@fumadocs/api-docs 0.0.2 → 0.0.3
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/css/generated/shared.css +1 -1
- package/dist/components/schema/client.d.ts +16 -1
- package/dist/components/schema/client.js +17 -12
- package/dist/components/schema/index.d.ts +13 -20
- package/dist/components/schema/index.js +82 -60
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/bundle.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/dereference.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.d.ts +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/normalize-args.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.d.ts +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parse.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/binary.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/json.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/text.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/yaml.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/pointer.d.ts +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/pointer.js +10 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/ref.d.ts +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/ref.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/refs.d.ts +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/refs.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolve-external.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/file.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/http.js +15 -6
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/types/index.d.ts +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/convert-path-to-posix.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/errors.d.ts +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/errors.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/is-windows.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/maybe.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/next.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/plugins.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/schema-resources.js +1 -1
- package/dist/node_modules/.pnpm/{@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15 → @apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15}/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/url.js +108 -42
- package/dist/schema/bundle.d.ts +1 -1
- package/dist/schema/bundle.js +1 -1
- package/dist/schema/to-string.js +6 -0
- package/package.json +17 -14
package/css/generated/shared.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@source inline("!isDefined *:data-[collapsible=true]:order-last *:min-w-0 --min-height --radix-popover-content-available-width -mx-3 -translate-x-1/2 -translate-y-1/2 @container @default @fuma-translate/react @fumari/stf @md:grid-cols-2 @param @radix-ui/react-accordion @radix-ui/react-dialog @radix-ui/react-select [&_svg]:size-3.5 a absolute accordion actual additionalProperties again ajv aliasName allOf always an anchor anchorIdStartsWith anchorSegments and animate-spin any anyFields anyOf applicable aria-label array as asSchema autoIds avoid backdrop-blur-sm be behavior bg-black/30 bg-fd-background/50 bg-fd-muted bg-fd-popover bg-fd-primary bg-fd-secondary binary block body boolean border border-b border-fd-primary/20 border-t both button buttonVariants catch children class-variance-authority className client clientHeight closed cn code col-span-full collapsible collisionPadding color const content createContext ctx current currentValue cva dark:text-yellow-400 data-[disabled]:opacity-50 data-[disabled]:pointer-events-none data-[state=closed]:animate-fd-accordion-up data-[state=closed]:animate-fd-dialog-out data-[state=closed]:animate-fd-fade-out data-[state=open]:animate-fd-accordion-down data-[state=open]:animate-fd-dialog-in data-[state=open]:animate-fd-fade-in data-[state=open]:text-fd-accent-foreground data-collapsible data-object-search-input data-placeholder:text-fd-muted-foreground dataEngine decoded default defaultValue deferredValue define delete deprecated depth dereference dereferenceShallow dereferenced description disabled:cursor-not-allowed disabled:opacity-50 display displayName div doc docRoot duplicated duration-200 dynamic element else empty empty:hidden end end-2 engine ensure enum example examples exclusiveMax exclusiveMin export extends fallback false fd-scroll-container field fieldData fieldLabelVariants fieldName fields file files filtered first first:border-t-0 firstItemRef fixed flex flex-1 flex-col flex-col-reverse flex-row flex-wrap focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-fd-ring focus-within:[&_svg]:text-fd-primary focus-within:ring-2 focus-within:ring-fd-ring focus:bg-fd-accent focus:outline-none focus:ring focus:ring-fd-ring focus:text-fd-accent-foreground font-medium font-mono font-semibold for format forwardRef from function gap-0.5 gap-1 gap-1.5 gap-2 gap-4 generate generateDefault generated ghost grid grid-cols-1 group-data-[state=open]/accordion:rotate-90 group/accordion h-10 h-9 h-[240px] h-px hash hidden hiddenProperties highlighted hook hover:bg-fd-accent hover:text-fd-accent-foreground hover:underline htmlFor i icon-sm icon-xs id idx if ignore import in in-popover include index indexItemMatch info infoTags initial inline-flex input inset-0 instanceof integer interface invalid is isDefined isDuplicated isDynamic isLazy isNumber isRequired it item itemId items items-center
|
|
1
|
+
@source inline("!isDefined *:data-[collapsible=true]:order-last *:min-w-0 --min-height --radix-popover-content-available-width -mx-3 -translate-x-1/2 -translate-y-1/2 @container @default @fuma-translate/react @fumari/stf @md:grid-cols-2 @param @radix-ui/react-accordion @radix-ui/react-dialog @radix-ui/react-select [&_svg]:size-3.5 a absolute accordion actual additionalProperties again ajv aliasName allOf always an anchor anchorIdStartsWith anchorSegments and animate-spin any anyFields anyOf applicable aria-label array as asSchema autoIds avoid backdrop-blur-sm be behavior bg-black/30 bg-fd-background/50 bg-fd-muted bg-fd-popover bg-fd-primary bg-fd-secondary binary block blocks body boolean border border-b border-fd-primary/20 border-t both button buttonVariants catch children class-variance-authority className client clientHeight closed cn code col-span-full collapsible collisionPadding color const content createContext ctx current currentValue cva dark:text-yellow-400 data-[disabled]:opacity-50 data-[disabled]:pointer-events-none data-[state=closed]:animate-fd-accordion-up data-[state=closed]:animate-fd-dialog-out data-[state=closed]:animate-fd-fade-out data-[state=open]:animate-fd-accordion-down data-[state=open]:animate-fd-dialog-in data-[state=open]:animate-fd-fade-in data-[state=open]:text-fd-accent-foreground data-collapsible data-object-search-input data-placeholder:text-fd-muted-foreground dataEngine decoded default defaultCode defaultValue deferredValue define delete deprecated depth dereference dereferenceShallow dereferenced description disabled:cursor-not-allowed disabled:opacity-50 display displayName div doc docRoot duplicated duration-200 dynamic element else empty empty:hidden end end-2 engine ensure enum example examples exclusiveMax exclusiveMin export extends fallback false fd-scroll-container field fieldData fieldLabelVariants fieldName fields file files filtered first first:border-t-0 firstItemRef fixed flex flex-1 flex-col flex-col-reverse flex-row flex-wrap focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-fd-ring focus-within:[&_svg]:text-fd-primary focus-within:ring-2 focus-within:ring-fd-ring focus:bg-fd-accent focus:outline-none focus:ring focus:ring-fd-ring focus:text-fd-accent-foreground font-medium font-mono font-semibold for format forwardRef from function gap-0.5 gap-1 gap-1.5 gap-2 gap-4 generate generateDefault generated ghost grid grid-cols-1 group-data-[state=open]/accordion:rotate-90 group/accordion h-10 h-9 h-[240px] h-px hash hidden hiddenProperties highlighted hook hover:bg-fd-accent hover:text-fd-accent-foreground hover:underline htmlFor i icon-sm icon-xs id idx if ignore import in in-popover include index indexItemMatch info infoTags initial inline-flex inlines input inset-0 instanceof integer interface invalid is isDefined isDuplicated isDynamic isLazy isNumber isRequired it item itemId items items-center j json justify-center key kind label labelVariants lang last:border-b-0 lazy leading-none left-1/2 length let line-through list-disc list-inside lucide-react marker:text-fd-muted-foreground matching max max-h-[460px] max-w-(--radix-popover-content-available-width) max-w-full max-w-lg mb-auto md me-auto members merge mergeAllOf mergeRefs min min-h-(--min-height,200px) min-w-0 ms-auto mt-2 multiple must mx-1 my-1 my-2 my-2! name namespace nested never new next node not-prose note null number object objectSearchOverrides objects of omit onChange onClick onKeyDown onOpenAutoFocus onOpenChange onScrollEnd onValueChange oneOf only opacity-80 open opts or order-last out outline outline-none overflow-hidden overflow-x-auto overflow-y-hidden overview p-1 p-1.5 p-2 p-4 param parentItem parentPathIndex part path pathIndex pathName pattern patternProperties pb-0 pe-2 peer-disabled:cursor-not-allowed peer-disabled:opacity-70 placeholder placeholder:text-fd-muted-foreground playground popover popoverRef position prev preventScroll primitive prop properties property props prose-no-margin ps-1 ps-2 ps-3 ps-6 pt-0 px px-2 px-3 px-4 py-0 py-1 py-1.5 py-2 py-4 quiet range raw rawRef rawSearch re-triggering react read readOnly ref refs remove removeItem render renderCodeblock renderMarkdown renderTypeInfoTrigger represents required resize-none resolver return role root rootId rotate-90 rounded-lg rounded-md rounded-sm rounded-xl s-highlight same sample satisfies schema schemaPropKeys schemaToString scroll scroll-m-20 scrollTop search secondary section segments select-none selected selectedType sep setError setInfo setNextName setPath setSearch setShow setValue shadow-lg shadow-md shadow-sm show showExample showSelect shrink-0 simplified single size size-3.5 size-4 skipNonRequired skipReadOnly slotType sm sm:flex-row sm:gap-2 sm:justify-end sm:text-start smooth stable states status step stf sticky store strict string stringifyFieldKey such svg t tab tabDepth tabValues tags target text text-[0.8125rem] text-center text-end text-fd-foreground text-fd-muted-foreground text-fd-muted-foreground/70 text-fd-popover-foreground text-fd-primary text-fd-primary-foreground text-fd-secondary-foreground text-lg text-orange-400 text-red-400 text-red-400/80 text-sm text-start text-xs text-yellow-600 that the tiem to toolbar top top-0 top-1/2 top-10 top-2 tracking-tight transition-colors transition-transform translations trigger true truncate try type typeName typeVariants typeof types undefined underline union unionField unknown updateInfo updated url use useAnchorId useCopyButton useFieldValue useMemo useNamespace useObject useRef useState useTranslations validateFormats validateSchema value valueSchema values variant variants w-0 w-[600px] w-fit w-full will with wrap-break-word write writeOnly x-playground-lazy z-20 z-50");
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SchemaUIGeneratedData } from "./index.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
2
3
|
|
|
3
4
|
//#region src/components/schema/client.d.ts
|
|
4
5
|
interface SchemaUIProps {
|
|
@@ -13,5 +14,19 @@ declare function SchemaUI({
|
|
|
13
14
|
as,
|
|
14
15
|
generated
|
|
15
16
|
}: SchemaUIProps): import("react").JSX.Element;
|
|
17
|
+
declare function InlineTag({
|
|
18
|
+
label,
|
|
19
|
+
children
|
|
20
|
+
}: {
|
|
21
|
+
label: ReactNode;
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
}): import("react").JSX.Element;
|
|
24
|
+
declare function BlockTag({
|
|
25
|
+
label,
|
|
26
|
+
children
|
|
27
|
+
}: {
|
|
28
|
+
label: ReactNode;
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
}): import("react").JSX.Element;
|
|
16
31
|
//#endregion
|
|
17
|
-
export { SchemaUI, SchemaUIProps };
|
|
32
|
+
export { BlockTag, InlineTag, SchemaUI, SchemaUIProps };
|
|
@@ -108,7 +108,7 @@ function SchemaDescription({ schema, ...props }) {
|
|
|
108
108
|
className: cn("prose-no-margin py-2 empty:hidden", props.className),
|
|
109
109
|
children: [schema.description, schema.infoTags && schema.infoTags.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
110
110
|
className: "flex flex-row gap-2 flex-wrap mt-2 not-prose empty:hidden",
|
|
111
|
-
children: schema.infoTags.map((tag, i) => /* @__PURE__ */ jsx(
|
|
111
|
+
children: schema.infoTags.map((tag, i) => /* @__PURE__ */ jsx(Fragment, { children: tag.node }, i))
|
|
112
112
|
})]
|
|
113
113
|
});
|
|
114
114
|
}
|
|
@@ -298,22 +298,27 @@ function ObjectSearchContent({ search: rawSearch, firstItemRef, properties, empt
|
|
|
298
298
|
if (filtered.length === 0) return empty();
|
|
299
299
|
return filtered.map(render);
|
|
300
300
|
}
|
|
301
|
-
function
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
return /* @__PURE__ */ jsxs("button", {
|
|
305
|
-
className: "inline-flex text-start items-start gap-2 bg-fd-secondary border rounded-lg text-xs p-1.5 shadow-md max-w-full",
|
|
306
|
-
onClick: () => setOpen((prev) => !prev),
|
|
301
|
+
function InlineTag({ label, children }) {
|
|
302
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
303
|
+
className: "inline-flex gap-2 bg-fd-secondary border rounded-lg text-xs p-1.5 shadow-md max-w-full",
|
|
307
304
|
children: [/* @__PURE__ */ jsx("span", {
|
|
308
305
|
className: "font-medium",
|
|
309
|
-
children:
|
|
306
|
+
children: label
|
|
310
307
|
}), /* @__PURE__ */ jsx("code", {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
children: tag.value
|
|
308
|
+
className: "min-w-0 flex-1 text-fd-muted-foreground wrap-break-word",
|
|
309
|
+
children
|
|
314
310
|
})]
|
|
315
311
|
});
|
|
316
312
|
}
|
|
313
|
+
function BlockTag({ label, children }) {
|
|
314
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
315
|
+
className: "flex flex-col w-full gap-2 bg-fd-secondary border rounded-lg p-1.5 shadow-md",
|
|
316
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
317
|
+
className: "font-medium text-xs",
|
|
318
|
+
children: label
|
|
319
|
+
}), children]
|
|
320
|
+
});
|
|
321
|
+
}
|
|
317
322
|
function SchemaUIPopover() {
|
|
318
323
|
const states = useStates();
|
|
319
324
|
const { path, setPath } = states;
|
|
@@ -412,4 +417,4 @@ function decodePath(path, highlighted) {
|
|
|
412
417
|
return out;
|
|
413
418
|
}
|
|
414
419
|
//#endregion
|
|
415
|
-
export { SchemaUI };
|
|
420
|
+
export { BlockTag, InlineTag, SchemaUI };
|
|
@@ -3,6 +3,9 @@ import { SchemaUIProps } from "./client.js";
|
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/components/schema/index.d.ts
|
|
6
|
+
interface InfoTag {
|
|
7
|
+
node: ReactNode;
|
|
8
|
+
}
|
|
6
9
|
interface FieldBase {
|
|
7
10
|
description?: ReactNode;
|
|
8
11
|
infoTags?: InfoTag[];
|
|
@@ -10,10 +13,6 @@ interface FieldBase {
|
|
|
10
13
|
aliasName: string;
|
|
11
14
|
deprecated?: boolean;
|
|
12
15
|
}
|
|
13
|
-
interface InfoTag {
|
|
14
|
-
label: ReactNode;
|
|
15
|
-
value: string;
|
|
16
|
-
}
|
|
17
16
|
interface SchemaDataObjectProperty {
|
|
18
17
|
name: string;
|
|
19
18
|
$type: string;
|
|
@@ -47,6 +46,10 @@ interface SchemaUIOptions {
|
|
|
47
46
|
client: Omit<SchemaUIProps, 'generated'>;
|
|
48
47
|
resolver: SchemaResolver;
|
|
49
48
|
renderMarkdown: (md: string) => ReactNode;
|
|
49
|
+
renderCodeblock: (opts: {
|
|
50
|
+
lang: string;
|
|
51
|
+
code: string;
|
|
52
|
+
}) => ReactNode;
|
|
50
53
|
/**
|
|
51
54
|
* include read only props
|
|
52
55
|
*/
|
|
@@ -66,18 +69,6 @@ interface SchemaUIGeneratedData {
|
|
|
66
69
|
$root: string;
|
|
67
70
|
refs: Record<string, SchemaData>;
|
|
68
71
|
}
|
|
69
|
-
interface SchemaUILabels {
|
|
70
|
-
default: string;
|
|
71
|
-
match: string;
|
|
72
|
-
format: string;
|
|
73
|
-
multipleOf: string;
|
|
74
|
-
range: string;
|
|
75
|
-
length: string;
|
|
76
|
-
properties: string;
|
|
77
|
-
items: string;
|
|
78
|
-
valueIn: string;
|
|
79
|
-
example: string;
|
|
80
|
-
}
|
|
81
72
|
declare function Schema({
|
|
82
73
|
client,
|
|
83
74
|
root,
|
|
@@ -85,18 +76,20 @@ declare function Schema({
|
|
|
85
76
|
writeOnly,
|
|
86
77
|
resolver,
|
|
87
78
|
showExample,
|
|
88
|
-
renderMarkdown
|
|
79
|
+
renderMarkdown,
|
|
80
|
+
renderCodeblock
|
|
89
81
|
}: SchemaUIOptions): import("react").JSX.Element;
|
|
90
82
|
declare function generateSchemaUI({
|
|
91
83
|
root,
|
|
92
84
|
resolver,
|
|
93
85
|
renderMarkdown,
|
|
86
|
+
renderCodeblock,
|
|
94
87
|
readOnly,
|
|
95
88
|
writeOnly,
|
|
96
89
|
showExample,
|
|
97
|
-
|
|
90
|
+
translations
|
|
98
91
|
}: Omit<SchemaUIOptions, 'client'> & {
|
|
99
|
-
|
|
92
|
+
translations?: Partial<Record<string, string>>;
|
|
100
93
|
}): SchemaUIGeneratedData;
|
|
101
94
|
//#endregion
|
|
102
|
-
export { FieldBase,
|
|
95
|
+
export { FieldBase, Schema, SchemaData, SchemaDataObjectProperty, SchemaUIGeneratedData, SchemaUIOptions, generateSchemaUI };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { mergeAllOf } from "../../schema/merge.js";
|
|
3
3
|
import { schemaToString } from "../../schema/to-string.js";
|
|
4
|
-
import { SchemaUI } from "./client.js";
|
|
4
|
+
import { BlockTag, InlineTag, SchemaUI } from "./client.js";
|
|
5
5
|
import { useMemo } from "react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
import { useTranslations } from "@fuma-translate/react";
|
|
7
|
+
import { fromTranslations, useTranslations } from "@fuma-translate/react";
|
|
8
8
|
//#region src/components/schema/index.tsx
|
|
9
|
-
function Schema({ client, root, readOnly, writeOnly, resolver, showExample, renderMarkdown }) {
|
|
10
|
-
const
|
|
9
|
+
function Schema({ client, root, readOnly, writeOnly, resolver, showExample, renderMarkdown, renderCodeblock }) {
|
|
10
|
+
const translations = useTranslations().translations;
|
|
11
11
|
const generated = useMemo(() => {
|
|
12
12
|
return generateSchemaUI({
|
|
13
13
|
root,
|
|
@@ -16,18 +16,8 @@ function Schema({ client, root, readOnly, writeOnly, resolver, showExample, rend
|
|
|
16
16
|
writeOnly,
|
|
17
17
|
showExample,
|
|
18
18
|
renderMarkdown,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
match: t("Match"),
|
|
22
|
-
format: t("Format"),
|
|
23
|
-
multipleOf: t("Multiple Of"),
|
|
24
|
-
range: t("Range"),
|
|
25
|
-
length: t("Length"),
|
|
26
|
-
properties: t("Properties"),
|
|
27
|
-
items: t("Items"),
|
|
28
|
-
valueIn: t("Value in"),
|
|
29
|
-
example: t("Example")
|
|
30
|
-
}
|
|
19
|
+
renderCodeblock,
|
|
20
|
+
translations
|
|
31
21
|
});
|
|
32
22
|
}, [
|
|
33
23
|
root,
|
|
@@ -36,62 +26,94 @@ function Schema({ client, root, readOnly, writeOnly, resolver, showExample, rend
|
|
|
36
26
|
resolver,
|
|
37
27
|
showExample,
|
|
38
28
|
renderMarkdown,
|
|
39
|
-
|
|
29
|
+
renderCodeblock,
|
|
30
|
+
translations
|
|
40
31
|
]);
|
|
41
32
|
return /* @__PURE__ */ jsx(SchemaUI, {
|
|
42
33
|
...client,
|
|
43
34
|
generated
|
|
44
35
|
});
|
|
45
36
|
}
|
|
46
|
-
function generateSchemaUI({ root, resolver, renderMarkdown, readOnly = false, writeOnly = false, showExample = false,
|
|
37
|
+
function generateSchemaUI({ root, resolver, renderMarkdown, renderCodeblock, readOnly = false, writeOnly = false, showExample = false, translations = {} }) {
|
|
38
|
+
const t = fromTranslations(translations, { note: "schema UI" });
|
|
47
39
|
const refs = {};
|
|
48
40
|
function generateInfoTags(schema) {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
label: labels.multipleOf,
|
|
64
|
-
value: schema.multipleOf.toString()
|
|
65
|
-
});
|
|
41
|
+
const inlines = [];
|
|
42
|
+
const blocks = [];
|
|
43
|
+
if (schema.pattern) inlines.push({ node: /* @__PURE__ */ jsx(InlineTag, {
|
|
44
|
+
label: t("Match"),
|
|
45
|
+
children: schema.pattern
|
|
46
|
+
}) });
|
|
47
|
+
if (schema.format) inlines.push({ node: /* @__PURE__ */ jsx(InlineTag, {
|
|
48
|
+
label: t("Format"),
|
|
49
|
+
children: schema.format
|
|
50
|
+
}) });
|
|
51
|
+
if (schema.multipleOf) inlines.push({ node: /* @__PURE__ */ jsx(InlineTag, {
|
|
52
|
+
label: t("Multiple Of"),
|
|
53
|
+
children: schema.multipleOf
|
|
54
|
+
}) });
|
|
66
55
|
let range = formatRange("value", schema.minimum, schema.exclusiveMinimum, schema.maximum, schema.exclusiveMaximum);
|
|
67
|
-
if (range)
|
|
68
|
-
label:
|
|
69
|
-
|
|
70
|
-
});
|
|
56
|
+
if (range) inlines.push({ node: /* @__PURE__ */ jsx(InlineTag, {
|
|
57
|
+
label: t("Range"),
|
|
58
|
+
children: range
|
|
59
|
+
}) });
|
|
71
60
|
range = formatRange("length", schema.minLength, void 0, schema.maxLength, void 0);
|
|
72
|
-
if (range)
|
|
73
|
-
label:
|
|
74
|
-
|
|
75
|
-
});
|
|
61
|
+
if (range) inlines.push({ node: /* @__PURE__ */ jsx(InlineTag, {
|
|
62
|
+
label: t("Length"),
|
|
63
|
+
children: range
|
|
64
|
+
}) });
|
|
76
65
|
range = formatRange("properties", schema.minProperties, void 0, schema.maxProperties, void 0);
|
|
77
|
-
if (range)
|
|
78
|
-
label:
|
|
79
|
-
|
|
80
|
-
});
|
|
66
|
+
if (range) inlines.push({ node: /* @__PURE__ */ jsx(InlineTag, {
|
|
67
|
+
label: t("Properties"),
|
|
68
|
+
children: range
|
|
69
|
+
}) });
|
|
81
70
|
range = formatRange("items", schema.minItems, void 0, schema.maxItems, void 0);
|
|
82
|
-
if (range)
|
|
83
|
-
label:
|
|
84
|
-
|
|
85
|
-
});
|
|
86
|
-
if (schema.enum)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
71
|
+
if (range) inlines.push({ node: /* @__PURE__ */ jsx(InlineTag, {
|
|
72
|
+
label: t("Items"),
|
|
73
|
+
children: range
|
|
74
|
+
}) });
|
|
75
|
+
if (schema.enum && schema.enum.length > 0) {
|
|
76
|
+
const members = schema.enum.map((value) => JSON.stringify(value, null, 2));
|
|
77
|
+
blocks.push({ node: /* @__PURE__ */ jsx(BlockTag, {
|
|
78
|
+
label: t("Value in"),
|
|
79
|
+
children: /* @__PURE__ */ jsx("ul", { children: members.map((m, i) => /* @__PURE__ */ jsx("li", {
|
|
80
|
+
className: "font-mono list-disc list-inside ps-1 marker:text-fd-muted-foreground",
|
|
81
|
+
children: m
|
|
82
|
+
}, i)) })
|
|
83
|
+
}) });
|
|
84
|
+
}
|
|
85
|
+
if (schema.default !== void 0) {
|
|
86
|
+
const defaultCode = JSON.stringify(schema.default, null, 2);
|
|
87
|
+
if (defaultCode.includes("\n")) blocks.push({ node: /* @__PURE__ */ jsx(BlockTag, {
|
|
88
|
+
label: t("Default"),
|
|
89
|
+
children: renderCodeblock({
|
|
90
|
+
lang: "json",
|
|
91
|
+
code: defaultCode
|
|
92
|
+
})
|
|
93
|
+
}) });
|
|
94
|
+
else inlines.push({ node: /* @__PURE__ */ jsx(InlineTag, {
|
|
95
|
+
label: t("Default"),
|
|
96
|
+
children: defaultCode
|
|
97
|
+
}) });
|
|
98
|
+
}
|
|
99
|
+
if (showExample && schema.examples) for (const example of schema.examples) {
|
|
100
|
+
const code = JSON.stringify(example, null, 2);
|
|
101
|
+
if (code.includes("\n")) {
|
|
102
|
+
blocks.push({ node: /* @__PURE__ */ jsx(BlockTag, {
|
|
103
|
+
label: t("Example"),
|
|
104
|
+
children: renderCodeblock({
|
|
105
|
+
lang: "json",
|
|
106
|
+
code
|
|
107
|
+
})
|
|
108
|
+
}) });
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
inlines.push({ node: /* @__PURE__ */ jsx(InlineTag, {
|
|
112
|
+
label: t("Example"),
|
|
113
|
+
children: code
|
|
114
|
+
}) });
|
|
115
|
+
}
|
|
116
|
+
return [...inlines, ...blocks];
|
|
95
117
|
}
|
|
96
118
|
let _counter = 0;
|
|
97
119
|
const autoIds = /* @__PURE__ */ new WeakMap();
|
|
@@ -2,7 +2,7 @@ import { getHash, resolve, stripHash } from "./util/url.js";
|
|
|
2
2
|
import { getSchemaBasePath } from "./util/schema-resources.js";
|
|
3
3
|
import Pointer from "./pointer.js";
|
|
4
4
|
import $Ref from "./ref.js";
|
|
5
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
5
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/bundle.js
|
|
6
6
|
/**
|
|
7
7
|
* Bundles all external JSON references into the main JSON schema, thus resulting in a schema that
|
|
8
8
|
* only has *internal* references, not any *external* references.
|
|
@@ -3,7 +3,7 @@ import { TimeoutError } from "./util/errors.js";
|
|
|
3
3
|
import { getSchemaBasePath } from "./util/schema-resources.js";
|
|
4
4
|
import Pointer from "./pointer.js";
|
|
5
5
|
import $Ref from "./ref.js";
|
|
6
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
6
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/dereference.js
|
|
7
7
|
var dereference_default = dereference;
|
|
8
8
|
/**
|
|
9
9
|
* Crawls the JSON schema, finds all JSON references, and dereferences them.
|
|
@@ -3,7 +3,7 @@ import { ParserOptions } from "./options.js";
|
|
|
3
3
|
import { JSONParserError, MissingPointerError, ParserError, ResolverError } from "./util/errors.js";
|
|
4
4
|
import { $Refs } from "./refs.js";
|
|
5
5
|
|
|
6
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
6
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.d.ts
|
|
7
7
|
/**
|
|
8
8
|
* This class parses a JSON schema, builds a map of its JSON references and their resolved values,
|
|
9
9
|
* and provides methods for traversing, manipulating, and dereferencing those references.
|
|
@@ -11,7 +11,7 @@ import resolveExternal from "./resolve-external.js";
|
|
|
11
11
|
import bundle$1 from "./bundle.js";
|
|
12
12
|
import dereference_default from "./dereference.js";
|
|
13
13
|
import maybe from "./util/maybe.js";
|
|
14
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
14
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.js
|
|
15
15
|
/**
|
|
16
16
|
* This class parses a JSON schema, builds a map of its JSON references and their resolved values,
|
|
17
17
|
* and provides methods for traversing, manipulating, and dereferencing those references.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getNewOptions } from "./options.js";
|
|
2
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
2
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/normalize-args.js
|
|
3
3
|
/**
|
|
4
4
|
* Normalizes the given arguments, accounting for optional args.
|
|
5
5
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HTTPResolverOptions, JSONSchema, JSONSchemaObject, Plugin, ResolverOptions } from "./types/index.js";
|
|
2
2
|
|
|
3
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
3
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.d.ts
|
|
4
4
|
type DeepPartial<T> = T extends object ? { [P in keyof T]?: DeepPartial<T[P]> } : T;
|
|
5
5
|
interface BundleOptions {
|
|
6
6
|
/**
|
|
@@ -4,7 +4,7 @@ import text_default from "./parsers/text.js";
|
|
|
4
4
|
import binary_default from "./parsers/binary.js";
|
|
5
5
|
import file_default from "./resolvers/file.js";
|
|
6
6
|
import http_default from "./resolvers/http.js";
|
|
7
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
7
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.js
|
|
8
8
|
const getJsonSchemaRefParserDefaultOptions = () => {
|
|
9
9
|
return {
|
|
10
10
|
/**
|
|
@@ -2,7 +2,7 @@ import { getExtension } from "./util/url.js";
|
|
|
2
2
|
import { ParserError, ResolverError, UnmatchedParserError, UnmatchedResolverError, isHandledError } from "./util/errors.js";
|
|
3
3
|
import { registerSchemaResources, usesDynamicIdScope } from "./util/schema-resources.js";
|
|
4
4
|
import { all, filter, run, sort } from "./util/plugins.js";
|
|
5
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
5
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parse.js
|
|
6
6
|
/**
|
|
7
7
|
* Reads and parses the specified file path or URL.
|
|
8
8
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
1
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/binary.js
|
|
2
2
|
const BINARY_REGEXP = /\.(jpeg|jpg|gif|png|bmp|ico)$/i;
|
|
3
3
|
var binary_default = {
|
|
4
4
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParserError } from "../util/errors.js";
|
|
2
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
2
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/json.js
|
|
3
3
|
var json_default = {
|
|
4
4
|
/**
|
|
5
5
|
* The order that this parser will run, in relation to other parsers.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParserError } from "../util/errors.js";
|
|
2
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
2
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/text.js
|
|
3
3
|
const TEXT_REGEXP = /\.(txt|htm|html|md|xml|js|min|map|css|scss|less|svg)$/i;
|
|
4
4
|
var text_default = {
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ParserError } from "../util/errors.js";
|
|
2
2
|
import yaml, { JSON_SCHEMA } from "js-yaml";
|
|
3
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
3
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/yaml.js
|
|
4
4
|
var yaml_default = {
|
|
5
5
|
/**
|
|
6
6
|
* The order that this parser will run, in relation to other parsers.
|
|
@@ -3,7 +3,7 @@ import { ParserOptions } from "./options.js";
|
|
|
3
3
|
import { $Ref } from "./ref.js";
|
|
4
4
|
import { JSONSchema4Type, JSONSchema6Type, JSONSchema7Type } from "json-schema";
|
|
5
5
|
|
|
6
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
6
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/pointer.d.ts
|
|
7
7
|
/**
|
|
8
8
|
* This class represents a single JSON pointer and its resolved value.
|
|
9
9
|
*
|
|
@@ -2,12 +2,17 @@ import { getHash, resolve, stripHash } from "./util/url.js";
|
|
|
2
2
|
import { InvalidPointerError, JSONParserError, MissingPointerError, isHandledError } from "./util/errors.js";
|
|
3
3
|
import { getSchemaBasePath } from "./util/schema-resources.js";
|
|
4
4
|
import $Ref from "./ref.js";
|
|
5
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
5
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/pointer.js
|
|
6
6
|
const nullSymbol = Symbol("null");
|
|
7
7
|
const slashes = /\//g;
|
|
8
8
|
const tildes = /~/g;
|
|
9
9
|
const escapedSlash = /~1/g;
|
|
10
10
|
const escapedTilde = /~0/g;
|
|
11
|
+
const unsafeSetTokens = new Set([
|
|
12
|
+
"__proto__",
|
|
13
|
+
"constructor",
|
|
14
|
+
"prototype"
|
|
15
|
+
]);
|
|
11
16
|
/**
|
|
12
17
|
* This class represents a single JSON pointer and its resolved value.
|
|
13
18
|
*
|
|
@@ -128,6 +133,7 @@ var Pointer = class Pointer {
|
|
|
128
133
|
this.value = value;
|
|
129
134
|
return value;
|
|
130
135
|
}
|
|
136
|
+
assertSafeSetTokens(this.path, tokens);
|
|
131
137
|
this.value = unwrapOrThrow(obj);
|
|
132
138
|
if (this.$ref.dynamicIdScope && !isAliasedResource(this.$ref)) this.scopeBase = getSchemaBasePath(this.scopeBase, this.value);
|
|
133
139
|
for (let i = 0; i < tokens.length - 1; i++) {
|
|
@@ -228,6 +234,9 @@ function setValue(pointer, token, value) {
|
|
|
228
234
|
else throw new JSONParserError(`Error assigning $ref pointer "${pointer.path}". \nCannot set "${token}" of a non-object.`);
|
|
229
235
|
return value;
|
|
230
236
|
}
|
|
237
|
+
function assertSafeSetTokens(pointerPath, tokens) {
|
|
238
|
+
for (const token of tokens) if (unsafeSetTokens.has(token)) throw new JSONParserError(`Error assigning $ref pointer "${pointerPath}". \nUnsafe JSON Pointer token "${token}" cannot be used for assignment.`);
|
|
239
|
+
}
|
|
231
240
|
function unwrapOrThrow(value) {
|
|
232
241
|
if (isHandledError(value)) throw value;
|
|
233
242
|
return value;
|
|
@@ -5,7 +5,7 @@ import { Pointer } from "./pointer.js";
|
|
|
5
5
|
import { $Refs } from "./refs.js";
|
|
6
6
|
import { JSONSchema4Type, JSONSchema6Type, JSONSchema7Type } from "json-schema";
|
|
7
7
|
|
|
8
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
8
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/ref.d.ts
|
|
9
9
|
type $RefError = JSONParserError | ResolverError | ParserError | MissingPointerError;
|
|
10
10
|
/**
|
|
11
11
|
* This class represents a single JSON reference and its resolved value.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getHash, safePointerToPath, stripHash } from "./util/url.js";
|
|
2
2
|
import { InvalidPointerError, isHandledError, normalizeError } from "./util/errors.js";
|
|
3
3
|
import Pointer, { nullSymbol } from "./pointer.js";
|
|
4
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
4
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/ref.js
|
|
5
5
|
/**
|
|
6
6
|
* This class represents a single JSON reference and its resolved value.
|
|
7
7
|
*
|
|
@@ -4,7 +4,7 @@ import { $Ref } from "./ref.js";
|
|
|
4
4
|
import { Pointer } from "./pointer.js";
|
|
5
5
|
import { JSONSchema4Type, JSONSchema6Type, JSONSchema7Type } from "json-schema";
|
|
6
6
|
|
|
7
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
7
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/refs.d.ts
|
|
8
8
|
interface $RefsMap<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
|
|
9
9
|
[url: string]: $Ref<S, O>;
|
|
10
10
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import convertPathToPosix from "./util/convert-path-to-posix.js";
|
|
2
2
|
import { resolve, stripHash, toFileSystemPath } from "./util/url.js";
|
|
3
3
|
import $Ref from "./ref.js";
|
|
4
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
4
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/refs.js
|
|
5
5
|
/**
|
|
6
6
|
* When you call the resolve method, the value that gets passed to the callback function (or Promise) is a $Refs object. This same object is accessible via the parser.$refs property of $RefParser objects.
|
|
7
7
|
*
|
|
@@ -4,7 +4,7 @@ import { getSchemaBasePath } from "./util/schema-resources.js";
|
|
|
4
4
|
import Pointer from "./pointer.js";
|
|
5
5
|
import $Ref from "./ref.js";
|
|
6
6
|
import parse from "./parse.js";
|
|
7
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
7
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolve-external.js
|
|
8
8
|
/**
|
|
9
9
|
* Crawls the JSON schema, finds all external JSON references, and resolves their values.
|
|
10
10
|
* This method does not mutate the JSON schema. The resolved values are added to {@link $RefParser#$refs}.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isFileSystemPath, toFileSystemPath } from "../util/url.js";
|
|
2
2
|
import { ResolverError } from "../util/errors.js";
|
|
3
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
3
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/file.js
|
|
4
4
|
var file_default = {
|
|
5
5
|
/**
|
|
6
6
|
* The order that this resolver will run, in relation to other resolvers.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isHttp, isUnsafeUrl, parse, resolve } from "../util/url.js";
|
|
2
2
|
import { ResolverError } from "../util/errors.js";
|
|
3
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
3
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/http.js
|
|
4
4
|
var http_default = {
|
|
5
5
|
/**
|
|
6
6
|
* The order that this resolver will run, in relation to other resolvers.
|
|
@@ -61,6 +61,7 @@ async function download(u, httpOptions, _redirects) {
|
|
|
61
61
|
const redirects = _redirects || [];
|
|
62
62
|
redirects.push(u.href);
|
|
63
63
|
try {
|
|
64
|
+
if (httpOptions.safeUrlResolver && isUnsafeUrl(u.href)) throw new Error(`Unsafe URL blocked by safeUrlResolver: ${u.href}`);
|
|
64
65
|
const res = await get(u, httpOptions);
|
|
65
66
|
if (res.status >= 400) {
|
|
66
67
|
const error = /* @__PURE__ */ new Error(`HTTP ERROR ${res.status}`);
|
|
@@ -70,11 +71,15 @@ async function download(u, httpOptions, _redirects) {
|
|
|
70
71
|
const error = /* @__PURE__ */ new Error(`Error downloading ${redirects[0]}. \nToo many redirects: \n ${redirects.join(" \n ")}`);
|
|
71
72
|
error.status = res.status;
|
|
72
73
|
throw new ResolverError(error);
|
|
73
|
-
} else
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
} else {
|
|
75
|
+
const location = getHeader(res, "location");
|
|
76
|
+
if (!location) {
|
|
77
|
+
const error = /* @__PURE__ */ new Error(`HTTP ${res.status} redirect with no location header`);
|
|
78
|
+
error.status = res.status;
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
return download(resolve(u.href, location), httpOptions, redirects);
|
|
82
|
+
}
|
|
78
83
|
else {
|
|
79
84
|
if (res.body) {
|
|
80
85
|
const buf = await res.arrayBuffer();
|
|
@@ -103,10 +108,14 @@ async function get(u, httpOptions) {
|
|
|
103
108
|
method: "GET",
|
|
104
109
|
headers: httpOptions.headers || {},
|
|
105
110
|
credentials: httpOptions.withCredentials ? "include" : "same-origin",
|
|
111
|
+
redirect: "manual",
|
|
106
112
|
signal: controller ? controller.signal : null
|
|
107
113
|
});
|
|
108
114
|
if (timeoutId) clearTimeout(timeoutId);
|
|
109
115
|
return response;
|
|
110
116
|
}
|
|
117
|
+
function getHeader(response, name) {
|
|
118
|
+
return response.headers.get(name);
|
|
119
|
+
}
|
|
111
120
|
//#endregion
|
|
112
121
|
export { http_default as default };
|
|
@@ -2,7 +2,7 @@ import { ParserOptions } from "../options.js";
|
|
|
2
2
|
import { $Refs } from "../refs.js";
|
|
3
3
|
import { JSONSchema4, JSONSchema4Object, JSONSchema6, JSONSchema6Object, JSONSchema7, JSONSchema7Object } from "json-schema";
|
|
4
4
|
|
|
5
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
5
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/types/index.d.ts
|
|
6
6
|
type JSONSchema = JSONSchema4 | JSONSchema6 | JSONSchema7;
|
|
7
7
|
type JSONSchemaObject = JSONSchema4Object | JSONSchema6Object | JSONSchema7Object;
|
|
8
8
|
type SchemaCallback<S extends object = JSONSchema> = (err: Error | null, schema?: S | object | null) => any;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
1
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/convert-path-to-posix.js
|
|
2
2
|
const win32Sep = "\\";
|
|
3
3
|
function convertPathToPosix(filePath) {
|
|
4
4
|
if (filePath.startsWith("\\\\?\\")) return filePath;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
1
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/errors.d.ts
|
|
2
2
|
type JSONParserErrorType = "EUNKNOWN" | "EPARSER" | "EUNMATCHEDPARSER" | "ETIMEOUT" | "ERESOLVER" | "EUNMATCHEDRESOLVER" | "EMISSINGPOINTER" | "EINVALIDPOINTER";
|
|
3
3
|
declare class JSONParserError extends Error {
|
|
4
4
|
readonly name: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getHash, stripHash, toFileSystemPath } from "./url.js";
|
|
2
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
2
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/errors.js
|
|
3
3
|
const nonJsonTypes = [
|
|
4
4
|
"function",
|
|
5
5
|
"symbol",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
1
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/is-windows.js
|
|
2
2
|
const isWindowsConst = /^win/.test(globalThis.process ? globalThis.process.platform : "");
|
|
3
3
|
const isWindows = () => isWindowsConst;
|
|
4
4
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import next_default from "./next.js";
|
|
2
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
2
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/maybe.js
|
|
3
3
|
function maybe(cb, promise) {
|
|
4
4
|
if (cb) {
|
|
5
5
|
promise.then(function(result) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
1
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/next.js
|
|
2
2
|
function makeNext() {
|
|
3
3
|
if (typeof process === "object" && typeof process.nextTick === "function") return process.nextTick;
|
|
4
4
|
else if (typeof setImmediate === "function") return setImmediate;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
1
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/plugins.js
|
|
2
2
|
/**
|
|
3
3
|
* Returns the given plugins as an array, rather than an object map.
|
|
4
4
|
* All other methods in this module expect an array of plugins rather than an object map.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolve } from "./url.js";
|
|
2
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
2
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/schema-resources.js
|
|
3
3
|
function getSchemaBasePath(basePath, value) {
|
|
4
4
|
const schemaId = getSchemaId(value);
|
|
5
5
|
return schemaId ? resolve(basePath, schemaId) : basePath;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import convertPathToPosix from "./convert-path-to-posix.js";
|
|
2
2
|
import { isWindows } from "./is-windows.js";
|
|
3
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.
|
|
3
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/url.js
|
|
4
4
|
const forwardSlashPattern = /\//g;
|
|
5
5
|
const protocolPattern = /^(\w{2,}):\/\//i;
|
|
6
6
|
const jsonPointerSlash = /~1/g;
|
|
@@ -19,6 +19,15 @@ const urlDecodePatterns = [
|
|
|
19
19
|
/%40/g,
|
|
20
20
|
"@"
|
|
21
21
|
];
|
|
22
|
+
const unsafeDomainSuffixes = [
|
|
23
|
+
".localhost",
|
|
24
|
+
".local",
|
|
25
|
+
".internal",
|
|
26
|
+
".intranet",
|
|
27
|
+
".corp",
|
|
28
|
+
".home",
|
|
29
|
+
".lan"
|
|
30
|
+
];
|
|
22
31
|
const parse = (u) => new URL(u);
|
|
23
32
|
/**
|
|
24
33
|
* Returns resolved target URL relative to a base URL in a manner similar to that of a Web browser resolving an anchor tag HREF.
|
|
@@ -147,58 +156,115 @@ function isUnsafeUrl(path) {
|
|
|
147
156
|
if (normalizedPath.startsWith("javascript:") || normalizedPath.startsWith("vbscript:") || normalizedPath.startsWith("data:")) return true;
|
|
148
157
|
if (normalizedPath.startsWith("file:")) return true;
|
|
149
158
|
if (typeof window !== "undefined" && window.location && window.location.href) return false;
|
|
150
|
-
const localPatterns = [
|
|
151
|
-
"localhost",
|
|
152
|
-
"127.0.0.1",
|
|
153
|
-
"::1",
|
|
154
|
-
"10.",
|
|
155
|
-
"172.16.",
|
|
156
|
-
"172.17.",
|
|
157
|
-
"172.18.",
|
|
158
|
-
"172.19.",
|
|
159
|
-
"172.20.",
|
|
160
|
-
"172.21.",
|
|
161
|
-
"172.22.",
|
|
162
|
-
"172.23.",
|
|
163
|
-
"172.24.",
|
|
164
|
-
"172.25.",
|
|
165
|
-
"172.26.",
|
|
166
|
-
"172.27.",
|
|
167
|
-
"172.28.",
|
|
168
|
-
"172.29.",
|
|
169
|
-
"172.30.",
|
|
170
|
-
"172.31.",
|
|
171
|
-
"192.168.",
|
|
172
|
-
"169.254.",
|
|
173
|
-
".local",
|
|
174
|
-
".internal",
|
|
175
|
-
".intranet",
|
|
176
|
-
".corp",
|
|
177
|
-
".home",
|
|
178
|
-
".lan"
|
|
179
|
-
];
|
|
180
159
|
try {
|
|
181
160
|
const url = new URL(normalizedPath.startsWith("//") ? "http:" + normalizedPath : normalizedPath);
|
|
182
|
-
|
|
183
|
-
for (const pattern of localPatterns) if (hostname === pattern || hostname.startsWith(pattern) || hostname.endsWith(pattern)) return true;
|
|
184
|
-
if (isPrivateIP(hostname)) return true;
|
|
161
|
+
if (isUnsafeHostname(url.hostname)) return true;
|
|
185
162
|
const port = url.port;
|
|
186
163
|
if (port && isInternalPort(parseInt(port))) return true;
|
|
187
164
|
} catch {
|
|
188
165
|
if (normalizedPath.startsWith("/") && !normalizedPath.startsWith("//")) return false;
|
|
189
|
-
|
|
166
|
+
if (containsUnsafeHostname(normalizedPath)) return true;
|
|
190
167
|
}
|
|
191
168
|
return false;
|
|
192
169
|
}
|
|
193
170
|
/**
|
|
194
|
-
* Helper function to check if
|
|
171
|
+
* Helper function to check if a hostname is local or resolves to a non-public literal address.
|
|
172
|
+
*/
|
|
173
|
+
function isUnsafeHostname(hostname) {
|
|
174
|
+
const normalizedHostname = normalizeHostname(hostname);
|
|
175
|
+
if (!normalizedHostname) return true;
|
|
176
|
+
if (normalizedHostname === "localhost" || unsafeDomainSuffixes.some((suffix) => normalizedHostname.endsWith(suffix))) return true;
|
|
177
|
+
const ipv4 = parseIPv4Address(normalizedHostname);
|
|
178
|
+
if (ipv4) return isUnsafeIPv4Address(ipv4);
|
|
179
|
+
const ipv6 = parseIPv6Address(normalizedHostname);
|
|
180
|
+
if (ipv6) return isUnsafeIPv6Address(ipv6);
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
function normalizeHostname(hostname) {
|
|
184
|
+
let normalizedHostname = hostname.trim().toLowerCase();
|
|
185
|
+
if (normalizedHostname.startsWith("[") && normalizedHostname.endsWith("]")) normalizedHostname = normalizedHostname.slice(1, -1);
|
|
186
|
+
while (normalizedHostname.endsWith(".")) normalizedHostname = normalizedHostname.slice(0, -1);
|
|
187
|
+
return normalizedHostname;
|
|
188
|
+
}
|
|
189
|
+
function parseIPv4Address(ip) {
|
|
190
|
+
const parts = ip.split(".");
|
|
191
|
+
if (parts.length !== 4) return;
|
|
192
|
+
const octets = parts.map((part) => {
|
|
193
|
+
if (!/^\d+$/.test(part)) return NaN;
|
|
194
|
+
return Number(part);
|
|
195
|
+
});
|
|
196
|
+
if (octets.some((octet) => !Number.isInteger(octet) || octet < 0 || octet > 255)) return;
|
|
197
|
+
return octets;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Helper function to check if an IPv4 address is in a non-public range.
|
|
201
|
+
*/
|
|
202
|
+
function isUnsafeIPv4Address([a, b, c, d]) {
|
|
203
|
+
return a === 0 || a === 10 || a === 127 || a === 100 && b >= 64 && b <= 127 || a === 169 && b === 254 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 0 && c === 0 || a === 192 && b === 168 || a === 198 && (b === 18 || b === 19) || a >= 224 || a === 255 && b === 255 && c === 255 && d === 255;
|
|
204
|
+
}
|
|
205
|
+
function parseIPv6Address(ip) {
|
|
206
|
+
if (!ip.includes(":")) return;
|
|
207
|
+
let normalizedIP = ip;
|
|
208
|
+
const lastSeparator = normalizedIP.lastIndexOf(":");
|
|
209
|
+
const possibleIPv4 = normalizedIP.slice(lastSeparator + 1);
|
|
210
|
+
if (possibleIPv4.includes(".")) {
|
|
211
|
+
const ipv4 = parseIPv4Address(possibleIPv4);
|
|
212
|
+
if (!ipv4) return;
|
|
213
|
+
const firstGroup = ipv4[0] * 256 + ipv4[1];
|
|
214
|
+
const secondGroup = ipv4[2] * 256 + ipv4[3];
|
|
215
|
+
normalizedIP = `${normalizedIP.slice(0, lastSeparator + 1)}${firstGroup.toString(16)}:${secondGroup.toString(16)}`;
|
|
216
|
+
}
|
|
217
|
+
const halves = normalizedIP.split("::");
|
|
218
|
+
if (halves.length > 2) return;
|
|
219
|
+
const head = parseIPv6Groups(halves[0]);
|
|
220
|
+
const tail = halves.length === 2 ? parseIPv6Groups(halves[1]) : [];
|
|
221
|
+
if (!head || !tail) return;
|
|
222
|
+
if (halves.length === 1) return head.length === 8 ? head : void 0;
|
|
223
|
+
const missingGroups = 8 - head.length - tail.length;
|
|
224
|
+
if (missingGroups < 1) return;
|
|
225
|
+
return [
|
|
226
|
+
...head,
|
|
227
|
+
...Array(missingGroups).fill(0),
|
|
228
|
+
...tail
|
|
229
|
+
];
|
|
230
|
+
}
|
|
231
|
+
function parseIPv6Groups(groups) {
|
|
232
|
+
if (!groups) return [];
|
|
233
|
+
const parsedGroups = groups.split(":").map((group) => {
|
|
234
|
+
if (!/^[\da-f]{1,4}$/i.test(group)) return NaN;
|
|
235
|
+
return Number.parseInt(group, 16);
|
|
236
|
+
});
|
|
237
|
+
if (parsedGroups.some((group) => !Number.isInteger(group) || group < 0 || group > 65535)) return;
|
|
238
|
+
return parsedGroups;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Helper function to check if an IPv6 address is in a non-public range.
|
|
195
242
|
*/
|
|
196
|
-
function
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
243
|
+
function isUnsafeIPv6Address(groups) {
|
|
244
|
+
if (groups.length !== 8) return false;
|
|
245
|
+
const isUnspecified = groups.every((group) => group === 0);
|
|
246
|
+
const isLoopback = groups.slice(0, 7).every((group) => group === 0) && groups[7] === 1;
|
|
247
|
+
const isUniqueLocal = (groups[0] & 65024) === 64512;
|
|
248
|
+
const isLinkLocal = (groups[0] & 65472) === 65152;
|
|
249
|
+
const isMulticast = (groups[0] & 65280) === 65280;
|
|
250
|
+
if (isUnspecified || isLoopback || isUniqueLocal || isLinkLocal || isMulticast) return true;
|
|
251
|
+
const mappedIPv4 = getMappedIPv4Address(groups);
|
|
252
|
+
return mappedIPv4 ? isUnsafeIPv4Address(mappedIPv4) : false;
|
|
253
|
+
}
|
|
254
|
+
function getMappedIPv4Address(groups) {
|
|
255
|
+
const firstFiveGroupsAreZero = groups.slice(0, 5).every((group) => group === 0);
|
|
256
|
+
const firstSixGroupsAreZero = firstFiveGroupsAreZero && groups[5] === 0;
|
|
257
|
+
const isIPv4Mapped = firstFiveGroupsAreZero && groups[5] === 65535;
|
|
258
|
+
if (!firstSixGroupsAreZero && !isIPv4Mapped) return;
|
|
259
|
+
return [
|
|
260
|
+
Math.floor(groups[6] / 256),
|
|
261
|
+
groups[6] % 256,
|
|
262
|
+
Math.floor(groups[7] / 256),
|
|
263
|
+
groups[7] % 256
|
|
264
|
+
];
|
|
265
|
+
}
|
|
266
|
+
function containsUnsafeHostname(value) {
|
|
267
|
+
return value.split(/[\s/?#]+/).map((candidate) => candidate.replace(/^[a-z][\d+.a-z-]*:\/\//i, "").replace(/:\d+$/, "")).filter(Boolean).some((candidate) => isUnsafeHostname(candidate));
|
|
202
268
|
}
|
|
203
269
|
/**
|
|
204
270
|
* Helper function to check if a port is typically used for internal services
|
package/dist/schema/bundle.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { bundle } from "../node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.
|
|
1
|
+
import { bundle } from "../node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.js";
|
|
2
2
|
export { bundle };
|
package/dist/schema/bundle.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { bundle } from "../node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.
|
|
1
|
+
import { bundle } from "../node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.js";
|
|
2
2
|
export { bundle };
|
package/dist/schema/to-string.js
CHANGED
|
@@ -24,6 +24,12 @@ function schemaToString(value, resolver, flags = 0) {
|
|
|
24
24
|
const { dereferenced: schema, $ref: rawRef } = resolver?.(input) ?? { dereferenced: input };
|
|
25
25
|
if (schema === true) return "any";
|
|
26
26
|
else if (schema === false) return "never";
|
|
27
|
+
if (schema.enum?.length === 1) switch (typeof schema.enum[0]) {
|
|
28
|
+
case "bigint":
|
|
29
|
+
case "boolean":
|
|
30
|
+
case "number":
|
|
31
|
+
case "string": return JSON.stringify(schema.enum[0]);
|
|
32
|
+
}
|
|
27
33
|
if ((flags & 1) === 1) {
|
|
28
34
|
if (schema.title) return schema.title;
|
|
29
35
|
if (typeof rawRef === "string") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fumadocs/api-docs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Shared utils for API docs generation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Docs",
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
"homepage": "https://fumadocs.dev",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"author": "Fuma Nama",
|
|
12
|
-
"repository":
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "github:fuma-nama/fumadocs"
|
|
15
|
+
},
|
|
13
16
|
"files": [
|
|
14
17
|
"css",
|
|
15
18
|
"dist"
|
|
@@ -47,28 +50,28 @@
|
|
|
47
50
|
"access": "public"
|
|
48
51
|
},
|
|
49
52
|
"dependencies": {
|
|
50
|
-
"@fuma-translate/react": "^1.0.
|
|
51
|
-
"@radix-ui/react-accordion": "^1.2.
|
|
52
|
-
"@radix-ui/react-dialog": "^1.1.
|
|
53
|
-
"@radix-ui/react-select": "^2.3.
|
|
53
|
+
"@fuma-translate/react": "^1.0.2",
|
|
54
|
+
"@radix-ui/react-accordion": "^1.2.14",
|
|
55
|
+
"@radix-ui/react-dialog": "^1.1.17",
|
|
56
|
+
"@radix-ui/react-select": "^2.3.1",
|
|
54
57
|
"class-variance-authority": "^0.7.1",
|
|
55
58
|
"github-slugger": "^2.0.0",
|
|
56
59
|
"js-yaml": "^4.2.0",
|
|
57
|
-
"lucide-react": "^1.
|
|
60
|
+
"lucide-react": "^1.20.0",
|
|
58
61
|
"tailwind-merge": "^3.6.0",
|
|
59
62
|
"@fumari/stf": "1.0.5"
|
|
60
63
|
},
|
|
61
64
|
"devDependencies": {
|
|
62
|
-
"@apidevtools/json-schema-ref-parser": "^15.3.
|
|
65
|
+
"@apidevtools/json-schema-ref-parser": "^15.3.6",
|
|
63
66
|
"@fastify/deepmerge": "^3.2.1",
|
|
64
|
-
"@tailwindcss/oxide": "^4.3.
|
|
65
|
-
"@types/node": "25.9.
|
|
67
|
+
"@tailwindcss/oxide": "^4.3.1",
|
|
68
|
+
"@types/node": "25.9.3",
|
|
66
69
|
"@types/react": "^19.2.17",
|
|
67
70
|
"ajv": "^8.20.0",
|
|
68
71
|
"json-schema-typed": "^8.0.2",
|
|
69
|
-
"tsdown": "0.22.
|
|
70
|
-
"fumadocs-
|
|
71
|
-
"fumadocs-
|
|
72
|
+
"tsdown": "0.22.3",
|
|
73
|
+
"fumadocs-ui": "16.10.5",
|
|
74
|
+
"fumadocs-core": "16.10.5",
|
|
72
75
|
"tsconfig": "0.0.0"
|
|
73
76
|
},
|
|
74
77
|
"peerDependencies": {
|
|
@@ -88,7 +91,7 @@
|
|
|
88
91
|
}
|
|
89
92
|
},
|
|
90
93
|
"inlinedDependencies": {
|
|
91
|
-
"@apidevtools/json-schema-ref-parser": "15.3.
|
|
94
|
+
"@apidevtools/json-schema-ref-parser": "15.3.6",
|
|
92
95
|
"@fastify/deepmerge": "3.2.1",
|
|
93
96
|
"ajv": "8.20.0",
|
|
94
97
|
"fast-deep-equal": "3.1.3",
|