@powerduck/schema-designer 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/README.md +217 -0
- package/dist/InlineSchemaEditor-BssSx3SI.d.ts +6 -0
- package/dist/InlineSchemaEditor-Bua-lDhE.d.cts +6 -0
- package/dist/chunk-2XUQB6BQ.js +1896 -0
- package/dist/chunk-4H3LXOL4.cjs +1900 -0
- package/dist/chunk-7LG4MVMD.cjs +2 -0
- package/dist/chunk-BXFABOMJ.js +1475 -0
- package/dist/chunk-FTALJIVZ.js +1 -0
- package/dist/chunk-GTZH37JS.cjs +1120 -0
- package/dist/chunk-GWHDTTQK.js +1437 -0
- package/dist/chunk-GXXD6ITE.cjs +1477 -0
- package/dist/chunk-HI5FBHCO.js +1057 -0
- package/dist/chunk-KX3LFFOV.js +88 -0
- package/dist/chunk-MADPN2PJ.js +185 -0
- package/dist/chunk-NOUORNCI.cjs +1452 -0
- package/dist/chunk-O6PTRJQ5.js +1195 -0
- package/dist/chunk-OBHJC3I2.cjs +2 -0
- package/dist/chunk-OOSNM45O.cjs +264 -0
- package/dist/chunk-P5B3HSPY.js +244 -0
- package/dist/chunk-PBE36BVA.js +1 -0
- package/dist/chunk-PVEYKCM6.js +1 -0
- package/dist/chunk-QZADGAP3.cjs +1218 -0
- package/dist/chunk-S7GNTGEE.js +1 -0
- package/dist/chunk-SMBDRWV2.cjs +2 -0
- package/dist/chunk-THYDOHOP.cjs +2 -0
- package/dist/chunk-WRHWOMZQ.cjs +190 -0
- package/dist/chunk-YNKP5JJA.cjs +32 -0
- package/dist/chunk-YWDKCX6N.cjs +91 -0
- package/dist/chunk-ZHNYNFGL.js +28 -0
- package/dist/compat/inline.cjs +137 -0
- package/dist/compat/inline.css +275 -0
- package/dist/compat/inline.d.cts +6 -0
- package/dist/compat/inline.d.ts +6 -0
- package/dist/compat/inline.js +4 -0
- package/dist/compat/parameters.cjs +90 -0
- package/dist/compat/parameters.css +997 -0
- package/dist/compat/parameters.d.cts +70 -0
- package/dist/compat/parameters.d.ts +70 -0
- package/dist/compat/parameters.js +9 -0
- package/dist/compat/tree.cjs +142 -0
- package/dist/compat/tree.css +1069 -0
- package/dist/compat/tree.d.cts +4 -0
- package/dist/compat/tree.d.ts +4 -0
- package/dist/compat/tree.js +5 -0
- package/dist/compat/variable-editor.cjs +82 -0
- package/dist/compat/variable-editor.d.cts +68 -0
- package/dist/compat/variable-editor.d.ts +68 -0
- package/dist/compat/variable-editor.js +1 -0
- package/dist/core/index.cjs +197 -0
- package/dist/core/index.d.cts +21 -0
- package/dist/core/index.d.ts +21 -0
- package/dist/core/index.js +4 -0
- package/dist/index.cjs +35 -0
- package/dist/index.css +1791 -0
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +10 -0
- package/dist/parameterValue-2pL9n-3q.d.ts +8 -0
- package/dist/parameterValue-Cky9Lnd3.d.cts +8 -0
- package/dist/react/index.cjs +35 -0
- package/dist/react/index.css +1791 -0
- package/dist/react/index.d.cts +9 -0
- package/dist/react/index.d.ts +9 -0
- package/dist/react/index.js +10 -0
- package/dist/react/inlineSchemaEditor/index.cjs +97 -0
- package/dist/react/inlineSchemaEditor/index.css +275 -0
- package/dist/react/inlineSchemaEditor/index.d.cts +6 -0
- package/dist/react/inlineSchemaEditor/index.d.ts +6 -0
- package/dist/react/inlineSchemaEditor/index.js +4 -0
- package/dist/react/parametersTable/index.cjs +22 -0
- package/dist/react/parametersTable/index.css +997 -0
- package/dist/react/parametersTable/index.d.cts +7 -0
- package/dist/react/parametersTable/index.d.ts +7 -0
- package/dist/react/parametersTable/index.js +9 -0
- package/dist/react/parametersTable/libs/generateValue.cjs +558 -0
- package/dist/react/parametersTable/libs/generateValue.d.cts +17 -0
- package/dist/react/parametersTable/libs/generateValue.d.ts +17 -0
- package/dist/react/parametersTable/libs/generateValue.js +551 -0
- package/dist/react/schemaTreeEditor/index.cjs +18 -0
- package/dist/react/schemaTreeEditor/index.css +1069 -0
- package/dist/react/schemaTreeEditor/index.d.cts +7 -0
- package/dist/react/schemaTreeEditor/index.d.ts +7 -0
- package/dist/react/schemaTreeEditor/index.js +5 -0
- package/dist/react/variableTextEditor/index.cjs +11 -0
- package/dist/react/variableTextEditor/index.css +306 -0
- package/dist/react/variableTextEditor/index.d.cts +6 -0
- package/dist/react/variableTextEditor/index.d.ts +6 -0
- package/dist/react/variableTextEditor/index.js +2 -0
- package/dist/schema-CKAPsYeW.d.cts +41 -0
- package/dist/schema-o7OJRaJ8.d.ts +41 -0
- package/dist/styles.css +1791 -0
- package/dist/tree-D06Xa6_N.d.ts +95 -0
- package/dist/tree-Dq1Rk-CF.d.cts +95 -0
- package/dist/types-B27Dw9do.d.cts +163 -0
- package/dist/types-B27Dw9do.d.ts +163 -0
- package/dist/types-Bk9rzr6l.d.cts +48 -0
- package/dist/types-D2jEaM9Z.d.cts +145 -0
- package/dist/types-D2jEaM9Z.d.ts +145 -0
- package/dist/types-xAihO_KW.d.ts +48 -0
- package/dist/variableTextEditor.types-ClzvARvK.d.cts +49 -0
- package/dist/variableTextEditor.types-ClzvARvK.d.ts +49 -0
- package/package.json +130 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/** JSON Schema accepts both schema objects and unconditional boolean schemas. */
|
|
2
|
+
interface SchemaObject {
|
|
3
|
+
[keyword: string]: unknown;
|
|
4
|
+
}
|
|
5
|
+
type SchemaValue = SchemaObject | boolean;
|
|
6
|
+
type SchemaPatch = Partial<SchemaObject>;
|
|
7
|
+
|
|
8
|
+
type JSONSchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
|
|
9
|
+
declare const SCHEMA_TYPES: JSONSchemaType[];
|
|
10
|
+
/**
|
|
11
|
+
* Loose JSON Schema shape. Unknown keywords are preserved untouched,
|
|
12
|
+
* the editor never strips fields it does not understand.
|
|
13
|
+
*/
|
|
14
|
+
interface JSONSchema {
|
|
15
|
+
$ref?: string;
|
|
16
|
+
$id?: string;
|
|
17
|
+
$schema?: string;
|
|
18
|
+
$defs?: Record<string, JSONSchema | boolean>;
|
|
19
|
+
definitions?: Record<string, JSONSchema | boolean>;
|
|
20
|
+
components?: {
|
|
21
|
+
schemas?: Record<string, JSONSchema | boolean>;
|
|
22
|
+
};
|
|
23
|
+
type?: JSONSchemaType | JSONSchemaType[];
|
|
24
|
+
title?: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
default?: unknown;
|
|
27
|
+
examples?: unknown[];
|
|
28
|
+
enum?: unknown[];
|
|
29
|
+
const?: unknown;
|
|
30
|
+
format?: string;
|
|
31
|
+
properties?: Record<string, JSONSchema | boolean>;
|
|
32
|
+
patternProperties?: Record<string, JSONSchema | boolean>;
|
|
33
|
+
additionalProperties?: boolean | JSONSchema;
|
|
34
|
+
required?: string[];
|
|
35
|
+
items?: JSONSchema | boolean;
|
|
36
|
+
prefixItems?: (JSONSchema | boolean)[];
|
|
37
|
+
minimum?: number;
|
|
38
|
+
maximum?: number;
|
|
39
|
+
exclusiveMinimum?: number;
|
|
40
|
+
exclusiveMaximum?: number;
|
|
41
|
+
multipleOf?: number;
|
|
42
|
+
minLength?: number;
|
|
43
|
+
maxLength?: number;
|
|
44
|
+
pattern?: string;
|
|
45
|
+
minItems?: number;
|
|
46
|
+
maxItems?: number;
|
|
47
|
+
uniqueItems?: boolean;
|
|
48
|
+
allOf?: (JSONSchema | boolean)[];
|
|
49
|
+
anyOf?: (JSONSchema | boolean)[];
|
|
50
|
+
oneOf?: (JSONSchema | boolean)[];
|
|
51
|
+
not?: JSONSchema | boolean;
|
|
52
|
+
deprecated?: boolean;
|
|
53
|
+
readOnly?: boolean;
|
|
54
|
+
writeOnly?: boolean;
|
|
55
|
+
[keyword: string]: unknown;
|
|
56
|
+
}
|
|
57
|
+
/** Where a row lives relative to its parent container. */
|
|
58
|
+
type NodeKind = "property" | "items" | "root";
|
|
59
|
+
/** Visual role of a row inside a resolved $ref block. */
|
|
60
|
+
type RefSegment = "none" | "head" | "body" | "tail" | "single";
|
|
61
|
+
/** One rendered line of the flattened tree. */
|
|
62
|
+
interface FlatNode {
|
|
63
|
+
/** Stable identity, built from the schema path. */
|
|
64
|
+
id: string;
|
|
65
|
+
/** Property key, or a synthetic label for array items. */
|
|
66
|
+
key: string;
|
|
67
|
+
/** Path from the root schema down to this node's own schema object. */
|
|
68
|
+
path: string[];
|
|
69
|
+
/** Path to the parent container that owns `key`. */
|
|
70
|
+
parentPath: string[];
|
|
71
|
+
depth: number;
|
|
72
|
+
kind: NodeKind;
|
|
73
|
+
/** The raw schema at `path`, possibly just a `$ref` stub. */
|
|
74
|
+
schema: JSONSchema;
|
|
75
|
+
value: SchemaValue;
|
|
76
|
+
/** The dereferenced schema used for rendering, identical to `schema` when no ref. */
|
|
77
|
+
resolved: JSONSchema;
|
|
78
|
+
resolvedValue: SchemaValue;
|
|
79
|
+
required: boolean;
|
|
80
|
+
expandable: boolean;
|
|
81
|
+
expanded: boolean;
|
|
82
|
+
/** Name of the referenced definition, when this node is a `$ref`. */
|
|
83
|
+
refName?: string;
|
|
84
|
+
/** True when the ref points at an ancestor and expansion was stopped. */
|
|
85
|
+
recursive: boolean;
|
|
86
|
+
/** Position inside the resolved ref block, drives the block border styling. */
|
|
87
|
+
refSegment: RefSegment;
|
|
88
|
+
/** Rows inside a ref subtree are read-only to protect shared components. */
|
|
89
|
+
readOnly: boolean;
|
|
90
|
+
/** Sortable only among siblings of the same `properties` object. */
|
|
91
|
+
sortable: boolean;
|
|
92
|
+
}
|
|
93
|
+
/** Insert position requested from the row menu. */
|
|
94
|
+
type AddFieldMode = "sibling" | "child";
|
|
95
|
+
type SchemaEditorErrorScope = "clone" | "resolveRef" | "flatten" | "reorder" | "commit" | "render";
|
|
96
|
+
interface SchemaEditorError {
|
|
97
|
+
scope: SchemaEditorErrorScope;
|
|
98
|
+
message: string;
|
|
99
|
+
/** Original thrown value, kept as-is for logging. */
|
|
100
|
+
cause?: unknown;
|
|
101
|
+
/** Schema path where it happened, when known. */
|
|
102
|
+
path?: string[];
|
|
103
|
+
}
|
|
104
|
+
type SchemaErrorHandler = (error: SchemaEditorError) => void;
|
|
105
|
+
interface AdvancedEditorContext {
|
|
106
|
+
required?: boolean;
|
|
107
|
+
onRequiredChange?: (required: boolean) => void;
|
|
108
|
+
nested: boolean;
|
|
109
|
+
schema: SchemaValue;
|
|
110
|
+
schemaName: string;
|
|
111
|
+
fullSchema: JSONSchema;
|
|
112
|
+
path: string[];
|
|
113
|
+
readOnly: boolean;
|
|
114
|
+
update: (next: SchemaValue) => void;
|
|
115
|
+
}
|
|
116
|
+
interface SchemaTreeEditorProps {
|
|
117
|
+
/** Controlled schema. Must be treated as immutable by the host. */
|
|
118
|
+
schema: JSONSchema;
|
|
119
|
+
onChange: (next: JSONSchema) => void;
|
|
120
|
+
/** Optional list columns. Hidden attributes remain editable in settings. */
|
|
121
|
+
showType?: boolean;
|
|
122
|
+
showRequired?: boolean;
|
|
123
|
+
showDescription?: boolean;
|
|
124
|
+
document?: JSONSchema;
|
|
125
|
+
className?: string;
|
|
126
|
+
/** Disables every mutating affordance. */
|
|
127
|
+
readOnly?: boolean;
|
|
128
|
+
/** Keys expanded on first mount. Uncontrolled afterwards. */
|
|
129
|
+
defaultExpanded?: string[];
|
|
130
|
+
/** Max rows rendered before the overflow notice appears. */
|
|
131
|
+
maxRows?: number;
|
|
132
|
+
/** Renders the advanced settings popover body for a row. */
|
|
133
|
+
renderAdvanced?: (context: AdvancedEditorContext) => React.ReactNode;
|
|
134
|
+
/** Called on any recovered internal failure. The component stays alive. */
|
|
135
|
+
onError?: SchemaErrorHandler;
|
|
136
|
+
/** Verify incoming schema identity and shape on every prop change. Default true. */
|
|
137
|
+
strictExternalSchema?: boolean;
|
|
138
|
+
}
|
|
139
|
+
type SchemaDesignerTreeProps = Omit<SchemaTreeEditorProps, "schema" | "onChange"> & {
|
|
140
|
+
schema?: SchemaValue;
|
|
141
|
+
value?: SchemaValue;
|
|
142
|
+
onChange: (schema: SchemaValue) => void;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export { type AddFieldMode as A, type FlatNode as F, type JSONSchema as J, type NodeKind as N, type RefSegment as R, SCHEMA_TYPES as S, type AdvancedEditorContext as a, type JSONSchemaType as b, type SchemaDesignerTreeProps as c, type SchemaEditorError as d, type SchemaEditorErrorScope as e, type SchemaErrorHandler as f, type SchemaObject as g, type SchemaPatch as h, type SchemaValue as i };
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/** JSON Schema accepts both schema objects and unconditional boolean schemas. */
|
|
2
|
+
interface SchemaObject {
|
|
3
|
+
[keyword: string]: unknown;
|
|
4
|
+
}
|
|
5
|
+
type SchemaValue = SchemaObject | boolean;
|
|
6
|
+
type SchemaPatch = Partial<SchemaObject>;
|
|
7
|
+
|
|
8
|
+
type JSONSchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
|
|
9
|
+
declare const SCHEMA_TYPES: JSONSchemaType[];
|
|
10
|
+
/**
|
|
11
|
+
* Loose JSON Schema shape. Unknown keywords are preserved untouched,
|
|
12
|
+
* the editor never strips fields it does not understand.
|
|
13
|
+
*/
|
|
14
|
+
interface JSONSchema {
|
|
15
|
+
$ref?: string;
|
|
16
|
+
$id?: string;
|
|
17
|
+
$schema?: string;
|
|
18
|
+
$defs?: Record<string, JSONSchema | boolean>;
|
|
19
|
+
definitions?: Record<string, JSONSchema | boolean>;
|
|
20
|
+
components?: {
|
|
21
|
+
schemas?: Record<string, JSONSchema | boolean>;
|
|
22
|
+
};
|
|
23
|
+
type?: JSONSchemaType | JSONSchemaType[];
|
|
24
|
+
title?: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
default?: unknown;
|
|
27
|
+
examples?: unknown[];
|
|
28
|
+
enum?: unknown[];
|
|
29
|
+
const?: unknown;
|
|
30
|
+
format?: string;
|
|
31
|
+
properties?: Record<string, JSONSchema | boolean>;
|
|
32
|
+
patternProperties?: Record<string, JSONSchema | boolean>;
|
|
33
|
+
additionalProperties?: boolean | JSONSchema;
|
|
34
|
+
required?: string[];
|
|
35
|
+
items?: JSONSchema | boolean;
|
|
36
|
+
prefixItems?: (JSONSchema | boolean)[];
|
|
37
|
+
minimum?: number;
|
|
38
|
+
maximum?: number;
|
|
39
|
+
exclusiveMinimum?: number;
|
|
40
|
+
exclusiveMaximum?: number;
|
|
41
|
+
multipleOf?: number;
|
|
42
|
+
minLength?: number;
|
|
43
|
+
maxLength?: number;
|
|
44
|
+
pattern?: string;
|
|
45
|
+
minItems?: number;
|
|
46
|
+
maxItems?: number;
|
|
47
|
+
uniqueItems?: boolean;
|
|
48
|
+
allOf?: (JSONSchema | boolean)[];
|
|
49
|
+
anyOf?: (JSONSchema | boolean)[];
|
|
50
|
+
oneOf?: (JSONSchema | boolean)[];
|
|
51
|
+
not?: JSONSchema | boolean;
|
|
52
|
+
deprecated?: boolean;
|
|
53
|
+
readOnly?: boolean;
|
|
54
|
+
writeOnly?: boolean;
|
|
55
|
+
[keyword: string]: unknown;
|
|
56
|
+
}
|
|
57
|
+
/** Where a row lives relative to its parent container. */
|
|
58
|
+
type NodeKind = "property" | "items" | "root";
|
|
59
|
+
/** Visual role of a row inside a resolved $ref block. */
|
|
60
|
+
type RefSegment = "none" | "head" | "body" | "tail" | "single";
|
|
61
|
+
/** One rendered line of the flattened tree. */
|
|
62
|
+
interface FlatNode {
|
|
63
|
+
/** Stable identity, built from the schema path. */
|
|
64
|
+
id: string;
|
|
65
|
+
/** Property key, or a synthetic label for array items. */
|
|
66
|
+
key: string;
|
|
67
|
+
/** Path from the root schema down to this node's own schema object. */
|
|
68
|
+
path: string[];
|
|
69
|
+
/** Path to the parent container that owns `key`. */
|
|
70
|
+
parentPath: string[];
|
|
71
|
+
depth: number;
|
|
72
|
+
kind: NodeKind;
|
|
73
|
+
/** The raw schema at `path`, possibly just a `$ref` stub. */
|
|
74
|
+
schema: JSONSchema;
|
|
75
|
+
value: SchemaValue;
|
|
76
|
+
/** The dereferenced schema used for rendering, identical to `schema` when no ref. */
|
|
77
|
+
resolved: JSONSchema;
|
|
78
|
+
resolvedValue: SchemaValue;
|
|
79
|
+
required: boolean;
|
|
80
|
+
expandable: boolean;
|
|
81
|
+
expanded: boolean;
|
|
82
|
+
/** Name of the referenced definition, when this node is a `$ref`. */
|
|
83
|
+
refName?: string;
|
|
84
|
+
/** True when the ref points at an ancestor and expansion was stopped. */
|
|
85
|
+
recursive: boolean;
|
|
86
|
+
/** Position inside the resolved ref block, drives the block border styling. */
|
|
87
|
+
refSegment: RefSegment;
|
|
88
|
+
/** Rows inside a ref subtree are read-only to protect shared components. */
|
|
89
|
+
readOnly: boolean;
|
|
90
|
+
/** Sortable only among siblings of the same `properties` object. */
|
|
91
|
+
sortable: boolean;
|
|
92
|
+
}
|
|
93
|
+
/** Insert position requested from the row menu. */
|
|
94
|
+
type AddFieldMode = "sibling" | "child";
|
|
95
|
+
type SchemaEditorErrorScope = "clone" | "resolveRef" | "flatten" | "reorder" | "commit" | "render";
|
|
96
|
+
interface SchemaEditorError {
|
|
97
|
+
scope: SchemaEditorErrorScope;
|
|
98
|
+
message: string;
|
|
99
|
+
/** Original thrown value, kept as-is for logging. */
|
|
100
|
+
cause?: unknown;
|
|
101
|
+
/** Schema path where it happened, when known. */
|
|
102
|
+
path?: string[];
|
|
103
|
+
}
|
|
104
|
+
type SchemaErrorHandler = (error: SchemaEditorError) => void;
|
|
105
|
+
interface AdvancedEditorContext {
|
|
106
|
+
required?: boolean;
|
|
107
|
+
onRequiredChange?: (required: boolean) => void;
|
|
108
|
+
nested: boolean;
|
|
109
|
+
schema: SchemaValue;
|
|
110
|
+
schemaName: string;
|
|
111
|
+
fullSchema: JSONSchema;
|
|
112
|
+
path: string[];
|
|
113
|
+
readOnly: boolean;
|
|
114
|
+
update: (next: SchemaValue) => void;
|
|
115
|
+
}
|
|
116
|
+
interface SchemaTreeEditorProps {
|
|
117
|
+
/** Controlled schema. Must be treated as immutable by the host. */
|
|
118
|
+
schema: JSONSchema;
|
|
119
|
+
onChange: (next: JSONSchema) => void;
|
|
120
|
+
/** Optional list columns. Hidden attributes remain editable in settings. */
|
|
121
|
+
showType?: boolean;
|
|
122
|
+
showRequired?: boolean;
|
|
123
|
+
showDescription?: boolean;
|
|
124
|
+
document?: JSONSchema;
|
|
125
|
+
className?: string;
|
|
126
|
+
/** Disables every mutating affordance. */
|
|
127
|
+
readOnly?: boolean;
|
|
128
|
+
/** Keys expanded on first mount. Uncontrolled afterwards. */
|
|
129
|
+
defaultExpanded?: string[];
|
|
130
|
+
/** Max rows rendered before the overflow notice appears. */
|
|
131
|
+
maxRows?: number;
|
|
132
|
+
/** Renders the advanced settings popover body for a row. */
|
|
133
|
+
renderAdvanced?: (context: AdvancedEditorContext) => React.ReactNode;
|
|
134
|
+
/** Called on any recovered internal failure. The component stays alive. */
|
|
135
|
+
onError?: SchemaErrorHandler;
|
|
136
|
+
/** Verify incoming schema identity and shape on every prop change. Default true. */
|
|
137
|
+
strictExternalSchema?: boolean;
|
|
138
|
+
}
|
|
139
|
+
type SchemaDesignerTreeProps = Omit<SchemaTreeEditorProps, "schema" | "onChange"> & {
|
|
140
|
+
schema?: SchemaValue;
|
|
141
|
+
value?: SchemaValue;
|
|
142
|
+
onChange: (schema: SchemaValue) => void;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export { type AddFieldMode as A, type FlatNode as F, type JSONSchema as J, type NodeKind as N, type RefSegment as R, SCHEMA_TYPES as S, type AdvancedEditorContext as a, type JSONSchemaType as b, type SchemaDesignerTreeProps as c, type SchemaEditorError as d, type SchemaEditorErrorScope as e, type SchemaErrorHandler as f, type SchemaObject as g, type SchemaPatch as h, type SchemaValue as i };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { i as SchemaValue } from './types-D2jEaM9Z.js';
|
|
2
|
+
|
|
3
|
+
type InlineSchemaType = "string" | "number" | "integer" | "boolean" | "array" | "object" | "null" | "any";
|
|
4
|
+
type SchemaFormatOptions = readonly string[];
|
|
5
|
+
type SchemaRecord = Record<string, unknown>;
|
|
6
|
+
interface OpenApiSchema extends SchemaRecord {
|
|
7
|
+
}
|
|
8
|
+
type CompositionKey = "allOf" | "anyOf" | "oneOf";
|
|
9
|
+
interface InlineSchemaEditorProps {
|
|
10
|
+
schema?: SchemaValue;
|
|
11
|
+
value?: SchemaValue;
|
|
12
|
+
onChange?: (value: SchemaValue) => void;
|
|
13
|
+
schemaType?: InlineSchemaType;
|
|
14
|
+
schemaName?: string;
|
|
15
|
+
fullSchema?: OpenApiSchema;
|
|
16
|
+
required?: boolean;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
showAdvanced?: boolean;
|
|
19
|
+
showComposition?: boolean;
|
|
20
|
+
showLiveJson?: boolean;
|
|
21
|
+
formatOptions?: SchemaFormatOptions;
|
|
22
|
+
path?: string[];
|
|
23
|
+
nested?: boolean;
|
|
24
|
+
onTypeChange?: (type: InlineSchemaType) => void;
|
|
25
|
+
onRequiredChange?: (required: boolean) => void;
|
|
26
|
+
update?: (patch: Partial<OpenApiSchema>) => void;
|
|
27
|
+
onExampleChange?: (value: unknown) => void;
|
|
28
|
+
onDefaultChange?: (value: unknown) => void;
|
|
29
|
+
onNameChange?: (name: string) => void;
|
|
30
|
+
}
|
|
31
|
+
interface SchemaPropertyItem {
|
|
32
|
+
name: string;
|
|
33
|
+
schema: OpenApiSchema;
|
|
34
|
+
required: boolean;
|
|
35
|
+
}
|
|
36
|
+
interface SchemaBuilderNode {
|
|
37
|
+
id: string;
|
|
38
|
+
name?: string;
|
|
39
|
+
schema: OpenApiSchema;
|
|
40
|
+
required?: boolean;
|
|
41
|
+
depth: number;
|
|
42
|
+
}
|
|
43
|
+
interface SchemaEditorState {
|
|
44
|
+
schema: OpenApiSchema;
|
|
45
|
+
type: InlineSchemaType;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type { CompositionKey as C, InlineSchemaEditorProps as I, OpenApiSchema as O, SchemaFormatOptions as S, InlineSchemaType as a, SchemaPropertyItem as b, SchemaBuilderNode as c, SchemaEditorState as d, SchemaRecord as e };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
interface EndpointVariable {
|
|
2
|
+
name: string;
|
|
3
|
+
value?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
type?: string;
|
|
6
|
+
color?: string;
|
|
7
|
+
backgroundColor?: string;
|
|
8
|
+
}
|
|
9
|
+
interface VariableTokenMatch {
|
|
10
|
+
token: string;
|
|
11
|
+
name: string;
|
|
12
|
+
from: number;
|
|
13
|
+
to: number;
|
|
14
|
+
variable?: EndpointVariable;
|
|
15
|
+
}
|
|
16
|
+
interface VariableTextPart {
|
|
17
|
+
key: string;
|
|
18
|
+
text: string;
|
|
19
|
+
token?: VariableTokenMatch;
|
|
20
|
+
}
|
|
21
|
+
interface VariableTokenPresentation {
|
|
22
|
+
className: string;
|
|
23
|
+
tokenColor?: string;
|
|
24
|
+
tokenBgColor?: string;
|
|
25
|
+
}
|
|
26
|
+
interface VariableTextEditorProps {
|
|
27
|
+
value: string;
|
|
28
|
+
variables?: readonly EndpointVariable[] | null;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
readOnly?: boolean;
|
|
31
|
+
placeholder?: string;
|
|
32
|
+
ariaLabel?: string;
|
|
33
|
+
className?: string;
|
|
34
|
+
autoFocus?: boolean;
|
|
35
|
+
allowLineBreaks?: boolean;
|
|
36
|
+
submitOnEnter?: boolean;
|
|
37
|
+
minHeight?: number;
|
|
38
|
+
/** Expand over neighboring content while preserving the original row height. */
|
|
39
|
+
expansionMode?: "inline" | "overlay";
|
|
40
|
+
safePadding?: number;
|
|
41
|
+
maxFocusedHeight?: number;
|
|
42
|
+
maxLength?: number;
|
|
43
|
+
onChange?: (value: string) => void;
|
|
44
|
+
onSubmit?: (value: string) => void;
|
|
45
|
+
onFocus?: () => void;
|
|
46
|
+
onBlur?: () => void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type { EndpointVariable as E, VariableTextEditorProps as V, VariableTextPart as a, VariableTokenMatch as b, VariableTokenPresentation as c };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
interface EndpointVariable {
|
|
2
|
+
name: string;
|
|
3
|
+
value?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
type?: string;
|
|
6
|
+
color?: string;
|
|
7
|
+
backgroundColor?: string;
|
|
8
|
+
}
|
|
9
|
+
interface VariableTokenMatch {
|
|
10
|
+
token: string;
|
|
11
|
+
name: string;
|
|
12
|
+
from: number;
|
|
13
|
+
to: number;
|
|
14
|
+
variable?: EndpointVariable;
|
|
15
|
+
}
|
|
16
|
+
interface VariableTextPart {
|
|
17
|
+
key: string;
|
|
18
|
+
text: string;
|
|
19
|
+
token?: VariableTokenMatch;
|
|
20
|
+
}
|
|
21
|
+
interface VariableTokenPresentation {
|
|
22
|
+
className: string;
|
|
23
|
+
tokenColor?: string;
|
|
24
|
+
tokenBgColor?: string;
|
|
25
|
+
}
|
|
26
|
+
interface VariableTextEditorProps {
|
|
27
|
+
value: string;
|
|
28
|
+
variables?: readonly EndpointVariable[] | null;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
readOnly?: boolean;
|
|
31
|
+
placeholder?: string;
|
|
32
|
+
ariaLabel?: string;
|
|
33
|
+
className?: string;
|
|
34
|
+
autoFocus?: boolean;
|
|
35
|
+
allowLineBreaks?: boolean;
|
|
36
|
+
submitOnEnter?: boolean;
|
|
37
|
+
minHeight?: number;
|
|
38
|
+
/** Expand over neighboring content while preserving the original row height. */
|
|
39
|
+
expansionMode?: "inline" | "overlay";
|
|
40
|
+
safePadding?: number;
|
|
41
|
+
maxFocusedHeight?: number;
|
|
42
|
+
maxLength?: number;
|
|
43
|
+
onChange?: (value: string) => void;
|
|
44
|
+
onSubmit?: (value: string) => void;
|
|
45
|
+
onFocus?: () => void;
|
|
46
|
+
onBlur?: () => void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type { EndpointVariable as E, VariableTextEditorProps as V, VariableTextPart as a, VariableTokenMatch as b, VariableTokenPresentation as c };
|
package/package.json
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@powerduck/schema-designer",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Composable JSON Schema and OpenAPI parameter editors for React.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./core": {
|
|
16
|
+
"types": "./dist/core/index.d.ts",
|
|
17
|
+
"import": "./dist/core/index.js",
|
|
18
|
+
"require": "./dist/core/index.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./react": {
|
|
21
|
+
"types": "./dist/react/index.d.ts",
|
|
22
|
+
"import": "./dist/react/index.js",
|
|
23
|
+
"require": "./dist/react/index.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./react/tree": {
|
|
26
|
+
"types": "./dist/react/schemaTreeEditor/index.d.ts",
|
|
27
|
+
"import": "./dist/react/schemaTreeEditor/index.js",
|
|
28
|
+
"require": "./dist/react/schemaTreeEditor/index.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./react/inline": {
|
|
31
|
+
"types": "./dist/react/inlineSchemaEditor/index.d.ts",
|
|
32
|
+
"import": "./dist/react/inlineSchemaEditor/index.js",
|
|
33
|
+
"require": "./dist/react/inlineSchemaEditor/index.cjs"
|
|
34
|
+
},
|
|
35
|
+
"./react/parameters": {
|
|
36
|
+
"types": "./dist/react/parametersTable/index.d.ts",
|
|
37
|
+
"import": "./dist/react/parametersTable/index.js",
|
|
38
|
+
"require": "./dist/react/parametersTable/index.cjs"
|
|
39
|
+
},
|
|
40
|
+
"./adapters/generator": {
|
|
41
|
+
"types": "./dist/react/parametersTable/libs/generateValue.d.ts",
|
|
42
|
+
"import": "./dist/react/parametersTable/libs/generateValue.js",
|
|
43
|
+
"require": "./dist/react/parametersTable/libs/generateValue.cjs"
|
|
44
|
+
},
|
|
45
|
+
"./styles.css": "./dist/styles.css",
|
|
46
|
+
"./package.json": "./package.json",
|
|
47
|
+
"./compat/inline": {
|
|
48
|
+
"types": "./dist/compat/inline.d.ts",
|
|
49
|
+
"import": "./dist/compat/inline.js",
|
|
50
|
+
"require": "./dist/compat/inline.cjs"
|
|
51
|
+
},
|
|
52
|
+
"./compat/tree": {
|
|
53
|
+
"types": "./dist/compat/tree.d.ts",
|
|
54
|
+
"import": "./dist/compat/tree.js",
|
|
55
|
+
"require": "./dist/compat/tree.cjs"
|
|
56
|
+
},
|
|
57
|
+
"./compat/parameters": {
|
|
58
|
+
"types": "./dist/compat/parameters.d.ts",
|
|
59
|
+
"import": "./dist/compat/parameters.js",
|
|
60
|
+
"require": "./dist/compat/parameters.cjs"
|
|
61
|
+
},
|
|
62
|
+
"./react/variable-editor": {
|
|
63
|
+
"types": "./dist/react/variableTextEditor/index.d.ts",
|
|
64
|
+
"import": "./dist/react/variableTextEditor/index.js",
|
|
65
|
+
"require": "./dist/react/variableTextEditor/index.cjs"
|
|
66
|
+
},
|
|
67
|
+
"./compat/variable-editor": {
|
|
68
|
+
"types": "./dist/compat/variable-editor.d.ts",
|
|
69
|
+
"import": "./dist/compat/variable-editor.js",
|
|
70
|
+
"require": "./dist/compat/variable-editor.cjs"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"files": [
|
|
74
|
+
"dist",
|
|
75
|
+
"README.md",
|
|
76
|
+
"LICENSE"
|
|
77
|
+
],
|
|
78
|
+
"sideEffects": [
|
|
79
|
+
"**/*.css"
|
|
80
|
+
],
|
|
81
|
+
"scripts": {
|
|
82
|
+
"build": "tsup && node scripts/styles.mjs",
|
|
83
|
+
"typecheck": "tsc --noEmit",
|
|
84
|
+
"test": "vitest run --pool=forks --maxWorkers=1 --minWorkers=1",
|
|
85
|
+
"benchmark": "node --import tsx scripts/benchmark.ts",
|
|
86
|
+
"dev": "vite examples --host 127.0.0.1 --port 4176",
|
|
87
|
+
"verify:package": "node scripts/verify-package.mjs"
|
|
88
|
+
},
|
|
89
|
+
"peerDependencies": {
|
|
90
|
+
"@chakra-ui/react": "^3.37.0",
|
|
91
|
+
"@emotion/react": "^11.14.0",
|
|
92
|
+
"react": ">=18.2.0 <20",
|
|
93
|
+
"react-dom": ">=18.2.0 <20"
|
|
94
|
+
},
|
|
95
|
+
"dependencies": {
|
|
96
|
+
"@codemirror/autocomplete": "^6.20.3",
|
|
97
|
+
"@codemirror/commands": "^6.11.0",
|
|
98
|
+
"@codemirror/language": "^6.12.4",
|
|
99
|
+
"@codemirror/state": "^6.7.1",
|
|
100
|
+
"@codemirror/view": "^6.43.9",
|
|
101
|
+
"@hello-pangea/dnd": "^18.0.1",
|
|
102
|
+
"nanoid": "^5.1.16",
|
|
103
|
+
"react-icons": "^5.7.0"
|
|
104
|
+
},
|
|
105
|
+
"optionalDependencies": {
|
|
106
|
+
"@faker-js/faker": "^10.6.0",
|
|
107
|
+
"ajv": "^8.20.0",
|
|
108
|
+
"ajv-formats": "^3.0.1",
|
|
109
|
+
"json-schema-faker": "^0.6.3"
|
|
110
|
+
},
|
|
111
|
+
"devDependencies": {
|
|
112
|
+
"@chakra-ui/react": "^3.37.0",
|
|
113
|
+
"@emotion/react": "^11.14.0",
|
|
114
|
+
"@testing-library/react": "^16.3.0",
|
|
115
|
+
"@types/react": "^19.0.0",
|
|
116
|
+
"@types/react-dom": "^19.0.0",
|
|
117
|
+
"jsdom": "^24.1.0",
|
|
118
|
+
"prettier": "^3.9.7",
|
|
119
|
+
"react": "^19.3.0",
|
|
120
|
+
"react-dom": "^19.3.0",
|
|
121
|
+
"tsup": "^8.5.0",
|
|
122
|
+
"tsx": "^4.20.0",
|
|
123
|
+
"typescript": "^5.9.0",
|
|
124
|
+
"vitest": "^1.6.0"
|
|
125
|
+
},
|
|
126
|
+
"license": "UNLICENSED",
|
|
127
|
+
"engines": {
|
|
128
|
+
"node": ">=22.12.0"
|
|
129
|
+
}
|
|
130
|
+
}
|