@webiny/api-headless-cms-ddb-es 6.1.0-beta.3 → 6.2.0-beta.0
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 +3 -2
- package/configurations.js +10 -8
- package/configurations.js.map +1 -1
- package/elasticsearch/createElasticsearchIndex.d.ts +2 -2
- package/elasticsearch/createElasticsearchIndex.js +58 -16
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/exports/api/cms/opensearch.d.ts +9 -0
- package/exports/api/cms/opensearch.js +11 -0
- package/exports/api/cms/opensearch.js.map +1 -0
- package/feature.d.ts +1 -0
- package/feature.js +188 -0
- package/feature.js.map +1 -0
- package/features/CmsEntryOpenSearchBodyModifier/abstractions.d.ts +16 -0
- package/features/CmsEntryOpenSearchBodyModifier/abstractions.js +4 -0
- package/features/CmsEntryOpenSearchBodyModifier/abstractions.js.map +1 -0
- package/features/CmsEntryOpenSearchBodyModifier/index.d.ts +1 -0
- package/features/CmsEntryOpenSearchBodyModifier/index.js +3 -0
- package/features/CmsEntryOpenSearchBodyModifier/index.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.d.ts +13 -0
- package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js +36 -0
- package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.d.ts +35 -0
- package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js +4 -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 +4 -0
- package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/constants.d.ts +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/constants.js +3 -0
- package/features/CmsEntryOpenSearchFieldIndex/constants.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/feature.d.ts +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/feature.js +24 -0
- package/features/CmsEntryOpenSearchFieldIndex/feature.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.d.ts +11 -0
- package/{elasticsearch/indexing/dateTimeIndexing.js → features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js} +21 -19
- package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.d.ts +10 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js +39 -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 +22 -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 +25 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.d.ts +11 -0
- package/{elasticsearch/indexing/numberIndexing.js → features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js} +11 -8
- package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.d.ts +10 -0
- package/{elasticsearch/indexing/objectIndexing.js → features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js} +50 -86
- package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.d.ts +10 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js +22 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/index.d.ts +3 -0
- package/features/CmsEntryOpenSearchFieldIndex/index.js +5 -0
- package/features/CmsEntryOpenSearchFieldIndex/index.js.map +1 -0
- package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.d.ts +11 -0
- package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js +38 -0
- package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js.map +1 -0
- package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.d.ts +37 -0
- package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js +4 -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 +4 -0
- package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js.map +1 -0
- package/features/CmsEntryOpenSearchFilter/constants.d.ts +1 -0
- package/features/CmsEntryOpenSearchFilter/constants.js +3 -0
- package/features/CmsEntryOpenSearchFilter/constants.js.map +1 -0
- package/features/CmsEntryOpenSearchFilter/feature.d.ts +1 -0
- package/features/CmsEntryOpenSearchFilter/feature.js +16 -0
- package/features/CmsEntryOpenSearchFilter/feature.js.map +1 -0
- package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.d.ts +9 -0
- package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js +23 -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 +61 -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 +49 -0
- package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js.map +1 -0
- package/features/CmsEntryOpenSearchFilter/index.d.ts +3 -0
- package/features/CmsEntryOpenSearchFilter/index.js +5 -0
- package/features/CmsEntryOpenSearchFilter/index.js.map +1 -0
- package/features/CmsEntryOpenSearchFullTextSearch/abstractions.d.ts +20 -0
- package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js +4 -0
- package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js.map +1 -0
- package/features/CmsEntryOpenSearchFullTextSearch/index.d.ts +1 -0
- package/features/CmsEntryOpenSearchFullTextSearch/index.js +3 -0
- package/features/CmsEntryOpenSearchFullTextSearch/index.js.map +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 +4 -0
- package/features/CmsEntryOpenSearchIndex/abstractions.js.map +1 -0
- package/features/CmsEntryOpenSearchIndex/feature.d.ts +1 -0
- package/features/CmsEntryOpenSearchIndex/feature.js +10 -0
- package/features/CmsEntryOpenSearchIndex/feature.js.map +1 -0
- package/features/CmsEntryOpenSearchIndex/index.d.ts +3 -0
- package/features/CmsEntryOpenSearchIndex/index.js +5 -0
- package/features/CmsEntryOpenSearchIndex/index.js.map +1 -0
- package/features/CmsEntryOpenSearchQueryModifier/abstractions.d.ts +16 -0
- package/features/CmsEntryOpenSearchQueryModifier/abstractions.js +4 -0
- package/features/CmsEntryOpenSearchQueryModifier/abstractions.js.map +1 -0
- package/features/CmsEntryOpenSearchQueryModifier/index.d.ts +1 -0
- package/features/CmsEntryOpenSearchQueryModifier/index.js +3 -0
- package/features/CmsEntryOpenSearchQueryModifier/index.js.map +1 -0
- package/features/CmsEntryOpenSearchSortModifier/abstractions.d.ts +15 -0
- package/features/CmsEntryOpenSearchSortModifier/abstractions.js +4 -0
- package/features/CmsEntryOpenSearchSortModifier/abstractions.js.map +1 -0
- package/features/CmsEntryOpenSearchSortModifier/index.d.ts +1 -0
- package/features/CmsEntryOpenSearchSortModifier/index.js +3 -0
- package/features/CmsEntryOpenSearchSortModifier/index.js.map +1 -0
- package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.d.ts +12 -0
- package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js +27 -0
- package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -0
- package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.d.ts +22 -0
- package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js +4 -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 +4 -0
- package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -0
- package/features/CmsEntryOpenSearchValueSearch/feature.d.ts +1 -0
- package/features/CmsEntryOpenSearchValueSearch/feature.js +16 -0
- package/features/CmsEntryOpenSearchValueSearch/feature.js.map +1 -0
- package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.d.ts +10 -0
- package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js +23 -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 +55 -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 +24 -0
- package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js.map +1 -0
- package/features/CmsEntryOpenSearchValueSearch/index.d.ts +3 -0
- package/features/CmsEntryOpenSearchValueSearch/index.js +5 -0
- package/features/CmsEntryOpenSearchValueSearch/index.js.map +1 -0
- package/features/CmsEntryOpenSearchValuesModifier/abstractions.d.ts +23 -0
- package/features/CmsEntryOpenSearchValuesModifier/abstractions.js +4 -0
- package/features/CmsEntryOpenSearchValuesModifier/abstractions.js.map +1 -0
- package/features/CmsEntryOpenSearchValuesModifier/index.d.ts +1 -0
- package/features/CmsEntryOpenSearchValuesModifier/index.js +3 -0
- package/features/CmsEntryOpenSearchValuesModifier/index.js.map +1 -0
- package/helpers/entryIndexHelpers.d.ts +5 -3
- package/helpers/entryIndexHelpers.js +28 -90
- package/helpers/entryIndexHelpers.js.map +1 -1
- package/index.d.ts +1 -3
- package/index.js +1 -188
- package/index.js.map +1 -1
- package/operations/entry/elasticsearch/body.d.ts +18 -2
- package/operations/entry/elasticsearch/body.js +32 -29
- package/operations/entry/elasticsearch/body.js.map +1 -1
- package/operations/entry/elasticsearch/fields.d.ts +6 -4
- package/operations/entry/elasticsearch/fields.js +14 -57
- package/operations/entry/elasticsearch/fields.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +5 -4
- package/operations/entry/elasticsearch/filtering/applyFiltering.js +3 -3
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/exec.d.ts +4 -0
- package/operations/entry/elasticsearch/filtering/exec.js +11 -64
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/path.d.ts +4 -3
- package/operations/entry/elasticsearch/filtering/path.js +4 -6
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearch.d.ts +2 -2
- package/operations/entry/elasticsearch/fullTextSearch.js +25 -29
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
- package/operations/entry/elasticsearch/sort.d.ts +2 -2
- package/operations/entry/elasticsearch/sort.js +2 -6
- package/operations/entry/elasticsearch/sort.js.map +1 -1
- package/operations/entry/elasticsearch/transformValueForSearch.d.ts +2 -9
- package/operations/entry/elasticsearch/transformValueForSearch.js +4 -14
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
- package/operations/entry/elasticsearch/types.d.ts +0 -7
- package/operations/entry/elasticsearch/types.js.map +1 -1
- package/operations/entry/index.d.ts +21 -1
- package/operations/entry/index.js +96 -39
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/transformations/index.d.ts +8 -2
- package/operations/entry/transformations/index.js +14 -12
- package/operations/entry/transformations/index.js.map +1 -1
- package/operations/entry/transformations/modifyEntryValues.d.ts +2 -2
- package/operations/entry/transformations/modifyEntryValues.js +3 -3
- package/operations/entry/transformations/modifyEntryValues.js.map +1 -1
- package/operations/entry/transformations/transformEntryToIndex.d.ts +4 -2
- package/operations/entry/transformations/transformEntryToIndex.js +6 -4
- package/operations/entry/transformations/transformEntryToIndex.js.map +1 -1
- package/operations/group/index.d.ts +2 -2
- package/operations/group/index.js +6 -9
- package/operations/group/index.js.map +1 -1
- package/package.json +25 -23
- package/tasks/createIndexTaskPlugin.js +8 -1
- package/tasks/createIndexTaskPlugin.js.map +1 -1
- package/types.d.ts +7 -112
- package/types.js +0 -23
- package/types.js.map +1 -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.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.map +0 -1
- package/elasticsearch/indexing/objectIndexing.d.ts +0 -12
- 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/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/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 -24
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +0 -19
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +0 -1
- package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +0 -4
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +0 -6
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +0 -1
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +0 -32
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +0 -32
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +0 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +0 -19
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +0 -13
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +0 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +0 -19
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +0 -13
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +0 -1
- package/plugins/CmsEntryElasticsearchValuesModifier.d.ts +0 -33
- package/plugins/CmsEntryElasticsearchValuesModifier.js +0 -42
- package/plugins/CmsEntryElasticsearchValuesModifier.js.map +0 -1
- package/plugins/CmsEntryFilterPlugin.d.ts +0 -49
- package/plugins/CmsEntryFilterPlugin.js +0 -15
- package/plugins/CmsEntryFilterPlugin.js.map +0 -1
- package/plugins/index.d.ts +0 -8
- package/plugins/index.js +0 -10
- package/plugins/index.js.map +0 -1
|
@@ -1 +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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AAK;UACLP,mBAAmB;UACnBG,kBAAkB;UAClBS,KAAK,EAAElB,KAAK,CAACW,MAAM,CAACsB,GAAG,IAAIE,MAAM,CAAC;UAClC;AACpB;AACA;UACoBhB,QAAQ,EAAEnB,KAAK,CAACY,SAAS,GAAGZ,KAAK,CAACY,SAAS,CAACuB,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,"names":["WebinyError","getFieldIdentifier","getFieldIdentifiers","prepareEntryToIndex","params","fieldRegistry","fieldIndexRegistry","storageEntry","entry","model","getFieldIndex","type","fieldIndexing","get","getDefault","values","rawValues","field","fields","identifier","fieldIndex","value","rawValue","toIndex","extractEntriesFromIndex","entries","list","indexValues","fieldType","identifiers","key","valueIdentifier","rawKey","rawValueIdentifier","fromIndex","ex","message","code","newEntry","push"],"sources":["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<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 { fieldRegistry, 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 fieldRegistry,\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 fieldRegistry,\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"],"mappings":"AAAA,SAASA,WAAW,QAAQ,eAAe;AAG3C,SAASC,kBAAkB,EAAEC,mBAAmB;AAyBhD,OAAO,MAAMC,mBAAmB,GAC5BC,MAAyC,IACtB;EACnB,MAAM;IAAEC,aAAa;IAAEC,kBAAkB;IAAEC,YAAY;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGL,MAAM;EAEhF,SAASM,aAAaA,CAACC,IAAY,EAA0C;IACzE,MAAMC,aAAa,GAAGN,kBAAkB,CAACO,GAAG,CAACF,IAAI,CAAC;IAClD,IAAIC,aAAa,EAAE;MACf,OAAOA,aAAa;IACxB;IACA,OAAON,kBAAkB,CAACQ,UAAU,CAAC,CAAC;EAC1C;;EAEA;EACA,MAAMC,MAAS,GAAG,CAAC,CAAM;EACzB,MAAMC,SAAY,GAAG,CAAC,CAAM;;EAE5B;EACA,KAAK,MAAMC,KAAK,IAAIR,KAAK,CAACS,MAAM,EAAE;IAC9B,MAAMC,UAAU,GAAGlB,kBAAkB,CAACM,YAAY,CAACQ,MAAM,EAAEE,KAAK,CAAY;IAC5E,IAAI,CAACE,UAAU,EAAE;MACb;IACJ;IAEA,MAAMC,UAAU,GAAGV,aAAa,CAACO,KAAK,CAACN,IAAI,CAAC;IAE5C,MAAM;MAAEU,KAAK;MAAEC;IAAS,CAAC,GAAGF,UAAU,CAACG,OAAO,CAAC;MAC3ClB,aAAa;MACbI,KAAK;MACLQ,KAAK;MACLK,QAAQ,EAAEd,KAAK,CAACO,MAAM,CAACI,UAAU,CAAC;MAClCE,KAAK,EAAEd,YAAY,CAACQ,MAAM,CAACI,UAAU,CAAC;MACtCT;IACJ,CAAC,CAAC;IAEF,IAAI,OAAO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B;QAClD,MAAMC,MAAM,GAAGH,WAAW,CAACI,kBAA6B;QACxDN,WAAW,CAACG,GAAG,CAAC,GAAGV,UAAU,CAACc,SAAS,CAAC;UACpC7B,aAAa;UACbI,KAAK;UACLQ,KAAK;UACLP,aAAa;UACbW,KAAK,EAAEb,KAAK,CAACO,MAAM,CAACe,GAAG,IAAIE,MAAM,CAAC;UAClC;AACpB;AACA;UACoBV,QAAQ,EAAEd,KAAK,CAACQ,SAAS,GAAGR,KAAK,CAACQ,SAAS,CAACgB,MAAM,IAAIF,GAAG,CAAC,GAAG;QACjE,CAAC,CAAC;MACN,CAAC,CAAC,OAAOK,EAAE,EAAE;QACT,MAAM,IAAInC,WAAW,CACjBmC,EAAE,CAACC,OAAO,IAAI,6CAA6C,EAC3DD,EAAE,CAACE,IAAI,IAAI,wBAAwB,EACnC;UACIpB,KAAK;UACLT;QACJ,CACJ,CAAC;MACL;IACJ;IACA;AACR;AACA;IACQ,MAAM8B,QAAqB,GAAG;MAC1B,GAAG9B,KAAK;MACRO,MAAM,EAAEY;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":[]}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,190 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import elasticsearchPlugins from "./elasticsearch/index.js";
|
|
3
|
-
import dynamoDbPlugins from "./dynamoDb/index.js";
|
|
4
|
-
import { createModelsStorageOperations } from "./operations/model/index.js";
|
|
5
|
-
import { createEntriesStorageOperations } from "./operations/entry/index.js";
|
|
6
|
-
import { ENTITIES } from "./types.js";
|
|
7
|
-
import { createGroupEntity } from "./definitions/group.js";
|
|
8
|
-
import { createModelEntity } from "./definitions/model.js";
|
|
9
|
-
import { createEntryEntity } from "./definitions/entry.js";
|
|
10
|
-
import { createElasticsearchIndex } from "./elasticsearch/createElasticsearchIndex.js";
|
|
11
|
-
import { PluginsContainer } from "@webiny/plugins";
|
|
12
|
-
import { createGroupsStorageOperations } from "./operations/group/index.js";
|
|
13
|
-
import { createOpenSearchEntity, createOpenSearchTable, OpenSearchQueryBuilderOperatorPlugin } from "@webiny/api-opensearch";
|
|
14
|
-
import { elasticsearchIndexPlugins } from "./elasticsearch/indices/index.js";
|
|
15
|
-
import { deleteElasticsearchIndex } from "./elasticsearch/deleteElasticsearchIndex.js";
|
|
16
|
-
import { CmsElasticsearchModelFieldPlugin, CmsEntryElasticsearchBodyModifierPlugin, CmsEntryElasticsearchFullTextSearchPlugin, CmsEntryElasticsearchIndexPlugin, CmsEntryElasticsearchQueryBuilderValueSearchPlugin, CmsEntryElasticsearchQueryModifierPlugin, CmsEntryElasticsearchSortModifierPlugin, CmsEntryElasticsearchValuesModifier } from "./plugins/index.js";
|
|
17
|
-
import { createFilterPlugins } from "./operations/entry/elasticsearch/filtering/plugins/index.js";
|
|
18
|
-
import { CmsEntryFilterPlugin } from "./plugins/CmsEntryFilterPlugin.js";
|
|
19
|
-
import { StorageOperationsCmsModelPlugin, StorageTransformPlugin } from "@webiny/api-headless-cms";
|
|
20
|
-
import { createCreateIndexTask } from "./tasks/createIndexTaskPlugin.js";
|
|
21
|
-
import { CompressorPlugin } from "@webiny/api";
|
|
22
|
-
import { ModelAfterCreateEventHandler } from "@webiny/api-headless-cms/features/contentModel/CreateModel/index.js";
|
|
23
|
-
import { ModelAfterCreateFromEventHandler } from "@webiny/api-headless-cms/features/contentModel/CreateModelFrom/events.js";
|
|
24
|
-
import { ModelAfterDeleteEventHandler } from "@webiny/api-headless-cms/features/contentModel/DeleteModel/events.js";
|
|
25
|
-
import { createTable } from "@webiny/db-dynamodb";
|
|
26
|
-
export * from "./plugins/index.js";
|
|
27
|
-
export const createStorageOperations = params => {
|
|
28
|
-
const {
|
|
29
|
-
table,
|
|
30
|
-
esTable,
|
|
31
|
-
documentClient,
|
|
32
|
-
elasticsearch,
|
|
33
|
-
plugins: userPlugins
|
|
34
|
-
} = params;
|
|
35
|
-
const tableInstance = createTable({
|
|
36
|
-
name: table || process.env.DB_TABLE,
|
|
37
|
-
documentClient
|
|
38
|
-
});
|
|
39
|
-
const tableElasticsearchInstance = createOpenSearchTable({
|
|
40
|
-
name: esTable,
|
|
41
|
-
documentClient
|
|
42
|
-
});
|
|
43
|
-
const entities = {
|
|
44
|
-
groups: createGroupEntity({
|
|
45
|
-
entityName: ENTITIES.GROUPS,
|
|
46
|
-
table: tableInstance
|
|
47
|
-
}),
|
|
48
|
-
models: createModelEntity({
|
|
49
|
-
entityName: ENTITIES.MODELS,
|
|
50
|
-
table: tableInstance
|
|
51
|
-
}),
|
|
52
|
-
entries: createEntryEntity({
|
|
53
|
-
entityName: ENTITIES.ENTRIES,
|
|
54
|
-
table: tableInstance
|
|
55
|
-
}),
|
|
56
|
-
entriesEs: createOpenSearchEntity({
|
|
57
|
-
entityName: ENTITIES.ENTRIES_ES,
|
|
58
|
-
table: tableElasticsearchInstance
|
|
59
|
-
})
|
|
60
|
-
};
|
|
61
|
-
const plugins = new PluginsContainer([
|
|
62
|
-
/**
|
|
63
|
-
* DynamoDB filter plugins for the where conditions.
|
|
64
|
-
*/
|
|
65
|
-
dynamoDbValueFilters(),
|
|
66
|
-
/**
|
|
67
|
-
* Field plugins for DynamoDB.
|
|
68
|
-
*/
|
|
69
|
-
dynamoDbPlugins(),
|
|
70
|
-
/**
|
|
71
|
-
* Field plugins for Elasticsearch.
|
|
72
|
-
*/
|
|
73
|
-
elasticsearchPlugins(),
|
|
74
|
-
/**
|
|
75
|
-
* Built-in Elasticsearch index templates.
|
|
76
|
-
*/
|
|
77
|
-
elasticsearchIndexPlugins(),
|
|
78
|
-
/**
|
|
79
|
-
* Filter plugins used to apply filtering from where conditions to Elasticsearch query.
|
|
80
|
-
*/
|
|
81
|
-
createFilterPlugins(),
|
|
82
|
-
/**
|
|
83
|
-
* User defined custom plugins.
|
|
84
|
-
* They are at the end because we can then override existing plugins.
|
|
85
|
-
*/
|
|
86
|
-
...(userPlugins || [])]);
|
|
87
|
-
const entries = createEntriesStorageOperations({
|
|
88
|
-
entity: entities.entries,
|
|
89
|
-
esEntity: entities.entriesEs,
|
|
90
|
-
plugins,
|
|
91
|
-
elasticsearch
|
|
92
|
-
});
|
|
93
|
-
return {
|
|
94
|
-
name: "dynamodb:elasticsearch",
|
|
95
|
-
beforeInit: async context => {
|
|
96
|
-
context.db.registry.register({
|
|
97
|
-
item: entities.entries,
|
|
98
|
-
app: "cms",
|
|
99
|
-
tags: ["regular", entities.entries.name]
|
|
100
|
-
});
|
|
101
|
-
context.db.registry.register({
|
|
102
|
-
item: entities.entriesEs,
|
|
103
|
-
app: "cms",
|
|
104
|
-
tags: ["es", entities.entriesEs.name]
|
|
105
|
-
});
|
|
106
|
-
/**
|
|
107
|
-
* Attach the elasticsearch into context if it is not already attached.
|
|
108
|
-
*/
|
|
109
|
-
if (!context.opensearch) {
|
|
110
|
-
context.opensearch = elasticsearch;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* This registers the task implementation
|
|
115
|
-
*/
|
|
116
|
-
createCreateIndexTask(context);
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Pass the plugins to the parent context.
|
|
120
|
-
*/
|
|
121
|
-
context.plugins.register([dynamoDbPlugins(), elasticsearchIndexPlugins()]);
|
|
122
|
-
/**
|
|
123
|
-
* We need to fetch all the plugin types in the list from the main container.
|
|
124
|
-
* This way we do not need to register plugins in the storage plugins contains.
|
|
125
|
-
*/
|
|
126
|
-
const types = [OpenSearchQueryBuilderOperatorPlugin.type,
|
|
127
|
-
// Headless CMS
|
|
128
|
-
"cms-model-field-to-graphql", CmsEntryFilterPlugin.type, CmsEntryElasticsearchBodyModifierPlugin.type, CmsEntryElasticsearchFullTextSearchPlugin.type, CmsEntryElasticsearchIndexPlugin.type, CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type, CmsEntryElasticsearchQueryModifierPlugin.type, CmsEntryElasticsearchSortModifierPlugin.type, CmsElasticsearchModelFieldPlugin.type, StorageOperationsCmsModelPlugin.type, StorageTransformPlugin.type, CmsEntryElasticsearchValuesModifier.type, CompressorPlugin.type];
|
|
129
|
-
for (const type of types) {
|
|
130
|
-
plugins.mergeByType(context.plugins, type);
|
|
131
|
-
}
|
|
132
|
-
entries.dataLoaders.clearAll();
|
|
133
|
-
},
|
|
134
|
-
init: async context => {
|
|
135
|
-
/**
|
|
136
|
-
* TODO @pavel
|
|
137
|
-
* Moved operations to AFTER create/from because at in before the model does not have modelId - to create the index.
|
|
138
|
-
*/
|
|
139
|
-
context.container.registerFactory(ModelAfterCreateEventHandler, () => ({
|
|
140
|
-
async handle(event) {
|
|
141
|
-
const {
|
|
142
|
-
model
|
|
143
|
-
} = event.payload;
|
|
144
|
-
await createElasticsearchIndex({
|
|
145
|
-
client: elasticsearch,
|
|
146
|
-
model,
|
|
147
|
-
plugins
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}));
|
|
151
|
-
context.container.registerFactory(ModelAfterCreateFromEventHandler, () => ({
|
|
152
|
-
async handle(event) {
|
|
153
|
-
const {
|
|
154
|
-
model
|
|
155
|
-
} = event.payload;
|
|
156
|
-
await createElasticsearchIndex({
|
|
157
|
-
client: elasticsearch,
|
|
158
|
-
model,
|
|
159
|
-
plugins
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
}));
|
|
163
|
-
context.container.registerFactory(ModelAfterDeleteEventHandler, () => ({
|
|
164
|
-
async handle(event) {
|
|
165
|
-
const {
|
|
166
|
-
model
|
|
167
|
-
} = event.payload;
|
|
168
|
-
await deleteElasticsearchIndex({
|
|
169
|
-
client: elasticsearch,
|
|
170
|
-
model
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}));
|
|
174
|
-
},
|
|
175
|
-
getEntities: () => entities,
|
|
176
|
-
getTable: () => tableInstance,
|
|
177
|
-
getEsTable: () => tableElasticsearchInstance,
|
|
178
|
-
groups: createGroupsStorageOperations({
|
|
179
|
-
entity: entities.groups,
|
|
180
|
-
plugins
|
|
181
|
-
}),
|
|
182
|
-
models: createModelsStorageOperations({
|
|
183
|
-
entity: entities.models,
|
|
184
|
-
elasticsearch
|
|
185
|
-
}),
|
|
186
|
-
entries
|
|
187
|
-
};
|
|
188
|
-
};
|
|
1
|
+
export { registerCmsOpenSearchStorageOperations } from "./feature.js";
|
|
189
2
|
|
|
190
3
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["dynamoDbValueFilters","elasticsearchPlugins","dynamoDbPlugins","createModelsStorageOperations","createEntriesStorageOperations","ENTITIES","createGroupEntity","createModelEntity","createEntryEntity","createElasticsearchIndex","PluginsContainer","createGroupsStorageOperations","createOpenSearchEntity","createOpenSearchTable","OpenSearchQueryBuilderOperatorPlugin","elasticsearchIndexPlugins","deleteElasticsearchIndex","CmsElasticsearchModelFieldPlugin","CmsEntryElasticsearchBodyModifierPlugin","CmsEntryElasticsearchFullTextSearchPlugin","CmsEntryElasticsearchIndexPlugin","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","CmsEntryElasticsearchQueryModifierPlugin","CmsEntryElasticsearchSortModifierPlugin","CmsEntryElasticsearchValuesModifier","createFilterPlugins","CmsEntryFilterPlugin","StorageOperationsCmsModelPlugin","StorageTransformPlugin","createCreateIndexTask","CompressorPlugin","ModelAfterCreateEventHandler","ModelAfterCreateFromEventHandler","ModelAfterDeleteEventHandler","createTable","createStorageOperations","params","table","esTable","documentClient","elasticsearch","plugins","userPlugins","tableInstance","name","process","env","DB_TABLE","tableElasticsearchInstance","entities","groups","entityName","GROUPS","models","MODELS","entries","ENTRIES","entriesEs","ENTRIES_ES","entity","esEntity","beforeInit","context","db","registry","register","item","app","tags","opensearch","types","type","mergeByType","dataLoaders","clearAll","init","container","registerFactory","handle","event","model","payload","client","getEntities","getTable","getEsTable"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters/index.js\";\nimport elasticsearchPlugins from \"./elasticsearch/index.js\";\nimport dynamoDbPlugins from \"./dynamoDb/index.js\";\nimport { createModelsStorageOperations } from \"./operations/model/index.js\";\nimport { createEntriesStorageOperations } from \"./operations/entry/index.js\";\nimport type { StorageOperationsFactory } from \"~/types.js\";\nimport { ENTITIES } from \"~/types.js\";\nimport { createGroupEntity } from \"~/definitions/group.js\";\nimport { createModelEntity } from \"~/definitions/model.js\";\nimport { createEntryEntity } from \"~/definitions/entry.js\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex.js\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createGroupsStorageOperations } from \"~/operations/group/index.js\";\nimport {\n createOpenSearchEntity,\n createOpenSearchTable,\n OpenSearchQueryBuilderOperatorPlugin\n} from \"@webiny/api-opensearch\";\nimport { elasticsearchIndexPlugins } from \"./elasticsearch/indices/index.js\";\nimport { deleteElasticsearchIndex } from \"./elasticsearch/deleteElasticsearchIndex.js\";\nimport {\n CmsElasticsearchModelFieldPlugin,\n CmsEntryElasticsearchBodyModifierPlugin,\n CmsEntryElasticsearchFullTextSearchPlugin,\n CmsEntryElasticsearchIndexPlugin,\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin,\n CmsEntryElasticsearchQueryModifierPlugin,\n CmsEntryElasticsearchSortModifierPlugin,\n CmsEntryElasticsearchValuesModifier\n} from \"~/plugins/index.js\";\nimport { createFilterPlugins } from \"~/operations/entry/elasticsearch/filtering/plugins/index.js\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin.js\";\nimport { StorageOperationsCmsModelPlugin, StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { createCreateIndexTask } from \"~/tasks/createIndexTaskPlugin.js\";\nimport { CompressorPlugin } from \"@webiny/api\";\nimport { ModelAfterCreateEventHandler } from \"@webiny/api-headless-cms/features/contentModel/CreateModel/index.js\";\nimport { ModelAfterCreateFromEventHandler } from \"@webiny/api-headless-cms/features/contentModel/CreateModelFrom/events.js\";\nimport { ModelAfterDeleteEventHandler } from \"@webiny/api-headless-cms/features/contentModel/DeleteModel/events.js\";\nimport { createTable } from \"@webiny/db-dynamodb\";\n\nexport * from \"./plugins/index.js\";\n\nexport const createStorageOperations: StorageOperationsFactory = params => {\n const { table, esTable, documentClient, elasticsearch, plugins: userPlugins } = params;\n\n const tableInstance = createTable({\n name: table || (process.env.DB_TABLE as string),\n documentClient\n });\n const tableElasticsearchInstance = createOpenSearchTable({\n name: esTable,\n documentClient\n });\n\n const entities = {\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance\n }),\n entriesEs: createOpenSearchEntity({\n entityName: ENTITIES.ENTRIES_ES,\n table: tableElasticsearchInstance\n })\n };\n\n const plugins = new PluginsContainer([\n /**\n * DynamoDB filter plugins for the where conditions.\n */\n dynamoDbValueFilters(),\n /**\n * Field plugins for DynamoDB.\n */\n dynamoDbPlugins(),\n /**\n * Field plugins for Elasticsearch.\n */\n elasticsearchPlugins(),\n /**\n * Built-in Elasticsearch index templates.\n */\n elasticsearchIndexPlugins(),\n /**\n * Filter plugins used to apply filtering from where conditions to Elasticsearch query.\n */\n createFilterPlugins(),\n /**\n * User defined custom plugins.\n * They are at the end because we can then override existing plugins.\n */\n ...(userPlugins || [])\n ]);\n\n const entries = createEntriesStorageOperations({\n entity: entities.entries,\n esEntity: entities.entriesEs,\n plugins,\n elasticsearch\n });\n\n return {\n name: \"dynamodb:elasticsearch\",\n beforeInit: async context => {\n context.db.registry.register({\n item: entities.entries,\n app: \"cms\",\n tags: [\"regular\", entities.entries.name]\n });\n context.db.registry.register({\n item: entities.entriesEs,\n app: \"cms\",\n tags: [\"es\", entities.entriesEs.name]\n });\n /**\n * Attach the elasticsearch into context if it is not already attached.\n */\n if (!context.opensearch) {\n context.opensearch = elasticsearch;\n }\n\n /**\n * This registers the task implementation\n */\n createCreateIndexTask(context);\n\n /**\n * Pass the plugins to the parent context.\n */\n context.plugins.register([dynamoDbPlugins(), elasticsearchIndexPlugins()]);\n /**\n * We need to fetch all the plugin types in the list from the main container.\n * This way we do not need to register plugins in the storage plugins contains.\n */\n const types: string[] = [\n OpenSearchQueryBuilderOperatorPlugin.type,\n // Headless CMS\n \"cms-model-field-to-graphql\",\n CmsEntryFilterPlugin.type,\n CmsEntryElasticsearchBodyModifierPlugin.type,\n CmsEntryElasticsearchFullTextSearchPlugin.type,\n CmsEntryElasticsearchIndexPlugin.type,\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type,\n CmsEntryElasticsearchQueryModifierPlugin.type,\n CmsEntryElasticsearchSortModifierPlugin.type,\n CmsElasticsearchModelFieldPlugin.type,\n StorageOperationsCmsModelPlugin.type,\n StorageTransformPlugin.type,\n CmsEntryElasticsearchValuesModifier.type,\n CompressorPlugin.type\n ];\n for (const type of types) {\n plugins.mergeByType(context.plugins, type);\n }\n entries.dataLoaders.clearAll();\n },\n init: async context => {\n /**\n * TODO @pavel\n * Moved operations to AFTER create/from because at in before the model does not have modelId - to create the index.\n */\n context.container.registerFactory(ModelAfterCreateEventHandler, () => ({\n async handle(event) {\n const { model } = event.payload;\n await createElasticsearchIndex({\n client: elasticsearch,\n model,\n plugins\n });\n }\n }));\n\n context.container.registerFactory(ModelAfterCreateFromEventHandler, () => ({\n async handle(event) {\n const { model } = event.payload;\n await createElasticsearchIndex({\n client: elasticsearch,\n model,\n plugins\n });\n }\n }));\n\n context.container.registerFactory(ModelAfterDeleteEventHandler, () => ({\n async handle(event) {\n const { model } = event.payload;\n await deleteElasticsearchIndex({\n client: elasticsearch,\n model\n });\n }\n }));\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n getEsTable: () => tableElasticsearchInstance,\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n plugins\n }),\n models: createModelsStorageOperations({\n entity: entities.models,\n elasticsearch\n }),\n entries\n };\n};\n"],"mappings":"AAAA,OAAOA,oBAAoB,MAAM,8CAA8C;AAC/E,OAAOC,oBAAoB;AAC3B,OAAOC,eAAe;AACtB,SAASC,6BAA6B;AACtC,SAASC,8BAA8B;AAEvC,SAASC,QAAQ;AACjB,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,wBAAwB;AACjC,SAASC,gBAAgB,QAAQ,iBAAiB;AAClD,SAASC,6BAA6B;AACtC,SACIC,sBAAsB,EACtBC,qBAAqB,EACrBC,oCAAoC,QACjC,wBAAwB;AAC/B,SAASC,yBAAyB;AAClC,SAASC,wBAAwB;AACjC,SACIC,gCAAgC,EAChCC,uCAAuC,EACvCC,yCAAyC,EACzCC,gCAAgC,EAChCC,kDAAkD,EAClDC,wCAAwC,EACxCC,uCAAuC,EACvCC,mCAAmC;AAEvC,SAASC,mBAAmB;AAC5B,SAASC,oBAAoB;AAC7B,SAASC,+BAA+B,EAAEC,sBAAsB,QAAQ,0BAA0B;AAClG,SAASC,qBAAqB;AAC9B,SAASC,gBAAgB,QAAQ,aAAa;AAC9C,SAASC,4BAA4B,QAAQ,qEAAqE;AAClH,SAASC,gCAAgC,QAAQ,0EAA0E;AAC3H,SAASC,4BAA4B,QAAQ,sEAAsE;AACnH,SAASC,WAAW,QAAQ,qBAAqB;AAEjD;AAEA,OAAO,MAAMC,uBAAiD,GAAGC,MAAM,IAAI;EACvE,MAAM;IAAEC,KAAK;IAAEC,OAAO;IAAEC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EA,CAAA,KAAMlC,QAAQ;IAC3BmC,QAAQ,EAAEA,CAAA,KAAMzC,aAAa;IAC7B0C,UAAU,EAAEA,CAAA,KAAMrC,0BAA0B;IAC5CE,MAAM,EAAEvC,6BAA6B,CAAC;MAClCgD,MAAM,EAAEV,QAAQ,CAACC,MAAM;MACvBT;IACJ,CAAC,CAAC;IACFY,MAAM,EAAElD,6BAA6B,CAAC;MAClCwD,MAAM,EAAEV,QAAQ,CAACI,MAAM;MACvBb;IACJ,CAAC,CAAC;IACFe;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["registerCmsOpenSearchStorageOperations"],"sources":["index.ts"],"sourcesContent":["export { registerCmsOpenSearchStorageOperations } from \"./feature.js\";\n"],"mappings":"AAAA,SAASA,sCAAsC","ignoreList":[]}
|
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
import type { PluginsContainer } from "@webiny/plugins";
|
|
2
2
|
import type { CmsEntryListParams, CmsEntryListWhere, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
+
import type { CmsEntryOpenSearchBodyModifier } from "../../../features/CmsEntryOpenSearchBodyModifier/index.js";
|
|
4
|
+
import type { CmsEntryOpenSearchSortModifier } from "../../../features/CmsEntryOpenSearchSortModifier/index.js";
|
|
5
|
+
import type { CmsEntryOpenSearchQueryModifier } from "../../../features/CmsEntryOpenSearchQueryModifier/index.js";
|
|
6
|
+
import type { CmsEntryOpenSearchValueSearchRegistry } from "../../../features/CmsEntryOpenSearchValueSearch/index.js";
|
|
7
|
+
import type { CmsEntryOpenSearchFullTextSearch } from "../../../features/CmsEntryOpenSearchFullTextSearch/index.js";
|
|
3
8
|
import type { PrimitiveValue, SearchBody } from "@webiny/api-opensearch/types.js";
|
|
4
|
-
|
|
9
|
+
import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/features/graphql/index.js";
|
|
10
|
+
import { CmsEntryOpenSearchFieldIndexRegistry } from "../../../features/CmsEntryOpenSearchFieldIndex/index.js";
|
|
11
|
+
import type { CmsEntryOpenSearchFilterRegistry } from "../../../features/CmsEntryOpenSearchFilter/index.js";
|
|
12
|
+
interface ICreateElasticsearchBodyParams {
|
|
5
13
|
plugins: PluginsContainer;
|
|
6
14
|
model: CmsModel;
|
|
15
|
+
fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;
|
|
16
|
+
fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface;
|
|
17
|
+
bodyModifiers: CmsEntryOpenSearchBodyModifier.Interface[];
|
|
18
|
+
sortModifiers: CmsEntryOpenSearchSortModifier.Interface[];
|
|
19
|
+
queryModifiers: CmsEntryOpenSearchQueryModifier.Interface[];
|
|
20
|
+
valueSearchRegistry: CmsEntryOpenSearchValueSearchRegistry.Interface;
|
|
21
|
+
fullTextSearches: CmsEntryOpenSearchFullTextSearch.Interface[];
|
|
22
|
+
filterRegistry: CmsEntryOpenSearchFilterRegistry.Interface;
|
|
7
23
|
params: Omit<CmsEntryListParams, "where" | "after"> & {
|
|
8
24
|
where: CmsEntryListWhere;
|
|
9
25
|
after?: PrimitiveValue[];
|
|
10
26
|
};
|
|
11
27
|
}
|
|
12
|
-
export declare const createElasticsearchBody: ({ plugins, model, params }:
|
|
28
|
+
export declare const createElasticsearchBody: ({ plugins, model, params, fieldRegistry, fieldIndexRegistry, bodyModifiers, sortModifiers, queryModifiers, valueSearchRegistry, fullTextSearches, filterRegistry }: ICreateElasticsearchBodyParams) => SearchBody;
|
|
13
29
|
export {};
|
|
@@ -2,16 +2,21 @@ import { createModelFields } from "./fields.js";
|
|
|
2
2
|
import { createFullTextSearchFields } from "./fullTextSearchFields.js";
|
|
3
3
|
import { createInitialQuery } from "./initialQuery.js";
|
|
4
4
|
import { applyFullTextSearch } from "./fullTextSearch.js";
|
|
5
|
-
import { createQueryModifierPluginList } from "./plugins/queryModifier.js";
|
|
6
|
-
import { createSortModifierPluginList } from "./plugins/sortModifier.js";
|
|
7
|
-
import { createBodyModifierPluginList } from "./plugins/bodyModifier.js";
|
|
8
5
|
import { createElasticsearchSort } from "./sort.js";
|
|
9
6
|
import { createExecFiltering } from "./filtering/index.js";
|
|
10
7
|
import { assignMinimumShouldMatchToQuery } from "./assignMinimumShouldMatchToQuery.js";
|
|
11
8
|
export const createElasticsearchBody = ({
|
|
12
9
|
plugins,
|
|
13
10
|
model,
|
|
14
|
-
params
|
|
11
|
+
params,
|
|
12
|
+
fieldRegistry,
|
|
13
|
+
fieldIndexRegistry,
|
|
14
|
+
bodyModifiers,
|
|
15
|
+
sortModifiers,
|
|
16
|
+
queryModifiers,
|
|
17
|
+
valueSearchRegistry,
|
|
18
|
+
fullTextSearches,
|
|
19
|
+
filterRegistry
|
|
15
20
|
}) => {
|
|
16
21
|
const {
|
|
17
22
|
fields,
|
|
@@ -25,30 +30,26 @@ export const createElasticsearchBody = ({
|
|
|
25
30
|
* We need the model fields constructed as a key -> field value, so we do not need to iterate through array when we require some field.
|
|
26
31
|
*/
|
|
27
32
|
const modelFields = createModelFields({
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
model,
|
|
34
|
+
fieldRegistry,
|
|
35
|
+
fieldIndexRegistry
|
|
30
36
|
});
|
|
31
37
|
|
|
32
38
|
/**
|
|
33
|
-
*
|
|
39
|
+
* Filter query modifiers applicable to this model.
|
|
34
40
|
*/
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
model
|
|
41
|
+
const applicableQueryModifiers = queryModifiers.filter(m => {
|
|
42
|
+
return !m.modelId || m.modelId === model.modelId;
|
|
38
43
|
});
|
|
39
44
|
/**
|
|
40
|
-
*
|
|
45
|
+
* Filter sort modifiers applicable to this model.
|
|
41
46
|
*/
|
|
42
|
-
const
|
|
43
|
-
plugins,
|
|
44
|
-
model
|
|
45
|
-
});
|
|
47
|
+
const applicableSortModifiers = sortModifiers.filter(m => !m.modelId || m.modelId === model.modelId);
|
|
46
48
|
/**
|
|
47
|
-
*
|
|
49
|
+
* Filter body modifiers applicable to this model.
|
|
48
50
|
*/
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
model
|
|
51
|
+
const applicableBodyModifiers = bodyModifiers.filter(m => {
|
|
52
|
+
return !m.modelId || m.modelId === model.modelId;
|
|
52
53
|
});
|
|
53
54
|
/**
|
|
54
55
|
* We need the fields which we can search through via the full text search.
|
|
@@ -71,7 +72,7 @@ export const createElasticsearchBody = ({
|
|
|
71
72
|
*/
|
|
72
73
|
applyFullTextSearch({
|
|
73
74
|
model,
|
|
74
|
-
|
|
75
|
+
fullTextSearches,
|
|
75
76
|
query,
|
|
76
77
|
term,
|
|
77
78
|
fields: fullTextSearchFields
|
|
@@ -79,27 +80,29 @@ export const createElasticsearchBody = ({
|
|
|
79
80
|
const execFiltering = createExecFiltering({
|
|
80
81
|
model,
|
|
81
82
|
fields: modelFields,
|
|
82
|
-
plugins
|
|
83
|
+
plugins,
|
|
84
|
+
valueSearchRegistry,
|
|
85
|
+
filterRegistry
|
|
83
86
|
});
|
|
84
87
|
execFiltering({
|
|
85
88
|
where,
|
|
86
89
|
query
|
|
87
90
|
});
|
|
88
|
-
for (const
|
|
89
|
-
|
|
91
|
+
for (const modifier of applicableQueryModifiers) {
|
|
92
|
+
modifier.modifyQuery({
|
|
90
93
|
query,
|
|
91
94
|
model,
|
|
92
95
|
where
|
|
93
96
|
});
|
|
94
97
|
}
|
|
95
98
|
const sort = createElasticsearchSort({
|
|
96
|
-
plugins,
|
|
97
99
|
sort: initialSort,
|
|
98
100
|
modelFields,
|
|
99
|
-
model
|
|
101
|
+
model,
|
|
102
|
+
valueSearchRegistry
|
|
100
103
|
});
|
|
101
|
-
for (const
|
|
102
|
-
|
|
104
|
+
for (const modifier of applicableSortModifiers) {
|
|
105
|
+
modifier.modifySort({
|
|
103
106
|
sort,
|
|
104
107
|
model
|
|
105
108
|
});
|
|
@@ -122,8 +125,8 @@ export const createElasticsearchBody = ({
|
|
|
122
125
|
search_after: after,
|
|
123
126
|
track_total_hits: true
|
|
124
127
|
};
|
|
125
|
-
for (const
|
|
126
|
-
|
|
128
|
+
for (const modifier of applicableBodyModifiers) {
|
|
129
|
+
modifier.modifyBody({
|
|
127
130
|
body,
|
|
128
131
|
model,
|
|
129
132
|
where
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createModelFields","createFullTextSearchFields","createInitialQuery","applyFullTextSearch","
|
|
1
|
+
{"version":3,"names":["createModelFields","createFullTextSearchFields","createInitialQuery","applyFullTextSearch","createElasticsearchSort","createExecFiltering","assignMinimumShouldMatchToQuery","createElasticsearchBody","plugins","model","params","fieldRegistry","fieldIndexRegistry","bodyModifiers","sortModifiers","queryModifiers","valueSearchRegistry","fullTextSearches","filterRegistry","fields","search","term","where","sort","initialSort","after","limit","modelFields","applicableQueryModifiers","filter","m","modelId","applicableSortModifiers","applicableBodyModifiers","fullTextSearchFields","targets","query","execFiltering","modifier","modifyQuery","modifySort","boolQuery","must","length","undefined","must_not","should","body","bool","size","search_after","track_total_hits","modifyBody"],"sources":["body.ts"],"sourcesContent":["import type { PluginsContainer } from \"@webiny/plugins\";\nimport type {\n CmsEntryListParams,\n CmsEntryListWhere,\n CmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { createModelFields } from \"./fields.js\";\nimport { createFullTextSearchFields } from \"./fullTextSearchFields.js\";\nimport { createInitialQuery } from \"./initialQuery.js\";\nimport { applyFullTextSearch } from \"./fullTextSearch.js\";\nimport type { CmsEntryOpenSearchBodyModifier } from \"~/features/CmsEntryOpenSearchBodyModifier/index.js\";\nimport type { CmsEntryOpenSearchSortModifier } from \"~/features/CmsEntryOpenSearchSortModifier/index.js\";\nimport type { CmsEntryOpenSearchQueryModifier } from \"~/features/CmsEntryOpenSearchQueryModifier/index.js\";\nimport type { CmsEntryOpenSearchValueSearchRegistry } from \"~/features/CmsEntryOpenSearchValueSearch/index.js\";\nimport type { CmsEntryOpenSearchFullTextSearch } from \"~/features/CmsEntryOpenSearchFullTextSearch/index.js\";\nimport { createElasticsearchSort } from \"./sort.js\";\nimport type {\n PrimitiveValue,\n QueryDslBoolQuery as BoolQueryConfig,\n SearchBody\n} from \"@webiny/api-opensearch/types.js\";\nimport { createExecFiltering } from \"./filtering/index.js\";\nimport { assignMinimumShouldMatchToQuery } from \"./assignMinimumShouldMatchToQuery.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/features/graphql/index.js\";\nimport { CmsEntryOpenSearchFieldIndexRegistry } from \"~/features/CmsEntryOpenSearchFieldIndex/index.js\";\nimport type { CmsEntryOpenSearchFilterRegistry } from \"~/features/CmsEntryOpenSearchFilter/index.js\";\n\ninterface ICreateElasticsearchBodyParams {\n plugins: PluginsContainer;\n model: CmsModel;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface;\n bodyModifiers: CmsEntryOpenSearchBodyModifier.Interface[];\n sortModifiers: CmsEntryOpenSearchSortModifier.Interface[];\n queryModifiers: CmsEntryOpenSearchQueryModifier.Interface[];\n valueSearchRegistry: CmsEntryOpenSearchValueSearchRegistry.Interface;\n fullTextSearches: CmsEntryOpenSearchFullTextSearch.Interface[];\n filterRegistry: CmsEntryOpenSearchFilterRegistry.Interface;\n params: Omit<CmsEntryListParams, \"where\" | \"after\"> & {\n where: CmsEntryListWhere;\n after?: PrimitiveValue[];\n };\n}\nexport const createElasticsearchBody = ({\n plugins,\n model,\n params,\n fieldRegistry,\n fieldIndexRegistry,\n bodyModifiers,\n sortModifiers,\n queryModifiers,\n valueSearchRegistry,\n fullTextSearches,\n filterRegistry\n}: ICreateElasticsearchBodyParams): SearchBody => {\n const { fields, search: term, where, sort: initialSort, after, limit } = params;\n /**\n * We need the model fields constructed as a key -> field value, so we do not need to iterate through array when we require some field.\n */\n const modelFields = createModelFields({\n model,\n fieldRegistry,\n fieldIndexRegistry\n });\n\n /**\n * Filter query modifiers applicable to this model.\n */\n const applicableQueryModifiers = queryModifiers.filter(m => {\n return !m.modelId || m.modelId === model.modelId;\n });\n /**\n * Filter sort modifiers applicable to this model.\n */\n const applicableSortModifiers = sortModifiers.filter(\n m => !m.modelId || m.modelId === model.modelId\n );\n /**\n * Filter body modifiers applicable to this model.\n */\n const applicableBodyModifiers = bodyModifiers.filter(m => {\n return !m.modelId || m.modelId === model.modelId;\n });\n /**\n * We need the fields which we can search through via the full text search.\n *\n */\n const fullTextSearchFields = createFullTextSearchFields({\n fields: modelFields,\n term,\n targets: fields\n });\n /**\n * The initial elasticsearch query where we attach some default conditions we always need.\n */\n const query = createInitialQuery({\n where,\n model\n });\n /**\n * Apply the full text search, if term is set.\n */\n applyFullTextSearch({\n model,\n fullTextSearches,\n query,\n term,\n fields: fullTextSearchFields\n });\n\n const execFiltering = createExecFiltering({\n model,\n fields: modelFields,\n plugins,\n valueSearchRegistry,\n filterRegistry\n });\n\n execFiltering({\n where,\n query\n });\n\n for (const modifier of applicableQueryModifiers) {\n modifier.modifyQuery({ query, model, where });\n }\n\n const sort = createElasticsearchSort({\n sort: initialSort,\n modelFields,\n model,\n valueSearchRegistry\n });\n\n for (const modifier of applicableSortModifiers) {\n modifier.modifySort({\n sort,\n model\n });\n }\n\n const boolQuery: BoolQueryConfig = {\n must: query.must.length > 0 ? query.must : undefined,\n must_not: query.must_not.length > 0 ? query.must_not : undefined,\n should: query.should.length > 0 ? query.should : undefined,\n filter: query.filter.length > 0 ? query.filter : undefined\n };\n\n assignMinimumShouldMatchToQuery({\n query: boolQuery\n });\n\n const body: SearchBody = {\n query: {\n bool: boolQuery\n },\n sort,\n size: (limit || 0) + 1,\n search_after: after,\n track_total_hits: true\n };\n\n for (const modifier of applicableBodyModifiers) {\n modifier.modifyBody({\n body,\n model,\n where\n });\n }\n\n return body;\n};\n"],"mappings":"AAMA,SAASA,iBAAiB;AAC1B,SAASC,0BAA0B;AACnC,SAASC,kBAAkB;AAC3B,SAASC,mBAAmB;AAM5B,SAASC,uBAAuB;AAMhC,SAASC,mBAAmB;AAC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EAEF,MAAMM,IAAgB,GAAG;IACrBX,KAAK,EAAE;MACHY,IAAI,EAAEP;IACV,CAAC;IACDlB,IAAI;IACJ0B,IAAI,EAAE,CAACvB,KAAK,IAAI,CAAC,IAAI,CAAC;IACtBwB,YAAY,EAAEzB,KAAK;IACnB0B,gBAAgB,EAAE;EACtB,CAAC;EAED,KAAK,MAAMb,QAAQ,IAAIL,uBAAuB,EAAE;IAC5CK,QAAQ,CAACc,UAAU,CAAC;MAChBL,IAAI;MACJtC,KAAK;MACLa;IACJ,CAAC,CAAC;EACN;EAEA,OAAOyB,IAAI;AACf,CAAC","ignoreList":[]}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type { PluginsContainer } from "@webiny/plugins";
|
|
2
1
|
import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/features/graphql/index.js";
|
|
3
|
+
import { CmsEntryOpenSearchFieldIndexRegistry } from "../../../features/CmsEntryOpenSearchFieldIndex/index.js";
|
|
4
|
+
interface ICreateModelFieldsParams {
|
|
5
5
|
model: CmsModel;
|
|
6
|
+
fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;
|
|
7
|
+
fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface;
|
|
6
8
|
}
|
|
7
|
-
export declare const createModelFields: ({
|
|
9
|
+
export declare const createModelFields: ({ model, fieldRegistry, fieldIndexRegistry }: ICreateModelFieldsParams) => {
|
|
8
10
|
[x: string]: import("./types.js").ModelField;
|
|
9
11
|
};
|
|
10
12
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import WebinyError from "@webiny/error";
|
|
2
|
-
import { CmsElasticsearchModelFieldPlugin } from "../../../plugins/index.js";
|
|
3
2
|
import { ENTRY_META_FIELDS, isDateTimeEntryMetaField, isIdentityEntryMetaField } from "@webiny/api-headless-cms/constants.js";
|
|
4
3
|
import { getBaseFieldType } from "@webiny/api-headless-cms/utils/getBaseFieldType.js";
|
|
5
4
|
import { liveFields } from "./fields/live.js";
|
|
@@ -136,38 +135,6 @@ const createSystemFields = () => {
|
|
|
136
135
|
...liveFields
|
|
137
136
|
};
|
|
138
137
|
};
|
|
139
|
-
const buildCustomFields = params => {
|
|
140
|
-
const {
|
|
141
|
-
fields,
|
|
142
|
-
fieldTypePlugins
|
|
143
|
-
} = params;
|
|
144
|
-
return fields.reduce((collection, field) => {
|
|
145
|
-
const typePlugin = fieldTypePlugins[field.fieldType];
|
|
146
|
-
if (!typePlugin) {
|
|
147
|
-
return collection;
|
|
148
|
-
}
|
|
149
|
-
let unmappedType = undefined;
|
|
150
|
-
if (typePlugin.unmappedType) {
|
|
151
|
-
unmappedType = typePlugin.unmappedType(field);
|
|
152
|
-
}
|
|
153
|
-
collection[field.fieldId] = {
|
|
154
|
-
type: field.fieldType,
|
|
155
|
-
field: createSystemField({
|
|
156
|
-
storageId: field.fieldId,
|
|
157
|
-
fieldId: field.fieldId,
|
|
158
|
-
type: field.fieldType
|
|
159
|
-
}),
|
|
160
|
-
unmappedType,
|
|
161
|
-
fullTextSearch: field.searchable ? typePlugin.fullTextSearch : false,
|
|
162
|
-
searchable: field.searchable || typePlugin.searchable,
|
|
163
|
-
sortable: field.sortable || typePlugin.sortable,
|
|
164
|
-
systemField: false,
|
|
165
|
-
path: field.path,
|
|
166
|
-
parents: []
|
|
167
|
-
};
|
|
168
|
-
return collection;
|
|
169
|
-
}, {});
|
|
170
|
-
};
|
|
171
138
|
const buildFieldsList = params => {
|
|
172
139
|
const {
|
|
173
140
|
plugins,
|
|
@@ -184,7 +151,7 @@ const buildFieldsList = params => {
|
|
|
184
151
|
searchable,
|
|
185
152
|
sortable,
|
|
186
153
|
unmappedType,
|
|
187
|
-
fullTextSearch
|
|
154
|
+
isFullTextSearchable: fullTextSearch
|
|
188
155
|
} = plugin;
|
|
189
156
|
/**
|
|
190
157
|
* If a field has child fields, go through them and add them to a result.
|
|
@@ -220,45 +187,35 @@ const buildFieldsList = params => {
|
|
|
220
187
|
}, {});
|
|
221
188
|
};
|
|
222
189
|
export const createModelFields = ({
|
|
223
|
-
|
|
224
|
-
|
|
190
|
+
model,
|
|
191
|
+
fieldRegistry,
|
|
192
|
+
fieldIndexRegistry
|
|
225
193
|
}) => {
|
|
226
194
|
const fields = model.fields;
|
|
227
|
-
const fieldDefinitionPlugins = plugins.byType(CmsElasticsearchModelFieldPlugin.type).filter(plugin => {
|
|
228
|
-
return plugin.canBeApplied(model.modelId);
|
|
229
|
-
});
|
|
230
195
|
/**
|
|
231
|
-
* Collect all unmappedType from
|
|
196
|
+
* Collect all unmappedType from field index registry.
|
|
232
197
|
*/
|
|
233
|
-
const unmappedTypes =
|
|
234
|
-
if (!
|
|
198
|
+
const unmappedTypes = fieldIndexRegistry.getAll().reduce((acc, fieldIndex) => {
|
|
199
|
+
if (!fieldIndex.unmappedType) {
|
|
235
200
|
return acc;
|
|
236
201
|
}
|
|
237
|
-
acc[
|
|
202
|
+
acc[fieldIndex.fieldType] = fieldIndex.unmappedType;
|
|
238
203
|
return acc;
|
|
239
204
|
}, {});
|
|
240
205
|
/**
|
|
241
206
|
* Collect all field types from the plugins.
|
|
242
207
|
*/
|
|
243
|
-
const fieldTypePlugins =
|
|
244
|
-
|
|
245
|
-
fieldType,
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
unmappedType: unmappedTypes[fieldType],
|
|
250
|
-
searchable: plugin.isSearchable,
|
|
251
|
-
sortable: plugin.isSortable,
|
|
252
|
-
fullTextSearch
|
|
208
|
+
const fieldTypePlugins = fieldRegistry.getAll().reduce((types, field) => {
|
|
209
|
+
types[field.fieldType] = {
|
|
210
|
+
unmappedType: unmappedTypes[field.fieldType],
|
|
211
|
+
searchable: field.isSearchable,
|
|
212
|
+
sortable: field.isSortable,
|
|
213
|
+
isFullTextSearchable: field.isFullTextSearchable
|
|
253
214
|
};
|
|
254
215
|
return types;
|
|
255
216
|
}, {});
|
|
256
217
|
return {
|
|
257
218
|
...createSystemFields(),
|
|
258
|
-
...buildCustomFields({
|
|
259
|
-
fields: fieldDefinitionPlugins,
|
|
260
|
-
fieldTypePlugins
|
|
261
|
-
}),
|
|
262
219
|
...buildFieldsList({
|
|
263
220
|
fields,
|
|
264
221
|
plugins: fieldTypePlugins,
|