@arbol-ai/maximus 8.1.0 → 8.4.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/dist/analytics/analytics.d.ts +16 -16
- package/dist/analytics/analytics.js +3 -3
- package/dist/body.d.ts +2 -2
- package/dist/body.js +2 -2
- package/dist/capture/index.d.ts +1 -1
- package/dist/capture/index.js +3 -4
- package/dist/chunks/{define-app-BxGZdNmS.js → define-app-CQpWqqqE.js} +33 -14
- package/dist/chunks/{json-B14evE6-.js → destination-DIkn8W6K.js} +65 -1
- package/dist/chunks/{digest-C7UGt760.js → digest-C51F1bhA.js} +1 -2
- package/dist/chunks/{errors-CWgE9uvM.js → errors-BoutSmiy.js} +2 -3
- package/dist/chunks/{execution-BTiAWA4n.js → execution-Bpq6s4nA.js} +9 -8
- package/dist/chunks/{generate-C-9FKW0o.js → generate-Dg88LzLU.js} +1 -1
- package/dist/chunks/{handler-iebR-urt.js → handler-DSpyrWc-.js} +6 -2
- package/dist/chunks/{http-layout-BvlbD__1.js → http-layout-BcYH4I2w.js} +1 -1
- package/dist/chunks/{http-paths-DMBxwpp6.js → http-paths-D043DkJv.js} +50 -81
- package/dist/chunks/http-routes-B6tCsnxB.js +29 -0
- package/dist/chunks/{openapi-BF3eCpux.js → openapi-D2rds7vy.js} +27 -116
- package/dist/chunks/{openapi-file-RcXoq0AF.js → openapi-file-BK8zET5U.js} +24 -6
- package/dist/chunks/{pages-BCksUeRf.js → pages-B7ysoFAM.js} +1 -1
- package/dist/chunks/result-CF4OzG9O.js +29 -0
- package/dist/chunks/{runtime-D5eR9-Es.js → runtime-CGtS2rOb.js} +132 -7
- package/dist/chunks/schemas-_UJcx_uY.js +813 -0
- package/dist/chunks/{server-B9C8KPwa.js → server-CVhTLNj2.js} +37 -101
- package/dist/chunks/{src-C-4z443M.js → src-D67OfW9B.js} +40 -19
- package/dist/chunks/tasks-C873C3le.js +100 -0
- package/dist/chunks/tasks-DYdY-dBI.js +267 -0
- package/dist/chunks/{types-Dqo3oGig.d.ts → types-BfGa2aJT.d.ts} +346 -138
- package/dist/chunks/validation-CpzAxj2_.js +201 -0
- package/dist/chunks/{workers-types-BgjyDtGd.d.ts → workers-types-Cxf-5cH7.d.ts} +6 -1
- package/dist/diagnostics.d.ts +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +1 -1
- 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 +11 -10
- package/dist/internals.d.ts +1 -1
- package/dist/internals.js +4 -4
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/tasks.d.ts +33 -0
- package/dist/mcp/tasks.js +3 -0
- package/dist/project/config.d.ts +2 -2
- package/dist/project/config.js +3 -2
- package/dist/project/index.d.ts +2 -2
- package/dist/project/index.js +3 -3
- package/dist/schemas.d.ts +2 -2
- package/dist/schemas.js +3 -3
- package/dist/standard-failures.d.ts +1 -1
- package/dist/tooling/cli.js +2 -2
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +6 -5
- package/dist/webhooks.d.ts +13 -2
- package/dist/webhooks.js +38 -1
- package/dist/workers/runtime.d.ts +1 -1
- package/dist/workers/runtime.js +1 -1
- package/package.json +11 -3
- package/skills/maximus/SKILL.md +7 -4
- package/skills/maximus/references/routes-and-tools.md +9 -1
- package/dist/chunks/result-CKgZHrnj.js +0 -56
- package/dist/chunks/schemas-BOFxZP1c.js +0 -227
- package/dist/chunks/validation-DMu0rkMQ.js +0 -670
package/dist/workers/runtime.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arbol-ai/maximus",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.0",
|
|
4
4
|
"description": "Maximus: define a service once and serve it over HTTP, MCP and Worker RPC on Cloudflare Workers, configured in vite.config.ts, with its OpenAPI and CLI.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -91,6 +91,10 @@
|
|
|
91
91
|
"types": "./dist/mcp/index.d.ts",
|
|
92
92
|
"import": "./dist/mcp/index.js"
|
|
93
93
|
},
|
|
94
|
+
"./mcp/tasks": {
|
|
95
|
+
"types": "./dist/mcp/tasks.d.ts",
|
|
96
|
+
"import": "./dist/mcp/tasks.js"
|
|
97
|
+
},
|
|
94
98
|
"./analytics": {
|
|
95
99
|
"types": "./dist/analytics/analytics.d.ts",
|
|
96
100
|
"import": "./dist/analytics/analytics.js"
|
|
@@ -134,12 +138,16 @@
|
|
|
134
138
|
},
|
|
135
139
|
"dependencies": {
|
|
136
140
|
"@modelcontextprotocol/server": "2.4.0",
|
|
137
|
-
"@
|
|
141
|
+
"@scalar/openapi-parser": "0.29.20",
|
|
138
142
|
"ajv-formats": "3.0.1",
|
|
139
|
-
"jose": "6.2.13"
|
|
143
|
+
"jose": "6.2.13",
|
|
144
|
+
"rou3": "1.0.0",
|
|
145
|
+
"standardwebhooks": "1.1.1",
|
|
146
|
+
"typebox": "1.4.5"
|
|
140
147
|
},
|
|
141
148
|
"devDependencies": {
|
|
142
149
|
"@cloudflare/vite-plugin": "2.0.0-beta.v.5",
|
|
150
|
+
"@modelcontextprotocol/ext-tasks": "0.2.3",
|
|
143
151
|
"@types/pg": "8.23.1",
|
|
144
152
|
"ajv": "8.20.0",
|
|
145
153
|
"cf": "1.0.0-beta.23",
|
package/skills/maximus/SKILL.md
CHANGED
|
@@ -66,7 +66,7 @@ each one.
|
|
|
66
66
|
| `bunx maximus gen route get /v1/notes/{noteId} --tool get_note` | Writes `routes/v1/notes/[noteId].get.ts`, which is also the MCP tool `get_note`. |
|
|
67
67
|
| `bunx maximus gen tool summarize-notes` | Writes `mcp/tools/summarize-notes.ts`, the tool `summarize_notes`. |
|
|
68
68
|
| `bunx maximus prepare` | Writes `.maximus/` for production, or with `--mode development` as `vp dev` does. `vp dev`, `vp build` and `vp test` prepare by themselves. |
|
|
69
|
-
| `bunx maximus openapi` | Writes `openapi.json`, and `openapi.rpc.json` when a route declares `rpc`; `--check` fails
|
|
69
|
+
| `bunx maximus openapi` | Writes `openapi.json`, and `openapi.rpc.json` when a route declares `rpc`; `--check` fails on a stale or invalid file. |
|
|
70
70
|
| `bun run test` | `vp test run`: the tests, in Node. |
|
|
71
71
|
| `bun run typecheck` | `maximus prepare`, then `tsc`, which also checks type tests. |
|
|
72
72
|
| `bun run check`, `bun run fix` | Lint and format; with fixes. |
|
|
@@ -98,7 +98,8 @@ Every `maximus` command says what it did in a sentence; `--json` prints it as JS
|
|
|
98
98
|
| Data in Postgres | `withTenantTransaction` from `@arbol-ai/maximus/postgres`. |
|
|
99
99
|
| A record of every call, for audit or a lake | `capture.ts` with `defineCapture` from `@arbol-ai/maximus/capture`; mark credential fields `secret: true`. See [Capture](https://github.com/getarbol/maximus/blob/main/docs/guides/capture.md). |
|
|
100
100
|
| Guidance agents read over MCP | `mcp/instructions.md`, `mcp/guides/<name>.md`, `mcp/skills/<name>.md`: static text for every caller, never tenant data. |
|
|
101
|
-
| A
|
|
101
|
+
| A service on 8.2 or earlier | [Upgrading to 8.3](https://github.com/getarbol/maximus/blob/main/docs/upgrading-to-8.3.md): TypeBox 1.x. |
|
|
102
|
+
| A 7.x service | [Upgrading to 8.0](https://github.com/getarbol/maximus/blob/main/docs/upgrading-to-8.md), then to 8.3. |
|
|
102
103
|
|
|
103
104
|
## Rules that are never broken
|
|
104
105
|
|
|
@@ -106,7 +107,8 @@ Every `maximus` command says what it did in a sentence; `--json` prints it as JS
|
|
|
106
107
|
`principal.organizationId`. Never take an organization from input, a header or a path.
|
|
107
108
|
- **Schemas are strict.** Inputs and outputs are strict objects or unions of strict objects: fields given as
|
|
108
109
|
`input: { … }` make one; a `t.Object` needs `{ additionalProperties: false }`. A shared entity has a
|
|
109
|
-
PascalCase `$id`. Use the shared schemas (`UuidSchema`, `EmailAddressSchema`, …) rather than copies
|
|
110
|
+
PascalCase `$id`. Use the shared schemas (`UuidSchema`, `EmailAddressSchema`, …) rather than copies, and
|
|
111
|
+
describe a use with TypeBox's `t.With(schema, { description })`, never by spreading the schema.
|
|
110
112
|
- **Each value is checked once, where it enters.** Maximus checks an operation's input and output; a handler
|
|
111
113
|
never parses its input again. Data from outside the pipeline, such as a stored record, a provider's
|
|
112
114
|
answer or a model's output, goes through `readSchema` or `checkSchema`. No casts, trust flags or no-op
|
|
@@ -127,7 +129,8 @@ Every `maximus` command says what it did in a sentence; `--json` prints it as JS
|
|
|
127
129
|
- **Worker code reads `env`, never `process.env`.** A secret is `bindings.secret()`. The development token is
|
|
128
130
|
never declared in `env` and never set on a deployed Worker.
|
|
129
131
|
- **Outbound calls:** a Worker's `fetch(…, { redirect: 'error' })` throws before it sends anything. Send with
|
|
130
|
-
`redirect: 'manual'` and refuse a `3xx`.
|
|
132
|
+
`redirect: 'manual'` and refuse a `3xx`. A URL someone else gave you, such as a customer's server, passes
|
|
133
|
+
`publicDestination(url)` from `@arbol-ai/maximus/body` first.
|
|
131
134
|
- **Generated code stays generated.** Never edit `.maximus/`: change the source files or `vite.config.ts`.
|
|
132
135
|
- **Refusals are guidance.** `maximus prepare`, `maximus()` and the application's `.build()` refuse a broken
|
|
133
136
|
project with a message that names the rule and the file or operation. Fix the declaration; never loosen
|
|
@@ -101,6 +101,7 @@ object, and its handler may return nothing.
|
|
|
101
101
|
| `http` | `successStatus` (200, 201 or 202), `body: 'bytes'`, `headers`, `response: 'attachment'`. |
|
|
102
102
|
| `mcp` | `{ name, idempotent?, openWorld? }`: also an MCP tool. `openWorld` is `true` unless declared. |
|
|
103
103
|
| `rpc` | `true` for every caller in `rpc.callers`, or `{ callers }` for some of them. |
|
|
104
|
+
| `task` | `true` or `{ ttlMs }`: a call that outlasts one second answers a task (MCP Tasks, or `Prefer: respond-async`); needs `MAXIMUS_TASKS`. |
|
|
104
105
|
| `maxBodyBytes`, `maxOutputBytes` | Its own limits, up to 16 MiB; the application's (32 KiB and 256 KiB) otherwise. |
|
|
105
106
|
|
|
106
107
|
A field no operation has does not compile, and `.build()` refuses it. A contract kept in a `const` keeps
|
|
@@ -128,6 +129,11 @@ browsers can import):
|
|
|
128
129
|
`HttpsUrlSchema`, `HexColorSchema`, `PostalAddressSchema`, `NamedReferenceSchema`, `SignedUrlSchema`,
|
|
129
130
|
`DeletedObjectSchema`, `EmptyInputSchema`.
|
|
130
131
|
- Absent values in an output are `t.Union([X, t.Null()])`: answer every field.
|
|
132
|
+
- `t` is TypeBox 1.x, which keeps what makes a schema optional, a codec (`t.Codec`) or a refinement
|
|
133
|
+
(`t.Refine`) in properties a spread drops: give a schema a description with
|
|
134
|
+
`t.With(schema, { description })`, never `{ ...schema, description }`. Spreading a record of fields
|
|
135
|
+
(`{ ...PageQueryFields, done: t.Boolean() }`) is safe. A recursive schema is
|
|
136
|
+
`t.Cyclic({ Node: … t.Ref('Node') … }, 'Node')`.
|
|
131
137
|
- `secret: true` on a schema marks a value capture never records, such as `t.String({ secret: true })`. It
|
|
132
138
|
changes nothing a caller or a handler sees.
|
|
133
139
|
- Codecs from `@arbol-ai/maximus/schemas` (`normalizeSchema`, `transformSchema`, `refineSchema`,
|
|
@@ -172,7 +178,9 @@ export default defineHandler(
|
|
|
172
178
|
`PageQueryFields` are `cursor`, `direction` (`forward` or `backward`) and `limit` (25 by default, at most
|
|
173
179
|
100; `pageLimit({ maximum })` lowers it). The answer is `{ object: 'list', data, pageInfo }`, whose
|
|
174
180
|
`pageInfo` holds `hasNextPage`, `hasPreviousPage`, `nextCursor` and `previousCursor`. Spread the fields
|
|
175
|
-
beside a list's own filters: `{ ...PageQueryFields, text: t.String() }`.
|
|
181
|
+
beside a list's own filters: `{ ...PageQueryFields, text: t.String() }`. A list the service holds whole is
|
|
182
|
+
cut with `cutPage(items, { key: (item) => [item.createdAt, item.id], order: 'desc' }, input)`: never write
|
|
183
|
+
cursors or offsets by hand. It answers `undefined` for a cursor it did not make; answer your own failure.
|
|
176
184
|
|
|
177
185
|
## Byte bodies and attachments
|
|
178
186
|
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { t as isRecord } from "./record-DQUDTpEA.js";
|
|
2
|
-
|
|
3
|
-
// src/internal/http-routes.ts
|
|
4
|
-
/**
|
|
5
|
-
* The parameter's schema in an object input, or in each member of a union. Every one must declare the
|
|
6
|
-
* parameter as a required string field, or this throws a TypeError.
|
|
7
|
-
*/
|
|
8
|
-
function pathParameterSchemas(input, parameter) {
|
|
9
|
-
if (input.type === "object") {
|
|
10
|
-
const schema = input.properties?.[parameter];
|
|
11
|
-
if (!schema || schema.type !== "string" || !input.required?.includes(parameter)) throw new TypeError(`Path parameter "${parameter}" must be a required string input field.`);
|
|
12
|
-
return [schema];
|
|
13
|
-
}
|
|
14
|
-
if (Array.isArray(input.anyOf) && input.anyOf.length > 0) return input.anyOf.flatMap((schema) => pathParameterSchemas(schema, parameter));
|
|
15
|
-
throw new TypeError("Path parameters require object input contracts.");
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* The group a route's path names, which OpenAPI publishes as its tag: its first fixed segment after the
|
|
19
|
-
* version, in words, such as `Notes` for `/v1/notes/{noteId}` and `Task lists` for `/v1/task-lists`;
|
|
20
|
-
* undefined when only parameters follow the version.
|
|
21
|
-
*/
|
|
22
|
-
function routeGroup(path) {
|
|
23
|
-
const segments = path.split("/").filter(Boolean);
|
|
24
|
-
const segment = (/^v[1-9][0-9]*$/.test(segments[0] ?? "") ? segments.slice(1) : segments).find((part) => !part.startsWith("{"));
|
|
25
|
-
if (segment === void 0) return;
|
|
26
|
-
const words = segment.replaceAll(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_-]+/).filter(Boolean).join(" ").toLowerCase();
|
|
27
|
-
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// src/result.ts
|
|
31
|
-
/** A success carrying `value`. */
|
|
32
|
-
function ok(value) {
|
|
33
|
-
return {
|
|
34
|
-
ok: true,
|
|
35
|
-
value
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
/** A failure carrying `error`, usually `catalog.someFailure.create()`. */
|
|
39
|
-
function err(error) {
|
|
40
|
-
return {
|
|
41
|
-
ok: false,
|
|
42
|
-
error
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Whether an untrusted answer (a Service Binding's, a stored one) is a Maximus Result: a success with
|
|
47
|
-
* its value, or a failure with a well-formed error. Anything else is not an answer at all.
|
|
48
|
-
*/
|
|
49
|
-
function isResult(value) {
|
|
50
|
-
if (!isRecord(value)) return false;
|
|
51
|
-
if (value.ok === true) return "value" in value;
|
|
52
|
-
const { error } = value;
|
|
53
|
-
return value.ok === false && isRecord(error) && typeof error.code === "string" && typeof error.message === "string" && typeof error.retryable === "boolean" && isRecord(error.data);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export { routeGroup as a, pathParameterSchemas as i, isResult as n, ok as r, err as t };
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { c as SchemaValidationError, f as inputSchema, l as defaultSchema, o as codecFault, r as decodeSchema, s as decodeIssues } from "./validation-DMu0rkMQ.js";
|
|
2
|
-
import { Kind, Type, Type as Type$1, Type as t } from "@sinclair/typebox";
|
|
3
|
-
|
|
4
|
-
// src/schema-reader.ts
|
|
5
|
-
/**
|
|
6
|
-
* Reads untrusted data — a stored record, a provider or model answer — through its schema's owner
|
|
7
|
-
* semantics: defaults applied, normalizers run before their checks, unknown keys of a strip object
|
|
8
|
-
* dropped. A refusal carries every issue with its path; nothing is coerced. An owner codec that fails
|
|
9
|
-
* throws what it threw.
|
|
10
|
-
*/
|
|
11
|
-
function checkSchema(schema, input) {
|
|
12
|
-
try {
|
|
13
|
-
return {
|
|
14
|
-
success: true,
|
|
15
|
-
data: decodeSchema(inputSchema(schema, { stripUnknown: true }), input)
|
|
16
|
-
};
|
|
17
|
-
} catch (error) {
|
|
18
|
-
const issues = decodeIssues(error);
|
|
19
|
-
if (!issues) throw codecFault(error);
|
|
20
|
-
return {
|
|
21
|
-
success: false,
|
|
22
|
-
error: new SchemaValidationError(issues)
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
/** `checkSchema`, throwing its SchemaValidationError on refusal. */
|
|
27
|
-
function readSchema(schema, input) {
|
|
28
|
-
const checked = checkSchema(schema, input);
|
|
29
|
-
if (!checked.success) throw checked.error;
|
|
30
|
-
return checked.data;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// src/attachment-schema.ts
|
|
34
|
-
/**
|
|
35
|
-
* The file an HTTP operation answers with and its output schema, with nothing that needs a runtime. An
|
|
36
|
-
* attachment is never a JSON or RPC value.
|
|
37
|
-
*/
|
|
38
|
-
/** The output of an operation that answers with a file (`http.response: 'attachment'`). */
|
|
39
|
-
const AttachmentOutputSchema = Type.Unsafe({
|
|
40
|
-
[Kind]: "HttpAttachment",
|
|
41
|
-
type: "string",
|
|
42
|
-
format: "binary",
|
|
43
|
-
description: "Authenticated attachment bytes with validated media type, filename and exact length."
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// src/pagination.ts
|
|
47
|
-
/**
|
|
48
|
-
* The one list contract: bidirectional keyset pagination. A list takes the query fields `cursor`,
|
|
49
|
-
* `direction` and `limit` and answers `{ object: 'list', data, pageInfo }`. The cursor is opaque to
|
|
50
|
-
* callers; there is no page number, page size, offset or implicit total.
|
|
51
|
-
*
|
|
52
|
-
* `PageInfo` and each `Page` are named schemas, so an OpenAPI document carries them once as
|
|
53
|
-
* `#/components/schemas/<name>` and every SDK generated from it shares their types.
|
|
54
|
-
*/
|
|
55
|
-
/** A public schema name: an SDK type in every language generated from the document. */
|
|
56
|
-
const PAGE_ID = /^[A-Z][A-Za-z0-9]{0,127}$/;
|
|
57
|
-
/**
|
|
58
|
-
* How to reach a list's neighboring pages: whether they exist and their opaque cursors, named `PageInfo`.
|
|
59
|
-
*/
|
|
60
|
-
const PageInfoSchema = Type.Object({
|
|
61
|
-
hasNextPage: Type.Boolean({ description: "Whether a later page exists in the current ordering." }),
|
|
62
|
-
hasPreviousPage: Type.Boolean({ description: "Whether an earlier page exists in the current ordering." }),
|
|
63
|
-
nextCursor: Type.Union([Type.String(), Type.Null()], { description: "Opaque cursor for the next page, or null when there is none." }),
|
|
64
|
-
previousCursor: Type.Union([Type.String(), Type.Null()], { description: "Opaque cursor for the previous page, or null when there is none." })
|
|
65
|
-
}, {
|
|
66
|
-
$id: "PageInfo",
|
|
67
|
-
additionalProperties: false
|
|
68
|
-
});
|
|
69
|
-
/**
|
|
70
|
-
* A list's `limit`: an integer from 1 to `maximum` (100), `default` (25, or the maximum when it is lower)
|
|
71
|
-
* when the caller sends none. A list whose items are costly lowers the maximum:
|
|
72
|
-
* `{ ...PageQueryFields, limit: pageLimit({ maximum: 20 }) }`. A default outside 1 to the maximum, or a
|
|
73
|
-
* value that is not an integer, throws a TypeError.
|
|
74
|
-
*/
|
|
75
|
-
function pageLimit(options = {}) {
|
|
76
|
-
const { maximum = 100, default: fallback = Math.min(25, maximum) } = options;
|
|
77
|
-
if (!(Number.isInteger(maximum) && Number.isInteger(fallback) && fallback >= 1 && fallback <= maximum)) throw new TypeError("A page limit has an integer default from 1 to its integer maximum.");
|
|
78
|
-
return defaultSchema(Type.Integer({
|
|
79
|
-
minimum: 1,
|
|
80
|
-
maximum,
|
|
81
|
-
description: `Maximum items returned in one page. Defaults to ${fallback}; larger reads require another cursor.`
|
|
82
|
-
}), fallback);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* The query fields of a list, spread into its input beside its own filters: an optional opaque `cursor`, a
|
|
86
|
-
* `direction` (`forward` by default, or `backward`) and a `limit` (`pageLimit()`).
|
|
87
|
-
*/
|
|
88
|
-
const PageQueryFields = {
|
|
89
|
-
cursor: Type.Optional(Type.String({ description: "Opaque cursor returned by pageInfo; omit it to request the first page." })),
|
|
90
|
-
direction: defaultSchema(Type.Union([Type.Literal("forward"), Type.Literal("backward")], { description: "Direction to traverse the stable keyset ordering from the supplied cursor." }), "forward"),
|
|
91
|
-
limit: pageLimit()
|
|
92
|
-
};
|
|
93
|
-
/**
|
|
94
|
-
* The output of a list of `item`, named by `$id` (`AppointmentPage`), a PascalCase name of up to 128
|
|
95
|
-
* characters; any other throws a TypeError. Give each list its own name and use it for that list only: two
|
|
96
|
-
* different shapes under one `$id` become two components, the second one suffixed `_2`.
|
|
97
|
-
*/
|
|
98
|
-
function Page(item, options) {
|
|
99
|
-
if (!PAGE_ID.test(options.$id)) throw new TypeError(`Page "${options.$id}" needs a PascalCase schema name, such as AppointmentPage.`);
|
|
100
|
-
return Type.Object({
|
|
101
|
-
data: Type.Array(item, { description: "Items admitted by this resource contract within the verified organization." }),
|
|
102
|
-
object: Type.Literal("list", { description: "Discriminator for a resource list response." }),
|
|
103
|
-
pageInfo: {
|
|
104
|
-
...PageInfoSchema,
|
|
105
|
-
description: "Opaque navigation cursors for this page’s stable keyset order."
|
|
106
|
-
}
|
|
107
|
-
}, {
|
|
108
|
-
$id: options.$id,
|
|
109
|
-
additionalProperties: false
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// src/common-schemas.ts
|
|
114
|
-
/**
|
|
115
|
-
* Values and objects that services publish alike, each named by its `$id`: an OpenAPI document carries
|
|
116
|
-
* it once as `#/components/schemas/<name>`, and every SDK generated from those documents has one type
|
|
117
|
-
* for it. A name is public, so it names exactly one shape. Domain records (people, patients,
|
|
118
|
-
* identity documents) stay with the service that owns them.
|
|
119
|
-
*/
|
|
120
|
-
/** An email address of at most 254 characters, named `EmailAddress`. */
|
|
121
|
-
const EmailAddressSchema = Type.String({
|
|
122
|
-
$id: "EmailAddress",
|
|
123
|
-
format: "email",
|
|
124
|
-
maxLength: 254,
|
|
125
|
-
description: "Email address."
|
|
126
|
-
});
|
|
127
|
-
/** A phone number in E.164 format, named `PhoneNumber`. */
|
|
128
|
-
const PhoneNumberSchema = Type.String({
|
|
129
|
-
$id: "PhoneNumber",
|
|
130
|
-
pattern: "^\\+[1-9][0-9]{1,14}$",
|
|
131
|
-
description: "Phone number in E.164 format."
|
|
132
|
-
});
|
|
133
|
-
/** An HTTPS URL of at most 2048 characters, named `HttpsUrl`. */
|
|
134
|
-
const HttpsUrlSchema = Type.String({
|
|
135
|
-
$id: "HttpsUrl",
|
|
136
|
-
format: "uri",
|
|
137
|
-
pattern: "^https://",
|
|
138
|
-
maxLength: 2048,
|
|
139
|
-
description: "An HTTPS URL."
|
|
140
|
-
});
|
|
141
|
-
/** A `#rrggbb` color, named `HexColor`. */
|
|
142
|
-
const HexColorSchema = Type.String({
|
|
143
|
-
$id: "HexColor",
|
|
144
|
-
pattern: "^#[0-9a-fA-F]{6}$",
|
|
145
|
-
description: "A color, as #rrggbb."
|
|
146
|
-
});
|
|
147
|
-
/** What a delete answers: the deleted resource's id and `deleted: true`, named `DeletedObject`. */
|
|
148
|
-
const DeletedObjectSchema = Type.Object({
|
|
149
|
-
id: Type.String({ description: "The id of the deleted resource." }),
|
|
150
|
-
deleted: Type.Literal(true)
|
|
151
|
-
}, {
|
|
152
|
-
$id: "DeletedObject",
|
|
153
|
-
additionalProperties: false
|
|
154
|
-
});
|
|
155
|
-
/** The URL of a `SignedUrl`, described as the credential it is. */
|
|
156
|
-
const SignedUrlFieldSchema = {
|
|
157
|
-
...HttpsUrlSchema,
|
|
158
|
-
description: "The signed URL. Anyone holding it has access until it expires."
|
|
159
|
-
};
|
|
160
|
-
/**
|
|
161
|
-
* A link that grants access by itself until it expires, such as a file download: its HTTPS `url` and its
|
|
162
|
-
* `expiresAt` date-time, named `SignedUrl`.
|
|
163
|
-
*/
|
|
164
|
-
const SignedUrlSchema = Type.Object({
|
|
165
|
-
url: SignedUrlFieldSchema,
|
|
166
|
-
expiresAt: Type.String({
|
|
167
|
-
format: "date-time",
|
|
168
|
-
description: "When the URL stops working."
|
|
169
|
-
})
|
|
170
|
-
}, {
|
|
171
|
-
$id: "SignedUrl",
|
|
172
|
-
additionalProperties: false
|
|
173
|
-
});
|
|
174
|
-
/** Another resource, by its id and the name people know it by, named `NamedReference`. */
|
|
175
|
-
const NamedReferenceSchema = Type.Object({
|
|
176
|
-
id: Type.String({ description: "The id of the referenced resource." }),
|
|
177
|
-
name: Type.String({ description: "Its name." })
|
|
178
|
-
}, {
|
|
179
|
-
$id: "NamedReference",
|
|
180
|
-
additionalProperties: false
|
|
181
|
-
});
|
|
182
|
-
/**
|
|
183
|
-
* A postal address, shaped as FHIR `Address` (its lines, city, state, postal code, ISO 3166-1 alpha-2 country
|
|
184
|
-
* code and use), every field optional, named `PostalAddress`.
|
|
185
|
-
*/
|
|
186
|
-
const PostalAddressSchema = Type.Object({
|
|
187
|
-
city: Type.Optional(Type.String({ maxLength: 120 })),
|
|
188
|
-
countryCode: Type.Optional(Type.String({
|
|
189
|
-
description: "ISO 3166-1 alpha-2.",
|
|
190
|
-
pattern: "^[A-Z]{2}$"
|
|
191
|
-
})),
|
|
192
|
-
line: Type.Optional(Type.Array(Type.String({ maxLength: 200 }), { maxItems: 4 })),
|
|
193
|
-
postalCode: Type.Optional(Type.String({ maxLength: 20 })),
|
|
194
|
-
state: Type.Optional(Type.String({ maxLength: 120 })),
|
|
195
|
-
use: Type.Optional(Type.Union([Type.Literal("home"), Type.Literal("work")]))
|
|
196
|
-
}, {
|
|
197
|
-
$id: "PostalAddress",
|
|
198
|
-
additionalProperties: false
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
// src/schemas.ts
|
|
202
|
-
/**
|
|
203
|
-
* `@arbol-ai/maximus/schemas`: the browser-safe schema vocabulary: TypeBox (`t`), its types, the validators
|
|
204
|
-
* and the shared identifier schemas, with nothing that needs a Worker runtime. A contract module that
|
|
205
|
-
* browsers import (a Dashboard reading an API's limits, a widget's settings) imports from here rather than
|
|
206
|
-
* the package root.
|
|
207
|
-
*/
|
|
208
|
-
/** The input of an operation that takes none: an empty strict object. */
|
|
209
|
-
const EmptyInputSchema = Type.Object({}, { additionalProperties: false });
|
|
210
|
-
/**
|
|
211
|
-
* An organization id as identity providers issue them (`org_…`, a UUID, a slug): 1 to 128 letters, digits,
|
|
212
|
-
* `_` and `-`, starting with a letter or digit, named `OrganizationId`. Nothing in it can change the meaning
|
|
213
|
-
* of a storage key, a path or a log line.
|
|
214
|
-
*/
|
|
215
|
-
const OrganizationIdSchema = Type.String({
|
|
216
|
-
$id: "OrganizationId",
|
|
217
|
-
pattern: "^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$",
|
|
218
|
-
description: "Verified organization identifier."
|
|
219
|
-
});
|
|
220
|
-
/** A lowercase RFC 9562 UUID of version 1 to 8, named `Uuid`. */
|
|
221
|
-
const UuidSchema = Type.String({
|
|
222
|
-
$id: "Uuid",
|
|
223
|
-
format: "uuid",
|
|
224
|
-
pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
export { pageLimit as _, t as a, readSchema as b, HexColorSchema as c, PhoneNumberSchema as d, PostalAddressSchema as f, PageQueryFields as g, PageInfoSchema as h, UuidSchema as i, HttpsUrlSchema as l, Page as m, OrganizationIdSchema as n, DeletedObjectSchema as o, SignedUrlSchema as p, Type$1 as r, EmailAddressSchema as s, EmptyInputSchema as t, NamedReferenceSchema as u, AttachmentOutputSchema as v, checkSchema as y };
|