@yimingliao/cms 0.0.32 → 0.0.34

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.
@@ -181,7 +181,7 @@ declare function createMultiFileSchema({ z, fileSchema, maxSizeInMb, }: {
181
181
  }): ({ size, extensions, }?: {
182
182
  size?: number;
183
183
  extensions?: string[];
184
- }) => void;
184
+ }) => zod.ZodArray<zod.ZodPipe<zod.ZodCustom<File, File>, zod.ZodTransform<BlobFile, File>>>;
185
185
 
186
186
  declare function createTocItemSchema({ z, schemas, }: {
187
187
  z: ReturnType<typeof createZod>;
@@ -389,60 +389,67 @@ function ogLocale(locale) {
389
389
  }
390
390
 
391
391
  // src/server/infrastructure/zod/create-zod.ts
392
- var patched = false;
393
392
  function createZod({
394
393
  unique,
395
394
  exist
396
395
  }) {
397
- if (patched) return z;
398
- patched = true;
399
396
  const stringProto = z.ZodString.prototype;
400
397
  const emailProto = z.ZodEmail.prototype;
401
- Object.defineProperty(stringProto, "unique", {
402
- configurable: true,
403
- writable: false,
404
- value: function(options) {
405
- return this.refine(async (v) => unique(v, options), {
406
- params: { i18nKey: "validator.unique" }
407
- });
408
- }
409
- });
410
- Object.defineProperty(stringProto, "exist", {
411
- configurable: true,
412
- writable: false,
413
- value: function(options) {
414
- return this.refine(async (v) => exist(v, options), {
415
- params: { i18nKey: "validator.exist" }
416
- });
417
- }
418
- });
419
- Object.defineProperty(stringProto, "bcp47", {
420
- configurable: true,
421
- writable: false,
422
- value: function() {
423
- return this.refine((v) => bcp47(v), {
424
- params: { i18nKey: "validator.bcp47" }
425
- });
426
- }
427
- });
428
- Object.defineProperty(stringProto, "ogLocale", {
429
- configurable: true,
430
- writable: false,
431
- value: function() {
432
- return this.refine((v) => ogLocale(v), {
433
- params: { i18nKey: "validator.og-locale" }
434
- });
435
- }
436
- });
437
- Object.defineProperty(emailProto, "unique", {
438
- configurable: true,
439
- writable: false,
440
- value: function(options) {
441
- return this.refine(async (v) => unique(v, options), {
442
- params: { i18nKey: "validator.unique" }
443
- });
444
- }
445
- });
398
+ if (!stringProto.unique) {
399
+ Object.defineProperty(stringProto, "unique", {
400
+ configurable: true,
401
+ writable: false,
402
+ value: function(options) {
403
+ return this.refine(async (v) => unique(v, options), {
404
+ params: { i18nKey: "validator.unique" }
405
+ });
406
+ }
407
+ });
408
+ }
409
+ if (!stringProto.exist) {
410
+ Object.defineProperty(stringProto, "exist", {
411
+ configurable: true,
412
+ writable: false,
413
+ value: function(options) {
414
+ return this.refine(async (v) => exist(v, options), {
415
+ params: { i18nKey: "validator.exist" }
416
+ });
417
+ }
418
+ });
419
+ }
420
+ if (!stringProto.bcp47) {
421
+ Object.defineProperty(stringProto, "bcp47", {
422
+ configurable: true,
423
+ writable: false,
424
+ value: function() {
425
+ return this.refine((v) => bcp47(v), {
426
+ params: { i18nKey: "validator.bcp47" }
427
+ });
428
+ }
429
+ });
430
+ }
431
+ if (!stringProto.ogLocale) {
432
+ Object.defineProperty(stringProto, "ogLocale", {
433
+ configurable: true,
434
+ writable: false,
435
+ value: function() {
436
+ return this.refine((v) => ogLocale(v), {
437
+ params: { i18nKey: "validator.og-locale" }
438
+ });
439
+ }
440
+ });
441
+ }
442
+ if (!emailProto.unique) {
443
+ Object.defineProperty(emailProto, "unique", {
444
+ configurable: true,
445
+ writable: false,
446
+ value: function(options) {
447
+ return this.refine(async (v) => unique(v, options), {
448
+ params: { i18nKey: "validator.unique" }
449
+ });
450
+ }
451
+ });
452
+ }
446
453
  return z;
447
454
  }
448
455
 
@@ -578,7 +585,7 @@ function createMultiFileSchema({
578
585
  size = maxSizeInMb * SIZE.MB,
579
586
  extensions = []
580
587
  } = {}) {
581
- z2.array(fileSchema({ size, extensions }));
588
+ return z2.array(fileSchema({ size, extensions }));
582
589
  };
583
590
  }
584
591
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yimingliao/cms",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "author": "Yiming Liao",
5
5
  "license": "MIT",
6
6
  "type": "module",