@webiny/api-headless-cms-ddb-es 0.0.0-mt-3 → 0.0.0-unstable.5e7233243f

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 (152) hide show
  1. package/configurations.d.ts +2 -2
  2. package/configurations.js +18 -7
  3. package/configurations.js.map +1 -0
  4. package/definitions/entry.d.ts +2 -2
  5. package/definitions/entry.js +5 -2
  6. package/definitions/entry.js.map +1 -0
  7. package/definitions/entryElasticsearch.d.ts +2 -2
  8. package/definitions/entryElasticsearch.js +2 -2
  9. package/definitions/entryElasticsearch.js.map +1 -0
  10. package/definitions/group.d.ts +2 -2
  11. package/definitions/group.js +2 -2
  12. package/definitions/group.js.map +1 -0
  13. package/definitions/model.d.ts +2 -2
  14. package/definitions/model.js +2 -2
  15. package/definitions/model.js.map +1 -0
  16. package/definitions/settings.d.ts +2 -2
  17. package/definitions/settings.js +2 -2
  18. package/definitions/settings.js.map +1 -0
  19. package/definitions/system.d.ts +2 -2
  20. package/definitions/system.js +2 -2
  21. package/definitions/system.js.map +1 -0
  22. package/definitions/table.d.ts +2 -2
  23. package/definitions/table.js.map +1 -0
  24. package/definitions/tableElasticsearch.d.ts +2 -2
  25. package/definitions/tableElasticsearch.js.map +1 -0
  26. package/dynamoDb/index.d.ts +1 -1
  27. package/dynamoDb/index.js +4 -6
  28. package/dynamoDb/index.js.map +1 -0
  29. package/dynamoDb/storage/date.d.ts +2 -3
  30. package/dynamoDb/storage/date.js +79 -45
  31. package/dynamoDb/storage/date.js.map +1 -0
  32. package/dynamoDb/storage/longText.d.ts +7 -4
  33. package/dynamoDb/storage/longText.js +71 -53
  34. package/dynamoDb/storage/longText.js.map +1 -0
  35. package/dynamoDb/storage/richText.d.ts +2 -3
  36. package/dynamoDb/storage/richText.js +84 -66
  37. package/dynamoDb/storage/richText.js.map +1 -0
  38. package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
  39. package/elasticsearch/createElasticsearchIndex.js +60 -0
  40. package/elasticsearch/createElasticsearchIndex.js.map +1 -0
  41. package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
  42. package/elasticsearch/deleteElasticsearchIndex.js +43 -0
  43. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
  44. package/elasticsearch/index.d.ts +1 -1
  45. package/elasticsearch/index.js.map +1 -0
  46. package/elasticsearch/indexing/dateTimeIndexing.js +15 -1
  47. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
  48. package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
  49. package/elasticsearch/indexing/index.js.map +1 -0
  50. package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
  51. package/elasticsearch/indexing/numberIndexing.js.map +1 -0
  52. package/elasticsearch/indexing/objectIndexing.d.ts +9 -0
  53. package/elasticsearch/indexing/objectIndexing.js +32 -9
  54. package/elasticsearch/indexing/objectIndexing.js.map +1 -0
  55. package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
  56. package/elasticsearch/indices/base.d.ts +2 -0
  57. package/elasticsearch/indices/base.js +23 -0
  58. package/elasticsearch/indices/base.js.map +1 -0
  59. package/elasticsearch/indices/index.d.ts +1 -0
  60. package/elasticsearch/indices/index.js +16 -0
  61. package/elasticsearch/indices/index.js.map +1 -0
  62. package/elasticsearch/indices/japanese.d.ts +2 -0
  63. package/elasticsearch/indices/japanese.js +24 -0
  64. package/elasticsearch/indices/japanese.js.map +1 -0
  65. package/elasticsearch/search/index.d.ts +2 -2
  66. package/elasticsearch/search/index.js +3 -5
  67. package/elasticsearch/search/index.js.map +1 -0
  68. package/elasticsearch/search/refSearch.d.ts +2 -3
  69. package/elasticsearch/search/refSearch.js +25 -16
  70. package/elasticsearch/search/refSearch.js.map +1 -0
  71. package/elasticsearch/search/timeSearch.d.ts +2 -3
  72. package/elasticsearch/search/timeSearch.js +22 -14
  73. package/elasticsearch/search/timeSearch.js.map +1 -0
  74. package/helpers/createElasticsearchQueryBody.js +312 -67
  75. package/helpers/createElasticsearchQueryBody.js.map +1 -0
  76. package/helpers/entryIndexHelpers.js +32 -12
  77. package/helpers/entryIndexHelpers.js.map +1 -0
  78. package/helpers/fields.d.ts +4 -62
  79. package/helpers/fields.js +27 -5
  80. package/helpers/fields.js.map +1 -0
  81. package/helpers/index.js.map +1 -0
  82. package/helpers/searchPluginsList.d.ts +2 -2
  83. package/helpers/searchPluginsList.js.map +1 -0
  84. package/helpers/transformValueForSearch.d.ts +5 -2
  85. package/helpers/transformValueForSearch.js +3 -0
  86. package/helpers/transformValueForSearch.js.map +1 -0
  87. package/index.js +61 -23
  88. package/index.js.map +1 -0
  89. package/operations/entry/dataLoaders.d.ts +6 -2
  90. package/operations/entry/dataLoaders.js +26 -6
  91. package/operations/entry/dataLoaders.js.map +1 -0
  92. package/operations/entry/elasticsearchFields.js +3 -0
  93. package/operations/entry/elasticsearchFields.js.map +1 -0
  94. package/operations/entry/index.d.ts +2 -2
  95. package/operations/entry/index.js +475 -162
  96. package/operations/entry/index.js.map +1 -0
  97. package/operations/entry/keys.js.map +1 -0
  98. package/operations/group/index.d.ts +2 -2
  99. package/operations/group/index.js +3 -5
  100. package/operations/group/index.js.map +1 -0
  101. package/operations/model/index.d.ts +2 -2
  102. package/operations/model/index.js +38 -35
  103. package/operations/model/index.js.map +1 -0
  104. package/operations/settings/index.d.ts +2 -2
  105. package/operations/settings/index.js +3 -5
  106. package/operations/settings/index.js.map +1 -0
  107. package/operations/system/index.d.ts +2 -2
  108. package/operations/system/index.js +3 -5
  109. package/operations/system/index.js.map +1 -0
  110. package/package.json +25 -29
  111. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +2 -2
  112. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
  113. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +3 -3
  114. package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -0
  115. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
  116. package/plugins/CmsEntryElasticsearchIndexPlugin.js +17 -0
  117. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
  118. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +30 -0
  119. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +43 -0
  120. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
  121. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +2 -2
  122. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
  123. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +2 -2
  124. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
  125. package/types.d.ts +2 -32
  126. package/types.js +0 -13
  127. package/types.js.map +1 -0
  128. package/upgrades/index.d.ts +1 -1
  129. package/upgrades/index.js +1 -7
  130. package/upgrades/index.js.map +1 -0
  131. package/helpers/operatorPluginsList.d.ts +0 -7
  132. package/helpers/operatorPluginsList.js +0 -30
  133. package/operations/entry/fields.d.ts +0 -3
  134. package/operations/entry/fields.js +0 -60
  135. package/operations/system/createElasticsearchTemplate.d.ts +0 -5
  136. package/operations/system/createElasticsearchTemplate.js +0 -62
  137. package/upgrades/utils.d.ts +0 -1
  138. package/upgrades/utils.js +0 -16
  139. package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +0 -6
  140. package/upgrades/v5.0.0/cleanDatabaseRecord.js +0 -16
  141. package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +0 -2
  142. package/upgrades/v5.0.0/createOldVersionIndiceName.js +0 -12
  143. package/upgrades/v5.0.0/entryValueFixer.d.ts +0 -4
  144. package/upgrades/v5.0.0/entryValueFixer.js +0 -124
  145. package/upgrades/v5.0.0/fieldFinder.d.ts +0 -6
  146. package/upgrades/v5.0.0/fieldFinder.js +0 -42
  147. package/upgrades/v5.0.0/helpers.d.ts +0 -4
  148. package/upgrades/v5.0.0/helpers.js +0 -57
  149. package/upgrades/v5.0.0/index.d.ts +0 -4
  150. package/upgrades/v5.0.0/index.js +0 -232
  151. package/upgrades/v5.8.0/index.d.ts +0 -4
  152. package/upgrades/v5.8.0/index.js +0 -426
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-ddb-es",
3
- "version": "0.0.0-mt-3",
3
+ "version": "0.0.0-unstable.5e7233243f",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "@webiny/api-headless-cms",
@@ -22,44 +22,40 @@
22
22
  ],
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@babel/runtime": "7.15.4",
26
- "@webiny/api-headless-cms": "0.0.0-mt-3",
27
- "@webiny/api-upgrade": "0.0.0-mt-3",
28
- "@webiny/db-dynamodb": "0.0.0-mt-3",
29
- "@webiny/error": "0.0.0-mt-3",
30
- "@webiny/handler": "0.0.0-mt-3",
31
- "@webiny/handler-aws": "0.0.0-mt-3",
32
- "@webiny/handler-db": "0.0.0-mt-3",
33
- "@webiny/plugins": "0.0.0-mt-3",
34
- "@webiny/utils": "0.0.0-mt-3",
35
- "dataloader": "2.0.0",
36
- "dynamodb-toolbox": "0.3.4",
25
+ "@babel/runtime": "7.18.9",
26
+ "@webiny/api": "0.0.0-unstable.5e7233243f",
27
+ "@webiny/api-elasticsearch": "0.0.0-unstable.5e7233243f",
28
+ "@webiny/api-headless-cms": "0.0.0-unstable.5e7233243f",
29
+ "@webiny/db-dynamodb": "0.0.0-unstable.5e7233243f",
30
+ "@webiny/error": "0.0.0-unstable.5e7233243f",
31
+ "@webiny/handler-db": "0.0.0-unstable.5e7233243f",
32
+ "@webiny/plugins": "0.0.0-unstable.5e7233243f",
33
+ "@webiny/utils": "0.0.0-unstable.5e7233243f",
34
+ "dataloader": "2.1.0",
35
+ "dynamodb-toolbox": "0.3.5",
37
36
  "jsonpack": "1.1.5",
