@gusto/baerly-storage 0.5.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 -511
- package/dist/CHANGELOG.md +1148 -307
- 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-Fe8CwB73.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-DzKBrUlg.js → cloudflare-CKHYXccw.js} +504 -124
- 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-DonTr-CV.js → deploy-Obj4nE-Z.js} +12 -16
- 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 +38 -39
- package/dist/dev-vite.js +67 -36
- 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-Dso1HWQj.d.ts +127 -0
- package/dist/gcs.d.ts +30 -0
- package/dist/gcs.js +1 -0
- package/dist/goog4-signer-CeLIABoE.js +331 -0
- package/dist/goog4-signer-CeLIABoE.js.map +1 -0
- package/dist/{http-DGd5tbNs.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-CuA9Mi3K.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 +130 -142
- package/dist/node.js +4 -3
- package/dist/{observability-BmflLCdF.js → observability-C-ISCCLE.js} +1275 -332
- 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-a7PJHBCy.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-Dsw2-n8S.js → runtime-spec-B5mg3pHF.js} +189 -28
- package/dist/runtime-spec-B5mg3pHF.js.map +1 -0
- package/dist/{s3-http-B-z8th6O.d.ts → s3-http-DBC_wiCL.d.ts} +18 -10
- package/dist/s3.d.ts +20 -7
- package/dist/s3.js +4 -5
- package/dist/s3.js.map +1 -1
- package/dist/sha256-4FfGQNPw.js +22 -0
- 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/sigv4-sign-5IUflUD_.js +507 -0
- 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-BL_JoPTn.js → src-Actga-bO.js} +1004 -378
- 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-DoDA-K7d.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-DBV1eQHC.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 +96 -69
- package/dist/aws4fetch.esm-p7eEzLCs.js +0 -1702
- package/dist/aws4fetch.esm-p7eEzLCs.js.map +0 -1
- package/dist/bytes-BXdamO3L.js +0 -11
- package/dist/bytes-BXdamO3L.js.map +0 -1
- package/dist/cloudflare-DzKBrUlg.js.map +0 -1
- package/dist/config-1tv0-Yzm.js +0 -2693
- package/dist/config-1tv0-Yzm.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-DSMIVqzL.js +0 -203
- package/dist/cost-DSMIVqzL.js.map +0 -1
- package/dist/current-json-C6nhPOm1.js.map +0 -1
- package/dist/db-DsPkOVEH.d.ts +0 -254
- package/dist/deploy-DonTr-CV.js.map +0 -1
- package/dist/doctor-DSIyCDg_.js +0 -346
- package/dist/doctor-DSIyCDg_.js.map +0 -1
- package/dist/dump-Bh5k26VQ.js +0 -94
- package/dist/dump-Bh5k26VQ.js.map +0 -1
- package/dist/errors-Dfa3p78c.js +0 -78
- package/dist/errors-Dfa3p78c.js.map +0 -1
- package/dist/export-DtF5tDIM.js +0 -401
- package/dist/export-DtF5tDIM.js.map +0 -1
- package/dist/fsck-D_djMO5D.js +0 -279
- package/dist/fsck-D_djMO5D.js.map +0 -1
- package/dist/http-DGd5tbNs.js.map +0 -1
- package/dist/index-0rZcMBwy.d.ts +0 -115
- package/dist/index-BNRh23K9.d.ts +0 -162
- package/dist/index-BYk9oCNf.d.ts +0 -1112
- package/dist/indexes-Dn9hbGQG.d.ts +0 -22
- package/dist/inspect-6WZ-pC7-.js +0 -133
- package/dist/inspect-6WZ-pC7-.js.map +0 -1
- package/dist/log-tail-D98U1JBo.js +0 -522
- package/dist/log-tail-D98U1JBo.js.map +0 -1
- package/dist/maintenance-B4Dki6Ig.js +0 -2157
- package/dist/maintenance-B4Dki6Ig.js.map +0 -1
- package/dist/maintenance-B_e0T99L.d.ts +0 -537
- package/dist/maintenance-C7coQp4c.js +0 -1418
- package/dist/maintenance-C7coQp4c.js.map +0 -1
- package/dist/normalize-rjnZLwS4.js +0 -133
- package/dist/normalize-rjnZLwS4.js.map +0 -1
- package/dist/observability-BmflLCdF.js.map +0 -1
- package/dist/plan-a7PJHBCy.js.map +0 -1
- package/dist/query-rAtXNQQB.js +0 -1773
- package/dist/query-rAtXNQQB.js.map +0 -1
- package/dist/rebuild-index-BVzQSZlm.js +0 -81
- package/dist/rebuild-index-BVzQSZlm.js.map +0 -1
- package/dist/request-u0M51mhJ.js +0 -72
- package/dist/request-u0M51mhJ.js.map +0 -1
- package/dist/restore-R-4rbciV.js +0 -778
- package/dist/restore-R-4rbciV.js.map +0 -1
- package/dist/rolldown-runtime-EAsCxrDo.js +0 -14
- package/dist/runtime-spec-Dsw2-n8S.js.map +0 -1
- package/dist/shared-secret-DgEicd3x.js.map +0 -1
- package/dist/src-BL_JoPTn.js.map +0 -1
- package/dist/src-CYHFDrKz.js +0 -536
- package/dist/src-CYHFDrKz.js.map +0 -1
- package/dist/src-DYZ4H1aF.js +0 -392
- package/dist/src-DYZ4H1aF.js.map +0 -1
- package/dist/subcommand-DoDA-K7d.js.map +0 -1
- package/dist/time-DUqvFMHq.js.map +0 -1
- package/dist/usage-DBV1eQHC.js.map +0 -1
- package/dist/validate-DtljsCh1.js.map +0 -1
- package/dist/wire-izfGZDvr.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { i as errorToExitCode, l as defineCommand, n as emitError, o as setJsonMode, r as emitSuccess, s as BaerlyError } from "./baerly.js";
|
|
2
|
+
import { t as loadAppConfig } from "./config-DEzInG6M.js";
|
|
3
|
+
import { t as deployCloudflare } from "./cloudflare-CKHYXccw.js";
|
|
4
|
+
// src/deploy.ts
|
|
5
5
|
/**
|
|
6
6
|
* `baerly deploy` — citty dispatcher.
|
|
7
7
|
*
|
|
@@ -16,8 +16,9 @@ import { a as setJsonMode, n as emitError, o as BaerlyError, r as emitSuccess, s
|
|
|
16
16
|
* - 1 user error (InvalidConfig, missing config, unknown target).
|
|
17
17
|
* - 2 storage / external error (NetworkError, Wrangler returned
|
|
18
18
|
* non-zero, anything non-BaerlyError).
|
|
19
|
-
* - 3 protocol invariant (
|
|
20
|
-
* should not happen here unless someone
|
|
19
|
+
* - 3 protocol invariant / conflict (WriteConflict, AlreadyExists,
|
|
20
|
+
* Internal, InvalidResponse, AmbiguousCommit — should not happen here unless someone
|
|
21
|
+
* hand-edited mid-flight).
|
|
21
22
|
*/
|
|
22
23
|
const DEPLOY_ARGS = {
|
|
23
24
|
target: {
|
|
@@ -31,8 +32,8 @@ const DEPLOY_ARGS = {
|
|
|
31
32
|
},
|
|
32
33
|
probeBucket: {
|
|
33
34
|
type: "string",
|
|
34
|
-
description: "Run a live CAS preflight against this bucket URI before deploying (s3://, file:///, memory://); aborts non-zero if the backend fails the conditional-write / exactly-one-winner probe. Same check as `baerly doctor --bucket
|
|
35
|
-
valueHint: "s3://bucket/prefix"
|
|
35
|
+
description: "Run a live CAS preflight against this bucket URI before deploying (s3://, gcs://, file:///, memory://); aborts non-zero if the backend fails the conditional-write / exactly-one-winner probe. Same CAS check as `baerly doctor --bucket` (doctor additionally runs GCS cost advisories).",
|
|
36
|
+
valueHint: "s3://bucket/prefix | gcs://bucket"
|
|
36
37
|
}
|
|
37
38
|
};
|
|
38
39
|
const KNOWN_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -42,11 +43,6 @@ const KNOWN_KEYS = /* @__PURE__ */ new Set([
|
|
|
42
43
|
"probe-bucket",
|
|
43
44
|
"_"
|
|
44
45
|
]);
|
|
45
|
-
const errorToExitCode = (code) => {
|
|
46
|
-
if (code === "InvalidConfig") return 1;
|
|
47
|
-
if (code === "Conflict" || code === "Internal" || code === "InvalidResponse") return 3;
|
|
48
|
-
return 2;
|
|
49
|
-
};
|
|
50
46
|
const handleDeploy = async (args) => {
|
|
51
47
|
setJsonMode(args.json === true);
|
|
52
48
|
try {
|
|
@@ -54,7 +50,8 @@ const handleDeploy = async (args) => {
|
|
|
54
50
|
const config = await loadAppConfig();
|
|
55
51
|
const target = args.target ?? config.target;
|
|
56
52
|
if (target === "cloudflare") {
|
|
57
|
-
const
|
|
53
|
+
const probeBucketUri = typeof args.probeBucket === "string" && args.probeBucket.length > 0 ? args.probeBucket : void 0;
|
|
54
|
+
const exit = await deployCloudflare(config, { probeBucketUri });
|
|
58
55
|
if (exit === 0) emitSuccess({
|
|
59
56
|
command: "deploy",
|
|
60
57
|
status: "ok",
|
|
@@ -84,7 +81,6 @@ const deploy = defineCommand({
|
|
|
84
81
|
if (code !== 0) process.exit(code);
|
|
85
82
|
}
|
|
86
83
|
});
|
|
87
|
-
//#endregion
|
|
88
84
|
export { deploy };
|
|
89
85
|
|
|
90
|
-
//# sourceMappingURL=deploy-
|
|
86
|
+
//# sourceMappingURL=deploy-Obj4nE-Z.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy-Obj4nE-Z.js","names":[],"sources":["../packages/cli/src/deploy.ts"],"sourcesContent":["/**\n * `baerly deploy` — citty dispatcher.\n *\n * Reads `baerly.config.ts:target` and routes to the matching\n * deploy backend. Today: `cloudflare` only — the `node` example\n * embodies its deployment shape directly (self-host via `node\n * server.js` after your PaaS or container build), so `baerly\n * deploy` rejects `target: \"node\"` with an actionable InvalidConfig.\n *\n * Exit-code contract (standard CLI shape):\n * - 0 success.\n * - 1 user error (InvalidConfig, missing config, unknown target).\n * - 2 storage / external error (NetworkError, Wrangler returned\n * non-zero, anything non-BaerlyError).\n * - 3 protocol invariant / conflict (WriteConflict, AlreadyExists,\n * Internal, InvalidResponse, AmbiguousCommit — should not happen here unless someone\n * hand-edited mid-flight).\n */\n\nimport { defineCommand, type ArgsDef, type ParsedArgs } from \"citty\";\nimport { BaerlyError } from \"@baerly/protocol\";\nimport { loadAppConfig } from \"./config.ts\";\nimport { deployCloudflare } from \"./deploy/cloudflare.ts\";\nimport { emitError, emitSuccess, setJsonMode, errorToExitCode } from \"./output.ts\";\n\nconst DEPLOY_ARGS = {\n target: {\n type: \"string\",\n description:\n 'Override `baerly.config.ts:target`. Only \"cloudflare\" supported (\"node\" self-deploys via your PaaS or container build).',\n valueHint: \"cloudflare\",\n },\n json: {\n type: \"boolean\",\n description: \"Emit a structured JSON envelope to stdout (success) or stderr (error)\",\n },\n probeBucket: {\n type: \"string\",\n description:\n \"Run a live CAS preflight against this bucket URI before deploying (s3://, gcs://, file:///, memory://); aborts non-zero if the backend fails the conditional-write / exactly-one-winner probe. Same CAS check as `baerly doctor --bucket` (doctor additionally runs GCS cost advisories).\",\n valueHint: \"s3://bucket/prefix | gcs://bucket\",\n },\n} as const satisfies ArgsDef;\n\nconst KNOWN_KEYS: ReadonlySet<string> = new Set([\n \"target\",\n \"json\",\n \"probeBucket\",\n \"probe-bucket\",\n \"_\",\n]);\n\nconst handleDeploy = async (args: ParsedArgs<typeof DEPLOY_ARGS>): Promise<number> => {\n setJsonMode(args.json === true);\n try {\n for (const k of Object.keys(args)) {\n if (!KNOWN_KEYS.has(k)) {\n throw new BaerlyError(\"InvalidConfig\", `baerly deploy: unknown flag --${k}`);\n }\n }\n const config = await loadAppConfig();\n const target = args.target ?? config.target;\n if (target === \"cloudflare\") {\n const probeBucketUri =\n typeof args.probeBucket === \"string\" && args.probeBucket.length > 0\n ? args.probeBucket\n : undefined;\n const exit = await deployCloudflare(config, { probeBucketUri });\n if (exit === 0) {\n emitSuccess({ command: \"deploy\", status: \"ok\", target });\n }\n return exit;\n }\n throw new BaerlyError(\n \"InvalidConfig\",\n `baerly deploy: target ${JSON.stringify(target)} has no deploy backend. ` +\n `Self-host: \\`node server.js\\` after your PaaS or container build. ` +\n `Cloudflare Workers is the only managed deploy backend today.`,\n );\n } catch (error) {\n if (error instanceof BaerlyError) {\n emitError(\"deploy\", error.code, error.message);\n return errorToExitCode(error.code);\n }\n emitError(\"deploy\", \"Unknown\", (error as Error).message);\n return 2;\n }\n};\n\n/** citty `defineCommand` block for `baerly deploy`. */\nexport const deploy = defineCommand({\n meta: {\n name: \"deploy\",\n description: \"Deploy this baerly app. Dispatches by baerly.config.ts:target.\",\n },\n args: DEPLOY_ARGS,\n run: async ({ args }) => {\n const code = await handleDeploy(args);\n if (code !== 0) {\n process.exit(code);\n }\n },\n});\n\n/**\n * Programmatic entry used by tests. Bypasses citty's `run` wrapper\n * (which would call `process.exit` and kill vitest) and returns the\n * integer exit code directly.\n */\nexport const runDeploy = async (argv: readonly string[]): Promise<number> => {\n const { parseArgs } = await import(\"citty\");\n let parsed: ParsedArgs<typeof DEPLOY_ARGS>;\n try {\n parsed = parseArgs<typeof DEPLOY_ARGS>(argv as string[], DEPLOY_ARGS);\n } catch (error) {\n setJsonMode(argv.includes(\"--json\"));\n emitError(\"deploy\", \"InvalidConfig\", (error as Error).message);\n return 1;\n }\n return handleDeploy(parsed);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,cAAc;CAClB,QAAQ;EACN,MAAM;EACN,aACE;EACF,WAAW;CACb;CACA,MAAM;EACJ,MAAM;EACN,aAAa;CACf;CACA,aAAa;EACX,MAAM;EACN,aACE;EACF,WAAW;CACb;AACF;AAEA,MAAM,6BAAkC,IAAI,IAAI;CAC9C;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,eAAe,OAAO,SAA0D;CACpF,YAAY,KAAK,SAAS,IAAI;CAC9B,IAAI;EACF,KAAK,MAAM,KAAK,OAAO,KAAK,IAAI,GAC9B,IAAI,CAAC,WAAW,IAAI,CAAC,GACnB,MAAM,IAAI,YAAY,iBAAiB,iCAAiC,GAAG;EAG/E,MAAM,SAAS,MAAM,cAAc;EACnC,MAAM,SAAS,KAAK,UAAU,OAAO;EACrC,IAAI,WAAW,cAAc;GAC3B,MAAM,iBACJ,OAAO,KAAK,gBAAgB,YAAY,KAAK,YAAY,SAAS,IAC9D,KAAK,cACL,KAAA;GACN,MAAM,OAAO,MAAM,iBAAiB,QAAQ,EAAE,eAAe,CAAC;GAC9D,IAAI,SAAS,GACX,YAAY;IAAE,SAAS;IAAU,QAAQ;IAAM;GAAO,CAAC;GAEzD,OAAO;EACT;EACA,MAAM,IAAI,YACR,iBACA,yBAAyB,KAAK,UAAU,MAAM,EAAE,uJAGlD;CACF,SAAS,OAAO;EACd,IAAI,iBAAiB,aAAa;GAChC,UAAU,UAAU,MAAM,MAAM,MAAM,OAAO;GAC7C,OAAO,gBAAgB,MAAM,IAAI;EACnC;EACA,UAAU,UAAU,WAAY,MAAgB,OAAO;EACvD,OAAO;CACT;AACF;;AAGA,MAAa,SAAS,cAAc;CAClC,MAAM;EACJ,MAAM;EACN,aAAa;CACf;CACA,MAAM;CACN,KAAK,OAAO,EAAE,WAAW;EACvB,MAAM,OAAO,MAAM,aAAa,IAAI;EACpC,IAAI,SAAS,GACX,QAAQ,KAAK,IAAI;CAErB;AACF,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region packages/dev/src/dev-banner.d.ts
|
|
2
1
|
interface DevBannerHint {
|
|
3
2
|
readonly key: string;
|
|
4
3
|
readonly value: string;
|
|
@@ -21,6 +20,4 @@ interface DevBannerOpts {
|
|
|
21
20
|
readonly write?: (chunk: string) => void;
|
|
22
21
|
}
|
|
23
22
|
declare function printDevBanner(opts: DevBannerOpts): void;
|
|
24
|
-
|
|
25
|
-
export { DevBannerOpts as n, printDevBanner as r, DevBannerHint as t };
|
|
26
|
-
//# sourceMappingURL=dev-banner-CWHIk8tH.d.ts.map
|
|
23
|
+
export { DevBannerOpts as n, printDevBanner as r, DevBannerHint as t };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev landing page for the API root (`GET /`).
|
|
3
|
+
*
|
|
4
|
+
* The HTTP surface is API-only: every path outside `/v1/*`
|
|
5
|
+
* returns the {@link HttpErrorEnvelope} 404 shape. That's correct for
|
|
6
|
+
* production but confusing in local dev — a user who clicks the
|
|
7
|
+
* `http://localhost:3000` link in their terminal sees a JSON 404 and
|
|
8
|
+
* assumes the server is broken.
|
|
9
|
+
*
|
|
10
|
+
* Adapters that wire the {@link DevLandingOptions} opt-in surface a
|
|
11
|
+
* small HTML page on `GET /` instead: app label, a clickable link to
|
|
12
|
+
* the UI, a `/v1/healthz` probe link, and a note that `/v1/c/*` is
|
|
13
|
+
* auth-gated. `GET /favicon.ico` answers 204 so browsers don't pin a
|
|
14
|
+
* second JSON 404 next to the landing page.
|
|
15
|
+
*
|
|
16
|
+
* Production deployments leave the option unset; the 404 falls
|
|
17
|
+
* through to the existing envelope.
|
|
18
|
+
*/
|
|
19
|
+
/** Options for {@link renderDevLanding}. */
|
|
20
|
+
interface DevLandingOptions {
|
|
21
|
+
/** Bucket-prefix / app name (typically passed through from the adapter's `app` option). */
|
|
22
|
+
readonly app: string;
|
|
23
|
+
/** URL of the human-facing UI (e.g., `"http://localhost:5173"`). */
|
|
24
|
+
readonly uiUrl: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Render the dev landing page HTML. Dependency-free; system fonts
|
|
28
|
+
* only; no JS. All substitutions are HTML-escaped to keep the page
|
|
29
|
+
* inert even when `app` / `uiUrl` come from env vars.
|
|
30
|
+
*/
|
|
31
|
+
declare const renderDevLanding: (opts: DevLandingOptions) => string;
|
|
32
|
+
export { renderDevLanding as n, DevLandingOptions as t };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// packages/dev/src/dev-landing.ts
|
|
2
|
+
/**
|
|
3
|
+
* Render the dev landing page HTML. Dependency-free; system fonts
|
|
4
|
+
* only; no JS. All substitutions are HTML-escaped to keep the page
|
|
5
|
+
* inert even when `app` / `uiUrl` come from env vars.
|
|
6
|
+
*/
|
|
7
|
+
const renderDevLanding = (opts) => {
|
|
8
|
+
const label = escapeHtml(opts.app);
|
|
9
|
+
const app = escapeHtml(opts.app);
|
|
10
|
+
const uiUrl = escapeHtml(opts.uiUrl);
|
|
11
|
+
return `<!doctype html>
|
|
12
|
+
<html lang="en">
|
|
13
|
+
<head>
|
|
14
|
+
<meta charset="utf-8">
|
|
15
|
+
<title>${label} — baerly api</title>
|
|
16
|
+
<style>
|
|
17
|
+
body { font-family: ui-sans-serif, system-ui, -apple-system, sans-serif; max-width: 40rem; margin: 3rem auto; padding: 0 1.5rem; color: #222; line-height: 1.5; }
|
|
18
|
+
h1 { font-size: 1.25rem; margin: 0 0 0.25rem; }
|
|
19
|
+
p.tag { color: #666; margin: 0 0 1.5rem; font-size: 0.9rem; }
|
|
20
|
+
a { color: #06c; }
|
|
21
|
+
ul { padding-left: 1.25rem; }
|
|
22
|
+
li { margin: 0.25rem 0; }
|
|
23
|
+
code { background: #f3f3f3; padding: 0.1em 0.35em; border-radius: 3px; font-size: 0.9em; }
|
|
24
|
+
</style>
|
|
25
|
+
</head>
|
|
26
|
+
<body>
|
|
27
|
+
<h1>${label}</h1>
|
|
28
|
+
<p class="tag">baerly api server · app <code>${app}</code></p>
|
|
29
|
+
<p>This is the API server. The UI lives at <a href="${uiUrl}">${uiUrl}</a>.</p>
|
|
30
|
+
<ul>
|
|
31
|
+
<li>Open the UI: <a href="${uiUrl}">${uiUrl}</a></li>
|
|
32
|
+
<li>Health probe: <a href="/v1/healthz">/v1/healthz</a></li>
|
|
33
|
+
<li>CRUD routes under <code>/v1/c/*</code> require an auth header and aren't clickable from here.</li>
|
|
34
|
+
</ul>
|
|
35
|
+
</body>
|
|
36
|
+
</html>
|
|
37
|
+
`;
|
|
38
|
+
};
|
|
39
|
+
const escapeHtml = (s) => s.replace(/[&<>"']/g, (c) => {
|
|
40
|
+
switch (c) {
|
|
41
|
+
case "&": return "&";
|
|
42
|
+
case "<": return "<";
|
|
43
|
+
case ">": return ">";
|
|
44
|
+
case "\"": return """;
|
|
45
|
+
default: return "'";
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
export { renderDevLanding as t };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=dev-landing-CD-si4dW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-landing-CD-si4dW.js","names":[],"sources":["../packages/dev/src/dev-landing.ts"],"sourcesContent":["/**\n * Dev landing page for the API root (`GET /`).\n *\n * The HTTP surface is API-only: every path outside `/v1/*`\n * returns the {@link HttpErrorEnvelope} 404 shape. That's correct for\n * production but confusing in local dev — a user who clicks the\n * `http://localhost:3000` link in their terminal sees a JSON 404 and\n * assumes the server is broken.\n *\n * Adapters that wire the {@link DevLandingOptions} opt-in surface a\n * small HTML page on `GET /` instead: app label, a clickable link to\n * the UI, a `/v1/healthz` probe link, and a note that `/v1/c/*` is\n * auth-gated. `GET /favicon.ico` answers 204 so browsers don't pin a\n * second JSON 404 next to the landing page.\n *\n * Production deployments leave the option unset; the 404 falls\n * through to the existing envelope.\n */\n\n/** Options for {@link renderDevLanding}. */\nexport interface DevLandingOptions {\n /** Bucket-prefix / app name (typically passed through from the adapter's `app` option). */\n readonly app: string;\n /** URL of the human-facing UI (e.g., `\"http://localhost:5173\"`). */\n readonly uiUrl: string;\n}\n\n/**\n * Render the dev landing page HTML. Dependency-free; system fonts\n * only; no JS. All substitutions are HTML-escaped to keep the page\n * inert even when `app` / `uiUrl` come from env vars.\n */\nexport const renderDevLanding = (opts: DevLandingOptions): string => {\n const label = escapeHtml(opts.app);\n const app = escapeHtml(opts.app);\n const uiUrl = escapeHtml(opts.uiUrl);\n return `<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>${label} — baerly api</title>\n<style>\n body { font-family: ui-sans-serif, system-ui, -apple-system, sans-serif; max-width: 40rem; margin: 3rem auto; padding: 0 1.5rem; color: #222; line-height: 1.5; }\n h1 { font-size: 1.25rem; margin: 0 0 0.25rem; }\n p.tag { color: #666; margin: 0 0 1.5rem; font-size: 0.9rem; }\n a { color: #06c; }\n ul { padding-left: 1.25rem; }\n li { margin: 0.25rem 0; }\n code { background: #f3f3f3; padding: 0.1em 0.35em; border-radius: 3px; font-size: 0.9em; }\n</style>\n</head>\n<body>\n<h1>${label}</h1>\n<p class=\"tag\">baerly api server · app <code>${app}</code></p>\n<p>This is the API server. The UI lives at <a href=\"${uiUrl}\">${uiUrl}</a>.</p>\n<ul>\n <li>Open the UI: <a href=\"${uiUrl}\">${uiUrl}</a></li>\n <li>Health probe: <a href=\"/v1/healthz\">/v1/healthz</a></li>\n <li>CRUD routes under <code>/v1/c/*</code> require an auth header and aren't clickable from here.</li>\n</ul>\n</body>\n</html>\n`;\n};\n\nconst escapeHtml = (s: string): string =>\n s.replace(/[&<>\"']/g, (c) => {\n switch (c) {\n case \"&\": {\n return \"&\";\n }\n case \"<\": {\n return \"<\";\n }\n case \">\": {\n return \">\";\n }\n case '\"': {\n return \""\";\n }\n default: {\n return \"'\";\n }\n }\n });\n"],"mappings":";;;;;;AAgCA,MAAa,oBAAoB,SAAoC;CACnE,MAAM,QAAQ,WAAW,KAAK,GAAG;CACjC,MAAM,MAAM,WAAW,KAAK,GAAG;CAC/B,MAAM,QAAQ,WAAW,KAAK,KAAK;CACnC,OAAO;;;;SAIA,MAAM;;;;;;;;;;;;MAYT,MAAM;+CACmC,IAAI;sDACG,MAAM,IAAI,MAAM;;8BAExC,MAAM,IAAI,MAAM;;;;;;;AAO9C;AAEA,MAAM,cAAc,MAClB,EAAE,QAAQ,aAAa,MAAM;CAC3B,QAAQ,GAAR;EACE,KAAK,KACH,OAAO;EAET,KAAK,KACH,OAAO;EAET,KAAK,KACH,OAAO;EAET,KAAK,MACH,OAAO;EAET,SACE,OAAO;CAEX;AACF,CAAC"}
|
package/dist/dev-vite.d.ts
CHANGED
|
@@ -1,18 +1,37 @@
|
|
|
1
|
-
import { n as BaerlyAppConfig } from "./app-config-
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import { t as
|
|
1
|
+
import { n as BaerlyAppConfig } from "./app-config-C6qW7m8S.js";
|
|
2
|
+
import { t as Verifier } from "./verifier-Bmlmndzo.js";
|
|
3
|
+
import { t as Db } from "./db-plFUNTSF.js";
|
|
4
|
+
import { t as DevBannerHint } from "./dev-banner-B5AUHmu1.js";
|
|
5
5
|
import { Plugin } from "vite";
|
|
6
|
-
|
|
7
|
-
//#region packages/dev/src/vite-plugin.d.ts
|
|
8
|
-
interface BaerlyDevOptions {
|
|
6
|
+
export interface BaerlyDevOptions {
|
|
9
7
|
/**
|
|
10
8
|
* The project's `baerly.config.ts`. `app`, `tenant`, `auth`, and the
|
|
11
9
|
* table set (`Object.keys(config.collections)`) are derived from it.
|
|
12
10
|
* Per-collection schemas/indexes flow through to the in-process
|
|
13
11
|
* listener the same way `baerlyNode` / `baerlyWorker` pipe them.
|
|
12
|
+
*
|
|
13
|
+
* **Optional.** If omitted, the config is loaded at dev-server startup
|
|
14
|
+
* from `configPath`, or — if that's also omitted — by convention from
|
|
15
|
+
* `<viteRoot>/src/baerly.config.ts`.
|
|
16
|
+
*
|
|
17
|
+
* Prefer omitting it (convention or `configPath`). Passing the object
|
|
18
|
+
* means the caller's `vite.config` must `import` the config module,
|
|
19
|
+
* which forces Nx's `@nx/vite` / `@nx/vitest` inference plugins to
|
|
20
|
+
* bundle that module — and its transitive imports — while creating the
|
|
21
|
+
* project graph. That pulls unresolved imports into the config bundle
|
|
22
|
+
* and forces the app into the root `nx.json` inference-exclusion lists.
|
|
23
|
+
* Letting `baerlyDev` load the config itself (below) keeps the caller's
|
|
24
|
+
* `vite.config` import-free, the same way `reactRouter()` loads
|
|
25
|
+
* `react-router.config.ts` by convention.
|
|
14
26
|
*/
|
|
15
|
-
readonly config
|
|
27
|
+
readonly config?: BaerlyAppConfig;
|
|
28
|
+
/**
|
|
29
|
+
* Absolute path to the `baerly.config` module (its default export is
|
|
30
|
+
* the `BaerlyAppConfig`). Loaded lazily via Vite's `ssrLoadModule` at
|
|
31
|
+
* dev-server startup. Overrides the `<viteRoot>/src/baerly.config.ts`
|
|
32
|
+
* convention. Ignored when `config` is provided.
|
|
33
|
+
*/
|
|
34
|
+
readonly configPath?: string;
|
|
16
35
|
/**
|
|
17
36
|
* Shared-secret token. **Optional.** Required only when
|
|
18
37
|
* `config.auth === "shared-secret"` and `verifier` is unset — in
|
|
@@ -24,9 +43,13 @@ interface BaerlyDevOptions {
|
|
|
24
43
|
* when `verifier` is supplied (the operator owns the auth seam).
|
|
25
44
|
*
|
|
26
45
|
* Throwing the symmetric `InvalidConfig` on a misconfig matches
|
|
27
|
-
* production behaviour: forgetting `SHARED_SECRET` in dev
|
|
28
|
-
*
|
|
29
|
-
*
|
|
46
|
+
* production behaviour: forgetting `SHARED_SECRET` in dev throws
|
|
47
|
+
* with the same locked wording the adapter would emit. With an
|
|
48
|
+
* explicit `config` object this fails fast at `vite dev` startup
|
|
49
|
+
* (factory-time resolution); when the config is loaded lazily
|
|
50
|
+
* (`configPath` / convention) the throw is deferred to dev-server
|
|
51
|
+
* startup and surfaces as a per-request 503 rather than aborting
|
|
52
|
+
* the Vite process.
|
|
30
53
|
*/
|
|
31
54
|
readonly secret?: string;
|
|
32
55
|
/**
|
|
@@ -49,7 +72,7 @@ interface BaerlyDevOptions {
|
|
|
49
72
|
/** Set to false to suppress the dev banner. Default: true. */
|
|
50
73
|
readonly banner?: boolean;
|
|
51
74
|
}
|
|
52
|
-
interface BaerlyDevAuthOptions {
|
|
75
|
+
export interface BaerlyDevAuthOptions {
|
|
53
76
|
/** Bearer token to inject on matched paths. */
|
|
54
77
|
readonly secret: string;
|
|
55
78
|
/**
|
|
@@ -105,7 +128,7 @@ interface BaerlyDevAuthOptions {
|
|
|
105
128
|
* });
|
|
106
129
|
* ```
|
|
107
130
|
*/
|
|
108
|
-
declare function baerlyDevAuth(opts: BaerlyDevAuthOptions): Plugin;
|
|
131
|
+
export declare function baerlyDevAuth(opts: BaerlyDevAuthOptions): Plugin;
|
|
109
132
|
/**
|
|
110
133
|
* Parse a `.dev.vars` / `.env` file and return the values for the
|
|
111
134
|
* requested `keys`. Supports `KEY=value`, `# comments`, blank lines,
|
|
@@ -122,29 +145,5 @@ declare function baerlyDevAuth(opts: BaerlyDevAuthOptions): Plugin;
|
|
|
122
145
|
* // ^? string | undefined
|
|
123
146
|
* ```
|
|
124
147
|
*/
|
|
125
|
-
declare function loadDevVars<K extends string>(path: string, ...keys: readonly K[]): Record<K, string | undefined>;
|
|
126
|
-
|
|
127
|
-
* Resolution order for the in-process verifier (mirrors
|
|
128
|
-
* `baerlyNode` / `baerlyWorker`):
|
|
129
|
-
*
|
|
130
|
-
* 1. `opts.verifier` set → use as-is.
|
|
131
|
-
* 2. else `opts.config.auth === "shared-secret"` → require
|
|
132
|
-
* `opts.secret`; build `sharedSecret({ secret, tenantPrefix:
|
|
133
|
-
* config.tenant })`. Throws `BaerlyError("InvalidConfig", ...)`
|
|
134
|
-
* at Vite startup when `opts.secret` is empty/unset — same
|
|
135
|
-
* locked wording the production adapter would emit.
|
|
136
|
-
* 3. else `opts.config.auth === "none"` → pin every request to
|
|
137
|
-
* `config.tenant`; no header check.
|
|
138
|
-
*
|
|
139
|
-
* Bearer injection on `/v1/*` only fires in branch 2 (and only when
|
|
140
|
-
* branch 1 didn't win) — the dev convenience that lets the SPA call
|
|
141
|
-
* the listener without putting the secret in the browser bundle.
|
|
142
|
-
* Branch 3 leaves the `Authorization` header alone.
|
|
143
|
-
*
|
|
144
|
-
* Verifier resolution happens eagerly at factory time so a misconfig
|
|
145
|
-
* fails Vite startup, not the first `/v1/*` round-trip.
|
|
146
|
-
*/
|
|
147
|
-
declare function baerlyDev(opts: BaerlyDevOptions): Plugin;
|
|
148
|
-
//#endregion
|
|
149
|
-
export { BaerlyDevAuthOptions, BaerlyDevOptions, baerlyDev, baerlyDevAuth, loadDevVars };
|
|
150
|
-
//# sourceMappingURL=dev-vite.d.ts.map
|
|
148
|
+
export declare function loadDevVars<K extends string>(path: string, ...keys: readonly K[]): Record<K, string | undefined>;
|
|
149
|
+
export declare function baerlyDev(opts: BaerlyDevOptions): Plugin;
|
package/dist/dev-vite.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { n as getRequestListener, t as baerlyNode } from "./src-Actga-bO.js";
|
|
2
|
+
import { t as BaerlyError } from "./errors-7Rk1HGCE.js";
|
|
3
|
+
import { t as Db } from "./src-Dr9uo3dc.js";
|
|
4
|
+
import { r as resolveVerifier } from "./runtime-spec-B5mg3pHF.js";
|
|
5
|
+
import { n as printDevBanner, r as LocalFsStorage, t as ensureTable } from "./src-D0MQfvOp.js";
|
|
4
6
|
import { resolve } from "node:path";
|
|
5
7
|
import { existsSync, readFileSync } from "node:fs";
|
|
6
|
-
|
|
8
|
+
// packages/dev/src/vite-plugin.ts
|
|
7
9
|
const isV1Path = (url) => url === "/v1" || url.startsWith("/v1/") || url.startsWith("/v1?");
|
|
8
10
|
/**
|
|
9
11
|
* Inject `Authorization: ${value}` into a Node `IncomingMessage` such
|
|
@@ -83,7 +85,8 @@ function baerlyDevAuth(opts) {
|
|
|
83
85
|
apply: "serve",
|
|
84
86
|
configureServer(server) {
|
|
85
87
|
server.middlewares.use((req, _res, next) => {
|
|
86
|
-
|
|
88
|
+
const url = req.url ?? "";
|
|
89
|
+
if (matchesAnyPrefix(url, prefixes)) injectAuthorizationHeader(req, `Bearer ${opts.secret}`);
|
|
87
90
|
next();
|
|
88
91
|
});
|
|
89
92
|
}
|
|
@@ -128,12 +131,12 @@ function loadDevVars(path, ...keys) {
|
|
|
128
131
|
* `baerlyNode` / `baerlyWorker`):
|
|
129
132
|
*
|
|
130
133
|
* 1. `opts.verifier` set → use as-is.
|
|
131
|
-
* 2. else `
|
|
134
|
+
* 2. else `config.auth === "shared-secret"` → require
|
|
132
135
|
* `opts.secret`; build `sharedSecret({ secret, tenantPrefix:
|
|
133
136
|
* config.tenant })`. Throws `BaerlyError("InvalidConfig", ...)`
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
* 3. else `
|
|
137
|
+
* when `opts.secret` is empty/unset — same locked wording the
|
|
138
|
+
* production adapter would emit.
|
|
139
|
+
* 3. else `config.auth === "none"` → pin every request to
|
|
137
140
|
* `config.tenant`; no header check.
|
|
138
141
|
*
|
|
139
142
|
* Bearer injection on `/v1/*` only fires in branch 2 (and only when
|
|
@@ -141,57 +144,84 @@ function loadDevVars(path, ...keys) {
|
|
|
141
144
|
* the listener without putting the secret in the browser bundle.
|
|
142
145
|
* Branch 3 leaves the `Authorization` header alone.
|
|
143
146
|
*
|
|
144
|
-
*
|
|
145
|
-
* fails Vite startup, not the first
|
|
147
|
+
* When an explicit `config` object is passed, verifier resolution happens
|
|
148
|
+
* eagerly at factory time so a misconfig fails Vite startup, not the first
|
|
149
|
+
* `/v1/*` round-trip. When the config is loaded lazily (`configPath` or the
|
|
150
|
+
* `<viteRoot>/src/baerly.config.ts` convention), that resolution is deferred
|
|
151
|
+
* to dev-server startup, once the config is available.
|
|
146
152
|
*/
|
|
153
|
+
function resolveAuth(opts, config) {
|
|
154
|
+
return {
|
|
155
|
+
verifier: resolveVerifier({
|
|
156
|
+
factoryVerifier: opts.verifier,
|
|
157
|
+
config,
|
|
158
|
+
readEnv: (k) => k === "SHARED_SECRET" ? opts.secret : process.env[k]
|
|
159
|
+
}),
|
|
160
|
+
bearerForInjection: opts.verifier === void 0 && config.auth === "shared-secret" ? opts.secret : void 0
|
|
161
|
+
};
|
|
162
|
+
}
|
|
147
163
|
function baerlyDev(opts) {
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
config: opts.config,
|
|
151
|
-
readEnv: (k) => k === "SHARED_SECRET" ? opts.secret : process.env[k]
|
|
152
|
-
});
|
|
153
|
-
const bearerForInjection = opts.verifier === void 0 && opts.config.auth === "shared-secret" ? opts.secret : void 0;
|
|
164
|
+
const eagerAuth = opts.config !== void 0 ? resolveAuth(opts, opts.config) : void 0;
|
|
165
|
+
let markSettled;
|
|
154
166
|
return {
|
|
155
167
|
name: "baerly-dev",
|
|
156
168
|
apply: "serve",
|
|
169
|
+
api: { whenSettled: new Promise((settle) => {
|
|
170
|
+
markSettled = settle;
|
|
171
|
+
}) },
|
|
157
172
|
configureServer(server) {
|
|
158
|
-
const app = opts.config.app;
|
|
159
|
-
const tenant = opts.config.tenant;
|
|
160
|
-
const tables = Object.keys(opts.config.collections);
|
|
161
173
|
const ready = (async () => {
|
|
174
|
+
let config;
|
|
175
|
+
if (opts.config !== void 0) config = opts.config;
|
|
176
|
+
else {
|
|
177
|
+
const configPath = opts.configPath ?? resolve(server.config.root, "src/baerly.config.ts");
|
|
178
|
+
const mod = await server.ssrLoadModule(configPath);
|
|
179
|
+
if (typeof mod.default !== "object" || mod.default === null) throw new BaerlyError("InvalidConfig", `baerly-dev: ${configPath} must default-export a BaerlyAppConfig object`);
|
|
180
|
+
config = mod.default;
|
|
181
|
+
}
|
|
182
|
+
const { verifier, bearerForInjection } = eagerAuth ?? resolveAuth(opts, config);
|
|
183
|
+
const app = config.app;
|
|
184
|
+
const tenant = config.tenant;
|
|
185
|
+
const collections = Object.keys(config.collections);
|
|
162
186
|
const storage = new LocalFsStorage({ root: opts.dataDir ?? resolve(server.config.root, ".baerly-data") });
|
|
163
|
-
for (const
|
|
187
|
+
for (const collection of collections) await ensureTable(storage, {
|
|
164
188
|
app,
|
|
165
189
|
tenant,
|
|
166
|
-
|
|
190
|
+
collection
|
|
167
191
|
});
|
|
168
192
|
if (opts.seed !== void 0) {
|
|
169
193
|
const db = Db.create({
|
|
170
194
|
storage,
|
|
171
195
|
app,
|
|
172
196
|
tenant,
|
|
173
|
-
config
|
|
197
|
+
config
|
|
174
198
|
});
|
|
175
199
|
await opts.seed(db);
|
|
176
200
|
}
|
|
177
201
|
const requestHandler = baerlyNode({
|
|
178
|
-
config
|
|
202
|
+
config,
|
|
179
203
|
storage,
|
|
180
204
|
verifier
|
|
181
205
|
}).fetch;
|
|
182
|
-
return
|
|
206
|
+
return {
|
|
207
|
+
listener: getRequestListener(requestHandler),
|
|
208
|
+
bearerForInjection,
|
|
209
|
+
appName: config.app
|
|
210
|
+
};
|
|
183
211
|
})();
|
|
184
212
|
ready.catch((error) => {
|
|
185
213
|
console.error("[baerly-dev] setup failed:", error);
|
|
186
214
|
});
|
|
215
|
+
ready.then(markSettled, markSettled);
|
|
187
216
|
server.middlewares.use((req, res, next) => {
|
|
188
217
|
const url = req.url;
|
|
189
218
|
if (url === void 0 || !isV1Path(url)) {
|
|
190
219
|
next();
|
|
191
220
|
return;
|
|
192
221
|
}
|
|
193
|
-
if (bearerForInjection !== void 0) injectAuthorizationHeader(req, `Bearer ${bearerForInjection}`);
|
|
194
|
-
ready.then((listener) => {
|
|
222
|
+
if (eagerAuth?.bearerForInjection !== void 0) injectAuthorizationHeader(req, `Bearer ${eagerAuth.bearerForInjection}`);
|
|
223
|
+
ready.then(({ listener, bearerForInjection }) => {
|
|
224
|
+
if (eagerAuth === void 0 && bearerForInjection !== void 0) injectAuthorizationHeader(req, `Bearer ${bearerForInjection}`);
|
|
195
225
|
listener(req, res);
|
|
196
226
|
}, (error) => {
|
|
197
227
|
res.statusCode = 503;
|
|
@@ -206,19 +236,20 @@ function baerlyDev(opts) {
|
|
|
206
236
|
const address = server.httpServer?.address();
|
|
207
237
|
const port = typeof address === "object" && address !== null ? address.port : void 0;
|
|
208
238
|
const url = port !== void 0 ? `http://localhost:${port}/` : "http://localhost/";
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
239
|
+
ready.then(({ appName }) => {
|
|
240
|
+
printDevBanner({
|
|
241
|
+
name: appName,
|
|
242
|
+
primaryUrl: {
|
|
243
|
+
label: "App",
|
|
244
|
+
url
|
|
245
|
+
},
|
|
246
|
+
...opts.hints !== void 0 && { hints: opts.hints }
|
|
247
|
+
});
|
|
248
|
+
}).catch(() => {});
|
|
217
249
|
});
|
|
218
250
|
}
|
|
219
251
|
};
|
|
220
252
|
}
|
|
221
|
-
//#endregion
|
|
222
253
|
export { baerlyDev, baerlyDevAuth, loadDevVars };
|
|
223
254
|
|
|
224
255
|
//# sourceMappingURL=dev-vite.js.map
|
package/dist/dev-vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-vite.js","names":[],"sources":["../packages/dev/src/vite-plugin.ts"],"sourcesContent":["import type { AddressInfo } from \"node:net\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { getRequestListener } from \"@hono/node-server\";\nimport type { Plugin } from \"vite\";\nimport { baerlyNode } from \"@baerly/adapter-node\";\nimport type { BaerlyAppConfig, Verifier } from \"@baerly/protocol\";\nimport { Db, resolveVerifier } from \"@baerly/server\";\nimport { type DevBannerHint, printDevBanner } from \"./dev-banner.ts\";\nimport { ensureTable } from \"./ensure-table.ts\";\nimport { LocalFsStorage } from \"./local-fs.ts\";\n\nexport interface BaerlyDevOptions {\n /**\n * The project's `baerly.config.ts`. `app`, `tenant`, `auth`, and the\n * table set (`Object.keys(config.collections)`) are derived from it.\n * Per-collection schemas/indexes flow through to the in-process\n * listener the same way `baerlyNode` / `baerlyWorker` pipe them.\n */\n readonly config: BaerlyAppConfig;\n /**\n * Shared-secret token. **Optional.** Required only when\n * `config.auth === \"shared-secret\"` and `verifier` is unset — in\n * that branch, clients must send `Authorization: Bearer <secret>`\n * AND the middleware injects the same bearer server-side before\n * forwarding to the in-process listener.\n *\n * Ignored when `config.auth === \"none\"` (no bearer to inject) or\n * when `verifier` is supplied (the operator owns the auth seam).\n *\n * Throwing the symmetric `InvalidConfig` on a misconfig matches\n * production behaviour: forgetting `SHARED_SECRET` in dev fails\n * fast at `vite dev` startup with the same locked wording the\n * adapter would emit.\n */\n readonly secret?: string;\n /**\n * Per-request `Verifier`. **Optional.** When set, overrides both\n * `config.auth` and `secret` (same precedence as the production\n * adapter factories). Use for dev-mode JWT validation against a\n * staging IdP, or any custom auth shape.\n */\n readonly verifier?: Verifier;\n /**\n * Absolute path to the data directory for LocalFsStorage.\n * **Optional** — defaults to `<vite root>/.baerly-data`, so the dev\n * server runs zero-config.\n */\n readonly dataDir?: string;\n /** Optional async seed callback, invoked after ensureTable, before mount. */\n readonly seed?: (db: Db) => Promise<void>;\n /** Extra hints appended to the dev banner. */\n readonly hints?: readonly DevBannerHint[];\n /** Set to false to suppress the dev banner. Default: true. */\n readonly banner?: boolean;\n}\n\nconst isV1Path = (url: string): boolean =>\n url === \"/v1\" || url.startsWith(\"/v1/\") || url.startsWith(\"/v1?\");\n\n/**\n * Inject `Authorization: ${value}` into a Node `IncomingMessage` such\n * that BOTH the parsed (`req.headers`) and the wire-form (`req.rawHeaders`)\n * views agree.\n *\n * Why both: `req.headers` is the parsed-and-lowercased JS map most\n * connect-style middleware reads, but Node→Fetch bridges typically\n * rebuild the Fetch `Headers` from `req.rawHeaders` (the original\n * `[name, value, name, value, …]` wire array) to preserve case and\n * multi-value semantics. `@cloudflare/vite-plugin`'s `createHeaders()`\n * does exactly that — so mutating `req.headers` alone silently drops\n * the bearer token when the in-process Worker receives the request.\n * Treat any new injection in this file as obligated to touch both.\n */\nconst injectAuthorizationHeader = (\n req: {\n headers: Record<string, string | string[] | undefined>;\n rawHeaders?: string[];\n },\n value: string,\n): void => {\n req.headers[\"authorization\"] = value;\n const raw = req.rawHeaders;\n if (raw === undefined) {\n return;\n }\n for (let i = 0; i < raw.length; i += 2) {\n if (raw[i]!.toLowerCase() === \"authorization\") {\n raw[i + 1] = value;\n return;\n }\n }\n raw.push(\"Authorization\", value);\n};\n\nexport interface BaerlyDevAuthOptions {\n /** Bearer token to inject on matched paths. */\n readonly secret: string;\n /**\n * Pathname prefixes to match. Default `[\"/v1\", \"/api\"]` — the\n * baerly cascade lives at `/v1/*`, and `/api/*` is the canonical\n * namespace for custom Worker routes (the \"wrap `baerly.fetch!`\"\n * recipe in the scaffold's AGENTS.md). Covering both by default\n * closes a recurring \"added a custom route, browser silently 401s\"\n * trap: agents typically edit `src/server/index.ts` without touching\n * `vite.config.ts`, so a `\"/v1\"`-only default leaves their new route\n * unauthenticated in `vite dev` and `pnpm verify` is silent on it.\n *\n * Override when you mount under a different namespace, or pass\n * `prefix: \"/v1\"` to opt out of `/api/*` injection entirely (rare —\n * the bearer is a harmless extra header on unmatched routes).\n */\n readonly prefix?: string | readonly string[];\n}\n\nconst normalisePrefixes = (prefix: string | readonly string[] | undefined): readonly string[] => {\n if (prefix === undefined) {\n return [\"/v1\", \"/api\"];\n }\n if (typeof prefix === \"string\") {\n return [prefix];\n }\n return prefix;\n};\n\nconst matchesAnyPrefix = (url: string, prefixes: readonly string[]): boolean => {\n for (const prefix of prefixes) {\n if (url === prefix || url.startsWith(`${prefix}/`) || url.startsWith(`${prefix}?`)) {\n return true;\n }\n }\n return false;\n};\n\n/**\n * Vite dev plugin: inject `Authorization: Bearer ${secret}` on every\n * request whose URL starts with one of `prefix` (default\n * `[\"/v1\", \"/api\"]`). Use this to keep the bearer token out of the\n * SPA bundle — the browser sends the request, Vite's middleware adds\n * the header, and the upstream handler (in-process worker or proxied\n * Node server) sees an authenticated request.\n *\n * **Custom Worker routes.** `baerlyWorker` only sees `/v1/*`; the\n * default `prefix` also covers `/api/*` because that's the canonical\n * namespace for the \"wrap `baerly.fetch!`\" recipe (a server-side\n * endpoint the SPA client can't run on its own, e.g. an endpoint\n * that fans a write across several documents server-side). If you\n * mount under a different namespace, override:\n *\n * ```ts\n * baerlyDevAuth({ secret, prefix: [\"/v1\", \"/internal\"] });\n * ```\n *\n * The bearer is dev-only convenience — production deploys put the\n * SPA, the baerly cascade, AND your custom routes behind the same\n * tenant boundary (CF Access, an upstream JWT, …), so this matters\n * exclusively while `vite dev` is the front door.\n *\n * @example\n * ```ts\n * import { baerlyDevAuth, loadDevVars } from \"@gusto/baerly-storage/dev/vite\";\n *\n * const { SHARED_SECRET } = loadDevVars(\".dev.vars\", \"SHARED_SECRET\");\n * export default defineConfig({\n * plugins: [\n * cloudflare(),\n * baerlyDevAuth({ secret: SHARED_SECRET ?? \"\" }),\n * ],\n * });\n * ```\n */\nexport function baerlyDevAuth(opts: BaerlyDevAuthOptions): Plugin {\n if (opts.secret === \"\") {\n throw new Error(\n \"baerlyDevAuth: secret must be non-empty. Set SHARED_SECRET in .dev.vars / .env.\",\n );\n }\n const prefixes: readonly string[] = normalisePrefixes(opts.prefix);\n return {\n name: \"baerly-dev-auth\",\n apply: \"serve\",\n configureServer(server) {\n server.middlewares.use((req, _res, next) => {\n const url = req.url ?? \"\";\n if (matchesAnyPrefix(url, prefixes)) {\n injectAuthorizationHeader(req, `Bearer ${opts.secret}`);\n }\n next();\n });\n },\n };\n}\n\n/**\n * Parse a `.dev.vars` / `.env` file and return the values for the\n * requested `keys`. Supports `KEY=value`, `# comments`, blank lines,\n * and single- or double-quoted values. Keys missing from the file\n * (or the whole file when it does not exist) come back as\n * `undefined` — fall back with `??` at the call site.\n *\n * The return type is `Record<K, string | undefined>` where `K` is\n * the union of literal key names you pass in, so property access\n * works under strict `noPropertyAccessFromIndexSignature`:\n *\n * ```ts\n * const { SHARED_SECRET } = loadDevVars(\".dev.vars\", \"SHARED_SECRET\");\n * // ^? string | undefined\n * ```\n */\nexport function loadDevVars<K extends string>(\n path: string,\n ...keys: readonly K[]\n): Record<K, string | undefined> {\n const out = {} as Record<K, string | undefined>;\n for (const key of keys) {\n out[key] = undefined;\n }\n if (!existsSync(path)) {\n return out;\n }\n const wanted = new Set<string>(keys);\n for (const rawLine of readFileSync(path, \"utf8\").split(\"\\n\")) {\n const line = rawLine.trim();\n if (line === \"\" || line.startsWith(\"#\")) {\n continue;\n }\n const eq = line.indexOf(\"=\");\n if (eq === -1) {\n continue;\n }\n const key = line.slice(0, eq).trim();\n if (!wanted.has(key)) {\n continue;\n }\n let value = line.slice(eq + 1).trim();\n if (\n (value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n value = value.slice(1, -1);\n }\n out[key as K] = value;\n }\n return out;\n}\n\n/**\n * Resolution order for the in-process verifier (mirrors\n * `baerlyNode` / `baerlyWorker`):\n *\n * 1. `opts.verifier` set → use as-is.\n * 2. else `opts.config.auth === \"shared-secret\"` → require\n * `opts.secret`; build `sharedSecret({ secret, tenantPrefix:\n * config.tenant })`. Throws `BaerlyError(\"InvalidConfig\", ...)`\n * at Vite startup when `opts.secret` is empty/unset — same\n * locked wording the production adapter would emit.\n * 3. else `opts.config.auth === \"none\"` → pin every request to\n * `config.tenant`; no header check.\n *\n * Bearer injection on `/v1/*` only fires in branch 2 (and only when\n * branch 1 didn't win) — the dev convenience that lets the SPA call\n * the listener without putting the secret in the browser bundle.\n * Branch 3 leaves the `Authorization` header alone.\n *\n * Verifier resolution happens eagerly at factory time so a misconfig\n * fails Vite startup, not the first `/v1/*` round-trip.\n */\nexport function baerlyDev(opts: BaerlyDevOptions): Plugin {\n // Resolution order: opts.verifier → config.auth.shared-secret →\n // config.auth.none → throw. Mirrors `baerlyWorker` / `baerlyNode`.\n // The synthetic `readEnv` hoists `opts.secret` to `SHARED_SECRET`\n // so the same resolver works — `baerlyDev` takes the secret as a\n // typed option rather than reading `process.env` directly.\n const verifier = resolveVerifier({\n factoryVerifier: opts.verifier,\n config: opts.config,\n readEnv: (k) => (k === \"SHARED_SECRET\" ? opts.secret : process.env[k]),\n });\n\n // Bearer injection only matters in the shared-secret branch (and\n // only when no override owns auth). For \"none\" or any custom\n // verifier, the `Authorization` header reaches the listener\n // unchanged.\n const bearerForInjection: string | undefined =\n opts.verifier === undefined && opts.config.auth === \"shared-secret\" ? opts.secret : undefined;\n\n return {\n name: \"baerly-dev\",\n apply: \"serve\",\n configureServer(server) {\n // Mount in the configureServer body (not a post-hook) so the\n // middleware runs BEFORE Vite's internal SPA history fallback.\n // Otherwise /v1/* requests get caught by the SPA fallback and\n // served the index.html shell.\n const app = opts.config.app;\n const tenant = opts.config.tenant;\n const tables = Object.keys(opts.config.collections);\n const ready = (async () => {\n const storage = new LocalFsStorage({\n root: opts.dataDir ?? resolve(server.config.root, \".baerly-data\"),\n });\n for (const table of tables) {\n await ensureTable(storage, { app, tenant, table });\n }\n if (opts.seed !== undefined) {\n const db = Db.create({ storage, app, tenant, config: opts.config });\n await opts.seed(db);\n }\n const requestHandler = baerlyNode({\n config: opts.config,\n storage,\n verifier,\n }).fetch;\n return getRequestListener(requestHandler);\n })();\n\n // Surface setup failures eagerly; without this an unhandled\n // rejection would silently kill the dev server.\n ready.catch((error: unknown) => {\n console.error(\"[baerly-dev] setup failed:\", error);\n });\n\n server.middlewares.use((req, res, next) => {\n const url = req.url;\n if (url === undefined || !isV1Path(url)) {\n next();\n return;\n }\n // Inject the bearer token server-side so the SPA never sees\n // the secret. Only runs for `config.auth === \"shared-secret\"`\n // without a `verifier:` override — otherwise the header\n // reaches the listener unchanged. Mutates both `req.headers`\n // and `req.rawHeaders` — see `injectAuthorizationHeader`'s\n // JSDoc.\n if (bearerForInjection !== undefined) {\n injectAuthorizationHeader(req, `Bearer ${bearerForInjection}`);\n }\n ready.then(\n (listener) => {\n listener(req as never, res as never);\n },\n (error: unknown) => {\n res.statusCode = 503;\n res.setHeader(\"content-type\", \"application/json\");\n res.end(JSON.stringify({ error: \"baerly-dev setup failed\", message: String(error) }));\n },\n );\n });\n\n if (opts.banner !== false) {\n server.httpServer?.once(\"listening\", () => {\n const address = server.httpServer?.address();\n const port =\n typeof address === \"object\" && address !== null\n ? (address as AddressInfo).port\n : undefined;\n const url = port !== undefined ? `http://localhost:${port}/` : \"http://localhost/\";\n printDevBanner({\n name: opts.config.app,\n primaryUrl: { label: \"App\", url },\n ...(opts.hints !== undefined && { hints: opts.hints }),\n });\n });\n }\n },\n };\n}\n"],"mappings":";;;;;;AAyDA,MAAM,YAAY,QAChB,QAAQ,SAAS,IAAI,WAAW,MAAM,K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ourcesContent":["import type { AddressInfo } from \"node:net\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { getRequestListener } from \"@hono/node-server\";\nimport type { Plugin } from \"vite\";\nimport { baerlyNode } from \"@baerly/adapter-node\";\nimport { BaerlyError, type BaerlyAppConfig, type Verifier } from \"@baerly/protocol\";\nimport { Db } from \"@baerly/server\";\nimport { resolveVerifier } from \"@baerly/server/_internal/kernel\";\nimport { type DevBannerHint, printDevBanner } from \"./dev-banner.ts\";\nimport { ensureTable } from \"./ensure-table.ts\";\nimport { LocalFsStorage } from \"./local-fs.ts\";\n\nexport interface BaerlyDevOptions {\n /**\n * The project's `baerly.config.ts`. `app`, `tenant`, `auth`, and the\n * table set (`Object.keys(config.collections)`) are derived from it.\n * Per-collection schemas/indexes flow through to the in-process\n * listener the same way `baerlyNode` / `baerlyWorker` pipe them.\n *\n * **Optional.** If omitted, the config is loaded at dev-server startup\n * from `configPath`, or — if that's also omitted — by convention from\n * `<viteRoot>/src/baerly.config.ts`.\n *\n * Prefer omitting it (convention or `configPath`). Passing the object\n * means the caller's `vite.config` must `import` the config module,\n * which forces Nx's `@nx/vite` / `@nx/vitest` inference plugins to\n * bundle that module — and its transitive imports — while creating the\n * project graph. That pulls unresolved imports into the config bundle\n * and forces the app into the root `nx.json` inference-exclusion lists.\n * Letting `baerlyDev` load the config itself (below) keeps the caller's\n * `vite.config` import-free, the same way `reactRouter()` loads\n * `react-router.config.ts` by convention.\n */\n readonly config?: BaerlyAppConfig;\n /**\n * Absolute path to the `baerly.config` module (its default export is\n * the `BaerlyAppConfig`). Loaded lazily via Vite's `ssrLoadModule` at\n * dev-server startup. Overrides the `<viteRoot>/src/baerly.config.ts`\n * convention. Ignored when `config` is provided.\n */\n readonly configPath?: string;\n /**\n * Shared-secret token. **Optional.** Required only when\n * `config.auth === \"shared-secret\"` and `verifier` is unset — in\n * that branch, clients must send `Authorization: Bearer <secret>`\n * AND the middleware injects the same bearer server-side before\n * forwarding to the in-process listener.\n *\n * Ignored when `config.auth === \"none\"` (no bearer to inject) or\n * when `verifier` is supplied (the operator owns the auth seam).\n *\n * Throwing the symmetric `InvalidConfig` on a misconfig matches\n * production behaviour: forgetting `SHARED_SECRET` in dev throws\n * with the same locked wording the adapter would emit. With an\n * explicit `config` object this fails fast at `vite dev` startup\n * (factory-time resolution); when the config is loaded lazily\n * (`configPath` / convention) the throw is deferred to dev-server\n * startup and surfaces as a per-request 503 rather than aborting\n * the Vite process.\n */\n readonly secret?: string;\n /**\n * Per-request `Verifier`. **Optional.** When set, overrides both\n * `config.auth` and `secret` (same precedence as the production\n * adapter factories). Use for dev-mode JWT validation against a\n * staging IdP, or any custom auth shape.\n */\n readonly verifier?: Verifier;\n /**\n * Absolute path to the data directory for LocalFsStorage.\n * **Optional** — defaults to `<vite root>/.baerly-data`, so the dev\n * server runs zero-config.\n */\n readonly dataDir?: string;\n /** Optional async seed callback, invoked after ensureTable, before mount. */\n readonly seed?: (db: Db) => Promise<void>;\n /** Extra hints appended to the dev banner. */\n readonly hints?: readonly DevBannerHint[];\n /** Set to false to suppress the dev banner. Default: true. */\n readonly banner?: boolean;\n}\n\nconst isV1Path = (url: string): boolean =>\n url === \"/v1\" || url.startsWith(\"/v1/\") || url.startsWith(\"/v1?\");\n\n/**\n * Inject `Authorization: ${value}` into a Node `IncomingMessage` such\n * that BOTH the parsed (`req.headers`) and the wire-form (`req.rawHeaders`)\n * views agree.\n *\n * Why both: `req.headers` is the parsed-and-lowercased JS map most\n * connect-style middleware reads, but Node→Fetch bridges typically\n * rebuild the Fetch `Headers` from `req.rawHeaders` (the original\n * `[name, value, name, value, …]` wire array) to preserve case and\n * multi-value semantics. `@cloudflare/vite-plugin`'s `createHeaders()`\n * does exactly that — so mutating `req.headers` alone silently drops\n * the bearer token when the in-process Worker receives the request.\n * Treat any new injection in this file as obligated to touch both.\n */\nconst injectAuthorizationHeader = (\n req: {\n headers: Record<string, string | string[] | undefined>;\n rawHeaders?: string[];\n },\n value: string,\n): void => {\n req.headers[\"authorization\"] = value;\n const raw = req.rawHeaders;\n if (raw === undefined) {\n return;\n }\n for (let i = 0; i < raw.length; i += 2) {\n if (raw[i]!.toLowerCase() === \"authorization\") {\n raw[i + 1] = value;\n return;\n }\n }\n raw.push(\"Authorization\", value);\n};\n\nexport interface BaerlyDevAuthOptions {\n /** Bearer token to inject on matched paths. */\n readonly secret: string;\n /**\n * Pathname prefixes to match. Default `[\"/v1\", \"/api\"]` — the\n * baerly cascade lives at `/v1/*`, and `/api/*` is the canonical\n * namespace for custom Worker routes (the \"wrap `baerly.fetch!`\"\n * recipe in the scaffold's AGENTS.md). Covering both by default\n * closes a recurring \"added a custom route, browser silently 401s\"\n * trap: agents typically edit `src/server/index.ts` without touching\n * `vite.config.ts`, so a `\"/v1\"`-only default leaves their new route\n * unauthenticated in `vite dev` and `pnpm verify` is silent on it.\n *\n * Override when you mount under a different namespace, or pass\n * `prefix: \"/v1\"` to opt out of `/api/*` injection entirely (rare —\n * the bearer is a harmless extra header on unmatched routes).\n */\n readonly prefix?: string | readonly string[];\n}\n\nconst normalisePrefixes = (prefix: string | readonly string[] | undefined): readonly string[] => {\n if (prefix === undefined) {\n return [\"/v1\", \"/api\"];\n }\n if (typeof prefix === \"string\") {\n return [prefix];\n }\n return prefix;\n};\n\nconst matchesAnyPrefix = (url: string, prefixes: readonly string[]): boolean => {\n for (const prefix of prefixes) {\n if (url === prefix || url.startsWith(`${prefix}/`) || url.startsWith(`${prefix}?`)) {\n return true;\n }\n }\n return false;\n};\n\n/**\n * Vite dev plugin: inject `Authorization: Bearer ${secret}` on every\n * request whose URL starts with one of `prefix` (default\n * `[\"/v1\", \"/api\"]`). Use this to keep the bearer token out of the\n * SPA bundle — the browser sends the request, Vite's middleware adds\n * the header, and the upstream handler (in-process worker or proxied\n * Node server) sees an authenticated request.\n *\n * **Custom Worker routes.** `baerlyWorker` only sees `/v1/*`; the\n * default `prefix` also covers `/api/*` because that's the canonical\n * namespace for the \"wrap `baerly.fetch!`\" recipe (a server-side\n * endpoint the SPA client can't run on its own, e.g. an endpoint\n * that fans a write across several documents server-side). If you\n * mount under a different namespace, override:\n *\n * ```ts\n * baerlyDevAuth({ secret, prefix: [\"/v1\", \"/internal\"] });\n * ```\n *\n * The bearer is dev-only convenience — production deploys put the\n * SPA, the baerly cascade, AND your custom routes behind the same\n * tenant boundary (CF Access, an upstream JWT, …), so this matters\n * exclusively while `vite dev` is the front door.\n *\n * @example\n * ```ts\n * import { baerlyDevAuth, loadDevVars } from \"@gusto/baerly-storage/dev/vite\";\n *\n * const { SHARED_SECRET } = loadDevVars(\".dev.vars\", \"SHARED_SECRET\");\n * export default defineConfig({\n * plugins: [\n * cloudflare(),\n * baerlyDevAuth({ secret: SHARED_SECRET ?? \"\" }),\n * ],\n * });\n * ```\n */\nexport function baerlyDevAuth(opts: BaerlyDevAuthOptions): Plugin {\n if (opts.secret === \"\") {\n throw new Error(\n \"baerlyDevAuth: secret must be non-empty. Set SHARED_SECRET in .dev.vars / .env.\",\n );\n }\n const prefixes: readonly string[] = normalisePrefixes(opts.prefix);\n return {\n name: \"baerly-dev-auth\",\n apply: \"serve\",\n configureServer(server) {\n server.middlewares.use((req, _res, next) => {\n const url = req.url ?? \"\";\n if (matchesAnyPrefix(url, prefixes)) {\n injectAuthorizationHeader(req, `Bearer ${opts.secret}`);\n }\n next();\n });\n },\n };\n}\n\n/**\n * Parse a `.dev.vars` / `.env` file and return the values for the\n * requested `keys`. Supports `KEY=value`, `# comments`, blank lines,\n * and single- or double-quoted values. Keys missing from the file\n * (or the whole file when it does not exist) come back as\n * `undefined` — fall back with `??` at the call site.\n *\n * The return type is `Record<K, string | undefined>` where `K` is\n * the union of literal key names you pass in, so property access\n * works under strict `noPropertyAccessFromIndexSignature`:\n *\n * ```ts\n * const { SHARED_SECRET } = loadDevVars(\".dev.vars\", \"SHARED_SECRET\");\n * // ^? string | undefined\n * ```\n */\nexport function loadDevVars<K extends string>(\n path: string,\n ...keys: readonly K[]\n): Record<K, string | undefined> {\n const out = {} as Record<K, string | undefined>;\n for (const key of keys) {\n out[key] = undefined;\n }\n if (!existsSync(path)) {\n return out;\n }\n const wanted = new Set<string>(keys);\n for (const rawLine of readFileSync(path, \"utf8\").split(\"\\n\")) {\n const line = rawLine.trim();\n if (line === \"\" || line.startsWith(\"#\")) {\n continue;\n }\n const eq = line.indexOf(\"=\");\n if (eq === -1) {\n continue;\n }\n const key = line.slice(0, eq).trim();\n if (!wanted.has(key)) {\n continue;\n }\n let value = line.slice(eq + 1).trim();\n if (\n (value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n value = value.slice(1, -1);\n }\n out[key as K] = value;\n }\n return out;\n}\n\n/**\n * Resolution order for the in-process verifier (mirrors\n * `baerlyNode` / `baerlyWorker`):\n *\n * 1. `opts.verifier` set → use as-is.\n * 2. else `config.auth === \"shared-secret\"` → require\n * `opts.secret`; build `sharedSecret({ secret, tenantPrefix:\n * config.tenant })`. Throws `BaerlyError(\"InvalidConfig\", ...)`\n * when `opts.secret` is empty/unset — same locked wording the\n * production adapter would emit.\n * 3. else `config.auth === \"none\"` → pin every request to\n * `config.tenant`; no header check.\n *\n * Bearer injection on `/v1/*` only fires in branch 2 (and only when\n * branch 1 didn't win) — the dev convenience that lets the SPA call\n * the listener without putting the secret in the browser bundle.\n * Branch 3 leaves the `Authorization` header alone.\n *\n * When an explicit `config` object is passed, verifier resolution happens\n * eagerly at factory time so a misconfig fails Vite startup, not the first\n * `/v1/*` round-trip. When the config is loaded lazily (`configPath` or the\n * `<viteRoot>/src/baerly.config.ts` convention), that resolution is deferred\n * to dev-server startup, once the config is available.\n */\nfunction resolveAuth(opts: BaerlyDevOptions, config: BaerlyAppConfig) {\n // Resolution order: opts.verifier → config.auth.shared-secret →\n // config.auth.none → throw. Mirrors `baerlyWorker` / `baerlyNode`. The\n // synthetic `readEnv` hoists `opts.secret` to `SHARED_SECRET` so the same\n // resolver works — `baerlyDev` takes the secret as a typed option rather\n // than reading `process.env` directly.\n const verifier = resolveVerifier({\n factoryVerifier: opts.verifier,\n config,\n readEnv: (k) => (k === \"SHARED_SECRET\" ? opts.secret : process.env[k]),\n });\n // Bearer injection only matters in the shared-secret branch (and only when\n // no override owns auth). For \"none\" or any custom verifier, the\n // `Authorization` header reaches the listener unchanged.\n const bearerForInjection: string | undefined =\n opts.verifier === undefined && config.auth === \"shared-secret\" ? opts.secret : undefined;\n return { verifier, bearerForInjection };\n}\n\nexport function baerlyDev(opts: BaerlyDevOptions): Plugin {\n // Eager, factory-time auth resolution when a `config` object is passed —\n // preserves fail-fast startup on misconfig. When `config` is omitted it's\n // loaded lazily in `configureServer` (see below) and auth resolves there.\n const eagerAuth = opts.config !== undefined ? resolveAuth(opts, opts.config) : undefined;\n // Readiness handle: resolves once configureServer's async setup settles\n // (success OR failure). The setup runs un-awaited in the background (Vite\n // doesn't await configureServer's internal promises), so without this\n // there is no way to know it has finished touching the data dir. Exposed\n // via Vite's `api` field so a caller — or a test that provisions a\n // throwaway data dir — can await settle before tearing that dir down,\n // rather than racing the in-flight `ensureTable`/`storage.put`.\n let markSettled!: () => void;\n const whenSettled = new Promise<void>((settle) => {\n markSettled = settle;\n });\n return {\n name: \"baerly-dev\",\n apply: \"serve\",\n api: { whenSettled },\n configureServer(server) {\n // Everything below runs at dev-server startup, NOT at plugin-factory\n // time. That lets callers omit `config` and instead have us load\n // `baerly.config` here (via `configPath`, or by convention) — so their\n // `vite.config` never imports the config module. Resolving it here\n // rather than in the factory is what keeps baerly apps out of Nx's\n // inference-plugin exclusion lists (see `BaerlyDevOptions.config`).\n //\n // Mount the middleware in the configureServer body (not a post-hook) so\n // it runs BEFORE Vite's internal SPA history fallback; otherwise /v1/*\n // requests get caught by the fallback and served the index.html shell.\n const ready = (async () => {\n // Resolution order for the config source: explicit `config` object →\n // explicit `configPath` → convention `<viteRoot>/src/baerly.config.ts`.\n let config: BaerlyAppConfig;\n if (opts.config !== undefined) {\n config = opts.config;\n } else {\n const configPath = opts.configPath ?? resolve(server.config.root, \"src/baerly.config.ts\");\n const mod = (await server.ssrLoadModule(configPath)) as { default?: unknown };\n // Mirrors packages/cli/src/config.ts's loadAppConfig: a module with no\n // (or a misnamed) default export would otherwise silently become\n // `undefined` here, surfacing later as a bare `TypeError` on the first\n // `config.app` read with no hint that the real problem is the export.\n if (typeof mod.default !== \"object\" || mod.default === null) {\n throw new BaerlyError(\n \"InvalidConfig\",\n `baerly-dev: ${configPath} must default-export a BaerlyAppConfig object`,\n );\n }\n config = mod.default as BaerlyAppConfig;\n }\n\n // Reuse the eager (factory-time) auth resolution when a `config` object\n // was passed; otherwise resolve now that the loaded config is available.\n const { verifier, bearerForInjection } = eagerAuth ?? resolveAuth(opts, config);\n\n const app = config.app;\n const tenant = config.tenant;\n const collections = Object.keys(config.collections);\n const storage = new LocalFsStorage({\n root: opts.dataDir ?? resolve(server.config.root, \".baerly-data\"),\n });\n for (const collection of collections) {\n await ensureTable(storage, { app, tenant, collection });\n }\n if (opts.seed !== undefined) {\n const db = Db.create({ storage, app, tenant, config });\n await opts.seed(db);\n }\n const requestHandler = baerlyNode({ config, storage, verifier }).fetch;\n return {\n listener: getRequestListener(requestHandler),\n bearerForInjection,\n appName: config.app,\n };\n })();\n\n // Surface setup failures eagerly; without this an unhandled\n // rejection would silently kill the dev server.\n ready.catch((error: unknown) => {\n console.error(\"[baerly-dev] setup failed:\", error);\n });\n // Settle the exposed readiness handle regardless of outcome — a\n // failed setup is still \"done\", and awaiters (see `api.whenSettled`)\n // only need to know the background work has stopped touching storage.\n void ready.then(markSettled, markSettled);\n\n server.middlewares.use((req, res, next) => {\n const url = req.url;\n if (url === undefined || !isV1Path(url)) {\n next();\n return;\n }\n // Inject the bearer token server-side so the SPA never sees the secret.\n // Only for `config.auth === \"shared-secret\"` without a `verifier:`\n // override — otherwise the header reaches the listener unchanged.\n // Mutates both `req.headers` and `req.rawHeaders` (see\n // `injectAuthorizationHeader`'s JSDoc). When auth resolved eagerly\n // (explicit `config`), inject synchronously here — before the async\n // listener resolves — preserving the pre-lazy-load timing. When the\n // config is loaded lazily, the bearer isn't known yet, so injection\n // happens in the `ready.then` below (still before the listener runs).\n if (eagerAuth?.bearerForInjection !== undefined) {\n injectAuthorizationHeader(req, `Bearer ${eagerAuth.bearerForInjection}`);\n }\n ready.then(\n ({ listener, bearerForInjection }) => {\n if (eagerAuth === undefined && bearerForInjection !== undefined) {\n injectAuthorizationHeader(req, `Bearer ${bearerForInjection}`);\n }\n listener(req as never, res as never);\n },\n (error: unknown) => {\n res.statusCode = 503;\n res.setHeader(\"content-type\", \"application/json\");\n res.end(JSON.stringify({ error: \"baerly-dev setup failed\", message: String(error) }));\n },\n );\n });\n\n if (opts.banner !== false) {\n server.httpServer?.once(\"listening\", () => {\n const address = server.httpServer?.address();\n const port =\n typeof address === \"object\" && address !== null\n ? (address as AddressInfo).port\n : undefined;\n const url = port !== undefined ? `http://localhost:${port}/` : \"http://localhost/\";\n ready\n .then(({ appName }) => {\n printDevBanner({\n name: appName,\n primaryUrl: { label: \"App\", url },\n ...(opts.hints !== undefined && { hints: opts.hints }),\n });\n })\n // A rejected `ready` is already logged by the `ready.catch` above.\n // Each `.then()`/`.catch()` call creates its own derived promise,\n // so without this, a config-load failure here would be a SECOND,\n // unguarded rejection — the exact \"unhandled rejection kills the\n // dev server\" failure that catch was added to prevent.\n .catch(() => {});\n });\n }\n },\n };\n}\n"],"mappings":";;;;;;;;AAmFA,MAAM,YAAY,QAChB,QAAQ,SAAS,IAAI,WAAW,MAAM,KAAK,IAAI,WAAW,MAAM;;;;;;;;;;;;;;;AAgBlE,MAAM,6BACJ,KAIA,UACS;CACT,IAAI,QAAQ,mBAAmB;CAC/B,MAAM,MAAM,IAAI;CAChB,IAAI,QAAQ,KAAA,GACV;CAEF,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK,GACnC,IAAI,IAAI,EAAE,CAAE,YAAY,MAAM,iBAAi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K,WAAW,OAClB,OAAO,YAAY,KAAK,mBAAmB;IACzC,MAAM,UAAU,OAAO,YAAY,QAAQ;IAC3C,MAAM,OACJ,OAAO,YAAY,YAAY,YAAY,OACtC,QAAwB,OACzB,KAAA;IACN,MAAM,MAAM,SAAS,KAAA,IAAY,oBAAoB,KAAK,KAAK;IAC/D,MACG,MAAM,EAAE,cAAc;KACrB,eAAe;MACb,MAAM;MACN,YAAY;OAAE,OAAO;OAAO;MAAI;MAChC,GAAI,KAAK,UAAU,KAAA,KAAa,EAAE,OAAO,KAAK,MAAM;KACtD,CAAC;IACH,CAAC,CAAC,CAMD,YAAY,CAAC,CAAC;GACnB,CAAC;EAEL;CACF;AACF"}
|
package/dist/dev.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import {
|
|
1
|
+
import { n as renderDevLanding, t as DevLandingOptions } from "./dev-landing-BI5UdmOb.js";
|
|
2
|
+
import { n as DevBannerOpts, r as printDevBanner, t as DevBannerHint } from "./dev-banner-B5AUHmu1.js";
|
|
3
|
+
import { n as LocalFsStorageOptions, r as ensureTable, t as LocalFsStorage } from "./index-JJrIu1pO.js";
|
|
3
4
|
export { type DevBannerHint, type DevBannerOpts, type DevLandingOptions, LocalFsStorage, LocalFsStorageOptions, ensureTable, printDevBanner, renderDevLanding };
|
package/dist/dev.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as renderDevLanding } from "./dev-landing-CD-si4dW.js";
|
|
2
|
+
import { n as printDevBanner, r as LocalFsStorage, t as ensureTable } from "./src-D0MQfvOp.js";
|
|
2
3
|
export { LocalFsStorage, ensureTable, printDevBanner, renderDevLanding };
|