@webiny/api-headless-cms-ddb-es 6.0.0 → 6.1.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 (92) hide show
  1. package/configurations.d.ts +2 -2
  2. package/configurations.js +2 -2
  3. package/configurations.js.map +1 -1
  4. package/elasticsearch/createElasticsearchIndex.d.ts +1 -1
  5. package/elasticsearch/createElasticsearchIndex.js +1 -1
  6. package/elasticsearch/createElasticsearchIndex.js.map +1 -1
  7. package/elasticsearch/deleteElasticsearchIndex.d.ts +1 -1
  8. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
  9. package/elasticsearch/indexing/dateTimeIndexing.js +0 -6
  10. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
  11. package/elasticsearch/indices/base.js +1 -1
  12. package/elasticsearch/indices/base.js.map +1 -1
  13. package/index.js +6 -6
  14. package/index.js.map +1 -1
  15. package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -0
  16. package/operations/entry/dataLoader/DataLoaderCache.js +2 -5
  17. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
  18. package/operations/entry/dataLoader/getAllEntryRevisions.js +5 -2
  19. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
  20. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +5 -1
  21. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
  22. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +5 -1
  23. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
  24. package/operations/entry/dataLoader/getRevisionById.js +5 -1
  25. package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
  26. package/operations/entry/dataLoader/types.d.ts +1 -0
  27. package/operations/entry/dataLoader/types.js.map +1 -1
  28. package/operations/entry/dataLoaders.js +3 -1
  29. package/operations/entry/dataLoaders.js.map +1 -1
  30. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +1 -1
  31. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
  32. package/operations/entry/elasticsearch/body.d.ts +1 -1
  33. package/operations/entry/elasticsearch/body.js.map +1 -1
  34. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +3 -3
  35. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
  36. package/operations/entry/elasticsearch/filtering/exec.d.ts +2 -2
  37. package/operations/entry/elasticsearch/filtering/exec.js +1 -1
  38. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
  39. package/operations/entry/elasticsearch/filtering/path.d.ts +2 -2
  40. package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
  41. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +1 -1
  42. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -1
  43. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +1 -1
  44. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -1
  45. package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -2
  46. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
  47. package/operations/entry/elasticsearch/fullTextSearch.d.ts +2 -2
  48. package/operations/entry/elasticsearch/fullTextSearch.js +1 -1
  49. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
  50. package/operations/entry/elasticsearch/initialQuery.d.ts +3 -3
  51. package/operations/entry/elasticsearch/initialQuery.js +1 -1
  52. package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
  53. package/operations/entry/elasticsearch/plugins/operator.d.ts +2 -2
  54. package/operations/entry/elasticsearch/plugins/operator.js +2 -2
  55. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
  56. package/operations/entry/elasticsearch/plugins/search.d.ts +2 -2
  57. package/operations/entry/elasticsearch/plugins/search.js.map +1 -1
  58. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +1 -1
  59. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -1
  60. package/operations/entry/elasticsearch/sort.d.ts +2 -2
  61. package/operations/entry/elasticsearch/sort.js +4 -4
  62. package/operations/entry/elasticsearch/sort.js.map +1 -1
  63. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +2 -2
  64. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
  65. package/operations/entry/elasticsearch/types.d.ts +4 -4
  66. package/operations/entry/elasticsearch/types.js.map +1 -1
  67. package/operations/entry/index.d.ts +2 -2
  68. package/operations/entry/index.js +1 -1
  69. package/operations/entry/index.js.map +1 -1
  70. package/operations/entry/transformations/index.js +1 -1
  71. package/operations/entry/transformations/index.js.map +1 -1
  72. package/operations/model/index.d.ts +1 -1
  73. package/operations/model/index.js.map +1 -1
  74. package/package.json +22 -23
  75. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +3 -3
  76. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +2 -2
  77. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
  78. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +2 -2
  79. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -1
  80. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +2 -2
  81. package/plugins/CmsEntryElasticsearchIndexPlugin.js +2 -2
  82. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
  83. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +3 -3
  84. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +2 -2
  85. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
  86. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +3 -3
  87. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +2 -2
  88. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
  89. package/plugins/CmsEntryFilterPlugin.d.ts +3 -3
  90. package/plugins/CmsEntryFilterPlugin.js.map +1 -1
  91. package/types.d.ts +2 -2
  92. package/types.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"names":["transformEntryKeys","transformEntryToIndex","CmsEntryElasticsearchValuesModifier","modifyEntryValues","modifyEntryValuesCallable","compress","createLatestRecordType","createPublishedRecordType","WebinyError","createTransformer","params","plugins","model","entry","baseEntry","storageEntry","baseStorageEntry","transformedToIndex","initialTransformedEntryToIndex","undefined","transformedEntryKeys","transformedEntryToIndex","modifiedEntryValues","elasticsearchLatestEntry","elasticsearchPublishedEntry","modifierPlugins","byType","type","filter","pl","canModify","modelId","modifiedEntry","modifiedStorageEntry","transformToIndex","length","result","getElasticsearchLatestEntryData","latest","TYPE","__type","getElasticsearchPublishedEntryData","published"],"sources":["index.ts"],"sourcesContent":["import type { PluginsContainer } from \"@webiny/plugins\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsStorageEntry,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { transformEntryKeys } from \"./transformEntryKeys.js\";\nimport type { CmsIndexEntry } from \"~/types.js\";\nimport { transformEntryToIndex } from \"~/operations/entry/transformations/transformEntryToIndex.js\";\nimport { CmsEntryElasticsearchValuesModifier } from \"~/plugins/index.js\";\nimport { modifyEntryValues as modifyEntryValuesCallable } from \"~/operations/entry/transformations/modifyEntryValues.js\";\nimport { compress } from \"@webiny/api-elasticsearch\";\nimport {\n createLatestRecordType,\n createPublishedRecordType\n} from \"~/operations/entry/recordType.js\";\nimport WebinyError from \"@webiny/error\";\n\ninterface BaseTransformerParams<T extends CmsEntryValues = CmsEntryValues> {\n plugins: PluginsContainer;\n model: StorageOperationsCmsModel<T>;\n}\n\ninterface EntryTransformerParams<T extends CmsEntryValues = CmsEntryValues>\n extends BaseTransformerParams<T> {\n entry: CmsEntry<T>;\n storageEntry: CmsEntry<T>;\n transformedToIndex?: never;\n}\n\ninterface TransformedEntryTransformerParams<T extends CmsEntryValues = CmsEntryValues>\n extends BaseTransformerParams<T> {\n entry?: never;\n storageEntry?: never;\n transformedToIndex: CmsIndexEntry<T>;\n}\n\ninterface TransformedKeysEntry<T extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<T>;\n storageEntry: CmsEntry<T>;\n}\n\ninterface ModifiedEntryValues<T extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<T>;\n storageEntry: CmsEntry<T>;\n}\n\ninterface TransformerResult<T extends CmsEntryValues = CmsEntryValues> {\n transformEntryKeys: () => TransformedKeysEntry<T>;\n transformToIndex: () => CmsIndexEntry<T>;\n getElasticsearchLatestEntryData: () => Promise<Record<string, any>>;\n getElasticsearchPublishedEntryData: () => Promise<Record<string, any>>;\n}\n\nexport const createTransformer = <T extends CmsEntryValues = CmsEntryValues>(\n params: EntryTransformerParams<T> | TransformedEntryTransformerParams<T>\n): TransformerResult<T> => {\n const {\n plugins,\n model,\n entry: baseEntry,\n storageEntry: baseStorageEntry,\n transformedToIndex: initialTransformedEntryToIndex = undefined\n } = params;\n\n let transformedEntryKeys: TransformedKeysEntry<T> | undefined = undefined;\n let transformedEntryToIndex: CmsIndexEntry<T> | undefined = initialTransformedEntryToIndex;\n let modifiedEntryValues: ModifiedEntryValues<T> | undefined = undefined;\n let elasticsearchLatestEntry: any = undefined;\n let elasticsearchPublishedEntry: any = undefined;\n\n const modifierPlugins = plugins\n .byType<CmsEntryElasticsearchValuesModifier>(CmsEntryElasticsearchValuesModifier.type)\n .filter(pl => pl.canModify(model.modelId));\n\n const modifyEntryValues = () => {\n if (initialTransformedEntryToIndex || !baseEntry) {\n throw new WebinyError(\n `Should not call the \"modifyEntryValues\" when \"transformedToIndex\" is provided.`,\n \"METHOD_NOT_ALLOWED\",\n {\n entry: initialTransformedEntryToIndex\n }\n );\n }\n if (modifiedEntryValues) {\n return modifiedEntryValues;\n }\n const modifiedEntry = modifyEntryValuesCallable<T>({\n plugins: modifierPlugins,\n model,\n entry: baseEntry\n });\n const modifiedStorageEntry = modifyEntryValuesCallable<T>({\n plugins: modifierPlugins,\n model,\n entry: baseStorageEntry\n });\n\n return (modifiedEntryValues = transformEntryKeys<T>({\n model,\n entry: modifiedEntry,\n storageEntry: modifiedStorageEntry\n }));\n };\n\n return {\n transformEntryKeys: function () {\n if (initialTransformedEntryToIndex || !baseEntry) {\n throw new WebinyError(\n `Should not call the \"modifyEntryValues\" when \"transformedToIndex\" is provided.`,\n \"METHOD_NOT_ALLOWED\",\n {\n entry: initialTransformedEntryToIndex\n }\n );\n }\n if (transformedEntryKeys) {\n return transformedEntryKeys;\n }\n return (transformedEntryKeys = transformEntryKeys({\n model,\n entry: baseEntry,\n storageEntry: baseStorageEntry\n }));\n },\n transformToIndex: function () {\n if (transformedEntryToIndex) {\n return transformedEntryToIndex;\n }\n let entry: CmsEntry<T>;\n let storageEntry: CmsStorageEntry<T>;\n /**\n * In case there are value modifier plugins, we need to\n * - run modifiers\n * - transform keys\n */\n if (modifierPlugins.length > 0) {\n const result = modifyEntryValues();\n entry = result.entry;\n storageEntry = result.storageEntry;\n }\n // In case there are no modifier plugins, just transform the keys - or used already transformed.\n else {\n const result = this.transformEntryKeys();\n entry = result.entry;\n storageEntry = result.storageEntry;\n }\n return (transformedEntryToIndex = transformEntryToIndex<T>({\n plugins,\n model,\n entry,\n storageEntry\n }));\n },\n getElasticsearchLatestEntryData: async function () {\n if (elasticsearchLatestEntry) {\n return elasticsearchLatestEntry;\n }\n const entry = this.transformToIndex();\n\n return (elasticsearchLatestEntry = await compress(plugins, {\n ...entry,\n latest: true,\n TYPE: createLatestRecordType(),\n __type: createLatestRecordType()\n }));\n },\n getElasticsearchPublishedEntryData: async function () {\n if (elasticsearchPublishedEntry) {\n return elasticsearchPublishedEntry;\n }\n const entry = this.transformToIndex();\n\n return (elasticsearchPublishedEntry = await compress(plugins, {\n ...entry,\n published: true,\n TYPE: createPublishedRecordType(),\n __type: createPublishedRecordType()\n }));\n }\n };\n};\n"],"mappings":"AAOA,SAASA,kBAAkB;AAE3B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AAwB;MACnC;MACA,MAAMV,KAAK,GAAG,IAAI,CAACqB,gBAAgB,CAAC,CAAC;MAErC,OAAQX,wBAAwB,GAAG,MAAMlB,QAAQ,CAACM,OAAO,EAAE;QACvD,GAAGE,KAAK;QACRyB,MAAM,EAAE,IAAI;QACZC,IAAI,EAAEjC,sBAAsB,CAAC,CAAC;QAC9BkC,MAAM,EAAElC,sBAAsB,CAAC;MACnC,CAAC,CAAC;IACN,CAAC;IACDmC,kCAAkC,EAAE,eAAAA,CAAA,EAAkB;MAClD,IAAIjB,2BAA2B,EAAE;QAC7B,OAAOA,2BAA2B;MACtC;MACA,MAAMX,KAAK,GAAG,IAAI,CAACqB,gBAAgB,CAAC,CAAC;MAErC,OAAQV,2BAA2B,GAAG,MAAMnB,QAAQ,CAACM,OAAO,EAAE;QAC1D,GAAGE,KAAK;QACR6B,SAAS,EAAE,IAAI;QACfH,IAAI,EAAEhC,yBAAyB,CAAC,CAAC;QACjCiC,MAAM,EAAEjC,yBAAyB,CAAC;MACtC,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["transformEntryKeys","transformEntryToIndex","CmsEntryElasticsearchValuesModifier","modifyEntryValues","modifyEntryValuesCallable","compress","createLatestRecordType","createPublishedRecordType","WebinyError","createTransformer","params","plugins","model","entry","baseEntry","storageEntry","baseStorageEntry","transformedToIndex","initialTransformedEntryToIndex","undefined","transformedEntryKeys","transformedEntryToIndex","modifiedEntryValues","elasticsearchLatestEntry","elasticsearchPublishedEntry","modifierPlugins","byType","type","filter","pl","canModify","modelId","modifiedEntry","modifiedStorageEntry","transformToIndex","length","result","getElasticsearchLatestEntryData","latest","TYPE","__type","getElasticsearchPublishedEntryData","published"],"sources":["index.ts"],"sourcesContent":["import type { PluginsContainer } from \"@webiny/plugins\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsStorageEntry,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { transformEntryKeys } from \"./transformEntryKeys.js\";\nimport type { CmsIndexEntry } from \"~/types.js\";\nimport { transformEntryToIndex } from \"~/operations/entry/transformations/transformEntryToIndex.js\";\nimport { CmsEntryElasticsearchValuesModifier } from \"~/plugins/index.js\";\nimport { modifyEntryValues as modifyEntryValuesCallable } from \"~/operations/entry/transformations/modifyEntryValues.js\";\nimport { compress } from \"@webiny/api-opensearch\";\nimport {\n createLatestRecordType,\n createPublishedRecordType\n} from \"~/operations/entry/recordType.js\";\nimport WebinyError from \"@webiny/error\";\n\ninterface BaseTransformerParams<T extends CmsEntryValues = CmsEntryValues> {\n plugins: PluginsContainer;\n model: StorageOperationsCmsModel<T>;\n}\n\ninterface EntryTransformerParams<T extends CmsEntryValues = CmsEntryValues>\n extends BaseTransformerParams<T> {\n entry: CmsEntry<T>;\n storageEntry: CmsEntry<T>;\n transformedToIndex?: never;\n}\n\ninterface TransformedEntryTransformerParams<T extends CmsEntryValues = CmsEntryValues>\n extends BaseTransformerParams<T> {\n entry?: never;\n storageEntry?: never;\n transformedToIndex: CmsIndexEntry<T>;\n}\n\ninterface TransformedKeysEntry<T extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<T>;\n storageEntry: CmsEntry<T>;\n}\n\ninterface ModifiedEntryValues<T extends CmsEntryValues = CmsEntryValues> {\n entry: CmsEntry<T>;\n storageEntry: CmsEntry<T>;\n}\n\ninterface TransformerResult<T extends CmsEntryValues = CmsEntryValues> {\n transformEntryKeys: () => TransformedKeysEntry<T>;\n transformToIndex: () => CmsIndexEntry<T>;\n getElasticsearchLatestEntryData: () => Promise<Record<string, any>>;\n getElasticsearchPublishedEntryData: () => Promise<Record<string, any>>;\n}\n\nexport const createTransformer = <T extends CmsEntryValues = CmsEntryValues>(\n params: EntryTransformerParams<T> | TransformedEntryTransformerParams<T>\n): TransformerResult<T> => {\n const {\n plugins,\n model,\n entry: baseEntry,\n storageEntry: baseStorageEntry,\n transformedToIndex: initialTransformedEntryToIndex = undefined\n } = params;\n\n let transformedEntryKeys: TransformedKeysEntry<T> | undefined = undefined;\n let transformedEntryToIndex: CmsIndexEntry<T> | undefined = initialTransformedEntryToIndex;\n let modifiedEntryValues: ModifiedEntryValues<T> | undefined = undefined;\n let elasticsearchLatestEntry: any = undefined;\n let elasticsearchPublishedEntry: any = undefined;\n\n const modifierPlugins = plugins\n .byType<CmsEntryElasticsearchValuesModifier>(CmsEntryElasticsearchValuesModifier.type)\n .filter(pl => pl.canModify(model.modelId));\n\n const modifyEntryValues = () => {\n if (initialTransformedEntryToIndex || !baseEntry) {\n throw new WebinyError(\n `Should not call the \"modifyEntryValues\" when \"transformedToIndex\" is provided.`,\n \"METHOD_NOT_ALLOWED\",\n {\n entry: initialTransformedEntryToIndex\n }\n );\n }\n if (modifiedEntryValues) {\n return modifiedEntryValues;\n }\n const modifiedEntry = modifyEntryValuesCallable<T>({\n plugins: modifierPlugins,\n model,\n entry: baseEntry\n });\n const modifiedStorageEntry = modifyEntryValuesCallable<T>({\n plugins: modifierPlugins,\n model,\n entry: baseStorageEntry\n });\n\n return (modifiedEntryValues = transformEntryKeys<T>({\n model,\n entry: modifiedEntry,\n storageEntry: modifiedStorageEntry\n }));\n };\n\n return {\n transformEntryKeys: function () {\n if (initialTransformedEntryToIndex || !baseEntry) {\n throw new WebinyError(\n `Should not call the \"modifyEntryValues\" when \"transformedToIndex\" is provided.`,\n \"METHOD_NOT_ALLOWED\",\n {\n entry: initialTransformedEntryToIndex\n }\n );\n }\n if (transformedEntryKeys) {\n return transformedEntryKeys;\n }\n return (transformedEntryKeys = transformEntryKeys({\n model,\n entry: baseEntry,\n storageEntry: baseStorageEntry\n }));\n },\n transformToIndex: function () {\n if (transformedEntryToIndex) {\n return transformedEntryToIndex;\n }\n let entry: CmsEntry<T>;\n let storageEntry: CmsStorageEntry<T>;\n /**\n * In case there are value modifier plugins, we need to\n * - run modifiers\n * - transform keys\n */\n if (modifierPlugins.length > 0) {\n const result = modifyEntryValues();\n entry = result.entry;\n storageEntry = result.storageEntry;\n }\n // In case there are no modifier plugins, just transform the keys - or used already transformed.\n else {\n const result = this.transformEntryKeys();\n entry = result.entry;\n storageEntry = result.storageEntry;\n }\n return (transformedEntryToIndex = transformEntryToIndex<T>({\n plugins,\n model,\n entry,\n storageEntry\n }));\n },\n getElasticsearchLatestEntryData: async function () {\n if (elasticsearchLatestEntry) {\n return elasticsearchLatestEntry;\n }\n const entry = this.transformToIndex();\n\n return (elasticsearchLatestEntry = await compress(plugins, {\n ...entry,\n latest: true,\n TYPE: createLatestRecordType(),\n __type: createLatestRecordType()\n }));\n },\n getElasticsearchPublishedEntryData: async function () {\n if (elasticsearchPublishedEntry) {\n return elasticsearchPublishedEntry;\n }\n const entry = this.transformToIndex();\n\n return (elasticsearchPublishedEntry = await compress(plugins, {\n ...entry,\n published: true,\n TYPE: createPublishedRecordType(),\n __type: createPublishedRecordType()\n }));\n }\n };\n};\n"],"mappings":"AAOA,SAASA,kBAAkB;AAE3B,SAASC,qBAAqB;AAC9B,SAASC,mCAAmC;AAC5C,SAASC,iBAAiB,IAAIC,yBAAyB;AACvD,SAASC,QAAQ,QAAQ,wBAAwB;AACjD,SACIC,sBAAsB,EACtBC,yBAAyB;AAE7B,OAAOC,WAAW,MAAM,eAAe;AAsCvC,OAAO,MAAMC,iBAAiB,GAC1BC,MAAwE,IACjD;EACvB,MAAM;IACFC,OAAO;IACPC,KAAK;IACLC,KAAK,EAAEC,SAAS;IAChBC,YAAY,EAAEC,gBAAgB;IAC9BC,kBAAkB,EAAEC,8BAA8B,GAAGC;EACzD,CAAC,GAAGT,MAAM;EAEV,IAAIU,oBAAyD,GAAGD,SAAS;EACzE,IAAIE,uBAAqD,GAAGH,8BAA8B;EAC1F,IAAII,mBAAuD,GAAGH,SAAS;EACvE,IAAII,wBAA6B,GAAGJ,SAAS;EAC7C,IAAIK,2BAAgC,GAAGL,SAAS;EAEhD,MAAMM,eAAe,GAAGd,OAAO,CAC1Be,MAAM,CAAsCxB,mCAAmC,CAACy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AC,CAAC;IACN;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import type { CmsModelStorageOperations } from "@webiny/api-headless-cms/types/index.js";
