@webiny/api-headless-cms-ddb-es 0.0.0-mt-3 → 0.0.0-unstable.2af142b57e
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/configurations.d.ts +2 -2
- package/configurations.js +13 -10
- package/configurations.js.map +1 -0
- package/definitions/entry.d.ts +2 -2
- package/definitions/entry.js +6 -12
- package/definitions/entry.js.map +1 -0
- package/definitions/entryElasticsearch.d.ts +2 -2
- package/definitions/entryElasticsearch.js +3 -12
- package/definitions/entryElasticsearch.js.map +1 -0
- package/definitions/group.d.ts +2 -2
- package/definitions/group.js +3 -12
- package/definitions/group.js.map +1 -0
- package/definitions/model.d.ts +2 -2
- package/definitions/model.js +8 -12
- package/definitions/model.js.map +1 -0
- package/definitions/settings.d.ts +2 -2
- package/definitions/settings.js +3 -12
- package/definitions/settings.js.map +1 -0
- package/definitions/system.d.ts +2 -2
- package/definitions/system.js +3 -12
- package/definitions/system.js.map +1 -0
- package/definitions/table.d.ts +2 -2
- package/definitions/table.js +0 -3
- package/definitions/table.js.map +1 -0
- package/definitions/tableElasticsearch.d.ts +2 -2
- package/definitions/tableElasticsearch.js +0 -3
- package/definitions/tableElasticsearch.js.map +1 -0
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/index.js +4 -11
- package/dynamoDb/index.js.map +1 -0
- package/dynamoDb/storage/date.d.ts +3 -3
- package/dynamoDb/storage/date.js +73 -54
- package/dynamoDb/storage/date.js.map +1 -0
- package/dynamoDb/storage/longText.d.ts +7 -4
- package/dynamoDb/storage/longText.js +72 -64
- package/dynamoDb/storage/longText.js.map +1 -0
- package/dynamoDb/storage/richText.d.ts +2 -3
- package/dynamoDb/storage/richText.js +74 -78
- package/dynamoDb/storage/richText.js.map +1 -0
- package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
- package/elasticsearch/createElasticsearchIndex.js +49 -0
- package/elasticsearch/createElasticsearchIndex.js.map +1 -0
- package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
- package/elasticsearch/deleteElasticsearchIndex.js +36 -0
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
- package/elasticsearch/index.d.ts +1 -1
- package/elasticsearch/index.js +1 -6
- package/elasticsearch/index.js.map +1 -0
- package/elasticsearch/indexing/dateTimeIndexing.js +17 -20
- package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
- package/elasticsearch/indexing/defaultFieldIndexing.js +5 -9
- package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
- package/elasticsearch/indexing/index.js +1 -10
- package/elasticsearch/indexing/index.js.map +1 -0
- package/elasticsearch/indexing/longTextIndexing.d.ts +4 -0
- package/elasticsearch/indexing/longTextIndexing.js +19 -9
- package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
- package/elasticsearch/indexing/numberIndexing.js +0 -9
- package/elasticsearch/indexing/numberIndexing.js.map +1 -0
- package/elasticsearch/indexing/objectIndexing.d.ts +9 -0
- package/elasticsearch/indexing/objectIndexing.js +26 -30
- package/elasticsearch/indexing/objectIndexing.js.map +1 -0
- package/elasticsearch/indexing/richTextIndexing.js +0 -5
- package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
- package/elasticsearch/indices/base.d.ts +2 -0
- package/elasticsearch/indices/base.js +12 -0
- package/elasticsearch/indices/base.js.map +1 -0
- package/elasticsearch/indices/index.d.ts +1 -0
- package/elasticsearch/indices/index.js +12 -0
- package/elasticsearch/indices/index.js.map +1 -0
- package/elasticsearch/indices/japanese.d.ts +2 -0
- package/elasticsearch/indices/japanese.js +13 -0
- package/elasticsearch/indices/japanese.js.map +1 -0
- package/elasticsearch/search/index.d.ts +2 -2
- package/elasticsearch/search/index.js +3 -9
- package/elasticsearch/search/index.js.map +1 -0
- package/elasticsearch/search/refSearch.d.ts +2 -3
- package/elasticsearch/search/refSearch.js +23 -18
- package/elasticsearch/search/refSearch.js.map +1 -0
- package/elasticsearch/search/timeSearch.d.ts +2 -3
- package/elasticsearch/search/timeSearch.js +18 -17
- package/elasticsearch/search/timeSearch.js.map +1 -0
- package/helpers/entryIndexHelpers.js +43 -57
- package/helpers/entryIndexHelpers.js.map +1 -0
- package/helpers/index.d.ts +0 -1
- package/helpers/index.js +0 -15
- package/helpers/index.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +120 -58
- package/index.js.map +1 -0
- package/operations/entry/dataLoaders.d.ts +6 -2
- package/operations/entry/dataLoaders.js +27 -61
- package/operations/entry/dataLoaders.js.map +1 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +32 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
- package/operations/entry/elasticsearch/body.d.ts +13 -0
- package/operations/entry/elasticsearch/body.js +140 -0
- package/operations/entry/elasticsearch/body.js.map +1 -0
- package/operations/entry/elasticsearch/fields.d.ts +9 -0
- package/operations/entry/elasticsearch/fields.js +229 -0
- package/operations/entry/elasticsearch/fields.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.js +57 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
- package/operations/entry/elasticsearch/filtering/exec.js +172 -0
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
- package/operations/entry/elasticsearch/filtering/index.js +16 -0
- package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/path.d.ts +15 -0
- package/operations/entry/elasticsearch/filtering/path.js +44 -0
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +28 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.js +13 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +65 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +48 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/populated.js +23 -0
- package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/values.js +22 -0
- package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
- package/operations/entry/elasticsearch/fullTextSearch.d.ts +12 -0
- package/operations/entry/elasticsearch/fullTextSearch.js +89 -0
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.js +25 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
- package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
- package/operations/entry/elasticsearch/initialQuery.js +103 -0
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
- package/operations/entry/elasticsearch/keyword.d.ts +2 -0
- package/operations/entry/elasticsearch/keyword.js +34 -0
- package/operations/entry/elasticsearch/keyword.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.js +16 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
- package/operations/entry/elasticsearch/plugins/operator.js +37 -0
- package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.js +16 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
- package/{helpers/searchPluginsList.js → operations/entry/elasticsearch/plugins/search.js} +8 -10
- package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.js +16 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
- package/operations/entry/elasticsearch/sort.d.ts +12 -0
- package/operations/entry/elasticsearch/sort.js +82 -0
- package/operations/entry/elasticsearch/sort.js.map +1 -0
- package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
- package/operations/entry/elasticsearch/transformValueForSearch.js +30 -0
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
- package/operations/entry/elasticsearch/types.d.ts +41 -0
- package/operations/entry/elasticsearch/types.js +5 -0
- package/operations/entry/elasticsearch/types.js.map +1 -0
- package/operations/entry/index.d.ts +2 -4
- package/operations/entry/index.js +457 -481
- package/operations/entry/index.js.map +1 -0
- package/operations/entry/keys.js +0 -9
- package/operations/entry/keys.js.map +1 -0
- package/operations/entry/recordType.d.ts +3 -0
- package/operations/entry/recordType.js +18 -0
- package/operations/entry/recordType.js.map +1 -0
- package/operations/group/index.d.ts +2 -2
- package/operations/group/index.js +10 -47
- package/operations/group/index.js.map +1 -0
- package/operations/model/index.d.ts +2 -2
- package/operations/model/index.js +34 -68
- package/operations/model/index.js.map +1 -0
- package/operations/settings/index.d.ts +2 -2
- package/operations/settings/index.js +7 -37
- package/operations/settings/index.js.map +1 -0
- package/operations/system/index.d.ts +2 -2
- package/operations/system/index.js +5 -28
- package/operations/system/index.js.map +1 -0
- package/package.json +24 -29
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +7 -3
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +9 -11
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +3 -3
- package/plugins/CmsEntryElasticsearchFieldPlugin.js +3 -9
- package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +23 -0
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +28 -0
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +12 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +30 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +33 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +4 -3
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +9 -11
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +4 -3
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +9 -11
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
- package/plugins/CmsEntryFilterPlugin.js +24 -0
- package/plugins/CmsEntryFilterPlugin.js.map +1 -0
- package/plugins/index.d.ts +7 -0
- package/plugins/index.js +82 -0
- package/plugins/index.js.map +1 -0
- package/types.d.ts +7 -34
- package/types.js +0 -18
- package/types.js.map +1 -0
- package/helpers/createElasticsearchQueryBody.d.ts +0 -11
- package/helpers/createElasticsearchQueryBody.js +0 -375
- package/helpers/fields.d.ts +0 -77
- package/helpers/fields.js +0 -174
- package/helpers/operatorPluginsList.d.ts +0 -7
- package/helpers/operatorPluginsList.js +0 -30
- package/helpers/searchPluginsList.d.ts +0 -6
- package/helpers/transformValueForSearch.d.ts +0 -9
- package/helpers/transformValueForSearch.js +0 -26
- package/operations/entry/elasticsearchFields.d.ts +0 -2
- package/operations/entry/elasticsearchFields.js +0 -32
- package/operations/entry/fields.d.ts +0 -3
- package/operations/entry/fields.js +0 -60
- package/operations/system/createElasticsearchTemplate.d.ts +0 -5
- package/operations/system/createElasticsearchTemplate.js +0 -62
- package/upgrades/index.d.ts +0 -2
- package/upgrades/index.js +0 -16
- package/upgrades/utils.d.ts +0 -1
- package/upgrades/utils.js +0 -16
- package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +0 -6
- package/upgrades/v5.0.0/cleanDatabaseRecord.js +0 -16
- package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +0 -2
- package/upgrades/v5.0.0/createOldVersionIndiceName.js +0 -12
- package/upgrades/v5.0.0/entryValueFixer.d.ts +0 -4
- package/upgrades/v5.0.0/entryValueFixer.js +0 -124
- package/upgrades/v5.0.0/fieldFinder.d.ts +0 -6
- package/upgrades/v5.0.0/fieldFinder.js +0 -42
- package/upgrades/v5.0.0/helpers.d.ts +0 -4
- package/upgrades/v5.0.0/helpers.js +0 -57
- package/upgrades/v5.0.0/index.d.ts +0 -4
- package/upgrades/v5.0.0/index.js +0 -232
- package/upgrades/v5.8.0/index.d.ts +0 -4
- package/upgrades/v5.8.0/index.js +0 -426
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getEntryData","input","output","getESLatestEntryData","plugins","entry","compress","latest","TYPE","createLatestRecordType","__type","getESPublishedEntryData","published","createPublishedRecordType","convertEntryKeysToStorage","params","model","values","convertValueKeyToStorage","fields","convertEntryKeysFromStorage","convertValueKeyFromStorage","createEntriesStorageOperations","entity","esEntity","elasticsearch","dataLoaders","DataLoadersHandler","create","initialEntry","storageEntry","initialStorageEntry","isPublished","status","locked","esEntry","prepareEntryToIndex","lodashCloneDeep","index","esIndex","configurations","es","esLatestData","esPublishedData","revisionKeys","PK","createPartitionKey","id","locale","tenant","SK","createRevisionSortKey","latestKeys","createLatestSortKey","publishedKeys","createPublishedSortKey","items","putBatch","createRecordType","push","batchWriteAll","table","clearAll","ex","WebinyError","message","code","error","esItems","data","createRevisionFrom","put","update","latestStorageEntry","getLatestRevisionByEntryId","ids","publishedStorageEntry","getPublishedRevisionByEntryId","undefined","elasticsearchLatestData","elasticsearchPublishedData","length","deleteEntry","partitionKey","queryAll","options","gte","deleteItems","map","item","deleteBatch","deleteEsItems","deleteRevision","latestEntry","list","limit","createLimit","result","indices","exists","body","hasMoreItems","totalCount","cursor","createElasticsearchBody","after","decodeCursor","response","search","hits","total","extractEntriesFromIndex","entries","_source","pop","encodeCursor","sort","value","get","shift","publish","latestEsEntry","getRecord","keys","previouslyPublishedEntry","getRevisionById","CONTENT_ENTRY_STATUS","UNPUBLISHED","savedOn","latestEsEntryDataDecompressed","decompress","PUBLISHED","publishedOn","preparedEntryData","unpublish","getRevisions","getAllEntryRevisions","getByIds","getLatestByIds","getPublishedByIds","getPreviousRevision","entryId","version","queryParams","lt","zeroPad","filters","attr","eq","reverse","queryOne","cleanupItem","delete"],"sources":["index.ts"],"sourcesContent":["import lodashCloneDeep from \"lodash/cloneDeep\";\nimport WebinyError from \"@webiny/error\";\nimport {\n CmsEntry,\n CmsEntryStorageOperations,\n CmsEntryStorageOperationsCreateParams,\n CmsEntryStorageOperationsCreateRevisionFromParams,\n CmsEntryStorageOperationsDeleteParams,\n CmsEntryStorageOperationsDeleteRevisionParams,\n CmsEntryStorageOperationsGetByIdsParams,\n CmsEntryStorageOperationsGetLatestByIdsParams,\n CmsEntryStorageOperationsGetLatestRevisionParams,\n CmsEntryStorageOperationsGetParams,\n CmsEntryStorageOperationsGetPreviousRevisionParams,\n CmsEntryStorageOperationsGetPublishedByIdsParams,\n CmsEntryStorageOperationsGetRevisionParams,\n CmsEntryStorageOperationsGetRevisionsParams,\n CmsEntryStorageOperationsListParams,\n CmsEntryStorageOperationsPublishParams,\n CmsEntryStorageOperationsUnpublishParams,\n CmsEntryStorageOperationsUpdateParams,\n CmsStorageEntry,\n CONTENT_ENTRY_STATUS,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types\";\nimport { extractEntriesFromIndex, prepareEntryToIndex } from \"~/helpers\";\nimport { configurations } from \"~/configurations\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { batchWriteAll } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport { DataLoadersHandler } from \"~/operations/entry/dataLoaders\";\nimport {\n createLatestSortKey,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"~/operations/entry/keys\";\nimport { queryAll, queryOne, QueryOneParams } from \"@webiny/db-dynamodb/utils/query\";\nimport {\n createLimit,\n encodeCursor,\n compress,\n decompress,\n decodeCursor\n} from \"@webiny/api-elasticsearch\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { zeroPad } from \"@webiny/utils\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { ElasticsearchSearchResponse } from \"@webiny/api-elasticsearch/types\";\nimport { CmsIndexEntry } from \"~/types\";\nimport { createElasticsearchBody } from \"~/operations/entry/elasticsearch/body\";\nimport { createLatestRecordType, createPublishedRecordType, createRecordType } from \"./recordType\";\n\nconst getEntryData = (input: CmsEntry): CmsEntry => {\n const output: any = {\n ...input\n };\n delete output[\"PK\"];\n delete output[\"SK\"];\n delete output[\"published\"];\n delete output[\"latest\"];\n\n return output;\n};\n\nconst getESLatestEntryData = async (plugins: PluginsContainer, entry: CmsEntry) => {\n return compress(plugins, {\n ...getEntryData(entry),\n latest: true,\n TYPE: createLatestRecordType(),\n __type: createLatestRecordType()\n });\n};\n\nconst getESPublishedEntryData = async (plugins: PluginsContainer, entry: CmsEntry) => {\n return compress(plugins, {\n ...getEntryData(entry),\n published: true,\n TYPE: createPublishedRecordType(),\n __type: createPublishedRecordType()\n });\n};\n\ninterface ConvertStorageEntryParams {\n entry: CmsStorageEntry;\n model: StorageOperationsCmsModel;\n}\nconst convertEntryKeysToStorage = (params: ConvertStorageEntryParams): CmsStorageEntry => {\n const { model, entry } = params;\n\n const values = model.convertValueKeyToStorage({\n fields: model.fields,\n values: entry.values\n });\n return {\n ...entry,\n values\n };\n};\n\nconst convertEntryKeysFromStorage = (params: ConvertStorageEntryParams): CmsStorageEntry => {\n const { model, entry } = params;\n\n const values = model.convertValueKeyFromStorage({\n fields: model.fields,\n values: entry.values\n });\n return {\n ...entry,\n values\n };\n};\n\ninterface ElasticsearchDbRecord {\n index: string;\n data: Record<string, string>;\n}\n\nexport interface CreateEntriesStorageOperationsParams {\n entity: Entity<any>;\n esEntity: Entity<any>;\n elasticsearch: Client;\n plugins: PluginsContainer;\n}\nexport const createEntriesStorageOperations = (\n params: CreateEntriesStorageOperationsParams\n): CmsEntryStorageOperations => {\n const { entity, esEntity, elasticsearch, plugins } = params;\n\n const dataLoaders = new DataLoadersHandler({\n entity\n });\n\n const create = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsCreateParams\n ) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const isPublished = initialEntry.status === \"published\";\n const locked = isPublished ? true : initialEntry.locked;\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n const esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep({ ...entry, locked }),\n storageEntry: lodashCloneDeep({ ...storageEntry, locked })\n });\n\n const { index: esIndex } = configurations.es({\n model\n });\n\n const esLatestData = await getESLatestEntryData(plugins, esEntry);\n const esPublishedData = await getESPublishedEntryData(plugins, esEntry);\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n locked,\n ...revisionKeys,\n TYPE: createRecordType()\n }),\n entity.putBatch({\n ...storageEntry,\n locked,\n ...latestKeys,\n TYPE: createLatestRecordType()\n })\n ];\n\n if (isPublished) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert entry data into the DynamoDB table.\",\n ex.code || \"CREATE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n\n const esItems = [\n esEntity.putBatch({\n ...latestKeys,\n index: esIndex,\n data: esLatestData\n })\n ];\n if (isPublished) {\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index: esIndex,\n data: esPublishedData\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert entry data into the Elasticsearch DynamoDB table.\",\n ex.code || \"CREATE_ES_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n esEntry\n }\n );\n }\n\n return initialStorageEntry;\n };\n\n const createRevisionFrom = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsCreateRevisionFromParams\n ) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep(entry),\n storageEntry: lodashCloneDeep(storageEntry)\n });\n\n const esLatestData = await getESLatestEntryData(plugins, esEntry);\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n TYPE: createRecordType(),\n ...revisionKeys\n }),\n entity.putBatch({\n ...storageEntry,\n TYPE: createLatestRecordType(),\n ...latestKeys\n })\n ];\n\n const { index } = configurations.es({\n model\n });\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create revision from given entry in the DynamoDB table.\",\n ex.code || \"CREATE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n /**\n * Update the \"latest\" entry item in the Elasticsearch\n */\n try {\n await esEntity.put({\n ...latestKeys,\n index,\n data: esLatestData\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update latest entry in the DynamoDB Elasticsearch table.\",\n ex.code || \"CREATE_REVISION_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n /**\n * There are no modifications on the entry created so just return the data.\n */\n return initialStorageEntry;\n };\n\n const update = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsUpdateParams\n ) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n const isPublished = entry.status === \"published\";\n const locked = isPublished ? true : entry.locked;\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n /**\n * We need the latest entry to check if it needs to be updated.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n locked,\n ...revisionKeys,\n TYPE: createRecordType()\n })\n ];\n if (isPublished) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n );\n }\n\n const esItems = [];\n\n const { index: esIndex } = configurations.es({\n model\n });\n /**\n * Variable for the elasticsearch entry so we do not convert it more than once\n */\n let esEntry: CmsIndexEntry | undefined = undefined;\n /**\n * If the latest entry is the one being updated, we need to create a new latest entry records.\n */\n let elasticsearchLatestData: any = null;\n if (latestStorageEntry?.id === entry.id) {\n /**\n * First we update the regular DynamoDB table\n */\n items.push(\n entity.putBatch({\n ...storageEntry,\n ...latestKeys,\n TYPE: createLatestSortKey()\n })\n );\n /**\n * And then update the Elasticsearch table to propagate changes to the Elasticsearch\n */\n esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep({\n ...entry,\n locked\n }),\n storageEntry: lodashCloneDeep({\n ...storageEntry,\n locked\n })\n });\n\n elasticsearchLatestData = await getESLatestEntryData(plugins, esEntry);\n\n esItems.push(\n esEntity.putBatch({\n ...latestKeys,\n index: esIndex,\n data: elasticsearchLatestData\n })\n );\n }\n let elasticsearchPublishedData = null;\n if (isPublished && publishedStorageEntry?.id === entry.id) {\n if (!elasticsearchLatestData) {\n /**\n * And then update the Elasticsearch table to propagate changes to the Elasticsearch\n */\n if (!esEntry) {\n esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep({\n ...entry,\n locked\n }),\n storageEntry: lodashCloneDeep({\n ...storageEntry,\n locked\n })\n });\n }\n elasticsearchPublishedData = await getESPublishedEntryData(plugins, esEntry);\n } else {\n elasticsearchPublishedData = {\n ...elasticsearchLatestData,\n published: true,\n TYPE: createPublishedRecordType(),\n __type: createPublishedRecordType()\n };\n delete elasticsearchPublishedData.latest;\n }\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index: esIndex,\n data: elasticsearchPublishedData\n })\n );\n }\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\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 if (esItems.length === 0) {\n return initialStorageEntry;\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\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 const deleteEntry = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsDeleteParams\n ) => {\n const { entry } = params;\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const items = await queryAll<CmsEntry>({\n entity,\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n\n const esItems = await queryAll<CmsEntry>({\n entity: esEntity,\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n\n const deleteItems = items.map(item => {\n return entity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\n });\n\n const deleteEsItems = esItems.map(item => {\n return esEntity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\n });\n\n try {\n await batchWriteAll({\n table: entity.table,\n items: deleteItems\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete entry records from DynamoDB table.\",\n ex.code || \"DELETE_ENTRY_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: deleteEsItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete entry records from DynamoDB Elasticsearch table.\",\n ex.code || \"DELETE_ENTRY_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n };\n\n const deleteRevision = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsDeleteRevisionParams\n ) => {\n const { entry, latestEntry, latestStorageEntry } = params;\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const { index } = configurations.es({\n model\n });\n /**\n * We need published entry to delete it if necessary.\n */\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n /**\n * We need to delete all existing records of the given entry revision.\n */\n const items = [\n /**\n * Delete records of given entry revision.\n */\n entity.deleteBatch({\n PK: partitionKey,\n SK: createRevisionSortKey(entry)\n })\n ];\n\n const esItems = [];\n\n /**\n * If revision we are deleting is the published one as well, we need to delete those records as well.\n */\n if (publishedStorageEntry?.id === entry.id) {\n items.push(\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n esItems.push(\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n }\n if (latestEntry && latestStorageEntry) {\n const esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep(latestEntry),\n storageEntry: lodashCloneDeep(latestStorageEntry)\n });\n\n const esLatestData = await getESLatestEntryData(plugins, esEntry);\n /**\n * In the end we need to set the new latest entry\n */\n items.push(\n entity.putBatch({\n ...latestStorageEntry,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestRecordType()\n })\n );\n esItems.push(\n esEntity.putBatch({\n PK: partitionKey,\n SK: createLatestSortKey(),\n index,\n data: esLatestData\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not batch write entry records to DynamoDB table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n latestStorageEntry\n }\n );\n }\n\n if (esItems.length === 0) {\n return;\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not batch write entry records to DynamoDB Elasticsearch table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n latestStorageEntry\n }\n );\n }\n };\n\n const list = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsListParams\n ) => {\n const limit = createLimit(params.limit, 50);\n const { index } = configurations.es({\n model\n });\n\n try {\n const result = await elasticsearch.indices.exists({\n index\n });\n if (!result?.body) {\n return {\n hasMoreItems: false,\n totalCount: 0,\n cursor: null,\n items: []\n };\n }\n } catch (ex) {\n throw new WebinyError(\n \"Could not determine if Elasticsearch index exists.\",\n \"ELASTICSEARCH_INDEX_CHECK_ERROR\",\n {\n error: ex,\n index\n }\n );\n }\n\n const body = createElasticsearchBody({\n model,\n params: {\n ...params,\n limit,\n after: decodeCursor(params.after)\n },\n plugins\n });\n\n let response: ElasticsearchSearchResponse<CmsIndexEntry>;\n try {\n response = await elasticsearch.search({\n index,\n body\n });\n } catch (ex) {\n throw new WebinyError(ex.message, ex.code || \"ELASTICSEARCH_ERROR\", {\n error: ex,\n index,\n body,\n model\n });\n }\n\n const { hits, total } = response?.body?.hits || {};\n\n const items = extractEntriesFromIndex({\n plugins,\n model,\n entries: hits.map(item => item._source)\n }).map(item => {\n return convertEntryKeysFromStorage({\n model,\n entry: item\n });\n });\n\n const hasMoreItems = items.length > limit;\n if (hasMoreItems) {\n /**\n * Remove the last item from results, we don't want to include it.\n */\n items.pop();\n }\n /**\n * Cursor is the `sort` value of the last item in the array.\n * https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after\n */\n const cursor = items.length > 0 ? encodeCursor(hits[items.length - 1].sort) || null : null;\n return {\n hasMoreItems,\n totalCount: total.value,\n cursor,\n items\n };\n };\n\n const get = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetParams\n ) => {\n const { items } = await list(model, {\n ...params,\n limit: 1\n });\n return items.shift() || null;\n };\n\n const publish = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsPublishParams\n ) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n /**\n * We need currently published entry to check if need to remove it.\n */\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n let latestEsEntry: ElasticsearchDbRecord | null = null;\n try {\n latestEsEntry = await getRecord<ElasticsearchDbRecord>({\n entity: esEntity,\n keys: latestKeys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not read Elasticsearch latest or published data.\",\n ex.code || \"PUBLISH_BATCH_READ\",\n {\n error: ex,\n latestKeys: latestKeys,\n publishedKeys: publishedKeys\n }\n );\n }\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n ...revisionKeys,\n TYPE: createRecordType()\n })\n ];\n const esItems = [];\n\n const { index } = configurations.es({\n model\n });\n\n if (publishedStorageEntry && publishedStorageEntry.id !== entry.id) {\n /**\n * If there is a `published` entry already, we need to set it to `unpublished`. We need to\n * execute two updates: update the previously published entry's status and the published entry record.\n * DynamoDB does not support `batchUpdate` - so here we load the previously published\n * entry's data to update its status within a batch operation. If, hopefully,\n * they introduce a true update batch operation, remove this `read` call.\n */\n const [previouslyPublishedEntry] = await dataLoaders.getRevisionById({\n model,\n ids: [publishedStorageEntry.id]\n });\n items.push(\n /**\n * Update currently published entry (unpublish it)\n */\n entity.putBatch({\n ...previouslyPublishedEntry,\n status: CONTENT_ENTRY_STATUS.UNPUBLISHED,\n savedOn: entry.savedOn,\n TYPE: createRecordType(),\n PK: createPartitionKey(publishedStorageEntry),\n SK: createRevisionSortKey(publishedStorageEntry)\n })\n );\n }\n /**\n * Update the helper item in DB with the new published entry\n */\n items.push(\n entity.putBatch({\n ...storageEntry,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n );\n\n /**\n * We need the latest entry to check if it needs to be updated as well in the Elasticsearch.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n if (latestStorageEntry?.id === entry.id) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n ...latestKeys\n })\n );\n }\n /**\n * If we are publishing the latest revision, let's also update the latest revision's status in ES.\n */\n if (latestEsEntry && latestStorageEntry?.id === entry.id) {\n /**\n * Need to decompress the data from Elasticsearch DynamoDB table.\n *\n * No need to transform it for the storage because it was fetched directly from the Elasticsearch table, where it sits transformed.\n */\n const latestEsEntryDataDecompressed: CmsEntry = (await decompress(\n plugins,\n latestEsEntry.data\n )) as any;\n\n esItems.push(\n esEntity.putBatch({\n index,\n PK: createPartitionKey(latestEsEntryDataDecompressed),\n SK: createLatestSortKey(),\n data: await getESLatestEntryData(plugins, {\n ...latestEsEntryDataDecompressed,\n status: CONTENT_ENTRY_STATUS.PUBLISHED,\n locked: true,\n savedOn: entry.savedOn,\n publishedOn: entry.publishedOn\n })\n })\n );\n }\n\n const preparedEntryData = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep(entry),\n storageEntry: lodashCloneDeep(storageEntry)\n });\n /**\n * Update the published revision entry in ES.\n */\n const esPublishedData = await getESPublishedEntryData(plugins, preparedEntryData);\n\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index,\n data: esPublishedData\n })\n );\n\n /**\n * Finally, execute regular table batch.\n */\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not store publish entry records in DynamoDB table.\",\n ex.code || \"PUBLISH_ERROR\",\n {\n error: ex,\n entry,\n latestStorageEntry,\n publishedStorageEntry\n }\n );\n }\n /**\n * And Elasticsearch table batch.\n */\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not store publish entry records in DynamoDB Elasticsearch table.\",\n ex.code || \"PUBLISH_ES_ERROR\",\n {\n error: ex,\n entry,\n latestStorageEntry,\n publishedStorageEntry\n }\n );\n }\n return initialStorageEntry;\n };\n\n const unpublish = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsUnpublishParams\n ) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n /**\n * We need the latest entry to check if it needs to be updated.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const items = [\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n }),\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createRevisionSortKey(entry),\n TYPE: createRecordType()\n })\n ];\n\n const esItems = [\n esEntity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n ];\n /**\n * If we are unpublishing the latest revision, let's also update the latest revision entry's status in ES.\n */\n if (latestStorageEntry?.id === entry.id) {\n const { index } = configurations.es({\n model\n });\n\n const preparedEntryData = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep(entry),\n storageEntry: lodashCloneDeep(storageEntry)\n });\n\n const esLatestData = await getESLatestEntryData(plugins, preparedEntryData);\n esItems.push(\n esEntity.putBatch({\n PK: partitionKey,\n SK: createLatestSortKey(),\n index,\n data: esLatestData\n })\n );\n }\n\n /**\n * Finally, execute regular table batch.\n */\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not store unpublished entry records in DynamoDB table.\",\n ex.code || \"UNPUBLISH_ERROR\",\n {\n entry,\n storageEntry\n }\n );\n }\n /**\n * And Elasticsearch table batch.\n */\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not store unpublished entry records in DynamoDB Elasticsearch table.\",\n ex.code || \"UNPUBLISH_ERROR\",\n {\n entry,\n storageEntry\n }\n );\n }\n return initialStorageEntry;\n };\n\n const getLatestRevisionByEntryId = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetLatestRevisionParams\n ) => {\n const [entry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n const getPublishedRevisionByEntryId = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetLatestRevisionParams\n ) => {\n const [entry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n\n const getRevisionById = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetRevisionParams\n ) => {\n const [entry] = await dataLoaders.getRevisionById({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n\n const getRevisions = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetRevisionsParams\n ) => {\n const entries = await dataLoaders.getAllEntryRevisions({\n model,\n ids: [params.id]\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getByIds = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetByIdsParams\n ) => {\n const entries = await dataLoaders.getRevisionById({\n model,\n ids: params.ids\n });\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getLatestByIds = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetLatestByIdsParams\n ) => {\n const entries = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: params.ids\n });\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getPublishedByIds = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetPublishedByIdsParams\n ) => {\n const entries = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: params.ids\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getPreviousRevision = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetPreviousRevisionParams\n ) => {\n const { tenant, locale } = model;\n const { entryId, version } = params;\n const queryParams: QueryOneParams = {\n entity,\n partitionKey: createPartitionKey({\n tenant,\n locale,\n id: entryId\n }),\n options: {\n lt: `REV#${zeroPad(version)}`,\n /**\n * We need to have extra checks because DynamoDB will return published or latest record if there is no REV# record.\n */\n filters: [\n {\n attr: \"TYPE\",\n eq: createRecordType()\n },\n {\n attr: \"version\",\n lt: version\n }\n ],\n reverse: true\n }\n };\n\n try {\n const result = await queryOne<CmsEntry>(queryParams);\n\n const entry = cleanupItem(entity, result);\n\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n entry,\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get previous version of given entry.\",\n ex.code || \"GET_PREVIOUS_VERSION_ERROR\",\n {\n ...params,\n error: ex,\n partitionKey: queryParams.partitionKey,\n options: queryParams.options,\n model\n }\n );\n }\n };\n\n return {\n create,\n createRevisionFrom,\n update,\n delete: deleteEntry,\n deleteRevision,\n get,\n publish,\n unpublish,\n list,\n getLatestRevisionByEntryId,\n getPublishedRevisionByEntryId,\n getRevisionById,\n getRevisions,\n getByIds,\n getLatestByIds,\n getPublishedByIds,\n getPreviousRevision\n };\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AAuBA;AACA;AAIA;AACA;AACA;AAMA;AACA;AAOA;AACA;AACA;AAGA;AACA;AAEA,MAAMA,YAAY,GAAIC,KAAe,IAAe;EAChD,MAAMC,MAAW,mCACVD,KAAK,CACX;EACD,OAAOC,MAAM,CAAC,IAAI,CAAC;EACnB,OAAOA,MAAM,CAAC,IAAI,CAAC;EACnB,OAAOA,MAAM,CAAC,WAAW,CAAC;EAC1B,OAAOA,MAAM,CAAC,QAAQ,CAAC;EAEvB,OAAOA,MAAM;AACjB,CAAC;AAED,MAAMC,oBAAoB,GAAG,OAAOC,OAAyB,EAA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5
5
|
});
|
|
6
6
|
exports.createRevisionSortKey = exports.createPublishedSortKey = exports.createPartitionKey = exports.createLatestSortKey = void 0;
|
|
7
|
-
|
|
8
7
|
var _utils = require("@webiny/utils");
|
|
9
|
-
|
|
10
8
|
const createPartitionKey = params => {
|
|
11
9
|
const {
|
|
12
10
|
tenant,
|
|
@@ -18,23 +16,16 @@ const createPartitionKey = params => {
|
|
|
18
16
|
} = (0, _utils.parseIdentifier)(initialId);
|
|
19
17
|
return `T#${tenant}#L#${locale}#CMS#CME#${id}`;
|
|
20
18
|
};
|
|
21
|
-
|
|
22
19
|
exports.createPartitionKey = createPartitionKey;
|
|
23
|
-
|
|
24
20
|
const createRevisionSortKey = params => {
|
|
25
21
|
return `REV#${(0, _utils.zeroPad)(params.version)}`;
|
|
26
22
|
};
|
|
27
|
-
|
|
28
23
|
exports.createRevisionSortKey = createRevisionSortKey;
|
|
29
|
-
|
|
30
24
|
const createLatestSortKey = () => {
|
|
31
25
|
return "L";
|
|
32
26
|
};
|
|
33
|
-
|
|
34
27
|
exports.createLatestSortKey = createLatestSortKey;
|
|
35
|
-
|
|
36
28
|
const createPublishedSortKey = () => {
|
|
37
29
|
return "P";
|
|
38
30
|
};
|
|
39
|
-
|
|
40
31
|
exports.createPublishedSortKey = createPublishedSortKey;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createPartitionKey","params","tenant","locale","id","initialId","parseIdentifier","createRevisionSortKey","zeroPad","version","createLatestSortKey","createPublishedSortKey"],"sources":["keys.ts"],"sourcesContent":["import { parseIdentifier, zeroPad } from \"@webiny/utils\";\n\nexport interface PartitionKeyParams {\n id: string;\n tenant: string;\n locale: string;\n}\nexport const createPartitionKey = (params: PartitionKeyParams): string => {\n const { tenant, locale, id: initialId } = params;\n const { id } = parseIdentifier(initialId);\n return `T#${tenant}#L#${locale}#CMS#CME#${id}`;\n};\n\nexport interface SortKeyParams {\n version: number;\n}\nexport const createRevisionSortKey = (params: SortKeyParams): string => {\n return `REV#${zeroPad(params.version)}`;\n};\n\nexport const createLatestSortKey = (): string => {\n return \"L\";\n};\n\nexport const createPublishedSortKey = (): string => {\n return \"P\";\n};\n"],"mappings":";;;;;;AAAA;AAOO,MAAMA,kBAAkB,GAAIC,MAA0B,IAAa;EACtE,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC,EAAE,EAAEC;EAAU,CAAC,GAAGJ,MAAM;EAChD,MAAM;IAAEG;EAAG,CAAC,GAAG,IAAAE,sBAAe,EAACD,SAAS,CAAC;EACzC,OAAQ,KAAIH,MAAO,MAAKC,MAAO,YAAWC,EAAG,EAAC;AAClD,CAAC;AAAC;AAKK,MAAMG,qBAAqB,GAAIN,MAAqB,IAAa;EACpE,OAAQ,OAAM,IAAAO,cAAO,EAACP,MAAM,CAACQ,OAAO,CAAE,EAAC;AAC3C,CAAC;AAAC;AAEK,MAAMC,mBAAmB,GAAG,MAAc;EAC7C,OAAO,GAAG;AACd,CAAC;AAAC;AAEK,MAAMC,sBAAsB,GAAG,MAAc;EAChD,OAAO,GAAG;AACd,CAAC;AAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createRecordType = exports.createPublishedRecordType = exports.createLatestRecordType = void 0;
|
|
7
|
+
const createRecordType = () => {
|
|
8
|
+
return "cms.entry";
|
|
9
|
+
};
|
|
10
|
+
exports.createRecordType = createRecordType;
|
|
11
|
+
const createLatestRecordType = () => {
|
|
12
|
+
return `${createRecordType()}.l`;
|
|
13
|
+
};
|
|
14
|
+
exports.createLatestRecordType = createLatestRecordType;
|
|
15
|
+
const createPublishedRecordType = () => {
|
|
16
|
+
return `${createRecordType()}.p`;
|
|
17
|
+
};
|
|
18
|
+
exports.createPublishedRecordType = createPublishedRecordType;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createRecordType","createLatestRecordType","createPublishedRecordType"],"sources":["recordType.ts"],"sourcesContent":["export const createRecordType = (): string => {\n return \"cms.entry\";\n};\nexport const createLatestRecordType = (): string => {\n return `${createRecordType()}.l`;\n};\nexport const createPublishedRecordType = (): string => {\n return `${createRecordType()}.p`;\n};\n"],"mappings":";;;;;;AAAO,MAAMA,gBAAgB,GAAG,MAAc;EAC1C,OAAO,WAAW;AACtB,CAAC;AAAC;AACK,MAAMC,sBAAsB,GAAG,MAAc;EAChD,OAAQ,GAAED,gBAAgB,EAAG,IAAG;AACpC,CAAC;AAAC;AACK,MAAME,yBAAyB,GAAG,MAAc;EACnD,OAAQ,GAAEF,gBAAgB,EAAG,IAAG;AACpC,CAAC;AAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CmsGroupStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
2
|
import { Entity } from "dynamodb-toolbox";
|
|
3
3
|
import { PluginsContainer } from "@webiny/plugins";
|
|
4
|
-
export interface
|
|
4
|
+
export interface CreateGroupsStorageOperationsParams {
|
|
5
5
|
entity: Entity<any>;
|
|
6
6
|
plugins: PluginsContainer;
|
|
7
7
|
}
|
|
8
|
-
export declare const createGroupsStorageOperations: (params:
|
|
8
|
+
export declare const createGroupsStorageOperations: (params: CreateGroupsStorageOperationsParams) => CmsGroupStorageOperations;
|
|
@@ -1,32 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createGroupsStorageOperations = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
12
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
10
|
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
15
|
-
|
|
16
11
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
17
|
-
|
|
18
12
|
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
19
|
-
|
|
20
13
|
var _filter = require("@webiny/db-dynamodb/utils/filter");
|
|
21
|
-
|
|
22
14
|
var _ValueFilterPlugin = require("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin");
|
|
23
|
-
|
|
24
15
|
var _sort = require("@webiny/db-dynamodb/utils/sort");
|
|
25
|
-
|
|
26
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
27
|
-
|
|
28
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
29
|
-
|
|
30
16
|
const createPartitionKey = params => {
|
|
31
17
|
const {
|
|
32
18
|
tenant,
|
|
@@ -34,44 +20,37 @@ const createPartitionKey = params => {
|
|
|
34
20
|
} = params;
|
|
35
21
|
return `T#${tenant}#L#${locale}#CMS#CMG`;
|
|
36
22
|
};
|
|
37
|
-
|
|
38
23
|
const createSortKeys = params => {
|
|
39
24
|
const {
|
|
40
25
|
id
|
|
41
26
|
} = params;
|
|
42
27
|
return id;
|
|
43
28
|
};
|
|
44
|
-
|
|
45
29
|
const createKeys = params => {
|
|
46
30
|
return {
|
|
47
31
|
PK: createPartitionKey(params),
|
|
48
32
|
SK: createSortKeys(params)
|
|
49
33
|
};
|
|
50
34
|
};
|
|
51
|
-
|
|
52
35
|
const createType = () => {
|
|
53
36
|
return "cms.group";
|
|
54
37
|
};
|
|
55
|
-
|
|
56
38
|
const createGroupsStorageOperations = params => {
|
|
57
39
|
const {
|
|
58
40
|
entity,
|
|
59
41
|
plugins
|
|
60
42
|
} = params;
|
|
61
43
|
const filteringPlugins = plugins.byType(_ValueFilterPlugin.ValueFilterPlugin.type);
|
|
62
|
-
|
|
63
44
|
if (filteringPlugins.length === 0) {
|
|
64
45
|
throw new _error.default("DynamoDB filtering plugins not loaded.", "MISSING_DYNAMODB_FILTERING_PLUGINS");
|
|
65
46
|
}
|
|
66
|
-
|
|
67
47
|
const create = async params => {
|
|
68
48
|
const {
|
|
69
49
|
group
|
|
70
50
|
} = params;
|
|
71
51
|
const keys = createKeys(group);
|
|
72
|
-
|
|
73
52
|
try {
|
|
74
|
-
await entity.put(
|
|
53
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, group), {}, {
|
|
75
54
|
TYPE: createType()
|
|
76
55
|
}, keys));
|
|
77
56
|
return group;
|
|
@@ -83,16 +62,13 @@ const createGroupsStorageOperations = params => {
|
|
|
83
62
|
});
|
|
84
63
|
}
|
|
85
64
|
};
|
|
86
|
-
|
|
87
65
|
const update = async params => {
|
|
88
66
|
const {
|
|
89
|
-
group
|
|
90
|
-
original
|
|
67
|
+
group
|
|
91
68
|
} = params;
|
|
92
69
|
const keys = createKeys(group);
|
|
93
|
-
|
|
94
70
|
try {
|
|
95
|
-
await entity.put(
|
|
71
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, group), {}, {
|
|
96
72
|
TYPE: createType()
|
|
97
73
|
}, keys));
|
|
98
74
|
return group;
|
|
@@ -100,19 +76,16 @@ const createGroupsStorageOperations = params => {
|
|
|
100
76
|
throw new _error.default(ex.message || "Could not update group.", ex.code || "UPDATE_GROUP_ERROR", {
|
|
101
77
|
error: ex,
|
|
102
78
|
group,
|
|
103
|
-
original,
|
|
104
79
|
keys
|
|
105
80
|
});
|
|
106
81
|
}
|
|
107
82
|
};
|
|
108
|
-
|
|
109
83
|
const deleteGroup = async params => {
|
|
110
84
|
const {
|
|
111
85
|
group
|
|
112
|
-
} = params;
|
|
113
|
-
|
|
86
|
+
} = params;
|
|
87
|
+
// TODO make sure that group has locale and tenant on it - add it in the crud just in case
|
|
114
88
|
const keys = createKeys(group);
|
|
115
|
-
|
|
116
89
|
try {
|
|
117
90
|
await entity.delete(keys);
|
|
118
91
|
return group;
|
|
@@ -124,10 +97,8 @@ const createGroupsStorageOperations = params => {
|
|
|
124
97
|
});
|
|
125
98
|
}
|
|
126
99
|
};
|
|
127
|
-
|
|
128
100
|
const get = async params => {
|
|
129
101
|
const keys = createKeys(params);
|
|
130
|
-
|
|
131
102
|
try {
|
|
132
103
|
const group = await (0, _get.get)({
|
|
133
104
|
entity,
|
|
@@ -135,14 +106,13 @@ const createGroupsStorageOperations = params => {
|
|
|
135
106
|
});
|
|
136
107
|
return (0, _cleanup.cleanupItem)(entity, group);
|
|
137
108
|
} catch (ex) {
|
|
138
|
-
throw new _error.default(ex.message || "Could not get group.", ex.code || "GET_GROUP_ERROR",
|
|
109
|
+
throw new _error.default(ex.message || "Could not get group.", ex.code || "GET_GROUP_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
139
110
|
error: ex
|
|
140
111
|
}, params), {}, {
|
|
141
112
|
keys
|
|
142
113
|
}));
|
|
143
114
|
}
|
|
144
115
|
};
|
|
145
|
-
|
|
146
116
|
const list = async params => {
|
|
147
117
|
const {
|
|
148
118
|
sort,
|
|
@@ -156,20 +126,17 @@ const createGroupsStorageOperations = params => {
|
|
|
156
126
|
}
|
|
157
127
|
};
|
|
158
128
|
let records = [];
|
|
159
|
-
|
|
160
129
|
try {
|
|
161
130
|
records = await (0, _query.queryAll)(queryAllParams);
|
|
162
131
|
} catch (ex) {
|
|
163
|
-
throw new _error.default(ex.message || "Could not list groups.", ex.code || "LIST_GROUP_ERROR",
|
|
132
|
+
throw new _error.default(ex.message || "Could not list groups.", ex.code || "LIST_GROUP_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
164
133
|
error: ex
|
|
165
134
|
}, params), {}, {
|
|
166
135
|
sort,
|
|
167
136
|
where: initialWhere
|
|
168
137
|
}));
|
|
169
138
|
}
|
|
170
|
-
|
|
171
|
-
const where = _objectSpread({}, initialWhere);
|
|
172
|
-
|
|
139
|
+
const where = (0, _objectSpread2.default)({}, initialWhere);
|
|
173
140
|
delete where["tenant"];
|
|
174
141
|
delete where["locale"];
|
|
175
142
|
const filteredItems = (0, _filter.filterItems)({
|
|
@@ -178,18 +145,15 @@ const createGroupsStorageOperations = params => {
|
|
|
178
145
|
fields: [],
|
|
179
146
|
plugins
|
|
180
147
|
});
|
|
181
|
-
|
|
182
148
|
if (!sort || sort.length === 0 || filteredItems.length === 0) {
|
|
183
149
|
return filteredItems;
|
|
184
150
|
}
|
|
185
|
-
|
|
186
151
|
return (0, _sort.sortItems)({
|
|
187
152
|
items: filteredItems,
|
|
188
153
|
sort,
|
|
189
154
|
fields: []
|
|
190
155
|
});
|
|
191
156
|
};
|
|
192
|
-
|
|
193
157
|
return {
|
|
194
158
|
create,
|
|
195
159
|
update,
|
|
@@ -198,5 +162,4 @@ const createGroupsStorageOperations = params => {
|
|
|
198
162
|
list
|
|
199
163
|
};
|
|
200
164
|
};
|
|
201
|
-
|
|
202
165
|
exports.createGroupsStorageOperations = createGroupsStorageOperations;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createPartitionKey","params","tenant","locale","createSortKeys","id","createKeys","PK","SK","createType","createGroupsStorageOperations","entity","plugins","filteringPlugins","byType","ValueFilterPlugin","type","length","WebinyError","create","group","keys","put","TYPE","ex","message","code","error","update","deleteGroup","delete","get","getRecord","cleanupItem","list","sort","where","initialWhere","queryAllParams","partitionKey","options","gte","records","queryAll","filteredItems","filterItems","items","fields","sortItems"],"sources":["index.ts"],"sourcesContent":["import {\n CmsGroup,\n CmsGroupStorageOperations,\n CmsGroupStorageOperationsCreateParams,\n CmsGroupStorageOperationsDeleteParams,\n CmsGroupStorageOperationsGetParams,\n CmsGroupStorageOperationsListParams,\n CmsGroupStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { filterItems } from \"@webiny/db-dynamodb/utils/filter\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\n\ninterface PartitionKeyParams {\n tenant: string;\n locale: string;\n}\nconst createPartitionKey = (params: PartitionKeyParams): string => {\n const { tenant, locale } = params;\n return `T#${tenant}#L#${locale}#CMS#CMG`;\n};\n\ninterface SortKeyParams {\n id: string;\n}\nconst createSortKeys = (params: SortKeyParams): string => {\n const { id } = params;\n return id;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams & SortKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKeys(params)\n };\n};\n\nconst createType = (): string => {\n return \"cms.group\";\n};\n\nexport interface CreateGroupsStorageOperationsParams {\n entity: Entity<any>;\n plugins: PluginsContainer;\n}\nexport const createGroupsStorageOperations = (\n params: CreateGroupsStorageOperationsParams\n): CmsGroupStorageOperations => {\n const { entity, plugins } = params;\n\n const filteringPlugins = plugins.byType<ValueFilterPlugin>(ValueFilterPlugin.type);\n if (filteringPlugins.length === 0) {\n throw new WebinyError(\n \"DynamoDB filtering plugins not loaded.\",\n \"MISSING_DYNAMODB_FILTERING_PLUGINS\"\n );\n }\n\n const create = async (params: CmsGroupStorageOperationsCreateParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await entity.put({\n ...group,\n TYPE: createType(),\n ...keys\n });\n return group;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create group.\",\n ex.code || \"CREATE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const update = async (params: CmsGroupStorageOperationsUpdateParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await entity.put({\n ...group,\n TYPE: createType(),\n ...keys\n });\n return group;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update group.\",\n ex.code || \"UPDATE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const deleteGroup = async (params: CmsGroupStorageOperationsDeleteParams) => {\n const { group } = params;\n // TODO make sure that group has locale and tenant on it - add it in the crud just in case\n const keys = createKeys(group);\n\n try {\n await entity.delete(keys);\n return group;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete group.\",\n ex.code || \"DELETE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const get = async (params: CmsGroupStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const group = await getRecord<CmsGroup>({\n entity,\n keys\n });\n\n return cleanupItem(entity, group);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get group.\",\n ex.code || \"GET_GROUP_ERROR\",\n {\n error: ex,\n ...params,\n keys\n }\n );\n }\n };\n const list = async (params: CmsGroupStorageOperationsListParams) => {\n const { sort, where: initialWhere } = params;\n\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey(initialWhere),\n options: {\n gte: \" \"\n }\n };\n\n let records: CmsGroup[] = [];\n try {\n records = await queryAll(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list groups.\",\n ex.code || \"LIST_GROUP_ERROR\",\n {\n error: ex,\n ...params,\n sort,\n where: initialWhere\n }\n );\n }\n\n const where: Partial<CmsGroupStorageOperationsListParams[\"where\"]> = {\n ...initialWhere\n };\n delete where[\"tenant\"];\n delete where[\"locale\"];\n\n const filteredItems = filterItems({\n items: records,\n where,\n fields: [],\n plugins\n });\n\n if (!sort || sort.length === 0 || filteredItems.length === 0) {\n return filteredItems;\n }\n return sortItems({\n items: filteredItems,\n sort,\n fields: []\n });\n };\n\n return {\n create,\n update,\n delete: deleteGroup,\n get,\n list\n };\n};\n"],"mappings":";;;;;;;;AAUA;AACA;AACA;AACA;AACA;AAEA;AACA;AAMA,MAAMA,kBAAkB,GAAIC,MAA0B,IAAa;EAC/D,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM;EACjC,OAAQ,KAAIC,MAAO,MAAKC,MAAO,UAAS;AAC5C,CAAC;AAKD,MAAMC,cAAc,GAAIH,MAAqB,IAAa;EACtD,MAAM;IAAEI;EAAG,CAAC,GAAGJ,MAAM;EACrB,OAAOI,EAAE;AACb,CAAC;AAMD,MAAMC,UAAU,GAAIL,MAA0C,IAAW;EACrE,OAAO;IACHM,EAAE,EAAEP,kBAAkB,CAACC,MAAM,CAAC;IAC9BO,EAAE,EAAEJ,cAAc,CAACH,MAAM;EAC7B,CAAC;AACL,CAAC;AAED,MAAMQ,UAAU,GAAG,MAAc;EAC7B,OAAO,WAAW;AACtB,CAAC;AAMM,MAAMC,6BAA6B,GACtCT,MAA2C,IACf;EAC5B,MAAM;IAAEU,MAAM;IAAEC;EAAQ,CAAC,GAAGX,MAAM;EAElC,MAAMY,gBAAgB,GAAGD,OAAO,CAACE,MAAM,CAAoBC,oCAAiB,CAACC,IAAI,CAAC;EAClF,IAAIH,gBAAgB,CAACI,MAAM,KAAK,CAAC,EAAE;IAC/B,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E,CAACE,IAAI,IAAI,kBAAkB;QAEzBC,KAAK,EAAEH;MAAE,GACNvB,MAAM;QACTkC,IAAI;QACJC,KAAK,EAAEC;MAAY,GAE1B;IACL;IAEA,MAAMD,KAA4D,mCAC3DC,YAAY,CAClB;IACD,OAAOD,KAAK,CAAC,QAAQ,CAAC;IACtB,OAAOA,KAAK,CAAC,QAAQ,CAAC;IAEtB,MAAMQ,aAAa,GAAG,IAAAC,mBAAW,EAAC;MAC9BC,KAAK,EAAEJ,OAAO;MACdN,KAAK;MACLW,MAAM,EAAE,EAAE;MACVnC;IACJ,CAAC,CAAC;IAEF,IAAI,CAACuB,IAAI,IAAIA,IAAI,CAAClB,MAAM,KAAK,CAAC,IAAI2B,aAAa,CAAC3B,MAAM,KAAK,CAAC,EAAE;MAC1D,OAAO2B,aAAa;IACxB;IACA,OAAO,IAAAI,eAAS,EAAC;MACbF,KAAK,EAAEF,aAAa;MACpBT,IAAI;MACJY,MAAM,EAAE;IACZ,CAAC,CAAC;EACN,CAAC;EAED,OAAO;IACH5B,MAAM;IACNS,MAAM;IACNE,MAAM,EAAED,WAAW;IACnBE,GAAG;IACHG;EACJ,CAAC;AACL,CAAC;AAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CmsModelStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
2
|
import { Entity } from "dynamodb-toolbox";
|
|
3
3
|
import { Client } from "@elastic/elasticsearch";
|
|
4
|
-
export interface
|
|
4
|
+
export interface CreateModelsStorageOperationsParams {
|
|
5
5
|
entity: Entity<any>;
|
|
6
6
|
elasticsearch: Client;
|
|
7
7
|
}
|
|
8
|
-
export declare const createModelsStorageOperations: (params:
|
|
8
|
+
export declare const createModelsStorageOperations: (params: CreateModelsStorageOperationsParams) => CmsModelStorageOperations;
|