@webiny/api-form-builder-so-ddb-es 5.33.5 → 5.34.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configurations.js +1 -1
- package/definitions/elasticsearch.js +3 -7
- package/definitions/elasticsearch.js.map +1 -1
- package/definitions/form.js +3 -7
- package/definitions/form.js.map +1 -1
- package/definitions/settings.js +3 -7
- package/definitions/settings.js.map +1 -1
- package/definitions/submission.js +3 -7
- package/definitions/submission.js.map +1 -1
- package/definitions/system.js +3 -7
- package/definitions/system.js.map +1 -1
- package/elasticsearch/createElasticsearchIndex.js +1 -1
- package/index.js +4 -8
- package/index.js.map +1 -1
- package/operations/form/elasticsearchBody.js +5 -11
- package/operations/form/elasticsearchBody.js.map +1 -1
- package/operations/form/index.js +23 -29
- package/operations/form/index.js.map +1 -1
- package/operations/settings/index.js +4 -8
- package/operations/settings/index.js.map +1 -1
- package/operations/submission/elasticsearchBody.js +5 -11
- package/operations/submission/elasticsearchBody.js.map +1 -1
- package/operations/submission/index.js +9 -14
- package/operations/submission/index.js.map +1 -1
- package/operations/system/index.js +4 -8
- package/operations/system/index.js.map +1 -1
- package/package.json +20 -20
- package/plugins/FormDynamoDbFieldPlugin.js +1 -1
- package/plugins/FormElasticsearchBodyModifierPlugin.js +1 -1
- package/plugins/FormElasticsearchFieldPlugin.js +1 -1
- package/plugins/FormElasticsearchIndexPlugin.js +1 -1
- package/plugins/FormElasticsearchQueryModifierPlugin.js +1 -1
- package/plugins/FormElasticsearchSortModifierPlugin.js +1 -1
- package/plugins/SubmissionElasticsearchBodyModifierPlugin.js +1 -1
- package/plugins/SubmissionElasticsearchFieldPlugin.js +1 -1
- package/plugins/SubmissionElasticsearchQueryModifierPlugin.js +1 -1
- package/plugins/SubmissionElasticsearchSortModifierPlugin.js +1 -1
package/configurations.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.createElasticsearchEntity = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
13
13
|
|
|
14
|
-
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; }
|
|
15
|
-
|
|
16
|
-
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; }
|
|
17
|
-
|
|
18
14
|
const createElasticsearchEntity = params => {
|
|
19
15
|
const {
|
|
20
16
|
table,
|
|
@@ -24,7 +20,7 @@ const createElasticsearchEntity = params => {
|
|
|
24
20
|
return new _dynamodbToolbox.Entity({
|
|
25
21
|
name: entityName,
|
|
26
22
|
table,
|
|
27
|
-
attributes:
|
|
23
|
+
attributes: (0, _objectSpread2.default)({
|
|
28
24
|
PK: {
|
|
29
25
|
partitionKey: true
|
|
30
26
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createElasticsearchEntity","params","table","entityName","attributes","Entity","name","PK","partitionKey","SK","sortKey","index","type","data","TYPE"],"sources":["elasticsearch.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createElasticsearchEntity = (params: Params) => {\n const { table, entityName, attributes } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n index: {\n type: \"string\"\n },\n data: {\n type: \"map\"\n },\n TYPE: {\n type: \"string\"\n },\n\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"names":["createElasticsearchEntity","params","table","entityName","attributes","Entity","name","PK","partitionKey","SK","sortKey","index","type","data","TYPE"],"sources":["elasticsearch.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createElasticsearchEntity = (params: Params) => {\n const { table, entityName, attributes } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n index: {\n type: \"string\"\n },\n data: {\n type: \"map\"\n },\n TYPE: {\n type: \"string\"\n },\n\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AASO,MAAMA,yBAAyB,GAAIC,MAAD,IAAoB;EACzD,MAAM;IAAEC,KAAF;IAASC,UAAT;IAAqBC;EAArB,IAAoCH,MAA1C;EACA,OAAO,IAAII,uBAAJ,CAAW;IACdC,IAAI,EAAEH,UADQ;IAEdD,KAFc;IAGdE,UAAU;MACNG,EAAE,EAAE;QACAC,YAAY,EAAE;MADd,CADE;MAINC,EAAE,EAAE;QACAC,OAAO,EAAE;MADT,CAJE;MAONC,KAAK,EAAE;QACHC,IAAI,EAAE;MADH,CAPD;MAUNC,IAAI,EAAE;QACFD,IAAI,EAAE;MADJ,CAVA;MAaNE,IAAI,EAAE;QACFF,IAAI,EAAE;MADJ;IAbA,GAiBFR,UAAU,IAAI,EAjBZ;EAHI,CAAX,CAAP;AAuBH,CAzBM"}
|
package/definitions/form.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.createFormEntity = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
13
13
|
|
|
14
|
-
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; }
|
|
15
|
-
|
|
16
|
-
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; }
|
|
17
|
-
|
|
18
14
|
const createFormEntity = params => {
|
|
19
15
|
const {
|
|
20
16
|
table,
|
|
@@ -24,7 +20,7 @@ const createFormEntity = params => {
|
|
|
24
20
|
return new _dynamodbToolbox.Entity({
|
|
25
21
|
table,
|
|
26
22
|
name: entityName,
|
|
27
|
-
attributes:
|
|
23
|
+
attributes: (0, _objectSpread2.default)({
|
|
28
24
|
PK: {
|
|
29
25
|
partitionKey: true
|
|
30
26
|
},
|
package/definitions/form.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createFormEntity","params","table","entityName","attributes","Entity","name","PK","partitionKey","SK","sortKey","TYPE","type","id","formId","tenant","locale","createdBy","ownedBy","savedOn","createdOn","slug","version","locked","published","publishedOn","status","fields","layout","stats","settings","triggers","webinyVersion"],"sources":["form.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createFormEntity = (params: Params): Entity<any> => {\n const { table, entityName, attributes } = params;\n return new Entity({\n table,\n name: entityName,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n TYPE: {\n type: \"string\"\n },\n id: {\n type: \"string\"\n },\n formId: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n createdBy: {\n type: \"map\"\n },\n ownedBy: {\n type: \"map\"\n },\n savedOn: {\n type: \"string\"\n },\n createdOn: {\n type: \"string\"\n },\n name: {\n type: \"string\"\n },\n slug: {\n type: \"string\"\n },\n version: {\n type: \"number\"\n },\n locked: {\n type: \"boolean\"\n },\n published: {\n type: \"boolean\"\n },\n publishedOn: {\n type: \"string\"\n },\n status: {\n type: \"string\"\n },\n fields: {\n type: \"list\"\n },\n layout: {\n type: \"list\"\n },\n stats: {\n type: \"map\"\n },\n settings: {\n type: \"map\"\n },\n triggers: {\n type: \"map\"\n },\n webinyVersion: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"names":["createFormEntity","params","table","entityName","attributes","Entity","name","PK","partitionKey","SK","sortKey","TYPE","type","id","formId","tenant","locale","createdBy","ownedBy","savedOn","createdOn","slug","version","locked","published","publishedOn","status","fields","layout","stats","settings","triggers","webinyVersion"],"sources":["form.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createFormEntity = (params: Params): Entity<any> => {\n const { table, entityName, attributes } = params;\n return new Entity({\n table,\n name: entityName,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n TYPE: {\n type: \"string\"\n },\n id: {\n type: \"string\"\n },\n formId: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n createdBy: {\n type: \"map\"\n },\n ownedBy: {\n type: \"map\"\n },\n savedOn: {\n type: \"string\"\n },\n createdOn: {\n type: \"string\"\n },\n name: {\n type: \"string\"\n },\n slug: {\n type: \"string\"\n },\n version: {\n type: \"number\"\n },\n locked: {\n type: \"boolean\"\n },\n published: {\n type: \"boolean\"\n },\n publishedOn: {\n type: \"string\"\n },\n status: {\n type: \"string\"\n },\n fields: {\n type: \"list\"\n },\n layout: {\n type: \"list\"\n },\n stats: {\n type: \"map\"\n },\n settings: {\n type: \"map\"\n },\n triggers: {\n type: \"map\"\n },\n webinyVersion: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AASO,MAAMA,gBAAgB,GAAIC,MAAD,IAAiC;EAC7D,MAAM;IAAEC,KAAF;IAASC,UAAT;IAAqBC;EAArB,IAAoCH,MAA1C;EACA,OAAO,IAAII,uBAAJ,CAAW;IACdH,KADc;IAEdI,IAAI,EAAEH,UAFQ;IAGdC,UAAU;MACNG,EAAE,EAAE;QACAC,YAAY,EAAE;MADd,CADE;MAINC,EAAE,EAAE;QACAC,OAAO,EAAE;MADT,CAJE;MAONC,IAAI,EAAE;QACFC,IAAI,EAAE;MADJ,CAPA;M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ireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.createSettingsEntity = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
13
13
|
|
|
14
|
-
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; }
|
|
15
|
-
|
|
16
|
-
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; }
|
|
17
|
-
|
|
18
14
|
const createSettingsEntity = params => {
|
|
19
15
|
const {
|
|
20
16
|
entityName,
|
|
@@ -24,7 +20,7 @@ const createSettingsEntity = params => {
|
|
|
24
20
|
return new _dynamodbToolbox.Entity({
|
|
25
21
|
name: entityName,
|
|
26
22
|
table,
|
|
27
|
-
attributes:
|
|
23
|
+
attributes: (0, _objectSpread2.default)({
|
|
28
24
|
PK: {
|
|
29
25
|
partitionKey: true
|
|
30
26
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createSettingsEntity","params","entityName","attributes","table","Entity","name","PK","partitionKey","SK","sortKey","TYPE","type","reCaptcha","domain","tenant","locale"],"sources":["settings.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createSettingsEntity = (params: Params): Entity<any> => {\n const { entityName, attributes, table } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n TYPE: {\n type: \"string\"\n },\n reCaptcha: {\n type: \"map\"\n },\n domain: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"names":["createSettingsEntity","params","entityName","attributes","table","Entity","name","PK","partitionKey","SK","sortKey","TYPE","type","reCaptcha","domain","tenant","locale"],"sources":["settings.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createSettingsEntity = (params: Params): Entity<any> => {\n const { entityName, attributes, table } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n TYPE: {\n type: \"string\"\n },\n reCaptcha: {\n type: \"map\"\n },\n domain: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AASO,MAAMA,oBAAoB,GAAIC,MAAD,IAAiC;EACjE,MAAM;IAAEC,UAAF;IAAcC,UAAd;IAA0BC;EAA1B,IAAoCH,MAA1C;EACA,OAAO,IAAII,uBAAJ,CAAW;IACdC,IAAI,EAAEJ,UADQ;IAEdE,KAFc;IAGdD,UAAU;MACNI,EAAE,EAAE;QACAC,YAAY,EAAE;MADd,CADE;MAINC,EAAE,EAAE;QACAC,OAAO,EAAE;MADT,CAJE;MAONC,IAAI,EAAE;QACFC,IAAI,EAAE;MADJ,CAPA;MAUNC,SAAS,EAAE;QACPD,IAAI,EAAE;MADC,CAVL;MAaNE,MAAM,EAAE;QACJF,IAAI,EAAE;MADF,CAbF;MAgBNG,MAAM,EAAE;QACJH,IAAI,EAAE;MADF,CAhBF;MAmBNI,MAAM,EAAE;QACJJ,IAAI,EAAE;MADF;IAnBF,GAsBFT,UAAU,IAAI,EAtBZ;EAHI,CAAX,CAAP;AA4BH,CA9BM"}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.createSubmissionEntity = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
13
13
|
|
|
14
|
-
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; }
|
|
15
|
-
|
|
16
|
-
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; }
|
|
17
|
-
|
|
18
14
|
const createSubmissionEntity = params => {
|
|
19
15
|
const {
|
|
20
16
|
table,
|
|
@@ -24,7 +20,7 @@ const createSubmissionEntity = params => {
|
|
|
24
20
|
return new _dynamodbToolbox.Entity({
|
|
25
21
|
table,
|
|
26
22
|
name: entityName,
|
|
27
|
-
attributes:
|
|
23
|
+
attributes: (0, _objectSpread2.default)({
|
|
28
24
|
PK: {
|
|
29
25
|
partitionKey: true
|
|
30
26
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createSubmissionEntity","params","table","entityName","attributes","Entity","name","PK","partitionKey","SK","sortKey","id","type","TYPE","data","meta","form","logs","createdOn","savedOn","ownedBy","tenant","locale","webinyVersion"],"sources":["submission.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createSubmissionEntity = (params: Params): Entity<any> => {\n const { table, entityName, attributes } = params;\n return new Entity({\n table,\n name: entityName,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n id: {\n type: \"string\"\n },\n TYPE: {\n type: \"string\"\n },\n data: {\n type: \"map\"\n },\n meta: {\n type: \"map\"\n },\n form: {\n type: \"map\"\n },\n logs: {\n type: \"list\"\n },\n createdOn: {\n type: \"string\"\n },\n savedOn: {\n type: \"string\"\n },\n ownedBy: {\n type: \"map\"\n },\n tenant: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n webinyVersion: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"names":["createSubmissionEntity","params","table","entityName","attributes","Entity","name","PK","partitionKey","SK","sortKey","id","type","TYPE","data","meta","form","logs","createdOn","savedOn","ownedBy","tenant","locale","webinyVersion"],"sources":["submission.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createSubmissionEntity = (params: Params): Entity<any> => {\n const { table, entityName, attributes } = params;\n return new Entity({\n table,\n name: entityName,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n id: {\n type: \"string\"\n },\n TYPE: {\n type: \"string\"\n },\n data: {\n type: \"map\"\n },\n meta: {\n type: \"map\"\n },\n form: {\n type: \"map\"\n },\n logs: {\n type: \"list\"\n },\n createdOn: {\n type: \"string\"\n },\n savedOn: {\n type: \"string\"\n },\n ownedBy: {\n type: \"map\"\n },\n tenant: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n webinyVersion: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AASO,MAAMA,sBAAsB,GAAIC,MAAD,IAAiC;EACnE,MAAM;IAAEC,KAAF;IAASC,UAAT;IAAqBC;EAArB,IAAoCH,MAA1C;EACA,OAAO,IAAII,uBAAJ,CAAW;IACdH,KADc;IAEdI,IAAI,EAAEH,UAFQ;IAGdC,UAAU;MACNG,EAAE,EAAE;QACAC,YAAY,EAAE;MADd,CADE;MAINC,EAAE,EAAE;QACAC,OAAO,EAAE;MADT,CAJE;MAONC,EAAE,EAAE;QACAC,IAAI,EAAE;MADN,CAPE;MAUNC,IAAI,EAAE;QACFD,IAAI,EAAE;MADJ,CAVA;MAaNE,IAAI,EAAE;QACFF,IAAI,EAAE;MADJ,CAbA;MAgBNG,IAAI,EAAE;QACFH,IAAI,EAAE;MADJ,CAhBA;MAmBNI,IAAI,EAAE;QACFJ,IAAI,EAAE;MADJ,CAnBA;MAsBNK,IAAI,EAAE;QACFL,IAAI,EAAE;MADJ,CAtBA;MAyBNM,SAAS,EAAE;QACPN,IAAI,EAAE;MADC,CAzBL;MA4BNO,OAAO,EAAE;QACLP,IAAI,EAAE;MADD,CA5BH;MA+BNQ,OAAO,EAAE;QACLR,IAAI,EAAE;MADD,CA/BH;MAkCNS,MAAM,EAAE;QACJT,IAAI,EAAE;MADF,CAlCF;MAqCNU,MAAM,EAAE;QACJV,IAAI,EAAE;MADF,CArCF;MAwCNW,aAAa,EAAE;QACXX,IAAI,EAAE;MADK;IAxCT,GA2CFR,UAAU,IAAI,EA3CZ;EAHI,CAAX,CAAP;AAiDH,CAnDM"}
|
package/definitions/system.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.createSystemEntity = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
13
13
|
|
|
14
|
-
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; }
|
|
15
|
-
|
|
16
|
-
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; }
|
|
17
|
-
|
|
18
14
|
const createSystemEntity = params => {
|
|
19
15
|
const {
|
|
20
16
|
entityName,
|
|
@@ -24,7 +20,7 @@ const createSystemEntity = params => {
|
|
|
24
20
|
return new _dynamodbToolbox.Entity({
|
|
25
21
|
name: entityName,
|
|
26
22
|
table,
|
|
27
|
-
attributes:
|
|
23
|
+
attributes: (0, _objectSpread2.default)({
|
|
28
24
|
PK: {
|
|
29
25
|
partitionKey: true
|
|
30
26
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createSystemEntity","params","entityName","attributes","table","Entity","name","PK","partitionKey","SK","sortKey","version","type","tenant"],"sources":["system.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createSystemEntity = (params: Params): Entity<any> => {\n const { entityName, attributes, table } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n version: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"names":["createSystemEntity","params","entityName","attributes","table","Entity","name","PK","partitionKey","SK","sortKey","version","type","tenant"],"sources":["system.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createSystemEntity = (params: Params): Entity<any> => {\n const { entityName, attributes, table } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n version: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AASO,MAAMA,kBAAkB,GAAIC,MAAD,IAAiC;EAC/D,MAAM;IAAEC,UAAF;IAAcC,UAAd;IAA0BC;EAA1B,IAAoCH,MAA1C;EACA,OAAO,IAAII,uBAAJ,CAAW;IACdC,IAAI,EAAEJ,UADQ;IAEdE,KAFc;IAGdD,UAAU;MACNI,EAAE,EAAE;QACAC,YAAY,EAAE;MADd,CADE;MAINC,EAAE,EAAE;QACAC,OAAO,EAAE;MADT,CAJE;MAONC,OAAO,EAAE;QACLC,IAAI,EAAE;MADD,CAPH;MAUNC,MAAM,EAAE;QACJD,IAAI,EAAE;MADF;IAVF,GAaFT,UAAU,IAAI,EAbZ;EAHI,CAAX,CAAP;AAmBH,CArBM"}
|
package/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.createFormBuilderStorageOperations = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _filters = _interopRequireDefault(require("@webiny/db-dynamodb/plugins/filters"));
|
|
13
13
|
|
|
@@ -49,10 +49,6 @@ var _indices = require("./elasticsearch/indices");
|
|
|
49
49
|
|
|
50
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); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
53
|
-
|
|
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
|
-
|
|
56
52
|
const reservedFields = ["PK", "SK", "index", "data", "TYPE", "__type", "GSI1_PK", "GSI1_SK"];
|
|
57
53
|
|
|
58
54
|
const isReserved = name => {
|
|
@@ -153,9 +149,9 @@ const createFormBuilderStorageOperations = params => {
|
|
|
153
149
|
attributes: attributes ? attributes[_types.ENTITIES.ES_SUBMISSION] : {}
|
|
154
150
|
})
|
|
155
151
|
};
|
|
156
|
-
return
|
|
152
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
157
153
|
init: async context => {
|
|
158
|
-
context.i18n.locales.
|
|
154
|
+
context.i18n.locales.onLocaleBeforeCreate.subscribe(async ({
|
|
159
155
|
locale,
|
|
160
156
|
tenant
|
|
161
157
|
}) => {
|
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","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\";\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,MAAM,CAACC,MAAP,CAAcV,UAAd,EAA0BW,OAA1B,CAAkCC,KAAK,IAAI;MACvCH,MAAM,CAACI,IAAP,CAAYD,KAAZ,EAAmBD,OAAnB,CAA2BjB,UAA3B;IACH,CAFD;EAGH;;EAED,MAAMa,OAAO,GAAG,IAAIO,yBAAJ,CAAqB;EACjC;AACR;AACA;EACQN,WAAW,IAAI,EAJkB;EAKjC;AACR;AACA;EACQ,IAAAO,6BAAA,GARiC;EASjC;A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Q,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":";;;;;;;;;;;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,C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1C,CAAoD,OAAO;QAAEC,MAAF;QAAUC;MAAV,CAAP,KAA8B;QAC9E,MAAM,IAAAC,kDAAA,EAAyB;UAC3B5C,aAD2B;UAE3BC,OAF2B;UAG3B0C,MAH2B;UAI3BD,MAAM,EAAEA,MAAM,CAACG;QAJY,CAAzB,CAAN;MAMH,CAPD;IAQH,CAVL;IAWIC,OAAO,EAAE,IAXb;IAYIC,QAAQ,EAAE,MAAMpD,KAZpB;IAaIqD,UAAU,EAAE,MAAMnD,OAbtB;IAcIoD,WAAW,EAAE,MAAMjC;EAdvB,GAeO,IAAAkC,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,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.createFormElasticType = exports.createElasticsearchBody = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
13
13
|
|
|
@@ -19,10 +19,6 @@ var _FormElasticsearchBodyModifierPlugin = require("../../plugins/FormElasticsea
|
|
|
19
19
|
|
|
20
20
|
var _FormElasticsearchQueryModifierPlugin = require("../../plugins/FormElasticsearchQueryModifierPlugin");
|
|
21
21
|
|
|
22
|
-
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; }
|
|
23
|
-
|
|
24
|
-
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; }
|
|
25
|
-
|
|
26
22
|
const createFormElasticType = () => {
|
|
27
23
|
return "fb.form";
|
|
28
24
|
};
|
|
@@ -58,8 +54,7 @@ const createElasticsearchQuery = params => {
|
|
|
58
54
|
*/
|
|
59
55
|
|
|
60
56
|
const operatorPlugins = (0, _apiElasticsearch.getElasticsearchOperatorPluginsByLocale)(plugins, initialWhere.locale);
|
|
61
|
-
|
|
62
|
-
const where = _objectSpread({}, initialWhere);
|
|
57
|
+
const where = (0, _objectSpread2.default)({}, initialWhere);
|
|
63
58
|
/**
|
|
64
59
|
* !!! IMPORTANT !!! There are few specific cases where we hardcode the query conditions.
|
|
65
60
|
*
|
|
@@ -67,7 +62,6 @@ const createElasticsearchQuery = params => {
|
|
|
67
62
|
* No need for the tenant filtering otherwise as each index is for single tenant.
|
|
68
63
|
*/
|
|
69
64
|
|
|
70
|
-
|
|
71
65
|
const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === "true";
|
|
72
66
|
|
|
73
67
|
if (sharedIndex && where.tenant) {
|
|
@@ -120,7 +114,7 @@ const createElasticsearchBody = params => {
|
|
|
120
114
|
return acc;
|
|
121
115
|
}, {});
|
|
122
116
|
const limit = (0, _apiElasticsearch.createLimit)(initialLimit, 100);
|
|
123
|
-
const query = createElasticsearchQuery(
|
|
117
|
+
const query = createElasticsearchQuery((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
124
118
|
fieldPlugins
|
|
125
119
|
}));
|
|
126
120
|
const sort = (0, _apiElasticsearch.createSort)({
|
|
@@ -148,7 +142,7 @@ const createElasticsearchBody = params => {
|
|
|
148
142
|
query: {
|
|
149
143
|
constant_score: {
|
|
150
144
|
filter: {
|
|
151
|
-
bool:
|
|
145
|
+
bool: (0, _objectSpread2.default)({}, query)
|
|
152
146
|
}
|
|
153
147
|
}
|
|
154
148
|
},
|
|
@@ -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 {\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
|
|
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,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