@palmares/schemas 0.0.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.
- package/.turbo/turbo-build$colon$watch.log +424 -0
- package/.turbo/turbo-build.log +13 -0
- package/.turbo/turbo-build:watch.log +26 -0
- package/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/dist/cjs/src/adapter/fields/array.js +157 -0
- package/dist/cjs/src/adapter/fields/boolean.js +167 -0
- package/dist/cjs/src/adapter/fields/datetime.js +167 -0
- package/dist/cjs/src/adapter/fields/index.js +311 -0
- package/dist/cjs/src/adapter/fields/number.js +167 -0
- package/dist/cjs/src/adapter/fields/object.js +167 -0
- package/dist/cjs/src/adapter/fields/string.js +167 -0
- package/dist/cjs/src/adapter/fields/union.js +167 -0
- package/dist/cjs/src/adapter/index.js +198 -0
- package/dist/cjs/src/adapter/types.js +4 -0
- package/dist/cjs/src/compile.js +262 -0
- package/dist/cjs/src/conf.js +27 -0
- package/dist/cjs/src/constants.js +42 -0
- package/dist/cjs/src/domain.js +12 -0
- package/dist/cjs/src/exceptions.js +168 -0
- package/dist/cjs/src/index.js +365 -0
- package/dist/cjs/src/model.js +628 -0
- package/dist/cjs/src/parsers/convert-from-number.js +20 -0
- package/dist/cjs/src/parsers/convert-from-string.js +24 -0
- package/dist/cjs/src/parsers/index.js +25 -0
- package/dist/cjs/src/schema/array.js +890 -0
- package/dist/cjs/src/schema/boolean.js +826 -0
- package/dist/cjs/src/schema/datetime.js +778 -0
- package/dist/cjs/src/schema/index.js +17 -0
- package/dist/cjs/src/schema/number.js +960 -0
- package/dist/cjs/src/schema/object.js +999 -0
- package/dist/cjs/src/schema/schema.js +1788 -0
- package/dist/cjs/src/schema/string.js +948 -0
- package/dist/cjs/src/schema/types.js +4 -0
- package/dist/cjs/src/schema/union.js +952 -0
- package/dist/cjs/src/types.js +4 -0
- package/dist/cjs/src/utils.js +627 -0
- package/dist/cjs/src/validators/array.js +457 -0
- package/dist/cjs/src/validators/boolean.js +199 -0
- package/dist/cjs/src/validators/datetime.js +287 -0
- package/dist/cjs/src/validators/number.js +403 -0
- package/dist/cjs/src/validators/object.js +290 -0
- package/dist/cjs/src/validators/schema.js +318 -0
- package/dist/cjs/src/validators/string.js +439 -0
- package/dist/cjs/src/validators/types.js +4 -0
- package/dist/cjs/src/validators/union.js +232 -0
- package/dist/cjs/src/validators/utils.js +426 -0
- package/dist/cjs/tsconfig.types.tsbuildinfo +1 -0
- package/dist/cjs/types/adapter/fields/array.d.ts +20 -0
- package/dist/cjs/types/adapter/fields/array.d.ts.map +1 -0
- package/dist/cjs/types/adapter/fields/boolean.d.ts +25 -0
- package/dist/cjs/types/adapter/fields/boolean.d.ts.map +1 -0
- package/dist/cjs/types/adapter/fields/datetime.d.ts +25 -0
- package/dist/cjs/types/adapter/fields/datetime.d.ts.map +1 -0
- package/dist/cjs/types/adapter/fields/index.d.ts +31 -0
- package/dist/cjs/types/adapter/fields/index.d.ts.map +1 -0
- package/dist/cjs/types/adapter/fields/number.d.ts +25 -0
- package/dist/cjs/types/adapter/fields/number.d.ts.map +1 -0
- package/dist/cjs/types/adapter/fields/object.d.ts +25 -0
- package/dist/cjs/types/adapter/fields/object.d.ts.map +1 -0
- package/dist/cjs/types/adapter/fields/string.d.ts +25 -0
- package/dist/cjs/types/adapter/fields/string.d.ts.map +1 -0
- package/dist/cjs/types/adapter/fields/union.d.ts +25 -0
- package/dist/cjs/types/adapter/fields/union.d.ts.map +1 -0
- package/dist/cjs/types/adapter/index.d.ts +25 -0
- package/dist/cjs/types/adapter/index.d.ts.map +1 -0
- package/dist/cjs/types/adapter/types.d.ts +144 -0
- package/dist/cjs/types/adapter/types.d.ts.map +1 -0
- package/dist/cjs/types/compile.d.ts +3 -0
- package/dist/cjs/types/compile.d.ts.map +1 -0
- package/dist/cjs/types/conf.d.ts +16 -0
- package/dist/cjs/types/conf.d.ts.map +1 -0
- package/dist/cjs/types/constants.d.ts +6 -0
- package/dist/cjs/types/constants.d.ts.map +1 -0
- package/dist/cjs/types/domain.d.ts +21 -0
- package/dist/cjs/types/domain.d.ts.map +1 -0
- package/dist/cjs/types/exceptions.d.ts +13 -0
- package/dist/cjs/types/exceptions.d.ts.map +1 -0
- package/dist/cjs/types/index.d.ts +240 -0
- package/dist/cjs/types/index.d.ts.map +1 -0
- package/dist/cjs/types/model.d.ts +136 -0
- package/dist/cjs/types/model.d.ts.map +1 -0
- package/dist/cjs/types/parsers/convert-from-number.d.ts +15 -0
- package/dist/cjs/types/parsers/convert-from-number.d.ts.map +1 -0
- package/dist/cjs/types/parsers/convert-from-string.d.ts +9 -0
- package/dist/cjs/types/parsers/convert-from-string.d.ts.map +1 -0
- package/dist/cjs/types/parsers/index.d.ts +3 -0
- package/dist/cjs/types/parsers/index.d.ts.map +1 -0
- package/dist/cjs/types/schema/array.d.ts +429 -0
- package/dist/cjs/types/schema/array.d.ts.map +1 -0
- package/dist/cjs/types/schema/boolean.d.ts +501 -0
- package/dist/cjs/types/schema/boolean.d.ts.map +1 -0
- package/dist/cjs/types/schema/datetime.d.ts +474 -0
- package/dist/cjs/types/schema/datetime.d.ts.map +1 -0
- package/dist/cjs/types/schema/index.d.ts +4 -0
- package/dist/cjs/types/schema/index.d.ts.map +1 -0
- package/dist/cjs/types/schema/number.d.ts +667 -0
- package/dist/cjs/types/schema/number.d.ts.map +1 -0
- package/dist/cjs/types/schema/object.d.ts +450 -0
- package/dist/cjs/types/schema/object.d.ts.map +1 -0
- package/dist/cjs/types/schema/schema.d.ts +646 -0
- package/dist/cjs/types/schema/schema.d.ts.map +1 -0
- package/dist/cjs/types/schema/string.d.ts +606 -0
- package/dist/cjs/types/schema/string.d.ts.map +1 -0
- package/dist/cjs/types/schema/types.d.ts +70 -0
- package/dist/cjs/types/schema/types.d.ts.map +1 -0
- package/dist/cjs/types/schema/union.d.ts +388 -0
- package/dist/cjs/types/schema/union.d.ts.map +1 -0
- package/dist/cjs/types/types.d.ts +11 -0
- package/dist/cjs/types/types.d.ts.map +1 -0
- package/dist/cjs/types/utils.d.ts +79 -0
- package/dist/cjs/types/utils.d.ts.map +1 -0
- package/dist/cjs/types/validators/array.d.ts +8 -0
- package/dist/cjs/types/validators/array.d.ts.map +1 -0
- package/dist/cjs/types/validators/boolean.d.ts +4 -0
- package/dist/cjs/types/validators/boolean.d.ts.map +1 -0
- package/dist/cjs/types/validators/datetime.d.ts +7 -0
- package/dist/cjs/types/validators/datetime.d.ts.map +1 -0
- package/dist/cjs/types/validators/number.d.ts +10 -0
- package/dist/cjs/types/validators/number.d.ts.map +1 -0
- package/dist/cjs/types/validators/object.d.ts +6 -0
- package/dist/cjs/types/validators/object.d.ts.map +1 -0
- package/dist/cjs/types/validators/schema.d.ts +10 -0
- package/dist/cjs/types/validators/schema.d.ts.map +1 -0
- package/dist/cjs/types/validators/string.d.ts +12 -0
- package/dist/cjs/types/validators/string.d.ts.map +1 -0
- package/dist/cjs/types/validators/types.d.ts +2 -0
- package/dist/cjs/types/validators/types.d.ts.map +1 -0
- package/dist/cjs/types/validators/union.d.ts +4 -0
- package/dist/cjs/types/validators/union.d.ts.map +1 -0
- package/dist/cjs/types/validators/utils.d.ts +83 -0
- package/dist/cjs/types/validators/utils.d.ts.map +1 -0
- package/dist/esm/src/adapter/fields/array.js +13 -0
- package/dist/esm/src/adapter/fields/boolean.js +20 -0
- package/dist/esm/src/adapter/fields/datetime.js +20 -0
- package/dist/esm/src/adapter/fields/index.js +37 -0
- package/dist/esm/src/adapter/fields/number.js +20 -0
- package/dist/esm/src/adapter/fields/object.js +20 -0
- package/dist/esm/src/adapter/fields/string.js +20 -0
- package/dist/esm/src/adapter/fields/union.js +20 -0
- package/dist/esm/src/adapter/index.js +18 -0
- package/dist/esm/src/adapter/types.js +1 -0
- package/dist/esm/src/compile.js +10 -0
- package/dist/esm/src/conf.js +19 -0
- package/dist/esm/src/constants.js +5 -0
- package/dist/esm/src/domain.js +2 -0
- package/dist/esm/src/exceptions.js +15 -0
- package/dist/esm/src/index.js +160 -0
- package/dist/esm/src/model.js +255 -0
- package/dist/esm/src/parsers/convert-from-number.js +8 -0
- package/dist/esm/src/parsers/convert-from-string.js +14 -0
- package/dist/esm/src/parsers/index.js +2 -0
- package/dist/esm/src/schema/array.js +403 -0
- package/dist/esm/src/schema/boolean.js +465 -0
- package/dist/esm/src/schema/datetime.js +423 -0
- package/dist/esm/src/schema/index.js +3 -0
- package/dist/esm/src/schema/number.js +592 -0
- package/dist/esm/src/schema/object.js +464 -0
- package/dist/esm/src/schema/schema.js +728 -0
- package/dist/esm/src/schema/string.js +579 -0
- package/dist/esm/src/schema/types.js +1 -0
- package/dist/esm/src/schema/union.js +388 -0
- package/dist/esm/src/types.js +1 -0
- package/dist/esm/src/utils.js +175 -0
- package/dist/esm/src/validators/array.js +135 -0
- package/dist/esm/src/validators/boolean.js +35 -0
- package/dist/esm/src/validators/datetime.js +85 -0
- package/dist/esm/src/validators/number.js +162 -0
- package/dist/esm/src/validators/object.js +38 -0
- package/dist/esm/src/validators/schema.js +114 -0
- package/dist/esm/src/validators/string.js +174 -0
- package/dist/esm/src/validators/types.js +1 -0
- package/dist/esm/src/validators/union.js +38 -0
- package/dist/esm/src/validators/utils.js +120 -0
- package/package.json +48 -0
- package/src/adapter/fields/array.ts +31 -0
- package/src/adapter/fields/boolean.ts +48 -0
- package/src/adapter/fields/datetime.ts +49 -0
- package/src/adapter/fields/index.ts +72 -0
- package/src/adapter/fields/number.ts +49 -0
- package/src/adapter/fields/object.ts +49 -0
- package/src/adapter/fields/string.ts +49 -0
- package/src/adapter/fields/union.ts +49 -0
- package/src/adapter/index.ts +34 -0
- package/src/adapter/types.ts +261 -0
- package/src/compile.ts +14 -0
- package/src/conf.ts +27 -0
- package/src/constants.ts +9 -0
- package/src/domain.ts +3 -0
- package/src/exceptions.ts +17 -0
- package/src/index.ts +338 -0
- package/src/model.ts +501 -0
- package/src/parsers/convert-from-number.ts +13 -0
- package/src/parsers/convert-from-string.ts +19 -0
- package/src/parsers/index.ts +2 -0
- package/src/schema/array.ts +633 -0
- package/src/schema/boolean.ts +700 -0
- package/src/schema/datetime.ts +613 -0
- package/src/schema/index.ts +5 -0
- package/src/schema/number.ts +885 -0
- package/src/schema/object.ts +699 -0
- package/src/schema/schema.ts +1093 -0
- package/src/schema/string.ts +807 -0
- package/src/schema/types.ts +126 -0
- package/src/schema/union.ts +596 -0
- package/src/types.ts +13 -0
- package/src/utils.ts +322 -0
- package/src/validators/array.ts +164 -0
- package/src/validators/boolean.ts +46 -0
- package/src/validators/datetime.ts +113 -0
- package/src/validators/number.ts +188 -0
- package/src/validators/object.ts +55 -0
- package/src/validators/schema.ts +134 -0
- package/src/validators/string.ts +215 -0
- package/src/validators/types.ts +1 -0
- package/src/validators/union.ts +52 -0
- package/src/validators/utils.ts +200 -0
- package/tsconfig.json +9 -0
- package/tsconfig.types.json +10 -0
@@ -0,0 +1,646 @@
|
|
1
|
+
import type { DefinitionsOfSchemaType, ValidationFallbackCallbackReturnType } from './types';
|
2
|
+
import type SchemaAdapter from '../adapter';
|
3
|
+
import type FieldAdapter from '../adapter/fields';
|
4
|
+
import type { ValidationDataBasedOnType } from '../adapter/types';
|
5
|
+
import type Validator from '../validators/utils';
|
6
|
+
export default class Schema<TType extends {
|
7
|
+
input: any;
|
8
|
+
validate: any;
|
9
|
+
internal: any;
|
10
|
+
output: any;
|
11
|
+
representation: any;
|
12
|
+
} = {
|
13
|
+
input: any;
|
14
|
+
validate: any;
|
15
|
+
internal: any;
|
16
|
+
output: any;
|
17
|
+
representation: any;
|
18
|
+
}, TDefinitions extends DefinitionsOfSchemaType = DefinitionsOfSchemaType> {
|
19
|
+
protected __beforeValidationCallbacks: Map<string, (adapterToUse: SchemaAdapter, fieldAdapter: FieldAdapter, schema: Schema<any, any> & {
|
20
|
+
__validateByAdapter: Schema<any, any>['__validateByAdapter'];
|
21
|
+
}, translatedSchemas: any[], value: TType['input'], path: ValidationFallbackCallbackReturnType['errors'][number]['path'], options: Parameters<Schema['__transformToAdapter']>[0]) => ReturnType<Schema['__validateByAdapter']>>;
|
22
|
+
protected __cachedGetParent?: (() => Schema<any, any>);
|
23
|
+
protected set __getParent(value: (() => Schema<any, any>));
|
24
|
+
protected get __getParent(): (() => Schema<any, any>) | undefined;
|
25
|
+
protected __alreadyAppliedModel: boolean;
|
26
|
+
protected __runBeforeParseAndData?: (self: any) => Promise<void>;
|
27
|
+
protected __rootFallbacksValidator: Validator;
|
28
|
+
protected __saveCallback?: (value: any) => Promise<any | void> | any | void;
|
29
|
+
protected __modelOmitCallback?: () => void;
|
30
|
+
protected __parsers: Record<'high' | 'medium' | 'low', Map<string, (value: any) => {
|
31
|
+
value: any;
|
32
|
+
preventNextParsers: boolean;
|
33
|
+
} | Promise<{
|
34
|
+
value: any;
|
35
|
+
preventNextParsers: boolean;
|
36
|
+
}>>> & {
|
37
|
+
_fallbacks: Set<string>;
|
38
|
+
};
|
39
|
+
protected __refinements: ((value: any) => Promise<void | undefined | {
|
40
|
+
code: string;
|
41
|
+
message: string;
|
42
|
+
}> | void | undefined | {
|
43
|
+
code: string;
|
44
|
+
message: string;
|
45
|
+
})[];
|
46
|
+
protected __nullable: {
|
47
|
+
message: string;
|
48
|
+
allow: boolean;
|
49
|
+
};
|
50
|
+
protected __optional: {
|
51
|
+
message: string;
|
52
|
+
allow: boolean;
|
53
|
+
};
|
54
|
+
protected __extends: {
|
55
|
+
callback: (schema: any) => any;
|
56
|
+
toStringCallback?: (schemaAsString: string) => string;
|
57
|
+
} | undefined;
|
58
|
+
protected __transformedSchemas: Record<string, {
|
59
|
+
transformed: boolean;
|
60
|
+
adapter: TDefinitions['schemaAdapter'];
|
61
|
+
schemas: any[];
|
62
|
+
}>;
|
63
|
+
protected __defaultFunction: (() => Promise<TType['input'] | TType['output']>) | undefined;
|
64
|
+
protected __toRepresentation: ((value: TType['output']) => TType['output']) | undefined;
|
65
|
+
protected __toValidate: ((value: TType['input']) => TType['validate']) | undefined;
|
66
|
+
protected __toInternal: ((value: TType['validate']) => TType['internal']) | undefined;
|
67
|
+
protected __type: {
|
68
|
+
message: string;
|
69
|
+
check: (value: TType['input']) => boolean;
|
70
|
+
};
|
71
|
+
/**
|
72
|
+
* This will validate the data with the fallbacks, so internally, without relaying on the schema adapter. This is nice because we can support things that the schema adapter is not able to support by default.
|
73
|
+
*
|
74
|
+
* @param errorsAsHashedSet - The errors as a hashed set. This is used to prevent duplicate errors.
|
75
|
+
* @param path - The path of the error.
|
76
|
+
* @param parseResult - The result of the parse method.
|
77
|
+
*/
|
78
|
+
private __validateByFallbacks;
|
79
|
+
/**
|
80
|
+
* This will validate by the adapter. In other words, we send the data to the schema adapter and then we validate that data.
|
81
|
+
* So understand that, first we send the data to the adapter, the adapter validates it, then, after we validate from the adapter
|
82
|
+
* we validate with the fallbacks so we can do all of the extra validations not handled by the adapter.
|
83
|
+
*
|
84
|
+
* @param value - The value to be validated.
|
85
|
+
* @param errorsAsHashedSet - The errors as a hashed set. This is used to prevent duplicate errors on the validator.
|
86
|
+
* @param path - The path of the error so we can construct an object with the nested paths of the error.
|
87
|
+
* @param parseResult - The result of the parse method.
|
88
|
+
*
|
89
|
+
* @returns The result and the errors of the parse method.
|
90
|
+
*/
|
91
|
+
protected __validateByAdapter(adapter: SchemaAdapter, fieldAdapter: FieldAdapter, schema: any, value: TType['input'], path: NonNullable<Parameters<Schema['__parse']>[1]>, options: Parameters<Schema['__transformToAdapter']>[0]): Promise<{
|
92
|
+
errors: any[];
|
93
|
+
parsed: any;
|
94
|
+
}>;
|
95
|
+
protected __transformToAdapter(_options: {
|
96
|
+
args: Omit<ValidationDataBasedOnType<any>, 'withFallback'>;
|
97
|
+
force?: boolean;
|
98
|
+
toInternalToBubbleUp?: (() => Promise<void>)[];
|
99
|
+
schemaAdapter?: SchemaAdapter;
|
100
|
+
errorsAsHashedSet?: Set<string>;
|
101
|
+
shouldAddStringVersion?: boolean;
|
102
|
+
appendFallbacksBeforeAdapterValidation?: (uniqueNameOfFallback: string, fallbackValidationBeforeAdapter: (adapterToUse: SchemaAdapter, fieldAdapter: FieldAdapter, schema: Omit<Schema<any, any>, '__validateByAdapter'> & {
|
103
|
+
__validateByAdapter: Schema<any, any>['__validateByAdapter'];
|
104
|
+
}, translatedSchemas: any[], value: any, path: ValidationFallbackCallbackReturnType['errors'][number]['path'], options: Parameters<Schema['__transformToAdapter']>[0]) => ReturnType<Schema['__validateByAdapter']>) => void;
|
105
|
+
}): Promise<{
|
106
|
+
transformed: ReturnType<FieldAdapter['translate']>;
|
107
|
+
asString: string;
|
108
|
+
}[]>;
|
109
|
+
/** */
|
110
|
+
protected __parsersToTransformValue(value: any, parsersToUse?: Set<string>): Promise<any>;
|
111
|
+
protected __parse(value: TType['input'], path: ValidationFallbackCallbackReturnType["errors"][number]["path"] | undefined, options: Parameters<Schema['__transformToAdapter']>[0]): Promise<{
|
112
|
+
errors: any[];
|
113
|
+
parsed: TType['internal'];
|
114
|
+
}>;
|
115
|
+
/**
|
116
|
+
* This let's you refine the schema with custom validations. This is useful when you want to validate something that is not supported by default by the schema adapter.
|
117
|
+
*
|
118
|
+
* @example
|
119
|
+
* ```typescript
|
120
|
+
* import * as p from '@palmares/schemas';
|
121
|
+
*
|
122
|
+
* const numberSchema = p.number().refine((value) => {
|
123
|
+
* if (value < 0) return { code: 'invalid_number', message: 'The number should be greater than 0' };
|
124
|
+
* });
|
125
|
+
*
|
126
|
+
* const { errors, parsed } = await numberSchema.parse(-1);
|
127
|
+
*
|
128
|
+
* console.log(errors); // [{ isValid: false, code: 'invalid_number', message: 'The number should be greater than 0', path: [] }]
|
129
|
+
* ```
|
130
|
+
*
|
131
|
+
* @param refinementCallback - The callback that will be called to validate the value.
|
132
|
+
* @param options - Options for the refinement.
|
133
|
+
* @param options.isAsync - Whether the callback is async or not. Defaults to true.
|
134
|
+
*/
|
135
|
+
refine(refinementCallback: (value: TType['input']) => Promise<void | undefined | {
|
136
|
+
code: string;
|
137
|
+
message: string;
|
138
|
+
}> | void | undefined | {
|
139
|
+
code: string;
|
140
|
+
message: string;
|
141
|
+
}): Schema<{
|
142
|
+
input: TType["input"];
|
143
|
+
validate: TType["validate"];
|
144
|
+
internal: TType["internal"];
|
145
|
+
output: TType["output"];
|
146
|
+
representation: TType["representation"];
|
147
|
+
}, TDefinitions>;
|
148
|
+
/**
|
149
|
+
* Allows the value to be either undefined or null.
|
150
|
+
*
|
151
|
+
* @example
|
152
|
+
* ```typescript
|
153
|
+
* import * as p from '@palmares/schemas';
|
154
|
+
*
|
155
|
+
* const numberSchema = p.number().optional();
|
156
|
+
*
|
157
|
+
* const { errors, parsed } = await numberSchema.parse(undefined);
|
158
|
+
*
|
159
|
+
* console.log(parsed); // undefined
|
160
|
+
*
|
161
|
+
* const { errors, parsed } = await numberSchema.parse(null);
|
162
|
+
*
|
163
|
+
* console.log(parsed); // null
|
164
|
+
*
|
165
|
+
* const { errors, parsed } = await numberSchema.parse(1);
|
166
|
+
*
|
167
|
+
* console.log(parsed); // 1
|
168
|
+
* ```
|
169
|
+
*
|
170
|
+
* @returns - The schema we are working with.
|
171
|
+
*/
|
172
|
+
optional(options?: {
|
173
|
+
message?: string;
|
174
|
+
allow?: false;
|
175
|
+
}): Schema<{
|
176
|
+
input: TType["input"] | undefined | null;
|
177
|
+
validate: TType["validate"] | undefined | null;
|
178
|
+
internal: TType["internal"] | undefined | null;
|
179
|
+
output: TType["output"] | undefined | null;
|
180
|
+
representation: TType["representation"] | undefined | null;
|
181
|
+
}, TDefinitions>;
|
182
|
+
/**
|
183
|
+
* Allows the value to be null and ONLY null. You can also use this function to set a custom message when the value is NULL by setting
|
184
|
+
* the { message: 'Your custom message', allow: false } on the options.
|
185
|
+
*
|
186
|
+
* @example
|
187
|
+
* ```typescript
|
188
|
+
* import * as p from '@palmares/schemas';
|
189
|
+
*
|
190
|
+
* const numberSchema = p.number().nullable();
|
191
|
+
*
|
192
|
+
* const { errors, parsed } = await numberSchema.parse(null);
|
193
|
+
*
|
194
|
+
* console.log(parsed); // null
|
195
|
+
*
|
196
|
+
* const { errors, parsed } = await numberSchema.parse(undefined);
|
197
|
+
*
|
198
|
+
* console.log(errors); // [{ isValid: false, code: 'invalid_type', message: 'Invalid type', path: [] }]
|
199
|
+
* ```
|
200
|
+
*
|
201
|
+
* @param options - The options for the nullable function.
|
202
|
+
* @param options.message - The message to be shown when the value is not null. Defaults to 'Cannot be null'.
|
203
|
+
* @param options.allow - Whether the value can be null or not. Defaults to true.
|
204
|
+
*
|
205
|
+
* @returns The schema.
|
206
|
+
*/
|
207
|
+
nullable(options?: {
|
208
|
+
message: string;
|
209
|
+
allow: false;
|
210
|
+
}): Schema<{
|
211
|
+
input: TType["input"] | null;
|
212
|
+
validate: TType["validate"] | null;
|
213
|
+
internal: TType["internal"] | null;
|
214
|
+
output: TType["output"] | null;
|
215
|
+
representation: TType["representation"] | null;
|
216
|
+
}, TDefinitions>;
|
217
|
+
/**
|
218
|
+
* Appends a custom schema to the schema, this way it will bypass the creation of the schema in runtime.
|
219
|
+
*
|
220
|
+
* By default when validating, on the first validation we create the schema. Just during the first validation. With this function, you bypass that,
|
221
|
+
* so you can speed up the validation process.
|
222
|
+
*
|
223
|
+
* @example
|
224
|
+
* ```typescript
|
225
|
+
* import * as p from '@palmares/schemas';
|
226
|
+
* import * as z from 'zod';
|
227
|
+
*
|
228
|
+
* const numberSchema = p.number().appendSchema(z.number());
|
229
|
+
*
|
230
|
+
* const { errors, parsed } = await numberSchema.parse(1);
|
231
|
+
* ```
|
232
|
+
*
|
233
|
+
* @param schema - The schema to be appended.
|
234
|
+
* @param args - The arguments for the schema.
|
235
|
+
* @param args.adapter - The adapter to be used. If not provided, the default adapter will be used.
|
236
|
+
*
|
237
|
+
* @returns The same schema again.
|
238
|
+
*/
|
239
|
+
appendSchema<TType extends any = any>(schema: TDefinitions['schemaAdapter'], args?: {
|
240
|
+
adapter?: SchemaAdapter;
|
241
|
+
}): Schema<{
|
242
|
+
input: TType;
|
243
|
+
validate: TType;
|
244
|
+
internal: TType;
|
245
|
+
output: TType;
|
246
|
+
representation: TType;
|
247
|
+
}, TDefinitions>;
|
248
|
+
/**
|
249
|
+
* This method will remove the value from the representation of the schema. If the value is undefined it will keep that way
|
250
|
+
* otherwise it will set the value to undefined after it's validated.
|
251
|
+
* This is used in conjunction with the {@link data} function, the {@link parse} function or {@link validate}
|
252
|
+
* function. This will remove the value from the representation of the schema.
|
253
|
+
*
|
254
|
+
* By default, the value will be removed just from the representation, in other words, when you call the {@link data} function.
|
255
|
+
* But if you want to remove the value from the internal representation, you can pass the argument `toInternal` as true.
|
256
|
+
* Then if you still want to remove the value from the representation, you will need to pass the argument `toRepresentation` as true as well.
|
257
|
+
*
|
258
|
+
* @example
|
259
|
+
* ```typescript
|
260
|
+
* import * as p from '@palmares/schemas';
|
261
|
+
*
|
262
|
+
* const userSchema = p.object({
|
263
|
+
* id: p.number().optional(),
|
264
|
+
* name: p.string(),
|
265
|
+
* password: p.string().omit()
|
266
|
+
* });
|
267
|
+
*
|
268
|
+
* const user = await userSchema.data({
|
269
|
+
* id: 1,
|
270
|
+
* name: 'John Doe',
|
271
|
+
* password: '123456'
|
272
|
+
* });
|
273
|
+
*
|
274
|
+
* console.log(user); // { id: 1, name: 'John Doe' }
|
275
|
+
* ```
|
276
|
+
*
|
277
|
+
*
|
278
|
+
* @param args - By default, the value will be removed just from the representation, in other words, when you call the {@link data} function.
|
279
|
+
* But if you want to remove the value from the internal representation, you can pass the argument `toInternal` as true.
|
280
|
+
* Then if you still want to remove the value from the representation, you will need to pass the argument `toRepresentation` as true as well.
|
281
|
+
*
|
282
|
+
* @returns The schema.
|
283
|
+
*/
|
284
|
+
omit<TToInternal extends boolean, TToRepresentation extends boolean = boolean extends TToInternal ? true : false>(args?: {
|
285
|
+
toInternal?: TToInternal;
|
286
|
+
toRepresentation?: TToRepresentation;
|
287
|
+
}): Schema<{
|
288
|
+
input: TToInternal extends true ? TType["input"] | undefined : TType["input"];
|
289
|
+
validate: TToInternal extends true ? TType["validate"] | undefined : TType["validate"];
|
290
|
+
internal: TToInternal extends true ? undefined : TType["internal"];
|
291
|
+
output: TToRepresentation extends true ? TType["output"] | undefined : TType["output"];
|
292
|
+
representation: TToRepresentation extends true ? undefined : TType["representation"];
|
293
|
+
}, TDefinitions>;
|
294
|
+
/**
|
295
|
+
* This function is used in conjunction with the {@link validate} function. It's used to save a value to an external source
|
296
|
+
* like a database. You should always return the schema after you save the value, that way we will always have the correct type
|
297
|
+
* of the schema after the save operation.
|
298
|
+
*
|
299
|
+
* You can use the {@link toRepresentation} function to transform and clean the value it returns after the save.
|
300
|
+
*
|
301
|
+
* @example
|
302
|
+
* ```typescript
|
303
|
+
* import * as p from '@palmares/schemas';
|
304
|
+
*
|
305
|
+
* import { User } from './models';
|
306
|
+
*
|
307
|
+
* const userSchema = p.object({
|
308
|
+
* id: p.number().optional(),
|
309
|
+
* name: p.string(),
|
310
|
+
* email: p.string().email(),
|
311
|
+
* }).onSave(async (value) => {
|
312
|
+
* // Create or update the user on the database using palmares models or any other library of your choice.
|
313
|
+
* if (value.id)
|
314
|
+
* await User.default.set(value, { search: { id: value.id } });
|
315
|
+
* else
|
316
|
+
* await User.default.set(value);
|
317
|
+
*
|
318
|
+
* return value;
|
319
|
+
* });
|
320
|
+
*
|
321
|
+
*
|
322
|
+
* // Then, on your controller, do something like this:
|
323
|
+
* const { isValid, save, errors } = await userSchema.validate(req.body);
|
324
|
+
* if (isValid) {
|
325
|
+
* const savedValue = await save();
|
326
|
+
* return Response.json(savedValue, { status: 201 });
|
327
|
+
* }
|
328
|
+
*
|
329
|
+
* return Response.json({ errors }, { status: 400 });
|
330
|
+
* ```
|
331
|
+
*
|
332
|
+
* @param callback - The callback that will be called to save the value on an external source.
|
333
|
+
*
|
334
|
+
* @returns The schema.
|
335
|
+
*/
|
336
|
+
onSave(callback: (value: TType['internal']) => Promise<TType['output']> | TType['output']): Schema<{
|
337
|
+
input: TType["input"];
|
338
|
+
validate: TType["validate"];
|
339
|
+
internal: TType["internal"];
|
340
|
+
output: TType["output"];
|
341
|
+
representation: TType["representation"];
|
342
|
+
}, TDefinitions & {
|
343
|
+
hasSave: true;
|
344
|
+
}>;
|
345
|
+
/**
|
346
|
+
* This function is used to validate the schema and save the value to the database. It is used in
|
347
|
+
* conjunction with the {@link onSave} function.
|
348
|
+
*
|
349
|
+
* Different from other validation libraries, palmares schemas is aware that you want to save. On your routes/functions
|
350
|
+
* we recommend to ALWAYS use this function instead of {@link parse} directly. This is because this function by default
|
351
|
+
* will return an object with the property `save` or the `errors`. If the errors are present, you can return the errors
|
352
|
+
* to the user. If the save property is present, you can use to save the value to an external source. e.g. a database.
|
353
|
+
*
|
354
|
+
* @example
|
355
|
+
* ```typescript
|
356
|
+
* import * as p from '@palmares/schemas';
|
357
|
+
*
|
358
|
+
* import { User } from './models';
|
359
|
+
*
|
360
|
+
* const userSchema = p.object({
|
361
|
+
* id: p.number().optional(),
|
362
|
+
* name: p.string(),
|
363
|
+
* email: p.string().email(),
|
364
|
+
* }).onSave(async (value) => {
|
365
|
+
* // Create or update the user on the database using palmares models or any other library of your choice.
|
366
|
+
* if (value.id)
|
367
|
+
* await User.default.set(value, { search: { id: value.id } });
|
368
|
+
* else
|
369
|
+
* await User.default.set(value);
|
370
|
+
*
|
371
|
+
* return value;
|
372
|
+
* });
|
373
|
+
*
|
374
|
+
*
|
375
|
+
* // Then, on your controller, do something like this:
|
376
|
+
* const { isValid, save, errors } = await userSchema.validate(req.body);
|
377
|
+
* if (isValid) {
|
378
|
+
* const savedValue = await save();
|
379
|
+
* return Response.json(savedValue, { status: 201 });
|
380
|
+
* }
|
381
|
+
*
|
382
|
+
* return Response.json({ errors }, { status: 400 });
|
383
|
+
* ```
|
384
|
+
*
|
385
|
+
* @param value - The value to be validated.
|
386
|
+
*
|
387
|
+
* @returns An object with the property isValid, if the value is valid, the function `save` will be present.
|
388
|
+
* If the value is invalid, the property errors will be present.
|
389
|
+
*/
|
390
|
+
validate(value: TType['input']): Promise<{
|
391
|
+
isValid: false;
|
392
|
+
errors: any[];
|
393
|
+
} | {
|
394
|
+
isValid: true;
|
395
|
+
save: () => Promise<TType['representation']>;
|
396
|
+
}>;
|
397
|
+
/**
|
398
|
+
* Internal function, when we call the {@link validate} function it's this function that gets called
|
399
|
+
* when the user uses the `save` function returned by the {@link validate} function if the value is valid.
|
400
|
+
*
|
401
|
+
* @param value - The value to be saved.
|
402
|
+
*
|
403
|
+
* @returns The value to representation.
|
404
|
+
*/
|
405
|
+
protected _save(value: TType['input']): Promise<TType['representation']>;
|
406
|
+
/**
|
407
|
+
* This function is used to validate and parse the value to the internal representation of the schema.
|
408
|
+
*
|
409
|
+
* @example
|
410
|
+
* ```typescript
|
411
|
+
* import * as p from '@palmares/schemas';
|
412
|
+
*
|
413
|
+
* const numberSchema = p.number().allowString();
|
414
|
+
*
|
415
|
+
* const { errors, parsed } = await numberSchema.parse('123');
|
416
|
+
*
|
417
|
+
* console.log(parsed); // 123
|
418
|
+
* ```
|
419
|
+
*
|
420
|
+
* @param value - The value to be parsed.
|
421
|
+
*
|
422
|
+
* @returns The parsed value.
|
423
|
+
*/
|
424
|
+
parse(value: TType['input']): Promise<{
|
425
|
+
errors?: any[];
|
426
|
+
parsed: TType['internal'];
|
427
|
+
}>;
|
428
|
+
/**
|
429
|
+
* This function is used to transform the value to the representation without validating it.
|
430
|
+
* This is useful when you want to return a data from a query directly to the user. But for example
|
431
|
+
* you are returning the data of a user, you can clean the password or any other sensitive data.
|
432
|
+
*
|
433
|
+
* @example
|
434
|
+
* ```typescript
|
435
|
+
* import * as p from '@palmares/schemas';
|
436
|
+
*
|
437
|
+
* const userSchema = p.object({
|
438
|
+
* id: p.number().optional(),
|
439
|
+
* name: p.string(),
|
440
|
+
* email: p.string().email(),
|
441
|
+
* password: p.string().optional()
|
442
|
+
* }).toRepresentation(async (value) => {
|
443
|
+
* return {
|
444
|
+
* id: value.id,
|
445
|
+
* name: value.name,
|
446
|
+
* email: value.email
|
447
|
+
* }
|
448
|
+
* });
|
449
|
+
*
|
450
|
+
* const user = await userSchema.data({
|
451
|
+
* id: 1,
|
452
|
+
* name: 'John Doe',
|
453
|
+
* email: 'john@gmail.com',
|
454
|
+
* password: '123456'
|
455
|
+
* });
|
456
|
+
* ```
|
457
|
+
*/
|
458
|
+
data(value: TType['output']): Promise<TType['representation']>;
|
459
|
+
instanceOf(args: Schema['__type']): Schema<{
|
460
|
+
input: TType["input"];
|
461
|
+
validate: TType["validate"];
|
462
|
+
internal: TType["internal"];
|
463
|
+
output: TType["output"];
|
464
|
+
representation: TType["representation"];
|
465
|
+
}, TDefinitions>;
|
466
|
+
/**
|
467
|
+
* This function is used to add a default value to the schema. If the value is either undefined or null, the default value will be used.
|
468
|
+
*
|
469
|
+
* @example
|
470
|
+
* ```typescript
|
471
|
+
* import * as p from '@palmares/schemas';
|
472
|
+
*
|
473
|
+
* const numberSchema = p.number().default(0);
|
474
|
+
*
|
475
|
+
* const { errors, parsed } = await numberSchema.parse(undefined);
|
476
|
+
*
|
477
|
+
* console.log(parsed); // 0
|
478
|
+
* ```
|
479
|
+
*/
|
480
|
+
default<TDefaultValue extends TType['input'] | (() => Promise<TType['input']>)>(defaultValueOrFunction: TDefaultValue): Schema<{
|
481
|
+
input: TType["input"] | undefined | null;
|
482
|
+
validate: TType["validate"];
|
483
|
+
internal: TType["internal"];
|
484
|
+
output: TType["output"] | undefined | null;
|
485
|
+
representation: TType["representation"];
|
486
|
+
}, TDefinitions>;
|
487
|
+
/**
|
488
|
+
* This function let's you customize the schema your own way. After we translate the schema on the adapter we call this function to let you customize
|
489
|
+
* the custom schema your own way. Our API does not support passthrough? No problem, you can use this function to customize the zod schema.
|
490
|
+
*
|
491
|
+
* @example
|
492
|
+
* ```typescript
|
493
|
+
* import * as p from '@palmares/schemas';
|
494
|
+
*
|
495
|
+
* const numberSchema = p.number().extends((schema) => {
|
496
|
+
* return schema.nonnegative();
|
497
|
+
* });
|
498
|
+
*
|
499
|
+
* const { errors, parsed } = await numberSchema.parse(-1);
|
500
|
+
*
|
501
|
+
* console.log(errors); // [{ isValid: false, code: 'nonnegative', message: 'The number should be nonnegative', path: [] }]
|
502
|
+
* ```
|
503
|
+
*
|
504
|
+
* @param callback - The callback that will be called to customize the schema.
|
505
|
+
* @param toStringCallback - The callback that will be called to transform the schema to a string when you want to compile the underlying schema
|
506
|
+
* to a string so you can save it for future runs.
|
507
|
+
*
|
508
|
+
* @returns The schema.
|
509
|
+
*/
|
510
|
+
extends(callback: (schema: Awaited<ReturnType<NonNullable<TDefinitions['schemaAdapter'][TDefinitions['schemaType']]>['translate']>>) => Awaited<ReturnType<NonNullable<TDefinitions['schemaAdapter'][TDefinitions['schemaType']]>['translate']>>, toStringCallback?: (schemaAsString: string) => string): this;
|
511
|
+
/**
|
512
|
+
* This function is used to transform the value to the representation of the schema. When using the {@link data} function. With this function you have full
|
513
|
+
* control to add data cleaning for example, transforming the data and whatever. Another use case is when you want to return deeply nested recursive data.
|
514
|
+
* The schema maps to itself.
|
515
|
+
*
|
516
|
+
* @example
|
517
|
+
* ```typescript
|
518
|
+
* import * as p from '@palmares/schemas';
|
519
|
+
*
|
520
|
+
* const recursiveSchema = p.object({
|
521
|
+
* id: p.number().optional(),
|
522
|
+
* name: p.string(),
|
523
|
+
* }).toRepresentation(async (value) => {
|
524
|
+
* return {
|
525
|
+
* id: value.id,
|
526
|
+
* name: value.name,
|
527
|
+
* children: await Promise.all(value.children.map(async (child) => await recursiveSchema.data(child)))
|
528
|
+
* }
|
529
|
+
* });
|
530
|
+
*
|
531
|
+
* const data = await recursiveSchema.data({
|
532
|
+
* id: 1,
|
533
|
+
* name: 'John Doe',
|
534
|
+
* });
|
535
|
+
* ```
|
536
|
+
*
|
537
|
+
* @example
|
538
|
+
* ```
|
539
|
+
* import * as p from '@palmares/schemas';
|
540
|
+
*
|
541
|
+
* const colorToRGBSchema = p.string().toRepresentation(async (value) => {
|
542
|
+
* switch (value) {
|
543
|
+
* case 'red': return { r: 255, g: 0, b: 0 };
|
544
|
+
* case 'green': return { r: 0, g: 255, b: 0 };
|
545
|
+
* case 'blue': return { r: 0, g: 0, b: 255 };
|
546
|
+
* default: return { r: 0, g: 0, b: 0 };
|
547
|
+
* }
|
548
|
+
* });
|
549
|
+
* ```
|
550
|
+
* @param toRepresentationCallback - The callback that will be called to transform the value to the representation.
|
551
|
+
* @param options - Options for the toRepresentation function.
|
552
|
+
* @param options.after - Whether the toRepresentationCallback should be called after the existing toRepresentationCallback. Defaults to true.
|
553
|
+
* @param options.before - Whether the toRepresentationCallback should be called before the existing toRepresentationCallback. Defaults to true.
|
554
|
+
*
|
555
|
+
* @returns The schema with a new return type
|
556
|
+
*/
|
557
|
+
toRepresentation<TRepresentation>(toRepresentationCallback: (value: TType['representation']) => Promise<TRepresentation>, options?: {
|
558
|
+
after?: boolean;
|
559
|
+
before?: boolean;
|
560
|
+
}): Schema<{
|
561
|
+
input: TType["input"];
|
562
|
+
validate: TType["validate"];
|
563
|
+
internal: TType["internal"];
|
564
|
+
output: TType["output"];
|
565
|
+
representation: TRepresentation;
|
566
|
+
}, TDefinitions>;
|
567
|
+
/**
|
568
|
+
* This function is used to transform the value to the internal representation of the schema. This is useful when you want to transform the value
|
569
|
+
* to a type that the schema adapter can understand. For example, you might want to transform a string to a date. This is the function you use.
|
570
|
+
*
|
571
|
+
* @example
|
572
|
+
* ```typescript
|
573
|
+
* import * as p from '@palmares/schemas';
|
574
|
+
*
|
575
|
+
* const dateSchema = p.string().toInternal((value) => {
|
576
|
+
* return new Date(value);
|
577
|
+
* });
|
578
|
+
*
|
579
|
+
* const date = await dateSchema.parse('2021-01-01');
|
580
|
+
*
|
581
|
+
* console.log(date); // Date object
|
582
|
+
*
|
583
|
+
* const rgbToColorSchema = p.object({
|
584
|
+
* r: p.number().min(0).max(255),
|
585
|
+
* g: p.number().min(0).max(255),
|
586
|
+
* b: p.number().min(0).max(255),
|
587
|
+
* }).toInternal(async (value) => {
|
588
|
+
* if (value.r === 255 && value.g === 0 && value.b === 0) return 'red';
|
589
|
+
* if (value.r === 0 && value.g === 255 && value.b === 0) return 'green';
|
590
|
+
* if (value.r === 0 && value.g === 0 && value.b === 255) return 'blue';
|
591
|
+
* return `rgb(${value.r}, ${value.g}, ${value.b})`;
|
592
|
+
* });
|
593
|
+
* ```
|
594
|
+
*
|
595
|
+
* @param toInternalCallback - The callback that will be called to transform the value to the internal representation.
|
596
|
+
*
|
597
|
+
* @returns The schema with a new return type.
|
598
|
+
*/
|
599
|
+
toInternal<TInternal>(toInternalCallback: (value: TType['validate']) => Promise<TInternal>): Schema<{
|
600
|
+
input: TType["input"];
|
601
|
+
validate: TType["validate"];
|
602
|
+
internal: TInternal;
|
603
|
+
output: TType["output"];
|
604
|
+
representation: TType["representation"];
|
605
|
+
}, TDefinitions>;
|
606
|
+
/**
|
607
|
+
* Called before the validation of the schema. Let's say that you want to validate a date that might receive a string, you can convert that string to a date
|
608
|
+
* here BEFORE the validation. This pretty much transforms the value to a type that the schema adapter can understand.
|
609
|
+
*
|
610
|
+
* @example
|
611
|
+
* ```
|
612
|
+
* import * as p from '@palmares/schemas';
|
613
|
+
* import * as z from 'zod';
|
614
|
+
*
|
615
|
+
* const customRecordToMapSchema = p.schema().appendSchema(z.map()).toValidate(async (value) => {
|
616
|
+
* return new Map(value); // Before validating we transform the value to a map.
|
617
|
+
* });
|
618
|
+
*
|
619
|
+
* const { errors, parsed } = await customRecordToMapSchema.parse({ key: 'value' });
|
620
|
+
* ```
|
621
|
+
*
|
622
|
+
* @param toValidateCallback - The callback that will be called to validate the value.
|
623
|
+
*
|
624
|
+
* @returns The schema with a new return type.
|
625
|
+
*/
|
626
|
+
toValidate<TValidate>(toValidateCallback: (value: TType['input']) => Promise<TValidate> | TValidate): Schema<{
|
627
|
+
input: TType["input"];
|
628
|
+
validate: TValidate;
|
629
|
+
internal: TType["internal"];
|
630
|
+
output: TType["output"];
|
631
|
+
representation: TType["representation"];
|
632
|
+
}, TDefinitions>;
|
633
|
+
/**
|
634
|
+
* Used to transform the given schema on a stringfied version of the adapter.
|
635
|
+
*/
|
636
|
+
compile(adapter: SchemaAdapter): Promise<string[]>;
|
637
|
+
static new<TType extends {
|
638
|
+
input: any;
|
639
|
+
output: any;
|
640
|
+
internal: any;
|
641
|
+
representation: any;
|
642
|
+
validate: any;
|
643
|
+
}>(..._args: any[]): Schema<TType>;
|
644
|
+
}
|
645
|
+
export declare const schema: typeof Schema.new;
|
646
|
+
//# sourceMappingURL=schema.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/schema/schema.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,uBAAuB,EAEvB,oCAAoC,EACrC,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,aAAa,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,SAAS,MAAM,qBAAqB,CAAC;AAEjD,MAAM,CAAC,OAAO,OAAO,MAAM,CACzB,KAAK,SAAS;IACZ,KAAK,EAAE,GAAG,CAAC;IACX,QAAQ,EAAE,GAAG,CAAC;IACd,QAAQ,EAAE,GAAG,CAAC;IACd,MAAM,EAAE,GAAG,CAAC;IACZ,cAAc,EAAE,GAAG,CAAC;CACrB,GAAG;IACF,KAAK,EAAE,GAAG,CAAC;IACX,QAAQ,EAAE,GAAG,CAAC;IACd,QAAQ,EAAE,GAAG,CAAC;IACd,MAAM,EAAE,GAAG,CAAC;IACZ,cAAc,EAAE,GAAG,CAAC;CACrB,EACD,YAAY,SAAS,uBAAuB,GAAG,uBAAuB;IAQtE,SAAS,CAAC,2BAA2B,EAAE,GAAG,CACxC,MAAM,EACN,CACE,YAAY,EAAE,aAAa,EAC3B,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG;QACzB,mBAAmB,EAAE,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