@livon/schema 0.27.0-rc.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 (169) hide show
  1. package/PROMPT.md +21 -0
  2. package/README.md +13 -0
  3. package/SCHEMA.md +13 -0
  4. package/dist/SchemaValidationError.cjs +41 -0
  5. package/dist/SchemaValidationError.d.ts +20 -0
  6. package/dist/SchemaValidationError.js +7 -0
  7. package/dist/SchemaValidationError.spec.cjs +65 -0
  8. package/dist/SchemaValidationError.spec.d.ts +1 -0
  9. package/dist/SchemaValidationError.spec.js +59 -0
  10. package/dist/after.cjs +36 -0
  11. package/dist/after.d.ts +30 -0
  12. package/dist/after.js +2 -0
  13. package/dist/after.spec.cjs +54 -0
  14. package/dist/after.spec.d.ts +1 -0
  15. package/dist/after.spec.js +48 -0
  16. package/dist/and.cjs +36 -0
  17. package/dist/and.d.ts +26 -0
  18. package/dist/and.js +2 -0
  19. package/dist/and.spec.cjs +57 -0
  20. package/dist/and.spec.d.ts +1 -0
  21. package/dist/and.spec.js +51 -0
  22. package/dist/api.cjs +317 -0
  23. package/dist/api.d.ts +107 -0
  24. package/dist/api.js +277 -0
  25. package/dist/api.spec.cjs +512 -0
  26. package/dist/api.spec.d.ts +1 -0
  27. package/dist/api.spec.js +506 -0
  28. package/dist/array.cjs +74 -0
  29. package/dist/array.d.ts +25 -0
  30. package/dist/array.js +40 -0
  31. package/dist/array.spec.cjs +167 -0
  32. package/dist/array.spec.d.ts +1 -0
  33. package/dist/array.spec.js +161 -0
  34. package/dist/before.cjs +36 -0
  35. package/dist/before.d.ts +30 -0
  36. package/dist/before.js +2 -0
  37. package/dist/before.spec.cjs +54 -0
  38. package/dist/before.spec.d.ts +1 -0
  39. package/dist/before.spec.js +48 -0
  40. package/dist/binary.cjs +53 -0
  41. package/dist/binary.d.ts +24 -0
  42. package/dist/binary.js +19 -0
  43. package/dist/binary.spec.cjs +107 -0
  44. package/dist/binary.spec.d.ts +1 -0
  45. package/dist/binary.spec.js +101 -0
  46. package/dist/boolean.cjs +53 -0
  47. package/dist/boolean.d.ts +24 -0
  48. package/dist/boolean.js +19 -0
  49. package/dist/boolean.spec.cjs +96 -0
  50. package/dist/boolean.spec.d.ts +1 -0
  51. package/dist/boolean.spec.js +90 -0
  52. package/dist/context.cjs +125 -0
  53. package/dist/context.d.ts +101 -0
  54. package/dist/context.js +76 -0
  55. package/dist/context.spec.cjs +244 -0
  56. package/dist/context.spec.d.ts +1 -0
  57. package/dist/context.spec.js +238 -0
  58. package/dist/date.cjs +53 -0
  59. package/dist/date.d.ts +24 -0
  60. package/dist/date.js +19 -0
  61. package/dist/date.spec.cjs +97 -0
  62. package/dist/date.spec.d.ts +1 -0
  63. package/dist/date.spec.js +91 -0
  64. package/dist/doc.cjs +54 -0
  65. package/dist/doc.d.ts +25 -0
  66. package/dist/doc.js +17 -0
  67. package/dist/doc.spec.cjs +99 -0
  68. package/dist/doc.spec.d.ts +1 -0
  69. package/dist/doc.spec.js +93 -0
  70. package/dist/enumeration.cjs +74 -0
  71. package/dist/enumeration.d.ts +50 -0
  72. package/dist/enumeration.js +40 -0
  73. package/dist/enumeration.spec.cjs +110 -0
  74. package/dist/enumeration.spec.d.ts +1 -0
  75. package/dist/enumeration.spec.js +104 -0
  76. package/dist/hydrate.cjs +18 -0
  77. package/dist/hydrate.d.ts +1 -0
  78. package/dist/hydrate.js +0 -0
  79. package/dist/index.cjs +145 -0
  80. package/dist/index.d.ts +34 -0
  81. package/dist/index.js +24 -0
  82. package/dist/index.spec.cjs +43 -0
  83. package/dist/index.spec.d.ts +1 -0
  84. package/dist/index.spec.js +37 -0
  85. package/dist/literal.cjs +55 -0
  86. package/dist/literal.d.ts +25 -0
  87. package/dist/literal.js +21 -0
  88. package/dist/literal.spec.cjs +93 -0
  89. package/dist/literal.spec.d.ts +1 -0
  90. package/dist/literal.spec.js +87 -0
  91. package/dist/number.cjs +89 -0
  92. package/dist/number.d.ts +84 -0
  93. package/dist/number.js +55 -0
  94. package/dist/number.spec.cjs +155 -0
  95. package/dist/number.spec.d.ts +1 -0
  96. package/dist/number.spec.js +149 -0
  97. package/dist/object.cjs +66 -0
  98. package/dist/object.d.ts +37 -0
  99. package/dist/object.js +32 -0
  100. package/dist/object.spec.cjs +171 -0
  101. package/dist/object.spec.d.ts +1 -0
  102. package/dist/object.spec.js +165 -0
  103. package/dist/operation.cjs +182 -0
  104. package/dist/operation.d.ts +197 -0
  105. package/dist/operation.js +133 -0
  106. package/dist/operation.spec.cjs +454 -0
  107. package/dist/operation.spec.d.ts +1 -0
  108. package/dist/operation.spec.js +448 -0
  109. package/dist/or.cjs +85 -0
  110. package/dist/or.d.ts +37 -0
  111. package/dist/or.js +51 -0
  112. package/dist/or.spec.cjs +204 -0
  113. package/dist/or.spec.d.ts +1 -0
  114. package/dist/or.spec.js +198 -0
  115. package/dist/schema.cjs +285 -0
  116. package/dist/schema.d.ts +132 -0
  117. package/dist/schema.js +233 -0
  118. package/dist/schema.spec.cjs +587 -0
  119. package/dist/schema.spec.d.ts +1 -0
  120. package/dist/schema.spec.js +581 -0
  121. package/dist/schemaFactory.cjs +125 -0
  122. package/dist/schemaFactory.d.ts +97 -0
  123. package/dist/schemaFactory.js +88 -0
  124. package/dist/schemaFactory.spec.cjs +197 -0
  125. package/dist/schemaFactory.spec.d.ts +1 -0
  126. package/dist/schemaFactory.spec.js +191 -0
  127. package/dist/schemaModule.cjs +280 -0
  128. package/dist/schemaModule.d.ts +97 -0
  129. package/dist/schemaModule.js +243 -0
  130. package/dist/schemaModule.spec.cjs +355 -0
  131. package/dist/schemaModule.spec.d.ts +1 -0
  132. package/dist/schemaModule.spec.js +349 -0
  133. package/dist/string.cjs +93 -0
  134. package/dist/string.d.ts +85 -0
  135. package/dist/string.js +59 -0
  136. package/dist/string.spec.cjs +158 -0
  137. package/dist/string.spec.d.ts +1 -0
  138. package/dist/string.spec.js +152 -0
  139. package/dist/testing/mocks/assertions.mock.cjs +48 -0
  140. package/dist/testing/mocks/assertions.mock.d.ts +5 -0
  141. package/dist/testing/mocks/assertions.mock.js +14 -0
  142. package/dist/testing/mocks/index.cjs +52 -0
  143. package/dist/testing/mocks/index.d.ts +4 -0
  144. package/dist/testing/mocks/index.js +3 -0
  145. package/dist/testing/mocks/schema.mock.cjs +120 -0
  146. package/dist/testing/mocks/schema.mock.d.ts +37 -0
  147. package/dist/testing/mocks/schema.mock.js +74 -0
  148. package/dist/tuple.cjs +58 -0
  149. package/dist/tuple.d.ts +33 -0
  150. package/dist/tuple.js +24 -0
  151. package/dist/tuple.spec.cjs +162 -0
  152. package/dist/tuple.spec.d.ts +1 -0
  153. package/dist/tuple.spec.js +156 -0
  154. package/dist/typeGuards.cjs +60 -0
  155. package/dist/typeGuards.d.ts +93 -0
  156. package/dist/typeGuards.js +8 -0
  157. package/dist/typeGuards.spec.cjs +101 -0
  158. package/dist/typeGuards.spec.d.ts +1 -0
  159. package/dist/typeGuards.spec.js +95 -0
  160. package/dist/types.cjs +18 -0
  161. package/dist/types.d.ts +289 -0
  162. package/dist/types.js +0 -0
  163. package/dist/union.cjs +74 -0
  164. package/dist/union.d.ts +33 -0
  165. package/dist/union.js +40 -0
  166. package/dist/union.spec.cjs +159 -0
  167. package/dist/union.spec.d.ts +1 -0
  168. package/dist/union.spec.js +153 -0
  169. package/package.json +47 -0
