graphddb 0.3.1 → 0.4.1
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/README.md +1 -1
- package/dist/{chunk-PNIZS37E.js → chunk-BROCT574.js} +8 -118
- package/dist/{chunk-YIXXTGZ6.js → chunk-CPTV3H2U.js} +220 -250
- package/dist/{chunk-VST3WOK3.js → chunk-G5RWWBAL.js} +43 -23
- package/dist/cli.js +51 -14
- package/dist/index.d.ts +307 -106
- package/dist/index.js +305 -46
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +2 -2
- package/dist/{types-DuJ08bgc.d.ts → types-BWOrWcbd.d.ts} +309 -425
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -79,23 +79,19 @@ import {
|
|
|
79
79
|
validateDepth,
|
|
80
80
|
when,
|
|
81
81
|
wholeKeysSentinel
|
|
82
|
-
} from "./chunk-
|
|
82
|
+
} from "./chunk-G5RWWBAL.js";
|
|
83
83
|
import {
|
|
84
84
|
CdcEmulator,
|
|
85
|
-
InMemoryProjectionSink,
|
|
86
85
|
MAINT_OUTBOX_PK_PREFIX,
|
|
87
86
|
MaintenanceDrain,
|
|
88
|
-
ProjectionSinkDrain,
|
|
89
87
|
compareDesc,
|
|
90
88
|
createCdcEmulator,
|
|
91
89
|
createMaintenanceDrain,
|
|
92
90
|
createMaintenanceDrainHandler,
|
|
93
|
-
createProjectionSinkDrain,
|
|
94
|
-
createProjectionSinkHandler,
|
|
95
91
|
orderAndTrimCollection,
|
|
96
92
|
pathField,
|
|
97
93
|
projectFrom
|
|
98
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-BROCT574.js";
|
|
99
95
|
import {
|
|
100
96
|
BATCH_GET_MAX_KEYS,
|
|
101
97
|
BATCH_WRITE_MAX_ITEMS,
|
|
@@ -111,7 +107,6 @@ import {
|
|
|
111
107
|
RetryingExecutor,
|
|
112
108
|
TableMapping,
|
|
113
109
|
TransactionContext,
|
|
114
|
-
ViewRegistry,
|
|
115
110
|
attachModelClass,
|
|
116
111
|
buildConditionExpression,
|
|
117
112
|
buildDeleteInput,
|
|
@@ -121,14 +116,10 @@ import {
|
|
|
121
116
|
buildUpdateInput,
|
|
122
117
|
collapseSameKeyItems,
|
|
123
118
|
collectRawConditionParams,
|
|
119
|
+
collectViewDefinitions,
|
|
124
120
|
commitTransaction,
|
|
125
121
|
cond,
|
|
126
122
|
createDefaultLinter,
|
|
127
|
-
defineProjection,
|
|
128
|
-
defineProjections,
|
|
129
|
-
defineVersioned,
|
|
130
|
-
defineView,
|
|
131
|
-
defineViews,
|
|
132
123
|
entityWrites,
|
|
133
124
|
execItemKeySignature,
|
|
134
125
|
executeDelete,
|
|
@@ -145,11 +136,9 @@ import {
|
|
|
145
136
|
isLifecycleContract,
|
|
146
137
|
isMaintainTrigger,
|
|
147
138
|
isParam,
|
|
148
|
-
isProjectionDefinition,
|
|
149
139
|
isRawCondition,
|
|
150
140
|
isRetryableError,
|
|
151
141
|
isRetryableTransactionCancellation,
|
|
152
|
-
isViewDefinition,
|
|
153
142
|
k,
|
|
154
143
|
key,
|
|
155
144
|
lifecyclePhaseForIntent,
|
|
@@ -164,9 +153,8 @@ import {
|
|
|
164
153
|
resolveKey,
|
|
165
154
|
resolveModelClass,
|
|
166
155
|
segmentFieldNames,
|
|
167
|
-
serializeFieldValue
|
|
168
|
-
|
|
169
|
-
} from "./chunk-YIXXTGZ6.js";
|
|
156
|
+
serializeFieldValue
|
|
157
|
+
} from "./chunk-CPTV3H2U.js";
|
|
170
158
|
|
|
171
159
|
// src/metadata/prefix.ts
|
|
172
160
|
function derivePrefix(customPrefix, className) {
|
|
@@ -217,6 +205,7 @@ var pendingFields = [];
|
|
|
217
205
|
var pendingEmbedded = [];
|
|
218
206
|
var pendingRelations = [];
|
|
219
207
|
var pendingAggregates = [];
|
|
208
|
+
var pendingMaintainedFrom = [];
|
|
220
209
|
function collectField(field2) {
|
|
221
210
|
pendingFields.push(field2);
|
|
222
211
|
}
|
|
@@ -229,6 +218,9 @@ function collectRelation(relation) {
|
|
|
229
218
|
function collectAggregate(aggregate2) {
|
|
230
219
|
pendingAggregates.push(aggregate2);
|
|
231
220
|
}
|
|
221
|
+
function collectMaintainedFrom(decl) {
|
|
222
|
+
pendingMaintainedFrom.push(decl);
|
|
223
|
+
}
|
|
232
224
|
function drainFields() {
|
|
233
225
|
const result = pendingFields;
|
|
234
226
|
pendingFields = [];
|
|
@@ -249,6 +241,11 @@ function drainAggregates() {
|
|
|
249
241
|
pendingAggregates = [];
|
|
250
242
|
return result;
|
|
251
243
|
}
|
|
244
|
+
function drainMaintainedFrom() {
|
|
245
|
+
const result = pendingMaintainedFrom;
|
|
246
|
+
pendingMaintainedFrom = [];
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
252
249
|
|
|
253
250
|
// src/decorators/model.ts
|
|
254
251
|
function model(options) {
|
|
@@ -257,7 +254,19 @@ function model(options) {
|
|
|
257
254
|
const embeddedFields = drainEmbedded();
|
|
258
255
|
const relations = drainRelations();
|
|
259
256
|
const aggregates = drainAggregates();
|
|
257
|
+
const maintainedFrom2 = drainMaintainedFrom();
|
|
260
258
|
const prefix = derivePrefix(options.prefix, context.name);
|
|
259
|
+
const kind = options.kind ?? "entity";
|
|
260
|
+
if (kind === "entity" && maintainedFrom2.length > 0) {
|
|
261
|
+
throw new Error(
|
|
262
|
+
`@model on '${String(context.name)}': ${maintainedFrom2.length} \`@maintainedFrom\` declaration(s) are present but \`kind\` is 'entity' (the default). A maintained view must declare \`@model({ kind: 'materializedView' | 'sparseView' })\` \u2014 a plain entity does not carry view maintainers.`
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
if (kind !== "entity" && maintainedFrom2.length === 0) {
|
|
266
|
+
throw new Error(
|
|
267
|
+
`@model on '${String(context.name)}': \`kind: '${kind}'\` declares a maintained view but no \`@maintainedFrom(...)\` source is stacked. A view with no source is maintained by nothing \u2014 add at least one \`@maintainedFrom\` decorator.`
|
|
268
|
+
);
|
|
269
|
+
}
|
|
261
270
|
MetadataRegistry.register(target, {
|
|
262
271
|
tableName: options.table,
|
|
263
272
|
prefix,
|
|
@@ -266,7 +275,10 @@ function model(options) {
|
|
|
266
275
|
gsiDefinitions: [],
|
|
267
276
|
relations,
|
|
268
277
|
aggregates,
|
|
269
|
-
embeddedFields
|
|
278
|
+
embeddedFields,
|
|
279
|
+
kind,
|
|
280
|
+
...options.description !== void 0 ? { description: options.description } : {},
|
|
281
|
+
maintainedFrom: maintainedFrom2
|
|
270
282
|
});
|
|
271
283
|
};
|
|
272
284
|
}
|
|
@@ -336,7 +348,95 @@ function embedded(modelFactory) {
|
|
|
336
348
|
};
|
|
337
349
|
}
|
|
338
350
|
|
|
351
|
+
// src/decorators/maintained-symbolic.ts
|
|
352
|
+
var SOURCE_REF = /* @__PURE__ */ Symbol("graphddb:maintainedSourceRef");
|
|
353
|
+
var SELF_REF = /* @__PURE__ */ Symbol("graphddb:maintainedSelfRef");
|
|
354
|
+
function isSourceRef(value) {
|
|
355
|
+
return typeof value === "object" && value !== null && value[SOURCE_REF] === true;
|
|
356
|
+
}
|
|
357
|
+
function isSelfRef(value) {
|
|
358
|
+
return typeof value === "object" && value !== null && value[SELF_REF] === true;
|
|
359
|
+
}
|
|
360
|
+
function createSourceProxy() {
|
|
361
|
+
const cache = /* @__PURE__ */ new Map();
|
|
362
|
+
return new Proxy(
|
|
363
|
+
{},
|
|
364
|
+
{
|
|
365
|
+
get(_t, prop) {
|
|
366
|
+
if (typeof prop !== "string") return void 0;
|
|
367
|
+
let ref = cache.get(prop);
|
|
368
|
+
if (!ref) {
|
|
369
|
+
ref = { [SOURCE_REF]: true, field: prop, path: `$.entity.${prop}` };
|
|
370
|
+
cache.set(prop, ref);
|
|
371
|
+
}
|
|
372
|
+
return ref;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
function createSelfProxy() {
|
|
378
|
+
const cache = /* @__PURE__ */ new Map();
|
|
379
|
+
return new Proxy(
|
|
380
|
+
{},
|
|
381
|
+
{
|
|
382
|
+
get(_t, prop) {
|
|
383
|
+
if (typeof prop !== "string") return void 0;
|
|
384
|
+
let ref = cache.get(prop);
|
|
385
|
+
if (!ref) {
|
|
386
|
+
ref = { [SELF_REF]: true, field: prop };
|
|
387
|
+
cache.set(prop, ref);
|
|
388
|
+
}
|
|
389
|
+
return ref;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
|
|
339
395
|
// src/decorators/relation.ts
|
|
396
|
+
function lowerVersionedProjectionValue(propertyName, attr, value) {
|
|
397
|
+
if (isSourceRef(value)) return identity(value.path);
|
|
398
|
+
if (value && typeof value === "object" && value.kind === "transform") {
|
|
399
|
+
return value;
|
|
400
|
+
}
|
|
401
|
+
throw new Error(
|
|
402
|
+
`@hasOne/@hasMany versioned relation '${propertyName}': projection target '${attr}' must be a \`source.<field>\` reference or a transform (e.g. \`preview(source.body, 120)\`), got ${JSON.stringify(value)}.`
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
function lowerVersionedOptions(propertyName, opts) {
|
|
406
|
+
if (!opts || typeof opts !== "object" || opts.pattern !== "versionedLatest" && opts.pattern !== "versionedHistory") {
|
|
407
|
+
throw new Error(
|
|
408
|
+
`@hasOne/@hasMany versioned relation '${propertyName}': the (self, source) => options callback must return \`{ pattern: 'versionedLatest' | 'versionedHistory', on, project }\`.`
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
if (!Array.isArray(opts.on) || opts.on.length === 0) {
|
|
412
|
+
throw new Error(
|
|
413
|
+
`@hasOne/@hasMany versioned relation '${propertyName}': \`on\` must be a non-empty array of lifecycle events (e.g. \`['created', 'updated']\`).`
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
const projectEntries = Object.entries(opts.project ?? {});
|
|
417
|
+
if (projectEntries.length === 0) {
|
|
418
|
+
throw new Error(
|
|
419
|
+
`@hasOne/@hasMany versioned relation '${propertyName}': \`project\` is empty \u2014 a versioned row with no captured attributes projects nothing.`
|
|
420
|
+
);
|
|
421
|
+
}
|
|
422
|
+
const project = {};
|
|
423
|
+
for (const [attr, value] of projectEntries) {
|
|
424
|
+
project[attr] = lowerVersionedProjectionValue(propertyName, attr, value);
|
|
425
|
+
}
|
|
426
|
+
return {
|
|
427
|
+
pattern: opts.pattern,
|
|
428
|
+
versioned: {
|
|
429
|
+
mode: opts.pattern === "versionedLatest" ? "latest" : "history",
|
|
430
|
+
on: [...opts.on],
|
|
431
|
+
project,
|
|
432
|
+
...opts.consistency !== void 0 ? { consistency: opts.consistency } : {},
|
|
433
|
+
...opts.updateMode !== void 0 ? { updateMode: opts.updateMode } : {}
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
function isVersionedCallback(arg) {
|
|
438
|
+
return typeof arg === "function";
|
|
439
|
+
}
|
|
340
440
|
var RESERVED_RELATION_PROPERTY_NAMES = /* @__PURE__ */ new Set([
|
|
341
441
|
"items"
|
|
342
442
|
]);
|
|
@@ -347,15 +447,34 @@ function assertRelationPropertyNameAllowed(propertyName) {
|
|
|
347
447
|
);
|
|
348
448
|
}
|
|
349
449
|
}
|
|
350
|
-
function hasMany(targetFactory,
|
|
450
|
+
function hasMany(targetFactory, keyBindingOrCallback, options) {
|
|
351
451
|
return function(_value, context) {
|
|
352
452
|
const propertyName = String(context.name);
|
|
353
453
|
assertRelationPropertyNameAllowed(propertyName);
|
|
454
|
+
if (isVersionedCallback(keyBindingOrCallback)) {
|
|
455
|
+
const opts = keyBindingOrCallback(
|
|
456
|
+
createSelfProxy(),
|
|
457
|
+
createSourceProxy()
|
|
458
|
+
);
|
|
459
|
+
if (opts.pattern !== "versionedHistory") {
|
|
460
|
+
throw new Error(
|
|
461
|
+
`@hasMany versioned relation '${propertyName}': a \`@hasMany\` maintains an append-only HISTORY, so its pattern must be 'versionedHistory' (got '${opts.pattern}'). Use \`@hasOne\` for 'versionedLatest' (the single overwritten pointer).`
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
collectRelation({
|
|
465
|
+
type: "hasMany",
|
|
466
|
+
propertyName,
|
|
467
|
+
targetFactory,
|
|
468
|
+
keyBinding: {},
|
|
469
|
+
options: lowerVersionedOptions(propertyName, opts)
|
|
470
|
+
});
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
354
473
|
collectRelation({
|
|
355
474
|
type: "hasMany",
|
|
356
475
|
propertyName,
|
|
357
476
|
targetFactory,
|
|
358
|
-
keyBinding,
|
|
477
|
+
keyBinding: keyBindingOrCallback,
|
|
359
478
|
options
|
|
360
479
|
});
|
|
361
480
|
};
|
|
@@ -373,15 +492,34 @@ function belongsTo(targetFactory, keyBinding, options) {
|
|
|
373
492
|
});
|
|
374
493
|
};
|
|
375
494
|
}
|
|
376
|
-
function hasOne(targetFactory,
|
|
495
|
+
function hasOne(targetFactory, keyBindingOrCallback) {
|
|
377
496
|
return function(_value, context) {
|
|
378
497
|
const propertyName = String(context.name);
|
|
379
498
|
assertRelationPropertyNameAllowed(propertyName);
|
|
499
|
+
if (isVersionedCallback(keyBindingOrCallback)) {
|
|
500
|
+
const opts = keyBindingOrCallback(
|
|
501
|
+
createSelfProxy(),
|
|
502
|
+
createSourceProxy()
|
|
503
|
+
);
|
|
504
|
+
if (opts.pattern !== "versionedLatest") {
|
|
505
|
+
throw new Error(
|
|
506
|
+
`@hasOne versioned relation '${propertyName}': a \`@hasOne\` maintains a single LATEST pointer (overwritten per revision), so its pattern must be 'versionedLatest' (got '${opts.pattern}'). Use \`@hasMany\` for 'versionedHistory' (append-only per-version rows).`
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
collectRelation({
|
|
510
|
+
type: "hasOne",
|
|
511
|
+
propertyName,
|
|
512
|
+
targetFactory,
|
|
513
|
+
keyBinding: {},
|
|
514
|
+
options: lowerVersionedOptions(propertyName, opts)
|
|
515
|
+
});
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
380
518
|
collectRelation({
|
|
381
519
|
type: "hasOne",
|
|
382
520
|
propertyName,
|
|
383
521
|
targetFactory,
|
|
384
|
-
keyBinding
|
|
522
|
+
keyBinding: keyBindingOrCallback
|
|
385
523
|
});
|
|
386
524
|
};
|
|
387
525
|
}
|
|
@@ -409,6 +547,118 @@ function max(field2) {
|
|
|
409
547
|
return { op: "max", field: field2 };
|
|
410
548
|
}
|
|
411
549
|
|
|
550
|
+
// src/decorators/maintained.ts
|
|
551
|
+
function whenMember(operand, op, value) {
|
|
552
|
+
const raw = isSourceRef(operand) ? operand.path : operand;
|
|
553
|
+
const path = raw.startsWith("$.input.") || raw.startsWith("$.entity.") ? raw : `$.entity.${raw}`;
|
|
554
|
+
const needsValue = op === "eq" || op === "ne";
|
|
555
|
+
if (needsValue && value === void 0) {
|
|
556
|
+
throw new Error(
|
|
557
|
+
`whenMember(source.\u2026, '${op}', \u2026): the '${op}' op requires a comparand value (e.g. \`whenMember(source.status, '${op}', 'active')\`).`
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
return needsValue ? { path, op, value } : { path, op };
|
|
561
|
+
}
|
|
562
|
+
function lowerProjectionValue(modelName, attr, value) {
|
|
563
|
+
if (isSourceRef(value)) return identity(value.path);
|
|
564
|
+
if (value && typeof value === "object" && value.kind === "transform") {
|
|
565
|
+
return value;
|
|
566
|
+
}
|
|
567
|
+
throw new Error(
|
|
568
|
+
`@maintainedFrom on '${modelName}': projection target '${attr}' must be a \`source.<field>\` reference or a transform (e.g. \`preview(source.body, 120)\`), got ${JSON.stringify(value)}. A maintained projection captures only symbolic source references \u2014 a literal / computed value is not allowed.`
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
function lowerKeyBind(modelName, keyBind) {
|
|
572
|
+
const out = {};
|
|
573
|
+
const entries = Object.entries(keyBind);
|
|
574
|
+
if (entries.length === 0) {
|
|
575
|
+
throw new Error(
|
|
576
|
+
`@maintainedFrom on '${modelName}': \`keyBind\` is empty. The view-row key binding (view-key field \u2192 \`source.<field>\`) is required to resolve which view row a source event maintains.`
|
|
577
|
+
);
|
|
578
|
+
}
|
|
579
|
+
for (const [viewKeyField, ref] of entries) {
|
|
580
|
+
if (!isSourceRef(ref)) {
|
|
581
|
+
throw new Error(
|
|
582
|
+
`@maintainedFrom on '${modelName}': \`keyBind.${viewKeyField}\` must be a \`source.<field>\` reference (e.g. \`{ ${viewKeyField}: source.${viewKeyField} }\`), got ${JSON.stringify(ref)}.`
|
|
583
|
+
);
|
|
584
|
+
}
|
|
585
|
+
out[viewKeyField] = ref.path;
|
|
586
|
+
}
|
|
587
|
+
return out;
|
|
588
|
+
}
|
|
589
|
+
function maintainedFrom(source, callback) {
|
|
590
|
+
return function(target, context) {
|
|
591
|
+
const modelName = String(context.name ?? target.name ?? "(anonymous)");
|
|
592
|
+
const selfProxy = createSelfProxy();
|
|
593
|
+
const sourceProxy = createSourceProxy();
|
|
594
|
+
const opts = callback(selfProxy, sourceProxy);
|
|
595
|
+
if (!opts || typeof opts !== "object") {
|
|
596
|
+
throw new Error(
|
|
597
|
+
`@maintainedFrom on '${modelName}': the (self, source) => options callback must return an options object.`
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
if (!Array.isArray(opts.on) || opts.on.length === 0) {
|
|
601
|
+
throw new Error(
|
|
602
|
+
`@maintainedFrom on '${modelName}': \`on\` must be a non-empty array of lifecycle events (e.g. \`['created', 'removed']\`).`
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
for (const ev of opts.on) {
|
|
606
|
+
if (ev !== "created" && ev !== "updated" && ev !== "removed") {
|
|
607
|
+
throw new Error(
|
|
608
|
+
`@maintainedFrom on '${modelName}': \`on\` event ${JSON.stringify(ev)} is not one of 'created' / 'updated' / 'removed'.`
|
|
609
|
+
);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
const keyBind = lowerKeyBind(modelName, opts.keyBind);
|
|
613
|
+
const projectEntries = Object.entries(opts.project ?? {});
|
|
614
|
+
if (projectEntries.length === 0) {
|
|
615
|
+
throw new Error(
|
|
616
|
+
`@maintainedFrom on '${modelName}': \`project\` is empty. A maintained view with no captured attributes projects nothing \u2014 declare a \`project\` map (e.g. \`{ title: source.title, textPreview: preview(source.body, 120) }\`).`
|
|
617
|
+
);
|
|
618
|
+
}
|
|
619
|
+
const project = {};
|
|
620
|
+
for (const [attr, value] of projectEntries) {
|
|
621
|
+
project[attr] = lowerProjectionValue(modelName, attr, value);
|
|
622
|
+
}
|
|
623
|
+
if (opts.collection && opts.when) {
|
|
624
|
+
throw new Error(
|
|
625
|
+
`@maintainedFrom on '${modelName}': a declaration carries both \`collection\` and \`when\`. They are mutually exclusive \u2014 a collection slice holds a maintained list; a membership (\`when\`) row appears/disappears as a whole.`
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
let collection;
|
|
629
|
+
if (opts.collection) {
|
|
630
|
+
const c = opts.collection;
|
|
631
|
+
if (!isSelfRef(c.field)) {
|
|
632
|
+
throw new Error(
|
|
633
|
+
`@maintainedFrom on '${modelName}': \`collection.field\` must be a \`self.<field>\` reference (the view attribute holding the list, e.g. \`self.latestPosts\`), got ${JSON.stringify(c.field)}.`
|
|
634
|
+
);
|
|
635
|
+
}
|
|
636
|
+
if (c.orderBy !== void 0 && !isSourceRef(c.orderBy)) {
|
|
637
|
+
throw new Error(
|
|
638
|
+
`@maintainedFrom on '${modelName}': \`collection.orderBy\` must be a \`source.<field>\` reference, got ${JSON.stringify(c.orderBy)}.`
|
|
639
|
+
);
|
|
640
|
+
}
|
|
641
|
+
collection = {
|
|
642
|
+
field: c.field.field,
|
|
643
|
+
...c.maxItems !== void 0 ? { maxItems: c.maxItems } : {},
|
|
644
|
+
...c.order !== void 0 ? { order: c.order } : {},
|
|
645
|
+
...c.orderBy !== void 0 ? { orderBy: c.orderBy.path } : {}
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
const metadata = {
|
|
649
|
+
sourceFactory: source,
|
|
650
|
+
on: [...opts.on],
|
|
651
|
+
keyBind,
|
|
652
|
+
project,
|
|
653
|
+
...collection ? { collection } : {},
|
|
654
|
+
...opts.when ? { when: opts.when } : {},
|
|
655
|
+
...opts.consistency !== void 0 ? { consistency: opts.consistency } : {},
|
|
656
|
+
...opts.updateMode !== void 0 ? { updateMode: opts.updateMode } : {}
|
|
657
|
+
};
|
|
658
|
+
collectMaintainedFrom(metadata);
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
|
|
412
662
|
// src/operations/declarative-transaction.ts
|
|
413
663
|
var PLACEHOLDER_RE = /\{[^{}]+\}/g;
|
|
414
664
|
function resolveTemplate(template, params, element) {
|
|
@@ -989,10 +1239,13 @@ var MaintenanceRebuilder = class {
|
|
|
989
1239
|
graph;
|
|
990
1240
|
constructor(opts = {}) {
|
|
991
1241
|
const classes = (opts.models ?? []).map(toClass);
|
|
992
|
-
const
|
|
993
|
-
const allClasses = [
|
|
1242
|
+
const explicitViews = opts.views;
|
|
1243
|
+
const allClasses = [
|
|
1244
|
+
...classes,
|
|
1245
|
+
...(explicitViews ?? []).map((v) => v.viewClass)
|
|
1246
|
+
];
|
|
994
1247
|
const scoped = allClasses.length > 0 ? new Map(allClasses.map((c) => [c, MetadataRegistry.get(c)])) : void 0;
|
|
995
|
-
this.graph = buildMaintenanceGraph(scoped,
|
|
1248
|
+
this.graph = buildMaintenanceGraph(scoped, explicitViews);
|
|
996
1249
|
}
|
|
997
1250
|
/**
|
|
998
1251
|
* Re-derive the materialized value for one owner row × maintainer from the source
|
|
@@ -1344,7 +1597,15 @@ function collectParams(structure, out = {}) {
|
|
|
1344
1597
|
return out;
|
|
1345
1598
|
}
|
|
1346
1599
|
function descriptorFromParam(name, value, existing) {
|
|
1347
|
-
const descriptor =
|
|
1600
|
+
const descriptor = {
|
|
1601
|
+
kind: value.kind,
|
|
1602
|
+
...value.literals !== void 0 ? { literals: value.literals } : {},
|
|
1603
|
+
// Pure-documentation description (issue #154); carried through verbatim. Does
|
|
1604
|
+
// not participate in the conflicting-kind check below (it is not part of the
|
|
1605
|
+
// execution-relevant descriptor identity).
|
|
1606
|
+
...value.description !== void 0 ? { description: value.description } : {},
|
|
1607
|
+
required: true
|
|
1608
|
+
};
|
|
1348
1609
|
if (existing !== void 0 && existing.kind !== descriptor.kind) {
|
|
1349
1610
|
throw new Error(
|
|
1350
1611
|
`Parameter '${name}' is declared with conflicting types ('${existing.kind}' and '${descriptor.kind}'). A parameter name must have a single type across a definition.`
|
|
@@ -1441,7 +1702,7 @@ function collectConditionTreeParams(obj, out) {
|
|
|
1441
1702
|
}
|
|
1442
1703
|
}
|
|
1443
1704
|
}
|
|
1444
|
-
function makeDefinition(model2, operation, key2, select, changes, condition) {
|
|
1705
|
+
function makeDefinition(model2, operation, key2, select, changes, condition, description) {
|
|
1445
1706
|
const params = collectParams(key2);
|
|
1446
1707
|
if (changes !== void 0) collectParams(changes, params);
|
|
1447
1708
|
collectConditionParams(condition, params);
|
|
@@ -1453,25 +1714,30 @@ function makeDefinition(model2, operation, key2, select, changes, condition) {
|
|
|
1453
1714
|
select,
|
|
1454
1715
|
changes,
|
|
1455
1716
|
...condition !== void 0 ? { condition } : {},
|
|
1717
|
+
...description !== void 0 ? { description } : {},
|
|
1456
1718
|
params
|
|
1457
1719
|
};
|
|
1458
1720
|
}
|
|
1459
|
-
function defineQuery(model2, key2, select) {
|
|
1721
|
+
function defineQuery(model2, key2, select, options) {
|
|
1460
1722
|
return makeDefinition(
|
|
1461
1723
|
model2,
|
|
1462
1724
|
"query",
|
|
1463
1725
|
key2,
|
|
1464
1726
|
select,
|
|
1465
|
-
void 0
|
|
1727
|
+
void 0,
|
|
1728
|
+
void 0,
|
|
1729
|
+
options?.description
|
|
1466
1730
|
);
|
|
1467
1731
|
}
|
|
1468
|
-
function defineList(model2, key2, select) {
|
|
1732
|
+
function defineList(model2, key2, select, options) {
|
|
1469
1733
|
return makeDefinition(
|
|
1470
1734
|
model2,
|
|
1471
1735
|
"list",
|
|
1472
1736
|
key2,
|
|
1473
1737
|
select,
|
|
1474
|
-
void 0
|
|
1738
|
+
void 0,
|
|
1739
|
+
void 0,
|
|
1740
|
+
options?.description
|
|
1475
1741
|
);
|
|
1476
1742
|
}
|
|
1477
1743
|
function definePut(model2, item, options) {
|
|
@@ -1481,7 +1747,8 @@ function definePut(model2, item, options) {
|
|
|
1481
1747
|
item,
|
|
1482
1748
|
void 0,
|
|
1483
1749
|
void 0,
|
|
1484
|
-
options?.condition
|
|
1750
|
+
options?.condition,
|
|
1751
|
+
options?.description
|
|
1485
1752
|
);
|
|
1486
1753
|
}
|
|
1487
1754
|
function defineUpdate(model2, key2, changes, options) {
|
|
@@ -1491,7 +1758,8 @@ function defineUpdate(model2, key2, changes, options) {
|
|
|
1491
1758
|
key2,
|
|
1492
1759
|
void 0,
|
|
1493
1760
|
changes,
|
|
1494
|
-
options?.condition
|
|
1761
|
+
options?.condition,
|
|
1762
|
+
options?.description
|
|
1495
1763
|
);
|
|
1496
1764
|
}
|
|
1497
1765
|
function defineDelete(model2, key2, options) {
|
|
@@ -1501,7 +1769,8 @@ function defineDelete(model2, key2, options) {
|
|
|
1501
1769
|
key2,
|
|
1502
1770
|
void 0,
|
|
1503
1771
|
void 0,
|
|
1504
|
-
options?.condition
|
|
1772
|
+
options?.condition,
|
|
1773
|
+
options?.description
|
|
1505
1774
|
);
|
|
1506
1775
|
}
|
|
1507
1776
|
function defineQueries(definitions) {
|
|
@@ -1546,7 +1815,6 @@ export {
|
|
|
1546
1815
|
DynamoExecutor,
|
|
1547
1816
|
EDGE_WRITES_MARKER,
|
|
1548
1817
|
ENTITY_WRITES_MARKER,
|
|
1549
|
-
InMemoryProjectionSink,
|
|
1550
1818
|
LIFECYCLE_CONTRACT_MARKER,
|
|
1551
1819
|
Linter,
|
|
1552
1820
|
MAINT_OUTBOX_PK_PREFIX,
|
|
@@ -1555,12 +1823,10 @@ export {
|
|
|
1555
1823
|
MaintenanceRebuilder,
|
|
1556
1824
|
MetadataRegistry,
|
|
1557
1825
|
OLD_VALUE_NAMESPACE,
|
|
1558
|
-
ProjectionSinkDrain,
|
|
1559
1826
|
RetryingExecutor,
|
|
1560
1827
|
SPEC_VERSION,
|
|
1561
1828
|
TableMapping,
|
|
1562
1829
|
TransactionContext,
|
|
1563
|
-
ViewRegistry,
|
|
1564
1830
|
aggregate,
|
|
1565
1831
|
assertBundleSerializable,
|
|
1566
1832
|
assertContractBoundaries,
|
|
@@ -1588,6 +1854,7 @@ export {
|
|
|
1588
1854
|
buildUpdateInput,
|
|
1589
1855
|
collectContractBoundaryViolations,
|
|
1590
1856
|
collectContractN1Violations,
|
|
1857
|
+
collectViewDefinitions,
|
|
1591
1858
|
compileFilterExpression,
|
|
1592
1859
|
compileFragment,
|
|
1593
1860
|
compileMutationPlan,
|
|
@@ -1600,8 +1867,6 @@ export {
|
|
|
1600
1867
|
createMaintenanceDrain,
|
|
1601
1868
|
createMaintenanceDrainHandler,
|
|
1602
1869
|
createMaintenanceRebuilder,
|
|
1603
|
-
createProjectionSinkDrain,
|
|
1604
|
-
createProjectionSinkHandler,
|
|
1605
1870
|
datetime,
|
|
1606
1871
|
decodeCursor,
|
|
1607
1872
|
decodePerKeyCursor,
|
|
@@ -1609,17 +1874,12 @@ export {
|
|
|
1609
1874
|
defineDelete,
|
|
1610
1875
|
defineList,
|
|
1611
1876
|
definePlan,
|
|
1612
|
-
defineProjection,
|
|
1613
|
-
defineProjections,
|
|
1614
1877
|
definePut,
|
|
1615
1878
|
defineQueries,
|
|
1616
1879
|
defineQuery,
|
|
1617
1880
|
defineTransaction,
|
|
1618
1881
|
defineTransactions,
|
|
1619
1882
|
defineUpdate,
|
|
1620
|
-
defineVersioned,
|
|
1621
|
-
defineView,
|
|
1622
|
-
defineViews,
|
|
1623
1883
|
deriveEdgeWriteItems,
|
|
1624
1884
|
deriveEdgeWriteItemsFor,
|
|
1625
1885
|
deriveModelEdgeWriteItems,
|
|
@@ -1675,19 +1935,18 @@ export {
|
|
|
1675
1935
|
isMutationInputRef,
|
|
1676
1936
|
isParam,
|
|
1677
1937
|
isPlannedCommandMethod,
|
|
1678
|
-
isProjectionDefinition,
|
|
1679
1938
|
isQueryModelContract,
|
|
1680
1939
|
isRetryableError,
|
|
1681
1940
|
isRetryableTransactionCancellation,
|
|
1682
1941
|
isSelectBuilder,
|
|
1683
1942
|
isTransactionRef,
|
|
1684
|
-
isViewDefinition,
|
|
1685
1943
|
k,
|
|
1686
1944
|
key,
|
|
1687
1945
|
lifecyclePhaseForIntent,
|
|
1688
1946
|
list,
|
|
1689
1947
|
literal,
|
|
1690
1948
|
maintainTrigger,
|
|
1949
|
+
maintainedFrom,
|
|
1691
1950
|
map,
|
|
1692
1951
|
max,
|
|
1693
1952
|
mintContractKeyFieldRef,
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as Executor, D as DynamoDBOperation, R as ReadExecOptions, a as ExecutorResult, B as BatchGetExecInput, P as PutInput, W as WriteExecOptions, b as WriteResult, U as UpdateInput, c as DeleteInput, d as BatchWriteExecItem, e as BatchExecOptions, T as TransactWriteExecItem, M as ModelStatic, f as DDBModel, C as ChangeEvent } from '../types-
|
|
1
|
+
import { E as Executor, D as DynamoDBOperation, R as ReadExecOptions, a as ExecutorResult, B as BatchGetExecInput, P as PutInput, W as WriteExecOptions, b as WriteResult, U as UpdateInput, c as DeleteInput, d as BatchWriteExecItem, e as BatchExecOptions, T as TransactWriteExecItem, M as ModelStatic, f as DDBModel, C as ChangeEvent } from '../types-BWOrWcbd.js';
|
|
2
2
|
import '@aws-sdk/client-dynamodb';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/testing/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createCdcEmulator
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-BROCT574.js";
|
|
4
4
|
import {
|
|
5
5
|
ClientManager,
|
|
6
6
|
MetadataRegistry,
|
|
7
7
|
TableMapping,
|
|
8
8
|
resolveModelClass
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-CPTV3H2U.js";
|
|
10
10
|
|
|
11
11
|
// src/memory/memory-store.ts
|
|
12
12
|
function deepClone(value) {
|