@fumadocs/api-docs 0.0.3 → 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/css/generated/shared.css +1 -1
- package/dist/components/accordion.d.ts +9 -6
- package/dist/components/accordion.js +16 -12
- package/dist/components/collapsible.d.ts +16 -0
- package/dist/components/collapsible.js +16 -0
- package/dist/components/dialog.d.ts +9 -9
- package/dist/components/dialog.js +12 -12
- package/dist/components/input.d.ts +8 -3
- package/dist/components/input.js +3 -4
- package/dist/components/playground/inputs.js +42 -30
- package/dist/components/popover.d.ts +15 -0
- package/dist/components/popover.js +23 -0
- package/dist/components/schema/client.js +34 -32
- package/dist/components/select-tab.js +3 -5
- package/dist/components/select.d.ts +46 -12
- package/dist/components/select.js +78 -66
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/index.js +1 -1
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/resolve.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/rules.js +1 -1
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js +1 -1
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/core.js +1 -1
- package/dist/ref-parser/bundle.d.ts +10 -0
- package/dist/{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-parser}/bundle.js +76 -6
- package/dist/{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-parser}/normalize-args.js +2 -2
- package/dist/ref-parser/options.d.ts +28 -0
- package/dist/ref-parser/options.js +27 -0
- package/dist/{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-parser}/parse.js +1 -1
- package/dist/{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-parser}/parsers/json.js +1 -1
- package/dist/{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-parser}/parsers/yaml.js +6 -12
- package/dist/ref-parser/pointer.d.ts +1 -0
- package/dist/{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-parser}/pointer.js +16 -54
- package/dist/ref-parser/ref.d.ts +1 -0
- package/dist/{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-parser}/ref.js +7 -49
- package/dist/ref-parser/refs.d.ts +1 -0
- package/dist/{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-parser}/refs.js +4 -41
- package/dist/{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-parser}/resolve-external.js +3 -3
- package/dist/{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-parser}/resolvers/file.js +1 -1
- package/dist/{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-parser}/types/index.d.ts +8 -40
- package/dist/{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-parser}/util/convert-path-to-posix.js +1 -1
- package/dist/ref-parser/util/errors.d.ts +1 -0
- package/dist/{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-parser}/util/errors.js +16 -34
- package/dist/ref-parser/util/is-windows.js +5 -0
- package/dist/{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-parser}/util/maybe.js +1 -1
- package/dist/{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-parser}/util/next.js +1 -1
- package/dist/{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-parser}/util/plugins.js +1 -1
- package/dist/{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-parser}/util/schema-resources.js +1 -1
- package/dist/ref-parser/util/url.js +206 -0
- package/dist/schema/bundle.d.ts +1 -1
- package/dist/schema/bundle.js +1 -1
- package/dist/schema/ref.d.ts +3 -1
- package/dist/schema/ref.js +1 -1
- package/dist/schema/sample.js +5 -7
- package/dist/utils/cn.js +1 -1
- package/dist/utils/deep-merge.js +8 -0
- package/package.json +12 -14
- package/dist/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 +0 -187
- package/dist/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 +0 -157
- package/dist/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 +0 -136
- package/dist/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 +0 -166
- package/dist/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 +0 -124
- package/dist/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 +0 -30
- package/dist/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 +0 -36
- package/dist/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 +0 -96
- package/dist/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 +0 -190
- package/dist/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 +0 -134
- package/dist/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 +0 -121
- package/dist/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 +0 -34
- package/dist/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 +0 -5
- package/dist/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 +0 -381
|
@@ -1,16 +1,50 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Select as Select$1 } from "@base-ui/react/select";
|
|
3
3
|
|
|
4
4
|
//#region src/components/select.d.ts
|
|
5
|
-
declare const Select:
|
|
6
|
-
declare const SelectGroup: React.ForwardRefExoticComponent<
|
|
7
|
-
declare const SelectValue: React.ForwardRefExoticComponent<
|
|
8
|
-
declare
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
declare
|
|
5
|
+
declare const Select: typeof Select$1.Root;
|
|
6
|
+
declare const SelectGroup: React.ForwardRefExoticComponent<Omit<import("@base-ui/react").SelectGroupProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
declare const SelectValue: React.ForwardRefExoticComponent<Omit<import("@base-ui/react").SelectValueProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
8
|
+
declare function SelectTrigger({
|
|
9
|
+
className,
|
|
10
|
+
children,
|
|
11
|
+
ref,
|
|
12
|
+
...props
|
|
13
|
+
}: React.ComponentProps<typeof Select$1.Trigger>): React.JSX.Element;
|
|
14
|
+
declare function SelectScrollUpButton({
|
|
15
|
+
className,
|
|
16
|
+
ref,
|
|
17
|
+
...props
|
|
18
|
+
}: React.ComponentProps<typeof Select$1.ScrollUpArrow>): React.JSX.Element;
|
|
19
|
+
declare function SelectScrollDownButton({
|
|
20
|
+
className,
|
|
21
|
+
ref,
|
|
22
|
+
...props
|
|
23
|
+
}: React.ComponentProps<typeof Select$1.ScrollDownArrow>): React.JSX.Element;
|
|
24
|
+
declare function SelectContent({
|
|
25
|
+
className,
|
|
26
|
+
children,
|
|
27
|
+
align,
|
|
28
|
+
side,
|
|
29
|
+
sideOffset,
|
|
30
|
+
ref,
|
|
31
|
+
...props
|
|
32
|
+
}: React.ComponentProps<typeof Select$1.Popup> & Pick<React.ComponentProps<typeof Select$1.Positioner>, 'align' | 'side' | 'sideOffset'>): React.JSX.Element;
|
|
33
|
+
declare function SelectLabel({
|
|
34
|
+
className,
|
|
35
|
+
ref,
|
|
36
|
+
...props
|
|
37
|
+
}: React.ComponentProps<typeof Select$1.GroupLabel>): React.JSX.Element;
|
|
38
|
+
declare function SelectItem({
|
|
39
|
+
className,
|
|
40
|
+
children,
|
|
41
|
+
ref,
|
|
42
|
+
...props
|
|
43
|
+
}: React.ComponentProps<typeof Select$1.Item>): React.JSX.Element;
|
|
44
|
+
declare function SelectSeparator({
|
|
45
|
+
className,
|
|
46
|
+
ref,
|
|
47
|
+
...props
|
|
48
|
+
}: React.ComponentProps<typeof Select$1.Separator>): React.JSX.Element;
|
|
15
49
|
//#endregion
|
|
16
50
|
export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue };
|
|
@@ -1,72 +1,84 @@
|
|
|
1
1
|
import { cn } from "../utils/cn.js";
|
|
2
|
-
import
|
|
2
|
+
import "react";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { Check, ChevronDown, ChevronUp } from "lucide-react";
|
|
5
|
-
import
|
|
5
|
+
import { Select as Select$1 } from "@base-ui/react/select";
|
|
6
6
|
//#region src/components/select.tsx
|
|
7
|
-
const Select =
|
|
8
|
-
const SelectGroup =
|
|
9
|
-
const SelectValue =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
7
|
+
const Select = Select$1.Root;
|
|
8
|
+
const SelectGroup = Select$1.Group;
|
|
9
|
+
const SelectValue = Select$1.Value;
|
|
10
|
+
function SelectTrigger({ className, children, ref, ...props }) {
|
|
11
|
+
return /* @__PURE__ */ jsxs(Select$1.Trigger, {
|
|
12
|
+
ref,
|
|
13
|
+
className: cn("flex items-center w-full rounded-md border p-2 gap-2 text-start text-sm text-fd-secondary-foreground bg-fd-secondary hover:bg-fd-accent focus:outline-none focus:ring focus:ring-fd-ring disabled:cursor-not-allowed disabled:opacity-50 data-placeholder:text-fd-muted-foreground", className),
|
|
14
|
+
...props,
|
|
15
|
+
children: [children, /* @__PURE__ */ jsx(Select$1.Icon, {
|
|
16
|
+
className: "ms-auto text-fd-muted-foreground shrink-0",
|
|
17
|
+
children: /* @__PURE__ */ jsx(ChevronDown, { className: "size-3.5" })
|
|
18
|
+
})]
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function SelectScrollUpButton({ className, ref, ...props }) {
|
|
22
|
+
return /* @__PURE__ */ jsx(Select$1.ScrollUpArrow, {
|
|
23
|
+
ref,
|
|
24
|
+
className: cn("flex items-center justify-center py-1", className),
|
|
25
|
+
...props,
|
|
26
|
+
children: /* @__PURE__ */ jsx(ChevronUp, { className: "size-4" })
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function SelectScrollDownButton({ className, ref, ...props }) {
|
|
30
|
+
return /* @__PURE__ */ jsx(Select$1.ScrollDownArrow, {
|
|
31
|
+
ref,
|
|
32
|
+
className: cn("flex items-center justify-center py-1", className),
|
|
33
|
+
...props,
|
|
34
|
+
children: /* @__PURE__ */ jsx(ChevronDown, { className: "size-4" })
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function SelectContent({ className, children, align = "start", side = "bottom", sideOffset = 4, ref, ...props }) {
|
|
38
|
+
return /* @__PURE__ */ jsx(Select$1.Portal, { children: /* @__PURE__ */ jsx(Select$1.Positioner, {
|
|
39
|
+
align,
|
|
40
|
+
side,
|
|
41
|
+
sideOffset,
|
|
42
|
+
className: "z-50",
|
|
43
|
+
children: /* @__PURE__ */ jsxs(Select$1.Popup, {
|
|
44
|
+
ref,
|
|
45
|
+
className: cn("z-50 min-w-(--anchor-width) overflow-hidden rounded-lg border bg-fd-popover text-fd-popover-foreground shadow-md", className),
|
|
46
|
+
...props,
|
|
47
|
+
children: [
|
|
48
|
+
/* @__PURE__ */ jsx(SelectScrollUpButton, {}),
|
|
49
|
+
/* @__PURE__ */ jsx(Select$1.List, {
|
|
50
|
+
className: "p-1",
|
|
51
|
+
children
|
|
52
|
+
}),
|
|
53
|
+
/* @__PURE__ */ jsx(SelectScrollDownButton, {})
|
|
54
|
+
]
|
|
55
|
+
})
|
|
56
|
+
}) });
|
|
57
|
+
}
|
|
58
|
+
function SelectLabel({ className, ref, ...props }) {
|
|
59
|
+
return /* @__PURE__ */ jsx(Select$1.GroupLabel, {
|
|
60
|
+
ref,
|
|
61
|
+
className: cn("py-1.5 pe-2 ps-6 text-sm font-semibold", className),
|
|
62
|
+
...props
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function SelectItem({ className, children, ref, ...props }) {
|
|
66
|
+
return /* @__PURE__ */ jsxs(Select$1.Item, {
|
|
67
|
+
ref,
|
|
68
|
+
className: cn("flex select-none flex-row items-center rounded-md py-1.5 px-2 text-sm outline-none data-[highlighted]:bg-fd-accent data-[highlighted]:text-fd-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className),
|
|
69
|
+
...props,
|
|
70
|
+
children: [/* @__PURE__ */ jsx(Select$1.ItemText, { children }), /* @__PURE__ */ jsx(Select$1.ItemIndicator, {
|
|
71
|
+
className: "ms-auto",
|
|
72
|
+
children: /* @__PURE__ */ jsx(Check, { className: "size-3.5 text-fd-primary" })
|
|
73
|
+
})]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function SelectSeparator({ className, ref, ...props }) {
|
|
77
|
+
return /* @__PURE__ */ jsx(Select$1.Separator, {
|
|
78
|
+
ref,
|
|
79
|
+
className: cn("my-1 h-px bg-fd-muted", className),
|
|
80
|
+
...props
|
|
81
|
+
});
|
|
82
|
+
}
|
|
71
83
|
//#endregion
|
|
72
84
|
export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue };
|
|
@@ -185,7 +185,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
185
185
|
return getJsonPointer.call(this, p, schOrRef);
|
|
186
186
|
}
|
|
187
187
|
exports.resolveSchema = resolveSchema;
|
|
188
|
-
const PREVENT_SCOPE_CHANGE = new Set([
|
|
188
|
+
const PREVENT_SCOPE_CHANGE = /* @__PURE__ */ new Set([
|
|
189
189
|
"properties",
|
|
190
190
|
"patternProperties",
|
|
191
191
|
"enum",
|
|
@@ -9,7 +9,7 @@ var require_resolve = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
9
9
|
const util_1 = require_util();
|
|
10
10
|
const equal = require_fast_deep_equal();
|
|
11
11
|
const traverse = require_json_schema_traverse();
|
|
12
|
-
const SIMPLE_INLINED = new Set([
|
|
12
|
+
const SIMPLE_INLINED = /* @__PURE__ */ new Set([
|
|
13
13
|
"type",
|
|
14
14
|
"format",
|
|
15
15
|
"pattern",
|
|
@@ -34,7 +34,7 @@ var require_resolve = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
34
34
|
return countKeys(schema) <= limit;
|
|
35
35
|
}
|
|
36
36
|
exports.inlineRef = inlineRef;
|
|
37
|
-
const REF_KEYWORDS = new Set([
|
|
37
|
+
const REF_KEYWORDS = /* @__PURE__ */ new Set([
|
|
38
38
|
"$ref",
|
|
39
39
|
"$recursiveRef",
|
|
40
40
|
"$recursiveAnchor",
|
|
@@ -3,7 +3,7 @@ import { __commonJSMin } from "../../../../../../../_virtual/_rolldown/runtime.j
|
|
|
3
3
|
var require_rules = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.getRules = exports.isJSONType = void 0;
|
|
6
|
-
const jsonTypes = new Set([
|
|
6
|
+
const jsonTypes = /* @__PURE__ */ new Set([
|
|
7
7
|
"string",
|
|
8
8
|
"number",
|
|
9
9
|
"integer",
|
package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js
CHANGED
|
@@ -49,7 +49,7 @@ var require_dataType = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
49
49
|
return checkTypes;
|
|
50
50
|
}
|
|
51
51
|
exports.coerceAndCheckDataType = coerceAndCheckDataType;
|
|
52
|
-
const COERCIBLE = new Set([
|
|
52
|
+
const COERCIBLE = /* @__PURE__ */ new Set([
|
|
53
53
|
"string",
|
|
54
54
|
"number",
|
|
55
55
|
"integer",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JSONSchema, SchemaCallback } from "./types/index.js";
|
|
2
|
+
import { BundleOptions, ParserOptions } from "./options.js";
|
|
3
|
+
//#region src/ref-parser/bundle.d.ts
|
|
4
|
+
declare function bundle<S extends object = JSONSchema>(schema: S | string, options?: ParserOptions<S>): Promise<S>;
|
|
5
|
+
declare function bundle<S extends object = JSONSchema>(schema: S | string, callback: SchemaCallback<S>): Promise<void>;
|
|
6
|
+
declare function bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
7
|
+
declare function bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(path: string, schema: S | string, options: O): Promise<S>;
|
|
8
|
+
declare function bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(path: string, schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { bundle };
|
|
@@ -1,8 +1,76 @@
|
|
|
1
|
-
import { getHash, resolve, stripHash } from "./util/url.js";
|
|
2
|
-
import {
|
|
1
|
+
import { cwd, fromFileSystemPath, getHash, isFileSystemPath, resolve, stripHash } from "./util/url.js";
|
|
2
|
+
import { JSONParserErrorGroup, isHandledError } from "./util/errors.js";
|
|
3
|
+
import { getSchemaBasePath, registerSchemaResources, usesDynamicIdScope } from "./util/schema-resources.js";
|
|
3
4
|
import Pointer from "./pointer.js";
|
|
4
5
|
import $Ref from "./ref.js";
|
|
5
|
-
|
|
6
|
+
import $Refs from "./refs.js";
|
|
7
|
+
import parse from "./parse.js";
|
|
8
|
+
import normalizeArgs from "./normalize-args.js";
|
|
9
|
+
import resolveExternal from "./resolve-external.js";
|
|
10
|
+
import maybe from "./util/maybe.js";
|
|
11
|
+
//#region src/ref-parser/bundle.ts
|
|
12
|
+
/**
|
|
13
|
+
* Internal parser state used by the bundle pipeline.
|
|
14
|
+
*/
|
|
15
|
+
var $RefParser = class {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.schema = null;
|
|
18
|
+
this.$refs = new $Refs();
|
|
19
|
+
}
|
|
20
|
+
async parse(path, schema, options) {
|
|
21
|
+
this.schema = null;
|
|
22
|
+
this.$refs = new $Refs();
|
|
23
|
+
if (!path && !schema) throw new Error(`Expected a file path or object. Got ${path || schema}`);
|
|
24
|
+
let pathType = "file";
|
|
25
|
+
if (path && isFileSystemPath(path)) path = fromFileSystemPath(path);
|
|
26
|
+
path = resolve(cwd(), path || "");
|
|
27
|
+
if (schema && typeof schema === "object") {
|
|
28
|
+
const $ref = this.$refs._add(path);
|
|
29
|
+
$ref.value = schema;
|
|
30
|
+
$ref.pathType = pathType;
|
|
31
|
+
$ref.dynamicIdScope = usesDynamicIdScope($ref.value);
|
|
32
|
+
registerSchemaResources(this.$refs, $ref.path, $ref.value, $ref.pathType, $ref.dynamicIdScope);
|
|
33
|
+
this.schema = schema;
|
|
34
|
+
return schema;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const result = await parse(path, this.$refs, options);
|
|
38
|
+
if (result !== null && typeof result === "object" && !Buffer.isBuffer(result)) {
|
|
39
|
+
this.schema = result;
|
|
40
|
+
return this.schema;
|
|
41
|
+
}
|
|
42
|
+
throw new SyntaxError(`"${this.$refs._root$Ref.path || result}" is not a valid JSON Schema`);
|
|
43
|
+
} catch (err) {
|
|
44
|
+
if (!options.continueOnError || !isHandledError(err)) throw err;
|
|
45
|
+
if (this.$refs._$refs[stripHash(path)]) this.$refs._$refs[stripHash(path)].addError(err);
|
|
46
|
+
this.schema = null;
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async resolve(path, schema, options) {
|
|
51
|
+
await this.parse(path, schema, options);
|
|
52
|
+
await resolveExternal(this, options);
|
|
53
|
+
finalize(this);
|
|
54
|
+
return this.$refs;
|
|
55
|
+
}
|
|
56
|
+
async runBundle(path, schema, options, callback) {
|
|
57
|
+
try {
|
|
58
|
+
await this.resolve(path, schema, options);
|
|
59
|
+
inlineRefs(this, options);
|
|
60
|
+
finalize(this);
|
|
61
|
+
return maybe(callback, Promise.resolve(this.schema));
|
|
62
|
+
} catch (err) {
|
|
63
|
+
return maybe(callback, Promise.reject(err));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
function finalize(parser) {
|
|
68
|
+
if (JSONParserErrorGroup.getParserErrors(parser).length > 0) throw new JSONParserErrorGroup(parser);
|
|
69
|
+
}
|
|
70
|
+
async function bundle() {
|
|
71
|
+
const args = normalizeArgs(arguments);
|
|
72
|
+
return new $RefParser().runBundle(args.path, args.schema, args.options, args.callback);
|
|
73
|
+
}
|
|
6
74
|
/**
|
|
7
75
|
* Bundles all external JSON references into the main JSON schema, thus resulting in a schema that
|
|
8
76
|
* only has *internal* references, not any *external* references.
|
|
@@ -11,7 +79,7 @@ import $Ref from "./ref.js";
|
|
|
11
79
|
* @param parser
|
|
12
80
|
* @param options
|
|
13
81
|
*/
|
|
14
|
-
function
|
|
82
|
+
function inlineRefs(parser, options) {
|
|
15
83
|
const rootScopeBase = parser.$refs._root$Ref.dynamicIdScope ? getSchemaBasePath(parser.$refs._root$Ref.path, parser.schema) : parser.$refs._root$Ref.path;
|
|
16
84
|
const inventory = [];
|
|
17
85
|
crawl(parser, "schema", parser.$refs._root$Ref.path + "#", rootScopeBase, parser.$refs._root$Ref.dynamicIdScope, "#", 0, inventory, parser.$refs, options);
|
|
@@ -79,6 +147,7 @@ function inventory$Ref($refParent, $refKey, path, scopeBase, dynamicIdScope, pat
|
|
|
79
147
|
const file = stripHash(pointer.path);
|
|
80
148
|
const hash = getHash(pointer.path);
|
|
81
149
|
const external = file !== $refs._root$Ref.path && !$refs._aliases[file];
|
|
150
|
+
const nestedResource = Boolean($refs._aliases[file]) && pointer.$ref.value !== $refs._root$Ref.value;
|
|
82
151
|
const extended = $Ref.isExtended$Ref($ref);
|
|
83
152
|
indirections += pointer.indirections;
|
|
84
153
|
const existingEntry = findInInventory(inventory, $refParent, $refKey);
|
|
@@ -96,6 +165,7 @@ function inventory$Ref($refParent, $refKey, path, scopeBase, dynamicIdScope, pat
|
|
|
96
165
|
circular: pointer.circular,
|
|
97
166
|
extended,
|
|
98
167
|
external,
|
|
168
|
+
nestedResource,
|
|
99
169
|
indirections
|
|
100
170
|
});
|
|
101
171
|
if (!existingEntry || external) crawl(pointer.value, null, pointer.path, pointer.$ref.path, pointer.$ref.dynamicIdScope, pathFromRoot, indirections + 1, inventory, $refs, options);
|
|
@@ -141,7 +211,7 @@ function remap(inventory, options, rootId) {
|
|
|
141
211
|
for (const entry of inventory) {
|
|
142
212
|
const bundleOpts = options.bundle || {};
|
|
143
213
|
if (!entry.external) {
|
|
144
|
-
if (bundleOpts.optimizeInternalRefs !== false) entry.$ref.$ref = entry.hash;
|
|
214
|
+
if (bundleOpts.optimizeInternalRefs !== false && !entry.nestedResource) entry.$ref.$ref = entry.hash;
|
|
145
215
|
} else if (entry.file === file && entry.hash === hash) if (rootId && isInsideIdScope(inventory, entry)) entry.$ref.$ref = rootId + pathFromRoot;
|
|
146
216
|
else entry.$ref.$ref = pathFromRoot;
|
|
147
217
|
else if (entry.file === file && entry.hash.indexOf(hash + "/") === 0) {
|
|
@@ -236,4 +306,4 @@ function isInsideIdScope(inventory, entry) {
|
|
|
236
306
|
return false;
|
|
237
307
|
}
|
|
238
308
|
//#endregion
|
|
239
|
-
export { bundle
|
|
309
|
+
export { $RefParser, bundle };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getNewOptions } from "./options.js";
|
|
2
|
-
//#region
|
|
2
|
+
//#region src/ref-parser/normalize-args.ts
|
|
3
3
|
/**
|
|
4
4
|
* Normalizes the given arguments, accounting for optional args.
|
|
5
5
|
*/
|
|
@@ -38,4 +38,4 @@ function normalizeArgs(_args) {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
//#endregion
|
|
41
|
-
export { normalizeArgs as default };
|
|
41
|
+
export { normalizeArgs as default, normalizeArgs };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { JSONSchema, JSONSchemaObject, Plugin, ResolverOptions } from "./types/index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/ref-parser/options.d.ts
|
|
4
|
+
type DeepPartial<T> = T extends object ? { [P in keyof T]?: DeepPartial<T[P]> } : T;
|
|
5
|
+
interface BundleOptions {
|
|
6
|
+
excludedPathMatcher?(path: string): boolean;
|
|
7
|
+
onBundle?(path: string, value: JSONSchemaObject, parent?: JSONSchemaObject, parentPropName?: string): void;
|
|
8
|
+
optimizeInternalRefs?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface $RefParserOptions<S extends object = JSONSchema> {
|
|
11
|
+
parse: {
|
|
12
|
+
json?: Plugin | boolean;
|
|
13
|
+
yaml?: Plugin | boolean;
|
|
14
|
+
[key: string]: Plugin | boolean | undefined;
|
|
15
|
+
};
|
|
16
|
+
resolve: {
|
|
17
|
+
external?: boolean;
|
|
18
|
+
file?: Partial<ResolverOptions<S>> | boolean;
|
|
19
|
+
} & {
|
|
20
|
+
[key: string]: Partial<ResolverOptions<S>> | boolean | undefined;
|
|
21
|
+
};
|
|
22
|
+
continueOnError: boolean;
|
|
23
|
+
bundle: BundleOptions;
|
|
24
|
+
mutateInputSchema?: boolean;
|
|
25
|
+
}
|
|
26
|
+
type ParserOptions<S extends object = JSONSchema> = DeepPartial<$RefParserOptions<S>>;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { $RefParserOptions, BundleOptions, DeepPartial, ParserOptions };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { mergeDeep } from "../utils/deep-merge.js";
|
|
2
|
+
import json_default from "./parsers/json.js";
|
|
3
|
+
import yaml_default from "./parsers/yaml.js";
|
|
4
|
+
import file_default from "./resolvers/file.js";
|
|
5
|
+
//#region src/ref-parser/options.ts
|
|
6
|
+
const getJsonSchemaRefParserDefaultOptions = () => {
|
|
7
|
+
return {
|
|
8
|
+
parse: {
|
|
9
|
+
json: { ...json_default },
|
|
10
|
+
yaml: { ...yaml_default }
|
|
11
|
+
},
|
|
12
|
+
resolve: {
|
|
13
|
+
file: { ...file_default },
|
|
14
|
+
external: true
|
|
15
|
+
},
|
|
16
|
+
continueOnError: false,
|
|
17
|
+
bundle: { excludedPathMatcher: () => false },
|
|
18
|
+
mutateInputSchema: true
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
const getNewOptions = (options) => {
|
|
22
|
+
const defaults = getJsonSchemaRefParserDefaultOptions();
|
|
23
|
+
if (!options) return defaults;
|
|
24
|
+
return mergeDeep(defaults, options);
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { getJsonSchemaRefParserDefaultOptions, getNewOptions };
|
|
@@ -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
|
|
5
|
+
//#region src/ref-parser/parse.ts
|
|
6
6
|
/**
|
|
7
7
|
* Reads and parses the specified file path or URL.
|
|
8
8
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParserError } from "../util/errors.js";
|
|
2
|
-
//#region
|
|
2
|
+
//#region src/ref-parser/parsers/json.ts
|
|
3
3
|
var json_default = {
|
|
4
4
|
/**
|
|
5
5
|
* The order that this parser will run, in relation to other parsers.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ParserError } from "../util/errors.js";
|
|
2
|
-
import
|
|
3
|
-
//#region
|
|
2
|
+
import { JSON_SCHEMA, load } from "js-yaml";
|
|
3
|
+
//#region src/ref-parser/parsers/yaml.ts
|
|
4
4
|
var yaml_default = {
|
|
5
5
|
/**
|
|
6
6
|
* The order that this parser will run, in relation to other parsers.
|
|
@@ -23,26 +23,20 @@ var yaml_default = {
|
|
|
23
23
|
],
|
|
24
24
|
/**
|
|
25
25
|
* Parses the given file as YAML
|
|
26
|
-
*
|
|
27
|
-
* @param file - An object containing information about the referenced file
|
|
28
|
-
* @param file.url - The full URL of the referenced file
|
|
29
|
-
* @param file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
|
|
30
|
-
* @param file.data - The file contents. This will be whatever data type was returned by the resolver
|
|
31
|
-
* @returns
|
|
32
26
|
*/
|
|
33
27
|
async parse(file) {
|
|
34
28
|
let data = file.data;
|
|
35
29
|
if (Buffer.isBuffer(data)) data = data.toString();
|
|
36
30
|
if (typeof data === "string") try {
|
|
37
|
-
return
|
|
31
|
+
return load(data, { schema: JSON_SCHEMA });
|
|
38
32
|
} catch {
|
|
39
33
|
try {
|
|
40
|
-
return
|
|
34
|
+
return load(data);
|
|
41
35
|
} catch (e) {
|
|
42
|
-
throw new ParserError(e
|
|
36
|
+
throw new ParserError(e instanceof Error ? e.message : "Parser Error", file.url);
|
|
43
37
|
}
|
|
44
38
|
}
|
|
45
|
-
|
|
39
|
+
return data;
|
|
46
40
|
}
|
|
47
41
|
};
|
|
48
42
|
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
+
import { appendInternalRefPath, decodeInternalRef } from "../schema/ref.js";
|
|
1
2
|
import { getHash, resolve, stripHash } from "./util/url.js";
|
|
2
3
|
import { InvalidPointerError, JSONParserError, MissingPointerError, isHandledError } from "./util/errors.js";
|
|
3
4
|
import { getSchemaBasePath } from "./util/schema-resources.js";
|
|
4
5
|
import $Ref from "./ref.js";
|
|
5
|
-
//#region
|
|
6
|
+
//#region src/ref-parser/pointer.ts
|
|
6
7
|
const nullSymbol = Symbol("null");
|
|
7
|
-
const
|
|
8
|
-
const tildes = /~/g;
|
|
9
|
-
const escapedSlash = /~1/g;
|
|
10
|
-
const escapedTilde = /~0/g;
|
|
11
|
-
const unsafeSetTokens = new Set([
|
|
8
|
+
const unsafeSetTokens = /* @__PURE__ */ new Set([
|
|
12
9
|
"__proto__",
|
|
13
10
|
"constructor",
|
|
14
11
|
"prototype"
|
|
@@ -22,37 +19,6 @@ const unsafeSetTokens = new Set([
|
|
|
22
19
|
* @class
|
|
23
20
|
*/
|
|
24
21
|
var Pointer = class Pointer {
|
|
25
|
-
/**
|
|
26
|
-
* The {@link $Ref} object that contains this {@link Pointer} object.
|
|
27
|
-
*/
|
|
28
|
-
$ref;
|
|
29
|
-
/**
|
|
30
|
-
* The file path or URL, containing the JSON pointer in the hash.
|
|
31
|
-
* This path is relative to the path of the main JSON schema file.
|
|
32
|
-
*/
|
|
33
|
-
path;
|
|
34
|
-
/**
|
|
35
|
-
* The original path or URL, used for error messages.
|
|
36
|
-
*/
|
|
37
|
-
originalPath;
|
|
38
|
-
/**
|
|
39
|
-
* The current base URI used to resolve nested $ref pointers while walking this pointer.
|
|
40
|
-
*/
|
|
41
|
-
scopeBase;
|
|
42
|
-
/**
|
|
43
|
-
* The value of the JSON pointer.
|
|
44
|
-
* Can be any JSON type, not just objects. Unknown file types are represented as Buffers (byte arrays).
|
|
45
|
-
*/
|
|
46
|
-
value;
|
|
47
|
-
/**
|
|
48
|
-
* Indicates whether the pointer references itself.
|
|
49
|
-
*/
|
|
50
|
-
circular;
|
|
51
|
-
/**
|
|
52
|
-
* The number of indirect references that were traversed to resolve the value.
|
|
53
|
-
* Resolving a single pointer may require resolving multiple $Refs.
|
|
54
|
-
*/
|
|
55
|
-
indirections;
|
|
56
22
|
constructor($ref, path, friendlyPath) {
|
|
57
23
|
this.$ref = $ref;
|
|
58
24
|
this.path = path;
|
|
@@ -161,28 +127,24 @@ var Pointer = class Pointer {
|
|
|
161
127
|
* @returns
|
|
162
128
|
*/
|
|
163
129
|
static parse(path, originalPath) {
|
|
164
|
-
const
|
|
165
|
-
if (!
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
130
|
+
const hash = getHash(path);
|
|
131
|
+
if (!hash || hash === "#") return [];
|
|
132
|
+
try {
|
|
133
|
+
return decodeInternalRef(hash);
|
|
134
|
+
} catch {
|
|
135
|
+
throw new InvalidPointerError(hash.slice(1), originalPath === void 0 ? path : originalPath);
|
|
136
|
+
}
|
|
170
137
|
}
|
|
171
138
|
/**
|
|
172
139
|
* Creates a JSON pointer path, by joining one or more tokens to a base path.
|
|
173
|
-
*
|
|
174
|
-
* @param base - The base path (e.g. "schema.json#/definitions/person")
|
|
175
|
-
* @param tokens - The token(s) to append (e.g. ["name", "first"])
|
|
176
|
-
* @returns
|
|
177
140
|
*/
|
|
178
141
|
static join(base, tokens) {
|
|
179
|
-
if (base.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
return base;
|
|
142
|
+
if (!base.includes("#")) base += "#";
|
|
143
|
+
const hashIndex = base.indexOf("#");
|
|
144
|
+
const prefix = base.slice(0, hashIndex);
|
|
145
|
+
let pointer = base.slice(hashIndex);
|
|
146
|
+
for (const token of Array.isArray(tokens) ? tokens : [tokens]) pointer = appendInternalRefPath(pointer, token);
|
|
147
|
+
return prefix + pointer;
|
|
186
148
|
}
|
|
187
149
|
};
|
|
188
150
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|