2
- import type { Client } from "@elastic/elasticsearch";
2
+ import type { Client } from "@webiny/api-opensearch";
3
3
  import type { IModelEntity } from "../../definitions/types.js";
4
4
  export interface CreateModelsStorageOperationsParams {
5
5
  entity: IModelEntity;
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","configurations","createPartitionKey","params","tenant","createSortKey","modelId","createKeys","Error","PK","SK","GSI_TENANT","createType","createModelsStorageOperations","entity","elasticsearch","create","model","index","es","keys","error","put","data","TYPE","ex","indices","delete","ignore_unavailable","dynamodbError","elasticsearchError","update","message","code","deleteModel","get","result","list","where","partitionKey","queryAll","options","gte","map","item"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModelStorageOperations,\n CmsModelStorageOperationsCreateParams,\n CmsModelStorageOperationsDeleteParams,\n CmsModelStorageOperationsGetParams,\n CmsModelStorageOperationsListParams,\n CmsModelStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { configurations } from \"~/configurations.js\";\nimport type { Client } from \"@elastic/elasticsearch\";\nimport type { IModelEntity } from \"~/definitions/types.js\";\n\ninterface PartitionKeysParams {\n tenant: string;\n}\n\nconst createPartitionKey = (params: PartitionKeysParams): string => {\n const { tenant } = params;\n return `T#${tenant}#CMS#CM`;\n};\n\ninterface SortKeyParams {\n modelId: string;\n}\n\nconst createSortKey = (params: SortKeyParams): string => {\n return params.modelId;\n};\n\ninterface IDynamoDbTableKeys {\n PK: string;\n SK: string;\n GSI_TENANT: string;\n}\n\nconst createKeys = (params: PartitionKeysParams & SortKeyParams): IDynamoDbTableKeys => {\n if (!params.tenant) {\n throw new Error(\"Missing tenant when creating model keys!\");\n }\n return {\n PK: createPartitionKey(params),\n SK: createSortKey(params),\n GSI_TENANT: params.tenant\n };\n};\n\nconst createType = (): string => {\n return \"cms.model\";\n};\n\nexport interface CreateModelsStorageOperationsParams {\n entity: IModelEntity;\n elasticsearch: Client;\n}\n\nexport const createModelsStorageOperations = (\n params: CreateModelsStorageOperationsParams\n): CmsModelStorageOperations => {\n const { entity, elasticsearch } = params;\n\n const create = async (params: CmsModelStorageOperationsCreateParams) => {\n const { model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n const keys = createKeys(model);\n\n let error;\n try {\n await entity.put({\n data: model,\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n error = ex;\n }\n /**\n * In case of DynamoDB error we need to remove the index we created.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record failed to be created.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n dynamodbError: error,\n elasticsearchError: ex\n }\n );\n }\n throw error;\n };\n\n const update = async (params: CmsModelStorageOperationsUpdateParams) => {\n const { model } = params;\n\n const keys = createKeys(model);\n\n try {\n await entity.put({\n data: model,\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update model.\",\n ex.code || \"MODEL_UPDATE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n };\n\n const deleteModel = async (params: CmsModelStorageOperationsDeleteParams) => {\n const { model } = params;\n const keys = createKeys(model);\n\n const { index } = configurations.es({\n model\n });\n\n try {\n await entity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete model.\",\n ex.code || \"MODEL_DELETE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n /**\n * Always delete the model index after deleting the model.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record delete.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n error: ex,\n index,\n model\n }\n );\n }\n\n return model;\n };\n\n const get = async (params: CmsModelStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const result = await entity.get(keys);\n\n return result ? result.data : null;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get model.\",\n ex.code || \"MODEL_GET_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n const list = async (params: CmsModelStorageOperationsListParams) => {\n const { where } = params;\n const partitionKey = createPartitionKey(where);\n try {\n const result = await entity.queryAll({\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n return result ? result.map(item => item.data) : [];\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list models.\",\n ex.code || \"MODEL_LIST_ERROR\",\n {\n error: ex,\n partitionKey\n }\n );\n }\n };\n\n return {\n create,\n update,\n delete: deleteModel,\n get,\n list\n };\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AASvC,SAASC,cAAc;AAQvB,MAAMC,kBAAkB,GAAIC,MAA2B,IAAa;EAChE,MAAM;IAAEC;EAAO,CAAC,GAAGD,MAAM;EACzB,OAAO,KAAKC,MAAM,SAAS;AAC/B,CAAC;AAMD,MAAMC,aAAa,GAAIF,MAAqB,IAAa;EACrD,OAAOA,MAAM,CAACG,OAAO;AACzB,CAAC;AAQD,MAAMC,UAAU,GAAIJ,MAA2C,IAAyB;EACpF,IAAI,CAACA,MAAM,CAACC,MAAM,EAAE;IAChB,MAAM,IAAII,KAAK,CAAC,0CAA0C,CAAC;EAC/D;EACA,OAAO;IACHC,EAAE,EAAEP,kBAAkB,CAACC,MAAM,CAAC;IAC9BO,EAAE,EAAEL,aAAa,CAACF,MAAM,CAAC;IACzBQ,UAAU,EAAER,MAAM,CAACC;EACvB,CAAC;AACL,CAAC;AAED,MAAMQ,UAAU,GAAGA,CAAA,KAAc;EAC7B,OAAO,WAAW;AACtB,CAAC;AAOD,OAAO,MAAMC,6BAA6B,GACtCV,MAA2C,IACf;EAC5B,MAAM;IAAEW,MAAM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CAACb,IAAI,GAAG,IAAI;IACtC,CAAC,CAAC,OAAOE,EAAE,EAAE;MACT,MAAM,IAAIzB,WAAW,CACjByB,EAAE,CAACO,OAAO,IAAI,sBAAsB,EACpCP,EAAE,CAACQ,IAAI,IAAI,iBAAiB,EAC5B;QACIZ,KAAK,EAAEI,EAAE;QACTL;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,MAAMiB,IAAI,GAAG,MAAOlC,MAA2C,IAAK;IAChE,MAAM;MAAEmC;IAAM,CAAC,GAAGnC,MAAM;IACxB,MAAMoC,YAAY,GAAGrC,kBAAkB,CAACoC,KAAK,CAAC;IAC9C,IAAI;MACA,MAAMF,MAAM,GAAG,MAAMtB,MAAM,CAAC0B,QAAQ,CAAC;QACjCD,YAAY;QACZE,OAAO,EAAE;UACLC,GAAG,EAAE;QACT;MACJ,CAAC,CAAC;MACF,OAAON,MAAM,GAAGA,MAAM,CAACO,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACrB,IAAI,CAAC,GAAG,EAAE;IACtD,CAAC,CAAC,OAAOE,EAAE,EAAE;MACT,MAAM,IAAIzB,WAAW,CACjByB,EAAE,CAACO,OAAO,IAAI,wBAAwB,EACtCP,EAAE,CAACQ,IAAI,IAAI,kBAAkB,EAC7B;QACIZ,KAAK,EAAEI,EAAE;QACTc;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACHvB,MAAM;IACNe,MAAM;IACNJ,MAAM,EAAEO,WAAW;IACnBC,GAAG;IACHE;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["WebinyError","configurations","createPartitionKey","params","tenant","createSortKey","modelId","createKeys","Error","PK","SK","GSI_TENANT","createType","createModelsStorageOperations","entity","elasticsearch","create","model","index","es","keys","error","put","data","TYPE","ex","indices","delete","ignore_unavailable","dynamodbError","elasticsearchError","update","message","code","deleteModel","get","result","list","where","partitionKey","queryAll","options","gte","map","item"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModelStorageOperations,\n CmsModelStorageOperationsCreateParams,\n CmsModelStorageOperationsDeleteParams,\n CmsModelStorageOperationsGetParams,\n CmsModelStorageOperationsListParams,\n CmsModelStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { configurations } from \"~/configurations.js\";\nimport type { Client } from \"@webiny/api-opensearch\";\nimport type { IModelEntity } from \"~/definitions/types.js\";\n\ninterface PartitionKeysParams {\n tenant: string;\n}\n\nconst createPartitionKey = (params: PartitionKeysParams): string => {\n const { tenant } = params;\n return `T#${tenant}#CMS#CM`;\n};\n\ninterface SortKeyParams {\n modelId: string;\n}\n\nconst createSortKey = (params: SortKeyParams): string => {\n return params.modelId;\n};\n\ninterface IDynamoDbTableKeys {\n PK: string;\n SK: string;\n GSI_TENANT: string;\n}\n\nconst createKeys = (params: PartitionKeysParams & SortKeyParams): IDynamoDbTableKeys => {\n if (!params.tenant) {\n throw new Error(\"Missing tenant when creating model keys!\");\n }\n return {\n PK: createPartitionKey(params),\n SK: createSortKey(params),\n GSI_TENANT: params.tenant\n };\n};\n\nconst createType = (): string => {\n return \"cms.model\";\n};\n\nexport interface CreateModelsStorageOperationsParams {\n entity: IModelEntity;\n elasticsearch: Client;\n}\n\nexport const createModelsStorageOperations = (\n params: CreateModelsStorageOperationsParams\n): CmsModelStorageOperations => {\n const { entity, elasticsearch } = params;\n\n const create = async (params: CmsModelStorageOperationsCreateParams) => {\n const { model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n const keys = createKeys(model);\n\n let error;\n try {\n await entity.put({\n data: model,\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n error = ex;\n }\n /**\n * In case of DynamoDB error we need to remove the index we created.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record failed to be created.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n dynamodbError: error,\n elasticsearchError: ex\n }\n );\n }\n throw error;\n };\n\n const update = async (params: CmsModelStorageOperationsUpdateParams) => {\n const { model } = params;\n\n const keys = createKeys(model);\n\n try {\n await entity.put({\n data: model,\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update model.\",\n ex.code || \"MODEL_UPDATE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n };\n\n const deleteModel = async (params: CmsModelStorageOperationsDeleteParams) => {\n const { model } = params;\n const keys = createKeys(model);\n\n const { index } = configurations.es({\n model\n });\n\n try {\n await entity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete model.\",\n ex.code || \"MODEL_DELETE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n /**\n * Always delete the model index after deleting the model.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record delete.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n error: ex,\n index,\n model\n }\n );\n }\n\n return model;\n };\n\n const get = async (params: CmsModelStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const result = await entity.get(keys);\n\n return result ? result.data : null;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get model.\",\n ex.code || \"MODEL_GET_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n const list = async (params: CmsModelStorageOperationsListParams) => {\n const { where } = params;\n const partitionKey = createPartitionKey(where);\n try {\n const result = await entity.queryAll({\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n return result ? result.map(item => item.data) : [];\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list models.\",\n ex.code || \"MODEL_LIST_ERROR\",\n {\n error: ex,\n partitionKey\n }\n );\n }\n };\n\n return {\n create,\n update,\n delete: deleteModel,\n get,\n list\n };\n};\n"],"mappings":"AAA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C;MACF,OAAON,MAAM,GAAGA,MAAM,CAACO,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACrB,IAAI,CAAC,GAAG,EAAE;IACtD,CAAC,CAAC,OAAOE,EAAE,EAAE;MACT,MAAM,IAAIzB,WAAW,CACjByB,EAAE,CAACO,OAAO,IAAI,wBAAwB,EACtCP,EAAE,CAACQ,IAAI,IAAI,kBAAkB,EAC7B;QACIZ,KAAK,EAAEI,EAAE;QACTc;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACHvB,MAAM;IACNe,MAAM;IACNJ,MAAM,EAAEO,WAAW;IACnBC,GAAG;IACHE;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-ddb-es",
3
- "version": "6.0.0",
3
+ "version": "6.1.0-beta.0",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -27,40 +27,39 @@
27
27
  ],
