@webiny/api-elasticsearch-tasks 0.0.0-unstable.2696f9d9e8
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/LICENSE +21 -0
- package/README.md +10 -0
- package/definitions/entry.d.ts +7 -0
- package/definitions/entry.js +36 -0
- package/definitions/entry.js.map +1 -0
- package/definitions/index.d.ts +2 -0
- package/definitions/index.js +29 -0
- package/definitions/index.js.map +1 -0
- package/definitions/table.d.ts +7 -0
- package/definitions/table.js +23 -0
- package/definitions/table.js.map +1 -0
- package/errors/IndexSettingsGetError.d.ts +6 -0
- package/errors/IndexSettingsGetError.js +20 -0
- package/errors/IndexSettingsGetError.js.map +1 -0
- package/errors/IndexSettingsSetError.d.ts +6 -0
- package/errors/IndexSettingsSetError.js +20 -0
- package/errors/IndexSettingsSetError.js.map +1 -0
- package/errors/IndexingDisableError.d.ts +2 -0
- package/errors/IndexingDisableError.js +10 -0
- package/errors/IndexingDisableError.js.map +1 -0
- package/errors/IndexingEnableError.d.ts +2 -0
- package/errors/IndexingEnableError.js +10 -0
- package/errors/IndexingEnableError.js.map +1 -0
- package/errors/index.d.ts +4 -0
- package/errors/index.js +51 -0
- package/errors/index.js.map +1 -0
- package/helpers/scan.d.ts +10 -0
- package/helpers/scan.js +24 -0
- package/helpers/scan.js.map +1 -0
- package/index.d.ts +4 -0
- package/index.js +13 -0
- package/index.js.map +1 -0
- package/package.json +54 -0
- package/settings/DisableIndexing.d.ts +7 -0
- package/settings/DisableIndexing.js +27 -0
- package/settings/DisableIndexing.js.map +1 -0
- package/settings/EnableIndexing.d.ts +7 -0
- package/settings/EnableIndexing.js +24 -0
- package/settings/EnableIndexing.js.map +1 -0
- package/settings/IndexManager.d.ts +12 -0
- package/settings/IndexManager.js +49 -0
- package/settings/IndexManager.js.map +1 -0
- package/settings/IndexSettingsManager.d.ts +8 -0
- package/settings/IndexSettingsManager.js +44 -0
- package/settings/IndexSettingsManager.js.map +1 -0
- package/settings/index.d.ts +1 -0
- package/settings/index.js +18 -0
- package/settings/index.js.map +1 -0
- package/settings/types.d.ts +6 -0
- package/settings/types.js +7 -0
- package/settings/types.js.map +1 -0
- package/tasks/Manager.d.ts +32 -0
- package/tasks/Manager.js +52 -0
- package/tasks/Manager.js.map +1 -0
- package/tasks/index.d.ts +1 -0
- package/tasks/index.js +18 -0
- package/tasks/index.js.map +1 -0
- package/tasks/reindexing/ReindexingTaskRunner.d.ts +16 -0
- package/tasks/reindexing/ReindexingTaskRunner.js +126 -0
- package/tasks/reindexing/ReindexingTaskRunner.js.map +1 -0
- package/tasks/reindexing/index.d.ts +1 -0
- package/tasks/reindexing/index.js +18 -0
- package/tasks/reindexing/index.js.map +1 -0
- package/tasks/reindexing/reindexingTaskDefinition.d.ts +8 -0
- package/tasks/reindexing/reindexingTaskDefinition.js +47 -0
- package/tasks/reindexing/reindexingTaskDefinition.js.map +1 -0
- package/types.d.ts +52 -0
- package/types.js +7 -0
- package/types.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Webiny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @webiny/api-elasticsearch-tasks
|
|
2
|
+
[](https://www.npmjs.com/package/@webiny/api-elasticsearch-tasks)
|
|
3
|
+
[](https://www.npmjs.com/package/@webiny/api-elasticsearch-tasks)
|
|
4
|
+
[](https://github.com/prettier/prettier)
|
|
5
|
+
[](http://makeapullrequest.com)
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
```
|
|
9
|
+
yarn add @webiny/api-elasticsearch-tasks
|
|
10
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createEntry = void 0;
|
|
7
|
+
var _toolbox = require("@webiny/db-dynamodb/toolbox");
|
|
8
|
+
const createEntry = params => {
|
|
9
|
+
const {
|
|
10
|
+
table,
|
|
11
|
+
entityName
|
|
12
|
+
} = params;
|
|
13
|
+
return new _toolbox.Entity({
|
|
14
|
+
name: entityName,
|
|
15
|
+
table,
|
|
16
|
+
attributes: {
|
|
17
|
+
PK: {
|
|
18
|
+
type: "string",
|
|
19
|
+
partitionKey: true
|
|
20
|
+
},
|
|
21
|
+
SK: {
|
|
22
|
+
type: "string",
|
|
23
|
+
sortKey: true
|
|
24
|
+
},
|
|
25
|
+
index: {
|
|
26
|
+
type: "string"
|
|
27
|
+
},
|
|
28
|
+
data: {
|
|
29
|
+
type: "map"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
exports.createEntry = createEntry;
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_toolbox","require","createEntry","params","table","entityName","Entity","name","attributes","PK","type","partitionKey","SK","sortKey","index","data","exports"],"sources":["entry.ts"],"sourcesContent":["import { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\n\ninterface Params {\n table: Table<string, string, string>;\n entityName: string;\n}\n\nexport const createEntry = (params: Params): Entity<any> => {\n const { table, entityName } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n type: \"string\",\n partitionKey: true\n },\n SK: {\n type: \"string\",\n sortKey: true\n },\n index: {\n type: \"string\"\n },\n data: {\n type: \"map\"\n }\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAOO,MAAMC,WAAW,GAAIC,MAAc,IAAkB;EACxD,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,MAAM;EACpC,OAAO,IAAIG,eAAM,CAAC;IACdC,IAAI,EAAEF,UAAU;IAChBD,KAAK;IACLI,UAAU,EAAE;MACRC,EAAE,EAAE;QACAC,IAAI,EAAE,QAAQ;QACdC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAF,IAAI,EAAE,QAAQ;QACdG,OAAO,EAAE;MACb,CAAC;MACDC,KAAK,EAAE;QACHJ,IAAI,EAAE;MACV,CAAC;MACDK,IAAI,EAAE;QACFL,IAAI,EAAE;MACV;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAACM,OAAA,CAAAd,WAAA,GAAAA,WAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
getDocumentClient: true
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "getDocumentClient", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _clientDynamodb.getDocumentClient;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
var _clientDynamodb = require("@webiny/aws-sdk/client-dynamodb");
|
|
16
|
+
var _table = require("./table");
|
|
17
|
+
Object.keys(_table).forEach(function (key) {
|
|
18
|
+
if (key === "default" || key === "__esModule") return;
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
20
|
+
if (key in exports && exports[key] === _table[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _table[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_clientDynamodb","require","_table","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export { getDocumentClient } from \"@webiny/aws-sdk/client-dynamodb\";\nexport * from \"./table\";\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DynamoDBClient } from "@webiny/aws-sdk/client-dynamodb";
|
|
2
|
+
import { Table } from "@webiny/db-dynamodb/toolbox";
|
|
3
|
+
interface Params {
|
|
4
|
+
documentClient: DynamoDBClient;
|
|
5
|
+
}
|
|
6
|
+
export declare const createTable: ({ documentClient }: Params) => Table<string, string, string>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createTable = void 0;
|
|
7
|
+
var _toolbox = require("@webiny/db-dynamodb/toolbox");
|
|
8
|
+
const createTable = ({
|
|
9
|
+
documentClient
|
|
10
|
+
}) => {
|
|
11
|
+
const config = {
|
|
12
|
+
name: process.env.DB_TABLE_ELASTICSEARCH,
|
|
13
|
+
partitionKey: "PK",
|
|
14
|
+
sortKey: "SK",
|
|
15
|
+
DocumentClient: documentClient,
|
|
16
|
+
autoExecute: true,
|
|
17
|
+
autoParse: true
|
|
18
|
+
};
|
|
19
|
+
return new _toolbox.Table(config);
|
|
20
|
+
};
|
|
21
|
+
exports.createTable = createTable;
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_toolbox","require","createTable","documentClient","config","name","process","env","DB_TABLE_ELASTICSEARCH","partitionKey","sortKey","DocumentClient","autoExecute","autoParse","Table","exports"],"sources":["table.ts"],"sourcesContent":["import { DynamoDBClient } from \"@webiny/aws-sdk/client-dynamodb\";\nimport { Table, TableConstructor } from \"@webiny/db-dynamodb/toolbox\";\n\ninterface Params {\n documentClient: DynamoDBClient;\n}\n\nexport const createTable = ({ documentClient }: Params): Table<string, string, string> => {\n const config: TableConstructor<string, string, string> = {\n name: process.env.DB_TABLE_ELASTICSEARCH as string,\n partitionKey: \"PK\",\n sortKey: \"SK\",\n DocumentClient: documentClient,\n autoExecute: true,\n autoParse: true\n };\n\n return new Table(config);\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAMO,MAAMC,WAAW,GAAGA,CAAC;EAAEC;AAAuB,CAAC,KAAoC;EACtF,MAAMC,MAAgD,GAAG;IACrDC,IAAI,EAAEC,OAAO,CAACC,GAAG,CAACC,sBAAgC;IAClDC,YAAY,EAAE,IAAI;IAClBC,OAAO,EAAE,IAAI;IACbC,cAAc,EAAER,cAAc;IAC9BS,WAAW,EAAE,IAAI;IACjBC,SAAS,EAAE;EACf,CAAC;EAED,OAAO,IAAIC,cAAK,CAACV,MAAM,CAAC;AAC5B,CAAC;AAACW,OAAA,CAAAb,WAAA,GAAAA,WAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.IndexSettingsGetError = void 0;
|
|
8
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
class IndexSettingsGetError extends _error.default {
|
|
10
|
+
constructor(error, index) {
|
|
11
|
+
super(error.message, "GET_INDEX_SETTINGS_ERROR", {
|
|
12
|
+
...error.data,
|
|
13
|
+
index
|
|
14
|
+
});
|
|
15
|
+
this.index = index;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.IndexSettingsGetError = IndexSettingsGetError;
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=IndexSettingsGetError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","IndexSettingsGetError","WebinyError","constructor","error","index","message","data","exports"],"sources":["IndexSettingsGetError.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { AugmentedError } from \"~/types\";\n\nexport class IndexSettingsGetError extends WebinyError {\n public readonly index: string;\n\n public constructor(error: AugmentedError, index: string) {\n super(error.message, \"GET_INDEX_SETTINGS_ERROR\", {\n ...error.data,\n index\n });\n this.index = index;\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGO,MAAMC,qBAAqB,SAASC,cAAW,CAAC;EAG5CC,WAAWA,CAACC,KAAqB,EAAEC,KAAa,EAAE;IACrD,KAAK,CAACD,KAAK,CAACE,OAAO,EAAE,0BAA0B,EAAE;MAC7C,GAAGF,KAAK,CAACG,IAAI;MACbF;IACJ,CAAC,CAAC;IACF,IAAI,CAACA,KAAK,GAAGA,KAAK;EACtB;AACJ;AAACG,OAAA,CAAAP,qBAAA,GAAAA,qBAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.IndexSettingsSetError = void 0;
|
|
8
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
class IndexSettingsSetError extends _error.default {
|
|
10
|
+
constructor(error, index) {
|
|
11
|
+
super(error.message, "SET_INDEX_SETTINGS_ERROR", {
|
|
12
|
+
...error.data,
|
|
13
|
+
index
|
|
14
|
+
});
|
|
15
|
+
this.index = index;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.IndexSettingsSetError = IndexSettingsSetError;
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=IndexSettingsSetError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","IndexSettingsSetError","WebinyError","constructor","error","index","message","data","exports"],"sources":["IndexSettingsSetError.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { AugmentedError } from \"~/types\";\n\nexport class IndexSettingsSetError extends WebinyError {\n public readonly index: string;\n\n public constructor(error: AugmentedError, index: string) {\n super(error.message, \"SET_INDEX_SETTINGS_ERROR\", {\n ...error.data,\n index\n });\n this.index = index;\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGO,MAAMC,qBAAqB,SAASC,cAAW,CAAC;EAG5CC,WAAWA,CAACC,KAAqB,EAAEC,KAAa,EAAE;IACrD,KAAK,CAACD,KAAK,CAACE,OAAO,EAAE,0BAA0B,EAAE;MAC7C,GAAGF,KAAK,CAACG,IAAI;MACbF;IACJ,CAAC,CAAC;IACF,IAAI,CAACA,KAAK,GAAGA,KAAK;EACtB;AACJ;AAACG,OAAA,CAAAP,qBAAA,GAAAA,qBAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.IndexingDisableError = void 0;
|
|
7
|
+
class IndexingDisableError extends Error {}
|
|
8
|
+
exports.IndexingDisableError = IndexingDisableError;
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=IndexingDisableError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["IndexingDisableError","Error","exports"],"sources":["IndexingDisableError.ts"],"sourcesContent":["export class IndexingDisableError extends Error {}\n"],"mappings":";;;;;;AAAO,MAAMA,oBAAoB,SAASC,KAAK,CAAC;AAAEC,OAAA,CAAAF,oBAAA,GAAAA,oBAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.IndexingEnableError = void 0;
|
|
7
|
+
class IndexingEnableError extends Error {}
|
|
8
|
+
exports.IndexingEnableError = IndexingEnableError;
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=IndexingEnableError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["IndexingEnableError","Error","exports"],"sources":["IndexingEnableError.ts"],"sourcesContent":["export class IndexingEnableError extends Error {}\n"],"mappings":";;;;;;AAAO,MAAMA,mBAAmB,SAASC,KAAK,CAAC;AAAEC,OAAA,CAAAF,mBAAA,GAAAA,mBAAA"}
|
package/errors/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _IndexingDisableError = require("./IndexingDisableError");
|
|
7
|
+
Object.keys(_IndexingDisableError).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _IndexingDisableError[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _IndexingDisableError[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _IndexingEnableError = require("./IndexingEnableError");
|
|
18
|
+
Object.keys(_IndexingEnableError).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _IndexingEnableError[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _IndexingEnableError[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _IndexSettingsGetError = require("./IndexSettingsGetError");
|
|
29
|
+
Object.keys(_IndexSettingsGetError).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _IndexSettingsGetError[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _IndexSettingsGetError[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _IndexSettingsSetError = require("./IndexSettingsSetError");
|
|
40
|
+
Object.keys(_IndexSettingsSetError).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _IndexSettingsSetError[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _IndexSettingsSetError[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_IndexingDisableError","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_IndexingEnableError","_IndexSettingsGetError","_IndexSettingsSetError"],"sources":["index.ts"],"sourcesContent":["export * from \"./IndexingDisableError\";\nexport * from \"./IndexingEnableError\";\nexport * from \"./IndexSettingsGetError\";\nexport * from \"./IndexSettingsSetError\";\n"],"mappings":";;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,qBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,qBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,qBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,oBAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,oBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,oBAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,oBAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,sBAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,sBAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,sBAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,sBAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,sBAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,sBAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,sBAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,sBAAA,CAAAP,GAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ScanOptions } from "@webiny/db-dynamodb";
|
|
2
|
+
import { Table } from "@webiny/db-dynamodb/toolbox";
|
|
3
|
+
import { IElasticsearchIndexingTaskValuesKeys } from "../types";
|
|
4
|
+
interface Params {
|
|
5
|
+
table: Table<string, string, string>;
|
|
6
|
+
keys?: IElasticsearchIndexingTaskValuesKeys;
|
|
7
|
+
options?: Pick<ScanOptions, "limit">;
|
|
8
|
+
}
|
|
9
|
+
export declare const scan: <T = any>(params: Params) => Promise<import("@webiny/db-dynamodb").ScanResponse<T>>;
|
|
10
|
+
export {};
|
package/helpers/scan.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.scan = void 0;
|
|
7
|
+
var _dbDynamodb = require("@webiny/db-dynamodb");
|
|
8
|
+
const scan = async params => {
|
|
9
|
+
const {
|
|
10
|
+
table,
|
|
11
|
+
keys
|
|
12
|
+
} = params;
|
|
13
|
+
return (0, _dbDynamodb.scan)({
|
|
14
|
+
table,
|
|
15
|
+
options: {
|
|
16
|
+
startKey: keys,
|
|
17
|
+
limit: 200,
|
|
18
|
+
...params.options
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
exports.scan = scan;
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=scan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_dbDynamodb","require","scan","params","table","keys","tableScan","options","startKey","limit","exports"],"sources":["scan.ts"],"sourcesContent":["import { scan as tableScan, ScanOptions } from \"@webiny/db-dynamodb\";\nimport { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { IElasticsearchIndexingTaskValuesKeys } from \"~/types\";\n\ninterface Params {\n table: Table<string, string, string>;\n keys?: IElasticsearchIndexingTaskValuesKeys;\n options?: Pick<ScanOptions, \"limit\">;\n}\n\nexport const scan = async <T = any>(params: Params) => {\n const { table, keys } = params;\n return tableScan<T>({\n table,\n options: {\n startKey: keys,\n limit: 200,\n ...params.options\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAUO,MAAMC,IAAI,GAAG,MAAgBC,MAAc,IAAK;EACnD,MAAM;IAAEC,KAAK;IAAEC;EAAK,CAAC,GAAGF,MAAM;EAC9B,OAAO,IAAAG,gBAAS,EAAI;IAChBF,KAAK;IACLG,OAAO,EAAE;MACLC,QAAQ,EAAEH,IAAI;MACdI,KAAK,EAAE,GAAG;MACV,GAAGN,MAAM,CAACI;IACd;EACJ,CAAC,CAAC;AACN,CAAC;AAACG,OAAA,CAAAR,IAAA,GAAAA,IAAA"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CreateElasticsearchIndexTaskConfig } from "./tasks";
|
|
2
|
+
import { Plugin } from "@webiny/plugins/types";
|
|
3
|
+
export declare type CreateElasticsearchBackgroundTasksParams = CreateElasticsearchIndexTaskConfig;
|
|
4
|
+
export declare const createElasticsearchBackgroundTasks: (params?: CreateElasticsearchBackgroundTasksParams) => Plugin[];
|
package/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createElasticsearchBackgroundTasks = void 0;
|
|
7
|
+
var _tasks = require("./tasks");
|
|
8
|
+
const createElasticsearchBackgroundTasks = params => {
|
|
9
|
+
return [(0, _tasks.createElasticsearchReindexingTask)(params)];
|
|
10
|
+
};
|
|
11
|
+
exports.createElasticsearchBackgroundTasks = createElasticsearchBackgroundTasks;
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_tasks","require","createElasticsearchBackgroundTasks","params","createElasticsearchReindexingTask","exports"],"sources":["index.ts"],"sourcesContent":["import { CreateElasticsearchIndexTaskConfig, createElasticsearchReindexingTask } from \"~/tasks\";\nimport { Plugin } from \"@webiny/plugins/types\";\n\nexport type CreateElasticsearchBackgroundTasksParams = CreateElasticsearchIndexTaskConfig;\n\nexport const createElasticsearchBackgroundTasks = (\n params?: CreateElasticsearchBackgroundTasksParams\n): Plugin[] => {\n return [createElasticsearchReindexingTask(params)];\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAKO,MAAMC,kCAAkC,GAC3CC,MAAiD,IACtC;EACX,OAAO,CAAC,IAAAC,wCAAiC,EAACD,MAAM,CAAC,CAAC;AACtD,CAAC;AAACE,OAAA,CAAAH,kCAAA,GAAAA,kCAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webiny/api-elasticsearch-tasks",
|
|
3
|
+
"version": "0.0.0-unstable.2696f9d9e8",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/webiny/webiny-js.git"
|
|
8
|
+
},
|
|
9
|
+
"description": "Tasks",
|
|
10
|
+
"contributors": [
|
|
11
|
+
"Bruno Zorić <bruno@webiny.com>"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@babel/runtime": "7.22.6",
|
|
16
|
+
"@webiny/api-elasticsearch": "0.0.0-unstable.2696f9d9e8",
|
|
17
|
+
"@webiny/aws-sdk": "0.0.0-unstable.2696f9d9e8",
|
|
18
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.2696f9d9e8",
|
|
19
|
+
"@webiny/error": "0.0.0-unstable.2696f9d9e8",
|
|
20
|
+
"@webiny/tasks": "0.0.0-unstable.2696f9d9e8"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@babel/cli": "7.22.6",
|
|
24
|
+
"@babel/core": "7.22.8",
|
|
25
|
+
"@babel/preset-env": "7.22.7",
|
|
26
|
+
"@babel/preset-typescript": "7.22.5",
|
|
27
|
+
"@webiny/api": "0.0.0-unstable.2696f9d9e8",
|
|
28
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.2696f9d9e8",
|
|
29
|
+
"@webiny/api-i18n": "0.0.0-unstable.2696f9d9e8",
|
|
30
|
+
"@webiny/api-security": "0.0.0-unstable.2696f9d9e8",
|
|
31
|
+
"@webiny/api-tenancy": "0.0.0-unstable.2696f9d9e8",
|
|
32
|
+
"@webiny/api-wcp": "0.0.0-unstable.2696f9d9e8",
|
|
33
|
+
"@webiny/cli": "0.0.0-unstable.2696f9d9e8",
|
|
34
|
+
"@webiny/handler": "0.0.0-unstable.2696f9d9e8",
|
|
35
|
+
"@webiny/handler-aws": "0.0.0-unstable.2696f9d9e8",
|
|
36
|
+
"@webiny/handler-db": "0.0.0-unstable.2696f9d9e8",
|
|
37
|
+
"@webiny/handler-graphql": "0.0.0-unstable.2696f9d9e8",
|
|
38
|
+
"@webiny/plugins": "0.0.0-unstable.2696f9d9e8",
|
|
39
|
+
"@webiny/project-utils": "0.0.0-unstable.2696f9d9e8",
|
|
40
|
+
"rimraf": "3.0.2",
|
|
41
|
+
"ttypescript": "1.5.15",
|
|
42
|
+
"type-fest": "2.19.0",
|
|
43
|
+
"typescript": "4.7.4"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public",
|
|
47
|
+
"directory": "dist"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "yarn webiny run build",
|
|
51
|
+
"watch": "yarn webiny run watch"
|
|
52
|
+
},
|
|
53
|
+
"gitHead": "2696f9d9e84ad621e1412a05e1252b5ca9c245fb"
|
|
54
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IIndexSettingsValues } from "../types";
|
|
2
|
+
import { IndexSettingsManager } from "./IndexSettingsManager";
|
|
3
|
+
export declare class DisableIndexing {
|
|
4
|
+
private readonly settings;
|
|
5
|
+
constructor(settings: IndexSettingsManager);
|
|
6
|
+
exec(index: string): Promise<IIndexSettingsValues>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DisableIndexing = void 0;
|
|
7
|
+
var _errors = require("../errors");
|
|
8
|
+
class DisableIndexing {
|
|
9
|
+
constructor(settings) {
|
|
10
|
+
this.settings = settings;
|
|
11
|
+
}
|
|
12
|
+
async exec(index) {
|
|
13
|
+
const settings = await this.settings.getSettings(index);
|
|
14
|
+
try {
|
|
15
|
+
await this.settings.setSettings(index, {
|
|
16
|
+
numberOfReplicas: 0,
|
|
17
|
+
refreshInterval: "-1"
|
|
18
|
+
});
|
|
19
|
+
} catch (ex) {
|
|
20
|
+
throw new _errors.IndexingDisableError(ex);
|
|
21
|
+
}
|
|
22
|
+
return settings;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.DisableIndexing = DisableIndexing;
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=DisableIndexing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_errors","require","DisableIndexing","constructor","settings","exec","index","getSettings","setSettings","numberOfReplicas","refreshInterval","ex","IndexingDisableError","exports"],"sources":["DisableIndexing.ts"],"sourcesContent":["import { IndexingDisableError } from \"~/errors\";\nimport { IIndexSettingsValues } from \"~/types\";\nimport { IndexSettingsManager } from \"./IndexSettingsManager\";\n\nexport class DisableIndexing {\n private readonly settings: IndexSettingsManager;\n\n public constructor(settings: IndexSettingsManager) {\n this.settings = settings;\n }\n\n public async exec(index: string): Promise<IIndexSettingsValues> {\n const settings = await this.settings.getSettings(index);\n\n try {\n await this.settings.setSettings(index, {\n numberOfReplicas: 0,\n refreshInterval: \"-1\"\n });\n } catch (ex) {\n throw new IndexingDisableError(ex);\n }\n\n return settings;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAIO,MAAMC,eAAe,CAAC;EAGlBC,WAAWA,CAACC,QAA8B,EAAE;IAC/C,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEA,MAAaC,IAAIA,CAACC,KAAa,EAAiC;IAC5D,MAAMF,QAAQ,GAAG,MAAM,IAAI,CAACA,QAAQ,CAACG,WAAW,CAACD,KAAK,CAAC;IAEvD,IAAI;MACA,MAAM,IAAI,CAACF,QAAQ,CAACI,WAAW,CAACF,KAAK,EAAE;QACnCG,gBAAgB,EAAE,CAAC;QACnBC,eAAe,EAAE;MACrB,CAAC,CAAC;IACN,CAAC,CAAC,OAAOC,EAAE,EAAE;MACT,MAAM,IAAIC,4BAAoB,CAACD,EAAE,CAAC;IACtC;IAEA,OAAOP,QAAQ;EACnB;AACJ;AAACS,OAAA,CAAAX,eAAA,GAAAA,eAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IIndexSettingsValues } from "../types";
|
|
2
|
+
import { IndexSettingsManager } from "./IndexSettingsManager";
|
|
3
|
+
export declare class EnableIndexing {
|
|
4
|
+
private readonly settings;
|
|
5
|
+
constructor(settings: IndexSettingsManager);
|
|
6
|
+
exec(index: string, settings: IIndexSettingsValues): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EnableIndexing = void 0;
|
|
7
|
+
var _errors = require("../errors");
|
|
8
|
+
class EnableIndexing {
|
|
9
|
+
constructor(settings) {
|
|
10
|
+
this.settings = settings;
|
|
11
|
+
}
|
|
12
|
+
async exec(index, settings) {
|
|
13
|
+
try {
|
|
14
|
+
await this.settings.setSettings(index, {
|
|
15
|
+
...settings
|
|
16
|
+
});
|
|
17
|
+
} catch (ex) {
|
|
18
|
+
throw new _errors.IndexingEnableError(ex);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.EnableIndexing = EnableIndexing;
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=EnableIndexing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_errors","require","EnableIndexing","constructor","settings","exec","index","setSettings","ex","IndexingEnableError","exports"],"sources":["EnableIndexing.ts"],"sourcesContent":["import { IndexingEnableError } from \"~/errors\";\nimport { IIndexSettingsValues } from \"~/types\";\nimport { IndexSettingsManager } from \"./IndexSettingsManager\";\n\nexport class EnableIndexing {\n private readonly settings: IndexSettingsManager;\n\n public constructor(settings: IndexSettingsManager) {\n this.settings = settings;\n }\n\n public async exec(index: string, settings: IIndexSettingsValues): Promise<void> {\n try {\n await this.settings.setSettings(index, {\n ...settings\n });\n } catch (ex) {\n throw new IndexingEnableError(ex);\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAIO,MAAMC,cAAc,CAAC;EAGjBC,WAAWA,CAACC,QAA8B,EAAE;IAC/C,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEA,MAAaC,IAAIA,CAACC,KAAa,EAAEF,QAA8B,EAAiB;IAC5E,IAAI;MACA,MAAM,IAAI,CAACA,QAAQ,CAACG,WAAW,CAACD,KAAK,EAAE;QACnC,GAAGF;MACP,CAAC,CAAC;IACN,CAAC,CAAC,OAAOI,EAAE,EAAE;MACT,MAAM,IAAIC,2BAAmB,CAACD,EAAE,CAAC;IACrC;EACJ;AACJ;AAACE,OAAA,CAAAR,cAAA,GAAAA,cAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IElasticsearchIndexingTaskValuesSettings } from "../types";
|
|
2
|
+
import { IIndexManager } from "./types";
|
|
3
|
+
import { Client } from "@webiny/api-elasticsearch";
|
|
4
|
+
export declare class IndexManager implements IIndexManager {
|
|
5
|
+
private readonly disable;
|
|
6
|
+
private readonly enable;
|
|
7
|
+
private readonly _settings;
|
|
8
|
+
get settings(): IElasticsearchIndexingTaskValuesSettings;
|
|
9
|
+
constructor(client: Client, settings: IElasticsearchIndexingTaskValuesSettings);
|
|
10
|
+
disableIndexing(index: string): Promise<import("../types").IIndexSettingsValues>;
|
|
11
|
+
enableIndexing(index?: string): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.IndexManager = void 0;
|
|
7
|
+
var _IndexSettingsManager = require("./IndexSettingsManager");
|
|
8
|
+
var _DisableIndexing = require("./DisableIndexing");
|
|
9
|
+
var _EnableIndexing = require("./EnableIndexing");
|
|
10
|
+
const defaultIndexSettings = {
|
|
11
|
+
numberOfReplicas: 1,
|
|
12
|
+
refreshInterval: "1s"
|
|
13
|
+
};
|
|
14
|
+
class IndexManager {
|
|
15
|
+
get settings() {
|
|
16
|
+
return this._settings;
|
|
17
|
+
}
|
|
18
|
+
constructor(client, settings) {
|
|
19
|
+
const indexSettings = new _IndexSettingsManager.IndexSettingsManager(client);
|
|
20
|
+
this.disable = new _DisableIndexing.DisableIndexing(indexSettings);
|
|
21
|
+
this.enable = new _EnableIndexing.EnableIndexing(indexSettings);
|
|
22
|
+
this._settings = settings;
|
|
23
|
+
}
|
|
24
|
+
async disableIndexing(index) {
|
|
25
|
+
/**
|
|
26
|
+
* No need to disable indexing if it's already disabled.
|
|
27
|
+
*/
|
|
28
|
+
if (this._settings[index]) {
|
|
29
|
+
return this._settings[index];
|
|
30
|
+
}
|
|
31
|
+
const settings = await this.disable.exec(index);
|
|
32
|
+
this._settings[index] = settings;
|
|
33
|
+
return settings;
|
|
34
|
+
}
|
|
35
|
+
async enableIndexing(index) {
|
|
36
|
+
if (!index) {
|
|
37
|
+
const indexes = Object.keys(this._settings);
|
|
38
|
+
for (const index of indexes) {
|
|
39
|
+
await this.enableIndexing(index);
|
|
40
|
+
}
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const settings = this._settings[index] || defaultIndexSettings;
|
|
44
|
+
await this.enable.exec(index, settings);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.IndexManager = IndexManager;
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=IndexManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_IndexSettingsManager","require","_DisableIndexing","_EnableIndexing","defaultIndexSettings","numberOfReplicas","refreshInterval","IndexManager","settings","_settings","constructor","client","indexSettings","IndexSettingsManager","disable","DisableIndexing","enable","EnableIndexing","disableIndexing","index","exec","enableIndexing","indexes","Object","keys","exports"],"sources":["IndexManager.ts"],"sourcesContent":["import { IndexSettingsManager } from \"~/settings/IndexSettingsManager\";\nimport { DisableIndexing } from \"./DisableIndexing\";\nimport { EnableIndexing } from \"./EnableIndexing\";\nimport { IElasticsearchIndexingTaskValuesSettings } from \"~/types\";\nimport { IIndexManager } from \"~/settings/types\";\nimport { Client } from \"@webiny/api-elasticsearch\";\n\nconst defaultIndexSettings = {\n numberOfReplicas: 1,\n refreshInterval: \"1s\"\n};\n\nexport class IndexManager implements IIndexManager {\n private readonly disable: DisableIndexing;\n private readonly enable: EnableIndexing;\n private readonly _settings: IElasticsearchIndexingTaskValuesSettings;\n\n public get settings(): IElasticsearchIndexingTaskValuesSettings {\n return this._settings;\n }\n\n public constructor(client: Client, settings: IElasticsearchIndexingTaskValuesSettings) {\n const indexSettings = new IndexSettingsManager(client);\n this.disable = new DisableIndexing(indexSettings);\n this.enable = new EnableIndexing(indexSettings);\n this._settings = settings;\n }\n\n public async disableIndexing(index: string) {\n /**\n * No need to disable indexing if it's already disabled.\n */\n if (this._settings[index]) {\n return this._settings[index];\n }\n const settings = await this.disable.exec(index);\n this._settings[index] = settings;\n return settings;\n }\n\n public async enableIndexing(index?: string) {\n if (!index) {\n const indexes = Object.keys(this._settings);\n for (const index of indexes) {\n await this.enableIndexing(index);\n }\n return;\n }\n const settings = this._settings[index] || defaultIndexSettings;\n await this.enable.exec(index, settings);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAKA,MAAMG,oBAAoB,GAAG;EACzBC,gBAAgB,EAAE,CAAC;EACnBC,eAAe,EAAE;AACrB,CAAC;AAEM,MAAMC,YAAY,CAA0B;EAK/C,IAAWC,QAAQA,CAAA,EAA6C;IAC5D,OAAO,IAAI,CAACC,SAAS;EACzB;EAEOC,WAAWA,CAACC,MAAc,EAAEH,QAAkD,EAAE;IACnF,MAAMI,aAAa,GAAG,IAAIC,0CAAoB,CAACF,MAAM,CAAC;IACtD,IAAI,CAACG,OAAO,GAAG,IAAIC,gCAAe,CAACH,aAAa,CAAC;IACjD,IAAI,CAACI,MAAM,GAAG,IAAIC,8BAAc,CAACL,aAAa,CAAC;IAC/C,IAAI,CAACH,SAAS,GAAGD,QAAQ;EAC7B;EAEA,MAAaU,eAAeA,CAACC,KAAa,EAAE;IACxC;AACR;AACA;IACQ,IAAI,IAAI,CAACV,SAAS,CAACU,KAAK,CAAC,EAAE;MACvB,OAAO,IAAI,CAACV,SAAS,CAACU,KAAK,CAAC;IAChC;IACA,MAAMX,QAAQ,GAAG,MAAM,IAAI,CAACM,OAAO,CAACM,IAAI,CAACD,KAAK,CAAC;IAC/C,IAAI,CAACV,SAAS,CAACU,KAAK,CAAC,GAAGX,QAAQ;IAChC,OAAOA,QAAQ;EACnB;EAEA,MAAaa,cAAcA,CAACF,KAAc,EAAE;IACxC,IAAI,CAACA,KAAK,EAAE;MACR,MAAMG,OAAO,GAAGC,MAAM,CAACC,IAAI,CAAC,IAAI,CAACf,SAAS,CAAC;MAC3C,KAAK,MAAMU,KAAK,IAAIG,OAAO,EAAE;QACzB,MAAM,IAAI,CAACD,cAAc,CAACF,KAAK,CAAC;MACpC;MACA;IACJ;IACA,MAAMX,QAAQ,GAAG,IAAI,CAACC,SAAS,CAACU,KAAK,CAAC,IAAIf,oBAAoB;IAC9D,MAAM,IAAI,CAACY,MAAM,CAACI,IAAI,CAACD,KAAK,EAAEX,QAAQ,CAAC;EAC3C;AACJ;AAACiB,OAAA,CAAAlB,YAAA,GAAAA,YAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Client } from "@webiny/api-elasticsearch";
|
|
2
|
+
import { IIndexSettingsValues } from "../types";
|
|
3
|
+
export declare class IndexSettingsManager {
|
|
4
|
+
private readonly elasticsearch;
|
|
5
|
+
constructor(elasticsearch: Client);
|
|
6
|
+
getSettings(index: string): Promise<IIndexSettingsValues>;
|
|
7
|
+
setSettings(index: string, settings: IIndexSettingsValues): Promise<void>;
|
|
8
|
+
}
|