@livon/schema 0.27.0-rc.5 → 0.28.0-rc.4

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 (172) hide show
  1. package/README.md +57 -41
  2. package/THIRD_PARTY_NOTICES.md +28 -0
  3. package/dist/SchemaValidationError.cjs +26 -49
  4. package/dist/SchemaValidationError.d.ts +1 -1
  5. package/dist/SchemaValidationError.js +1 -14
  6. package/dist/after.cjs +26 -62
  7. package/dist/after.d.ts +1 -1
  8. package/dist/after.js +1 -27
  9. package/dist/and.cjs +48 -69
  10. package/dist/and.d.ts +31 -5
  11. package/dist/and.js +23 -34
  12. package/dist/api.cjs +71 -140
  13. package/dist/api.d.ts +3 -3
  14. package/dist/api.js +36 -94
  15. package/dist/array.cjs +31 -72
  16. package/dist/array.d.ts +1 -1
  17. package/dist/array.js +6 -34
  18. package/dist/before.cjs +26 -62
  19. package/dist/before.d.ts +1 -1
  20. package/dist/before.js +1 -27
  21. package/dist/binary.cjs +30 -71
  22. package/dist/binary.d.ts +1 -1
  23. package/dist/binary.js +5 -33
  24. package/dist/boolean.cjs +30 -71
  25. package/dist/boolean.d.ts +1 -1
  26. package/dist/boolean.js +5 -33
  27. package/dist/combinatorName.cjs +28 -45
  28. package/dist/combinatorName.js +3 -10
  29. package/dist/context.cjs +49 -121
  30. package/dist/context.d.ts +6 -6
  31. package/dist/context.js +14 -81
  32. package/dist/date.cjs +30 -71
  33. package/dist/date.d.ts +1 -1
  34. package/dist/date.js +5 -33
  35. package/dist/doc.cjs +37 -82
  36. package/dist/doc.d.ts +2 -2
  37. package/dist/doc.js +10 -46
  38. package/dist/enumeration.cjs +43 -84
  39. package/dist/enumeration.d.ts +4 -4
  40. package/dist/enumeration.js +17 -44
  41. package/dist/hydrate.cjs +13 -24
  42. package/dist/hydrate.js +0 -4
  43. package/dist/index.cjs +81 -121
  44. package/dist/index.d.ts +1 -1
  45. package/dist/index.js +0 -76
  46. package/dist/literal.cjs +30 -69
  47. package/dist/literal.d.ts +1 -1
  48. package/dist/literal.js +5 -30
  49. package/dist/number.cjs +52 -101
  50. package/dist/number.d.ts +6 -6
  51. package/dist/number.js +27 -63
  52. package/dist/object.cjs +33 -85
  53. package/dist/object.d.ts +1 -1
  54. package/dist/object.js +8 -47
  55. package/dist/operation.cjs +64 -142
  56. package/dist/operation.d.ts +6 -6
  57. package/dist/operation.js +26 -96
  58. package/dist/or.cjs +37 -85
  59. package/dist/or.d.ts +1 -1
  60. package/dist/or.js +10 -45
  61. package/dist/schema.cjs +71 -173
  62. package/dist/schema.d.ts +7 -7
  63. package/dist/schema.js +27 -123
  64. package/dist/schemaFactory.cjs +40 -85
  65. package/dist/schemaFactory.d.ts +6 -6
  66. package/dist/schemaFactory.js +5 -38
  67. package/dist/schemaModule.cjs +81 -147
  68. package/dist/schemaModule.d.ts +1 -1
  69. package/dist/schemaModule.js +52 -106
  70. package/dist/string.cjs +55 -104
  71. package/dist/string.d.ts +6 -6
  72. package/dist/string.js +30 -66
  73. package/dist/tuple.cjs +31 -78
  74. package/dist/tuple.d.ts +1 -1
  75. package/dist/tuple.js +6 -40
  76. package/dist/typeGuards.cjs +44 -121
  77. package/dist/typeGuards.d.ts +7 -7
  78. package/dist/typeGuards.js +7 -80
  79. package/dist/types.cjs +13 -24
  80. package/dist/types.d.ts +7 -7
  81. package/dist/types.js +0 -4
  82. package/dist/union.cjs +26 -46
  83. package/dist/union.d.ts +1 -1
  84. package/dist/union.js +0 -6
  85. package/package.json +26 -33
  86. package/PROMPT.md +0 -21
  87. package/SCHEMA.md +0 -13
  88. package/dist/mini/SchemaValidationError.cjs +0 -1
  89. package/dist/mini/SchemaValidationError.d.ts +0 -20
  90. package/dist/mini/SchemaValidationError.js +0 -1
  91. package/dist/mini/after.cjs +0 -1
  92. package/dist/mini/after.d.ts +0 -30
  93. package/dist/mini/after.js +0 -1
  94. package/dist/mini/and.cjs +0 -1
  95. package/dist/mini/and.d.ts +0 -37
  96. package/dist/mini/and.js +0 -1
  97. package/dist/mini/api.cjs +0 -1
  98. package/dist/mini/api.d.ts +0 -107
  99. package/dist/mini/api.js +0 -1
  100. package/dist/mini/array.cjs +0 -1
  101. package/dist/mini/array.d.ts +0 -25
  102. package/dist/mini/array.js +0 -1
  103. package/dist/mini/before.cjs +0 -1
  104. package/dist/mini/before.d.ts +0 -30
  105. package/dist/mini/before.js +0 -1
  106. package/dist/mini/binary.cjs +0 -1
  107. package/dist/mini/binary.d.ts +0 -24
  108. package/dist/mini/binary.js +0 -1
  109. package/dist/mini/boolean.cjs +0 -1
  110. package/dist/mini/boolean.d.ts +0 -24
  111. package/dist/mini/boolean.js +0 -1
  112. package/dist/mini/combinatorName.cjs +0 -1
  113. package/dist/mini/combinatorName.d.ts +0 -8
  114. package/dist/mini/combinatorName.js +0 -1
  115. package/dist/mini/context.cjs +0 -1
  116. package/dist/mini/context.d.ts +0 -101
  117. package/dist/mini/context.js +0 -1
  118. package/dist/mini/date.cjs +0 -1
  119. package/dist/mini/date.d.ts +0 -24
  120. package/dist/mini/date.js +0 -1
  121. package/dist/mini/doc.cjs +0 -1
  122. package/dist/mini/doc.d.ts +0 -25
  123. package/dist/mini/doc.js +0 -1
  124. package/dist/mini/enumeration.cjs +0 -1
  125. package/dist/mini/enumeration.d.ts +0 -50
  126. package/dist/mini/enumeration.js +0 -1
  127. package/dist/mini/hydrate.cjs +0 -1
  128. package/dist/mini/hydrate.d.ts +0 -1
  129. package/dist/mini/hydrate.js +0 -0
  130. package/dist/mini/index.cjs +0 -1
  131. package/dist/mini/index.d.ts +0 -34
  132. package/dist/mini/index.js +0 -1
  133. package/dist/mini/literal.cjs +0 -1
  134. package/dist/mini/literal.d.ts +0 -25
  135. package/dist/mini/literal.js +0 -1
  136. package/dist/mini/number.cjs +0 -1
  137. package/dist/mini/number.d.ts +0 -84
  138. package/dist/mini/number.js +0 -1
  139. package/dist/mini/object.cjs +0 -1
  140. package/dist/mini/object.d.ts +0 -37
  141. package/dist/mini/object.js +0 -1
  142. package/dist/mini/operation.cjs +0 -1
  143. package/dist/mini/operation.d.ts +0 -197
  144. package/dist/mini/operation.js +0 -1
  145. package/dist/mini/or.cjs +0 -1
  146. package/dist/mini/or.d.ts +0 -36
  147. package/dist/mini/or.js +0 -1
  148. package/dist/mini/schema.cjs +0 -1
  149. package/dist/mini/schema.d.ts +0 -132
  150. package/dist/mini/schema.js +0 -1
  151. package/dist/mini/schemaFactory.cjs +0 -1
  152. package/dist/mini/schemaFactory.d.ts +0 -97
  153. package/dist/mini/schemaFactory.js +0 -1
  154. package/dist/mini/schemaModule.cjs +0 -1
  155. package/dist/mini/schemaModule.d.ts +0 -80
  156. package/dist/mini/schemaModule.js +0 -1
  157. package/dist/mini/string.cjs +0 -1
  158. package/dist/mini/string.d.ts +0 -85
  159. package/dist/mini/string.js +0 -1
  160. package/dist/mini/tuple.cjs +0 -1
  161. package/dist/mini/tuple.d.ts +0 -33
  162. package/dist/mini/tuple.js +0 -1
  163. package/dist/mini/typeGuards.cjs +0 -1
  164. package/dist/mini/typeGuards.d.ts +0 -93
  165. package/dist/mini/typeGuards.js +0 -1
  166. package/dist/mini/types.cjs +0 -1
  167. package/dist/mini/types.d.ts +0 -293
  168. package/dist/mini/types.js +0 -0
  169. package/dist/mini/union.cjs +0 -1
  170. package/dist/mini/union.d.ts +0 -30
  171. package/dist/mini/union.js +0 -1
  172. /package/{LICENCE.md → LICENSE.md} +0 -0
