everything-dev 2.0.0-rc.1 → 2.0.0-rc.5
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/dist/api-contract.cjs +3 -6
- package/dist/api-contract.cjs.map +1 -1
- package/dist/api-contract.mjs +3 -6
- package/dist/api-contract.mjs.map +1 -1
- package/dist/apps/upload/src/client.cjs +188 -0
- package/dist/apps/upload/src/client.cjs.map +1 -0
- package/dist/apps/upload/src/client.mjs +180 -0
- package/dist/apps/upload/src/client.mjs.map +1 -0
- package/dist/auth-login.cjs +1 -1
- package/dist/auth-login.mjs +1 -1
- package/dist/build.cjs +2 -2
- package/dist/build.mjs +2 -2
- package/dist/bundle-fs-resolve.cjs +9 -17
- package/dist/bundle-fs-resolve.cjs.map +1 -1
- package/dist/bundle-fs-resolve.d.cts +6 -0
- package/dist/bundle-fs-resolve.d.mts +6 -0
- package/dist/bundle-fs-resolve.mjs +9 -17
- package/dist/bundle-fs-resolve.mjs.map +1 -1
- package/dist/bundle-path.cjs +48 -0
- package/dist/bundle-path.cjs.map +1 -0
- package/dist/bundle-path.mjs +45 -0
- package/dist/bundle-path.mjs.map +1 -0
- package/dist/cdn-deploy.cjs +29 -11
- package/dist/cdn-deploy.cjs.map +1 -1
- package/dist/cdn-deploy.mjs +29 -11
- package/dist/cdn-deploy.mjs.map +1 -1
- package/dist/cli/init.cjs +4 -6
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.d.cts +1 -1
- package/dist/cli/init.d.mts +1 -1
- package/dist/cli/init.mjs +4 -6
- package/dist/cli/init.mjs.map +1 -1
- package/dist/cli/status.cjs +69 -3
- package/dist/cli/status.cjs.map +1 -1
- package/dist/cli/status.mjs +67 -4
- package/dist/cli/status.mjs.map +1 -1
- package/dist/cli/sync.cjs +1 -2
- package/dist/cli/sync.cjs.map +1 -1
- package/dist/cli/sync.mjs +1 -2
- package/dist/cli/sync.mjs.map +1 -1
- package/dist/cli/upgrade.cjs +2 -2
- package/dist/cli/upgrade.cjs.map +1 -1
- package/dist/cli/upgrade.mjs +2 -2
- package/dist/cli/upgrade.mjs.map +1 -1
- package/dist/cli.cjs +5 -7
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +5 -7
- package/dist/cli.mjs.map +1 -1
- package/dist/commands/deploy.cjs +26 -18
- package/dist/commands/deploy.cjs.map +1 -1
- package/dist/commands/deploy.mjs +26 -18
- package/dist/commands/deploy.mjs.map +1 -1
- package/dist/commands/init.cjs +1 -1
- package/dist/commands/init.cjs.map +1 -1
- package/dist/commands/init.mjs +1 -1
- package/dist/commands/init.mjs.map +1 -1
- package/dist/commands/plugins.cjs +2 -2
- package/dist/commands/plugins.cjs.map +1 -1
- package/dist/commands/plugins.mjs +2 -2
- package/dist/commands/plugins.mjs.map +1 -1
- package/dist/commands/upgrade.cjs +31 -8
- package/dist/commands/upgrade.cjs.map +1 -1
- package/dist/commands/upgrade.mjs +31 -8
- package/dist/commands/upgrade.mjs.map +1 -1
- package/dist/components/dev-render.cjs +1 -1
- package/dist/components/dev-render.mjs +1 -1
- package/dist/config.cjs +3 -3
- package/dist/config.cjs.map +1 -1
- package/dist/config.mjs +3 -3
- package/dist/config.mjs.map +1 -1
- package/dist/contract.cjs +2 -0
- package/dist/contract.cjs.map +1 -1
- package/dist/contract.d.cts +3 -0
- package/dist/contract.d.mts +3 -0
- package/dist/contract.meta.cjs +2 -1
- package/dist/contract.meta.cjs.map +1 -1
- package/dist/contract.meta.d.cts +4 -1
- package/dist/contract.meta.d.mts +4 -1
- package/dist/contract.meta.mjs +2 -1
- package/dist/contract.meta.mjs.map +1 -1
- package/dist/contract.mjs +2 -0
- package/dist/contract.mjs.map +1 -1
- package/dist/db/driver.cjs +22 -2
- package/dist/db/driver.cjs.map +1 -1
- package/dist/db/driver.d.cts +13 -2
- package/dist/db/driver.d.mts +13 -2
- package/dist/db/driver.mjs +22 -3
- package/dist/db/driver.mjs.map +1 -1
- package/dist/db/index.cjs +1 -0
- package/dist/db/index.d.cts +2 -2
- package/dist/db/index.d.mts +2 -2
- package/dist/db/index.mjs +2 -2
- package/dist/deploy-diff.cjs +1 -1
- package/dist/deploy-diff.cjs.map +1 -1
- package/dist/deploy-diff.mjs +1 -1
- package/dist/deploy-diff.mjs.map +1 -1
- package/dist/dev-program.cjs +11 -2
- package/dist/dev-program.cjs.map +1 -1
- package/dist/dev-program.mjs +11 -3
- package/dist/dev-program.mjs.map +1 -1
- package/dist/image-deploy.cjs +103 -31
- package/dist/image-deploy.cjs.map +1 -1
- package/dist/image-deploy.mjs +103 -33
- package/dist/image-deploy.mjs.map +1 -1
- package/dist/internal/manifest-normalizer.cjs.map +1 -1
- package/dist/internal/manifest-normalizer.mjs.map +1 -1
- package/dist/plugin.d.cts +902 -1
- package/dist/plugin.d.mts +902 -1
- package/dist/publish.cjs +51 -2
- package/dist/publish.cjs.map +1 -1
- package/dist/publish.mjs +51 -4
- package/dist/publish.mjs.map +1 -1
- package/dist/resolution/session.cjs.map +1 -1
- package/dist/resolution/session.d.cts +5 -5
- package/dist/resolution/session.d.mts +5 -5
- package/dist/resolution/session.mjs.map +1 -1
- package/dist/storage-upload.cjs +7 -68
- package/dist/storage-upload.cjs.map +1 -1
- package/dist/storage-upload.mjs +7 -68
- package/dist/storage-upload.mjs.map +1 -1
- package/dist/types.d.cts +31 -1
- package/dist/types.d.mts +31 -1
- package/dist/ui/api.cjs +11 -69
- package/dist/ui/api.cjs.map +1 -1
- package/dist/ui/api.d.cts +2 -4
- package/dist/ui/api.d.mts +2 -4
- package/dist/ui/api.mjs +11 -69
- package/dist/ui/api.mjs.map +1 -1
- package/dist/ui/auth-guards.d.cts +78 -2
- package/dist/ui/auth-guards.d.mts +78 -2
- package/dist/ui/auth.cjs.map +1 -1
- package/dist/ui/auth.d.cts +4133 -7
- package/dist/ui/auth.d.mts +4133 -7
- package/dist/ui/auth.mjs.map +1 -1
- package/dist/ui/hydrate.cjs +2 -2
- package/dist/ui/hydrate.cjs.map +1 -1
- package/dist/ui/hydrate.mjs +2 -2
- package/dist/ui/hydrate.mjs.map +1 -1
- package/dist/utils/theme.cjs +2 -2
- package/dist/utils/theme.cjs.map +1 -1
- package/dist/utils/theme.mjs +2 -2
- package/dist/utils/theme.mjs.map +1 -1
- package/dist/version-manifest-resolve.cjs +55 -10
- package/dist/version-manifest-resolve.cjs.map +1 -1
- package/dist/version-manifest-resolve.mjs +53 -10
- package/dist/version-manifest-resolve.mjs.map +1 -1
- package/dist/workspace.cjs +26 -13
- package/dist/workspace.cjs.map +1 -1
- package/dist/workspace.mjs +26 -14
- package/dist/workspace.mjs.map +1 -1
- package/package.json +12 -10
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
let effect = require("effect");
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
let every_plugin_version_manifest = require("every-plugin/version-manifest");
|
|
4
|
+
|
|
5
|
+
//#region ../../apps/upload/src/client.ts
|
|
6
|
+
const BundleFileSchema = zod.z.object({
|
|
7
|
+
path: zod.z.string().min(1).max(512),
|
|
8
|
+
contentBase64: zod.z.string().min(1)
|
|
9
|
+
});
|
|
10
|
+
const UploadRequestSchema = zod.z.object({
|
|
11
|
+
account: zod.z.string().min(1),
|
|
12
|
+
gateway: zod.z.string().min(1),
|
|
13
|
+
workspace: zod.z.string().min(1),
|
|
14
|
+
files: zod.z.array(BundleFileSchema).min(1).max(1e4)
|
|
15
|
+
});
|
|
16
|
+
const UploadResponseSchema = zod.z.object({
|
|
17
|
+
stored: zod.z.number().int(),
|
|
18
|
+
/** files recognized as byte-identical to what the store already holds (SRI metadata match) and skipped */
|
|
19
|
+
unchanged: zod.z.number().int().optional(),
|
|
20
|
+
totalBytes: zod.z.number().int(),
|
|
21
|
+
integrity: zod.z.record(zod.z.string(), zod.z.string()),
|
|
22
|
+
storage: zod.z.enum(["s3", "memory"]).optional().describe("Resolved bundle-storage backend: `s3` (R2/MinIO, persistent) or `memory` (ephemeral — bytes are lost on restart)")
|
|
23
|
+
});
|
|
24
|
+
const NamespaceQuerySchema = zod.z.object({
|
|
25
|
+
account: zod.z.string().min(1),
|
|
26
|
+
gateway: zod.z.string().min(1)
|
|
27
|
+
});
|
|
28
|
+
const ListBundlesQuerySchema = NamespaceQuerySchema.extend({ workspace: zod.z.string().min(1).optional() });
|
|
29
|
+
const BundleObjectSummarySchema = zod.z.object({
|
|
30
|
+
key: zod.z.string(),
|
|
31
|
+
size: zod.z.number().int(),
|
|
32
|
+
lastModified: zod.z.string().nullable().optional()
|
|
33
|
+
});
|
|
34
|
+
const ListBundlesResultSchema = zod.z.object({
|
|
35
|
+
storage: zod.z.enum(["s3", "memory"]),
|
|
36
|
+
prefix: zod.z.string(),
|
|
37
|
+
objects: zod.z.array(BundleObjectSummarySchema),
|
|
38
|
+
truncated: zod.z.boolean()
|
|
39
|
+
});
|
|
40
|
+
const ListVersionsQuerySchema = NamespaceQuerySchema.extend({ workspace: zod.z.string().min(1) });
|
|
41
|
+
const VersionSummarySchema = zod.z.object({
|
|
42
|
+
version: zod.z.string().regex(/^[0-9a-f]{16}$/),
|
|
43
|
+
entry: zod.z.string(),
|
|
44
|
+
entryIntegrity: zod.z.string(),
|
|
45
|
+
gitSha: zod.z.string().optional(),
|
|
46
|
+
builtAt: zod.z.string().optional(),
|
|
47
|
+
fileCount: zod.z.number().int().optional(),
|
|
48
|
+
lastModified: zod.z.string().nullable().optional()
|
|
49
|
+
});
|
|
50
|
+
const ListVersionsResultSchema = zod.z.object({
|
|
51
|
+
storage: zod.z.enum(["s3", "memory"]),
|
|
52
|
+
versions: zod.z.array(VersionSummarySchema),
|
|
53
|
+
truncated: zod.z.boolean()
|
|
54
|
+
});
|
|
55
|
+
const IntegrityReportQuerySchema = NamespaceQuerySchema.extend({
|
|
56
|
+
workspace: zod.z.string().min(1),
|
|
57
|
+
version: zod.z.string().regex(/^[0-9a-f]{16}$/)
|
|
58
|
+
});
|
|
59
|
+
const IntegrityReportResultSchema = zod.z.object({
|
|
60
|
+
storage: zod.z.enum(["s3", "memory"]),
|
|
61
|
+
manifest: every_plugin_version_manifest.WorkspaceVersionManifestSchema,
|
|
62
|
+
/** SRI recompute of the manifest's entry object against `entryIntegrity`;
|
|
63
|
+
* null when the entry object is missing from the store. */
|
|
64
|
+
entryVerified: zod.z.boolean().nullable()
|
|
65
|
+
});
|
|
66
|
+
const STATUS_ATTEMPTS = 3;
|
|
67
|
+
const TRANSPORT_ATTEMPTS = 5;
|
|
68
|
+
const RETRYABLE_STATUSES = /* @__PURE__ */ new Set([
|
|
69
|
+
408,
|
|
70
|
+
429,
|
|
71
|
+
500,
|
|
72
|
+
502,
|
|
73
|
+
503,
|
|
74
|
+
504
|
|
75
|
+
]);
|
|
76
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
77
|
+
const backoffMs = (attempt) => 1e3 * attempt + Math.floor(Math.random() * 500);
|
|
78
|
+
var UploadTransferError = class UploadTransferError extends effect.Data.TaggedError("UploadTransferError") {
|
|
79
|
+
constructor(status, detail, note) {
|
|
80
|
+
super({
|
|
81
|
+
status,
|
|
82
|
+
detail,
|
|
83
|
+
note
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
get message() {
|
|
87
|
+
return `${this.detail}${this.note ?? ""}`;
|
|
88
|
+
}
|
|
89
|
+
withNote(note) {
|
|
90
|
+
return new UploadTransferError(this.status, this.detail, `${this.note ?? ""}${note}`);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
function describeTransferFailure(status, detail) {
|
|
94
|
+
const trimmed = detail.slice(0, 300);
|
|
95
|
+
if (status === 408 || /request timeout|bundle upload timed out/i.test(trimmed)) return `${trimmed} — the serving host timed out the upload; raise BOS_STORAGE_UPLOAD_TIMEOUT_MS there or upload smaller batches (BOS_MAX_BUNDLE_UPLOAD_BYTES)`;
|
|
96
|
+
try {
|
|
97
|
+
const parsed = JSON.parse(detail);
|
|
98
|
+
if (parsed?.code === "INTERNAL_SERVER_ERROR" && parsed?.message === "Internal Server Error") return `${trimmed} — the host hid the underlying error; check the host logs for the cause`;
|
|
99
|
+
} catch {}
|
|
100
|
+
return trimmed;
|
|
101
|
+
}
|
|
102
|
+
async function requestJson(config, label, path, parse, init) {
|
|
103
|
+
const fetchImpl = config.fetchImpl ?? fetch;
|
|
104
|
+
const headers = { ...init?.headers };
|
|
105
|
+
if (config.apiKey) headers["x-api-key"] = config.apiKey;
|
|
106
|
+
if (init?.body && !headers["content-type"]) headers["content-type"] = "application/json";
|
|
107
|
+
let lastError;
|
|
108
|
+
let transportFailures = 0;
|
|
109
|
+
let statusFailures = 0;
|
|
110
|
+
for (let attempt = 1; attempt <= TRANSPORT_ATTEMPTS; attempt++) {
|
|
111
|
+
try {
|
|
112
|
+
const response = await fetchImpl(`${config.origin.replace(/\/$/, "")}${path}`, {
|
|
113
|
+
...init,
|
|
114
|
+
headers: transportFailures > 0 ? {
|
|
115
|
+
...headers,
|
|
116
|
+
connection: "close"
|
|
117
|
+
} : headers
|
|
118
|
+
});
|
|
119
|
+
if (response.ok) return parse(await response.json());
|
|
120
|
+
const detail = await response.text().catch(() => "");
|
|
121
|
+
lastError = new UploadTransferError(response.status, `[upload] ${label} failed: ${response.status} ${describeTransferFailure(response.status, detail)}`);
|
|
122
|
+
if (!RETRYABLE_STATUSES.has(response.status)) break;
|
|
123
|
+
statusFailures += 1;
|
|
124
|
+
if (statusFailures >= STATUS_ATTEMPTS) break;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
transportFailures += 1;
|
|
127
|
+
lastError = new UploadTransferError(0, `[upload] ${label} failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
128
|
+
}
|
|
129
|
+
if (attempt < TRANSPORT_ATTEMPTS) await sleep(backoffMs(attempt));
|
|
130
|
+
}
|
|
131
|
+
if (lastError instanceof UploadTransferError && lastError.status === 0) lastError = lastError.withNote(" (Bun fetch note: re-run with fetch verbose diagnostics for detail)");
|
|
132
|
+
throw lastError ?? /* @__PURE__ */ new Error(`[upload] ${label} failed`);
|
|
133
|
+
}
|
|
134
|
+
const parseJsonBody = (label, schema) => {
|
|
135
|
+
return (response) => {
|
|
136
|
+
try {
|
|
137
|
+
return schema.parse(response);
|
|
138
|
+
} catch (error) {
|
|
139
|
+
throw new UploadTransferError(0, `[upload] ${label} returned an unexpected payload: ${error instanceof Error ? error.message : String(error)}`);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
function createUploadClient(config) {
|
|
144
|
+
return {
|
|
145
|
+
uploadBundle(input) {
|
|
146
|
+
const payload = UploadRequestSchema.parse(input);
|
|
147
|
+
return requestJson(config, `bundle upload for ${payload.workspace}`, "/api/storage/bundles", parseJsonBody("bundle upload", UploadResponseSchema), {
|
|
148
|
+
method: "POST",
|
|
149
|
+
body: JSON.stringify(payload)
|
|
150
|
+
});
|
|
151
|
+
},
|
|
152
|
+
listBundles(input) {
|
|
153
|
+
const query = new URLSearchParams({
|
|
154
|
+
account: input.account,
|
|
155
|
+
gateway: input.gateway
|
|
156
|
+
});
|
|
157
|
+
if (input.workspace) query.set("workspace", input.workspace);
|
|
158
|
+
return requestJson(config, "bundle listing", `/api/storage/bundles?${query.toString()}`, parseJsonBody("bundle listing", ListBundlesResultSchema), { method: "GET" });
|
|
159
|
+
},
|
|
160
|
+
listVersions(input) {
|
|
161
|
+
return requestJson(config, "version listing", `/api/storage/versions?${new URLSearchParams({
|
|
162
|
+
account: input.account,
|
|
163
|
+
gateway: input.gateway,
|
|
164
|
+
workspace: input.workspace
|
|
165
|
+
}).toString()}`, parseJsonBody("version listing", ListVersionsResultSchema), { method: "GET" });
|
|
166
|
+
},
|
|
167
|
+
integrityReport(input) {
|
|
168
|
+
return requestJson(config, "integrity report", `/api/storage/integrity?${new URLSearchParams({
|
|
169
|
+
account: input.account,
|
|
170
|
+
gateway: input.gateway,
|
|
171
|
+
workspace: input.workspace,
|
|
172
|
+
version: input.version
|
|
173
|
+
}).toString()}`, parseJsonBody("integrity report", IntegrityReportResultSchema), { method: "GET" });
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
//#endregion
|
|
179
|
+
exports.BundleFileSchema = BundleFileSchema;
|
|
180
|
+
exports.BundleObjectSummarySchema = BundleObjectSummarySchema;
|
|
181
|
+
exports.IntegrityReportResultSchema = IntegrityReportResultSchema;
|
|
182
|
+
exports.ListBundlesResultSchema = ListBundlesResultSchema;
|
|
183
|
+
exports.ListVersionsResultSchema = ListVersionsResultSchema;
|
|
184
|
+
exports.UploadRequestSchema = UploadRequestSchema;
|
|
185
|
+
exports.UploadResponseSchema = UploadResponseSchema;
|
|
186
|
+
exports.VersionSummarySchema = VersionSummarySchema;
|
|
187
|
+
exports.createUploadClient = createUploadClient;
|
|
188
|
+
//# sourceMappingURL=client.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.cjs","names":["z","WorkspaceVersionManifestSchema","Data"],"sources":["../../../../../../apps/upload/src/client.ts"],"sourcesContent":["import { Data } from \"effect\";\nimport { WorkspaceVersionManifestSchema } from \"every-plugin/version-manifest\";\nimport { z } from \"zod\";\n\nexport const BundleFileSchema = z.object({\n path: z.string().min(1).max(512),\n contentBase64: z.string().min(1),\n});\n\nexport const UploadRequestSchema = z.object({\n account: z.string().min(1),\n gateway: z.string().min(1),\n workspace: z.string().min(1),\n files: z.array(BundleFileSchema).min(1).max(10_000),\n});\n\nexport const UploadResponseSchema = z.object({\n stored: z.number().int(),\n /** files recognized as byte-identical to what the store already holds (SRI metadata match) and skipped */\n unchanged: z.number().int().optional(),\n totalBytes: z.number().int(),\n integrity: z.record(z.string(), z.string()),\n storage: z\n .enum([\"s3\", \"memory\"])\n .optional()\n .describe(\n \"Resolved bundle-storage backend: `s3` (R2/MinIO, persistent) or `memory` (ephemeral — bytes are lost on restart)\",\n ),\n});\n\nconst NamespaceQuerySchema = z.object({\n account: z.string().min(1),\n gateway: z.string().min(1),\n});\n\nexport const ListBundlesQuerySchema = NamespaceQuerySchema.extend({\n workspace: z.string().min(1).optional(),\n});\n\nexport const BundleObjectSummarySchema = z.object({\n key: z.string(),\n size: z.number().int(),\n lastModified: z.string().nullable().optional(),\n});\n\nexport const ListBundlesResultSchema = z.object({\n storage: z.enum([\"s3\", \"memory\"]),\n prefix: z.string(),\n objects: z.array(BundleObjectSummarySchema),\n truncated: z.boolean(),\n});\n\nexport const ListVersionsQuerySchema = NamespaceQuerySchema.extend({\n workspace: z.string().min(1),\n});\n\nexport const VersionSummarySchema = z.object({\n version: z.string().regex(/^[0-9a-f]{16}$/),\n entry: z.string(),\n entryIntegrity: z.string(),\n gitSha: z.string().optional(),\n builtAt: z.string().optional(),\n fileCount: z.number().int().optional(),\n lastModified: z.string().nullable().optional(),\n});\n\nexport const ListVersionsResultSchema = z.object({\n storage: z.enum([\"s3\", \"memory\"]),\n versions: z.array(VersionSummarySchema),\n truncated: z.boolean(),\n});\n\nexport const IntegrityReportQuerySchema = NamespaceQuerySchema.extend({\n workspace: z.string().min(1),\n version: z.string().regex(/^[0-9a-f]{16}$/),\n});\n\nexport const IntegrityReportResultSchema = z.object({\n storage: z.enum([\"s3\", \"memory\"]),\n manifest: WorkspaceVersionManifestSchema,\n /** SRI recompute of the manifest's entry object against `entryIntegrity`;\n * null when the entry object is missing from the store. */\n entryVerified: z.boolean().nullable(),\n});\n\nexport type BundleFile = z.infer<typeof BundleFileSchema>;\nexport type UploadRequest = z.infer<typeof UploadRequestSchema>;\nexport type UploadResponse = z.infer<typeof UploadResponseSchema>;\nexport type ListBundlesQuery = z.infer<typeof ListBundlesQuerySchema>;\nexport type BundleObjectSummary = z.infer<typeof BundleObjectSummarySchema>;\nexport type ListBundlesResult = z.infer<typeof ListBundlesResultSchema>;\nexport type ListVersionsQuery = z.infer<typeof ListVersionsQuerySchema>;\nexport type VersionSummary = z.infer<typeof VersionSummarySchema>;\nexport type ListVersionsResult = z.infer<typeof ListVersionsResultSchema>;\nexport type IntegrityReportQuery = z.infer<typeof IntegrityReportQuerySchema>;\nexport type IntegrityReportResult = z.infer<typeof IntegrityReportResultSchema>;\n\nexport interface UploadClientConfig {\n origin: string;\n apiKey?: string;\n fetchImpl?: typeof fetch;\n}\n\nexport interface UploadClient {\n uploadBundle(input: UploadRequest): Promise<UploadResponse>;\n listBundles(input: ListBundlesQuery): Promise<ListBundlesResult>;\n listVersions(input: ListVersionsQuery): Promise<ListVersionsResult>;\n integrityReport(input: IntegrityReportQuery): Promise<IntegrityReportResult>;\n}\n\nconst STATUS_ATTEMPTS = 3;\nconst TRANSPORT_ATTEMPTS = 5;\nconst RETRYABLE_STATUSES = new Set([408, 429, 500, 502, 503, 504]);\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\nconst backoffMs = (attempt: number) => 1000 * attempt + Math.floor(Math.random() * 500);\n\nclass UploadTransferError extends Data.TaggedError(\"UploadTransferError\")<{\n readonly status: number;\n readonly detail: string;\n readonly note?: string;\n}> {\n constructor(status: number, detail: string, note?: string) {\n super({ status, detail, note });\n }\n\n override get message() {\n return `${this.detail}${this.note ?? \"\"}`;\n }\n\n withNote(note: string) {\n return new UploadTransferError(this.status, this.detail, `${this.note ?? \"\"}${note}`);\n }\n}\n\nfunction describeTransferFailure(status: number, detail: string): string {\n const trimmed = detail.slice(0, 300);\n if (status === 408 || /request timeout|bundle upload timed out/i.test(trimmed)) {\n return `${trimmed} — the serving host timed out the upload; raise BOS_STORAGE_UPLOAD_TIMEOUT_MS there or upload smaller batches (BOS_MAX_BUNDLE_UPLOAD_BYTES)`;\n }\n try {\n const parsed = JSON.parse(detail) as { code?: unknown; message?: unknown };\n if (parsed?.code === \"INTERNAL_SERVER_ERROR\" && parsed?.message === \"Internal Server Error\") {\n return `${trimmed} — the host hid the underlying error; check the host logs for the cause`;\n }\n } catch {\n // not a JSON error body\n }\n return trimmed;\n}\n\nasync function requestJson<T>(\n config: UploadClientConfig,\n label: string,\n path: string,\n parse: (value: unknown) => T,\n init?: RequestInit,\n): Promise<T> {\n const fetchImpl = config.fetchImpl ?? fetch;\n const headers: Record<string, string> = { ...(init?.headers as Record<string, string>) };\n if (config.apiKey) headers[\"x-api-key\"] = config.apiKey;\n if (init?.body && !headers[\"content-type\"]) headers[\"content-type\"] = \"application/json\";\n\n let lastError: UploadTransferError | Error | undefined;\n let transportFailures = 0;\n let statusFailures = 0;\n for (let attempt = 1; attempt <= TRANSPORT_ATTEMPTS; attempt++) {\n try {\n const response = await fetchImpl(`${config.origin.replace(/\\/$/, \"\")}${path}`, {\n ...init,\n headers: transportFailures > 0 ? { ...headers, connection: \"close\" } : headers,\n });\n\n if (response.ok) {\n return parse(await response.json());\n }\n\n const detail = await response.text().catch(() => \"\");\n lastError = new UploadTransferError(\n response.status,\n `[upload] ${label} failed: ${response.status} ${describeTransferFailure(response.status, detail)}`,\n );\n if (!RETRYABLE_STATUSES.has(response.status)) break;\n statusFailures += 1;\n if (statusFailures >= STATUS_ATTEMPTS) break;\n } catch (error) {\n transportFailures += 1;\n lastError = new UploadTransferError(\n 0,\n `[upload] ${label} failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n\n if (attempt < TRANSPORT_ATTEMPTS) await sleep(backoffMs(attempt));\n }\n\n if (lastError instanceof UploadTransferError && lastError.status === 0) {\n lastError = lastError.withNote(\n \" (Bun fetch note: re-run with fetch verbose diagnostics for detail)\",\n );\n }\n throw lastError ?? new Error(`[upload] ${label} failed`);\n}\n\nconst parseJsonBody = <T>(label: string, schema: { parse: (value: unknown) => T }) => {\n return (response: unknown): T => {\n try {\n return schema.parse(response);\n } catch (error) {\n throw new UploadTransferError(\n 0,\n `[upload] ${label} returned an unexpected payload: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n };\n};\n\nexport function createUploadClient(config: UploadClientConfig): UploadClient {\n return {\n uploadBundle(input) {\n const payload = UploadRequestSchema.parse(input);\n return requestJson(\n config,\n `bundle upload for ${payload.workspace}`,\n \"/api/storage/bundles\",\n parseJsonBody(\"bundle upload\", UploadResponseSchema),\n { method: \"POST\", body: JSON.stringify(payload) },\n );\n },\n\n listBundles(input) {\n const query = new URLSearchParams({ account: input.account, gateway: input.gateway });\n if (input.workspace) query.set(\"workspace\", input.workspace);\n return requestJson(\n config,\n \"bundle listing\",\n `/api/storage/bundles?${query.toString()}`,\n parseJsonBody(\"bundle listing\", ListBundlesResultSchema),\n { method: \"GET\" },\n );\n },\n\n listVersions(input) {\n const query = new URLSearchParams({\n account: input.account,\n gateway: input.gateway,\n workspace: input.workspace,\n });\n return requestJson(\n config,\n \"version listing\",\n `/api/storage/versions?${query.toString()}`,\n parseJsonBody(\"version listing\", ListVersionsResultSchema),\n { method: \"GET\" },\n );\n },\n\n integrityReport(input) {\n const query = new URLSearchParams({\n account: input.account,\n gateway: input.gateway,\n workspace: input.workspace,\n version: input.version,\n });\n return requestJson(\n config,\n \"integrity report\",\n `/api/storage/integrity?${query.toString()}`,\n parseJsonBody(\"integrity report\", IntegrityReportResultSchema),\n { method: \"GET\" },\n );\n },\n };\n}\n"],"mappings":";;;;;AAIA,MAAa,mBAAmBA,MAAE,OAAO;CACvC,MAAMA,MAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG;CAC/B,eAAeA,MAAE,OAAO,CAAC,CAAC,IAAI,CAAC;AACjC,CAAC;AAED,MAAa,sBAAsBA,MAAE,OAAO;CAC1C,SAASA,MAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACzB,SAASA,MAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACzB,WAAWA,MAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAC3B,OAAOA,MAAE,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAM;AACpD,CAAC;AAED,MAAa,uBAAuBA,MAAE,OAAO;CAC3C,QAAQA,MAAE,OAAO,CAAC,CAAC,IAAI;;CAEvB,WAAWA,MAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;CACrC,YAAYA,MAAE,OAAO,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AM,CAClB;EACF;CACF;AACF"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { Data } from "effect";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { WorkspaceVersionManifestSchema } from "every-plugin/version-manifest";
|
|
4
|
+
|
|
5
|
+
//#region ../../apps/upload/src/client.ts
|
|
6
|
+
const BundleFileSchema = z.object({
|
|
7
|
+
path: z.string().min(1).max(512),
|
|
8
|
+
contentBase64: z.string().min(1)
|
|
9
|
+
});
|
|
10
|
+
const UploadRequestSchema = z.object({
|
|
11
|
+
account: z.string().min(1),
|
|
12
|
+
gateway: z.string().min(1),
|
|
13
|
+
workspace: z.string().min(1),
|
|
14
|
+
files: z.array(BundleFileSchema).min(1).max(1e4)
|
|
15
|
+
});
|
|
16
|
+
const UploadResponseSchema = z.object({
|
|
17
|
+
stored: z.number().int(),
|
|
18
|
+
/** files recognized as byte-identical to what the store already holds (SRI metadata match) and skipped */
|
|
19
|
+
unchanged: z.number().int().optional(),
|
|
20
|
+
totalBytes: z.number().int(),
|
|
21
|
+
integrity: z.record(z.string(), z.string()),
|
|
22
|
+
storage: z.enum(["s3", "memory"]).optional().describe("Resolved bundle-storage backend: `s3` (R2/MinIO, persistent) or `memory` (ephemeral — bytes are lost on restart)")
|
|
23
|
+
});
|
|
24
|
+
const NamespaceQuerySchema = z.object({
|
|
25
|
+
account: z.string().min(1),
|
|
26
|
+
gateway: z.string().min(1)
|
|
27
|
+
});
|
|
28
|
+
const ListBundlesQuerySchema = NamespaceQuerySchema.extend({ workspace: z.string().min(1).optional() });
|
|
29
|
+
const BundleObjectSummarySchema = z.object({
|
|
30
|
+
key: z.string(),
|
|
31
|
+
size: z.number().int(),
|
|
32
|
+
lastModified: z.string().nullable().optional()
|
|
33
|
+
});
|
|
34
|
+
const ListBundlesResultSchema = z.object({
|
|
35
|
+
storage: z.enum(["s3", "memory"]),
|
|
36
|
+
prefix: z.string(),
|
|
37
|
+
objects: z.array(BundleObjectSummarySchema),
|
|
38
|
+
truncated: z.boolean()
|
|
39
|
+
});
|
|
40
|
+
const ListVersionsQuerySchema = NamespaceQuerySchema.extend({ workspace: z.string().min(1) });
|
|
41
|
+
const VersionSummarySchema = z.object({
|
|
42
|
+
version: z.string().regex(/^[0-9a-f]{16}$/),
|
|
43
|
+
entry: z.string(),
|
|
44
|
+
entryIntegrity: z.string(),
|
|
45
|
+
gitSha: z.string().optional(),
|
|
46
|
+
builtAt: z.string().optional(),
|
|
47
|
+
fileCount: z.number().int().optional(),
|
|
48
|
+
lastModified: z.string().nullable().optional()
|
|
49
|
+
});
|
|
50
|
+
const ListVersionsResultSchema = z.object({
|
|
51
|
+
storage: z.enum(["s3", "memory"]),
|
|
52
|
+
versions: z.array(VersionSummarySchema),
|
|
53
|
+
truncated: z.boolean()
|
|
54
|
+
});
|
|
55
|
+
const IntegrityReportQuerySchema = NamespaceQuerySchema.extend({
|
|
56
|
+
workspace: z.string().min(1),
|
|
57
|
+
version: z.string().regex(/^[0-9a-f]{16}$/)
|
|
58
|
+
});
|
|
59
|
+
const IntegrityReportResultSchema = z.object({
|
|
60
|
+
storage: z.enum(["s3", "memory"]),
|
|
61
|
+
manifest: WorkspaceVersionManifestSchema,
|
|
62
|
+
/** SRI recompute of the manifest's entry object against `entryIntegrity`;
|
|
63
|
+
* null when the entry object is missing from the store. */
|
|
64
|
+
entryVerified: z.boolean().nullable()
|
|
65
|
+
});
|
|
66
|
+
const STATUS_ATTEMPTS = 3;
|
|
67
|
+
const TRANSPORT_ATTEMPTS = 5;
|
|
68
|
+
const RETRYABLE_STATUSES = /* @__PURE__ */ new Set([
|
|
69
|
+
408,
|
|
70
|
+
429,
|
|
71
|
+
500,
|
|
72
|
+
502,
|
|
73
|
+
503,
|
|
74
|
+
504
|
|
75
|
+
]);
|
|
76
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
77
|
+
const backoffMs = (attempt) => 1e3 * attempt + Math.floor(Math.random() * 500);
|
|
78
|
+
var UploadTransferError = class UploadTransferError extends Data.TaggedError("UploadTransferError") {
|
|
79
|
+
constructor(status, detail, note) {
|
|
80
|
+
super({
|
|
81
|
+
status,
|
|
82
|
+
detail,
|
|
83
|
+
note
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
get message() {
|
|
87
|
+
return `${this.detail}${this.note ?? ""}`;
|
|
88
|
+
}
|
|
89
|
+
withNote(note) {
|
|
90
|
+
return new UploadTransferError(this.status, this.detail, `${this.note ?? ""}${note}`);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
function describeTransferFailure(status, detail) {
|
|
94
|
+
const trimmed = detail.slice(0, 300);
|
|
95
|
+
if (status === 408 || /request timeout|bundle upload timed out/i.test(trimmed)) return `${trimmed} — the serving host timed out the upload; raise BOS_STORAGE_UPLOAD_TIMEOUT_MS there or upload smaller batches (BOS_MAX_BUNDLE_UPLOAD_BYTES)`;
|
|
96
|
+
try {
|
|
97
|
+
const parsed = JSON.parse(detail);
|
|
98
|
+
if (parsed?.code === "INTERNAL_SERVER_ERROR" && parsed?.message === "Internal Server Error") return `${trimmed} — the host hid the underlying error; check the host logs for the cause`;
|
|
99
|
+
} catch {}
|
|
100
|
+
return trimmed;
|
|
101
|
+
}
|
|
102
|
+
async function requestJson(config, label, path, parse, init) {
|
|
103
|
+
const fetchImpl = config.fetchImpl ?? fetch;
|
|
104
|
+
const headers = { ...init?.headers };
|
|
105
|
+
if (config.apiKey) headers["x-api-key"] = config.apiKey;
|
|
106
|
+
if (init?.body && !headers["content-type"]) headers["content-type"] = "application/json";
|
|
107
|
+
let lastError;
|
|
108
|
+
let transportFailures = 0;
|
|
109
|
+
let statusFailures = 0;
|
|
110
|
+
for (let attempt = 1; attempt <= TRANSPORT_ATTEMPTS; attempt++) {
|
|
111
|
+
try {
|
|
112
|
+
const response = await fetchImpl(`${config.origin.replace(/\/$/, "")}${path}`, {
|
|
113
|
+
...init,
|
|
114
|
+
headers: transportFailures > 0 ? {
|
|
115
|
+
...headers,
|
|
116
|
+
connection: "close"
|
|
117
|
+
} : headers
|
|
118
|
+
});
|
|
119
|
+
if (response.ok) return parse(await response.json());
|
|
120
|
+
const detail = await response.text().catch(() => "");
|
|
121
|
+
lastError = new UploadTransferError(response.status, `[upload] ${label} failed: ${response.status} ${describeTransferFailure(response.status, detail)}`);
|
|
122
|
+
if (!RETRYABLE_STATUSES.has(response.status)) break;
|
|
123
|
+
statusFailures += 1;
|
|
124
|
+
if (statusFailures >= STATUS_ATTEMPTS) break;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
transportFailures += 1;
|
|
127
|
+
lastError = new UploadTransferError(0, `[upload] ${label} failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
128
|
+
}
|
|
129
|
+
if (attempt < TRANSPORT_ATTEMPTS) await sleep(backoffMs(attempt));
|
|
130
|
+
}
|
|
131
|
+
if (lastError instanceof UploadTransferError && lastError.status === 0) lastError = lastError.withNote(" (Bun fetch note: re-run with fetch verbose diagnostics for detail)");
|
|
132
|
+
throw lastError ?? /* @__PURE__ */ new Error(`[upload] ${label} failed`);
|
|
133
|
+
}
|
|
134
|
+
const parseJsonBody = (label, schema) => {
|
|
135
|
+
return (response) => {
|
|
136
|
+
try {
|
|
137
|
+
return schema.parse(response);
|
|
138
|
+
} catch (error) {
|
|
139
|
+
throw new UploadTransferError(0, `[upload] ${label} returned an unexpected payload: ${error instanceof Error ? error.message : String(error)}`);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
function createUploadClient(config) {
|
|
144
|
+
return {
|
|
145
|
+
uploadBundle(input) {
|
|
146
|
+
const payload = UploadRequestSchema.parse(input);
|
|
147
|
+
return requestJson(config, `bundle upload for ${payload.workspace}`, "/api/storage/bundles", parseJsonBody("bundle upload", UploadResponseSchema), {
|
|
148
|
+
method: "POST",
|
|
149
|
+
body: JSON.stringify(payload)
|
|
150
|
+
});
|
|
151
|
+
},
|
|
152
|
+
listBundles(input) {
|
|
153
|
+
const query = new URLSearchParams({
|
|
154
|
+
account: input.account,
|
|
155
|
+
gateway: input.gateway
|
|
156
|
+
});
|
|
157
|
+
if (input.workspace) query.set("workspace", input.workspace);
|
|
158
|
+
return requestJson(config, "bundle listing", `/api/storage/bundles?${query.toString()}`, parseJsonBody("bundle listing", ListBundlesResultSchema), { method: "GET" });
|
|
159
|
+
},
|
|
160
|
+
listVersions(input) {
|
|
161
|
+
return requestJson(config, "version listing", `/api/storage/versions?${new URLSearchParams({
|
|
162
|
+
account: input.account,
|
|
163
|
+
gateway: input.gateway,
|
|
164
|
+
workspace: input.workspace
|
|
165
|
+
}).toString()}`, parseJsonBody("version listing", ListVersionsResultSchema), { method: "GET" });
|
|
166
|
+
},
|
|
167
|
+
integrityReport(input) {
|
|
168
|
+
return requestJson(config, "integrity report", `/api/storage/integrity?${new URLSearchParams({
|
|
169
|
+
account: input.account,
|
|
170
|
+
gateway: input.gateway,
|
|
171
|
+
workspace: input.workspace,
|
|
172
|
+
version: input.version
|
|
173
|
+
}).toString()}`, parseJsonBody("integrity report", IntegrityReportResultSchema), { method: "GET" });
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
//#endregion
|
|
179
|
+
export { BundleFileSchema, BundleObjectSummarySchema, IntegrityReportResultSchema, ListBundlesResultSchema, ListVersionsResultSchema, UploadRequestSchema, UploadResponseSchema, VersionSummarySchema, createUploadClient };
|
|
180
|
+
//# sourceMappingURL=client.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.mjs","names":[],"sources":["../../../../../../apps/upload/src/client.ts"],"sourcesContent":["import { Data } from \"effect\";\nimport { WorkspaceVersionManifestSchema } from \"every-plugin/version-manifest\";\nimport { z } from \"zod\";\n\nexport const BundleFileSchema = z.object({\n path: z.string().min(1).max(512),\n contentBase64: z.string().min(1),\n});\n\nexport const UploadRequestSchema = z.object({\n account: z.string().min(1),\n gateway: z.string().min(1),\n workspace: z.string().min(1),\n files: z.array(BundleFileSchema).min(1).max(10_000),\n});\n\nexport const UploadResponseSchema = z.object({\n stored: z.number().int(),\n /** files recognized as byte-identical to what the store already holds (SRI metadata match) and skipped */\n unchanged: z.number().int().optional(),\n totalBytes: z.number().int(),\n integrity: z.record(z.string(), z.string()),\n storage: z\n .enum([\"s3\", \"memory\"])\n .optional()\n .describe(\n \"Resolved bundle-storage backend: `s3` (R2/MinIO, persistent) or `memory` (ephemeral — bytes are lost on restart)\",\n ),\n});\n\nconst NamespaceQuerySchema = z.object({\n account: z.string().min(1),\n gateway: z.string().min(1),\n});\n\nexport const ListBundlesQuerySchema = NamespaceQuerySchema.extend({\n workspace: z.string().min(1).optional(),\n});\n\nexport const BundleObjectSummarySchema = z.object({\n key: z.string(),\n size: z.number().int(),\n lastModified: z.string().nullable().optional(),\n});\n\nexport const ListBundlesResultSchema = z.object({\n storage: z.enum([\"s3\", \"memory\"]),\n prefix: z.string(),\n objects: z.array(BundleObjectSummarySchema),\n truncated: z.boolean(),\n});\n\nexport const ListVersionsQuerySchema = NamespaceQuerySchema.extend({\n workspace: z.string().min(1),\n});\n\nexport const VersionSummarySchema = z.object({\n version: z.string().regex(/^[0-9a-f]{16}$/),\n entry: z.string(),\n entryIntegrity: z.string(),\n gitSha: z.string().optional(),\n builtAt: z.string().optional(),\n fileCount: z.number().int().optional(),\n lastModified: z.string().nullable().optional(),\n});\n\nexport const ListVersionsResultSchema = z.object({\n storage: z.enum([\"s3\", \"memory\"]),\n versions: z.array(VersionSummarySchema),\n truncated: z.boolean(),\n});\n\nexport const IntegrityReportQuerySchema = NamespaceQuerySchema.extend({\n workspace: z.string().min(1),\n version: z.string().regex(/^[0-9a-f]{16}$/),\n});\n\nexport const IntegrityReportResultSchema = z.object({\n storage: z.enum([\"s3\", \"memory\"]),\n manifest: WorkspaceVersionManifestSchema,\n /** SRI recompute of the manifest's entry object against `entryIntegrity`;\n * null when the entry object is missing from the store. */\n entryVerified: z.boolean().nullable(),\n});\n\nexport type BundleFile = z.infer<typeof BundleFileSchema>;\nexport type UploadRequest = z.infer<typeof UploadRequestSchema>;\nexport type UploadResponse = z.infer<typeof UploadResponseSchema>;\nexport type ListBundlesQuery = z.infer<typeof ListBundlesQuerySchema>;\nexport type BundleObjectSummary = z.infer<typeof BundleObjectSummarySchema>;\nexport type ListBundlesResult = z.infer<typeof ListBundlesResultSchema>;\nexport type ListVersionsQuery = z.infer<typeof ListVersionsQuerySchema>;\nexport type VersionSummary = z.infer<typeof VersionSummarySchema>;\nexport type ListVersionsResult = z.infer<typeof ListVersionsResultSchema>;\nexport type IntegrityReportQuery = z.infer<typeof IntegrityReportQuerySchema>;\nexport type IntegrityReportResult = z.infer<typeof IntegrityReportResultSchema>;\n\nexport interface UploadClientConfig {\n origin: string;\n apiKey?: string;\n fetchImpl?: typeof fetch;\n}\n\nexport interface UploadClient {\n uploadBundle(input: UploadRequest): Promise<UploadResponse>;\n listBundles(input: ListBundlesQuery): Promise<ListBundlesResult>;\n listVersions(input: ListVersionsQuery): Promise<ListVersionsResult>;\n integrityReport(input: IntegrityReportQuery): Promise<IntegrityReportResult>;\n}\n\nconst STATUS_ATTEMPTS = 3;\nconst TRANSPORT_ATTEMPTS = 5;\nconst RETRYABLE_STATUSES = new Set([408, 429, 500, 502, 503, 504]);\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\nconst backoffMs = (attempt: number) => 1000 * attempt + Math.floor(Math.random() * 500);\n\nclass UploadTransferError extends Data.TaggedError(\"UploadTransferError\")<{\n readonly status: number;\n readonly detail: string;\n readonly note?: string;\n}> {\n constructor(status: number, detail: string, note?: string) {\n super({ status, detail, note });\n }\n\n override get message() {\n return `${this.detail}${this.note ?? \"\"}`;\n }\n\n withNote(note: string) {\n return new UploadTransferError(this.status, this.detail, `${this.note ?? \"\"}${note}`);\n }\n}\n\nfunction describeTransferFailure(status: number, detail: string): string {\n const trimmed = detail.slice(0, 300);\n if (status === 408 || /request timeout|bundle upload timed out/i.test(trimmed)) {\n return `${trimmed} — the serving host timed out the upload; raise BOS_STORAGE_UPLOAD_TIMEOUT_MS there or upload smaller batches (BOS_MAX_BUNDLE_UPLOAD_BYTES)`;\n }\n try {\n const parsed = JSON.parse(detail) as { code?: unknown; message?: unknown };\n if (parsed?.code === \"INTERNAL_SERVER_ERROR\" && parsed?.message === \"Internal Server Error\") {\n return `${trimmed} — the host hid the underlying error; check the host logs for the cause`;\n }\n } catch {\n // not a JSON error body\n }\n return trimmed;\n}\n\nasync function requestJson<T>(\n config: UploadClientConfig,\n label: string,\n path: string,\n parse: (value: unknown) => T,\n init?: RequestInit,\n): Promise<T> {\n const fetchImpl = config.fetchImpl ?? fetch;\n const headers: Record<string, string> = { ...(init?.headers as Record<string, string>) };\n if (config.apiKey) headers[\"x-api-key\"] = config.apiKey;\n if (init?.body && !headers[\"content-type\"]) headers[\"content-type\"] = \"application/json\";\n\n let lastError: UploadTransferError | Error | undefined;\n let transportFailures = 0;\n let statusFailures = 0;\n for (let attempt = 1; attempt <= TRANSPORT_ATTEMPTS; attempt++) {\n try {\n const response = await fetchImpl(`${config.origin.replace(/\\/$/, \"\")}${path}`, {\n ...init,\n headers: transportFailures > 0 ? { ...headers, connection: \"close\" } : headers,\n });\n\n if (response.ok) {\n return parse(await response.json());\n }\n\n const detail = await response.text().catch(() => \"\");\n lastError = new UploadTransferError(\n response.status,\n `[upload] ${label} failed: ${response.status} ${describeTransferFailure(response.status, detail)}`,\n );\n if (!RETRYABLE_STATUSES.has(response.status)) break;\n statusFailures += 1;\n if (statusFailures >= STATUS_ATTEMPTS) break;\n } catch (error) {\n transportFailures += 1;\n lastError = new UploadTransferError(\n 0,\n `[upload] ${label} failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n\n if (attempt < TRANSPORT_ATTEMPTS) await sleep(backoffMs(attempt));\n }\n\n if (lastError instanceof UploadTransferError && lastError.status === 0) {\n lastError = lastError.withNote(\n \" (Bun fetch note: re-run with fetch verbose diagnostics for detail)\",\n );\n }\n throw lastError ?? new Error(`[upload] ${label} failed`);\n}\n\nconst parseJsonBody = <T>(label: string, schema: { parse: (value: unknown) => T }) => {\n return (response: unknown): T => {\n try {\n return schema.parse(response);\n } catch (error) {\n throw new UploadTransferError(\n 0,\n `[upload] ${label} returned an unexpected payload: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n };\n};\n\nexport function createUploadClient(config: UploadClientConfig): UploadClient {\n return {\n uploadBundle(input) {\n const payload = UploadRequestSchema.parse(input);\n return requestJson(\n config,\n `bundle upload for ${payload.workspace}`,\n \"/api/storage/bundles\",\n parseJsonBody(\"bundle upload\", UploadResponseSchema),\n { method: \"POST\", body: JSON.stringify(payload) },\n );\n },\n\n listBundles(input) {\n const query = new URLSearchParams({ account: input.account, gateway: input.gateway });\n if (input.workspace) query.set(\"workspace\", input.workspace);\n return requestJson(\n config,\n \"bundle listing\",\n `/api/storage/bundles?${query.toString()}`,\n parseJsonBody(\"bundle listing\", ListBundlesResultSchema),\n { method: \"GET\" },\n );\n },\n\n listVersions(input) {\n const query = new URLSearchParams({\n account: input.account,\n gateway: input.gateway,\n workspace: input.workspace,\n });\n return requestJson(\n config,\n \"version listing\",\n `/api/storage/versions?${query.toString()}`,\n parseJsonBody(\"version listing\", ListVersionsResultSchema),\n { method: \"GET\" },\n );\n },\n\n integrityReport(input) {\n const query = new URLSearchParams({\n account: input.account,\n gateway: input.gateway,\n workspace: input.workspace,\n version: input.version,\n });\n return requestJson(\n config,\n \"integrity report\",\n `/api/storage/integrity?${query.toString()}`,\n parseJsonBody(\"integrity report\", IntegrityReportResultSchema),\n { method: \"GET\" },\n );\n },\n };\n}\n"],"mappings":";;;;;AAIA,MAAa,mBAAmB,EAAE,OAAO;CACvC,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG;CAC/B,eAAe,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;AACjC,CAAC;AAED,MAAa,sBAAsB,EAAE,OAAO;CAC1C,SAAS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MAAM;IACf,SAAS,MAAM;IACf,WAAW,MAAM;GACnB,CAI+B,CAAC,CAAC,SAAS,KACxC,cAAc,mBAAmB,wBAAwB,GACzD,EAAE,QAAQ,MAAM,CAClB;EACF;EAEA,gBAAgB,OAAO;GAOrB,OAAO,YACL,QACA,oBACA,0BAA0B,IATV,gBAAgB;IAChC,SAAS,MAAM;IACf,SAAS,MAAM;IACf,WAAW,MAAM;IACjB,SAAS,MAAM;GACjB,CAIgC,CAAC,CAAC,SAAS,KACzC,cAAc,oBAAoB,2BAA2B,GAC7D,EAAE,QAAQ,MAAM,CAClB;EACF;CACF;AACF"}
|
package/dist/auth-login.cjs
CHANGED
package/dist/auth-login.mjs
CHANGED
package/dist/build.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
2
|
const require_config = require('./config.cjs');
|
|
3
|
-
const require_timing = require('./cli/timing.cjs');
|
|
4
3
|
const require_run = require('./utils/run.cjs');
|
|
4
|
+
const require_theme = require('./utils/theme.cjs');
|
|
5
|
+
const require_timing = require('./cli/timing.cjs');
|
|
5
6
|
const require_workspace = require('./workspace.cjs');
|
|
6
7
|
const require_shared_deps = require('./shared-deps.cjs');
|
|
7
8
|
const require_string = require('./utils/string.cjs');
|
|
8
|
-
const require_theme = require('./utils/theme.cjs');
|
|
9
9
|
let node_process = require("node:process");
|
|
10
10
|
node_process = require_runtime.__toESM(node_process, 1);
|
|
11
11
|
let node_fs_promises = require("node:fs/promises");
|
package/dist/build.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { resolveLocalDevelopmentPath } from "./config.mjs";
|
|
2
|
-
import { formatDuration } from "./cli/timing.mjs";
|
|
3
2
|
import { run } from "./utils/run.mjs";
|
|
3
|
+
import { colors, icons } from "./utils/theme.mjs";
|
|
4
|
+
import { formatDuration } from "./cli/timing.mjs";
|
|
4
5
|
import { ensureFreshDeps, findWorkspaceRoot } from "./workspace.mjs";
|
|
5
6
|
import { syncResolvedSharedDeps } from "./shared-deps.mjs";
|
|
6
7
|
import { padRight } from "./utils/string.mjs";
|
|
7
|
-
import { colors, icons } from "./utils/theme.mjs";
|
|
8
8
|
import process from "node:process";
|
|
9
9
|
import { access, readFile } from "node:fs/promises";
|
|
10
10
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_bundle_path = require('./bundle-path.cjs');
|
|
3
4
|
const require_config = require('./config.cjs');
|
|
4
5
|
const require_bundle_cache = require('./bundle-cache.cjs');
|
|
5
6
|
let node_fs = require("node:fs");
|
|
@@ -43,25 +44,16 @@ const MIME_TYPES = {
|
|
|
43
44
|
".txt": "text/plain",
|
|
44
45
|
".xml": "application/xml"
|
|
45
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Own-namespace path for a bundle URL: the shared URL→staged-path mapping,
|
|
49
|
+
* narrowed to the runtime identity — a URL whose encoded namespace differs
|
|
50
|
+
* from `namespace.account`/`namespace.gateway` must fall to the network/cache
|
|
51
|
+
* path, never serve a sibling namespace's staged bytes.
|
|
52
|
+
*/
|
|
46
53
|
function bundleUrlToLocalPath(url, namespace) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
parsed = new URL(url);
|
|
50
|
-
} catch {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") return null;
|
|
54
|
-
const prefix = `/bundles/${encodeURIComponent(namespace.account)}/${encodeURIComponent(namespace.gateway)}/`;
|
|
55
|
-
if (!parsed.pathname.startsWith(prefix)) return null;
|
|
56
|
-
let rest;
|
|
57
|
-
try {
|
|
58
|
-
rest = decodeURIComponent(parsed.pathname.slice(prefix.length));
|
|
59
|
-
} catch {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
if (!rest || rest.endsWith("/")) return null;
|
|
54
|
+
const filePath = require_bundle_path.bundleUrlToStagedPath(url, namespace.bundleDir);
|
|
55
|
+
if (!filePath) return null;
|
|
63
56
|
const nsDir = node_path.default.resolve(namespace.bundleDir, namespace.account, namespace.gateway);
|
|
64
|
-
const filePath = node_path.default.resolve(nsDir, rest);
|
|
65
57
|
if (filePath !== nsDir && !filePath.startsWith(nsDir + node_path.default.sep)) return null;
|
|
66
58
|
return filePath;
|
|
67
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle-fs-resolve.cjs","names":["Schema","path","Context","Effect","readFile","cacheControlOf","Layer","ManagedRuntime","bundleCachePath","writeBundleCache","readBundleCache","isAppDescriptorPath","readFileSync","existsSync","bundleCacheRoot"],"sources":["../src/bundle-fs-resolve.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { Context, Effect, Layer, ManagedRuntime, Schema } from \"effect\";\nimport { cacheControlOf } from \"every-plugin/build/artifact-names\";\nimport {\n bundleCachePath,\n bundleCacheRoot,\n readBundleCache,\n writeBundleCache,\n} from \"./bundle-cache\";\nimport { isAppDescriptorPath } from \"./config\";\n\n/**\n * Local-first bundle resolution (ADR 0011 amendment; unified policy, ADR 0021\n * amendment): a self-contained runtime image stages its own namespace under\n * `BOS_BUNDLE_DIR` as `bundles/<account>/<gateway>/<workspace>/…` and consumes\n * those bytes directly from disk; a miss falls through to the network, so a\n * partially-staged namespace boots over the wire instead of failing. The\n * registry tier (children, `BOS_BUNDLE_DIR` unset) keeps the network fetch —\n * the namespace guard below only ever matches the runtime's own\n * account/gateway, never another runtime's layout.\n */\n\nexport interface BundleNamespace {\n readonly bundleDir: string;\n readonly account: string;\n readonly gateway: string;\n}\n\nexport class BundleReadError extends Schema.TaggedError<BundleReadError>()(\"BundleReadError\", {\n path: Schema.String,\n cause: Schema.optional(Schema.Unknown),\n}) {}\n\nconst MIME_TYPES: Record<string, string> = {\n \".js\": \"text/javascript\",\n \".mjs\": \"text/javascript\",\n \".cjs\": \"text/javascript\",\n \".css\": \"text/css\",\n \".json\": \"application/json\",\n \".map\": \"application/json\",\n \".svg\": \"image/svg+xml\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".gif\": \"image/gif\",\n \".webp\": \"image/webp\",\n \".avif\": \"image/avif\",\n \".ico\": \"image/x-icon\",\n \".html\": \"text/html\",\n \".htm\": \"text/html\",\n \".webmanifest\": \"application/manifest+json\",\n \".md\": \"text/markdown\",\n \".ts\": \"text/plain\",\n \".woff\": \"font/woff\",\n \".woff2\": \"font/woff2\",\n \".ttf\": \"font/ttf\",\n \".otf\": \"font/otf\",\n \".eot\": \"application/vnd.ms-fontobject\",\n \".wasm\": \"application/wasm\",\n \".txt\": \"text/plain\",\n \".xml\": \"application/xml\",\n};\n\nexport function bundleUrlToLocalPath(url: string, namespace: BundleNamespace): string | null {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return null;\n }\n if (parsed.protocol !== \"https:\" && parsed.protocol !== \"http:\") return null;\n\n const prefix = `/bundles/${encodeURIComponent(namespace.account)}/${encodeURIComponent(namespace.gateway)}/`;\n if (!parsed.pathname.startsWith(prefix)) return null;\n\n let rest: string;\n try {\n rest = decodeURIComponent(parsed.pathname.slice(prefix.length));\n } catch {\n return null;\n }\n if (!rest || rest.endsWith(\"/\")) return null;\n\n // BOS_BUNDLE_DIR holds `<account>/<gateway>/<workspace>/…` directly (the\n // same layout host/src/routes/bundles.ts serves) — resolve and contain\n // within the OWN namespace, never a sibling one.\n const nsDir = path.resolve(namespace.bundleDir, namespace.account, namespace.gateway);\n const filePath = path.resolve(nsDir, rest);\n if (filePath !== nsDir && !filePath.startsWith(nsDir + path.sep)) return null;\n\n return filePath;\n}\n\nexport class BundleResolver extends Context.Service<\n BundleResolver,\n {\n /** Resolve a fetch target from the staged namespace; null = miss or not our namespace — fall through to the network. */\n readonly lookup: (input: string | URL | Request) => Effect.Effect<Response | null>;\n }\n>()(\"everything-dev/bundle-fs-resolve/BundleResolver\") {\n static layer(namespace: BundleNamespace): Layer.Layer<BundleResolver> {\n const respond = Effect.fn(\"BundleResolver.respond\")(function* (\n url: string,\n ): Effect.fn.Return<Response | null, never> {\n const filePath = bundleUrlToLocalPath(url, namespace);\n if (!filePath) return null;\n const bytes = yield* Effect.tryPromise({\n try: () => readFile(filePath),\n catch: (cause) => new BundleReadError({ path: filePath, cause }),\n }).pipe(Effect.catchTag(\"BundleReadError\", () => Effect.succeed(null)));\n if (bytes === null) return null;\n const name = path.basename(filePath);\n const contentType =\n MIME_TYPES[path.extname(name).toLowerCase()] ?? \"application/octet-stream\";\n return new Response(new Uint8Array(bytes), {\n headers: {\n \"content-type\": contentType,\n \"cache-control\": cacheControlOf(name),\n etag: `\"${Buffer.from(bytes.subarray(0, 4096)).toString(\"base64\").slice(0, 24)}\"`,\n },\n });\n });\n\n return Layer.effect(\n BundleResolver,\n Effect.succeed(\n BundleResolver.of({\n lookup: (input) => {\n const url =\n typeof input === \"string\" ? input : input instanceof URL ? input.href : input.url;\n return respond(url);\n },\n }),\n ),\n );\n }\n}\n\nexport interface BundleFetchHandle {\n readonly uninstall: () => Promise<void>;\n}\n\nexport interface BundleFetchOptions {\n /** Own-namespace FS resolution — requires a staged `BOS_BUNDLE_DIR`. */\n namespace?: BundleNamespace;\n /**\n * Foreign-namespace stale-if-error cache (child tier): `/bundles/…` URLs\n * outside the own namespace write through to disk on success and serve\n * the last-known-good bytes when the origin fails. Enabled implicitly\n * when `namespace` is present (deployment contexts), or explicitly via\n * `BOS_BUNDLE_CACHE_DIR`.\n */\n cacheDir?: string;\n}\n\ntype FetchImpl = typeof globalThis.fetch;\n\nconst staleResponse = (bytes: Uint8Array, url: string): Response => {\n const name = url.split(\"?\")[0].split(\"/\").pop() ?? \"\";\n const contentType = MIME_TYPES[path.extname(name).toLowerCase()] ?? \"application/octet-stream\";\n return new Response(bytes.slice().buffer, {\n status: 200,\n headers: { \"content-type\": contentType, \"x-bundle-cache\": \"stale\" },\n });\n};\n\n/**\n * Installs the resolver as a global fetch interceptor — the one seam every\n * boot-time consumer shares (config manifest discovery, contract-type\n * fetches, orchestrator host loading, MF remoteEntry/identity probes).\n * One layered resolution policy: staged disk → network → stale-if-error.\n * Own-namespace URLs resolve from the staged directory and fall through to\n * the original fetch on a miss (a partially-staged namespace boots over the\n * wire instead of failing); a miss never touches the write-through cache —\n * for the own namespace the staged disk IS the resilience artifact. Foreign\n * `/bundles/…` URLs get the network with the stale-if-error cache; every\n * other URL falls through to the original fetch untouched. Inert when\n * neither a staged namespace nor a cache is configured.\n */\nexport function installGlobalBundleFetch(options: BundleFetchOptions): BundleFetchHandle {\n const namespace = options.namespace;\n const cacheDir = options.cacheDir;\n const runtime = namespace ? ManagedRuntime.make(BundleResolver.layer(namespace)) : null;\n const original: FetchImpl = globalThis.fetch;\n const patched = (async (input: Parameters<FetchImpl>[0], init?: Parameters<FetchImpl>[1]) => {\n const url = typeof input === \"string\" ? input : input instanceof URL ? input.href : input.url;\n\n if (namespace && bundleUrlToLocalPath(url, namespace)) {\n if (!runtime) throw new Error(\"unreachable: resolver runtime missing\");\n const response = await runtime.runPromise(\n Effect.gen(function* () {\n const resolver = yield* BundleResolver;\n return yield* resolver.lookup(input);\n }),\n );\n if (response !== null) return response;\n return original(input, init);\n }\n\n if (cacheDir !== undefined && bundleCachePath(url, { cacheDir })) {\n return (async () => {\n try {\n const response = await original(input, init);\n if (response.ok) {\n try {\n const bytes = new Uint8Array(await response.clone().arrayBuffer());\n await writeBundleCache(url, bytes, { cacheDir });\n } catch {\n // write-through is best-effort\n }\n } else {\n const cached = await readBundleCache(url, { cacheDir });\n if (cached) return staleResponse(cached, url);\n }\n return response;\n } catch (error) {\n const cached = await readBundleCache(url, { cacheDir });\n if (cached) return staleResponse(cached, url);\n throw error;\n }\n })();\n }\n\n return original(input, init);\n }) as FetchImpl;\n const originalPreconnect = (original as Partial<FetchImpl>).preconnect;\n if (originalPreconnect) {\n patched.preconnect = originalPreconnect.bind(original);\n }\n globalThis.fetch = patched;\n return {\n uninstall: async () => {\n if (globalThis.fetch === patched) {\n globalThis.fetch = original;\n }\n if (runtime) await runtime.dispose();\n },\n };\n}\n\n/**\n * Boot-time installer for the CLI: derives the own namespace from\n * `BOS_BUNDLE_DIR` plus the runtime identity (`BOS_ACCOUNT`/`BOS_GATEWAY`\n * registry env taking precedence over the bos.config.json fields), and the\n * foreign-namespace cache from `BOS_BUNDLE_CACHE_DIR`. Tier auto-detection\n * (ADR 0021): an identity whose namespace is not actually staged under the\n * bundle dir drops to the registry tier — plain network fetch — instead of\n * deterministically 404ing own-namespace URLs against a foreign image's\n * staged bytes. Never throws — a missing or malformed identity leaves the\n * default network fetch in place.\n */\nexport function installBundleFetchFromEnv(input: {\n configPath?: string | null;\n}): BundleFetchHandle | null {\n const bundleDir = process.env.BOS_BUNDLE_DIR;\n const cacheDir = process.env.BOS_BUNDLE_CACHE_DIR;\n if (!bundleDir && cacheDir === undefined) return null;\n\n let configAccount: string | undefined;\n let configGateway: string | undefined;\n const configPath = input.configPath;\n if (configPath && !isAppDescriptorPath(configPath)) {\n try {\n const parsed = JSON.parse(readFileSync(configPath, \"utf8\")) as {\n account?: string;\n domain?: string;\n };\n configAccount = parsed.account;\n configGateway = parsed.domain;\n } catch {\n // unreadable config — identity may still come from the registry env\n }\n }\n\n const account = process.env.BOS_ACCOUNT ?? configAccount;\n const gateway = process.env.BOS_GATEWAY ?? configGateway;\n if (bundleDir && (!account || !gateway)) return null;\n\n let namespace: BundleNamespace | undefined;\n if (bundleDir && account && gateway) {\n if (existsSync(path.join(bundleDir, account, gateway))) {\n namespace = { bundleDir, account, gateway };\n } else {\n console.warn(\n `[bundles] staged namespace ${account}/${gateway} not found under ${bundleDir} — registry tier (network fetch)`,\n );\n }\n }\n return installGlobalBundleFetch({\n namespace,\n cacheDir: cacheDir ?? (nam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ile","cacheControlOf","Layer","ManagedRuntime","bundleCachePath","writeBundleCache","readBundleCache","isAppDescriptorPath","readFileSync","existsSync","bundleCacheRoot"],"sources":["../src/bundle-fs-resolve.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { Context, Effect, Layer, ManagedRuntime, Schema } from \"effect\";\nimport { cacheControlOf } from \"every-plugin/build/artifact-names\";\nimport {\n bundleCachePath,\n bundleCacheRoot,\n readBundleCache,\n writeBundleCache,\n} from \"./bundle-cache\";\nimport { bundleUrlToStagedPath } from \"./bundle-path\";\nimport { isAppDescriptorPath } from \"./config\";\n\n/**\n * Local-first bundle resolution (ADR 0011 amendment; unified policy, ADR 0021\n * amendment): a self-contained runtime image stages its own namespace under\n * `BOS_BUNDLE_DIR` as `bundles/<account>/<gateway>/<workspace>/…` and consumes\n * those bytes directly from disk; a miss falls through to the network, so a\n * partially-staged namespace boots over the wire instead of failing. The\n * registry tier (children, `BOS_BUNDLE_DIR` unset) keeps the network fetch —\n * the namespace guard below only ever matches the runtime's own\n * account/gateway, never another runtime's layout.\n */\n\nexport interface BundleNamespace {\n readonly bundleDir: string;\n readonly account: string;\n readonly gateway: string;\n}\n\nexport class BundleReadError extends Schema.TaggedError<BundleReadError>()(\"BundleReadError\", {\n path: Schema.String,\n cause: Schema.optional(Schema.Unknown),\n}) {}\n\nconst MIME_TYPES: Record<string, string> = {\n \".js\": \"text/javascript\",\n \".mjs\": \"text/javascript\",\n \".cjs\": \"text/javascript\",\n \".css\": \"text/css\",\n \".json\": \"application/json\",\n \".map\": \"application/json\",\n \".svg\": \"image/svg+xml\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".gif\": \"image/gif\",\n \".webp\": \"image/webp\",\n \".avif\": \"image/avif\",\n \".ico\": \"image/x-icon\",\n \".html\": \"text/html\",\n \".htm\": \"text/html\",\n \".webmanifest\": \"application/manifest+json\",\n \".md\": \"text/markdown\",\n \".ts\": \"text/plain\",\n \".woff\": \"font/woff\",\n \".woff2\": \"font/woff2\",\n \".ttf\": \"font/ttf\",\n \".otf\": \"font/otf\",\n \".eot\": \"application/vnd.ms-fontobject\",\n \".wasm\": \"application/wasm\",\n \".txt\": \"text/plain\",\n \".xml\": \"application/xml\",\n};\n\n/**\n * Own-namespace path for a bundle URL: the shared URL→staged-path mapping,\n * narrowed to the runtime identity — a URL whose encoded namespace differs\n * from `namespace.account`/`namespace.gateway` must fall to the network/cache\n * path, never serve a sibling namespace's staged bytes.\n */\nexport function bundleUrlToLocalPath(url: string, namespace: BundleNamespace): string | null {\n const filePath = bundleUrlToStagedPath(url, namespace.bundleDir);\n if (!filePath) return null;\n\n const nsDir = path.resolve(namespace.bundleDir, namespace.account, namespace.gateway);\n if (filePath !== nsDir && !filePath.startsWith(nsDir + path.sep)) return null;\n\n return filePath;\n}\n\nexport class BundleResolver extends Context.Service<\n BundleResolver,\n {\n /** Resolve a fetch target from the staged namespace; null = miss or not our namespace — fall through to the network. */\n readonly lookup: (input: string | URL | Request) => Effect.Effect<Response | null>;\n }\n>()(\"everything-dev/bundle-fs-resolve/BundleResolver\") {\n static layer(namespace: BundleNamespace): Layer.Layer<BundleResolver> {\n const respond = Effect.fn(\"BundleResolver.respond\")(function* (\n url: string,\n ): Effect.fn.Return<Response | null, never> {\n const filePath = bundleUrlToLocalPath(url, namespace);\n if (!filePath) return null;\n const bytes = yield* Effect.tryPromise({\n try: () => readFile(filePath),\n catch: (cause) => new BundleReadError({ path: filePath, cause }),\n }).pipe(Effect.catchTag(\"BundleReadError\", () => Effect.succeed(null)));\n if (bytes === null) return null;\n const name = path.basename(filePath);\n const contentType =\n MIME_TYPES[path.extname(name).toLowerCase()] ?? \"application/octet-stream\";\n return new Response(new Uint8Array(bytes), {\n headers: {\n \"content-type\": contentType,\n \"cache-control\": cacheControlOf(name),\n etag: `\"${Buffer.from(bytes.subarray(0, 4096)).toString(\"base64\").slice(0, 24)}\"`,\n },\n });\n });\n\n return Layer.effect(\n BundleResolver,\n Effect.succeed(\n BundleResolver.of({\n lookup: (input) => {\n const url =\n typeof input === \"string\" ? input : input instanceof URL ? input.href : input.url;\n return respond(url);\n },\n }),\n ),\n );\n }\n}\n\nexport interface BundleFetchHandle {\n readonly uninstall: () => Promise<void>;\n}\n\nexport interface BundleFetchOptions {\n /** Own-namespace FS resolution — requires a staged `BOS_BUNDLE_DIR`. */\n namespace?: BundleNamespace;\n /**\n * Foreign-namespace stale-if-error cache (child tier): `/bundles/…` URLs\n * outside the own namespace write through to disk on success and serve\n * the last-known-good bytes when the origin fails. Enabled implicitly\n * when `namespace` is present (deployment contexts), or explicitly via\n * `BOS_BUNDLE_CACHE_DIR`.\n */\n cacheDir?: string;\n}\n\ntype FetchImpl = typeof globalThis.fetch;\n\nconst staleResponse = (bytes: Uint8Array, url: string): Response => {\n const name = url.split(\"?\")[0].split(\"/\").pop() ?? \"\";\n const contentType = MIME_TYPES[path.extname(name).toLowerCase()] ?? \"application/octet-stream\";\n return new Response(bytes.slice().buffer, {\n status: 200,\n headers: { \"content-type\": contentType, \"x-bundle-cache\": \"stale\" },\n });\n};\n\n/**\n * Installs the resolver as a global fetch interceptor — the one seam every\n * boot-time consumer shares (config manifest discovery, contract-type\n * fetches, orchestrator host loading, MF remoteEntry/identity probes).\n * One layered resolution policy: staged disk → network → stale-if-error.\n * Own-namespace URLs resolve from the staged directory and fall through to\n * the original fetch on a miss (a partially-staged namespace boots over the\n * wire instead of failing); a miss never touches the write-through cache —\n * for the own namespace the staged disk IS the resilience artifact. Foreign\n * `/bundles/…` URLs get the network with the stale-if-error cache; every\n * other URL falls through to the original fetch untouched. Inert when\n * neither a staged namespace nor a cache is configured.\n */\nexport function installGlobalBundleFetch(options: BundleFetchOptions): BundleFetchHandle {\n const namespace = options.namespace;\n const cacheDir = options.cacheDir;\n const runtime = namespace ? ManagedRuntime.make(BundleResolver.layer(namespace)) : null;\n const original: FetchImpl = globalThis.fetch;\n const patched = (async (input: Parameters<FetchImpl>[0], init?: Parameters<FetchImpl>[1]) => {\n const url = typeof input === \"string\" ? input : input instanceof URL ? input.href : input.url;\n\n if (namespace && bundleUrlToLocalPath(url, namespace)) {\n if (!runtime) throw new Error(\"unreachable: resolver runtime missing\");\n const response = await runtime.runPromise(\n Effect.gen(function* () {\n const resolver = yield* BundleResolver;\n return yield* resolver.lookup(input);\n }),\n );\n if (response !== null) return response;\n return original(input, init);\n }\n\n if (cacheDir !== undefined && bundleCachePath(url, { cacheDir })) {\n return (async () => {\n try {\n const response = await original(input, init);\n if (response.ok) {\n try {\n const bytes = new Uint8Array(await response.clone().arrayBuffer());\n await writeBundleCache(url, bytes, { cacheDir });\n } catch {\n // write-through is best-effort\n }\n } else {\n const cached = await readBundleCache(url, { cacheDir });\n if (cached) return staleResponse(cached, url);\n }\n return response;\n } catch (error) {\n const cached = await readBundleCache(url, { cacheDir });\n if (cached) return staleResponse(cached, url);\n throw error;\n }\n })();\n }\n\n return original(input, init);\n }) as FetchImpl;\n const originalPreconnect = (original as Partial<FetchImpl>).preconnect;\n if (originalPreconnect) {\n patched.preconnect = originalPreconnect.bind(original);\n }\n globalThis.fetch = patched;\n return {\n uninstall: async () => {\n if (globalThis.fetch === patched) {\n globalThis.fetch = original;\n }\n if (runtime) await runtime.dispose();\n },\n };\n}\n\n/**\n * Boot-time installer for the CLI: derives the own namespace from\n * `BOS_BUNDLE_DIR` plus the runtime identity (`BOS_ACCOUNT`/`BOS_GATEWAY`\n * registry env taking precedence over the bos.config.json fields), and the\n * foreign-namespace cache from `BOS_BUNDLE_CACHE_DIR`. Tier auto-detection\n * (ADR 0021): an identity whose namespace is not actually staged under the\n * bundle dir drops to the registry tier — plain network fetch — instead of\n * deterministically 404ing own-namespace URLs against a foreign image's\n * staged bytes. Never throws — a missing or malformed identity leaves the\n * default network fetch in place.\n */\nexport function installBundleFetchFromEnv(input: {\n configPath?: string | null;\n}): BundleFetchHandle | null {\n const bundleDir = process.env.BOS_BUNDLE_DIR;\n const cacheDir = process.env.BOS_BUNDLE_CACHE_DIR;\n if (!bundleDir && cacheDir === undefined) return null;\n\n let configAccount: string | undefined;\n let configGateway: string | undefined;\n const configPath = input.configPath;\n if (configPath && !isAppDescriptorPath(configPath)) {\n try {\n const parsed = JSON.parse(readFileSync(configPath, \"utf8\")) as {\n account?: string;\n domain?: string;\n };\n configAccount = parsed.account;\n configGateway = parsed.domain;\n } catch {\n // unreadable config — identity may still come from the registry env\n }\n }\n\n const account = process.env.BOS_ACCOUNT ?? configAccount;\n const gateway = process.env.BOS_GATEWAY ?? configGateway;\n if (bundleDir && (!account || !gateway)) return null;\n\n let namespace: BundleNamespace | undefined;\n if (bundleDir && account && gateway) {\n if (existsSync(path.join(bundleDir, account, gateway))) {\n namespace = { bundleDir, account, gateway };\n } else {\n console.warn(\n `[bundles] staged namespace ${account}/${gateway} not found under ${bundleDir} — registry tier (network fetch)`,\n );\n }\n }\n return installGlobalBundleFetch({\n namespace,\n cacheDir: cacheDir ?? (namespace ? bundleCacheRoot() : undefined),\n });\n}\n"],"mappings":";;;;;;;;;;;;;AA+BA,IAAa,kBAAb,cAAqCA,cAAO,YAA6B,CAAC,CAAC,mBAAmB;CAC5F,MAAMA,cAAO;CACb,OAAOA,cAAO,SAASA,cAAO,OAAO;AACvC,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAM,aAAqC;CACzC,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACT,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,gBAAgB;CAChB,OAAO;CACP,OAAO;CACP,SAAS;CACT,UAAU;CACV,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,QAAQ;AACV;;;;;;;AAQA,SAAgB,qBAAqB,KAAa,WAA2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;EAAQ;OAE1C,QAAQ,KACN,8BAA8B,QAAQ,GAAG,QAAQ,mBAAmB,UAAU,iCAChF;CAEJ;CACA,OAAO,yBAAyB;EAC9B;EACA,UAAU,aAAa,YAAYa,qCAAgB,IAAI;CACzD,CAAC;AACH"}
|
|
@@ -20,6 +20,12 @@ declare const BundleReadError_base: Schema.Class<BundleReadError, Schema.TaggedS
|
|
|
20
20
|
readonly cause: Schema.optional<Schema.Unknown>;
|
|
21
21
|
}>, import("effect/Cause").YieldableError>;
|
|
22
22
|
declare class BundleReadError extends BundleReadError_base {}
|
|
23
|
+
/**
|
|
24
|
+
* Own-namespace path for a bundle URL: the shared URL→staged-path mapping,
|
|
25
|
+
* narrowed to the runtime identity — a URL whose encoded namespace differs
|
|
26
|
+
* from `namespace.account`/`namespace.gateway` must fall to the network/cache
|
|
27
|
+
* path, never serve a sibling namespace's staged bytes.
|
|
28
|
+
*/
|
|
23
29
|
declare function bundleUrlToLocalPath(url: string, namespace: BundleNamespace): string | null;
|
|
24
30
|
declare const BundleResolver_base: Context.ServiceClass<BundleResolver, "everything-dev/bundle-fs-resolve/BundleResolver", {
|
|
25
31
|
/** Resolve a fetch target from the staged namespace; null = miss or not our namespace — fall through to the network. */
|
|
@@ -20,6 +20,12 @@ declare const BundleReadError_base: Schema.Class<BundleReadError, Schema.TaggedS
|
|
|
20
20
|
readonly cause: Schema.optional<Schema.Unknown>;
|
|
21
21
|
}>, import("effect/Cause").YieldableError>;
|
|
22
22
|
declare class BundleReadError extends BundleReadError_base {}
|
|
23
|
+
/**
|
|
24
|
+
* Own-namespace path for a bundle URL: the shared URL→staged-path mapping,
|
|
25
|
+
* narrowed to the runtime identity — a URL whose encoded namespace differs
|
|
26
|
+
* from `namespace.account`/`namespace.gateway` must fall to the network/cache
|
|
27
|
+
* path, never serve a sibling namespace's staged bytes.
|
|
28
|
+
*/
|
|
23
29
|
declare function bundleUrlToLocalPath(url: string, namespace: BundleNamespace): string | null;
|
|
24
30
|
declare const BundleResolver_base: Context.ServiceClass<BundleResolver, "everything-dev/bundle-fs-resolve/BundleResolver", {
|
|
25
31
|
/** Resolve a fetch target from the staged namespace; null = miss or not our namespace — fall through to the network. */
|