@webiny/api-headless-cms-ddb-es 6.4.12-beta.5 → 6.5.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/exports/api/cms/opensearch.d.ts +1 -1
  2. package/exports/api/cms/opensearch.js +1 -1
  3. package/feature.js +29 -15
  4. package/feature.js.map +1 -1
  5. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js +4 -4
  6. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js.map +1 -1
  7. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js +11 -2
  8. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js.map +1 -1
  9. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js +1 -1
  10. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js.map +1 -1
  11. package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.js +1 -1
  12. package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.js.map +1 -1
  13. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js +1 -1
  14. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js.map +1 -1
  15. package/helpers/fieldIdentifier.js +2 -2
  16. package/helpers/fieldIdentifier.js.map +1 -1
  17. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +2 -2
  18. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
  19. package/operations/entry/elasticsearch/body.d.ts +5 -3
  20. package/operations/entry/elasticsearch/body.js +4 -3
  21. package/operations/entry/elasticsearch/body.js.map +1 -1
  22. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +3 -3
  23. package/operations/entry/elasticsearch/filtering/applyFiltering.js +2 -2
  24. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
  25. package/operations/entry/elasticsearch/filtering/exec.d.ts +2 -2
  26. package/operations/entry/elasticsearch/filtering/exec.js +7 -6
  27. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
  28. package/operations/entry/elasticsearch/fullTextSearch.js +2 -2
  29. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
  30. package/operations/entry/elasticsearch/keyword.js +2 -2
  31. package/operations/entry/elasticsearch/keyword.js.map +1 -1
  32. package/operations/entry/elasticsearch/plugins/operator.d.ts +4 -4
  33. package/operations/entry/elasticsearch/plugins/operator.js +3 -6
  34. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
  35. package/operations/entry/elasticsearch/sort.d.ts +4 -1
  36. package/operations/entry/elasticsearch/sort.js +5 -5
  37. package/operations/entry/elasticsearch/sort.js.map +1 -1
  38. package/operations/entry/elasticsearch/types.d.ts +3 -6
  39. package/operations/entry/index.d.ts +4 -3
  40. package/operations/entry/index.js +40 -18
  41. package/operations/entry/index.js.map +1 -1
  42. package/operations/entry/transformations/modifyEntryValues.d.ts +1 -1
  43. package/package.json +24 -24
  44. package/tasks/CreateElasticsearchIndexTask.d.ts +16 -0
  45. package/tasks/{createIndexTaskPlugin.js → CreateElasticsearchIndexTask.js} +25 -20
  46. package/tasks/CreateElasticsearchIndexTask.js.map +1 -0
  47. package/types.d.ts +4 -7
  48. package/types.js.map +1 -1
  49. package/debuggerNamespaces.d.ts +0 -12
  50. package/debuggerNamespaces.js +0 -0
  51. package/tasks/createIndexTaskPlugin.d.ts +0 -2
  52. package/tasks/createIndexTaskPlugin.js.map +0 -1
@@ -5,5 +5,5 @@ export { CmsEntryOpenSearchSortModifier } from "../../../features/CmsEntryOpenSe
5
5
  export { CmsEntryOpenSearchQueryModifier } from "../../../features/CmsEntryOpenSearchQueryModifier/index.js";
6
6
  export { CmsEntryOpenSearchValueSearch, CmsEntryOpenSearchValueSearchRegistry } from "../../../features/CmsEntryOpenSearchValueSearch/index.js";
7
7
  export { CmsEntryOpenSearchFullTextSearch } from "../../../features/CmsEntryOpenSearchFullTextSearch/index.js";
8
- export { CmsModelOpenSearchIndex } from "../../../features/CmsModelOpenSearchIndex/index.js";
8
+ export { CmsModelOpenSearchIndex, CmsModelOpenSearchIndexProvider } from "../../../features/CmsModelOpenSearchIndex/index.js";
9
9
  export { CmsEntryOpenSearchValuesModifier } from "../../../features/CmsEntryOpenSearchValuesModifier/index.js";
@@ -5,5 +5,5 @@ export { CmsEntryOpenSearchSortModifier } from "../../../features/CmsEntryOpenSe
5
5
  export { CmsEntryOpenSearchQueryModifier } from "../../../features/CmsEntryOpenSearchQueryModifier/index.js";
6
6
  export { CmsEntryOpenSearchValueSearch, CmsEntryOpenSearchValueSearchRegistry } from "../../../features/CmsEntryOpenSearchValueSearch/index.js";
7
7
  export { CmsEntryOpenSearchFullTextSearch } from "../../../features/CmsEntryOpenSearchFullTextSearch/index.js";
8
- export { CmsModelOpenSearchIndex } from "../../../features/CmsModelOpenSearchIndex/index.js";
8
+ export { CmsModelOpenSearchIndex, CmsModelOpenSearchIndexProvider } from "../../../features/CmsModelOpenSearchIndex/index.js";
9
9
  export { CmsEntryOpenSearchValuesModifier } from "../../../features/CmsEntryOpenSearchValuesModifier/index.js";
package/feature.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createTable, registerExtension } from "@webiny/db-dynamodb";
1
+ import { DynamoDBClient, createTable } from "@webiny/db-dynamodb";
2
2
  import { StorageOperationsFactory } from "@webiny/api-headless-cms/exports/api/cms/storage.js";
3
3
  import { ENTITIES } from "./types.js";
4
4
  import { createRegisterExtensionPlugin } from "@webiny/handler";
@@ -15,7 +15,6 @@ import { createElasticsearchIndex } from "./elasticsearch/createElasticsearchInd
15
15
  import { createGroupsStorageOperations } from "./operations/group/index.js";
16
16
  import { createOpenSearchEntity, createOpenSearchTable } from "@webiny/api-opensearch";
17
17
  import { deleteElasticsearchIndex } from "./elasticsearch/deleteElasticsearchIndex.js";
18
- import { createCreateIndexTask } from "./tasks/createIndexTaskPlugin.js";
19
18
  import { ModelAfterCreateEventHandler } from "@webiny/api-headless-cms/features/contentModel/CreateModel/index.js";
20
19
  import { ModelAfterCreateFromEventHandler } from "@webiny/api-headless-cms/features/contentModel/CreateModelFrom/events.js";
21
20
  import { ModelAfterDeleteEventHandler } from "@webiny/api-headless-cms/features/contentModel/DeleteModel/events.js";
@@ -27,10 +26,14 @@ import { CmsEntryOpenSearchQueryModifier } from "./features/CmsEntryOpenSearchQu
27
26
  import { CmsEntryOpenSearchFullTextSearch } from "./features/CmsEntryOpenSearchFullTextSearch/index.js";
28
27
  import { CmsEntryOpenSearchValuesModifier } from "./features/CmsEntryOpenSearchValuesModifier/index.js";
29
28
  import { CmsEntryOpenSearchFieldIndexFeature, CmsEntryOpenSearchFieldIndexRegistry } from "./features/CmsEntryOpenSearchFieldIndex/index.js";
30
- import { Debugger } from "@webiny/api-core/features/debugger/index.js";
31
29
  import { CmsEntryOpenSearchFilterFeature, CmsEntryOpenSearchFilterRegistry } from "./features/CmsEntryOpenSearchFilter/index.js";
