@tangle-network/agent-app 0.61.4 → 0.62.0
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/{DesignCanvas-L6J72JQ2.js → DesignCanvas-IQKYAEC4.js} +3 -2
- package/dist/{DesignCanvasEditor-QFQD63MR.js → DesignCanvasEditor-O7OCZTGC.js} +5 -4
- package/dist/{TimelineEditor-7KBPJQLT.js → TimelineEditor-VB2UJ34D.js} +4 -2
- package/dist/VaultPane-AYW7CO33.js +8 -0
- package/dist/agent-profiles/d1.js +1 -1
- package/dist/agent-profiles/index.d.ts +0 -82
- package/dist/agent-profiles/index.js +1 -21
- package/dist/agent-profiles/self-management.d.ts +0 -55
- package/dist/alerting/index.d.ts +1 -1
- package/dist/alerting/index.js +1 -3
- package/dist/alerting/slack.d.ts +6 -79
- package/dist/app-auth/drizzle.d.ts +17 -271
- package/dist/app-auth/drizzle.js +6 -2
- package/dist/app-auth/drizzle.js.map +1 -1
- package/dist/app-auth/index.js +3 -3
- package/dist/assets/types.d.ts +2 -1
- package/dist/assistant/AssistantPanel.d.ts +1 -1
- package/dist/assistant/index.js +635 -392
- package/dist/assistant/index.js.map +1 -1
- package/dist/billing/identity-locks.d.ts +5 -0
- package/dist/billing/index.js +1 -1
- package/dist/brand-extraction/index.js.map +1 -1
- package/dist/brand-extraction/types.d.ts +2 -1
- package/dist/chat-react/index.js +6 -5
- package/dist/chat-routes/attachment-write-safety.d.ts +4 -0
- package/dist/chat-routes/draft-persistence.d.ts +2 -14
- package/dist/chat-routes/index.d.ts +1 -0
- package/dist/chat-routes/index.js +853 -773
- package/dist/chat-routes/index.js.map +1 -1
- package/dist/chat-routes/sandbox-model-source.d.ts +20 -0
- package/dist/chat-routes/stored-attachments.d.ts +18 -0
- package/dist/chat-routes/turn-admission.d.ts +1 -1
- package/dist/chat-routes/turn-execution.d.ts +2 -2
- package/dist/chat-routes/turn-route-contracts.d.ts +3 -29
- package/dist/chat-store/core.d.ts +19 -1
- package/dist/chat-store/index.js.map +1 -1
- package/dist/chat-store/store.d.ts +3 -29
- package/dist/{chunk-ATQQCG4I.js → chunk-2VJLLRVV.js} +2 -2
- package/dist/{chunk-R4X5474U.js → chunk-52SDU43B.js} +12 -27
- package/dist/chunk-52SDU43B.js.map +1 -0
- package/dist/{chunk-MDRH3SDA.js → chunk-54YIL7WM.js} +3 -3
- package/dist/{chunk-6QJ3GB3A.js → chunk-5GSZGTPJ.js} +2 -2
- package/dist/{chunk-5IM2CLYX.js → chunk-6JEDSKFH.js} +232 -218
- package/dist/chunk-6JEDSKFH.js.map +1 -0
- package/dist/{chunk-6PRQ45QE.js → chunk-6OG4244Y.js} +1 -1
- package/dist/chunk-6OG4244Y.js.map +1 -0
- package/dist/{chunk-ZDPUC6CM.js → chunk-6ZVSMA4T.js} +3 -3
- package/dist/{chunk-TXUAGSFR.js → chunk-76MPX7JQ.js} +47 -1
- package/dist/chunk-76MPX7JQ.js.map +1 -0
- package/dist/{chunk-BOQ4HVVH.js → chunk-7ISHKBAD.js} +61 -52
- package/dist/chunk-7ISHKBAD.js.map +1 -0
- package/dist/chunk-7PULOECS.js +22 -0
- package/dist/chunk-7PULOECS.js.map +1 -0
- package/dist/{chunk-KJODHPWM.js → chunk-CPVGRQ43.js} +511 -339
- package/dist/chunk-CPVGRQ43.js.map +1 -0
- package/dist/{chunk-LO6VQ35O.js → chunk-CQZVJVME.js} +2 -2
- package/dist/{chunk-Y43PXON2.js → chunk-EFQUAWWF.js} +577 -546
- package/dist/chunk-EFQUAWWF.js.map +1 -0
- package/dist/{chunk-FPNZMIAW.js → chunk-ELX5YITO.js} +1 -1
- package/dist/chunk-ELX5YITO.js.map +1 -0
- package/dist/chunk-FGAROAUF.js +19 -0
- package/dist/chunk-FGAROAUF.js.map +1 -0
- package/dist/{chunk-HN6MZ2XL.js → chunk-FTNGGR37.js} +641 -466
- package/dist/chunk-FTNGGR37.js.map +1 -0
- package/dist/{chunk-G4F2NWZH.js → chunk-FZ3ZFVAC.js} +4 -4
- package/dist/{chunk-UCCSJX64.js → chunk-GIEUZBQQ.js} +1112 -644
- package/dist/chunk-GIEUZBQQ.js.map +1 -0
- package/dist/{chunk-MEKOWH5E.js → chunk-IVBREL7A.js} +785 -526
- package/dist/chunk-IVBREL7A.js.map +1 -0
- package/dist/{chunk-WSEXFTN4.js → chunk-JBXNU5WD.js} +26 -26
- package/dist/chunk-JBXNU5WD.js.map +1 -0
- package/dist/{chunk-F2VX6TTJ.js → chunk-JRCZHDRG.js} +2 -41
- package/dist/chunk-JRCZHDRG.js.map +1 -0
- package/dist/{chunk-LXYQOOXU.js → chunk-JRW6LCIA.js} +552 -302
- package/dist/chunk-JRW6LCIA.js.map +1 -0
- package/dist/{chunk-TVPH5T4F.js → chunk-KS4I7KVC.js} +16 -22
- package/dist/{chunk-TVPH5T4F.js.map → chunk-KS4I7KVC.js.map} +1 -1
- package/dist/{chunk-J2BBYVGF.js → chunk-MRZP65DZ.js} +1 -117
- package/dist/chunk-MRZP65DZ.js.map +1 -0
- package/dist/{chunk-4ZSLX3LY.js → chunk-OODZCBSM.js} +1 -1
- package/dist/chunk-OODZCBSM.js.map +1 -0
- package/dist/chunk-P4RRC4AO.js +47 -0
- package/dist/chunk-P4RRC4AO.js.map +1 -0
- package/dist/{chunk-ORQD4AUO.js → chunk-PCAY23GS.js} +1 -6
- package/dist/chunk-PCAY23GS.js.map +1 -0
- package/dist/{chunk-NMZUW6VJ.js → chunk-PEJ5OP5B.js} +3 -3
- package/dist/chunk-PEJ5OP5B.js.map +1 -0
- package/dist/{chunk-NHYRIM4I.js → chunk-PIPNDZ6H.js} +304 -194
- package/dist/chunk-PIPNDZ6H.js.map +1 -0
- package/dist/{chunk-L7LQRJGD.js → chunk-TCJ4TMOW.js} +37 -33
- package/dist/{chunk-L7LQRJGD.js.map → chunk-TCJ4TMOW.js.map} +1 -1
- package/dist/chunk-UHSUY6H6.js +79 -0
- package/dist/chunk-UHSUY6H6.js.map +1 -0
- package/dist/{chunk-PDD5A43Y.js → chunk-UTL6TEN6.js} +3 -3
- package/dist/{chunk-VJBFCNAU.js → chunk-UW2DKTEM.js} +123 -130
- package/dist/chunk-UW2DKTEM.js.map +1 -0
- package/dist/{chunk-S27DKRI6.js → chunk-VDYEVCQQ.js} +2 -2
- package/dist/{chunk-UFQM46NV.js → chunk-VK3F4N4U.js} +2 -2
- package/dist/{chunk-6ZIC6OG5.js → chunk-VYBTQK25.js} +126 -122
- package/dist/chunk-VYBTQK25.js.map +1 -0
- package/dist/{chunk-RL3Z747H.js → chunk-W2BV2XOC.js} +1491 -700
- package/dist/chunk-W2BV2XOC.js.map +1 -0
- package/dist/{chunk-FUZETA6Z.js → chunk-X6SZGQTK.js} +2 -2
- package/dist/{chunk-CD2LQXY6.js → chunk-XOHE6SKU.js} +14 -16
- package/dist/{chunk-CD2LQXY6.js.map → chunk-XOHE6SKU.js.map} +1 -1
- package/dist/{chunk-ZBB5KQ6B.js → chunk-Y3GO6SG3.js} +73 -66
- package/dist/chunk-Y3GO6SG3.js.map +1 -0
- package/dist/chunk-ZAMHLXNS.js +56 -0
- package/dist/chunk-ZAMHLXNS.js.map +1 -0
- package/dist/{chunk-RHFN7TUV.js → chunk-ZDHCV462.js} +47 -44
- package/dist/{chunk-RHFN7TUV.js.map → chunk-ZDHCV462.js.map} +1 -1
- package/dist/chunk-ZOS3D26Z.js +72 -0
- package/dist/chunk-ZOS3D26Z.js.map +1 -0
- package/dist/design-canvas/index.js +32 -32
- package/dist/design-canvas/index.js.map +1 -1
- package/dist/design-canvas-react/components/DesignCanvas.d.ts +1 -1
- package/dist/design-canvas-react/components/Workspace.d.ts +1 -1
- package/dist/design-canvas-react/components/glyphs.d.ts +31 -40
- package/dist/design-canvas-react/components/transform-math.d.ts +0 -8
- package/dist/design-canvas-react/components/use-workspace-keyboard.d.ts +2 -2
- package/dist/design-canvas-react/contracts.d.ts +2 -2
- package/dist/design-canvas-react/engine.js +1 -1
- package/dist/design-canvas-react/index.js +9 -7
- package/dist/design-canvas-react/index.js.map +1 -1
- package/dist/design-canvas-react/lazy.js +1 -1
- package/dist/eval/calibration.d.ts +1 -38
- package/dist/eval/index.d.ts +2 -4
- package/dist/eval/index.js +0 -84
- package/dist/eval/index.js.map +1 -1
- package/dist/harness/index.d.ts +1 -1
- package/dist/harness/index.js +1 -1
- package/dist/harness/session-selection.d.ts +2 -2
- package/dist/hub-approvals/index.js +1 -1
- package/dist/hub-approvals/result.d.ts +1 -1
- package/dist/hub-approvals-react/index.js +4 -4
- package/dist/hub-approvals-react/index.js.map +1 -1
- package/dist/hub-approvals-react/parts.d.ts +1 -1
- package/dist/launch-invariants/cli.js +4 -4
- package/dist/launch-invariants/index.js +3 -3
- package/dist/launch-invariants/testing.js +4 -4
- package/dist/legibility/cli.js +1 -1
- package/dist/legibility/index.js +1 -1
- package/dist/{mention-editor-B23OMFT2.js → mention-editor-4BKBMWIK.js} +83 -57
- package/dist/mention-editor-4BKBMWIK.js.map +1 -0
- package/dist/missions/index.js +144 -137
- package/dist/missions/index.js.map +1 -1
- package/dist/operator/index.js +1 -1
- package/dist/peer-floors/check.js +1 -1
- package/dist/peer-floors/cli.js +6 -14
- package/dist/peer-floors/cli.js.map +1 -1
- package/dist/peer-floors/source-entries.d.ts +6 -0
- package/dist/platform/index.js +10 -10
- package/dist/preset-cloudflare/index.js +1 -1
- package/dist/profile/index.d.ts +0 -1
- package/dist/profile/index.js +1 -422
- package/dist/profile/index.js.map +1 -1
- package/dist/profile-editor/server.d.ts +0 -1
- package/dist/profile-editor/server.js +0 -1
- package/dist/profile-editor/server.js.map +1 -1
- package/dist/public-consultation/index.d.ts +2 -2
- package/dist/public-consultation/index.js +6 -6
- package/dist/record/drizzle.js +156 -148
- package/dist/record/drizzle.js.map +1 -1
- package/dist/runtime/index.js +4 -4
- package/dist/runtime/router-turn.js +3 -3
- package/dist/sandbox/index.js +5 -5
- package/dist/sequences/drizzle.js +5 -15
- package/dist/sequences/drizzle.js.map +1 -1
- package/dist/sequences/index.d.ts +1 -0
- package/dist/sequences/index.js +18 -14
- package/dist/sequences/index.js.map +1 -1
- package/dist/sequences/row-mapping.d.ts +7 -0
- package/dist/sequences-react/components/TimelineEditor.d.ts +0 -40
- package/dist/sequences-react/components/TimelineHistory.d.ts +31 -0
- package/dist/sequences-react/components/glyphs.d.ts +12 -21
- package/dist/sequences-react/components/index.d.ts +0 -2
- package/dist/sequences-react/components/interaction-math.d.ts +3 -3
- package/dist/sequences-react/contracts.d.ts +1 -1
- package/dist/sequences-react/engine/snap.d.ts +2 -2
- package/dist/sequences-react/index.js +4 -4
- package/dist/sequences-react/index.js.map +1 -1
- package/dist/settings-react/index.js +13 -30
- package/dist/settings-react/index.js.map +1 -1
- package/dist/settings-react/timezone-picker.d.ts +0 -6
- package/dist/signoff/browser-budget.d.ts +6 -1
- package/dist/signoff/cli.d.ts +0 -7
- package/dist/signoff/cli.js +1 -2
- package/dist/signoff/cli.js.map +1 -1
- package/dist/signoff/index.js +1 -1
- package/dist/skills/index.d.ts +1 -1
- package/dist/skills/index.js +5 -25
- package/dist/skills/marketplace.d.ts +1 -75
- package/dist/skills-placement/box.js +3 -4
- package/dist/skills-placement/box.js.map +1 -1
- package/dist/skills-placement/index.js +3 -4
- package/dist/spend/cli-args.d.ts +1 -1
- package/dist/spend/cli.js +3 -3
- package/dist/spend/cli.js.map +1 -1
- package/dist/spend/index.js +1 -1
- package/dist/stories/design-canvas/fixtures.d.ts +1 -14
- package/dist/stream/index.js +17 -17
- package/dist/studio/generation.d.ts +1 -1
- package/dist/studio/index.js +1 -1
- package/dist/studio-react/index.js +353 -184
- package/dist/studio-react/index.js.map +1 -1
- package/dist/studio-react/studio-composer.d.ts +1 -5
- package/dist/studio-react/studio-history-screen.d.ts +1 -1
- package/dist/teams/invitations-api.d.ts +3 -3
- package/dist/teams/invitations-api.js +74 -72
- package/dist/teams/invitations-api.js.map +1 -1
- package/dist/teams/member-sync.d.ts +2 -0
- package/dist/teams/members-api.d.ts +2 -2
- package/dist/teams/members-api.js +1 -1
- package/dist/teams-react/index.js +28 -45
- package/dist/teams-react/index.js.map +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/mcp-arguments.d.ts +1 -1
- package/dist/trace/index.d.ts +1 -18
- package/dist/trace/index.js +1 -36
- package/dist/trace/index.js.map +1 -1
- package/dist/trace/mission-flow.d.ts +1 -59
- package/dist/turn-health/index.d.ts +1 -1
- package/dist/turn-health/index.js +2 -2
- package/dist/turn-health/sink.d.ts +2 -1
- package/dist/turn-trace/index.js +2 -4
- package/dist/turn-trace/recorder.d.ts +0 -2
- package/dist/vault/VaultPane.d.ts +0 -20
- package/dist/vault/VaultPaneOperations.d.ts +318 -0
- package/dist/vault/index.js +2 -1
- package/dist/vault/index.js.map +1 -1
- package/dist/vault/lazy.js +1 -1
- package/dist/web-react/agent-profile-editor.d.ts +1 -2
- package/dist/web-react/agent-profile-editor.js +6 -5
- package/dist/web-react/chat-composer.d.ts +1 -1
- package/dist/web-react/durable-plan-flow.d.ts +6 -1
- package/dist/web-react/editor-glyphs.d.ts +12 -0
- package/dist/web-react/focus-navigation.d.ts +12 -0
- package/dist/web-react/history-controls.d.ts +37 -0
- package/dist/web-react/index.js +36 -34
- package/dist/web-react/interaction-question-card.d.ts +1 -1
- package/dist/web-react/record-grid-writes.d.ts +31 -0
- package/dist/web-react/record-grid.d.ts +1 -48
- package/dist/web-react/session-history-panel.d.ts +1 -9
- package/dist/web-react/use-document-dark.d.ts +1 -0
- package/dist/workspace-export/engine.d.ts +1 -6
- package/dist/workspace-export/index.js +198 -185
- package/dist/workspace-export/index.js.map +1 -1
- package/dist/workspace-export/routes.d.ts +1 -1
- package/dist/workspace-react/index.js +9 -8
- package/dist/workspace-react/index.js.map +1 -1
- package/package.json +1 -11
- package/dist/VaultPane-RXL3WLA2.js +0 -7
- package/dist/agent-profiles/reaper.d.ts +0 -31
- package/dist/agent-profiles/reaper.js +0 -29
- package/dist/agent-profiles/reaper.js.map +0 -1
- package/dist/chunk-4ZSLX3LY.js.map +0 -1
- package/dist/chunk-5IM2CLYX.js.map +0 -1
- package/dist/chunk-6OSJNJA2.js +0 -251
- package/dist/chunk-6OSJNJA2.js.map +0 -1
- package/dist/chunk-6PRQ45QE.js.map +0 -1
- package/dist/chunk-6ZIC6OG5.js.map +0 -1
- package/dist/chunk-BDEBQ4WO.js +0 -38
- package/dist/chunk-BDEBQ4WO.js.map +0 -1
- package/dist/chunk-BOQ4HVVH.js.map +0 -1
- package/dist/chunk-F2VX6TTJ.js.map +0 -1
- package/dist/chunk-FPNZMIAW.js.map +0 -1
- package/dist/chunk-HN6MZ2XL.js.map +0 -1
- package/dist/chunk-J2BBYVGF.js.map +0 -1
- package/dist/chunk-KJODHPWM.js.map +0 -1
- package/dist/chunk-LTWJYNEC.js +0 -100
- package/dist/chunk-LTWJYNEC.js.map +0 -1
- package/dist/chunk-LXYQOOXU.js.map +0 -1
- package/dist/chunk-MEKOWH5E.js.map +0 -1
- package/dist/chunk-NHYRIM4I.js.map +0 -1
- package/dist/chunk-NMZUW6VJ.js.map +0 -1
- package/dist/chunk-ORQD4AUO.js.map +0 -1
- package/dist/chunk-R4X5474U.js.map +0 -1
- package/dist/chunk-RL3Z747H.js.map +0 -1
- package/dist/chunk-TXUAGSFR.js.map +0 -1
- package/dist/chunk-UCCSJX64.js.map +0 -1
- package/dist/chunk-VJBFCNAU.js.map +0 -1
- package/dist/chunk-WSEXFTN4.js.map +0 -1
- package/dist/chunk-Y43PXON2.js.map +0 -1
- package/dist/chunk-ZBB5KQ6B.js.map +0 -1
- package/dist/eval/parity.d.ts +0 -74
- package/dist/mention-editor-B23OMFT2.js.map +0 -1
- package/dist/profile/humanizer-skill.d.ts +0 -23
- package/dist/profile/humanizer-skill.vendored.d.ts +0 -4
- package/dist/sequences-react/components/BrandMark.d.ts +0 -10
- package/dist/skills/marketplace-drizzle.d.ts +0 -121
- package/dist/skills/marketplace-drizzle.js +0 -34
- package/dist/skills/marketplace-drizzle.js.map +0 -1
- package/dist/teams-react/components/BrandMark.d.ts +0 -10
- /package/dist/{DesignCanvas-L6J72JQ2.js.map → DesignCanvas-IQKYAEC4.js.map} +0 -0
- /package/dist/{DesignCanvasEditor-QFQD63MR.js.map → DesignCanvasEditor-O7OCZTGC.js.map} +0 -0
- /package/dist/{TimelineEditor-7KBPJQLT.js.map → TimelineEditor-VB2UJ34D.js.map} +0 -0
- /package/dist/{VaultPane-RXL3WLA2.js.map → VaultPane-AYW7CO33.js.map} +0 -0
- /package/dist/{chunk-ATQQCG4I.js.map → chunk-2VJLLRVV.js.map} +0 -0
- /package/dist/{chunk-MDRH3SDA.js.map → chunk-54YIL7WM.js.map} +0 -0
- /package/dist/{chunk-6QJ3GB3A.js.map → chunk-5GSZGTPJ.js.map} +0 -0
- /package/dist/{chunk-ZDPUC6CM.js.map → chunk-6ZVSMA4T.js.map} +0 -0
- /package/dist/{chunk-LO6VQ35O.js.map → chunk-CQZVJVME.js.map} +0 -0
- /package/dist/{chunk-G4F2NWZH.js.map → chunk-FZ3ZFVAC.js.map} +0 -0
- /package/dist/{chunk-PDD5A43Y.js.map → chunk-UTL6TEN6.js.map} +0 -0
- /package/dist/{chunk-S27DKRI6.js.map → chunk-VDYEVCQQ.js.map} +0 -0
- /package/dist/{chunk-UFQM46NV.js.map → chunk-VK3F4N4U.js.map} +0 -0
- /package/dist/{chunk-FUZETA6Z.js.map → chunk-X6SZGQTK.js.map} +0 -0
package/dist/record/drizzle.js
CHANGED
|
@@ -289,80 +289,97 @@ function createRecordStore(options) {
|
|
|
289
289
|
}
|
|
290
290
|
return recordFail("supersede-race", `${lastError} (gave up after ${attempts} attempts)`);
|
|
291
291
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
292
|
+
const { list, heads, materialize } = createRecordReads(table, db, storePeriodScope);
|
|
293
|
+
const { validateWrite, insertValues } = createRecordWriteInputs(policy, requireRef, requireQuote, extraColumnNames, tableName, affirmable);
|
|
294
|
+
return { atomicStrategy: strategy, write, review, list, heads, materialize };
|
|
295
|
+
}
|
|
296
|
+
function toFoldable(row) {
|
|
297
|
+
return {
|
|
298
|
+
id: row.id,
|
|
299
|
+
seq: row.seq,
|
|
300
|
+
dimension: row.dimension,
|
|
301
|
+
period: row.period,
|
|
302
|
+
path: row.path,
|
|
303
|
+
itemKey: row.itemKey,
|
|
304
|
+
valueJson: row.valueJson,
|
|
305
|
+
affirmedEmpty: row.affirmedEmpty
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function canonicalize(canonicalizer, path, raw, column) {
|
|
309
|
+
if (!canonicalizer) return recordOk(raw);
|
|
310
|
+
const result = canonicalizer(path, raw);
|
|
311
|
+
if (!result.succeeded) return recordFail("invalid-input", `write: '${path}' ${column} \u2014 ${result.error}`);
|
|
312
|
+
return result;
|
|
313
|
+
}
|
|
314
|
+
function firstRow(rows) {
|
|
315
|
+
return Array.isArray(rows) ? rows[0] : void 0;
|
|
316
|
+
}
|
|
317
|
+
function resolveAtomicStrategy(db) {
|
|
318
|
+
if (typeof db.batch === "function") return "batch";
|
|
319
|
+
if (typeof db.run === "function") return "begin-immediate";
|
|
320
|
+
throw new Error(
|
|
321
|
+
"createRecordStore: the injected driver exposes neither batch() nor run() \u2014 an atomic supersede is impossible on it"
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
async function runGuardedPair(db, strategy, guard, main) {
|
|
325
|
+
if (strategy === "batch") {
|
|
326
|
+
const batch = db.batch;
|
|
327
|
+
if (typeof batch !== "function") {
|
|
328
|
+
throw new Error("runGuardedPair: batch strategy resolved but the driver has no batch()");
|
|
312
329
|
}
|
|
330
|
+
const results = await batch.call(db, [guard, main]);
|
|
331
|
+
const guardRows = results[0];
|
|
332
|
+
const mainRows = Array.isArray(results[1]) ? results[1] : [];
|
|
333
|
+
return {
|
|
334
|
+
guardMatched: Array.isArray(guardRows) && guardRows.length === 1,
|
|
335
|
+
mainMatched: mainRows.length > 0,
|
|
336
|
+
rolledBack: false,
|
|
337
|
+
mainRows
|
|
338
|
+
};
|
|
313
339
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
)).orderBy(asc(table.seq));
|
|
321
|
-
}
|
|
322
|
-
async function heads(input) {
|
|
323
|
-
const period = input.period ?? RECORD_PERIOD_SENTINEL;
|
|
324
|
-
if (!Number.isInteger(period)) {
|
|
325
|
-
return recordFail("invalid-input", `heads: period must be an integer, got ${String(period)}`);
|
|
340
|
+
await db.run(sql2`begin immediate`);
|
|
341
|
+
try {
|
|
342
|
+
const guardRows = await guard;
|
|
343
|
+
if (!Array.isArray(guardRows) || guardRows.length !== 1) {
|
|
344
|
+
await db.run(sql2`rollback`);
|
|
345
|
+
return { guardMatched: false, mainMatched: false, rolledBack: true, mainRows: [] };
|
|
326
346
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
return recordFail("storage-failed", `heads: ${errorMessage(error)}`);
|
|
347
|
+
const mainRows = await main;
|
|
348
|
+
if (!Array.isArray(mainRows) || mainRows.length === 0) {
|
|
349
|
+
await db.run(sql2`rollback`);
|
|
350
|
+
return { guardMatched: true, mainMatched: false, rolledBack: true, mainRows: [] };
|
|
332
351
|
}
|
|
352
|
+
await db.run(sql2`commit`);
|
|
353
|
+
return { guardMatched: true, mainMatched: true, rolledBack: false, mainRows };
|
|
354
|
+
} catch (error) {
|
|
355
|
+
await rollbackQuietly(db);
|
|
356
|
+
throw error;
|
|
333
357
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
if (!folded.succeeded) return folded;
|
|
348
|
-
const periodScope = rules.periodScope ?? storePeriodScope;
|
|
349
|
-
try {
|
|
350
|
-
const proposed = await db.select({ path: table.path, period: table.period, conflict: table.conflict }).from(table).where(and(
|
|
351
|
-
eq(table.scopeId, input.scopeId),
|
|
352
|
-
eq(table.reviewState, "proposed"),
|
|
353
|
-
lte(table.period, period)
|
|
354
|
-
));
|
|
355
|
-
const visible = proposed.filter((row) => recordEntryVisibleInPeriod(periodScope(row.path), row.period, period));
|
|
356
|
-
return recordOk({
|
|
357
|
-
value: folded.value.value,
|
|
358
|
-
entryCount: folded.value.entryCount,
|
|
359
|
-
pendingProposed: visible.length,
|
|
360
|
-
conflicts: visible.filter((row) => row.conflict).length
|
|
361
|
-
});
|
|
362
|
-
} catch (error) {
|
|
363
|
-
return recordFail("storage-failed", `materialize: ${errorMessage(error)}`);
|
|
364
|
-
}
|
|
358
|
+
}
|
|
359
|
+
async function rollbackQuietly(db) {
|
|
360
|
+
try {
|
|
361
|
+
await db.run(sql2`rollback`);
|
|
362
|
+
} catch {
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
function errorMessage(error) {
|
|
366
|
+
const parts = [];
|
|
367
|
+
let cursor = error;
|
|
368
|
+
for (let depth = 0; depth < 5 && cursor instanceof Error; depth++) {
|
|
369
|
+
parts.push(cursor.message);
|
|
370
|
+
cursor = cursor.cause;
|
|
365
371
|
}
|
|
372
|
+
return parts.length > 0 ? parts.join(" \u2014 ") : String(error);
|
|
373
|
+
}
|
|
374
|
+
function isUniqueViolation(error) {
|
|
375
|
+
let cursor = error;
|
|
376
|
+
for (let depth = 0; depth < 5 && cursor instanceof Error; depth++) {
|
|
377
|
+
if (cursor.message.includes("UNIQUE constraint failed")) return true;
|
|
378
|
+
cursor = cursor.cause;
|
|
379
|
+
}
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
function createRecordWriteInputs(policy, requireRef, requireQuote, extraColumnNames, tableName, affirmable) {
|
|
366
383
|
function validateWrite(input) {
|
|
367
384
|
const period = input.period ?? RECORD_PERIOD_SENTINEL;
|
|
368
385
|
const minPeriod = policy.minPeriod ?? RECORD_PERIOD_SENTINEL;
|
|
@@ -481,93 +498,84 @@ function createRecordStore(options) {
|
|
|
481
498
|
reviewedBy: null
|
|
482
499
|
};
|
|
483
500
|
}
|
|
484
|
-
return {
|
|
485
|
-
}
|
|
486
|
-
function toFoldable(row) {
|
|
487
|
-
return {
|
|
488
|
-
id: row.id,
|
|
489
|
-
seq: row.seq,
|
|
490
|
-
dimension: row.dimension,
|
|
491
|
-
period: row.period,
|
|
492
|
-
path: row.path,
|
|
493
|
-
itemKey: row.itemKey,
|
|
494
|
-
valueJson: row.valueJson,
|
|
495
|
-
affirmedEmpty: row.affirmedEmpty
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
function canonicalize(canonicalizer, path, raw, column) {
|
|
499
|
-
if (!canonicalizer) return recordOk(raw);
|
|
500
|
-
const result = canonicalizer(path, raw);
|
|
501
|
-
if (!result.succeeded) return recordFail("invalid-input", `write: '${path}' ${column} \u2014 ${result.error}`);
|
|
502
|
-
return result;
|
|
501
|
+
return { validateWrite, insertValues };
|
|
503
502
|
}
|
|
504
|
-
function
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
if (typeof db.batch === "function") return "batch";
|
|
509
|
-
if (typeof db.run === "function") return "begin-immediate";
|
|
510
|
-
throw new Error(
|
|
511
|
-
"createRecordStore: the injected driver exposes neither batch() nor run() \u2014 an atomic supersede is impossible on it"
|
|
512
|
-
);
|
|
513
|
-
}
|
|
514
|
-
async function runGuardedPair(db, strategy, guard, main) {
|
|
515
|
-
if (strategy === "batch") {
|
|
516
|
-
const batch = db.batch;
|
|
517
|
-
if (typeof batch !== "function") {
|
|
518
|
-
throw new Error("runGuardedPair: batch strategy resolved but the driver has no batch()");
|
|
519
|
-
}
|
|
520
|
-
const results = await batch.call(db, [guard, main]);
|
|
521
|
-
const guardRows = results[0];
|
|
522
|
-
const mainRows = Array.isArray(results[1]) ? results[1] : [];
|
|
523
|
-
return {
|
|
524
|
-
guardMatched: Array.isArray(guardRows) && guardRows.length === 1,
|
|
525
|
-
mainMatched: mainRows.length > 0,
|
|
526
|
-
rolledBack: false,
|
|
527
|
-
mainRows
|
|
528
|
-
};
|
|
529
|
-
}
|
|
530
|
-
await db.run(sql2`begin immediate`);
|
|
531
|
-
try {
|
|
532
|
-
const guardRows = await guard;
|
|
533
|
-
if (!Array.isArray(guardRows) || guardRows.length !== 1) {
|
|
534
|
-
await db.run(sql2`rollback`);
|
|
535
|
-
return { guardMatched: false, mainMatched: false, rolledBack: true, mainRows: [] };
|
|
503
|
+
function createRecordReads(table, db, storePeriodScope) {
|
|
504
|
+
async function list(input) {
|
|
505
|
+
if (input.period !== void 0 && !Number.isInteger(input.period)) {
|
|
506
|
+
return recordFail("invalid-input", `list: period must be an integer, got ${String(input.period)}`);
|
|
536
507
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
await db.
|
|
540
|
-
|
|
508
|
+
try {
|
|
509
|
+
const where = input.period === void 0 ? eq(table.scopeId, input.scopeId) : and(eq(table.scopeId, input.scopeId), lte(table.period, input.period));
|
|
510
|
+
const rows = await db.select().from(table).where(where).orderBy(asc(table.seq));
|
|
511
|
+
const visible = rows.filter((row) => {
|
|
512
|
+
if (input.period !== void 0 && !recordEntryVisibleInPeriod(storePeriodScope(row.path), row.period, input.period)) return false;
|
|
513
|
+
if (input.reviewState !== void 0) {
|
|
514
|
+
if (row.reviewState !== input.reviewState) return false;
|
|
515
|
+
} else if (!input.includeRejected && row.reviewState === "rejected") {
|
|
516
|
+
return false;
|
|
517
|
+
}
|
|
518
|
+
if (!input.includeSuperseded && row.supersededById !== null) return false;
|
|
519
|
+
return true;
|
|
520
|
+
});
|
|
521
|
+
return recordOk(visible);
|
|
522
|
+
} catch (error) {
|
|
523
|
+
return recordFail("storage-failed", `list: ${errorMessage(error)}`);
|
|
541
524
|
}
|
|
542
|
-
await db.run(sql2`commit`);
|
|
543
|
-
return { guardMatched: true, mainMatched: true, rolledBack: false, mainRows };
|
|
544
|
-
} catch (error) {
|
|
545
|
-
await rollbackQuietly(db);
|
|
546
|
-
throw error;
|
|
547
525
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
526
|
+
async function loadHeads(scopeId, period) {
|
|
527
|
+
return db.select().from(table).where(and(
|
|
528
|
+
eq(table.scopeId, scopeId),
|
|
529
|
+
eq(table.reviewState, "accepted"),
|
|
530
|
+
isNull(table.supersededById),
|
|
531
|
+
lte(table.period, period)
|
|
532
|
+
)).orderBy(asc(table.seq));
|
|
553
533
|
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
534
|
+
async function heads(input) {
|
|
535
|
+
const period = input.period ?? RECORD_PERIOD_SENTINEL;
|
|
536
|
+
if (!Number.isInteger(period)) {
|
|
537
|
+
return recordFail("invalid-input", `heads: period must be an integer, got ${String(period)}`);
|
|
538
|
+
}
|
|
539
|
+
try {
|
|
540
|
+
const rows = await loadHeads(input.scopeId, period);
|
|
541
|
+
return recordOk(rows.filter((row) => recordEntryVisibleInPeriod(storePeriodScope(row.path), row.period, period)));
|
|
542
|
+
} catch (error) {
|
|
543
|
+
return recordFail("storage-failed", `heads: ${errorMessage(error)}`);
|
|
544
|
+
}
|
|
561
545
|
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
546
|
+
async function materialize(input) {
|
|
547
|
+
const period = input.period ?? RECORD_PERIOD_SENTINEL;
|
|
548
|
+
if (!Number.isInteger(period)) {
|
|
549
|
+
return recordFail("invalid-input", `materialize: period must be an integer, got ${String(period)}`);
|
|
550
|
+
}
|
|
551
|
+
let loaded;
|
|
552
|
+
try {
|
|
553
|
+
loaded = await loadHeads(input.scopeId, period);
|
|
554
|
+
} catch (error) {
|
|
555
|
+
return recordFail("storage-failed", `materialize: ${errorMessage(error)}`);
|
|
556
|
+
}
|
|
557
|
+
const rules = input.rules.periodScope ? input.rules : { ...input.rules, periodScope: storePeriodScope };
|
|
558
|
+
const folded = foldRecordEntries(loaded.map(toFoldable), { rules, period });
|
|
559
|
+
if (!folded.succeeded) return folded;
|
|
560
|
+
const periodScope = rules.periodScope ?? storePeriodScope;
|
|
561
|
+
try {
|
|
562
|
+
const proposed = await db.select({ path: table.path, period: table.period, conflict: table.conflict }).from(table).where(and(
|
|
563
|
+
eq(table.scopeId, input.scopeId),
|
|
564
|
+
eq(table.reviewState, "proposed"),
|
|
565
|
+
lte(table.period, period)
|
|
566
|
+
));
|
|
567
|
+
const visible = proposed.filter((row) => recordEntryVisibleInPeriod(periodScope(row.path), row.period, period));
|
|
568
|
+
return recordOk({
|
|
569
|
+
value: folded.value.value,
|
|
570
|
+
entryCount: folded.value.entryCount,
|
|
571
|
+
pendingProposed: visible.length,
|
|
572
|
+
conflicts: visible.filter((row) => row.conflict).length
|
|
573
|
+
});
|
|
574
|
+
} catch (error) {
|
|
575
|
+
return recordFail("storage-failed", `materialize: ${errorMessage(error)}`);
|
|
576
|
+
}
|
|
569
577
|
}
|
|
570
|
-
return
|
|
578
|
+
return { list, heads, materialize };
|
|
571
579
|
}
|
|
572
580
|
export {
|
|
573
581
|
RECORD_STORE_COLUMNS,
|