@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
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { CmsEntryOpenSearchValueSearch } from "../abstractions/CmsEntryOpenSearchValueSearch.js";
|
|
2
|
+
import { WebinyError } from "@webiny/error";
|
|
3
|
+
import { NoValueContainer } from "../../../values/NoValueContainer.js";
|
|
4
|
+
const getKey = (params)=>{
|
|
5
|
+
const { field, value } = params;
|
|
6
|
+
const keys = Object.keys(value);
|
|
7
|
+
if (0 === keys.length) throw new WebinyError(`Searchable JSON field "${field.fieldId}" cannot be empty.`, "EMPTY_SEARCHABLE_JSON_FIELD", {
|
|
8
|
+
field,
|
|
9
|
+
value
|
|
10
|
+
});
|
|
11
|
+
if (keys.length > 1) throw new WebinyError(`Searchable JSON field "${field.fieldId}" can only have one key.`, "MULTIPLE_KEYS_IN_SEARCHABLE_JSON_FIELD", {
|
|
12
|
+
field,
|
|
13
|
+
value,
|
|
14
|
+
keys
|
|
15
|
+
});
|
|
16
|
+
return keys[0];
|
|
17
|
+
};
|
|
18
|
+
class SearchableJsonSearchImpl {
|
|
19
|
+
transform(params) {
|
|
20
|
+
const { value } = params;
|
|
21
|
+
if (NoValueContainer.is(value)) return null;
|
|
22
|
+
const key = getKey(params);
|
|
23
|
+
return value[key] || null;
|
|
24
|
+
}
|
|
25
|
+
createPath(params) {
|
|
26
|
+
const { field } = params;
|
|
27
|
+
if (NoValueContainer.is(params.originalValue)) return `${field.storageId}.unknown`;
|
|
28
|
+
const key = getKey({
|
|
29
|
+
field,
|
|
30
|
+
value: params.originalValue
|
|
31
|
+
});
|
|
32
|
+
return `${field.storageId}.${key}`;
|
|
33
|
+
}
|
|
34
|
+
constructor(){
|
|
35
|
+
this.fieldType = "searchable-json";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const SearchableJsonSearch = CmsEntryOpenSearchValueSearch.createImplementation({
|
|
39
|
+
implementation: SearchableJsonSearchImpl,
|
|
40
|
+
dependencies: []
|
|
41
|
+
});
|
|
42
|
+
export { SearchableJsonSearch };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=SearchableJsonSearch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js","sources":["../../../../src/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsEntryOpenSearchValueSearch } from \"../abstractions/CmsEntryOpenSearchValueSearch.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport { NoValueContainer } from \"~/values/NoValueContainer.js\";\n\ninterface IGetKeyParams {\n field: CmsModelField;\n value: {\n [key: string]: any;\n };\n}\n\nconst getKey = (params: IGetKeyParams): string => {\n const { field, value } = params;\n const keys = Object.keys(value);\n if (keys.length === 0) {\n throw new WebinyError(\n `Searchable JSON field \"${field.fieldId}\" cannot be empty.`,\n \"EMPTY_SEARCHABLE_JSON_FIELD\",\n {\n field,\n value\n }\n );\n } else if (keys.length > 1) {\n throw new WebinyError(\n `Searchable JSON field \"${field.fieldId}\" can only have one key.`,\n \"MULTIPLE_KEYS_IN_SEARCHABLE_JSON_FIELD\",\n {\n field,\n value,\n keys\n }\n );\n }\n return keys[0];\n};\n\nclass SearchableJsonSearchImpl implements CmsEntryOpenSearchValueSearch.Interface {\n public readonly fieldType = \"searchable-json\";\n\n public transform(params: CmsEntryOpenSearchValueSearch.Transform): any {\n const { value } = params;\n\n if (NoValueContainer.is(value)) {\n return null;\n }\n\n const key = getKey(params);\n return value[key] || null;\n }\n\n public createPath(params: CmsEntryOpenSearchValueSearch.CreatePath): string | null {\n const { field } = params;\n\n if (NoValueContainer.is(params.originalValue)) {\n return `${field.storageId}.unknown`;\n }\n\n const key = getKey({\n field,\n value: params.originalValue\n });\n\n return `${field.storageId}.${key}`;\n }\n}\n\nexport const SearchableJsonSearch = CmsEntryOpenSearchValueSearch.createImplementation({\n implementation: SearchableJsonSearchImpl,\n dependencies: []\n});\n"],"names":["getKey","params","field","value","keys","Object","WebinyError","SearchableJsonSearchImpl","NoValueContainer","key","SearchableJsonSearch","CmsEntryOpenSearchValueSearch"],"mappings":";;;AAYA,MAAMA,SAAS,CAACC;IACZ,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF;IACzB,MAAMG,OAAOC,OAAO,IAAI,CAACF;IACzB,IAAIC,AAAgB,MAAhBA,KAAK,MAAM,EACX,MAAM,IAAIE,YACN,CAAC,uBAAuB,EAAEJ,MAAM,OAAO,CAAC,kBAAkB,CAAC,EAC3D,+BACA;QACIA;QACAC;IACJ;IAED,IAAIC,KAAK,MAAM,GAAG,GACrB,MAAM,IAAIE,YACN,CAAC,uBAAuB,EAAEJ,MAAM,OAAO,CAAC,wBAAwB,CAAC,EACjE,0CACA;QACIA;QACAC;QACAC;IACJ;IAGR,OAAOA,IAAI,CAAC,EAAE;AAClB;AAEA,MAAMG;IAGK,UAAUN,MAA+C,EAAO;QACnE,MAAM,EAAEE,KAAK,EAAE,GAAGF;QAElB,IAAIO,iBAAiB,EAAE,CAACL,QACpB,OAAO;QAGX,MAAMM,MAAMT,OAAOC;QACnB,OAAOE,KAAK,CAACM,IAAI,IAAI;IACzB;IAEO,WAAWR,MAAgD,EAAiB;QAC/E,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAElB,IAAIO,iBAAiB,EAAE,CAACP,OAAO,aAAa,GACxC,OAAO,GAAGC,MAAM,SAAS,CAAC,QAAQ,CAAC;QAGvC,MAAMO,MAAMT,OAAO;YACfE;YACA,OAAOD,OAAO,aAAa;QAC/B;QAEA,OAAO,GAAGC,MAAM,SAAS,CAAC,CAAC,EAAEO,KAAK;IACtC;;aA1BgB,SAAS,GAAG;;AA2BhC;AAEO,MAAMC,uBAAuBC,8BAA8B,oBAAoB,CAAC;IACnF,gBAAgBJ;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CmsEntryOpenSearchValueSearch } from "../abstractions/CmsEntryOpenSearchValueSearch.js";
|
|
2
|
+
declare class TimeSearchImpl implements CmsEntryOpenSearchValueSearch.Interface {
|
|
3
|
+
readonly fieldType = "datetime";
|
|
4
|
+
transform(params: CmsEntryOpenSearchValueSearch.Transform): any;
|
|
5
|
+
createPath(): string | null;
|
|
6
|
+
}
|
|
7
|
+
export declare const TimeSearch: typeof TimeSearchImpl & {
|
|
8
|
+
__abstraction: import("@webiny/di").Abstraction<import("../abstractions/CmsEntryOpenSearchValueSearch.js").ICmsEntryOpenSearchValueSearch>;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CmsEntryOpenSearchValueSearch } from "../abstractions/CmsEntryOpenSearchValueSearch.js";
|
|
2
|
+
class TimeSearchImpl {
|
|
3
|
+
transform(params) {
|
|
4
|
+
const { field, value } = params;
|
|
5
|
+
if (!value || field.settings?.type !== "time") return value;
|
|
6
|
+
const [hours, minutes, seconds = 0] = value.split(":").map(Number);
|
|
7
|
+
return 60 * hours * 60 + 60 * minutes + seconds;
|
|
8
|
+
}
|
|
9
|
+
createPath() {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
constructor(){
|
|
13
|
+
this.fieldType = "datetime";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const TimeSearch = CmsEntryOpenSearchValueSearch.createImplementation({
|
|
17
|
+
implementation: TimeSearchImpl,
|
|
18
|
+
dependencies: []
|
|
19
|
+
});
|
|
20
|
+
export { TimeSearch };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=TimeSearch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js","sources":["../../../../src/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.ts"],"sourcesContent":["import { CmsEntryOpenSearchValueSearch } from \"../abstractions/CmsEntryOpenSearchValueSearch.js\";\n\nclass TimeSearchImpl implements CmsEntryOpenSearchValueSearch.Interface {\n public readonly fieldType = \"datetime\";\n\n public transform(params: CmsEntryOpenSearchValueSearch.Transform): any {\n const { field, value } = params;\n if (!value || field.settings?.type !== \"time\") {\n return value;\n }\n const [hours, minutes, seconds = 0] = value.split(\":\").map(Number);\n return hours * 60 * 60 + minutes * 60 + seconds;\n }\n\n public createPath(): string | null {\n return null;\n }\n}\n\nexport const TimeSearch = CmsEntryOpenSearchValueSearch.createImplementation({\n implementation: TimeSearchImpl,\n dependencies: []\n});\n"],"names":["TimeSearchImpl","params","field","value","hours","minutes","seconds","Number","TimeSearch","CmsEntryOpenSearchValueSearch"],"mappings":";AAEA,MAAMA;IAGK,UAAUC,MAA+C,EAAO;QACnE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF;QACzB,IAAI,CAACE,SAASD,MAAM,QAAQ,EAAE,SAAS,QACnC,OAAOC;QAEX,MAAM,CAACC,OAAOC,SAASC,UAAU,CAAC,CAAC,GAAGH,MAAM,KAAK,CAAC,KAAK,GAAG,CAACI;QAC3D,OAAOH,AAAQ,KAARA,QAAa,KAAKC,AAAU,KAAVA,UAAeC;IAC5C;IAEO,aAA4B;QAC/B,OAAO;IACX;;aAbgB,SAAS,GAAG;;AAchC;AAEO,MAAME,aAAaC,8BAA8B,oBAAoB,CAAC;IACzE,gBAAgBT;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { CmsEntryOpenSearchValueSearch } from "./abstractions/CmsEntryOpenSearchValueSearch.js";
|
|
2
|
+
export { CmsEntryOpenSearchValueSearchRegistry } from "./abstractions/CmsEntryOpenSearchValueSearchRegistry.js";
|
|
3
|
+
export { CmsEntryOpenSearchValueSearchFeature } from "./feature.js";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { CmsEntryOpenSearchValueSearch } from "./abstractions/CmsEntryOpenSearchValueSearch.js";
|
|
2
|
+
export { CmsEntryOpenSearchValueSearchRegistry } from "./abstractions/CmsEntryOpenSearchValueSearchRegistry.js";
|
|
3
|
+
export { CmsEntryOpenSearchValueSearchFeature } from "./feature.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CmsEntry, CmsEntryValues, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
export interface SetValuesCb<T extends CmsEntryValues = CmsEntryValues> {
|
|
3
|
+
(prev: T): T;
|
|
4
|
+
}
|
|
5
|
+
export interface ModifyValuesParams<T extends CmsEntryValues = CmsEntryValues> {
|
|
6
|
+
model: CmsModel;
|
|
7
|
+
entry: CmsEntry<T>;
|
|
8
|
+
values: T;
|
|
9
|
+
setValues: (cb: SetValuesCb<T>) => void;
|
|
10
|
+
}
|
|
11
|
+
export interface ICmsEntryOpenSearchValuesModifier {
|
|
12
|
+
canModify(modelId: string): boolean;
|
|
13
|
+
modify<T extends CmsEntryValues = CmsEntryValues>(params: {
|
|
14
|
+
model: CmsModel;
|
|
15
|
+
entry: CmsEntry<T>;
|
|
16
|
+
values: T;
|
|
17
|
+
}): T;
|
|
18
|
+
}
|
|
19
|
+
export declare const CmsEntryOpenSearchValuesModifier: import("@webiny/di").Abstraction<ICmsEntryOpenSearchValuesModifier>;
|
|
20
|
+
export declare namespace CmsEntryOpenSearchValuesModifier {
|
|
21
|
+
type Interface = ICmsEntryOpenSearchValuesModifier;
|
|
22
|
+
type Params<T extends CmsEntryValues = CmsEntryValues> = ModifyValuesParams<T>;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/CmsEntryOpenSearchValuesModifier/abstractions.js","sources":["../../../src/features/CmsEntryOpenSearchValuesModifier/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { CmsEntry, CmsEntryValues, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface SetValuesCb<T extends CmsEntryValues = CmsEntryValues> {\n (prev: T): T;\n}\n\nexport interface ModifyValuesParams<T extends CmsEntryValues = CmsEntryValues> {\n model: CmsModel;\n entry: CmsEntry<T>;\n values: T;\n setValues: (cb: SetValuesCb<T>) => void;\n}\n\nexport interface ICmsEntryOpenSearchValuesModifier {\n canModify(modelId: string): boolean;\n modify<T extends CmsEntryValues = CmsEntryValues>(params: {\n model: CmsModel;\n entry: CmsEntry<T>;\n values: T;\n }): T;\n}\n\nexport const CmsEntryOpenSearchValuesModifier =\n createAbstraction<ICmsEntryOpenSearchValuesModifier>(\"Cms/Entry/OpenSearch/ValuesModifier\");\n\nexport namespace CmsEntryOpenSearchValuesModifier {\n export type Interface = ICmsEntryOpenSearchValuesModifier;\n export type Params<T extends CmsEntryValues = CmsEntryValues> = ModifyValuesParams<T>;\n}\n"],"names":["CmsEntryOpenSearchValuesModifier","createAbstraction"],"mappings":";AAuBO,MAAMA,mCACTC,kBAAqD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CmsEntryOpenSearchValuesModifier } from "./abstractions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CmsEntryOpenSearchValuesModifier } from "./abstractions.js";
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import type { CmsEntry, CmsEntryValues, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
2
|
import type { CmsIndexEntry } from "../types.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
|
|
4
|
+
import type { CmsEntryOpenSearchFieldIndexRegistry } from "../features/CmsEntryOpenSearchFieldIndex/index.js";
|
|
4
5
|
interface SetupEntriesIndexHelpersParams {
|
|
5
|
-
|
|
6
|
+
fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;
|
|
7
|
+
fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface;
|
|
6
8
|
}
|
|
7
9
|
interface ExtractEntriesFromIndexParams<T extends CmsEntryValues = CmsEntryValues> extends SetupEntriesIndexHelpersParams {
|
|
8
10
|
model: CmsModel;
|
|
9
11
|
entries: CmsIndexEntry<T>[];
|
|
10
12
|
}
|
|
11
|
-
interface PrepareElasticsearchDataParams<T extends CmsEntryValues = CmsEntryValues> extends SetupEntriesIndexHelpersParams {
|
|
13
|
+
interface PrepareElasticsearchDataParams<T extends CmsEntryValues = CmsEntryValues> extends Omit<SetupEntriesIndexHelpersParams, "fieldRegistry"> {
|
|
12
14
|
model: CmsModel;
|
|
13
15
|
entry: CmsEntry<T>;
|
|
14
16
|
storageEntry: CmsEntry<T>;
|
|
15
17
|
}
|
|
16
18
|
export declare const prepareEntryToIndex: <T extends CmsEntryValues = CmsEntryValues>(params: PrepareElasticsearchDataParams<T>) => CmsIndexEntry<T>;
|
|
17
|
-
export declare const extractEntriesFromIndex: <T extends CmsEntryValues = CmsEntryValues>({
|
|
19
|
+
export declare const extractEntriesFromIndex: <T extends CmsEntryValues = CmsEntryValues>({ fieldRegistry, fieldIndexRegistry, entries, model }: ExtractEntriesFromIndexParams<T>) => CmsEntry<T>[];
|
|
18
20
|
export {};
|
|
@@ -1,196 +1,80 @@
|
|
|
1
|
-
import WebinyError from "@webiny/error";
|
|
1
|
+
import { WebinyError } from "@webiny/error";
|
|
2
2
|
import { getFieldIdentifier, getFieldIdentifiers } from "./fieldIdentifier.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
model
|
|
10
|
-
} = params;
|
|
11
|
-
const {
|
|
12
|
-
fieldIndexPlugins,
|
|
13
|
-
defaultIndexFieldPlugin,
|
|
14
|
-
fieldTypePlugins
|
|
15
|
-
} = setupEntriesIndexHelpers({
|
|
16
|
-
plugins
|
|
17
|
-
});
|
|
18
|
-
function getFieldIndexPlugin(type) {
|
|
19
|
-
const fieldType = getBaseFieldType({
|
|
20
|
-
type
|
|
21
|
-
});
|
|
22
|
-
return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;
|
|
23
|
-
}
|
|
24
|
-
function getFieldTypePlugin(type) {
|
|
25
|
-
const fieldType = getBaseFieldType({
|
|
26
|
-
type
|
|
27
|
-
});
|
|
28
|
-
const pl = fieldTypePlugins[fieldType];
|
|
29
|
-
if (pl) {
|
|
30
|
-
return pl;
|
|
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();
|
|
31
9
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// TODO: remove this `if` once we convert this plugin to proper plugin class
|
|
48
|
-
if (!targetFieldPlugin || !targetFieldPlugin.toIndex) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
const {
|
|
52
|
-
value,
|
|
53
|
-
rawValue
|
|
54
|
-
} = targetFieldPlugin.toIndex({
|
|
55
|
-
plugins,
|
|
56
|
-
model,
|
|
57
|
-
field,
|
|
58
|
-
rawValue: entry.values[identifier],
|
|
59
|
-
value: storageEntry.values[identifier],
|
|
60
|
-
getFieldIndexPlugin,
|
|
61
|
-
getFieldTypePlugin
|
|
62
|
-
});
|
|
63
|
-
if (typeof value !== "undefined") {
|
|
64
|
-
values[identifier] = value;
|
|
65
|
-
}
|
|
66
|
-
if (typeof rawValue !== "undefined") {
|
|
67
|
-
rawValues[identifier] = rawValue;
|
|
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;
|
|
68
25
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
};
|
|
26
|
+
return {
|
|
27
|
+
...storageEntry,
|
|
28
|
+
values,
|
|
29
|
+
rawValues
|
|
30
|
+
};
|
|
75
31
|
};
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
for (const plugin of plugins.reverse()) {
|
|
82
|
-
if (fieldIndexPlugins[plugin.fieldType]) {
|
|
83
|
-
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();
|
|
84
37
|
}
|
|
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
|
-
|
|
121
|
-
type
|
|
122
|
-
});
|
|
123
|
-
return fieldTypePlugins[fieldType];
|
|
124
|
-
}
|
|
125
|
-
const list = [];
|
|
126
|
-
for (const entry of entries) {
|
|
127
|
-
// This object will contain values processed by field index plugins
|
|
128
|
-
const indexValues = {};
|
|
129
|
-
|
|
130
|
-
// We only consider fields that are present in the model
|
|
131
|
-
for (const field of model.fields) {
|
|
132
|
-
const fieldTypePlugin = getFieldTypePlugin(field.type);
|
|
133
|
-
if (!fieldTypePlugin) {
|
|
134
|
-
throw new WebinyError(`Missing field type plugin "${field.type}". Extract entries from index.`);
|
|
135
|
-
}
|
|
136
|
-
const targetFieldPlugin = getFieldIndexPlugin(field.type);
|
|
137
|
-
if (!targetFieldPlugin || !targetFieldPlugin.fromIndex) {
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* We can safely cast as the code will not continue in case of no identifiers.
|
|
142
|
-
*/
|
|
143
|
-
const identifiers = getFieldIdentifiers(entry.values, entry.rawValues, field);
|
|
144
|
-
if (!identifiers) {
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
147
|
-
try {
|
|
148
|
-
const key = identifiers.valueIdentifier;
|
|
149
|
-
const rawKey = identifiers.rawValueIdentifier;
|
|
150
|
-
indexValues[key] = targetFieldPlugin.fromIndex({
|
|
151
|
-
plugins,
|
|
152
|
-
model,
|
|
153
|
-
field,
|
|
154
|
-
getFieldIndexPlugin,
|
|
155
|
-
getFieldTypePlugin,
|
|
156
|
-
value: entry.values[key || rawKey],
|
|
157
|
-
/**
|
|
158
|
-
* Possibly no rawValues so we must check for the existence of the field.
|
|
159
|
-
*/
|
|
160
|
-
rawValue: entry.rawValues ? entry.rawValues[rawKey || key] : null
|
|
161
|
-
});
|
|
162
|
-
} catch (ex) {
|
|
163
|
-
throw new WebinyError(ex.message || "Could not transform entry field from index.", ex.code || "FIELD_FROM_INDEX_ERROR", {
|
|
164
|
-
field,
|
|
165
|
-
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
|
|
166
74
|
});
|
|
167
|
-
}
|
|
168
75
|
}
|
|
169
|
-
|
|
170
|
-
* Let's have a new entry so we do not modify the original one.
|
|
171
|
-
*/
|
|
172
|
-
const newEntry = {
|
|
173
|
-
...entry,
|
|
174
|
-
values: indexValues
|
|
175
|
-
};
|
|
176
|
-
/**
|
|
177
|
-
* If we want to remove the rawValues, TYPE, latest, published and __type, we must make them optional or ignore them.
|
|
178
|
-
*/
|
|
179
|
-
// @ts-expect-error
|
|
180
|
-
delete newEntry["rawValues"];
|
|
181
|
-
// @ts-expect-error
|
|
182
|
-
delete newEntry["TYPE"];
|
|
183
|
-
// @ts-expect-error
|
|
184
|
-
delete newEntry["__type"];
|
|
185
|
-
// @ts-expect-error
|
|
186
|
-
delete newEntry["latest"];
|
|
187
|
-
// @ts-expect-error
|
|
188
|
-
delete newEntry["published"];
|
|
189
|
-
list.push({
|
|
190
|
-
...newEntry
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
return list;
|
|
76
|
+
return list;
|
|
194
77
|
};
|
|
78
|
+
export { extractEntriesFromIndex, prepareEntryToIndex };
|
|
195
79
|
|
|
196
80
|
//# sourceMappingURL=entryIndexHelpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebinyError","getFieldIdentifier","getFieldIdentifiers","getBaseFieldType","prepareEntryToIndex","params","plugins","storageEntry","entry","model","fieldIndexPlugins","defaultIndexFieldPlugin","fieldTypePlugins","setupEntriesIndexHelpers","getFieldIndexPlugin","type","fieldType","getFieldTypePlugin","pl","values","rawValues","field","fields","identifier","targetFieldPlugin","toIndex","value","rawValue","pluginsContainer","byType","plugin","reverse","find","reduce","extractEntriesFromIndex","entries","list","indexValues","fieldTypePlugin","fromIndex","identifiers","key","valueIdentifier","rawKey","rawValueIdentifier","ex","message","code","newEntry","push"],"sources":["entryIndexHelpers.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n CmsModelFieldToGraphQLPlugin\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CmsIndexEntry, CmsModelFieldToElasticsearchPlugin } from \"~/types.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { getFieldIdentifier, getFieldIdentifiers } from \"~/helpers/fieldIdentifier.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\n\ninterface SetupEntriesIndexHelpersParams {\n plugins: PluginsContainer;\n}\n\ninterface ExtractEntriesFromIndexParams<T extends CmsEntryValues = CmsEntryValues>\n extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entries: CmsIndexEntry<T>[];\n}\n\ninterface PrepareElasticsearchDataParams<T extends CmsEntryValues = CmsEntryValues>\n extends SetupEntriesIndexHelpersParams {\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 { plugins, storageEntry, entry, model } = params;\n const { fieldIndexPlugins, defaultIndexFieldPlugin, fieldTypePlugins } =\n setupEntriesIndexHelpers({ plugins });\n\n function getFieldIndexPlugin(type: string) {\n const fieldType = getBaseFieldType({\n type\n });\n return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;\n }\n\n function getFieldTypePlugin(type: string) {\n const fieldType = getBaseFieldType({\n type\n });\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: 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 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[identifier],\n value: storageEntry.values[identifier],\n getFieldIndexPlugin,\n getFieldTypePlugin\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\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 = <T extends CmsEntryValues = CmsEntryValues>({\n plugins,\n entries,\n model\n}: ExtractEntriesFromIndexParams<T>): CmsEntry<T>[] => {\n const { fieldIndexPlugins, defaultIndexFieldPlugin, fieldTypePlugins } =\n setupEntriesIndexHelpers({ plugins });\n\n function getFieldIndexPlugin(type: string) {\n const fieldType = getBaseFieldType({\n type\n });\n return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;\n }\n\n function getFieldTypePlugin(type: string) {\n const fieldType = getBaseFieldType({\n type\n });\n return fieldTypePlugins[fieldType];\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 fieldTypePlugin = getFieldTypePlugin(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 /**\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\n try {\n const key = identifiers.valueIdentifier as keyof T;\n const rawKey = identifiers.rawValueIdentifier as keyof T;\n indexValues[key] = targetFieldPlugin.fromIndex({\n plugins,\n model,\n field,\n getFieldIndexPlugin,\n getFieldTypePlugin,\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"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AASvC,SAASC,kBAAkB,EAAEC,mBAAmB;AAChD,SAASC,gBAAgB,QAAQ,oDAAoD;AAmBrF,OAAO,MAAMC,mBAAmB,GAC5BC,MAAyC,IACtB;EACnB,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,mBAAmBA,CAACC,IAAY,EAAE;IACvC,MAAMC,SAAS,GAAGb,gBAAgB,CAAC;MAC/BY;IACJ,CAAC,CAAC;IACF,OAAOL,iBAAiB,CAACM,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MAAM,IAAIF,GAAG,CAAC,GAAG;QACjE,CAAC,CAAC;MACN,CAAC,CAAC,OAAOI,EAAE,EAAE;QACT,MAAM,IAAI7C,WAAW,CACjB6C,EAAE,CAACC,OAAO,IAAI,6CAA6C,EAC3DD,EAAE,CAACE,IAAI,IAAI,wBAAwB,EACnC;UACI1B,KAAK;UACLb;QACJ,CACJ,CAAC;MACL;IACJ;IACA;AACR;AACA;IACQ,MAAMwC,QAAqB,GAAG;MAC1B,GAAGxC,KAAK;MACRW,MAAM,EAAEkB;IACZ,CAAC;IACD;AACR;AACA;IACQ;IACA,OAAOW,QAAQ,CAAC,WAAW,CAAC;IAC5B;IACA,OAAOA,QAAQ,CAAC,MAAM,CAAC;IACvB;IACA,OAAOA,QAAQ,CAAC,QAAQ,CAAC;IACzB;IACA,OAAOA,QAAQ,CAAC,QAAQ,CAAC;IACzB;IACA,OAAOA,QAAQ,CAAC,WAAW,CAAC;IAC5BZ,IAAI,CAACa,IAAI,CAAC;MACN,GAAGD;IACP,CAAC,CAAC;EACN;EAEA,OAAOZ,IAAI;AACf,CAAC","ignoreList":[]}
|
|
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,C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,CAAC,oBAAoB,EAAEZ,MAAM,IAAI,CAAC,8BAA8B,CAAC;YAIzE,MAAMG,aAAaR,cAAcK,MAAM,IAAI;YAI3C,MAAMa,cAAcC,oBAAoBrB,MAAM,MAAM,EAAEA,MAAM,SAAS,EAAEO;YACvE,IAAKa,aAGL,IAAI;gBACA,MAAME,MAAMF,YAAY,eAAe;gBACvC,MAAMG,SAASH,YAAY,kBAAkB;gBAC7CH,WAAW,CAACK,IAAI,GAAGZ,WAAW,SAAS,CAAC;oBACpCT;oBACAM;oBACAL;oBACA,OAAOF,MAAM,MAAM,CAACsB,OAAOC,OAAO;oBAIlC,UAAUvB,MAAM,SAAS,GAAGA,MAAM,SAAS,CAACuB,UAAUD,IAAI,GAAG;gBACjE;YACJ,EAAE,OAAOE,IAAI;gBACT,MAAM,IAAIL,YACNK,GAAG,OAAO,IAAI,+CACdA,GAAG,IAAI,IAAI,0BACX;oBACIjB;oBACAP;gBACJ;YAER;QACJ;QAIA,MAAMyB,WAAwB;YAC1B,GAAGzB,KAAK;YACR,QAAQiB;QACZ;QAKA,OAAOQ,QAAQ,CAAC,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"}
|
|
@@ -1,35 +1,23 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
return
|
|
4
|
-
|
|
5
|
-
return values.hasOwnProperty(property);
|
|
6
|
-
}
|
|
7
|
-
return values[property] !== undefined;
|
|
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];
|
|
8
5
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return field.
|
|
12
|
-
} else if (hasOwnProperty(values, field.fieldId)) {
|
|
13
|
-
return field.fieldId;
|
|
14
|
-
}
|
|
15
|
-
return undefined;
|
|
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;
|
|
16
9
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
rawValueIdentifier = valueIdentifier;
|
|
28
|
-
}
|
|
29
|
-
return {
|
|
30
|
-
valueIdentifier,
|
|
31
|
-
rawValueIdentifier
|
|
32
|
-
};
|
|
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
|
+
};
|
|
33
20
|
};
|
|
21
|
+
export { getFieldIdentifier, getFieldIdentifiers };
|
|
34
22
|
|
|
35
23
|
//# sourceMappingURL=fieldIdentifier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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.js
CHANGED
package/index.d.ts
CHANGED