Skip to content

Commit 0b4c123

Browse files
authored
Merge pull request #434 from kuzzleio/6.2.0-proposal
# [6.2.0](https://github.com/kuzzleio/sdk-javascript/releases/tag/6.2.0) (2019-07-31) #### Bug fixes - [ [#428](#428) ] Properly handle boolean flags in HTTP querystrings ([scottinet](https://github.com/scottinet)) - [ [#427](#427) ] Solve promise+event+memory leaks when the network fails ([scottinet](https://github.com/scottinet)) - [ [#424](#424) ] Prevent pending request leak when disconnect the SDK ([Aschen](https://github.com/Aschen)) - [ [#422](#422) ] Fix bug when decoding JWT in browser ([Aschen](https://github.com/Aschen)) - [ [#420](#420) ] Fix http protocol unresolved promise on connection error ([Aschen](https://github.com/Aschen)) #### New features - [ [#419](#419) ] Add bulk:write and bulk:mWrite ([Aschen](https://github.com/Aschen)) #### Enhancements - [ [#421](#421) ] Get api routes from server:publicApi ([Aschen](https://github.com/Aschen)) - [ [#423](#423) ] Emit queryError event on malformed request ([Aschen](https://github.com/Aschen)) - [ [#417](#417) ] Security controller documentation ([benoitvidis](https://github.com/benoitvidis)) ---
2 parents 58d7837 + b8129a0 commit 0b4c123

File tree

171 files changed

+6995
-8818
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+6995
-8818
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"semi": [2, "always"],
4747
"keyword-spacing": 2,
4848
"space-before-blocks": 2,
49-
"space-in-parens": [2, "never"],
49+
"space-in-parens": [0, "never"],
5050
"vars-on-top": 2,
5151
"yoda": [2, "never"]
5252
},

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ examples/node_modules/
1414

1515
# Compiled files
1616
coverage/
17+
18+
doc/framework
19+
dead_links.json

.travis.yml

Lines changed: 81 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
sudo: true
22

3+
env:
4+
global:
5+
- AWS_ACCESS_KEY_ID=AKIAIYAXFUAHXOWP2MJA
6+
# AWS_SECRET_ACCESS_KEY
7+
- secure: "HU48VGBdv/GyVAm6g8eiA3DbKoAPL98AeORbF7UhKLQenxmQRGb1gfdMPNLdop35+95SlxcFC9ogoHcqLBSPLLcTSX57faWpNacD/7j69Z03avgdmfaFOGMOwGd5tOdq4pYmis34xyGJW1kpwAl2U6jp/pcBXABDnCLfRS5kJUsXvrwdE75UACoXQ1tXEtqq9y5LcFo/dGYrhuVvqYQmAUA+ExrfXaIKtUSf2tN5CvYL0cSxLyoQlnbbIQvouyNRyfuGFqNHc3jyBOc/nZWHS0ES91+6ddwZs/i9Fs98TfB3JS9x+gKYWrhDmxek/fOy22+qYUHQ81txk4SQ3GILWiWTfWOTdsBU+Y0FYnC5syLAqpdIstBhmMUUS8NWs5HdYmBv4q0zkTiwBGL/wrLwXkAcLLKUNOrUeMAL1fjQuVRC3hzql15s/A2LwPOR6xwyCu1mH8GKogYulGVWOEHQuk8bC3MaKgDr/4ZoUlCC9Q+mYP/WT+t/NA/0OQIvZVhVVilXk1MTbQMkvrBSuiuxACsyFGVNrkLaC8x2Pjyd2kgZaIv4c2JiiWfvW5IZd7xeyLLKESOfHP8rIf60jmvE7hxD9Yje7JXjo0uvnpEGx2PuMSq5zeUynoLaa8AIMAJ9an3fgdfKKcZ/XPOCAgpmxnKH+leAQx86qwxdAAIkgPY="
8+
39
jobs:
410
include:
5-
- name: Sdk tests
6-
stage: Tests
7-
sudo: false
11+
- stage: Tests
12+
name: Unit Tests
13+
if: type = pull_request OR type = push AND branch =~ /^master|[0-9]+-(dev|stable)$/ OR type = cron
814
language: node_js
915
node_js: 8
1016

@@ -76,13 +82,80 @@ jobs:
7682

