@voltro/plugin-openapi 0.86.0 → 0.88.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/generate.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { rpcPathItems as e } from "./rpc.js";
2
2
  import { jsonSchemaDocumentOf as t } from "@voltro/protocol";
3
3
  import { publicSurfaceDigest as n } from "@voltro/protocol/rest";
4
- //#region src/generate.ts
4
+ // src/generate.ts
5
5
  var r = (e) => e.replace(/:([A-Za-z0-9_]+)/g, "{$1}"), i = (e) => {
6
6
  let t = e.anyOf ?? e.oneOf;
7
7
  if (!Array.isArray(t)) return e;
@@ -162,7 +162,8 @@ var r = (e) => e.replace(/:([A-Za-z0-9_]+)/g, "{$1}"), i = (e) => {
162
162
  410: "Gone",
163
163
  422: "Unprocessable Content",
164
164
  429: "Too Many Requests",
165
- 500: "Internal Server Error"
165
+ 500: "Internal Server Error",
166
+ 503: "Service Unavailable"
166
167
  }, g = (e, t, n) => {
167
168
  let r = t.format.errors === "problem-details" && t.format.encodeError === void 0, i = r ? "application/problem+json" : "application/json", o = /* @__PURE__ */ new Map();
168
169
  for (let e of t.errorResponses) {
@@ -173,6 +174,7 @@ var r = (e) => e.replace(/:([A-Za-z0-9_]+)/g, "{$1}"), i = (e) => {
173
174
  ...l
174
175
  } : {
175
176
  error: e.tag,
177
+ _tag: e.tag,
176
178
  ...l
177
179
  };
178
180
  t.push({
@@ -200,18 +202,18 @@ var r = (e) => e.replace(/:([A-Za-z0-9_]+)/g, "{$1}"), i = (e) => {
200
202
  } }
201
203
  };
202
204
  }, c = {};
203
- c[400] = s(400, "Invalid request — the input failed schema decode."), t.security !== "none" && (c[401] = s(401, "Unauthorized — no valid bearer.")), (t.security === "required" || (e.guards?.length ?? 0) > 0) && (c[403] = s(403, "Forbidden — the caller lacks a required scope."));
205
+ c[400] = s(400, "Invalid request — the input failed schema decode."), t.security !== "none" && (c[401] = s(401, "Unauthorized — no valid bearer.")), (t.security === "required" || (e.guards?.length ?? 0) > 0) && (c[403] = s(403, "Forbidden — the caller lacks a required scope.")), e.sunset !== void 0 && (c[410] = s(410, `Gone — the route is past its sunset date (${e.sunset}).`)), c[500] = s(500, "Internal Server Error.");
204
206
  for (let [e, t] of [...o.entries()].sort((e, t) => e[0] - t[0])) {
205
- let n = t.map((e) => e.tag);
207
+ let n = t.map((e) => e.tag), r = c[String(e)], a = r?.content, o = t.length === 1 ? t[0].schema : { oneOf: t.map((e) => e.schema) }, s = a?.[i] === void 0 ? o : { anyOf: [o, a[i].schema] };
206
208
  c[String(e)] = {
207
- description: `${h[e] ?? "Error"} — ${n.join(" | ")}`,
209
+ description: `${h[e] ?? "Error"} — ${n.join(" | ")}${r === void 0 ? "" : `; ${r.description}`}`,
208
210
  content: { [i]: {
209
- schema: t.length === 1 ? t[0].schema : { oneOf: t.map((e) => e.schema) },
211
+ schema: s,
210
212
  example: t[0].example
211
213
  } }
212
214
  };
213
215
  }
214
- return e.sunset !== void 0 && (c[410] = s(410, `Gone — the route is past its sunset date (${e.sunset}).`)), c[500] = s(500, "Internal Server Error."), c;
216
+ return c;
215
217
  }, _ = (e, t, n) => {
216
218
  let r = a(t.input, n), o = r.properties ?? {}, s = new Set(r.required ?? []), c = new Set(t.pathParams), l = [], u = {}, d = [], f = e.example?.request, p = (e) => typeof f == "object" && f && e in f ? { example: f[e] } : {};
217
219
  for (let [t, n] of Object.entries(o)) {
@@ -432,5 +434,4 @@ function S(t, i = {}, u = {}, p = {}) {
432
434
  }
433
435
  };
434
436
  }
435
- //#endregion
436
437
  export { l as HTTP_ERROR_SCHEMA, c as HTTP_ERROR_SCHEMA_NAME, f as PROBLEM_DETAILS_SCHEMA, d as PROBLEM_DETAILS_SCHEMA_NAME, p as deriveExample, u as errorResponse, S as generateOpenApiSpec, o as rewriteRefs, a as toJsonSchema };
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { swaggerUiHtml as r } from "./swaggerUi.js";
3
3
  import { Effect as i } from "effect";
4
4
  import { definePlugin as a } from "@voltro/protocol";
5
5
  import { pluginEnv as o } from "@voltro/env";
6
- //#region src/index.ts
6
+ // src/index.ts
7
7
  var s = o([
8
8
  {
9
9
  name: "OPENAPI_DOCS_TOKEN",
@@ -90,6 +90,7 @@ var s = o([
90
90
  versions: O
91
91
  })
92
92
  }), P = [{
93
+ workload: "rest",
93
94
  method: "GET",
94
95
  path: t,
95
96
  match: "exact",
@@ -104,6 +105,7 @@ var s = o([
104
105
  };
105
106
  }
106
107
  }, {
108
+ workload: "rest",
107
109
  method: "GET",
108
110
  path: T,
109
111
  handle: async (e) => {
@@ -118,6 +120,7 @@ var s = o([
118
120
  }
119
121
  }];
120
122
  return o !== !1 && P.push({
123
+ workload: "rest",
121
124
  method: "GET",
122
125
  path: o,
123
126
  match: "exact",
@@ -128,6 +131,7 @@ var s = o([
128
131
  }
129
132
  }), a({
130
133
  name: p,
134
+ workloads: ["rest"],
131
135
  description: "OpenAPI 3.1 spec + Swagger-UI docs from defineRestRoute descriptors + rpc procedures.",
132
136
  permissions: [],
133
137
  declaredEnv: s.declared,
@@ -150,5 +154,4 @@ var s = o([
150
154
  })
151
155
  });
152
156
  };
153
- //#endregion
154
157
  export { e as PROBLEM_DETAILS_SCHEMA_NAME, t as deriveExample, n as generateOpenApiSpec, d as mountedVersions, p as openapiPlugin, r as swaggerUiHtml, f as versionLabel };
package/dist/rpc.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { errorResponse as e, toJsonSchema as t } from "./generate.js";
2
- //#region src/rpc.ts
2
+ // src/rpc.ts
3
3
  var n = "/rpc", r = "rpc", i = (e) => e.ast._tag === "Never", a = (e, t) => `${e} ${t}`, o = (e) => `Voltro rpc ${e}. This \`/rpc/<name>\` path is a documentation projection of the procedure's input/output schemas — live calls go through ${e === "query" || e === "stream" ? "the batched `POST /rpc` endpoint (first snapshot / element) or the WebSocket rpc channel (reactive/streaming)" : "the batched `POST /rpc` endpoint"}, NOT a REST request to this path. The request body below is the rpc payload.`, s = (n, s) => {
4
4
  let { kind: c, name: l } = n, u = {
5
5
  required: !0,
@@ -41,5 +41,4 @@ var n = "/rpc", r = "rpc", i = (e) => e.ast._tag === "Never", a = (e, t) => `${e
41
41
  }
42
42
  return r;
43
43
  };
44
- //#endregion
45
44
  export { c as rpcPathItems };
package/dist/swaggerUi.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/swaggerUi.ts
1
+ // src/swaggerUi.ts
2
2
  var e = "5.17.14", t = `https://unpkg.com/swagger-ui-dist@${e}/swagger-ui.css`, n = `https://unpkg.com/swagger-ui-dist@${e}/swagger-ui-bundle.js`, r = (e, r = "API docs", i = {}) => `<!doctype html>
3
3
  <html lang="en">
4
4
  <head>
@@ -16,5 +16,4 @@ var e = "5.17.14", t = `https://unpkg.com/swagger-ui-dist@${e}/swagger-ui.css`,
16
16
  <\/script>
17
17
  </body>
18
18
  </html>`;
19
- //#endregion
20
19
  export { r as swaggerUiHtml };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/plugin-openapi",
3
- "version": "0.86.0",
3
+ "version": "0.88.0",
4
4
  "description": "Generate an OpenAPI 3.1 spec from defineRestRoute descriptors and serve it + a Swagger-UI docs page. Zero hand-maintained API docs — the REST descriptors ARE the source of truth.",
5
5
  "keywords": [
6
6
  "voltro",
@@ -33,11 +33,11 @@
33
33
  "node": ">=24.0.0"
34
34
  },
35
35
  "dependencies": {
36
- "@voltro/env": "0.86.0",
37
- "@voltro/protocol": "0.86.0"
36
+ "@voltro/env": "0.88.0",
37
+ "@voltro/protocol": "0.88.0"
38
38
  },
39
39
  "peerDependencies": {
40
- "effect": "4.0.1"
40
+ "effect": "4.1.0"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public"