@webiny/api-headless-cms-ddb-es 0.0.0-unstable.6f45466a1d → 0.0.0-unstable.7be00a75a9
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 +5 -4
- package/configurations.js +27 -33
- package/configurations.js.map +1 -1
- package/definitions/entry.js +7 -9
- package/definitions/entry.js.map +1 -1
- package/definitions/group.js +7 -9
- package/definitions/group.js.map +1 -1
- package/definitions/model.js +7 -9
- package/definitions/model.js.map +1 -1
- package/definitions/types.d.ts +9 -3
- package/definitions/types.js +0 -3
- package/elasticsearch/createElasticsearchIndex.d.ts +3 -3
- package/elasticsearch/createElasticsearchIndex.js +52 -27
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/elasticsearch/deleteElasticsearchIndex.d.ts +1 -1
- package/elasticsearch/deleteElasticsearchIndex.js +18 -26
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
- package/exports/api/cms/opensearch.d.ts +9 -0
- package/exports/api/cms/opensearch.js +9 -0
- package/feature.d.ts +1 -0
- package/feature.js +179 -0
- package/feature.js.map +1 -0
- package/features/CmsEntryOpenSearchBodyModifier/abstractions.d.ts +16 -0
- package/features/CmsEntryOpenSearchBodyModifier/abstractions.js +5 -0
- package/features/CmsEntryOpenSearchBodyModifier/abstractions.js.map +1 -0
- package/features/CmsEntryOpenSearchBodyModifier/index.d.ts +1 -0
- package/features/CmsEntryOpenSearchBodyModifier/index.js +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.d.ts +14 -0
- package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js +42 -0
- package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.d.ts +32 -0
- package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js +5 -0
- package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.d.ts +11 -0
- package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js +5 -0
- package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/constants.d.ts +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/constants.js +4 -0
- package/features/CmsEntryOpenSearchFieldIndex/constants.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/feature.d.ts +4 -0
- package/features/CmsEntryOpenSearchFieldIndex/feature.js +29 -0
- package/features/CmsEntryOpenSearchFieldIndex/feature.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.d.ts +11 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js +60 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.d.ts +13 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js +33 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.d.ts +10 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js +21 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.d.ts +10 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js +22 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.d.ts +11 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js +32 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.d.ts +12 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js +107 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.d.ts +10 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js +21 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.d.ts +15 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js +40 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.d.ts +15 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.js +40 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/index.d.ts +3 -0
- package/features/CmsEntryOpenSearchFieldIndex/index.js +3 -0
- package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.d.ts +11 -0
- package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js +36 -0
- package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js.map +1 -0
- package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.d.ts +37 -0
- package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js +5 -0
- package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js.map +1 -0
- package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.d.ts +9 -0
- package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js +5 -0
- package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js.map +1 -0
- package/features/CmsEntryOpenSearchFilter/constants.d.ts +1 -0
- package/features/CmsEntryOpenSearchFilter/constants.js +4 -0
- package/features/CmsEntryOpenSearchFilter/constants.js.map +1 -0
- package/features/CmsEntryOpenSearchFilter/feature.d.ts +4 -0
- package/features/CmsEntryOpenSearchFilter/feature.js +17 -0
- package/features/CmsEntryOpenSearchFilter/feature.js.map +1 -0
- package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.d.ts +9 -0
- package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js +26 -0
- package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js.map +1 -0
- package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.d.ts +9 -0
- package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js +43 -0
- package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js.map +1 -0
- package/features/CmsEntryOpenSearchFilter/fields/RefFilter.d.ts +9 -0
- package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js +36 -0
- package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js.map +1 -0
- package/features/CmsEntryOpenSearchFilter/index.d.ts +3 -0
- package/features/CmsEntryOpenSearchFilter/index.js +3 -0
- package/features/CmsEntryOpenSearchFullTextSearch/abstractions.d.ts +20 -0
- package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js +5 -0
- package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js.map +1 -0
- package/features/CmsEntryOpenSearchFullTextSearch/index.d.ts +1 -0
- package/features/CmsEntryOpenSearchFullTextSearch/index.js +1 -0
- package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.d.ts +11 -0
- package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.js +17 -0
- package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.js.map +1 -0
- package/features/CmsEntryOpenSearchIndex/abstractions.d.ts +14 -0
- package/features/CmsEntryOpenSearchIndex/abstractions.js +5 -0
- package/features/CmsEntryOpenSearchIndex/abstractions.js.map +1 -0
- package/features/CmsEntryOpenSearchIndex/feature.d.ts +4 -0
- package/features/CmsEntryOpenSearchIndex/feature.js +11 -0
- package/features/CmsEntryOpenSearchIndex/feature.js.map +1 -0
- package/features/CmsEntryOpenSearchIndex/index.d.ts +3 -0
- package/features/CmsEntryOpenSearchIndex/index.js +3 -0
- package/features/CmsEntryOpenSearchQueryModifier/abstractions.d.ts +16 -0
- package/features/CmsEntryOpenSearchQueryModifier/abstractions.js +5 -0
- package/features/CmsEntryOpenSearchQueryModifier/abstractions.js.map +1 -0
- package/features/CmsEntryOpenSearchQueryModifier/index.d.ts +1 -0
- package/features/CmsEntryOpenSearchQueryModifier/index.js +1 -0
- package/features/CmsEntryOpenSearchSortModifier/abstractions.d.ts +15 -0
- package/features/CmsEntryOpenSearchSortModifier/abstractions.js +5 -0
- package/features/CmsEntryOpenSearchSortModifier/abstractions.js.map +1 -0
- package/features/CmsEntryOpenSearchSortModifier/index.d.ts +1 -0
- package/features/CmsEntryOpenSearchSortModifier/index.js +1 -0
- package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.d.ts +12 -0
- package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js +31 -0
- package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -0
- package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.d.ts +22 -0
- package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js +5 -0
- package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js.map +1 -0
- package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.d.ts +10 -0
- package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js +5 -0
- package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -0
- package/features/CmsEntryOpenSearchValueSearch/feature.d.ts +4 -0
- package/features/CmsEntryOpenSearchValueSearch/feature.js +17 -0
- package/features/CmsEntryOpenSearchValueSearch/feature.js.map +1 -0
- package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.d.ts +10 -0
- package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js +21 -0
- package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js.map +1 -0
- package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.d.ts +10 -0
- package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js +44 -0
- package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js.map +1 -0
- package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.d.ts +10 -0
- package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js +22 -0
- package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js.map +1 -0
- package/features/CmsEntryOpenSearchValueSearch/index.d.ts +3 -0
- package/features/CmsEntryOpenSearchValueSearch/index.js +3 -0
- package/features/CmsEntryOpenSearchValuesModifier/abstractions.d.ts +23 -0
- package/features/CmsEntryOpenSearchValuesModifier/abstractions.js +5 -0
- package/features/CmsEntryOpenSearchValuesModifier/abstractions.js.map +1 -0
- package/features/CmsEntryOpenSearchValuesModifier/index.d.ts +1 -0
- package/features/CmsEntryOpenSearchValuesModifier/index.js +1 -0
- package/helpers/entryIndexHelpers.d.ts +6 -4
- package/helpers/entryIndexHelpers.js +70 -186
- package/helpers/entryIndexHelpers.js.map +1 -1
- package/helpers/fieldIdentifier.js +18 -30
- package/helpers/fieldIdentifier.js.map +1 -1
- package/helpers/index.js +0 -2
- package/index.d.ts +1 -3
- package/index.js +1 -190
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +22 -29
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
- package/operations/entry/dataLoader/constants.js +2 -1
- package/operations/entry/dataLoader/constants.js.map +1 -1
- package/operations/entry/dataLoader/createBatchScheduleFn.js +6 -15
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
- package/operations/entry/dataLoader/getAllEntryRevisions.js +18 -26
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +28 -34
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +28 -34
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getRevisionById.js +33 -43
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
- package/operations/entry/dataLoader/index.js +8 -9
- package/operations/entry/dataLoader/index.js.map +1 -1
- package/operations/entry/dataLoader/types.d.ts +1 -0
- package/operations/entry/dataLoader/types.js +0 -3
- package/operations/entry/dataLoaders.js +81 -97
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +6 -24
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
- package/operations/entry/elasticsearch/body.d.ts +19 -3
- package/operations/entry/elasticsearch/body.js +74 -122
- package/operations/entry/elasticsearch/body.js.map +1 -1
- package/operations/entry/elasticsearch/fields/createSystemField.d.ts +4 -0
- package/operations/entry/elasticsearch/fields/createSystemField.js +9 -0
- package/operations/entry/elasticsearch/fields/createSystemField.js.map +1 -0
- package/operations/entry/elasticsearch/fields/live.d.ts +2 -0
- package/operations/entry/elasticsearch/fields/live.js +50 -0
- package/operations/entry/elasticsearch/fields/live.js.map +1 -0
- package/operations/entry/elasticsearch/fields/location.d.ts +2 -0
- package/operations/entry/elasticsearch/fields/location.js +50 -0
- package/operations/entry/elasticsearch/fields/location.js.map +1 -0
- package/operations/entry/elasticsearch/fields/state.d.ts +2 -0
- package/operations/entry/elasticsearch/fields/state.js +104 -0
- package/operations/entry/elasticsearch/fields/state.js.map +1 -0
- package/operations/entry/elasticsearch/fields.d.ts +6 -4
- package/operations/entry/elasticsearch/fields.js +194 -388
- package/operations/entry/elasticsearch/fields.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +6 -5
- package/operations/entry/elasticsearch/filtering/applyFiltering.js +32 -45
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/exec.d.ts +6 -2
- package/operations/entry/elasticsearch/filtering/exec.js +84 -166
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/index.js +0 -2
- package/operations/entry/elasticsearch/filtering/path.d.ts +4 -3
- package/operations/entry/elasticsearch/filtering/path.js +24 -35
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -2
- package/operations/entry/elasticsearch/filtering/populated.js +8 -14
- package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/values.js +11 -12
- package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearch.d.ts +7 -6
- package/operations/entry/elasticsearch/fullTextSearch.js +45 -79
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +4 -4
- package/operations/entry/elasticsearch/fullTextSearchFields.js +7 -17
- package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
- package/operations/entry/elasticsearch/initialQuery.d.ts +3 -3
- package/operations/entry/elasticsearch/initialQuery.js +37 -80
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
- package/operations/entry/elasticsearch/keyword.js +13 -27
- package/operations/entry/elasticsearch/keyword.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/operator.d.ts +2 -2
- package/operations/entry/elasticsearch/plugins/operator.js +10 -21
- package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +6 -4
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -1
- package/operations/entry/elasticsearch/sort.d.ts +4 -4
- package/operations/entry/elasticsearch/sort.js +69 -96
- package/operations/entry/elasticsearch/sort.js.map +1 -1
- package/operations/entry/elasticsearch/transformValueForSearch.d.ts +2 -9
- package/operations/entry/elasticsearch/transformValueForSearch.js +9 -24
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
- package/operations/entry/elasticsearch/types.d.ts +3 -10
- package/operations/entry/elasticsearch/types.js +0 -3
- package/operations/entry/index.d.ts +22 -2
- package/operations/entry/index.js +1316 -1650
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.js +43 -63
- package/operations/entry/keys.js.map +1 -1
- package/operations/entry/recordType.js +4 -9
- package/operations/entry/recordType.js.map +1 -1
- package/operations/entry/transformations/convertEntryKeys.js +21 -26
- package/operations/entry/transformations/convertEntryKeys.js.map +1 -1
- package/operations/entry/transformations/index.d.ts +6 -2
- package/operations/entry/transformations/index.js +84 -112
- package/operations/entry/transformations/index.js.map +1 -1
- package/operations/entry/transformations/modifyEntryValues.d.ts +6 -4
- package/operations/entry/transformations/modifyEntryValues.js +12 -17
- package/operations/entry/transformations/modifyEntryValues.js.map +1 -1
- package/operations/entry/transformations/transformEntryKeys.js +13 -16
- package/operations/entry/transformations/transformEntryKeys.js.map +1 -1
- package/operations/entry/transformations/transformEntryToIndex.d.ts +2 -2
- package/operations/entry/transformations/transformEntryToIndex.js +16 -20
- package/operations/entry/transformations/transformEntryToIndex.js.map +1 -1
- package/operations/group/index.d.ts +2 -2
- package/operations/group/index.js +115 -139
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +1 -1
- package/operations/model/index.js +128 -157
- package/operations/model/index.js.map +1 -1
- package/package.json +35 -30
- package/tasks/createIndexTaskPlugin.js +36 -32
- package/tasks/createIndexTaskPlugin.js.map +1 -1
- package/types.d.ts +7 -112
- package/types.js +7 -36
- package/types.js.map +1 -1
- package/values/NoValueContainer.js +8 -10
- package/values/NoValueContainer.js.map +1 -1
- package/definitions/types.js.map +0 -1
- package/dynamoDb/index.d.ts +0 -3
- package/dynamoDb/index.js +0 -8
- package/dynamoDb/index.js.map +0 -1
- package/dynamoDb/storage/longText.d.ts +0 -10
- package/dynamoDb/storage/longText.js +0 -88
- package/dynamoDb/storage/longText.js.map +0 -1
- package/dynamoDb/storage/richText.d.ts +0 -2
- package/dynamoDb/storage/richText.js +0 -51
- package/dynamoDb/storage/richText.js.map +0 -1
- package/elasticsearch/index.d.ts +0 -2
- package/elasticsearch/index.js +0 -5
- package/elasticsearch/index.js.map +0 -1
- package/elasticsearch/indexing/dateTimeIndexing.d.ts +0 -3
- package/elasticsearch/indexing/dateTimeIndexing.js +0 -81
- package/elasticsearch/indexing/dateTimeIndexing.js.map +0 -1
- package/elasticsearch/indexing/defaultFieldIndexing.d.ts +0 -3
- package/elasticsearch/indexing/defaultFieldIndexing.js +0 -47
- package/elasticsearch/indexing/defaultFieldIndexing.js.map +0 -1
- package/elasticsearch/indexing/index.d.ts +0 -2
- package/elasticsearch/indexing/index.js +0 -10
- package/elasticsearch/indexing/index.js.map +0 -1
- package/elasticsearch/indexing/jsonIndexing.d.ts +0 -2
- package/elasticsearch/indexing/jsonIndexing.js +0 -21
- package/elasticsearch/indexing/jsonIndexing.js.map +0 -1
- package/elasticsearch/indexing/longTextIndexing.d.ts +0 -7
- package/elasticsearch/indexing/longTextIndexing.js +0 -35
- package/elasticsearch/indexing/longTextIndexing.js.map +0 -1
- package/elasticsearch/indexing/numberIndexing.d.ts +0 -3
- package/elasticsearch/indexing/numberIndexing.js +0 -34
- package/elasticsearch/indexing/numberIndexing.js.map +0 -1
- package/elasticsearch/indexing/objectIndexing.d.ts +0 -12
- package/elasticsearch/indexing/objectIndexing.js +0 -194
- package/elasticsearch/indexing/objectIndexing.js.map +0 -1
- package/elasticsearch/indexing/richTextIndexing.d.ts +0 -3
- package/elasticsearch/indexing/richTextIndexing.js +0 -24
- package/elasticsearch/indexing/richTextIndexing.js.map +0 -1
- package/elasticsearch/indices/base.d.ts +0 -2
- package/elasticsearch/indices/base.js +0 -7
- package/elasticsearch/indices/base.js.map +0 -1
- package/elasticsearch/indices/index.d.ts +0 -1
- package/elasticsearch/indices/index.js +0 -6
- package/elasticsearch/indices/index.js.map +0 -1
- package/elasticsearch/search/index.d.ts +0 -3
- package/elasticsearch/search/index.js +0 -6
- package/elasticsearch/search/index.js.map +0 -1
- package/elasticsearch/search/refSearch.d.ts +0 -2
- package/elasticsearch/search/refSearch.js +0 -24
- package/elasticsearch/search/refSearch.js.map +0 -1
- package/elasticsearch/search/searchableJson.d.ts +0 -2
- package/elasticsearch/search/searchableJson.js +0 -53
- package/elasticsearch/search/searchableJson.js.map +0 -1
- package/elasticsearch/search/timeSearch.d.ts +0 -2
- package/elasticsearch/search/timeSearch.js +0 -20
- package/elasticsearch/search/timeSearch.js.map +0 -1
- package/helpers/index.js.map +0 -1
- package/index.js.map +0 -1
- package/operations/entry/dataLoader/types.js.map +0 -1
- package/operations/entry/elasticsearch/filtering/index.js.map +0 -1
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +0 -2
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +0 -22
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +0 -1
- package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +0 -1
- package/operations/entry/elasticsearch/filtering/plugins/index.js +0 -8
- package/operations/entry/elasticsearch/filtering/plugins/index.js.map +0 -1
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +0 -2
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +0 -61
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +0 -1
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +0 -2
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +0 -49
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +0 -1
- package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +0 -9
- package/operations/entry/elasticsearch/plugins/bodyModifier.js +0 -11
- package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +0 -1
- package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +0 -9
- package/operations/entry/elasticsearch/plugins/queryModifier.js +0 -11
- package/operations/entry/elasticsearch/plugins/queryModifier.js.map +0 -1
- package/operations/entry/elasticsearch/plugins/search.d.ts +0 -7
- package/operations/entry/elasticsearch/plugins/search.js +0 -18
- package/operations/entry/elasticsearch/plugins/search.js.map +0 -1
- package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +0 -9
- package/operations/entry/elasticsearch/plugins/sortModifier.js +0 -11
- package/operations/entry/elasticsearch/plugins/sortModifier.js.map +0 -1
- package/operations/entry/elasticsearch/types.js.map +0 -1
- package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +0 -69
- package/plugins/CmsElasticsearchModelFieldPlugin.js +0 -46
- package/plugins/CmsElasticsearchModelFieldPlugin.js.map +0 -1
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +0 -22
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +0 -13
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +0 -1
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +0 -23
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +0 -19
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +0 -1
- package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +0 -4
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +0 -6
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +0 -1
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +0 -32
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +0 -32
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +0 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +0 -19
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +0 -13
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +0 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +0 -19
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +0 -13
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +0 -1
- package/plugins/CmsEntryElasticsearchValuesModifier.d.ts +0 -33
- package/plugins/CmsEntryElasticsearchValuesModifier.js +0 -42
- package/plugins/CmsEntryElasticsearchValuesModifier.js.map +0 -1
- package/plugins/CmsEntryFilterPlugin.d.ts +0 -49
- package/plugins/CmsEntryFilterPlugin.js +0 -15
- package/plugins/CmsEntryFilterPlugin.js.map +0 -1
- package/plugins/index.d.ts +0 -8
- package/plugins/index.js +0 -10
- package/plugins/index.js.map +0 -1
|
@@ -1,164 +1,135 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _webiny_error from "@webiny/error";
|
|
2
2
|
import { configurations } from "../../configurations.js";
|
|
3
|
-
const createPartitionKey = params
|
|
4
|
-
|
|
5
|
-
tenant
|
|
6
|
-
} = params;
|
|
7
|
-
return `T#${tenant}#CMS#CM`;
|
|
3
|
+
const createPartitionKey = (params)=>{
|
|
4
|
+
const { tenant } = params;
|
|
5
|
+
return `T#${tenant}#CMS#CM`;
|
|
8
6
|
};
|
|
9
|
-
const createSortKey = params
|
|
10
|
-
|
|
7
|
+
const createSortKey = (params)=>params.modelId;
|
|
8
|
+
const createKeys = (params)=>{
|
|
9
|
+
if (!params.tenant) throw new Error("Missing tenant when creating model keys!");
|
|
10
|
+
return {
|
|
11
|
+
PK: createPartitionKey(params),
|
|
12
|
+
SK: createSortKey(params),
|
|
13
|
+
GSI_TENANT: params.tenant
|
|
14
|
+
};
|
|
11
15
|
};
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
return model;
|
|
122
|
-
};
|
|
123
|
-
const get = async params => {
|
|
124
|
-
const keys = createKeys(params);
|
|
125
|
-
try {
|
|
126
|
-
const result = await entity.get(keys);
|
|
127
|
-
return result ? result.data : null;
|
|
128
|
-
} catch (ex) {
|
|
129
|
-
throw new WebinyError(ex.message || "Could not get model.", ex.code || "MODEL_GET_ERROR", {
|
|
130
|
-
error: ex,
|
|
131
|
-
keys
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
const list = async params => {
|
|
136
|
-
const {
|
|
137
|
-
where
|
|
138
|
-
} = params;
|
|
139
|
-
const partitionKey = createPartitionKey(where);
|
|
140
|
-
try {
|
|
141
|
-
const result = await entity.queryAll({
|
|
142
|
-
partitionKey,
|
|
143
|
-
options: {
|
|
144
|
-
gte: " "
|
|
16
|
+
const createType = ()=>"cms.model";
|
|
17
|
+
const createModelsStorageOperations = (params)=>{
|
|
18
|
+
const { entity, elasticsearch } = params;
|
|
19
|
+
const create = async (params)=>{
|
|
20
|
+
const { model } = params;
|
|
21
|
+
const { index } = configurations.es({
|
|
22
|
+
model
|
|
23
|
+
});
|
|
24
|
+
const keys = createKeys(model);
|
|
25
|
+
let error;
|
|
26
|
+
try {
|
|
27
|
+
await entity.put({
|
|
28
|
+
data: model,
|
|
29
|
+
...keys,
|
|
30
|
+
TYPE: createType()
|
|
31
|
+
});
|
|
32
|
+
return model;
|
|
33
|
+
} catch (ex) {
|
|
34
|
+
error = ex;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
await elasticsearch.indices.delete({
|
|
38
|
+
index,
|
|
39
|
+
ignore_unavailable: true
|
|
40
|
+
});
|
|
41
|
+
} catch (ex) {
|
|
42
|
+
throw new _webiny_error(`Could not delete elasticsearch index "${index}" after model record failed to be created.`, "DELETE_MODEL_INDEX_ERROR", {
|
|
43
|
+
dynamodbError: error,
|
|
44
|
+
elasticsearchError: ex
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
throw error;
|
|
48
|
+
};
|
|
49
|
+
const update = async (params)=>{
|
|
50
|
+
const { model } = params;
|
|
51
|
+
const keys = createKeys(model);
|
|
52
|
+
try {
|
|
53
|
+
await entity.put({
|
|
54
|
+
data: model,
|
|
55
|
+
...keys,
|
|
56
|
+
TYPE: createType()
|
|
57
|
+
});
|
|
58
|
+
return model;
|
|
59
|
+
} catch (ex) {
|
|
60
|
+
throw new _webiny_error(ex.message || "Could not update model.", ex.code || "MODEL_UPDATE_ERROR", {
|
|
61
|
+
error: ex,
|
|
62
|
+
model,
|
|
63
|
+
keys
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const deleteModel = async (params)=>{
|
|
68
|
+
const { model } = params;
|
|
69
|
+
const keys = createKeys(model);
|
|
70
|
+
const { index } = configurations.es({
|
|
71
|
+
model
|
|
72
|
+
});
|
|
73
|
+
try {
|
|
74
|
+
await entity.delete(keys);
|
|
75
|
+
} catch (ex) {
|
|
76
|
+
throw new _webiny_error(ex.message || "Could not delete model.", ex.code || "MODEL_DELETE_ERROR", {
|
|
77
|
+
error: ex,
|
|
78
|
+
model,
|
|
79
|
+
keys
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
await elasticsearch.indices.delete({
|
|
84
|
+
index,
|
|
85
|
+
ignore_unavailable: true
|
|
86
|
+
});
|
|
87
|
+
} catch (ex) {
|
|
88
|
+
throw new _webiny_error(`Could not delete elasticsearch index "${index}" after model record delete.`, "DELETE_MODEL_INDEX_ERROR", {
|
|
89
|
+
error: ex,
|
|
90
|
+
index,
|
|
91
|
+
model
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const get = async (params)=>{
|
|
96
|
+
const keys = createKeys(params);
|
|
97
|
+
try {
|
|
98
|
+
const result = await entity.get(keys);
|
|
99
|
+
return result ? result.data : null;
|
|
100
|
+
} catch (ex) {
|
|
101
|
+
throw new _webiny_error(ex.message || "Could not get model.", ex.code || "MODEL_GET_ERROR", {
|
|
102
|
+
error: ex,
|
|
103
|
+
keys
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const list = async (params)=>{
|
|
108
|
+
const { where } = params;
|
|
109
|
+
const partitionKey = createPartitionKey(where);
|
|
110
|
+
try {
|
|
111
|
+
const result = await entity.queryAll({
|
|
112
|
+
partitionKey,
|
|
113
|
+
options: {
|
|
114
|
+
gte: " "
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
return result ? result.map((item)=>item.data) : [];
|
|
118
|
+
} catch (ex) {
|
|
119
|
+
throw new _webiny_error(ex.message || "Could not list models.", ex.code || "MODEL_LIST_ERROR", {
|
|
120
|
+
error: ex,
|
|
121
|
+
partitionKey
|
|
122
|
+
});
|
|
145
123
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
return {
|
|
156
|
-
create,
|
|
157
|
-
update,
|
|
158
|
-
delete: deleteModel,
|
|
159
|
-
get,
|
|
160
|
-
list
|
|
161
|
-
};
|
|
124
|
+
};
|
|
125
|
+
return {
|
|
126
|
+
create,
|
|
127
|
+
update,
|
|
128
|
+
delete: deleteModel,
|
|
129
|
+
get,
|
|
130
|
+
list
|
|
131
|
+
};
|
|
162
132
|
};
|
|
133
|
+
export { createModelsStorageOperations };
|
|
163
134
|
|
|
164
135
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebinyError","configurations","createPartitionKey","params","tenant","createSortKey","modelId","createKeys","Error","PK","SK","GSI_TENANT","createType","createModelsStorageOperations","entity","elasticsearch","create","model","index","es","keys","error","put","data","TYPE","ex","indices","delete","ignore_unavailable","dynamodbError","elasticsearchError","update","message","code","deleteModel","get","result","list","where","partitionKey","queryAll","options","gte","map","item"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModelStorageOperations,\n CmsModelStorageOperationsCreateParams,\n CmsModelStorageOperationsDeleteParams,\n CmsModelStorageOperationsGetParams,\n CmsModelStorageOperationsListParams,\n CmsModelStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { configurations } from \"~/configurations.js\";\nimport type { Client } from \"@elastic/elasticsearch\";\nimport type { IModelEntity } from \"~/definitions/types.js\";\n\ninterface PartitionKeysParams {\n tenant: string;\n}\n\nconst createPartitionKey = (params: PartitionKeysParams): string => {\n const { tenant } = params;\n return `T#${tenant}#CMS#CM`;\n};\n\ninterface SortKeyParams {\n modelId: string;\n}\n\nconst createSortKey = (params: SortKeyParams): string => {\n return params.modelId;\n};\n\ninterface IDynamoDbTableKeys {\n PK: string;\n SK: string;\n GSI_TENANT: string;\n}\n\nconst createKeys = (params: PartitionKeysParams & SortKeyParams): IDynamoDbTableKeys => {\n if (!params.tenant) {\n throw new Error(\"Missing tenant when creating model keys!\");\n }\n return {\n PK: createPartitionKey(params),\n SK: createSortKey(params),\n GSI_TENANT: params.tenant\n };\n};\n\nconst createType = (): string => {\n return \"cms.model\";\n};\n\nexport interface CreateModelsStorageOperationsParams {\n entity: IModelEntity;\n elasticsearch: Client;\n}\n\nexport const createModelsStorageOperations = (\n params: CreateModelsStorageOperationsParams\n): CmsModelStorageOperations => {\n const { entity, elasticsearch } = params;\n\n const create = async (params: CmsModelStorageOperationsCreateParams) => {\n const { model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n const keys = createKeys(model);\n\n let error;\n try {\n await entity.put({\n data: model,\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n error = ex;\n }\n /**\n * In case of DynamoDB error we need to remove the index we created.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record failed to be created.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n dynamodbError: error,\n elasticsearchError: ex\n }\n );\n }\n throw error;\n };\n\n const update = async (params: CmsModelStorageOperationsUpdateParams) => {\n const { model } = params;\n\n const keys = createKeys(model);\n\n try {\n await entity.put({\n data: model,\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update model.\",\n ex.code || \"MODEL_UPDATE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n };\n\n const deleteModel = async (params: CmsModelStorageOperationsDeleteParams) => {\n const { model } = params;\n const keys = createKeys(model);\n\n const { index } = configurations.es({\n model\n });\n\n try {\n await entity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete model.\",\n ex.code || \"MODEL_DELETE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n /**\n * Always delete the model index after deleting the model.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record delete.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n error: ex,\n index,\n model\n }\n );\n }\n\n return model;\n };\n\n const get = async (params: CmsModelStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const result = await entity.get(keys);\n\n return result ? result.data : null;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get model.\",\n ex.code || \"MODEL_GET_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n const list = async (params: CmsModelStorageOperationsListParams) => {\n const { where } = params;\n const partitionKey = createPartitionKey(where);\n try {\n const result = await entity.queryAll({\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n return result ? result.map(item => item.data) : [];\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list models.\",\n ex.code || \"MODEL_LIST_ERROR\",\n {\n error: ex,\n partitionKey\n }\n );\n }\n };\n\n return {\n create,\n update,\n delete: deleteModel,\n get,\n list\n };\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AASvC,SAASC,cAAc;AAQvB,MAAMC,kBAAkB,GAAIC,MAA2B,IAAa;EAChE,MAAM;IAAEC;EAAO,CAAC,GAAGD,MAAM;EACzB,OAAO,KAAKC,MAAM,SAAS;AAC/B,CAAC;AAMD,MAAMC,aAAa,GAAIF,MAAqB,IAAa;EACrD,OAAOA,MAAM,CAACG,OAAO;AACzB,CAAC;AAQD,MAAMC,UAAU,GAAIJ,MAA2C,IAAyB;EACpF,IAAI,CAACA,MAAM,CAACC,MAAM,EAAE;IAChB,MAAM,IAAII,KAAK,CAAC,0CAA0C,CAAC;EAC/D;EACA,OAAO;IACHC,EAAE,EAAEP,kBAAkB,CAACC,MAAM,CAAC;IAC9BO,EAAE,EAAEL,aAAa,CAACF,MAAM,CAAC;IACzBQ,UAAU,EAAER,MAAM,CAACC;EACvB,CAAC;AACL,CAAC;AAED,MAAMQ,UAAU,GAAGA,CAAA,KAAc;EAC7B,OAAO,WAAW;AACtB,CAAC;AAOD,OAAO,MAAMC,6BAA6B,GACtCV,MAA2C,IACf;EAC5B,MAAM;IAAEW,MAAM;IAAEC;EAAc,CAAC,GAAGZ,MAAM;EAExC,MAAMa,MAAM,GAAG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E;MACT,MAAM,IAAIzB,WAAW,CACjByB,EAAE,CAACO,OAAO,IAAI,sBAAsB,EACpCP,EAAE,CAACQ,IAAI,IAAI,iBAAiB,EAC5B;QACIZ,KAAK,EAAEI,EAAE;QACTL;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,MAAMiB,IAAI,GAAG,MAAOlC,MAA2C,IAAK;IAChE,MAAM;MAAEmC;IAAM,CAAC,GAAGnC,MAAM;IACxB,MAAMoC,YAAY,GAAGrC,kBAAkB,CAACoC,KAAK,CAAC;IAC9C,IAAI;MACA,MAAMF,MAAM,GAAG,MAAMtB,MAAM,CAAC0B,QAAQ,CAAC;QACjCD,YAAY;QACZE,OAAO,EAAE;UACLC,GAAG,EAAE;QACT;MACJ,CAAC,CAAC;MACF,OAAON,MAAM,GAAGA,MAAM,CAACO,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACrB,IAAI,CAAC,GAAG,EAAE;IACtD,CAAC,CAAC,OAAOE,EAAE,EAAE;MACT,MAAM,IAAIzB,WAAW,CACjByB,EAAE,CAACO,OAAO,IAAI,wBAAwB,EACtCP,EAAE,CAACQ,IAAI,IAAI,kBAAkB,EAC7B;QACIZ,KAAK,EAAEI,EAAE;QACTc;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACHvB,MAAM;IACNe,MAAM;IACNJ,MAAM,EAAEO,WAAW;IACnBC,GAAG;IACHE;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"operations/model/index.js","sources":["../../../src/operations/model/index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModelStorageOperations,\n CmsModelStorageOperationsCreateParams,\n CmsModelStorageOperationsDeleteParams,\n CmsModelStorageOperationsGetParams,\n CmsModelStorageOperationsListParams,\n CmsModelStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { configurations } from \"~/configurations.js\";\nimport type { Client } from \"@webiny/api-opensearch\";\nimport type { IModelEntity } from \"~/definitions/types.js\";\n\ninterface PartitionKeysParams {\n tenant: string;\n}\n\nconst createPartitionKey = (params: PartitionKeysParams): string => {\n const { tenant } = params;\n return `T#${tenant}#CMS#CM`;\n};\n\ninterface SortKeyParams {\n modelId: string;\n}\n\nconst createSortKey = (params: SortKeyParams): string => {\n return params.modelId;\n};\n\ninterface IDynamoDbTableKeys {\n PK: string;\n SK: string;\n GSI_TENANT: string;\n}\n\nconst createKeys = (params: PartitionKeysParams & SortKeyParams): IDynamoDbTableKeys => {\n if (!params.tenant) {\n throw new Error(\"Missing tenant when creating model keys!\");\n }\n return {\n PK: createPartitionKey(params),\n SK: createSortKey(params),\n GSI_TENANT: params.tenant\n };\n};\n\nconst createType = (): string => {\n return \"cms.model\";\n};\n\nexport interface CreateModelsStorageOperationsParams {\n entity: IModelEntity;\n elasticsearch: Client;\n}\n\nexport const createModelsStorageOperations = (\n params: CreateModelsStorageOperationsParams\n): CmsModelStorageOperations => {\n const { entity, elasticsearch } = params;\n\n const create = async (params: CmsModelStorageOperationsCreateParams) => {\n const { model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n const keys = createKeys(model);\n\n let error;\n try {\n await entity.put({\n data: model,\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n error = ex;\n }\n /**\n * In case of DynamoDB error we need to remove the index we created.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record failed to be created.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n dynamodbError: error,\n elasticsearchError: ex\n }\n );\n }\n throw error;\n };\n\n const update = async (params: CmsModelStorageOperationsUpdateParams) => {\n const { model } = params;\n\n const keys = createKeys(model);\n\n try {\n await entity.put({\n data: model,\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update model.\",\n ex.code || \"MODEL_UPDATE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n };\n\n const deleteModel = async (params: CmsModelStorageOperationsDeleteParams): Promise<void> => {\n const { model } = params;\n const keys = createKeys(model);\n\n const { index } = configurations.es({\n model\n });\n\n try {\n await entity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete model.\",\n ex.code || \"MODEL_DELETE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n /**\n * Always delete the model index after deleting the model.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record delete.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n error: ex,\n index,\n model\n }\n );\n }\n };\n\n const get = async (params: CmsModelStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const result = await entity.get(keys);\n\n return result ? result.data : null;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get model.\",\n ex.code || \"MODEL_GET_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n const list = async (params: CmsModelStorageOperationsListParams) => {\n const { where } = params;\n const partitionKey = createPartitionKey(where);\n try {\n const result = await entity.queryAll({\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n return result ? result.map(item => item.data) : [];\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list models.\",\n ex.code || \"MODEL_LIST_ERROR\",\n {\n error: ex,\n partitionKey\n }\n );\n }\n };\n\n return {\n create,\n update,\n delete: deleteModel,\n get,\n list\n };\n};\n"],"names":["createPartitionKey","params","tenant","createSortKey","createKeys","Error","createType","createModelsStorageOperations","entity","elasticsearch","create","model","index","configurations","keys","error","ex","WebinyError","update","deleteModel","get","result","list","where","partitionKey","item"],"mappings":";;AAiBA,MAAMA,qBAAqB,CAACC;IACxB,MAAM,EAAEC,MAAM,EAAE,GAAGD;IACnB,OAAO,CAAC,EAAE,EAAEC,OAAO,OAAO,CAAC;AAC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ACX;gBACI,OAAOA;gBACPQ;YACJ;QAER;IACJ;IAEA,OAAO;QACHd;QACAQ;QACA,QAAQC;QACRC;QACAE;IACJ;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-ddb-es",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.7be00a75a9",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
6
9
|
"keywords": [
|
|
7
10
|
"@webiny/api-headless-cms",
|
|
8
11
|
"storage-operations",
|
|
@@ -27,40 +30,42 @@
|
|
|
27
30
|
],
|
|
28
31
|
"license": "MIT",
|
|
29
32
|
"dependencies": {
|
|
30
|
-
"@webiny/api": "0.0.0-unstable.
|
|
31
|
-
"@webiny/api-elasticsearch": "0.0.0-unstable.
|
|
32
|
-
"@webiny/api-
|
|
33
|
-
"@webiny/api-
|
|
34
|
-
"@webiny/aws-sdk": "0.0.0-unstable.
|
|
35
|
-
"@webiny/db-dynamodb": "0.0.0-unstable.
|
|
36
|
-
"@webiny/error": "0.0.0-unstable.
|
|
37
|
-
"@webiny/
|
|
38
|
-
"@webiny/
|
|
39
|
-
"@webiny/
|
|
33
|
+
"@webiny/api": "0.0.0-unstable.7be00a75a9",
|
|
34
|
+
"@webiny/api-elasticsearch-tasks": "0.0.0-unstable.7be00a75a9",
|
|
35
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.7be00a75a9",
|
|
36
|
+
"@webiny/api-opensearch": "0.0.0-unstable.7be00a75a9",
|
|
37
|
+
"@webiny/aws-sdk": "0.0.0-unstable.7be00a75a9",
|
|
38
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.7be00a75a9",
|
|
39
|
+
"@webiny/error": "0.0.0-unstable.7be00a75a9",
|
|
40
|
+
"@webiny/feature": "0.0.0-unstable.7be00a75a9",
|
|
41
|
+
"@webiny/handler-db": "0.0.0-unstable.7be00a75a9",
|
|
42
|
+
"@webiny/plugins": "0.0.0-unstable.7be00a75a9",
|
|
43
|
+
"@webiny/utils": "0.0.0-unstable.7be00a75a9",
|
|
40
44
|
"dataloader": "2.2.3",
|
|
41
|
-
"lodash": "4.
|
|
45
|
+
"lodash": "4.18.1"
|
|
42
46
|
},
|
|
43
47
|
"devDependencies": {
|
|
44
|
-
"@elastic/elasticsearch": "7.12.0",
|
|
45
48
|
"@types/jsonpack": "1.1.6",
|
|
46
|
-
"@webiny/api-core": "0.0.0-unstable.
|
|
47
|
-
"@webiny/api-dynamodb-to-elasticsearch": "0.0.0-unstable.
|
|
48
|
-
"@webiny/build-tools": "0.0.0-unstable.
|
|
49
|
-
"@webiny/
|
|
50
|
-
"@webiny/handler
|
|
51
|
-
"@webiny/handler-
|
|
52
|
-
"@webiny/
|
|
53
|
-
"@webiny/
|
|
54
|
-
"@webiny/
|
|
49
|
+
"@webiny/api-core": "0.0.0-unstable.7be00a75a9",
|
|
50
|
+
"@webiny/api-dynamodb-to-elasticsearch": "0.0.0-unstable.7be00a75a9",
|
|
51
|
+
"@webiny/build-tools": "0.0.0-unstable.7be00a75a9",
|
|
52
|
+
"@webiny/di": "0.0.0-unstable.7be00a75a9",
|
|
53
|
+
"@webiny/handler": "0.0.0-unstable.7be00a75a9",
|
|
54
|
+
"@webiny/handler-aws": "0.0.0-unstable.7be00a75a9",
|
|
55
|
+
"@webiny/handler-graphql": "0.0.0-unstable.7be00a75a9",
|
|
56
|
+
"@webiny/project-utils": "0.0.0-unstable.7be00a75a9",
|
|
57
|
+
"@webiny/tasks": "0.0.0-unstable.7be00a75a9",
|
|
58
|
+
"@webiny/wcp": "0.0.0-unstable.7be00a75a9",
|
|
55
59
|
"jest-dynalite": "3.6.1",
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"vitest": "3.2.4"
|
|
60
|
+
"rimraf": "6.1.3",
|
|
61
|
+
"typescript": "6.0.3",
|
|
62
|
+
"vitest": "4.1.7"
|
|
60
63
|
},
|
|
61
64
|
"publishConfig": {
|
|
62
|
-
"access": "public"
|
|
63
|
-
"directory": "dist"
|
|
65
|
+
"access": "public"
|
|
64
66
|
},
|
|
65
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "b8aec8a1be3f25c3b428b357fe1e352c7cbff9ae",
|
|
68
|
+
"webiny": {
|
|
69
|
+
"publishFrom": "dist"
|
|
70
|
+
}
|
|
66
71
|
}
|
|
@@ -1,41 +1,45 @@
|
|
|
1
1
|
import { OpensearchTenantIndexFactory } from "@webiny/api-elasticsearch-tasks";
|
|
2
2
|
import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
|
|
3
3
|
import { configurations } from "../configurations.js";
|
|
4
|
+
import { CmsEntryOpenSearchIndex } from "../features/CmsEntryOpenSearchIndex/index.js";
|
|
4
5
|
class CreateElasticsearchIndexTask {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
constructor(context, listModels){
|
|
7
|
+
this.context = context;
|
|
8
|
+
this.listModels = listModels;
|
|
9
|
+
}
|
|
10
|
+
async getIndexList(tenant) {
|
|
11
|
+
const result = await this.listModels.execute();
|
|
12
|
+
const models = result.value;
|
|
13
|
+
if (0 === models.length) return [];
|
|
14
|
+
const indexConfigs = this.context.container.resolveAll(CmsEntryOpenSearchIndex);
|
|
15
|
+
const indexes = models.map((model)=>{
|
|
16
|
+
const { index } = configurations.es({
|
|
17
|
+
model: {
|
|
18
|
+
modelId: model.modelId,
|
|
19
|
+
tenant: tenant.id
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
index,
|
|
24
|
+
settings: configurations.indexSettings({
|
|
25
|
+
indexConfigs,
|
|
26
|
+
model: {
|
|
27
|
+
modelId: model.modelId,
|
|
28
|
+
tenant: tenant.id,
|
|
29
|
+
group: model.group
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
return indexes;
|
|
14
35
|
}
|
|
15
|
-
const indexes = models.map(model => {
|
|
16
|
-
const {
|
|
17
|
-
index
|
|
18
|
-
} = configurations.es({
|
|
19
|
-
model: {
|
|
20
|
-
modelId: model.modelId,
|
|
21
|
-
tenant: tenant.id
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
return {
|
|
25
|
-
index,
|
|
26
|
-
settings: configurations.indexSettings({
|
|
27
|
-
context: this.context
|
|
28
|
-
})
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
return indexes;
|
|
32
|
-
}
|
|
33
36
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const createCreateIndexTask = (context)=>{
|
|
38
|
+
context.container.registerFactory(OpensearchTenantIndexFactory, ()=>{
|
|
39
|
+
const listModels = context.container.resolve(ListModelsUseCase);
|
|
40
|
+
return new CreateElasticsearchIndexTask(context, listModels);
|
|
41
|
+
});
|
|
39
42
|
};
|
|
43
|
+
export { createCreateIndexTask };
|
|
40
44
|
|
|
41
45
|
//# sourceMappingURL=createIndexTaskPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"tasks/createIndexTaskPlugin.js","sources":["../../src/tasks/createIndexTaskPlugin.ts"],"sourcesContent":["import { OpensearchTenantIndexFactory } from \"@webiny/api-elasticsearch-tasks\";\nimport type { Tenant } from \"@webiny/api-core/types/tenancy.js\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels/index.js\";\nimport { configurations } from \"~/configurations.js\";\nimport type { CmsContext } from \"~/types.js\";\nimport { CmsEntryOpenSearchIndex } from \"~/features/CmsEntryOpenSearchIndex/index.js\";\n\nclass CreateElasticsearchIndexTask implements OpensearchTenantIndexFactory.Interface {\n constructor(\n private context: CmsContext,\n private listModels: ListModelsUseCase.Interface\n ) {}\n\n async getIndexList(tenant: Tenant): Promise<OpensearchTenantIndexFactory.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 indexConfigs = this.context.container.resolveAll(CmsEntryOpenSearchIndex);\n\n const indexes = models.map<OpensearchTenantIndexFactory.IndexConfig>(model => {\n const { index } = configurations.es({\n model: {\n modelId: model.modelId,\n tenant: tenant.id\n }\n });\n return {\n index,\n settings: configurations.indexSettings({\n indexConfigs,\n model: {\n modelId: model.modelId,\n tenant: tenant.id,\n group: model.group\n }\n })\n };\n });\n\n return indexes;\n }\n}\n\nexport const createCreateIndexTask = (context: CmsContext) => {\n context.container.registerFactory(OpensearchTenantIndexFactory, () => {\n const listModels = context.container.resolve(ListModelsUseCase);\n return new CreateElasticsearchIndexTask(context, listModels);\n });\n};\n"],"names":["CreateElasticsearchIndexTask","context","listModels","tenant","result","models","indexConfigs","CmsEntryOpenSearchIndex","indexes","model","index","configurations","createCreateIndexTask","OpensearchTenantIndexFactory","ListModelsUseCase"],"mappings":";;;;AAOA,MAAMA;IACF,YACYC,OAAmB,EACnBC,UAAuC,CACjD;aAFUD,OAAO,GAAPA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,aAAaC,MAAc,EAAuD;QACpF,MAAMC,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO;QAC5C,MAAMC,SAASD,OAAO,KAAK;QAE3B,IAAIC,AAAkB,MAAlBA,OAAO,MAAM,EACb,OAAO,EAAE;QAGb,MAAMC,eAAe,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,CAACC;QAEvD,MAAMC,UAAUH,OAAO,GAAG,CAA2CI,CAAAA;YACjE,MAAM,EAAEC,KAAK,EAAE,GAAGC,eAAe,EAAE,CAAC;gBAChC,OAAO;oBACH,SAASF,MAAM,OAAO;oBACtB,QAAQN,OAAO,EAAE;gBACrB;YACJ;YACA,OAAO;gBACHO;gBACA,UAAUC,eAAe,aAAa,CAAC;oBACnCL;oBACA,OAAO;wBACH,SAASG,MAAM,OAAO;wBACtB,QAAQN,OAAO,EAAE;wBACjB,OAAOM,MAAM,KAAK;oBACtB;gBACJ;YACJ;QACJ;QAEA,OAAOD;IACX;AACJ;AAEO,MAAMI,wBAAwB,CAACX;IAClCA,QAAQ,SAAS,CAAC,eAAe,CAACY,8BAA8B;QAC5D,MAAMX,aAAaD,QAAQ,SAAS,CAAC,OAAO,CAACa;QAC7C,OAAO,IAAId,6BAA6BC,SAASC;IACrD;AACJ"}
|