@payloadcms/db-postgres 0.1.0-beta.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. package/dist/connect.js +82 -0
  2. package/dist/create.js +32 -0
  3. package/dist/createGlobal.js +32 -0
  4. package/dist/createGlobalVersion.js +48 -0
  5. package/dist/createMigration.js +85 -0
  6. package/dist/createVersion.js +54 -0
  7. package/dist/deleteMany.js +44 -0
  8. package/dist/deleteOne.js +47 -0
  9. package/dist/deleteVersions.js +46 -0
  10. package/dist/destroy.js +16 -0
  11. package/dist/find/buildFindManyArgs.js +61 -0
  12. package/dist/find/chainMethods.js +21 -0
  13. package/dist/find/findMany.js +197 -0
  14. package/dist/find/traverseFields.js +118 -0
  15. package/dist/find.js +35 -0
  16. package/dist/findGlobal.js +38 -0
  17. package/dist/findGlobalVersions.js +39 -0
  18. package/dist/findOne.js +49 -0
  19. package/dist/findVersions.js +39 -0
  20. package/dist/index.js +95 -0
  21. package/dist/init.js +74 -0
  22. package/dist/migrate.js +81 -0
  23. package/dist/migrateStatus.js +54 -0
  24. package/dist/mock.js +13 -0
  25. package/dist/queries/buildAndOrConditions.js +39 -0
  26. package/dist/queries/buildQuery.js +80 -0
  27. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js +24 -0
  28. package/dist/queries/createJSONQuery/formatJSONPathSegment.js +15 -0
  29. package/dist/queries/createJSONQuery/index.js +64 -0
  30. package/dist/queries/getTableColumnFromPath.js +333 -0
  31. package/dist/queries/operatorMap.js +34 -0
  32. package/dist/queries/parseParams.js +146 -0
  33. package/dist/queries/sanitizeQueryValue.js +79 -0
  34. package/dist/queryDrafts.js +56 -0
  35. package/dist/reference.js +76 -0
  36. package/dist/schema/build.js +245 -0
  37. package/dist/schema/createIndex.js +19 -0
  38. package/dist/schema/parentIDColumnMap.js +18 -0
  39. package/dist/schema/traverseFields.js +430 -0
  40. package/dist/schema/validateExistingBlockIsIdentical.js +34 -0
  41. package/dist/transactions/beginTransaction.js +51 -0
  42. package/dist/transactions/commitTransaction.js +24 -0
  43. package/dist/transactions/rollbackTransaction.js +20 -0
  44. package/dist/transform/read/hasManyNumber.js +20 -0
  45. package/dist/transform/read/index.js +42 -0
  46. package/dist/transform/read/relationship.js +74 -0
  47. package/dist/transform/read/traverseFields.js +325 -0
  48. package/dist/transform/write/array.js +55 -0
  49. package/dist/transform/write/blocks.js +56 -0
  50. package/dist/transform/write/index.js +46 -0
  51. package/dist/transform/write/numbers.js +21 -0
  52. package/dist/transform/write/relationships.js +33 -0
  53. package/dist/transform/write/selects.js +29 -0
  54. package/dist/transform/write/traverseFields.js +379 -0
  55. package/dist/transform/write/types.js +6 -0
  56. package/dist/types.js +6 -0
  57. package/dist/update.js +48 -0
  58. package/dist/updateGlobal.js +39 -0
  59. package/dist/updateGlobalVersion.js +50 -0
  60. package/dist/updateVersion.js +50 -0
  61. package/dist/upsertRow/deleteExistingArrayRows.js +20 -0
  62. package/dist/upsertRow/deleteExistingRowsByPath.js +43 -0
  63. package/dist/upsertRow/index.js +243 -0
  64. package/dist/upsertRow/insertArrays.js +64 -0
  65. package/dist/upsertRow/types.js +6 -0
  66. package/dist/utilities/appendPrefixToKeys.js +16 -0
  67. package/dist/utilities/createBlocksMap.js +39 -0
  68. package/dist/utilities/createMigrationTable.js +23 -0
  69. package/dist/utilities/createRelationshipMap.js +29 -0
  70. package/dist/utilities/hasLocalesTable.js +21 -0
  71. package/dist/utilities/isArrayOfRows.js +15 -0
  72. package/dist/utilities/migrationTableExists.js +19 -0
  73. package/dist/webpack.js +30 -0
  74. package/package.json +47 -0