@@ -0,0 +1,50 @@
1
+ import { SchemaFactoryChainDefinition, SchemaWithChain } from './schemaFactory.js';
2
+ import type { SchemaDoc } from './types.js';
3
+ export type EnumValues = readonly [string | number, ...(string | number)[]];
4
+ /**
5
+ * Chain operation: enforces one exact enum literal.
6
+ *
7
+ * @see https://live-input-vector-output-node.github.io/livon-ts/docs/schema/enumeration
8
+ *
9
+ * @example
10
+ * // Restricts parsed values to one exact enum literal.
11
+ * enumeration('Role').values('admin', 'user').literal('admin')
12
+ */
13
+ export interface EnumLiteralChain<TValue extends string | number> {
14
+ (data: TValue): (only: TValue) => TValue;
15
+ }
16
+ /**
17
+ * Chain map for enum schemas.
18
+ *
19
+ * @see https://live-input-vector-output-node.github.io/livon-ts/docs/schema/enumeration
20
+ */
21
+ export interface EnumChainDefinition<TValue extends string | number> extends SchemaFactoryChainDefinition<TValue> {
22
+ literal: EnumLiteralChain<TValue>;
23
+ }
24
+ /**
25
+ * Factory returned by `enumeration(...)`.
26
+ *
27
+ * @see https://live-input-vector-output-node.github.io/livon-ts/docs/schema/enumeration
28
+ */
29
+ export interface EnumFactory {
30
+ values: <TValues extends EnumValues>(...values: TValues) => SchemaWithChain<TValues[number], EnumChainDefinition<TValues[number]>>;
31
+ }
32
+ /**
33
+ * enumeration is part of the public LIVON API.
34
+ *
35
+ * @remarks
36
+ * Parameter and return types are defined in the TypeScript signature.
37
+ *
38
+ * @see https://live-input-vector-output-node.github.io/livon-ts/docs/schema/enumeration
39
+ *
40
+ * @example
41
+ * // Creates an enum schema that accepts only 'admin' or 'user'.
42
+ * const Role = enumeration('Role').values('admin', 'user');
43
+ * Role.parse('admin');
44
+ *
45
+ * @example
46
+ * // Adds a chain rule so only the 'admin' enum literal is accepted.
47
+ * const AdminRole = enumeration('Role').values('admin', 'user').literal('admin');
48
+ * AdminRole.parse('admin');
49
+ */
50
+ export declare const enumeration: (name: string, doc?: SchemaDoc) => EnumFactory;
@@ -0,0 +1,40 @@
1
+ import { schemaFactory } from "./schemaFactory.js";
2
+ const enumeration = (name, doc)=>({
3
+ values: (...values)=>schemaFactory({
4
+ name: `enum:${name}`,
5
+ type: 'enum',
6
+ doc,
7
+ ast: ()=>({
8
+ type: 'enum',
9
+ name,
10
+ constraints: {
11
+ values
12
+ }
13
+ }),
14
+ validate: (input)=>{
15
+ if (!values.includes(input)) throw {
16
+ message: `Input "${String(input)}" is not valid for enum "${name}". Valid values: ${values.join(', ')}`,
17
+ code: 'enum.value',
18
+ context: {
19
+ name,
20
+ values
21
+ }
22
+ };
23
+ return input;
24
+ },
25
+ chain: {
26
+ literal: (data)=>(only)=>{
27
+ if (data !== only) throw {
28
+ message: `Input "${String(data)}" does not match literal "${String(only)}" for enum "${name}".`,
29
+ code: 'enum.literal',
30
+ context: {
31
+ name,
32
+ only
33
+ }
34
+ };
35
+ return data;
36
+ }
37
+ }
38
+ })
39
+ });
40
+ export { enumeration };
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ var __webpack_exports__ = {};
3
+ const external_vitest_namespaceObject = require("vitest");
4
+ const external_enumeration_cjs_namespaceObject = require("./enumeration.cjs");
5
+ const external_schemaFactory_cjs_namespaceObject = require("./schemaFactory.cjs");
6
+ const index_cjs_namespaceObject = require("./testing/mocks/index.cjs");
7
+ external_vitest_namespaceObject.vi.mock('./schemaFactory.js', ()=>({
8
+ schemaFactory: external_vitest_namespaceObject.vi.fn()
9
+ }));
10
+ const schemaFactoryMock = external_vitest_namespaceObject.vi.mocked(external_schemaFactory_cjs_namespaceObject.schemaFactory);
11
+ const schemaContextMock = (0, index_cjs_namespaceObject.createSchemaContextMock)();
12
+ const schemaFactoryImplementation = (0, index_cjs_namespaceObject.createSchemaFactoryMock)();
13
+ const getFactoryInput = ()=>{
14
+ const call = schemaFactoryMock.mock.calls[0];
15
+ if (!call) throw new Error('schemaFactory should be called once before reading input');
16
+ return call[0];
17
+ };
18
+ (0, external_vitest_namespaceObject.describe)('enumeration()', ()=>{
19
+ (0, external_vitest_namespaceObject.beforeAll)(()=>{
20
+ schemaFactoryMock.mockImplementation(schemaFactoryImplementation);
21
+ });
22
+ (0, external_vitest_namespaceObject.beforeEach)(()=>{
23
+ schemaFactoryMock.mockClear();
24
+ schemaFactoryImplementation.mockClear();
25
+ });
26
+ (0, external_vitest_namespaceObject.afterEach)(()=>{
27
+ schemaFactoryMock.mockClear();
28
+ });
29
+ (0, external_vitest_namespaceObject.afterAll)(()=>{
30
+ schemaFactoryMock.mockReset();
31
+ schemaFactoryImplementation.mockReset();
32
+ });
33
+ (0, external_vitest_namespaceObject.describe)('happy', ()=>{
34
+ (0, external_vitest_namespaceObject.it)('should return enum factory when enumeration is created', ()=>{
35
+ const result = (0, external_enumeration_cjs_namespaceObject.enumeration)('Role');
36
+ (0, external_vitest_namespaceObject.expect)(typeof result.values).toBe('function');
37
+ (0, external_vitest_namespaceObject.expect)(schemaFactoryMock).toHaveBeenCalledTimes(0);
38
+ });
39
+ (0, external_vitest_namespaceObject.it)('should delegate to schemaFactory when values() is called', ()=>{
40
+ const result = (0, external_enumeration_cjs_namespaceObject.enumeration)('Role', {
41
+ summary: 'enum doc'
42
+ });
43
+ const schema = result.values('user', 'admin');
44
+ (0, external_vitest_namespaceObject.expect)(schemaFactoryMock).toHaveBeenCalledTimes(1);
45
+ const factoryInput = getFactoryInput();
46
+ (0, external_vitest_namespaceObject.expect)(factoryInput.name).toBe('enum:Role');
47
+ (0, external_vitest_namespaceObject.expect)(factoryInput.type).toBe('enum');
48
+ (0, external_vitest_namespaceObject.expect)(factoryInput.doc).toEqual({
49
+ summary: 'enum doc'
50
+ });
51
+ (0, external_vitest_namespaceObject.expect)(factoryInput.ast(schemaContextMock)).toEqual({
52
+ type: 'enum',
53
+ name: 'Role',
54
+ constraints: {
55
+ values: [
56
+ 'user',
57
+ 'admin'
58
+ ]
59
+ }
60
+ });
61
+ (0, external_vitest_namespaceObject.expect)(Object.keys(factoryInput.chain)).toEqual([
62
+ 'literal'
63
+ ]);
64
+ (0, external_vitest_namespaceObject.expect)(schema).toBe(schemaFactoryMock.mock.results[0]?.value);
65
+ });
66
+ (0, external_vitest_namespaceObject.it)('should validate enum value and literal chain when values are included', ()=>{
67
+ (0, external_enumeration_cjs_namespaceObject.enumeration)('Role').values('user', 'admin');
68
+ const factoryInput = getFactoryInput();
69
+ (0, external_vitest_namespaceObject.expect)(factoryInput.validate('admin', schemaContextMock)).toBe('admin');
70
+ (0, external_vitest_namespaceObject.expect)(factoryInput.chain.literal('admin')('admin')).toBe('admin');
71
+ });
72
+ });
73
+ (0, external_vitest_namespaceObject.describe)('sad', ()=>{
74
+ (0, external_vitest_namespaceObject.it)('should throw enum.value when input is not part of values', ()=>{
75
+ (0, external_enumeration_cjs_namespaceObject.enumeration)('Role').values('user', 'admin');
76
+ const factoryInput = getFactoryInput();
77
+ const thrown = (0, index_cjs_namespaceObject.captureThrow)(()=>factoryInput.validate('guest', schemaContextMock));
78
+ (0, external_vitest_namespaceObject.expect)(thrown.threw).toBe(true);
79
+ (0, external_vitest_namespaceObject.expect)(thrown.value).toEqual({
80
+ message: 'Input "guest" is not valid for enum "Role". Valid values: user, admin',
81
+ code: 'enum.value',
82
+ context: {
83
+ name: 'Role',
84
+ values: [
85
+ 'user',
86
+ 'admin'
87
+ ]
88
+ }
89
+ });
90
+ });
91
+ (0, external_vitest_namespaceObject.it)('should throw enum.literal when literal() does not match selected value', ()=>{
92
+ (0, external_enumeration_cjs_namespaceObject.enumeration)('Role').values('user', 'admin');
93
+ const factoryInput = getFactoryInput();
94
+ const thrown = (0, index_cjs_namespaceObject.captureThrow)(()=>factoryInput.chain.literal('user')('admin'));
95
+ (0, external_vitest_namespaceObject.expect)(thrown.threw).toBe(true);
96
+ (0, external_vitest_namespaceObject.expect)(thrown.value).toEqual({
97
+ message: 'Input "user" does not match literal "admin" for enum "Role".',
98
+ code: 'enum.literal',
99
+ context: {
100
+ name: 'Role',
101
+ only: 'admin'
102
+ }
103
+ });
104
+ });
105
+ });
106
+ });
107
+ for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
108
+ Object.defineProperty(exports, '__esModule', {
109
+ value: true
110
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,104 @@
1
+ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
2
+ import { enumeration } from "./enumeration.js";
3
+ import { schemaFactory } from "./schemaFactory.js";
4
+ import { captureThrow, createSchemaContextMock, createSchemaFactoryMock } from "./testing/mocks/index.js";
5
+ vi.mock('./schemaFactory.js', ()=>({
6
+ schemaFactory: vi.fn()
7
+ }));
8
+ const schemaFactoryMock = vi.mocked(schemaFactory);
9
+ const schemaContextMock = createSchemaContextMock();
10
+ const schemaFactoryImplementation = createSchemaFactoryMock();
11
+ const getFactoryInput = ()=>{
12
+ const call = schemaFactoryMock.mock.calls[0];
13
+ if (!call) throw new Error('schemaFactory should be called once before reading input');
14
+ return call[0];
15
+ };
16
+ describe('enumeration()', ()=>{
17
+ beforeAll(()=>{
18
+ schemaFactoryMock.mockImplementation(schemaFactoryImplementation);
19
+ });
20
+ beforeEach(()=>{
21
+ schemaFactoryMock.mockClear();
22
+ schemaFactoryImplementation.mockClear();
23
+ });
24
+ afterEach(()=>{
25
+ schemaFactoryMock.mockClear();
26
+ });
27
+ afterAll(()=>{
28
+ schemaFactoryMock.mockReset();
29
+ schemaFactoryImplementation.mockReset();
30
+ });
31
+ describe('happy', ()=>{
32
+ it('should return enum factory when enumeration is created', ()=>{
33
+ const result = enumeration('Role');
34
+ expect(typeof result.values).toBe('function');
35
+ expect(schemaFactoryMock).toHaveBeenCalledTimes(0);
36
+ });
37
+ it('should delegate to schemaFactory when values() is called', ()=>{
38
+ const result = enumeration('Role', {
39
+ summary: 'enum doc'
40
+ });
41
+ const schema = result.values('user', 'admin');
42
+ expect(schemaFactoryMock).toHaveBeenCalledTimes(1);
43
+ const factoryInput = getFactoryInput();
44
+ expect(factoryInput.name).toBe('enum:Role');
45
+ expect(factoryInput.type).toBe('enum');
46
+ expect(factoryInput.doc).toEqual({
47
+ summary: 'enum doc'
48
+ });
49
+ expect(factoryInput.ast(schemaContextMock)).toEqual({
50
+ type: 'enum',
51
+ name: 'Role',
52
+ constraints: {
53
+ values: [
54
+ 'user',
55
+ 'admin'
56
+ ]
57
+ }
58
+ });
59
+ expect(Object.keys(factoryInput.chain)).toEqual([
60
+ 'literal'
61
+ ]);
62
+ expect(schema).toBe(schemaFactoryMock.mock.results[0]?.value);
63
+ });
64
+ it('should validate enum value and literal chain when values are included', ()=>{
65
+ enumeration('Role').values('user', 'admin');
66
+ const factoryInput = getFactoryInput();
67
+ expect(factoryInput.validate('admin', schemaContextMock)).toBe('admin');
68
+ expect(factoryInput.chain.literal('admin')('admin')).toBe('admin');
69
+ });
70
+ });
71
+ describe('sad', ()=>{
72
+ it('should throw enum.value when input is not part of values', ()=>{
73
+ enumeration('Role').values('user', 'admin');
74
+ const factoryInput = getFactoryInput();
75
+ const thrown = captureThrow(()=>factoryInput.validate('guest', schemaContextMock));
76
+ expect(thrown.threw).toBe(true);
77
+ expect(thrown.value).toEqual({
78
+ message: 'Input "guest" is not valid for enum "Role". Valid values: user, admin',
79
+ code: 'enum.value',
80
+ context: {
81
+ name: 'Role',
82
+ values: [
83
+ 'user',
84
+ 'admin'
85
+ ]
86
+ }
87
+ });
88
+ });
89
+ it('should throw enum.literal when literal() does not match selected value', ()=>{
90
+ enumeration('Role').values('user', 'admin');
91
+ const factoryInput = getFactoryInput();
92
+ const thrown = captureThrow(()=>factoryInput.chain.literal('user')('admin'));
93
+ expect(thrown.threw).toBe(true);
94
+ expect(thrown.value).toEqual({
95
+ message: 'Input "user" does not match literal "admin" for enum "Role".',
96
+ code: 'enum.literal',
97
+ context: {
98
+ name: 'Role',
99
+ only: 'admin'
100
+ }
101
+ });
102
+ });
103
+ });
104
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.r = (exports1)=>{
5
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
+ value: 'Module'
7
+ });
8
+ Object.defineProperty(exports1, '__esModule', {
9
+ value: true
10
+ });
11
+ };
12
+ })();
13
+ var __webpack_exports__ = {};
14
+ __webpack_require__.r(__webpack_exports__);
15
+ for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
16
+ Object.defineProperty(exports, '__esModule', {
17
+ value: true
18
+ });
@@ -0,0 +1 @@
1
+ export {};
File without changes
package/dist/index.cjs ADDED
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
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
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
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
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ enumeration: ()=>external_enumeration_cjs_namespaceObject.enumeration,
28
+ createSchemaContext: ()=>external_context_cjs_namespaceObject.createSchemaContext,
29
+ binary: ()=>external_binary_cjs_namespaceObject.binary,
30
+ runFieldOperation: ()=>external_operation_cjs_namespaceObject.runFieldOperation,
31
+ string: ()=>external_string_cjs_namespaceObject.string,
32
+ date: ()=>external_date_cjs_namespaceObject.date,
33
+ object: ()=>external_object_cjs_namespaceObject.object,
34
+ runOperation: ()=>external_operation_cjs_namespaceObject.runOperation,
35
+ mergeDoc: ()=>external_doc_cjs_namespaceObject.mergeDoc,
36
+ createSchemaValidationError: ()=>external_SchemaValidationError_cjs_namespaceObject.createSchemaValidationError,
37
+ boolean: ()=>external_boolean_cjs_namespaceObject.boolean,
38
+ subscription: ()=>external_api_cjs_namespaceObject.subscription,
39
+ union: ()=>external_union_cjs_namespaceObject.union,
40
+ after: ()=>external_after_cjs_namespaceObject.after,
41
+ api: ()=>external_api_cjs_namespaceObject.api,
42
+ tuple: ()=>external_tuple_cjs_namespaceObject.tuple,
43
+ schemaModule: ()=>external_schemaModule_cjs_namespaceObject.schemaModule,
44
+ array: ()=>external_array_cjs_namespaceObject.array,
45
+ normalizeDoc: ()=>external_doc_cjs_namespaceObject.normalizeDoc,
46
+ schemaFactory: ()=>external_schemaFactory_cjs_namespaceObject.schemaFactory,
47
+ composeApi: ()=>external_api_cjs_namespaceObject.composeApi,
48
+ or: ()=>external_or_cjs_namespaceObject.or,
49
+ and: ()=>external_and_cjs_namespaceObject.and,
50
+ before: ()=>external_before_cjs_namespaceObject.before,
51
+ typeGuards: ()=>external_typeGuards_cjs_namespaceObject,
52
+ literal: ()=>external_literal_cjs_namespaceObject.literal,
53
+ fieldOperation: ()=>external_operation_cjs_namespaceObject.fieldOperation,
54
+ number: ()=>external_number_cjs_namespaceObject.number,
55
+ operation: ()=>external_operation_cjs_namespaceObject.operation,
56
+ createSchemaModuleInput: ()=>external_schemaModule_cjs_namespaceObject.createSchemaModuleInput
57
+ });
58
+ const external_SchemaValidationError_cjs_namespaceObject = require("./SchemaValidationError.cjs");
59
+ const external_schemaFactory_cjs_namespaceObject = require("./schemaFactory.cjs");
60
+ const external_typeGuards_cjs_namespaceObject = require("./typeGuards.cjs");
61
+ const external_string_cjs_namespaceObject = require("./string.cjs");
62
+ const external_number_cjs_namespaceObject = require("./number.cjs");
63
+ const external_boolean_cjs_namespaceObject = require("./boolean.cjs");
64
+ const external_date_cjs_namespaceObject = require("./date.cjs");
65
+ const external_enumeration_cjs_namespaceObject = require("./enumeration.cjs");
66
+ const external_array_cjs_namespaceObject = require("./array.cjs");
67
+ const external_object_cjs_namespaceObject = require("./object.cjs");
68
+ const external_union_cjs_namespaceObject = require("./union.cjs");
69
+ const external_or_cjs_namespaceObject = require("./or.cjs");
70
+ const external_tuple_cjs_namespaceObject = require("./tuple.cjs");
71
+ const external_literal_cjs_namespaceObject = require("./literal.cjs");
72
+ const external_binary_cjs_namespaceObject = require("./binary.cjs");
73
+ const external_api_cjs_namespaceObject = require("./api.cjs");
74
+ const external_operation_cjs_namespaceObject = require("./operation.cjs");
75
+ const external_before_cjs_namespaceObject = require("./before.cjs");
76
+ const external_after_cjs_namespaceObject = require("./after.cjs");
77
+ const external_and_cjs_namespaceObject = require("./and.cjs");
78
+ const external_context_cjs_namespaceObject = require("./context.cjs");
79
+ const external_schemaModule_cjs_namespaceObject = require("./schemaModule.cjs");
80
+ const external_doc_cjs_namespaceObject = require("./doc.cjs");
81
+ exports.after = __webpack_exports__.after;
82
+ exports.and = __webpack_exports__.and;
83
+ exports.api = __webpack_exports__.api;
84
+ exports.array = __webpack_exports__.array;
85
+ exports.before = __webpack_exports__.before;
86
+ exports.binary = __webpack_exports__.binary;
87
+ exports.boolean = __webpack_exports__.boolean;
88
+ exports.composeApi = __webpack_exports__.composeApi;
89
+ exports.createSchemaContext = __webpack_exports__.createSchemaContext;
90
+ exports.createSchemaModuleInput = __webpack_exports__.createSchemaModuleInput;
91
+ exports.createSchemaValidationError = __webpack_exports__.createSchemaValidationError;
92
+ exports.date = __webpack_exports__.date;
93
+ exports.enumeration = __webpack_exports__.enumeration;
94
+ exports.fieldOperation = __webpack_exports__.fieldOperation;
95
+ exports.literal = __webpack_exports__.literal;
96
+ exports.mergeDoc = __webpack_exports__.mergeDoc;
97
+ exports.normalizeDoc = __webpack_exports__.normalizeDoc;
98
+ exports.number = __webpack_exports__.number;
99
+ exports.object = __webpack_exports__.object;
100
+ exports.operation = __webpack_exports__.operation;
101
+ exports.or = __webpack_exports__.or;
102
+ exports.runFieldOperation = __webpack_exports__.runFieldOperation;
103
+ exports.runOperation = __webpack_exports__.runOperation;
104
+ exports.schemaFactory = __webpack_exports__.schemaFactory;
105
+ exports.schemaModule = __webpack_exports__.schemaModule;
106
+ exports.string = __webpack_exports__.string;
107
+ exports.subscription = __webpack_exports__.subscription;
108
+ exports.tuple = __webpack_exports__.tuple;
109
+ exports.typeGuards = __webpack_exports__.typeGuards;
110
+ exports.union = __webpack_exports__.union;
111
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
112
+ "after",
113
+ "and",
114
+ "api",
115
+ "array",
116
+ "before",
117
+ "binary",
118
+ "boolean",
119
+ "composeApi",
120
+ "createSchemaContext",
121
+ "createSchemaModuleInput",
122
+ "createSchemaValidationError",
123
+ "date",
124
+ "enumeration",
125
+ "fieldOperation",
126
+ "literal",
127
+ "mergeDoc",
128
+ "normalizeDoc",
129
+ "number",
130
+ "object",
131
+ "operation",
132
+ "or",
133
+ "runFieldOperation",
134
+ "runOperation",
135
+ "schemaFactory",
136
+ "schemaModule",
137
+ "string",
138
+ "subscription",
139
+ "tuple",
140
+ "typeGuards",
141
+ "union"
142
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
143
+ Object.defineProperty(exports, '__esModule', {
144
+ value: true
145
+ });
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Public package entrypoint for `@livon/schema`.
3
+ *
4
+ * @see https://live-input-vector-output-node.github.io/livon-ts/docs/packages/schema
5
+ */
6
+ export { createSchemaValidationError } from './SchemaValidationError.js';
7
+ export type { SchemaValidationError } from './SchemaValidationError.js';
8
+ export { schemaFactory } from './schemaFactory.js';
9
+ export type { SchemaWithChain, SchemaFactoryChainDefinition } from './schemaFactory.js';
10
+ export * as typeGuards from './typeGuards.js';
11
+ export { string } from './string.js';
12
+ export { number } from './number.js';
13
+ export { boolean } from './boolean.js';
14
+ export { date } from './date.js';
15
+ export { enumeration } from './enumeration.js';
16
+ export { array } from './array.js';
17
+ export { object } from './object.js';
18
+ export { union } from './union.js';
19
+ export { or } from './or.js';
20
+ export { tuple } from './tuple.js';
21
+ export { literal } from './literal.js';
22
+ export { binary } from './binary.js';
23
+ export { api, composeApi, subscription } from './api.js';
24
+ export type { Api, ApiFieldShape, ApiShape, Subscription, SubscriptionShape, SubscriptionInput, SubscriptionFilter, SubscriptionExecutor, } from './api.js';
25
+ export { fieldOperation, operation, runFieldOperation, runOperation } from './operation.js';
26
+ export type { Operation, FieldOperation, OperationRooms } from './operation.js';
27
+ export { before } from './before.js';
28
+ export { after } from './after.js';
29
+ export { and } from './and.js';
30
+ export { createSchemaContext } from './context.js';
31
+ export { schemaModule, createSchemaModuleInput } from './schemaModule.js';
32
+ export { normalizeDoc, mergeDoc } from './doc.js';
33
+ export type { Schema, SchemaIssue, SchemaResult, SchemaBuildContext, SchemaBuildContextInput, SchemaRequestContext, SchemaRequestContextInput, SchemaContext, Publisher, PublishInput, Shape, Infer, AstNode, SchemaDoc, AstBuilder, Logger, PublishAck, AckConfig, AckMode, } from './types.js';
34
+ export type { SchemaModuleInput, SchemaModuleLike, SchemaModuleOptions, SchemaModuleDecoder, SchemaModuleEncoder, SchemaModuleGetRequestContext, SchemaModuleNow, } from './schemaModule.js';
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ import { createSchemaValidationError } from "./SchemaValidationError.js";
2
+ import { schemaFactory } from "./schemaFactory.js";
3
+ import { string } from "./string.js";
4
+ import { number } from "./number.js";
5
+ import { boolean as external_boolean_js_boolean } from "./boolean.js";
6
+ import { date } from "./date.js";
7
+ import { enumeration } from "./enumeration.js";
8
+ import { array } from "./array.js";
9
+ import { object } from "./object.js";
10
+ import { union } from "./union.js";
11
+ import { or } from "./or.js";
12
+ import { tuple } from "./tuple.js";
13
+ import { literal } from "./literal.js";
14
+ import { binary } from "./binary.js";
15
+ import { api, composeApi, subscription } from "./api.js";
16
+ import { fieldOperation, operation, runFieldOperation, runOperation } from "./operation.js";
17
+ import { before } from "./before.js";
18
+ import { after } from "./after.js";
19
+ import { and } from "./and.js";
20
+ import { createSchemaContext } from "./context.js";
21
+ import { createSchemaModuleInput, schemaModule } from "./schemaModule.js";
22
+ import { mergeDoc, normalizeDoc } from "./doc.js";
23
+ import * as __rspack_external__typeGuards_js_2b25dd2c from "./typeGuards.js";
24
+ export { after, and, api, array, before, binary, external_boolean_js_boolean as boolean, composeApi, createSchemaContext, createSchemaModuleInput, createSchemaValidationError, date, enumeration, fieldOperation, literal, mergeDoc, normalizeDoc, number, object, operation, or, runFieldOperation, runOperation, schemaFactory, schemaModule, string, subscription, tuple, __rspack_external__typeGuards_js_2b25dd2c as typeGuards, union };
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __webpack_exports__ = {};
3
+ const external_vitest_namespaceObject = require("vitest");
4
+ const external_index_cjs_namespaceObject = require("./index.cjs");
5
+ (0, external_vitest_namespaceObject.describe)('index exports', ()=>{
6
+ (0, external_vitest_namespaceObject.beforeAll)(()=>{});
7
+ (0, external_vitest_namespaceObject.beforeEach)(()=>{});
8
+ (0, external_vitest_namespaceObject.afterEach)(()=>{});
9
+ (0, external_vitest_namespaceObject.afterAll)(()=>{});
10
+ (0, external_vitest_namespaceObject.describe)('happy', ()=>{
11
+ (0, external_vitest_namespaceObject.it)('should expose schema builder functions when package entrypoint is imported', ()=>{
12
+ (0, external_vitest_namespaceObject.expect)(typeof external_index_cjs_namespaceObject.string).toBe('function');
13
+ (0, external_vitest_namespaceObject.expect)(typeof external_index_cjs_namespaceObject.number).toBe('function');
14
+ (0, external_vitest_namespaceObject.expect)(typeof external_index_cjs_namespaceObject.object).toBe('function');
15
+ (0, external_vitest_namespaceObject.expect)(typeof external_index_cjs_namespaceObject.array).toBe('function');
16
+ (0, external_vitest_namespaceObject.expect)(typeof external_index_cjs_namespaceObject.union).toBe('function');
17
+ (0, external_vitest_namespaceObject.expect)(typeof external_index_cjs_namespaceObject.or).toBe('function');
18
+ (0, external_vitest_namespaceObject.expect)(typeof external_index_cjs_namespaceObject.tuple).toBe('function');
19
+ (0, external_vitest_namespaceObject.expect)(typeof external_index_cjs_namespaceObject.literal).toBe('function');
20
+ (0, external_vitest_namespaceObject.expect)(typeof external_index_cjs_namespaceObject.binary).toBe('function');
21
+ });
22
+ (0, external_vitest_namespaceObject.it)('should expose api and runtime integration helpers when package entrypoint is imported', ()=>{
23
+ (0, external_vitest_namespaceObject.expect)(typeof external_index_cjs_namespaceObject.api).toBe('function');
24
+ (0, external_vitest_namespaceObject.expect)(typeof external_index_cjs_namespaceObject.composeApi).toBe('function');
25
+ (0, external_vitest_namespaceObject.expect)(typeof external_index_cjs_namespaceObject.subscription).toBe('function');
26
+ (0, external_vitest_namespaceObject.expect)(typeof external_index_cjs_namespaceObject.operation).toBe('function');
27
+ (0, external_vitest_namespaceObject.expect)(typeof external_index_cjs_namespaceObject.fieldOperation).toBe('function');
28
+ (0, external_vitest_namespaceObject.expect)(typeof external_index_cjs_namespaceObject.schemaModule).toBe('function');
29
+ (0, external_vitest_namespaceObject.expect)(typeof external_index_cjs_namespaceObject.createSchemaModuleInput).toBe('function');
30
+ });
31
+ });
32
+ (0, external_vitest_namespaceObject.describe)('sad', ()=>{
33
+ (0, external_vitest_namespaceObject.it)('should keep typeGuards namespace defined when package entrypoint is imported', ()=>{
34
+ (0, external_vitest_namespaceObject.expect)(external_index_cjs_namespaceObject.typeGuards).toBeDefined();
35
+ (0, external_vitest_namespaceObject.expect)(typeof external_index_cjs_namespaceObject.typeGuards.isString).toBe('function');
36
+ (0, external_vitest_namespaceObject.expect)(typeof external_index_cjs_namespaceObject.typeGuards.isRecord).toBe('function');
37
+ });
38
+ });
39
+ });
40
+ for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
41
+ Object.defineProperty(exports, '__esModule', {
42
+ value: true
43
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
1
+ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
2
+ import { api, array, binary, composeApi, createSchemaModuleInput, fieldOperation, literal, number, object, operation, or, schemaModule, string, subscription, tuple, typeGuards, union } from "./index.js";
3
+ describe('index exports', ()=>{
4
+ beforeAll(()=>{});
5
+ beforeEach(()=>{});
6
+ afterEach(()=>{});
7
+ afterAll(()=>{});
8
+ describe('happy', ()=>{
9
+ it('should expose schema builder functions when package entrypoint is imported', ()=>{
10
+ expect(typeof string).toBe('function');
11
+ expect(typeof number).toBe('function');
12
+ expect(typeof object).toBe('function');
13
+ expect(typeof array).toBe('function');
14
+ expect(typeof union).toBe('function');
15
+ expect(typeof or).toBe('function');
16
+ expect(typeof tuple).toBe('function');
17
+ expect(typeof literal).toBe('function');
18
+ expect(typeof binary).toBe('function');
19
+ });
20
+ it('should expose api and runtime integration helpers when package entrypoint is imported', ()=>{
21
+ expect(typeof api).toBe('function');
22
+ expect(typeof composeApi).toBe('function');
23
+ expect(typeof subscription).toBe('function');
24
+ expect(typeof operation).toBe('function');
25
+ expect(typeof fieldOperation).toBe('function');
26
+ expect(typeof schemaModule).toBe('function');
27
+ expect(typeof createSchemaModuleInput).toBe('function');
28
+ });
29
+ });
30
+ describe('sad', ()=>{
31
+ it('should keep typeGuards namespace defined when package entrypoint is imported', ()=>{
32
+ expect(typeGuards).toBeDefined();
33
+ expect(typeof typeGuards.isString).toBe('function');
34
+ expect(typeof typeGuards.isRecord).toBe('function');
35
+ });
36
+ });
37
+ });