28
28
  "license": "MIT",
29
29
  "dependencies": {
30
- "@webiny/api": "6.0.0",
31
- "@webiny/api-elasticsearch": "6.0.0",
32
- "@webiny/api-elasticsearch-tasks": "6.0.0",
33
- "@webiny/api-headless-cms": "6.0.0",
34
- "@webiny/aws-sdk": "6.0.0",
35
- "@webiny/db-dynamodb": "6.0.0",
36
- "@webiny/error": "6.0.0",
37
- "@webiny/handler-db": "6.0.0",
38
- "@webiny/plugins": "6.0.0",
39
- "@webiny/utils": "6.0.0",
30
+ "@webiny/api": "6.1.0-beta.0",
31
+ "@webiny/api-elasticsearch-tasks": "6.1.0-beta.0",
32
+ "@webiny/api-headless-cms": "6.1.0-beta.0",
33
+ "@webiny/api-opensearch": "6.1.0-beta.0",
34
+ "@webiny/aws-sdk": "6.1.0-beta.0",
35
+ "@webiny/db-dynamodb": "6.1.0-beta.0",
36
+ "@webiny/error": "6.1.0-beta.0",
37
+ "@webiny/handler-db": "6.1.0-beta.0",
38
+ "@webiny/plugins": "6.1.0-beta.0",
39
+ "@webiny/utils": "6.1.0-beta.0",
40
40
  "dataloader": "2.2.3",
41
41
  "lodash": "4.17.23"
42
42
  },
