formspec 0.1.0-alpha.10 → 0.1.0-alpha.11

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 ADDED
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ buildFormSchemas: () => import_build.buildFormSchemas,
24
+ createInitialFieldState: () => import_core.createInitialFieldState,
25
+ defineResolvers: () => import_runtime.defineResolvers,
26
+ field: () => import_dsl.field,
27
+ formspec: () => import_dsl.formspec,
28
+ formspecWithValidation: () => import_dsl.formspecWithValidation,
29
+ generateJsonSchema: () => import_build.generateJsonSchema,
30
+ generateUiSchema: () => import_build.generateUiSchema,
31
+ group: () => import_dsl.group,
32
+ is: () => import_dsl.is,
33
+ logValidationIssues: () => import_dsl.logValidationIssues,
34
+ validateForm: () => import_dsl.validateForm,
35
+ when: () => import_dsl.when,
36
+ writeSchemas: () => import_build.writeSchemas
37
+ });
38
+ module.exports = __toCommonJS(index_exports);
39
+ var import_core = require("@formspec/core");
40
+ var import_dsl = require("@formspec/dsl");
41
+ var import_build = require("@formspec/build");
42
+ var import_runtime = require("@formspec/runtime");
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ buildFormSchemas,
46
+ createInitialFieldState,
47
+ defineResolvers,
48
+ field,
49
+ formspec,
50
+ formspecWithValidation,
51
+ generateJsonSchema,
52
+ generateUiSchema,
53
+ group,
54
+ is,
55
+ logValidationIssues,
56
+ validateForm,
57
+ when,
58
+ writeSchemas
59
+ });
60
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +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 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;AAMxC,iBASO;AAwBP,mBAKO;AAwBP,qBAAgC;","names":[]}
package/dist/index.js CHANGED
@@ -1,67 +1,36 @@
1
- /**
2
- * FormSpec - Type-safe form specifications
3
- *
4
- * This package re-exports everything from the FormSpec library for convenience.
5
- * You can import everything you need from a single package:
6
- *
7
- * @example
8
- * ```typescript
9
- * import {
10
- * // DSL functions
11
- * formspec, field, group, when, is,
12
- * // Type inference
13
- * type InferSchema,
14
- * // Schema generation
15
- * buildFormSchemas,
16
- * // Resolvers
17
- * defineResolvers,
18
- * // Core types
19
- * type FormSpec, type FormElement,
20
- * } from "formspec";
21
- *
22
- * // Define a form
23
- * const InvoiceForm = formspec(
24
- * group("Customer",
25
- * field.text("name", { label: "Name", required: true }),
26
- * field.dynamicEnum("country", "fetch_countries", { label: "Country" }),
27
- * ),
28
- * group("Details",
29
- * field.number("amount", { label: "Amount", min: 0 }),
30
- * field.enum("status", ["draft", "sent", "paid"]),
31
- * when(is("status", "draft"),
32
- * field.text("notes", { label: "Internal Notes" }),
33
- * ),
34
- * ),
35
- * );
36
- *
37
- * // Infer the schema type
38
- * type Schema = InferSchema<typeof InvoiceForm.elements>;
39
- *
40
- * // Generate JSON Schema and UI Schema
41
- * const { jsonSchema, uiSchema } = buildFormSchemas(InvoiceForm);
42
- *
43
- * // Define resolvers for dynamic data
44
- * const resolvers = defineResolvers(InvoiceForm, {
45
- * fetch_countries: async () => ({
46
- * options: [{ value: "us", label: "United States" }],
47
- * validity: "valid",
48
- * }),
49
- * });
50
- * ```
51
- *
52
- * @packageDocumentation
53
- */
54
- export { createInitialFieldState } from "@formspec/core";
55
- // =============================================================================
56
- // DSL functions
57
- // =============================================================================
58
- export { field, group, when, is, formspec, formspecWithValidation, validateForm, logValidationIssues, } from "@formspec/dsl";
59
- // =============================================================================
60
- // Build tools
61
- // =============================================================================
62
- export { generateJsonSchema, generateUiSchema, buildFormSchemas, writeSchemas, } from "@formspec/build";
63
- // =============================================================================
64
- // Runtime helpers
65
- // =============================================================================
66
- export { defineResolvers } from "@formspec/runtime";
1
+ // src/index.ts
2
+ import { createInitialFieldState } from "@formspec/core";
3
+ import {
4
+ field,
5
+ group,
6
+ when,
7
+ is,
8
+ formspec,
9
+ formspecWithValidation,
10
+ validateForm,
11
+ logValidationIssues
12
+ } from "@formspec/dsl";
13
+ import {
14
+ generateJsonSchema,
15
+ generateUiSchema,
16
+ buildFormSchemas,
17
+ writeSchemas
18
+ } from "@formspec/build";
19
+ import { defineResolvers } from "@formspec/runtime";
20
+ export {
21
+ buildFormSchemas,
22
+ createInitialFieldState,
23
+ defineResolvers,
24
+ field,
25
+ formspec,
26
+ formspecWithValidation,
27
+ generateJsonSchema,
28
+ generateUiSchema,
29
+ group,
30
+ is,
31
+ logValidationIssues,
32
+ validateForm,
33
+ when,
34
+ writeSchemas
35
+ };
67
36
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AA0CH,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,gFAAgF;AAChF,gBAAgB;AAChB,gFAAgF;AAEhF,OAAO,EACL,KAAK,EACL,KAAK,EACL,IAAI,EACJ,EAAE,EACF,QAAQ,EACR,sBAAsB,EACtB,YAAY,EACZ,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAoBvB,gFAAgF;AAChF,cAAc;AACd,gFAAgF;AAEhF,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,GACb,MAAM,iBAAiB,CAAC;AAoBzB,gFAAgF;AAChF,kBAAkB;AAClB,gFAAgF;AAEhF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
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 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;AAMxC;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;AAwBP,SAAS,uBAAuB;","names":[]}
package/package.json CHANGED
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "name": "formspec",
3
- "version": "0.1.0-alpha.10",
3
+ "version": "0.1.0-alpha.11",
4
4
  "description": "Type-safe form specifications that compile to JSON Schema and JSON Forms UI Schema",
