@formspec/constraints 0.1.0-alpha.7

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.
Files changed (52) hide show
  1. package/README.md +265 -0
  2. package/dist/__tests__/loader.test.d.ts +2 -0
  3. package/dist/__tests__/loader.test.d.ts.map +1 -0
  4. package/dist/__tests__/loader.test.js +133 -0
  5. package/dist/__tests__/loader.test.js.map +1 -0
  6. package/dist/__tests__/validators.test.d.ts +2 -0
  7. package/dist/__tests__/validators.test.d.ts.map +1 -0
  8. package/dist/__tests__/validators.test.js +404 -0
  9. package/dist/__tests__/validators.test.js.map +1 -0
  10. package/dist/browser.d.ts +51 -0
  11. package/dist/browser.d.ts.map +1 -0
  12. package/dist/browser.js +65 -0
  13. package/dist/browser.js.map +1 -0
  14. package/dist/constraints.d.ts +544 -0
  15. package/dist/defaults.d.ts +15 -0
  16. package/dist/defaults.d.ts.map +1 -0
  17. package/dist/defaults.js +106 -0
  18. package/dist/defaults.js.map +1 -0
  19. package/dist/index.d.ts +44 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +46 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/loader.d.ts +81 -0
  24. package/dist/loader.d.ts.map +1 -0
  25. package/dist/loader.js +140 -0
  26. package/dist/loader.js.map +1 -0
  27. package/dist/types.d.ts +200 -0
  28. package/dist/types.d.ts.map +1 -0
  29. package/dist/types.js +2 -0
  30. package/dist/types.js.map +1 -0
  31. package/dist/validators/field-options.d.ts +49 -0
  32. package/dist/validators/field-options.d.ts.map +1 -0
  33. package/dist/validators/field-options.js +79 -0
  34. package/dist/validators/field-options.js.map +1 -0
  35. package/dist/validators/field-types.d.ts +38 -0
  36. package/dist/validators/field-types.d.ts.map +1 -0
  37. package/dist/validators/field-types.js +93 -0
  38. package/dist/validators/field-types.js.map +1 -0
  39. package/dist/validators/formspec.d.ts +54 -0
  40. package/dist/validators/formspec.d.ts.map +1 -0
  41. package/dist/validators/formspec.js +152 -0
  42. package/dist/validators/formspec.js.map +1 -0
  43. package/dist/validators/index.d.ts +5 -0
  44. package/dist/validators/index.d.ts.map +1 -0
  45. package/dist/validators/index.js +5 -0
  46. package/dist/validators/index.js.map +1 -0
  47. package/dist/validators/layout.d.ts +39 -0
  48. package/dist/validators/layout.d.ts.map +1 -0
  49. package/dist/validators/layout.js +107 -0
  50. package/dist/validators/layout.js.map +1 -0
  51. package/formspec.schema.json +245 -0
  52. package/package.json +57 -0
