@webiny/api-headless-cms-ddb-es 6.6.0-alpha.0 → 6.6.0-alpha.1
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.
- package/abstractions/CmsDdbEsEntriesEsEntity.d.ts +1 -1
- package/abstractions/CmsDdbEsEntriesEsEntity.js.map +1 -1
- package/feature.js +1 -1
- package/feature.js.map +1 -1
- package/operations/entry/DdbEsCreateEntry.d.ts +3 -2
- package/operations/entry/DdbEsCreateEntry.js +7 -4
- package/operations/entry/DdbEsCreateEntry.js.map +1 -1
- package/operations/entry/DdbEsCreateEntryRevisionFrom.d.ts +3 -2
- package/operations/entry/DdbEsCreateEntryRevisionFrom.js +7 -4
- package/operations/entry/DdbEsCreateEntryRevisionFrom.js.map +1 -1
- package/operations/entry/DdbEsDeleteEntryRevision.d.ts +3 -2
- package/operations/entry/DdbEsDeleteEntryRevision.js +7 -4
- package/operations/entry/DdbEsDeleteEntryRevision.js.map +1 -1
- package/operations/entry/DdbEsGetUniqueFieldValues.d.ts +3 -2
- package/operations/entry/DdbEsGetUniqueFieldValues.js +8 -5
- package/operations/entry/DdbEsGetUniqueFieldValues.js.map +1 -1
- package/operations/entry/DdbEsListEntries.d.ts +3 -2
- package/operations/entry/DdbEsListEntries.js +8 -5
- package/operations/entry/DdbEsListEntries.js.map +1 -1
- package/operations/entry/DdbEsMoveEntry.js.map +1 -1
- package/operations/entry/DdbEsMoveToBin.js.map +1 -1
- package/operations/entry/DdbEsPublishEntry.d.ts +3 -2
- package/operations/entry/DdbEsPublishEntry.js +7 -4
- package/operations/entry/DdbEsPublishEntry.js.map +1 -1
- package/operations/entry/DdbEsRestoreFromBin.js.map +1 -1
- package/operations/entry/DdbEsUnpublishEntry.d.ts +3 -2
- package/operations/entry/DdbEsUnpublishEntry.js +7 -4
- package/operations/entry/DdbEsUnpublishEntry.js.map +1 -1
- package/operations/entry/DdbEsUpdateEntry.d.ts +3 -2
- package/operations/entry/DdbEsUpdateEntry.js +7 -4
- package/operations/entry/DdbEsUpdateEntry.js.map +1 -1
- package/operations/model/DdbEsCreateModel.d.ts +3 -1
- package/operations/model/DdbEsCreateModel.js +8 -4
- package/operations/model/DdbEsCreateModel.js.map +1 -1
- package/operations/model/DdbEsDeleteModel.d.ts +1 -3
- package/operations/model/DdbEsDeleteModel.js +2 -21
- package/operations/model/DdbEsDeleteModel.js.map +1 -1
- package/package.json +27 -27
- package/tasks/CreateElasticsearchIndexTask.d.ts +3 -3
- package/tasks/CreateElasticsearchIndexTask.js +15 -24
- package/tasks/CreateElasticsearchIndexTask.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/entry/DdbEsUpdateEntry.js","sources":["../../../src/operations/entry/DdbEsUpdateEntry.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { UpdateEntryStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/UpdateEntryStorageOperation.js\";\nimport { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\nimport { CmsDdbEsEntriesEsEntity } from \"~/abstractions/CmsDdbEsEntriesEsEntity.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport {\n CmsEntryOpenSearchFieldIndexRegistry,\n CmsEntryOpenSearchValuesModifier\n} from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\nimport { configurations } from \"@webiny/api-headless-cms-utils-os/configurations.js\";\nimport { createTransformer } from \"./transformations/index.js\";\nimport {\n createEntryLatestKeys,\n createEntryPublishedKeys,\n createEntryRevisionKeys,\n createPartitionKey,\n createRevisionSortKey\n} from \"./keys.js\";\nimport {\n isEntryLevelEntryMetaField,\n pickEntryMetaFields\n} from \"@webiny/api-headless-cms/constants.js\";\nimport type { IEntryEntityAttributes } from \"~/definitions/types.js\";\nimport type { CmsIndexEntry } from \"@webiny/api-headless-cms-utils-os/types.js\";\n\nclass DdbEsUpdateEntryImpl implements UpdateEntryStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEsEntryEntity.Interface,\n private esEntity: CmsDdbEsEntriesEsEntity.Interface,\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface,\n private compressionHandler: CompressionHandler.Interface,\n private valuesModifiers: CmsEntryOpenSearchValuesModifier.Interface[]\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsUpdateParams<T>\n ) {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = this.storageModelProvider.getModel(initialModel);\n\n const transformer = createTransformer({\n valuesModifiers: this.valuesModifiers,\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry,\n fieldIndexRegistry: this.fieldIndexRegistry,\n compressionHandler: this.compressionHandler\n });\n\n const { entry, storageEntry } = transformer.transformEntryKeys();\n\n const isPublished = entry.status === \"published\";\n const locked = isPublished ? true : entry.locked;\n\n const revisionKeys = createEntryRevisionKeys(entry);\n const latestKeys = createEntryLatestKeys(entry);\n const publishedKeys = createEntryPublishedKeys(entry);\n\n /**\n * We need the latest entry to check if it needs to be updated.\n */\n const [latestStorageEntry] = await this.dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const [publishedStorageEntry] = await this.dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const entityBatch = this.entity.createEntityWriter({\n put: [\n {\n ...revisionKeys,\n data: {\n ...storageEntry,\n locked\n }\n }\n ]\n });\n\n if (isPublished) {\n entityBatch.put({\n ...publishedKeys,\n data: {\n ...storageEntry,\n locked\n }\n });\n }\n\n const elasticsearchEntityBatch = this.esEntity.createEntityWriter();\n\n const { index: esIndex } = configurations.es({\n model\n });\n\n /**\n * If the latest entry is the one being updated, we need to create a new latest entry records.\n */\n if (latestStorageEntry) {\n const updatingLatestRevision = latestStorageEntry.id === entry.id;\n if (updatingLatestRevision) {\n /**\n * First we update the regular DynamoDB table.\n */\n entityBatch.put({\n ...latestKeys,\n data: storageEntry\n });\n\n /**\n * And then update the Elasticsearch table to propagate changes to the Elasticsearch\n */\n const elasticsearchLatestData = await transformer.getElasticsearchLatestEntryData();\n\n elasticsearchEntityBatch.put({\n ...latestKeys,\n index: esIndex,\n data: elasticsearchLatestData\n });\n } else {\n /**\n * If not updating latest revision, we still want to update the latest revision's\n * entry-level meta fields to match the current revision's entry-level meta fields.\n */\n const updatedEntryLevelMetaFields = pickEntryMetaFields(\n entry,\n isEntryLevelEntryMetaField\n );\n\n const updatedLatestStorageEntry: IEntryEntityAttributes = {\n ...latestKeys,\n data: {\n ...latestStorageEntry,\n ...updatedEntryLevelMetaFields\n }\n };\n\n /**\n * First we update the regular DynamoDB table. Two updates are needed:\n * - one for the actual revision record\n * - one for the latest record\n */\n entityBatch.put({\n ...updatedLatestStorageEntry,\n PK: createPartitionKey({\n id: latestStorageEntry.id,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(latestStorageEntry)\n });\n\n entityBatch.put({\n ...updatedLatestStorageEntry\n });\n\n /**\n * Update the Elasticsearch table to propagate changes to the Elasticsearch.\n */\n const latestEsEntry = await this.esEntity.getClean(latestKeys);\n\n if (latestEsEntry) {\n const latestEsEntryDataDecompressed = (await this.compressionHandler.decompress(\n latestEsEntry.data\n )) as CmsIndexEntry;\n\n const updatedLatestEntry = await this.compressionHandler.compress({\n ...latestEsEntryDataDecompressed,\n ...updatedEntryLevelMetaFields\n });\n\n elasticsearchEntityBatch.put({\n ...latestKeys,\n index: esIndex,\n data: updatedLatestEntry\n });\n }\n }\n }\n\n if (isPublished && publishedStorageEntry?.id === entry.id) {\n const elasticsearchPublishedData =\n await transformer.getElasticsearchPublishedEntryData();\n elasticsearchEntityBatch.put({\n ...publishedKeys,\n index: esIndex,\n data: elasticsearchPublishedData\n });\n }\n try {\n await entityBatch.execute();\n\n this.dataLoaders.clearAll({\n tenant: entry.tenant\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry DynamoDB records.\",\n ex.code || \"UPDATE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n try {\n await elasticsearchEntityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry DynamoDB Elasticsearch records.\",\n ex.code || \"UPDATE_ES_ENTRY_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n return initialStorageEntry;\n }\n}\n\nexport const DdbEsUpdateEntry = UpdateEntryStorageOperation.createImplementation({\n implementation: DdbEsUpdateEntryImpl,\n dependencies: [\n CmsDdbEsEntryEntity,\n CmsDdbEsEntriesEsEntity,\n CmsDdbEsDataLoaders,\n CmsStorageModelProvider,\n CmsEntryOpenSearchFieldIndexRegistry,\n CompressionHandler,\n [CmsEntryOpenSearchValuesModifier, { multiple: true }]\n ]\n});\n"],"names":["DdbEsUpdateEntryImpl","entity","esEntity","dataLoaders","storageModelProvider","fieldIndexRegistry","compressionHandler","valuesModifiers","initialModel","params","initialEntry","initialStorageEntry","model","transformer","createTransformer","entry","storageEntry","isPublished","locked","revisionKeys","createEntryRevisionKeys","latestKeys","createEntryLatestKeys","publishedKeys","createEntryPublishedKeys","latestStorageEntry","publishedStorageEntry","entityBatch","elasticsearchEntityBatch","esIndex","configurations","updatingLatestRevision","elasticsearchLatestData","updatedEntryLevelMetaFields","pickEntryMetaFields","isEntryLevelEntryMetaField","updatedLatestStorageEntry","createPartitionKey","createRevisionSortKey","latestEsEntry","latestEsEntryDataDecompressed","updatedLatestEntry","elasticsearchPublishedData","ex","WebinyError","DdbEsUpdateEntry","UpdateEntryStorageOperation","CmsDdbEsEntryEntity","CmsDdbEsEntriesEsEntity","CmsDdbEsDataLoaders","CmsStorageModelProvider","CmsEntryOpenSearchFieldIndexRegistry","CompressionHandler","CmsEntryOpenSearchValuesModifier"],"mappings":";;;;;;;;;;;;AAgCA,MAAMA;IACF,YACYC,MAAqC,EACrCC,QAA2C,EAC3CC,WAA0C,EAC1CC,oBAAuD,EACvDC,kBAAkE,EAClEC,kBAAgD,EAChDC,eAA6D,CACvE;aAPUN,MAAM,GAANA;aACAC,QAAQ,GAARA;aACAC,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;aACAC,kBAAkB,GAAlBA;aACAC,kBAAkB,GAAlBA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAAgD,EAClD;QACE,MAAM,EAAE,OAAOC,YAAY,EAAE,cAAcC,mBAAmB,EAAE,GAAGF;QACnE,MAAMG,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAACJ;QAEjD,MAAMK,cAAcC,kBAAkB;YAClC,iBAAiB,IAAI,CAAC,eAAe;YACrCF;YACA,OAAOF;YACP,cAAcC;YACd,oBAAoB,IAAI,CAAC,kBAAkB;YAC3C,oBAAoB,IAAI,CAAC,kBAAkB;QAC/C;QAEA,MAAM,EAAEI,KAAK,EAAEC,YAAY,EAAE,GAAGH,YAAY,kBAAkB;QAE9D,MAAMI,cAAcF,AAAiB,gBAAjBA,MAAM,MAAM;QAChC,MAAMG,SAASD,cAAc,OAAOF,MAAM,MAAM;QAEhD,MAAMI,eAAeC,wBAAwBL;QAC7C,MAAMM,aAAaC,sBAAsBP;QACzC,MAAMQ,gBAAgBC,yBAAyBT;QAK/C,MAAM,CAACU,mBAAmB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,0BAA0B,CAAC;YAC3Eb;YACA,KAAK;gBAACG,MAAM,EAAE;aAAC;QACnB;QAEA,MAAM,CAACW,sBAAsB,GAAG,MAAM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CAAC,QAAQ,CAAClB;gBAEnD,IAAIkB,eAAe;oBACf,MAAMC,gCAAiC,MAAM,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAC3ED,cAAc,IAAI;oBAGtB,MAAME,qBAAqB,MAAM,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC;wBAC9D,GAAGD,6BAA6B;wBAChC,GAAGP,2BAA2B;oBAClC;oBAEAL,yBAAyB,GAAG,CAAC;wBACzB,GAAGP,UAAU;wBACb,OAAOQ;wBACP,MAAMY;oBACV;gBACJ;YACJ;QACJ;QAEA,IAAIxB,eAAeS,uBAAuB,OAAOX,MAAM,EAAE,EAAE;YACvD,MAAM2B,6BACF,MAAM7B,YAAY,kCAAkC;YACxDe,yBAAyB,GAAG,CAAC;gBACzB,GAAGL,aAAa;gBAChB,OAAOM;gBACP,MAAMa;YACV;QACJ;QACA,IAAI;YACA,MAAMf,YAAY,OAAO;YAEzB,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;gBACtB,QAAQZ,MAAM,MAAM;YACxB;QACJ,EAAE,OAAO4B,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,4CACdA,GAAG,IAAI,IAAI,sBACX;gBACI,OAAOA;gBACP5B;gBACAC;YACJ;QAER;QACA,IAAI;YACA,MAAMY,yBAAyB,OAAO;QAC1C,EAAE,OAAOe,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,0DACdA,GAAG,IAAI,IAAI,yBACX;gBACI,OAAOA;gBACP5B;YACJ;QAER;QACA,OAAOJ;IACX;AACJ;AAEO,MAAMkC,mBAAmBC,4BAA4B,oBAAoB,CAAC;IAC7E,gBAAgB9C;IAChB,cAAc;QACV+C;QACAC;QACAC;QACAC;QACAC;QACAC;QACA;YAACC;YAAkC;gBAAE,UAAU;YAAK;SAAE;KACzD;AACL"}
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbEsUpdateEntry.js","sources":["../../../src/operations/entry/DdbEsUpdateEntry.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { UpdateEntryStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/UpdateEntryStorageOperation.js\";\nimport { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\nimport { CmsDdbEsEntriesEsEntity } from \"~/abstractions/CmsDdbEsEntriesEsEntity.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport {\n CmsEntryOpenSearchFieldIndexRegistry,\n CmsEntryOpenSearchValuesModifier,\n CmsModelOpenSearchIndexProvider\n} from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\nimport { createConfigurations } from \"@webiny/api-headless-cms-utils-os/configurations.js\";\nimport { createTransformer } from \"./transformations/index.js\";\nimport {\n createEntryLatestKeys,\n createEntryPublishedKeys,\n createEntryRevisionKeys,\n createPartitionKey,\n createRevisionSortKey\n} from \"./keys.js\";\nimport {\n isEntryLevelEntryMetaField,\n pickEntryMetaFields\n} from \"@webiny/api-headless-cms/constants.js\";\nimport type { IEntryEntityAttributes } from \"~/definitions/types.js\";\nimport type { CmsIndexEntry } from \"@webiny/api-headless-cms-utils-os/types.js\";\n\nclass DdbEsUpdateEntryImpl implements UpdateEntryStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEsEntryEntity.Interface,\n private esEntity: CmsDdbEsEntriesEsEntity.Interface,\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface,\n private compressionHandler: CompressionHandler.Interface,\n private indexProvider: CmsModelOpenSearchIndexProvider.Interface,\n private valuesModifiers: CmsEntryOpenSearchValuesModifier.Interface[]\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsUpdateParams<T>\n ) {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = this.storageModelProvider.getModel(initialModel);\n\n const transformer = createTransformer({\n valuesModifiers: this.valuesModifiers,\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry,\n fieldIndexRegistry: this.fieldIndexRegistry,\n compressionHandler: this.compressionHandler\n });\n\n const { entry, storageEntry } = transformer.transformEntryKeys();\n\n const isPublished = entry.status === \"published\";\n const locked = isPublished ? true : entry.locked;\n\n const revisionKeys = createEntryRevisionKeys(entry);\n const latestKeys = createEntryLatestKeys(entry);\n const publishedKeys = createEntryPublishedKeys(entry);\n\n /**\n * We need the latest entry to check if it needs to be updated.\n */\n const [latestStorageEntry] = await this.dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const [publishedStorageEntry] = await this.dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const entityBatch = this.entity.createEntityWriter({\n put: [\n {\n ...revisionKeys,\n data: {\n ...storageEntry,\n locked\n }\n }\n ]\n });\n\n if (isPublished) {\n entityBatch.put({\n ...publishedKeys,\n data: {\n ...storageEntry,\n locked\n }\n });\n }\n\n const elasticsearchEntityBatch = this.esEntity.createEntityWriter();\n\n const configurations = createConfigurations(this.indexProvider);\n const { index: esIndex } = await configurations.es({\n model\n });\n\n /**\n * If the latest entry is the one being updated, we need to create a new latest entry records.\n */\n if (latestStorageEntry) {\n const updatingLatestRevision = latestStorageEntry.id === entry.id;\n if (updatingLatestRevision) {\n /**\n * First we update the regular DynamoDB table.\n */\n entityBatch.put({\n ...latestKeys,\n data: storageEntry\n });\n\n /**\n * And then update the Elasticsearch table to propagate changes to the Elasticsearch\n */\n const elasticsearchLatestData = await transformer.getElasticsearchLatestEntryData();\n\n elasticsearchEntityBatch.put({\n ...latestKeys,\n index: esIndex,\n data: elasticsearchLatestData\n });\n } else {\n /**\n * If not updating latest revision, we still want to update the latest revision's\n * entry-level meta fields to match the current revision's entry-level meta fields.\n */\n const updatedEntryLevelMetaFields = pickEntryMetaFields(\n entry,\n isEntryLevelEntryMetaField\n );\n\n const updatedLatestStorageEntry: IEntryEntityAttributes = {\n ...latestKeys,\n data: {\n ...latestStorageEntry,\n ...updatedEntryLevelMetaFields\n }\n };\n\n /**\n * First we update the regular DynamoDB table. Two updates are needed:\n * - one for the actual revision record\n * - one for the latest record\n */\n entityBatch.put({\n ...updatedLatestStorageEntry,\n PK: createPartitionKey({\n id: latestStorageEntry.id,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(latestStorageEntry)\n });\n\n entityBatch.put({\n ...updatedLatestStorageEntry\n });\n\n /**\n * Update the Elasticsearch table to propagate changes to the Elasticsearch.\n */\n const latestEsEntry = await this.esEntity.getClean(latestKeys);\n\n if (latestEsEntry) {\n const latestEsEntryDataDecompressed = (await this.compressionHandler.decompress(\n latestEsEntry.data\n )) as CmsIndexEntry;\n\n const updatedLatestEntry = await this.compressionHandler.compress({\n ...latestEsEntryDataDecompressed,\n ...updatedEntryLevelMetaFields\n });\n\n elasticsearchEntityBatch.put({\n ...latestKeys,\n index: esIndex,\n data: updatedLatestEntry\n });\n }\n }\n }\n\n if (isPublished && publishedStorageEntry?.id === entry.id) {\n const elasticsearchPublishedData =\n await transformer.getElasticsearchPublishedEntryData();\n elasticsearchEntityBatch.put({\n ...publishedKeys,\n index: esIndex,\n data: elasticsearchPublishedData\n });\n }\n try {\n await entityBatch.execute();\n\n this.dataLoaders.clearAll({\n tenant: entry.tenant\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry DynamoDB records.\",\n ex.code || \"UPDATE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n try {\n await elasticsearchEntityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry DynamoDB Elasticsearch records.\",\n ex.code || \"UPDATE_ES_ENTRY_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n return initialStorageEntry;\n }\n}\n\nexport const DdbEsUpdateEntry = UpdateEntryStorageOperation.createImplementation({\n implementation: DdbEsUpdateEntryImpl,\n dependencies: [\n CmsDdbEsEntryEntity,\n CmsDdbEsEntriesEsEntity,\n CmsDdbEsDataLoaders,\n CmsStorageModelProvider,\n CmsEntryOpenSearchFieldIndexRegistry,\n CompressionHandler,\n CmsModelOpenSearchIndexProvider,\n [CmsEntryOpenSearchValuesModifier, { multiple: true }]\n ]\n});\n"],"names":["DdbEsUpdateEntryImpl","entity","esEntity","dataLoaders","storageModelProvider","fieldIndexRegistry","compressionHandler","indexProvider","valuesModifiers","initialModel","params","initialEntry","initialStorageEntry","model","transformer","createTransformer","entry","storageEntry","isPublished","locked","revisionKeys","createEntryRevisionKeys","latestKeys","createEntryLatestKeys","publishedKeys","createEntryPublishedKeys","latestStorageEntry","publishedStorageEntry","entityBatch","elasticsearchEntityBatch","configurations","createConfigurations","esIndex","updatingLatestRevision","elasticsearchLatestData","updatedEntryLevelMetaFields","pickEntryMetaFields","isEntryLevelEntryMetaField","updatedLatestStorageEntry","createPartitionKey","createRevisionSortKey","latestEsEntry","latestEsEntryDataDecompressed","updatedLatestEntry","elasticsearchPublishedData","ex","WebinyError","DdbEsUpdateEntry","UpdateEntryStorageOperation","CmsDdbEsEntryEntity","CmsDdbEsEntriesEsEntity","CmsDdbEsDataLoaders","CmsStorageModelProvider","CmsEntryOpenSearchFieldIndexRegistry","CompressionHandler","CmsModelOpenSearchIndexProvider","CmsEntryOpenSearchValuesModifier"],"mappings":";;;;;;;;;;;;AAiCA,MAAMA;IACF,YACYC,MAAqC,EACrCC,QAA2C,EAC3CC,WAA0C,EAC1CC,oBAAuD,EACvDC,kBAAkE,EAClEC,kBAAgD,EAChDC,aAAwD,EACxDC,eAA6D,CACvE;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C;oBAEAN,yBAAyB,GAAG,CAAC;wBACzB,GAAGP,UAAU;wBACb,OAAOU;wBACP,MAAMW;oBACV;gBACJ;YACJ;QACJ;QAEA,IAAIzB,eAAeS,uBAAuB,OAAOX,MAAM,EAAE,EAAE;YACvD,MAAM4B,6BACF,MAAM9B,YAAY,kCAAkC;YACxDe,yBAAyB,GAAG,CAAC;gBACzB,GAAGL,aAAa;gBAChB,OAAOQ;gBACP,MAAMY;YACV;QACJ;QACA,IAAI;YACA,MAAMhB,YAAY,OAAO;YAEzB,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;gBACtB,QAAQZ,MAAM,MAAM;YACxB;QACJ,EAAE,OAAO6B,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,4CACdA,GAAG,IAAI,IAAI,sBACX;gBACI,OAAOA;gBACP7B;gBACAC;YACJ;QAER;QACA,IAAI;YACA,MAAMY,yBAAyB,OAAO;QAC1C,EAAE,OAAOgB,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,0DACdA,GAAG,IAAI,IAAI,yBACX;gBACI,OAAOA;gBACP7B;YACJ;QAER;QACA,OAAOJ;IACX;AACJ;AAEO,MAAMmC,mBAAmBC,4BAA4B,oBAAoB,CAAC;IAC7E,gBAAgBhD;IAChB,cAAc;QACViD;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACA;YAACC;YAAkC;gBAAE,UAAU;YAAK;SAAE;KACzD;AACL"}
|
|
@@ -2,10 +2,12 @@ import type { CmsModelStorageOperationsCreateParams } from "@webiny/api-headless
|
|
|
2
2
|
import { CreateModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/CreateModelStorageOperation.js";
|
|
3
3
|
import { CmsDdbEsModelEntity } from "../../abstractions/CmsDdbEsModelEntity.js";
|
|
4
4
|
import { OpenSearchClient } from "@webiny/api-opensearch/exports/api/opensearch.js";
|
|
5
|
+
import { CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
5
6
|
declare class DdbEsCreateModelImpl implements CreateModelStorageOperation.Interface {
|
|
6
7
|
private entity;
|
|
8
|
+
private indexProvider;
|
|
7
9
|
private elasticsearch;
|
|
8
|
-
constructor(entity: CmsDdbEsModelEntity.Interface, openSearchClient: OpenSearchClient.Interface);
|
|
10
|
+
constructor(entity: CmsDdbEsModelEntity.Interface, openSearchClient: OpenSearchClient.Interface, indexProvider: CmsModelOpenSearchIndexProvider.Interface);
|
|
9
11
|
execute(params: CmsModelStorageOperationsCreateParams): Promise<import("@webiny/api-headless-cms/types/model.js").StorageCmsModel>;
|
|
10
12
|
}
|
|
11
13
|
export declare const DdbEsCreateModel: typeof DdbEsCreateModelImpl & {
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import _webiny_error from "@webiny/error";
|
|
2
|
-
import {
|
|
2
|
+
import { createConfigurations } from "@webiny/api-headless-cms-utils-os/configurations.js";
|
|
3
3
|
import { CreateModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/CreateModelStorageOperation.js";
|
|
4
4
|
import { CmsDdbEsModelEntity } from "../../abstractions/CmsDdbEsModelEntity.js";
|
|
5
5
|
import { OpenSearchClient } from "@webiny/api-opensearch/exports/api/opensearch.js";
|
|
6
6
|
import { createKeys, createType } from "./keys.js";
|
|
7
|
+
import { CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
7
8
|
class DdbEsCreateModelImpl {
|
|
8
|
-
constructor(entity, openSearchClient){
|
|
9
|
+
constructor(entity, openSearchClient, indexProvider){
|
|
9
10
|
this.entity = entity;
|
|
11
|
+
this.indexProvider = indexProvider;
|
|
10
12
|
this.elasticsearch = openSearchClient.use();
|
|
11
13
|
}
|
|
12
14
|
async execute(params) {
|
|
13
15
|
const { model } = params;
|
|
14
|
-
const
|
|
16
|
+
const configurations = createConfigurations(this.indexProvider);
|
|
17
|
+
const { index } = await configurations.es({
|
|
15
18
|
model
|
|
16
19
|
});
|
|
17
20
|
const keys = createKeys(model);
|
|
@@ -44,7 +47,8 @@ const DdbEsCreateModel = CreateModelStorageOperation.createImplementation({
|
|
|
44
47
|
implementation: DdbEsCreateModelImpl,
|
|
45
48
|
dependencies: [
|
|
46
49
|
CmsDdbEsModelEntity,
|
|
47
|
-
OpenSearchClient
|
|
50
|
+
OpenSearchClient,
|
|
51
|
+
CmsModelOpenSearchIndexProvider
|
|
48
52
|
]
|
|
49
53
|
});
|
|
50
54
|
export { DdbEsCreateModel };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/model/DdbEsCreateModel.js","sources":["../../../src/operations/model/DdbEsCreateModel.ts"],"sourcesContent":["import type { CmsModelStorageOperationsCreateParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport {
|
|
1
|
+
{"version":3,"file":"operations/model/DdbEsCreateModel.js","sources":["../../../src/operations/model/DdbEsCreateModel.ts"],"sourcesContent":["import type { CmsModelStorageOperationsCreateParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { createConfigurations } from \"@webiny/api-headless-cms-utils-os/configurations.js\";\nimport { CreateModelStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/model/CreateModelStorageOperation.js\";\nimport { CmsDdbEsModelEntity } from \"~/abstractions/CmsDdbEsModelEntity.js\";\nimport { OpenSearchClient } from \"@webiny/api-opensearch/exports/api/opensearch.js\";\nimport { createKeys, createType } from \"./keys.js\";\nimport { CmsModelOpenSearchIndexProvider } from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\n\nclass DdbEsCreateModelImpl implements CreateModelStorageOperation.Interface {\n private elasticsearch;\n\n constructor(\n private entity: CmsDdbEsModelEntity.Interface,\n openSearchClient: OpenSearchClient.Interface,\n private indexProvider: CmsModelOpenSearchIndexProvider.Interface\n ) {\n this.elasticsearch = openSearchClient.use();\n }\n\n async execute(params: CmsModelStorageOperationsCreateParams) {\n const { model } = params;\n\n const configurations = createConfigurations(this.indexProvider);\n const { index } = await configurations.es({\n model\n });\n\n const keys = createKeys(model);\n\n let error;\n try {\n await this.entity.put({\n data: model,\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n error = ex;\n }\n try {\n await this.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\nexport const DdbEsCreateModel = CreateModelStorageOperation.createImplementation({\n implementation: DdbEsCreateModelImpl,\n dependencies: [CmsDdbEsModelEntity, OpenSearchClient, CmsModelOpenSearchIndexProvider]\n});\n"],"names":["DdbEsCreateModelImpl","entity","openSearchClient","indexProvider","params","model","configurations","createConfigurations","index","keys","createKeys","error","createType","ex","WebinyError","DdbEsCreateModel","CreateModelStorageOperation","CmsDdbEsModelEntity","OpenSearchClient","CmsModelOpenSearchIndexProvider"],"mappings":";;;;;;;AASA,MAAMA;IAGF,YACYC,MAAqC,EAC7CC,gBAA4C,EACpCC,aAAwD,CAClE;aAHUF,MAAM,GAANA;aAEAE,aAAa,GAAbA;QAER,IAAI,CAAC,aAAa,GAAGD,iBAAiB,GAAG;IAC7C;IAEA,MAAM,QAAQE,MAA6C,EAAE;QACzD,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAElB,MAAME,iBAAiBC,qBAAqB,IAAI,CAAC,aAAa;QAC9D,MAAM,EAAEC,KAAK,EAAE,GAAG,MAAMF,eAAe,EAAE,CAAC;YACtCD;QACJ;QAEA,MAAMI,OAAOC,WAAWL;QAExB,IAAIM;QACJ,IAAI;YACA,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;gBAClB,MAAMN;gBACN,GAAGI,IAAI;gBACP,MAAMG;YACV;YACA,OAAOP;QACX,EAAE,OAAOQ,IAAI;YACTF,QAAQE;QACZ;QACA,IAAI;YACA,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC;gBACpCL;gBACA,oBAAoB;YACxB;QACJ,EAAE,OAAOK,IAAI;YACT,MAAM,IAAIC,cACN,CAAC,sCAAsC,EAAEN,MAAM,0CAA0C,CAAC,EAC1F,4BACA;gBACI,eAAeG;gBACf,oBAAoBE;YACxB;QAER;QACA,MAAMF;IACV;AACJ;AAEO,MAAMI,mBAAmBC,4BAA4B,oBAAoB,CAAC;IAC7E,gBAAgBhB;IAChB,cAAc;QAACiB;QAAqBC;QAAkBC;KAAgC;AAC1F"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { CmsModelStorageOperationsDeleteParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
2
|
import { DeleteModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/DeleteModelStorageOperation.js";
|
|
3
3
|
import { CmsDdbEsModelEntity } from "../../abstractions/CmsDdbEsModelEntity.js";
|
|
4
|
-
import { OpenSearchClient } from "@webiny/api-opensearch/exports/api/opensearch.js";
|
|
5
4
|
declare class DdbEsDeleteModelImpl implements DeleteModelStorageOperation.Interface {
|
|
6
5
|
private entity;
|
|
7
|
-
|
|
8
|
-
constructor(entity: CmsDdbEsModelEntity.Interface, openSearchClient: OpenSearchClient.Interface);
|
|
6
|
+
constructor(entity: CmsDdbEsModelEntity.Interface);
|
|
9
7
|
execute(params: CmsModelStorageOperationsDeleteParams): Promise<void>;
|
|
10
8
|
}
|
|
11
9
|
export declare const DdbEsDeleteModel: typeof DdbEsDeleteModelImpl & {
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import error from "@webiny/error";
|
|
2
|
-
import { configurations } from "@webiny/api-headless-cms-utils-os/configurations.js";
|
|
3
2
|
import { DeleteModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/DeleteModelStorageOperation.js";
|
|
4
3
|
import { CmsDdbEsModelEntity } from "../../abstractions/CmsDdbEsModelEntity.js";
|
|
5
|
-
import { OpenSearchClient } from "@webiny/api-opensearch/exports/api/opensearch.js";
|
|
6
4
|
import { createKeys } from "./keys.js";
|
|
7
5
|
class DdbEsDeleteModelImpl {
|
|
8
|
-
constructor(entity
|
|
6
|
+
constructor(entity){
|
|
9
7
|
this.entity = entity;
|
|
10
|
-
this.elasticsearch = openSearchClient.use();
|
|
11
8
|
}
|
|
12
9
|
async execute(params) {
|
|
13
10
|
const { model } = params;
|
|
14
11
|
const keys = createKeys(model);
|
|
15
|
-
const { index } = configurations.es({
|
|
16
|
-
model
|
|
17
|
-
});
|
|
18
12
|
try {
|
|
19
13
|
await this.entity.delete(keys);
|
|
20
14
|
} catch (ex) {
|
|
@@ -24,25 +18,12 @@ class DdbEsDeleteModelImpl {
|
|
|
24
18
|
keys
|
|
25
19
|
});
|
|
26
20
|
}
|
|
27
|
-
try {
|
|
28
|
-
await this.elasticsearch.indices.delete({
|
|
29
|
-
index,
|
|
30
|
-
ignore_unavailable: true
|
|
31
|
-
});
|
|
32
|
-
} catch (ex) {
|
|
33
|
-
throw new error(`Could not delete elasticsearch index "${index}" after model record delete.`, "DELETE_MODEL_INDEX_ERROR", {
|
|
34
|
-
error: ex,
|
|
35
|
-
index,
|
|
36
|
-
model
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
21
|
}
|
|
40
22
|
}
|
|
41
23
|
const DdbEsDeleteModel = DeleteModelStorageOperation.createImplementation({
|
|
42
24
|
implementation: DdbEsDeleteModelImpl,
|
|
43
25
|
dependencies: [
|
|
44
|
-
CmsDdbEsModelEntity
|
|
45
|
-
OpenSearchClient
|
|
26
|
+
CmsDdbEsModelEntity
|
|
46
27
|
]
|
|
47
28
|
});
|
|
48
29
|
export { DdbEsDeleteModel };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/model/DdbEsDeleteModel.js","sources":["../../../src/operations/model/DdbEsDeleteModel.ts"],"sourcesContent":["import type { CmsModelStorageOperationsDeleteParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport {
|
|
1
|
+
{"version":3,"file":"operations/model/DdbEsDeleteModel.js","sources":["../../../src/operations/model/DdbEsDeleteModel.ts"],"sourcesContent":["import type { CmsModelStorageOperationsDeleteParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { DeleteModelStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/model/DeleteModelStorageOperation.js\";\nimport { CmsDdbEsModelEntity } from \"~/abstractions/CmsDdbEsModelEntity.js\";\nimport { createKeys } from \"./keys.js\";\n\nclass DdbEsDeleteModelImpl implements DeleteModelStorageOperation.Interface {\n constructor(private entity: CmsDdbEsModelEntity.Interface) {}\n\n async execute(params: CmsModelStorageOperationsDeleteParams): Promise<void> {\n const { model } = params;\n const keys = createKeys(model);\n\n try {\n await this.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}\n\nexport const DdbEsDeleteModel = DeleteModelStorageOperation.createImplementation({\n implementation: DdbEsDeleteModelImpl,\n dependencies: [CmsDdbEsModelEntity]\n});\n"],"names":["DdbEsDeleteModelImpl","entity","params","model","keys","createKeys","ex","WebinyError","DdbEsDeleteModel","DeleteModelStorageOperation","CmsDdbEsModelEntity"],"mappings":";;;;AAMA,MAAMA;IACF,YAAoBC,MAAqC,CAAE;aAAvCA,MAAM,GAANA;IAAwC;IAE5D,MAAM,QAAQC,MAA6C,EAAiB;QACxE,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAClB,MAAME,OAAOC,WAAWF;QAExB,IAAI;YACA,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAACC;QAC7B,EAAE,OAAOE,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,2BACdA,GAAG,IAAI,IAAI,sBACX;gBACI,OAAOA;gBACPH;gBACAC;YACJ;QAER;IACJ;AACJ;AAEO,MAAMI,mBAAmBC,4BAA4B,oBAAoB,CAAC;IAC7E,gBAAgBT;IAChB,cAAc;QAACU;KAAoB;AACvC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-ddb-es",
|
|
3
|
-
"version": "6.6.0-alpha.
|
|
3
|
+
"version": "6.6.0-alpha.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -30,40 +30,40 @@
|
|
|
30
30
|
],
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@webiny/api": "6.6.0-alpha.
|
|
34
|
-
"@webiny/api-headless-cms": "6.6.0-alpha.
|
|
35
|
-
"@webiny/api-headless-cms-storage": "6.6.0-alpha.
|
|
36
|
-
"@webiny/api-headless-cms-utils-os": "6.6.0-alpha.
|
|
37
|
-
"@webiny/api-opensearch": "6.6.0-alpha.
|
|
38
|
-
"@webiny/api-
|
|
39
|
-
"@webiny/
|
|
40
|
-
"@webiny/db
|
|
41
|
-
"@webiny/
|
|
42
|
-
"@webiny/
|
|
43
|
-
"@webiny/
|
|
44
|
-
"@webiny/
|
|
45
|
-
"@webiny/
|
|
33
|
+
"@webiny/api": "6.6.0-alpha.1",
|
|
34
|
+
"@webiny/api-headless-cms": "6.6.0-alpha.1",
|
|
35
|
+
"@webiny/api-headless-cms-storage": "6.6.0-alpha.1",
|
|
36
|
+
"@webiny/api-headless-cms-utils-os": "6.6.0-alpha.1",
|
|
37
|
+
"@webiny/api-opensearch": "6.6.0-alpha.1",
|
|
38
|
+
"@webiny/api-opensearch-aws": "6.6.0-alpha.1",
|
|
39
|
+
"@webiny/api-search-index-tasks": "6.6.0-alpha.1",
|
|
40
|
+
"@webiny/db": "6.6.0-alpha.1",
|
|
41
|
+
"@webiny/db-dynamodb": "6.6.0-alpha.1",
|
|
42
|
+
"@webiny/error": "6.6.0-alpha.1",
|
|
43
|
+
"@webiny/feature": "6.6.0-alpha.1",
|
|
44
|
+
"@webiny/plugins": "6.6.0-alpha.1",
|
|
45
|
+
"@webiny/stdlib": "0.0.17",
|
|
46
|
+
"@webiny/utils": "6.6.0-alpha.1",
|
|
46
47
|
"dataloader": "2.2.3",
|
|
47
48
|
"lodash": "4.18.1"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
51
|
"@types/jsonpack": "1.1.6",
|
|
51
|
-
"@webiny/api-core": "6.6.0-alpha.
|
|
52
|
-
"@webiny/api-core-testing": "6.6.0-alpha.
|
|
53
|
-
"@webiny/api-graphql": "6.6.0-alpha.
|
|
54
|
-
"@webiny/api-search-index-tasks-ddb-os": "6.6.0-alpha.
|
|
55
|
-
"@webiny/api-sync-ddb-to-opensearch": "6.6.0-alpha.
|
|
56
|
-
"@webiny/background-tasks": "6.6.0-alpha.
|
|
57
|
-
"@webiny/build-tools": "6.6.0-alpha.
|
|
58
|
-
"@webiny/di": "1.0
|
|
59
|
-
"@webiny/event-handler-core": "6.6.0-alpha.
|
|
60
|
-
"@webiny/handler": "6.6.0-alpha.
|
|
61
|
-
"@webiny/
|
|
62
|
-
"@webiny/wcp": "6.6.0-alpha.0",
|
|
52
|
+
"@webiny/api-core": "6.6.0-alpha.1",
|
|
53
|
+
"@webiny/api-core-testing": "6.6.0-alpha.1",
|
|
54
|
+
"@webiny/api-graphql": "6.6.0-alpha.1",
|
|
55
|
+
"@webiny/api-search-index-tasks-ddb-os": "6.6.0-alpha.1",
|
|
56
|
+
"@webiny/api-sync-ddb-to-opensearch": "6.6.0-alpha.1",
|
|
57
|
+
"@webiny/background-tasks": "6.6.0-alpha.1",
|
|
58
|
+
"@webiny/build-tools": "6.6.0-alpha.1",
|
|
59
|
+
"@webiny/di": "1.1.0",
|
|
60
|
+
"@webiny/event-handler-core": "6.6.0-alpha.1",
|
|
61
|
+
"@webiny/handler": "6.6.0-alpha.1",
|
|
62
|
+
"@webiny/wcp": "6.6.0-alpha.1",
|
|
63
63
|
"jest-dynalite": "3.6.1",
|
|
64
64
|
"rimraf": "6.1.3",
|
|
65
65
|
"typescript": "7.0.2",
|
|
66
|
-
"vitest": "4.1.
|
|
66
|
+
"vitest": "4.1.11"
|
|
67
67
|
},
|
|
68
68
|
"publishConfig": {
|
|
69
69
|
"access": "public"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { TenantIndexFactory } from "@webiny/api-search-index-tasks";
|
|
2
2
|
import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
4
4
|
declare class CreateElasticsearchIndexTaskImpl implements TenantIndexFactory.Interface {
|
|
5
|
-
private readonly
|
|
5
|
+
private readonly indexProvider;
|
|
6
6
|
private listModels;
|
|
7
|
-
constructor(
|
|
7
|
+
constructor(indexProvider: CmsModelOpenSearchIndexProvider.Interface, listModels: ListModelsUseCase.Interface);
|
|
8
8
|
getIndexList(tenant: TenantIndexFactory.Tenant): Promise<TenantIndexFactory.IndexConfig[]>;
|
|
9
9
|
}
|
|
10
10
|
export declare const CreateElasticsearchIndexTask: typeof CreateElasticsearchIndexTaskImpl & {
|
|
@@ -1,46 +1,37 @@
|
|
|
1
1
|
import { TenantIndexFactory } from "@webiny/api-search-index-tasks";
|
|
2
2
|
import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { createConfigurations } from "@webiny/api-headless-cms-utils-os/configurations.js";
|
|
4
|
+
import { CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
5
5
|
class CreateElasticsearchIndexTaskImpl {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
6
|
+
constructor(indexProvider, listModels){
|
|
7
|
+
this.indexProvider = indexProvider;
|
|
8
8
|
this.listModels = listModels;
|
|
9
9
|
}
|
|
10
10
|
async getIndexList(tenant) {
|
|
11
11
|
const result = await this.listModels.execute();
|
|
12
12
|
const models = result.value;
|
|
13
13
|
if (0 === models.length) return [];
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const configurations = createConfigurations(this.indexProvider);
|
|
15
|
+
const indices = [];
|
|
16
|
+
for (const model of models){
|
|
17
|
+
const { index, settings } = await configurations.es({
|
|
16
18
|
model: {
|
|
17
|
-
|
|
19
|
+
...model,
|
|
18
20
|
tenant: tenant.id
|
|
19
21
|
}
|
|
20
22
|
});
|
|
21
|
-
|
|
23
|
+
indices.push({
|
|
22
24
|
index,
|
|
23
|
-
settings
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
tenant: tenant.id,
|
|
28
|
-
group: model.group
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
};
|
|
32
|
-
});
|
|
25
|
+
settings
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return indices;
|
|
33
29
|
}
|
|
34
30
|
}
|
|
35
31
|
const CreateElasticsearchIndexTask = TenantIndexFactory.createImplementation({
|
|
36
32
|
implementation: CreateElasticsearchIndexTaskImpl,
|
|
37
33
|
dependencies: [
|
|
38
|
-
|
|
39
|
-
CmsEntryOpenSearchIndex,
|
|
40
|
-
{
|
|
41
|
-
multiple: true
|
|
42
|
-
}
|
|
43
|
-
],
|
|
34
|
+
CmsModelOpenSearchIndexProvider,
|
|
44
35
|
ListModelsUseCase
|
|
45
36
|
]
|
|
46
37
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks/CreateElasticsearchIndexTask.js","sources":["../../src/tasks/CreateElasticsearchIndexTask.ts"],"sourcesContent":["import { TenantIndexFactory } from \"@webiny/api-search-index-tasks\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels/index.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"tasks/CreateElasticsearchIndexTask.js","sources":["../../src/tasks/CreateElasticsearchIndexTask.ts"],"sourcesContent":["import { TenantIndexFactory } from \"@webiny/api-search-index-tasks\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels/index.js\";\nimport { createConfigurations } from \"@webiny/api-headless-cms-utils-os/configurations.js\";\nimport { CmsModelOpenSearchIndexProvider } from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\n\nclass CreateElasticsearchIndexTaskImpl implements TenantIndexFactory.Interface {\n constructor(\n private readonly indexProvider: CmsModelOpenSearchIndexProvider.Interface,\n private listModels: ListModelsUseCase.Interface\n ) {}\n\n async getIndexList(\n tenant: TenantIndexFactory.Tenant\n ): Promise<TenantIndexFactory.IndexConfig[]> {\n const result = await this.listModels.execute();\n const models = result.value;\n\n if (models.length === 0) {\n return [];\n }\n\n const configurations = createConfigurations(this.indexProvider);\n\n const indices: TenantIndexFactory.IndexConfig[] = [];\n for (const model of models) {\n const { index, settings } = await configurations.es({\n model: {\n ...model,\n tenant: tenant.id\n }\n });\n indices.push({ index, settings });\n }\n return indices;\n }\n}\n\nexport const CreateElasticsearchIndexTask = TenantIndexFactory.createImplementation({\n implementation: CreateElasticsearchIndexTaskImpl,\n dependencies: [CmsModelOpenSearchIndexProvider, ListModelsUseCase]\n});\n"],"names":["CreateElasticsearchIndexTaskImpl","indexProvider","listModels","tenant","result","models","configurations","createConfigurations","indices","model","index","settings","CreateElasticsearchIndexTask","TenantIndexFactory","CmsModelOpenSearchIndexProvider","ListModelsUseCase"],"mappings":";;;;AAKA,MAAMA;IACF,YACqBC,aAAwD,EACjEC,UAAuC,CACjD;aAFmBD,aAAa,GAAbA;aACTC,UAAU,GAAVA;IACT;IAEH,MAAM,aACFC,MAAiC,EACQ;QACzC,MAAMC,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO;QAC5C,MAAMC,SAASD,OAAO,KAAK;QAE3B,IAAIC,AAAkB,MAAlBA,OAAO,MAAM,EACb,OAAO,EAAE;QAGb,MAAMC,iBAAiBC,qBAAqB,IAAI,CAAC,aAAa;QAE9D,MAAMC,UAA4C,EAAE;QACpD,KAAK,MAAMC,SAASJ,OAAQ;YACxB,MAAM,EAAEK,KAAK,EAAEC,QAAQ,EAAE,GAAG,MAAML,eAAe,EAAE,CAAC;gBAChD,OAAO;oBACH,GAAGG,KAAK;oBACR,QAAQN,OAAO,EAAE;gBACrB;YACJ;YACAK,QAAQ,IAAI,CAAC;gBAAEE;gBAAOC;YAAS;QACnC;QACA,OAAOH;IACX;AACJ;AAEO,MAAMI,+BAA+BC,mBAAmB,oBAAoB,CAAC;IAChF,gBAAgBb;IAChB,cAAc;QAACc;QAAiCC;KAAkB;AACtE"}
|