@jsdev_ninja/core 0.12.4 → 0.12.6

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/dist/core.es.js CHANGED
@@ -102,7 +102,7 @@ const h = b.arrayToEnum([
102
102
  "not_multiple_of",
103
103
  "not_finite"
104
104
  ]), at = (r) => JSON.stringify(r, null, 2).replace(/"([^"]+)":/g, "$1:");
105
- class S extends Error {
105
+ class C extends Error {
106
106
  get errors() {
107
107
  return this.issues;
108
108
  }
@@ -139,7 +139,7 @@ class S extends Error {
139
139
  return s(this), n;
140
140
  }
141
141
  static assert(e) {
142
- if (!(e instanceof S))
142
+ if (!(e instanceof C))
143
143
  throw new Error(`Not a ZodError: ${e}`);
144
144
  }
145
145
  toString() {
@@ -161,7 +161,7 @@ class S extends Error {
161
161
  return this.flatten();
162
162
  }
163
163
  }
164
- S.create = (r) => new S(r);
164
+ C.create = (r) => new C(r);
165
165
  const G = (r, e) => {
166
166
  let t;
167
167
  switch (r.code) {
@@ -307,7 +307,7 @@ class T {
307
307
  }
308
308
  const g = Object.freeze({
309
309
  status: "aborted"
310
- }), Y = (r) => ({ status: "dirty", value: r }), C = (r) => ({ status: "valid", value: r }), Oe = (r) => r.status === "aborted", je = (r) => r.status === "dirty", B = (r) => r.status === "valid", se = (r) => typeof Promise < "u" && r instanceof Promise;
310
+ }), Y = (r) => ({ status: "dirty", value: r }), S = (r) => ({ status: "valid", value: r }), Oe = (r) => r.status === "aborted", je = (r) => r.status === "dirty", B = (r) => r.status === "valid", se = (r) => typeof Promise < "u" && r instanceof Promise;
311
311
  function be(r, e, t, n) {
312
312
  if (typeof e == "function" ? r !== e || !0 : !e.has(r)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
313
313
  return e.get(r);
@@ -339,7 +339,7 @@ const Me = (r, e) => {
339
339
  get error() {
340
340
  if (this._error)
341
341
  return this._error;
342
- const t = new S(r.common.issues);
342
+ const t = new C(r.common.issues);
343
343
  return this._error = t, this._error;
344
344
  }
345
345
  };
@@ -591,10 +591,10 @@ function Je(r) {
591
591
  const t = [];
592
592
  return t.push(r.local ? "Z?" : "Z"), r.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
593
593
  }
594
- function Ct(r, e) {
594
+ function St(r, e) {
595
595
  return !!((e === "v4" || !e) && gt.test(r) || (e === "v6" || !e) && _t.test(r));
596
596
  }
597
- function St(r, e) {
597
+ function Ct(r, e) {
598
598
  if (!ht.test(r))
599
599
  return !1;
600
600
  try {
@@ -739,11 +739,11 @@ class I extends _ {
739
739
  validation: "duration",
740
740
  code: d.invalid_string,
741
741
  message: a.message
742
- }), n.dirty()) : a.kind === "ip" ? Ct(e.data, a.version) || (s = this._getOrReturnCtx(e, s), f(s, {
742
+ }), n.dirty()) : a.kind === "ip" ? St(e.data, a.version) || (s = this._getOrReturnCtx(e, s), f(s, {
743
743
  validation: "ip",
744
744
  code: d.invalid_string,
745
745
  message: a.message
746
- }), n.dirty()) : a.kind === "jwt" ? St(e.data, a.alg) || (s = this._getOrReturnCtx(e, s), f(s, {
746
+ }), n.dirty()) : a.kind === "jwt" ? Ct(e.data, a.alg) || (s = this._getOrReturnCtx(e, s), f(s, {
747
747
  validation: "jwt",
748
748
  code: d.invalid_string,
749
749
  message: a.message
@@ -1316,7 +1316,7 @@ class ae extends _ {
1316
1316
  received: n.parsedType
1317
1317
  }), g;
1318
1318
  }
1319
- return C(e.data);
1319
+ return S(e.data);
1320
1320
  }
1321
1321
  }
1322
1322
  ae.create = (r) => new ae({
@@ -1412,7 +1412,7 @@ class xe extends _ {
1412
1412
  received: n.parsedType
1413
1413
  }), g;
1414
1414
  }
1415
- return C(e.data);
1415
+ return S(e.data);
1416
1416
  }
1417
1417
  }
1418
1418
  xe.create = (r) => new xe({
@@ -1429,7 +1429,7 @@ class ie extends _ {
1429
1429
  received: n.parsedType
1430
1430
  }), g;
1431
1431
  }
1432
- return C(e.data);
1432
+ return S(e.data);
1433
1433
  }
1434
1434
  }
1435
1435
  ie.create = (r) => new ie({
@@ -1446,7 +1446,7 @@ class oe extends _ {
1446
1446
  received: n.parsedType
1447
1447
  }), g;
1448
1448
  }
1449
- return C(e.data);
1449
+ return S(e.data);
1450
1450
  }
