arktype 3.0.0-beta.0 → 3.0.0-beta.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.
Files changed (51) hide show
  1. package/README.md +162 -10
  2. package/out/attributes.d.ts +4 -2
  3. package/out/checkers.d.ts +37 -2
  4. package/out/{chunk-Z4F45ZTE.js → chunk-2U2AWCI3.js} +3 -3
  5. package/out/{chunk-5NJWD7CO.js → chunk-5U2ZMDNI.js} +215 -140
  6. package/out/{chunk-KJ3C5GTL.js → chunk-DLWCO4RV.js} +1 -1
  7. package/out/{chunk-H4VRNKMB.js → chunk-E3DZXEZK.js} +1 -1
  8. package/out/{chunk-EJZJUYPI.js → chunk-EVCML554.js} +2 -2
  9. package/out/{chunk-KI2MOYNT.js → chunk-GPNK5353.js} +184 -32
  10. package/out/{chunk-LUXERINN.js → chunk-RAZ3TXOE.js} +40 -38
  11. package/out/chunk-SWOOCAHN.js +4 -0
  12. package/out/{chunk-ARTS74PX.js → chunk-UETB6YE2.js} +1 -1
  13. package/out/{chunk-JHDPSG5Y.js → chunk-UK5UGFOX.js} +6 -6
  14. package/out/{chunk-WEPQK3AY.js → chunk-VV6YDN2D.js} +441 -145
  15. package/out/codecs.js +5 -5
  16. package/out/config.d.ts +6 -3
  17. package/out/i18n.d.ts +1 -1
  18. package/out/i18n.js +1 -1
  19. package/out/index.d.ts +1 -1
  20. package/out/index.js +5 -5
  21. package/out/internal.d.ts +1 -0
  22. package/out/internal.js +11 -11
  23. package/out/island.js +2 -2
  24. package/out/islandDependency.js +11 -11
  25. package/out/keywords/functions.d.ts +24 -24
  26. package/out/keywords/keywords.d.ts +2 -2
  27. package/out/keywords/phrases.d.ts +23 -23
  28. package/out/keywords/ts.js +2 -2
  29. package/out/locale.d.ts +1 -1
  30. package/out/locales/de.js +1 -1
  31. package/out/locales/en.js +3 -3
  32. package/out/match.d.ts +5 -3
  33. package/out/mutatesInput.js +2 -2
  34. package/out/parser/definition.d.ts +54 -3
  35. package/out/parser/shift/operand/unenclosed.d.ts +3 -1
  36. package/out/parser/shift/operand/unresolvable.d.ts +68 -0
  37. package/out/parser/shift/operator/bounds.d.ts +4 -1
  38. package/out/runtime.d.ts +34 -25
  39. package/out/runtime.js +2 -2
  40. package/out/runtimeDevelopment.js +63 -4
  41. package/out/scope.d.ts +4 -4
  42. package/out/standalone/artifact.d.ts +4 -0
  43. package/out/standalone/baking.d.ts +8 -1
  44. package/out/standalone/sites.d.ts +6 -3
  45. package/out/standalone/values.d.ts +2 -0
  46. package/out/type.d.ts +42 -5
  47. package/package.json +49 -6
  48. package/skills/arktype/SKILL.md +211 -92
  49. package/skills/arktype/references/migrating.md +990 -255
  50. package/skills/arktype/references/precompile.md +8 -5
  51. package/out/chunk-EDEN5UWG.js +0 -4
@@ -102,6 +102,8 @@ A project that `tsc` compiles to run from its `outDir` precompiles what it emits
102
102
 
103
103
  A library that others install doesn't precompile itself, with `--emit` or a bundler: an app's build fails for a dependency that imports `arktype/runtime`. Precompiling a library means publishing what `tsc` emits with `"ark": { "aot": true }` in its `package.json` and `arktype` in `peerDependencies`, so each app's build precompiles it, and running `npx arktype-precompile --check src` until it accepts every definition.
