@jsdev_ninja/core 0.15.1 → 0.15.3

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
@@ -105,7 +105,7 @@ const p = b.arrayToEnum([
105
105
  "not_multiple_of",
106
106
  "not_finite"
107
107
  ]), ct = (n) => JSON.stringify(n, null, 2).replace(/"([^"]+)":/g, "$1:");
108
- class A extends Error {
108
+ class N extends Error {
109
109
  get errors() {
110
110
  return this.issues;
111
111
  }
@@ -142,7 +142,7 @@ class A extends Error {
142
142
  return a(this), r;
143
143
  }
144
144
  static assert(e) {
145
- if (!(e instanceof A))
145
+ if (!(e instanceof N))
146
146
  throw new Error(`Not a ZodError: ${e}`);
147
147
  }
148
148
  toString() {
@@ -164,7 +164,7 @@ class A extends Error {
164
164
  return this.flatten();
165
165
  }
166
166
  }
167
- A.create = (n) => new A(n);
167
+ N.create = (n) => new N(n);
168
168
  const X = (n, e) => {
169
169
  let t;
170
170
  switch (n.code) {
@@ -342,7 +342,7 @@ const Me = (n, e) => {
342
342
  get error() {
343
343
  if (this._error)
344
344
  return this._error;
345
- const t = new A(n.common.issues);
345
+ const t = new N(n.common.issues);
346
346
  return this._error = t, this._error;
347
347
  }
348
348
  };
@@ -580,13 +580,13 @@ class _ {
580
580
  }
581
581
  }
582
582
  const lt = /^c[^\s-]{8,}$/i, mt = /^[0-9a-z]+$/, pt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, ft = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, ht = /^[a-z0-9_-]{21}$/i, gt = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, yt = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, vt = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, _t = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
583
- let Ne;
583
+ let Ae;
584
584
  const bt = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, xt = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, kt = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,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|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", It = new RegExp(`^${qe}$`);
585
585
  function Be(n) {
586
586
  let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
587
587
  return n.precision ? e = `${e}\\.\\d{${n.precision}}` : n.precision == null && (e = `${e}(\\.\\d+)?`), e;
588
588
  }
589
- function At(n) {
589
+ function Nt(n) {
590
590
  return new RegExp(`^${Be(n)}$`);
591
591
  }
592
592
  function We(n) {
@@ -594,7 +594,7 @@ function We(n) {
594
594
  const t = [];
595
595
  return t.push(n.local ? "Z?" : "Z"), n.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
596
596
  }
597
- function Nt(n, e) {
597
+ function At(n, e) {
598
598
  return !!((e === "v4" || !e) && bt.test(n) || (e === "v6" || !e) && kt.test(n));
599
599
  }
600
600
  function Ct(n, e) {
@@ -610,7 +610,7 @@ function Ct(n, e) {
610
610
  function jt(n, e) {
611
611
  return !!((e === "v4" || !e) && xt.test(n) || (e === "v6" || !e) && wt.test(n));
612
612
  }
613
- class N extends _ {
613
+ class A extends _ {
614
614
  _parse(e) {
615
615
  if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== p.string) {
616
616
  const i = this._getOrReturnCtx(e);
@@ -665,7 +665,7 @@ class N extends _ {
665
665
  message: i.message
666
666
  }), r.dirty());
667
667
  else if (i.kind === "emoji")
668
- Ne || (Ne = new RegExp(_t, "u")), Ne.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
668
+ Ae || (Ae = new RegExp(_t, "u")), Ae.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
669
669
  validation: "emoji",
670
670
  code: d.invalid_string,
671
671
  message: i.message
@@ -734,7 +734,7 @@ class N extends _ {
734
734
  code: d.invalid_string,
735
735
  validation: "date",
736
736
  message: i.message
737
- }), r.dirty()) : i.kind === "time" ? At(i).test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
737
+ }), r.dirty()) : i.kind === "time" ? Nt(i).test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
738
738
  code: d.invalid_string,
739
739
  validation: "time",
740
740
  message: i.message
@@ -742,7 +742,7 @@ class N extends _ {
742
742
  validation: "duration",
743
743
  code: d.invalid_string,
744
744
  message: i.message
745
- }), r.dirty()) : i.kind === "ip" ? Nt(e.data, i.version) || (a = this._getOrReturnCtx(e, a), m(a, {
745
+ }), r.dirty()) : i.kind === "ip" ? At(e.data, i.version) || (a = this._getOrReturnCtx(e, a), m(a, {
746
746
  validation: "ip",
747
747
  code: d.invalid_string,
748
748
  message: i.message
@@ -773,7 +773,7 @@ class N extends _ {
773
773
  });
774
774
  }
775
775
  _addCheck(e) {
776
- return new N({
776
+ return new A({
777
777
  ...this._def,
778
778
  checks: [...this._def.checks, e]
779
779
  });
@@ -910,19 +910,19 @@ class N extends _ {
910
910
  return this.min(1, h.errToObj(e));
911
911
  }
912
912
  trim() {
913
- return new N({
913
+ return new A({
914
914
  ...this._def,
915
915
  checks: [...this._def.checks, { kind: "trim" }]
916
916
  });
917
917
  }
918
918
  toLowerCase() {
919
- return new N({
919
+ return new A({
920
920
  ...this._def,
921
921
  checks: [...this._def.checks, { kind: "toLowerCase" }]
922
922
  });
923
923
  }
924
924
  toUpperCase() {
925
- return new N({
925
+ return new A({
926
926
  ...this._def,
927
927
  checks: [...this._def.checks, { kind: "toUpperCase" }]
928
928
  });
@@ -988,9 +988,9 @@ class N extends _ {
988
988
  return e;
989
989
  }
990
990
  }
991
- N.create = (n) => {
991
+ A.create = (n) => {
992
992
  var e;
993
- return new N({
993
+ return new A({
994
994
  checks: [],
995
995
  typeName: g.ZodString,
996
996
  coerce: (e = n == null ? void 0 : n.coerce) !== null && e !== void 0 ? e : !1,
@@ -1897,7 +1897,7 @@ class ie extends _ {
1897
1897
  for (const o of i)
1898
1898
  if (o.result.status === "dirty")
1899
1899
  return t.common.issues.push(...o.ctx.common.issues), o.result;
1900
- const c = i.map((o) => new A(o.ctx.common.issues));
1900
+ const c = i.map((o) => new N(o.ctx.common.issues));
1901
1901
  return m(t, {
1902
1902
  code: d.invalid_union,
1903
1903
  unionErrors: c
@@ -1944,7 +1944,7 @@ class ie extends _ {
1944
1944
  }
1945
1945
  if (i)
1946
1946
  return t.common.issues.push(...i.ctx.common.issues), i.result;
1947
- const o = c.map((l) => new A(l));
1947
+ const o = c.map((l) => new N(l));
1948
1948
  return m(t, {
1949
1949
  code: d.invalid_union,
1950
1950
  unionErrors: o
@@ -2171,7 +2171,7 @@ class ce extends _ {
2171
2171
  typeName: g.ZodRecord,
2172
2172
  ...v(r)
2173
2173
  }) : new ce({
2174
- keyType: N.create(),
2174
+ keyType: A.create(),
2175
2175
  valueType: e,
2176
2176
  typeName: g.ZodRecord,
2177
2177
  ...v(t)
@@ -2338,7 +2338,7 @@ class Y extends _ {
2338
2338
  if (this._def.returns instanceof J) {
2339
2339
  const o = this;
2340
2340
  return I(async function(...l) {
2341
- const u = new A([]), f = await o._def.args.parseAsync(l, i).catch((w) => {
2341
+ const u = new N([]), f = await o._def.args.parseAsync(l, i).catch((w) => {
2342
2342
  throw u.addIssue(r(l, w)), u;
2343
2343
  }), x = await Reflect.apply(c, this, f);
2344
2344
  return await o._def.returns._def.type.parseAsync(x, i).catch((w) => {
@@ -2350,10 +2350,10 @@ class Y extends _ {
2350
2350
  return I(function(...l) {
2351
2351
  const u = o._def.args.safeParse(l, i);
2352
2352
  if (!u.success)
2353
- throw new A([r(l, u.error)]);
2353
+ throw new N([r(l, u.error)]);
2354
2354
  const f = Reflect.apply(c, this, u.data), x = o._def.returns.safeParse(f, i);
2355
2355
  if (!x.success)
2356
- throw new A([a(f, x.error)]);
2356
+ throw new N([a(f, x.error)]);
2357
2357
  return x.data;
2358
2358
  });
2359
2359
  }
@@ -2704,7 +2704,7 @@ class pe extends _ {
2704
2704
  status: "valid",
2705
2705
  value: i.status === "valid" ? i.value : this._def.catchValue({
2706
2706
  get error() {
2707
- return new A(r.common.issues);
2707
+ return new N(r.common.issues);
2708
2708
  },
2709
2709
  input: r.data
2710
2710
  })
@@ -2712,7 +2712,7 @@ class pe extends _ {
2712
2712
  status: "valid",
2713
2713
  value: a.status === "valid" ? a.value : this._def.catchValue({
2714
2714
  get error() {
2715
- return new A(r.common.issues);
2715
+ return new N(r.common.issues);
2716
2716
  },
2717
2717
  input: r.data
2718
2718
  })
@@ -2844,8 +2844,8 @@ var g;
2844
2844
  })(g || (g = {}));
2845
2845
  const Pt = (n, e = {
2846
2846
  message: `Input not instance of ${n.name}`
2847
- }) => Ye((t) => t instanceof n, e), Xe = N.create, Ge = M.create, Et = we.create, Rt = V.create, Je = re.create, $t = q.create, Mt = be.create, Vt = se.create, zt = ae.create, Lt = G.create, Ft = F.create, Ut = $.create, qt = xe.create, Bt = C.create, Wt = k.create, Qt = k.strictCreate, Yt = ie.create, Xt = Te.create, Gt = oe.create, Jt = D.create, Ht = ce.create, Kt = ke.create, en = B.create, tn = Y.create, nn = de.create, rn = ue.create, sn = z.create, an = le.create, on = J.create, ze = j.create, cn = Z.create, dn = L.create, un = j.createWithPreprocess, ln = he.create, mn = () => Xe().optional(), pn = () => Ge().optional(), fn = () => Je().optional(), hn = {
2848
- string: (n) => N.create({ ...n, coerce: !0 }),
2847
+ }) => Ye((t) => t instanceof n, e), Xe = A.create, Ge = M.create, Et = we.create, Rt = V.create, Je = re.create, $t = q.create, Mt = be.create, Vt = se.create, zt = ae.create, Lt = G.create, Ft = F.create, Ut = $.create, qt = xe.create, Bt = C.create, Wt = k.create, Qt = k.strictCreate, Yt = ie.create, Xt = Te.create, Gt = oe.create, Jt = D.create, Ht = ce.create, Kt = ke.create, en = B.create, tn = Y.create, nn = de.create, rn = ue.create, sn = z.create, an = le.create, on = J.create, ze = j.create, cn = Z.create, dn = L.create, un = j.createWithPreprocess, ln = he.create, mn = () => Xe().optional(), pn = () => Ge().optional(), fn = () => Je().optional(), hn = {
2848
+ string: (n) => A.create({ ...n, coerce: !0 }),
2849
2849
  number: (n) => M.create({ ...n, coerce: !0 }),
2850
2850
  boolean: (n) => re.create({
2851
2851
  ...n,
@@ -2880,7 +2880,7 @@ var s = /* @__PURE__ */ Object.freeze({
2880
2880
  getParsedType: E,
2881
2881
  ZodType: _,
2882
2882
  datetimeRegex: We,
2883
- ZodString: N,
2883
+ ZodString: A,
2884
2884
  ZodNumber: M,
2885
2885
  ZodBigInt: V,
2886
2886
  ZodBoolean: re,
@@ -2968,7 +2968,7 @@ var s = /* @__PURE__ */ Object.freeze({
2968
2968
  NEVER: gn,
2969
2969
  ZodIssueCode: d,
2970
2970
  quotelessJson: ct,
2971
- ZodError: A
2971
+ ZodError: N
2972
2972
  });
2973
2973
  const Se = s.object({
2974
2974
  country: s.string().optional(),
@@ -3269,6 +3269,20 @@ const ge = s.object({
3269
3269
  emailOnInvoice: s.string().email().optional(),
3270
3270
  phoneNumberOnInvoice: s.string().optional(),
3271
3271
  clientComment: s.string().optional(),
3272
+ // --- B2B buyer details (optional, additive — back-compat) ---
3273
+ companyName: s.string().optional(),
3274
+ companyNumber: s.string().optional(),
3275
+ // ח.פ / עוסק מורשה (aligns with Organization.companyNumber)
3276
+ contact: s.object({
3277
+ fullName: s.string().optional(),
3278
+ role: s.string().optional(),
3279
+ // תפקיד
3280
+ phone: s.string().optional(),
3281
+ email: s.string().optional()
3282
+ }).optional(),
3283
+ poNumber: s.string().optional(),
3284
+ // הזמנת רכש
3285
+ outOfStockPolicy: s.enum(["substitute", "remove"]).optional(),
3272
3286
  organizationId: s.string().optional(),
3273
3287
  billingAccount: tt.optional(),
3274
3288
  deliveryNote: xn.optional(),
@@ -3299,7 +3313,7 @@ const ge = s.object({
3299
3313
  }), In = s.object({
3300
3314
  minSpend: s.number().positive().optional(),
3301
3315
  stackable: s.boolean().default(!1)
3302
- }).optional(), An = s.discriminatedUnion("variantType", [
3316
+ }).optional(), Nn = s.discriminatedUnion("variantType", [
3303
3317
  s.object({
3304
3318
  variantType: s.literal("bundle"),
3305
3319
  productsId: s.array(s.string().nonempty()).min(1),
@@ -3318,10 +3332,10 @@ const ge = s.object({
3318
3332
  active: s.boolean(),
3319
3333
  startDate: s.number(),
3320
3334
  endDate: s.number(),
3321
- variant: An,
3335
+ variant: Nn,
3322
3336
  conditions: In
3323
3337
  });
3324
- class Nn {
3338
+ class An {
3325
3339
  canApply(e, t) {
3326
3340
  if (e.variant.variantType !== "bundle" || !this.isDiscountActive(e)) return !1;
3327
3341
  const { productsId: r, requiredQuantity: a } = e.variant;
@@ -3389,7 +3403,7 @@ class nt {
3389
3403
  }
3390
3404
  }
3391
3405
  $e(nt, "strategies", /* @__PURE__ */ new Map([
3392
- ["bundle", new Nn()]
3406
+ ["bundle", new An()]
3393
3407
  ]));
3394
3408
  class Gn {
3395
3409
  static calculateDiscounts(e, t, r) {
@@ -3466,6 +3480,10 @@ const Cn = s.object({
3466
3480
  }), Hn = rt.omit({ id: !0 }), jn = s.object({
3467
3481
  type: s.literal("SupplierInvoice"),
3468
3482
  id: s.string(),
3483
+ // "draft" = work-in-progress, NOT yet finalized. Product prices are only
3484
+ // updated once the invoice is finalized ("completed"). Legacy invoices have
3485
+ // no status and are treated as finalized.
3486
+ status: s.enum(["draft", "completed"]).optional(),
3469
3487
  supplier: rt,
3470
3488
  invoiceNumber: s.string(),
3471
3489
  date: s.number(),
@@ -3588,13 +3606,13 @@ function sr({
3588
3606
  const { product: u, amount: f, finalPrice: x, finalDiscount: T } = l;
3589
3607
  let w = 0;
3590
3608
  if (u.vat) {
3591
- let Ae = 0;
3609
+ let Ne = 0;
3592
3610
  if (a) {
3593
3611
  const st = Number((x / (1 + De.VAT / 100)).toFixed(2)), at = x - st;
3594
- w = Number(at.toFixed(2)), w = w * f, Ae = Number(w.toFixed(2));
3612
+ w = Number(at.toFixed(2)), w = w * f, Ne = Number(w.toFixed(2));
3595
3613
  } else
3596
- w = x * De.VAT / 100, w = w * f, Ae = Number(w.toFixed(2));
3597
- o.vat = Number((o.vat + Ae).toFixed(2));
3614
+ w = x * De.VAT / 100, w = w * f, Ne = Number(w.toFixed(2));
3615
+ o.vat = Number((o.vat + Ne).toFixed(2));
3598
3616
  }
3599
3617
  const H = Number(x.toFixed(2));
3600
3618
  return o.cost += f * H, o.discount += T && f * T, o.finalCost += f * H + (a ? 0 : w), o.productsCost += f * H + (a ? 0 : w), o.cost = Number(o.cost.toFixed(2)), o.discount = Number(o.discount.toFixed(2)), o.finalCost = Number(o.finalCost.toFixed(2)), o.productsCost = Number(o.productsCost.toFixed(2)), o;
@@ -3679,7 +3697,7 @@ export {
3679
3697
  er as BudgetRecordSchema,
3680
3698
  Zn as BudgetRecordTypeSchema,
3681
3699
  nr as BudgetTransactionTypeSchema,
3682
- Nn as BundleDiscountStrategy,
3700
+ An as BundleDiscountStrategy,
3683
3701
  et as CalculatedDataSchema,
3684
3702
  Ke as CartItemProductSchema,
3685
3703
  Un as CartSchema,
@@ -3690,7 +3708,7 @@ export {
3690
3708
  Gn as DiscountEngine,
3691
3709
  Xn as DiscountSchema,
3692
3710
  nt as DiscountStrategyFactory,
3693
- An as DiscountVariantSchema,
3711
+ Nn as DiscountVariantSchema,
3694
3712
  bn as EzDeliveryNoteSchema,
3695
3713
  Bn as FavoriteProductSchema,
3696
3714
  Vn as FileSchema,