@gusto/baerly-storage 0.6.0 → 0.7.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/README.md +47 -124
- package/dist/API.md +161 -512
- package/dist/CHANGELOG.md +1137 -378
- package/dist/RECIPES.md +398 -80
- package/dist/THIRD-PARTY-LICENSES.txt +5 -26
- package/dist/{app-config-DyiFK3_k.d.ts → app-config-C6qW7m8S.d.ts} +119 -111
- package/dist/app-config.d.ts +31 -1
- package/dist/app-config.js +1 -2
- package/dist/app-config.js.map +1 -1
- package/dist/auth.d.ts +33 -28
- package/dist/auth.js +549 -985
- package/dist/auth.js.map +1 -1
- package/dist/baerly.js +130 -138
- package/dist/baerly.js.map +1 -1
- package/dist/baerly.spec.json +97 -22
- package/dist/capacity-warning-header-BlVopyiI.js +16 -0
- package/dist/capacity-warning-header-BlVopyiI.js.map +1 -0
- package/dist/{client-ypCm3zjt.d.ts → client-CHQTXpef.d.ts} +121 -36
- package/dist/client-react.d.ts +67 -20
- package/dist/client-react.js +240 -54
- package/dist/client-react.js.map +1 -1
- package/dist/client.d.ts +5 -4
- package/dist/client.js +51 -16
- package/dist/client.js.map +1 -1
- package/dist/{cloudflare-wrVYf4bb.js → cloudflare-CKHYXccw.js} +61 -82
- package/dist/cloudflare-CKHYXccw.js.map +1 -0
- package/dist/cloudflare.d.ts +106 -71
- package/dist/cloudflare.js +334 -271
- package/dist/cloudflare.js.map +1 -1
- package/dist/code-resolution-CL_7L0wS.js +22 -0
- package/dist/code-resolution-CL_7L0wS.js.map +1 -0
- package/dist/collection-api-DbyhLAY8.d.ts +1001 -0
- package/dist/config-DEzInG6M.js +4035 -0
- package/dist/config-DEzInG6M.js.map +1 -0
- package/dist/constants-D3GSH3tc.js +469 -0
- package/dist/constants-D3GSH3tc.js.map +1 -0
- package/dist/{context-DRZ3tZ5l.js → context-rlpSnHFA.js} +17 -17
- package/dist/context-rlpSnHFA.js.map +1 -0
- package/dist/cost-B52llVDx.js +330 -0
- package/dist/cost-B52llVDx.js.map +1 -0
- package/dist/{current-json-C6nhPOm1.js → current-json-CC6lE4Aj.js} +115 -32
- package/dist/current-json-CC6lE4Aj.js.map +1 -0
- package/dist/db-plFUNTSF.d.ts +130 -0
- package/dist/db-read-seams-BSs0m1z1.js +3261 -0
- package/dist/db-read-seams-BSs0m1z1.js.map +1 -0
- package/dist/{deploy-Di_Q01qx.js → deploy-Obj4nE-Z.js} +10 -14
- package/dist/deploy-Obj4nE-Z.js.map +1 -0
- package/dist/{dev-banner-CWHIk8tH.d.ts → dev-banner-B5AUHmu1.d.ts} +1 -4
- package/dist/dev-landing-BI5UdmOb.d.ts +32 -0
- package/dist/dev-landing-CD-si4dW.js +50 -0
- package/dist/dev-landing-CD-si4dW.js.map +1 -0
- package/dist/dev-vite.d.ts +9 -14
- package/dist/dev-vite.js +11 -10
- package/dist/dev-vite.js.map +1 -1
- package/dist/dev.d.ts +3 -2
- package/dist/dev.js +2 -1
- package/dist/doctor-BA0i-YAN.js +270 -0
- package/dist/doctor-BA0i-YAN.js.map +1 -0
- package/dist/dump-D1vX8ozg.js +133 -0
- package/dist/dump-D1vX8ozg.js.map +1 -0
- package/dist/errors-7Rk1HGCE.js +160 -0
- package/dist/errors-7Rk1HGCE.js.map +1 -0
- package/dist/{validate-DtljsCh1.js → export-BVL2EvYE.js} +409 -19
- package/dist/export-BVL2EvYE.js.map +1 -0
- package/dist/fsck-BWkPgov4.js +145 -0
- package/dist/fsck-BWkPgov4.js.map +1 -0
- package/dist/{gcs-admin-Bx6xSNJj.d.ts → gcs-admin-Dso1HWQj.d.ts} +18 -14
- package/dist/gcs.d.ts +19 -7
- package/dist/gcs.js +1 -2
- package/dist/{goog4-signer-Z7KnJ1su.js → goog4-signer-CeLIABoE.js} +102 -92
- package/dist/goog4-signer-CeLIABoE.js.map +1 -0
- package/dist/{http-7zT29K3P.js → http-Z5rZyYMX.js} +898 -271
- package/dist/http-Z5rZyYMX.js.map +1 -0
- package/dist/http-transport-DNUM8kU-.js +1299 -0
- package/dist/http-transport-DNUM8kU-.js.map +1 -0
- package/dist/http.d.ts +366 -294
- package/dist/http.js +2 -2
- package/dist/index-JJrIu1pO.d.ts +135 -0
- package/dist/index-LEgHN0qJ.d.ts +50 -0
- package/dist/{index-DP3ClvcA.d.ts → index-RiEYj8t0.d.ts} +291 -78
- package/dist/index.d.ts +27 -6
- package/dist/index.js +3 -5
- package/dist/inspect-BTsVYZKd.js +196 -0
- package/dist/inspect-BTsVYZKd.js.map +1 -0
- package/dist/{key-Di6yyxFu.js → key-C4FPZ9Io.js} +3 -4
- package/dist/{key-Di6yyxFu.js.map → key-C4FPZ9Io.js.map} +1 -1
- package/dist/ledger-Dj_bGgo0.js +192 -0
- package/dist/ledger-Dj_bGgo0.js.map +1 -0
- package/dist/legacy-names-DgZBtgOh.js +47 -0
- package/dist/legacy-names-DgZBtgOh.js.map +1 -0
- package/dist/log-C9W15Dfo.d.ts +94 -0
- package/dist/log-tail-DWJbneBF.js +142 -0
- package/dist/log-tail-DWJbneBF.js.map +1 -0
- package/dist/log-walk-C-vA-WGJ.js +111 -0
- package/dist/log-walk-C-vA-WGJ.js.map +1 -0
- package/dist/maintenance-Dd-Yakqj.js +1709 -0
- package/dist/maintenance-Dd-Yakqj.js.map +1 -0
- package/dist/maintenance-DevB6z4e.js +2237 -0
- package/dist/maintenance-DevB6z4e.js.map +1 -0
- package/dist/maintenance.d.ts +100 -3
- package/dist/maintenance.js +1 -3
- package/dist/node.d.ts +119 -92
- package/dist/node.js +3 -3
- package/dist/{observability-Ch-VQJyE.js → observability-C-ISCCLE.js} +1247 -326
- package/dist/observability-C-ISCCLE.js.map +1 -0
- package/dist/observability.d.ts +27 -3
- package/dist/observability.js +3 -3
- package/dist/path-segment-DBXG26PW.js +363 -0
- package/dist/path-segment-DBXG26PW.js.map +1 -0
- package/dist/{plan-C4qgiXSg.js → plan-BvQbaNMe.js} +19 -11
- package/dist/plan-BvQbaNMe.js.map +1 -0
- package/dist/request-CRWiTrza.js +272 -0
- package/dist/request-CRWiTrza.js.map +1 -0
- package/dist/restore-U6Im8V1V.js +1467 -0
- package/dist/restore-U6Im8V1V.js.map +1 -0
- package/dist/retry-OBtLB2GC.js +126 -0
- package/dist/retry-OBtLB2GC.js.map +1 -0
- package/dist/rolldown-runtime-D3KUYPsf.js +12 -0
- package/dist/{runtime-spec--LykAdl1.js → runtime-spec-B5mg3pHF.js} +189 -28
- package/dist/runtime-spec-B5mg3pHF.js.map +1 -0
- package/dist/{s3-http-DD5gDc7t.d.ts → s3-http-DBC_wiCL.d.ts} +14 -8
- package/dist/s3.d.ts +20 -7
- package/dist/s3.js +4 -5
- package/dist/s3.js.map +1 -1
- package/dist/{sha256-CqcKTjw9.js → sha256-4FfGQNPw.js} +9 -9
- package/dist/sha256-4FfGQNPw.js.map +1 -0
- package/dist/{shared-secret-DgEicd3x.js → shared-secret-Vkur-8r0.js} +27 -15
- package/dist/shared-secret-Vkur-8r0.js.map +1 -0
- package/dist/{aws4fetch.esm-CXE5ZbAa.js → sigv4-sign-5IUflUD_.js} +143 -96
- package/dist/sigv4-sign-5IUflUD_.js.map +1 -0
- package/dist/snapshot-CknzkDM0.js +148 -0
- package/dist/snapshot-CknzkDM0.js.map +1 -0
- package/dist/{src-BMFfDUI2.js → src-Actga-bO.js} +949 -363
- package/dist/src-Actga-bO.js.map +1 -0
- package/dist/src-D0MQfvOp.js +812 -0
- package/dist/src-D0MQfvOp.js.map +1 -0
- package/dist/src-Dr9uo3dc.js +501 -0
- package/dist/src-Dr9uo3dc.js.map +1 -0
- package/dist/{subcommand-BV68pqwJ.js → subcommand-BLoF66dG.js} +89 -16
- package/dist/subcommand-BLoF66dG.js.map +1 -0
- package/dist/{time-DUqvFMHq.js → time-DRxTP9iv.js} +15 -34
- package/dist/time-DRxTP9iv.js.map +1 -0
- package/dist/types-suVbsEWS.d.ts +116 -0
- package/dist/{usage-BMZR8o6U.js → usage-CPzVhrQr.js} +40 -45
- package/dist/usage-CPzVhrQr.js.map +1 -0
- package/dist/uuid-BuT_c404.js +333 -0
- package/dist/uuid-BuT_c404.js.map +1 -0
- package/dist/verifier-Bmlmndzo.d.ts +95 -0
- package/dist/{wire-izfGZDvr.js → wire-DndvKU-K.js} +2 -3
- package/dist/wire-DndvKU-K.js.map +1 -0
- package/package.json +90 -69
- package/dist/aws4fetch.esm-CXE5ZbAa.js.map +0 -1
- package/dist/bytes-BXdamO3L.js +0 -11
- package/dist/bytes-BXdamO3L.js.map +0 -1
- package/dist/cloudflare-wrVYf4bb.js.map +0 -1
- package/dist/config-B6nTy8e2.js +0 -3095
- package/dist/config-B6nTy8e2.js.map +0 -1
- package/dist/constants-CfeMWQWk.js +0 -222
- package/dist/constants-CfeMWQWk.js.map +0 -1
- package/dist/context-DRZ3tZ5l.js.map +0 -1
- package/dist/cost-_SE_SVgZ.js +0 -203
- package/dist/cost-_SE_SVgZ.js.map +0 -1
- package/dist/current-json-C6nhPOm1.js.map +0 -1
- package/dist/db-DjjthkTi.d.ts +0 -254
- package/dist/deploy-Di_Q01qx.js.map +0 -1
- package/dist/doctor-RWVRpvat.js +0 -102
- package/dist/doctor-RWVRpvat.js.map +0 -1
- package/dist/dump-m2vEYDNY.js +0 -94
- package/dist/dump-m2vEYDNY.js.map +0 -1
- package/dist/errors-Dfa3p78c.js +0 -78
- package/dist/errors-Dfa3p78c.js.map +0 -1
- package/dist/export-DenKwEQu.js +0 -401
- package/dist/export-DenKwEQu.js.map +0 -1
- package/dist/fsck-2Vq-7-e2.js +0 -279
- package/dist/fsck-2Vq-7-e2.js.map +0 -1
- package/dist/goog4-signer-Z7KnJ1su.js.map +0 -1
- package/dist/http-7zT29K3P.js.map +0 -1
- package/dist/http-transport-BTgVCY5r.js +0 -1250
- package/dist/http-transport-BTgVCY5r.js.map +0 -1
- package/dist/index-BHz92Acj.d.ts +0 -162
- package/dist/index-CEZKQsKt.d.ts +0 -1113
- package/dist/index-uE-w2dgj.d.ts +0 -115
- package/dist/indexes-Dn9hbGQG.d.ts +0 -22
- package/dist/inspect-BpYbH1DM.js +0 -133
- package/dist/inspect-BpYbH1DM.js.map +0 -1
- package/dist/log-tail-QWU4wlu-.js +0 -514
- package/dist/log-tail-QWU4wlu-.js.map +0 -1
- package/dist/maintenance-BGHGt2Yg.d.ts +0 -537
- package/dist/maintenance-DULFcpd1.js +0 -2144
- package/dist/maintenance-DULFcpd1.js.map +0 -1
- package/dist/maintenance-fEi-UZ2o.js +0 -1412
- package/dist/maintenance-fEi-UZ2o.js.map +0 -1
- package/dist/normalize-rjnZLwS4.js +0 -133
- package/dist/normalize-rjnZLwS4.js.map +0 -1
- package/dist/observability-Ch-VQJyE.js.map +0 -1
- package/dist/plan-C4qgiXSg.js.map +0 -1
- package/dist/query-C43r-6ib.js +0 -1773
- package/dist/query-C43r-6ib.js.map +0 -1
- package/dist/rebuild-index-BH1dc1p6.js +0 -81
- package/dist/rebuild-index-BH1dc1p6.js.map +0 -1
- package/dist/request-u0M51mhJ.js +0 -72
- package/dist/request-u0M51mhJ.js.map +0 -1
- package/dist/restore-D0VYWzfP.js +0 -778
- package/dist/restore-D0VYWzfP.js.map +0 -1
- package/dist/rolldown-runtime-EAsCxrDo.js +0 -14
- package/dist/runtime-spec--LykAdl1.js.map +0 -1
- package/dist/sha256-CqcKTjw9.js.map +0 -1
- package/dist/shared-secret-DgEicd3x.js.map +0 -1
- package/dist/src-BMFfDUI2.js.map +0 -1
- package/dist/src-DYZ4H1aF.js +0 -392
- package/dist/src-DYZ4H1aF.js.map +0 -1
- package/dist/src-DvbTEya2.js +0 -536
- package/dist/src-DvbTEya2.js.map +0 -1
- package/dist/subcommand-BV68pqwJ.js.map +0 -1
- package/dist/time-DUqvFMHq.js.map +0 -1
- package/dist/usage-BMZR8o6U.js.map +0 -1
- package/dist/validate-DtljsCh1.js.map +0 -1
- package/dist/wire-izfGZDvr.js.map +0 -1
|
@@ -1,537 +0,0 @@
|
|
|
1
|
-
import { d as IndexDefinition } from "./app-config-DyiFK3_k.js";
|
|
2
|
-
import { d as CurrentJson, p as Storage } from "./index-CEZKQsKt.js";
|
|
3
|
-
//#region packages/server/src/compactor.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Public configuration knobs for {@link compact}. All optional; the
|
|
6
|
-
* engine works unbounded by default. Opt into a per-run cap via the
|
|
7
|
-
* `CLOUDFLARE_FREE_TIER` profile (from `./maintenance.ts`) or by
|
|
8
|
-
* reaching for {@link InternalCompactOptions} via the
|
|
9
|
-
* `@baerly/server/_internal/testing` subpath.
|
|
10
|
-
*/
|
|
11
|
-
interface CompactOptions {
|
|
12
|
-
/**
|
|
13
|
-
* Minimum log-tail length to compact. Skips work when there are
|
|
14
|
-
* fewer than this many live entries past the last snapshot.
|
|
15
|
-
* Default 100.
|
|
16
|
-
*/
|
|
17
|
-
readonly minEntriesToCompact?: number;
|
|
18
|
-
/** Optional AbortSignal forwarded to every storage call. */
|
|
19
|
-
readonly signal?: AbortSignal;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Internal-only widening of {@link CompactOptions}. Surfaced via the
|
|
23
|
-
* `@baerly/server/_internal/testing` subpath (NOT in the published
|
|
24
|
-
* `publishConfig.exports`); production callers should use
|
|
25
|
-
* {@link CompactOptions}.
|
|
26
|
-
*
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
interface InternalCompactOptions extends CompactOptions {
|
|
30
|
-
/**
|
|
31
|
-
* @internal Budget cap for the CF free-tier subrequest budget;
|
|
32
|
-
* `CLOUDFLARE_FREE_TIER` sets it. Tests also set it to exercise
|
|
33
|
-
* the cap path. The compactor's I/O profile is
|
|
34
|
-
* `maxEntriesPerRun + 3` subrequests (N GETs + 1 PUT snapshot +
|
|
35
|
-
* 1 GET current + 1 PUT current). The default is effectively
|
|
36
|
-
* unbounded (`Number.MAX_SAFE_INTEGER`).
|
|
37
|
-
*/
|
|
38
|
-
readonly maxEntriesPerRun?: number;
|
|
39
|
-
/**
|
|
40
|
-
* @internal SNAPSHOT-axis byte ceiling. The rebuilt snapshot body
|
|
41
|
-
* (NOT snapshot + tail) must be `<= ceilingBytes` or the fold is
|
|
42
|
-
* DEFERRED before the PUT. `undefined ⇒ no ceiling` (`Infinity`).
|
|
43
|
-
* The write-tick runner threads its pre-fold-projection `C` here as
|
|
44
|
-
* a Node-side belt-and-suspenders; on a CPU-killable CF isolate the
|
|
45
|
-
* kill lands during walk+encode (before this check), so the decisive
|
|
46
|
-
* CF guard is the runner's pre-fold projection, not this.
|
|
47
|
-
*/
|
|
48
|
-
readonly ceilingBytes?: number;
|
|
49
|
-
/**
|
|
50
|
-
* @internal SNAPSHOT-axis row ceiling. The rebuilt snapshot row count
|
|
51
|
-
* (`base.size`, NOT including the tail) must be `<= ceilingEntries`
|
|
52
|
-
* or the fold is DEFERRED before the PUT. `undefined ⇒ no ceiling`
|
|
53
|
-
* (`Infinity`). Catches the tiny-doc case where bytes stay small but
|
|
54
|
-
* row count balloons.
|
|
55
|
-
*/
|
|
56
|
-
readonly ceilingEntries?: number;
|
|
57
|
-
/**
|
|
58
|
-
* @internal A fresh tail LOWER BOUND the caller already observed (the
|
|
59
|
-
* write-tick runner threads the writer's in-memory `observedTail`,
|
|
60
|
-
* `seq + 1`). When present it raises the ceiling-probe FLOOR to
|
|
61
|
-
* `max(log_seq_start, tail_hint, knownTail)`, so on a stale-low stored
|
|
62
|
-
* `tail_hint` the forward probe walks only "commits since this writer's
|
|
63
|
-
* commit" instead of re-walking the whole gap from the stale hint
|
|
64
|
-
* (which could blow the CF subrequest budget — B4). The compactor still
|
|
65
|
-
* discovers the TRUE tail by probing UP from this floor (small gap).
|
|
66
|
-
* Absent on the scheduled path ⇒ probe from `max(log_seq_start,
|
|
67
|
-
* tail_hint)` as before.
|
|
68
|
-
*/
|
|
69
|
-
readonly knownTail?: number;
|
|
70
|
-
}
|
|
71
|
-
interface CompactResult {
|
|
72
|
-
/** `true` iff a new snapshot landed and `current.json` was advanced. */
|
|
73
|
-
readonly written: boolean;
|
|
74
|
-
/** Reason `written === false`. */
|
|
75
|
-
readonly skippedReason?: "below-min-threshold" | "current-json-missing" | "cas-lost" | "deferred";
|
|
76
|
-
/** `true` on the over-ceiling rebuild-defer path (`skippedReason === "deferred"`). */
|
|
77
|
-
readonly deferred?: boolean;
|
|
78
|
-
/** Prior snapshot key (`null` if no prior snapshot existed). */
|
|
79
|
-
readonly previousSnapshotKey: string | null;
|
|
80
|
-
/** New snapshot key (`undefined` if `written === false` and no PUT happened). */
|
|
81
|
-
readonly newSnapshotKey?: string;
|
|
82
|
-
/** `log_seq_start` before the run. */
|
|
83
|
-
readonly logSeqStartBefore: number;
|
|
84
|
-
/** `log_seq_start` after the run. */
|
|
85
|
-
readonly logSeqStartAfter: number;
|
|
86
|
-
/** Number of log entries folded into the new snapshot. */
|
|
87
|
-
readonly entriesFolded: number;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Fold a prefix of the live log into a new snapshot and CAS-advance
|
|
91
|
-
* `current.json`. Idempotent: a second run with no new writes is a
|
|
92
|
-
* no-op (below-min-threshold).
|
|
93
|
-
*
|
|
94
|
-
* Single-attempt: on CAS conflict we return
|
|
95
|
-
* `{written: false, skippedReason: "cas-lost", newSnapshotKey}` — the
|
|
96
|
-
* caller (the cron handler invoking `runScheduledMaintenance` from
|
|
97
|
-
* `./maintenance.ts`) decides whether to schedule another run. The
|
|
98
|
-
* orphan snapshot file just written will be swept by `runGc()`.
|
|
99
|
-
*
|
|
100
|
-
* @throws BaerlyError code="InvalidResponse" — `current.json` is
|
|
101
|
-
* present but malformed, or a snapshot body fails its schema /
|
|
102
|
-
* collection cross-check.
|
|
103
|
-
* @throws BaerlyError code="Internal" — protocol-invariant violation:
|
|
104
|
-
* a log entry missing inside `[log_seq_start, foldEnd)`, or the
|
|
105
|
-
* prior-snapshot pointer resolves to no body / a body whose hash
|
|
106
|
-
* doesn't match its filename.
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* ```ts
|
|
110
|
-
* import { compact } from "@gusto/baerly-storage";
|
|
111
|
-
*
|
|
112
|
-
* const res = await compact(
|
|
113
|
-
* { storage, currentJsonKey: "app/x/tenant/t/manifests/tickets/current.json" },
|
|
114
|
-
* { minEntriesToCompact: 100, maxEntriesPerRun: 40 },
|
|
115
|
-
* );
|
|
116
|
-
* if (res.written) console.log("snapshot landed at", res.newSnapshotKey);
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
|
-
declare const compact: (args: {
|
|
120
|
-
storage: Storage; /** Full bucket-relative key of the CAS pointer. */
|
|
121
|
-
currentJsonKey: string;
|
|
122
|
-
}, options?: CompactOptions) => Promise<CompactResult>;
|
|
123
|
-
//#endregion
|
|
124
|
-
//#region packages/server/src/gc.d.ts
|
|
125
|
-
/**
|
|
126
|
-
* Public tunables for {@link runGc}. All optional; the engine works
|
|
127
|
-
* unbounded by default. Opt into per-run caps via the
|
|
128
|
-
* `CLOUDFLARE_FREE_TIER` profile (from `./maintenance.ts`) or by
|
|
129
|
-
* reaching for {@link InternalRunGcOptions} via the
|
|
130
|
-
* `@baerly/server/_internal/testing` subpath.
|
|
131
|
-
*/
|
|
132
|
-
interface RunGcOptions {
|
|
133
|
-
readonly signal?: AbortSignal;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Internal-only widening of {@link RunGcOptions}. Surfaced via the
|
|
137
|
-
* `@baerly/server/_internal/testing` subpath (NOT in the published
|
|
138
|
-
* `publishConfig.exports`); production callers should use
|
|
139
|
-
* {@link RunGcOptions}.
|
|
140
|
-
*
|
|
141
|
-
* @internal
|
|
142
|
-
*/
|
|
143
|
-
interface InternalRunGcOptions extends RunGcOptions {
|
|
144
|
-
/**
|
|
145
|
-
* @internal Override grace-period for tests. Defaults to
|
|
146
|
-
* {@link GC_GRACE_PERIOD_MILLIS} (7 days). Tests use `0` to bypass
|
|
147
|
-
* the grace and exercise the sweep path in one pass.
|
|
148
|
-
*/
|
|
149
|
-
readonly graceMillis?: number;
|
|
150
|
-
/**
|
|
151
|
-
* @internal Budget cap on candidates marked per category per run.
|
|
152
|
-
* `CLOUDFLARE_FREE_TIER` sets it; bounds LIST + classification
|
|
153
|
-
* cost per pass. The default is effectively unbounded
|
|
154
|
-
* (`Number.MAX_SAFE_INTEGER`).
|
|
155
|
-
*/
|
|
156
|
-
readonly maxMarksPerRun?: number;
|
|
157
|
-
/**
|
|
158
|
-
* @internal Budget cap on keys deleted per run.
|
|
159
|
-
* `CLOUDFLARE_FREE_TIER` sets it — CF free-tier safe when paired
|
|
160
|
-
* with `compact()` in the same scheduled handler. The default is
|
|
161
|
-
* effectively unbounded (`Number.MAX_SAFE_INTEGER`).
|
|
162
|
-
*/
|
|
163
|
-
readonly maxSweepsPerRun?: number;
|
|
164
|
-
/**
|
|
165
|
-
* @internal Clock injection for tests. Defaults to
|
|
166
|
-
* `() => new Date()`. The function is invoked at mark time (to
|
|
167
|
-
* compute `due_at` when `lastModified` is absent) and at sweep
|
|
168
|
-
* time (to compare against candidate `due_at`).
|
|
169
|
-
*/
|
|
170
|
-
readonly now?: () => Date;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Return shape of {@link runGc}.
|
|
174
|
-
*/
|
|
175
|
-
interface RunGcResult {
|
|
176
|
-
/** Per-category counts of newly-marked candidates in this pass. */
|
|
177
|
-
readonly marked: {
|
|
178
|
-
readonly stale_log: number;
|
|
179
|
-
readonly orphan_snapshot: number;
|
|
180
|
-
readonly orphan_content: number;
|
|
181
|
-
};
|
|
182
|
-
/** Number of keys deleted in this pass. */
|
|
183
|
-
readonly swept: number;
|
|
184
|
-
/**
|
|
185
|
-
* Depth of `gc/pending.json` after this pass. Drives the
|
|
186
|
-
* `db.orphan.candidate_count` metric. Best-effort on `cas-lost` —
|
|
187
|
-
* see module JSDoc.
|
|
188
|
-
*/
|
|
189
|
-
readonly pendingDepth: number;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Single GC pass — mark new orphans, sweep due-elapsed candidates,
|
|
193
|
-
* persist via CAS-update on `gc/pending.json`.
|
|
194
|
-
*
|
|
195
|
-
* Returns immediately if `current.json` is missing — there's nothing
|
|
196
|
-
* to do until a writer has bootstrapped the collection.
|
|
197
|
-
*
|
|
198
|
-
* @example
|
|
199
|
-
* ```ts
|
|
200
|
-
* import { runGc } from "@gusto/baerly-storage";
|
|
201
|
-
*
|
|
202
|
-
* const r = await runGc({ storage, currentJsonKey });
|
|
203
|
-
* console.log(`marked ${r.marked.stale_log} stale logs, swept ${r.swept}`);
|
|
204
|
-
* ```
|
|
205
|
-
*/
|
|
206
|
-
declare const runGc: (args: {
|
|
207
|
-
storage: Storage;
|
|
208
|
-
currentJsonKey: string;
|
|
209
|
-
}, options?: RunGcOptions) => Promise<RunGcResult>;
|
|
210
|
-
//#endregion
|
|
211
|
-
//#region packages/server/src/rebuild-index.d.ts
|
|
212
|
-
/**
|
|
213
|
-
* Reconciliation summary.
|
|
214
|
-
*
|
|
215
|
-
* In a normal (mutating) run, the counts describe what was actually
|
|
216
|
-
* PUT / DELETEd. In `dryRun` mode ({@link RebuildIndexOptions.dryRun}),
|
|
217
|
-
* `added` / `removed` report the counts that a real rebuild *would*
|
|
218
|
-
* have produced — storage is unchanged. `kept` counts pre-existing
|
|
219
|
-
* intersection keys (`expected ∩ actual`) at function entry. In a real
|
|
220
|
-
* run, `kept` may also include keys promoted from `added` via the
|
|
221
|
-
* Conflict-race fallback (a PUT with `ifNoneMatch:"*"` returned 412
|
|
222
|
-
* because a peer wrote the same key first, so the key was already
|
|
223
|
-
* in place by the time we observed it); dryRun mode never issues
|
|
224
|
-
* those PUTs and therefore does not observe that race.
|
|
225
|
-
*/
|
|
226
|
-
interface RebuildIndexResult {
|
|
227
|
-
/**
|
|
228
|
-
* Keys PUT because they were missing on storage. In `dryRun` mode,
|
|
229
|
-
* the predicted PUT count — no writes were issued.
|
|
230
|
-
*/
|
|
231
|
-
readonly added: number;
|
|
232
|
-
/**
|
|
233
|
-
* Keys DELETEd because the doc no longer exists / no longer projects
|
|
234
|
-
* them. In `dryRun` mode, the predicted DELETE count — no deletes
|
|
235
|
-
* were issued.
|
|
236
|
-
*/
|
|
237
|
-
readonly removed: number;
|
|
238
|
-
/** Keys already in place. The healthy-index re-run reports this as the full expected count. */
|
|
239
|
-
readonly kept: number;
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Optional knobs accepted by {@link rebuildIndex}. Every field is
|
|
243
|
-
* optional; the function behaves identically to the older
|
|
244
|
-
* positional-arg shape when `opts` is omitted.
|
|
245
|
-
*
|
|
246
|
-
* @public — surfaced from `baerly-storage` so admin tooling and the
|
|
247
|
-
* observability layer can opt in.
|
|
248
|
-
*/
|
|
249
|
-
interface RebuildIndexOptions {
|
|
250
|
-
/**
|
|
251
|
-
* Cancellation signal. Forwarded to every storage `list` call so
|
|
252
|
-
* long-running rebuilds over large collections can be cut short
|
|
253
|
-
* by admin tooling. Storage `get` / `put` / `delete` calls inside
|
|
254
|
-
* the reconciliation loop do not currently honour the signal
|
|
255
|
-
* (the per-call durations are short enough that cooperative
|
|
256
|
-
* cancellation between calls suffices); future tightening can
|
|
257
|
-
* forward it through without breaking callers.
|
|
258
|
-
*/
|
|
259
|
-
readonly signal?: AbortSignal;
|
|
260
|
-
/**
|
|
261
|
-
* When `true`, walk the expected-vs-actual diff and return the
|
|
262
|
-
* counts that a real rebuild would have produced WITHOUT issuing
|
|
263
|
-
* any PUT or DELETE. Used by `baerly admin fsck --indexes`
|
|
264
|
-
* to report drift cheaply. Defaults to `false`.
|
|
265
|
-
*
|
|
266
|
-
* `kept` is reported as the pre-existing intersection
|
|
267
|
-
* (`expected ∩ actual`); a real run can additionally fold
|
|
268
|
-
* Conflict-race-demoted PUTs into `kept`, which dryRun does not
|
|
269
|
-
* observe. See {@link RebuildIndexResult}.
|
|
270
|
-
*/
|
|
271
|
-
readonly dryRun?: boolean;
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Idempotently reconcile one secondary index for one collection.
|
|
275
|
-
*
|
|
276
|
-
* @param storage Storage handle (any in-tree `Storage`).
|
|
277
|
-
* @param currentJsonKey The collection's `current.json` key.
|
|
278
|
-
* @param def The index to reconcile. Single-field today;
|
|
279
|
-
* composite definitions are accepted by the
|
|
280
|
-
* key encoder but the read path only consults
|
|
281
|
-
* single-field keys.
|
|
282
|
-
* @param opts Optional knobs — see {@link RebuildIndexOptions}.
|
|
283
|
-
* Strictly additive: existing positional-arg
|
|
284
|
-
* callers compile and behave unchanged when
|
|
285
|
-
* omitted.
|
|
286
|
-
*
|
|
287
|
-
* @throws BaerlyError code="InvalidResponse" — `current.json` missing.
|
|
288
|
-
* @throws BaerlyError code="Internal" — protocol-invariant
|
|
289
|
-
* violation (snapshot hash mismatch, missing log entry inside
|
|
290
|
-
* `[log_seq_start, tail_hint)`).
|
|
291
|
-
*/
|
|
292
|
-
declare const rebuildIndex: (storage: Storage, currentJsonKey: string, def: IndexDefinition, opts?: RebuildIndexOptions) => Promise<RebuildIndexResult>;
|
|
293
|
-
//#endregion
|
|
294
|
-
//#region packages/server/src/maintenance.d.ts
|
|
295
|
-
interface MaintenanceArgs {
|
|
296
|
-
readonly storage: Storage;
|
|
297
|
-
/** Full bucket-relative key of the CAS pointer for the target collection. */
|
|
298
|
-
readonly currentJsonKey: string;
|
|
299
|
-
}
|
|
300
|
-
interface MaintenanceOptions {
|
|
301
|
-
/** Forwarded to `compact()`. */
|
|
302
|
-
readonly compact?: CompactOptions;
|
|
303
|
-
/** Forwarded to `runGc()`. */
|
|
304
|
-
readonly gc?: RunGcOptions;
|
|
305
|
-
/** Forwarded to both primitives. */
|
|
306
|
-
readonly signal?: AbortSignal;
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Internal-only widening of {@link MaintenanceOptions}. Surfaced via
|
|
310
|
-
* the `@baerly/server/_internal/testing` subpath (NOT in the
|
|
311
|
-
* published `publishConfig.exports`); production callers should use
|
|
312
|
-
* {@link MaintenanceOptions}.
|
|
313
|
-
*
|
|
314
|
-
* @internal
|
|
315
|
-
*/
|
|
316
|
-
interface InternalMaintenanceOptions extends MaintenanceOptions {
|
|
317
|
-
/** @internal Internal compact options (budget caps). */
|
|
318
|
-
readonly compact?: InternalCompactOptions;
|
|
319
|
-
/** @internal Internal GC options (budget caps + clock seam + grace). */
|
|
320
|
-
readonly gc?: InternalRunGcOptions;
|
|
321
|
-
}
|
|
322
|
-
interface MaintenanceResult {
|
|
323
|
-
readonly compact: CompactResult;
|
|
324
|
-
readonly gc: RunGcResult;
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Single maintenance pass for one collection. Runs `compact()` then
|
|
328
|
-
* `runGc()` (in that order; the compactor's advance of
|
|
329
|
-
* `log_seq_start` produces the stale-log candidates the GC then
|
|
330
|
-
* marks). Callers wanting a single phase per tick invoke
|
|
331
|
-
* `compact()` or `runGc()` directly instead.
|
|
332
|
-
*
|
|
333
|
-
* Errors propagate — the caller's cron handler is responsible for
|
|
334
|
-
* logging them. The Cloudflare runtime ships uncaught Worker errors
|
|
335
|
-
* to the dashboard; Node operators wrap their `node-cron` callbacks
|
|
336
|
-
* themselves.
|
|
337
|
-
*
|
|
338
|
-
* @example
|
|
339
|
-
* ```ts
|
|
340
|
-
* import { runScheduledMaintenance, CLOUDFLARE_FREE_TIER } from "@gusto/baerly-storage/maintenance";
|
|
341
|
-
*
|
|
342
|
-
* // Node (unbounded — defaults fold the entire live tail):
|
|
343
|
-
* const res = await runScheduledMaintenance(
|
|
344
|
-
* { storage, currentJsonKey: "app/x/tenant/t/manifests/tickets/current.json" },
|
|
345
|
-
* );
|
|
346
|
-
* console.log("compacted:", res.compact.entriesFolded, "swept:", res.gc.swept);
|
|
347
|
-
*
|
|
348
|
-
* // Cloudflare free tier (50-subrequest cap, single phase per tick):
|
|
349
|
-
* await runScheduledMaintenance({ storage, currentJsonKey }, CLOUDFLARE_FREE_TIER);
|
|
350
|
-
* ```
|
|
351
|
-
*/
|
|
352
|
-
declare const runScheduledMaintenance: (args: MaintenanceArgs, options?: MaintenanceOptions) => Promise<MaintenanceResult>;
|
|
353
|
-
/** The six host-agnostic write-tick budgets (`maxFoldBytes`=`C`, `maxFoldRows`=`E`). Canonical shape; mirrors the protocol constants (typed there to avoid a cycle). */
|
|
354
|
-
interface MaintenanceProfile {
|
|
355
|
-
readonly gcInterval: number;
|
|
356
|
-
readonly gcMaxMarks: number;
|
|
357
|
-
readonly gcMaxSweeps: number;
|
|
358
|
-
readonly maxFoldEntriesPerPass: number;
|
|
359
|
-
readonly maxFoldBytes: number;
|
|
360
|
-
readonly maxFoldRows: number;
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Tuning profile for the 50-subrequest Cloudflare free-tier budget,
|
|
364
|
-
* derived from {@link MAINTENANCE_PROFILE_CF_FREE} (one source of truth).
|
|
365
|
-
*
|
|
366
|
-
* Budget arithmetic (worst case):
|
|
367
|
-
* compact: 1 GET current + 1 GET snapshot (if any) + N GETs log
|
|
368
|
-
* + 1 PUT snapshot + 1 PUT current = 3 + N (N = maxEntriesPerRun).
|
|
369
|
-
* runGc: 1 GET current + 1 GET pending + 3 LISTs (one page each)
|
|
370
|
-
* + M GETs log (live tail for content hashes) + S DELETEs + 1 PUT
|
|
371
|
-
* pending = 6 + M + S.
|
|
372
|
-
*
|
|
373
|
-
* With N=20, M=20, S=10 the totals are: compact ≈ 23, gc ≈ 36 — over
|
|
374
|
-
* the 50 cap combined. The Cloudflare scheduled handler therefore
|
|
375
|
-
* alternates phases per tick (even minute → compact, odd minute →
|
|
376
|
-
* GC) by calling `compact()` / `runGc()` directly instead of
|
|
377
|
-
* `runScheduledMaintenance`; the `maintenance-budget.test.ts`
|
|
378
|
-
* worst-case test proves each phase in isolation sits under 50 ops
|
|
379
|
-
* with these bounds.
|
|
380
|
-
*/
|
|
381
|
-
declare const CLOUDFLARE_FREE_TIER: MaintenanceOptions;
|
|
382
|
-
/**
|
|
383
|
-
* Tuning profile for the 10,000-subrequest Cloudflare paid-tier budget,
|
|
384
|
-
* derived from {@link MAINTENANCE_PROFILE_CF_PAID} (one source of truth).
|
|
385
|
-
* Keeps the single-phase CPU-killable shape but affords Node-tier per-pass
|
|
386
|
-
* throughput (compact ≈ 3+200, gc ≈ 6+200+100 — far under the 10k cap).
|
|
387
|
-
*
|
|
388
|
-
* To honour `BAERLY_MAINTENANCE_PROFILE=cf-paid` on the cron path, pass this
|
|
389
|
-
* constant to `runScheduledMaintenance` inside your
|
|
390
|
-
* {@link WorkerScheduledHandler}; the worked recipe lives in the `scheduled`
|
|
391
|
-
* handler docstring of `baerlyWorker` (`@gusto/baerly-storage/cloudflare`).
|
|
392
|
-
*/
|
|
393
|
-
declare const CLOUDFLARE_PAID_TIER: MaintenanceOptions;
|
|
394
|
-
/**
|
|
395
|
-
* Floor-based GC-cadence boundary crossing. Every commit advances the
|
|
396
|
-
* writer-observed tail by one logical slot; `tail_hint` remains a
|
|
397
|
-
* lower bound and may be refreshed later by maintenance. The floor test
|
|
398
|
-
* trips on any interval boundary inside `(prevSeq, nextSeq]`, so it
|
|
399
|
-
* stays correct whether the observed/probed tail advances by one or
|
|
400
|
-
* catches up by a larger step.
|
|
401
|
-
*/
|
|
402
|
-
declare const crossesGcBoundary: (prevSeq: number, nextSeq: number, interval: number) => boolean;
|
|
403
|
-
/**
|
|
404
|
-
* Derived live-tail byte size — the ratio TRIGGER input that replaces the
|
|
405
|
-
* formerly-stored exact byte count. `(observedTail − log_seq_start) ×
|
|
406
|
-
* mean_entry_bytes`. `observedTail` is a param so write-tick callers can
|
|
407
|
-
* pass the writer-observed tail and scheduled callers can pass a
|
|
408
|
-
* probe-discovered true tail. Cold-start (no mean yet) falls back to
|
|
409
|
-
* {@link MAINTENANCE_COLD_START_ENTRY_BYTES}, never 0 (see that constant).
|
|
410
|
-
* TRIGGER-only — structurally barred from `foldViable` (the exact-bytes CPU-kill
|
|
411
|
-
* ceiling).
|
|
412
|
-
*/
|
|
413
|
-
declare const estimateTailBytes: (current: CurrentJson, observedTail: number) => number;
|
|
414
|
-
/**
|
|
415
|
-
* The cheap DISPATCH gate the writer calls after a commit — zero
|
|
416
|
-
* storage ops; it reads the post-commit {@link CurrentJson} already in
|
|
417
|
-
* scope. Ratio-OR-boundary, WITHOUT the entry floor (the floor is part
|
|
418
|
-
* of the fold-trigger Gate 1 checked inside {@link runBoundedMaintenance}).
|
|
419
|
-
* Returning `false` lets the writer skip the dispatch entirely. Ratio
|
|
420
|
-
* numerator is the DERIVED {@link estimateTailBytes};
|
|
421
|
-
* `observedTail` threads from the caller (the writer's in-memory observed
|
|
422
|
-
* tail `seq+1` under single-write commit). Both the boundary check and the
|
|
423
|
-
* ratio key off `observedTail`, since the stored `tail_hint` is now only a
|
|
424
|
-
* non-authoritative lower bound (compactor-advanced).
|
|
425
|
-
*/
|
|
426
|
-
declare const shouldFireMaintenance: (current: CurrentJson, prevSeq: number, gcInterval: number, observedTail: number) => boolean;
|
|
427
|
-
/** Per-tier caps for {@link runBoundedMaintenance}, threaded by the adapter. */
|
|
428
|
-
interface BoundedMaintenanceOptions {
|
|
429
|
-
/** Host budgets, threaded by the adapter. Absent ⇒ {@link MAINTENANCE_PROFILE_CF_FREE} (CF-free-safe default; keeps a bare `Db.create()` maintaining). */
|
|
430
|
-
readonly profile?: MaintenanceProfile;
|
|
431
|
-
/** Gate-1 minimum live-tail length. Default {@link WRITE_TICK_MIN_ENTRIES_TO_COMPACT}. */
|
|
432
|
-
readonly minEntriesToCompact?: number;
|
|
433
|
-
/**
|
|
434
|
-
* How many phases this tick may run. `"single"` (CF-free-safe
|
|
435
|
-
* default) runs at most one of fold / GC per tick; `"both"` lets a
|
|
436
|
-
* capable host run a fold AND a GC in one tick.
|
|
437
|
-
*/
|
|
438
|
-
readonly phasesPerTick?: "single" | "both";
|
|
439
|
-
/**
|
|
440
|
-
* @internal — test seam. Forwarded into the runner's `runGc` call as
|
|
441
|
-
* `graceMillis`. Default `undefined` ⇒ `runGc`'s 7-day
|
|
442
|
-
* {@link GC_GRACE_PERIOD_MILLIS}. The drain-rate test sets `0` so a
|
|
443
|
-
* single pass marks AND sweeps, making the steady-state object-count
|
|
444
|
-
* trajectory observable without an 8-day clock advance. Production
|
|
445
|
-
* never sets this.
|
|
446
|
-
*/
|
|
447
|
-
readonly gcGraceMillis?: number;
|
|
448
|
-
/**
|
|
449
|
-
* @internal — test seam. Forwarded into the runner's `runGc` call as
|
|
450
|
-
* the clock `now`. Default `undefined` ⇒ `runGc`'s `() => new Date()`.
|
|
451
|
-
* Production never sets this.
|
|
452
|
-
*/
|
|
453
|
-
readonly now?: () => Date;
|
|
454
|
-
readonly signal?: AbortSignal;
|
|
455
|
-
}
|
|
456
|
-
/**
|
|
457
|
-
* The write-tick maintenance runner: a bounded, single-attempt
|
|
458
|
-
* composition of {@link compact} and {@link runGc} for one collection,
|
|
459
|
-
* sized to fit a CPU-killable Cloudflare free-tier isolate by default.
|
|
460
|
-
*
|
|
461
|
-
* INVARIANT: a {@link MaintenanceProfile} changes only maintenance rate +
|
|
462
|
-
* defer threshold — never data/API/query/wire/correctness; reads stay pure.
|
|
463
|
-
* See `maintenance-profile-equivalence.test.ts`.
|
|
464
|
-
*
|
|
465
|
-
* Never throws — the write-tick caller must never see a maintenance
|
|
466
|
-
* failure. Expected signals (CAS contention, an over-ceiling deferral)
|
|
467
|
-
* are swallowed quietly; unexpected throws bump
|
|
468
|
-
* `db.maintenance.unexpected_error_total`, log a stack, and are
|
|
469
|
-
* swallowed.
|
|
470
|
-
*
|
|
471
|
-
* Control flow (fold-priority with a stateless GC-starvation guard):
|
|
472
|
-
* 0. `disabled` → skip fold/GC, but still allow the rate-limited
|
|
473
|
-
* tail_hint refresh that bounds read/write forward-probes.
|
|
474
|
-
* 1. Read `current.json` once.
|
|
475
|
-
* 2. Hard-GC starvation boundary (`"single"` only) → GC slice, skip fold.
|
|
476
|
-
* 3. Gate 1 (ratio AND entry floor) trips → fold if viable, else
|
|
477
|
-
* defer (and metric); on `"single"` a successful fold attempt is
|
|
478
|
-
* this tick's one phase.
|
|
479
|
-
* 4. Otherwise (or on `"both"`) → GC iff the cadence boundary crossed.
|
|
480
|
-
*/
|
|
481
|
-
declare const runBoundedMaintenance: (args: {
|
|
482
|
-
storage: Storage;
|
|
483
|
-
currentJsonKey: string; /** The pre-commit observed tail — the GC cadence baseline. */
|
|
484
|
-
prevSeq: number;
|
|
485
|
-
/**
|
|
486
|
-
* Writer's in-memory observed tail (`seq + 1`). Given on the
|
|
487
|
-
* write-tick path so the runner's Gate-1 ratio + GC cadence key off
|
|
488
|
-
* the true tail without an O(gap) re-probe (the stored `tail_hint` is
|
|
489
|
-
* only a lower bound). Absent on a scheduled tick ⇒ the runner probes.
|
|
490
|
-
*/
|
|
491
|
-
observedTail?: number; /** `C` override (from `BAERLY_MAINTENANCE_MAX_FOLD_BYTES`). */
|
|
492
|
-
maxFoldBytes?: number; /** From `BAERLY_MAINTENANCE_DISABLE`: disable fold/GC phases, not tail_hint refresh. */
|
|
493
|
-
disabled?: boolean;
|
|
494
|
-
}, options?: BoundedMaintenanceOptions) => Promise<void>;
|
|
495
|
-
/**
|
|
496
|
-
* Default maintenance dispatcher: run the task inline and await it.
|
|
497
|
-
* Adapters that can keep running after the response (Cloudflare:
|
|
498
|
-
* `ctx.waitUntil`) override this with a fire-and-forget variant that
|
|
499
|
-
* returns `void`.
|
|
500
|
-
*/
|
|
501
|
-
declare const dispatchInlineAwaited: (task: () => Promise<void>) => void | Promise<void>;
|
|
502
|
-
/**
|
|
503
|
-
* Per-request maintenance dispatch config, set by the adapter onto the
|
|
504
|
-
* observability context (NOT `Db.create`). It rides the per-request ALS
|
|
505
|
-
* context because `dispatch = ctx.waitUntil` is inherently per-request,
|
|
506
|
-
* and routing it through `Db.create` would widen that surface past its
|
|
507
|
-
* locked four fields. The writer reads it at the post-commit dispatch
|
|
508
|
-
* point via `getCurrentContext()?.maintenance`.
|
|
509
|
-
*
|
|
510
|
-
* Absent ⇒ inline dispatch + CF-free-safe caps (the defaults inside
|
|
511
|
-
* {@link runBoundedMaintenance}), so a bare `Db.create(...)` maintains
|
|
512
|
-
* out of the box once enough writes accrue.
|
|
513
|
-
*/
|
|
514
|
-
interface MaintenanceDispatch {
|
|
515
|
-
/** How to run the maintenance task. Default {@link dispatchInlineAwaited}. CF sets `ctx.waitUntil`. */
|
|
516
|
-
readonly dispatch?: (task: () => Promise<void>) => void | Promise<void>;
|
|
517
|
-
/** From `BAERLY_MAINTENANCE_DISABLE`: disables fold/GC phases while preserving tail_hint refresh. */
|
|
518
|
-
readonly disabled?: boolean;
|
|
519
|
-
/** `C` override, from `BAERLY_MAINTENANCE_MAX_FOLD_BYTES`. */
|
|
520
|
-
readonly maxFoldBytes?: number;
|
|
521
|
-
/** Per-tier caps forwarded to {@link runBoundedMaintenance}. */
|
|
522
|
-
readonly options?: BoundedMaintenanceOptions;
|
|
523
|
-
}
|
|
524
|
-
/**
|
|
525
|
-
* Parse the two host-agnostic ops-plane env vars into the
|
|
526
|
-
* {@link MaintenanceDispatch} overrides. Shared by every host adapter so the
|
|
527
|
-
* cross-host contract has one source of truth: `maxFoldBytes` (`C`) is the
|
|
528
|
-
* finite `BAERLY_MAINTENANCE_MAX_FOLD_BYTES` or undefined; `disabled` is
|
|
529
|
-
* `BAERLY_MAINTENANCE_DISABLE` truthy (set, non-empty, not `"0"`/`"false"`).
|
|
530
|
-
*/
|
|
531
|
-
declare const parseMaintenanceEnv: (readEnv: (key: string) => string | undefined) => {
|
|
532
|
-
maxFoldBytes?: number;
|
|
533
|
-
disabled: boolean;
|
|
534
|
-
};
|
|
535
|
-
//#endregion
|
|
536
|
-
export { CompactOptions as C, runGc as S, compact as T, RebuildIndexOptions as _, MaintenanceArgs as a, RunGcOptions as b, MaintenanceProfile as c, dispatchInlineAwaited as d, estimateTailBytes as f, shouldFireMaintenance as g, runScheduledMaintenance as h, InternalMaintenanceOptions as i, MaintenanceResult as l, runBoundedMaintenance as m, CLOUDFLARE_FREE_TIER as n, MaintenanceDispatch as o, parseMaintenanceEnv as p, CLOUDFLARE_PAID_TIER as r, MaintenanceOptions as s, BoundedMaintenanceOptions as t, crossesGcBoundary as u, RebuildIndexResult as v, CompactResult as w, RunGcResult as x, rebuildIndex as y };
|
|
537
|
-
//# sourceMappingURL=maintenance-BGHGt2Yg.d.ts.map
|