package/README.md CHANGED
@@ -1,5 +1,14 @@
1
+ <!-- Generated from website/docs/packages/*.md. Do not edit directly. -->
2
+
1
3
  # @livon/schema
2
4
 
5
+
6
+ [![npm](https://img.shields.io/npm/v/%40livon%2Fschema)](https://www.npmjs.com/package/@livon/schema)
7
+ [![dependencies](https://img.shields.io/librariesio/release/npm/%40livon%2Fschema?label=dependencies)](https://libraries.io/npm/%40livon%2Fschema)
8
+ [![code quality](https://img.shields.io/github/actions/workflow/status/live-input-vector-output-node/livon-ts/code-quality.yml?branch=main&label=code%20quality)](https://github.com/live-input-vector-output-node/livon-ts/actions/workflows/code-quality.yml)
9
+ [![package size](https://img.shields.io/npm/unpacked-size/%40livon%2Fschema?label=package%20size)](https://www.npmjs.com/package/@livon/schema)
10
+ [![license](https://img.shields.io/github/license/live-input-vector-output-node/livon-ts)](https://github.com/live-input-vector-output-node/livon-ts)
11
+
3
12
  ## Install
4
13
 
5
14
  ```sh
@@ -8,48 +17,52 @@ pnpm add @livon/schema
8
17
 
9
18
  ## Purpose
10
19
 
11
- [@livon/schema](https://live-input-vector-output-node.github.io/livon-ts/docs/packages/schema) defines:
20
+ [@livon/schema](https://livon.tech/docs/packages/schema) defines:
12
21
 
13
- - [value schemas](https://live-input-vector-output-node.github.io/livon-ts/docs/schema) (`string`, `number`, `object`, `array`, `or`, `union`, ...)
22
+ - [value schemas](https://livon.tech/docs/schema) (`string`, `number`, `object`, `array`, `or`, `union`, ...)
14
23
  - operation schemas
15
24
  - subscription schemas
16
- - [schema runtime module](https://live-input-vector-output-node.github.io/livon-ts/docs/technical/runtime-design) (`schemaModule`)
25
+ - [schema module](https://livon.tech/docs/technical/runtime-design) (`schemaModule`)
26
+
27
+ ## Best for
28
+
29
+ Use this package when you want a single schema source for validation, typing, and generated client APIs.
17
30
 
18
31
  ## Schema API docs
19
32
 
20
33
  Each schema/combinator has its own usage page:
21
34
 
22
- - [Schema APIs overview](https://live-input-vector-output-node.github.io/livon-ts/docs/schema)
23
- - [Schema Type Safety](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/type-safety)
24
- - [Schema Context](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/context)
25
- - [string](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/string)
26
- - [number](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/number)
27
- - [boolean](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/boolean)
28
- - [date](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/date)
29
- - [enumeration](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/enumeration)
30
- - [object](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/object)
31
- - [array](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/array)
32
- - [tuple](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/tuple)
33
- - [literal](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/literal)
34
- - [union](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/union)
35
- - [or](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/or)
36
- - [binary](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/binary)
37
- - [before](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/before)
38
- - [after](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/after)
39
- - [and](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/and)
40
- - [api](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/api)
41
- - [operation](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/operation)
42
- - [subscription](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/subscription)
43
- - [fieldResolver](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/field-resolver)
44
- - [schemaFactory](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/schema-factory)
45
- - [typeGuards](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/type-guards)
35
+ - [Schema APIs overview](https://livon.tech/docs/schema)
36
+ - [Schema Type Safety](https://livon.tech/docs/schema/type-safety)
37
+ - [Schema Context](https://livon.tech/docs/schema/context)
38
+ - [string](https://livon.tech/docs/schema/string)
39
+ - [number](https://livon.tech/docs/schema/number)
40
+ - [boolean](https://livon.tech/docs/schema/boolean)
41
+ - [date](https://livon.tech/docs/schema/date)
42
+ - [enumeration](https://livon.tech/docs/schema/enumeration)
43
+ - [object](https://livon.tech/docs/schema/object)
44
+ - [array](https://livon.tech/docs/schema/array)
45
+ - [tuple](https://livon.tech/docs/schema/tuple)
46
+ - [literal](https://livon.tech/docs/schema/literal)
47
+ - [union](https://livon.tech/docs/schema/union)
48
+ - [or](https://livon.tech/docs/schema/or)
49
+ - [binary](https://livon.tech/docs/schema/binary)
50
+ - [before](https://livon.tech/docs/schema/before)
51
+ - [after](https://livon.tech/docs/schema/after)
52
+ - [and](https://livon.tech/docs/schema/and)
53
+ - [api](https://livon.tech/docs/schema/api)
54
+ - [operation](https://livon.tech/docs/schema/operation)
55
+ - [subscription](https://livon.tech/docs/schema/subscription)
56
+ - [fieldResolver](https://livon.tech/docs/schema/field-resolver)
57
+ - [schemaFactory](https://livon.tech/docs/schema/schema-factory)
58
+ - [typeGuards](https://livon.tech/docs/schema/type-guards)
46
59
 
47
60
  ## Type safety model
48
61
 
49
- LIVON [schemas](https://live-input-vector-output-node.github.io/livon-ts/docs/schema) are both runtime validators and type sources.
62
+ LIVON [schemas](https://livon.tech/docs/schema) are both runtime validators and type sources.
50
63
  Primitive schema names are optional, so `string()` and `number()` are valid defaults.
51
64
 
52
- 1. Define payload shape once in [schema](https://live-input-vector-output-node.github.io/livon-ts/docs/schema).
65
+ 1. Define payload shape once in [schema](https://livon.tech/docs/schema).
53
66
  2. Validate unknown input with `parse()`.
54
67
  3. Reuse schema entrypoint with `typed()`.
55
68
  4. Derive types with `Infer` instead of hand-written payload interfaces.
@@ -97,7 +110,7 @@ const typed = User.typed(typedInput);
97
110
  ```ts
98
111
  import {api} from '@livon/schema';
99
112
 
100
- const apiSchema = api({
113
+ const ApiSchema = api({
101
114
  type: User,
102
115
  operations: {
103
116
  sendMessage,
@@ -110,9 +123,12 @@ const apiSchema = api({
110
123
  },
111
124
  });
112
125
 
113
- export const serverSchema = apiSchema;
126
+ export const serverSchema = ApiSchema;
114
127
  ```
115
128
 
129
+ Use the `api(...)` (or `composeApi(...)`) result directly in `schemaModule(...)`.
130
+ No additional schema-module input factory is required.
131
+
116
132
  ### Parameters in this example
117
133
 
118
134
  `api({...})`:
@@ -124,10 +140,10 @@ export const serverSchema = apiSchema;
124
140
 
125
141
  For focused usage patterns:
126
142
 
127
- - [api](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/api)
128
- - [operation](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/operation)
129
- - [subscription](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/subscription)
130
- - [fieldResolver](https://live-input-vector-output-node.github.io/livon-ts/docs/schema/field-resolver)
143
+ - [api](https://livon.tech/docs/schema/api)
144
+ - [operation](https://livon.tech/docs/schema/operation)
145
+ - [subscription](https://livon.tech/docs/schema/subscription)
146
+ - [fieldResolver](https://livon.tech/docs/schema/field-resolver)
131
147
 
132
148
  ## Mount schema module into runtime
133
149
 
@@ -147,12 +163,12 @@ runtime(schemaModule(serverSchema, {explain: true}));
147
163
 
148
164
  ## Explain endpoint
149
165
 
150
- If `explain: true`, [schema module](https://live-input-vector-output-node.github.io/livon-ts/docs/technical/runtime-design) responds to `$explain` with AST/checksum metadata.
166
+ If `explain: true`, [schema module](https://livon.tech/docs/technical/runtime-design) responds to `$explain` with AST/checksum metadata.
151
167
 
152
168
  ## Related pages
153
169
 
154
- - [Validated by Default](https://live-input-vector-output-node.github.io/livon-ts/docs/core/validated-by-default)
155
- - [parse vs typed](https://live-input-vector-output-node.github.io/livon-ts/docs/core/parse-vs-typed)
156
- - [Schema APIs overview](https://live-input-vector-output-node.github.io/livon-ts/docs/schema)
157
- - [Runtime Design](https://live-input-vector-output-node.github.io/livon-ts/docs/technical/runtime-design)
158
- - [Architecture](https://live-input-vector-output-node.github.io/livon-ts/docs/technical/architecture)
170
+ - [Validated by Default](https://livon.tech/docs/core/validated-by-default)
171
+ - [parse vs typed](https://livon.tech/docs/core/parse-vs-typed)
172
+ - [Schema APIs overview](https://livon.tech/docs/schema)
173
+ - [Runtime Design](https://livon.tech/docs/technical/runtime-design)
174
+ - [Architecture](https://livon.tech/docs/technical/architecture)
@@ -0,0 +1,28 @@
1
+ Third-Party Notices
2
+
3
+ This package includes third-party software. The following licenses apply:
4
+
5
+ ------------------------------------------------------------------------------
6
+ msgpackr
7
+ ------------------------------------------------------------------------------
8
+ License: MIT
9
+
10
+ Copyright (c) 2020 Kris Zyp
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
@@ -1,64 +1,41 @@
1
1
  "use strict";
2
- const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
3
- return typeof document === 'undefined'
4
- ? new (require('url'.replace('', '')).URL)('file:' + __filename).href
5
- : (document.currentScript && document.currentScript.src) ||
6
- new URL('main.js', document.baseURI).href;
7
- })();
8
- ;
9
- // The require scope
10
2
  var __webpack_require__ = {};
11
-
12
- // webpack/runtime/define_property_getters
13
- (() => {
14
- __webpack_require__.d = (exports, definition) => {
15
- for(var key in definition) {
16
- if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
17
- Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
18
- }
19
- }
20
- };
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
21
10
  })();
22
- // webpack/runtime/has_own_property
23
- (() => {
24
- __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
25
13
  })();
26
- // webpack/runtime/make_namespace_object
27
- (() => {
28
- // define __esModule on exports
29
- __webpack_require__.r = (exports) => {
30
- if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
31
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
32
- }
33
- Object.defineProperty(exports, '__esModule', { value: true });
34
- };
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
35
23
  })();
36
24
  var __webpack_exports__ = {};
37
25
  __webpack_require__.r(__webpack_exports__);
38
26
  __webpack_require__.d(__webpack_exports__, {
39
- createSchemaValidationError: () => (createSchemaValidationError)
27
+ createSchemaValidationError: ()=>createSchemaValidationError
40
28
  });
41
- /**
42
- * createSchemaValidationError is part of the public LIVON API.
43
- *
44
- * @remarks
45
- * Parameter and return types are defined in the TypeScript signature.
46
- *
47
- * @see https://live-input-vector-output-node.github.io/livon-ts/docs/schema/type-safety
48
- *
49
- * @example
50
- * const result = createSchemaValidationError(undefined as never);
51
- */ const createSchemaValidationError = ({ issues, meta })=>{
29
+ const createSchemaValidationError = ({ issues, meta })=>{
52
30
  const error = new Error('Schema validation failed');
53
31
  error.issues = issues;
54
32
  error.meta = meta;
55
33
  return error;
56
34
  };
57
-
58
35
  exports.createSchemaValidationError = __webpack_exports__.createSchemaValidationError;
59
- for(var __rspack_i in __webpack_exports__) {
60
- if(["createSchemaValidationError"].indexOf(__rspack_i) === -1) {
61
- exports[__rspack_i] = __webpack_exports__[__rspack_i];
62
- }
63
- }
64
- Object.defineProperty(exports, '__esModule', { value: true });
36
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
37
+ "createSchemaValidationError"
38
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
39
+ Object.defineProperty(exports, '__esModule', {
40
+ value: true
41
+ });
@@ -9,7 +9,7 @@ export type SchemaValidationError = Error & {
9
9
  * @remarks
10
10
  * Parameter and return types are defined in the TypeScript signature.
11
11
  *
12
- * @see https://live-input-vector-output-node.github.io/livon-ts/docs/schema/type-safety
12
+ * @see https://livon.tech/docs/schema/type-safety
13
13
  *
14
14
  * @example
15
15
  * const result = createSchemaValidationError(undefined as never);
@@ -1,20 +1,7 @@
1
-
2
- ;// CONCATENATED MODULE: ./src/SchemaValidationError.ts
3
- /**
4
- * createSchemaValidationError is part of the public LIVON API.
5
- *
6
- * @remarks
7
- * Parameter and return types are defined in the TypeScript signature.
8
- *
9
- * @see https://live-input-vector-output-node.github.io/livon-ts/docs/schema/type-safety
10
- *
11
- * @example
12
- * const result = createSchemaValidationError(undefined as never);
13
- */ const createSchemaValidationError = ({ issues, meta })=>{
1
+ const createSchemaValidationError = ({ issues, meta })=>{
14
2
  const error = new Error('Schema validation failed');
15
3
  error.issues = issues;
16
4
  error.meta = meta;
17
5
  return error;
18
6
  };
19
-
20
7
  export { createSchemaValidationError };
package/dist/after.cjs CHANGED
@@ -1,72 +1,36 @@
1
1
  "use strict";
2
- const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
3
- return typeof document === 'undefined'
4
- ? new (require('url'.replace('', '')).URL)('file:' + __filename).href
5
- : (document.currentScript && document.currentScript.src) ||
6
- new URL('main.js', document.baseURI).href;
7
- })();
8
- ;
9
- // The require scope
10
2
  var __webpack_require__ = {};
11
-
12
- // webpack/runtime/define_property_getters
13
- (() => {
14
- __webpack_require__.d = (exports, definition) => {
15
- for(var key in definition) {
16
- if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
17
- Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
18
- }
19
- }
20
- };
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
21
10
  })();
