Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2857c79
Add debug
michael-lefebvre Aug 8, 2018
c038382
tweak flow types and bump
unity Aug 10, 2018
0a1ef35
Prettier
unity Aug 10, 2018
af4b113
be consistent with what's in the documentation
unity Aug 10, 2018
85ec465
prettier, flow, lint-staged enforced on each commit
unity Aug 10, 2018
6051a8d
apply `prettier`
unity Aug 10, 2018
f38ce8f
formatting
unity Aug 10, 2018
06f7c82
fix changelog and revert `fix` to be consistent with tests
unity Aug 10, 2018
795429b
update ignores & prettify
unity Aug 10, 2018
7c51e82
don't auto-prettify code. bad manners
unity Aug 10, 2018
7cd960e
Make Claims Flow typing open, and ensure `anonymous_id` is supported …
unity Aug 12, 2018
8e1a747
Accounts support anonymous IDs
unity Aug 13, 2018
7ee2e62
disable docs for now
unity Aug 13, 2018
d0d843c
add missing field
unity Aug 23, 2018
bb17fcc
Update author and node versions
unity Sep 25, 2018
c5decab
update dependencies, and cleanup
unity Sep 25, 2018
5dc542e
Tweak and improve Flow types
unity Sep 25, 2018
dee2b6a
We can just assign the property here.
unity Sep 25, 2018
cc16a2f
tweak var names
unity Sep 25, 2018
983638d
flow types
unity Sep 25, 2018
a040fed
readd precommit hook
unity Sep 25, 2018
1eb80aa
tweak Types
unity Oct 1, 2018
5ea3f99
Merge branch 'feature/enforce-code-style' of github.com:hull/hull-cli…
unity Oct 1, 2018
e266e5c
mocha.opts
unity Oct 2, 2018
d2bfabb
lint
unity Oct 2, 2018
7c89c97
return a new config object, don't mutate the previous one.
unity Oct 2, 2018
3a5100f
wording
unity Oct 2, 2018
6c7ed47
flow typing, and fix LogArray logggin
unity Oct 3, 2018
06eb080
linting, deprecate `hull.asUser(id)` syntax, fix Minihull methods
unity Oct 3, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
{
"plugins": ["transform-flow-comments", ["transform-object-rest-spread", { "useBuiltIns": true }]]
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
],
"@babel/preset-flow"
],
"plugins": [
"@babel/plugin-transform-flow-comments"
]
}
63 changes: 41 additions & 22 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,34 +1,53 @@
{
"parser": "babel-eslint",
"globals": {},
"env": {
"es6": true,
"node": true
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"comma-dangle": [0],
"max-len": [0],
"camelcase": [0],
"quotes": [2, "double"],
"prefer-arrow-callback": [0],
"new-cap": [0],
"no-underscore-dangle": [0],
"arrow-body-style" : [0],
"no-param-reassign" : [0],
"no-console": [0],
"eqeqeq": [1],
"prefer-destructuring": [0],
"class-methods-use-this": [0],
"flowtype-errors/show-errors": 2,
"spaced-comment": ["error", "always", { "markers": [":", "::"] }],
"no-use-before-define": ["error", { "classes": false }]
"settings": {
"ecmascript": 6,
"jsx": true,
"import/extensions": [".js", ".jsx"],
"flowtype": {
"onlyFilesWithFlowAnnotation": true
}
},
"extends": [
"airbnb-base",
"eslint:recommended",
"prettier",
"prettier/flowtype",
"prettier/standard",
"plugin:flowtype/recommended"
],
"plugins": [
"prettier",
"flowtype",
"flowtype-errors"
],
"env": {
"node": true,
"browser": true,
"commonjs": true,
"worker": true,
"mongo": true,
"es6": true
},
"rules": {
"strict": 0,
"camelcase": [0],
"class-methods-use-this": [0],
"no-underscore-dangle": [0],
"no-console": [1],
"eqeqeq": [1],
"new-cap": [1],
"no-param-reassign": [1],
"no-unused-vars": [1],
"prefer-arrow-callback": [1],
"prefer-destructuring": [1],
"flowtype-errors/show-errors": [2],
"no-use-before-define": ["error", { "classes": false }]
}
}
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ flow-typed
all=warn

[options]
include_warnings=true
include_warnings=false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
node_modules
.env
.env.sh
/lib
*tgz
Expand Down
45 changes: 22 additions & 23 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

HullClient instance constructor - creates new instance to perform API calls, issue traits/track calls and log information

**Parameters**
### Parameters

- `config` **[Object][1]** configuration object
- `config.id` **[string][2]** Connector ID - required
Expand All @@ -20,7 +20,7 @@ HullClient instance constructor - creates new instance to perform API calls, iss
- `config.logs` **[Array][4]?** an optional array to capture all logs entries, you can provide your own array or use `captureLogs` to initiate empty one
- `config.firehoseEvents` **[Array][4]?** an optional array to capture all firehose events, you can provide your own array or use `captureFirehoseEvents` to initiate empty one

**Examples**
### Examples

```javascript
const HullClient = require("hull-client");
Expand All @@ -35,7 +35,7 @@ const hullClient = new HullClient({

Returns the global configuration object.

**Examples**
#### Examples

```javascript
const hullClient = new HullClient({});
Expand All @@ -57,7 +57,7 @@ Returns **[Object][1]** current `HullClient` configuration parameters
Takes User Claims (link to User Identity docs) and returnes `HullClient` instance scoped to this User.
This makes [#traits][5] and [#track][6] methods available.

**Parameters**
#### Parameters

- `userClaim` **[Object][1]**
- `additionalClaims` **[Object][1]** (optional, default `{}`)
Expand All @@ -72,10 +72,9 @@ Returns **[UserScopedHullClient][8]**

### asAccount

Takes Account Claims (link to User Identity docs) and returnes `HullClient` instance scoped to this Account.
This makes [#traits][5] method available.

**Parameters**
#### Parameters

- `accountClaim` **[Object][1]**
- `additionalClaims` **[Object][1]** (optional, default `Object.freeze({})`)
Expand All @@ -93,7 +92,7 @@ The following methods are available when `HullClient` instance is scoped to an u
How to get scoped client? Use `asUser` or `asAccount` methods.
The `EntityScopedHullClient` is never directly returned by the HullClient but is a base class for UserScopedHullClient and AccountScopedHullClient classes.

**Examples**
### Examples

```javascript
const hullClient = new HullClient({ id, secret, organization });
Expand All @@ -107,11 +106,11 @@ Used for [Bring your own users][10].
Creates a signed string for the user passed in hash. `userHash` needs an `email` field.
[You can then pass this client-side to Hull.js][11] to authenticate users client-side and cross-domain

**Parameters**
#### Parameters

- `claims` **[Object][1]** additionalClaims

**Examples**
#### Examples

```javascript
hullClient.asUser({ email: "xxx@example.com", external_id: "1234" }).token(optionalClaims);
Expand All @@ -124,7 +123,7 @@ Returns **[string][2]** token

Saves attributes on the user or account. Only available on User or Account scoped `HullClient` instance (see [#asuser][12] and [#asaccount][13]).

**Parameters**
#### Parameters

- `traits` **[Object][1]** object with new attributes, it's always flat object, without nested subobjects

Expand All @@ -137,7 +136,7 @@ Returns **[Promise][14]**
The following methods are available when `HullClient` instance is scoped to an user only
How to get scoped client? Use `asUser` method

**Examples**
### Examples

```javascript
const hullClient = new HullClient({ id, secret, organization });
Expand All @@ -150,7 +149,7 @@ scopedHullClient.traits({ new_attribute: "new_value" });
Available only for User scoped `HullClient` instance (see [#asuser][12]).
Returns `HullClient` instance scoped to both User and Account, but all traits/track call would be performed on the User, who will be also linked to the Account.

**Parameters**
#### Parameters

- `accountClaim` **[Object][1]** [description] (optional, default `Object.freeze({})`)

Expand All @@ -160,7 +159,7 @@ Returns **[HullClient][15]** HullClient scoped to a User and linked to an Accoun

Issues an `alias` event on user?

**Parameters**
#### Parameters

- `body` **[Object][1]**

Expand All @@ -170,7 +169,7 @@ Returns **[Promise][14]**

Stores events on user. Only available on User scoped `HullClient` instance (see [#asuser][12]).

**Parameters**
#### Parameters

- `event` **[string][2]** event name
- `properties` **[Object][1]** additional information about event, this is a one-level JSON object (optional, default `{}`)
Expand All @@ -190,7 +189,7 @@ Returns **[Promise][14]**

This is a class returned when we scope client to account. It provides `token` and `traits` methods.

**Examples**
### Examples

```javascript
const hullClient = new HullClient({ id, secret, organization });
Expand All @@ -207,7 +206,7 @@ Their are available on base `HullClient` and all scoped classes.

Performs a HTTP request on selected url of Hull REST API (prefixed with `prefix` param of the constructor)

**Parameters**
#### Parameters

- `url` **[string][2]**
- `method` **[string][2]**
Expand All @@ -220,7 +219,7 @@ Performs a HTTP request on selected url of Hull REST API (prefixed with `prefix`

Performs a GET HTTP request on selected url of Hull REST API (prefixed with `prefix` param of the constructor)

**Parameters**
#### Parameters

- `url` **[string][2]**
- `params` **[Object][1]?**
Expand All @@ -232,7 +231,7 @@ Performs a GET HTTP request on selected url of Hull REST API (prefixed with `pre

Performs a POST HTTP request on selected url of Hull REST API (prefixed with `prefix` param of the constructor

**Parameters**
#### Parameters

- `url` **[string][2]**
- `params` **[Object][1]?**
Expand All @@ -244,7 +243,7 @@ Performs a POST HTTP request on selected url of Hull REST API (prefixed with `pr

Performs a DELETE HTTP request on selected url of Hull REST API (prefixed with `prefix` param of the constructor)

**Parameters**
#### Parameters

- `url` **[string][2]**
- `params` **[Object][1]?**
Expand All @@ -256,7 +255,7 @@ Performs a DELETE HTTP request on selected url of Hull REST API (prefixed with `

Performs a PUT HTTP request on selected url of Hull REST API (prefixed with `prefix` param of the constructor)

**Parameters**
#### Parameters

- `url` **[string][2]**
- `params` **[Object][1]?**
Expand All @@ -280,7 +279,7 @@ Updates `private_settings` merging them with existing ones before.

Note: this method will trigger `hullClient.put` and will result in `ship:update` notify event coming from Hull platform - possible loop condition.

**Parameters**
#### Parameters

- `newSettings` **[Object][1]** settings to update

Expand All @@ -291,11 +290,11 @@ Returns **[Promise][14]**
The Hull API returns traits in a "flat" format, with '/' delimiters in the key.
This method can be used to group those traits into subobjects:

**Parameters**
#### Parameters

- `user` **[Object][1]** flat object

**Examples**
#### Examples

```javascript
hullClient.utils.traits.group({
Expand Down
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
# CHANGELOG

## 2.0.0-rc1
* Removed and deprecated hull.asUser("id") syntax. Use: hull.asUser({ id: id })
* winston 3 -> https://github.com/winstonjs/winston/blob/master/UPGRADE-3.0.md
* babel 7
* update dependencies
* add `yarn watch` rask to build continuously. Use with `yarn link hull-client`
* add `debug` - Logs all calls to the REST api when active.
* tweak Flow types
* be more strict with code style, enforce flow, prettier + lint at each commit.
* fix CHANGELOG to be consistent with actual code behaviour for `firehoseEventsArray`

## 2.0.0-beta.3
* fix missing flow types
* documentation adjustments

## 2.0.0-beta.2
* adds experimental `logsArray` and `firehoseEventsArray` to additionally capture log lines and firehose events to separate arrays.
CAUTION: this does not disable normal behaviour of the libary
* adds experimental `logsArray` and `firehoseEventsArray` to capture log lines and firehose events to separate arrays.
CAUTION: this DOES disable normal behaviour of the libary
* fix retry callback errors

## 2.0.0-beta.1
Expand Down
4 changes: 4 additions & 0 deletions mocha.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--compilers js:@babel/register
--exit
--require @babel/register
-R spec
Loading