@livon/schema 0.27.0-rc.2 → 0.27.0-rc.5
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/LICENCE.md +21 -0
- package/README.md +153 -8
- package/dist/SchemaValidationError.cjs +64 -1
- package/dist/SchemaValidationError.js +20 -1
- package/dist/after.cjs +72 -1
- package/dist/after.js +28 -1
- package/dist/and.cjs +80 -1
- package/dist/and.d.ts +20 -9
- package/dist/and.js +36 -1
- package/dist/api.cjs +386 -1
- package/dist/api.js +335 -1
- package/dist/array.cjs +115 -1
- package/dist/array.js +68 -1
- package/dist/before.cjs +72 -1
- package/dist/before.js +28 -1
- package/dist/binary.cjs +94 -1
- package/dist/binary.js +47 -1
- package/dist/boolean.cjs +94 -1
- package/dist/boolean.js +47 -1
- package/dist/combinatorName.cjs +63 -0
- package/dist/combinatorName.d.ts +8 -0
- package/dist/combinatorName.js +19 -0
- package/dist/context.cjs +197 -1
- package/dist/context.js +143 -1
- package/dist/date.cjs +94 -1
- package/dist/date.js +47 -1
- package/dist/doc.cjs +99 -1
- package/dist/doc.js +53 -1
- package/dist/enumeration.cjs +115 -1
- package/dist/enumeration.js +67 -1
- package/dist/hydrate.cjs +29 -1
- package/dist/hydrate.js +4 -0
- package/dist/index.cjs +182 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +100 -1
- package/dist/literal.cjs +94 -1
- package/dist/literal.js +46 -1
- package/dist/mini/SchemaValidationError.cjs +1 -0
- package/dist/mini/SchemaValidationError.d.ts +20 -0
- package/dist/mini/SchemaValidationError.js +1 -0
- package/dist/mini/after.cjs +1 -0
- package/dist/mini/after.d.ts +30 -0
- package/dist/mini/after.js +1 -0
- package/dist/mini/and.cjs +1 -0
- package/dist/mini/and.d.ts +37 -0
- package/dist/mini/and.js +1 -0
- package/dist/mini/api.cjs +1 -0
- package/dist/mini/api.d.ts +107 -0
- package/dist/mini/api.js +1 -0
- package/dist/mini/array.cjs +1 -0
- package/dist/mini/array.d.ts +25 -0
- package/dist/mini/array.js +1 -0
- package/dist/mini/before.cjs +1 -0
- package/dist/mini/before.d.ts +30 -0
- package/dist/mini/before.js +1 -0
- package/dist/mini/binary.cjs +1 -0
- package/dist/mini/binary.d.ts +24 -0
- package/dist/mini/binary.js +1 -0
- package/dist/mini/boolean.cjs +1 -0
- package/dist/mini/boolean.d.ts +24 -0
- package/dist/mini/boolean.js +1 -0
- package/dist/mini/combinatorName.cjs +1 -0
- package/dist/mini/combinatorName.d.ts +8 -0
- package/dist/mini/combinatorName.js +1 -0
- package/dist/mini/context.cjs +1 -0
- package/dist/mini/context.d.ts +101 -0
- package/dist/mini/context.js +1 -0
- package/dist/mini/date.cjs +1 -0
- package/dist/mini/date.d.ts +24 -0
- package/dist/mini/date.js +1 -0
- package/dist/mini/doc.cjs +1 -0
- package/dist/mini/doc.d.ts +25 -0
- package/dist/mini/doc.js +1 -0
- package/dist/mini/enumeration.cjs +1 -0
- package/dist/mini/enumeration.d.ts +50 -0
- package/dist/mini/enumeration.js +1 -0
- package/dist/mini/hydrate.cjs +1 -0
- package/dist/mini/hydrate.d.ts +1 -0
- package/dist/mini/hydrate.js +0 -0
- package/dist/mini/index.cjs +1 -0
- package/dist/mini/index.d.ts +34 -0
- package/dist/mini/index.js +1 -0
- package/dist/mini/literal.cjs +1 -0
- package/dist/mini/literal.d.ts +25 -0
- package/dist/mini/literal.js +1 -0
- package/dist/mini/number.cjs +1 -0
- package/dist/mini/number.d.ts +84 -0
- package/dist/mini/number.js +1 -0
- package/dist/mini/object.cjs +1 -0
- package/dist/mini/object.d.ts +37 -0
- package/dist/mini/object.js +1 -0
- package/dist/mini/operation.cjs +1 -0
- package/dist/mini/operation.d.ts +197 -0
- package/dist/mini/operation.js +1 -0
- package/dist/mini/or.cjs +1 -0
- package/dist/mini/or.d.ts +36 -0
- package/dist/mini/or.js +1 -0
- package/dist/mini/schema.cjs +1 -0
- package/dist/mini/schema.d.ts +132 -0
- package/dist/mini/schema.js +1 -0
- package/dist/mini/schemaFactory.cjs +1 -0
- package/dist/mini/schemaFactory.d.ts +97 -0
- package/dist/mini/schemaFactory.js +1 -0
- package/dist/mini/schemaModule.cjs +1 -0
- package/dist/mini/schemaModule.d.ts +80 -0
- package/dist/mini/schemaModule.js +1 -0
- package/dist/mini/string.cjs +1 -0
- package/dist/mini/string.d.ts +85 -0
- package/dist/mini/string.js +1 -0
- package/dist/mini/tuple.cjs +1 -0
- package/dist/mini/tuple.d.ts +33 -0
- package/dist/mini/tuple.js +1 -0
- package/dist/mini/typeGuards.cjs +1 -0
- package/dist/mini/typeGuards.d.ts +93 -0
- package/dist/mini/typeGuards.js +1 -0
- package/dist/mini/types.cjs +1 -0
- package/dist/mini/types.d.ts +293 -0
- package/dist/mini/types.js +0 -0
- package/dist/mini/union.cjs +1 -0
- package/dist/mini/union.d.ts +30 -0
- package/dist/mini/union.js +1 -0
- package/dist/number.cjs +138 -1
- package/dist/number.js +91 -1
- package/dist/object.cjs +118 -1
- package/dist/object.js +71 -1
- package/dist/operation.cjs +260 -1
- package/dist/operation.js +203 -1
- package/dist/or.cjs +141 -1
- package/dist/or.d.ts +1 -2
- package/dist/or.js +94 -1
- package/dist/schema.cjs +394 -1
- package/dist/schema.js +336 -1
- package/dist/schemaFactory.cjs +170 -1
- package/dist/schemaFactory.js +121 -1
- package/dist/schemaModule.cjs +344 -1
- package/dist/schemaModule.d.ts +2 -19
- package/dist/schemaModule.js +298 -1
- package/dist/string.cjs +142 -1
- package/dist/string.js +95 -1
- package/dist/tuple.cjs +105 -1
- package/dist/tuple.js +58 -1
- package/dist/typeGuards.cjs +137 -1
- package/dist/typeGuards.js +81 -1
- package/dist/types.cjs +29 -1
- package/dist/types.d.ts +5 -1
- package/dist/types.js +4 -0
- package/dist/union.cjs +57 -1
- package/dist/union.d.ts +5 -8
- package/dist/union.js +9 -1
- package/package.json +13 -6
package/LICENCE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LIVON contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,13 +1,158 @@
|
|
|
1
|
-
# @livon/schema
|
|
1
|
+
# @livon/schema
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Install
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
```sh
|
|
6
|
+
pnpm add @livon/schema
|
|
7
|
+
```
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
## Purpose
|
|
9
10
|
|
|
10
|
-
-
|
|
11
|
-
- `website/docs/schema/index.md`
|
|
11
|
+
[@livon/schema](https://live-input-vector-output-node.github.io/livon-ts/docs/packages/schema) defines:
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
- [value schemas](https://live-input-vector-output-node.github.io/livon-ts/docs/schema) (`string`, `number`, `object`, `array`, `or`, `union`, ...)
|
|
14
|
+
- operation schemas
|
|
15
|
+
- subscription schemas
|
|
16
|
+
- [schema runtime module](https://live-input-vector-output-node.github.io/livon-ts/docs/technical/runtime-design) (`schemaModule`)
|
|
17
|
+
|
|
18
|
+
## Schema API docs
|
|
19
|
+
|
|
20
|
+
Each schema/combinator has its own usage page:
|
|
21
|
+
|
|
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)
|
|
46
|
+
|
|
47
|
+
## Type safety model
|
|
48
|
+
|
|
49
|
+
LIVON [schemas](https://live-input-vector-output-node.github.io/livon-ts/docs/schema) are both runtime validators and type sources.
|
|
50
|
+
Primitive schema names are optional, so `string()` and `number()` are valid defaults.
|
|
51
|
+
|
|
52
|
+
1. Define payload shape once in [schema](https://live-input-vector-output-node.github.io/livon-ts/docs/schema).
|
|
53
|
+
2. Validate unknown input with `parse()`.
|
|
54
|
+
3. Reuse schema entrypoint with `typed()`.
|
|
55
|
+
4. Derive types with `Infer` instead of hand-written payload interfaces.
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import {object, string, number, type Infer} from '@livon/schema';
|
|
59
|
+
|
|
60
|
+
const User = object({
|
|
61
|
+
name: 'User',
|
|
62
|
+
shape: {
|
|
63
|
+
id: string(),
|
|
64
|
+
age: number().int().min(0),
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
type UserType = Infer<typeof User>;
|
|
69
|
+
|
|
70
|
+
const input: unknown = JSON.parse(raw);
|
|
71
|
+
const parsed = User.parse(input);
|
|
72
|
+
const typedInput: UserType = {id: 'u-1', age: 21};
|
|
73
|
+
const typed = User.typed(typedInput);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Parameters in this example
|
|
77
|
+
|
|
78
|
+
`object({...})`:
|
|
79
|
+
|
|
80
|
+
- `name` (`string`): schema node name.
|
|
81
|
+
- `shape` (`Record<string, Schema>`): field schema map.
|
|
82
|
+
|
|
83
|
+
`number().int().min(0)`:
|
|
84
|
+
|
|
85
|
+
- `min` (`number`): minimum allowed numeric value.
|
|
86
|
+
|
|
87
|
+
`User.parse(input)`:
|
|
88
|
+
|
|
89
|
+
- `input` (`unknown`): runtime value to validate/parse.
|
|
90
|
+
|
|
91
|
+
`User.typed(typedInput)`:
|
|
92
|
+
|
|
93
|
+
- `typedInput` (`UserType`): pretyped value using same schema entrypoint.
|
|
94
|
+
|
|
95
|
+
## Compose API schema
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
import {api} from '@livon/schema';
|
|
99
|
+
|
|
100
|
+
const apiSchema = api({
|
|
101
|
+
type: User,
|
|
102
|
+
operations: {
|
|
103
|
+
sendMessage,
|
|
104
|
+
},
|
|
105
|
+
subscriptions: {
|
|
106
|
+
onMessage,
|
|
107
|
+
},
|
|
108
|
+
fieldOperations: {
|
|
109
|
+
greeting: userGreetingResolver,
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
export const serverSchema = apiSchema;
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Parameters in this example
|
|
117
|
+
|
|
118
|
+
`api({...})`:
|
|
119
|
+
|
|
120
|
+
- `type` (`Schema`, optional): entity schema for field operations.
|
|
121
|
+
- `operations` (`Record<string, Operation>`, optional): request/response operations.
|
|
122
|
+
- `subscriptions` (`Record<string, Subscription | Schema>`, optional): publish topic schemas.
|
|
123
|
+
- `fieldOperations` (`Record<string, FieldOperation>`, optional): field-level resolvers.
|
|
124
|
+
|
|
125
|
+
For focused usage patterns:
|
|
126
|
+
|
|
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)
|
|
131
|
+
|
|
132
|
+
## Mount schema module into runtime
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
import {runtime} from '@livon/runtime';
|
|
136
|
+
import {schemaModule} from '@livon/schema';
|
|
137
|
+
|
|
138
|
+
runtime(schemaModule(serverSchema, {explain: true}));
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Parameters in this example
|
|
142
|
+
|
|
143
|
+
`schemaModule(serverSchema, options?)`:
|
|
144
|
+
|
|
145
|
+
- `serverSchema` (`Api | ComposedApi`): fully composed schema from `api(...)` or `composeApi(...)`.
|
|
146
|
+
- `options.explain` (`boolean`, optional): enables `$explain` endpoint for AST/checksum metadata.
|
|
147
|
+
|
|
148
|
+
## Explain endpoint
|
|
149
|
+
|
|
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.
|
|
151
|
+
|
|
152
|
+
## Related pages
|
|
153
|
+
|
|
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)
|
|
@@ -1 +1,64 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
+
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
|
+
};
|
|
21
|
+
})();
|
|
22
|
+
// webpack/runtime/has_own_property
|
|
23
|
+
(() => {
|
|
24
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
25
|
+
})();
|
|
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
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __webpack_exports__ = {};
|
|
37
|
+
__webpack_require__.r(__webpack_exports__);
|
|
38
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
39
|
+
createSchemaValidationError: () => (createSchemaValidationError)
|
|
40
|
+
});
|
|
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 })=>{
|
|
52
|
+
const error = new Error('Schema validation failed');
|
|
53
|
+
error.issues = issues;
|
|
54
|
+
error.meta = meta;
|
|
55
|
+
return error;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
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 });
|
|
@@ -1 +1,20 @@
|
|
|
1
|
-
|
|
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 })=>{
|
|
14
|
+
const error = new Error('Schema validation failed');
|
|
15
|
+
error.issues = issues;
|
|
16
|
+
error.meta = meta;
|
|
17
|
+
return error;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { createSchemaValidationError };
|
package/dist/after.cjs
CHANGED
|
@@ -1 +1,72 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
+
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
|
+
};
|
|
21
|
+
})();
|
|
22
|
+
// webpack/runtime/has_own_property
|
|
23
|
+
(() => {
|
|
24
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
25
|
+
})();
|
|
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
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __webpack_exports__ = {};
|
|
37
|
+
__webpack_require__.r(__webpack_exports__);
|
|
38
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
39
|
+
after: () => (after)
|
|
40
|
+
});
|
|
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
|
+
|
|
66
|
+
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 });
|
package/dist/after.js
CHANGED
|
@@ -1 +1,28 @@
|
|
|
1
|
-
|
|
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
|
+
|
|
28
|
+
export { after };
|
package/dist/and.cjs
CHANGED
|
@@ -1 +1,80 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
+
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
|
+
};
|
|
21
|
+
})();
|
|
22
|
+
// webpack/runtime/has_own_property
|
|
23
|
+
(() => {
|
|
24
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
25
|
+
})();
|
|
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
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __webpack_exports__ = {};
|
|
37
|
+
__webpack_require__.r(__webpack_exports__);
|
|
38
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
39
|
+
and: () => (and)
|
|
40
|
+
});
|
|
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
|
|
72
|
+
});
|
|
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
|
+
}
|
|
79
|
+
}
|
|
80
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
package/dist/and.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Schema } from './types.js';
|
|
|
2
2
|
export interface AndInput<T, U> {
|
|
3
3
|
left: Schema<T>;
|
|
4
4
|
right: Schema<U>;
|
|
5
|
+
name?: string;
|
|
5
6
|
}
|
|
6
7
|
/**
|
|
7
8
|
* and is part of the public LIVON API.
|
|
@@ -12,15 +13,25 @@ export interface AndInput<T, U> {
|
|
|
12
13
|
* @see https://live-input-vector-output-node.github.io/livon-ts/docs/schema/and
|
|
13
14
|
*
|
|
14
15
|
* @example
|
|
15
|
-
* //
|
|
16
|
-
* const
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
16
|
+
* // Extends a base message input schema with an id field.
|
|
17
|
+
* const messageInput = object({
|
|
18
|
+
* name: 'MessageInput',
|
|
19
|
+
* shape: { text: string() },
|
|
20
|
+
* });
|
|
21
|
+
* const withId = object({
|
|
22
|
+
* name: 'WithId',
|
|
23
|
+
* shape: { id: string() },
|
|
24
|
+
* });
|
|
25
|
+
* const MessageWithId = and({ left: messageInput, right: withId });
|
|
26
|
+
* MessageWithId.parse({ text: 'Hello', id: 'm-1' });
|
|
20
27
|
*
|
|
21
28
|
* @example
|
|
22
|
-
* //
|
|
23
|
-
* const
|
|
24
|
-
*
|
|
29
|
+
* // Uses explicit naming for generated type surfaces.
|
|
30
|
+
* const MessageWithId = and({
|
|
31
|
+
* left: messageInput,
|
|
32
|
+
* right: withId,
|
|
33
|
+
* name: 'MessageWithId',
|
|
34
|
+
* });
|
|
35
|
+
* MessageWithId.parse({ text: 'Hello', id: 'm-1' });
|
|
25
36
|
*/
|
|
26
|
-
export declare const and: <T, U>({ left, right }: AndInput<T, U>) => Schema<T & U>;
|
|
37
|
+
export declare const and: <T, U>({ left, right, name }: AndInput<T, U>) => Schema<T & U>;
|
package/dist/and.js
CHANGED
|
@@ -1 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
;// CONCATENATED MODULE: ./src/and.ts
|
|
3
|
+
/**
|
|
4
|
+
* and 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/and
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Extends a base message input schema with an id field.
|
|
13
|
+
* const messageInput = object({
|
|
14
|
+
* name: 'MessageInput',
|
|
15
|
+
* shape: { text: string() },
|
|
16
|
+
* });
|
|
17
|
+
* const withId = object({
|
|
18
|
+
* name: 'WithId',
|
|
19
|
+
* shape: { id: string() },
|
|
20
|
+
* });
|
|
21
|
+
* const MessageWithId = and({ left: messageInput, right: withId });
|
|
22
|
+
* MessageWithId.parse({ text: 'Hello', id: 'm-1' });
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Uses explicit naming for generated type surfaces.
|
|
26
|
+
* const MessageWithId = and({
|
|
27
|
+
* left: messageInput,
|
|
28
|
+
* right: withId,
|
|
29
|
+
* name: 'MessageWithId',
|
|
30
|
+
* });
|
|
31
|
+
* MessageWithId.parse({ text: 'Hello', id: 'm-1' });
|
|
32
|
+
*/ const and = ({ left, right, name })=>name === undefined ? left.and(right) : left.and(right, {
|
|
33
|
+
name
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export { and };
|