@niscorp/moss 0.3.2 → 0.3.3

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/DESIGN.md +84 -19
  3. package/DOCS.md +170 -35
  4. package/README.md +2 -2
  5. package/dist/{chunk-J72N3EMJ.js → chunk-4T6KAXBP.js} +45 -27
  6. package/dist/chunk-4T6KAXBP.js.map +1 -0
  7. package/dist/{chunk-ZP3C53AC.js → chunk-AUZMT3GL.js} +739 -654
  8. package/dist/chunk-AUZMT3GL.js.map +1 -0
  9. package/dist/{chunk-ZOEUEMDX.js → chunk-HOZID4EM.js} +131 -16
  10. package/dist/chunk-HOZID4EM.js.map +1 -0
  11. package/dist/chunk-NE2EXMTO.js +103 -0
  12. package/dist/chunk-NE2EXMTO.js.map +1 -0
  13. package/dist/client/node.cjs +1 -1
  14. package/dist/client/node.cjs.map +1 -1
  15. package/dist/client/node.js +1 -1
  16. package/dist/client/node.js.map +1 -1
  17. package/dist/client.cjs +60 -26
  18. package/dist/client.cjs.map +1 -1
  19. package/dist/client.d.cts +6 -1
  20. package/dist/client.d.ts +6 -1
  21. package/dist/client.js +2 -2
  22. package/dist/{document-D9khv9jI.d.cts → document-DhWxieUc.d.cts} +22 -3
  23. package/dist/{document-D9khv9jI.d.ts → document-DhWxieUc.d.ts} +22 -3
  24. package/dist/index.cjs +777 -572
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +19 -3
  27. package/dist/index.d.ts +19 -3
  28. package/dist/index.js +2 -2
  29. package/dist/node.cjs +370 -219
  30. package/dist/node.cjs.map +1 -1
  31. package/dist/node.d.cts +2 -1
  32. package/dist/node.d.ts +2 -1
  33. package/dist/node.js +3 -3
  34. package/dist/terminal/index.cjs +60 -26
  35. package/dist/terminal/index.cjs.map +1 -1
  36. package/dist/terminal/index.js +2 -2
  37. package/dist/vite.cjs +103 -28
  38. package/dist/vite.cjs.map +1 -1
  39. package/dist/vite.d.cts +1 -1
  40. package/dist/vite.d.ts +1 -1
  41. package/dist/vite.js +14 -9
  42. package/dist/vite.js.map +1 -1
  43. package/package.json +9 -9
  44. package/dist/chunk-J72N3EMJ.js.map +0 -1
  45. package/dist/chunk-SUVDISEG.js +0 -64
  46. package/dist/chunk-SUVDISEG.js.map +0 -1
  47. package/dist/chunk-ZOEUEMDX.js.map +0 -1
  48. package/dist/chunk-ZP3C53AC.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,7 +1,8 @@