7783
before_script:
7884
- npm run doc-prepare
79-
- npm run --prefix doc/framework clone-repos
85+
- npm run --prefix doc/framework repositories -- clone
86+
script:
87+
- gem install typhoeus
88+
- HYDRA_MAX_CONCURRENCY=20 npm run --prefix doc/framework dead-links
89+
90+
91+
- stage: Deployment Doc Dev
92+
name: Deploy next-docs.kuzzle.io
93+
if: type = push AND branch =~ .*-dev
94+
language: node_js
95+
node_js: 10
96+
env:
97+
- NODE_ENV=production
98+
- S3_BUCKET=docs-next.kuzzle.io
99+
- CLOUDFRONT_DISTRIBUTION_ID=E2ZCCEK9GRB49U
100+
- AWS_DEFAULT_REGION=us-west-2
101+
102+
addons:
103+
apt:
104+
packages:
105+
- python
106+
- python-pip
107+
108+
install:
109+
- pip install awscli --upgrade --user
110+
80111
script:
81-
- npm run --prefix doc/framework dead-links
112+
- npm run doc-prepare
113+
- npm run doc-build
114+
115+
deploy:
116+
provider: script
117+
script:
118+
- npm run doc-upload
119+
skip_cleanup: true
82120

121+
after_deploy:
122+
- npm run doc-cloudfront
123+
124+
# - stage: Deployment Doc Prod
125+
# name: Deploy docs.kuzzle.io
126+
# if: type = push AND branch =~ /^master|[0-9]+-stable$/
127+
# language: node_js
128+
# node_js: 10
129+
# env:
130+
# - NODE_ENV=production
131+
# - S3_BUCKET=docs.kuzzle.io
132+
# - CLOUDFRONT_DISTRIBUTION_ID=E3D6RP0POLCJMM
133+
# - AWS_DEFAULT_REGION=us-west-2
134+
135+
# addons:
136+
# apt:
137+
# packages:
138+
# - python
139+
# - python-pip
140+
141+
# install:
142+
# - pip install awscli --upgrade --user
143+
144+
# script:
145+
# - npm run doc-prepare
146+
# - npm run doc-build
147+
148+
# deploy:
149+
# provider: script
150+
# script:
151+
# - npm run doc-upload
152+
# skip_cleanup: true
153+
154+
# after_deploy:
155+
# - npm run doc-cloudfront
83156

84157
- stage: Deploy Stable release on NPM
85-
if: branch = master AND tag IS present AND type != cron
158+
if: branch =~ /^master|[0-9]+-stable$/ AND tag IS present AND type != cron
86159
sudo: false
87160
language: node_js
88161
node_js: 8
@@ -110,13 +183,9 @@ jobs:
110183
111184
api_key:
112185
secure: ktfR6QVV59uCVLTfb60JSjPxzxg+UYe63pIGxU9awh1wJW89SQqQdeshHas3ojwrNoMOVybx/L6owtD8uIB4Xlau6pd7StBAA1VQ3vLa6RxU5SUr9VOz3RhZutRnYXH28Ziz/ynr6zVnwGxTzFsxBAdQ9CVS3ErBzliTgMVI+52YRNB3mBDiccSKVNGmp2APiWiaEidrmaOFkCwWQKsAxFTbBoCsDYGGAq8a8b1i2nE+BL4JWB1D2x55xzFaciDIQONXnY9YPAAbzCHBTKAne5iD6XwFj7Zg/42fHTn16LBSG+Sw+7aWyV11U6SJYKAjm/5GZEUrbvX/mwNQ7VYcvMStiP1nnt/L/s/Y7d0K3mwdsV8U8RCctElOeqLsDqoBzQYAxHTqRqJzyFNMcbcMhZgsHH5LgQDoJdKFwzP2ysYoazgm/jnr9atvlqucjWU8madRS34S8wD0zGjYf8VXH3WMUvL5mFwtb58FRCZKO3G7QJlGE8bdZ8CfJa/1tFnYY9SA0018GaXbh0RqQw0RskbmXEKTlnDBxaRd/ZjfaOjF4JcMGGZ8hsCRjxuDFY5Ki0kKDAlDV1W40fkkqPVm8k9H8Elwt0UFZvvAdjG4c+gV0zdAKHQ7P6uKvXiDlsKRHulE3Ztpo6jqGN69s7aLm6DKNVsaE4cNmmUOv3ODrM4=
113-
on:
114-
repo: kuzzleio/sdk-javascript
115-
all_branches: true
116-
condition: $TRAVIS_BRANCH = master
117186

