@arbol-ai/maximus 7.1.0 → 7.3.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/config/oxfmt.mjs +1 -0
- package/config/oxlint.mjs +1 -0
- package/dist/analytics/analytics.d.ts +2 -4
- package/dist/analytics/analytics.js +3 -4
- package/dist/body.d.ts +1 -1
- package/dist/body.js +2 -2
- package/dist/chunks/{body-BcMbreNd.js → body-6LichrQm.js} +1 -2
- package/dist/chunks/{correlation-gaiEoMBr.js → correlation-BEkcFFGT.js} +1 -2
- package/dist/chunks/{execution-qfZuMSIu.js → execution-B-yy4C7N.js} +14 -23
- package/dist/chunks/{json-Dwni3u4c.js → json-Bu4BLT25.js} +2 -3
- package/dist/chunks/prepare-project-zi106pWF.js +146 -0
- package/dist/chunks/{record-D2H3cg8S.js → record-DY-lX9w1.js} +2 -4
- package/dist/chunks/runtime-BPnaa-NK.js +223 -0
- package/dist/chunks/{schemas-q-51wBMQ.js → schemas-CzTvbXb6.js} +6 -11
- package/dist/chunks/{src-Ph5KHCRP.js → src-DPSpGNnT.js} +25 -21
- package/dist/chunks/{telemetry-DvZgrzZn.js → telemetry-BTwB68m5.js} +2 -4
- package/dist/chunks/{types-CGwAhnTE.d.ts → types-BWxDd3tY.d.ts} +128 -64
- package/dist/chunks/{validation-DWxKk1Js.js → validation-r-sgmsqb.js} +3 -6
- package/dist/client/client.d.ts +1 -3
- package/dist/client/client.js +7 -11
- package/dist/diagnostics.d.ts +1 -3
- package/dist/diagnostics.js +2 -2
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +3 -4
- package/dist/http-paths.d.ts +1 -1
- package/dist/http-paths.js +1 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -7
- package/dist/internals.d.ts +1 -1
- package/dist/internals.js +2 -2
- package/dist/mcp/index.d.ts +2 -4
- package/dist/mcp/index.js +5 -7
- package/dist/postgres/index.d.ts +0 -4
- package/dist/postgres/index.js +2 -4
- package/dist/project/index.d.ts +24 -0
- package/dist/project/index.js +82 -0
- package/dist/projection.d.ts +1 -3
- package/dist/projection.js +1 -2
- package/dist/schemas.d.ts +1 -1
- package/dist/schemas.js +2 -2
- package/dist/standard-failures.d.ts +1 -3
- package/dist/standard-failures.js +1 -2
- package/dist/tooling/cli.js +41 -24
- package/dist/tooling/testing.d.ts +1 -3
- package/dist/tooling/testing.js +1 -2
- package/dist/tooling/vite.d.ts +3 -0
- package/dist/tooling/vite.js +44 -0
- package/dist/webhooks.d.ts +2 -4
- package/dist/webhooks.js +1 -2
- package/dist/workers/runtime.d.ts +2 -112
- package/dist/workers/runtime.js +1 -226
- package/package.json +19 -6
- package/skills/maximus/SKILL.md +1 -1
- package/skills/maximus/references/building-a-service.md +9 -0
- package/templates/project/.agents/skills/project/SKILL.md.template +17 -0
- package/templates/project/.github/workflows/ci.yml.template +36 -0
- package/templates/project/.gitignore.template +10 -0
- package/templates/project/CLAUDE.md.template +34 -0
- package/templates/project/README.md.template +47 -0
- package/templates/project/cloudflare.config.ts.template +24 -0
- package/templates/project/package.json.template +38 -0
- package/templates/project/pages/index.ts.template +11 -0
- package/templates/project/routes/v1/greeting.ts.template +22 -0
- package/templates/project/src/app.ts.template +2 -0
- package/templates/project/src/application.ts.template +26 -0
- package/templates/project/src/index.ts.template +3 -0
- package/templates/project/src/worker.ts.template +6 -0
- package/templates/project/tsconfig.json.template +30 -0
- package/templates/project/vite.config.ts.template +11 -0
- package/templates/service/.github/workflows/ci.yml.template +1 -1
- package/templates/service/.gitignore.template +1 -0
- package/templates/service/CLAUDE.md.template +2 -0
- package/templates/service/README.md.template +7 -7
- package/templates/service/package.json.template +14 -9
- package/templates/service/tests/contract.test.ts.template +1 -1
- package/templates/service/vite.config.ts.template +8 -2
- package/templates/service/vitest.config.ts.template +1 -1
- package/templates/service/oxfmt.config.ts.template +0 -1
- package/templates/service/oxlint.config.ts.template +0 -1
package/dist/client/client.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { r as isRequestId } from "../chunks/correlation-
|
|
1
|
+
import { r as isRequestId } from "../chunks/correlation-BEkcFFGT.js";
|
|
2
2
|
import { standardErrors } from "../errors.js";
|
|
3
|
-
import { n as exactLength, t as isRecord } from "../chunks/record-
|
|
3
|
+
import { n as exactLength, t as isRecord } from "../chunks/record-DY-lX9w1.js";
|
|
4
4
|
import { isInputHeaderName, isPathParameterValue, operationPathParameters } from "../http-paths.js";
|
|
5
|
-
import { i as readJsonResponse } from "../chunks/json-
|
|
5
|
+
import { i as readJsonResponse } from "../chunks/json-Bu4BLT25.js";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/client/attachment-response.ts
|
|
8
8
|
/**
|
|
9
9
|
* An attachment as the typed client hands it out: a Response whose body is held to the length its headers
|
|
10
10
|
* declare.
|
|
@@ -25,8 +25,7 @@ function boundedAttachment(response, maxBytes) {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
//#region src/client/operation-abort.ts
|
|
28
|
+
// src/client/operation-abort.ts
|
|
30
29
|
/**
|
|
31
30
|
* Lets a client call stop waiting when its caller aborts, without cancelling the work it waited for.
|
|
32
31
|
*/
|
|
@@ -49,8 +48,7 @@ async function awaitWithSignal(pending, signal) {
|
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
//#region src/client/response-envelope.ts
|
|
51
|
+
// src/client/response-envelope.ts
|
|
54
52
|
/**
|
|
55
53
|
* Reads an operation's response envelope as the typed client receives it, checking its shape and its
|
|
56
54
|
* status before any data or failure reaches the caller.
|
|
@@ -101,8 +99,7 @@ async function readOperationEnvelope(response, options) {
|
|
|
101
99
|
}
|
|
102
100
|
}
|
|
103
101
|
|
|
104
|
-
|
|
105
|
-
//#region src/client/client.ts
|
|
102
|
+
// src/client/client.ts
|
|
106
103
|
/**
|
|
107
104
|
* `@arbol-ai/maximus/client`: the typed HTTP client. Its methods are inferred from the application's type
|
|
108
105
|
* alone, and its routes come from the service's live OpenAPI document.
|
|
@@ -321,5 +318,4 @@ function createClient(origin, token, options = {}) {
|
|
|
321
318
|
} });
|
|
322
319
|
}
|
|
323
320
|
|
|
324
|
-
//#endregion
|
|
325
321
|
export { createClient };
|
package/dist/diagnostics.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { $t as
|
|
2
|
-
//#region src/internal/diagnostics.d.ts
|
|
1
|
+
import { $t as Observer, Gn as isRequestId, Hn as TraceParent, Kn as parseTraceParent, Qt as ExecutionObservation, Un as createRequestId, Vn as DurableCorrelation, Wn as durableCorrelation, Zt as BackgroundContext, an as withDiagnostics, en as TelemetryConfig, in as telemetryEnabled, nn as recordExecution, rn as reportUnexpected, tn as diagnosticsEnabled } from "./chunks/types-BWxDd3tY.js";
|
|
3
2
|
/**
|
|
4
3
|
* What diagnostics may say about an error: its name, its causes' names, its issue count and its stack
|
|
5
4
|
* locations.
|
|
@@ -37,5 +36,4 @@ export declare function createDiagnostics(errorNames?: readonly string[]): {
|
|
|
37
36
|
safeErrorName: (error: unknown) => string;
|
|
38
37
|
describeError: (error: unknown) => ErrorDescription;
|
|
39
38
|
};
|
|
40
|
-
//#endregion
|
|
41
39
|
export { type BackgroundContext, type DurableCorrelation, type ErrorDescription, type ExecutionObservation, type Observer, type TelemetryConfig, type TraceParent, createRequestId, diagnosticsEnabled, durableCorrelation, isRequestId, parseTraceParent, recordExecution, reportUnexpected, telemetryEnabled, withDiagnostics };
|
package/dist/diagnostics.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as parseTraceParent, n as durableCorrelation, r as isRequestId, t as createRequestId } from "./chunks/correlation-
|
|
2
|
-
import { a as telemetryEnabled, c as createDiagnostics, i as reportUnexpected, o as withDiagnostics, r as recordExecution, t as diagnosticsEnabled } from "./chunks/telemetry-
|
|
1
|
+
import { i as parseTraceParent, n as durableCorrelation, r as isRequestId, t as createRequestId } from "./chunks/correlation-BEkcFFGT.js";
|
|
2
|
+
import { a as telemetryEnabled, c as createDiagnostics, i as reportUnexpected, o as withDiagnostics, r as recordExecution, t as diagnosticsEnabled } from "./chunks/telemetry-BTwB68m5.js";
|
|
3
3
|
|
|
4
4
|
export { createDiagnostics, createRequestId, diagnosticsEnabled, durableCorrelation, isRequestId, parseTraceParent, recordExecution, reportUnexpected, telemetryEnabled, withDiagnostics };
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Bn as standardErrors, Fn as Failure, Gn as isRequestId, In as FailureData, Ln as FailureSchema, Mn as ErrorCatalog, Nn as ErrorDefinition, Pn as ErrorFactory, Rn as defineErrors, jn as DefinedErrors, zn as resultSchema } from "./chunks/types-BWxDd3tY.js";
|
|
2
2
|
export { DefinedErrors, ErrorCatalog, ErrorDefinition, ErrorFactory, Failure, FailureData, FailureSchema, defineErrors, isRequestId, resultSchema, standardErrors };
|
package/dist/errors.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { STANDARD_FAILURES } from "./standard-failures.js";
|
|
2
|
-
import { i as parseSchema } from "./chunks/validation-
|
|
3
|
-
import { r as isRequestId } from "./chunks/correlation-
|
|
2
|
+
import { i as parseSchema } from "./chunks/validation-r-sgmsqb.js";
|
|
3
|
+
import { r as isRequestId } from "./chunks/correlation-BEkcFFGT.js";
|
|
4
4
|
import { Type } from "@sinclair/typebox";
|
|
5
5
|
import { Value } from "@sinclair/typebox/value";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/errors.ts
|
|
8
8
|
/**
|
|
9
9
|
* `@arbol-ai/maximus/errors`: error catalogs. `defineErrors` joins the standard failures and an
|
|
10
10
|
* application's own into one catalog whose factories build each failure and whose schema validates every
|
|
@@ -124,5 +124,4 @@ function resultSchema(value, error) {
|
|
|
124
124
|
}, { additionalProperties: false })]);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
//#endregion
|
|
128
127
|
export { FailureSchema, defineErrors, isRequestId, resultSchema, standardErrors };
|
package/dist/http-paths.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as HttpRouteDefinition, D as isInputHeaderName, E as decodePathParameter, O as isPathParameterValue, T as createHttpRouteResolver, k as operationPathParameters, w as HttpRouteMatch } from "./chunks/types-BWxDd3tY.js";
|
|
2
2
|
export { HttpRouteDefinition, HttpRouteMatch, createHttpRouteResolver, decodePathParameter, isInputHeaderName, isPathParameterValue, operationPathParameters };
|
package/dist/http-paths.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/http-paths.ts
|
|
2
2
|
/**
|
|
3
3
|
* `@arbol-ai/maximus/http-paths`: versioned route templates, path parameter decoding, and the router that
|
|
4
4
|
* matches a request to exactly one operation.
|
|
@@ -196,5 +196,4 @@ function createHttpRouteResolver(definitions) {
|
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
//#endregion
|
|
200
199
|
export { createHttpRouteResolver, decodePathParameter, isInputHeaderName, isPathParameterValue, operationPathParameters };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as SignedUrl, $t as Observer, A as HttpOptions, An as ok, At as parseInput, Bn as standardErrors, Bt as McpGuide, C as HttpRouteDefinition, Dn as Success, En as Result, F as createHttpHandler, Fn as Failure, Ft as AppManifest, G as EmailAddressSchema, Ht as OperationMiddleware, I as EmptyInputSchema, In as FailureData, It as Exposure, J as NamedReference, Jn as AttachmentOutputSchema, Jt as operationMatchesScopes, K as HexColorSchema, Kt as isPublicOperation, L as OrganizationIdSchema, Ln as FailureSchema, Lt as Invocation, M as HttpTransport, Mn as ErrorCatalog, Mt as ApplicationBuilder, N as RouteContext, Nn as ErrorDefinition, Nt as ApplicationConfiguration, On as err, P as TransportContext, Pn as ErrorFactory, Pt as maximus, Q as PostalAddressSchema, Qt as ExecutionObservation, Rn as defineErrors, Rt as InvocationAuthority, S as readBodyText, Sn as matchesScopes, T as createHttpRouteResolver, Tn as FailureResult, U as DeletedObject, Ut as OperationScope, V as UuidSchema, Vt as McpSkill, W as DeletedObjectSchema, Wt as OperationShape, X as PhoneNumberSchema, Xt as AdmissionObservation, Y as NamedReferenceSchema, Yt as operationScopes, Z as PostalAddress, Zt as BackgroundContext, _ as retryAfterSeconds, _n as createTokenVerifier, at as PageQueryFields, b as HttpBodyFailureReason, bn as protectedResourceMetadata, cn as TokenAlgorithm, d as Type, dn as TokenDevelopment, en as TelemetryConfig, et as SignedUrlSchema, f as t, fn as TokenPolicy, g as readJsonResponse, gn as createTokenAuthorization, h as readJsonBody, hn as TokenScheme, it as PageQuery, j as HttpRoute, jn as DefinedErrors, jt as parseSchema, kn as isResult, l as Static, ln as TokenClaims, m as isJsonMediaType, mn as TokenResolutionContext, nt as PageInfo, on as Principal, ot as TPage, p as createOpenApi, pn as TokenPrincipal, q as HttpsUrlSchema, qn as Attachment, rn as reportUnexpected, rt as PageInfoSchema, sn as PrincipalSchema, st as pageLimit, tt as Page, u as TSchema, un as TokenClient, v as BodyReadOptions, vn as projectToken, w as HttpRouteMatch, wn as BinaryBody, x as readBodyBytes, xn as ScopeMatch, y as HttpBodyFailure, yn as OAuthResource, zn as resultSchema, zt as McpConfiguration } from "./chunks/types-BWxDd3tY.js";
|
|
2
2
|
export { type AdmissionObservation, type AppManifest, type ApplicationBuilder, type ApplicationConfiguration, type Attachment, AttachmentOutputSchema, type BackgroundContext, type BinaryBody, type BodyReadOptions, type DefinedErrors, type DeletedObject, DeletedObjectSchema, EmailAddressSchema, EmptyInputSchema, type ErrorCatalog, type ErrorDefinition, type ErrorFactory, type ExecutionObservation, type Exposure, type Failure, type FailureData, type FailureResult, FailureSchema, HexColorSchema, type HttpBodyFailure, type HttpBodyFailureReason, type HttpOptions, type HttpRoute, type HttpRouteDefinition, type HttpRouteMatch, type HttpTransport, HttpsUrlSchema, type Invocation, type InvocationAuthority, type McpConfiguration, type McpGuide, type McpSkill, type NamedReference, NamedReferenceSchema, type OAuthResource, type Observer, type OperationMiddleware, type OperationScope, type OperationShape, OrganizationIdSchema, Page, type PageInfo, PageInfoSchema, type PageQuery, PageQueryFields, PhoneNumberSchema, type PostalAddress, PostalAddressSchema, type Principal, PrincipalSchema, type Result, type RouteContext, type ScopeMatch, type SignedUrl, SignedUrlSchema, type Static, type Success, type TPage, type TSchema, type TelemetryConfig, type TokenAlgorithm, type TokenClaims, type TokenClient, type TokenDevelopment, type TokenPolicy, type TokenPrincipal, type TokenResolutionContext, type TokenScheme, type TransportContext, Type, UuidSchema, createHttpHandler, createHttpRouteResolver, createOpenApi, createTokenAuthorization, createTokenVerifier, defineErrors, err, isJsonMediaType, isPublicOperation, isResult, matchesScopes, maximus, ok, operationMatchesScopes, operationScopes, pageLimit, parseInput, parseSchema, projectToken, protectedResourceMetadata, readBodyBytes, readBodyText, readJsonBody, readJsonResponse, reportUnexpected, resultSchema, retryAfterSeconds, standardErrors, t };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { i as parseSchema, r as parseInput } from "./chunks/validation-
|
|
1
|
+
import { i as parseSchema, r as parseInput } from "./chunks/validation-r-sgmsqb.js";
|
|
2
2
|
import { FailureSchema, defineErrors, resultSchema, standardErrors } from "./errors.js";
|
|
3
|
-
import { n as readBodyBytes, r as readBodyText } from "./chunks/body-
|
|
4
|
-
import { C as operationMatchesScopes, E as matchesScopes, T as operationScopes, a as createTokenVerifier, d as err, f as isResult, i as createTokenAuthorization, o as projectToken, p as ok, r as PrincipalSchema, y as isPublicOperation } from "./chunks/execution-
|
|
3
|
+
import { n as readBodyBytes, r as readBodyText } from "./chunks/body-6LichrQm.js";
|
|
4
|
+
import { C as operationMatchesScopes, E as matchesScopes, T as operationScopes, a as createTokenVerifier, d as err, f as isResult, i as createTokenAuthorization, o as projectToken, p as ok, r as PrincipalSchema, y as isPublicOperation } from "./chunks/execution-B-yy4C7N.js";
|
|
5
5
|
import { createHttpRouteResolver } from "./http-paths.js";
|
|
6
|
-
import { _ as pageLimit, 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, s as EmailAddressSchema, t as EmptyInputSchema, u as NamedReferenceSchema, v as AttachmentOutputSchema } from "./chunks/schemas-
|
|
7
|
-
import {
|
|
8
|
-
import { i as reportUnexpected } from "./chunks/telemetry-
|
|
9
|
-
import { a as retryAfterSeconds, i as readJsonResponse, r as readJsonBody, t as isJsonMediaType } from "./chunks/json-
|
|
6
|
+
import { _ as pageLimit, 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, s as EmailAddressSchema, t as EmptyInputSchema, u as NamedReferenceSchema, v as AttachmentOutputSchema } from "./chunks/schemas-CzTvbXb6.js";
|
|
7
|
+
import { d as maximus, i as createOpenApi, n as t, r as createHttpHandler, t as Type, u as protectedResourceMetadata } from "./chunks/src-DPSpGNnT.js";
|
|
8
|
+
import { i as reportUnexpected } from "./chunks/telemetry-BTwB68m5.js";
|
|
9
|
+
import { a as retryAfterSeconds, i as readJsonResponse, r as readJsonBody, t as isJsonMediaType } from "./chunks/json-Bu4BLT25.js";
|
|
10
10
|
|
|
11
11
|
export { AttachmentOutputSchema, DeletedObjectSchema, EmailAddressSchema, EmptyInputSchema, FailureSchema, HexColorSchema, HttpsUrlSchema, NamedReferenceSchema, OrganizationIdSchema, Page, PageInfoSchema, PageQueryFields, PhoneNumberSchema, PostalAddressSchema, PrincipalSchema, SignedUrlSchema, Type, UuidSchema, createHttpHandler, createHttpRouteResolver, createOpenApi, createTokenAuthorization, createTokenVerifier, defineErrors, err, isJsonMediaType, isPublicOperation, isResult, matchesScopes, maximus, ok, operationMatchesScopes, operationScopes, pageLimit, parseInput, parseSchema, projectToken, protectedResourceMetadata, readBodyBytes, readBodyText, readJsonBody, readJsonResponse, reportUnexpected, resultSchema, retryAfterSeconds, standardErrors, t };
|
package/dist/internals.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as HttpOptions, C as HttpRouteDefinition, Ft as AppManifest, Gt as composeOperations, Ht as OperationMiddleware, Lt as Invocation, M as HttpTransport, P as TransportContext, Rt as InvocationAuthority, T as createHttpRouteResolver, Wt as OperationShape, Yt as operationScopes, Zt as BackgroundContext, an as withDiagnostics, c as executeOperation, en as TelemetryConfig, in as telemetryEnabled, nn as recordExecution, qt as operation, s as defineApp, w as HttpRouteMatch } from "./chunks/types-BWxDd3tY.js";
|
|
2
2
|
export { type AppManifest, type BackgroundContext, type HttpOptions, type HttpRouteDefinition, type HttpRouteMatch, type HttpTransport, type Invocation, type InvocationAuthority, type OperationMiddleware, type OperationShape, type TelemetryConfig, type TransportContext, composeOperations, createHttpRouteResolver, defineApp, executeOperation, operation, operationScopes, recordExecution, telemetryEnabled, withDiagnostics };
|
package/dist/internals.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as operationScopes, n as defineApp, t as executeOperation, v as composeOperations, x as operation } from "./chunks/execution-
|
|
1
|
+
import { T as operationScopes, n as defineApp, t as executeOperation, v as composeOperations, x as operation } from "./chunks/execution-B-yy4C7N.js";
|
|
2
2
|
import { createHttpRouteResolver } from "./http-paths.js";
|
|
3
|
-
import { a as telemetryEnabled, o as withDiagnostics, r as recordExecution } from "./chunks/telemetry-
|
|
3
|
+
import { a as telemetryEnabled, o as withDiagnostics, r as recordExecution } from "./chunks/telemetry-BTwB68m5.js";
|
|
4
4
|
|
|
5
5
|
export { composeOperations, createHttpRouteResolver, defineApp, executeOperation, operation, operationScopes, recordExecution, telemetryEnabled, withDiagnostics };
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region src/mcp/index.d.ts
|
|
1
|
+
import { M as HttpTransport } from "../chunks/types-BWxDd3tY.js";
|
|
3
2
|
/**
|
|
4
3
|
* The MCP transport, for `createWorker(app, { transports: [mcp()] })`: serves the operations that declare
|
|
5
4
|
* `mcp` as tools over Streamable HTTP at `/mcp` (or `path`), with the OpenAPI document and guides as
|
|
@@ -8,5 +7,4 @@ import { E as HttpTransport } from "../chunks/types-CGwAhnTE.js";
|
|
|
8
7
|
*/
|
|
9
8
|
export declare function mcp(options?: {
|
|
10
9
|
path?: string;
|
|
11
|
-
}): HttpTransport;
|
|
12
|
-
//#endregion
|
|
10
|
+
}): HttpTransport;
|
package/dist/mcp/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { standardErrors } from "../errors.js";
|
|
2
|
-
import { C as operationMatchesScopes, b as mcpOpenWorld, g as MAX_BODY_BYTES_CEILING, m as sha256Hex } from "../chunks/execution-
|
|
3
|
-
import { a as canonical, o as standaloneSchema } from "../chunks/src-
|
|
4
|
-
import { i as reportUnexpected } from "../chunks/telemetry-
|
|
2
|
+
import { C as operationMatchesScopes, b as mcpOpenWorld, g as MAX_BODY_BYTES_CEILING, m as sha256Hex } from "../chunks/execution-B-yy4C7N.js";
|
|
3
|
+
import { a as canonical, o as standaloneSchema } from "../chunks/src-DPSpGNnT.js";
|
|
4
|
+
import { i as reportUnexpected } from "../chunks/telemetry-BTwB68m5.js";
|
|
5
5
|
import { Type } from "@sinclair/typebox";
|
|
6
6
|
import { Value } from "@sinclair/typebox/value";
|
|
7
7
|
import { stringify } from "yaml";
|
|
8
8
|
import { McpServer, ProtocolError, ProtocolErrorCode, createMcpHandler } from "@modelcontextprotocol/server";
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// src/mcp/skills.ts
|
|
11
11
|
/**
|
|
12
12
|
* The MCP Skills extension (SEP-2640): `skills/list` and `skills/get` describe each skill by its
|
|
13
13
|
* frontmatter and the manifest of its one file, whose size and SHA-256 digest hosts verify, and
|
|
@@ -172,8 +172,7 @@ function readSkill(skills, input) {
|
|
|
172
172
|
};
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
|
|
176
|
-
//#region src/mcp/index.ts
|
|
175
|
+
// src/mcp/index.ts
|
|
177
176
|
/**
|
|
178
177
|
* `@arbol-ai/maximus/mcp`: the MCP transport. One stateless server per request, built with the official SDK,
|
|
179
178
|
* lists the caller's tools and runs them through the shared execution path, and serves the OpenAPI document
|
|
@@ -402,5 +401,4 @@ function mcp(options = {}) {
|
|
|
402
401
|
};
|
|
403
402
|
}
|
|
404
403
|
|
|
405
|
-
//#endregion
|
|
406
404
|
export { mcp };
|
package/dist/postgres/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Pool, PoolClient } from "pg";
|
|
2
|
-
//#region src/postgres/failures.d.ts
|
|
3
2
|
/** Where a transaction was when it failed. */
|
|
4
3
|
type TransactionStage = 'connect' | 'begin' | 'configure' | 'work' | 'commit';
|
|
5
4
|
/**
|
|
@@ -26,8 +25,6 @@ interface TransactionFailure {
|
|
|
26
25
|
}
|
|
27
26
|
/** Only server ErrorResponse instances establish a SQLSTATE; arbitrary error messages are never classified. */
|
|
28
27
|
export declare function classifyTransactionFailure(error: unknown, stage: TransactionStage): TransactionFailure;
|
|
29
|
-
//#endregion
|
|
30
|
-
//#region src/postgres/transaction.d.ts
|
|
31
28
|
/** The organization a transaction works for, taken from the verified principal. */
|
|
32
29
|
interface TenantContext {
|
|
33
30
|
/**
|
|
@@ -77,5 +74,4 @@ type TransactionResult<T> = {
|
|
|
77
74
|
* identity after rollback. Uncertain COMMIT never retries; reconcile by the owner's logical key.
|
|
78
75
|
*/
|
|
79
76
|
export declare function withTenantTransaction<T>(pool: Pick<Pool, 'connect'>, tenant: TenantContext, options: TransactionOptions, work: (client: PoolClient, tenant: TenantContext) => Promise<T>): Promise<TransactionResult<T>>;
|
|
80
|
-
//#endregion
|
|
81
77
|
export type { TenantContext, TransactionFailure, TransactionOptions, TransactionResult, TransactionStage };
|
package/dist/postgres/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { setTimeout } from "node:timers/promises";
|
|
2
2
|
import { DatabaseError } from "pg";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/postgres/failures.ts
|
|
5
5
|
/**
|
|
6
6
|
* Classifies a Postgres transaction failure by the server's SQLSTATE and the stage it happened in, never
|
|
7
7
|
* by its message.
|
|
@@ -45,8 +45,7 @@ function classifyTransactionFailure(error, stage) {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
//#region src/postgres/transaction.ts
|
|
48
|
+
// src/postgres/transaction.ts
|
|
50
49
|
/**
|
|
51
50
|
* Short tenant-scoped Postgres transactions on one checked-out client, with time budgets and opt-in
|
|
52
51
|
* database-only retries.
|
|
@@ -136,5 +135,4 @@ async function withTenantTransaction(pool, tenant, options, work) {
|
|
|
136
135
|
throw new Error("Unreachable transaction attempt.");
|
|
137
136
|
}
|
|
138
137
|
|
|
139
|
-
//#endregion
|
|
140
138
|
export { classifyTransactionFailure, withTenantTransaction };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Ft as AppManifest, Wt as OperationShape, j as HttpRoute, n as WorkerOptions, r as WorkerRuntime } from "../chunks/types-BWxDd3tY.js";
|
|
2
|
+
/** File modules use native Workers handlers; unmatched events fail instead of disappearing. */
|
|
3
|
+
type Handlers<E> = Omit<ExportedHandler<E>, 'fetch'>;
|
|
4
|
+
/** One schedule, declared beside the code it runs. Configure its trigger in Cloudflare as well. */
|
|
5
|
+
interface ProjectCron<E> {
|
|
6
|
+
cron: string;
|
|
7
|
+
handler: NonNullable<Handlers<E>['scheduled']>;
|
|
8
|
+
}
|
|
9
|
+
/** Optional background modules discovered at build time. Keys are physical queue names and recipients. */
|
|
10
|
+
interface ProjectEvents<E> {
|
|
11
|
+
crons?: readonly ProjectCron<E>[];
|
|
12
|
+
queues?: Readonly<Record<string, NonNullable<Handlers<E>['queue']>>>;
|
|
13
|
+
email?: Readonly<Record<string, NonNullable<Handlers<E>['email']>>>;
|
|
14
|
+
}
|
|
15
|
+
/** Pages are native response handlers; rendering libraries stay in the application. */
|
|
16
|
+
export interface ProjectModules<E> extends ProjectEvents<E> {
|
|
17
|
+
pages?: Readonly<Record<string, HttpRoute<E>>>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 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.
|
|
22
|
+
*/
|
|
23
|
+
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
|
+
export type { ProjectCron, ProjectEvents };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { standardErrors } from "../errors.js";
|
|
2
|
+
import { c as nativePaths, l as ownsPrefix, s as VERSIONED_PATH } from "../chunks/src-DPSpGNnT.js";
|
|
3
|
+
import { r as createAssetHandler, t as createWorker } from "../chunks/runtime-BPnaa-NK.js";
|
|
4
|
+
|
|
5
|
+
// src/project/handlers.ts
|
|
6
|
+
/** Compose file handlers with explicit fallbacks, preserving the platform's execution context. */
|
|
7
|
+
function projectHandlers(events, fallback = {}) {
|
|
8
|
+
const handlers = { ...fallback };
|
|
9
|
+
if (events.crons?.length) {
|
|
10
|
+
const schedules = /* @__PURE__ */ new Map();
|
|
11
|
+
for (const { cron, handler } of events.crons) {
|
|
12
|
+
if (!cron.trim()) throw new TypeError("A cron module must export a nonempty cron expression.");
|
|
13
|
+
schedules.set(cron, [...schedules.get(cron) ?? [], handler]);
|
|
14
|
+
}
|
|
15
|
+
handlers.scheduled = async function scheduled(controller, env, context) {
|
|
16
|
+
const matched = schedules.get(controller.cron);
|
|
17
|
+
if (!matched) {
|
|
18
|
+
if (fallback.scheduled) {
|
|
19
|
+
await fallback.scheduled.call(this, controller, env, context);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
throw new Error("No module handles this cron trigger.");
|
|
23
|
+
}
|
|
24
|
+
await Promise.all(matched.map(async (handler) => {
|
|
25
|
+
await handler.call(this, controller, env, context);
|
|
26
|
+
}));
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (events.queues && Object.keys(events.queues).length) {
|
|
30
|
+
const queues = new Map(Object.entries(events.queues));
|
|
31
|
+
handlers.queue = async function queue(batch, env, context) {
|
|
32
|
+
const handler = queues.get(batch.queue) ?? fallback.queue;
|
|
33
|
+
if (!handler) throw new Error("No module handles this queue; the batch must be retried.");
|
|
34
|
+
await handler.call(this, batch, env, context);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (events.email && Object.keys(events.email).length) {
|
|
38
|
+
const recipients = new Map(Object.entries(events.email));
|
|
39
|
+
handlers.email = async function email(message, env, context) {
|
|
40
|
+
const handler = recipients.get(message.to) ?? recipients.get("_default") ?? fallback.email;
|
|
41
|
+
if (!handler) {
|
|
42
|
+
message.setReject("This recipient is not configured.");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
await handler.call(this, message, env, context);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return handlers;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/project/index.ts
|
|
52
|
+
/** Optional Workers composition for projects whose modules are discovered by `maximus prepare`. */
|
|
53
|
+
/**
|
|
54
|
+
* 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.
|
|
56
|
+
*/
|
|
57
|
+
function createProjectWorker(app, modules, options = {}) {
|
|
58
|
+
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
|
+
const native = nativePaths(app.tokens, options.http ?? {});
|
|
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.`);
|
|
62
|
+
const fallback = options.assets ? createAssetHandler(options.assets) : options.http?.fallback;
|
|
63
|
+
return createWorker(app, {
|
|
64
|
+
...options,
|
|
65
|
+
assets: void 0,
|
|
66
|
+
handlers: projectHandlers(modules, options.handlers),
|
|
67
|
+
http: {
|
|
68
|
+
...options.http,
|
|
69
|
+
async fallback(request, env, context) {
|
|
70
|
+
const page = pages.get(new URL(request.url).pathname);
|
|
71
|
+
if (page) {
|
|
72
|
+
if (request.method !== "GET" && request.method !== "HEAD") return context.fail(standardErrors.methodNotAllowed.create(), { allow: "GET, HEAD" });
|
|
73
|
+
const response = await page(request, env, context);
|
|
74
|
+
return request.method === "HEAD" ? new Response(null, response) : response;
|
|
75
|
+
}
|
|
76
|
+
return fallback ? await fallback(request, env, context) : context.fail(standardErrors.notFound.create());
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export { createProjectWorker };
|
package/dist/projection.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/projection.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* How a service's names and input schemas project onto the surfaces a gateway builds from its OpenAPI
|
|
4
3
|
* document, so the service, the gateway and the gateway's generated clients agree without coordinating:
|
|
@@ -32,5 +31,4 @@ export declare function mcpToolName(namespace: string, name: ProjectedName): str
|
|
|
32
31
|
* How one input field travels in a query string, or null when it cannot: objects and nested lists
|
|
33
32
|
* do not. Lists are comma separated; a `null` alternative is not expressible and is ignored.
|
|
34
33
|
*/
|
|
35
|
-
export declare function queryKind(schema: unknown, resolve?: SchemaResolver): QueryKind | null;
|
|
36
|
-
//#endregion
|
|
34
|
+
export declare function queryKind(schema: unknown, resolve?: SchemaResolver): QueryKind | null;
|
package/dist/projection.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/projection.ts
|
|
2
2
|
function record(value) {
|
|
3
3
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
4
4
|
}
|
|
@@ -56,5 +56,4 @@ function queryKind(schema, resolve) {
|
|
|
56
56
|
return value.type === "integer" || value.type === "number" || value.type === "boolean" ? value.type : null;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
//#endregion
|
|
60
59
|
export { kebab, mcpToolName, permissionDescription, queryKind, snake };
|
package/dist/schemas.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as SignedUrl, At as parseInput, B as Type, Cn as StaticDecode, Ct as strictObject, Dt as InputIssue, Et as urlSchema, G as EmailAddressSchema, H as t, I as EmptyInputSchema, J as NamedReference, Jn as AttachmentOutputSchema, K as HexColorSchema, L as OrganizationIdSchema, Ot as decodeInput, Q as PostalAddressSchema, R as Static, St as refineSchema, Tt as transformSchema, U as DeletedObject, V as UuidSchema, W as DeletedObjectSchema, X as PhoneNumberSchema, Y as NamedReferenceSchema, Z as PostalAddress, _t as inspectSchema, at as PageQueryFields, bt as normalizeSchema, ct as Checked, dt as SchemaInput, et as SignedUrlSchema, ft as SchemaIssue, gt as inputSchema, ht as extendObject, it as PageQuery, jt as parseSchema, kt as decodeSchema, lt as checkSchema, mt as defaultSchema, nt as PageInfo, ot as TPage, pt as SchemaValidationError, q as HttpsUrlSchema, qn as Attachment, rt as PageInfoSchema, st as pageLimit, tt as Page, ut as readSchema, vt as literalUnion, wt as stripObject, xt as pipeSchema, yt as looseObject, z as TSchema } from "./chunks/types-BWxDd3tY.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 strictObject, b as urlSchema, c as extendObject, d as inspectSchema, f as literalUnion, g as refineSchema, h as pipeSchema, i as parseSchema, m as normalizeSchema, n as decodeSchema, o as SchemaValidationError, p as looseObject, r as parseInput, s as defaultSchema, t as decodeInput, u as inputSchema, v as stripObject, y as transformSchema } from "./chunks/validation-
|
|
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 strictObject, b as urlSchema, c as extendObject, d as inspectSchema, f as literalUnion, g as refineSchema, h as pipeSchema, i as parseSchema, m as normalizeSchema, n as decodeSchema, o as SchemaValidationError, p as looseObject, r as parseInput, s as defaultSchema, t as decodeInput, u as inputSchema, v as stripObject, y as transformSchema } from "./chunks/validation-r-sgmsqb.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-CzTvbXb6.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,4 +1,3 @@
|
|
|
1
|
-
//#region src/standard-failures.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* `@arbol-ai/maximus/failures`: the framework's own failures as plain data: code, HTTP status,
|
|
4
3
|
* message, retryability and Retry-After. No runtime and no schema library, for a dispatcher that presents
|
|
@@ -87,5 +86,4 @@ export declare const STANDARD_FAILURES: {
|
|
|
87
86
|
readonly status: 502;
|
|
88
87
|
readonly message: 'The operation may have been applied; check its result before repeating it.';
|
|
89
88
|
};
|
|
90
|
-
};
|
|
91
|
-
//#endregion
|
|
89
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/standard-failures.ts
|
|
2
2
|
/** The framework's own failures, by the name `standardErrors` gives each. */
|
|
3
3
|
const STANDARD_FAILURES = {
|
|
4
4
|
invalidInput: {
|
|
@@ -71,5 +71,4 @@ const STANDARD_FAILURES = {
|
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
-
//#endregion
|
|
75
74
|
export { STANDARD_FAILURES };
|
package/dist/tooling/cli.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { t as prepareProject } from "../chunks/prepare-project-zi106pWF.js";
|
|
3
|
+
import { dirname, join, relative, resolve } from "node:path";
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, symlinkSync, writeFileSync } from "node:fs";
|
|
2
5
|
import { parseArgs } from "node:util";
|
|
3
6
|
import { randomBytes } from "node:crypto";
|
|
4
|
-
import { existsSync, mkdirSync, readFileSync, readdirSync, symlinkSync, writeFileSync } from "node:fs";
|
|
5
|
-
import { dirname, join, relative, resolve } from "node:path";
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
// src/tooling/internal/scaffold.ts
|
|
8
9
|
/**
|
|
9
10
|
* `maximus init`: a new service from the starter template.
|
|
10
11
|
*/
|
|
@@ -24,29 +25,33 @@ function packageDirectory() {
|
|
|
24
25
|
/**
|
|
25
26
|
* `maximus init`: writes a new service from the starter template into a directory that does not exist yet.
|
|
26
27
|
*/
|
|
27
|
-
function scaffold(directory, name) {
|
|
28
|
+
function scaffold(directory, name, layout = "service") {
|
|
28
29
|
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
30
|
const root = resolve(directory);
|
|
30
31
|
if (existsSync(root)) throw new Error("Choose a new directory; existing projects are never overwritten.");
|
|
31
32
|
const own = packageDirectory();
|
|
32
|
-
const template = join(own, "templates", "service");
|
|
33
33
|
const { version } = JSON.parse(readFileSync(join(own, "package.json"), "utf-8"));
|
|
34
34
|
const values = {
|
|
35
35
|
__PROJECT_NAME__: name,
|
|
36
36
|
__ENTRYPOINT__: `${name.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("")}Service`,
|
|
37
|
-
__MAXIMUS_VERSION__: version
|
|
37
|
+
__MAXIMUS_VERSION__: version,
|
|
38
|
+
__COMPATIBILITY_DATE__: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)
|
|
38
39
|
};
|
|
39
|
-
for (const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
for (const templateName of layout === "project" ? ["service", "project"] : ["service"]) {
|
|
41
|
+
const template = join(own, "templates", templateName);
|
|
42
|
+
for (const file of readdirSync(template, {
|
|
43
|
+
recursive: true,
|
|
44
|
+
withFileTypes: true
|
|
45
|
+
})) {
|
|
46
|
+
if (!file.isFile() || !file.name.endsWith(".template")) continue;
|
|
47
|
+
const source = resolve(file.parentPath, file.name);
|
|
48
|
+
if (layout === "project" && templateName === "service" && (relative(template, source).startsWith("tests/") || file.name === "vitest.config.ts.template")) continue;
|
|
49
|
+
const target = resolve(root, relative(template, source).replace(/\.template$/, ""));
|
|
50
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
51
|
+
let text = readFileSync(source, "utf-8");
|
|
52
|
+
for (const [placeholder, value] of Object.entries(values)) text = text.replaceAll(placeholder, value);
|
|
53
|
+
writeFileSync(target, text, { flag: templateName === "project" ? "w" : "wx" });
|
|
54
|
+
}
|
|
50
55
|
}
|
|
51
56
|
writeFileSync(resolve(root, ".dev.vars"), `DEVELOPMENT_TOKEN=${randomBytes(32).toString("hex")}\n`, {
|
|
52
57
|
flag: "wx",
|
|
@@ -59,12 +64,12 @@ function scaffold(directory, name) {
|
|
|
59
64
|
}
|
|
60
65
|
return {
|
|
61
66
|
directory: root,
|
|
62
|
-
|
|
67
|
+
layout,
|
|
68
|
+
next: layout === "project" ? "Run bun install and bun run dev. The public home page says Hello World. Configure the origin and token policy in src/application.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."
|
|
63
69
|
};
|
|
64
70
|
}
|
|
65
71
|
|
|
66
|
-
|
|
67
|
-
//#region src/tooling/cli.ts
|
|
72
|
+
// src/tooling/cli.ts
|
|
68
73
|
/**
|
|
69
74
|
* The `maximus` command: `init` creates a new service. Developing, building and deploying it are `cf`'s own
|
|
70
75
|
* commands, which Maximus does not wrap.
|
|
@@ -73,6 +78,14 @@ const { values, positionals } = parseArgs({
|
|
|
73
78
|
allowPositionals: true,
|
|
74
79
|
options: {
|
|
75
80
|
name: { type: "string" },
|
|
81
|
+
layout: {
|
|
82
|
+
type: "string",
|
|
83
|
+
default: "service"
|
|
84
|
+
},
|
|
85
|
+
mode: {
|
|
86
|
+
type: "string",
|
|
87
|
+
default: "production"
|
|
88
|
+
},
|
|
76
89
|
help: {
|
|
77
90
|
type: "boolean",
|
|
78
91
|
default: false
|
|
@@ -82,7 +95,8 @@ const { values, positionals } = parseArgs({
|
|
|
82
95
|
const [command, target] = positionals;
|
|
83
96
|
/** The help the command prints for `--help` or a usage mistake. */
|
|
84
97
|
const USAGE = [
|
|
85
|
-
"Usage: maximus init <new-directory> --name <name>",
|
|
98
|
+
"Usage: maximus init <new-directory> --name <name> [--layout service|project]",
|
|
99
|
+
" maximus prepare [directory] [--mode production|development]",
|
|
86
100
|
"Creates a new service. Develop, build and deploy it with cf: cf dev, cf build, cf workers types and",
|
|
87
101
|
"cf deploy."
|
|
88
102
|
].join("\n");
|
|
@@ -92,13 +106,18 @@ if (values.help) {
|
|
|
92
106
|
}
|
|
93
107
|
/** Runs the command the arguments name. */
|
|
94
108
|
function run() {
|
|
109
|
+
if (command === "prepare") {
|
|
110
|
+
console.info(JSON.stringify(prepareProject(target ?? ".", values.mode)));
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
95
113
|
if (command !== "init") {
|
|
96
114
|
console.error(USAGE);
|
|
97
115
|
process.exitCode = 1;
|
|
98
116
|
return;
|
|
99
117
|
}
|
|
100
118
|
if (!target || !values.name) throw new TypeError("Use maximus init <new-directory> --name <name>.");
|
|
101
|
-
|
|
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)));
|
|
102
121
|
}
|
|
103
122
|
try {
|
|
104
123
|
run();
|
|
@@ -106,5 +125,3 @@ try {
|
|
|
106
125
|
console.error(error instanceof Error && !process.env.MAXIMUS_DEBUG ? `maximus: ${error.message}` : error);
|
|
107
126
|
process.exitCode = 1;
|
|
108
127
|
}
|
|
109
|
-
|
|
110
|
-
//#endregion
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
//#region src/tooling/testing.d.ts
|
|
2
1
|
/** One deployed contract smoke; security and protocol matrices remain framework tests. */
|
|
3
2
|
export declare function verifyContract(fetch: (request: Request) => Promise<Response>, origin: string): Promise<{
|
|
4
3
|
paths: string[];
|
|
5
4
|
operations: string[];
|
|
6
|
-
}>;
|
|
7
|
-
//#endregion
|
|
5
|
+
}>;
|
package/dist/tooling/testing.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parse } from "yaml";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/tooling/testing.ts
|
|
4
4
|
/**
|
|
5
5
|
* `@arbol-ai/maximus/testing`: a contract smoke test for a local or deployed service.
|
|
6
6
|
*/
|
|
@@ -17,5 +17,4 @@ async function verifyContract(fetch, origin) {
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
//#endregion
|
|
21
20
|
export { verifyContract };
|