attaform 0.29.0 → 0.30.1
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/abstract.d.mts +15 -21
- package/dist/abstract.mjs +4 -4
- package/dist/dev/abstract.mjs +4 -4
- package/dist/dev/chunks/dev-key-collision-warnings.mjs +47 -8
- package/dist/dev/chunks/devtools.mjs +2 -2
- package/dist/dev/directive.mjs +1 -1
- package/dist/dev/history.mjs +1 -2
- package/dist/dev/index.mjs +5 -5
- package/dist/dev/runtime/plugins/attaform.mjs +3 -3
- package/dist/dev/shared/{attaform-dev.BO-71R54.mjs → attaform-dev.BJK1kqHY.mjs} +44 -198
- package/dist/dev/shared/{attaform-dev.D8aoKb89.mjs → attaform-dev.BMQ3GcgD.mjs} +51 -64
- package/dist/dev/shared/{attaform-dev.BgM6FdtA.mjs → attaform-dev.BUIFcTYf.mjs} +94 -62
- package/dist/dev/shared/{attaform-dev.q6UutkCx.mjs → attaform-dev.CT7MDjPy.mjs} +92 -152
- package/dist/dev/shared/{attaform-dev.ButTkwHd.mjs → attaform-dev.CZz4GYZ6.mjs} +26 -15
- package/dist/dev/shared/{attaform-dev.DD5m2W51.mjs → attaform-dev.Chm4D6SJ.mjs} +2 -4
- package/dist/dev/shared/{attaform-dev.DrzObAZo.mjs → attaform-dev.DuEE4GU1.mjs} +4 -4
- package/dist/dev/shared/{attaform-dev.DHuydLAC.mjs → attaform-dev.DxHdkkPG.mjs} +674 -734
- package/dist/dev/shared/{attaform-dev.A-TpJW0B.mjs → attaform-dev.zlvDr0WB.mjs} +3 -21
- package/dist/dev/zod-v3.mjs +6 -6
- package/dist/dev/zod-v4.mjs +6 -6
- package/dist/dev/zod.mjs +5 -5
- package/dist/directive.d.mts +4 -4
- package/dist/directive.mjs +1 -1
- package/dist/esbuild.d.mts +11 -0
- package/dist/esbuild.mjs +1 -1
- package/dist/history.d.mts +3 -32
- package/dist/history.mjs +1 -2
- package/dist/index.d.mts +67 -70
- package/dist/index.mjs +5 -5
- package/dist/nuxt.d.mts +6 -14
- package/dist/nuxt.mjs +3 -7
- package/dist/rollup.d.mts +11 -0
- package/dist/rollup.mjs +1 -1
- package/dist/rspack.d.mts +19 -11
- package/dist/rspack.mjs +1 -1
- package/dist/runtime/components/AttaformDevtoolsPanel.vue +12 -12
- package/dist/runtime/components/DevtoolsValueTree.vue +2 -2
- package/dist/runtime/plugins/attaform.mjs +3 -3
- package/dist/shared/{attaform.CIWLMY-R.d.mts → attaform.2FslhB9R.d.mts} +83 -95
- package/dist/shared/{attaform.Cvao8bW5.mjs → attaform.8mfKZCwH.mjs} +7 -7
- package/dist/shared/{attaform.DRUT703x.d.mts → attaform.B-Tb62qV.d.mts} +12 -12
- package/dist/shared/{attaform.v0fQtWyA.mjs → attaform.B1rH9ht6.mjs} +1 -1
- package/dist/shared/{attaform.BndjUUYX.mjs → attaform.B2iebkPA.mjs} +4 -4
- package/dist/shared/{attaform.DhnPb6nK.mjs → attaform.BAf3UNn4.mjs} +1 -1
- package/dist/shared/{attaform.CZMAYwSK.mjs → attaform.BIWicztt.mjs} +651 -678
- package/dist/shared/attaform.BcQwgWaq.d.mts +2153 -0
- package/dist/shared/attaform.Br8EBn5B.d.mts +4553 -0
- package/dist/shared/{attaform.C2MVyuxC.mjs → attaform.CO918TdU.mjs} +44 -198
- package/dist/shared/{attaform.CZYt_5N_.mjs → attaform.CdZIEf7_.mjs} +1 -19
- package/dist/shared/{attaform.B0dKL8ST.mjs → attaform.DRsANMok.mjs} +94 -62
- package/dist/shared/{attaform.DffRL5pP.mjs → attaform.D_f1WgYf.mjs} +46 -59
- package/dist/shared/{attaform.D1fnTifF.mjs → attaform.D_pt1gOj.mjs} +92 -150
- package/dist/shared/attaform.L0kUn3vL.d.mts +42 -0
- package/dist/shared/{attaform.D0x-qSXm.mjs → attaform.WiGdIqgx.mjs} +1 -3
- package/dist/shared/{attaform.BK0cgu2K.mjs → attaform.ZYn2ahzJ.mjs} +3 -3
- package/dist/transforms.d.mts +153 -26
- package/dist/transforms.mjs +1 -1
- package/dist/vite.d.mts +29 -52
- package/dist/vite.mjs +8 -3
- package/dist/webpack.d.mts +20 -12
- package/dist/webpack.mjs +1 -1
- package/dist/zod-v3.d.mts +90 -96
- package/dist/zod-v3.mjs +6 -6
- package/dist/zod-v4.d.mts +119 -119
- package/dist/zod-v4.mjs +6 -6
- package/dist/zod.d.mts +5 -5
- package/dist/zod.mjs +5 -5
- package/package.json +9 -7
- package/skills/attaform/SKILL.md +1 -1
- package/skills/attaform/references/custom-components.md +1 -1
- package/dist/chunks/fingerprint.mjs +0 -183
- package/dist/chunks/fingerprint2.mjs +0 -159
- package/dist/dev/chunks/fingerprint.mjs +0 -183
- package/dist/dev/chunks/fingerprint2.mjs +0 -159
- package/dist/dev/shared/attaform-dev.BxfsuwBR.mjs +0 -44
- package/dist/shared/attaform.BxfsuwBR.mjs +0 -44
- package/dist/shared/attaform.CsoeRi3P.d.mts +0 -5155
- package/dist/shared/attaform.DDtqHYv1.d.mts +0 -2465
- package/dist/shared/attaform.axHXVQO7.d.mts +0 -44
package/dist/zod-v4.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { a as assertZodVersion, k as kindOf, u as useForm, z as zodAdapter } from './shared/attaform.
|
|
2
|
-
import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './shared/attaform.
|
|
3
|
-
export { A as AttaformError, I as InvalidPathError, a as InvalidUseFormConfigError, O as OutsideSetupError, R as ROOT_PATH, b as ROOT_PATH_KEY, c as RegistryNotInstalledError, d as ReservedFormKeyError, S as SubmitErrorHandlerError, e as canonicalizePath, i as isPathPrefix, p as parseDottedPath } from './shared/attaform.
|
|
4
|
-
export { A as AttaformErrorCode,
|
|
5
|
-
export { D as DEVTOOLS_WINDOW_KEY, c as createAttaform, a as createRegistry, g as getRegistryFromApp, h as hydrateAttaformState, k as kAttaformRegistry, r as renderAttaformState, u as useRegistry } from './shared/attaform.
|
|
6
|
-
export { a as assignKey, v as vRegister } from './shared/attaform.
|
|
1
|
+
export { a as assertZodVersion, k as kindOf, u as useForm, z as zodAdapter } from './shared/attaform.CO918TdU.mjs';
|
|
2
|
+
import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './shared/attaform.DRsANMok.mjs';
|
|
3
|
+
export { A as AttaformError, I as InvalidPathError, a as InvalidUseFormConfigError, O as OutsideSetupError, R as ROOT_PATH, b as ROOT_PATH_KEY, c as RegistryNotInstalledError, d as ReservedFormKeyError, S as SubmitErrorHandlerError, e as canonicalizePath, i as isPathPrefix, p as parseDottedPath } from './shared/attaform.CdZIEf7_.mjs';
|
|
4
|
+
export { A as AttaformErrorCode, e as escapeForInlineScript, g as gate, i as injectForm, a as injectWizard, b as isUnset, l as lazy, u as unset, d as useRegister, f as useWizard } from './shared/attaform.BIWicztt.mjs';
|
|
5
|
+
export { D as DEVTOOLS_WINDOW_KEY, c as createAttaform, a as createRegistry, g as getRegistryFromApp, h as hydrateAttaformState, k as kAttaformRegistry, r as renderAttaformState, u as useRegistry } from './shared/attaform.WiGdIqgx.mjs';
|
|
6
|
+
export { a as assignKey, v as vRegister } from './shared/attaform.D_f1WgYf.mjs';
|
|
7
7
|
export { i as isRegisterValue } from './shared/attaform.KvlEedlF.mjs';
|
|
8
8
|
|
|
9
9
|
const fieldMeta = installingFieldMetaStore;
|
package/dist/zod.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { a as AnyForm, b as AttaformDevtoolsBridge, c as AttaformError, d as AttaformErrorCode, e as AttaformPluginOptions, A as AttaformRegistry, C as CompiledStep, D as
|
|
2
|
-
export { b as ArrayItem, c as ArrayPath,
|
|
3
|
-
export { v as vRegister } from './shared/attaform.
|
|
1
|
+
export { a as AnyForm, b as AttaformDevtoolsBridge, c as AttaformError, d as AttaformErrorCode, e as AttaformPluginOptions, A as AttaformRegistry, C as CompiledStep, D as DEVTOOLS_WINDOW_KEY, F as FormStatus, f as FormStatusSeed, G as GateMarker, I as InjectWizardInput, g as InvalidPathError, h as InvalidUseFormConfigError, L as LazyMarker, O as OutsideSetupError, R as RegistryNotInstalledError, i as ReservedFormKeyError, S as SerializedAttaformState, j as SerializedFormData, k as StepSlot, l as SubmitErrorHandlerError, U as UseRegisterOptions, m as UseRegisterReturn, n as UseWizardReturnType, W as WizardAggregateError, o as WizardCtx, p as WizardCtxForm, q as WizardOnError, r as WizardOnSubmit, s as WizardOptions, t as WizardPersistFn, u as WizardRestoreFn, v as WizardRestoreState, w as WizardStatusesProxy, x as WizardSubmitContext, y as assignKey, z as createAttaform, B as createRegistry, E as escapeForInlineScript, H as gate, J as getRegistryFromApp, K as hydrateAttaformState, M as injectForm, N as injectWizard, P as isRegisterValue, Q as kAttaformRegistry, T as lazy, V as renderAttaformState, X as useRegister, Y as useRegistry, Z as useWizard } from './shared/attaform.BcQwgWaq.mjs';
|
|
2
|
+
export { b as ArrayItem, c as ArrayPath, C as CustomDirectiveRegisterAssignerFn, d as DeepPartial, D as DefaultValuesInput, e as DefaultValuesShape, f as DisplayState, E as ErrorInput, g as ErrorsProxyShape, h as FieldMetaPayload, i as FieldState, j as FieldStateMap, k as FieldStateMapEntry, l as FlatPath, m as FormErrorRecord, n as FormErrorsSurface, F as FormKey, o as FormMeta, G as GenericForm, H as HandleSubmit, p as HistoryPlugin, I as IsTuple, q as IsUnion, J as JoinSegments, r as Json, K as KeyofUnion, L as LiftedValueShape, M as MetaTrackerValue, N as NestedReadType, s as NestedType, O as OnError, t as OnSubmit, P as ParseOptions, u as PartialFlatPath, v as Path, w as PathKey, x as PendingValidationStatus, y as Primitive, R as ROOT_PATH, z as ROOT_PATH_KEY, B as ReactiveValidationStatus, Q as RecordPath, S as RecordValue, T as RegisterDirective, V as RegisterFlatPath, W as RegisterOptions, X as RegisterSelectModifier, Y as RegisterTextModifier, Z as RegisterTransform, _ as RegisterValue, $ as SchemaDefaultsResult, a0 as SchemaParseErrorWithData, a1 as SchemaParseErrorWithoutData, a2 as SchemaParseResult, a3 as SchemaParseSuccess, a4 as Segment, a5 as SetValueCallback, a6 as SetValuePayload, a7 as SettledValidationStatus, a8 as SlimPrimitiveKind, a9 as SubmitHandler, aa as Unset, U as UseFormConfiguration, a as UseFormReturnType, ab as ValidateOn, ac as ValidateOnConfig, ad as ValidationError, ae as ValidationResponse, af as ValidationResponseWithoutValue, ag as ValueOfUnion, ah as WriteMeta, ai as WriteShape, aj as canonicalizePath, ak as isPathPrefix, al as isUnset, am as parseDottedPath, an as unset } from './shared/attaform.Br8EBn5B.mjs';
|
|
3
|
+
export { v as vRegister } from './shared/attaform.L0kUn3vL.mjs';
|
|
4
4
|
export { UseFormConfig, UseFormConfigV3, UseFormConfigV4, UseFormReturn, UseFormReturnV3, UseFormReturnV4, fieldMeta, useForm, withMeta } from './index.mjs';
|
|
5
|
-
export { P as PathInput, a as PathOutput } from './shared/attaform.
|
|
5
|
+
export { P as PathInput, a as PathOutput } from './shared/attaform.2FslhB9R.mjs';
|
|
6
6
|
import 'vue';
|
|
7
|
-
import './shared/attaform.
|
|
7
|
+
import './shared/attaform.B-Tb62qV.mjs';
|
|
8
8
|
import 'zod';
|
package/dist/zod.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { A as AttaformError, I as InvalidPathError, a as InvalidUseFormConfigError, O as OutsideSetupError, R as ROOT_PATH, b as ROOT_PATH_KEY, c as RegistryNotInstalledError, d as ReservedFormKeyError, S as SubmitErrorHandlerError, e as canonicalizePath, i as isPathPrefix, p as parseDottedPath } from './shared/attaform.
|
|
2
|
-
export { A as AttaformErrorCode,
|
|
3
|
-
export { D as DEVTOOLS_WINDOW_KEY, c as createAttaform, a as createRegistry, g as getRegistryFromApp, h as hydrateAttaformState, k as kAttaformRegistry, r as renderAttaformState, u as useRegistry } from './shared/attaform.
|
|
4
|
-
export { a as assignKey, v as vRegister } from './shared/attaform.
|
|
5
|
-
export { f as fieldMeta, u as useForm, w as withMeta } from './shared/attaform.
|
|
1
|
+
export { A as AttaformError, I as InvalidPathError, a as InvalidUseFormConfigError, O as OutsideSetupError, R as ROOT_PATH, b as ROOT_PATH_KEY, c as RegistryNotInstalledError, d as ReservedFormKeyError, S as SubmitErrorHandlerError, e as canonicalizePath, i as isPathPrefix, p as parseDottedPath } from './shared/attaform.CdZIEf7_.mjs';
|
|
2
|
+
export { A as AttaformErrorCode, e as escapeForInlineScript, g as gate, i as injectForm, a as injectWizard, b as isUnset, l as lazy, u as unset, d as useRegister, f as useWizard } from './shared/attaform.BIWicztt.mjs';
|
|
3
|
+
export { D as DEVTOOLS_WINDOW_KEY, c as createAttaform, a as createRegistry, g as getRegistryFromApp, h as hydrateAttaformState, k as kAttaformRegistry, r as renderAttaformState, u as useRegistry } from './shared/attaform.WiGdIqgx.mjs';
|
|
4
|
+
export { a as assignKey, v as vRegister } from './shared/attaform.D_f1WgYf.mjs';
|
|
5
|
+
export { f as fieldMeta, u as useForm, w as withMeta } from './shared/attaform.B2iebkPA.mjs';
|
|
6
6
|
export { i as isRegisterValue } from './shared/attaform.KvlEedlF.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "attaform",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.1",
|
|
4
4
|
"types": "./dist/index.d.mts",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"@commitlint/cli": "^21.0.1",
|
|
130
130
|
"@commitlint/config-conventional": "^21.0.1",
|
|
131
131
|
"@eslint/js": "^10.0.1",
|
|
132
|
-
"@fast-check/vitest": "^0.
|
|
132
|
+
"@fast-check/vitest": "^0.5.0",
|
|
133
133
|
"@nuxt/devtools": "^3.4.2",
|
|
134
134
|
"@nuxt/devtools-kit": "^3.2.0",
|
|
135
135
|
"@nuxt/kit": "^4.4.2",
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"@types/jsdom": "^30.0.0",
|
|
142
142
|
"@types/node": "^26.5.1",
|
|
143
143
|
"@vitejs/plugin-vue": "^6.0.6",
|
|
144
|
-
"@vitest/coverage-v8": "^
|
|
144
|
+
"@vitest/coverage-v8": "^5.0.1",
|
|
145
145
|
"@vue/compiler-core": "^3.5.33",
|
|
146
146
|
"@vue/compiler-sfc": "^3.5.33",
|
|
147
147
|
"@vue/devtools-api": "^8.1.1",
|
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
"typescript-eslint": "^8.59.0",
|
|
172
172
|
"unbuild": "^3.6.1",
|
|
173
173
|
"vite": "^8.3.0",
|
|
174
|
-
"vitest": "^
|
|
174
|
+
"vitest": "^5.0.1",
|
|
175
175
|
"vue": "^3.5.33",
|
|
176
176
|
"vue-eslint-parser": "^10.4.0",
|
|
177
177
|
"vue-tsc": "^3.2.7",
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
"nuxt": ">=3.0.0",
|
|
187
187
|
"vite": ">=5.0.0",
|
|
188
188
|
"vue": ">=3.5.0",
|
|
189
|
-
"zod": ">=3.
|
|
189
|
+
"zod": ">=3.20.0"
|
|
190
190
|
},
|
|
191
191
|
"peerDependenciesMeta": {
|
|
192
192
|
"@nuxt/devtools-kit": {
|
|
@@ -212,8 +212,8 @@
|
|
|
212
212
|
"build:site": "pnpm --filter attaform-site build",
|
|
213
213
|
"lint": "eslint --cache --concurrency=auto --max-warnings 0 . && pnpm format:check",
|
|
214
214
|
"lint:fix": "eslint --cache --concurrency=auto --max-warnings 0 --fix . && pnpm format",
|
|
215
|
-
"format": "prettier --write '**/*.{ts,js,vue,css,scss,md,json,yml,yaml}'",
|
|
216
|
-
"format:check": "prettier --check '**/*.{ts,js,vue,css,scss,md,json,yml,yaml}'",
|
|
215
|
+
"format": "prettier --write '**/*.{ts,js,mjs,cjs,vue,css,scss,md,json,yml,yaml}'",
|
|
216
|
+
"format:check": "prettier --check '**/*.{ts,js,mjs,cjs,vue,css,scss,md,json,yml,yaml}'",
|
|
217
217
|
"check": "pnpm check:security-floors && pnpm lint && pnpm typecheck && pnpm check:site && pnpm test && pnpm test:nuxt-ui && pnpm check:size && pnpm check:tarball && pnpm check:eager && pnpm check:bench && pnpm check:coverage",
|
|
218
218
|
"fix": "pnpm lint:fix",
|
|
219
219
|
"typecheck": "tsc --noEmit",
|
|
@@ -230,8 +230,10 @@
|
|
|
230
230
|
"check:eager": "node scripts/check-eager-size.mjs",
|
|
231
231
|
"check:coverage": "node scripts/run-with-webstorage-flag.mjs vitest run --coverage",
|
|
232
232
|
"check:bench": "node scripts/check-bench.mjs",
|
|
233
|
+
"bench:delta": "node scripts/bench-delta.mjs",
|
|
233
234
|
"check:bundled-types": "node scripts/check-bundled-types.mjs",
|
|
234
235
|
"check:doc-snippets": "node scripts/check-doc-snippets.mjs",
|
|
236
|
+
"check:comment-only": "node scripts/check-comment-only.mjs",
|
|
235
237
|
"check:site": "pnpm dev:prepare && pnpm --filter attaform-site typecheck",
|
|
236
238
|
"fallow": "DO_NOT_TRACK=1 FALLOW_TELEMETRY=0 npx --yes fallow@2.88.3 --score",
|
|
237
239
|
"version": "node scripts/promote-changelog.mjs && (node scripts/generate-release-notes.mjs || echo '[version] release-notes step failed; continuing') && node scripts/sync-doc-versions.mjs && node scripts/build-bestpractices-json.mjs && git add CHANGELOG.md RELEASES.md docs/scorecard/cii-best-practices-answers.md .bestpractices.json"
|
package/skills/attaform/SKILL.md
CHANGED
|
@@ -83,7 +83,7 @@ Prefer an explicit `key` (`useForm({ schema, key: 'sign-in' })`): it makes the f
|
|
|
83
83
|
- **Read errors through `field.showErrors` and `field.firstError?.message`.** The visibility heuristic lives in `showErrors`; reaching into `field.errors[0]` bypasses it. The async "checking" indicator is `field.showPending`.
|
|
84
84
|
- **Route server errors through `form.setErrors(...)` inside the callback.** `setErrors` replaces the whole user-error layer, so call `form.clearErrors()` at the top of the submit for a fresh attempt. See `references/errors.md`.
|
|
85
85
|
- **Banners read `form.meta.firstOwnError`,** the form's own error bucket, not `form.errors([])` (the whole-form aggregate). See `references/errors.md`.
|
|
86
|
-
- **Accessibility is automatic.** `v-register` keeps `aria-invalid`, `aria-busy`, `aria-required`, and `aria-describedby` in sync and emits them during SSR. Put `form.fields.<path>.aria.errorId` on the error element so `aria-describedby` resolves. Author any ARIA attribute yourself to take
|
|
86
|
+
- **Accessibility is automatic.** `v-register` keeps `aria-invalid`, `aria-busy`, `aria-required`, and `aria-describedby` in sync and emits them during SSR. Put `form.fields.<path>.aria.errorId` on the error element so `aria-describedby` resolves. Author any ARIA attribute yourself to take that one over.
|
|
87
87
|
- **Reach with `?.` on injected forms.** `injectForm()` and `injectWizard()` return `T | null`; chain optional access (`form?.register('email')`) at every consumption site.
|
|
88
88
|
- **Put labels on the schema, not the template.** `z.string().register(fieldMeta, { label: 'Email' })`; read it back through `form.fields.email.label` (resolved, with a humanized-path fallback).
|
|
89
89
|
- **Native inputs first.** Bind `<input>`, `<select>`, `<textarea>` with `v-register`. Reach for `useRegister` only inside a custom input component. See `references/custom-components.md`.
|
|
@@ -48,7 +48,7 @@ For a **compound** component that binds _multiple_ paths (a date range exposing
|
|
|
48
48
|
## Let Attaform own display and ARIA
|
|
49
49
|
|
|
50
50
|
- Read the display signals straight in the template: `field.showErrors` gates the error row, `field.showPending` gates an async "checking" indicator (it is anti-flash timed), `field.firstError?.message` is the text.
|
|
51
|
-
- `v-register`
|
|
51
|
+
- `v-register` keeps `aria-invalid`, `aria-busy`, and `aria-required` in sync. It wires the _error_ id, and only while the field is in its error state, so author `aria-describedby` yourself if a _static_ hint should stay associated too.
|
|
52
52
|
- **`v-register` alone does binding, SSR value injection, and ARIA.** Do not stack a second _writer_ on it: no `v-model`, no handler that writes the field back, no `:reset-signal` prop, no redundant directive import. If a control seems to need that scaffolding, find the idiomatic shape rather than hand-rolling around it.
|
|
53
53
|
- **An _observer_ is not a second writer.** A `@change` that only reads, or a `watch(form.toRef('path'), ...)`, is supported beside `v-register`. The directive attaches its own listener in the `created` hook, before Vue applies yours, so it writes the field first and your handler reads committed state. That is the shape for a surface that saves each decision as it is made instead of on submit; see `references/saving.md`.
|
|
54
54
|
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { c as canonicalStringify } from '../shared/attaform.BxfsuwBR.mjs';
|
|
2
|
-
|
|
3
|
-
const cyclicSentinel = "<cyclic>";
|
|
4
|
-
function fingerprintZodSchema(schema) {
|
|
5
|
-
const cache = /* @__PURE__ */ new WeakMap();
|
|
6
|
-
const inProgress = /* @__PURE__ */ new WeakSet();
|
|
7
|
-
return visit(schema, cache, inProgress);
|
|
8
|
-
}
|
|
9
|
-
function visit(schema, cache, inProgress) {
|
|
10
|
-
const key = schema;
|
|
11
|
-
const cached = cache.get(key);
|
|
12
|
-
if (cached !== void 0) return cached;
|
|
13
|
-
if (inProgress.has(key)) return cyclicSentinel;
|
|
14
|
-
inProgress.add(key);
|
|
15
|
-
try {
|
|
16
|
-
const computed = computeFingerprint(schema, cache, inProgress);
|
|
17
|
-
cache.set(key, computed);
|
|
18
|
-
return computed;
|
|
19
|
-
} finally {
|
|
20
|
-
inProgress.delete(key);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function getDef(schema) {
|
|
24
|
-
return schema._def;
|
|
25
|
-
}
|
|
26
|
-
function computeFingerprint(schema, cache, inProgress) {
|
|
27
|
-
const def = getDef(schema);
|
|
28
|
-
const kind = def.typeName ?? "ZodUnknown";
|
|
29
|
-
const recurse = (child) => visit(child, cache, inProgress);
|
|
30
|
-
switch (kind) {
|
|
31
|
-
case "ZodString":
|
|
32
|
-
case "ZodNumber":
|
|
33
|
-
case "ZodBigInt":
|
|
34
|
-
case "ZodDate":
|
|
35
|
-
return `${kind}${formatChecks(def.checks)}`;
|
|
36
|
-
case "ZodBoolean":
|
|
37
|
-
case "ZodNull":
|
|
38
|
-
case "ZodUndefined":
|
|
39
|
-
case "ZodAny":
|
|
40
|
-
case "ZodUnknown":
|
|
41
|
-
case "ZodNaN":
|
|
42
|
-
case "ZodVoid":
|
|
43
|
-
case "ZodNever":
|
|
44
|
-
return kind;
|
|
45
|
-
case "ZodLiteral":
|
|
46
|
-
return `ZodLiteral:${canonicalStringify(def.value)}`;
|
|
47
|
-
case "ZodEnum": {
|
|
48
|
-
const values = Array.isArray(def.values) ? def.values : [];
|
|
49
|
-
const sorted = [...values].sort((a, b) => {
|
|
50
|
-
const as = String(a);
|
|
51
|
-
const bs = String(b);
|
|
52
|
-
return as < bs ? -1 : as > bs ? 1 : 0;
|
|
53
|
-
});
|
|
54
|
-
return `ZodEnum:${canonicalStringify(sorted)}`;
|
|
55
|
-
}
|
|
56
|
-
case "ZodNativeEnum": {
|
|
57
|
-
const values = def.values && typeof def.values === "object" && !Array.isArray(def.values) ? Object.values(def.values) : [];
|
|
58
|
-
const sorted = [...values].sort((a, b) => {
|
|
59
|
-
const as = String(a);
|
|
60
|
-
const bs = String(b);
|
|
61
|
-
return as < bs ? -1 : as > bs ? 1 : 0;
|
|
62
|
-
});
|
|
63
|
-
return `ZodNativeEnum:${canonicalStringify(sorted)}`;
|
|
64
|
-
}
|
|
65
|
-
case "ZodObject": {
|
|
66
|
-
const shape = readShapeSafely(def);
|
|
67
|
-
const sortedEntries = Object.entries(shape).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => `${JSON.stringify(k)}:${recurse(v)}`);
|
|
68
|
-
return `ZodObject{${sortedEntries.join(",")}}${formatChecks(def.checks)}`;
|
|
69
|
-
}
|
|
70
|
-
case "ZodArray":
|
|
71
|
-
return `ZodArray[${def.type === void 0 ? "?" : recurse(def.type)}]${formatChecks(def.checks)}`;
|
|
72
|
-
case "ZodTuple": {
|
|
73
|
-
const items = def.items ?? [];
|
|
74
|
-
return `ZodTuple[${items.map(recurse).join(",")}]`;
|
|
75
|
-
}
|
|
76
|
-
case "ZodRecord": {
|
|
77
|
-
const keyPart = def.keyType === void 0 ? "?" : recurse(def.keyType);
|
|
78
|
-
const valuePart = def.valueType === void 0 ? "?" : recurse(def.valueType);
|
|
79
|
-
return `ZodRecord<${keyPart},${valuePart}>`;
|
|
80
|
-
}
|
|
81
|
-
case "ZodUnion": {
|
|
82
|
-
const options = (def.options ?? []).map(recurse).sort();
|
|
83
|
-
return `ZodUnion(${options.join("|")})`;
|
|
84
|
-
}
|
|
85
|
-
case "ZodDiscriminatedUnion": {
|
|
86
|
-
const disc = def.discriminator ?? "?";
|
|
87
|
-
const options = (def.options ?? []).map(recurse).sort();
|
|
88
|
-
return `ZodDiscriminatedUnion[${JSON.stringify(disc)}](${options.join("|")})`;
|
|
89
|
-
}
|
|
90
|
-
case "ZodOptional": {
|
|
91
|
-
const inner = def.innerType;
|
|
92
|
-
return inner === void 0 ? "ZodOptional(?)" : `ZodOptional(${recurse(inner)})`;
|
|
93
|
-
}
|
|
94
|
-
case "ZodNullable": {
|
|
95
|
-
const inner = def.innerType;
|
|
96
|
-
return inner === void 0 ? "ZodNullable(?)" : `ZodNullable(${recurse(inner)})`;
|
|
97
|
-
}
|
|
98
|
-
case "ZodDefault": {
|
|
99
|
-
const inner = def.innerType;
|
|
100
|
-
return `ZodDefault[${defaultFactoryRepr(def.defaultValue)}](${inner === void 0 ? "?" : recurse(inner)})`;
|
|
101
|
-
}
|
|
102
|
-
case "ZodReadonly": {
|
|
103
|
-
const inner = def.innerType;
|
|
104
|
-
return inner === void 0 ? "ZodReadonly(?)" : `ZodReadonly(${recurse(inner)})`;
|
|
105
|
-
}
|
|
106
|
-
case "ZodEffects": {
|
|
107
|
-
const effectType = def.effect?.type ?? "effect";
|
|
108
|
-
const inner = def.schema;
|
|
109
|
-
return `ZodEffects:${effectType}:fn:*(${inner === void 0 ? "?" : recurse(inner)})`;
|
|
110
|
-
}
|
|
111
|
-
case "ZodPipeline": {
|
|
112
|
-
const inner = def.in ?? def.out;
|
|
113
|
-
return inner === void 0 ? "ZodPipeline(?)" : `ZodPipeline(${recurse(inner)})`;
|
|
114
|
-
}
|
|
115
|
-
case "ZodCatch": {
|
|
116
|
-
const inner = def.innerType ?? def.schema;
|
|
117
|
-
const catchRepr = defaultFactoryRepr(def.catchValue);
|
|
118
|
-
return `ZodCatch[${catchRepr}](${inner === void 0 ? "?" : recurse(inner)})`;
|
|
119
|
-
}
|
|
120
|
-
case "ZodLazy": {
|
|
121
|
-
const resolve = def.getter;
|
|
122
|
-
if (typeof resolve !== "function") return "ZodLazy(?)";
|
|
123
|
-
try {
|
|
124
|
-
const inner = resolve();
|
|
125
|
-
return `ZodLazy(${recurse(inner)})`;
|
|
126
|
-
} catch {
|
|
127
|
-
return "ZodLazy(?)";
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
case "ZodIntersection": {
|
|
131
|
-
const leftPart = def.left === void 0 ? "?" : recurse(def.left);
|
|
132
|
-
const rightPart = def.right === void 0 ? "?" : recurse(def.right);
|
|
133
|
-
const parts = [leftPart, rightPart].sort();
|
|
134
|
-
return `ZodIntersection(${parts.join("&")})`;
|
|
135
|
-
}
|
|
136
|
-
case "ZodSet": {
|
|
137
|
-
const inner = def.valueType;
|
|
138
|
-
return inner === void 0 ? "ZodSet(?)" : `ZodSet<${recurse(inner)}>${formatChecks(def.checks)}`;
|
|
139
|
-
}
|
|
140
|
-
case "ZodBranded": {
|
|
141
|
-
const inner = def.type;
|
|
142
|
-
return inner === void 0 ? "ZodBranded(?)" : `ZodBranded(${recurse(inner)})`;
|
|
143
|
-
}
|
|
144
|
-
// Structural opacity — schemas whose runtime behaviour isn't
|
|
145
|
-
// introspectable via `_def` fall here. Still distinguishable
|
|
146
|
-
// from other kinds by the returned string.
|
|
147
|
-
case "ZodPromise":
|
|
148
|
-
case "ZodFunction":
|
|
149
|
-
case "ZodMap":
|
|
150
|
-
case "ZodSymbol":
|
|
151
|
-
default:
|
|
152
|
-
return `${kind}:*`;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
function readShapeSafely(def) {
|
|
156
|
-
if (typeof def.shape !== "function") return {};
|
|
157
|
-
try {
|
|
158
|
-
return def.shape();
|
|
159
|
-
} catch {
|
|
160
|
-
return {};
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
function defaultFactoryRepr(factory) {
|
|
164
|
-
if (typeof factory !== "function") return "none";
|
|
165
|
-
let first;
|
|
166
|
-
let second;
|
|
167
|
-
try {
|
|
168
|
-
first = factory();
|
|
169
|
-
second = factory();
|
|
170
|
-
} catch {
|
|
171
|
-
return "fn:*";
|
|
172
|
-
}
|
|
173
|
-
if (!Object.is(first, second)) return "fn:*";
|
|
174
|
-
if (typeof first === "function") return "fn:*";
|
|
175
|
-
return canonicalStringify(first);
|
|
176
|
-
}
|
|
177
|
-
function formatChecks(checks) {
|
|
178
|
-
if (!Array.isArray(checks) || checks.length === 0) return "";
|
|
179
|
-
const parts = checks.map((c) => canonicalStringify(c)).sort();
|
|
180
|
-
return `[${parts.join(";")}]`;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export { fingerprintZodSchema };
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { c as canonicalStringify } from '../shared/attaform.BxfsuwBR.mjs';
|
|
2
|
-
import { k as kindOf, g as getIntersectionLeft, b as getIntersectionRight, c as unwrapLazy, d as unwrapInner, e as unwrapPipe, f as getDiscriminator, h as getDiscriminatedOptions, i as getUnionOptions, j as getRecordKeyType, l as getRecordValueType, m as getTupleItems, n as getSetValueType, o as getArrayElement, p as getObjectShape, q as getEnumValues, r as getLiteralValues, s as getChecks, t as getCatchDefault, v as getDefaultValue } from '../shared/attaform.C2MVyuxC.mjs';
|
|
3
|
-
|
|
4
|
-
const cyclicSentinel = "<cyclic>";
|
|
5
|
-
function fingerprintZodSchema(schema) {
|
|
6
|
-
const cache = /* @__PURE__ */ new WeakMap();
|
|
7
|
-
const inProgress = /* @__PURE__ */ new WeakSet();
|
|
8
|
-
return visit(schema, cache, inProgress);
|
|
9
|
-
}
|
|
10
|
-
function visit(schema, cache, inProgress) {
|
|
11
|
-
const cached = cache.get(schema);
|
|
12
|
-
if (cached !== void 0) return cached;
|
|
13
|
-
if (inProgress.has(schema)) return cyclicSentinel;
|
|
14
|
-
inProgress.add(schema);
|
|
15
|
-
try {
|
|
16
|
-
const computed = computeFingerprint(schema, cache, inProgress);
|
|
17
|
-
cache.set(schema, computed);
|
|
18
|
-
return computed;
|
|
19
|
-
} finally {
|
|
20
|
-
inProgress.delete(schema);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function computeFingerprint(schema, cache, inProgress) {
|
|
24
|
-
const kind = kindOf(schema);
|
|
25
|
-
const recurse = (child) => visit(child, cache, inProgress);
|
|
26
|
-
switch (kind) {
|
|
27
|
-
// Kind-only leaves: no further structure to descend into.
|
|
28
|
-
case "boolean":
|
|
29
|
-
case "null":
|
|
30
|
-
case "undefined":
|
|
31
|
-
case "any":
|
|
32
|
-
case "unknown":
|
|
33
|
-
case "nan":
|
|
34
|
-
case "void":
|
|
35
|
-
case "never":
|
|
36
|
-
return kind;
|
|
37
|
-
// Leaves with checks (min/max/email/regex/...). Checks are
|
|
38
|
-
// canonicalised and sorted so `.min(3).max(10)` and `.max(10).min(3)`
|
|
39
|
-
// produce identical fingerprints.
|
|
40
|
-
case "string":
|
|
41
|
-
case "number":
|
|
42
|
-
case "bigint":
|
|
43
|
-
case "date":
|
|
44
|
-
return `${kind}${formatChecks(schema)}`;
|
|
45
|
-
case "literal": {
|
|
46
|
-
const values = [...getLiteralValues(schema)].sort((a, b) => {
|
|
47
|
-
const as = canonicalStringify(a);
|
|
48
|
-
const bs = canonicalStringify(b);
|
|
49
|
-
return as < bs ? -1 : as > bs ? 1 : 0;
|
|
50
|
-
});
|
|
51
|
-
return `literal:${canonicalStringify(values)}`;
|
|
52
|
-
}
|
|
53
|
-
case "enum":
|
|
54
|
-
return `enum:${canonicalStringify([...getEnumValues(schema)].sort((a, b) => compare(a, b)))}`;
|
|
55
|
-
case "object": {
|
|
56
|
-
const shape = getObjectShape(schema);
|
|
57
|
-
const sortedEntries = Object.entries(shape).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => `${JSON.stringify(k)}:${recurse(v)}`);
|
|
58
|
-
return `object{${sortedEntries.join(",")}}${formatChecks(schema)}`;
|
|
59
|
-
}
|
|
60
|
-
case "array":
|
|
61
|
-
return `array[${recurse(getArrayElement(schema))}]${formatChecks(schema)}`;
|
|
62
|
-
case "set":
|
|
63
|
-
return `set<${recurse(getSetValueType(schema))}>${formatChecks(schema)}`;
|
|
64
|
-
case "tuple":
|
|
65
|
-
return `tuple[${getTupleItems(schema).map(recurse).join(",")}]`;
|
|
66
|
-
case "record":
|
|
67
|
-
return `record<${recurse(getRecordKeyType(schema))},${recurse(getRecordValueType(schema))}>`;
|
|
68
|
-
case "union": {
|
|
69
|
-
const options = getUnionOptions(schema).map(recurse).sort();
|
|
70
|
-
return `union(${options.join("|")})`;
|
|
71
|
-
}
|
|
72
|
-
case "discriminated-union": {
|
|
73
|
-
const disc = getDiscriminator(schema) ?? "?";
|
|
74
|
-
const options = getDiscriminatedOptions(schema).map(recurse).sort();
|
|
75
|
-
return `dunion[${JSON.stringify(disc)}](${options.join("|")})`;
|
|
76
|
-
}
|
|
77
|
-
case "optional": {
|
|
78
|
-
const inner = unwrapInner(schema);
|
|
79
|
-
return inner === void 0 ? "optional(?)" : `optional(${recurse(inner)})`;
|
|
80
|
-
}
|
|
81
|
-
case "nullable": {
|
|
82
|
-
const inner = unwrapInner(schema);
|
|
83
|
-
return inner === void 0 ? "nullable(?)" : `nullable(${recurse(inner)})`;
|
|
84
|
-
}
|
|
85
|
-
case "default": {
|
|
86
|
-
const inner = unwrapInner(schema);
|
|
87
|
-
return `default[${stableValueRepr(getDefaultValue, schema)}](${inner === void 0 ? "?" : recurse(inner)})`;
|
|
88
|
-
}
|
|
89
|
-
case "readonly": {
|
|
90
|
-
const inner = unwrapInner(schema);
|
|
91
|
-
return inner === void 0 ? "readonly(?)" : `readonly(${recurse(inner)})`;
|
|
92
|
-
}
|
|
93
|
-
case "pipe": {
|
|
94
|
-
const inner = unwrapPipe(schema);
|
|
95
|
-
return inner === void 0 ? "pipe(?)" : `pipe(${recurse(inner)})`;
|
|
96
|
-
}
|
|
97
|
-
case "catch": {
|
|
98
|
-
const inner = unwrapInner(schema);
|
|
99
|
-
return `catch[${stableValueRepr(getCatchDefault, schema)}](${inner === void 0 ? "?" : recurse(inner)})`;
|
|
100
|
-
}
|
|
101
|
-
case "lazy": {
|
|
102
|
-
const inner = unwrapLazy(schema);
|
|
103
|
-
return inner === void 0 ? "lazy(?)" : `lazy(${recurse(inner)})`;
|
|
104
|
-
}
|
|
105
|
-
case "intersection": {
|
|
106
|
-
const left = getIntersectionLeft(schema);
|
|
107
|
-
const right = getIntersectionRight(schema);
|
|
108
|
-
const leftFp = left === void 0 ? "?" : recurse(left);
|
|
109
|
-
const rightFp = right === void 0 ? "?" : recurse(right);
|
|
110
|
-
const parts = [leftFp, rightFp].sort();
|
|
111
|
-
return `intersection(${parts.join("&")})`;
|
|
112
|
-
}
|
|
113
|
-
// Structural shape isn't observable for these. Bucket them into
|
|
114
|
-
// kind-only fingerprints — a schema-mismatch warning can't do
|
|
115
|
-
// better than "both are `custom`" here, but that still catches
|
|
116
|
-
// `object` vs `custom` mismatches. `map` / `symbol` / `function`
|
|
117
|
-
// are rejected at adapter construction; kept here for exhaustive
|
|
118
|
-
// switch safety when `fingerprintSchema` is called from tooling.
|
|
119
|
-
case "promise":
|
|
120
|
-
case "custom":
|
|
121
|
-
case "template-literal":
|
|
122
|
-
case "transform":
|
|
123
|
-
case "file":
|
|
124
|
-
case "map":
|
|
125
|
-
case "symbol":
|
|
126
|
-
case "function":
|
|
127
|
-
return `${kind}:*`;
|
|
128
|
-
default: {
|
|
129
|
-
const _ = kind;
|
|
130
|
-
return `unknown:${String(_)}`;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
function stableValueRepr(get, schema) {
|
|
135
|
-
const first = get(schema);
|
|
136
|
-
const second = get(schema);
|
|
137
|
-
if (!Object.is(first, second) || typeof first === "function") return "fn:*";
|
|
138
|
-
return canonicalStringify(first);
|
|
139
|
-
}
|
|
140
|
-
function formatChecks(schema) {
|
|
141
|
-
const checks = getChecks(schema);
|
|
142
|
-
if (checks.length === 0) return "";
|
|
143
|
-
const parts = checks.map((c) => serializeCheck(c)).sort();
|
|
144
|
-
return `[${parts.join(";")}]`;
|
|
145
|
-
}
|
|
146
|
-
function serializeCheck(check) {
|
|
147
|
-
if (check !== null && typeof check === "object") {
|
|
148
|
-
const def = check._zod?.def;
|
|
149
|
-
if (def !== void 0) return canonicalStringify(def);
|
|
150
|
-
}
|
|
151
|
-
return canonicalStringify(check);
|
|
152
|
-
}
|
|
153
|
-
function compare(a, b) {
|
|
154
|
-
const as = String(a);
|
|
155
|
-
const bs = String(b);
|
|
156
|
-
return as < bs ? -1 : as > bs ? 1 : 0;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export { fingerprintZodSchema };
|