104
104
 
105
+ A package whose types others read writes its declarations with `npx arktype-precompile --declare` in place of `tsc`'s: each Type, Scope and Module is declared by its shape, in a `~arktype.d.ts` beside the others, and nothing changes at runtime. A cyclic scope's types ship no other way, since `tsc` declares an inferred cycle as `any` or fails with `TS5088`. It reads the program with the TypeScript installed: 5.5 to 6's compiler API, or TypeScript 7.1 or later's native API through tsgo, or tsrs where its binary is installed; `--checker tsjs|tsgo|tsrs` chooses one.
106
+
105
107
  ### Tests
106
108
 
107
109
  - Vitest: nothing beyond the Vite plugin.
@@ -142,8 +144,8 @@ Composing inside a definition is fine anywhere, even in a function body: `const
142
144
  ## What changes at runtime
143
145
 
144
146
  - A validator validates, `.assert()`s and is a Standard Schema, but has no `.and`, `.or`, `.pick` or other composing method. The build fails where it sees one called outside a definition.
145
- - Each error in `out.issues` has only `code`, `path`, `data`, `expected` and `message`, and `arktype/runtime` doesn't export `byPath`, `flatByPath`, `flatProblemsByPath` or `messageIn`. To group messages by key, group `out.issues` by `issue.path.join(".")`.
146
- - Error messages are arktype's: they say what failed but not what the value was, `email must be an email address`, and a missing key reads `name must be a string (was missing)`. Text configured with `.configure({ message })` or `.describe()` is kept, as is a `required` message configured in the config module, whose function receives `propString` and `valueMeta` as in arktype.
147
+ - Each error in `out.issues` has only `code`, `path`, `data`, `expected` and `message`, and `arktype/runtime` doesn't export `byPath`, `flatByPath`, `flatMessagesByPath` or `messageIn`. To group messages by key, group `out.issues` by `issue.path.join(".")`.
148
+ - Error messages are arktype's: an issue's `message` says what failed, without its path or what the value was, like `must be an email address`, and `out.summary` writes the path before it, like `email must be an email address`. A missing key reads `name must be a string (was missing)`. Text configured with `.configure({ message })` or `.describe()` is kept, as is a `required` message configured in the config module, whose function receives `propString` and `valueMeta` as in arktype.
147
149
  - The build works out which introspection members, like `toJsonSchema()`, `json` and `~standard.jsonSchema`, each validator needs, baking each where it sees code read it, following it into its dependencies and, in a build reading one module at a time, into each module importing it. So the MCP SDK, the AI SDK, Elysia's OpenAPI plugin, hono-openapi and oRPC's `@orpc/arktype` converter need nothing set, and setting one under `members` only overrides what the build works out. Where the build loses track of a validator, like one passed to a function it can't resolve, it bakes each into it and a production build warns `precompile: baking each introspection member into ...`; the build is correct, only larger. Code the build can't see, like code outside the bundle reading an entry's export, reads a member it didn't bake and throws, naming the member to set true under `members`. A production build decides `assert`, `meta`, `~standard` and `methods` the same way, keeping in each validator what the code it reaches reads, like `~standard` for Hono's `sValidator`, with nothing to set. tRPC, Hono's validators, React Hook Form, TanStack Form and Router and t3-env need nothing.
148
150
  - `drizzle-arktype` creates Types from your tables as the program runs, so it runs on arktype, as the next item sets, which ships the parser. To precompile those Types instead, write each one out with a line that fails to compile if it drifts from the table, like `const matches: Equals<typeof selectTask.infer, typeof tasks.$inferSelect> = true`, with `Equals` from migrating.md's How to convert.
149
151
  - A dependency that imports arktype fails a standalone build unless it opts in with `"ark": { "aot": true }` in its `package.json`, or the program decides for it under `"precompile"`: `"dependencies": { "@t3-oss/env-core": "aot" }` precompiles one whose Types are static, like t3-env's presets, and `"dependencies": { "drizzle-arktype": "arktype" }` runs one creating Types from values it reads as it runs on arktype, sharing the program's `configure()`. A dependency that only reads `type.errors`, like `@hono/arktype-validator`, builds as it is.
@@ -166,7 +168,7 @@ Each build error names the file, line and column, then why, then the fix on its
166
168
  | `` `shape` is written at ..., so its value at the site is not known `` | write the object whole in its literal, or define each variant as its own Type |
167
169
  | `User.description reads description, which a standalone validator lacks` | read it inside a definition, or set that member under `members` |
168
170
  | `T.default(x) can't be precompiled yet`, `.default() gives the definition of an object's key` | write `.default(x)` at the object key it's for, not in a `const`, as the message shows |
169
- | `flatProblemsByPath(out) calls flatProblemsByPath, which arktype/runtime doesn't export` (or `byPath`, `flatByPath`) | read `out.issues`, grouping by `issue.path.join(".")`; for `messageIn`, read `issue.message` |
171
+ | `flatMessagesByPath(out) calls flatMessagesByPath, which arktype/runtime doesn't export` (or `byPath`, `flatByPath`) | read `out.issues`, grouping by `issue.path.join(".")`; for `messageIn`, read `issue.message` |
170
172
  | `configure() is called, but the build has no config module` | add `"config"` to `ark.json`, as above |
