@kayjs/kay 1.106.0 → 1.107.0

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 (222) hide show
  1. package/README.md +2 -2
  2. package/dist/eslint.js +428 -176
  3. package/editors/zed/extension.toml +2 -2
  4. package/llms/action-protection.md +1 -1
  5. package/llms/actions-refused-fields.md +22 -0
  6. package/llms/actions.md +2 -22
  7. package/llms/browser-only.md +1 -1
  8. package/llms/compiler-api.md +1 -1
  9. package/llms/components.md +1 -1
  10. package/llms/deprecated-lints.md +2 -3
  11. package/llms/island-and-form-lints.md +1 -0
  12. package/llms/islands.md +10 -1
  13. package/llms/project-new-and-add.md +1 -1
  14. package/llms/project.md +2 -2
  15. package/llms/schemas.md +6 -4
  16. package/llms/upgrading.md +19 -1
  17. package/llms/whats-new.md +14 -1
  18. package/package.json +15 -6
  19. package/src/build/client.ts +20 -24
  20. package/src/build/entry-files.ts +19 -0
  21. package/src/build/lazy-components.ts +130 -0
  22. package/src/build/lazy-manifest.ts +56 -0
  23. package/src/build/lazy-stubs.ts +31 -0
  24. package/src/build/plugin.ts +3 -1
  25. package/src/build/runtime-chunk.ts +1 -1
  26. package/src/build/transform.ts +17 -7
  27. package/src/build/variants.ts +7 -4
  28. package/src/check/action-options.ts +56 -0
  29. package/src/check/schema-json.ts +226 -0
  30. package/src/check/shadow-types.ts +11 -9
  31. package/src/compiler/codegen.ts +7 -17
  32. package/src/compiler/deprecated-lints-1-105.ts +41 -0
  33. package/src/compiler/deprecated-lints-1-106.ts +1 -1
  34. package/src/compiler/deprecated-lints-1-107.ts +14 -0
  35. package/src/compiler/deprecated-lints.ts +7 -55
  36. package/src/compiler/import-edits.ts +15 -0
  37. package/src/compiler/index.ts +8 -3
  38. package/src/compiler/island-declaration.ts +15 -0
  39. package/src/compiler/kay-exports.ts +1 -0
  40. package/src/compiler/lazy-imports.ts +357 -0
  41. package/src/compiler/parser.ts +2 -2
  42. package/src/compiler/route-lints.ts +2 -0
  43. package/src/compiler/schema-lints.ts +13 -0
  44. package/src/compiler/script-server.ts +6 -3
  45. package/src/content/validate.ts +1 -1
  46. package/src/new.ts +6 -2
  47. package/src/runtime/action.ts +47 -4
  48. package/src/runtime/client.ts +10 -0
  49. package/src/runtime/dom-lazy.ts +276 -0
  50. package/src/runtime/field-errors.ts +58 -0
  51. package/src/runtime/field-refusal.ts +179 -0
  52. package/src/runtime/form.ts +3 -2
  53. package/src/runtime/html.ts +6 -1
  54. package/src/runtime/index.ts +2 -0
  55. package/src/runtime/island.server.ts +36 -2
  56. package/src/runtime/schema-record.ts +2 -1
  57. package/src/runtime/schema.client.ts +104 -14
  58. package/src/runtime/schema.ts +9 -2
  59. package/src/runtime/standard-schema.ts +32 -0
  60. package/src/runtime/validate-run.client.ts +179 -0
  61. package/src/runtime/validate.client.ts +11 -0
  62. package/src/runtime/validate.ts +4 -137
  63. package/src/server/actions.ts +48 -43
  64. package/src/server/answer.ts +102 -0
  65. package/src/server/api-input.ts +166 -0
  66. package/src/server/api.ts +12 -44
  67. package/src/server/app-stages.ts +15 -8
  68. package/src/server/app.ts +5 -2
  69. package/src/server/client.ts +2 -0
  70. package/src/server/dev.ts +7 -9
  71. package/src/server/file-limit.ts +7 -1
  72. package/src/server/forms.ts +1 -1
  73. package/src/server/host-allowlist.ts +7 -7
  74. package/src/server/index.ts +2 -0
  75. package/src/server/kay-routes.ts +221 -0
  76. package/src/server/kay-server.ts +228 -0
  77. package/src/server/kept-exports.ts +1 -0
  78. package/src/server/library.ts +0 -2
  79. package/src/server/mcp.ts +1 -1
  80. package/src/server/openapi.ts +12 -3
  81. package/src/server/phases.ts +249 -0
  82. package/src/server/protection.ts +6 -6
  83. package/src/server/proxy-key.ts +8 -8
  84. package/src/server/query.ts +4 -25
  85. package/src/server/receive.ts +43 -0
  86. package/src/server/render-document.ts +13 -3
  87. package/src/server/request-context.ts +137 -0
  88. package/src/server/schema-check.ts +1 -1
  89. package/src/server/socket.ts +19 -47
  90. package/src/server/stream.ts +1 -1
  91. package/src/server/validate.ts +346 -0
  92. package/src/test/mount.ts +6 -2
  93. package/types/build/client.d.ts +3 -2
  94. package/types/build/client.d.ts.map +1 -1
  95. package/types/build/entry-files.d.ts +4 -0
  96. package/types/build/entry-files.d.ts.map +1 -0
  97. package/types/build/lazy-components.d.ts +6 -0
  98. package/types/build/lazy-components.d.ts.map +1 -0
  99. package/types/build/lazy-manifest.d.ts +19 -0
  100. package/types/build/lazy-manifest.d.ts.map +1 -0
  101. package/types/build/lazy-stubs.d.ts +5 -0
  102. package/types/build/lazy-stubs.d.ts.map +1 -0
  103. package/types/build/plugin.d.ts +1 -0
  104. package/types/build/plugin.d.ts.map +1 -1
  105. package/types/build/transform.d.ts +3 -1
  106. package/types/build/transform.d.ts.map +1 -1
  107. package/types/build/variants.d.ts.map +1 -1
  108. package/types/check/action-options.d.ts +3 -0
  109. package/types/check/action-options.d.ts.map +1 -0
  110. package/types/check/schema-json.d.ts +3 -0
  111. package/types/check/schema-json.d.ts.map +1 -0
  112. package/types/check/shadow-types.d.ts.map +1 -1
  113. package/types/compiler/codegen.d.ts +2 -0
  114. package/types/compiler/codegen.d.ts.map +1 -1
  115. package/types/compiler/deprecated-lints-1-105.d.ts +39 -0
  116. package/types/compiler/deprecated-lints-1-105.d.ts.map +1 -0
  117. package/types/compiler/deprecated-lints-1-106.d.ts +1 -1
  118. package/types/compiler/deprecated-lints-1-106.d.ts.map +1 -1
  119. package/types/compiler/deprecated-lints-1-107.d.ts +12 -0
  120. package/types/compiler/deprecated-lints-1-107.d.ts.map +1 -0
  121. package/types/compiler/deprecated-lints.d.ts +36 -44
  122. package/types/compiler/deprecated-lints.d.ts.map +1 -1
  123. package/types/compiler/import-edits.d.ts +1 -0
  124. package/types/compiler/import-edits.d.ts.map +1 -1
  125. package/types/compiler/index.d.ts +2 -0
  126. package/types/compiler/index.d.ts.map +1 -1
  127. package/types/compiler/island-declaration.d.ts +5 -0
  128. package/types/compiler/island-declaration.d.ts.map +1 -1
  129. package/types/compiler/kay-exports.d.ts.map +1 -1
  130. package/types/compiler/lazy-imports.d.ts +33 -0
  131. package/types/compiler/lazy-imports.d.ts.map +1 -0
  132. package/types/compiler/lints.d.ts +44 -44
  133. package/types/compiler/route-lints.d.ts +8 -0
  134. package/types/compiler/route-lints.d.ts.map +1 -1
  135. package/types/compiler/schema-lints.d.ts +11 -0
  136. package/types/compiler/schema-lints.d.ts.map +1 -0
  137. package/types/compiler/script-server.d.ts.map +1 -1
  138. package/types/new.d.ts +1 -0
  139. package/types/new.d.ts.map +1 -1
  140. package/types/runtime/action.d.ts +26 -1
  141. package/types/runtime/action.d.ts.map +1 -1
  142. package/types/runtime/client.d.ts.map +1 -1
  143. package/types/runtime/dom-lazy.d.ts +6 -0
  144. package/types/runtime/dom-lazy.d.ts.map +1 -0
  145. package/types/runtime/field-errors.d.ts +4 -0
  146. package/types/runtime/field-errors.d.ts.map +1 -0
  147. package/types/runtime/field-refusal.d.ts +37 -0
  148. package/types/runtime/field-refusal.d.ts.map +1 -0
  149. package/types/runtime/form.d.ts +1 -1
  150. package/types/runtime/form.d.ts.map +1 -1
  151. package/types/runtime/html.d.ts.map +1 -1
  152. package/types/runtime/index.d.ts +2 -0
  153. package/types/runtime/index.d.ts.map +1 -1
  154. package/types/runtime/island.server.d.ts +2 -0
  155. package/types/runtime/island.server.d.ts.map +1 -1
  156. package/types/runtime/schema-record.d.ts.map +1 -1
  157. package/types/runtime/schema.client.d.ts.map +1 -1
  158. package/types/runtime/schema.d.ts +6 -1
  159. package/types/runtime/schema.d.ts.map +1 -1
  160. package/types/runtime/standard-schema.d.ts +37 -0
  161. package/types/runtime/standard-schema.d.ts.map +1 -0
  162. package/types/runtime/validate-run.client.d.ts +4 -0
  163. package/types/runtime/validate-run.client.d.ts.map +1 -0
  164. package/types/runtime/validate.client.d.ts +4 -0
  165. package/types/runtime/validate.client.d.ts.map +1 -0
  166. package/types/runtime/validate.d.ts +1 -21
  167. package/types/runtime/validate.d.ts.map +1 -1
  168. package/types/server/actions.d.ts.map +1 -1
  169. package/types/server/answer.d.ts +6 -0
  170. package/types/server/answer.d.ts.map +1 -0
  171. package/types/server/api-input.d.ts +19 -0
  172. package/types/server/api-input.d.ts.map +1 -0
  173. package/types/server/api.d.ts.map +1 -1
  174. package/types/server/app-stages.d.ts +4 -1
  175. package/types/server/app-stages.d.ts.map +1 -1
  176. package/types/server/app.d.ts +2 -0
  177. package/types/server/app.d.ts.map +1 -1
  178. package/types/server/client.d.ts +1 -0
  179. package/types/server/client.d.ts.map +1 -1
  180. package/types/server/dev.d.ts +1 -1
  181. package/types/server/dev.d.ts.map +1 -1
  182. package/types/server/file-limit.d.ts.map +1 -1
  183. package/types/server/host-allowlist.d.ts +3 -3
  184. package/types/server/host-allowlist.d.ts.map +1 -1
  185. package/types/server/index.d.ts +2 -0
  186. package/types/server/index.d.ts.map +1 -1
  187. package/types/server/kay-routes.d.ts +47 -0
  188. package/types/server/kay-routes.d.ts.map +1 -0
  189. package/types/server/kay-server.d.ts +25 -0
  190. package/types/server/kay-server.d.ts.map +1 -0
  191. package/types/server/kept-exports.d.ts.map +1 -1
  192. package/types/server/library.d.ts +0 -1
  193. package/types/server/library.d.ts.map +1 -1
  194. package/types/server/openapi.d.ts.map +1 -1
  195. package/types/server/phases.d.ts +36 -0
  196. package/types/server/phases.d.ts.map +1 -0
  197. package/types/server/protection.d.ts +3 -2
  198. package/types/server/protection.d.ts.map +1 -1
  199. package/types/server/proxy-key.d.ts +3 -3
  200. package/types/server/proxy-key.d.ts.map +1 -1
  201. package/types/server/query.d.ts.map +1 -1
  202. package/types/server/receive.d.ts +9 -0
  203. package/types/server/receive.d.ts.map +1 -0
  204. package/types/server/render-document.d.ts.map +1 -1
  205. package/types/server/request-context.d.ts +29 -0
  206. package/types/server/request-context.d.ts.map +1 -0
  207. package/types/server/schema-check.d.ts +1 -0
  208. package/types/server/schema-check.d.ts.map +1 -1
  209. package/types/server/socket.d.ts +3 -5
  210. package/types/server/socket.d.ts.map +1 -1
  211. package/types/server/validate.d.ts +26 -0
  212. package/types/server/validate.d.ts.map +1 -0
  213. package/types/test/mount.d.ts.map +1 -1
  214. package/src/check/schema-type.ts +0 -9
  215. package/src/compiler/deprecated-script-fence.ts +0 -26
  216. package/src/server/field-errors.ts +0 -136
  217. package/types/check/schema-type.d.ts +0 -3
  218. package/types/check/schema-type.d.ts.map +0 -1
  219. package/types/compiler/deprecated-script-fence.d.ts +0 -3
  220. package/types/compiler/deprecated-script-fence.d.ts.map +0 -1
  221. package/types/server/field-errors.d.ts +0 -6
  222. package/types/server/field-errors.d.ts.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import type { Elysia } from 'elysia';