43
43
  "devDependencies": {
44
- "@elastic/elasticsearch": "7.12.0",
45
44
  "@types/jsonpack": "1.1.6",
46
- "@webiny/api-core": "6.0.0",
47
- "@webiny/api-dynamodb-to-elasticsearch": "6.0.0",
48
- "@webiny/build-tools": "6.0.0",
49
- "@webiny/handler": "6.0.0",
50
- "@webiny/handler-aws": "6.0.0",
51
- "@webiny/handler-graphql": "6.0.0",
52
- "@webiny/project-utils": "6.0.0",
53
- "@webiny/tasks": "6.0.0",
54
- "@webiny/wcp": "6.0.0",
45
+ "@webiny/api-core": "6.1.0-beta.0",
46
+ "@webiny/api-dynamodb-to-elasticsearch": "6.1.0-beta.0",
47
+ "@webiny/build-tools": "6.1.0-beta.0",
48
+ "@webiny/handler": "6.1.0-beta.0",
49
+ "@webiny/handler-aws": "6.1.0-beta.0",
50
+ "@webiny/handler-graphql": "6.1.0-beta.0",
51
+ "@webiny/project-utils": "6.1.0-beta.0",
52
+ "@webiny/tasks": "6.1.0-beta.0",
53
+ "@webiny/wcp": "6.1.0-beta.0",
55
54
  "jest-dynalite": "3.6.1",
56
55
  "prettier": "3.6.2",
57
56
  "rimraf": "6.1.3",
58
57
  "typescript": "5.9.3",
59
- "vitest": "4.0.18"
58
+ "vitest": "4.1.2"
60
59
  },
61
60
  "publishConfig": {
62
61
  "access": "public",
63
62
  "directory": "dist"
64
63
  },
65
- "gitHead": "9c6892640a45679ff521e25cd6587dff57393a2e"
64
+ "gitHead": "a3bd3695c66c79238e380d7360d9731b5fcf9c87"
66
65
  }
@@ -1,5 +1,5 @@
1
- import type { ModifyBodyCallable, ModifyBodyParams as BaseModifyBodyParams } from "@webiny/api-elasticsearch";
2
- import { ElasticsearchBodyModifierPlugin } from "@webiny/api-elasticsearch";
1
+ import type { ModifyBodyCallable, ModifyBodyParams as BaseModifyBodyParams } from "@webiny/api-opensearch";
2
+ import { OpenSearchBodyModifierPlugin } from "@webiny/api-opensearch";
3
3
  import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
