@workerstack/clients 1.0.0-rc.25 → 1.0.0-rc.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -43
- package/bin/{honey-clients.js → clients.js} +12 -12
- package/dist/cli.d.ts +3 -3
- package/dist/cli.js +14 -14
- package/dist/emit/cli/discovery.js +1 -1
- package/dist/emit/cli/install.js +2 -2
- package/dist/emit/cli/layout.js +1 -1
- package/dist/emit/cli/module.js +1 -1
- package/dist/emit/cli/release.js +1 -1
- package/dist/emit/csharp/errors.js +1 -1
- package/dist/emit/csharp/sdk-client.js +1 -1
- package/dist/emit/csharp/sdk-csproj.d.ts +1 -1
- package/dist/emit/csharp/sdk-csproj.js +2 -2
- package/dist/emit/csharp/sdk.d.ts +1 -1
- package/dist/emit/csharp/sdk.js +2 -2
- package/dist/emit/csharp/transport.js +2 -2
- package/dist/emit/csharp/types-record.d.ts +1 -1
- package/dist/emit/go/sdk-client.js +1 -1
- package/dist/emit/go/sdk.js +1 -1
- package/dist/emit/java/sdk-errors.js +5 -5
- package/dist/emit/java/sdk-op.d.ts +1 -1
- package/dist/emit/java/sdk.js +3 -3
- package/dist/emit/mcp/files.d.ts +1 -1
- package/dist/emit/mcp/mounted.js +2 -2
- package/dist/emit/mcp/runtime.js +1 -1
- package/dist/emit/mcp/server.js +1 -1
- package/dist/emit/python/errors.js +1 -1
- package/dist/emit/python/sdk-client.js +2 -2
- package/dist/emit/python/sdk-pyproject.js +4 -4
- package/dist/emit/python/sdk.d.ts +1 -1
- package/dist/emit/python/sdk.js +11 -11
- package/dist/emit/python/transport.js +1 -1
- package/dist/emit/rust/errors.js +2 -2
- package/dist/emit/rust/sdk-cargo.js +3 -3
- package/dist/emit/rust/sdk.d.ts +1 -1
- package/dist/emit/rust/sdk.js +2 -2
- package/dist/emit/shared/format.d.ts +1 -1
- package/dist/emit/shared/metadata.d.ts +1 -1
- package/dist/emit/shared/status-keys.d.ts +1 -1
- package/dist/emit/shared/status-keys.js +1 -1
- package/dist/emit/ts/app-client.js +2 -2
- package/dist/emit/ts/route-tree.js +1 -1
- package/dist/emit/ts/sdk-types-preamble.js +16 -16
- package/dist/emit/ts/sdk-types.js +6 -6
- package/dist/emit/ts/tanstack-query.js +5 -5
- package/dist/emit/ts/type-gen.d.ts +2 -2
- package/dist/emit/ts/type-gen.js +16 -16
- package/dist/extract/extract.js +3 -3
- package/dist/extract/serialize.js +1 -1
- package/dist/gen/args.js +3 -3
- package/dist/gen/formatters.d.ts +6 -6
- package/dist/gen/formatters.js +7 -7
- package/dist/gen/process.d.ts +3 -3
- package/dist/gen/process.js +7 -7
- package/dist/gen/targets.d.ts +3 -3
- package/dist/gen/targets.js +3 -3
- package/dist/gen/write.d.ts +1 -1
- package/dist/gen/write.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/ir/load.js +10 -10
- package/dist/ir/model.d.ts +4 -4
- package/dist/ir/sdk-model.d.ts +1 -1
- package/dist/ir/sdk-model.js +1 -1
- package/dist/ir/slots.d.ts +3 -3
- package/dist/ir/slots.js +10 -10
- package/dist/release/bootstrap.js +1 -1
- package/dist/release/bump-command.js +1 -1
- package/dist/release/cli.d.ts +4 -4
- package/dist/release/cli.js +6 -6
- package/dist/release/context.d.ts +1 -1
- package/dist/release/context.js +1 -1
- package/dist/release/digest.d.ts +1 -1
- package/dist/release/digest.js +2 -2
- package/dist/release/index.d.ts +1 -1
- package/dist/release/load.js +1 -1
- package/dist/release/manifest.js +1 -1
- package/dist/release/registries.d.ts +2 -0
- package/dist/release/registries.js +9 -6
- package/dist/release/release-workflow.js +2 -2
- package/dist/release/spec-gate.d.ts +2 -2
- package/dist/release/spec-gate.js +2 -2
- package/dist/release/sync-command.d.ts +1 -1
- package/dist/release/sync-command.js +1 -1
- package/dist/release/sync-tree.js +1 -1
- package/dist/release/types.d.ts +6 -6
- package/dist/runtime/cli/body.go +1 -1
- package/dist/runtime/cli/config.go +3 -3
- package/dist/runtime/cli/discovery.go +1 -1
- package/dist/runtime/cli/format.go +1 -1
- package/dist/runtime/cli/log.go +1 -1
- package/dist/runtime/cli/output.go +1 -1
- package/dist/runtime/cli/params.go +1 -1
- package/dist/runtime/cli/run.go +1 -1
- package/dist/runtime/cli/socket.go +1 -1
- package/dist/runtime/cli/stream.go +1 -1
- package/dist/runtime/cli/target.go +1 -1
- package/dist/runtime/csharp/Adapters.cs +2 -2
- package/dist/runtime/csharp/Auth.cs +2 -2
- package/dist/runtime/csharp/Body.cs +3 -3
- package/dist/runtime/csharp/Config.cs +2 -2
- package/dist/runtime/csharp/Envelope.cs +3 -3
- package/dist/runtime/csharp/Errors.cs +10 -10
- package/dist/runtime/csharp/Events.cs +2 -2
- package/dist/runtime/csharp/Exchange.cs +4 -4
- package/dist/runtime/csharp/Handler.cs +3 -3
- package/dist/runtime/csharp/Hooks.cs +3 -3
- package/dist/runtime/csharp/Invalidation.cs +2 -2
- package/dist/runtime/csharp/Json.cs +2 -2
- package/dist/runtime/csharp/Log.cs +2 -2
- package/dist/runtime/csharp/Operation.cs +2 -2
- package/dist/runtime/csharp/Path.cs +2 -2
- package/dist/runtime/csharp/Query.cs +2 -2
- package/dist/runtime/csharp/Realtime.cs +2 -2
- package/dist/runtime/csharp/RealtimeLoop.cs +3 -3
- package/dist/runtime/csharp/Redirect.cs +2 -2
- package/dist/runtime/csharp/Result.cs +2 -2
- package/dist/runtime/csharp/Sse.cs +2 -2
- package/dist/runtime/csharp/Stale.cs +2 -2
- package/dist/runtime/csharp/Transport.cs +2 -2
- package/dist/runtime/csharp/TransportLongPoll.cs +2 -2
- package/dist/runtime/csharp/TransportSse.cs +2 -2
- package/dist/runtime/csharp/TransportWs.cs +2 -2
- package/dist/runtime/csharp/Wire.cs +2 -2
- package/dist/runtime/csharp/Ws.cs +2 -2
- package/dist/runtime/csharp/WsDial.cs +2 -2
- package/dist/runtime/go/auth.go +1 -1
- package/dist/runtime/go/body.go +2 -2
- package/dist/runtime/go/config.go +1 -1
- package/dist/runtime/go/errors.go +5 -5
- package/dist/runtime/go/export.go +10 -10
- package/dist/runtime/go/hooks.go +2 -2
- package/dist/runtime/go/invalidation.go +2 -2
- package/dist/runtime/go/log.go +1 -1
- package/dist/runtime/go/nullable.go +1 -1
- package/dist/runtime/go/options.go +1 -1
- package/dist/runtime/go/path.go +1 -1
- package/dist/runtime/go/query.go +2 -2
- package/dist/runtime/go/realtime.go +4 -4
- package/dist/runtime/go/realtime_loop.go +1 -1
- package/dist/runtime/go/redirect.go +2 -2
- package/dist/runtime/go/request.go +9 -9
- package/dist/runtime/go/result.go +2 -2
- package/dist/runtime/go/sse.go +3 -3
- package/dist/runtime/go/stale.go +1 -1
- package/dist/runtime/go/stream.go +2 -2
- package/dist/runtime/go/transport.go +2 -2
- package/dist/runtime/go/transport_longpoll.go +1 -1
- package/dist/runtime/go/transport_sse.go +2 -2
- package/dist/runtime/go/ws.go +1 -1
- package/dist/runtime/java/Answer.java +2 -2
- package/dist/runtime/java/ApiException.java +2 -2
- package/dist/runtime/java/BinaryBody.java +2 -2
- package/dist/runtime/java/Body.java +4 -4
- package/dist/runtime/java/Call.java +2 -2
- package/dist/runtime/java/CallLog.java +2 -2
- package/dist/runtime/java/ClientConfig.java +2 -2
- package/dist/runtime/java/ConnectionState.java +2 -2
- package/dist/runtime/java/Credential.java +2 -2
- package/dist/runtime/java/Deadline.java +2 -2
- package/dist/runtime/java/Decode.java +2 -2
- package/dist/runtime/java/Envelope.java +2 -2
- package/dist/runtime/java/ErrorEnvelope.java +3 -3
- package/dist/runtime/java/EventStream.java +2 -2
- package/dist/runtime/java/Exchange.java +2 -2
- package/dist/runtime/java/FilePart.java +2 -2
- package/dist/runtime/java/Flight.java +3 -3
- package/dist/runtime/java/Hooks.java +3 -3
- package/dist/runtime/java/Hops.java +2 -2
- package/dist/runtime/java/{HoneyException.java → HttpException.java} +4 -4
- package/dist/runtime/java/InvalidationConfig.java +2 -2
- package/dist/runtime/java/Json.java +3 -3
- package/dist/runtime/java/Keepalive.java +2 -2
- package/dist/runtime/java/LogEntry.java +2 -2
- package/dist/runtime/java/LongPollAdapter.java +2 -2
- package/dist/runtime/java/Operation.java +2 -2
- package/dist/runtime/java/Opt.java +2 -2
- package/dist/runtime/java/Pump.java +2 -2
- package/dist/runtime/java/RawResponse.java +2 -2
- package/dist/runtime/java/Realtime.java +2 -2
- package/dist/runtime/java/RealtimeLoop.java +4 -4
- package/dist/runtime/java/RedirectPolicy.java +2 -2
- package/dist/runtime/java/Redirects.java +2 -2
- package/dist/runtime/java/RequestContext.java +2 -2
- package/dist/runtime/java/RequestHook.java +2 -2
- package/dist/runtime/java/RequestOptions.java +2 -2
- package/dist/runtime/java/ResponseContext.java +2 -2
- package/dist/runtime/java/ResponseHook.java +2 -2
- package/dist/runtime/java/Result.java +2 -2
- package/dist/runtime/java/ResumableConnection.java +2 -2
- package/dist/runtime/java/SdkException.java +3 -3
- package/dist/runtime/java/Socket.java +2 -2
- package/dist/runtime/java/Sse.java +2 -2
- package/dist/runtime/java/SseAdapter.java +2 -2
- package/dist/runtime/java/SseEvent.java +2 -2
- package/dist/runtime/java/StaleMeta.java +2 -2
- package/dist/runtime/java/StaleTracker.java +2 -2
- package/dist/runtime/java/Transport.java +2 -2
- package/dist/runtime/java/TransportAdapter.java +2 -2
- package/dist/runtime/java/TransportConnection.java +2 -2
- package/dist/runtime/java/TransportKind.java +2 -2
- package/dist/runtime/java/TransportMessage.java +2 -2
- package/dist/runtime/java/TransportOptions.java +2 -2
- package/dist/runtime/java/TypedWebSocket.java +2 -2
- package/dist/runtime/java/UrlPath.java +2 -2
- package/dist/runtime/java/UrlQuery.java +2 -2
- package/dist/runtime/java/WsAdapter.java +2 -2
- package/dist/runtime/java/WsClose.java +2 -2
- package/dist/runtime/java/WsDial.java +2 -2
- package/dist/runtime/java/WsMessage.java +2 -2
- package/dist/runtime/mcp/call.ts +3 -3
- package/dist/runtime/mcp/result.ts +2 -2
- package/dist/runtime/python/__init__.py +1 -1
- package/dist/runtime/python/auth.py +1 -1
- package/dist/runtime/python/body.py +1 -1
- package/dist/runtime/python/config.py +1 -1
- package/dist/runtime/python/errors.py +11 -11
- package/dist/runtime/python/events.py +4 -4
- package/dist/runtime/python/exchange.py +1 -1
- package/dist/runtime/python/hooks.py +4 -4
- package/dist/runtime/python/invalidation.py +1 -1
- package/dist/runtime/python/log.py +1 -1
- package/dist/runtime/python/operation.py +1 -1
- package/dist/runtime/python/path.py +1 -1
- package/dist/runtime/python/query.py +1 -1
- package/dist/runtime/python/realtime.py +5 -5
- package/dist/runtime/python/redirect.py +1 -1
- package/dist/runtime/python/result.py +1 -1
- package/dist/runtime/python/send_async.py +4 -4
- package/dist/runtime/python/send_sync.py +3 -3
- package/dist/runtime/python/sse.py +1 -1
- package/dist/runtime/python/stale.py +1 -1
- package/dist/runtime/python/transport.py +1 -1
- package/dist/runtime/python/transport_longpoll.py +1 -1
- package/dist/runtime/python/transport_sse.py +1 -1
- package/dist/runtime/python/transport_ws.py +1 -1
- package/dist/runtime/python/ws.py +3 -3
- package/dist/runtime/rust/Cargo.lock +1 -1
- package/dist/runtime/rust/answer.rs +1 -1
- package/dist/runtime/rust/auth.rs +1 -1
- package/dist/runtime/rust/body.rs +2 -2
- package/dist/runtime/rust/call.rs +1 -1
- package/dist/runtime/rust/config.rs +1 -1
- package/dist/runtime/rust/envelope.rs +3 -3
- package/dist/runtime/rust/errors.rs +3 -3
- package/dist/runtime/rust/events.rs +1 -1
- package/dist/runtime/rust/exchange.rs +1 -1
- package/dist/runtime/rust/hooks.rs +1 -1
- package/dist/runtime/rust/invalidation.rs +1 -1
- package/dist/runtime/rust/log.rs +1 -1
- package/dist/runtime/rust/nullable.rs +1 -1
- package/dist/runtime/rust/path.rs +1 -1
- package/dist/runtime/rust/query.rs +1 -1
- package/dist/runtime/rust/realtime.rs +1 -1
- package/dist/runtime/rust/realtime_loop.rs +1 -1
- package/dist/runtime/rust/redirect.rs +1 -1
- package/dist/runtime/rust/request.rs +1 -1
- package/dist/runtime/rust/result.rs +1 -1
- package/dist/runtime/rust/sse.rs +1 -1
- package/dist/runtime/rust/stale.rs +1 -1
- package/dist/runtime/rust/transport.rs +1 -1
- package/dist/runtime/rust/transport_longpoll.rs +1 -1
- package/dist/runtime/rust/transport_sse.rs +1 -1
- package/dist/runtime/rust/transport_ws.rs +1 -1
- package/dist/runtime/rust/ws.rs +1 -1
- package/dist/runtime/ts/app-types.ts +5 -5
- package/dist/runtime/ts/app.ts +5 -5
- package/dist/runtime/ts/http.ts +3 -3
- package/dist/runtime/ts/path.ts +1 -1
- package/dist/runtime/ts/request.ts +1 -1
- package/dist/runtime/ts/sdk.ts +1 -1
- package/package.json +5 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `generateTypes` (F3): an app's `_gen/types.gen.d.ts` — the `Routes` map, each route's ctx,
|
|
3
|
-
* input, output, errors and meta, the route selectors with the `
|
|
3
|
+
* input, output, errors and meta, the route selectors with the `HttpCodegen` augmentation, and
|
|
4
4
|
* `BaseCtx`. Read from the app's OpenAPI document (the IR), its route tree (meta, O1) and the
|
|
5
|
-
* extracted ctx types (middleware, env, taps, parsed inputs, O3), joined on `x-
|
|
5
|
+
* extracted ctx types (middleware, env, taps, parsed inputs, O3), joined on `x-backend-route`.
|
|
6
6
|
*/
|
|
7
7
|
import type { ExtractedTypes } from "../../extract/extract.ts";
|
|
8
8
|
import type { RouteTree } from "./route-tree.ts";
|
package/dist/emit/ts/type-gen.js
CHANGED
|
@@ -9,9 +9,9 @@ import { irToTs } from "../shared/type-emitter.js";
|
|
|
9
9
|
import { componentNames } from "./sdk-types.js";
|
|
10
10
|
/* the names the file declares, which a component schema never takes */
|
|
11
11
|
const RESERVED = [
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
12
|
+
"HttpContext",
|
|
13
|
+
"HttpError",
|
|
14
|
+
"HttpMeta",
|
|
15
15
|
"Omit",
|
|
16
16
|
"Partial",
|
|
17
17
|
"Readonly",
|
|
@@ -21,7 +21,7 @@ const RESERVED = [
|
|
|
21
21
|
"TapMap",
|
|
22
22
|
];
|
|
23
23
|
/* the v1 error-factory signature of a key without a schema (core errors.ts ErrorFactoryOpts) */
|
|
24
|
-
const STANDARD_FACTORY = "(opts?: { cause?: unknown; fields?: Record<string, { error_key: string; message: string; path: string }[]>; headers?: Record<string, string>; vars?: Record<string, number | string> }) =>
|
|
24
|
+
const STANDARD_FACTORY = "(opts?: { cause?: unknown; fields?: Record<string, { error_key: string; message: string; path: string }[]>; headers?: Record<string, string>; vars?: Record<string, number | string> }) => HttpError";
|
|
25
25
|
const EXTRACTORS = [
|
|
26
26
|
["RouteCtx", "ctx"],
|
|
27
27
|
["RouteInput", "input"],
|
|
@@ -34,7 +34,7 @@ const EXTRACTORS = [
|
|
|
34
34
|
/** `{ k: T; … }`, or `{}` when there is nothing in it. */
|
|
35
35
|
const objectText = (fields) => fields.length === 0 ? "{}" : `{ ${fields.map(([key, type]) => `${key}: ${type}`).join("; ")} }`;
|
|
36
36
|
const propsText = (props) => objectText(props.map((p) => [`${quoteKey(p.name)}${p.optional ? "?" : ""}`, p.type]));
|
|
37
|
-
/** The documented routes by route id; an operation without `x-
|
|
37
|
+
/** The documented routes by route id; an operation without `x-backend-route` is reported and left out. */
|
|
38
38
|
function routesOf(ir, report) {
|
|
39
39
|
const routes = new Map();
|
|
40
40
|
const missing = [];
|
|
@@ -43,7 +43,7 @@ function routesOf(ir, report) {
|
|
|
43
43
|
if (op.extensions.websocket === true)
|
|
44
44
|
continue;
|
|
45
45
|
if (id === undefined)
|
|
46
|
-
missing.push(`${op.method} ${op.path}: no x-
|
|
46
|
+
missing.push(`${op.method} ${op.path}: no x-backend-route; left out of Routes`);
|
|
47
47
|
/* `all()` and an optional param document one route as several operations: the first speaks for it */
|
|
48
48
|
if (id !== undefined && !routes.has(id))
|
|
49
49
|
routes.set(id, op);
|
|
@@ -131,7 +131,7 @@ function errorsOf(op, ctx) {
|
|
|
131
131
|
.map(([code, shapes]) => [String(code), [...shapes].join(" | ")]);
|
|
132
132
|
const factory = (key) => shape(key) === "null"
|
|
133
133
|
? STANDARD_FACTORY
|
|
134
|
-
: `(data: ${shape(key)}, opts?: { cause?: unknown; headers?: Record<string, string> }) =>
|
|
134
|
+
: `(data: ${shape(key)}, opts?: { cause?: unknown; headers?: Record<string, string> }) => HttpError`;
|
|
135
135
|
return {
|
|
136
136
|
factories: keys.map((key) => [quoteKey(key), factory(key)]),
|
|
137
137
|
fields: [
|
|
@@ -150,8 +150,8 @@ function errorsOf(op, ctx) {
|
|
|
150
150
|
function ctxMeta(extracted, literal) {
|
|
151
151
|
const declared = extracted?.meta ?? null;
|
|
152
152
|
/* the OpenAPI keys the declared meta does not redefine: a consumer that types `security` its own way holds
|
|
153
|
-
that type in the handler, and intersecting
|
|
154
|
-
return declared === null ? literal : `Partial<Omit<
|
|
153
|
+
that type in the handler, and intersecting backend's would conflict with it */
|
|
154
|
+
return declared === null ? literal : `Partial<Omit<HttpMeta, keyof ${declared}>> & ${declared}`;
|
|
155
155
|
}
|
|
156
156
|
/** `ctx.params`: the type a param schema gives it as extracted, else each of the pattern's params a string. */
|
|
157
157
|
function ctxParams(extracted, id, pattern) {
|
|
@@ -197,7 +197,7 @@ function routeEntry(id, op, options, ctx) {
|
|
|
197
197
|
function baseCtx(extracted, name) {
|
|
198
198
|
const env = extracted?.env ?? "Record<string, unknown>";
|
|
199
199
|
const taps = extracted?.taps ?? null;
|
|
200
|
-
const parts = [taps === null ? `
|
|
200
|
+
const parts = [taps === null ? `HttpContext<${env}>` : `Omit<HttpContext<${env}>, "tap">`];
|
|
201
201
|
const middleware = extracted?.middleware ?? [];
|
|
202
202
|
if (middleware.length > 0)
|
|
203
203
|
parts.push(propsText(middleware));
|
|
@@ -232,19 +232,19 @@ export function generateTypes(options) {
|
|
|
232
232
|
const ctx = { names, resolve: (schema) => irToTs(schema, names) };
|
|
233
233
|
const hasErrors = [...routes.values()].some((op) => Object.keys(op.extensions.errors ?? {}).length > 0);
|
|
234
234
|
const selectors = [...routes.keys()].sort(compareCodeUnits);
|
|
235
|
-
/*
|
|
235
|
+
/* HttpMeta only when a declared meta is emitted: the ctx's meta is that type and the keys a route may add */
|
|
236
236
|
const declaredMeta = options.extracted?.meta ?? null;
|
|
237
237
|
const imports = [
|
|
238
|
-
"
|
|
238
|
+
"HttpContext",
|
|
239
239
|
"WithOutput",
|
|
240
|
-
...(hasErrors ? ["
|
|
241
|
-
...(declaredMeta === null ? [] : ["
|
|
240
|
+
...(hasErrors ? ["HttpError"] : []),
|
|
241
|
+
...(declaredMeta === null ? [] : ["HttpMeta"]),
|
|
242
242
|
];
|
|
243
|
-
const out = [`import type { ${imports.join(", ")} } from "@workerstack/backend"`];
|
|
243
|
+
const out = [`import type { ${imports.join(", ")} } from "@workerstack/backend/http"`];
|
|
244
244
|
out.push(...baseCtx(options.extracted, name));
|
|
245
245
|
if (selectors.length > 0) {
|
|
246
246
|
out.push(`export type RouteSelector = ${selectors.map(tsString).join(" | ")}`);
|
|
247
|
-
out.push('declare module "@workerstack/backend" {\n\tinterface
|
|
247
|
+
out.push('declare module "@workerstack/backend/http" {\n\tinterface HttpCodegen {\n\t\trouteSelector: RouteSelector\n\t}\n}');
|
|
248
248
|
}
|
|
249
249
|
for (const schema of Object.keys(ir.schemas).sort(compareCodeUnits))
|
|
250
250
|
out.push(`type ${names.refName?.(schema)} = ${ctx.resolve(ir.schemas[schema])}`);
|
package/dist/extract/extract.js
CHANGED
|
@@ -17,9 +17,9 @@ import { dirname, join, relative, sep } from "node:path";
|
|
|
17
17
|
import { addedProps, frameworkClass, routeAdditions } from "./chain.js";
|
|
18
18
|
import { Serializer } from "./serialize.js";
|
|
19
19
|
import { loadEntry, registrations } from "./walk.js";
|
|
20
|
-
/* the type-only members every
|
|
20
|
+
/* the type-only members every backend app carries */
|
|
21
21
|
const APP_MEMBERS = ["$ctx", "$env", "$taps"];
|
|
22
|
-
/* the declared meta, read when the app carries it: an app from an older
|
|
22
|
+
/* the declared meta, read when the app carries it: an app from an older backend has no $meta and still extracts */
|
|
23
23
|
const META_MEMBER = "$meta";
|
|
24
24
|
/** The nearest named package.json above `file` (one without a name only marks a module type). */
|
|
25
25
|
function nearestPackage(file, cache) {
|
|
@@ -162,7 +162,7 @@ export function extractTypes(options) {
|
|
|
162
162
|
});
|
|
163
163
|
if (members.includes(undefined)) {
|
|
164
164
|
const missing = APP_MEMBERS.filter((_, index) => members[index] === undefined);
|
|
165
|
-
throw new Error(`Export "${exportName}" is not a
|
|
165
|
+
throw new Error(`Export "${exportName}" is not a backend app: it carries no ${missing.join(", ")}`);
|
|
166
166
|
}
|
|
167
167
|
const [ctx, env, tapsType] = members;
|
|
168
168
|
const metaSym = appType.getProperty(META_MEMBER);
|
|
@@ -249,7 +249,7 @@ export class Serializer {
|
|
|
249
249
|
#resolved(type) {
|
|
250
250
|
if (type.intrinsicName !== "error")
|
|
251
251
|
return;
|
|
252
|
-
throw new Error(`type ${this.checker.typeToString(type)} does not resolve in the program
|
|
252
|
+
throw new Error(`type ${this.checker.typeToString(type)} does not resolve in the program clients reads: the entry, its imports and its tsconfig's .d.ts files`);
|
|
253
253
|
}
|
|
254
254
|
/** An optional member's type, without the `| undefined` its `?` already says (a `null` stays). */
|
|
255
255
|
optional(type) {
|
package/dist/gen/args.js
CHANGED
|
@@ -9,11 +9,11 @@ import { isListField, METADATA_FIELDS } from "../emit/shared/metadata.js";
|
|
|
9
9
|
import { isBooleanOption, TARGET_OPTIONS, TARGETS } from "./targets.js";
|
|
10
10
|
/** The usage text, the options listed by target. */
|
|
11
11
|
export function usage() {
|
|
12
|
-
return `usage:
|
|
12
|
+
return `usage: clients generate (--spec <openapi.json> | --app <module>[#export]) --target <name>... --out <dir>
|
|
13
13
|
[--watch] [options]
|
|
14
14
|
|
|
15
15
|
--spec <file> the OpenAPI document (JSON) to generate from
|
|
16
|
-
--app <module> a
|
|
16
|
+
--app <module> a backend app module instead: its export (#name, else app, else default) is the app, and its
|
|
17
17
|
openApi export, if any, the document's options (core's generateOpenApi); the module
|
|
18
18
|
exports the app and serves nothing: one that calls serve() as it loads is outside --app
|
|
19
19
|
--target <name> ${TARGETS.join(", ")}; repeat for more than one
|
|
@@ -34,7 +34,7 @@ ${Object.entries(TARGET_OPTIONS)
|
|
|
34
34
|
.map(([target, options]) => ` ${target}: ${options.map((key) => `--${target}-${kebab(key)}`).join(" ")}`)
|
|
35
35
|
.join("\n")}
|
|
36
36
|
|
|
37
|
-
Each <out>/<target> keeps .
|
|
37
|
+
Each <out>/<target> keeps .clients-generated.json: the package it makes on each registry (registry, name, version),
|
|
38
38
|
and every file it wrote with its sha256. A regeneration deletes a file the last run wrote and this one does not,
|
|
39
39
|
unless it was edited since: that one is kept and named on stderr.
|
|
40
40
|
Nothing outside <out>/<target> is written or deleted, and no symlink is followed.
|
package/dist/gen/formatters.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare function findGofmt(env?: NodeJS.ProcessEnv): string | undefined;
|
|
|
9
9
|
/**
|
|
10
10
|
* The pinned ruff, or none: `RUFF` names it, else PATH. A named path that is not there counts as none, so a
|
|
11
11
|
* stale override is a skip with its own line rather than a spawn failure deep in the post-pass, which
|
|
12
|
-
* `formatFiles` would raise as though
|
|
12
|
+
* `formatFiles` would raise as though clients had emitted unparseable Python.
|
|
13
13
|
*/
|
|
14
14
|
export declare function findRuff(env?: NodeJS.ProcessEnv): string | undefined;
|
|
15
15
|
/**
|
|
@@ -24,10 +24,10 @@ export type FormatPass = {
|
|
|
24
24
|
readonly extension: string;
|
|
25
25
|
readonly install: string;
|
|
26
26
|
/**
|
|
27
|
-
* Say nothing when this one is absent. Only `ts`: oxfmt is
|
|
27
|
+
* Say nothing when this one is absent. Only `ts`: oxfmt is clients' own choice of TS formatter and a
|
|
28
28
|
* declared optional peer, so a consumer is not expected to have it and "TS goes out as emitted" is the
|
|
29
29
|
* documented rule (Q12, `blueprint/00-rules.md`). ruff, rustfmt and gofmt are the language's own standard
|
|
30
|
-
* tools, which a developer of that language has —
|
|
30
|
+
* tools, which a developer of that language has — clients simply never called them, and silence there is
|
|
31
31
|
* what let unformatted Python ship.
|
|
32
32
|
*/
|
|
33
33
|
readonly quiet?: true;
|
|
@@ -42,7 +42,7 @@ export type FormatPass = {
|
|
|
42
42
|
export declare const FORMATTERS: Partial<Record<Target, FormatPass>>;
|
|
43
43
|
/**
|
|
44
44
|
* The formatter for `target`, or none when its binary is not there. Each factory is named here rather than
|
|
45
|
-
* held in the table's rows: `
|
|
45
|
+
* held in the table's rows: `clients/spawn-timeout` proves which exports reach a spawn by walking named calls
|
|
46
46
|
* (the repo lint plugin's `spawners.js`), and a closure in a table is opaque to that walk — which would leave a
|
|
47
47
|
* test calling `generated()` free of the bound it needs, since the spawn is real either way.
|
|
48
48
|
*/
|
|
@@ -54,8 +54,8 @@ export declare function formatterFor(target: Target, where: {
|
|
|
54
54
|
* A formatter that is not there: the files go out as emitted and the skip is named, so unformatted output is
|
|
55
55
|
* never silent. A consumer generating a Python SDK should not need ruff to get valid Python.
|
|
56
56
|
*
|
|
57
|
-
* `
|
|
58
|
-
* unformatted code. Deliberately NOT `
|
|
57
|
+
* `CLIENTS_REQUIRE_FORMATTERS=1` makes it fail instead, for a pipeline that would rather stop than ship
|
|
58
|
+
* unformatted code. Deliberately NOT `CLIENTS_REQUIRE_TOOLCHAINS`, which this repository's CI sets on six jobs
|
|
59
59
|
* to mean "these TESTS need their toolchain, do not skip" — reading it here turned every incidental
|
|
60
60
|
* generation in CI without oxfmt into a hard failure, which is how rc.10's release run died.
|
|
61
61
|
*/
|
package/dist/gen/formatters.js
CHANGED
|
@@ -21,7 +21,7 @@ import { rustfmtFormatter } from "../emit/shared/rustfmt.js";
|
|
|
21
21
|
* The binary a caller named through an environment variable, checked here at the edge. An override that
|
|
22
22
|
* points at nothing is a mistake in how the run was configured, so it is a named error: falling back to some
|
|
23
23
|
* other binary would ignore an explicit instruction, and spawning it would surface inside the post-pass,
|
|
24
|
-
* which raises a failure there as though
|
|
24
|
+
* which raises a failure there as though clients had emitted source the formatter could not parse.
|
|
25
25
|
*/
|
|
26
26
|
function named(variable, path) {
|
|
27
27
|
if (path === undefined || path === "")
|
|
@@ -57,7 +57,7 @@ export function findGofmt(env = process.env) {
|
|
|
57
57
|
/**
|
|
58
58
|
* The pinned ruff, or none: `RUFF` names it, else PATH. A named path that is not there counts as none, so a
|
|
59
59
|
* stale override is a skip with its own line rather than a spawn failure deep in the post-pass, which
|
|
60
|
-
* `formatFiles` would raise as though
|
|
60
|
+
* `formatFiles` would raise as though clients had emitted unparseable Python.
|
|
61
61
|
*/
|
|
62
62
|
export function findRuff(env = process.env) {
|
|
63
63
|
return named("RUFF", env.RUFF) ?? onPath("ruff", env);
|
|
@@ -101,7 +101,7 @@ export const FORMATTERS = {
|
|
|
101
101
|
};
|
|
102
102
|
/**
|
|
103
103
|
* The formatter for `target`, or none when its binary is not there. Each factory is named here rather than
|
|
104
|
-
* held in the table's rows: `
|
|
104
|
+
* held in the table's rows: `clients/spawn-timeout` proves which exports reach a spawn by walking named calls
|
|
105
105
|
* (the repo lint plugin's `spawners.js`), and a closure in a table is opaque to that walk — which would leave a
|
|
106
106
|
* test calling `generated()` free of the bound it needs, since the spawn is real either way.
|
|
107
107
|
*/
|
|
@@ -131,16 +131,16 @@ export async function formatterFor(target, where) {
|
|
|
131
131
|
* A formatter that is not there: the files go out as emitted and the skip is named, so unformatted output is
|
|
132
132
|
* never silent. A consumer generating a Python SDK should not need ruff to get valid Python.
|
|
133
133
|
*
|
|
134
|
-
* `
|
|
135
|
-
* unformatted code. Deliberately NOT `
|
|
134
|
+
* `CLIENTS_REQUIRE_FORMATTERS=1` makes it fail instead, for a pipeline that would rather stop than ship
|
|
135
|
+
* unformatted code. Deliberately NOT `CLIENTS_REQUIRE_TOOLCHAINS`, which this repository's CI sets on six jobs
|
|
136
136
|
* to mean "these TESTS need their toolchain, do not skip" — reading it here turned every incidental
|
|
137
137
|
* generation in CI without oxfmt into a hard failure, which is how rc.10's release run died.
|
|
138
138
|
*/
|
|
139
139
|
export function missingFormatter(target, pass, env, report) {
|
|
140
140
|
const said = `${pass.tool} was not found, so the ${target} output is not formatted (${pass.install})`;
|
|
141
141
|
/* an explicit demand is honoured for every target, quiet or not: the caller asked to be stopped */
|
|
142
|
-
if (env.
|
|
142
|
+
if (env.CLIENTS_REQUIRE_FORMATTERS === "1")
|
|
143
143
|
throw new Error(said);
|
|
144
144
|
if (pass.quiet !== true)
|
|
145
|
-
report(`
|
|
145
|
+
report(`clients: ${said}\n`);
|
|
146
146
|
}
|
package/dist/gen/process.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/** argv that starts the package's `
|
|
1
|
+
/** argv that starts the package's `clients` bin on the current runtime. */
|
|
2
2
|
export declare function cliInvocation(): [string, string];
|
|
3
3
|
/** How a child ended, as a failure names it: its signal, else its exit code. */
|
|
4
4
|
export declare const endOf: (code: number | null, signal: NodeJS.Signals | null) => string;
|
|
5
5
|
/**
|
|
6
|
-
* Runs `
|
|
7
|
-
* with how it ended. A Bun handoff is never repeated in the child, and the child is marked
|
|
6
|
+
* Runs `clients <args>` in `cwd` with its output inherited, and resolves when it exits 0; any other end rejects
|
|
7
|
+
* with how it ended. A Bun handoff is never repeated in the child, and the child is marked CLIENTS_CODEGEN_CHILD, over
|
|
8
8
|
* any `env`, so it refuses `--watch`.
|
|
9
9
|
*/
|
|
10
10
|
export declare function runCli(args: readonly string[], options: {
|
package/dist/gen/process.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The generate CLI's child process (bit 17 phase h): watch mode runs each generation as a fresh `
|
|
2
|
+
* The generate CLI's child process (bit 17 phase h): watch mode runs each generation as a fresh `clients`, so
|
|
3
3
|
* nothing one run loads outlives it. The child is the package's own bin on this runtime, which picks the entry as it
|
|
4
4
|
* does for a user (Bun the TypeScript source, a checkout the source through jiti, an install the compiled one).
|
|
5
5
|
*/
|
|
6
6
|
import { spawn } from "node:child_process";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
|
-
/** argv that starts the package's `
|
|
8
|
+
/** argv that starts the package's `clients` bin on the current runtime. */
|
|
9
9
|
export function cliInvocation() {
|
|
10
|
-
return [process.execPath, fileURLToPath(new URL("../../bin/
|
|
10
|
+
return [process.execPath, fileURLToPath(new URL("../../bin/clients.js", import.meta.url))];
|
|
11
11
|
}
|
|
12
12
|
/** How a child ended, as a failure names it: its signal, else its exit code. */
|
|
13
13
|
export const endOf = (code, signal) => signal ?? `exit ${code}`;
|
|
14
14
|
/**
|
|
15
|
-
* Runs `
|
|
16
|
-
* with how it ended. A Bun handoff is never repeated in the child, and the child is marked
|
|
15
|
+
* Runs `clients <args>` in `cwd` with its output inherited, and resolves when it exits 0; any other end rejects
|
|
16
|
+
* with how it ended. A Bun handoff is never repeated in the child, and the child is marked CLIENTS_CODEGEN_CHILD, over
|
|
17
17
|
* any `env`, so it refuses `--watch`.
|
|
18
18
|
*/
|
|
19
19
|
export function runCli(args, options) {
|
|
@@ -21,7 +21,7 @@ export function runCli(args, options) {
|
|
|
21
21
|
return new Promise((resolve, reject) => {
|
|
22
22
|
const child = spawn(command, [bin, ...args], {
|
|
23
23
|
cwd: options.cwd,
|
|
24
|
-
env: { ...process.env,
|
|
24
|
+
env: { ...process.env, CLIENTS_NO_BUN_HANDOFF: "1", ...options.env, CLIENTS_CODEGEN_CHILD: "1" },
|
|
25
25
|
stdio: ["ignore", "inherit", "inherit"],
|
|
26
26
|
});
|
|
27
27
|
child.on("error", reject);
|
|
@@ -29,7 +29,7 @@ export function runCli(args, options) {
|
|
|
29
29
|
if (code === 0)
|
|
30
30
|
resolve();
|
|
31
31
|
else
|
|
32
|
-
reject(new Error(`
|
|
32
|
+
reject(new Error(`clients ${args[0] ?? ""} failed (${endOf(code, signal)})`));
|
|
33
33
|
});
|
|
34
34
|
});
|
|
35
35
|
}
|
package/dist/gen/targets.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The targets
|
|
2
|
+
* The targets clients generates and each target's options (plan 39 8.1): the table the CLI reads
|
|
3
3
|
* `--<target>-<option>` from, and what a caller holding a run as data (a release manifest) checks it with, so a new
|
|
4
4
|
* target or option reaches that caller with no change of its own. The schemas are Standard Schemas (v1), the kind
|
|
5
|
-
*
|
|
5
|
+
* clients takes everywhere, so any validator that reads one checks a run before it reaches `generated`.
|
|
6
6
|
*/
|
|
7
7
|
import { type Metadata } from "../emit/shared/metadata.ts";
|
|
8
8
|
/**
|
|
@@ -68,7 +68,7 @@ export type TargetOptionsSchema<T extends Target> = {
|
|
|
68
68
|
/** The Standard Schema version. */
|
|
69
69
|
readonly version: 1;
|
|
70
70
|
/** Who made the schema. */
|
|
71
|
-
readonly vendor: "
|
|
71
|
+
readonly vendor: "clients";
|
|
72
72
|
/** Checks `value` as `T`'s options: its option names only, each a non-empty string, a switch true or false. */
|
|
73
73
|
readonly validate: (value: unknown) => OptionsResult<T>;
|
|
74
74
|
/** The types the schema reads and answers, for a caller to infer from; never set at runtime. */
|
package/dist/gen/targets.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The targets
|
|
2
|
+
* The targets clients generates and each target's options (plan 39 8.1): the table the CLI reads
|
|
3
3
|
* `--<target>-<option>` from, and what a caller holding a run as data (a release manifest) checks it with, so a new
|
|
4
4
|
* target or option reaches that caller with no change of its own. The schemas are Standard Schemas (v1), the kind
|
|
5
|
-
*
|
|
5
|
+
* clients takes everywhere, so any validator that reads one checks a run before it reaches `generated`.
|
|
6
6
|
*/
|
|
7
7
|
import { authorName } from "../emit/shared/metadata.js";
|
|
8
8
|
/**
|
|
@@ -111,7 +111,7 @@ function schemaOf(target) {
|
|
|
111
111
|
const issues = given.flatMap(([key, option]) => issueOf(target, key, option) ?? []);
|
|
112
112
|
return issues.length > 0 ? { issues } : { value: Object.fromEntries(given) };
|
|
113
113
|
},
|
|
114
|
-
vendor: "
|
|
114
|
+
vendor: "clients",
|
|
115
115
|
version: 1,
|
|
116
116
|
},
|
|
117
117
|
};
|
package/dist/gen/write.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { PackageIdentity } from "../emit/shared/metadata.ts";
|
|
|
3
3
|
* The manifest a target's directory keeps: `files`, each file it wrote by its path with its sha256, and `packages`,
|
|
4
4
|
* the package as each registry lists it (`registry`, `name`, `version`), when the writer names it.
|
|
5
5
|
*/
|
|
6
|
-
export declare const MANIFEST = ".
|
|
6
|
+
export declare const MANIFEST = ".clients-generated.json";
|
|
7
7
|
/** What a write did: the files rewritten, the stale ones deleted, and the edited stale ones kept. */
|
|
8
8
|
export type Written = {
|
|
9
9
|
/** each stale file removed, its path relative to the directory */
|
package/dist/gen/write.js
CHANGED
|
@@ -14,7 +14,7 @@ import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
|
14
14
|
* The manifest a target's directory keeps: `files`, each file it wrote by its path with its sha256, and `packages`,
|
|
15
15
|
* the package as each registry lists it (`registry`, `name`, `version`), when the writer names it.
|
|
16
16
|
*/
|
|
17
|
-
export const MANIFEST = ".
|
|
17
|
+
export const MANIFEST = ".clients-generated.json";
|
|
18
18
|
const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
19
19
|
/** Whether `path` is a symlink, a dangling one included. */
|
|
20
20
|
function isLink(path) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@workerstack/clients`'s module entry (bit 19 h2): what core's build plugin imports, dynamically, to write an
|
|
3
3
|
* app's artifacts (the route tree, the types, each file only when it changed). The SDK, CLI and MCP server generators
|
|
4
|
-
* stay behind the `
|
|
4
|
+
* stay behind the `clients` bin. Bit 21 e: the MCP handler an app mounts is the plugin's `codegen.mcp` output.
|
|
5
5
|
*/
|
|
6
6
|
export { type Metadata, METADATA_FIELDS, type MetadataField, type PackageIdentity, type Registry, } from "./emit/shared/metadata.ts";
|
|
7
7
|
export { type ExtractedTypes, type ExtractOptions, extractTypes, loadTsMorph } from "./extract/extract.ts";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@workerstack/clients`'s module entry (bit 19 h2): what core's build plugin imports, dynamically, to write an
|
|
3
3
|
* app's artifacts (the route tree, the types, each file only when it changed). The SDK, CLI and MCP server generators
|
|
4
|
-
* stay behind the `
|
|
4
|
+
* stay behind the `clients` bin. Bit 21 e: the MCP handler an app mounts is the plugin's `codegen.mcp` output.
|
|
5
5
|
*/
|
|
6
6
|
export { METADATA_FIELDS, } from "./emit/shared/metadata.js";
|
|
7
7
|
export { extractTypes, loadTsMorph } from "./extract/extract.js";
|
package/dist/ir/load.js
CHANGED
|
@@ -7,12 +7,12 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
7
7
|
return path;
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
|
-
* `
|
|
11
|
-
* document generated by the app's own core, `@workerstack/backend/openapi`, resolved from the app as it would be at run
|
|
10
|
+
* `clients generate --app <module>[#export]` (bit 19 h2, carry-in #1): the app module loaded and its OpenAPI
|
|
11
|
+
* document generated by the app's own core, `@workerstack/backend/http/openapi`, resolved from the app as it would be at run
|
|
12
12
|
* time, so gen imports no core itself (H2). The named export, else `app`, else `default`, is the app; the module's
|
|
13
13
|
* `openApi` export, if any, is the document's options (core's GenerateOpenApiOptions), else a bare `info`. On Node
|
|
14
14
|
* the module loads through jiti, a core checkout read from its source by alias; on Bun through Bun's own import, a
|
|
15
|
-
* checkout read from its source by the
|
|
15
|
+
* checkout read from its source by the backend-source condition, refused when this Bun resolves it elsewhere (bit 20).
|
|
16
16
|
* With no core installed where the app resolves it, the refusal names it.
|
|
17
17
|
*/
|
|
18
18
|
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
@@ -35,11 +35,11 @@ function coreRoot(from) {
|
|
|
35
35
|
return undefined;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
/** A package.json map's entries with a `
|
|
38
|
+
/** A package.json map's entries with a `backend-source` target: each keyed by `key(subpath)`, at that file under `root`. */
|
|
39
39
|
function sourcesOf(root, map, key) {
|
|
40
40
|
const out = {};
|
|
41
41
|
for (const [subpath, target] of Object.entries(map)) {
|
|
42
|
-
const source = typeof target === "object" ? target["
|
|
42
|
+
const source = typeof target === "object" ? target["backend-source"] : undefined;
|
|
43
43
|
if (source !== undefined)
|
|
44
44
|
out[key(subpath)] = join(root, source);
|
|
45
45
|
}
|
|
@@ -61,7 +61,7 @@ function appOf(mod, ref, name) {
|
|
|
61
61
|
if (typeof app?.fetch === "function")
|
|
62
62
|
return app;
|
|
63
63
|
const which = name === undefined ? "no `app` or `default` export" : `no export ${JSON.stringify(name)}`;
|
|
64
|
-
throw new Error(`--app ${ref}: ${which} that is a
|
|
64
|
+
throw new Error(`--app ${ref}: ${which} that is a backend app (name one as <module>#<export>)`);
|
|
65
65
|
}
|
|
66
66
|
/* Node: jiti, its one module cache shared by the app and its document, so both see one core module (its GRAPH symbol) */
|
|
67
67
|
async function jitiImporter(path, alias) {
|
|
@@ -72,7 +72,7 @@ async function jitiImporter(path, alias) {
|
|
|
72
72
|
/*
|
|
73
73
|
* Bun: its own import, never jiti, which there retries a module that threw through its Babel (evaluating it twice),
|
|
74
74
|
* whose Error.prepareStackTrace hook then breaks Bun's captureStackTrace on a non-Error (Vite's follow-redirects), and
|
|
75
|
-
* whose native mode ignores the aliases (bit 20). A checkout's aliases hold by the
|
|
75
|
+
* whose native mode ignores the aliases (bit 20). A checkout's aliases hold by the backend-source condition instead:
|
|
76
76
|
* each must resolve to its source, never to an unbuilt or stale dist/.
|
|
77
77
|
*/
|
|
78
78
|
function bunImporter(bun, path, aliases, ref) {
|
|
@@ -86,7 +86,7 @@ function bunImporter(bun, path, aliases, ref) {
|
|
|
86
86
|
/* unresolvable without the condition (a checkout has no dist/): refused below, as one resolved elsewhere */
|
|
87
87
|
}
|
|
88
88
|
if (resolved !== realpathSync(source))
|
|
89
|
-
throw new Error(`--app ${ref}: ${specifier} is a checkout, read from its source only under the
|
|
89
|
+
throw new Error(`--app ${ref}: ${specifier} is a checkout, read from its source only under the backend-source condition: start Bun with --conditions=backend-source`);
|
|
90
90
|
}
|
|
91
91
|
return (specifier) => import(__rewriteRelativeImportExtension(pathToFileURL(bun.resolveSync(specifier, from)).href));
|
|
92
92
|
}
|
|
@@ -101,12 +101,12 @@ export async function loadAppDocument(ref, cwd) {
|
|
|
101
101
|
throw new Error(`--app ${ref}: no ${CORE} is installed where ${relative(cwd, path)} resolves it`);
|
|
102
102
|
const bun = globalThis.Bun;
|
|
103
103
|
const aliases = sourceAliases(root);
|
|
104
|
-
/* Bun resolves core's own imports under the
|
|
104
|
+
/* Bun resolves core's own imports under the backend-source condition, through core's package.json */
|
|
105
105
|
const load = bun === undefined
|
|
106
106
|
? await jitiImporter(path, { ...aliases.exports, ...aliases.imports })
|
|
107
107
|
: bunImporter(bun, path, aliases.exports, ref);
|
|
108
108
|
const mod = await load(path);
|
|
109
109
|
const app = appOf(mod, ref, name);
|
|
110
|
-
const { generateOpenApi } = (await load(`${CORE}/openapi`));
|
|
110
|
+
const { generateOpenApi } = (await load(`${CORE}/http/openapi`));
|
|
111
111
|
return generateOpenApi(app, mod.openApi ?? DEFAULT_OPTIONS);
|
|
112
112
|
}
|
package/dist/ir/model.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ export type IRParam = {
|
|
|
74
74
|
description?: string;
|
|
75
75
|
/** a path param is always required */
|
|
76
76
|
required?: boolean;
|
|
77
|
-
/** a path param spanning segments (`x-
|
|
77
|
+
/** a path param spanning segments (`x-backend-wildcard`) */
|
|
78
78
|
wildcard?: true;
|
|
79
79
|
/** `schema.default`, as declared */
|
|
80
80
|
default?: unknown;
|
|
@@ -119,12 +119,12 @@ export type IRResponse = {
|
|
|
119
119
|
contentType: string;
|
|
120
120
|
schema?: IRSchema;
|
|
121
121
|
}[];
|
|
122
|
-
/** a response a declared error produces (`x-
|
|
122
|
+
/** a response a declared error produces (`x-backend-error`), never a declared output */
|
|
123
123
|
error?: true;
|
|
124
124
|
};
|
|
125
125
|
export type IROperationExtensions = {
|
|
126
126
|
deprecated?: true;
|
|
127
|
-
/** every declared error key (`x-
|
|
127
|
+
/** every declared error key (`x-backend-errors`): its status, null when it has none, and its own schema */
|
|
128
128
|
errors?: Record<string, {
|
|
129
129
|
schema?: IRSchema;
|
|
130
130
|
status: number | null;
|
|
@@ -133,7 +133,7 @@ export type IROperationExtensions = {
|
|
|
133
133
|
invalidates?: string[];
|
|
134
134
|
mcp?: true;
|
|
135
135
|
realtime?: true;
|
|
136
|
-
/** the
|
|
136
|
+
/** the backend route id the operation came from (`x-backend-route`): what extracted ctx types are keyed by */
|
|
137
137
|
route?: string;
|
|
138
138
|
sse?: true;
|
|
139
139
|
websocket?: true;
|
package/dist/ir/sdk-model.d.ts
CHANGED
|
@@ -79,7 +79,7 @@ export declare function sseEventSchema(op: IROperation, resolve: (schema: IRSche
|
|
|
79
79
|
export declare function sdkModel(ir: IR): SdkModel;
|
|
80
80
|
/** The component schemas on a by-value cycle, direct or mutual: such a reference needs a pointer or a `Box`. */
|
|
81
81
|
export declare function valueCycleSchemas(schemas: Record<string, IRSchema>): Set<string>;
|
|
82
|
-
/**
|
|
82
|
+
/** backend's error envelope (`success: false`, an `error_key` enum, one `status`): its keys and status, else `null`. */
|
|
83
83
|
export declare function irErrorEnvelope(schema: IRSchema, resolve: (schema: IRSchema) => IRSchema): {
|
|
84
84
|
keys: string[];
|
|
85
85
|
status: number;
|
package/dist/ir/sdk-model.js
CHANGED
|
@@ -185,7 +185,7 @@ function envelopeShape(envelope, field, resolve) {
|
|
|
185
185
|
const item = list?.kind === "array" ? resolve(list.items) : undefined;
|
|
186
186
|
return ["error_key", "message", "path"].every((name) => isString(field(item, name)));
|
|
187
187
|
}
|
|
188
|
-
/**
|
|
188
|
+
/** backend's error envelope (`success: false`, an `error_key` enum, one `status`): its keys and status, else `null`. */
|
|
189
189
|
export function irErrorEnvelope(schema, resolve) {
|
|
190
190
|
const field = (object, name) => {
|
|
191
191
|
const found = object?.kind === "object" ? object.fields.find((f) => f.name === name) : undefined;
|
package/dist/ir/slots.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* One operation's slots in the IR: its parameters by where they travel, its request bodies in
|
|
3
|
-
* preference order, its responses by status, and the
|
|
3
|
+
* preference order, its responses by status, and the backend extensions it carries (realtime, SSE,
|
|
4
4
|
* websocket, invalidation…), and for a Standard Webhooks event, its type and data. Component `$ref`s on
|
|
5
5
|
* parameters, bodies, responses and an event's envelope are followed.
|
|
6
6
|
*/
|
|
@@ -31,10 +31,10 @@ export declare function responsesOf(op: Json, components: Components): {
|
|
|
31
31
|
responses: Record<string, IRResponse>;
|
|
32
32
|
sse: boolean;
|
|
33
33
|
};
|
|
34
|
-
/** The
|
|
34
|
+
/** The backend extensions: each only when it is literally `true`; invalidation targets as strings. */
|
|
35
35
|
export declare function extensionsOf(op: Json, sse: boolean): IROperationExtensions;
|
|
36
36
|
/**
|
|
37
|
-
* The Standard Webhooks event the webhook `name` declares through `x-
|
|
37
|
+
* The Standard Webhooks event the webhook `name` declares through `x-backend-webhook`, from its JSON
|
|
38
38
|
* body's `{ type, timestamp, data }` envelope; none when unmarked. gen reads documents it did not
|
|
39
39
|
* write: a marked webhook it could not verify into a typed event is refused, never emitted half.
|
|
40
40
|
*/
|
package/dist/ir/slots.js
CHANGED
|
@@ -55,7 +55,7 @@ function paramOf(p) {
|
|
|
55
55
|
};
|
|
56
56
|
if (typeof p.description === "string")
|
|
57
57
|
param.description = p.description;
|
|
58
|
-
if (p["x-
|
|
58
|
+
if (p["x-backend-wildcard"] === true)
|
|
59
59
|
param.wildcard = true;
|
|
60
60
|
if (schema?.default !== undefined)
|
|
61
61
|
param.default = schema.default;
|
|
@@ -170,7 +170,7 @@ export function responsesOf(op, components) {
|
|
|
170
170
|
return each === undefined ? { contentType } : { contentType, schema: schemaToIR(each) };
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
|
-
if (response?.["x-
|
|
173
|
+
if (response?.["x-backend-error"] === true)
|
|
174
174
|
out.error = true;
|
|
175
175
|
const headers = responseHeaders(response, components);
|
|
176
176
|
if (headers !== undefined)
|
|
@@ -179,7 +179,7 @@ export function responsesOf(op, components) {
|
|
|
179
179
|
}
|
|
180
180
|
return { responses, sse };
|
|
181
181
|
}
|
|
182
|
-
/** The
|
|
182
|
+
/** The backend extensions: each only when it is literally `true`; invalidation targets as strings. */
|
|
183
183
|
export function extensionsOf(op, sse) {
|
|
184
184
|
const out = {};
|
|
185
185
|
if (op["x-websocket"] === true)
|
|
@@ -194,17 +194,17 @@ export function extensionsOf(op, sse) {
|
|
|
194
194
|
out.idempotencyKey = true;
|
|
195
195
|
if (op["x-mcp"] === true)
|
|
196
196
|
out.mcp = true;
|
|
197
|
-
if (typeof op["x-
|
|
198
|
-
out.route = op["x-
|
|
197
|
+
if (typeof op["x-backend-route"] === "string")
|
|
198
|
+
out.route = op["x-backend-route"];
|
|
199
199
|
const invalidate = op["x-invalidate"];
|
|
200
200
|
if (Array.isArray(invalidate))
|
|
201
201
|
out.invalidates = invalidate.filter((target) => typeof target === "string");
|
|
202
|
-
const errors = declaredErrors(op["x-
|
|
202
|
+
const errors = declaredErrors(op["x-backend-errors"]);
|
|
203
203
|
if (errors !== undefined)
|
|
204
204
|
out.errors = errors;
|
|
205
205
|
return out;
|
|
206
206
|
}
|
|
207
|
-
/** `x-
|
|
207
|
+
/** `x-backend-errors` as the IR reads it: each key with a numeric or null status, its schema when it has one. */
|
|
208
208
|
function declaredErrors(raw) {
|
|
209
209
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
210
210
|
return undefined;
|
|
@@ -219,15 +219,15 @@ function declaredErrors(raw) {
|
|
|
219
219
|
return Object.keys(out).length > 0 ? out : undefined;
|
|
220
220
|
}
|
|
221
221
|
/**
|
|
222
|
-
* The Standard Webhooks event the webhook `name` declares through `x-
|
|
222
|
+
* The Standard Webhooks event the webhook `name` declares through `x-backend-webhook`, from its JSON
|
|
223
223
|
* body's `{ type, timestamp, data }` envelope; none when unmarked. gen reads documents it did not
|
|
224
224
|
* write: a marked webhook it could not verify into a typed event is refused, never emitted half.
|
|
225
225
|
*/
|
|
226
226
|
export function eventOf(name, op, components) {
|
|
227
|
-
const marker = op["x-
|
|
227
|
+
const marker = op["x-backend-webhook"];
|
|
228
228
|
if (marker === undefined)
|
|
229
229
|
return undefined;
|
|
230
|
-
const refuse = (reason) => new Error(`x-
|
|
230
|
+
const refuse = (reason) => new Error(`x-backend-webhook on webhook ${JSON.stringify(name)}: ${reason}`);
|
|
231
231
|
if (marker !== "standard-webhooks")
|
|
232
232
|
throw refuse(`${JSON.stringify(marker)} is not standard-webhooks`);
|
|
233
233
|
const content = deref(op.requestBody, components)?.content;
|
|
@@ -17,7 +17,7 @@ const DECIMAL_RADIX = 10;
|
|
|
17
17
|
export const FORCE_COMMIT_LIMIT = 2;
|
|
18
18
|
/** What `release bootstrap` prints when it is not told what to target. */
|
|
19
19
|
export const USAGE = [
|
|
20
|
-
"Usage:
|
|
20
|
+
"Usage: clients release bootstrap --config <path> (--all | --only <names>) [--force-bootstrap]",
|
|
21
21
|
"",
|
|
22
22
|
"Tip: get a token via: gh auth token",
|
|
23
23
|
];
|