5
5
  "type": "module",
6
- "main": "./dist/index.js",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
7
8
  "types": "./dist/formspec.d.ts",
8
9
  "exports": {
9
10
  ".": {
10
11
  "types": "./dist/formspec.d.ts",
11
- "import": "./dist/index.js"
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
12
14
  }
13
15
  },
14
16
  "files": [
@@ -16,10 +18,10 @@
16
18
  "README.md"
17
19
  ],
18
20
  "dependencies": {
19
- "@formspec/core": "0.1.0-alpha.10",
20
- "@formspec/dsl": "0.1.0-alpha.10",
21
- "@formspec/build": "0.1.0-alpha.10",
22
- "@formspec/runtime": "0.1.0-alpha.10"
21
+ "@formspec/core": "0.1.0-alpha.11",
22
+ "@formspec/dsl": "0.1.0-alpha.11",
23
+ "@formspec/build": "0.1.0-alpha.11",
24
+ "@formspec/runtime": "0.1.0-alpha.11"
23
25
  },
24
26
  "publishConfig": {
25
27
  "access": "public"
@@ -34,7 +36,7 @@
34
36
  ],
35
37
  "license": "UNLICENSED",
36
38
  "scripts": {
37
- "build": "tsc && declaration-file-normalizer dist/index.d.ts && api-extractor run --local",
39
+ "build": "tsup && tsc --emitDeclarationOnly && declaration-file-normalizer dist/index.d.ts && api-extractor run --local",
38
40
  "clean": "rm -rf dist temp",
39
41
  "typecheck": "tsc --noEmit",
40
42
  "api-extractor": "api-extractor run",