38
- "lodash.chunk": "4.2.0",
39
- "lodash.clonedeep": "4.5.0",
40
- "lodash.omit": "4.5.0"
37
+ "lodash": "4.17.21"
41
38
  },
42
39
  "devDependencies": {
43
- "@babel/cli": "^7.5.5",
44
- "@babel/core": "^7.5.5",
45
- "@babel/preset-env": "^7.5.5",
46
- "@babel/preset-flow": "^7.0.0",
40
+ "@babel/cli": "^7.16.0",
41
+ "@babel/core": "^7.16.0",
42
+ "@babel/preset-env": "^7.16.4",
43
+ "@babel/preset-flow": "^7.16.0",
47
44
  "@elastic/elasticsearch": "7.12.0",
48
- "@shelf/jest-elasticsearch": "^1.0.0",
49
45
  "@types/jsonpack": "^1.1.0",
50
- "@webiny/api-dynamodb-to-elasticsearch": "^0.0.0-mt-3",
51
- "@webiny/api-elasticsearch": "^0.0.0-mt-3",
52
- "@webiny/cli": "^0.0.0-mt-3",
53
- "@webiny/project-utils": "^0.0.0-mt-3",
54
- "jest": "^26.6.3",
46
+ "@webiny/api-dynamodb-to-elasticsearch": "^0.0.0-unstable.5e7233243f",
47
+ "@webiny/cli": "^0.0.0-unstable.5e7233243f",
48
+ "@webiny/handler-aws": "^0.0.0-unstable.5e7233243f",
49
+ "@webiny/project-utils": "^0.0.0-unstable.5e7233243f",
50
+ "jest": "^28.1.0",
55
51
  "jest-dynalite": "^3.2.0",
56
- "jest-environment-node": "^26.6.2",
52
+ "jest-environment-node": "^27.2.4",
57
53
  "mdbid": "^1.0.0",
58
54
  "prettier": "^2.3.2",
59
55
  "rimraf": "^3.0.2",
60
56
  "sinon": "^9.0.2",
61
57
  "ttypescript": "^1.5.12",
62
- "typescript": "^4.1.3"
58
+ "typescript": "4.7.4"
63
59
  },
