@tokenoftrust/storefront-runner 7.11.4 → 7.11.6
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.
|
@@ -315,22 +315,6 @@ export class SourceAuthorityStore {
|
|
|
315
315
|
mutation,
|
|
316
316
|
],
|
|
317
317
|
});
|
|
318
|
-
for (const r of records.filter(
|
|
319
|
-
(r) => r.kind === "check" || r.kind === "result",
|
|
320
|
-
)) {
|
|
321
|
-
const controlId = `source-control:${await digestJson({ key, kind: r.kind, id: r.id })}`;
|
|
322
|
-
statements.push({
|
|
323
|
-
sql: `INSERT INTO scrappy_commerce_inbox(tenant_id,stage,source,source_event_id,event_version,idempotency_key,payload_digest,received_at) SELECT tenant_id,stage,source,?,1,?,?,? FROM commerce_source_authority WHERE ${WHERE} AND mutation_id=?`,
|
|
324
|
-
params: [
|
|
325
|
-
controlId,
|
|
326
|
-
controlId,
|
|
327
|
-
r.digest,
|
|
328
|
-
now,
|
|
329
|
-
...keyParams(key),
|
|
330
|
-
mutation,
|
|
331
|
-
],
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
318
|
if (replay)
|
|
335
319
|
statements.push({
|
|
336
320
|
sql: `INSERT INTO scrappy_caller_replay(tenant_id,stage,issuer,jti,seen_at) SELECT tenant_id,stage,?,?,? FROM commerce_source_authority WHERE ${WHERE} AND mutation_id=?`,
|
|
@@ -359,25 +343,40 @@ export class SourceAuthorityStore {
|
|
|
359
343
|
mutation,
|
|
360
344
|
],
|
|
361
345
|
});
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
346
|
+
// Record a source-authority audit entry only when durable authority health transitions
|
|
347
|
+
// (ignoring transient pending_check flips during healthy renewals).
|
|
348
|
+
const prevDurableStatus = !old
|
|
349
|
+
? "none"
|
|
350
|
+
: !old.accepted_ledger_generation ||
|
|
351
|
+
old.source_sync_pending ||
|
|
352
|
+
old.unresolved_count ||
|
|
353
|
+
old.authority_budget
|
|
354
|
+
? "held"
|
|
355
|
+
: "verified";
|
|
356
|
+
const nextDurableStatus =
|
|
357
|
+
!state.accepted || state.sync || state.holds.length > 0 || state.budget
|
|
358
|
+
? "held"
|
|
359
|
+
: "verified";
|
|
360
|
+
if (nextDurableStatus !== prevDurableStatus) {
|
|
361
|
+
statements.push({
|
|
362
|
+
sql: `INSERT INTO scrappy_shipment_audit(audit_id,tenant_id,stage,order_id,at,actor_id,kind,from_state,to_state)
|
|
363
|
+
SELECT ?,tenant_id,stage,order_id,?,'commerce-source-authority','source-authority',?,?
|
|
364
|
+
FROM scrappy_commerce_orders WHERE tenant_id=? AND stage=? AND source=? AND source_order_id=?
|
|
365
|
+
AND EXISTS(SELECT 1 FROM commerce_source_authority WHERE ${WHERE} AND mutation_id=?)`,
|
|
366
|
+
params: [
|
|
367
|
+
`audit_${crypto.randomUUID()}`,
|
|
368
|
+
`${now}#source-${state.version}`,
|
|
369
|
+
prevDurableStatus,
|
|
370
|
+
nextDurableStatus,
|
|
371
|
+
key.tenantId,
|
|
372
|
+
key.stage,
|
|
373
|
+
key.source,
|
|
374
|
+
key.sourceOrderId,
|
|
375
|
+
...keyParams(key),
|
|
376
|
+
mutation,
|
|
377
|
+
],
|
|
378
|
+
});
|
|
379
|
+
}
|
|
381
380
|
const result = await this.db.batchResults(statements);
|
|
382
381
|
return Boolean(result[0]?.results.length);
|
|
383
382
|
}
|
|
@@ -135,7 +135,7 @@ function readSnapshot(value: unknown): FinalCartWire | null {
|
|
|
135
135
|
typeof v.tenantId !== "string" || !["preview", "publication"].includes(String(v.stage)) || typeof v.currency !== "string" || !/^[A-Z]{3}$/.test(v.currency) ||
|
|
136
136
|
!Array.isArray(v.lines) || v.lines.length < 1 || v.lines.length > 50) return null;
|
|
137
137
|
if (v.lines.some(line => !line || typeof line !== "object" || skuFromToken(line.sku) === null ||
|
|
138
|
-
!Number.isSafeInteger(line.quantity) || line.quantity < 1 || line.quantity >
|
|
138
|
+
!Number.isSafeInteger(line.quantity) || line.quantity < 1 || line.quantity > 10_000 || !Number.isSafeInteger(line.unitMinor) || line.unitMinor < 0 ||
|
|
139
139
|
Object.keys(line).some(k => !["sku", "quantity", "unitMinor"].includes(k)))) return null;
|
|
140
140
|
const t = v.totals as Record<string, unknown> | undefined;
|
|
141
141
|
const totalKeys = ["subtotalMinor", "shippingMinor", "taxMinor", "totalMinor"];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "7.11.
|
|
3
|
+
"version": "7.11.6",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
|
|
6
6
|
"packageManager": "pnpm@11.9.0",
|