formspec 0.1.0-alpha.12 → 0.1.0-alpha.14
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 +8 -8
- package/dist/formspec.d.ts +33 -0
- package/dist/index.cjs +23 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -147,14 +147,14 @@ You can import from the umbrella package for convenience, or from individual pac
|
|
|
147
147
|
|
|
148
148
|
## Related Packages
|
|
149
149
|
|
|
150
|
-
| Package
|
|
151
|
-
|
|
|
152
|
-
| `@formspec/constraints`
|
|
153
|
-
| `@formspec/validator`
|
|
154
|
-
| `@formspec/eslint-plugin`
|
|
155
|
-
| `@formspec/language-server` | Language server for editor integration
|
|
156
|
-
| `@formspec/cli`
|
|
157
|
-
| `@formspec/playground`
|
|
150
|
+
| Package | Description |
|
|
151
|
+
| --------------------------- | ------------------------------------------ |
|
|
152
|
+
| `@formspec/constraints` | Constraint definitions and validators |
|
|
153
|
+
| `@formspec/validator` | JSON Schema validation for secure runtimes |
|
|
154
|
+
| `@formspec/eslint-plugin` | ESLint rules for FormSpec |
|
|
155
|
+
| `@formspec/language-server` | Language server for editor integration |
|
|
156
|
+
| `@formspec/cli` | CLI tool for build-time schema generation |
|
|
157
|
+
| `@formspec/playground` | Interactive browser editor (private) |
|
|
158
158
|
|
|
159
159
|
## License
|
|
160
160
|
|
package/dist/formspec.d.ts
CHANGED
|
@@ -91,6 +91,17 @@ import { InferFieldValue } from '@formspec/dsl';
|
|
|
91
91
|
import { InferFormSchema } from '@formspec/dsl';
|
|
92
92
|
import { InferSchema } from '@formspec/dsl';
|
|
93
93
|
import { is } from '@formspec/dsl';
|
|
94
|
+
import { isArrayField } from '@formspec/core';
|
|
95
|
+
import { isBooleanField } from '@formspec/core';
|
|
96
|
+
import { isConditional } from '@formspec/core';
|
|
97
|
+
import { isDynamicEnumField } from '@formspec/core';
|
|
98
|
+
import { isDynamicSchemaField } from '@formspec/core';
|
|
99
|
+
import { isField } from '@formspec/core';
|
|
100
|
+
import { isGroup } from '@formspec/core';
|
|
101
|
+
import { isNumberField } from '@formspec/core';
|
|
102
|
+
import { isObjectField } from '@formspec/core';
|
|
103
|
+
import { isStaticEnumField } from '@formspec/core';
|
|
104
|
+
import { isTextField } from '@formspec/core';
|
|
94
105
|
import { JsonSchema2020 } from '@formspec/build';
|
|
95
106
|
import { JSONSchema7 } from '@formspec/build';
|
|
96
107
|
import { JSONSchemaType } from '@formspec/build';
|
|
@@ -198,6 +209,28 @@ export { InferSchema }
|
|
|
198
209
|
|
|
199
210
|
export { is }
|
|
200
211
|
|
|
212
|
+
export { isArrayField }
|
|
213
|
+
|
|
214
|
+
export { isBooleanField }
|
|
215
|
+
|
|
216
|
+
export { isConditional }
|
|
217
|
+
|
|
218
|
+
export { isDynamicEnumField }
|
|
219
|
+
|
|
220
|
+
export { isDynamicSchemaField }
|
|
221
|
+
|
|
222
|
+
export { isField }
|
|
223
|
+
|
|
224
|
+
export { isGroup }
|
|
225
|
+
|
|
226
|
+
export { isNumberField }
|
|
227
|
+
|
|
228
|
+
export { isObjectField }
|
|
229
|
+
|
|
230
|
+
export { isStaticEnumField }
|
|
231
|
+
|
|
232
|
+
export { isTextField }
|
|
233
|
+
|
|
201
234
|
export { JsonSchema2020 }
|
|
202
235
|
|
|
203
236
|
export { JSONSchema7 }
|
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,17 @@ __export(index_exports, {
|
|
|
30
30
|
generateUiSchema: () => import_build.generateUiSchema,
|
|
31
31
|
group: () => import_dsl.group,
|
|
32
32
|
is: () => import_dsl.is,
|
|
33
|
+
isArrayField: () => import_core2.isArrayField,
|
|
34
|
+
isBooleanField: () => import_core2.isBooleanField,
|
|
35
|
+
isConditional: () => import_core2.isConditional,
|
|
36
|
+
isDynamicEnumField: () => import_core2.isDynamicEnumField,
|
|
37
|
+
isDynamicSchemaField: () => import_core2.isDynamicSchemaField,
|
|
38
|
+
isField: () => import_core2.isField,
|
|
39
|
+
isGroup: () => import_core2.isGroup,
|
|
40
|
+
isNumberField: () => import_core2.isNumberField,
|
|
41
|
+
isObjectField: () => import_core2.isObjectField,
|
|
42
|
+
isStaticEnumField: () => import_core2.isStaticEnumField,
|
|
43
|
+
isTextField: () => import_core2.isTextField,
|
|
33
44
|
logValidationIssues: () => import_dsl.logValidationIssues,
|
|
34
45
|
validateForm: () => import_dsl.validateForm,
|
|
35
46
|
when: () => import_dsl.when,
|
|
@@ -37,6 +48,7 @@ __export(index_exports, {
|
|
|
37
48
|
});
|
|
38
49
|
module.exports = __toCommonJS(index_exports);
|
|
39
50
|
var import_core = require("@formspec/core");
|
|
51
|
+
var import_core2 = require("@formspec/core");
|
|
40
52
|
var import_dsl = require("@formspec/dsl");
|
|
41
53
|
var import_build = require("@formspec/build");
|
|
42
54
|
var import_runtime = require("@formspec/runtime");
|
|
@@ -52,6 +64,17 @@ var import_runtime = require("@formspec/runtime");
|
|
|
52
64
|
generateUiSchema,
|
|
53
65
|
group,
|
|
54
66
|
is,
|
|
67
|
+
isArrayField,
|
|
68
|
+
isBooleanField,
|
|
69
|
+
isConditional,
|
|
70
|
+
isDynamicEnumField,
|
|
71
|
+
isDynamicSchemaField,
|
|
72
|
+
isField,
|
|
73
|
+
isGroup,
|
|
74
|
+
isNumberField,
|
|
75
|
+
isObjectField,
|
|
76
|
+
isStaticEnumField,
|
|
77
|
+
isTextField,
|
|
55
78
|
logValidationIssues,
|
|
56
79
|
validateForm,
|
|
57
80
|
when,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * FormSpec - Type-safe form specifications\n *\n * This package re-exports everything from the FormSpec library for convenience.\n * You can import everything you need from a single package:\n *\n * @example\n * ```typescript\n * import {\n * // DSL functions\n * formspec, field, group, when, is,\n * // Type inference\n * type InferSchema,\n * // Schema generation\n * buildFormSchemas,\n * // Resolvers\n * defineResolvers,\n * // Core types\n * type FormSpec, type FormElement,\n * } from \"formspec\";\n *\n * // Define a form\n * const InvoiceForm = formspec(\n * group(\"Customer\",\n * field.text(\"name\", { label: \"Name\", required: true }),\n * field.dynamicEnum(\"country\", \"fetch_countries\", { label: \"Country\" }),\n * ),\n * group(\"Details\",\n * field.number(\"amount\", { label: \"Amount\", min: 0 }),\n * field.enum(\"status\", [\"draft\", \"sent\", \"paid\"]),\n * when(is(\"status\", \"draft\"),\n * field.text(\"notes\", { label: \"Internal Notes\" }),\n * ),\n * ),\n * );\n *\n * // Infer the schema type\n * type Schema = InferSchema<typeof InvoiceForm.elements>;\n *\n * // Generate JSON Schema and UI Schema\n * const { jsonSchema, uiSchema } = buildFormSchemas(InvoiceForm);\n *\n * // Define resolvers for dynamic data\n * const resolvers = defineResolvers(InvoiceForm, {\n * fetch_countries: async () => ({\n * options: [{ value: \"us\", label: \"United States\" }],\n * validity: \"valid\",\n * }),\n * });\n * ```\n *\n * @packageDocumentation\n */\n\n// =============================================================================\n// Core types\n// =============================================================================\n\nexport type {\n // Validity\n Validity,\n\n // Field state\n FieldState,\n\n // Form state\n FormState,\n\n // Data sources\n DataSourceRegistry,\n DataSourceOption,\n FetchOptionsResponse,\n DataSourceValueType,\n\n // Elements\n TextField,\n NumberField,\n BooleanField,\n StaticEnumField,\n DynamicEnumField,\n DynamicSchemaField,\n ArrayField,\n ObjectField,\n AnyField,\n Group,\n Conditional,\n FormElement,\n FormSpec,\n\n // Predicates\n EqualsPredicate,\n Predicate,\n} from \"@formspec/core\";\n\nexport { createInitialFieldState } from \"@formspec/core\";\n\n// =============================================================================\n// DSL functions\n// =============================================================================\n\nexport {\n field,\n group,\n when,\n is,\n formspec,\n formspecWithValidation,\n validateForm,\n logValidationIssues,\n} from \"@formspec/dsl\";\n\n// Re-export enum option types (commonly used)\nexport type { EnumOption, EnumOptionValue } from \"@formspec/dsl\";\n\nexport type {\n // Type inference\n InferFieldValue,\n ExtractFields,\n ExtractFieldsFromArray,\n BuildSchema,\n InferSchema,\n InferFormSchema,\n // Validation\n FormSpecOptions,\n ValidationSeverity,\n ValidationIssue,\n ValidationResult,\n} from \"@formspec/dsl\";\n\n// =============================================================================\n// Build tools\n// =============================================================================\n\nexport {\n generateJsonSchema,\n generateUiSchema,\n buildFormSchemas,\n writeSchemas,\n} from \"@formspec/build\";\n\nexport type {\n JsonSchema2020,\n JSONSchema7,\n JSONSchemaType,\n UISchema,\n UISchemaElement,\n UISchemaElementType,\n ControlElement,\n VerticalLayout,\n HorizontalLayout,\n GroupLayout,\n Rule,\n RuleEffect,\n SchemaBasedCondition,\n BuildResult,\n WriteSchemasOptions,\n WriteSchemasResult,\n} from \"@formspec/build\";\n\n// =============================================================================\n// Runtime helpers\n// =============================================================================\n\nexport { defineResolvers } from \"@formspec/runtime\";\n\nexport type { Resolver, ResolverMap, ResolverRegistry } from \"@formspec/runtime\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8FA,kBAAwC;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * FormSpec - Type-safe form specifications\n *\n * This package re-exports everything from the FormSpec library for convenience.\n * You can import everything you need from a single package:\n *\n * @example\n * ```typescript\n * import {\n * // DSL functions\n * formspec, field, group, when, is,\n * // Type inference\n * type InferSchema,\n * // Schema generation\n * buildFormSchemas,\n * // Resolvers\n * defineResolvers,\n * // Core types\n * type FormSpec, type FormElement,\n * } from \"formspec\";\n *\n * // Define a form\n * const InvoiceForm = formspec(\n * group(\"Customer\",\n * field.text(\"name\", { label: \"Name\", required: true }),\n * field.dynamicEnum(\"country\", \"fetch_countries\", { label: \"Country\" }),\n * ),\n * group(\"Details\",\n * field.number(\"amount\", { label: \"Amount\", min: 0 }),\n * field.enum(\"status\", [\"draft\", \"sent\", \"paid\"]),\n * when(is(\"status\", \"draft\"),\n * field.text(\"notes\", { label: \"Internal Notes\" }),\n * ),\n * ),\n * );\n *\n * // Infer the schema type\n * type Schema = InferSchema<typeof InvoiceForm.elements>;\n *\n * // Generate JSON Schema and UI Schema\n * const { jsonSchema, uiSchema } = buildFormSchemas(InvoiceForm);\n *\n * // Define resolvers for dynamic data\n * const resolvers = defineResolvers(InvoiceForm, {\n * fetch_countries: async () => ({\n * options: [{ value: \"us\", label: \"United States\" }],\n * validity: \"valid\",\n * }),\n * });\n * ```\n *\n * @packageDocumentation\n */\n\n// =============================================================================\n// Core types\n// =============================================================================\n\nexport type {\n // Validity\n Validity,\n\n // Field state\n FieldState,\n\n // Form state\n FormState,\n\n // Data sources\n DataSourceRegistry,\n DataSourceOption,\n FetchOptionsResponse,\n DataSourceValueType,\n\n // Elements\n TextField,\n NumberField,\n BooleanField,\n StaticEnumField,\n DynamicEnumField,\n DynamicSchemaField,\n ArrayField,\n ObjectField,\n AnyField,\n Group,\n Conditional,\n FormElement,\n FormSpec,\n\n // Predicates\n EqualsPredicate,\n Predicate,\n} from \"@formspec/core\";\n\nexport { createInitialFieldState } from \"@formspec/core\";\n\n// Type guards\nexport {\n isField,\n isTextField,\n isNumberField,\n isBooleanField,\n isStaticEnumField,\n isDynamicEnumField,\n isDynamicSchemaField,\n isArrayField,\n isObjectField,\n isGroup,\n isConditional,\n} from \"@formspec/core\";\n\n// =============================================================================\n// DSL functions\n// =============================================================================\n\nexport {\n field,\n group,\n when,\n is,\n formspec,\n formspecWithValidation,\n validateForm,\n logValidationIssues,\n} from \"@formspec/dsl\";\n\n// Re-export enum option types (commonly used)\nexport type { EnumOption, EnumOptionValue } from \"@formspec/dsl\";\n\nexport type {\n // Type inference\n InferFieldValue,\n ExtractFields,\n ExtractFieldsFromArray,\n BuildSchema,\n InferSchema,\n InferFormSchema,\n // Validation\n FormSpecOptions,\n ValidationSeverity,\n ValidationIssue,\n ValidationResult,\n} from \"@formspec/dsl\";\n\n// =============================================================================\n// Build tools\n// =============================================================================\n\nexport {\n generateJsonSchema,\n generateUiSchema,\n buildFormSchemas,\n writeSchemas,\n} from \"@formspec/build\";\n\nexport type {\n JsonSchema2020,\n JSONSchema7,\n JSONSchemaType,\n UISchema,\n UISchemaElement,\n UISchemaElementType,\n ControlElement,\n VerticalLayout,\n HorizontalLayout,\n GroupLayout,\n Rule,\n RuleEffect,\n SchemaBasedCondition,\n BuildResult,\n WriteSchemasOptions,\n WriteSchemasResult,\n} from \"@formspec/build\";\n\n// =============================================================================\n// Runtime helpers\n// =============================================================================\n\nexport { defineResolvers } from \"@formspec/runtime\";\n\nexport type { Resolver, ResolverMap, ResolverRegistry } from \"@formspec/runtime\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8FA,kBAAwC;AAGxC,IAAAA,eAYO;AAMP,iBASO;AAwBP,mBAKO;AAyBP,qBAAgC;","names":["import_core"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
*/
|
|
54
54
|
export type { Validity, FieldState, FormState, DataSourceRegistry, DataSourceOption, FetchOptionsResponse, DataSourceValueType, TextField, NumberField, BooleanField, StaticEnumField, DynamicEnumField, DynamicSchemaField, ArrayField, ObjectField, AnyField, Group, Conditional, FormElement, FormSpec, EqualsPredicate, Predicate, } from "@formspec/core";
|
|
55
55
|
export { createInitialFieldState } from "@formspec/core";
|
|
56
|
+
export { isField, isTextField, isNumberField, isBooleanField, isStaticEnumField, isDynamicEnumField, isDynamicSchemaField, isArrayField, isObjectField, isGroup, isConditional, } from "@formspec/core";
|
|
56
57
|
export { field, group, when, is, formspec, formspecWithValidation, validateForm, logValidationIssues, } from "@formspec/dsl";
|
|
57
58
|
export type { EnumOption, EnumOptionValue } from "@formspec/dsl";
|
|
58
59
|
export type { InferFieldValue, ExtractFields, ExtractFieldsFromArray, BuildSchema, InferSchema, InferFormSchema, FormSpecOptions, ValidationSeverity, ValidationIssue, ValidationResult, } from "@formspec/dsl";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAMH,YAAY,EAEV,QAAQ,EAGR,UAAU,EAGV,SAAS,EAGT,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EAGnB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,QAAQ,EACR,KAAK,EACL,WAAW,EACX,WAAW,EACX,QAAQ,EAGR,eAAe,EACf,SAAS,GACV,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAMH,YAAY,EAEV,QAAQ,EAGR,UAAU,EAGV,SAAS,EAGT,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EAGnB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,QAAQ,EACR,KAAK,EACL,WAAW,EACX,WAAW,EACX,QAAQ,EAGR,eAAe,EACf,SAAS,GACV,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAGzD,OAAO,EACL,OAAO,EACP,WAAW,EACX,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACb,OAAO,EACP,aAAa,GACd,MAAM,gBAAgB,CAAC;AAMxB,OAAO,EACL,KAAK,EACL,KAAK,EACL,IAAI,EACJ,EAAE,EACF,QAAQ,EACR,sBAAsB,EACtB,YAAY,EACZ,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAGvB,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEjE,YAAY,EAEV,eAAe,EACf,aAAa,EACb,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,eAAe,EAEf,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAMvB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,GACb,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,cAAc,EACd,WAAW,EACX,cAAc,EACd,QAAQ,EACR,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,IAAI,EACJ,UAAU,EACV,oBAAoB,EACpB,WAAW,EACX,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AAMzB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { createInitialFieldState } from "@formspec/core";
|
|
3
|
+
import {
|
|
4
|
+
isField,
|
|
5
|
+
isTextField,
|
|
6
|
+
isNumberField,
|
|
7
|
+
isBooleanField,
|
|
8
|
+
isStaticEnumField,
|
|
9
|
+
isDynamicEnumField,
|
|
10
|
+
isDynamicSchemaField,
|
|
11
|
+
isArrayField,
|
|
12
|
+
isObjectField,
|
|
13
|
+
isGroup,
|
|
14
|
+
isConditional
|
|
15
|
+
} from "@formspec/core";
|
|
3
16
|
import {
|
|
4
17
|
field,
|
|
5
18
|
group,
|
|
@@ -28,6 +41,17 @@ export {
|
|
|
28
41
|
generateUiSchema,
|
|
29
42
|
group,
|
|
30
43
|
is,
|
|
44
|
+
isArrayField,
|
|
45
|
+
isBooleanField,
|
|
46
|
+
isConditional,
|
|
47
|
+
isDynamicEnumField,
|
|
48
|
+
isDynamicSchemaField,
|
|
49
|
+
isField,
|
|
50
|
+
isGroup,
|
|
51
|
+
isNumberField,
|
|
52
|
+
isObjectField,
|
|
53
|
+
isStaticEnumField,
|
|
54
|
+
isTextField,
|
|
31
55
|
logValidationIssues,
|
|
32
56
|
validateForm,
|
|
33
57
|
when,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * FormSpec - Type-safe form specifications\n *\n * This package re-exports everything from the FormSpec library for convenience.\n * You can import everything you need from a single package:\n *\n * @example\n * ```typescript\n * import {\n * // DSL functions\n * formspec, field, group, when, is,\n * // Type inference\n * type InferSchema,\n * // Schema generation\n * buildFormSchemas,\n * // Resolvers\n * defineResolvers,\n * // Core types\n * type FormSpec, type FormElement,\n * } from \"formspec\";\n *\n * // Define a form\n * const InvoiceForm = formspec(\n * group(\"Customer\",\n * field.text(\"name\", { label: \"Name\", required: true }),\n * field.dynamicEnum(\"country\", \"fetch_countries\", { label: \"Country\" }),\n * ),\n * group(\"Details\",\n * field.number(\"amount\", { label: \"Amount\", min: 0 }),\n * field.enum(\"status\", [\"draft\", \"sent\", \"paid\"]),\n * when(is(\"status\", \"draft\"),\n * field.text(\"notes\", { label: \"Internal Notes\" }),\n * ),\n * ),\n * );\n *\n * // Infer the schema type\n * type Schema = InferSchema<typeof InvoiceForm.elements>;\n *\n * // Generate JSON Schema and UI Schema\n * const { jsonSchema, uiSchema } = buildFormSchemas(InvoiceForm);\n *\n * // Define resolvers for dynamic data\n * const resolvers = defineResolvers(InvoiceForm, {\n * fetch_countries: async () => ({\n * options: [{ value: \"us\", label: \"United States\" }],\n * validity: \"valid\",\n * }),\n * });\n * ```\n *\n * @packageDocumentation\n */\n\n// =============================================================================\n// Core types\n// =============================================================================\n\nexport type {\n // Validity\n Validity,\n\n // Field state\n FieldState,\n\n // Form state\n FormState,\n\n // Data sources\n DataSourceRegistry,\n DataSourceOption,\n FetchOptionsResponse,\n DataSourceValueType,\n\n // Elements\n TextField,\n NumberField,\n BooleanField,\n StaticEnumField,\n DynamicEnumField,\n DynamicSchemaField,\n ArrayField,\n ObjectField,\n AnyField,\n Group,\n Conditional,\n FormElement,\n FormSpec,\n\n // Predicates\n EqualsPredicate,\n Predicate,\n} from \"@formspec/core\";\n\nexport { createInitialFieldState } from \"@formspec/core\";\n\n// =============================================================================\n// DSL functions\n// =============================================================================\n\nexport {\n field,\n group,\n when,\n is,\n formspec,\n formspecWithValidation,\n validateForm,\n logValidationIssues,\n} from \"@formspec/dsl\";\n\n// Re-export enum option types (commonly used)\nexport type { EnumOption, EnumOptionValue } from \"@formspec/dsl\";\n\nexport type {\n // Type inference\n InferFieldValue,\n ExtractFields,\n ExtractFieldsFromArray,\n BuildSchema,\n InferSchema,\n InferFormSchema,\n // Validation\n FormSpecOptions,\n ValidationSeverity,\n ValidationIssue,\n ValidationResult,\n} from \"@formspec/dsl\";\n\n// =============================================================================\n// Build tools\n// =============================================================================\n\nexport {\n generateJsonSchema,\n generateUiSchema,\n buildFormSchemas,\n writeSchemas,\n} from \"@formspec/build\";\n\nexport type {\n JsonSchema2020,\n JSONSchema7,\n JSONSchemaType,\n UISchema,\n UISchemaElement,\n UISchemaElementType,\n ControlElement,\n VerticalLayout,\n HorizontalLayout,\n GroupLayout,\n Rule,\n RuleEffect,\n SchemaBasedCondition,\n BuildResult,\n WriteSchemasOptions,\n WriteSchemasResult,\n} from \"@formspec/build\";\n\n// =============================================================================\n// Runtime helpers\n// =============================================================================\n\nexport { defineResolvers } from \"@formspec/runtime\";\n\nexport type { Resolver, ResolverMap, ResolverRegistry } from \"@formspec/runtime\";\n"],"mappings":";AA8FA,SAAS,+BAA+B;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * FormSpec - Type-safe form specifications\n *\n * This package re-exports everything from the FormSpec library for convenience.\n * You can import everything you need from a single package:\n *\n * @example\n * ```typescript\n * import {\n * // DSL functions\n * formspec, field, group, when, is,\n * // Type inference\n * type InferSchema,\n * // Schema generation\n * buildFormSchemas,\n * // Resolvers\n * defineResolvers,\n * // Core types\n * type FormSpec, type FormElement,\n * } from \"formspec\";\n *\n * // Define a form\n * const InvoiceForm = formspec(\n * group(\"Customer\",\n * field.text(\"name\", { label: \"Name\", required: true }),\n * field.dynamicEnum(\"country\", \"fetch_countries\", { label: \"Country\" }),\n * ),\n * group(\"Details\",\n * field.number(\"amount\", { label: \"Amount\", min: 0 }),\n * field.enum(\"status\", [\"draft\", \"sent\", \"paid\"]),\n * when(is(\"status\", \"draft\"),\n * field.text(\"notes\", { label: \"Internal Notes\" }),\n * ),\n * ),\n * );\n *\n * // Infer the schema type\n * type Schema = InferSchema<typeof InvoiceForm.elements>;\n *\n * // Generate JSON Schema and UI Schema\n * const { jsonSchema, uiSchema } = buildFormSchemas(InvoiceForm);\n *\n * // Define resolvers for dynamic data\n * const resolvers = defineResolvers(InvoiceForm, {\n * fetch_countries: async () => ({\n * options: [{ value: \"us\", label: \"United States\" }],\n * validity: \"valid\",\n * }),\n * });\n * ```\n *\n * @packageDocumentation\n */\n\n// =============================================================================\n// Core types\n// =============================================================================\n\nexport type {\n // Validity\n Validity,\n\n // Field state\n FieldState,\n\n // Form state\n FormState,\n\n // Data sources\n DataSourceRegistry,\n DataSourceOption,\n FetchOptionsResponse,\n DataSourceValueType,\n\n // Elements\n TextField,\n NumberField,\n BooleanField,\n StaticEnumField,\n DynamicEnumField,\n DynamicSchemaField,\n ArrayField,\n ObjectField,\n AnyField,\n Group,\n Conditional,\n FormElement,\n FormSpec,\n\n // Predicates\n EqualsPredicate,\n Predicate,\n} from \"@formspec/core\";\n\nexport { createInitialFieldState } from \"@formspec/core\";\n\n// Type guards\nexport {\n isField,\n isTextField,\n isNumberField,\n isBooleanField,\n isStaticEnumField,\n isDynamicEnumField,\n isDynamicSchemaField,\n isArrayField,\n isObjectField,\n isGroup,\n isConditional,\n} from \"@formspec/core\";\n\n// =============================================================================\n// DSL functions\n// =============================================================================\n\nexport {\n field,\n group,\n when,\n is,\n formspec,\n formspecWithValidation,\n validateForm,\n logValidationIssues,\n} from \"@formspec/dsl\";\n\n// Re-export enum option types (commonly used)\nexport type { EnumOption, EnumOptionValue } from \"@formspec/dsl\";\n\nexport type {\n // Type inference\n InferFieldValue,\n ExtractFields,\n ExtractFieldsFromArray,\n BuildSchema,\n InferSchema,\n InferFormSchema,\n // Validation\n FormSpecOptions,\n ValidationSeverity,\n ValidationIssue,\n ValidationResult,\n} from \"@formspec/dsl\";\n\n// =============================================================================\n// Build tools\n// =============================================================================\n\nexport {\n generateJsonSchema,\n generateUiSchema,\n buildFormSchemas,\n writeSchemas,\n} from \"@formspec/build\";\n\nexport type {\n JsonSchema2020,\n JSONSchema7,\n JSONSchemaType,\n UISchema,\n UISchemaElement,\n UISchemaElementType,\n ControlElement,\n VerticalLayout,\n HorizontalLayout,\n GroupLayout,\n Rule,\n RuleEffect,\n SchemaBasedCondition,\n BuildResult,\n WriteSchemasOptions,\n WriteSchemasResult,\n} from \"@formspec/build\";\n\n// =============================================================================\n// Runtime helpers\n// =============================================================================\n\nexport { defineResolvers } from \"@formspec/runtime\";\n\nexport type { Resolver, ResolverMap, ResolverRegistry } from \"@formspec/runtime\";\n"],"mappings":";AA8FA,SAAS,+BAA+B;AAGxC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAwBP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAyBP,SAAS,uBAAuB;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "formspec",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.14",
|
|
4
4
|
"description": "Type-safe form specifications that compile to JSON Schema and JSON Forms UI Schema",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"README.md"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@formspec/core": "0.1.0-alpha.
|
|
22
|
-
"@formspec/dsl": "0.1.0-alpha.
|
|
23
|
-
"@formspec/build": "0.1.0-alpha.
|
|
24
|
-
"@formspec/runtime": "0.1.0-alpha.
|
|
21
|
+
"@formspec/core": "0.1.0-alpha.14",
|
|
22
|
+
"@formspec/dsl": "0.1.0-alpha.14",
|
|
23
|
+
"@formspec/build": "0.1.0-alpha.14",
|
|
24
|
+
"@formspec/runtime": "0.1.0-alpha.14"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|