@predictorsdk/client 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/README.md +1 -1
  2. package/dist/Client.d.ts +20 -0
  3. package/dist/Client.js +164 -7
  4. package/dist/api/client/requests/GetBinanceCryptoPricesRequest.d.ts +18 -0
  5. package/dist/api/client/requests/GetBinanceCryptoPricesRequest.js +2 -0
  6. package/dist/api/client/requests/GetSportsMatchingMarketsRequest.d.ts +4 -4
  7. package/dist/api/client/requests/index.d.ts +1 -0
  8. package/dist/api/errors/BadGatewayError.d.ts +6 -0
  9. package/dist/api/errors/BadGatewayError.js +17 -0
  10. package/dist/api/errors/index.d.ts +1 -0
  11. package/dist/api/errors/index.js +1 -0
  12. package/dist/api/types/CryptoPriceItem.d.ts +8 -0
  13. package/dist/api/types/CryptoPriceItem.js +2 -0
  14. package/dist/api/types/CryptoPricesResponse.d.ts +8 -0
  15. package/dist/api/types/CryptoPricesResponse.js +2 -0
  16. package/dist/api/types/ErrorResponse.d.ts +3 -1
  17. package/dist/api/types/PlatformMarket.d.ts +8 -16
  18. package/dist/api/types/PlatformMarket.js +1 -9
  19. package/dist/api/types/PlatformMarketPlatform.d.ts +7 -0
  20. package/dist/api/types/PlatformMarketPlatform.js +7 -0
  21. package/dist/api/types/index.d.ts +3 -0
  22. package/dist/api/types/index.js +3 -0
  23. package/dist/core/auth/BasicAuth.d.ts +2 -2
  24. package/dist/core/auth/BasicAuth.js +6 -1
  25. package/dist/core/index.d.ts +1 -0
  26. package/dist/core/index.js +1 -0
  27. package/dist/core/schemas/Schema.d.ts +88 -0
  28. package/dist/core/schemas/Schema.js +22 -0
  29. package/dist/core/schemas/builders/bigint/bigint.d.ts +2 -0
  30. package/dist/core/schemas/builders/bigint/bigint.js +53 -0
  31. package/dist/core/schemas/builders/bigint/index.d.ts +1 -0
  32. package/dist/core/schemas/builders/bigint/index.js +1 -0
  33. package/dist/core/schemas/builders/date/date.d.ts +2 -0
  34. package/dist/core/schemas/builders/date/date.js +62 -0
  35. package/dist/core/schemas/builders/date/index.d.ts +1 -0
  36. package/dist/core/schemas/builders/date/index.js +1 -0
  37. package/dist/core/schemas/builders/enum/enum.d.ts +2 -0
  38. package/dist/core/schemas/builders/enum/enum.js +35 -0
  39. package/dist/core/schemas/builders/enum/index.d.ts +1 -0
  40. package/dist/core/schemas/builders/enum/index.js +1 -0
  41. package/dist/core/schemas/builders/index.d.ts +14 -0
  42. package/dist/core/schemas/builders/index.js +14 -0
  43. package/dist/core/schemas/builders/lazy/index.d.ts +3 -0
  44. package/dist/core/schemas/builders/lazy/index.js +2 -0
  45. package/dist/core/schemas/builders/lazy/lazy.d.ts +5 -0
  46. package/dist/core/schemas/builders/lazy/lazy.js +22 -0
  47. package/dist/core/schemas/builders/lazy/lazyObject.d.ts +3 -0
  48. package/dist/core/schemas/builders/lazy/lazyObject.js +17 -0
  49. package/dist/core/schemas/builders/list/index.d.ts +1 -0
  50. package/dist/core/schemas/builders/list/index.js +1 -0
  51. package/dist/core/schemas/builders/list/list.d.ts +2 -0
  52. package/dist/core/schemas/builders/list/list.js +49 -0
  53. package/dist/core/schemas/builders/literals/booleanLiteral.d.ts +2 -0
  54. package/dist/core/schemas/builders/literals/booleanLiteral.js +25 -0
  55. package/dist/core/schemas/builders/literals/index.d.ts +2 -0
  56. package/dist/core/schemas/builders/literals/index.js +2 -0
  57. package/dist/core/schemas/builders/literals/stringLiteral.d.ts +2 -0
  58. package/dist/core/schemas/builders/literals/stringLiteral.js +25 -0
  59. package/dist/core/schemas/builders/object/index.d.ts +6 -0
  60. package/dist/core/schemas/builders/object/index.js +3 -0
  61. package/dist/core/schemas/builders/object/object.d.ts +3 -0
  62. package/dist/core/schemas/builders/object/object.js +381 -0
  63. package/dist/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts +6 -0
  64. package/dist/core/schemas/builders/object/objectWithoutOptionalProperties.js +4 -0
  65. package/dist/core/schemas/builders/object/property.d.ts +8 -0
  66. package/dist/core/schemas/builders/object/property.js +11 -0
  67. package/dist/core/schemas/builders/object/types.d.ts +31 -0
  68. package/dist/core/schemas/builders/object/types.js +1 -0
  69. package/dist/core/schemas/builders/object-like/getObjectLikeUtils.d.ts +9 -0
  70. package/dist/core/schemas/builders/object-like/getObjectLikeUtils.js +62 -0
  71. package/dist/core/schemas/builders/object-like/index.d.ts +2 -0
  72. package/dist/core/schemas/builders/object-like/index.js +1 -0
  73. package/dist/core/schemas/builders/object-like/types.d.ts +7 -0
  74. package/dist/core/schemas/builders/object-like/types.js +1 -0
  75. package/dist/core/schemas/builders/primitives/any.d.ts +2 -0
  76. package/dist/core/schemas/builders/primitives/any.js +6 -0
  77. package/dist/core/schemas/builders/primitives/boolean.d.ts +2 -0
  78. package/dist/core/schemas/builders/primitives/boolean.js +22 -0
  79. package/dist/core/schemas/builders/primitives/index.d.ts +6 -0
  80. package/dist/core/schemas/builders/primitives/index.js +6 -0
  81. package/dist/core/schemas/builders/primitives/never.d.ts +2 -0
  82. package/dist/core/schemas/builders/primitives/never.js +11 -0
  83. package/dist/core/schemas/builders/primitives/number.d.ts +2 -0
  84. package/dist/core/schemas/builders/primitives/number.js +22 -0
  85. package/dist/core/schemas/builders/primitives/string.d.ts +2 -0
  86. package/dist/core/schemas/builders/primitives/string.js +22 -0
  87. package/dist/core/schemas/builders/primitives/unknown.d.ts +2 -0
  88. package/dist/core/schemas/builders/primitives/unknown.js +3 -0
  89. package/dist/core/schemas/builders/record/index.d.ts +2 -0
  90. package/dist/core/schemas/builders/record/index.js +1 -0
  91. package/dist/core/schemas/builders/record/record.d.ts +4 -0
  92. package/dist/core/schemas/builders/record/record.js +133 -0
  93. package/dist/core/schemas/builders/record/types.d.ts +6 -0
  94. package/dist/core/schemas/builders/record/types.js +1 -0
  95. package/dist/core/schemas/builders/schema-utils/JsonError.d.ts +5 -0
  96. package/dist/core/schemas/builders/schema-utils/JsonError.js +9 -0
  97. package/dist/core/schemas/builders/schema-utils/ParseError.d.ts +5 -0
  98. package/dist/core/schemas/builders/schema-utils/ParseError.js +9 -0
  99. package/dist/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +21 -0
  100. package/dist/core/schemas/builders/schema-utils/getSchemaUtils.js +150 -0
  101. package/dist/core/schemas/builders/schema-utils/index.d.ts +4 -0
  102. package/dist/core/schemas/builders/schema-utils/index.js +3 -0
  103. package/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.d.ts +2 -0
  104. package/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.js +6 -0
  105. package/dist/core/schemas/builders/set/index.d.ts +1 -0
  106. package/dist/core/schemas/builders/set/index.js +1 -0
  107. package/dist/core/schemas/builders/set/set.d.ts +2 -0
  108. package/dist/core/schemas/builders/set/set.js +42 -0
  109. package/dist/core/schemas/builders/undiscriminated-union/index.d.ts +2 -0
  110. package/dist/core/schemas/builders/undiscriminated-union/index.js +1 -0
  111. package/dist/core/schemas/builders/undiscriminated-union/types.d.ts +4 -0
  112. package/dist/core/schemas/builders/undiscriminated-union/types.js +1 -0
  113. package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.d.ts +3 -0
  114. package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +39 -0
  115. package/dist/core/schemas/builders/union/discriminant.d.ts +5 -0
  116. package/dist/core/schemas/builders/union/discriminant.js +6 -0
  117. package/dist/core/schemas/builders/union/index.d.ts +4 -0
  118. package/dist/core/schemas/builders/union/index.js +2 -0
  119. package/dist/core/schemas/builders/union/types.d.ts +13 -0
  120. package/dist/core/schemas/builders/union/types.js +1 -0
  121. package/dist/core/schemas/builders/union/union.d.ts +4 -0
  122. package/dist/core/schemas/builders/union/union.js +127 -0
  123. package/dist/core/schemas/index.d.ts +2 -0
  124. package/dist/core/schemas/index.js +1 -0
  125. package/dist/core/schemas/utils/MaybePromise.d.ts +1 -0
  126. package/dist/core/schemas/utils/MaybePromise.js +1 -0
  127. package/dist/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts +7 -0
  128. package/dist/core/schemas/utils/addQuestionMarksToNullableProperties.js +1 -0
  129. package/dist/core/schemas/utils/createIdentitySchemaCreator.d.ts +2 -0
  130. package/dist/core/schemas/utils/createIdentitySchemaCreator.js +15 -0
  131. package/dist/core/schemas/utils/entries.d.ts +1 -0
  132. package/dist/core/schemas/utils/entries.js +3 -0
  133. package/dist/core/schemas/utils/filterObject.d.ts +1 -0
  134. package/dist/core/schemas/utils/filterObject.js +10 -0
  135. package/dist/core/schemas/utils/getErrorMessageForIncorrectType.d.ts +1 -0
  136. package/dist/core/schemas/utils/getErrorMessageForIncorrectType.js +24 -0
  137. package/dist/core/schemas/utils/isPlainObject.d.ts +1 -0
  138. package/dist/core/schemas/utils/isPlainObject.js +12 -0
  139. package/dist/core/schemas/utils/keys.d.ts +1 -0
  140. package/dist/core/schemas/utils/keys.js +3 -0
  141. package/dist/core/schemas/utils/maybeSkipValidation.d.ts +2 -0
  142. package/dist/core/schemas/utils/maybeSkipValidation.js +28 -0
  143. package/dist/core/schemas/utils/partition.d.ts +1 -0
  144. package/dist/core/schemas/utils/partition.js +12 -0
  145. package/dist/index.d.ts +1 -0
  146. package/dist/index.js +1 -0
  147. package/dist/serialization/index.d.ts +1 -0
  148. package/dist/serialization/index.js +1 -0
  149. package/dist/serialization/types/CryptoPriceItem.d.ts +11 -0
  150. package/dist/serialization/types/CryptoPriceItem.js +7 -0
  151. package/dist/serialization/types/CryptoPricesResponse.d.ts +12 -0
  152. package/dist/serialization/types/CryptoPricesResponse.js +8 -0
  153. package/dist/serialization/types/ErrorResponse.d.ts +11 -0
  154. package/dist/serialization/types/ErrorResponse.js +7 -0
  155. package/dist/serialization/types/PlatformMarket.d.ts +16 -0
  156. package/dist/serialization/types/PlatformMarket.js +12 -0
  157. package/dist/serialization/types/PlatformMarketPlatform.d.ts +7 -0
  158. package/dist/serialization/types/PlatformMarketPlatform.js +3 -0
  159. package/dist/serialization/types/SportsMatchingResponse.d.ts +10 -0
  160. package/dist/serialization/types/SportsMatchingResponse.js +6 -0
  161. package/dist/serialization/types/index.d.ts +6 -0
  162. package/dist/serialization/types/index.js +6 -0
  163. package/package.json +14 -3
