@lostgradient/backchannel 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +62 -2
- package/dist/access-policy-metadata.d.ts +92 -0
- package/dist/access-policy-metadata.js +87 -0
- package/dist/asyncapi-channels.d.ts +46 -0
- package/dist/asyncapi-channels.js +399 -0
- package/dist/asyncapi.d.ts +40 -0
- package/dist/asyncapi.js +165 -0
- package/dist/authentication/api-key.d.ts +4 -0
- package/dist/authentication/api-key.js +114 -0
- package/dist/authentication/audit.d.ts +115 -0
- package/dist/authentication/audit.js +75 -0
- package/dist/authentication/credential-verifiers.d.ts +60 -0
- package/dist/authentication/credential-verifiers.js +102 -0
- package/dist/authentication/crypto.d.ts +7 -0
- package/dist/authentication/crypto.js +140 -0
- package/dist/authentication/index.d.ts +80 -0
- package/dist/authentication/index.js +212 -0
- package/dist/authentication/rate-limiter.d.ts +133 -0
- package/dist/authentication/rate-limiter.js +124 -0
- package/dist/authentication/redaction.d.ts +72 -0
- package/dist/authentication/redaction.js +118 -0
- package/dist/authentication/rotating-api-key-store.d.ts +127 -0
- package/dist/authentication/rotating-api-key-store.js +126 -0
- package/dist/authentication/types.d.ts +337 -0
- package/dist/authentication/types.js +26 -0
- package/dist/authentication.d.ts +1 -0
- package/dist/authentication.js +1 -0
- package/dist/authorization-scope.d.ts +109 -0
- package/dist/authorization-scope.js +144 -0
- package/dist/authorization.d.ts +55 -0
- package/dist/authorization.js +134 -0
- package/dist/bind-feed-lifetime.d.ts +45 -0
- package/dist/bind-feed-lifetime.js +55 -0
- package/dist/byte-arrays.d.ts +5 -0
- package/dist/byte-arrays.js +9 -0
- package/dist/client/catalog-client.d.ts +285 -0
- package/dist/client/catalog-client.js +74 -0
- package/dist/client/in-process-transport.d.ts +19 -0
- package/dist/client/in-process-transport.js +136 -0
- package/dist/client/index.d.ts +14 -0
- package/dist/client/index.js +14 -0
- package/dist/client/json-rpc-http-transport.d.ts +118 -0
- package/dist/client/json-rpc-http-transport.js +127 -0
- package/dist/client/server-sent-event-parser.d.ts +55 -0
- package/dist/client/server-sent-event-parser.js +78 -0
- package/dist/client/sse-subscription-transport.d.ts +72 -0
- package/dist/client/sse-subscription-transport.js +224 -0
- package/dist/client/subscription-client.d.ts +122 -0
- package/dist/client/subscription-client.js +28 -0
- package/dist/connection-lease.d.ts +10 -0
- package/dist/connection-lease.js +8 -0
- package/dist/discovery-filter.d.ts +13 -0
- package/dist/discovery-filter.js +16 -0
- package/dist/discovery-info.d.ts +94 -0
- package/dist/discovery-info.js +38 -0
- package/dist/event-selector.d.ts +7 -0
- package/dist/event-selector.js +7 -0
- package/dist/fault-code.d.ts +84 -0
- package/dist/fault-code.js +114 -0
- package/dist/fault-remediation.d.ts +30 -0
- package/dist/fault-remediation.js +52 -0
- package/dist/fault-to-http.d.ts +11 -0
- package/dist/fault-to-http.js +13 -0
- package/dist/fault-to-json-rpc.d.ts +53 -0
- package/dist/fault-to-json-rpc.js +143 -0
- package/dist/fault-wire-safety.d.ts +45 -0
- package/dist/fault-wire-safety.js +72 -0
- package/dist/generator.d.ts +9 -0
- package/dist/generator.js +9 -0
- package/dist/handler/auth-context-principal.d.ts +37 -0
- package/dist/handler/auth-context-principal.js +67 -0
- package/dist/handler/authentication-responses.d.ts +23 -0
- package/dist/handler/authentication-responses.js +34 -0
- package/dist/handler/json-responses.d.ts +15 -0
- package/dist/handler/json-responses.js +32 -0
- package/dist/handler/operation-handler-authentication.d.ts +64 -0
- package/dist/handler/operation-handler-authentication.js +58 -0
- package/dist/handler/operation-handler-discovery.d.ts +29 -0
- package/dist/handler/operation-handler-discovery.js +55 -0
- package/dist/handler/operation-handler-mounts.d.ts +100 -0
- package/dist/handler/operation-handler-mounts.js +134 -0
- package/dist/handler/operation-handler-subscription.d.ts +34 -0
- package/dist/handler/operation-handler-subscription.js +112 -0
- package/dist/handler/operation-handler.d.ts +162 -0
- package/dist/handler/operation-handler.js +236 -0
- package/dist/handler/workspace-release.d.ts +6 -0
- package/dist/handler/workspace-release.js +75 -0
- package/dist/in-memory-replay-live-backend.d.ts +47 -0
- package/dist/in-memory-replay-live-backend.js +129 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +30 -0
- package/dist/internal/cryptography/encryption.d.ts +108 -0
- package/dist/internal/cryptography/encryption.js +241 -0
- package/dist/internal/cryptography/hash.d.ts +72 -0
- package/dist/internal/cryptography/hash.js +233 -0
- package/dist/internal/cryptography/index.d.ts +4 -0
- package/dist/internal/cryptography/index.js +2 -0
- package/dist/internals.d.ts +58 -0
- package/dist/internals.js +54 -0
- package/dist/json-rpc-dispatch.d.ts +88 -0
- package/dist/json-rpc-dispatch.js +154 -0
- package/dist/json-rpc-framing.d.ts +42 -0
- package/dist/json-rpc-framing.js +50 -0
- package/dist/json-rpc-http.d.ts +36 -0
- package/dist/json-rpc-http.js +191 -0
- package/dist/json-rpc-parse.d.ts +69 -0
- package/dist/json-rpc-parse.js +206 -0
- package/dist/json-rpc-protocol.d.ts +76 -0
- package/dist/json-rpc-protocol.js +54 -0
- package/dist/json-rpc-session-runtime.d.ts +55 -0
- package/dist/json-rpc-session-runtime.js +111 -0
- package/dist/json-rpc-websocket-subscription-pump.d.ts +9 -0
- package/dist/json-rpc-websocket-subscription-pump.js +46 -0
- package/dist/json-rpc-websocket-subscriptions.d.ts +10 -0
- package/dist/json-rpc-websocket-subscriptions.js +33 -0
- package/dist/json-rpc-websocket-types.d.ts +34 -0
- package/dist/json-rpc-websocket-types.js +1 -0
- package/dist/json-rpc-websocket-validation.d.ts +45 -0
- package/dist/json-rpc-websocket-validation.js +154 -0
- package/dist/json-rpc-websocket.d.ts +20 -0
- package/dist/json-rpc-websocket.js +363 -0
- package/dist/json-schema-utilities.d.ts +5 -0
- package/dist/json-schema-utilities.js +17 -0
- package/dist/mcp-discovery-names.d.ts +11 -0
- package/dist/mcp-discovery-names.js +11 -0
- package/dist/openapi-canonical-json.d.ts +10 -0
- package/dist/openapi-canonical-json.js +23 -0
- package/dist/openapi-error-responses.d.ts +15 -0
- package/dist/openapi-error-responses.js +104 -0
- package/dist/openapi-schemas.d.ts +17 -0
- package/dist/openapi-schemas.js +94 -0
- package/dist/openapi.d.ts +60 -0
- package/dist/openapi.js +351 -0
- package/dist/openrpc-document-schema.d.ts +255 -0
- package/dist/openrpc-document-schema.js +84 -0
- package/dist/openrpc-errors.d.ts +93 -0
- package/dist/openrpc-errors.js +134 -0
- package/dist/openrpc.d.ts +66 -0
- package/dist/openrpc.js +260 -0
- package/dist/operation-catalog/behavior-types.d.ts +34 -0
- package/dist/operation-catalog/behavior-types.js +1 -0
- package/dist/operation-catalog/behavior-validation.d.ts +3 -0
- package/dist/operation-catalog/behavior-validation.js +298 -0
- package/dist/operation-catalog/dispatch-allowlist.d.ts +4 -0
- package/dist/operation-catalog/dispatch-allowlist.js +7 -0
- package/dist/operation-catalog/dispatch-preparation.d.ts +24 -0
- package/dist/operation-catalog/dispatch-preparation.js +49 -0
- package/dist/operation-catalog/index.d.ts +19 -0
- package/dist/operation-catalog/index.js +17 -0
- package/dist/operation-catalog/operation-dispatch.d.ts +14 -0
- package/dist/operation-catalog/operation-dispatch.js +115 -0
- package/dist/operation-catalog/operation-interceptors.d.ts +15 -0
- package/dist/operation-catalog/operation-interceptors.js +1 -0
- package/dist/operation-catalog/operation-metadata.d.ts +5 -0
- package/dist/operation-catalog/operation-metadata.js +104 -0
- package/dist/operation-catalog/pipeline-helpers.d.ts +70 -0
- package/dist/operation-catalog/pipeline-helpers.js +242 -0
- package/dist/operation-catalog/pipeline-stages.d.ts +23 -0
- package/dist/operation-catalog/pipeline-stages.js +226 -0
- package/dist/operation-catalog/pipeline.d.ts +7 -0
- package/dist/operation-catalog/pipeline.js +33 -0
- package/dist/operation-catalog/registry.d.ts +17 -0
- package/dist/operation-catalog/registry.js +132 -0
- package/dist/operation-catalog/stream-pipeline.d.ts +37 -0
- package/dist/operation-catalog/stream-pipeline.js +129 -0
- package/dist/operation-catalog/subscription-lifecycle.d.ts +6 -0
- package/dist/operation-catalog/subscription-lifecycle.js +27 -0
- package/dist/operation-catalog/types.d.ts +392 -0
- package/dist/operation-catalog/types.js +40 -0
- package/dist/operation-catalog/universal-faults.d.ts +11 -0
- package/dist/operation-catalog/universal-faults.js +15 -0
- package/dist/operation-catalog-snapshot.d.ts +215 -0
- package/dist/operation-catalog-snapshot.js +128 -0
- package/dist/operation-catalog.d.ts +1 -0
- package/dist/operation-catalog.js +1 -0
- package/dist/operation-description-audit.d.ts +44 -0
- package/dist/operation-description-audit.js +90 -0
- package/dist/operation-fault-helpers.d.ts +21 -0
- package/dist/operation-fault-helpers.js +32 -0
- package/dist/operation-fault.d.ts +245 -0
- package/dist/operation-fault.js +235 -0
- package/dist/operation-registry.d.ts +46 -0
- package/dist/operation-registry.js +46 -0
- package/dist/operations/closable-iterable.d.ts +23 -0
- package/dist/operations/closable-iterable.js +51 -0
- package/dist/operations/get-principal.d.ts +106 -0
- package/dist/operations/get-principal.js +107 -0
- package/dist/operations/sse-stream.d.ts +67 -0
- package/dist/operations/sse-stream.js +264 -0
- package/dist/principal.d.ts +253 -0
- package/dist/principal.js +254 -0
- package/dist/replay-live-feed-internals.d.ts +47 -0
- package/dist/replay-live-feed-internals.js +215 -0
- package/dist/replay-live-feed-types.d.ts +66 -0
- package/dist/replay-live-feed-types.js +7 -0
- package/dist/replay-live-feed.d.ts +49 -0
- package/dist/replay-live-feed.js +126 -0
- package/dist/rest-binding.d.ts +215 -0
- package/dist/rest-binding.js +95 -0
- package/dist/rest-body.d.ts +17 -0
- package/dist/rest-body.js +95 -0
- package/dist/route-model.d.ts +305 -0
- package/dist/route-model.js +320 -0
- package/dist/runtime/cors.d.ts +161 -0
- package/dist/runtime/cors.js +265 -0
- package/dist/scripts/generate-operation-client.d.ts +186 -0
- package/dist/scripts/generate-operation-client.js +561 -0
- package/dist/scripts/operation-behaviors.d.ts +3 -0
- package/dist/scripts/operation-behaviors.js +16 -0
- package/dist/scripts/operation-client-aliases.d.ts +32 -0
- package/dist/scripts/operation-client-aliases.js +255 -0
- package/dist/scripts/operation-client-domains.d.ts +21 -0
- package/dist/scripts/operation-client-domains.js +74 -0
- package/dist/scripts/operation-client-schema.d.ts +46 -0
- package/dist/scripts/operation-client-schema.js +310 -0
- package/dist/scripts/operation-client-svelte.d.ts +3 -0
- package/dist/scripts/operation-client-svelte.js +61 -0
- package/dist/sequence-cursor.d.ts +46 -0
- package/dist/sequence-cursor.js +62 -0
- package/dist/sse-error-payload-schema.d.ts +12 -0
- package/dist/sse-error-payload-schema.js +33 -0
- package/dist/stdio-session.d.ts +71 -0
- package/dist/stdio-session.js +347 -0
- package/dist/zod-json-schema.d.ts +22 -0
- package/dist/zod-json-schema.js +49 -0
- package/package.json +38 -3
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI 3.1 document generator driven from the operation and direct-route
|
|
3
|
+
* models.
|
|
4
|
+
*
|
|
5
|
+
* Produces a JSON-serializable OpenAPI document for the REST-ish HTTP
|
|
6
|
+
* surface. Both `handleRequest()` and `serve()` expose this at
|
|
7
|
+
* `GET /openapi.json`. Every operation-catalog binding carries the canonical
|
|
8
|
+
* `x-weft-access` metadata and, when applicable,
|
|
9
|
+
* `x-weft-parameterizedAccess`; direct infrastructure routes do not.
|
|
10
|
+
*
|
|
11
|
+
* @module server/openapi
|
|
12
|
+
*/
|
|
13
|
+
import { type DiscoveryInfo } from "./discovery-info.js";
|
|
14
|
+
import { type OpenApiSchemaHelper } from "./openapi-schemas.js";
|
|
15
|
+
import type { OperationRegistry } from "./operation-catalog.js";
|
|
16
|
+
import type { RestBindingDescription } from "./rest-binding.js";
|
|
17
|
+
import { DIRECT_HTTP_ROUTES } from "./route-model.js";
|
|
18
|
+
/** The names of the security schemes an OpenAPI document declares. */
|
|
19
|
+
export type OpenApiSecuritySchemeName = 'bearerAuth' | 'apiKeyAuth';
|
|
20
|
+
/** Options for customizing the generated OpenAPI document. */
|
|
21
|
+
export type OpenApiOptions = {
|
|
22
|
+
/** API title. Defaults to `discoveryInfo.title`, then to `'API'`. */
|
|
23
|
+
title?: string;
|
|
24
|
+
/** API version. Defaults to `discoveryInfo.version`, then to `'0.0.0'`. */
|
|
25
|
+
version?: string;
|
|
26
|
+
/** Operator-supplied discovery metadata applied to the generated document. */
|
|
27
|
+
discoveryInfo?: DiscoveryInfo;
|
|
28
|
+
/** Operation registry used to emit operation-backed REST bindings. */
|
|
29
|
+
registry: OperationRegistry;
|
|
30
|
+
/**
|
|
31
|
+
* REST bindings used to emit OpenAPI path items. A server that overrides
|
|
32
|
+
* its binding set (e.g. for a restricted subset) passes the same set here
|
|
33
|
+
* so `/openapi.json` matches the live HTTP surface.
|
|
34
|
+
*/
|
|
35
|
+
restBindings: ReadonlyArray<RestBindingDescription>;
|
|
36
|
+
/** Server URL. When omitted, no `servers` array is included. */
|
|
37
|
+
serverUrl?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Security schemes the live server actually supports. When omitted,
|
|
40
|
+
* emit both current API-key scheme names so generated clients can choose
|
|
41
|
+
* either header-oriented convention.
|
|
42
|
+
*/
|
|
43
|
+
supportedSchemes?: ReadonlySet<OpenApiSecuritySchemeName>;
|
|
44
|
+
/** The direct routes the server serves, by handler. Defaults to all of them. */
|
|
45
|
+
directRoutes?: ReadonlyArray<(typeof DIRECT_HTTP_ROUTES)[number]['handler']>;
|
|
46
|
+
/**
|
|
47
|
+
* Paths answered without authentication; other direct routes inherit the
|
|
48
|
+
* document-level security. Defaults to the routes defined as public.
|
|
49
|
+
*/
|
|
50
|
+
publicPaths?: ReadonlySet<string>;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Emit REST bindings into the OpenAPI paths map. Exported for tests;
|
|
54
|
+
* `generateOpenApiDocument` is the production entry point.
|
|
55
|
+
*
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
export declare function emitBindings(paths: Record<string, Record<string, unknown>>, tagSet: Set<string>, bindings: ReadonlyArray<RestBindingDescription>, registry: OperationRegistry, schemaHelper?: OpenApiSchemaHelper): void;
|
|
59
|
+
/** Generates an OpenAPI document from a registry. */
|
|
60
|
+
export declare function generateOpenApiDocument(options: OpenApiOptions): Record<string, unknown>;
|
package/dist/openapi.js
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI 3.1 document generator driven from the operation and direct-route
|
|
3
|
+
* models.
|
|
4
|
+
*
|
|
5
|
+
* Produces a JSON-serializable OpenAPI document for the REST-ish HTTP
|
|
6
|
+
* surface. Both `handleRequest()` and `serve()` expose this at
|
|
7
|
+
* `GET /openapi.json`. Every operation-catalog binding carries the canonical
|
|
8
|
+
* `x-weft-access` metadata and, when applicable,
|
|
9
|
+
* `x-weft-parameterizedAccess`; direct infrastructure routes do not.
|
|
10
|
+
*
|
|
11
|
+
* @module server/openapi
|
|
12
|
+
*/
|
|
13
|
+
import { serializeAccessPolicy, serializeParameterizedAccess } from "./access-policy-metadata.js";
|
|
14
|
+
import { isDiscoverable } from "./discovery-filter.js";
|
|
15
|
+
import { applyDiscoveryInfo, resolveDocumentTitleAndVersion, } from "./discovery-info.js";
|
|
16
|
+
import { asPlainObject, compareStrings } from "./json-schema-utilities.js";
|
|
17
|
+
import { buildErrorResponses, ERROR_SCHEMA } from "./openapi-error-responses.js";
|
|
18
|
+
import { extractComponentsSchemas } from "./openapi-schemas.js";
|
|
19
|
+
import { DIRECT_HTTP_ROUTES, externalApiPath, toOpenApiPath, } from "./route-model.js";
|
|
20
|
+
import { zodToJsonSchema } from "./zod-json-schema.js";
|
|
21
|
+
const DEFAULT_SCHEMA_HELPER = {
|
|
22
|
+
components: {},
|
|
23
|
+
refFor() {
|
|
24
|
+
return undefined;
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const JSON_MEDIA_TYPE = 'application/json';
|
|
28
|
+
const OCTET_STREAM_MEDIA_TYPE = 'application/octet-stream';
|
|
29
|
+
/** Build path parameter metadata for an Express-style route pattern. */
|
|
30
|
+
function buildPathParameters(paramNames) {
|
|
31
|
+
return paramNames.map((name) => ({
|
|
32
|
+
name,
|
|
33
|
+
in: 'path',
|
|
34
|
+
required: true,
|
|
35
|
+
schema: { type: name === 'step' ? 'integer' : 'string' },
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
function inputSourceEntries(binding) {
|
|
39
|
+
return Object.entries(binding.inputSources)
|
|
40
|
+
.filter((entry) => entry[1] !== undefined)
|
|
41
|
+
.toSorted(([left], [right]) => compareStrings(left, right));
|
|
42
|
+
}
|
|
43
|
+
function inputJsonSchema(operation) {
|
|
44
|
+
return zodToJsonSchema(operation.inputSchema);
|
|
45
|
+
}
|
|
46
|
+
function fieldSchema(operation, field) {
|
|
47
|
+
const properties = asPlainObject(inputJsonSchema(operation)['properties']);
|
|
48
|
+
return asPlainObject(Object.hasOwn(properties, field) ? properties[field] : undefined);
|
|
49
|
+
}
|
|
50
|
+
function requiredInputFields(operation) {
|
|
51
|
+
const required = inputJsonSchema(operation)['required'];
|
|
52
|
+
if (!Array.isArray(required))
|
|
53
|
+
return new Set();
|
|
54
|
+
return new Set(required.filter((entry) => typeof entry === 'string'));
|
|
55
|
+
}
|
|
56
|
+
function binaryBodySchema() {
|
|
57
|
+
return { type: 'string', format: 'binary' };
|
|
58
|
+
}
|
|
59
|
+
function streamingResponseSchema(mediaType) {
|
|
60
|
+
if (mediaType === OCTET_STREAM_MEDIA_TYPE)
|
|
61
|
+
return binaryBodySchema();
|
|
62
|
+
return { type: 'string' };
|
|
63
|
+
}
|
|
64
|
+
function directRouteContentSchema(content) {
|
|
65
|
+
if (content.schema === 'string')
|
|
66
|
+
return { type: 'string' };
|
|
67
|
+
return { type: 'object' };
|
|
68
|
+
}
|
|
69
|
+
function outputCanBeNull(operation) {
|
|
70
|
+
try {
|
|
71
|
+
return operation.outputSchema.safeParse(null).success;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function buildBindingParameters(binding, operation) {
|
|
78
|
+
const parameters = buildPathParameters(binding.pathParamNames);
|
|
79
|
+
const seen = new Set(parameters.map((parameter) => `${String(parameter['in'])}:${String(parameter['name'])}`));
|
|
80
|
+
for (const [field, source] of inputSourceEntries(binding)) {
|
|
81
|
+
if (source.kind !== 'query' && source.kind !== 'header')
|
|
82
|
+
continue;
|
|
83
|
+
const parameter = {
|
|
84
|
+
name: source.kind === 'query' ? source.queryParam : source.headerName,
|
|
85
|
+
in: source.kind,
|
|
86
|
+
required: false,
|
|
87
|
+
schema: fieldSchema(operation, field),
|
|
88
|
+
};
|
|
89
|
+
const key = `${parameter.in}:${parameter.name}`;
|
|
90
|
+
if (seen.has(key))
|
|
91
|
+
continue;
|
|
92
|
+
parameters.push(parameter);
|
|
93
|
+
seen.add(key);
|
|
94
|
+
}
|
|
95
|
+
return parameters;
|
|
96
|
+
}
|
|
97
|
+
function buildRequestBodyFromInputSources(binding, operation) {
|
|
98
|
+
const entries = inputSourceEntries(binding);
|
|
99
|
+
const bodyEntry = entries.find((entry) => entry[1].kind === 'body');
|
|
100
|
+
if (bodyEntry !== undefined) {
|
|
101
|
+
const [field, source] = bodyEntry;
|
|
102
|
+
if (source.kind !== 'body')
|
|
103
|
+
return undefined;
|
|
104
|
+
const mediaType = source.mediaType ?? JSON_MEDIA_TYPE;
|
|
105
|
+
const schema = mediaType === OCTET_STREAM_MEDIA_TYPE ? binaryBodySchema() : fieldSchema(operation, field);
|
|
106
|
+
return {
|
|
107
|
+
required: true,
|
|
108
|
+
content: { [mediaType]: { schema } },
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
const bodyFieldEntries = entries.filter((entry) => entry[1].kind === 'body-field');
|
|
112
|
+
if (bodyFieldEntries.length === 0)
|
|
113
|
+
return undefined;
|
|
114
|
+
const requiredFields = requiredInputFields(operation);
|
|
115
|
+
const properties = {};
|
|
116
|
+
const required = [];
|
|
117
|
+
for (const [field, source] of bodyFieldEntries) {
|
|
118
|
+
properties[source.bodyField] = fieldSchema(operation, field);
|
|
119
|
+
if (requiredFields.has(field))
|
|
120
|
+
required.push(source.bodyField);
|
|
121
|
+
}
|
|
122
|
+
const schema = {
|
|
123
|
+
type: 'object',
|
|
124
|
+
properties,
|
|
125
|
+
additionalProperties: operation.unknownKeyPolicy.http !== 'reject',
|
|
126
|
+
};
|
|
127
|
+
if (required.length > 0)
|
|
128
|
+
schema['required'] = required.toSorted(compareStrings);
|
|
129
|
+
return {
|
|
130
|
+
required: true,
|
|
131
|
+
content: { [JSON_MEDIA_TYPE]: { schema } },
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function buildRequestBody(binding, operation, schemaHelper) {
|
|
135
|
+
const requestBody = buildRequestBodyFromInputSources(binding, operation);
|
|
136
|
+
if (requestBody !== undefined)
|
|
137
|
+
return requestBody;
|
|
138
|
+
if (inputSourceEntries(binding).length > 0)
|
|
139
|
+
return undefined;
|
|
140
|
+
if (binding.method !== 'POST' && binding.method !== 'PUT' && binding.method !== 'PATCH') {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
content: {
|
|
145
|
+
[JSON_MEDIA_TYPE]: {
|
|
146
|
+
schema: schemaHelper.refFor(operation.name, 'Input') ?? { type: 'object' },
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Build the success-response object for a binding, branching on its
|
|
153
|
+
* declared `success.kind`. JSON bindings emit `application/json` with
|
|
154
|
+
* the operation's output schema. Streaming bindings emit the binding's
|
|
155
|
+
* declared `mediaType` and document the payload as either binary or a
|
|
156
|
+
* string. Empty (204) bindings emit a no-content response.
|
|
157
|
+
*/
|
|
158
|
+
function buildSuccessResponse(binding, operation, schemaHelper) {
|
|
159
|
+
const success = binding.success;
|
|
160
|
+
if (success.kind === 'empty') {
|
|
161
|
+
return {
|
|
162
|
+
[String(success.status)]: {
|
|
163
|
+
description: 'No content',
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
if (success.kind === 'streaming') {
|
|
168
|
+
const responses = {
|
|
169
|
+
'200': {
|
|
170
|
+
description: 'Streaming response',
|
|
171
|
+
content: {
|
|
172
|
+
[success.mediaType]: {
|
|
173
|
+
schema: streamingResponseSchema(success.mediaType),
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
if (success.mediaType === OCTET_STREAM_MEDIA_TYPE && outputCanBeNull(operation)) {
|
|
179
|
+
responses['404'] = { description: 'Storage key not found' };
|
|
180
|
+
}
|
|
181
|
+
return responses;
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
[String(success.status)]: {
|
|
185
|
+
description: 'Successful response',
|
|
186
|
+
content: {
|
|
187
|
+
[JSON_MEDIA_TYPE]: {
|
|
188
|
+
schema: schemaHelper.refFor(operation.name, 'Output') ?? { type: 'object' },
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Emit REST bindings into the OpenAPI paths map. Exported for tests;
|
|
196
|
+
* `generateOpenApiDocument` is the production entry point.
|
|
197
|
+
*
|
|
198
|
+
* @internal
|
|
199
|
+
*/
|
|
200
|
+
export function emitBindings(paths, tagSet, bindings, registry, schemaHelper = DEFAULT_SCHEMA_HELPER) {
|
|
201
|
+
for (const binding of bindings) {
|
|
202
|
+
tryRegisterBinding(paths, tagSet, binding, registry, schemaHelper);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function tryRegisterBinding(paths, tagSet, binding, registry, schemaHelper) {
|
|
206
|
+
const operation = registry.get(binding.operationName);
|
|
207
|
+
if (operation === undefined)
|
|
208
|
+
return;
|
|
209
|
+
if (!isDiscoverable(operation))
|
|
210
|
+
return;
|
|
211
|
+
// Operation-backed REST endpoints are served under the external `/api`
|
|
212
|
+
// prefix; direct routes (health/metrics/spec/well-known) stay at the origin
|
|
213
|
+
// root and are emitted unprefixed by `emitDirectRoutes`.
|
|
214
|
+
const openApiPath = externalApiPath(toOpenApiPath(binding.path));
|
|
215
|
+
if (!paths[openApiPath])
|
|
216
|
+
paths[openApiPath] = {};
|
|
217
|
+
paths[openApiPath][binding.method.toLowerCase()] = buildBindingEntry(binding, operation, schemaHelper);
|
|
218
|
+
for (const tag of operation.tags)
|
|
219
|
+
tagSet.add(tag);
|
|
220
|
+
}
|
|
221
|
+
function buildBindingEntry(binding, operation, schemaHelper) {
|
|
222
|
+
const parameters = buildBindingParameters(binding, operation);
|
|
223
|
+
const successResponse = buildSuccessResponse(binding, operation, schemaHelper);
|
|
224
|
+
const entry = {
|
|
225
|
+
summary: operation.summary,
|
|
226
|
+
operationId: operation.name,
|
|
227
|
+
tags: operation.tags,
|
|
228
|
+
'x-weft-access': serializeAccessPolicy(operation.access),
|
|
229
|
+
responses: {
|
|
230
|
+
...successResponse,
|
|
231
|
+
...buildErrorResponses(operation),
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
if (operation.parameterizedAccess !== undefined) {
|
|
235
|
+
entry['x-weft-parameterizedAccess'] = serializeParameterizedAccess(operation.parameterizedAccess);
|
|
236
|
+
}
|
|
237
|
+
if (operation.description !== undefined)
|
|
238
|
+
entry['description'] = operation.description;
|
|
239
|
+
if (parameters.length > 0)
|
|
240
|
+
entry['parameters'] = parameters;
|
|
241
|
+
const requestBody = buildRequestBody(binding, operation, schemaHelper);
|
|
242
|
+
if (requestBody !== undefined)
|
|
243
|
+
entry['requestBody'] = requestBody;
|
|
244
|
+
return entry;
|
|
245
|
+
}
|
|
246
|
+
function buildDirectRouteResponses(route) {
|
|
247
|
+
const responses = {};
|
|
248
|
+
for (const routeResponse of route.responses) {
|
|
249
|
+
const response = {
|
|
250
|
+
description: routeResponse.description,
|
|
251
|
+
};
|
|
252
|
+
if (routeResponse.content !== undefined) {
|
|
253
|
+
const content = {};
|
|
254
|
+
for (const contentVariant of routeResponse.content) {
|
|
255
|
+
content[contentVariant.mediaType] = {
|
|
256
|
+
schema: directRouteContentSchema(contentVariant),
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
response['content'] = content;
|
|
260
|
+
}
|
|
261
|
+
responses[String(routeResponse.status)] = response;
|
|
262
|
+
}
|
|
263
|
+
return responses;
|
|
264
|
+
}
|
|
265
|
+
function buildDirectRouteSecurity(route, publicPaths) {
|
|
266
|
+
return (publicPaths?.has(route.path) ?? route.access === 'public') ? [] : undefined;
|
|
267
|
+
}
|
|
268
|
+
function emitDirectRoutes(paths, tagSet, served, publicPaths) {
|
|
269
|
+
for (const route of DIRECT_HTTP_ROUTES) {
|
|
270
|
+
if (served !== undefined && !served.includes(route.handler))
|
|
271
|
+
continue;
|
|
272
|
+
const openApiPath = toOpenApiPath(route.path);
|
|
273
|
+
if (!paths[openApiPath])
|
|
274
|
+
paths[openApiPath] = {};
|
|
275
|
+
const parameters = buildPathParameters(route.paramNames);
|
|
276
|
+
const entry = {
|
|
277
|
+
summary: route.summary,
|
|
278
|
+
operationId: route.handler,
|
|
279
|
+
tags: route.tags,
|
|
280
|
+
responses: buildDirectRouteResponses(route),
|
|
281
|
+
};
|
|
282
|
+
const security = buildDirectRouteSecurity(route, publicPaths);
|
|
283
|
+
if (security !== undefined)
|
|
284
|
+
entry['security'] = security;
|
|
285
|
+
if (parameters.length > 0)
|
|
286
|
+
entry['parameters'] = parameters;
|
|
287
|
+
paths[openApiPath][route.method.toLowerCase()] = entry;
|
|
288
|
+
for (const tag of route.tags)
|
|
289
|
+
tagSet.add(tag);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/** Generates an OpenAPI document from a registry. */
|
|
293
|
+
export function generateOpenApiDocument(options) {
|
|
294
|
+
const infoBlock = applyDiscoveryInfo(resolveDocumentTitleAndVersion(options, options.discoveryInfo), options.discoveryInfo);
|
|
295
|
+
const registry = options.registry;
|
|
296
|
+
const schemaHelper = extractComponentsSchemas(registry);
|
|
297
|
+
const { paths, tags } = buildOpenApiPaths(options, registry, schemaHelper);
|
|
298
|
+
const { security, securitySchemes } = buildSecurityBlock(options.supportedSchemes);
|
|
299
|
+
const document = {
|
|
300
|
+
openapi: '3.1.0',
|
|
301
|
+
info: infoBlock,
|
|
302
|
+
paths,
|
|
303
|
+
tags,
|
|
304
|
+
security,
|
|
305
|
+
components: {
|
|
306
|
+
schemas: {
|
|
307
|
+
...schemaHelper.components,
|
|
308
|
+
Error: ERROR_SCHEMA,
|
|
309
|
+
},
|
|
310
|
+
securitySchemes,
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
applyOpenApiExtras(document, options);
|
|
314
|
+
return document;
|
|
315
|
+
}
|
|
316
|
+
function buildOpenApiPaths(options, registry, schemaHelper) {
|
|
317
|
+
const paths = {};
|
|
318
|
+
const tagSet = new Set();
|
|
319
|
+
emitBindings(paths, tagSet, options.restBindings, registry, schemaHelper);
|
|
320
|
+
// Direct routes are reserved infrastructure endpoints, so they are emitted
|
|
321
|
+
// after bindings and overwrite any conflicting user binding documentation.
|
|
322
|
+
emitDirectRoutes(paths, tagSet, options.directRoutes, options.publicPaths);
|
|
323
|
+
const tags = [...tagSet].toSorted().map((name) => ({ name }));
|
|
324
|
+
return { paths, tags };
|
|
325
|
+
}
|
|
326
|
+
const SECURITY_SCHEME_DEFINITIONS = {
|
|
327
|
+
bearerAuth: {
|
|
328
|
+
type: 'http',
|
|
329
|
+
scheme: 'bearer',
|
|
330
|
+
bearerFormat: 'JWT',
|
|
331
|
+
},
|
|
332
|
+
apiKeyAuth: {
|
|
333
|
+
type: 'apiKey',
|
|
334
|
+
in: 'header',
|
|
335
|
+
name: 'x-api-key',
|
|
336
|
+
},
|
|
337
|
+
};
|
|
338
|
+
function buildSecurityBlock(supportedSchemes) {
|
|
339
|
+
const schemes = supportedSchemes ?? new Set(['bearerAuth', 'apiKeyAuth']);
|
|
340
|
+
const security = [...schemes].map((schemeName) => ({ [schemeName]: [] }));
|
|
341
|
+
const securitySchemes = Object.fromEntries([...schemes].map((schemeName) => [schemeName, SECURITY_SCHEME_DEFINITIONS[schemeName]]));
|
|
342
|
+
return { security, securitySchemes };
|
|
343
|
+
}
|
|
344
|
+
function applyOpenApiExtras(document, options) {
|
|
345
|
+
if (options.serverUrl) {
|
|
346
|
+
document['servers'] = [{ url: options.serverUrl }];
|
|
347
|
+
}
|
|
348
|
+
if (options.discoveryInfo?.externalDocs !== undefined) {
|
|
349
|
+
document['externalDocs'] = { ...options.discoveryInfo.externalDocs };
|
|
350
|
+
}
|
|
351
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal committed Zod schema for the OpenRPC document shape that Weft emits.
|
|
3
|
+
*
|
|
4
|
+
* @module server/openrpc-document-schema
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
export declare const ContentDescriptorSchema: z.ZodObject<{
|
|
8
|
+
name: z.ZodString;
|
|
9
|
+
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
10
|
+
required: z.ZodBoolean;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
export declare const OpenRpcMethodSchema: z.ZodObject<{
|
|
13
|
+
name: z.ZodString;
|
|
14
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
15
|
+
description: z.ZodOptional<z.ZodString>;
|
|
16
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
17
|
+
name: z.ZodString;
|
|
18
|
+
}, z.core.$strict>>>;
|
|
19
|
+
paramStructure: z.ZodLiteral<"by-name">;
|
|
20
|
+
params: z.ZodArray<z.ZodObject<{
|
|
21
|
+
name: z.ZodString;
|
|
22
|
+
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
23
|
+
required: z.ZodBoolean;
|
|
24
|
+
}, z.core.$strict>>;
|
|
25
|
+
result: z.ZodObject<{
|
|
26
|
+
name: z.ZodString;
|
|
27
|
+
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
28
|
+
required: z.ZodBoolean;
|
|
29
|
+
}, z.core.$strict>;
|
|
30
|
+
errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
31
|
+
$ref: z.ZodString;
|
|
32
|
+
}, z.core.$strict>>>;
|
|
33
|
+
'x-weft-paramsSchema': z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
34
|
+
'x-weft-access': z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
35
|
+
kind: z.ZodLiteral<"public">;
|
|
36
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
37
|
+
kind: z.ZodLiteral<"authenticated">;
|
|
38
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
39
|
+
kind: z.ZodLiteral<"scoped">;
|
|
40
|
+
scopes: z.ZodObject<{
|
|
41
|
+
kind: z.ZodEnum<{
|
|
42
|
+
anyOf: "anyOf";
|
|
43
|
+
allOf: "allOf";
|
|
44
|
+
}>;
|
|
45
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
46
|
+
}, z.core.$strict>;
|
|
47
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
48
|
+
kind: z.ZodLiteral<"optionalAuth">;
|
|
49
|
+
authenticatedScopes: z.ZodObject<{
|
|
50
|
+
kind: z.ZodEnum<{
|
|
51
|
+
anyOf: "anyOf";
|
|
52
|
+
allOf: "allOf";
|
|
53
|
+
}>;
|
|
54
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
55
|
+
}, z.core.$strict>;
|
|
56
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
57
|
+
kind: z.ZodLiteral<"scopedAlternatives">;
|
|
58
|
+
alternatives: z.ZodArray<z.ZodObject<{
|
|
59
|
+
kind: z.ZodEnum<{
|
|
60
|
+
anyOf: "anyOf";
|
|
61
|
+
allOf: "allOf";
|
|
62
|
+
}>;
|
|
63
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
64
|
+
}, z.core.$strict>>;
|
|
65
|
+
}, z.core.$strict>], "kind">;
|
|
66
|
+
'x-weft-mcp': z.ZodOptional<z.ZodObject<{
|
|
67
|
+
workflowType: z.ZodString;
|
|
68
|
+
toolName: z.ZodString;
|
|
69
|
+
toolDiscovery: z.ZodObject<{
|
|
70
|
+
method: z.ZodLiteral<"tools/list">;
|
|
71
|
+
source: z.ZodLiteral<"live">;
|
|
72
|
+
}, z.core.$strict>;
|
|
73
|
+
}, z.core.$strict>>;
|
|
74
|
+
'x-weft-parameterizedAccess': z.ZodOptional<z.ZodObject<{
|
|
75
|
+
discriminator: z.ZodString;
|
|
76
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
77
|
+
variants: z.ZodArray<z.ZodObject<{
|
|
78
|
+
value: z.ZodString;
|
|
79
|
+
access: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
80
|
+
kind: z.ZodLiteral<"public">;
|
|
81
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
82
|
+
kind: z.ZodLiteral<"authenticated">;
|
|
83
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
84
|
+
kind: z.ZodLiteral<"scoped">;
|
|
85
|
+
scopes: z.ZodObject<{
|
|
86
|
+
kind: z.ZodEnum<{
|
|
87
|
+
anyOf: "anyOf";
|
|
88
|
+
allOf: "allOf";
|
|
89
|
+
}>;
|
|
90
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
91
|
+
}, z.core.$strict>;
|
|
92
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
93
|
+
kind: z.ZodLiteral<"optionalAuth">;
|
|
94
|
+
authenticatedScopes: z.ZodObject<{
|
|
95
|
+
kind: z.ZodEnum<{
|
|
96
|
+
anyOf: "anyOf";
|
|
97
|
+
allOf: "allOf";
|
|
98
|
+
}>;
|
|
99
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
100
|
+
}, z.core.$strict>;
|
|
101
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
102
|
+
kind: z.ZodLiteral<"scopedAlternatives">;
|
|
103
|
+
alternatives: z.ZodArray<z.ZodObject<{
|
|
104
|
+
kind: z.ZodEnum<{
|
|
105
|
+
anyOf: "anyOf";
|
|
106
|
+
allOf: "allOf";
|
|
107
|
+
}>;
|
|
108
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
109
|
+
}, z.core.$strict>>;
|
|
110
|
+
}, z.core.$strict>], "kind">;
|
|
111
|
+
}, z.core.$strict>>;
|
|
112
|
+
}, z.core.$strict>>;
|
|
113
|
+
}, z.core.$strict>;
|
|
114
|
+
/** The Zod schema an OpenRPC document must satisfy. */
|
|
115
|
+
export declare const OpenRpcDocumentSchema: z.ZodObject<{
|
|
116
|
+
openrpc: z.ZodLiteral<"1.3.2">;
|
|
117
|
+
info: z.ZodObject<{
|
|
118
|
+
title: z.ZodString;
|
|
119
|
+
version: z.ZodString;
|
|
120
|
+
description: z.ZodOptional<z.ZodString>;
|
|
121
|
+
contact: z.ZodOptional<z.ZodObject<{
|
|
122
|
+
name: z.ZodOptional<z.ZodString>;
|
|
123
|
+
url: z.ZodOptional<z.ZodString>;
|
|
124
|
+
email: z.ZodOptional<z.ZodString>;
|
|
125
|
+
}, z.core.$strict>>;
|
|
126
|
+
license: z.ZodOptional<z.ZodObject<{
|
|
127
|
+
name: z.ZodString;
|
|
128
|
+
url: z.ZodOptional<z.ZodString>;
|
|
129
|
+
}, z.core.$strict>>;
|
|
130
|
+
externalDocs: z.ZodOptional<z.ZodObject<{
|
|
131
|
+
description: z.ZodOptional<z.ZodString>;
|
|
132
|
+
url: z.ZodString;
|
|
133
|
+
}, z.core.$strict>>;
|
|
134
|
+
}, z.core.$strict>;
|
|
135
|
+
methods: z.ZodArray<z.ZodObject<{
|
|
136
|
+
name: z.ZodString;
|
|
137
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
138
|
+
description: z.ZodOptional<z.ZodString>;
|
|
139
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
140
|
+
name: z.ZodString;
|
|
141
|
+
}, z.core.$strict>>>;
|
|
142
|
+
paramStructure: z.ZodLiteral<"by-name">;
|
|
143
|
+
params: z.ZodArray<z.ZodObject<{
|
|
144
|
+
name: z.ZodString;
|
|
145
|
+
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
146
|
+
required: z.ZodBoolean;
|
|
147
|
+
}, z.core.$strict>>;
|
|
148
|
+
result: z.ZodObject<{
|
|
149
|
+
name: z.ZodString;
|
|
150
|
+
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
151
|
+
required: z.ZodBoolean;
|
|
152
|
+
}, z.core.$strict>;
|
|
153
|
+
errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
154
|
+
$ref: z.ZodString;
|
|
155
|
+
}, z.core.$strict>>>;
|
|
156
|
+
'x-weft-paramsSchema': z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
157
|
+
'x-weft-access': z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
158
|
+
kind: z.ZodLiteral<"public">;
|
|
159
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
160
|
+
kind: z.ZodLiteral<"authenticated">;
|
|
161
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
162
|
+
kind: z.ZodLiteral<"scoped">;
|
|
163
|
+
scopes: z.ZodObject<{
|
|
164
|
+
kind: z.ZodEnum<{
|
|
165
|
+
anyOf: "anyOf";
|
|
166
|
+
allOf: "allOf";
|
|
167
|
+
}>;
|
|
168
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
169
|
+
}, z.core.$strict>;
|
|
170
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
171
|
+
kind: z.ZodLiteral<"optionalAuth">;
|
|
172
|
+
authenticatedScopes: z.ZodObject<{
|
|
173
|
+
kind: z.ZodEnum<{
|
|
174
|
+
anyOf: "anyOf";
|
|
175
|
+
allOf: "allOf";
|
|
176
|
+
}>;
|
|
177
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
178
|
+
}, z.core.$strict>;
|
|
179
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
180
|
+
kind: z.ZodLiteral<"scopedAlternatives">;
|
|
181
|
+
alternatives: z.ZodArray<z.ZodObject<{
|
|
182
|
+
kind: z.ZodEnum<{
|
|
183
|
+
anyOf: "anyOf";
|
|
184
|
+
allOf: "allOf";
|
|
185
|
+
}>;
|
|
186
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
187
|
+
}, z.core.$strict>>;
|
|
188
|
+
}, z.core.$strict>], "kind">;
|
|
189
|
+
'x-weft-mcp': z.ZodOptional<z.ZodObject<{
|
|
190
|
+
workflowType: z.ZodString;
|
|
191
|
+
toolName: z.ZodString;
|
|
192
|
+
toolDiscovery: z.ZodObject<{
|
|
193
|
+
method: z.ZodLiteral<"tools/list">;
|
|
194
|
+
source: z.ZodLiteral<"live">;
|
|
195
|
+
}, z.core.$strict>;
|
|
196
|
+
}, z.core.$strict>>;
|
|
197
|
+
'x-weft-parameterizedAccess': z.ZodOptional<z.ZodObject<{
|
|
198
|
+
discriminator: z.ZodString;
|
|
199
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
200
|
+
variants: z.ZodArray<z.ZodObject<{
|
|
201
|
+
value: z.ZodString;
|
|
202
|
+
access: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
203
|
+
kind: z.ZodLiteral<"public">;
|
|
204
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
205
|
+
kind: z.ZodLiteral<"authenticated">;
|
|
206
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
207
|
+
kind: z.ZodLiteral<"scoped">;
|
|
208
|
+
scopes: z.ZodObject<{
|
|
209
|
+
kind: z.ZodEnum<{
|
|
210
|
+
anyOf: "anyOf";
|
|
211
|
+
allOf: "allOf";
|
|
212
|
+
}>;
|
|
213
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
214
|
+
}, z.core.$strict>;
|
|
215
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
216
|
+
kind: z.ZodLiteral<"optionalAuth">;
|
|
217
|
+
authenticatedScopes: z.ZodObject<{
|
|
218
|
+
kind: z.ZodEnum<{
|
|
219
|
+
anyOf: "anyOf";
|
|
220
|
+
allOf: "allOf";
|
|
221
|
+
}>;
|
|
222
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
223
|
+
}, z.core.$strict>;
|
|
224
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
225
|
+
kind: z.ZodLiteral<"scopedAlternatives">;
|
|
226
|
+
alternatives: z.ZodArray<z.ZodObject<{
|
|
227
|
+
kind: z.ZodEnum<{
|
|
228
|
+
anyOf: "anyOf";
|
|
229
|
+
allOf: "allOf";
|
|
230
|
+
}>;
|
|
231
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
232
|
+
}, z.core.$strict>>;
|
|
233
|
+
}, z.core.$strict>], "kind">;
|
|
234
|
+
}, z.core.$strict>>;
|
|
235
|
+
}, z.core.$strict>>;
|
|
236
|
+
}, z.core.$strict>>;
|
|
237
|
+
components: z.ZodOptional<z.ZodObject<{
|
|
238
|
+
errors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
239
|
+
code: z.ZodNumber;
|
|
240
|
+
message: z.ZodString;
|
|
241
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
242
|
+
'x-http-status': z.ZodOptional<z.ZodNumber>;
|
|
243
|
+
}, z.core.$strict>>>;
|
|
244
|
+
schemas: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
245
|
+
}, z.core.$strict>>;
|
|
246
|
+
servers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
247
|
+
url: z.ZodString;
|
|
248
|
+
}, z.core.$strict>>>;
|
|
249
|
+
'x-weft-mcp': z.ZodOptional<z.ZodObject<{
|
|
250
|
+
discoveryPath: z.ZodLiteral<"/.well-known/mcp.json">;
|
|
251
|
+
toolDiscoveryMethod: z.ZodLiteral<"tools/list">;
|
|
252
|
+
toolNames: z.ZodArray<z.ZodString>;
|
|
253
|
+
}, z.core.$strict>>;
|
|
254
|
+
}, z.core.$strict>;
|
|
255
|
+
export type OpenRpcDocument = z.infer<typeof OpenRpcDocumentSchema>;
|