@gusto/baerly-storage 0.2.0 → 0.4.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/LICENSE +202 -0
- package/NOTICE +29 -0
- package/README.md +176 -70
- package/dist/API.md +213 -139
- package/dist/CHANGELOG.md +434 -0
- package/dist/RECIPES.md +125 -0
- package/dist/THIRD-PARTY-LICENSES.txt +238 -0
- package/dist/{app-config-C0Bbw_Z6.d.ts → app-config-DyiFK3_k.d.ts} +55 -11
- package/dist/app-config.d.ts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +301 -301
- package/dist/auth.js.map +1 -1
- package/dist/aws4fetch.esm-p7eEzLCs.js +1702 -0
- package/dist/aws4fetch.esm-p7eEzLCs.js.map +1 -0
- package/dist/baerly.js +35 -15
- package/dist/baerly.js.map +1 -1
- package/dist/baerly.spec.json +342 -0
- package/dist/bytes-BXdamO3L.js.map +1 -1
- package/dist/{client-DYZfoZb9.d.ts → client-Fe8CwB73.d.ts} +10 -10
- package/dist/client-react.d.ts +3 -3
- package/dist/client-react.js +4 -4
- package/dist/client-react.js.map +1 -1
- package/dist/client.d.ts +4 -4
- package/dist/client.js +3 -3
- package/dist/client.js.map +1 -1
- package/dist/{cloudflare-CINJPKCW.js → cloudflare-DzKBrUlg.js} +178 -2
- package/dist/cloudflare-DzKBrUlg.js.map +1 -0
- package/dist/cloudflare.d.ts +49 -6
- package/dist/cloudflare.js +59 -26
- package/dist/cloudflare.js.map +1 -1
- package/dist/config-1tv0-Yzm.js +2693 -0
- package/dist/config-1tv0-Yzm.js.map +1 -0
- package/dist/constants-CfeMWQWk.js +222 -0
- package/dist/constants-CfeMWQWk.js.map +1 -0
- package/dist/context-DRZ3tZ5l.js.map +1 -1
- package/dist/{cost-CQt1YRkA.js → cost-DSMIVqzL.js} +43 -42
- package/dist/cost-DSMIVqzL.js.map +1 -0
- package/dist/current-json-C6nhPOm1.js +190 -0
- package/dist/current-json-C6nhPOm1.js.map +1 -0
- package/dist/{db-BM3y2JQw.d.ts → db-DsPkOVEH.d.ts} +26 -108
- package/dist/{deploy-CrAbfgCq.js → deploy-DonTr-CV.js} +12 -5
- package/dist/deploy-DonTr-CV.js.map +1 -0
- package/dist/dev-vite.d.ts +11 -7
- package/dist/dev-vite.js +7 -6
- package/dist/dev-vite.js.map +1 -1
- package/dist/dev.d.ts +1 -1
- package/dist/dev.js +1 -1
- package/dist/{doctor-Db-hzPmE.js → doctor-DSIyCDg_.js} +14 -136
- package/dist/doctor-DSIyCDg_.js.map +1 -0
- package/dist/{dump-BYA55NLP.js → dump-Bh5k26VQ.js} +10 -31
- package/dist/dump-Bh5k26VQ.js.map +1 -0
- package/dist/{errors-DOdL95kK.js → errors-Dfa3p78c.js} +25 -5
- package/dist/errors-Dfa3p78c.js.map +1 -0
- package/dist/{export-Bhbz90-z.js → export-DtF5tDIM.js} +11 -32
- package/dist/{export-Bhbz90-z.js.map → export-DtF5tDIM.js.map} +1 -1
- package/dist/{fsck-CPPZWt9p.js → fsck-D_djMO5D.js} +28 -39
- package/dist/fsck-D_djMO5D.js.map +1 -0
- package/dist/{http-Cw8p6y5b.js → http-DxM9MflO.js} +151 -79
- package/dist/http-DxM9MflO.js.map +1 -0
- package/dist/http.d.ts +42 -26
- package/dist/http.js +3 -2
- package/dist/{index-DwDTWPSU.d.ts → index-0rZcMBwy.d.ts} +10 -7
- package/dist/{index-C3JAH1Yo.d.ts → index-B6oexfOB.d.ts} +9 -9
- package/dist/{index-cUY-36AN.d.ts → index-BNRh23K9.d.ts} +21 -5
- package/dist/{index-DSvwEUeF.d.ts → index-BYk9oCNf.d.ts} +240 -202
- package/dist/index.d.ts +6 -6
- package/dist/index.js +5 -5
- package/dist/{indexes-DAu2AkTW.d.ts → indexes-Dn9hbGQG.d.ts} +2 -2
- package/dist/{inspect-Bdbzvi-_.js → inspect-6WZ-pC7-.js} +21 -36
- package/dist/inspect-6WZ-pC7-.js.map +1 -0
- package/dist/key-Di6yyxFu.js +35 -0
- package/dist/key-Di6yyxFu.js.map +1 -0
- package/dist/{snapshot-SS8USDUF.js → log-tail-D98U1JBo.js} +179 -84
- package/dist/log-tail-D98U1JBo.js.map +1 -0
- package/dist/{maintenance-ClzBC1Vv.js → maintenance-B4Dki6Ig.js} +438 -176
- package/dist/maintenance-B4Dki6Ig.js.map +1 -0
- package/dist/{maintenance-BRrThz8V.d.ts → maintenance-B_e0T99L.d.ts} +114 -26
- package/dist/{maintenance-BvOv6BMM.js → maintenance-C7coQp4c.js} +217 -94
- package/dist/maintenance-C7coQp4c.js.map +1 -0
- package/dist/maintenance.d.ts +3 -2
- package/dist/maintenance.js +3 -2
- package/dist/node.d.ts +176 -68
- package/dist/node.js +3 -2
- package/dist/{normalize-XWY25_sG.js → normalize-rjnZLwS4.js} +2 -2
- package/dist/normalize-rjnZLwS4.js.map +1 -0
- package/dist/{observability-CpOiEN0k.js → observability-wzs3-BL_.js} +279 -109
- package/dist/observability-wzs3-BL_.js.map +1 -0
- package/dist/observability.d.ts +3 -3
- package/dist/observability.js +1 -1
- package/dist/{plan-DOTl21vq.js → plan-a7PJHBCy.js} +7 -4
- package/dist/plan-a7PJHBCy.js.map +1 -0
- package/dist/{query-BmiQy328.js → query-rAtXNQQB.js} +1063 -1202
- package/dist/query-rAtXNQQB.js.map +1 -0
- package/dist/{rebuild-index-DC_nR6wP.js → rebuild-index-BVzQSZlm.js} +10 -32
- package/dist/rebuild-index-BVzQSZlm.js.map +1 -0
- package/dist/{request-BEF_OvMh.js → request-u0M51mhJ.js} +3 -3
- package/dist/{request-BEF_OvMh.js.map → request-u0M51mhJ.js.map} +1 -1
- package/dist/restore-R-4rbciV.js +778 -0
- package/dist/restore-R-4rbciV.js.map +1 -0
- package/dist/runtime-spec-qL3_lTTU.js +391 -0
- package/dist/runtime-spec-qL3_lTTU.js.map +1 -0
- package/dist/s3-http-B-z8th6O.d.ts +60 -0
- package/dist/s3.d.ts +47 -0
- package/dist/s3.js +45 -0
- package/dist/s3.js.map +1 -0
- package/dist/{shared-secret-BJdSwpgw.js → shared-secret-DgEicd3x.js} +13 -5
- package/dist/shared-secret-DgEicd3x.js.map +1 -0
- package/dist/src-BG20LZs7.js +2271 -0
- package/dist/src-BG20LZs7.js.map +1 -0
- package/dist/{src-zhEAmmF7.js → src-CYHFDrKz.js} +82 -99
- package/dist/src-CYHFDrKz.js.map +1 -0
- package/dist/{src-QQ7jDeL2.js → src-DYZ4H1aF.js} +44 -23
- package/dist/src-DYZ4H1aF.js.map +1 -0
- package/dist/subcommand-DoDA-K7d.js +197 -0
- package/dist/subcommand-DoDA-K7d.js.map +1 -0
- package/dist/time-DUqvFMHq.js +119 -0
- package/dist/time-DUqvFMHq.js.map +1 -0
- package/dist/{usage-CLjirdD-.js → usage-DBV1eQHC.js} +7 -22
- package/dist/usage-DBV1eQHC.js.map +1 -0
- package/dist/{validate-DCq_0DIn.js → validate-DtljsCh1.js} +51 -51
- package/dist/{validate-DCq_0DIn.js.map → validate-DtljsCh1.js.map} +1 -1
- package/dist/wire-izfGZDvr.js.map +1 -1
- package/package.json +77 -42
- package/dist/cloudflare-CINJPKCW.js.map +0 -1
- package/dist/config-DVfDGyw1.js +0 -278
- package/dist/config-DVfDGyw1.js.map +0 -1
- package/dist/cost-CQt1YRkA.js.map +0 -1
- package/dist/current-json-C-EyJqs0.js +0 -354
- package/dist/current-json-C-EyJqs0.js.map +0 -1
- package/dist/deploy-CrAbfgCq.js.map +0 -1
- package/dist/doctor-Db-hzPmE.js.map +0 -1
- package/dist/dump-BYA55NLP.js.map +0 -1
- package/dist/errors-DOdL95kK.js.map +0 -1
- package/dist/fsck-CPPZWt9p.js.map +0 -1
- package/dist/http-Cw8p6y5b.js.map +0 -1
- package/dist/inspect-Bdbzvi-_.js.map +0 -1
- package/dist/maintenance-BvOv6BMM.js.map +0 -1
- package/dist/maintenance-ClzBC1Vv.js.map +0 -1
- package/dist/normalize-XWY25_sG.js.map +0 -1
- package/dist/observability-CpOiEN0k.js.map +0 -1
- package/dist/plan-DOTl21vq.js.map +0 -1
- package/dist/query-BmiQy328.js.map +0 -1
- package/dist/rebuild-index-DC_nR6wP.js.map +0 -1
- package/dist/restore-C6IcmLeA.js +0 -771
- package/dist/restore-C6IcmLeA.js.map +0 -1
- package/dist/shared-secret-BJdSwpgw.js.map +0 -1
- package/dist/snapshot-SS8USDUF.js.map +0 -1
- package/dist/src-DU1sCMlr.js +0 -6236
- package/dist/src-DU1sCMlr.js.map +0 -1
- package/dist/src-QQ7jDeL2.js.map +0 -1
- package/dist/src-zhEAmmF7.js.map +0 -1
- package/dist/subcommand-DZcHcsYp.js +0 -5122
- package/dist/subcommand-DZcHcsYp.js.map +0 -1
- package/dist/usage-CLjirdD-.js.map +0 -1
- /package/dist/{chunk-EAsCxrDo.js → rolldown-runtime-EAsCxrDo.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as IndexDefinition, f as DocumentData, n as BaerlyAppConfig, r as BaerlyConfig, u as SchemaValidator } from "./app-config-
|
|
2
|
-
import {
|
|
1
|
+
import { d as IndexDefinition, f as DocumentData, n as BaerlyAppConfig, r as BaerlyConfig, u as SchemaValidator, v as SNAPSHOT_SCHEMA_VERSION } from "./app-config-DyiFK3_k.js";
|
|
2
|
+
import { n as LogEntry, p as Storage, r as Verifier } from "./index-BYk9oCNf.js";
|
|
3
3
|
//#region packages/server/src/config.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Flatten `BaerlyConfig.collections` into the per-collection
|
|
@@ -84,7 +84,7 @@ declare const snapshotKey: (collectionPrefix: string, minSeq: number, maxSeq: nu
|
|
|
84
84
|
* leaves an orphan.
|
|
85
85
|
*/
|
|
86
86
|
interface SnapshotBody {
|
|
87
|
-
readonly schema_version:
|
|
87
|
+
readonly schema_version: typeof SNAPSHOT_SCHEMA_VERSION;
|
|
88
88
|
readonly min_seq: number;
|
|
89
89
|
readonly max_seq: number;
|
|
90
90
|
readonly collection: string;
|
|
@@ -142,5 +142,21 @@ declare const walkLogRange: (storage: Storage, logPrefix: string, fromSeq: numbe
|
|
|
142
142
|
signal?: AbortSignal;
|
|
143
143
|
}) => Promise<LogEntry[]>;
|
|
144
144
|
//#endregion
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
//#region packages/server/src/log-tail.d.ts
|
|
146
|
+
/**
|
|
147
|
+
* Discover the true committed tail and fold entries in `[hint, tail)`.
|
|
148
|
+
* `tail` is the first empty seq (>= hint); `entries` are the
|
|
149
|
+
* LogEntries in `[hint, tail)` in seq order. `cap` bounds the walk;
|
|
150
|
+
* exhausting it THROWS `Internal` (never silently truncates) — see
|
|
151
|
+
* the cap-exhaustion comment below.
|
|
152
|
+
*/
|
|
153
|
+
declare const probeTailFrom: (storage: Storage, logPrefix: string, hint: number, opts?: {
|
|
154
|
+
signal?: AbortSignal;
|
|
155
|
+
cap?: number;
|
|
156
|
+
}) => Promise<{
|
|
157
|
+
tail: number;
|
|
158
|
+
entries: LogEntry[];
|
|
159
|
+
}>;
|
|
160
|
+
//#endregion
|
|
161
|
+
export { loadSnapshotAsMap as a, collectionsToMaps as c, encodeSnapshotBody as i, walkLogRange as n, snapshotKey as o, SnapshotBody as r, resolveVerifier as s, probeTailFrom as t };
|
|
162
|
+
//# sourceMappingURL=index-BNRh23K9.d.ts.map
|
|
@@ -1,4 +1,165 @@
|
|
|
1
|
-
import { f as DocumentData, m as JSONValue, p as DocumentValue } from "./app-config-
|
|
1
|
+
import { f as DocumentData, m as JSONValue, p as DocumentValue } from "./app-config-DyiFK3_k.js";
|
|
2
|
+
//#region packages/protocol/src/errors.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Discriminator for {@link BaerlyError}. Strings (not subclasses) so they
|
|
5
|
+
* survive cross-realm boundaries (e.g. a Web Worker) and so callers can
|
|
6
|
+
* pattern-match with grep-friendly equality.
|
|
7
|
+
*/
|
|
8
|
+
type BaerlyErrorCode = /** Caller-provided config or input is invalid (bad bucket, unsupported credential type, malformed URL, bucket not version-enabled when versioning was requested). */"InvalidConfig" /** Generic S3/HTTP transport failure (5xx, unexpected status, retries exhausted). */ | "NetworkError" /** S3 returned 403. Either credentials are wrong or the bucket policy denies the operation. */ | "AccessDenied" /** Server returned data that didn't parse (malformed XML, non-JSON body where JSON expected). */ | "InvalidResponse" /** Internal invariant violation — should not be reachable. File a bug. */ | "Internal"
|
|
9
|
+
/**
|
|
10
|
+
* Document body failed schema validation. Emitted by the table-API
|
|
11
|
+
* write verbs (`Collection.insert`, `Query.update`, `Collection.replace`) when
|
|
12
|
+
* the body is not valid JSON or contains an array where
|
|
13
|
+
* `DocumentValue` is required; also emitted when a collection has a
|
|
14
|
+
* declared `SchemaValidator` (via `Db.create({ collections })`) and
|
|
15
|
+
* the bound schema rejects the doc. In the schema-rejection case the
|
|
16
|
+
* error carries an `issues` array describing each failure. HTTP layer
|
|
17
|
+
* maps this to 400.
|
|
18
|
+
*/
|
|
19
|
+
| "SchemaError"
|
|
20
|
+
/**
|
|
21
|
+
* Write conflicted with current state: CAS retry budget exhausted,
|
|
22
|
+
* duplicate caller-supplied `_id`, or an already-existing guarded
|
|
23
|
+
* storage key. Check `BaerlyError.retriable` to decide whether the
|
|
24
|
+
* same logical operation should be retried.
|
|
25
|
+
*/
|
|
26
|
+
| "Conflict"
|
|
27
|
+
/**
|
|
28
|
+
* `Verifier` returned no identity. HTTP server maps to 401.
|
|
29
|
+
* Code is reserved here so the union locks.
|
|
30
|
+
*/
|
|
31
|
+
| "Unauthorized"
|
|
32
|
+
/**
|
|
33
|
+
* The addressed resource does not exist. HTTP server maps to 404.
|
|
34
|
+
* Emitted by the row-by-id read / update / delete handlers in
|
|
35
|
+
* `packages/server/src/http/router.ts` when the predicate
|
|
36
|
+
* `{ _id }` matches zero rows. Not a protocol invariant —
|
|
37
|
+
* callers may retry after creating the resource or treat as a
|
|
38
|
+
* miss depending on intent. The CLI maps this to the generic
|
|
39
|
+
* exit-2 "storage error" bucket, not the exit-3 "protocol
|
|
40
|
+
* invariant" bucket.
|
|
41
|
+
*/
|
|
42
|
+
| "NotFound"
|
|
43
|
+
/**
|
|
44
|
+
* Request body exceeded the server's size cap. HTTP server maps
|
|
45
|
+
* to 413. Cap is `MAX_BODY_BYTES` (1 MiB today; exported from
|
|
46
|
+
* `packages/server/src/http/router.ts`). The Node adapter
|
|
47
|
+
* enforces during the `node:http` stream pump so the process
|
|
48
|
+
* never materializes a multi-MiB body; Workers also rely on
|
|
49
|
+
* platform-side caps (16 MB free / 100 MB paid).
|
|
50
|
+
*/
|
|
51
|
+
| "PayloadTooLarge"
|
|
52
|
+
/**
|
|
53
|
+
* A predicate is structurally well-formed but contradicts itself —
|
|
54
|
+
* no document can match. Emitted by `validateWire` and
|
|
55
|
+
* `mergePredicateWires`. Triggers:
|
|
56
|
+
* - `{ clauses: [{op:"in", field:"priority", value:[]}] }` (empty `in` set)
|
|
57
|
+
* - an `eq` clause with a value outside the residual interval
|
|
58
|
+
* established by range clauses on the same field
|
|
59
|
+
* - merging `{op:"gt", value:10}` with `{op:"lt", value:5}` on the
|
|
60
|
+
* same field (empty interval)
|
|
61
|
+
* - merging two `in` clauses on the same field with empty intersection
|
|
62
|
+
*
|
|
63
|
+
* Conflicting equality across clauses (`eq:"open"` + `eq:"closed"` on
|
|
64
|
+
* the same field) surfaces as `InvalidConfig` rather than this code —
|
|
65
|
+
* the merger treats it as a caller-side configuration bug, not an
|
|
66
|
+
* algebraic contradiction.
|
|
67
|
+
*
|
|
68
|
+
* The HTTP layer treats this as a 400 (caller error). The distinct
|
|
69
|
+
* code lets downstream code short-circuit empty-by-construction
|
|
70
|
+
* without re-running the validator or parsing messages.
|
|
71
|
+
*/
|
|
72
|
+
| "UnsatisfiablePredicate"
|
|
73
|
+
/**
|
|
74
|
+
* A `useQuery` callback awaited a recorder terminal
|
|
75
|
+
* (`.get`/`.first`/`.all`/`.count`). The recorder runs once per
|
|
76
|
+
* render to capture the chain shape; it cannot survive an `await`
|
|
77
|
+
* because the proxy doesn't proxy across microtask boundaries. The
|
|
78
|
+
* recorder's terminal returns a thenable whose `.then` throws this
|
|
79
|
+
* error synchronously, converting what would otherwise be a silent
|
|
80
|
+
* spinner-hang into a render-time error the hook surfaces as
|
|
81
|
+
* `status: "error"`. Companion `baerly/no-await-in-use-query` lint
|
|
82
|
+
* flags the pattern at edit time. For compound reads, use
|
|
83
|
+
* `Promise.all` (parallel) or compose two `useQuery` calls with
|
|
84
|
+
* `useQuery.skip` (dependent).
|
|
85
|
+
*/
|
|
86
|
+
| "UseQueryAwaitedRecorder"
|
|
87
|
+
/**
|
|
88
|
+
* A write method (`.insert`/`.update`/`.replace`/`.delete`) was
|
|
89
|
+
* called on the recorder inside a `useQuery` callback. Writes
|
|
90
|
+
* inside reads are a programming error; the recorder rejects them
|
|
91
|
+
* synchronously from the discovery pass, before any I/O fires. Use
|
|
92
|
+
* `useMutation()` instead.
|
|
93
|
+
*/
|
|
94
|
+
| "UnexpectedWriteInQuery"
|
|
95
|
+
/**
|
|
96
|
+
* A `useMutation()` callback rejected with a non-`BaerlyError`
|
|
97
|
+
* throwable. The hook wraps the original throw under this code so
|
|
98
|
+
* the `error` slot is always a `BaerlyError`; the original value
|
|
99
|
+
* is preserved on `.cause`.
|
|
100
|
+
*/
|
|
101
|
+
| "MutationFailed";
|
|
102
|
+
/**
|
|
103
|
+
* The single error class thrown by baerly-storage. Discriminate by `code`, not
|
|
104
|
+
* `instanceof`: the code string survives `JSON.stringify` round-trips
|
|
105
|
+
* across Worker / iframe / postMessage realm boundaries, where each
|
|
106
|
+
* realm has its own `BaerlyError` constructor identity. IDB-restored
|
|
107
|
+
* writes can replay across realms, so `instanceof` would spuriously
|
|
108
|
+
* fail on a structurally-identical error from another realm.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* try {
|
|
113
|
+
* await db.collection("tickets").insert({ title: "hi" });
|
|
114
|
+
* } catch (err) {
|
|
115
|
+
* if (err instanceof BaerlyError && err.code === "Conflict") {
|
|
116
|
+
* // Check err.retriable; CAS can retry, duplicate _id cannot.
|
|
117
|
+
* }
|
|
118
|
+
* throw err;
|
|
119
|
+
* }
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
declare class BaerlyError extends Error {
|
|
123
|
+
readonly code: BaerlyErrorCode;
|
|
124
|
+
readonly cause?: unknown;
|
|
125
|
+
/**
|
|
126
|
+
* Structured field-path issues, set only when `code === "SchemaError"`.
|
|
127
|
+
* Each entry's `path` is a dotted-key list (e.g. `["assignee", "team"]`
|
|
128
|
+
* or `["items", 3, "qty"]`) that targets the offending field on the
|
|
129
|
+
* input document. `message` is the validator-emitted human string.
|
|
130
|
+
*
|
|
131
|
+
* The HTTP layer's `mapError` renders these into the 400 body via
|
|
132
|
+
* the existing `HttpErrorEnvelope`; older callers that don't know
|
|
133
|
+
* about `issues` see a plain message-only error and stay correct.
|
|
134
|
+
*/
|
|
135
|
+
readonly issues?: ReadonlyArray<{
|
|
136
|
+
readonly path: ReadonlyArray<string | number>;
|
|
137
|
+
readonly message: string;
|
|
138
|
+
}>;
|
|
139
|
+
/**
|
|
140
|
+
* Raw HTTP status, set only by the client-side wire decoder when
|
|
141
|
+
* inflating an `HttpErrorEnvelope` into this class. Server-side
|
|
142
|
+
* throws never set it (the HTTP layer's `mapError` derives the
|
|
143
|
+
* outbound status from `code`). Useful for diagnostics — e.g. to
|
|
144
|
+
* distinguish 404-as-"no such row" from 404-as-"route not found".
|
|
145
|
+
* Discriminate by `code` for behavior; reach for `status` only when
|
|
146
|
+
* you genuinely need the wire value.
|
|
147
|
+
*/
|
|
148
|
+
readonly status?: number;
|
|
149
|
+
/** Canonical corrective action; crosses the wire via `HttpErrorEnvelope.error.resolution`. */
|
|
150
|
+
readonly resolution?: string;
|
|
151
|
+
private readonly retriableOverride;
|
|
152
|
+
/**
|
|
153
|
+
* Whether this error instance is retriable. Defaults from `code`, but
|
|
154
|
+
* context-sensitive throw sites can override it.
|
|
155
|
+
*/
|
|
156
|
+
get retriable(): boolean;
|
|
157
|
+
constructor(code: BaerlyErrorCode, message: string, cause?: unknown, issues?: ReadonlyArray<{
|
|
158
|
+
readonly path: ReadonlyArray<string | number>;
|
|
159
|
+
readonly message: string;
|
|
160
|
+
}>, status?: number, resolution?: string, retriableOverride?: boolean);
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
2
163
|
//#region packages/protocol/src/storage/types.d.ts
|
|
3
164
|
/**
|
|
4
165
|
* Object-storage abstraction. The protocol kernel writes through
|
|
@@ -123,11 +284,11 @@ interface StorageListEntry {
|
|
|
123
284
|
/**
|
|
124
285
|
* Per-collection control object. CAS-protected. One per
|
|
125
286
|
* `(tenant, collection)` key — for example
|
|
126
|
-
* `<tenant>/<collection>/current.json`. The compactor swaps
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
287
|
+
* `<tenant>/<collection>/current.json`. The compactor swaps snapshot
|
|
288
|
+
* generations by CAS-writing this object; the Writer reads it on every
|
|
289
|
+
* commit to find the snapshot pointer and a non-authoritative
|
|
290
|
+
* tail-probe floor. The numbered log create mints the next integer
|
|
291
|
+
* `seq`; no commit-path code CAS-advances `current.json`.
|
|
131
292
|
*
|
|
132
293
|
* The schema is forward-compatible: adding a new optional field is
|
|
133
294
|
* non-breaking. Renaming or removing a field requires bumping
|
|
@@ -136,11 +297,11 @@ interface StorageListEntry {
|
|
|
136
297
|
*/
|
|
137
298
|
interface CurrentJson {
|
|
138
299
|
/**
|
|
139
|
-
* Schema version. Today: `
|
|
300
|
+
* Schema version. Today: `3`. Bump on any breaking change to
|
|
140
301
|
* field semantics; readers must reject unknown major versions
|
|
141
302
|
* with `BaerlyError{code:"InvalidResponse"}`.
|
|
142
303
|
*/
|
|
143
|
-
schema_version:
|
|
304
|
+
schema_version: 3;
|
|
144
305
|
/**
|
|
145
306
|
* Pointer to the current snapshot generation. `null` before the
|
|
146
307
|
* first compaction has produced a snapshot — readers fall back
|
|
@@ -149,23 +310,24 @@ interface CurrentJson {
|
|
|
149
310
|
*/
|
|
150
311
|
snapshot: string | null;
|
|
151
312
|
/**
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
313
|
+
* Non-authoritative monotone lower bound on the committed log tail.
|
|
314
|
+
* The authoritative tail is discovered by forward-probe (log-tail.ts);
|
|
315
|
+
* never trust this as the head. Durable advancement is owned by
|
|
316
|
+
* compaction folds, write-tick tail refreshes, and explicit
|
|
317
|
+
* operator/import paths; ordinary writer commits do not refresh it.
|
|
156
318
|
*/
|
|
157
|
-
|
|
319
|
+
tail_hint: number;
|
|
158
320
|
/**
|
|
159
321
|
* Lowest live log sequence number. Entries with `seq < log_seq_start`
|
|
160
322
|
* have been folded into the snapshot at {@link snapshot} (or, if
|
|
161
323
|
* `snapshot === null`, have been dropped because the collection was
|
|
162
|
-
* truncated). Readers walk `[log_seq_start,
|
|
324
|
+
* truncated). Readers walk `[log_seq_start, tail_hint)`. Always
|
|
163
325
|
* present on disk — fresh `current.json` writes via
|
|
164
326
|
* {@link createCurrentJson} set this to `0`; the compactor advances
|
|
165
327
|
* it on every fold.
|
|
166
328
|
*
|
|
167
329
|
* Invariants the compactor maintains:
|
|
168
|
-
* - `0 <= log_seq_start <=
|
|
330
|
+
* - `0 <= log_seq_start <= tail_hint`
|
|
169
331
|
* - `log_seq_start` advances monotonically (never decreases)
|
|
170
332
|
* - `log_seq_start > 0` implies `snapshot !== null` (the snapshot
|
|
171
333
|
* covers `[0, log_seq_start)`)
|
|
@@ -175,19 +337,27 @@ interface CurrentJson {
|
|
|
175
337
|
* Embedded write-fence epoch. See {@link WriterFence}.
|
|
176
338
|
*/
|
|
177
339
|
writer_fence: WriterFence;
|
|
178
|
-
/** EXACT byte size of the live log tail [log_seq_start, next_seq). Maintained exactly
|
|
179
|
-
* by the full-fence CAS on BOTH paths: each write adds its log bytes; a successful
|
|
180
|
-
* fold (which proves no concurrent write) resets to 0 from a known-empty tail. */
|
|
181
|
-
tail_bytes: number;
|
|
182
340
|
/** Byte size of the snapshot pointed to by `snapshot`. */
|
|
183
341
|
snapshot_bytes: number;
|
|
184
|
-
/**
|
|
185
|
-
*
|
|
342
|
+
/**
|
|
343
|
+
* Row count of the snapshot (= compactor `base.size`, free). With
|
|
344
|
+
* `tail_hint - log_seq_start` (trusted tail entries) this gives the
|
|
345
|
+
* fold's entry count for the ENTRY ceiling `E`. Seeded 0.
|
|
346
|
+
*/
|
|
186
347
|
snapshot_rows: number;
|
|
187
|
-
/**
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
348
|
+
/**
|
|
349
|
+
* Optional compactor-stamped mean folded-entry byte size. Maintenance
|
|
350
|
+
* derives live-tail bytes as `entry_count × mean_entry_bytes` without
|
|
351
|
+
* an exact stored counter; absent until first fold.
|
|
352
|
+
*/
|
|
353
|
+
mean_entry_bytes?: number;
|
|
354
|
+
/**
|
|
355
|
+
* Baseline for rate-limiting the graduation defer-warn off SHARED
|
|
356
|
+
* durable state, not per-isolate memory. The warn fires when the
|
|
357
|
+
* observed/probed tail minus `last_warned_seq` reaches
|
|
358
|
+
* MAINTENANCE_WARN_INTERVAL_WRITES, and that firing CASes
|
|
359
|
+
* `last_warned_seq` to the observed/probed tail. Absent → 0.
|
|
360
|
+
*/
|
|
191
361
|
last_warned_seq?: number;
|
|
192
362
|
}
|
|
193
363
|
/**
|
|
@@ -195,23 +365,24 @@ interface CurrentJson {
|
|
|
195
365
|
* monotonically-bumped `epoch` is the only safety-critical field —
|
|
196
366
|
* `owner` is informational and may be missing in older records;
|
|
197
367
|
* `claimed_at` is the server response date at claim time, NOT the
|
|
198
|
-
* local clock; `lease_until` is reserved for manual rotation and
|
|
199
|
-
*
|
|
368
|
+
* local clock; `lease_until` is reserved for manual rotation and is not
|
|
369
|
+
* consumed by the current kernel. Log entries are not stamped with this
|
|
370
|
+
* epoch; the fence is dormant authority metadata, not a reader replay
|
|
371
|
+
* filter.
|
|
200
372
|
*
|
|
201
373
|
* Borrowed from FoundationDB's `recoveryCount` on cstate, IsleDB's
|
|
202
374
|
* `writer_fence` on `manifest/CURRENT`, and TigerBeetle's VSR view
|
|
203
|
-
* number.
|
|
204
|
-
*
|
|
205
|
-
*
|
|
375
|
+
* number. In the earlier two-write commit design, every commit checked
|
|
376
|
+
* the epoch before continuing under `current.json` authority. Under
|
|
377
|
+
* single-write commit no production path reads or writes the fence.
|
|
206
378
|
*/
|
|
207
379
|
interface WriterFence {
|
|
208
380
|
/**
|
|
209
381
|
* Monotonic unsigned integer. Bumped only by an explicit
|
|
210
382
|
* {@link claimWriter} call — do NOT bump on every cold start, do
|
|
211
|
-
* NOT bump on every commit.
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
* is `< current.writer_fence.epoch`.
|
|
383
|
+
* NOT bump on every commit. Under single-write commit this is retained
|
|
384
|
+
* as an explicit admin/testing primitive only; no production commit
|
|
385
|
+
* path claims or verifies the fence.
|
|
215
386
|
*/
|
|
216
387
|
epoch: number;
|
|
217
388
|
/**
|
|
@@ -257,8 +428,9 @@ interface CurrentJsonRead {
|
|
|
257
428
|
* The methods on this interface ARE the supported operator surface.
|
|
258
429
|
* Vocabulary additions (`or`, `not`, `regex`, `ne`, `exists`, ...)
|
|
259
430
|
* are intentionally absent — calling them is a TS2339 compile
|
|
260
|
-
* error, not a runtime rejection.
|
|
261
|
-
*
|
|
431
|
+
* error, not a runtime rejection. The algebra is conjunction-only in
|
|
432
|
+
* perpetuity — see the API surface lock in
|
|
433
|
+
* docs/contributing/conventions/change-discipline.md.
|
|
262
434
|
*
|
|
263
435
|
* @template T - the document shape the predicate is keyed against.
|
|
264
436
|
*/
|
|
@@ -494,7 +666,7 @@ type _StripIndex<T> = { [K in keyof T as string extends K ? never : K]: T[K] };
|
|
|
494
666
|
* today's open-keyed default behavior.
|
|
495
667
|
* @internal
|
|
496
668
|
*/
|
|
497
|
-
type _AllPaths<T, D extends _PathDepth[number] = 4> = [D] extends [never] ? never : T extends object ? keyof _StripIndex<T> & string extends never ? string : { [K in keyof _StripIndex<T> & string]: _IsPathLeaf<T[K]
|
|
669
|
+
type _AllPaths<T, D extends _PathDepth[number] = 4> = [D] extends [never] ? never : T extends object ? keyof _StripIndex<T> & string extends never ? string : { [K in keyof _StripIndex<T> & string]: _IsPathLeaf<NonNullable<T[K]>> extends true ? K : K | `${K}.${_AllPaths<NonNullable<T[K]>, _PathDepth[D]>}` }[keyof _StripIndex<T> & string] : never;
|
|
498
670
|
/**
|
|
499
671
|
* Legal dotted-path keys over `T`, with the root-level `_id` filtered
|
|
500
672
|
* out so the top-level shape no longer accepts `{ _id: "x" }`. Nested
|
|
@@ -657,158 +829,16 @@ interface Query<T extends DocumentData = DocumentData> {
|
|
|
657
829
|
}>;
|
|
658
830
|
}
|
|
659
831
|
//#endregion
|
|
660
|
-
//#region packages/protocol/src/
|
|
661
|
-
/**
|
|
662
|
-
|
|
663
|
-
* survive cross-realm boundaries (e.g. a Web Worker) and so callers can
|
|
664
|
-
* pattern-match with grep-friendly equality.
|
|
665
|
-
*/
|
|
666
|
-
type BaerlyErrorCode = /** Caller-provided config or input is invalid (bad bucket, unsupported credential type, malformed URL, bucket not version-enabled when versioning was requested). */"InvalidConfig" /** Generic S3/HTTP transport failure (5xx, unexpected status, retries exhausted). */ | "NetworkError" /** S3 returned 403. Either credentials are wrong or the bucket policy denies the operation. */ | "AccessDenied" /** Server returned data that didn't parse (malformed XML, non-JSON body where JSON expected). */ | "InvalidResponse" /** Internal invariant violation — should not be reachable. File a bug. */ | "Internal"
|
|
667
|
-
/**
|
|
668
|
-
* Document body failed schema validation. Emitted by the table-API
|
|
669
|
-
* write verbs (`Collection.insert`, `Query.update`, `Collection.replace`) when
|
|
670
|
-
* the body is not valid JSON or contains an array where
|
|
671
|
-
* `DocumentValue` is required; also emitted when a collection has a
|
|
672
|
-
* declared `SchemaValidator` (via `Db.create({ collections })`) and
|
|
673
|
-
* the bound schema rejects the doc. In the schema-rejection case the
|
|
674
|
-
* error carries an `issues` array describing each failure. HTTP layer
|
|
675
|
-
* maps this to 422.
|
|
676
|
-
*/
|
|
677
|
-
| "SchemaError"
|
|
678
|
-
/**
|
|
679
|
-
* CAS lost on `current.json`. Caller decides whether to retry.
|
|
680
|
-
* Surfaces in the collection API and HTTP layer.
|
|
681
|
-
*/
|
|
682
|
-
| "Conflict"
|
|
683
|
-
/**
|
|
684
|
-
* `Verifier` returned no identity. HTTP server maps to 401.
|
|
685
|
-
* Code is reserved here so the union locks.
|
|
686
|
-
*/
|
|
687
|
-
| "Unauthorized"
|
|
688
|
-
/**
|
|
689
|
-
* The addressed resource does not exist. HTTP server maps to 404.
|
|
690
|
-
* Emitted by the row-by-id read / update / delete handlers in
|
|
691
|
-
* `packages/server/src/http/router.ts` when the predicate
|
|
692
|
-
* `{ _id }` matches zero rows. Not a protocol invariant —
|
|
693
|
-
* callers may retry after creating the resource or treat as a
|
|
694
|
-
* miss depending on intent. The CLI maps this to the generic
|
|
695
|
-
* exit-2 "storage error" bucket, not the exit-3 "protocol
|
|
696
|
-
* invariant" bucket.
|
|
697
|
-
*/
|
|
698
|
-
| "NotFound"
|
|
699
|
-
/**
|
|
700
|
-
* Request body exceeded the server's size cap. HTTP server maps
|
|
701
|
-
* to 413. Cap is `MAX_BODY_BYTES` (1 MiB today; exported from
|
|
702
|
-
* `packages/server/src/http/router.ts`). The Node adapter
|
|
703
|
-
* enforces during the `node:http` stream pump so the process
|
|
704
|
-
* never materializes a multi-MiB body; Workers also rely on
|
|
705
|
-
* platform-side caps (16 MB free / 100 MB paid).
|
|
706
|
-
*/
|
|
707
|
-
| "PayloadTooLarge"
|
|
708
|
-
/**
|
|
709
|
-
* A predicate is structurally well-formed but contradicts itself —
|
|
710
|
-
* no document can match. Emitted by `validateWire` and
|
|
711
|
-
* `mergePredicateWires`. Triggers:
|
|
712
|
-
* - `{ clauses: [{op:"in", field:"priority", value:[]}] }` (empty `in` set)
|
|
713
|
-
* - an `eq` clause with a value outside the residual interval
|
|
714
|
-
* established by range clauses on the same field
|
|
715
|
-
* - merging `{op:"gt", value:10}` with `{op:"lt", value:5}` on the
|
|
716
|
-
* same field (empty interval)
|
|
717
|
-
* - merging two `in` clauses on the same field with empty intersection
|
|
718
|
-
*
|
|
719
|
-
* Conflicting equality across clauses (`eq:"open"` + `eq:"closed"` on
|
|
720
|
-
* the same field) surfaces as `InvalidConfig` rather than this code —
|
|
721
|
-
* the merger treats it as a caller-side configuration bug, not an
|
|
722
|
-
* algebraic contradiction.
|
|
723
|
-
*
|
|
724
|
-
* The HTTP layer treats this as a 400 (caller error). The distinct
|
|
725
|
-
* code lets downstream code short-circuit empty-by-construction
|
|
726
|
-
* without re-running the validator or parsing messages.
|
|
727
|
-
*/
|
|
728
|
-
| "UnsatisfiablePredicate"
|
|
729
|
-
/**
|
|
730
|
-
* A `useQuery` callback awaited a recorder terminal
|
|
731
|
-
* (`.get`/`.first`/`.all`/`.count`). The recorder runs once per
|
|
732
|
-
* render to capture the chain shape; it cannot survive an `await`
|
|
733
|
-
* because the proxy doesn't proxy across microtask boundaries. The
|
|
734
|
-
* recorder's terminal returns a thenable whose `.then` throws this
|
|
735
|
-
* error synchronously, converting what would otherwise be a silent
|
|
736
|
-
* spinner-hang into a render-time error the hook surfaces as
|
|
737
|
-
* `status: "error"`. Companion `baerly/no-await-in-use-query` lint
|
|
738
|
-
* flags the pattern at edit time. For compound reads, use
|
|
739
|
-
* `Promise.all` (parallel) or compose two `useQuery` calls with
|
|
740
|
-
* `useQuery.skip` (dependent).
|
|
741
|
-
*/
|
|
742
|
-
| "UseQueryAwaitedRecorder"
|
|
743
|
-
/**
|
|
744
|
-
* A write method (`.insert`/`.update`/`.replace`/`.delete`) was
|
|
745
|
-
* called on the recorder inside a `useQuery` callback. Writes
|
|
746
|
-
* inside reads are a programming error; the recorder rejects them
|
|
747
|
-
* synchronously from the discovery pass, before any I/O fires. Use
|
|
748
|
-
* `useMutation()` instead.
|
|
749
|
-
*/
|
|
750
|
-
| "UnexpectedWriteInQuery"
|
|
751
|
-
/**
|
|
752
|
-
* A `useMutation()` callback rejected with a non-`BaerlyError`
|
|
753
|
-
* throwable. The hook wraps the original throw under this code so
|
|
754
|
-
* the `error` slot is always a `BaerlyError`; the original value
|
|
755
|
-
* is preserved on `.cause`.
|
|
756
|
-
*/
|
|
757
|
-
| "MutationFailed";
|
|
758
|
-
/**
|
|
759
|
-
* The single error class thrown by Baerly. Discriminate by `code`, not
|
|
760
|
-
* `instanceof`: the code string survives `JSON.stringify` round-trips
|
|
761
|
-
* across Worker / iframe / postMessage realm boundaries, where each
|
|
762
|
-
* realm has its own `BaerlyError` constructor identity. IDB-restored
|
|
763
|
-
* writes can replay across realms, so `instanceof` would spuriously
|
|
764
|
-
* fail on a structurally-identical error from another realm.
|
|
765
|
-
*
|
|
766
|
-
* @example
|
|
767
|
-
* ```ts
|
|
768
|
-
* try {
|
|
769
|
-
* await db.collection("tickets").insert({ title: "hi" });
|
|
770
|
-
* } catch (err) {
|
|
771
|
-
* if (err instanceof BaerlyError && err.code === "Conflict") {
|
|
772
|
-
* // ... CAS lost; retry
|
|
773
|
-
* }
|
|
774
|
-
* throw err;
|
|
775
|
-
* }
|
|
776
|
-
* ```
|
|
777
|
-
*/
|
|
778
|
-
declare class BaerlyError extends Error {
|
|
779
|
-
readonly code: BaerlyErrorCode;
|
|
780
|
-
readonly cause?: unknown;
|
|
781
|
-
/**
|
|
782
|
-
* Structured field-path issues, set only when `code === "SchemaError"`.
|
|
783
|
-
* Each entry's `path` is a dotted-key list (e.g. `["assignee", "team"]`
|
|
784
|
-
* or `["items", 3, "qty"]`) that targets the offending field on the
|
|
785
|
-
* input document. `message` is the validator-emitted human string.
|
|
786
|
-
*
|
|
787
|
-
* The HTTP layer's `mapError` renders these into the 400 body via
|
|
788
|
-
* the existing `HttpErrorEnvelope`; older callers that don't know
|
|
789
|
-
* about `issues` see a plain message-only error and stay correct.
|
|
790
|
-
*/
|
|
791
|
-
readonly issues?: ReadonlyArray<{
|
|
792
|
-
readonly path: ReadonlyArray<string | number>;
|
|
793
|
-
readonly message: string;
|
|
794
|
-
}>;
|
|
832
|
+
//#region packages/protocol/src/storage/memory.d.ts
|
|
833
|
+
/** Options for {@link MemoryStorage}. */
|
|
834
|
+
interface MemoryStorageOptions {
|
|
795
835
|
/**
|
|
796
|
-
*
|
|
797
|
-
*
|
|
798
|
-
*
|
|
799
|
-
* outbound status from `code`). Useful for diagnostics — e.g. to
|
|
800
|
-
* distinguish 404-as-"no such row" from 404-as-"route not found".
|
|
801
|
-
* Discriminate by `code` for behavior; reach for `status` only when
|
|
802
|
-
* you genuinely need the wire value.
|
|
836
|
+
* Acknowledge the store is intentionally ephemeral — required to
|
|
837
|
+
* construct in a detected deployment ({@link isDeployedEnv}); ignored in
|
|
838
|
+
* dev/test. Env equivalent: `BAERLY_ALLOW_EPHEMERAL_STORAGE=true`.
|
|
803
839
|
*/
|
|
804
|
-
|
|
805
|
-
constructor(code: BaerlyErrorCode, message: string, cause?: unknown, issues?: ReadonlyArray<{
|
|
806
|
-
readonly path: ReadonlyArray<string | number>;
|
|
807
|
-
readonly message: string;
|
|
808
|
-
}>, status?: number);
|
|
840
|
+
ephemeral?: boolean;
|
|
809
841
|
}
|
|
810
|
-
//#endregion
|
|
811
|
-
//#region packages/protocol/src/storage/memory.d.ts
|
|
812
842
|
/**
|
|
813
843
|
* In-memory `Storage`. The randomized property test runs against
|
|
814
844
|
* this; it must be deterministic — no clocks beyond the caller's,
|
|
@@ -831,6 +861,7 @@ declare class BaerlyError extends Error {
|
|
|
831
861
|
*/
|
|
832
862
|
declare class MemoryStorage implements Storage {
|
|
833
863
|
#private;
|
|
864
|
+
constructor(opts?: MemoryStorageOptions);
|
|
834
865
|
get(key: string, opts?: StorageGetOptions): Promise<StorageGetResult | null>;
|
|
835
866
|
put(key: string, body: Uint8Array, opts?: StoragePutOptions): Promise<StoragePutResult>;
|
|
836
867
|
delete(key: string, opts?: {
|
|
@@ -946,11 +977,13 @@ type Verifier = (req: Request) => Promise<VerifierResult | null>;
|
|
|
946
977
|
/**
|
|
947
978
|
* Debezium-style JSON CDC envelope using pgoutput's message-tag (`I`/`U`/`D`) vocabulary. One per mutation.
|
|
948
979
|
*
|
|
949
|
-
*
|
|
950
|
-
*
|
|
951
|
-
*
|
|
952
|
-
*
|
|
953
|
-
*
|
|
980
|
+
* `LogEntry` is now a public, versionless/additive-only wire contract:
|
|
981
|
+
* 0.3.0 is the public early-access baseline. It is still pre-1.0 and
|
|
982
|
+
* soaking, so breaking changes remain possible, but only through an
|
|
983
|
+
* explicit compatibility decision, changelog/migration notes, and a
|
|
984
|
+
* versioned release. Assume external consumers may exist; do not
|
|
985
|
+
* silently rename, remove, or repurpose fields. Consumers must ignore
|
|
986
|
+
* unknown keys; new optional fields can be added in compatible releases.
|
|
954
987
|
*
|
|
955
988
|
* Field requirement matrix:
|
|
956
989
|
* - Always: `lsn`, `commit_ts`, `op`, `collection`, `session`,
|
|
@@ -985,11 +1018,9 @@ interface LogEntry {
|
|
|
985
1018
|
/** Insert / Update / Delete. */
|
|
986
1019
|
op: "I" | "U" | "D";
|
|
987
1020
|
/**
|
|
988
|
-
* Collection name — the pgoutput RELATION analogue. Today
|
|
989
|
-
*
|
|
990
|
-
*
|
|
991
|
-
* `ref.bucket` for flat keys with no separator. The table API
|
|
992
|
-
* makes collections first-class.
|
|
1021
|
+
* Collection name — the pgoutput RELATION analogue. Today this is
|
|
1022
|
+
* the collection bound to the `current.json` whose `tail_hint` minted
|
|
1023
|
+
* the entry. The table API makes collections first-class.
|
|
993
1024
|
*/
|
|
994
1025
|
collection: string;
|
|
995
1026
|
/**
|
|
@@ -1008,7 +1039,7 @@ interface LogEntry {
|
|
|
1008
1039
|
before?: DocumentData;
|
|
1009
1040
|
/**
|
|
1010
1041
|
* Pre-image of the primary key. U/D always carry this when
|
|
1011
|
-
* `replica_identity` is not `PATCH_ONLY`. (For
|
|
1042
|
+
* `replica_identity` is not `PATCH_ONLY`. (For baerly-storage today,
|
|
1012
1043
|
* `_id` is the only PK.)
|
|
1013
1044
|
*/
|
|
1014
1045
|
key_old?: {
|
|
@@ -1017,12 +1048,19 @@ interface LogEntry {
|
|
|
1017
1048
|
/** ORIGIN analogue — the writer session id. */
|
|
1018
1049
|
origin?: string;
|
|
1019
1050
|
/**
|
|
1020
|
-
* Causal metadata (
|
|
1051
|
+
* Causal metadata (baerly-storage-only; no pgoutput analogue). The
|
|
1021
1052
|
* session id that built the `lsn`. Surfaces here so consumers
|
|
1022
1053
|
* can dedupe / order without parsing the cursor.
|
|
1023
1054
|
*/
|
|
1024
1055
|
session: string;
|
|
1025
|
-
/**
|
|
1056
|
+
/**
|
|
1057
|
+
* The `log/<seq>` slot this entry occupies — the integer in its
|
|
1058
|
+
* `log/<seq>.json` key, minted by `Writer.commit` as the forward-probed
|
|
1059
|
+
* collection-log tail (the winning `If-None-Match: "*"` create). One
|
|
1060
|
+
* entry per `session`, so this is a per-collection slot, not a
|
|
1061
|
+
* per-session counter. Also encoded (descending base-32) as the LSN's
|
|
1062
|
+
* third segment — see `lsnParts`.
|
|
1063
|
+
*/
|
|
1026
1064
|
seq: number;
|
|
1027
1065
|
}
|
|
1028
1066
|
//#endregion
|
|
@@ -1041,7 +1079,7 @@ interface LogEntry {
|
|
|
1041
1079
|
* stdout (one JSON object per HTTP request).
|
|
1042
1080
|
*
|
|
1043
1081
|
* **Naming convention** matches the load-bearing metrics:
|
|
1044
|
-
* - `db.write.class_a_ops_per_logical_write` — histogram (p99 alert
|
|
1082
|
+
* - `db.write.class_a_ops_per_logical_write` — histogram (recommend p99 alert ~5; not gated).
|
|
1045
1083
|
* Includes one Class A op per index PUT + index DELETE emitted
|
|
1046
1084
|
* in the commit's fence. Idle-reader cost is unchanged.
|
|
1047
1085
|
* - `db.r2.put.412_total` — counter (CAS conflict / If-Match-or-None-Match loss)
|
|
@@ -1070,5 +1108,5 @@ interface MetricsRecorder {
|
|
|
1070
1108
|
histogram(name: string, value: number, labels?: Readonly<Record<string, string>>): void;
|
|
1071
1109
|
}
|
|
1072
1110
|
//#endregion
|
|
1073
|
-
export {
|
|
1074
|
-
//# sourceMappingURL=index-
|
|
1111
|
+
export { StoragePutOptions as _, MemoryStorage as a, BaerlyErrorCode as b, Predicate as c, CurrentJson as d, CurrentJsonRead as f, StorageListEntry as g, StorageGetResult as h, VerifierResult as i, Query as l, StorageGetOptions as m, LogEntry as n, Collection as o, Storage as p, Verifier as r, OrderSpec as s, MetricsRecorder as t, PredicateArg as u, StoragePutResult as v, BaerlyError as y };
|
|
1112
|
+
//# sourceMappingURL=index-BYk9oCNf.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as CollectionNames, c as defineConfig, d as IndexDefinition, f as DocumentData, i as CollectionDefinition, l as SchemaIssue, n as BaerlyAppConfig, o as RowOf, r as BaerlyConfig, s as UnboundConfig, u as SchemaValidator } from "./app-config-
|
|
2
|
-
import {
|
|
3
|
-
import { t as allIndexKeysFor } from "./indexes-
|
|
4
|
-
import { a as
|
|
5
|
-
import { n as validateOrThrow, t as Db } from "./db-
|
|
6
|
-
export { type BaerlyAppConfig, type BaerlyConfig, BaerlyError, type BaerlyErrorCode, type Collection, type CollectionDefinition, type CollectionNames, Db, type DocumentData, type IndexDefinition, MemoryStorage, type Query, type RowOf, type SchemaIssue, type SchemaValidator, type SnapshotBody, type Storage, type StorageGetResult, type StorageListEntry, type StoragePutResult, type UnboundConfig, type Verifier, type VerifierResult, allIndexKeysFor, collectionsToMaps, defineConfig, encodeSnapshotBody, loadSnapshotAsMap, resolveVerifier, snapshotKey, validateOrThrow, walkLogRange };
|
|
1
|
+
import { a as CollectionNames, c as defineConfig, d as IndexDefinition, f as DocumentData, i as CollectionDefinition, l as SchemaIssue, n as BaerlyAppConfig, o as RowOf, r as BaerlyConfig, s as UnboundConfig, u as SchemaValidator } from "./app-config-DyiFK3_k.js";
|
|
2
|
+
import { a as MemoryStorage, b as BaerlyErrorCode, c as Predicate, g as StorageListEntry, h as StorageGetResult, i as VerifierResult, l as Query, o as Collection, p as Storage, r as Verifier, u as PredicateArg, v as StoragePutResult, y as BaerlyError } from "./index-BYk9oCNf.js";
|
|
3
|
+
import { t as allIndexKeysFor } from "./indexes-Dn9hbGQG.js";
|
|
4
|
+
import { a as loadSnapshotAsMap, c as collectionsToMaps, i as encodeSnapshotBody, n as walkLogRange, o as snapshotKey, r as SnapshotBody, s as resolveVerifier, t as probeTailFrom } from "./index-BNRh23K9.js";
|
|
5
|
+
import { n as validateOrThrow, t as Db } from "./db-DsPkOVEH.js";
|
|
6
|
+
export { type BaerlyAppConfig, type BaerlyConfig, BaerlyError, type BaerlyErrorCode, type Collection, type CollectionDefinition, type CollectionNames, Db, type DocumentData, type IndexDefinition, MemoryStorage, type Predicate, type PredicateArg, type Query, type RowOf, type SchemaIssue, type SchemaValidator, type SnapshotBody, type Storage, type StorageGetResult, type StorageListEntry, type StoragePutResult, type UnboundConfig, type Verifier, type VerifierResult, allIndexKeysFor, collectionsToMaps, defineConfig, encodeSnapshotBody, loadSnapshotAsMap, probeTailFrom, resolveVerifier, snapshotKey, validateOrThrow, walkLogRange };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineConfig } from "./app-config.js";
|
|
2
|
-
import { t as BaerlyError } from "./errors-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
export { BaerlyError, Db, MemoryStorage, allIndexKeysFor, collectionsToMaps, defineConfig, encodeSnapshotBody, loadSnapshotAsMap, resolveVerifier, snapshotKey, validateOrThrow, walkLogRange };
|
|
2
|
+
import { t as BaerlyError } from "./errors-Dfa3p78c.js";
|
|
3
|
+
import { b as loadSnapshotAsMap, g as allIndexKeysFor, h as walkLogRange, w as probeTailFrom, x as snapshotKey, y as encodeSnapshotBody } from "./maintenance-B4Dki6Ig.js";
|
|
4
|
+
import { i as MemoryStorage, n as resolveVerifier, r as collectionsToMaps, t as Db } from "./src-CYHFDrKz.js";
|
|
5
|
+
import { o as validateOrThrow } from "./query-rAtXNQQB.js";
|
|
6
|
+
export { BaerlyError, Db, MemoryStorage, allIndexKeysFor, collectionsToMaps, defineConfig, encodeSnapshotBody, loadSnapshotAsMap, probeTailFrom, resolveVerifier, snapshotKey, validateOrThrow, walkLogRange };
|