kuzzle 2.16.8 → 2.17.0
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/README.md +11 -0
- package/lib/api/controllers/adminController.js +7 -6
- package/lib/api/controllers/authController.js +11 -11
- package/lib/api/controllers/baseController.js +60 -3
- package/lib/api/controllers/clusterController.js +1 -1
- package/lib/api/controllers/collectionController.js +7 -5
- package/lib/api/controllers/documentController.js +130 -17
- package/lib/api/controllers/indexController.js +1 -1
- package/lib/api/controllers/memoryStorageController.js +39 -38
- package/lib/api/controllers/realtimeController.js +1 -1
- package/lib/api/controllers/securityController.js +49 -49
- package/lib/api/controllers/serverController.js +73 -27
- package/lib/api/documentExtractor.js +3 -3
- package/lib/api/funnel.js +40 -21
- package/lib/api/httpRoutes.js +9 -4
- package/lib/api/openapi/OpenApiManager.d.ts +11 -0
- package/lib/api/openapi/OpenApiManager.js +96 -0
- package/lib/api/openapi/{document → components/document}/count.yaml +2 -2
- package/lib/api/openapi/{document → components/document}/create.yaml +2 -2
- package/lib/api/openapi/{document → components/document}/createOrReplace.yaml +2 -2
- package/lib/api/openapi/{document → components/document}/delete.yaml +1 -1
- package/lib/api/openapi/{document → components/document}/deleteByQuery.yaml +2 -2
- package/lib/api/openapi/{document → components/document}/exists.yaml +1 -1
- package/lib/api/openapi/{document → components/document}/get.yaml +1 -1
- package/lib/api/openapi/{document → components/document}/index.d.ts +2 -0
- package/lib/api/openapi/{document → components/document}/index.js +7 -2
- package/lib/api/openapi/{document → components/document}/replace.yaml +2 -2
- package/lib/api/openapi/{document → components/document}/scroll.yaml +1 -1
- package/lib/api/openapi/{document → components/document}/update.yaml +2 -2
- package/lib/api/openapi/components/document/validate.yaml +42 -0
- package/lib/api/openapi/components/index.d.ts +2 -0
- package/lib/api/openapi/components/index.js +18 -0
- package/lib/api/openapi/{payloads.yaml → components/payloads.yaml} +0 -0
- package/lib/api/openapi/index.d.ts +1 -2
- package/lib/api/openapi/index.js +1 -5
- package/lib/api/openapi/openApiGenerator.d.ts +7 -0
- package/lib/api/openapi/openApiGenerator.js +133 -0
- package/lib/api/request/kuzzleRequest.d.ts +11 -11
- package/lib/api/request/kuzzleRequest.js +38 -48
- package/lib/cluster/node.js +9 -9
- package/lib/cluster/publisher.js +1 -1
- package/lib/cluster/subscriber.js +1 -1
- package/lib/cluster/workers/IDCardRenewer.js +13 -4
- package/lib/config/default.config.js +1 -0
- package/lib/config/index.js +6 -6
- package/lib/core/auth/passportResponse.js +6 -6
- package/lib/core/auth/passportWrapper.js +5 -5
- package/lib/core/backend/backend.d.ts +5 -1
- package/lib/core/backend/backend.js +12 -8
- package/lib/core/backend/backendConfig.d.ts +5 -1
- package/lib/core/backend/backendConfig.js +4 -0
- package/lib/core/backend/backendOpenApi.d.ts +9 -0
- package/lib/core/backend/backendOpenApi.js +69 -0
- package/lib/core/backend/index.d.ts +1 -0
- package/lib/core/backend/index.js +1 -0
- package/lib/core/network/accessLogger.js +6 -6
- package/lib/core/network/clientConnection.js +1 -1
- package/lib/core/network/entryPoint.js +5 -5
- package/lib/core/network/httpRouter/index.js +5 -5
- package/lib/core/network/httpRouter/routeHandler.js +3 -3
- package/lib/core/network/httpRouter/routePart.js +5 -5
- package/lib/core/network/protocolManifest.js +1 -1
- package/lib/core/network/protocols/httpMessage.js +2 -2
- package/lib/core/network/protocols/httpwsProtocol.js +207 -46
- package/lib/core/network/protocols/mqttProtocol.js +3 -3
- package/lib/core/network/protocols/protocol.js +3 -3
- package/lib/core/network/router.js +7 -6
- package/lib/core/plugin/plugin.js +38 -64
- package/lib/core/plugin/pluginContext.d.ts +10 -1
- package/lib/core/plugin/pluginContext.js +2 -0
- package/lib/core/plugin/pluginManifest.js +3 -3
- package/lib/core/plugin/pluginRepository.js +5 -5
- package/lib/core/plugin/pluginsManager.js +29 -28
- package/lib/core/realtime/notification/server.js +1 -1
- package/lib/core/realtime/notification/user.js +1 -1
- package/lib/core/realtime/notifier.js +5 -5
- package/lib/core/security/index.js +1 -1
- package/lib/core/security/profileRepository.d.ts +176 -0
- package/lib/core/security/profileRepository.js +426 -443
- package/lib/core/security/roleRepository.js +16 -16
- package/lib/core/security/securityLoader.js +3 -3
- package/lib/core/security/tokenRepository.js +18 -21
- package/lib/core/security/userRepository.js +8 -8
- package/lib/core/shared/abstractManifest.js +4 -4
- package/lib/core/shared/repository.js +6 -6
- package/lib/core/shared/sdk/funnelProtocol.js +1 -1
- package/lib/core/shared/sdk/impersonatedSdk.js +1 -1
- package/lib/core/shared/store.js +30 -23
- package/lib/core/statistics/statistics.js +17 -17
- package/lib/core/storage/clientAdapter.js +45 -10
- package/lib/core/validation/baseType.js +5 -5
- package/lib/core/validation/types/anything.js +1 -1
- package/lib/core/validation/types/boolean.js +2 -2
- package/lib/core/validation/types/date.js +9 -9
- package/lib/core/validation/types/email.js +5 -5
- package/lib/core/validation/types/enum.js +6 -6
- package/lib/core/validation/types/geoPoint.js +2 -2
- package/lib/core/validation/types/geoShape.js +28 -25
- package/lib/core/validation/types/integer.js +4 -4
- package/lib/core/validation/types/ipAddress.js +7 -6
- package/lib/core/validation/types/numeric.js +4 -4
- package/lib/core/validation/types/object.js +5 -5
- package/lib/core/validation/types/string.js +5 -5
- package/lib/core/validation/types/url.js +7 -6
- package/lib/core/validation/validation.js +95 -84
- package/lib/kerror/codes/1-services.json +12 -0
- package/lib/kerror/codes/2-api.json +12 -0
- package/lib/kerror/codes/3-network.json +12 -0
- package/lib/kerror/codes/4-plugin.json +6 -0
- package/lib/kerror/codes/index.js +11 -11
- package/lib/kerror/index.js +1 -1
- package/lib/kuzzle/dumpGenerator.js +3 -3
- package/lib/kuzzle/event/kuzzleEventEmitter.js +4 -4
- package/lib/kuzzle/event/pipeRunner.js +1 -1
- package/lib/kuzzle/event/waterfall.js +6 -6
- package/lib/kuzzle/kuzzle.js +36 -5
- package/lib/kuzzle/log.js +3 -3
- package/lib/kuzzle/vault.js +3 -3
- package/lib/model/security/profile.d.ts +54 -0
- package/lib/model/security/profile.js +174 -233
- package/lib/model/security/rights.js +1 -1
- package/lib/model/security/role.d.ts +40 -0
- package/lib/model/security/role.js +159 -191
- package/lib/model/security/user.d.ts +29 -0
- package/lib/model/security/user.js +84 -52
- package/lib/model/storage/apiKey.js +2 -2
- package/lib/model/storage/baseModel.js +3 -3
- package/lib/service/cache/redis.js +7 -7
- package/lib/service/storage/elasticsearch.js +152 -90
- package/lib/service/storage/esWrapper.js +2 -3
- package/lib/types/ControllerDefinition.d.ts +3 -3
- package/lib/types/ControllerRights.d.ts +22 -0
- package/lib/types/ControllerRights.js +23 -0
- package/lib/types/HttpStream.d.ts +32 -0
- package/lib/types/HttpStream.js +70 -0
- package/lib/types/OpenApiDefinition.d.ts +43 -0
- package/lib/types/{config/StorageService/StorageServiceElasticsearchConfiguration.js → OpenApiDefinition.js} +1 -1
- package/lib/types/Policy.d.ts +25 -0
- package/lib/types/Policy.js +23 -0
- package/lib/types/PolicyRestrictions.d.ts +21 -0
- package/lib/types/PolicyRestrictions.js +23 -0
- package/lib/types/Target.d.ts +15 -0
- package/lib/types/Target.js +23 -0
- package/lib/types/config/KuzzleConfiguration.d.ts +4 -0
- package/lib/types/config/ServicesConfiguration.d.ts +2 -2
- package/lib/types/config/{StorageService/StorageServiceElasticsearchConfiguration.d.ts → storageEngine/StorageEngineElasticsearchConfiguration.d.ts} +10 -3
- package/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.js +3 -0
- package/lib/types/index.d.ts +7 -1
- package/lib/types/index.js +7 -1
- package/lib/util/array.d.ts +11 -0
- package/lib/util/array.js +57 -0
- package/lib/util/assertType.js +6 -6
- package/lib/util/bufferedPassThrough.d.ts +76 -0
- package/lib/util/bufferedPassThrough.js +161 -0
- package/lib/util/deprecate.js +7 -5
- package/lib/util/didYouMean.js +1 -1
- package/lib/util/dump-collection.d.ts +3 -0
- package/lib/util/dump-collection.js +265 -0
- package/lib/util/extractFields.js +2 -2
- package/lib/util/inflector.d.ts +8 -0
- package/lib/util/inflector.js +16 -0
- package/lib/util/requestAssertions.js +7 -7
- package/lib/util/wildcard.js +55 -0
- package/package-lock.json +881 -431
- package/package.json +23 -20
- package/lib/api/openApiGenerator.d.ts +0 -7
- package/lib/api/openApiGenerator.js +0 -197
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import { Profile } from '../../model/security/profile';
|
|
3
|
+
import Repository from '../shared/repository';
|
|
4
|
+
import { JSONObject } from 'kuzzle-sdk';
|
|
5
|
+
/** @internal */
|
|
6
|
+
declare type CreateOrReplaceOptions = {
|
|
7
|
+
method?: string;
|
|
8
|
+
refresh?: string;
|
|
9
|
+
strict?: boolean;
|
|
10
|
+
userId?: string;
|
|
11
|
+
};
|
|
12
|
+
/** @internal */
|
|
13
|
+
declare type ValidateAndSaveProfileOptions = {
|
|
14
|
+
method?: string;
|
|
15
|
+
refresh?: string;
|
|
16
|
+
strict?: boolean;
|
|
17
|
+
retryOnConflict?: number;
|
|
18
|
+
};
|
|
19
|
+
/** @internal */
|
|
20
|
+
declare type UpdateOptions = {
|
|
21
|
+
userId?: string;
|
|
22
|
+
refresh?: string;
|
|
23
|
+
strict?: boolean;
|
|
24
|
+
retryOnConflict?: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* @class ProfileRepository
|
|
28
|
+
* @extends Repository
|
|
29
|
+
*/
|
|
30
|
+
export declare class ProfileRepository extends Repository {
|
|
31
|
+
private module;
|
|
32
|
+
private profiles;
|
|
33
|
+
/**
|
|
34
|
+
* @constructor
|
|
35
|
+
*/
|
|
36
|
+
constructor(securityModule: any);
|
|
37
|
+
init(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Loads a Profile
|
|
40
|
+
*
|
|
41
|
+
* @param {string} id
|
|
42
|
+
* @returns {Promise.<Promise>}
|
|
43
|
+
* @throws {NotFoundError} If the corresponding profile doesn't exist
|
|
44
|
+
*/
|
|
45
|
+
load(id: string): Promise<Profile>;
|
|
46
|
+
/**
|
|
47
|
+
* Loads a Profile object given its id.
|
|
48
|
+
* Stores the promise of the profile being loaded in the memcache
|
|
49
|
+
* and then replaces it by the profile itself once it has been loaded
|
|
50
|
+
*
|
|
51
|
+
* This is to allow parallelisation while preventing sending requests
|
|
52
|
+
* to ES, which is slow
|
|
53
|
+
*
|
|
54
|
+
* @param {Array} profileIds - Array of profiles ids
|
|
55
|
+
* @param {Object} options - resetCache (false)
|
|
56
|
+
*
|
|
57
|
+
* @returns {Promise} Resolves to the matching Profile object if found, null
|
|
58
|
+
* if not.
|
|
59
|
+
*/
|
|
60
|
+
loadProfiles(profileIds?: string[]): Promise<Profile[]>;
|
|
61
|
+
/**
|
|
62
|
+
* @override
|
|
63
|
+
*/
|
|
64
|
+
loadOneFromDatabase(id: string): Promise<Profile>;
|
|
65
|
+
/**
|
|
66
|
+
* Creates a new profile, or create/replace a profile
|
|
67
|
+
*
|
|
68
|
+
* @param {String} id
|
|
69
|
+
* @param {Object} policies
|
|
70
|
+
* @param {Object} [opts]
|
|
71
|
+
* @returns {Profile}
|
|
72
|
+
*/
|
|
73
|
+
_createOrReplace(id: string, content: JSONObject, { method, refresh, strict, userId }?: CreateOrReplaceOptions): Promise<Profile>;
|
|
74
|
+
/**
|
|
75
|
+
* Creates a new profile
|
|
76
|
+
*
|
|
77
|
+
* @param {String} id
|
|
78
|
+
* @param {Object} content
|
|
79
|
+
* @param {Object} [opts]
|
|
80
|
+
* @returns {Profile}
|
|
81
|
+
*/
|
|
82
|
+
create(id: string, content: JSONObject, opts?: JSONObject): Promise<Profile>;
|
|
83
|
+
/**
|
|
84
|
+
* Creates or replaces a profile
|
|
85
|
+
*
|
|
86
|
+
* @param {String} id
|
|
87
|
+
* @param {Object} content
|
|
88
|
+
* @param {Object} [opts]
|
|
89
|
+
* @returns {Profile}
|
|
90
|
+
*/
|
|
91
|
+
createOrReplace(id: string, content: JSONObject, opts?: JSONObject): Promise<Profile>;
|
|
92
|
+
/**
|
|
93
|
+
* Updates a profile
|
|
94
|
+
* @param {String} id
|
|
95
|
+
* @param {Object} content
|
|
96
|
+
* @param {Object} [opts]
|
|
97
|
+
* @returns {Promise}
|
|
98
|
+
*/
|
|
99
|
+
update(id: string, content: JSONObject, { refresh, retryOnConflict, strict, userId }?: UpdateOptions): Promise<Profile>;
|
|
100
|
+
/**
|
|
101
|
+
* Deletes a profile
|
|
102
|
+
*
|
|
103
|
+
* @param {String} id
|
|
104
|
+
* @param {object} [options]
|
|
105
|
+
* @returns {Promise}
|
|
106
|
+
*/
|
|
107
|
+
deleteById(id: string, options?: JSONObject): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* @override
|
|
110
|
+
*/
|
|
111
|
+
delete(profile: Profile, { refresh, onAssignedUsers, userId, }?: {
|
|
112
|
+
refresh?: string;
|
|
113
|
+
onAssignedUsers?: string;
|
|
114
|
+
userId?: string;
|
|
115
|
+
}): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* From a Profile object, returns a serialized object ready to be persisted
|
|
118
|
+
* to the database.
|
|
119
|
+
*
|
|
120
|
+
* @param {Profile} profile
|
|
121
|
+
* @returns {object}
|
|
122
|
+
*/
|
|
123
|
+
serializeToDatabase(profile: Profile): import("lodash").Omit<Profile, "_id">;
|
|
124
|
+
/**
|
|
125
|
+
* Given a Profile object, validates its definition and if OK, persist it to the database.
|
|
126
|
+
*
|
|
127
|
+
* @param {Profile} profile
|
|
128
|
+
* @param {Object} [options]
|
|
129
|
+
* @param {string} [options.method] - Document persistence method
|
|
130
|
+
* @param {string} [options.refresh] - (Don't) wait for index refresh
|
|
131
|
+
* @param {number} [options.retryOnConflict] - Number of retries when an
|
|
132
|
+
* update fails due to a conflict
|
|
133
|
+
* @param {boolean} [options.strict] - if true, restrictions can only be
|
|
134
|
+
* applied on existing indexes/collections
|
|
135
|
+
* @returns {Promise<Profile>}
|
|
136
|
+
**/
|
|
137
|
+
validateAndSaveProfile(profile: Profile, { method, refresh, retryOnConflict, strict }?: ValidateAndSaveProfileOptions): Promise<Profile>;
|
|
138
|
+
/**
|
|
139
|
+
* @param {object} dto
|
|
140
|
+
* @returns {Promise<Profile>}
|
|
141
|
+
*/
|
|
142
|
+
fromDTO(dto: JSONObject): Promise<Profile>;
|
|
143
|
+
/**
|
|
144
|
+
* @override
|
|
145
|
+
*/
|
|
146
|
+
truncate(opts: JSONObject): Promise<void>;
|
|
147
|
+
/**
|
|
148
|
+
* Invalidate the cache entries for the given profile. If none is provided,
|
|
149
|
+
* the entire cache is emptied.
|
|
150
|
+
* @param {string} [profileId]
|
|
151
|
+
*/
|
|
152
|
+
invalidate(profileId?: string): void;
|
|
153
|
+
/**
|
|
154
|
+
* Optimize each policy to get a O(1) index access time
|
|
155
|
+
* and a O(log(n)) collection search time.
|
|
156
|
+
*
|
|
157
|
+
* - Deduplicate indexes using a map
|
|
158
|
+
* - Sort collections per index
|
|
159
|
+
* @param {Object[]} policies
|
|
160
|
+
*/
|
|
161
|
+
private optimizePolicies;
|
|
162
|
+
/**
|
|
163
|
+
* Optimize a policy to get a O(1) index access time
|
|
164
|
+
* and a O(log(n)) collection search time.
|
|
165
|
+
*
|
|
166
|
+
* - Deduplicate indexes using a map
|
|
167
|
+
* - Sort collections per index
|
|
168
|
+
* @param policy
|
|
169
|
+
*/
|
|
170
|
+
private optimizePolicy;
|
|
171
|
+
toDTO(dto: Profile): Promise<JSONObject>;
|
|
172
|
+
deleteFromDatabase(id: string, options: JSONObject): Promise<any>;
|
|
173
|
+
search(searchBody: JSONObject, options: JSONObject): Promise<any>;
|
|
174
|
+
scroll(id: string, ttl: number): Promise<any>;
|
|
175
|
+
}
|
|
176
|
+
export {};
|