@@ -0,0 +1,430 @@
1
+ /* eslint-disable no-param-reassign */ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "traverseFields", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return traverseFields;
9
+ }
10
+ });
11
+ const _drizzleorm = require("drizzle-orm");
12
+ const _pgcore = require("drizzle-orm/pg-core");
13
+ const _errors = require("payload/errors");
14
+ const _types = require("payload/types");
15
+ const _tosnakecase = /*#__PURE__*/ _interop_require_default(require("to-snake-case"));
16
+ const _hasLocalesTable = require("../utilities/hasLocalesTable");
17
+ const _build = require("./build");
18
+ const _createIndex = require("./createIndex");
19
+ const _parentIDColumnMap = require("./parentIDColumnMap");
20
+ const _validateExistingBlockIsIdentical = require("./validateExistingBlockIsIdentical");
21
+ function _interop_require_default(obj) {
22
+ return obj && obj.__esModule ? obj : {
23
+ default: obj
24
+ };
25
+ }
26
+ const traverseFields = ({ adapter, buildRelationships, columnPrefix, columns, disableUnique = false, fieldPrefix, fields, forceLocalized, indexes, localesColumns, localesIndexes, newTableName, parentTableName, relationsToBuild, relationships, rootRelationsToBuild, rootTableIDColType, rootTableName })=>{
27
+ let hasLocalizedField = false;
28
+ let hasLocalizedRelationshipField = false;
29
+ let hasManyNumberField = false;
30
+ let hasLocalizedManyNumberField = false;
31
+ let parentIDColType = 'integer';
32
+ if (columns.id instanceof _pgcore.PgNumericBuilder) parentIDColType = 'numeric';
33
+ if (columns.id instanceof _pgcore.PgVarcharBuilder) parentIDColType = 'varchar';
34
+ fields.forEach((field)=>{
35
+ if ('name' in field && field.name === 'id') return;
36
+ let columnName;
37
+ let fieldName;
38
+ let targetTable = columns;
39
+ let targetIndexes = indexes;
40
+ if ((0, _types.fieldAffectsData)(field)) {
41
+ columnName = `${columnPrefix || ''}${field.name[0] === '_' ? '_' : ''}${(0, _tosnakecase.default)(field.name)}`;
42
+ fieldName = `${fieldPrefix || ''}${field.name}`;
43
+ // If field is localized,
44
+ // add the column to the locale table instead of main table
45
+ if (adapter.payload.config.localization && (field.localized || forceLocalized)) {
46
+ hasLocalizedField = true;
47
+ targetTable = localesColumns;
48
+ targetIndexes = localesIndexes;
49
+ }
50
+ if ((field.unique || field.index) && ![
51
+ 'array',
52
+ 'blocks',
53
+ 'group',
54
+ 'point',
55
+ 'relationship',
56
+ 'upload'
57
+ ].includes(field.type) && !(field.type === 'number' && field.hasMany === true)) {
58
+ targetIndexes[`${field.name}Idx`] = (0, _createIndex.createIndex)({
59
+ name: fieldName,
60
+ columnName,
61
+ unique: disableUnique !== true && field.unique
62
+ });
63
+ }
64
+ }
65
+ switch(field.type){
66
+ case 'text':
67
+ case 'email':
68
+ case 'code':
69
+ case 'textarea':
70
+ {
71
+ targetTable[fieldName] = (0, _pgcore.varchar)(columnName);
72
+ break;
73
+ }
74
+ case 'number':
75
+ {
76
+ if (field.hasMany) {
77
+ if (field.localized) {
78
+ hasLocalizedManyNumberField = true;
79
+ }
80
+ if (field.index) {
81
+ hasManyNumberField = 'index';
82
+ } else if (!hasManyNumberField) {
83
+ hasManyNumberField = true;
84
+ }
85
+ if (field.unique) {
86
+ throw new _errors.InvalidConfiguration('Unique is not supported in Postgres for hasMany number fields.');
87
+ }
88
+ } else {
89
+ targetTable[fieldName] = (0, _pgcore.numeric)(columnName);
90
+ }
91
+ break;
92
+ }
93
+ case 'richText':
94
+ case 'json':
95
+ {
96
+ targetTable[fieldName] = (0, _pgcore.jsonb)(columnName);
97
+ break;
98
+ }
99
+ case 'date':
100
+ {
101
+ targetTable[fieldName] = (0, _pgcore.timestamp)(columnName, {
102
+ mode: 'string',
103
+ precision: 3,
104
+ withTimezone: true
105
+ });
106
+ break;
107
+ }
108
+ case 'point':
109
+ {
110
+ break;
111
+ }
112
+ case 'radio':
113
+ case 'select':
114
+ {
115
+ const enumName = `enum_${newTableName}_${columnPrefix || ''}${(0, _tosnakecase.default)(field.name)}`;
116
+ adapter.enums[enumName] = (0, _pgcore.pgEnum)(enumName, field.options.map((option)=>{
117
+ if ((0, _types.optionIsObject)(option)) {
118
+ return option.value;
119
+ }
120
+ return option;
121
+ }));
122
+ if (field.type === 'select' && field.hasMany) {
123
+ const baseColumns = {
124
+ order: (0, _pgcore.integer)('order').notNull(),
125
+ parent: _parentIDColumnMap.parentIDColumnMap[parentIDColType]('parent_id').references(()=>adapter.tables[parentTableName].id, {
126
+ onDelete: 'cascade'
127
+ }).notNull(),
128
+ value: adapter.enums[enumName]('value')
129
+ };
130
+ const baseExtraConfig = {};
131
+ if (field.localized) {
132
+ baseColumns.locale = adapter.enums.enum__locales('locale').notNull();
133
+ baseExtraConfig.parentOrderLocale = (cols)=>(0, _pgcore.unique)().on(cols.parent, cols.order, cols.locale);
134
+ } else {
135
+ baseExtraConfig.parent = (cols)=>(0, _pgcore.index)('parent_idx').on(cols.parent);
136
+ baseExtraConfig.order = (cols)=>(0, _pgcore.index)('order_idx').on(cols.order);
137
+ }
138
+ if (field.index) {
139
+ baseExtraConfig.value = (cols)=>(0, _pgcore.index)('value_idx').on(cols.value);
140
+ }
141
+ const selectTableName = `${newTableName}_${(0, _tosnakecase.default)(fieldName)}`;
142
+ (0, _build.buildTable)({
143
+ adapter,
144
+ baseColumns,
145
+ baseExtraConfig,
146
+ disableUnique,
147
+ fields: [],
148
+ tableName: selectTableName
149
+ });
150
+ relationsToBuild.set(fieldName, selectTableName);
151
+ const selectTableRelations = (0, _drizzleorm.relations)(adapter.tables[selectTableName], ({ one })=>{
152
+ const result = {
153
+ parent: one(adapter.tables[parentTableName], {
154
+ fields: [
155
+ adapter.tables[selectTableName].parent
156
+ ],
157
+ references: [
158
+ adapter.tables[parentTableName].id
159
+ ]
160
+ })
161
+ };
162
+ return result;
163
+ });
164
+ adapter.relations[`relation_${selectTableName}`] = selectTableRelations;
165
+ } else {
166
+ targetTable[fieldName] = adapter.enums[enumName](fieldName);
167
+ }
168
+ break;
169
+ }
170
+ case 'checkbox':
171
+ {
172
+ targetTable[fieldName] = (0, _pgcore.boolean)(columnName);
173
+ break;
174
+ }
175
+ case 'array':
176
+ {
177
+ const baseColumns = {
178
+ _order: (0, _pgcore.integer)('_order').notNull(),
179
+ _parentID: _parentIDColumnMap.parentIDColumnMap[parentIDColType]('_parent_id').references(()=>adapter.tables[parentTableName].id, {
180
+ onDelete: 'cascade'
181
+ }).notNull()
182
+ };
183
+ const baseExtraConfig = {};
184
+ if (field.localized && adapter.payload.config.localization) {
185
+ baseColumns._locale = adapter.enums.enum__locales('_locale').notNull();
186
+ baseExtraConfig._parentOrderLocale = (cols)=>(0, _pgcore.unique)().on(cols._parentID, cols._order, cols._locale);
187
+ } else {
188
+ baseExtraConfig._parentOrder = (cols)=>(0, _pgcore.unique)().on(cols._parentID, cols._order);
189
+ }
190
+ const arrayTableName = `${newTableName}_${(0, _tosnakecase.default)(field.name)}`;
191
+ const { relationsToBuild: subRelationsToBuild } = (0, _build.buildTable)({
192
+ adapter,
193
+ baseColumns,
194
+ baseExtraConfig,
195
+ disableUnique,
196
+ fields: field.fields,
197
+ rootRelationsToBuild,
198
+ rootTableIDColType,
199
+ rootTableName,
200
+ tableName: arrayTableName
201
+ });
202
+ relationsToBuild.set(fieldName, arrayTableName);
203
+ const arrayTableRelations = (0, _drizzleorm.relations)(adapter.tables[arrayTableName], ({ many, one })=>{
204
+ const result = {
205
+ _parentID: one(adapter.tables[parentTableName], {
206
+ fields: [
207
+ adapter.tables[arrayTableName]._parentID
208
+ ],
209
+ references: [
210
+ adapter.tables[parentTableName].id
211
+ ]
212
+ })
213
+ };
214
+ if ((0, _hasLocalesTable.hasLocalesTable)(field.fields)) {
215
+ result._locales = many(adapter.tables[`${arrayTableName}_locales`]);
216
+ }
217
+ subRelationsToBuild.forEach((val, key)=>{
218
+ result[key] = many(adapter.tables[val]);
219
+ });
220
+ return result;
221
+ });
222
+ adapter.relations[`relations_${arrayTableName}`] = arrayTableRelations;
223
+ break;
224
+ }
225
+ case 'blocks':
226
+ {
227
+ field.blocks.forEach((block)=>{
228
+ const blockTableName = `${rootTableName}_blocks_${(0, _tosnakecase.default)(block.slug)}`;
229
+ if (!adapter.tables[blockTableName]) {
230
+ const baseColumns = {
231
+ _order: (0, _pgcore.integer)('_order').notNull(),
232
+ _parentID: _parentIDColumnMap.parentIDColumnMap[rootTableIDColType]('_parent_id').references(()=>adapter.tables[rootTableName].id, {
233
+ onDelete: 'cascade'
234
+ }).notNull(),
235
+ _path: (0, _pgcore.text)('_path').notNull()
236
+ };
237
+ const baseExtraConfig = {};
238
+ if (field.localized && adapter.payload.config.localization) {
239
+ baseColumns._locale = adapter.enums.enum__locales('_locale').notNull();
240
+ baseExtraConfig._parentPathOrderLocale = (cols)=>(0, _pgcore.unique)().on(cols._parentID, cols._path, cols._order, cols._locale);
241
+ } else {
242
+ baseExtraConfig._parentPathOrder = (cols)=>(0, _pgcore.unique)().on(cols._parentID, cols._path, cols._order);
243
+ }
244
+ const { relationsToBuild: subRelationsToBuild } = (0, _build.buildTable)({
245
+ adapter,
246
+ baseColumns,
247
+ baseExtraConfig,
248
+ disableUnique,
249
+ fields: block.fields,
250
+ rootRelationsToBuild,
251
+ rootTableIDColType,
252
+ rootTableName,
253
+ tableName: blockTableName
254
+ });
255
+ const blockTableRelations = (0, _drizzleorm.relations)(adapter.tables[blockTableName], ({ many, one })=>{
256
+ const result = {
257
+ _parentID: one(adapter.tables[rootTableName], {
258
+ fields: [
259
+ adapter.tables[blockTableName]._parentID
260
+ ],
261
+ references: [
262
+ adapter.tables[rootTableName].id
263
+ ]
264
+ })
265
+ };
266
+ if ((0, _hasLocalesTable.hasLocalesTable)(block.fields)) {
267
+ result._locales = many(adapter.tables[`${blockTableName}_locales`]);
268
+ }
269
+ subRelationsToBuild.forEach((val, key)=>{
270
+ result[key] = many(adapter.tables[val]);
271
+ });
272
+ return result;
273
+ });
274
+ adapter.relations[`relations_${blockTableName}`] = blockTableRelations;
275
+ } else if (process.env.NODE_ENV !== 'production') {
276
+ (0, _validateExistingBlockIsIdentical.validateExistingBlockIsIdentical)({
277
+ block,
278
+ localized: field.localized,
279
+ rootTableName,
280
+ table: adapter.tables[blockTableName]
281
+ });
282
+ }
283
+ rootRelationsToBuild.set(`_blocks_${block.slug}`, blockTableName);
284
+ });
285
+ break;
286
+ }
287
+ case 'tab':
288
+ case 'group':
289
+ {
290
+ if (!('name' in field)) {
291
+ const { hasLocalizedField: groupHasLocalizedField, hasLocalizedManyNumberField: groupHasLocalizedManyNumberField, hasLocalizedRelationshipField: groupHasLocalizedRelationshipField, hasManyNumberField: groupHasManyNumberField } = traverseFields({
292
+ adapter,
293
+ buildRelationships,
294
+ columnPrefix,
295
+ columns,
296
+ disableUnique,
297
+ fieldPrefix,
298
+ fields: field.fields,
299
+ forceLocalized,
300
+ indexes,
301
+ localesColumns,
302
+ localesIndexes,
303
+ newTableName: parentTableName,
304
+ parentTableName,
305
+ relationsToBuild,
306
+ relationships,
307
+ rootRelationsToBuild,
308
+ rootTableIDColType,
309
+ rootTableName
310
+ });
311
+ if (groupHasLocalizedField) hasLocalizedField = true;
312
+ if (groupHasLocalizedRelationshipField) hasLocalizedRelationshipField = true;
313
+ if (groupHasManyNumberField) hasManyNumberField = true;
314
+ if (groupHasLocalizedManyNumberField) hasLocalizedManyNumberField = true;
315
+ break;
316
+ }
317
+ const { hasLocalizedField: groupHasLocalizedField, hasLocalizedManyNumberField: groupHasLocalizedManyNumberField, hasLocalizedRelationshipField: groupHasLocalizedRelationshipField, hasManyNumberField: groupHasManyNumberField } = traverseFields({
318
+ adapter,
319
+ buildRelationships,
320
+ columnPrefix: `${columnName}_`,
321
+ columns,
322
+ disableUnique,
323
+ fieldPrefix: `${fieldName}_`,
324
+ fields: field.fields,
325
+ forceLocalized: field.localized,
326
+ indexes,
327
+ localesColumns,
328
+ localesIndexes,
329
+ newTableName: `${parentTableName}_${columnName}`,
330
+ parentTableName,
331
+ relationsToBuild,
332
+ relationships,
333
+ rootRelationsToBuild,
334
+ rootTableIDColType,
335
+ rootTableName
336
+ });
337
+ if (groupHasLocalizedField) hasLocalizedField = true;
338
+ if (groupHasLocalizedRelationshipField) hasLocalizedRelationshipField = true;
339
+ if (groupHasManyNumberField) hasManyNumberField = true;
340
+ if (groupHasLocalizedManyNumberField) hasLocalizedManyNumberField = true;
341
+ break;
342
+ }
343
+ case 'tabs':
344
+ {
345
+ const { hasLocalizedField: tabHasLocalizedField, hasLocalizedManyNumberField: tabHasLocalizedManyNumberField, hasLocalizedRelationshipField: tabHasLocalizedRelationshipField, hasManyNumberField: tabHasManyNumberField } = traverseFields({
346
+ adapter,
347
+ buildRelationships,
348
+ columnPrefix,
349
+ columns,
350
+ disableUnique,
351
+ fieldPrefix,
352
+ fields: field.tabs.map((tab)=>({
353
+ ...tab,
354
+ type: 'tab'
355
+ })),
356
+ forceLocalized,
357
+ indexes,
358
+ localesColumns,
359
+ localesIndexes,
360
+ newTableName,
361
+ parentTableName,
362
+ relationsToBuild,
363
+ relationships,
364
+ rootRelationsToBuild,
365
+ rootTableIDColType,
366
+ rootTableName
367
+ });
368
+ if (tabHasLocalizedField) hasLocalizedField = true;
369
+ if (tabHasLocalizedRelationshipField) hasLocalizedRelationshipField = true;
370
+ if (tabHasManyNumberField) hasManyNumberField = true;
371
+ if (tabHasLocalizedManyNumberField) hasLocalizedManyNumberField = true;
372
+ break;
373
+ }
374
+ case 'row':
375
+ case 'collapsible':
376
+ {
377
+ const { hasLocalizedField: rowHasLocalizedField, hasLocalizedManyNumberField: rowHasLocalizedManyNumberField, hasLocalizedRelationshipField: rowHasLocalizedRelationshipField, hasManyNumberField: rowHasManyNumberField } = traverseFields({
378
+ adapter,
379
+ buildRelationships,
380
+ columnPrefix,
381
+ columns,
382
+ disableUnique,
383
+ fieldPrefix,
384
+ fields: field.fields,
385
+ forceLocalized,
386
+ indexes,
387
+ localesColumns,
388
+ localesIndexes,
389
+ newTableName: parentTableName,
390
+ parentTableName,
391
+ relationsToBuild,
392
+ relationships,
393
+ rootRelationsToBuild,
394
+ rootTableIDColType,
395
+ rootTableName
396
+ });
397
+ if (rowHasLocalizedField) hasLocalizedField = true;
398
+ if (rowHasLocalizedRelationshipField) hasLocalizedRelationshipField = true;
399
+ if (rowHasManyNumberField) hasManyNumberField = true;
400
+ if (rowHasLocalizedManyNumberField) hasLocalizedManyNumberField = true;
401
+ break;
402
+ }
403
+ case 'relationship':
404
+ case 'upload':
405
+ if (Array.isArray(field.relationTo)) {
406
+ field.relationTo.forEach((relation)=>relationships.add(relation));
407
+ } else {
408
+ relationships.add(field.relationTo);
409
+ }
410
+ if (field.localized && adapter.payload.config.localization) {
411
+ hasLocalizedRelationshipField = true;
412
+ }
413
+ break;
414
+ default:
415
+ break;
416
+ }
417
+ const condition = field.admin && field.admin.condition;
418
+ if (targetTable[fieldName] && 'required' in field && field.required && !condition) {
419
+ targetTable[fieldName].notNull();
420
+ }
421
+ });
422
+ return {
423
+ hasLocalizedField,
424
+ hasLocalizedManyNumberField,
425
+ hasLocalizedRelationshipField,
426
+ hasManyNumberField
427
+ };
428
+ };
429
+
430
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zY2hlbWEvdHJhdmVyc2VGaWVsZHMudHMiXSwic291cmNlc0NvbnRlbnQiOlsiLyogZXNsaW50LWRpc2FibGUgbm8tcGFyYW0tcmVhc3NpZ24gKi9cbmltcG9ydCB0eXBlIHsgUmVsYXRpb24gfSBmcm9tICdkcml6emxlLW9ybSdcbmltcG9ydCB0eXBlIHsgSW5kZXhCdWlsZGVyLCBQZ0NvbHVtbkJ1aWxkZXIsIFVuaXF1ZUNvbnN0cmFpbnRCdWlsZGVyIH0gZnJvbSAnZHJpenpsZS1vcm0vcGctY29yZSdcbmltcG9ydCB0eXBlIHsgRmllbGQsIFRhYkFzRmllbGQgfSBmcm9tICdwYXlsb2FkL3R5cGVzJ1xuXG5pbXBvcnQgeyByZWxhdGlvbnMgfSBmcm9tICdkcml6emxlLW9ybSdcbmltcG9ydCB7XG4gIFBnTnVtZXJpY0J1aWxkZXIsXG4gIFBnVmFyY2hhckJ1aWxkZXIsXG4gIGJvb2xlYW4sXG4gIGluZGV4LFxuICBpbnRlZ2VyLFxuICBqc29uYixcbiAgbnVtZXJpYyxcbiAgcGdFbnVtLFxuICB0ZXh0LFxuICB0aW1lc3RhbXAsXG4gIHVuaXF1ZSxcbiAgdmFyY2hhcixcbn0gZnJvbSAnZHJpenpsZS1vcm0vcGctY29yZSdcbmltcG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G4gICAgICAgIGJyZWFrXG4gICAgICB9XG5cbiAgICAgIGNhc2UgJ3JpY2hUZXh0JzpcbiAgICAgIGNhc2UgJ2pzb24nOiB7XG4gICAgICAgIHRhcmdldFRhYmxlW2ZpZWxkTmFtZV0gPSBqc29uYihjb2x1bW5OYW1lKVxuICAgICAgICBicmVha1xuICAgICAgfVxuXG4gICAgICBjYXNlICdkYXRlJzoge1xuICAgICAgICB0YXJnZXRUYWJsZVtmaWVsZE5hbWVdID0gdGltZXN0YW1wKGNvbHVtbk5hbWUsIHtcbiAgICAgICAgICBtb2RlOiAnc3RyaW5nJyxcbiAgICAgICAgICBwcmVjaXNpb246IDMsXG4gICAgICAgICAgd2l0aFRpbWV6b25lOiB0cnVlLFxuICAgICAgICB9KVxuICAgICAgICBicmVha1xuICAgICAgfVxuXG4gICAgICBjYXNlICdwb2ludCc6IHtcbiAgICAgICAgYnJlYWtcbiAgICAgIH1cblxuICAgICAgY2FzZSAncmFkaW8nOlxuICAgICAgY2FzZSAnc2VsZWN0Jzoge1xuICAgICAgICBjb25zdCBlbnVtTmFtZSA9IGBlbnVtXyR7bmV3VGFibGVOYW1lfV8ke2NvbHVtblByZWZpeCB8fCAnJ30ke3RvU25ha2VDYXNlKGZpZWxkLm5hbWUpfWBcblxuICAgICAgICBhZGFwdGVyLmVudW1zW2VudW1OYW1lXSA9IHBnRW51bShcbiAgICAgICAgICBlbnVtTmFtZSxcbiAgICAgICAgICBmaWVsZC5vcHRpb25zLm1hcCgob3B0aW9uKSA9PiB7XG4gICAgICAgICAgICBpZiAob3B0aW9uSXNPYmplY3Qob3B0aW9uKSkge1xuICAgICAgICAgICAgICByZXR1cm4gb3B0aW9uLnZhbHVlXG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHJldHVybiBvcHRpb25cbiAgICAgICAgICB9KSBhcyBbc3RyaW5nLCAuLi5zdHJpbmdbXV0sXG4gICAgICAgIClcblxuICAgICAgICBpZiAoZmllbGQudHlwZSA9PT0gJ3NlbGVjdCcgJiYgZmllbGQuaGFzTWFueSkge1xuICAgICAgICAgIGNvbnN0IGJhc2VDb2x1bW5zOiBSZWNvcmQ8c3RyaW5nLCBQZ0NvbHVtbkJ1aWxkZXI+ID0ge1xuICAgICAgICAgICAgb3JkZXI6IGludGVnZXIoJ29yZGVyJykubm90TnVsbCgpLFxuICAgICAgICAgICAgcGFyZW50OiBwYXJlbnRJRENvbHVtbk1hcFtwYXJlbnRJRENvbFR5cGVdKCdwYXJlbnRfaWQnKVxuICAgICAgICAgICAgICAucmVmZXJlbmNlcygoKSA9PiBhZGFwdGVyLnRhYmxlc1twYXJlbnRUYWJsZU5hbWVdLmlkLCB7IG9uRGVsZXRlOiAnY2FzY2FkZScgfSlcbiAgICAgICAgICAgICAgLm5vdE51bGwoKSxcbiAgICAgICAgICAgIHZhbHVlOiBhZGFwdGVyLmVudW1zW2VudW1OYW1lXSgndmFsdWUnKSxcbiAgICAgICAgICB9XG5cbiAgICAgICAgICBjb25zdCBiYXNlRXh0cmFDb25maWc6IFJlY29yZDxcbiAgICAgICAgICAgIHN0cmluZyxcbiAgICAgICAgICAgIChjb2xzOiBHZW5lcmljQ29sdW1ucykgPT4gSW5kZXhCdWlsZGVyIHwgVW5pcXVlQ29uc3RyYWludEJ1aWxkZXJcbiAgICAgICAgICA+ID0ge31cblxuICAgICAgICAgIGlmIChmaWVsZC5sb2NhbGl6ZWQpIHtcbiAgICAgICAgICAgIGJhc2VDb2x1bW5zLmxvY2FsZSA9IGFkYXB0ZXIuZW51bXMuZW51bV9fbG9jYWxlcygnbG9jYWxlJykubm90TnVsbCgpXG4gICAgICAgICAgICBiYXNlRXh0cmFDb25maWcucGFyZW50T3JkZXJMb2NhbGUgPSAoY29scykgPT5cbiAgICAgICAgICAgICAgdW5pcXVlKCkub24oY29scy5wYXJlbnQsIGNvbHMub3JkZXIsIGNvbHMubG9jYWxlKVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBiYXNlRXh0cmFDb25maWcucGFyZW50ID0gKGNvbHMpID0+IGluZGV4KCdwYXJlbnRfaWR4Jykub24oY29scy5wYXJlbnQpXG4gICAgICAgICAgICBiYXNlRXh0cmFDb25maWcub3JkZXIgPSAoY29scykgPT4gaW5kZXgoJ29yZGVyX2lkeCcpLm9uKGNvbHMub3JkZXIpXG4gICAgICAgICAgfVxuXG4gICAgICAgICAgaWYgKGZpZWxkLmluZGV4KSB7XG4gICAgICAgICAgICBiYXNlRXh0cmFDb25maWcudmFsdWUgPSAoY29scykgPT4gaW5kZXgoJ3ZhbHVlX2lkeCcpLm9uKGNvbHMudmFsdWUpXG4gICAgICAgICAgfVxuXG4gICAgICAgICAgY29uc3Qgc2VsZWN0VGFibGVOYW1lID0gYCR7bmV3VGFibGVOYW1lfV8ke3RvU25ha2VDYXNlKGZpZWxkTmFtZSl9YFxuXG4gICAgICAgICAgYnVpbGRUYWJsZSh7XG4gICAgICAgICAgICBhZGFwdGVyLFxuICAgICAgICAgICAgYmFzZUNvbHVtbnMsXG4gICAgICAgICAgICBiYXNlRXh0cmFDb25maWcsXG4gICAgICAgICAgICBkaXNhYmxlVW5pcXVlLFxuICAgICAgICAgICAgZmllbGRzOiBbXSxcbiAgICAgICAgICAgIHRhYmxlTmFtZTogc2VsZWN0VGFibGVOYW1lLFxuICAgICAgICAgIH0pXG5cbiAgICAgICAgICByZWxhdGlvbnNUb0J1aWxkLnNldChmaWVsZE5hbWUsIHNlbGVjdFRhYmxlTmFtZSlcblxuICAgICAgICAgIGNvbnN0IHNlbGVjdFRhYmxlUmVsYXRpb25zID0gcmVsYXRpb25zKGFkYXB0ZXIudGFibGVzW3NlbGVjdFRhYmxlTmFtZV0sICh7IG9uZSB9KSA9PiB7XG4gICAgICAgICAgICBjb25zdCByZXN1bHQ6IFJlY29yZDxzdHJpbmcsIFJlbGF0aW9uPHN0cmluZz4+ID0ge1xuICAgICAgICAgICAgICBwYXJlbnQ6IG9uZShhZGFwdGVyLnRhYmxlc1twYXJlbnRUYWJsZU5hbWVdLCB7XG4gICAgICAgICAgICAgICAgZmllbGRzOiBbYWRhcHRlci50YWJsZXNbc2VsZWN0VGFibGVOYW1lXS5wYXJlbnRdLFxuICAgICAgICAgICAgICAgIHJlZmVyZW5jZXM6IFthZGFwdGVyLnRhYmxlc1twYXJlbnRUYWJsZU5hbWVdLmlkXSxcbiAgICAgICAgICAgICAgfSksXG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHJldHVybiByZXN1bHRcbiAgICAgICAgICB9KVxuXG4gICAgICAgICAgYWRhcHRlci5yZWxhdGlvbnNbYHJlbGF0aW9uXyR7c2VsZWN0VGFibGVOYW1lfWBdID0gc2VsZWN0VGFibGVSZWxhdGlvbnNcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICB0YXJnZXRUYWJsZVtmaWVsZE5hbWVdID0gYWRhcHRlci5lbnVtc1tlbnVtTmFtZV0oZmllbGROYW1lKVxuICAgICAgICB9XG4gICAgICAgIGJyZWFrXG4gICAgICB9XG5cbiAgICAgIGNhc2UgJ2NoZWNrYm94Jzoge1xuICAgICAgICB0YXJnZXRUYWJsZVtmaWVsZE5hbWVdID0gYm9vbGVhbihjb2x1bW5OYW1lKVxuICAgICAgICBicmVha1xuICAgICAgfVxuXG4gICAgICBjYXNlICdhcnJheSc6IHtcbiAgICAgICAgY29uc3QgYmFzZUNvbHVtbnM6IFJlY29yZDxzdHJpbmcsIFBnQ29sdW1uQnVpbGRlcj4gPSB7XG4gICAgICAgICAgX29yZGVyOiBpbnRlZ2VyKCdfb3JkZXInKS5ub3ROdWxsKCksXG4gICAgICAgICAgX3BhcmVudElEOiBwYXJlbnRJRENvbHVtbk1hcFtwYXJlbnRJRENvbFR5cGVdKCdfcGFyZW50X2lkJylcbiAgICAgICAgICAgIC5yZWZlcmVuY2VzKCgpID0+IGFkYXB0ZXIudGFibGVzW3BhcmVudFRhYmxlTmFtZV0uaWQsIHsgb25EZWxldGU6ICdjYXNjYWRlJyB9KVxuICAgICAgICA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xuICAgICAgICAgIGZpZWxkczogZmllbGQuZmllbGRzLFxuICAgICAgICAgIHJvb3RSZWxhdGlvbnNUb0J1aWxkLFxuICAgICAgICAgIHJvb3RUYWJsZUlEQ29sVHlwZSxcbiAgICAgICAgICByb290VGFibGVOYW1lLFxuICAgICAgICAgIHRhYmxlTmFtZTogYXJyYXlUYWJsZU5hbWUsXG4gICAgICAgIH0pXG5cbiAgICAgICAgcmVsYXRpb25zVG9CdWlsZC5zZXQoZmllbGROYW1lLCBhcnJheVRhYmxlTmFtZSlcblxuICAgICAgICBjb25zdCBhcnJheVRhYmxlUmVsYXRpb25zID0gcmVsYXRpb25zKGFkYXB0ZXIudGFibGVzW2FycmF5VGFibGVOYW1lXSwgKHsgbWFueSwgb25lIH0pID0+IHtcbiAgICAgICAgICBjb25zdCByZXN1bHQ6IFJlY29yZDxzdHJpbmcsIFJlbGF0aW9uPHN0cmluZz4+ID0ge1xuICAgICAgICAgICAgX3BhcmVudElEOiBvbmUoYWRhcHRlci50YWJsZXNbcGFyZW50VGFibGVOYW1lXSwge1xuICAgICAgICAgICAgICBmaWVsZHM6IFthZGFwdGVyLnRhYmxlc1thcnJheVRhYmxlTmFtZV0uX3BhcmVudElEXSxcbiAgICAgICAgICAgICAgcmVmZXJlbmNlczogW2FkYXB0ZXIudGFibGVzW3BhcmVudFRhYmxlTmFtZV0uaWRdLFxuICAgICAgICAgICAgfSksXG4gICAgICAgICAgfVxuXG4gICAgICAgICAgaWYgKGhhc0xvY2FsZXNUYWJsZShmaWVsZC5maWVsZHMpKSB7XG4gICAgICAgICAgICByZXN1bHQuX2xvY2FsZXMgPSBtYW55KGFkYXB0ZXIudGFibGVzW2Ake2FycmF5VGFibGVOYW1lfV9sb2NhbGVzYF0pXG4gICAgICAgICAgfVxuXG4gICAgICAgICAgc3ViUmVsYXRpb25zVG9CdWlsZC5mb3JFYWNoKCh2YWwsIGtleSkgPT4ge1xuICAgICAgICAgICAgcmVzdWx0W2tleV0gPSBtYW55KGFk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gICAgICAgICAgIChjb2xzOiBHZW5lcmljQ29sdW1ucykgPT4gSW5kZXhCdWlsZGVyIHwgVW5pcXVlQ29uc3RyYWludEJ1aWxkZXJcbiAgICAgICAgICAgID4gPSB7fVxuXG4gICAgICAgICAgICBpZiAoZmllbGQubG9jYWxpemVkICYmIGFkYXB0ZXIucGF5bG9hZC5jb25maWcubG9jYWxpemF0aW9uKSB7XG4gICAgICAgICAgICAgIGJhc2VDb2x1bW5zLl9sb2NhbGUgPSBhZGFwdGVyLmVudW1zLmVudW1fX2xvY2FsZXMoJ19sb2NhbGUnKS5ub3ROdWxsKClcbiAgICAgICAgICAgICAgYmFzZUV4dHJhQ29uZmlnLl9wYXJlbnRQYXRoT3JkZXJMb2NhbGUgPSAoY29scykgPT5cbiAgICAgICAgICAgICAgICB1bmlxdWUoKS5vbihjb2xzLl9wYXJlbnRJRCwgY29scy5fcGF0aCwgY29scy5fb3JkZXIsIGNvbHMuX2xvY2FsZSlcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIGJhc2VFeHRyYUNvbmZpZy5fcGFyZW50UGF0aE9yZGVyID0gKGNvbHMpID0+XG4gICAgICAgICAgICAgICAgdW5pcXVlKCkub24oY29scy5fcGFyZW50SUQsIGNvbHMuX3BhdGgsIGNvbHMuX29yZGVyKVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBjb25zdCB7IHJlbGF0aW9uc1RvQnVpbGQ6IHN1YlJlbGF0aW9uc1RvQnVpbGQgfSA9IGJ1aWxkVGFibGUoe1xuICAgICAgICAgICAgICBhZGFwdGVyLFxuICAgICAgICAgICAgICBiYXNlQ29sdW1ucyxcbiAgICAgICAgICAgICAgYmFzZUV4dHJhQ29uZmlnLFxuICAgICAgICAgICAgICBkaXNhYmxlVW5pcXVlLFxuICAgICAgICAgICAgICBmaWVsZHM6IGJsb2NrLmZpZWxkcyxcbiAgICAgICAgICAgICAgcm9vdFJlbGF0aW9uc1RvQnVpbGQsXG4gICAgICAgICAgICAgIHJvb3RUYWJsZUlEQ29sVHlwZSxcbiAgICAgICAgICAgICAgcm9vdFRhYmxlTmFtZSxcbiAgICAgICAgICAgICAgdGFibGVOYW1lOiBibG9ja1RhYmxlTmFtZSxcbiAgICAgICAgICAgIH0pXG5cbiAgICAgICAgICAgIGNvbnN0IGJsb2NrVGFibGVSZWxhdGlvbnMgPSByZWxhdGlvbnMoXG4gICAgICAgICAgICAgIGFkYXB0ZXIudGFibGVzW2Jsb2NrVGFibGVOYW1lXSxcbiAgICAgICAgICAgICAgKHsgbWFueSwgb25lIH0pID0+IHtcbiAgICAgICAgICAgICAgICBjb25zdCByZXN1bHQ6IFJlY29yZDxzdHJpbmcsIFJlbGF0aW9uPHN0cmluZz4+ID0ge1xuICAgICAgICAgICAgICAgICAgX3BhcmVudElEOiBvbmUoYWRhcHRlci50YWJsZXNbcm9vdFRhYmxlTmFtZV0sIHtcbiAgICAgICAgICAgICAgICAgICAgZmllbGRzOiBbYWRhcHRlci50YWJsZXNbYmxvY2tUYWJsZU5hbWVdLl9wYXJlbnRJRF0sXG4gICAgICAgICAgICAgICAgICAgIHJlZmVyZW5jZXM6IFthZGFwdGVyLnRhYmxlc1tyb290VGFibGVOYW1lXS5pZF0sXG4gICAgICAgICAgICAgICAgICB9KSxcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAoaGFzTG9jYWxlc1RhYmxlKGJsb2NrLmZpZWxkcykpIHtcbiAgICAgICAgICAgICAgICAgIHJlc3VsdC5fbG9jYWxlcyA9IG1hbnkoYWRhcHRlci50YWJsZXNbYCR7YmxvY2tUYWJsZU5hbWV9X2xvY2FsZXNgXSlcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBzdWJSZWxhdGlvbnNUb0J1aWxkLmZvckVhY2goKHZhbCwga2V5KSA9PiB7XG4gICAgICAgICAgICAgICAgICByZXN1bHRba2V5XSA9IG1hbnkoYWRhcHRlci50YWJsZXNbdmFsX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QUNBQztvQkFDRjtvQkFFQSxJQUFJeUcsc0JBQXNCeEcsb0JBQW9CO29CQUM5QyxJQUFJMEcsa0NBQWtDekcsZ0NBQWdDO29CQUN0RSxJQUFJMEcsdUJBQXVCekcscUJBQXFCO29CQUNoRCxJQUFJdUcsZ0NBQWdDdEcsOEJBQThCO29CQUNsRTtnQkFDRjtZQUVBLEtBQUs7WUFDTCxLQUFLO2dCQUNILElBQUl5RyxNQUFNQyxPQUFPLENBQUNwRyxNQUFNcUcsVUFBVSxHQUFHO29CQUNuQ3JHLE1BQU1xRyxVQUFVLENBQUN0RyxPQUFPLENBQUMsQ0FBQ3VHLFdBQWFuSCxjQUFjb0gsR0FBRyxDQUFDRDtnQkFDM0QsT0FBTztvQkFDTG5ILGNBQWNvSCxHQUFHLENBQUN2RyxNQUFNcUcsVUFBVTtnQkFDcEM7Z0JBRUEsSUFBSXJHLE1BQU1XLFNBQVMsSUFBSXRDLFFBQVFtQyxPQUFPLENBQUNDLE1BQU0sQ0FBQ0MsWUFBWSxFQUFFO29CQUMxRGxCLGdDQUFnQztnQkFDbEM7Z0JBQ0E7WUFFRjtnQkFDRTtRQUNKO1FBRUEsTUFBTWdILFlBQVl4RyxNQUFNeUcsS0FBSyxJQUFJekcsTUFBTXlHLEtBQUssQ0FBQ0QsU0FBUztRQUV0RCxJQUFJcEcsV0FBVyxDQUFDRCxVQUFVLElBQUksY0FBY0gsU0FBU0EsTUFBTTBHLFFBQVEsSUFBSSxDQUFDRixXQUFXO1lBQ2pGcEcsV0FBVyxDQUFDRCxVQUFVLENBQUNrQyxPQUFPO1FBQ2hDO0lBQ0Y7SUFFQSxPQUFPO1FBQ0w5QztRQUNBRztRQUNBRjtRQUNBQztJQUNGO0FBQ0YifQ==
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "validateExistingBlockIsIdentical", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return validateExistingBlockIsIdentical;
9
+ }
10
+ });
11
+ const _errors = require("payload/errors");
12
+ const _utilities = require("payload/utilities");
13
+ const validateExistingBlockIsIdentical = ({ block, localized, rootTableName, table })=>{
14
+ if (table) {
15
+ const fieldNames = (0, _utilities.flattenTopLevelFields)(block.fields).flatMap((field)=>field.name);
16
+ Object.keys(table).forEach((fieldName)=>{
17
+ if (![
18
+ '_locale',
19
+ '_order',
20
+ '_parentID',
21
+ '_path'
22
+ ].includes(fieldName)) {
23
+ if (fieldNames.indexOf(fieldName) === -1) {
24
+ throw new _errors.InvalidConfiguration(`The table ${rootTableName} has multiple blocks with slug ${block.slug}, but the schemas do not match. One block includes the field ${fieldName}, while the other block does not.`);
25
+ }
26
+ }
27
+ });
28
+ if (Boolean(localized) !== Boolean(table._locale)) {
29
+ throw new _errors.InvalidConfiguration(`The table ${rootTableName} has multiple blocks with slug ${block.slug}, but the schemas do not match. One is localized, but another is not. Block schemas of the same name must match exactly.`);
30
+ }
31
+ }
32
+ };
33
+
34
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zY2hlbWEvdmFsaWRhdGVFeGlzdGluZ0Jsb2NrSXNJZGVudGljYWwudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHR5cGUgeyBCbG9jayB9IGZyb20gJ3BheWxvYWQvdHlwZXMnXG5cbmltcG9ydCB7IEludmFsaWRDb25maWd1cmF0aW9uIH0gZnJvbSAncGF5bG9hZC9lcnJvcnMnXG5pbXBvcnQgeyBmbGF0dGVuVG9wTGV2ZWxGaWVsZHMgfSBmcm9tICdwYXlsb2FkL3V0aWxpdGllcydcblxuaW1wb3J0IHR5cGUgeyBHZW5lcmljVGFibGUgfSBmcm9tICcuLi90eXBlcydcblxudHlwZSBBcmdzID0ge1xuICBibG9jazogQmxvY2tcbiAgbG9jYWxpemVkOiBib29sZWFuXG4gIHJvb3RUYWJsZU5hbWU6IHN0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JBQVU7Z0JBQWE7YUFBUSxDQUFDQyxRQUFRLENBQUNELFlBQVk7Z0JBQ3BFLElBQUlULFdBQVdXLE9BQU8sQ0FBQ0YsZUFBZSxDQUFDLEdBQUc7b0JBQ3hDLE1BQU0sSUFBSUcsNEJBQW9CLENBQzVCLENBQUMsVUFBVSxFQUFFZCxjQUFjLCtCQUErQixFQUFFRixNQUFNaUIsSUFBSSxDQUFDLDZEQUE2RCxFQUFFSixVQUFVLGlDQUFpQyxDQUFDO2dCQUV0TDtZQUNGO1FBQ0Y7UUFFQSxJQUFJSyxRQUFRakIsZUFBZWlCLFFBQVFmLE1BQU1nQixPQUFPLEdBQUc7WUFDakQsTUFBTSxJQUFJSCw0QkFBb0IsQ0FDNUIsQ0FBQyxVQUFVLEVBQUVkLGNBQWMsK0JBQStCLEVBQUVGLE1BQU1pQixJQUFJLENBQUMsd0hBQXdILENBQUM7UUFFcE07SUFDRjtBQUNGIn0=
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "beginTransaction", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return beginTransaction;
9
+ }
10
+ });
11
+ const _uuid = require("uuid");
12
+ const beginTransaction = async function beginTransaction() {
13
+ let id;
14
+ try {
15
+ id = (0, _uuid.v4)();
16
+ let reject;
17
+ let resolve;
18
+ let transaction;
19
+ let transactionReady;
20
+ // Drizzle only exposes a transactions API that is sufficient if you
21
+ // can directly pass around the `tx` argument. But our operations are spread
22
+ // over many files and we don't want to pass the `tx` around like that,
23
+ // so instead, we "lift" up the `resolve` and `reject` methods
24
+ // and will call them in our respective transaction methods
25
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
26
+ this.db.transaction(async (tx)=>{
27
+ transaction = tx;
28
+ await new Promise((res, rej)=>{
29
+ transactionReady();
30
+ resolve = res;
31
+ reject = rej;
32
+ });
33
+ }).catch(()=>{
34
+ // swallow
35
+ });
36
+ // Need to wait until the transaction is ready
37
+ // before binding its `resolve` and `reject` methods below
38
+ await new Promise((resolve)=>transactionReady = resolve);
39
+ this.sessions[id] = {
40
+ db: transaction,
41
+ reject,
42
+ resolve
43
+ };
44
+ } catch (err) {
45
+ this.payload.logger.error(`Error: cannot begin transaction: ${err.message}`, err);
46
+ process.exit(1);
47
+ }
48
+ return id;
49
+ };
50
+
51
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90cmFuc2FjdGlvbnMvYmVnaW5UcmFuc2FjdGlvbi50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgdHlwZSB7IEJlZ2luVHJhbnNhY3Rpb24gfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuXG5pbXBvcnQgeyB2NCBhcyB1dWlkIH0gZnJvbSAndXVpZCdcblxuaW1wb3J0IHR5cGUgeyBEcml6emxlVHJhbnNhY3Rpb24sIFBvc3RncmVzQWRhcHRlciB9IGZyb20gJy4uL3R5cGVzJ1xuXG5leHBvcnQgY29uc3QgYmVnaW5UcmFuc2FjdGlvbjogQmVnaW5UcmFuc2FjdGlvbiA9IGFzeW5jIGZ1bmN0aW9uIGJlZ2luVHJhbnNhY3Rpb24oXG4gIHRoaXM6IFBvc3RncmVzQWRhcHRlcixcbikge1xuICBsZXQgaWRcbiAgdHJ5IHtcbiAgICBpZCA9IHV1aWQoKVxuXG4gICAgbGV0IHJlamVjdDogKHZhbHVlPzogdW5rbm93bikgPT4gdm9pZFxuICAgIGxldCByZXNvbHZlOiAodmFsdWU/OiB1bmtub3duKSA9PiB2b2lkXG4gICAgbGV0IHRyYW5zYWN0aW9uOiBEcml6emxlVHJhbnNhY3Rpb25cblxuICAgIGxldCB0cmFuc2FjdGlvblJlYWR5OiAodmFsdWU/OiB1bmtub3duKSA9PiB2b2lkXG5cbiAgICAvLyBEcml6emxlIG9ubHkgZXhwb3NlcyBhIHRyYW5zYWN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QztnQkFDdEJMO2dCQUNBRixVQUFVTTtnQkFDVlAsU0FBU1E7WUFDWDtRQUNGLEdBQ0NDLEtBQUssQ0FBQztRQUNMLFVBQVU7UUFDWjtRQUVGLDhDQUE4QztRQUM5QywwREFBMEQ7UUFDMUQsTUFBTSxJQUFJSCxRQUFRLENBQUNMLFVBQWFFLG1CQUFtQkY7UUFFbkQsSUFBSSxDQUFDUyxRQUFRLENBQUNaLEdBQUcsR0FBRztZQUNsQk0sSUFBSUY7WUFDSkY7WUFDQUM7UUFDRjtJQUNGLEVBQUUsT0FBT1UsS0FBSztRQUNaLElBQUksQ0FBQ0MsT0FBTyxDQUFDQyxNQUFNLENBQUNDLEtBQUssQ0FBQyxDQUFDLGlDQUFpQyxFQUFFSCxJQUFJSSxPQUFPLENBQUMsQ0FBQyxFQUFFSjtRQUM3RUssUUFBUUMsSUFBSSxDQUFDO0lBQ2Y7SUFFQSxPQUFPbkI7QUFDVCJ9
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "commitTransaction", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return commitTransaction;
9
+ }
10
+ });
11
+ const commitTransaction = async function commitTransaction(id) {
12
+ if (!this.sessions[id]) {
13
+ this.payload.logger.warn('commitTransaction called when no transaction exists');
14
+ return;
15
+ }
16
+ try {
17
+ this.sessions[id].resolve();
18
+ } catch (err) {
19
+ this.sessions[id].reject();
20
+ }
21
+ delete this.sessions[id];
22
+ };
23
+
24
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90cmFuc2FjdGlvbnMvY29tbWl0VHJhbnNhY3Rpb24udHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHR5cGUgeyBDb21taXRUcmFuc2FjdGlvbiB9IGZyb20gJ3BheWxvYWQvZGF0YWJhc2UnXG5cbmV4cG9ydCB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