fumadocs-openapi 10.8.5 → 10.8.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.
Files changed (48) hide show
  1. package/css/generated/shared.css +22 -1
  2. package/dist/generate-file.d.ts +1 -1
  3. package/dist/generate-file.js +1 -1
  4. package/dist/index.d.ts +2 -2
  5. package/dist/node_modules/.pnpm/{@scalar_helpers@0.6.0 → @scalar_helpers@0.8.0}/node_modules/@scalar/helpers/dist/general/create-limiter.js +1 -1
  6. package/dist/node_modules/.pnpm/{@scalar_helpers@0.6.0 → @scalar_helpers@0.8.0}/node_modules/@scalar/helpers/dist/object/is-object.js +1 -1
  7. package/dist/node_modules/.pnpm/{@scalar_helpers@0.6.0 → @scalar_helpers@0.8.0}/node_modules/@scalar/helpers/dist/object/prevent-pollution.js +1 -1
  8. package/dist/node_modules/.pnpm/{@scalar_helpers@0.6.0 → @scalar_helpers@0.8.0}/node_modules/@scalar/helpers/dist/queue/queue.js +1 -1
  9. package/dist/node_modules/.pnpm/{@scalar_helpers@0.6.0 → @scalar_helpers@0.8.0}/node_modules/@scalar/helpers/dist/string/generate-hash.js +1 -1
  10. package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/bundle/bundle.js +2 -2
  11. package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/bundle/plugins/fetch-urls/index.js +2 -2
  12. package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/bundle/plugins/read-files/index.js +1 -1
  13. package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/bundle/value-generator.js +2 -2
  14. package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/convert-to-local-ref.js +1 -1
  15. package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/escape-json-pointer.js +1 -1
  16. package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/get-schemas.js +1 -1
  17. package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/get-segments-from-path.js +1 -1
  18. package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/get-value-by-path.js +1 -1
  19. package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/is-file-path.js +1 -1
  20. package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/is-http-url.js +1 -1
  21. package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/is-json-object.js +2 -2
  22. package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/is-yaml.js +1 -1
  23. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/normalize.js +33 -0
  24. package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/resolve-reference-path.js +1 -1
  25. package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/set-value-at-path.js +2 -2
  26. package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/to-relative-path.js +1 -1
  27. package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/helpers/unescape-json-pointer.js +1 -1
  28. package/dist/playground/client.js +1 -1
  29. package/dist/server/index.d.ts +108 -3
  30. package/dist/server/index.js +181 -2
  31. package/dist/server/proxy.d.ts +1 -1
  32. package/dist/types.d.ts +1 -1
  33. package/dist/ui/base.d.ts +1 -1
  34. package/dist/ui/components/method-label.js +1 -4
  35. package/dist/ui/index.d.ts +1 -1
  36. package/dist/utils/document/process.js +4 -4
  37. package/dist/utils/pages/builder.d.ts +4 -3
  38. package/dist/utils/pages/builder.js +20 -1
  39. package/dist/utils/pages/to-text.d.ts +1 -1
  40. package/dist/utils/pages/to-text.js +23 -42
  41. package/package.json +7 -7
  42. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.12/node_modules/@scalar/json-magic/dist/helpers/normalize.js +0 -26
  43. package/dist/server/create.d.ts +0 -40
  44. package/dist/server/create.js +0 -42
  45. package/dist/server/source-api.d.ts +0 -55
  46. package/dist/server/source-api.js +0 -149
  47. /package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/bundle/plugins/node.js +0 -0
  48. /package/dist/node_modules/.pnpm/{@scalar_json-magic@0.12.12 → @scalar_json-magic@0.12.14}/node_modules/@scalar/json-magic/dist/bundle/plugins/parse-yaml/index.js +0 -0
