@webiny/api-form-builder-so-ddb-es 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f
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 +16 -7
- package/configurations.js +38 -13
- package/configurations.js.map +1 -0
- package/definitions/elasticsearch.d.ts +47 -5
- package/definitions/elasticsearch.js +8 -16
- package/definitions/elasticsearch.js.map +1 -0
- package/definitions/form.d.ts +6 -4
- package/definitions/form.js +9 -17
- package/definitions/form.js.map +1 -0
- package/definitions/settings.d.ts +6 -4
- package/definitions/settings.js +8 -16
- package/definitions/settings.js.map +1 -0
- package/definitions/submission.d.ts +6 -4
- package/definitions/submission.js +8 -16
- package/definitions/submission.js.map +1 -0
- package/definitions/system.d.ts +6 -4
- package/definitions/system.js +8 -16
- package/definitions/system.js.map +1 -0
- package/definitions/table.d.ts +7 -6
- package/definitions/table.js +7 -6
- package/definitions/table.js.map +1 -0
- package/definitions/tableElasticsearch.d.ts +6 -5
- package/definitions/tableElasticsearch.js +7 -6
- package/definitions/tableElasticsearch.js.map +1 -0
- package/elasticsearch/createElasticsearchIndex.d.ts +10 -0
- package/elasticsearch/createElasticsearchIndex.js +41 -0
- package/elasticsearch/createElasticsearchIndex.js.map +1 -0
- package/elasticsearch/indices/base.d.ts +2 -0
- package/elasticsearch/indices/base.js +13 -0
- package/elasticsearch/indices/base.js.map +1 -0
- package/elasticsearch/indices/index.d.ts +1 -0
- package/elasticsearch/indices/index.js +14 -0
- package/elasticsearch/indices/index.js.map +1 -0
- package/elasticsearch/indices/japanese.d.ts +2 -0
- package/elasticsearch/indices/japanese.js +14 -0
- package/elasticsearch/indices/japanese.js.map +1 -0
- package/index.d.ts +2 -1
- package/index.js +100 -81
- package/index.js.map +1 -0
- package/operations/form/elasticsearchBody.d.ts +4 -4
- package/operations/form/elasticsearchBody.js +19 -63
- package/operations/form/elasticsearchBody.js.map +1 -0
- package/operations/form/elasticsearchFields.js +2 -3
- package/operations/form/elasticsearchFields.js.map +1 -0
- package/operations/form/fields.js +2 -3
- package/operations/form/fields.js.map +1 -0
- package/operations/form/index.d.ts +8 -8
- package/operations/form/index.js +196 -243
- package/operations/form/index.js.map +1 -0
- package/operations/settings/index.d.ts +5 -5
- package/operations/settings/index.js +26 -35
- package/operations/settings/index.js.map +1 -0
- package/operations/submission/elasticsearchBody.d.ts +4 -4
- package/operations/submission/elasticsearchBody.js +22 -61
- package/operations/submission/elasticsearchBody.js.map +1 -0
- package/operations/submission/elasticsearchFields.js +2 -3
- package/operations/submission/elasticsearchFields.js.map +1 -0
- package/operations/submission/index.d.ts +7 -7
- package/operations/submission/index.js +68 -96
- package/operations/submission/index.js.map +1 -0
- package/operations/system/index.d.ts +5 -5
- package/operations/system/index.js +22 -32
- package/operations/system/index.js.map +1 -0
- package/package.json +28 -35
- package/plugins/FormDynamoDbFieldPlugin.js +5 -9
- package/plugins/FormDynamoDbFieldPlugin.js.map +1 -0
- package/plugins/FormElasticsearchBodyModifierPlugin.d.ts +1 -1
- package/plugins/FormElasticsearchBodyModifierPlugin.js +6 -10
- package/plugins/FormElasticsearchBodyModifierPlugin.js.map +1 -0
- package/plugins/FormElasticsearchFieldPlugin.d.ts +1 -1
- package/plugins/FormElasticsearchFieldPlugin.js +6 -10
- package/plugins/FormElasticsearchFieldPlugin.js.map +1 -0
- package/plugins/FormElasticsearchIndexPlugin.d.ts +4 -0
- package/plugins/FormElasticsearchIndexPlugin.js +13 -0
- package/plugins/FormElasticsearchIndexPlugin.js.map +1 -0
- package/plugins/FormElasticsearchQueryModifierPlugin.d.ts +1 -1
- package/plugins/FormElasticsearchQueryModifierPlugin.js +6 -10
- package/plugins/FormElasticsearchQueryModifierPlugin.js.map +1 -0
- package/plugins/FormElasticsearchSortModifierPlugin.d.ts +1 -1
- package/plugins/FormElasticsearchSortModifierPlugin.js +6 -10
- package/plugins/FormElasticsearchSortModifierPlugin.js.map +1 -0
- package/plugins/SubmissionElasticsearchBodyModifierPlugin.d.ts +1 -1
- package/plugins/SubmissionElasticsearchBodyModifierPlugin.js +6 -10
- package/plugins/SubmissionElasticsearchBodyModifierPlugin.js.map +1 -0
- package/plugins/SubmissionElasticsearchFieldPlugin.d.ts +1 -1
- package/plugins/SubmissionElasticsearchFieldPlugin.js +6 -10
- package/plugins/SubmissionElasticsearchFieldPlugin.js.map +1 -0
- package/plugins/SubmissionElasticsearchQueryModifierPlugin.d.ts +1 -1
- package/plugins/SubmissionElasticsearchQueryModifierPlugin.js +6 -10
- package/plugins/SubmissionElasticsearchQueryModifierPlugin.js.map +1 -0
- package/plugins/SubmissionElasticsearchSortModifierPlugin.d.ts +1 -1
- package/plugins/SubmissionElasticsearchSortModifierPlugin.js +6 -10
- package/plugins/SubmissionElasticsearchSortModifierPlugin.js.map +1 -0
- package/plugins/index.d.ts +10 -0
- package/plugins/index.js +117 -0
- package/plugins/index.js.map +1 -0
- package/tasks/createIndexTaskPlugin.d.ts +2 -0
- package/tasks/createIndexTaskPlugin.js +36 -0
- package/tasks/createIndexTaskPlugin.js.map +1 -0
- package/types.d.ts +17 -15
- package/types.js +6 -6
- 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/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ENTITIES","exports"],"sources":["types.ts"],"sourcesContent":["import type {\n FormBuilder,\n FormBuilderContext as BaseFormBuilderContext,\n FormBuilderFormStorageOperations as BaseFormBuilderFormStorageOperations,\n FormBuilderSettingsStorageOperations as BaseFormBuilderSettingsStorageOperations,\n FormBuilderStorageOperations as BaseFormBuilderStorageOperations,\n FormBuilderSubmissionStorageOperations as BaseFormBuilderSubmissionStorageOperations,\n FormBuilderSystemStorageOperations as BaseFormBuilderSystemStorageOperations\n} from \"@webiny/api-form-builder/types\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport type { AttributeDefinition, Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport type { Client } from \"@elastic/elasticsearch\";\nimport type { PluginCollection } from \"@webiny/plugins/types\";\n\nexport type Attributes = Record<string, AttributeDefinition>;\n\nexport enum ENTITIES {\n FORM = \"FormBuilderForm\",\n ES_SUBMISSION = \"FormBuilderSubmissionEs\",\n ES_FORM = \"FormBuilderFormEs\",\n SUBMISSION = \"FormBuilderSubmission\",\n SYSTEM = \"FormBuilderSystem\",\n SETTINGS = \"FormBuilderSettings\"\n}\n\nexport interface FormBuilderStorageOperationsFactoryParams {\n documentClient: DynamoDBDocument;\n elasticsearch: Client;\n table?: string;\n esTable?: string;\n attributes?: Record<ENTITIES, Attributes>;\n plugins?: PluginCollection;\n}\n\nexport interface FormBuilderSystemCreateKeysParams {\n tenant: string;\n}\n\nexport interface FormBuilderSystemStorageOperations extends BaseFormBuilderSystemStorageOperations {\n createSystemPartitionKey: (params: FormBuilderSystemCreateKeysParams) => string;\n createSystemSortKey: () => string;\n}\n\nexport interface FormBuilderFormCreateKeyParams {\n id: string;\n tenant: string;\n locale: string;\n}\n\nexport interface FormBuilderFormStorageOperations extends BaseFormBuilderFormStorageOperations {\n createFormPartitionKey: (params: FormBuilderFormCreateKeyParams) => string;\n}\n\nexport interface FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams {\n tenant: string;\n locale: string;\n formId: string;\n}\n\nexport interface FormBuilderSubmissionStorageOperations\n extends BaseFormBuilderSubmissionStorageOperations {\n createSubmissionPartitionKey: (\n params: FormBuilderSubmissionStorageOperationsCreatePartitionKeyParams\n ) => string;\n createSubmissionSortKey: (id: string) => string;\n}\n\nexport interface FormBuilderSettingsStorageOperationsCreatePartitionKeyParams {\n tenant: string;\n locale: string;\n}\n\nexport interface FormBuilderSettingsStorageOperations\n extends BaseFormBuilderSettingsStorageOperations {\n createSettingsPartitionKey: (\n params: FormBuilderSettingsStorageOperationsCreatePartitionKeyParams\n ) => string;\n createSettingsSortKey: () => string;\n}\n\nexport type Entities = \"form\" | \"esForm\" | \"submission\" | \"esSubmission\" | \"system\" | \"settings\";\n\nexport interface FormBuilderStorageOperations\n extends BaseFormBuilderStorageOperations,\n FormBuilderSettingsStorageOperations,\n FormBuilderSubmissionStorageOperations,\n FormBuilderFormStorageOperations,\n FormBuilderSystemStorageOperations {\n getTable(): Table<string, string, string>;\n getEsTable(): Table<string, string, string>;\n getEntities(): Record<Entities, Entity<any>>;\n}\n\nexport interface FormBuilderStorageOperationsFactory {\n (params: FormBuilderStorageOperationsFactoryParams): FormBuilderStorageOperations;\n}\n\nexport interface FormBuilderContext extends BaseFormBuilderContext {\n formBuilder: FormBuilder & {\n storageOperations: FormBuilderStorageOperations;\n };\n}\n"],"mappings":";;;;;;IAgBYA,QAAQ,GAAAC,OAAA,CAAAD,QAAA,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA","ignoreList":[]}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.createElasticsearchIndex = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _configurations = _interopRequireDefault(require("../../configurations"));
|
|
13
|
-
|
|
14
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (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 = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
17
|
-
|
|
18
|
-
const createElasticsearchIndex = async params => {
|
|
19
|
-
const {
|
|
20
|
-
tenant,
|
|
21
|
-
elasticsearch
|
|
22
|
-
} = params;
|
|
23
|
-
|
|
24
|
-
const esIndex = _configurations.default.es({
|
|
25
|
-
tenant
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const {
|
|
29
|
-
body: exists
|
|
30
|
-
} = await elasticsearch.indices.exists(esIndex);
|
|
31
|
-
|
|
32
|
-
if (exists) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
await elasticsearch.indices.create(_objectSpread(_objectSpread({}, esIndex), {}, {
|
|
37
|
-
body: {
|
|
38
|
-
/**
|
|
39
|
-
* need this part for sorting to work on text fields
|
|
40
|
-
*/
|
|
41
|
-
settings: {
|
|
42
|
-
analysis: {
|
|
43
|
-
analyzer: {
|
|
44
|
-
lowercase_analyzer: {
|
|
45
|
-
type: "custom",
|
|
46
|
-
filter: ["lowercase", "trim"],
|
|
47
|
-
tokenizer: "keyword"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
mappings: {
|
|
53
|
-
properties: {
|
|
54
|
-
property: {
|
|
55
|
-
type: "text",
|
|
56
|
-
fields: {
|
|
57
|
-
keyword: {
|
|
58
|
-
type: "keyword",
|
|
59
|
-
ignore_above: 256
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
analyzer: "lowercase_analyzer"
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}));
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
exports.createElasticsearchIndex = createElasticsearchIndex;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { UpgradePlugin } from "@webiny/api-upgrade/types";
|
|
2
|
-
import { FormBuilderContext } from "@webiny/api-form-builder/types";
|
|
3
|
-
declare const _default: () => UpgradePlugin<FormBuilderContext>;
|
|
4
|
-
/**
|
|
5
|
-
* This upgrade adds:
|
|
6
|
-
* - formId (first part of the id) and webinyVersion to the form records
|
|
7
|
-
*/
|
|
8
|
-
export default _default;
|
package/upgrades/5.16.0/index.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
13
|
-
|
|
14
|
-
var _utils = require("@webiny/utils");
|
|
15
|
-
|
|
16
|
-
var _batchWrite = require("@webiny/db-dynamodb/utils/batchWrite");
|
|
17
|
-
|
|
18
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
19
|
-
|
|
20
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
-
|
|
22
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
23
|
-
|
|
24
|
-
const upgradeForms = async params => {
|
|
25
|
-
const {
|
|
26
|
-
storageOperations,
|
|
27
|
-
tenant,
|
|
28
|
-
locale,
|
|
29
|
-
webinyVersion
|
|
30
|
-
} = params;
|
|
31
|
-
/**
|
|
32
|
-
* We need all of the forms from the database.
|
|
33
|
-
* We are getting them from the Elasticsearch because there is no general PK for the forms.
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
let forms = [];
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
const {
|
|
40
|
-
items
|
|
41
|
-
} = await storageOperations.listForms({
|
|
42
|
-
where: {
|
|
43
|
-
latest: true,
|
|
44
|
-
tenant: tenant.id,
|
|
45
|
-
locale: locale.code
|
|
46
|
-
},
|
|
47
|
-
after: null,
|
|
48
|
-
limit: 10000,
|
|
49
|
-
sort: ["createdOn_DESC"]
|
|
50
|
-
});
|
|
51
|
-
forms = items;
|
|
52
|
-
} catch (ex) {
|
|
53
|
-
console.log(ex.message);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (forms.length === 0) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const entity = storageOperations.getEntities().form;
|
|
62
|
-
const items = [];
|
|
63
|
-
/**
|
|
64
|
-
* ## Regular DynamoDB table.
|
|
65
|
-
* We need to get all the records from all of the forms.
|
|
66
|
-
* Unfortunately, we need to query in a loop to be able to get those forms.
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
for (const form of forms) {
|
|
70
|
-
const {
|
|
71
|
-
id: formId
|
|
72
|
-
} = (0, _utils.parseIdentifier)(form.id);
|
|
73
|
-
const formRecords = await (0, _query.queryAll)({
|
|
74
|
-
entity,
|
|
75
|
-
partitionKey: storageOperations.createFormPartitionKey({
|
|
76
|
-
id: form.id,
|
|
77
|
-
tenant: tenant.id,
|
|
78
|
-
locale: locale.code
|
|
79
|
-
})
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
for (const record of formRecords) {
|
|
83
|
-
/**
|
|
84
|
-
* Checks for "just in case".
|
|
85
|
-
*/
|
|
86
|
-
if (!record || !record.PK || !record.SK) {
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
items.push(entity.putBatch(_objectSpread(_objectSpread({}, record), {}, {
|
|
91
|
-
formId,
|
|
92
|
-
webinyVersion
|
|
93
|
-
})));
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* And finally write all the records to the database again.
|
|
98
|
-
*/
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
try {
|
|
102
|
-
await (0, _batchWrite.batchWriteAll)({
|
|
103
|
-
table: entity.table,
|
|
104
|
-
items
|
|
105
|
-
});
|
|
106
|
-
} catch (ex) {
|
|
107
|
-
throw new _error.default("Could not update all form records.", "UPGRADE_FORM_RECORDS_ERROR", {
|
|
108
|
-
error: ex
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* ## Elasticsearch DynamoDB table.
|
|
113
|
-
*/
|
|
114
|
-
|
|
115
|
-
};
|
|
116
|
-
/**
|
|
117
|
-
* This upgrade adds:
|
|
118
|
-
* - formId (first part of the id) and webinyVersion to the form records
|
|
119
|
-
*/
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
var _default = () => {
|
|
123
|
-
return {
|
|
124
|
-
type: "api-upgrade",
|
|
125
|
-
app: "form-builder",
|
|
126
|
-
version: "5.16.0",
|
|
127
|
-
apply: async context => {
|
|
128
|
-
const tenant = context.tenancy.getCurrentTenant();
|
|
129
|
-
const locale = context.i18nContent.getLocale();
|
|
130
|
-
const storageOperations = context.formBuilder.storageOperations;
|
|
131
|
-
await upgradeForms({
|
|
132
|
-
storageOperations,
|
|
133
|
-
tenant,
|
|
134
|
-
locale,
|
|
135
|
-
webinyVersion: context.WEBINY_VERSION
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
exports.default = _default;
|