22
- // webpack/runtime/has_own_property
23
- (() => {
24
- __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
25
13
  })();
26
- // webpack/runtime/make_namespace_object
27
- (() => {
28
- // define __esModule on exports
29
- __webpack_require__.r = (exports) => {
30
- if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
31
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
32
- }
33
- Object.defineProperty(exports, '__esModule', { value: true });
34
- };
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
35
23
  })();
36
24
  var __webpack_exports__ = {};
37
25
  __webpack_require__.r(__webpack_exports__);
38
26
  __webpack_require__.d(__webpack_exports__, {
39
- after: () => (after)
27
+ after: ()=>after
40
28
  });
41
- /**
42
- * after is part of the public LIVON API.
43
- *
44
- * @remarks
45
- * Parameter and return types are defined in the TypeScript signature.
46
- *
47
- * @see https://live-input-vector-output-node.github.io/livon-ts/docs/schema/after
48
- *
49
- * @example
50
- * // Postprocesses validated string output by converting it to uppercase.
51
- * const UppercaseName = after({
52
- * schema: string(),
53
- * hook: (value: string) => value.toUpperCase(),
54
- * });
55
- * UppercaseName.parse('alice');
56
- *
57
- * @example
58
- * // Extends the postprocessed schema to also allow undefined.
59
- * const MaybeUppercaseName = after({
60
- * schema: string(),
61
- * hook: (value: string) => value.toUpperCase(),
62
- * }).optional();
63
- * MaybeUppercaseName.parse(undefined);
64
- */ const after = ({ schema, hook })=>schema.after(hook);
65
-
29
+ const after = ({ schema, hook })=>schema.after(hook);
66
30
  exports.after = __webpack_exports__.after;
