@connectedxm/zpl-generator 0.0.1 → 0.0.2-beta.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/index.es.js +129 -129
- package/dist/src/generate.d.ts +29 -0
- package/dist/src/validate.d.ts +1175 -0
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -130,10 +130,10 @@ class O extends Error {
|
|
|
130
130
|
else if (i.path.length === 0)
|
|
131
131
|
r._errors.push(t(i));
|
|
132
132
|
else {
|
|
133
|
-
let o = r,
|
|
134
|
-
for (;
|
|
135
|
-
const
|
|
136
|
-
|
|
133
|
+
let o = r, f = 0;
|
|
134
|
+
for (; f < i.path.length; ) {
|
|
135
|
+
const h = i.path[f];
|
|
136
|
+
f === i.path.length - 1 ? (o[h] = o[h] || { _errors: [] }, o[h]._errors.push(t(i))) : o[h] = o[h] || { _errors: [] }, o = o[h], f++;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
};
|
|
@@ -239,9 +239,9 @@ const Me = (n) => {
|
|
|
239
239
|
message: s.message
|
|
240
240
|
};
|
|
241
241
|
let o = "";
|
|
242
|
-
const
|
|
243
|
-
for (const
|
|
244
|
-
o =
|
|
242
|
+
const f = r.filter((h) => !!h).slice().reverse();
|
|
243
|
+
for (const h of f)
|
|
244
|
+
o = h(i, { data: e, defaultError: o }).message;
|
|
245
245
|
return {
|
|
246
246
|
...s,
|
|
247
247
|
path: a,
|
|
@@ -266,7 +266,7 @@ function c(n, e) {
|
|
|
266
266
|
});
|
|
267
267
|
n.common.issues.push(r);
|
|
268
268
|
}
|
|
269
|
-
class
|
|
269
|
+
class w {
|
|
270
270
|
constructor() {
|
|
271
271
|
this.value = "valid";
|
|
272
272
|
}
|
|
@@ -294,7 +294,7 @@ class b {
|
|
|
294
294
|
value: i
|
|
295
295
|
});
|
|
296
296
|
}
|
|
297
|
-
return
|
|
297
|
+
return w.mergeObjectSync(e, r);
|
|
298
298
|
}
|
|
299
299
|
static mergeObjectSync(e, t) {
|
|
300
300
|
const r = {};
|
|
@@ -344,8 +344,8 @@ function g(n) {
|
|
|
344
344
|
if (e && (t || r))
|
|
345
345
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
346
346
|
return e ? { errorMap: e, description: s } : { errorMap: (i, o) => {
|
|
347
|
-
const { message:
|
|
348
|
-
return i.code === "invalid_enum_value" ? { message:
|
|
347
|
+
const { message: f } = n;
|
|
348
|
+
return i.code === "invalid_enum_value" ? { message: f ?? o.defaultError } : typeof o.data > "u" ? { message: f ?? r ?? o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: f ?? t ?? o.defaultError };
|
|
349
349
|
}, description: s };
|
|
350
350
|
}
|
|
351
351
|
class _ {
|
|
@@ -367,7 +367,7 @@ class _ {
|
|
|
367
367
|
}
|
|
368
368
|
_processInputParams(e) {
|
|
369
369
|
return {
|
|
370
|
-
status: new
|
|
370
|
+
status: new w(),
|
|
371
371
|
ctx: {
|
|
372
372
|
common: e.parent.common,
|
|
373
373
|
data: e.data,
|
|
@@ -469,7 +469,7 @@ class _ {
|
|
|
469
469
|
code: d.custom,
|
|
470
470
|
...r(s)
|
|
471
471
|
});
|
|
472
|
-
return typeof Promise < "u" && i instanceof Promise ? i.then((
|
|
472
|
+
return typeof Promise < "u" && i instanceof Promise ? i.then((f) => f ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
|
|
473
473
|
});
|
|
474
474
|
}
|
|
475
475
|
refinement(e, t) {
|
|
@@ -612,7 +612,7 @@ class R extends _ {
|
|
|
612
612
|
received: a.parsedType
|
|
613
613
|
}), m;
|
|
614
614
|
}
|
|
615
|
-
const r = new
|
|
615
|
+
const r = new w();
|
|
616
616
|
let s;
|
|
617
617
|
for (const a of this._def.checks)
|
|
618
618
|
if (a.kind === "min")
|
|
@@ -1003,7 +1003,7 @@ class B extends _ {
|
|
|
1003
1003
|
}), m;
|
|
1004
1004
|
}
|
|
1005
1005
|
let r;
|
|
1006
|
-
const s = new
|
|
1006
|
+
const s = new w();
|
|
1007
1007
|
for (const a of this._def.checks)
|
|
1008
1008
|
a.kind === "int" ? v.isInteger(e.data) || (r = this._getOrReturnCtx(e, r), c(r, {
|
|
1009
1009
|
code: d.invalid_type,
|
|
@@ -1175,7 +1175,7 @@ class z extends _ {
|
|
|
1175
1175
|
if (this._getType(e) !== u.bigint)
|
|
1176
1176
|
return this._getInvalidInput(e);
|
|
1177
1177
|
let r;
|
|
1178
|
-
const s = new
|
|
1178
|
+
const s = new w();
|
|
1179
1179
|
for (const a of this._def.checks)
|
|
1180
1180
|
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (r = this._getOrReturnCtx(e, r), c(r, {
|
|
1181
1181
|
code: d.too_small,
|
|
@@ -1328,7 +1328,7 @@ class q extends _ {
|
|
|
1328
1328
|
code: d.invalid_date
|
|
1329
1329
|
}), m;
|
|
1330
1330
|
}
|
|
1331
|
-
const r = new
|
|
1331
|
+
const r = new w();
|
|
1332
1332
|
let s;
|
|
1333
1333
|
for (const a of this._def.checks)
|
|
1334
1334
|
a.kind === "min" ? e.data.getTime() < a.value && (s = this._getOrReturnCtx(e, s), c(s, {
|
|
@@ -1453,7 +1453,7 @@ ke.create = (n) => new ke({
|
|
|
1453
1453
|
typeName: p.ZodAny,
|
|
1454
1454
|
...g(n)
|
|
1455
1455
|
});
|
|
1456
|
-
class
|
|
1456
|
+
class be extends _ {
|
|
1457
1457
|
constructor() {
|
|
1458
1458
|
super(...arguments), this._unknown = !0;
|
|
1459
1459
|
}
|
|
@@ -1461,7 +1461,7 @@ class we extends _ {
|
|
|
1461
1461
|
return S(e.data);
|
|
1462
1462
|
}
|
|
1463
1463
|
}
|
|
1464
|
-
|
|
1464
|
+
be.create = (n) => new be({
|
|
1465
1465
|
typeName: p.ZodUnknown,
|
|
1466
1466
|
...g(n)
|
|
1467
1467
|
});
|
|
@@ -1479,7 +1479,7 @@ j.create = (n) => new j({
|
|
|
1479
1479
|
typeName: p.ZodNever,
|
|
1480
1480
|
...g(n)
|
|
1481
1481
|
});
|
|
1482
|
-
class
|
|
1482
|
+
class we extends _ {
|
|
1483
1483
|
_parse(e) {
|
|
1484
1484
|
if (this._getType(e) !== u.undefined) {
|
|
1485
1485
|
const r = this._getOrReturnCtx(e);
|
|
@@ -1492,7 +1492,7 @@ class be extends _ {
|
|
|
1492
1492
|
return S(e.data);
|
|
1493
1493
|
}
|
|
1494
1494
|
}
|
|
1495
|
-
|
|
1495
|
+
we.create = (n) => new we({
|
|
1496
1496
|
typeName: p.ZodVoid,
|
|
1497
1497
|
...g(n)
|
|
1498
1498
|
});
|
|
@@ -1532,9 +1532,9 @@ class T extends _ {
|
|
|
1532
1532
|
exact: !1,
|
|
1533
1533
|
message: s.maxLength.message
|
|
1534
1534
|
}), r.dirty()), t.common.async)
|
|
1535
|
-
return Promise.all([...t.data].map((i, o) => s.type._parseAsync(new Z(t, i, t.path, o)))).then((i) =>
|
|
1535
|
+
return Promise.all([...t.data].map((i, o) => s.type._parseAsync(new Z(t, i, t.path, o)))).then((i) => w.mergeArray(r, i));
|
|
1536
1536
|
const a = [...t.data].map((i, o) => s.type._parseSync(new Z(t, i, t.path, o)));
|
|
1537
|
-
return
|
|
1537
|
+
return w.mergeArray(r, a);
|
|
1538
1538
|
}
|
|
1539
1539
|
get element() {
|
|
1540
1540
|
return this._def.type;
|
|
@@ -1597,47 +1597,47 @@ class k extends _ {
|
|
|
1597
1597
|
}
|
|
1598
1598
|
_parse(e) {
|
|
1599
1599
|
if (this._getType(e) !== u.object) {
|
|
1600
|
-
const
|
|
1601
|
-
return c(
|
|
1600
|
+
const h = this._getOrReturnCtx(e);
|
|
1601
|
+
return c(h, {
|
|
1602
1602
|
code: d.invalid_type,
|
|
1603
1603
|
expected: u.object,
|
|
1604
|
-
received:
|
|
1604
|
+
received: h.parsedType
|
|
1605
1605
|
}), m;
|
|
1606
1606
|
}
|
|
1607
1607
|
const { status: r, ctx: s } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
1608
1608
|
if (!(this._def.catchall instanceof j && this._def.unknownKeys === "strip"))
|
|
1609
|
-
for (const
|
|
1610
|
-
i.includes(
|
|
1611
|
-
const
|
|
1612
|
-
for (const
|
|
1613
|
-
const y = a[
|
|
1614
|
-
|
|
1615
|
-
key: { status: "valid", value:
|
|
1616
|
-
value: y._parse(new Z(s, C, s.path,
|
|
1617
|
-
alwaysSet:
|
|
1609
|
+
for (const h in s.data)
|
|
1610
|
+
i.includes(h) || o.push(h);
|
|
1611
|
+
const f = [];
|
|
1612
|
+
for (const h of i) {
|
|
1613
|
+
const y = a[h], C = s.data[h];
|
|
1614
|
+
f.push({
|
|
1615
|
+
key: { status: "valid", value: h },
|
|
1616
|
+
value: y._parse(new Z(s, C, s.path, h)),
|
|
1617
|
+
alwaysSet: h in s.data
|
|
1618
1618
|
});
|
|
1619
1619
|
}
|
|
1620
1620
|
if (this._def.catchall instanceof j) {
|
|
1621
|
-
const
|
|
1622
|
-
if (
|
|
1621
|
+
const h = this._def.unknownKeys;
|
|
1622
|
+
if (h === "passthrough")
|
|
1623
1623
|
for (const y of o)
|
|
1624
|
-
|
|
1624
|
+
f.push({
|
|
1625
1625
|
key: { status: "valid", value: y },
|
|
1626
1626
|
value: { status: "valid", value: s.data[y] }
|
|
1627
1627
|
});
|
|
1628
|
-
else if (
|
|
1628
|
+
else if (h === "strict")
|
|
1629
1629
|
o.length > 0 && (c(s, {
|
|
1630
1630
|
code: d.unrecognized_keys,
|
|
1631
1631
|
keys: o
|
|
1632
1632
|
}), r.dirty());
|
|
1633
|
-
else if (
|
|
1633
|
+
else if (h !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1634
1634
|
} else {
|
|
1635
|
-
const
|
|
1635
|
+
const h = this._def.catchall;
|
|
1636
1636
|
for (const y of o) {
|
|
1637
1637
|
const C = s.data[y];
|
|
1638
|
-
|
|
1638
|
+
f.push({
|
|
1639
1639
|
key: { status: "valid", value: y },
|
|
1640
|
-
value:
|
|
1640
|
+
value: h._parse(
|
|
1641
1641
|
new Z(s, C, s.path, y)
|
|
1642
1642
|
//, ctx.child(key), value, getParsedType(value)
|
|
1643
1643
|
),
|
|
@@ -1646,17 +1646,17 @@ class k extends _ {
|
|
|
1646
1646
|
}
|
|
1647
1647
|
}
|
|
1648
1648
|
return s.common.async ? Promise.resolve().then(async () => {
|
|
1649
|
-
const
|
|
1650
|
-
for (const y of
|
|
1649
|
+
const h = [];
|
|
1650
|
+
for (const y of f) {
|
|
1651
1651
|
const C = await y.key, ne = await y.value;
|
|
1652
|
-
|
|
1652
|
+
h.push({
|
|
1653
1653
|
key: C,
|
|
1654
1654
|
value: ne,
|
|
1655
1655
|
alwaysSet: y.alwaysSet
|
|
1656
1656
|
});
|
|
1657
1657
|
}
|
|
1658
|
-
return
|
|
1659
|
-
}).then((
|
|
1658
|
+
return h;
|
|
1659
|
+
}).then((h) => w.mergeObjectSync(r, h)) : w.mergeObjectSync(r, f);
|
|
1660
1660
|
}
|
|
1661
1661
|
get shape() {
|
|
1662
1662
|
return this._def.shape();
|
|
@@ -1910,26 +1910,26 @@ class H extends _ {
|
|
|
1910
1910
|
{
|
|
1911
1911
|
let a;
|
|
1912
1912
|
const i = [];
|
|
1913
|
-
for (const
|
|
1914
|
-
const
|
|
1913
|
+
for (const f of r) {
|
|
1914
|
+
const h = {
|
|
1915
1915
|
...t,
|
|
1916
1916
|
common: {
|
|
1917
1917
|
...t.common,
|
|
1918
1918
|
issues: []
|
|
1919
1919
|
},
|
|
1920
1920
|
parent: null
|
|
1921
|
-
}, y =
|
|
1921
|
+
}, y = f._parseSync({
|
|
1922
1922
|
data: t.data,
|
|
1923
1923
|
path: t.path,
|
|
1924
|
-
parent:
|
|
1924
|
+
parent: h
|
|
1925
1925
|
});
|
|
1926
1926
|
if (y.status === "valid")
|
|
1927
1927
|
return y;
|
|
1928
|
-
y.status === "dirty" && !a && (a = { result: y, ctx:
|
|
1928
|
+
y.status === "dirty" && !a && (a = { result: y, ctx: h }), h.common.issues.length && i.push(h.common.issues);
|
|
1929
1929
|
}
|
|
1930
1930
|
if (a)
|
|
1931
1931
|
return t.common.issues.push(...a.ctx.common.issues), a.result;
|
|
1932
|
-
const o = i.map((
|
|
1932
|
+
const o = i.map((f) => new O(f));
|
|
1933
1933
|
return c(t, {
|
|
1934
1934
|
code: d.invalid_union,
|
|
1935
1935
|
unionErrors: o
|
|
@@ -2015,10 +2015,10 @@ function de(n, e) {
|
|
|
2015
2015
|
if (t === u.object && r === u.object) {
|
|
2016
2016
|
const s = v.objectKeys(e), a = v.objectKeys(n).filter((o) => s.indexOf(o) !== -1), i = { ...n, ...e };
|
|
2017
2017
|
for (const o of a) {
|
|
2018
|
-
const
|
|
2019
|
-
if (!
|
|
2018
|
+
const f = de(n[o], e[o]);
|
|
2019
|
+
if (!f.valid)
|
|
2020
2020
|
return { valid: !1 };
|
|
2021
|
-
i[o] =
|
|
2021
|
+
i[o] = f.data;
|
|
2022
2022
|
}
|
|
2023
2023
|
return { valid: !0, data: i };
|
|
2024
2024
|
} else if (t === u.array && r === u.array) {
|
|
@@ -2026,10 +2026,10 @@ function de(n, e) {
|
|
|
2026
2026
|
return { valid: !1 };
|
|
2027
2027
|
const s = [];
|
|
2028
2028
|
for (let a = 0; a < n.length; a++) {
|
|
2029
|
-
const i = n[a], o = e[a],
|
|
2030
|
-
if (!
|
|
2029
|
+
const i = n[a], o = e[a], f = de(i, o);
|
|
2030
|
+
if (!f.valid)
|
|
2031
2031
|
return { valid: !1 };
|
|
2032
|
-
s.push(
|
|
2032
|
+
s.push(f.data);
|
|
2033
2033
|
}
|
|
2034
2034
|
return { valid: !0, data: s };
|
|
2035
2035
|
} else return t === u.date && r === u.date && +n == +e ? { valid: !0, data: n } : { valid: !1 };
|
|
@@ -2097,10 +2097,10 @@ class E extends _ {
|
|
|
2097
2097
|
type: "array"
|
|
2098
2098
|
}), t.dirty());
|
|
2099
2099
|
const a = [...r.data].map((i, o) => {
|
|
2100
|
-
const
|
|
2101
|
-
return
|
|
2100
|
+
const f = this._def.items[o] || this._def.rest;
|
|
2101
|
+
return f ? f._parse(new Z(r, i, r.path, o)) : null;
|
|
2102
2102
|
}).filter((i) => !!i);
|
|
2103
|
-
return r.common.async ? Promise.all(a).then((i) =>
|
|
2103
|
+
return r.common.async ? Promise.all(a).then((i) => w.mergeArray(t, i)) : w.mergeArray(t, a);
|
|
2104
2104
|
}
|
|
2105
2105
|
get items() {
|
|
2106
2106
|
return this._def.items;
|
|
@@ -2137,28 +2137,28 @@ class Se extends _ {
|
|
|
2137
2137
|
expected: u.map,
|
|
2138
2138
|
received: r.parsedType
|
|
2139
2139
|
}), m;
|
|
2140
|
-
const s = this._def.keyType, a = this._def.valueType, i = [...r.data.entries()].map(([o,
|
|
2141
|
-
key: s._parse(new Z(r, o, r.path, [
|
|
2142
|
-
value: a._parse(new Z(r,
|
|
2140
|
+
const s = this._def.keyType, a = this._def.valueType, i = [...r.data.entries()].map(([o, f], h) => ({
|
|
2141
|
+
key: s._parse(new Z(r, o, r.path, [h, "key"])),
|
|
2142
|
+
value: a._parse(new Z(r, f, r.path, [h, "value"]))
|
|
2143
2143
|
}));
|
|
2144
2144
|
if (r.common.async) {
|
|
2145
2145
|
const o = /* @__PURE__ */ new Map();
|
|
2146
2146
|
return Promise.resolve().then(async () => {
|
|
2147
|
-
for (const
|
|
2148
|
-
const
|
|
2149
|
-
if (
|
|
2147
|
+
for (const f of i) {
|
|
2148
|
+
const h = await f.key, y = await f.value;
|
|
2149
|
+
if (h.status === "aborted" || y.status === "aborted")
|
|
2150
2150
|
return m;
|
|
2151
|
-
(
|
|
2151
|
+
(h.status === "dirty" || y.status === "dirty") && t.dirty(), o.set(h.value, y.value);
|
|
2152
2152
|
}
|
|
2153
2153
|
return { status: t.value, value: o };
|
|
2154
2154
|
});
|
|
2155
2155
|
} else {
|
|
2156
2156
|
const o = /* @__PURE__ */ new Map();
|
|
2157
|
-
for (const
|
|
2158
|
-
const
|
|
2159
|
-
if (
|
|
2157
|
+
for (const f of i) {
|
|
2158
|
+
const h = f.key, y = f.value;
|
|
2159
|
+
if (h.status === "aborted" || y.status === "aborted")
|
|
2160
2160
|
return m;
|
|
2161
|
-
(
|
|
2161
|
+
(h.status === "dirty" || y.status === "dirty") && t.dirty(), o.set(h.value, y.value);
|
|
2162
2162
|
}
|
|
2163
2163
|
return { status: t.value, value: o };
|
|
2164
2164
|
}
|
|
@@ -2196,17 +2196,17 @@ class F extends _ {
|
|
|
2196
2196
|
message: s.maxSize.message
|
|
2197
2197
|
}), t.dirty());
|
|
2198
2198
|
const a = this._def.valueType;
|
|
2199
|
-
function i(
|
|
2200
|
-
const
|
|
2201
|
-
for (const y of
|
|
2199
|
+
function i(f) {
|
|
2200
|
+
const h = /* @__PURE__ */ new Set();
|
|
2201
|
+
for (const y of f) {
|
|
2202
2202
|
if (y.status === "aborted")
|
|
2203
2203
|
return m;
|
|
2204
|
-
y.status === "dirty" && t.dirty(),
|
|
2204
|
+
y.status === "dirty" && t.dirty(), h.add(y.value);
|
|
2205
2205
|
}
|
|
2206
|
-
return { status: t.value, value:
|
|
2206
|
+
return { status: t.value, value: h };
|
|
2207
2207
|
}
|
|
2208
|
-
const o = [...r.data.values()].map((
|
|
2209
|
-
return r.common.async ? Promise.all(o).then((
|
|
2208
|
+
const o = [...r.data.values()].map((f, h) => a._parse(new Z(r, f, r.path, h)));
|
|
2209
|
+
return r.common.async ? Promise.all(o).then((f) => i(f)) : i(o);
|
|
2210
2210
|
}
|
|
2211
2211
|
min(e, t) {
|
|
2212
2212
|
return new F({
|
|
@@ -2407,12 +2407,12 @@ class M extends _ {
|
|
|
2407
2407
|
return Promise.resolve(i).then(async (o) => {
|
|
2408
2408
|
if (t.value === "aborted")
|
|
2409
2409
|
return m;
|
|
2410
|
-
const
|
|
2410
|
+
const f = await this._def.schema._parseAsync({
|
|
2411
2411
|
data: o,
|
|
2412
2412
|
path: r.path,
|
|
2413
2413
|
parent: r
|
|
2414
2414
|
});
|
|
2415
|
-
return
|
|
2415
|
+
return f.status === "aborted" ? m : f.status === "dirty" || t.value === "dirty" ? W(f.value) : f;
|
|
2416
2416
|
});
|
|
2417
2417
|
{
|
|
2418
2418
|
if (t.value === "aborted")
|
|
@@ -2427,10 +2427,10 @@ class M extends _ {
|
|
|
2427
2427
|
}
|
|
2428
2428
|
if (s.type === "refinement") {
|
|
2429
2429
|
const i = (o) => {
|
|
2430
|
-
const
|
|
2430
|
+
const f = s.refinement(o, a);
|
|
2431
2431
|
if (r.common.async)
|
|
2432
|
-
return Promise.resolve(
|
|
2433
|
-
if (
|
|
2432
|
+
return Promise.resolve(f);
|
|
2433
|
+
if (f instanceof Promise)
|
|
2434
2434
|
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2435
2435
|
return o;
|
|
2436
2436
|
};
|
|
@@ -2656,14 +2656,14 @@ var p;
|
|
|
2656
2656
|
})(p || (p = {}));
|
|
2657
2657
|
const te = R.create, x = B.create;
|
|
2658
2658
|
j.create;
|
|
2659
|
-
const $e = T.create,
|
|
2659
|
+
const $e = T.create, he = k.create;
|
|
2660
2660
|
H.create;
|
|
2661
2661
|
const at = ue.create;
|
|
2662
2662
|
Y.create;
|
|
2663
2663
|
E.create;
|
|
2664
2664
|
const V = J.create;
|
|
2665
2665
|
I.create;
|
|
2666
|
-
const
|
|
2666
|
+
const b = Q.create;
|
|
2667
2667
|
X.create;
|
|
2668
2668
|
N.create;
|
|
2669
2669
|
L.create;
|
|
@@ -2681,29 +2681,29 @@ const it = {
|
|
|
2681
2681
|
Backfeed70: "70",
|
|
2682
2682
|
Backfeed80: "80",
|
|
2683
2683
|
Backfeed90: "90"
|
|
2684
|
-
}, ot =
|
|
2684
|
+
}, ot = b(it), dt = {
|
|
2685
2685
|
Continuous: "N",
|
|
2686
2686
|
VariableLengthContinuous: "V",
|
|
2687
2687
|
NonContinuousWebSensing: "W",
|
|
2688
2688
|
NonContinuousWebSensingAlt: "Y",
|
|
2689
2689
|
NonContinuousMarkSensing: "M",
|
|
2690
2690
|
AutoDetect: "A"
|
|
2691
|
-
}, ct =
|
|
2691
|
+
}, ct = b(dt), ut = {
|
|
2692
2692
|
DirectThermal: "D",
|
|
2693
2693
|
ThermalTransfer: "T"
|
|
2694
|
-
}, lt =
|
|
2694
|
+
}, lt = b(ut), ht = {
|
|
2695
2695
|
Invert: "I",
|
|
2696
2696
|
Normal: "N"
|
|
2697
|
-
},
|
|
2697
|
+
}, ft = b(ht), mt = {
|
|
2698
2698
|
Mirror: "Y",
|
|
2699
2699
|
Normal: "N"
|
|
2700
|
-
}, pt =
|
|
2700
|
+
}, pt = b(mt), gt = {
|
|
2701
2701
|
Normal: "A",
|
|
2702
2702
|
Half: "B"
|
|
2703
|
-
}, yt =
|
|
2703
|
+
}, yt = b(gt), _t = {
|
|
2704
2704
|
Enable: "Y",
|
|
2705
2705
|
Disable: "N"
|
|
2706
|
-
}, vt =
|
|
2706
|
+
}, vt = b(_t), xt = {
|
|
2707
2707
|
TearOff: "T",
|
|
2708
2708
|
PeelOff: "P",
|
|
2709
2709
|
Rewind: "R",
|
|
@@ -2712,44 +2712,44 @@ const it = {
|
|
|
2712
2712
|
DelayedCut: "D",
|
|
2713
2713
|
EncodeRFID: "F",
|
|
2714
2714
|
Kiosk: "K"
|
|
2715
|
-
}, kt =
|
|
2715
|
+
}, kt = b(xt), bt = {
|
|
2716
2716
|
Prepeel: "Y",
|
|
2717
2717
|
NoPrepeel: "N"
|
|
2718
|
-
},
|
|
2718
|
+
}, wt = b(bt), St = {
|
|
2719
2719
|
AllMedia: "Y",
|
|
2720
2720
|
ContinuousOnly: "N"
|
|
2721
|
-
}, Tt =
|
|
2721
|
+
}, Tt = b(St), Ct = {
|
|
2722
2722
|
NoRotation: "N",
|
|
2723
2723
|
Rotate90: "R",
|
|
2724
2724
|
Rotate180: "I",
|
|
2725
2725
|
Rotate270: "B"
|
|
2726
|
-
}, Re =
|
|
2726
|
+
}, Re = b(Ct), At = {
|
|
2727
2727
|
Left: "L",
|
|
2728
2728
|
Right: "R",
|
|
2729
2729
|
Center: "C",
|
|
2730
2730
|
Justified: "J"
|
|
2731
|
-
}, Nt =
|
|
2731
|
+
}, Nt = b(At), Ot = {
|
|
2732
2732
|
Highest: "H",
|
|
2733
2733
|
High: "Q",
|
|
2734
2734
|
Medium: "M",
|
|
2735
2735
|
Lower: "L"
|
|
2736
|
-
}, $t =
|
|
2736
|
+
}, $t = b(Ot), Rt = {
|
|
2737
2737
|
Yes: "Y",
|
|
2738
2738
|
No: "N"
|
|
2739
|
-
}, se =
|
|
2739
|
+
}, se = b(Rt), Ze = {
|
|
2740
2740
|
Start: "start",
|
|
2741
2741
|
End: "end"
|
|
2742
|
-
}, Zt =
|
|
2742
|
+
}, Zt = b(Ze), jt = he({
|
|
2743
2743
|
word: te(),
|
|
2744
2744
|
width: x(),
|
|
2745
2745
|
spaceWidth: x()
|
|
2746
|
-
}),
|
|
2746
|
+
}), fe = he({
|
|
2747
2747
|
name: te(),
|
|
2748
2748
|
x: x().int(),
|
|
2749
2749
|
y: x().int(),
|
|
2750
2750
|
data: te()
|
|
2751
|
-
}), Et =
|
|
2752
|
-
type: V("
|
|
2751
|
+
}), Et = fe.extend({
|
|
2752
|
+
type: V("text"),
|
|
2753
2753
|
// ^A font, height, width
|
|
2754
2754
|
font: te().regex(/^[A-Z0-9]$/, "Font must be a single character A-Z or 0-9"),
|
|
2755
2755
|
fontOrientation: Re,
|
|
@@ -2763,7 +2763,7 @@ const it = {
|
|
|
2763
2763
|
hangingIndent: x().int().min(0).max(9999),
|
|
2764
2764
|
verticalAlignment: Zt,
|
|
2765
2765
|
wordWidths: $e(jt).optional()
|
|
2766
|
-
}), It =
|
|
2766
|
+
}), It = fe.extend({
|
|
2767
2767
|
type: V("barcode"),
|
|
2768
2768
|
// ^BY barWidth
|
|
2769
2769
|
barWidth: x().int().min(4).max(9999),
|
|
@@ -2773,7 +2773,7 @@ const it = {
|
|
|
2773
2773
|
line: se,
|
|
2774
2774
|
lineAbove: se,
|
|
2775
2775
|
checkDigit: se
|
|
2776
|
-
}), Mt =
|
|
2776
|
+
}), Mt = fe.extend({
|
|
2777
2777
|
type: V("qrcode"),
|
|
2778
2778
|
// ^BQ orientation, model, magnification, errorCorrection, mask
|
|
2779
2779
|
orientation: V("N"),
|
|
@@ -2785,7 +2785,7 @@ const it = {
|
|
|
2785
2785
|
Et,
|
|
2786
2786
|
It,
|
|
2787
2787
|
Mt
|
|
2788
|
-
]), je =
|
|
2788
|
+
]), je = he({
|
|
2789
2789
|
type: V("thermal"),
|
|
2790
2790
|
// ~TA adjustment
|
|
2791
2791
|
tearOffAdjustment: x().int().min(0).max(120),
|
|
@@ -2797,7 +2797,7 @@ const it = {
|
|
|
2797
2797
|
// ^MT mediaType
|
|
2798
2798
|
thermalMediaType: lt,
|
|
2799
2799
|
// ^PO orientation
|
|
2800
|
-
printOrientation:
|
|
2800
|
+
printOrientation: ft,
|
|
2801
2801
|
// ^PM mirror
|
|
2802
2802
|
mirror: pt,
|
|
2803
2803
|
// ^LH x,y
|
|
@@ -2815,14 +2815,14 @@ const it = {
|
|
|
2815
2815
|
reverse: vt,
|
|
2816
2816
|
// ^MM mode, prepeel
|
|
2817
2817
|
postPrintMode: kt,
|
|
2818
|
-
prepeel:
|
|
2818
|
+
prepeel: wt,
|
|
2819
2819
|
// ^PW width
|
|
2820
2820
|
printWidth: x().int().min(2),
|
|
2821
2821
|
// ^LL length, allMedia
|
|
2822
2822
|
labelLength: x().int().min(1).max(32e3),
|
|
2823
2823
|
allMedia: Tt,
|
|
2824
|
-
//
|
|
2825
|
-
|
|
2824
|
+
// Fields
|
|
2825
|
+
fields: $e(Lt)
|
|
2826
2826
|
});
|
|
2827
2827
|
function Yt(n) {
|
|
2828
2828
|
return je.safeParse(n);
|
|
@@ -2837,7 +2837,7 @@ function Qt(n) {
|
|
|
2837
2837
|
}
|
|
2838
2838
|
function Pt(n) {
|
|
2839
2839
|
const e = ["^XA", Vt(n)];
|
|
2840
|
-
for (const t of n.
|
|
2840
|
+
for (const t of n.fields)
|
|
2841
2841
|
e.push(Dt(t));
|
|
2842
2842
|
return e.push("^XZ"), e.join(`
|
|
2843
2843
|
`);
|
|
@@ -2864,7 +2864,7 @@ function Vt(n) {
|
|
|
2864
2864
|
}
|
|
2865
2865
|
function Dt(n) {
|
|
2866
2866
|
switch (n.type) {
|
|
2867
|
-
case "
|
|
2867
|
+
case "text":
|
|
2868
2868
|
return Bt(n);
|
|
2869
2869
|
case "barcode":
|
|
2870
2870
|
return qt(n);
|
|
@@ -2872,7 +2872,7 @@ function Dt(n) {
|
|
|
2872
2872
|
return Ht(n);
|
|
2873
2873
|
default: {
|
|
2874
2874
|
const e = n;
|
|
2875
|
-
throw new Error(`Unsupported
|
|
2875
|
+
throw new Error(`Unsupported field type: ${e.type}`);
|
|
2876
2876
|
}
|
|
2877
2877
|
}
|
|
2878
2878
|
}
|
|
@@ -2904,12 +2904,12 @@ function Ft(n, e, t) {
|
|
|
2904
2904
|
continue;
|
|
2905
2905
|
}
|
|
2906
2906
|
const i = a.split(" ");
|
|
2907
|
-
let o = 0,
|
|
2908
|
-
for (let
|
|
2909
|
-
const y = r.get(i[
|
|
2910
|
-
o > 0 && o + me > t ? (
|
|
2907
|
+
let o = 0, f = 1;
|
|
2908
|
+
for (let h = 0; h < i.length; h++) {
|
|
2909
|
+
const y = r.get(i[h]), C = y?.width ?? 0, ne = y?.spaceWidth ?? 0, me = o > 0 ? ne + C : C;
|
|
2910
|
+
o > 0 && o + me > t ? (f++, o = C) : o += me;
|
|
2911
2911
|
}
|
|
2912
|
-
s +=
|
|
2912
|
+
s += f;
|
|
2913
2913
|
}
|
|
2914
2914
|
return s;
|
|
2915
2915
|
}
|
|
@@ -2937,9 +2937,9 @@ export {
|
|
|
2937
2937
|
dt as MediaType,
|
|
2938
2938
|
mt as MirrorMode,
|
|
2939
2939
|
xt as PostPrintMode,
|
|
2940
|
-
|
|
2940
|
+
bt as PrepeelMode,
|
|
2941
2941
|
gt as PrintDensityAdjustment,
|
|
2942
|
-
|
|
2942
|
+
ht as PrintOrientation,
|
|
2943
2943
|
Ot as QRCodeErrorCorrection,
|
|
2944
2944
|
_t as ReverseMode,
|
|
2945
2945
|
At as TextAlignment,
|
|
@@ -2950,22 +2950,22 @@ export {
|
|
|
2950
2950
|
Wt as applyVerticalAlignment,
|
|
2951
2951
|
ot as backfeedActionSchema,
|
|
2952
2952
|
je as badgeSchema,
|
|
2953
|
-
It as
|
|
2954
|
-
Lt as blockSchema,
|
|
2953
|
+
It as barcodeFieldSchema,
|
|
2955
2954
|
zt as countLines,
|
|
2956
|
-
|
|
2955
|
+
Lt as fieldSchema,
|
|
2957
2956
|
Re as fontOrientationSchema,
|
|
2958
2957
|
Qt as generate,
|
|
2959
2958
|
ct as mediaTypeSchema,
|
|
2960
2959
|
pt as mirrorModeSchema,
|
|
2961
2960
|
kt as postPrintModeSchema,
|
|
2962
|
-
|
|
2961
|
+
wt as prepeelModeSchema,
|
|
2963
2962
|
yt as printDensityAdjustmentSchema,
|
|
2964
|
-
|
|
2963
|
+
ft as printOrientationSchema,
|
|
2965
2964
|
$t as qrCodeErrorCorrectionSchema,
|
|
2966
|
-
Mt as
|
|
2965
|
+
Mt as qrcodeFieldSchema,
|
|
2967
2966
|
vt as reverseModeSchema,
|
|
2968
2967
|
Nt as textAlignmentSchema,
|
|
2968
|
+
Et as textFieldSchema,
|
|
2969
2969
|
lt as thermalMediaTypeSchema,
|
|
2970
2970
|
Yt as validateBadge,
|
|
2971
2971
|
Jt as validateBadgeOrThrow,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Badge, TextField } from './validate';
|
|
2
|
+
/**
|
|
3
|
+
* Generates ZPL (Zebra Programming Language) from a Badge configuration.
|
|
4
|
+
* Switches on badge type and renders the complete label format for thermal printers.
|
|
5
|
+
*/
|
|
6
|
+
export declare function generate(badge: Badge): string;
|
|
7
|
+
/**
|
|
8
|
+
* ZPL ^FB blocks have no vertical alignment — text always starts at line 1.
|
|
9
|
+
* To simulate "end" (bottom) alignment, we count how many lines the data
|
|
10
|
+
* will occupy and prepend empty ZPL line breaks (\&) to push it down.
|
|
11
|
+
*
|
|
12
|
+
* Two counting strategies:
|
|
13
|
+
* - wordWidths provided: simulate word-wrap using pre-measured pixel widths
|
|
14
|
+
* - wordWidths omitted: approximate chars per line from maxWidth / font width
|
|
15
|
+
*/
|
|
16
|
+
export declare function applyVerticalAlignment(field: TextField): string;
|
|
17
|
+
/**
|
|
18
|
+
* Counts how many lines the field data will occupy inside a ^FB field.
|
|
19
|
+
* Exported so consuming projects (e.g. React label previews) can reuse
|
|
20
|
+
* the same logic to stay in sync with the generator.
|
|
21
|
+
*
|
|
22
|
+
* When wordWidths are provided, simulates ZPL word-wrap: words are placed
|
|
23
|
+
* on the current line until the next word would exceed maxWidth, then a
|
|
24
|
+
* new line is started. Explicit \& breaks always start a new line.
|
|
25
|
+
*
|
|
26
|
+
* When wordWidths are not provided, falls back to a character-width
|
|
27
|
+
* heuristic using fontWidth (or fontHeight).
|
|
28
|
+
*/
|
|
29
|
+
export declare function countLines(field: TextField): number;
|