@webiny/api-headless-cms-utils-os 0.0.0-unstable.0d717d18dd → 0.0.0-unstable.3fddf667ea

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 (70) hide show
  1. package/configurations.d.ts +8 -9
  2. package/configurations.js +15 -22
  3. package/configurations.js.map +1 -1
  4. package/exports/api/cms/opensearch.d.ts +1 -0
  5. package/exports/api/cms/opensearch.js +1 -0
  6. package/features/CmsEntryOpenSearchBodyBuilder/CmsEntryOpenSearchBodyBuilder.d.ts +3 -1
  7. package/features/CmsEntryOpenSearchBodyBuilder/CmsEntryOpenSearchBodyBuilder.js +15 -5
  8. package/features/CmsEntryOpenSearchBodyBuilder/CmsEntryOpenSearchBodyBuilder.js.map +1 -1
  9. package/features/CmsEntryOpenSearchBodyBuilder/abstractions.d.ts +4 -0
  10. package/features/CmsEntryOpenSearchBodyBuilder/abstractions.js.map +1 -1
  11. package/features/CmsEntryOpenSearchExecFiltering/CmsEntryOpenSearchExecFiltering.js +2 -3
  12. package/features/CmsEntryOpenSearchExecFiltering/CmsEntryOpenSearchExecFiltering.js.map +1 -1
  13. package/features/CmsEntryOpenSearchFieldIndex/feature.js +10 -10
  14. package/features/CmsEntryOpenSearchFieldIndex/feature.js.map +1 -1
  15. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js +4 -4
  16. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js.map +1 -1
  17. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js +11 -2
  18. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js.map +1 -1
  19. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js +1 -1
  20. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js.map +1 -1
  21. package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.js +1 -1
  22. package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.js.map +1 -1
  23. package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.d.ts +1 -1
  24. package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.js +1 -1
  25. package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.js.map +1 -1
  26. package/features/CmsEntryOpenSearchIndexCreate/CmsEntryOpenSearchIndexCreate.js +3 -4
  27. package/features/CmsEntryOpenSearchIndexCreate/CmsEntryOpenSearchIndexCreate.js.map +1 -1
  28. package/features/CmsEntryOpenSearchIndexDelete/CmsEntryOpenSearchIndexDelete.js +3 -4
  29. package/features/CmsEntryOpenSearchIndexDelete/CmsEntryOpenSearchIndexDelete.js.map +1 -1
  30. package/features/CmsEntryOpenSearchUtilsFeature.js +2 -0
  31. package/features/CmsEntryOpenSearchUtilsFeature.js.map +1 -1
  32. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js +1 -1
  33. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js.map +1 -1
  34. package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndex.d.ts +8 -0
  35. package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndex.js +17 -0
  36. package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndex.js.map +1 -0
  37. package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndexProvider.d.ts +12 -0
  38. package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndexProvider.js +35 -0
  39. package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndexProvider.js.map +1 -0
  40. package/features/CmsModelOpenSearchIndex/feature.d.ts +4 -0
  41. package/features/CmsModelOpenSearchIndex/feature.js +13 -0
  42. package/features/CmsModelOpenSearchIndex/feature.js.map +1 -0
  43. package/features/CmsModelOpenSearchIndex/index.d.ts +3 -0
  44. package/features/CmsModelOpenSearchIndex/index.js +3 -0
  45. package/helpers/fieldIdentifier.js +2 -2
  46. package/helpers/fieldIdentifier.js.map +1 -1
  47. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +2 -2
  48. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
  49. package/operations/entry/elasticsearch/fields/system.d.ts +7 -0
  50. package/operations/entry/elasticsearch/fields/system.js +58 -0
  51. package/operations/entry/elasticsearch/fields/system.js.map +1 -0
  52. package/operations/entry/elasticsearch/fields.d.ts +4 -2
  53. package/operations/entry/elasticsearch/fields.js +6 -4
  54. package/operations/entry/elasticsearch/fields.js.map +1 -1
  55. package/operations/entry/elasticsearch/fullTextSearch.js +12 -3
  56. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
  57. package/operations/entry/elasticsearch/initialQuery.d.ts +4 -0
  58. package/operations/entry/elasticsearch/initialQuery.js +2 -4
  59. package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
  60. package/operations/entry/elasticsearch/initialQuery.test.d.ts +1 -0
  61. package/operations/entry/elasticsearch/initialQuery.test.js +48 -0
  62. package/operations/entry/elasticsearch/initialQuery.test.js.map +1 -0
  63. package/operations/entry/elasticsearch/keyword.js +2 -2
  64. package/operations/entry/elasticsearch/keyword.js.map +1 -1
  65. package/package.json +8 -7
  66. package/testing/createTestModelIndexName.d.ts +3 -0
  67. package/testing/createTestModelIndexName.js +11 -0
  68. package/testing/createTestModelIndexName.js.map +1 -0
  69. package/testing/index.d.ts +1 -0
  70. package/testing/index.js +1 -0
@@ -2,7 +2,7 @@ import error from "@webiny/error";
2
2
  import { OpenSearchClient } from "@webiny/api-opensearch/exports/api/opensearch.js";
3
3
  import { CmsModelOpenSearchIndexProvider } from "../CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js";
4
4
  import { CmsEntryOpenSearchIndexCreate } from "./abstractions.js";
