@arbol-ai/maximus 7.3.1 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -38
- package/bin/maximus.js +4 -0
- package/config/oxfmt.mjs +1 -0
- package/config/oxlint.mjs +10 -0
- package/dist/analytics/analytics.d.ts +21 -9
- package/dist/analytics/analytics.js +19 -5
- package/dist/body.d.ts +1 -1
- package/dist/body.js +2 -2
- package/dist/chunks/agent-skills-Ef65jTf_.js +49 -0
- package/dist/chunks/agent-skills-m7y1EUch.js +3 -0
- package/dist/chunks/{body-6LichrQm.js → body-DOIHwIIl.js} +14 -7
- package/dist/chunks/{correlation-BEkcFFGT.js → correlation-4b23a-a4.js} +8 -5
- package/dist/chunks/define-app-CfVZBt7D.js +336 -0
- package/dist/chunks/errors-WfyKhiyk.js +131 -0
- package/dist/chunks/execution-CfZEx_JP.js +84 -0
- package/dist/chunks/generate-C-9FKW0o.js +197 -0
- package/dist/chunks/handler-DWTGoduQ.js +140 -0
- package/dist/chunks/http-layout-_h7xwgPC.js +128 -0
- package/dist/chunks/http-paths-DMBxwpp6.js +218 -0
- package/dist/chunks/{json-Bu4BLT25.js → json-B14evE6-.js} +21 -5
- package/dist/chunks/names-ncD7A3DV.js +280 -0
- package/dist/chunks/openapi-CV0KmJpS.js +1588 -0
- package/dist/chunks/openapi-file-OjSs9mRv.js +83 -0
- package/dist/chunks/pages-DyC0m8Zb.js +14 -0
- package/dist/chunks/prepare-configured-BmRJLg6J.js +3 -0
- package/dist/chunks/prepare-configured-Cithjf80.js +52 -0
- package/dist/chunks/project-files-C0OX7MQQ.js +130 -0
- package/dist/chunks/query-kind-CWKAXEME.js +40 -0
- package/dist/chunks/record-DQUDTpEA.js +10 -0
- package/dist/chunks/result-CKgZHrnj.js +56 -0
- package/dist/chunks/{runtime-BPnaa-NK.js → runtime-CVVf5hmp.js} +50 -25
- package/dist/chunks/scaffold-DGrcjR3h.js +3 -0
- package/dist/chunks/scaffold-DZD6dfoZ.js +138 -0
- package/dist/chunks/{schemas-CzTvbXb6.js → schemas-p_aRcMC1.js} +30 -14
- package/dist/chunks/server-CCc7fil4.js +410 -0
- package/dist/chunks/src--HZrH1U9.js +568 -0
- package/dist/chunks/standard-failures-CLjxS2ea.js +74 -0
- package/dist/chunks/{telemetry-BTwB68m5.js → telemetry-C3LfZcOB.js} +32 -11
- package/dist/chunks/{types-BWxDd3tY.d.ts → types-BQYB4Ads.d.ts} +998 -337
- package/dist/chunks/{validation-r-sgmsqb.js → validation-fTohBT6R.js} +69 -28
- package/dist/chunks/workers-types-iONp32T4.d.ts +143 -0
- package/dist/chunks/yaml-Dk2L24yQ.js +74 -0
- package/dist/diagnostics.d.ts +6 -4
- package/dist/diagnostics.js +2 -2
- package/dist/errors.d.ts +2 -2
- package/dist/errors.js +2 -125
- package/dist/http-paths.d.ts +1 -1
- package/dist/http-paths.js +1 -197
- package/dist/index.d.ts +2 -2
- package/dist/index.js +12 -10
- package/dist/internals.d.ts +1 -1
- package/dist/internals.js +5 -3
- package/dist/mcp/index.d.ts +3 -2
- package/dist/mcp/index.js +5 -387
- package/dist/postgres/index.d.ts +25 -8
- package/dist/postgres/index.js +17 -8
- package/dist/project/config.d.ts +139 -0
- package/dist/project/config.js +196 -0
- package/dist/project/index.d.ts +17 -4
- package/dist/project/index.js +44 -9
- package/dist/projection.d.ts +14 -13
- package/dist/projection.js +8 -32
- package/dist/schemas.d.ts +1 -1
- package/dist/schemas.js +2 -2
- package/dist/standard-failures.d.ts +2 -89
- package/dist/standard-failures.js +1 -72
- package/dist/tooling/cli.js +151 -107
- package/dist/tooling/testing.js +2 -2
- package/dist/vite/cloudflare-workers.js +25 -0
- package/dist/vite/index.d.ts +157 -0
- package/dist/vite/index.js +1477 -0
- package/dist/webhooks.d.ts +12 -10
- package/dist/webhooks.js +26 -12
- package/dist/workers/runtime.d.ts +1 -1
- package/dist/workers/runtime.js +1 -1
- package/package.json +30 -22
- package/skills/maximus/SKILL.md +165 -69
- package/skills/maximus/references/deploying.md +73 -0
- package/skills/maximus/references/errors-and-results.md +114 -55
- package/skills/maximus/references/project.md +202 -0
- package/skills/maximus/references/routes-and-tools.md +256 -0
- package/skills/maximus/references/testing.md +137 -50
- package/skills/maximus/references/transports.md +113 -100
- package/skills/maximus/references/writing-code.md +84 -0
- package/templates/mcp/mcp/instructions.md.template +2 -0
- package/templates/mcp/routes/v1/greeting.get.ts.template +12 -0
- package/templates/mcp/tests/mcp.test.ts.template +36 -0
- package/templates/project/.agents/skills/project/SKILL.md.template +21 -12
- package/templates/project/.github/workflows/ci.yml.template +4 -1
- package/templates/project/CLAUDE.md.template +41 -22
- package/templates/project/README.md.template +54 -47
- package/templates/project/middleware/10-response.ts.template +16 -0
- package/templates/project/package.json.template +16 -8
- package/templates/project/pages/index.ts.template +2 -4
- package/templates/project/routes/v1/greeting.get.ts.template +10 -0
- package/templates/project/routes/v1/greeting.post.ts.template +12 -0
- package/templates/project/tests/greeting.test.ts.template +45 -0
- package/templates/project/tsconfig.json.template +8 -5
- package/templates/project/vite.config.ts.template +15 -7
- package/templates/web/app/main.tsx.template +16 -0
- package/templates/web/app/root.tsx.template +17 -0
- package/templates/web/app/routes/index.tsx.template +9 -0
- package/templates/web/index.html.template +12 -0
- package/templates/web/package.json.template +12 -0
- package/templates/web/tsconfig.json.template +7 -0
- package/templates/web/vite.config.ts.template +22 -0
- package/dist/chunks/execution-B-yy4C7N.js +0 -691
- package/dist/chunks/prepare-project-zi106pWF.js +0 -146
- package/dist/chunks/record-DY-lX9w1.js +0 -34
- package/dist/chunks/src-DPSpGNnT.js +0 -1164
- package/dist/client/client.d.ts +0 -129
- package/dist/client/client.js +0 -321
- package/dist/tooling/vite.d.ts +0 -3
- package/dist/tooling/vite.js +0 -44
- package/skills/maximus/references/adding-an-operation.md +0 -179
- package/skills/maximus/references/building-a-service.md +0 -167
- package/skills/maximus/references/migration-from-v2.md +0 -62
- package/skills/maximus/references/migration-to-v5.md +0 -37
- package/skills/maximus/references/publishing-and-verification.md +0 -39
- package/templates/project/cloudflare.config.ts.template +0 -24
- package/templates/project/routes/v1/greeting.ts.template +0 -22
- package/templates/project/src/app.ts.template +0 -2
- package/templates/project/src/application.ts.template +0 -26
- package/templates/project/src/index.ts.template +0 -3
- package/templates/project/src/worker.ts.template +0 -6
- package/templates/service/.agents/skills/project/SKILL.md.template +0 -10
- package/templates/service/.github/workflows/ci.yml.template +0 -21
- package/templates/service/.gitignore.template +0 -9
- package/templates/service/CLAUDE.md.template +0 -5
- package/templates/service/README.md.template +0 -45
- package/templates/service/cloudflare.config.ts.template +0 -30
- package/templates/service/package.json.template +0 -36
- package/templates/service/src/app.ts.template +0 -30
- package/templates/service/src/index.ts.template +0 -13
- package/templates/service/tests/contract.test.ts.template +0 -12
- package/templates/service/tsconfig.json.template +0 -16
- package/templates/service/vite.config.ts.template +0 -13
- package/templates/service/vitest.config.ts.template +0 -10
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { a as routeGroup, r as ok, t as err } from "../chunks/result-CKgZHrnj.js";
|
|
2
|
+
import { c as isHandlerDeclaration, l as isToolDeclaration, s as isContextDeclaration, t as Failed } from "../chunks/handler-DWTGoduQ.js";
|
|
3
|
+
import { n as routeTitle, t as routeName } from "../chunks/names-ncD7A3DV.js";
|
|
4
|
+
|
|
5
|
+
// src/project/bind.ts
|
|
6
|
+
/** A route's effect when it declares none: GET reads, DELETE deletes and the other methods write. */
|
|
7
|
+
function methodEffect(method) {
|
|
8
|
+
if (method === "GET") return "read";
|
|
9
|
+
return method === "DELETE" ? "delete" : "write";
|
|
10
|
+
}
|
|
11
|
+
/** The methods HTTP defines as idempotent: the default idempotent hint of a route's tool. */
|
|
12
|
+
const IDEMPOTENT_METHODS = /* @__PURE__ */ new Set([
|
|
13
|
+
"GET",
|
|
14
|
+
"PUT",
|
|
15
|
+
"DELETE"
|
|
16
|
+
]);
|
|
17
|
+
/** `complete_task` as `Complete task`: a tool's default title. */
|
|
18
|
+
function humanize(name) {
|
|
19
|
+
const words = name.replaceAll("_", " ");
|
|
20
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
21
|
+
}
|
|
22
|
+
/** A segment name in PascalCase, as `Word` types it. */
|
|
23
|
+
function word(segment) {
|
|
24
|
+
return segment.split(/[-_]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
25
|
+
}
|
|
26
|
+
/** A tool's operation name, as `ToolName` types it. */
|
|
27
|
+
function toolName(file) {
|
|
28
|
+
const name = word(file);
|
|
29
|
+
return name.charAt(0).toLowerCase() + name.slice(1);
|
|
30
|
+
}
|
|
31
|
+
/** The resource a route's scope names by default: its first fixed segment after the version, in kebab-case. */
|
|
32
|
+
function routeResource(path) {
|
|
33
|
+
const segments = path.split("/").filter(Boolean);
|
|
34
|
+
return segments.slice(/^v[1-9][0-9]*$/.test(segments[0] ?? "") ? 1 : 0).find((segment) => !segment.startsWith("{"))?.replaceAll(/([a-z0-9])([A-Z])/g, "$1-$2").replaceAll("_", "-").toLowerCase();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The `fail` a declaration receives: the catalog's failure for a code, with the data the code declares. An
|
|
38
|
+
* unknown code, or data its code refuses, throws, which the execution path reports as `INTERNAL_ERROR`.
|
|
39
|
+
*/
|
|
40
|
+
function catalogFail(errors) {
|
|
41
|
+
const names = new Map(Object.entries(errors.definitions).map(([name, { code }]) => [code, name]));
|
|
42
|
+
return (code, data) => {
|
|
43
|
+
const factory = Reflect.get(errors, names.get(code) ?? "");
|
|
44
|
+
if (typeof factory !== "object" || factory === null || !("create" in factory) || typeof factory.create !== "function") throw new TypeError(`The error catalog has no failure ${code}.`);
|
|
45
|
+
return new Failed(factory.create(data));
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** A byte body as a route reads it: a failure to read is one the route answers as it is. */
|
|
49
|
+
function routeBody(body) {
|
|
50
|
+
return { async read() {
|
|
51
|
+
const bytes = await body.read();
|
|
52
|
+
return bytes.ok ? bytes : err(new Failed(bytes.error));
|
|
53
|
+
} };
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Runs a declaration's handler as an operation: its output answers a success and `fail(code)` the catalog's
|
|
57
|
+
* failure. The execution path checks the declared failures and the output once, as for every operation.
|
|
58
|
+
*/
|
|
59
|
+
function execute(errors, handler) {
|
|
60
|
+
const fail = catalogFail(errors);
|
|
61
|
+
return async (context, input) => {
|
|
62
|
+
const answer = await handler({
|
|
63
|
+
...context,
|
|
64
|
+
input,
|
|
65
|
+
fail,
|
|
66
|
+
...context.body ? { body: routeBody(context.body) } : {}
|
|
67
|
+
});
|
|
68
|
+
return Failed.is(answer) ? err(answer.failure) : ok(answer);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Prepares every call's context with `context.ts`'s declaration, after admission: what it returns joins the
|
|
73
|
+
* context, and `fail(code)` answers the call. The base must not declare operations yet.
|
|
74
|
+
*/
|
|
75
|
+
function bindContext(base, declaration) {
|
|
76
|
+
if (!isContextDeclaration(declaration)) throw new TypeError("context.ts's default export must come from defineContext.");
|
|
77
|
+
const fail = catalogFail(base.definition.errors);
|
|
78
|
+
return base.derive(async (invocation) => {
|
|
79
|
+
const answer = await declaration.prepare({
|
|
80
|
+
...invocation,
|
|
81
|
+
fail
|
|
82
|
+
});
|
|
83
|
+
return Failed.is(answer) ? err(answer.failure) : ok(answer);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Binds a `defineHandler` declaration to the application, under the path and method its filename gives. The
|
|
88
|
+
* operation is named by its `operationId`, else by `name`, the one `maximus prepare` derives from its method
|
|
89
|
+
* and path with `routeName`: `getNote` for `GET /v1/notes/{noteId}`.
|
|
90
|
+
*/
|
|
91
|
+
function bindRoute(base, declaration, path, method, name) {
|
|
92
|
+
if (!isHandlerDeclaration(declaration)) throw new TypeError(`${method} ${path}: a route file's default export must come from defineHandler.`);
|
|
93
|
+
const { operationId, effect = methodEffect(method), scope, title = routeTitle(method, path), group = routeGroup(path), description = "", http, mcp, ...options } = declaration.options;
|
|
94
|
+
const resource = routeResource(path);
|
|
95
|
+
if (scope === void 0 && resource === void 0) throw new TypeError(`${method} ${path}: no fixed segment names its scope; declare its scope.`);
|
|
96
|
+
if (mcp && !description.trim()) throw new TypeError(`${method} ${path}: a route that is an MCP tool describes what it does.`);
|
|
97
|
+
if (method === "DELETE" && effect === "read") throw new TypeError(`${method} ${path}: a DELETE route deletes; its effect is delete or write, never read.`);
|
|
98
|
+
const definition = {
|
|
99
|
+
...options,
|
|
100
|
+
title,
|
|
101
|
+
...group === void 0 ? {} : { group },
|
|
102
|
+
description,
|
|
103
|
+
effect,
|
|
104
|
+
scope: scope ?? `${base.definition.namespace}:${resource}:${effect === "read" ? "read" : "write"}`,
|
|
105
|
+
input: declaration.input,
|
|
106
|
+
output: declaration.output,
|
|
107
|
+
http: {
|
|
108
|
+
...http,
|
|
109
|
+
method,
|
|
110
|
+
path
|
|
111
|
+
},
|
|
112
|
+
...mcp ? { mcp: {
|
|
113
|
+
...mcp,
|
|
114
|
+
idempotent: mcp.idempotent ?? IDEMPOTENT_METHODS.has(method)
|
|
115
|
+
} } : {}
|
|
116
|
+
};
|
|
117
|
+
return base.operation(operationId ?? name, definition, execute(base.definition.errors, declaration.handler));
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Binds a `defineTool` declaration to the application, under the name its file gives: `summarize-tasks` is
|
|
121
|
+
* the operation `summarizeTasks` and the tool `summarize_tasks`.
|
|
122
|
+
*/
|
|
123
|
+
function bindTool(base, declaration, file) {
|
|
124
|
+
if (!isToolDeclaration(declaration)) throw new TypeError(`Tool ${file}: an MCP tool file's default export must come from defineTool.`);
|
|
125
|
+
if (!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(file)) throw new TypeError(`Tool ${file}: name tool files in kebab-case, such as summarize-tasks.ts.`);
|
|
126
|
+
const { effect, scope, title, idempotent = effect === "read", openWorld, ...options } = declaration.options;
|
|
127
|
+
const name = file.replaceAll("-", "_");
|
|
128
|
+
const definition = {
|
|
129
|
+
...options,
|
|
130
|
+
title: title ?? humanize(name),
|
|
131
|
+
effect,
|
|
132
|
+
scope: scope ?? `${base.definition.namespace}:${file}:${effect === "read" ? "read" : "write"}`,
|
|
133
|
+
input: declaration.input,
|
|
134
|
+
output: declaration.output,
|
|
135
|
+
mcp: {
|
|
136
|
+
name,
|
|
137
|
+
idempotent,
|
|
138
|
+
...openWorld === void 0 ? {} : { openWorld }
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
return base.operation(toolName(file), definition, execute(base.definition.errors, declaration.handler));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/project/config.ts
|
|
145
|
+
/**
|
|
146
|
+
* Declares a `middleware/` module that wraps every HTTP request, in filename order, before the request's
|
|
147
|
+
* token is verified: CORS, security headers, request ids. It cannot authenticate a caller or bypass admission.
|
|
148
|
+
*/
|
|
149
|
+
function defineMiddleware(handle) {
|
|
150
|
+
return {
|
|
151
|
+
phase: "request",
|
|
152
|
+
handle
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Declares a `middleware/` module that runs after the caller is admitted, around every operation over HTTP,
|
|
157
|
+
* MCP and RPC, with the verified invocation: business policy that must hold on every transport.
|
|
158
|
+
*/
|
|
159
|
+
function defineOperationMiddleware(handle) {
|
|
160
|
+
return {
|
|
161
|
+
phase: "operation",
|
|
162
|
+
handle
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Splits `middleware/`'s modules by phase, in their order, keeping each module's own context type. A default
|
|
167
|
+
* export that neither helper made is refused.
|
|
168
|
+
*/
|
|
169
|
+
function collectMiddleware(modules) {
|
|
170
|
+
const middleware = [];
|
|
171
|
+
const requestMiddleware = [];
|
|
172
|
+
for (const module of modules) if (module?.phase === "operation" && typeof module.handle === "function") middleware.push(module.handle);
|
|
173
|
+
else if (module?.phase === "request" && typeof module.handle === "function") requestMiddleware.push(module.handle);
|
|
174
|
+
else throw new TypeError("A middleware module must default-export defineMiddleware or defineOperationMiddleware.");
|
|
175
|
+
return {
|
|
176
|
+
middleware,
|
|
177
|
+
requestMiddleware
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/** Applies the project's operation middleware to its base, before any route binds to it. */
|
|
181
|
+
function useProjectMiddleware(base, middleware) {
|
|
182
|
+
let application = base;
|
|
183
|
+
for (const handler of middleware) application = application.use(handler);
|
|
184
|
+
return application;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Refuses an application whose operations do not all run the project's middleware, as a route bound to an
|
|
188
|
+
* earlier base would: its policy would silently be skipped.
|
|
189
|
+
*/
|
|
190
|
+
function checkProjectPipeline(base, app) {
|
|
191
|
+
const expected = base.definition.middleware ?? [];
|
|
192
|
+
for (const [name, operation] of Object.entries(app.operations)) if (expected.some((handler, index) => operation.pipeline?.middleware[index] !== handler)) throw new TypeError(`Operation "${name}" omits project middleware. Bind it to the base in .maximus/base.ts.`);
|
|
193
|
+
return app;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export { bindContext, bindRoute, bindTool, checkProjectPipeline, collectMiddleware, defineMiddleware, defineOperationMiddleware, routeName, toolName, useProjectMiddleware };
|
package/dist/project/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as HttpRoute, pn as OperationShape, rn as AppManifest } from "../chunks/types-BQYB4Ads.js";
|
|
2
|
+
import { n as WorkerOptions, r as WorkerRuntime } from "../chunks/workers-types-iONp32T4.js";
|
|
2
3
|
/** File modules use native Workers handlers; unmatched events fail instead of disappearing. */
|
|
3
4
|
type Handlers<E> = Omit<ExportedHandler<E>, 'fetch'>;
|
|
4
5
|
/** One schedule, declared beside the code it runs. Configure its trigger in Cloudflare as well. */
|
|
@@ -12,13 +13,25 @@ interface ProjectEvents<E> {
|
|
|
12
13
|
queues?: Readonly<Record<string, NonNullable<Handlers<E>['queue']>>>;
|
|
13
14
|
email?: Readonly<Record<string, NonNullable<Handlers<E>['email']>>>;
|
|
14
15
|
}
|
|
15
|
-
/**
|
|
16
|
+
/** The methods a page may answer; one that answers `GET` also answers `HEAD`. */
|
|
17
|
+
export type PageMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
18
|
+
/**
|
|
19
|
+
* A page: a native response handler at a fixed path outside the API, such as a landing page or a provider's
|
|
20
|
+
* webhook. A function answers `GET`; a record answers each method it names, `{ POST: receive }`.
|
|
21
|
+
*/
|
|
22
|
+
export type ProjectPage<E> = HttpRoute<E> | Readonly<Partial<Record<PageMethod, HttpRoute<E>>>>;
|
|
23
|
+
/** The modules a project's Worker composes: its pages and its event handlers. */
|
|
16
24
|
export interface ProjectModules<E> extends ProjectEvents<E> {
|
|
17
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The pages, keyed by their path: fixed paths the API, discovery and the Worker's other routes leave free.
|
|
27
|
+
* Rendering libraries stay in the application.
|
|
28
|
+
*/
|
|
29
|
+
pages?: Readonly<Record<string, ProjectPage<E>>>;
|
|
18
30
|
}
|
|
19
31
|
/**
|
|
20
32
|
* Compose discovered modules through the existing runtime. Operations keep its single authorization,
|
|
21
|
-
* schema and diagnostic pipeline; pages only answer paths outside the API and protocol namespaces
|
|
33
|
+
* schema and diagnostic pipeline; pages only answer paths outside the API and protocol namespaces, each the
|
|
34
|
+
* methods it declares, and `405` with an `allow` header for any other.
|
|
22
35
|
*/
|
|
23
36
|
export declare function createProjectWorker<E, C, O extends Record<string, OperationShape>>(app: AppManifest<E, C, O>, modules: ProjectModules<E>, options?: WorkerOptions<E>): WorkerRuntime<E, O>;
|
|
24
37
|
export type { ProjectCron, ProjectEvents };
|
package/dist/project/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { standardErrors } from "../errors.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { i as standardErrors } from "../chunks/errors-WfyKhiyk.js";
|
|
2
|
+
import { r as createAssetHandler, t as createWorker } from "../chunks/runtime-CVVf5hmp.js";
|
|
3
|
+
import { t as checkPagePaths } from "../chunks/pages-DyC0m8Zb.js";
|
|
4
4
|
|
|
5
5
|
// src/project/handlers.ts
|
|
6
6
|
/** Compose file handlers with explicit fallbacks, preserving the platform's execution context. */
|
|
@@ -50,15 +50,49 @@ function projectHandlers(events, fallback = {}) {
|
|
|
50
50
|
|
|
51
51
|
// src/project/index.ts
|
|
52
52
|
/** Optional Workers composition for projects whose modules are discovered by `maximus prepare`. */
|
|
53
|
+
/** The methods a page record may name. */
|
|
54
|
+
const PAGE_METHODS = /* @__PURE__ */ new Set([
|
|
55
|
+
"GET",
|
|
56
|
+
"POST",
|
|
57
|
+
"PUT",
|
|
58
|
+
"PATCH",
|
|
59
|
+
"DELETE"
|
|
60
|
+
]);
|
|
61
|
+
/** The order an `allow` header lists a page's methods in: `HEAD` beside the `GET` that answers it. */
|
|
62
|
+
const ALLOW_ORDER = [
|
|
63
|
+
"GET",
|
|
64
|
+
"HEAD",
|
|
65
|
+
"POST",
|
|
66
|
+
"PUT",
|
|
67
|
+
"PATCH",
|
|
68
|
+
"DELETE"
|
|
69
|
+
];
|
|
70
|
+
/**
|
|
71
|
+
* Each method a page answers, with its handler. Refuses a method other than `GET`, `POST`, `PUT`, `PATCH`
|
|
72
|
+
* and `DELETE`, a handler that is not a function, and a record that names no method.
|
|
73
|
+
*/
|
|
74
|
+
function pageRoutes(path, page) {
|
|
75
|
+
const entries = typeof page === "function" ? [["GET", page]] : Object.entries(page);
|
|
76
|
+
const methods = /* @__PURE__ */ new Map();
|
|
77
|
+
for (const [method, route] of entries) {
|
|
78
|
+
if (!PAGE_METHODS.has(method) || typeof route !== "function") throw new TypeError(`Page ${path} must map GET, POST, PUT, PATCH or DELETE to a handler function; it maps ${method}.`);
|
|
79
|
+
methods.set(method, route);
|
|
80
|
+
}
|
|
81
|
+
if (methods.size === 0) throw new TypeError(`Page ${path} must answer at least one method.`);
|
|
82
|
+
return {
|
|
83
|
+
methods,
|
|
84
|
+
allow: ALLOW_ORDER.filter((method) => methods.has(method === "HEAD" ? "GET" : method)).join(", ")
|
|
85
|
+
};
|
|
86
|
+
}
|
|
53
87
|
/**
|
|
54
88
|
* Compose discovered modules through the existing runtime. Operations keep its single authorization,
|
|
55
|
-
* schema and diagnostic pipeline; pages only answer paths outside the API and protocol namespaces
|
|
89
|
+
* schema and diagnostic pipeline; pages only answer paths outside the API and protocol namespaces, each the
|
|
90
|
+
* methods it declares, and `405` with an `allow` header for any other.
|
|
56
91
|
*/
|
|
57
92
|
function createProjectWorker(app, modules, options = {}) {
|
|
58
93
|
if (options.assets && options.http?.fallback) throw new TypeError("Worker assets and an HTTP fallback cannot both own unmatched paths.");
|
|
59
|
-
const pages = new Map(Object.entries(modules.pages ?? {}));
|
|
60
|
-
|
|
61
|
-
for (const path of pages.keys()) if (!/^\/(?:[a-zA-Z0-9._~-]+(?:\/[a-zA-Z0-9._~-]+)*)?$/.test(path) || path.split("/").some((segment) => segment === "." || segment === "..") || native.reserved.has(path) || native.base && ownsPrefix(native.base, path) || VERSIONED_PATH.test(path) || ownsPrefix("/.well-known", path) || Object.hasOwn(options.routes ?? {}, path) || Object.keys(options.http?.mounts ?? {}).some((prefix) => ownsPrefix(prefix, path)) || options.transports?.some((transport) => ownsPrefix(transport.path, path))) throw new TypeError(`Page path is reserved or malformed: ${path}. Move the API with http.basePath.`);
|
|
94
|
+
const pages = new Map(Object.entries(modules.pages ?? {}).map(([path, page]) => [path, pageRoutes(path, page)]));
|
|
95
|
+
checkPagePaths(pages.keys(), app.tokens, options);
|
|
62
96
|
const fallback = options.assets ? createAssetHandler(options.assets) : options.http?.fallback;
|
|
63
97
|
return createWorker(app, {
|
|
64
98
|
...options,
|
|
@@ -69,8 +103,9 @@ function createProjectWorker(app, modules, options = {}) {
|
|
|
69
103
|
async fallback(request, env, context) {
|
|
70
104
|
const page = pages.get(new URL(request.url).pathname);
|
|
71
105
|
if (page) {
|
|
72
|
-
|
|
73
|
-
|
|
106
|
+
const route = page.methods.get(request.method === "HEAD" ? "GET" : request.method);
|
|
107
|
+
if (!route) return context.fail(standardErrors.methodNotAllowed.create(), { allow: page.allow });
|
|
108
|
+
const response = await route(request, env, context);
|
|
74
109
|
return request.method === "HEAD" ? new Response(null, response) : response;
|
|
75
110
|
}
|
|
76
111
|
return fallback ? await fallback(request, env, context) : context.fail(standardErrors.notFound.create());
|
package/dist/projection.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* How a service's names and input schemas project onto the surfaces a gateway builds from its OpenAPI
|
|
3
|
-
* document, so the service, the gateway and the gateway's generated clients agree without coordinating:
|
|
4
|
-
* the MCP tool, the CLI's kebab-case words, a permission's description and the typed query codec.
|
|
5
|
-
* Browser-safe: no runtime, no schema library.
|
|
6
|
-
*/
|
|
7
1
|
/** How one input field travels in a query string. */
|
|
8
|
-
|
|
2
|
+
type QueryKind = 'string' | 'integer' | 'number' | 'boolean' | 'list';
|
|
9
3
|
/** Resolves a local `$ref` (`#/components/schemas/<name>`) of a bundled document. */
|
|
10
|
-
|
|
4
|
+
type SchemaResolver = (reference: string) => unknown;
|
|
5
|
+
/**
|
|
6
|
+
* How one input field travels in a query string, its `$ref`s followed through `resolve`, or null when it
|
|
7
|
+
* cannot: objects and nested lists do not. Lists are comma separated; a `null` alternative is not
|
|
8
|
+
* expressible and is ignored.
|
|
9
|
+
*/
|
|
10
|
+
export declare function queryKind(schema: unknown, resolve?: SchemaResolver): QueryKind | null;
|
|
11
11
|
/** A resource and the verb that acts on it, such as `appointments` and `findNearest`. */
|
|
12
12
|
export interface ProjectedName {
|
|
13
13
|
/** The resource, in camelCase. */
|
|
@@ -25,10 +25,11 @@ export declare function snake(value: string): string;
|
|
|
25
25
|
* never stands in, since a permission covers several operations.
|
|
26
26
|
*/
|
|
27
27
|
export declare function permissionDescription(scope: string): string;
|
|
28
|
-
/** Portable across MCP clients and model providers (`^[a-z][a-z0-9_]{0,63}$`). */
|
|
29
|
-
export declare function mcpToolName(namespace: string, name: ProjectedName): string;
|
|
30
28
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
29
|
+
* The MCP tool name a gateway gives an operation, `<namespace>_<resource>_<verb>` in snake_case: the
|
|
30
|
+
* namespace `scheduling` with `{ resource: 'appointments', verb: 'findNearest' }` is
|
|
31
|
+
* `scheduling_appointments_find_nearest`. A name that is not portable across MCP clients and model providers
|
|
32
|
+
* (`^[a-z][a-z0-9_]{0,63}$`) throws a TypeError.
|
|
33
33
|
*/
|
|
34
|
-
export declare function
|
|
34
|
+
export declare function mcpToolName(namespace: string, name: ProjectedName): string;
|
|
35
|
+
export type { QueryKind, SchemaResolver };
|
package/dist/projection.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { t as queryKind } from "./chunks/query-kind-CWKAXEME.js";
|
|
2
|
+
|
|
1
3
|
// src/projection.ts
|
|
2
|
-
function record(value) {
|
|
3
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
4
|
-
}
|
|
5
4
|
/** A camelCase name in kebab-case: `findNearest` is `find-nearest`. */
|
|
6
5
|
function kebab(value) {
|
|
7
6
|
return value.replaceAll(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
@@ -21,39 +20,16 @@ function permissionDescription(scope) {
|
|
|
21
20
|
const subject = segments.slice(0, -1).join(" ").replaceAll("-", " ");
|
|
22
21
|
return `${action.charAt(0).toUpperCase()}${action.slice(1)} ${subject}`;
|
|
23
22
|
}
|
|
24
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* The MCP tool name a gateway gives an operation, `<namespace>_<resource>_<verb>` in snake_case: the
|
|
25
|
+
* namespace `scheduling` with `{ resource: 'appointments', verb: 'findNearest' }` is
|
|
26
|
+
* `scheduling_appointments_find_nearest`. A name that is not portable across MCP clients and model providers
|
|
27
|
+
* (`^[a-z][a-z0-9_]{0,63}$`) throws a TypeError.
|
|
28
|
+
*/
|
|
25
29
|
function mcpToolName(namespace, name) {
|
|
26
30
|
const tool = `${snake(namespace)}_${snake(name.resource)}_${snake(name.verb)}`;
|
|
27
31
|
if (!/^[a-z][a-z0-9_]{0,63}$/.test(tool)) throw new TypeError(`MCP tool name ${tool} is not portable.`);
|
|
28
32
|
return tool;
|
|
29
33
|
}
|
|
30
|
-
function resolved(schema, resolve) {
|
|
31
|
-
let value = schema;
|
|
32
|
-
for (let depth = 0; record(value) && typeof value.$ref === "string"; depth += 1) {
|
|
33
|
-
if (!resolve || depth > 16) return;
|
|
34
|
-
value = resolve(value.$ref);
|
|
35
|
-
}
|
|
36
|
-
return value;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* How one input field travels in a query string, or null when it cannot: objects and nested lists
|
|
40
|
-
* do not. Lists are comma separated; a `null` alternative is not expressible and is ignored.
|
|
41
|
-
*/
|
|
42
|
-
function queryKind(schema, resolve) {
|
|
43
|
-
const value = resolved(schema, resolve);
|
|
44
|
-
if (!record(value)) return null;
|
|
45
|
-
let branches = null;
|
|
46
|
-
if (Array.isArray(value.anyOf)) branches = value.anyOf;
|
|
47
|
-
else if (Array.isArray(value.oneOf)) branches = value.oneOf;
|
|
48
|
-
if (branches) {
|
|
49
|
-
const kinds = branches.filter((branch) => !(record(branch) && branch.type === "null")).map((branch) => queryKind(branch, resolve));
|
|
50
|
-
if (!kinds.length || kinds.includes(null)) return null;
|
|
51
|
-
if (kinds.includes("list")) return kinds.every((kind) => kind === "list" || kind === "string") ? "list" : null;
|
|
52
|
-
return kinds.every((kind) => kind === kinds[0]) ? kinds[0] ?? null : null;
|
|
53
|
-
}
|
|
54
|
-
if (value.type === "array") return queryKind(value.items, resolve) === "string" ? "list" : null;
|
|
55
|
-
if (value.type === "string" || typeof value.const === "string" || Array.isArray(value.enum) && value.enum.every((entry) => typeof entry === "string")) return "string";
|
|
56
|
-
return value.type === "integer" || value.type === "number" || value.type === "boolean" ? value.type : null;
|
|
57
|
-
}
|
|
58
34
|
|
|
59
35
|
export { kebab, mcpToolName, permissionDescription, queryKind, snake };
|
package/dist/schemas.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as PageInfo, B as DeletedObject, Ct as urlSchema, Dt as parseInput, Et as decodeSchema, F as Static, G as NamedReference, H as EmailAddressSchema, I as TSchema, J as PostalAddress, Jn as StaticDecode, K as NamedReferenceSchema, L as Type, N as EmptyInputSchema, Ot as parseSchema, P as OrganizationIdSchema, Q as Page, R as UuidSchema, St as transformSchema, Tt as decodeInput, U as HexColorSchema, V as DeletedObjectSchema, W as HttpsUrlSchema, X as SignedUrl, Y as PostalAddressSchema, Z as SignedUrlSchema, _t as normalizeSchema, at as Checked, bt as strictObject, ct as SchemaInput, dt as defaultSchema, et as PageInfoSchema, ft as extendObject, gt as looseObject, ht as literalUnion, ir as AttachmentOutputSchema, it as pageLimit, lt as SchemaIssue, mt as inspectSchema, nt as PageQueryFields, ot as checkSchema, pt as inputSchema, q as PhoneNumberSchema, rr as Attachment, rt as TPage, st as readSchema, tt as PageQuery, ut as SchemaValidationError, vt as pipeSchema, wt as InputIssue, xt as stripObject, yt as refineSchema, z as t } from "./chunks/types-BQYB4Ads.js";
|
|
2
2
|
export { type Attachment, AttachmentOutputSchema, type Checked, type DeletedObject, DeletedObjectSchema, EmailAddressSchema, EmptyInputSchema, HexColorSchema, HttpsUrlSchema, type InputIssue, type NamedReference, NamedReferenceSchema, OrganizationIdSchema, Page, type PageInfo, PageInfoSchema, type PageQuery, PageQueryFields, PhoneNumberSchema, type PostalAddress, PostalAddressSchema, type SchemaInput, type SchemaIssue, SchemaValidationError, type SignedUrl, SignedUrlSchema, type Static, type StaticDecode, type TPage, type TSchema, Type, UuidSchema, checkSchema, decodeInput, decodeSchema, defaultSchema, extendObject, inputSchema, inspectSchema, literalUnion, looseObject, normalizeSchema, pageLimit, parseInput, parseSchema, pipeSchema, readSchema, refineSchema, strictObject, stripObject, t, transformSchema, urlSchema };
|
package/dist/schemas.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
import { _ as pageLimit, a as t, b as readSchema, c as HexColorSchema, d as PhoneNumberSchema, f as PostalAddressSchema, g as PageQueryFields, h as PageInfoSchema, i as UuidSchema, l as HttpsUrlSchema, m as Page, n as OrganizationIdSchema, o as DeletedObjectSchema, p as SignedUrlSchema, r as Type, s as EmailAddressSchema, t as EmptyInputSchema, u as NamedReferenceSchema, v as AttachmentOutputSchema, y as checkSchema } from "./chunks/schemas-
|
|
1
|
+
import { _ as refineSchema, b as transformSchema, c as defaultSchema, d as inputSchema, f as inspectSchema, g as pipeSchema, h as normalizeSchema, i as parseSchema, l as extendObject, m as looseObject, n as decodeSchema, p as literalUnion, r as parseInput, s as SchemaValidationError, t as decodeInput, v as strictObject, x as urlSchema, y as stripObject } from "./chunks/validation-fTohBT6R.js";
|
|
2
|
+
import { _ as pageLimit, a as t, b as readSchema, c as HexColorSchema, d as PhoneNumberSchema, f as PostalAddressSchema, g as PageQueryFields, h as PageInfoSchema, i as UuidSchema, l as HttpsUrlSchema, m as Page, n as OrganizationIdSchema, o as DeletedObjectSchema, p as SignedUrlSchema, r as Type, s as EmailAddressSchema, t as EmptyInputSchema, u as NamedReferenceSchema, v as AttachmentOutputSchema, y as checkSchema } from "./chunks/schemas-p_aRcMC1.js";
|
|
3
3
|
|
|
4
4
|
export { AttachmentOutputSchema, DeletedObjectSchema, EmailAddressSchema, EmptyInputSchema, HexColorSchema, HttpsUrlSchema, NamedReferenceSchema, OrganizationIdSchema, Page, PageInfoSchema, PageQueryFields, PhoneNumberSchema, PostalAddressSchema, SchemaValidationError, SignedUrlSchema, Type, UuidSchema, checkSchema, decodeInput, decodeSchema, defaultSchema, extendObject, inputSchema, inspectSchema, literalUnion, looseObject, normalizeSchema, pageLimit, parseInput, parseSchema, pipeSchema, readSchema, refineSchema, strictObject, stripObject, t, transformSchema, urlSchema };
|
|
@@ -1,89 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* message, retryability and Retry-After. No runtime and no schema library, for a dispatcher that presents
|
|
4
|
-
* them, such as an API gateway. `defineErrors` builds their schemas from this same table.
|
|
5
|
-
*/
|
|
6
|
-
/** One of the framework's own failures. */
|
|
7
|
-
export interface StandardFailure {
|
|
8
|
-
/** The stable code clients branch on, such as `RATE_LIMITED`. */
|
|
9
|
-
readonly code: string;
|
|
10
|
-
/** The HTTP status that answers it. */
|
|
11
|
-
readonly status: number;
|
|
12
|
-
/** A fixed message for people; it never carries request data. */
|
|
13
|
-
readonly message: string;
|
|
14
|
-
/** Whether the same request may succeed later; false when absent. */
|
|
15
|
-
readonly retryable?: boolean;
|
|
16
|
-
/** The seconds a client waits before retrying, sent as `Retry-After`. */
|
|
17
|
-
readonly retryAfter?: number;
|
|
18
|
-
}
|
|
19
|
-
/** The framework's own failures, by the name `standardErrors` gives each. */
|
|
20
|
-
export declare const STANDARD_FAILURES: {
|
|
21
|
-
readonly invalidInput: {
|
|
22
|
-
readonly code: 'INVALID_INPUT';
|
|
23
|
-
readonly status: 400;
|
|
24
|
-
readonly message: 'The request does not match the published schema.';
|
|
25
|
-
};
|
|
26
|
-
readonly unauthorized: {
|
|
27
|
-
readonly code: 'UNAUTHORIZED';
|
|
28
|
-
readonly status: 401;
|
|
29
|
-
readonly message: 'A valid access token is required.';
|
|
30
|
-
};
|
|
31
|
-
readonly forbidden: {
|
|
32
|
-
readonly code: 'FORBIDDEN';
|
|
33
|
-
readonly status: 403;
|
|
34
|
-
readonly message: 'The token does not authorize this operation.';
|
|
35
|
-
};
|
|
36
|
-
readonly notFound: {
|
|
37
|
-
readonly code: 'NOT_FOUND';
|
|
38
|
-
readonly status: 404;
|
|
39
|
-
readonly message: 'The requested operation does not exist.';
|
|
40
|
-
};
|
|
41
|
-
readonly methodNotAllowed: {
|
|
42
|
-
readonly code: 'HTTP_METHOD_NOT_ALLOWED';
|
|
43
|
-
readonly status: 405;
|
|
44
|
-
readonly message: 'The HTTP method is not supported for this resource.';
|
|
45
|
-
};
|
|
46
|
-
readonly tooLarge: {
|
|
47
|
-
readonly code: 'REQUEST_TOO_LARGE';
|
|
48
|
-
readonly status: 413;
|
|
49
|
-
readonly message: 'The request exceeds the allowed size.';
|
|
50
|
-
};
|
|
51
|
-
readonly unsupportedMedia: {
|
|
52
|
-
readonly code: 'UNSUPPORTED_MEDIA_TYPE';
|
|
53
|
-
readonly status: 415;
|
|
54
|
-
readonly message: 'The request content type is not supported.';
|
|
55
|
-
};
|
|
56
|
-
readonly rateLimited: {
|
|
57
|
-
readonly code: 'RATE_LIMITED';
|
|
58
|
-
readonly status: 429;
|
|
59
|
-
readonly message: 'The request rate limit was exceeded. Try again later.';
|
|
60
|
-
readonly retryable: true;
|
|
61
|
-
readonly retryAfter: 60;
|
|
62
|
-
};
|
|
63
|
-
readonly internal: {
|
|
64
|
-
readonly code: 'INTERNAL_ERROR';
|
|
65
|
-
readonly status: 500;
|
|
66
|
-
readonly message: 'The service could not complete the operation.';
|
|
67
|
-
};
|
|
68
|
-
readonly upstreamUnavailable: {
|
|
69
|
-
readonly code: 'UPSTREAM_UNAVAILABLE';
|
|
70
|
-
readonly status: 503;
|
|
71
|
-
readonly message: 'The upstream service could not complete the request.';
|
|
72
|
-
readonly retryable: true;
|
|
73
|
-
};
|
|
74
|
-
readonly upstreamTimeout: {
|
|
75
|
-
readonly code: 'UPSTREAM_TIMEOUT';
|
|
76
|
-
readonly status: 504;
|
|
77
|
-
readonly message: 'The upstream service did not respond before its deadline.';
|
|
78
|
-
readonly retryable: true;
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* A write may have been applied and its answer was lost. Never retried: the caller reconciles (reads
|
|
82
|
-
* the resource or polls the operation) before deciding to repeat anything.
|
|
83
|
-
*/
|
|
84
|
-
readonly outcomeUnknown: {
|
|
85
|
-
readonly code: 'OUTCOME_UNKNOWN';
|
|
86
|
-
readonly status: 502;
|
|
87
|
-
readonly message: 'The operation may have been applied; check its result before repeating it.';
|
|
88
|
-
};
|
|
89
|
-
};
|
|
1
|
+
import { $t as StandardFailure, Qt as STANDARD_FAILURES } from "./chunks/types-BQYB4Ads.js";
|
|
2
|
+
export { STANDARD_FAILURES, StandardFailure };
|
|
@@ -1,74 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
/** The framework's own failures, by the name `standardErrors` gives each. */
|
|
3
|
-
const STANDARD_FAILURES = {
|
|
4
|
-
invalidInput: {
|
|
5
|
-
code: "INVALID_INPUT",
|
|
6
|
-
status: 400,
|
|
7
|
-
message: "The request does not match the published schema."
|
|
8
|
-
},
|
|
9
|
-
unauthorized: {
|
|
10
|
-
code: "UNAUTHORIZED",
|
|
11
|
-
status: 401,
|
|
12
|
-
message: "A valid access token is required."
|
|
13
|
-
},
|
|
14
|
-
forbidden: {
|
|
15
|
-
code: "FORBIDDEN",
|
|
16
|
-
status: 403,
|
|
17
|
-
message: "The token does not authorize this operation."
|
|
18
|
-
},
|
|
19
|
-
notFound: {
|
|
20
|
-
code: "NOT_FOUND",
|
|
21
|
-
status: 404,
|
|
22
|
-
message: "The requested operation does not exist."
|
|
23
|
-
},
|
|
24
|
-
methodNotAllowed: {
|
|
25
|
-
code: "HTTP_METHOD_NOT_ALLOWED",
|
|
26
|
-
status: 405,
|
|
27
|
-
message: "The HTTP method is not supported for this resource."
|
|
28
|
-
},
|
|
29
|
-
tooLarge: {
|
|
30
|
-
code: "REQUEST_TOO_LARGE",
|
|
31
|
-
status: 413,
|
|
32
|
-
message: "The request exceeds the allowed size."
|
|
33
|
-
},
|
|
34
|
-
unsupportedMedia: {
|
|
35
|
-
code: "UNSUPPORTED_MEDIA_TYPE",
|
|
36
|
-
status: 415,
|
|
37
|
-
message: "The request content type is not supported."
|
|
38
|
-
},
|
|
39
|
-
rateLimited: {
|
|
40
|
-
code: "RATE_LIMITED",
|
|
41
|
-
status: 429,
|
|
42
|
-
message: "The request rate limit was exceeded. Try again later.",
|
|
43
|
-
retryable: true,
|
|
44
|
-
retryAfter: 60
|
|
45
|
-
},
|
|
46
|
-
internal: {
|
|
47
|
-
code: "INTERNAL_ERROR",
|
|
48
|
-
status: 500,
|
|
49
|
-
message: "The service could not complete the operation."
|
|
50
|
-
},
|
|
51
|
-
upstreamUnavailable: {
|
|
52
|
-
code: "UPSTREAM_UNAVAILABLE",
|
|
53
|
-
status: 503,
|
|
54
|
-
message: "The upstream service could not complete the request.",
|
|
55
|
-
retryable: true
|
|
56
|
-
},
|
|
57
|
-
upstreamTimeout: {
|
|
58
|
-
code: "UPSTREAM_TIMEOUT",
|
|
59
|
-
status: 504,
|
|
60
|
-
message: "The upstream service did not respond before its deadline.",
|
|
61
|
-
retryable: true
|
|
62
|
-
},
|
|
63
|
-
/**
|
|
64
|
-
* A write may have been applied and its answer was lost. Never retried: the caller reconciles (reads
|
|
65
|
-
* the resource or polls the operation) before deciding to repeat anything.
|
|
66
|
-
*/
|
|
67
|
-
outcomeUnknown: {
|
|
68
|
-
code: "OUTCOME_UNKNOWN",
|
|
69
|
-
status: 502,
|
|
70
|
-
message: "The operation may have been applied; check its result before repeating it."
|
|
71
|
-
}
|
|
72
|
-
};
|
|
1
|
+
import { t as STANDARD_FAILURES } from "./chunks/standard-failures-CLjxS2ea.js";
|
|
73
2
|
|
|
74
3
|
export { STANDARD_FAILURES };
|