171
173
  | `... loads src/schemas.ts, which creates a Type, before the config module ... runs` | import the config module first in that file, before any module that creates a Type |
172
174
  | `` `User` comes from `~/schemas`, which the build can't resolve `` | add the alias to `tsconfig.json`'s `paths` |
@@ -180,9 +182,10 @@ Each build error names the file, line and column, then why, then the fix on its
180
182
  | `arktype resolves to ... rather than arktype/runtime` (Turbopack) | add the `resolveAlias` entries it lists |
181
183
  | `type is not a function` at runtime | a module defining Types wasn't precompiled, e.g. no Turbopack rule matches its extension; add one |
182
184
 
183
- Two messages concern `members`:
185
+ Three messages concern `members`:
184
186
 
185
187
  - `prune: keeping assert, meta, ~standard and methods, because the validator at src/schemas.ts:7:9 is lost where ...` (a warning): the build kept the members it couldn't prove unread, as where a Type is passed to a function it can't resolve; the build is correct, only larger. To build without the warning, set each member it names under `members` in `ark.json`, `true` where code may read it, like `~standard` where a library validates with it, else `false`, e.g. `"precompile": { "members": { "assert": false, "meta": false, "~standard": true, "methods": false } }`.
186
- - `toJsonSchema isn't precompiled`, at runtime: code the build can't see read it, like code outside the bundle reading an entry's export; set that member true under `members`.
188
+ - `toJsonSchema isn't precompiled`, at runtime in development, or `toJsonSchema is not a function` in production, where a member no build baked reads `undefined`: code the build can't see read it, like code outside the bundle reading an entry's export; set that member true under `members`.
189
+ - `some-plugin transformed src/form.ts after arktype's plugin read it, and the program as built reads what the build left out of its validators: a module reads assert of a validator` (Vite, Rollup or Rolldown; webpack and Rspack say it of a loader): a plugin after arktype's added a read of something a production build left out, and the build failed rather than ship it. Set each member the message names true under `members`, or `prune: false` where it names none. Moving the plugin doesn't help.
187
190
 
188
191
  Every message and its fix: https://arktype.io/docs/precompile/troubleshooting.md.
@@ -1,4 +0,0 @@
1
- // out/i18n.js
2
- export { describeCause, describeMissing, groupByPath, labelOf, writeKeywordExpected } from "@ark/schema/i18n";
3
- export { isolate, listPattern } from "@ark/util";
4
-