30
+ import { DbRegistry } from "@webiny/db/exports/api/db.js";
31
+ import { OpenSearchClient, OpenSearchFieldFactory, OpenSearchQueryBuilderOperatorRegistry } from "@webiny/api-opensearch/exports/api/opensearch.js";
32
+ import { CreateElasticsearchIndexTask } from "./tasks/CreateElasticsearchIndexTask.js";
32
33
  const createOpenSearchStorageOperations = (params)=>{
33
- const { table, esTable, documentClient, elasticsearch, plugins, container } = params;
34
+ const { table, esTable, elasticsearch, plugins, container } = params;
35
+ const db = container.resolve(DynamoDBClient);
36
+ const documentClient = db.client;
34
37
  const tableInstance = createTable({
35
38
  name: table || process.env.DB_TABLE,
36
39
  documentClient
@@ -67,6 +70,8 @@ const createOpenSearchStorageOperations = (params)=>{
67
70
  const fullTextSearches = container.resolveAll(CmsEntryOpenSearchFullTextSearch);
68
71
  const valuesModifiers = container.resolveAll(CmsEntryOpenSearchValuesModifier);
69
72
  const filterRegistry = container.resolve(CmsEntryOpenSearchFilterRegistry);
73
+ const operatorRegistry = container.resolve(OpenSearchQueryBuilderOperatorRegistry);
74
+ const fieldFactory = container.resolve(OpenSearchFieldFactory);
70
75
  const indexProvider = container.resolve(CmsModelOpenSearchIndexProvider);
71
76
  const configurations = createConfigurations(indexProvider);
72
77
  container.registerFactory(ModelAfterCreateEventHandler, ()=>({
@@ -103,8 +108,9 @@ const createOpenSearchStorageOperations = (params)=>{
103
108
  entity: entities.entries,
104
109
  esEntity: entities.entriesEs,
105
110
  plugins,
106
- elasticsearch,
107
111
  configurations,
112
+ operatorRegistry,
113
+ elasticsearch,
108
114
  fieldRegistry,
109
115
  fieldIndexRegistry,
110
116
  compressionHandler,
@@ -115,12 +121,13 @@ const createOpenSearchStorageOperations = (params)=>{
115
121
  fullTextSearches,
116
122
  valuesModifiers,
117
123
  filterRegistry,
118
- debuggerService: container.resolve(Debugger)
124
+ fieldFactory
119
125
  });
120
126
  return {
121
127
  name: "dynamodb:opensearch",
122
128
  beforeInit: async (context)=>{
123
- context.db.registry.register({
129
+ const dbRegistry = context.container.resolve(DbRegistry);
130
+ dbRegistry.register({
124
131
  item: entities.entries,
125
132
  app: "cms",
126
133
  tags: [
@@ -128,7 +135,7 @@ const createOpenSearchStorageOperations = (params)=>{
128
135
  entities.entries.name
129
136
  ]
130
137
  });
131
- context.db.registry.register({
138
+ dbRegistry.register({
132
139
  item: entities.entriesEs,
133
140
  app: "cms",
134
141
  tags: [
@@ -136,7 +143,6 @@ const createOpenSearchStorageOperations = (params)=>{
136
143
  entities.entriesEs.name
137
144
  ]
138
145
  });
139
- createCreateIndexTask(context);
140
146
  entries.dataLoaders.clearAll();
141
147
  },
142
148
  getEntities: ()=>entities,
@@ -155,10 +161,12 @@ const createOpenSearchStorageOperations = (params)=>{
155
161
  };
156
162
  };
157
163
  class OpenSearchStorageOperationsFactoryImpl {
164
+ constructor(openSearchClient){
165
+ this.openSearchClient = openSearchClient;
166
+ }
158
167
  async create(context) {
159
168
  return createOpenSearchStorageOperations({
160
- documentClient: context.db.driver.getClient(),
161
- elasticsearch: context.opensearch,
169
+ elasticsearch: this.openSearchClient.use(),
162
170
  plugins: context.plugins,
163
171
  container: context.container
164
172
  });
@@ -166,7 +174,9 @@ class OpenSearchStorageOperationsFactoryImpl {
166
174
  }
167
175
  const OpenSearchStorageOperationsFactory = StorageOperationsFactory.createImplementation({
168
176
  implementation: OpenSearchStorageOperationsFactoryImpl,
169
- dependencies: []
177
+ dependencies: [
178
+ OpenSearchClient
179
+ ]
170
180
  });
171
181
  const storageOperationsFeature = createFeature({
172
182
  name: "cms.storageOperations.openSearch",
@@ -175,13 +185,17 @@ const storageOperationsFeature = createFeature({
175
185
  CmsEntryOpenSearchFilterFeature.register(container);
176
186
  CmsModelOpenSearchIndexFeature.register(container);
177
187
  CmsEntryOpenSearchValueSearchFeature.register(container);
188
+ container.register(CreateElasticsearchIndexTask);
178
189
  container.register(OpenSearchStorageOperationsFactory).inSingletonScope();
179
190
  }
180
191
  });
181
- const registerCmsOpenSearchStorageOperations = ()=>[
182
- registerExtension(),
183
- createRegisterExtensionPlugin((context)=>storageOperationsFeature.register(context.container))
192
+ const registerCmsOpenSearchStorageOperations = ()=>{
193
+ const plugin = createRegisterExtensionPlugin((context)=>storageOperationsFeature.register(context.container));
194
+ plugin.name = "cms.registerOpenSearchStorageOperations";
195
+ return [
196
+ plugin
184
197
  ];
198
+ };
185
199
  export { registerCmsOpenSearchStorageOperations };
186
200
 
187
201
  //# sourceMappingURL=feature.js.map
package/feature.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"feature.js","sources":["../src/feature.ts"],"sourcesContent":["import { createTable, registerExtension as registerDynamoDbExtension } from \"@webiny/db-dynamodb\";\nimport { StorageOperationsFactory as StorageOperationsFactoryAbstraction } from \"@webiny/api-headless-cms/exports/api/cms/storage.js\";\nimport type { CmsContext, StorageOperationsFactory as IStorageOperationsFactory } from \"~/types.js\";\nimport { ENTITIES } from \"~/types.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createRegisterExtensionPlugin } from \"@webiny/handler\";\nimport { createFeature } from \"@webiny/feature/api/index.js\";\nimport {\n CmsEntryOpenSearchValueSearchFeature,\n CmsEntryOpenSearchValueSearchRegistry\n} from \"~/features/CmsEntryOpenSearchValueSearch/index.js\";\nimport {\n CmsModelOpenSearchIndexFeature,\n CmsModelOpenSearchIndexProvider\n} from \"~/features/CmsModelOpenSearchIndex/index.js\";\nimport { createConfigurations } from \"~/configurations.js\";\nimport { createModelsStorageOperations } from \"./operations/model/index.js\";\nimport { createEntriesStorageOperations } from \"./operations/entry/index.js\";\nimport { createGroupEntity } from \"~/definitions/group.js\";\nimport { createModelEntity } from \"~/definitions/model.js\";\nimport { createEntryEntity } from \"~/definitions/entry.js\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex.js\";\nimport { createGroupsStorageOperations } from \"~/operations/group/index.js\";\nimport { createOpenSearchEntity, createOpenSearchTable } from \"@webiny/api-opensearch\";\nimport { deleteElasticsearchIndex } from \"./elasticsearch/deleteElasticsearchIndex.js\";\nimport { createCreateIndexTask } from \"~/tasks/createIndexTaskPlugin.js\";\nimport { ModelAfterCreateEventHandler } from \"@webiny/api-headless-cms/features/contentModel/CreateModel/index.js\";\nimport { ModelAfterCreateFromEventHandler } from \"@webiny/api-headless-cms/features/contentModel/CreateModelFrom/events.js\";\nimport { ModelAfterDeleteEventHandler } from \"@webiny/api-headless-cms/features/contentModel/DeleteModel/events.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\nimport { CmsEntryOpenSearchBodyModifier } from \"~/features/CmsEntryOpenSearchBodyModifier/index.js\";\nimport { CmsEntryOpenSearchSortModifier } from \"~/features/CmsEntryOpenSearchSortModifier/index.js\";\nimport { CmsEntryOpenSearchQueryModifier } from \"~/features/CmsEntryOpenSearchQueryModifier/index.js\";\nimport { CmsEntryOpenSearchFullTextSearch } from \"~/features/CmsEntryOpenSearchFullTextSearch/index.js\";\nimport { CmsEntryOpenSearchValuesModifier } from \"~/features/CmsEntryOpenSearchValuesModifier/index.js\";\nimport {\n CmsEntryOpenSearchFieldIndexFeature,\n CmsEntryOpenSearchFieldIndexRegistry\n} from \"~/features/CmsEntryOpenSearchFieldIndex/index.js\";\nimport { Debugger } from \"@webiny/api-core/features/debugger/index.js\";\nimport {\n CmsEntryOpenSearchFilterFeature,\n CmsEntryOpenSearchFilterRegistry\n} from \"~/features/CmsEntryOpenSearchFilter/index.js\";\n\nconst createOpenSearchStorageOperations: IStorageOperationsFactory = params => {\n const { table, esTable, documentClient, elasticsearch, plugins, container } = params;\n\n const tableInstance = createTable({\n name: table || (process.env.DB_TABLE as string),\n documentClient\n });\n const tableElasticsearchInstance = createOpenSearchTable({\n name: esTable,\n documentClient\n });\n\n const entities = {\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance\n }),\n entriesEs: createOpenSearchEntity({\n entityName: ENTITIES.ENTRIES_ES,\n table: tableElasticsearchInstance\n })\n };\n\n const fieldRegistry = container.resolve(CmsModelFieldToGraphQLRegistry);\n const fieldIndexRegistry = container.resolve(CmsEntryOpenSearchFieldIndexRegistry);\n const compressionHandler = container.resolve(CompressionHandler);\n const bodyModifiers = container.resolveAll(CmsEntryOpenSearchBodyModifier);\n const sortModifiers = container.resolveAll(CmsEntryOpenSearchSortModifier);\n const queryModifiers = container.resolveAll(CmsEntryOpenSearchQueryModifier);\n const valueSearchRegistry = container.resolve(CmsEntryOpenSearchValueSearchRegistry);\n const fullTextSearches = container.resolveAll(CmsEntryOpenSearchFullTextSearch);\n const valuesModifiers = container.resolveAll(CmsEntryOpenSearchValuesModifier);\n const filterRegistry = container.resolve(CmsEntryOpenSearchFilterRegistry);\n\n const indexProvider = container.resolve(CmsModelOpenSearchIndexProvider);\n const configurations = createConfigurations(indexProvider);\n\n container.registerFactory(ModelAfterCreateEventHandler, () => ({\n async handle(event) {\n const { model } = event.payload;\n await createElasticsearchIndex({\n client: elasticsearch,\n configurations,\n model\n });\n }\n }));\n\n container.registerFactory(ModelAfterCreateFromEventHandler, () => ({\n async handle(event) {\n const { model } = event.payload;\n await createElasticsearchIndex({\n client: elasticsearch,\n configurations,\n model\n });\n }\n }));\n\n container.registerFactory(ModelAfterDeleteEventHandler, () => ({\n async handle(event) {\n const { model } = event.payload;\n await deleteElasticsearchIndex({\n client: elasticsearch,\n configurations,\n model\n });\n }\n }));\n\n const entries = createEntriesStorageOperations({\n entity: entities.entries,\n esEntity: entities.entriesEs,\n plugins,\n elasticsearch,\n configurations,\n fieldRegistry,\n fieldIndexRegistry,\n compressionHandler,\n bodyModifiers,\n sortModifiers,\n queryModifiers,\n valueSearchRegistry,\n fullTextSearches,\n valuesModifiers,\n filterRegistry,\n debuggerService: container.resolve(Debugger)\n });\n\n return {\n name: \"dynamodb:opensearch\",\n beforeInit: async context => {\n context.db.registry.register({\n item: entities.entries,\n app: \"cms\",\n tags: [\"regular\", entities.entries.name]\n });\n context.db.registry.register({\n item: entities.entriesEs,\n app: \"cms\",\n tags: [\"es\", entities.entriesEs.name]\n });\n // TODO we know that context is ok, but types are missing elasticsearch/opensearch\n // @ts-expect-error\n createCreateIndexTask(context);\n\n entries.dataLoaders.clearAll();\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n getEsTable: () => tableElasticsearchInstance,\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n container\n }),\n models: createModelsStorageOperations({\n entity: entities.models,\n elasticsearch,\n configurations\n }),\n entries\n };\n};\n\nclass OpenSearchStorageOperationsFactoryImpl\n implements StorageOperationsFactoryAbstraction.Interface\n{\n public async create(context: CmsContext) {\n return createOpenSearchStorageOperations({\n documentClient: context.db.driver.getClient() as DynamoDBDocument,\n elasticsearch: context.opensearch,\n plugins: context.plugins,\n container: context.container\n });\n }\n}\n\nconst OpenSearchStorageOperationsFactory = StorageOperationsFactoryAbstraction.createImplementation(\n {\n implementation: OpenSearchStorageOperationsFactoryImpl,\n dependencies: []\n }\n);\n\nconst storageOperationsFeature = createFeature({\n name: \"cms.storageOperations.openSearch\",\n register: container => {\n CmsEntryOpenSearchFieldIndexFeature.register(container);\n CmsEntryOpenSearchFilterFeature.register(container);\n CmsModelOpenSearchIndexFeature.register(container);\n CmsEntryOpenSearchValueSearchFeature.register(container);\n container.register(OpenSearchStorageOperationsFactory).inSingletonScope();\n }\n});\n\nexport const registerCmsOpenSearchStorageOperations = () => {\n return [\n registerDynamoDbExtension(),\n createRegisterExtensionPlugin(context => {\n return storageOperationsFeature.register(context.container);\n })\n ];\n};\n"],"names":["createOpenSearchStorageOperations","params","table","esTable","documentClient","elasticsearch","plugins","container","tableInstance","createTable","process","tableElasticsearchInstance","createOpenSearchTable","entities","createGroupEntity","ENTITIES","createModelEntity","createEntryEntity","createOpenSearchEntity","fieldRegistry","CmsModelFieldToGraphQLRegistry","fieldIndexRegistry","CmsEntryOpenSearchFieldIndexRegistry","compressionHandler","CompressionHandler","bodyModifiers","CmsEntryOpenSearchBodyModifier","sortModifiers","CmsEntryOpenSearchSortModifier","queryModifiers","CmsEntryOpenSearchQueryModifier","valueSearchRegistry","CmsEntryOpenSearchValueSearchRegistry","fullTextSearches","CmsEntryOpenSearchFullTextSearch","valuesModifiers","CmsEntryOpenSearchValuesModifier","filterRegistry","CmsEntryOpenSearchFilterRegistry","indexProvider","CmsModelOpenSearchIndexProvider","configurations","createConfigurations","ModelAfterCreateEventHandler","event","model","createElasticsearchIndex","ModelAfterCreateFromEventHandler","ModelAfterDeleteEventHandler","deleteElasticsearchIndex","entries","createEntriesStorageOperations","Debugger","context","createCreateIndexTask","createGroupsStorageOperations","createModelsStorageOperations","OpenSearchStorageOperationsFactoryImpl","OpenSearchStorageOperationsFactory","StorageOperationsFactoryAbstraction","storageOperationsFeature","createFeature","CmsEntryOpenSearchFieldIndexFeature","CmsEntryOpenSearchFilterFeature","CmsModelOpenSearchIndexFeature","CmsEntryOpenSearchValueSearchFeature","registerCmsOpenSearchStorageOperations","registerDynamoDbExtension","createRegisterExtensionPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAMA,oCAA+DC,CAAAA;IACjE,MAAM,EAAEC,KAAK,EAAEC,OAAO,EAAEC,cAAc,EAAEC,aAAa,EAAEC,OAAO,EAAEC,SAAS,EAAE,GAAGN;IAE9E,MAAMO,gBAAgBC,YAAY;QAC9B,MAAMP,SAAUQ,QAAQ,GAAG,CAAC,QAAQ;QACpCN;IACJ;IACA,MAAMO,6BAA6BC,sBAAsB;QACrD,MAAMT;QACNC;IACJ;IAEA,MAAMS,WAAW;QACb,QAAQC,kBAAkB;YACtB,YAAYC,SAAS,MAAM;YAC3B,OAAOP;QACX;QACA,QAAQQ,kBAAkB;YACtB,YAAYD,SAAS,MAAM;YAC3B,OAAOP;QACX;QACA,SAASS,kBAAkB;YACvB,YAAYF,SAAS,OAAO;YAC5B,OAAOP;QACX;QACA,WAAWU,uBAAuB;YAC9B,YAAYH,SAAS,UAAU;YAC/B,OAAOJ;QACX;IACJ;IAEA,MAAMQ,gBAAgBZ,UAAU,OAAO,CAACa;IACxC,MAAMC,qBAAqBd,UAAU,OAAO,CAACe;IAC7C,MAAMC,qBAAqBhB,UAAU,OAAO,CAACiB;IAC7C,MAAMC,gBAAgBlB,UAAU,UAAU,CAACmB;IAC3C,MAAMC,gBAAgBpB,UAAU,UAAU,CAACqB;IAC3C,MAAMC,iBAAiBtB,UAAU,UAAU,CAACuB;IAC5C,MAAMC,sBAAsBxB,UAAU,OAAO,CAACyB;IAC9C,MAAMC,mBAAmB1B,UAAU,UAAU,CAAC2B;IAC9C,MAAMC,kBAAkB5B,UAAU,UAAU,CAAC6B;IAC7C,MAAMC,iBAAi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C,IAAI;iBAAC;YACzC;YAGAyC,sBAAsBD;YAEtBH,QAAQ,WAAW,CAAC,QAAQ;QAChC;QACA,aAAa,IAAMrC;QACnB,UAAU,IAAML;QAChB,YAAY,IAAMG;QAClB,QAAQ4C,8BAA8B;YAClC,QAAQ1C,SAAS,MAAM;YACvBN;QACJ;QACA,QAAQiD,8BAA8B;YAClC,QAAQ3C,SAAS,MAAM;YACvBR;YACAoC;QACJ;QACAS;IACJ;AACJ;AAEA,MAAMO;IAGF,MAAa,OAAOJ,OAAmB,EAAE;QACrC,OAAOrD,kCAAkC;YACrC,gBAAgBqD,QAAQ,EAAE,CAAC,MAAM,CAAC,SAAS;YAC3C,eAAeA,QAAQ,UAAU;YACjC,SAASA,QAAQ,OAAO;YACxB,WAAWA,QAAQ,SAAS;QAChC;IACJ;AACJ;AAEA,MAAMK,qCAAqCC,yBAAAA,oBAAwD,CAC/F;IACI,gBAAgBF;IAChB,cAAc,EAAE;AACpB;AAGJ,MAAMG,2BAA2BC,cAAc;IAC3C,MAAM;IACN,UAAUtD,CAAAA;QACNuD,oCAAoC,QAAQ,CAACvD;QAC7CwD,gCAAgC,QAAQ,CAACxD;QACzCyD,+BAA+B,QAAQ,CAACzD;QACxC0D,qCAAqC,QAAQ,CAAC1D;QAC9CA,UAAU,QAAQ,CAACmD,oCAAoC,gBAAgB;IAC3E;AACJ;AAEO,MAAMQ,yCAAyC,IAC3C;QACHC;QACAC,8BAA8Bf,CAAAA,UACnBO,yBAAyB,QAAQ,CAACP,QAAQ,SAAS;KAEjE"}
1
+ {"version":3,"file":"feature.js","sources":["../src/feature.ts"],"sourcesContent":["import { createTable, DynamoDBClient } from \"@webiny/db-dynamodb\";\nimport { StorageOperationsFactory as StorageOperationsFactoryAbstraction } from \"@webiny/api-headless-cms/exports/api/cms/storage.js\";\nimport type { CmsContext, StorageOperationsFactory as IStorageOperationsFactory } from \"~/types.js\";\nimport { ENTITIES } from \"~/types.js\";\nimport { createRegisterExtensionPlugin } from \"@webiny/handler\";\nimport { createFeature } from \"@webiny/feature/api/index.js\";\nimport {\n CmsEntryOpenSearchValueSearchFeature,\n CmsEntryOpenSearchValueSearchRegistry\n} from \"~/features/CmsEntryOpenSearchValueSearch/index.js\";\nimport {\n CmsModelOpenSearchIndexFeature,\n CmsModelOpenSearchIndexProvider\n} from \"~/features/CmsModelOpenSearchIndex/index.js\";\nimport { createConfigurations } from \"~/configurations.js\";\nimport { createModelsStorageOperations } from \"./operations/model/index.js\";\nimport { createEntriesStorageOperations } from \"./operations/entry/index.js\";\nimport { createGroupEntity } from \"~/definitions/group.js\";\nimport { createModelEntity } from \"~/definitions/model.js\";\nimport { createEntryEntity } from \"~/definitions/entry.js\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex.js\";\nimport { createGroupsStorageOperations } from \"~/operations/group/index.js\";\nimport { createOpenSearchEntity, createOpenSearchTable } from \"@webiny/api-opensearch\";\nimport { deleteElasticsearchIndex } from \"./elasticsearch/deleteElasticsearchIndex.js\";\nimport { ModelAfterCreateEventHandler } from \"@webiny/api-headless-cms/features/contentModel/CreateModel/index.js\";\nimport { ModelAfterCreateFromEventHandler } from \"@webiny/api-headless-cms/features/contentModel/CreateModelFrom/events.js\";\nimport { ModelAfterDeleteEventHandler } from \"@webiny/api-headless-cms/features/contentModel/DeleteModel/events.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\nimport { CmsEntryOpenSearchBodyModifier } from \"~/features/CmsEntryOpenSearchBodyModifier/index.js\";\nimport { CmsEntryOpenSearchSortModifier } from \"~/features/CmsEntryOpenSearchSortModifier/index.js\";\nimport { CmsEntryOpenSearchQueryModifier } from \"~/features/CmsEntryOpenSearchQueryModifier/index.js\";\nimport { CmsEntryOpenSearchFullTextSearch } from \"~/features/CmsEntryOpenSearchFullTextSearch/index.js\";\nimport { CmsEntryOpenSearchValuesModifier } from \"~/features/CmsEntryOpenSearchValuesModifier/index.js\";\nimport {\n CmsEntryOpenSearchFieldIndexFeature,\n CmsEntryOpenSearchFieldIndexRegistry\n} from \"~/features/CmsEntryOpenSearchFieldIndex/index.js\";\nimport {\n CmsEntryOpenSearchFilterFeature,\n CmsEntryOpenSearchFilterRegistry\n} from \"~/features/CmsEntryOpenSearchFilter/index.js\";\nimport { DbRegistry } from \"@webiny/db/exports/api/db.js\";\nimport {\n OpenSearchClient,\n OpenSearchFieldFactory,\n OpenSearchQueryBuilderOperatorRegistry\n} from \"@webiny/api-opensearch/exports/api/opensearch.js\";\nimport { CreateElasticsearchIndexTask } from \"~/tasks/CreateElasticsearchIndexTask.js\";\n\nconst createOpenSearchStorageOperations: IStorageOperationsFactory = params => {\n const { table, esTable, elasticsearch, plugins, container } = params;\n\n const db = container.resolve(DynamoDBClient);\n const documentClient = db.client;\n\n const tableInstance = createTable({\n name: table || (process.env.DB_TABLE as string),\n documentClient\n });\n const tableElasticsearchInstance = createOpenSearchTable({\n name: esTable,\n documentClient\n });\n\n const entities = {\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance\n }),\n entriesEs: createOpenSearchEntity({\n entityName: ENTITIES.ENTRIES_ES,\n table: tableElasticsearchInstance\n })\n };\n\n const fieldRegistry = container.resolve(CmsModelFieldToGraphQLRegistry);\n const fieldIndexRegistry = container.resolve(CmsEntryOpenSearchFieldIndexRegistry);\n const compressionHandler = container.resolve(CompressionHandler);\n const bodyModifiers = container.resolveAll(CmsEntryOpenSearchBodyModifier);\n const sortModifiers = container.resolveAll(CmsEntryOpenSearchSortModifier);\n const queryModifiers = container.resolveAll(CmsEntryOpenSearchQueryModifier);\n const valueSearchRegistry = container.resolve(CmsEntryOpenSearchValueSearchRegistry);\n const fullTextSearches = container.resolveAll(CmsEntryOpenSearchFullTextSearch);\n const valuesModifiers = container.resolveAll(CmsEntryOpenSearchValuesModifier);\n const filterRegistry = container.resolve(CmsEntryOpenSearchFilterRegistry);\n const operatorRegistry = container.resolve(OpenSearchQueryBuilderOperatorRegistry);\n const fieldFactory = container.resolve(OpenSearchFieldFactory);\n\n const indexProvider = container.resolve(CmsModelOpenSearchIndexProvider);\n const configurations = createConfigurations(indexProvider);\n\n container.registerFactory(ModelAfterCreateEventHandler, () => ({\n async handle(event) {\n const { model } = event.payload;\n await createElasticsearchIndex({\n client: elasticsearch,\n configurations,\n model\n });\n }\n }));\n\n container.registerFactory(ModelAfterCreateFromEventHandler, () => ({\n async handle(event) {\n const { model } = event.payload;\n await createElasticsearchIndex({\n client: elasticsearch,\n configurations,\n model\n });\n }\n }));\n\n container.registerFactory(ModelAfterDeleteEventHandler, () => ({\n async handle(event) {\n const { model } = event.payload;\n await deleteElasticsearchIndex({\n client: elasticsearch,\n configurations,\n model\n });\n }\n }));\n\n const entries = createEntriesStorageOperations({\n entity: entities.entries,\n esEntity: entities.entriesEs,\n plugins,\n configurations,\n operatorRegistry,\n elasticsearch,\n fieldRegistry,\n fieldIndexRegistry,\n compressionHandler,\n bodyModifiers,\n sortModifiers,\n queryModifiers,\n valueSearchRegistry,\n fullTextSearches,\n valuesModifiers,\n filterRegistry,\n fieldFactory\n });\n\n return {\n name: \"dynamodb:opensearch\",\n beforeInit: async context => {\n const dbRegistry = context.container.resolve(DbRegistry);\n\n dbRegistry.register({\n item: entities.entries,\n app: \"cms\",\n tags: [\"regular\", entities.entries.name]\n });\n dbRegistry.register({\n item: entities.entriesEs,\n app: \"cms\",\n tags: [\"es\", entities.entriesEs.name]\n });\n\n entries.dataLoaders.clearAll();\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n getEsTable: () => tableElasticsearchInstance,\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n container\n }),\n models: createModelsStorageOperations({\n entity: entities.models,\n elasticsearch,\n configurations\n }),\n entries\n };\n};\n\nclass OpenSearchStorageOperationsFactoryImpl\n implements StorageOperationsFactoryAbstraction.Interface\n{\n public constructor(private readonly openSearchClient: OpenSearchClient.Interface) {}\n\n public async create(context: CmsContext) {\n return createOpenSearchStorageOperations({\n elasticsearch: this.openSearchClient.use(),\n plugins: context.plugins,\n container: context.container\n });\n }\n}\n\nconst OpenSearchStorageOperationsFactory = StorageOperationsFactoryAbstraction.createImplementation(\n {\n implementation: OpenSearchStorageOperationsFactoryImpl,\n dependencies: [OpenSearchClient]\n }\n);\n\nconst storageOperationsFeature = createFeature({\n name: \"cms.storageOperations.openSearch\",\n register: container => {\n CmsEntryOpenSearchFieldIndexFeature.register(container);\n CmsEntryOpenSearchFilterFeature.register(container);\n CmsModelOpenSearchIndexFeature.register(container);\n CmsEntryOpenSearchValueSearchFeature.register(container);\n container.register(CreateElasticsearchIndexTask);\n container.register(OpenSearchStorageOperationsFactory).inSingletonScope();\n }\n});\n\nexport const registerCmsOpenSearchStorageOperations = () => {\n const plugin = createRegisterExtensionPlugin(context => {\n return storageOperationsFeature.register(context.container);\n });\n\n plugin.name = \"cms.registerOpenSearchStorageOperations\";\n\n return [plugin];\n};\n"],"names":["createOpenSearchStorageOperations","params","table","esTable","elasticsearch","plugins","container","db","DynamoDBClient","documentClient","tableInstance","createTable","process","tableElasticsearchInstance","createOpenSearchTable","entities","createGroupEntity","ENTITIES","createModelEntity","createEntryEntity","createOpenSearchEntity","fieldRegistry","CmsModelFieldToGraphQLRegistry","fieldIndexRegistry","CmsEntryOpenSearchFieldIndexRegistry","compressionHandler","CompressionHandler","bodyModifiers","CmsEntryOpenSearchBodyModifier","sortModifiers","CmsEntryOpenSearchSortModifier","queryModifiers","CmsEntryOpenSearchQueryModifier","valueSearchRegistry","CmsEntryOpenSearchValueSearchRegistry","fullTextSearches","CmsEntryOpenSearchFullTextSearch","valuesModifiers","CmsEntryOpenSearchValuesModifier","filterRegistry","CmsEntryOpenSearchFilterRegistry","operatorRegistry","OpenSearchQueryBuilderOperatorRegistry","fieldFactory","OpenSearchFieldFactory","indexProvider","CmsModelOpenSearchIndexProvider","configurations","createConfigurations","ModelAfterCreateEventHandler","event","model","createElasticsearchIndex","ModelAfterCreateFromEventHandler","ModelAfterDeleteEventHandler","deleteElasticsearchIndex","entries","createEntriesStorageOperations","context","dbRegistry","DbRegistry","createGroupsStorageOperations","createModelsStorageOperations","OpenSearchStorageOperationsFactoryImpl","openSearchClient","OpenSearchStorageOperationsFactory","StorageOperationsFactoryAbstraction","OpenSearchClient","storageOperationsFeature","createFeature","CmsEntryOpenSearchFieldIndexFeature","CmsEntryOpenSearchFilterFeature","CmsModelOpenSearchIndexFeature","CmsEntryOpenSearchValueSearchFeature","CreateElasticsearchIndexTask","registerCmsOpenSearchStorageOperations","plugin","createRegisterExtensionPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,MAAMA,oCAA+DC,CAAAA;IACjE,MAAM,EAAEC,KAAK,EAAEC,OAAO,EAAEC,aAAa,EAAEC,OAAO,EAAEC,SAAS,EAAE,GAAGL;IAE9D,MAAMM,KAAKD,UAAU,OAAO,CAACE;IAC7B,MAAMC,iBAAiBF,GAAG,MAAM;IAEhC,MAAMG,gBAAgBC,YAAY;QAC9B,MAAMT,SAAUU,QAAQ,GAAG,CAAC,QAAQ;QACpCH;IACJ;IACA,MAAMI,6BAA6BC,sBAAsB;QACrD,MAAMX;QACNM;IACJ;IAEA,MAAMM,WAAW;QACb,QAAQC,kBAAkB;YACtB,YAAYC,SAAS,MAAM;YAC3B,OAAOP;QACX;QACA,QAAQQ,kBAAkB;YACtB,YAAYD,SAAS,MAAM;YAC3B,OAAOP;QACX;QACA,SAASS,kBAAkB;YACvB,YAAYF,SAAS,OAAO;YAC5B,OAAOP;QACX;QACA,WAAWU,uBAAuB;YAC9B,YAAYH,SAAS,UAAU;YAC/B,OAAOJ;QACX;IACJ;IAEA,MAAMQ,gBAAgBf,UAAU,OAAO,CAACgB;IACxC,MAA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C9CA,UAAU,QAAQ,CAACoE;QACnBpE,UAAU,QAAQ,CAAC2D,oCAAoC,gBAAgB;IAC3E;AACJ;AAEO,MAAMU,yCAAyC;IAClD,MAAMC,SAASC,8BAA8BnB,CAAAA,UAClCU,yBAAyB,QAAQ,CAACV,QAAQ,SAAS;IAG9DkB,OAAO,IAAI,GAAG;IAEd,OAAO;QAACA;KAAO;AACnB"}
@@ -17,15 +17,15 @@ const convertNumberToTime = (value)=>{
17
17
  };
18
18
  const convertValueToIndex = (value, field)=>{
19
19
  if (!value) return null;
20
- else if (field.settings?.type === "time") return convertTimeToNumber(value);
20
+ if (field.settings?.type === "time") return convertTimeToNumber(value);
21
21
  return value;
22
22
  };
23
23
  const convertValueFromIndex = (value, field)=>{
24
24
  const type = field.settings?.type;
25
25
  if ("time" === type) return convertNumberToTime(value);
26
- else if (!value) return null;
27
- else if ("dateTimeWithTimezone" === type) return value;
28
- else if ("date" === type) {
26
+ if (!value) return null;
27
+ if ("dateTimeWithTimezone" === type) return value;
28
+ if ("date" === type) {
29
29
  const dateValue = new Date(value);
30
30
  return dateValue.toISOString().slice(0, 10);
31
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js","sources":["../../../../src/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.ts"],"sourcesContent":["import type { CmsModelDateTimeField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsEntryOpenSearchFieldIndex } from \"../abstractions/CmsEntryOpenSearchFieldIndex.js\";\n\nconst convertTimeToNumber = (time?: string): number | null => {\n if (!time) {\n return null;\n }\n const [hours, minutes, seconds = 0] = time.split(\":\").map(Number);\n return hours * 60 * 60 + minutes * 60 + seconds;\n};\n\nconst convertNumberToTime = (value?: number): string | null => {\n if (value === undefined || value === null) {\n return null;\n }\n\n const hours = Math.floor(value / 60 / 60);\n const minutes = Math.floor((value - hours * 60 * 60) / 60);\n const seconds = Math.floor(value - hours * 60 * 60 - minutes * 60);\n\n return [hours, minutes, seconds].map(v => String(v).padStart(2, \"0\")).join(\":\");\n};\n\nconst convertValueToIndex = (value: string, field: CmsModelDateTimeField) => {\n if (!value) {\n return null;\n } else if (field.settings?.type === \"time\") {\n return convertTimeToNumber(value);\n }\n return value;\n};\n\nconst convertValueFromIndex = (\n value: string | number,\n field: CmsModelDateTimeField\n): string | null => {\n const type = field.settings?.type;\n if (type === \"time\") {\n return convertNumberToTime(value as number);\n } else if (!value) {\n return null;\n } else if (type === \"dateTimeWithTimezone\") {\n return value as string;\n } else if (type === \"date\") {\n const dateValue = new Date(value);\n return dateValue.toISOString().slice(0, 10);\n }\n return new Date(value).toISOString();\n};\n\nclass DateTimeFieldIndexImpl implements CmsEntryOpenSearchFieldIndex.Interface {\n public readonly fieldType = \"datetime\";\n\n public unmappedType(): string {\n return \"date\";\n }\n\n public toIndex({\n field,\n value\n }: CmsEntryOpenSearchFieldIndex.ToIndex): CmsEntryOpenSearchFieldIndex.ToValue {\n if (Array.isArray(value) === true) {\n return {\n value: value.map((v: string) => {\n return convertValueToIndex(v, field as CmsModelDateTimeField);\n })\n };\n }\n return {\n value: convertValueToIndex(value, field as CmsModelDateTimeField)\n };\n }\n\n public fromIndex({ field, value }: CmsEntryOpenSearchFieldIndex.FromIndex): any {\n if (Array.isArray(value) === true) {\n return value.map((v: string) => {\n return convertValueFromIndex(v, field as CmsModelDateTimeField);\n });\n }\n return convertValueFromIndex(value, field as CmsModelDateTimeField);\n }\n}\n\nexport const DateTimeFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({\n implementation: DateTimeFieldIndexImpl,\n dependencies: []\n});\n"],"names":["convertTimeToNumber","time","hours","minutes","seconds","Number","convertNumberToTime","value","Math","v","String","convertValueToIndex","field","convertValueFromIndex","type","dateValue","Date","DateTimeFieldIndexImpl","Array","DateTimeFieldIndex","CmsEntryOpenSearchFieldIndex"],"mappings":";AAGA,MAAMA,sBAAsB,CAACC;IACzB,IAAI,CAAC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AACX,QACd,OAAO;YACH,OAAOA,MAAM,GAAG,CAAC,CAACE,IACPE,oBAAoBF,GAAGG;QAEtC;QAEJ,OAAO;YACH,OAAOD,oBAAoBJ,OAAOK;QACtC;IACJ;IAEO,UAAU,EAAEA,KAAK,EAAEL,KAAK,EAA0C,EAAO;QAC5E,IAAIW,AAAyB,SAAzBA,MAAM,OAAO,CAACX,QACd,OAAOA,MAAM,GAAG,CAAC,CAACE,IACPI,sBAAsBJ,GAAGG;QAGxC,OAAOC,sBAAsBN,OAAOK;IACxC;;aA7BgB,SAAS,GAAG;;AA8BhC;AAEO,MAAMO,qBAAqBC,6BAA6B,oBAAoB,CAAC;IAChF,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
1
+ {"version":3,"file":"features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js","sources":["../../../../src/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.ts"],"sourcesContent":["import type { CmsModelDateTimeField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsEntryOpenSearchFieldIndex } from \"../abstractions/CmsEntryOpenSearchFieldIndex.js\";\n\nconst convertTimeToNumber = (time?: string): number | null => {\n if (!time) {\n return null;\n }\n const [hours, minutes, seconds = 0] = time.split(\":\").map(Number);\n return hours * 60 * 60 + minutes * 60 + seconds;\n};\n\nconst convertNumberToTime = (value?: number): string | null => {\n if (value === undefined || value === null) {\n return null;\n }\n\n const hours = Math.floor(value / 60 / 60);\n const minutes = Math.floor((value - hours * 60 * 60) / 60);\n const seconds = Math.floor(value - hours * 60 * 60 - minutes * 60);\n\n return [hours, minutes, seconds].map(v => String(v).padStart(2, \"0\")).join(\":\");\n};\n\nconst convertValueToIndex = (value: string, field: CmsModelDateTimeField) => {\n if (!value) {\n return null;\n } else if (field.settings?.type === \"time\") {\n return convertTimeToNumber(value);\n }\n return value;\n};\n\nconst convertValueFromIndex = (\n value: string | number,\n field: CmsModelDateTimeField\n): string | null => {\n const type = field.settings?.type;\n if (type === \"time\") {\n return convertNumberToTime(value as number);\n } else if (!value) {\n return null;\n } else if (type === \"dateTimeWithTimezone\") {\n return value as string;\n } else if (type === \"date\") {\n const dateValue = new Date(value);\n return dateValue.toISOString().slice(0, 10);\n }\n return new Date(value).toISOString();\n};\n\nclass DateTimeFieldIndexImpl implements CmsEntryOpenSearchFieldIndex.Interface {\n public readonly fieldType = \"datetime\";\n\n public unmappedType(): string {\n return \"date\";\n }\n\n public toIndex({\n field,\n value\n }: CmsEntryOpenSearchFieldIndex.ToIndex): CmsEntryOpenSearchFieldIndex.ToValue {\n if (Array.isArray(value) === true) {\n return {\n value: value.map((v: string) => {\n return convertValueToIndex(v, field as CmsModelDateTimeField);\n })\n };\n }\n return {\n value: convertValueToIndex(value, field as CmsModelDateTimeField)\n };\n }\n\n public fromIndex({ field, value }: CmsEntryOpenSearchFieldIndex.FromIndex): any {\n if (Array.isArray(value) === true) {\n return value.map((v: string) => {\n return convertValueFromIndex(v, field as CmsModelDateTimeField);\n });\n }\n return convertValueFromIndex(value, field as CmsModelDateTimeField);\n }\n}\n\nexport const DateTimeFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({\n implementation: DateTimeFieldIndexImpl,\n dependencies: []\n});\n"],"names":["convertTimeToNumber","time","hours","minutes","seconds","Number","convertNumberToTime","value","Math","v","String","convertValueToIndex","field","convertValueFromIndex","type","dateValue","Date","DateTimeFieldIndexImpl","Array","DateTimeFieldIndex","CmsEntryOpenSearchFieldIndex"],"mappings":";AAGA,MAAMA,sBAAsB,CAACC;IACzB,IAAI,CAACA,MACD,OAAO;IAEX,MAAM,CAACC,OAAOC,SAASC,UAAU,CAAC,CAAC,GAAGH,KAAK,KAAK,CAAC,KAAK,GAAG,CAACI;IAC1D,OAAOH,AAAQ,KAARA,QAAa,KAAKC,AAAU,KAAVA,UAAeC;AAC5C;AAEA,MAAME,sBAAsB,CAACC;IACzB,IAAIA,QAAAA,OACA,OAAO;IAGX,MAAML,QAAQM,KAAK,KAAK,C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C,CAACE,IACPI,sBAAsBJ,GAAGG;QAGxC,OAAOC,sBAAsBN,OAAOK;IACxC;;aA7BgB,SAAS,GAAG;;AA8BhC;AAEO,MAAMO,qBAAqBC,6BAA6B,oBAAoB,CAAC;IAChF,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
@@ -19,6 +19,10 @@ class ObjectFieldIndexImpl {
19
19
  model,
20
20
  fields
21
21
  });
22
+ if (initialValue[key]?._id) {
23
+ value._id = initialValue[key]._id;
24
+ rawValue._id = initialValue[key]._id;
25
+ }
22
26
  result.value.push(value);
23
27
  result.rawValue.push(rawValue);
24
28
  }
@@ -40,13 +44,18 @@ class ObjectFieldIndexImpl {
40
44
  const fields = field.settings?.fields || [];
41
45
  if (field.list) {
42
46
  const source = value || rawValue || [];
43
- return source.map((_, index)=>this.processFromIndex({
47
+ return source.map((_, index)=>{
48
+ const processed = this.processFromIndex({
44
49
  value: value ? value[index] || {} : {},
45
50
  rawValue: rawValue ? rawValue[index] || {} : {},
46
51
  getFieldIndex,
47
52
  model,
48
53
  fields
49
- }));
54
+ });
55
+ const sourceItem = value ? value[index] : rawValue ? rawValue[index] : null;
56
+ if (sourceItem?._id) processed._id = sourceItem._id;
57
+ return processed;
58
+ });
50
59
  }
51
60
  return this.processFromIndex({
52
61
  value,
@@ -1 +1 @@
1
- {"version":3,"file":"features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js","sources":["../../../../src/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.ts"],"sourcesContent":["import type { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { getFieldIdentifiers } from \"~/helpers/index.js\";\nimport { CmsEntryOpenSearchFieldIndex } from \"../abstractions/CmsEntryOpenSearchFieldIndex.js\";\n\ninterface ProcessToIndexParams {\n fields: CmsModelField[];\n value: Record<string, any>;\n rawValue: Record<string, any>;\n getFieldIndex: (fieldType: string) => CmsEntryOpenSearchFieldIndex.Interface;\n model: CmsModel;\n}\n\ninterface ReducerValue {\n value: Record<string, any>;\n rawValue: Record<string, any>;\n}\n\ninterface ProcessFromIndexParams {\n fields: CmsModelField[];\n value: Record<string, any>;\n rawValue?: Record<string, any> | null;\n getFieldIndex: (fieldType: string) => CmsEntryOpenSearchFieldIndex.Interface;\n model: CmsModel;\n}\n\nclass ObjectFieldIndexImpl implements CmsEntryOpenSearchFieldIndex.Interface {\n public readonly fieldType = \"object\";\n\n public toIndex({\n model,\n field,\n value: initialValue,\n rawValue: initialRawValue,\n getFieldIndex\n }: CmsEntryOpenSearchFieldIndex.ToIndex): CmsEntryOpenSearchFieldIndex.ToValue {\n if (!initialValue) {\n return { value: null };\n }\n\n const fields = (field.settings?.fields || []) as CmsModelField[];\n\n if (field.list) {\n const result: { value: Record<string, any>[]; rawValue: Record<string, any>[] } = {\n value: [],\n rawValue: []\n };\n for (const key in initialValue) {\n const { value, rawValue } = this.processToIndex({\n value: initialValue[key],\n rawValue: initialRawValue[key],\n getFieldIndex,\n model,\n fields\n });\n\n result.value.push(value);\n result.rawValue.push(rawValue);\n }\n\n return {\n value: result.value.length > 0 ? result.value : undefined,\n rawValue: result.rawValue.length > 0 ? result.rawValue : undefined\n };\n }\n\n return this.processToIndex({\n value: initialValue,\n rawValue: initialRawValue,\n getFieldIndex,\n model,\n fields\n });\n }\n\n public fromIndex({\n field,\n value,\n rawValue,\n model,\n getFieldIndex\n }: CmsEntryOpenSearchFieldIndex.FromIndex): any {\n if (!value) {\n return null;\n }\n\n const fields = field.settings?.fields || [];\n\n if (field.list) {\n const source = value || rawValue || [];\n\n return source.map((_: any, index: number) =>\n this.processFromIndex({\n value: value ? value[index] || {} : {},\n rawValue: rawValue ? rawValue[index] || {} : {},\n getFieldIndex,\n model,\n fields\n })\n );\n }\n\n return this.processFromIndex({\n value,\n rawValue,\n getFieldIndex,\n model,\n fields\n });\n }\n\n private processToIndex(params: ProcessToIndexParams): ReducerValue {\n const {\n fields,\n value: sourceValue,\n rawValue: sourceRawValue,\n getFieldIndex,\n model\n } = params;\n\n return fields.reduce<ReducerValue>(\n (values, field) => {\n const plugin = getFieldIndex(field.type);\n\n const identifiers = getFieldIdentifiers(sourceValue, sourceRawValue, field);\n if (!identifiers) {\n return values;\n }\n\n const { value, rawValue } = plugin.toIndex({\n model,\n field,\n value: sourceValue[\n identifiers.valueIdentifier || identifiers.rawValueIdentifier\n ],\n rawValue:\n sourceRawValue[\n identifiers.rawValueIdentifier || identifiers.valueIdentifier\n ],\n getFieldIndex\n });\n\n if (value !== undefined) {\n values.value[identifiers.valueIdentifier || identifiers.rawValueIdentifier] =\n value;\n }\n if (rawValue !== undefined) {\n values.rawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier] =\n rawValue;\n }\n\n return values;\n },\n { value: {}, rawValue: {} }\n );\n }\n\n private processFromIndex = (params: ProcessFromIndexParams): Record<string, any> => {\n const {\n fields,\n value: sourceValue,\n rawValue: sourceRawValue,\n getFieldIndex,\n model\n } = params;\n\n return fields.reduce<Record<string, any>>((values, field) => {\n const plugin = getFieldIndex(field.type);\n\n const identifiers = getFieldIdentifiers(sourceValue, sourceRawValue, field);\n if (!identifiers) {\n return values;\n }\n\n const value = plugin.fromIndex({\n model,\n field,\n value: sourceValue[identifiers.valueIdentifier || identifiers.rawValueIdentifier],\n rawValue: sourceRawValue\n ? sourceRawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier]\n : null,\n getFieldIndex\n });\n\n if (value !== undefined) {\n values[identifiers.valueIdentifier || identifiers.rawValueIdentifier] = value;\n }\n\n return values;\n }, {});\n };\n}\n\nexport const ObjectFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({\n implementation: ObjectFieldIndexImpl,\n dependencies: []\n});\n"],"names":["ObjectFieldIndexImpl","model","field","initialValue","initialRawValue","getFieldIndex","fields","result","key","value","rawValue","undefined","source","_","index","params","sourceValue","sourceRawValue","values","plugin","identifiers","getFieldIdentifiers","ObjectFieldIndex","CmsEntryOpenSearchFieldIndex"],"mappings":";;AAy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,IAAI;gBAEvC,MAAMkB,cAAcC,oBAAoBL,aAAaC,gBAAgBf;gBACrE,IAAI,CAACkB,aACD,OAAOF;gBAGX,MAAMT,QAAQU,OAAO,SAAS,CAAC;oBAC3BlB;oBACAC;oBACA,OAAOc,WAAW,CAACI,YAAY,eAAe,IAAIA,YAAY,kBAAkB,CAAC;oBACjF,UAAUH,iBACJA,cAAc,CAACG,YAAY,kBAAkB,IAAIA,YAAY,eAAe,CAAC,GAC7E;oBACNf;gBACJ;gBAEA,IAAII,AAAUE,WAAVF,OACAS,MAAM,CAACE,YAAY,eAAe,IAAIA,YAAY,kBAAkB,CAAC,GAAGX;gBAG5E,OAAOS;YACX,GAAG,CAAC;QACR;;AACJ;AAEO,MAAMI,mBAAmBC,6BAA6B,oBAAoB,CAAC;IAC9E,gBAAgBvB;IAChB,cAAc,EAAE;AACpB"}
1
+ {"version":3,"file":"features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js","sources":["../../../../src/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.ts"],"sourcesContent":["import type { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { getFieldIdentifiers } from \"~/helpers/index.js\";\nimport { CmsEntryOpenSearchFieldIndex } from \"../abstractions/CmsEntryOpenSearchFieldIndex.js\";\n\ninterface ProcessToIndexParams {\n fields: CmsModelField[];\n value: Record<string, any>;\n rawValue: Record<string, any>;\n getFieldIndex: (fieldType: string) => CmsEntryOpenSearchFieldIndex.Interface;\n model: CmsModel;\n}\n\ninterface ReducerValue {\n value: Record<string, any>;\n rawValue: Record<string, any>;\n}\n\ninterface ProcessFromIndexParams {\n fields: CmsModelField[];\n value: Record<string, any>;\n rawValue?: Record<string, any> | null;\n getFieldIndex: (fieldType: string) => CmsEntryOpenSearchFieldIndex.Interface;\n model: CmsModel;\n}\n\nclass ObjectFieldIndexImpl implements CmsEntryOpenSearchFieldIndex.Interface {\n public readonly fieldType = \"object\";\n\n public toIndex({\n model,\n field,\n value: initialValue,\n rawValue: initialRawValue,\n getFieldIndex\n }: CmsEntryOpenSearchFieldIndex.ToIndex): CmsEntryOpenSearchFieldIndex.ToValue {\n if (!initialValue) {\n return { value: null };\n }\n\n const fields = (field.settings?.fields || []) as CmsModelField[];\n\n if (field.list) {\n const result: { value: Record<string, any>[]; rawValue: Record<string, any>[] } = {\n value: [],\n rawValue: []\n };\n for (const key in initialValue) {\n const { value, rawValue } = this.processToIndex({\n value: initialValue[key],\n rawValue: initialRawValue[key],\n getFieldIndex,\n model,\n fields\n });\n\n if (initialValue[key]?._id) {\n value._id = initialValue[key]._id;\n rawValue._id = initialValue[key]._id;\n }\n\n result.value.push(value);\n result.rawValue.push(rawValue);\n }\n\n return {\n value: result.value.length > 0 ? result.value : undefined,\n rawValue: result.rawValue.length > 0 ? result.rawValue : undefined\n };\n }\n\n return this.processToIndex({\n value: initialValue,\n rawValue: initialRawValue,\n getFieldIndex,\n model,\n fields\n });\n }\n\n public fromIndex({\n field,\n value,\n rawValue,\n model,\n getFieldIndex\n }: CmsEntryOpenSearchFieldIndex.FromIndex): any {\n if (!value) {\n return null;\n }\n\n const fields = field.settings?.fields || [];\n\n if (field.list) {\n const source = value || rawValue || [];\n\n return source.map((_: any, index: number) => {\n const processed = this.processFromIndex({\n value: value ? value[index] || {} : {},\n rawValue: rawValue ? rawValue[index] || {} : {},\n getFieldIndex,\n model,\n fields\n });\n const sourceItem = value ? value[index] : rawValue ? rawValue[index] : null;\n if (sourceItem?._id) {\n processed._id = sourceItem._id;\n }\n return processed;\n });\n }\n\n return this.processFromIndex({\n value,\n rawValue,\n getFieldIndex,\n model,\n fields\n });\n }\n\n private processToIndex(params: ProcessToIndexParams): ReducerValue {\n const {\n fields,\n value: sourceValue,\n rawValue: sourceRawValue,\n getFieldIndex,\n model\n } = params;\n\n return fields.reduce<ReducerValue>(\n (values, field) => {\n const plugin = getFieldIndex(field.type);\n\n const identifiers = getFieldIdentifiers(sourceValue, sourceRawValue, field);\n if (!identifiers) {\n return values;\n }\n\n const { value, rawValue } = plugin.toIndex({\n model,\n field,\n value: sourceValue[\n identifiers.valueIdentifier || identifiers.rawValueIdentifier\n ],\n rawValue:\n sourceRawValue[\n identifiers.rawValueIdentifier || identifiers.valueIdentifier\n ],\n getFieldIndex\n });\n\n if (value !== undefined) {\n values.value[identifiers.valueIdentifier || identifiers.rawValueIdentifier] =\n value;\n }\n if (rawValue !== undefined) {\n values.rawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier] =\n rawValue;\n }\n\n return values;\n },\n { value: {}, rawValue: {} }\n );\n }\n\n private processFromIndex = (params: ProcessFromIndexParams): Record<string, any> => {\n const {\n fields,\n value: sourceValue,\n rawValue: sourceRawValue,\n getFieldIndex,\n model\n } = params;\n\n return fields.reduce<Record<string, any>>((values, field) => {\n const plugin = getFieldIndex(field.type);\n\n const identifiers = getFieldIdentifiers(sourceValue, sourceRawValue, field);\n if (!identifiers) {\n return values;\n }\n\n const value = plugin.fromIndex({\n model,\n field,\n value: sourceValue[identifiers.valueIdentifier || identifiers.rawValueIdentifier],\n rawValue: sourceRawValue\n ? sourceRawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier]\n : null,\n getFieldIndex\n });\n\n if (value !== undefined) {\n values[identifiers.valueIdentifier || identifiers.rawValueIdentifier] = value;\n }\n\n return values;\n }, {});\n };\n}\n\nexport const ObjectFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({\n implementation: ObjectFieldIndexImpl,\n dependencies: []\n});\n"],"names":["ObjectFieldIndexImpl","model","field","initialValue","initialRawValue","getFieldIndex","fields","result","key","value","rawValue","undefined","source","_","index","processed","sourceItem","params","sourceValue","sourceRawValue","values","plugin","identifiers","getFieldIdentifiers","ObjectFieldIndex","CmsEntryOpenSearchFieldIndex"],"mappings":";;AAyBA,MAAMA;IAGK,QAAQ,EACXC,KAAK,EACLC,KAAK,EACL,OAAOC,YAAY,EACnB,UAAUC,eAAe,EACzBC,aAAa,EACsB,EAAwC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IAElC;;aA1IgB,SAAS,GAAG;aA4IpB,gBAAgB,GAAG,CAACH;YACxB,MAAM,EACFX,MAAM,EACN,OAAOY,WAAW,EAClB,UAAUC,cAAc,EACxBd,aAAa,EACbJ,KAAK,EACR,GAAGgB;YAEJ,OAAOX,OAAO,MAAM,CAAsB,CAACc,QAAQlB;gBAC/C,MAAMmB,SAAShB,cAAcH,MAAM,IAAI;gBAEvC,MAAMoB,cAAcC,oBAAoBL,aAAaC,gBAAgBjB;gBACrE,IAAI,CAACoB,aACD,OAAOF;gBAGX,MAAMX,QAAQY,OAAO,SAAS,CAAC;oBAC3BpB;oBACAC;oBACA,OAAOgB,WAAW,CAACI,YAAY,eAAe,IAAIA,YAAY,kBAAkB,CAAC;oBACjF,UAAUH,iBACJA,cAAc,CAACG,YAAY,kBAAkB,IAAIA,YAAY,eAAe,CAAC,GAC7E;oBACNjB;gBACJ;gBAEA,IAAII,AAAUE,WAAVF,OACAW,MAAM,CAACE,YAAY,eAAe,IAAIA,YAAY,kBAAkB,CAAC,GAAGb;gBAG5E,OAAOW;YACX,GAAG,CAAC;QACR;;AACJ;AAEO,MAAMI,mBAAmBC,6BAA6B,oBAAoB,CAAC;IAC9E,gBAAgBzB;IAChB,cAAc,EAAE;AACpB"}
@@ -25,7 +25,7 @@ class TextCompressedFieldIndexImpl {
25
25
  isSearchable(field) {
26
26
  const fieldType = this.fieldRegistry.get(field.type);
27
27
  if (!fieldType?.isSearchable) return false;
28
- else if (field.settings?.disableFullTextSearch === true) return false;
28
+ if (field.settings?.disableFullTextSearch === true) return false;
29
29
  return true;
30
30
  }
31
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js","sources":["../../../../src/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.ts"],"sourcesContent":["import { CmsEntryOpenSearchFieldIndex } from \"../abstractions/CmsEntryOpenSearchFieldIndex.js\";\nimport type { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport { TextFieldTypes } from \"@webiny/api-headless-cms/features/modelBuilder/index.js\";\n\nclass TextCompressedFieldIndexImpl implements CmsEntryOpenSearchFieldIndex.Interface {\n public readonly fieldType = TextFieldTypes.COMPRESSED;\n\n public constructor(private readonly fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface) {}\n\n public toIndex(\n params: CmsEntryOpenSearchFieldIndex.ToIndex\n ): CmsEntryOpenSearchFieldIndex.ToValue {\n const { field, value } = params;\n const isSearchable = this.isSearchable(field);\n\n if (isSearchable) {\n return { value };\n }\n\n return {\n rawValue: value\n };\n }\n\n public fromIndex(params: CmsEntryOpenSearchFieldIndex.FromIndex): any {\n const { field, value, rawValue } = params;\n const isSearchable = this.isSearchable(field);\n\n if (isSearchable) {\n return value === undefined ? rawValue : value;\n }\n return rawValue === undefined ? value : rawValue;\n }\n\n private isSearchable(field: CmsModelField): boolean {\n const fieldType = this.fieldRegistry.get(field.type);\n if (!fieldType?.isSearchable) {\n return false;\n } else if (field.settings?.disableFullTextSearch === true) {\n return false;\n }\n return true;\n }\n}\n\nexport const TextCompressedFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({\n implementation: TextCompressedFieldIndexImpl,\n dependencies: [CmsModelFieldToGraphQLRegistry]\n});\n"],"names":["TextCompressedFieldIndexImpl","fieldRegistry","TextFieldTypes","params","field","value","isSearchable","rawValue","undefined","fieldType","TextCompressedFieldIndex","CmsEntryOpenSearchFieldIndex","CmsModelFieldToGraphQLRegistry"],"mappings":";;;AAKA,MAAMA;IAGF,YAAoCC,aAAuD,CAAE;aAAzDA,aAAa,GAAbA;aAFpB,SAAS,GAAGC,eAAe,UAAU;IAEyC;IAEvF,QACHC,MAA4C,EACR;QACpC,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF;QACzB,MAAMG,eAAe,IAAI,CAAC,YAAY,CAACF;QAEvC,IAAIE,cACA,OAAO;YAAED;QAAM;QAGnB,OAAO;YACH,UAAUA;QACd;IACJ;IAEO,UAAUF,MAA8C,EAAO;QAClE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEE,QAAQ,EAAE,GAAGJ;QACnC,MAAMG,eAAe,IAAI,CAAC,YAAY,CAACF;QAEvC,IAAIE,cACA,OAAOD,AAAUG,WAAVH,QAAsBE,WAAWF;QAE5C,OAAOE,AAAaC,WAAbD,WAAyBF,QAAQE;IAC5C;IAEQ,aAAaH,KAAoB,EAAW;QAChD,MAAMK,YAAY,IAAI,CAAC,aAAa,CAAC,GAAG,CAACL,MAAM,IAAI;QACnD,IAAI,CAACK,WAAW,cACZ,OAAO;aACJ,IAAIL,MAAM,QAAQ,EAAE,0BAA0B,MACjD,OAAO;QAEX,OAAO;IACX;AACJ;AAEO,MAAMM,2BAA2BC,6BAA6B,oBAAoB,CAAC;IACtF,gBAAgBX;IAChB,cAAc;QAACY;KAA+B;AAClD"}
1
+ {"version":3,"file":"features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js","sources":["../../../../src/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.ts"],"sourcesContent":["import { CmsEntryOpenSearchFieldIndex } from \"../abstractions/CmsEntryOpenSearchFieldIndex.js\";\nimport type { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport { TextFieldTypes } from \"@webiny/api-headless-cms/features/modelBuilder/index.js\";\n\nclass TextCompressedFieldIndexImpl implements CmsEntryOpenSearchFieldIndex.Interface {\n public readonly fieldType = TextFieldTypes.COMPRESSED;\n\n public constructor(private readonly fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface) {}\n\n public toIndex(\n params: CmsEntryOpenSearchFieldIndex.ToIndex\n ): CmsEntryOpenSearchFieldIndex.ToValue {\n const { field, value } = params;\n const isSearchable = this.isSearchable(field);\n\n if (isSearchable) {\n return { value };\n }\n\n return {\n rawValue: value\n };\n }\n\n public fromIndex(params: CmsEntryOpenSearchFieldIndex.FromIndex): any {\n const { field, value, rawValue } = params;\n const isSearchable = this.isSearchable(field);\n\n if (isSearchable) {\n return value === undefined ? rawValue : value;\n }\n return rawValue === undefined ? value : rawValue;\n }\n\n private isSearchable(field: CmsModelField): boolean {\n const fieldType = this.fieldRegistry.get(field.type);\n if (!fieldType?.isSearchable) {\n return false;\n } else if (field.settings?.disableFullTextSearch === true) {\n return false;\n }\n return true;\n }\n}\n\nexport const TextCompressedFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({\n implementation: TextCompressedFieldIndexImpl,\n dependencies: [CmsModelFieldToGraphQLRegistry]\n});\n"],"names":["TextCompressedFieldIndexImpl","fieldRegistry","TextFieldTypes","params","field","value","isSearchable","rawValue","undefined","fieldType","TextCompressedFieldIndex","CmsEntryOpenSearchFieldIndex","CmsModelFieldToGraphQLRegistry"],"mappings":";;;AAKA,MAAMA;IAGF,YAAoCC,aAAuD,CAAE;aAAzDA,aAAa,GAAbA;aAFpB,SAAS,GAAGC,eAAe,UAAU;IAEyC;IAEvF,QACHC,MAA4C,EACR;QACpC,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF;QACzB,MAAMG,eAAe,IAAI,CAAC,YAAY,CAACF;QAEvC,IAAIE,cACA,OAAO;YAAED;QAAM;QAGnB,OAAO;YACH,UAAUA;QACd;IACJ;IAEO,UAAUF,MAA8C,EAAO;QAClE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEE,QAAQ,EAAE,GAAGJ;QACnC,MAAMG,eAAe,IAAI,CAAC,YAAY,CAACF;QAEvC,IAAIE,cACA,OAAOD,AAAUG,WAAVH,QAAsBE,WAAWF;QAE5C,OAAOE,AAAaC,WAAbD,WAAyBF,QAAQE;IAC5C;IAEQ,aAAaH,KAAoB,EAAW;QAChD,MAAMK,YAAY,IAAI,CAAC,aAAa,CAAC,GAAG,CAACL,MAAM,IAAI;QACnD,IAAI,CAACK,WAAW,cACZ,OAAO;QACJ,IAAIL,MAAM,QAAQ,EAAE,0BAA0B,MACjD,OAAO;QAEX,OAAO;IACX;AACJ;AAEO,MAAMM,2BAA2BC,6BAA6B,oBAAoB,CAAC;IACtF,gBAAgBX;IAChB,cAAc;QAACY;KAA+B;AAClD"}
@@ -25,7 +25,7 @@ class TextEncryptedFieldIndexImpl {
25
25
  isSearchable(field) {
26
26
  const fieldType = this.fieldRegistry.get(field.type);
27
27
  if (!fieldType?.isSearchable) return false;
28
- else if (field.settings?.disableFullTextSearch === true) return false;
28
+ if (field.settings?.disableFullTextSearch === true) return false;
29
29
  return true;
30
30
  }
31
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.js","sources":["../../../../src/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.ts"],"sourcesContent":["import { CmsEntryOpenSearchFieldIndex } from \"../abstractions/CmsEntryOpenSearchFieldIndex.js\";\nimport type { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport { TextFieldTypes } from \"@webiny/api-headless-cms/features/modelBuilder/index.js\";\n\nclass TextEncryptedFieldIndexImpl implements CmsEntryOpenSearchFieldIndex.Interface {\n public readonly fieldType = TextFieldTypes.ENCRYPTED;\n\n public constructor(private readonly fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface) {}\n\n public toIndex(\n params: CmsEntryOpenSearchFieldIndex.ToIndex\n ): CmsEntryOpenSearchFieldIndex.ToValue {\n const { field, value } = params;\n const isSearchable = this.isSearchable(field);\n\n if (isSearchable) {\n return { value };\n }\n\n return {\n rawValue: value\n };\n }\n\n public fromIndex(params: CmsEntryOpenSearchFieldIndex.FromIndex): any {\n const { field, value, rawValue } = params;\n const isSearchable = this.isSearchable(field);\n\n if (isSearchable) {\n return value === undefined ? rawValue : value;\n }\n return rawValue === undefined ? value : rawValue;\n }\n\n private isSearchable(field: CmsModelField): boolean {\n const fieldType = this.fieldRegistry.get(field.type);\n if (!fieldType?.isSearchable) {\n return false;\n } else if (field.settings?.disableFullTextSearch === true) {\n return false;\n }\n return true;\n }\n}\n\nexport const TextEncryptedFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({\n implementation: TextEncryptedFieldIndexImpl,\n dependencies: [CmsModelFieldToGraphQLRegistry]\n});\n"],"names":["TextEncryptedFieldIndexImpl","fieldRegistry","TextFieldTypes","params","field","value","isSearchable","rawValue","undefined","fieldType","TextEncryptedFieldIndex","CmsEntryOpenSearchFieldIndex","CmsModelFieldToGraphQLRegistry"],"mappings":";;;AAKA,MAAMA;IAGF,YAAoCC,aAAuD,CAAE;aAAzDA,aAAa,GAAbA;aAFpB,SAAS,GAAGC,eAAe,SAAS;IAE0C;IAEvF,QACHC,MAA4C,EACR;QACpC,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF;QACzB,MAAMG,eAAe,IAAI,CAAC,YAAY,CAACF;QAEvC,IAAIE,cACA,OAAO;YAAED;QAAM;QAGnB,OAAO;YACH,UAAUA;QACd;IACJ;IAEO,UAAUF,MAA8C,EAAO;QAClE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEE,QAAQ,EAAE,GAAGJ;QACnC,MAAMG,eAAe,IAAI,CAAC,YAAY,CAACF;QAEvC,IAAIE,cACA,OAAOD,AAAUG,WAAVH,QAAsBE,WAAWF;QAE5C,OAAOE,AAAaC,WAAbD,WAAyBF,QAAQE;IAC5C;IAEQ,aAAaH,KAAoB,EAAW;QAChD,MAAMK,YAAY,IAAI,CAAC,aAAa,CAAC,GAAG,CAACL,MAAM,IAAI;QACnD,IAAI,CAACK,WAAW,cACZ,OAAO;aACJ,IAAIL,MAAM,QAAQ,EAAE,0BAA0B,MACjD,OAAO;QAEX,OAAO;IACX;AACJ;AAEO,MAAMM,0BAA0BC,6BAA6B,oBAAoB,CAAC;IACrF,gBAAgBX;IAChB,cAAc;QAACY;KAA+B;AAClD"}
1
+ {"version":3,"file":"features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.js","sources":["../../../../src/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.ts"],"sourcesContent":["import { CmsEntryOpenSearchFieldIndex } from \"../abstractions/CmsEntryOpenSearchFieldIndex.js\";\nimport type { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport { TextFieldTypes } from \"@webiny/api-headless-cms/features/modelBuilder/index.js\";\n\nclass TextEncryptedFieldIndexImpl implements CmsEntryOpenSearchFieldIndex.Interface {\n public readonly fieldType = TextFieldTypes.ENCRYPTED;\n\n public constructor(private readonly fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface) {}\n\n public toIndex(\n params: CmsEntryOpenSearchFieldIndex.ToIndex\n ): CmsEntryOpenSearchFieldIndex.ToValue {\n const { field, value } = params;\n const isSearchable = this.isSearchable(field);\n\n if (isSearchable) {\n return { value };\n }\n\n return {\n rawValue: value\n };\n }\n\n public fromIndex(params: CmsEntryOpenSearchFieldIndex.FromIndex): any {\n const { field, value, rawValue } = params;\n const isSearchable = this.isSearchable(field);\n\n if (isSearchable) {\n return value === undefined ? rawValue : value;\n }\n return rawValue === undefined ? value : rawValue;\n }\n\n private isSearchable(field: CmsModelField): boolean {\n const fieldType = this.fieldRegistry.get(field.type);\n if (!fieldType?.isSearchable) {\n return false;\n } else if (field.settings?.disableFullTextSearch === true) {\n return false;\n }\n return true;\n }\n}\n\nexport const TextEncryptedFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({\n implementation: TextEncryptedFieldIndexImpl,\n dependencies: [CmsModelFieldToGraphQLRegistry]\n});\n"],"names":["TextEncryptedFieldIndexImpl","fieldRegistry","TextFieldTypes","params","field","value","isSearchable","rawValue","undefined","fieldType","TextEncryptedFieldIndex","CmsEntryOpenSearchFieldIndex","CmsModelFieldToGraphQLRegistry"],"mappings":";;;AAKA,MAAMA;IAGF,YAAoCC,aAAuD,CAAE;aAAzDA,aAAa,GAAbA;aAFpB,SAAS,GAAGC,eAAe,SAAS;IAE0C;IAEvF,QACHC,MAA4C,EACR;QACpC,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF;QACzB,MAAMG,eAAe,IAAI,CAAC,YAAY,CAACF;QAEvC,IAAIE,cACA,OAAO;YAAED;QAAM;QAGnB,OAAO;YACH,UAAUA;QACd;IACJ;IAEO,UAAUF,MAA8C,EAAO;QAClE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEE,QAAQ,EAAE,GAAGJ;QACnC,MAAMG,eAAe,IAAI,CAAC,YAAY,CAACF;QAEvC,IAAIE,cACA,OAAOD,AAAUG,WAAVH,QAAsBE,WAAWF;QAE5C,OAAOE,AAAaC,WAAbD,WAAyBF,QAAQE;IAC5C;IAEQ,aAAaH,KAAoB,EAAW;QAChD,MAAMK,YAAY,IAAI,CAAC,aAAa,CAAC,GAAG,CAACL,MAAM,IAAI;QACnD,IAAI,CAACK,WAAW,cACZ,OAAO;QACJ,IAAIL,MAAM,QAAQ,EAAE,0BAA0B,MACjD,OAAO;QAEX,OAAO;IACX;AACJ;AAEO,MAAMM,0BAA0BC,6BAA6B,oBAAoB,CAAC;IACrF,gBAAgBX;IAChB,cAAc;QAACY;KAA+B;AAClD"}
@@ -8,7 +8,7 @@ const getKey = (params)=>{
8
8
  field,
9
9
  value
10
10
  });
11
- else if (keys.length > 1) throw new WebinyError(`Searchable JSON field "${field.fieldId}" can only have one key.`, "MULTIPLE_KEYS_IN_SEARCHABLE_JSON_FIELD", {
11
+ if (keys.length > 1) throw new WebinyError(`Searchable JSON field "${field.fieldId}" can only have one key.`, "MULTIPLE_KEYS_IN_SEARCHABLE_JSON_FIELD", {
12
12
  field,
13
13
  value,
14
14
  keys
@@ -1 +1 @@
1
- {"version":3,"file":"features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js","sources":["../../../../src/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsEntryOpenSearchValueSearch } from \"../abstractions/CmsEntryOpenSearchValueSearch.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport { NoValueContainer } from \"~/values/NoValueContainer.js\";\n\ninterface IGetKeyParams {\n field: CmsModelField;\n value: {\n [key: string]: any;\n };\n}\n\nconst getKey = (params: IGetKeyParams): string => {\n const { field, value } = params;\n const keys = Object.keys(value);\n if (keys.length === 0) {\n throw new WebinyError(\n `Searchable JSON field \"${field.fieldId}\" cannot be empty.`,\n \"EMPTY_SEARCHABLE_JSON_FIELD\",\n {\n field,\n value\n }\n );\n } else if (keys.length > 1) {\n throw new WebinyError(\n `Searchable JSON field \"${field.fieldId}\" can only have one key.`,\n \"MULTIPLE_KEYS_IN_SEARCHABLE_JSON_FIELD\",\n {\n field,\n value,\n keys\n }\n );\n }\n return keys[0];\n};\n\nclass SearchableJsonSearchImpl implements CmsEntryOpenSearchValueSearch.Interface {\n public readonly fieldType = \"searchable-json\";\n\n public transform(params: CmsEntryOpenSearchValueSearch.Transform): any {\n const { value } = params;\n\n if (NoValueContainer.is(value)) {\n return null;\n }\n\n const key = getKey(params);\n return value[key] || null;\n }\n\n public createPath(params: CmsEntryOpenSearchValueSearch.CreatePath): string | null {\n const { field } = params;\n\n if (NoValueContainer.is(params.originalValue)) {\n return `${field.storageId}.unknown`;\n }\n\n const key = getKey({\n field,\n value: params.originalValue\n });\n\n return `${field.storageId}.${key}`;\n }\n}\n\nexport const SearchableJsonSearch = CmsEntryOpenSearchValueSearch.createImplementation({\n implementation: SearchableJsonSearchImpl,\n dependencies: []\n});\n"],"names":["getKey","params","field","value","keys","Object","WebinyError","SearchableJsonSearchImpl","NoValueContainer","key","SearchableJsonSearch","CmsEntryOpenSearchValueSearch"],"mappings":";;;AAYA,MAAMA,SAAS,CAACC;IACZ,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF;IACzB,MAAMG,OAAOC,OAAO,IAAI,CAACF;IACzB,IAAIC,AAAgB,MAAhBA,KAAK,MAAM,EACX,MAAM,IAAIE,YACN,CAAC,uBAAuB,EAAEJ,MAAM,OAAO,CAAC,kBAAkB,CAAC,EAC3D,+BACA;QACIA;QACAC;IACJ;SAED,IAAIC,KAAK,MAAM,GAAG,GACrB,MAAM,IAAIE,YACN,CAAC,uBAAuB,EAAEJ,MAAM,OAAO,CAAC,wBAAwB,CAAC,EACjE,0CACA;QACIA;QACAC;QACAC;IACJ;IAGR,OAAOA,IAAI,CAAC,EAAE;AAClB;AAEA,MAAMG;IAGK,UAAUN,MAA+C,EAAO;QACnE,MAAM,EAAEE,KAAK,EAAE,GAAGF;QAElB,IAAIO,iBAAiB,EAAE,CAACL,QACpB,OAAO;QAGX,MAAMM,MAAMT,OAAOC;QACnB,OAAOE,KAAK,CAACM,IAAI,IAAI;IACzB;IAEO,WAAWR,MAAgD,EAAiB;QAC/E,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAElB,IAAIO,iBAAiB,EAAE,CAACP,OAAO,aAAa,GACxC,OAAO,GAAGC,MAAM,SAAS,CAAC,QAAQ,CAAC;QAGvC,MAAMO,MAAMT,OAAO;YACfE;YACA,OAAOD,OAAO,aAAa;QAC/B;QAEA,OAAO,GAAGC,MAAM,SAAS,CAAC,CAAC,EAAEO,KAAK;IACtC;;aA1BgB,SAAS,GAAG;;AA2BhC;AAEO,MAAMC,uBAAuBC,8BAA8B,oBAAoB,CAAC;IACnF,gBAAgBJ;IAChB,cAAc,EAAE;AACpB"}
1
+ {"version":3,"file":"features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js","sources":["../../../../src/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsEntryOpenSearchValueSearch } from \"../abstractions/CmsEntryOpenSearchValueSearch.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport { NoValueContainer } from \"~/values/NoValueContainer.js\";\n\ninterface IGetKeyParams {\n field: CmsModelField;\n value: {\n [key: string]: any;\n };\n}\n\nconst getKey = (params: IGetKeyParams): string => {\n const { field, value } = params;\n const keys = Object.keys(value);\n if (keys.length === 0) {\n throw new WebinyError(\n `Searchable JSON field \"${field.fieldId}\" cannot be empty.`,\n \"EMPTY_SEARCHABLE_JSON_FIELD\",\n {\n field,\n value\n }\n );\n } else if (keys.length > 1) {\n throw new WebinyError(\n `Searchable JSON field \"${field.fieldId}\" can only have one key.`,\n \"MULTIPLE_KEYS_IN_SEARCHABLE_JSON_FIELD\",\n {\n field,\n value,\n keys\n }\n );\n }\n return keys[0];\n};\n\nclass SearchableJsonSearchImpl implements CmsEntryOpenSearchValueSearch.Interface {\n public readonly fieldType = \"searchable-json\";\n\n public transform(params: CmsEntryOpenSearchValueSearch.Transform): any {\n const { value } = params;\n\n if (NoValueContainer.is(value)) {\n return null;\n }\n\n const key = getKey(params);\n return value[key] || null;\n }\n\n public createPath(params: CmsEntryOpenSearchValueSearch.CreatePath): string | null {\n const { field } = params;\n\n if (NoValueContainer.is(params.originalValue)) {\n return `${field.storageId}.unknown`;\n }\n\n const key = getKey({\n field,\n value: params.originalValue\n });\n\n return `${field.storageId}.${key}`;\n }\n}\n\nexport const SearchableJsonSearch = CmsEntryOpenSearchValueSearch.createImplementation({\n implementation: SearchableJsonSearchImpl,\n dependencies: []\n});\n"],"names":["getKey","params","field","value","keys","Object","WebinyError","SearchableJsonSearchImpl","NoValueContainer","key","SearchableJsonSearch","CmsEntryOpenSearchValueSearch"],"mappings":";;;AAYA,MAAMA,SAAS,CAACC;IACZ,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF;IACzB,MAAMG,OAAOC,OAAO,IAAI,CAACF;IACzB,IAAIC,AAAgB,MAAhBA,KAAK,MAAM,EACX,MAAM,IAAIE,YACN,CAAC,uBAAuB,EAAEJ,MAAM,OAAO,CAAC,kBAAkB,CAAC,EAC3D,+BACA;QACIA;QACAC;IACJ;IAED,IAAIC,KAAK,MAAM,GAAG,GACrB,MAAM,IAAIE,YACN,CAAC,uBAAuB,EAAEJ,MAAM,OAAO,CAAC,wBAAwB,CAAC,EACjE,0CACA;QACIA;QACAC;QACAC;IACJ;IAGR,OAAOA,IAAI,CAAC,EAAE;AAClB;AAEA,MAAMG;IAGK,UAAUN,MAA+C,EAAO;QACnE,MAAM,EAAEE,KAAK,EAAE,GAAGF;QAElB,IAAIO,iBAAiB,EAAE,CAACL,QACpB,OAAO;QAGX,MAAMM,MAAMT,OAAOC;QACnB,OAAOE,KAAK,CAACM,IAAI,IAAI;IACzB;IAEO,WAAWR,MAAgD,EAAiB;QAC/E,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAElB,IAAIO,iBAAiB,EAAE,CAACP,OAAO,aAAa,GACxC,OAAO,GAAGC,MAAM,SAAS,CAAC,QAAQ,CAAC;QAGvC,MAAMO,MAAMT,OAAO;YACfE;YACA,OAAOD,OAAO,aAAa;QAC/B;QAEA,OAAO,GAAGC,MAAM,SAAS,CAAC,CAAC,EAAEO,KAAK;IACtC;;aA1BgB,SAAS,GAAG;;AA2BhC;AAEO,MAAMC,uBAAuBC,8BAA8B,oBAAoB,CAAC;IACnF,gBAAgBJ;IAChB,cAAc,EAAE;AACpB"}
@@ -1,11 +1,11 @@
1
1
  const fieldIdentifier_hasOwnProperty = (values = {}, property)=>{
2
2
  if (!values) return false;
3
- else if (values.hasOwnProperty) return values.hasOwnProperty(property);
3
+ if (values.hasOwnProperty) return values.hasOwnProperty(property);
4
4
  return void 0 !== values[property];
5
5
  };
6
6
  const getFieldIdentifier = (values, field)=>{
7
7
  if (field.storageId && fieldIdentifier_hasOwnProperty(values, field.storageId)) return field.storageId;
8
- else if (fieldIdentifier_hasOwnProperty(values, field.fieldId)) return field.fieldId;
8
+ if (fieldIdentifier_hasOwnProperty(values, field.fieldId)) return field.fieldId;
9
9
  };
10
10
  const getFieldIdentifiers = (values, rawValues, field)=>{
11
11
  let valueIdentifier = getFieldIdentifier(values, field);
@@ -1 +1 @@
1
- {"version":3,"file":"helpers/fieldIdentifier.js","sources":["../../src/helpers/fieldIdentifier.ts"],"sourcesContent":["import type { CmsEntryValues, CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\n\nconst hasOwnProperty = (\n values: CmsEntryValues | null | undefined = {},\n property: string\n): boolean => {\n if (!values) {\n return false;\n } else if (values.hasOwnProperty) {\n return values.hasOwnProperty(property);\n }\n return values[property] !== undefined;\n};\n\nexport const getFieldIdentifier = (\n values: CmsEntryValues | null | undefined,\n field: CmsModelField\n): string | undefined => {\n if (field.storageId && hasOwnProperty(values, field.storageId)) {\n return field.storageId;\n } else if (hasOwnProperty(values, field.fieldId)) {\n return field.fieldId;\n }\n return undefined;\n};\n\nexport const getFieldIdentifiers = (\n values: CmsEntryValues,\n rawValues: CmsEntryValues | null | undefined,\n field: CmsModelField\n) => {\n let valueIdentifier = getFieldIdentifier(values, field);\n let rawValueIdentifier = getFieldIdentifier(rawValues, field);\n if (!valueIdentifier && !rawValueIdentifier) {\n return null;\n }\n if (!valueIdentifier) {\n valueIdentifier = rawValueIdentifier as string;\n }\n if (!rawValueIdentifier) {\n rawValueIdentifier = valueIdentifier as string;\n }\n return {\n valueIdentifier,\n rawValueIdentifier\n };\n};\n"],"names":["hasOwnProperty","values","property","undefined","getFieldIdentifier","field","getFieldIdentifiers","rawValues","valueIdentifier","rawValueIdentifier"],"mappings":"AAEA,MAAMA,iCAAiB,CACnBC,SAA4C,CAAC,CAAC,EAC9CC;IAEA,IAAI,CAACD,QACD,OAAO;SACJ,IAAIA,OAAO,cAAc,EAC5B,OAAOA,OAAO,cAAc,CAACC;IAEjC,OAAOD,AAAqBE,WAArBF,MAAM,CAACC,SAAS;AAC3B;AAEO,MAAME,qBAAqB,CAC9BH,QACAI;IAEA,IAAIA,MAAM,SAAS,IAAIL,+BAAeC,QAAQI,MAAM,SAAS,GACzD,OAAOA,MAAM,SAAS;SACnB,IAAIL,+BAAeC,QAAQI,MAAM,OAAO,GAC3C,OAAOA,MAAM,OAAO;AAG5B;AAEO,MAAMC,sBAAsB,CAC/BL,QACAM,WACAF;IAEA,IAAIG,kBAAkBJ,mBAAmBH,QAAQI;IACjD,IAAII,qBAAqBL,mBAAmBG,WAAWF;IACvD,IAAI,CAACG,mBAAmB,CAACC,oBACrB,OAAO;IAEX,IAAI,CAACD,iBACDA,kBAAkBC;IAEtB,IAAI,CAACA,oBACDA,qBAAqBD;IAEzB,OAAO;QACHA;QACAC;IACJ;AACJ"}
1
+ {"version":3,"file":"helpers/fieldIdentifier.js","sources":["../../src/helpers/fieldIdentifier.ts"],"sourcesContent":["import type { CmsEntryValues, CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\n\nconst hasOwnProperty = (\n values: CmsEntryValues | null | undefined = {},\n property: string\n): boolean => {\n if (!values) {\n return false;\n } else if (values.hasOwnProperty) {\n return values.hasOwnProperty(property);\n }\n return values[property] !== undefined;\n};\n\nexport const getFieldIdentifier = (\n values: CmsEntryValues | null | undefined,\n field: CmsModelField\n): string | undefined => {\n if (field.storageId && hasOwnProperty(values, field.storageId)) {\n return field.storageId;\n } else if (hasOwnProperty(values, field.fieldId)) {\n return field.fieldId;\n }\n return undefined;\n};\n\nexport const getFieldIdentifiers = (\n values: CmsEntryValues,\n rawValues: CmsEntryValues | null | undefined,\n field: CmsModelField\n) => {\n let valueIdentifier = getFieldIdentifier(values, field);\n let rawValueIdentifier = getFieldIdentifier(rawValues, field);\n if (!valueIdentifier && !rawValueIdentifier) {\n return null;\n }\n if (!valueIdentifier) {\n valueIdentifier = rawValueIdentifier as string;\n }\n if (!rawValueIdentifier) {\n rawValueIdentifier = valueIdentifier as string;\n }\n return {\n valueIdentifier,\n rawValueIdentifier\n };\n};\n"],"names":["hasOwnProperty","values","property","undefined","getFieldIdentifier","field","getFieldIdentifiers","rawValues","valueIdentifier","rawValueIdentifier"],"mappings":"AAEA,MAAMA,iCAAiB,CACnBC,SAA4C,CAAC,CAAC,EAC9CC;IAEA,IAAI,CAACD,QACD,OAAO;IACJ,IAAIA,OAAO,cAAc,EAC5B,OAAOA,OAAO,cAAc,CAACC;IAEjC,OAAOD,AAAqBE,WAArBF,MAAM,CAACC,SAAS;AAC3B;AAEO,MAAME,qBAAqB,CAC9BH,QACAI;IAEA,IAAIA,MAAM,SAAS,IAAIL,+BAAeC,QAAQI,MAAM,SAAS,GACzD,OAAOA,MAAM,SAAS;IACnB,IAAIL,+BAAeC,QAAQI,MAAM,OAAO,GAC3C,OAAOA,MAAM,OAAO;AAG5B;AAEO,MAAMC,sBAAsB,CAC/BL,QACAM,WACAF;IAEA,IAAIG,kBAAkBJ,mBAAmBH,QAAQI;IACjD,IAAII,qBAAqBL,mBAAmBG,WAAWF;IACvD,IAAI,CAACG,mBAAmB,CAACC,oBACrB,OAAO;IAEX,IAAI,CAACD,iBACDA,kBAAkBC;IAEtB,IAAI,CAACA,oBACDA,qBAAqBD;IAEzB,OAAO;QACHA;QACAC;IACJ;AACJ"}
@@ -1,7 +1,7 @@
1
1
  const assignMinimumShouldMatchToQuery = ({ query, value = 1 })=>{
2
2
  if (!Array.isArray(query.should)) return;
3
- else if (0 === query.should.length) return;
4
- else if (query.minimum_should_match) return;
3
+ if (0 === query.should.length) return;
4
+ if (query.minimum_should_match) return;
5
5
  query.minimum_should_match = value > 0 ? value : 1;
6
6
  };
7
7
  export { assignMinimumShouldMatchToQuery };
@@ -1 +1 @@
1
- {"version":3,"file":"operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js","sources":["../../../../src/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.ts"],"sourcesContent":["import type { QueryDslBoolQuery as BoolQueryConfig } from \"@webiny/api-opensearch/types.js\";\n\n/**\n * This function will assign a minimum_should_match for the query if conditions are met:\n * * should is an array\n * * it is not empty\n * * minimum_should_match is not already set\n *\n *\n * By the default we set it to 1 as we want at least one OR condition to produce results.\n *\n * Users can modify minimum_should_match value via the body or query modification plugins.\n */\ninterface Params {\n query: BoolQueryConfig;\n value?: number;\n}\nexport const assignMinimumShouldMatchToQuery = ({ query, value = 1 }: Params): void => {\n if (!Array.isArray(query.should)) {\n return;\n } else if (query.should.length === 0) {\n return;\n } else if (query.minimum_should_match) {\n return;\n }\n query.minimum_should_match = value > 0 ? value : 1;\n};\n"],"names":["assignMinimumShouldMatchToQuery","query","value","Array"],"mappings":"AAiBO,MAAMA,kCAAkC,CAAC,EAAEC,KAAK,EAAEC,QAAQ,CAAC,EAAU;IACxE,IAAI,CAACC,MAAM,OAAO,CAACF,MAAM,MAAM,GAC3B;SACG,IAAIA,AAAwB,MAAxBA,MAAM,MAAM,CAAC,MAAM,EAC1B;SACG,IAAIA,MAAM,oBAAoB,EACjC;IAEJA,MAAM,oBAAoB,GAAGC,QAAQ,IAAIA,QAAQ;AACrD"}
1
+ {"version":3,"file":"operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js","sources":["../../../../src/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.ts"],"sourcesContent":["import type { QueryDslBoolQuery as BoolQueryConfig } from \"@webiny/api-opensearch/types.js\";\n\n/**\n * This function will assign a minimum_should_match for the query if conditions are met:\n * * should is an array\n * * it is not empty\n * * minimum_should_match is not already set\n *\n *\n * By the default we set it to 1 as we want at least one OR condition to produce results.\n *\n * Users can modify minimum_should_match value via the body or query modification plugins.\n */\ninterface Params {\n query: BoolQueryConfig;\n value?: number;\n}\nexport const assignMinimumShouldMatchToQuery = ({ query, value = 1 }: Params): void => {\n if (!Array.isArray(query.should)) {\n return;\n } else if (query.should.length === 0) {\n return;\n } else if (query.minimum_should_match) {\n return;\n }\n query.minimum_should_match = value > 0 ? value : 1;\n};\n"],"names":["assignMinimumShouldMatchToQuery","query","value","Array"],"mappings":"AAiBO,MAAMA,kCAAkC,CAAC,EAAEC,KAAK,EAAEC,QAAQ,CAAC,EAAU;IACxE,IAAI,CAACC,MAAM,OAAO,CAACF,MAAM,MAAM,GAC3B;IACG,IAAIA,AAAwB,MAAxBA,MAAM,MAAM,CAAC,MAAM,EAC1B;IACG,IAAIA,MAAM,oBAAoB,EACjC;IAEJA,MAAM,oBAAoB,GAAGC,QAAQ,IAAIA,QAAQ;AACrD"}
@@ -1,4 +1,5 @@
1
- import type { PluginsContainer } from "@webiny/plugins";
1
+ import type { OpenSearchQueryBuilderOperatorRegistry } from "@webiny/api-opensearch/exports/api/opensearch.js";
2
+ import type { OpenSearchFieldFactory } from "@webiny/api-opensearch/exports/api/opensearch.js";
2
3
  import type { CmsEntryListParams, CmsEntryListWhere, CmsModel } from "@webiny/api-headless-cms/types/index.js";
3
4
  import type { CmsEntryOpenSearchBodyModifier } from "../../../features/CmsEntryOpenSearchBodyModifier/index.js";
4
5
  import type { CmsEntryOpenSearchSortModifier } from "../../../features/CmsEntryOpenSearchSortModifier/index.js";
@@ -10,7 +11,7 @@ import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/feature
10
11
  import { CmsEntryOpenSearchFieldIndexRegistry } from "../../../features/CmsEntryOpenSearchFieldIndex/index.js";
11
12
  import type { CmsEntryOpenSearchFilterRegistry } from "../../../features/CmsEntryOpenSearchFilter/index.js";
12
13
  interface ICreateElasticsearchBodyParams {
13
- plugins: PluginsContainer;
14
+ operatorRegistry: OpenSearchQueryBuilderOperatorRegistry.Interface;
14
15
  model: CmsModel;
15
16
  shared: boolean;
16
17
  fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;
@@ -21,10 +22,11 @@ interface ICreateElasticsearchBodyParams {
21
22
  valueSearchRegistry: CmsEntryOpenSearchValueSearchRegistry.Interface;
22
23
  fullTextSearches: CmsEntryOpenSearchFullTextSearch.Interface[];
23
24
  filterRegistry: CmsEntryOpenSearchFilterRegistry.Interface;
25
+ fieldFactory: OpenSearchFieldFactory.Interface;
24
26
  params: Omit<CmsEntryListParams, "where" | "after"> & {
25
27
  where: CmsEntryListWhere;
26
28
  after?: PrimitiveValue[];
27
29
  };
28
30
  }
29
- export declare const createElasticsearchBody: ({ plugins, model, shared, params, fieldRegistry, fieldIndexRegistry, bodyModifiers, sortModifiers, queryModifiers, valueSearchRegistry, fullTextSearches, filterRegistry }: ICreateElasticsearchBodyParams) => SearchBody;
31
+ export declare const createElasticsearchBody: ({ operatorRegistry, model, shared, params, fieldRegistry, fieldIndexRegistry, bodyModifiers, sortModifiers, queryModifiers, valueSearchRegistry, fullTextSearches, filterRegistry, fieldFactory }: ICreateElasticsearchBodyParams) => SearchBody;
30
32
  export {};
@@ -5,7 +5,7 @@ import { applyFullTextSearch } from "./fullTextSearch.js";
5
5
  import { createElasticsearchSort } from "./sort.js";
6
6
  import { createExecFiltering } from "./filtering/index.js";
7
7
  import { assignMinimumShouldMatchToQuery } from "./assignMinimumShouldMatchToQuery.js";
8
- const createElasticsearchBody = ({ plugins, model, shared, params, fieldRegistry, fieldIndexRegistry, bodyModifiers, sortModifiers, queryModifiers, valueSearchRegistry, fullTextSearches, filterRegistry })=>{
8
+ const createElasticsearchBody = ({ operatorRegistry, model, shared, params, fieldRegistry, fieldIndexRegistry, bodyModifiers, sortModifiers, queryModifiers, valueSearchRegistry, fullTextSearches, filterRegistry, fieldFactory })=>{
9
9
  const { fields, search: term, where, sort: initialSort, after, limit } = params;
10
10
  const modelFields = createModelFields({
11
11
  model,
@@ -35,7 +35,7 @@ const createElasticsearchBody = ({ plugins, model, shared, params, fieldRegistry
35
35
  const execFiltering = createExecFiltering({
36
36
  model,
37
37
  fields: modelFields,
38
- plugins,
38
+ operatorRegistry,
39
39
  valueSearchRegistry,
40
40
  filterRegistry
41
41
  });
@@ -52,7 +52,8 @@ const createElasticsearchBody = ({ plugins, model, shared, params, fieldRegistry
52
52
  sort: initialSort,
53
53
  modelFields,
54
54
  model,
55
- valueSearchRegistry
55
+ valueSearchRegistry,
56
+ fieldFactory
56
57
  });
57
58
  for (const modifier of applicableSortModifiers)modifier.modifySort({
58
59
  sort,
@@ -1 +1 @@
1
- {"version":3,"file":"operations/entry/elasticsearch/body.js","sources":["../../../../src/operations/entry/elasticsearch/body.ts"],"sourcesContent":["import type { PluginsContainer } from \"@webiny/plugins\";\nimport type {\n CmsEntryListParams,\n CmsEntryListWhere,\n CmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { createModelFields } from \"./fields.js\";\nimport { createFullTextSearchFields } from \"./fullTextSearchFields.js\";\nimport { createInitialQuery } from \"./initialQuery.js\";\nimport { applyFullTextSearch } from \"./fullTextSearch.js\";\nimport type { CmsEntryOpenSearchBodyModifier } from \"~/features/CmsEntryOpenSearchBodyModifier/index.js\";\nimport type { CmsEntryOpenSearchSortModifier } from \"~/features/CmsEntryOpenSearchSortModifier/index.js\";\nimport type { CmsEntryOpenSearchQueryModifier } from \"~/features/CmsEntryOpenSearchQueryModifier/index.js\";\nimport type { CmsEntryOpenSearchValueSearchRegistry } from \"~/features/CmsEntryOpenSearchValueSearch/index.js\";\nimport type { CmsEntryOpenSearchFullTextSearch } from \"~/features/CmsEntryOpenSearchFullTextSearch/index.js\";\nimport { createElasticsearchSort } from \"./sort.js\";\nimport type {\n PrimitiveValue,\n QueryDslBoolQuery as BoolQueryConfig,\n SearchBody\n} from \"@webiny/api-opensearch/types.js\";\nimport { createExecFiltering } from \"./filtering/index.js\";\nimport { assignMinimumShouldMatchToQuery } from \"./assignMinimumShouldMatchToQuery.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/features/graphql/index.js\";\nimport { CmsEntryOpenSearchFieldIndexRegistry } from \"~/features/CmsEntryOpenSearchFieldIndex/index.js\";\nimport type { CmsEntryOpenSearchFilterRegistry } from \"~/features/CmsEntryOpenSearchFilter/index.js\";\n\ninterface ICreateElasticsearchBodyParams {\n plugins: PluginsContainer;\n model: CmsModel;\n shared: boolean;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface;\n bodyModifiers: CmsEntryOpenSearchBodyModifier.Interface[];\n sortModifiers: CmsEntryOpenSearchSortModifier.Interface[];\n queryModifiers: CmsEntryOpenSearchQueryModifier.Interface[];\n valueSearchRegistry: CmsEntryOpenSearchValueSearchRegistry.Interface;\n fullTextSearches: CmsEntryOpenSearchFullTextSearch.Interface[];\n filterRegistry: CmsEntryOpenSearchFilterRegistry.Interface;\n params: Omit<CmsEntryListParams, \"where\" | \"after\"> & {\n where: CmsEntryListWhere;\n after?: PrimitiveValue[];\n };\n}\nexport const createElasticsearchBody = ({\n plugins,\n model,\n shared,\n params,\n fieldRegistry,\n fieldIndexRegistry,\n bodyModifiers,\n sortModifiers,\n queryModifiers,\n valueSearchRegistry,\n fullTextSearches,\n filterRegistry\n}: ICreateElasticsearchBodyParams): SearchBody => {\n const { fields, search: term, where, sort: initialSort, after, limit } = params;\n /**\n * We need the model fields constructed as a key -> field value, so we do not need to iterate through array when we require some field.\n */\n const modelFields = createModelFields({\n model,\n fieldRegistry,\n fieldIndexRegistry\n });\n\n /**\n * Filter query modifiers applicable to this model.\n */\n const applicableQueryModifiers = queryModifiers.filter(m => {\n return !m.modelId || m.modelId === model.modelId;\n });\n /**\n * Filter sort modifiers applicable to this model.\n */\n const applicableSortModifiers = sortModifiers.filter(\n m => !m.modelId || m.modelId === model.modelId\n );\n /**\n * Filter body modifiers applicable to this model.\n */\n const applicableBodyModifiers = bodyModifiers.filter(m => {\n return !m.modelId || m.modelId === model.modelId;\n });\n /**\n * We need the fields which we can search through via the full text search.\n *\n */\n const fullTextSearchFields = createFullTextSearchFields({\n fields: modelFields,\n term,\n targets: fields\n });\n /**\n * The initial elasticsearch query where we attach some default conditions we always need.\n */\n const query = createInitialQuery({\n where,\n model,\n shared\n });\n /**\n * Apply the full text search, if term is set.\n */\n applyFullTextSearch({\n model,\n fullTextSearches,\n query,\n term,\n fields: fullTextSearchFields\n });\n\n const execFiltering = createExecFiltering({\n model,\n fields: modelFields,\n plugins,\n valueSearchRegistry,\n filterRegistry\n });\n\n execFiltering({\n where,\n query\n });\n\n for (const modifier of applicableQueryModifiers) {\n modifier.modifyQuery({ query, model, where });\n }\n\n const sort = createElasticsearchSort({\n sort: initialSort,\n modelFields,\n model,\n valueSearchRegistry\n });\n\n for (const modifier of applicableSortModifiers) {\n modifier.modifySort({\n sort,\n model\n });\n }\n\n const boolQuery: BoolQueryConfig = {\n must: query.must.length > 0 ? query.must : undefined,\n must_not: query.must_not.length > 0 ? query.must_not : undefined,\n should: query.should.length > 0 ? query.should : undefined,\n filter: query.filter.length > 0 ? query.filter : undefined\n };\n\n assignMinimumShouldMatchToQuery({\n query: boolQuery\n });\n\n const body: SearchBody = {\n query: {\n bool: boolQuery\n },\n sort,\n size: (limit || 0) + 1,\n search_after: after,\n track_total_hits: true\n };\n\n for (const modifier of applicableBodyModifiers) {\n modifier.modifyBody({\n body,\n model,\n where\n });\n }\n\n return body;\n};\n"],"names":["createElasticsearchBody","plugins","model","shared","params","fieldRegistry","fieldIndexRegistry","bodyModifiers","sortModifiers","queryModifiers","valueSearchRegistry","fullTextSearches","filterRegistry","fields","term","where","initialSort","after","limit","modelFields","createModelFields","applicableQueryModifiers","m","applicableSortModifiers","applicableBodyModifiers","fullTextSearchFields","createFullTextSearchFields","query","createInitialQuery","applyFullTextSearch","execFiltering","createExecFiltering","modifier","sort","createElasticsearchSort","boolQuery","undefined","assignMinimumShouldMatchToQuery","body"],"mappings":";;;;;;;AA4CO,MAAMA,0BAA0B,CAAC,EACpCC,OAAO,EACPC,KAAK,EACLC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,kBAAkB,EAClBC,aAAa,EACbC,aAAa,EACbC,cAAc,EACdC,mBAAmB,EACnBC,gBAAgB,EAChBC,cAAc,EACe;IAC7B,MAAM,EAAEC,MAAM,EAAE,QAAQC,IA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AM,GAAGS;QACjD,QAAQT,MAAM,MAAM,CAAC,MAAM,GAAG,IAAIA,MAAM,MAAM,GAAGS;IACrD;IAEAC,gCAAgC;QAC5B,OAAOF;IACX;IAEA,MAAMG,OAAmB;QACrB,OAAO;YACH,MAAMH;QACV;QACAF;QACA,MAAOf,AAAAA,CAAAA,SAAS,KAAK;QACrB,cAAcD;QACd,kBAAkB;IACtB;IAEA,KAAK,MAAMe,YAAYR,wBACnBQ,SAAS,UAAU,CAAC;QAChBM;QACApC;QACAa;IACJ;IAGJ,OAAOuB;AACX"}
1
+ {"version":3,"file":"operations/entry/elasticsearch/body.js","sources":["../../../../src/operations/entry/elasticsearch/body.ts"],"sourcesContent":["import type { OpenSearchQueryBuilderOperatorRegistry } from \"@webiny/api-opensearch/exports/api/opensearch.js\";\nimport type { OpenSearchFieldFactory } from \"@webiny/api-opensearch/exports/api/opensearch.js\";\nimport type {\n CmsEntryListParams,\n CmsEntryListWhere,\n CmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { createModelFields } from \"./fields.js\";\nimport { createFullTextSearchFields } from \"./fullTextSearchFields.js\";\nimport { createInitialQuery } from \"./initialQuery.js\";\nimport { applyFullTextSearch } from \"./fullTextSearch.js\";\nimport type { CmsEntryOpenSearchBodyModifier } from \"~/features/CmsEntryOpenSearchBodyModifier/index.js\";\nimport type { CmsEntryOpenSearchSortModifier } from \"~/features/CmsEntryOpenSearchSortModifier/index.js\";\nimport type { CmsEntryOpenSearchQueryModifier } from \"~/features/CmsEntryOpenSearchQueryModifier/index.js\";\nimport type { CmsEntryOpenSearchValueSearchRegistry } from \"~/features/CmsEntryOpenSearchValueSearch/index.js\";\nimport type { CmsEntryOpenSearchFullTextSearch } from \"~/features/CmsEntryOpenSearchFullTextSearch/index.js\";\nimport { createElasticsearchSort } from \"./sort.js\";\nimport type {\n PrimitiveValue,\n QueryDslBoolQuery as BoolQueryConfig,\n SearchBody\n} from \"@webiny/api-opensearch/types.js\";\nimport { createExecFiltering } from \"./filtering/index.js\";\nimport { assignMinimumShouldMatchToQuery } from \"./assignMinimumShouldMatchToQuery.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/features/graphql/index.js\";\nimport { CmsEntryOpenSearchFieldIndexRegistry } from \"~/features/CmsEntryOpenSearchFieldIndex/index.js\";\nimport type { CmsEntryOpenSearchFilterRegistry } from \"~/features/CmsEntryOpenSearchFilter/index.js\";\n\ninterface ICreateElasticsearchBodyParams {\n operatorRegistry: OpenSearchQueryBuilderOperatorRegistry.Interface;\n model: CmsModel;\n shared: boolean;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface;\n bodyModifiers: CmsEntryOpenSearchBodyModifier.Interface[];\n sortModifiers: CmsEntryOpenSearchSortModifier.Interface[];\n queryModifiers: CmsEntryOpenSearchQueryModifier.Interface[];\n valueSearchRegistry: CmsEntryOpenSearchValueSearchRegistry.Interface;\n fullTextSearches: CmsEntryOpenSearchFullTextSearch.Interface[];\n filterRegistry: CmsEntryOpenSearchFilterRegistry.Interface;\n fieldFactory: OpenSearchFieldFactory.Interface;\n params: Omit<CmsEntryListParams, \"where\" | \"after\"> & {\n where: CmsEntryListWhere;\n after?: PrimitiveValue[];\n };\n}\nexport const createElasticsearchBody = ({\n operatorRegistry,\n model,\n shared,\n params,\n fieldRegistry,\n fieldIndexRegistry,\n bodyModifiers,\n sortModifiers,\n queryModifiers,\n valueSearchRegistry,\n fullTextSearches,\n filterRegistry,\n fieldFactory\n}: ICreateElasticsearchBodyParams): SearchBody => {\n const { fields, search: term, where, sort: initialSort, after, limit } = params;\n /**\n * We need the model fields constructed as a key -> field value, so we do not need to iterate through array when we require some field.\n */\n const modelFields = createModelFields({\n model,\n fieldRegistry,\n fieldIndexRegistry\n });\n\n /**\n * Filter query modifiers applicable to this model.\n */\n const applicableQueryModifiers = queryModifiers.filter(m => {\n return !m.modelId || m.modelId === model.modelId;\n });\n /**\n * Filter sort modifiers applicable to this model.\n */\n const applicableSortModifiers = sortModifiers.filter(\n m => !m.modelId || m.modelId === model.modelId\n );\n /**\n * Filter body modifiers applicable to this model.\n */\n const applicableBodyModifiers = bodyModifiers.filter(m => {\n return !m.modelId || m.modelId === model.modelId;\n });\n /**\n * We need the fields which we can search through via the full text search.\n *\n */\n const fullTextSearchFields = createFullTextSearchFields({\n fields: modelFields,\n term,\n targets: fields\n });\n /**\n * The initial elasticsearch query where we attach some default conditions we always need.\n */\n const query = createInitialQuery({\n where,\n model,\n shared\n });\n /**\n * Apply the full text search, if term is set.\n */\n applyFullTextSearch({\n model,\n fullTextSearches,\n query,\n term,\n fields: fullTextSearchFields\n });\n\n const execFiltering = createExecFiltering({\n model,\n fields: modelFields,\n operatorRegistry,\n valueSearchRegistry,\n filterRegistry\n });\n\n execFiltering({\n where,\n query\n });\n\n for (const modifier of applicableQueryModifiers) {\n modifier.modifyQuery({ query, model, where });\n }\n\n const sort = createElasticsearchSort({\n sort: initialSort,\n modelFields,\n model,\n valueSearchRegistry,\n fieldFactory\n });\n\n for (const modifier of applicableSortModifiers) {\n modifier.modifySort({\n sort,\n model\n });\n }\n\n const boolQuery: BoolQueryConfig = {\n must: query.must.length > 0 ? query.must : undefined,\n must_not: query.must_not.length > 0 ? query.must_not : undefined,\n should: query.should.length > 0 ? query.should : undefined,\n filter: query.filter.length > 0 ? query.filter : undefined\n };\n\n assignMinimumShouldMatchToQuery({\n query: boolQuery\n });\n\n const body: SearchBody = {\n query: {\n bool: boolQuery\n },\n sort,\n size: (limit || 0) + 1,\n search_after: after,\n track_total_hits: true\n };\n\n for (const modifier of applicableBodyModifiers) {\n modifier.modifyBody({\n body,\n model,\n where\n });\n }\n\n return body;\n};\n"],"names":["createElasticsearchBody","operatorRegistry","model","shared","params","fieldRegistry","fieldIndexRegistry","bodyModifiers","sortModifiers","queryModifiers","valueSearchRegistry","fullTextSearches","filterRegistry","fieldFactory","fields","term","where","initialSort","after","limit","modelFields","createModelFields","applicableQueryModifiers","m","applicableSortModifiers","applicableBodyModifiers","fullTextSearchFields","createFullTextSearchFields","query","createInitialQuery","applyFullTextSearch","execFiltering","createExecFiltering","modifier","sort","createElasticsearchSort","boolQuery","undefined","assignMinimumShouldMatchToQuery","body"],"mappings":";;;;;;;AA8CO,MAAMA,0BAA0B,CAAC,EACpCC,gBAAgB,EAChBC,KAAK,EACLC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,kBAAkB,EAClBC,aAAa,EACbC,aAAa,EACbC,cAAc,EACdC,mBAAmB,EACnBC,gBAAgB,EAChBC,cAAc,EACdC,YAAY,EACiB;IAC7B,MAAM,EAAEC,MAAM,EAAE,QAAQC,IAAI,EAAEC,KAAK,EAAE,MAAMC,WAAW,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGf;IAIzE,MAAMgB,cAAcC,kBAAkB;QAClCnB;QACAG;QACAC;IACJ;IAKA,MAAMgB,2BAA2Bb,eAAe,MAAM,CAACc,CAAAA,IAC5C,CAACA,EAAE,OAAO,IAAIA,EAAE,OAAO,KAAKrB,MAAM,OAAO;IAKpD,MAAMsB,0BAA0BhB,cAAc,MAAM,CAChDe,CAAAA,IAAK,CAACA,EAAE,OAAO,IAAIA,EAAE,OAAO,KAAKrB,MAAM,OAAO;IAKlD,MAAMuB,0BAA0BlB,cAAc,MAAM,CAACgB,CAAAA,IAC1C,CAACA,EAAE,OAAO,IAAIA,EAAE,OAAO,KAAKrB,MAAM,OAAO;IAMpD,MAAMwB,uBAAuBC,2BAA2B;QACpD,QAAQP;QACRL;QACA,SAASD;IACb;IAIA,MAAMc,QAAQC,mBAAmB;QAC7Bb;QACAd;QACAC;IACJ;IAIA2B,oBAAoB;QAChB5B;QACAS;QACAiB;QACAb;QACA,QAAQW;IACZ;IAEA,MAAMK,gBAAgBC,oBAAoB;QACtC9B;QACA,QAAQkB;QACRnB;QACAS;QACAE;IACJ;IAEAmB,cAAc;QACVf;QACAY;IACJ;IAEA,KAAK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