1
- import { N as NiscRuntime, S as SessionVerifier, L as LayoutVariant, P as PageManifest } from './document-D9khv9jI.cjs';
2
- export { B as Bundle, C as CLOSE_INVALID_TOKEN, a as CLOSE_SHELL_FAILED, b as CLOSE_SIGNED_OUT, c as CallIntegration, d as Catalog, e as ClientMessage, f as Connection, g as Contract, D as DEFAULT_IDENTITY_IDLE_MS, h as DEFAULT_IDENTITY_MAX, i as DEFAULT_IDLE_MS, j as DEFAULT_REVALIDATE_MS, k as DocumentConfig, l as DrawnDocument, E as Emit, m as ExecuteAs, n as ExportedDocument, F as Fabric, o as FabricApply, p as FabricMessage, q as FabricSignal, r as FactIntake, s as FunctionSession, I as IdentityCache, t as IdentityCacheContext, u as IdentityRecord, v as IdentityReport, w as IntakeContext, x as IntakeResult, y as IntegrationRow, M as MOSS_SEQUENCE, z as MossServer, A as NiscApp, G as PressResult, R as RunRecord, H as RunSink, J as RunTurn, K as SNAPSHOT_ELEMENT_ID, O as ServerMessage, Q as ShellHost, T as ShellManifest, U as ShellNeed, V as ShellOpening, W as ShellReport, X as ShellSession, Y as ShellSnapshot, Z as SocketAccept, _ as SocketContext, $ as SpanClock, a0 as StorePress, a1 as Telemetry, a2 as TelemetrySpan, a3 as buildContract, a4 as callIntegrationWith, a5 as contractAsMarkdown, a6 as copyPress, a7 as createIdentityCache, a8 as createServer, a9 as createShellHost, aa as createSocket, ab as defineApp, ac as describePlacements, ad as devSession, ae as documentHeaders, af as embedSnapshot, ag as emitterOf, ah as exportDocuments, ai as filterInstalled, aj as initIntegrations, ak as integrationByKey, al as integrationOfAction, am as listAttachments, an as listIntegrations, ao as listPlacements, ap as loadIntegrationActions, aq as memoKeyOf, ar as mintDevToken, as as renderDocument, at as resolveCatalog, au as resolveCatalogForRoles, av as resolvePolicy, aw as resolvePolicyAtReach, ax as resolvePolicyForRoles, ay as resolveRoles, az as resolveVariants, aA as resolveVariantsForRoles, aB as runIntake, aC as shellNeedOf, aD as spanClock, aE as tokenFromCookie, aF as verifyVariants, aG as wearableOf, aH as wireFabric } from './document-D9khv9jI.cjs';
1
+ import { N as NiscRuntime, S as SessionVerifier, a as NiscApp, L as LayoutVariant, P as PageManifest } from './document-DhWxieUc.cjs';
2
+ export { B as Bundle, C as CLOSE_INVALID_TOKEN, b as CLOSE_SHELL_FAILED, c as CLOSE_SIGNED_OUT, d as CallIntegration, e as Catalog, f as ClientMessage, g as Connection, h as Contract, D as DEFAULT_IDENTITY_IDLE_MS, i as DEFAULT_IDENTITY_MAX, j as DEFAULT_IDLE_MS, k as DEFAULT_REVALIDATE_MS, l as DocumentConfig, m as DrawnDocument, E as Emit, n as ExecuteAs, o as ExportedDocument, F as Fabric, p as FabricApply, q as FabricMessage, r as FabricSignal, s as FactIntake, t as FunctionSession, I as IdentityCache, u as IdentityCacheContext, v as IdentityRecord, w as IdentityReport, x as IntakeContext, y as IntakeResult, z as IntegrationRow, M as MOSS_SEQUENCE, A as MossServer, G as PROTOCOL, H as PressResult, R as RunRecord, J as RunSink, K as RunTurn, O as SNAPSHOT_ELEMENT_ID, Q as ServerMessage, T as ShellHost, U as ShellManifest, V as ShellNeed, W as ShellOpening, X as ShellReport, Y as ShellSession, Z as ShellSnapshot, _ as SocketAccept, $ as SocketContext, a0 as SpanClock, a1 as StorePress, a2 as Telemetry, a3 as TelemetrySpan, a4 as buildContract, a5 as callIntegrationWith, a6 as contractAsMarkdown, a7 as copyPress, a8 as createIdentityCache, a9 as createServer, aa as createShellHost, ab as createSocket, ac as defineApp, ad as describePlacements, ae as devSession, af as documentHeaders, ag as embedSnapshot, ah as emitterOf, ai as exportDocuments, aj as filterInstalled, ak as initIntegrations, al as integrationByKey, am as integrationOfAction, an as listAttachments, ao as listIntegrations, ap as listPlacements, aq as loadIntegrationActions, ar as memoKeyOf, as as mintDevToken, at as offerToken, au as renderDocument, av as resolveCatalog, aw as resolveCatalogForRoles, ax as resolvePolicy, ay as resolvePolicyAtReach, az as resolvePolicyForRoles, aA as resolveRoles, aB as resolveVariants, aC as resolveVariantsForRoles, aD as runIntake, aE as shellNeedOf, aF as spanClock, aG as verifyVariants, aH as wearableOf, aI as wireFabric } from './document-DhWxieUc.cjs';
3
3
  import { Sequence } from '@niscorp/strata';
4
4
  import { PgPool, QueryEngine, DatabaseSchema, SeedEntry, SeedMutation, WriteEvent } from '@niscorp/vex';
5
+ import { MigrateReport } from '@niscorp/strata/postgres';
5
6
  import { TideStore, Tide, Fact, Retention } from '@niscorp/tide';
6
7
  import { ActionDefinition } from '@niscorp/nova';
7
8
  import { ClosureAuditor } from '@niscorp/charter';
@@ -45,6 +46,15 @@ type DataLayer = {
45
46
  };
