@rpcbase/db 0.1.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.
- package/README.md +0 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +649 -0
- package/dist/models/Tenant.d.ts +10 -0
- package/dist/models/Tenant.d.ts.map +1 -0
- package/dist/models/User.d.ts +14 -0
- package/dist/models/User.d.ts.map +1 -0
- package/dist/models/index.d.ts +3 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/schema/assertions/assertions.d.ts +20 -0
- package/dist/schema/assertions/assertions.d.ts.map +1 -0
- package/dist/schema/assertions/constructor.d.ts +10 -0
- package/dist/schema/assertions/constructor.d.ts.map +1 -0
- package/dist/schema/assertions/custom.d.ts +6 -0
- package/dist/schema/assertions/custom.d.ts.map +1 -0
- package/dist/schema/assertions/instanceOf.d.ts +10 -0
- package/dist/schema/assertions/instanceOf.d.ts.map +1 -0
- package/dist/schema/assertions/staticNames.d.ts +10 -0
- package/dist/schema/assertions/staticNames.d.ts.map +1 -0
- package/dist/schema/assertions/types.d.ts +17 -0
- package/dist/schema/assertions/types.d.ts.map +1 -0
- package/dist/schema/extension.d.ts +66 -0
- package/dist/schema/extension.d.ts.map +1 -0
- package/dist/schema/index.d.ts +73 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.test.d.ts +2 -0
- package/dist/schema/index.test.d.ts.map +1 -0
- package/dist/schema/mongoose.types.d.ts +93 -0
- package/dist/schema/mongoose.types.d.ts.map +1 -0
- package/dist/setupFile.d.ts +2 -0
- package/dist/setupFile.d.ts.map +1 -0
- package/package.json +65 -0
package/README.md
ADDED
|
File without changes
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,649 @@
|
|
|
1
|
+
import { Schema, isValidObjectId, Types, SchemaTypes } from "mongoose";
|
|
2
|
+
import { z, ZodMap, ZodRecord, ZodAny, ZodUnion, ZodNullable, ZodOptional, ZodDefault, ZodDate, ZodEnum, ZodBoolean, ZodArray, ZodObject, ZodNumber, ZodString } from "zod";
|
|
3
|
+
export * from "zod";
|
|
4
|
+
import { z as z2 } from "zod";
|
|
5
|
+
const ZUser = z.object({
|
|
6
|
+
email: z.string().email().optional(),
|
|
7
|
+
password: z.string(),
|
|
8
|
+
name: z.string().optional(),
|
|
9
|
+
phone: z.string().optional(),
|
|
10
|
+
tenants: z.array(z.string()),
|
|
11
|
+
email_verification_code: z.string().length(6).optional(),
|
|
12
|
+
email_verification_expires_at: z.date().optional()
|
|
13
|
+
});
|
|
14
|
+
const UserSchema = new Schema({
|
|
15
|
+
email: { type: String, unique: true, sparse: true },
|
|
16
|
+
phone: { type: String, unique: true, sparse: true },
|
|
17
|
+
password: { type: String, required: true },
|
|
18
|
+
name: String,
|
|
19
|
+
tenants: { type: [String], index: true, required: true },
|
|
20
|
+
email_verification_code: { type: String, required: false },
|
|
21
|
+
email_verification_expires_at: { type: Date, required: false }
|
|
22
|
+
});
|
|
23
|
+
const ZTenant = z.object({
|
|
24
|
+
tenant_id: z.string(),
|
|
25
|
+
parent_tenant_id: z.string().optional(),
|
|
26
|
+
name: z.string().optional()
|
|
27
|
+
});
|
|
28
|
+
const TenantSchema = new Schema({
|
|
29
|
+
tenant_id: { type: String, required: true, unique: true, index: true },
|
|
30
|
+
parent_tenant_id: { type: String },
|
|
31
|
+
name: { type: String }
|
|
32
|
+
});
|
|
33
|
+
const zmAssert$4 = {
|
|
34
|
+
string(f) {
|
|
35
|
+
return f.constructor.name === "ZodString";
|
|
36
|
+
},
|
|
37
|
+
number(f) {
|
|
38
|
+
return f.constructor.name === "ZodNumber";
|
|
39
|
+
},
|
|
40
|
+
object(f) {
|
|
41
|
+
return f.constructor.name === "ZodObject";
|
|
42
|
+
},
|
|
43
|
+
array(f) {
|
|
44
|
+
return f.constructor.name === "ZodArray";
|
|
45
|
+
},
|
|
46
|
+
boolean(f) {
|
|
47
|
+
return f.constructor.name === "ZodBoolean";
|
|
48
|
+
},
|
|
49
|
+
enumerable(f) {
|
|
50
|
+
return f.constructor.name === "ZodEnum";
|
|
51
|
+
},
|
|
52
|
+
date(f) {
|
|
53
|
+
return f.constructor.name === "ZodDate";
|
|
54
|
+
},
|
|
55
|
+
def(f) {
|
|
56
|
+
return f.constructor.name === "ZodDefault";
|
|
57
|
+
},
|
|
58
|
+
optional(f) {
|
|
59
|
+
return f.constructor.name === "ZodOptional";
|
|
60
|
+
},
|
|
61
|
+
nullable(f) {
|
|
62
|
+
return f.constructor.name === "ZodNullable";
|
|
63
|
+
},
|
|
64
|
+
union(f) {
|
|
65
|
+
return f.constructor.name === "ZodUnion";
|
|
66
|
+
},
|
|
67
|
+
any(f) {
|
|
68
|
+
return f.constructor.name === "ZodAny";
|
|
69
|
+
},
|
|
70
|
+
mapOrRecord(f) {
|
|
71
|
+
return f.constructor.name === "ZodMap" || f.constructor.name === "ZodRecord";
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const zmAssertIds = {
|
|
75
|
+
objectId(f) {
|
|
76
|
+
return "__zm_type" in f && f.__zm_type === "ObjectId";
|
|
77
|
+
},
|
|
78
|
+
uuid(f) {
|
|
79
|
+
return "__zm_type" in f && f.__zm_type === "UUID";
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const zmAssert$3 = {
|
|
83
|
+
string(f) {
|
|
84
|
+
return f instanceof ZodString;
|
|
85
|
+
},
|
|
86
|
+
number(f) {
|
|
87
|
+
return f instanceof ZodNumber;
|
|
88
|
+
},
|
|
89
|
+
object(f) {
|
|
90
|
+
return f instanceof ZodObject;
|
|
91
|
+
},
|
|
92
|
+
array(f) {
|
|
93
|
+
return f instanceof ZodArray;
|
|
94
|
+
},
|
|
95
|
+
boolean(f) {
|
|
96
|
+
return f instanceof ZodBoolean;
|
|
97
|
+
},
|
|
98
|
+
enumerable(f) {
|
|
99
|
+
return f instanceof ZodEnum;
|
|
100
|
+
},
|
|
101
|
+
date(f) {
|
|
102
|
+
return f instanceof ZodDate;
|
|
103
|
+
},
|
|
104
|
+
def(f) {
|
|
105
|
+
return f instanceof ZodDefault;
|
|
106
|
+
},
|
|
107
|
+
optional(f) {
|
|
108
|
+
return f instanceof ZodOptional;
|
|
109
|
+
},
|
|
110
|
+
nullable(f) {
|
|
111
|
+
return f instanceof ZodNullable;
|
|
112
|
+
},
|
|
113
|
+
union(f) {
|
|
114
|
+
return f instanceof ZodUnion;
|
|
115
|
+
},
|
|
116
|
+
any(f) {
|
|
117
|
+
return f instanceof ZodAny;
|
|
118
|
+
},
|
|
119
|
+
mapOrRecord(f) {
|
|
120
|
+
return f instanceof ZodMap || f instanceof ZodRecord;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const zmAssert$2 = {
|
|
124
|
+
string(f) {
|
|
125
|
+
return "__zm_type" in f && f.__zm_type === "String";
|
|
126
|
+
},
|
|
127
|
+
number(f) {
|
|
128
|
+
return "__zm_type" in f && f.__zm_type === "Number";
|
|
129
|
+
},
|
|
130
|
+
object(f) {
|
|
131
|
+
return "__zm_type" in f && f.__zm_type === "Object";
|
|
132
|
+
},
|
|
133
|
+
array(f) {
|
|
134
|
+
return "__zm_type" in f && f.__zm_type === "Array";
|
|
135
|
+
},
|
|
136
|
+
boolean(f) {
|
|
137
|
+
return "__zm_type" in f && f.__zm_type === "Boolean";
|
|
138
|
+
},
|
|
139
|
+
enumerable(f) {
|
|
140
|
+
return "__zm_type" in f && f.__zm_type === "Enum";
|
|
141
|
+
},
|
|
142
|
+
date(f) {
|
|
143
|
+
return "__zm_type" in f && f.__zm_type === "Date";
|
|
144
|
+
},
|
|
145
|
+
def(f) {
|
|
146
|
+
return "__zm_type" in f && f.__zm_type === "Default";
|
|
147
|
+
},
|
|
148
|
+
optional(f) {
|
|
149
|
+
return "__zm_type" in f && f.__zm_type === "Optional";
|
|
150
|
+
},
|
|
151
|
+
nullable(f) {
|
|
152
|
+
return "__zm_type" in f && f.__zm_type === "Nullable";
|
|
153
|
+
},
|
|
154
|
+
union(f) {
|
|
155
|
+
return "__zm_type" in f && f.__zm_type === "Union";
|
|
156
|
+
},
|
|
157
|
+
any(f) {
|
|
158
|
+
return "__zm_type" in f && f.__zm_type === "Any";
|
|
159
|
+
},
|
|
160
|
+
mapOrRecord(f) {
|
|
161
|
+
return "__zm_type" in f && (f.__zm_type === "Map" || f.__zm_type === "Record");
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
const assertions = [zmAssert$4, zmAssert$3, zmAssert$2];
|
|
165
|
+
const zmAssert = Object.keys(zmAssert$4).map((key) => key).reduce((acc, key) => {
|
|
166
|
+
acc[key] = (f) => {
|
|
167
|
+
return assertions.some((assertion) => assertion[key](f));
|
|
168
|
+
};
|
|
169
|
+
return acc;
|
|
170
|
+
}, {});
|
|
171
|
+
const zmAssert$1 = {
|
|
172
|
+
...zmAssert,
|
|
173
|
+
...zmAssertIds
|
|
174
|
+
};
|
|
175
|
+
let zod_extended = false;
|
|
176
|
+
const isSchemaCandidate = (value) => {
|
|
177
|
+
return Boolean(value && typeof value === "object" && "_def" in value);
|
|
178
|
+
};
|
|
179
|
+
const resolveSchemaAndFlag = (self, args, defaultFlag = true) => {
|
|
180
|
+
let schema = isSchemaCandidate(self) ? self : void 0;
|
|
181
|
+
let flag;
|
|
182
|
+
if (args.length > 0) {
|
|
183
|
+
const [firstArg, secondArg] = args;
|
|
184
|
+
if (typeof firstArg === "boolean") flag = firstArg;
|
|
185
|
+
if (typeof secondArg === "boolean") flag = secondArg;
|
|
186
|
+
if (!schema && isSchemaCandidate(firstArg)) {
|
|
187
|
+
schema = firstArg;
|
|
188
|
+
if (typeof secondArg === "boolean") flag = secondArg;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (!schema) return { schema: void 0, flag: defaultFlag };
|
|
192
|
+
if (typeof flag !== "boolean") flag = defaultFlag;
|
|
193
|
+
return { schema, flag };
|
|
194
|
+
};
|
|
195
|
+
const resolveSchemaAndValue = (self, args) => {
|
|
196
|
+
let schema = isSchemaCandidate(self) ? self : void 0;
|
|
197
|
+
let value = args[0];
|
|
198
|
+
if (!schema && isSchemaCandidate(value)) {
|
|
199
|
+
schema = value;
|
|
200
|
+
value = args.length > 1 ? args[1] : void 0;
|
|
201
|
+
}
|
|
202
|
+
return { schema, value };
|
|
203
|
+
};
|
|
204
|
+
function extendZod(z_0) {
|
|
205
|
+
if (zod_extended) return;
|
|
206
|
+
zod_extended = true;
|
|
207
|
+
const UNIQUE_SUPPORT_LIST = [z_0.ZodString, z_0.ZodNumber, z_0.ZodDate];
|
|
208
|
+
for (const type of UNIQUE_SUPPORT_LIST) {
|
|
209
|
+
const proto = type?.prototype;
|
|
210
|
+
if (!proto) continue;
|
|
211
|
+
proto.unique = function unique(...args) {
|
|
212
|
+
const { schema, flag } = resolveSchemaAndFlag(this, args);
|
|
213
|
+
if (!schema) return this;
|
|
214
|
+
schema.__zm_unique = flag;
|
|
215
|
+
if (schema._def && typeof schema._def === "object") {
|
|
216
|
+
schema._def.__zm_unique = flag;
|
|
217
|
+
}
|
|
218
|
+
return schema;
|
|
219
|
+
};
|
|
220
|
+
proto.sparse = function sparse(...args) {
|
|
221
|
+
const { schema, flag } = resolveSchemaAndFlag(this, args);
|
|
222
|
+
if (!schema) return this;
|
|
223
|
+
schema.__zm_sparse = flag;
|
|
224
|
+
if (schema._def && typeof schema._def === "object") {
|
|
225
|
+
schema._def.__zm_sparse = flag;
|
|
226
|
+
}
|
|
227
|
+
return schema;
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
const TypesMap = {
|
|
231
|
+
String: z_0.ZodString,
|
|
232
|
+
Number: z_0.ZodNumber,
|
|
233
|
+
Object: z_0.ZodObject,
|
|
234
|
+
Array: z_0.ZodArray,
|
|
235
|
+
Boolean: z_0.ZodBoolean,
|
|
236
|
+
Enum: z_0.ZodEnum,
|
|
237
|
+
Date: z_0.ZodDate,
|
|
238
|
+
Default: z_0.ZodDefault,
|
|
239
|
+
Optional: z_0.ZodOptional,
|
|
240
|
+
Nullable: z_0.ZodNullable,
|
|
241
|
+
Union: z_0.ZodUnion,
|
|
242
|
+
Any: z_0.ZodAny,
|
|
243
|
+
Map: z_0.ZodMap,
|
|
244
|
+
Record: z_0.ZodRecord,
|
|
245
|
+
Pipe: z_0.ZodPipe
|
|
246
|
+
};
|
|
247
|
+
for (const [key, value] of Object.entries(TypesMap)) {
|
|
248
|
+
if (value?.prototype) {
|
|
249
|
+
value.prototype.__zm_type = key;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
const createId = () => {
|
|
254
|
+
return z.string().refine((v) => isValidObjectId(v), { error: "Invalid ObjectId" }).or(z.instanceof(Types.ObjectId));
|
|
255
|
+
};
|
|
256
|
+
const zId = (ref) => {
|
|
257
|
+
const output = createId();
|
|
258
|
+
const schema = output;
|
|
259
|
+
schema.__zm_type = "ObjectId";
|
|
260
|
+
schema.__zm_ref = ref;
|
|
261
|
+
schema.ref = function ref2(...args) {
|
|
262
|
+
const { schema: target, value } = resolveSchemaAndValue(this, args);
|
|
263
|
+
if (!target || typeof value !== "string") return target ?? this;
|
|
264
|
+
target.__zm_ref = value;
|
|
265
|
+
if (target._def && typeof target._def === "object") {
|
|
266
|
+
target._def.__zm_ref = value;
|
|
267
|
+
}
|
|
268
|
+
return target;
|
|
269
|
+
};
|
|
270
|
+
schema.refPath = function refPath(...args) {
|
|
271
|
+
const { schema: target, value } = resolveSchemaAndValue(this, args);
|
|
272
|
+
if (!target || typeof value !== "string") return target ?? this;
|
|
273
|
+
target.__zm_refPath = value;
|
|
274
|
+
if (target._def && typeof target._def === "object") {
|
|
275
|
+
target._def.__zm_refPath = value;
|
|
276
|
+
}
|
|
277
|
+
return target;
|
|
278
|
+
};
|
|
279
|
+
schema.unique = function unique(...args) {
|
|
280
|
+
const { schema: target, flag } = resolveSchemaAndFlag(this, args);
|
|
281
|
+
if (!target) return this;
|
|
282
|
+
target.__zm_unique = flag;
|
|
283
|
+
if (target._def && typeof target._def === "object") {
|
|
284
|
+
target._def.__zm_unique = flag;
|
|
285
|
+
}
|
|
286
|
+
return target;
|
|
287
|
+
};
|
|
288
|
+
schema.sparse = function sparse(...args) {
|
|
289
|
+
const { schema: target, flag } = resolveSchemaAndFlag(this, args);
|
|
290
|
+
if (!target) return this;
|
|
291
|
+
target.__zm_sparse = flag;
|
|
292
|
+
if (target._def && typeof target._def === "object") {
|
|
293
|
+
target._def.__zm_sparse = flag;
|
|
294
|
+
}
|
|
295
|
+
return target;
|
|
296
|
+
};
|
|
297
|
+
return output;
|
|
298
|
+
};
|
|
299
|
+
const createUUID = () => {
|
|
300
|
+
return z.uuid({ error: "Invalid UUID" }).or(z.instanceof(Types.UUID));
|
|
301
|
+
};
|
|
302
|
+
const zUUID = (ref) => {
|
|
303
|
+
const output = createUUID();
|
|
304
|
+
const schema = output;
|
|
305
|
+
schema.__zm_type = "UUID";
|
|
306
|
+
schema.__zm_ref = ref;
|
|
307
|
+
schema.ref = function ref2(...args) {
|
|
308
|
+
const { schema: target, value } = resolveSchemaAndValue(this, args);
|
|
309
|
+
if (!target || typeof value !== "string") return target ?? this;
|
|
310
|
+
target.__zm_ref = value;
|
|
311
|
+
if (target._def && typeof target._def === "object") {
|
|
312
|
+
target._def.__zm_ref = value;
|
|
313
|
+
}
|
|
314
|
+
return target;
|
|
315
|
+
};
|
|
316
|
+
schema.refPath = function refPath(...args) {
|
|
317
|
+
const { schema: target, value } = resolveSchemaAndValue(this, args);
|
|
318
|
+
if (!target || typeof value !== "string") return target ?? this;
|
|
319
|
+
target.__zm_refPath = value;
|
|
320
|
+
if (target._def && typeof target._def === "object") {
|
|
321
|
+
target._def.__zm_refPath = value;
|
|
322
|
+
}
|
|
323
|
+
return target;
|
|
324
|
+
};
|
|
325
|
+
schema.unique = function unique(...args) {
|
|
326
|
+
const { schema: target, flag } = resolveSchemaAndFlag(this, args);
|
|
327
|
+
if (!target) return this;
|
|
328
|
+
target.__zm_unique = flag;
|
|
329
|
+
if (target._def && typeof target._def === "object") {
|
|
330
|
+
target._def.__zm_unique = flag;
|
|
331
|
+
}
|
|
332
|
+
return target;
|
|
333
|
+
};
|
|
334
|
+
schema.sparse = function sparse(...args) {
|
|
335
|
+
const { schema: target, flag } = resolveSchemaAndFlag(this, args);
|
|
336
|
+
if (!target) return this;
|
|
337
|
+
target.__zm_sparse = flag;
|
|
338
|
+
if (target._def && typeof target._def === "object") {
|
|
339
|
+
target._def.__zm_sparse = flag;
|
|
340
|
+
}
|
|
341
|
+
return target;
|
|
342
|
+
};
|
|
343
|
+
return output;
|
|
344
|
+
};
|
|
345
|
+
function zodSchema(schema, options) {
|
|
346
|
+
const definition = parseObject(schema);
|
|
347
|
+
return new Schema(definition, options);
|
|
348
|
+
}
|
|
349
|
+
function zodSchemaRaw(schema) {
|
|
350
|
+
return parseObject(schema);
|
|
351
|
+
}
|
|
352
|
+
function parseObject(obj) {
|
|
353
|
+
const object = {};
|
|
354
|
+
for (const [key, rawField] of Object.entries(obj.shape)) {
|
|
355
|
+
const field = rawField;
|
|
356
|
+
if (zmAssert$1.object(field)) {
|
|
357
|
+
object[key] = parseObject(field);
|
|
358
|
+
} else {
|
|
359
|
+
const f = parseField(field);
|
|
360
|
+
if (!f) throw new Error(`Unsupported field type: ${field.constructor}`);
|
|
361
|
+
object[key] = f;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return object;
|
|
365
|
+
}
|
|
366
|
+
function extractCustomValidation(field) {
|
|
367
|
+
const checks = field._def?.checks;
|
|
368
|
+
if (!Array.isArray(checks)) return void 0;
|
|
369
|
+
for (const check of checks) {
|
|
370
|
+
if (!check || typeof check !== "object") continue;
|
|
371
|
+
if (check.__zm_validation) {
|
|
372
|
+
return check.__zm_validation;
|
|
373
|
+
}
|
|
374
|
+
const def = check.def;
|
|
375
|
+
if (!def || def.type !== "custom" || typeof def.fn !== "function") continue;
|
|
376
|
+
const validator = (value) => {
|
|
377
|
+
try {
|
|
378
|
+
const result = def.fn(value, {
|
|
379
|
+
ctx: {
|
|
380
|
+
addIssue() {
|
|
381
|
+
return void 0;
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
input: value,
|
|
385
|
+
parsedType: typeof value
|
|
386
|
+
});
|
|
387
|
+
return result !== false;
|
|
388
|
+
} catch {
|
|
389
|
+
return false;
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
let message;
|
|
393
|
+
if (typeof def.error === "function") {
|
|
394
|
+
try {
|
|
395
|
+
const computed = def.error({
|
|
396
|
+
ctx: {
|
|
397
|
+
addIssue() {
|
|
398
|
+
return void 0;
|
|
399
|
+
}
|
|
400
|
+
},
|
|
401
|
+
input: void 0,
|
|
402
|
+
parsedType: "unknown"
|
|
403
|
+
});
|
|
404
|
+
if (typeof computed === "string") {
|
|
405
|
+
message = computed;
|
|
406
|
+
}
|
|
407
|
+
} catch {
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
const validation = {
|
|
411
|
+
validator,
|
|
412
|
+
message
|
|
413
|
+
};
|
|
414
|
+
check.__zm_validation = validation;
|
|
415
|
+
return validation;
|
|
416
|
+
}
|
|
417
|
+
return void 0;
|
|
418
|
+
}
|
|
419
|
+
function parseField(field, required = true, def, refinement) {
|
|
420
|
+
if (!field) return null;
|
|
421
|
+
const customRefinement = extractCustomValidation(field);
|
|
422
|
+
const directRefinement = field.__zm_validation ?? field._def?.__zm_validation ?? customRefinement;
|
|
423
|
+
const currentRefinement = refinement ?? directRefinement;
|
|
424
|
+
if (zmAssert$1.objectId(field)) {
|
|
425
|
+
const ref = field.__zm_ref;
|
|
426
|
+
const refPath = field.__zm_refPath;
|
|
427
|
+
const unique = field.__zm_unique ?? (field._def?.__zm_unique ?? false);
|
|
428
|
+
const sparse = field.__zm_sparse ?? (field._def?.__zm_sparse ?? false);
|
|
429
|
+
return parseObjectId(required, ref, unique, refPath, sparse);
|
|
430
|
+
}
|
|
431
|
+
if (zmAssert$1.uuid(field)) {
|
|
432
|
+
const ref = field.__zm_ref;
|
|
433
|
+
const refPath = field.__zm_refPath;
|
|
434
|
+
const unique = field.__zm_unique ?? (field._def?.__zm_unique ?? false);
|
|
435
|
+
const sparse = field.__zm_sparse ?? (field._def?.__zm_sparse ?? false);
|
|
436
|
+
return parseUUID(required, ref, unique, refPath, sparse);
|
|
437
|
+
}
|
|
438
|
+
if (zmAssert$1.object(field)) {
|
|
439
|
+
return parseObject(field);
|
|
440
|
+
}
|
|
441
|
+
if (zmAssert$1.number(field)) {
|
|
442
|
+
const isUnique = field.__zm_unique ?? field._def?.__zm_unique ?? false;
|
|
443
|
+
const isSparse = field.__zm_sparse ?? field._def?.__zm_sparse ?? false;
|
|
444
|
+
return parseNumber(
|
|
445
|
+
field,
|
|
446
|
+
required,
|
|
447
|
+
def,
|
|
448
|
+
isUnique,
|
|
449
|
+
currentRefinement,
|
|
450
|
+
isSparse
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
if (zmAssert$1.string(field)) {
|
|
454
|
+
const isUnique = field.__zm_unique ?? field._def?.__zm_unique ?? false;
|
|
455
|
+
const isSparse = field.__zm_sparse ?? field._def?.__zm_sparse ?? false;
|
|
456
|
+
return parseString(
|
|
457
|
+
field,
|
|
458
|
+
required,
|
|
459
|
+
def,
|
|
460
|
+
isUnique,
|
|
461
|
+
currentRefinement,
|
|
462
|
+
isSparse
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
if (zmAssert$1.enumerable(field)) {
|
|
466
|
+
const enumValues = Array.isArray(field.options) ? field.options : Object.values(field.enum ?? {});
|
|
467
|
+
return parseEnum(enumValues, required, def);
|
|
468
|
+
}
|
|
469
|
+
if (zmAssert$1.boolean(field)) {
|
|
470
|
+
return parseBoolean(required, def);
|
|
471
|
+
}
|
|
472
|
+
if (zmAssert$1.date(field)) {
|
|
473
|
+
const isUnique = field.__zm_unique ?? field._def?.__zm_unique ?? false;
|
|
474
|
+
const isSparse = field.__zm_sparse ?? field._def?.__zm_sparse ?? false;
|
|
475
|
+
return parseDate(
|
|
476
|
+
required,
|
|
477
|
+
def,
|
|
478
|
+
currentRefinement,
|
|
479
|
+
isUnique,
|
|
480
|
+
isSparse
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
if (zmAssert$1.array(field)) {
|
|
484
|
+
return parseArray(
|
|
485
|
+
required,
|
|
486
|
+
field.element,
|
|
487
|
+
def
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
if (zmAssert$1.def(field)) {
|
|
491
|
+
const defaultValue = typeof field._def.defaultValue === "function" ? field._def.defaultValue() : field._def.defaultValue;
|
|
492
|
+
return parseField(
|
|
493
|
+
field._def.innerType,
|
|
494
|
+
required,
|
|
495
|
+
defaultValue,
|
|
496
|
+
currentRefinement
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
if (zmAssert$1.optional(field)) {
|
|
500
|
+
return parseField(field._def.innerType, false, void 0, currentRefinement);
|
|
501
|
+
}
|
|
502
|
+
if (zmAssert$1.nullable(field)) {
|
|
503
|
+
return parseField(
|
|
504
|
+
field._def.innerType,
|
|
505
|
+
false,
|
|
506
|
+
def || null,
|
|
507
|
+
currentRefinement
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
if (zmAssert$1.union(field)) {
|
|
511
|
+
return parseField(field._def.options[0], required, def, currentRefinement);
|
|
512
|
+
}
|
|
513
|
+
if (zmAssert$1.any(field)) {
|
|
514
|
+
return parseMixed(required, def);
|
|
515
|
+
}
|
|
516
|
+
if (zmAssert$1.mapOrRecord(field)) {
|
|
517
|
+
const mapValueType = field.valueType ?? field.valueSchema;
|
|
518
|
+
const mapKeyType = field.keyType ?? field.keySchema;
|
|
519
|
+
if (!mapKeyType) {
|
|
520
|
+
throw new Error("Unsupported map key type: undefined");
|
|
521
|
+
}
|
|
522
|
+
return parseMap(
|
|
523
|
+
required,
|
|
524
|
+
mapValueType,
|
|
525
|
+
def
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
return null;
|
|
529
|
+
}
|
|
530
|
+
function parseNumber(field, required = true, def, unique = false, validate, sparse = false) {
|
|
531
|
+
const output = {
|
|
532
|
+
type: Number,
|
|
533
|
+
default: def,
|
|
534
|
+
min: field.minValue ?? void 0,
|
|
535
|
+
max: field.maxValue ?? void 0,
|
|
536
|
+
required,
|
|
537
|
+
unique,
|
|
538
|
+
sparse
|
|
539
|
+
};
|
|
540
|
+
if (validate) output.validate = validate;
|
|
541
|
+
return output;
|
|
542
|
+
}
|
|
543
|
+
function parseString(field, required = true, def, unique = false, validate, sparse = false) {
|
|
544
|
+
const output = {
|
|
545
|
+
type: String,
|
|
546
|
+
default: def,
|
|
547
|
+
required,
|
|
548
|
+
minLength: field.minLength ?? void 0,
|
|
549
|
+
maxLength: field.maxLength ?? void 0,
|
|
550
|
+
unique,
|
|
551
|
+
sparse
|
|
552
|
+
};
|
|
553
|
+
if (validate) output.validate = validate;
|
|
554
|
+
return output;
|
|
555
|
+
}
|
|
556
|
+
function parseEnum(values, required = true, def) {
|
|
557
|
+
return {
|
|
558
|
+
type: String,
|
|
559
|
+
unique: false,
|
|
560
|
+
sparse: false,
|
|
561
|
+
default: def,
|
|
562
|
+
enum: values,
|
|
563
|
+
required
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
function parseBoolean(required = true, def) {
|
|
567
|
+
return {
|
|
568
|
+
type: Boolean,
|
|
569
|
+
default: def,
|
|
570
|
+
required
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
function parseDate(required = true, def, validate, unique = false, sparse = false) {
|
|
574
|
+
const output = {
|
|
575
|
+
type: Date,
|
|
576
|
+
default: def,
|
|
577
|
+
required,
|
|
578
|
+
unique,
|
|
579
|
+
sparse
|
|
580
|
+
};
|
|
581
|
+
if (validate) output.validate = validate;
|
|
582
|
+
return output;
|
|
583
|
+
}
|
|
584
|
+
function parseObjectId(required = true, ref, unique = false, refPath, sparse = false) {
|
|
585
|
+
const output = {
|
|
586
|
+
type: SchemaTypes.ObjectId,
|
|
587
|
+
required,
|
|
588
|
+
unique,
|
|
589
|
+
sparse
|
|
590
|
+
};
|
|
591
|
+
if (ref) output.ref = ref;
|
|
592
|
+
if (refPath) output.refPath = refPath;
|
|
593
|
+
return output;
|
|
594
|
+
}
|
|
595
|
+
function parseArray(required = true, element, def) {
|
|
596
|
+
const innerType = parseField(element);
|
|
597
|
+
if (!innerType) throw new Error("Unsupported array type");
|
|
598
|
+
return {
|
|
599
|
+
type: [innerType],
|
|
600
|
+
default: def,
|
|
601
|
+
required
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
function parseMap(required = true, valueType, def) {
|
|
605
|
+
if (!valueType) {
|
|
606
|
+
throw new Error("Unsupported map value type: undefined");
|
|
607
|
+
}
|
|
608
|
+
const pointer = parseField(valueType);
|
|
609
|
+
if (!pointer) {
|
|
610
|
+
const typeName = valueType?.constructor?.name ?? "unknown";
|
|
611
|
+
throw new Error(`Unsupported map value type (${typeName})`);
|
|
612
|
+
}
|
|
613
|
+
return {
|
|
614
|
+
type: Map,
|
|
615
|
+
of: pointer,
|
|
616
|
+
default: def,
|
|
617
|
+
required
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
function parseUUID(required = true, ref, unique = false, refPath, sparse = false) {
|
|
621
|
+
const output = {
|
|
622
|
+
type: SchemaTypes.UUID,
|
|
623
|
+
required,
|
|
624
|
+
unique,
|
|
625
|
+
sparse
|
|
626
|
+
};
|
|
627
|
+
if (ref) output.ref = ref;
|
|
628
|
+
if (refPath) output.refPath = refPath;
|
|
629
|
+
return output;
|
|
630
|
+
}
|
|
631
|
+
function parseMixed(required = true, def) {
|
|
632
|
+
return {
|
|
633
|
+
type: SchemaTypes.Mixed,
|
|
634
|
+
default: def,
|
|
635
|
+
required
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
export {
|
|
639
|
+
TenantSchema,
|
|
640
|
+
UserSchema,
|
|
641
|
+
ZTenant,
|
|
642
|
+
ZUser,
|
|
643
|
+
extendZod,
|
|
644
|
+
z2 as z,
|
|
645
|
+
zId,
|
|
646
|
+
zUUID,
|
|
647
|
+
zodSchema,
|
|
648
|
+
zodSchemaRaw
|
|
649
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Schema } from '../../../vite/node_modules/mongoose';
|
|
2
|
+
import { z } from '../../../vite/node_modules/zod';
|
|
3
|
+
export declare const ZTenant: z.ZodObject<{
|
|
4
|
+
tenant_id: z.ZodString;
|
|
5
|
+
parent_tenant_id: z.ZodOptional<z.ZodString>;
|
|
6
|
+
name: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export type ITenant = z.infer<typeof ZTenant>;
|
|
9
|
+
export declare const TenantSchema: Schema;
|
|
10
|
+
//# sourceMappingURL=Tenant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tenant.d.ts","sourceRoot":"","sources":["../../src/models/Tenant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,OAAO;;;;iBAIlB,CAAA;AAEF,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,CAAC;AAE9C,eAAO,MAAM,YAAY,EAAE,MAIzB,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Schema } from '../../../vite/node_modules/mongoose';
|
|
2
|
+
import { z } from '../../../vite/node_modules/zod';
|
|
3
|
+
export declare const ZUser: z.ZodObject<{
|
|
4
|
+
email: z.ZodOptional<z.ZodString>;
|
|
5
|
+
password: z.ZodString;
|
|
6
|
+
name: z.ZodOptional<z.ZodString>;
|
|
7
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
8
|
+
tenants: z.ZodArray<z.ZodString>;
|
|
9
|
+
email_verification_code: z.ZodOptional<z.ZodString>;
|
|
10
|
+
email_verification_expires_at: z.ZodOptional<z.ZodDate>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export type IUser = z.infer<typeof ZUser>;
|
|
13
|
+
export declare const UserSchema: Schema;
|
|
14
|
+
//# sourceMappingURL=User.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"User.d.ts","sourceRoot":"","sources":["../../src/models/User.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,KAAK;;;;;;;;iBAQhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,KAAK,CAAC,CAAC;AAE1C,eAAO,MAAM,UAAU,EAAE,MAQvB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ZodType } from '../../../../vite/node_modules/zod';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
objectId(f: ZodType<any>): f is ZodType<string>;
|
|
4
|
+
uuid(f: ZodType<any>): f is ZodType<string>;
|
|
5
|
+
string(f: ZodType<any>): f is import('../../../../vite/node_modules/zod').ZodString;
|
|
6
|
+
number(f: ZodType<any>): f is import('../../../../vite/node_modules/zod').ZodNumber;
|
|
7
|
+
object(f: ZodType<any>): f is import('../../../../vite/node_modules/zod').ZodObject<any>;
|
|
8
|
+
array(f: ZodType<any>): f is import('../../../../vite/node_modules/zod').ZodArray<any>;
|
|
9
|
+
boolean(f: ZodType<any>): f is import('../../../../vite/node_modules/zod').ZodBoolean;
|
|
10
|
+
enumerable(f: ZodType<any>): f is import('../../../../vite/node_modules/zod').ZodEnum<any>;
|
|
11
|
+
date(f: ZodType<any>): f is import('../../../../vite/node_modules/zod').ZodDate;
|
|
12
|
+
def(f: ZodType<any>): f is import('../../../../vite/node_modules/zod').ZodDefault<any>;
|
|
13
|
+
optional(f: ZodType<any>): f is import('../../../../vite/node_modules/zod').ZodOptional<any>;
|
|
14
|
+
nullable(f: ZodType<any>): f is import('../../../../vite/node_modules/zod').ZodNullable<any>;
|
|
15
|
+
union(f: ZodType<any>): f is import('../../../../vite/node_modules/zod').ZodUnion<any>;
|
|
16
|
+
any(f: ZodType<any>): f is import('../../../../vite/node_modules/zod').ZodAny;
|
|
17
|
+
mapOrRecord(f: ZodType<any>): f is import('../../../../vite/node_modules/zod').ZodMap<any> | import('../../../../vite/node_modules/zod').ZodRecord<any>;
|
|
18
|
+
};
|
|
19
|
+
export default _default;
|
|
20
|
+
//# sourceMappingURL=assertions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../../../src/schema/assertions/assertions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;;;;;;;;;;;;;;;;;;AAoBlC,wBAGC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IAsserts } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Constructor assertions (CommonJS)
|
|
4
|
+
* @internal
|
|
5
|
+
*
|
|
6
|
+
* Asserts if a Zod type is a specific type
|
|
7
|
+
* by checking the constructor name of it's prototype.
|
|
8
|
+
*/
|
|
9
|
+
export declare const zmAssert: IAsserts;
|
|
10
|
+
//# sourceMappingURL=constructor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constructor.d.ts","sourceRoot":"","sources":["../../../src/schema/assertions/constructor.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,EAAE,QAoDtB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../../src/schema/assertions/custom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAGlC,eAAO,MAAM,WAAW;gBACV,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC;YAIvC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC;CAG5C,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IAsserts } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Instance assertions (ESM)
|
|
4
|
+
* @internal
|
|
5
|
+
*
|
|
6
|
+
* Asserts if a Zod type is a specific type
|
|
7
|
+
* by checking the instance of it's prototype.
|
|
8
|
+
*/
|
|
9
|
+
export declare const zmAssert: IAsserts;
|
|
10
|
+
//# sourceMappingURL=instanceOf.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instanceOf.d.ts","sourceRoot":"","sources":["../../../src/schema/assertions/instanceOf.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,EAAE,QAoDtB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IAsserts } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Static names assertions (Bundlers)
|
|
4
|
+
* @internal
|
|
5
|
+
*
|
|
6
|
+
* Asserts if a Zod type is a specific type
|
|
7
|
+
* by checking the `__zm_type` property of it's prototype.
|
|
8
|
+
*/
|
|
9
|
+
export declare const zmAssert: IAsserts;
|
|
10
|
+
//# sourceMappingURL=staticNames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staticNames.d.ts","sourceRoot":"","sources":["../../../src/schema/assertions/staticNames.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,EAAE,QAoDtB,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ZodAny, ZodArray, ZodBoolean, ZodDate, ZodDefault, ZodEnum, ZodMap, ZodNullable, ZodNumber, ZodObject, ZodOptional, ZodRecord, ZodString, ZodType, ZodUnion } from '../../../../vite/node_modules/zod';
|
|
2
|
+
export interface IAsserts {
|
|
3
|
+
string(f: ZodType<any>): f is ZodString;
|
|
4
|
+
number(f: ZodType<any>): f is ZodNumber;
|
|
5
|
+
object(f: ZodType<any>): f is ZodObject<any>;
|
|
6
|
+
array(f: ZodType<any>): f is ZodArray<any>;
|
|
7
|
+
boolean(f: ZodType<any>): f is ZodBoolean;
|
|
8
|
+
enumerable(f: ZodType<any>): f is ZodEnum<any>;
|
|
9
|
+
date(f: ZodType<any>): f is ZodDate;
|
|
10
|
+
def(f: ZodType<any>): f is ZodDefault<any>;
|
|
11
|
+
optional(f: ZodType<any>): f is ZodOptional<any>;
|
|
12
|
+
nullable(f: ZodType<any>): f is ZodNullable<any>;
|
|
13
|
+
union(f: ZodType<any>): f is ZodUnion<any>;
|
|
14
|
+
any(f: ZodType<any>): f is ZodAny;
|
|
15
|
+
mapOrRecord(f: ZodType<any>): f is ZodMap<any> | ZodRecord<any>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","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AChD,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAA;IAC1C,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,MAAM,CAAA;IACjC,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAA;CAChE"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Types } from '../../../vite/node_modules/mongoose';
|
|
2
|
+
import { z } from '../../../vite/node_modules/zod';
|
|
3
|
+
declare module '../../../vite/node_modules/zod' {
|
|
4
|
+
interface ZodString {
|
|
5
|
+
unique: (arg?: boolean) => ZodString;
|
|
6
|
+
sparse: (arg?: boolean) => ZodString;
|
|
7
|
+
__zm_unique: boolean;
|
|
8
|
+
__zm_sparse: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface ZodNumber {
|
|
11
|
+
unique: (arg?: boolean) => ZodNumber;
|
|
12
|
+
sparse: (arg?: boolean) => ZodNumber;
|
|
13
|
+
__zm_unique: boolean;
|
|
14
|
+
__zm_sparse: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface ZodDate {
|
|
17
|
+
unique: (arg?: boolean) => ZodDate;
|
|
18
|
+
sparse: (arg?: boolean) => ZodDate;
|
|
19
|
+
__zm_unique: boolean;
|
|
20
|
+
__zm_sparse: boolean;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Extends the Zod library with additional functionality.
|
|
25
|
+
*
|
|
26
|
+
* This function modifies the Zod library to add custom validation and uniqueness checks.
|
|
27
|
+
* It ensures that the extension is only applied once.
|
|
28
|
+
*
|
|
29
|
+
* @param z_0 - The Zod library to extend.
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* - Overrides `refine` method to `ZodType` that includes additional metadata for validation.
|
|
33
|
+
* - Overrides `unique` method to `ZodString`, `ZodNumber`, and `ZodDate` to mark them as unique.
|
|
34
|
+
* - Overrides `sparse` method to `ZodString`, `ZodNumber`, and `ZodDate` to mark them as sparse.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import { z } from "zod"
|
|
39
|
+
* import { extendZod } from "./extension"
|
|
40
|
+
*
|
|
41
|
+
* extendZod(z)
|
|
42
|
+
*
|
|
43
|
+
* const schema = z.object({
|
|
44
|
+
* name: z.string().unique()
|
|
45
|
+
* })
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function extendZod(z_0: typeof z): void;
|
|
49
|
+
export type TzmId = ReturnType<typeof createId> & {
|
|
50
|
+
unique: (arg?: boolean) => TzmId;
|
|
51
|
+
sparse: (arg?: boolean) => TzmId;
|
|
52
|
+
ref: (arg: string) => TzmId;
|
|
53
|
+
refPath: (arg: string) => TzmId;
|
|
54
|
+
};
|
|
55
|
+
declare const createId: () => z.ZodUnion<[z.ZodString, z.ZodCustom<Types.ObjectId, Types.ObjectId>]>;
|
|
56
|
+
export declare const zId: (ref?: string) => TzmId;
|
|
57
|
+
export type TzmUUID = ReturnType<typeof createUUID> & {
|
|
58
|
+
unique: (arg?: boolean) => TzmUUID;
|
|
59
|
+
sparse: (arg?: boolean) => TzmUUID;
|
|
60
|
+
ref: (arg: string) => TzmUUID;
|
|
61
|
+
refPath: (arg: string) => TzmUUID;
|
|
62
|
+
};
|
|
63
|
+
declare const createUUID: () => z.ZodUnion<[z.ZodUUID, z.ZodCustom<Types.UUID, Types.UUID>]>;
|
|
64
|
+
export declare const zUUID: (ref?: string) => TzmUUID;
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=extension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../src/schema/extension.ts"],"names":[],"mappings":"AAC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,8EAKb,CAAA;AAED,eAAO,MAAM,GAAG,GAAI,MAAM,MAAM,KAAG,KAoDlC,CAAA;AAED,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG;IACpD,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,OAAO,CAAA;IAClC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,OAAO,CAAA;IAClC,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAA;IAC7B,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAA;CAClC,CAAA;AAED,QAAA,MAAM,UAAU,oEAEf,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM,KAAG,OAoDpC,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Schema, SchemaOptions } from '../../../vite/node_modules/mongoose';
|
|
2
|
+
import { ZodObject, ZodRawShape, z } from '../../../vite/node_modules/zod';
|
|
3
|
+
import type * as zm from "./mongoose.types";
|
|
4
|
+
export * from './extension';
|
|
5
|
+
export * from '../../../vite/node_modules/zod';
|
|
6
|
+
export { z };
|
|
7
|
+
/**
|
|
8
|
+
* Converts a Zod schema to a Mongoose schema
|
|
9
|
+
* @param schema zod schema to parse
|
|
10
|
+
* @returns mongoose schema
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { extendZod, zodSchema } from "@zodyac/zod-mongoose"
|
|
14
|
+
* import { model } from "mongoose"
|
|
15
|
+
* import { z } from "zod"
|
|
16
|
+
*
|
|
17
|
+
* extendZod(z)
|
|
18
|
+
*
|
|
19
|
+
* const zUser = z.object({
|
|
20
|
+
* name: z.string().min(3).max(255),
|
|
21
|
+
* age: z.number().min(18).max(100),
|
|
22
|
+
* active: z.boolean().default(false),
|
|
23
|
+
* access: z.enum(["admin", "user"]).default("user"),
|
|
24
|
+
* companyId: zId("Company"),
|
|
25
|
+
* address: z.object({
|
|
26
|
+
* street: z.string(),
|
|
27
|
+
* city: z.string(),
|
|
28
|
+
* state: z.enum(["CA", "NY", "TX"]),
|
|
29
|
+
* }),
|
|
30
|
+
* tags: z.array(z.string()),
|
|
31
|
+
* createdAt: z.date(),
|
|
32
|
+
* updatedAt: z.date(),
|
|
33
|
+
* })
|
|
34
|
+
*
|
|
35
|
+
* const schema = zodSchema(zDoc)
|
|
36
|
+
* const userModel = model("User", schema)
|
|
37
|
+
*/
|
|
38
|
+
export declare function zodSchema<T extends ZodRawShape>(schema: ZodObject<T>, options?: SchemaOptions<any>): Schema<z.infer<typeof schema>>;
|
|
39
|
+
/**
|
|
40
|
+
* Converts a Zod schema to a raw Mongoose schema object
|
|
41
|
+
* @param schema zod schema to parse
|
|
42
|
+
* @returns mongoose schema
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* import { extendZod, zodSchemaRaw } from "@zodyac/zod-mongoose"
|
|
46
|
+
* import { model, Schema } from "mongoose"
|
|
47
|
+
* import { z } from "zod"
|
|
48
|
+
*
|
|
49
|
+
* extendZod(z)
|
|
50
|
+
*
|
|
51
|
+
* const zUser = z.object({
|
|
52
|
+
* name: z.string().min(3).max(255),
|
|
53
|
+
* age: z.number().min(18).max(100),
|
|
54
|
+
* active: z.boolean().default(false),
|
|
55
|
+
* access: z.enum(["admin", "user"]).default("user"),
|
|
56
|
+
* companyId: zId("Company"),
|
|
57
|
+
* address: z.object({
|
|
58
|
+
* street: z.string(),
|
|
59
|
+
* city: z.string(),
|
|
60
|
+
* state: z.enum(["CA", "NY", "TX"]),
|
|
61
|
+
* }),
|
|
62
|
+
* tags: z.array(z.string()),
|
|
63
|
+
* createdAt: z.date(),
|
|
64
|
+
* updatedAt: z.date(),
|
|
65
|
+
* })
|
|
66
|
+
*
|
|
67
|
+
* const rawSchema = zodSchemaRaw(zDoc)
|
|
68
|
+
* const schema = new Schema(rawSchema)
|
|
69
|
+
* const userModel = model("User", schema)
|
|
70
|
+
*/
|
|
71
|
+
export declare function zodSchemaRaw<T extends ZodRawShape>(schema: ZodObject<T>): zm._Schema<T>;
|
|
72
|
+
export default zodSchema;
|
|
73
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAe,MAAM,UAAU,CAAA;AAClE,OAAO,EAEL,SAAS,EACT,WAAW,EAGX,CAAC,EACF,MAAM,KAAK,CAAA;AAGZ,OAAO,KAAK,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAG3C,cAAc,aAAa,CAAA;AAC3B,cAAc,KAAK,CAAA;AAEnB,OAAO,EAAE,CAAC,EAAE,CAAA;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,WAAW,EAC7C,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,EACpB,OAAO,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,GAC3B,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,CAAC,CAGhC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,WAAW,EAChD,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,GACnB,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAEf;AA6ZD,eAAe,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/schema/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { SchemaDefinition, SchemaTypeOptions, SchemaTypes, Types } from '../../../vite/node_modules/mongoose';
|
|
2
|
+
import { ZodType, z } from '../../../vite/node_modules/zod';
|
|
3
|
+
export interface zID extends z.ZodUnion<[
|
|
4
|
+
z.ZodString,
|
|
5
|
+
z.ZodType<Types.ObjectId, Types.ObjectId>
|
|
6
|
+
]> {
|
|
7
|
+
__zm_type: "ObjectId";
|
|
8
|
+
__zm_ref?: string;
|
|
9
|
+
__zm_refPath?: string;
|
|
10
|
+
ref: (ref: string) => zID;
|
|
11
|
+
unique: (val?: boolean) => zID;
|
|
12
|
+
sparse: (val?: boolean) => zID;
|
|
13
|
+
refPath: (ref: string) => zID;
|
|
14
|
+
}
|
|
15
|
+
export interface zUUID extends z.ZodUnion<[
|
|
16
|
+
z.ZodString,
|
|
17
|
+
z.ZodType<Types.UUID, Types.UUID>
|
|
18
|
+
]> {
|
|
19
|
+
__zm_type: "UUID";
|
|
20
|
+
__zm_ref?: string;
|
|
21
|
+
__zm_refPath?: string;
|
|
22
|
+
unique: (val?: boolean) => zUUID;
|
|
23
|
+
sparse: (val?: boolean) => zUUID;
|
|
24
|
+
ref: (ref: string) => zUUID;
|
|
25
|
+
refPath: (ref: string) => zUUID;
|
|
26
|
+
}
|
|
27
|
+
export interface _Field<T> {
|
|
28
|
+
required: boolean;
|
|
29
|
+
default?: T;
|
|
30
|
+
validate?: {
|
|
31
|
+
validator: (v: T) => boolean;
|
|
32
|
+
message?: string;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface mString extends _Field<string> {
|
|
36
|
+
type: StringConstructor;
|
|
37
|
+
unique: boolean;
|
|
38
|
+
sparse: boolean;
|
|
39
|
+
enum?: string[];
|
|
40
|
+
match?: RegExp;
|
|
41
|
+
minLength?: number;
|
|
42
|
+
maxLength?: number;
|
|
43
|
+
}
|
|
44
|
+
export interface mNumber extends _Field<number> {
|
|
45
|
+
type: NumberConstructor;
|
|
46
|
+
unique: boolean;
|
|
47
|
+
sparse: boolean;
|
|
48
|
+
min?: number;
|
|
49
|
+
max?: number;
|
|
50
|
+
}
|
|
51
|
+
export interface mBoolean extends _Field<boolean> {
|
|
52
|
+
type: BooleanConstructor;
|
|
53
|
+
}
|
|
54
|
+
export interface mDate extends _Field<Date> {
|
|
55
|
+
type: DateConstructor;
|
|
56
|
+
unique: boolean;
|
|
57
|
+
sparse: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface mObjectId extends _Field<Types.ObjectId> {
|
|
60
|
+
type: typeof SchemaTypes.ObjectId;
|
|
61
|
+
unique?: boolean;
|
|
62
|
+
sparse?: boolean;
|
|
63
|
+
ref?: string;
|
|
64
|
+
refPath?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface mUUID extends _Field<Types.UUID> {
|
|
67
|
+
type: typeof SchemaTypes.UUID;
|
|
68
|
+
unique?: boolean;
|
|
69
|
+
sparse?: boolean;
|
|
70
|
+
ref?: string;
|
|
71
|
+
refPath?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface mArray<K> extends _Field<K[]> {
|
|
74
|
+
type: [_Field<K>];
|
|
75
|
+
}
|
|
76
|
+
export interface mMixed<T> extends _Field<T> {
|
|
77
|
+
type: typeof SchemaTypes.Mixed;
|
|
78
|
+
}
|
|
79
|
+
export type Constructor = StringConstructor | NumberConstructor | ObjectConstructor | DateConstructor | BooleanConstructor | BigIntConstructor | typeof SchemaTypes.ObjectId | typeof SchemaTypes.UUID;
|
|
80
|
+
export interface mMap<T, K> extends _Field<Map<T, K>> {
|
|
81
|
+
type: typeof Map;
|
|
82
|
+
of?: _Field<K>;
|
|
83
|
+
}
|
|
84
|
+
export type mField = mString | mNumber | mBoolean | mDate | mObjectId | mUUID | mMixed<unknown> | mArray<unknown> | _Schema<unknown> | mMap<unknown, unknown>;
|
|
85
|
+
export type _Schema<T> = SchemaDefinition & {
|
|
86
|
+
[K in keyof T]: (_Field<T[K]> & SchemaTypeOptions<T[K]>) | _Schema<T[K]>;
|
|
87
|
+
};
|
|
88
|
+
export type UnwrapZodType<T> = T extends ZodType<infer K> ? K : never;
|
|
89
|
+
export type EffectValidator<T> = {
|
|
90
|
+
validator: (v: T) => boolean;
|
|
91
|
+
message?: string;
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=mongoose.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongoose.types.d.ts","sourceRoot":"","sources":["../../src/schema/mongoose.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACvF,OAAO,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGrC,MAAM,WAAW,GACf,SAAQ,CAAC,CAAC,QAAQ,CAAC;IACjB,CAAC,CAAC,SAAS;IACX,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC;CAC1C,CAAC;IACF,SAAS,EAAE,UAAU,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CAAA;IACzB,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,GAAG,CAAA;IAC9B,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,GAAG,CAAA;IAC9B,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CAAA;CAC9B;AAED,MAAM,WAAW,KACf,SAAQ,CAAC,CAAC,QAAQ,CAAC;IACjB,CAAC,CAAC,SAAS;IACX,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC;CAClC,CAAC;IACF,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,KAAK,CAAA;IAChC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AAS,GACT,KAAK,GACL,MAAM,CAAC,OAAO,CAAC,GACf,MAAM,CAAC,OAAO,CAAC,GACf,OAAO,CAAC,OAAO,CAAC,GAChB,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AAE1B,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,gBAAgB,GAAG;KACzC,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACzE,CAAA;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAErE,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC/B,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,CAAA;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupFile.d.ts","sourceRoot":"","sources":["../src/setupFile.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rpcbase/db",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "wireit",
|
|
12
|
+
"test": "vitest run --coverage",
|
|
13
|
+
"release": "wireit"
|
|
14
|
+
},
|
|
15
|
+
"wireit": {
|
|
16
|
+
"build": {
|
|
17
|
+
"command": "../../node_modules/.bin/vite build",
|
|
18
|
+
"files": [
|
|
19
|
+
"src/**/*",
|
|
20
|
+
"../../tsconfig.json",
|
|
21
|
+
"../../scripts/tsconfig.pkg.json",
|
|
22
|
+
"./tsconfig.json",
|
|
23
|
+
"./vite.config.js",
|
|
24
|
+
"../../scripts/vite.config-pkg.js"
|
|
25
|
+
],
|
|
26
|
+
"output": [
|
|
27
|
+
"dist/"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"build-watch": {
|
|
31
|
+
"command": "../../node_modules/.bin/vite build --watch",
|
|
32
|
+
"service": true,
|
|
33
|
+
"dependencies": [
|
|
34
|
+
"build"
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
"release": {
|
|
38
|
+
"command": "../../scripts/publish.js",
|
|
39
|
+
"dependencies": [
|
|
40
|
+
"build"
|
|
41
|
+
],
|
|
42
|
+
"files": [
|
|
43
|
+
"../../scripts/publish.js",
|
|
44
|
+
"package.json",
|
|
45
|
+
"dist/**/*"
|
|
46
|
+
],
|
|
47
|
+
"output": [],
|
|
48
|
+
"env": {
|
|
49
|
+
"NPM_RELEASE_CHANNEL": {
|
|
50
|
+
"external": true
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"mongoose": "^8",
|
|
57
|
+
"zod": "^4"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@types/node": "24.10.1",
|
|
61
|
+
"@vitest/coverage-v8": "4.0.9",
|
|
62
|
+
"mongoose": "8.19.4",
|
|
63
|
+
"vitest": "4.0.9"
|
|
64
|
+
}
|
|
65
|
+
}
|