@feltdb/feltkit 0.3.6 → 0.3.8
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/appboundry/engine.wasm +0 -0
- package/dist/app.d.ts +5 -1
- package/dist/app.js +9 -1
- package/dist/app.js.map +1 -1
- package/dist/appboundry/build.d.ts +106 -0
- package/dist/appboundry/build.js +306 -0
- package/dist/appboundry/build.js.map +1 -0
- package/dist/appboundry/codec.d.ts +6 -0
- package/dist/appboundry/codec.js +98 -0
- package/dist/appboundry/codec.js.map +1 -0
- package/dist/appboundry/guest-index.d.ts +9 -0
- package/dist/appboundry/guest-index.js +10 -0
- package/dist/appboundry/guest-index.js.map +1 -0
- package/dist/appboundry/guest.d.ts +3 -0
- package/dist/appboundry/guest.js +300 -0
- package/dist/appboundry/guest.js.map +1 -0
- package/dist/appboundry/wasm.d.ts +12 -0
- package/dist/appboundry/wasm.js +68 -0
- package/dist/appboundry/wasm.js.map +1 -0
- package/dist/cli/cloudflare.d.ts +20 -0
- package/dist/cli/cloudflare.js +128 -0
- package/dist/cli/cloudflare.js.map +1 -0
- package/dist/cli/deploy.d.ts +7 -4
- package/dist/cli/deploy.js +213 -6
- package/dist/cli/deploy.js.map +1 -1
- package/dist/cli/main.js +133 -37
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/vercel.d.ts +8 -2
- package/dist/cli/vercel.js +14 -8
- package/dist/cli/vercel.js.map +1 -1
- package/dist/dashboard/assets/index-CUgBiFRg.js +15 -0
- package/dist/dashboard/assets/index-dGaQg6ak.css +1 -0
- package/dist/dashboard/index.html +3 -3
- package/dist/dashboard/theme.js +9 -4
- package/dist/runtime/assemble.d.ts +2 -0
- package/dist/runtime/assemble.js +45 -0
- package/dist/runtime/assemble.js.map +1 -0
- package/dist/runtime/capabilities.d.ts +2 -0
- package/dist/runtime/capabilities.js +24 -0
- package/dist/runtime/capabilities.js.map +1 -0
- package/dist/runtime/collections.d.ts +7 -0
- package/dist/runtime/collections.js +18 -0
- package/dist/runtime/collections.js.map +1 -0
- package/dist/runtime/data.d.ts +2 -6
- package/dist/runtime/data.js +2 -16
- package/dist/runtime/data.js.map +1 -1
- package/dist/runtime/deployment.js +2 -2
- package/dist/runtime/loader.d.ts +2 -1
- package/dist/runtime/loader.js +2 -38
- package/dist/runtime/loader.js.map +1 -1
- package/dist/runtime/projects.d.ts +3 -0
- package/dist/runtime/projects.js +1 -1
- package/dist/runtime/projects.js.map +1 -1
- package/dist/runtime/runtime.js +16 -28
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/storage-check.js +1 -1
- package/dist/runtime/storage-check.js.map +1 -1
- package/dist/runtime/targets.d.ts +23 -9
- package/dist/runtime/targets.js +53 -4
- package/dist/runtime/targets.js.map +1 -1
- package/dist/server/production.d.ts +2 -2
- package/dist/server/production.js +3 -3
- package/dist/server/production.js.map +1 -1
- package/package.json +7 -3
- package/skills/.claude-plugin/marketplace.json +1 -1
- package/skills/.claude-plugin/plugin.json +1 -1
- package/skills/feltkit-operations/SKILL.md +2 -1
- package/dist/dashboard/assets/index-B-ra0AY9.css +0 -1
- package/dist/dashboard/assets/index-DLFqtVAO.js +0 -15
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@feltdb/feltkit` as application code sees it inside an AppBoundry artifact: the
|
|
3
|
+
* definition API, schemas and errors. Nothing here reaches Node, a database, or the
|
|
4
|
+
* network; `feltkit build --target appboundry` fails if application code imports
|
|
5
|
+
* anything else from FeltKit.
|
|
6
|
+
*/
|
|
7
|
+
export { feltkit, FeltKitApp, RESERVED_COLLECTIONS } from "../app.js";
|
|
8
|
+
export { s } from "../schema.js";
|
|
9
|
+
export { FeltKitError, fail, isFeltKitError } from "../errors.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@feltdb/feltkit` as application code sees it inside an AppBoundry artifact: the
|
|
3
|
+
* definition API, schemas and errors. Nothing here reaches Node, a database, or the
|
|
4
|
+
* network; `feltkit build --target appboundry` fails if application code imports
|
|
5
|
+
* anything else from FeltKit.
|
|
6
|
+
*/
|
|
7
|
+
export { feltkit, FeltKitApp, RESERVED_COLLECTIONS } from "../app.js";
|
|
8
|
+
export { s } from "../schema.js";
|
|
9
|
+
export { FeltKitError, fail, isFeltKitError } from "../errors.js";
|
|
10
|
+
//# sourceMappingURL=guest-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guest-index.js","sourceRoot":"","sources":["../../src/appboundry/guest-index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The FeltKit runtime inside an AppBoundry artifact (guest ABI appboundry-guest/1).
|
|
3
|
+
*
|
|
4
|
+
* This file is bundled, with the application's own `feltkit/` modules, into the program
|
|
5
|
+
* that the guest engine (appboundry/engine) evaluates. It runs handlers with the same
|
|
6
|
+
* `ctx` an application gets from `feltkit dev`, but it owns nothing: every read, write,
|
|
7
|
+
* and service effect is an operation it asks the host for, and the host (AppBoundry)
|
|
8
|
+
* validates each one against the artifact's manifest before performing it.
|
|
9
|
+
*
|
|
10
|
+
* __abg.describe() what this program implements (checked by the host on load)
|
|
11
|
+
* __abg.invoke(json) start one function call
|
|
12
|
+
* __abg.resume(json) results of the operations the call was waiting for
|
|
13
|
+
* __abg.poll() { state: "suspended", calls } | { state: "returned", value } | { state: "failed", error }
|
|
14
|
+
*
|
|
15
|
+
* Suspend and resume: an operation is a promise that stays pending until the host
|
|
16
|
+
* answers it. When the engine has run every job it can, poll() hands the host the
|
|
17
|
+
* operations still outstanding (several, when a handler awaits them together).
|
|
18
|
+
*
|
|
19
|
+
* Kept from FeltKit: argument, record, and `returns` validation with the application's
|
|
20
|
+
* own schemas, FeltKit's error shapes and messages, and `ctx.auth`. The host checks the
|
|
21
|
+
* same schemas and permissions again, independently: the guest is never trusted to
|
|
22
|
+
* enforce them. Writes are buffered by the host, which commits them atomically when the
|
|
23
|
+
* handler returns and discards them if it throws.
|
|
24
|
+
*/
|
|
25
|
+
import { grantsPermission } from "@appport/authorization";
|
|
26
|
+
import { FeltKitError, isFeltKitError } from "../errors.js";
|
|
27
|
+
import { validate } from "../schema.js";
|
|
28
|
+
import { assemble } from "../runtime/assemble.js";
|
|
29
|
+
import { CollectionResolver } from "../runtime/collections.js";
|
|
30
|
+
import { fromBase64, toBase64, utf8Decode, utf8Encode, installTextCodecs } from "./codec.js";
|
|
31
|
+
export const GUEST_ABI = "appboundry-guest/1";
|
|
32
|
+
const UNSUPPORTED = (what) => new FeltKitError("CONFIGURATION", `${what} is not available in an AppBoundry artifact.`, {
|
|
33
|
+
hint: "`feltkit build --target appboundry` refuses applications that use it; this call should not have been reachable.",
|
|
34
|
+
});
|
|
35
|
+
/** Install `globalThis.__abg` for the modules of one application. */
|
|
36
|
+
export function installGuest(namespaces, producer) {
|
|
37
|
+
installTextCodecs();
|
|
38
|
+
const project = assemble(namespaces);
|
|
39
|
+
const resolver = new CollectionResolver(project.app.collections);
|
|
40
|
+
let pending = new Map();
|
|
41
|
+
let outbox = [];
|
|
42
|
+
let logs = [];
|
|
43
|
+
let settled = null;
|
|
44
|
+
let active = false;
|
|
45
|
+
let nextId = 1;
|
|
46
|
+
const host = (op, payload) => new Promise((resolve, reject) => {
|
|
47
|
+
const id = nextId++;
|
|
48
|
+
pending.set(id, { resolve: resolve, reject });
|
|
49
|
+
outbox.push({ id, op, ...payload });
|
|
50
|
+
});
|
|
51
|
+
const log = (level) => (message, fields) => {
|
|
52
|
+
logs.push({ level, message: String(message), ...(fields ? { fields: plain(fields) } : {}) });
|
|
53
|
+
};
|
|
54
|
+
const errorJSON = (error, production) => {
|
|
55
|
+
if (isFeltKitError(error))
|
|
56
|
+
return error.toJSON();
|
|
57
|
+
const message = error?.message ?? String(error);
|
|
58
|
+
log("error")(`Unhandled error: ${message}`, error?.stack ? { stack: error.stack } : undefined);
|
|
59
|
+
if (production)
|
|
60
|
+
return { code: "INTERNAL", message: "Internal error." };
|
|
61
|
+
return { code: "INTERNAL", message, hint: "This error was thrown by application code. Throw FeltKitError (or use fail()) to return a structured error." };
|
|
62
|
+
};
|
|
63
|
+
const run = async (fn, invocation) => {
|
|
64
|
+
const parsed = validate(fn.argsSchema, invocation.args ?? {});
|
|
65
|
+
if (!parsed.ok) {
|
|
66
|
+
throw new FeltKitError("INVALID_ARGUMENT", `Invalid arguments for ${invocation.function}: ${parsed.issues.map((i) => `${i.path}: ${i.message}`).join("; ")}`, {
|
|
67
|
+
details: { issues: parsed.issues },
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const writable = fn.kind === "mutation";
|
|
71
|
+
const ctx = {
|
|
72
|
+
db: database(resolver, host, writable),
|
|
73
|
+
auth: authContext(invocation.principal, invocation.permissions),
|
|
74
|
+
services: services(host, writable),
|
|
75
|
+
environment: invocation.environment,
|
|
76
|
+
requestId: invocation.requestId,
|
|
77
|
+
log: { info: log("info"), warn: log("warn"), error: log("error") },
|
|
78
|
+
};
|
|
79
|
+
if (writable) {
|
|
80
|
+
Object.defineProperty(ctx, "agent", { enumerable: true, get: () => { throw UNSUPPORTED("ctx.agent"); } });
|
|
81
|
+
Object.defineProperty(ctx, "unsafe", { enumerable: true, get: () => { throw UNSUPPORTED("ctx.unsafe.feltdb"); } });
|
|
82
|
+
}
|
|
83
|
+
const value = await fn.handler(ctx, parsed.value);
|
|
84
|
+
if (fn.returns) {
|
|
85
|
+
const output = validate(fn.returns, value);
|
|
86
|
+
if (!output.ok) {
|
|
87
|
+
throw new FeltKitError("INTERNAL", `${invocation.function} returned a value that does not match its \`returns\` schema: ${output.issues.map((i) => `${i.path}: ${i.message}`).join("; ")}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return value === undefined ? null : value;
|
|
91
|
+
};
|
|
92
|
+
const status = () => {
|
|
93
|
+
const drained = logs;
|
|
94
|
+
logs = [];
|
|
95
|
+
if (settled) {
|
|
96
|
+
const done = { ...settled, logs: [...settled.logs, ...drained] };
|
|
97
|
+
active = false;
|
|
98
|
+
settled = null;
|
|
99
|
+
pending = new Map();
|
|
100
|
+
outbox = [];
|
|
101
|
+
return done;
|
|
102
|
+
}
|
|
103
|
+
const calls = outbox;
|
|
104
|
+
outbox = [];
|
|
105
|
+
return { state: "suspended", calls, logs: drained };
|
|
106
|
+
};
|
|
107
|
+
globalThis.__abg = {
|
|
108
|
+
describe() {
|
|
109
|
+
return JSON.stringify({
|
|
110
|
+
ok: true,
|
|
111
|
+
abi: GUEST_ABI,
|
|
112
|
+
producer,
|
|
113
|
+
application: project.app.name,
|
|
114
|
+
functions: [...project.functions.entries()].map(([name, fn]) => ({ name, kind: fn.kind })).sort((a, b) => a.name.localeCompare(b.name)),
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
invoke(json) {
|
|
118
|
+
if (active)
|
|
119
|
+
throw new Error("A call is already running in this instance.");
|
|
120
|
+
active = true;
|
|
121
|
+
settled = null;
|
|
122
|
+
const invocation = JSON.parse(json);
|
|
123
|
+
const production = invocation.environment?.production === true;
|
|
124
|
+
const fn = project.functions.get(invocation.function);
|
|
125
|
+
if (!fn) {
|
|
126
|
+
settled = { state: "failed", error: new FeltKitError("FUNCTION_NOT_FOUND", `No query or mutation named "${invocation.function}".`).toJSON(), logs: [] };
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
run(fn, invocation).then((value) => { settled = { state: "returned", value: plain(value), logs: [] }; }, (error) => { settled = { state: "failed", error: errorJSON(error, production), logs: [] }; });
|
|
130
|
+
},
|
|
131
|
+
resume(json) {
|
|
132
|
+
for (const result of JSON.parse(json)) {
|
|
133
|
+
const waiting = pending.get(result.id);
|
|
134
|
+
if (!waiting)
|
|
135
|
+
continue;
|
|
136
|
+
pending.delete(result.id);
|
|
137
|
+
if (result.ok)
|
|
138
|
+
waiting.resolve(result.value);
|
|
139
|
+
else {
|
|
140
|
+
const error = result.error ?? { code: "INTERNAL", message: "The host refused the operation." };
|
|
141
|
+
waiting.reject(new FeltKitError(error.code, error.message, { ...(error.details !== undefined ? { details: error.details } : {}), ...(error.hint ? { hint: error.hint } : {}) }));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
poll() {
|
|
146
|
+
return JSON.stringify(status());
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** A JSON-safe copy: what crosses the boundary is data, never live objects. */
|
|
151
|
+
function plain(value) {
|
|
152
|
+
if (value === undefined)
|
|
153
|
+
return null;
|
|
154
|
+
return JSON.parse(JSON.stringify(value, (_key, v) => (v instanceof Uint8Array ? { $bytes: toBase64(v) } : v)));
|
|
155
|
+
}
|
|
156
|
+
function authContext(principal, granted) {
|
|
157
|
+
const permissions = Object.freeze([...granted]);
|
|
158
|
+
return Object.freeze({
|
|
159
|
+
principal,
|
|
160
|
+
permissions,
|
|
161
|
+
has: (permission) => grantsPermission([...permissions], permission),
|
|
162
|
+
require(permission) {
|
|
163
|
+
if (!principal)
|
|
164
|
+
throw new FeltKitError("UNAUTHORIZED", "Authentication is required");
|
|
165
|
+
if (!grantsPermission([...permissions], permission))
|
|
166
|
+
throw new FeltKitError("FORBIDDEN", `Missing permission: ${permission}`);
|
|
167
|
+
},
|
|
168
|
+
requirePrincipal() {
|
|
169
|
+
if (!principal)
|
|
170
|
+
throw new FeltKitError("UNAUTHORIZED", "Authentication is required");
|
|
171
|
+
return principal;
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function stripSystem(value) {
|
|
176
|
+
const { id: _id, __version: _v, ...rest } = value;
|
|
177
|
+
return rest;
|
|
178
|
+
}
|
|
179
|
+
function validateRecord(resolver, name, value) {
|
|
180
|
+
const definition = resolver.resolve(name);
|
|
181
|
+
const result = validate(definition.schema, value);
|
|
182
|
+
if (!result.ok) {
|
|
183
|
+
throw new FeltKitError("VALIDATION_FAILED", `Invalid "${definition.name}" record: ${result.issues.map((i) => `${i.path}: ${i.message}`).join("; ")}`, {
|
|
184
|
+
details: { collection: definition.name, issues: result.issues },
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/** `ctx.db`. Reads and writes are host operations; the host keeps the mutation's pending writes. */
|
|
189
|
+
function database(resolver, host, writable) {
|
|
190
|
+
const name = (ref) => resolver.resolve(ref).name;
|
|
191
|
+
const reader = {
|
|
192
|
+
get: (ref, id) => {
|
|
193
|
+
const collection = name(ref);
|
|
194
|
+
if (typeof id !== "string" || !id)
|
|
195
|
+
throw new FeltKitError("INVALID_ARGUMENT", "get() needs a record id.");
|
|
196
|
+
return host("db.get", { collection, key: id });
|
|
197
|
+
},
|
|
198
|
+
find: (ref, filter, options = {}) => host("db.find", { collection: name(ref), filter: definedOnly(filter), options: plain(options) }),
|
|
199
|
+
query: (ref, request) => host("db.query", { collection: name(ref), request: plain(request ?? {}) }),
|
|
200
|
+
count: (ref, filter) => host("db.count", { collection: name(ref), filter: definedOnly(filter) }),
|
|
201
|
+
};
|
|
202
|
+
if (!writable)
|
|
203
|
+
return reader;
|
|
204
|
+
return {
|
|
205
|
+
...reader,
|
|
206
|
+
insert: async (ref, value) => {
|
|
207
|
+
const collection = name(ref);
|
|
208
|
+
if (!value || typeof value !== "object")
|
|
209
|
+
throw new FeltKitError("INVALID_ARGUMENT", "insert() needs a record object.");
|
|
210
|
+
const fields = stripSystem(value);
|
|
211
|
+
validateRecord(resolver, collection, fields);
|
|
212
|
+
return host("db.insert", { collection, value: plain(fields) });
|
|
213
|
+
},
|
|
214
|
+
patch: (ref, id, fields) => {
|
|
215
|
+
const collection = name(ref);
|
|
216
|
+
const set = stripSystem(fields ?? {});
|
|
217
|
+
// JSON has no undefined: a field patched to undefined is removed, as in FeltKit.
|
|
218
|
+
const unset = Object.entries(set).filter(([, v]) => v === undefined).map(([k]) => k);
|
|
219
|
+
return host("db.patch", { collection, key: id, fields: plain(set), unset });
|
|
220
|
+
},
|
|
221
|
+
replace: (ref, id, value) => {
|
|
222
|
+
const collection = name(ref);
|
|
223
|
+
const fields = stripSystem(value ?? {});
|
|
224
|
+
validateRecord(resolver, collection, fields);
|
|
225
|
+
return host("db.replace", { collection, key: id, value: plain(fields) });
|
|
226
|
+
},
|
|
227
|
+
delete: async (ref, id) => {
|
|
228
|
+
await host("db.delete", { collection: name(ref), key: id });
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function definedOnly(filter) {
|
|
233
|
+
return plain(Object.fromEntries(Object.entries(filter ?? {}).filter(([, v]) => v !== undefined)));
|
|
234
|
+
}
|
|
235
|
+
/** `ctx.services`, as FeltKit binds them. Every method is one host operation on AppPort Services. */
|
|
236
|
+
function services(host, writable) {
|
|
237
|
+
const call = (service, method, input = {}) => host("service", { service, method, input: plain(input) });
|
|
238
|
+
const withBytes = (read) => {
|
|
239
|
+
const bytes = fromBase64(read.content);
|
|
240
|
+
return { file: read.file, bytes, text: () => utf8Decode(bytes) };
|
|
241
|
+
};
|
|
242
|
+
const filesReader = {
|
|
243
|
+
list: (filter = {}) => call("files", "list", { filter }),
|
|
244
|
+
get: (id) => call("files", "get", { id }),
|
|
245
|
+
read: async (id) => withBytes(await call("files", "read", { id })),
|
|
246
|
+
};
|
|
247
|
+
const notificationsReader = {
|
|
248
|
+
list: (filter = {}) => call("notifications", "list", { filter }),
|
|
249
|
+
get: (id) => call("notifications", "get", { id }),
|
|
250
|
+
};
|
|
251
|
+
const configurationReader = {
|
|
252
|
+
list: () => call("configuration", "list"),
|
|
253
|
+
get: async (name) => (await call("configuration", "list"))[name] ?? null,
|
|
254
|
+
};
|
|
255
|
+
if (!writable)
|
|
256
|
+
return { files: filesReader, notifications: notificationsReader, configuration: configurationReader };
|
|
257
|
+
return {
|
|
258
|
+
files: {
|
|
259
|
+
...filesReader,
|
|
260
|
+
upload: (input) => {
|
|
261
|
+
if (!input || typeof input.name !== "string" || !input.name.trim())
|
|
262
|
+
throw new FeltKitError("INVALID_ARGUMENT", "upload() needs a file name.");
|
|
263
|
+
const bytes = typeof input.content === "string" ? utf8Encode(input.content) : input.content;
|
|
264
|
+
if (!(bytes instanceof Uint8Array))
|
|
265
|
+
throw new FeltKitError("INVALID_ARGUMENT", "upload() content must be a string or Uint8Array.");
|
|
266
|
+
return call("files", "upload", {
|
|
267
|
+
name: input.name,
|
|
268
|
+
...(input.contentType ? { contentType: input.contentType } : {}),
|
|
269
|
+
content: toBase64(bytes),
|
|
270
|
+
...(input.metadata ? { metadata: input.metadata } : {}),
|
|
271
|
+
});
|
|
272
|
+
},
|
|
273
|
+
remove: async (id) => {
|
|
274
|
+
await call("files", "remove", { id });
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
notifications: {
|
|
278
|
+
...notificationsReader,
|
|
279
|
+
send: (input) => call("notifications", "send", input),
|
|
280
|
+
markRead: (id) => call("notifications", "markRead", { id }),
|
|
281
|
+
dismiss: (id) => call("notifications", "dismiss", { id }),
|
|
282
|
+
},
|
|
283
|
+
configuration: {
|
|
284
|
+
...configurationReader,
|
|
285
|
+
set: async (name, value) => {
|
|
286
|
+
await call("configuration", "set", { name, value });
|
|
287
|
+
},
|
|
288
|
+
remove: async (name) => {
|
|
289
|
+
await call("configuration", "remove", { name });
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
jobs: {
|
|
293
|
+
enqueue: (type, payload = {}, options = {}) => call("jobs", "enqueue", { type, payload, options }),
|
|
294
|
+
},
|
|
295
|
+
webhooks: {
|
|
296
|
+
emit: (type, payload) => call("webhooks", "emit", { type, payload }),
|
|
297
|
+
},
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
//# sourceMapping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mB;YACtB,GAAG,EAAE,KAAK,EAAE,IAAY,EAAE,KAAa,EAAE,EAAE;gBACzC,MAAM,IAAI,CAAC,eAAe,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;YACtD,CAAC;YACD,MAAM,EAAE,KAAK,EAAE,IAAY,EAAE,EAAE;gBAC7B,MAAM,IAAI,CAAC,eAAe,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;YAClD,CAAC;SACF;QACD,IAAI,EAAE;YACJ,OAAO,EAAE,CAAC,IAAY,EAAE,UAAmC,EAAE,EAAE,UAAmC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;SAC7J;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,CAAC,IAAY,EAAE,OAAgC,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;SACtG;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The few WebAssembly binary operations the AppBoundry target needs: append a custom
|
|
3
|
+
* section, read one back. A custom section is covered by the module's hash and ignored
|
|
4
|
+
* by the engine's code, so the program travels inside module.wasm itself.
|
|
5
|
+
*/
|
|
6
|
+
/** The custom section holding the application program (UTF-8 JavaScript). */
|
|
7
|
+
export declare const PROGRAM_SECTION = "appboundry.program";
|
|
8
|
+
export declare function appendCustomSection(module: Uint8Array, name: string, payload: Uint8Array): Uint8Array;
|
|
9
|
+
export declare function customSections(module: Uint8Array): Array<{
|
|
10
|
+
name: string;
|
|
11
|
+
payload: Uint8Array;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The few WebAssembly binary operations the AppBoundry target needs: append a custom
|
|
3
|
+
* section, read one back. A custom section is covered by the module's hash and ignored
|
|
4
|
+
* by the engine's code, so the program travels inside module.wasm itself.
|
|
5
|
+
*/
|
|
6
|
+
/** The custom section holding the application program (UTF-8 JavaScript). */
|
|
7
|
+
export const PROGRAM_SECTION = "appboundry.program";
|
|
8
|
+
function uleb(value) {
|
|
9
|
+
const out = [];
|
|
10
|
+
do {
|
|
11
|
+
let byte = value & 0x7f;
|
|
12
|
+
value >>>= 7;
|
|
13
|
+
if (value !== 0)
|
|
14
|
+
byte |= 0x80;
|
|
15
|
+
out.push(byte);
|
|
16
|
+
} while (value !== 0);
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
function readUleb(bytes, offset) {
|
|
20
|
+
let result = 0;
|
|
21
|
+
let shift = 0;
|
|
22
|
+
for (;;) {
|
|
23
|
+
const byte = bytes[offset++];
|
|
24
|
+
result += (byte & 0x7f) * 2 ** shift;
|
|
25
|
+
if ((byte & 0x80) === 0)
|
|
26
|
+
return [result, offset];
|
|
27
|
+
shift += 7;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const MAGIC = [0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00];
|
|
31
|
+
function assertModule(bytes) {
|
|
32
|
+
if (bytes.length < 8 || MAGIC.some((b, i) => bytes[i] !== b))
|
|
33
|
+
throw new Error("not a WebAssembly 1.0 module");
|
|
34
|
+
}
|
|
35
|
+
export function appendCustomSection(module, name, payload) {
|
|
36
|
+
assertModule(module);
|
|
37
|
+
if (customSections(module).some((section) => section.name === name))
|
|
38
|
+
throw new Error(`the module already has a "${name}" section`);
|
|
39
|
+
const encodedName = new TextEncoder().encode(name);
|
|
40
|
+
const content = [...uleb(encodedName.length), ...encodedName];
|
|
41
|
+
const size = content.length + payload.length;
|
|
42
|
+
const header = new Uint8Array([0x00, ...uleb(size), ...content]);
|
|
43
|
+
const out = new Uint8Array(module.length + header.length + payload.length);
|
|
44
|
+
out.set(module, 0);
|
|
45
|
+
out.set(header, module.length);
|
|
46
|
+
out.set(payload, module.length + header.length);
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
export function customSections(module) {
|
|
50
|
+
assertModule(module);
|
|
51
|
+
const found = [];
|
|
52
|
+
let offset = 8;
|
|
53
|
+
while (offset < module.length) {
|
|
54
|
+
const id = module[offset++];
|
|
55
|
+
const [size, start] = readUleb(module, offset);
|
|
56
|
+
const end = start + size;
|
|
57
|
+
if (end > module.length)
|
|
58
|
+
throw new Error("truncated section");
|
|
59
|
+
if (id === 0) {
|
|
60
|
+
const [nameLength, nameStart] = readUleb(module, start);
|
|
61
|
+
const name = new TextDecoder().decode(module.subarray(nameStart, nameStart + nameLength));
|
|
62
|
+
found.push({ name, payload: module.subarray(nameStart + nameLength, end) });
|
|
63
|
+
}
|
|
64
|
+
offset = end;
|
|
65
|
+
}
|
|
66
|
+
return found;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=wasm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../../src/appboundry/wasm.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,6EAA6E;AAC7E,MAAM,CAAC,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAEpD,SAAS,IAAI,CAAC,KAAa;IACzB,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,GAAG,CAAC;QACF,IAAI,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC;QACxB,KAAK,MAAM,CAAC,CAAC;QACb,IAAI,KAAK,KAAK,CAAC;YAAE,IAAI,IAAI,IAAI,CAAC;QAC9B,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC,QAAQ,KAAK,KAAK,CAAC,EAAE;IACtB,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,QAAQ,CAAC,KAAiB,EAAE,MAAc;IACjD,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,KAAK,GAAG,CAAC,C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AAS,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC;YAC1F,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS,GAAG,UAAU,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QAC9E,CAAC;QACD,MAAM,GAAG,GAAG,CAAC;IACf,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { VercelEnvPlan } from "./vercel.js";
|
|
2
|
+
/** wrangler and the containers library the artifact pins (both published at least two weeks before they were pinned). */
|
|
3
|
+
export declare const WRANGLER_VERSION = "4.151.2";
|
|
4
|
+
export declare const CONTAINERS_VERSION = "0.3.7";
|
|
5
|
+
/** wrangler builds the image with the local Docker: say so before uploading anything. */
|
|
6
|
+
export declare function ensureDocker(artifact: string): Promise<void>;
|
|
7
|
+
/** The artifact's wrangler and @cloudflare/containers, installed once (FELTKIT_WRANGLER_CLI skips it). */
|
|
8
|
+
export declare function ensureCloudflareTools(artifact: string, report: (line: string) => void): Promise<void>;
|
|
9
|
+
/** The URL wrangler printed for the Worker: its workers.dev address, else the last https URL that is not Cloudflare's dashboard. */
|
|
10
|
+
export declare function workerUrl(output: string): string | null;
|
|
11
|
+
/** `wrangler secret bulk` with the plan's values as JSON on stdin (the Worker must exist: deploy once first). */
|
|
12
|
+
export declare function uploadCloudflareSecrets(plan: VercelEnvPlan): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* `wrangler deploy --secrets-file`: the code, the image and the secrets in one step. wrangler's
|
|
15
|
+
* output is shown as it runs (scrubbed of the values) and read for the Worker's URL.
|
|
16
|
+
*/
|
|
17
|
+
export declare function cloudflareDeploy(plan: VercelEnvPlan): Promise<{
|
|
18
|
+
code: number;
|
|
19
|
+
url: string | null;
|
|
20
|
+
}>;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `feltkit cloudflare env` and `feltkit cloudflare deploy`: set a Cloudflare Worker's secrets from
|
|
3
|
+
* the values FeltDB gave you, then deploy, for an artifact built with `feltkit deploy --target cloudflare`.
|
|
4
|
+
*
|
|
5
|
+
* What is uploaded is exactly what `feltkit vercel env` would upload (planPlatformEnv: the
|
|
6
|
+
* artifact's variables, FeltKit's settings and credentials; never the control key, FELTDB_MANAGED_*
|
|
7
|
+
* or VITE_*), all as Worker secrets: the artifact's Worker passes them to the container. `deploy`
|
|
8
|
+
* sends them with the code in one `wrangler deploy --secrets-file`, from a file only this user can
|
|
9
|
+
* read that is deleted as soon as wrangler returns; `env` sends them with `wrangler secret bulk` on
|
|
10
|
+
* stdin. Values are never printed or put in argv.
|
|
11
|
+
*
|
|
12
|
+
* wrangler builds the container image with the local Docker, so Docker must be running. wrangler
|
|
13
|
+
* and @cloudflare/containers are the artifact's own devDependencies (pinned by `feltkit deploy`),
|
|
14
|
+
* installed into it on first use; the image installs only the app's runtime dependencies.
|
|
15
|
+
*/
|
|
16
|
+
import { spawn } from "node:child_process";
|
|
17
|
+
import { existsSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
18
|
+
import { tmpdir } from "node:os";
|
|
19
|
+
import { join } from "node:path";
|
|
20
|
+
import { FeltKitError } from "../errors.js";
|
|
21
|
+
/** wrangler and the containers library the artifact pins (both published at least two weeks before they were pinned). */
|
|
22
|
+
export const WRANGLER_VERSION = "4.151.2";
|
|
23
|
+
export const CONTAINERS_VERSION = "0.3.7";
|
|
24
|
+
function run(command, args, options) {
|
|
25
|
+
return new Promise((done, fail) => {
|
|
26
|
+
const child = spawn(command, args, { cwd: options.cwd, stdio: [options.input === undefined ? "inherit" : "pipe", "pipe", "pipe"] });
|
|
27
|
+
let output = "";
|
|
28
|
+
const take = (chunk) => {
|
|
29
|
+
output += chunk;
|
|
30
|
+
if (options.show)
|
|
31
|
+
process.stderr.write(chunk);
|
|
32
|
+
};
|
|
33
|
+
child.stdout.on("data", take);
|
|
34
|
+
child.stderr.on("data", take);
|
|
35
|
+
child.once("error", (error) => fail(new FeltKitError("UNAVAILABLE", `Could not run ${command}: ${error.message}`)));
|
|
36
|
+
child.once("exit", (code) => done({ code: code ?? 1, output }));
|
|
37
|
+
if (options.input !== undefined)
|
|
38
|
+
child.stdin.end(options.input);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/** wrangler: FELTKIT_WRANGLER_CLI (a path), else the artifact's own (npx, after installing it). */
|
|
42
|
+
function wranglerCommand(args) {
|
|
43
|
+
const cli = process.env.FELTKIT_WRANGLER_CLI;
|
|
44
|
+
return cli ? [cli, args] : ["npx", ["--no-install", "wrangler", ...args]];
|
|
45
|
+
}
|
|
46
|
+
/** wrangler builds the image with the local Docker: say so before uploading anything. */
|
|
47
|
+
export async function ensureDocker(artifact) {
|
|
48
|
+
const docker = process.env.FELTKIT_DOCKER_CLI ?? "docker";
|
|
49
|
+
let result;
|
|
50
|
+
try {
|
|
51
|
+
result = await run(docker, ["info", "--format", "{{.ServerVersion}}"], { cwd: artifact });
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
result = { code: 1, output: "" };
|
|
55
|
+
}
|
|
56
|
+
if (result.code !== 0) {
|
|
57
|
+
throw new FeltKitError("UNAVAILABLE", "Docker is not running here, and Cloudflare Containers builds the app's image with it (`wrangler deploy` runs `docker build`). Nothing was uploaded.", {
|
|
58
|
+
hint: "Start Docker Desktop (or the Docker daemon), then run this again.",
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** The artifact's wrangler and @cloudflare/containers, installed once (FELTKIT_WRANGLER_CLI skips it). */
|
|
63
|
+
export async function ensureCloudflareTools(artifact, report) {
|
|
64
|
+
if (process.env.FELTKIT_WRANGLER_CLI)
|
|
65
|
+
return;
|
|
66
|
+
if (existsSync(join(artifact, "node_modules", "wrangler")) && existsSync(join(artifact, "node_modules", "@cloudflare", "containers")))
|
|
67
|
+
return;
|
|
68
|
+
report(`Installing wrangler ${WRANGLER_VERSION} and @cloudflare/containers ${CONTAINERS_VERSION} into the artifact (once)…`);
|
|
69
|
+
const installed = await run("npm", ["install", "--no-audit", "--no-fund"], { cwd: artifact });
|
|
70
|
+
if (installed.code !== 0)
|
|
71
|
+
throw new FeltKitError("UNAVAILABLE", `npm install in ${artifact} failed (exit ${installed.code}); nothing was uploaded.`, { hint: installed.output.trim().split("\n").slice(-4).join("\n") });
|
|
72
|
+
}
|
|
73
|
+
/** The URL wrangler printed for the Worker: its workers.dev address, else the last https URL that is not Cloudflare's dashboard. */
|
|
74
|
+
export function workerUrl(output) {
|
|
75
|
+
const urls = (output.match(/https:\/\/[^\s"'`)\]]+/g) ?? []).map((url) => url.replace(/[.,;]$/, "").replace(/\/$/, ""));
|
|
76
|
+
const dev = urls.filter((url) => /\.workers\.dev$/.test(new URL(url).hostname));
|
|
77
|
+
if (dev.length)
|
|
78
|
+
return dev[dev.length - 1];
|
|
79
|
+
const own = urls.filter((url) => !/(^|\.)cloudflare\.com$/.test(new URL(url).hostname));
|
|
80
|
+
return own.length ? own[own.length - 1] : null;
|
|
81
|
+
}
|
|
82
|
+
/** Scrubs every planned value out of text before it is shown. */
|
|
83
|
+
function scrub(text, plan) {
|
|
84
|
+
let out = text;
|
|
85
|
+
for (const value of Object.values(plan.values))
|
|
86
|
+
if (value.length >= 4)
|
|
87
|
+
out = out.split(value).join("…");
|
|
88
|
+
return out;
|
|
89
|
+
}
|
|
90
|
+
/** `wrangler secret bulk` with the plan's values as JSON on stdin (the Worker must exist: deploy once first). */
|
|
91
|
+
export async function uploadCloudflareSecrets(plan) {
|
|
92
|
+
const [command, args] = wranglerCommand(["secret", "bulk"]);
|
|
93
|
+
const result = await run(command, args, { cwd: plan.artifact, input: JSON.stringify(plan.values) });
|
|
94
|
+
if (result.code !== 0) {
|
|
95
|
+
throw new FeltKitError("UNAVAILABLE", `wrangler secret bulk failed (exit ${result.code}).`, {
|
|
96
|
+
hint: `${scrub(result.output, plan).trim().split("\n").slice(-4).join("\n")}\nA Worker that was never deployed has no secrets to set: run \`npx feltkit cloudflare deploy\`.`,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* `wrangler deploy --secrets-file`: the code, the image and the secrets in one step. wrangler's
|
|
102
|
+
* output is shown as it runs (scrubbed of the values) and read for the Worker's URL.
|
|
103
|
+
*/
|
|
104
|
+
export async function cloudflareDeploy(plan) {
|
|
105
|
+
const dir = mkdtempSync(join(tmpdir(), "feltkit-cloudflare-"));
|
|
106
|
+
const file = join(dir, "secrets.json");
|
|
107
|
+
try {
|
|
108
|
+
writeFileSync(file, JSON.stringify(plan.values), { mode: 0o600 });
|
|
109
|
+
const [command, args] = wranglerCommand(["deploy", "--secrets-file", file]);
|
|
110
|
+
const result = await new Promise((done, fail) => {
|
|
111
|
+
const child = spawn(command, args, { cwd: plan.artifact, stdio: ["inherit", "pipe", "pipe"] });
|
|
112
|
+
let output = "";
|
|
113
|
+
const show = (chunk) => {
|
|
114
|
+
output += chunk;
|
|
115
|
+
process.stderr.write(scrub(String(chunk), plan));
|
|
116
|
+
};
|
|
117
|
+
child.stdout.on("data", show);
|
|
118
|
+
child.stderr.on("data", show);
|
|
119
|
+
child.once("error", (error) => fail(new FeltKitError("UNAVAILABLE", `Could not run wrangler (${command}): ${error.message}`)));
|
|
120
|
+
child.once("exit", (code) => done({ code: code ?? 1, output }));
|
|
121
|
+
});
|
|
122
|
+
return { code: result.code, url: result.code === 0 ? workerUrl(result.output) : null };
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
rmSync(dir, { recursive: true, force: true });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=cloudflare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudflare.js","sourceRoot":"","sources":["../../src/cli/cloudflare.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,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AK,CAAC;gBAChB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;YACnD,CAAC,CAAC;YACF,KAAK,CAAC,MAAO,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC/B,KAAK,CAAC,MAAO,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC/B,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,aAAa,EAAE,2BAA2B,OAAO,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;YAC/H,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;QACH,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACzF,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
|
package/dist/cli/deploy.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { DEPLOY_TARGETS, VERCEL_DATA, type DeployTarget, type StorageMode, type VercelData } from "../runtime/targets.js";
|
|
2
|
-
export { DEPLOY_TARGETS, VERCEL_DATA, type DeployTarget, type VercelData };
|
|
1
|
+
import { DEPLOY_TARGETS, PLATFORM_DATA, VERCEL_DATA, type DeployTarget, type PlatformData, type StorageMode, type VercelData } from "../runtime/targets.js";
|
|
2
|
+
export { DEPLOY_TARGETS, PLATFORM_DATA, VERCEL_DATA, type DeployTarget, type PlatformData, type VercelData };
|
|
3
3
|
export { DEPLOY_DIR } from "../runtime/deployment.js";
|
|
4
4
|
export declare function deploy(options: {
|
|
5
5
|
projectDir: string;
|
|
6
6
|
out?: string;
|
|
7
7
|
target?: DeployTarget;
|
|
8
|
-
data?:
|
|
8
|
+
data?: PlatformData;
|
|
9
|
+
instances?: number;
|
|
9
10
|
}): Promise<{
|
|
10
11
|
dir: string;
|
|
11
12
|
application: string;
|
|
12
13
|
build: import("../server/project.js").BuildResult;
|
|
13
14
|
apiKeys: boolean;
|
|
14
15
|
target: DeployTarget;
|
|
15
|
-
data:
|
|
16
|
+
data: PlatformData | undefined;
|
|
16
17
|
storage: StorageMode;
|
|
17
18
|
services: string[];
|
|
18
19
|
credentialRefs: string[];
|
|
@@ -21,3 +22,5 @@ export declare function deploy(options: {
|
|
|
21
22
|
/** Sentence case to mid-sentence: only the first letter. */
|
|
22
23
|
export declare const lower: (text: string) => string;
|
|
23
24
|
export declare const variable: (ref: string) => string;
|
|
25
|
+
/** The compatibility date the Worker is built for: one the pinned wrangler (WRANGLER_VERSION) knows. */
|
|
26
|
+
export declare const CLOUDFLARE_COMPATIBILITY_DATE = "2026-10-01";
|