@pgxsinkit/contracts 0.2.5 → 0.2.7
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/event-stream.d.ts +158 -0
- package/dist/event-stream.d.ts.map +1 -0
- package/dist/events.d.ts +158 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +588 -69
- package/dist/index.js.map +11 -7
- package/dist/projection.d.ts +2 -2
- package/dist/projection.d.ts.map +1 -1
- package/dist/registry-diff.d.ts +57 -4
- package/dist/registry-diff.d.ts.map +1 -1
- package/dist/registry-invariant.d.ts +110 -0
- package/dist/registry-invariant.d.ts.map +1 -0
- package/dist/registry.d.ts +144 -1
- package/dist/registry.d.ts.map +1 -1
- package/dist/sql-role-guard.d.ts +21 -0
- package/dist/sql-role-guard.d.ts.map +1 -0
- package/dist/supabase-rls.d.ts +113 -8
- package/dist/supabase-rls.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/registry-authoring/SKILL.md +280 -222
- package/src/event-stream.ts +214 -0
- package/src/events.ts +154 -0
- package/src/index.ts +4 -0
- package/src/projection.ts +7 -2
- package/src/registry-diff.ts +235 -7
- package/src/registry-invariant.ts +218 -0
- package/src/registry.ts +413 -3
- package/src/sql-role-guard.ts +33 -0
- package/src/supabase-rls.ts +336 -48
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Event-stream registration (ADR-0053 decision 1) — the contract half of the **Event lane**, the toolkit's
|
|
4
|
+
* second lane beside the sync rail.
|
|
5
|
+
*
|
|
6
|
+
* An **Event stream** is a named, registered category of append-only client events sharing one payload
|
|
7
|
+
* schema and one consumer-side handling. It is registered on the sync registry
|
|
8
|
+
* (`SyncRegistryDefinition.streams`), where the record KEY is the Event-stream name, so there is one
|
|
9
|
+
* contract artifact rather than a second one to lock, diff and thread through the server and the worker.
|
|
10
|
+
*
|
|
11
|
+
* The registration stays **declarative data only** — no functions. The gating hook (consent/entitlement
|
|
12
|
+
* refusal before enqueue) is a function on `CreateSyncServerOptions`, keyed by Event-stream name, never a
|
|
13
|
+
* field here.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* One claim-derived identity field of an Event stream: the JSON path into the **verified** request claims
|
|
17
|
+
* the value is stamped from at ingest.
|
|
18
|
+
*
|
|
19
|
+
* The same addressing as a managed field's `authClaim` strategy (`ManagedFieldSpec.claimPath`) — `["sub"]`
|
|
20
|
+
* for the auth subject, `["app_metadata", "person_id"]` for an app-minted identity — so the two
|
|
21
|
+
* claim-stamping surfaces of the toolkit read identically. Identity is **server-stamped**, never
|
|
22
|
+
* client-trusted: the client's envelope carries no identity at all (see `eventEnvelopeSchema`), and the
|
|
23
|
+
* stamped value reaches the consumer callback on the queue envelope (`stampedEventSchema`).
|
|
24
|
+
*/
|
|
25
|
+
export interface EventStreamIdentityField {
|
|
26
|
+
/** JSON path into the verified claims; each segment a plain identifier. Must be non-empty. */
|
|
27
|
+
claimPath: readonly string[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A registered Event stream: its payload contract and its claim→identity stamping rule.
|
|
31
|
+
*
|
|
32
|
+
* `payload` is a **strict** zod schema, and strictness is ENFORCED, not merely advertised: an object-rooted
|
|
33
|
+
* payload (including every object inside a union or discriminated union) must carry a `never` catchall —
|
|
34
|
+
* `.strict()` or `z.strictObject()` — or `defineSyncRegistry` rejects the registration. A stripping object
|
|
35
|
+
* would let a misspelled or newly-added key vanish between the caller and the consumer with no verdict
|
|
36
|
+
* anywhere, which is exactly the silence the Event lane's "everything in the Outbox is well-formed"
|
|
37
|
+
* invariant exists to prevent. A NON-object root (a string, array, record, a transform pipeline, …) is
|
|
38
|
+
* accepted unchanged and follows ordinary parse-contract semantics: what the schema ACCEPTS is what
|
|
39
|
+
* `appendEvent` validates, and the JSON-NORMALIZED form of what the schema PRODUCES is what the consumer
|
|
40
|
+
* receives.
|
|
41
|
+
*
|
|
42
|
+
* **The schema EXECUTES at both boundaries; only ONE execution's output is taken.** `appendEvent` runs it as
|
|
43
|
+
* pure validation — the result is discarded and the Outbox stores the value the caller supplied — and the
|
|
44
|
+
* ingestion endpoint runs it again as the one AUTHORITATIVE parse, whose output is what is enqueued and what
|
|
45
|
+
* the consumer callback receives. A transform callback therefore runs twice, so **transforms must be pure
|
|
46
|
+
* and deterministic**: an effectful or environment-dependent one is unsupported, because the server's run is
|
|
47
|
+
* the one that counts and nothing reconciles it against the client's. Parse output the JSON value domain
|
|
48
|
+
* cannot carry (a `BigInt`, `undefined`) is a terminal per-event `rejected` at ingest, never a batch fault.
|
|
49
|
+
*
|
|
50
|
+
* **What is enqueued is the JSON-NORMALIZED parse output, not the parse output itself.** Ingest serializes
|
|
51
|
+
* the authoritative parse's result and enqueues the round-trip, so every queue backend — the in-memory fake
|
|
52
|
+
* and real pgmq's `jsonb` alike — delivers the identical value. The consequence is worth designing against:
|
|
53
|
+
* a transform producing a `Date` reaches the consumer as that date's ISO STRING, and a nested `undefined`
|
|
54
|
+
* property is dropped (an `undefined` array member becomes `null`). A transform that must round-trip as a
|
|
55
|
+
* rich type has to encode it itself.
|
|
56
|
+
*
|
|
57
|
+
* **Schema evolution is compatibility-bound** (ADR-0053 decision 1): a payload schema may evolve only
|
|
58
|
+
* backward-compatibly — it must keep accepting every previously-valid payload, because events written
|
|
59
|
+
* offline under the old schema are still in flight. An incompatible change requires a NEW Event-stream
|
|
60
|
+
* name. The registry lock records a hash of this entry so a change is a reviewable `risky` diff; the hash
|
|
61
|
+
* DETECTS change, it cannot judge compatibility (see `registryEventStreams`).
|
|
62
|
+
*/
|
|
63
|
+
export interface EventStreamEntry<TPayload extends z.ZodType = z.ZodType> {
|
|
64
|
+
payload: TPayload;
|
|
65
|
+
/**
|
|
66
|
+
* The identity fields stamped server-side from verified claims, keyed by field name. The stamped record
|
|
67
|
+
* (field name → value) is what the consumer callback receives on every event.
|
|
68
|
+
*/
|
|
69
|
+
identity: Record<string, EventStreamIdentityField>;
|
|
70
|
+
/**
|
|
71
|
+
* An opaque version counter for the part of this payload contract the lock's hash cannot see — the same
|
|
72
|
+
* role `RowFilterSpec.revision` plays for a `customWhere` closure. The lock hashes the payload schema as
|
|
73
|
+
* a **JSON Schema**, and refinements/transforms are simply not representable there: a reviewer
|
|
74
|
+
* demonstrated that `z.string().refine(v => v.length >= 3)` and the INCOMPATIBLE `>= 10` version produce
|
|
75
|
+
* the identical stream hash, so the `risky` diff the ADR relies on never fires.
|
|
76
|
+
*
|
|
77
|
+
* So: whenever you change acceptance logic a JSON Schema cannot express (any `.refine`/`.superRefine`
|
|
78
|
+
* threshold, a cross-field check, a transform), you MUST bump `revision` (positive integer). That is
|
|
79
|
+
* what surfaces the change in the lock diff, where the compatibility rule can actually be reviewed.
|
|
80
|
+
* Leaving it unchanged after a refinement change silently bypasses the gate.
|
|
81
|
+
*/
|
|
82
|
+
revision?: number;
|
|
83
|
+
}
|
|
84
|
+
/** A registry's Event streams, keyed by Event-stream name (the key IS the name). */
|
|
85
|
+
export type EventStreamRegistry = Record<string, EventStreamEntry>;
|
|
86
|
+
/** The payload TYPE of a registered Event stream — what `appendEvent` accepts for it. */
|
|
87
|
+
export type EventStreamPayload<TEntry extends EventStreamEntry> = TEntry extends EventStreamEntry<infer TPayload> ? z.infer<TPayload> : never;
|
|
88
|
+
/**
|
|
89
|
+
* The queue-name prefix each Event stream's pgmq queue is provisioned under (`pgxsinkit_events_<stream>`,
|
|
90
|
+
* ADR-0053 decision 5). Its length is what bounds {@link EVENT_STREAM_NAME_MAX_LENGTH}.
|
|
91
|
+
*/
|
|
92
|
+
export declare const EVENT_STREAM_QUEUE_PREFIX = "pgxsinkit_events_";
|
|
93
|
+
/**
|
|
94
|
+
* The maximum length of an Event-stream name: **30**. pgmq's queue-name limit is 47 characters and
|
|
95
|
+
* {@link EVENT_STREAM_QUEUE_PREFIX} consumes 17 of them, so a longer name could not be provisioned. The
|
|
96
|
+
* bound is enforced at `defineSyncRegistry` (module eval) rather than at deployment DDL, because a name
|
|
97
|
+
* that fails only when the queue is created fails far too late.
|
|
98
|
+
*/
|
|
99
|
+
export declare const EVENT_STREAM_NAME_MAX_LENGTH: number;
|
|
100
|
+
/**
|
|
101
|
+
* Event-stream names are lowercase `[a-z][a-z0-9_]*` — the intersection of what pgmq accepts unquoted and
|
|
102
|
+
* what stays legible as a queue/table suffix.
|
|
103
|
+
*/
|
|
104
|
+
export declare const EVENT_STREAM_NAME_PATTERN: RegExp;
|
|
105
|
+
/**
|
|
106
|
+
* Declare one Event stream for a registry's `streams` map.
|
|
107
|
+
*
|
|
108
|
+
* The Event-stream NAME is the record key it is registered under, so it is not named here — the name (and
|
|
109
|
+
* this entry's payload/identity shape) is validated fail-closed at `defineSyncRegistry`, which sees the
|
|
110
|
+
* whole map and reports EVERY offender in one error rather than one per build.
|
|
111
|
+
*
|
|
112
|
+
* ```ts
|
|
113
|
+
* import { z } from "zod";
|
|
114
|
+
*
|
|
115
|
+
* export const registry = defineSyncRegistry({
|
|
116
|
+
* tables: { issue },
|
|
117
|
+
* streams: {
|
|
118
|
+
* board_issue_viewed: defineEventStream({
|
|
119
|
+
* payload: z.object({ issueId: z.uuid() }).strict(),
|
|
120
|
+
* identity: { viewerId: { claimPath: ["sub"] } },
|
|
121
|
+
* }),
|
|
122
|
+
* },
|
|
123
|
+
* });
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export declare function defineEventStream<const TPayload extends z.ZodType>(input: {
|
|
127
|
+
payload: TPayload;
|
|
128
|
+
identity: Record<string, EventStreamIdentityField>;
|
|
129
|
+
/** Bump on every change the JSON-Schema hash cannot see. See {@link EventStreamEntry.revision}. */
|
|
130
|
+
revision?: number;
|
|
131
|
+
}): EventStreamEntry<TPayload>;
|
|
132
|
+
/**
|
|
133
|
+
* Whether a value walks and quacks like a zod schema.
|
|
134
|
+
*
|
|
135
|
+
* Duck-typed on `safeParse` (the capability `appendEvent` and the ingest endpoint actually use) rather
|
|
136
|
+
* than `instanceof z.ZodType`: zod is a PEER dependency, so a consumer with a duplicated zod install would
|
|
137
|
+
* fail an `instanceof` against a schema that is perfectly usable.
|
|
138
|
+
*/
|
|
139
|
+
export declare function isZodSchema(value: unknown): value is z.ZodType;
|
|
140
|
+
/**
|
|
141
|
+
* Whether an Event stream's payload schema has a NON-strict object at its root — the one shape
|
|
142
|
+
* `validateEventStreams` refuses (ADR-0053 decision 1: the payload contract is strict, and the promise is
|
|
143
|
+
* enforced rather than advertised).
|
|
144
|
+
*
|
|
145
|
+
* zod v4 models strictness as the object's **catchall**: `.strict()` / `z.strictObject()` set it to
|
|
146
|
+
* `ZodNever`, a bare `z.object()` leaves it unset (unknown keys are silently STRIPPED), and
|
|
147
|
+
* `z.looseObject()` / `.catchall(…)` set something else. So the rule is exactly "an object root's catchall
|
|
148
|
+
* must be `never`", read off `_zod.def` — the same duck-typed posture as {@link isZodSchema}, never an
|
|
149
|
+
* `instanceof` a peer-installed class.
|
|
150
|
+
*
|
|
151
|
+
* A union (or discriminated union) is walked recursively, because each member is equally a root the client
|
|
152
|
+
* may append against. Every other root — string, array, record, a `.transform()` pipeline — is NOT an
|
|
153
|
+
* object and is accepted unchanged. A schema whose internals cannot be read at all (a duplicated zod
|
|
154
|
+
* install, a hand-rolled duck-typed schema) is likewise accepted: this check can only refuse what it can
|
|
155
|
+
* actually see.
|
|
156
|
+
*/
|
|
157
|
+
export declare function hasNonStrictObjectRoot(schema: unknown): boolean;
|
|
158
|
+
//# sourceMappingURL=event-stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-stream.d.ts","sourceRoot":"","sources":["../src/event-stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;GASG;AACH,MAAM,WAAW,wBAAwB;IACvC,8FAA8F;IA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;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAoB/D"}
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* The **Event lane**'s wire contracts (ADR-0053 decision 3 + decision 5): the flush endpoint's request and
|
|
4
|
+
* verdict bodies, the request-shape limits both sides enforce, and the stamped envelope that travels the
|
|
5
|
+
* queue to the consumer callback.
|
|
6
|
+
*
|
|
7
|
+
* The mutation endpoint's sibling, minus what events don't need — no `seq` (a batch's internal order is
|
|
8
|
+
* its array order; the Outbox's local append ordinal stays local) and no base version (nothing to conflict
|
|
9
|
+
* with). Same strictness discipline as `mutation.ts`.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The batch ingestion endpoint. Deliberate constants, not tuning: the client flush loop clamps its
|
|
13
|
+
* batching to them and the server enforces them independently of any client's configuration.
|
|
14
|
+
*
|
|
15
|
+
* **`MAX_EVENTS_PER_BATCH` (1000)** — one flush batch. Large enough that a device draining an offline
|
|
16
|
+
* backlog makes real progress per round trip, small enough that one batch stays a modest request and one
|
|
17
|
+
* queue transaction.
|
|
18
|
+
*
|
|
19
|
+
* **`MAX_EVENT_PAYLOAD_BYTES` (64 KiB)** — the serialized payload of ONE event. Events are facts, not
|
|
20
|
+
* documents; a payload approaching this is a modelling smell. Enforced at `appendEvent` (so the library
|
|
21
|
+
* caller fails at the call site) AND at ingest, where a single oversized payload is a per-event
|
|
22
|
+
* `rejected` verdict rather than a batch fault.
|
|
23
|
+
*
|
|
24
|
+
* **`MAX_EVENT_REQUEST_BYTES` (4 MiB)** — the whole request body, the backstop for the two above (1000
|
|
25
|
+
* events × 64 KiB would exceed it, deliberately: the body cap binds first). A violation is a batch-level
|
|
26
|
+
* 413, reachable only under deployment skew or from a non-library caller.
|
|
27
|
+
*/
|
|
28
|
+
export declare const MAX_EVENTS_PER_BATCH = 1000;
|
|
29
|
+
/** See {@link MAX_EVENTS_PER_BATCH}. Serialized bytes of one event's payload. */
|
|
30
|
+
export declare const MAX_EVENT_PAYLOAD_BYTES: number;
|
|
31
|
+
/** See {@link MAX_EVENTS_PER_BATCH}. Bytes of the whole `POST /api/events` body. */
|
|
32
|
+
export declare const MAX_EVENT_REQUEST_BYTES: number;
|
|
33
|
+
/**
|
|
34
|
+
* The batch event-ingestion endpoint path(s) — the Event lane's twin of the mutation route's
|
|
35
|
+
* `batchMutationPaths`. It lives HERE, in contracts, rather than beside the server route: the same
|
|
36
|
+
* constant is the client flush loop's target and the server's mount point, and the neighbouring
|
|
37
|
+
* request-shape limits are already contracts-level toolkit constants both sides read.
|
|
38
|
+
*/
|
|
39
|
+
export declare const batchEventPaths: readonly ["/api/events"];
|
|
40
|
+
/**
|
|
41
|
+
* One client-produced event as it crosses the wire. The library builds it (`appendEvent` stamps `eventId`
|
|
42
|
+
* and `occurredAtUs`); `stream` is the registered Event-stream name.
|
|
43
|
+
*
|
|
44
|
+
* It carries NO identity: identity is stamped server-side from verified claims per the stream's
|
|
45
|
+
* registration (see `EventStreamIdentityField`), never client-trusted. `stream` is validated only as a
|
|
46
|
+
* non-empty string here — an unregistered name is a per-event `deferred` verdict (ordinary rollout skew),
|
|
47
|
+
* not a framing fault.
|
|
48
|
+
*/
|
|
49
|
+
export declare const eventEnvelopeSchema: z.ZodObject<{
|
|
50
|
+
stream: z.ZodString;
|
|
51
|
+
eventId: z.ZodUUID;
|
|
52
|
+
occurredAtUs: z.ZodString;
|
|
53
|
+
payload: z.ZodUnknown;
|
|
54
|
+
}, z.core.$strict>;
|
|
55
|
+
/**
|
|
56
|
+
* The `POST /api/events` body. A request failing this parse — or exceeding the request-shape limits — is a
|
|
57
|
+
* batch-level 400/413: a malformed item without a parseable `eventId` cannot receive a per-event verdict.
|
|
58
|
+
* That layer is unreachable through the library (appends are validated, envelopes are library-built); it
|
|
59
|
+
* exists for library bugs and non-library callers.
|
|
60
|
+
*/
|
|
61
|
+
export declare const batchEventRequestSchema: z.ZodObject<{
|
|
62
|
+
events: z.ZodArray<z.ZodObject<{
|
|
63
|
+
stream: z.ZodString;
|
|
64
|
+
eventId: z.ZodUUID;
|
|
65
|
+
occurredAtUs: z.ZodString;
|
|
66
|
+
payload: z.ZodUnknown;
|
|
67
|
+
}, z.core.$strict>>;
|
|
68
|
+
}, z.core.$strict>;
|
|
69
|
+
/**
|
|
70
|
+
* The per-event verdict. Three of the four are TERMINAL — the client deletes the Outbox row:
|
|
71
|
+
*
|
|
72
|
+
* - `acked` — enqueued.
|
|
73
|
+
* - `refused` — the consent/entitlement gating hook said no.
|
|
74
|
+
* - `rejected` — a schema-invalid payload for a KNOWN Event stream, or an oversized payload. Given
|
|
75
|
+
* append-time validation and the backward-compatibility rule, this means a non-library caller or a
|
|
76
|
+
* broken consumer deployment — a bug, not a rollout.
|
|
77
|
+
*
|
|
78
|
+
* `deferred` is NOT terminal: an Event stream the server does not (yet) know is ordinary deployment skew
|
|
79
|
+
* (a client rolled out ahead of its server), and deleting those events would be data loss on a normal
|
|
80
|
+
* path. Deferred rows stay in the Outbox, retry with backoff, and drain when the rollout completes.
|
|
81
|
+
*/
|
|
82
|
+
export declare const eventAckStatusSchema: z.ZodEnum<{
|
|
83
|
+
acked: "acked";
|
|
84
|
+
deferred: "deferred";
|
|
85
|
+
refused: "refused";
|
|
86
|
+
rejected: "rejected";
|
|
87
|
+
}>;
|
|
88
|
+
export declare const eventAckSchema: z.ZodObject<{
|
|
89
|
+
eventId: z.ZodUUID;
|
|
90
|
+
status: z.ZodEnum<{
|
|
91
|
+
acked: "acked";
|
|
92
|
+
deferred: "deferred";
|
|
93
|
+
refused: "refused";
|
|
94
|
+
rejected: "rejected";
|
|
95
|
+
}>;
|
|
96
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
97
|
+
}, z.core.$strict>;
|
|
98
|
+
/** The 2xx body: one verdict per well-formed envelope in the request. */
|
|
99
|
+
export declare const batchEventAckSchema: z.ZodObject<{
|
|
100
|
+
acks: z.ZodArray<z.ZodObject<{
|
|
101
|
+
eventId: z.ZodUUID;
|
|
102
|
+
status: z.ZodEnum<{
|
|
103
|
+
acked: "acked";
|
|
104
|
+
deferred: "deferred";
|
|
105
|
+
refused: "refused";
|
|
106
|
+
rejected: "rejected";
|
|
107
|
+
}>;
|
|
108
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
109
|
+
}, z.core.$strict>>;
|
|
110
|
+
}, z.core.$strict>;
|
|
111
|
+
/**
|
|
112
|
+
* The body of a non-2xx batch-event response. Unlike the mutation path there is NO per-item rejection
|
|
113
|
+
* field: a well-formed envelope always gets a per-event verdict in a 2xx `acks` array, so a non-2xx is
|
|
114
|
+
* *always* a whole-batch fault (framing, limits, auth, queue unavailable) with nothing to attribute.
|
|
115
|
+
* Unknown extra fields are stripped.
|
|
116
|
+
*/
|
|
117
|
+
export declare const batchEventErrorSchema: z.ZodObject<{
|
|
118
|
+
message: z.ZodOptional<z.ZodString>;
|
|
119
|
+
}, z.core.$strip>;
|
|
120
|
+
/**
|
|
121
|
+
* The **stamped** envelope (ADR-0053 decision 5): what the server produces at ingest, carries through the
|
|
122
|
+
* queue, and delivers to the consumer callback as-is. `identity` is the record of claim-derived fields the
|
|
123
|
+
* Event stream's registration declares, resolved from the VERIFIED claims of the ingesting request.
|
|
124
|
+
*
|
|
125
|
+
* This is the security-sensitive interface of the lane — the point where a client-supplied event becomes
|
|
126
|
+
* an attributed fact — so its shape is contracts-defined, never implementation-defined. It carries no
|
|
127
|
+
* `stream` (the queue message names it once, below) and no client-supplied identity of any kind.
|
|
128
|
+
*/
|
|
129
|
+
export declare const stampedEventSchema: z.ZodObject<{
|
|
130
|
+
eventId: z.ZodUUID;
|
|
131
|
+
occurredAtUs: z.ZodString;
|
|
132
|
+
identity: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
133
|
+
payload: z.ZodUnknown;
|
|
134
|
+
}, z.core.$strict>;
|
|
135
|
+
/**
|
|
136
|
+
* One queue message: a single-stream sub-batch. The endpoint splits a mixed flush batch by Event stream
|
|
137
|
+
* (preserving array order) and enqueues each sub-batch as ONE message on that stream's queue — one
|
|
138
|
+
* visibility timeout, one ack, one consumer transaction per message. Events arrive at the callback in
|
|
139
|
+
* append order WITHIN a message; across messages there is no ordering promise (ADR-0053 decision 6).
|
|
140
|
+
*/
|
|
141
|
+
export declare const eventQueueMessageSchema: z.ZodObject<{
|
|
142
|
+
stream: z.ZodString;
|
|
143
|
+
events: z.ZodArray<z.ZodObject<{
|
|
144
|
+
eventId: z.ZodUUID;
|
|
145
|
+
occurredAtUs: z.ZodString;
|
|
146
|
+
identity: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
147
|
+
payload: z.ZodUnknown;
|
|
148
|
+
}, z.core.$strict>>;
|
|
149
|
+
}, z.core.$strict>;
|
|
150
|
+
export type EventEnvelope = z.infer<typeof eventEnvelopeSchema>;
|
|
151
|
+
export type BatchEventRequest = z.infer<typeof batchEventRequestSchema>;
|
|
152
|
+
export type EventAckStatus = z.infer<typeof eventAckStatusSchema>;
|
|
153
|
+
export type EventAck = z.infer<typeof eventAckSchema>;
|
|
154
|
+
export type BatchEventAck = z.infer<typeof batchEventAckSchema>;
|
|
155
|
+
export type BatchEventError = z.infer<typeof batchEventErrorSchema>;
|
|
156
|
+
export type StampedEvent = z.infer<typeof stampedEventSchema>;
|
|
157
|
+
export type EventQueueMessage = z.infer<typeof eventQueueMessageSchema>;
|
|
158
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,oBAAoB,OAAO,CAAC;AACzC,iFAAiF;AACjF,eAAO,MAAM,uBAAuB,QAAY,C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CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,13 +2,17 @@ export * from "./apply-strategy";
|
|
|
2
2
|
export * from "./common";
|
|
3
3
|
export * from "./config";
|
|
4
4
|
export * from "./convergence-model";
|
|
5
|
+
export * from "./event-stream";
|
|
6
|
+
export * from "./events";
|
|
5
7
|
export * from "./fingerprint";
|
|
6
8
|
export * from "./registry";
|
|
7
9
|
export * from "./registry-diff";
|
|
10
|
+
export * from "./registry-invariant";
|
|
8
11
|
export * from "./mutation";
|
|
9
12
|
export * from "./projection";
|
|
10
13
|
export * from "./runtime";
|
|
11
14
|
export * from "./sql-defaults";
|
|
12
15
|
export * from "./sql-identifier";
|
|
16
|
+
export * from "./sql-role-guard";
|
|
13
17
|
export * from "./supabase-rls";
|
|
14
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
|