@webiny/api-form-builder-so-ddb 0.0.0-unstable.e3f4727c56 → 0.0.0-unstable.eb196ccd2f
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/definitions/form.d.ts +4 -3
- package/definitions/form.js +10 -9
- package/definitions/form.js.map +1 -1
- package/definitions/settings.d.ts +4 -3
- package/definitions/settings.js +9 -8
- package/definitions/settings.js.map +1 -1
- package/definitions/submission.d.ts +4 -3
- package/definitions/submission.js +9 -8
- package/definitions/submission.js.map +1 -1
- package/definitions/system.d.ts +4 -3
- package/definitions/system.js +9 -8
- package/definitions/system.js.map +1 -1
- package/definitions/table.d.ts +4 -4
- package/definitions/table.js +8 -4
- package/definitions/table.js.map +1 -1
- package/index.d.ts +2 -1
- package/index.js +50 -23
- package/index.js.map +1 -1
- package/operations/form/fields.js +3 -1
- package/operations/form/fields.js.map +1 -1
- package/operations/form/index.d.ts +4 -4
- package/operations/form/index.js +119 -83
- package/operations/form/index.js.map +1 -1
- package/operations/settings/index.d.ts +3 -3
- package/operations/settings/index.js +23 -8
- package/operations/settings/index.js.map +1 -1
- package/operations/submission/fields.js +3 -1
- package/operations/submission/fields.js.map +1 -1
- package/operations/submission/index.d.ts +4 -4
- package/operations/submission/index.js +28 -13
- package/operations/submission/index.js.map +1 -1
- package/operations/system/index.d.ts +3 -3
- package/operations/system/index.js +19 -7
- package/operations/system/index.js.map +1 -1
- package/package.json +19 -25
- package/plugins/FormDynamoDbFieldPlugin.js +5 -4
- package/plugins/FormDynamoDbFieldPlugin.js.map +1 -1
- package/plugins/FormSubmissionDynamoDbFieldPlugin.js +5 -4
- package/plugins/FormSubmissionDynamoDbFieldPlugin.js.map +1 -1
- package/plugins/index.d.ts +2 -0
- package/plugins/index.js +29 -0
- package/plugins/index.js.map +1 -0
- package/types.d.ts +9 -11
- package/types.js +5 -4
- package/types.js.map +1 -1
package/operations/form/index.js
CHANGED
|
@@ -5,11 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.createFormStorageOperations = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
9
|
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
11
|
-
var
|
|
12
|
-
var _batchWrite = require("@webiny/db-dynamodb/utils/batchWrite");
|
|
10
|
+
var _dbDynamodb = require("@webiny/db-dynamodb");
|
|
13
11
|
var _filter = require("@webiny/db-dynamodb/utils/filter");
|
|
14
12
|
var _sort = require("@webiny/db-dynamodb/utils/sort");
|
|
15
13
|
var _utils = require("@webiny/utils");
|
|
@@ -19,7 +17,6 @@ var _get = require("@webiny/db-dynamodb/utils/get");
|
|
|
19
17
|
const createFormStorageOperations = params => {
|
|
20
18
|
const {
|
|
21
19
|
entity,
|
|
22
|
-
table,
|
|
23
20
|
plugins
|
|
24
21
|
} = params;
|
|
25
22
|
const formDynamoDbFields = plugins.byType(_FormDynamoDbFieldPlugin.FormDynamoDbFieldPlugin.type);
|
|
@@ -109,16 +106,21 @@ const createFormStorageOperations = params => {
|
|
|
109
106
|
const revisionKeys = createRevisionKeys(form);
|
|
110
107
|
const latestKeys = createLatestKeys(form);
|
|
111
108
|
const gsiKeys = createGSIKeys(form);
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
109
|
+
const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
|
|
110
|
+
entity,
|
|
111
|
+
put: [{
|
|
112
|
+
...form,
|
|
113
|
+
...revisionKeys,
|
|
114
|
+
...gsiKeys,
|
|
115
|
+
TYPE: createFormType()
|
|
116
|
+
}, {
|
|
117
|
+
...form,
|
|
118
|
+
...latestKeys,
|
|
119
|
+
TYPE: createFormLatestType()
|
|
120
|
+
}]
|
|
121
|
+
});
|
|
117
122
|
try {
|
|
118
|
-
await (
|
|
119
|
-
table,
|
|
120
|
-
items
|
|
121
|
-
});
|
|
123
|
+
await entityBatch.execute();
|
|
122
124
|
} catch (ex) {
|
|
123
125
|
throw new _error.default(ex.message || "Could not insert form data into table.", ex.code || "CREATE_FORM_ERROR", {
|
|
124
126
|
revisionKeys,
|
|
@@ -137,16 +139,21 @@ const createFormStorageOperations = params => {
|
|
|
137
139
|
const revisionKeys = createRevisionKeys(form);
|
|
138
140
|
const latestKeys = createLatestKeys(form);
|
|
139
141
|
const gsiKeys = createGSIKeys(form);
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
|
|
143
|
+
entity,
|
|
144
|
+
put: [{
|
|
145
|
+
...form,
|
|
146
|
+
...revisionKeys,
|
|
147
|
+
...gsiKeys,
|
|
148
|
+
TYPE: createFormType()
|
|
149
|
+
}, {
|
|
150
|
+
...form,
|
|
151
|
+
...latestKeys,
|
|
152
|
+
TYPE: createFormLatestType()
|
|
153
|
+
}]
|
|
154
|
+
});
|
|
145
155
|
try {
|
|
146
|
-
await (
|
|
147
|
-
table,
|
|
148
|
-
items
|
|
149
|
-
});
|
|
156
|
+
await entityBatch.execute();
|
|
150
157
|
} catch (ex) {
|
|
151
158
|
throw new _error.default(ex.message || "Could not create form data in the table, from existing form.", ex.code || "CREATE_FORM_FROM_ERROR", {
|
|
152
159
|
revisionKeys,
|
|
@@ -180,19 +187,24 @@ const createFormStorageOperations = params => {
|
|
|
180
187
|
}
|
|
181
188
|
});
|
|
182
189
|
const isLatestForm = latestForm ? latestForm.id === form.id : false;
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
190
|
+
const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
|
|
191
|
+
entity,
|
|
192
|
+
put: [{
|
|
193
|
+
...form,
|
|
194
|
+
...revisionKeys,
|
|
195
|
+
...gsiKeys,
|
|
196
|
+
TYPE: createFormType()
|
|
197
|
+
}]
|
|
198
|
+
});
|
|
186
199
|
if (isLatestForm) {
|
|
187
|
-
|
|
200
|
+
entityBatch.put({
|
|
201
|
+
...form,
|
|
202
|
+
...latestKeys,
|
|
188
203
|
TYPE: createFormLatestType()
|
|
189
|
-
})
|
|
204
|
+
});
|
|
190
205
|
}
|
|
191
206
|
try {
|
|
192
|
-
await (
|
|
193
|
-
table,
|
|
194
|
-
items
|
|
195
|
-
});
|
|
207
|
+
await entityBatch.execute();
|
|
196
208
|
} catch (ex) {
|
|
197
209
|
throw new _error.default(ex.message || "Could not update form data in the table.", ex.code || "UPDATE_FORM_ERROR", {
|
|
198
210
|
revisionKeys,
|
|
@@ -247,11 +259,10 @@ const createFormStorageOperations = params => {
|
|
|
247
259
|
SK: sortKey
|
|
248
260
|
};
|
|
249
261
|
try {
|
|
250
|
-
|
|
262
|
+
return await (0, _get.getClean)({
|
|
251
263
|
entity,
|
|
252
264
|
keys
|
|
253
265
|
});
|
|
254
|
-
return (0, _cleanup.cleanupItem)(entity, item);
|
|
255
266
|
} catch (ex) {
|
|
256
267
|
throw new _error.default(ex.message || "Could not get form by keys.", ex.code || "GET_FORM_ERROR", {
|
|
257
268
|
keys
|
|
@@ -282,7 +293,9 @@ const createFormStorageOperations = params => {
|
|
|
282
293
|
});
|
|
283
294
|
}
|
|
284
295
|
const totalCount = results.length;
|
|
285
|
-
const where =
|
|
296
|
+
const where = {
|
|
297
|
+
...initialWhere
|
|
298
|
+
};
|
|
286
299
|
/**
|
|
287
300
|
* We need to remove conditions so we do not filter by them again.
|
|
288
301
|
*/
|
|
@@ -350,7 +363,9 @@ const createFormStorageOperations = params => {
|
|
|
350
363
|
options: queryAllParams.options
|
|
351
364
|
});
|
|
352
365
|
}
|
|
353
|
-
const where =
|
|
366
|
+
const where = {
|
|
367
|
+
...initialWhere
|
|
368
|
+
};
|
|
354
369
|
/**
|
|
355
370
|
* We need to remove conditions so we do not filter by them again.
|
|
356
371
|
*/
|
|
@@ -382,7 +397,7 @@ const createFormStorageOperations = params => {
|
|
|
382
397
|
entity,
|
|
383
398
|
partitionKey: createFormPartitionKey(form),
|
|
384
399
|
options: {
|
|
385
|
-
beginsWith: form.formId
|
|
400
|
+
beginsWith: form.formId || undefined
|
|
386
401
|
}
|
|
387
402
|
};
|
|
388
403
|
try {
|
|
@@ -393,25 +408,25 @@ const createFormStorageOperations = params => {
|
|
|
393
408
|
options: queryAllParams.options
|
|
394
409
|
});
|
|
395
410
|
}
|
|
396
|
-
let
|
|
397
|
-
const
|
|
398
|
-
|
|
399
|
-
|
|
411
|
+
let latestPublishedKeys;
|
|
412
|
+
const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
|
|
413
|
+
entity,
|
|
414
|
+
delete: [createLatestKeys(form)]
|
|
415
|
+
});
|
|
416
|
+
for (const item of items) {
|
|
417
|
+
if (!latestPublishedKeys && item.published) {
|
|
418
|
+
latestPublishedKeys = createLatestPublishedKeys(item);
|
|
400
419
|
}
|
|
401
|
-
|
|
420
|
+
entityBatch.delete({
|
|
402
421
|
PK: item.PK,
|
|
403
422
|
SK: item.SK
|
|
404
423
|
});
|
|
405
|
-
});
|
|
406
|
-
if (hasLatestPublishedRecord) {
|
|
407
|
-
deleteItems.push(entity.deleteBatch(createLatestPublishedKeys(items[0])));
|
|
408
424
|
}
|
|
409
|
-
|
|
425
|
+
if (latestPublishedKeys) {
|
|
426
|
+
entityBatch.delete(latestPublishedKeys);
|
|
427
|
+
}
|
|
410
428
|
try {
|
|
411
|
-
await (
|
|
412
|
-
table,
|
|
413
|
-
items: deleteItems
|
|
414
|
-
});
|
|
429
|
+
await entityBatch.execute();
|
|
415
430
|
} catch (ex) {
|
|
416
431
|
throw new _error.default(ex.message || "Could not delete form and it's submissions.", ex.code || "DELETE_FORM_AND_SUBMISSIONS_ERROR");
|
|
417
432
|
}
|
|
@@ -435,7 +450,10 @@ const createFormStorageOperations = params => {
|
|
|
435
450
|
const latestPublishedForm = revisions.find(rev => rev.published === true);
|
|
436
451
|
const isLatest = latestForm ? latestForm.id === form.id : false;
|
|
437
452
|
const isLatestPublished = latestPublishedForm ? latestPublishedForm.id === form.id : false;
|
|
438
|
-
const
|
|
453
|
+
const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
|
|
454
|
+
entity,
|
|
455
|
+
delete: [revisionKeys]
|
|
456
|
+
});
|
|
439
457
|
if (isLatest || isLatestPublished) {
|
|
440
458
|
/**
|
|
441
459
|
* Sort out the latest published record.
|
|
@@ -445,34 +463,35 @@ const createFormStorageOperations = params => {
|
|
|
445
463
|
return new Date(b.publishedOn).getTime() - new Date(a.publishedOn).getTime();
|
|
446
464
|
}).shift();
|
|
447
465
|
if (previouslyPublishedForm) {
|
|
448
|
-
|
|
466
|
+
entityBatch.put({
|
|
467
|
+
...previouslyPublishedForm,
|
|
468
|
+
...createLatestPublishedKeys(previouslyPublishedForm),
|
|
449
469
|
GSI1_PK: null,
|
|
450
470
|
GSI1_SK: null,
|
|
451
471
|
TYPE: createFormLatestPublishedType()
|
|
452
|
-
})
|
|
472
|
+
});
|
|
453
473
|
} else {
|
|
454
|
-
|
|
474
|
+
entityBatch.delete(createLatestPublishedKeys(form));
|
|
455
475
|
}
|
|
456
476
|
}
|
|
457
477
|
/**
|
|
458
478
|
* Sort out the latest record.
|
|
459
479
|
*/
|
|
460
480
|
if (isLatest) {
|
|
461
|
-
|
|
481
|
+
entityBatch.put({
|
|
482
|
+
...previous,
|
|
483
|
+
...latestKeys,
|
|
462
484
|
GSI1_PK: null,
|
|
463
485
|
GSI1_SK: null,
|
|
464
486
|
TYPE: createFormLatestType()
|
|
465
|
-
})
|
|
487
|
+
});
|
|
466
488
|
}
|
|
467
489
|
}
|
|
468
490
|
/**
|
|
469
491
|
* Now save the batch data.
|
|
470
492
|
*/
|
|
471
493
|
try {
|
|
472
|
-
await (
|
|
473
|
-
table,
|
|
474
|
-
items
|
|
475
|
-
});
|
|
494
|
+
await entityBatch.execute();
|
|
476
495
|
return form;
|
|
477
496
|
} catch (ex) {
|
|
478
497
|
throw new _error.default(ex.message || "Could not delete form revision from table.", ex.code || "DELETE_FORM_REVISION_ERROR", {
|
|
@@ -520,24 +539,32 @@ const createFormStorageOperations = params => {
|
|
|
520
539
|
/**
|
|
521
540
|
* Update revision and latest published records
|
|
522
541
|
*/
|
|
523
|
-
const
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
542
|
+
const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
|
|
543
|
+
entity,
|
|
544
|
+
put: [{
|
|
545
|
+
...form,
|
|
546
|
+
...revisionKeys,
|
|
547
|
+
...gsiKeys,
|
|
548
|
+
TYPE: createFormType()
|
|
549
|
+
}, {
|
|
550
|
+
...form,
|
|
551
|
+
...latestPublishedKeys,
|
|
552
|
+
TYPE: createFormLatestPublishedType()
|
|
553
|
+
}]
|
|
554
|
+
});
|
|
555
|
+
|
|
528
556
|
/**
|
|
529
557
|
* Update the latest form as well
|
|
530
558
|
*/
|
|
531
559
|
if (isLatestForm) {
|
|
532
|
-
|
|
560
|
+
entityBatch.put({
|
|
561
|
+
...form,
|
|
562
|
+
...latestKeys,
|
|
533
563
|
TYPE: createFormLatestType()
|
|
534
|
-
})
|
|
564
|
+
});
|
|
535
565
|
}
|
|
536
566
|
try {
|
|
537
|
-
await (
|
|
538
|
-
table,
|
|
539
|
-
items
|
|
540
|
-
});
|
|
567
|
+
await entityBatch.execute();
|
|
541
568
|
} catch (ex) {
|
|
542
569
|
throw new _error.default(ex.message || "Could not publish form.", ex.code || "PUBLISH_FORM_ERROR", {
|
|
543
570
|
form,
|
|
@@ -589,13 +616,21 @@ const createFormStorageOperations = params => {
|
|
|
589
616
|
});
|
|
590
617
|
const isLatest = latestForm ? latestForm.id === form.id : false;
|
|
591
618
|
const isLatestPublished = latestPublishedForm ? latestPublishedForm.id === form.id : false;
|
|
592
|
-
const
|
|
593
|
-
|
|
594
|
-
|
|
619
|
+
const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
|
|
620
|
+
entity,
|
|
621
|
+
put: [{
|
|
622
|
+
...form,
|
|
623
|
+
...revisionKeys,
|
|
624
|
+
...gsiKeys,
|
|
625
|
+
TYPE: createFormType()
|
|
626
|
+
}]
|
|
627
|
+
});
|
|
595
628
|
if (isLatest) {
|
|
596
|
-
|
|
629
|
+
entityBatch.put({
|
|
630
|
+
...form,
|
|
631
|
+
...latestKeys,
|
|
597
632
|
TYPE: createFormLatestType()
|
|
598
|
-
})
|
|
633
|
+
});
|
|
599
634
|
}
|
|
600
635
|
/**
|
|
601
636
|
* In case previously published revision exists, replace current one with that one.
|
|
@@ -614,18 +649,17 @@ const createFormStorageOperations = params => {
|
|
|
614
649
|
});
|
|
615
650
|
const previouslyPublishedRevision = revisions.shift();
|
|
616
651
|
if (previouslyPublishedRevision) {
|
|
617
|
-
|
|
652
|
+
entityBatch.put({
|
|
653
|
+
...previouslyPublishedRevision,
|
|
654
|
+
...latestPublishedKeys,
|
|
618
655
|
TYPE: createFormLatestPublishedType()
|
|
619
|
-
})
|
|
656
|
+
});
|
|
620
657
|
} else {
|
|
621
|
-
|
|
658
|
+
entityBatch.delete(latestPublishedKeys);
|
|
622
659
|
}
|
|
623
660
|
}
|
|
624
661
|
try {
|
|
625
|
-
await (
|
|
626
|
-
table,
|
|
627
|
-
items
|
|
628
|
-
});
|
|
662
|
+
await entityBatch.execute();
|
|
629
663
|
return form;
|
|
630
664
|
} catch (ex) {
|
|
631
665
|
throw new _error.default(ex.message || "Could not unpublish form.", ex.code || "UNPUBLISH_FORM_ERROR", {
|
|
@@ -652,4 +686,6 @@ const createFormStorageOperations = params => {
|
|
|
652
686
|
createFormPartitionKey
|
|
653
687
|
};
|
|
654
688
|
};
|
|
655
|
-
exports.createFormStorageOperations = createFormStorageOperations;
|
|
689
|
+
exports.createFormStorageOperations = createFormStorageOperations;
|
|
690
|
+
|
|
691
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createFormStorageOperations","params","entity","table","plugins","formDynamoDbFields","byType","FormDynamoDbFieldPlugin","type","createFormPartitionKey","tenant","locale","createFormLatestPartitionKey","createFormLatestPublishedPartitionKey","createFormGSIPartitionKey","id","targetId","parseIdentifier","createRevisionSortKey","createFormLatestSortKey","formId","value","createLatestPublishedSortKey","createGSISortKey","version","createFormType","createFormLatestType","createFormLatestPublishedType","createRevisionKeys","form","PK","SK","createLatestKeys","createLatestPublishedKeys","createGSIKeys","GSI1_PK","GSI1_SK","createForm","revisionKeys","latestKeys","gsiKeys","items","putBatch","TYPE","batchWriteAll","ex","WebinyError","message","code","createFormFrom","original","latest","updateForm","latestForm","getForm","where","isLatestForm","push","published","partitionKey","sortKey","createIdentifier","keys","item","get","cleanupItem","listForms","sort","limit","initialWhere","after","queryAllParams","options","gte","results","queryAll","totalCount","length","filteredItems","filterItems","fields","sortedItems","sortItems","start","parseInt","decodeCursor","hasMoreItems","end","undefined","slice","cursor","encodeCursor","meta","listFormRevisions","index","deleteForm","beginsWith","hasLatestPublishedRecord","deleteItems","map","deleteBatch","deleteFormRevision","revisions","previous","latestPublishedForm","find","rev","isLatest","isLatestPublished","previouslyPublishedForm","filter","f","publishedOn","a","b","Date","getTime","shift","publishForm","latestPublishedKeys","unpublishForm","version_not","publishedOn_not","previouslyPublishedRevision"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\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 { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { batchWriteAll } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport { filterItems } from \"@webiny/db-dynamodb/utils/filter\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\nimport { createIdentifier, parseIdentifier } from \"@webiny/utils\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport {\n FormBuilderFormCreateGSIPartitionKeyParams,\n FormBuilderFormCreatePartitionKeyParams,\n FormBuilderFormStorageOperations\n} from \"~/types\";\nimport { FormDynamoDbFieldPlugin } from \"~/plugins/FormDynamoDbFieldPlugin\";\nimport { decodeCursor, encodeCursor } from \"@webiny/db-dynamodb/utils/cursor\";\nimport { get } from \"@webiny/db-dynamodb/utils/get\";\n\ntype DbRecord<T = any> = T & {\n PK: string;\n SK: string;\n TYPE: string;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\n\ninterface FormLatestSortKeyParams {\n id?: string;\n formId?: string;\n}\n\ninterface GsiKeys {\n GSI1_PK: string;\n GSI1_SK: string;\n}\n\nexport interface CreateFormStorageOperationsParams {\n entity: Entity<any>;\n table: Table;\n plugins: PluginsContainer;\n}\n\nexport const createFormStorageOperations = (\n params: CreateFormStorageOperationsParams\n): FormBuilderFormStorageOperations => {\n const { entity, table, plugins } = params;\n\n const formDynamoDbFields = plugins.byType<FormDynamoDbFieldPlugin>(\n FormDynamoDbFieldPlugin.type\n );\n\n const createFormPartitionKey = (params: FormBuilderFormCreatePartitionKeyParams): string => {\n const { tenant, locale } = params;\n\n return `T#${tenant}#L#${locale}#FB#F`;\n };\n\n const createFormLatestPartitionKey = (\n params: FormBuilderFormCreatePartitionKeyParams\n ): string => {\n return `${createFormPartitionKey(params)}#L`;\n };\n\n const createFormLatestPublishedPartitionKey = (\n params: FormBuilderFormCreatePartitionKeyParams\n ): string => {\n return `${createFormPartitionKey(params)}#LP`;\n };\n\n const createFormGSIPartitionKey = (\n params: FormBuilderFormCreateGSIPartitionKeyParams\n ): string => {\n const { tenant, locale, id: targetId } = params;\n const { id } = parseIdentifier(targetId);\n\n return `T#${tenant}#L#${locale}#FB#F#${id}`;\n };\n\n const createRevisionSortKey = ({ id }: { id: string }): string => {\n return `${id}`;\n };\n\n const createFormLatestSortKey = ({ id, formId }: FormLatestSortKeyParams): string => {\n const value = parseIdentifier(id || formId);\n return value.id;\n };\n\n const createLatestPublishedSortKey = ({ id, formId }: FormLatestSortKeyParams): string => {\n const value = parseIdentifier(id || formId);\n return value.id;\n };\n\n const createGSISortKey = (version: number) => {\n return `${version}`;\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 createRevisionKeys = (form: FbForm): Keys => {\n return {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form)\n };\n };\n\n const createLatestKeys = (form: FbForm): Keys => {\n return {\n PK: createFormLatestPartitionKey(form),\n SK: createFormLatestSortKey(form)\n };\n };\n\n const createLatestPublishedKeys = (form: FbForm): Keys => {\n return {\n PK: createFormLatestPublishedPartitionKey(form),\n SK: createLatestPublishedSortKey(form)\n };\n };\n\n const createGSIKeys = (form: FbForm): GsiKeys => {\n return {\n GSI1_PK: createFormGSIPartitionKey(form),\n GSI1_SK: createGSISortKey(form.version)\n };\n };\n\n const createForm = async (\n params: FormBuilderStorageOperationsCreateFormParams\n ): Promise<FbForm> => {\n const { form } = params;\n\n const revisionKeys = createRevisionKeys(form);\n const latestKeys = createLatestKeys(form);\n const gsiKeys = createGSIKeys(form);\n\n const items = [\n entity.putBatch({\n ...form,\n ...revisionKeys,\n ...gsiKeys,\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 || \"Could not insert form data into table.\",\n ex.code || \"CREATE_FORM_ERROR\",\n {\n revisionKeys,\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 = createRevisionKeys(form);\n const latestKeys = createLatestKeys(form);\n const gsiKeys = createGSIKeys(form);\n\n const items = [\n entity.putBatch({\n ...form,\n ...revisionKeys,\n ...gsiKeys,\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 || \"Could not create form data in the 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 return form;\n };\n\n const updateForm = async (\n params: FormBuilderStorageOperationsUpdateFormParams\n ): Promise<FbForm> => {\n const { form, original } = params;\n\n const revisionKeys = createRevisionKeys(form);\n const latestKeys = createLatestKeys(form);\n const gsiKeys = createGSIKeys(form);\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 ...revisionKeys,\n ...gsiKeys,\n TYPE: createFormType()\n })\n ];\n if (isLatestForm) {\n items.push(\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 || \"Could not update form data in the table.\",\n ex.code || \"UPDATE_FORM_ERROR\",\n {\n revisionKeys,\n latestKeys,\n original,\n form,\n latestForm\n }\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 } = where;\n if (latest && published) {\n throw new WebinyError(\"Cannot have both latest and published params.\");\n }\n let partitionKey: string;\n let sortKey: string;\n if (latest) {\n partitionKey = createFormLatestPartitionKey(where);\n sortKey = createFormLatestSortKey(where);\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 partitionKey = createFormLatestPublishedPartitionKey(where);\n sortKey = createLatestPublishedSortKey(where);\n } else if (id || version) {\n partitionKey = createFormPartitionKey(where);\n sortKey = createRevisionSortKey({\n id:\n id ||\n createIdentifier({\n id: formId as string,\n version: version as number\n })\n });\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: partitionKey,\n SK: sortKey\n };\n\n try {\n const item = await get<FbForm>({ entity, keys });\n return cleanupItem(entity, 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: initialWhere, after } = params;\n\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createFormLatestPartitionKey(initialWhere),\n options: {\n gte: \" \"\n }\n };\n\n let results;\n try {\n results = await queryAll<FbForm>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could list forms.\",\n ex.code || \"LIST_FORMS_ERROR\",\n {\n where: initialWhere,\n partitionKey: queryAllParams.partitionKey\n }\n );\n }\n const totalCount = results.length;\n\n const where: Partial<FormBuilderStorageOperationsListFormsParams[\"where\"]> = {\n ...initialWhere\n };\n /**\n * We need to remove conditions so we do not filter by them again.\n */\n delete where.tenant;\n delete where.locale;\n\n const filteredItems = filterItems({\n plugins,\n items: results,\n where,\n fields: formDynamoDbFields\n });\n\n const sortedItems = sortItems({\n items: filteredItems,\n sort,\n fields: formDynamoDbFields\n });\n\n const start = parseInt(decodeCursor(after) || \"0\") || 0;\n const hasMoreItems = totalCount > start + limit;\n const end = limit > totalCount + start + limit ? undefined : start + limit;\n const items = sortedItems.slice(start, end);\n /**\n * Although we do not need a cursor here, we will use it as such to keep it standardized.\n * Number is simply encoded.\n */\n const cursor = items.length > 0 ? encodeCursor(start + limit) : null;\n\n const meta = {\n hasMoreItems,\n totalCount,\n cursor\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\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createFormGSIPartitionKey({\n tenant,\n locale,\n id: formId || id\n }),\n options: {\n index: \"GSI1\",\n gte: \" \"\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 };\n /**\n * We need to remove conditions so we do not filter by them again.\n */\n delete where.id;\n delete where.formId;\n delete where.tenant;\n delete where.locale;\n\n const filteredItems = filterItems({\n plugins,\n items,\n where,\n fields: formDynamoDbFields\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 records.\n */\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createFormPartitionKey(form),\n options: {\n beginsWith: form.formId\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 let hasLatestPublishedRecord = false;\n\n const deleteItems = items.map(item => {\n if (!hasLatestPublishedRecord && item.published) {\n hasLatestPublishedRecord = true;\n }\n return entity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\n });\n if (hasLatestPublishedRecord) {\n deleteItems.push(entity.deleteBatch(createLatestPublishedKeys(items[0])));\n }\n\n deleteItems.push(entity.deleteBatch(createLatestKeys(items[0])));\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 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 = createRevisionKeys(form);\n const latestKeys = createLatestKeys(form);\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\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 ...createLatestPublishedKeys(previouslyPublishedForm),\n GSI1_PK: null,\n GSI1_SK: null,\n TYPE: createFormLatestPublishedType()\n })\n );\n } else {\n items.push(entity.deleteBatch(createLatestPublishedKeys(form)));\n }\n }\n /**\n * Sort out the latest record.\n */\n if (isLatest) {\n items.push(\n entity.putBatch({\n ...previous,\n ...latestKeys,\n GSI1_PK: null,\n GSI1_SK: null,\n TYPE: createFormLatestType()\n })\n );\n }\n }\n /**\n * Now save the batch data.\n */\n try {\n await batchWriteAll({\n table,\n items\n });\n return form;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form revision from 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 = createRevisionKeys(form);\n\n const latestKeys = createLatestKeys(form);\n\n const latestPublishedKeys = createLatestPublishedKeys(form);\n\n const gsiKeys = {\n GSI1_PK: createFormGSIPartitionKey(form),\n GSI1_SK: createGSISortKey(form.version)\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 ...gsiKeys,\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 return form;\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 = createRevisionKeys(form);\n const latestKeys = createLatestKeys(form);\n const latestPublishedKeys = createLatestPublishedKeys(form);\n const gsiKeys = createGSIKeys(form);\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 ...gsiKeys,\n TYPE: createFormType()\n })\n ];\n\n if (isLatest) {\n entity.putBatch({\n ...form,\n ...latestKeys,\n TYPE: createFormLatestType()\n });\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 return form;\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\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":";;;;;;;;AAAA;AAiBA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AA6BO,MAAMA,2BAA2B,GACpCC,MAAyC,IACN;EACnC,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAEzC,MAAMI,kBAAkB,GAAGD,OAAO,CAACE,MAAM,CACrCC,gDAAuB,CAACC,IAAI,CAC/B;EAED,MAAMC,sBAAsB,GAAIR,MAA+C,IAAa;IACxF,MAAM;MAAES,MAAM;MAAEC;IAAO,CAAC,GAAGV,MAAM;IAEjC,OAAQ,KAAIS,MAAO,MAAKC,MAAO,OAAM;EACzC,CAAC;EAED,MAAMC,4BAA4B,GAC9BX,MAA+C,IACtC;IACT,OAAQ,GAAEQ,sBAAsB,CAACR,MAAM,CAAE,IAAG;EAChD,CAAC;EAED,MAAMY,qCAAqC,GACvCZ,MAA+C,IACtC;IACT,OAAQ,GAAEQ,sBAAsB,CAACR,MAAM,CAAE,KAAI;EACjD,CAAC;EAED,MAAMa,yBAAyB,GAC3Bb,MAAkD,IACzC;IACT,MAAM;MAAES,MAAM;MAAEC,MAAM;MAAEI,EAAE,EAAEC;IAAS,CAAC,GAAGf,MAAM;IAC/C,MAAM;MAAEc;IAAG,CAAC,GAAG,IAAAE,sBAAe,EAACD,QAAQ,CAAC;IAExC,OAAQ,KAAIN,MAAO,MAAKC,MAAO,SAAQI,EAAG,EAAC;EAC/C,CAAC;EAED,MAAMG,qBAAqB,GAAG,CAAC;IAAEH;EAAmB,CAA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,UAAU;IACVM,kBAAkB;IAClBiB,WAAW;IACXE,aAAa;IACb/G;EACJ,CAAC;AACL,CAAC;AAAC"}
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_query","_dbDynamodb","_filter","_sort","_utils","_FormDynamoDbFieldPlugin","_cursor","_get","createFormStorageOperations","params","entity","plugins","formDynamoDbFields","byType","FormDynamoDbFieldPlugin","type","createFormPartitionKey","tenant","locale","createFormLatestPartitionKey","createFormLatestPublishedPartitionKey","createFormGSIPartitionKey","id","targetId","parseIdentifier","createRevisionSortKey","createFormLatestSortKey","formId","value","createLatestPublishedSortKey","createGSISortKey","version","createFormType","createFormLatestType","createFormLatestPublishedType","createRevisionKeys","form","PK","SK","createLatestKeys","createLatestPublishedKeys","createGSIKeys","GSI1_PK","GSI1_SK","createForm","revisionKeys","latestKeys","gsiKeys","entityBatch","createEntityWriteBatch","put","TYPE","execute","ex","WebinyError","message","code","createFormFrom","original","latest","updateForm","latestForm","getForm","where","isLatestForm","published","partitionKey","sortKey","createIdentifier","keys","getClean","listForms","sort","limit","initialWhere","after","queryAllParams","options","gte","results","queryAll","totalCount","length","filteredItems","filterItems","items","fields","sortedItems","sortItems","start","parseInt","decodeCursor","hasMoreItems","end","undefined","slice","cursor","encodeCursor","meta","listFormRevisions","index","deleteForm","beginsWith","latestPublishedKeys","delete","item","deleteFormRevision","revisions","previous","latestPublishedForm","find","rev","isLatest","isLatestPublished","previouslyPublishedForm","filter","f","publishedOn","a","b","Date","getTime","shift","publishForm","unpublishForm","version_not","publishedOn_not","previouslyPublishedRevision","exports"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\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 type { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport type { QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { queryAll } from \"@webiny/db-dynamodb/utils/query\";\nimport { createEntityWriteBatch } from \"@webiny/db-dynamodb\";\nimport { filterItems } from \"@webiny/db-dynamodb/utils/filter\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\nimport { createIdentifier, parseIdentifier } from \"@webiny/utils\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type {\n FormBuilderFormCreateGSIPartitionKeyParams,\n FormBuilderFormCreatePartitionKeyParams,\n FormBuilderFormStorageOperations\n} from \"~/types\";\nimport { FormDynamoDbFieldPlugin } from \"~/plugins/FormDynamoDbFieldPlugin\";\nimport { decodeCursor, encodeCursor } from \"@webiny/db-dynamodb/utils/cursor\";\nimport { getClean } from \"@webiny/db-dynamodb/utils/get\";\n\ntype DbRecord<T = any> = T & {\n PK: string;\n SK: string;\n TYPE: string;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\n\ninterface FormLatestSortKeyParams {\n id?: string;\n formId?: string;\n}\n\ninterface GsiKeys {\n GSI1_PK: string;\n GSI1_SK: string;\n}\n\nexport interface CreateFormStorageOperationsParams {\n entity: Entity<any>;\n table: Table<string, string, string>;\n plugins: PluginsContainer;\n}\n\nexport const createFormStorageOperations = (\n params: CreateFormStorageOperationsParams\n): FormBuilderFormStorageOperations => {\n const { entity, plugins } = params;\n\n const formDynamoDbFields = plugins.byType<FormDynamoDbFieldPlugin>(\n FormDynamoDbFieldPlugin.type\n );\n\n const createFormPartitionKey = (params: FormBuilderFormCreatePartitionKeyParams): string => {\n const { tenant, locale } = params;\n\n return `T#${tenant}#L#${locale}#FB#F`;\n };\n\n const createFormLatestPartitionKey = (\n params: FormBuilderFormCreatePartitionKeyParams\n ): string => {\n return `${createFormPartitionKey(params)}#L`;\n };\n\n const createFormLatestPublishedPartitionKey = (\n params: FormBuilderFormCreatePartitionKeyParams\n ): string => {\n return `${createFormPartitionKey(params)}#LP`;\n };\n\n const createFormGSIPartitionKey = (\n params: FormBuilderFormCreateGSIPartitionKeyParams\n ): string => {\n const { tenant, locale, id: targetId } = params;\n const { id } = parseIdentifier(targetId);\n\n return `T#${tenant}#L#${locale}#FB#F#${id}`;\n };\n\n const createRevisionSortKey = ({ id }: { id: string }): string => {\n return `${id}`;\n };\n\n const createFormLatestSortKey = ({ id, formId }: FormLatestSortKeyParams): string => {\n const value = parseIdentifier(id || formId);\n return value.id;\n };\n\n const createLatestPublishedSortKey = ({ id, formId }: FormLatestSortKeyParams): string => {\n const value = parseIdentifier(id || formId);\n return value.id;\n };\n\n const createGSISortKey = (version: number) => {\n return `${version}`;\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 createRevisionKeys = (form: Pick<FbForm, \"id\" | \"tenant\" | \"locale\">): Keys => {\n return {\n PK: createFormPartitionKey(form),\n SK: createRevisionSortKey(form)\n };\n };\n\n const createLatestKeys = (form: Pick<FbForm, \"tenant\" | \"locale\" | \"id\" | \"formId\">): Keys => {\n return {\n PK: createFormLatestPartitionKey(form),\n SK: createFormLatestSortKey(form)\n };\n };\n\n const createLatestPublishedKeys = (\n form: Pick<FbForm, \"tenant\" | \"locale\" | \"id\" | \"formId\">\n ): Keys => {\n return {\n PK: createFormLatestPublishedPartitionKey(form),\n SK: createLatestPublishedSortKey(form)\n };\n };\n\n const createGSIKeys = (form: Pick<FbForm, \"version\" | \"tenant\" | \"locale\">): GsiKeys => {\n return {\n GSI1_PK: createFormGSIPartitionKey(form),\n GSI1_SK: createGSISortKey(form.version)\n };\n };\n\n const createForm = async (\n params: FormBuilderStorageOperationsCreateFormParams\n ): Promise<FbForm> => {\n const { form } = params;\n\n const revisionKeys = createRevisionKeys(form);\n const latestKeys = createLatestKeys(form);\n const gsiKeys = createGSIKeys(form);\n\n const entityBatch = createEntityWriteBatch({\n entity,\n put: [\n {\n ...form,\n ...revisionKeys,\n ...gsiKeys,\n TYPE: createFormType()\n },\n {\n ...form,\n ...latestKeys,\n TYPE: createFormLatestType()\n }\n ]\n });\n\n try {\n await entityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert form data into table.\",\n ex.code || \"CREATE_FORM_ERROR\",\n {\n revisionKeys,\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 = createRevisionKeys(form);\n const latestKeys = createLatestKeys(form);\n const gsiKeys = createGSIKeys(form);\n\n const entityBatch = createEntityWriteBatch({\n entity,\n put: [\n {\n ...form,\n ...revisionKeys,\n ...gsiKeys,\n TYPE: createFormType()\n },\n {\n ...form,\n ...latestKeys,\n TYPE: createFormLatestType()\n }\n ]\n });\n\n try {\n await entityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create form data in the 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 return form;\n };\n\n const updateForm = async (\n params: FormBuilderStorageOperationsUpdateFormParams\n ): Promise<FbForm> => {\n const { form, original } = params;\n\n const revisionKeys = createRevisionKeys(form);\n const latestKeys = createLatestKeys(form);\n const gsiKeys = createGSIKeys(form);\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 entityBatch = createEntityWriteBatch({\n entity,\n put: [\n {\n ...form,\n ...revisionKeys,\n ...gsiKeys,\n TYPE: createFormType()\n }\n ]\n });\n\n if (isLatestForm) {\n entityBatch.put({\n ...form,\n ...latestKeys,\n TYPE: createFormLatestType()\n });\n }\n try {\n await entityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update form data in the table.\",\n ex.code || \"UPDATE_FORM_ERROR\",\n {\n revisionKeys,\n latestKeys,\n original,\n form,\n latestForm\n }\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 } = where;\n if (latest && published) {\n throw new WebinyError(\"Cannot have both latest and published params.\");\n }\n let partitionKey: string;\n let sortKey: string;\n if (latest) {\n partitionKey = createFormLatestPartitionKey(where);\n sortKey = createFormLatestSortKey(where);\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 partitionKey = createFormLatestPublishedPartitionKey(where);\n sortKey = createLatestPublishedSortKey(where);\n } else if (id || version) {\n partitionKey = createFormPartitionKey(where);\n sortKey = createRevisionSortKey({\n id:\n id ||\n createIdentifier({\n id: formId as string,\n version: version as number\n })\n });\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: partitionKey,\n SK: sortKey\n };\n\n try {\n return await getClean<FbForm>({ entity, keys });\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: initialWhere, after } = params;\n\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createFormLatestPartitionKey(initialWhere),\n options: {\n gte: \" \"\n }\n };\n\n let results;\n try {\n results = await queryAll<FbForm>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could list forms.\",\n ex.code || \"LIST_FORMS_ERROR\",\n {\n where: initialWhere,\n partitionKey: queryAllParams.partitionKey\n }\n );\n }\n const totalCount = results.length;\n\n const where: Partial<FormBuilderStorageOperationsListFormsParams[\"where\"]> = {\n ...initialWhere\n };\n /**\n * We need to remove conditions so we do not filter by them again.\n */\n delete where.tenant;\n delete where.locale;\n\n const filteredItems = filterItems({\n plugins,\n items: results,\n where,\n fields: formDynamoDbFields\n });\n\n const sortedItems = sortItems({\n items: filteredItems,\n sort,\n fields: formDynamoDbFields\n });\n\n const start = parseInt(decodeCursor(after) || \"0\") || 0;\n const hasMoreItems = totalCount > start + limit;\n const end = limit > totalCount + start + limit ? undefined : start + limit;\n const items = sortedItems.slice(start, end);\n /**\n * Although we do not need a cursor here, we will use it as such to keep it standardized.\n * Number is simply encoded.\n */\n const cursor = items.length > 0 ? encodeCursor(start + limit) : null;\n\n const meta = {\n hasMoreItems,\n totalCount,\n cursor\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\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createFormGSIPartitionKey({\n tenant,\n locale,\n id: formId || id\n }),\n options: {\n index: \"GSI1\",\n gte: \" \"\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 };\n /**\n * We need to remove conditions so we do not filter by them again.\n */\n delete where.id;\n delete where.formId;\n delete where.tenant;\n delete where.locale;\n\n const filteredItems = filterItems({\n plugins,\n items,\n where,\n fields: formDynamoDbFields\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 records.\n */\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createFormPartitionKey(form),\n options: {\n beginsWith: form.formId || undefined\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 let latestPublishedKeys: Keys | undefined;\n const entityBatch = createEntityWriteBatch({\n entity,\n delete: [createLatestKeys(form)]\n });\n\n for (const item of items) {\n if (!latestPublishedKeys && item.published) {\n latestPublishedKeys = createLatestPublishedKeys(item);\n }\n entityBatch.delete({\n PK: item.PK,\n SK: item.SK\n });\n }\n\n if (latestPublishedKeys) {\n entityBatch.delete(latestPublishedKeys);\n }\n\n try {\n await entityBatch.execute();\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 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 = createRevisionKeys(form);\n const latestKeys = createLatestKeys(form);\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 entityBatch = createEntityWriteBatch({\n entity,\n delete: [revisionKeys]\n });\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 entityBatch.put({\n ...previouslyPublishedForm,\n ...createLatestPublishedKeys(previouslyPublishedForm),\n GSI1_PK: null,\n GSI1_SK: null,\n TYPE: createFormLatestPublishedType()\n });\n } else {\n entityBatch.delete(createLatestPublishedKeys(form));\n }\n }\n /**\n * Sort out the latest record.\n */\n if (isLatest) {\n entityBatch.put({\n ...previous,\n ...latestKeys,\n GSI1_PK: null,\n GSI1_SK: null,\n TYPE: createFormLatestType()\n });\n }\n }\n /**\n * Now save the batch data.\n */\n try {\n await entityBatch.execute();\n\n return form;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete form revision from 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 = createRevisionKeys(form);\n\n const latestKeys = createLatestKeys(form);\n\n const latestPublishedKeys = createLatestPublishedKeys(form);\n\n const gsiKeys = {\n GSI1_PK: createFormGSIPartitionKey(form),\n GSI1_SK: createGSISortKey(form.version)\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 entityBatch = createEntityWriteBatch({\n entity,\n put: [\n {\n ...form,\n ...revisionKeys,\n ...gsiKeys,\n TYPE: createFormType()\n },\n {\n ...form,\n ...latestPublishedKeys,\n TYPE: createFormLatestPublishedType()\n }\n ]\n });\n\n /**\n * Update the latest form as well\n */\n if (isLatestForm) {\n entityBatch.put({\n ...form,\n ...latestKeys,\n TYPE: createFormLatestType()\n });\n }\n\n try {\n await entityBatch.execute();\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 return form;\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 = createRevisionKeys(form);\n const latestKeys = createLatestKeys(form);\n const latestPublishedKeys = createLatestPublishedKeys(form);\n const gsiKeys = createGSIKeys(form);\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 entityBatch = createEntityWriteBatch({\n entity,\n put: [\n {\n ...form,\n ...revisionKeys,\n ...gsiKeys,\n TYPE: createFormType()\n }\n ]\n });\n\n if (isLatest) {\n entityBatch.put({\n ...form,\n ...latestKeys,\n TYPE: createFormLatestType()\n });\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 entityBatch.put({\n ...previouslyPublishedRevision,\n ...latestPublishedKeys,\n TYPE: createFormLatestPublishedType()\n });\n } else {\n entityBatch.delete(latestPublishedKeys);\n }\n }\n\n try {\n await entityBatch.execute();\n return form;\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\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":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAkBA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAOA,IAAAM,wBAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,IAAA,GAAAR,OAAA;AA6BO,MAAMS,2BAA2B,GACpCC,MAAyC,IACN;EACnC,MAAM;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGF,MAAM;EAElC,MAAMG,kBAAkB,GAAGD,OAAO,CAACE,MAAM,CACrCC,gDAAuB,CAACC,IAC5B,CAAC;EAED,MAAMC,sBAAsB,GAAIP,MAA+C,IAAa;IACxF,MAAM;MAAEQ,MAAM;MAAEC;IAAO,CAAC,GAAGT,MAAM;IAEjC,OAAO,KAAKQ,MAAM,MAAMC,MAAM,OAAO;EACzC,CAAC;EAED,MAAMC,4BAA4B,GAC9BV,MAA+C,IACtC;IACT,OAAO,GAAGO,sBAAs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ACwD,MAAM,CAACD,mBAAmB,CAAC;MAC3C;IACJ;IAEA,IAAI;MACA,MAAMvD,WAAW,CAACI,OAAO,CAAC,CAAC;MAC3B,OAAOhB,IAAI;IACf,CAAC,CAAC,OAAOiB,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,2BAA2B,EACzCF,EAAE,CAACG,IAAI,IAAI,sBAAsB,EACjC;QACIpB,IAAI;QACJsB,QAAQ;QACRG,UAAU;QACVhB,YAAY;QACZC,UAAU;QACVyD;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACH3D,UAAU;IACVa,cAAc;IACdG,UAAU;IACVW,SAAS;IACT4B,iBAAiB;IACjBrC,OAAO;IACPuC,UAAU;IACVK,kBAAkB;IAClBiB,WAAW;IACXC,aAAa;IACb5G;EACJ,CAAC;AACL,CAAC;AAACgH,OAAA,CAAAxH,2BAAA,GAAAA,2BAAA","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Entity, Table } from "dynamodb
|
|
2
|
-
import { FormBuilderSettingsStorageOperations } from "../../types";
|
|
1
|
+
import type { Entity, Table } from "@webiny/db-dynamodb/toolbox";
|
|
2
|
+
import type { FormBuilderSettingsStorageOperations } from "../../types";
|
|
3
3
|
export interface CreateSettingsStorageOperationsParams {
|
|
4
4
|
entity: Entity<any>;
|
|
5
|
-
table: Table
|
|
5
|
+
table: Table<string, string, string>;
|
|
6
6
|
}
|
|
7
7
|
export declare const createSettingsStorageOperations: (params: CreateSettingsStorageOperationsParams) => FormBuilderSettingsStorageOperations;
|