67
- for(var __rspack_i in __webpack_exports__) {
68
- if(["after"].indexOf(__rspack_i) === -1) {
69
- exports[__rspack_i] = __webpack_exports__[__rspack_i];
70
- }
71
- }
72
- Object.defineProperty(exports, '__esModule', { value: true });
31
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
32
+ "after"
33
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
34
+ Object.defineProperty(exports, '__esModule', {
35
+ value: true
36
+ });
package/dist/after.d.ts CHANGED
@@ -9,7 +9,7 @@ export interface AfterInput<T> {
9
9
  * @remarks
10
10
  * Parameter and return types are defined in the TypeScript signature.
11
11
  *
12
- * @see https://live-input-vector-output-node.github.io/livon-ts/docs/schema/after
12
+ * @see https://livon.tech/docs/schema/after
13
13
  *
14
14
  * @example
15
15
  * // Postprocesses validated string output by converting it to uppercase.
package/dist/after.js CHANGED
@@ -1,28 +1,2 @@
1
-
2
- ;// CONCATENATED MODULE: ./src/after.ts
3
- /**
4
- * after is part of the public LIVON API.
5
- *
6
- * @remarks
7
- * Parameter and return types are defined in the TypeScript signature.
8
- *
9
- * @see https://live-input-vector-output-node.github.io/livon-ts/docs/schema/after
10
- *
11
- * @example
12
- * // Postprocesses validated string output by converting it to uppercase.
13
- * const UppercaseName = after({
14
- * schema: string(),
15
- * hook: (value: string) => value.toUpperCase(),
16
- * });
17
- * UppercaseName.parse('alice');
18
- *
19
- * @example
20
- * // Extends the postprocessed schema to also allow undefined.
21
- * const MaybeUppercaseName = after({
22
- * schema: string(),
23
- * hook: (value: string) => value.toUpperCase(),
24
- * }).optional();
25
- * MaybeUppercaseName.parse(undefined);
26
- */ const after = ({ schema, hook })=>schema.after(hook);
27
-
1
+ const after = ({ schema, hook })=>schema.after(hook);
28
2
  export { after };
package/dist/and.cjs CHANGED
@@ -1,80 +1,59 @@
1
1
  "use strict";
2
- const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
3
- return typeof document === 'undefined'
4
- ? new (require('url'.replace('', '')).URL)('file:' + __filename).href
5
- : (document.currentScript && document.currentScript.src) ||
6
- new URL('main.js', document.baseURI).href;
7
- })();
8
- ;
9
- // The require scope
10
2
  var __webpack_require__ = {};