@@ -0,0 +1,53 @@
1
+ import { SchemaType } from "../../Schema.js";
2
+ import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType.js";
3
+ import { maybeSkipValidation } from "../../utils/maybeSkipValidation.js";
4
+ import { getSchemaUtils } from "../schema-utils/index.js";
5
+ export function bigint() {
6
+ const baseSchema = {
7
+ parse: (raw, { breadcrumbsPrefix = [] } = {}) => {
8
+ if (typeof raw === "bigint") {
9
+ return {
10
+ ok: true,
11
+ value: raw,
12
+ };
13
+ }
14
+ if (typeof raw === "number") {
15
+ return {
16
+ ok: true,
17
+ value: BigInt(raw),
18
+ };
19
+ }
20
+ return {
21
+ ok: false,
22
+ errors: [
23
+ {
24
+ path: breadcrumbsPrefix,
25
+ message: getErrorMessageForIncorrectType(raw, "bigint | number"),
26
+ },
27
+ ],
28
+ };
29
+ },
30
+ json: (bigint, { breadcrumbsPrefix = [] } = {}) => {
31
+ if (typeof bigint !== "bigint") {
32
+ return {
33
+ ok: false,
34
+ errors: [
35
+ {
36
+ path: breadcrumbsPrefix,
37
+ message: getErrorMessageForIncorrectType(bigint, "bigint"),
38
+ },
39
+ ],
40
+ };
41
+ }
42
+ return {
43
+ ok: true,
44
+ value: bigint,
45
+ };
46
+ },
47
+ getType: () => SchemaType.BIGINT,
48
+ };
49
+ return {
50
+ ...maybeSkipValidation(baseSchema),
51
+ ...getSchemaUtils(baseSchema),
52
+ };
53
+ }
@@ -0,0 +1 @@
1
+ export { bigint } from "./bigint.js";
@@ -0,0 +1 @@
1
+ export { bigint } from "./bigint.js";
@@ -0,0 +1,2 @@
1
+ import { type Schema } from "../../Schema.js";
2
+ export declare function date(): Schema<string, Date>;
@@ -0,0 +1,62 @@
1
+ import { SchemaType } from "../../Schema.js";
2
+ import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType.js";
3
+ import { maybeSkipValidation } from "../../utils/maybeSkipValidation.js";
4
+ import { getSchemaUtils } from "../schema-utils/index.js";
5
+ // https://stackoverflow.com/questions/12756159/regex-and-iso8601-formatted-datetime
6
+ const ISO_8601_REGEX = /^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
7
+ export function date() {
8
+ const baseSchema = {
9
+ parse: (raw, { breadcrumbsPrefix = [] } = {}) => {
10
+ if (typeof raw !== "string") {
11
+ return {
12
+ ok: false,
13
+ errors: [
14
+ {
15
+ path: breadcrumbsPrefix,
16
+ message: getErrorMessageForIncorrectType(raw, "string"),
17
+ },
18
+ ],
19
+ };
20
+ }
21
+ if (!ISO_8601_REGEX.test(raw)) {
22
+ return {
23
+ ok: false,
24
+ errors: [
25
+ {
26
+ path: breadcrumbsPrefix,
27
+ message: getErrorMessageForIncorrectType(raw, "ISO 8601 date string"),
28
+ },
29
+ ],
30
+ };
31
+ }
32
+ return {
33
+ ok: true,
34
+ value: new Date(raw),
35
+ };
36
+ },
37
+ json: (date, { breadcrumbsPrefix = [] } = {}) => {
38
+ if (date instanceof Date) {
39
+ return {
40
+ ok: true,
41
+ value: date.toISOString(),
42
+ };
43
+ }
44
+ else {
45
+ return {
46
+ ok: false,
47
+ errors: [
48
+ {
49
+ path: breadcrumbsPrefix,
50
+ message: getErrorMessageForIncorrectType(date, "Date object"),
51
+ },
52
+ ],
53
+ };
54
+ }
55
+ },
56
+ getType: () => SchemaType.DATE,
57
+ };
58
+ return {
59
+ ...maybeSkipValidation(baseSchema),
60
+ ...getSchemaUtils(baseSchema),
61
+ };
62
+ }
@@ -0,0 +1 @@
1
+ export { date } from "./date.js";
@@ -0,0 +1 @@
1
+ export { date } from "./date.js";
@@ -0,0 +1,2 @@
1
+ import { type Schema } from "../../Schema.js";
2
+ export declare function enum_<U extends string, E extends U[]>(values: E): Schema<E[number], E[number]>;
@@ -0,0 +1,35 @@
1
+ import { SchemaType } from "../../Schema.js";
2
+ import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator.js";
3
+ import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType.js";
4
+ export function enum_(values) {
5
+ const validValues = new Set(values);
6
+ const schemaCreator = createIdentitySchemaCreator(SchemaType.ENUM, (value, { allowUnrecognizedEnumValues, breadcrumbsPrefix = [] } = {}) => {
7
+ if (typeof value !== "string") {
8
+ return {
9
+ ok: false,
10
+ errors: [
11
+ {
12
+ path: breadcrumbsPrefix,
13
+ message: getErrorMessageForIncorrectType(value, "string"),
14
+ },
15
+ ],
16
+ };
17
+ }
18
+ if (!validValues.has(value) && !allowUnrecognizedEnumValues) {
19
+ return {
20
+ ok: false,
21
+ errors: [
22
+ {
23
+ path: breadcrumbsPrefix,
24
+ message: getErrorMessageForIncorrectType(value, "enum"),
25
+ },
26
+ ],
27
+ };
28
+ }
29
+ return {
30
+ ok: true,
31
+ value: value,
32
+ };
33
+ });
34
+ return schemaCreator();
35
+ }
@@ -0,0 +1 @@
1
+ export { enum_ } from "./enum.js";
@@ -0,0 +1 @@
1
+ export { enum_ } from "./enum.js";
@@ -0,0 +1,14 @@
1
+ export * from "./bigint/index.js";
2
+ export * from "./date/index.js";
3
+ export * from "./enum/index.js";
4
+ export * from "./lazy/index.js";
5
+ export * from "./list/index.js";
6
+ export * from "./literals/index.js";
7
+ export * from "./object/index.js";
8
+ export * from "./object-like/index.js";
9
+ export * from "./primitives/index.js";
10
+ export * from "./record/index.js";
11
+ export * from "./schema-utils/index.js";
12
+ export * from "./set/index.js";
13
+ export * from "./undiscriminated-union/index.js";
14
+ export * from "./union/index.js";
@@ -0,0 +1,14 @@
1
+ export * from "./bigint/index.js";
2
+ export * from "./date/index.js";
3
+ export * from "./enum/index.js";
4
+ export * from "./lazy/index.js";
5
+ export * from "./list/index.js";
6
+ export * from "./literals/index.js";
7
+ export * from "./object/index.js";
8
+ export * from "./object-like/index.js";
9
+ export * from "./primitives/index.js";
10
+ export * from "./record/index.js";
11
+ export * from "./schema-utils/index.js";
12
+ export * from "./set/index.js";
13
+ export * from "./undiscriminated-union/index.js";
14
+ export * from "./union/index.js";
@@ -0,0 +1,3 @@
1
+ export type { SchemaGetter } from "./lazy.js";
2
+ export { lazy } from "./lazy.js";
3
+ export { lazyObject } from "./lazyObject.js";
@@ -0,0 +1,2 @@
1
+ export { lazy } from "./lazy.js";
2
+ export { lazyObject } from "./lazyObject.js";
@@ -0,0 +1,5 @@
1
+ import type { BaseSchema, Schema } from "../../Schema.js";
2
+ export type SchemaGetter<SchemaType extends Schema<any, any>> = () => SchemaType;
3
+ export declare function lazy<Raw, Parsed>(getter: SchemaGetter<Schema<Raw, Parsed>>): Schema<Raw, Parsed>;
4
+ export declare function constructLazyBaseSchema<Raw, Parsed>(getter: SchemaGetter<Schema<Raw, Parsed>>): BaseSchema<Raw, Parsed>;
5
+ export declare function getMemoizedSchema<SchemaType extends Schema<any, any>>(getter: SchemaGetter<SchemaType>): SchemaType;
@@ -0,0 +1,22 @@
1
+ import { getSchemaUtils } from "../schema-utils/index.js";
2
+ export function lazy(getter) {
3
+ const baseSchema = constructLazyBaseSchema(getter);
4
+ return {
5
+ ...baseSchema,
6
+ ...getSchemaUtils(baseSchema),
7
+ };
8
+ }
9
+ export function constructLazyBaseSchema(getter) {
10
+ return {
11
+ parse: (raw, opts) => getMemoizedSchema(getter).parse(raw, opts),
12
+ json: (parsed, opts) => getMemoizedSchema(getter).json(parsed, opts),
13
+ getType: () => getMemoizedSchema(getter).getType(),
14
+ };
15
+ }
16
+ export function getMemoizedSchema(getter) {
17
+ const castedGetter = getter;
18
+ if (castedGetter.__zurg_memoized == null) {
19
+ castedGetter.__zurg_memoized = getter();
20
+ }
21
+ return castedGetter.__zurg_memoized;
22
+ }
@@ -0,0 +1,3 @@
1
+ import type { ObjectSchema } from "../object/types.js";
2
+ import { type SchemaGetter } from "./lazy.js";
3
+ export declare function lazyObject<Raw, Parsed>(getter: SchemaGetter<ObjectSchema<Raw, Parsed>>): ObjectSchema<Raw, Parsed>;
@@ -0,0 +1,17 @@
1
+ import { getObjectUtils } from "../object/index.js";
2
+ import { getObjectLikeUtils } from "../object-like/index.js";
3
+ import { getSchemaUtils } from "../schema-utils/index.js";
4
+ import { constructLazyBaseSchema, getMemoizedSchema } from "./lazy.js";
5
+ export function lazyObject(getter) {
6
+ const baseSchema = {
7
+ ...constructLazyBaseSchema(getter),
8
+ _getRawProperties: () => getMemoizedSchema(getter)._getRawProperties(),
9
+ _getParsedProperties: () => getMemoizedSchema(getter)._getParsedProperties(),
10
+ };
11
+ return {
12
+ ...baseSchema,
13
+ ...getSchemaUtils(baseSchema),
14
+ ...getObjectLikeUtils(baseSchema),
15
+ ...getObjectUtils(baseSchema),
16
+ };
17
+ }
@@ -0,0 +1 @@
1
+ export { list } from "./list.js";
@@ -0,0 +1 @@
1
+ export { list } from "./list.js";
@@ -0,0 +1,2 @@
1
+ import { type Schema } from "../../Schema.js";
2
+ export declare function list<Raw, Parsed>(schema: Schema<Raw, Parsed>): Schema<Raw[], Parsed[]>;
@@ -0,0 +1,49 @@
1
+ import { SchemaType } from "../../Schema.js";
2
+ import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType.js";
3
+ import { maybeSkipValidation } from "../../utils/maybeSkipValidation.js";
4
+ import { getSchemaUtils } from "../schema-utils/index.js";
5
+ export function list(schema) {
6
+ const baseSchema = {
7
+ parse: (raw, opts) => validateAndTransformArray(raw, (item, index) => schema.parse(item, {
8
+ ...opts,
9
+ breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), `[${index}]`],
10
+ })),
11
+ json: (parsed, opts) => validateAndTransformArray(parsed, (item, index) => schema.json(item, {
12
+ ...opts,
13
+ breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), `[${index}]`],
14
+ })),
15
+ getType: () => SchemaType.LIST,
16
+ };
17
+ return {
18
+ ...maybeSkipValidation(baseSchema),
19
+ ...getSchemaUtils(baseSchema),
20
+ };
21
+ }
22
+ function validateAndTransformArray(value, transformItem) {
23
+ if (!Array.isArray(value)) {
24
+ return {
25
+ ok: false,
26
+ errors: [
27
+ {
28
+ message: getErrorMessageForIncorrectType(value, "list"),
29
+ path: [],
30
+ },
31
+ ],
32
+ };
33
+ }
34
+ const result = [];
35
+ const errors = [];
36
+ for (let i = 0; i < value.length; i++) {
37
+ const item = transformItem(value[i], i);
38
+ if (item.ok) {
39
+ result.push(item.value);
40
+ }
41
+ else {
42
+ errors.push(...item.errors);
43
+ }
44
+ }
45
+ if (errors.length === 0) {
46
+ return { ok: true, value: result };
47
+ }
48
+ return { ok: false, errors };
49
+ }
@@ -0,0 +1,2 @@
1
+ import { type Schema } from "../../Schema.js";
2
+ export declare function booleanLiteral<V extends boolean>(literal: V): Schema<V, V>;
@@ -0,0 +1,25 @@
1
+ import { SchemaType } from "../../Schema.js";
2
+ import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator.js";
3
+ import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType.js";
4
+ export function booleanLiteral(literal) {
5
+ const schemaCreator = createIdentitySchemaCreator(SchemaType.BOOLEAN_LITERAL, (value, { breadcrumbsPrefix = [] } = {}) => {
6
+ if (value === literal) {
7
+ return {
8
+ ok: true,
9
+ value: literal,
10
+ };
11
+ }
12
+ else {
13
+ return {
14
+ ok: false,
15
+ errors: [
16
+ {
17
+ path: breadcrumbsPrefix,
18
+ message: getErrorMessageForIncorrectType(value, `${literal.toString()}`),
19
+ },
20
+ ],
21
+ };
22
+ }
23
+ });
24
+ return schemaCreator();
25
+ }
@@ -0,0 +1,2 @@
1
+ export { booleanLiteral } from "./booleanLiteral.js";
2
+ export { stringLiteral } from "./stringLiteral.js";
@@ -0,0 +1,2 @@
1
+ export { booleanLiteral } from "./booleanLiteral.js";
2
+ export { stringLiteral } from "./stringLiteral.js";
@@ -0,0 +1,2 @@
1
+ import { type Schema } from "../../Schema.js";
2
+ export declare function stringLiteral<V extends string>(literal: V): Schema<V, V>;
@@ -0,0 +1,25 @@
1
+ import { SchemaType } from "../../Schema.js";
2
+ import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator.js";
3
+ import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType.js";
4
+ export function stringLiteral(literal) {
5
+ const schemaCreator = createIdentitySchemaCreator(SchemaType.STRING_LITERAL, (value, { breadcrumbsPrefix = [] } = {}) => {
6
+ if (value === literal) {
7
+ return {
8
+ ok: true,
9
+ value: literal,
10
+ };
11
+ }
12
+ else {
13
+ return {
14
+ ok: false,
15
+ errors: [
16
+ {
17
+ path: breadcrumbsPrefix,
18
+ message: getErrorMessageForIncorrectType(value, `"${literal}"`),
19
+ },
20
+ ],
21
+ };
22
+ }
23
+ });
24
+ return schemaCreator();
25
+ }
@@ -0,0 +1,6 @@
1
+ export { getObjectUtils, object } from "./object.js";
2
+ export type { inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas, inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas, } from "./objectWithoutOptionalProperties.js";
3
+ export { objectWithoutOptionalProperties } from "./objectWithoutOptionalProperties.js";
4
+ export type { Property } from "./property.js";
5
+ export { isProperty, property } from "./property.js";
6
+ export type { BaseObjectSchema, inferObjectSchemaFromPropertySchemas, inferParsedObject, inferParsedObjectFromPropertySchemas, inferParsedPropertySchema, inferRawKey, inferRawObject, inferRawObjectFromPropertySchemas, inferRawPropertySchema, ObjectSchema, ObjectUtils, PropertySchemas, } from "./types.js";
@@ -0,0 +1,3 @@
1
+ export { getObjectUtils, object } from "./object.js";
2
+ export { objectWithoutOptionalProperties } from "./objectWithoutOptionalProperties.js";
3
+ export { isProperty, property } from "./property.js";
@@ -0,0 +1,3 @@
1
+ import type { BaseObjectSchema, inferObjectSchemaFromPropertySchemas, ObjectUtils, PropertySchemas } from "./types.js";
2
+ export declare function object<ParsedKeys extends string, T extends PropertySchemas<ParsedKeys>>(schemas: T): inferObjectSchemaFromPropertySchemas<T>;
3
+ export declare function getObjectUtils<Raw, Parsed>(schema: BaseObjectSchema<Raw, Parsed>): ObjectUtils<Raw, Parsed>;