@webiny/api-form-builder-so-ddb-es 0.0.0-unstable.1e66d121db → 0.0.0-unstable.40876133bb
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/elasticsearch/createElasticsearchIndex.js +2 -2
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/elasticsearch/indices/base.js +2 -6
- package/elasticsearch/indices/base.js.map +1 -1
- package/elasticsearch/indices/japanese.js +2 -6
- package/elasticsearch/indices/japanese.js.map +1 -1
- package/index.js +2 -2
- package/index.js.map +1 -1
- package/operations/form/elasticsearchBody.js +6 -14
- package/operations/form/elasticsearchBody.js.map +1 -1
- package/operations/form/index.js +3 -3
- package/operations/form/index.js.map +1 -1
- package/operations/submission/elasticsearchBody.js +6 -14
- package/operations/submission/elasticsearchBody.js.map +1 -1
- package/operations/submission/index.js +4 -6
- package/operations/submission/index.js.map +1 -1
- package/package.json +14 -14
- package/plugins/FormElasticsearchBodyModifierPlugin.d.ts +1 -1
- package/plugins/FormElasticsearchBodyModifierPlugin.js +2 -2
- package/plugins/FormElasticsearchBodyModifierPlugin.js.map +1 -1
- package/plugins/FormElasticsearchFieldPlugin.d.ts +1 -1
- package/plugins/FormElasticsearchFieldPlugin.js +2 -2
- package/plugins/FormElasticsearchFieldPlugin.js.map +1 -1
- package/plugins/FormElasticsearchIndexPlugin.d.ts +1 -1
- package/plugins/FormElasticsearchIndexPlugin.js +2 -2
- package/plugins/FormElasticsearchIndexPlugin.js.map +1 -1
- package/plugins/FormElasticsearchQueryModifierPlugin.d.ts +1 -1
- package/plugins/FormElasticsearchQueryModifierPlugin.js +2 -2
- package/plugins/FormElasticsearchQueryModifierPlugin.js.map +1 -1
- package/plugins/FormElasticsearchSortModifierPlugin.d.ts +1 -1
- package/plugins/FormElasticsearchSortModifierPlugin.js +2 -2
- package/plugins/FormElasticsearchSortModifierPlugin.js.map +1 -1
- package/plugins/SubmissionElasticsearchBodyModifierPlugin.d.ts +1 -1
- package/plugins/SubmissionElasticsearchBodyModifierPlugin.js +2 -2
- package/plugins/SubmissionElasticsearchBodyModifierPlugin.js.map +1 -1
- package/plugins/SubmissionElasticsearchFieldPlugin.d.ts +1 -1
- package/plugins/SubmissionElasticsearchFieldPlugin.js +2 -2
- package/plugins/SubmissionElasticsearchFieldPlugin.js.map +1 -1
- package/plugins/SubmissionElasticsearchQueryModifierPlugin.d.ts +1 -1
- package/plugins/SubmissionElasticsearchQueryModifierPlugin.js +2 -2
- package/plugins/SubmissionElasticsearchQueryModifierPlugin.js.map +1 -1
- package/plugins/SubmissionElasticsearchSortModifierPlugin.d.ts +1 -1
- package/plugins/SubmissionElasticsearchSortModifierPlugin.js +2 -2
- package/plugins/SubmissionElasticsearchSortModifierPlugin.js.map +1 -1
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.createElasticsearchIndex = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
11
11
|
|
|
12
12
|
var _FormElasticsearchIndexPlugin = require("../plugins/FormElasticsearchIndexPlugin");
|
|
13
13
|
|
|
@@ -22,7 +22,7 @@ const createElasticsearchIndex = async params => {
|
|
|
22
22
|
locale,
|
|
23
23
|
tenant
|
|
24
24
|
} = params;
|
|
25
|
-
const plugin = (0,
|
|
25
|
+
const plugin = (0, _apiElasticsearch.getLastAddedIndexPlugin)({
|
|
26
26
|
container,
|
|
27
27
|
type: _FormElasticsearchIndexPlugin.FormElasticsearchIndexPlugin.type,
|
|
28
28
|
locale
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createElasticsearchIndex","params","elasticsearch","plugins","container","locale","tenant","plugin","getLastAddedIndexPlugin","type","FormElasticsearchIndexPlugin","index","configurations","es","response","indices","exists","body","create","ex","WebinyError","message","code","error"],"sources":["createElasticsearchIndex.ts"],"sourcesContent":["import { Client } from \"@elastic/elasticsearch\";\nimport { getLastAddedIndexPlugin } from \"@webiny/api-elasticsearch
|
|
1
|
+
{"version":3,"names":["createElasticsearchIndex","params","elasticsearch","plugins","container","locale","tenant","plugin","getLastAddedIndexPlugin","type","FormElasticsearchIndexPlugin","index","configurations","es","response","indices","exists","body","create","ex","WebinyError","message","code","error"],"sources":["createElasticsearchIndex.ts"],"sourcesContent":["import { Client } from \"@elastic/elasticsearch\";\nimport { getLastAddedIndexPlugin } from \"@webiny/api-elasticsearch\";\nimport { FormElasticsearchIndexPlugin } from \"~/plugins/FormElasticsearchIndexPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\nimport { configurations } from \"~/configurations\";\n\ninterface CreateElasticsearchIndexParams {\n elasticsearch: Client;\n plugins: PluginsContainer;\n tenant: string;\n locale: string;\n}\n\nexport const createElasticsearchIndex = async (params: CreateElasticsearchIndexParams) => {\n const { elasticsearch, plugins: container, locale, tenant } = params;\n\n const plugin = getLastAddedIndexPlugin<FormElasticsearchIndexPlugin>({\n container,\n type: FormElasticsearchIndexPlugin.type,\n locale\n });\n\n const { index } = configurations.es({\n locale,\n tenant\n });\n\n try {\n const response = await elasticsearch.indices.exists({\n index\n });\n if (response.body) {\n return;\n }\n\n await elasticsearch.indices.create({\n index,\n body: plugin.body\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create Elasticsearch index for the Form Builder.\",\n ex.code || \"FB_ELASTICSEARCH_INDEX_ERROR\",\n {\n error: ex,\n type: FormElasticsearchIndexPlugin.type,\n locale,\n tenant,\n index,\n body: plugin.body\n }\n );\n }\n};\n"],"mappings":";;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AASO,MAAMA,wBAAwB,GAAG,MAAOC,MAAP,IAAkD;EACtF,MAAM;IAAEC,aAAF;IAAiBC,OAAO,EAAEC,SAA1B;IAAqCC,MAArC;IAA6CC;EAA7C,IAAwDL,MAA9D;EAEA,MAAMM,MAAM,GAAG,IAAAC,yCAAA,EAAsD;IACjEJ,SADiE;IAEjEK,IAAI,EAAEC,0DAAA,CAA6BD,IAF8B;IAGjEJ;EAHiE,CAAtD,CAAf;;EAMA,MAAM;IAAEM;EAAF,IAAYC,8BAAA,CAAeC,EAAf,CAAkB;IAChCR,MADgC;IAEhCC;EAFgC,CAAlB,CAAlB;;EAKA,IAAI;IACA,MAAMQ,QAAQ,GAAG,MAAMZ,aAAa,CAACa,OAAd,CAAsBC,MAAtB,CAA6B;MAChDL;IADgD,CAA7B,CAAvB;;IAGA,IAAIG,QAAQ,CAACG,IAAb,EAAmB;MACf;IACH;;IAED,MAAMf,aAAa,CAACa,OAAd,CAAsBG,MAAtB,CAA6B;MAC/BP,KAD+B;MAE/BM,IAAI,EAAEV,MAAM,CAACU;IAFkB,CAA7B,CAAN;EAIH,CAZD,CAYE,OAAOE,EAAP,EAAW;IACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,4DADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,8BAFT,EAGF;MACIC,KAAK,EAAEJ,EADX;MAEIV,IAAI,EAAEC,0DAAA,CAA6BD,IAFvC;MAGIJ,MAHJ;MAIIC,MAJJ;MAKIK,KALJ;MAMIM,IAAI,EAAEV,MAAM,CAACU;IANjB,CAHE,CAAN;EAYH;AACJ,CAxCM"}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.base = void 0;
|
|
9
7
|
|
|
10
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
8
|
var _FormElasticsearchIndexPlugin = require("../../plugins/FormElasticsearchIndexPlugin");
|
|
13
9
|
|
|
14
|
-
var
|
|
10
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
15
11
|
|
|
16
12
|
const base = new _FormElasticsearchIndexPlugin.FormElasticsearchIndexPlugin({
|
|
17
|
-
body: (0,
|
|
13
|
+
body: (0, _apiElasticsearch.getBaseConfiguration)()
|
|
18
14
|
});
|
|
19
15
|
exports.base = base;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["base","FormElasticsearchIndexPlugin","body","
|
|
1
|
+
{"version":3,"names":["base","FormElasticsearchIndexPlugin","body","getBaseConfiguration"],"sources":["base.ts"],"sourcesContent":["import { FormElasticsearchIndexPlugin } from \"~/plugins/FormElasticsearchIndexPlugin\";\nimport { getBaseConfiguration } from \"@webiny/api-elasticsearch\";\n\nexport const base = new FormElasticsearchIndexPlugin({\n body: getBaseConfiguration()\n});\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEO,MAAMA,IAAI,GAAG,IAAIC,0DAAJ,CAAiC;EACjDC,IAAI,EAAE,IAAAC,sCAAA;AAD2C,CAAjC,CAAb"}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.japanese = void 0;
|
|
9
7
|
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _japanese = require("@webiny/api-elasticsearch/indexConfiguration/japanese");
|
|
8
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
13
9
|
|
|
14
10
|
var _FormElasticsearchIndexPlugin = require("../../plugins/FormElasticsearchIndexPlugin");
|
|
15
11
|
|
|
16
12
|
const japanese = new _FormElasticsearchIndexPlugin.FormElasticsearchIndexPlugin({
|
|
17
|
-
body: (0,
|
|
13
|
+
body: (0, _apiElasticsearch.getJapaneseConfiguration)(),
|
|
18
14
|
locales: ["ja", "ja-jp"]
|
|
19
15
|
});
|
|
20
16
|
exports.japanese = japanese;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["japanese","FormElasticsearchIndexPlugin","body","
|
|
1
|
+
{"version":3,"names":["japanese","FormElasticsearchIndexPlugin","body","getJapaneseConfiguration","locales"],"sources":["japanese.ts"],"sourcesContent":["import { getJapaneseConfiguration } from \"@webiny/api-elasticsearch\";\nimport { FormElasticsearchIndexPlugin } from \"~/plugins/FormElasticsearchIndexPlugin\";\n\nexport const japanese = new FormElasticsearchIndexPlugin({\n body: getJapaneseConfiguration(),\n locales: [\"ja\", \"ja-jp\"]\n});\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEO,MAAMA,QAAQ,GAAG,IAAIC,0DAAJ,CAAiC;EACrDC,IAAI,EAAE,IAAAC,0CAAA,GAD+C;EAErDC,OAAO,EAAE,CAAC,IAAD,EAAO,OAAP;AAF4C,CAAjC,CAAjB"}
|
package/index.js
CHANGED
|
@@ -43,7 +43,7 @@ var _plugins = require("@webiny/plugins");
|
|
|
43
43
|
|
|
44
44
|
var _elasticsearch = require("./definitions/elasticsearch");
|
|
45
45
|
|
|
46
|
-
var
|
|
46
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
47
47
|
|
|
48
48
|
var _indices = require("./elasticsearch/indices");
|
|
49
49
|
|
|
@@ -97,7 +97,7 @@ const createFormBuilderStorageOperations = params => {
|
|
|
97
97
|
/**
|
|
98
98
|
* Elasticsearch operators.
|
|
99
99
|
*/
|
|
100
|
-
(0,
|
|
100
|
+
(0, _apiElasticsearch.getElasticsearchOperators)(),
|
|
101
101
|
/**
|
|
102
102
|
* Built-in Elasticsearch index plugins
|
|
103
103
|
*/
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["reservedFields","isReserved","name","includes","WebinyError","createFormBuilderStorageOperations","params","attributes","table","tableName","esTable","esTableName","documentClient","elasticsearch","plugins","userPlugins","Object","values","forEach","attrs","keys","PluginsContainer","submissionElasticsearchFields","formElasticsearchFields","dynamoDbValueFilters","getElasticsearchOperators","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","init","context","i18n","locales","onLocaleBeforeCreate","subscribe","locale","tenant","createElasticsearchIndex","code","upgrade","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 { getElasticsearchOperators } from \"@webiny/api-elasticsearch/operators\";\nimport { elasticsearchIndexPlugins } from \"~/elasticsearch/indices\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex\";\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 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 * Elasticsearch operators.\n */\n getElasticsearchOperators(),\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 init: async context => {\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 upgrade: null,\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;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA,MAAMA,cAAc,GAAG,CAAC,IAAD,EAAO,IAAP,EAAa,OAAb,EAAsB,MAAtB,EAA8B,MAA9B,EAAsC,QAAtC,EAAgD,SAAhD,EAA2D,SAA3D,CAAvB;;AAEA,MAAMC,UAAU,GAAIC,IAAD,IAAwB;EACvC,IAAIF,cAAc,CAACG,QAAf,CAAwBD,IAAxB,MAAkC,KAAtC,EAA6C;IACzC;EACH;;EACD,MAAM,IAAIE,cAAJ,CAAiB,mBAAkBF,IAAK,mBAAxC,EAA4D,uBAA5D,EAAqF;IACvFA;EADuF,CAArF,CAAN;AAGH,CAPD;;AASO,MAAMG,kCAAuE,GAAGC,MAAM,IAAI;EAC7F,MAAM;IACFC,UADE;IAEFC,KAAK,EAAEC,SAFL;IAGFC,OAAO,EAAEC,WAHP;IAIFC,cAJE;IAKFC,aALE;IAMFC,OAAO,EAAEC;EANP,IAOFT,MAPJ;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AAkC,sCAAA,EAA8B;IAC7BvD,KAD6B;IAE7BwD,MAAM,EAAEnC,QAAQ,CAACS;EAFY,CAA9B,CAfP,GAmBO,IAAA2B,0CAAA,EAAgC;IAC/BzD,KAD+B;IAE/BwD,MAAM,EAAEnC,QAAQ,CAACY;EAFc,CAAhC,CAnBP,GAuBO,IAAAyB,kCAAA,EAA4B;IAC3BrD,aAD2B;IAE3BL,KAF2B;IAG3BwD,MAAM,EAAEnC,QAAQ,CAACC,IAHU;IAI3BqC,QAAQ,EAAEtC,QAAQ,CAACe,MAJQ;IAK3B9B;EAL2B,CAA5B,CAvBP,GA8BO,IAAAsD,8CAAA,EAAkC;IACjCvD,aADiC;IAEjCL,KAFiC;IAGjCwD,MAAM,EAAEnC,QAAQ,CAACM,UAHgB;IAIjCgC,QAAQ,EAAEtC,QAAQ,CAACkB,YAJc;IAKjCjC;EALiC,CAAlC,CA9BP;AAsCH,CAlIM"}
|
|
1
|
+
{"version":3,"names":["reservedFields","isReserved","name","includes","WebinyError","createFormBuilderStorageOperations","params","attributes","table","tableName","esTable","esTableName","documentClient","elasticsearch","plugins","userPlugins","Object","values","forEach","attrs","keys","PluginsContainer","submissionElasticsearchFields","formElasticsearchFields","dynamoDbValueFilters","getElasticsearchOperators","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","init","context","i18n","locales","onLocaleBeforeCreate","subscribe","locale","tenant","createElasticsearchIndex","code","upgrade","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 { getElasticsearchOperators } from \"@webiny/api-elasticsearch\";\nimport { elasticsearchIndexPlugins } from \"~/elasticsearch/indices\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex\";\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 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 * Elasticsearch operators.\n */\n getElasticsearchOperators(),\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 init: async context => {\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 upgrade: null,\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":";;;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C;EALiC,CAAlC,CA9BP;AAsCH,CAlIM"}
|
|
@@ -9,11 +9,7 @@ exports.createFormElasticType = exports.createElasticsearchBody = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
var _sort = require("@webiny/api-elasticsearch/sort");
|
|
15
|
-
|
|
16
|
-
var _limit = require("@webiny/api-elasticsearch/limit");
|
|
12
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
17
13
|
|
|
18
14
|
var _FormElasticsearchFieldPlugin = require("../../plugins/FormElasticsearchFieldPlugin");
|
|
19
15
|
|
|
@@ -23,10 +19,6 @@ var _FormElasticsearchBodyModifierPlugin = require("../../plugins/FormElasticsea
|
|
|
23
19
|
|
|
24
20
|
var _FormElasticsearchQueryModifierPlugin = require("../../plugins/FormElasticsearchQueryModifierPlugin");
|
|
25
21
|
|
|
26
|
-
var _where = require("@webiny/api-elasticsearch/where");
|
|
27
|
-
|
|
28
|
-
var _operators = require("@webiny/api-elasticsearch/operators");
|
|
29
|
-
|
|
30
22
|
const createFormElasticType = () => {
|
|
31
23
|
return "fb.form";
|
|
32
24
|
};
|
|
@@ -61,7 +53,7 @@ const createElasticsearchQuery = params => {
|
|
|
61
53
|
* Be aware that, if having more registered operator plugins of same type, the last one will be used.
|
|
62
54
|
*/
|
|
63
55
|
|
|
64
|
-
const operatorPlugins = (0,
|
|
56
|
+
const operatorPlugins = (0, _apiElasticsearch.getElasticsearchOperatorPluginsByLocale)(plugins, initialWhere.locale);
|
|
65
57
|
const where = (0, _objectSpread2.default)({}, initialWhere);
|
|
66
58
|
/**
|
|
67
59
|
* !!! IMPORTANT !!! There are few specific cases where we hardcode the query conditions.
|
|
@@ -100,7 +92,7 @@ const createElasticsearchQuery = params => {
|
|
|
100
92
|
* We apply other conditions as they are passed via the where value.
|
|
101
93
|
*/
|
|
102
94
|
|
|
103
|
-
(0,
|
|
95
|
+
(0, _apiElasticsearch.applyWhere)({
|
|
104
96
|
query,
|
|
105
97
|
where,
|
|
106
98
|
fields: fieldPlugins,
|
|
@@ -121,11 +113,11 @@ const createElasticsearchBody = params => {
|
|
|
121
113
|
acc[plugin.field] = plugin;
|
|
122
114
|
return acc;
|
|
123
115
|
}, {});
|
|
124
|
-
const limit = (0,
|
|
116
|
+
const limit = (0, _apiElasticsearch.createLimit)(initialLimit, 100);
|
|
125
117
|
const query = createElasticsearchQuery((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
126
118
|
fieldPlugins
|
|
127
119
|
}));
|
|
128
|
-
const sort = (0,
|
|
120
|
+
const sort = (0, _apiElasticsearch.createSort)({
|
|
129
121
|
sort: initialSort,
|
|
130
122
|
fieldPlugins
|
|
131
123
|
});
|
|
@@ -161,7 +153,7 @@ const createElasticsearchBody = params => {
|
|
|
161
153
|
* Which is correct in some cases. In our case, it is not.
|
|
162
154
|
* https://www.elastic.co/guide/en/elasticsearch/reference/7.13/paginate-search-results.html
|
|
163
155
|
*/
|
|
164
|
-
search_after: (0,
|
|
156
|
+
search_after: (0, _apiElasticsearch.decodeCursor)(after),
|
|
165
157
|
sort
|
|
166
158
|
};
|
|
167
159
|
const bodyModifiers = plugins.byType(_FormElasticsearchBodyModifierPlugin.FormElasticsearchBodyModifierPlugin.type);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createFormElasticType","createInitialQueryValue","must","term","must_not","should","filter","createElasticsearchQuery","params","plugins","where","initialWhere","fieldPlugins","query","operatorPlugins","getElasticsearchOperatorPluginsByLocale","locale","sharedIndex","process","env","ELASTICSEARCH_SHARED_INDEXES","tenant","push","applyWhere","fields","operators","createElasticsearchBody","limit","initialLimit","sort","initialSort","after","byType","FormElasticsearchFieldPlugin","type","reduce","acc","plugin","field","createLimit","createSort","queryModifiers","FormElasticsearchQueryModifierPlugin","modifyQuery","sortModifiers","FormElasticsearchSortModifierPlugin","modifySort","body","constant_score","bool","size","search_after","decodeCursor","bodyModifiers","FormElasticsearchBodyModifierPlugin","modifyBody"],"sources":["elasticsearchBody.ts"],"sourcesContent":["import { SearchBody as esSearchBody } from \"elastic-ts\";\nimport {
|
|
1
|
+
{"version":3,"names":["createFormElasticType","createInitialQueryValue","must","term","must_not","should","filter","createElasticsearchQuery","params","plugins","where","initialWhere","fieldPlugins","query","operatorPlugins","getElasticsearchOperatorPluginsByLocale","locale","sharedIndex","process","env","ELASTICSEARCH_SHARED_INDEXES","tenant","push","applyWhere","fields","operators","createElasticsearchBody","limit","initialLimit","sort","initialSort","after","byType","FormElasticsearchFieldPlugin","type","reduce","acc","plugin","field","createLimit","createSort","queryModifiers","FormElasticsearchQueryModifierPlugin","modifyQuery","sortModifiers","FormElasticsearchSortModifierPlugin","modifySort","body","constant_score","bool","size","search_after","decodeCursor","bodyModifiers","FormElasticsearchBodyModifierPlugin","modifyBody"],"sources":["elasticsearchBody.ts"],"sourcesContent":["import { SearchBody as esSearchBody } from \"elastic-ts\";\nimport {\n decodeCursor,\n getElasticsearchOperatorPluginsByLocale,\n applyWhere,\n createLimit,\n createSort\n} from \"@webiny/api-elasticsearch\";\nimport { ElasticsearchBoolQueryConfig } from \"@webiny/api-elasticsearch/types\";\nimport { FormElasticsearchFieldPlugin } from \"~/plugins/FormElasticsearchFieldPlugin\";\nimport { FormElasticsearchSortModifierPlugin } from \"~/plugins/FormElasticsearchSortModifierPlugin\";\nimport { FormElasticsearchBodyModifierPlugin } from \"~/plugins/FormElasticsearchBodyModifierPlugin\";\nimport { FormBuilderStorageOperationsListFormsParams } from \"@webiny/api-form-builder/types\";\nimport { FormElasticsearchQueryModifierPlugin } from \"~/plugins/FormElasticsearchQueryModifierPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\nexport const createFormElasticType = (): string => {\n return \"fb.form\";\n};\n\nconst createInitialQueryValue = (): ElasticsearchBoolQueryConfig => {\n return {\n must: [\n /**\n * We add the __type filtering in the initial query because it must be applied.\n */\n {\n term: {\n \"__type.keyword\": createFormElasticType()\n }\n }\n ],\n must_not: [],\n should: [],\n filter: []\n };\n};\n\ninterface CreateElasticsearchQueryParams extends CreateElasticsearchBodyParams {\n fieldPlugins: Record<string, FormElasticsearchFieldPlugin>;\n}\n\nconst createElasticsearchQuery = (params: CreateElasticsearchQueryParams) => {\n const { plugins, where: initialWhere, fieldPlugins } = params;\n const query = createInitialQueryValue();\n /**\n * Be aware that, if having more registered operator plugins of same type, the last one will be used.\n */\n const operatorPlugins = getElasticsearchOperatorPluginsByLocale(plugins, initialWhere.locale);\n\n const where: Partial<FormBuilderStorageOperationsListFormsParams[\"where\"]> = {\n ...initialWhere\n };\n /**\n * !!! IMPORTANT !!! There are few specific cases where we hardcode the query conditions.\n *\n * When ES index is shared between tenants, we need to filter records by tenant ID.\n * No need for the tenant filtering otherwise as each index is for single tenant.\n */\n const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === \"true\";\n if (sharedIndex && where.tenant) {\n query.must.push({\n term: {\n \"tenant.keyword\": where.tenant\n }\n });\n }\n /**\n * Remove tenant so it is not applied again later.\n * Possibly tenant is not defined, but just in case, remove it.\n */\n delete where.tenant;\n /**\n * Add the locale to filtering.\n */\n query.must.push({\n term: {\n \"locale.keyword\": where.locale as string\n }\n });\n delete where.locale;\n /**\n * We apply other conditions as they are passed via the where value.\n */\n applyWhere({\n query,\n where,\n fields: fieldPlugins,\n operators: operatorPlugins\n });\n\n return query;\n};\n\ninterface CreateElasticsearchBodyParams {\n plugins: PluginsContainer;\n where: FormBuilderStorageOperationsListFormsParams[\"where\"];\n limit: number;\n after?: string;\n sort: string[];\n}\n\nexport const createElasticsearchBody = (params: CreateElasticsearchBodyParams): esSearchBody => {\n const { plugins, where, limit: initialLimit, sort: initialSort, after } = params;\n\n const fieldPlugins = plugins\n .byType<FormElasticsearchFieldPlugin>(FormElasticsearchFieldPlugin.type)\n .reduce((acc, plugin) => {\n acc[plugin.field] = plugin;\n return acc;\n }, {} as Record<string, FormElasticsearchFieldPlugin>);\n\n const limit = createLimit(initialLimit, 100);\n\n const query = createElasticsearchQuery({\n ...params,\n fieldPlugins\n });\n\n const sort = createSort({\n sort: initialSort,\n fieldPlugins\n });\n\n const queryModifiers = plugins.byType<FormElasticsearchQueryModifierPlugin>(\n FormElasticsearchQueryModifierPlugin.type\n );\n\n for (const plugin of queryModifiers) {\n plugin.modifyQuery({\n query,\n where\n });\n }\n\n const sortModifiers = plugins.byType<FormElasticsearchSortModifierPlugin>(\n FormElasticsearchSortModifierPlugin.type\n );\n\n for (const plugin of sortModifiers) {\n plugin.modifySort({\n sort\n });\n }\n\n const body = {\n query: {\n constant_score: {\n filter: {\n bool: {\n ...query\n }\n }\n }\n },\n size: limit + 1,\n /**\n * Casting as any is required due to search_after is accepting an array of values.\n * Which is correct in some cases. In our case, it is not.\n * https://www.elastic.co/guide/en/elasticsearch/reference/7.13/paginate-search-results.html\n */\n search_after: decodeCursor(after) as any,\n sort\n };\n\n const bodyModifiers = plugins.byType<FormElasticsearchBodyModifierPlugin>(\n FormElasticsearchBodyModifierPlugin.type\n );\n\n for (const plugin of bodyModifiers) {\n plugin.modifyBody({\n body\n });\n }\n\n return body;\n};\n"],"mappings":";;;;;;;;;;;AACA;;AAQA;;AACA;;AACA;;AAEA;;AAGO,MAAMA,qBAAqB,GAAG,MAAc;EAC/C,OAAO,SAAP;AACH,CAFM;;;;AAIP,MAAMC,uBAAuB,GAAG,MAAoC;EAChE,OAAO;IACHC,IAAI,EAAE;IACF;AACZ;AACA;IACY;MACIC,IAAI,EAAE;QACF,kBAAkBH,qBAAqB;MADrC;IADV,CAJE,CADH;IAWHI,QAAQ,EAAE,EAXP;IAYHC,MAAM,EAAE,EAZL;IAaHC,MAAM,EAAE;EAbL,CAAP;AAeH,CAhBD;;AAsBA,MAAMC,wBAAwB,GAAIC,MAAD,IAA4C;EACzE,MAAM;IAAEC,OAAF;IAAWC,KAAK,EAAEC,YAAlB;IAAg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_utils = require("@webiny/utils");
|
|
|
29
29
|
|
|
30
30
|
var _elasticsearchBody = require("./elasticsearchBody");
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
33
33
|
|
|
34
34
|
const getESDataForLatestRevision = form => ({
|
|
35
35
|
__type: (0, _elasticsearchBody.createFormElasticType)(),
|
|
@@ -368,7 +368,7 @@ const createFormStorageOperations = params => {
|
|
|
368
368
|
sort,
|
|
369
369
|
limit: limit + 1,
|
|
370
370
|
where,
|
|
371
|
-
after: (0,
|
|
371
|
+
after: (0, _apiElasticsearch.decodeCursor)(after)
|
|
372
372
|
});
|
|
373
373
|
|
|
374
374
|
const esConfig = _configurations.configurations.es({
|
|
@@ -412,7 +412,7 @@ const createFormStorageOperations = params => {
|
|
|
412
412
|
const meta = {
|
|
413
413
|
hasMoreItems,
|
|
414
414
|
totalCount: total.value,
|
|
415
|
-
cursor: items.length > 0 ? (0,
|
|
415
|
+
cursor: items.length > 0 ? (0, _apiElasticsearch.encodeCursor)(hits[items.length - 1].sort) || null : null
|
|
416
416
|
};
|
|
417
417
|
return {
|
|
418
418
|
items,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getESDataForLatestRevision","form","__type","createFormElasticType","id","createdOn","savedOn","name","slug","published","publishedOn","version","locked","status","createdBy","ownedBy","tenant","locale","webinyVersion","formId","createFormStorageOperations","params","entity","esEntity","table","plugins","elasticsearch","formDynamoDbFields","fields","createFormPartitionKey","targetId","parseIdentifier","createRevisionSortKey","value","Number","zeroPad","createLatestSortKey","createLatestPublishedSortKey","createFormType","createFormLatestType","createFormLatestPublishedType","createForm","revisionKeys","PK","SK","latestKeys","items","putBatch","TYPE","batchWriteAll","ex","WebinyError","message","code","index","configurations","es","put","data","createFormFrom","original","latest","updateForm","latestForm","getForm","where","isLatestForm","push","sortKey","keys","result","get","Item","cleanupItem","listForms","sort","limit","after","body","createElasticsearchBody","decodeCursor","esConfig","query","response","search","hits","total","map","item","_source","hasMoreItems","length","pop","meta","totalCount","cursor","encodeCursor","listFormRevisions","initialWhere","queryAllParams","partitionKey","options","beginsWith","queryAll","undefined","filteredItems","filterItems","sortItems","deleteForm","gte","deleteItems","deleteBatch","delete","deleteFormRevision","revisions","previous","latestPublishedForm","find","rev","isLatest","isLatestPublished","esDataItem","previouslyPublishedForm","filter","f","a","b","Date","getTime","shift","publishForm","latestPublishedKeys","esData","unpublishForm","version_not","publishedOn_not","previouslyPublishedRevision"],"sources":["index.ts"],"sourcesContent":["import {\n FbForm,\n FormBuilderStorageOperationsCreateFormFromParams,\n FormBuilderStorageOperationsCreateFormParams,\n FormBuilderStorageOperationsDeleteFormParams,\n FormBuilderStorageOperationsDeleteFormRevisionParams,\n FormBuilderStorageOperationsGetFormParams,\n FormBuilderStorageOperationsListFormRevisionsParams,\n FormBuilderStorageOperationsListFormRevisionsParamsWhere,\n FormBuilderStorageOperationsListFormsParams,\n FormBuilderStorageOperationsListFormsResponse,\n FormBuilderStorageOperationsPublishFormParams,\n FormBuilderStorageOperationsUnpublishFormParams,\n FormBuilderStorageOperationsUpdateFormParams\n} from \"@webiny/api-form-builder/types\";\nimport { Entity, Table } from \"dynamodb-toolbox\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport WebinyError from \"@webiny/error\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { batchWriteAll } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport { configurations } from \"~/configurations\";\nimport { filterItems } from \"@webiny/db-dynamodb/utils/filter\";\nimport fields from \"./fields\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\nimport { parseIdentifier, zeroPad } from \"@webiny/utils\";\nimport { createElasticsearchBody, createFormElasticType } from \"./elasticsearchBody\";\nimport { decodeCursor, encodeCursor } from \"@webiny/api-elasticsearch/cursors\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { FormBuilderFormCreateKeyParams, FormBuilderFormStorageOperations } from \"~/types\";\nimport { ElasticsearchSearchResponse } from \"@webiny/api-elasticsearch/types\";\n\nexport type DbRecord<T = any> = T & {\n PK: string;\n SK: string;\n TYPE: string;\n};\n\nexport interface CreateFormStorageOperationsParams {\n entity: Entity<any>;\n esEntity: Entity<any>;\n table: Table;\n elasticsearch: Client;\n plugins: PluginsContainer;\n}\n\ntype FbFormElastic = Omit<FbForm, \"triggers\" | \"fields\" | \"settings\" | \"layout\" | \"stats\"> & {\n __type: string;\n};\n\nconst getESDataForLatestRevision = (form: FbForm): FbFormElastic => ({\n __type: createFormElasticType(),\n id: form.id,\n createdOn: form.createdOn,\n savedOn: form.savedOn,\n name: form.name,\n slug: form.slug,\n published: form.published,\n publishedOn: form.publishedOn,\n version: form.version,\n locked: form.locked,\n status: form.status,\n createdBy: form.createdBy,\n ownedBy: form.ownedBy,\n tenant: form.tenant,\n locale: form.locale,\n webinyVersion: form.webinyVersion,\n formId: form.formId\n});\n\nexport const createFormStorageOperations = (\n params: CreateFormStorageOperationsParams\n): FormBuilderFormStorageOperations => {\n const { entity, esEntity, table, plugins, elasticsearch } = params;\n\n const formDynamoDbFields = fields();\n\n const createFormPartitionKey = (params: FormBuilderFormCreateKeyParams): string => {\n const { tenant, locale, id: targetId } = params;\n\n const { id } = parseIdentifier(targetId);\n\n return `T#${tenant}#L#${locale}#FB#F#${id}`;\n };\n\n const createRevisionSortKey = (value: string | number | undefined): string => {\n const version =\n typeof value === \"number\" ? Number(value) : (parseIdentifier(value).version as number);\n return `REV#${zeroPad(version)}`;\n };\n\n const createLatestSortKey = (): string => {\n return \"L\";\n };\n\n const createLatestPublishedSortKey = (): string => {\n return \"LP\";\n };\n\n const createFormType = (): string => {\n return \"fb.form\";\n };\n\n const createFormLatestType = (): string => {\n return \"fb.form.latest\";\n };\n\n const createFormLatestPublishedType = (): string => {\n return \"fb.form.latestPublished\";\n };\n\n const createForm = async (\n params: FormBuilderStorageOperationsCreateFormParams\n ): Promise<FbForm> => {\n const { form } = params;\n\n const revisionKeys = {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form.id)\n };\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\n\n const items = [\n entity.putBatch({\n ...form,\n TYPE: createFormType(),\n ...revisionKeys\n }),\n entity.putBatch({\n ...form,\n TYPE: createFormLatestType(),\n ...latestKeys\n })\n ];\n\n try {\n await batchWriteAll({\n table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert form data into regular table.\",\n ex.code || \"CREATE_FORM_ERROR\",\n {\n revisionKeys,\n latestKeys,\n form\n }\n );\n }\n try {\n const { index } = configurations.es({\n tenant: form.tenant,\n locale: form.locale\n });\n await esEntity.put({\n index,\n data: getESDataForLatestRevision(form),\n TYPE: createFormType(),\n ...latestKeys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert form data into Elasticsearch table.\",\n ex.code || \"CREATE_FORM_ERROR\",\n {\n latestKeys,\n form\n }\n );\n }\n return form;\n };\n\n const createFormFrom = async (\n params: FormBuilderStorageOperationsCreateFormFromParams\n ): Promise<FbForm> => {\n const { form, original, latest } = params;\n\n const revisionKeys = {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form.version)\n };\n\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\n\n const items = [\n entity.putBatch({\n ...form,\n ...revisionKeys,\n TYPE: createFormType()\n }),\n entity.putBatch({\n ...form,\n ...latestKeys,\n TYPE: createFormLatestType()\n })\n ];\n\n try {\n await batchWriteAll({\n table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not create form data in the regular table, from existing form.\",\n ex.code || \"CREATE_FORM_FROM_ERROR\",\n {\n revisionKeys,\n latestKeys,\n original,\n form,\n latest\n }\n );\n }\n\n try {\n const { index } = configurations.es({\n tenant: form.tenant,\n locale: form.locale\n });\n await esEntity.put({\n index,\n data: getESDataForLatestRevision(form),\n TYPE: createFormLatestType(),\n ...latestKeys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not create form in the Elasticsearch table, from existing form.\",\n ex.code || \"CREATE_FORM_FROM_ERROR\",\n {\n latestKeys,\n form,\n latest,\n original\n }\n );\n }\n return form;\n };\n\n const updateForm = async (\n params: FormBuilderStorageOperationsUpdateFormParams\n ): Promise<FbForm> => {\n const { form, original } = params;\n\n const revisionKeys = {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form.id)\n };\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\n\n const { formId, tenant, locale } = form;\n\n const latestForm = await getForm({\n where: {\n formId,\n tenant,\n locale,\n latest: true\n }\n });\n const isLatestForm = latestForm ? latestForm.id === form.id : false;\n\n const items = [\n entity.putBatch({\n ...form,\n TYPE: createFormType(),\n ...revisionKeys\n })\n ];\n if (isLatestForm) {\n items.push(\n entity.putBatch({\n ...form,\n TYPE: createFormLatestType(),\n ...latestKeys\n })\n );\n }\n try {\n await batchWriteAll({\n table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update form data in the regular table.\",\n ex.code || \"UPDATE_FORM_ERROR\",\n {\n revisionKeys,\n latestKeys,\n original,\n form,\n latestForm\n }\n );\n }\n /**\n * No need to go further if its not latest form.\n */\n if (!isLatestForm) {\n return form;\n }\n\n try {\n const { index } = configurations.es({\n tenant: form.tenant,\n locale: form.locale\n });\n await esEntity.put({\n index,\n data: getESDataForLatestRevision(form),\n TYPE: createFormLatestType(),\n ...latestKeys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update form data in the Elasticsearch table.\",\n ex.code || \"UPDATE_FORM_ERROR\",\n {\n latestKeys,\n form,\n latestForm,\n original\n }\n );\n }\n return form;\n };\n\n const getForm = async (\n params: FormBuilderStorageOperationsGetFormParams\n ): Promise<FbForm | null> => {\n const { where } = params;\n const { id, formId, latest, published, version, tenant, locale } = where;\n if (latest && published) {\n throw new WebinyError(\"Cannot have both latest and published params.\");\n }\n let sortKey: string;\n if (latest) {\n sortKey = createLatestSortKey();\n } else if (published && !version) {\n /**\n * Because of the specifics how DynamoDB works, we must not load the published record if version is sent.\n */\n sortKey = createLatestPublishedSortKey();\n } else if (id || version) {\n sortKey = createRevisionSortKey(version || id);\n } else {\n throw new WebinyError(\n \"Missing parameter to create a sort key.\",\n \"MISSING_WHERE_PARAMETER\",\n {\n where\n }\n );\n }\n\n const keys = {\n PK: createFormPartitionKey({\n tenant,\n locale,\n id: (formId || id) as string\n }),\n SK: sortKey\n };\n\n try {\n const result = await entity.get(keys);\n if (!result || !result.Item) {\n return null;\n }\n return cleanupItem(entity, result.Item);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get form by keys.\",\n ex.code || \"GET_FORM_ERROR\",\n {\n keys\n }\n );\n }\n };\n\n const listForms = async (\n params: FormBuilderStorageOperationsListFormsParams\n ): Promise<FormBuilderStorageOperationsListFormsResponse> => {\n const { sort, limit, where, after } = params;\n\n const body = createElasticsearchBody({\n plugins,\n sort,\n limit: limit + 1,\n where,\n after: decodeCursor(after) as any\n });\n\n const esConfig = configurations.es({\n tenant: where.tenant,\n locale: where.locale\n });\n\n const query = {\n ...esConfig,\n body\n };\n\n let response: ElasticsearchSearchResponse<FbForm>;\n try {\n response = await elasticsearch.search(query);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could list forms.\",\n ex.code || \"LIST_FORMS_ERROR\",\n {\n where,\n query\n }\n );\n }\n\n const { hits, total } = response.body.hits;\n const items = hits.map(item => item._source);\n\n const hasMoreItems = items.length > limit;\n if (hasMoreItems) {\n /**\n * Remove the last item from results, we don't want to include it.\n */\n items.pop();\n }\n /**\n * Cursor is the `sort` value of the last item in the array.\n * https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after\n */\n\n const meta = {\n hasMoreItems,\n totalCount: total.value,\n cursor: items.length > 0 ? encodeCursor(hits[items.length - 1].sort) || null : null\n };\n\n return {\n items,\n meta\n };\n };\n\n const listFormRevisions = async (\n params: FormBuilderStorageOperationsListFormRevisionsParams\n ): Promise<FbForm[]> => {\n const { where: initialWhere, sort } = params;\n const { id, formId, tenant, locale } = initialWhere;\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createFormPartitionKey({\n tenant,\n locale,\n id: (id || formId) as string\n }),\n options: {\n beginsWith: \"REV#\"\n }\n };\n\n let items: FbForm[] = [];\n try {\n items = await queryAll<FbForm>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not query forms by given params.\",\n ex.code || \"QUERY_FORMS_ERROR\",\n {\n partitionKey: queryAllParams.partitionKey,\n options: queryAllParams.options\n }\n );\n }\n const where: Partial<FormBuilderStorageOperationsListFormRevisionsParamsWhere> = {\n ...initialWhere,\n id: undefined,\n formId: undefined\n };\n const filteredItems = filterItems({\n plugins,\n items,\n where,\n fields: formDynamoDbFields\n });\n if (!sort || sort.length === 0) {\n return filteredItems;\n }\n return sortItems({\n items: filteredItems,\n sort,\n fields: formDynamoDbFields\n });\n };\n\n const deleteForm = async (\n params: FormBuilderStorageOperationsDeleteFormParams\n ): Promise<FbForm> => {\n const { form } = params;\n let items: any[];\n /**\n * This will find all form and submission records.\n */\n const queryAllParams = {\n entity,\n partitionKey: createFormPartitionKey(form),\n options: {\n gte: \" \"\n }\n };\n try {\n items = await queryAll<DbRecord>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not query forms and submissions by given params.\",\n ex.code || \"QUERY_FORM_AND_SUBMISSIONS_ERROR\",\n {\n partitionKey: queryAllParams.partitionKey,\n options: queryAllParams.options\n }\n );\n }\n\n const deleteItems = items.map(item => {\n return entity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\n });\n try {\n await batchWriteAll({\n table,\n items: deleteItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form and it's submissions.\",\n ex.code || \"DELETE_FORM_AND_SUBMISSIONS_ERROR\"\n );\n }\n\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\n try {\n await esEntity.delete(latestKeys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete latest form record from Elasticsearch.\",\n ex.code || \"DELETE_FORM_ERROR\",\n {\n latestKeys\n }\n );\n }\n return form;\n };\n /**\n * We need to:\n * - delete current revision\n * - get previously published revision and update the record if it exists or delete if it does not\n * - update latest record if current one is the latest\n */\n const deleteFormRevision = async (\n params: FormBuilderStorageOperationsDeleteFormRevisionParams\n ): Promise<FbForm> => {\n const { form, revisions, previous } = params;\n\n const revisionKeys = {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form.id)\n };\n\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\n\n const latestForm = revisions[0];\n const latestPublishedForm = revisions.find(rev => rev.published === true);\n\n const isLatest = latestForm ? latestForm.id === form.id : false;\n const isLatestPublished = latestPublishedForm ? latestPublishedForm.id === form.id : false;\n\n const items = [entity.deleteBatch(revisionKeys)];\n let esDataItem = undefined;\n\n if (isLatest || isLatestPublished) {\n /**\n * Sort out the latest published record.\n */\n if (isLatestPublished) {\n const previouslyPublishedForm = revisions\n .filter(f => !!f.publishedOn && f.version !== form.version)\n .sort((a, b) => {\n return (\n new Date(b.publishedOn as string).getTime() -\n new Date(a.publishedOn as string).getTime()\n );\n })\n .shift();\n if (previouslyPublishedForm) {\n items.push(\n entity.putBatch({\n ...previouslyPublishedForm,\n PK: createFormPartitionKey(previouslyPublishedForm),\n SK: createLatestPublishedSortKey(),\n TYPE: createFormLatestPublishedType()\n })\n );\n } else {\n items.push(\n entity.deleteBatch({\n PK: createFormPartitionKey(form),\n SK: createLatestPublishedSortKey()\n })\n );\n }\n }\n /**\n * Sort out the latest record.\n */\n if (isLatest && previous) {\n items.push(\n entity.putBatch({\n ...previous,\n ...latestKeys,\n TYPE: createFormLatestType()\n })\n );\n\n const { index } = configurations.es({\n tenant: previous.tenant,\n locale: previous.locale\n });\n\n esDataItem = {\n index,\n ...latestKeys,\n data: getESDataForLatestRevision(previous)\n };\n }\n }\n /**\n * Now save the batch data.\n */\n try {\n await batchWriteAll({\n table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form revision from regular table.\",\n ex.code || \"DELETE_FORM_REVISION_ERROR\",\n {\n form,\n latestForm,\n revisionKeys,\n latestKeys\n }\n );\n }\n /**\n * And then the Elasticsearch data, if any.\n */\n if (!esDataItem) {\n return form;\n }\n try {\n await esEntity.put(esDataItem);\n return form;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form from to the Elasticsearch table.\",\n ex.code || \"DELETE_FORM_REVISION_ERROR\",\n {\n form,\n latestForm,\n revisionKeys,\n latestKeys\n }\n );\n }\n };\n\n /**\n * We need to save form in:\n * - regular form record\n * - latest published form record\n * - latest form record - if form is latest one\n * - elasticsearch latest form record\n */\n const publishForm = async (\n params: FormBuilderStorageOperationsPublishFormParams\n ): Promise<FbForm> => {\n const { form, original } = params;\n\n const revisionKeys = {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form.version)\n };\n\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\n\n const latestPublishedKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestPublishedSortKey()\n };\n\n const { locale, tenant, formId } = form;\n\n const latestForm = await getForm({\n where: {\n formId,\n tenant,\n locale,\n latest: true\n }\n });\n\n const isLatestForm = latestForm ? latestForm.id === form.id : false;\n /**\n * Update revision and latest published records\n */\n const items = [\n entity.putBatch({\n ...form,\n ...revisionKeys,\n TYPE: createFormType()\n }),\n entity.putBatch({\n ...form,\n ...latestPublishedKeys,\n TYPE: createFormLatestPublishedType()\n })\n ];\n /**\n * Update the latest form as well\n */\n if (isLatestForm) {\n items.push(\n entity.putBatch({\n ...form,\n ...latestKeys,\n TYPE: createFormLatestType()\n })\n );\n }\n\n try {\n await batchWriteAll({\n table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not publish form.\",\n ex.code || \"PUBLISH_FORM_ERROR\",\n {\n form,\n original,\n latestForm,\n revisionKeys,\n latestKeys,\n latestPublishedKeys\n }\n );\n }\n if (!isLatestForm) {\n return form;\n }\n const { index } = configurations.es({\n tenant: form.tenant,\n locale: form.locale\n });\n const esData = getESDataForLatestRevision(form);\n try {\n await esEntity.put({\n ...latestKeys,\n index,\n TYPE: createFormLatestType(),\n data: esData\n });\n return form;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not publish form to the Elasticsearch.\",\n ex.code || \"PUBLISH_FORM_ERROR\",\n {\n form,\n original,\n latestForm,\n revisionKeys,\n latestKeys,\n latestPublishedKeys\n }\n );\n }\n };\n\n /**\n * We need to:\n * - update form revision record\n * - if latest published (LP) is current form, find the previously published record and update LP if there is some previously published, delete otherwise\n * - if is latest update the Elasticsearch record\n */\n const unpublishForm = async (\n params: FormBuilderStorageOperationsUnpublishFormParams\n ): Promise<FbForm> => {\n const { form, original } = params;\n\n const revisionKeys = {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form.version)\n };\n\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\n\n const latestPublishedKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestPublishedSortKey()\n };\n\n const { formId, tenant, locale } = form;\n\n const latestForm = await getForm({\n where: {\n formId,\n tenant,\n locale,\n latest: true\n }\n });\n\n const latestPublishedForm = await getForm({\n where: {\n formId,\n tenant,\n locale,\n published: true\n }\n });\n\n const isLatest = latestForm ? latestForm.id === form.id : false;\n const isLatestPublished = latestPublishedForm ? latestPublishedForm.id === form.id : false;\n\n const items = [\n entity.putBatch({\n ...form,\n ...revisionKeys,\n TYPE: createFormType()\n })\n ];\n let esData: any = undefined;\n if (isLatest) {\n esData = getESDataForLatestRevision(form);\n }\n /**\n * In case previously published revision exists, replace current one with that one.\n * And if it does not, delete the record.\n */\n if (isLatestPublished) {\n const revisions = await listFormRevisions({\n where: {\n formId,\n tenant,\n locale,\n version_not: form.version,\n publishedOn_not: null\n },\n sort: [\"savedOn_DESC\"]\n });\n\n const previouslyPublishedRevision = revisions.shift();\n if (previouslyPublishedRevision) {\n items.push(\n entity.putBatch({\n ...previouslyPublishedRevision,\n ...latestPublishedKeys,\n TYPE: createFormLatestPublishedType()\n })\n );\n } else {\n items.push(entity.deleteBatch(latestPublishedKeys));\n }\n }\n\n try {\n await batchWriteAll({\n table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not unpublish form.\",\n ex.code || \"UNPUBLISH_FORM_ERROR\",\n {\n form,\n original,\n latestForm,\n revisionKeys,\n latestKeys,\n latestPublishedKeys\n }\n );\n }\n /**\n * No need to go further in case of non-existing Elasticsearch data.\n */\n if (!esData) {\n return form;\n }\n const { index } = configurations.es({\n tenant: form.tenant,\n locale: form.locale\n });\n try {\n await esEntity.put({\n ...latestKeys,\n index,\n TYPE: createFormLatestType(),\n data: esData\n });\n return form;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not unpublish form from the Elasticsearch.\",\n ex.code || \"UNPUBLISH_FORM_ERROR\",\n {\n form,\n original,\n latestForm,\n revisionKeys,\n latestKeys,\n latestPublishedKeys\n }\n );\n }\n };\n\n return {\n createForm,\n createFormFrom,\n updateForm,\n listForms,\n listFormRevisions,\n getForm,\n deleteForm,\n deleteFormRevision,\n publishForm,\n unpublishForm,\n createFormPartitionKey\n };\n};\n"],"mappings":";;;;;;;;;;;AAiBA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAuBA,MAAMA,0BAA0B,GAAIC,IAAD,KAAkC;EACjEC,MAAM,EAAE,IAAAC,wCAAA,GADyD;EAEjEC,EAAE,EAAEH,IAAI,CAACG,EAFwD;EAGjEC,SAAS,EAAEJ,IAAI,CAACI,SAHiD;EAIjEC,OA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IAAI,CAACgB;IAFmB,CAAlB,CAAlB;;IAIA,IAAI;MACA,MAAMM,QAAQ,CAACkC,GAAT,6DACCZ,UADD;QAEFS,KAFE;QAGFN,IAAI,EAAET,oBAAoB,EAHxB;QAIFmB,IAAI,EAAE0E;MAJJ,GAAN;MAMA,OAAOnI,IAAP;IACH,CARD,CAQE,OAAOiD,EAAP,EAAW;MACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,kDADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,sBAFT,EAGF;QACIpD,IADJ;QAEI2D,QAFJ;QAGIG,UAHJ;QAIIrB,YAJJ;QAKIG,UALJ;QAMIsF;MANJ,CAHE,CAAN;IAYH;EACJ,CAvID;;EAyIA,OAAO;IACH1F,UADG;IAEHkB,cAFG;IAGHG,UAHG;IAIHY,SAJG;IAKHuB,iBALG;IAMHjC,OANG;IAOH4C,UAPG;IAQHK,kBARG;IASHiB,WATG;IAUHG,aAVG;IAWHxG;EAXG,CAAP;AAaH,CA/4BM"}
|
|
1
|
+
{"version":3,"names":["getESDataForLatestRevision","form","__type","createFormElasticType","id","createdOn","savedOn","name","slug","published","publishedOn","version","locked","status","createdBy","ownedBy","tenant","locale","webinyVersion","formId","createFormStorageOperations","params","entity","esEntity","table","plugins","elasticsearch","formDynamoDbFields","fields","createFormPartitionKey","targetId","parseIdentifier","createRevisionSortKey","value","Number","zeroPad","createLatestSortKey","createLatestPublishedSortKey","createFormType","createFormLatestType","createFormLatestPublishedType","createForm","revisionKeys","PK","SK","latestKeys","items","putBatch","TYPE","batchWriteAll","ex","WebinyError","message","code","index","configurations","es","put","data","createFormFrom","original","latest","updateForm","latestForm","getForm","where","isLatestForm","push","sortKey","keys","result","get","Item","cleanupItem","listForms","sort","limit","after","body","createElasticsearchBody","decodeCursor","esConfig","query","response","search","hits","total","map","item","_source","hasMoreItems","length","pop","meta","totalCount","cursor","encodeCursor","listFormRevisions","initialWhere","queryAllParams","partitionKey","options","beginsWith","queryAll","undefined","filteredItems","filterItems","sortItems","deleteForm","gte","deleteItems","deleteBatch","delete","deleteFormRevision","revisions","previous","latestPublishedForm","find","rev","isLatest","isLatestPublished","esDataItem","previouslyPublishedForm","filter","f","a","b","Date","getTime","shift","publishForm","latestPublishedKeys","esData","unpublishForm","version_not","publishedOn_not","previouslyPublishedRevision"],"sources":["index.ts"],"sourcesContent":["import {\n FbForm,\n FormBuilderStorageOperationsCreateFormFromParams,\n FormBuilderStorageOperationsCreateFormParams,\n FormBuilderStorageOperationsDeleteFormParams,\n FormBuilderStorageOperationsDeleteFormRevisionParams,\n FormBuilderStorageOperationsGetFormParams,\n FormBuilderStorageOperationsListFormRevisionsParams,\n FormBuilderStorageOperationsListFormRevisionsParamsWhere,\n FormBuilderStorageOperationsListFormsParams,\n FormBuilderStorageOperationsListFormsResponse,\n FormBuilderStorageOperationsPublishFormParams,\n FormBuilderStorageOperationsUnpublishFormParams,\n FormBuilderStorageOperationsUpdateFormParams\n} from \"@webiny/api-form-builder/types\";\nimport { Entity, Table } from \"dynamodb-toolbox\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport WebinyError from \"@webiny/error\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { batchWriteAll } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport { configurations } from \"~/configurations\";\nimport { filterItems } from \"@webiny/db-dynamodb/utils/filter\";\nimport fields from \"./fields\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\nimport { parseIdentifier, zeroPad } from \"@webiny/utils\";\nimport { createElasticsearchBody, createFormElasticType } from \"./elasticsearchBody\";\nimport { decodeCursor, encodeCursor } from \"@webiny/api-elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { FormBuilderFormCreateKeyParams, FormBuilderFormStorageOperations } from \"~/types\";\nimport { ElasticsearchSearchResponse } from \"@webiny/api-elasticsearch/types\";\n\nexport type DbRecord<T = any> = T & {\n PK: string;\n SK: string;\n TYPE: string;\n};\n\nexport interface CreateFormStorageOperationsParams {\n entity: Entity<any>;\n esEntity: Entity<any>;\n table: Table;\n elasticsearch: Client;\n plugins: PluginsContainer;\n}\n\ntype FbFormElastic = Omit<FbForm, \"triggers\" | \"fields\" | \"settings\" | \"layout\" | \"stats\"> & {\n __type: string;\n};\n\nconst getESDataForLatestRevision = (form: FbForm): FbFormElastic => ({\n __type: createFormElasticType(),\n id: form.id,\n createdOn: form.createdOn,\n savedOn: form.savedOn,\n name: form.name,\n slug: form.slug,\n published: form.published,\n publishedOn: form.publishedOn,\n version: form.version,\n locked: form.locked,\n status: form.status,\n createdBy: form.createdBy,\n ownedBy: form.ownedBy,\n tenant: form.tenant,\n locale: form.locale,\n webinyVersion: form.webinyVersion,\n formId: form.formId\n});\n\nexport const createFormStorageOperations = (\n params: CreateFormStorageOperationsParams\n): FormBuilderFormStorageOperations => {\n const { entity, esEntity, table, plugins, elasticsearch } = params;\n\n const formDynamoDbFields = fields();\n\n const createFormPartitionKey = (params: FormBuilderFormCreateKeyParams): string => {\n const { tenant, locale, id: targetId } = params;\n\n const { id } = parseIdentifier(targetId);\n\n return `T#${tenant}#L#${locale}#FB#F#${id}`;\n };\n\n const createRevisionSortKey = (value: string | number | undefined): string => {\n const version =\n typeof value === \"number\" ? Number(value) : (parseIdentifier(value).version as number);\n return `REV#${zeroPad(version)}`;\n };\n\n const createLatestSortKey = (): string => {\n return \"L\";\n };\n\n const createLatestPublishedSortKey = (): string => {\n return \"LP\";\n };\n\n const createFormType = (): string => {\n return \"fb.form\";\n };\n\n const createFormLatestType = (): string => {\n return \"fb.form.latest\";\n };\n\n const createFormLatestPublishedType = (): string => {\n return \"fb.form.latestPublished\";\n };\n\n const createForm = async (\n params: FormBuilderStorageOperationsCreateFormParams\n ): Promise<FbForm> => {\n const { form } = params;\n\n const revisionKeys = {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form.id)\n };\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\n\n const items = [\n entity.putBatch({\n ...form,\n TYPE: createFormType(),\n ...revisionKeys\n }),\n entity.putBatch({\n ...form,\n TYPE: createFormLatestType(),\n ...latestKeys\n })\n ];\n\n try {\n await batchWriteAll({\n table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert form data into regular table.\",\n ex.code || \"CREATE_FORM_ERROR\",\n {\n revisionKeys,\n latestKeys,\n form\n }\n );\n }\n try {\n const { index } = configurations.es({\n tenant: form.tenant,\n locale: form.locale\n });\n await esEntity.put({\n index,\n data: getESDataForLatestRevision(form),\n TYPE: createFormType(),\n ...latestKeys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert form data into Elasticsearch table.\",\n ex.code || \"CREATE_FORM_ERROR\",\n {\n latestKeys,\n form\n }\n );\n }\n return form;\n };\n\n const createFormFrom = async (\n params: FormBuilderStorageOperationsCreateFormFromParams\n ): Promise<FbForm> => {\n const { form, original, latest } = params;\n\n const revisionKeys = {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form.version)\n };\n\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\n\n const items = [\n entity.putBatch({\n ...form,\n ...revisionKeys,\n TYPE: createFormType()\n }),\n entity.putBatch({\n ...form,\n ...latestKeys,\n TYPE: createFormLatestType()\n })\n ];\n\n try {\n await batchWriteAll({\n table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not create form data in the regular table, from existing form.\",\n ex.code || \"CREATE_FORM_FROM_ERROR\",\n {\n revisionKeys,\n latestKeys,\n original,\n form,\n latest\n }\n );\n }\n\n try {\n const { index } = configurations.es({\n tenant: form.tenant,\n locale: form.locale\n });\n await esEntity.put({\n index,\n data: getESDataForLatestRevision(form),\n TYPE: createFormLatestType(),\n ...latestKeys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not create form in the Elasticsearch table, from existing form.\",\n ex.code || \"CREATE_FORM_FROM_ERROR\",\n {\n latestKeys,\n form,\n latest,\n original\n }\n );\n }\n return form;\n };\n\n const updateForm = async (\n params: FormBuilderStorageOperationsUpdateFormParams\n ): Promise<FbForm> => {\n const { form, original } = params;\n\n const revisionKeys = {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form.id)\n };\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\n\n const { formId, tenant, locale } = form;\n\n const latestForm = await getForm({\n where: {\n formId,\n tenant,\n locale,\n latest: true\n }\n });\n const isLatestForm = latestForm ? latestForm.id === form.id : false;\n\n const items = [\n entity.putBatch({\n ...form,\n TYPE: createFormType(),\n ...revisionKeys\n })\n ];\n if (isLatestForm) {\n items.push(\n entity.putBatch({\n ...form,\n TYPE: createFormLatestType(),\n ...latestKeys\n })\n );\n }\n try {\n await batchWriteAll({\n table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update form data in the regular table.\",\n ex.code || \"UPDATE_FORM_ERROR\",\n {\n revisionKeys,\n latestKeys,\n original,\n form,\n latestForm\n }\n );\n }\n /**\n * No need to go further if its not latest form.\n */\n if (!isLatestForm) {\n return form;\n }\n\n try {\n const { index } = configurations.es({\n tenant: form.tenant,\n locale: form.locale\n });\n await esEntity.put({\n index,\n data: getESDataForLatestRevision(form),\n TYPE: createFormLatestType(),\n ...latestKeys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update form data in the Elasticsearch table.\",\n ex.code || \"UPDATE_FORM_ERROR\",\n {\n latestKeys,\n form,\n latestForm,\n original\n }\n );\n }\n return form;\n };\n\n const getForm = async (\n params: FormBuilderStorageOperationsGetFormParams\n ): Promise<FbForm | null> => {\n const { where } = params;\n const { id, formId, latest, published, version, tenant, locale } = where;\n if (latest && published) {\n throw new WebinyError(\"Cannot have both latest and published params.\");\n }\n let sortKey: string;\n if (latest) {\n sortKey = createLatestSortKey();\n } else if (published && !version) {\n /**\n * Because of the specifics how DynamoDB works, we must not load the published record if version is sent.\n */\n sortKey = createLatestPublishedSortKey();\n } else if (id || version) {\n sortKey = createRevisionSortKey(version || id);\n } else {\n throw new WebinyError(\n \"Missing parameter to create a sort key.\",\n \"MISSING_WHERE_PARAMETER\",\n {\n where\n }\n );\n }\n\n const keys = {\n PK: createFormPartitionKey({\n tenant,\n locale,\n id: (formId || id) as string\n }),\n SK: sortKey\n };\n\n try {\n const result = await entity.get(keys);\n if (!result || !result.Item) {\n return null;\n }\n return cleanupItem(entity, result.Item);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get form by keys.\",\n ex.code || \"GET_FORM_ERROR\",\n {\n keys\n }\n );\n }\n };\n\n const listForms = async (\n params: FormBuilderStorageOperationsListFormsParams\n ): Promise<FormBuilderStorageOperationsListFormsResponse> => {\n const { sort, limit, where, after } = params;\n\n const body = createElasticsearchBody({\n plugins,\n sort,\n limit: limit + 1,\n where,\n after: decodeCursor(after) as any\n });\n\n const esConfig = configurations.es({\n tenant: where.tenant,\n locale: where.locale\n });\n\n const query = {\n ...esConfig,\n body\n };\n\n let response: ElasticsearchSearchResponse<FbForm>;\n try {\n response = await elasticsearch.search(query);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could list forms.\",\n ex.code || \"LIST_FORMS_ERROR\",\n {\n where,\n query\n }\n );\n }\n\n const { hits, total } = response.body.hits;\n const items = hits.map(item => item._source);\n\n const hasMoreItems = items.length > limit;\n if (hasMoreItems) {\n /**\n * Remove the last item from results, we don't want to include it.\n */\n items.pop();\n }\n /**\n * Cursor is the `sort` value of the last item in the array.\n * https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after\n */\n\n const meta = {\n hasMoreItems,\n totalCount: total.value,\n cursor: items.length > 0 ? encodeCursor(hits[items.length - 1].sort) || null : null\n };\n\n return {\n items,\n meta\n };\n };\n\n const listFormRevisions = async (\n params: FormBuilderStorageOperationsListFormRevisionsParams\n ): Promise<FbForm[]> => {\n const { where: initialWhere, sort } = params;\n const { id, formId, tenant, locale } = initialWhere;\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createFormPartitionKey({\n tenant,\n locale,\n id: (id || formId) as string\n }),\n options: {\n beginsWith: \"REV#\"\n }\n };\n\n let items: FbForm[] = [];\n try {\n items = await queryAll<FbForm>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not query forms by given params.\",\n ex.code || \"QUERY_FORMS_ERROR\",\n {\n partitionKey: queryAllParams.partitionKey,\n options: queryAllParams.options\n }\n );\n }\n const where: Partial<FormBuilderStorageOperationsListFormRevisionsParamsWhere> = {\n ...initialWhere,\n id: undefined,\n formId: undefined\n };\n const filteredItems = filterItems({\n plugins,\n items,\n where,\n fields: formDynamoDbFields\n });\n if (!sort || sort.length === 0) {\n return filteredItems;\n }\n return sortItems({\n items: filteredItems,\n sort,\n fields: formDynamoDbFields\n });\n };\n\n const deleteForm = async (\n params: FormBuilderStorageOperationsDeleteFormParams\n ): Promise<FbForm> => {\n const { form } = params;\n let items: any[];\n /**\n * This will find all form and submission records.\n */\n const queryAllParams = {\n entity,\n partitionKey: createFormPartitionKey(form),\n options: {\n gte: \" \"\n }\n };\n try {\n items = await queryAll<DbRecord>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not query forms and submissions by given params.\",\n ex.code || \"QUERY_FORM_AND_SUBMISSIONS_ERROR\",\n {\n partitionKey: queryAllParams.partitionKey,\n options: queryAllParams.options\n }\n );\n }\n\n const deleteItems = items.map(item => {\n return entity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\n });\n try {\n await batchWriteAll({\n table,\n items: deleteItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form and it's submissions.\",\n ex.code || \"DELETE_FORM_AND_SUBMISSIONS_ERROR\"\n );\n }\n\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\n try {\n await esEntity.delete(latestKeys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete latest form record from Elasticsearch.\",\n ex.code || \"DELETE_FORM_ERROR\",\n {\n latestKeys\n }\n );\n }\n return form;\n };\n /**\n * We need to:\n * - delete current revision\n * - get previously published revision and update the record if it exists or delete if it does not\n * - update latest record if current one is the latest\n */\n const deleteFormRevision = async (\n params: FormBuilderStorageOperationsDeleteFormRevisionParams\n ): Promise<FbForm> => {\n const { form, revisions, previous } = params;\n\n const revisionKeys = {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form.id)\n };\n\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\n\n const latestForm = revisions[0];\n const latestPublishedForm = revisions.find(rev => rev.published === true);\n\n const isLatest = latestForm ? latestForm.id === form.id : false;\n const isLatestPublished = latestPublishedForm ? latestPublishedForm.id === form.id : false;\n\n const items = [entity.deleteBatch(revisionKeys)];\n let esDataItem = undefined;\n\n if (isLatest || isLatestPublished) {\n /**\n * Sort out the latest published record.\n */\n if (isLatestPublished) {\n const previouslyPublishedForm = revisions\n .filter(f => !!f.publishedOn && f.version !== form.version)\n .sort((a, b) => {\n return (\n new Date(b.publishedOn as string).getTime() -\n new Date(a.publishedOn as string).getTime()\n );\n })\n .shift();\n if (previouslyPublishedForm) {\n items.push(\n entity.putBatch({\n ...previouslyPublishedForm,\n PK: createFormPartitionKey(previouslyPublishedForm),\n SK: createLatestPublishedSortKey(),\n TYPE: createFormLatestPublishedType()\n })\n );\n } else {\n items.push(\n entity.deleteBatch({\n PK: createFormPartitionKey(form),\n SK: createLatestPublishedSortKey()\n })\n );\n }\n }\n /**\n * Sort out the latest record.\n */\n if (isLatest && previous) {\n items.push(\n entity.putBatch({\n ...previous,\n ...latestKeys,\n TYPE: createFormLatestType()\n })\n );\n\n const { index } = configurations.es({\n tenant: previous.tenant,\n locale: previous.locale\n });\n\n esDataItem = {\n index,\n ...latestKeys,\n data: getESDataForLatestRevision(previous)\n };\n }\n }\n /**\n * Now save the batch data.\n */\n try {\n await batchWriteAll({\n table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form revision from regular table.\",\n ex.code || \"DELETE_FORM_REVISION_ERROR\",\n {\n form,\n latestForm,\n revisionKeys,\n latestKeys\n }\n );\n }\n /**\n * And then the Elasticsearch data, if any.\n */\n if (!esDataItem) {\n return form;\n }\n try {\n await esEntity.put(esDataItem);\n return form;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form from to the Elasticsearch table.\",\n ex.code || \"DELETE_FORM_REVISION_ERROR\",\n {\n form,\n latestForm,\n revisionKeys,\n latestKeys\n }\n );\n }\n };\n\n /**\n * We need to save form in:\n * - regular form record\n * - latest published form record\n * - latest form record - if form is latest one\n * - elasticsearch latest form record\n */\n const publishForm = async (\n params: FormBuilderStorageOperationsPublishFormParams\n ): Promise<FbForm> => {\n const { form, original } = params;\n\n const revisionKeys = {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form.version)\n };\n\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\n\n const latestPublishedKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestPublishedSortKey()\n };\n\n const { locale, tenant, formId } = form;\n\n const latestForm = await getForm({\n where: {\n formId,\n tenant,\n locale,\n latest: true\n }\n });\n\n const isLatestForm = latestForm ? latestForm.id === form.id : false;\n /**\n * Update revision and latest published records\n */\n const items = [\n entity.putBatch({\n ...form,\n ...revisionKeys,\n TYPE: createFormType()\n }),\n entity.putBatch({\n ...form,\n ...latestPublishedKeys,\n TYPE: createFormLatestPublishedType()\n })\n ];\n /**\n * Update the latest form as well\n */\n if (isLatestForm) {\n items.push(\n entity.putBatch({\n ...form,\n ...latestKeys,\n TYPE: createFormLatestType()\n })\n );\n }\n\n try {\n await batchWriteAll({\n table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not publish form.\",\n ex.code || \"PUBLISH_FORM_ERROR\",\n {\n form,\n original,\n latestForm,\n revisionKeys,\n latestKeys,\n latestPublishedKeys\n }\n );\n }\n if (!isLatestForm) {\n return form;\n }\n const { index } = configurations.es({\n tenant: form.tenant,\n locale: form.locale\n });\n const esData = getESDataForLatestRevision(form);\n try {\n await esEntity.put({\n ...latestKeys,\n index,\n TYPE: createFormLatestType(),\n data: esData\n });\n return form;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not publish form to the Elasticsearch.\",\n ex.code || \"PUBLISH_FORM_ERROR\",\n {\n form,\n original,\n latestForm,\n revisionKeys,\n latestKeys,\n latestPublishedKeys\n }\n );\n }\n };\n\n /**\n * We need to:\n * - update form revision record\n * - if latest published (LP) is current form, find the previously published record and update LP if there is some previously published, delete otherwise\n * - if is latest update the Elasticsearch record\n */\n const unpublishForm = async (\n params: FormBuilderStorageOperationsUnpublishFormParams\n ): Promise<FbForm> => {\n const { form, original } = params;\n\n const revisionKeys = {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form.version)\n };\n\n const latestKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestSortKey()\n };\n\n const latestPublishedKeys = {\n PK: createFormPartitionKey(form),\n SK: createLatestPublishedSortKey()\n };\n\n const { formId, tenant, locale } = form;\n\n const latestForm = await getForm({\n where: {\n formId,\n tenant,\n locale,\n latest: true\n }\n });\n\n const latestPublishedForm = await getForm({\n where: {\n formId,\n tenant,\n locale,\n published: true\n }\n });\n\n const isLatest = latestForm ? latestForm.id === form.id : false;\n const isLatestPublished = latestPublishedForm ? latestPublishedForm.id === form.id : false;\n\n const items = [\n entity.putBatch({\n ...form,\n ...revisionKeys,\n TYPE: createFormType()\n })\n ];\n let esData: any = undefined;\n if (isLatest) {\n esData = getESDataForLatestRevision(form);\n }\n /**\n * In case previously published revision exists, replace current one with that one.\n * And if it does not, delete the record.\n */\n if (isLatestPublished) {\n const revisions = await listFormRevisions({\n where: {\n formId,\n tenant,\n locale,\n version_not: form.version,\n publishedOn_not: null\n },\n sort: [\"savedOn_DESC\"]\n });\n\n const previouslyPublishedRevision = revisions.shift();\n if (previouslyPublishedRevision) {\n items.push(\n entity.putBatch({\n ...previouslyPublishedRevision,\n ...latestPublishedKeys,\n TYPE: createFormLatestPublishedType()\n })\n );\n } else {\n items.push(entity.deleteBatch(latestPublishedKeys));\n }\n }\n\n try {\n await batchWriteAll({\n table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not unpublish form.\",\n ex.code || \"UNPUBLISH_FORM_ERROR\",\n {\n form,\n original,\n latestForm,\n revisionKeys,\n latestKeys,\n latestPublishedKeys\n }\n );\n }\n /**\n * No need to go further in case of non-existing Elasticsearch data.\n */\n if (!esData) {\n return form;\n }\n const { index } = configurations.es({\n tenant: form.tenant,\n locale: form.locale\n });\n try {\n await esEntity.put({\n ...latestKeys,\n index,\n TYPE: createFormLatestType(),\n data: esData\n });\n return form;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not unpublish form from the Elasticsearch.\",\n ex.code || \"UNPUBLISH_FORM_ERROR\",\n {\n form,\n original,\n latestForm,\n revisionKeys,\n latestKeys,\n latestPublishedKeys\n }\n );\n }\n };\n\n return {\n createForm,\n createFormFrom,\n updateForm,\n listForms,\n listFormRevisions,\n getForm,\n deleteForm,\n deleteFormRevision,\n publishForm,\n unpublishForm,\n createFormPartitionKey\n };\n};\n"],"mappings":";;;;;;;;;;;AAiBA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAuBA,MAAMA,0BAA0B,GAAIC,IAAD,KAAkC;EACjEC,MAAM,EAAE,IAAAC,wCAAA,GADyD;EAEjEC,EAAE,EAAEH,IAAI,CAACG,EAFwD;EAGjEC,SAAS,EAAEJ,IAAI,CAACI,SAHiD;EAIjEC,OAAO,EAAEL,IAAI,CAACK,OAJmD;EAKjEC,IAAI,EAAEN,IAAI,CAACM,IALsD;EAMjEC,IAAI,EAAEP,IAAI,CAACO,IAN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;QAGFN,IAAI,EAAET,oBAAoB,EAHxB;QAIFmB,IAAI,EAAE0E;MAJJ,GAAN;MAMA,OAAOnI,IAAP;IACH,CARD,CAQE,OAAOiD,EAAP,EAAW;MACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,kDADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,sBAFT,EAGF;QACIpD,IADJ;QAEI2D,QAFJ;QAGIG,UAHJ;QAIIrB,YAJJ;QAKIG,UALJ;QAMIsF;MANJ,CAHE,CAAN;IAYH;EACJ,CAvID;;EAyIA,OAAO;IACH1F,UADG;IAEHkB,cAFG;IAGHG,UAHG;IAIHY,SAJG;IAKHuB,iBALG;IAMHjC,OANG;IAOH4C,UAPG;IAQHK,kBARG;IASHiB,WATG;IAUHG,aAVG;IAWHxG;EAXG,CAAP;AAaH,CA/4BM"}
|
|
@@ -9,13 +9,7 @@ exports.createSubmissionElasticType = exports.createElasticsearchBody = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
var _sort = require("@webiny/api-elasticsearch/sort");
|
|
15
|
-
|
|
16
|
-
var _limit = require("@webiny/api-elasticsearch/limit");
|
|
17
|
-
|
|
18
|
-
var _ElasticsearchQueryBuilderOperatorPlugin = require("@webiny/api-elasticsearch/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin");
|
|
12
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
19
13
|
|
|
20
14
|
var _SubmissionElasticsearchFieldPlugin = require("../../plugins/SubmissionElasticsearchFieldPlugin");
|
|
21
15
|
|
|
@@ -25,8 +19,6 @@ var _SubmissionElasticsearchBodyModifierPlugin = require("../../plugins/Submissi
|
|
|
25
19
|
|
|
26
20
|
var _SubmissionElasticsearchQueryModifierPlugin = require("../../plugins/SubmissionElasticsearchQueryModifierPlugin");
|
|
27
21
|
|
|
28
|
-
var _where = require("@webiny/api-elasticsearch/where");
|
|
29
|
-
|
|
30
22
|
const createInitialQueryValue = () => {
|
|
31
23
|
return {
|
|
32
24
|
must: [
|
|
@@ -61,7 +53,7 @@ const createElasticsearchQuery = params => {
|
|
|
61
53
|
* Be aware that, if having more registered operator plugins of same type, the last one will be used.
|
|
62
54
|
*/
|
|
63
55
|
|
|
64
|
-
const operatorPlugins = plugins.byType(
|
|
56
|
+
const operatorPlugins = plugins.byType(_apiElasticsearch.ElasticsearchQueryBuilderOperatorPlugin.type).reduce((acc, plugin) => {
|
|
65
57
|
if (plugin.isLocaleSupported(initialWhere.locale) === false) {
|
|
66
58
|
return acc;
|
|
67
59
|
}
|
|
@@ -117,7 +109,7 @@ const createElasticsearchQuery = params => {
|
|
|
117
109
|
* We apply other conditions as they are passed via the where value.
|
|
118
110
|
*/
|
|
119
111
|
|
|
120
|
-
(0,
|
|
112
|
+
(0, _apiElasticsearch.applyWhere)({
|
|
121
113
|
query,
|
|
122
114
|
where,
|
|
123
115
|
fields: fieldPlugins,
|
|
@@ -138,11 +130,11 @@ const createElasticsearchBody = params => {
|
|
|
138
130
|
acc[plugin.field] = plugin;
|
|
139
131
|
return acc;
|
|
140
132
|
}, {});
|
|
141
|
-
const limit = (0,
|
|
133
|
+
const limit = (0, _apiElasticsearch.createLimit)(initialLimit, 100);
|
|
142
134
|
const query = createElasticsearchQuery((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
143
135
|
fieldPlugins
|
|
144
136
|
}));
|
|
145
|
-
const sort = (0,
|
|
137
|
+
const sort = (0, _apiElasticsearch.createSort)({
|
|
146
138
|
sort: initialSort,
|
|
147
139
|
fieldPlugins
|
|
148
140
|
});
|
|
@@ -178,7 +170,7 @@ const createElasticsearchBody = params => {
|
|
|
178
170
|
* Which is correct in some cases. In our case, it is not.
|
|
179
171
|
* https://www.elastic.co/guide/en/elasticsearch/reference/7.13/paginate-search-results.html
|
|
180
172
|
*/
|
|
181
|
-
search_after: (0,
|
|
173
|
+
search_after: (0, _apiElasticsearch.decodeCursor)(after),
|
|
182
174
|
sort
|
|
183
175
|
};
|
|
184
176
|
const bodyModifiers = plugins.byType(_SubmissionElasticsearchBodyModifierPlugin.SubmissionElasticsearchBodyModifierPlugin.type);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createInitialQueryValue","must","term","must_not","should","filter","createSubmissionElasticType","createElasticsearchQuery","params","plugins","where","initialWhere","fieldPlugins","query","operatorPlugins","byType","ElasticsearchQueryBuilderOperatorPlugin","type","reduce","acc","plugin","isLocaleSupported","locale","getOperator","sharedIndex","process","env","ELASTICSEARCH_SHARED_INDEXES","tenant","push","formId","applyWhere","fields","operators","createElasticsearchBody","limit","initialLimit","sort","initialSort","after","SubmissionElasticsearchFieldPlugin","field","createLimit","createSort","queryModifiers","SubmissionElasticsearchQueryModifierPlugin","modifyQuery","sortModifiers","SubmissionElasticsearchSortModifierPlugin","modifySort","body","constant_score","bool","size","search_after","decodeCursor","bodyModifiers","SubmissionElasticsearchBodyModifierPlugin","modifyBody"],"sources":["elasticsearchBody.ts"],"sourcesContent":["import { SearchBody as esSearchBody } from \"elastic-ts\";\nimport { decodeCursor } from \"@webiny/api-elasticsearch/cursors\";\nimport { ElasticsearchBoolQueryConfig } from \"@webiny/api-elasticsearch/types\";\nimport { createSort } from \"@webiny/api-elasticsearch/sort\";\nimport { createLimit } from \"@webiny/api-elasticsearch/limit\";\nimport { ElasticsearchQueryBuilderOperatorPlugin } from \"@webiny/api-elasticsearch/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\nimport { SubmissionElasticsearchFieldPlugin } from \"~/plugins/SubmissionElasticsearchFieldPlugin\";\nimport { SubmissionElasticsearchSortModifierPlugin } from \"~/plugins/SubmissionElasticsearchSortModifierPlugin\";\nimport { SubmissionElasticsearchBodyModifierPlugin } from \"~/plugins/SubmissionElasticsearchBodyModifierPlugin\";\nimport { FormBuilderStorageOperationsListSubmissionsParams } from \"@webiny/api-form-builder/types\";\nimport { SubmissionElasticsearchQueryModifierPlugin } from \"~/plugins/SubmissionElasticsearchQueryModifierPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { applyWhere } from \"@webiny/api-elasticsearch/where\";\n\nconst createInitialQueryValue = (): ElasticsearchBoolQueryConfig => {\n return {\n must: [\n /**\n * We add the __type filtering in the initial query because it must be applied.\n */\n {\n term: {\n \"__type.keyword\": \"fb.submission\"\n }\n }\n ],\n must_not: [],\n should: [],\n filter: []\n };\n};\n\nexport const createSubmissionElasticType = (): string => {\n return \"fb.submission\";\n};\n\ninterface CreateElasticsearchQueryParams extends CreateElasticsearchBodyParams {\n fieldPlugins: Record<string, SubmissionElasticsearchFieldPlugin>;\n}\n\nconst createElasticsearchQuery = (params: CreateElasticsearchQueryParams) => {\n const { plugins, where: initialWhere, fieldPlugins } = params;\n const query = createInitialQueryValue();\n /**\n * Be aware that, if having more registered operator plugins of same type, the last one will be used.\n */\n const operatorPlugins = plugins\n .byType<ElasticsearchQueryBuilderOperatorPlugin>(\n ElasticsearchQueryBuilderOperatorPlugin.type\n )\n .reduce((acc, plugin) => {\n if (plugin.isLocaleSupported(initialWhere.locale) === false) {\n return acc;\n }\n acc[plugin.getOperator()] = plugin;\n return acc;\n }, {} as Record<string, ElasticsearchQueryBuilderOperatorPlugin>);\n\n const where: Partial<FormBuilderStorageOperationsListSubmissionsParams[\"where\"]> = {\n ...initialWhere\n };\n /**\n * !!! IMPORTANT !!! There are few specific cases where we hardcode the query conditions.\n *\n * When ES index is shared between tenants, we need to filter records by tenant ID.\n * No need for the tenant filtering otherwise as each index is for single tenant.\n */\n const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === \"true\";\n if (sharedIndex && where.tenant) {\n query.must.push({\n term: {\n \"tenant.keyword\": where.tenant\n }\n });\n }\n /**\n * Remove tenant so it is not applied again later.\n * Possibly tenant is not defined, but just in case, remove it.\n */\n delete where.tenant;\n /**\n * Add the locale to filtering.\n */\n query.must.push({\n term: {\n \"locale.keyword\": where.locale as string\n }\n });\n delete where.locale;\n /**\n * And add the parent (form) to the filtering, if it exists.\n */\n query.must.push({\n term: {\n \"form.parent.keyword\": where.formId as string\n }\n });\n delete where.formId;\n /**\n * We apply other conditions as they are passed via the where value.\n */\n applyWhere({\n query,\n where,\n fields: fieldPlugins,\n operators: operatorPlugins\n });\n\n return query;\n};\n\ninterface CreateElasticsearchBodyParams {\n plugins: PluginsContainer;\n where: FormBuilderStorageOperationsListSubmissionsParams[\"where\"];\n limit: number;\n after?: string;\n sort: string[];\n}\n\nexport const createElasticsearchBody = (params: CreateElasticsearchBodyParams): esSearchBody => {\n const { plugins, where, limit: initialLimit, sort: initialSort, after } = params;\n\n const fieldPlugins = plugins\n .byType<SubmissionElasticsearchFieldPlugin>(SubmissionElasticsearchFieldPlugin.type)\n .reduce((acc, plugin) => {\n acc[plugin.field] = plugin;\n return acc;\n }, {} as Record<string, SubmissionElasticsearchFieldPlugin>);\n\n const limit = createLimit(initialLimit, 100);\n\n const query = createElasticsearchQuery({\n ...params,\n fieldPlugins\n });\n\n const sort = createSort({\n sort: initialSort,\n fieldPlugins\n });\n\n const queryModifiers = plugins.byType<SubmissionElasticsearchQueryModifierPlugin>(\n SubmissionElasticsearchQueryModifierPlugin.type\n );\n\n for (const plugin of queryModifiers) {\n plugin.modifyQuery({\n query,\n where\n });\n }\n\n const sortModifiers = plugins.byType<SubmissionElasticsearchSortModifierPlugin>(\n SubmissionElasticsearchSortModifierPlugin.type\n );\n\n for (const plugin of sortModifiers) {\n plugin.modifySort({\n sort\n });\n }\n\n const body = {\n query: {\n constant_score: {\n filter: {\n bool: {\n ...query\n }\n }\n }\n },\n size: limit + 1,\n /**\n * Casting as any is required due to search_after is accepting an array of values.\n * Which is correct in some cases. In our case, it is not.\n * https://www.elastic.co/guide/en/elasticsearch/reference/7.13/paginate-search-results.html\n */\n search_after: decodeCursor(after) as any,\n sort\n };\n\n const bodyModifiers = plugins.byType<SubmissionElasticsearchBodyModifierPlugin>(\n SubmissionElasticsearchBodyModifierPlugin.type\n );\n\n for (const plugin of bodyModifiers) {\n plugin.modifyBody({\n body\n });\n }\n\n return body;\n};\n"],"mappings":";;;;;;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AAEA,MAAMA,uBAAuB,GAAG,MAAoC;EAChE,OAAO;IACHC,IAAI,EAAE;IACF;AACZ;AACA;IACY;MACIC,IAAI,EAAE;QACF,kBAAkB;MADhB;IADV,CAJE,CADH;IAWHC,QAAQ,EAAE,EAXP;IAYHC,MAAM,EAAE,EAZL;IAaHC,MAAM,EAAE;EAbL,CAAP;AAeH,CAhBD;;AAkBO,MAAMC,2BAA2B,GAAG,MAAc;EACrD,OAAO,eAAP;AACH,CAFM;;;;AAQP,MAAMC,wBAAwB,GAAIC,MAAD,IAA4C;EACzE,MAAM;IAAEC,OAAF;IAAWC,KAAK,EAAEC,YAAlB;IAAgCC;EAAhC,IAAiDJ,MAAvD;EACA,MAAMK,KAAK,GAAGb,uBAAuB,EAArC;EACA;AACJ;AACA;;EACI,MAAMc,eAAe,GAAGL,OAAO,CAC1BM,MADmB,CAEhBC,gFAAA,CAAwCC,IAFxB,EAInBC,MAJmB,CAIZ,CAACC,GAAD,EAAMC,MAAN,KAAiB;IACrB,IAAIA,MAAM,CAACC,iBAAP,CAAyBV,YAAY,CAACW,MAAtC,MAAkD,KAAtD,EAA6D;MACzD,OAAOH,GAAP;IACH;;IACDA,GAAG,CAACC,MAAM,CAACG,WAAP,EAAD,CAAH,GAA4BH,MAA5B;IACA,OAAOD,GAAP;EACH,CAVmB,EAUjB,EAViB,CAAxB;EAYA,MAAMT,KAA0E,mCACzEC,YADyE,CAAhF;EAGA;AACJ;AACA;AACA;AACA;AACA;;EACI,MAAMa,WAAW,GAAGC,OAAO,CAACC,GAAR,CAAYC,4BAAZ,KAA6C,MAAjE;;EACA,IAAIH,WAAW,IAAId,KAAK,CA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IAElCI;EAFkC,GAAtC;EAKA,MAAMyB,IAAI,GAAG,IAAAM,gBAAA,EAAW;IACpBN,IAAI,EAAEC,WADc;IAEpB1B;EAFoB,CAAX,CAAb;EAKA,MAAMgC,cAAc,GAAGnC,OAAO,CAACM,MAAR,CACnB8B,sFAAA,CAA2C5B,IADxB,CAAvB;;EAIA,KAAK,MAAMG,MAAX,IAAqBwB,cAArB,EAAqC;IACjCxB,MAAM,CAAC0B,WAAP,CAAmB;MACfjC,KADe;MAEfH;IAFe,CAAnB;EAIH;;EAED,MAAMqC,aAAa,GAAGtC,OAAO,CAACM,MAAR,CAClBiC,oFAAA,CAA0C/B,IADxB,CAAtB;;EAIA,KAAK,MAAMG,MAAX,IAAqB2B,aAArB,EAAoC;IAChC3B,MAAM,CAAC6B,UAAP,CAAkB;MACdZ;IADc,CAAlB;EAGH;;EAED,MAAMa,IAAI,GAAG;IACTrC,KAAK,EAAE;MACHsC,cAAc,EAAE;QACZ9C,MAAM,EAAE;UACJ+C,IAAI,kCACGvC,KADH;QADA;MADI;IADb,CADE;IAUTwC,IAAI,EAAElB,KAAK,GAAG,CAVL;;IAWT;AACR;AACA;AACA;AACA;IACQmB,YAAY,EAAE,IAAAC,qBAAA,EAAahB,KAAb,CAhBL;IAiBTF;EAjBS,CAAb;EAoBA,MAAMmB,aAAa,GAAG/C,OAAO,CAACM,MAAR,CAClB0C,oFAAA,CAA0CxC,IADxB,CAAtB;;EAIA,KAAK,MAAMG,MAAX,IAAqBoC,aAArB,EAAoC;IAChCpC,MAAM,CAACsC,UAAP,CAAkB;MACdR;IADc,CAAlB;EAGH;;EAED,OAAOA,IAAP;AACH,CA1EM"}
|
|
1
|
+
{"version":3,"names":["createInitialQueryValue","must","term","must_not","should","filter","createSubmissionElasticType","createElasticsearchQuery","params","plugins","where","initialWhere","fieldPlugins","query","operatorPlugins","byType","ElasticsearchQueryBuilderOperatorPlugin","type","reduce","acc","plugin","isLocaleSupported","locale","getOperator","sharedIndex","process","env","ELASTICSEARCH_SHARED_INDEXES","tenant","push","formId","applyWhere","fields","operators","createElasticsearchBody","limit","initialLimit","sort","initialSort","after","SubmissionElasticsearchFieldPlugin","field","createLimit","createSort","queryModifiers","SubmissionElasticsearchQueryModifierPlugin","modifyQuery","sortModifiers","SubmissionElasticsearchSortModifierPlugin","modifySort","body","constant_score","bool","size","search_after","decodeCursor","bodyModifiers","SubmissionElasticsearchBodyModifierPlugin","modifyBody"],"sources":["elasticsearchBody.ts"],"sourcesContent":["import { SearchBody as esSearchBody } from \"elastic-ts\";\nimport {\n decodeCursor,\n createLimit,\n createSort,\n applyWhere,\n ElasticsearchQueryBuilderOperatorPlugin\n} from \"@webiny/api-elasticsearch\";\nimport { ElasticsearchBoolQueryConfig } from \"@webiny/api-elasticsearch/types\";\nimport { SubmissionElasticsearchFieldPlugin } from \"~/plugins/SubmissionElasticsearchFieldPlugin\";\nimport { SubmissionElasticsearchSortModifierPlugin } from \"~/plugins/SubmissionElasticsearchSortModifierPlugin\";\nimport { SubmissionElasticsearchBodyModifierPlugin } from \"~/plugins/SubmissionElasticsearchBodyModifierPlugin\";\nimport { FormBuilderStorageOperationsListSubmissionsParams } from \"@webiny/api-form-builder/types\";\nimport { SubmissionElasticsearchQueryModifierPlugin } from \"~/plugins/SubmissionElasticsearchQueryModifierPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\nconst createInitialQueryValue = (): ElasticsearchBoolQueryConfig => {\n return {\n must: [\n /**\n * We add the __type filtering in the initial query because it must be applied.\n */\n {\n term: {\n \"__type.keyword\": \"fb.submission\"\n }\n }\n ],\n must_not: [],\n should: [],\n filter: []\n };\n};\n\nexport const createSubmissionElasticType = (): string => {\n return \"fb.submission\";\n};\n\ninterface CreateElasticsearchQueryParams extends CreateElasticsearchBodyParams {\n fieldPlugins: Record<string, SubmissionElasticsearchFieldPlugin>;\n}\n\nconst createElasticsearchQuery = (params: CreateElasticsearchQueryParams) => {\n const { plugins, where: initialWhere, fieldPlugins } = params;\n const query = createInitialQueryValue();\n /**\n * Be aware that, if having more registered operator plugins of same type, the last one will be used.\n */\n const operatorPlugins = plugins\n .byType<ElasticsearchQueryBuilderOperatorPlugin>(\n ElasticsearchQueryBuilderOperatorPlugin.type\n )\n .reduce((acc, plugin) => {\n if (plugin.isLocaleSupported(initialWhere.locale) === false) {\n return acc;\n }\n acc[plugin.getOperator()] = plugin;\n return acc;\n }, {} as Record<string, ElasticsearchQueryBuilderOperatorPlugin>);\n\n const where: Partial<FormBuilderStorageOperationsListSubmissionsParams[\"where\"]> = {\n ...initialWhere\n };\n /**\n * !!! IMPORTANT !!! There are few specific cases where we hardcode the query conditions.\n *\n * When ES index is shared between tenants, we need to filter records by tenant ID.\n * No need for the tenant filtering otherwise as each index is for single tenant.\n */\n const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === \"true\";\n if (sharedIndex && where.tenant) {\n query.must.push({\n term: {\n \"tenant.keyword\": where.tenant\n }\n });\n }\n /**\n * Remove tenant so it is not applied again later.\n * Possibly tenant is not defined, but just in case, remove it.\n */\n delete where.tenant;\n /**\n * Add the locale to filtering.\n */\n query.must.push({\n term: {\n \"locale.keyword\": where.locale as string\n }\n });\n delete where.locale;\n /**\n * And add the parent (form) to the filtering, if it exists.\n */\n query.must.push({\n term: {\n \"form.parent.keyword\": where.formId as string\n }\n });\n delete where.formId;\n /**\n * We apply other conditions as they are passed via the where value.\n */\n applyWhere({\n query,\n where,\n fields: fieldPlugins,\n operators: operatorPlugins\n });\n\n return query;\n};\n\ninterface CreateElasticsearchBodyParams {\n plugins: PluginsContainer;\n where: FormBuilderStorageOperationsListSubmissionsParams[\"where\"];\n limit: number;\n after?: string;\n sort: string[];\n}\n\nexport const createElasticsearchBody = (params: CreateElasticsearchBodyParams): esSearchBody => {\n const { plugins, where, limit: initialLimit, sort: initialSort, after } = params;\n\n const fieldPlugins = plugins\n .byType<SubmissionElasticsearchFieldPlugin>(SubmissionElasticsearchFieldPlugin.type)\n .reduce((acc, plugin) => {\n acc[plugin.field] = plugin;\n return acc;\n }, {} as Record<string, SubmissionElasticsearchFieldPlugin>);\n\n const limit = createLimit(initialLimit, 100);\n\n const query = createElasticsearchQuery({\n ...params,\n fieldPlugins\n });\n\n const sort = createSort({\n sort: initialSort,\n fieldPlugins\n });\n\n const queryModifiers = plugins.byType<SubmissionElasticsearchQueryModifierPlugin>(\n SubmissionElasticsearchQueryModifierPlugin.type\n );\n\n for (const plugin of queryModifiers) {\n plugin.modifyQuery({\n query,\n where\n });\n }\n\n const sortModifiers = plugins.byType<SubmissionElasticsearchSortModifierPlugin>(\n SubmissionElasticsearchSortModifierPlugin.type\n );\n\n for (const plugin of sortModifiers) {\n plugin.modifySort({\n sort\n });\n }\n\n const body = {\n query: {\n constant_score: {\n filter: {\n bool: {\n ...query\n }\n }\n }\n },\n size: limit + 1,\n /**\n * Casting as any is required due to search_after is accepting an array of values.\n * Which is correct in some cases. In our case, it is not.\n * https://www.elastic.co/guide/en/elasticsearch/reference/7.13/paginate-search-results.html\n */\n search_after: decodeCursor(after) as any,\n sort\n };\n\n const bodyModifiers = plugins.byType<SubmissionElasticsearchBodyModifierPlugin>(\n SubmissionElasticsearchBodyModifierPlugin.type\n );\n\n for (const plugin of bodyModifiers) {\n plugin.modifyBody({\n body\n });\n }\n\n return body;\n};\n"],"mappings":";;;;;;;;;;;AACA;;AAQA;;AACA;;AACA;;AAEA;;AAGA,MAAMA,uBAAuB,GAAG,MAAoC;EAChE,OAAO;IACHC,IAAI,EAAE;IACF;AACZ;AACA;IACY;MACIC,IAAI,EAAE;QACF,kBAAkB;MADhB;IADV,CAJE,CADH;IAWHC,QAAQ,EAAE,EAXP;IAYHC,MAAM,EAAE,EAZL;IAaHC,MAAM,EAAE;EAbL,CAAP;AAeH,CAhBD;;AAkBO,MAAMC,2BAA2B,GAAG,MAAc;EACrD,OAAO,eAAP;AACH,CAFM;;;;AAQP,MAAMC,wBAAwB,GAAIC,MAAD,IAA4C;EACzE,MAAM;IAAEC,OAAF;I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Ac,EAAE;QACZ9C,MAAM,EAAE;UACJ+C,IAAI,kCACGvC,KADH;QADA;MADI;IADb,CADE;IAUTwC,IAAI,EAAElB,KAAK,GAAG,CAVL;;IAWT;AACR;AACA;AACA;AACA;IACQmB,YAAY,EAAE,IAAAC,8BAAA,EAAahB,KAAb,CAhBL;IAiBTF;EAjBS,CAAb;EAoBA,MAAMmB,aAAa,GAAG/C,OAAO,CAACM,MAAR,CAClB0C,oFAAA,CAA0CxC,IADxB,CAAtB;;EAIA,KAAK,MAAMG,MAAX,IAAqBoC,aAArB,EAAoC;IAChCpC,MAAM,CAACsC,UAAP,CAAkB;MACdR;IADc,CAAlB;EAGH;;EAED,OAAOA,IAAP;AACH,CA1EM"}
|
|
@@ -15,7 +15,7 @@ var _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
|
|
|
15
15
|
|
|
16
16
|
var _sort = require("@webiny/db-dynamodb/utils/sort");
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
19
19
|
|
|
20
20
|
var _elasticsearchBody = require("./elasticsearchBody");
|
|
21
21
|
|
|
@@ -25,8 +25,6 @@ var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
|
25
25
|
|
|
26
26
|
var _utils = require("@webiny/utils");
|
|
27
27
|
|
|
28
|
-
var _cursors = require("@webiny/api-elasticsearch/cursors");
|
|
29
|
-
|
|
30
28
|
const createSubmissionStorageOperations = params => {
|
|
31
29
|
const {
|
|
32
30
|
entity,
|
|
@@ -238,13 +236,13 @@ const createSubmissionStorageOperations = params => {
|
|
|
238
236
|
};
|
|
239
237
|
}
|
|
240
238
|
|
|
241
|
-
const limit = (0,
|
|
239
|
+
const limit = (0, _apiElasticsearch.createLimit)(initialLimit);
|
|
242
240
|
const body = (0, _elasticsearchBody.createElasticsearchBody)({
|
|
243
241
|
plugins,
|
|
244
242
|
sort,
|
|
245
243
|
limit: limit + 1,
|
|
246
244
|
where,
|
|
247
|
-
after: (0,
|
|
245
|
+
after: (0, _apiElasticsearch.decodeCursor)(after)
|
|
248
246
|
});
|
|
249
247
|
|
|
250
248
|
const esConfig = _configurations.configurations.es({
|
|
@@ -288,7 +286,7 @@ const createSubmissionStorageOperations = params => {
|
|
|
288
286
|
const meta = {
|
|
289
287
|
hasMoreItems,
|
|
290
288
|
totalCount: total.value,
|
|
291
|
-
cursor: items.length > 0 ? (0,
|
|
289
|
+
cursor: items.length > 0 ? (0, _apiElasticsearch.encodeCursor)(hits[items.length - 1].sort) || null : null
|
|
292
290
|
};
|
|
293
291
|
return {
|
|
294
292
|
items,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createSubmissionStorageOperations","params","entity","esEntity","table","elasticsearch","plugins","createSubmissionPartitionKey","tenant","locale","formId","id","parseIdentifier","createSubmissionSortKey","createSubmissionType","createSubmission","submission","form","keys","PK","SK","put","TYPE","ex","WebinyError","message","code","index","configurations","es","data","__type","createSubmissionElasticType","updateSubmission","original","deleteSubmission","delete","listSubmissionsByIds","where","sort","items","id_in","map","getBatch","results","batchReadAll","submissions","filter","Boolean","cleanupItem","sortItems","fields","listSubmissions","limit","initialLimit","after","meta","hasMoreItems","cursor","totalCount","length","createLimit","body","createElasticsearchBody","decodeCursor","esConfig","query","response","search","hits","total","item","_source","pop","value","encodeCursor","getSubmission","result","get","Item"],"sources":["index.ts"],"sourcesContent":["import {\n FbSubmission,\n FormBuilderStorageOperationsCreateSubmissionParams,\n FormBuilderStorageOperationsDeleteSubmissionParams,\n FormBuilderStorageOperationsGetSubmissionParams,\n FormBuilderStorageOperationsListSubmissionsParams,\n FormBuilderStorageOperationsListSubmissionsResponse,\n FormBuilderStorageOperationsUpdateSubmissionParams\n} from \"@webiny/api-form-builder/types\";\nimport { Entity, Table } from \"dynamodb-toolbox\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport WebinyError from \"@webiny/error\";\nimport { batchReadAll } from \"@webiny/db-dynamodb/utils/batchRead\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\nimport { createLimit } from \"@webiny/api-elasticsearch/limit\";\nimport {\n createElasticsearchBody,\n createSubmissionElasticType\n} from \"~/operations/submission/elasticsearchBody\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport {\n FormBuilderSubmissionStorageOperations,\n FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams\n} from \"~/types\";\nimport { configurations } from \"~/configurations\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { decodeCursor, encodeCursor } from \"@webiny/api-elasticsearch/cursors\";\nimport { ElasticsearchSearchResponse } from \"@webiny/api-elasticsearch/types\";\n\nexport interface CreateSubmissionStorageOperationsParams {\n entity: Entity<any>;\n esEntity: Entity<any>;\n table: Table;\n elasticsearch: Client;\n plugins: PluginsContainer;\n}\n\nexport const createSubmissionStorageOperations = (\n params: CreateSubmissionStorageOperationsParams\n): FormBuilderSubmissionStorageOperations => {\n const { entity, esEntity, table, elasticsearch, plugins } = params;\n\n const createSubmissionPartitionKey = (\n params: FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams\n ) => {\n const { tenant, locale, formId } = params;\n\n const { id } = parseIdentifier(formId);\n\n return `T#${tenant}#L#${locale}#FB#F#${id}`;\n };\n const createSubmissionSortKey = (id: string) => {\n return `FS#${id}`;\n };\n\n const createSubmissionType = () => {\n return \"fb.formSubmission\";\n };\n\n const createSubmission = async (\n params: FormBuilderStorageOperationsCreateSubmissionParams\n ): Promise<FbSubmission> => {\n const { submission, form } = params;\n const keys = {\n PK: createSubmissionPartitionKey(form),\n SK: createSubmissionSortKey(submission.id)\n };\n\n try {\n await entity.put({\n ...submission,\n ...keys,\n TYPE: createSubmissionType()\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create form submission in the DynamoDB.\",\n ex.code || \"UPDATE_FORM_SUBMISSION_ERROR\",\n {\n submission,\n form,\n keys\n }\n );\n }\n\n try {\n const { index } = configurations.es({\n tenant: form.tenant,\n locale: form.locale\n });\n await esEntity.put({\n index,\n data: {\n ...submission,\n __type: createSubmissionElasticType()\n },\n TYPE: createSubmissionType(),\n ...keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create form submission in the Elasticsearch.\",\n ex.code || \"UPDATE_FORM_SUBMISSION_ERROR\",\n {\n submission,\n form,\n keys\n }\n );\n }\n\n return submission;\n };\n /**\n * We do not save the data in the Elasticsearch because there is no need for that.\n */\n const updateSubmission = async (\n params: FormBuilderStorageOperationsUpdateSubmissionParams\n ): Promise<FbSubmission> => {\n const { submission, form, original } = params;\n const keys = {\n PK: createSubmissionPartitionKey(form),\n SK: createSubmissionSortKey(submission.id)\n };\n\n try {\n await entity.put({\n ...submission,\n ...keys,\n TYPE: createSubmissionType()\n });\n return submission;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update form submission in the DynamoDB.\",\n ex.code || \"UPDATE_FORM_SUBMISSION_ERROR\",\n {\n submission,\n original,\n form,\n keys\n }\n );\n }\n };\n\n const deleteSubmission = async (\n params: FormBuilderStorageOperationsDeleteSubmissionParams\n ): Promise<FbSubmission> => {\n const { submission, form } = params;\n\n const keys = {\n PK: createSubmissionPartitionKey(form),\n SK: createSubmissionSortKey(submission.id)\n };\n\n try {\n await entity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form submission from DynamoDB.\",\n ex.code || \"DELETE_FORM_SUBMISSION_ERROR\",\n {\n submission,\n form,\n keys\n }\n );\n }\n\n try {\n await esEntity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form submission from Elasticsearch.\",\n ex.code || \"DELETE_FORM_SUBMISSION_ERROR\",\n {\n submission,\n form,\n keys\n }\n );\n }\n\n return submission;\n };\n\n /**\n *\n * We are using this method because it is faster to fetch the exact data from the DynamoDB than Elasticsearch.\n *\n * @internal\n */\n const listSubmissionsByIds = async (\n params: FormBuilderStorageOperationsListSubmissionsParams\n ): Promise<FbSubmission[]> => {\n const { where, sort } = params;\n const items = (where.id_in || []).map(id => {\n return entity.getBatch({\n PK: createSubmissionPartitionKey({\n ...where\n }),\n SK: createSubmissionSortKey(id)\n });\n });\n\n let results: FbSubmission[] = [];\n\n try {\n results = await batchReadAll<FbSubmission>({\n table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not batch read form submissions.\",\n ex.code || \"BATCH_READ_SUBMISSIONS_ERROR\",\n {\n where,\n sort\n }\n );\n }\n /**\n * We need to remove empty results because it is a possibility that batch read returned null for non-existing record.\n */\n const submissions = results.filter(Boolean).map(submission => {\n return cleanupItem(entity, submission);\n }) as FbSubmission[];\n if (!sort) {\n return submissions;\n }\n return sortItems<FbSubmission>({\n items: submissions,\n sort,\n fields: []\n });\n };\n\n const listSubmissions = async (\n params: FormBuilderStorageOperationsListSubmissionsParams\n ): Promise<FormBuilderStorageOperationsListSubmissionsResponse> => {\n const { where, sort = [], limit: initialLimit, after } = params;\n\n if (where.id_in) {\n const items = await listSubmissionsByIds(params);\n\n return {\n items,\n meta: {\n hasMoreItems: false,\n cursor: null,\n totalCount: items.length\n }\n };\n }\n\n const limit = createLimit(initialLimit);\n\n const body = createElasticsearchBody({\n plugins,\n sort,\n limit: limit + 1,\n where,\n after: decodeCursor(after) as any\n });\n\n const esConfig = configurations.es({\n tenant: where.tenant,\n locale: where.locale\n });\n\n const query = {\n ...esConfig,\n body\n };\n\n let response: ElasticsearchSearchResponse<FbSubmission>;\n try {\n response = await elasticsearch.search(query);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could list form submissions.\",\n ex.code || \"LIST_SUBMISSIONS_ERROR\",\n {\n where,\n query\n }\n );\n }\n\n const { hits, total } = response.body.hits;\n const items = hits.map(item => item._source);\n\n const hasMoreItems = items.length > limit;\n if (hasMoreItems) {\n /**\n * Remove the last item from results, we don't want to include it.\n */\n items.pop();\n }\n /**\n * Cursor is the `sort` value of the last item in the array.\n * https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after\n */\n const meta = {\n hasMoreItems,\n totalCount: total.value,\n cursor: items.length > 0 ? encodeCursor(hits[items.length - 1].sort) || null : null\n };\n\n return {\n items,\n meta\n };\n };\n\n const getSubmission = async (\n params: FormBuilderStorageOperationsGetSubmissionParams\n ): Promise<FbSubmission | null> => {\n const { where } = params;\n\n const keys = {\n PK: createSubmissionPartitionKey({\n ...where,\n formId: where.formId as string\n }),\n SK: createSubmissionSortKey(where.id)\n };\n\n try {\n const result = await entity.get(keys);\n\n if (!result || !result.Item) {\n return null;\n }\n\n return cleanupItem(entity, result.Item);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not oad submission.\",\n ex.code || \"GET_SUBMISSION_ERROR\",\n {\n where,\n keys\n }\n );\n }\n };\n\n return {\n createSubmission,\n deleteSubmission,\n updateSubmission,\n listSubmissions,\n getSubmission,\n createSubmissionPartitionKey,\n createSubmissionSortKey\n };\n};\n"],"mappings":";;;;;;;;;;;AAWA;;AACA;;AACA;;AACA;;AACA;;AASA;;AACA;;AACA;;AACA;;AAWO,MAAMA,iCAAiC,GAC1CC,MAD6C,IAEJ;EACzC,MAAM;IAAEC,MAAF;IAAUC,QAAV;IAAoBC,KAApB;IAA2BC,aAA3B;IAA0CC;EAA1C,IAAsDL,MAA5D;;EAEA,MAAMM,4BAA4B,GAC9BN,MADiC,IAEhC;IACD,MAAM;MAAEO,MAAF;MAAUC,MAAV;MAAkBC;IAAlB,IAA6BT,MAAnC;IAEA,MAAM;MAAEU;IAAF,IAAS,IAAAC,sBAAA,EAAgBF,MAAhB,CAAf;IAEA,OAAQ,KAAIF,MAAO,MAAKC,MAAO,SAAQE,EAAG,EAA1C;EACH,CARD;;EASA,MAAME,uBAAuB,GAAIF,EAAD,IAAgB;IAC5C,OAAQ,MAAKA,EAAG,EAAhB;EACH,CAFD;;EAIA,MAAMG,oBAAoB,GAAG,MAAM;IAC/B,OAAO,mBAAP;EACH,CAF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,EAEFF,EAAE,CAACG,IAAH,IAAW,sBAFT,EAGF;QACIY,KADJ;QAEIpB;MAFJ,CAHE,CAAN;IAQH;EACJ,CA/BD;;EAiCA,OAAO;IACHH,gBADG;IAEHoB,gBAFG;IAGHF,gBAHG;IAIHmB,eAJG;IAKHwB,aALG;IAMHrE,4BANG;IAOHM;EAPG,CAAP;AASH,CAnUM"}
|
|
1
|
+
{"version":3,"names":["createSubmissionStorageOperations","params","entity","esEntity","table","elasticsearch","plugins","createSubmissionPartitionKey","tenant","locale","formId","id","parseIdentifier","createSubmissionSortKey","createSubmissionType","createSubmission","submission","form","keys","PK","SK","put","TYPE","ex","WebinyError","message","code","index","configurations","es","data","__type","createSubmissionElasticType","updateSubmission","original","deleteSubmission","delete","listSubmissionsByIds","where","sort","items","id_in","map","getBatch","results","batchReadAll","submissions","filter","Boolean","cleanupItem","sortItems","fields","listSubmissions","limit","initialLimit","after","meta","hasMoreItems","cursor","totalCount","length","createLimit","body","createElasticsearchBody","decodeCursor","esConfig","query","response","search","hits","total","item","_source","pop","value","encodeCursor","getSubmission","result","get","Item"],"sources":["index.ts"],"sourcesContent":["import {\n FbSubmission,\n FormBuilderStorageOperationsCreateSubmissionParams,\n FormBuilderStorageOperationsDeleteSubmissionParams,\n FormBuilderStorageOperationsGetSubmissionParams,\n FormBuilderStorageOperationsListSubmissionsParams,\n FormBuilderStorageOperationsListSubmissionsResponse,\n FormBuilderStorageOperationsUpdateSubmissionParams\n} from \"@webiny/api-form-builder/types\";\nimport { Entity, Table } from \"dynamodb-toolbox\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport WebinyError from \"@webiny/error\";\nimport { batchReadAll } from \"@webiny/db-dynamodb/utils/batchRead\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\nimport { createLimit, encodeCursor, decodeCursor } from \"@webiny/api-elasticsearch\";\nimport {\n createElasticsearchBody,\n createSubmissionElasticType\n} from \"~/operations/submission/elasticsearchBody\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport {\n FormBuilderSubmissionStorageOperations,\n FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams\n} from \"~/types\";\nimport { configurations } from \"~/configurations\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { ElasticsearchSearchResponse } from \"@webiny/api-elasticsearch/types\";\n\nexport interface CreateSubmissionStorageOperationsParams {\n entity: Entity<any>;\n esEntity: Entity<any>;\n table: Table;\n elasticsearch: Client;\n plugins: PluginsContainer;\n}\n\nexport const createSubmissionStorageOperations = (\n params: CreateSubmissionStorageOperationsParams\n): FormBuilderSubmissionStorageOperations => {\n const { entity, esEntity, table, elasticsearch, plugins } = params;\n\n const createSubmissionPartitionKey = (\n params: FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams\n ) => {\n const { tenant, locale, formId } = params;\n\n const { id } = parseIdentifier(formId);\n\n return `T#${tenant}#L#${locale}#FB#F#${id}`;\n };\n const createSubmissionSortKey = (id: string) => {\n return `FS#${id}`;\n };\n\n const createSubmissionType = () => {\n return \"fb.formSubmission\";\n };\n\n const createSubmission = async (\n params: FormBuilderStorageOperationsCreateSubmissionParams\n ): Promise<FbSubmission> => {\n const { submission, form } = params;\n const keys = {\n PK: createSubmissionPartitionKey(form),\n SK: createSubmissionSortKey(submission.id)\n };\n\n try {\n await entity.put({\n ...submission,\n ...keys,\n TYPE: createSubmissionType()\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create form submission in the DynamoDB.\",\n ex.code || \"UPDATE_FORM_SUBMISSION_ERROR\",\n {\n submission,\n form,\n keys\n }\n );\n }\n\n try {\n const { index } = configurations.es({\n tenant: form.tenant,\n locale: form.locale\n });\n await esEntity.put({\n index,\n data: {\n ...submission,\n __type: createSubmissionElasticType()\n },\n TYPE: createSubmissionType(),\n ...keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create form submission in the Elasticsearch.\",\n ex.code || \"UPDATE_FORM_SUBMISSION_ERROR\",\n {\n submission,\n form,\n keys\n }\n );\n }\n\n return submission;\n };\n /**\n * We do not save the data in the Elasticsearch because there is no need for that.\n */\n const updateSubmission = async (\n params: FormBuilderStorageOperationsUpdateSubmissionParams\n ): Promise<FbSubmission> => {\n const { submission, form, original } = params;\n const keys = {\n PK: createSubmissionPartitionKey(form),\n SK: createSubmissionSortKey(submission.id)\n };\n\n try {\n await entity.put({\n ...submission,\n ...keys,\n TYPE: createSubmissionType()\n });\n return submission;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update form submission in the DynamoDB.\",\n ex.code || \"UPDATE_FORM_SUBMISSION_ERROR\",\n {\n submission,\n original,\n form,\n keys\n }\n );\n }\n };\n\n const deleteSubmission = async (\n params: FormBuilderStorageOperationsDeleteSubmissionParams\n ): Promise<FbSubmission> => {\n const { submission, form } = params;\n\n const keys = {\n PK: createSubmissionPartitionKey(form),\n SK: createSubmissionSortKey(submission.id)\n };\n\n try {\n await entity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form submission from DynamoDB.\",\n ex.code || \"DELETE_FORM_SUBMISSION_ERROR\",\n {\n submission,\n form,\n keys\n }\n );\n }\n\n try {\n await esEntity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form submission from Elasticsearch.\",\n ex.code || \"DELETE_FORM_SUBMISSION_ERROR\",\n {\n submission,\n form,\n keys\n }\n );\n }\n\n return submission;\n };\n\n /**\n *\n * We are using this method because it is faster to fetch the exact data from the DynamoDB than Elasticsearch.\n *\n * @internal\n */\n const listSubmissionsByIds = async (\n params: FormBuilderStorageOperationsListSubmissionsParams\n ): Promise<FbSubmission[]> => {\n const { where, sort } = params;\n const items = (where.id_in || []).map(id => {\n return entity.getBatch({\n PK: createSubmissionPartitionKey({\n ...where\n }),\n SK: createSubmissionSortKey(id)\n });\n });\n\n let results: FbSubmission[] = [];\n\n try {\n results = await batchReadAll<FbSubmission>({\n table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not batch read form submissions.\",\n ex.code || \"BATCH_READ_SUBMISSIONS_ERROR\",\n {\n where,\n sort\n }\n );\n }\n /**\n * We need to remove empty results because it is a possibility that batch read returned null for non-existing record.\n */\n const submissions = results.filter(Boolean).map(submission => {\n return cleanupItem(entity, submission);\n }) as FbSubmission[];\n if (!sort) {\n return submissions;\n }\n return sortItems<FbSubmission>({\n items: submissions,\n sort,\n fields: []\n });\n };\n\n const listSubmissions = async (\n params: FormBuilderStorageOperationsListSubmissionsParams\n ): Promise<FormBuilderStorageOperationsListSubmissionsResponse> => {\n const { where, sort = [], limit: initialLimit, after } = params;\n\n if (where.id_in) {\n const items = await listSubmissionsByIds(params);\n\n return {\n items,\n meta: {\n hasMoreItems: false,\n cursor: null,\n totalCount: items.length\n }\n };\n }\n\n const limit = createLimit(initialLimit);\n\n const body = createElasticsearchBody({\n plugins,\n sort,\n limit: limit + 1,\n where,\n after: decodeCursor(after) as any\n });\n\n const esConfig = configurations.es({\n tenant: where.tenant,\n locale: where.locale\n });\n\n const query = {\n ...esConfig,\n body\n };\n\n let response: ElasticsearchSearchResponse<FbSubmission>;\n try {\n response = await elasticsearch.search(query);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could list form submissions.\",\n ex.code || \"LIST_SUBMISSIONS_ERROR\",\n {\n where,\n query\n }\n );\n }\n\n const { hits, total } = response.body.hits;\n const items = hits.map(item => item._source);\n\n const hasMoreItems = items.length > limit;\n if (hasMoreItems) {\n /**\n * Remove the last item from results, we don't want to include it.\n */\n items.pop();\n }\n /**\n * Cursor is the `sort` value of the last item in the array.\n * https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after\n */\n const meta = {\n hasMoreItems,\n totalCount: total.value,\n cursor: items.length > 0 ? encodeCursor(hits[items.length - 1].sort) || null : null\n };\n\n return {\n items,\n meta\n };\n };\n\n const getSubmission = async (\n params: FormBuilderStorageOperationsGetSubmissionParams\n ): Promise<FbSubmission | null> => {\n const { where } = params;\n\n const keys = {\n PK: createSubmissionPartitionKey({\n ...where,\n formId: where.formId as string\n }),\n SK: createSubmissionSortKey(where.id)\n };\n\n try {\n const result = await entity.get(keys);\n\n if (!result || !result.Item) {\n return null;\n }\n\n return cleanupItem(entity, result.Item);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not oad submission.\",\n ex.code || \"GET_SUBMISSION_ERROR\",\n {\n where,\n keys\n }\n );\n }\n };\n\n return {\n createSubmission,\n deleteSubmission,\n updateSubmission,\n listSubmissions,\n getSubmission,\n createSubmissionPartitionKey,\n createSubmissionSortKey\n };\n};\n"],"mappings":";;;;;;;;;;;AAWA;;AACA;;AACA;;AACA;;AACA;;AASA;;AACA;;AACA;;AAWO,MAAMA,iCAAiC,GAC1CC,MAD6C,IAEJ;EACzC,MAAM;IAAEC,MAAF;IAAUC,QAAV;IAAoBC,KAApB;IAA2BC,aAA3B;IAA0CC;EAA1C,IAAsDL,MAA5D;;EAEA,MAAMM,4BAA4B,GAC9BN,MADiC,IAEhC;IACD,MAAM;MAAEO,MAAF;MAAUC,MAAV;MAAkBC;IAAlB,IAA6BT,MAAnC;IAEA,MAAM;MAAEU;IAAF,IAAS,IAAAC,sBAAA,EAAgBF,MAAhB,CAAf;IAEA,OAAQ,KAAIF,MAAO,MAAKC,MAAO,SAAQE,EAAG,EAA1C;EACH,CARD;;EASA,MAAME,uBAAuB,GAAIF,EAAD,IAAgB;IAC5C,OAAQ,MAAKA,EAAG,EAAhB;EACH,CAFD;;EAIA,MAAMG,oBAAoB,GAAG,MAAM;IAC/B,OAAO,mBAAP;EACH,CAFD;;EAIA,MAAMC,gBAAgB,GAAG,MACrBd,MADqB,IAEG;IACxB,MAAM;MAAEe,UAAF;MAAcC;IAAd,IAAuBhB,MAA7B;IACA,MAAMiB,IAAI,GAAG;MACTC,EAAE,EAAEZ,4BAA4B,CAACU,IAAD,CADvB;MAETG,EAAE,EAAEP,uBAAuB,CAAC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M;EAPG,CAAP;AASH,CAnUM"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-form-builder-so-ddb-es",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.40876133bb",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-form-builder",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@babel/runtime": "7.19.0",
|
|
25
25
|
"@elastic/elasticsearch": "7.12.0",
|
|
26
|
-
"@webiny/api": "0.0.0-unstable.
|
|
27
|
-
"@webiny/api-elasticsearch": "0.0.0-unstable.
|
|
28
|
-
"@webiny/api-form-builder": "0.0.0-unstable.
|
|
29
|
-
"@webiny/db-dynamodb": "0.0.0-unstable.
|
|
30
|
-
"@webiny/error": "0.0.0-unstable.
|
|
31
|
-
"@webiny/plugins": "0.0.0-unstable.
|
|
32
|
-
"@webiny/utils": "0.0.0-unstable.
|
|
26
|
+
"@webiny/api": "0.0.0-unstable.40876133bb",
|
|
27
|
+
"@webiny/api-elasticsearch": "0.0.0-unstable.40876133bb",
|
|
28
|
+
"@webiny/api-form-builder": "0.0.0-unstable.40876133bb",
|
|
29
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.40876133bb",
|
|
30
|
+
"@webiny/error": "0.0.0-unstable.40876133bb",
|
|
31
|
+
"@webiny/plugins": "0.0.0-unstable.40876133bb",
|
|
32
|
+
"@webiny/utils": "0.0.0-unstable.40876133bb",
|
|
33
33
|
"dynamodb-toolbox": "0.3.5",
|
|
34
34
|
"elastic-ts": "0.8.0"
|
|
35
35
|
},
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"@babel/core": "^7.19.3",
|
|
39
39
|
"@babel/preset-env": "^7.19.4",
|
|
40
40
|
"@babel/preset-typescript": "^7.18.6",
|
|
41
|
-
"@webiny/api-dynamodb-to-elasticsearch": "^0.0.0-unstable.
|
|
42
|
-
"@webiny/cli": "^0.0.0-unstable.
|
|
43
|
-
"@webiny/handler-aws": "^0.0.0-unstable.
|
|
44
|
-
"@webiny/handler-db": "^0.0.0-unstable.
|
|
45
|
-
"@webiny/project-utils": "^0.0.0-unstable.
|
|
41
|
+
"@webiny/api-dynamodb-to-elasticsearch": "^0.0.0-unstable.40876133bb",
|
|
42
|
+
"@webiny/cli": "^0.0.0-unstable.40876133bb",
|
|
43
|
+
"@webiny/handler-aws": "^0.0.0-unstable.40876133bb",
|
|
44
|
+
"@webiny/handler-db": "^0.0.0-unstable.40876133bb",
|
|
45
|
+
"@webiny/project-utils": "^0.0.0-unstable.40876133bb",
|
|
46
46
|
"csvtojson": "^2.0.10",
|
|
47
47
|
"jest": "^28.1.0",
|
|
48
48
|
"jest-dynalite": "^3.2.0",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"build": "yarn webiny run build",
|
|
60
60
|
"watch": "yarn webiny run watch"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "f33811072795d25c5787ae39808e75e3312fb247"
|
|
63
63
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElasticsearchBodyModifierPlugin } from "@webiny/api-elasticsearch
|
|
1
|
+
import { ElasticsearchBodyModifierPlugin } from "@webiny/api-elasticsearch";
|
|
2
2
|
export declare class FormElasticsearchBodyModifierPlugin extends ElasticsearchBodyModifierPlugin {
|
|
3
3
|
static readonly type: string;
|
|
4
4
|
}
|
|
@@ -9,9 +9,9 @@ exports.FormElasticsearchBodyModifierPlugin = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
13
13
|
|
|
14
|
-
class FormElasticsearchBodyModifierPlugin extends
|
|
14
|
+
class FormElasticsearchBodyModifierPlugin extends _apiElasticsearch.ElasticsearchBodyModifierPlugin {}
|
|
15
15
|
|
|
16
16
|
exports.FormElasticsearchBodyModifierPlugin = FormElasticsearchBodyModifierPlugin;
|
|
17
17
|
(0, _defineProperty2.default)(FormElasticsearchBodyModifierPlugin, "type", "formBuilder.elasticsearch.modifier.body.form");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FormElasticsearchBodyModifierPlugin","ElasticsearchBodyModifierPlugin"],"sources":["FormElasticsearchBodyModifierPlugin.ts"],"sourcesContent":["import { ElasticsearchBodyModifierPlugin } from \"@webiny/api-elasticsearch
|
|
1
|
+
{"version":3,"names":["FormElasticsearchBodyModifierPlugin","ElasticsearchBodyModifierPlugin"],"sources":["FormElasticsearchBodyModifierPlugin.ts"],"sourcesContent":["import { ElasticsearchBodyModifierPlugin } from \"@webiny/api-elasticsearch\";\n\nexport class FormElasticsearchBodyModifierPlugin extends ElasticsearchBodyModifierPlugin {\n public static override readonly type: string = \"formBuilder.elasticsearch.modifier.body.form\";\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAEO,MAAMA,mCAAN,SAAkDC,iDAAlD,CAAkF;;;8BAA5ED,mC,UACsC,8C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElasticsearchFieldPlugin } from "@webiny/api-elasticsearch
|
|
1
|
+
import { ElasticsearchFieldPlugin } from "@webiny/api-elasticsearch";
|
|
2
2
|
export declare class FormElasticsearchFieldPlugin extends ElasticsearchFieldPlugin {
|
|
3
3
|
static readonly type: string;
|
|
4
4
|
}
|
|
@@ -9,9 +9,9 @@ exports.FormElasticsearchFieldPlugin = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
13
13
|
|
|
14
|
-
class FormElasticsearchFieldPlugin extends
|
|
14
|
+
class FormElasticsearchFieldPlugin extends _apiElasticsearch.ElasticsearchFieldPlugin {}
|
|
15
15
|
|
|
16
16
|
exports.FormElasticsearchFieldPlugin = FormElasticsearchFieldPlugin;
|
|
17
17
|
(0, _defineProperty2.default)(FormElasticsearchFieldPlugin, "type", "formBuilder.elasticsearch.fieldDefinition.form");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FormElasticsearchFieldPlugin","ElasticsearchFieldPlugin"],"sources":["FormElasticsearchFieldPlugin.ts"],"sourcesContent":["import { ElasticsearchFieldPlugin } from \"@webiny/api-elasticsearch
|
|
1
|
+
{"version":3,"names":["FormElasticsearchFieldPlugin","ElasticsearchFieldPlugin"],"sources":["FormElasticsearchFieldPlugin.ts"],"sourcesContent":["import { ElasticsearchFieldPlugin } from \"@webiny/api-elasticsearch\";\n\nexport class FormElasticsearchFieldPlugin extends ElasticsearchFieldPlugin {\n public static override readonly type: string = \"formBuilder.elasticsearch.fieldDefinition.form\";\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAEO,MAAMA,4BAAN,SAA2CC,0CAA3C,CAAoE;;;8BAA9DD,4B,UACsC,gD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElasticsearchIndexPlugin } from "@webiny/api-elasticsearch
|
|
1
|
+
import { ElasticsearchIndexPlugin } from "@webiny/api-elasticsearch";
|
|
2
2
|
export declare class FormElasticsearchIndexPlugin extends ElasticsearchIndexPlugin {
|
|
3
3
|
static readonly type: string;
|
|
4
4
|
}
|
|
@@ -9,9 +9,9 @@ exports.FormElasticsearchIndexPlugin = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
13
13
|
|
|
14
|
-
class FormElasticsearchIndexPlugin extends
|
|
14
|
+
class FormElasticsearchIndexPlugin extends _apiElasticsearch.ElasticsearchIndexPlugin {}
|
|
15
15
|
|
|
16
16
|
exports.FormElasticsearchIndexPlugin = FormElasticsearchIndexPlugin;
|
|
17
17
|
(0, _defineProperty2.default)(FormElasticsearchIndexPlugin, "type", "formBuilder.form.elasticsearch.index");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FormElasticsearchIndexPlugin","ElasticsearchIndexPlugin"],"sources":["FormElasticsearchIndexPlugin.ts"],"sourcesContent":["import { ElasticsearchIndexPlugin } from \"@webiny/api-elasticsearch
|
|
1
|
+
{"version":3,"names":["FormElasticsearchIndexPlugin","ElasticsearchIndexPlugin"],"sources":["FormElasticsearchIndexPlugin.ts"],"sourcesContent":["import { ElasticsearchIndexPlugin } from \"@webiny/api-elasticsearch\";\n\nexport class FormElasticsearchIndexPlugin extends ElasticsearchIndexPlugin {\n public static override readonly type: string = \"formBuilder.form.elasticsearch.index\";\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAEO,MAAMA,4BAAN,SAA2CC,0CAA3C,CAAoE;;;8BAA9DD,4B,UACsC,sC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElasticsearchQueryModifierPlugin } from "@webiny/api-elasticsearch
|
|
1
|
+
import { ElasticsearchQueryModifierPlugin } from "@webiny/api-elasticsearch";
|
|
2
2
|
export declare class FormElasticsearchQueryModifierPlugin extends ElasticsearchQueryModifierPlugin {
|
|
3
3
|
static readonly type: string;
|
|
4
4
|
}
|
|
@@ -9,9 +9,9 @@ exports.FormElasticsearchQueryModifierPlugin = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
13
13
|
|
|
14
|
-
class FormElasticsearchQueryModifierPlugin extends
|
|
14
|
+
class FormElasticsearchQueryModifierPlugin extends _apiElasticsearch.ElasticsearchQueryModifierPlugin {}
|
|
15
15
|
|
|
16
16
|
exports.FormElasticsearchQueryModifierPlugin = FormElasticsearchQueryModifierPlugin;
|
|
17
17
|
(0, _defineProperty2.default)(FormElasticsearchQueryModifierPlugin, "type", "formBuilder.elasticsearch.modifier.query.form");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FormElasticsearchQueryModifierPlugin","ElasticsearchQueryModifierPlugin"],"sources":["FormElasticsearchQueryModifierPlugin.ts"],"sourcesContent":["import { ElasticsearchQueryModifierPlugin } from \"@webiny/api-elasticsearch
|
|
1
|
+
{"version":3,"names":["FormElasticsearchQueryModifierPlugin","ElasticsearchQueryModifierPlugin"],"sources":["FormElasticsearchQueryModifierPlugin.ts"],"sourcesContent":["import { ElasticsearchQueryModifierPlugin } from \"@webiny/api-elasticsearch\";\n\nexport class FormElasticsearchQueryModifierPlugin extends ElasticsearchQueryModifierPlugin {\n public static override readonly type: string = \"formBuilder.elasticsearch.modifier.query.form\";\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAEO,MAAMA,oCAAN,SAAmDC,kDAAnD,CAAoF;;;8BAA9ED,oC,UACsC,+C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElasticsearchSortModifierPlugin } from "@webiny/api-elasticsearch
|
|
1
|
+
import { ElasticsearchSortModifierPlugin } from "@webiny/api-elasticsearch";
|
|
2
2
|
export declare class FormElasticsearchSortModifierPlugin extends ElasticsearchSortModifierPlugin {
|
|
3
3
|
static readonly type: string;
|
|
4
4
|
}
|
|
@@ -9,9 +9,9 @@ exports.FormElasticsearchSortModifierPlugin = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
13
13
|
|
|
14
|
-
class FormElasticsearchSortModifierPlugin extends
|
|
14
|
+
class FormElasticsearchSortModifierPlugin extends _apiElasticsearch.ElasticsearchSortModifierPlugin {}
|
|
15
15
|
|
|
16
16
|
exports.FormElasticsearchSortModifierPlugin = FormElasticsearchSortModifierPlugin;
|
|
17
17
|
(0, _defineProperty2.default)(FormElasticsearchSortModifierPlugin, "type", "formBuilder.elasticsearch.modifier.sort.form");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FormElasticsearchSortModifierPlugin","ElasticsearchSortModifierPlugin"],"sources":["FormElasticsearchSortModifierPlugin.ts"],"sourcesContent":["import { ElasticsearchSortModifierPlugin } from \"@webiny/api-elasticsearch
|
|
1
|
+
{"version":3,"names":["FormElasticsearchSortModifierPlugin","ElasticsearchSortModifierPlugin"],"sources":["FormElasticsearchSortModifierPlugin.ts"],"sourcesContent":["import { ElasticsearchSortModifierPlugin } from \"@webiny/api-elasticsearch\";\n\nexport class FormElasticsearchSortModifierPlugin extends ElasticsearchSortModifierPlugin {\n public static override readonly type: string = \"formBuilder.elasticsearch.modifier.sort.form\";\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAEO,MAAMA,mCAAN,SAAkDC,iDAAlD,CAAkF;;;8BAA5ED,mC,UACsC,8C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElasticsearchBodyModifierPlugin } from "@webiny/api-elasticsearch
|
|
1
|
+
import { ElasticsearchBodyModifierPlugin } from "@webiny/api-elasticsearch";
|
|
2
2
|
export declare class SubmissionElasticsearchBodyModifierPlugin extends ElasticsearchBodyModifierPlugin {
|
|
3
3
|
static readonly type: string;
|
|
4
4
|
}
|
|
@@ -9,9 +9,9 @@ exports.SubmissionElasticsearchBodyModifierPlugin = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
13
13
|
|
|
14
|
-
class SubmissionElasticsearchBodyModifierPlugin extends
|
|
14
|
+
class SubmissionElasticsearchBodyModifierPlugin extends _apiElasticsearch.ElasticsearchBodyModifierPlugin {}
|
|
15
15
|
|
|
16
16
|
exports.SubmissionElasticsearchBodyModifierPlugin = SubmissionElasticsearchBodyModifierPlugin;
|
|
17
17
|
(0, _defineProperty2.default)(SubmissionElasticsearchBodyModifierPlugin, "type", "formBuilder.elasticsearch.modifier.body.submission");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SubmissionElasticsearchBodyModifierPlugin","ElasticsearchBodyModifierPlugin"],"sources":["SubmissionElasticsearchBodyModifierPlugin.ts"],"sourcesContent":["import { ElasticsearchBodyModifierPlugin } from \"@webiny/api-elasticsearch
|
|
1
|
+
{"version":3,"names":["SubmissionElasticsearchBodyModifierPlugin","ElasticsearchBodyModifierPlugin"],"sources":["SubmissionElasticsearchBodyModifierPlugin.ts"],"sourcesContent":["import { ElasticsearchBodyModifierPlugin } from \"@webiny/api-elasticsearch\";\n\nexport class SubmissionElasticsearchBodyModifierPlugin extends ElasticsearchBodyModifierPlugin {\n public static override readonly type: string =\n \"formBuilder.elasticsearch.modifier.body.submission\";\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAEO,MAAMA,yCAAN,SAAwDC,iDAAxD,CAAwF;;;8BAAlFD,yC,UAEL,oD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElasticsearchFieldPlugin } from "@webiny/api-elasticsearch
|
|
1
|
+
import { ElasticsearchFieldPlugin } from "@webiny/api-elasticsearch";
|
|
2
2
|
export declare class SubmissionElasticsearchFieldPlugin extends ElasticsearchFieldPlugin {
|
|
3
3
|
static readonly type: string;
|
|
4
4
|
}
|
|
@@ -9,9 +9,9 @@ exports.SubmissionElasticsearchFieldPlugin = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
13
13
|
|
|
14
|
-
class SubmissionElasticsearchFieldPlugin extends
|
|
14
|
+
class SubmissionElasticsearchFieldPlugin extends _apiElasticsearch.ElasticsearchFieldPlugin {}
|
|
15
15
|
|
|
16
16
|
exports.SubmissionElasticsearchFieldPlugin = SubmissionElasticsearchFieldPlugin;
|
|
17
17
|
(0, _defineProperty2.default)(SubmissionElasticsearchFieldPlugin, "type", "formBuilder.elasticsearch.fieldDefinition.submission");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SubmissionElasticsearchFieldPlugin","ElasticsearchFieldPlugin"],"sources":["SubmissionElasticsearchFieldPlugin.ts"],"sourcesContent":["import { ElasticsearchFieldPlugin } from \"@webiny/api-elasticsearch
|
|
1
|
+
{"version":3,"names":["SubmissionElasticsearchFieldPlugin","ElasticsearchFieldPlugin"],"sources":["SubmissionElasticsearchFieldPlugin.ts"],"sourcesContent":["import { ElasticsearchFieldPlugin } from \"@webiny/api-elasticsearch\";\n\nexport class SubmissionElasticsearchFieldPlugin extends ElasticsearchFieldPlugin {\n public static override readonly type: string =\n \"formBuilder.elasticsearch.fieldDefinition.submission\";\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAEO,MAAMA,kCAAN,SAAiDC,0CAAjD,CAA0E;;;8BAApED,kC,UAEL,sD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElasticsearchQueryModifierPlugin } from "@webiny/api-elasticsearch
|
|
1
|
+
import { ElasticsearchQueryModifierPlugin } from "@webiny/api-elasticsearch";
|
|
2
2
|
export declare class SubmissionElasticsearchQueryModifierPlugin extends ElasticsearchQueryModifierPlugin {
|
|
3
3
|
static readonly type: string;
|
|
4
4
|
}
|
|
@@ -9,9 +9,9 @@ exports.SubmissionElasticsearchQueryModifierPlugin = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
13
13
|
|
|
14
|
-
class SubmissionElasticsearchQueryModifierPlugin extends
|
|
14
|
+
class SubmissionElasticsearchQueryModifierPlugin extends _apiElasticsearch.ElasticsearchQueryModifierPlugin {}
|
|
15
15
|
|
|
16
16
|
exports.SubmissionElasticsearchQueryModifierPlugin = SubmissionElasticsearchQueryModifierPlugin;
|
|
17
17
|
(0, _defineProperty2.default)(SubmissionElasticsearchQueryModifierPlugin, "type", "formBuilder.elasticsearch.modifier.query.submission");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SubmissionElasticsearchQueryModifierPlugin","ElasticsearchQueryModifierPlugin"],"sources":["SubmissionElasticsearchQueryModifierPlugin.ts"],"sourcesContent":["import { ElasticsearchQueryModifierPlugin } from \"@webiny/api-elasticsearch
|
|
1
|
+
{"version":3,"names":["SubmissionElasticsearchQueryModifierPlugin","ElasticsearchQueryModifierPlugin"],"sources":["SubmissionElasticsearchQueryModifierPlugin.ts"],"sourcesContent":["import { ElasticsearchQueryModifierPlugin } from \"@webiny/api-elasticsearch\";\n\nexport class SubmissionElasticsearchQueryModifierPlugin extends ElasticsearchQueryModifierPlugin {\n public static override readonly type: string =\n \"formBuilder.elasticsearch.modifier.query.submission\";\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAEO,MAAMA,0CAAN,SAAyDC,kDAAzD,CAA0F;;;8BAApFD,0C,UAEL,qD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElasticsearchSortModifierPlugin } from "@webiny/api-elasticsearch
|
|
1
|
+
import { ElasticsearchSortModifierPlugin } from "@webiny/api-elasticsearch";
|
|
2
2
|
export declare class SubmissionElasticsearchSortModifierPlugin extends ElasticsearchSortModifierPlugin {
|
|
3
3
|
static readonly type: string;
|
|
4
4
|
}
|
|
@@ -9,9 +9,9 @@ exports.SubmissionElasticsearchSortModifierPlugin = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
13
13
|
|
|
14
|
-
class SubmissionElasticsearchSortModifierPlugin extends
|
|
14
|
+
class SubmissionElasticsearchSortModifierPlugin extends _apiElasticsearch.ElasticsearchSortModifierPlugin {}
|
|
15
15
|
|
|
16
16
|
exports.SubmissionElasticsearchSortModifierPlugin = SubmissionElasticsearchSortModifierPlugin;
|
|
17
17
|
(0, _defineProperty2.default)(SubmissionElasticsearchSortModifierPlugin, "type", "formBuilder.elasticsearch.modifier.sort.submission");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SubmissionElasticsearchSortModifierPlugin","ElasticsearchSortModifierPlugin"],"sources":["SubmissionElasticsearchSortModifierPlugin.ts"],"sourcesContent":["import { ElasticsearchSortModifierPlugin } from \"@webiny/api-elasticsearch
|
|
1
|
+
{"version":3,"names":["SubmissionElasticsearchSortModifierPlugin","ElasticsearchSortModifierPlugin"],"sources":["SubmissionElasticsearchSortModifierPlugin.ts"],"sourcesContent":["import { ElasticsearchSortModifierPlugin } from \"@webiny/api-elasticsearch\";\n\nexport class SubmissionElasticsearchSortModifierPlugin extends ElasticsearchSortModifierPlugin {\n public static override readonly type: string =\n \"formBuilder.elasticsearch.modifier.sort.submission\";\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAEO,MAAMA,yCAAN,SAAwDC,iDAAxD,CAAwF;;;8BAAlFD,yC,UAEL,oD"}
|