@webiny/api-form-builder-so-ddb-es 5.39.0 → 5.39.1-beta.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.
@@ -1,11 +1,18 @@
1
- export interface ElasticsearchConfigParams {
1
+ import { ElasticsearchIndexRequestBody } from "@webiny/api-elasticsearch/types";
2
+ import { FormBuilderContext } from "@webiny/api-form-builder/types";
3
+ export interface ConfigurationsElasticsearch {
4
+ index: string;
5
+ }
6
+ export interface ConfigurationsElasticsearchParams {
2
7
  tenant: string;
3
8
  locale: string;
4
9
  }
5
- interface ElasticsearchConfig {
6
- index: string;
10
+ export interface ConfigurationsIndexSettingsParams {
11
+ context: FormBuilderContext;
12
+ locale: string;
13
+ }
14
+ export interface Configurations {
15
+ es: (params: ConfigurationsElasticsearchParams) => ConfigurationsElasticsearch;
16
+ indexSettings: (params: ConfigurationsIndexSettingsParams) => Partial<ElasticsearchIndexRequestBody>;
7
17
  }
8
- export declare const configurations: {
9
- es(params: ElasticsearchConfigParams): ElasticsearchConfig;
10
- };
11
- export {};
18
+ export declare const configurations: Configurations;
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(params) {
11
13
  const {
@@ -34,6 +36,17 @@ const configurations = {
34
36
  return {
35
37
  index: prefix + index
36
38
  };
39
+ },
40
+ indexSettings: ({
41
+ context,
42
+ locale
43
+ }) => {
44
+ const plugin = (0, _apiElasticsearch.getLastAddedIndexPlugin)({
45
+ container: context.plugins,
46
+ type: _plugins.FormElasticsearchIndexPlugin.type,
47
+ locale
48
+ });
49
+ return plugin ? plugin.body : {};
37
50
  }
38
51
  };
39
52
  exports.configurations = configurations;
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","configurations","es","params","tenant","locale","WebinyError","sharedIndex","process","env","ELASTICSEARCH_SHARED_INDEXES","tenantId","localeCode","WEBINY_ELASTICSEARCH_INDEX_LOCALE","index","filter","Boolean","join","toLowerCase","prefix","ELASTIC_SEARCH_INDEX_PREFIX","exports"],"sources":["configurations.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nexport interface ElasticsearchConfigParams {\n tenant: string;\n locale: string;\n}\n\ninterface ElasticsearchConfig {\n index: string;\n}\n\nexport const configurations = {\n es(params: ElasticsearchConfigParams): ElasticsearchConfig {\n const { tenant, locale } = params;\n if (!tenant) {\n throw new WebinyError(\n `Missing \"tenant\" parameter when trying to create Elasticsearch index name.`,\n \"TENANT_ERROR\"\n );\n }\n\n const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === \"true\";\n\n const tenantId = sharedIndex ? \"root\" : tenant;\n let localeCode: string | null = null;\n if (process.env.WEBINY_ELASTICSEARCH_INDEX_LOCALE === \"true\") {\n if (!locale) {\n throw new WebinyError(\n `Missing \"locale\" parameter when trying to create Elasticsearch index name.`,\n \"LOCALE_ERROR\"\n );\n }\n localeCode = locale;\n }\n\n const index = [tenantId, localeCode, \"form-builder\"]\n .filter(Boolean)\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};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAWO,MAAMC,cAAc,GAAG;EAC1BC,EAAEA,CAACC,MAAiC,EAAuB;IACvD,MAAM;MAAEC,MAAM;MAAEC;IAAO,CAAC,GAAGF,MAAM;IACjC,IAAI,CAACC,MAAM,EAAE;MACT,MAAM,IAAIE,cAAW,CAChB,4EAA2E,EAC5E,cACJ,CAAC;IACL;IAEA,MAAMC,WAAW,GAAGC,OAAO,CAACC,GAAG,CAACC,4BAA4B,KAAK,MAAM;IAEvE,MAAMC,QAAQ,GAAGJ,WAAW,GAAG,MAAM,GAAGH,MAAM;IAC9C,IAAIQ,UAAyB,GAAG,IAAI;IACpC,IAAIJ,OAAO,CAACC,GAAG,CAACI,iCAAiC,KAAK,MAAM,EAAE;MAC1D,IAAI,CAACR,MAAM,EAAE;QACT,MAAM,IAAIC,cAAW,CAChB,4EAA2E,EAC5E,cACJ,CAAC;MACL;MACAM,UAAU,GAAGP,MAAM;IACvB;IAEA,MAAMS,KAAK,GAAG,CAACH,QAAQ,EAAEC,UAAU,EAAE,cAAc,CAAC,CAC/CG,MAAM,CAACC,OAAO,CAAC,CACfC,IAAI,CAAC,GAAG,CAAC,CACTC,WAAW,CAAC,CAAC;IAElB,MAAMC,MAAM,GAAGX,OAAO,CAACC,GAAG,CAACW,2BAA2B,IAAI,EAAE;IAC5D,IAAI,CAACD,MAAM,EAAE;MACT,OAAO;QACHL;MACJ,CAAC;IACL;IACA,OAAO;MACHA,KAAK,EAAEK,MAAM,GAAGL;IACpB,CAAC;EACL;AACJ,CAAC;AAACO,OAAA,CAAApB,cAAA,GAAAA,cAAA"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_apiElasticsearch","_plugins","configurations","es","params","tenant","locale","WebinyError","sharedIndex","process","env","ELASTICSEARCH_SHARED_INDEXES","tenantId","localeCode","WEBINY_ELASTICSEARCH_INDEX_LOCALE","index","filter","Boolean","join","toLowerCase","prefix","ELASTIC_SEARCH_INDEX_PREFIX","indexSettings","context","plugin","getLastAddedIndexPlugin","container","plugins","type","FormElasticsearchIndexPlugin","body","exports"],"sources":["configurations.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { getLastAddedIndexPlugin } from \"@webiny/api-elasticsearch\";\nimport { FormElasticsearchIndexPlugin } from \"~/plugins\";\nimport { ElasticsearchIndexRequestBody } from \"@webiny/api-elasticsearch/types\";\nimport { FormBuilderContext } from \"@webiny/api-form-builder/types\";\n\nexport interface ConfigurationsElasticsearch {\n index: string;\n}\n\nexport interface ConfigurationsElasticsearchParams {\n tenant: string;\n locale: string;\n}\n\nexport interface ConfigurationsIndexSettingsParams {\n context: FormBuilderContext;\n locale: string;\n}\n\nexport interface Configurations {\n es: (params: ConfigurationsElasticsearchParams) => ConfigurationsElasticsearch;\n indexSettings: (\n params: ConfigurationsIndexSettingsParams\n ) => Partial<ElasticsearchIndexRequestBody>;\n}\n\nexport const configurations: Configurations = {\n es(params) {\n const { tenant, locale } = params;\n if (!tenant) {\n throw new WebinyError(\n `Missing \"tenant\" parameter when trying to create Elasticsearch index name.`,\n \"TENANT_ERROR\"\n );\n }\n\n const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === \"true\";\n\n const tenantId = sharedIndex ? \"root\" : tenant;\n let localeCode: string | null = null;\n if (process.env.WEBINY_ELASTICSEARCH_INDEX_LOCALE === \"true\") {\n if (!locale) {\n throw new WebinyError(\n `Missing \"locale\" parameter when trying to create Elasticsearch index name.`,\n \"LOCALE_ERROR\"\n );\n }\n localeCode = locale;\n }\n\n const index = [tenantId, localeCode, \"form-builder\"]\n .filter(Boolean)\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, locale }) => {\n const plugin = getLastAddedIndexPlugin<FormElasticsearchIndexPlugin>({\n container: context.plugins,\n type: FormElasticsearchIndexPlugin.type,\n locale\n });\n\n return plugin ? plugin.body : {};\n }\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAyBO,MAAMG,cAA8B,GAAG;EAC1CC,EAAEA,CAACC,MAAM,EAAE;IACP,MAAM;MAAEC,MAAM;MAAEC;IAAO,CAAC,GAAGF,MAAM;IACjC,IAAI,C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createIndexTaskPlugin = require("./tasks/createIndexTaskPlugin");
43
44
  const reservedFields = ["PK", "SK", "index", "data", "TYPE", "__type", "GSI1_PK", "GSI1_SK"];
44
45
  const isReserved = name => {
45
46
  if (reservedFields.includes(name) === false) {
@@ -140,6 +141,7 @@ const createFormBuilderStorageOperations = params => {
140
141
  for (const type of types) {
141
142
  plugins.mergeByType(context.plugins, type);
142
143
  }
144
+ context.plugins.register([(0, _createIndexTaskPlugin.createIndexTaskPlugin)(), (0, _indices.elasticsearchIndexPlugins)()]);
143
145
  },
144
146
  init: async context => {
145
147
  context.i18n.locales.onLocaleBeforeCreate.subscribe(async ({
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_filters","_interopRequireDefault","require","_elasticsearchFields","_elasticsearchFields2","_error","_types","_table","_form","_submission","_system","_settings","_system2","_submission2","_settings2","_form2","_tableElasticsearch","_plugins","_elasticsearch","_apiElasticsearch","_indices","_createElasticsearchIndex","_plugins2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","reservedFields","isReserved","name","includes","WebinyError","createFormBuilderStorageOperations","params","attributes","table","tableName","esTable","esTableName","documentClient","elasticsearch","plugins","userPlugins","values","attrs","PluginsContainer","submissionElasticsearchFields","formElasticsearchFields","dynamoDbValueFilters","elasticsearchIndexPlugins","createTable","createElasticsearchTable","entities","form","createFormEntity","entityName","ENTITIES","FORM","submission","createSubmissionEntity","SUBMISSION","system","createSystemEntity","SYSTEM","settings","createSettingsEntity","SETTINGS","esForm","createElasticsearchEntity","ES_FORM","esSubmission","ES_SUBMISSION","beforeInit","context","types","CompressionPlugin","type","ElasticsearchQueryBuilderOperatorPlugin","FormDynamoDbFieldPlugin","FormElasticsearchBodyModifierPlugin","FormElasticsearchFieldPlugin","FormElasticsearchIndexPlugin","FormElasticsearchQueryModifierPlugin","FormElasticsearchSortModifierPlugin","SubmissionElasticsearchBodyModifierPlugin","SubmissionElasticsearchFieldPlugin","SubmissionElasticsearchQueryModifierPlugin","SubmissionElasticsearchSortModifierPlugin","mergeByType","init","i18n","locales","onLocaleBeforeCreate","subscribe","locale","tenant","createElasticsearchIndex","code","getTable","getEsTable","getEntities","createSystemStorageOperations","entity","createSettingsStorageOperations","createFormStorageOperations","esEntity","createSubmissionStorageOperations"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters\";\nimport formElasticsearchFields from \"./operations/form/elasticsearchFields\";\nimport submissionElasticsearchFields from \"./operations/submission/elasticsearchFields\";\nimport WebinyError from \"@webiny/error\";\nimport { FormBuilderStorageOperationsFactory, ENTITIES } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\nimport { createFormEntity } from \"~/definitions/form\";\nimport { createSubmissionEntity } from \"~/definitions/submission\";\nimport { createSystemEntity } from \"~/definitions/system\";\nimport { createSettingsEntity } from \"~/definitions/settings\";\nimport { createSystemStorageOperations } from \"~/operations/system\";\nimport { createSubmissionStorageOperations } from \"~/operations/submission\";\nimport { createSettingsStorageOperations } from \"~/operations/settings\";\nimport { createFormStorageOperations } from \"~/operations/form\";\nimport { createElasticsearchTable } from \"~/definitions/tableElasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createElasticsearchEntity } from \"~/definitions/elasticsearch\";\nimport {\n CompressionPlugin,\n ElasticsearchQueryBuilderOperatorPlugin\n} from \"@webiny/api-elasticsearch\";\nimport { elasticsearchIndexPlugins } from \"~/elasticsearch/indices\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex\";\nimport { FormBuilderContext } from \"@webiny/api-form-builder/types\";\nimport {\n FormDynamoDbFieldPlugin,\n FormElasticsearchBodyModifierPlugin,\n FormElasticsearchFieldPlugin,\n FormElasticsearchIndexPlugin,\n FormElasticsearchQueryModifierPlugin,\n FormElasticsearchSortModifierPlugin,\n SubmissionElasticsearchBodyModifierPlugin,\n SubmissionElasticsearchFieldPlugin,\n SubmissionElasticsearchQueryModifierPlugin,\n SubmissionElasticsearchSortModifierPlugin\n} from \"~/plugins\";\n\nconst reservedFields = [\"PK\", \"SK\", \"index\", \"data\", \"TYPE\", \"__type\", \"GSI1_PK\", \"GSI1_SK\"];\n\nconst isReserved = (name: string): void => {\n if (reservedFields.includes(name) === false) {\n return;\n }\n throw new WebinyError(`Attribute name \"${name}\" is not allowed.`, \"ATTRIBUTE_NOT_ALLOWED\", {\n name\n });\n};\n\nexport * from \"./plugins\";\n\nexport const createFormBuilderStorageOperations: FormBuilderStorageOperationsFactory = params => {\n const {\n attributes,\n table: tableName,\n esTable: esTableName,\n documentClient,\n elasticsearch,\n plugins: userPlugins\n } = params;\n\n if (attributes) {\n Object.values(attributes).forEach(attrs => {\n Object.keys(attrs).forEach(isReserved);\n });\n }\n\n const plugins = new PluginsContainer([\n /**\n * User defined plugins.\n */\n userPlugins || [],\n /**\n * Elasticsearch field definitions for the submission record.\n */\n submissionElasticsearchFields(),\n /**\n * Elasticsearch field definitions for the form record.\n */\n formElasticsearchFields(),\n /**\n * DynamoDB filter plugins for the where conditions.\n */\n dynamoDbValueFilters(),\n /**\n * Built-in Elasticsearch index plugins\n */\n elasticsearchIndexPlugins()\n ]);\n\n const table = createTable({\n tableName,\n documentClient\n });\n\n const esTable = createElasticsearchTable({\n tableName: esTableName,\n documentClient\n });\n\n const entities = {\n /**\n * Regular entities.\n */\n form: createFormEntity({\n entityName: ENTITIES.FORM,\n table,\n attributes: attributes ? attributes[ENTITIES.FORM] : {}\n }),\n submission: createSubmissionEntity({\n entityName: ENTITIES.SUBMISSION,\n table,\n attributes: attributes ? attributes[ENTITIES.SUBMISSION] : {}\n }),\n system: createSystemEntity({\n entityName: ENTITIES.SYSTEM,\n table,\n attributes: attributes ? attributes[ENTITIES.SYSTEM] : {}\n }),\n settings: createSettingsEntity({\n entityName: ENTITIES.SETTINGS,\n table,\n attributes: attributes ? attributes[ENTITIES.SETTINGS] : {}\n }),\n /**\n * Elasticsearch entities.\n */\n esForm: createElasticsearchEntity({\n entityName: ENTITIES.ES_FORM,\n table: esTable,\n attributes: attributes ? attributes[ENTITIES.ES_FORM] : {}\n }),\n esSubmission: createElasticsearchEntity({\n entityName: ENTITIES.ES_SUBMISSION,\n table: esTable,\n attributes: attributes ? attributes[ENTITIES.ES_SUBMISSION] : {}\n })\n };\n\n return {\n beforeInit: async (context: FormBuilderContext) => {\n const types: string[] = [\n // Elasticsearch\n CompressionPlugin.type,\n ElasticsearchQueryBuilderOperatorPlugin.type,\n // Form Builder\n FormDynamoDbFieldPlugin.type,\n FormElasticsearchBodyModifierPlugin.type,\n FormElasticsearchFieldPlugin.type,\n FormElasticsearchIndexPlugin.type,\n FormElasticsearchQueryModifierPlugin.type,\n FormElasticsearchSortModifierPlugin.type,\n SubmissionElasticsearchBodyModifierPlugin.type,\n SubmissionElasticsearchFieldPlugin.type,\n SubmissionElasticsearchQueryModifierPlugin.type,\n SubmissionElasticsearchSortModifierPlugin.type\n ];\n for (const type of types) {\n plugins.mergeByType(context.plugins, type);\n }\n },\n init: async (context: FormBuilderContext) => {\n context.i18n.locales.onLocaleBeforeCreate.subscribe(async ({ locale, tenant }) => {\n await createElasticsearchIndex({\n elasticsearch,\n plugins,\n tenant,\n locale: locale.code\n });\n });\n },\n getTable: () => table,\n getEsTable: () => esTable,\n getEntities: () => entities,\n ...createSystemStorageOperations({\n table,\n entity: entities.system\n }),\n ...createSettingsStorageOperations({\n table,\n entity: entities.settings\n }),\n ...createFormStorageOperations({\n elasticsearch,\n table,\n entity: entities.form,\n esEntity: entities.esForm,\n plugins\n }),\n ...createSubmissionStorageOperations({\n elasticsearch,\n table,\n entity: entities.submission,\n esEntity: entities.esSubmission,\n plugins\n })\n };\n};\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,qBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,MAAA,G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a;MACbL,KAAK;MACLmE,MAAM,EAAElD,QAAQ,CAACM,UAAU;MAC3B+C,QAAQ,EAAErD,QAAQ,CAACkB,YAAY;MAC/B7B;IACJ,CAAC;EACL,CAAC;AACL,CAAC;AAAClB,OAAA,CAAAS,kCAAA,GAAAA,kCAAA"}
1
+ {"version":3,"names":["_filters","_interopRequireDefault","require","_elasticsearchFields","_elasticsearchFields2","_error","_types","_table","_form","_submission","_system","_settings","_system2","_submission2","_settings2","_form2","_tableElasticsearch","_plugins","_elasticsearch","_apiElasticsearch","_indices","_createElasticsearchIndex","_plugins2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_createIndexTaskPlugin","reservedFields","isReserved","name","includes","WebinyError","createFormBuilderStorageOperations","params","attributes","table","tableName","esTable","esTableName","documentClient","elasticsearch","plugins","userPlugins","values","attrs","PluginsContainer","submissionElasticsearchFields","formElasticsearchFields","dynamoDbValueFilters","elasticsearchIndexPlugins","createTable","createElasticsearchTable","entities","form","createFormEntity","entityName","ENTITIES","FORM","submission","createSubmissionEntity","SUBMISSION","system","createSystemEntity","SYSTEM","settings","createSettingsEntity","SETTINGS","esForm","createElasticsearchEntity","ES_FORM","esSubmission","ES_SUBMISSION","beforeInit","context","types","CompressionPlugin","type","ElasticsearchQueryBuilderOperatorPlugin","FormDynamoDbFieldPlugin","FormElasticsearchBodyModifierPlugin","FormElasticsearchFieldPlugin","FormElasticsearchIndexPlugin","FormElasticsearchQueryModifierPlugin","FormElasticsearchSortModifierPlugin","SubmissionElasticsearchBodyModifierPlugin","SubmissionElasticsearchFieldPlugin","SubmissionElasticsearchQueryModifierPlugin","SubmissionElasticsearchSortModifierPlugin","mergeByType","register","createIndexTaskPlugin","init","i18n","locales","onLocaleBeforeCreate","subscribe","locale","tenant","createElasticsearchIndex","code","getTable","getEsTable","getEntities","createSystemStorageOperations","entity","createSettingsStorageOperations","createFormStorageOperations","esEntity","createSubmissionStorageOperations"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters\";\nimport formElasticsearchFields from \"./operations/form/elasticsearchFields\";\nimport submissionElasticsearchFields from \"./operations/submission/elasticsearchFields\";\nimport WebinyError from \"@webiny/error\";\nimport { ENTITIES, FormBuilderStorageOperationsFactory } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\nimport { createFormEntity } from \"~/definitions/form\";\nimport { createSubmissionEntity } from \"~/definitions/submission\";\nimport { createSystemEntity } from \"~/definitions/system\";\nimport { createSettingsEntity } from \"~/definitions/settings\";\nimport { createSystemStorageOperations } from \"~/operations/system\";\nimport { createSubmissionStorageOperations } from \"~/operations/submission\";\nimport { createSettingsStorageOperations } from \"~/operations/settings\";\nimport { createFormStorageOperations } from \"~/operations/form\";\nimport { createElasticsearchTable } from \"~/definitions/tableElasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createElasticsearchEntity } from \"~/definitions/elasticsearch\";\nimport {\n CompressionPlugin,\n ElasticsearchQueryBuilderOperatorPlugin\n} from \"@webiny/api-elasticsearch\";\nimport { elasticsearchIndexPlugins } from \"~/elasticsearch/indices\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex\";\nimport { FormBuilderContext } from \"@webiny/api-form-builder/types\";\nimport {\n FormDynamoDbFieldPlugin,\n FormElasticsearchBodyModifierPlugin,\n FormElasticsearchFieldPlugin,\n FormElasticsearchIndexPlugin,\n FormElasticsearchQueryModifierPlugin,\n FormElasticsearchSortModifierPlugin,\n SubmissionElasticsearchBodyModifierPlugin,\n SubmissionElasticsearchFieldPlugin,\n SubmissionElasticsearchQueryModifierPlugin,\n SubmissionElasticsearchSortModifierPlugin\n} from \"~/plugins\";\nimport { createIndexTaskPlugin } from \"~/tasks/createIndexTaskPlugin\";\n\nconst reservedFields = [\"PK\", \"SK\", \"index\", \"data\", \"TYPE\", \"__type\", \"GSI1_PK\", \"GSI1_SK\"];\n\nconst isReserved = (name: string): void => {\n if (reservedFields.includes(name) === false) {\n return;\n }\n throw new WebinyError(`Attribute name \"${name}\" is not allowed.`, \"ATTRIBUTE_NOT_ALLOWED\", {\n name\n });\n};\n\nexport * from \"./plugins\";\n\nexport const createFormBuilderStorageOperations: FormBuilderStorageOperationsFactory = params => {\n const {\n attributes,\n table: tableName,\n esTable: esTableName,\n documentClient,\n elasticsearch,\n plugins: userPlugins\n } = params;\n\n if (attributes) {\n Object.values(attributes).forEach(attrs => {\n Object.keys(attrs).forEach(isReserved);\n });\n }\n\n const plugins = new PluginsContainer([\n /**\n * User defined plugins.\n */\n userPlugins || [],\n /**\n * Elasticsearch field definitions for the submission record.\n */\n submissionElasticsearchFields(),\n /**\n * Elasticsearch field definitions for the form record.\n */\n formElasticsearchFields(),\n /**\n * DynamoDB filter plugins for the where conditions.\n */\n dynamoDbValueFilters(),\n /**\n * Built-in Elasticsearch index plugins\n */\n elasticsearchIndexPlugins()\n ]);\n\n const table = createTable({\n tableName,\n documentClient\n });\n\n const esTable = createElasticsearchTable({\n tableName: esTableName,\n documentClient\n });\n\n const entities = {\n /**\n * Regular entities.\n */\n form: createFormEntity({\n entityName: ENTITIES.FORM,\n table,\n attributes: attributes ? attributes[ENTITIES.FORM] : {}\n }),\n submission: createSubmissionEntity({\n entityName: ENTITIES.SUBMISSION,\n table,\n attributes: attributes ? attributes[ENTITIES.SUBMISSION] : {}\n }),\n system: createSystemEntity({\n entityName: ENTITIES.SYSTEM,\n table,\n attributes: attributes ? attributes[ENTITIES.SYSTEM] : {}\n }),\n settings: createSettingsEntity({\n entityName: ENTITIES.SETTINGS,\n table,\n attributes: attributes ? attributes[ENTITIES.SETTINGS] : {}\n }),\n /**\n * Elasticsearch entities.\n */\n esForm: createElasticsearchEntity({\n entityName: ENTITIES.ES_FORM,\n table: esTable,\n attributes: attributes ? attributes[ENTITIES.ES_FORM] : {}\n }),\n esSubmission: createElasticsearchEntity({\n entityName: ENTITIES.ES_SUBMISSION,\n table: esTable,\n attributes: attributes ? attributes[ENTITIES.ES_SUBMISSION] : {}\n })\n };\n\n return {\n beforeInit: async (context: FormBuilderContext) => {\n const types: string[] = [\n // Elasticsearch\n CompressionPlugin.type,\n ElasticsearchQueryBuilderOperatorPlugin.type,\n // Form Builder\n FormDynamoDbFieldPlugin.type,\n FormElasticsearchBodyModifierPlugin.type,\n FormElasticsearchFieldPlugin.type,\n FormElasticsearchIndexPlugin.type,\n FormElasticsearchQueryModifierPlugin.type,\n FormElasticsearchSortModifierPlugin.type,\n SubmissionElasticsearchBodyModifierPlugin.type,\n SubmissionElasticsearchFieldPlugin.type,\n SubmissionElasticsearchQueryModifierPlugin.type,\n SubmissionElasticsearchSortModifierPlugin.type\n ];\n for (const type of types) {\n plugins.mergeByType(context.plugins, type);\n }\n context.plugins.register([createIndexTaskPlugin(), elasticsearchIndexPlugins()]);\n },\n init: async (context: FormBuilderContext) => {\n context.i18n.locales.onLocaleBeforeCreate.subscribe(async ({ locale, tenant }) => {\n await createElasticsearchIndex({\n elasticsearch,\n plugins,\n tenant,\n locale: locale.code\n });\n });\n },\n getTable: () => table,\n getEsTable: () => esTable,\n getEntities: () => entities,\n ...createSystemStorageOperations({\n table,\n entity: entities.system\n }),\n ...createSettingsStorageOperations({\n table,\n entity: entities.settings\n }),\n ...createFormStorageOperations({\n elasticsearch,\n table,\n entity: entities.form,\n esEntity: entities.esForm,\n plugins\n }),\n ...createSubmissionStorageOperations({\n elasticsearch,\n table,\n entity: entities.submission,\n esEntity: entities.esSubmission,\n plugins\n })\n };\n};\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,qBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,MAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GA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CAAC,CAAC;IACF,GAAG,IAAAmE,8CAAiC,EAAC;MACjCpE,aAAa;MACbL,KAAK;MACLqE,MAAM,EAAEpD,QAAQ,CAACM,UAAU;MAC3BiD,QAAQ,EAAEvD,QAAQ,CAACkB,YAAY;MAC/B7B;IACJ,CAAC;EACL,CAAC;AACL,CAAC;AAACnB,OAAA,CAAAU,kCAAA,GAAAA,kCAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-form-builder-so-ddb-es",
3
- "version": "5.39.0",
3
+ "version": "5.39.1-beta.1",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "@webiny/api-form-builder",
@@ -27,13 +27,14 @@
27
27
  "dependencies": {
28
28
  "@babel/runtime": "7.22.6",
29
29
  "@elastic/elasticsearch": "7.12.0",
30
- "@webiny/api-elasticsearch": "5.39.0",
31
- "@webiny/api-form-builder": "5.39.0",
32
- "@webiny/aws-sdk": "5.39.0",
33
- "@webiny/db-dynamodb": "5.39.0",
34
- "@webiny/error": "5.39.0",
35
- "@webiny/plugins": "5.39.0",
36
- "@webiny/utils": "5.39.0",
30
+ "@webiny/api-elasticsearch": "5.39.1-beta.1",
31
+ "@webiny/api-elasticsearch-tasks": "5.39.1-beta.1",
32
+ "@webiny/api-form-builder": "5.39.1-beta.1",
33
+ "@webiny/aws-sdk": "5.39.1-beta.1",
34
+ "@webiny/db-dynamodb": "5.39.1-beta.1",
35
+ "@webiny/error": "5.39.1-beta.1",
36
+ "@webiny/plugins": "5.39.1-beta.1",
37
+ "@webiny/utils": "5.39.1-beta.1",
37
38
  "elastic-ts": "0.8.0"
38
39
  },
39
40
  "devDependencies": {
@@ -41,11 +42,11 @@
41
42
  "@babel/core": "7.22.8",
42
43
  "@babel/preset-env": "7.22.7",
43
44
  "@babel/preset-typescript": "7.22.5",
44
- "@webiny/api-dynamodb-to-elasticsearch": "5.39.0",
45
- "@webiny/cli": "5.39.0",
46
- "@webiny/handler-aws": "5.39.0",
47
- "@webiny/handler-db": "5.39.0",
48
- "@webiny/project-utils": "5.39.0",
45
+ "@webiny/api-dynamodb-to-elasticsearch": "5.39.1-beta.1",
46
+ "@webiny/cli": "5.39.1-beta.1",
47
+ "@webiny/handler-aws": "5.39.1-beta.1",
48
+ "@webiny/handler-db": "5.39.1-beta.1",
49
+ "@webiny/project-utils": "5.39.1-beta.1",
49
50
  "csvtojson": "2.0.10",
50
51
  "jest": "29.5.0",
51
52
  "jest-dynalite": "3.6.1",
@@ -61,5 +62,5 @@
61
62
  "build": "yarn webiny run build",
62
63
  "watch": "yarn webiny run watch"
63
64
  },
64
- "gitHead": "3846541fd9c1764e6a8041f0b4208d720eb9c314"
65
+ "gitHead": "6fc74b45740bd4123dcf9b5890bfacee594208bf"
65
66
  }
@@ -0,0 +1,2 @@
1
+ import { FormBuilderContext } from "../types";
2
+ export declare const createIndexTaskPlugin: () => import("@webiny/api-elasticsearch-tasks").CreateElasticsearchIndexTaskPlugin<FormBuilderContext>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createIndexTaskPlugin = void 0;
7
+ var _apiElasticsearchTasks = require("@webiny/api-elasticsearch-tasks");
8
+ var _configurations = require("../configurations");
9
+ const createIndexTaskPlugin = () => {
10
+ return (0, _apiElasticsearchTasks.createElasticsearchIndexTaskPlugin)({
11
+ name: "elasticsearch.formBuilder.createIndexTaskPlugin",
12
+ getIndexList: async params => {
13
+ const {
14
+ context,
15
+ tenant,
16
+ locale
17
+ } = params;
18
+ const {
19
+ index
20
+ } = _configurations.configurations.es({
21
+ tenant,
22
+ locale
23
+ });
24
+ return [{
25
+ index,
26
+ settings: _configurations.configurations.indexSettings({
27
+ context,
28
+ locale
29
+ })
30
+ }];
31
+ }
32
+ });
33
+ };
34
+ exports.createIndexTaskPlugin = createIndexTaskPlugin;
35
+
36
+ //# sourceMappingURL=createIndexTaskPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_apiElasticsearchTasks","require","_configurations","createIndexTaskPlugin","createElasticsearchIndexTaskPlugin","name","getIndexList","params","context","tenant","locale","index","configurations","es","settings","indexSettings","exports"],"sources":["createIndexTaskPlugin.ts"],"sourcesContent":["import { createElasticsearchIndexTaskPlugin } from \"@webiny/api-elasticsearch-tasks\";\nimport { configurations } from \"~/configurations\";\nimport { FormBuilderContext } from \"~/types\";\n\nexport const createIndexTaskPlugin = () => {\n return createElasticsearchIndexTaskPlugin<FormBuilderContext>({\n name: \"elasticsearch.formBuilder.createIndexTaskPlugin\",\n getIndexList: async params => {\n const { context, tenant, locale } = params;\n\n const { index } = configurations.es({\n tenant,\n locale\n });\n return [\n {\n index,\n settings: configurations.indexSettings({\n context,\n locale\n })\n }\n ];\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAGO,MAAME,qBAAqB,GAAGA,CAAA,KAAM;EACvC,OAAO,IAAAC,yDAAkC,EAAqB;IAC1DC,IAAI,EAAE,iDAAiD;IACvDC,YAAY,EAAE,MAAMC,MAAM,IAAI;MAC1B,MAAM;QAAEC,OAAO;QAAEC,MAAM;QAAEC;MAAO,CAAC,GAAGH,MAAM;MAE1C,MAAM;QAAEI;MAAM,CAAC,GAAGC,8BAAc,CAACC,EAAE,CAAC;QAChCJ,MAAM;QACNC;MACJ,CAAC,CAAC;MACF,OAAO,CACH;QACIC,KAAK;QACLG,QAAQ,EAAEF,8BAAc,CAACG,aAAa,CAAC;UACnCP,OAAO;UACPE;QACJ,CAAC;MACL,CAAC,CACJ;IACL;EACJ,CAAC,CAAC;AACN,CAAC;AAACM,OAAA,CAAAb,qBAAA,GAAAA,qBAAA"}
package/types.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { FormBuilderStorageOperations as BaseFormBuilderStorageOperations, FormBuilderSystemStorageOperations as BaseFormBuilderSystemStorageOperations, FormBuilderSubmissionStorageOperations as BaseFormBuilderSubmissionStorageOperations, FormBuilderSettingsStorageOperations as BaseFormBuilderSettingsStorageOperations, FormBuilderFormStorageOperations as BaseFormBuilderFormStorageOperations } from "@webiny/api-form-builder/types";
1
+ import { FormBuilderStorageOperations as BaseFormBuilderStorageOperations, FormBuilderSystemStorageOperations as BaseFormBuilderSystemStorageOperations, FormBuilderSubmissionStorageOperations as BaseFormBuilderSubmissionStorageOperations, FormBuilderSettingsStorageOperations as BaseFormBuilderSettingsStorageOperations, FormBuilderFormStorageOperations as BaseFormBuilderFormStorageOperations, FormBuilderContext } from "@webiny/api-form-builder/types";
2
2
  import { DynamoDBClient } from "@webiny/aws-sdk/client-dynamodb";
3
3
  import { Entity, Table } from "@webiny/db-dynamodb/toolbox";
4
4
  import { AttributeDefinition } from "@webiny/db-dynamodb/toolbox";
5
5
  import { Client } from "@elastic/elasticsearch";
6
6
  import { PluginCollection } from "@webiny/plugins/types";
7
+ export { FormBuilderContext };
7
8
  export declare type Attributes = Record<string, AttributeDefinition>;
8
9
  export declare enum ENTITIES {
9
10
  FORM = "FormBuilderForm",
package/types.js CHANGED
@@ -4,6 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ENTITIES = void 0;
7
+ Object.defineProperty(exports, "FormBuilderContext", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _types.FormBuilderContext;
11
+ }
12
+ });
13
+ var _types = require("@webiny/api-form-builder/types");
7
14
  let ENTITIES = /*#__PURE__*/function (ENTITIES) {
8
15
  ENTITIES["FORM"] = "FormBuilderForm";
9
16
  ENTITIES["ES_FORM"] = "FormBuilderFormEs";
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["ENTITIES","exports"],"sources":["types.ts"],"sourcesContent":["import {\n FormBuilderStorageOperations as BaseFormBuilderStorageOperations,\n FormBuilderSystemStorageOperations as BaseFormBuilderSystemStorageOperations,\n FormBuilderSubmissionStorageOperations as BaseFormBuilderSubmissionStorageOperations,\n FormBuilderSettingsStorageOperations as BaseFormBuilderSettingsStorageOperations,\n FormBuilderFormStorageOperations as BaseFormBuilderFormStorageOperations\n} from \"@webiny/api-form-builder/types\";\nimport { DynamoDBClient } from \"@webiny/aws-sdk/client-dynamodb\";\nimport { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { AttributeDefinition } from \"@webiny/db-dynamodb/toolbox\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { PluginCollection } from \"@webiny/plugins/types\";\n\nexport type Attributes = Record<string, AttributeDefinition>;\n\nexport enum ENTITIES {\n FORM = \"FormBuilderForm\",\n ES_FORM = \"FormBuilderFormEs\",\n SUBMISSION = \"FormBuilderSubmission\",\n ES_SUBMISSION = \"FormBuilderSubmissionEs\",\n SYSTEM = \"FormBuilderSystem\",\n SETTINGS = \"FormBuilderSettings\"\n}\n\nexport interface FormBuilderStorageOperationsFactoryParams {\n documentClient: DynamoDBClient;\n elasticsearch: Client;\n table?: string;\n esTable?: string;\n attributes?: Record<ENTITIES, Attributes>;\n plugins?: PluginCollection;\n}\n\nexport interface FormBuilderSystemCreateKeysParams {\n tenant: string;\n}\n\nexport interface FormBuilderSystemStorageOperations extends BaseFormBuilderSystemStorageOperations {\n createSystemPartitionKey: (params: FormBuilderSystemCreateKeysParams) => string;\n createSystemSortKey: () => string;\n}\n\nexport interface FormBuilderFormCreateKeyParams {\n id: string;\n tenant: string;\n locale: string;\n}\n\nexport interface FormBuilderFormStorageOperations extends BaseFormBuilderFormStorageOperations {\n createFormPartitionKey: (params: FormBuilderFormCreateKeyParams) => string;\n}\n\nexport interface FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams {\n tenant: string;\n locale: string;\n formId: string;\n}\n\nexport interface FormBuilderSubmissionStorageOperations\n extends BaseFormBuilderSubmissionStorageOperations {\n createSubmissionPartitionKey: (\n params: FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams\n ) => string;\n createSubmissionSortKey: (id: string) => string;\n}\n\nexport interface FormBuilderSettingsStorageOperationsCreatePartitionKeyParams {\n tenant: string;\n locale: string;\n}\n\nexport interface FormBuilderSettingsStorageOperations\n extends BaseFormBuilderSettingsStorageOperations {\n createSettingsPartitionKey: (\n params: FormBuilderSettingsStorageOperationsCreatePartitionKeyParams\n ) => string;\n createSettingsSortKey: () => string;\n}\n\nexport type Entities = \"form\" | \"esForm\" | \"submission\" | \"esSubmission\" | \"system\" | \"settings\";\n\nexport interface FormBuilderStorageOperations\n extends BaseFormBuilderStorageOperations,\n FormBuilderSettingsStorageOperations,\n FormBuilderSubmissionStorageOperations,\n FormBuilderFormStorageOperations,\n FormBuilderSystemStorageOperations {\n getTable(): Table<string, string, string>;\n getEsTable(): Table<string, string, string>;\n getEntities(): Record<Entities, Entity<any>>;\n}\n\nexport interface FormBuilderStorageOperationsFactory {\n (params: FormBuilderStorageOperationsFactoryParams): FormBuilderStorageOperations;\n}\n"],"mappings":";;;;;;IAeYA,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;AAAAC,OAAA,CAAAD,QAAA,GAAAA,QAAA"}
1
+ {"version":3,"names":["_types","require","ENTITIES","exports"],"sources":["types.ts"],"sourcesContent":["import {\n FormBuilderStorageOperations as BaseFormBuilderStorageOperations,\n FormBuilderSystemStorageOperations as BaseFormBuilderSystemStorageOperations,\n FormBuilderSubmissionStorageOperations as BaseFormBuilderSubmissionStorageOperations,\n FormBuilderSettingsStorageOperations as BaseFormBuilderSettingsStorageOperations,\n FormBuilderFormStorageOperations as BaseFormBuilderFormStorageOperations,\n FormBuilderContext\n} from \"@webiny/api-form-builder/types\";\nimport { DynamoDBClient } from \"@webiny/aws-sdk/client-dynamodb\";\nimport { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { AttributeDefinition } from \"@webiny/db-dynamodb/toolbox\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { PluginCollection } from \"@webiny/plugins/types\";\n\nexport { FormBuilderContext };\n\nexport type Attributes = Record<string, AttributeDefinition>;\n\nexport enum ENTITIES {\n FORM = \"FormBuilderForm\",\n ES_FORM = \"FormBuilderFormEs\",\n SUBMISSION = \"FormBuilderSubmission\",\n ES_SUBMISSION = \"FormBuilderSubmissionEs\",\n SYSTEM = \"FormBuilderSystem\",\n SETTINGS = \"FormBuilderSettings\"\n}\n\nexport interface FormBuilderStorageOperationsFactoryParams {\n documentClient: DynamoDBClient;\n elasticsearch: Client;\n table?: string;\n esTable?: string;\n attributes?: Record<ENTITIES, Attributes>;\n plugins?: PluginCollection;\n}\n\nexport interface FormBuilderSystemCreateKeysParams {\n tenant: string;\n}\n\nexport interface FormBuilderSystemStorageOperations extends BaseFormBuilderSystemStorageOperations {\n createSystemPartitionKey: (params: FormBuilderSystemCreateKeysParams) => string;\n createSystemSortKey: () => string;\n}\n\nexport interface FormBuilderFormCreateKeyParams {\n id: string;\n tenant: string;\n locale: string;\n}\n\nexport interface FormBuilderFormStorageOperations extends BaseFormBuilderFormStorageOperations {\n createFormPartitionKey: (params: FormBuilderFormCreateKeyParams) => string;\n}\n\nexport interface FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams {\n tenant: string;\n locale: string;\n formId: string;\n}\n\nexport interface FormBuilderSubmissionStorageOperations\n extends BaseFormBuilderSubmissionStorageOperations {\n createSubmissionPartitionKey: (\n params: FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams\n ) => string;\n createSubmissionSortKey: (id: string) => string;\n}\n\nexport interface FormBuilderSettingsStorageOperationsCreatePartitionKeyParams {\n tenant: string;\n locale: string;\n}\n\nexport interface FormBuilderSettingsStorageOperations\n extends BaseFormBuilderSettingsStorageOperations {\n createSettingsPartitionKey: (\n params: FormBuilderSettingsStorageOperationsCreatePartitionKeyParams\n ) => string;\n createSettingsSortKey: () => string;\n}\n\nexport type Entities = \"form\" | \"esForm\" | \"submission\" | \"esSubmission\" | \"system\" | \"settings\";\n\nexport interface FormBuilderStorageOperations\n extends BaseFormBuilderStorageOperations,\n FormBuilderSettingsStorageOperations,\n FormBuilderSubmissionStorageOperations,\n FormBuilderFormStorageOperations,\n FormBuilderSystemStorageOperations {\n getTable(): Table<string, string, string>;\n getEsTable(): Table<string, string, string>;\n getEntities(): Record<Entities, Entity<any>>;\n}\n\nexport interface FormBuilderStorageOperationsFactory {\n (params: FormBuilderStorageOperationsFactoryParams): FormBuilderStorageOperations;\n}\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAOwC,IAW5BC,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;AAAAC,OAAA,CAAAD,QAAA,GAAAA,QAAA"}