@voltro/plugin-openapi 0.69.1 → 0.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -2,6 +2,15 @@ import { ProcedureDescriptor } from '@voltro/protocol';
2
2
  import { RestRouteDescriptor } from '@voltro/protocol/rest';
3
3
  import { VoltroPlugin } from '@voltro/protocol';
4
4
 
5
+ /**
6
+ * A body derived from a wire JSON schema, deterministically — the same schema
7
+ * always derives the same body, so a generated collection's diff stays quiet.
8
+ * Not a substitute for an author's `publicApi.example`: it exists so an
9
+ * operation without one is not an empty body in Swagger UI and in every
10
+ * collection, and it is marked `x-voltro-example: derived` where it is used.
11
+ */
12
+ export declare const deriveExample: (schema: JsonObject, defs: Record<string, unknown>, depth?: number) => unknown;
13
+
5
14
  /**
6
15
  * Build the full OpenAPI 3.1 document from a list of REST descriptors and,
7
16
  * optionally, the rpc procedure descriptors.
@@ -11,7 +20,12 @@ import { VoltroPlugin } from '@voltro/protocol';
11
20
  */
12
21
  export declare function generateOpenApiSpec(routes: ReadonlyArray<RestRouteDescriptor<any, any>>, info?: OpenApiInfo): OpenApiDocument;
13
22
 
14
- export declare function generateOpenApiSpec(routes: ReadonlyArray<RestRouteDescriptor<any, any>>, info: OpenApiInfo, sources: OpenApiSources): OpenApiDocument;
23
+ export declare function generateOpenApiSpec(routes: ReadonlyArray<RestRouteDescriptor<any, any>>, info: OpenApiInfo, sources: OpenApiSources, options?: OpenApiGenerateOptions): OpenApiDocument;
24
+
25
+ declare type JsonObject = Record<string, unknown>;
26
+
27
+ /** Every version mounted, newest first (`v2` before `v1`). */
28
+ export declare const mountedVersions: (routes: ReadonlyArray<RestRouteDescriptor<any, any>>) => ReadonlyArray<string>;
15
29
 
16
30
  /** A minimal OpenAPI 3.1 document — the shape `generateOpenApiSpec` returns.
17
31
  * Deliberately narrow: it names the top-level keys a deployment reads (so the
@@ -24,18 +38,79 @@ export declare interface OpenApiDocument {
24
38
  readonly title: string;
25
39
  readonly version: string;
26
40
  readonly description?: string;
41
+ readonly contact?: OpenApiInfo['contact'];
42
+ readonly license?: OpenApiInfo['license'];
43
+ readonly termsOfService?: string;
44
+ readonly 'x-logo'?: OpenApiInfo['logo'];
27
45
  };
46
+ readonly servers?: ReadonlyArray<{
47
+ readonly url: string;
48
+ readonly description?: string;
49
+ readonly 'x-voltro-environment'?: string;
50
+ }>;
51
+ readonly externalDocs?: OpenApiExternalDocs;
52
+ readonly 'x-voltro-environment'?: string;
53
+ /** The digest of the projected surface — what a generated client was built
54
+ * from, and what `voltro check --public-api --against` compares. */
55
+ readonly 'x-voltro-surface-digest'?: string;
28
56
  readonly paths: Record<string, Record<string, unknown>>;
57
+ /** Every tag group an operation uses, with its description when one was given. */
58
+ readonly tags?: ReadonlyArray<{
59
+ readonly name: string;
60
+ readonly description?: string;
61
+ readonly externalDocs?: OpenApiExternalDocs;
62
+ }>;
29
63
  readonly components: {
30
64
  readonly schemas: Record<string, unknown>;
31
65
  readonly securitySchemes?: Record<string, unknown>;
32
66
  };
33
67
  }
34
68
 
69
+ export declare interface OpenApiExternalDocs {
70
+ readonly url: string;
71
+ readonly description?: string;
72
+ }
73
+
74
+ /** What the generator knows beyond the routes: a description per tag group
75
+ * (`teams` → "Teams and membership"), for the document's `tags[]`. */
76
+ export declare interface OpenApiGenerateOptions {
77
+ readonly tagDescriptions?: Readonly<Record<string, string>>;
78
+ /** A link per tag group — the handbook page of a domain — for `tags[].externalDocs`. */
79
+ readonly tagExternalDocs?: Readonly<Record<string, OpenApiExternalDocs>>;
80
+ /** The document's `externalDocs`. */
81
+ readonly externalDocs?: OpenApiExternalDocs;
82
+ /** The document's `servers` — the first entry is what a generated client
83
+ * and a collection take as the default base URL. */
84
+ readonly servers?: ReadonlyArray<OpenApiServer>;
85
+ /** The environment THIS instance serves (`x-voltro-environment` on the
86
+ * document): `dev`, `staging`, `production`, … */
87
+ readonly environment?: string;
88
+ }
89
+
35
90
  export declare interface OpenApiInfo {
36
91
  readonly title?: string;
37
92
  readonly version?: string;
38
93
  readonly description?: string;
94
+ /** The API team a consumer writes to — `info.contact`. */
95
+ readonly contact?: {
96
+ readonly name?: string;
97
+ readonly url?: string;
98
+ readonly email?: string;
99
+ };
100
+ /** `info.license`. */
101
+ readonly license?: {
102
+ readonly name: string;
103
+ readonly url?: string;
104
+ readonly identifier?: string;
105
+ };
106
+ /** `info.termsOfService` — a URL. */
107
+ readonly termsOfService?: string;
108
+ /** `x-logo` — what ReDoc renders at the top of the page. */
109
+ readonly logo?: {
110
+ readonly url: string;
111
+ readonly altText?: string;
112
+ readonly backgroundColor?: string;
113
+ };
39
114
  }