@@ -1,149 +0,0 @@
1
- import { toStaticData } from "../utils/pages/to-static-data.js";
2
- import { MethodLabel } from "../ui/components/method-label.js";
3
- import path from "node:path";
4
- import { PathUtils } from "fumadocs-core/source";
5
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
- //#region src/server/source-api.tsx
7
- /**
8
- * Fumadocs Source API integration, pass this to `plugins` array in `loader()`.
9
- */
10
- function openapiPlugin() {
11
- return {
12
- name: "fumadocs:openapi",
13
- enforce: "pre",
14
- transformPageTree: { file(node, filePath) {
15
- if (!filePath) return node;
16
- const file = this.storage.read(filePath);
17
- if (!file || file.format !== "page") return node;
18
- const openApiData = file.data._openapi;
19
- if (!openApiData || typeof openApiData !== "object") return node;
20
- if (openApiData.deprecated) node.name = /* @__PURE__ */ jsx("span", {
21
- className: "fd-page-tree-item-name line-through",
22
- children: node.name
23
- });
24
- if (openApiData.webhook) node.name = /* @__PURE__ */ jsxs(Fragment, { children: [
25
- node.name,
26
- " ",
27
- /* @__PURE__ */ jsx("span", {
28
- className: "ms-auto border border-current px-1 rounded-lg text-xs text-nowrap font-mono",
29
- children: "Webhook"
30
- })
31
- ] });
32
- else if (openApiData.method) node.name = /* @__PURE__ */ jsxs(Fragment, { children: [
33
- node.name,
34
- " ",
35
- /* @__PURE__ */ jsx(MethodLabel, {
36
- className: "ms-auto text-xs text-nowrap",
37
- children: openApiData.method
38
- })
39
- ] });
40
- return node;
41
- } }
42
- };
43
- }
44
- /**
45
- * Generate virtual pages for Fumadocs Source API
46
- */
47
- async function openapiSource(server, options = {}) {
48
- const { baseDir = "", meta = false } = options;
49
- const { createAutoPreset } = await import("../utils/pages/preset-auto.js");
50
- const { fromServer } = await import("../utils/pages/builder.js");
51
- const files = [];
52
- const entries = await fromServer(server, createAutoPreset(options));
53
- for (const [schemaId, list] of Object.entries(entries)) {
54
- const processed = await server.getSchema(schemaId);
55
- function onEntry(entry) {
56
- const props = getProps(entry);
57
- files.push({
58
- type: "page",
59
- path: `${baseDir}/${entry.path}`,
60
- data: {
61
- ...entry.info,
62
- getAPIPageProps() {
63
- return props;
64
- },
65
- async getClientAPIPageProps() {
66
- return {
67
- payload: {
68
- bundled: processed.bundled,
69
- proxyUrl: server.options.proxyUrl
70
- },
71
- ...props
72
- };
73
- },
74
- getSchema() {
75
- return {
76
- id: schemaId,
77
- ...processed
78
- };
79
- },
80
- ...toStaticData(props, processed.dereferenced),
81
- _openapi: {
82
- method: entry.type === "operation" || entry.type === "webhook" ? entry.item.method : void 0,
83
- webhook: entry.type === "webhook",
84
- deprecated: entry.info.deprecated
85
- }
86
- }
87
- });
88
- }
89
- function onEntries(entries, parent) {
90
- if (!meta) {
91
- for (const entry of entries) if (entry.type === "group") onEntries(entry.entries, entry);
92
- else onEntry(entry);
93
- return;
94
- }
95
- const { folderStyle = "folder" } = meta === true ? {} : meta;
96
- const pages = [];
97
- for (const entry of entries) {
98
- const relativePath = PathUtils.slash(parent ? path.relative(parent.path, entry.path) : entry.path);
99
- if (entry.type === "group") {
100
- onEntries(entry.entries, entry);
101
- if (folderStyle === "folder") pages.push(relativePath);
102
- else pages.push(`---${entry.info.title}---`, `...${relativePath}`);
103
- } else {
104
- onEntry(entry);
105
- pages.push(relativePath.slice(0, -PathUtils.extname(entry.path).length));
106
- }
107
- }
108
- if (pages.length === 0) return;
109
- files.push({
110
- type: "meta",
111
- path: path.join(baseDir, parent?.path ?? "", "meta.json"),
112
- data: {
113
- title: parent?.info.title,
114
- description: parent?.info.description,
115
- pages
116
- }
117
- });
118
- }
119
- onEntries(list);
120
- }
121
- return { files };
122
- }
123
- function getProps(entry) {
124
- if (entry.type === "operation") return {
125
- document: entry.schemaId,
126
- operations: [entry.item],
127
- showDescription: true
128
- };
129
- if (entry.type === "webhook") return {
130
- document: entry.schemaId,
131
- webhooks: [entry.item],
132
- showDescription: true
133
- };
134
- return {
135
- showTitle: true,
136
- showDescription: true,
137
- document: entry.schemaId,
138
- operations: entry.operations,
139
- webhooks: entry.webhooks
140
- };
141
- }
142
- /**
143
- * @deprecated use `openapiPlugin()`
144
- */
145
- function transformerOpenAPI() {
146
- return openapiPlugin().transformPageTree;
147
- }
148
- //#endregion
149
- export { openapiPlugin, openapiSource, transformerOpenAPI };