kuzzle 2.29.1 → 2.30.0-beta.1
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/index.d.ts +15 -11
- package/index.js +4 -0
- package/lib/core/cache/cacheDbEnum.d.ts +9 -0
- package/lib/core/cache/cacheDbEnum.js +10 -16
- package/lib/core/plugin/pluginContext.d.ts +3 -3
- package/lib/core/plugin/pluginContext.js +10 -10
- package/lib/core/plugin/pluginRepository.js +3 -3
- package/lib/core/security/profileRepository.d.ts +4 -4
- package/lib/core/security/profileRepository.js +7 -7
- package/lib/core/security/roleRepository.js +4 -4
- package/lib/core/security/tokenRepository.d.ts +2 -2
- package/lib/core/security/tokenRepository.js +5 -5
- package/lib/core/security/userRepository.js +3 -3
- package/lib/core/shared/{repository.d.ts → ObjectRepository.d.ts} +4 -3
- package/lib/core/shared/{repository.js → ObjectRepository.js} +11 -14
- package/lib/core/shared/store.d.ts +51 -0
- package/lib/core/shared/store.js +135 -193
- package/lib/core/storage/storageEngine.js +3 -3
- package/lib/core/storage/storeScopeEnum.d.ts +8 -0
- package/lib/core/storage/storeScopeEnum.js +9 -15
- package/lib/kuzzle/internalIndexHandler.js +3 -3
- package/lib/service/storage/elasticsearch.d.ts +6 -6
- package/lib/service/storage/elasticsearch.js +10 -10
- package/lib/types/index.d.ts +20 -22
- package/lib/types/index.js +20 -22
- package/lib/types/shared/StoreCollectionsDefinition.d.ts +12 -0
- package/lib/types/shared/StoreCollectionsDefinition.js +3 -0
- package/package.json +2 -4
package/index.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export { NameGenerator } from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
1
|
+
export * from "./lib/core/backend";
|
|
2
|
+
export * from "./lib/types";
|
|
3
|
+
export * from "./lib/core/plugin/pluginContext";
|
|
4
|
+
export * from "./lib/core/shared/sdk/embeddedSdk";
|
|
5
|
+
export * from "./lib/api/request";
|
|
6
|
+
export * from "./lib/kerror/errors";
|
|
7
|
+
export * from "./lib/util/mutex";
|
|
8
|
+
export * from "./lib/util/Inflector";
|
|
9
|
+
export { NameGenerator } from "./lib/util/name-generator";
|
|
10
|
+
export * from "kuzzle-sdk";
|
|
11
|
+
export * from "./lib/core/shared/KoncordeWrapper";
|
|
12
|
+
export * from "./lib/core/shared/ObjectRepository";
|
|
13
|
+
export * from "./lib/core/shared/store";
|
|
14
|
+
export * from "./lib/core/cache/cacheDbEnum";
|
|
15
|
+
export * from "./lib/core/storage/storeScopeEnum";
|
package/index.js
CHANGED
|
@@ -27,4 +27,8 @@ var name_generator_1 = require("./lib/util/name-generator");
|
|
|
27
27
|
Object.defineProperty(exports, "NameGenerator", { enumerable: true, get: function () { return name_generator_1.NameGenerator; } });
|
|
28
28
|
__exportStar(require("kuzzle-sdk"), exports);
|
|
29
29
|
__exportStar(require("./lib/core/shared/KoncordeWrapper"), exports);
|
|
30
|
+
__exportStar(require("./lib/core/shared/ObjectRepository"), exports);
|
|
31
|
+
__exportStar(require("./lib/core/shared/store"), exports);
|
|
32
|
+
__exportStar(require("./lib/core/cache/cacheDbEnum"), exports);
|
|
33
|
+
__exportStar(require("./lib/core/storage/storeScopeEnum"), exports);
|
|
30
34
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/*
|
|
2
3
|
* Kuzzle, a backend software, self-hostable and ready to use
|
|
3
4
|
* to power modern apps
|
|
@@ -18,23 +19,16 @@
|
|
|
18
19
|
* See the License for the specific language governing permissions and
|
|
19
20
|
* limitations under the License.
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @typedef {string} cacheDbEnum
|
|
26
|
-
*/
|
|
27
|
-
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.cacheDbEnum = void 0;
|
|
28
24
|
/**
|
|
29
25
|
* Enum for the cache engine target (used by classes using either the
|
|
30
26
|
* internal or the public DB)
|
|
31
|
-
* @readOnly
|
|
32
|
-
* @enum {cacheDbEnum}
|
|
33
27
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
var cacheDbEnum;
|
|
29
|
+
(function (cacheDbEnum) {
|
|
30
|
+
cacheDbEnum["INTERNAL"] = "internal";
|
|
31
|
+
cacheDbEnum["NONE"] = "none";
|
|
32
|
+
cacheDbEnum["PUBLIC"] = "public";
|
|
33
|
+
})(cacheDbEnum || (exports.cacheDbEnum = cacheDbEnum = {}));
|
|
34
|
+
//# sourceMappingURL=cacheDbEnum.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Koncorde } from "../shared/KoncordeWrapper";
|
|
2
1
|
import { Client } from "@elastic/elasticsearch";
|
|
3
2
|
import { JSONObject } from "kuzzle-sdk";
|
|
4
|
-
import {
|
|
3
|
+
import { Koncorde } from "../shared/KoncordeWrapper";
|
|
4
|
+
import { KuzzleRequest, RequestContext, RequestInput } from "../../../index";
|
|
5
5
|
import { Mutex } from "../../util/mutex";
|
|
6
|
-
import { RequestContext, RequestInput, KuzzleRequest } from "../../../index";
|
|
7
6
|
import { BackendCluster } from "../backend";
|
|
7
|
+
import { EmbeddedSDK } from "../shared/sdk/embeddedSdk";
|
|
8
8
|
export interface Repository {
|
|
9
9
|
create(document: JSONObject, options: any): Promise<any>;
|
|
10
10
|
createOrReplace(document: JSONObject, options: any): Promise<any>;
|
|
@@ -49,18 +49,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
49
49
|
exports.PluginContext = void 0;
|
|
50
50
|
const bluebird_1 = __importDefault(require("bluebird"));
|
|
51
51
|
const KoncordeWrapper_1 = require("../shared/KoncordeWrapper");
|
|
52
|
-
const
|
|
53
|
-
const pluginRepository_1 = __importDefault(require("./pluginRepository"));
|
|
54
|
-
const store_1 = __importDefault(require("../shared/store"));
|
|
55
|
-
const elasticsearch_1 = __importDefault(require("../../service/storage/elasticsearch"));
|
|
56
|
-
const safeObject_1 = require("../../util/safeObject");
|
|
57
|
-
const promback_1 = __importDefault(require("../../util/promback"));
|
|
58
|
-
const mutex_1 = require("../../util/mutex");
|
|
52
|
+
const index_1 = require("../../../index");
|
|
59
53
|
const kerror = __importStar(require("../../kerror"));
|
|
60
|
-
const storeScopeEnum_1 = __importDefault(require("../storage/storeScopeEnum"));
|
|
61
54
|
const errors_1 = require("../../kerror/errors");
|
|
62
|
-
const
|
|
55
|
+
const elasticsearch_1 = __importDefault(require("../../service/storage/elasticsearch"));
|
|
56
|
+
const mutex_1 = require("../../util/mutex");
|
|
57
|
+
const promback_1 = __importDefault(require("../../util/promback"));
|
|
58
|
+
const safeObject_1 = require("../../util/safeObject");
|
|
63
59
|
const backend_1 = require("../backend");
|
|
60
|
+
const embeddedSdk_1 = require("../shared/sdk/embeddedSdk");
|
|
61
|
+
const store_1 = require("../shared/store");
|
|
62
|
+
const storeScopeEnum_1 = require("../storage/storeScopeEnum");
|
|
63
|
+
const pluginRepository_1 = __importDefault(require("./pluginRepository"));
|
|
64
64
|
const contextError = kerror.wrap("plugin", "context");
|
|
65
65
|
class PluginContext {
|
|
66
66
|
constructor(pluginName) {
|
|
@@ -92,7 +92,7 @@ class PluginContext {
|
|
|
92
92
|
// uppercase are forbidden by ES
|
|
93
93
|
const pluginIndex = `plugin-${pluginName}`.toLowerCase();
|
|
94
94
|
/* context.constructors =============================================== */
|
|
95
|
-
const pluginStore = new store_1.
|
|
95
|
+
const pluginStore = new store_1.Store(pluginIndex, storeScopeEnum_1.storeScopeEnum.PRIVATE);
|
|
96
96
|
// eslint-disable-next-line no-inner-declarations
|
|
97
97
|
function PluginContextRepository(collection, ObjectConstructor = null) {
|
|
98
98
|
if (!collection) {
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
const { merge } = require("lodash");
|
|
25
25
|
|
|
26
26
|
const { NotFoundError } = require("../../kerror/errors");
|
|
27
|
-
const {
|
|
28
|
-
const cacheDbEnum = require("../cache/cacheDbEnum");
|
|
27
|
+
const { ObjectRepository } = require("../shared/ObjectRepository");
|
|
28
|
+
const { cacheDbEnum } = require("../cache/cacheDbEnum");
|
|
29
29
|
|
|
30
|
-
class PluginRepository extends
|
|
30
|
+
class PluginRepository extends ObjectRepository {
|
|
31
31
|
constructor(store, collection) {
|
|
32
32
|
super({ cache: cacheDbEnum.NONE, store });
|
|
33
33
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
|
-
import { Profile } from "../../model/security/profile";
|
|
3
|
-
import { Repository } from "../shared/repository";
|
|
4
2
|
import { JSONObject } from "kuzzle-sdk";
|
|
3
|
+
import { Profile } from "../../model/security/profile";
|
|
4
|
+
import { ObjectRepository } from "../shared/ObjectRepository";
|
|
5
5
|
/** @internal */
|
|
6
6
|
type CreateOrReplaceOptions = {
|
|
7
7
|
method?: string;
|
|
@@ -25,9 +25,9 @@ type UpdateOptions = {
|
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
27
27
|
* @class ProfileRepository
|
|
28
|
-
* @extends
|
|
28
|
+
* @extends ObjectRepository
|
|
29
29
|
*/
|
|
30
|
-
export declare class ProfileRepository extends
|
|
30
|
+
export declare class ProfileRepository extends ObjectRepository<Profile> {
|
|
31
31
|
private module;
|
|
32
32
|
private profiles;
|
|
33
33
|
/**
|
|
@@ -47,23 +47,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
47
47
|
};
|
|
48
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
49
|
exports.ProfileRepository = void 0;
|
|
50
|
-
const lodash_1 = require("lodash");
|
|
51
50
|
const bluebird_1 = __importDefault(require("bluebird"));
|
|
52
|
-
const
|
|
53
|
-
const repository_1 = require("../shared/repository");
|
|
51
|
+
const lodash_1 = require("lodash");
|
|
54
52
|
const kerror = __importStar(require("../../kerror"));
|
|
55
|
-
const
|
|
53
|
+
const profile_1 = require("../../model/security/profile");
|
|
54
|
+
const cacheDbEnum_1 = require("../cache/cacheDbEnum");
|
|
55
|
+
const ObjectRepository_1 = require("../shared/ObjectRepository");
|
|
56
56
|
/**
|
|
57
57
|
* @class ProfileRepository
|
|
58
|
-
* @extends
|
|
58
|
+
* @extends ObjectRepository
|
|
59
59
|
*/
|
|
60
|
-
class ProfileRepository extends
|
|
60
|
+
class ProfileRepository extends ObjectRepository_1.ObjectRepository {
|
|
61
61
|
/**
|
|
62
62
|
* @constructor
|
|
63
63
|
*/
|
|
64
64
|
constructor(securityModule) {
|
|
65
65
|
super({
|
|
66
|
-
cache: cacheDbEnum_1.
|
|
66
|
+
cache: cacheDbEnum_1.cacheDbEnum.NONE,
|
|
67
67
|
store: global.kuzzle.internalIndex,
|
|
68
68
|
});
|
|
69
69
|
this.module = securityModule;
|
|
@@ -25,18 +25,18 @@ const Bluebird = require("bluebird");
|
|
|
25
25
|
|
|
26
26
|
const kuzzleStateEnum = require("../../kuzzle/kuzzleStateEnum");
|
|
27
27
|
const { Role } = require("../../model/security/role");
|
|
28
|
-
const {
|
|
28
|
+
const { ObjectRepository } = require("../shared/ObjectRepository");
|
|
29
29
|
const kerror = require("../../kerror");
|
|
30
30
|
const didYouMean = require("../../util/didYouMean");
|
|
31
|
-
const cacheDbEnum = require("../cache/cacheDbEnum");
|
|
31
|
+
const { cacheDbEnum } = require("../cache/cacheDbEnum");
|
|
32
32
|
|
|
33
33
|
const roleRightsError = kerror.wrap("security", "role");
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* @class RoleRepository
|
|
37
|
-
* @extends
|
|
37
|
+
* @extends ObjectRepository
|
|
38
38
|
*/
|
|
39
|
-
class RoleRepository extends
|
|
39
|
+
class RoleRepository extends ObjectRepository {
|
|
40
40
|
/**
|
|
41
41
|
* @constructor
|
|
42
42
|
* @param {SecurityModule} securityModule
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { JSONObject } from "kuzzle-sdk";
|
|
2
2
|
import { Token } from "../../model/security/token";
|
|
3
|
-
import { Repository } from "../shared/repository";
|
|
4
3
|
import { User } from "../../model/security/user";
|
|
5
|
-
|
|
4
|
+
import { ObjectRepository } from "../shared/ObjectRepository";
|
|
5
|
+
export declare class TokenRepository extends ObjectRepository<Token> {
|
|
6
6
|
private tokenGracePeriod;
|
|
7
7
|
private anonymousToken;
|
|
8
8
|
constructor(opts?: JSONObject);
|
|
@@ -47,20 +47,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
47
47
|
};
|
|
48
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
49
|
exports.TokenRepository = void 0;
|
|
50
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
51
50
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
51
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
52
52
|
const ms_1 = __importDefault(require("ms"));
|
|
53
|
-
const
|
|
53
|
+
const kerror = __importStar(require("../../kerror"));
|
|
54
54
|
const errors_1 = require("../../kerror/errors");
|
|
55
55
|
const token_1 = require("../../model/security/token");
|
|
56
|
-
const
|
|
56
|
+
const apiKey_1 = __importDefault(require("../../model/storage/apiKey"));
|
|
57
57
|
const debug_1 = __importDefault(require("../../util/debug"));
|
|
58
58
|
const mutex_1 = require("../../util/mutex");
|
|
59
|
-
const
|
|
59
|
+
const ObjectRepository_1 = require("../shared/ObjectRepository");
|
|
60
60
|
const securityError = kerror.wrap("security", "token");
|
|
61
61
|
const debug = (0, debug_1.default)("kuzzle:bootstrap:tokens");
|
|
62
62
|
const BOOTSTRAP_DONE_KEY = "token/bootstrap";
|
|
63
|
-
class TokenRepository extends
|
|
63
|
+
class TokenRepository extends ObjectRepository_1.ObjectRepository {
|
|
64
64
|
constructor(opts = {}) {
|
|
65
65
|
super();
|
|
66
66
|
this.collection = "token";
|
|
@@ -23,16 +23,16 @@
|
|
|
23
23
|
|
|
24
24
|
const { Request } = require("../../api/request");
|
|
25
25
|
const debug = require("../../util/debug")("kuzzle:core:security:users");
|
|
26
|
-
const {
|
|
26
|
+
const { ObjectRepository } = require("../shared/ObjectRepository");
|
|
27
27
|
const kerror = require("../../kerror");
|
|
28
28
|
const { User } = require("../../model/security/user");
|
|
29
29
|
const ApiKey = require("../../model/storage/apiKey");
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* @class UserRepository
|
|
33
|
-
* @extends
|
|
33
|
+
* @extends ObjectRepository
|
|
34
34
|
*/
|
|
35
|
-
class UserRepository extends
|
|
35
|
+
class UserRepository extends ObjectRepository {
|
|
36
36
|
/**
|
|
37
37
|
* @param {SecurityModule} securityModule
|
|
38
38
|
* @constructor
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { JSONObject } from "kuzzle-sdk";
|
|
2
|
-
|
|
2
|
+
import { cacheDbEnum } from "../cache/cacheDbEnum";
|
|
3
|
+
export declare class ObjectRepository<TObject extends {
|
|
3
4
|
_id: string;
|
|
4
5
|
}> {
|
|
5
6
|
protected ttl: number;
|
|
@@ -7,9 +8,9 @@ export declare class Repository<TObject extends {
|
|
|
7
8
|
protected collection: string;
|
|
8
9
|
protected ObjectConstructor: any;
|
|
9
10
|
protected store: any;
|
|
10
|
-
protected cacheDb:
|
|
11
|
+
protected cacheDb: cacheDbEnum;
|
|
11
12
|
constructor({ cache, store }?: {
|
|
12
|
-
cache?:
|
|
13
|
+
cache?: cacheDbEnum;
|
|
13
14
|
store?: any;
|
|
14
15
|
});
|
|
15
16
|
loadOneFromDatabase(id: string): Promise<TObject>;
|
|
@@ -42,15 +42,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
42
42
|
__setModuleDefault(result, mod);
|
|
43
43
|
return result;
|
|
44
44
|
};
|
|
45
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
46
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
47
|
-
};
|
|
48
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
-
exports.
|
|
50
|
-
const cacheDbEnum_1 = __importDefault(require("../cache/cacheDbEnum"));
|
|
46
|
+
exports.ObjectRepository = void 0;
|
|
51
47
|
const kerror = __importStar(require("../../kerror"));
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
const cacheDbEnum_1 = require("../cache/cacheDbEnum");
|
|
49
|
+
class ObjectRepository {
|
|
50
|
+
constructor({ cache = cacheDbEnum_1.cacheDbEnum.INTERNAL, store = null } = {}) {
|
|
54
51
|
this.ttl = global.kuzzle.config.repositories.common.cacheTTL;
|
|
55
52
|
this.collection = null;
|
|
56
53
|
this.ObjectConstructor = null;
|
|
@@ -133,7 +130,7 @@ class Repository {
|
|
|
133
130
|
if (response === null) {
|
|
134
131
|
return null;
|
|
135
132
|
}
|
|
136
|
-
return await this.fromDTO(
|
|
133
|
+
return await this.fromDTO({ ...JSON.parse(response) });
|
|
137
134
|
}
|
|
138
135
|
catch (err) {
|
|
139
136
|
throw kerror.get("services", "cache", "read_failed", err.message);
|
|
@@ -156,7 +153,7 @@ class Repository {
|
|
|
156
153
|
* @param options.key - Optional cache key
|
|
157
154
|
*/
|
|
158
155
|
async load(id, options = {}) {
|
|
159
|
-
if (this.cacheDb === cacheDbEnum_1.
|
|
156
|
+
if (this.cacheDb === cacheDbEnum_1.cacheDbEnum.NONE) {
|
|
160
157
|
return this.loadOneFromDatabase(id);
|
|
161
158
|
}
|
|
162
159
|
const object = await this.loadFromCache(id, options);
|
|
@@ -195,7 +192,7 @@ class Repository {
|
|
|
195
192
|
*/
|
|
196
193
|
async delete(object, options = {}) {
|
|
197
194
|
const promises = [];
|
|
198
|
-
if (this.cacheDb !== cacheDbEnum_1.
|
|
195
|
+
if (this.cacheDb !== cacheDbEnum_1.cacheDbEnum.NONE) {
|
|
199
196
|
promises.push(this.deleteFromCache(object._id, options));
|
|
200
197
|
}
|
|
201
198
|
if (this.store) {
|
|
@@ -219,7 +216,7 @@ class Repository {
|
|
|
219
216
|
async persistToCache(object, options = {}) {
|
|
220
217
|
const key = options.key || this.getCacheKey(object._id);
|
|
221
218
|
const value = JSON.stringify(this.serializeToCache(object));
|
|
222
|
-
const ttl = options.ttl
|
|
219
|
+
const ttl = options.ttl ?? this.ttl;
|
|
223
220
|
await global.kuzzle.ask(`core:cache:${this.cacheDb}:store`, key, value, {
|
|
224
221
|
ttl,
|
|
225
222
|
});
|
|
@@ -305,7 +302,7 @@ class Repository {
|
|
|
305
302
|
* @returns {object}
|
|
306
303
|
*/
|
|
307
304
|
toDTO(o) {
|
|
308
|
-
return
|
|
305
|
+
return { ...o };
|
|
309
306
|
}
|
|
310
307
|
/**
|
|
311
308
|
* Recursively delete all objects in repository with a scroll
|
|
@@ -397,5 +394,5 @@ class Repository {
|
|
|
397
394
|
return result;
|
|
398
395
|
}
|
|
399
396
|
}
|
|
400
|
-
exports.
|
|
401
|
-
//# sourceMappingURL=
|
|
397
|
+
exports.ObjectRepository = ObjectRepository;
|
|
398
|
+
//# sourceMappingURL=ObjectRepository.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { StoreCollectionsDefinition } from "../../types";
|
|
2
|
+
import { storeScopeEnum } from "../storage/storeScopeEnum";
|
|
3
|
+
/**
|
|
4
|
+
* Wrapper around the document store.
|
|
5
|
+
* Once instantiated, this class can only access the index passed in the
|
|
6
|
+
* constructor
|
|
7
|
+
*/
|
|
8
|
+
export declare class Store {
|
|
9
|
+
count: (...args: any[]) => Promise<any>;
|
|
10
|
+
create: (...args: any[]) => Promise<any>;
|
|
11
|
+
createCollection: (...args: any[]) => Promise<any>;
|
|
12
|
+
createOrReplace: (...args: any[]) => Promise<any>;
|
|
13
|
+
delete: (...args: any[]) => Promise<any>;
|
|
14
|
+
deleteByQuery: (...args: any[]) => Promise<any>;
|
|
15
|
+
deleteCollection: (...args: any[]) => Promise<any>;
|
|
16
|
+
deleteFields: (...args: any[]) => Promise<any>;
|
|
17
|
+
deleteIndex: (...args: any[]) => Promise<any>;
|
|
18
|
+
exists: (...args: any[]) => Promise<any>;
|
|
19
|
+
get: (...args: any[]) => Promise<any>;
|
|
20
|
+
getMapping: (...args: any[]) => Promise<any>;
|
|
21
|
+
getSettings: (...args: any[]) => Promise<any>;
|
|
22
|
+
mExecute: (...args: any[]) => Promise<any>;
|
|
23
|
+
mGet: (...args: any[]) => Promise<any>;
|
|
24
|
+
multiSearch: (...args: any[]) => Promise<any>;
|
|
25
|
+
refreshCollection: (...args: any[]) => Promise<any>;
|
|
26
|
+
replace: (...args: any[]) => Promise<any>;
|
|
27
|
+
search: (...args: any[]) => Promise<any>;
|
|
28
|
+
scroll: (...args: any[]) => Promise<any>;
|
|
29
|
+
truncateCollection: (...args: any[]) => Promise<any>;
|
|
30
|
+
update: (...args: any[]) => Promise<any>;
|
|
31
|
+
updateByQuery: (...args: any[]) => Promise<any>;
|
|
32
|
+
updateCollection: (...args: any[]) => Promise<any>;
|
|
33
|
+
updateMapping: (...args: any[]) => Promise<any>;
|
|
34
|
+
protected index: string;
|
|
35
|
+
protected scope: storeScopeEnum;
|
|
36
|
+
constructor(index: string, scope: storeScopeEnum);
|
|
37
|
+
/**
|
|
38
|
+
* Initialize the index, and creates provided collections
|
|
39
|
+
*/
|
|
40
|
+
init(collections?: StoreCollectionsDefinition): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Creates collections with the provided mappings
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} collections - collections with mappings
|
|
45
|
+
*
|
|
46
|
+
* @returns {Promise}
|
|
47
|
+
*/
|
|
48
|
+
createCollections(collections: StoreCollectionsDefinition, { indexCacheOnly }?: {
|
|
49
|
+
indexCacheOnly?: boolean;
|
|
50
|
+
}): Promise<any>;
|
|
51
|
+
}
|
package/lib/core/shared/store.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/*
|
|
2
3
|
* Kuzzle, a backend software, self-hostable and ready to use
|
|
3
4
|
* to power modern apps
|
|
@@ -18,209 +19,150 @@
|
|
|
18
19
|
* See the License for the specific language governing permissions and
|
|
19
20
|
* limitations under the License.
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
25
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
26
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
27
|
+
}
|
|
28
|
+
Object.defineProperty(o, k2, desc);
|
|
29
|
+
}) : (function(o, m, k, k2) {
|
|
30
|
+
if (k2 === undefined) k2 = k;
|
|
31
|
+
o[k2] = m[k];
|
|
32
|
+
}));
|
|
33
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
34
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
35
|
+
}) : function(o, v) {
|
|
36
|
+
o["default"] = v;
|
|
37
|
+
});
|
|
38
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.Store = void 0;
|
|
47
|
+
const kerror = __importStar(require("../../kerror"));
|
|
48
|
+
const async_1 = require("../../util/async");
|
|
49
|
+
const esRequest_1 = require("../../util/esRequest");
|
|
50
|
+
const mutex_1 = require("../../util/mutex");
|
|
29
51
|
/**
|
|
30
52
|
* Wrapper around the document store.
|
|
31
53
|
* Once instantiated, this class can only access the index passed in the
|
|
32
54
|
* constructor
|
|
33
55
|
*/
|
|
34
56
|
class Store {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
for (const [method, event] of Object.entries(methodsMapping)) {
|
|
71
|
-
this[method] = (...args) => global.kuzzle.ask(event, this.index, ...args);
|
|
57
|
+
constructor(index, scope) {
|
|
58
|
+
this.index = index;
|
|
59
|
+
this.scope = scope;
|
|
60
|
+
const methodsMapping = {
|
|
61
|
+
count: `core:storage:${scope}:document:count`,
|
|
62
|
+
create: `core:storage:${scope}:document:create`,
|
|
63
|
+
createCollection: `core:storage:${scope}:collection:create`,
|
|
64
|
+
createOrReplace: `core:storage:${scope}:document:createOrReplace`,
|
|
65
|
+
delete: `core:storage:${scope}:document:delete`,
|
|
66
|
+
deleteByQuery: `core:storage:${scope}:document:deleteByQuery`,
|
|
67
|
+
deleteCollection: `core:storage:${scope}:collection:delete`,
|
|
68
|
+
deleteFields: `core:storage:${scope}:document:deleteFields`,
|
|
69
|
+
deleteIndex: `core:storage:${scope}:index:delete`,
|
|
70
|
+
exists: `core:storage:${scope}:document:exist`,
|
|
71
|
+
get: `core:storage:${scope}:document:get`,
|
|
72
|
+
getMapping: `core:storage:${scope}:mappings:get`,
|
|
73
|
+
getSettings: `core:storage:${scope}:collection:settings:get`,
|
|
74
|
+
mExecute: `core:storage:${scope}:document:mExecute`,
|
|
75
|
+
mGet: `core:storage:${scope}:document:mGet`,
|
|
76
|
+
refreshCollection: `core:storage:${scope}:collection:refresh`,
|
|
77
|
+
replace: `core:storage:${scope}:document:replace`,
|
|
78
|
+
search: `core:storage:${scope}:document:search`,
|
|
79
|
+
truncateCollection: `core:storage:${scope}:collection:truncate`,
|
|
80
|
+
update: `core:storage:${scope}:document:update`,
|
|
81
|
+
updateByQuery: `core:storage:${scope}:document:updateByQuery`,
|
|
82
|
+
updateCollection: `core:storage:${scope}:collection:update`,
|
|
83
|
+
updateMapping: `core:storage:${scope}:mappings:update`,
|
|
84
|
+
};
|
|
85
|
+
for (const [method, event] of Object.entries(methodsMapping)) {
|
|
86
|
+
this[method] = (...args) => global.kuzzle.ask(event, this.index, ...args);
|
|
87
|
+
}
|
|
88
|
+
// the scroll and multiSearch method are special: they doesn't need an index parameter
|
|
89
|
+
// we keep them for ease of use
|
|
90
|
+
this.scroll = (scrollId, opts) => global.kuzzle.ask(`core:storage:${scope}:document:scroll`, scrollId, opts);
|
|
91
|
+
this.multiSearch = (targets, searchBody, opts) => global.kuzzle.ask(`core:storage:${scope}:document:multiSearch`, targets, searchBody, opts);
|
|
72
92
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
opts,
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
this.multiSearch = (targets, searchBody, opts) =>
|
|
84
|
-
global.kuzzle.ask(
|
|
85
|
-
`core:storage:${scope}:document:multiSearch`,
|
|
86
|
-
targets,
|
|
87
|
-
searchBody,
|
|
88
|
-
opts,
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Initialize the index, and creates provided collections
|
|
94
|
-
*
|
|
95
|
-
* @param {Object} collections - List of collections with mappings to create
|
|
96
|
-
*
|
|
97
|
-
* @returns {Promise}
|
|
98
|
-
*/
|
|
99
|
-
async init(collections = {}) {
|
|
100
|
-
const creatingMutex = new Mutex(`Store.init(${this.index})`, {
|
|
101
|
-
timeout: 0,
|
|
102
|
-
ttl: 30000,
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
if (await creatingMutex.lock()) {
|
|
106
|
-
try {
|
|
107
|
-
await this.createCollections(collections, {
|
|
108
|
-
indexCacheOnly: false,
|
|
93
|
+
/**
|
|
94
|
+
* Initialize the index, and creates provided collections
|
|
95
|
+
*/
|
|
96
|
+
async init(collections = {}) {
|
|
97
|
+
const creatingMutex = new mutex_1.Mutex(`Store.init(${this.index})`, {
|
|
98
|
+
timeout: 0,
|
|
99
|
+
ttl: 30000,
|
|
109
100
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Creates collections with the provided mappings
|
|
124
|
-
*
|
|
125
|
-
* @param {Object} collections - collections with mappings
|
|
126
|
-
*
|
|
127
|
-
* @returns {Promise}
|
|
128
|
-
*/
|
|
129
|
-
createCollections(collections, { indexCacheOnly = false } = {}) {
|
|
130
|
-
return promiseAllN(
|
|
131
|
-
Object.entries(collections).map(([collection, config]) => async () => {
|
|
132
|
-
// @deprecated
|
|
133
|
-
if (!(config.mappings !== undefined && config.settings !== undefined)) {
|
|
134
|
-
// @deprecated
|
|
135
|
-
return global.kuzzle.ask(
|
|
136
|
-
`core:storage:${this.scope}:collection:create`,
|
|
137
|
-
this.index,
|
|
138
|
-
collection,
|
|
139
|
-
{ mappings: config },
|
|
140
|
-
{ indexCacheOnly },
|
|
141
|
-
);
|
|
101
|
+
if (await creatingMutex.lock()) {
|
|
102
|
+
try {
|
|
103
|
+
await this.createCollections(collections, {
|
|
104
|
+
indexCacheOnly: false,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
await creatingMutex.unlock();
|
|
109
|
+
}
|
|
142
110
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (indexCacheOnly) {
|
|
150
|
-
return global.kuzzle.ask(
|
|
151
|
-
`core:storage:${this.scope}:collection:create`,
|
|
152
|
-
this.index,
|
|
153
|
-
collection,
|
|
154
|
-
// @deprecated
|
|
155
|
-
isConfigDeprecated ? { mappings: config.mappings } : config,
|
|
156
|
-
{ indexCacheOnly },
|
|
157
|
-
);
|
|
111
|
+
else {
|
|
112
|
+
await creatingMutex.wait({ timeout: -1 });
|
|
113
|
+
await this.createCollections(collections, {
|
|
114
|
+
indexCacheOnly: true,
|
|
115
|
+
});
|
|
158
116
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
`core:storage:${this.scope}:collection:settings:get`,
|
|
174
|
-
this.index,
|
|
175
|
-
collection,
|
|
176
|
-
);
|
|
177
|
-
|
|
178
|
-
if (
|
|
179
|
-
!isConfigDeprecated &&
|
|
180
|
-
parseInt(existingSettings.number_of_shards) !==
|
|
181
|
-
config.settings.number_of_shards
|
|
182
|
-
) {
|
|
183
|
-
if (global.NODE_ENV === "development") {
|
|
184
|
-
throw kerror.get(
|
|
185
|
-
"storage",
|
|
186
|
-
"wrong_collection_number_of_shards",
|
|
187
|
-
collection,
|
|
188
|
-
this.index,
|
|
189
|
-
this.scope,
|
|
190
|
-
"number_of_shards",
|
|
191
|
-
config.settings.number_of_shards,
|
|
192
|
-
existingSettings.number_of_shards,
|
|
193
|
-
);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Creates collections with the provided mappings
|
|
120
|
+
*
|
|
121
|
+
* @param {Object} collections - collections with mappings
|
|
122
|
+
*
|
|
123
|
+
* @returns {Promise}
|
|
124
|
+
*/
|
|
125
|
+
createCollections(collections, { indexCacheOnly = false } = {}) {
|
|
126
|
+
return (0, async_1.promiseAllN)(Object.entries(collections).map(([collection, config]) => async () => {
|
|
127
|
+
// @deprecated
|
|
128
|
+
if (!(config.mappings !== undefined && config.settings !== undefined)) {
|
|
129
|
+
// @deprecated
|
|
130
|
+
return global.kuzzle.ask(`core:storage:${this.scope}:collection:create`, this.index, collection, { mappings: config }, { indexCacheOnly });
|
|
194
131
|
}
|
|
195
|
-
global.kuzzle.log.warn(
|
|
196
|
-
`Attempt to recreate an existing collection ${collection} of index ${this.index} of scope ${this.scope} with non matching static setting : number_of_shards at ${config.settings.number_of_shards} while existing one is at ${existingSettings.number_of_shards}`,
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return global.kuzzle.ask(
|
|
201
|
-
`core:storage:${this.scope}:collection:create`,
|
|
202
|
-
this.index,
|
|
203
|
-
collection,
|
|
204
132
|
// @deprecated
|
|
205
|
-
isConfigDeprecated
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
133
|
+
const isConfigDeprecated = config.settings.number_of_shards === undefined &&
|
|
134
|
+
config.settings.number_of_replicas === undefined;
|
|
135
|
+
if (indexCacheOnly) {
|
|
136
|
+
return global.kuzzle.ask(`core:storage:${this.scope}:collection:create`, this.index, collection,
|
|
137
|
+
// @deprecated
|
|
138
|
+
isConfigDeprecated ? { mappings: config.mappings } : config, { indexCacheOnly });
|
|
139
|
+
}
|
|
140
|
+
const exist = await global.kuzzle.ask(`core:storage:${this.scope}:collection:exist`, this.index, collection);
|
|
141
|
+
if (exist) {
|
|
142
|
+
// @deprecated
|
|
143
|
+
const dynamicSettings = isConfigDeprecated
|
|
144
|
+
? null
|
|
145
|
+
: (0, esRequest_1.getESIndexDynamicSettings)(config.settings);
|
|
146
|
+
const existingSettings = await global.kuzzle.ask(`core:storage:${this.scope}:collection:settings:get`, this.index, collection);
|
|
147
|
+
if (!isConfigDeprecated &&
|
|
148
|
+
parseInt(existingSettings.number_of_shards) !==
|
|
149
|
+
config.settings.number_of_shards) {
|
|
150
|
+
if (global.NODE_ENV === "development") {
|
|
151
|
+
throw kerror.get("storage", "wrong_collection_number_of_shards", collection, this.index, this.scope, "number_of_shards", config.settings.number_of_shards, existingSettings.number_of_shards);
|
|
152
|
+
}
|
|
153
|
+
global.kuzzle.log.warn(`Attempt to recreate an existing collection ${collection} of index ${this.index} of scope ${this.scope} with non matching static setting : number_of_shards at ${config.settings.number_of_shards} while existing one is at ${existingSettings.number_of_shards}`);
|
|
154
|
+
}
|
|
155
|
+
return global.kuzzle.ask(`core:storage:${this.scope}:collection:create`, this.index, collection,
|
|
156
|
+
// @deprecated
|
|
157
|
+
isConfigDeprecated
|
|
158
|
+
? { mappings: config.mappings }
|
|
159
|
+
: { mappings: config.mappings, settings: dynamicSettings }, { indexCacheOnly: true });
|
|
160
|
+
}
|
|
161
|
+
return global.kuzzle.ask(`core:storage:${this.scope}:collection:create`, this.index, collection,
|
|
162
|
+
// @deprecated
|
|
163
|
+
isConfigDeprecated ? { mappings: config.mappings } : config, { indexCacheOnly });
|
|
164
|
+
}), 10);
|
|
165
|
+
}
|
|
224
166
|
}
|
|
225
|
-
|
|
226
|
-
|
|
167
|
+
exports.Store = Store;
|
|
168
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -25,15 +25,15 @@ const Bluebird = require("bluebird");
|
|
|
25
25
|
|
|
26
26
|
const kerror = require("../../kerror").wrap("services", "storage");
|
|
27
27
|
const ClientAdapter = require("./clientAdapter");
|
|
28
|
-
const
|
|
28
|
+
const { storeScopeEnum } = require("./storeScopeEnum");
|
|
29
29
|
|
|
30
30
|
class StorageEngine {
|
|
31
31
|
constructor() {
|
|
32
32
|
// Storage client for public indexes only
|
|
33
|
-
this.public = new ClientAdapter(
|
|
33
|
+
this.public = new ClientAdapter(storeScopeEnum.PUBLIC);
|
|
34
34
|
|
|
35
35
|
// Storage client for private indexes only
|
|
36
|
-
this.private = new ClientAdapter(
|
|
36
|
+
this.private = new ClientAdapter(storeScopeEnum.PRIVATE);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/*
|
|
2
3
|
* Kuzzle, a backend software, self-hostable and ready to use
|
|
3
4
|
* to power modern apps
|
|
@@ -18,22 +19,15 @@
|
|
|
18
19
|
* See the License for the specific language governing permissions and
|
|
19
20
|
* limitations under the License.
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @typedef {string} storeScopeEnum
|
|
26
|
-
*/
|
|
27
|
-
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.storeScopeEnum = void 0;
|
|
28
24
|
/**
|
|
29
25
|
* Enum for the storage target (used by classes using either private or
|
|
30
26
|
* public indexes)
|
|
31
|
-
* @readOnly
|
|
32
|
-
* @enum {storeScopeEnum}
|
|
33
27
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
var storeScopeEnum;
|
|
29
|
+
(function (storeScopeEnum) {
|
|
30
|
+
storeScopeEnum["PRIVATE"] = "private";
|
|
31
|
+
storeScopeEnum["PUBLIC"] = "public";
|
|
32
|
+
})(storeScopeEnum || (exports.storeScopeEnum = storeScopeEnum = {}));
|
|
33
|
+
//# sourceMappingURL=storeScopeEnum.js.map
|
|
@@ -26,9 +26,9 @@ const crypto = require("crypto");
|
|
|
26
26
|
const Bluebird = require("bluebird");
|
|
27
27
|
|
|
28
28
|
const debug = require("../util/debug")("kuzzle:bootstrap:internalIndex");
|
|
29
|
-
const Store = require("../core/shared/store");
|
|
29
|
+
const { Store } = require("../core/shared/store");
|
|
30
30
|
const { Mutex } = require("../util/mutex");
|
|
31
|
-
const
|
|
31
|
+
const { storeScopeEnum } = require("../core/storage/storeScopeEnum");
|
|
32
32
|
const kerror = require("../kerror");
|
|
33
33
|
|
|
34
34
|
const securitiesBootstrap = {
|
|
@@ -81,7 +81,7 @@ class InternalIndexHandler extends Store {
|
|
|
81
81
|
constructor() {
|
|
82
82
|
super(
|
|
83
83
|
global.kuzzle.config.services.storageEngine.internalIndex.name,
|
|
84
|
-
|
|
84
|
+
storeScopeEnum.PRIVATE,
|
|
85
85
|
);
|
|
86
86
|
|
|
87
87
|
this.timeout =
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _ from "lodash";
|
|
2
2
|
import { RequestParams, Client as StorageClient } from "@elastic/elasticsearch";
|
|
3
|
-
import {
|
|
3
|
+
import { JSONObject, KRequestBody, KRequestParams } from "../../types/storage/Elasticsearch";
|
|
4
4
|
import { TypeMapping } from "@elastic/elasticsearch/api/types";
|
|
5
|
+
import { storeScopeEnum } from "../../core/storage/storeScopeEnum";
|
|
6
|
+
import Service from "../service";
|
|
5
7
|
import ESWrapper from "./esWrapper";
|
|
6
8
|
import QueryTranslator from "./queryTranslator";
|
|
7
|
-
import Service from "../service";
|
|
8
|
-
import scopeEnum from "../../core/storage/storeScopeEnum";
|
|
9
9
|
/**
|
|
10
10
|
* @param {Kuzzle} kuzzle kuzzle instance
|
|
11
11
|
* @param {Object} config Service configuration
|
|
@@ -14,7 +14,7 @@ import scopeEnum from "../../core/storage/storeScopeEnum";
|
|
|
14
14
|
*/
|
|
15
15
|
export default class ElasticSearch extends Service {
|
|
16
16
|
_client: StorageClient;
|
|
17
|
-
_scope:
|
|
17
|
+
_scope: storeScopeEnum;
|
|
18
18
|
_indexPrefix: string;
|
|
19
19
|
_esWrapper: ESWrapper;
|
|
20
20
|
_esVersion: any;
|
|
@@ -31,8 +31,8 @@ export default class ElasticSearch extends Service {
|
|
|
31
31
|
* @returns {Object}
|
|
32
32
|
*/
|
|
33
33
|
static buildClient(config: any): StorageClient;
|
|
34
|
-
constructor(config: any, scope?:
|
|
35
|
-
get scope():
|
|
34
|
+
constructor(config: any, scope?: storeScopeEnum);
|
|
35
|
+
get scope(): storeScopeEnum;
|
|
36
36
|
/**
|
|
37
37
|
* Initializes the elasticsearch client
|
|
38
38
|
*
|
|
@@ -49,21 +49,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
49
49
|
const lodash_1 = __importDefault(require("lodash"));
|
|
50
50
|
const elasticsearch_1 = require("@elastic/elasticsearch");
|
|
51
51
|
const assert_1 = __importDefault(require("assert"));
|
|
52
|
-
const ms_1 = __importDefault(require("ms"));
|
|
53
52
|
const bluebird_1 = __importDefault(require("bluebird"));
|
|
53
|
+
const ms_1 = __importDefault(require("ms"));
|
|
54
54
|
const semver_1 = __importDefault(require("semver"));
|
|
55
55
|
const debug_1 = __importDefault(require("../../util/debug"));
|
|
56
|
-
const
|
|
57
|
-
const queryTranslator_1 = __importDefault(require("./queryTranslator"));
|
|
58
|
-
const didYouMean_1 = __importDefault(require("../../util/didYouMean"));
|
|
59
|
-
const service_1 = __importDefault(require("../service"));
|
|
56
|
+
const storeScopeEnum_1 = require("../../core/storage/storeScopeEnum");
|
|
60
57
|
const kerror = __importStar(require("../../kerror"));
|
|
61
|
-
const
|
|
62
|
-
const safeObject_1 = require("../../util/safeObject");
|
|
63
|
-
const storeScopeEnum_1 = __importDefault(require("../../core/storage/storeScopeEnum"));
|
|
58
|
+
const didYouMean_1 = __importDefault(require("../../util/didYouMean"));
|
|
64
59
|
const extractFields_1 = __importDefault(require("../../util/extractFields"));
|
|
65
60
|
const mutex_1 = require("../../util/mutex");
|
|
66
61
|
const name_generator_1 = require("../../util/name-generator");
|
|
62
|
+
const requestAssertions_1 = require("../../util/requestAssertions");
|
|
63
|
+
const safeObject_1 = require("../../util/safeObject");
|
|
64
|
+
const service_1 = __importDefault(require("../service"));
|
|
65
|
+
const esWrapper_1 = __importDefault(require("./esWrapper"));
|
|
66
|
+
const queryTranslator_1 = __importDefault(require("./queryTranslator"));
|
|
67
67
|
(0, debug_1.default)("kuzzle:services:elasticsearch");
|
|
68
68
|
const SCROLL_CACHE_PREFIX = "_docscroll_";
|
|
69
69
|
const ROOT_MAPPING_PROPERTIES = [
|
|
@@ -117,11 +117,11 @@ class ElasticSearch extends service_1.default {
|
|
|
117
117
|
};
|
|
118
118
|
return new elasticsearch_1.Client({ defer, ...config });
|
|
119
119
|
}
|
|
120
|
-
constructor(config, scope = storeScopeEnum_1.
|
|
120
|
+
constructor(config, scope = storeScopeEnum_1.storeScopeEnum.PUBLIC) {
|
|
121
121
|
super("elasticsearch", config);
|
|
122
122
|
this._scope = scope;
|
|
123
123
|
this._indexPrefix =
|
|
124
|
-
scope === storeScopeEnum_1.
|
|
124
|
+
scope === storeScopeEnum_1.storeScopeEnum.PRIVATE ? PRIVATE_PREFIX : PUBLIC_PREFIX;
|
|
125
125
|
this._client = null;
|
|
126
126
|
this._esWrapper = null;
|
|
127
127
|
this._esVersion = null;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,39 +1,37 @@
|
|
|
1
|
-
export * from "./Plugin";
|
|
2
1
|
export * from "./Controller";
|
|
3
2
|
export * from "./ControllerDefinition";
|
|
4
3
|
export * from "./ControllerRights";
|
|
5
4
|
export * from "./Deprecation";
|
|
6
5
|
export * from "./EventHandler";
|
|
7
|
-
export * from "./Policy";
|
|
8
|
-
export * from "./PolicyRestrictions";
|
|
9
|
-
export * from "./User";
|
|
10
|
-
export * from "./Token";
|
|
11
|
-
export * from "./Target";
|
|
12
6
|
export * from "./Global";
|
|
13
7
|
export * from "./HttpStream";
|
|
8
|
+
export * from "./KuzzleDocument";
|
|
9
|
+
export * from "./OpenApiDefinition";
|
|
14
10
|
export * from "./PasswordPolicy";
|
|
11
|
+
export * from "./Plugin";
|
|
12
|
+
export * from "./Policy";
|
|
13
|
+
export * from "./PolicyRestrictions";
|
|
14
|
+
export * from "./ProfileDefinition";
|
|
15
|
+
export * from "./RoleDefinition";
|
|
16
|
+
export * from "./Target";
|
|
17
|
+
export * from "./Token";
|
|
18
|
+
export * from "./User";
|
|
19
|
+
export * from "./config/DumpConfiguration";
|
|
20
|
+
export * from "./config/HttpConfiguration";
|
|
15
21
|
export * from "./config/KuzzleConfiguration";
|
|
22
|
+
export * from "./config/LimitsConfiguration";
|
|
23
|
+
export * from "./config/PluginsConfiguration";
|
|
24
|
+
export * from "./config/SecurityConfiguration";
|
|
16
25
|
export * from "./config/ServerConfiguration";
|
|
17
26
|
export * from "./config/ServicesConfiguration";
|
|
18
|
-
export * from "./config/SecurityConfiguration";
|
|
19
|
-
export * from "./config/HttpConfiguration";
|
|
20
|
-
export * from "./config/PluginsConfiguration";
|
|
21
|
-
export * from "./RoleDefinition";
|
|
22
|
-
export * from "./ProfileDefinition";
|
|
23
|
-
export * from "./Plugin";
|
|
24
|
-
export * from "./config/LimitsConfiguration";
|
|
25
|
-
export * from "./RoleDefinition";
|
|
26
|
-
export * from "./ProfileDefinition";
|
|
27
|
-
export * from "./realtime/RealtimeScope";
|
|
28
|
-
export * from "./realtime/RealtimeUsers";
|
|
29
|
-
export * from "./realtime/RoomList";
|
|
30
|
-
export * from "./KuzzleDocument";
|
|
31
|
-
export * from "./config/publicCache/PublicCacheRedisConfiguration";
|
|
32
27
|
export * from "./config/internalCache/InternalCacheRedisConfiguration";
|
|
28
|
+
export * from "./config/publicCache/PublicCacheRedisConfiguration";
|
|
33
29
|
export * from "./config/storageEngine/StorageEngineElasticsearchConfiguration";
|
|
34
|
-
export * from "./config/DumpConfiguration";
|
|
35
|
-
export * from "./OpenApiDefinition";
|
|
36
30
|
export * from "./errors/ErrorDefinition";
|
|
37
31
|
export * from "./errors/ErrorDomains";
|
|
38
32
|
export * from "./events/EventGenericDocument";
|
|
39
33
|
export * from "./events/EventProtocol";
|
|
34
|
+
export * from "./realtime/RealtimeScope";
|
|
35
|
+
export * from "./realtime/RealtimeUsers";
|
|
36
|
+
export * from "./realtime/RoomList";
|
|
37
|
+
export * from "./shared/StoreCollectionsDefinition";
|
package/lib/types/index.js
CHANGED
|
@@ -34,43 +34,41 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
34
34
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
35
35
|
};
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
__exportStar(require("./Plugin"), exports);
|
|
38
37
|
__exportStar(require("./Controller"), exports);
|
|
39
38
|
__exportStar(require("./ControllerDefinition"), exports);
|
|
40
39
|
__exportStar(require("./ControllerRights"), exports);
|
|
41
40
|
__exportStar(require("./Deprecation"), exports);
|
|
42
41
|
__exportStar(require("./EventHandler"), exports);
|
|
43
|
-
__exportStar(require("./Policy"), exports);
|
|
44
|
-
__exportStar(require("./PolicyRestrictions"), exports);
|
|
45
|
-
__exportStar(require("./User"), exports);
|
|
46
|
-
__exportStar(require("./Token"), exports);
|
|
47
|
-
__exportStar(require("./Target"), exports);
|
|
48
42
|
__exportStar(require("./Global"), exports);
|
|
49
43
|
__exportStar(require("./HttpStream"), exports);
|
|
44
|
+
__exportStar(require("./KuzzleDocument"), exports);
|
|
45
|
+
__exportStar(require("./OpenApiDefinition"), exports);
|
|
50
46
|
__exportStar(require("./PasswordPolicy"), exports);
|
|
47
|
+
__exportStar(require("./Plugin"), exports);
|
|
48
|
+
__exportStar(require("./Policy"), exports);
|
|
49
|
+
__exportStar(require("./PolicyRestrictions"), exports);
|
|
50
|
+
__exportStar(require("./ProfileDefinition"), exports);
|
|
51
|
+
__exportStar(require("./RoleDefinition"), exports);
|
|
52
|
+
__exportStar(require("./Target"), exports);
|
|
53
|
+
__exportStar(require("./Token"), exports);
|
|
54
|
+
__exportStar(require("./User"), exports);
|
|
55
|
+
__exportStar(require("./config/DumpConfiguration"), exports);
|
|
56
|
+
__exportStar(require("./config/HttpConfiguration"), exports);
|
|
51
57
|
__exportStar(require("./config/KuzzleConfiguration"), exports);
|
|
58
|
+
__exportStar(require("./config/LimitsConfiguration"), exports);
|
|
59
|
+
__exportStar(require("./config/PluginsConfiguration"), exports);
|
|
60
|
+
__exportStar(require("./config/SecurityConfiguration"), exports);
|
|
52
61
|
__exportStar(require("./config/ServerConfiguration"), exports);
|
|
53
62
|
__exportStar(require("./config/ServicesConfiguration"), exports);
|
|
54
|
-
__exportStar(require("./config/SecurityConfiguration"), exports);
|
|
55
|
-
__exportStar(require("./config/HttpConfiguration"), exports);
|
|
56
|
-
__exportStar(require("./config/PluginsConfiguration"), exports);
|
|
57
|
-
__exportStar(require("./RoleDefinition"), exports);
|
|
58
|
-
__exportStar(require("./ProfileDefinition"), exports);
|
|
59
|
-
__exportStar(require("./Plugin"), exports);
|
|
60
|
-
__exportStar(require("./config/LimitsConfiguration"), exports);
|
|
61
|
-
__exportStar(require("./RoleDefinition"), exports);
|
|
62
|
-
__exportStar(require("./ProfileDefinition"), exports);
|
|
63
|
-
__exportStar(require("./realtime/RealtimeScope"), exports);
|
|
64
|
-
__exportStar(require("./realtime/RealtimeUsers"), exports);
|
|
65
|
-
__exportStar(require("./realtime/RoomList"), exports);
|
|
66
|
-
__exportStar(require("./KuzzleDocument"), exports);
|
|
67
|
-
__exportStar(require("./config/publicCache/PublicCacheRedisConfiguration"), exports);
|
|
68
63
|
__exportStar(require("./config/internalCache/InternalCacheRedisConfiguration"), exports);
|
|
64
|
+
__exportStar(require("./config/publicCache/PublicCacheRedisConfiguration"), exports);
|
|
69
65
|
__exportStar(require("./config/storageEngine/StorageEngineElasticsearchConfiguration"), exports);
|
|
70
|
-
__exportStar(require("./config/DumpConfiguration"), exports);
|
|
71
|
-
__exportStar(require("./OpenApiDefinition"), exports);
|
|
72
66
|
__exportStar(require("./errors/ErrorDefinition"), exports);
|
|
73
67
|
__exportStar(require("./errors/ErrorDomains"), exports);
|
|
74
68
|
__exportStar(require("./events/EventGenericDocument"), exports);
|
|
75
69
|
__exportStar(require("./events/EventProtocol"), exports);
|
|
70
|
+
__exportStar(require("./realtime/RealtimeScope"), exports);
|
|
71
|
+
__exportStar(require("./realtime/RealtimeUsers"), exports);
|
|
72
|
+
__exportStar(require("./realtime/RoomList"), exports);
|
|
73
|
+
__exportStar(require("./shared/StoreCollectionsDefinition"), exports);
|
|
76
74
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { JSONObject } from "../../../index";
|
|
2
|
+
export interface StoreCollectionDefinition {
|
|
3
|
+
/**
|
|
4
|
+
* Collection mappings
|
|
5
|
+
*/
|
|
6
|
+
mappings: JSONObject;
|
|
7
|
+
/**
|
|
8
|
+
* Collection settings
|
|
9
|
+
*/
|
|
10
|
+
settings?: JSONObject;
|
|
11
|
+
}
|
|
12
|
+
export type StoreCollectionsDefinition = Record<string, StoreCollectionDefinition>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kuzzle",
|
|
3
3
|
"author": "The Kuzzle Team <support@kuzzle.io>",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.30.0-beta.1",
|
|
5
5
|
"description": "Kuzzle is an open-source solution that handles all the data management through a secured API, with a large choice of protocols.",
|
|
6
6
|
"bin": "bin/start-kuzzle-server",
|
|
7
7
|
"scripts": {
|
|
@@ -21,9 +21,7 @@
|
|
|
21
21
|
"test:functional:legacy": "npm run test:functional:legacy:http && npm run test:functional:legacy:websocket && npm run test:functional:legacy:mqtt",
|
|
22
22
|
"test:functional:websocket": "KUZZLE_PROTOCOL=websocket cucumber-js --profile websocket",
|
|
23
23
|
"test:functional": "npm run test:functional:http && npm run test:functional:websocket && npm run test:functional:jest",
|
|
24
|
-
"test:lint
|
|
25
|
-
"test:lint:ts": "eslint ./lib --ext .ts --config .eslintc-ts.json",
|
|
26
|
-
"test:lint": "npm run test:lint:js && npm run test:lint:ts",
|
|
24
|
+
"test:lint": "eslint ./lib ./test ./bin ./features ./plugins/available/functional-test-plugin",
|
|
27
25
|
"test:unit": "DEBUG= npx --node-arg=--trace-warnings mocha --exit",
|
|
28
26
|
"test": "npm run clean && npm run --silent test:lint && npm run build && npm run test:unit:coverage && npm run test:functional"
|
|
29
27
|
},
|