40
115
 
41
116
  export declare const openapiPlugin: (options: OpenApiPluginOptions) => VoltroPlugin;
@@ -54,6 +129,30 @@ export declare interface OpenApiPluginOptions {
54
129
  readonly procedures?: ReadonlyArray<ProcedureDescriptor>;
55
130
  /** Spec metadata. */
56
131
  readonly info?: OpenApiInfo;
132
+ /** A description per tag group (`teams` → 'Teams and membership'), for the
133
+ * document's `tags[]`. A group with no entry is listed by name. */
134
+ readonly tagDescriptions?: Readonly<Record<string, string>>;
135
+ /** A link per tag group — the handbook page of a domain — for
136
+ * `tags[].externalDocs`. */
137
+ readonly tagExternalDocs?: Readonly<Record<string, OpenApiExternalDocs>>;
138
+ /** The document's `externalDocs`. */
139
+ readonly externalDocs?: OpenApiExternalDocs;
140
+ /**
141
+ * Where the API is reachable — the document's `servers`. The first entry is
142
+ * the default base URL of a generated client and of a collection, and every
143
+ * entry becomes one environment file there. Omitted: one entry from
144
+ * `VOLTRO_PUBLIC_API_ORIGIN` when that is set (the public origin of THIS
145
+ * api — `VOLTRO_API_ORIGIN` is the web app's server-side route to it, and
146
+ * `VOLTRO_PUBLIC_URL` the storage plugin's), tagged with `environment`.
147
+ */
148
+ readonly servers?: ReadonlyArray<OpenApiServer>;
149
+ /**
150
+ * The environment this instance serves — `dev`, `staging`, `production` —
151
+ * written as `x-voltro-environment` on the document and on the default
152
+ * server entry. Default `VOLTRO_ENVIRONMENT`, else `production` under
153
+ * `NODE_ENV=production` and `dev` otherwise.
154
+ */
155
+ readonly environment?: string;
57
156
  /** Path to serve the JSON spec. Default `/openapi.json`. */
58
157
  readonly specPath?: string;
59
158
  /** Path to serve the Swagger-UI page. Default `/docs`. `false` disables it. */
@@ -74,6 +173,28 @@ export declare interface OpenApiPluginOptions {
74
173
  * `procedures` only.
75
174
  */
76
175
  readonly includeAppRoutes?: boolean;
176
+ /**
177
+ * Document the app's OWN rpc procedures — every query, mutation, action and
178
+ * stream discovery found, minus `internal` ones — without listing them in
179
+ * `procedures`. Default `false`: the spec stays REST-only unless asked. The
180
+ * framework hands the plugin the discovered descriptors
181
+ * (`onProcedureSurface`) once discovery has run, on both boot paths; one
182
+ * also passed in `procedures` is documented once. Importing the descriptor
183
+ * modules into `app.config.ts` to fill `procedures` evaluates every one of
184
+ * them before discovery on every load of the config — this option is the
185
+ * way around that.
186
+ */
187
+ readonly includeAppProcedures?: boolean;
188
+ }
189
+
190
+ /** One `servers[]` entry: where the API is reachable, and for which
191
+ * environment (`x-voltro-environment`), so a collection can write one
192
+ * environment file per entry. */
193
+ export declare interface OpenApiServer {
194
+ readonly url: string;
195
+ readonly description?: string;
196
+ /** `dev` | `staging` | `production` — free text; the entry's environment. */
197
+ readonly environment?: string;
77
198
  }
78
199
 
79
200
  /** Extra sources to fold into the spec beyond the REST `routes`. Today: the
@@ -85,6 +206,29 @@ export declare interface OpenApiSources {
85
206
  readonly procedures?: ReadonlyArray<ProcedureDescriptor>;
86
207
  }
87
208
 
88
- export declare const swaggerUiHtml: (specUrl: string, title?: string) => string;
209
+ /** RFC 9457 Problem Details — the error body of every projection under a
210
+ * `problem-details` profile. Published once; each typed error's response
211
+ * references it and names its `type`. */
212
+ export declare const PROBLEM_DETAILS_SCHEMA_NAME = "ProblemDetails";
213
+
214
+ /** One entry of Swagger UI's "Select a definition" dropdown. */
215
+ declare interface SwaggerUiDefinition {
216
+ readonly url: string;
217
+ readonly name: string;
218
+ }
219
+
220
+ export declare const swaggerUiHtml: (specUrl: string, title?: string, options?: SwaggerUiOptions) => string;
221
+
222
+ declare interface SwaggerUiOptions {
223
+ /** Several definitions — one per API version — shown as a dropdown in the
224
+ * topbar (`urls`), instead of the single `url`. */
225
+ readonly urls?: ReadonlyArray<SwaggerUiDefinition>;
226
+ /** The dropdown's preselected entry (`urls.primaryName`). */
227
+ readonly primaryName?: string;
228
+ }
229
+
230
+ /** The dropdown name of a version: the version, with the earliest `sunset`
231
+ * among its routes when one is declared — `v1 — sunset 2027-03-01`. */
232
+ export declare const versionLabel: (version: string, routes: ReadonlyArray<RestRouteDescriptor<any, any>>) => string;
89
233
 
90
234
  export { }