@webiny/api-headless-cms-es-tasks 0.0.0-unstable.39223eb3c1

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.
Files changed (60) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -0
  3. package/index.d.ts +3 -0
  4. package/index.js +37 -0
  5. package/index.js.map +1 -0
  6. package/package.json +45 -0
  7. package/tasks/MockDataCreator/MockDataCreator.d.ts +6 -0
  8. package/tasks/MockDataCreator/MockDataCreator.js +106 -0
  9. package/tasks/MockDataCreator/MockDataCreator.js.map +1 -0
  10. package/tasks/MockDataCreator/mockData.d.ts +520 -0
  11. package/tasks/MockDataCreator/mockData.js +1195 -0
  12. package/tasks/MockDataCreator/mockData.js.map +1 -0
  13. package/tasks/MockDataCreator/types.d.ts +6 -0
  14. package/tasks/MockDataCreator/types.js +7 -0
  15. package/tasks/MockDataCreator/types.js.map +1 -0
  16. package/tasks/MockDataManager/MockDataManager.d.ts +8 -0
  17. package/tasks/MockDataManager/MockDataManager.js +113 -0
  18. package/tasks/MockDataManager/MockDataManager.js.map +1 -0
  19. package/tasks/MockDataManager/calculateAmounts.d.ts +6 -0
  20. package/tasks/MockDataManager/calculateAmounts.js +63 -0
  21. package/tasks/MockDataManager/calculateAmounts.js.map +1 -0
  22. package/tasks/MockDataManager/calculateSeconds.d.ts +3 -0
  23. package/tasks/MockDataManager/calculateSeconds.js +23 -0
  24. package/tasks/MockDataManager/calculateSeconds.js.map +1 -0
  25. package/tasks/MockDataManager/constants.d.ts +1 -0
  26. package/tasks/MockDataManager/constants.js +9 -0
  27. package/tasks/MockDataManager/constants.js.map +1 -0
  28. package/tasks/MockDataManager/createModelAndGroup.d.ts +14 -0
  29. package/tasks/MockDataManager/createModelAndGroup.js +47 -0
  30. package/tasks/MockDataManager/createModelAndGroup.js.map +1 -0
  31. package/tasks/MockDataManager/group.d.ts +2 -0
  32. package/tasks/MockDataManager/group.js +18 -0
  33. package/tasks/MockDataManager/group.js.map +1 -0
  34. package/tasks/MockDataManager/model.d.ts +3 -0
  35. package/tasks/MockDataManager/model.js +4703 -0
  36. package/tasks/MockDataManager/model.js.map +1 -0
  37. package/tasks/MockDataManager/types.d.ts +10 -0
  38. package/tasks/MockDataManager/types.js +7 -0
  39. package/tasks/MockDataManager/types.js.map +1 -0
  40. package/tasks/createMockDataCreatorTask.d.ts +4 -0
  41. package/tasks/createMockDataCreatorTask.js +29 -0
  42. package/tasks/createMockDataCreatorTask.js.map +1 -0
  43. package/tasks/createMockDataManagerTask.d.ts +4 -0
  44. package/tasks/createMockDataManagerTask.js +61 -0
  45. package/tasks/createMockDataManagerTask.js.map +1 -0
  46. package/types.d.ts +6 -0
  47. package/types.js +18 -0
  48. package/types.js.map +1 -0
  49. package/utils/createIndex.d.ts +9 -0
  50. package/utils/createIndex.js +38 -0
  51. package/utils/createIndex.js.map +1 -0
  52. package/utils/disableIndexing.d.ts +7 -0
  53. package/utils/disableIndexing.js +35 -0
  54. package/utils/disableIndexing.js.map +1 -0
  55. package/utils/enableIndexing.d.ts +8 -0
  56. package/utils/enableIndexing.js +35 -0
  57. package/utils/enableIndexing.js.map +1 -0
  58. package/utils/index.d.ts +3 -0
  59. package/utils/index.js +40 -0
  60. package/utils/index.js.map +1 -0