@@ -0,0 +1,245 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft-07/schema#",
3
+ "$id": "https://formspec.dev/schemas/formspec.schema.json",
4
+ "title": "FormSpec Configuration",
5
+ "description": "Configuration file schema for FormSpec projects (.formspec.yml)",
6
+ "type": "object",
7
+ "properties": {
8
+ "constraints": {
9
+ "$ref": "#/$defs/ConstraintConfig"
10
+ }
11
+ },
12
+ "additionalProperties": false,
13
+ "$defs": {
14
+ "Severity": {
15
+ "type": "string",
16
+ "enum": ["error", "warn", "off"],
17
+ "description": "Severity level for constraint violations. 'error' fails validation, 'warn' emits warning, 'off' allows the feature."
18
+ },
19
+ "ConstraintConfig": {
20
+ "type": "object",
21
+ "description": "Complete constraint configuration for a FormSpec project",
22
+ "properties": {
23
+ "fieldTypes": {
24
+ "$ref": "#/$defs/FieldTypeConstraints"
25
+ },
26
+ "layout": {
27
+ "$ref": "#/$defs/LayoutConstraints"
28
+ },
29
+ "uiSchema": {
30
+ "$ref": "#/$defs/UISchemaConstraints"
31
+ },
32
+ "fieldOptions": {
33
+ "$ref": "#/$defs/FieldOptionConstraints"
34
+ },
35
+ "controlOptions": {
36
+ "$ref": "#/$defs/ControlOptionConstraints"
37
+ }
38
+ },
39
+ "additionalProperties": false
40
+ },
41
+ "FieldTypeConstraints": {
42
+ "type": "object",
43
+ "description": "Control which field types are allowed",
44
+ "properties": {
45
+ "text": {
46
+ "$ref": "#/$defs/Severity",
47
+ "description": "field.text() - basic text input"
48
+ },
49
+ "number": {
50
+ "$ref": "#/$defs/Severity",
51
+ "description": "field.number() - numeric input"
52
+ },
53
+ "boolean": {
54
+ "$ref": "#/$defs/Severity",
55
+ "description": "field.boolean() - checkbox/toggle"
56
+ },
57
+ "staticEnum": {
58
+ "$ref": "#/$defs/Severity",
59
+ "description": "field.enum() with literal options"
60
+ },
61
+ "dynamicEnum": {
62
+ "$ref": "#/$defs/Severity",
63
+ "description": "field.dynamicEnum() - runtime-fetched options"
64
+ },
65
+ "dynamicSchema": {
66
+ "$ref": "#/$defs/Severity",
67
+ "description": "field.dynamicSchema() - runtime-fetched schema"
68
+ },
69
+ "array": {
70
+ "$ref": "#/$defs/Severity",
71
+ "description": "field.array() / field.arrayWithConfig()"
72
+ },
73
+ "object": {
74
+ "$ref": "#/$defs/Severity",
75
+ "description": "field.object() / field.objectWithConfig()"
76
+ }
77
+ },
78
+ "additionalProperties": false
79
+ },
80
+ "LayoutConstraints": {
81
+ "type": "object",
82
+ "description": "Control grouping, conditionals, and nesting",
83
+ "properties": {
84
+ "group": {
85
+ "$ref": "#/$defs/Severity",
86
+ "description": "group() - visual grouping of fields"
87
+ },
88
+ "conditionals": {
89
+ "$ref": "#/$defs/Severity",
90
+ "description": "when() - conditional field visibility"
91
+ },
92
+ "maxNestingDepth": {
93
+ "type": "integer",
94
+ "minimum": 0,
95
+ "description": "Maximum nesting depth for objects/arrays (0 = flat only)"
96
+ }
97
+ },
98
+ "additionalProperties": false
99
+ },
100
+ "LayoutTypeConstraints": {
101
+ "type": "object",
102
+ "description": "JSONForms layout type constraints",
103
+ "properties": {
104
+ "VerticalLayout": {
105
+ "$ref": "#/$defs/Severity",
106
+ "description": "Stack elements vertically"
107
+ },
108
+ "HorizontalLayout": {
109
+ "$ref": "#/$defs/Severity",
110
+ "description": "Arrange elements horizontally"
111
+ },
112
+ "Group": {
113
+ "$ref": "#/$defs/Severity",
114
+ "description": "Visual grouping with label"
115
+ },
116
+ "Categorization": {
117
+ "$ref": "#/$defs/Severity",
118
+ "description": "Tabbed/wizard interface"
119
+ },
120
+ "Category": {
121
+ "$ref": "#/$defs/Severity",
122
+ "description": "Individual tab/step in Categorization"
123
+ }
124
+ },
125
+ "additionalProperties": false
126
+ },
127
+ "RuleEffectConstraints": {
128
+ "type": "object",
129
+ "description": "JSONForms rule effect constraints",
130
+ "properties": {
131
+ "SHOW": {
132
+ "$ref": "#/$defs/Severity",
133
+ "description": "Show element when condition is true"
134
+ },
135
+ "HIDE": {
136
+ "$ref": "#/$defs/Severity",
137
+ "description": "Hide element when condition is true"
138
+ },
139
+ "ENABLE": {
140
+ "$ref": "#/$defs/Severity",
141
+ "description": "Enable element when condition is true"
142
+ },
143
+ "DISABLE": {
144
+ "$ref": "#/$defs/Severity",
145
+ "description": "Disable element when condition is true"
146
+ }
147
+ },
148
+ "additionalProperties": false
149
+ },
150
+ "RuleConstraints": {
151
+ "type": "object",
152
+ "description": "JSONForms rule constraints",
153
+ "properties": {
154
+ "enabled": {
155
+ "$ref": "#/$defs/Severity",
156
+ "description": "Whether rules are enabled at all"
157
+ },
158
+ "effects": {
159
+ "$ref": "#/$defs/RuleEffectConstraints",
160
+ "description": "Fine-grained control over rule effects"
161
+ }
162
+ },
163
+ "additionalProperties": false
164
+ },
165
+ "UISchemaConstraints": {
166
+ "type": "object",
167
+ "description": "JSONForms UI Schema feature constraints",
168
+ "properties": {
169
+ "layouts": {
170
+ "$ref": "#/$defs/LayoutTypeConstraints",
171
+ "description": "Layout type constraints"
172
+ },
173
+ "rules": {
174
+ "$ref": "#/$defs/RuleConstraints",
175
+ "description": "Rule (conditional) constraints"
176
+ }
177
+ },
178
+ "additionalProperties": false
179
+ },
180
+ "FieldOptionConstraints": {
181
+ "type": "object",
182
+ "description": "Control which field configuration options are allowed",
183
+ "properties": {
184
+ "label": {
185
+ "$ref": "#/$defs/Severity",
186
+ "description": "Field label text"
187
+ },
188
+ "placeholder": {
189
+ "$ref": "#/$defs/Severity",
190
+ "description": "Input placeholder text"
191
+ },
192
+ "required": {
193
+ "$ref": "#/$defs/Severity",
194
+ "description": "Whether field is required"
195
+ },
196
+ "minValue": {
197
+ "$ref": "#/$defs/Severity",
198
+ "description": "Minimum value for numbers"
199
+ },
200
+ "maxValue": {
201
+ "$ref": "#/$defs/Severity",
202
+ "description": "Maximum value for numbers"
203
+ },
204
+ "minItems": {
205
+ "$ref": "#/$defs/Severity",
206
+ "description": "Minimum array length"
207
+ },
208
+ "maxItems": {
209
+ "$ref": "#/$defs/Severity",
210
+ "description": "Maximum array length"
211
+ }
212
+ },
213
+ "additionalProperties": false
214
+ },
215
+ "ControlOptionConstraints": {
216
+ "type": "object",
217
+ "description": "Control which JSONForms Control.options are allowed",
218
+ "properties": {
219
+ "format": {
220
+ "$ref": "#/$defs/Severity",
221
+ "description": "Renderer format hint (e.g., 'radio', 'textarea')"
222
+ },
223
+ "readonly": {
224
+ "$ref": "#/$defs/Severity",
225
+ "description": "Read-only mode"
226
+ },
227
+ "multi": {
228
+ "$ref": "#/$defs/Severity",
229
+ "description": "Multi-select for enums"
230
+ },
231
+ "showUnfocusedDescription": {
232
+ "$ref": "#/$defs/Severity",
233
+ "description": "Show description when unfocused"
234
+ },
235
+ "hideRequiredAsterisk": {
236
+ "$ref": "#/$defs/Severity",
237
+ "description": "Hide required indicator"
238
+ }
239
+ },
240
+ "additionalProperties": {
241
+ "$ref": "#/$defs/Severity"
242
+ }
243
+ }
244
+ }
245
+ }
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@formspec/constraints",
3
+ "version": "0.1.0-alpha.7",
4
+ "description": "Constraint validation for FormSpec - restrict features based on target environment capabilities",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/constraints.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/constraints.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./browser": {
14
+ "types": "./dist/browser.d.ts",
15
+ "import": "./dist/browser.js"
16
+ },
17
+ "./formspec.schema.json": "./formspec.schema.json"
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "formspec.schema.json",
22
+ "README.md"
23
+ ],
24
+ "dependencies": {
25
+ "yaml": "^2.7.0",
26
+ "@formspec/core": "0.1.0-alpha.4"
27
+ },
28
+ "devDependencies": {
29
+ "tsd": "^0.31.0",
30
+ "vitest": "^3.0.0",
31
+ "@formspec/dsl": "0.1.0-alpha.6"
32
+ },
33
+ "tsd": {
34
+ "directory": "src/__tests__"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "keywords": [
40
+ "formspec",
41
+ "constraints",
42
+ "validation",
43
+ "jsonschema",
44
+ "jsonforms"
45
+ ],
46
+ "license": "UNLICENSED",
47
+ "scripts": {
48
+ "build": "tsc && api-extractor run --local",
49
+ "clean": "rm -rf dist temp",
50
+ "typecheck": "tsc --noEmit",
51
+ "test": "vitest run",
52
+ "test:types": "tsd",
53
+ "api-extractor": "api-extractor run",
54
+ "api-extractor:local": "api-extractor run --local",
55
+ "api-documenter": "api-documenter markdown -i temp -o docs"
56
+ }
57
+ }