@webiny/api-headless-cms-ddb-es 0.0.0-unstable.b14eaecf38 → 0.0.0-unstable.b6d7105cee
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/README.md +6 -30
- package/configurations.d.ts +20 -10
- package/configurations.js +34 -32
- package/configurations.js.map +1 -1
- package/definitions/entry.d.ts +4 -5
- package/definitions/entry.js +10 -87
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +6 -6
- package/definitions/group.js +10 -64
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +6 -6
- package/definitions/model.js +10 -108
- package/definitions/model.js.map +1 -1
- package/definitions/types.d.ts +65 -0
- package/definitions/types.js +0 -0
- package/elasticsearch/createElasticsearchIndex.d.ts +6 -6
- package/elasticsearch/createElasticsearchIndex.js +42 -46
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/elasticsearch/deleteElasticsearchIndex.d.ts +6 -4
- package/elasticsearch/deleteElasticsearchIndex.js +21 -34
- 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 +201 -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/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/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.d.ts +25 -0
- package/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js +36 -0
- package/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js.map +1 -0
- package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndex.d.ts +8 -0
- package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndex.js +17 -0
- package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndex.js.map +1 -0
- package/features/CmsModelOpenSearchIndex/abstractions.d.ts +20 -0
- package/features/CmsModelOpenSearchIndex/abstractions.js +5 -0
- package/features/CmsModelOpenSearchIndex/abstractions.js.map +1 -0
- package/features/CmsModelOpenSearchIndex/feature.d.ts +4 -0
- package/features/CmsModelOpenSearchIndex/feature.js +13 -0
- package/features/CmsModelOpenSearchIndex/feature.js.map +1 -0
- package/features/CmsModelOpenSearchIndex/index.d.ts +3 -0
- package/features/CmsModelOpenSearchIndex/index.js +3 -0
- package/helpers/entryIndexHelpers.d.ts +13 -11
- package/helpers/entryIndexHelpers.js +73 -168
- package/helpers/entryIndexHelpers.js.map +1 -1
- package/helpers/fieldIdentifier.d.ts +6 -0
- package/helpers/fieldIdentifier.js +23 -0
- package/helpers/fieldIdentifier.js.map +1 -0
- package/helpers/index.d.ts +2 -1
- package/helpers/index.js +2 -16
- package/index.d.ts +1 -3
- package/index.js +1 -215
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +16 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +27 -0
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
- package/operations/entry/dataLoader/constants.d.ts +1 -0
- package/operations/entry/dataLoader/constants.js +5 -0
- package/operations/entry/dataLoader/constants.js.map +1 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js +10 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js +24 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +34 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +34 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
- package/operations/entry/dataLoader/getRevisionById.js +40 -0
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
- package/operations/entry/dataLoader/index.d.ts +8 -0
- package/operations/entry/dataLoader/index.js +18 -0
- package/operations/entry/dataLoader/index.js.map +1 -0
- package/operations/entry/dataLoader/types.d.ts +6 -0
- package/operations/entry/dataLoader/types.js +0 -0
- package/operations/entry/dataLoaders.d.ts +17 -38
- package/operations/entry/dataLoaders.js +83 -306
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +8 -31
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
- package/operations/entry/elasticsearch/body.d.ts +25 -6
- package/operations/entry/elasticsearch/body.js +85 -136
- 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 +8 -6
- package/operations/entry/elasticsearch/fields.js +202 -256
- 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 +37 -55
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/exec.d.ts +13 -8
- package/operations/entry/elasticsearch/filtering/exec.js +93 -169
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/index.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/index.js +1 -16
- package/operations/entry/elasticsearch/filtering/path.d.ts +5 -3
- package/operations/entry/elasticsearch/filtering/path.js +26 -43
- 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 +10 -21
- package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/values.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/values.js +13 -20
- 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 +47 -85
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +4 -4
- package/operations/entry/elasticsearch/fullTextSearchFields.js +9 -24
- package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
- package/operations/entry/elasticsearch/initialQuery.d.ts +5 -4
- package/operations/entry/elasticsearch/initialQuery.js +38 -98
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
- package/operations/entry/elasticsearch/keyword.d.ts +1 -1
- package/operations/entry/elasticsearch/keyword.js +16 -33
- package/operations/entry/elasticsearch/keyword.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/operator.d.ts +4 -5
- package/operations/entry/elasticsearch/plugins/operator.js +9 -36
- package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.d.ts +2 -0
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +8 -0
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -0
- package/operations/entry/elasticsearch/sort.d.ts +9 -6
- package/operations/entry/elasticsearch/sort.js +76 -77
- package/operations/entry/elasticsearch/sort.js.map +1 -1
- package/operations/entry/elasticsearch/transformValueForSearch.d.ts +3 -10
- package/operations/entry/elasticsearch/transformValueForSearch.js +11 -29
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
- package/operations/entry/elasticsearch/types.d.ts +6 -16
- package/operations/entry/elasticsearch/types.js +0 -5
- package/operations/entry/index.d.ts +33 -6
- package/operations/entry/index.js +1348 -1138
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.d.ts +31 -1
- package/operations/entry/keys.js +46 -27
- package/operations/entry/keys.js.map +1 -1
- package/operations/entry/recordType.js +5 -17
- package/operations/entry/recordType.js.map +1 -1
- package/operations/entry/transformations/convertEntryKeys.d.ts +8 -0
- package/operations/entry/transformations/convertEntryKeys.js +25 -0
- package/operations/entry/transformations/convertEntryKeys.js.map +1 -0
- package/operations/entry/transformations/index.d.ts +33 -0
- package/operations/entry/transformations/index.js +91 -0
- package/operations/entry/transformations/index.js.map +1 -0
- package/operations/entry/transformations/modifyEntryValues.d.ts +53 -0
- package/operations/entry/transformations/modifyEntryValues.js +16 -0
- package/operations/entry/transformations/modifyEntryValues.js.map +1 -0
- package/operations/entry/transformations/transformEntryKeys.d.ts +11 -0
- package/operations/entry/transformations/transformEntryKeys.js +17 -0
- package/operations/entry/transformations/transformEntryKeys.js.map +1 -0
- package/operations/entry/transformations/transformEntryToIndex.d.ts +10 -0
- package/operations/entry/transformations/transformEntryToIndex.js +20 -0
- package/operations/entry/transformations/transformEntryToIndex.js.map +1 -0
- package/operations/group/index.d.ts +7 -6
- package/operations/group/index.js +117 -161
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +6 -4
- package/operations/model/index.js +115 -167
- package/operations/model/index.js.map +1 -1
- package/package.json +44 -48
- package/tasks/CreateElasticsearchIndexTask.d.ts +14 -0
- package/tasks/CreateElasticsearchIndexTask.js +40 -0
- package/tasks/CreateElasticsearchIndexTask.js.map +1 -0
- package/types.d.ts +31 -137
- package/types.js +9 -41
- package/types.js.map +1 -1
- package/values/NoValueContainer.d.ts +5 -0
- package/values/NoValueContainer.js +11 -0
- package/values/NoValueContainer.js.map +1 -0
- package/definitions/entryElasticsearch.d.ts +0 -8
- package/definitions/entryElasticsearch.js +0 -37
- package/definitions/entryElasticsearch.js.map +0 -1
- package/definitions/settings.d.ts +0 -8
- package/definitions/settings.js +0 -53
- package/definitions/settings.js.map +0 -1
- package/definitions/system.d.ts +0 -8
- package/definitions/system.js +0 -41
- package/definitions/system.js.map +0 -1
- package/definitions/table.d.ts +0 -8
- package/definitions/table.js +0 -21
- package/definitions/table.js.map +0 -1
- package/definitions/tableElasticsearch.d.ts +0 -8
- package/definitions/tableElasticsearch.js +0 -21
- package/definitions/tableElasticsearch.js.map +0 -1
- package/dynamoDb/index.d.ts +0 -2
- package/dynamoDb/index.js +0 -11
- package/dynamoDb/index.js.map +0 -1
- package/dynamoDb/storage/date.d.ts +0 -3
- package/dynamoDb/storage/date.js +0 -86
- package/dynamoDb/storage/date.js.map +0 -1
- package/dynamoDb/storage/longText.d.ts +0 -10
- package/dynamoDb/storage/longText.js +0 -93
- package/dynamoDb/storage/longText.js.map +0 -1
- package/dynamoDb/storage/richText.d.ts +0 -7
- package/dynamoDb/storage/richText.js +0 -110
- package/dynamoDb/storage/richText.js.map +0 -1
- package/elasticsearch/index.d.ts +0 -2
- package/elasticsearch/index.js +0 -11
- package/elasticsearch/index.js.map +0 -1
- package/elasticsearch/indexing/dateTimeIndexing.d.ts +0 -3
- package/elasticsearch/indexing/dateTimeIndexing.js +0 -86
- package/elasticsearch/indexing/dateTimeIndexing.js.map +0 -1
- package/elasticsearch/indexing/defaultFieldIndexing.d.ts +0 -3
- package/elasticsearch/indexing/defaultFieldIndexing.js +0 -52
- package/elasticsearch/indexing/defaultFieldIndexing.js.map +0 -1
- package/elasticsearch/indexing/index.d.ts +0 -2
- package/elasticsearch/indexing/index.js +0 -15
- package/elasticsearch/indexing/index.js.map +0 -1
- package/elasticsearch/indexing/longTextIndexing.d.ts +0 -7
- package/elasticsearch/indexing/longTextIndexing.js +0 -40
- package/elasticsearch/indexing/longTextIndexing.js.map +0 -1
- package/elasticsearch/indexing/numberIndexing.d.ts +0 -3
- package/elasticsearch/indexing/numberIndexing.js +0 -39
- package/elasticsearch/indexing/numberIndexing.js.map +0 -1
- package/elasticsearch/indexing/objectIndexing.d.ts +0 -12
- package/elasticsearch/indexing/objectIndexing.js +0 -196
- package/elasticsearch/indexing/objectIndexing.js.map +0 -1
- package/elasticsearch/indexing/richTextIndexing.d.ts +0 -3
- package/elasticsearch/indexing/richTextIndexing.js +0 -29
- package/elasticsearch/indexing/richTextIndexing.js.map +0 -1
- package/elasticsearch/indices/base.d.ts +0 -2
- package/elasticsearch/indices/base.js +0 -12
- package/elasticsearch/indices/base.js.map +0 -1
- package/elasticsearch/indices/index.d.ts +0 -1
- package/elasticsearch/indices/index.js +0 -12
- package/elasticsearch/indices/index.js.map +0 -1
- package/elasticsearch/indices/japanese.d.ts +0 -2
- package/elasticsearch/indices/japanese.js +0 -13
- package/elasticsearch/indices/japanese.js.map +0 -1
- package/elasticsearch/search/index.d.ts +0 -3
- package/elasticsearch/search/index.js +0 -10
- package/elasticsearch/search/index.js.map +0 -1
- package/elasticsearch/search/refSearch.d.ts +0 -2
- package/elasticsearch/search/refSearch.js +0 -29
- package/elasticsearch/search/refSearch.js.map +0 -1
- package/elasticsearch/search/timeSearch.d.ts +0 -2
- package/elasticsearch/search/timeSearch.js +0 -26
- package/elasticsearch/search/timeSearch.js.map +0 -1
- package/helpers/index.js.map +0 -1
- package/index.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 -28
- 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 -13
- 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 -65
- 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 -48
- 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 -16
- 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 -16
- 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 -24
- 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 -16
- package/operations/entry/elasticsearch/plugins/sortModifier.js.map +0 -1
- package/operations/entry/elasticsearch/types.js.map +0 -1
- package/operations/settings/index.d.ts +0 -6
- package/operations/settings/index.js +0 -111
- package/operations/settings/index.js.map +0 -1
- package/operations/system/index.d.ts +0 -6
- package/operations/system/index.js +0 -82
- package/operations/system/index.js.map +0 -1
- package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +0 -69
- package/plugins/CmsElasticsearchModelFieldPlugin.js +0 -48
- package/plugins/CmsElasticsearchModelFieldPlugin.js.map +0 -1
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +0 -21
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +0 -22
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +0 -1
- package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +0 -12
- package/plugins/CmsEntryElasticsearchFieldPlugin.js +0 -24
- package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +0 -1
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +0 -23
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +0 -28
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +0 -1
- package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +0 -4
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +0 -12
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +0 -1
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +0 -31
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +0 -37
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +0 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +0 -18
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +0 -22
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +0 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +0 -18
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +0 -22
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +0 -1
- package/plugins/CmsEntryFilterPlugin.d.ts +0 -49
- package/plugins/CmsEntryFilterPlugin.js +0 -24
- package/plugins/CmsEntryFilterPlugin.js.map +0 -1
- package/plugins/index.d.ts +0 -7
- package/plugins/index.js +0 -82
- package/plugins/index.js.map +0 -1
|
@@ -1,175 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
|
-
const prepareEntryToIndex = params => {
|
|
11
|
-
const {
|
|
12
|
-
plugins,
|
|
13
|
-
storageEntry,
|
|
14
|
-
entry,
|
|
15
|
-
model
|
|
16
|
-
} = params;
|
|
17
|
-
const {
|
|
18
|
-
fieldIndexPlugins,
|
|
19
|
-
defaultIndexFieldPlugin,
|
|
20
|
-
fieldTypePlugins
|
|
21
|
-
} = setupEntriesIndexHelpers({
|
|
22
|
-
plugins
|
|
23
|
-
});
|
|
24
|
-
function getFieldIndexPlugin(fieldType) {
|
|
25
|
-
return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;
|
|
26
|
-
}
|
|
27
|
-
function getFieldTypePlugin(fieldType) {
|
|
28
|
-
const pl = fieldTypePlugins[fieldType];
|
|
29
|
-
if (pl) {
|
|
30
|
-
return pl;
|
|
31
|
-
}
|
|
32
|
-
throw new _error.default(`Missing field type plugin "${fieldType}". Prepare entry for index.`);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// These objects will contain values processed by field index plugins
|
|
36
|
-
const values = {};
|
|
37
|
-
const rawValues = {};
|
|
38
|
-
|
|
39
|
-
// We're only interested in current model fields.
|
|
40
|
-
for (const field of model.fields) {
|
|
41
|
-
if (storageEntry.values.hasOwnProperty(field.storageId) === false) {
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
const targetFieldPlugin = getFieldIndexPlugin(field.type);
|
|
45
|
-
|
|
46
|
-
// TODO: remove this `if` once we convert this plugin to proper plugin class
|
|
47
|
-
if (!targetFieldPlugin || !targetFieldPlugin.toIndex) {
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
const {
|
|
51
|
-
value,
|
|
52
|
-
rawValue
|
|
53
|
-
} = targetFieldPlugin.toIndex({
|
|
54
|
-
plugins,
|
|
55
|
-
model,
|
|
56
|
-
field,
|
|
57
|
-
rawValue: entry.values[field.storageId],
|
|
58
|
-
value: storageEntry.values[field.storageId],
|
|
59
|
-
getFieldIndexPlugin,
|
|
60
|
-
getFieldTypePlugin
|
|
61
|
-
});
|
|
62
|
-
if (typeof value !== "undefined") {
|
|
63
|
-
values[field.storageId] = value;
|
|
1
|
+
import { WebinyError } from "@webiny/error";
|
|
2
|
+
import { getFieldIdentifier, getFieldIdentifiers } from "./fieldIdentifier.js";
|
|
3
|
+
const prepareEntryToIndex = (params)=>{
|
|
4
|
+
const { fieldIndexRegistry, storageEntry, entry, model } = params;
|
|
5
|
+
function getFieldIndex(type) {
|
|
6
|
+
const fieldIndexing = fieldIndexRegistry.get(type);
|
|
7
|
+
if (fieldIndexing) return fieldIndexing;
|
|
8
|
+
return fieldIndexRegistry.getDefault();
|
|
64
9
|
}
|
|
65
|
-
|
|
66
|
-
|
|
10
|
+
const values = {};
|
|
11
|
+
const rawValues = {};
|
|
12
|
+
for (const field of model.fields){
|
|
13
|
+
const identifier = getFieldIdentifier(storageEntry.values, field);
|
|
14
|
+
if (!identifier) continue;
|
|
15
|
+
const fieldIndex = getFieldIndex(field.type);
|
|
16
|
+
const { value, rawValue } = fieldIndex.toIndex({
|
|
17
|
+
model,
|
|
18
|
+
field,
|
|
19
|
+
rawValue: entry.values[identifier],
|
|
20
|
+
value: storageEntry.values[identifier],
|
|
21
|
+
getFieldIndex
|
|
22
|
+
});
|
|
23
|
+
if (void 0 !== value) values[identifier] = value;
|
|
24
|
+
if (void 0 !== rawValue) rawValues[identifier] = rawValue;
|
|
67
25
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
26
|
+
return {
|
|
27
|
+
...storageEntry,
|
|
28
|
+
values,
|
|
29
|
+
rawValues
|
|
30
|
+
};
|
|
73
31
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const fieldIndexPlugins = {};
|
|
80
|
-
for (const plugin of plugins.reverse()) {
|
|
81
|
-
if (fieldIndexPlugins[plugin.fieldType]) {
|
|
82
|
-
continue;
|
|
32
|
+
const extractEntriesFromIndex = ({ fieldRegistry, fieldIndexRegistry, entries, model })=>{
|
|
33
|
+
function getFieldIndex(type) {
|
|
34
|
+
const fieldIndex = fieldIndexRegistry.get(type);
|
|
35
|
+
if (fieldIndex) return fieldIndex;
|
|
36
|
+
return fieldIndexRegistry.getDefault();
|
|
83
37
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
const indexValues = {};
|
|
121
|
-
|
|
122
|
-
// We only consider fields that are present in the model
|
|
123
|
-
for (const field of model.fields) {
|
|
124
|
-
const fieldTypePlugin = fieldTypePlugins[field.type];
|
|
125
|
-
if (!fieldTypePlugin) {
|
|
126
|
-
throw new _error.default(`Missing field type plugin "${field.type}". Extract entries from index.`);
|
|
127
|
-
}
|
|
128
|
-
const targetFieldPlugin = getFieldIndexPlugin(field.type);
|
|
129
|
-
if (!targetFieldPlugin || !targetFieldPlugin.fromIndex) {
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
try {
|
|
133
|
-
indexValues[field.storageId] = targetFieldPlugin.fromIndex({
|
|
134
|
-
plugins,
|
|
135
|
-
model,
|
|
136
|
-
field,
|
|
137
|
-
getFieldIndexPlugin,
|
|
138
|
-
getFieldTypePlugin,
|
|
139
|
-
value: entry.values[field.storageId],
|
|
140
|
-
/**
|
|
141
|
-
* Possibly no rawValues so we must check for the existence of the field.
|
|
142
|
-
*/
|
|
143
|
-
rawValue: entry.rawValues ? entry.rawValues[field.storageId] : null
|
|
144
|
-
});
|
|
145
|
-
} catch (ex) {
|
|
146
|
-
throw new _error.default(ex.message || "Could not transform entry field from index.", ex.code || "FIELD_FROM_INDEX_ERROR", {
|
|
147
|
-
field,
|
|
148
|
-
entry
|
|
38
|
+
const list = [];
|
|
39
|
+
for (const entry of entries){
|
|
40
|
+
const indexValues = {};
|
|
41
|
+
for (const field of model.fields){
|
|
42
|
+
const fieldType = fieldRegistry.get(field.type);
|
|
43
|
+
if (!fieldType) throw new WebinyError(`Missing field type "${field.type}". Extract entries from index.`);
|
|
44
|
+
const fieldIndex = getFieldIndex(field.type);
|
|
45
|
+
const identifiers = getFieldIdentifiers(entry.values, entry.rawValues, field);
|
|
46
|
+
if (identifiers) try {
|
|
47
|
+
const key = identifiers.valueIdentifier;
|
|
48
|
+
const rawKey = identifiers.rawValueIdentifier;
|
|
49
|
+
indexValues[key] = fieldIndex.fromIndex({
|
|
50
|
+
model,
|
|
51
|
+
field,
|
|
52
|
+
getFieldIndex,
|
|
53
|
+
value: entry.values[key || rawKey],
|
|
54
|
+
rawValue: entry.rawValues ? entry.rawValues[rawKey || key] : null
|
|
55
|
+
});
|
|
56
|
+
} catch (ex) {
|
|
57
|
+
throw new WebinyError(ex.message || "Could not transform entry field from index.", ex.code || "FIELD_FROM_INDEX_ERROR", {
|
|
58
|
+
field,
|
|
59
|
+
entry
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const newEntry = {
|
|
64
|
+
...entry,
|
|
65
|
+
values: indexValues
|
|
66
|
+
};
|
|
67
|
+
delete newEntry["rawValues"];
|
|
68
|
+
delete newEntry["TYPE"];
|
|
69
|
+
delete newEntry["__type"];
|
|
70
|
+
delete newEntry["latest"];
|
|
71
|
+
delete newEntry["published"];
|
|
72
|
+
list.push({
|
|
73
|
+
...newEntry
|
|
149
74
|
});
|
|
150
|
-
}
|
|
151
75
|
}
|
|
152
|
-
|
|
153
|
-
* Let's have a new entry so we do not modify the original one.
|
|
154
|
-
*/
|
|
155
|
-
const newEntry = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
|
|
156
|
-
values: indexValues
|
|
157
|
-
});
|
|
158
|
-
/**
|
|
159
|
-
* If we want to remove the rawValues, TYPE, latest, published and __type, we must make them optional or ignore them.
|
|
160
|
-
*/
|
|
161
|
-
// @ts-ignore
|
|
162
|
-
delete newEntry["rawValues"];
|
|
163
|
-
// @ts-ignore
|
|
164
|
-
delete newEntry["TYPE"];
|
|
165
|
-
// @ts-ignore
|
|
166
|
-
delete newEntry["__type"];
|
|
167
|
-
// @ts-ignore
|
|
168
|
-
delete newEntry["latest"];
|
|
169
|
-
// @ts-ignore
|
|
170
|
-
delete newEntry["published"];
|
|
171
|
-
list.push((0, _objectSpread2.default)({}, newEntry));
|
|
172
|
-
}
|
|
173
|
-
return list;
|
|
76
|
+
return list;
|
|
174
77
|
};
|
|
175
|
-
|
|
78
|
+
export { extractEntriesFromIndex, prepareEntryToIndex };
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=entryIndexHelpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["prepareEntryToIndex","params","plugins","storageEntry","entry","model","fieldIndexPlugins","defaultIndexFieldPlugin","fieldTypePlugins","setupEntriesIndexHelpers","getFieldIndexPlugin","fieldType","getFieldTypePlugin","pl","WebinyError","values","rawValues","field","fields","hasOwnProperty","storageId","targetFieldPlugin","type","toIndex","value","rawValue","pluginsContainer","byType","plugin","reverse","find","reduce","extractEntriesFromIndex","entries","list","indexValues","fieldTypePlugin","fromIndex","ex","message","code","newEntry","push"],"sources":["entryIndexHelpers.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntry, CmsModel, CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\nimport { CmsIndexEntry, CmsModelFieldToElasticsearchPlugin } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\ninterface SetupEntriesIndexHelpersParams {\n plugins: PluginsContainer;\n}\n\ninterface ExtractEntriesFromIndexParams extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entries: CmsIndexEntry[];\n}\n\ninterface PrepareElasticsearchDataParams extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entry: CmsEntry;\n storageEntry: CmsEntry;\n}\n\nexport const prepareEntryToIndex = (params: PrepareElasticsearchDataParams): CmsIndexEntry => {\n const { plugins, storageEntry, entry, model } = params;\n const { fieldIndexPlugins, defaultIndexFieldPlugin, fieldTypePlugins } =\n setupEntriesIndexHelpers({ plugins });\n\n function getFieldIndexPlugin(fieldType: string) {\n return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;\n }\n\n function getFieldTypePlugin(fieldType: string) {\n const pl = fieldTypePlugins[fieldType];\n if (pl) {\n return pl;\n }\n throw new WebinyError(`Missing field type plugin \"${fieldType}\". Prepare entry for index.`);\n }\n\n // These objects will contain values processed by field index plugins\n const values: Record<string, string> = {};\n const rawValues: Record<string, string> = {};\n\n // We're only interested in current model fields.\n for (const field of model.fields) {\n if (storageEntry.values.hasOwnProperty(field.storageId) === false) {\n continue;\n }\n\n const targetFieldPlugin = getFieldIndexPlugin(field.type);\n\n // TODO: remove this `if` once we convert this plugin to proper plugin class\n if (!targetFieldPlugin || !targetFieldPlugin.toIndex) {\n continue;\n }\n\n const { value, rawValue } = targetFieldPlugin.toIndex({\n plugins,\n model,\n field,\n rawValue: entry.values[field.storageId],\n value: storageEntry.values[field.storageId],\n getFieldIndexPlugin,\n getFieldTypePlugin\n });\n\n if (typeof value !== \"undefined\") {\n values[field.storageId] = value;\n }\n\n if (typeof rawValue !== \"undefined\") {\n rawValues[field.storageId] = rawValue;\n }\n }\n return {\n ...storageEntry,\n values,\n rawValues\n } as CmsIndexEntry;\n};\n\nconst setupEntriesIndexHelpers = ({\n plugins: pluginsContainer\n}: SetupEntriesIndexHelpersParams) => {\n const plugins = pluginsContainer.byType<CmsModelFieldToElasticsearchPlugin>(\n \"cms-model-field-to-elastic-search\"\n );\n\n const fieldIndexPlugins: Record<string, CmsModelFieldToElasticsearchPlugin> = {};\n for (const plugin of plugins.reverse()) {\n if (fieldIndexPlugins[plugin.fieldType]) {\n continue;\n }\n fieldIndexPlugins[plugin.fieldType] = plugin;\n }\n // we will use this plugin if no targeted plugin found\n const defaultIndexFieldPlugin = plugins.find(plugin => plugin.fieldType === \"*\");\n\n // CmsModelFieldToGraphQLPlugin plugins\n const fieldTypePlugins: Record<string, CmsModelFieldToGraphQLPlugin> = pluginsContainer\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce((plugins, plugin) => ({ ...plugins, [plugin.fieldType]: plugin }), {});\n\n return {\n fieldIndexPlugins,\n defaultIndexFieldPlugin,\n fieldTypePlugins\n };\n};\n\nexport const extractEntriesFromIndex = ({\n plugins,\n entries,\n model\n}: ExtractEntriesFromIndexParams): CmsEntry[] => {\n const { fieldIndexPlugins, defaultIndexFieldPlugin, fieldTypePlugins } =\n setupEntriesIndexHelpers({ plugins });\n\n function getFieldIndexPlugin(fieldType: string) {\n return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;\n }\n\n function getFieldTypePlugin(fieldType: string) {\n return fieldTypePlugins[fieldType];\n }\n\n const list: CmsEntry[] = [];\n\n for (const entry of entries) {\n // This object will contain values processed by field index plugins\n const indexValues: Record<string, string> = {};\n\n // We only consider fields that are present in the model\n for (const field of model.fields) {\n const fieldTypePlugin = fieldTypePlugins[field.type];\n if (!fieldTypePlugin) {\n throw new WebinyError(\n `Missing field type plugin \"${field.type}\". Extract entries from index.`\n );\n }\n\n const targetFieldPlugin = getFieldIndexPlugin(field.type);\n if (!targetFieldPlugin || !targetFieldPlugin.fromIndex) {\n continue;\n }\n try {\n indexValues[field.storageId] = targetFieldPlugin.fromIndex({\n plugins,\n model,\n field,\n getFieldIndexPlugin,\n getFieldTypePlugin,\n value: entry.values[field.storageId],\n /**\n * Possibly no rawValues so we must check for the existence of the field.\n */\n rawValue: entry.rawValues ? entry.rawValues[field.storageId] : null\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not transform entry field from index.\",\n ex.code || \"FIELD_FROM_INDEX_ERROR\",\n {\n field,\n entry\n }\n );\n }\n }\n /**\n * Let's have a new entry so we do not modify the original one.\n */\n const newEntry: CmsEntry = {\n ...entry,\n values: indexValues\n };\n /**\n * If we want to remove the rawValues, TYPE, latest, published and __type, we must make them optional or ignore them.\n */\n // @ts-ignore\n delete newEntry[\"rawValues\"];\n // @ts-ignore\n delete newEntry[\"TYPE\"];\n // @ts-ignore\n delete newEntry[\"__type\"];\n // @ts-ignore\n delete newEntry[\"latest\"];\n // @ts-ignore\n delete newEntry[\"published\"];\n list.push({ ...newEntry });\n }\n\n return list;\n};\n"],"mappings":";;;;;;;;AAAA;AAoBO,MAAMA,mBAAmB,GAAIC,MAAsC,IAAoB;EAC1F,MAAM;IAAEC,OAAO;IAAEC,YAAY;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGJ,MAAM;EACtD,MAAM;IAAEK,iBAAiB;IAAEC,uBAAuB;IAAEC;EAAiB,CAAC,GAClEC,wBAAwB,CAAC;IAAEP;EAAQ,CAAC,CAAC;EAEzC,SAASQ,mBAAmB,CAACC,SAAiB,EAAE;IAC5C,OAAOL,iBAAiB,CAACK,SAAS,CAAC,IAAIJ,uBAAuB;EAClE;EAEA,SAASK,kBAAkB,CAACD,SAAiB,EAAE;IAC3C,MAAME,EAAE,GAAGL,gBAAgB,CAACG,SAAS,CAAC;IACtC,IAAIE,EAAE,EAAE;MACJ,OAAOA,EAAE;IACb;IACA,MAAM,IAAIC,cAAW,CAAE,8BAA6BH,SAAU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|
|
1
|
+
{"version":3,"file":"helpers/entryIndexHelpers.js","sources":["../../src/helpers/entryIndexHelpers.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport type { CmsEntry, CmsEntryValues, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CmsIndexEntry } from \"~/types.js\";\nimport { getFieldIdentifier, getFieldIdentifiers } from \"~/helpers/fieldIdentifier.js\";\nimport type { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport type {\n CmsEntryOpenSearchFieldIndex,\n CmsEntryOpenSearchFieldIndexRegistry\n} from \"~/features/CmsEntryOpenSearchFieldIndex/index.js\";\n\ninterface SetupEntriesIndexHelpersParams {\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface;\n}\n\ninterface ExtractEntriesFromIndexParams<\n T extends CmsEntryValues = CmsEntryValues\n> extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entries: CmsIndexEntry<T>[];\n}\n\ninterface PrepareElasticsearchDataParams<T extends CmsEntryValues = CmsEntryValues> extends Omit<\n SetupEntriesIndexHelpersParams,\n \"fieldRegistry\"\n> {\n model: CmsModel;\n entry: CmsEntry<T>;\n storageEntry: CmsEntry<T>;\n}\n\nexport const prepareEntryToIndex = <T extends CmsEntryValues = CmsEntryValues>(\n params: PrepareElasticsearchDataParams<T>\n): CmsIndexEntry<T> => {\n const { fieldIndexRegistry, storageEntry, entry, model } = params;\n\n function getFieldIndex(type: string): CmsEntryOpenSearchFieldIndex.Interface {\n const fieldIndexing = fieldIndexRegistry.get(type);\n if (fieldIndexing) {\n return fieldIndexing;\n }\n return fieldIndexRegistry.getDefault();\n }\n\n // These objects will contain values processed by field index implementations\n const values: T = {} as T;\n const rawValues: T = {} as T;\n\n // We're only interested in current model fields.\n for (const field of model.fields) {\n const identifier = getFieldIdentifier(storageEntry.values, field) as keyof T;\n if (!identifier) {\n continue;\n }\n\n const fieldIndex = getFieldIndex(field.type);\n\n const { value, rawValue } = fieldIndex.toIndex({\n model,\n field,\n rawValue: entry.values[identifier],\n value: storageEntry.values[identifier],\n getFieldIndex\n });\n\n if (typeof value !== \"undefined\") {\n values[identifier] = value;\n }\n\n if (typeof rawValue !== \"undefined\") {\n rawValues[identifier] = rawValue;\n }\n }\n return {\n ...storageEntry,\n values,\n rawValues\n };\n};\n\nexport const extractEntriesFromIndex = <T extends CmsEntryValues = CmsEntryValues>({\n fieldRegistry,\n fieldIndexRegistry,\n entries,\n model\n}: ExtractEntriesFromIndexParams<T>): CmsEntry<T>[] => {\n function getFieldIndex(type: string): CmsEntryOpenSearchFieldIndex.Interface {\n const fieldIndex = fieldIndexRegistry.get(type);\n if (fieldIndex) {\n return fieldIndex;\n }\n return fieldIndexRegistry.getDefault();\n }\n\n const list: CmsEntry<T>[] = [];\n\n for (const entry of entries) {\n // This object will contain values processed by field index plugins\n const indexValues: T = {} as T;\n\n // We only consider fields that are present in the model\n for (const field of model.fields) {\n const fieldType = fieldRegistry.get(field.type);\n if (!fieldType) {\n throw new WebinyError(\n `Missing field type \"${field.type}\". Extract entries from index.`\n );\n }\n\n const fieldIndex = getFieldIndex(field.type);\n /**\n * We can safely cast as the code will not continue in case of no identifiers.\n */\n const identifiers = getFieldIdentifiers(entry.values, entry.rawValues, field);\n if (!identifiers) {\n continue;\n }\n try {\n const key = identifiers.valueIdentifier as keyof T;\n const rawKey = identifiers.rawValueIdentifier as keyof T;\n indexValues[key] = fieldIndex.fromIndex({\n model,\n field,\n getFieldIndex,\n value: entry.values[key || rawKey],\n /**\n * Possibly no rawValues so we must check for the existence of the field.\n */\n rawValue: entry.rawValues ? entry.rawValues[rawKey || key] : null\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not transform entry field from index.\",\n ex.code || \"FIELD_FROM_INDEX_ERROR\",\n {\n field,\n entry\n }\n );\n }\n }\n /**\n * Let's have a new entry so we do not modify the original one.\n */\n const newEntry: CmsEntry<T> = {\n ...entry,\n values: indexValues\n };\n /**\n * If we want to remove the rawValues, TYPE, latest, published and __type, we must make them optional or ignore them.\n */\n // @ts-expect-error\n delete newEntry[\"rawValues\"];\n // @ts-expect-error\n delete newEntry[\"TYPE\"];\n // @ts-expect-error\n delete newEntry[\"__type\"];\n // @ts-expect-error\n delete newEntry[\"latest\"];\n // @ts-expect-error\n delete newEntry[\"published\"];\n list.push({\n ...newEntry\n });\n }\n\n return list;\n};\n"],"names":["prepareEntryToIndex","params","fieldIndexRegistry","storageEntry","entry","model","getFieldIndex","type","fieldIndexing","values","rawValues","field","identifier","getFieldIdentifier","fieldIndex","value","rawValue","extractEntriesFromIndex","fieldRegistry","entries","list","indexValues","fieldType","WebinyError","identifiers","getFieldIdentifiers","key","rawKey","ex","newEntry"],"mappings":";;AA+BO,MAAMA,sBAAsB,CAC/BC;IAEA,MAAM,EAAEC,kBAAkB,EAAEC,YAAY,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGJ;IAE3D,SAASK,cAAcC,IAAY;QAC/B,MAAMC,gBAAgBN,mBAAmB,GAAG,CAACK;QAC7C,IAAIC,eACA,OAAOA;QAEX,OAAON,mBAAmB,UAAU;IACxC;IAGA,MAAMO,SAAY,CAAC;IACnB,MAAMC,YAAe,CAAC;IAGtB,KAAK,MAAMC,SAASN,MAAM,MAAM,CAAE;QAC9B,MAAMO,aAAaC,mBAAmBV,aAAa,MAAM,EAAEQ;QAC3D,IAAI,CAACC,YACD;QAGJ,MAAME,aAAaR,cAAcK,MAAM,IAAI;QAE3C,MAAM,EAAEI,KAAK,EAAEC,QAAQ,EAAE,GAAGF,WAAW,OAAO,CAAC;YAC3CT;YACAM;YACA,UAAUP,MAAM,MAAM,CAACQ,WAAW;YAClC,OAAOT,aAAa,MAAM,CAACS,WAAW;YACtCN;QACJ;QAEA,IAAI,AAAiB,WAAVS,OACPN,MAAM,CAACG,WAAW,GAAGG;QAGzB,IAAI,AAAoB,WAAbC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YAAY;QAE5B,OAAOA,QAAQ,CAAC,OAAO;QAEvB,OAAOA,QAAQ,CAAC,SAAS;QAEzB,OAAOA,QAAQ,CAAC,SAAS;QAEzB,OAAOA,QAAQ,CAAC,YAAY;QAC5BT,KAAK,IAAI,CAAC;YACN,GAAGS,QAAQ;QACf;IACJ;IAEA,OAAOT;AACX"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CmsEntryValues, CmsModelField } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
export declare const getFieldIdentifier: (values: CmsEntryValues | null | undefined, field: CmsModelField) => string | undefined;
|
|
3
|
+
export declare const getFieldIdentifiers: (values: CmsEntryValues, rawValues: CmsEntryValues | null | undefined, field: CmsModelField) => {
|
|
4
|
+
valueIdentifier: string;
|
|
5
|
+
rawValueIdentifier: string;
|
|
6
|
+
} | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const fieldIdentifier_hasOwnProperty = (values = {}, property)=>{
|
|
2
|
+
if (!values) return false;
|
|
3
|
+
if (values.hasOwnProperty) return values.hasOwnProperty(property);
|
|
4
|
+
return void 0 !== values[property];
|
|
5
|
+
};
|
|
6
|
+
const getFieldIdentifier = (values, field)=>{
|
|
7
|
+
if (field.storageId && fieldIdentifier_hasOwnProperty(values, field.storageId)) return field.storageId;
|
|
8
|
+
if (fieldIdentifier_hasOwnProperty(values, field.fieldId)) return field.fieldId;
|
|
9
|
+
};
|
|
10
|
+
const getFieldIdentifiers = (values, rawValues, field)=>{
|
|
11
|
+
let valueIdentifier = getFieldIdentifier(values, field);
|
|
12
|
+
let rawValueIdentifier = getFieldIdentifier(rawValues, field);
|
|
13
|
+
if (!valueIdentifier && !rawValueIdentifier) return null;
|
|
14
|
+
if (!valueIdentifier) valueIdentifier = rawValueIdentifier;
|
|
15
|
+
if (!rawValueIdentifier) rawValueIdentifier = valueIdentifier;
|
|
16
|
+
return {
|
|
17
|
+
valueIdentifier,
|
|
18
|
+
rawValueIdentifier
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export { getFieldIdentifier, getFieldIdentifiers };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=fieldIdentifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers/fieldIdentifier.js","sources":["../../src/helpers/fieldIdentifier.ts"],"sourcesContent":["import type { CmsEntryValues, CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\n\nconst hasOwnProperty = (\n values: CmsEntryValues | null | undefined = {},\n property: string\n): boolean => {\n if (!values) {\n return false;\n } else if (values.hasOwnProperty) {\n return values.hasOwnProperty(property);\n }\n return values[property] !== undefined;\n};\n\nexport const getFieldIdentifier = (\n values: CmsEntryValues | null | undefined,\n field: CmsModelField\n): string | undefined => {\n if (field.storageId && hasOwnProperty(values, field.storageId)) {\n return field.storageId;\n } else if (hasOwnProperty(values, field.fieldId)) {\n return field.fieldId;\n }\n return undefined;\n};\n\nexport const getFieldIdentifiers = (\n values: CmsEntryValues,\n rawValues: CmsEntryValues | null | undefined,\n field: CmsModelField\n) => {\n let valueIdentifier = getFieldIdentifier(values, field);\n let rawValueIdentifier = getFieldIdentifier(rawValues, field);\n if (!valueIdentifier && !rawValueIdentifier) {\n return null;\n }\n if (!valueIdentifier) {\n valueIdentifier = rawValueIdentifier as string;\n }\n if (!rawValueIdentifier) {\n rawValueIdentifier = valueIdentifier as string;\n }\n return {\n valueIdentifier,\n rawValueIdentifier\n };\n};\n"],"names":["hasOwnProperty","values","property","undefined","getFieldIdentifier","field","getFieldIdentifiers","rawValues","valueIdentifier","rawValueIdentifier"],"mappings":"AAEA,MAAMA,iCAAiB,CACnBC,SAA4C,CAAC,CAAC,EAC9CC;IAEA,IAAI,CAACD,QACD,OAAO;IACJ,IAAIA,OAAO,cAAc,EAC5B,OAAOA,OAAO,cAAc,CAACC;IAEjC,OAAOD,AAAqBE,WAArBF,MAAM,CAACC,SAAS;AAC3B;AAEO,MAAME,qBAAqB,CAC9BH,QACAI;IAEA,IAAIA,MAAM,SAAS,IAAIL,+BAAeC,QAAQI,MAAM,SAAS,GACzD,OAAOA,MAAM,SAAS;IACnB,IAAIL,+BAAeC,QAAQI,MAAM,OAAO,GAC3C,OAAOA,MAAM,OAAO;AAG5B;AAEO,MAAMC,sBAAsB,CAC/BL,QACAM,WACAF;IAEA,IAAIG,kBAAkBJ,mBAAmBH,QAAQI;IACjD,IAAII,qBAAqBL,mBAAmBG,WAAWF;IACvD,IAAI,CAACG,mBAAmB,CAACC,oBACrB,OAAO;IAEX,IAAI,CAACD,iBACDA,kBAAkBC;IAEtB,IAAI,CAACA,oBACDA,qBAAqBD;IAEzB,OAAO;QACHA;QACAC;IACJ;AACJ"}
|
package/helpers/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from "./entryIndexHelpers";
|
|
1
|
+
export * from "./entryIndexHelpers.js";
|
|
2
|
+
export * from "./fieldIdentifier.js";
|
package/helpers/index.js
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _entryIndexHelpers = require("./entryIndexHelpers");
|
|
7
|
-
Object.keys(_entryIndexHelpers).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _entryIndexHelpers[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _entryIndexHelpers[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
1
|
+
export * from "./entryIndexHelpers.js";
|
|
2
|
+
export * from "./fieldIdentifier.js";
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,215 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
var _exportNames = {
|
|
8
|
-
createStorageOperations: true
|
|
9
|
-
};
|
|
10
|
-
exports.createStorageOperations = void 0;
|
|
11
|
-
var _filters = _interopRequireDefault(require("@webiny/db-dynamodb/plugins/filters"));
|
|
12
|
-
var _elasticsearch = _interopRequireDefault(require("./elasticsearch"));
|
|
13
|
-
var _dynamoDb = _interopRequireDefault(require("./dynamoDb"));
|
|
14
|
-
var _settings = require("./operations/settings");
|
|
15
|
-
var _system = require("./operations/system");
|
|
16
|
-
var _model = require("./operations/model");
|
|
17
|
-
var _entry = require("./operations/entry");
|
|
18
|
-
var _types = require("./types");
|
|
19
|
-
var _table = require("./definitions/table");
|
|
20
|
-
var _tableElasticsearch = require("./definitions/tableElasticsearch");
|
|
21
|
-
var _group = require("./definitions/group");
|
|
22
|
-
var _model2 = require("./definitions/model");
|
|
23
|
-
var _entry2 = require("./definitions/entry");
|
|
24
|
-
var _entryElasticsearch = require("./definitions/entryElasticsearch");
|
|
25
|
-
var _system2 = require("./definitions/system");
|
|
26
|
-
var _settings2 = require("./definitions/settings");
|
|
27
|
-
var _createElasticsearchIndex = require("./elasticsearch/createElasticsearchIndex");
|
|
28
|
-
var _plugins = require("@webiny/plugins");
|
|
29
|
-
var _group2 = require("./operations/group");
|
|
30
|
-
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
31
|
-
var _indices = require("./elasticsearch/indices");
|
|
32
|
-
var _deleteElasticsearchIndex = require("./elasticsearch/deleteElasticsearchIndex");
|
|
33
|
-
var _plugins2 = require("./plugins");
|
|
34
|
-
Object.keys(_plugins2).forEach(function (key) {
|
|
35
|
-
if (key === "default" || key === "__esModule") return;
|
|
36
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
37
|
-
if (key in exports && exports[key] === _plugins2[key]) return;
|
|
38
|
-
Object.defineProperty(exports, key, {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function () {
|
|
41
|
-
return _plugins2[key];
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
var _plugins3 = require("./operations/entry/elasticsearch/filtering/plugins");
|
|
46
|
-
var _CmsEntryFilterPlugin = require("./plugins/CmsEntryFilterPlugin");
|
|
47
|
-
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
48
|
-
const createStorageOperations = params => {
|
|
49
|
-
const {
|
|
50
|
-
attributes,
|
|
51
|
-
table,
|
|
52
|
-
esTable,
|
|
53
|
-
documentClient,
|
|
54
|
-
elasticsearch,
|
|
55
|
-
plugins: userPlugins
|
|
56
|
-
} = params;
|
|
57
|
-
const tableInstance = (0, _table.createTable)({
|
|
58
|
-
table,
|
|
59
|
-
documentClient
|
|
60
|
-
});
|
|
61
|
-
const tableElasticsearchInstance = (0, _tableElasticsearch.createElasticsearchTable)({
|
|
62
|
-
table: esTable,
|
|
63
|
-
documentClient
|
|
64
|
-
});
|
|
65
|
-
const entities = {
|
|
66
|
-
settings: (0, _settings2.createSettingsEntity)({
|
|
67
|
-
entityName: _types.ENTITIES.SETTINGS,
|
|
68
|
-
table: tableInstance,
|
|
69
|
-
attributes: attributes ? attributes[_types.ENTITIES.SETTINGS] : {}
|
|
70
|
-
}),
|
|
71
|
-
system: (0, _system2.createSystemEntity)({
|
|
72
|
-
entityName: _types.ENTITIES.SYSTEM,
|
|
73
|
-
table: tableInstance,
|
|
74
|
-
attributes: attributes ? attributes[_types.ENTITIES.SYSTEM] : {}
|
|
75
|
-
}),
|
|
76
|
-
groups: (0, _group.createGroupEntity)({
|
|
77
|
-
entityName: _types.ENTITIES.GROUPS,
|
|
78
|
-
table: tableInstance,
|
|
79
|
-
attributes: attributes ? attributes[_types.ENTITIES.GROUPS] : {}
|
|
80
|
-
}),
|
|
81
|
-
models: (0, _model2.createModelEntity)({
|
|
82
|
-
entityName: _types.ENTITIES.MODELS,
|
|
83
|
-
table: tableInstance,
|
|
84
|
-
attributes: attributes ? attributes[_types.ENTITIES.MODELS] : {}
|
|
85
|
-
}),
|
|
86
|
-
entries: (0, _entry2.createEntryEntity)({
|
|
87
|
-
entityName: _types.ENTITIES.ENTRIES,
|
|
88
|
-
table: tableInstance,
|
|
89
|
-
attributes: attributes ? attributes[_types.ENTITIES.ENTRIES] : {}
|
|
90
|
-
}),
|
|
91
|
-
entriesEs: (0, _entryElasticsearch.createEntryElasticsearchEntity)({
|
|
92
|
-
entityName: _types.ENTITIES.ENTRIES_ES,
|
|
93
|
-
table: tableElasticsearchInstance,
|
|
94
|
-
attributes: attributes ? attributes[_types.ENTITIES.ENTRIES_ES] : {}
|
|
95
|
-
})
|
|
96
|
-
};
|
|
97
|
-
const plugins = new _plugins.PluginsContainer([
|
|
98
|
-
/**
|
|
99
|
-
* DynamoDB filter plugins for the where conditions.
|
|
100
|
-
*/
|
|
101
|
-
(0, _filters.default)(),
|
|
102
|
-
/**
|
|
103
|
-
* Field plugins for DynamoDB.
|
|
104
|
-
*/
|
|
105
|
-
(0, _dynamoDb.default)(),
|
|
106
|
-
/**
|
|
107
|
-
* Field plugins for Elasticsearch.
|
|
108
|
-
*/
|
|
109
|
-
(0, _elasticsearch.default)(),
|
|
110
|
-
/**
|
|
111
|
-
* Built-in Elasticsearch index templates.
|
|
112
|
-
*/
|
|
113
|
-
(0, _indices.elasticsearchIndexPlugins)(),
|
|
114
|
-
/**
|
|
115
|
-
* Filter plugins used to apply filtering from where conditions to Elasticsearch query.
|
|
116
|
-
*/
|
|
117
|
-
(0, _plugins3.createFilterPlugins)(),
|
|
118
|
-
/**
|
|
119
|
-
* User defined custom plugins.
|
|
120
|
-
* They are at the end because we can then override existing plugins.
|
|
121
|
-
*/
|
|
122
|
-
...(userPlugins || [])]);
|
|
123
|
-
return {
|
|
124
|
-
name: "dynamodb:elasticsearch",
|
|
125
|
-
beforeInit: async context => {
|
|
126
|
-
/**
|
|
127
|
-
* Attach the elasticsearch into context if it is not already attached.
|
|
128
|
-
*/
|
|
129
|
-
if (!context.elasticsearch) {
|
|
130
|
-
context.elasticsearch = elasticsearch;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Pass the plugins to the parent context.
|
|
134
|
-
*/
|
|
135
|
-
context.plugins.register([(0, _dynamoDb.default)()]);
|
|
136
|
-
/**
|
|
137
|
-
* We need to fetch all the plugin types in the list from the main container.
|
|
138
|
-
* This way we do not need to register plugins in the storage plugins contains.
|
|
139
|
-
*/
|
|
140
|
-
const types = [
|
|
141
|
-
// Elasticsearch
|
|
142
|
-
_apiElasticsearch.CompressionPlugin.type, _apiElasticsearch.ElasticsearchQueryBuilderOperatorPlugin.type,
|
|
143
|
-
// Headless CMS
|
|
144
|
-
"cms-model-field-to-graphql", _CmsEntryFilterPlugin.CmsEntryFilterPlugin.type, _plugins2.CmsEntryElasticsearchBodyModifierPlugin.type, _plugins2.CmsEntryElasticsearchFullTextSearchPlugin.type, _plugins2.CmsEntryElasticsearchIndexPlugin.type, _plugins2.CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type, _plugins2.CmsEntryElasticsearchQueryModifierPlugin.type, _plugins2.CmsEntryElasticsearchSortModifierPlugin.type, _plugins2.CmsElasticsearchModelFieldPlugin.type, _apiHeadlessCms.StorageOperationsCmsModelPlugin.type];
|
|
145
|
-
for (const type of types) {
|
|
146
|
-
plugins.mergeByType(context.plugins, type);
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
init: async context => {
|
|
150
|
-
/**
|
|
151
|
-
* We need to create indexes on before model create and on clone (create from).
|
|
152
|
-
* Other apps create indexes on locale creation.
|
|
153
|
-
*/
|
|
154
|
-
context.cms.onModelBeforeCreate.subscribe(async ({
|
|
155
|
-
model
|
|
156
|
-
}) => {
|
|
157
|
-
await (0, _createElasticsearchIndex.createElasticsearchIndex)({
|
|
158
|
-
elasticsearch,
|
|
159
|
-
model,
|
|
160
|
-
plugins
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
context.cms.onModelBeforeCreateFrom.subscribe(async ({
|
|
164
|
-
model
|
|
165
|
-
}) => {
|
|
166
|
-
await (0, _createElasticsearchIndex.createElasticsearchIndex)({
|
|
167
|
-
elasticsearch,
|
|
168
|
-
model,
|
|
169
|
-
plugins
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
context.cms.onModelAfterDelete.subscribe(async ({
|
|
173
|
-
model
|
|
174
|
-
}) => {
|
|
175
|
-
await (0, _deleteElasticsearchIndex.deleteElasticsearchIndex)({
|
|
176
|
-
elasticsearch,
|
|
177
|
-
model
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
context.cms.onModelInitialize.subscribe(async ({
|
|
181
|
-
model
|
|
182
|
-
}) => {
|
|
183
|
-
await (0, _createElasticsearchIndex.createElasticsearchIndex)({
|
|
184
|
-
elasticsearch,
|
|
185
|
-
model,
|
|
186
|
-
plugins
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
},
|
|
190
|
-
getEntities: () => entities,
|
|
191
|
-
getTable: () => tableInstance,
|
|
192
|
-
getEsTable: () => tableElasticsearchInstance,
|
|
193
|
-
system: (0, _system.createSystemStorageOperations)({
|
|
194
|
-
entity: entities.system
|
|
195
|
-
}),
|
|
196
|
-
settings: (0, _settings.createSettingsStorageOperations)({
|
|
197
|
-
entity: entities.settings
|
|
198
|
-
}),
|
|
199
|
-
groups: (0, _group2.createGroupsStorageOperations)({
|
|
200
|
-
entity: entities.groups,
|
|
201
|
-
plugins
|
|
202
|
-
}),
|
|
203
|
-
models: (0, _model.createModelsStorageOperations)({
|
|
204
|
-
entity: entities.models,
|
|
205
|
-
elasticsearch
|
|
206
|
-
}),
|
|
207
|
-
entries: (0, _entry.createEntriesStorageOperations)({
|
|
208
|
-
entity: entities.entries,
|
|
209
|
-
esEntity: entities.entriesEs,
|
|
210
|
-
plugins,
|
|
211
|
-
elasticsearch
|
|
212
|
-
})
|
|
213
|
-
};
|
|
214
|
-
};
|
|
215
|
-
exports.createStorageOperations = createStorageOperations;
|
|
1
|
+
export { registerCmsOpenSearchStorageOperations } from "./feature.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type DataLoader from "dataloader";
|
|
2
|
+
export interface CacheKeyParams {
|
|
3
|
+
name: string;
|
|
4
|
+
tenant: string;
|
|
5
|
+
modelId: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ClearAllParams {
|
|
8
|
+
tenant: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class DataLoaderCache {
|
|
11
|
+
private readonly cache;
|
|
12
|
+
getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null;
|
|
13
|
+
setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void;
|
|
14
|
+
clearAll(params?: ClearAllParams): void;
|
|
15
|
+
private createKey;
|
|
16
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
class DataLoaderCache {
|
|
2
|
+
getDataLoader(params) {
|
|
3
|
+
const key = this.createKey(params);
|
|
4
|
+
return this.cache[key] || null;
|
|
5
|
+
}
|
|
6
|
+
setDataLoader(params, dataLoader) {
|
|
7
|
+
const key = this.createKey(params);
|
|
8
|
+
this.cache[key] = dataLoader;
|
|
9
|
+
}
|
|
10
|
+
clearAll(params) {
|
|
11
|
+
if (!params) {
|
|
12
|
+
for(const current in this.cache)this.cache[current].clearAll();
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const key = `${params.tenant}_`;
|
|
16
|
+
for(const current in this.cache)if (false !== current.startsWith(key)) this.cache[current].clearAll();
|
|
17
|
+
}
|
|
18
|
+
createKey(params) {
|
|
19
|
+
return `${params.tenant}_${params.modelId}_${params.name}`;
|
|
20
|
+
}
|
|
21
|
+
constructor(){
|
|
22
|
+
this.cache = {};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export { DataLoaderCache };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=DataLoaderCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/dataLoader/DataLoaderCache.js","sources":["../../../../src/operations/entry/dataLoader/DataLoaderCache.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\n\nexport interface CacheKeyParams {\n name: string;\n tenant: string;\n modelId: string;\n}\n\nexport interface ClearAllParams {\n tenant: string;\n}\n\nexport class DataLoaderCache {\n private readonly cache: Record<string, DataLoader<any, any>> = {};\n\n public getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null {\n const key = this.createKey(params);\n\n return this.cache[key] || null;\n }\n\n public setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void {\n const key = this.createKey(params);\n this.cache[key] = dataLoader;\n }\n\n public clearAll(params?: ClearAllParams): void {\n if (!params) {\n for (const current in this.cache) {\n this.cache[current].clearAll();\n }\n return;\n }\n const key = `${params.tenant}_`;\n for (const current in this.cache) {\n if (current.startsWith(key) === false) {\n continue;\n }\n this.cache[current].clearAll();\n }\n }\n\n private createKey(params: CacheKeyParams): string {\n return `${params.tenant}_${params.modelId}_${params.name}`;\n }\n}\n"],"names":["DataLoaderCache","params","key","dataLoader","current"],"mappings":"AAYO,MAAMA;IAGF,cAAgCC,MAAsB,EAA2B;QACpF,MAAMC,MAAM,IAAI,CAAC,SAAS,CAACD;QAE3B,OAAO,IAAI,CAAC,KAAK,CAACC,IAAI,IAAI;IAC9B;IAEO,cAAcD,MAAsB,EAAEE,UAAgC,EAAQ;QACjF,MAAMD,MAAM,IAAI,CAAC,SAAS,CAACD;QAC3B,IAAI,CAAC,KAAK,CAACC,IAAI,GAAGC;IACtB;IAEO,SAASF,MAAuB,EAAQ;QAC3C,IAAI,CAACA,QAAQ;YACT,IAAK,MAAMG,WAAW,IAAI,CAAC,KAAK,CAC5B,IAAI,CAAC,KAAK,CAACA,QAAQ,CAAC,QAAQ;YAEhC;QACJ;QACA,MAAMF,MAAM,GAAGD,OAAO,MAAM,CAAC,CAAC,CAAC;QAC/B,IAAK,MAAMG,WAAW,IAAI,CAAC,KAAK,CAC5B,IAAIA,AAA4B,UAA5BA,QAAQ,UAAU,CAACF,MAGvB,IAAI,CAAC,KAAK,CAACE,QAAQ,CAAC,QAAQ;IAEpC;IAEQ,UAAUH,MAAsB,EAAU;QAC9C,OAAO,GAAGA,OAAO,MAAM,CAAC,CAAC,EAAEA,OAAO,OAAO,CAAC,CAAC,EAAEA,OAAO,IAAI,EAAE;IAC9D;;aA/BiB,KAAK,GAAyC,CAAC;;AAgCpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CMS_ENTRY_BATCH_SCHEDULE_WAIT: number;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const batchScheduleWaitEnv = Number(process.env.WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT || "0");
|
|
2
|
+
const CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;
|
|
3
|
+
export { CMS_ENTRY_BATCH_SCHEDULE_WAIT };
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/dataLoader/constants.js","sources":["../../../../src/operations/entry/dataLoader/constants.ts"],"sourcesContent":["const batchScheduleWaitEnv = Number(process.env.WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT || \"0\");\nexport const CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;\n"],"names":["batchScheduleWaitEnv","Number","process","CMS_ENTRY_BATCH_SCHEDULE_WAIT","isNaN"],"mappings":"AAAA,MAAMA,uBAAuBC,OAAOC,QAAQ,GAAG,CAAC,wCAAwC,IAAI;AACrF,MAAMC,gCAAgCC,MAAMJ,wBAAwB,IAAIA"}
|