@webiny/api-form-builder-so-ddb-es 0.0.0-mt-3 → 0.0.0-unstable.5e7233243f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configurations.d.ts +7 -5
- package/configurations.js +31 -9
- package/configurations.js.map +1 -0
- package/definitions/elasticsearch.d.ts +2 -1
- package/definitions/elasticsearch.js +2 -2
- package/definitions/elasticsearch.js.map +1 -0
- package/definitions/form.d.ts +2 -1
- package/definitions/form.js +2 -2
- package/definitions/form.js.map +1 -0
- package/definitions/settings.d.ts +2 -1
- package/definitions/settings.js +2 -2
- package/definitions/settings.js.map +1 -0
- package/definitions/submission.d.ts +2 -1
- package/definitions/submission.js +2 -2
- package/definitions/submission.js.map +1 -0
- package/definitions/system.d.ts +2 -1
- package/definitions/system.js +2 -2
- package/definitions/system.js.map +1 -0
- package/definitions/table.d.ts +3 -2
- package/definitions/table.js.map +1 -0
- package/definitions/tableElasticsearch.d.ts +2 -1
- package/definitions/tableElasticsearch.js.map +1 -0
- package/elasticsearch/createElasticsearchIndex.d.ts +10 -0
- package/elasticsearch/createElasticsearchIndex.js +63 -0
- package/elasticsearch/createElasticsearchIndex.js.map +1 -0
- package/elasticsearch/indices/base.d.ts +2 -0
- package/elasticsearch/indices/base.js +23 -0
- package/elasticsearch/indices/base.js.map +1 -0
- package/elasticsearch/indices/index.d.ts +1 -0
- package/elasticsearch/indices/index.js +16 -0
- package/elasticsearch/indices/index.js.map +1 -0
- package/elasticsearch/indices/japanese.d.ts +2 -0
- package/elasticsearch/indices/japanese.js +24 -0
- package/elasticsearch/indices/japanese.js.map +1 -0
- package/index.js +35 -28
- package/index.js.map +1 -0
- package/operations/form/elasticsearchBody.js +6 -9
- package/operations/form/elasticsearchBody.js.map +1 -0
- package/operations/form/elasticsearchFields.js.map +1 -0
- package/operations/form/fields.js.map +1 -0
- package/operations/form/index.d.ts +2 -2
- package/operations/form/index.js +28 -21
- package/operations/form/index.js.map +1 -0
- package/operations/settings/index.d.ts +2 -2
- package/operations/settings/index.js +2 -2
- package/operations/settings/index.js.map +1 -0
- package/operations/submission/elasticsearchBody.js +7 -3
- package/operations/submission/elasticsearchBody.js.map +1 -0
- package/operations/submission/elasticsearchFields.js.map +1 -0
- package/operations/submission/index.d.ts +2 -2
- package/operations/submission/index.js +12 -10
- package/operations/submission/index.js.map +1 -0
- package/operations/system/index.d.ts +2 -2
- package/operations/system/index.js +2 -2
- package/operations/system/index.js.map +1 -0
- package/package.json +22 -26
- package/plugins/FormDynamoDbFieldPlugin.js.map +1 -0
- package/plugins/FormElasticsearchBodyModifierPlugin.js.map +1 -0
- package/plugins/FormElasticsearchFieldPlugin.js.map +1 -0
- package/plugins/FormElasticsearchIndexPlugin.d.ts +4 -0
- package/plugins/FormElasticsearchIndexPlugin.js +17 -0
- package/plugins/FormElasticsearchIndexPlugin.js.map +1 -0
- package/plugins/FormElasticsearchQueryModifierPlugin.js.map +1 -0
- package/plugins/FormElasticsearchSortModifierPlugin.js.map +1 -0
- package/plugins/SubmissionElasticsearchBodyModifierPlugin.js.map +1 -0
- package/plugins/SubmissionElasticsearchFieldPlugin.js.map +1 -0
- package/plugins/SubmissionElasticsearchQueryModifierPlugin.js.map +1 -0
- package/plugins/SubmissionElasticsearchSortModifierPlugin.js.map +1 -0
- package/types.d.ts +2 -2
- package/types.js.map +1 -0
- package/operations/system/createElasticsearchIndex.d.ts +0 -6
- package/operations/system/createElasticsearchIndex.js +0 -70
- package/upgrades/5.16.0/index.d.ts +0 -8
- package/upgrades/5.16.0/index.js +0 -141
package/index.js
CHANGED
|
@@ -9,10 +9,16 @@ exports.createFormBuilderStorageOperations = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _filters = _interopRequireDefault(require("@webiny/db-dynamodb/plugins/filters"));
|
|
13
|
+
|
|
14
|
+
var _elasticsearchFields = _interopRequireDefault(require("./operations/form/elasticsearchFields"));
|
|
15
|
+
|
|
16
|
+
var _elasticsearchFields2 = _interopRequireDefault(require("./operations/submission/elasticsearchFields"));
|
|
13
17
|
|
|
14
18
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
19
|
|
|
20
|
+
var _types = require("./types");
|
|
21
|
+
|
|
16
22
|
var _table = require("./definitions/table");
|
|
17
23
|
|
|
18
24
|
var _form = require("./definitions/form");
|
|
@@ -31,27 +37,21 @@ var _settings2 = require("./operations/settings");
|
|
|
31
37
|
|
|
32
38
|
var _form2 = require("./operations/form");
|
|
33
39
|
|
|
34
|
-
var _createElasticsearchIndex = require("./operations/system/createElasticsearchIndex");
|
|
35
|
-
|
|
36
40
|
var _tableElasticsearch = require("./definitions/tableElasticsearch");
|
|
37
41
|
|
|
38
42
|
var _plugins = require("@webiny/plugins");
|
|
39
43
|
|
|
40
44
|
var _elasticsearch = require("./definitions/elasticsearch");
|
|
41
45
|
|
|
42
|
-
var _elasticsearchFields = _interopRequireDefault(require("./operations/submission/elasticsearchFields"));
|
|
43
|
-
|
|
44
|
-
var _elasticsearchFields2 = _interopRequireDefault(require("./operations/form/elasticsearchFields"));
|
|
45
|
-
|
|
46
|
-
var _filters = _interopRequireDefault(require("@webiny/db-dynamodb/plugins/filters"));
|
|
47
|
-
|
|
48
46
|
var _operators = require("@webiny/api-elasticsearch/operators");
|
|
49
47
|
|
|
50
|
-
var
|
|
48
|
+
var _indices = require("./elasticsearch/indices");
|
|
49
|
+
|
|
50
|
+
var _createElasticsearchIndex = require("./elasticsearch/createElasticsearchIndex");
|
|
51
51
|
|
|
52
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
52
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
53
53
|
|
|
54
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
54
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
55
55
|
|
|
56
56
|
const reservedFields = ["PK", "SK", "index", "data", "TYPE", "__type", "GSI1_PK", "GSI1_SK"];
|
|
57
57
|
|
|
@@ -67,12 +67,12 @@ const isReserved = name => {
|
|
|
67
67
|
|
|
68
68
|
const createFormBuilderStorageOperations = params => {
|
|
69
69
|
const {
|
|
70
|
-
attributes
|
|
70
|
+
attributes,
|
|
71
71
|
table: tableName,
|
|
72
72
|
esTable: esTableName,
|
|
73
73
|
documentClient,
|
|
74
74
|
elasticsearch,
|
|
75
|
-
plugins:
|
|
75
|
+
plugins: userPlugins
|
|
76
76
|
} = params;
|
|
77
77
|
|
|
78
78
|
if (attributes) {
|
|
@@ -85,15 +85,15 @@ const createFormBuilderStorageOperations = params => {
|
|
|
85
85
|
/**
|
|
86
86
|
* User defined plugins.
|
|
87
87
|
*/
|
|
88
|
-
|
|
88
|
+
userPlugins || [],
|
|
89
89
|
/**
|
|
90
90
|
* Elasticsearch field definitions for the submission record.
|
|
91
91
|
*/
|
|
92
|
-
(0,
|
|
92
|
+
(0, _elasticsearchFields2.default)(),
|
|
93
93
|
/**
|
|
94
94
|
* Elasticsearch field definitions for the form record.
|
|
95
95
|
*/
|
|
96
|
-
(0,
|
|
96
|
+
(0, _elasticsearchFields.default)(),
|
|
97
97
|
/**
|
|
98
98
|
* DynamoDB filter plugins for the where conditions.
|
|
99
99
|
*/
|
|
@@ -101,7 +101,11 @@ const createFormBuilderStorageOperations = params => {
|
|
|
101
101
|
/**
|
|
102
102
|
* Elasticsearch operators.
|
|
103
103
|
*/
|
|
104
|
-
(0, _operators.getElasticsearchOperators)()
|
|
104
|
+
(0, _operators.getElasticsearchOperators)(),
|
|
105
|
+
/**
|
|
106
|
+
* Built-in Elasticsearch index plugins
|
|
107
|
+
*/
|
|
108
|
+
(0, _indices.elasticsearchIndexPlugins)()]);
|
|
105
109
|
const table = (0, _table.createTable)({
|
|
106
110
|
tableName,
|
|
107
111
|
documentClient
|
|
@@ -117,22 +121,22 @@ const createFormBuilderStorageOperations = params => {
|
|
|
117
121
|
form: (0, _form.createFormEntity)({
|
|
118
122
|
entityName: _types.ENTITIES.FORM,
|
|
119
123
|
table,
|
|
120
|
-
attributes: attributes[_types.ENTITIES.FORM]
|
|
124
|
+
attributes: attributes ? attributes[_types.ENTITIES.FORM] : {}
|
|
121
125
|
}),
|
|
122
126
|
submission: (0, _submission.createSubmissionEntity)({
|
|
123
127
|
entityName: _types.ENTITIES.SUBMISSION,
|
|
124
128
|
table,
|
|
125
|
-
attributes: attributes[_types.ENTITIES.SUBMISSION]
|
|
129
|
+
attributes: attributes ? attributes[_types.ENTITIES.SUBMISSION] : {}
|
|
126
130
|
}),
|
|
127
131
|
system: (0, _system.createSystemEntity)({
|
|
128
132
|
entityName: _types.ENTITIES.SYSTEM,
|
|
129
133
|
table,
|
|
130
|
-
attributes: attributes[_types.ENTITIES.SYSTEM]
|
|
134
|
+
attributes: attributes ? attributes[_types.ENTITIES.SYSTEM] : {}
|
|
131
135
|
}),
|
|
132
136
|
settings: (0, _settings.createSettingsEntity)({
|
|
133
137
|
entityName: _types.ENTITIES.SETTINGS,
|
|
134
138
|
table,
|
|
135
|
-
attributes: attributes[_types.ENTITIES.SETTINGS]
|
|
139
|
+
attributes: attributes ? attributes[_types.ENTITIES.SETTINGS] : {}
|
|
136
140
|
}),
|
|
137
141
|
|
|
138
142
|
/**
|
|
@@ -141,26 +145,29 @@ const createFormBuilderStorageOperations = params => {
|
|
|
141
145
|
esForm: (0, _elasticsearch.createElasticsearchEntity)({
|
|
142
146
|
entityName: _types.ENTITIES.ES_FORM,
|
|
143
147
|
table: esTable,
|
|
144
|
-
attributes: attributes[_types.ENTITIES.ES_FORM]
|
|
148
|
+
attributes: attributes ? attributes[_types.ENTITIES.ES_FORM] : {}
|
|
145
149
|
}),
|
|
146
150
|
esSubmission: (0, _elasticsearch.createElasticsearchEntity)({
|
|
147
151
|
entityName: _types.ENTITIES.ES_SUBMISSION,
|
|
148
152
|
table: esTable,
|
|
149
|
-
attributes: attributes[_types.ENTITIES.ES_SUBMISSION]
|
|
153
|
+
attributes: attributes ? attributes[_types.ENTITIES.ES_SUBMISSION] : {}
|
|
150
154
|
})
|
|
151
155
|
};
|
|
152
156
|
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
153
|
-
init: async
|
|
154
|
-
|
|
157
|
+
init: async context => {
|
|
158
|
+
context.i18n.locales.onBeforeCreate.subscribe(async ({
|
|
159
|
+
locale,
|
|
155
160
|
tenant
|
|
156
161
|
}) => {
|
|
157
162
|
await (0, _createElasticsearchIndex.createElasticsearchIndex)({
|
|
158
163
|
elasticsearch,
|
|
159
|
-
|
|
164
|
+
plugins,
|
|
165
|
+
tenant,
|
|
166
|
+
locale: locale.code
|
|
160
167
|
});
|
|
161
168
|
});
|
|
162
169
|
},
|
|
163
|
-
upgrade:
|
|
170
|
+
upgrade: null,
|
|
164
171
|
getTable: () => table,
|
|
165
172
|
getEsTable: () => esTable,
|
|
166
173
|
getEntities: () => entities
|
package/index.js.map
ADDED
|
@@ -0,0 +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","onBeforeCreate","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.onBeforeCreate.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;;EASA,IAAIC,UAAJ,EAAgB;IACZS,MAA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7BwD,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"}
|
|
@@ -15,8 +15,6 @@ var _sort = require("@webiny/api-elasticsearch/sort");
|
|
|
15
15
|
|
|
16
16
|
var _limit = require("@webiny/api-elasticsearch/limit");
|
|
17
17
|
|
|
18
|
-
var _ElasticsearchQueryBuilderOperatorPlugin = require("@webiny/api-elasticsearch/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin");
|
|
19
|
-
|
|
20
18
|
var _FormElasticsearchFieldPlugin = require("../../plugins/FormElasticsearchFieldPlugin");
|
|
21
19
|
|
|
22
20
|
var _FormElasticsearchSortModifierPlugin = require("../../plugins/FormElasticsearchSortModifierPlugin");
|
|
@@ -27,9 +25,11 @@ var _FormElasticsearchQueryModifierPlugin = require("../../plugins/FormElasticse
|
|
|
27
25
|
|
|
28
26
|
var _where = require("@webiny/api-elasticsearch/where");
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
var _operators = require("@webiny/api-elasticsearch/operators");
|
|
29
|
+
|
|
30
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
31
31
|
|
|
32
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
32
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
33
|
|
|
34
34
|
const createFormElasticType = () => {
|
|
35
35
|
return "fb.form";
|
|
@@ -65,10 +65,7 @@ const createElasticsearchQuery = params => {
|
|
|
65
65
|
* Be aware that, if having more registered operator plugins of same type, the last one will be used.
|
|
66
66
|
*/
|
|
67
67
|
|
|
68
|
-
const operatorPlugins =
|
|
69
|
-
acc[plugin.getOperator()] = plugin;
|
|
70
|
-
return acc;
|
|
71
|
-
}, {});
|
|
68
|
+
const operatorPlugins = (0, _operators.getElasticsearchOperatorPluginsByLocale)(plugins, initialWhere.locale);
|
|
72
69
|
|
|
73
70
|
const where = _objectSpread({}, initialWhere);
|
|
74
71
|
/**
|
|
@@ -81,7 +78,7 @@ const createElasticsearchQuery = params => {
|
|
|
81
78
|
|
|
82
79
|
const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === "true";
|
|
83
80
|
|
|
84
|
-
if (sharedIndex) {
|
|
81
|
+
if (sharedIndex && where.tenant) {
|
|
85
82
|
query.must.push({
|
|
86
83
|
term: {
|
|
87
84
|
"tenant.keyword": where.tenant
|
|
@@ -0,0 +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 { 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 { 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\";\nimport { applyWhere } from \"@webiny/api-elasticsearch/where\";\nimport { getElasticsearchOperatorPluginsByLocale } from \"@webiny/api-elasticsearch/operators\";\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;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;;;;;AAEO,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;IAAgCC;EAAhC,IAAiDJ,MAAvD;EACA,MAAMK,KAAK,GAAGZ,uBAAuB,EAArC;EACA;AACJ;AACA;;EACI,MAAMa,eAAe,GAAG,IAAAC,kDAA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MAAMf,KAAK,GAAGN,wBAAwB,iCAC/BC,MAD+B;IAElCI;EAFkC,GAAtC;EAKA,MAAMiB,IAAI,GAAG,IAAAW,gBAAA,EAAW;IACpBX,IAAI,EAAEC,WADc;IAEpBlB;EAFoB,CAAX,CAAb;EAKA,MAAM6B,cAAc,GAAGhC,OAAO,CAACuB,MAAR,CACnBU,0EAAA,CAAqCR,IADlB,CAAvB;;EAIA,KAAK,MAAMG,MAAX,IAAqBI,cAArB,EAAqC;IACjCJ,MAAM,CAACM,WAAP,CAAmB;MACf9B,KADe;MAEfH;IAFe,CAAnB;EAIH;;EAED,MAAMkC,aAAa,GAAGnC,OAAO,CAACuB,MAAR,CAClBa,wEAAA,CAAoCX,IADlB,CAAtB;;EAIA,KAAK,MAAMG,MAAX,IAAqBO,aAArB,EAAoC;IAChCP,MAAM,CAACS,UAAP,CAAkB;MACdjB;IADc,CAAlB;EAGH;;EAED,MAAMkB,IAAI,GAAG;IACTlC,KAAK,EAAE;MACHmC,cAAc,EAAE;QACZ1C,MAAM,EAAE;UACJ2C,IAAI,oBACGpC,KADH;QADA;MADI;IADb,CADE;IAUTqC,IAAI,EAAEvB,KAAK,GAAG,CAVL;;IAWT;AACR;AACA;AACA;AACA;IACQwB,YAAY,EAAE,IAAAC,qBAAA,EAAarB,KAAb,CAhBL;IAiBTF;EAjBS,CAAb;EAoBA,MAAMwB,aAAa,GAAG5C,OAAO,CAACuB,MAAR,CAClBsB,wEAAA,CAAoCpB,IADlB,CAAtB;;EAIA,KAAK,MAAMG,MAAX,IAAqBgB,aAArB,EAAoC;IAChChB,MAAM,CAACkB,UAAP,CAAkB;MACdR;IADc,CAAlB;EAGH;;EAED,OAAOA,IAAP;AACH,CA1EM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["FormElasticsearchFieldPlugin","field","unmappedType","path","ALL"],"sources":["elasticsearchFields.ts"],"sourcesContent":["import { FormElasticsearchFieldPlugin } from \"~/plugins/FormElasticsearchFieldPlugin\";\n\nexport default () => [\n new FormElasticsearchFieldPlugin({\n field: \"createdOn\",\n unmappedType: \"date\"\n }),\n new FormElasticsearchFieldPlugin({\n field: \"savedOn\",\n unmappedType: \"date\"\n }),\n new FormElasticsearchFieldPlugin({\n field: \"publishedOn\",\n unmappedType: \"date\"\n }),\n new FormElasticsearchFieldPlugin({\n field: \"ownedBy\",\n path: \"ownedBy.id\"\n }),\n new FormElasticsearchFieldPlugin({\n field: \"createdBy\",\n path: \"createdBy.id\"\n }),\n /**\n * Always add the ALL fields plugin because of the keyword/path build.\n */\n new FormElasticsearchFieldPlugin({\n field: FormElasticsearchFieldPlugin.ALL\n })\n];\n"],"mappings":";;;;;;;AAAA;;eAEe,MAAM,CACjB,IAAIA,0DAAJ,CAAiC;EAC7BC,KAAK,EAAE,WADsB;EAE7BC,YAAY,EAAE;AAFe,CAAjC,CADiB,EAKjB,IAAIF,0DAAJ,CAAiC;EAC7BC,KAAK,EAAE,SADsB;EAE7BC,YAAY,EAAE;AAFe,CAAjC,CALiB,EASjB,IAAIF,0DAAJ,CAAiC;EAC7BC,KAAK,EAAE,aADsB;EAE7BC,YAAY,EAAE;AAFe,CAAjC,CATiB,EAajB,IAAIF,0DAAJ,CAAiC;EAC7BC,KAAK,EAAE,SADsB;EAE7BE,IAAI,EAAE;AAFuB,CAAjC,CAbiB,EAiBjB,IAAIH,0DAAJ,CAAiC;EAC7BC,KAAK,EAAE,WADsB;EAE7BE,IAAI,EAAE;AAFuB,CAAjC,CAjBiB;AAqBjB;AACJ;AACA;AACI,IAAIH,0DAAJ,CAAiC;EAC7BC,KAAK,EAAED,0DAAA,CAA6BI;AADP,CAAjC,CAxBiB,C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["FormDynamoDbFieldPlugin","field","type"],"sources":["fields.ts"],"sourcesContent":["import { FormDynamoDbFieldPlugin } from \"~/plugins/FormDynamoDbFieldPlugin\";\n\nexport default () => [\n new FormDynamoDbFieldPlugin({\n field: \"publishedOn\",\n type: \"date\"\n })\n];\n"],"mappings":";;;;;;;AAAA;;eAEe,MAAM,CACjB,IAAIA,gDAAJ,CAA4B;EACxBC,KAAK,EAAE,aADiB;EAExBC,IAAI,EAAE;AAFkB,CAA5B,CADiB,C"}
|
|
@@ -7,11 +7,11 @@ export declare type DbRecord<T = any> = T & {
|
|
|
7
7
|
SK: string;
|
|
8
8
|
TYPE: string;
|
|
9
9
|
};
|
|
10
|
-
export interface
|
|
10
|
+
export interface CreateFormStorageOperationsParams {
|
|
11
11
|
entity: Entity<any>;
|
|
12
12
|
esEntity: Entity<any>;
|
|
13
13
|
table: Table;
|
|
14
14
|
elasticsearch: Client;
|
|
15
15
|
plugins: PluginsContainer;
|
|
16
16
|
}
|
|
17
|
-
export declare const createFormStorageOperations: (params:
|
|
17
|
+
export declare const createFormStorageOperations: (params: CreateFormStorageOperationsParams) => FormBuilderFormStorageOperations;
|
package/operations/form/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
|
17
17
|
|
|
18
18
|
var _batchWrite = require("@webiny/db-dynamodb/utils/batchWrite");
|
|
19
19
|
|
|
20
|
-
var _configurations =
|
|
20
|
+
var _configurations = require("../../configurations");
|
|
21
21
|
|
|
22
22
|
var _filter = require("@webiny/db-dynamodb/utils/filter");
|
|
23
23
|
|
|
@@ -31,9 +31,9 @@ var _elasticsearchBody = require("./elasticsearchBody");
|
|
|
31
31
|
|
|
32
32
|
var _cursors = require("@webiny/api-elasticsearch/cursors");
|
|
33
33
|
|
|
34
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
34
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
35
35
|
|
|
36
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
36
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
37
37
|
|
|
38
38
|
const getESDataForLatestRevision = form => ({
|
|
39
39
|
__type: (0, _elasticsearchBody.createFormElasticType)(),
|
|
@@ -136,8 +136,9 @@ const createFormStorageOperations = params => {
|
|
|
136
136
|
try {
|
|
137
137
|
const {
|
|
138
138
|
index
|
|
139
|
-
} = _configurations.
|
|
140
|
-
tenant: form.tenant
|
|
139
|
+
} = _configurations.configurations.es({
|
|
140
|
+
tenant: form.tenant,
|
|
141
|
+
locale: form.locale
|
|
141
142
|
});
|
|
142
143
|
|
|
143
144
|
await esEntity.put(_objectSpread({
|
|
@@ -193,8 +194,9 @@ const createFormStorageOperations = params => {
|
|
|
193
194
|
try {
|
|
194
195
|
const {
|
|
195
196
|
index
|
|
196
|
-
} = _configurations.
|
|
197
|
-
tenant: form.tenant
|
|
197
|
+
} = _configurations.configurations.es({
|
|
198
|
+
tenant: form.tenant,
|
|
199
|
+
locale: form.locale
|
|
198
200
|
});
|
|
199
201
|
|
|
200
202
|
await esEntity.put(_objectSpread({
|
|
@@ -277,8 +279,9 @@ const createFormStorageOperations = params => {
|
|
|
277
279
|
try {
|
|
278
280
|
const {
|
|
279
281
|
index
|
|
280
|
-
} = _configurations.
|
|
281
|
-
tenant: form.tenant
|
|
282
|
+
} = _configurations.configurations.es({
|
|
283
|
+
tenant: form.tenant,
|
|
284
|
+
locale: form.locale
|
|
282
285
|
});
|
|
283
286
|
|
|
284
287
|
await esEntity.put(_objectSpread({
|
|
@@ -372,8 +375,9 @@ const createFormStorageOperations = params => {
|
|
|
372
375
|
after: (0, _cursors.decodeCursor)(after)
|
|
373
376
|
});
|
|
374
377
|
|
|
375
|
-
const esConfig = _configurations.
|
|
376
|
-
tenant: where.tenant
|
|
378
|
+
const esConfig = _configurations.configurations.es({
|
|
379
|
+
tenant: where.tenant,
|
|
380
|
+
locale: where.locale
|
|
377
381
|
});
|
|
378
382
|
|
|
379
383
|
const query = _objectSpread(_objectSpread({}, esConfig), {}, {
|
|
@@ -413,7 +417,7 @@ const createFormStorageOperations = params => {
|
|
|
413
417
|
const meta = {
|
|
414
418
|
hasMoreItems,
|
|
415
419
|
totalCount: total.value,
|
|
416
|
-
cursor: items.length > 0 ? (0, _cursors.encodeCursor)(hits[items.length - 1].sort) : null
|
|
420
|
+
cursor: items.length > 0 ? (0, _cursors.encodeCursor)(hits[items.length - 1].sort) || null : null
|
|
417
421
|
};
|
|
418
422
|
return {
|
|
419
423
|
items,
|
|
@@ -466,7 +470,7 @@ const createFormStorageOperations = params => {
|
|
|
466
470
|
fields: formDynamoDbFields
|
|
467
471
|
});
|
|
468
472
|
|
|
469
|
-
if (
|
|
473
|
+
if (!sort || sort.length === 0) {
|
|
470
474
|
return filteredItems;
|
|
471
475
|
}
|
|
472
476
|
|
|
@@ -580,7 +584,7 @@ const createFormStorageOperations = params => {
|
|
|
580
584
|
})));
|
|
581
585
|
} else {
|
|
582
586
|
items.push(entity.deleteBatch({
|
|
583
|
-
PK: createFormPartitionKey(
|
|
587
|
+
PK: createFormPartitionKey(form),
|
|
584
588
|
SK: createLatestPublishedSortKey()
|
|
585
589
|
}));
|
|
586
590
|
}
|
|
@@ -590,15 +594,16 @@ const createFormStorageOperations = params => {
|
|
|
590
594
|
*/
|
|
591
595
|
|
|
592
596
|
|
|
593
|
-
if (isLatest) {
|
|
597
|
+
if (isLatest && previous) {
|
|
594
598
|
items.push(entity.putBatch(_objectSpread(_objectSpread(_objectSpread({}, previous), latestKeys), {}, {
|
|
595
599
|
TYPE: createFormLatestType()
|
|
596
600
|
})));
|
|
597
601
|
|
|
598
602
|
const {
|
|
599
603
|
index
|
|
600
|
-
} = _configurations.
|
|
601
|
-
tenant: previous.tenant
|
|
604
|
+
} = _configurations.configurations.es({
|
|
605
|
+
tenant: previous.tenant,
|
|
606
|
+
locale: previous.locale
|
|
602
607
|
});
|
|
603
608
|
|
|
604
609
|
esDataItem = _objectSpread(_objectSpread({
|
|
@@ -728,8 +733,9 @@ const createFormStorageOperations = params => {
|
|
|
728
733
|
|
|
729
734
|
const {
|
|
730
735
|
index
|
|
731
|
-
} = _configurations.
|
|
732
|
-
tenant: form.tenant
|
|
736
|
+
} = _configurations.configurations.es({
|
|
737
|
+
tenant: form.tenant,
|
|
738
|
+
locale: form.locale
|
|
733
739
|
});
|
|
734
740
|
|
|
735
741
|
const esData = getESDataForLatestRevision(form);
|
|
@@ -862,8 +868,9 @@ const createFormStorageOperations = params => {
|
|
|
862
868
|
|
|
863
869
|
const {
|
|
864
870
|
index
|
|
865
|
-
} = _configurations.
|
|
866
|
-
tenant: form.tenant
|
|
871
|
+
} = _configurations.configurations.es({
|
|
872
|
+
tenant: form.tenant,
|
|
873
|
+
locale: form.locale
|
|
867
874
|
});
|
|
868
875
|
|
|
869
876
|
try {
|
|
@@ -0,0 +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,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IACH;;IACD,MAAM;MAAEqD;IAAF,IAAYC,8BAAA,CAAeC,EAAf,CAAkB;MAChCxC,MAAM,EAAEf,IAAI,CAACe,MADmB;MAEhCC,MAAM,EAAEhB,IAAI,CAACgB;IAFmB,CAAlB,CAAlB;;IAIA,IAAI;MACA,MAAMM,QAAQ,CAACkC,GAAT,iCACCZ,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,7 +1,7 @@
|
|
|
1
1
|
import { Entity, Table } from "dynamodb-toolbox";
|
|
2
2
|
import { FormBuilderSettingsStorageOperations } from "../../types";
|
|
3
|
-
export interface
|
|
3
|
+
export interface CreateSettingsStorageOperationsParams {
|
|
4
4
|
entity: Entity<any>;
|
|
5
5
|
table: Table;
|
|
6
6
|
}
|
|
7
|
-
export declare const createSettingsStorageOperations: (params:
|
|
7
|
+
export declare const createSettingsStorageOperations: (params: CreateSettingsStorageOperationsParams) => FormBuilderSettingsStorageOperations;
|
|
@@ -13,9 +13,9 @@ var _error = _interopRequireDefault(require("@webiny/error"));
|
|
|
13
13
|
|
|
14
14
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
15
15
|
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
17
|
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
19
|
|
|
20
20
|
const createSettingsStorageOperations = params => {
|
|
21
21
|
const {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createSettingsStorageOperations","params","entity","createSettingsPartitionKey","tenant","locale","createSettingsSortKey","createKeys","PK","SK","createSettings","settings","keys","put","ex","WebinyError","message","code","getSettings","result","get","Item","cleanupItem","updateSettings","original","deleteSettings","delete"],"sources":["index.ts"],"sourcesContent":["import {\n FormBuilderStorageOperationsCreateSettingsParams,\n FormBuilderStorageOperationsDeleteSettingsParams,\n FormBuilderStorageOperationsGetSettingsParams,\n FormBuilderStorageOperationsUpdateSettingsParams,\n Settings\n} from \"@webiny/api-form-builder/types\";\nimport { Entity, Table } from \"dynamodb-toolbox\";\nimport {\n FormBuilderSettingsStorageOperations,\n FormBuilderSettingsStorageOperationsCreatePartitionKeyParams\n} from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\nexport interface CreateSettingsStorageOperationsParams {\n entity: Entity<any>;\n table: Table;\n}\n\nexport const createSettingsStorageOperations = (\n params: CreateSettingsStorageOperationsParams\n): FormBuilderSettingsStorageOperations => {\n const { entity } = params;\n\n const createSettingsPartitionKey = ({\n tenant,\n locale\n }: FormBuilderSettingsStorageOperationsCreatePartitionKeyParams): string => {\n return `T#${tenant}#L#${locale}#FB#SETTINGS`;\n };\n\n const createSettingsSortKey = (): string => {\n return \"default\";\n };\n\n const createKeys = (params: FormBuilderSettingsStorageOperationsCreatePartitionKeyParams) => {\n return {\n PK: createSettingsPartitionKey(params),\n SK: createSettingsSortKey()\n };\n };\n\n const createSettings = async (\n params: FormBuilderStorageOperationsCreateSettingsParams\n ): Promise<Settings> => {\n const { settings } = params;\n const keys = createKeys(settings);\n\n try {\n await entity.put({\n ...settings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create the settings record by given keys.\",\n ex.code || \"CREATE_SETTINGS_ERROR\",\n {\n keys,\n settings\n }\n );\n }\n };\n\n const getSettings = async (\n params: FormBuilderStorageOperationsGetSettingsParams\n ): Promise<Settings | null> => {\n const keys = createKeys(params);\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 the settings record by given keys.\",\n ex.code || \"LOAD_SETTINGS_ERROR\",\n {\n keys\n }\n );\n }\n };\n\n const updateSettings = async (\n params: FormBuilderStorageOperationsUpdateSettingsParams\n ): Promise<Settings> => {\n const { settings, original } = params;\n const keys = createKeys(settings);\n\n try {\n await entity.put({\n ...settings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update the settings record by given keys.\",\n ex.code || \"UPDATE_SETTINGS_ERROR\",\n {\n keys,\n original,\n settings\n }\n );\n }\n };\n\n const deleteSettings = async (\n params: FormBuilderStorageOperationsDeleteSettingsParams\n ): Promise<void> => {\n const { settings } = params;\n const keys = createKeys(settings);\n try {\n await entity.delete();\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete the settings record by given keys.\",\n ex.code || \"DELETE_SETTINGS_ERROR\",\n {\n keys\n }\n );\n }\n };\n\n return {\n createSettings,\n getSettings,\n updateSettings,\n deleteSettings,\n createSettingsPartitionKey,\n createSettingsSortKey\n };\n};\n"],"mappings":";;;;;;;;;;;AAYA;;AACA;;;;;;AAOO,MAAMA,+BAA+B,GACxCC,MAD2C,IAEJ;EACvC,MAAM;IAAEC;EAAF,IAAaD,MAAnB;;EAEA,MAAME,0BAA0B,GAAG,CAAC;IAChCC,MADgC;IAEhCC;EAFgC,CAAD,KAGyC;IACxE,OAAQ,KAAID,MAAO,MAAKC,MAAO,cAA/B;EACH,CALD;;EAOA,MAAMC,qBAAqB,GAAG,MAAc;IACxC,OAAO,SAAP;EACH,CAFD;;EAIA,MAAMC,UAAU,GAAIN,MAAD,IAA0E;IACzF,OAAO;MACHO,EAAE,EAAEL,0BAA0B,CAACF,MAAD,CAD3B;MAEHQ,EAAE,EAAEH,qBAAqB;IAFtB,CAAP;EAIH,CALD;;EAOA,MAAMI,cAAc,GAAG,MACnBT,MADmB,IAEC;IACpB,MAAM;MAAEU;IAAF,IAAeV,MAArB;IACA,MAAMW,IAAI,GAAGL,UAAU,CAACI,QAAD,CAAvB;;IAEA,IAAI;MACA,MAAMT,MAAM,CAACW,GAAP,iCACCF,QADD,GAECC,IAFD,EAAN;MAIA,OAAOD,QAAP;IACH,CAND,CAME,OAAOG,EAAP,EAAW;MACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,qDADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,uBAFT,EAGF;QACIL,IADJ;QAEID;MAFJ,CAHE,CAAN;IAQH;EACJ,CAtBD;;EAwBA,MAAMO,WAAW,GAAG,MAChBjB,MADgB,IAEW;IAC3B,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AE,CAACG,IAAH,IAAW,uBAFT,EAGF;QACIL;MADJ,CAHE,CAAN;IAOH;EACJ,CAhBD;;EAkBA,OAAO;IACHF,cADG;IAEHQ,WAFG;IAGHK,cAHG;IAIHE,cAJG;IAKHtB,0BALG;IAMHG;EANG,CAAP;AAQH,CAxHM"}
|
|
@@ -27,9 +27,9 @@ var _SubmissionElasticsearchQueryModifierPlugin = require("../../plugins/Submiss
|
|
|
27
27
|
|
|
28
28
|
var _where = require("@webiny/api-elasticsearch/where");
|
|
29
29
|
|
|
30
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
30
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
31
31
|
|
|
32
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
32
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
33
|
|
|
34
34
|
const createInitialQueryValue = () => {
|
|
35
35
|
return {
|
|
@@ -66,6 +66,10 @@ const createElasticsearchQuery = params => {
|
|
|
66
66
|
*/
|
|
67
67
|
|
|
68
68
|
const operatorPlugins = plugins.byType(_ElasticsearchQueryBuilderOperatorPlugin.ElasticsearchQueryBuilderOperatorPlugin.type).reduce((acc, plugin) => {
|
|
69
|
+
if (plugin.isLocaleSupported(initialWhere.locale) === false) {
|
|
70
|
+
return acc;
|
|
71
|
+
}
|
|
72
|
+
|
|
69
73
|
acc[plugin.getOperator()] = plugin;
|
|
70
74
|
return acc;
|
|
71
75
|
}, {});
|
|
@@ -81,7 +85,7 @@ const createElasticsearchQuery = params => {
|
|
|
81
85
|
|
|
82
86
|
const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === "true";
|
|
83
87
|
|
|
84
|
-
if (sharedIndex) {
|
|
88
|
+
if (sharedIndex && where.tenant) {
|
|
85
89
|
query.must.push({
|
|
86
90
|
term: {
|
|
87
91
|
"tenant.keyword": where.tenant
|