@smart-byte/leani-sdk 0.1.0-rc.1 → 0.1.0-rc.2

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/README.md CHANGED
@@ -29,10 +29,13 @@ const summary = await leani.request<Summary>(
29
29
  );
30
30
  ```
31
31
 
32
- The client rejects absolute and protocol-relative URLs before attaching a
33
- bearer token. Prefer the canonical instance-scoped `basePath` from capability
34
- discovery; short aliases may be absent when several instances share one
35
- extension.
32
+ The client rejects absolute and protocol-relative URLs, path segments that
33
+ decode to `.` or `..`, backslashes, encoded slashes, backslashes, and percent
34
+ signs, and control characters before attaching a bearer token. Every path
35
+ resolves under the base URL's path, one starting with `/` included, and the SDK
36
+ does not follow redirects. Prefer the canonical instance-scoped `basePath` from
37
+ capability discovery; short aliases may be absent when several instances share
38
+ one extension.
36
39
 
37
40
  When an alias is absent, pass the discovered canonical path to the typed
38
41
  helper instead of giving up its response types:
@@ -52,11 +55,15 @@ Historical subscription orchestration and unified live/history iterators are
52
55
  available from `@smart-byte/leani-sdk/backfill`. Required consumers should commit the
53
56
  application transaction before acknowledging the Leani-owned durable cursor.
54
57
  Destination writes must be idempotent because a crash between those steps can
55
- replay a change.
58
+ replay a change. Acknowledge a batch's `ackCursor` (or `acknowledgeableCursor`),
59
+ never a change's own cursor; a backfill session's `deliveryBatches()` yields
60
+ every such boundary with its changes, while `events()` yields changes only.
56
61
 
57
62
  The browser build assumes a same-origin deployment or a reverse proxy that
58
63
  adds the application's CORS policy. Leani does not enable cross-origin access
59
- on its native API by default.
64
+ on its native API by default, and refuses a browser origin that is neither
65
+ loopback nor listed in `api.allowed_origins`. The SDK's mutations without a
66
+ JSON body send `x-leani-request: 1`, which the node requires.
60
67
 
61
68
  Typed subscriptions accept a configured `processor` instance when a kind is
62
69
  ambiguous. `blobs.subscribe()` yields a `{ block, transactions }` payload on
@@ -75,9 +82,16 @@ with `boundaryCursor` and `recovery.follow` set to `null`. `queryAndFollow()`
75
82
  requires delivery and otherwise returns HTTP 409 `delivery_disabled`.
76
83
 
77
84
  Both package entry points use `LeaniError` for HTTP failures, including status,
78
- code, retryability, and request ID. ResetRequiredError is a LeaniError with
85
+ code, retryability, and request ID. A failure below HTTP, such as a refused or
86
+ reset connection or a silent stream, is a retryable `TransportError`, a
87
+ `LeaniError` with status 0. ResetRequiredError is a LeaniError with
79
88
  `code: "cursor_expired"`; rebuild application state from a fresh snapshot.
80
89
 
81
90
  ## License
82
91
 
83
92
  [MIT](LICENSE).
93
+
94
+ Development uses the TypeScript 7 native compiler through `@typescript/native`.
95
+ The pinned `typescript` 5.9 package supplies the JavaScript compiler API required
96
+ by `openapi-typescript`; build and typecheck scripts invoke the native compiler
97
+ explicitly so installing both packages cannot change which compiler runs.
@@ -1,4 +1,4 @@
1
- export { LeaniError } from "./errors.ts";
1
+ export { LeaniError, TransportError } from "./errors.ts";
2
2
  import type { ChangeEnvelope, DurableConsumer, FetchLike, ProcessorSummary } from "./index.ts";
3
3
  export type BackfillExecutionMode = "fill_missing" | "recompute";
4
4
  export type BackfillState = "waiting_for_consumer" | "queued" | "running" | "backpressured" | "storage_backpressured" | "draining" | "complete_reclaimable" | "completed" | "failed" | "cancelled";
@@ -203,6 +203,16 @@ export interface DeliverySession<THello, TRecord> extends AsyncIterable<TRecord>
203
203
  }
204
204
  export interface BackfillDeliverySession<T = unknown> extends DeliverySession<BackfillStreamHello, BackfillStreamRecord<T>> {
205
205
  batches(): AsyncIterable<BackfillStreamBatch<T>>;
206
+ /**
207
+ * Every acknowledgement boundary with the changes it covers: each batch,
208
+ * including one without changes, then the completion. Commit `events`,
209
+ * then acknowledge `ackCursor`.
210
+ */
211
+ deliveryBatches(): AsyncIterable<HistoryDeliveryBatch<T>>;
212
+ /**
213
+ * The batches' changes, flattened. They carry no acknowledgement
214
+ * boundary; acknowledge from `deliveryBatches()` or `batches()`.
215
+ */
206
216
  events(): AsyncIterable<ChangeEnvelope<T>>;
207
217
  }
208
218
  export type LiveDeliverySession<T = unknown> = DeliverySession<LiveStreamHello, LiveStreamRecord<T>>;
@@ -237,6 +247,10 @@ export type UnifiedDeliveryBatch<T = unknown> = {
237
247
  completion?: BackfillStreamCompletion;
238
248
  record: BackfillStreamBatch<T> | BackfillStreamCompletion;
239
249
  };
250
+ /** One history lane's batch, as `BackfillDeliverySession.deliveryBatches()` yields it. */
251
+ export type HistoryDeliveryBatch<T = unknown> = Extract<UnifiedDeliveryBatch<T>, {
252
+ laneKind: "history";
253
+ }>;
240
254
  export interface MultiLaneDelivery<T = unknown> {
241
255
  batches(): AsyncIterable<UnifiedDeliveryBatch<T>>;
242
256
  liveBatches(): AsyncIterable<UnifiedDeliveryBatch<T>>;
@@ -296,4 +310,3 @@ export interface BackfillSubscriptionClient {
296
310
  }
297
311
  export declare function createBackfillSubscriptionClient(options: BackfillSubscriptionClientOptions): BackfillSubscriptionClient;
298
312
  export declare function parseNdjson(body: ReadableStream<Uint8Array>, signal?: AbortSignal): AsyncGenerator<unknown>;
299
- //# sourceMappingURL=backfill.d.ts.map