@makehq/forman-schema 1.1.2 → 1.2.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 +33 -5
- package/dist/index.cjs +7 -5
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +7 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,14 +58,36 @@ const formanSchema = toFormanSchema(jsonSchemaField);
|
|
|
58
58
|
|
|
59
59
|
### Forman Schema Types
|
|
60
60
|
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
61
|
+
- account → number
|
|
62
|
+
- aiagent → string
|
|
63
|
+
- array → array
|
|
64
|
+
- buffer → string
|
|
65
|
+
- cert → string
|
|
66
|
+
- collection → object
|
|
67
|
+
- color → string
|
|
68
|
+
- datastore → number
|
|
64
69
|
- date → string
|
|
70
|
+
- email → string
|
|
71
|
+
- file → string
|
|
72
|
+
- filename → string
|
|
73
|
+
- folder → string
|
|
74
|
+
- hidden → string
|
|
75
|
+
- hook → number
|
|
76
|
+
- integer → number
|
|
65
77
|
- json → string
|
|
78
|
+
- keychain → number
|
|
79
|
+
- number → number
|
|
80
|
+
- path → string
|
|
81
|
+
- pkey → string
|
|
82
|
+
- port → number
|
|
66
83
|
- select → string with enum
|
|
67
|
-
-
|
|
68
|
-
-
|
|
84
|
+
- text → string
|
|
85
|
+
- time → string
|
|
86
|
+
- timestamp → string
|
|
87
|
+
- timezone → string
|
|
88
|
+
- uinteger → number
|
|
89
|
+
- url → string
|
|
90
|
+
- uuid → string
|
|
69
91
|
|
|
70
92
|
### JSON Schema Types
|
|
71
93
|
|
|
@@ -75,6 +97,12 @@ const formanSchema = toFormanSchema(jsonSchemaField);
|
|
|
75
97
|
- object → collection
|
|
76
98
|
- array → array
|
|
77
99
|
|
|
100
|
+
## Error Handling
|
|
101
|
+
|
|
102
|
+
### SchemaConversionError
|
|
103
|
+
|
|
104
|
+
`SchemaConversionError` is thrown when schema conversion fails. It includes a message and optionally the field that caused the error.
|
|
105
|
+
|
|
78
106
|
## Testing
|
|
79
107
|
|
|
80
108
|
To test the project:
|
package/dist/index.cjs
CHANGED
|
@@ -78,7 +78,8 @@ var FORMAN_TYPE_MAP = {
|
|
|
78
78
|
timestamp: "string",
|
|
79
79
|
timezone: "string",
|
|
80
80
|
url: "string",
|
|
81
|
-
uuid: "string"
|
|
81
|
+
uuid: "string",
|
|
82
|
+
any: void 0
|
|
82
83
|
};
|
|
83
84
|
function validateFormanField(field) {
|
|
84
85
|
if (!field.type) {
|
|
@@ -145,7 +146,7 @@ function toJSONSchemaInternal(field, context = createDefaultContext()) {
|
|
|
145
146
|
validateFormanField(field);
|
|
146
147
|
const normalizedField = normalizeFieldType(field);
|
|
147
148
|
const result = {
|
|
148
|
-
type: FORMAN_TYPE_MAP[normalizedField.type]
|
|
149
|
+
type: FORMAN_TYPE_MAP[normalizedField.type],
|
|
149
150
|
title: noEmpty(normalizedField.label),
|
|
150
151
|
description: noEmpty(normalizedField.help)
|
|
151
152
|
};
|
|
@@ -168,7 +169,6 @@ function toJSONSchemaInternal(field, context = createDefaultContext()) {
|
|
|
168
169
|
}
|
|
169
170
|
function handleCollectionType(field, result, context) {
|
|
170
171
|
Object.assign(result, {
|
|
171
|
-
type: "object",
|
|
172
172
|
properties: {},
|
|
173
173
|
required: []
|
|
174
174
|
});
|
|
@@ -329,6 +329,7 @@ function handlePrimitiveType(field, result) {
|
|
|
329
329
|
var JSON_PRIMITIVE_TYPE_MAP = {
|
|
330
330
|
string: "text",
|
|
331
331
|
number: "number",
|
|
332
|
+
integer: "number",
|
|
332
333
|
boolean: "boolean"
|
|
333
334
|
};
|
|
334
335
|
function toFormanSchema(field) {
|
|
@@ -395,8 +396,9 @@ function toFormanSchema(field) {
|
|
|
395
396
|
return textField;
|
|
396
397
|
default:
|
|
397
398
|
const primitiveField = {
|
|
398
|
-
type: JSON_PRIMITIVE_TYPE_MAP[field.type] || "
|
|
399
|
-
|
|
399
|
+
type: JSON_PRIMITIVE_TYPE_MAP[field.type] || "any",
|
|
400
|
+
label: noEmpty(field.title),
|
|
401
|
+
help: noEmpty(field.description),
|
|
400
402
|
default: field.default
|
|
401
403
|
};
|
|
402
404
|
if (field.minimum !== void 0 || field.maximum !== void 0) {
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -51,7 +51,8 @@ var FORMAN_TYPE_MAP = {
|
|
|
51
51
|
timestamp: "string",
|
|
52
52
|
timezone: "string",
|
|
53
53
|
url: "string",
|
|
54
|
-
uuid: "string"
|
|
54
|
+
uuid: "string",
|
|
55
|
+
any: void 0
|
|
55
56
|
};
|
|
56
57
|
function validateFormanField(field) {
|
|
57
58
|
if (!field.type) {
|
|
@@ -118,7 +119,7 @@ function toJSONSchemaInternal(field, context = createDefaultContext()) {
|
|
|
118
119
|
validateFormanField(field);
|
|
119
120
|
const normalizedField = normalizeFieldType(field);
|
|
120
121
|
const result = {
|
|
121
|
-
type: FORMAN_TYPE_MAP[normalizedField.type]
|
|
122
|
+
type: FORMAN_TYPE_MAP[normalizedField.type],
|
|
122
123
|
title: noEmpty(normalizedField.label),
|
|
123
124
|
description: noEmpty(normalizedField.help)
|
|
124
125
|
};
|
|
@@ -141,7 +142,6 @@ function toJSONSchemaInternal(field, context = createDefaultContext()) {
|
|
|
141
142
|
}
|
|
142
143
|
function handleCollectionType(field, result, context) {
|
|
143
144
|
Object.assign(result, {
|
|
144
|
-
type: "object",
|
|
145
145
|
properties: {},
|
|
146
146
|
required: []
|
|
147
147
|
});
|
|
@@ -302,6 +302,7 @@ function handlePrimitiveType(field, result) {
|
|
|
302
302
|
var JSON_PRIMITIVE_TYPE_MAP = {
|
|
303
303
|
string: "text",
|
|
304
304
|
number: "number",
|
|
305
|
+
integer: "number",
|
|
305
306
|
boolean: "boolean"
|
|
306
307
|
};
|
|
307
308
|
function toFormanSchema(field) {
|
|
@@ -368,8 +369,9 @@ function toFormanSchema(field) {
|
|
|
368
369
|
return textField;
|
|
369
370
|
default:
|
|
370
371
|
const primitiveField = {
|
|
371
|
-
type: JSON_PRIMITIVE_TYPE_MAP[field.type] || "
|
|
372
|
-
|
|
372
|
+
type: JSON_PRIMITIVE_TYPE_MAP[field.type] || "any",
|
|
373
|
+
label: noEmpty(field.title),
|
|
374
|
+
help: noEmpty(field.description),
|
|
373
375
|
default: field.default
|
|
374
376
|
};
|
|
375
377
|
if (field.minimum !== void 0 || field.maximum !== void 0) {
|