5
- import { getOpenSearchIndexPrefix } from "@webiny/api-opensearch";
5
+ import { createConfigurations } from "../../configurations.js";
6
6
  class CmsEntryOpenSearchIndexCreateImpl {
7
7
  constructor(openSearchClient, indexProvider){
8
8
  this.openSearchClient = openSearchClient;
@@ -11,11 +11,10 @@ class CmsEntryOpenSearchIndexCreateImpl {
11
11
  async execute(params) {
12
12
  const { model } = params;
13
13
  const client = this.openSearchClient.use();
14
- const { index: rawIndex, settings } = await this.indexProvider.execute({
14
+ const configurations = createConfigurations(this.indexProvider);
15
+ const { index, settings } = await configurations.es({
15
16
  model
16
17
  });
17
- const prefix = getOpenSearchIndexPrefix();
18
- const index = prefix ? prefix + rawIndex : rawIndex;
19
18
  try {
20
19
  const response = await client.indices.exists({
21
20
  index,
@@ -1 +1 @@
1
- {"version":3,"file":"features/CmsEntryOpenSearchIndexCreate/CmsEntryOpenSearchIndexCreate.js","sources":["../../../src/features/CmsEntryOpenSearchIndexCreate/CmsEntryOpenSearchIndexCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { OpenSearchClient } from \"@webiny/api-opensearch/exports/api/opensearch.js\";\nimport { CmsModelOpenSearchIndexProvider } from \"~/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js\";\nimport { CmsEntryOpenSearchIndexCreate as CmsEntryOpenSearchIndexCreateAbstraction } from \"./abstractions.js\";\nimport { getOpenSearchIndexPrefix } from \"@webiny/api-opensearch\";\n\nclass CmsEntryOpenSearchIndexCreateImpl\n implements CmsEntryOpenSearchIndexCreateAbstraction.Interface\n{\n public constructor(\n private readonly openSearchClient: OpenSearchClient.Interface,\n private readonly indexProvider: CmsModelOpenSearchIndexProvider.Interface\n ) {}\n\n public async execute(params: CmsEntryOpenSearchIndexCreateAbstraction.Params): Promise<void> {\n const { model } = params;\n const client = this.openSearchClient.use();\n\n const { index: rawIndex, settings } = await this.indexProvider.execute({ model });\n const prefix = getOpenSearchIndexPrefix();\n const index = prefix ? prefix + rawIndex : rawIndex;\n\n try {\n const response = await client.indices.exists({\n index,\n ignore_unavailable: false,\n allow_no_indices: true,\n include_defaults: true,\n flat_settings: false,\n local: false\n });\n if (response.body) {\n console.log(\n `Elasticsearch index \"${index}\" for the CMS model \"${model.name}\" already exists.`\n );\n return;\n }\n } catch {\n console.error(`Could not determine if the index \"${index}\" exists.`);\n }\n\n try {\n await client.indices.create({\n index,\n body: {\n ...settings\n }\n });\n } catch (ex) {\n console.error(\n `Could not create Elasticsearch index \"${index}\" for the CMS model \"${model.name}\".`\n );\n console.error(ex);\n throw new WebinyError(\n ex.message || \"Could not create OpenSearch index for the CMS entry.\",\n ex.code || \"CREATE_OPENSEARCH_INDEX_ERROR\",\n {\n error: {\n ...ex,\n message: ex.message,\n code: ex.code,\n data: ex.data\n },\n tenant: model.tenant,\n index,\n body: settings\n }\n );\n }\n }\n}\n\nexport const CmsEntryOpenSearchIndexCreate =\n CmsEntryOpenSearchIndexCreateAbstraction.createImplementation({\n implementation: CmsEntryOpenSearchIndexCreateImpl,\n dependencies: [OpenSearchClient, CmsModelOpenSearchIndexProvider]\n });\n"],"names":["CmsEntryOpenSearchIndexCreateImpl","openSearchClient","indexProvider","params","model","client","rawIndex","settings","prefix","getOpenSearchIndexPrefix","index","response","console","ex","WebinyError","CmsEntryOpenSearchIndexCreate","CmsEntryOpenSearchIndexCreateAbstraction","OpenSearchClient","CmsModelOpenSearchIndexProvider"],"mappings":";;;;;AAMA,MAAMA;IAGF,YACqBC,gBAA4C,EAC5CC,aAAwD,CAC3E;aAFmBD,gBAAgB,GAAhBA;aACAC,aAAa,GAAbA;IAClB;IAEH,MAAa,QAAQC,MAAuD,EAAiB;QACzF,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAClB,MAAME,SAAS,IAAI,CAAC,gBAAgB,CAAC,GAAG;QAExC,MAAM,EAAE,OAAOC,QAAQ,EAAEC,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;YAAEH;QAAM;QAC/E,MAAMI,SAASC;QACf,MAAMC,QAAQF,SAASA,SAASF,WAAWA;QAE3C,IAAI;YACA,MAAMK,WAAW,MAAMN,OAAO,OAAO,CAAC,MAAM,CAAC;gBACzCK;gBACA,oBAAoB;gBACpB,kBAAkB;gBAClB,kBAAkB;gBAClB,eAAe;gBACf,OAAO;YACX;YACA,IAAIC,SAAS,IAAI,EAAE,YACfC,QAAQ,GAAG,CACP,CAAC,qBAAqB,EAAEF,MAAM,qBAAqB,EAAEN,MAAM,IAAI,CAAC,iBAAiB,CAAC;QAI9F,EAAE,OAAM;YACJQ,QAAQ,KAAK,CAAC,CAAC,kCAAkC,EAAEF,MAAM,SAAS,CAAC;QACvE;QAEA,IAAI;YACA,MAAML,OAAO,OAAO,CAAC,MAAM,CAAC;gBACxBK;gBACA,MAAM;oBACF,GAAGH,QAAQ;gBACf;YACJ;QACJ,EAAE,OAAOM,IAAI;YACTD,QAAQ,KAAK,CACT,CAAC,sCAAsC,EAAEF,MAAM,qBAAqB,EAAEN,MAAM,IAAI,CAAC,EAAE,CAAC;YAExFQ,QAAQ,KAAK,CAACC;YACd,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,wDACdA,GAAG,IAAI,IAAI,iCACX;gBACI,OAAO;oBACH,GAAGA,EAAE;oBACL,SAASA,GAAG,OAAO;oBACnB,MAAMA,GAAG,IAAI;oBACb,MAAMA,GAAG,IAAI;gBACjB;gBACA,QAAQT,MAAM,MAAM;gBACpBM;gBACA,MAAMH;YACV;QAER;IACJ;AACJ;AAEO,MAAMQ,8DACTC,8BAAAA,oBAA6D,CAAC;IAC1D,gBAAgBhB;IAChB,cAAc;QAACiB;QAAkBC;KAAgC;AACrE"}
1
+ {"version":3,"file":"features/CmsEntryOpenSearchIndexCreate/CmsEntryOpenSearchIndexCreate.js","sources":["../../../src/features/CmsEntryOpenSearchIndexCreate/CmsEntryOpenSearchIndexCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { OpenSearchClient } from \"@webiny/api-opensearch/exports/api/opensearch.js\";\nimport { CmsModelOpenSearchIndexProvider } from \"~/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js\";\nimport { CmsEntryOpenSearchIndexCreate as CmsEntryOpenSearchIndexCreateAbstraction } from \"./abstractions.js\";\nimport { createConfigurations } from \"~/configurations.js\";\n\nclass CmsEntryOpenSearchIndexCreateImpl\n implements CmsEntryOpenSearchIndexCreateAbstraction.Interface\n{\n public constructor(\n private readonly openSearchClient: OpenSearchClient.Interface,\n private readonly indexProvider: CmsModelOpenSearchIndexProvider.Interface\n ) {}\n\n public async execute(params: CmsEntryOpenSearchIndexCreateAbstraction.Params): Promise<void> {\n const { model } = params;\n const client = this.openSearchClient.use();\n\n const configurations = createConfigurations(this.indexProvider);\n const { index, settings } = await configurations.es({ model });\n\n try {\n const response = await client.indices.exists({\n index,\n ignore_unavailable: false,\n allow_no_indices: true,\n include_defaults: true,\n flat_settings: false,\n local: false\n });\n if (response.body) {\n console.log(\n `Elasticsearch index \"${index}\" for the CMS model \"${model.name}\" already exists.`\n );\n return;\n }\n } catch {\n console.error(`Could not determine if the index \"${index}\" exists.`);\n }\n\n try {\n await client.indices.create({\n index,\n body: {\n ...settings\n }\n });\n } catch (ex) {\n console.error(\n `Could not create Elasticsearch index \"${index}\" for the CMS model \"${model.name}\".`\n );\n console.error(ex);\n throw new WebinyError(\n ex.message || \"Could not create OpenSearch index for the CMS entry.\",\n ex.code || \"CREATE_OPENSEARCH_INDEX_ERROR\",\n {\n error: {\n ...ex,\n message: ex.message,\n code: ex.code,\n data: ex.data\n },\n tenant: model.tenant,\n index,\n body: settings\n }\n );\n }\n }\n}\n\nexport const CmsEntryOpenSearchIndexCreate =\n CmsEntryOpenSearchIndexCreateAbstraction.createImplementation({\n implementation: CmsEntryOpenSearchIndexCreateImpl,\n dependencies: [OpenSearchClient, CmsModelOpenSearchIndexProvider]\n });\n"],"names":["CmsEntryOpenSearchIndexCreateImpl","openSearchClient","indexProvider","params","model","client","configurations","createConfigurations","index","settings","response","console","ex","WebinyError","CmsEntryOpenSearchIndexCreate","CmsEntryOpenSearchI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G,IAAI;gBACjB;gBACA,QAAQR,MAAM,MAAM;gBACpBI;gBACA,MAAMC;YACV;QAER;IACJ;AACJ;AAEO,MAAMK,8DACTC,8BAAAA,oBAA6D,CAAC;IAC1D,gBAAgBf;IAChB,cAAc;QAACgB;QAAkBC;KAAgC;AACrE"}
@@ -1,7 +1,7 @@
1
1
  import { OpenSearchClient } from "@webiny/api-opensearch/exports/api/opensearch.js";
2
2
  import { CmsModelOpenSearchIndexProvider } from "../CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js";
3
3
  import { CmsEntryOpenSearchIndexDelete } from "./abstractions.js";
4
- import { getOpenSearchIndexPrefix } from "@webiny/api-opensearch";
4
+ import { createConfigurations } from "../../configurations.js";
5
5
  class CmsEntryOpenSearchIndexDeleteImpl {
6
6
  constructor(openSearchClient, indexProvider){
7
7
  this.openSearchClient = openSearchClient;
@@ -9,12 +9,11 @@ class CmsEntryOpenSearchIndexDeleteImpl {
9
9
  }
10
10
  async execute(params) {
11
11
  const { model } = params;
12
- const { index: rawIndex, shared } = await this.indexProvider.execute({
12
+ const configurations = createConfigurations(this.indexProvider);
13
+ const { index, shared } = await configurations.es({
13
14
  model
14
15
  });
15
16
  if (shared) return;
16
- const prefix = getOpenSearchIndexPrefix();
17
- const index = prefix ? prefix + rawIndex : rawIndex;
18
17
  const client = this.openSearchClient.use();
19
18
  const { body: exists } = await client.indices.exists({
20
19
  index
@@ -1 +1 @@
1
- {"version":3,"file":"features/CmsEntryOpenSearchIndexDelete/CmsEntryOpenSearchIndexDelete.js","sources":["../../../src/features/CmsEntryOpenSearchIndexDelete/CmsEntryOpenSearchIndexDelete.ts"],"sourcesContent":["import { OpenSearchClient } from \"@webiny/api-opensearch/exports/api/opensearch.js\";\nimport { CmsModelOpenSearchIndexProvider } from \"~/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js\";\nimport { CmsEntryOpenSearchIndexDelete as CmsEntryOpenSearchIndexDeleteAbstraction } from \"./abstractions.js\";\nimport { getOpenSearchIndexPrefix } from \"@webiny/api-opensearch\";\n\nclass CmsEntryOpenSearchIndexDeleteImpl\n implements CmsEntryOpenSearchIndexDeleteAbstraction.Interface\n{\n public constructor(\n private readonly openSearchClient: OpenSearchClient.Interface,\n private readonly indexProvider: CmsModelOpenSearchIndexProvider.Interface\n ) {}\n\n public async execute(params: CmsEntryOpenSearchIndexDeleteAbstraction.Params): Promise<void> {\n const { model } = params;\n\n const { index: rawIndex, shared } = await this.indexProvider.execute({ model });\n if (shared) {\n return;\n }\n\n const prefix = getOpenSearchIndexPrefix();\n const index = prefix ? prefix + rawIndex : rawIndex;\n const client = this.openSearchClient.use();\n\n const { body: exists } = await client.indices.exists({ index });\n if (!exists) {\n return;\n }\n\n try {\n await client.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n console.log(`Could not delete Elasticsearch index \"${index}\". Please do it manually.`);\n console.log(ex.message);\n }\n }\n}\n\nexport const CmsEntryOpenSearchIndexDelete =\n CmsEntryOpenSearchIndexDeleteAbstraction.createImplementation({\n implementation: CmsEntryOpenSearchIndexDeleteImpl,\n dependencies: [OpenSearchClient, CmsModelOpenSearchIndexProvider]\n });\n"],"names":["CmsEntryOpenSearchIndexDeleteImpl","openSearchClient","indexProvider","params","model","rawIndex","shared","prefix","getOpenSearchIndexPrefix","index","client","exists","ex","console","CmsEntryOpenSearchIndexDelete","CmsEntryOpenSearchIndexDeleteAbstraction","OpenSearchClient","CmsModelOpenSearchIndexProvider"],"mappings":";;;;AAKA,MAAMA;IAGF,YACqBC,gBAA4C,EAC5CC,aAAwD,CAC3E;aAFmBD,gBAAgB,GAAhBA;aACAC,aAAa,GAAbA;IAClB;IAEH,MAAa,QAAQC,MAAuD,EAAiB;QACzF,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAElB,MAAM,EAAE,OAAOE,QAAQ,EAAEC,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;YAAEF;QAAM;QAC7E,IAAIE,QACA;QAGJ,MAAMC,SAASC;QACf,MAAMC,QAAQF,SAASA,SAASF,WAAWA;QAC3C,MAAMK,SAAS,IAAI,CAAC,gBAAgB,CAAC,GAAG;QAExC,MAAM,EAAE,MAAMC,MAAM,EAAE,GAAG,MAAMD,OAAO,OAAO,CAAC,MAAM,CAAC;YAAED;QAAM;QAC7D,IAAI,CAACE,QACD;QAGJ,IAAI;YACA,MAAMD,OAAO,OAAO,CAAC,MAAM,CAAC;gBACxBD;gBACA,oBAAoB;YACxB;QACJ,EAAE,OAAOG,IAAI;YACTC,QAAQ,GAAG,CAAC,CAAC,sCAAsC,EAAEJ,MAAM,yBAAyB,CAAC;YACrFI,QAAQ,GAAG,CAACD,GAAG,OAAO;QAC1B;IACJ;AACJ;AAEO,MAAME,8DACTC,8BAAAA,oBAA6D,CAAC;IAC1D,gBAAgBf;IAChB,cAAc;QAACgB;QAAkBC;KAAgC;AACrE"}
1
+ {"version":3,"file":"features/CmsEntryOpenSearchIndexDelete/CmsEntryOpenSearchIndexDelete.js","sources":["../../../src/features/CmsEntryOpenSearchIndexDelete/CmsEntryOpenSearchIndexDelete.ts"],"sourcesContent":["import { OpenSearchClient } from \"@webiny/api-opensearch/exports/api/opensearch.js\";\nimport { CmsModelOpenSearchIndexProvider } from \"~/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js\";\nimport { CmsEntryOpenSearchIndexDelete as CmsEntryOpenSearchIndexDeleteAbstraction } from \"./abstractions.js\";\nimport { createConfigurations } from \"~/configurations.js\";\n\nclass CmsEntryOpenSearchIndexDeleteImpl\n implements CmsEntryOpenSearchIndexDeleteAbstraction.Interface\n{\n public constructor(\n private readonly openSearchClient: OpenSearchClient.Interface,\n private readonly indexProvider: CmsModelOpenSearchIndexProvider.Interface\n ) {}\n\n public async execute(params: CmsEntryOpenSearchIndexDeleteAbstraction.Params): Promise<void> {\n const { model } = params;\n\n const configurations = createConfigurations(this.indexProvider);\n const { index, shared } = await configurations.es({ model });\n if (shared) {\n return;\n }\n const client = this.openSearchClient.use();\n\n const { body: exists } = await client.indices.exists({ index });\n if (!exists) {\n return;\n }\n\n try {\n await client.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n console.log(`Could not delete Elasticsearch index \"${index}\". Please do it manually.`);\n console.log(ex.message);\n }\n }\n}\n\nexport const CmsEntryOpenSearchIndexDelete =\n CmsEntryOpenSearchIndexDeleteAbstraction.createImplementation({\n implementation: CmsEntryOpenSearchIndexDeleteImpl,\n dependencies: [OpenSearchClient, CmsModelOpenSearchIndexProvider]\n });\n"],"names":["CmsEntryOpenSearchIndexDeleteImpl","openSearchClient","indexProvider","params","model","configurations","createConfigurations","index","shared","client","exists","ex","console","CmsEntryOpenSearchIndexDelete","CmsEntryOpenSearchIndexDeleteAbstraction","OpenSearchClient","CmsModelOpenSearchIndexProvider"],"mappings":";;;;AAKA,MAAMA;IAGF,YACqBC,gBAA4C,EAC5CC,aAAwD,CAC3E;aAFmBD,gBAAgB,GAAhBA;aACAC,aAAa,GAAbA;IAClB;IAEH,MAAa,QAAQC,MAAuD,EAAiB;QACzF,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAElB,MAAME,iBAAiBC,qBAAqB,IAAI,CAAC,aAAa;QAC9D,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAE,GAAG,MAAMH,eAAe,EAAE,CAAC;YAAED;QAAM;QAC1D,IAAII,QACA;QAEJ,MAAMC,SAAS,IAAI,CAAC,gBAAgB,CAAC,GAAG;QAExC,MAAM,EAAE,MAAMC,MAAM,EAAE,GAAG,MAAMD,OAAO,OAAO,CAAC,MAAM,CAAC;YAAEF;QAAM;QAC7D,IAAI,CAACG,QACD;QAGJ,IAAI;YACA,MAAMD,OAAO,OAAO,CAAC,MAAM,CAAC;gBACxBF;gBACA,oBAAoB;YACxB;QACJ,EAAE,OAAOI,IAAI;YACTC,QAAQ,GAAG,CAAC,CAAC,sCAAsC,EAAEL,MAAM,yBAAyB,CAAC;YACrFK,QAAQ,GAAG,CAACD,GAAG,OAAO;QAC1B;IACJ;AACJ;AAEO,MAAME,8DACTC,8BAAAA,oBAA6D,CAAC;IAC1D,gBAAgBd;IAChB,cAAc;QAACe;QAAkBC;KAAgC;AACrE"}
@@ -13,9 +13,11 @@ import { CmsEntryOpenSearchValueSearchFeature } from "./CmsEntryOpenSearchValueS
13
13
  import { ModelAfterCreateHandler } from "./CmsEntryOpenSearchIndexCreate/ModelAfterCreateHandler.js";
14
14
  import { ModelAfterCreateFromHandler } from "./CmsEntryOpenSearchIndexCreate/ModelAfterCreateFromHandler.js";
15
15
  import { ModelAfterDeleteHandler } from "./CmsEntryOpenSearchIndexDelete/ModelAfterDeleteHandler.js";
16
+ import { CmsModelOpenSearchIndexFeature } from "./CmsModelOpenSearchIndex/index.js";
16
17
  const CmsEntryOpenSearchUtilsFeature = createFeature({
17
18
  name: "Cms/Entry/OpenSearch/UtilsFeature",
18
19
  register: (container)=>{
20
+ CmsModelOpenSearchIndexFeature.register(container);
19
21
  CmsEntryOpenSearchFieldIndexFeature.register(container);
20
22
  CmsEntryOpenSearchFilterFeature.register(container);
21
23
  CmsEntryOpenSearchIndexFeature.register(container);
@@ -1 +1 @@
1
- {"version":3,"file":"features/CmsEntryOpenSearchUtilsFeature.js","sources":["../../src/features/CmsEntryOpenSearchUtilsFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { CmsEntryOpenSearchFieldIndexFeature } from \"./CmsEntryOpenSearchFieldIndex/feature.js\";\nimport { CmsEntryOpenSearchFilterFeature } from \"./CmsEntryOpenSearchFilter/feature.js\";\nimport { CmsEntryOpenSearchIndexFeature } from \"./CmsEntryOpenSearchIndex/feature.js\";\nimport { CmsEntryOpenSearchIndexCreateFeature } from \"./CmsEntryOpenSearchIndexCreate/feature.js\";\nimport { CmsEntryOpenSearchIndexDeleteFeature } from \"./CmsEntryOpenSearchIndexDelete/feature.js\";\nimport { CmsEntryOpenSearchFieldPathFactoryFeature } from \"./CmsEntryOpenSearchFieldPathFactory/feature.js\";\nimport { CmsEntryOpenSearchValueTransformerFeature } from \"./CmsEntryOpenSearchValueTransformer/feature.js\";\nimport { CmsEntryOpenSearchOperatorListFeature } from \"./CmsEntryOpenSearchOperatorList/feature.js\";\nimport { CmsEntryOpenSearchExecFilteringFeature } from \"./CmsEntryOpenSearchExecFiltering/feature.js\";\nimport { CmsEntryOpenSearchBodyBuilderFeature } from \"./CmsEntryOpenSearchBodyBuilder/feature.js\";\nimport { CmsEntryOpenSearchValueSearchFeature } from \"./CmsEntryOpenSearchValueSearch/feature.js\";\nimport { ModelAfterCreateHandler } from \"./CmsEntryOpenSearchIndexCreate/ModelAfterCreateHandler.js\";\nimport { ModelAfterCreateFromHandler } from \"./CmsEntryOpenSearchIndexCreate/ModelAfterCreateFromHandler.js\";\nimport { ModelAfterDeleteHandler } from \"./CmsEntryOpenSearchIndexDelete/ModelAfterDeleteHandler.js\";\n\nexport const CmsEntryOpenSearchUtilsFeature = createFeature({\n name: \"Cms/Entry/OpenSearch/UtilsFeature\",\n register: container => {\n CmsEntryOpenSearchFieldIndexFeature.register(container);\n CmsEntryOpenSearchFilterFeature.register(container);\n CmsEntryOpenSearchIndexFeature.register(container);\n CmsEntryOpenSearchIndexCreateFeature.register(container);\n CmsEntryOpenSearchIndexDeleteFeature.register(container);\n CmsEntryOpenSearchFieldPathFactoryFeature.register(container);\n CmsEntryOpenSearchValueTransformerFeature.register(container);\n CmsEntryOpenSearchOperatorListFeature.register(container);\n CmsEntryOpenSearchExecFilteringFeature.register(container);\n CmsEntryOpenSearchBodyBuilderFeature.register(container);\n CmsEntryOpenSearchValueSearchFeature.register(container);\n\n // Model lifecycle event handlers for OpenSearch index management\n container.register(ModelAfterCreateHandler);\n container.register(ModelAfterCreateFromHandler);\n container.register(ModelAfterDeleteHandler);\n }\n});\n"],"names":["CmsEntryOpenSearchUtilsFeature","createFeature","container","CmsEntryOpenSearchFieldIndexFeature","CmsEntryOpenSearchFilterFeature","CmsEntryOpenSearchIndexFeature","CmsEntryOpenSearchIndexCreateFeature","CmsEntryOpenSearchIndexDeleteFeature","CmsEntryOpenSearchFieldPathFactoryFeature","CmsEntryOpenSearchValueTransformerFeature","CmsEntryOpenSearchOperatorListFeature","CmsEntryOpenSearchExecFilteringFeature","CmsEntryOpenSearchBodyBuilderFeature","CmsEntryOpenSearchValueSearchFeature","ModelAfterCreateHandler","ModelAfterCreateFromHandler","ModelAfterDeleteHandler"],"mappings":";;;;;;;;;;;;;;;AAgBO,MAAMA,iCAAiCC,cAAc;IACxD,MAAM;IACN,UAAUC,CAAAA;QACNC,oCAAoC,QAAQ,CAACD;QAC7CE,gCAAgC,QAAQ,CAACF;QACzCG,+BAA+B,QAAQ,CAACH;QACxCI,qCAAqC,QAAQ,CAACJ;QAC9CK,qCAAqC,QAAQ,CAACL;QAC9CM,0CAA0C,QAAQ,CAACN;QACnDO,0CAA0C,QAAQ,CAACP;QACnDQ,sCAAsC,QAAQ,CAACR;QAC/CS,uCAAuC,QAAQ,CAACT;QAChDU,qCAAqC,QAAQ,CAACV;QAC9CW,qCAAqC,QAAQ,CAACX;QAG9CA,UAAU,QAAQ,CAACY;QACnBZ,UAAU,QAAQ,CAACa;QACnBb,UAAU,QAAQ,CAACc;IACvB;AACJ"}
1
+ {"version":3,"file":"features/CmsEntryOpenSearchUtilsFeature.js","sources":["../../src/features/CmsEntryOpenSearchUtilsFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { CmsEntryOpenSearchFieldIndexFeature } from \"./CmsEntryOpenSearchFieldIndex/feature.js\";\nimport { CmsEntryOpenSearchFilterFeature } from \"./CmsEntryOpenSearchFilter/feature.js\";\nimport { CmsEntryOpenSearchIndexFeature } from \"./CmsEntryOpenSearchIndex/feature.js\";\nimport { CmsEntryOpenSearchIndexCreateFeature } from \"./CmsEntryOpenSearchIndexCreate/feature.js\";\nimport { CmsEntryOpenSearchIndexDeleteFeature } from \"./CmsEntryOpenSearchIndexDelete/feature.js\";\nimport { CmsEntryOpenSearchFieldPathFactoryFeature } from \"./CmsEntryOpenSearchFieldPathFactory/feature.js\";\nimport { CmsEntryOpenSearchValueTransformerFeature } from \"./CmsEntryOpenSearchValueTransformer/feature.js\";\nimport { CmsEntryOpenSearchOperatorListFeature } from \"./CmsEntryOpenSearchOperatorList/feature.js\";\nimport { CmsEntryOpenSearchExecFilteringFeature } from \"./CmsEntryOpenSearchExecFiltering/feature.js\";\nimport { CmsEntryOpenSearchBodyBuilderFeature } from \"./CmsEntryOpenSearchBodyBuilder/feature.js\";\nimport { CmsEntryOpenSearchValueSearchFeature } from \"./CmsEntryOpenSearchValueSearch/feature.js\";\nimport { ModelAfterCreateHandler } from \"./CmsEntryOpenSearchIndexCreate/ModelAfterCreateHandler.js\";\nimport { ModelAfterCreateFromHandler } from \"./CmsEntryOpenSearchIndexCreate/ModelAfterCreateFromHandler.js\";\nimport { ModelAfterDeleteHandler } from \"./CmsEntryOpenSearchIndexDelete/ModelAfterDeleteHandler.js\";\nimport { CmsModelOpenSearchIndexFeature } from \"./CmsModelOpenSearchIndex/index.js\";\n\nexport const CmsEntryOpenSearchUtilsFeature = createFeature({\n name: \"Cms/Entry/OpenSearch/UtilsFeature\",\n register: container => {\n CmsModelOpenSearchIndexFeature.register(container);\n CmsEntryOpenSearchFieldIndexFeature.register(container);\n CmsEntryOpenSearchFilterFeature.register(container);\n CmsEntryOpenSearchIndexFeature.register(container);\n CmsEntryOpenSearchIndexCreateFeature.register(container);\n CmsEntryOpenSearchIndexDeleteFeature.register(container);\n CmsEntryOpenSearchFieldPathFactoryFeature.register(container);\n CmsEntryOpenSearchValueTransformerFeature.register(container);\n CmsEntryOpenSearchOperatorListFeature.register(container);\n CmsEntryOpenSearchExecFilteringFeature.register(container);\n CmsEntryOpenSearchBodyBuilderFeature.register(container);\n CmsEntryOpenSearchValueSearchFeature.register(container);\n\n // Model lifecycle event handlers for OpenSearch index management\n container.register(ModelAfterCreateHandler);\n container.register(ModelAfterCreateFromHandler);\n container.register(ModelAfterDeleteHandler);\n }\n});\n"],"names":["CmsEntryOpenSearchUtilsFeature","createFeature","container","CmsModelOpenSearchIndexFeature","CmsEntryOpenSearchFieldIndexFeature","CmsEntryOpenSearchFilterFeature","CmsEntryOpenSearchIndexFeature","CmsEntryOpenSearchIndexCreateFeature","CmsEntryOpenSearchIndexDeleteFeature","CmsEntryOpenSearchFieldPathFactoryFeature","CmsEntryOpenSearchValueTransformerFeature","CmsEntryOpenSearchOperatorListFeature","CmsEntryOpenSearchExecFilteringFeature","CmsEntryOpenSearchBodyBuilderFeature","CmsEntryOpenSearchValueSearchFeature","ModelAfterCreateHandler","ModelAfterCreateFromHandler","ModelAfterDeleteHandler"],"mappings":";;;;;;;;;;;;;;;;AAiBO,MAAMA,iCAAiCC,cAAc;IACxD,MAAM;IACN,UAAUC,CAAAA;QACNC,+BAA+B,QAAQ,CAACD;QACxCE,oCAAoC,QAAQ,CAACF;QAC7CG,gCAAgC,QAAQ,CAACH;QACzCI,+BAA+B,QAAQ,CAACJ;QACxCK,qCAAqC,QAAQ,CAACL;QAC9CM,qCAAqC,QAAQ,CAACN;QAC9CO,0CAA0C,QAAQ,CAACP;QACnDQ,0CAA0C,QAAQ,CAACR;QACnDS,sCAAsC,QAAQ,CAACT;QAC/CU,uCAAuC,QAAQ,CAACV;QAChDW,qCAAqC,QAAQ,CAACX;QAC9CY,qCAAqC,QAAQ,CAACZ;QAG9CA,UAAU,QAAQ,CAACa;QACnBb,UAAU,QAAQ,CAACc;QACnBd,UAAU,QAAQ,CAACe;IACvB;AACJ"}
@@ -8,7 +8,7 @@ const getKey = (params)=>{
8
8
  field,
9
9
  value
10
10
  });
11
- if (keys.length > 1) throw new WebinyError(`Searchable JSON field "${field.fieldId}" can only have one key.`, "MULTIPLE_KEYS_IN_SEARCHABLE_JSON_FIELD", {
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", {
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;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
+ {"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"}
@@ -0,0 +1,8 @@
1
+ import { CmsModelOpenSearchIndex } from "./abstractions.js";
2
+ declare class DefaultCmsModelOpenSearchIndexImpl implements CmsModelOpenSearchIndex.Interface {
3
+ execute(): Promise<CmsModelOpenSearchIndex.Result>;
4
+ }
5
+ export declare const DefaultCmsModelOpenSearchIndex: typeof DefaultCmsModelOpenSearchIndexImpl & {
6
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ICmsModelOpenSearchIndex>;
7
+ };
8
+ export {};
@@ -0,0 +1,17 @@
1
+ import { getBaseConfiguration, isSharedOpenSearchIndex } from "@webiny/api-opensearch";
2
+ import { CmsModelOpenSearchIndex } from "./abstractions.js";
3
+ class DefaultCmsModelOpenSearchIndexImpl {
4
+ async execute() {
5
+ return {
6
+ settings: getBaseConfiguration(),
7
+ shared: isSharedOpenSearchIndex()
8
+ };
9
+ }
10
+ }
11
+ const DefaultCmsModelOpenSearchIndex = CmsModelOpenSearchIndex.createImplementation({
12
+ implementation: DefaultCmsModelOpenSearchIndexImpl,
13
+ dependencies: []
14
+ });
15
+ export { DefaultCmsModelOpenSearchIndex };
16
+
17
+ //# sourceMappingURL=DefaultCmsModelOpenSearchIndex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndex.js","sources":["../../../src/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndex.ts"],"sourcesContent":["import { getBaseConfiguration, isSharedOpenSearchIndex } from \"@webiny/api-opensearch\";\nimport { CmsModelOpenSearchIndex } from \"./abstractions.js\";\n\nclass DefaultCmsModelOpenSearchIndexImpl implements CmsModelOpenSearchIndex.Interface {\n public async execute(): Promise<CmsModelOpenSearchIndex.Result> {\n return {\n settings: getBaseConfiguration(),\n shared: isSharedOpenSearchIndex()\n };\n }\n}\n\nexport const DefaultCmsModelOpenSearchIndex = CmsModelOpenSearchIndex.createImplementation({\n implementation: DefaultCmsModelOpenSearchIndexImpl,\n dependencies: []\n});\n"],"names":["DefaultCmsModelOpenSearchIndexImpl","getBaseConfiguration","isSharedOpenSearchIndex","DefaultCmsModelOpenSearchIndex","CmsModelOpenSearchIndex"],"mappings":";;AAGA,MAAMA;IACF,MAAa,UAAmD;QAC5D,OAAO;YACH,UAAUC;YACV,QAAQC;QACZ;IACJ;AACJ;AAEO,MAAMC,iCAAiCC,wBAAwB,oBAAoB,CAAC;IACvF,gBAAgBJ;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,12 @@
1
+ import { CmsModelOpenSearchIndexProvider, type ICmsModelOpenSearchIndexProviderResult } from "./CmsModelOpenSearchIndexProvider.js";
2
+ import { CmsModelOpenSearchIndex } from "./abstractions.js";
3
+ declare class CmsModelOpenSearchIndexProviderImpl implements CmsModelOpenSearchIndexProvider.Interface {
4
+ private readonly indexConfig;
5
+ private readonly cache;
6
+ constructor(indexConfig: CmsModelOpenSearchIndex.Interface);
7
+ execute(params: CmsModelOpenSearchIndex.Params): Promise<ICmsModelOpenSearchIndexProviderResult>;
8
+ }
9
+ export declare const DefaultCmsModelOpenSearchIndexProvider: typeof CmsModelOpenSearchIndexProviderImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("./CmsModelOpenSearchIndexProvider.js").ICmsModelOpenSearchIndexProvider>;
11
+ };
12
+ export {};
@@ -0,0 +1,35 @@
1
+ import { CmsModelOpenSearchIndexProvider } from "./CmsModelOpenSearchIndexProvider.js";
2
+ import { CmsModelOpenSearchIndex } from "./abstractions.js";
3
+ class CmsModelOpenSearchIndexProviderImpl {
4
+ constructor(indexConfig){
5
+ this.indexConfig = indexConfig;
6
+ this.cache = new Map();
7
+ }
8
+ async execute(params) {
9
+ const key = `${params.model.tenant}:${params.model.modelId}`;
10
+ const cached = this.cache.get(key);
11
+ if (cached) return cached;
12
+ const { shared, settings } = await this.indexConfig.execute(params);
13
+ const index = [
14
+ shared ? "root" : params.model.tenant,
15
+ "headless-cms",
16
+ params.model.modelId
17
+ ].join("-").toLowerCase();
18
+ const result = {
19
+ index,
20
+ settings,
21
+ shared
22
+ };
23
+ this.cache.set(key, result);
24
+ return result;
25
+ }
26
+ }
27
+ const DefaultCmsModelOpenSearchIndexProvider = CmsModelOpenSearchIndexProvider.createImplementation({
28
+ implementation: CmsModelOpenSearchIndexProviderImpl,
29
+ dependencies: [
30
+ CmsModelOpenSearchIndex
31
+ ]
32
+ });
33
+ export { DefaultCmsModelOpenSearchIndexProvider };
34
+
35
+ //# sourceMappingURL=DefaultCmsModelOpenSearchIndexProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndexProvider.js","sources":["../../../src/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndexProvider.ts"],"sourcesContent":["import {\n CmsModelOpenSearchIndexProvider,\n type ICmsModelOpenSearchIndexProviderResult\n} from \"./CmsModelOpenSearchIndexProvider.js\";\nimport { CmsModelOpenSearchIndex } from \"./abstractions.js\";\n\nclass CmsModelOpenSearchIndexProviderImpl implements CmsModelOpenSearchIndexProvider.Interface {\n private readonly cache = new Map<string, ICmsModelOpenSearchIndexProviderResult>();\n\n public constructor(private readonly indexConfig: CmsModelOpenSearchIndex.Interface) {}\n\n public async execute(\n params: CmsModelOpenSearchIndex.Params\n ): Promise<ICmsModelOpenSearchIndexProviderResult> {\n const key = `${params.model.tenant}:${params.model.modelId}`;\n const cached = this.cache.get(key);\n if (cached) {\n return cached;\n }\n\n const { shared, settings } = await this.indexConfig.execute(params);\n\n const index = [shared ? \"root\" : params.model.tenant, \"headless-cms\", params.model.modelId]\n .join(\"-\")\n .toLowerCase();\n\n const result: ICmsModelOpenSearchIndexProviderResult = { index, settings, shared };\n this.cache.set(key, result);\n return result;\n }\n}\n\nexport const DefaultCmsModelOpenSearchIndexProvider =\n CmsModelOpenSearchIndexProvider.createImplementation({\n implementation: CmsModelOpenSearchIndexProviderImpl,\n dependencies: [CmsModelOpenSearchIndex]\n });\n"],"names":["CmsModelOpenSearchIndexProviderImpl","indexConfig","Map","params","key","cached","shared","settings","index","result","DefaultCmsModelOpenSearchIndexProvider","CmsModelOpenSearchIndexProvider","CmsModelOpenSearchIndex"],"mappings":";;AAMA,MAAMA;IAGF,YAAoCC,WAA8C,CAAE;aAAhDA,WAAW,GAAXA;aAFnB,KAAK,GAAG,IAAIC;IAEwD;IAErF,MAAa,QACTC,MAAsC,EACS;QAC/C,MAAMC,MAAM,GAAGD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,EAAEA,OAAO,KAAK,CAAC,OAAO,EAAE;QAC5D,MAAME,SAAS,IAAI,CAAC,KAAK,CAAC,GAAG,CAACD;QAC9B,IAAIC,QACA,OAAOA;QAGX,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAACJ;QAE5D,MAAMK,QAAQ;YAACF,SAAS,SAASH,OAAO,KAAK,CAAC,MAAM;YAAE;YAAgBA,OAAO,KAAK,CAAC,OAAO;SAAC,CACtF,IAAI,CAAC,KACL,WAAW;QAEhB,MAAMM,SAAiD;YAAED;YAAOD;YAAUD;QAAO;QACjF,IAAI,CAAC,KAAK,CAAC,GAAG,CAACF,KAAKK;QACpB,OAAOA;IACX;AACJ;AAEO,MAAMC,yCACTC,gCAAgC,oBAAoB,CAAC;IACjD,gBAAgBX;IAChB,cAAc;QAACY;KAAwB;AAC3C"}
@@ -0,0 +1,4 @@
1
+ export declare const CmsModelOpenSearchIndexFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,13 @@
1
+ import { createFeature } from "@webiny/feature/api/index.js";
2
+ import { DefaultCmsModelOpenSearchIndex } from "./DefaultCmsModelOpenSearchIndex.js";
3
+ import { DefaultCmsModelOpenSearchIndexProvider } from "./DefaultCmsModelOpenSearchIndexProvider.js";
4
+ const CmsModelOpenSearchIndexFeature = createFeature({
5
+ name: "Cms/Model/OpenSearch/IndexFeature",
6
+ register: (container)=>{
7
+ container.register(DefaultCmsModelOpenSearchIndex);
8
+ container.register(DefaultCmsModelOpenSearchIndexProvider).inContainerScope();
9
+ }
10
+ });
11
+ export { CmsModelOpenSearchIndexFeature };
12
+
13
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/CmsModelOpenSearchIndex/feature.js","sources":["../../../src/features/CmsModelOpenSearchIndex/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { DefaultCmsModelOpenSearchIndex } from \"./DefaultCmsModelOpenSearchIndex.js\";\nimport { DefaultCmsModelOpenSearchIndexProvider } from \"./DefaultCmsModelOpenSearchIndexProvider.js\";\n\nexport const CmsModelOpenSearchIndexFeature = createFeature({\n name: \"Cms/Model/OpenSearch/IndexFeature\",\n register: container => {\n container.register(DefaultCmsModelOpenSearchIndex);\n container.register(DefaultCmsModelOpenSearchIndexProvider).inContainerScope();\n }\n});\n"],"names":["CmsModelOpenSearchIndexFeature","createFeature","container","DefaultCmsModelOpenSearchIndex","DefaultCmsModelOpenSearchIndexProvider"],"mappings":";;;AAIO,MAAMA,iCAAiCC,cAAc;IACxD,MAAM;IACN,UAAUC,CAAAA;QACNA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,wCAAwC,gBAAgB;IAC/E;AACJ"}
@@ -2,3 +2,6 @@ export { CmsModelOpenSearchIndex } from "./abstractions.js";
2
2
  export type { ICmsModelOpenSearchIndex, ICmsModelOpenSearchIndexParams, ICmsModelOpenSearchIndexResult } from "./abstractions.js";
3
3
  export { CmsModelOpenSearchIndexProvider } from "./CmsModelOpenSearchIndexProvider.js";
4
4
  export type { ICmsModelOpenSearchIndexProvider, ICmsModelOpenSearchIndexProviderResult } from "./CmsModelOpenSearchIndexProvider.js";
5
+ export { DefaultCmsModelOpenSearchIndex } from "./DefaultCmsModelOpenSearchIndex.js";
6
+ export { DefaultCmsModelOpenSearchIndexProvider } from "./DefaultCmsModelOpenSearchIndexProvider.js";
7
+ export { CmsModelOpenSearchIndexFeature } from "./feature.js";
@@ -1,2 +1,5 @@
1
1
  export { CmsModelOpenSearchIndex } from "./abstractions.js";
2
2
  export { CmsModelOpenSearchIndexProvider } from "./CmsModelOpenSearchIndexProvider.js";
3
+ export { DefaultCmsModelOpenSearchIndex } from "./DefaultCmsModelOpenSearchIndex.js";
4
+ export { DefaultCmsModelOpenSearchIndexProvider } from "./DefaultCmsModelOpenSearchIndexProvider.js";
5
+ export { CmsModelOpenSearchIndexFeature } from "./feature.js";
@@ -1,11 +1,11 @@
1
1
  const fieldIdentifier_hasOwnProperty = (values = {}, property)=>{
2
2
  if (!values) return false;
3
- if (values.hasOwnProperty) return values.hasOwnProperty(property);
3
+ else 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
- if (fieldIdentifier_hasOwnProperty(values, field.fieldId)) return field.fieldId;
8
+ else 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;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
+ {"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,7 +1,7 @@
1
1
  const assignMinimumShouldMatchToQuery = ({ query, value = 1 })=>{
2
2
  if (!Array.isArray(query.should)) return;
3
- if (0 === query.should.length) return;
4
- if (query.minimum_should_match) return;
3
+ else if (0 === query.should.length) return;
4
+ else 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;IACG,IAAIA,AAAwB,MAAxBA,MAAM,MAAM,CAAC,MAAM,EAC1B;IACG,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;SACG,IAAIA,AAAwB,MAAxBA,MAAM,MAAM,CAAC,MAAM,EAC1B;SACG,IAAIA,MAAM,oBAAoB,EACjC;IAEJA,MAAM,oBAAoB,GAAGC,QAAQ,IAAIA,QAAQ;AACrD"}
@@ -0,0 +1,7 @@
1
+ import type { ModelFields } from "../../../../operations/entry/elasticsearch/types.js";
2
+ import type { CmsModelField } from "@webiny/api-headless-cms/types/index.js";
3
+ /**
4
+ * Filter fields for the fields registered as `CmsEntrySystemField`. The `system` object is indexed
5
+ * as-is (raw storage ids), so a text field resolves to `system.<path>.keyword`.
6
+ */
7
+ export declare const createEntrySystemFields: (fields: CmsModelField[]) => ModelFields;
@@ -0,0 +1,58 @@
1
+ import { createSystemField } from "./createSystemField.js";
2
+ const systemParent = {
3
+ fieldId: "system",
4
+ type: "object",
5
+ storageId: "system"
6
+ };
7
+ const addFields = (result, fields, parents)=>{
8
+ for (const field of fields){
9
+ const path = [
10
+ ...parents.map((parent)=>parent.fieldId),
11
+ field.fieldId
12
+ ].join(".");
13
+ result[path] = {
14
+ type: field.type,
15
+ systemField: true,
16
+ searchable: true,
17
+ sortable: false,
18
+ parents,
19
+ field
20
+ };
21
+ const children = field.settings?.fields;
22
+ if (children?.length) addFields(result, children, [
23
+ ...parents,
24
+ {
25
+ fieldId: field.fieldId,
26
+ type: field.type,
27
+ storageId: field.storageId
28
+ }
29
+ ]);
30
+ }
31
+ };
32
+ const createEntrySystemFields = (fields)=>{
33
+ if (0 === fields.length) return {};
34
+ const result = {
35
+ system: {
36
+ type: "object",
37
+ systemField: true,
38
+ searchable: true,
39
+ sortable: false,
40
+ field: createSystemField({
41
+ storageId: "system",
42
+ fieldId: "system",
43
+ type: "object",
44
+ settings: {
45
+ fields
46
+ }
47
+ }),
48
+ parents: []
49
+ }
50
+ };
51
+ addFields(result, fields, [
52
+ systemParent
53
+ ]);
54
+ return result;
55
+ };
56
+ export { createEntrySystemFields };
57
+
58
+ //# sourceMappingURL=system.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/elasticsearch/fields/system.js","sources":["../../../../../src/operations/entry/elasticsearch/fields/system.ts"],"sourcesContent":["import type { ModelFieldParent, ModelFields } from \"~/operations/entry/elasticsearch/types.js\";\nimport type { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createSystemField } from \"./createSystemField.js\";\n\nconst systemParent: ModelFieldParent = {\n fieldId: \"system\",\n type: \"object\",\n storageId: \"system\"\n};\n\n/**\n * ObjectFilter resolves one level at a time, so every nested object needs its own entry.\n */\nconst addFields = (result: ModelFields, fields: CmsModelField[], parents: ModelFieldParent[]) => {\n for (const field of fields) {\n const path = [...parents.map(parent => parent.fieldId), field.fieldId].join(\".\");\n result[path] = {\n type: field.type,\n systemField: true,\n searchable: true,\n sortable: false,\n parents,\n field\n };\n const children = field.settings?.fields;\n if (!children?.length) {\n continue;\n }\n addFields(result, children, [\n ...parents,\n {\n fieldId: field.fieldId,\n type: field.type,\n storageId: field.storageId\n }\n ]);\n }\n};\n\n/**\n * Filter fields for the fields registered as `CmsEntrySystemField`. The `system` object is indexed\n * as-is (raw storage ids), so a text field resolves to `system.<path>.keyword`.\n */\nexport const createEntrySystemFields = (fields: CmsModelField[]): ModelFields => {\n if (fields.length === 0) {\n return {};\n }\n const result: ModelFields = {\n system: {\n type: \"object\",\n systemField: true,\n searchable: true,\n sortable: false,\n field: createSystemField({\n storageId: \"system\",\n fieldId: \"system\",\n type: \"object\",\n settings: {\n fields\n }\n }),\n parents: []\n }\n };\n addFields(result, fields, [systemParent]);\n return result;\n};\n"],"names":["systemParent","addFields","result","fields","parents","field","path","parent","children","createEntrySystemFields","createSystemField"],"mappings":";AAIA,MAAMA,eAAiC;IACnC,SAAS;IACT,MAAM;IACN,WAAW;AACf;AAKA,MAAMC,YAAY,CAACC,QAAqBC,QAAyBC;IAC7D,KAAK,MAAMC,SAASF,OAAQ;QACxB,MAAMG,OAAO;eAAIF,QAAQ,GAAG,CAACG,CAAAA,SAAUA,OAAO,OAAO;YAAGF,MAAM,OAAO;SAAC,CAAC,IAAI,CAAC;QAC5EH,MAAM,CAACI,KAAK,GAAG;YACX,MAAMD,MAAM,IAAI;YAChB,aAAa;YACb,YAAY;YACZ,UAAU;YACVD;YACAC;QACJ;QACA,MAAMG,WAAWH,MAAM,QAAQ,EAAE;QACjC,IAAKG,UAAU,QAGfP,UAAUC,QAAQM,UAAU;eACrBJ;YACH;gBACI,SAASC,MAAM,OAAO;gBACtB,MAAMA,MAAM,IAAI;gBAChB,WAAWA,MAAM,SAAS;YAC9B;SACH;IACL;AACJ;AAMO,MAAMI,0BAA0B,CAACN;IACpC,IAAIA,AAAkB,MAAlBA,OAAO,MAAM,EACb,OAAO,CAAC;IAEZ,MAAMD,SAAsB;QACxB,QAAQ;YACJ,MAAM;YACN,aAAa;YACb,YAAY;YACZ,UAAU;YACV,OAAOQ,kBAAkB;gBACrB,WAAW;gBACX,SAAS;gBACT,MAAM;gBACN,UAAU;oBACNP;gBACJ;YACJ;YACA,SAAS,EAAE;QACf;IACJ;IACAF,UAAUC,QAAQC,QAAQ;QAACH;KAAa;IACxC,OAAOE;AACX"}
@@ -1,12 +1,14 @@
1
- import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
1
+ import type { CmsModel, CmsModelField } from "@webiny/api-headless-cms/types/index.js";
2
2
  import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/features/graphql/index.js";
3
3
  import { CmsEntryOpenSearchFieldIndexRegistry } from "../../../features/CmsEntryOpenSearchFieldIndex/index.js";
4
4
  interface ICreateModelFieldsParams {
5
5
  model: CmsModel;
6
6
  fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;
7
7
  fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface;
8
+ /** Fields registered as `CmsEntrySystemField`, filterable under `system`. */
9
+ systemFields: CmsModelField[];
8
10
  }
9
- export declare const createModelFields: ({ model, fieldRegistry, fieldIndexRegistry }: ICreateModelFieldsParams) => {
11
+ export declare const createModelFields: ({ model, fieldRegistry, fieldIndexRegistry, systemFields }: ICreateModelFieldsParams) => {
10
12
  [x: string]: import("./types.js").ModelField;
11
13
  };
12
14
  export {};
@@ -5,7 +5,8 @@ import { liveFields } from "./fields/live.js";
5
5
  import { createSystemField } from "./fields/createSystemField.js";
6
6
  import { stateFields } from "./fields/state.js";
7
7
  import { locationFields } from "./fields/location.js";
8
- const createSystemFields = ()=>{
8
+ import { createEntrySystemFields } from "./fields/system.js";
9
+ const createSystemFields = (entrySystemFields)=>{
9
10
  const onMetaFields = ENTRY_META_FIELDS.filter(isDateTimeEntryMetaField).reduce((current, fieldName)=>({
10
11
  ...current,
11
12
  [fieldName]: {
@@ -128,7 +129,8 @@ const createSystemFields = ()=>{
128
129
  parents: []
129
130
  },
130
131
  ...stateFields,
131
- ...liveFields
132
+ ...liveFields,
133
+ ...createEntrySystemFields(entrySystemFields)
132
134
  };
133
135
  };
134
136
  const buildFieldsList = (params)=>{
@@ -171,7 +173,7 @@ const buildFieldsList = (params)=>{
171
173
  return result;
172
174
  }, {});
173
175
  };
174
- const createModelFields = ({ model, fieldRegistry, fieldIndexRegistry })=>{
176
+ const createModelFields = ({ model, fieldRegistry, fieldIndexRegistry, systemFields })=>{
175
177
  const fields = model.fields;
176
178
  const unmappedTypes = fieldIndexRegistry.getAll().reduce((acc, fieldIndex)=>{
177
179
  if (!fieldIndex.unmappedType) return acc;
@@ -188,7 +190,7 @@ const createModelFields = ({ model, fieldRegistry, fieldIndexRegistry })=>{
188
190
  return types;
189
191
  }, {});
190
192
  return {
191
- ...createSystemFields(),
193
+ ...createSystemFields(systemFields),
192
194
  ...buildFieldsList({
193
195
  fields,
194
196
  plugins: fieldTypePlugins,
@@ -1 +1 @@
1
- {"version":3,"file":"operations/entry/elasticsearch/fields.js","sources":["../../../../src/operations/entry/elasticsearch/fields.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { ModelFieldParent, ModelFields } from \"./types.js\";\nimport {\n ENTRY_META_FIELDS,\n isDateTimeEntryMetaField,\n isIdentityEntryMetaField\n} from \"@webiny/api-headless-cms/constants.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\nimport { liveFields } from \"./fields/live.js\";\nimport { createSystemField } from \"./fields/createSystemField.js\";\nimport { stateFields } from \"./fields/state.js\";\nimport { locationFields } from \"./fields/location.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/features/graphql/index.js\";\nimport { CmsEntryOpenSearchFieldIndexRegistry } from \"~/features/CmsEntryOpenSearchFieldIndex/index.js\";\n\nconst createSystemFields = (): ModelFields => {\n const onMetaFields = ENTRY_META_FIELDS.filter(isDateTimeEntryMetaField).reduce(\n (current, fieldName) => {\n return {\n ...current,\n [fieldName]: {\n type: \"date\",\n unmappedType: \"date\",\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: fieldName,\n fieldId: fieldName,\n type: \"text\",\n settings: {\n type: \"dateTimeWithoutTimezone\"\n }\n }),\n parents: []\n }\n };\n },\n {}\n );\n\n const byMetaFields = ENTRY_META_FIELDS.filter(isIdentityEntryMetaField).reduce(\n (current, fieldName) => {\n return {\n ...current,\n [fieldName]: {\n type: \"text\",\n unmappedType: undefined,\n systemField: true,\n searchable: true,\n sortable: true,\n path: `${fieldName}.id`,\n field: createSystemField({\n storageId: fieldName,\n fieldId: fieldName,\n type: \"text\"\n }),\n parents: []\n }\n };\n },\n {}\n );\n\n return {\n id: {\n type: \"text\",\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: \"id\",\n fieldId: \"id\",\n type: \"text\"\n }),\n parents: []\n },\n entryId: {\n type: \"text\",\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: \"entryId\",\n fieldId: \"entryId\",\n type: \"text\"\n }),\n parents: []\n },\n\n ...onMetaFields,\n ...byMetaFields,\n\n ...locationFields,\n version: {\n type: \"number\",\n unmappedType: undefined,\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: \"version\",\n fieldId: \"version\",\n type: \"number\"\n }),\n parents: []\n },\n status: {\n type: \"string\",\n unmappedType: undefined,\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: false,\n field: createSystemField({\n storageId: \"status\",\n fieldId: \"status\",\n type: \"string\"\n }),\n parents: []\n },\n wbyDeleted: {\n type: \"boolean\",\n unmappedType: undefined,\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: false,\n field: createSystemField({\n storageId: \"wbyDeleted\",\n fieldId: \"wbyDeleted\",\n type: \"boolean\"\n }),\n parents: []\n },\n binOriginalFolderId: {\n type: \"text\",\n unmappedType: undefined,\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: false,\n field: createSystemField({\n storageId: \"binOriginalFolderId\",\n fieldId: \"binOriginalFolderId\",\n type: \"text\"\n }),\n parents: []\n },\n ...stateFields,\n ...liveFields\n };\n};\n\ninterface UnmappedFieldTypes {\n [type: string]: (field: Pick<CmsModelField, \"fieldId\" | \"type\">) => string | undefined;\n}\n\ninterface FieldTypePlugin {\n unmappedType?: (field: Pick<CmsModelField, \"fieldId\" | \"type\">) => string | undefined;\n searchable: boolean;\n sortable: boolean;\n isFullTextSearchable?: boolean;\n}\n\ninterface FieldTypePlugins {\n [key: string]: FieldTypePlugin;\n}\n\ninterface BuildParams {\n plugins: FieldTypePlugins;\n fields: CmsModelField[];\n parents: ModelFieldParent[];\n}\n\nconst buildFieldsList = (params: BuildParams): ModelFields => {\n const { plugins, fields, parents } = params;\n\n return fields.reduce<ModelFields>((result, field) => {\n const fieldType = getBaseFieldType(field);\n const plugin = plugins[fieldType];\n if (!plugin) {\n throw new WebinyError(`There is no plugin for field type \"${field.type}\".`);\n }\n\n const { searchable, sortable, unmappedType, isFullTextSearchable: fullTextSearch } = plugin;\n /**\n * If a field has child fields, go through them and add them to a result.\n */\n const childFields = field.settings?.fields || [];\n if (childFields.length > 0) {\n /**\n * Let's build all the child fields\n */\n const childResult = buildFieldsList({\n fields: childFields,\n plugins,\n parents: [\n ...parents,\n {\n fieldId: field.fieldId,\n storageId: field.storageId,\n type: fieldType\n }\n ]\n });\n Object.assign(result, childResult);\n }\n\n const identifier = [...parents.map(p => p.fieldId), field.fieldId].join(\".\");\n\n result[identifier] = {\n type: fieldType,\n parents,\n searchable,\n sortable,\n fullTextSearch,\n unmappedType: typeof unmappedType === \"function\" ? unmappedType(field) : undefined,\n systemField: false,\n field\n };\n\n return result;\n }, {});\n};\n\ninterface ICreateModelFieldsParams {\n model: CmsModel;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface;\n}\n\nexport const createModelFields = ({\n model,\n fieldRegistry,\n fieldIndexRegistry\n}: ICreateModelFieldsParams) => {\n const fields = model.fields;\n /**\n * Collect all unmappedType from field index registry.\n */\n const unmappedTypes = fieldIndexRegistry\n .getAll()\n .reduce<UnmappedFieldTypes>((acc, fieldIndex) => {\n if (!fieldIndex.unmappedType) {\n return acc;\n }\n acc[fieldIndex.fieldType] = fieldIndex.unmappedType;\n return acc;\n }, {});\n /**\n * Collect all field types from the plugins.\n */\n const fieldTypePlugins = fieldRegistry.getAll().reduce<FieldTypePlugins>((types, field) => {\n types[field.fieldType] = {\n unmappedType: unmappedTypes[field.fieldType],\n searchable: field.isSearchable,\n sortable: field.isSortable,\n isFullTextSearchable: field.isFullTextSearchable\n };\n return types;\n }, {});\n\n return {\n ...createSystemFields(),\n ...buildFieldsList({\n fields,\n plugins: fieldTypePlugins,\n parents: [\n {\n fieldId: \"values\",\n type: \"object\",\n storageId: \"values\"\n }\n ]\n })\n };\n};\n"],"names":["createSystemFields","onMetaFields","ENTRY_META_FIELDS","isDateTimeEntryMetaField","current","fieldName","createSystemField","byMetaFields","isIdentityEntryMetaField","undefined","locationFields","stateFields","liveFields","buildFieldsList","params","plugins","fields","parents","result","field","fieldType","getBaseFieldType","plugin","WebinyError","searchable","sortable","unmappedType","fullTextSearch","childFields","childResult","Object","identifier","p","createModelFields","model","fieldRegistry","fieldIndexRegistry","unmappedTypes","acc","fieldIndex","fieldTypePlugins","types"],"mappings":";;;;;;;AAgBA,MAAMA,qBAAqB;IACvB,MAAMC,eAAeC,kBAAkB,MAAM,CAACC,0BAA0B,MAAM,CAC1E,CAACC,SAASC,YACC;YACH,GAAGD,OAAO;YACV,CAACC,UAAU,EAAE;gBACT,MAAM;gBACN,cAAc;gBACd,SAAS;gBACT,aAAa;gBACb,YAAY;gBACZ,UAAU;gBACV,OAAOC,kBAAkB;oBACrB,WAAWD;oBACX,SAASA;oBACT,MAAM;oBACN,UAAU;wBACN,MAAM;oBACV;gBACJ;gBACA,SAAS,EAAE;YACf;QACJ,IAEJ,CAAC;IAGL,MAAME,eAAeL,kBAAkB,MAAM,CAACM,0BAA0B,MAAM,CAC1E,CAACJ,SAASC,YACC;YACH,GAAGD,OAAO;YACV,CAACC,UAAU,EAAE;gBACT,MAAM;gBACN,cAAcI;gBACd,aAAa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,WAAW,YAAY;QACnD,OAAOD;IACX,GAAG,CAAC;IAIR,MAAME,mBAAmBL,cAAc,MAAM,GAAG,MAAM,CAAmB,CAACM,OAAOtB;QAC7EsB,KAAK,CAACtB,MAAM,SAAS,CAAC,GAAG;YACrB,cAAckB,aAAa,CAAClB,MAAM,SAAS,CAAC;YAC5C,YAAYA,MAAM,YAAY;YAC9B,UAAUA,MAAM,UAAU;YAC1B,sBAAsBA,MAAM,oBAAoB;QACpD;QACA,OAAOsB;IACX,GAAG,CAAC;IAEJ,OAAO;QACH,GAAGzC,oBAAoB;QACvB,GAAGa,gBAAgB;YACfG;YACA,SAASwB;YACT,SAAS;gBACL;oBACI,SAAS;oBACT,MAAM;oBACN,WAAW;gBACf;aACH;QACL,EAAE;IACN;AACJ"}
1
+ {"version":3,"file":"operations/entry/elasticsearch/fields.js","sources":["../../../../src/operations/entry/elasticsearch/fields.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { ModelFieldParent, ModelFields } from \"./types.js\";\nimport {\n ENTRY_META_FIELDS,\n isDateTimeEntryMetaField,\n isIdentityEntryMetaField\n} from \"@webiny/api-headless-cms/constants.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\nimport { liveFields } from \"./fields/live.js\";\nimport { createSystemField } from \"./fields/createSystemField.js\";\nimport { stateFields } from \"./fields/state.js\";\nimport { locationFields } from \"./fields/location.js\";\nimport { createEntrySystemFields } from \"./fields/system.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/features/graphql/index.js\";\nimport { CmsEntryOpenSearchFieldIndexRegistry } from \"~/features/CmsEntryOpenSearchFieldIndex/index.js\";\n\nconst createSystemFields = (entrySystemFields: CmsModelField[]): ModelFields => {\n const onMetaFields = ENTRY_META_FIELDS.filter(isDateTimeEntryMetaField).reduce(\n (current, fieldName) => {\n return {\n ...current,\n [fieldName]: {\n type: \"date\",\n unmappedType: \"date\",\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: fieldName,\n fieldId: fieldName,\n type: \"text\",\n settings: {\n type: \"dateTimeWithoutTimezone\"\n }\n }),\n parents: []\n }\n };\n },\n {}\n );\n\n const byMetaFields = ENTRY_META_FIELDS.filter(isIdentityEntryMetaField).reduce(\n (current, fieldName) => {\n return {\n ...current,\n [fieldName]: {\n type: \"text\",\n unmappedType: undefined,\n systemField: true,\n searchable: true,\n sortable: true,\n path: `${fieldName}.id`,\n field: createSystemField({\n storageId: fieldName,\n fieldId: fieldName,\n type: \"text\"\n }),\n parents: []\n }\n };\n },\n {}\n );\n\n return {\n id: {\n type: \"text\",\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: \"id\",\n fieldId: \"id\",\n type: \"text\"\n }),\n parents: []\n },\n entryId: {\n type: \"text\",\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: \"entryId\",\n fieldId: \"entryId\",\n type: \"text\"\n }),\n parents: []\n },\n\n ...onMetaFields,\n ...byMetaFields,\n\n ...locationFields,\n version: {\n type: \"number\",\n unmappedType: undefined,\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: true,\n field: createSystemField({\n storageId: \"version\",\n fieldId: \"version\",\n type: \"number\"\n }),\n parents: []\n },\n status: {\n type: \"string\",\n unmappedType: undefined,\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: false,\n field: createSystemField({\n storageId: \"status\",\n fieldId: \"status\",\n type: \"string\"\n }),\n parents: []\n },\n wbyDeleted: {\n type: \"boolean\",\n unmappedType: undefined,\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: false,\n field: createSystemField({\n storageId: \"wbyDeleted\",\n fieldId: \"wbyDeleted\",\n type: \"boolean\"\n }),\n parents: []\n },\n binOriginalFolderId: {\n type: \"text\",\n unmappedType: undefined,\n keyword: false,\n systemField: true,\n searchable: true,\n sortable: false,\n field: createSystemField({\n storageId: \"binOriginalFolderId\",\n fieldId: \"binOriginalFolderId\",\n type: \"text\"\n }),\n parents: []\n },\n ...stateFields,\n ...liveFields,\n ...createEntrySystemFields(entrySystemFields)\n };\n};\n\ninterface UnmappedFieldTypes {\n [type: string]: (field: Pick<CmsModelField, \"fieldId\" | \"type\">) => string | undefined;\n}\n\ninterface FieldTypePlugin {\n unmappedType?: (field: Pick<CmsModelField, \"fieldId\" | \"type\">) => string | undefined;\n searchable: boolean;\n sortable: boolean;\n isFullTextSearchable?: boolean;\n}\n\ninterface FieldTypePlugins {\n [key: string]: FieldTypePlugin;\n}\n\ninterface BuildParams {\n plugins: FieldTypePlugins;\n fields: CmsModelField[];\n parents: ModelFieldParent[];\n}\n\nconst buildFieldsList = (params: BuildParams): ModelFields => {\n const { plugins, fields, parents } = params;\n\n return fields.reduce<ModelFields>((result, field) => {\n const fieldType = getBaseFieldType(field);\n const plugin = plugins[fieldType];\n if (!plugin) {\n throw new WebinyError(`There is no plugin for field type \"${field.type}\".`);\n }\n\n const { searchable, sortable, unmappedType, isFullTextSearchable: fullTextSearch } = plugin;\n /**\n * If a field has child fields, go through them and add them to a result.\n */\n const childFields = field.settings?.fields || [];\n if (childFields.length > 0) {\n /**\n * Let's build all the child fields\n */\n const childResult = buildFieldsList({\n fields: childFields,\n plugins,\n parents: [\n ...parents,\n {\n fieldId: field.fieldId,\n storageId: field.storageId,\n type: fieldType\n }\n ]\n });\n Object.assign(result, childResult);\n }\n\n const identifier = [...parents.map(p => p.fieldId), field.fieldId].join(\".\");\n\n result[identifier] = {\n type: fieldType,\n parents,\n searchable,\n sortable,\n fullTextSearch,\n unmappedType: typeof unmappedType === \"function\" ? unmappedType(field) : undefined,\n systemField: false,\n field\n };\n\n return result;\n }, {});\n};\n\ninterface ICreateModelFieldsParams {\n model: CmsModel;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface;\n /** Fields registered as `CmsEntrySystemField`, filterable under `system`. */\n systemFields: CmsModelField[];\n}\n\nexport const createModelFields = ({\n model,\n fieldRegistry,\n fieldIndexRegistry,\n systemFields\n}: ICreateModelFieldsParams) => {\n const fields = model.fields;\n /**\n * Collect all unmappedType from field index registry.\n */\n const unmappedTypes = fieldIndexRegistry\n .getAll()\n .reduce<UnmappedFieldTypes>((acc, fieldIndex) => {\n if (!fieldIndex.unmappedType) {\n return acc;\n }\n acc[fieldIndex.fieldType] = fieldIndex.unmappedType;\n return acc;\n }, {});\n /**\n * Collect all field types from the plugins.\n */\n const fieldTypePlugins = fieldRegistry.getAll().reduce<FieldTypePlugins>((types, field) => {\n types[field.fieldType] = {\n unmappedType: unmappedTypes[field.fieldType],\n searchable: field.isSearchable,\n sortable: field.isSortable,\n isFullTextSearchable: field.isFullTextSearchable\n };\n return types;\n }, {});\n\n return {\n ...createSystemFields(systemFields),\n ...buildFieldsList({\n fields,\n plugins: fieldTypePlugins,\n parents: [\n {\n fieldId: \"values\",\n type: \"object\",\n storageId: \"values\"\n }\n ]\n })\n };\n};\n"],"names":["createSystemFields","entrySystemFields","onMetaFields","ENTRY_META_FIELDS","isDateTimeEntryMetaField","current","fieldName","createSystemField","byMetaFields","isIdentityEntryMetaField","undefined","locationFields","stateFields","liveFields","createEntrySystemFields","buildFieldsList","params","plugins","fields","parents","result","field","fieldType","getBaseFieldType","plugin","WebinyError","searchable","sortable","unmappedType","fullTextSearch","childFields","childResult","Object","identifier","p","createModelFields","model","fieldRegistry","fieldIndexRegistry","systemFields","unmappedTypes","acc","fieldIndex","fieldTypePlugins","types"],"mappings":";;;;;;;;AAiBA,MAAMA,qBAAqB,CAACC;IACxB,MAAMC,eAAeC,kBAAkB,MAAM,CAACC,0BAA0B,MAAM,CAC1E,CAACC,SAASC,YACC;YACH,GAAGD,OAAO;YACV,CAACC,UAAU,EAAE;gBACT,MAAM;gBACN,cAAc;gBACd,SAAS;gBACT,aAAa;gBACb,YAAY;gBACZ,UA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,SAASX;YACzE,aAAa;YACbW;QACJ;QAEA,OAAOD;IACX,GAAG,CAAC;AACR;AAUO,MAAMe,oBAAoB,CAAC,EAC9BC,KAAK,EACLC,aAAa,EACbC,kBAAkB,EAClBC,YAAY,EACW;IACvB,MAAMrB,SAASkB,MAAM,MAAM;IAI3B,MAAMI,gBAAgBF,mBACjB,MAAM,GACN,MAAM,CAAqB,CAACG,KAAKC;QAC9B,IAAI,CAACA,WAAW,YAAY,EACxB,OAAOD;QAEXA,GAAG,CAACC,WAAW,SAAS,CAAC,GAAGA,WAAW,YAAY;QACnD,OAAOD;IACX,GAAG,CAAC;IAIR,MAAME,mBAAmBN,cAAc,MAAM,GAAG,MAAM,CAAmB,CAACO,OAAOvB;QAC7EuB,KAAK,CAACvB,MAAM,SAAS,CAAC,GAAG;YACrB,cAAcmB,aAAa,CAACnB,MAAM,SAAS,CAAC;YAC5C,YAAYA,MAAM,YAAY;YAC9B,UAAUA,MAAM,UAAU;YAC1B,sBAAsBA,MAAM,oBAAoB;QACpD;QACA,OAAOuB;IACX,GAAG,CAAC;IAEJ,OAAO;QACH,GAAG5C,mBAAmBuC,aAAa;QACnC,GAAGxB,gBAAgB;YACfG;YACA,SAASyB;YACT,SAAS;gBACL;oBACI,SAAS;oBACT,MAAM;oBACN,WAAW;gBACf;aACH;QACL,EAAE;IACN;AACJ"}
@@ -5,6 +5,7 @@ const defaultFullTextSearch = {
5
5
  query.must.push({
6
6
  query_string: {
7
7
  allow_leading_wildcard: true,
8
+ lenient: true,
8
9
  fields: Object.values(fields).map(createFieldPath),
9
10
  query: `*${prepareTerm(term)}*`,
10
11
  default_operator: "and"
@@ -21,7 +22,7 @@ const getFullTextSearch = (params)=>{
21
22
  for (const item of reversed){
22
23
  const models = item.models || [];
23
24
  if (models.includes(model.modelId)) return item;
24
- if (!fallback && 0 === models.length) fallback = item;
25
+ else if (!fallback && 0 === models.length) fallback = item;
25
26
  }
26
27
  return fallback || defaultFullTextSearch;
27
28
  };
@@ -37,8 +38,16 @@ const applyFullTextSearch = (params)=>{
37
38
  model,
38
39
  createFieldPath: (field)=>{
39
40
  if ("function" == typeof field.path) return field.path(term);
40
- if (field.systemField) return field.path || field.field.storageId;
41
- return `values.${field.path || field.field.storageId}`;
41
+ else if (field.systemField) return field.path || field.field.storageId;
42
+ const parents = field.parents.length > 0 ? field.parents.map((p)=>p.storageId) : [
43
+ "values"
44
+ ];
45
+ const path = [
46
+ ...parents,
47
+ field.path || field.field.storageId
48
+ ].join(".");
49
+ if ("searchable-json" === field.type) return `${path}.*`;
50
+ return path;
42
51
  },
43
52
  fields,
44
53
  query,