11
-
12
- // webpack/runtime/define_property_getters
13
- (() => {
14
- __webpack_require__.d = (exports, definition) => {
15
- for(var key in definition) {
16
- if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
17
- Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
18
- }
19
- }
20
- };
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
21
10
  })();
22
- // webpack/runtime/has_own_property
23
- (() => {
24
- __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
25
13
  })();
26
- // webpack/runtime/make_namespace_object
27
- (() => {
28
- // define __esModule on exports
29
- __webpack_require__.r = (exports) => {
30
- if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
31
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
32
- }
33
- Object.defineProperty(exports, '__esModule', { value: true });
34
- };
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
35
23
  })();
36
24
  var __webpack_exports__ = {};
37
25
  __webpack_require__.r(__webpack_exports__);
38
26
  __webpack_require__.d(__webpack_exports__, {
39
- and: () => (and)
27
+ and: ()=>and
40
28
  });
41
- /**
42
- * and is part of the public LIVON API.
43
- *
44
- * @remarks
45
- * Parameter and return types are defined in the TypeScript signature.
46
- *
47
- * @see https://live-input-vector-output-node.github.io/livon-ts/docs/schema/and
48
- *
49
- * @example
50
- * // Extends a base message input schema with an id field.
51
- * const messageInput = object({
52
- * name: 'MessageInput',
53
- * shape: { text: string() },
54
- * });
55
- * const withId = object({
56
- * name: 'WithId',
57
- * shape: { id: string() },
58
- * });
59
- * const MessageWithId = and({ left: messageInput, right: withId });
60
- * MessageWithId.parse({ text: 'Hello', id: 'm-1' });
61
- *
62
- * @example
63
- * // Uses explicit naming for generated type surfaces.
64
- * const MessageWithId = and({
65
- * left: messageInput,
66
- * right: withId,
67
- * name: 'MessageWithId',
68
- * });
69
- * MessageWithId.parse({ text: 'Hello', id: 'm-1' });
70
- */ const and = ({ left, right, name })=>name === undefined ? left.and(right) : left.and(right, {
71
- name
29
+ const isLegacyInput = (input)=>'left' in input && 'right' in input;
30
+ function and(input) {
31
+ if (isLegacyInput(input)) {
32
+ const { left, right, name } = input;
33
+ return void 0 === name ? left.and(right) : left.and(right, {
34
+ name
35
+ });
36
+ }
37
+ const { schemas, name } = input;
38
+ if (schemas.length < 2) throw new Error('and() requires at least 2 schemas in the schemas array');
39
+ const [first, ...rest] = schemas;
40
+ const initial = first;
41
+ const lastIndex = rest.length - 1;
42
+ const reduced = rest.reduce((state, schema)=>({
43
+ schema: void 0 !== name && state.index === lastIndex ? state.schema.and(schema, {
44
+ name
45
+ }) : state.schema.and(schema),
46
+ index: state.index + 1
47
+ }), {
48
+ schema: initial,
49
+ index: 0
72
50
  });
73
-
74
- exports.and = __webpack_exports__.and;
75
- for(var __rspack_i in __webpack_exports__) {
76
- if(["and"].indexOf(__rspack_i) === -1) {
77
- exports[__rspack_i] = __webpack_exports__[__rspack_i];
78
- }
51
+ return reduced.schema;
79
52
  }
80
- Object.defineProperty(exports, '__esModule', { value: true });
53
+ exports.and = __webpack_exports__.and;
54
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
55
+ "and"
56
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
57
+ Object.defineProperty(exports, '__esModule', {
58
+ value: true
59
+ });
package/dist/and.d.ts CHANGED
@@ -1,19 +1,28 @@
1
1
  import { Schema } from './types.js';
2
- export interface AndInput<T, U> {
2
+ type InferSchemasTuple<T extends readonly Schema<unknown>[]> = {
3
+ [K in keyof T]: T[K] extends Schema<infer U> ? U : never;
4
+ };
5
+ type IntersectTuple<T extends readonly unknown[]> = T extends readonly [infer Head, ...infer Tail] ? Head & IntersectTuple<Tail> : unknown;
6
+ export interface AndSchemaInput<TSchemas extends readonly Schema<unknown>[]> {
7
+ name?: string;
8
+ schemas: TSchemas;
9
+ }
10
+ export interface AndLegacyInput<T, U> {
3
11
  left: Schema<T>;
4
12
  right: Schema<U>;
5
13
  name?: string;
6
14
  }
15
+ type VariadicSchemaTuple = readonly [Schema<any>, Schema<any>, ...Schema<any>[]];
7
16
  /**
8
17
  * and is part of the public LIVON API.
9
18
  *
10
19
  * @remarks
11
20
  * Parameter and return types are defined in the TypeScript signature.
12
21
  *
13
- * @see https://live-input-vector-output-node.github.io/livon-ts/docs/schema/and
22
+ * @see https://livon.tech/docs/schema/and
14
23
  *
15
24
  * @example
16
- * // Extends a base message input schema with an id field.
25
+ * // Extends a base message input schema with an id field (legacy API).
17
26
  * const messageInput = object({
18
27
  * name: 'MessageInput',
19
28
  * shape: { text: string() },
@@ -26,12 +35,29 @@ export interface AndInput<T, U> {
26
35
  * MessageWithId.parse({ text: 'Hello', id: 'm-1' });
27
36
  *
28
37
  * @example
29
- * // Uses explicit naming for generated type surfaces.
38
+ * // Uses explicit naming for generated type surfaces (legacy API).
30
39
  * const MessageWithId = and({
31
40
  * left: messageInput,
32
41
  * right: withId,
33
42
  * name: 'MessageWithId',
34
43
  * });
35
44
  * MessageWithId.parse({ text: 'Hello', id: 'm-1' });
45
+ *
46
+ * @example
47
+ * // Composes multiple schemas using the schemas array (new API).
48
+ * const MessageWithId = and({
49
+ * name: 'MessageWithId',
50
+ * schemas: [messageInput, withId],
51
+ * });
52
+ * MessageWithId.parse({ text: 'Hello', id: 'm-1' });
53
+ *
54
+ * @example
55
+ * // Composes three schemas using the schemas array.
56
+ * const MessageComplete = and({
57
+ * schemas: [messageInput, withId, withTimestamp],
58
+ * });
59
+ * MessageComplete.parse({ text: 'Hello', id: 'm-1', timestamp: Date.now() });
36
60
  */
37
- export declare const and: <T, U>({ left, right, name }: AndInput<T, U>) => Schema<T & U>;
61
+ export declare function and<TSchemas extends VariadicSchemaTuple>(input: AndSchemaInput<TSchemas>): Schema<IntersectTuple<InferSchemasTuple<TSchemas>>>;
62
+ export declare function and<T, U>(input: AndLegacyInput<T, U>): Schema<T & U>;
63
+ export {};