118-
- stage: "Deploy Beta release on NPM"
119-
if: type != pull_request && branch =~ ^[0-9]+-beta$
187+
- stage: Deploy Beta release on NPM
188+
if: type = push && branch =~ /^[0-9]+-dev$/
120189
sudo: false
121190
language: node_js
122191
node_js: 8

bug.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const Kuzzle = require('./index').Kuzzle;
2+
3+
4+
const kuzzle = new Kuzzle('websocket', {host: 'localhost'});
5+
6+
async function run() {
7+
await kuzzle.connect();
8+
const roomID = await kuzzle.realtime.subscribe('obix', 'firmwares', {}, (r) => {
9+
console.log(r);
10+
})
11+
12+
await kuzzle.realtime.publish('obix', 'firmware', {msg: 'hello world'})
13+
}
14+
15+
run()

doc/6/.vuepress

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../framework/src/.vuepress/
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
code: true
3+
type: page
4+
title: mWrite
5+
description: Creates or replaces multiple documents directly into the storage engine.
6+
---
7+
8+
# mWrite
9+
10+
<SinceBadge version="6.2.0" />
11+
12+
<SinceBadge version="Kuzzle 1.8.0" />
13+
14+
Creates or replaces multiple documents directly into the storage engine.
15+
16+
This is a low level route intended to bypass Kuzzle actions on document creation, notably:
17+
- check [document validity](/core/1/guides/essentials/data-validation),
18+
- add [kuzzle metadata](/core/1/guides/essentials/document-metadata),
19+
- trigger [realtime notifications](/core/1/guides/essentials/real-time) (unless asked otherwise)
20+
21+
<br/>
22+
23+
```js
24+
mWrite (index, collection, documents, [options])
25+
```
26+
27+
<br/>
28+
29+
| Argument | Type | Description |
30+
| ------------ | ----------------- | -------------------- |
31+
| `index` | <pre>string</pre> | Index name |
32+
| `collection` | <pre>string</pre> | Collection name |
33+
| `documents` | <pre>object[]</pre> | Array of objects representing the documents |
34+
| `options` | <pre>object</pre> | Query options |
35+
36+
### documents
37+
38+
An array of objects. Each object describes a document to create or replace, by exposing the following properties:
39+
- `_id`: document unique identifier (optional)
40+
- `body`: document content
41+
42+
### options
43+
44+
Additional query options
45+
46+
| Property | Type<br/>(default) | Description |
47+
| ---------- | ------------------------------- | ------------------ |
48+
| `queuable` | <pre>boolean</pre><br/>(`true`) | If true, queues the request during downtime, until connected to Kuzzle again |
49+
| `notify` | <pre>boolean</pre><br/>(`false`) | if set to true, Kuzzle will trigger realtime notifications |
50+
| `refresh` | <pre>string</pre><br/>(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) |
51+
52+
---
53+
54+
## Resolves
55+
56+
Returns a `hits` array, containing the list of created documents, in the same order than the one provided in the query.
57+
58+
Each created document is an object with the following properties:
59+
60+
| Name | Type | Description |
61+
| --------- | ----------------- | ------------------- |
62+
| `_id` | <pre>string</pre> | ID of the newly created document |
63+
| `_version` | <pre>number</pre> | Version of the document in the persistent data storage |
64+
| `_source` | <pre>object</pre> | Created document |
65+
66+
If one or more document creations fail, the promise is rejected and the `error` object contains a [partial error](/core/1/api/essentials/errors/#partialerror) error.
67+
68+
## Usage
69+
70+
<<< ./snippets/mWrite.js
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
try {
2+
const documents = [
3+
{
4+
_id: 'panipokari',
5+
body: {
6+
licence: 'B',
7+
_kuzzle_info: { creator: 'bahi', createdAt: 746186305 }
8+
}
9+
},
10+
{
11+
body: {
12+
licence: 'B',
13+
_kuzzle_info: { creator: 'dahi', createdAt: 835005505 }
14+
}
15+
}
16+
];
17+
18+
const result = await kuzzle.bulk.mWrite(
19+
'nyc-open-data',
20+
'yellow-taxi',
21+
documents
22+
);
23+
24+
console.log(result);
25+
/*
26+
{ hits:
27+
[ { _id: 'panipokari',
28+
_source: {
29+
"licence": "B",
30+
"_kuzzle_info": {
31+
"creator": "bahi",
32+
"createdAt": 746186305 } },
33+
_version: 1 },
34+
{ _id: 'AWvlrMIZE7sKlamkyoHr',
35+
_source: {
36+
"licence": "B",
37+
"_kuzzle_info": {
38+
"creator": "dahi",
39+
"createdAt": 835005505 } },
40+
_version: 1 } ],
41+
total: 2 }
42+
*/
43+
44+
console.log(`Document creator is ${result.hits[1]._source._kuzzle_info.creator}`);
45+
} catch (error) {
46+
console.error(error.message);
47+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: bulk#mWrite
3+
description: Creates or replaces multiple documents directly into the storage engine.
4+
hooks:
5+
before: |
6+
curl -X DELETE kuzzle:7512/nyc-open-data
7+
curl -X POST kuzzle:7512/nyc-open-data/_create
8+
curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi
9+
template: default
10+
expected: Document creator is dahi
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
code: true
3+
type: page
4+
title: write
5+
description: Creates or replaces a document directly into the storage engine.
6+
---
7+
8+
# write
9+
10+
<SinceBadge version="6.2.0" />
11+
12+
<SinceBadge version="Kuzzle 1.8.0" />
13+
14+
Creates or replaces a document directly into the storage engine.
15+
16+
This is a low level route intended to bypass Kuzzle actions on document creation, notably:
17+
- check [document validity](/core/1/guides/essentials/data-validation),
18+
- add [kuzzle metadata](/core/1/guides/essentials/document-metadata),
19+
- trigger [realtime notifications](/core/1/guides/essentials/real-time) (unless asked otherwise).
20+
21+
<br/>
22+
23+
```js
24+
write (index, collection, document, [id], [options])
25+
```
26+
27+
<br/>
28+
29+
| Argument | Type | Description |
30+
| ------------ | ----------------- | -------------------- |
31+
| `index` | <pre>string</pre> | Index name |
32+
| `collection` | <pre>string</pre> | Collection name |
33+
| `document` | <pre>object</pre> | Document content |
34+
| `id` | <pre>string</pre> | Optional document ID |
35+
| `options` | <pre>object</pre> | Query options |
36+
37+
### options
38+
39+
Additional query options
40+
41+
| Property | Type<br/>(default) | Description |
42+
| ---------- | ------------------------------- | ------------------ |
43+
| `queuable` | <pre>boolean</pre><br/>(`true`) | If true, queues the request during downtime, until connected to Kuzzle again |
44+
| `notify` | <pre>boolean</pre><br/>(`false`) | if set to true, Kuzzle will trigger realtime notifications |
45+
| `refresh` | <pre>string</pre><br/>(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) |
46+
47+
---
48+
49+
## Resolves
50+
51+
Resolves to an object containing the document creation result.
52+
53+
| Name | Type | Description |
54+
| --------- | ----------------- | ------------------------------------------------------ |
55+
| `_id` | <pre>string</pre> | ID of the newly created document |
56+
| `_version` | <pre>number</pre> | Version of the document in the persistent data storage |
57+
| `_source` | <pre>object</pre> | Created document |
58+
59+
## Usage
60+
61+
<<< ./snippets/write.js
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
try {
2+
const document = {
3+
licence: 'B',
4+
_kuzzle_info: {
5+
creator: 'liia',
6+
createdAt: 653132233
7+
}
8+
};
9+
10+
const result = await kuzzle.bulk.write(
11+
'nyc-open-data',
12+
'yellow-taxi',
13+
document
14+
);
15+
16+
console.log(result);
17+
/*
18+
{ _id: 'AWvljct6E7sKlamkyoHl',
19+
_version: 1,
20+
_source:
21+
{ licence: 'B',
22+
_kuzzle_info: { creator: 'liia', createdAt: 653132233 } }
23+
*/
24+
25+
console.log(`Document creator is ${result._source._kuzzle_info.creator}`);
26+
} catch (error) {
27+
console.error(error.message);
28+
}

0 commit comments

Comments
 (0)