kuzzle 2.16.0 → 2.16.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/httpRoutes.js +1 -1
- package/lib/api/openApiGenerator.d.ts +2 -1
- package/lib/api/openApiGenerator.js +28 -30
- package/lib/api/openapi/document/count.yaml +47 -0
- package/lib/api/openapi/document/create.yaml +46 -0
- package/lib/api/openapi/document/createOrReplace.yaml +61 -0
- package/lib/api/openapi/document/delete.yaml +67 -0
- package/lib/api/openapi/document/deleteByQuery.yaml +90 -0
- package/lib/api/openapi/document/exists.yaml +35 -0
- package/lib/api/openapi/document/get.yaml +68 -0
- package/lib/api/openapi/{documents/document.d.ts → document/index.d.ts} +0 -1
- package/lib/api/openapi/{documents/document.js → document/index.js} +13 -15
- package/lib/api/openapi/document/replace.yaml +66 -0
- package/lib/api/openapi/document/scroll.yaml +49 -0
- package/lib/api/openapi/document/update.yaml +78 -0
- package/lib/api/openapi/index.d.ts +2 -0
- package/lib/api/openapi/index.js +18 -0
- package/lib/api/openapi/payloads.yaml +32 -0
- package/lib/api/request/kuzzleRequest.d.ts +64 -30
- package/lib/api/request/kuzzleRequest.js +135 -29
- package/lib/api/request/requestContext.d.ts +22 -17
- package/lib/api/request/requestContext.js +109 -44
- package/lib/api/request/requestInput.d.ts +24 -19
- package/lib/api/request/requestInput.js +175 -115
- package/lib/api/request/requestResponse.d.ts +8 -12
- package/lib/api/request/requestResponse.js +29 -35
- package/lib/core/backend/backendController.js +0 -3
- package/lib/core/plugin/plugin.js +18 -8
- package/lib/core/plugin/pluginsManager.js +2 -4
- package/lib/kuzzle/kuzzle.js +5 -9
- package/lib/{api/openapi/tools.d.ts → util/readYamlFile.d.ts} +1 -1
- package/lib/{api/openapi/tools.js → util/readYamlFile.js} +1 -1
- package/package-lock.json +22 -22
- package/package.json +6 -21
- package/.kuzzlerc.sample +0 -988
- package/CONTRIBUTING.md +0 -116
- package/bin/.lib/colorOutput.js +0 -71
- package/bin/.upgrades/connectors/es.js +0 -90
- package/bin/.upgrades/connectors/redis.js +0 -112
- package/bin/.upgrades/lib/connectorContext.js +0 -38
- package/bin/.upgrades/lib/context.js +0 -142
- package/bin/.upgrades/lib/formatters.js +0 -103
- package/bin/.upgrades/lib/inquirerExtended.js +0 -46
- package/bin/.upgrades/lib/logger.js +0 -99
- package/bin/.upgrades/lib/progressBar.js +0 -70
- package/bin/.upgrades/versions/v1/checkConfiguration.js +0 -85
- package/bin/.upgrades/versions/v1/index.js +0 -35
- package/bin/.upgrades/versions/v1/upgradeCache.js +0 -149
- package/bin/.upgrades/versions/v1/upgradeStorage.js +0 -450
- package/protocols/available/.gitignore +0 -4
- package/protocols/enabled/.gitignore +0 -4
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
DocumentReplace:
|
|
2
|
+
summary: "Replaces the content of an existing document."
|
|
3
|
+
tags:
|
|
4
|
+
- document
|
|
5
|
+
parameters:
|
|
6
|
+
- in: path
|
|
7
|
+
name: index
|
|
8
|
+
schema:
|
|
9
|
+
type: string
|
|
10
|
+
required: true
|
|
11
|
+
- in: path
|
|
12
|
+
name: collection
|
|
13
|
+
schema:
|
|
14
|
+
type: string
|
|
15
|
+
required: true
|
|
16
|
+
- in: path
|
|
17
|
+
name: documentId
|
|
18
|
+
schema:
|
|
19
|
+
type: string
|
|
20
|
+
required: true
|
|
21
|
+
- in: path
|
|
22
|
+
name: refresh
|
|
23
|
+
schema:
|
|
24
|
+
type: string
|
|
25
|
+
description: " if set to wait_for, Kuzzle will not respond until the deletion has been indexed"
|
|
26
|
+
required: false
|
|
27
|
+
- in: path
|
|
28
|
+
name: silent
|
|
29
|
+
schema:
|
|
30
|
+
type: boolean
|
|
31
|
+
description: "if set, then Kuzzle will not generate notifications. Available since 2.9.2"
|
|
32
|
+
required: false
|
|
33
|
+
- name: body
|
|
34
|
+
in: "body"
|
|
35
|
+
description: "Replaces the content of an existing document."
|
|
36
|
+
required: true
|
|
37
|
+
schema:
|
|
38
|
+
$ref: "#/components/schemas/DocumentReplaceRequest"
|
|
39
|
+
responses:
|
|
40
|
+
200:
|
|
41
|
+
description: "Replaces the content of an existing document."
|
|
42
|
+
schema:
|
|
43
|
+
$ref: "#/components/schemas/DocumentReplaceResponse"
|
|
44
|
+
|
|
45
|
+
components:
|
|
46
|
+
schemas:
|
|
47
|
+
DocumentReplaceRequest:
|
|
48
|
+
allOf:
|
|
49
|
+
- type: "object"
|
|
50
|
+
description: "new document content"
|
|
51
|
+
DocumentReplaceResponse:
|
|
52
|
+
allOf:
|
|
53
|
+
- $ref: "#/components/ResponsePayload"
|
|
54
|
+
- type: "object"
|
|
55
|
+
properties:
|
|
56
|
+
result:
|
|
57
|
+
type: "object"
|
|
58
|
+
properties:
|
|
59
|
+
_id:
|
|
60
|
+
type: "string"
|
|
61
|
+
description: "documentId"
|
|
62
|
+
_version:
|
|
63
|
+
type: "integer"
|
|
64
|
+
_sources:
|
|
65
|
+
type: "object"
|
|
66
|
+
description: "new document content"
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
DocumentScroll:
|
|
2
|
+
summary: "Moves a search cursor forward."
|
|
3
|
+
tags:
|
|
4
|
+
- document
|
|
5
|
+
parameters:
|
|
6
|
+
- in: path
|
|
7
|
+
name: "scrollId"
|
|
8
|
+
schema:
|
|
9
|
+
type: integer
|
|
10
|
+
description: "cursor unique identifier, obtained by either a search or a scroll query"
|
|
11
|
+
required: true
|
|
12
|
+
- in: path
|
|
13
|
+
name: "scroll"
|
|
14
|
+
schema:
|
|
15
|
+
type: integer
|
|
16
|
+
description: "refresh the cursor duration, using the time to live syntax."
|
|
17
|
+
required: false
|
|
18
|
+
responses:
|
|
19
|
+
200:
|
|
20
|
+
description: "Moves a search cursor forward."
|
|
21
|
+
schema:
|
|
22
|
+
$ref: "#/components/schemas/DocumentScrollResponse"
|
|
23
|
+
|
|
24
|
+
components:
|
|
25
|
+
schemas:
|
|
26
|
+
DocumentScrollResponse:
|
|
27
|
+
allOf:
|
|
28
|
+
- $ref: "#/components/ResponsePayload"
|
|
29
|
+
- type: "object"
|
|
30
|
+
properties:
|
|
31
|
+
result:
|
|
32
|
+
type: "object"
|
|
33
|
+
properties:
|
|
34
|
+
scrollId:
|
|
35
|
+
type: "string"
|
|
36
|
+
total:
|
|
37
|
+
type: "integer"
|
|
38
|
+
hits:
|
|
39
|
+
type: "array"
|
|
40
|
+
items:
|
|
41
|
+
type: "object"
|
|
42
|
+
properties:
|
|
43
|
+
_id:
|
|
44
|
+
type: "string"
|
|
45
|
+
_score:
|
|
46
|
+
type: "integer"
|
|
47
|
+
_source:
|
|
48
|
+
type: "object"
|
|
49
|
+
description: "document content"
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
DocumentUpdate:
|
|
2
|
+
summary: "Updates a document content."
|
|
3
|
+
tags:
|
|
4
|
+
- document
|
|
5
|
+
parameters:
|
|
6
|
+
- in: path
|
|
7
|
+
name: index
|
|
8
|
+
schema:
|
|
9
|
+
type: string
|
|
10
|
+
required: true
|
|
11
|
+
- in: path
|
|
12
|
+
name: collection
|
|
13
|
+
schema:
|
|
14
|
+
type: string
|
|
15
|
+
required: true
|
|
16
|
+
- in: path
|
|
17
|
+
name: _id
|
|
18
|
+
schema:
|
|
19
|
+
type: string
|
|
20
|
+
required: true
|
|
21
|
+
- in: path
|
|
22
|
+
name: refresh
|
|
23
|
+
schema:
|
|
24
|
+
type: string
|
|
25
|
+
description: "if set to wait_for, Kuzzle will not respond until the deletion has been indexed"
|
|
26
|
+
required: false
|
|
27
|
+
- in: path
|
|
28
|
+
name: silent
|
|
29
|
+
schema:
|
|
30
|
+
type: boolean
|
|
31
|
+
description: "if set, then Kuzzle will not generate notifications. Available since 2.9.2"
|
|
32
|
+
required: false
|
|
33
|
+
- in: path
|
|
34
|
+
name: source
|
|
35
|
+
schema:
|
|
36
|
+
type: boolean
|
|
37
|
+
required: false
|
|
38
|
+
description: "if set to true Kuzzle will return the entire updated document body in the response."
|
|
39
|
+
- in: path
|
|
40
|
+
name: retryOnConflict
|
|
41
|
+
schema:
|
|
42
|
+
type: integer
|
|
43
|
+
description: "conflicts may occur if the same document gets updated multiple times within a short timespan, in a database cluster. You can set the retryOnConflict optional argument (with a retry count), to tell Kuzzle to retry the failing updates the specified amount of times before rejecting the request with an error."
|
|
44
|
+
required: false
|
|
45
|
+
- name: body
|
|
46
|
+
in: "body"
|
|
47
|
+
description: "Updates a document content."
|
|
48
|
+
required: true
|
|
49
|
+
schema:
|
|
50
|
+
$ref: "#/components/schemas/DocumentUpdateRequest"
|
|
51
|
+
responses:
|
|
52
|
+
200:
|
|
53
|
+
description: "Updates a document content."
|
|
54
|
+
schema:
|
|
55
|
+
$ref: "#/components/schemas/DocumentUpdateResponse"
|
|
56
|
+
|
|
57
|
+
components:
|
|
58
|
+
schemas:
|
|
59
|
+
DocumentUpdateRequest:
|
|
60
|
+
allOf:
|
|
61
|
+
- type: "object"
|
|
62
|
+
description: "document changes"
|
|
63
|
+
DocumentUpdateResponse:
|
|
64
|
+
allOf:
|
|
65
|
+
- $ref: "#/components/ResponsePayload"
|
|
66
|
+
- type: "object"
|
|
67
|
+
properties:
|
|
68
|
+
result:
|
|
69
|
+
type: "object"
|
|
70
|
+
properties:
|
|
71
|
+
_id:
|
|
72
|
+
type: "string"
|
|
73
|
+
description: "documentId"
|
|
74
|
+
_version:
|
|
75
|
+
type: "integer"
|
|
76
|
+
_source:
|
|
77
|
+
type: string
|
|
78
|
+
description: "partial or entire document"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.OpenApiPayloadsDefinitions = void 0;
|
|
14
|
+
const readYamlFile_1 = require("../../util/readYamlFile");
|
|
15
|
+
__exportStar(require("./document"), exports);
|
|
16
|
+
// Document definitions (reusable object for KuzzleRequest and KuzzleResponse)
|
|
17
|
+
exports.OpenApiPayloadsDefinitions = (0, readYamlFile_1.readYamlFile)(__dirname + '/payloads.yaml').definitions;
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
definitions:
|
|
2
|
+
RequestPayload:
|
|
3
|
+
type: "object"
|
|
4
|
+
properties:
|
|
5
|
+
controller:
|
|
6
|
+
type: "string"
|
|
7
|
+
enum: "document"
|
|
8
|
+
action:
|
|
9
|
+
type: "string"
|
|
10
|
+
enum: "foo"
|
|
11
|
+
index:
|
|
12
|
+
type: "string"
|
|
13
|
+
collection:
|
|
14
|
+
type: "string"
|
|
15
|
+
ResponsePayload:
|
|
16
|
+
type: "object"
|
|
17
|
+
properties:
|
|
18
|
+
status:
|
|
19
|
+
type: "integer"
|
|
20
|
+
error:
|
|
21
|
+
type: "object"
|
|
22
|
+
index:
|
|
23
|
+
type: "string"
|
|
24
|
+
collection:
|
|
25
|
+
type: "string"
|
|
26
|
+
controller:
|
|
27
|
+
type: "string"
|
|
28
|
+
action:
|
|
29
|
+
type: "string"
|
|
30
|
+
requestId:
|
|
31
|
+
type: "integer"
|
|
32
|
+
description: "unique request identifie"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { JSONObject } from 'kuzzle-sdk';
|
|
2
2
|
import { RequestInput } from './requestInput';
|
|
3
|
+
import { RequestResponse } from './requestResponse';
|
|
3
4
|
import { RequestContext } from './requestContext';
|
|
4
5
|
import { KuzzleError } from '../../kerror/errors';
|
|
5
6
|
import { Deprecation, User } from '../../types';
|
|
@@ -12,46 +13,47 @@ import { Deprecation, User } from '../../types';
|
|
|
12
13
|
*/
|
|
13
14
|
export declare class KuzzleRequest {
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
+
* Request external ID (specified by "requestId" or random uuid)
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
+
id: string;
|
|
19
|
+
constructor(data: any, options: any);
|
|
18
20
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
* Request internal ID
|
|
22
|
+
*/
|
|
23
|
+
get internalId(): string;
|
|
22
24
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
* Deprecation warnings for the API action
|
|
26
|
+
*/
|
|
27
|
+
get deprecations(): Deprecation[] | void;
|
|
26
28
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
* Request timestamp (in Epoch-micro)
|
|
30
|
+
*/
|
|
31
|
+
get timestamp(): number;
|
|
30
32
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
* Request HTTP status
|
|
34
|
+
*/
|
|
35
|
+
get status(): number;
|
|
36
|
+
set status(i: number);
|
|
34
37
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
* Request input
|
|
39
|
+
*/
|
|
40
|
+
get input(): RequestInput;
|
|
38
41
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
* Request context
|
|
43
|
+
*/
|
|
44
|
+
get context(): RequestContext;
|
|
42
45
|
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
* Request error
|
|
47
|
+
*/
|
|
48
|
+
get error(): KuzzleError | null;
|
|
46
49
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
* Request result
|
|
51
|
+
*/
|
|
52
|
+
get result(): any | null;
|
|
50
53
|
/**
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
constructor(data: any, options: any);
|
|
54
|
+
* Request response
|
|
55
|
+
*/
|
|
56
|
+
get response(): RequestResponse;
|
|
55
57
|
/**
|
|
56
58
|
* Adds an error to the request, and sets the request's status to the error one.
|
|
57
59
|
*/
|
|
@@ -101,6 +103,38 @@ export declare class KuzzleRequest {
|
|
|
101
103
|
data: JSONObject;
|
|
102
104
|
options: JSONObject;
|
|
103
105
|
};
|
|
106
|
+
/**
|
|
107
|
+
* Return a POJO representing the request.
|
|
108
|
+
*
|
|
109
|
+
* This can be used to match Koncorde filter rather than the Request object
|
|
110
|
+
* because it has properties defined with invisible unicode characters.
|
|
111
|
+
*/
|
|
112
|
+
pojo(): {
|
|
113
|
+
context: {
|
|
114
|
+
connection: import("./requestContext").Connection;
|
|
115
|
+
token: import("../../types").Token;
|
|
116
|
+
user: User;
|
|
117
|
+
};
|
|
118
|
+
deprecations: void | Deprecation[];
|
|
119
|
+
error: KuzzleError;
|
|
120
|
+
id: string;
|
|
121
|
+
input: {
|
|
122
|
+
action: string;
|
|
123
|
+
args: JSONObject;
|
|
124
|
+
body: JSONObject;
|
|
125
|
+
controller: string;
|
|
126
|
+
jwt: string;
|
|
127
|
+
volatile: JSONObject;
|
|
128
|
+
};
|
|
129
|
+
internalId: string;
|
|
130
|
+
response: {
|
|
131
|
+
headers: JSONObject;
|
|
132
|
+
raw: boolean;
|
|
133
|
+
};
|
|
134
|
+
result: any;
|
|
135
|
+
status: number;
|
|
136
|
+
timestamp: number;
|
|
137
|
+
};
|
|
104
138
|
/**
|
|
105
139
|
* Returns the `lang` param of the request.
|
|
106
140
|
*
|
|
@@ -53,6 +53,17 @@ const kerror_1 = __importDefault(require("../../kerror"));
|
|
|
53
53
|
const assert = __importStar(require("../../util/assertType"));
|
|
54
54
|
const safeObject_1 = require("../../util/safeObject");
|
|
55
55
|
const assertionError = kerror_1.default.wrap('api', 'assert');
|
|
56
|
+
// private properties
|
|
57
|
+
// \u200b is a zero width space, used to masquerade console.log output
|
|
58
|
+
const _internalId = 'internalId\u200b';
|
|
59
|
+
const _status = 'status\u200b';
|
|
60
|
+
const _input = 'input\u200b';
|
|
61
|
+
const _error = 'error\u200b';
|
|
62
|
+
const _result = 'result\u200b';
|
|
63
|
+
const _context = 'context\u200b';
|
|
64
|
+
const _timestamp = 'timestamp\u200b';
|
|
65
|
+
const _response = 'response\u200b';
|
|
66
|
+
const _deprecations = 'deprecations\u200b';
|
|
56
67
|
/**
|
|
57
68
|
* The `KuzzleRequest` class represents a request being processed by Kuzzle.
|
|
58
69
|
*
|
|
@@ -62,21 +73,21 @@ const assertionError = kerror_1.default.wrap('api', 'assert');
|
|
|
62
73
|
*/
|
|
63
74
|
class KuzzleRequest {
|
|
64
75
|
constructor(data, options) {
|
|
65
|
-
this
|
|
66
|
-
this
|
|
67
|
-
this
|
|
68
|
-
this
|
|
69
|
-
this
|
|
70
|
-
this
|
|
71
|
-
this
|
|
72
|
-
this
|
|
76
|
+
this[_internalId] = (0, nanoid_1.nanoid)();
|
|
77
|
+
this[_status] = 102;
|
|
78
|
+
this[_input] = new requestInput_1.RequestInput(data);
|
|
79
|
+
this[_context] = new requestContext_1.RequestContext(options);
|
|
80
|
+
this[_error] = null;
|
|
81
|
+
this[_result] = null;
|
|
82
|
+
this[_response] = null;
|
|
83
|
+
this[_deprecations] = undefined;
|
|
73
84
|
// @deprecated - Backward compatibility with the RequestInput.headers
|
|
74
85
|
// property
|
|
75
|
-
this.
|
|
86
|
+
this[_input].headers = this[_context].connection.misc.headers;
|
|
76
87
|
this.id = data.requestId
|
|
77
88
|
? assert.assertString('requestId', data.requestId)
|
|
78
89
|
: (0, nanoid_1.nanoid)();
|
|
79
|
-
this
|
|
90
|
+
this[_timestamp] = data.timestamp || Date.now();
|
|
80
91
|
// handling provided options
|
|
81
92
|
if (options !== undefined && options !== null) {
|
|
82
93
|
if (typeof options !== 'object' || Array.isArray(options)) {
|
|
@@ -111,6 +122,67 @@ class KuzzleRequest {
|
|
|
111
122
|
this.status = options.status;
|
|
112
123
|
}
|
|
113
124
|
}
|
|
125
|
+
Object.seal(this);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Request internal ID
|
|
129
|
+
*/
|
|
130
|
+
get internalId() {
|
|
131
|
+
return this[_internalId];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Deprecation warnings for the API action
|
|
135
|
+
*/
|
|
136
|
+
get deprecations() {
|
|
137
|
+
return this[_deprecations];
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Request timestamp (in Epoch-micro)
|
|
141
|
+
*/
|
|
142
|
+
get timestamp() {
|
|
143
|
+
return this[_timestamp];
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Request HTTP status
|
|
147
|
+
*/
|
|
148
|
+
get status() {
|
|
149
|
+
return this[_status];
|
|
150
|
+
}
|
|
151
|
+
set status(i) {
|
|
152
|
+
this[_status] = assert.assertInteger('status', i);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Request input
|
|
156
|
+
*/
|
|
157
|
+
get input() {
|
|
158
|
+
return this[_input];
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Request context
|
|
162
|
+
*/
|
|
163
|
+
get context() {
|
|
164
|
+
return this[_context];
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Request error
|
|
168
|
+
*/
|
|
169
|
+
get error() {
|
|
170
|
+
return this[_error];
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Request result
|
|
174
|
+
*/
|
|
175
|
+
get result() {
|
|
176
|
+
return this[_result];
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Request response
|
|
180
|
+
*/
|
|
181
|
+
get response() {
|
|
182
|
+
if (this[_response] === null) {
|
|
183
|
+
this[_response] = new requestResponse_1.RequestResponse(this);
|
|
184
|
+
}
|
|
185
|
+
return this[_response];
|
|
114
186
|
}
|
|
115
187
|
/**
|
|
116
188
|
* Adds an error to the request, and sets the request's status to the error one.
|
|
@@ -119,14 +191,14 @@ class KuzzleRequest {
|
|
|
119
191
|
if (!error || !(error instanceof Error)) {
|
|
120
192
|
throw new errors_1.InternalError('Cannot set non-error object as a request\'s error');
|
|
121
193
|
}
|
|
122
|
-
this
|
|
123
|
-
this.status = this.
|
|
194
|
+
this[_error] = error instanceof errors_1.KuzzleError ? error : new errors_1.InternalError(error);
|
|
195
|
+
this.status = this[_error].status;
|
|
124
196
|
}
|
|
125
197
|
/**
|
|
126
198
|
* Sets the request error to null and status to 200
|
|
127
199
|
*/
|
|
128
200
|
clearError() {
|
|
129
|
-
this
|
|
201
|
+
this[_error] = null;
|
|
130
202
|
this.status = 200;
|
|
131
203
|
}
|
|
132
204
|
/**
|
|
@@ -151,7 +223,7 @@ class KuzzleRequest {
|
|
|
151
223
|
if (options.raw !== undefined) {
|
|
152
224
|
this.response.raw = options.raw;
|
|
153
225
|
}
|
|
154
|
-
this
|
|
226
|
+
this[_result] = result;
|
|
155
227
|
}
|
|
156
228
|
/**
|
|
157
229
|
* Add a deprecation for a used component, this can be action/controller/parameters...
|
|
@@ -168,7 +240,7 @@ class KuzzleRequest {
|
|
|
168
240
|
version,
|
|
169
241
|
};
|
|
170
242
|
if (!this.deprecations) {
|
|
171
|
-
this
|
|
243
|
+
this[_deprecations] = [deprecation];
|
|
172
244
|
}
|
|
173
245
|
else {
|
|
174
246
|
this.deprecations.push(deprecation);
|
|
@@ -182,28 +254,62 @@ class KuzzleRequest {
|
|
|
182
254
|
serialize() {
|
|
183
255
|
const serialized = {
|
|
184
256
|
data: {
|
|
185
|
-
_id: this.
|
|
257
|
+
_id: this[_input].args._id,
|
|
258
|
+
action: this[_input].action,
|
|
259
|
+
body: this[_input].body,
|
|
260
|
+
collection: this[_input].args.collection,
|
|
261
|
+
controller: this[_input].controller,
|
|
262
|
+
index: this[_input].args.index,
|
|
263
|
+
jwt: this[_input].jwt,
|
|
264
|
+
requestId: this.id,
|
|
265
|
+
timestamp: this[_timestamp],
|
|
266
|
+
volatile: this[_input].volatile,
|
|
267
|
+
},
|
|
268
|
+
// @deprecated - duplicate of options.connection.misc.headers
|
|
269
|
+
headers: this[_input].headers,
|
|
270
|
+
options: {
|
|
271
|
+
error: this[_error],
|
|
272
|
+
result: this[_result],
|
|
273
|
+
status: this[_status],
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
Object.assign(serialized.data, this[_input].args);
|
|
277
|
+
Object.assign(serialized.options, this[_context].toJSON());
|
|
278
|
+
return serialized;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Return a POJO representing the request.
|
|
282
|
+
*
|
|
283
|
+
* This can be used to match Koncorde filter rather than the Request object
|
|
284
|
+
* because it has properties defined with invisible unicode characters.
|
|
285
|
+
*/
|
|
286
|
+
pojo() {
|
|
287
|
+
return {
|
|
288
|
+
context: {
|
|
289
|
+
connection: this.context.connection,
|
|
290
|
+
token: this.context.token,
|
|
291
|
+
user: this.context.user,
|
|
292
|
+
},
|
|
293
|
+
deprecations: this.deprecations,
|
|
294
|
+
error: this.error,
|
|
295
|
+
id: this.id,
|
|
296
|
+
input: {
|
|
186
297
|
action: this.input.action,
|
|
298
|
+
args: this.input.args,
|
|
187
299
|
body: this.input.body,
|
|
188
|
-
collection: this.input.args.collection,
|
|
189
300
|
controller: this.input.controller,
|
|
190
|
-
index: this.input.args.index,
|
|
191
301
|
jwt: this.input.jwt,
|
|
192
|
-
requestId: this.id,
|
|
193
|
-
timestamp: this.timestamp,
|
|
194
302
|
volatile: this.input.volatile,
|
|
195
303
|
},
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
result: this.result,
|
|
201
|
-
status: this.status,
|
|
304
|
+
internalId: this.internalId,
|
|
305
|
+
response: {
|
|
306
|
+
headers: this.response.headers,
|
|
307
|
+
raw: this.response.raw,
|
|
202
308
|
},
|
|
309
|
+
result: this.result,
|
|
310
|
+
status: this.status,
|
|
311
|
+
timestamp: this.timestamp,
|
|
203
312
|
};
|
|
204
|
-
Object.assign(serialized.data, this.input.args);
|
|
205
|
-
Object.assign(serialized.options, this.context.toJSON());
|
|
206
|
-
return serialized;
|
|
207
313
|
}
|
|
208
314
|
/**
|
|
209
315
|
* Returns the `lang` param of the request.
|
|
@@ -24,23 +24,26 @@ export declare type ContextMisc = {
|
|
|
24
24
|
* Information about the connection at the origin of the request.
|
|
25
25
|
*/
|
|
26
26
|
export declare class Connection {
|
|
27
|
+
constructor(connection: any);
|
|
27
28
|
/**
|
|
28
29
|
* Unique identifier of the user connection
|
|
29
30
|
*/
|
|
30
|
-
id: string;
|
|
31
|
+
set id(str: string);
|
|
32
|
+
get id(): string | null;
|
|
31
33
|
/**
|
|
32
34
|
* Network protocol name
|
|
33
35
|
*/
|
|
34
|
-
protocol: string;
|
|
36
|
+
set protocol(str: string);
|
|
37
|
+
get protocol(): string | null;
|
|
35
38
|
/**
|
|
36
39
|
* Chain of IP addresses, starting from the client
|
|
37
40
|
*/
|
|
38
|
-
ips: string[];
|
|
41
|
+
set ips(arr: string[]);
|
|
42
|
+
get ips(): string[];
|
|
39
43
|
/**
|
|
40
44
|
* Additional informations about the connection
|
|
41
45
|
*/
|
|
42
|
-
misc: ContextMisc;
|
|
43
|
-
constructor(connection: any);
|
|
46
|
+
get misc(): ContextMisc;
|
|
44
47
|
/**
|
|
45
48
|
* Serializes the Connection object
|
|
46
49
|
*/
|
|
@@ -53,18 +56,6 @@ export declare class Connection {
|
|
|
53
56
|
* and origin (connection, protocol).
|
|
54
57
|
*/
|
|
55
58
|
export declare class RequestContext {
|
|
56
|
-
/**
|
|
57
|
-
* Connection that initiated the request
|
|
58
|
-
*/
|
|
59
|
-
connection: Connection;
|
|
60
|
-
/**
|
|
61
|
-
* Authentication token
|
|
62
|
-
*/
|
|
63
|
-
token: Token | null;
|
|
64
|
-
/**
|
|
65
|
-
* Associated user
|
|
66
|
-
*/
|
|
67
|
-
user: User | null;
|
|
68
59
|
constructor(options?: any);
|
|
69
60
|
/**
|
|
70
61
|
* Serializes the RequestContext object
|
|
@@ -81,4 +72,18 @@ export declare class RequestContext {
|
|
|
81
72
|
*/
|
|
82
73
|
get protocol(): string | null;
|
|
83
74
|
set protocol(str: string);
|
|
75
|
+
/**
|
|
76
|
+
* Connection that initiated the request
|
|
77
|
+
*/
|
|
78
|
+
get connection(): Connection;
|
|
79
|
+
/**
|
|
80
|
+
* Authentication token
|
|
81
|
+
*/
|
|
82
|
+
get token(): Token | null;
|
|
83
|
+
set token(obj: Token | null);
|
|
84
|
+
/**
|
|
85
|
+
* Associated user
|
|
86
|
+
*/
|
|
87
|
+
get user(): User | null;
|
|
88
|
+
set user(obj: User | null);
|
|
84
89
|
}
|