1451
1451
  }
1452
1452
  oe.create = (r) => new oe({
@@ -1458,7 +1458,7 @@ class X extends _ {
1458
1458
  super(...arguments), this._any = !0;
1459
1459
  }
1460
1460
  _parse(e) {
1461
- return C(e.data);
1461
+ return S(e.data);
1462
1462
  }
1463
1463
  }
1464
1464
  X.create = (r) => new X({
@@ -1470,7 +1470,7 @@ class U extends _ {
1470
1470
  super(...arguments), this._unknown = !0;
1471
1471
  }
1472
1472
  _parse(e) {
1473
- return C(e.data);
1473
+ return S(e.data);
1474
1474
  }
1475
1475
  }
1476
1476
  U.create = (r) => new U({
@@ -1501,7 +1501,7 @@ class ke extends _ {
1501
1501
  received: n.parsedType
1502
1502
  }), g;
1503
1503
  }
1504
- return C(e.data);
1504
+ return S(e.data);
1505
1505
  }
1506
1506
  }
1507
1507
  ke.create = (r) => new ke({
@@ -1894,7 +1894,7 @@ class ce extends _ {
1894
1894
  for (const o of a)
1895
1895
  if (o.result.status === "dirty")
1896
1896
  return t.common.issues.push(...o.ctx.common.issues), o.result;
1897
- const c = a.map((o) => new S(o.ctx.common.issues));
1897
+ const c = a.map((o) => new C(o.ctx.common.issues));
1898
1898
  return f(t, {
1899
1899
  code: d.invalid_union,
1900
1900
  unionErrors: c
@@ -1941,7 +1941,7 @@ class ce extends _ {
1941
1941
  }
1942
1942
  if (a)
1943
1943
  return t.common.issues.push(...a.ctx.common.issues), a.result;
1944
- const o = c.map((l) => new S(l));
1944
+ const o = c.map((l) => new C(l));
1945
1945
  return f(t, {
1946
1946
  code: d.invalid_union,
1947
1947
  unionErrors: o
@@ -1958,7 +1958,7 @@ ce.create = (r, e) => new ce({
1958
1958
  ...v(e)
1959
1959
  });
1960
1960
  const P = (r) => r instanceof le ? P(r.schema) : r instanceof N ? P(r.innerType()) : r instanceof fe ? [r.value] : r instanceof z ? r.options : r instanceof he ? b.objectValues(r.enum) : r instanceof pe ? P(r._def.innerType) : r instanceof ie ? [void 0] : r instanceof oe ? [null] : r instanceof j ? [void 0, ...P(r.unwrap())] : r instanceof F ? [null, ...P(r.unwrap())] : r instanceof Re || r instanceof ye ? P(r.unwrap()) : r instanceof me ? P(r._def.innerType) : [];
1961
- class Ce extends _ {
1961
+ class Se extends _ {
1962
1962
  _parse(e) {
1963
1963
  const { ctx: t } = this._processInputParams(e);
1964
1964
  if (t.parsedType !== h.object)
@@ -2011,7 +2011,7 @@ class Ce extends _ {
2011
2011
  s.set(o, a);
2012
2012
  }
2013
2013
  }
2014
- return new Ce({
2014
+ return new Se({
2015
2015
  typeName: y.ZodDiscriminatedUnion,
2016
2016
  discriminator: e,
2017
2017
  options: t,
@@ -2334,8 +2334,8 @@ class Q extends _ {
2334
2334
  const a = { errorMap: t.common.contextualErrorMap }, c = t.data;
2335
2335
  if (this._def.returns instanceof K) {
2336
2336
  const o = this;
2337
- return C(async function(...l) {
2338
- const u = new S([]), p = await o._def.args.parseAsync(l, a).catch((w) => {
2337
+ return S(async function(...l) {
2338
+ const u = new C([]), p = await o._def.args.parseAsync(l, a).catch((w) => {
2339
2339
  throw u.addIssue(n(l, w)), u;
2340
2340
  }), x = await Reflect.apply(c, this, p);
2341
2341
  return await o._def.returns._def.type.parseAsync(x, a).catch((w) => {
@@ -2344,13 +2344,13 @@ class Q extends _ {
2344
2344
  });
2345
2345
  } else {
2346
2346
  const o = this;
2347
- return C(function(...l) {
2347
+ return S(function(...l) {
2348
2348
  const u = o._def.args.safeParse(l, a);
2349
2349
  if (!u.success)
2350
- throw new S([n(l, u.error)]);
2350
+ throw new C([n(l, u.error)]);
2351
2351
  const p = Reflect.apply(c, this, u.data), x = o._def.returns.safeParse(p, a);
2352
2352
  if (!x.success)
2353
- throw new S([s(p, x.error)]);
2353
+ throw new C([s(p, x.error)]);
2354
2354
  return x.data;
2355
2355
  });
2356
2356
  }
@@ -2451,7 +2451,7 @@ class z extends _ {
2451
2451
  options: n
2452
2452
  }), g;
2453
2453
  }
2454
- return C(e.data);
2454
+ return S(e.data);
2455
2455
  }
2456
2456
  get options() {
2457
2457
  return this._def.values;
@@ -2511,7 +2511,7 @@ class he extends _ {
2511
2511
  options: s
2512
2512
  }), g;
2513
2513
  }
2514
- return C(e.data);
2514
+ return S(e.data);
2515
2515
  }
2516
2516
  get enum() {
2517
2517
  return this._def.values;
@@ -2536,7 +2536,7 @@ class K extends _ {
2536
2536
  received: t.parsedType
2537
2537
  }), g;
2538
2538
  const n = t.parsedType === h.promise ? t.data : Promise.resolve(t.data);
2539
- return C(n.then((s) => this._def.type.parseAsync(s, {
2539
+ return S(n.then((s) => this._def.type.parseAsync(s, {
2540
2540
  path: t.path,
2541
2541
  errorMap: t.common.contextualErrorMap
2542
2542
  })));
@@ -2638,7 +2638,7 @@ N.createWithPreprocess = (r, e, t) => new N({
2638
2638
  });
2639
2639
  class j extends _ {
2640
2640
  _parse(e) {
2641
- return this._getType(e) === h.undefined ? C(void 0) : this._def.innerType._parse(e);
2641
+ return this._getType(e) === h.undefined ? S(void 0) : this._def.innerType._parse(e);
2642
2642
  }
2643
2643
  unwrap() {
2644
2644
  return this._def.innerType;
@@ -2651,7 +2651,7 @@ j.create = (r, e) => new j({
2651
2651
  });
2652
2652
  class F extends _ {
2653
2653
  _parse(e) {
2654
- return this._getType(e) === h.null ? C(null) : this._def.innerType._parse(e);
2654
+ return this._getType(e) === h.null ? S(null) : this._def.innerType._parse(e);
2655
2655
  }
2656
2656
  unwrap() {
2657
2657
  return this._def.innerType;
@@ -2701,7 +2701,7 @@ class me extends _ {
2701
2701
  status: "valid",
2702
2702
  value: a.status === "valid" ? a.value : this._def.catchValue({
2703
2703
  get error() {
2704
- return new S(n.common.issues);
2704
+ return new C(n.common.issues);
2705
2705
  },
2706
2706
  input: n.data
2707
2707
  })
@@ -2709,7 +2709,7 @@ class me extends _ {
2709
2709
  status: "valid",
2710
2710
  value: s.status === "valid" ? s.value : this._def.catchValue({
2711
2711
  get error() {
2712
- return new S(n.common.issues);
2712
+ return new C(n.common.issues);
2713
2713
  },
2714
2714
  input: n.data
2715
2715
  })
@@ -2841,7 +2841,7 @@ var y;
2841
2841
  })(y || (y = {}));
2842
2842
  const Ot = (r, e = {
2843
2843
  message: `Input not instance of ${r.name}`
2844
- }) => Qe((t) => t instanceof r, e), He = I.create, Ge = V.create, jt = Te.create, Et = L.create, Xe = ae.create, Rt = q.create, Pt = xe.create, $t = ie.create, Dt = oe.create, Mt = X.create, Vt = U.create, Lt = M.create, zt = ke.create, Ft = A.create, Ut = k.create, Bt = k.strictCreate, qt = ce.create, Wt = Ce.create, Jt = de.create, Yt = R.create, Qt = ue.create, Ht = we.create, Gt = W.create, Xt = Q.create, Kt = le.create, er = fe.create, tr = z.create, rr = he.create, nr = K.create, Le = N.create, sr = j.create, ar = F.create, ir = N.createWithPreprocess, or = ge.create, cr = () => He().optional(), dr = () => Ge().optional(), ur = () => Xe().optional(), lr = {
2844
+ }) => Qe((t) => t instanceof r, e), He = I.create, Ge = V.create, jt = Te.create, Et = L.create, Xe = ae.create, Rt = q.create, Pt = xe.create, $t = ie.create, Dt = oe.create, Mt = X.create, Vt = U.create, Lt = M.create, zt = ke.create, Ft = A.create, Ut = k.create, Bt = k.strictCreate, qt = ce.create, Wt = Se.create, Jt = de.create, Yt = R.create, Qt = ue.create, Ht = we.create, Gt = W.create, Xt = Q.create, Kt = le.create, er = fe.create, tr = z.create, rr = he.create, nr = K.create, Le = N.create, sr = j.create, ar = F.create, ir = N.createWithPreprocess, or = ge.create, cr = () => He().optional(), dr = () => Ge().optional(), ur = () => Xe().optional(), lr = {
2845
2845
  string: (r) => I.create({ ...r, coerce: !0 }),
2846
2846
  number: (r) => V.create({ ...r, coerce: !0 }),
2847
2847
  boolean: (r) => ae.create({
@@ -2862,7 +2862,7 @@ var i = /* @__PURE__ */ Object.freeze({
2862
2862
  ParseStatus: T,
2863
2863
  INVALID: g,
2864
2864
  DIRTY: Y,
2865
- OK: C,
2865
+ OK: S,
2866
2866
  isAborted: Oe,
2867
2867
  isDirty: je,
2868
2868
  isValid: B,
@@ -2892,7 +2892,7 @@ var i = /* @__PURE__ */ Object.freeze({
2892
2892
  ZodArray: A,
2893
2893
  ZodObject: k,
2894
2894
  ZodUnion: ce,
2895
- ZodDiscriminatedUnion: Ce,
2895
+ ZodDiscriminatedUnion: Se,
2896
2896
  ZodIntersection: de,
2897
2897
  ZodTuple: R,
2898
2898
  ZodRecord: ue,
@@ -2965,7 +2965,7 @@ var i = /* @__PURE__ */ Object.freeze({
2965
2965
  NEVER: fr,
2966
2966
  ZodIssueCode: d,
2967
2967
  quotelessJson: at,
2968
- ZodError: S
2968
+ ZodError: C
2969
2969
  });
2970
2970
  const hr = i.object({
2971
2971
  country: i.string(),
@@ -3050,15 +3050,15 @@ const H = i.object({
3050
3050
  }),
3051
3051
  // @deprecated
3052
3052
  categoryNames: i.array(i.string())
3053
- }), Cr = et.extend({
3053
+ }), Sr = et.extend({
3054
3054
  image: i.instanceof(File).optional()
3055
3055
  }), tt = i.object({
3056
3056
  product: et,
3057
3057
  originalPrice: i.number().optional(),
3058
3058
  finalPrice: i.number().optional(),
3059
3059
  finalDiscount: i.number().optional(),
3060
- amount: i.number().int().positive({ message: "Quantity must be a positive integer." })
3061
- }), Sr = i.object({
3060
+ amount: i.number().positive({ message: "Quantity must be a positive number." })
3061
+ }), Cr = i.object({
3062
3062
  type: i.literal("Cart"),
3063
3063
  id: i.string().uuid(),
3064
3064
  companyId: i.string().uuid(),
@@ -3155,12 +3155,10 @@ const Nr = i.object({
3155
3155
  // what store charge
3156
3156
  date: i.number(),
3157
3157
  deliveryDate: i.coerce.number().optional(),
3158
- createdAt: i.number().optional(),
3159
3158
  client: pr.required({}),
3160
3159
  nameOnInvoice: i.string().optional(),
3161
3160
  clientComment: i.string().optional()
3162
- }), mr = i.enum(["individual", "company"]);
3163
- i.object({
3161
+ }), mr = i.enum(["individual", "company"]), Or = i.object({
3164
3162
  id: i.string(),
3165
3163
  companyId: i.string(),
3166
3164
  name: i.string(),
@@ -3175,8 +3173,7 @@ i.object({
3175
3173
  minimumOrder: i.number().optional(),
3176
3174
  freeDeliveryPrice: i.number().optional(),
3177
3175
  deliveryPrice: i.number().optional()
3178
- });
3179
- const Ie = i.string().min(1), Or = i.object({
3176
+ }), Ie = i.string().min(1), jr = i.object({
3180
3177
  type: i.literal("Discount"),
3181
3178
  storeId: Ie,
3182
3179
  companyId: Ie,
@@ -3207,7 +3204,7 @@ function Fe(r) {
3207
3204
  }
3208
3205
  return ((t = r.discount) == null ? void 0 : t.type) === "number" ? r.price - r.discount.value : r.price;
3209
3206
  }
3210
- function jr({
3207
+ function Er({
3211
3208
  cart: r,
3212
3209
  discounts: e,
3213
3210
  store: t
@@ -3228,10 +3225,10 @@ function jr({
3228
3225
  (Z) => o.variant.productsId.includes(Z.product.id)
3229
3226
  ), x = (p == null ? void 0 : p.reduce((Z, De) => (o.variant.productsId.includes(De.product.id) && (Z += De.amount), Z), 0)) ?? 0, O = Math.floor(x / o.variant.requiredQuantity), w = Fe((l = p[0]) == null ? void 0 : l.product), ee = ze((u = p[0]) == null ? void 0 : u.product);
3230
3227
  console.log("price", w, ee);
3231
- const Se = Number(
3228
+ const Ce = Number(
3232
3229
  (o.variant.discountPrice / o.variant.requiredQuantity).toFixed(2)
3233
3230
  ) * 1;
3234
- console.log("discountPrice", Se);
3231
+ console.log("discountPrice", Ce);
3235
3232
  const nt = (w * o.variant.requiredQuantity - o.variant.discountPrice) * O, st = x * w - nt, $e = Number((st / x).toFixed(2));
3236
3233
  s = s.map((Z) => o.variant.productsId.includes(Z.product.id) ? {
3237
3234
  ...Z,
@@ -3249,8 +3246,8 @@ function jr({
3249
3246
  if (u.vat) {
3250
3247
  let ee = 0;
3251
3248
  if (n) {
3252
- const Se = x * (Ae.VAT / (100 + Ae.VAT));
3253
- w = Number(Se.toFixed(2)), w = w * p, ee = Number(w.toFixed(2));
3249
+ const Ce = x * (Ae.VAT / (100 + Ae.VAT));
3250
+ w = Number(Ce.toFixed(2)), w = w * p, ee = Number(w.toFixed(2));
3254
3251
  } else
3255
3252
  w = x * Ae.VAT / 100, w = w * p, ee = Number(w.toFixed(2));
3256
3253
  o.vat = Number((o.vat + ee).toFixed(2));
@@ -3294,30 +3291,32 @@ const yr = {
3294
3291
  }) => `${r}/${e}/${t}${n ? `/${n}` : ""}`,
3295
3292
  // for backend
3296
3293
  getDocPath: (r) => `{companyId}/{storeId}/${r}/{id}`
3297
- }, Er = {
3294
+ }, Rr = {
3298
3295
  firestore: vr
3299
3296
  };
3300
3297
  export {
3301
3298
  hr as AddressSchema,
3302
3299
  Ke as BaseCategorySchema,
3303
3300
  tt as CartItemProductSchema,
3304
- Sr as CartSchema,
3301
+ Cr as CartSchema,
3305
3302
  Pe as CategorySchema,
3306
3303
  Zr as CompanySchema,
3307
- Or as DiscountSchema,
3304
+ jr as DiscountSchema,
3308
3305
  Ir as FavoriteProductSchema,
3309
3306
  xr as FileSchema,
3310
- Er as FirebaseAPI,
3307
+ Rr as FirebaseAPI,
3311
3308
  H as LocaleSchema,
3312
3309
  wr as LocaleValueSchema,
3313
- Cr as NewProductSchema,
3310
+ Sr as NewProductSchema,
3314
3311
  Nr as OrderSchema,
3315
3312
  et as ProductSchema,
3316
3313
  rt as ProfilePaymentTypeSchema,
3317
3314
  pr as ProfileSchema,
3315
+ Or as StoreSchema,
3318
3316
  Tr as TFlattenCategorySchema,
3317
+ mr as clientTypesSchema,
3319
3318
  Ar as createEmptyProfile,
3320
- jr as getCartCost,
3319
+ Er as getCartCost,
3321
3320
  kr as isFile,
3322
3321
  D as notEmptyTextSchema,
3323
3322
  br as numericTextSchema