@streamsy/projection 0.12.0 → 0.14.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.
@@ -30,6 +30,8 @@ type Entry<Inputs extends InputMap> = { readonly [K in keyof Inputs]: {
30
30
  readonly offset?: string;
31
31
  }; }[keyof Inputs];
32
32
  type InputServices<Inputs extends InputMap> = Inputs[keyof Inputs]["stream"]["Identifier"];
33
+ /** A typed handler failure bearing this marker stops its binding without retry. */
34
+ declare const NonRetryable: unique symbol;
33
35
  declare const NotAttached_base: Schema.Class<NotAttached, Schema.TaggedStruct<"NotAttached", {
34
36
  readonly projection: Schema.String;
35
37
  }>, import("effect/Cause").YieldableError>;
@@ -43,7 +45,7 @@ declare const InvalidBinding_base: Schema.Class<InvalidBinding, Schema.TaggedStr
43
45
  declare class InvalidBinding extends InvalidBinding_base {}
44
46
  declare const ProjectionFault_base: Schema.Class<ProjectionFault, Schema.TaggedStruct<"ProjectionFault", {
45
47
  readonly phase: Schema.Literals<readonly ["load", "read", "pin", "process", "checkpoint"]>;
46
- readonly reason: Schema.Literals<readonly ["history-unavailable", "identity-mismatch", "invalid-record", "invalid-source", "invalid-options", "invalid-output", "token-conflict", "output-busy", "range-unreproducible", "stale-epoch", "storage-failure", "unsupported-composition"]>;
48
+ readonly reason: Schema.Literals<readonly ["history-unavailable", "identity-mismatch", "invalid-record", "invalid-source", "invalid-options", "invalid-output", "token-conflict", "output-busy", "range-unreproducible", "stale-epoch", "retired-generation", "storage-failure", "unsupported-composition"]>;
47
49
  readonly input: Schema.optionalKey<Schema.String>;
48
50
  readonly message: Schema.String;
49
51
  readonly cause: Schema.optionalKey<Schema.Defect>;
@@ -62,8 +64,6 @@ interface Range extends Schema.Schema.Type<typeof Range> {}
62
64
  /** `params` holds the decoded values the declaration was bound with. Keys use the encoded strings. */
63
65
  interface Unit<P = Record<string, string>> {
64
66
  readonly projectionId: string;
65
- /** The declared version; defaults to 1. */
66
- readonly version: number;
67
67
  readonly generation: number;
68
68
  readonly params: P;
69
69
  /** The inputs that contributed items or a terminal outcome; retries reproduce these. */
@@ -105,9 +105,9 @@ declare const CheckpointRecord: Schema.Struct<{
105
105
  }>;
106
106
  }>;
107
107
  interface CheckpointRecord extends Schema.Schema.Type<typeof CheckpointRecord> {}
108
+ type RetirementStatus = "retired" | "already-retired";
108
109
  interface ProjectionKey {
109
110
  readonly id: string;
110
- readonly version: number;
111
111
  readonly generation: number;
112
112
  readonly params: Record<string, string>;
113
113
  }
@@ -116,13 +116,47 @@ interface Loaded {
116
116
  readonly record: Option.Option<CheckpointRecord>;
117
117
  readonly token: string;
118
118
  }
119
+ /** A binding found by `CheckpointStoreApi.list`. */
120
+ interface ListedBinding {
121
+ readonly generation: number;
122
+ readonly params: Record<string, string>;
123
+ }
124
+ interface RoutedStreamRecord {
125
+ readonly output: string;
126
+ readonly streamId: string;
127
+ }
128
+ /** Access the route inventory in the checkpoint owner's transaction. */
129
+ interface RouteRecords {
130
+ /** Whether this output owns the stream, including after a forget. */
131
+ readonly has: (key: ProjectionKey, output: string, streamId: string) => Effect.Effect<boolean, ProjectionFault>;
132
+ readonly state: (key: ProjectionKey, output: string, streamId: string) => Effect.Effect<"absent" | "live" | "forgotten", ProjectionFault>;
133
+ readonly add: (key: ProjectionKey, output: string, streamId: string) => Effect.Effect<void, ProjectionFault>;
134
+ /** Lists every route record for the key in unspecified order. */
135
+ readonly list: (key: ProjectionKey) => Effect.Effect<ReadonlyArray<RoutedStreamRecord>, ProjectionFault>;
136
+ /** Mark every route record for the key as forgotten. An absent checkpoint can tolerate unsupported listing. */
137
+ readonly forget: (key: ProjectionKey, options?: {
138
+ readonly ignoreUnsupportedList?: boolean;
139
+ }) => Effect.Effect<void, ProjectionFault>;
140
+ readonly clear: (key: ProjectionKey) => Effect.Effect<void, ProjectionFault>;
141
+ }
119
142
  interface CheckpointStoreApi {
120
143
  readonly load: (key: ProjectionKey) => Effect.Effect<Loaded, ProjectionFault>;
144
+ /**
145
+ * Lists each generation and encoded params with a live checkpoint for an id.
146
+ * Reads every stored version slot, including legacy slots. Each pair appears once,
147
+ * in unspecified order.
148
+ */
149
+ readonly list?: (id: string) => Effect.Effect<ReadonlyArray<ListedBinding>, ProjectionFault>;
150
+ /** Generation-owned streams opened lazily by routed outputs. */
151
+ readonly routes?: RouteRecords;
121
152
  /** Compare-and-set inside the owner transaction; returns the new token. */
122
153
  readonly compareAndSet: (key: ProjectionKey, ifToken: string, record: CheckpointRecord) => Effect.Effect<string, ProjectionFault>;
123
- /** Deletes the record. Absent keys are ignored. */
154
+ /** Deletes a live record. Absent keys and tombstones are ignored. */
124
155
  readonly remove: (key: ProjectionKey) => Effect.Effect<void, ProjectionFault>;
156
+ /** Replaces a live, absent or undecodable record with a tombstone. */
157
+ readonly retire?: (key: ProjectionKey) => Effect.Effect<RetirementStatus, ProjectionFault>;
125
158
  }
159
+ type EncodedEntries = ReadonlyArray<readonly [key: string, encoded: string]>;
126
160
  declare const CheckpointStore_base: Context.ServiceClass<CheckpointStore, "@streamsy/projection/CheckpointStore", CheckpointStoreApi>;
127
161
  /** Stores each projection's offsets and encoded state in one compare-and-set record. */
128
162
  declare class CheckpointStore extends CheckpointStore_base {
@@ -136,6 +170,8 @@ declare class CheckpointStore extends CheckpointStore_base {
136
170
  }
137
171
  /** The encoded seam a checkpoint Layer builds on; both shipped Layers use it. */
138
172
  interface EncodedStore {
173
+ /** A snapshot of the stored entries whose keys start with the exact prefix. */
174
+ readonly list?: (prefix: string) => Effect.Effect<EncodedEntries, ProjectionFault>;
139
175
  readonly read: (key: string) => Effect.Effect<Option.Option<string>, ProjectionFault>;
140
176
  readonly write: (key: string, value: string) => Effect.Effect<void, ProjectionFault>;
141
177
  readonly remove: (key: string) => Effect.Effect<void, ProjectionFault>;
@@ -145,9 +181,8 @@ declare const fromStore: (store: EncodedStore) => CheckpointStoreApi;
145
181
  /** What the kernel needs to locate a record; every projection value satisfies it. */
146
182
  interface Identity {
147
183
  readonly id: string;
148
- readonly version: number;
149
184
  readonly generation: number;
150
185
  readonly params: Record<string, string>;
151
186
  readonly inputs: InputMap;
152
187
  }
153
- export { InputServices as _, Identity as a, Slices as b, fromStore as c, Unit as d, InvalidBinding as f, InputMap as g, Entry as h, EncodedStore as i, recordKey as l, ProjectionFault as m, CheckpointStore as n, Loaded as o, NotAttached as p, CheckpointStoreApi as r, ProjectionKey as s, CheckpointRecord as t, Range as u, ItemOf as v, Slice as y };
188
+ export { ItemOf as C, InputServices as S, Slices as T, NonRetryable as _, Identity as a, Entry as b, ProjectionKey as c, RoutedStreamRecord as d, fromStore as f, InvalidBinding as g, Unit as h, EncodedStore as i, RetirementStatus as l, Range as m, CheckpointStore as n, ListedBinding as o, recordKey as p, CheckpointStoreApi as r, Loaded as s, CheckpointRecord as t, RouteRecords as u, NotAttached as v, Slice as w, InputMap as x, ProjectionFault as y };
@@ -1,2 +1,2 @@
1
- import { c as fromStore, i as EncodedStore, l as recordKey, n as CheckpointStore, o as Loaded, r as CheckpointStoreApi, s as ProjectionKey, t as CheckpointRecord } from "./checkpoint-store-DCfrS4Fd.js";
2
- export { CheckpointRecord, CheckpointStore, type CheckpointStoreApi, type EncodedStore, type Loaded, type ProjectionKey, fromStore, recordKey };
1
+ import { c as ProjectionKey, d as RoutedStreamRecord, f as fromStore, i as EncodedStore, n as CheckpointStore, o as ListedBinding, p as recordKey, r as CheckpointStoreApi, s as Loaded, t as CheckpointRecord, u as RouteRecords } from "./checkpoint-store-Cy5myzCL.js";
2
+ export { CheckpointRecord, CheckpointStore, type CheckpointStoreApi, type EncodedStore, type ListedBinding, type Loaded, type ProjectionKey, type RouteRecords, type RoutedStreamRecord, fromStore, recordKey };
@@ -1 +1 @@
1
- export { t as CheckpointRecord, n as CheckpointStore, i as fromStore, o as recordKey } from "./checkpoint-store--bWf1qeP.js";
1
+ export { t as CheckpointRecord, n as CheckpointStore, a as fromStore, c as recordKey } from "./checkpoint-store-BE0zelau.js";