@makehq/forman-schema 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +9 -4
- package/dist/index.d.cts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +9 -4
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -35,9 +35,14 @@ function isObject(value) {
|
|
|
35
35
|
|
|
36
36
|
// src/forman.ts
|
|
37
37
|
var SchemaConversionError = class extends Error {
|
|
38
|
+
/** Field that caused the error */
|
|
39
|
+
field;
|
|
40
|
+
/**
|
|
41
|
+
* @param message The error message
|
|
42
|
+
* @param field The field that caused the error
|
|
43
|
+
*/
|
|
38
44
|
constructor(message, field) {
|
|
39
45
|
super(message);
|
|
40
|
-
this.field = field;
|
|
41
46
|
this.name = "SchemaConversionError";
|
|
42
47
|
}
|
|
43
48
|
};
|
|
@@ -66,7 +71,7 @@ var FORMAN_TYPE_MAP = {
|
|
|
66
71
|
filename: "string",
|
|
67
72
|
file: "string",
|
|
68
73
|
folder: "string",
|
|
69
|
-
hidden:
|
|
74
|
+
hidden: void 0,
|
|
70
75
|
integer: "number",
|
|
71
76
|
uinteger: "number",
|
|
72
77
|
password: "string",
|
|
@@ -192,7 +197,7 @@ function handleCollectionType(field, result, context) {
|
|
|
192
197
|
[name]: { const: value }
|
|
193
198
|
}
|
|
194
199
|
},
|
|
195
|
-
then: typeof nested === "string" ? { $ref:
|
|
200
|
+
then: typeof nested === "string" ? { $ref: nested } : nested
|
|
196
201
|
});
|
|
197
202
|
}
|
|
198
203
|
})
|
|
@@ -292,7 +297,7 @@ function handleSelectType(field, result, context) {
|
|
|
292
297
|
configurable: true,
|
|
293
298
|
enumerable: true,
|
|
294
299
|
writable: true,
|
|
295
|
-
value: typeof nested === "string" ? nested : toJSONSchemaInternal(
|
|
300
|
+
value: typeof nested === "string" ? { $ref: appendQueryString(nested, context.domain, [...context.tail, field.name]) } : toJSONSchemaInternal(
|
|
296
301
|
{ type: "collection", spec: nested },
|
|
297
302
|
{
|
|
298
303
|
...context,
|
package/dist/index.d.cts
CHANGED
|
@@ -48,7 +48,13 @@ type FormanSchemaField = {
|
|
|
48
48
|
/** Validation rules */
|
|
49
49
|
validate?: FormanSchemaValidation;
|
|
50
50
|
} & Record<`x-${string}`, unknown>;
|
|
51
|
+
/**
|
|
52
|
+
* Valid Forman Schema values
|
|
53
|
+
*/
|
|
51
54
|
type FormanSchemaValue = string | number | boolean | null;
|
|
55
|
+
/**
|
|
56
|
+
* Option for a select field
|
|
57
|
+
*/
|
|
52
58
|
type FormanSchemaOption = {
|
|
53
59
|
/** Option value */
|
|
54
60
|
value: FormanSchemaValue;
|
|
@@ -57,15 +63,26 @@ type FormanSchemaOption = {
|
|
|
57
63
|
/** Nested fields for this option */
|
|
58
64
|
nested?: FormanSchemaNested;
|
|
59
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* Extended options for a select field
|
|
68
|
+
*/
|
|
60
69
|
type FormanSchemaExtendedOptions = {
|
|
61
70
|
/** Store for the options */
|
|
62
71
|
store: FormanSchemaOption[] | string;
|
|
63
72
|
/** Nested fields for every option */
|
|
64
73
|
nested?: FormanSchemaNested;
|
|
65
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* Nested fields
|
|
77
|
+
*/
|
|
66
78
|
type FormanSchemaNested = FormanSchemaField[] | string | FormanSchemaExtendedNested;
|
|
79
|
+
/**
|
|
80
|
+
* Extended nested fields
|
|
81
|
+
*/
|
|
67
82
|
type FormanSchemaExtendedNested = {
|
|
83
|
+
/** Store for the nested fields */
|
|
68
84
|
store: FormanSchemaField[] | string;
|
|
85
|
+
/** Domain for the nested fields */
|
|
69
86
|
domain?: string;
|
|
70
87
|
};
|
|
71
88
|
|
package/dist/index.d.ts
CHANGED
|
@@ -48,7 +48,13 @@ type FormanSchemaField = {
|
|
|
48
48
|
/** Validation rules */
|
|
49
49
|
validate?: FormanSchemaValidation;
|
|
50
50
|
} & Record<`x-${string}`, unknown>;
|
|
51
|
+
/**
|
|
52
|
+
* Valid Forman Schema values
|
|
53
|
+
*/
|
|
51
54
|
type FormanSchemaValue = string | number | boolean | null;
|
|
55
|
+
/**
|
|
56
|
+
* Option for a select field
|
|
57
|
+
*/
|
|
52
58
|
type FormanSchemaOption = {
|
|
53
59
|
/** Option value */
|
|
54
60
|
value: FormanSchemaValue;
|
|
@@ -57,15 +63,26 @@ type FormanSchemaOption = {
|
|
|
57
63
|
/** Nested fields for this option */
|
|
58
64
|
nested?: FormanSchemaNested;
|
|
59
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* Extended options for a select field
|
|
68
|
+
*/
|
|
60
69
|
type FormanSchemaExtendedOptions = {
|
|
61
70
|
/** Store for the options */
|
|
62
71
|
store: FormanSchemaOption[] | string;
|
|
63
72
|
/** Nested fields for every option */
|
|
64
73
|
nested?: FormanSchemaNested;
|
|
65
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* Nested fields
|
|
77
|
+
*/
|
|
66
78
|
type FormanSchemaNested = FormanSchemaField[] | string | FormanSchemaExtendedNested;
|
|
79
|
+
/**
|
|
80
|
+
* Extended nested fields
|
|
81
|
+
*/
|
|
67
82
|
type FormanSchemaExtendedNested = {
|
|
83
|
+
/** Store for the nested fields */
|
|
68
84
|
store: FormanSchemaField[] | string;
|
|
85
|
+
/** Domain for the nested fields */
|
|
69
86
|
domain?: string;
|
|
70
87
|
};
|
|
71
88
|
|
package/dist/index.js
CHANGED
|
@@ -8,9 +8,14 @@ function isObject(value) {
|
|
|
8
8
|
|
|
9
9
|
// src/forman.ts
|
|
10
10
|
var SchemaConversionError = class extends Error {
|
|
11
|
+
/** Field that caused the error */
|
|
12
|
+
field;
|
|
13
|
+
/**
|
|
14
|
+
* @param message The error message
|
|
15
|
+
* @param field The field that caused the error
|
|
16
|
+
*/
|
|
11
17
|
constructor(message, field) {
|
|
12
18
|
super(message);
|
|
13
|
-
this.field = field;
|
|
14
19
|
this.name = "SchemaConversionError";
|
|
15
20
|
}
|
|
16
21
|
};
|
|
@@ -39,7 +44,7 @@ var FORMAN_TYPE_MAP = {
|
|
|
39
44
|
filename: "string",
|
|
40
45
|
file: "string",
|
|
41
46
|
folder: "string",
|
|
42
|
-
hidden:
|
|
47
|
+
hidden: void 0,
|
|
43
48
|
integer: "number",
|
|
44
49
|
uinteger: "number",
|
|
45
50
|
password: "string",
|
|
@@ -165,7 +170,7 @@ function handleCollectionType(field, result, context) {
|
|
|
165
170
|
[name]: { const: value }
|
|
166
171
|
}
|
|
167
172
|
},
|
|
168
|
-
then: typeof nested === "string" ? { $ref:
|
|
173
|
+
then: typeof nested === "string" ? { $ref: nested } : nested
|
|
169
174
|
});
|
|
170
175
|
}
|
|
171
176
|
})
|
|
@@ -265,7 +270,7 @@ function handleSelectType(field, result, context) {
|
|
|
265
270
|
configurable: true,
|
|
266
271
|
enumerable: true,
|
|
267
272
|
writable: true,
|
|
268
|
-
value: typeof nested === "string" ? nested : toJSONSchemaInternal(
|
|
273
|
+
value: typeof nested === "string" ? { $ref: appendQueryString(nested, context.domain, [...context.tail, field.name]) } : toJSONSchemaInternal(
|
|
269
274
|
{ type: "collection", spec: nested },
|
|
270
275
|
{
|
|
271
276
|
...context,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@makehq/forman-schema",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Forman Schema Tools",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Make",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"@types/json-schema": "^7.0.15",
|
|
41
41
|
"@types/node": "^22.13.10",
|
|
42
42
|
"jest": "^29.7.0",
|
|
43
|
+
"json-schema": "^0.4.0",
|
|
43
44
|
"prettier": "^3.5.3",
|
|
44
45
|
"ts-jest": "^29.2.6",
|
|
45
46
|
"ts-node": "^10.9.2",
|