@@ -0,0 +1,10 @@
1
+ import type { ITaskResponseDoneResultOutput } from "@webiny/tasks";
2
+ export interface IMockDataManagerInput {
3
+ modelId: string;
4
+ amount: number;
5
+ seconds?: number;
6
+ amountOfTasks?: number;
7
+ amountOfRecords?: number;
8
+ overwrite?: boolean;
9
+ }
10
+ export type IMockDataManagerOutput = ITaskResponseDoneResultOutput;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ITaskResponseDoneResultOutput } from \"@webiny/tasks\";\n\nexport interface IMockDataManagerInput {\n modelId: string;\n amount: number;\n seconds?: number;\n amountOfTasks?: number;\n amountOfRecords?: number;\n overwrite?: boolean;\n}\n\nexport type IMockDataManagerOutput = ITaskResponseDoneResultOutput;\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import type { Context } from "../types";
2
+ import type { IMockDataCreatorInput } from "./MockDataCreator/types";
3
+ export declare const MOCK_DATA_CREATOR_TASK_ID = "mockDataCreator";
4
+ export declare const createMockDataCreatorTask: () => import("@webiny/tasks").TaskDefinitionPlugin<Context, IMockDataCreatorInput, import("@webiny/tasks").ITaskResponseDoneResultOutput>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createMockDataCreatorTask = exports.MOCK_DATA_CREATOR_TASK_ID = void 0;
7
+ var _tasks = require("@webiny/tasks");
8
+ const MOCK_DATA_CREATOR_TASK_ID = exports.MOCK_DATA_CREATOR_TASK_ID = "mockDataCreator";
9
+ const createMockDataCreatorTask = () => {
10
+ return (0, _tasks.createTaskDefinition)({
11
+ id: MOCK_DATA_CREATOR_TASK_ID,
12
+ title: "Mock Data Creator",
13
+ maxIterations: 500,
14
+ async run(params) {
15
+ const {
16
+ MockDataCreator
17
+ } = await import(/* webpackChunkName: "MockDataCreator" */"./MockDataCreator/MockDataCreator");
18
+ const carsMock = new MockDataCreator();
19
+ try {
20
+ return await carsMock.execute(params);
21
+ } catch (ex) {
22
+ return params.response.error(ex);
23
+ }
24
+ }
25
+ });
26
+ };
27
+ exports.createMockDataCreatorTask = createMockDataCreatorTask;
28
+
29
+ //# sourceMappingURL=createMockDataCreatorTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_tasks","require","MOCK_DATA_CREATOR_TASK_ID","exports","createMockDataCreatorTask","createTaskDefinition","id","title","maxIterations","run","params","MockDataCreator","carsMock","execute","ex","response","error"],"sources":["createMockDataCreatorTask.ts"],"sourcesContent":["import { createTaskDefinition } from \"@webiny/tasks\";\nimport type { Context } from \"~/types\";\nimport type { IMockDataCreatorInput, IMockDataCreatorOutput } from \"~/tasks/MockDataCreator/types\";\n\nexport const MOCK_DATA_CREATOR_TASK_ID = \"mockDataCreator\";\n\nexport const createMockDataCreatorTask = () => {\n return createTaskDefinition<Context, IMockDataCreatorInput, IMockDataCreatorOutput>({\n id: MOCK_DATA_CREATOR_TASK_ID,\n title: \"Mock Data Creator\",\n maxIterations: 500,\n async run(params) {\n const { MockDataCreator } = await import(\n /* webpackChunkName: \"MockDataCreator\" */ \"./MockDataCreator/MockDataCreator\"\n );\n\n const carsMock = new MockDataCreator<\n Context,\n IMockDataCreatorInput,\n IMockDataCreatorOutput\n >();\n\n try {\n return await carsMock.execute(params);\n } catch (ex) {\n return params.response.error(ex);\n }\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAIO,MAAMC,yBAAyB,GAAAC,OAAA,CAAAD,yBAAA,GAAG,iBAAiB;AAEnD,MAAME,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,OAAO,IAAAC,2BAAoB,EAAyD;IAChFC,EAAE,EAAEJ,yBAAyB;IAC7BK,KAAK,EAAE,mBAAmB;IAC1BC,aAAa,EAAE,GAAG;IAClB,MAAMC,GAAGA,CAACC,MAAM,EAAE;MACd,MAAM;QAAEC;MAAgB,CAAC,GAAG,MAAM,MAAM,CACpC,4EACJ,CAAC;MAED,MAAMC,QAAQ,GAAG,IAAID,eAAe,CAIlC,CAAC;MAEH,IAAI;QACA,OAAO,MAAMC,QAAQ,CAACC,OAAO,CAACH,MAAM,CAAC;MACzC,CAAC,CAAC,OAAOI,EAAE,EAAE;QACT,OAAOJ,MAAM,CAACK,QAAQ,CAACC,KAAK,CAACF,EAAE,CAAC;MACpC;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAACX,OAAA,CAAAC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import type { Context } from "../types";
2
+ import type { IMockDataManagerInput } from "./MockDataManager/types";
3
+ export declare const MOCK_DATA_MANAGER_TASK_ID = "mockDataManager";
4
+ export declare const createMockDataManagerTask: () => import("@webiny/tasks").TaskDefinitionPlugin<Context, IMockDataManagerInput, import("@webiny/tasks").ITaskResponseDoneResultOutput>;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createMockDataManagerTask = exports.MOCK_DATA_MANAGER_TASK_ID = void 0;
7
+ var _tasks = require("@webiny/tasks");
8
+ var _constants = require("./MockDataManager/constants");
9
+ var _utils = require("../utils");
10
+ const MOCK_DATA_MANAGER_TASK_ID = exports.MOCK_DATA_MANAGER_TASK_ID = "mockDataManager";
11
+ const createMockDataManagerTask = () => {
12
+ return (0, _tasks.createTaskDefinition)({
13
+ id: MOCK_DATA_MANAGER_TASK_ID,
14
+ title: "Mock Data Manager",
15
+ maxIterations: 500,
16
+ async run(params) {
17
+ const {
18
+ MockDataManager
19
+ } = await import(/* webpackChunkName: "MockDataManager" */"./MockDataManager/MockDataManager");
20
+ const carsMock = new MockDataManager();
21
+ try {
22
+ return await carsMock.execute({
23
+ ...params,
24
+ input: {
25
+ ...params.input,
26
+ modelId: _constants.CARS_MODEL_ID
27
+ }
28
+ });
29
+ } catch (ex) {
30
+ return params.response.error(ex);
31
+ }
32
+ },
33
+ async onError({
34
+ context
35
+ }) {
36
+ await (0, _utils.enableIndexing)({
37
+ client: context.elasticsearch,
38
+ model: {
39
+ modelId: _constants.CARS_MODEL_ID,
40
+ tenant: "root",
41
+ locale: "en-US"
42
+ }
43
+ });
44
+ },
45
+ async onAbort({
46
+ context
47
+ }) {
48
+ await (0, _utils.enableIndexing)({
49
+ client: context.elasticsearch,
50
+ model: {
51
+ modelId: _constants.CARS_MODEL_ID,
52
+ tenant: "root",
53
+ locale: "en-US"
54
+ }
55
+ });
56
+ }
57
+ });
58
+ };
59
+ exports.createMockDataManagerTask = createMockDataManagerTask;
60
+
61
+ //# sourceMappingURL=createMockDataManagerTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_tasks","require","_constants","_utils","MOCK_DATA_MANAGER_TASK_ID","exports","createMockDataManagerTask","createTaskDefinition","id","title","maxIterations","run","params","MockDataManager","carsMock","execute","input","modelId","CARS_MODEL_ID","ex","response","error","onError","context","enableIndexing","client","elasticsearch","model","tenant","locale","onAbort"],"sources":["createMockDataManagerTask.ts"],"sourcesContent":["import { createTaskDefinition } from \"@webiny/tasks\";\nimport type { Context } from \"~/types\";\nimport type { IMockDataManagerInput, IMockDataManagerOutput } from \"~/tasks/MockDataManager/types\";\nimport { CARS_MODEL_ID } from \"~/tasks/MockDataManager/constants\";\nimport { enableIndexing } from \"~/utils\";\n\nexport const MOCK_DATA_MANAGER_TASK_ID = \"mockDataManager\";\n\nexport const createMockDataManagerTask = () => {\n return createTaskDefinition<Context, IMockDataManagerInput, IMockDataManagerOutput>({\n id: MOCK_DATA_MANAGER_TASK_ID,\n title: \"Mock Data Manager\",\n maxIterations: 500,\n async run(params) {\n const { MockDataManager } = await import(\n /* webpackChunkName: \"MockDataManager\" */ \"./MockDataManager/MockDataManager\"\n );\n\n const carsMock = new MockDataManager<\n Context,\n IMockDataManagerInput,\n IMockDataManagerOutput\n >();\n\n try {\n return await carsMock.execute({\n ...params,\n input: {\n ...params.input,\n modelId: CARS_MODEL_ID\n }\n });\n } catch (ex) {\n return params.response.error(ex);\n }\n },\n async onError({ context }) {\n await enableIndexing({\n client: context.elasticsearch,\n model: {\n modelId: CARS_MODEL_ID,\n tenant: \"root\",\n locale: \"en-US\"\n }\n });\n },\n async onAbort({ context }) {\n await enableIndexing({\n client: context.elasticsearch,\n model: {\n modelId: CARS_MODEL_ID,\n tenant: \"root\",\n locale: \"en-US\"\n }\n });\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEO,MAAMG,yBAAyB,GAAAC,OAAA,CAAAD,yBAAA,GAAG,iBAAiB;AAEnD,MAAME,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,OAAO,IAAAC,2BAAoB,EAAyD;IAChFC,EAAE,EAAEJ,yBAAyB;IAC7BK,KAAK,EAAE,mBAAmB;IAC1BC,aAAa,EAAE,GAAG;IAClB,MAAMC,GAAGA,CAACC,MAAM,EAAE;MACd,MAAM;QAAEC;MAAgB,CAAC,GAAG,MAAM,MAAM,CACpC,4EACJ,CAAC;MAED,MAAMC,QAAQ,GAAG,IAAID,eAAe,CAIlC,CAAC;MAEH,IAAI;QACA,OAAO,MAAMC,QAAQ,CAACC,OAAO,CAAC;UAC1B,GAAGH,MAAM;UACTI,KAAK,EAAE;YACH,GAAGJ,MAAM,CAACI,KAAK;YACfC,OAAO,EAAEC;UACb;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,OAAOC,EAAE,EAAE;QACT,OAAOP,MAAM,CAACQ,QAAQ,CAACC,KAAK,CAACF,EAAE,CAAC;MACpC;IACJ,CAAC;IACD,MAAMG,OAAOA,CAAC;MAAEC;IAAQ,CAAC,EAAE;MACvB,MAAM,IAAAC,qBAAc,EAAC;QACjBC,MAAM,EAAEF,OAAO,CAACG,aAAa;QAC7BC,KAAK,EAAE;UACHV,OAAO,EAAEC,wBAAa;UACtBU,MAAM,EAAE,MAAM;UACdC,MAAM,EAAE;QACZ;MACJ,CAAC,CAAC;IACN,CAAC;IACD,MAAMC,OAAOA,CAAC;MAAEP;IAAQ,CAAC,EAAE;MACvB,MAAM,IAAAC,qBAAc,EAAC;QACjBC,MAAM,EAAEF,OAAO,CAACG,aAAa;QAC7BC,KAAK,EAAE;UACHV,OAAO,EAAEC,wBAAa;UACtBU,MAAM,EAAE,MAAM;UACdC,MAAM,EAAE;QACZ;MACJ,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACxB,OAAA,CAAAC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
package/types.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import type { ElasticsearchContext } from "@webiny/api-elasticsearch/types";
2
+ import type { CmsContext } from "@webiny/api-headless-cms/types";
3
+ import type { Context as TasksContext } from "@webiny/tasks/types";
4
+ export * from "./tasks/MockDataManager/types";
5
+ export interface Context extends CmsContext, ElasticsearchContext, TasksContext {
6
+ }
package/types.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _types = require("./tasks/MockDataManager/types");
7
+ Object.keys(_types).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _types[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _types[key];
14
+ }
15
+ });
16
+ });
17
+
18
+ //# sourceMappingURL=types.js.map
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_types","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["types.ts"],"sourcesContent":["import type { ElasticsearchContext } from \"@webiny/api-elasticsearch/types\";\nimport type { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport type { Context as TasksContext } from \"@webiny/tasks/types\";\n\nexport * from \"./tasks/MockDataManager/types\";\n\nexport interface Context extends CmsContext, ElasticsearchContext, TasksContext {}\n"],"mappings":";;;;;AAIA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ import type { Client } from "@webiny/api-elasticsearch";
2
+ import type { CmsModel } from "@webiny/api-headless-cms/types";
3
+ import type { PluginsContainer } from "@webiny/plugins";
4
+ export interface ICreateIndexParams {
5
+ client: Client;
6
+ model: Pick<CmsModel, "modelId" | "tenant" | "locale">;
7
+ plugins: PluginsContainer;
8
+ }
9
+ export declare const createIndex: (params: ICreateIndexParams) => Promise<void>;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createIndex = void 0;
7
+ var _apiElasticsearch = require("@webiny/api-elasticsearch");
8
+ var _configurations = require("@webiny/api-headless-cms-ddb-es/configurations");
9
+ var _plugins = require("@webiny/api-headless-cms-ddb-es/plugins");
10
+ const createIndex = async params => {
11
+ const {
12
+ client,
13
+ model,
14
+ plugins
15
+ } = params;
16
+ const {
17
+ index
18
+ } = _configurations.configurations.es({
19
+ model
20
+ });
21
+ const result = await client.indices.exists({
22
+ index
23
+ });
24
+ if (result.body) {
25
+ return;
26
+ }
27
+ await (0, _apiElasticsearch.createIndex)({
28
+ index,
29
+ client,
30
+ locale: model.locale,
31
+ tenant: model.tenant,
32
+ plugins,
33
+ type: _plugins.CmsEntryElasticsearchIndexPlugin.type
34
+ });
35
+ };
36
+ exports.createIndex = createIndex;
37
+
38
+ //# sourceMappingURL=createIndex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_apiElasticsearch","require","_configurations","_plugins","createIndex","params","client","model","plugins","index","configurations","es","result","indices","exists","body","baseCreateIndex","locale","tenant","type","CmsEntryElasticsearchIndexPlugin","exports"],"sources":["createIndex.ts"],"sourcesContent":["import type { Client } from \"@webiny/api-elasticsearch\";\nimport { createIndex as baseCreateIndex } from \"@webiny/api-elasticsearch\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { configurations } from \"@webiny/api-headless-cms-ddb-es/configurations\";\nimport { CmsEntryElasticsearchIndexPlugin } from \"@webiny/api-headless-cms-ddb-es/plugins\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\n\nexport interface ICreateIndexParams {\n client: Client;\n model: Pick<CmsModel, \"modelId\" | \"tenant\" | \"locale\">;\n plugins: PluginsContainer;\n}\n\nexport const createIndex = async (params: ICreateIndexParams): Promise<void> => {\n const { client, model, plugins } = params;\n\n const { index } = configurations.es({\n model\n });\n\n const result = await client.indices.exists({\n index\n });\n if (result.body) {\n return;\n }\n\n await baseCreateIndex({\n index,\n client,\n locale: model.locale,\n tenant: model.tenant,\n plugins,\n type: CmsEntryElasticsearchIndexPlugin.type\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AASO,MAAMG,WAAW,GAAG,MAAOC,MAA0B,IAAoB;EAC5E,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAEzC,MAAM;IAAEI;EAAM,CAAC,GAAGC,8BAAc,CAACC,EAAE,CAAC;IAChCJ;EACJ,CAAC,CAAC;EAEF,MAAMK,MAAM,GAAG,MAAMN,MAAM,CAACO,OAAO,CAACC,MAAM,CAAC;IACvCL;EACJ,CAAC,CAAC;EACF,IAAIG,MAAM,CAACG,IAAI,EAAE;IACb;EACJ;EAEA,MAAM,IAAAC,6BAAe,EAAC;IAClBP,KAAK;IACLH,MAAM;IACNW,MAAM,EAAEV,KAAK,CAACU,MAAM;IACpBC,MAAM,EAAEX,KAAK,CAACW,MAAM;IACpBV,OAAO;IACPW,IAAI,EAAEC,yCAAgC,CAACD;EAC3C,CAAC,CAAC;AACN,CAAC;AAACE,OAAA,CAAAjB,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ import type { Client } from "@webiny/api-elasticsearch";
2
+ import type { CmsModel } from "@webiny/api-headless-cms/types";
3
+ export interface IDisableIndexingParams {
4
+ client: Client;
5
+ model: Pick<CmsModel, "modelId" | "tenant" | "locale">;
6
+ }
7
+ export declare const disableIndexing: (params: IDisableIndexingParams) => Promise<void>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.disableIndexing = void 0;
7
+ var _configurations = require("@webiny/api-headless-cms-ddb-es/configurations");
8
+ const disableIndexing = async params => {
9
+ const {
10
+ client,
11
+ model
12
+ } = params;
13
+ const {
14
+ index
15
+ } = _configurations.configurations.es({
16
+ model
17
+ });
18
+ try {
19
+ await client.indices.putSettings({
20
+ index,
21
+ body: {
22
+ index: {
23
+ number_of_replicas: 0,
24
+ refresh_interval: "-1"
25
+ }
26
+ }
27
+ });
28
+ } catch (ex) {
29
+ console.error(ex);
30
+ throw ex;
31
+ }
32
+ };
33
+ exports.disableIndexing = disableIndexing;
34
+
35
+ //# sourceMappingURL=disableIndexing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_configurations","require","disableIndexing","params","client","model","index","configurations","es","indices","putSettings","body","number_of_replicas","refresh_interval","ex","console","error","exports"],"sources":["disableIndexing.ts"],"sourcesContent":["import type { Client } from \"@webiny/api-elasticsearch\";\nimport { configurations } from \"@webiny/api-headless-cms-ddb-es/configurations\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\n\nexport interface IDisableIndexingParams {\n client: Client;\n model: Pick<CmsModel, \"modelId\" | \"tenant\" | \"locale\">;\n}\n\nexport const disableIndexing = async (params: IDisableIndexingParams) => {\n const { client, model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n try {\n await client.indices.putSettings({\n index,\n body: {\n index: {\n number_of_replicas: 0,\n refresh_interval: \"-1\"\n }\n }\n });\n } catch (ex) {\n console.error(ex);\n throw ex;\n }\n};\n"],"mappings":";;;;;;AACA,IAAAA,eAAA,GAAAC,OAAA;AAQO,MAAMC,eAAe,GAAG,MAAOC,MAA8B,IAAK;EACrE,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAEhC,MAAM;IAAEG;EAAM,CAAC,GAAGC,8BAAc,CAACC,EAAE,CAAC;IAChCH;EACJ,CAAC,CAAC;EAEF,IAAI;IACA,MAAMD,MAAM,CAACK,OAAO,CAACC,WAAW,CAAC;MAC7BJ,KAAK;MACLK,IAAI,EAAE;QACFL,KAAK,EAAE;UACHM,kBAAkB,EAAE,CAAC;UACrBC,gBAAgB,EAAE;QACtB;MACJ;IACJ,CAAC,CAAC;EACN,CAAC,CAAC,OAAOC,EAAE,EAAE;IACTC,OAAO,CAACC,KAAK,CAACF,EAAE,CAAC;IACjB,MAAMA,EAAE;EACZ;AACJ,CAAC;AAACG,OAAA,CAAAf,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import type { Client } from "@webiny/api-elasticsearch";
2
+ import type { CmsModel } from "@webiny/api-headless-cms/types";
3
+ interface IEnableIndexingParams {
4
+ client: Client;
5
+ model: Pick<CmsModel, "modelId" | "tenant" | "locale">;
6
+ }
7
+ export declare const enableIndexing: (params: IEnableIndexingParams) => Promise<void>;
8
+ export {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.enableIndexing = void 0;
7
+ var _configurations = require("@webiny/api-headless-cms-ddb-es/configurations");
8
+ const enableIndexing = async params => {
9
+ const {
10
+ client,
11
+ model
12
+ } = params;
13
+ const {
14
+ index
15
+ } = _configurations.configurations.es({
16
+ model
17
+ });
18
+ try {
19
+ await client.indices.putSettings({
20
+ index,
21
+ body: {
22
+ index: {
23
+ number_of_replicas: 1,
24
+ refresh_interval: "1s"
25
+ }
26
+ }
27
+ });
28
+ } catch (ex) {
29
+ console.error(ex);
30
+ throw ex;
31
+ }
32
+ };
33
+ exports.enableIndexing = enableIndexing;
34
+
35
+ //# sourceMappingURL=enableIndexing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_configurations","require","enableIndexing","params","client","model","index","configurations","es","indices","putSettings","body","number_of_replicas","refresh_interval","ex","console","error","exports"],"sources":["enableIndexing.ts"],"sourcesContent":["import type { Client } from \"@webiny/api-elasticsearch\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { configurations } from \"@webiny/api-headless-cms-ddb-es/configurations\";\n\ninterface IEnableIndexingParams {\n client: Client;\n model: Pick<CmsModel, \"modelId\" | \"tenant\" | \"locale\">;\n}\n\nexport const enableIndexing = async (params: IEnableIndexingParams) => {\n const { client, model } = params;\n const { index } = configurations.es({\n model\n });\n try {\n await client.indices.putSettings({\n index,\n body: {\n index: {\n number_of_replicas: 1,\n refresh_interval: \"1s\"\n }\n }\n });\n } catch (ex) {\n console.error(ex);\n throw ex;\n }\n};\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AAOO,MAAMC,cAAc,GAAG,MAAOC,MAA6B,IAAK;EACnE,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAChC,MAAM;IAAEG;EAAM,CAAC,GAAGC,8BAAc,CAACC,EAAE,CAAC;IAChCH;EACJ,CAAC,CAAC;EACF,IAAI;IACA,MAAMD,MAAM,CAACK,OAAO,CAACC,WAAW,CAAC;MAC7BJ,KAAK;MACLK,IAAI,EAAE;QACFL,KAAK,EAAE;UACHM,kBAAkB,EAAE,CAAC;UACrBC,gBAAgB,EAAE;QACtB;MACJ;IACJ,CAAC,CAAC;EACN,CAAC,CAAC,OAAOC,EAAE,EAAE;IACTC,OAAO,CAACC,KAAK,CAACF,EAAE,CAAC;IACjB,MAAMA,EAAE;EACZ;AACJ,CAAC;AAACG,OAAA,CAAAf,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export * from "./createIndex";
2
+ export * from "./disableIndexing";
3
+ export * from "./enableIndexing";
package/utils/index.js ADDED
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _createIndex = require("./createIndex");
7
+ Object.keys(_createIndex).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _createIndex[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _createIndex[key];
14
+ }
15
+ });
16
+ });
17
+ var _disableIndexing = require("./disableIndexing");
18
+ Object.keys(_disableIndexing).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _disableIndexing[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _disableIndexing[key];
25
+ }
26
+ });
27
+ });
28
+ var _enableIndexing = require("./enableIndexing");
29
+ Object.keys(_enableIndexing).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _enableIndexing[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _enableIndexing[key];
36
+ }
37
+ });
38
+ });
39
+
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_createIndex","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_disableIndexing","_enableIndexing"],"sources":["index.ts"],"sourcesContent":["export * from \"./createIndex\";\nexport * from \"./disableIndexing\";\nexport * from \"./enableIndexing\";\n"],"mappings":";;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,YAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,YAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,YAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,gBAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,gBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,gBAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,gBAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,eAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,eAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,eAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,eAAA,CAAAN,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}