64
60
  "publishConfig": {
65
61
  "access": "public",
@@ -69,5 +65,5 @@
69
65
  "build": "yarn webiny run build",
70
66
  "watch": "yarn webiny run watch"
71
67
  },
72
- "gitHead": "ebea815be2be99404591cba465cc1fe88355bd48"
68
+ "gitHead": "995a4b337db9b8497c6615e335dcd206afe26f8f"
73
69
  }
@@ -3,7 +3,7 @@ import { CmsModel } from "@webiny/api-headless-cms/types";
3
3
  export interface ModifyBodyParams extends BaseModifyBodyParams {
4
4
  model: CmsModel;
5
5
  }
6
- export interface Config {
6
+ export interface CmsEntryElasticsearchBodyModifierPluginConfig {
7
7
  modifyBody: ModifyBodyCallable<ModifyBodyParams>;
8
8
  /**
9
9
  * If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.
@@ -13,5 +13,5 @@ export interface Config {
13
13
  export declare class CmsEntryElasticsearchBodyModifierPlugin extends ElasticsearchBodyModifierPlugin<ModifyBodyParams> {
14
14
  static readonly type: string;
15
15
  readonly modelId?: string;
16
- constructor(config: Config);
16
+ constructor(config: CmsEntryElasticsearchBodyModifierPluginConfig);
17
17
  }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CmsEntryElasticsearchBodyModifierPlugin","ElasticsearchBodyModifierPlugin","constructor","config","modifyBody","modelId"],"sources":["CmsEntryElasticsearchBodyModifierPlugin.ts"],"sourcesContent":["import {\n ElasticsearchBodyModifierPlugin,\n ModifyBodyCallable,\n ModifyBodyParams as BaseModifyBodyParams\n} from \"@webiny/api-elasticsearch/plugins/definition/ElasticsearchBodyModifierPlugin\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\nexport interface ModifyBodyParams extends BaseModifyBodyParams {\n model: CmsModel;\n}\n\nexport interface CmsEntryElasticsearchBodyModifierPluginConfig {\n modifyBody: ModifyBodyCallable<ModifyBodyParams>;\n /**\n * If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.\n */\n modelId?: string;\n}\n\nexport class CmsEntryElasticsearchBodyModifierPlugin extends ElasticsearchBodyModifierPlugin<ModifyBodyParams> {\n public static override readonly type: string = \"cms.elasticsearch.modifier.body.entry\";\n\n public readonly modelId?: string;\n\n public constructor(config: CmsEntryElasticsearchBodyModifierPluginConfig) {\n super(config.modifyBody);\n\n this.modelId = config.modelId;\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAmBO,MAAMA,uCAAN,SAAsDC,gEAAtD,CAAwG;EAKpGC,WAAW,CAACC,MAAD,EAAwD;IACtE,MAAMA,MAAM,CAACC,UAAb;IADsE;IAGtE,KAAKC,OAAL,GAAeF,MAAM,CAACE,OAAtB;EACH;;AAT0G;;;8BAAlGL,uC,UACsC,uC"}
@@ -1,5 +1,5 @@
1
- import { ElasticsearchFieldPlugin, Params as BaseParams } from "@webiny/api-elasticsearch/plugins/definition/ElasticsearchFieldPlugin";
2
- export interface Params extends BaseParams {
1
+ import { ElasticsearchFieldPlugin, ElasticsearchFieldPluginParams as ElasticsearchFieldPluginParamsBaseParams } from "@webiny/api-elasticsearch/plugins/definition/ElasticsearchFieldPlugin";
2
+ export interface CmsEntryElasticsearchFieldPluginParams extends ElasticsearchFieldPluginParamsBaseParams {
3
3
  /**
4
4
  * If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.
5
5
  */
@@ -8,5 +8,5 @@ export interface Params extends BaseParams {
8
8
  export declare class CmsEntryElasticsearchFieldPlugin extends ElasticsearchFieldPlugin {
9
9
  static readonly type: string;
10
10
  readonly modelId?: string;
11
- constructor(params: Params);
11
+ constructor(params: CmsEntryElasticsearchFieldPluginParams);
12
12
  }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CmsEntryElasticsearchFieldPlugin","ElasticsearchFieldPlugin","constructor","params","modelId"],"sources":["CmsEntryElasticsearchFieldPlugin.ts"],"sourcesContent":["import {\n ElasticsearchFieldPlugin,\n ElasticsearchFieldPluginParams as ElasticsearchFieldPluginParamsBaseParams\n} from \"@webiny/api-elasticsearch/plugins/definition/ElasticsearchFieldPlugin\";\n\nexport interface CmsEntryElasticsearchFieldPluginParams\n extends ElasticsearchFieldPluginParamsBaseParams {\n /**\n * If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.\n */\n modelId?: string;\n}\nexport class CmsEntryElasticsearchFieldPlugin extends ElasticsearchFieldPlugin {\n public static override readonly type: string = \"elasticsearch.fieldDefinition.cms.entry\";\n\n public readonly modelId?: string;\n\n public constructor(params: CmsEntryElasticsearchFieldPluginParams) {\n super(params);\n\n this.modelId = params.modelId;\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAYO,MAAMA,gCAAN,SAA+CC,kDAA/C,CAAwE;EAKpEC,WAAW,CAACC,MAAD,EAAiD;IAC/D,MAAMA,MAAN;IAD+D;IAG/D,KAAKC,OAAL,GAAeD,MAAM,CAACC,OAAtB;EACH;;AAT0E;;;8BAAlEJ,gC,UACsC,yC"}
@@ -0,0 +1,4 @@
1
+ import { ElasticsearchIndexPlugin } from "@webiny/api-elasticsearch/plugins/definition/ElasticsearchIndexPlugin";
2
+ export declare class CmsEntryElasticsearchIndexPlugin extends ElasticsearchIndexPlugin {
3
+ static readonly type: string;
4
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.CmsEntryElasticsearchIndexPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _ElasticsearchIndexPlugin = require("@webiny/api-elasticsearch/plugins/definition/ElasticsearchIndexPlugin");
13
+
14
+ class CmsEntryElasticsearchIndexPlugin extends _ElasticsearchIndexPlugin.ElasticsearchIndexPlugin {}
15
+
16
+ exports.CmsEntryElasticsearchIndexPlugin = CmsEntryElasticsearchIndexPlugin;
17
+ (0, _defineProperty2.default)(CmsEntryElasticsearchIndexPlugin, "type", "cms.entry.elasticsearch.index");
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CmsEntryElasticsearchIndexPlugin","ElasticsearchIndexPlugin"],"sources":["CmsEntryElasticsearchIndexPlugin.ts"],"sourcesContent":["import { ElasticsearchIndexPlugin } from \"@webiny/api-elasticsearch/plugins/definition/ElasticsearchIndexPlugin\";\n\nexport class CmsEntryElasticsearchIndexPlugin extends ElasticsearchIndexPlugin {\n public static override readonly type: string = \"cms.entry.elasticsearch.index\";\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAEO,MAAMA,gCAAN,SAA+CC,kDAA/C,CAAwE;;;8BAAlED,gC,UACsC,+B"}
@@ -0,0 +1,30 @@
1
+ import { Plugin } from "@webiny/plugins/Plugin";
2
+ import { CmsModelField } from "@webiny/api-headless-cms/types";
3
+ export interface CreatePathCallableParams<T = any> {
4
+ field: CmsModelField;
5
+ key: string;
6
+ value: T;
7
+ }
8
+ export interface CreatePathCallable<T = any> {
9
+ (params: CreatePathCallableParams<T>): string;
10
+ }
11
+ export interface TransformCallableParams<T = any> {
12
+ field: CmsModelField;
13
+ value: T;
14
+ }
15
+ export interface TransformCallable<T = any> {
16
+ (params: TransformCallableParams<T>): string;
17
+ }
18
+ export interface CmsEntryElasticsearchQueryBuilderValueSearchPluginParams {
19
+ fieldType: string;
20
+ path?: string | CreatePathCallable;
21
+ transform: TransformCallable;
22
+ }
23
+ export declare class CmsEntryElasticsearchQueryBuilderValueSearchPlugin extends Plugin {
24
+ static readonly type: string;
25
+ private readonly config;
26
+ get fieldType(): string;
27
+ constructor(params: CmsEntryElasticsearchQueryBuilderValueSearchPluginParams);
28
+ transform(params: TransformCallableParams): any;
29
+ createPath(params: CreatePathCallableParams): string | null;
30
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.CmsEntryElasticsearchQueryBuilderValueSearchPlugin = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _Plugin = require("@webiny/plugins/Plugin");
13
+
14
+ class CmsEntryElasticsearchQueryBuilderValueSearchPlugin extends _Plugin.Plugin {
15
+ get fieldType() {
16
+ return this.config.fieldType;
17
+ }
18
+
19
+ constructor(params) {
20
+ super();
21
+ (0, _defineProperty2.default)(this, "config", void 0);
22
+ this.config = params;
23
+ this.name = `${this.constructor.type}-${this.config.fieldType}`;
24
+ }
25
+
26
+ transform(params) {
27
+ return this.config.transform(params);
28
+ }
29
+
30
+ createPath(params) {
31
+ if (typeof this.config.path === "function") {
32
+ return this.config.path(params);
33
+ } else if (typeof this.config.path === "string") {
34
+ return this.config.path;
35
+ }
36
+
37
+ return null;
38
+ }
39
+
40
+ }
41
+
42
+ exports.CmsEntryElasticsearchQueryBuilderValueSearchPlugin = CmsEntryElasticsearchQueryBuilderValueSearchPlugin;
43
+ (0, _defineProperty2.default)(CmsEntryElasticsearchQueryBuilderValueSearchPlugin, "type", "cms-elastic-search-query-builder-value-search");
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CmsEntryElasticsearchQueryBuilderValueSearchPlugin","Plugin","fieldType","config","constructor","params","name","type","transform","createPath","path"],"sources":["CmsEntryElasticsearchQueryBuilderValueSearchPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nexport interface CreatePathCallableParams<T = any> {\n field: CmsModelField;\n key: string;\n value: T;\n}\n\nexport interface CreatePathCallable<T = any> {\n (params: CreatePathCallableParams<T>): string;\n}\n\nexport interface TransformCallableParams<T = any> {\n field: CmsModelField;\n value: T;\n}\nexport interface TransformCallable<T = any> {\n (params: TransformCallableParams<T>): string;\n}\n\nexport interface CmsEntryElasticsearchQueryBuilderValueSearchPluginParams {\n fieldType: string;\n path?: string | CreatePathCallable;\n transform: TransformCallable;\n}\nexport class CmsEntryElasticsearchQueryBuilderValueSearchPlugin extends Plugin {\n public static override readonly type: string = \"cms-elastic-search-query-builder-value-search\";\n\n private readonly config: CmsEntryElasticsearchQueryBuilderValueSearchPluginParams;\n\n public get fieldType(): string {\n return this.config.fieldType;\n }\n\n public constructor(params: CmsEntryElasticsearchQueryBuilderValueSearchPluginParams) {\n super();\n\n this.config = params;\n this.name = `${(this.constructor as any).type}-${this.config.fieldType}`;\n }\n\n public transform(params: TransformCallableParams): any {\n return this.config.transform(params);\n }\n\n public createPath(params: CreatePathCallableParams): string | null {\n if (typeof this.config.path === \"function\") {\n return this.config.path(params);\n } else if (typeof this.config.path === \"string\") {\n return this.config.path;\n }\n return null;\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AA0BO,MAAMA,kDAAN,SAAiEC,cAAjE,CAAwE;EAKvD,IAATC,SAAS,GAAW;IAC3B,OAAO,KAAKC,MAAL,CAAYD,SAAnB;EACH;;EAEME,WAAW,CAACC,MAAD,EAAmE;IACjF;IADiF;IAGjF,KAAKF,MAAL,GAAcE,MAAd;IACA,KAAKC,IAAL,GAAa,GAAG,KAAKF,WAAN,CAA0BG,IAAK,IAAG,KAAKJ,MAAL,CAAYD,SAAU,EAAvE;EACH;;EAEMM,SAAS,CAACH,MAAD,EAAuC;IACnD,OAAO,KAAKF,MAAL,CAAYK,SAAZ,CAAsBH,MAAtB,CAAP;EACH;;EAEMI,UAAU,CAACJ,MAAD,EAAkD;IAC/D,IAAI,OAAO,KAAKF,MAAL,CAAYO,IAAnB,KAA4B,UAAhC,EAA4C;MACxC,OAAO,KAAKP,MAAL,CAAYO,IAAZ,CAAiBL,MAAjB,CAAP;IACH,CAFD,MAEO,IAAI,OAAO,KAAKF,MAAL,CAAYO,IAAnB,KAA4B,QAAhC,EAA0C;MAC7C,OAAO,KAAKP,MAAL,CAAYO,IAAnB;IACH;;IACD,OAAO,IAAP;EACH;;AA3B0E;;;8BAAlEV,kD,UACsC,+C"}
@@ -3,7 +3,7 @@ import { CmsModel } from "@webiny/api-headless-cms/types";
3
3
  export interface ModifyQueryParams extends BaseModifyQueryParams {
4
4
  model: CmsModel;
5
5
  }
6
- export interface Config {
6
+ export interface CmsEntryElasticsearchQueryModifierPluginConfig {
7
7
  modifyQuery: ModifyQueryCallable<ModifyQueryParams>;
8
8
  /**
9
9
  * If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.
@@ -13,5 +13,5 @@ export interface Config {
13
13
  export declare class CmsEntryElasticsearchQueryModifierPlugin extends ElasticsearchQueryModifierPlugin<ModifyQueryParams> {
14
14
  static readonly type: string;
15
15
  readonly modelId?: string;
16
- constructor(config: Config);
16
+ constructor(config: CmsEntryElasticsearchQueryModifierPluginConfig);
17
17
  }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CmsEntryElasticsearchQueryModifierPlugin","ElasticsearchQueryModifierPlugin","constructor","config","modifyQuery","modelId"],"sources":["CmsEntryElasticsearchQueryModifierPlugin.ts"],"sourcesContent":["import {\n ElasticsearchQueryModifierPlugin,\n ModifyQueryCallable,\n ModifyQueryParams as BaseModifyQueryParams\n} from \"@webiny/api-elasticsearch/plugins/definition/ElasticsearchQueryModifierPlugin\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\nexport interface ModifyQueryParams extends BaseModifyQueryParams {\n model: CmsModel;\n}\n\nexport interface CmsEntryElasticsearchQueryModifierPluginConfig {\n modifyQuery: ModifyQueryCallable<ModifyQueryParams>;\n /**\n * If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.\n */\n modelId?: string;\n}\n\nexport class CmsEntryElasticsearchQueryModifierPlugin extends ElasticsearchQueryModifierPlugin<ModifyQueryParams> {\n public static override readonly type: string = \"cms.elasticsearch.modifier.query.entry\";\n\n public readonly modelId?: string;\n\n public constructor(config: CmsEntryElasticsearchQueryModifierPluginConfig) {\n super(config.modifyQuery);\n\n this.modelId = config.modelId;\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAmBO,MAAMA,wCAAN,SAAuDC,kEAAvD,CAA2G;EAKvGC,WAAW,CAACC,MAAD,EAAyD;IACvE,MAAMA,MAAM,CAACC,WAAb;IADuE;IAGvE,KAAKC,OAAL,GAAeF,MAAM,CAACE,OAAtB;EACH;;AAT6G;;;8BAArGL,wC,UACsC,wC"}
@@ -3,7 +3,7 @@ import { CmsModel } from "@webiny/api-headless-cms/types";
3
3
  export interface ModifySortParams extends BaseModifySortParams {
4
4
  model: CmsModel;
5
5
  }
6
- export interface Config {
6
+ export interface CmsEntryElasticsearchSortModifierPluginConfig {
7
7
  modifySort: ModifySortCallable<ModifySortParams>;
8
8
  /**
9
9
  * If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.
@@ -13,5 +13,5 @@ export interface Config {
13
13
  export declare class CmsEntryElasticsearchSortModifierPlugin extends ElasticsearchSortModifierPlugin<ModifySortParams> {
14
14
  static readonly type: string;
15
15
  readonly modelId?: string;
16
- constructor(config: Config);
16
+ constructor(config: CmsEntryElasticsearchSortModifierPluginConfig);
17
17
  }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CmsEntryElasticsearchSortModifierPlugin","ElasticsearchSortModifierPlugin","constructor","config","modifySort","modelId"],"sources":["CmsEntryElasticsearchSortModifierPlugin.ts"],"sourcesContent":["import {\n ElasticsearchSortModifierPlugin,\n ModifySortCallable,\n ModifySortParams as BaseModifySortParams\n} from \"@webiny/api-elasticsearch/plugins/definition/ElasticsearchSortModifierPlugin\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\nexport interface ModifySortParams extends BaseModifySortParams {\n model: CmsModel;\n}\n\nexport interface CmsEntryElasticsearchSortModifierPluginConfig {\n modifySort: ModifySortCallable<ModifySortParams>;\n /**\n * If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.\n */\n modelId?: string;\n}\n\nexport class CmsEntryElasticsearchSortModifierPlugin extends ElasticsearchSortModifierPlugin<ModifySortParams> {\n public static override readonly type: string = \"cms.elasticsearch.modifier.sort.entry\";\n\n public readonly modelId?: string;\n\n public constructor(config: CmsEntryElasticsearchSortModifierPluginConfig) {\n super(config.modifySort);\n this.modelId = config.modelId;\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAmBO,MAAMA,uCAAN,SAAsDC,gEAAtD,CAAwG;EAKpGC,WAAW,CAACC,MAAD,EAAwD;IACtE,MAAMA,MAAM,CAACC,UAAb;IADsE;IAEtE,KAAKC,OAAL,GAAeF,MAAM,CAACE,OAAtB;EACH;;AAR0G;;;8BAAlGL,uC,UACsC,uC"}
package/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Plugin } from "@webiny/plugins/types";
1
+ import { Plugin, PluginCollection } from "@webiny/plugins/types";
2
2
  import { CmsEntry, CmsModel, CmsModelField, CmsModelFieldToGraphQLPlugin, HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations } from "@webiny/api-headless-cms/types";
3
3
  import { DynamoDBTypes, TableConstructor } from "dynamodb-toolbox/dist/classes/Table";
4
4
  import { DocumentClient } from "aws-sdk/clients/dynamodb";
@@ -6,35 +6,6 @@ import { EntityAttributeConfig, EntityCompositeAttributes } from "dynamodb-toolb
6
6
  import { Client } from "@elastic/elasticsearch";
7
7
  import { Entity, Table } from "dynamodb-toolbox";
8
8
  import { PluginsContainer } from "@webiny/plugins";
9
- /**
10
- * Arguments for ElasticsearchQueryBuilderValueSearchPlugin.
11
- *
12
- * @see ElasticsearchQueryBuilderValueSearchPlugin.transform
13
- */
14
- interface ElasticsearchQueryBuilderValueSearchPluginArgs {
15
- field: CmsModelField;
16
- value: any;
17
- }
18
- /**
19
- * A plugin definition for transforming the search value for Elasticsearch.
20
- *
21
- * @category Plugin
22
- * @category Elasticsearch
23
- */
24
- export interface ElasticsearchQueryBuilderValueSearchPlugin extends Plugin {
25
- /**
26
- * A plugin type.
27
- */
28
- type: "cms-elastic-search-query-builder-value-search";
29
- /**
30
- * A field type for plugin to target.
31
- */
32
- fieldType: string;
33
- /**
34
- * Transform value that is going to be searched for in the Elasticsearch.
35
- */
36
- transform: (args: ElasticsearchQueryBuilderValueSearchPluginArgs) => any;
37
- }
38
9
  /**
39
10
  * A definition of the entry that is being prepared for the Elasticsearch.
40
11
  *
@@ -176,9 +147,8 @@ export interface StorageOperationsFactoryParams {
176
147
  elasticsearch: Client;
177
148
  table?: TableModifier;
178
149
  esTable?: TableModifier;
179
- modelFieldToGraphQLPlugins: CmsModelFieldToGraphQLPlugin[];
180
150
  attributes?: Record<ENTITIES, Attributes>;
181
- plugins?: Plugin[] | Plugin[][];
151
+ plugins?: PluginCollection;
182
152
  }
183
153
  export interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {
184
154
  getTable: () => Table;
package/types.js CHANGED
@@ -5,19 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.ENTITIES = void 0;
7
7
 
8
- /**
9
- * Arguments for ElasticsearchQueryBuilderValueSearchPlugin.
10
- *
11
- * @see ElasticsearchQueryBuilderValueSearchPlugin.transform
12
- */
13
-
14
- /**
15
- * A plugin definition for transforming the search value for Elasticsearch.
16
- *
17
- * @category Plugin
18
- * @category Elasticsearch
19
- */
20
-
21
8
  /**
22
9
  * A definition of the entry that is being prepared for the Elasticsearch.
23
10
  *
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ENTITIES"],"sources":["types.ts"],"sourcesContent":["import { Plugin, PluginCollection } from \"@webiny/plugins/types\";\nimport {\n CmsEntry,\n CmsModel,\n CmsModelField,\n CmsModelFieldToGraphQLPlugin,\n HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations\n} from \"@webiny/api-headless-cms/types\";\nimport { DynamoDBTypes, TableConstructor } from \"dynamodb-toolbox/dist/classes/Table\";\nimport { DocumentClient } from \"aws-sdk/clients/dynamodb\";\nimport {\n EntityAttributeConfig,\n EntityCompositeAttributes\n} from \"dynamodb-toolbox/dist/classes/Entity\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { Entity, Table } from \"dynamodb-toolbox\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\n/**\n * A definition of the entry that is being prepared for the Elasticsearch.\n *\n * @category Elasticsearch\n * @category CmsEntry\n */\nexport interface CmsIndexEntry extends CmsEntry {\n /**\n * Values that are not going to be indexed.\n */\n rawValues: Record<string, any>;\n /**\n * A first part of the ID, without the revision.\n * For example, we can search for all the revisions of the given entry.\n */\n primaryId: string;\n /**\n * Dev can add what ever keys they want and need. Just need to be careful not to break the entry.\n */\n [key: string]: any;\n}\n\n/**\n * Arguments for the method that is transforming content entry in its original form to the one we are storing to the Elasticsearch.\n *\n * @category Elasticsearch\n * @category CmsEntry\n */\ninterface CmsModelFieldToElasticsearchToParams {\n plugins: PluginsContainer;\n model: CmsModel;\n field: CmsModelField;\n /**\n * Raw value on the entry - before prepare for storage.\n */\n rawValue: any;\n /**\n * Value prepared for storage received from base api-headless-cms package.\n */\n value: any;\n getFieldIndexPlugin(fieldType: string): CmsModelFieldToElasticsearchPlugin;\n getFieldTypePlugin(fieldType: string): CmsModelFieldToGraphQLPlugin;\n}\n\n/**\n * Arguments for the method that is transforming content entry from Elasticsearch into the original one.\n *\n * @category Elasticsearch\n * @category CmsEntry\n */\ninterface CmsModelFieldToElasticsearchFromParams {\n plugins: PluginsContainer;\n model: CmsModel;\n field: CmsModelField;\n value: any;\n rawValue: any;\n getFieldIndexPlugin(fieldType: string): CmsModelFieldToElasticsearchPlugin;\n getFieldTypePlugin(fieldType: string): CmsModelFieldToGraphQLPlugin;\n}\n\ninterface ToIndexValue {\n /**\n * Use this key to store value for indexing.\n */\n value?: any;\n /**\n * Use this key to tell ES that this value should not be indexed.\n */\n rawValue?: any;\n}\n\n/**\n * A plugin defining transformation of entry for Elasticsearch.\n *\n * @category Plugin\n * @category ContentModelField\n * @category CmsEntry\n * @category Elasticsearch\n */\nexport interface CmsModelFieldToElasticsearchPlugin extends Plugin {\n /**\n * A plugin type\n */\n type: \"cms-model-field-to-elastic-search\";\n /**\n * A unique identifier of the field type (text, number, json, myField, ...).\n *\n * ```ts\n * fieldType: \"myField\"\n * ```\n */\n fieldType: string;\n /**\n * If you need to define a type when building an Elasticsearch query.\n * Check [dateTimeIndexing](https://github.com/webiny/webiny-js/blob/3074165701b8b45e5fc6ac2444caace7d04ada66/packages/api-headless-cms/src/content/plugins/es/indexing/dateTimeIndexing.ts) plugin for usage example.\n *\n * ```ts\n * unmappedType: \"date\"\n * ```\n */\n unmappedType?: (field: CmsModelField) => string;\n /**\n * This is meant to do some transformation of the entry, preferably only to fieldType it was defined for. Nothing is stopping you to do anything you want to other fields, but try to separate field transformations.\n * It returns `Partial<CmsContentIndexEntryType>`. Always return a top-level property of the entry since it is merged via spread operator.\n *\n * ```ts\n * toIndex({ value }) {\n * return {\n * value: value, // This will be stored and indexed\n * rawValue: JSON.stringify(value) // This will be stored but excluded from indexing\n * };\n * }\n * ```\n */\n toIndex?: (params: CmsModelFieldToElasticsearchToParams) => ToIndexValue;\n /**\n * This is meant to revert a transformation done in the `toIndex` method.\n * You have access to \"value\" or a \"rawValue\", depending on what you returned from `toIndex`.\n *\n * ```ts\n * fromIndex({ value, rawValue }) {\n * return JSON.parse(rawValue);\n * }\n * ```\n */\n fromIndex?: (params: CmsModelFieldToElasticsearchFromParams) => any;\n}\n\nexport type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;\n\nexport type Attributes = Record<string, AttributeDefinition>;\n\nexport enum ENTITIES {\n SYSTEM = \"CmsSystem\",\n SETTINGS = \"CmsSettings\",\n GROUPS = \"CmsGroups\",\n MODELS = \"CmsModels\",\n ENTRIES = \"CmsEntries\",\n ENTRIES_ES = \"CmsEntriesElasticsearch\"\n}\n\nexport interface TableModifier {\n (table: TableConstructor): TableConstructor;\n}\n\nexport interface StorageOperationsFactoryParams {\n documentClient: DocumentClient;\n elasticsearch: Client;\n table?: TableModifier;\n esTable?: TableModifier;\n attributes?: Record<ENTITIES, Attributes>;\n plugins?: PluginCollection;\n}\n\nexport interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {\n getTable: () => Table;\n getEsTable: () => Table;\n getEntities: () => Record<\n \"system\" | \"settings\" | \"groups\" | \"models\" | \"entries\" | \"entriesEs\",\n Entity<any>\n >;\n}\n\nexport interface StorageOperationsFactory {\n (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;\n}\n"],"mappings":";;;;;;;AAkBA;AACA;AACA;AACA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;;AAsBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IAsDYA,Q;;;WAAAA,Q;EAAAA,Q;EAAAA,Q;EAAAA,Q;EAAAA,Q;EAAAA,Q;EAAAA,Q;GAAAA,Q,wBAAAA,Q"}
@@ -1,2 +1,2 @@
1
- declare const _default: () => import("@webiny/api-upgrade").UpgradePlugin<import("@webiny/api-headless-cms/types").CmsContext>[];
1
+ declare const _default: () => never[];
2
2
  export default _default;
package/upgrades/index.js CHANGED
@@ -1,16 +1,10 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.default = void 0;
9
7
 
10
- var _index = _interopRequireDefault(require("./v5.0.0/index"));
11
-
12
- var _index2 = _interopRequireDefault(require("./v5.8.0/index"));
13
-
14
- var _default = () => [(0, _index.default)(), (0, _index2.default)()];
8
+ var _default = () => [];
15
9
 
16
10
  exports.default = _default;
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export default () => [];\n"],"mappings":";;;;;;;eAAe,MAAM,E"}
@@ -1,7 +0,0 @@
1
- import { ElasticsearchQueryBuilderOperatorPlugin } from "@webiny/api-elasticsearch/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin";
2
- import { PluginsContainer } from "@webiny/plugins";
3
- interface OperatorPlugins {
4
- [operator: string]: ElasticsearchQueryBuilderOperatorPlugin;
5
- }
6
- export declare const operatorPluginsList: (plugins: PluginsContainer) => OperatorPlugins;
7
- export {};
@@ -1,30 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.operatorPluginsList = void 0;
9
-
10
- var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
- var _ElasticsearchQueryBuilderOperatorPlugin = require("@webiny/api-elasticsearch/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin");
13
-
14
- const operatorPluginsList = plugins => {
15
- return plugins.byType(_ElasticsearchQueryBuilderOperatorPlugin.ElasticsearchQueryBuilderOperatorPlugin.type).reduce((plugins, plugin) => {
16
- const operator = plugin.getOperator();
17
-
18
- if (plugins[operator]) {
19
- throw new _error.default("There is a ElasticsearchQueryBuilderOperatorPlugin defined for the operator.", "PLUGIN_ALREADY_EXISTS", {
20
- operator: operator,
21
- name: plugin.name || "unknown"
22
- });
23
- }
24
-
25
- plugins[operator] = plugin;
26
- return plugins;
27
- }, {});
28
- };
29
-
30
- exports.operatorPluginsList = operatorPluginsList;
@@ -1,3 +0,0 @@
1
- import { CmsModel } from "@webiny/api-headless-cms/types";
2
- import { CmsEntryElasticsearchFieldPlugin } from "../../plugins/CmsEntryElasticsearchFieldPlugin";
3
- export declare const createElasticsearchFields: (model: CmsModel) => Record<string, CmsEntryElasticsearchFieldPlugin>;
@@ -1,60 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createElasticsearchFields = void 0;
7
-
8
- var _CmsEntryElasticsearchFieldPlugin = require("../../plugins/CmsEntryElasticsearchFieldPlugin");
9
-
10
- const fieldsWithKeywords = ["text", "long-text", "rich-text", "id", "ref"];
11
- /**
12
- * We need to map entry system fields that have different paths, no keyword or not sortable.
13
- */
14
-
15
- const systemFields = {
16
- createdBy: new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
17
- field: "createdBy",
18
- path: "createdBy.id",
19
- searchable: true,
20
- keyword: true,
21
- sortable: false
22
- }),
23
- ownedBy: new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
24
- field: "ownedBy",
25
- path: "ownedBy.id",
26
- searchable: true,
27
- keyword: true,
28
- sortable: false
29
- }),
30
- createdOn: new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
31
- field: "createdOn",
32
- path: "createdOn",
33
- searchable: true,
34
- keyword: false,
35
- sortable: false,
36
- unmappedType: "date"
37
- }),
38
- savedOn: new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
39
- field: "savedOn",
40
- path: "savedOn",
41
- searchable: true,
42
- keyword: false,
43
- sortable: false,
44
- unmappedType: "date"
45
- })
46
- };
47
-
48
- const createElasticsearchFields = model => {
49
- return model.fields.reduce((fields, field) => {
50
- fields[field.fieldId] = new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
51
- field: field.fieldId,
52
- path: `values.${field.fieldId}`,
53
- searchable: true,
54
- keyword: fieldsWithKeywords.includes(field.type)
55
- });
56
- return fields;
57
- }, systemFields);
58
- };
59
-
60
- exports.createElasticsearchFields = createElasticsearchFields;
@@ -1,5 +0,0 @@
1
- import { Client } from "@elastic/elasticsearch";
2
- export interface Params {
3
- elasticsearch: Client;
4
- }
5
- export declare const createElasticsearchTemplate: (params: Params) => Promise<void>;
@@ -1,62 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.createElasticsearchTemplate = void 0;
9
-
10
- var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
- const createElasticsearchTemplate = async params => {
13
- const {
14
- elasticsearch
15
- } = params;
16
- const options = {
17
- name: "headless-cms-entries-index",
18
- body: {
19
- index_patterns: ["*headless-cms*"],
20
- settings: {
21
- analysis: {
22
- analyzer: {
23
- lowercase_analyzer: {
24
- type: "custom",
25
- filter: ["lowercase", "trim"],
26
- tokenizer: "keyword"
27
- }
28
- }
29
- }
30
- },
31
- mappings: {
32
- properties: {
33
- property: {
34
- type: "text",
35
- fields: {
36
- keyword: {
37
- type: "keyword",
38
- ignore_above: 256
39
- }
40
- },
41
- analyzer: "lowercase_analyzer"
42
- },
43
- rawValues: {
44
- type: "object",
45
- enabled: false
46
- }
47
- }
48
- }
49
- }
50
- };
51
-
52
- try {
53
- await elasticsearch.indices.putTemplate(options);
54
- } catch (ex) {
55
- throw new _error.default(ex.message || "Could not create Elasticsearch index template for the Headless CMS.", ex.code || "CMS_ELASTICSEARCH_TEMPLATE_ERROR", {
56
- error: ex,
57
- options
58
- });
59
- }
60
- };
61
-
62
- exports.createElasticsearchTemplate = createElasticsearchTemplate;
@@ -1 +0,0 @@
1
- export declare const paginateBatch: (items: any, perPage: any, execute: any) => Promise<void>;
package/upgrades/utils.js DELETED
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.paginateBatch = void 0;
7
-
8
- const paginateBatch = async (items, perPage, execute) => {
9
- const pages = Math.ceil(items.length / perPage);
10
-
11
- for (let i = 0; i < pages; i++) {
12
- await execute(items.slice(i * perPage, i * perPage + perPage));
13
- }
14
- };
15
-
16
- exports.paginateBatch = paginateBatch;
@@ -1,6 +0,0 @@
1
- import { CmsEntry, CmsModel } from "@webiny/api-headless-cms/types";
2
- export declare const cleanDatabaseRecord: <T extends CmsModel | CmsEntry>(record: T & {
3
- PK?: string;
4
- SK?: string;
5
- TYPE?: string;
6
- }) => T;
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.cleanDatabaseRecord = void 0;
9
-
10
- var _lodash = _interopRequireDefault(require("lodash.omit"));
11
-
12
- const cleanDatabaseRecord = record => {
13
- return (0, _lodash.default)(record, ["PK", "SK", "TYPE"]);
14
- };
15
-
16
- exports.cleanDatabaseRecord = cleanDatabaseRecord;
@@ -1,2 +0,0 @@
1
- import { CmsContext } from "@webiny/api-headless-cms/types";
2
- export declare const createOldVersionIndiceName: (context: CmsContext) => string;
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createOldVersionIndiceName = void 0;
7
-
8
- const createOldVersionIndiceName = context => {
9
- return `${context.tenancy.getCurrentTenant().id}-headless-cms`;
10
- };
11
-
12
- exports.createOldVersionIndiceName = createOldVersionIndiceName;