4
4
  export interface ModifyBodyParams extends BaseModifyBodyParams {
5
5
  model: CmsModel;
@@ -14,7 +14,7 @@ export interface CmsEntryElasticsearchBodyModifierPluginConfig {
14
14
  */
15
15
  modelId?: string;
16
16
  }
17
- export declare class CmsEntryElasticsearchBodyModifierPlugin extends ElasticsearchBodyModifierPlugin<ModifyBodyParams> {
17
+ export declare class CmsEntryElasticsearchBodyModifierPlugin extends OpenSearchBodyModifierPlugin<ModifyBodyParams> {
18
18
  static readonly type: string;
19
19
  readonly modelId?: string;
20
20
  constructor(config: CmsEntryElasticsearchBodyModifierPluginConfig);
@@ -1,5 +1,5 @@
1
- import { ElasticsearchBodyModifierPlugin } from "@webiny/api-elasticsearch";
2
- export class CmsEntryElasticsearchBodyModifierPlugin extends ElasticsearchBodyModifierPlugin {
1
+ import { OpenSearchBodyModifierPlugin } from "@webiny/api-opensearch";
2
+ export class CmsEntryElasticsearchBodyModifierPlugin extends OpenSearchBodyModifierPlugin {
3
3
  static type = "cms.elasticsearch.modifier.body.entry";
4
4
  constructor(config) {
5
5
  super(config.modifyBody);
@@ -1 +1 @@
1
- {"version":3,"names":["ElasticsearchBodyModifierPlugin","CmsEntryElasticsearchBodyModifierPlugin","type","constructor","config","modifyBody","modelId","createCmsEntryElasticsearchBodyModifierPlugin"],"sources":["CmsEntryElasticsearchBodyModifierPlugin.ts"],"sourcesContent":["import type {\n ModifyBodyCallable,\n ModifyBodyParams as BaseModifyBodyParams\n} from \"@webiny/api-elasticsearch\";\nimport { ElasticsearchBodyModifierPlugin } from \"@webiny/api-elasticsearch\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface ModifyBodyParams extends BaseModifyBodyParams {\n model: CmsModel;\n where: {\n [key: string]: any;\n };\n}\n\nexport interface CmsEntryElasticsearchBodyModifierPluginConfig {\n modifyBody: ModifyBodyCallable<ModifyBodyParams>;\n /**\n * If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.\n */\n modelId?: string;\n}\n\nexport class CmsEntryElasticsearchBodyModifierPlugin extends ElasticsearchBodyModifierPlugin<ModifyBodyParams> {\n public static override readonly type: string = \"cms.elasticsearch.modifier.body.entry\";\n\n public readonly modelId?: string;\n\n public constructor(config: CmsEntryElasticsearchBodyModifierPluginConfig) {\n super(config.modifyBody);\n\n this.modelId = config.modelId;\n }\n}\n\nexport const createCmsEntryElasticsearchBodyModifierPlugin = (\n config: CmsEntryElasticsearchBodyModifierPluginConfig\n) => {\n return new CmsEntryElasticsearchBodyModifierPlugin(config);\n};\n"],"mappings":"AAIA,SAASA,+BAA+B,QAAQ,2BAA2B;AAkB3E,OAAO,MAAMC,uCAAuC,SAASD,+BAA+B,CAAmB;EAC3G,OAAgCE,IAAI,GAAW,uCAAuC;EAI/EC,WAAWA,CAACC,MAAqD,EAAE;IACtE,KAAK,CAACA,MAAM,CAACC,UAAU,CAAC;IAExB,IAAI,CAACC,OAAO,GAAGF,MAAM,CAACE,OAAO;EACjC;AACJ;AAEA,OAAO,MAAMC,6CAA6C,GACtDH,MAAqD,IACpD;EACD,OAAO,IAAIH,uCAAuC,CAACG,MAAM,CAAC;AAC9D,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["OpenSearchBodyModifierPlugin","CmsEntryElasticsearchBodyModifierPlugin","type","constructor","config","modifyBody","modelId","createCmsEntryElasticsearchBodyModifierPlugin"],"sources":["CmsEntryElasticsearchBodyModifierPlugin.ts"],"sourcesContent":["import type {\n ModifyBodyCallable,\n ModifyBodyParams as BaseModifyBodyParams\n} from \"@webiny/api-opensearch\";\nimport { OpenSearchBodyModifierPlugin } from \"@webiny/api-opensearch\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface ModifyBodyParams extends BaseModifyBodyParams {\n model: CmsModel;\n where: {\n [key: string]: any;\n };\n}\n\nexport interface CmsEntryElasticsearchBodyModifierPluginConfig {\n modifyBody: ModifyBodyCallable<ModifyBodyParams>;\n /**\n * If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.\n */\n modelId?: string;\n}\n\nexport class CmsEntryElasticsearchBodyModifierPlugin extends OpenSearchBodyModifierPlugin<ModifyBodyParams> {\n public static override readonly type: string = \"cms.elasticsearch.modifier.body.entry\";\n\n public readonly modelId?: string;\n\n public constructor(config: CmsEntryElasticsearchBodyModifierPluginConfig) {\n super(config.modifyBody);\n\n this.modelId = config.modelId;\n }\n}\n\nexport const createCmsEntryElasticsearchBodyModifierPlugin = (\n config: CmsEntryElasticsearchBodyModifierPluginConfig\n) => {\n return new CmsEntryElasticsearchBodyModifierPlugin(config);\n};\n"],"mappings":"AAIA,SAASA,4BAA4B,QAAQ,wBAAwB;AAkBrE,OAAO,MAAMC,uCAAuC,SAASD,4BAA4B,CAAmB;EACxG,OAAgCE,IAAI,GAAW,uCAAuC;EAI/EC,WAAWA,CAACC,MAAqD,EAAE;IACtE,KAAK,CAACA,MAAM,CAACC,UAAU,CAAC;IAExB,IAAI,CAACC,OAAO,GAAGF,MAAM,CAACE,OAAO;EACjC;AACJ;AAEA,OAAO,MAAMC,6CAA6C,GACtDH,MAAqD,IACpD;EACD,OAAO,IAAIH,uCAAuC,CAACG,MAAM,CAAC;AAC9D,CAAC","ignoreList":[]}
@@ -1,10 +1,10 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
- import type { ElasticsearchBoolQueryConfig } from "@webiny/api-elasticsearch/types.js";
2
+ import type { OpenSearchBoolQueryConfig } from "@webiny/api-opensearch/types.js";
3
3
  import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
4
4
  import type { ModelField, ModelFields } from "../operations/entry/elasticsearch/types.js";
5
5
  export interface CmsEntryElasticsearchFullTextSearchPluginCbParams {
6
6
  model: CmsModel;
7
- query: ElasticsearchBoolQueryConfig;
7
+ query: OpenSearchBoolQueryConfig;
8
8
  term: string;
9
9
  fields: ModelFields;
10
10
  createFieldPath: (field: ModelField) => string;
@@ -1 +1 @@
1
- {"version":3,"names":["Plugin","CmsEntryElasticsearchFullTextSearchPlugin","type","models","params","constructor","apply","createCmsEntryElasticsearchFullTextSearchPlugin"],"sources":["CmsEntryElasticsearchFullTextSearchPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { ElasticsearchBoolQueryConfig } from \"@webiny/api-elasticsearch/types.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { ModelField, ModelFields } from \"~/operations/entry/elasticsearch/types.js\";\n\nexport interface CmsEntryElasticsearchFullTextSearchPluginCbParams {\n model: CmsModel;\n query: ElasticsearchBoolQueryConfig;\n term: string;\n fields: ModelFields;\n createFieldPath: (field: ModelField) => string;\n prepareTerm: (term: string) => string;\n}\nexport interface CmsEntryElasticsearchFullTextSearchPluginParams {\n models?: string[];\n apply: (params: CmsEntryElasticsearchFullTextSearchPluginCbParams) => void;\n}\nexport class CmsEntryElasticsearchFullTextSearchPlugin extends Plugin {\n public static override readonly type: string =\n \"headless-cms.elasticsearch.entry.fullTextSearch\";\n\n private readonly params: CmsEntryElasticsearchFullTextSearchPluginParams;\n\n public get models() {\n return this.params.models;\n }\n\n public constructor(params: CmsEntryElasticsearchFullTextSearchPluginParams) {\n super();\n this.params = params;\n }\n\n public apply(params: CmsEntryElasticsearchFullTextSearchPluginCbParams): void {\n return this.params.apply(params);\n }\n}\n\nexport const createCmsEntryElasticsearchFullTextSearchPlugin = (\n params: CmsEntryElasticsearchFullTextSearchPluginParams\n) => {\n return new CmsEntryElasticsearchFullTextSearchPlugin(params);\n};\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAiB;AAiBxC,OAAO,MAAMC,yCAAyC,SAASD,MAAM,CAAC;EAClE,OAAgCE,IAAI,GAChC,iDAAiD;EAIrD,IAAWC,MAAMA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACC,MAAM,CAACD,MAAM;EAC7B;EAEOE,WAAWA,CAACD,MAAuD,EAAE;IACxE,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEOE,KAAKA,CAACF,MAAyD,EAAQ;IAC1E,OAAO,IAAI,CAACA,MAAM,CAACE,KAAK,CAACF,MAAM,CAAC;EACpC;AACJ;AAEA,OAAO,MAAMG,+CAA+C,GACxDH,MAAuD,IACtD;EACD,OAAO,IAAIH,yCAAyC,CAACG,MAAM,CAAC;AAChE,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Plugin","CmsEntryElasticsearchFullTextSearchPlugin","type","models","params","constructor","apply","createCmsEntryElasticsearchFullTextSearchPlugin"],"sources":["CmsEntryElasticsearchFullTextSearchPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { OpenSearchBoolQueryConfig } from \"@webiny/api-opensearch/types.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { ModelField, ModelFields } from \"~/operations/entry/elasticsearch/types.js\";\n\nexport interface CmsEntryElasticsearchFullTextSearchPluginCbParams {\n model: CmsModel;\n query: OpenSearchBoolQueryConfig;\n term: string;\n fields: ModelFields;\n createFieldPath: (field: ModelField) => string;\n prepareTerm: (term: string) => string;\n}\nexport interface CmsEntryElasticsearchFullTextSearchPluginParams {\n models?: string[];\n apply: (params: CmsEntryElasticsearchFullTextSearchPluginCbParams) => void;\n}\nexport class CmsEntryElasticsearchFullTextSearchPlugin extends Plugin {\n public static override readonly type: string =\n \"headless-cms.elasticsearch.entry.fullTextSearch\";\n\n private readonly params: CmsEntryElasticsearchFullTextSearchPluginParams;\n\n public get models() {\n return this.params.models;\n }\n\n public constructor(params: CmsEntryElasticsearchFullTextSearchPluginParams) {\n super();\n this.params = params;\n }\n\n public apply(params: CmsEntryElasticsearchFullTextSearchPluginCbParams): void {\n return this.params.apply(params);\n }\n}\n\nexport const createCmsEntryElasticsearchFullTextSearchPlugin = (\n params: CmsEntryElasticsearchFullTextSearchPluginParams\n) => {\n return new CmsEntryElasticsearchFullTextSearchPlugin(params);\n};\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAiB;AAiBxC,OAAO,MAAMC,yCAAyC,SAASD,MAAM,CAAC;EAClE,OAAgCE,IAAI,GAChC,iDAAiD;EAIrD,IAAWC,MAAMA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACC,MAAM,CAACD,MAAM;EAC7B;EAEOE,WAAWA,CAACD,MAAuD,EAAE;IACxE,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEOE,KAAKA,CAACF,MAAyD,EAAQ;IAC1E,OAAO,IAAI,CAACA,MAAM,CAACE,KAAK,CAACF,MAAM,CAAC;EACpC;AACJ;AAEA,OAAO,MAAMG,+CAA+C,GACxDH,MAAuD,IACtD;EACD,OAAO,IAAIH,yCAAyC,CAACG,MAAM,CAAC;AAChE,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { ElasticsearchIndexPlugin } from "@webiny/api-elasticsearch";
2
- export declare class CmsEntryElasticsearchIndexPlugin extends ElasticsearchIndexPlugin {
1
+ import { OpenSearchIndexPlugin } from "@webiny/api-opensearch";
2
+ export declare class CmsEntryElasticsearchIndexPlugin extends OpenSearchIndexPlugin {
3
3
  static readonly type: string;
4
4
  }
@@ -1,5 +1,5 @@
1
- import { ElasticsearchIndexPlugin } from "@webiny/api-elasticsearch";
2
- export class CmsEntryElasticsearchIndexPlugin extends ElasticsearchIndexPlugin {
1
+ import { OpenSearchIndexPlugin } from "@webiny/api-opensearch";
2
+ export class CmsEntryElasticsearchIndexPlugin extends OpenSearchIndexPlugin {
3
3
  static type = "cms.entry.elasticsearch.index";
4
4
  }
5
5
 
@@ -1 +1 @@
1
- {"version":3,"names":["ElasticsearchIndexPlugin","CmsEntryElasticsearchIndexPlugin","type"],"sources":["CmsEntryElasticsearchIndexPlugin.ts"],"sourcesContent":["import { ElasticsearchIndexPlugin } from \"@webiny/api-elasticsearch\";\n\nexport class CmsEntryElasticsearchIndexPlugin extends ElasticsearchIndexPlugin {\n public static override readonly type: string = \"cms.entry.elasticsearch.index\";\n}\n"],"mappings":"AAAA,SAASA,wBAAwB,QAAQ,2BAA2B;AAEpE,OAAO,MAAMC,gCAAgC,SAASD,wBAAwB,CAAC;EAC3E,OAAgCE,IAAI,GAAW,+BAA+B;AAClF","ignoreList":[]}
1
+ {"version":3,"names":["OpenSearchIndexPlugin","CmsEntryElasticsearchIndexPlugin","type"],"sources":["CmsEntryElasticsearchIndexPlugin.ts"],"sourcesContent":["import { OpenSearchIndexPlugin } from \"@webiny/api-opensearch\";\n\nexport class CmsEntryElasticsearchIndexPlugin extends OpenSearchIndexPlugin {\n public static override readonly type: string = \"cms.entry.elasticsearch.index\";\n}\n"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,wBAAwB;AAE9D,OAAO,MAAMC,gCAAgC,SAASD,qBAAqB,CAAC;EACxE,OAAgCE,IAAI,GAAW,+BAA+B;AAClF","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import type { ModifyQueryCallable, ModifyQueryParams as BaseModifyQueryParams } from "@webiny/api-elasticsearch";
2
- import { ElasticsearchQueryModifierPlugin } from "@webiny/api-elasticsearch";
1
+ import type { ModifyQueryCallable, ModifyQueryParams as BaseModifyQueryParams } from "@webiny/api-opensearch";
2
+ import { OpenSearchQueryModifierPlugin } from "@webiny/api-opensearch";
3
3
  import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
4
4
  export interface ModifyQueryParams extends BaseModifyQueryParams {
5
5
  model: CmsModel;
@@ -11,7 +11,7 @@ export interface CmsEntryElasticsearchQueryModifierPluginConfig {
11
11
  */
12
12
  modelId?: string;
13
13
  }
14
- export declare class CmsEntryElasticsearchQueryModifierPlugin extends ElasticsearchQueryModifierPlugin<ModifyQueryParams> {
14
+ export declare class CmsEntryElasticsearchQueryModifierPlugin extends OpenSearchQueryModifierPlugin<ModifyQueryParams> {
15
15
  static readonly type: string;
16
16
  readonly modelId?: string;
17
17
  constructor(config: CmsEntryElasticsearchQueryModifierPluginConfig);
@@ -1,5 +1,5 @@
1
- import { ElasticsearchQueryModifierPlugin } from "@webiny/api-elasticsearch";
2
- export class CmsEntryElasticsearchQueryModifierPlugin extends ElasticsearchQueryModifierPlugin {
1
+ import { OpenSearchQueryModifierPlugin } from "@webiny/api-opensearch";
2
+ export class CmsEntryElasticsearchQueryModifierPlugin extends OpenSearchQueryModifierPlugin {
3
3
  static type = "cms.elasticsearch.modifier.query.entry";
4
4
  constructor(config) {
5
5
  super(config.modifyQuery);
@@ -1 +1 @@
1
- {"version":3,"names":["ElasticsearchQueryModifierPlugin","CmsEntryElasticsearchQueryModifierPlugin","type","constructor","config","modifyQuery","modelId","createCmsEntryElasticsearchQueryModifierPlugin"],"sources":["CmsEntryElasticsearchQueryModifierPlugin.ts"],"sourcesContent":["import type {\n ModifyQueryCallable,\n ModifyQueryParams as BaseModifyQueryParams\n} from \"@webiny/api-elasticsearch\";\nimport { ElasticsearchQueryModifierPlugin } from \"@webiny/api-elasticsearch\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface ModifyQueryParams extends BaseModifyQueryParams {\n model: CmsModel;\n}\n\nexport interface CmsEntryElasticsearchQueryModifierPluginConfig {\n modifyQuery: ModifyQueryCallable<ModifyQueryParams>;\n /**\n * If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.\n */\n modelId?: string;\n}\n\nexport class CmsEntryElasticsearchQueryModifierPlugin extends ElasticsearchQueryModifierPlugin<ModifyQueryParams> {\n public static override readonly type: string = \"cms.elasticsearch.modifier.query.entry\";\n\n public readonly modelId?: string;\n\n public constructor(config: CmsEntryElasticsearchQueryModifierPluginConfig) {\n super(config.modifyQuery);\n\n this.modelId = config.modelId;\n }\n}\n\nexport const createCmsEntryElasticsearchQueryModifierPlugin = (\n config: CmsEntryElasticsearchQueryModifierPluginConfig\n) => {\n return new CmsEntryElasticsearchQueryModifierPlugin(config);\n};\n"],"mappings":"AAIA,SAASA,gCAAgC,QAAQ,2BAA2B;AAe5E,OAAO,MAAMC,wCAAwC,SAASD,gCAAgC,CAAoB;EAC9G,OAAgCE,IAAI,GAAW,wCAAwC;EAIhFC,WAAWA,CAACC,MAAsD,EAAE;IACvE,KAAK,CAACA,MAAM,CAACC,WAAW,CAAC;IAEzB,IAAI,CAACC,OAAO,GAAGF,MAAM,CAACE,OAAO;EACjC;AACJ;AAEA,OAAO,MAAMC,8CAA8C,GACvDH,MAAsD,IACrD;EACD,OAAO,IAAIH,wCAAwC,CAACG,MAAM,CAAC;AAC/D,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["OpenSearchQueryModifierPlugin","CmsEntryElasticsearchQueryModifierPlugin","type","constructor","config","modifyQuery","modelId","createCmsEntryElasticsearchQueryModifierPlugin"],"sources":["CmsEntryElasticsearchQueryModifierPlugin.ts"],"sourcesContent":["import type {\n ModifyQueryCallable,\n ModifyQueryParams as BaseModifyQueryParams\n} from \"@webiny/api-opensearch\";\nimport { OpenSearchQueryModifierPlugin } from \"@webiny/api-opensearch\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface ModifyQueryParams extends BaseModifyQueryParams {\n model: CmsModel;\n}\n\nexport interface CmsEntryElasticsearchQueryModifierPluginConfig {\n modifyQuery: ModifyQueryCallable<ModifyQueryParams>;\n /**\n * If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.\n */\n modelId?: string;\n}\n\nexport class CmsEntryElasticsearchQueryModifierPlugin extends OpenSearchQueryModifierPlugin<ModifyQueryParams> {\n public static override readonly type: string = \"cms.elasticsearch.modifier.query.entry\";\n\n public readonly modelId?: string;\n\n public constructor(config: CmsEntryElasticsearchQueryModifierPluginConfig) {\n super(config.modifyQuery);\n\n this.modelId = config.modelId;\n }\n}\n\nexport const createCmsEntryElasticsearchQueryModifierPlugin = (\n config: CmsEntryElasticsearchQueryModifierPluginConfig\n) => {\n return new CmsEntryElasticsearchQueryModifierPlugin(config);\n};\n"],"mappings":"AAIA,SAASA,6BAA6B,QAAQ,wBAAwB;AAetE,OAAO,MAAMC,wCAAwC,SAASD,6BAA6B,CAAoB;EAC3G,OAAgCE,IAAI,GAAW,wCAAwC;EAIhFC,WAAWA,CAACC,MAAsD,EAAE;IACvE,KAAK,CAACA,MAAM,CAACC,WAAW,CAAC;IAEzB,IAAI,CAACC,OAAO,GAAGF,MAAM,CAACE,OAAO;EACjC;AACJ;AAEA,OAAO,MAAMC,8CAA8C,GACvDH,MAAsD,IACrD;EACD,OAAO,IAAIH,wCAAwC,CAACG,MAAM,CAAC;AAC/D,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import type { ModifySortCallable, ModifySortParams as BaseModifySortParams } from "@webiny/api-elasticsearch";
2
- import { ElasticsearchSortModifierPlugin } from "@webiny/api-elasticsearch";
1
+ import type { ModifySortCallable, ModifySortParams as BaseModifySortParams } from "@webiny/api-opensearch";
2
+ import { OpenSearchSortModifierPlugin } from "@webiny/api-opensearch";
3
3
  import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
4
4
  export interface ModifySortParams extends BaseModifySortParams {
5
5
  model: CmsModel;
@@ -11,7 +11,7 @@ export interface CmsEntryElasticsearchSortModifierPluginConfig {
11
11
  */
12
12
  modelId?: string;
13
13
  }
14
- export declare class CmsEntryElasticsearchSortModifierPlugin extends ElasticsearchSortModifierPlugin<ModifySortParams> {
14
+ export declare class CmsEntryElasticsearchSortModifierPlugin extends OpenSearchSortModifierPlugin<ModifySortParams> {
15
15
  static readonly type: string;
16
16
  readonly modelId?: string;
17
17
  constructor(config: CmsEntryElasticsearchSortModifierPluginConfig);
@@ -1,5 +1,5 @@
1
- import { ElasticsearchSortModifierPlugin } from "@webiny/api-elasticsearch";
2
- export class CmsEntryElasticsearchSortModifierPlugin extends ElasticsearchSortModifierPlugin {
1
+ import { OpenSearchSortModifierPlugin } from "@webiny/api-opensearch";
2
+ export class CmsEntryElasticsearchSortModifierPlugin extends OpenSearchSortModifierPlugin {
3
3
  static type = "cms.elasticsearch.modifier.sort.entry";
4
4
  constructor(config) {
5
5
  super(config.modifySort);
@@ -1 +1 @@
1
- {"version":3,"names":["ElasticsearchSortModifierPlugin","CmsEntryElasticsearchSortModifierPlugin","type","constructor","config","modifySort","modelId","createCmsEntryElasticsearchSortModifierPlugin"],"sources":["CmsEntryElasticsearchSortModifierPlugin.ts"],"sourcesContent":["import type {\n ModifySortCallable,\n ModifySortParams as BaseModifySortParams\n} from \"@webiny/api-elasticsearch\";\nimport { ElasticsearchSortModifierPlugin } from \"@webiny/api-elasticsearch\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface ModifySortParams extends BaseModifySortParams {\n model: CmsModel;\n}\n\nexport interface CmsEntryElasticsearchSortModifierPluginConfig {\n modifySort: ModifySortCallable<ModifySortParams>;\n /**\n * If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.\n */\n modelId?: string;\n}\n\nexport class CmsEntryElasticsearchSortModifierPlugin extends ElasticsearchSortModifierPlugin<ModifySortParams> {\n public static override readonly type: string = \"cms.elasticsearch.modifier.sort.entry\";\n\n public readonly modelId?: string;\n\n public constructor(config: CmsEntryElasticsearchSortModifierPluginConfig) {\n super(config.modifySort);\n this.modelId = config.modelId;\n }\n}\n\nexport const createCmsEntryElasticsearchSortModifierPlugin = (\n config: CmsEntryElasticsearchSortModifierPluginConfig\n) => {\n return new CmsEntryElasticsearchSortModifierPlugin(config);\n};\n"],"mappings":"AAIA,SAASA,+BAA+B,QAAQ,2BAA2B;AAe3E,OAAO,MAAMC,uCAAuC,SAASD,+BAA+B,CAAmB;EAC3G,OAAgCE,IAAI,GAAW,uCAAuC;EAI/EC,WAAWA,CAACC,MAAqD,EAAE;IACtE,KAAK,CAACA,MAAM,CAACC,UAAU,CAAC;IACxB,IAAI,CAACC,OAAO,GAAGF,MAAM,CAACE,OAAO;EACjC;AACJ;AAEA,OAAO,MAAMC,6CAA6C,GACtDH,MAAqD,IACpD;EACD,OAAO,IAAIH,uCAAuC,CAACG,MAAM,CAAC;AAC9D,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["OpenSearchSortModifierPlugin","CmsEntryElasticsearchSortModifierPlugin","type","constructor","config","modifySort","modelId","createCmsEntryElasticsearchSortModifierPlugin"],"sources":["CmsEntryElasticsearchSortModifierPlugin.ts"],"sourcesContent":["import type {\n ModifySortCallable,\n ModifySortParams as BaseModifySortParams\n} from \"@webiny/api-opensearch\";\nimport { OpenSearchSortModifierPlugin } from \"@webiny/api-opensearch\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface ModifySortParams extends BaseModifySortParams {\n model: CmsModel;\n}\n\nexport interface CmsEntryElasticsearchSortModifierPluginConfig {\n modifySort: ModifySortCallable<ModifySortParams>;\n /**\n * If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.\n */\n modelId?: string;\n}\n\nexport class CmsEntryElasticsearchSortModifierPlugin extends OpenSearchSortModifierPlugin<ModifySortParams> {\n public static override readonly type: string = \"cms.elasticsearch.modifier.sort.entry\";\n\n public readonly modelId?: string;\n\n public constructor(config: CmsEntryElasticsearchSortModifierPluginConfig) {\n super(config.modifySort);\n this.modelId = config.modelId;\n }\n}\n\nexport const createCmsEntryElasticsearchSortModifierPlugin = (\n config: CmsEntryElasticsearchSortModifierPluginConfig\n) => {\n return new CmsEntryElasticsearchSortModifierPlugin(config);\n};\n"],"mappings":"AAIA,SAASA,4BAA4B,QAAQ,wBAAwB;AAerE,OAAO,MAAMC,uCAAuC,SAASD,4BAA4B,CAAmB;EACxG,OAAgCE,IAAI,GAAW,uCAAuC;EAI/EC,WAAWA,CAACC,MAAqD,EAAE;IACtE,KAAK,CAACA,MAAM,CAACC,UAAU,CAAC;IACxB,IAAI,CAACC,OAAO,GAAGF,MAAM,CAACE,OAAO;EACjC;AACJ;AAEA,OAAO,MAAMC,6CAA6C,GACtDH,MAAqD,IACpD;EACD,OAAO,IAAIH,uCAAuC,CAACG,MAAM,CAAC;AAC9D,CAAC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
2
  import type { ValueFilterPlugin } from "@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin.js";
3
3
  import type { ModelField, ModelFields } from "../operations/entry/elasticsearch/types.js";
4
- import type { ElasticsearchBoolQueryConfig } from "@webiny/api-elasticsearch/types.js";
4
+ import type { OpenSearchBoolQueryConfig } from "@webiny/api-opensearch/types.js";
5
5
  interface CmsEntryFilterPluginConfig {
6
6
  fieldType: string;
7
7
  exec: (params: ExecParams) => void;
@@ -9,7 +9,7 @@ interface CmsEntryFilterPluginConfig {
9
9
  interface ApplyParams {
10
10
  key: string;
11
11
  value: any;
12
- query: ElasticsearchBoolQueryConfig;
12
+ query: OpenSearchBoolQueryConfig;
13
13
  operator: string;
14
14
  field: ModelField;
15
15
  }
@@ -27,7 +27,7 @@ interface ExecParams {
27
27
  operator: string;
28
28
  field: ModelField;
29
29
  fields: ModelFields;
30
- query: ElasticsearchBoolQueryConfig;
30
+ query: OpenSearchBoolQueryConfig;
31
31
  }
32
32
  export interface CmsEntryFilterPluginCreateResponse {
33
33
  field: ModelField;
@@ -1 +1 @@
1
- {"version":3,"names":["Plugin","CmsEntryFilterPlugin","type","ALL","constructor","config","fieldType","exec","params"],"sources":["CmsEntryFilterPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin.js\";\nimport type { ModelField, ModelFields } from \"~/operations/entry/elasticsearch/types.js\";\nimport type { ElasticsearchBoolQueryConfig } from \"@webiny/api-elasticsearch/types.js\";\n\ninterface CmsEntryFilterPluginConfig {\n fieldType: string;\n exec: (params: ExecParams) => void;\n}\ninterface ApplyParams {\n key: string;\n value: any;\n query: ElasticsearchBoolQueryConfig;\n operator: string;\n field: ModelField;\n}\nexport interface ApplyFilteringCb {\n (params: ApplyParams): void;\n}\n\nexport interface GetFilterPluginCb {\n (type: string): CmsEntryFilterPlugin;\n}\n\ninterface ExecParams {\n applyFiltering: ApplyFilteringCb;\n getFilterPlugin: GetFilterPluginCb;\n key: string;\n value: any;\n operator: string;\n field: ModelField;\n fields: ModelFields;\n query: ElasticsearchBoolQueryConfig;\n}\n\nexport interface CmsEntryFilterPluginCreateResponse {\n field: ModelField;\n path: string;\n fieldPathId: string;\n plugin: ValueFilterPlugin;\n negate: boolean;\n compareValue: any;\n transformValue: <I = any, O = any>(value: I) => O;\n}\n\nexport class CmsEntryFilterPlugin extends Plugin {\n public static override readonly type: string = \"cms.elasticsearch.entry.filter\";\n public static readonly ALL: string = \"*\";\n\n private readonly config: CmsEntryFilterPluginConfig;\n public readonly fieldType: string;\n\n public constructor(config: CmsEntryFilterPluginConfig) {\n super();\n this.config = config;\n this.fieldType = this.config.fieldType;\n }\n\n public exec(params: ExecParams) {\n return this.config.exec(params);\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAiB;AA6CxC,OAAO,MAAMC,oBAAoB,SAASD,MAAM,CAAC;EAC7C,OAAgCE,IAAI,GAAW,gCAAgC;EAC/E,OAAuBC,GAAG,GAAW,GAAG;EAKjCC,WAAWA,CAACC,MAAkC,EAAE;IACnD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,SAAS,GAAG,IAAI,CAACD,MAAM,CAACC,SAAS;EAC1C;EAEOC,IAAIA,CAACC,MAAkB,EAAE;IAC5B,OAAO,IAAI,CAACH,MAAM,CAACE,IAAI,CAACC,MAAM,CAAC;EACnC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["Plugin","CmsEntryFilterPlugin","type","ALL","constructor","config","fieldType","exec","params"],"sources":["CmsEntryFilterPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin.js\";\nimport type { ModelField, ModelFields } from \"~/operations/entry/elasticsearch/types.js\";\nimport type { OpenSearchBoolQueryConfig } from \"@webiny/api-opensearch/types.js\";\n\ninterface CmsEntryFilterPluginConfig {\n fieldType: string;\n exec: (params: ExecParams) => void;\n}\ninterface ApplyParams {\n key: string;\n value: any;\n query: OpenSearchBoolQueryConfig;\n operator: string;\n field: ModelField;\n}\nexport interface ApplyFilteringCb {\n (params: ApplyParams): void;\n}\n\nexport interface GetFilterPluginCb {\n (type: string): CmsEntryFilterPlugin;\n}\n\ninterface ExecParams {\n applyFiltering: ApplyFilteringCb;\n getFilterPlugin: GetFilterPluginCb;\n key: string;\n value: any;\n operator: string;\n field: ModelField;\n fields: ModelFields;\n query: OpenSearchBoolQueryConfig;\n}\n\nexport interface CmsEntryFilterPluginCreateResponse {\n field: ModelField;\n path: string;\n fieldPathId: string;\n plugin: ValueFilterPlugin;\n negate: boolean;\n compareValue: any;\n transformValue: <I = any, O = any>(value: I) => O;\n}\n\nexport class CmsEntryFilterPlugin extends Plugin {\n public static override readonly type: string = \"cms.elasticsearch.entry.filter\";\n public static readonly ALL: string = \"*\";\n\n private readonly config: CmsEntryFilterPluginConfig;\n public readonly fieldType: string;\n\n public constructor(config: CmsEntryFilterPluginConfig) {\n super();\n this.config = config;\n this.fieldType = this.config.fieldType;\n }\n\n public exec(params: ExecParams) {\n return this.config.exec(params);\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAiB;AA6CxC,OAAO,MAAMC,oBAAoB,SAASD,MAAM,CAAC;EAC7C,OAAgCE,IAAI,GAAW,gCAAgC;EAC/E,OAAuBC,GAAG,GAAW,GAAG;EAKjCC,WAAWA,CAACC,MAAkC,EAAE;IACnD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,SAAS,GAAG,IAAI,CAACD,MAAM,CAACC,SAAS;EAC1C;EAEOC,IAAIA,CAACC,MAAkB,EAAE;IAC5B,OAAO,IAAI,CAACH,MAAM,CAACE,IAAI,CAACC,MAAM,CAAC;EACnC;AACJ","ignoreList":[]}
package/types.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import type { Plugin, PluginCollection } from "@webiny/plugins/types.js";
2
2
  import type { CmsContext as BaseCmsContext, CmsEntry, CmsEntryStorageOperations as BaseCmsEntryStorageOperations, CmsEntryValues, CmsModel, CmsModelField, CmsModelFieldToGraphQLPlugin, CmsModelFieldType, HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations } from "@webiny/api-headless-cms/types/index.js";
3
3
  import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
4
- import type { Client } from "@elastic/elasticsearch";
4
+ import type { Client } from "@webiny/api-opensearch";
5
5
  import type { PluginsContainer } from "@webiny/plugins";
6
6
  import type { IEntryEntity, IGroupEntity, IModelEntity } from "./definitions/types.js";
7
- import type { IElasticsearchEntity } from "@webiny/api-elasticsearch";
7
+ import type { IOpenSearchEntity as IElasticsearchEntity } from "@webiny/api-opensearch";
8
8
  import type { ITable } from "@webiny/db-dynamodb";
9
9
  /**
10
10
  * A definition of the entry that is being prepared for the Elasticsearch.
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["ENTITIES"],"sources":["types.ts"],"sourcesContent":["import type { Plugin, PluginCollection } from \"@webiny/plugins/types.js\";\nimport type {\n CmsContext as BaseCmsContext,\n CmsEntry,\n CmsEntryStorageOperations as BaseCmsEntryStorageOperations,\n CmsEntryValues,\n CmsModel,\n CmsModelField,\n CmsModelFieldToGraphQLPlugin,\n CmsModelFieldType,\n HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { Client } from \"@elastic/elasticsearch\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { IEntryEntity, IGroupEntity, IModelEntity } from \"~/definitions/types.js\";\nimport type { IElasticsearchEntity } from \"@webiny/api-elasticsearch\";\nimport type { ITable } from \"@webiny/db-dynamodb\";\n\n/**\n * A definition of the entry that is being prepared for the Elasticsearch.\n *\n * @category Elasticsearch\n * @category CmsEntry\n */\nexport interface CmsIndexEntry<T extends CmsEntryValues = CmsEntryValues> extends CmsEntry<T> {\n /**\n * Values that are not going to be indexed.\n */\n rawValues: Partial<T>;\n /**\n * Dev can add whatever keys they want and need. Just need to be careful not to break the entry.\n */\n [key: string]: any;\n}\n\n/**\n * Arguments for the method that is transforming content entry in its original form to the one we are storing to the Elasticsearch.\n *\n * @category Elasticsearch\n * @category CmsEntry\n */\nexport interface CmsModelFieldToElasticsearchToParams {\n plugins: PluginsContainer;\n model: CmsModel;\n field: CmsModelField;\n /**\n * Raw value on the entry - before prepare for storage.\n */\n rawValue: any;\n /**\n * Value prepared for storage received from base api-headless-cms package.\n */\n value: any;\n getFieldIndexPlugin(fieldType: string): CmsModelFieldToElasticsearchPlugin;\n getFieldTypePlugin(fieldType: string): CmsModelFieldToGraphQLPlugin;\n}\n\n/**\n * Arguments for the method that is transforming content entry from Elasticsearch into the original one.\n *\n * @category Elasticsearch\n * @category CmsEntry\n */\nexport interface CmsModelFieldToElasticsearchFromParams {\n plugins: PluginsContainer;\n model: CmsModel;\n field: CmsModelField;\n value: any;\n rawValue: any;\n getFieldIndexPlugin(fieldType: string): CmsModelFieldToElasticsearchPlugin;\n getFieldTypePlugin(fieldType: string): CmsModelFieldToGraphQLPlugin;\n}\n\ninterface ToIndexValue {\n /**\n * Use this key to store value for indexing.\n */\n value?: any;\n /**\n * Use this key to tell ES that this value should not be indexed.\n */\n rawValue?: any;\n}\n\n/**\n * A plugin defining transformation of entry for Elasticsearch.\n *\n * @category Plugin\n * @category ContentModelField\n * @category CmsEntry\n * @category Elasticsearch\n */\nexport interface CmsModelFieldToElasticsearchPlugin extends Plugin {\n /**\n * A plugin type\n */\n type: \"cms-model-field-to-elastic-search\";\n /**\n * A unique identifier of the field type (text, number, json, myField, ...).\n *\n * ```ts\n * fieldType: \"myField\"\n * ```\n */\n fieldType: CmsModelFieldType;\n /**\n * If you need to define a type when building an Elasticsearch query.\n * Check [dateTimeIndexing](https://github.com/webiny/webiny-js/blob/3074165701b8b45e5fc6ac2444caace7d04ada66/packages/api-headless-cms/src/content/plugins/es/indexing/dateTimeIndexing.ts) plugin for usage example.\n *\n * ```ts\n * unmappedType: \"date\"\n * ```\n */\n unmappedType?: (field: Pick<CmsModelField, \"fieldId\" | \"type\">) => string;\n /**\n * This is meant to do some transformation of the entry, preferably only to fieldType it was defined for. Nothing is stopping you to do anything you want to other fields, but try to separate field transformations.\n * It returns `Partial<CmsContentIndexEntryType>`. Always return a top-level property of the entry since it is merged via spread operator.\n *\n * ```ts\n * toIndex({ value }) {\n * return {\n * value: value, // This will be stored and indexed\n * rawValue: JSON.stringify(value) // This will be stored but excluded from indexing\n * };\n * }\n * ```\n */\n toIndex?: (params: CmsModelFieldToElasticsearchToParams) => ToIndexValue;\n /**\n * This is meant to revert a transformation done in the `toIndex` method.\n * You have access to \"value\" or a \"rawValue\", depending on what you returned from `toIndex`.\n *\n * ```ts\n * fromIndex({ value, rawValue }) {\n * return JSON.parse(rawValue);\n * }\n * ```\n */\n fromIndex?: (params: CmsModelFieldToElasticsearchFromParams) => any;\n}\n\nexport enum ENTITIES {\n GROUPS = \"CmsGroups\",\n MODELS = \"CmsModels\",\n ENTRIES = \"CmsEntries\",\n ENTRIES_ES = \"CmsEntriesElasticsearch\"\n}\n\nexport interface StorageOperationsFactoryParams {\n documentClient: DynamoDBDocument;\n elasticsearch: Client;\n table?: string;\n esTable?: string;\n plugins?: PluginCollection;\n}\n\nexport interface CmsContext extends BaseCmsContext {\n [key: string]: any;\n}\n\nexport interface IGetEntitiesResponse {\n groups: IGroupEntity;\n models: IModelEntity;\n entries: IEntryEntity;\n entriesEs: IElasticsearchEntity;\n}\n\nexport interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations<CmsContext> {\n getTable: () => ITable;\n getEsTable: () => ITable;\n getEntities: () => IGetEntitiesResponse;\n}\n\nexport interface StorageOperationsFactory {\n (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;\n}\n\nexport interface CmsEntryStorageOperations extends BaseCmsEntryStorageOperations {\n dataLoaders: IDataLoadersHandler;\n}\n\nexport interface DataLoadersHandlerInterfaceClearAllParams {\n model: Pick<CmsModel, \"tenant\">;\n}\nexport interface IDataLoadersHandler {\n clearAll: (params?: DataLoadersHandlerInterfaceClearAllParams) => void;\n}\n"],"mappings":"AAmBA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;;AAsBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkDA,WAAYA,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA","ignoreList":[]}
1
+ {"version":3,"names":["ENTITIES"],"sources":["types.ts"],"sourcesContent":["import type { Plugin, PluginCollection } from \"@webiny/plugins/types.js\";\nimport type {\n CmsContext as BaseCmsContext,\n CmsEntry,\n CmsEntryStorageOperations as BaseCmsEntryStorageOperations,\n CmsEntryValues,\n CmsModel,\n CmsModelField,\n CmsModelFieldToGraphQLPlugin,\n CmsModelFieldType,\n HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { Client } from \"@webiny/api-opensearch\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { IEntryEntity, IGroupEntity, IModelEntity } from \"~/definitions/types.js\";\nimport type { IOpenSearchEntity as IElasticsearchEntity } from \"@webiny/api-opensearch\";\nimport type { ITable } from \"@webiny/db-dynamodb\";\n\n/**\n * A definition of the entry that is being prepared for the Elasticsearch.\n *\n * @category Elasticsearch\n * @category CmsEntry\n */\nexport interface CmsIndexEntry<T extends CmsEntryValues = CmsEntryValues> extends CmsEntry<T> {\n /**\n * Values that are not going to be indexed.\n */\n rawValues: Partial<T>;\n /**\n * Dev can add whatever keys they want and need. Just need to be careful not to break the entry.\n */\n [key: string]: any;\n}\n\n/**\n * Arguments for the method that is transforming content entry in its original form to the one we are storing to the Elasticsearch.\n *\n * @category Elasticsearch\n * @category CmsEntry\n */\nexport interface CmsModelFieldToElasticsearchToParams {\n plugins: PluginsContainer;\n model: CmsModel;\n field: CmsModelField;\n /**\n * Raw value on the entry - before prepare for storage.\n */\n rawValue: any;\n /**\n * Value prepared for storage received from base api-headless-cms package.\n */\n value: any;\n getFieldIndexPlugin(fieldType: string): CmsModelFieldToElasticsearchPlugin;\n getFieldTypePlugin(fieldType: string): CmsModelFieldToGraphQLPlugin;\n}\n\n/**\n * Arguments for the method that is transforming content entry from Elasticsearch into the original one.\n *\n * @category Elasticsearch\n * @category CmsEntry\n */\nexport interface CmsModelFieldToElasticsearchFromParams {\n plugins: PluginsContainer;\n model: CmsModel;\n field: CmsModelField;\n value: any;\n rawValue: any;\n getFieldIndexPlugin(fieldType: string): CmsModelFieldToElasticsearchPlugin;\n getFieldTypePlugin(fieldType: string): CmsModelFieldToGraphQLPlugin;\n}\n\ninterface ToIndexValue {\n /**\n * Use this key to store value for indexing.\n */\n value?: any;\n /**\n * Use this key to tell ES that this value should not be indexed.\n */\n rawValue?: any;\n}\n\n/**\n * A plugin defining transformation of entry for Elasticsearch.\n *\n * @category Plugin\n * @category ContentModelField\n * @category CmsEntry\n * @category Elasticsearch\n */\nexport interface CmsModelFieldToElasticsearchPlugin extends Plugin {\n /**\n * A plugin type\n */\n type: \"cms-model-field-to-elastic-search\";\n /**\n * A unique identifier of the field type (text, number, json, myField, ...).\n *\n * ```ts\n * fieldType: \"myField\"\n * ```\n */\n fieldType: CmsModelFieldType;\n /**\n * If you need to define a type when building an Elasticsearch query.\n * Check [dateTimeIndexing](https://github.com/webiny/webiny-js/blob/3074165701b8b45e5fc6ac2444caace7d04ada66/packages/api-headless-cms/src/content/plugins/es/indexing/dateTimeIndexing.ts) plugin for usage example.\n *\n * ```ts\n * unmappedType: \"date\"\n * ```\n */\n unmappedType?: (field: Pick<CmsModelField, \"fieldId\" | \"type\">) => string;\n /**\n * This is meant to do some transformation of the entry, preferably only to fieldType it was defined for. Nothing is stopping you to do anything you want to other fields, but try to separate field transformations.\n * It returns `Partial<CmsContentIndexEntryType>`. Always return a top-level property of the entry since it is merged via spread operator.\n *\n * ```ts\n * toIndex({ value }) {\n * return {\n * value: value, // This will be stored and indexed\n * rawValue: JSON.stringify(value) // This will be stored but excluded from indexing\n * };\n * }\n * ```\n */\n toIndex?: (params: CmsModelFieldToElasticsearchToParams) => ToIndexValue;\n /**\n * This is meant to revert a transformation done in the `toIndex` method.\n * You have access to \"value\" or a \"rawValue\", depending on what you returned from `toIndex`.\n *\n * ```ts\n * fromIndex({ value, rawValue }) {\n * return JSON.parse(rawValue);\n * }\n * ```\n */\n fromIndex?: (params: CmsModelFieldToElasticsearchFromParams) => any;\n}\n\nexport enum ENTITIES {\n GROUPS = \"CmsGroups\",\n MODELS = \"CmsModels\",\n ENTRIES = \"CmsEntries\",\n ENTRIES_ES = \"CmsEntriesElasticsearch\"\n}\n\nexport interface StorageOperationsFactoryParams {\n documentClient: DynamoDBDocument;\n elasticsearch: Client;\n table?: string;\n esTable?: string;\n plugins?: PluginCollection;\n}\n\nexport interface CmsContext extends BaseCmsContext {\n [key: string]: any;\n}\n\nexport interface IGetEntitiesResponse {\n groups: IGroupEntity;\n models: IModelEntity;\n entries: IEntryEntity;\n entriesEs: IElasticsearchEntity;\n}\n\nexport interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations<CmsContext> {\n getTable: () => ITable;\n getEsTable: () => ITable;\n getEntities: () => IGetEntitiesResponse;\n}\n\nexport interface StorageOperationsFactory {\n (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;\n}\n\nexport interface CmsEntryStorageOperations extends BaseCmsEntryStorageOperations {\n dataLoaders: IDataLoadersHandler;\n}\n\nexport interface DataLoadersHandlerInterfaceClearAllParams {\n model: Pick<CmsModel, \"tenant\">;\n}\nexport interface IDataLoadersHandler {\n clearAll: (params?: DataLoadersHandlerInterfaceClearAllParams) => void;\n}\n"],"mappings":"AAmBA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;;AAsBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkDA,WAAYA,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA","ignoreList":[]}