46
47
  declare const createDataLayer: (runtime: NiscRuntime, entries?: readonly (SeedEntry | SeedMutation)[]) => Promise<DataLayer>;
47
48
 
49
+ type TablesReport = MigrateReport & {
50
+ removed: readonly string[];
51
+ retyped: readonly string[];
52
+ alreadyBroken: readonly string[];
53
+ };
54
+ declare const migrateTables: (runtime: NiscRuntime, app: NiscApp, options?: {
55
+ dryRun?: boolean;
56
+ }) => Promise<TablesReport>;
57
+
48
58
  declare const TIDE_TABLES: readonly ["tide_fact", "tide_run", "tide_work", "tide_reflex_state"];
49
59
  declare const TIDE_DDL = "\nCREATE TABLE IF NOT EXISTS tide_fact (\n id text PRIMARY KEY,\n kind text NOT NULL CHECK (kind IN ('write','signal','manual','run')),\n entity text,\n op text CHECK (op IN ('insert','update','delete')),\n row jsonb,\n name text,\n payload jsonb,\n reflex text,\n run_id text,\n occurrence text,\n stats jsonb,\n target text,\n by text,\n at bigint NOT NULL,\n not_before bigint,\n dedupe_key text,\n cause text,\n depth integer NOT NULL DEFAULT 0,\n delivered_at bigint,\n parked text,\n released boolean,\n -- WHOSE FACT THIS IS. The identity of the reflex that minted it, absent on\n -- anything the host ingested. The matcher refuses to hand a fact minted\n -- under one identity to a reflex running under another, which is the only\n -- thing standing between a carried row and somebody else's effect \u2014 tide is\n -- the one place a row travels without being read, so no scope policy is\n -- consulted on the way.\n as_who text\n);\n\n-- A PARTIAL index, because a fact with no dedupeKey is not claiming to be\n-- unique: it is a distinct occurrence of something, not a repeat of it.\n-- entity is in the key: without it, two producers over different tables\n-- that agreed on a key value silently ate each other's rows.\nCREATE UNIQUE INDEX IF NOT EXISTS tide_fact_dedupe\n ON tide_fact (kind, coalesce(entity,''), coalesce(name,''), dedupe_key)\n WHERE dedupe_key IS NOT NULL;\n\n-- The matcher's query, every advance.\nCREATE INDEX IF NOT EXISTS tide_fact_due\n ON tide_fact (at) WHERE delivered_at IS NULL AND parked IS NULL;\nCREATE INDEX IF NOT EXISTS tide_fact_swept ON tide_fact (delivered_at);\n\nCREATE TABLE IF NOT EXISTS tide_run (\n id text PRIMARY KEY,\n reflex_id text NOT NULL,\n version text NOT NULL,\n as_who text,\n cause text NOT NULL,\n occurrence text,\n fact_ids jsonb,\n state text NOT NULL CHECK (state IN ('pending','fanned','settled','skipped')),\n depth integer NOT NULL DEFAULT 0,\n selected integer,\n total integer NOT NULL DEFAULT 0,\n done integer NOT NULL DEFAULT 0,\n failed integer NOT NULL DEFAULT 0,\n due_at bigint NOT NULL,\n created_at bigint NOT NULL,\n settled_at bigint,\n drained boolean,\n note text,\n -- THE IDEMPOTENCY. One constraint, every trigger kind: an occurrence\n -- cannot open twice, a replayed fact cannot open twice, and two instances\n -- ticking at the same moment contend instead of duplicating.\n UNIQUE (reflex_id, cause)\n);\n\nCREATE INDEX IF NOT EXISTS tide_run_pending ON tide_run (state, due_at);\nCREATE INDEX IF NOT EXISTS tide_run_ledger ON tide_run (reflex_id, created_at DESC);\nCREATE INDEX IF NOT EXISTS tide_run_swept ON tide_run (settled_at);\n\nCREATE TABLE IF NOT EXISTS tide_work (\n id text PRIMARY KEY,\n -- ON DELETE CASCADE, because a run and its work are one fact about the\n -- world. Sweeping runs and leaving work destroys the UNIQUE(run_id, unit)\n -- row that IS the \"this unit already ran\" record \u2014 and a restore then\n -- re-charges the invoice.\n run_id text NOT NULL REFERENCES tide_run(id) ON DELETE CASCADE,\n reflex_id text NOT NULL,\n unit text NOT NULL,\n cause text NOT NULL,\n env jsonb NOT NULL,\n depth integer NOT NULL DEFAULT 0,\n state text NOT NULL CHECK (state IN ('pending','claimed','retrying','done','failed')),\n attempt integer NOT NULL DEFAULT 0,\n token text,\n -- Zero, never null, when unclaimed: \"never claimed or lapsed\" is then one\n -- comparison rather than a disjunction.\n claimed_until bigint NOT NULL DEFAULT 0,\n not_before bigint NOT NULL,\n input jsonb,\n output jsonb,\n error text,\n created_at bigint NOT NULL,\n settled_at bigint,\n UNIQUE (run_id, unit)\n);\n\nCREATE INDEX IF NOT EXISTS tide_work_claimable ON tide_work (state, not_before, claimed_until);\nCREATE INDEX IF NOT EXISTS tide_work_run ON tide_work (run_id);\nCREATE INDEX IF NOT EXISTS tide_work_swept ON tide_work (settled_at);\n\nCREATE TABLE IF NOT EXISTS tide_reflex_state (\n reflex_id text PRIMARY KEY,\n armed_at bigint NOT NULL DEFAULT 0,\n materialized_through bigint\n);\n\n-- Polls are gone (the vex bridge pushes writes \u2014 a poll could only\n-- re-discover them late), and their cursor state goes with them. IF EXISTS,\n-- so a store created after the removal is not asked to drop what it never had.\nALTER TABLE tide_reflex_state DROP COLUMN IF EXISTS poll_cursor;\nALTER TABLE tide_reflex_state DROP COLUMN IF EXISTS poll_seen;\nALTER TABLE tide_reflex_state DROP COLUMN IF EXISTS polled_at;\n";
