@webiny/api-headless-cms-ddb-es 5.39.1-beta.0 → 5.39.1
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 +11 -4
- package/configurations.js +13 -0
- package/configurations.js.map +1 -1
- package/index.js +2 -1
- package/index.js.map +1 -1
- package/package.json +23 -19
- package/tasks/createIndexTaskPlugin.d.ts +2 -0
- package/tasks/createIndexTaskPlugin.js +67 -0
- package/tasks/createIndexTaskPlugin.js.map +1 -0
package/configurations.d.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
2
|
-
|
|
2
|
+
import { CmsContext } from "./types";
|
|
3
|
+
import { ElasticsearchIndexRequestBody } from "@webiny/api-elasticsearch/types";
|
|
4
|
+
interface ConfigurationsElasticsearch {
|
|
3
5
|
index: string;
|
|
4
6
|
}
|
|
5
|
-
interface CmsElasticsearchParams {
|
|
7
|
+
export interface CmsElasticsearchParams {
|
|
6
8
|
model: Pick<CmsModel, "tenant" | "locale" | "modelId">;
|
|
7
9
|
}
|
|
8
|
-
interface
|
|
9
|
-
|
|
10
|
+
export interface ConfigurationsIndexSettingsParams {
|
|
11
|
+
context: CmsContext;
|
|
12
|
+
model: Pick<CmsModel, "locale">;
|
|
13
|
+
}
|
|
14
|
+
export interface Configurations {
|
|
15
|
+
es: (params: CmsElasticsearchParams) => ConfigurationsElasticsearch;
|
|
16
|
+
indexSettings: (params: ConfigurationsIndexSettingsParams) => Partial<ElasticsearchIndexRequestBody>;
|
|
10
17
|
}
|
|
11
18
|
export declare const configurations: Configurations;
|
|
12
19
|
export {};
|
package/configurations.js
CHANGED
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.configurations = void 0;
|
|
8
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
10
|
+
var _plugins = require("./plugins");
|
|
9
11
|
const configurations = {
|
|
10
12
|
es({
|
|
11
13
|
model
|
|
@@ -30,6 +32,17 @@ const configurations = {
|
|
|
30
32
|
return {
|
|
31
33
|
index: prefix + index
|
|
32
34
|
};
|
|
35
|
+
},
|
|
36
|
+
indexSettings: ({
|
|
37
|
+
context,
|
|
38
|
+
model
|
|
39
|
+
}) => {
|
|
40
|
+
const plugin = (0, _apiElasticsearch.getLastAddedIndexPlugin)({
|
|
41
|
+
container: context.plugins,
|
|
42
|
+
type: _plugins.CmsEntryElasticsearchIndexPlugin.type,
|
|
43
|
+
locale: model.locale
|
|
44
|
+
});
|
|
45
|
+
return plugin ? plugin.body : {};
|
|
33
46
|
}
|
|
34
47
|
};
|
|
35
48
|
exports.configurations = configurations;
|
package/configurations.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","configurations","es","model","tenant","locale","WebinyError","sharedIndex","process","env","ELASTICSEARCH_SHARED_INDEXES","index","modelId","join","toLowerCase","prefix","ELASTIC_SEARCH_INDEX_PREFIX","exports"],"sources":["configurations.ts"],"sourcesContent":["import { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\ninterface
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_apiElasticsearch","_plugins","configurations","es","model","tenant","locale","WebinyError","sharedIndex","process","env","ELASTICSEARCH_SHARED_INDEXES","index","modelId","join","toLowerCase","prefix","ELASTIC_SEARCH_INDEX_PREFIX","indexSettings","context","plugin","getLastAddedIndexPlugin","container","plugins","type","CmsEntryElasticsearchIndexPlugin","body","exports"],"sources":["configurations.ts"],"sourcesContent":["import { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsContext } from \"~/types\";\nimport { getLastAddedIndexPlugin } from \"@webiny/api-elasticsearch\";\nimport { ElasticsearchIndexRequestBody } from \"@webiny/api-elasticsearch/types\";\nimport { CmsEntryElasticsearchIndexPlugin } from \"~/plugins\";\n\ninterface ConfigurationsElasticsearch {\n index: string;\n}\n\nexport interface CmsElasticsearchParams {\n model: Pick<CmsModel, \"tenant\" | \"locale\" | \"modelId\">;\n}\n\nexport interface ConfigurationsIndexSettingsParams {\n context: CmsContext;\n model: Pick<CmsModel, \"locale\">;\n}\n\nexport interface Configurations {\n es: (params: CmsElasticsearchParams) => ConfigurationsElasticsearch;\n indexSettings: (\n params: ConfigurationsIndexSettingsParams\n ) => Partial<ElasticsearchIndexRequestBody>;\n}\n\nexport const configurations: Configurations = {\n es({ model }) {\n const { tenant, locale } = model;\n\n if (!tenant) {\n throw new WebinyError(\n `Missing \"tenant\" parameter when trying to create Elasticsearch index name.`,\n \"TENANT_ERROR\"\n );\n } else if (!locale) {\n throw new WebinyError(\n `Missing \"locale\" parameter when trying to create Elasticsearch index name.`,\n \"LOCALE_ERROR\"\n );\n }\n\n const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === \"true\";\n const index = [sharedIndex ? \"root\" : tenant, \"headless-cms\", locale, model.modelId]\n .join(\"-\")\n .toLowerCase();\n\n const prefix = process.env.ELASTIC_SEARCH_INDEX_PREFIX || \"\";\n if (!prefix) {\n return {\n index\n };\n }\n return {\n index: prefix + index\n };\n },\n indexSettings: ({ context, model }) => {\n const plugin = getLastAddedIndexPlugin<CmsEntryElasticsearchIndexPlugin>({\n container: context.plugins,\n type: CmsEntryElasticsearchIndexPlugin.type,\n locale: model.locale\n });\n\n return plugin ? plugin.body : {};\n }\n};\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AAsBO,MAAMG,cAA8B,GAAG;EAC1CC,EAAEA,CAAC;IAAEC;EAAM,CAAC,EAAE;IACV,MAAM;MAAEC,MAAM;MAAEC;IAAO,CAAC,GAAGF,KAAK;IAEhC,IAAI,CAACC,MAAM,EAAE;MACT,MAAM,IAAIE,cAAW,CAChB,4EAA2E,EAC5E,cACJ,CAAC;IACL,CAAC,MAAM,IAAI,CAACD,MAAM,EAAE;MAChB,MAAM,IAAIC,cAAW,CAChB,4EAA2E,EAC5E,cACJ,CAAC;IACL;IAEA,MAAMC,WAAW,GAAGC,OAAO,CAACC,GAAG,CAACC,4BAA4B,KAAK,MAAM;IACvE,MAAMC,KAAK,GAAG,CAACJ,WAAW,GAAG,MAAM,GAAGH,MAAM,EAAE,cAAc,EAAEC,MAAM,EAAEF,KAAK,CAACS,OAAO,CAAC,CAC/EC,IAAI,CAAC,GAAG,CAAC,CACTC,WAAW,CAAC,CAAC;IAElB,MAAMC,MAAM,GAAGP,OAAO,CAACC,GAAG,CAACO,2BAA2B,IAAI,EAAE;IAC5D,IAAI,CAACD,MAAM,EAAE;MACT,OAAO;QACHJ;MACJ,CAAC;IACL;IACA,OAAO;MACHA,KAAK,EAAEI,MAAM,GAAGJ;IACpB,CAAC;EACL,CAAC;EACDM,aAAa,EAAEA,CAAC;IAAEC,OAAO;IAAEf;EAAM,CAAC,KAAK;IACnC,MAAMgB,MAAM,GAAG,IAAAC,yCAAuB,EAAmC;MACrEC,SAAS,EAAEH,OAAO,CAACI,OAAO;MAC1BC,IAAI,EAAEC,yCAAgC,CAACD,IAAI;MAC3ClB,MAAM,EAAEF,KAAK,CAACE;IAClB,CAAC,CAAC;IAEF,OAAOc,MAAM,GAAGA,MAAM,CAACM,IAAI,GAAG,CAAC,CAAC;EACpC;AACJ,CAAC;AAACC,OAAA,CAAAzB,cAAA,GAAAA,cAAA"}
|
package/index.js
CHANGED
|
@@ -44,6 +44,7 @@ var _plugins3 = require("./operations/entry/elasticsearch/filtering/plugins");
|
|
|
44
44
|
var _CmsEntryFilterPlugin = require("./plugins/CmsEntryFilterPlugin");
|
|
45
45
|
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
46
46
|
var _indexes = require("./operations/system/indexes");
|
|
47
|
+
var _createIndexTaskPlugin = require("./tasks/createIndexTaskPlugin");
|
|
47
48
|
const createStorageOperations = params => {
|
|
48
49
|
const {
|
|
49
50
|
attributes,
|
|
@@ -132,7 +133,7 @@ const createStorageOperations = params => {
|
|
|
132
133
|
/**
|
|
133
134
|
* Pass the plugins to the parent context.
|
|
134
135
|
*/
|
|
135
|
-
context.plugins.register([(0, _dynamoDb.default)()]);
|
|
136
|
+
context.plugins.register([(0, _dynamoDb.default)(), (0, _createIndexTaskPlugin.createIndexTaskPluginTest)(), (0, _indices.elasticsearchIndexPlugins)()]);
|
|
136
137
|
/**
|
|
137
138
|
* We need to fetch all the plugin types in the list from the main container.
|
|
138
139
|
* This way we do not need to register plugins in the storage plugins contains.
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_filters","_interopRequireDefault","require","_elasticsearch","_dynamoDb","_system","_model","_entry","_types","_table","_tableElasticsearch","_group","_model2","_entry2","_entryElasticsearch","_system2","_createElasticsearchIndex","_plugins","_group2","_apiElasticsearch","_indices","_deleteElasticsearchIndex","_plugins2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_plugins3","_CmsEntryFilterPlugin","_apiHeadlessCms","_indexes","createStorageOperations","params","attributes","table","esTable","documentClient","elasticsearch","plugins","userPlugins","tableInstance","createTable","tableElasticsearchInstance","createElasticsearchTable","entities","system","createSystemEntity","entityName","ENTITIES","SYSTEM","groups","createGroupEntity","GROUPS","models","createModelEntity","MODELS","entries","createEntryEntity","ENTRIES","entriesEs","createEntryElasticsearchEntity","ENTRIES_ES","PluginsContainer","dynamoDbValueFilters","dynamoDbPlugins","elasticsearchPlugins","elasticsearchIndexPlugins","createFilterPlugins","createEntriesStorageOperations","entity","esEntity","name","beforeInit","context","register","types","CompressionPlugin","type","ElasticsearchQueryBuilderOperatorPlugin","CmsEntryFilterPlugin","CmsEntryElasticsearchBodyModifierPlugin","CmsEntryElasticsearchFullTextSearchPlugin","CmsEntryElasticsearchIndexPlugin","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","CmsEntryElasticsearchQueryModifierPlugin","CmsEntryElasticsearchSortModifierPlugin","CmsElasticsearchModelFieldPlugin","StorageOperationsCmsModelPlugin","CmsEntryElasticsearchValuesModifier","mergeByType","dataLoaders","clearAll","init","createElasticsearchIndexesOnLocaleAfterCreate","client","cms","onModelBeforeCreate","subscribe","model","createElasticsearchIndex","onModelBeforeCreateFrom","onModelAfterDelete","deleteElasticsearchIndex","onModelInitialize","getEntities","getTable","getEsTable","createSystemStorageOperations","createGroupsStorageOperations","createModelsStorageOperations"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters\";\nimport elasticsearchPlugins from \"./elasticsearch\";\nimport dynamoDbPlugins from \"./dynamoDb\";\nimport { createSystemStorageOperations } from \"./operations/system\";\nimport { createModelsStorageOperations } from \"./operations/model\";\nimport { createEntriesStorageOperations } from \"./operations/entry\";\nimport { ENTITIES, StorageOperationsFactory } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\nimport { createElasticsearchTable } from \"~/definitions/tableElasticsearch\";\nimport { createGroupEntity } from \"~/definitions/group\";\nimport { createModelEntity } from \"~/definitions/model\";\nimport { createEntryEntity } from \"~/definitions/entry\";\nimport { createEntryElasticsearchEntity } from \"~/definitions/entryElasticsearch\";\nimport { createSystemEntity } from \"~/definitions/system\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createGroupsStorageOperations } from \"~/operations/group\";\nimport {\n CompressionPlugin,\n ElasticsearchQueryBuilderOperatorPlugin\n} from \"@webiny/api-elasticsearch\";\nimport { elasticsearchIndexPlugins } from \"./elasticsearch/indices\";\nimport { deleteElasticsearchIndex } from \"./elasticsearch/deleteElasticsearchIndex\";\nimport {\n CmsElasticsearchModelFieldPlugin,\n CmsEntryElasticsearchBodyModifierPlugin,\n CmsEntryElasticsearchFullTextSearchPlugin,\n CmsEntryElasticsearchIndexPlugin,\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin,\n CmsEntryElasticsearchQueryModifierPlugin,\n CmsEntryElasticsearchSortModifierPlugin,\n CmsEntryElasticsearchValuesModifier\n} from \"~/plugins\";\nimport { createFilterPlugins } from \"~/operations/entry/elasticsearch/filtering/plugins\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { StorageOperationsCmsModelPlugin } from \"@webiny/api-headless-cms\";\nimport { createElasticsearchIndexesOnLocaleAfterCreate } from \"~/operations/system/indexes\";\n\nexport * from \"./plugins\";\n\nexport const createStorageOperations: StorageOperationsFactory = params => {\n const {\n attributes,\n table,\n esTable,\n documentClient,\n elasticsearch,\n plugins: userPlugins\n } = params;\n\n const tableInstance = createTable({\n table,\n documentClient\n });\n const tableElasticsearchInstance = createElasticsearchTable({\n table: esTable,\n documentClient\n });\n\n const entities = {\n system: createSystemEntity({\n entityName: ENTITIES.SYSTEM,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SYSTEM] : {}\n }),\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.GROUPS] : {}\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.MODELS] : {}\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.ENTRIES] : {}\n }),\n entriesEs: createEntryElasticsearchEntity({\n entityName: ENTITIES.ENTRIES_ES,\n table: tableElasticsearchInstance,\n attributes: attributes ? attributes[ENTITIES.ENTRIES_ES] : {}\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 /**\n * Attach the elasticsearch into context if it is not already attached.\n */\n if (!context.elasticsearch) {\n context.elasticsearch = elasticsearch;\n }\n /**\n * Pass the plugins to the parent context.\n */\n context.plugins.register([dynamoDbPlugins()]);\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 // Elasticsearch\n CompressionPlugin.type,\n ElasticsearchQueryBuilderOperatorPlugin.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 CmsEntryElasticsearchValuesModifier.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 * We need to create indexes on before model create and on clone (create from).\n * Other apps create indexes on locale creation.\n */\n await createElasticsearchIndexesOnLocaleAfterCreate({\n context,\n client: elasticsearch,\n plugins\n });\n\n context.cms.onModelBeforeCreate.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n client: elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onModelBeforeCreateFrom.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n client: elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onModelAfterDelete.subscribe(async ({ model }) => {\n await deleteElasticsearchIndex({\n client: elasticsearch,\n model\n });\n });\n\n context.cms.onModelInitialize.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n client: elasticsearch,\n model,\n plugins\n });\n });\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n getEsTable: () => tableElasticsearchInstance,\n system: createSystemStorageOperations({\n entity: entities.system\n }),\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,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,mBAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AACA,IAAAW,OAAA,GAAAX,OAAA;AACA,IAAAY,mBAAA,GAAAZ,OAAA;AACA,IAAAa,QAAA,GAAAb,OAAA;AACA,IAAAc,yBAAA,GAAAd,OAAA;AACA,IAAAe,QAAA,GAAAf,OAAA;AACA,IAAAgB,OAAA,GAAAhB,OAAA;AACA,IAAAiB,iBAAA,GAAAjB,OAAA;AAIA,IAAAkB,QAAA,GAAAlB,OAAA;AACA,IAAAmB,yBAAA,GAAAnB,OAAA;AACA,IAAAoB,SAAA,GAAApB,OAAA;AAeAqB,MAAA,CAAAC,I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
|
1
|
+
{"version":3,"names":["_filters","_interopRequireDefault","require","_elasticsearch","_dynamoDb","_system","_model","_entry","_types","_table","_tableElasticsearch","_group","_model2","_entry2","_entryElasticsearch","_system2","_createElasticsearchIndex","_plugins","_group2","_apiElasticsearch","_indices","_deleteElasticsearchIndex","_plugins2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_plugins3","_CmsEntryFilterPlugin","_apiHeadlessCms","_indexes","_createIndexTaskPlugin","createStorageOperations","params","attributes","table","esTable","documentClient","elasticsearch","plugins","userPlugins","tableInstance","createTable","tableElasticsearchInstance","createElasticsearchTable","entities","system","createSystemEntity","entityName","ENTITIES","SYSTEM","groups","createGroupEntity","GROUPS","models","createModelEntity","MODELS","entries","createEntryEntity","ENTRIES","entriesEs","createEntryElasticsearchEntity","ENTRIES_ES","PluginsContainer","dynamoDbValueFilters","dynamoDbPlugins","elasticsearchPlugins","elasticsearchIndexPlugins","createFilterPlugins","createEntriesStorageOperations","entity","esEntity","name","beforeInit","context","register","createIndexTaskPluginTest","types","CompressionPlugin","type","ElasticsearchQueryBuilderOperatorPlugin","CmsEntryFilterPlugin","CmsEntryElasticsearchBodyModifierPlugin","CmsEntryElasticsearchFullTextSearchPlugin","CmsEntryElasticsearchIndexPlugin","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","CmsEntryElasticsearchQueryModifierPlugin","CmsEntryElasticsearchSortModifierPlugin","CmsElasticsearchModelFieldPlugin","StorageOperationsCmsModelPlugin","CmsEntryElasticsearchValuesModifier","mergeByType","dataLoaders","clearAll","init","createElasticsearchIndexesOnLocaleAfterCreate","client","cms","onModelBeforeCreate","subscribe","model","createElasticsearchIndex","onModelBeforeCreateFrom","onModelAfterDelete","deleteElasticsearchIndex","onModelInitialize","getEntities","getTable","getEsTable","createSystemStorageOperations","createGroupsStorageOperations","createModelsStorageOperations"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters\";\nimport elasticsearchPlugins from \"./elasticsearch\";\nimport dynamoDbPlugins from \"./dynamoDb\";\nimport { createSystemStorageOperations } from \"./operations/system\";\nimport { createModelsStorageOperations } from \"./operations/model\";\nimport { createEntriesStorageOperations } from \"./operations/entry\";\nimport { ENTITIES, StorageOperationsFactory } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\nimport { createElasticsearchTable } from \"~/definitions/tableElasticsearch\";\nimport { createGroupEntity } from \"~/definitions/group\";\nimport { createModelEntity } from \"~/definitions/model\";\nimport { createEntryEntity } from \"~/definitions/entry\";\nimport { createEntryElasticsearchEntity } from \"~/definitions/entryElasticsearch\";\nimport { createSystemEntity } from \"~/definitions/system\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createGroupsStorageOperations } from \"~/operations/group\";\nimport {\n CompressionPlugin,\n ElasticsearchQueryBuilderOperatorPlugin\n} from \"@webiny/api-elasticsearch\";\nimport { elasticsearchIndexPlugins } from \"./elasticsearch/indices\";\nimport { deleteElasticsearchIndex } from \"./elasticsearch/deleteElasticsearchIndex\";\nimport {\n CmsElasticsearchModelFieldPlugin,\n CmsEntryElasticsearchBodyModifierPlugin,\n CmsEntryElasticsearchFullTextSearchPlugin,\n CmsEntryElasticsearchIndexPlugin,\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin,\n CmsEntryElasticsearchQueryModifierPlugin,\n CmsEntryElasticsearchSortModifierPlugin,\n CmsEntryElasticsearchValuesModifier\n} from \"~/plugins\";\nimport { createFilterPlugins } from \"~/operations/entry/elasticsearch/filtering/plugins\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { StorageOperationsCmsModelPlugin } from \"@webiny/api-headless-cms\";\nimport { createElasticsearchIndexesOnLocaleAfterCreate } from \"~/operations/system/indexes\";\nimport { createIndexTaskPluginTest } from \"~/tasks/createIndexTaskPlugin\";\n\nexport * from \"./plugins\";\n\nexport const createStorageOperations: StorageOperationsFactory = params => {\n const {\n attributes,\n table,\n esTable,\n documentClient,\n elasticsearch,\n plugins: userPlugins\n } = params;\n\n const tableInstance = createTable({\n table,\n documentClient\n });\n const tableElasticsearchInstance = createElasticsearchTable({\n table: esTable,\n documentClient\n });\n\n const entities = {\n system: createSystemEntity({\n entityName: ENTITIES.SYSTEM,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SYSTEM] : {}\n }),\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.GROUPS] : {}\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.MODELS] : {}\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.ENTRIES] : {}\n }),\n entriesEs: createEntryElasticsearchEntity({\n entityName: ENTITIES.ENTRIES_ES,\n table: tableElasticsearchInstance,\n attributes: attributes ? attributes[ENTITIES.ENTRIES_ES] : {}\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 /**\n * Attach the elasticsearch into context if it is not already attached.\n */\n if (!context.elasticsearch) {\n context.elasticsearch = elasticsearch;\n }\n /**\n * Pass the plugins to the parent context.\n */\n context.plugins.register([\n dynamoDbPlugins(),\n createIndexTaskPluginTest(),\n elasticsearchIndexPlugins()\n ]);\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 // Elasticsearch\n CompressionPlugin.type,\n ElasticsearchQueryBuilderOperatorPlugin.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 CmsEntryElasticsearchValuesModifier.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 * We need to create indexes on before model create and on clone (create from).\n * Other apps create indexes on locale creation.\n */\n await createElasticsearchIndexesOnLocaleAfterCreate({\n context,\n client: elasticsearch,\n plugins\n });\n\n context.cms.onModelBeforeCreate.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n client: elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onModelBeforeCreateFrom.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n client: elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onModelAfterDelete.subscribe(async ({ model }) => {\n await deleteElasticsearchIndex({\n client: elasticsearch,\n model\n });\n });\n\n context.cms.onModelInitialize.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n client: elasticsearch,\n model,\n plugins\n });\n });\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n getEsTable: () => tableElasticsearchInstance,\n system: createSystemStorageOperations({\n entity: entities.system\n }),\n groups: createGroupsStorageOperations({\n entity: entities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FmC,OAAO,CAACuB,GAAG,CAACM,kBAAkB,CAACJ,SAAS,CAAC,OAAO;QAAEC;MAAM,CAAC,KAAK;QAC1D,MAAM,IAAAI,kDAAwB,EAAC;UAC3BR,MAAM,EAAE1D,aAAa;UACrB8D;QACJ,CAAC,CAAC;MACN,CAAC,CAAC;MAEF1B,OAAO,CAACuB,GAAG,CAACQ,iBAAiB,CAACN,SAAS,CAAC,OAAO;QAAEC;MAAM,CAAC,KAAK;QACzD,MAAM,IAAAC,kDAAwB,EAAC;UAC3BL,MAAM,EAAE1D,aAAa;UACrB8D,KAAK;UACL7D;QACJ,CAAC,CAAC;MACN,CAAC,CAAC;IACN,CAAC;IACDmE,WAAW,EAAEA,CAAA,KAAM7D,QAAQ;IAC3B8D,QAAQ,EAAEA,CAAA,KAAMlE,aAAa;IAC7BmE,UAAU,EAAEA,CAAA,KAAMjE,0BAA0B;IAC5CG,MAAM,EAAE,IAAA+D,qCAA6B,EAAC;MAClCvC,MAAM,EAAEzB,QAAQ,CAACC;IACrB,CAAC,CAAC;IACFK,MAAM,EAAE,IAAA2D,qCAA6B,EAAC;MAClCxC,MAAM,EAAEzB,QAAQ,CAACM,MAAM;MACvBZ;IACJ,CAAC,CAAC;IACFe,MAAM,EAAE,IAAAyD,oCAA6B,EAAC;MAClCzC,MAAM,EAAEzB,QAAQ,CAACS,MAAM;MACvBhB;IACJ,CAAC,CAAC;IACFmB;EACJ,CAAC;AACL,CAAC;AAAClC,OAAA,CAAAS,uBAAA,GAAAA,uBAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-ddb-es",
|
|
3
|
-
"version": "5.39.1
|
|
3
|
+
"version": "5.39.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-headless-cms",
|
|
@@ -27,15 +27,16 @@
|
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/runtime": "7.22.6",
|
|
30
|
-
"@webiny/api": "5.39.1
|
|
31
|
-
"@webiny/api-elasticsearch": "5.39.1
|
|
32
|
-
"@webiny/api-
|
|
33
|
-
"@webiny/
|
|
34
|
-
"@webiny/
|
|
35
|
-
"@webiny/
|
|
36
|
-
"@webiny/
|
|
37
|
-
"@webiny/
|
|
38
|
-
"@webiny/
|
|
30
|
+
"@webiny/api": "5.39.1",
|
|
31
|
+
"@webiny/api-elasticsearch": "5.39.1",
|
|
32
|
+
"@webiny/api-elasticsearch-tasks": "5.39.1",
|
|
33
|
+
"@webiny/api-headless-cms": "5.39.1",
|
|
34
|
+
"@webiny/aws-sdk": "5.39.1",
|
|
35
|
+
"@webiny/db-dynamodb": "5.39.1",
|
|
36
|
+
"@webiny/error": "5.39.1",
|
|
37
|
+
"@webiny/handler-db": "5.39.1",
|
|
38
|
+
"@webiny/plugins": "5.39.1",
|
|
39
|
+
"@webiny/utils": "5.39.1",
|
|
39
40
|
"dataloader": "2.2.1",
|
|
40
41
|
"jsonpack": "1.1.5",
|
|
41
42
|
"lodash": "4.17.21"
|
|
@@ -46,14 +47,17 @@
|
|
|
46
47
|
"@babel/preset-env": "7.22.7",
|
|
47
48
|
"@elastic/elasticsearch": "7.12.0",
|
|
48
49
|
"@types/jsonpack": "1.1.2",
|
|
49
|
-
"@webiny/api-dynamodb-to-elasticsearch": "5.39.1
|
|
50
|
-
"@webiny/api-i18n": "5.39.1
|
|
51
|
-
"@webiny/api-security": "5.39.1
|
|
52
|
-
"@webiny/api-tenancy": "5.39.1
|
|
53
|
-
"@webiny/
|
|
54
|
-
"@webiny/
|
|
55
|
-
"@webiny/handler
|
|
56
|
-
"@webiny/
|
|
50
|
+
"@webiny/api-dynamodb-to-elasticsearch": "5.39.1",
|
|
51
|
+
"@webiny/api-i18n": "5.39.1",
|
|
52
|
+
"@webiny/api-security": "5.39.1",
|
|
53
|
+
"@webiny/api-tenancy": "5.39.1",
|
|
54
|
+
"@webiny/api-wcp": "5.39.1",
|
|
55
|
+
"@webiny/cli": "5.39.1",
|
|
56
|
+
"@webiny/handler": "5.39.1",
|
|
57
|
+
"@webiny/handler-aws": "5.39.1",
|
|
58
|
+
"@webiny/handler-graphql": "5.39.1",
|
|
59
|
+
"@webiny/project-utils": "5.39.1",
|
|
60
|
+
"@webiny/tasks": "5.39.1",
|
|
57
61
|
"jest": "29.5.0",
|
|
58
62
|
"jest-dynalite": "3.6.1",
|
|
59
63
|
"prettier": "2.8.8",
|
|
@@ -70,5 +74,5 @@
|
|
|
70
74
|
"build": "yarn webiny run build",
|
|
71
75
|
"watch": "yarn webiny run watch"
|
|
72
76
|
},
|
|
73
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "6fc74b45740bd4123dcf9b5890bfacee594208bf"
|
|
74
78
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createIndexTaskPluginTest = void 0;
|
|
7
|
+
var _apiElasticsearchTasks = require("@webiny/api-elasticsearch-tasks");
|
|
8
|
+
var _configurations = require("../configurations");
|
|
9
|
+
const createIndexTaskPluginTest = () => {
|
|
10
|
+
return (0, _apiElasticsearchTasks.createElasticsearchIndexTaskPlugin)({
|
|
11
|
+
name: "elasticsearch.cms.createIndexTaskPlugin",
|
|
12
|
+
getIndexList: async ({
|
|
13
|
+
context,
|
|
14
|
+
locale,
|
|
15
|
+
tenant
|
|
16
|
+
}) => {
|
|
17
|
+
const originalTenant = context.tenancy.getCurrentTenant();
|
|
18
|
+
if (!originalTenant) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
const originalLocale = context.i18n.getCurrentLocale("content");
|
|
22
|
+
if (!originalLocale) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
const selectedTenant = await context.tenancy.getTenantById(tenant);
|
|
26
|
+
if (!selectedTenant) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
const selectedLocale = await context.i18n.getLocale(locale);
|
|
30
|
+
if (!selectedLocale) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
const models = await context.cms.listModels();
|
|
34
|
+
if (models.length === 0) {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
context.tenancy.setCurrentTenant(selectedTenant);
|
|
38
|
+
context.i18n.setCurrentLocale("content", selectedLocale);
|
|
39
|
+
const indexes = models.map(model => {
|
|
40
|
+
const {
|
|
41
|
+
index
|
|
42
|
+
} = _configurations.configurations.es({
|
|
43
|
+
model: {
|
|
44
|
+
modelId: model.modelId,
|
|
45
|
+
tenant,
|
|
46
|
+
locale
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
index,
|
|
51
|
+
settings: _configurations.configurations.indexSettings({
|
|
52
|
+
context,
|
|
53
|
+
model: {
|
|
54
|
+
locale
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
context.tenancy.setCurrentTenant(originalTenant);
|
|
60
|
+
context.i18n.setCurrentLocale("content", originalLocale);
|
|
61
|
+
return indexes;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
exports.createIndexTaskPluginTest = createIndexTaskPluginTest;
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=createIndexTaskPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_apiElasticsearchTasks","require","_configurations","createIndexTaskPluginTest","createElasticsearchIndexTaskPlugin","name","getIndexList","context","locale","tenant","originalTenant","tenancy","getCurrentTenant","originalLocale","i18n","getCurrentLocale","selectedTenant","getTenantById","selectedLocale","getLocale","models","cms","listModels","length","setCurrentTenant","setCurrentLocale","indexes","map","model","index","configurations","es","modelId","settings","indexSettings","exports"],"sources":["createIndexTaskPlugin.ts"],"sourcesContent":["import {\n createElasticsearchIndexTaskPlugin,\n CreateElasticsearchIndexTaskPluginIndex\n} from \"@webiny/api-elasticsearch-tasks\";\nimport { configurations } from \"~/configurations\";\nimport { CmsContext } from \"~/types\";\n\nexport const createIndexTaskPluginTest = () => {\n return createElasticsearchIndexTaskPlugin<CmsContext>({\n name: \"elasticsearch.cms.createIndexTaskPlugin\",\n getIndexList: async ({ context, locale, tenant }) => {\n const originalTenant = context.tenancy.getCurrentTenant();\n if (!originalTenant) {\n return [];\n }\n const originalLocale = context.i18n.getCurrentLocale(\"content\");\n if (!originalLocale) {\n return [];\n }\n\n const selectedTenant = await context.tenancy.getTenantById(tenant);\n if (!selectedTenant) {\n return [];\n }\n const selectedLocale = await context.i18n.getLocale(locale);\n if (!selectedLocale) {\n return [];\n }\n const models = await context.cms.listModels();\n if (models.length === 0) {\n return [];\n }\n\n context.tenancy.setCurrentTenant(selectedTenant);\n context.i18n.setCurrentLocale(\"content\", selectedLocale);\n\n const indexes = models.map<CreateElasticsearchIndexTaskPluginIndex>(model => {\n const { index } = configurations.es({\n model: {\n modelId: model.modelId,\n tenant,\n locale\n }\n });\n return {\n index,\n settings: configurations.indexSettings({\n context,\n model: {\n locale\n }\n })\n };\n });\n\n context.tenancy.setCurrentTenant(originalTenant);\n context.i18n.setCurrentLocale(\"content\", originalLocale);\n return indexes;\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAIA,IAAAC,eAAA,GAAAD,OAAA;AAGO,MAAME,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,OAAO,IAAAC,yDAAkC,EAAa;IAClDC,IAAI,EAAE,yCAAyC;IAC/CC,YAAY,EAAE,MAAAA,CAAO;MAAEC,OAAO;MAAEC,MAAM;MAAEC;IAAO,CAAC,KAAK;MACjD,MAAMC,cAAc,GAAGH,OAAO,CAACI,OAAO,CAACC,gBAAgB,CAAC,CAAC;MACzD,IAAI,CAACF,cAAc,EAAE;QACjB,OAAO,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