graphddb 0.7.1 → 0.7.2
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/dist/{chunk-C5Q2NMRW.js → chunk-H34BNRDZ.js} +50 -21
- package/dist/cli.js +1 -1
- package/dist/index.js +3 -9
- package/dist/spec/index.js +1 -1
- package/package.json +1 -1
|
@@ -2942,6 +2942,30 @@ function renderTemplateRecord(record, key, params, contextLabel) {
|
|
|
2942
2942
|
}
|
|
2943
2943
|
return out;
|
|
2944
2944
|
}
|
|
2945
|
+
var EFFECT_FIELD_MAPS = /* @__PURE__ */ new WeakMap();
|
|
2946
|
+
function effectFieldMap(modelClass) {
|
|
2947
|
+
let map = EFFECT_FIELD_MAPS.get(modelClass);
|
|
2948
|
+
if (map === void 0) {
|
|
2949
|
+
map = new Map(MetadataRegistry.get(modelClass).fields.map((f) => [f.propertyName, f]));
|
|
2950
|
+
EFFECT_FIELD_MAPS.set(modelClass, map);
|
|
2951
|
+
}
|
|
2952
|
+
return map;
|
|
2953
|
+
}
|
|
2954
|
+
function serializeEffectParams(modelClasses, values) {
|
|
2955
|
+
const maps = modelClasses.map(effectFieldMap);
|
|
2956
|
+
const oldPrefix = `${OLD_VALUE_NAMESPACE}.`;
|
|
2957
|
+
const out = {};
|
|
2958
|
+
for (const [name, value] of Object.entries(values)) {
|
|
2959
|
+
const fieldName = name.startsWith(oldPrefix) ? name.slice(oldPrefix.length) : name;
|
|
2960
|
+
let fieldMeta;
|
|
2961
|
+
for (const map of maps) {
|
|
2962
|
+
fieldMeta = map.get(fieldName);
|
|
2963
|
+
if (fieldMeta !== void 0) break;
|
|
2964
|
+
}
|
|
2965
|
+
out[name] = fieldMeta !== void 0 ? serializeFieldValue(value, fieldMeta) : value instanceof Date ? value.toISOString() : value;
|
|
2966
|
+
}
|
|
2967
|
+
return out;
|
|
2968
|
+
}
|
|
2945
2969
|
function renderEdgeWriteItems(edge, key, params, contextLabel, modelBySignature) {
|
|
2946
2970
|
const adjacency = edge.entity.modelClass;
|
|
2947
2971
|
return edge.items.map((item) => {
|
|
@@ -3287,11 +3311,14 @@ async function executeCommandMethod(contract, methodName, keyOrKeys, params = {}
|
|
|
3287
3311
|
);
|
|
3288
3312
|
if (hasDerivedEffects) {
|
|
3289
3313
|
const modelBySignature = /* @__PURE__ */ new Map();
|
|
3314
|
+
const fragmentClasses = ops.map((opn) => modelClassOf(opn));
|
|
3315
|
+
const effectKey = serializeEffectParams(fragmentClasses, key);
|
|
3316
|
+
const effectParams = serializeEffectParams(fragmentClasses, params);
|
|
3290
3317
|
const edgeItems = edgeWrites2.flatMap(
|
|
3291
3318
|
(edge, i) => renderEdgeWriteItems(
|
|
3292
3319
|
edge,
|
|
3293
|
-
|
|
3294
|
-
|
|
3320
|
+
effectKey,
|
|
3321
|
+
effectParams,
|
|
3295
3322
|
`command method '${methodName}' (edge #${i})`,
|
|
3296
3323
|
modelBySignature
|
|
3297
3324
|
)
|
|
@@ -3299,41 +3326,41 @@ async function executeCommandMethod(contract, methodName, keyOrKeys, params = {}
|
|
|
3299
3326
|
const updateItems = derivedUpdates.map(
|
|
3300
3327
|
(update, i) => renderDerivedUpdate(
|
|
3301
3328
|
update,
|
|
3302
|
-
|
|
3303
|
-
|
|
3329
|
+
effectKey,
|
|
3330
|
+
effectParams,
|
|
3304
3331
|
`command method '${methodName}' (derive #${i})`,
|
|
3305
3332
|
modelBySignature
|
|
3306
3333
|
)
|
|
3307
3334
|
);
|
|
3308
3335
|
const guardItems = uniqueGuards.flatMap(
|
|
3309
|
-
(guard, i) => renderUniqueGuardItems(guard,
|
|
3336
|
+
(guard, i) => renderUniqueGuardItems(guard, effectKey, effectParams, `command method '${methodName}' (unique #${i})`)
|
|
3310
3337
|
);
|
|
3311
3338
|
const outboxItems = outboxEvents.flatMap(
|
|
3312
|
-
(event, i) => renderOutboxEventItems(event,
|
|
3339
|
+
(event, i) => renderOutboxEventItems(event, effectKey, effectParams, `command method '${methodName}' (emit #${i})`)
|
|
3313
3340
|
);
|
|
3314
3341
|
const idempotencyItems = idempotencyGuard !== void 0 ? renderIdempotencyGuardItems(
|
|
3315
3342
|
idempotencyGuard,
|
|
3316
|
-
|
|
3317
|
-
|
|
3343
|
+
effectKey,
|
|
3344
|
+
effectParams,
|
|
3318
3345
|
`command method '${methodName}' (idempotency)`
|
|
3319
3346
|
) : [];
|
|
3320
3347
|
const maintainItems = maintainWrites.map(
|
|
3321
3348
|
(m, i) => renderMaintainWriteItem(
|
|
3322
3349
|
m,
|
|
3323
|
-
|
|
3324
|
-
|
|
3350
|
+
effectKey,
|
|
3351
|
+
effectParams,
|
|
3325
3352
|
`command method '${methodName}' (maintain #${i})`,
|
|
3326
3353
|
modelBySignature
|
|
3327
3354
|
)
|
|
3328
3355
|
);
|
|
3329
3356
|
const maintainOutboxItems = maintainOutbox.flatMap(
|
|
3330
|
-
(mo, i) => renderMaintainOutboxItems(mo,
|
|
3357
|
+
(mo, i) => renderMaintainOutboxItems(mo, effectKey, effectParams, `command method '${methodName}' (maintain-outbox #${i})`)
|
|
3331
3358
|
);
|
|
3332
3359
|
const checks = conditionChecks.map((check, i) => ({
|
|
3333
3360
|
check: renderConditionCheck(
|
|
3334
3361
|
check,
|
|
3335
|
-
|
|
3336
|
-
|
|
3362
|
+
effectKey,
|
|
3363
|
+
effectParams,
|
|
3337
3364
|
`command method '${methodName}' (requires #${i})`
|
|
3338
3365
|
)
|
|
3339
3366
|
}));
|
|
@@ -3369,6 +3396,7 @@ function renderCompiledOp(op, ctx) {
|
|
|
3369
3396
|
const baseOp = op.condition !== void 0 ? withCondition(fragment.op, op.condition) : fragment.op;
|
|
3370
3397
|
const modelBySignature = /* @__PURE__ */ new Map();
|
|
3371
3398
|
const write = renderWrite(baseOp, op.params, op.params, ctx);
|
|
3399
|
+
const effectParams = serializeEffectParams([modelClassOf(fragment.op)], op.params);
|
|
3372
3400
|
const edgeItems = [];
|
|
3373
3401
|
const updateItems = [];
|
|
3374
3402
|
const guardItems = [];
|
|
@@ -3378,34 +3406,34 @@ function renderCompiledOp(op, ctx) {
|
|
|
3378
3406
|
const maintainOutboxItems = [];
|
|
3379
3407
|
const checkItems = [];
|
|
3380
3408
|
for (const edge of fragment.edgeWrites ?? []) {
|
|
3381
|
-
edgeItems.push(...renderEdgeWriteItems(edge,
|
|
3409
|
+
edgeItems.push(...renderEdgeWriteItems(edge, effectParams, effectParams, `${ctx} edge`, modelBySignature));
|
|
3382
3410
|
}
|
|
3383
3411
|
for (const u of fragment.derivedUpdates ?? []) {
|
|
3384
|
-
updateItems.push(renderDerivedUpdate(u,
|
|
3412
|
+
updateItems.push(renderDerivedUpdate(u, effectParams, effectParams, `${ctx} derive`, modelBySignature));
|
|
3385
3413
|
}
|
|
3386
3414
|
for (const g of fragment.uniqueGuards ?? []) {
|
|
3387
|
-
guardItems.push(...renderUniqueGuardItems(g,
|
|
3415
|
+
guardItems.push(...renderUniqueGuardItems(g, effectParams, effectParams, `${ctx} unique`));
|
|
3388
3416
|
}
|
|
3389
3417
|
for (const e of fragment.outboxEvents ?? []) {
|
|
3390
|
-
outboxItems.push(...renderOutboxEventItems(e,
|
|
3418
|
+
outboxItems.push(...renderOutboxEventItems(e, effectParams, effectParams, `${ctx} emit`));
|
|
3391
3419
|
}
|
|
3392
3420
|
if (fragment.idempotencyGuard !== void 0) {
|
|
3393
3421
|
idempotencyItems.push(
|
|
3394
|
-
...renderIdempotencyGuardItems(fragment.idempotencyGuard,
|
|
3422
|
+
...renderIdempotencyGuardItems(fragment.idempotencyGuard, effectParams, effectParams, `${ctx} idempotency`)
|
|
3395
3423
|
);
|
|
3396
3424
|
}
|
|
3397
3425
|
for (const m of fragment.maintainWrites ?? []) {
|
|
3398
3426
|
maintainItems.push(
|
|
3399
|
-
renderMaintainWriteItem(m,
|
|
3427
|
+
renderMaintainWriteItem(m, effectParams, effectParams, `${ctx} maintain`, modelBySignature)
|
|
3400
3428
|
);
|
|
3401
3429
|
}
|
|
3402
3430
|
for (const mo of fragment.maintainOutbox ?? []) {
|
|
3403
3431
|
maintainOutboxItems.push(
|
|
3404
|
-
...renderMaintainOutboxItems(mo,
|
|
3432
|
+
...renderMaintainOutboxItems(mo, effectParams, effectParams, `${ctx} maintain-outbox`)
|
|
3405
3433
|
);
|
|
3406
3434
|
}
|
|
3407
3435
|
for (const c of fragment.conditionChecks ?? []) {
|
|
3408
|
-
checkItems.push({ check: renderConditionCheck(c,
|
|
3436
|
+
checkItems.push({ check: renderConditionCheck(c, effectParams, effectParams, `${ctx} requires`) });
|
|
3409
3437
|
}
|
|
3410
3438
|
const hasDerivedEffects = edgeItems.length > 0 || updateItems.length > 0 || guardItems.length > 0 || outboxItems.length > 0 || idempotencyItems.length > 0 || maintainItems.length > 0 || maintainOutboxItems.length > 0 || checkItems.length > 0;
|
|
3411
3439
|
return {
|
|
@@ -8150,6 +8178,7 @@ export {
|
|
|
8150
8178
|
compileSingleFragmentPlan,
|
|
8151
8179
|
MAX_TRANSACT_COMPOSE_ITEMS,
|
|
8152
8180
|
compileMutationPlan,
|
|
8181
|
+
serializeEffectParams,
|
|
8153
8182
|
executeCommandMethod,
|
|
8154
8183
|
LOGICAL_EFFECT_CATEGORIES,
|
|
8155
8184
|
executeLogicalWriteOps,
|
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -86,10 +86,11 @@ import {
|
|
|
86
86
|
query,
|
|
87
87
|
resolveLifecycle,
|
|
88
88
|
resolveRelations,
|
|
89
|
+
serializeEffectParams,
|
|
89
90
|
validateDepth,
|
|
90
91
|
when,
|
|
91
92
|
wholeKeysSentinel
|
|
92
|
-
} from "./chunk-
|
|
93
|
+
} from "./chunk-H34BNRDZ.js";
|
|
93
94
|
import {
|
|
94
95
|
CdcEmulator,
|
|
95
96
|
MAINT_OUTBOX_PK_PREFIX,
|
|
@@ -1336,13 +1337,6 @@ function bindEntities(plan2, planId) {
|
|
|
1336
1337
|
}
|
|
1337
1338
|
return { classes, manifest: { version: SPEC_VERSION, tables, entities } };
|
|
1338
1339
|
}
|
|
1339
|
-
function templateParams(values) {
|
|
1340
|
-
const out = {};
|
|
1341
|
-
for (const [k2, v] of Object.entries(values)) {
|
|
1342
|
-
out[k2] = v instanceof Date ? v.toISOString() : v;
|
|
1343
|
-
}
|
|
1344
|
-
return out;
|
|
1345
|
-
}
|
|
1346
1340
|
function renderSpecItem(transaction, index, manifest, params) {
|
|
1347
1341
|
const single = {
|
|
1348
1342
|
params: transaction.params,
|
|
@@ -1351,7 +1345,7 @@ function renderSpecItem(transaction, index, manifest, params) {
|
|
|
1351
1345
|
return expandTransactionItems(single, manifest, params);
|
|
1352
1346
|
}
|
|
1353
1347
|
function renderEffectsForOp(op, boundParams) {
|
|
1354
|
-
const rendered =
|
|
1348
|
+
const rendered = serializeEffectParams([op.modelClass], boundParams);
|
|
1355
1349
|
const effects = {};
|
|
1356
1350
|
const checks = [];
|
|
1357
1351
|
const modelBySignature = /* @__PURE__ */ new Map();
|
package/dist/spec/index.js
CHANGED