50
60
  declare const TIDE_SEQUENCE: Sequence;
@@ -93,6 +103,12 @@ declare const createGeneration: (pool: PgPool, ctx: {
93
103
  everyMs?: number;
94
104
  }) => Generation;
95
105
 
106
+ declare const tokenFromCookie: (header: string | null | undefined, name?: string) => string | null;
107
+ declare const sessionCookies: (page: string | Request, token: string | null, options?: {
108
+ key?: string;
109
+ lastsMs?: number | null;
110
+ }) => string[];
111
+
96
112
  type PageMatch = {
97
113
  name: string;
98
114
  params: Record<string, string>;
@@ -102,4 +118,4 @@ type PageRouter = {
102
118
  };
103
119
  declare const createPageRouter: (pages: Record<string, PageManifest>) => PageRouter;
104
120
 
105
- export { type Assertion, type AssertionSigner, DEFAULT_GENERATION_POLL_MS, type DataLayer, GENERATION_DDL, type Generation, LayoutVariant, NiscRuntime, PageManifest, type PageMatch, type PageRouter, SESSIONS_SEQUENCE, SessionVerifier, TIDE_DDL, TIDE_SEQUENCE, TIDE_TABLES, type TideDriver, type TideDriverConfig, type TideStoreOptions, auditClosure, createAssertionSigner, createDataLayer, createGeneration, createPageRouter, createTideDriver, createTideStore, hashIntegrationKey, initSessions, mintIntegrationKey, mintSession, mintWrites, revokeAllFor, revokeSession, sessionOf, sessionVerifierOf, verifyAssertion };
121
+ export { type Assertion, type AssertionSigner, DEFAULT_GENERATION_POLL_MS, type DataLayer, GENERATION_DDL, type Generation, LayoutVariant, NiscApp, NiscRuntime, PageManifest, type PageMatch, type PageRouter, SESSIONS_SEQUENCE, SessionVerifier, TIDE_DDL, TIDE_SEQUENCE, TIDE_TABLES, type TablesReport, type TideDriver, type TideDriverConfig, type TideStoreOptions, auditClosure, createAssertionSigner, createDataLayer, createGeneration, createPageRouter, createTideDriver, createTideStore, hashIntegrationKey, initSessions, migrateTables, mintIntegrationKey, mintSession, mintWrites, revokeAllFor, revokeSession, sessionCookies, sessionOf, sessionVerifierOf, tokenFromCookie, verifyAssertion };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { N as NiscRuntime, S as SessionVerifier, L as LayoutVariant, P as PageManifest } from './document-D9khv9jI.js';
2
- export { B as Bundle, C as CLOSE_INVALID_TOKEN, a as CLOSE_SHELL_FAILED, b as CLOSE_SIGNED_OUT, c as CallIntegration, d as Catalog, e as ClientMessage, f as Connection, g as Contract, D as DEFAULT_IDENTITY_IDLE_MS, h as DEFAULT_IDENTITY_MAX, i as DEFAULT_IDLE_MS, j as DEFAULT_REVALIDATE_MS, k as DocumentConfig, l as DrawnDocument, E as Emit, m as ExecuteAs, n as ExportedDocument, F as Fabric, o as FabricApply, p as FabricMessage, q as FabricSignal, r as FactIntake, s as FunctionSession, I as IdentityCache, t as IdentityCacheContext, u as IdentityRecord, v as IdentityReport, w as IntakeContext, x as IntakeResult, y as IntegrationRow, M as MOSS_SEQUENCE, z as MossServer, A as NiscApp, G as PressResult, R as RunRecord, H as RunSink, J as RunTurn, K as SNAPSHOT_ELEMENT_ID, O as ServerMessage, Q as ShellHost, T as ShellManifest, U as ShellNeed, V as ShellOpening, W as ShellReport, X as ShellSession, Y as ShellSnapshot, Z as SocketAccept, _ as SocketContext, $ as SpanClock, a0 as StorePress, a1 as Telemetry, a2 as TelemetrySpan, a3 as buildContract, a4 as callIntegrationWith, a5 as contractAsMarkdown, a6 as copyPress, a7 as createIdentityCache, a8 as createServer, a9 as createShellHost, aa as createSocket, ab as defineApp, ac as describePlacements, ad as devSession, ae as documentHeaders, af as embedSnapshot, ag as emitterOf, ah as exportDocuments, ai as filterInstalled, aj as initIntegrations, ak as integrationByKey, al as integrationOfAction, am as listAttachments, an as listIntegrations, ao as listPlacements, ap as loadIntegrationActions, aq as memoKeyOf, ar as mintDevToken, as as renderDocument, at as resolveCatalog, au as resolveCatalogForRoles, av as resolvePolicy, aw as resolvePolicyAtReach, ax as resolvePolicyForRoles, ay as resolveRoles, az as resolveVariants, aA as resolveVariantsForRoles, aB as runIntake, aC as shellNeedOf, aD as spanClock, aE as tokenFromCookie, aF as verifyVariants, aG as wearableOf, aH as wireFabric } from './document-D9khv9jI.js';
1
+ import { N as NiscRuntime, S as SessionVerifier, a as NiscApp, L as LayoutVariant, P as PageManifest } from './document-DhWxieUc.js';
2
+ export { B as Bundle, C as CLOSE_INVALID_TOKEN, b as CLOSE_SHELL_FAILED, c as CLOSE_SIGNED_OUT, d as CallIntegration, e as Catalog, f as ClientMessage, g as Connection, h as Contract, D as DEFAULT_IDENTITY_IDLE_MS, i as DEFAULT_IDENTITY_MAX, j as DEFAULT_IDLE_MS, k as DEFAULT_REVALIDATE_MS, l as DocumentConfig, m as DrawnDocument, E as Emit, n as ExecuteAs, o as ExportedDocument, F as Fabric, p as FabricApply, q as FabricMessage, r as FabricSignal, s as FactIntake, t as FunctionSession, I as IdentityCache, u as IdentityCacheContext, v as IdentityRecord, w as IdentityReport, x as IntakeContext, y as IntakeResult, z as IntegrationRow, M as MOSS_SEQUENCE, A as MossServer, G as PROTOCOL, H as PressResult, R as RunRecord, J as RunSink, K as RunTurn, O as SNAPSHOT_ELEMENT_ID, Q as ServerMessage, T as ShellHost, U as ShellManifest, V as ShellNeed, W as ShellOpening, X as ShellReport, Y as ShellSession, Z as ShellSnapshot, _ as SocketAccept, $ as SocketContext, a0 as SpanClock, a1 as StorePress, a2 as Telemetry, a3 as TelemetrySpan, a4 as buildContract, a5 as callIntegrationWith, a6 as contractAsMarkdown, a7 as copyPress, a8 as createIdentityCache, a9 as createServer, aa as createShellHost, ab as createSocket, ac as defineApp, ad as describePlacements, ae as devSession, af as documentHeaders, ag as embedSnapshot, ah as emitterOf, ai as exportDocuments, aj as filterInstalled, ak as initIntegrations, al as integrationByKey, am as integrationOfAction, an as listAttachments, ao as listIntegrations, ap as listPlacements, aq as loadIntegrationActions, ar as memoKeyOf, as as mintDevToken, at as offerToken, au as renderDocument, av as resolveCatalog, aw as resolveCatalogForRoles, ax as resolvePolicy, ay as resolvePolicyAtReach, az as resolvePolicyForRoles, aA as resolveRoles, aB as resolveVariants, aC as resolveVariantsForRoles, aD as runIntake, aE as shellNeedOf, aF as spanClock, aG as verifyVariants, aH as wearableOf, aI as wireFabric } from './document-DhWxieUc.js';
3
3
  import { Sequence } from '@niscorp/strata';
4
4
  import { PgPool, QueryEngine, DatabaseSchema, SeedEntry, SeedMutation, WriteEvent } from '@niscorp/vex';
5
+ import { MigrateReport } from '@niscorp/strata/postgres';
5
6
  import { TideStore, Tide, Fact, Retention } from '@niscorp/tide';
6
7
  import { ActionDefinition } from '@niscorp/nova';
7
8
  import { ClosureAuditor } from '@niscorp/charter';
@@ -45,6 +46,15 @@ type DataLayer = {
45
46
  };
46
47
  declare const createDataLayer: (runtime: NiscRuntime, entries?: readonly (SeedEntry | SeedMutation)[]) => Promise<DataLayer>;
47
48
 
49
+ type TablesReport = MigrateReport & {
50
+ removed: readonly string[];
51
+ retyped: readonly string[];
52
+ alreadyBroken: readonly string[];
53
+ };
54
+ declare const migrateTables: (runtime: NiscRuntime, app: NiscApp, options?: {
55
+ dryRun?: boolean;
56
+ }) => Promise<TablesReport>;
57
+
48
58
  declare const TIDE_TABLES: readonly ["tide_fact", "tide_run", "tide_work", "tide_reflex_state"];
49
59
  declare const TIDE_DDL = "\nCREATE TABLE IF NOT EXISTS tide_fact (\n id text PRIMARY KEY,\n kind text NOT NULL CHECK (kind IN ('write','signal','manual','run')),\n entity text,\n op text CHECK (op IN ('insert','update','delete')),\n row jsonb,\n name text,\n payload jsonb,\n reflex text,\n run_id text,\n occurrence text,\n stats jsonb,\n target text,\n by text,\n at bigint NOT NULL,\n not_before bigint,\n dedupe_key text,\n cause text,\n depth integer NOT NULL DEFAULT 0,\n delivered_at bigint,\n parked text,\n released boolean,\n -- WHOSE FACT THIS IS. The identity of the reflex that minted it, absent on\n -- anything the host ingested. The matcher refuses to hand a fact minted\n -- under one identity to a reflex running under another, which is the only\n -- thing standing between a carried row and somebody else's effect \u2014 tide is\n -- the one place a row travels without being read, so no scope policy is\n -- consulted on the way.\n as_who text\n);\n\n-- A PARTIAL index, because a fact with no dedupeKey is not claiming to be\n-- unique: it is a distinct occurrence of something, not a repeat of it.\n-- entity is in the key: without it, two producers over different tables\n-- that agreed on a key value silently ate each other's rows.\nCREATE UNIQUE INDEX IF NOT EXISTS tide_fact_dedupe\n ON tide_fact (kind, coalesce(entity,''), coalesce(name,''), dedupe_key)\n WHERE dedupe_key IS NOT NULL;\n\n-- The matcher's query, every advance.\nCREATE INDEX IF NOT EXISTS tide_fact_due\n ON tide_fact (at) WHERE delivered_at IS NULL AND parked IS NULL;\nCREATE INDEX IF NOT EXISTS tide_fact_swept ON tide_fact (delivered_at);\n\nCREATE TABLE IF NOT EXISTS tide_run (\n id text PRIMARY KEY,\n reflex_id text NOT NULL,\n version text NOT NULL,\n as_who text,\n cause text NOT NULL,\n occurrence text,\n fact_ids jsonb,\n state text NOT NULL CHECK (state IN ('pending','fanned','settled','skipped')),\n depth integer NOT NULL DEFAULT 0,\n selected integer,\n total integer NOT NULL DEFAULT 0,\n done integer NOT NULL DEFAULT 0,\n failed integer NOT NULL DEFAULT 0,\n due_at bigint NOT NULL,\n created_at bigint NOT NULL,\n settled_at bigint,\n drained boolean,\n note text,\n -- THE IDEMPOTENCY. One constraint, every trigger kind: an occurrence\n -- cannot open twice, a replayed fact cannot open twice, and two instances\n -- ticking at the same moment contend instead of duplicating.\n UNIQUE (reflex_id, cause)\n);\n\nCREATE INDEX IF NOT EXISTS tide_run_pending ON tide_run (state, due_at);\nCREATE INDEX IF NOT EXISTS tide_run_ledger ON tide_run (reflex_id, created_at DESC);\nCREATE INDEX IF NOT EXISTS tide_run_swept ON tide_run (settled_at);\n\nCREATE TABLE IF NOT EXISTS tide_work (\n id text PRIMARY KEY,\n -- ON DELETE CASCADE, because a run and its work are one fact about the\n -- world. Sweeping runs and leaving work destroys the UNIQUE(run_id, unit)\n -- row that IS the \"this unit already ran\" record \u2014 and a restore then\n -- re-charges the invoice.\n run_id text NOT NULL REFERENCES tide_run(id) ON DELETE CASCADE,\n reflex_id text NOT NULL,\n unit text NOT NULL,\n cause text NOT NULL,\n env jsonb NOT NULL,\n depth integer NOT NULL DEFAULT 0,\n state text NOT NULL CHECK (state IN ('pending','claimed','retrying','done','failed')),\n attempt integer NOT NULL DEFAULT 0,\n token text,\n -- Zero, never null, when unclaimed: \"never claimed or lapsed\" is then one\n -- comparison rather than a disjunction.\n claimed_until bigint NOT NULL DEFAULT 0,\n not_before bigint NOT NULL,\n input jsonb,\n output jsonb,\n error text,\n created_at bigint NOT NULL,\n settled_at bigint,\n UNIQUE (run_id, unit)\n);\n\nCREATE INDEX IF NOT EXISTS tide_work_claimable ON tide_work (state, not_before, claimed_until);\nCREATE INDEX IF NOT EXISTS tide_work_run ON tide_work (run_id);\nCREATE INDEX IF NOT EXISTS tide_work_swept ON tide_work (settled_at);\n\nCREATE TABLE IF NOT EXISTS tide_reflex_state (\n reflex_id text PRIMARY KEY,\n armed_at bigint NOT NULL DEFAULT 0,\n materialized_through bigint\n);\n\n-- Polls are gone (the vex bridge pushes writes \u2014 a poll could only\n-- re-discover them late), and their cursor state goes with them. IF EXISTS,\n-- so a store created after the removal is not asked to drop what it never had.\nALTER TABLE tide_reflex_state DROP COLUMN IF EXISTS poll_cursor;\nALTER TABLE tide_reflex_state DROP COLUMN IF EXISTS poll_seen;\nALTER TABLE tide_reflex_state DROP COLUMN IF EXISTS polled_at;\n";
50
60
  declare const TIDE_SEQUENCE: Sequence;
@@ -93,6 +103,12 @@ declare const createGeneration: (pool: PgPool, ctx: {
93
103
  everyMs?: number;
94
104
  }) => Generation;
95
105
 
106
+ declare const tokenFromCookie: (header: string | null | undefined, name?: string) => string | null;
107
+ declare const sessionCookies: (page: string | Request, token: string | null, options?: {
108
+ key?: string;
109
+ lastsMs?: number | null;
110
+ }) => string[];
111
+
96
112
  type PageMatch = {
97
113
  name: string;
98
114
  params: Record<string, string>;
@@ -102,4 +118,4 @@ type PageRouter = {
102
118
  };
103
119
  declare const createPageRouter: (pages: Record<string, PageManifest>) => PageRouter;
104
120
 
105
- export { type Assertion, type AssertionSigner, DEFAULT_GENERATION_POLL_MS, type DataLayer, GENERATION_DDL, type Generation, LayoutVariant, NiscRuntime, PageManifest, type PageMatch, type PageRouter, SESSIONS_SEQUENCE, SessionVerifier, TIDE_DDL, TIDE_SEQUENCE, TIDE_TABLES, type TideDriver, type TideDriverConfig, type TideStoreOptions, auditClosure, createAssertionSigner, createDataLayer, createGeneration, createPageRouter, createTideDriver, createTideStore, hashIntegrationKey, initSessions, mintIntegrationKey, mintSession, mintWrites, revokeAllFor, revokeSession, sessionOf, sessionVerifierOf, verifyAssertion };
121
+ export { type Assertion, type AssertionSigner, DEFAULT_GENERATION_POLL_MS, type DataLayer, GENERATION_DDL, type Generation, LayoutVariant, NiscApp, NiscRuntime, PageManifest, type PageMatch, type PageRouter, SESSIONS_SEQUENCE, SessionVerifier, TIDE_DDL, TIDE_SEQUENCE, TIDE_TABLES, type TablesReport, type TideDriver, type TideDriverConfig, type TideStoreOptions, auditClosure, createAssertionSigner, createDataLayer, createGeneration, createPageRouter, createTideDriver, createTideStore, hashIntegrationKey, initSessions, migrateTables, mintIntegrationKey, mintSession, mintWrites, revokeAllFor, revokeSession, sessionCookies, sessionOf, sessionVerifierOf, tokenFromCookie, verifyAssertion };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export { DEFAULT_GENERATION_POLL_MS, DEFAULT_IDENTITY_IDLE_MS, DEFAULT_IDENTITY_MAX, DEFAULT_IDLE_MS, GENERATION_DDL, MOSS_SEQUENCE, SESSIONS_SEQUENCE, SNAPSHOT_ELEMENT_ID, TIDE_DDL, TIDE_SEQUENCE, TIDE_TABLES, auditClosure, buildContract, callIntegrationWith, contractAsMarkdown, copyPress, createAssertionSigner, createDataLayer, createGeneration, createIdentityCache, createPageRouter, createServer, createShellHost, createTideStore, describePlacements, devSession, documentHeaders, embedSnapshot, exportDocuments, filterInstalled, hashIntegrationKey, initIntegrations, initSessions, integrationByKey, integrationOfAction, listAttachments, listIntegrations, listPlacements, loadIntegrationActions, memoKeyOf, mintDevToken, mintIntegrationKey, mintSession, mintWrites, renderDocument, resolveCatalog, resolveCatalogForRoles, resolvePolicy, resolvePolicyAtReach, resolvePolicyForRoles, resolveRoles, resolveVariants, resolveVariantsForRoles, revokeAllFor, revokeSession, runIntake, sessionOf, sessionVerifierOf, shellNeedOf, tokenFromCookie, verifyAssertion, verifyVariants, wearableOf, wireFabric } from './chunk-ZP3C53AC.js';
2
- export { CLOSE_INVALID_TOKEN, CLOSE_SHELL_FAILED, CLOSE_SIGNED_OUT, DEFAULT_REVALIDATE_MS, createSocket, emitterOf, spanClock } from './chunk-ZOEUEMDX.js';
1
+ export { DEFAULT_GENERATION_POLL_MS, DEFAULT_IDENTITY_IDLE_MS, DEFAULT_IDENTITY_MAX, DEFAULT_IDLE_MS, GENERATION_DDL, MOSS_SEQUENCE, SESSIONS_SEQUENCE, SNAPSHOT_ELEMENT_ID, TIDE_DDL, TIDE_SEQUENCE, TIDE_TABLES, auditClosure, buildContract, callIntegrationWith, contractAsMarkdown, copyPress, createAssertionSigner, createDataLayer, createGeneration, createIdentityCache, createPageRouter, createServer, createShellHost, createTideStore, describePlacements, devSession, documentHeaders, embedSnapshot, exportDocuments, filterInstalled, hashIntegrationKey, initIntegrations, initSessions, integrationByKey, integrationOfAction, listAttachments, listIntegrations, listPlacements, loadIntegrationActions, memoKeyOf, migrateTables, mintDevToken, mintIntegrationKey, mintSession, mintWrites, renderDocument, resolveCatalog, resolveCatalogForRoles, resolvePolicy, resolvePolicyAtReach, resolvePolicyForRoles, resolveRoles, resolveVariants, resolveVariantsForRoles, revokeAllFor, revokeSession, runIntake, sessionOf, sessionVerifierOf, shellNeedOf, verifyAssertion, verifyVariants, wearableOf, wireFabric } from './chunk-AUZMT3GL.js';
2
+ export { CLOSE_INVALID_TOKEN, CLOSE_SHELL_FAILED, CLOSE_SIGNED_OUT, DEFAULT_REVALIDATE_MS, PROTOCOL, createSocket, emitterOf, offerToken, sessionCookies, spanClock, tokenFromCookie } from './chunk-HOZID4EM.js';
3
3
 
4
4
  // src/app.ts
5
5
  var defineApp = (app) => app;