@relkit/runtime-hono 0.7.2 → 0.7.6
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/agent-observation-pages.d.ts +15 -0
- package/dist/agent-observation-pages.d.ts.map +1 -0
- package/dist/agent-observation-pages.js +69 -0
- package/dist/agent-observation-pages.js.map +1 -0
- package/dist/agent-observation.d.ts +18 -21
- package/dist/agent-observation.d.ts.map +1 -1
- package/dist/agent-observation.js +39 -73
- package/dist/agent-observation.js.map +1 -1
- package/dist/agent-observation.schemas.d.ts +16 -0
- package/dist/agent-observation.schemas.d.ts.map +1 -0
- package/dist/agent-observation.schemas.js +18 -0
- package/dist/agent-observation.schemas.js.map +1 -0
- package/dist/agent-observation.types.d.ts +25 -1
- package/dist/agent-observation.types.d.ts.map +1 -1
- package/dist/agent-rpc-resume-admission.d.ts +80 -0
- package/dist/agent-rpc-resume-admission.d.ts.map +1 -0
- package/dist/agent-rpc-resume-admission.js +95 -0
- package/dist/agent-rpc-resume-admission.js.map +1 -0
- package/dist/agent-rpc-resume.d.ts +22 -52
- package/dist/agent-rpc-resume.d.ts.map +1 -1
- package/dist/agent-rpc-resume.js +38 -86
- package/dist/agent-rpc-resume.js.map +1 -1
- package/dist/agent-rpc-resume.types.d.ts +17 -1
- package/dist/agent-rpc-resume.types.d.ts.map +1 -1
- package/dist/api-docs-auth.d.ts +16 -0
- package/dist/api-docs-auth.d.ts.map +1 -0
- package/dist/api-docs-auth.js +92 -0
- package/dist/api-docs-auth.js.map +1 -0
- package/dist/api-docs-document.d.ts +37 -0
- package/dist/api-docs-document.d.ts.map +1 -0
- package/dist/api-docs-document.js +109 -0
- package/dist/api-docs-document.js.map +1 -0
- package/dist/api-docs.d.ts.map +1 -1
- package/dist/api-docs.js +31 -70
- package/dist/api-docs.js.map +1 -1
- package/dist/api-docs.types.d.ts +2 -0
- package/dist/api-docs.types.d.ts.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +5 -0
- package/dist/auth.js.map +1 -1
- package/dist/auth.types.d.ts +3 -0
- package/dist/auth.types.d.ts.map +1 -1
- package/dist/create-app.d.ts +8 -8
- package/dist/create-app.d.ts.map +1 -1
- package/dist/create-app.js +6 -91
- package/dist/create-app.js.map +1 -1
- package/dist/create-rest-app.d.ts +36 -0
- package/dist/create-rest-app.d.ts.map +1 -0
- package/dist/create-rest-app.js +133 -0
- package/dist/create-rest-app.js.map +1 -0
- package/dist/materialize-rest-routes.d.ts +9 -0
- package/dist/materialize-rest-routes.d.ts.map +1 -0
- package/dist/materialize-rest-routes.js +62 -0
- package/dist/materialize-rest-routes.js.map +1 -0
- package/dist/materialize-routes-utils.d.ts +1 -1
- package/dist/materialize-routes-utils.d.ts.map +1 -1
- package/dist/materialize-routes-utils.js +10 -3
- package/dist/materialize-routes-utils.js.map +1 -1
- package/dist/materialize-routes.d.ts +5 -0
- package/dist/materialize-routes.d.ts.map +1 -1
- package/dist/materialize-routes.js +2 -49
- package/dist/materialize-routes.js.map +1 -1
- package/dist/materialize-routes.types.d.ts +3 -0
- package/dist/materialize-routes.types.d.ts.map +1 -1
- package/dist/prepared-app.d.ts +17 -0
- package/dist/prepared-app.d.ts.map +1 -0
- package/dist/prepared-app.js +56 -0
- package/dist/prepared-app.js.map +1 -0
- package/dist/prepared-transports.service.d.ts +30 -0
- package/dist/prepared-transports.service.d.ts.map +1 -0
- package/dist/prepared-transports.service.js +45 -0
- package/dist/prepared-transports.service.js.map +1 -0
- package/dist/prepared-transports.types.d.ts +33 -0
- package/dist/prepared-transports.types.d.ts.map +1 -0
- package/dist/prepared-transports.types.js +2 -0
- package/dist/prepared-transports.types.js.map +1 -0
- package/package.json +19 -15
package/dist/api-docs.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Installs protected JSON and Scalar routes for the shared application reference.
|
|
3
|
+
* Configuration is validated before registration; authorization precedes lazy
|
|
4
|
+
* document generation through ApiDocuments, executed at each HTTP request edge.
|
|
5
|
+
*/
|
|
6
|
+
import { API_BASE_PATH, API_VERSION, assertJsonValue, canonicalJson, } from "@relkit/contracts";
|
|
7
|
+
import { Effect, Layer } from "effect";
|
|
3
8
|
import { Scalar } from "@scalar/hono-api-reference";
|
|
9
|
+
import { ApiDocuments, documentFrom } from "./api-docs-document.js";
|
|
10
|
+
import { runHttp } from "./http-effect.js";
|
|
4
11
|
import { isAuthorized, jsonResponse } from "./internal-endpoints-utils.js";
|
|
5
12
|
export const OPENAPI_PATH = `${API_BASE_PATH}/openapi.json`;
|
|
6
13
|
export const API_REFERENCE_PATH = `${API_BASE_PATH}/api-reference`;
|
|
@@ -22,13 +29,23 @@ export function installApiDocs(app, plan, options = {}) {
|
|
|
22
29
|
validate(mode, enabled, options);
|
|
23
30
|
if (!enabled)
|
|
24
31
|
return;
|
|
25
|
-
const
|
|
32
|
+
const baseDocument = options.document ?? documentFrom(plan);
|
|
33
|
+
assertJsonValue(baseDocument);
|
|
34
|
+
const documents = Layer.effect(ApiDocuments, ApiDocuments.make(baseDocument, options));
|
|
35
|
+
const document = (signal) => runHttp(ApiDocuments.use((service) => service.get()).pipe(Effect.provide(documents)), signal);
|
|
26
36
|
const auth = authorization(options);
|
|
27
37
|
const embed = mode === "production" || auth.bearerToken !== undefined || auth.authorize !== undefined;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
registerDocumentRoutes(app, document, auth, embed);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Registers both representations behind the same authorization barrier.
|
|
42
|
+
* @param app - Hono application with already validated exposure policy.
|
|
43
|
+
* @param document - Lazy JSON reader executed only for an authorized request.
|
|
44
|
+
* @param auth - Existing internal endpoint authorization policy.
|
|
45
|
+
* @param embed - Whether Scalar must embed JSON to avoid a second protected fetch.
|
|
46
|
+
* @returns Nothing; installs two request handlers.
|
|
47
|
+
*/
|
|
48
|
+
function registerDocumentRoutes(app, document, auth, embed) {
|
|
32
49
|
/** Require the configured inspector authorization before serving API documentation.
|
|
33
50
|
* @param handler - Document or reference-UI handler to run after authorization.
|
|
34
51
|
* @returns A handler yielding the protected response or a bearer-authentication challenge.
|
|
@@ -41,10 +58,16 @@ export function installApiDocs(app, plan, options = {}) {
|
|
|
41
58
|
}
|
|
42
59
|
return handler(context, next);
|
|
43
60
|
};
|
|
44
|
-
app.get(OPENAPI_PATH, protect(async () => new Response(canonicalJson(document), {
|
|
61
|
+
app.get(OPENAPI_PATH, protect(async (context) => new Response(canonicalJson(await document(context.req.raw.signal)), {
|
|
45
62
|
headers: responseHeaders("application/json"),
|
|
46
63
|
})));
|
|
47
64
|
app.get(API_REFERENCE_PATH, protect(async (context, next) => {
|
|
65
|
+
const reference = Scalar({
|
|
66
|
+
...(embed
|
|
67
|
+
? { content: canonicalJson(await document(context.req.raw.signal)) }
|
|
68
|
+
: { url: "./openapi.json" }),
|
|
69
|
+
pageTitle: "RELKIT API Reference",
|
|
70
|
+
});
|
|
48
71
|
const response = await reference(context, next);
|
|
49
72
|
if (!(response instanceof Response))
|
|
50
73
|
return response;
|
|
@@ -58,22 +81,6 @@ export function installApiDocs(app, plan, options = {}) {
|
|
|
58
81
|
});
|
|
59
82
|
}));
|
|
60
83
|
}
|
|
61
|
-
/** Builds the OpenAPI document from the registered application graph.
|
|
62
|
-
* @param plan - Validated application registration plan.
|
|
63
|
-
* @returns The generated OpenAPI document for valid function targets and raw routes.
|
|
64
|
-
*/
|
|
65
|
-
function documentFrom(plan) {
|
|
66
|
-
const functions = new Set(plan.functions.map(({ id }) => id));
|
|
67
|
-
return generateOpenApi({
|
|
68
|
-
contractVersion: CONTRACT_VERSION,
|
|
69
|
-
nodes: [
|
|
70
|
-
...plan.functions,
|
|
71
|
-
...plan.httpTriggers.filter(({ config, targetFunctionId }) => (isRecord(config) && config.rawHandler === true) || functions.has(targetFunctionId)),
|
|
72
|
-
...(plan.services ?? []),
|
|
73
|
-
],
|
|
74
|
-
edges: [],
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
84
|
/** Selects the configured API-document authorization policy.
|
|
78
85
|
* @param options - Application dependencies and configuration for this domain.
|
|
79
86
|
* @returns The API-document bearer token and authorization callback in inspector option form.
|
|
@@ -115,50 +122,4 @@ function responseHeaders(contentType) {
|
|
|
115
122
|
"x-relkit-api-version": String(API_VERSION),
|
|
116
123
|
};
|
|
117
124
|
}
|
|
118
|
-
/** Removes excluded service domains from the generated API document.
|
|
119
|
-
* @param document - Generated API document to project for public exposure.
|
|
120
|
-
* @param excluded - Service domains excluded from the published API document.
|
|
121
|
-
* @returns The document with excluded service operations and unused tags removed.
|
|
122
|
-
*/
|
|
123
|
-
function filterDomains(document, excluded = []) {
|
|
124
|
-
if (excluded.length === 0 || !isRecord(document) || !isRecord(document.paths))
|
|
125
|
-
return document;
|
|
126
|
-
const domains = new Set(excluded);
|
|
127
|
-
const methods = new Set(["get", "put", "post", "delete", "options", "head", "patch", "trace"]);
|
|
128
|
-
const paths = Object.fromEntries(Object.entries(document.paths).flatMap(([path, item]) => {
|
|
129
|
-
if (!isRecord(item))
|
|
130
|
-
return [[path, item]];
|
|
131
|
-
const entries = Object.entries(item);
|
|
132
|
-
const kept = entries.filter(([method, operation]) => {
|
|
133
|
-
if (!methods.has(method) || !isRecord(operation))
|
|
134
|
-
return true;
|
|
135
|
-
const metadata = operation["x-relkit"];
|
|
136
|
-
return (!isRecord(metadata) ||
|
|
137
|
-
typeof metadata.serviceId !== "string" ||
|
|
138
|
-
!domains.has(metadata.serviceId));
|
|
139
|
-
});
|
|
140
|
-
if (kept.length < entries.length && !kept.some(([method]) => methods.has(method)))
|
|
141
|
-
return [];
|
|
142
|
-
return [[path, Object.fromEntries(kept)]];
|
|
143
|
-
}));
|
|
144
|
-
const usedTags = new Set(Object.values(paths).flatMap((item) => !isRecord(item)
|
|
145
|
-
? []
|
|
146
|
-
: Object.entries(item).flatMap(([method, operation]) => methods.has(method) && isRecord(operation) && Array.isArray(operation.tags)
|
|
147
|
-
? operation.tags
|
|
148
|
-
: [])));
|
|
149
|
-
return {
|
|
150
|
-
...document,
|
|
151
|
-
paths,
|
|
152
|
-
...(Array.isArray(document.tags)
|
|
153
|
-
? { tags: document.tags.filter((tag) => isRecord(tag) && usedTags.has(tag.name)) }
|
|
154
|
-
: {}),
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
/** Recognizes a non-null object before reading its named properties.
|
|
158
|
-
* @param value - Value inspected, validated or projected by this operation.
|
|
159
|
-
* @returns Whether the inspected value satisfies the declared type guard.
|
|
160
|
-
*/
|
|
161
|
-
function isRecord(value) {
|
|
162
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
163
|
-
}
|
|
164
125
|
//# sourceMappingURL=api-docs.js.map
|
package/dist/api-docs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-docs.js","sourceRoot":"","sources":["../src/api-docs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,WAAW,EACX,
|
|
1
|
+
{"version":3,"file":"api-docs.js","sourceRoot":"","sources":["../src/api-docs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,aAAa,EACb,WAAW,EACX,eAAe,EACf,aAAa,GAEd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAI3E,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,aAAa,eAAwB,CAAC;AACrE,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,aAAa,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C,uEAAuE,CACxE,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS,IAAI,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC3E,MAAM,IAAI,yBAAyB,CAAC,gCAAgC,CAAC,CAAC;IACxE,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,eAAe,CAAC,WAAmB;IAC1C,OAAO;QACL,eAAe,EAAE,UAAU;QAC3B,cAAc,EAAE,WAAW;QAC3B,sBAAsB,EAAE,MAAM,CAAC,WAAW,CAAC;KAC5C,CAAC;AACJ,CAAC"}
|
package/dist/api-docs.types.d.ts
CHANGED
|
@@ -10,5 +10,7 @@ export interface ApiDocsOptions {
|
|
|
10
10
|
readonly bearerToken?: string;
|
|
11
11
|
readonly authorize?: InternalEndpointOptions["authorize"];
|
|
12
12
|
readonly document?: OpenApiDocument | JsonValue;
|
|
13
|
+
/** Native authentication schema, acquired only for authorized documentation requests. */
|
|
14
|
+
readonly getAuthDocument?: () => Promise<JsonValue>;
|
|
13
15
|
}
|
|
14
16
|
//# sourceMappingURL=api-docs.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-docs.types.d.ts","sourceRoot":"","sources":["../src/api-docs.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAE7F,+EAA+E;AAC/E,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,oBAAoB,CAAC;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IACvC,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,uBAAuB,CAAC,WAAW,CAAC,CAAC;IAC1D,QAAQ,CAAC,QAAQ,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"api-docs.types.d.ts","sourceRoot":"","sources":["../src/api-docs.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAE7F,+EAA+E;AAC/E,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,oBAAoB,CAAC;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IACvC,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,uBAAuB,CAAC,WAAW,CAAC,CAAC;IAC1D,QAAQ,CAAC,QAAQ,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;IAChD,yFAAyF;IACzF,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;CACrD"}
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACh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B,MAAM,EAAE,4BAA4B,CAAC,YAAY,CAAC,0CAgBnD;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,GAAG,eAAe,CAiC5F;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI,CAoBzF"}
|
package/dist/auth.js
CHANGED
|
@@ -31,6 +31,11 @@ export function createHttpAuthRuntime(options) {
|
|
|
31
31
|
return Object.freeze({
|
|
32
32
|
protected: Object.freeze([...options.protected]),
|
|
33
33
|
publicPaths: Object.freeze([...options.publicPaths]),
|
|
34
|
+
...(options.getOpenApiDocument === undefined
|
|
35
|
+
? {}
|
|
36
|
+
: {
|
|
37
|
+
getOpenApiDocument: options.getOpenApiDocument,
|
|
38
|
+
}),
|
|
34
39
|
/** Returns the stable authentication context owned by one native request.
|
|
35
40
|
* @param request - Native request whose headers, body and cancellation signal define this operation.
|
|
36
41
|
* @returns The existing request context or a new context sharing a lazily cached session lookup.
|
package/dist/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAOhD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAOzF;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,OAAO,EAK7C,CAAC,kCAAkC,CAAC;CAAG;AAE1C;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAgB,EAChB,MAAkD;IAElD,MAAM,IAAI,GAAG,YAAY,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACjE,kFAAkF;IAClF,I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;IAChF,CAAC;IACD,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,QAAQ,IAAI,CAAC,EAAE,CAAC;QAClB,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC3D,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;IACjF,CAAC;IACD,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,IAAI,SAAS,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;IAC9E,OAAO,IAAI,KAAK,OAAO,CAAC;AAC1B,CAAC"}
|
package/dist/auth.types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { JsonValue } from "@relkit/contracts";
|
|
1
2
|
/** Contract for http auth invocation used by auth. */
|
|
2
3
|
export interface HttpAuthInvocation {
|
|
3
4
|
readonly getSession: (options?: {
|
|
@@ -10,11 +11,13 @@ export interface HttpAuthRuntime {
|
|
|
10
11
|
readonly publicPaths: readonly string[];
|
|
11
12
|
readonly contextFor: (request: Request) => HttpAuthInvocation;
|
|
12
13
|
readonly protects: (path: string) => boolean;
|
|
14
|
+
readonly getOpenApiDocument?: () => Promise<JsonValue>;
|
|
13
15
|
}
|
|
14
16
|
/** create http auth runtime options configuring dependencies, callbacks and runtime policy. */
|
|
15
17
|
export interface CreateHttpAuthRuntimeOptions {
|
|
16
18
|
readonly protected: readonly string[];
|
|
17
19
|
readonly publicPaths: readonly string[];
|
|
18
20
|
readonly getSession: (headers: Headers) => Promise<unknown | null>;
|
|
21
|
+
readonly getOpenApiDocument?: () => Promise<JsonValue>;
|
|
19
22
|
}
|
|
20
23
|
//# sourceMappingURL=auth.types.d.ts.map
|
package/dist/auth.types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.types.d.ts","sourceRoot":"","sources":["../src/auth.types.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;CAC1F;AAED,mDAAmD;AACnD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,kBAAkB,CAAC;IAC9D,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.types.d.ts","sourceRoot":"","sources":["../src/auth.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,sDAAsD;AACtD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;CAC1F;AAED,mDAAmD;AACnD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,kBAAkB,CAAC;IAC9D,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAC7C,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;CACxD;AAED,+FAA+F;AAC/F,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IACnE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;CACxD"}
|
package/dist/create-app.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Constructs the canonical eager HTTP application. Shared REST setup lives in
|
|
3
|
+
* create-rest-app; this public factory adds the agent and RPC/MCP transports in
|
|
4
|
+
* their existing order and preserves synchronous configuration rejection.
|
|
5
|
+
*/
|
|
6
|
+
import type { Hono } from "hono";
|
|
7
|
+
import type { CreateAppOptions } from "./create-app.types.js";
|
|
3
8
|
export type { CreateAppOptions, FrameworkMiddlewareInput } from "./create-app.types.js";
|
|
9
|
+
export { installFrameworkMiddleware } from "./create-rest-app.js";
|
|
4
10
|
/** Creates the HTTP application from the already verified registration plan.
|
|
5
11
|
* @param options - Application dependencies and configuration for this domain.
|
|
6
12
|
* @returns The synchronously constructed Hono application; request work remains lazy.
|
|
7
13
|
*/
|
|
8
14
|
export declare function createApp(options: CreateAppOptions): Hono;
|
|
9
|
-
/** Installs supplied framework middleware in the fixed v3 order.
|
|
10
|
-
* @param app - Hono application receiving the configured endpoints or middleware.
|
|
11
|
-
* @param input - Submitted operation input; validation and authorization occur before effects are admitted.
|
|
12
|
-
* @returns Nothing; the requested update is applied to the owned state.
|
|
13
|
-
*/
|
|
14
|
-
export declare function installFrameworkMiddleware(app: Hono, input: FrameworkMiddlewareInput | undefined): void;
|
|
15
15
|
//# sourceMappingURL=create-app.d.ts.map
|
package/dist/create-app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-app.d.ts","sourceRoot":"","sources":["../src/create-app.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-app.d.ts","sourceRoot":"","sources":["../src/create-app.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAGjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAO9D,YAAY,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAElE;;;GAGG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAOzD"}
|
package/dist/create-app.js
CHANGED
|
@@ -1,103 +1,18 @@
|
|
|
1
|
-
import { Hono } from "hono";
|
|
2
1
|
import { installAgentInspectorEndpoints } from "./agent-inspector.js";
|
|
3
2
|
import { installAgentProtocolEndpoints } from "./agent-protocol.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { installHttpLogging } from "./http-logging.js";
|
|
8
|
-
import { graphSnapshot, installInternalEndpoints } from "./internal-endpoints.js";
|
|
9
|
-
import { assertHttpManifest, materializeRoutes } from "./materialize-routes.js";
|
|
10
|
-
import { createFrameworkMiddleware, FRAMEWORK_MIDDLEWARE_ORDER } from "./middleware.js";
|
|
11
|
-
import { installTransportSecurity } from "./transport-security.js";
|
|
3
|
+
import { createApplicationShell, installApplicationDocuments, routeOptions, } from "./create-rest-app.js";
|
|
4
|
+
import { materializeRoutes } from "./materialize-routes.js";
|
|
5
|
+
export { installFrameworkMiddleware } from "./create-rest-app.js";
|
|
12
6
|
/** Creates the HTTP application from the already verified registration plan.
|
|
13
7
|
* @param options - Application dependencies and configuration for this domain.
|
|
14
8
|
* @returns The synchronously constructed Hono application; request work remains lazy.
|
|
15
9
|
*/
|
|
16
10
|
export function createApp(options) {
|
|
17
|
-
|
|
18
|
-
const app = new Hono();
|
|
19
|
-
installHttpLogging(app, options);
|
|
20
|
-
const middlewareOptions = {
|
|
21
|
-
...(options.middleware ?? {}),
|
|
22
|
-
graphHash: options.plan.graphHash,
|
|
23
|
-
...(options.generationId === undefined ? {} : { generationId: options.generationId }),
|
|
24
|
-
...(options.observability === undefined ? {} : { observability: options.observability }),
|
|
25
|
-
};
|
|
26
|
-
installFrameworkMiddleware(app, options.frameworkMiddleware ?? createFrameworkMiddleware(middlewareOptions));
|
|
27
|
-
installTransportSecurity(app, options.transportSecurity);
|
|
28
|
-
installInternalEndpoints(app, {
|
|
29
|
-
graph: graphSnapshot(options.plan),
|
|
30
|
-
...(options.internalEndpoints ?? {}),
|
|
31
|
-
});
|
|
11
|
+
const app = createApplicationShell(options);
|
|
32
12
|
installAgentInspectorEndpoints(app, options, options.internalEndpoints ?? {});
|
|
33
|
-
|
|
34
|
-
installClientContractEndpoint(app, options.clientContract);
|
|
35
|
-
if (options.clientIdentity !== undefined) {
|
|
36
|
-
installClientIdentityEndpoint(app, options.clientIdentity, options.auth);
|
|
37
|
-
}
|
|
13
|
+
installApplicationDocuments(app, options);
|
|
38
14
|
installAgentProtocolEndpoints(app, options);
|
|
39
|
-
|
|
40
|
-
? options.requestMapping
|
|
41
|
-
: { maxBodyBytes: options.middleware.maxBodyBytes, ...(options.requestMapping ?? {}) };
|
|
42
|
-
materializeRoutes(app, {
|
|
43
|
-
...options,
|
|
44
|
-
...(requestMapping === undefined ? {} : { requestMapping }),
|
|
45
|
-
});
|
|
15
|
+
materializeRoutes(app, routeOptions(options));
|
|
46
16
|
return app;
|
|
47
17
|
}
|
|
48
|
-
/** Resolves API-document options from the application configuration.
|
|
49
|
-
* @param options - Application dependencies and configuration for this domain.
|
|
50
|
-
* @returns API-doc settings with explicit options overriding internal-endpoint defaults.
|
|
51
|
-
*/
|
|
52
|
-
function apiDocsOptions(options) {
|
|
53
|
-
const docs = options.apiDocs ?? {};
|
|
54
|
-
const internal = options.internalEndpoints ?? {};
|
|
55
|
-
return {
|
|
56
|
-
...docs,
|
|
57
|
-
mode: docs.mode ?? internal.environment ?? internal.mode ?? "development",
|
|
58
|
-
...(docs.bearerToken !== undefined
|
|
59
|
-
? { bearerToken: docs.bearerToken }
|
|
60
|
-
: internal.bearerToken === undefined
|
|
61
|
-
? {}
|
|
62
|
-
: { bearerToken: internal.bearerToken }),
|
|
63
|
-
...(docs.authorize !== undefined
|
|
64
|
-
? { authorize: docs.authorize }
|
|
65
|
-
: internal.authorize === undefined
|
|
66
|
-
? {}
|
|
67
|
-
: { authorize: internal.authorize }),
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
/** Installs supplied framework middleware in the fixed v3 order.
|
|
71
|
-
* @param app - Hono application receiving the configured endpoints or middleware.
|
|
72
|
-
* @param input - Submitted operation input; validation and authorization occur before effects are admitted.
|
|
73
|
-
* @returns Nothing; the requested update is applied to the owned state.
|
|
74
|
-
*/
|
|
75
|
-
export function installFrameworkMiddleware(app, input) {
|
|
76
|
-
if (input === undefined)
|
|
77
|
-
return;
|
|
78
|
-
const middleware = normalizeFrameworkMiddleware(input);
|
|
79
|
-
for (const name of FRAMEWORK_MIDDLEWARE_ORDER) {
|
|
80
|
-
const handler = middleware.get(name);
|
|
81
|
-
if (handler !== undefined)
|
|
82
|
-
app.use("*", handler);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
/** Normalizes optional middleware configuration into an ordered list.
|
|
86
|
-
* @param input - Submitted operation input; validation and authorization occur before effects are admitted.
|
|
87
|
-
* @returns A map of unique, recognized framework middleware names to their handlers.
|
|
88
|
-
*/
|
|
89
|
-
function normalizeFrameworkMiddleware(input) {
|
|
90
|
-
const result = new Map();
|
|
91
|
-
const entries = Array.isArray(input)
|
|
92
|
-
? input.map((item) => [item.name, item.handler])
|
|
93
|
-
: Object.entries(input);
|
|
94
|
-
for (const [name, handler] of entries) {
|
|
95
|
-
if (!FRAMEWORK_MIDDLEWARE_ORDER.includes(name))
|
|
96
|
-
throw new TypeError(`Unknown framework middleware "${String(name)}".`);
|
|
97
|
-
if (result.has(name))
|
|
98
|
-
throw new TypeError(`Duplicate framework middleware "${name}".`);
|
|
99
|
-
result.set(name, handler);
|
|
100
|
-
}
|
|
101
|
-
return result;
|
|
102
|
-
}
|
|
103
18
|
//# sourceMappingURL=create-app.js.map
|
package/dist/create-app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-app.js","sourceRoot":"","sources":["../src/create-app.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-app.js","sourceRoot":"","sources":["../src/create-app.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAEpE,OAAO,EACL,sBAAsB,EACtB,2BAA2B,EAC3B,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAElE;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,OAAyB;IACjD,MAAM,GAAG,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC5C,8BAA8B,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;IAC9E,2BAA2B,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1C,6BAA6B,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5C,iBAAiB,CAAC,GAAG,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9C,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shares eager HTTP policy between canonical and prepared applications. The shell
|
|
3
|
+
* validates the complete manifest and installs framework/security/control routes;
|
|
4
|
+
* REST construction adds documentation, client identity and declared routes without
|
|
5
|
+
* importing agent, RPC or MCP transport implementations. No resources are acquired.
|
|
6
|
+
*/
|
|
7
|
+
import { Hono } from "hono";
|
|
8
|
+
import type { CreateAppOptions, FrameworkMiddlewareInput } from "./create-app.types.js";
|
|
9
|
+
/** Constructs only eagerly required HTTP behavior.
|
|
10
|
+
* @param options - Complete checked cohort and runtime dependencies.
|
|
11
|
+
* @returns A REST application with canonical policy and no deferred transports.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createRestApp(options: CreateAppOptions): Hono;
|
|
14
|
+
/** Validates the cohort and installs policy in canonical order.
|
|
15
|
+
* @param options - Complete checked cohort and runtime dependencies.
|
|
16
|
+
* @returns A shell awaiting transport registration; malformed configuration throws.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createApplicationShell(options: CreateAppOptions): Hono;
|
|
19
|
+
/** Adds the canonical documentation and client endpoints.
|
|
20
|
+
* @param app - Shell whose policy is already installed.
|
|
21
|
+
* @param options - Validated runtime configuration.
|
|
22
|
+
* @returns Nothing; registers protected documents and client identity.
|
|
23
|
+
*/
|
|
24
|
+
export declare function installApplicationDocuments(app: Hono, options: CreateAppOptions): void;
|
|
25
|
+
/** Merges the framework body limit into route mapping.
|
|
26
|
+
* @param options - Complete application configuration.
|
|
27
|
+
* @returns Route options preserving an explicit mapping override.
|
|
28
|
+
*/
|
|
29
|
+
export declare function routeOptions(options: CreateAppOptions): CreateAppOptions;
|
|
30
|
+
/** Installs validated middleware in the fixed framework order.
|
|
31
|
+
* @param app - Shell receiving middleware before endpoint registration.
|
|
32
|
+
* @param input - User supplied overrides; missing input installs nothing.
|
|
33
|
+
* @returns Nothing; duplicate or unrecognized names throw before activation.
|
|
34
|
+
*/
|
|
35
|
+
export declare function installFrameworkMiddleware(app: Hono, input: FrameworkMiddlewareInput | undefined): void;
|
|
36
|
+
//# sourceMappingURL=create-rest-app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-rest-app.d.ts","sourceRoot":"","sources":["../src/create-rest-app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,IAAI,EAA0B,MAAM,MAAM,CAAC;AAIpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AASxF;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAM7D;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAoBtE;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAMtF;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,gBAAgB,CASxE;AA2BD;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,IAAI,EACT,KAAK,EAAE,wBAAwB,GAAG,SAAS,GAC1C,IAAI,CAON"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shares eager HTTP policy between canonical and prepared applications. The shell
|
|
3
|
+
* validates the complete manifest and installs framework/security/control routes;
|
|
4
|
+
* REST construction adds documentation, client identity and declared routes without
|
|
5
|
+
* importing agent, RPC or MCP transport implementations. No resources are acquired.
|
|
6
|
+
*/
|
|
7
|
+
import { Hono } from "hono";
|
|
8
|
+
import { installApiDocs } from "./api-docs.js";
|
|
9
|
+
import { installClientContractEndpoint } from "./client-contract.js";
|
|
10
|
+
import { installClientIdentityEndpoint } from "./client-identity.js";
|
|
11
|
+
import { installHttpLogging } from "./http-logging.js";
|
|
12
|
+
import { graphSnapshot, installInternalEndpoints } from "./internal-endpoints.js";
|
|
13
|
+
import { assertHttpManifest } from "./materialize-routes-validation.js";
|
|
14
|
+
import { materializeRestRoutes } from "./materialize-rest-routes.js";
|
|
15
|
+
import { createFrameworkMiddleware, FRAMEWORK_MIDDLEWARE_ORDER } from "./middleware.js";
|
|
16
|
+
import { installStaticFiles } from "./static-files.js";
|
|
17
|
+
import { installTransportSecurity } from "./transport-security.js";
|
|
18
|
+
/** Constructs only eagerly required HTTP behavior.
|
|
19
|
+
* @param options - Complete checked cohort and runtime dependencies.
|
|
20
|
+
* @returns A REST application with canonical policy and no deferred transports.
|
|
21
|
+
*/
|
|
22
|
+
export function createRestApp(options) {
|
|
23
|
+
const app = createApplicationShell(options);
|
|
24
|
+
installApplicationDocuments(app, options);
|
|
25
|
+
materializeRestRoutes(app, routeOptions(options));
|
|
26
|
+
installStaticFiles(app, options.staticFiles);
|
|
27
|
+
return app;
|
|
28
|
+
}
|
|
29
|
+
/** Validates the cohort and installs policy in canonical order.
|
|
30
|
+
* @param options - Complete checked cohort and runtime dependencies.
|
|
31
|
+
* @returns A shell awaiting transport registration; malformed configuration throws.
|
|
32
|
+
*/
|
|
33
|
+
export function createApplicationShell(options) {
|
|
34
|
+
assertHttpManifest(options);
|
|
35
|
+
const app = new Hono();
|
|
36
|
+
installHttpLogging(app, options);
|
|
37
|
+
const middlewareOptions = {
|
|
38
|
+
...(options.middleware ?? {}),
|
|
39
|
+
graphHash: options.plan.graphHash,
|
|
40
|
+
...(options.generationId === undefined ? {} : { generationId: options.generationId }),
|
|
41
|
+
...(options.observability === undefined ? {} : { observability: options.observability }),
|
|
42
|
+
};
|
|
43
|
+
installFrameworkMiddleware(app, options.frameworkMiddleware ?? createFrameworkMiddleware(middlewareOptions));
|
|
44
|
+
installTransportSecurity(app, options.transportSecurity);
|
|
45
|
+
installInternalEndpoints(app, {
|
|
46
|
+
graph: graphSnapshot(options.plan),
|
|
47
|
+
...(options.internalEndpoints ?? {}),
|
|
48
|
+
});
|
|
49
|
+
return app;
|
|
50
|
+
}
|
|
51
|
+
/** Adds the canonical documentation and client endpoints.
|
|
52
|
+
* @param app - Shell whose policy is already installed.
|
|
53
|
+
* @param options - Validated runtime configuration.
|
|
54
|
+
* @returns Nothing; registers protected documents and client identity.
|
|
55
|
+
*/
|
|
56
|
+
export function installApplicationDocuments(app, options) {
|
|
57
|
+
installApiDocs(app, options.plan, apiDocsOptions(options));
|
|
58
|
+
installClientContractEndpoint(app, options.clientContract);
|
|
59
|
+
if (options.clientIdentity !== undefined) {
|
|
60
|
+
installClientIdentityEndpoint(app, options.clientIdentity, options.auth);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** Merges the framework body limit into route mapping.
|
|
64
|
+
* @param options - Complete application configuration.
|
|
65
|
+
* @returns Route options preserving an explicit mapping override.
|
|
66
|
+
*/
|
|
67
|
+
export function routeOptions(options) {
|
|
68
|
+
if (options.middleware?.maxBodyBytes === undefined)
|
|
69
|
+
return options;
|
|
70
|
+
return {
|
|
71
|
+
...options,
|
|
72
|
+
requestMapping: {
|
|
73
|
+
maxBodyBytes: options.middleware.maxBodyBytes,
|
|
74
|
+
...(options.requestMapping ?? {}),
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** Resolves document protection from existing internal endpoint policy.
|
|
79
|
+
* @param options - Complete application configuration.
|
|
80
|
+
* @returns Document settings with explicit overrides taking precedence.
|
|
81
|
+
*/
|
|
82
|
+
function apiDocsOptions(options) {
|
|
83
|
+
const docs = options.apiDocs ?? {};
|
|
84
|
+
const internal = options.internalEndpoints ?? {};
|
|
85
|
+
const bearerToken = docs.bearerToken ?? internal.bearerToken;
|
|
86
|
+
const authorize = docs.authorize ?? internal.authorize;
|
|
87
|
+
return {
|
|
88
|
+
...docs,
|
|
89
|
+
...(docs.getAuthDocument !== undefined ||
|
|
90
|
+
options.auth?.getOpenApiDocument === undefined ||
|
|
91
|
+
options.plan.services?.some((service) => service.capability?.kind === "better-auth" && docs.excludeDomains?.includes(service.id))
|
|
92
|
+
? {}
|
|
93
|
+
: { getAuthDocument: options.auth.getOpenApiDocument }),
|
|
94
|
+
mode: docs.mode ?? internal.environment ?? internal.mode ?? "development",
|
|
95
|
+
...(bearerToken === undefined ? {} : { bearerToken }),
|
|
96
|
+
...(authorize === undefined ? {} : { authorize }),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** Installs validated middleware in the fixed framework order.
|
|
100
|
+
* @param app - Shell receiving middleware before endpoint registration.
|
|
101
|
+
* @param input - User supplied overrides; missing input installs nothing.
|
|
102
|
+
* @returns Nothing; duplicate or unrecognized names throw before activation.
|
|
103
|
+
*/
|
|
104
|
+
export function installFrameworkMiddleware(app, input) {
|
|
105
|
+
if (input === undefined)
|
|
106
|
+
return;
|
|
107
|
+
const middleware = normalizeFrameworkMiddleware(input);
|
|
108
|
+
for (const name of FRAMEWORK_MIDDLEWARE_ORDER) {
|
|
109
|
+
const handler = middleware.get(name);
|
|
110
|
+
if (handler !== undefined)
|
|
111
|
+
app.use("*", handler);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/** Validates names and preserves a single handler for each framework step.
|
|
115
|
+
* @param input - Array or keyed middleware declarations.
|
|
116
|
+
* @returns A validated lookup consumed in framework order.
|
|
117
|
+
*/
|
|
118
|
+
function normalizeFrameworkMiddleware(input) {
|
|
119
|
+
const result = new Map();
|
|
120
|
+
const entries = Array.isArray(input)
|
|
121
|
+
? input.map((item) => [item.name, item.handler])
|
|
122
|
+
: Object.entries(input);
|
|
123
|
+
for (const [name, handler] of entries) {
|
|
124
|
+
if (!FRAMEWORK_MIDDLEWARE_ORDER.some((expected) => expected === name)) {
|
|
125
|
+
throw new TypeError(`Unknown framework middleware "${name}".`);
|
|
126
|
+
}
|
|
127
|
+
if (result.has(name))
|
|
128
|
+
throw new TypeError(`Duplicate framework middleware "${name}".`);
|
|
129
|
+
result.set(name, handler);
|
|
130
|
+
}
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=create-rest-app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-rest-app.js","sourceRoot":"","sources":["../src/create-rest-app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,IAAI,EAA0B,MAAM,MAAM,CAAC;AACpD,OAAO,EAAE,cAAc,EAAuB,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AACxF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAEnE;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,OAAyB;IACrD,MAAM,GAAG,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC5C,2BAA2B,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1C,qBAAqB,CAAC,GAAG,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;IAClD,kBAAkB,CAAC,GAAG,EAAE,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AQ,KAAK,IAAI,CAAC,EAAE,CAAC;YACtE,MAAM,IAAI,SAAS,CAAC,iCAAiC,IAAI,IAAI,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,MAAM,IAAI,SAAS,CAAC,mCAAmC,IAAI,IAAI,CAAC,CAAC;QACvF,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Hono } from "hono";
|
|
2
|
+
import type { RouteMaterializationOptions } from "./materialize-routes.types.js";
|
|
3
|
+
/** Registers declared routes after validating the entire manifest.
|
|
4
|
+
* @param app - Shell with framework policy already installed.
|
|
5
|
+
* @param options - Validated cohort and invocation dependencies.
|
|
6
|
+
* @returns Nothing; registration has no asynchronous resource lifetime.
|
|
7
|
+
*/
|
|
8
|
+
export declare function materializeRestRoutes(app: Hono, options: RouteMaterializationOptions): void;
|
|
9
|
+
//# sourceMappingURL=materialize-rest-routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"materialize-rest-routes.d.ts","sourceRoot":"","sources":["../src/materialize-rest-routes.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAKjC,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAIjF;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,2BAA2B,GAAG,IAAI,CAwB3F"}
|