2
- import { ValidationError } from 'elysia';
2
+ import type { Issue } from './validate';
3
3
  import { ElysiaWS } from 'elysia/ws';
4
4
  export interface SocketRefusalFrame {
5
5
  error: {
@@ -18,13 +18,11 @@ type Peer = ElysiaWS;
18
18
  type Checked = {
19
19
  value: unknown;
20
20
  } | {
21
- refused: ValidationError;
22
- schema: unknown;
21
+ refused: Issue[];
23
22
  } | Promise<{
24
23
  value: unknown;
25
24
  } | {
26
- refused: ValidationError;
27
- schema: unknown;
25
+ refused: Issue[];
28
26
  }>;
29
27
  export declare function adopt(ws: ElysiaWS, route: SocketRoute): Promise<ElysiaWS>;
30
28
  declare const ADOPTED: unique symbol;
@@ -1 +1 @@
1
- {"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../src/server/socket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAsB,eAAe,EAAE,MAAM,QAAQ,CAAA;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAWpC,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE;QAAE,GAAG,EAAE,oBAAoB,GAAG,oBAAoB,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,C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AC,OAAO,EAAE,OAAO,KAAK,IAAI,CA4CpE;AAED,UAAU,SAAS;IACjB,KAAK,EAAE,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAA;CACzC;AAID,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,GAAG,SAAS,GAAG,SAAS,CA4BhG;AAkBD,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;CAC1B;AAuBD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,MAAM,GAAG,aAAa,CAiBpG"}
@@ -0,0 +1,26 @@
1
+ import type { LocaleState } from '../runtime/locale-state';
2
+ import type { InvalidWord } from './words';
3
+ export type Source = 'form' | 'query' | 'params' | 'env' | 'json';
4
+ export interface Issue {
5
+ path: string;
6
+ key: InvalidWord;
7
+ params: Record<string, string | number>;
8
+ message: string;
9
+ }
10
+ export interface Refusal {
11
+ errors: Issue[];
12
+ status: 422;
13
+ }
14
+ export type Validated<Value = unknown> = {
15
+ value: Value;
16
+ } | Refusal;
17
+ export interface ValidateOptions {
18
+ source: Source;
19
+ locale?: LocaleState | undefined;
20
+ trim?: boolean | undefined;
21
+ }
22
+ export declare function isRefusal(result: Validated): result is Refusal;
23
+ export declare function messagesOf(errors: readonly Issue[]): Record<string, string>;
24
+ export declare function validate<Value = unknown>(schema: object, value: unknown, { source, locale, trim }: ValidateOptions): Promise<Validated<Value>>;
25
+ export declare function validateNow<Value = unknown>(schema: object, value: unknown, { source, locale, trim }: ValidateOptions): Validated<Value>;
26
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/server/validate.ts"],"names":[],"mappings":"AAC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AAC,IAAI,CAAC,CAM5C;AAGD,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,UAAoB,GAAG,IAAI,CAE/F;AAGD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAKpE;AAGD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,UAAoB,GAAG,OAAO,CAIjF;AAmBD,KAAK,OAAO,CAAC,SAAS,IAAI,SAAS,SAAS,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,OAAO,GAAG,KAAK,GAAG,KAAK,CAAA;AAG3F,KAAK,cAAc,CAAC,SAAS,IAAI,SAAS,SAAS,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,KAAK,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,GAAG,KAAK,CAAA;AAOpK,wBAAsB,cAAc,CAAC,SAAS,SAAS,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,cAAc,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA"}
@@ -1,9 +0,0 @@
1
- import type { CheckDiagnostic, CheckOptions } from '.'
2
- import { renamedTypes } from './renamed-exports'
3
-
4
- const OLD_NAME = /\bTSchema\b/
5
-
6
- // `TSchema` imported from `kay/library`, which is `Schema` since 1.103: kay's own name for what `s` builds, so a signature of the app does not name TypeBox. The fix renames the import and every use of it.
7
- export async function schemaType(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
8
- return renamedTypes(root, options, { lint: 'deprecated-schema-type', modules: { 'kay/library': { TSchema: 'Schema' } }, needle: OLD_NAME, since: '1.103', until: '1.106' })
9
- }
@@ -1,26 +0,0 @@
1
- import type { Diagnostic, KayFile } from './ast'
2
-
3
- const SPELLED_OUT = /^---[ \t]+script\b/
4
-
5
- // `--- script` opening a file: the bare `---` is the same fence, and only a script that follows a named fence needs the word, as there a bare line would close the named one.
6
- export function spelledOutScriptFence(file: KayFile): Diagnostic[] {
7
- const line = file.scriptLine
8
-
9
- if (!line || file.source.slice(0, line.start).trim() !== '')
10
- return []
11
-
12
- const spelled = SPELLED_OUT.exec(file.source.slice(line.start, line.end))
13
-
14
- if (!spelled)
15
- return []
16
-
17
- return [{
18
- start: line.start,
19
- end: line.start + spelled[0].length,
20
- code: 'deprecated-script-fence',
21
- checkOnly: true,
22
- message: '`--- script` is `---` spelled out, deprecated since 1.102',
23
- help: 'write `---`: the word is only needed for a script that follows a `--- server`, `--- module` or `--- style` fence',
24
- fixes: [{ title: 'Write `---`', safe: true, edits: [{ start: line.start + 3, end: line.start + spelled[0].length, text: '' }] }],
25
- }]
26
- }
@@ -1,136 +0,0 @@
1
- import type { TSchema, ValidationError } from 'elysia'
2
- import { fieldOf } from './schema-check'
3
- import { invalidWord, schemaRefusal } from './words'
4
-
5
- const withoutFunctions = new WeakMap<object, unknown>()
6
-
7
- // Where a stripped node keeps its `error` function, on the node itself: a schema Elysia merges or clones (a guard's with the route's) keeps own symbols, where a lookup by the identity of the whole schema would miss it.
8
- const STRIPPED_ERROR = Symbol.for('kay.strippedError')
9
-
10
- // The text an `error` option gives a field, a string or the string a function returns; a function that throws or returns anything else gives none, so the field keeps its default wording.
11
- // A function is called where the caller runs, which is inside the request's locale.
12
- export function errorText(error: unknown): string | undefined {
13
- if (typeof error === 'function') {
14
- try {
15
- const text = (error as () => unknown)()
16
-
17
- return typeof text === 'string' ? text : undefined
18
- }
19
- catch {
20
- return undefined
21
- }
22
- }
23
-
24
- return typeof error === 'string' ? error : undefined
25
- }
26
-
27
- function isNode(value: unknown): value is Record<string | symbol, unknown> {
28
- if (typeof value !== 'object' || value === null)
29
- return false
30
-
31
- const prototype = Object.getPrototypeOf(value) as unknown
32
-
33
- return prototype === Object.prototype || prototype === null
34
- }
35
-
36
- function hasErrorFunction(node: unknown): boolean {
37
- if (Array.isArray(node))
38
- return node.some(hasErrorFunction)
39
-
40
- return isNode(node) && Object.entries(node).some(([key, value]) => (key === 'error' && typeof value === 'function') || hasErrorFunction(value))
41
- }
42
-
43
- function stripped(node: unknown): unknown {
44
- if (Array.isArray(node))
45
- return node.map(stripped)
46
-
47
- if (!isNode(node))
48
- return node
49
-
50
- const copy = Object.create(Object.getPrototypeOf(node) as object | null) as Record<string | symbol, unknown>
51
-
52
- for (const key of Reflect.ownKeys(node)) {
53
- if (key === 'error' && typeof node[key] === 'function')
54
- copy[STRIPPED_ERROR] = node[key]
55
- else
56
- copy[key] = stripped(node[key])
57
- }
58
-
59
- return copy
60
- }
61
-
62
- // The schema Elysia validates with: the same, but for the `error` functions, which Elysia would call outside the request's locale and which kay reads itself with `fieldMessage`.
63
- export function validated(schema: TSchema): TSchema {
64
- if (!hasErrorFunction(schema))
65
- return schema
66
-
67
- if (!withoutFunctions.has(schema)) {
68
- const copy = stripped(schema)
69
-
70
- withoutFunctions.set(schema, copy)
71
- }
72
-
73
- return withoutFunctions.get(schema) as TSchema
74
- }
75
-
76
- const segmentOf = (segment: string): string => segment.replaceAll('~1', '/').replaceAll('~0', '~')
77
-
78
- // The first `error` found on the way down: a field's own, else a branch of its `anyOf`.
79
- function find(node: unknown, segments: string[]): string | undefined {
80
- if (!isNode(node))
81
- return undefined
82
-
83
- const [head, ...rest] = segments
84
- const named = head !== undefined && isNode(node.properties) && Object.hasOwn(node.properties, head)
85
- const found = head === undefined ? errorText(node.error ?? node[STRIPPED_ERROR]) : find(named ? (node.properties as Record<string, unknown>)[head] : node.items, rest)
86
-
87
- if (found !== undefined || !Array.isArray(node.anyOf))
88
- return found
89
-
90
- for (const branch of node.anyOf) {
91
- const inBranch = find(branch, segments)
92
-
93
- if (inBranch !== undefined)
94
- return inBranch
95
- }
96
-
97
- return undefined
98
- }
99
-
100
- // The `error` option at a JSON pointer of the action's own schema, a field's, an item's or one of a union's branches, read in the current locale.
101
- export function fieldMessage(schema: unknown, pointer: string): string | undefined {
102
- return find(schema, pointer.split('/').slice(1).map(segmentOf))
103
- }
104
-
105
- // The `kay.invalid.*` text for what an issue refused, Elysia's own summary when the site words none; the limit it names goes in as `{min}` or `{max}`, a format as `{format}`.
106
- function refusalText(issue: { summary?: string | undefined, schema?: unknown, value?: unknown }): string {
107
- const { kind, params } = schemaRefusal(issue)
108
-
109
- return invalidWord(`kay.invalid.${kind}`, issue.summary, params)
110
- }
111
-
112
- // A message per field the schema refused: its own `error` when it has one, else the `kay.invalid.*` text, both in the current locale.
113
- // An issue of a Standard Schema validator has no TypeBox schema: its dotted path names the field and its own message is the text.
114
- export function refusedFields(schema: unknown, error: Readonly<ValidationError>): Record<string, string> {
115
- const errors: Record<string, string> = Object.create(null) as Record<string, string>
116
-
117
- for (const issue of error.all) {
118
- if (!('schema' in issue)) {
119
- const standard = issue as { path?: string, summary?: string, message?: string }
120
- const dot = standard.path?.indexOf('.') ?? -1
121
- const named = dot < 0 ? standard.path : standard.path?.slice(0, dot)
122
-
123
- errors[named === undefined || named === 'root' ? '' : named] ??= standard.summary ?? standard.message ?? 'Invalid value'
124
-
125
- continue
126
- }
127
-
128
- const field = 'path' in issue ? fieldOf(issue.path) : ''
129
- const own = 'schema' in issue ? (issue.schema as { error?: unknown }).error : undefined
130
- const custom = ('path' in issue ? fieldMessage(schema, issue.path) : undefined) ?? (typeof own === 'string' ? own : undefined)
131
-
132
- errors[field] ??= custom ?? refusalText(issue)
133
- }
134
-
135
- return errors
136
- }
@@ -1,3 +0,0 @@
1
- import type { CheckDiagnostic, CheckOptions } from '.';
2
- export declare function schemaType(root: string, options: CheckOptions): Promise<CheckDiagnostic[]>;
3
- //# sourceMappingURL=schema-type.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema-type.d.ts","sourceRoot":"","sources":["../../src/check/schema-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,GAAG,CAAA;AAMtD,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAEhG"}
@@ -1,3 +0,0 @@
1
- import type { Diagnostic, KayFile } from './ast';
2
- export declare function spelledOutScriptFence(file: KayFile): Diagnostic[];
3
- //# sourceMappingURL=deprecated-script-fence.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deprecated-script-fence.d.ts","sourceRoot":"","sources":["../../src/compiler/deprecated-script-fence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAKhD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,EAAE,CAoBjE"}
@@ -1,6 +0,0 @@
1
- import type { TSchema, ValidationError } from 'elysia';
2
- export declare function errorText(error: unknown): string | undefined;
3
- export declare function validated(schema: TSchema): TSchema;
4
- export declare function fieldMessage(schema: unknown, pointer: string): string | undefined;
5
- export declare function refusedFields(schema: unknown, error: Readonly<ValidationError>): Record<string, string>;
6
- //# sourceMappingURL=field-errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"field-errors.d.ts","sourceRoot":"","sources":["../../src/server/field-errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAWtD,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAa5D;AAsCD,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAWlD;AA2BD,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEjF;AAWD,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAsBvG"}