@hedystia/validations 1.7.0 → 1.7.2

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.
@@ -0,0 +1,311 @@
1
+ /** The Standard Schema interface. */
2
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
3
+ /** The Standard Schema properties. */
4
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
5
+ }
6
+ declare namespace StandardSchemaV1 {
7
+ /** The Standard Schema properties interface. */
8
+ export interface Props<Input = unknown, Output = Input> {
9
+ /** The version number of the standard. */
10
+ readonly version: 1;
11
+ /** The vendor name of the schema library. */
12
+ readonly vendor: string;
13
+ /** Validates unknown input values. */
14
+ readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
15
+ /** Inferred types associated with the schema. */
16
+ readonly types?: Types<Input, Output> | undefined;
17
+ }
18
+ /** The result interface of the validate function. */
19
+ export type Result<Output> = SuccessResult<Output> | FailureResult;
20
+ /** The result interface if validation succeeds. */
21
+ export interface SuccessResult<Output> {
22
+ /** The typed output value. */
23
+ readonly value: Output;
24
+ /** The non-existent issues. */
25
+ readonly issues?: undefined;
26
+ }
27
+ /** The result interface if validation fails. */
28
+ export interface FailureResult {
29
+ /** The issues of failed validation. */
30
+ readonly issues: ReadonlyArray<Issue>;
31
+ }
32
+ /** The issue interface of the failure output. */
33
+ export interface Issue {
34
+ /** The error message of the issue. */
35
+ readonly message: string;
36
+ /** The path of the issue, if any. */
37
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
38
+ }
39
+ /** The path segment interface of the issue. */
40
+ export interface PathSegment {
41
+ /** The key representing a path segment. */
42
+ readonly key: PropertyKey;
43
+ }
44
+ /** The Standard Schema types interface. */
45
+ export interface Types<Input = unknown, Output = Input> {
46
+ /** The input type of the schema. */
47
+ readonly input: Input;
48
+ /** The output type of the schema. */
49
+ readonly output: Output;
50
+ }
51
+ /** Infers the input type of a Standard Schema. */
52
+ export type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
53
+ /** Infers the output type of a Standard Schema. */
54
+ export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
55
+ export { };
56
+ }
57
+
58
+ /* tslint:disable */
59
+ /* eslint-disable */
60
+ declare class HSchema {
61
+ private constructor();
62
+ free(): void;
63
+ [Symbol.dispose](): void;
64
+ static string(): HSchema;
65
+ static number(): HSchema;
66
+ static boolean(): HSchema;
67
+ static any(): HSchema;
68
+ static null_type(): HSchema;
69
+ static literal(val: any): HSchema;
70
+ static object(): HSchema;
71
+ static array(item: HSchema): HSchema;
72
+ static union(schemas_arr: HSchema[]): HSchema;
73
+ static instance_of(ctor: Function, name: string): HSchema;
74
+ optional(): HSchema;
75
+ coerce(): HSchema;
76
+ min_length(n: number): HSchema;
77
+ max_length(n: number): HSchema;
78
+ uuid(): HSchema;
79
+ email(): HSchema;
80
+ regex(pattern: string): HSchema;
81
+ phone(): HSchema;
82
+ domain(require_protocol: boolean): HSchema;
83
+ min(n: number): HSchema;
84
+ max(n: number): HSchema;
85
+ add_prop(key: string, schema: HSchema): void;
86
+ validate(value: any): any;
87
+ get_json_schema(): any;
88
+ }
89
+
90
+ type SchemaPrimitive = "string" | "number" | "boolean" | "any";
91
+ type Simplify<T> = T extends any ? {
92
+ [K in keyof T]: T[K];
93
+ } : never;
94
+ type RequiredKeys<S> = {
95
+ [K in keyof S]: S[K] extends OptionalSchema<any, any> ? never : K;
96
+ }[keyof S];
97
+ type OptionalKeys<S> = {
98
+ [K in keyof S]: S[K] extends OptionalSchema<any, any> ? K : never;
99
+ }[keyof S];
100
+ type SchemaPrimitiveMap = {
101
+ string: string;
102
+ number: number;
103
+ boolean: boolean;
104
+ any: unknown;
105
+ };
106
+ type SchemaType<S> = S extends BaseSchema<any, infer O> ? O : S extends keyof SchemaPrimitiveMap ? SchemaPrimitiveMap[S] : S extends Record<string, any> ? InferSchema<S> : unknown;
107
+ type InferObject<S extends SchemaDefinition> = Simplify<{
108
+ [K in RequiredKeys<S>]: SchemaType<S[K]>;
109
+ } & {
110
+ [K in OptionalKeys<S>]?: SchemaType<S[K]>;
111
+ }>;
112
+ type InferSchema<S> = S extends BaseSchema<any, infer O> ? O : S extends "string" ? string : S extends "number" ? number : S extends "boolean" ? boolean : S extends {
113
+ [key: string]: any;
114
+ } ? {
115
+ [K in keyof S as undefined extends InferSchema<S[K]> ? K : never]?: InferSchema<S[K]>;
116
+ } & {
117
+ [K in keyof S as undefined extends InferSchema<S[K]> ? never : K]: InferSchema<S[K]>;
118
+ } : unknown;
119
+ type SchemaDefinition = {
120
+ [key: string]: SchemaPrimitive | SchemaLike | BaseSchema<any, any>;
121
+ };
122
+ interface SchemaLike {
123
+ [key: string]: SchemaPrimitive | SchemaLike | BaseSchema<any, any>;
124
+ }
125
+ interface Schema<I, O> extends StandardSchemaV1<I, O> {
126
+ optional(): OptionalSchema<I, O | undefined>;
127
+ enum<V extends O & (string | number | boolean), Values extends readonly [V, ...V[]]>(values: Values): UnionSchema<I, Values[number]>;
128
+ array(): ArraySchema<I, O[]>;
129
+ instanceOf<C extends new (...args: any[]) => any>(constructor: C): InstanceOfSchema<I, InstanceType<C>>;
130
+ jsonSchema: any;
131
+ readonly inferred: O;
132
+ }
133
+ declare abstract class BaseSchema<I, O> implements Schema<I, O> {
134
+ protected wasmSchema: HSchema;
135
+ constructor(wasmSchema: HSchema);
136
+ get "~standard"(): StandardSchemaV1.Props<I, O>;
137
+ get jsonSchema(): any;
138
+ get inferred(): O;
139
+ coerce(): this;
140
+ optional(): OptionalSchema<I, O | undefined>;
141
+ array(): ArraySchema<I, O[]>;
142
+ enum<V extends O & (string | number | boolean), Values extends readonly [V, ...V[]]>(values: Values): UnionSchema<I, Values[number]>;
143
+ instanceOf<C extends new (...args: any[]) => any>(constructor: C): InstanceOfSchema<I, InstanceType<C>>;
144
+ }
145
+ declare class StringSchemaType extends BaseSchema<unknown, string> {
146
+ constructor(s?: HSchema);
147
+ minLength(n: number): StringSchemaType;
148
+ maxLength(n: number): StringSchemaType;
149
+ uuid(): StringSchemaType;
150
+ email(): StringSchemaType;
151
+ regex(r: RegExp): StringSchemaType;
152
+ phone(): StringSchemaType;
153
+ domain(r?: boolean): StringSchemaType;
154
+ }
155
+ declare class NumberSchemaType extends BaseSchema<unknown, number> {
156
+ constructor(s?: HSchema);
157
+ min(n: number): NumberSchemaType;
158
+ max(n: number): NumberSchemaType;
159
+ }
160
+ declare class BooleanSchemaType extends BaseSchema<unknown, boolean> {
161
+ constructor();
162
+ }
163
+ declare class NullSchemaType extends BaseSchema<unknown, null> {
164
+ constructor();
165
+ }
166
+ declare class AnySchemaType extends BaseSchema<unknown, any> {
167
+ constructor();
168
+ }
169
+ declare class LiteralSchema<I, T extends string | number | boolean> extends BaseSchema<I, T> {
170
+ readonly value: T;
171
+ constructor(value: T);
172
+ }
173
+ declare class OptionalSchema<I, O> extends BaseSchema<I, O | undefined> {
174
+ readonly innerSchema: BaseSchema<any, any>;
175
+ constructor(ws: HSchema, originalSchema?: BaseSchema<any, any>);
176
+ }
177
+ declare class ArraySchema<I, O extends any[]> extends BaseSchema<I, O> {
178
+ readonly innerSchema: BaseSchema<any, any>;
179
+ constructor(ws: HSchema, originalSchema?: BaseSchema<any, any>);
180
+ }
181
+ declare class ObjectSchemaType<T extends Record<string, unknown>> extends BaseSchema<unknown, T> {
182
+ readonly definition: SchemaDefinition;
183
+ constructor(definition: SchemaDefinition);
184
+ }
185
+ declare class UnionSchema<I, O> extends BaseSchema<I, O> {
186
+ readonly schemas: BaseSchema<any, any>[];
187
+ constructor(schemas: BaseSchema<any, any>[]);
188
+ }
189
+ declare class InstanceOfSchema<I, O> extends BaseSchema<I, O> {
190
+ readonly classConstructor: new (...args: any[]) => any;
191
+ constructor(_baseWasm: HSchema, constructor: new (...args: any[]) => any);
192
+ }
193
+ type AnySchema = SchemaPrimitive | BaseSchema<any, any> | SchemaDefinition;
194
+ /**
195
+ * Collection of helper functions for creating schema types.
196
+ * @returns {typeof h} Schema type helpers
197
+ */
198
+ declare const h: {
199
+ /**
200
+ * Create a string schema type.
201
+ * @returns {StringSchemaType} String schema type
202
+ */
203
+ string: () => StringSchemaType;
204
+ /**
205
+ * Create a number schema type.
206
+ * @returns {NumberSchemaType} Number schema type
207
+ */
208
+ number: () => NumberSchemaType;
209
+ /**
210
+ * Create a boolean schema type.
211
+ * @returns {BooleanSchemaType} Boolean schema type
212
+ */
213
+ boolean: () => BooleanSchemaType;
214
+ /**
215
+ * Create a null schema type.
216
+ * @returns {NullSchemaType} Null schema type
217
+ */
218
+ null: () => NullSchemaType;
219
+ /**
220
+ * Create an "any" schema type.
221
+ * @returns {AnySchemaType} Any schema type
222
+ */
223
+ any: () => AnySchemaType;
224
+ /**
225
+ * Create a literal schema type.
226
+ * @template T
227
+ * @param {T} val - Literal value
228
+ * @returns {LiteralSchema<T>} Literal schema type
229
+ */
230
+ literal: <T extends string | number | boolean>(val: T) => LiteralSchema<unknown, T>;
231
+ /**
232
+ * Create an object schema type.
233
+ * @template S
234
+ * @param {S} [schemaDef] - Optional schema definition
235
+ * @returns {ObjectSchemaType<InferObject<S>>} Object schema type
236
+ */
237
+ object: <S extends SchemaDefinition>(schemaDef?: S) => ObjectSchemaType<InferObject<S>>;
238
+ /**
239
+ * Create an array schema type.
240
+ * @template S
241
+ * @param {S} schema - Schema definition for array items
242
+ * @returns {ArraySchema<unknown, InferSchema<S>>} Array schema type
243
+ */
244
+ array: <S extends AnySchema>(schema: S) => ArraySchema<any, any[]>;
245
+ /**
246
+ * Create an optional schema type.
247
+ * @template S
248
+ * @param {S} schema - Schema to mark as optional
249
+ * @returns {OptionalSchema<unknown, InferSchema<S>>} Optional schema type
250
+ */
251
+ optional: <S extends AnySchema>(schema: S) => OptionalSchema<any, any>;
252
+ /**
253
+ * Create a union schema from multiple schemas.
254
+ * @template S
255
+ * @param {...S} schemas - Schemas to combine
256
+ * @returns {UnionSchema<unknown, InferSchema<S[number]>>} Union schema type
257
+ */
258
+ options: <S extends AnySchema[]>(...schemas: S) => UnionSchema<unknown, InferSchema<S[number]>>;
259
+ /**
260
+ * Create an enum schema from a list of primitive values.
261
+ * @template T
262
+ * @template Values
263
+ * @param {Values} values - Array of allowed literal values
264
+ * @returns {UnionSchema<unknown, Values[number]>} Enum schema type
265
+ * @throws {Error} If the array is empty
266
+ */
267
+ enum: <T extends string | number | boolean, Values extends readonly [T, ...T[]]>(values: Values) => UnionSchema<unknown, Values[number]>;
268
+ /**
269
+ * Create a schema that validates instances of a specific class.
270
+ * @template C
271
+ * @param {C} constructor - Constructor function or class
272
+ * @returns {InstanceOfSchema<unknown, InstanceType<C>>} InstanceOf schema type
273
+ */
274
+ instanceOf: <C extends new (...args: any[]) => any>(constructor: C) => InstanceOfSchema<unknown, InstanceType<C>>;
275
+ /**
276
+ * Create a UUID schema type.
277
+ * @returns {StringSchemaType} UUID schema type
278
+ */
279
+ uuid: () => StringSchemaType;
280
+ /**
281
+ * Create an email schema type.
282
+ * @returns {StringSchemaType} Email schema type
283
+ */
284
+ email: () => StringSchemaType;
285
+ /**
286
+ * Create a regex-validated string schema type.
287
+ * @param {RegExp} r - Regular expression
288
+ * @returns {StringSchemaType} Regex schema type
289
+ */
290
+ regex: (r: RegExp) => StringSchemaType;
291
+ /**
292
+ * Create a phone schema type.
293
+ * @returns {StringSchemaType} Phone schema type
294
+ */
295
+ phone: () => StringSchemaType;
296
+ /**
297
+ * Create a domain schema type.
298
+ * @param {boolean} [req=true] - Whether domain must include http/https
299
+ * @returns {StringSchemaType} Domain schema type
300
+ */
301
+ domain: (req?: boolean) => StringSchemaType;
302
+ /**
303
+ * Convert any schema into a standard schema.
304
+ * @template T
305
+ * @param {AnySchema} schema - Schema to convert
306
+ * @returns {Schema<unknown, T>} Standardized schema
307
+ */
308
+ toStandard: <T>(schema: AnySchema) => Schema<unknown, T>;
309
+ };
310
+
311
+ export { type AnySchema, AnySchemaType, ArraySchema, BaseSchema, BooleanSchemaType, InstanceOfSchema, LiteralSchema, NullSchemaType, NumberSchemaType, ObjectSchemaType, OptionalSchema, StringSchemaType, UnionSchema, h };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";var X=Object.create;var T=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var ee=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty;var te=(e,n)=>()=>(e&&(n=e(e=0)),n);var re=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),v=(e,n)=>{for(var t in n)T(e,t,{get:n[t],enumerable:!0})},P=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of Z(n))!ne.call(e,a)&&a!==t&&T(e,a,{get:()=>n[a],enumerable:!(r=Y(n,a))||r.enumerable});return e};var ae=(e,n,t)=>(t=e!=null?X(ee(e)):{},P(n||!e||!e.__esModule?T(t,"default",{value:e,enumerable:!0}):t,e)),$=e=>P(T({},"__esModule",{value:!0}),e);var H={};v(H,{is_instance_of:()=>se});function se(e,n){return e instanceof n}var U=te(()=>{"use strict"});var Q=re((o,G)=>{"use strict";var D={};D["./snippets/validations-f447b611bd96feb0/inline0.js"]=(U(),$(H));D.__wbindgen_placeholder__=G.exports;function K(e){return e==null}function M(e){let n=typeof e;if(n=="number"||n=="boolean"||e==null)return`${e}`;if(n=="string")return`"${e}"`;if(n=="symbol"){let a=e.description;return a==null?"Symbol":`Symbol(${a})`}if(n=="function"){let a=e.name;return typeof a=="string"&&a.length>0?`Function(${a})`:"Function"}if(Array.isArray(e)){let a=e.length,c="[";a>0&&(c+=M(e[0]));for(let i=1;i<a;i++)c+=", "+M(e[i]);return c+="]",c}let t=/\[object ([^\]]+)\]/.exec(toString.call(e)),r;if(t&&t.length>1)r=t[1];else return toString.call(e);if(r=="Object")try{return"Object("+JSON.stringify(e)+")"}catch{return"Object"}return e instanceof Error?`${e.name}: ${e.message}
2
+ ${e.stack}`:r}var d=0,k=null;function j(){return(k===null||k.byteLength===0)&&(k=new Uint8Array(s.memory.buffer)),k}var g=new TextEncoder;"encodeInto"in g||(g.encodeInto=function(e,n){let t=g.encode(e);return n.set(t),{read:e.length,written:t.length}});function y(e,n,t){if(t===void 0){let h=g.encode(e),p=n(h.length,1)>>>0;return j().subarray(p,p+h.length).set(h),d=h.length,p}let r=e.length,a=n(r,1)>>>0,c=j(),i=0;for(;i<r;i++){let h=e.charCodeAt(i);if(h>127)break;c[a+i]=h}if(i!==r){i!==0&&(e=e.slice(i)),a=t(a,r,r=i+e.length*3,1)>>>0;let h=j().subarray(a+i,a+r),p=g.encodeInto(e,h);i+=p.written,a=t(a,r,i,1)>>>0}return d=i,a}var f=null;function l(){return(f===null||f.buffer.detached===!0||f.buffer.detached===void 0&&f.buffer!==s.memory.buffer)&&(f=new DataView(s.memory.buffer)),f}var q=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});q.decode();function oe(e,n){return q.decode(j().subarray(e,e+n))}function N(e,n){return e=e>>>0,oe(e,n)}function z(e){let n=s.__externref_table_alloc();return s.__wbindgen_externrefs.set(n,e),n}function J(e,n){try{return e.apply(this,n)}catch(t){let r=z(t);s.__wbindgen_exn_store(r)}}function L(e,n){if(!(e instanceof n))throw new Error(`expected instance of ${n.name}`)}function ce(e,n){let t=n(e.length*4,4)>>>0;for(let r=0;r<e.length;r++){let a=z(e[r]);l().setUint32(t+4*r,a,!0)}return d=e.length,t}var W=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>s.__wbg_hschema_free(e>>>0,1)),b=class e{static __wrap(n){n=n>>>0;let t=Object.create(e.prototype);return t.__wbg_ptr=n,W.register(t,t.__wbg_ptr,t),t}static __unwrap(n){return n instanceof e?n.__destroy_into_raw():0}__destroy_into_raw(){let n=this.__wbg_ptr;return this.__wbg_ptr=0,W.unregister(this),n}free(){let n=this.__destroy_into_raw();s.__wbg_hschema_free(n,0)}static string(){let n=s.hschema_string();return e.__wrap(n)}static number(){let n=s.hschema_number();return e.__wrap(n)}static boolean(){let n=s.hschema_boolean();return e.__wrap(n)}static any(){let n=s.hschema_any();return e.__wrap(n)}static null_type(){let n=s.hschema_null_type();return e.__wrap(n)}static literal(n){let t=s.hschema_literal(n);return e.__wrap(t)}static object(){let n=s.hschema_object();return e.__wrap(n)}static array(n){L(n,e);let t=s.hschema_array(n.__wbg_ptr);return e.__wrap(t)}static union(n){let t=ce(n,s.__wbindgen_malloc),r=d,a=s.hschema_union(t,r);return e.__wrap(a)}static instance_of(n,t){let r=y(t,s.__wbindgen_malloc,s.__wbindgen_realloc),a=d,c=s.hschema_instance_of(n,r,a);return e.__wrap(c)}optional(){let n=s.hschema_optional(this.__wbg_ptr);return e.__wrap(n)}coerce(){let n=s.hschema_coerce(this.__wbg_ptr);return e.__wrap(n)}min_length(n){let t=s.hschema_min_length(this.__wbg_ptr,n);return e.__wrap(t)}max_length(n){let t=s.hschema_max_length(this.__wbg_ptr,n);return e.__wrap(t)}uuid(){let n=s.hschema_uuid(this.__wbg_ptr);return e.__wrap(n)}email(){let n=s.hschema_email(this.__wbg_ptr);return e.__wrap(n)}regex(n){let t=y(n,s.__wbindgen_malloc,s.__wbindgen_realloc),r=d,a=s.hschema_regex(this.__wbg_ptr,t,r);return e.__wrap(a)}phone(){let n=s.hschema_phone(this.__wbg_ptr);return e.__wrap(n)}domain(n){let t=s.hschema_domain(this.__wbg_ptr,n);return e.__wrap(t)}min(n){let t=s.hschema_min(this.__wbg_ptr,n);return e.__wrap(t)}max(n){let t=s.hschema_max(this.__wbg_ptr,n);return e.__wrap(t)}add_prop(n,t){let r=y(n,s.__wbindgen_malloc,s.__wbindgen_realloc),a=d;L(t,e),s.hschema_add_prop(this.__wbg_ptr,r,a,t.__wbg_ptr)}validate(n){return s.hschema_validate(this.__wbg_ptr,n)}get_json_schema(){return s.hschema_get_json_schema(this.__wbg_ptr)}};Symbol.dispose&&(b.prototype[Symbol.dispose]=b.prototype.free);o.HSchema=b;o.__wbg___wbindgen_boolean_get_6d5a1ee65bab5f68=function(e){let n=e,t=typeof n=="boolean"?n:void 0;return K(t)?16777215:t?1:0};o.__wbg___wbindgen_debug_string_df47ffb5e35e6763=function(e,n){let t=M(n),r=y(t,s.__wbindgen_malloc,s.__wbindgen_realloc),a=d;l().setInt32(e+4*1,a,!0),l().setInt32(e+4*0,r,!0)};o.__wbg___wbindgen_is_falsy_46b8d2f2aba49112=function(e){return!e};o.__wbg___wbindgen_is_null_5e69f72e906cc57c=function(e){return e===null};o.__wbg___wbindgen_is_object_c818261d21f283a4=function(e){let n=e;return typeof n=="object"&&n!==null};o.__wbg___wbindgen_is_string_fbb76cb2940daafd=function(e){return typeof e=="string"};o.__wbg___wbindgen_is_undefined_2d472862bd29a478=function(e){return e===void 0};o.__wbg___wbindgen_jsval_eq_6b13ab83478b1c50=function(e,n){return e===n};o.__wbg___wbindgen_number_get_a20bf9b85341449d=function(e,n){let t=n,r=typeof t=="number"?t:void 0;l().setFloat64(e+8*1,K(r)?0:r,!0),l().setInt32(e+4*0,!K(r),!0)};o.__wbg___wbindgen_string_get_e4f06c90489ad01b=function(e,n){let t=n,r=typeof t=="string"?t:void 0;var a=K(r)?0:y(r,s.__wbindgen_malloc,s.__wbindgen_realloc),c=d;l().setInt32(e+4*1,c,!0),l().setInt32(e+4*0,a,!0)};o.__wbg___wbindgen_throw_b855445ff6a94295=function(e,n){throw new Error(N(e,n))};o.__wbg_from_a4ad7cbddd0d7135=function(e){return Array.from(e)};o.__wbg_get_7bed016f185add81=function(e,n){return e[n>>>0]};o.__wbg_get_efcb449f58ec27c2=function(){return J(function(e,n){return Reflect.get(e,n)},arguments)};o.__wbg_hschema_unwrap=function(e){return b.__unwrap(e)};o.__wbg_isArray_96e0af9891d0945d=function(e){return Array.isArray(e)};o.__wbg_length_cdd215e10d9dd507=function(e){return e.length};o.__wbg_new_1acc0b6eea89d040=function(){return new Object};o.__wbg_new_e17d9f43105b08be=function(){return new Array};o.__wbg_push_df81a39d04db858c=function(e,n){return e.push(n)};o.__wbg_set_3fda3bac07393de4=function(e,n,t){e[n]=t};o.__wbg_set_c213c871859d6500=function(e,n,t){e[n>>>0]=t};o.__wbg_set_c2abbebe8b9ebee1=function(){return J(function(e,n,t){return Reflect.set(e,n,t)},arguments)};o.__wbindgen_cast_2241b6af4c4b2941=function(e,n){return N(e,n)};o.__wbindgen_cast_d6cd19b81560fd6e=function(e){return e};o.__wbindgen_init_externref_table=function(){let e=s.__wbindgen_externrefs,n=e.grow(4);e.set(0,void 0),e.set(n+0,void 0),e.set(n+1,null),e.set(n+2,!0),e.set(n+3,!1)};var ie=`${__dirname}/validations_bg.wasm`,_e=require("fs").readFileSync(ie),ue=new WebAssembly.Module(_e),s=o.__wasm=new WebAssembly.Instance(ue,D).exports;s.__wbindgen_start()});var me={};v(me,{AnySchemaType:()=>O,ArraySchema:()=>C,BaseSchema:()=>u,BooleanSchemaType:()=>I,InstanceOfSchema:()=>E,LiteralSchema:()=>B,NullSchemaType:()=>A,NumberSchemaType:()=>x,ObjectSchemaType:()=>w,OptionalSchema:()=>F,StringSchemaType:()=>S,UnionSchema:()=>R,h:()=>m});module.exports=$(me);var _=ae(Q()),u=class{wasmSchema;constructor(n){this.wasmSchema=n}get"~standard"(){return{version:1,vendor:"h-schema-rs",validate:n=>this.wasmSchema.validate(n)}}get jsonSchema(){return this.wasmSchema.get_json_schema()}get inferred(){return null}coerce(){return this.wasmSchema=this.wasmSchema.coerce(),this}optional(){return new F(this.wasmSchema.optional(),this)}array(){return new C(_.HSchema.array(this.wasmSchema),this)}enum(n){let t=n.map(r=>m.literal(r));return m.options(...t)}instanceOf(n){return new E(this.wasmSchema,n)}},S=class e extends u{constructor(n=_.HSchema.string()){super(n)}minLength(n){return new e(this.wasmSchema.min_length(n))}maxLength(n){return new e(this.wasmSchema.max_length(n))}uuid(){return new e(this.wasmSchema.uuid())}email(){return new e(this.wasmSchema.email())}regex(n){return new e(this.wasmSchema.regex(n.source))}phone(){return new e(this.wasmSchema.phone())}domain(n=!0){return new e(this.wasmSchema.domain(n))}},x=class e extends u{constructor(n=_.HSchema.number()){super(n)}min(n){return new e(this.wasmSchema.min(n))}max(n){return new e(this.wasmSchema.max(n))}},I=class extends u{constructor(){super(_.HSchema.boolean())}},A=class extends u{constructor(){super(_.HSchema.null_type())}},O=class extends u{constructor(){super(_.HSchema.any())}},B=class extends u{value;constructor(n){super(_.HSchema.literal(n)),this.value=n}},F=class extends u{innerSchema;constructor(n,t){super(n),this.innerSchema=t}},C=class extends u{innerSchema;constructor(n,t){super(n),this.innerSchema=t}},w=class extends u{definition;constructor(n){let t=_.HSchema.object();for(let r in n){let a=n[r],c;a instanceof u?c=a.wasmSchema:typeof a=="string"?a==="string"?c=_.HSchema.string():a==="number"?c=_.HSchema.number():a==="boolean"?c=_.HSchema.boolean():c=_.HSchema.any():c=_.HSchema.any(),t.add_prop(r,c)}super(t),this.definition=n}},R=class extends u{schemas;constructor(n){let t=n.map(r=>r.wasmSchema);super(_.HSchema.union(t)),this.schemas=n}},E=class extends u{classConstructor;constructor(n,t){super(_.HSchema.instance_of(t,t.name)),this.classConstructor=t}};function V(e){return e instanceof u?e:e==="string"?new S:e==="number"?new x:e==="boolean"?new I:typeof e=="object"&&e!==null?new w(e):new O}var m={string:()=>new S,number:()=>new x,boolean:()=>new I,null:()=>new A,any:()=>new O,literal:e=>new B(e),object:e=>new w(e||{}),array:e=>V(e).array(),optional:e=>V(e).optional(),options:(...e)=>{let n=e.map(t=>V(t));return new R(n)},enum:e=>{if(!e||e.length===0)throw new Error("h.enum() requires non-empty array");let n=e.map(t=>m.literal(t));return m.options(...n)},instanceOf:e=>new w({}).instanceOf(e),uuid:()=>m.string().uuid(),email:()=>m.string().email(),regex:e=>m.string().regex(e),phone:()=>m.string().phone(),domain:(e=!0)=>m.string().domain(e),toStandard:e=>V(e)};0&&(module.exports={AnySchemaType,ArraySchema,BaseSchema,BooleanSchemaType,InstanceOfSchema,LiteralSchema,NullSchemaType,NumberSchemaType,ObjectSchemaType,OptionalSchema,StringSchemaType,UnionSchema,h});
Binary file
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@hedystia/validations",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
4
4
  "devDependencies": {
5
5
  "@standard-schema/spec": "^1.0.0",
6
- "@types/bun": "latest",
6
+ "@types/bun": "^1.3.3",
7
7
  "tsup": "^8.3.5"
8
8
  },
9
9
  "peerDependencies": {