@arbol-ai/maximus 7.4.0 → 8.0.1
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-x7uY70_1.js +341 -0
- package/dist/chunks/{errors-D7zG9kx9.js → errors-C5w9WY1l.js} +10 -5
- package/dist/chunks/{execution-kVUJPy1A.js → execution-rOiLo8VG.js} +28 -15
- package/dist/chunks/generate-C-9FKW0o.js +197 -0
- package/dist/chunks/handler-iebR-urt.js +141 -0
- package/dist/chunks/http-layout-DS8DnPyu.js +128 -0
- package/dist/chunks/{http-paths-yKD6TSNJ.js → http-paths-DMBxwpp6.js} +50 -31
- package/dist/chunks/{json-Bu4BLT25.js → json-B14evE6-.js} +21 -5
- package/dist/chunks/names-ncD7A3DV.js +280 -0
- package/dist/chunks/openapi-CeolxIqa.js +1588 -0
- package/dist/chunks/openapi-file-Bz9FRaE6.js +83 -0
- package/dist/chunks/pages-iZTvFs5a.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-DlqA7J38.js → runtime-D94vx21X.js} +50 -26
- 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-Bzf1Q1_4.js +410 -0
- package/dist/chunks/src-CPrJpbOM.js +573 -0
- package/dist/chunks/{standard-failures-CLjxS2ea.js → standard-failures-Lh4mSfwG.js} +1 -1
- package/dist/chunks/{telemetry-BTwB68m5.js → telemetry-C3LfZcOB.js} +32 -11
- package/dist/chunks/{types-DQdfRF3f.d.ts → types-DTIuIEJ-.d.ts} +1000 -342
- package/dist/chunks/{validation-r-sgmsqb.js → validation-fTohBT6R.js} +69 -28
- package/dist/chunks/workers-types-BRk_Xa_5.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 -2
- package/dist/http-paths.d.ts +1 -1
- package/dist/http-paths.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +12 -11
- package/dist/internals.d.ts +1 -1
- package/dist/internals.js +5 -4
- 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 +110 -72
- package/dist/project/config.js +161 -45
- 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 -1
- package/dist/tooling/cli.js +149 -105
- 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 +26 -22
- package/skills/maximus/SKILL.md +165 -68
- 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 -25
- package/templates/project/README.md.template +54 -48
- package/templates/project/middleware/10-response.ts.template +5 -2
- package/templates/project/package.json.template +13 -9
- 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 -6
- 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/builder-BiXv7d2v.js +0 -100
- package/dist/chunks/define-app-DvD_1jUE.js +0 -625
- package/dist/chunks/prepare-project-CMyGSEtI.js +0 -236
- package/dist/chunks/prepare-project-MtS0-W_n.js +0 -3
- package/dist/chunks/record-DY-lX9w1.js +0 -34
- package/dist/chunks/src-N3oyx5QF.js +0 -1091
- 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 -57
- 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 -42
- package/templates/project/cloudflare.config.ts.template +0 -24
- package/templates/project/maximus.config.ts.template +0 -20
- package/templates/project/routes/v1/greeting.ts.template +0 -38
- 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
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-DTIuIEJ-.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-DTIuIEJ-.js";
|
|
2
|
+
export { STANDARD_FAILURES, StandardFailure };
|
package/dist/tooling/cli.js
CHANGED
|
@@ -1,123 +1,167 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { dirname, join, relative, resolve } from "node:path";
|
|
2
|
+
import { basename, relative, resolve } from "node:path";
|
|
4
3
|
import { parseArgs } from "node:util";
|
|
5
|
-
import { randomBytes } from "node:crypto";
|
|
6
|
-
|
|
7
|
-
// src/tooling/internal/scaffold.ts
|
|
8
|
-
/**
|
|
9
|
-
* `maximus init`: a new service from the starter template.
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* The Maximus package's own directory: the nearest one above this module with a package.json. The
|
|
13
|
-
* build bundles this module into the CLI, so its depth below the package differs from the source's.
|
|
14
|
-
*/
|
|
15
|
-
function packageDirectory() {
|
|
16
|
-
let directory = import.meta.dirname;
|
|
17
|
-
while (!existsSync(join(directory, "package.json"))) {
|
|
18
|
-
const parent = dirname(directory);
|
|
19
|
-
if (parent === directory) throw new Error("Found no package.json above the Maximus CLI.");
|
|
20
|
-
directory = parent;
|
|
21
|
-
}
|
|
22
|
-
return directory;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* `maximus init`: writes a new service from the starter template into a directory that does not exist yet.
|
|
26
|
-
*/
|
|
27
|
-
function scaffold(directory, name, layout = "service") {
|
|
28
|
-
if (!/^(?=.{2,41}$)[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(name)) throw new TypeError("Use a lowercase kebab-case project name of 2 to 41 characters.");
|
|
29
|
-
const root = resolve(directory);
|
|
30
|
-
if (existsSync(root)) throw new Error("Choose a new directory; existing projects are never overwritten.");
|
|
31
|
-
const own = packageDirectory();
|
|
32
|
-
const { version } = JSON.parse(readFileSync(join(own, "package.json"), "utf-8"));
|
|
33
|
-
const values = {
|
|
34
|
-
__PROJECT_NAME__: name,
|
|
35
|
-
__ENTRYPOINT__: `${name.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("")}Service`,
|
|
36
|
-
__MAXIMUS_VERSION__: version,
|
|
37
|
-
__COMPATIBILITY_DATE__: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)
|
|
38
|
-
};
|
|
39
|
-
for (const templateName of layout === "project" ? ["service", "project"] : ["service"]) {
|
|
40
|
-
const template = join(own, "templates", templateName);
|
|
41
|
-
for (const file of readdirSync(template, {
|
|
42
|
-
recursive: true,
|
|
43
|
-
withFileTypes: true
|
|
44
|
-
})) {
|
|
45
|
-
if (!file.isFile() || !file.name.endsWith(".template")) continue;
|
|
46
|
-
const source = resolve(file.parentPath, file.name);
|
|
47
|
-
if (layout === "project" && templateName === "service" && (relative(template, source).startsWith("tests/") || relative(template, source).startsWith("src/") || file.name === "vitest.config.ts.template")) continue;
|
|
48
|
-
const target = resolve(root, relative(template, source).replace(/\.template$/, ""));
|
|
49
|
-
mkdirSync(dirname(target), { recursive: true });
|
|
50
|
-
let text = readFileSync(source, "utf-8");
|
|
51
|
-
for (const [placeholder, value] of Object.entries(values)) text = text.replaceAll(placeholder, value);
|
|
52
|
-
writeFileSync(target, text, { flag: templateName === "project" ? "w" : "wx" });
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
writeFileSync(resolve(root, ".dev.vars"), `DEVELOPMENT_TOKEN=${randomBytes(32).toString("hex")}\n`, {
|
|
56
|
-
flag: "wx",
|
|
57
|
-
mode: 384
|
|
58
|
-
});
|
|
59
|
-
symlinkSync("CLAUDE.md", resolve(root, "AGENTS.md"));
|
|
60
|
-
for (const harness of [".claude", ".codex"]) {
|
|
61
|
-
mkdirSync(resolve(root, harness, "skills"), { recursive: true });
|
|
62
|
-
symlinkSync("../../.agents/skills/project", resolve(root, harness, "skills/project"));
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
directory: root,
|
|
66
|
-
layout,
|
|
67
|
-
next: layout === "project" ? "Run bun install and bun run dev. The public home page says Hello World. Configure the origin and token policy in maximus.config.ts before adding production callers. Use bun run verify for types, lint and build, then bun run deploy." : "Run bun install and bun run dev, and call it with the DEVELOPMENT_TOKEN in .dev.vars. Before the first deployment, set origin, audience and issuer in src/app.ts, run bun run verify, sign in with cf auth login and run bun run deploy."
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
4
|
|
|
71
5
|
// src/tooling/cli.ts
|
|
72
6
|
/**
|
|
73
|
-
* The `maximus` command
|
|
74
|
-
*
|
|
7
|
+
* The `maximus` command: creates projects, generates their routes and tools, links the Maximus skill for
|
|
8
|
+
* coding agents and writes `.maximus/`. Vite+ owns development and builds; Cloudflare's `cf` deploys.
|
|
75
9
|
*/
|
|
76
|
-
const { values, positionals } = parseArgs({
|
|
77
|
-
allowPositionals: true,
|
|
78
|
-
options: {
|
|
79
|
-
name: { type: "string" },
|
|
80
|
-
layout: {
|
|
81
|
-
type: "string",
|
|
82
|
-
default: "service"
|
|
83
|
-
},
|
|
84
|
-
mode: {
|
|
85
|
-
type: "string",
|
|
86
|
-
default: "production"
|
|
87
|
-
},
|
|
88
|
-
help: {
|
|
89
|
-
type: "boolean",
|
|
90
|
-
default: false
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
const [command, target] = positionals;
|
|
95
10
|
/** The help the command prints for `--help` or a usage mistake. */
|
|
96
11
|
const USAGE = [
|
|
97
|
-
"Usage: maximus init <new-directory> --name <name> [--
|
|
12
|
+
"Usage: maximus init <new-directory> [--name <name>] [--web] [--no-mcp]",
|
|
13
|
+
" maximus gen route <method> <path> [--tool <mcp_tool_name>] [--root <directory>]",
|
|
14
|
+
" maximus gen tool <name> [--root <directory>]",
|
|
15
|
+
" maximus skills [directory]",
|
|
98
16
|
" maximus prepare [directory] [--mode production|development]",
|
|
99
|
-
"
|
|
100
|
-
"
|
|
17
|
+
" maximus openapi [directory] [--out <file>] [--check]",
|
|
18
|
+
"",
|
|
19
|
+
"init creates a project: an API whose greeting route is also an MCP tool, and with --web a React app.",
|
|
20
|
+
"gen writes a route file (routes/v1/tasks/[taskId].get.ts) or an MCP tool file (mcp/tools/<name>.ts).",
|
|
21
|
+
"skills links the installed Maximus skill into the project's .agents, .claude and .codex skill folders.",
|
|
22
|
+
"prepare writes .maximus/ from vite.config.ts and the project files, as vp dev and vp build do.",
|
|
23
|
+
"openapi writes the Worker's OpenAPI documents, openapi.json and openapi.rpc.json; --check fails if they changed.",
|
|
24
|
+
"",
|
|
25
|
+
"Each command says what it did; with --json it prints that as JSON instead, for scripts."
|
|
101
26
|
].join("\n");
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
27
|
+
/** How `prepare` names the modules of each convention it counts, one and many. */
|
|
28
|
+
const MODULES = {
|
|
29
|
+
routes: ["route", "routes"],
|
|
30
|
+
mcp: ["MCP tool", "MCP tools"],
|
|
31
|
+
pages: ["page", "pages"],
|
|
32
|
+
middleware: ["middleware module", "middleware modules"],
|
|
33
|
+
crons: ["cron", "crons"],
|
|
34
|
+
queues: ["queue", "queues"],
|
|
35
|
+
email: ["email handler", "email handlers"],
|
|
36
|
+
"durable-objects": ["Durable Object", "Durable Objects"],
|
|
37
|
+
app: ["app page", "app pages"]
|
|
38
|
+
};
|
|
39
|
+
/** The modules `prepare` found, as a person reads them: `5 routes, 1 MCP tool`, or `no modules`. */
|
|
40
|
+
function modules(counts) {
|
|
41
|
+
const found = Object.entries(counts).flatMap(([kind, count]) => {
|
|
42
|
+
const [one, many] = MODULES[kind] ?? [kind, kind];
|
|
43
|
+
return count > 0 ? [`${count} ${count === 1 ? one : many}`] : [];
|
|
44
|
+
});
|
|
45
|
+
return found.length ? found.join(", ") : "no modules";
|
|
105
46
|
}
|
|
106
|
-
/**
|
|
47
|
+
/** A path as the person running the command reads it: relative to where they are. */
|
|
48
|
+
function shown(path) {
|
|
49
|
+
return relative(process.cwd(), path) || ".";
|
|
50
|
+
}
|
|
51
|
+
/** Runs the command the arguments name; an unknown or incomplete option is a refusal like any other. */
|
|
107
52
|
async function run() {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
53
|
+
const { values, positionals } = parseArgs({
|
|
54
|
+
allowPositionals: true,
|
|
55
|
+
allowNegative: true,
|
|
56
|
+
options: {
|
|
57
|
+
name: { type: "string" },
|
|
58
|
+
web: {
|
|
59
|
+
type: "boolean",
|
|
60
|
+
default: false
|
|
61
|
+
},
|
|
62
|
+
mcp: {
|
|
63
|
+
type: "boolean",
|
|
64
|
+
default: true
|
|
65
|
+
},
|
|
66
|
+
tool: { type: "string" },
|
|
67
|
+
root: {
|
|
68
|
+
type: "string",
|
|
69
|
+
default: "."
|
|
70
|
+
},
|
|
71
|
+
mode: {
|
|
72
|
+
type: "string",
|
|
73
|
+
default: "production"
|
|
74
|
+
},
|
|
75
|
+
out: { type: "string" },
|
|
76
|
+
check: {
|
|
77
|
+
type: "boolean",
|
|
78
|
+
default: false
|
|
79
|
+
},
|
|
80
|
+
json: {
|
|
81
|
+
type: "boolean",
|
|
82
|
+
default: false
|
|
83
|
+
},
|
|
84
|
+
help: {
|
|
85
|
+
type: "boolean",
|
|
86
|
+
default: false
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
const [command, ...rest] = positionals;
|
|
91
|
+
if (values.help) {
|
|
92
|
+
console.info(USAGE);
|
|
111
93
|
return;
|
|
112
94
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
95
|
+
/** Says what the command did: a sentence for a person, or its data as JSON with --json. */
|
|
96
|
+
const report = (data, sentence) => console.info(values.json ? JSON.stringify(data) : sentence);
|
|
97
|
+
switch (command) {
|
|
98
|
+
case "init": {
|
|
99
|
+
const [target] = rest;
|
|
100
|
+
if (!target) throw new TypeError("Use maximus init <new-directory> [--name <name>].");
|
|
101
|
+
const { scaffold } = await import("../chunks/scaffold-DGrcjR3h.js");
|
|
102
|
+
const name = values.name ?? basename(resolve(target));
|
|
103
|
+
const created = scaffold(target, name, {
|
|
104
|
+
mcp: values.mcp,
|
|
105
|
+
web: values.web
|
|
106
|
+
});
|
|
107
|
+
const serves = created.mcp ? "an API and its MCP server" : "an API";
|
|
108
|
+
report(created, `Created ${name} in ${shown(created.directory)}/: ${serves}${created.web ? " with a web app" : ""}.\n${created.next}`);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
case "gen": {
|
|
112
|
+
const { generateRoute, generateTool } = await import("../chunks/generate-C-9FKW0o.js");
|
|
113
|
+
const [kind, ...args] = rest;
|
|
114
|
+
if (kind === "route" && args.length === 2) {
|
|
115
|
+
const [method = "", path = ""] = args;
|
|
116
|
+
const route = generateRoute(values.root, method, path, values.tool);
|
|
117
|
+
const tool = values.tool ? `, also the MCP tool ${values.tool}` : "";
|
|
118
|
+
report(route, `Wrote ${shown(route.file)}: ${route.method} ${route.path}${tool}.`);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (kind === "tool" && args.length === 1) {
|
|
122
|
+
const tool = generateTool(values.root, args[0] ?? "");
|
|
123
|
+
report(tool, `Wrote ${shown(tool.file)}: the MCP tool ${tool.tool}.`);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
throw new TypeError("Use maximus gen route <method> <path>, or maximus gen tool <name>.");
|
|
127
|
+
}
|
|
128
|
+
case "skills": {
|
|
129
|
+
const { linkAgentSkills } = await import("../chunks/agent-skills-m7y1EUch.js");
|
|
130
|
+
const linked = linkAgentSkills(rest[0] ?? ".");
|
|
131
|
+
report({ linked }, linked.length ? `Linked the Maximus skill for coding agents: ${linked.join(", ")}.` : "The Maximus skill was already linked for coding agents.");
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
case "prepare": {
|
|
135
|
+
if (values.mode !== "production" && values.mode !== "development") throw new TypeError("Prepare with --mode production, as a build does, or development, as vp dev does.");
|
|
136
|
+
const { prepareConfiguredProject } = await import("../chunks/prepare-configured-BmRJLg6J.js");
|
|
137
|
+
const prepared = await prepareConfiguredProject(rest[0] ?? ".", values.mode);
|
|
138
|
+
report(prepared, `${prepared.changed ? "Prepared" : "Kept"} .maximus/ for ${prepared.mode}: ${modules(prepared.modules)}.`);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
case "openapi": {
|
|
142
|
+
const { writeOpenApi } = await import("../chunks/openapi-file-Bz9FRaE6.js");
|
|
143
|
+
const written = await writeOpenApi(rest[0] ?? ".", {
|
|
144
|
+
...values.out === void 0 ? {} : { out: values.out },
|
|
145
|
+
check: values.check
|
|
146
|
+
});
|
|
147
|
+
const files = [written, ...written.rpc ? [written.rpc] : []];
|
|
148
|
+
const stale = files.filter(({ changed }) => changed);
|
|
149
|
+
if (values.check && stale.length) {
|
|
150
|
+
report(written, `${stale.map(({ file }) => shown(file)).join(" and ")} ${stale.length === 1 ? "differs" : "differ"} from what the routes declare; run maximus openapi.`);
|
|
151
|
+
process.exitCode = 1;
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
report(written, files.map(({ file, operations, changed }) => {
|
|
155
|
+
let state = changed ? "was written" : "was current";
|
|
156
|
+
if (values.check) state = "matches the routes";
|
|
157
|
+
return `${shown(file)} ${state}: ${operations} operation${operations === 1 ? "" : "s"}.`;
|
|
158
|
+
}).join(" "));
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
default:
|
|
162
|
+
console.error(USAGE);
|
|
163
|
+
process.exitCode = 1;
|
|
117
164
|
}
|
|
118
|
-
if (!target || !values.name) throw new TypeError("Use maximus init <new-directory> --name <name>.");
|
|
119
|
-
if (values.layout !== "service" && values.layout !== "project") throw new TypeError("Choose --layout service or --layout project.");
|
|
120
|
-
console.info(JSON.stringify(scaffold(target, values.name, values.layout)));
|
|
121
165
|
}
|
|
122
166
|
try {
|
|
123
167
|
await run();
|
package/dist/tooling/testing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as toYaml } from "../chunks/yaml-Dk2L24yQ.js";
|
|
2
2
|
|
|
3
3
|
// src/tooling/testing.ts
|
|
4
4
|
/**
|
|
@@ -10,7 +10,7 @@ async function verifyContract(fetch, origin) {
|
|
|
10
10
|
const yaml = await fetch(new Request(`${origin}/openapi.yaml`));
|
|
11
11
|
if (!json.ok || !yaml.ok) throw new Error("OpenAPI is unavailable.");
|
|
12
12
|
const schema = await json.json();
|
|
13
|
-
if (
|
|
13
|
+
if (toYaml(schema) !== await yaml.text()) throw new Error("OpenAPI JSON/YAML differ.");
|
|
14
14
|
return {
|
|
15
15
|
paths: Object.keys(schema.paths),
|
|
16
16
|
operations: Object.values(schema.paths).flatMap((path) => Object.values(path).map((op) => op.operationId))
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/vite/cloudflare-workers.ts
|
|
2
|
+
/** The base of a Worker's named entrypoints. */
|
|
3
|
+
var WorkerEntrypoint = class {
|
|
4
|
+
ctx;
|
|
5
|
+
env;
|
|
6
|
+
constructor(ctx, env) {
|
|
7
|
+
this.ctx = ctx;
|
|
8
|
+
this.env = env;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
/** The base of a Worker's Durable Object classes. */
|
|
12
|
+
var DurableObject = class {
|
|
13
|
+
ctx;
|
|
14
|
+
env;
|
|
15
|
+
constructor(ctx, env) {
|
|
16
|
+
this.ctx = ctx;
|
|
17
|
+
this.env = env;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
/** The base of objects passed by reference over RPC: a marker, with no members of its own to stand in for. */
|
|
21
|
+
var RpcTarget = class {};
|
|
22
|
+
/** Native tracing: no active span until a test installs `getActiveSpan`. */
|
|
23
|
+
const tracing = {};
|
|
24
|
+
|
|
25
|
+
export { DurableObject, RpcTarget, WorkerEntrypoint, tracing };
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { An as TokenAlgorithm, Mn as TokenDevelopment, Nn as TokenPolicy } from "../chunks/types-DTIuIEJ-.js";
|
|
2
|
+
import { WorkerConfig } from "cf/config";
|
|
3
|
+
import { Plugin } from "vite";
|
|
4
|
+
/** Where the Worker runs: `development` under `vp dev`, `production` in every build. */
|
|
5
|
+
type Phase = 'development' | 'production';
|
|
6
|
+
/** How tokens are verified, as configuration states it; the code that verifies them itself is `auth.ts`. */
|
|
7
|
+
type TokenOptions = Omit<TokenPolicy, 'resolve' | 'challenge' | 'resources' | 'resourceMetadataUrl' | 'audience' | 'development'> & {
|
|
8
|
+
/** The audience tokens must carry, or several any one of which they may carry; by default, the origin. */
|
|
9
|
+
audience?: TokenPolicy['audience'];
|
|
10
|
+
/**
|
|
11
|
+
* The token `vp dev` accepts from localhost: its binding, `DEVELOPMENT_TOKEN` by default, which only
|
|
12
|
+
* `vp dev` declares. `false` accepts none.
|
|
13
|
+
*/
|
|
14
|
+
development?: TokenDevelopment | false;
|
|
15
|
+
};
|
|
16
|
+
/** Another Maximus service this one calls over native RPC: its Worker, and the OpenAPI document that types it. */
|
|
17
|
+
interface ServiceOptions {
|
|
18
|
+
/** The service's Worker name, as its own configuration names it. */
|
|
19
|
+
worker: string;
|
|
20
|
+
/** The OpenAPI document the service publishes with `maximus openapi`, a path from this project's root. */
|
|
21
|
+
openapi: string;
|
|
22
|
+
}
|
|
23
|
+
/** What a web app (`index.html` at the project's root) answers with, besides its build. */
|
|
24
|
+
interface WebAppOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Response headers for the app's pages and files, merged over Maximus's defaults: a Content Security Policy
|
|
27
|
+
* that admits the app's own origin and its token issuers (none behind Cloudflare Access),
|
|
28
|
+
* `frame-ancestors 'none'`, `no-referrer`, same-origin opener and resource policies, and HSTS. A header set
|
|
29
|
+
* to `false` is left out. Under `vp dev` the policy and HSTS are left out, since Vite's development client
|
|
30
|
+
* runs inline scripts over plain HTTP.
|
|
31
|
+
*/
|
|
32
|
+
headers?: Readonly<Record<string, string | false>>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* What `vite.config.ts` states: the application's configuration, and the Worker's settings as Cloudflare
|
|
36
|
+
* names them. Maximus owns the Worker's entry and, for a web app, its assets; it adds `nodejs_compat` and,
|
|
37
|
+
* under `vp dev`, the development token. The code that completes the application is `errors.ts`, `auth.ts`,
|
|
38
|
+
* `context.ts` and `telemetry.ts`.
|
|
39
|
+
*/
|
|
40
|
+
interface MaximusOptions extends Omit<WorkerConfig, 'name' | 'entrypoint' | 'env' | 'assets'> {
|
|
41
|
+
/**
|
|
42
|
+
* The service's name: the Worker's, the MCP server's and the scopes' prefix. By default, the package's name
|
|
43
|
+
* without its scope.
|
|
44
|
+
*/
|
|
45
|
+
name?: string;
|
|
46
|
+
/** The prefix of every scope, `<namespace>:<resource>:<action>`; by default, the name. */
|
|
47
|
+
namespace?: string;
|
|
48
|
+
/** The human name OpenAPI, the MCP server and OAuth discovery show; by default, the name. */
|
|
49
|
+
title?: string;
|
|
50
|
+
/** What the service is for, in a sentence or two, which OpenAPI publishes as `info.description`. */
|
|
51
|
+
description?: string;
|
|
52
|
+
/**
|
|
53
|
+
* What each group of routes holds, by the group's name, which OpenAPI publishes as its tag's description:
|
|
54
|
+
* `{ Notes: "The notes of the caller's organization." }`. A route's group is the first segment of its path
|
|
55
|
+
* after the version, in words, unless its contract declares one.
|
|
56
|
+
*/
|
|
57
|
+
groups?: Readonly<Record<string, string>>;
|
|
58
|
+
/** The version OpenAPI, the MCP server and `/health` report; by default, the package's version. */
|
|
59
|
+
version?: string;
|
|
60
|
+
/**
|
|
61
|
+
* The public HTTPS origin OpenAPI, MCP resources and OAuth discovery advertise. A `workers.dev` origin is
|
|
62
|
+
* served there; any other is the Worker's custom domain, unless `domains` or a fetch trigger route it.
|
|
63
|
+
*/
|
|
64
|
+
origin: string;
|
|
65
|
+
/**
|
|
66
|
+
* How tokens are verified: the OAuth issuer, the audience and the development token, or Cloudflare Access.
|
|
67
|
+
* `auth0()` and `cloudflareAccess()` state them for those providers.
|
|
68
|
+
*/
|
|
69
|
+
tokens?: TokenOptions;
|
|
70
|
+
/** The Workers allowed to call native RPC methods, by the `caller` their Service Binding names; none by default. */
|
|
71
|
+
rpc?: {
|
|
72
|
+
callers: readonly string[];
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Other Maximus services this one calls over native RPC, by the binding `env` gives each, such as
|
|
76
|
+
* `{ PRICING: { worker: 'pricing', openapi: '../pricing/openapi.json' } }`: the Worker, and the OpenAPI
|
|
77
|
+
* document it publishes with `maximus openapi`, from this project's root, which types the binding's methods
|
|
78
|
+
* in `.maximus/services/`. Each binding's props name this service, by its `name`, as the caller the other
|
|
79
|
+
* admits in its `rpc.callers`.
|
|
80
|
+
*/
|
|
81
|
+
services?: Readonly<Record<string, ServiceOptions>>;
|
|
82
|
+
/** Where the API and the health check answer: `/api` and `/health` by default. */
|
|
83
|
+
http?: {
|
|
84
|
+
basePath?: string;
|
|
85
|
+
healthPath?: string;
|
|
86
|
+
};
|
|
87
|
+
/** The request body limit of every operation that sets none, in bytes: 32 KiB by default. */
|
|
88
|
+
maxBodyBytes?: number;
|
|
89
|
+
/** The output limit of every operation that sets none, in bytes: 256 KiB by default. */
|
|
90
|
+
maxOutputBytes?: number;
|
|
91
|
+
/** A rate limiting binding every HTTP and MCP call passes, per organization and actor. */
|
|
92
|
+
rateLimit?: {
|
|
93
|
+
binding: string;
|
|
94
|
+
retryAfter?: number;
|
|
95
|
+
};
|
|
96
|
+
/** The Worker's bindings, from `cf/config`'s `bindings`; the generated `Env` is inferred from them. */
|
|
97
|
+
env?: WorkerConfig['env'];
|
|
98
|
+
/** What a web app answers with besides its build: its response headers. */
|
|
99
|
+
webApp?: WebAppOptions;
|
|
100
|
+
}
|
|
101
|
+
/** The algorithms Auth0 signs an API's access tokens with that a JWKS publishes the keys of. */
|
|
102
|
+
type Auth0Algorithm = Extract<TokenAlgorithm, 'RS256' | 'RS512' | 'PS256'>;
|
|
103
|
+
/** What `auth0()` takes: the tenant's domain, the API's audience and its signing algorithms. */
|
|
104
|
+
interface Auth0Options {
|
|
105
|
+
/**
|
|
106
|
+
* The tenant's domain, such as `acme.us.auth0.com`, or its custom domain: a host name without a scheme,
|
|
107
|
+
* port or path. For a tenant whose tokens may name either, list both, the canonical one first.
|
|
108
|
+
*/
|
|
109
|
+
domain: string | readonly [string, ...string[]];
|
|
110
|
+
/** The API's identifier, which its access tokens carry as their audience, or several. */
|
|
111
|
+
audience: string | readonly string[];
|
|
112
|
+
/** The algorithms the API signs its access tokens with, as its settings name them; `['RS256']` by default. */
|
|
113
|
+
algorithms?: readonly Auth0Algorithm[];
|
|
114
|
+
}
|
|
115
|
+
/** What `cloudflareAccess()` takes: the team, the Access application and what its callers hold. */
|
|
116
|
+
interface CloudflareAccessOptions {
|
|
117
|
+
/** The Zero Trust team name: `acme` for `acme.cloudflareaccess.com`. */
|
|
118
|
+
team: string;
|
|
119
|
+
/** The Access application's Application Audience (AUD) tag, from its overview in the dashboard. */
|
|
120
|
+
aud: string;
|
|
121
|
+
/**
|
|
122
|
+
* The organization every caller acts in. Leave it out to read each caller's from a claim, named as
|
|
123
|
+
* `claims.organization` beside the preset, such as `custom.org_id` for a custom OIDC claim.
|
|
124
|
+
*/
|
|
125
|
+
organizationId?: string;
|
|
126
|
+
/** The scopes callers hold: every person Access lets through, and each service token by its client id. */
|
|
127
|
+
scopes: {
|
|
128
|
+
/** The scopes every person Access lets through holds. */
|
|
129
|
+
people: readonly string[];
|
|
130
|
+
/** The scopes of each service token, by its client id (`<id>.access`); one not listed holds none. */
|
|
131
|
+
services?: Readonly<Record<string, readonly string[]>>;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The token options of an API whose access tokens Auth0 issues: its issuer, `https://<domain>/` with the
|
|
136
|
+
* trailing slash of Auth0's `iss`, its audience and its algorithms. The JWKS, the endpoints and the claims
|
|
137
|
+
* keep their defaults, which are Auth0's. Throws a TypeError for a domain that is not a lowercase host name,
|
|
138
|
+
* such as one with a scheme or a path, and for an algorithm other than RS256, RS512 and PS256: HS256 tokens
|
|
139
|
+
* are signed with a secret, which no JWKS publishes.
|
|
140
|
+
*/
|
|
141
|
+
export declare function auth0({ domain, audience, algorithms }: Auth0Options): TokenOptions;
|
|
142
|
+
/**
|
|
143
|
+
* The token options of an application behind Cloudflare Access: the application token Access sets in
|
|
144
|
+
* `Cf-Access-Jwt-Assertion`, read from there alone and verified against the team's keys (RS256, issued by
|
|
145
|
+
* `https://<team>.cloudflareaccess.com`) for the application's AUD tag, and the scopes `scopes` grants. A
|
|
146
|
+
* production build pins the Worker to its origin, so no request reaches it around Access. Throws a TypeError
|
|
147
|
+
* for a team that is not a team name, such as the team's domain, and an AUD tag that is not 64 lowercase
|
|
148
|
+
* hexadecimal characters.
|
|
149
|
+
*/
|
|
150
|
+
export declare function cloudflareAccess({ team, aud, organizationId, scopes }: CloudflareAccessOptions): TokenOptions;
|
|
151
|
+
/**
|
|
152
|
+
* Maximus in Vite+: prepares the project from its files before every build and source change, brings the
|
|
153
|
+
* Maximus lint and format presets, and builds, runs and deploys the Worker these options describe through
|
|
154
|
+
* Cloudflare's Vite plugin.
|
|
155
|
+
*/
|
|
156
|
+
export declare function maximus(options: MaximusOptions): Plugin[];
|
|
157
|
+
export type { Auth0Algorithm, Auth0Options, CloudflareAccessOptions, MaximusOptions, Phase, ServiceOptions, TokenOptions, WebAppOptions };
|