@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
package/dist/maintenance.d.ts
CHANGED
|
@@ -1,3 +1,100 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Published `@gusto/baerly-storage/maintenance` entry: the opt-in
|
|
3
|
+
* scheduled-maintenance SDK, one function addressed by collection.
|
|
4
|
+
*
|
|
5
|
+
* The phases it composes (`compact`, `runGc`), the host tiers behind its
|
|
6
|
+
* `tier` option, the write-tick runner and env parsing live in
|
|
7
|
+
* `./maintenance.ts` and reach the CLI, adapters, and bench through the
|
|
8
|
+
* unpublished `@baerly/server/_internal/maintenance` subpath.
|
|
9
|
+
*/
|
|
10
|
+
import { t as Storage } from "./types-suVbsEWS.js";
|
|
11
|
+
/**
|
|
12
|
+
* Run one opt-in scheduled maintenance pass over one collection: fold its
|
|
13
|
+
* recent writes, delete data nothing references any more, and retire old
|
|
14
|
+
* log entries. Optional: every write already runs bounded maintenance in
|
|
15
|
+
* band, so a collection that takes writes maintains itself. A schedule is
|
|
16
|
+
* for collections served mostly read-only, or to keep folding ahead of
|
|
17
|
+
* the write tick.
|
|
18
|
+
*
|
|
19
|
+
* One call does a bounded amount of work and returns; it never loops or
|
|
20
|
+
* retries, and it is safe to run concurrently with writes and with other
|
|
21
|
+
* passes. The caller schedules the next pass. Run one collection per
|
|
22
|
+
* Cloudflare invocation: shard the cron schedule or persist a collection
|
|
23
|
+
* cursor instead of looping tenants or collections in one invocation.
|
|
24
|
+
*
|
|
25
|
+
* `tier` sizes the pass for its host, in the `BAERLY_MAINTENANCE_PROFILE`
|
|
26
|
+
* vocabulary: `"cf-free"` fits one Workers Free invocation through the R2
|
|
27
|
+
* binding, `"cf-paid"` one Workers Paid invocation, and `"node"` (the
|
|
28
|
+
* default) is unbounded. S3 storage on Workers needs Paid, with
|
|
29
|
+
* `"cf-paid"`.
|
|
30
|
+
*
|
|
31
|
+
* Errors propagate; log them from the cron handler. On Cloudflare an
|
|
32
|
+
* uncaught error reaches the Workers dashboard.
|
|
33
|
+
*
|
|
34
|
+
* @throws BaerlyError code="InvalidConfig" when `app`, `tenant` or
|
|
35
|
+
* `collection` is not a name `Db.create` / `db.collection` accepts, or
|
|
36
|
+
* `tier` is not one of the listed values, or when an option this
|
|
37
|
+
* release no longer accepts is passed.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { runScheduledMaintenance } from "@gusto/baerly-storage/maintenance";
|
|
42
|
+
*
|
|
43
|
+
* const target = { storage, app: "helpdesk", tenant: "acme", collection: "tickets" };
|
|
44
|
+
*
|
|
45
|
+
* // Node: one unbounded pass.
|
|
46
|
+
* const res = await runScheduledMaintenance(target);
|
|
47
|
+
* console.log("folded", res.folded, "deleted", res.gcDeleted);
|
|
48
|
+
*
|
|
49
|
+
* // Cloudflare: one bounded pass per invocation.
|
|
50
|
+
* await runScheduledMaintenance(target, { tier: "cf-paid" });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare const runScheduledMaintenance: (target: MaintenanceTarget, options?: MaintenanceOptions) => Promise<MaintenanceResult>;
|
|
54
|
+
/** The collection one {@link runScheduledMaintenance} call maintains. */
|
|
55
|
+
interface MaintenanceTarget {
|
|
56
|
+
readonly storage: Storage;
|
|
57
|
+
/** The same `app` the `Db` that writes this collection was created with. */
|
|
58
|
+
readonly app: string;
|
|
59
|
+
/** The same `tenant` the `Db` that writes this collection was created with. */
|
|
60
|
+
readonly tenant: string;
|
|
61
|
+
/** The collection name, as passed to `db.collection(name)`. */
|
|
62
|
+
readonly collection: string;
|
|
63
|
+
}
|
|
64
|
+
/** Options for {@link runScheduledMaintenance}. All optional. */
|
|
65
|
+
interface MaintenanceOptions {
|
|
66
|
+
/**
|
|
67
|
+
* The host this pass runs on, in the `BAERLY_MAINTENANCE_PROFILE`
|
|
68
|
+
* vocabulary. `"cf-free"` and `"cf-paid"` cap one pass's work so it fits
|
|
69
|
+
* one Workers invocation on that plan; `"node"` (the default) is
|
|
70
|
+
* unbounded.
|
|
71
|
+
*/
|
|
72
|
+
readonly tier?: "cf-free" | "cf-paid" | "node";
|
|
73
|
+
/** Forwarded to every storage call. */
|
|
74
|
+
readonly signal?: AbortSignal;
|
|
75
|
+
}
|
|
76
|
+
/** What one {@link runScheduledMaintenance} call did. */
|
|
77
|
+
interface MaintenanceResult {
|
|
78
|
+
/** Writes folded into the collection's compacted state. `0` when the pass did not compact. */
|
|
79
|
+
readonly folded: number;
|
|
80
|
+
/**
|
|
81
|
+
* Present when contention or a probe budget prevented folding. Omitted
|
|
82
|
+
* for `"cf-free"` tails below its 20-entry fold floor, which stay unfolded
|
|
83
|
+
* until more writes arrive. Nothing is lost; the next pass retries after
|
|
84
|
+
* contention or a probe-budget deferral. `"contention"`: a concurrent
|
|
85
|
+
* write or pass won the race. `"budget"`: the pass ran out of its
|
|
86
|
+
* per-invocation budget while locating the latest writes; it saved its
|
|
87
|
+
* progress, so later passes get further.
|
|
88
|
+
*/
|
|
89
|
+
readonly deferred?: {
|
|
90
|
+
readonly reason: "contention" | "budget";
|
|
91
|
+
};
|
|
92
|
+
/** Objects this pass deleted from storage. */
|
|
93
|
+
readonly gcDeleted: number;
|
|
94
|
+
/**
|
|
95
|
+
* Objects marked for deletion that a later pass deletes once their grace
|
|
96
|
+
* period ends.
|
|
97
|
+
*/
|
|
98
|
+
readonly pending: number;
|
|
99
|
+
}
|
|
100
|
+
export type { MaintenanceOptions, MaintenanceResult, MaintenanceTarget };
|
package/dist/maintenance.js
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { a as estimateTailBytes, c as runScheduledMaintenance, d as runGc, f as compact, i as dispatchInlineAwaited, l as shouldFireMaintenance, n as CLOUDFLARE_PAID_TIER, o as parseMaintenanceEnv, r as crossesGcBoundary, s as runBoundedMaintenance, t as CLOUDFLARE_FREE_TIER, u as rebuildIndex } from "./maintenance-DULFcpd1.js";
|
|
3
|
-
export { CLOUDFLARE_FREE_TIER, CLOUDFLARE_PAID_TIER, MAINTENANCE_PROFILE_CF_FREE, MAINTENANCE_PROFILE_CF_PAID, MAINTENANCE_PROFILE_NODE, compact, crossesGcBoundary, dispatchInlineAwaited, estimateTailBytes, parseMaintenanceEnv, rebuildIndex, runBoundedMaintenance, runGc, runScheduledMaintenance, shouldFireMaintenance };
|
|
1
|
+
export { a as runScheduledMaintenance } from "./maintenance-DevB6z4e.js";
|
package/dist/node.d.ts
CHANGED
|
@@ -1,11 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
/**
|
|
2
|
+
* `@baerly/adapter-node` — Node host adapter for `@baerly/server`.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the runtime-appropriate `Storage` impls and the one-call
|
|
5
|
+
* host helper. Pairs with `@baerly/adapter-cloudflare`, which provides
|
|
6
|
+
* the same surface for Workers + R2 bindings.
|
|
7
|
+
*
|
|
8
|
+
* `baerlyNode` is the public seam. It composes the kernel router with
|
|
9
|
+
* `@hono/node-server`'s `serve()` and SIGTERM/SIGINT handlers into a
|
|
10
|
+
* single handle. The returned `BaerlyNodeHandle` exposes `.fetch` for
|
|
11
|
+
* in-process embedding (Vite middleware, custom servers, tests) and
|
|
12
|
+
* `.listen(port)` for the standard standalone-server case. The
|
|
13
|
+
* `serve()` call is lazy — calling `baerlyNode(opts)` builds the Hono
|
|
14
|
+
* app + resolves the verifier but does not create an `http.Server`
|
|
15
|
+
* until `.listen()` runs.
|
|
16
|
+
*
|
|
17
|
+
* Maintenance (compaction + GC) is in-band: it runs INLINE on the
|
|
18
|
+
* write path the kernel decides needs it — no `setInterval`, no cron,
|
|
19
|
+
* no operator scheduler. Tune via `BAERLY_MAINTENANCE_MAX_FOLD_BYTES` /
|
|
20
|
+
* `BAERLY_MAINTENANCE_DISABLE` (see {@link baerlyNode} for the accepted
|
|
21
|
+
* values); invalid values fail API/database dispatch with
|
|
22
|
+
* `BaerlyError{code:"InvalidConfig"}`. Call `runScheduledMaintenance`
|
|
23
|
+
* from `@gusto/baerly-storage/maintenance` for an explicit out-of-band sweep.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { baerlyNode, s3Storage } from "@gusto/baerly-storage/node";
|
|
28
|
+
* import config from "./baerly.config.ts";
|
|
29
|
+
*
|
|
30
|
+
* const handle = baerlyNode({
|
|
31
|
+
* config,
|
|
32
|
+
* storage: s3Storage({
|
|
33
|
+
* region: "us-east-1",
|
|
34
|
+
* bucket: process.env["BUCKET"]!,
|
|
35
|
+
* credentials: {
|
|
36
|
+
* accessKeyId: process.env["AWS_ACCESS_KEY_ID"]!,
|
|
37
|
+
* secretAccessKey: process.env["AWS_SECRET_ACCESS_KEY"]!,
|
|
38
|
+
* },
|
|
39
|
+
* }),
|
|
40
|
+
* });
|
|
41
|
+
* await handle.listen(Number(process.env["PORT"] ?? 8080));
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* Advanced users who need to override the `fetch` / retry knobs can
|
|
45
|
+
* construct `S3HttpStorage` directly — see the `S3HttpStorageOptions`
|
|
46
|
+
* JSDoc. The four factories (`s3Storage`, `r2Storage`, `minioStorage`,
|
|
47
|
+
* `gcsStorage`) wrap the common case for AWS S3, R2, Minio, and GCS.
|
|
48
|
+
*/
|
|
49
|
+
import { n as S3HttpStorageOptions, t as S3HttpStorage } from "./s3-http-DBC_wiCL.js";
|
|
50
|
+
import { a as DEFAULT_GCS_ENDPOINT, i as CredentialsProvider, n as gcsVersioningStatus, o as GcsHttpStorage, r as Credentials, s as GcsHttpStorageOptions, t as GcsVersioningStatus } from "./gcs-admin-Dso1HWQj.js";
|
|
51
|
+
import { t as Storage } from "./types-suVbsEWS.js";
|
|
52
|
+
import { t as DevLandingOptions } from "./dev-landing-BI5UdmOb.js";
|
|
53
|
+
import { n as BaerlyAppConfig } from "./app-config-C6qW7m8S.js";
|
|
54
|
+
import { t as Verifier } from "./verifier-Bmlmndzo.js";
|
|
55
|
+
import { f as ObservabilityConfig } from "./index-RiEYj8t0.js";
|
|
9
56
|
/**
|
|
10
57
|
* AWS S3 `Storage` factory. Wraps `S3HttpStorage` with the standard
|
|
11
58
|
* `aws4fetch` SigV4 signer. The endpoint is derived from the region as
|
|
@@ -36,7 +83,7 @@ import { n as S3HttpStorageOptions, t as S3HttpStorage } from "./s3-http-DD5gDc7
|
|
|
36
83
|
* });
|
|
37
84
|
* ```
|
|
38
85
|
*/
|
|
39
|
-
declare function s3Storage(opts: {
|
|
86
|
+
export declare function s3Storage(opts: {
|
|
40
87
|
region: string;
|
|
41
88
|
bucket: string;
|
|
42
89
|
credentials: Credentials | CredentialsProvider;
|
|
@@ -66,7 +113,7 @@ declare function s3Storage(opts: {
|
|
|
66
113
|
* });
|
|
67
114
|
* ```
|
|
68
115
|
*/
|
|
69
|
-
declare function r2Storage(opts: {
|
|
116
|
+
export declare function r2Storage(opts: {
|
|
70
117
|
accountId: string;
|
|
71
118
|
bucket: string;
|
|
72
119
|
credentials: Credentials | CredentialsProvider;
|
|
@@ -92,7 +139,7 @@ declare function r2Storage(opts: {
|
|
|
92
139
|
* });
|
|
93
140
|
* ```
|
|
94
141
|
*/
|
|
95
|
-
declare function minioStorage(opts: {
|
|
142
|
+
export declare function minioStorage(opts: {
|
|
96
143
|
endpoint: string;
|
|
97
144
|
bucket: string;
|
|
98
145
|
credentials: Credentials | CredentialsProvider;
|
|
@@ -125,13 +172,12 @@ declare function minioStorage(opts: {
|
|
|
125
172
|
* });
|
|
126
173
|
* ```
|
|
127
174
|
*/
|
|
128
|
-
declare function gcsStorage(opts: {
|
|
175
|
+
export declare function gcsStorage(opts: {
|
|
129
176
|
bucket: string;
|
|
130
|
-
credentials: Credentials | CredentialsProvider;
|
|
177
|
+
credentials: Credentials | CredentialsProvider;
|
|
178
|
+
/** GCS endpoint. Defaults to `https://storage.googleapis.com`. */
|
|
131
179
|
endpoint?: string;
|
|
132
180
|
}): Storage;
|
|
133
|
-
//#endregion
|
|
134
|
-
//#region packages/adapter-node/src/local-fs-storage.d.ts
|
|
135
181
|
interface LocalFsStorageFactoryOptions {
|
|
136
182
|
/**
|
|
137
183
|
* Root data directory. Resolution order: this option →
|
|
@@ -146,10 +192,12 @@ interface LocalFsStorageFactoryOptions {
|
|
|
146
192
|
* and lost on exit.
|
|
147
193
|
*
|
|
148
194
|
* NOT for multi-instance production: `LocalFsStorage`'s `ifMatch` CAS is
|
|
149
|
-
*
|
|
150
|
-
* atomic
|
|
151
|
-
*
|
|
152
|
-
*
|
|
195
|
+
* serialized within one process only, so a `current.json` CAS-advance is
|
|
196
|
+
* not atomic against a second process on the same directory (see its class
|
|
197
|
+
* JSDoc). Every call here returns a fresh instance, which is fine — the
|
|
198
|
+
* lock is keyed by resolved root, so instances sharing a directory share
|
|
199
|
+
* it. For horizontally-scaled deploys use `s3Storage` / `r2Storage`, whose
|
|
200
|
+
* cross-process guarantee the no-lease maintenance fold relies on.
|
|
153
201
|
*
|
|
154
202
|
* @example
|
|
155
203
|
* ```ts
|
|
@@ -160,9 +208,7 @@ interface LocalFsStorageFactoryOptions {
|
|
|
160
208
|
* await baerlyNode({ config, storage: localFsStorage() }).listen(8080);
|
|
161
209
|
* ```
|
|
162
210
|
*/
|
|
163
|
-
declare const localFsStorage: (opts?: LocalFsStorageFactoryOptions) => Storage;
|
|
164
|
-
//#endregion
|
|
165
|
-
//#region packages/adapter-node/src/resolve-storage.d.ts
|
|
211
|
+
export declare const localFsStorage: (opts?: LocalFsStorageFactoryOptions) => Storage;
|
|
166
212
|
/** Result of {@link resolveStorageFromEnv}. */
|
|
167
213
|
interface ResolvedStorage {
|
|
168
214
|
readonly storage: Storage;
|
|
@@ -201,9 +247,7 @@ interface ResolvedStorage {
|
|
|
201
247
|
* await baerlyNode({ config, storage }).listen(Number(process.env["PORT"] ?? 8080));
|
|
202
248
|
* ```
|
|
203
249
|
*/
|
|
204
|
-
declare const resolveStorageFromEnv: (env?: Record<string, string | undefined>) => ResolvedStorage;
|
|
205
|
-
//#endregion
|
|
206
|
-
//#region packages/adapter-node/src/assert-storage-reachable.d.ts
|
|
250
|
+
export declare const resolveStorageFromEnv: (env?: Record<string, string | undefined>) => ResolvedStorage;
|
|
207
251
|
/** Options for {@link assertStorageReachable}. */
|
|
208
252
|
interface AssertStorageReachableOptions {
|
|
209
253
|
/** Key prefix for the throwaway probe sentinels. Default `""`. */
|
|
@@ -242,9 +286,7 @@ interface AssertStorageReachableOptions {
|
|
|
242
286
|
* console.log(`[baerly] storage=${label} (reachable)`);
|
|
243
287
|
* ```
|
|
244
288
|
*/
|
|
245
|
-
declare const assertStorageReachable: (storage: Storage, opts?: AssertStorageReachableOptions) => Promise<void>;
|
|
246
|
-
//#endregion
|
|
247
|
-
//#region packages/adapter-node/src/credentials/from-eks.d.ts
|
|
289
|
+
export declare const assertStorageReachable: (storage: Storage, opts?: AssertStorageReachableOptions) => Promise<void>;
|
|
248
290
|
/**
|
|
249
291
|
* Resolve AWS credentials on EKS regardless of which identity mechanism the
|
|
250
292
|
* cluster uses, so callers don't have to know. EKS injects credentials one of
|
|
@@ -260,12 +302,10 @@ declare const assertStorageReachable: (storage: Storage, opts?: AssertStorageRea
|
|
|
260
302
|
* and re-checked on each refresh. Use this instead of the mechanism-specific
|
|
261
303
|
* providers unless you have a reason to pin one.
|
|
262
304
|
*/
|
|
263
|
-
declare function fromEks(opts?: {
|
|
305
|
+
export declare function fromEks(opts?: {
|
|
264
306
|
fetch?: typeof fetch;
|
|
265
307
|
readFile?: (path: string, encoding: "utf8") => Promise<string>;
|
|
266
308
|
}): CredentialsProvider;
|
|
267
|
-
//#endregion
|
|
268
|
-
//#region packages/adapter-node/src/credentials/from-eks-pod-identity.d.ts
|
|
269
309
|
/**
|
|
270
310
|
* Resolve AWS credentials from the EKS Pod Identity agent (the 2023
|
|
271
311
|
* successor to IRSA). The agent runs on each EKS node and exchanges
|
|
@@ -280,13 +320,16 @@ declare function fromEks(opts?: {
|
|
|
280
320
|
*
|
|
281
321
|
* Both are required. Agent should respond instantly on the node-local
|
|
282
322
|
* link — 2 s timeout protects against hangs.
|
|
323
|
+
*
|
|
324
|
+
* The URI must name the agent: loopback, or the ECS / EKS link-local
|
|
325
|
+
* addresses (the AWS SDK's container-credentials allow-list). Anything
|
|
326
|
+
* else throws `InvalidConfig` before the token file is read, so a
|
|
327
|
+
* misconfigured or injected env var never sends the token off-node.
|
|
283
328
|
*/
|
|
284
|
-
declare function fromEksPodIdentity(opts?: {
|
|
329
|
+
export declare function fromEksPodIdentity(opts?: {
|
|
285
330
|
fetch?: typeof fetch;
|
|
286
331
|
readFile?: (path: string, encoding: "utf8") => Promise<string>;
|
|
287
332
|
}): CredentialsProvider;
|
|
288
|
-
//#endregion
|
|
289
|
-
//#region packages/adapter-node/src/credentials/from-web-identity.d.ts
|
|
290
333
|
/**
|
|
291
334
|
* Resolve AWS credentials via IRSA (IAM Roles for Service Accounts) — the
|
|
292
335
|
* web-identity-token flow, distinct from the EKS Pod Identity agent that
|
|
@@ -305,12 +348,10 @@ declare function fromEksPodIdentity(opts?: {
|
|
|
305
348
|
* STS credentials expire (~1 h); the returned provider reports `expiration`, so
|
|
306
349
|
* the signing layer re-resolves before they lapse.
|
|
307
350
|
*/
|
|
308
|
-
declare function fromWebIdentity(opts?: {
|
|
351
|
+
export declare function fromWebIdentity(opts?: {
|
|
309
352
|
fetch?: typeof fetch;
|
|
310
353
|
readFile?: (path: string, encoding: "utf8") => Promise<string>;
|
|
311
354
|
}): CredentialsProvider;
|
|
312
|
-
//#endregion
|
|
313
|
-
//#region packages/adapter-node/src/baerly-node.d.ts
|
|
314
355
|
/**
|
|
315
356
|
* Options for {@link baerlyNode}. Composes the {@link createApp}
|
|
316
357
|
* surface (same `app` / `storage` / `verifier` / `webRoot` / etc.)
|
|
@@ -357,6 +398,14 @@ interface BaerlyNodeOptions {
|
|
|
357
398
|
readonly sinceTimeoutMs?: number;
|
|
358
399
|
readonly sincePollIntervalMs?: number;
|
|
359
400
|
}
|
|
401
|
+
/** Options for {@link BaerlyNodeHandle.listen}. */
|
|
402
|
+
interface BaerlyNodeListenOptions {
|
|
403
|
+
/**
|
|
404
|
+
* Address to bind, passed to Node's `server.listen(port, host)`.
|
|
405
|
+
* Omit to bind every interface.
|
|
406
|
+
*/
|
|
407
|
+
readonly hostname?: string;
|
|
408
|
+
}
|
|
360
409
|
/**
|
|
361
410
|
* Handle returned by {@link baerlyNode}. Composes a running
|
|
362
411
|
* `node:http` server lifecycle.
|
|
@@ -365,68 +414,46 @@ interface BaerlyNodeOptions {
|
|
|
365
414
|
* directly for in-process embedding (Vite middleware via
|
|
366
415
|
* `@hono/node-server.getRequestListener`, custom servers, tests).
|
|
367
416
|
* Calling `fetch` does not start the `node:http` server; the
|
|
368
|
-
* server lifecycle is owned by `listen(
|
|
417
|
+
* server lifecycle is owned by `listen()` / `close()`.
|
|
369
418
|
* Hono's optional `env`/`executionCtx` parameters are intentionally
|
|
370
419
|
* omitted from the signature — this is a Node-host handle, and
|
|
371
420
|
* those parameters are Workers-only.
|
|
372
|
-
* - `listen(port)` binds the server, installs
|
|
373
|
-
* handlers that call `close()` and exit `0`, and
|
|
374
|
-
* the server is actually listening (after Node's
|
|
375
|
-
* event fires). Throws on `'error'` from the server.
|
|
421
|
+
* - `listen(port, { hostname })` binds the server, installs
|
|
422
|
+
* SIGTERM/SIGINT handlers that call `close()` and exit `0`, and
|
|
423
|
+
* resolves once the server is actually listening (after Node's
|
|
424
|
+
* `'listening'` event fires). Throws on `'error'` from the server.
|
|
425
|
+
* Without `hostname` it binds every interface (Node's default:
|
|
426
|
+
* `::` dual-stack, or `0.0.0.0` without IPv6), which is what a
|
|
427
|
+
* container wants; pass `"127.0.0.1"` to accept loopback only.
|
|
376
428
|
* - `close()` closes the server and removes the signal handlers.
|
|
377
429
|
* Resolves once `Server.close` callback fires. Safe to call
|
|
378
|
-
* multiple times.
|
|
430
|
+
* multiple times; every call returns the same promise. A closed
|
|
431
|
+
* handle is final: `listen()` after `close()` rejects with
|
|
432
|
+
* `BaerlyError("InvalidConfig")`; create a new handle instead.
|
|
379
433
|
*/
|
|
380
434
|
interface BaerlyNodeHandle {
|
|
381
435
|
readonly fetch: (request: Request) => Response | Promise<Response>;
|
|
382
|
-
|
|
436
|
+
/**
|
|
437
|
+
* Bind the server on `port`, every interface unless `hostname` is set.
|
|
438
|
+
* Rejects with `BaerlyError("InvalidConfig")` once `close()` has been
|
|
439
|
+
* called.
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* ```ts
|
|
443
|
+
* // Loopback only, e.g. behind a reverse proxy on the same host.
|
|
444
|
+
* await handle.listen(8080, { hostname: "127.0.0.1" });
|
|
445
|
+
* ```
|
|
446
|
+
*/
|
|
447
|
+
listen(port: number, options?: BaerlyNodeListenOptions): Promise<void>;
|
|
448
|
+
/**
|
|
449
|
+
* Close the server and remove the signal handlers.
|
|
450
|
+
*
|
|
451
|
+
* If a `listen()` bind is still pending, `close()` waits for it to
|
|
452
|
+
* settle and then closes the resulting listener. That pending
|
|
453
|
+
* `listen()` resolves without installing signal handlers, or rejects
|
|
454
|
+
* with the bind error.
|
|
455
|
+
*/
|
|
383
456
|
close(): Promise<void>;
|
|
384
457
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
* from `@baerly/adapter-cloudflare`.
|
|
388
|
-
*
|
|
389
|
-
* Composes:
|
|
390
|
-
* - {@link createApp} → exposed as `handle.fetch` for in-process
|
|
391
|
-
* embedding; wrapped in `@hono/node-server.serve({ fetch, createServer })`
|
|
392
|
-
* lazily when `listen()` is called.
|
|
393
|
-
* - SIGTERM + SIGINT handlers installed on `listen()` that call
|
|
394
|
-
* `close()` and `process.exit(0)`. On any error during close,
|
|
395
|
-
* `process.exit(1)`.
|
|
396
|
-
*
|
|
397
|
-
* **Maintenance is in-band, not scheduled.** There is no `setInterval`,
|
|
398
|
-
* no cron, and no `maintenance:` option: the kernel maintains itself on
|
|
399
|
-
* a bare bucket with zero operator infrastructure. Compaction + GC run
|
|
400
|
-
* INLINE on the (rare) write that crosses a maintenance trigger —
|
|
401
|
-
* `createFetchHandler` threads a Node-tier `MaintenanceDispatch`
|
|
402
|
-
* onto the per-request observability context, which the writer reads at
|
|
403
|
-
* its post-commit dispatch point. Reads never tick. Tune via the
|
|
404
|
-
* `BAERLY_MAINTENANCE_MAX_FOLD_BYTES` / `BAERLY_MAINTENANCE_DISABLE`
|
|
405
|
-
* env vars; for an explicit out-of-band sweep, call
|
|
406
|
-
* `runScheduledMaintenance` from `@gusto/baerly-storage` directly.
|
|
407
|
-
*
|
|
408
|
-
* @example
|
|
409
|
-
* ```ts
|
|
410
|
-
* import { baerlyNode, s3Storage } from "@gusto/baerly-storage/node";
|
|
411
|
-
* import config from "./baerly.config.ts";
|
|
412
|
-
*
|
|
413
|
-
* const handle = baerlyNode({
|
|
414
|
-
* config,
|
|
415
|
-
* storage: s3Storage({
|
|
416
|
-
* region: "us-east-1",
|
|
417
|
-
* bucket: process.env["BUCKET"]!,
|
|
418
|
-
* credentials: {
|
|
419
|
-
* accessKeyId: process.env["AWS_ACCESS_KEY_ID"]!,
|
|
420
|
-
* secretAccessKey: process.env["AWS_SECRET_ACCESS_KEY"]!,
|
|
421
|
-
* },
|
|
422
|
-
* }),
|
|
423
|
-
* // No verifier needed when config.auth is "none" or "shared-secret".
|
|
424
|
-
* webRoot: "./dist/client",
|
|
425
|
-
* });
|
|
426
|
-
* await handle.listen(Number(process.env["PORT"] ?? 8080));
|
|
427
|
-
* ```
|
|
428
|
-
*/
|
|
429
|
-
declare function baerlyNode(opts: BaerlyNodeOptions): BaerlyNodeHandle;
|
|
430
|
-
//#endregion
|
|
431
|
-
export { type AssertStorageReachableOptions, type BaerlyNodeHandle, type BaerlyNodeOptions, type Credentials, type CredentialsProvider, DEFAULT_GCS_ENDPOINT, GcsHttpStorage, type GcsHttpStorageOptions, type GcsVersioningStatus, type LocalFsStorageFactoryOptions, type ResolvedStorage, S3HttpStorage, type S3HttpStorageOptions, assertStorageReachable, baerlyNode, fromEks, fromEksPodIdentity, fromWebIdentity, gcsStorage, gcsVersioningStatus, localFsStorage, minioStorage, r2Storage, resolveStorageFromEnv, s3Storage };
|
|
432
|
-
//# sourceMappingURL=node.d.ts.map
|
|
458
|
+
export declare function baerlyNode(opts: BaerlyNodeOptions): BaerlyNodeHandle;
|
|
459
|
+
export { type AssertStorageReachableOptions, type BaerlyNodeHandle, type BaerlyNodeListenOptions, type BaerlyNodeOptions, type Credentials, type CredentialsProvider, DEFAULT_GCS_ENDPOINT, GcsHttpStorage, type GcsHttpStorageOptions, type GcsVersioningStatus, type LocalFsStorageFactoryOptions, type ResolvedStorage, S3HttpStorage, type S3HttpStorageOptions, gcsVersioningStatus };
|
package/dist/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as fromEksPodIdentity, c as localFsStorage, d as r2Storage, f as s3Storage, i as fromWebIdentity, l as gcsStorage, o as assertStorageReachable, p as gcsVersioningStatus, r as fromEks, s as resolveStorageFromEnv, t as baerlyNode, u as minioStorage } from "./src-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { a as fromEksPodIdentity, c as localFsStorage, d as r2Storage, f as s3Storage, i as fromWebIdentity, l as gcsStorage, o as assertStorageReachable, p as gcsVersioningStatus, r as fromEks, s as resolveStorageFromEnv, t as baerlyNode, u as minioStorage } from "./src-Actga-bO.js";
|
|
2
|
+
import { r as S3HttpStorage } from "./sigv4-sign-5IUflUD_.js";
|
|
3
|
+
import { i as GcsHttpStorage, r as DEFAULT_GCS_ENDPOINT } from "./goog4-signer-CeLIABoE.js";
|
|
4
4
|
export { DEFAULT_GCS_ENDPOINT, GcsHttpStorage, S3HttpStorage, assertStorageReachable, baerlyNode, fromEks, fromEksPodIdentity, fromWebIdentity, gcsStorage, gcsVersioningStatus, localFsStorage, minioStorage, r2Storage, resolveStorageFromEnv, s3Storage };
|