ksef-client-ts 0.5.1 → 0.5.2

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.js CHANGED
@@ -225,6 +225,10 @@ var init_ksef_session_expired_error = __esm({
225
225
  });
226
226
 
227
227
  // src/errors/ksef-validation-error.ts
228
+ var ksef_validation_error_exports = {};
229
+ __export(ksef_validation_error_exports, {
230
+ KSeFValidationError: () => KSeFValidationError
231
+ });
228
232
  var KSeFValidationError;
229
233
  var init_ksef_validation_error = __esm({
230
234
  "src/errors/ksef-validation-error.ts"() {
@@ -926,6 +930,211 @@ var init_ksef_feature = __esm({
926
930
  }
927
931
  });
928
932
 
933
+ // src/validation/patterns.ts
934
+ function computeCrc8Hex(data) {
935
+ let crc = 0;
936
+ const bytes = new TextEncoder().encode(data);
937
+ for (const byte of bytes) {
938
+ crc ^= byte;
939
+ for (let i = 0; i < 8; i++) {
940
+ crc = (crc & 128) !== 0 ? (crc << 1 ^ CRC8_POLY) & 255 : crc << 1 & 255;
941
+ }
942
+ }
943
+ return crc.toString(16).toUpperCase().padStart(2, "0");
944
+ }
945
+ function isValidNip(value) {
946
+ if (!Nip.test(value)) return false;
947
+ let sum = 0;
948
+ for (let i = 0; i < 9; i++) {
949
+ sum += Number(value[i]) * NIP_WEIGHTS[i];
950
+ }
951
+ const checksum = sum % 11;
952
+ return checksum !== 10 && checksum === Number(value[9]);
953
+ }
954
+ function isValidVatUe(value) {
955
+ return VatUe.test(value);
956
+ }
957
+ function isValidNipVatUe(value) {
958
+ return NipVatUe.test(value);
959
+ }
960
+ function isValidInternalId(value) {
961
+ return InternalId.test(value);
962
+ }
963
+ function isValidPeppolId(value) {
964
+ return PeppolId.test(value);
965
+ }
966
+ function isValidReferenceNumber(value) {
967
+ return ReferenceNumber.test(value);
968
+ }
969
+ function isValidKsefNumber(value) {
970
+ if (!KsefNumber.test(value)) return false;
971
+ let normalized = value;
972
+ if (value.length === 36) {
973
+ const parts = value.split("-");
974
+ if (parts.length === 5) normalized = `${parts[0]}-${parts[1]}-${parts[2]}${parts[3]}-${parts[4]}`;
975
+ else return false;
976
+ }
977
+ if (normalized.length !== 35) return false;
978
+ return computeCrc8Hex(normalized.slice(0, 32)) === normalized.slice(-2);
979
+ }
980
+ function isValidKsefNumberV35(value) {
981
+ if (!KsefNumberV35.test(value)) return false;
982
+ return computeCrc8Hex(value.slice(0, 32)) === value.slice(-2);
983
+ }
984
+ function isValidKsefNumberV36(value) {
985
+ if (!KsefNumberV36.test(value)) return false;
986
+ const parts = value.split("-");
987
+ if (parts.length !== 5) return false;
988
+ const normalized = `${parts[0]}-${parts[1]}-${parts[2]}${parts[3]}-${parts[4]}`;
989
+ return computeCrc8Hex(normalized.slice(0, 32)) === normalized.slice(-2);
990
+ }
991
+ function isValidPesel(value) {
992
+ if (!Pesel.test(value)) return false;
993
+ let sum = 0;
994
+ for (let i = 0; i < 10; i++) {
995
+ sum += Number(value[i]) * PESEL_WEIGHTS[i];
996
+ }
997
+ const checksum = (10 - sum % 10) % 10;
998
+ return checksum === Number(value[10]);
999
+ }
1000
+ function isValidCertificateName(value) {
1001
+ return CertificateName.test(value);
1002
+ }
1003
+ function isValidCertificateFingerprint(value) {
1004
+ return CertificateFingerprint.test(value);
1005
+ }
1006
+ function isValidBase64(value) {
1007
+ return Base64String.test(value);
1008
+ }
1009
+ function isValidIp4Address(value) {
1010
+ return Ip4Address.test(value);
1011
+ }
1012
+ function isValidSha256Base64(value) {
1013
+ return Sha256Base64.test(value);
1014
+ }
1015
+ var NIP_PATTERN_CORE, VAT_UE_PATTERN_CORE, Nip, VatUe, NipVatUe, InternalId, PeppolId, ReferenceNumber, KsefNumber, KsefNumberV35, KsefNumberV36, CertificateName, Pesel, CertificateFingerprint, Base64String, Ip4Address, Ip4Range, Ip4Mask, Sha256Base64, NIP_WEIGHTS, PESEL_WEIGHTS, CRC8_POLY;
1016
+ var init_patterns = __esm({
1017
+ "src/validation/patterns.ts"() {
1018
+ "use strict";
1019
+ NIP_PATTERN_CORE = "[1-9]((\\d[1-9])|([1-9]\\d))\\d{7}";
1020
+ VAT_UE_PATTERN_CORE = "(ATU\\d{8}|BE[01]{1}\\d{9}|BG\\d{9,10}|CY\\d{8}[A-Z]|CZ\\d{8,10}|DE\\d{9}|DK\\d{8}|EE\\d{9}|EL\\d{9}|ES([A-Z]\\d{8}|\\d{8}[A-Z]|[A-Z]\\d{7}[A-Z])|FI\\d{8}|FR[A-Z0-9]{2}\\d{9}|HR\\d{11}|HU\\d{8}|IE(\\d{7}[A-Z]{2}|\\d[A-Z0-9+*]\\d{5}[A-Z])|IT\\d{11}|LT(\\d{9}|\\d{12})|LU\\d{8}|LV\\d{11}|MT\\d{8}|NL[A-Z0-9+*]{12}|PT\\d{9}|RO\\d{2,10}|SE\\d{12}|SI\\d{8}|SK\\d{10}|XI((\\d{9}|\\d{12})|(GD|HA)\\d{3}))";
1021
+ Nip = new RegExp(`^${NIP_PATTERN_CORE}$`);
1022
+ VatUe = new RegExp(`^${VAT_UE_PATTERN_CORE}$`);
1023
+ NipVatUe = new RegExp(`^${NIP_PATTERN_CORE}-${VAT_UE_PATTERN_CORE}$`);
1024
+ InternalId = /^[1-9]((\d[1-9])|([1-9]\d))\d{7}-\d{5}$/;
1025
+ PeppolId = /^P[A-Z]{2}[0-9]{6}$/;
1026
+ ReferenceNumber = /^(20[2-9][0-9]|2[1-9][0-9]{2}|[3-9][0-9]{3})(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])-([0-9A-Z]{2})-([0-9A-F]{10})-([0-9A-F]{10})-([0-9A-F]{2})$/;
1027
+ KsefNumber = /^([1-9](\d[1-9]|[1-9]\d)\d{7})-(20[2-9][0-9]|2[1-9]\d{2}|[3-9]\d{3})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])-([0-9A-F]{6})-?([0-9A-F]{6})-([0-9A-F]{2})$/;
1028
+ KsefNumberV35 = /^([1-9]((\d[1-9])|([1-9]\d))\d{7}|M\d{9}|[A-Z]{3}\d{7})-(20[2-9][0-9]|2[1-9][0-9]{2}|[3-9][0-9]{3})(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])-([0-9A-F]{6})([0-9A-F]{6})-([0-9A-F]{2})$/;
1029
+ KsefNumberV36 = /^([1-9]((\d[1-9])|([1-9]\d))\d{7}|M\d{9}|[A-Z]{3}\d{7})-(20[2-9][0-9]|2[1-9][0-9]{2}|[3-9][0-9]{3})(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])-([0-9A-F]{6})-([0-9A-F]{6})-([0-9A-F]{2})$/;
1030
+ CertificateName = /^[a-zA-Z0-9_\- ąćęłńóśźżĄĆĘŁŃÓŚŹŻ]+$/;
1031
+ Pesel = /^\d{2}(?:0[1-9]|1[0-2]|2[1-9]|3[0-2]|4[1-9]|5[0-2]|6[1-9]|7[0-2]|8[1-9]|9[0-2])\d{7}$/;
1032
+ CertificateFingerprint = /^[0-9A-F]{64}$/;
1033
+ Base64String = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
1034
+ Ip4Address = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/;
1035
+ Ip4Range = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}-((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/;
1036
+ Ip4Mask = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}\/(0|[1-9]|1[0-9]|2[0-9]|3[0-2])$/;
1037
+ Sha256Base64 = /^[A-Za-z0-9+/]{43}=$/;
1038
+ NIP_WEIGHTS = [6, 5, 7, 2, 3, 4, 5, 6, 7];
1039
+ PESEL_WEIGHTS = [1, 3, 7, 9, 1, 3, 7, 9, 1, 3];
1040
+ CRC8_POLY = 7;
1041
+ }
1042
+ });
1043
+
1044
+ // src/validation/xml-to-object.ts
1045
+ import { DOMParser } from "@xmldom/xmldom";
1046
+ function xmlToObject(xml) {
1047
+ const errors = [];
1048
+ const doc = new DOMParser({
1049
+ errorHandler: {
1050
+ warning: (_msg) => {
1051
+ },
1052
+ error: (msg) => errors.push(msg),
1053
+ fatalError: (msg) => errors.push(msg)
1054
+ }
1055
+ }).parseFromString(xml, "text/xml");
1056
+ if (errors.length > 0 || !doc || !doc.documentElement) {
1057
+ return { object: null, rootElement: null, namespace: null, errors };
1058
+ }
1059
+ const root = doc.documentElement;
1060
+ const rootName = getLocalName(root);
1061
+ const namespace = root.namespaceURI || null;
1062
+ const obj = elementToObject(root);
1063
+ return {
1064
+ object: typeof obj === "object" && obj !== null ? obj : { "#text": obj },
1065
+ rootElement: rootName,
1066
+ namespace,
1067
+ errors: []
1068
+ };
1069
+ }
1070
+ function getLocalName(node) {
1071
+ if (node.localName) return node.localName;
1072
+ const name = node.nodeName;
1073
+ const idx = name.indexOf(":");
1074
+ return idx === -1 ? name : name.substring(idx + 1);
1075
+ }
1076
+ function elementToObject(el) {
1077
+ const result = {};
1078
+ let hasChildElements = false;
1079
+ for (let i = 0; i < el.attributes.length; i++) {
1080
+ const a = el.attributes.item(i);
1081
+ if (!a) continue;
1082
+ const name = a.nodeName;
1083
+ if (name === "xmlns" || name.startsWith("xmlns:")) continue;
1084
+ const attrLocal = getLocalName(a);
1085
+ result[`@${attrLocal}`] = a.value;
1086
+ }
1087
+ const childCounts = /* @__PURE__ */ new Map();
1088
+ for (let i = 0; i < el.childNodes.length; i++) {
1089
+ const child = el.childNodes.item(i);
1090
+ if (!child || child.nodeType !== 1) continue;
1091
+ const name = getLocalName(child);
1092
+ childCounts.set(name, (childCounts.get(name) || 0) + 1);
1093
+ hasChildElements = true;
1094
+ }
1095
+ if (!hasChildElements) {
1096
+ const text = getTextContent(el);
1097
+ const hasAttrs = Object.keys(result).length > 0;
1098
+ if (hasAttrs) {
1099
+ result["#text"] = text;
1100
+ return result;
1101
+ }
1102
+ return text;
1103
+ }
1104
+ for (let i = 0; i < el.childNodes.length; i++) {
1105
+ const child = el.childNodes.item(i);
1106
+ if (!child || child.nodeType !== 1) continue;
1107
+ const name = getLocalName(child);
1108
+ const value = elementToObject(child);
1109
+ const count = childCounts.get(name) || 1;
1110
+ if (count > 1) {
1111
+ if (!Array.isArray(result[name])) {
1112
+ result[name] = [];
1113
+ }
1114
+ result[name].push(value);
1115
+ } else {
1116
+ result[name] = value;
1117
+ }
1118
+ }
1119
+ return result;
1120
+ }
1121
+ function getTextContent(el) {
1122
+ let text = "";
1123
+ for (let i = 0; i < el.childNodes.length; i++) {
1124
+ const child = el.childNodes.item(i);
1125
+ if (!child) continue;
1126
+ if (child.nodeType === 3 || child.nodeType === 4) {
1127
+ text += child.nodeValue || "";
1128
+ }
1129
+ }
1130
+ return text.trim();
1131
+ }
1132
+ var init_xml_to_object = __esm({
1133
+ "src/validation/xml-to-object.ts"() {
1134
+ "use strict";
1135
+ }
1136
+ });
1137
+
929
1138
  // src/validation/schemas/fa3.ts
930
1139
  var fa3_exports = {};
931
1140
  __export(fa3_exports, {
@@ -940,18 +1149,18 @@ var init_fa3 = __esm({
940
1149
  TDataCzas = z.string();
941
1150
  TZnakowy = z.string().min(1).max(256);
942
1151
  TNaglowek = z.object({
943
- "KodFormularza": z.object({ "#text": TKodFormularza, "@kodSystemowy": z.literal("FA (3)"), "@wersjaSchemy": z.literal("1-0E") }),
1152
+ "KodFormularza": z.object({ "#text": TKodFormularza, "@kodSystemowy": z.literal("FA (3)"), "@wersjaSchemy": z.literal("1-0E") }).strict(),
944
1153
  "WariantFormularza": z.literal("3"),
945
1154
  "DataWytworzeniaFa": z.string(),
946
1155
  "SystemInfo": TZnakowy.optional()
947
- });
1156
+ }).strict();
948
1157
  TKodyKrajowUE = z.enum(["AT", "BE", "BG", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "EL", "HR", "HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL", "PL", "PT", "RO", "SK", "SI", "ES", "SE", "XI"]);
949
1158
  TNrNIP = z.string().regex(/^[1-9]((\d[1-9])|([1-9]\d))\d{7}$/);
950
1159
  TZnakowy512 = z.string().min(1).max(512);
951
1160
  TPodmiot1 = z.object({
952
1161
  "NIP": TNrNIP,
953
1162
  "Nazwa": TZnakowy512
954
- });
1163
+ }).strict();
955
1164
  TKodKraju = z.enum(["AF", "AX", "AL", "DZ", "AD", "AO", "AI", "AQ", "AG", "AN", "SA", "AR", "AM", "AW", "AU", "AT", "AZ", "BS", "BH", "BD", "BB", "BE", "BZ", "BJ", "BM", "BT", "BY", "BO", "BQ", "BA", "BW", "BR", "BN", "IO", "BG", "BF", "BI", "XC", "CL", "CN", "HR", "CW", "CY", "TD", "ME", "DK", "DM", "DO", "DJ", "EG", "EC", "ER", "EE", "ET", "FK", "FJ", "PH", "FI", "FR", "TF", "GA", "GM", "GH", "GI", "GR", "GD", "GL", "GE", "GU", "GG", "GY", "GF", "GP", "GT", "GN", "GQ", "GW", "HT", "ES", "HN", "HK", "IN", "ID", "IQ", "IR", "IE", "IS", "IL", "JM", "JP", "YE", "JE", "JO", "KY", "KH", "CM", "CA", "QA", "KZ", "KE", "KG", "KI", "CO", "KM", "CG", "CD", "KP", "XK", "CR", "CU", "KW", "LA", "LS", "LB", "LR", "LY", "LI", "LT", "LV", "LU", "MK", "MG", "YT", "MO", "MW", "MV", "MY", "ML", "MT", "MP", "MA", "MQ", "MR", "MU", "MX", "XL", "FM", "UM", "MD", "MC", "MN", "MS", "MZ", "MM", "NA", "NR", "NP", "NL", "DE", "NE", "NG", "NI", "NU", "NF", "NO", "NC", "NZ", "PS", "OM", "PK", "PW", "PA", "PG", "PY", "PE", "PN", "PF", "PL", "GS", "PT", "PR", "CF", "CZ", "KR", "ZA", "RE", "RU", "RO", "RW", "EH", "BL", "KN", "LC", "MF", "VC", "SV", "WS", "AS", "SM", "SN", "RS", "SC", "SL", "SG", "SK", "SI", "SO", "LK", "PM", "US", "SZ", "SD", "SS", "SR", "SJ", "SH", "SY", "CH", "SE", "TJ", "TH", "TW", "TZ", "TG", "TK", "TO", "TT", "TN", "TR", "TM", "TV", "UG", "UA", "UY", "UZ", "VU", "WF", "VA", "HU", "VE", "GB", "VN", "IT", "TL", "CI", "BV", "CX", "IM", "SX", "CK", "VI", "VG", "HM", "CC", "MH", "FO", "SB", "ST", "TC", "ZM", "CV", "ZW", "AE", "XI"]);
956
1165
  TGLN = z.string().min(1).max(13);
957
1166
  TAdres = z.object({
@@ -959,7 +1168,7 @@ var init_fa3 = __esm({
959
1168
  "AdresL1": TZnakowy512,
960
1169
  "AdresL2": TZnakowy512.optional(),
961
1170
  "GLN": TGLN.optional()
962
- });
1171
+ }).strict();
963
1172
  TAdresEmail = z.string().min(3).max(255).regex(/^(.)+@(.)+$/);
964
1173
  TNumerTelefonu = z.string().min(1).max(16);
965
1174
  TStatusInfoPodatnika = z.enum(["1", "2", "3", "4"]);
@@ -974,7 +1183,7 @@ var init_fa3 = __esm({
974
1183
  "NrID": z.string().min(1).max(50).optional(),
975
1184
  "BrakID": TWybor1.optional(),
976
1185
  "Nazwa": TZnakowy512.optional()
977
- });
1186
+ }).strict();
978
1187
  TZnakowy50 = z.string().min(1).max(50);
979
1188
  TZnakowy20 = z.string().min(1).max(20);
980
1189
  TNIPIdWew = z.string().min(1).max(20).regex(/^[1-9]((\d[1-9])|([1-9]\d))\d{7}-\d{5}$/);
@@ -987,7 +1196,7 @@ var init_fa3 = __esm({
987
1196
  "NrID": z.string().min(1).max(50).optional(),
988
1197
  "BrakID": TWybor1.optional(),
989
1198
  "Nazwa": TZnakowy512.optional()
990
- });
1199
+ }).strict();
991
1200
  TRolaPodmiotu3 = z.enum(["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"]);
992
1201
  TProcentowy = z.coerce.number().min(0).max(100);
993
1202
  TRolaPodmiotuUpowaznionego = z.enum(["1", "2", "3"]);
@@ -1005,7 +1214,7 @@ var init_fa3 = __esm({
1005
1214
  "NrWiersza": TNaturalny.optional(),
1006
1215
  "Klucz": TZnakowy,
1007
1216
  "Wartosc": TZnakowy
1008
- });
1217
+ }).strict();
1009
1218
  TKwotowy2 = z.string().regex(/^-?([1-9]\d{0,13}|0)(\.\d{1,8})?$/);
1010
1219
  TStawkaPodatku = z.enum(["23", "22", "8", "7", "5", "4", "3", "0 KR", "0 WDT", "0 EX", "zw", "oo", "np I", "np II"]);
1011
1220
  TGTU = z.enum(["GTU_01", "GTU_02", "GTU_03", "GTU_04", "GTU_05", "GTU_06", "GTU_07", "GTU_08", "GTU_09", "GTU_10", "GTU_11", "GTU_12", "GTU_13"]);
@@ -1020,7 +1229,7 @@ var init_fa3 = __esm({
1020
1229
  "RachunekWlasnyBanku": TRachunekWlasnyBanku.optional(),
1021
1230
  "NazwaBanku": TZnakowy.optional(),
1022
1231
  "OpisRachunku": TZnakowy.optional()
1023
- });
1232
+ }).strict();
1024
1233
  TDataU = z.string();
1025
1234
  TRodzajTransportu = z.enum(["1", "2", "3", "4", "5", "7", "8"]);
1026
1235
  TLadunek = z.enum(["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"]);
@@ -1041,13 +1250,13 @@ var init_fa3 = __esm({
1041
1250
  "AdresL1": TZnakowy512,
1042
1251
  "AdresL2": TZnakowy512.optional(),
1043
1252
  "GLN": TGLN.optional()
1044
- }).optional(),
1253
+ }).strict().optional(),
1045
1254
  "DaneKontaktowe": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(z.object({
1046
1255
  "Email": TAdresEmail.optional(),
1047
1256
  "Telefon": TNumerTelefonu.optional()
1048
- })).min(0).max(3)).optional(),
1257
+ }).strict()).min(0).max(3)).optional(),
1049
1258
  "StatusInfoPodatnika": TStatusInfoPodatnika.optional()
1050
- }),
1259
+ }).strict(),
1051
1260
  "Podmiot2": z.object({
1052
1261
  "NrEORI": TZnakowy.optional(),
1053
1262
  "DaneIdentyfikacyjne": TPodmiot2,
@@ -1056,12 +1265,12 @@ var init_fa3 = __esm({
1056
1265
  "DaneKontaktowe": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(z.object({
1057
1266
  "Email": TAdresEmail.optional(),
1058
1267
  "Telefon": TNumerTelefonu.optional()
1059
- })).min(0).max(3)).optional(),
1268
+ }).strict()).min(0).max(3)).optional(),
1060
1269
  "NrKlienta": TZnakowy.optional(),
1061
1270
  "IDNabywcy": z.string().min(1).max(32).optional(),
1062
1271
  "JST": z.enum(["1", "2"]),
1063
1272
  "GV": z.enum(["1", "2"])
1064
- }),
1273
+ }).strict(),
1065
1274
  "Podmiot3": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(z.object({
1066
1275
  "IDNabywcy": z.string().min(1).max(32).optional(),
1067
1276
  "NrEORI": TZnakowy.optional(),
@@ -1071,13 +1280,13 @@ var init_fa3 = __esm({
1071
1280
  "DaneKontaktowe": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(z.object({
1072
1281
  "Email": TAdresEmail.optional(),
1073
1282
  "Telefon": TNumerTelefonu.optional()
1074
- })).min(0).max(3)).optional(),
1283
+ }).strict()).min(0).max(3)).optional(),
1075
1284
  "Rola": TRolaPodmiotu3.optional(),
1076
1285
  "RolaInna": TWybor1.optional(),
1077
1286
  "OpisRoli": TZnakowy.optional(),
1078
1287
  "Udzial": TProcentowy.optional(),
1079
1288
  "NrKlienta": TZnakowy.optional()
1080
- })).min(0).max(100)).optional(),
1289
+ }).strict()).min(0).max(100)).optional(),
1081
1290
  "PodmiotUpowazniony": z.object({
1082
1291
  "NrEORI": TZnakowy.optional(),
1083
1292
  "DaneIdentyfikacyjne": TPodmiot1,
@@ -1086,9 +1295,9 @@ var init_fa3 = __esm({
1086
1295
  "DaneKontaktowe": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(z.object({
1087
1296
  "EmailPU": TAdresEmail.optional(),
1088
1297
  "TelefonPU": TNumerTelefonu.optional()
1089
- })).min(0).max(3)).optional(),
1298
+ }).strict()).min(0).max(3)).optional(),
1090
1299
  "RolaPU": TRolaPodmiotuUpowaznionego
1091
- }).optional(),
1300
+ }).strict().optional(),
1092
1301
  "Fa": z.object({
1093
1302
  "KodWaluty": TKodWaluty,
1094
1303
  "P_1": TDataT,
@@ -1099,7 +1308,7 @@ var init_fa3 = __esm({
1099
1308
  "OkresFa": z.object({
1100
1309
  "P_6_Od": TDataT,
1101
1310
  "P_6_Do": TDataT
1102
- }).optional(),
1311
+ }).strict().optional(),
1103
1312
  "P_13_1": TKwotowy.optional(),
1104
1313
  "P_14_1": TKwotowy.optional(),
1105
1314
  "P_14_1W": TKwotowy.optional(),
@@ -1129,7 +1338,7 @@ var init_fa3 = __esm({
1129
1338
  "P_17": TWybor1_2,
1130
1339
  "P_18": TWybor1_2,
1131
1340
  "P_18A": TWybor1_2,
1132
- "Zwolnienie": z.union([z.object({ "P_19": TWybor1, "P_19A": TZnakowy.optional(), "P_19B": TZnakowy.optional(), "P_19C": TZnakowy.optional() }), z.object({ "P_19N": TWybor1 })]),
1341
+ "Zwolnienie": z.union([z.object({ "P_19": TWybor1, "P_19A": TZnakowy.optional(), "P_19B": TZnakowy.optional(), "P_19C": TZnakowy.optional() }).strict(), z.object({ "P_19N": TWybor1 }).strict()]),
1133
1342
  "NoweSrodkiTransportu": z.union([z.object({ "P_22": TWybor1, "P_42_5": TWybor1_2, "NowySrodekTransportu": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(z.object({
1134
1343
  "P_22A": TDataT,
1135
1344
  "P_NrWierszaNST": TNaturalny,
@@ -1148,10 +1357,10 @@ var init_fa3 = __esm({
1148
1357
  "P_22C1": TZnakowy.optional(),
1149
1358
  "P_22D": TZnakowy.optional(),
1150
1359
  "P_22D1": TZnakowy.optional()
1151
- })).min(1).max(1e4)) }), z.object({ "P_22N": TWybor1 })]),
1360
+ }).strict()).min(1).max(1e4)) }).strict(), z.object({ "P_22N": TWybor1 }).strict()]),
1152
1361
  "P_23": TWybor1_2,
1153
- "PMarzy": z.union([z.object({ "P_PMarzy": TWybor1, "P_PMarzy_2": TWybor1.optional(), "P_PMarzy_3_1": TWybor1.optional(), "P_PMarzy_3_2": TWybor1.optional(), "P_PMarzy_3_3": TWybor1.optional() }), z.object({ "P_PMarzyN": TWybor1 })])
1154
- }),
1362
+ "PMarzy": z.union([z.object({ "P_PMarzy": TWybor1, "P_PMarzy_2": TWybor1.optional(), "P_PMarzy_3_1": TWybor1.optional(), "P_PMarzy_3_2": TWybor1.optional(), "P_PMarzy_3_3": TWybor1.optional() }).strict(), z.object({ "P_PMarzyN": TWybor1 }).strict()])
1363
+ }).strict(),
1155
1364
  "RodzajFaktury": TRodzajFaktury,
1156
1365
  "PrzyczynaKorekty": TZnakowy.optional(),
1157
1366
  "TypKorekty": TTypKorekty.optional(),
@@ -1161,30 +1370,30 @@ var init_fa3 = __esm({
1161
1370
  "NrKSeF": TWybor1.optional(),
1162
1371
  "NrKSeFFaKorygowanej": TNumerKSeF.optional(),
1163
1372
  "NrKSeFN": TWybor1.optional()
1164
- })).min(1).max(5e4)).optional(),
1373
+ }).strict()).min(1).max(5e4)).optional(),
1165
1374
  "OkresFaKorygowanej": TZnakowy.optional(),
1166
1375
  "NrFaKorygowany": TZnakowy.optional(),
1167
1376
  "Podmiot1K": z.object({
1168
1377
  "PrefiksPodatnika": TKodyKrajowUE.optional(),
1169
1378
  "DaneIdentyfikacyjne": TPodmiot1,
1170
1379
  "Adres": TAdres
1171
- }).optional(),
1380
+ }).strict().optional(),
1172
1381
  "Podmiot2K": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(z.object({
1173
1382
  "DaneIdentyfikacyjne": TPodmiot2,
1174
1383
  "Adres": TAdres.optional(),
1175
1384
  "IDNabywcy": z.string().min(1).max(32).optional()
1176
- })).min(0).max(101)).optional(),
1385
+ }).strict()).min(0).max(101)).optional(),
1177
1386
  "P_15ZK": TKwotowy.optional(),
1178
1387
  "KursWalutyZK": TIlosci.optional(),
1179
1388
  "ZaliczkaCzesciowa": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(z.object({
1180
1389
  "P_6Z": TDataT,
1181
1390
  "P_15Z": TKwotowy,
1182
1391
  "KursWalutyZW": TIlosci.optional()
1183
- })).min(0).max(31)).optional(),
1392
+ }).strict()).min(0).max(31)).optional(),
1184
1393
  "FP": TWybor1.optional(),
1185
1394
  "TP": TWybor1.optional(),
1186
1395
  "DodatkowyOpis": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(TKluczWartosc).min(0).max(1e4)).optional(),
1187
- "FakturaZaliczkowa": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(z.union([z.object({ "NrKSeFZN": TWybor1, "NrFaZaliczkowej": TZnakowy }), z.object({ "NrKSeFFaZaliczkowej": TNumerKSeF })])).min(0).max(100)).optional(),
1396
+ "FakturaZaliczkowa": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(z.union([z.object({ "NrKSeFZN": TWybor1, "NrFaZaliczkowej": TZnakowy }).strict(), z.object({ "NrKSeFFaZaliczkowej": TNumerKSeF }).strict()])).min(0).max(100)).optional(),
1188
1397
  "ZwrotAkcyzy": TWybor1.optional(),
1189
1398
  "FaWiersz": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(z.object({
1190
1399
  "NrWierszaFa": TNaturalny,
@@ -1212,21 +1421,21 @@ var init_fa3 = __esm({
1212
1421
  "Procedura": TOznaczenieProcedury.optional(),
1213
1422
  "KursWaluty": TIlosci.optional(),
1214
1423
  "StanPrzed": TWybor1.optional()
1215
- })).min(0).max(1e4)).optional(),
1424
+ }).strict()).min(0).max(1e4)).optional(),
1216
1425
  "Rozliczenie": z.object({
1217
1426
  "Obciazenia": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(z.object({
1218
1427
  "Kwota": TKwotowy,
1219
1428
  "Powod": TZnakowy
1220
- })).min(0).max(100)).optional(),
1429
+ }).strict()).min(0).max(100)).optional(),
1221
1430
  "SumaObciazen": TKwotowy.optional(),
1222
1431
  "Odliczenia": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(z.object({
1223
1432
  "Kwota": TKwotowy,
1224
1433
  "Powod": TZnakowy
1225
- })).min(0).max(100)).optional(),
1434
+ }).strict()).min(0).max(100)).optional(),
1226
1435
  "SumaOdliczen": TKwotowy.optional(),
1227
1436
  "DoZaplaty": TKwotowy.optional(),
1228
1437
  "DoRozliczenia": TKwotowy.optional()
1229
- }).optional(),
1438
+ }).strict().optional(),
1230
1439
  "Platnosc": z.object({
1231
1440
  "Zaplacono": TWybor1.optional(),
1232
1441
  "DataZaplaty": TData.optional(),
@@ -1237,15 +1446,15 @@ var init_fa3 = __esm({
1237
1446
  "FormaPlatnosci": TFormaPlatnosci.optional(),
1238
1447
  "PlatnoscInna": TWybor1.optional(),
1239
1448
  "OpisPlatnosci": TZnakowy.optional()
1240
- })).min(1).max(100)).optional(),
1449
+ }).strict()).min(1).max(100)).optional(),
1241
1450
  "TerminPlatnosci": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(z.object({
1242
1451
  "Termin": TData.optional(),
1243
1452
  "TerminOpis": z.object({
1244
1453
  "Ilosc": z.coerce.number().int(),
1245
1454
  "Jednostka": TZnakowy50,
1246
1455
  "ZdarzeniePoczatkowe": TZnakowy
1247
- }).optional()
1248
- })).min(0).max(100)).optional(),
1456
+ }).strict().optional()
1457
+ }).strict()).min(0).max(100)).optional(),
1249
1458
  "FormaPlatnosci": TFormaPlatnosci.optional(),
1250
1459
  "PlatnoscInna": TWybor1.optional(),
1251
1460
  "OpisPlatnosci": TZnakowy.optional(),
@@ -1254,19 +1463,19 @@ var init_fa3 = __esm({
1254
1463
  "Skonto": z.object({
1255
1464
  "WarunkiSkonta": TZnakowy,
1256
1465
  "WysokoscSkonta": TZnakowy
1257
- }).optional(),
1466
+ }).strict().optional(),
1258
1467
  "LinkDoPlatnosci": z.string().min(1).max(512).regex(/^(https?):\/\/([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}(:[0-9]{1,5})?(\/[^\s?#]*)?\?([^#\s]*&)?IPKSeF=[0-9]{3}[a-zA-Z0-9]{10}(&[^#\s]*)?(#.*)?$/).optional(),
1259
1468
  "IPKSeF": z.string().min(1).max(13).regex(/^[0-9]{3}[a-zA-Z0-9]{10}$/).optional()
1260
- }).optional(),
1469
+ }).strict().optional(),
1261
1470
  "WarunkiTransakcji": z.object({
1262
1471
  "Umowy": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(z.object({
1263
1472
  "DataUmowy": TDataU.optional(),
1264
1473
  "NrUmowy": TZnakowy.optional()
1265
- })).min(0).max(100)).optional(),
1474
+ }).strict()).min(0).max(100)).optional(),
1266
1475
  "Zamowienia": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(z.object({
1267
1476
  "DataZamowienia": TDataU.optional(),
1268
1477
  "NrZamowienia": TZnakowy.optional()
1269
- })).min(0).max(100)).optional(),
1478
+ }).strict()).min(0).max(100)).optional(),
1270
1479
  "NrPartiiTowaru": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(TZnakowy).min(0).max(1e3)).optional(),
1271
1480
  "WarunkiDostawy": TZnakowy.optional(),
1272
1481
  "KursUmowny": TIlosci.optional(),
@@ -1278,7 +1487,7 @@ var init_fa3 = __esm({
1278
1487
  "Przewoznik": z.object({
1279
1488
  "DaneIdentyfikacyjne": TPodmiot2,
1280
1489
  "AdresPrzewoznika": TAdres
1281
- }).optional(),
1490
+ }).strict().optional(),
1282
1491
  "NrZleceniaTransportu": TZnakowy.optional(),
1283
1492
  "OpisLadunku": TLadunek.optional(),
1284
1493
  "LadunekInny": TWybor1.optional(),
@@ -1289,9 +1498,9 @@ var init_fa3 = __esm({
1289
1498
  "WysylkaZ": TAdres.optional(),
1290
1499
  "WysylkaPrzez": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(TAdres).min(0).max(20)).optional(),
1291
1500
  "WysylkaDo": TAdres.optional()
1292
- })).min(0).max(20)).optional(),
1501
+ }).strict()).min(0).max(20)).optional(),
1293
1502
  "PodmiotPosredniczacy": TWybor1.optional()
1294
- }).optional(),
1503
+ }).strict().optional(),
1295
1504
  "Zamowienie": z.object({
1296
1505
  "WartoscZamowienia": TKwotowy,
1297
1506
  "ZamowienieWiersz": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(z.object({
@@ -1315,24 +1524,24 @@ var init_fa3 = __esm({
1315
1524
  "ProceduraZ": TOznaczenieProceduryZ.optional(),
1316
1525
  "KwotaAkcyzyZ": TKwotowy.optional(),
1317
1526
  "StanPrzedZ": TWybor1.optional()
1318
- })).min(1).max(1e4))
1319
- }).optional()
1320
- }),
1527
+ }).strict()).min(1).max(1e4))
1528
+ }).strict().optional()
1529
+ }).strict(),
1321
1530
  "Stopka": z.object({
1322
1531
  "Informacje": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(z.object({
1323
1532
  "StopkaFaktury": TTekstowy.optional()
1324
- })).min(0).max(3)).optional(),
1533
+ }).strict()).min(0).max(3)).optional(),
1325
1534
  "Rejestry": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(z.object({
1326
1535
  "PelnaNazwa": TZnakowy.optional(),
1327
1536
  "KRS": TNrKRS.optional(),
1328
1537
  "REGON": TNrREGON.optional(),
1329
1538
  "BDO": z.string().min(1).max(9).optional()
1330
- })).min(0).max(100)).optional()
1331
- }).optional(),
1539
+ }).strict()).min(0).max(100)).optional()
1540
+ }).strict().optional(),
1332
1541
  "Zalacznik": z.object({
1333
1542
  "BlokDanych": z.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z.array(z.any()).min(1).max(1e3))
1334
- }).optional()
1335
- });
1543
+ }).strict().optional()
1544
+ }).strict();
1336
1545
  }
1337
1546
  });
1338
1547
 
@@ -1350,18 +1559,18 @@ var init_fa2 = __esm({
1350
1559
  TDataCzas2 = z2.string();
1351
1560
  TZnakowy3 = z2.string().min(1).max(256);
1352
1561
  TNaglowek2 = z2.object({
1353
- "KodFormularza": z2.object({ "#text": TKodFormularza2, "@kodSystemowy": z2.literal("FA (2)"), "@wersjaSchemy": z2.literal("1-0E") }),
1562
+ "KodFormularza": z2.object({ "#text": TKodFormularza2, "@kodSystemowy": z2.literal("FA (2)"), "@wersjaSchemy": z2.literal("1-0E") }).strict(),
1354
1563
  "WariantFormularza": z2.literal("2"),
1355
1564
  "DataWytworzeniaFa": z2.string(),
1356
1565
  "SystemInfo": TZnakowy3.optional()
1357
- });
1566
+ }).strict();
1358
1567
  TKodyKrajowUE2 = z2.enum(["AT", "BE", "BG", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "EL", "HR", "HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL", "PL", "PT", "RO", "SK", "SI", "ES", "SE", "XI"]);
1359
1568
  TNrNIP2 = z2.string().regex(/^[1-9]((\d[1-9])|([1-9]\d))\d{7}$/);
1360
1569
  TZnakowy5122 = z2.string().min(1).max(512);
1361
1570
  TPodmiot12 = z2.object({
1362
1571
  "NIP": TNrNIP2,
1363
1572
  "Nazwa": TZnakowy5122
1364
- });
1573
+ }).strict();
1365
1574
  TKodKraju2 = z2.enum(["AF", "AX", "AL", "DZ", "AD", "AO", "AI", "AQ", "AG", "AN", "SA", "AR", "AM", "AW", "AU", "AT", "AZ", "BS", "BH", "BD", "BB", "BE", "BZ", "BJ", "BM", "BT", "BY", "BO", "BQ", "BA", "BW", "BR", "BN", "IO", "BG", "BF", "BI", "XC", "CL", "CN", "HR", "CW", "CY", "TD", "ME", "DK", "DM", "DO", "DJ", "EG", "EC", "ER", "EE", "ET", "FK", "FJ", "PH", "FI", "FR", "TF", "GA", "GM", "GH", "GI", "GR", "GD", "GL", "GE", "GU", "GG", "GY", "GF", "GP", "GT", "GN", "GQ", "GW", "HT", "ES", "HN", "HK", "IN", "ID", "IQ", "IR", "IE", "IS", "IL", "JM", "JP", "YE", "JE", "JO", "KY", "KH", "CM", "CA", "QA", "KZ", "KE", "KG", "KI", "CO", "KM", "CG", "CD", "KP", "XK", "CR", "CU", "KW", "LA", "LS", "LB", "LR", "LY", "LI", "LT", "LV", "LU", "MK", "MG", "YT", "MO", "MW", "MV", "MY", "ML", "MT", "MP", "MA", "MQ", "MR", "MU", "MX", "XL", "FM", "UM", "MD", "MC", "MN", "MS", "MZ", "MM", "NA", "NR", "NP", "NL", "DE", "NE", "NG", "NI", "NU", "NF", "NO", "NC", "NZ", "PS", "OM", "PK", "PW", "PA", "PG", "PY", "PE", "PN", "PF", "PL", "GS", "PT", "PR", "CF", "CZ", "KR", "ZA", "RE", "RU", "RO", "RW", "EH", "BL", "KN", "LC", "MF", "VC", "SV", "WS", "AS", "SM", "SN", "RS", "SC", "SL", "SG", "SK", "SI", "SO", "LK", "PM", "US", "SZ", "SD", "SS", "SR", "SJ", "SH", "SY", "CH", "SE", "TJ", "TH", "TW", "TZ", "TG", "TK", "TO", "TT", "TN", "TR", "TM", "TV", "UG", "UA", "UY", "UZ", "VU", "WF", "VA", "HU", "VE", "GB", "VN", "IT", "TL", "CI", "BV", "CX", "IM", "SX", "CK", "VI", "VG", "HM", "CC", "MH", "FO", "SB", "ST", "TC", "ZM", "CV", "ZW", "AE", "XI"]);
1366
1575
  TGLN2 = z2.string().min(1).max(13);
1367
1576
  TAdres2 = z2.object({
@@ -1369,7 +1578,7 @@ var init_fa2 = __esm({
1369
1578
  "AdresL1": TZnakowy5122,
1370
1579
  "AdresL2": TZnakowy5122.optional(),
1371
1580
  "GLN": TGLN2.optional()
1372
- });
1581
+ }).strict();
1373
1582
  TAdresEmail2 = z2.string().min(3).max(255).regex(/^(.)+@(.)+$/);
1374
1583
  TNumerTelefonu2 = z2.string().min(1).max(16);
1375
1584
  TStatusInfoPodatnika2 = z2.enum(["1", "2", "3", "4"]);
@@ -1384,7 +1593,7 @@ var init_fa2 = __esm({
1384
1593
  "NrID": z2.string().min(1).max(50).regex(/^[a-zA-Z0-9]{1,50}$/).optional(),
1385
1594
  "BrakID": TWybor12.optional(),
1386
1595
  "Nazwa": TZnakowy5122.optional()
1387
- });
1596
+ }).strict();
1388
1597
  TZnakowy502 = z2.string().min(1).max(50);
1389
1598
  TZnakowy202 = z2.string().min(1).max(20);
1390
1599
  TNIPIdWew2 = z2.string().min(1).max(20).regex(/^[1-9]((\d[1-9])|([1-9]\d))\d{7}-\d{5}$/);
@@ -1397,7 +1606,7 @@ var init_fa2 = __esm({
1397
1606
  "NrID": z2.string().min(1).max(50).regex(/^[a-zA-Z0-9]{1,50}$/).optional(),
1398
1607
  "BrakID": TWybor12.optional(),
1399
1608
  "Nazwa": TZnakowy5122.optional()
1400
- });
1609
+ }).strict();
1401
1610
  TRolaPodmiotu32 = z2.enum(["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]);
1402
1611
  TProcentowy2 = z2.coerce.number().min(0).max(100);
1403
1612
  TRolaPodmiotuUpowaznionego2 = z2.enum(["1", "2", "3"]);
@@ -1415,7 +1624,7 @@ var init_fa2 = __esm({
1415
1624
  "NrWiersza": TNaturalny2.optional(),
1416
1625
  "Klucz": TZnakowy3,
1417
1626
  "Wartosc": TZnakowy3
1418
- });
1627
+ }).strict();
1419
1628
  TKwotowy22 = z2.string().regex(/^-?([1-9]\d{0,13}|0)(\.\d{1,8})?$/);
1420
1629
  TStawkaPodatku2 = z2.enum(["23", "22", "8", "7", "5", "4", "3", "0", "zw", "oo", "np"]);
1421
1630
  TGTU2 = z2.enum(["GTU_01", "GTU_02", "GTU_03", "GTU_04", "GTU_05", "GTU_06", "GTU_07", "GTU_08", "GTU_09", "GTU_10", "GTU_11", "GTU_12", "GTU_13"]);
@@ -1430,7 +1639,7 @@ var init_fa2 = __esm({
1430
1639
  "RachunekWlasnyBanku": TRachunekWlasnyBanku2.optional(),
1431
1640
  "NazwaBanku": TZnakowy3.optional(),
1432
1641
  "OpisRachunku": TZnakowy3.optional()
1433
- });
1642
+ }).strict();
1434
1643
  TRodzajTransportu2 = z2.enum(["1", "2", "3", "4", "5", "7", "8"]);
1435
1644
  TLadunek2 = z2.enum(["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"]);
1436
1645
  TOznaczenieProceduryZ2 = z2.enum(["WSTO_EE", "IED", "TT_D", "B_SPV", "B_SPV_DOSTAWA", "B_MPV_PROWIZJA"]);
@@ -1449,13 +1658,13 @@ var init_fa2 = __esm({
1449
1658
  "AdresL1": TZnakowy5122,
1450
1659
  "AdresL2": TZnakowy5122.optional(),
1451
1660
  "GLN": TGLN2.optional()
1452
- }).optional(),
1661
+ }).strict().optional(),
1453
1662
  "DaneKontaktowe": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(z2.object({
1454
1663
  "Email": TAdresEmail2.optional(),
1455
1664
  "Telefon": TNumerTelefonu2.optional()
1456
- })).min(0).max(3)).optional(),
1665
+ }).strict()).min(0).max(3)).optional(),
1457
1666
  "StatusInfoPodatnika": TStatusInfoPodatnika2.optional()
1458
- }),
1667
+ }).strict(),
1459
1668
  "Podmiot2": z2.object({
1460
1669
  "NrEORI": TZnakowy3.optional(),
1461
1670
  "DaneIdentyfikacyjne": TPodmiot22,
@@ -1464,10 +1673,10 @@ var init_fa2 = __esm({
1464
1673
  "DaneKontaktowe": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(z2.object({
1465
1674
  "Email": TAdresEmail2.optional(),
1466
1675
  "Telefon": TNumerTelefonu2.optional()
1467
- })).min(0).max(3)).optional(),
1676
+ }).strict()).min(0).max(3)).optional(),
1468
1677
  "NrKlienta": TZnakowy3.optional(),
1469
1678
  "IDNabywcy": z2.string().min(1).max(32).optional()
1470
- }),
1679
+ }).strict(),
1471
1680
  "Podmiot3": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(z2.object({
1472
1681
  "IDNabywcy": z2.string().min(1).max(32).optional(),
1473
1682
  "NrEORI": TZnakowy3.optional(),
@@ -1477,13 +1686,13 @@ var init_fa2 = __esm({
1477
1686
  "DaneKontaktowe": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(z2.object({
1478
1687
  "Email": TAdresEmail2.optional(),
1479
1688
  "Telefon": TNumerTelefonu2.optional()
1480
- })).min(0).max(3)).optional(),
1689
+ }).strict()).min(0).max(3)).optional(),
1481
1690
  "Rola": TRolaPodmiotu32.optional(),
1482
1691
  "RolaInna": TWybor12.optional(),
1483
1692
  "OpisRoli": TZnakowy3.optional(),
1484
1693
  "Udzial": TProcentowy2.optional(),
1485
1694
  "NrKlienta": TZnakowy3.optional()
1486
- })).min(0).max(100)).optional(),
1695
+ }).strict()).min(0).max(100)).optional(),
1487
1696
  "PodmiotUpowazniony": z2.object({
1488
1697
  "NrEORI": TZnakowy3.optional(),
1489
1698
  "DaneIdentyfikacyjne": TPodmiot12,
@@ -1492,9 +1701,9 @@ var init_fa2 = __esm({
1492
1701
  "DaneKontaktowe": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(z2.object({
1493
1702
  "EmailPU": TAdresEmail2.optional(),
1494
1703
  "TelefonPU": TNumerTelefonu2.optional()
1495
- })).min(0).max(3)).optional(),
1704
+ }).strict()).min(0).max(3)).optional(),
1496
1705
  "RolaPU": TRolaPodmiotuUpowaznionego2
1497
- }).optional(),
1706
+ }).strict().optional(),
1498
1707
  "Fa": z2.object({
1499
1708
  "KodWaluty": TKodWaluty2,
1500
1709
  "P_1": TDataT2,
@@ -1505,7 +1714,7 @@ var init_fa2 = __esm({
1505
1714
  "OkresFa": z2.object({
1506
1715
  "P_6_Od": TDataT2,
1507
1716
  "P_6_Do": TDataT2
1508
- }).optional(),
1717
+ }).strict().optional(),
1509
1718
  "P_13_1": TKwotowy3.optional(),
1510
1719
  "P_14_1": TKwotowy3.optional(),
1511
1720
  "P_14_1W": TKwotowy3.optional(),
@@ -1535,7 +1744,7 @@ var init_fa2 = __esm({
1535
1744
  "P_17": TWybor1_22,
1536
1745
  "P_18": TWybor1_22,
1537
1746
  "P_18A": TWybor1_22,
1538
- "Zwolnienie": z2.union([z2.object({ "P_19": TWybor12, "P_19A": TZnakowy3.optional(), "P_19B": TZnakowy3.optional(), "P_19C": TZnakowy3.optional() }), z2.object({ "P_19N": TWybor12 })]),
1747
+ "Zwolnienie": z2.union([z2.object({ "P_19": TWybor12, "P_19A": TZnakowy3.optional(), "P_19B": TZnakowy3.optional(), "P_19C": TZnakowy3.optional() }).strict(), z2.object({ "P_19N": TWybor12 }).strict()]),
1539
1748
  "NoweSrodkiTransportu": z2.union([z2.object({ "P_22": TWybor12, "P_42_5": TWybor1_22, "NowySrodekTransportu": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(z2.object({
1540
1749
  "P_22A": TDataT2,
1541
1750
  "P_NrWierszaNST": TNaturalny2,
@@ -1554,10 +1763,10 @@ var init_fa2 = __esm({
1554
1763
  "P_22C1": TZnakowy3.optional(),
1555
1764
  "P_22D": TZnakowy3.optional(),
1556
1765
  "P_22D1": TZnakowy3.optional()
1557
- })).min(1).max(1e4)) }), z2.object({ "P_22N": TWybor12 })]),
1766
+ }).strict()).min(1).max(1e4)) }).strict(), z2.object({ "P_22N": TWybor12 }).strict()]),
1558
1767
  "P_23": TWybor1_22,
1559
- "PMarzy": z2.union([z2.object({ "P_PMarzy": TWybor12, "P_PMarzy_2": TWybor12.optional(), "P_PMarzy_3_1": TWybor12.optional(), "P_PMarzy_3_2": TWybor12.optional(), "P_PMarzy_3_3": TWybor12.optional() }), z2.object({ "P_PMarzyN": TWybor12 })])
1560
- }),
1768
+ "PMarzy": z2.union([z2.object({ "P_PMarzy": TWybor12, "P_PMarzy_2": TWybor12.optional(), "P_PMarzy_3_1": TWybor12.optional(), "P_PMarzy_3_2": TWybor12.optional(), "P_PMarzy_3_3": TWybor12.optional() }).strict(), z2.object({ "P_PMarzyN": TWybor12 }).strict()])
1769
+ }).strict(),
1561
1770
  "RodzajFaktury": TRodzajFaktury2,
1562
1771
  "PrzyczynaKorekty": TZnakowy3.optional(),
1563
1772
  "TypKorekty": TTypKorekty2.optional(),
@@ -1567,30 +1776,30 @@ var init_fa2 = __esm({
1567
1776
  "NrKSeF": TWybor12.optional(),
1568
1777
  "NrKSeFFaKorygowanej": TNumerKSeF2.optional(),
1569
1778
  "NrKSeFN": TWybor12.optional()
1570
- })).min(1)).optional(),
1779
+ }).strict()).min(1)).optional(),
1571
1780
  "OkresFaKorygowanej": TZnakowy3.optional(),
1572
1781
  "NrFaKorygowany": TZnakowy3.optional(),
1573
1782
  "Podmiot1K": z2.object({
1574
1783
  "PrefiksPodatnika": TKodyKrajowUE2.optional(),
1575
1784
  "DaneIdentyfikacyjne": TPodmiot12,
1576
1785
  "Adres": TAdres2
1577
- }).optional(),
1786
+ }).strict().optional(),
1578
1787
  "Podmiot2K": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(z2.object({
1579
1788
  "DaneIdentyfikacyjne": TPodmiot22,
1580
1789
  "Adres": TAdres2.optional(),
1581
1790
  "IDNabywcy": z2.string().min(1).max(32).optional()
1582
- })).min(0).max(101)).optional(),
1791
+ }).strict()).min(0).max(101)).optional(),
1583
1792
  "P_15ZK": TKwotowy3.optional(),
1584
1793
  "KursWalutyZK": TIlosci2.optional(),
1585
1794
  "ZaliczkaCzesciowa": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(z2.object({
1586
1795
  "P_6Z": TDataT2,
1587
1796
  "P_15Z": TKwotowy3,
1588
1797
  "KursWalutyZW": TIlosci2.optional()
1589
- })).min(0).max(31)).optional(),
1798
+ }).strict()).min(0).max(31)).optional(),
1590
1799
  "FP": TWybor12.optional(),
1591
1800
  "TP": TWybor12.optional(),
1592
1801
  "DodatkowyOpis": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(TKluczWartosc2).min(0).max(1e4)).optional(),
1593
- "FakturaZaliczkowa": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(z2.union([z2.object({ "NrKSeFZN": TWybor12, "NrFaZaliczkowej": TZnakowy3 }), z2.object({ "NrKSeFFaZaliczkowej": TNumerKSeF2 })])).min(0).max(100)).optional(),
1802
+ "FakturaZaliczkowa": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(z2.union([z2.object({ "NrKSeFZN": TWybor12, "NrFaZaliczkowej": TZnakowy3 }).strict(), z2.object({ "NrKSeFFaZaliczkowej": TNumerKSeF2 }).strict()])).min(0).max(100)).optional(),
1594
1803
  "ZwrotAkcyzy": TWybor12.optional(),
1595
1804
  "FaWiersz": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(z2.object({
1596
1805
  "NrWierszaFa": TNaturalny2,
@@ -1618,21 +1827,21 @@ var init_fa2 = __esm({
1618
1827
  "Procedura": TOznaczenieProcedury2.optional(),
1619
1828
  "KursWaluty": TIlosci2.optional(),
1620
1829
  "StanPrzed": TWybor12.optional()
1621
- })).min(0).max(1e4)).optional(),
1830
+ }).strict()).min(0).max(1e4)).optional(),
1622
1831
  "Rozliczenie": z2.object({
1623
1832
  "Obciazenia": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(z2.object({
1624
1833
  "Kwota": TKwotowy3,
1625
1834
  "Powod": TZnakowy3
1626
- })).min(0).max(100)).optional(),
1835
+ }).strict()).min(0).max(100)).optional(),
1627
1836
  "SumaObciazen": TKwotowy3.optional(),
1628
1837
  "Odliczenia": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(z2.object({
1629
1838
  "Kwota": TKwotowy3,
1630
1839
  "Powod": TZnakowy3
1631
- })).min(0).max(100)).optional(),
1840
+ }).strict()).min(0).max(100)).optional(),
1632
1841
  "SumaOdliczen": TKwotowy3.optional(),
1633
1842
  "DoZaplaty": TKwotowy3.optional(),
1634
1843
  "DoRozliczenia": TKwotowy3.optional()
1635
- }).optional(),
1844
+ }).strict().optional(),
1636
1845
  "Platnosc": z2.object({
1637
1846
  "Zaplacono": TWybor12.optional(),
1638
1847
  "DataZaplaty": TData2.optional(),
@@ -1640,11 +1849,11 @@ var init_fa2 = __esm({
1640
1849
  "ZaplataCzesciowa": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(z2.object({
1641
1850
  "KwotaZaplatyCzesciowej": TKwotowy3,
1642
1851
  "DataZaplatyCzesciowej": TData2
1643
- })).min(1).max(100)).optional(),
1852
+ }).strict()).min(1).max(100)).optional(),
1644
1853
  "TerminPlatnosci": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(z2.object({
1645
1854
  "Termin": TData2,
1646
1855
  "TerminOpis": TZnakowy3.optional()
1647
- })).min(0).max(100)).optional(),
1856
+ }).strict()).min(0).max(100)).optional(),
1648
1857
  "FormaPlatnosci": TFormaPlatnosci2.optional(),
1649
1858
  "PlatnoscInna": TWybor12.optional(),
1650
1859
  "OpisPlatnosci": TZnakowy3.optional(),
@@ -1653,17 +1862,17 @@ var init_fa2 = __esm({
1653
1862
  "Skonto": z2.object({
1654
1863
  "WarunkiSkonta": TZnakowy3,
1655
1864
  "WysokoscSkonta": TZnakowy3
1656
- }).optional()
1657
- }).optional(),
1865
+ }).strict().optional()
1866
+ }).strict().optional(),
1658
1867
  "WarunkiTransakcji": z2.object({
1659
1868
  "Umowy": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(z2.object({
1660
1869
  "DataUmowy": TData2.optional(),
1661
1870
  "NrUmowy": TZnakowy3.optional()
1662
- })).min(0).max(100)).optional(),
1871
+ }).strict()).min(0).max(100)).optional(),
1663
1872
  "Zamowienia": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(z2.object({
1664
1873
  "DataZamowienia": TData2.optional(),
1665
1874
  "NrZamowienia": TZnakowy3.optional()
1666
- })).min(0).max(100)).optional(),
1875
+ }).strict()).min(0).max(100)).optional(),
1667
1876
  "NrPartiiTowaru": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(TZnakowy3).min(0).max(1e3)).optional(),
1668
1877
  "WarunkiDostawy": TZnakowy3.optional(),
1669
1878
  "KursUmowny": TIlosci2.optional(),
@@ -1675,7 +1884,7 @@ var init_fa2 = __esm({
1675
1884
  "Przewoznik": z2.object({
1676
1885
  "DaneIdentyfikacyjne": TPodmiot22,
1677
1886
  "AdresPrzewoznika": TAdres2
1678
- }).optional(),
1887
+ }).strict().optional(),
1679
1888
  "NrZleceniaTransportu": TZnakowy3.optional(),
1680
1889
  "OpisLadunku": TLadunek2.optional(),
1681
1890
  "LadunekInny": TWybor12.optional(),
@@ -1686,9 +1895,9 @@ var init_fa2 = __esm({
1686
1895
  "WysylkaZ": TAdres2.optional(),
1687
1896
  "WysylkaPrzez": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(TAdres2).min(0).max(20)).optional(),
1688
1897
  "WysylkaDo": TAdres2.optional()
1689
- })).min(0).max(20)).optional(),
1898
+ }).strict()).min(0).max(20)).optional(),
1690
1899
  "PodmiotPosredniczacy": TWybor12.optional()
1691
- }).optional(),
1900
+ }).strict().optional(),
1692
1901
  "Zamowienie": z2.object({
1693
1902
  "WartoscZamowienia": TKwotowy3,
1694
1903
  "ZamowienieWiersz": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(z2.object({
@@ -1712,21 +1921,21 @@ var init_fa2 = __esm({
1712
1921
  "ProceduraZ": TOznaczenieProceduryZ2.optional(),
1713
1922
  "KwotaAkcyzyZ": TKwotowy3.optional(),
1714
1923
  "StanPrzedZ": TWybor12.optional()
1715
- })).min(1).max(1e4))
1716
- }).optional()
1717
- }),
1924
+ }).strict()).min(1).max(1e4))
1925
+ }).strict().optional()
1926
+ }).strict(),
1718
1927
  "Stopka": z2.object({
1719
1928
  "Informacje": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(z2.object({
1720
1929
  "StopkaFaktury": TTekstowy2.optional()
1721
- })).min(0).max(3)).optional(),
1930
+ }).strict()).min(0).max(3)).optional(),
1722
1931
  "Rejestry": z2.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z2.array(z2.object({
1723
1932
  "PelnaNazwa": TZnakowy3.optional(),
1724
1933
  "KRS": TNrKRS2.optional(),
1725
1934
  "REGON": TNrREGON2.optional(),
1726
1935
  "BDO": z2.string().min(1).max(9).optional()
1727
- })).min(0).max(100)).optional()
1728
- }).optional()
1729
- });
1936
+ }).strict()).min(0).max(100)).optional()
1937
+ }).strict().optional()
1938
+ }).strict();
1730
1939
  }
1731
1940
  });
1732
1941
 
@@ -1744,17 +1953,17 @@ var init_rr1_v11e = __esm({
1744
1953
  TDataCzas3 = z3.string();
1745
1954
  TZnakowy4 = z3.string().min(1).max(256);
1746
1955
  TNaglowek3 = z3.object({
1747
- "KodFormularza": z3.object({ "#text": TKodFormularza3, "@kodSystemowy": z3.literal("FA_RR (1)"), "@wersjaSchemy": z3.literal("1-1E") }),
1956
+ "KodFormularza": z3.object({ "#text": TKodFormularza3, "@kodSystemowy": z3.literal("FA_RR (1)"), "@wersjaSchemy": z3.literal("1-1E") }).strict(),
1748
1957
  "WariantFormularza": z3.literal("1"),
1749
1958
  "DataWytworzeniaFa": z3.string(),
1750
1959
  "SystemInfo": TZnakowy4.optional()
1751
- });
1960
+ }).strict();
1752
1961
  TNrNIP3 = z3.string().regex(/^[1-9]((\d[1-9])|([1-9]\d))\d{7}$/);
1753
1962
  TZnakowy5123 = z3.string().min(1).max(512);
1754
1963
  TPodmiot13 = z3.object({
1755
1964
  "NIP": TNrNIP3,
1756
1965
  "Nazwa": TZnakowy5123
1757
- });
1966
+ }).strict();
1758
1967
  TKodKraju3 = z3.enum(["AF", "AX", "AL", "DZ", "AD", "AO", "AI", "AQ", "AG", "AN", "SA", "AR", "AM", "AW", "AU", "AT", "AZ", "BS", "BH", "BD", "BB", "BE", "BZ", "BJ", "BM", "BT", "BY", "BO", "BQ", "BA", "BW", "BR", "BN", "IO", "BG", "BF", "BI", "XC", "CL", "CN", "HR", "CW", "CY", "TD", "ME", "DK", "DM", "DO", "DJ", "EG", "EC", "ER", "EE", "ET", "FK", "FJ", "PH", "FI", "FR", "TF", "GA", "GM", "GH", "GI", "GR", "GD", "GL", "GE", "GU", "GG", "GY", "GF", "GP", "GT", "GN", "GQ", "GW", "HT", "ES", "HN", "HK", "IN", "ID", "IQ", "IR", "IE", "IS", "IL", "JM", "JP", "YE", "JE", "JO", "KY", "KH", "CM", "CA", "QA", "KZ", "KE", "KG", "KI", "CO", "KM", "CG", "CD", "KP", "XK", "CR", "CU", "KW", "LA", "LS", "LB", "LR", "LY", "LI", "LT", "LV", "LU", "MK", "MG", "YT", "MO", "MW", "MV", "MY", "ML", "MT", "MP", "MA", "MQ", "MR", "MU", "MX", "XL", "FM", "UM", "MD", "MC", "MN", "MS", "MZ", "MM", "NA", "NR", "NP", "NL", "DE", "NE", "NG", "NI", "NU", "NF", "NO", "NC", "NZ", "PS", "OM", "PK", "PW", "PA", "PG", "PY", "PE", "PN", "PF", "PL", "GS", "PT", "PR", "CF", "CZ", "KR", "ZA", "RE", "RU", "RO", "RW", "EH", "BL", "KN", "LC", "MF", "VC", "SV", "WS", "AS", "SM", "SN", "RS", "SC", "SL", "SG", "SK", "SI", "SO", "LK", "PM", "US", "SZ", "SD", "SS", "SR", "SJ", "SH", "SY", "CH", "SE", "TJ", "TH", "TW", "TZ", "TG", "TK", "TO", "TT", "TN", "TR", "TM", "TV", "UG", "UA", "UY", "UZ", "VU", "WF", "VA", "HU", "VE", "GB", "VN", "IT", "TL", "CI", "BV", "CX", "IM", "SX", "CK", "VI", "VG", "HM", "CC", "MH", "FO", "SB", "ST", "TC", "ZM", "CV", "ZW", "AE", "XI"]);
1759
1968
  TGLN3 = z3.string().min(1).max(13);
1760
1969
  TAdres3 = z3.object({
@@ -1762,7 +1971,7 @@ var init_rr1_v11e = __esm({
1762
1971
  "AdresL1": TZnakowy5123,
1763
1972
  "AdresL2": TZnakowy5123.optional(),
1764
1973
  "GLN": TGLN3.optional()
1765
- });
1974
+ }).strict();
1766
1975
  TAdresEmail3 = z3.string().min(3).max(255).regex(/^(.)+@(.)+$/);
1767
1976
  TNumerTelefonu3 = z3.string().min(1).max(16);
1768
1977
  TStatusInfoPodatnika3 = z3.enum(["1", "2", "3", "4"]);
@@ -1774,7 +1983,7 @@ var init_rr1_v11e = __esm({
1774
1983
  "IDWew": TNIPIdWew3.optional(),
1775
1984
  "BrakID": TWybor13.optional(),
1776
1985
  "Nazwa": TZnakowy5123
1777
- });
1986
+ }).strict();
1778
1987
  TRolaPodmiotu33 = z3.enum(["1", "2", "3", "5", "6", "7", "8", "9", "10", "11"]);
1779
1988
  TKodWaluty3 = z3.enum(["AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BOV", "BRL", "BSD", "BTN", "BWP", "BYN", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLF", "CLP", "CNY", "COP", "COU", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GGP", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "IMP", "INR", "IQD", "IRR", "ISK", "JEP", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRU", "MUR", "MVR", "MWK", "MXN", "MXV", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLL", "SOS", "SRD", "SSP", "STN", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "USN", "UYI", "UYU", "UYW", "UZS", "VES", "VND", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XCG", "XDR", "XOF", "XPD", "XPF", "XPT", "XSU", "XUA", "XXX", "YER", "ZAR", "ZMW", "ZWL"]);
1780
1989
  TData3 = z3.string();
@@ -1788,7 +1997,7 @@ var init_rr1_v11e = __esm({
1788
1997
  "NrWiersza": TNaturalny3.optional(),
1789
1998
  "Klucz": TZnakowy4,
1790
1999
  "Wartosc": TZnakowy4
1791
- });
2000
+ }).strict();
1792
2001
  TZnakowy503 = z3.string().min(1).max(50);
1793
2002
  TIlosci3 = z3.string().regex(/^-?([1-9]\d{0,15}|0)(\.\d{1,6})?$/);
1794
2003
  TKwotowy23 = z3.string().regex(/^-?([1-9]\d{0,13}|0)(\.\d{1,8})?$/);
@@ -1802,7 +2011,7 @@ var init_rr1_v11e = __esm({
1802
2011
  "SWIFT": SWIFT_Type3.optional(),
1803
2012
  "NazwaBanku": TZnakowy4.optional(),
1804
2013
  "OpisRachunku": TZnakowy4.optional()
1805
- });
2014
+ }).strict();
1806
2015
  TTekstowy3 = z3.string().min(1).max(3500);
1807
2016
  TNrKRS3 = z3.string().regex(/^\d{10}$/);
1808
2017
  TNrREGON3 = z3.union([z3.string().regex(/^\d{9}$/), z3.string().regex(/^\d{14}$/)]);
@@ -1815,9 +2024,9 @@ var init_rr1_v11e = __esm({
1815
2024
  "DaneKontaktowe": z3.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z3.array(z3.object({
1816
2025
  "Email": TAdresEmail3.optional(),
1817
2026
  "Telefon": TNumerTelefonu3.optional()
1818
- })).min(0).max(3)).optional(),
2027
+ }).strict()).min(0).max(3)).optional(),
1819
2028
  "NrKontrahenta": TZnakowy4.optional()
1820
- }),
2029
+ }).strict(),
1821
2030
  "Podmiot2": z3.object({
1822
2031
  "DaneIdentyfikacyjne": TPodmiot13,
1823
2032
  "Adres": TAdres3,
@@ -1825,9 +2034,9 @@ var init_rr1_v11e = __esm({
1825
2034
  "DaneKontaktowe": z3.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z3.array(z3.object({
1826
2035
  "Email": TAdresEmail3.optional(),
1827
2036
  "Telefon": TNumerTelefonu3.optional()
1828
- })).min(0).max(3)).optional(),
2037
+ }).strict()).min(0).max(3)).optional(),
1829
2038
  "StatusInfoPodatnika": TStatusInfoPodatnika3.optional()
1830
- }),
2039
+ }).strict(),
1831
2040
  "Podmiot3": z3.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z3.array(z3.object({
1832
2041
  "DaneIdentyfikacyjne": TPodmiot33,
1833
2042
  "Adres": TAdres3.optional(),
@@ -1835,11 +2044,11 @@ var init_rr1_v11e = __esm({
1835
2044
  "DaneKontaktowe": z3.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z3.array(z3.object({
1836
2045
  "Email": TAdresEmail3.optional(),
1837
2046
  "Telefon": TNumerTelefonu3.optional()
1838
- })).min(0).max(3)).optional(),
2047
+ }).strict()).min(0).max(3)).optional(),
1839
2048
  "Rola": TRolaPodmiotu33.optional(),
1840
2049
  "RolaInna": TWybor13.optional(),
1841
2050
  "OpisRoli": TZnakowy4.optional()
1842
- })).min(0).max(100)).optional(),
2051
+ }).strict()).min(0).max(100)).optional(),
1843
2052
  "FakturaRR": z3.object({
1844
2053
  "KodWaluty": TKodWaluty3,
1845
2054
  "P_1M": TZnakowy4.optional(),
@@ -1862,20 +2071,20 @@ var init_rr1_v11e = __esm({
1862
2071
  "NrKSeF": TWybor13.optional(),
1863
2072
  "NrKSeFFaKorygowanej": TNumerKSeF3.optional(),
1864
2073
  "NrKSeFN": TWybor13.optional()
1865
- })).min(1).max(5e4)).optional(),
2074
+ }).strict()).min(1).max(5e4)).optional(),
1866
2075
  "NrFaKorygowany": TZnakowy4.optional(),
1867
2076
  "Podmiot1K": z3.object({
1868
2077
  "DaneIdentyfikacyjne": TPodmiot13,
1869
2078
  "Adres": TAdres3
1870
- }).optional(),
2079
+ }).strict().optional(),
1871
2080
  "Podmiot2K": z3.object({
1872
2081
  "DaneIdentyfikacyjne": TPodmiot13,
1873
2082
  "Adres": TAdres3
1874
- }).optional(),
2083
+ }).strict().optional(),
1875
2084
  "DokumentZaplaty": z3.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z3.array(z3.object({
1876
2085
  "NrDokumentu": TZnakowy4,
1877
2086
  "DataDokumentu": TData3.optional()
1878
- })).min(0).max(50)).optional(),
2087
+ }).strict()).min(0).max(50)).optional(),
1879
2088
  "DodatkowyOpis": z3.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z3.array(TKluczWartosc3).min(0).max(1e4)).optional(),
1880
2089
  "FakturaRRWiersz": z3.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z3.array(z3.object({
1881
2090
  "NrWierszaFa": TNaturalny3,
@@ -1895,21 +2104,21 @@ var init_rr1_v11e = __esm({
1895
2104
  "P_11": TKwotowy4,
1896
2105
  "StanPrzed": TWybor13.optional(),
1897
2106
  "KursWaluty": TIlosci3.optional()
1898
- })).min(0).max(1e4)).optional(),
2107
+ }).strict()).min(0).max(1e4)).optional(),
1899
2108
  "Rozliczenie": z3.object({
1900
2109
  "Obciazenia": z3.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z3.array(z3.object({
1901
2110
  "Kwota": TKwotowy4,
1902
2111
  "Powod": TZnakowy4
1903
- })).min(0).max(100)).optional(),
2112
+ }).strict()).min(0).max(100)).optional(),
1904
2113
  "SumaObciazen": TKwotowy4.optional(),
1905
2114
  "Odliczenia": z3.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z3.array(z3.object({
1906
2115
  "Kwota": TKwotowy4,
1907
2116
  "Powod": TZnakowy4
1908
- })).min(0).max(100)).optional(),
2117
+ }).strict()).min(0).max(100)).optional(),
1909
2118
  "SumaOdliczen": TKwotowy4.optional(),
1910
2119
  "DoZaplaty": TKwotowy4.optional(),
1911
2120
  "DoRozliczenia": TKwotowy4.optional()
1912
- }).optional(),
2121
+ }).strict().optional(),
1913
2122
  "Platnosc": z3.object({
1914
2123
  "FormaPlatnosci": TFormaPlatnosci3.optional(),
1915
2124
  "PlatnoscInna": TWybor13.optional(),
@@ -1918,20 +2127,20 @@ var init_rr1_v11e = __esm({
1918
2127
  "RachunekBankowy2": z3.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z3.array(TRachunekBankowy3).min(0).max(3)).optional(),
1919
2128
  "IPKSeF": z3.string().min(1).max(13).regex(/^[0-9]{3}[a-zA-Z0-9]{10}$/).optional(),
1920
2129
  "LinkDoPlatnosci": z3.string().min(1).max(512).regex(/^(https?):\/\/([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}(:[0-9]{1,5})?(\/[^\s?#]*)?\?([^#\s]*&)?IPKSeF=[0-9]{3}[a-zA-Z0-9]{10}(&[^#\s]*)?(#.*)?$/).optional()
1921
- }).optional()
1922
- }),
2130
+ }).strict().optional()
2131
+ }).strict(),
1923
2132
  "Stopka": z3.object({
1924
2133
  "Informacje": z3.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z3.array(z3.object({
1925
2134
  "StopkaFaktury": TTekstowy3.optional()
1926
- })).min(0).max(3)).optional(),
2135
+ }).strict()).min(0).max(3)).optional(),
1927
2136
  "Rejestry": z3.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z3.array(z3.object({
1928
2137
  "PelnaNazwa": TZnakowy4.optional(),
1929
2138
  "KRS": TNrKRS3.optional(),
1930
2139
  "REGON": TNrREGON3.optional(),
1931
2140
  "BDO": z3.string().min(1).max(9).optional()
1932
- })).min(0).max(100)).optional()
1933
- }).optional()
1934
- });
2141
+ }).strict()).min(0).max(100)).optional()
2142
+ }).strict().optional()
2143
+ }).strict();
1935
2144
  }
1936
2145
  });
1937
2146
 
@@ -1949,17 +2158,17 @@ var init_rr1_v10e = __esm({
1949
2158
  TDataCzas4 = z4.string();
1950
2159
  TZnakowy5 = z4.string().min(1).max(256);
1951
2160
  TNaglowek4 = z4.object({
1952
- "KodFormularza": z4.object({ "#text": TKodFormularza4, "@kodSystemowy": z4.literal("FA_RR(1)"), "@wersjaSchemy": z4.literal("1-0E") }),
2161
+ "KodFormularza": z4.object({ "#text": TKodFormularza4, "@kodSystemowy": z4.literal("FA_RR(1)"), "@wersjaSchemy": z4.literal("1-0E") }).strict(),
1953
2162
  "WariantFormularza": z4.literal("1"),
1954
2163
  "DataWytworzeniaFa": z4.string(),
1955
2164
  "SystemInfo": TZnakowy5.optional()
1956
- });
2165
+ }).strict();
1957
2166
  TNrNIP4 = z4.string().regex(/^[1-9]((\d[1-9])|([1-9]\d))\d{7}$/);
1958
2167
  TZnakowy5124 = z4.string().min(1).max(512);
1959
2168
  TPodmiot14 = z4.object({
1960
2169
  "NIP": TNrNIP4,
1961
2170
  "Nazwa": TZnakowy5124
1962
- });
2171
+ }).strict();
1963
2172
  TKodKraju4 = z4.enum(["AF", "AX", "AL", "DZ", "AD", "AO", "AI", "AQ", "AG", "AN", "SA", "AR", "AM", "AW", "AU", "AT", "AZ", "BS", "BH", "BD", "BB", "BE", "BZ", "BJ", "BM", "BT", "BY", "BO", "BQ", "BA", "BW", "BR", "BN", "IO", "BG", "BF", "BI", "XC", "CL", "CN", "HR", "CW", "CY", "TD", "ME", "DK", "DM", "DO", "DJ", "EG", "EC", "ER", "EE", "ET", "FK", "FJ", "PH", "FI", "FR", "TF", "GA", "GM", "GH", "GI", "GR", "GD", "GL", "GE", "GU", "GG", "GY", "GF", "GP", "GT", "GN", "GQ", "GW", "HT", "ES", "HN", "HK", "IN", "ID", "IQ", "IR", "IE", "IS", "IL", "JM", "JP", "YE", "JE", "JO", "KY", "KH", "CM", "CA", "QA", "KZ", "KE", "KG", "KI", "CO", "KM", "CG", "CD", "KP", "XK", "CR", "CU", "KW", "LA", "LS", "LB", "LR", "LY", "LI", "LT", "LV", "LU", "MK", "MG", "YT", "MO", "MW", "MV", "MY", "ML", "MT", "MP", "MA", "MQ", "MR", "MU", "MX", "XL", "FM", "UM", "MD", "MC", "MN", "MS", "MZ", "MM", "NA", "NR", "NP", "NL", "DE", "NE", "NG", "NI", "NU", "NF", "NO", "NC", "NZ", "PS", "OM", "PK", "PW", "PA", "PG", "PY", "PE", "PN", "PF", "PL", "GS", "PT", "PR", "CF", "CZ", "KR", "ZA", "RE", "RU", "RO", "RW", "EH", "BL", "KN", "LC", "MF", "VC", "SV", "WS", "AS", "SM", "SN", "RS", "SC", "SL", "SG", "SK", "SI", "SO", "LK", "PM", "US", "SZ", "SD", "SS", "SR", "SJ", "SH", "SY", "CH", "SE", "TJ", "TH", "TW", "TZ", "TG", "TK", "TO", "TT", "TN", "TR", "TM", "TV", "UG", "UA", "UY", "UZ", "VU", "WF", "VA", "HU", "VE", "GB", "VN", "IT", "TL", "CI", "BV", "CX", "IM", "SX", "CK", "VI", "VG", "HM", "CC", "MH", "FO", "SB", "ST", "TC", "ZM", "CV", "ZW", "AE", "XI"]);
1964
2173
  TGLN4 = z4.string().min(1).max(13);
1965
2174
  TAdres4 = z4.object({
@@ -1967,7 +2176,7 @@ var init_rr1_v10e = __esm({
1967
2176
  "AdresL1": TZnakowy5124,
1968
2177
  "AdresL2": TZnakowy5124.optional(),
1969
2178
  "GLN": TGLN4.optional()
1970
- });
2179
+ }).strict();
1971
2180
  TAdresEmail4 = z4.string().min(3).max(255).regex(/^(.)+@(.)+$/);
1972
2181
  TNumerTelefonu4 = z4.string().min(1).max(16);
1973
2182
  TStatusInfoPodatnika4 = z4.enum(["1", "2", "3", "4"]);
@@ -1979,7 +2188,7 @@ var init_rr1_v10e = __esm({
1979
2188
  "IDWew": TNIPIdWew4.optional(),
1980
2189
  "BrakID": TWybor14.optional(),
1981
2190
  "Nazwa": TZnakowy5124
1982
- });
2191
+ }).strict();
1983
2192
  TRolaPodmiotu34 = z4.enum(["1", "2", "3", "5", "6", "7", "8", "9", "10", "11"]);
1984
2193
  TKodWaluty4 = z4.enum(["AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BOV", "BRL", "BSD", "BTN", "BWP", "BYN", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLF", "CLP", "CNY", "COP", "COU", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GGP", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "IMP", "INR", "IQD", "IRR", "ISK", "JEP", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRU", "MUR", "MVR", "MWK", "MXN", "MXV", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLL", "SOS", "SRD", "SSP", "STN", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "USN", "UYI", "UYU", "UYW", "UZS", "VES", "VND", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XCG", "XDR", "XOF", "XPD", "XPF", "XPT", "XSU", "XUA", "XXX", "YER", "ZAR", "ZMW", "ZWL"]);
1985
2194
  TData4 = z4.string();
@@ -1993,7 +2202,7 @@ var init_rr1_v10e = __esm({
1993
2202
  "NrWiersza": TNaturalny4.optional(),
1994
2203
  "Klucz": TZnakowy5,
1995
2204
  "Wartosc": TZnakowy5
1996
- });
2205
+ }).strict();
1997
2206
  TZnakowy504 = z4.string().min(1).max(50);
1998
2207
  TIlosci4 = z4.string().regex(/^-?([1-9]\d{0,15}|0)(\.\d{1,6})?$/);
1999
2208
  TKwotowy24 = z4.string().regex(/^-?([1-9]\d{0,13}|0)(\.\d{1,8})?$/);
@@ -2007,7 +2216,7 @@ var init_rr1_v10e = __esm({
2007
2216
  "SWIFT": SWIFT_Type4.optional(),
2008
2217
  "NazwaBanku": TZnakowy5.optional(),
2009
2218
  "OpisRachunku": TZnakowy5.optional()
2010
- });
2219
+ }).strict();
2011
2220
  TTekstowy4 = z4.string().min(1).max(3500);
2012
2221
  TNrKRS4 = z4.string().regex(/^\d{10}$/);
2013
2222
  TNrREGON4 = z4.union([z4.string().regex(/^\d{9}$/), z4.string().regex(/^\d{14}$/)]);
@@ -2020,9 +2229,9 @@ var init_rr1_v10e = __esm({
2020
2229
  "DaneKontaktowe": z4.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z4.array(z4.object({
2021
2230
  "Email": TAdresEmail4.optional(),
2022
2231
  "Telefon": TNumerTelefonu4.optional()
2023
- })).min(0).max(3)).optional(),
2232
+ }).strict()).min(0).max(3)).optional(),
2024
2233
  "NrKontrahenta": TZnakowy5.optional()
2025
- }),
2234
+ }).strict(),
2026
2235
  "Podmiot2": z4.object({
2027
2236
  "DaneIdentyfikacyjne": TPodmiot14,
2028
2237
  "Adres": TAdres4,
@@ -2030,9 +2239,9 @@ var init_rr1_v10e = __esm({
2030
2239
  "DaneKontaktowe": z4.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z4.array(z4.object({
2031
2240
  "Email": TAdresEmail4.optional(),
2032
2241
  "Telefon": TNumerTelefonu4.optional()
2033
- })).min(0).max(3)).optional(),
2242
+ }).strict()).min(0).max(3)).optional(),
2034
2243
  "StatusInfoPodatnika": TStatusInfoPodatnika4.optional()
2035
- }),
2244
+ }).strict(),
2036
2245
  "Podmiot3": z4.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z4.array(z4.object({
2037
2246
  "DaneIdentyfikacyjne": TPodmiot34,
2038
2247
  "Adres": TAdres4.optional(),
@@ -2040,11 +2249,11 @@ var init_rr1_v10e = __esm({
2040
2249
  "DaneKontaktowe": z4.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z4.array(z4.object({
2041
2250
  "Email": TAdresEmail4.optional(),
2042
2251
  "Telefon": TNumerTelefonu4.optional()
2043
- })).min(0).max(3)).optional(),
2252
+ }).strict()).min(0).max(3)).optional(),
2044
2253
  "Rola": TRolaPodmiotu34.optional(),
2045
2254
  "RolaInna": TWybor14.optional(),
2046
2255
  "OpisRoli": TZnakowy5.optional()
2047
- })).min(0).max(100)).optional(),
2256
+ }).strict()).min(0).max(100)).optional(),
2048
2257
  "FakturaRR": z4.object({
2049
2258
  "KodWaluty": TKodWaluty4,
2050
2259
  "P_1M": TZnakowy5.optional(),
@@ -2067,20 +2276,20 @@ var init_rr1_v10e = __esm({
2067
2276
  "NrKSeF": TWybor14.optional(),
2068
2277
  "NrKSeFFaKorygowanej": TNumerKSeF4.optional(),
2069
2278
  "NrKSeFN": TWybor14.optional()
2070
- })).min(1).max(5e4)).optional(),
2279
+ }).strict()).min(1).max(5e4)).optional(),
2071
2280
  "NrFaKorygowany": TZnakowy5.optional(),
2072
2281
  "Podmiot1K": z4.object({
2073
2282
  "DaneIdentyfikacyjne": TPodmiot14,
2074
2283
  "Adres": TAdres4
2075
- }).optional(),
2284
+ }).strict().optional(),
2076
2285
  "Podmiot2K": z4.object({
2077
2286
  "DaneIdentyfikacyjne": TPodmiot14,
2078
2287
  "Adres": TAdres4
2079
- }).optional(),
2288
+ }).strict().optional(),
2080
2289
  "DokumentZaplaty": z4.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z4.array(z4.object({
2081
2290
  "NrDokumentu": TZnakowy5,
2082
2291
  "DataDokumentu": TData4.optional()
2083
- })).min(0).max(50)).optional(),
2292
+ }).strict()).min(0).max(50)).optional(),
2084
2293
  "DodatkowyOpis": z4.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z4.array(TKluczWartosc4).min(0).max(1e4)).optional(),
2085
2294
  "FakturaRRWiersz": z4.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z4.array(z4.object({
2086
2295
  "NrWierszaFa": TNaturalny4,
@@ -2100,21 +2309,21 @@ var init_rr1_v10e = __esm({
2100
2309
  "P_11": TKwotowy5,
2101
2310
  "StanPrzed": TWybor14.optional(),
2102
2311
  "KursWaluty": TIlosci4.optional()
2103
- })).min(0).max(1e4)).optional(),
2312
+ }).strict()).min(0).max(1e4)).optional(),
2104
2313
  "Rozliczenie": z4.object({
2105
2314
  "Obciazenia": z4.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z4.array(z4.object({
2106
2315
  "Kwota": TKwotowy5,
2107
2316
  "Powod": TZnakowy5
2108
- })).min(0).max(100)).optional(),
2317
+ }).strict()).min(0).max(100)).optional(),
2109
2318
  "SumaObciazen": TKwotowy5.optional(),
2110
2319
  "Odliczenia": z4.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z4.array(z4.object({
2111
2320
  "Kwota": TKwotowy5,
2112
2321
  "Powod": TZnakowy5
2113
- })).min(0).max(100)).optional(),
2322
+ }).strict()).min(0).max(100)).optional(),
2114
2323
  "SumaOdliczen": TKwotowy5.optional(),
2115
2324
  "DoZaplaty": TKwotowy5.optional(),
2116
2325
  "DoRozliczenia": TKwotowy5.optional()
2117
- }).optional(),
2326
+ }).strict().optional(),
2118
2327
  "Platnosc": z4.object({
2119
2328
  "FormaPlatnosci": TFormaPlatnosci4.optional(),
2120
2329
  "PlatnoscInna": TWybor14.optional(),
@@ -2123,20 +2332,20 @@ var init_rr1_v10e = __esm({
2123
2332
  "RachunekBankowy2": z4.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z4.array(TRachunekBankowy4).min(0).max(3)).optional(),
2124
2333
  "IPKSeF": z4.string().min(1).max(13).regex(/^[0-9]{3}[a-zA-Z0-9]{10}$/).optional(),
2125
2334
  "LinkDoPlatnosci": z4.string().min(1).max(512).regex(/^(https?):\/\/([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}(:[0-9]{1,5})?(\/[^\s?#]*)?\?([^#\s]*&)?IPKSeF=[0-9]{3}[a-zA-Z0-9]{10}(&[^#\s]*)?(#.*)?$/).optional()
2126
- }).optional()
2127
- }),
2335
+ }).strict().optional()
2336
+ }).strict(),
2128
2337
  "Stopka": z4.object({
2129
2338
  "Informacje": z4.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z4.array(z4.object({
2130
2339
  "StopkaFaktury": TTekstowy4.optional()
2131
- })).min(0).max(3)).optional(),
2340
+ }).strict()).min(0).max(3)).optional(),
2132
2341
  "Rejestry": z4.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z4.array(z4.object({
2133
2342
  "PelnaNazwa": TZnakowy5.optional(),
2134
2343
  "KRS": TNrKRS4.optional(),
2135
2344
  "REGON": TNrREGON4.optional(),
2136
2345
  "BDO": z4.string().min(1).max(9).optional()
2137
- })).min(0).max(100)).optional()
2138
- }).optional()
2139
- });
2346
+ }).strict()).min(0).max(100)).optional()
2347
+ }).strict().optional()
2348
+ }).strict();
2140
2349
  }
2141
2350
  });
2142
2351
 
@@ -2205,7 +2414,7 @@ var init_pef3 = __esm({
2205
2414
  "WithholdingTaxTotal": z5.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z5.array(z5.any()).min(0)).optional(),
2206
2415
  "LegalMonetaryTotal": z5.any(),
2207
2416
  "InvoiceLine": z5.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z5.array(z5.any()).min(1))
2208
- });
2417
+ }).strict();
2209
2418
  PEF3Schema = InvoiceType;
2210
2419
  }
2211
2420
  });
@@ -2272,120 +2481,404 @@ var init_pef_kor3 = __esm({
2272
2481
  "TaxTotal": z6.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z6.array(z6.any()).min(0)).optional(),
2273
2482
  "LegalMonetaryTotal": z6.any(),
2274
2483
  "CreditNoteLine": z6.preprocess((v) => Array.isArray(v) ? v : v == null ? [] : [v], z6.array(z6.any()).min(1))
2275
- });
2484
+ }).strict();
2276
2485
  PEF_KOR3Schema = CreditNoteType;
2277
2486
  }
2278
2487
  });
2279
2488
 
2280
- // src/services/auth.ts
2281
- var AuthService;
2282
- var init_auth = __esm({
2283
- "src/services/auth.ts"() {
2489
+ // src/validation/schemas/index.ts
2490
+ var NAMESPACE_MAP;
2491
+ var init_schemas = __esm({
2492
+ "src/validation/schemas/index.ts"() {
2284
2493
  "use strict";
2285
- init_ksef_feature();
2286
- init_rest_request();
2287
- init_routes();
2288
- AuthService = class {
2289
- restClient;
2290
- constructor(restClient) {
2291
- this.restClient = restClient;
2292
- }
2293
- async getChallenge() {
2294
- const request = RestRequest.post(Routes.Authorization.challenge);
2295
- const response = await this.restClient.execute(request);
2296
- return response.body;
2297
- }
2298
- async submitXadesAuthRequest(signedXml, verifyCertificateChain = false, enforceXadesCompliance = false) {
2299
- const request = RestRequest.post(Routes.Authorization.xadesSignature).body(signedXml).header("Content-Type", "application/xml").query("verifyCertificateChain", String(verifyCertificateChain));
2300
- if (enforceXadesCompliance) {
2301
- request.header(KSEF_FEATURE_HEADER, ENFORCE_XADES_COMPLIANCE);
2302
- }
2303
- const response = await this.restClient.execute(request);
2304
- return response.body;
2305
- }
2306
- async submitKsefTokenAuthRequest(payload) {
2307
- const request = RestRequest.post(Routes.Authorization.ksefToken).body(payload);
2308
- const response = await this.restClient.execute(request);
2309
- return response.body;
2310
- }
2311
- async getAuthStatus(referenceNumber, authToken) {
2312
- const request = RestRequest.get(Routes.Authorization.status(referenceNumber)).accessToken(authToken);
2313
- const response = await this.restClient.execute(request);
2314
- return response.body;
2315
- }
2316
- async getAccessToken(authToken) {
2317
- const request = RestRequest.post(Routes.Authorization.Token.redeem).accessToken(authToken);
2318
- const response = await this.restClient.execute(request);
2319
- return response.body;
2320
- }
2321
- async refreshAccessToken(refreshToken) {
2322
- const request = RestRequest.post(Routes.Authorization.Token.refresh).accessToken(refreshToken).skipAuthRetry();
2323
- const response = await this.restClient.execute(request);
2324
- return response.body;
2325
- }
2494
+ init_fa3();
2495
+ init_fa2();
2496
+ init_rr1_v11e();
2497
+ init_rr1_v10e();
2498
+ init_pef3();
2499
+ init_pef_kor3();
2500
+ NAMESPACE_MAP = {
2501
+ "http://crd.gov.pl/wzor/2025/06/25/13775/": "FA3",
2502
+ "http://crd.gov.pl/wzor/2023/06/29/12648/": "FA2",
2503
+ "http://crd.gov.pl/wzor/2026/03/06/14189/": "RR1_V11E",
2504
+ "http://crd.gov.pl/wzor/2026/02/17/14164/": "RR1_V10E",
2505
+ "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2": "PEF3",
2506
+ "urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2": "PEF_KOR3"
2326
2507
  };
2327
2508
  }
2328
2509
  });
2329
2510
 
2330
- // src/services/active-sessions.ts
2331
- var ActiveSessionsService;
2332
- var init_active_sessions = __esm({
2333
- "src/services/active-sessions.ts"() {
2511
+ // src/validation/schema-registry.ts
2512
+ async function loadSchema(type) {
2513
+ const cached = schemaCache.get(type);
2514
+ if (cached) return cached;
2515
+ let mod;
2516
+ switch (type) {
2517
+ case "FA3":
2518
+ mod = await Promise.resolve().then(() => (init_fa3(), fa3_exports));
2519
+ break;
2520
+ case "FA2":
2521
+ mod = await Promise.resolve().then(() => (init_fa2(), fa2_exports));
2522
+ break;
2523
+ case "RR1_V11E":
2524
+ mod = await Promise.resolve().then(() => (init_rr1_v11e(), rr1_v11e_exports));
2525
+ break;
2526
+ case "RR1_V10E":
2527
+ mod = await Promise.resolve().then(() => (init_rr1_v10e(), rr1_v10e_exports));
2528
+ break;
2529
+ case "PEF3":
2530
+ mod = await Promise.resolve().then(() => (init_pef3(), pef3_exports));
2531
+ break;
2532
+ case "PEF_KOR3":
2533
+ mod = await Promise.resolve().then(() => (init_pef_kor3(), pef_kor3_exports));
2534
+ break;
2535
+ default:
2536
+ throw new Error(`Unknown schema type: ${type}`);
2537
+ }
2538
+ const exportName = `${type}Schema`;
2539
+ const schema = mod[exportName];
2540
+ if (!schema) {
2541
+ throw new Error(`Schema export "${exportName}" not found in module for type "${type}"`);
2542
+ }
2543
+ schemaCache.set(type, schema);
2544
+ return schema;
2545
+ }
2546
+ var ROOT_ELEMENT_MAP, schemaCache, SchemaRegistry;
2547
+ var init_schema_registry = __esm({
2548
+ "src/validation/schema-registry.ts"() {
2334
2549
  "use strict";
2335
- init_rest_request();
2336
- init_routes();
2337
- ActiveSessionsService = class {
2338
- restClient;
2339
- constructor(restClient) {
2340
- this.restClient = restClient;
2550
+ init_schemas();
2551
+ ROOT_ELEMENT_MAP = {
2552
+ Invoice: "PEF3",
2553
+ CreditNote: "PEF_KOR3"
2554
+ };
2555
+ schemaCache = /* @__PURE__ */ new Map();
2556
+ SchemaRegistry = {
2557
+ /**
2558
+ * Get a Zod schema by type. Lazy-loads the module on first access.
2559
+ */
2560
+ async get(type) {
2561
+ return loadSchema(type);
2562
+ },
2563
+ /**
2564
+ * List all available schema types.
2565
+ */
2566
+ availableSchemas() {
2567
+ return ["FA3", "FA2", "RR1_V11E", "RR1_V10E", "PEF3", "PEF_KOR3"];
2568
+ },
2569
+ /**
2570
+ * Detect schema type from XML namespace URI and/or root element name.
2571
+ *
2572
+ * Detection priority:
2573
+ * 1. Namespace URI match (unique per FA/RR schemas)
2574
+ * 2. Root element name match (for PEF/PEF_KOR which use UBL namespaces)
2575
+ */
2576
+ detect(namespace, rootElement) {
2577
+ if (namespace) {
2578
+ const byNs = NAMESPACE_MAP[namespace];
2579
+ if (byNs) return byNs;
2580
+ }
2581
+ if (rootElement) {
2582
+ const byRoot = ROOT_ELEMENT_MAP[rootElement];
2583
+ if (byRoot) return byRoot;
2584
+ }
2585
+ return null;
2341
2586
  }
2342
- async getActiveSessions(pageSize, continuationToken) {
2343
- const request = RestRequest.get(Routes.ActiveSessions.session);
2344
- if (pageSize !== void 0) request.query("pageSize", String(pageSize));
2345
- if (continuationToken !== void 0) request.header("x-continuation-token", continuationToken);
2346
- const response = await this.restClient.execute(request);
2347
- return response.body;
2587
+ };
2588
+ }
2589
+ });
2590
+
2591
+ // src/validation/invoice-validator.ts
2592
+ var invoice_validator_exports = {};
2593
+ __export(invoice_validator_exports, {
2594
+ batchValidationDetails: () => batchValidationDetails,
2595
+ validate: () => validate,
2596
+ validateBatch: () => validateBatch,
2597
+ validateBusinessRules: () => validateBusinessRules,
2598
+ validateSchema: () => validateSchema,
2599
+ validateWellFormedness: () => validateWellFormedness
2600
+ });
2601
+ function validateWellFormedness(xml, _parsed) {
2602
+ if (!xml || !xml.trim()) {
2603
+ return {
2604
+ valid: false,
2605
+ schemaType: null,
2606
+ errors: [{ code: "MALFORMED_XML", message: "Empty XML input" }]
2607
+ };
2608
+ }
2609
+ const { object, rootElement, namespace, errors } = _parsed ?? xmlToObject(xml);
2610
+ if (errors.length > 0 || !object) {
2611
+ return {
2612
+ valid: false,
2613
+ schemaType: null,
2614
+ errors: errors.map((msg) => ({ code: "MALFORMED_XML", message: msg }))
2615
+ };
2616
+ }
2617
+ const schemaType = SchemaRegistry.detect(namespace, rootElement);
2618
+ return { valid: true, schemaType, errors: [] };
2619
+ }
2620
+ async function validateSchema(xml, options, _parsed) {
2621
+ const { object, rootElement, namespace, errors: parseErrors } = _parsed ?? xmlToObject(xml);
2622
+ if (parseErrors.length > 0 || !object) {
2623
+ return {
2624
+ valid: false,
2625
+ schemaType: null,
2626
+ errors: parseErrors.map((msg) => ({ code: "MALFORMED_XML", message: msg }))
2627
+ };
2628
+ }
2629
+ const schemaType = options?.schema ?? SchemaRegistry.detect(namespace, rootElement);
2630
+ if (!schemaType) {
2631
+ return {
2632
+ valid: false,
2633
+ schemaType: null,
2634
+ errors: [{
2635
+ code: "UNKNOWN_SCHEMA",
2636
+ message: `Cannot detect schema type from namespace "${namespace}" and root element "${rootElement}"`
2637
+ }]
2638
+ };
2639
+ }
2640
+ const schema = await SchemaRegistry.get(schemaType);
2641
+ const result = schema.safeParse(object);
2642
+ if (result.success) {
2643
+ return { valid: true, schemaType, errors: [] };
2644
+ }
2645
+ const prefix = rootElement ? `/${rootElement}/` : "/";
2646
+ const validationErrors = result.error.issues.map((issue) => {
2647
+ const zodPath = issue.path.join("/");
2648
+ const path = zodPath ? `${prefix}${zodPath}` : rootElement ? `/${rootElement}` : void 0;
2649
+ return {
2650
+ code: mapZodErrorCode(issue),
2651
+ message: issue.message,
2652
+ path
2653
+ };
2654
+ });
2655
+ return { valid: false, schemaType, errors: validationErrors };
2656
+ }
2657
+ function mapZodErrorCode(issue) {
2658
+ switch (issue.code) {
2659
+ case "invalid_type":
2660
+ return issue.input === void 0 ? "MISSING_REQUIRED_ELEMENT" : "INVALID_VALUE";
2661
+ case "invalid_enum_value":
2662
+ // Zod v3
2663
+ case "invalid_value":
2664
+ return "INVALID_ENUM_VALUE";
2665
+ case "invalid_string":
2666
+ // Zod v3
2667
+ case "invalid_format":
2668
+ return "PATTERN_MISMATCH";
2669
+ case "too_big":
2670
+ return "MAX_OCCURS_EXCEEDED";
2671
+ case "unrecognized_keys":
2672
+ return "UNRECOGNIZED_KEY";
2673
+ default:
2674
+ return "SCHEMA_VALIDATION_ERROR";
2675
+ }
2676
+ }
2677
+ function validateBusinessRules(xml, _parsed) {
2678
+ const { object, rootElement, namespace, errors: parseErrors } = _parsed ?? xmlToObject(xml);
2679
+ if (parseErrors.length > 0 || !object) {
2680
+ return {
2681
+ valid: false,
2682
+ schemaType: null,
2683
+ errors: parseErrors.map((msg) => ({ code: "MALFORMED_XML", message: msg }))
2684
+ };
2685
+ }
2686
+ const schemaType = SchemaRegistry.detect(namespace, rootElement);
2687
+ const errors = [];
2688
+ collectNipPeselErrors(object, rootElement ? `/${rootElement}` : "", errors);
2689
+ collectDateErrors(object, rootElement, errors);
2690
+ return { valid: errors.length === 0, schemaType, errors };
2691
+ }
2692
+ function collectNipPeselErrors(obj, path, errors) {
2693
+ for (const [key, value] of Object.entries(obj)) {
2694
+ const currentPath = path ? `${path}/${key}` : key;
2695
+ if (key === "NIP" && typeof value === "string") {
2696
+ if (!isValidNip(value)) {
2697
+ errors.push({
2698
+ code: "INVALID_NIP_CHECKSUM",
2699
+ message: `Invalid NIP checksum: ${value}`,
2700
+ path: currentPath
2701
+ });
2348
2702
  }
2349
- async revokeCurrentSession() {
2350
- const request = RestRequest.delete(Routes.ActiveSessions.currentSession);
2351
- await this.restClient.executeVoid(request);
2703
+ } else if (key === "PESEL" && typeof value === "string") {
2704
+ if (!isValidPesel(value)) {
2705
+ errors.push({
2706
+ code: "INVALID_PESEL_CHECKSUM",
2707
+ message: `Invalid PESEL checksum: ${value}`,
2708
+ path: currentPath
2709
+ });
2352
2710
  }
2353
- async revokeSession(sessionRef) {
2354
- const request = RestRequest.delete(Routes.ActiveSessions.delete(sessionRef));
2355
- await this.restClient.executeVoid(request);
2711
+ } else if (typeof value === "object" && value !== null) {
2712
+ if (Array.isArray(value)) {
2713
+ for (let i = 0; i < value.length; i++) {
2714
+ if (typeof value[i] === "object" && value[i] !== null) {
2715
+ collectNipPeselErrors(value[i], `${currentPath}/${i}`, errors);
2716
+ }
2717
+ }
2718
+ } else {
2719
+ collectNipPeselErrors(value, currentPath, errors);
2356
2720
  }
2357
- };
2721
+ }
2722
+ }
2723
+ }
2724
+ function getPolandLocalDate() {
2725
+ return new Intl.DateTimeFormat("sv-SE", { timeZone: "Europe/Warsaw" }).format(Date.now());
2726
+ }
2727
+ function collectDateErrors(obj, rootElement, errors) {
2728
+ const fa = obj["Fa"];
2729
+ if (!fa || typeof fa !== "object") return;
2730
+ const p1 = fa["P_1"];
2731
+ if (typeof p1 !== "string") return;
2732
+ const today = getPolandLocalDate();
2733
+ if (p1 > today) {
2734
+ const prefix = rootElement ? `/${rootElement}` : "";
2735
+ errors.push({
2736
+ code: "FUTURE_INVOICE_DATE",
2737
+ message: `Invoice date P_1 (${p1}) is in the future \u2014 KSeF rejects invoices with P_1 > today (${today})`,
2738
+ path: `${prefix}/Fa/P_1`
2739
+ });
2740
+ }
2741
+ }
2742
+ async function validate(xml, options) {
2743
+ const parsed = xml && xml.trim() ? xmlToObject(xml) : void 0;
2744
+ const l1 = validateWellFormedness(xml, parsed);
2745
+ if (!l1.valid) return l1;
2746
+ const l2 = await validateSchema(xml, options, parsed);
2747
+ if (!l2.valid) return l2;
2748
+ const l3 = validateBusinessRules(xml, parsed);
2749
+ return { ...l3, schemaType: l2.schemaType };
2750
+ }
2751
+ async function validateBatch(invoices, options) {
2752
+ const results = [];
2753
+ for (const { fileName, xml } of invoices) {
2754
+ results.push({ fileName, result: await validate(xml, options) });
2755
+ }
2756
+ return { valid: results.every((r) => r.result.valid), results };
2757
+ }
2758
+ function batchValidationDetails(batch) {
2759
+ return batch.results.filter((r) => !r.result.valid).flatMap((r) => r.result.errors.map((e) => ({
2760
+ field: e.path ? `${r.fileName}:${e.path}` : r.fileName,
2761
+ message: e.message
2762
+ })));
2763
+ }
2764
+ var init_invoice_validator = __esm({
2765
+ "src/validation/invoice-validator.ts"() {
2766
+ "use strict";
2767
+ init_xml_to_object();
2768
+ init_schema_registry();
2769
+ init_patterns();
2358
2770
  }
2359
2771
  });
2360
2772
 
2361
- // src/services/online-session.ts
2362
- var OnlineSessionService;
2363
- var init_online_session = __esm({
2364
- "src/services/online-session.ts"() {
2773
+ // src/services/auth.ts
2774
+ var AuthService;
2775
+ var init_auth = __esm({
2776
+ "src/services/auth.ts"() {
2365
2777
  "use strict";
2366
2778
  init_ksef_feature();
2367
2779
  init_rest_request();
2368
2780
  init_routes();
2369
- OnlineSessionService = class {
2781
+ AuthService = class {
2370
2782
  restClient;
2371
2783
  constructor(restClient) {
2372
2784
  this.restClient = restClient;
2373
2785
  }
2374
- async openSession(request, upoVersion) {
2375
- const req = RestRequest.post(Routes.Sessions.Online.open).body(request);
2376
- if (upoVersion) {
2377
- req.header(KSEF_FEATURE_HEADER, upoVersion);
2378
- }
2379
- const response = await this.restClient.execute(req);
2786
+ async getChallenge() {
2787
+ const request = RestRequest.post(Routes.Authorization.challenge);
2788
+ const response = await this.restClient.execute(request);
2380
2789
  return response.body;
2381
2790
  }
2382
- async sendInvoice(sessionRef, request) {
2383
- const req = RestRequest.post(Routes.Sessions.Online.invoices(sessionRef)).body(request);
2384
- const response = await this.restClient.execute(req);
2791
+ async submitXadesAuthRequest(signedXml, verifyCertificateChain = false, enforceXadesCompliance = false) {
2792
+ const request = RestRequest.post(Routes.Authorization.xadesSignature).body(signedXml).header("Content-Type", "application/xml").query("verifyCertificateChain", String(verifyCertificateChain));
2793
+ if (enforceXadesCompliance) {
2794
+ request.header(KSEF_FEATURE_HEADER, ENFORCE_XADES_COMPLIANCE);
2795
+ }
2796
+ const response = await this.restClient.execute(request);
2385
2797
  return response.body;
2386
2798
  }
2387
- async closeSession(sessionRef) {
2388
- const req = RestRequest.post(Routes.Sessions.Online.close(sessionRef));
2799
+ async submitKsefTokenAuthRequest(payload) {
2800
+ const request = RestRequest.post(Routes.Authorization.ksefToken).body(payload);
2801
+ const response = await this.restClient.execute(request);
2802
+ return response.body;
2803
+ }
2804
+ async getAuthStatus(referenceNumber, authToken) {
2805
+ const request = RestRequest.get(Routes.Authorization.status(referenceNumber)).accessToken(authToken);
2806
+ const response = await this.restClient.execute(request);
2807
+ return response.body;
2808
+ }
2809
+ async getAccessToken(authToken) {
2810
+ const request = RestRequest.post(Routes.Authorization.Token.redeem).accessToken(authToken);
2811
+ const response = await this.restClient.execute(request);
2812
+ return response.body;
2813
+ }
2814
+ async refreshAccessToken(refreshToken) {
2815
+ const request = RestRequest.post(Routes.Authorization.Token.refresh).accessToken(refreshToken).skipAuthRetry();
2816
+ const response = await this.restClient.execute(request);
2817
+ return response.body;
2818
+ }
2819
+ };
2820
+ }
2821
+ });
2822
+
2823
+ // src/services/active-sessions.ts
2824
+ var ActiveSessionsService;
2825
+ var init_active_sessions = __esm({
2826
+ "src/services/active-sessions.ts"() {
2827
+ "use strict";
2828
+ init_rest_request();
2829
+ init_routes();
2830
+ ActiveSessionsService = class {
2831
+ restClient;
2832
+ constructor(restClient) {
2833
+ this.restClient = restClient;
2834
+ }
2835
+ async getActiveSessions(pageSize, continuationToken) {
2836
+ const request = RestRequest.get(Routes.ActiveSessions.session);
2837
+ if (pageSize !== void 0) request.query("pageSize", String(pageSize));
2838
+ if (continuationToken !== void 0) request.header("x-continuation-token", continuationToken);
2839
+ const response = await this.restClient.execute(request);
2840
+ return response.body;
2841
+ }
2842
+ async revokeCurrentSession() {
2843
+ const request = RestRequest.delete(Routes.ActiveSessions.currentSession);
2844
+ await this.restClient.executeVoid(request);
2845
+ }
2846
+ async revokeSession(sessionRef) {
2847
+ const request = RestRequest.delete(Routes.ActiveSessions.delete(sessionRef));
2848
+ await this.restClient.executeVoid(request);
2849
+ }
2850
+ };
2851
+ }
2852
+ });
2853
+
2854
+ // src/services/online-session.ts
2855
+ var OnlineSessionService;
2856
+ var init_online_session = __esm({
2857
+ "src/services/online-session.ts"() {
2858
+ "use strict";
2859
+ init_ksef_feature();
2860
+ init_rest_request();
2861
+ init_routes();
2862
+ OnlineSessionService = class {
2863
+ restClient;
2864
+ constructor(restClient) {
2865
+ this.restClient = restClient;
2866
+ }
2867
+ async openSession(request, upoVersion) {
2868
+ const req = RestRequest.post(Routes.Sessions.Online.open).body(request);
2869
+ if (upoVersion) {
2870
+ req.header(KSEF_FEATURE_HEADER, upoVersion);
2871
+ }
2872
+ const response = await this.restClient.execute(req);
2873
+ return response.body;
2874
+ }
2875
+ async sendInvoice(sessionRef, request) {
2876
+ const req = RestRequest.post(Routes.Sessions.Online.invoices(sessionRef)).body(request);
2877
+ const response = await this.restClient.execute(req);
2878
+ return response.body;
2879
+ }
2880
+ async closeSession(sessionRef) {
2881
+ const req = RestRequest.post(Routes.Sessions.Online.close(sessionRef));
2389
2882
  await this.restClient.executeVoid(req);
2390
2883
  }
2391
2884
  };
@@ -3736,6 +4229,105 @@ var init_verification_link_service = __esm({
3736
4229
  }
3737
4230
  });
3738
4231
 
4232
+ // src/utils/zip.ts
4233
+ var zip_exports = {};
4234
+ __export(zip_exports, {
4235
+ createZip: () => createZip,
4236
+ unzip: () => unzip
4237
+ });
4238
+ import { ZipFile } from "yazl";
4239
+ import { fromBuffer } from "yauzl";
4240
+ async function createZip(entries) {
4241
+ return new Promise((resolve, reject) => {
4242
+ const zipfile = new ZipFile();
4243
+ for (const entry of entries) {
4244
+ zipfile.addBuffer(Buffer.from(entry.content), entry.fileName);
4245
+ }
4246
+ const chunks = [];
4247
+ zipfile.outputStream.on("data", (chunk) => chunks.push(chunk));
4248
+ zipfile.outputStream.on("error", (err) => reject(err));
4249
+ zipfile.outputStream.on("end", () => resolve(Buffer.concat(chunks)));
4250
+ zipfile.end();
4251
+ });
4252
+ }
4253
+ async function unzip(buffer, options = {}) {
4254
+ const limits = { ...DEFAULT_UNZIP_OPTIONS, ...options };
4255
+ return new Promise((resolve, reject) => {
4256
+ fromBuffer(buffer, { lazyEntries: true }, (err, zipfile) => {
4257
+ if (err || !zipfile) {
4258
+ reject(err ?? new Error("Failed to open zip buffer"));
4259
+ return;
4260
+ }
4261
+ const files = /* @__PURE__ */ new Map();
4262
+ let totalUncompressed = 0;
4263
+ zipfile.readEntry();
4264
+ zipfile.on("entry", (entry) => {
4265
+ if (entry.fileName.endsWith("/")) {
4266
+ zipfile.readEntry();
4267
+ return;
4268
+ }
4269
+ if (limits.maxFiles > 0 && files.size >= limits.maxFiles) {
4270
+ reject(new Error("zip contains too many files"));
4271
+ return;
4272
+ }
4273
+ const uncompressedSize = entry.uncompressedSize ?? 0;
4274
+ const compressedSize = entry.compressedSize ?? 0;
4275
+ if (limits.maxFileUncompressedSize > 0 && uncompressedSize > limits.maxFileUncompressedSize) {
4276
+ reject(new Error("zip entry exceeds max_file_uncompressed_size"));
4277
+ return;
4278
+ }
4279
+ if (limits.maxTotalUncompressedSize > 0) {
4280
+ totalUncompressed += uncompressedSize;
4281
+ if (totalUncompressed > limits.maxTotalUncompressedSize) {
4282
+ reject(new Error("zip exceeds max_total_uncompressed_size"));
4283
+ return;
4284
+ }
4285
+ }
4286
+ if (limits.maxCompressionRatio !== null) {
4287
+ if (compressedSize === 0 && uncompressedSize > 0) {
4288
+ reject(new Error("zip entry has suspicious compression metadata"));
4289
+ return;
4290
+ }
4291
+ if (compressedSize > 0 && uncompressedSize > 0) {
4292
+ const ratio = uncompressedSize / compressedSize;
4293
+ if (ratio > limits.maxCompressionRatio) {
4294
+ reject(new Error("zip entry exceeds max_compression_ratio"));
4295
+ return;
4296
+ }
4297
+ }
4298
+ }
4299
+ zipfile.openReadStream(entry, (streamErr, stream) => {
4300
+ if (streamErr || !stream) {
4301
+ reject(streamErr ?? new Error("Failed to read zip entry"));
4302
+ return;
4303
+ }
4304
+ const chunks = [];
4305
+ stream.on("data", (chunk) => chunks.push(chunk));
4306
+ stream.on("error", (streamError) => reject(streamError));
4307
+ stream.on("end", () => {
4308
+ files.set(entry.fileName, Buffer.concat(chunks));
4309
+ zipfile.readEntry();
4310
+ });
4311
+ });
4312
+ });
4313
+ zipfile.on("end", () => resolve(files));
4314
+ zipfile.on("error", (zipErr) => reject(zipErr));
4315
+ });
4316
+ });
4317
+ }
4318
+ var DEFAULT_UNZIP_OPTIONS;
4319
+ var init_zip = __esm({
4320
+ "src/utils/zip.ts"() {
4321
+ "use strict";
4322
+ DEFAULT_UNZIP_OPTIONS = {
4323
+ maxFiles: 1e4,
4324
+ maxTotalUncompressedSize: 2e9,
4325
+ maxFileUncompressedSize: 5e8,
4326
+ maxCompressionRatio: 200
4327
+ };
4328
+ }
4329
+ });
4330
+
3739
4331
  // src/client.ts
3740
4332
  var client_exports = {};
3741
4333
  __export(client_exports, {
@@ -3787,573 +4379,148 @@ var init_client = __esm({
3787
4379
  init_auth();
3788
4380
  init_active_sessions();
3789
4381
  init_online_session();
3790
- init_batch_session();
3791
- init_session_status();
3792
- init_invoice_download();
3793
- init_permissions();
3794
- init_tokens();
3795
- init_certificates();
3796
- init_lighthouse();
3797
- init_limits();
3798
- init_peppol();
3799
- init_test_data();
3800
- init_certificate_fetcher();
3801
- init_cryptography_service();
3802
- init_verification_link_service();
3803
- init_auth_xml_builder();
3804
- KSeFClient = class {
3805
- auth;
3806
- activeSessions;
3807
- onlineSession;
3808
- batchSession;
3809
- sessionStatus;
3810
- invoices;
3811
- permissions;
3812
- tokens;
3813
- certificates;
3814
- lighthouse;
3815
- limits;
3816
- peppol;
3817
- testData;
3818
- crypto;
3819
- qr;
3820
- options;
3821
- authManager;
3822
- constructor(options) {
3823
- this.options = resolveOptions(options);
3824
- const authManager = options?.authManager ?? new DefaultAuthManager(async () => {
3825
- const rt = this.authManager.getRefreshToken();
3826
- if (!rt) return null;
3827
- const res = await this.auth.refreshAccessToken(rt);
3828
- return res.accessToken.token;
3829
- });
3830
- this.authManager = authManager;
3831
- const restClientConfig = buildRestClientConfig(options, authManager);
3832
- const restClient = new RestClient(this.options, restClientConfig);
3833
- const fetcher = new CertificateFetcher(restClient);
3834
- this.crypto = new CryptographyService(fetcher);
3835
- this.auth = new AuthService(restClient);
3836
- this.activeSessions = new ActiveSessionsService(restClient);
3837
- this.onlineSession = new OnlineSessionService(restClient);
3838
- this.batchSession = new BatchSessionService(restClient);
3839
- this.sessionStatus = new SessionStatusService(restClient);
3840
- this.invoices = new InvoiceDownloadService(restClient);
3841
- this.permissions = new PermissionsService(restClient);
3842
- this.tokens = new TokenService(restClient);
3843
- this.certificates = new CertificateApiService(restClient);
3844
- this.lighthouse = new LighthouseService(this.options);
3845
- this.limits = new LimitsService(restClient);
3846
- this.peppol = new PeppolService(restClient);
3847
- this.testData = new TestDataService(restClient, this.options.environmentName);
3848
- this.qr = new VerificationLinkService(this.options.baseQrUrl);
3849
- }
3850
- async loginWithToken(token, nip) {
3851
- const challenge = await this.auth.getChallenge();
3852
- await this.crypto.init();
3853
- const encryptedToken = this.crypto.encryptKsefToken(token, challenge.timestamp);
3854
- const submitResult = await this.auth.submitKsefTokenAuthRequest({
3855
- challenge: challenge.challenge,
3856
- contextIdentifier: { type: "Nip", value: nip },
3857
- encryptedToken: Buffer.from(encryptedToken).toString("base64")
3858
- });
3859
- const authToken = submitResult.authenticationToken.token;
3860
- await this.awaitAuthReady(submitResult.referenceNumber, authToken);
3861
- const tokens = await this.auth.getAccessToken(authToken);
3862
- this.authManager.setAccessToken(tokens.accessToken.token);
3863
- this.authManager.setRefreshToken(tokens.refreshToken.token);
3864
- }
3865
- async loginWithCertificate(certPem, keyPem, nip, keyPassword) {
3866
- const challenge = await this.auth.getChallenge();
3867
- const authRequestXml = buildAuthTokenRequestXml(challenge.challenge, nip);
3868
- const { SignatureService: SignatureService2 } = await Promise.resolve().then(() => (init_signature_service(), signature_service_exports));
3869
- const signedXml = SignatureService2.sign(authRequestXml, certPem, keyPem, keyPassword);
3870
- const submitResult = await this.auth.submitXadesAuthRequest(signedXml);
3871
- const authToken = submitResult.authenticationToken.token;
3872
- await this.awaitAuthReady(submitResult.referenceNumber, authToken);
3873
- const tokens = await this.auth.getAccessToken(authToken);
3874
- this.authManager.setAccessToken(tokens.accessToken.token);
3875
- this.authManager.setRefreshToken(tokens.refreshToken.token);
3876
- }
3877
- async loginWithPkcs12(p12, password, nip) {
3878
- const { Pkcs12Loader: Pkcs12Loader2 } = await Promise.resolve().then(() => (init_pkcs12_loader(), pkcs12_loader_exports));
3879
- const { certificatePem, privateKeyPem } = Pkcs12Loader2.load(p12, password);
3880
- await this.loginWithCertificate(certificatePem, privateKeyPem, nip);
3881
- }
3882
- async awaitAuthReady(referenceNumber, authToken) {
3883
- for (let i = 0; i < 30; i++) {
3884
- const status = await this.auth.getAuthStatus(referenceNumber, authToken);
3885
- if (status.status.code === 200) return;
3886
- if (status.status.code !== 100) {
3887
- throw new Error(`Authentication failed with status ${status.status.code}: ${status.status.description}`);
3888
- }
3889
- await new Promise((r) => setTimeout(r, 1e3));
3890
- }
3891
- }
3892
- async logout() {
3893
- this.authManager.setAccessToken(void 0);
3894
- this.authManager.setRefreshToken(void 0);
3895
- }
3896
- };
3897
- }
3898
- });
3899
-
3900
- // src/index.ts
3901
- init_config();
3902
- init_errors();
3903
-
3904
- // src/http/index.ts
3905
- init_route_builder();
3906
- init_rest_request();
3907
- init_rest_client();
3908
- init_routes();
3909
- init_transport();
3910
- init_retry_policy();
3911
- init_rate_limit_policy();
3912
- init_auth_manager();
3913
- init_presigned_url_policy();
3914
- init_ksef_feature();
3915
-
3916
- // src/validation/patterns.ts
3917
- var NIP_PATTERN_CORE = "[1-9]((\\d[1-9])|([1-9]\\d))\\d{7}";
3918
- var VAT_UE_PATTERN_CORE = "(ATU\\d{8}|BE[01]{1}\\d{9}|BG\\d{9,10}|CY\\d{8}[A-Z]|CZ\\d{8,10}|DE\\d{9}|DK\\d{8}|EE\\d{9}|EL\\d{9}|ES([A-Z]\\d{8}|\\d{8}[A-Z]|[A-Z]\\d{7}[A-Z])|FI\\d{8}|FR[A-Z0-9]{2}\\d{9}|HR\\d{11}|HU\\d{8}|IE(\\d{7}[A-Z]{2}|\\d[A-Z0-9+*]\\d{5}[A-Z])|IT\\d{11}|LT(\\d{9}|\\d{12})|LU\\d{8}|LV\\d{11}|MT\\d{8}|NL[A-Z0-9+*]{12}|PT\\d{9}|RO\\d{2,10}|SE\\d{12}|SI\\d{8}|SK\\d{10}|XI((\\d{9}|\\d{12})|(GD|HA)\\d{3}))";
3919
- var Nip = new RegExp(`^${NIP_PATTERN_CORE}$`);
3920
- var VatUe = new RegExp(`^${VAT_UE_PATTERN_CORE}$`);
3921
- var NipVatUe = new RegExp(`^${NIP_PATTERN_CORE}-${VAT_UE_PATTERN_CORE}$`);
3922
- var InternalId = /^[1-9]((\d[1-9])|([1-9]\d))\d{7}-\d{5}$/;
3923
- var PeppolId = /^P[A-Z]{2}[0-9]{6}$/;
3924
- var ReferenceNumber = /^(20[2-9][0-9]|2[1-9][0-9]{2}|[3-9][0-9]{3})(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])-([0-9A-Z]{2})-([0-9A-F]{10})-([0-9A-F]{10})-([0-9A-F]{2})$/;
3925
- var KsefNumber = /^([1-9](\d[1-9]|[1-9]\d)\d{7})-(20[2-9][0-9]|2[1-9]\d{2}|[3-9]\d{3})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])-([0-9A-F]{6})-?([0-9A-F]{6})-([0-9A-F]{2})$/;
3926
- var KsefNumberV35 = /^([1-9]((\d[1-9])|([1-9]\d))\d{7}|M\d{9}|[A-Z]{3}\d{7})-(20[2-9][0-9]|2[1-9][0-9]{2}|[3-9][0-9]{3})(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])-([0-9A-F]{6})([0-9A-F]{6})-([0-9A-F]{2})$/;
3927
- var KsefNumberV36 = /^([1-9]((\d[1-9])|([1-9]\d))\d{7}|M\d{9}|[A-Z]{3}\d{7})-(20[2-9][0-9]|2[1-9][0-9]{2}|[3-9][0-9]{3})(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])-([0-9A-F]{6})-([0-9A-F]{6})-([0-9A-F]{2})$/;
3928
- var CertificateName = /^[a-zA-Z0-9_\- ąćęłńóśźżĄĆĘŁŃÓŚŹŻ]+$/;
3929
- var Pesel = /^\d{2}(?:0[1-9]|1[0-2]|2[1-9]|3[0-2]|4[1-9]|5[0-2]|6[1-9]|7[0-2]|8[1-9]|9[0-2])\d{7}$/;
3930
- var CertificateFingerprint = /^[0-9A-F]{64}$/;
3931
- var Base64String = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
3932
- var Ip4Address = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/;
3933
- var Ip4Range = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}-((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/;
3934
- var Ip4Mask = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}\/(0|[1-9]|1[0-9]|2[0-9]|3[0-2])$/;
3935
- var Sha256Base64 = /^[A-Za-z0-9+/]{43}=$/;
3936
- var NIP_WEIGHTS = [6, 5, 7, 2, 3, 4, 5, 6, 7];
3937
- var PESEL_WEIGHTS = [1, 3, 7, 9, 1, 3, 7, 9, 1, 3];
3938
- var CRC8_POLY = 7;
3939
- function computeCrc8Hex(data) {
3940
- let crc = 0;
3941
- const bytes = new TextEncoder().encode(data);
3942
- for (const byte of bytes) {
3943
- crc ^= byte;
3944
- for (let i = 0; i < 8; i++) {
3945
- crc = (crc & 128) !== 0 ? (crc << 1 ^ CRC8_POLY) & 255 : crc << 1 & 255;
3946
- }
3947
- }
3948
- return crc.toString(16).toUpperCase().padStart(2, "0");
3949
- }
3950
- function isValidNip(value) {
3951
- if (!Nip.test(value)) return false;
3952
- let sum = 0;
3953
- for (let i = 0; i < 9; i++) {
3954
- sum += Number(value[i]) * NIP_WEIGHTS[i];
3955
- }
3956
- const checksum = sum % 11;
3957
- return checksum !== 10 && checksum === Number(value[9]);
3958
- }
3959
- function isValidVatUe(value) {
3960
- return VatUe.test(value);
3961
- }
3962
- function isValidNipVatUe(value) {
3963
- return NipVatUe.test(value);
3964
- }
3965
- function isValidInternalId(value) {
3966
- return InternalId.test(value);
3967
- }
3968
- function isValidPeppolId(value) {
3969
- return PeppolId.test(value);
3970
- }
3971
- function isValidReferenceNumber(value) {
3972
- return ReferenceNumber.test(value);
3973
- }
3974
- function isValidKsefNumber(value) {
3975
- if (!KsefNumber.test(value)) return false;
3976
- let normalized = value;
3977
- if (value.length === 36) {
3978
- const parts = value.split("-");
3979
- if (parts.length === 5) normalized = `${parts[0]}-${parts[1]}-${parts[2]}${parts[3]}-${parts[4]}`;
3980
- else return false;
3981
- }
3982
- if (normalized.length !== 35) return false;
3983
- return computeCrc8Hex(normalized.slice(0, 32)) === normalized.slice(-2);
3984
- }
3985
- function isValidKsefNumberV35(value) {
3986
- if (!KsefNumberV35.test(value)) return false;
3987
- return computeCrc8Hex(value.slice(0, 32)) === value.slice(-2);
3988
- }
3989
- function isValidKsefNumberV36(value) {
3990
- if (!KsefNumberV36.test(value)) return false;
3991
- const parts = value.split("-");
3992
- if (parts.length !== 5) return false;
3993
- const normalized = `${parts[0]}-${parts[1]}-${parts[2]}${parts[3]}-${parts[4]}`;
3994
- return computeCrc8Hex(normalized.slice(0, 32)) === normalized.slice(-2);
3995
- }
3996
- function isValidPesel(value) {
3997
- if (!Pesel.test(value)) return false;
3998
- let sum = 0;
3999
- for (let i = 0; i < 10; i++) {
4000
- sum += Number(value[i]) * PESEL_WEIGHTS[i];
4001
- }
4002
- const checksum = (10 - sum % 10) % 10;
4003
- return checksum === Number(value[10]);
4004
- }
4005
- function isValidCertificateName(value) {
4006
- return CertificateName.test(value);
4007
- }
4008
- function isValidCertificateFingerprint(value) {
4009
- return CertificateFingerprint.test(value);
4010
- }
4011
- function isValidBase64(value) {
4012
- return Base64String.test(value);
4013
- }
4014
- function isValidIp4Address(value) {
4015
- return Ip4Address.test(value);
4016
- }
4017
- function isValidSha256Base64(value) {
4018
- return Sha256Base64.test(value);
4019
- }
4020
-
4021
- // src/validation/constraints.ts
4022
- var REQUIRED_CHALLENGE_LENGTH = 36;
4023
- var CERTIFICATE_NAME_MIN_LENGTH = 5;
4024
- var CERTIFICATE_NAME_MAX_LENGTH = 100;
4025
- var SUBUNIT_NAME_MIN_LENGTH = 5;
4026
- var SUBUNIT_NAME_MAX_LENGTH = 256;
4027
- var PERMISSION_DESCRIPTION_MIN_LENGTH = 5;
4028
- var PERMISSION_DESCRIPTION_MAX_LENGTH = 256;
4029
-
4030
- // src/validation/xml-to-object.ts
4031
- import { DOMParser } from "@xmldom/xmldom";
4032
- function xmlToObject(xml) {
4033
- const errors = [];
4034
- const doc = new DOMParser({
4035
- errorHandler: {
4036
- warning: (_msg) => {
4037
- },
4038
- error: (msg) => errors.push(msg),
4039
- fatalError: (msg) => errors.push(msg)
4040
- }
4041
- }).parseFromString(xml, "text/xml");
4042
- if (errors.length > 0 || !doc || !doc.documentElement) {
4043
- return { object: null, rootElement: null, namespace: null, errors };
4044
- }
4045
- const root = doc.documentElement;
4046
- const rootName = getLocalName(root);
4047
- const namespace = root.namespaceURI || null;
4048
- const obj = elementToObject(root);
4049
- return {
4050
- object: typeof obj === "object" && obj !== null ? obj : { "#text": obj },
4051
- rootElement: rootName,
4052
- namespace,
4053
- errors: []
4054
- };
4055
- }
4056
- function getLocalName(node) {
4057
- if (node.localName) return node.localName;
4058
- const name = node.nodeName;
4059
- const idx = name.indexOf(":");
4060
- return idx === -1 ? name : name.substring(idx + 1);
4061
- }
4062
- function elementToObject(el) {
4063
- const result = {};
4064
- let hasChildElements = false;
4065
- for (let i = 0; i < el.attributes.length; i++) {
4066
- const a = el.attributes.item(i);
4067
- if (!a) continue;
4068
- const name = a.nodeName;
4069
- if (name === "xmlns" || name.startsWith("xmlns:")) continue;
4070
- const attrLocal = getLocalName(a);
4071
- result[`@${attrLocal}`] = a.value;
4072
- }
4073
- const childCounts = /* @__PURE__ */ new Map();
4074
- for (let i = 0; i < el.childNodes.length; i++) {
4075
- const child = el.childNodes.item(i);
4076
- if (!child || child.nodeType !== 1) continue;
4077
- const name = getLocalName(child);
4078
- childCounts.set(name, (childCounts.get(name) || 0) + 1);
4079
- hasChildElements = true;
4080
- }
4081
- if (!hasChildElements) {
4082
- const text = getTextContent(el);
4083
- const hasAttrs = Object.keys(result).length > 0;
4084
- if (hasAttrs) {
4085
- result["#text"] = text;
4086
- return result;
4087
- }
4088
- return text;
4089
- }
4090
- for (let i = 0; i < el.childNodes.length; i++) {
4091
- const child = el.childNodes.item(i);
4092
- if (!child || child.nodeType !== 1) continue;
4093
- const name = getLocalName(child);
4094
- const value = elementToObject(child);
4095
- const count = childCounts.get(name) || 1;
4096
- if (count > 1) {
4097
- if (!Array.isArray(result[name])) {
4098
- result[name] = [];
4099
- }
4100
- result[name].push(value);
4101
- } else {
4102
- result[name] = value;
4103
- }
4104
- }
4105
- return result;
4106
- }
4107
- function getTextContent(el) {
4108
- let text = "";
4109
- for (let i = 0; i < el.childNodes.length; i++) {
4110
- const child = el.childNodes.item(i);
4111
- if (!child) continue;
4112
- if (child.nodeType === 3 || child.nodeType === 4) {
4113
- text += child.nodeValue || "";
4114
- }
4115
- }
4116
- return text.trim();
4117
- }
4118
-
4119
- // src/validation/schemas/index.ts
4120
- init_fa3();
4121
- init_fa2();
4122
- init_rr1_v11e();
4123
- init_rr1_v10e();
4124
- init_pef3();
4125
- init_pef_kor3();
4126
- var NAMESPACE_MAP = {
4127
- "http://crd.gov.pl/wzor/2025/06/25/13775/": "FA3",
4128
- "http://crd.gov.pl/wzor/2023/06/29/12648/": "FA2",
4129
- "http://crd.gov.pl/wzor/2026/03/06/14189/": "RR1_V11E",
4130
- "http://crd.gov.pl/wzor/2026/02/17/14164/": "RR1_V10E",
4131
- "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2": "PEF3",
4132
- "urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2": "PEF_KOR3"
4133
- };
4134
-
4135
- // src/validation/schema-registry.ts
4136
- var ROOT_ELEMENT_MAP = {
4137
- Invoice: "PEF3",
4138
- CreditNote: "PEF_KOR3"
4139
- };
4140
- var schemaCache = /* @__PURE__ */ new Map();
4141
- async function loadSchema(type) {
4142
- const cached = schemaCache.get(type);
4143
- if (cached) return cached;
4144
- let mod;
4145
- switch (type) {
4146
- case "FA3":
4147
- mod = await Promise.resolve().then(() => (init_fa3(), fa3_exports));
4148
- break;
4149
- case "FA2":
4150
- mod = await Promise.resolve().then(() => (init_fa2(), fa2_exports));
4151
- break;
4152
- case "RR1_V11E":
4153
- mod = await Promise.resolve().then(() => (init_rr1_v11e(), rr1_v11e_exports));
4154
- break;
4155
- case "RR1_V10E":
4156
- mod = await Promise.resolve().then(() => (init_rr1_v10e(), rr1_v10e_exports));
4157
- break;
4158
- case "PEF3":
4159
- mod = await Promise.resolve().then(() => (init_pef3(), pef3_exports));
4160
- break;
4161
- case "PEF_KOR3":
4162
- mod = await Promise.resolve().then(() => (init_pef_kor3(), pef_kor3_exports));
4163
- break;
4164
- default:
4165
- throw new Error(`Unknown schema type: ${type}`);
4166
- }
4167
- const exportName = `${type}Schema`;
4168
- const schema = mod[exportName];
4169
- if (!schema) {
4170
- throw new Error(`Schema export "${exportName}" not found in module for type "${type}"`);
4171
- }
4172
- schemaCache.set(type, schema);
4173
- return schema;
4174
- }
4175
- var SchemaRegistry = {
4176
- /**
4177
- * Get a Zod schema by type. Lazy-loads the module on first access.
4178
- */
4179
- async get(type) {
4180
- return loadSchema(type);
4181
- },
4182
- /**
4183
- * List all available schema types.
4184
- */
4185
- availableSchemas() {
4186
- return ["FA3", "FA2", "RR1_V11E", "RR1_V10E", "PEF3", "PEF_KOR3"];
4187
- },
4188
- /**
4189
- * Detect schema type from XML namespace URI and/or root element name.
4190
- *
4191
- * Detection priority:
4192
- * 1. Namespace URI match (unique per FA/RR schemas)
4193
- * 2. Root element name match (for PEF/PEF_KOR which use UBL namespaces)
4194
- */
4195
- detect(namespace, rootElement) {
4196
- if (namespace) {
4197
- const byNs = NAMESPACE_MAP[namespace];
4198
- if (byNs) return byNs;
4199
- }
4200
- if (rootElement) {
4201
- const byRoot = ROOT_ELEMENT_MAP[rootElement];
4202
- if (byRoot) return byRoot;
4203
- }
4204
- return null;
4205
- }
4206
- };
4207
-
4208
- // src/validation/invoice-validator.ts
4209
- function validateWellFormedness(xml, _parsed) {
4210
- if (!xml || !xml.trim()) {
4211
- return {
4212
- valid: false,
4213
- schemaType: null,
4214
- errors: [{ code: "MALFORMED_XML", message: "Empty XML input" }]
4215
- };
4216
- }
4217
- const { object, rootElement, namespace, errors } = _parsed ?? xmlToObject(xml);
4218
- if (errors.length > 0 || !object) {
4219
- return {
4220
- valid: false,
4221
- schemaType: null,
4222
- errors: errors.map((msg) => ({ code: "MALFORMED_XML", message: msg }))
4223
- };
4224
- }
4225
- const schemaType = SchemaRegistry.detect(namespace, rootElement);
4226
- return { valid: true, schemaType, errors: [] };
4227
- }
4228
- async function validateSchema(xml, options, _parsed) {
4229
- const { object, rootElement, namespace, errors: parseErrors } = _parsed ?? xmlToObject(xml);
4230
- if (parseErrors.length > 0 || !object) {
4231
- return {
4232
- valid: false,
4233
- schemaType: null,
4234
- errors: parseErrors.map((msg) => ({ code: "MALFORMED_XML", message: msg }))
4235
- };
4236
- }
4237
- const schemaType = options?.schema ?? SchemaRegistry.detect(namespace, rootElement);
4238
- if (!schemaType) {
4239
- return {
4240
- valid: false,
4241
- schemaType: null,
4242
- errors: [{
4243
- code: "UNKNOWN_SCHEMA",
4244
- message: `Cannot detect schema type from namespace "${namespace}" and root element "${rootElement}"`
4245
- }]
4246
- };
4247
- }
4248
- const schema = await SchemaRegistry.get(schemaType);
4249
- const result = schema.safeParse(object);
4250
- if (result.success) {
4251
- return { valid: true, schemaType, errors: [] };
4252
- }
4253
- const prefix = rootElement ? `/${rootElement}/` : "/";
4254
- const validationErrors = result.error.issues.map((issue) => {
4255
- const zodPath = issue.path.join("/");
4256
- const path = zodPath ? `${prefix}${zodPath}` : rootElement ? `/${rootElement}` : void 0;
4257
- return {
4258
- code: mapZodErrorCode(issue),
4259
- message: issue.message,
4260
- path
4261
- };
4262
- });
4263
- return { valid: false, schemaType, errors: validationErrors };
4264
- }
4265
- function mapZodErrorCode(issue) {
4266
- switch (issue.code) {
4267
- case "invalid_type":
4268
- return issue.input === void 0 ? "MISSING_REQUIRED_ELEMENT" : "INVALID_VALUE";
4269
- case "invalid_enum_value":
4270
- // Zod v3
4271
- case "invalid_value":
4272
- return "INVALID_ENUM_VALUE";
4273
- case "invalid_string":
4274
- // Zod v3
4275
- case "invalid_format":
4276
- return "PATTERN_MISMATCH";
4277
- case "too_big":
4278
- return "MAX_OCCURS_EXCEEDED";
4279
- default:
4280
- return "SCHEMA_VALIDATION_ERROR";
4281
- }
4282
- }
4283
- function validateBusinessRules(xml, _parsed) {
4284
- const { object, rootElement, namespace, errors: parseErrors } = _parsed ?? xmlToObject(xml);
4285
- if (parseErrors.length > 0 || !object) {
4286
- return {
4287
- valid: false,
4288
- schemaType: null,
4289
- errors: parseErrors.map((msg) => ({ code: "MALFORMED_XML", message: msg }))
4290
- };
4291
- }
4292
- const schemaType = SchemaRegistry.detect(namespace, rootElement);
4293
- const errors = [];
4294
- collectNipPeselErrors(object, rootElement ? `/${rootElement}` : "", errors);
4295
- collectDateErrors(object, rootElement, errors);
4296
- return { valid: errors.length === 0, schemaType, errors };
4297
- }
4298
- function collectNipPeselErrors(obj, path, errors) {
4299
- for (const [key, value] of Object.entries(obj)) {
4300
- const currentPath = path ? `${path}/${key}` : key;
4301
- if (key === "NIP" && typeof value === "string") {
4302
- if (!isValidNip(value)) {
4303
- errors.push({
4304
- code: "INVALID_NIP_CHECKSUM",
4305
- message: `Invalid NIP checksum: ${value}`,
4306
- path: currentPath
4382
+ init_batch_session();
4383
+ init_session_status();
4384
+ init_invoice_download();
4385
+ init_permissions();
4386
+ init_tokens();
4387
+ init_certificates();
4388
+ init_lighthouse();
4389
+ init_limits();
4390
+ init_peppol();
4391
+ init_test_data();
4392
+ init_certificate_fetcher();
4393
+ init_cryptography_service();
4394
+ init_verification_link_service();
4395
+ init_auth_xml_builder();
4396
+ KSeFClient = class {
4397
+ auth;
4398
+ activeSessions;
4399
+ onlineSession;
4400
+ batchSession;
4401
+ sessionStatus;
4402
+ invoices;
4403
+ permissions;
4404
+ tokens;
4405
+ certificates;
4406
+ lighthouse;
4407
+ limits;
4408
+ peppol;
4409
+ testData;
4410
+ crypto;
4411
+ qr;
4412
+ options;
4413
+ authManager;
4414
+ constructor(options) {
4415
+ this.options = resolveOptions(options);
4416
+ const authManager = options?.authManager ?? new DefaultAuthManager(async () => {
4417
+ const rt = this.authManager.getRefreshToken();
4418
+ if (!rt) return null;
4419
+ const res = await this.auth.refreshAccessToken(rt);
4420
+ return res.accessToken.token;
4307
4421
  });
4422
+ this.authManager = authManager;
4423
+ const restClientConfig = buildRestClientConfig(options, authManager);
4424
+ const restClient = new RestClient(this.options, restClientConfig);
4425
+ const fetcher = new CertificateFetcher(restClient);
4426
+ this.crypto = new CryptographyService(fetcher);
4427
+ this.auth = new AuthService(restClient);
4428
+ this.activeSessions = new ActiveSessionsService(restClient);
4429
+ this.onlineSession = new OnlineSessionService(restClient);
4430
+ this.batchSession = new BatchSessionService(restClient);
4431
+ this.sessionStatus = new SessionStatusService(restClient);
4432
+ this.invoices = new InvoiceDownloadService(restClient);
4433
+ this.permissions = new PermissionsService(restClient);
4434
+ this.tokens = new TokenService(restClient);
4435
+ this.certificates = new CertificateApiService(restClient);
4436
+ this.lighthouse = new LighthouseService(this.options);
4437
+ this.limits = new LimitsService(restClient);
4438
+ this.peppol = new PeppolService(restClient);
4439
+ this.testData = new TestDataService(restClient, this.options.environmentName);
4440
+ this.qr = new VerificationLinkService(this.options.baseQrUrl);
4308
4441
  }
4309
- } else if (key === "PESEL" && typeof value === "string") {
4310
- if (!isValidPesel(value)) {
4311
- errors.push({
4312
- code: "INVALID_PESEL_CHECKSUM",
4313
- message: `Invalid PESEL checksum: ${value}`,
4314
- path: currentPath
4442
+ async loginWithToken(token, nip) {
4443
+ const challenge = await this.auth.getChallenge();
4444
+ await this.crypto.init();
4445
+ const encryptedToken = this.crypto.encryptKsefToken(token, challenge.timestamp);
4446
+ const submitResult = await this.auth.submitKsefTokenAuthRequest({
4447
+ challenge: challenge.challenge,
4448
+ contextIdentifier: { type: "Nip", value: nip },
4449
+ encryptedToken: Buffer.from(encryptedToken).toString("base64")
4315
4450
  });
4451
+ const authToken = submitResult.authenticationToken.token;
4452
+ await this.awaitAuthReady(submitResult.referenceNumber, authToken);
4453
+ const tokens = await this.auth.getAccessToken(authToken);
4454
+ this.authManager.setAccessToken(tokens.accessToken.token);
4455
+ this.authManager.setRefreshToken(tokens.refreshToken.token);
4316
4456
  }
4317
- } else if (typeof value === "object" && value !== null) {
4318
- if (Array.isArray(value)) {
4319
- for (let i = 0; i < value.length; i++) {
4320
- if (typeof value[i] === "object" && value[i] !== null) {
4321
- collectNipPeselErrors(value[i], `${currentPath}/${i}`, errors);
4457
+ async loginWithCertificate(certPem, keyPem, nip, keyPassword) {
4458
+ const challenge = await this.auth.getChallenge();
4459
+ const authRequestXml = buildAuthTokenRequestXml(challenge.challenge, nip);
4460
+ const { SignatureService: SignatureService2 } = await Promise.resolve().then(() => (init_signature_service(), signature_service_exports));
4461
+ const signedXml = SignatureService2.sign(authRequestXml, certPem, keyPem, keyPassword);
4462
+ const submitResult = await this.auth.submitXadesAuthRequest(signedXml);
4463
+ const authToken = submitResult.authenticationToken.token;
4464
+ await this.awaitAuthReady(submitResult.referenceNumber, authToken);
4465
+ const tokens = await this.auth.getAccessToken(authToken);
4466
+ this.authManager.setAccessToken(tokens.accessToken.token);
4467
+ this.authManager.setRefreshToken(tokens.refreshToken.token);
4468
+ }
4469
+ async loginWithPkcs12(p12, password, nip) {
4470
+ const { Pkcs12Loader: Pkcs12Loader2 } = await Promise.resolve().then(() => (init_pkcs12_loader(), pkcs12_loader_exports));
4471
+ const { certificatePem, privateKeyPem } = Pkcs12Loader2.load(p12, password);
4472
+ await this.loginWithCertificate(certificatePem, privateKeyPem, nip);
4473
+ }
4474
+ async awaitAuthReady(referenceNumber, authToken) {
4475
+ for (let i = 0; i < 30; i++) {
4476
+ const status = await this.auth.getAuthStatus(referenceNumber, authToken);
4477
+ if (status.status.code === 200) return;
4478
+ if (status.status.code !== 100) {
4479
+ throw new Error(`Authentication failed with status ${status.status.code}: ${status.status.description}`);
4322
4480
  }
4481
+ await new Promise((r) => setTimeout(r, 1e3));
4323
4482
  }
4324
- } else {
4325
- collectNipPeselErrors(value, currentPath, errors);
4326
4483
  }
4327
- }
4328
- }
4329
- }
4330
- function getPolandLocalDate() {
4331
- return new Intl.DateTimeFormat("sv-SE", { timeZone: "Europe/Warsaw" }).format(Date.now());
4332
- }
4333
- function collectDateErrors(obj, rootElement, errors) {
4334
- const fa = obj["Fa"];
4335
- if (!fa || typeof fa !== "object") return;
4336
- const p1 = fa["P_1"];
4337
- if (typeof p1 !== "string") return;
4338
- const today = getPolandLocalDate();
4339
- if (p1 > today) {
4340
- const prefix = rootElement ? `/${rootElement}` : "";
4341
- errors.push({
4342
- code: "FUTURE_INVOICE_DATE",
4343
- message: `Invoice date P_1 (${p1}) is in the future \u2014 KSeF rejects invoices with P_1 > today (${today})`,
4344
- path: `${prefix}/Fa/P_1`
4345
- });
4484
+ async logout() {
4485
+ this.authManager.setAccessToken(void 0);
4486
+ this.authManager.setRefreshToken(void 0);
4487
+ }
4488
+ };
4346
4489
  }
4347
- }
4348
- async function validate(xml, options) {
4349
- const parsed = xml && xml.trim() ? xmlToObject(xml) : void 0;
4350
- const l1 = validateWellFormedness(xml, parsed);
4351
- if (!l1.valid) return l1;
4352
- const l2 = await validateSchema(xml, options, parsed);
4353
- if (!l2.valid) return l2;
4354
- const l3 = validateBusinessRules(xml, parsed);
4355
- return { ...l3, schemaType: l2.schemaType };
4356
- }
4490
+ });
4491
+
4492
+ // src/index.ts
4493
+ init_config();
4494
+ init_errors();
4495
+
4496
+ // src/http/index.ts
4497
+ init_route_builder();
4498
+ init_rest_request();
4499
+ init_rest_client();
4500
+ init_routes();
4501
+ init_transport();
4502
+ init_retry_policy();
4503
+ init_rate_limit_policy();
4504
+ init_auth_manager();
4505
+ init_presigned_url_policy();
4506
+ init_ksef_feature();
4507
+
4508
+ // src/validation/index.ts
4509
+ init_patterns();
4510
+
4511
+ // src/validation/constraints.ts
4512
+ var REQUIRED_CHALLENGE_LENGTH = 36;
4513
+ var CERTIFICATE_NAME_MIN_LENGTH = 5;
4514
+ var CERTIFICATE_NAME_MAX_LENGTH = 100;
4515
+ var SUBUNIT_NAME_MIN_LENGTH = 5;
4516
+ var SUBUNIT_NAME_MAX_LENGTH = 256;
4517
+ var PERMISSION_DESCRIPTION_MIN_LENGTH = 5;
4518
+ var PERMISSION_DESCRIPTION_MAX_LENGTH = 256;
4519
+
4520
+ // src/validation/index.ts
4521
+ init_xml_to_object();
4522
+ init_schema_registry();
4523
+ init_invoice_validator();
4357
4524
 
4358
4525
  // src/models/document-structures/types.ts
4359
4526
  var SystemCode = {
@@ -5100,93 +5267,8 @@ function escapeXml2(str) {
5100
5267
  return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
5101
5268
  }
5102
5269
 
5103
- // src/utils/zip.ts
5104
- import { ZipFile } from "yazl";
5105
- import { fromBuffer } from "yauzl";
5106
- var DEFAULT_UNZIP_OPTIONS = {
5107
- maxFiles: 1e4,
5108
- maxTotalUncompressedSize: 2e9,
5109
- maxFileUncompressedSize: 5e8,
5110
- maxCompressionRatio: 200
5111
- };
5112
- async function createZip(entries) {
5113
- return new Promise((resolve, reject) => {
5114
- const zipfile = new ZipFile();
5115
- for (const entry of entries) {
5116
- zipfile.addBuffer(Buffer.from(entry.content), entry.fileName);
5117
- }
5118
- const chunks = [];
5119
- zipfile.outputStream.on("data", (chunk) => chunks.push(chunk));
5120
- zipfile.outputStream.on("error", (err) => reject(err));
5121
- zipfile.outputStream.on("end", () => resolve(Buffer.concat(chunks)));
5122
- zipfile.end();
5123
- });
5124
- }
5125
- async function unzip(buffer, options = {}) {
5126
- const limits = { ...DEFAULT_UNZIP_OPTIONS, ...options };
5127
- return new Promise((resolve, reject) => {
5128
- fromBuffer(buffer, { lazyEntries: true }, (err, zipfile) => {
5129
- if (err || !zipfile) {
5130
- reject(err ?? new Error("Failed to open zip buffer"));
5131
- return;
5132
- }
5133
- const files = /* @__PURE__ */ new Map();
5134
- let totalUncompressed = 0;
5135
- zipfile.readEntry();
5136
- zipfile.on("entry", (entry) => {
5137
- if (entry.fileName.endsWith("/")) {
5138
- zipfile.readEntry();
5139
- return;
5140
- }
5141
- if (limits.maxFiles > 0 && files.size >= limits.maxFiles) {
5142
- reject(new Error("zip contains too many files"));
5143
- return;
5144
- }
5145
- const uncompressedSize = entry.uncompressedSize ?? 0;
5146
- const compressedSize = entry.compressedSize ?? 0;
5147
- if (limits.maxFileUncompressedSize > 0 && uncompressedSize > limits.maxFileUncompressedSize) {
5148
- reject(new Error("zip entry exceeds max_file_uncompressed_size"));
5149
- return;
5150
- }
5151
- if (limits.maxTotalUncompressedSize > 0) {
5152
- totalUncompressed += uncompressedSize;
5153
- if (totalUncompressed > limits.maxTotalUncompressedSize) {
5154
- reject(new Error("zip exceeds max_total_uncompressed_size"));
5155
- return;
5156
- }
5157
- }
5158
- if (limits.maxCompressionRatio !== null) {
5159
- if (compressedSize === 0 && uncompressedSize > 0) {
5160
- reject(new Error("zip entry has suspicious compression metadata"));
5161
- return;
5162
- }
5163
- if (compressedSize > 0 && uncompressedSize > 0) {
5164
- const ratio = uncompressedSize / compressedSize;
5165
- if (ratio > limits.maxCompressionRatio) {
5166
- reject(new Error("zip entry exceeds max_compression_ratio"));
5167
- return;
5168
- }
5169
- }
5170
- }
5171
- zipfile.openReadStream(entry, (streamErr, stream) => {
5172
- if (streamErr || !stream) {
5173
- reject(streamErr ?? new Error("Failed to read zip entry"));
5174
- return;
5175
- }
5176
- const chunks = [];
5177
- stream.on("data", (chunk) => chunks.push(chunk));
5178
- stream.on("error", (streamError) => reject(streamError));
5179
- stream.on("end", () => {
5180
- files.set(entry.fileName, Buffer.concat(chunks));
5181
- zipfile.readEntry();
5182
- });
5183
- });
5184
- });
5185
- zipfile.on("end", () => resolve(files));
5186
- zipfile.on("error", (zipErr) => reject(zipErr));
5187
- });
5188
- });
5189
- }
5270
+ // src/utils/index.ts
5271
+ init_zip();
5190
5272
 
5191
5273
  // src/utils/jwt.ts
5192
5274
  function decodeJwtPayload(token) {
@@ -5369,6 +5451,7 @@ function parseUpoXml(xml) {
5369
5451
  }
5370
5452
 
5371
5453
  // src/workflows/online-session-workflow.ts
5454
+ init_invoice_validator();
5372
5455
  init_ksef_validation_error();
5373
5456
  async function openOnlineSession(client, options) {
5374
5457
  await client.crypto.init();
@@ -5451,6 +5534,24 @@ async function openSendAndClose(client, invoices, options) {
5451
5534
  // src/workflows/batch-session-workflow.ts
5452
5535
  async function uploadBatch(client, zipData, options) {
5453
5536
  await client.crypto.init();
5537
+ if (options?.validate) {
5538
+ const { unzip: unzip2 } = await Promise.resolve().then(() => (init_zip(), zip_exports));
5539
+ const { validateBatch: validateBatch2, batchValidationDetails: batchValidationDetails2 } = await Promise.resolve().then(() => (init_invoice_validator(), invoice_validator_exports));
5540
+ const { KSeFValidationError: KSeFValidationError2 } = await Promise.resolve().then(() => (init_ksef_validation_error(), ksef_validation_error_exports));
5541
+ const zipBuf = Buffer.isBuffer(zipData) ? zipData : Buffer.from(zipData.buffer, zipData.byteOffset, zipData.byteLength);
5542
+ const files = await unzip2(zipBuf);
5543
+ const invoices = [...files.entries()].filter(([name]) => name.endsWith(".xml")).map(([name, data]) => ({ fileName: name, xml: data.toString("utf-8") }));
5544
+ if (invoices.length > 0) {
5545
+ const result2 = await validateBatch2(invoices);
5546
+ if (!result2.valid) {
5547
+ const invalidCount = result2.results.filter((r) => !r.result.valid).length;
5548
+ throw new KSeFValidationError2(
5549
+ `Batch validation failed: ${invalidCount} of ${invoices.length} invoices invalid`,
5550
+ batchValidationDetails2(result2)
5551
+ );
5552
+ }
5553
+ }
5554
+ }
5454
5555
  const encData = client.crypto.getEncryptionData();
5455
5556
  const formCode = options?.formCode ?? DEFAULT_FORM_CODE;
5456
5557
  const encryptFn = (part) => client.crypto.encryptAES256(part, encData.cipherKey, encData.cipherIv);
@@ -5562,6 +5663,7 @@ async function uploadBatchParsed(client, zipData, options) {
5562
5663
  }
5563
5664
 
5564
5665
  // src/workflows/invoice-export-workflow.ts
5666
+ init_zip();
5565
5667
  async function doExport(client, filters, options) {
5566
5668
  await client.crypto.init();
5567
5669
  const encData = client.crypto.getEncryptionData();
@@ -5938,6 +6040,7 @@ export {
5938
6040
  authenticateWithExternalSignature,
5939
6041
  authenticateWithPkcs12,
5940
6042
  authenticateWithToken,
6043
+ batchValidationDetails,
5941
6044
  buildUnsignedAuthTokenRequestXml,
5942
6045
  calculateBackoff,
5943
6046
  createZip,
@@ -5985,6 +6088,7 @@ export {
5985
6088
  uploadBatchStream,
5986
6089
  uploadBatchStreamParsed,
5987
6090
  validate,
6091
+ validateBatch,
5988
6092
  validateBusinessRules,
5989
6093
  validateFormCodeForSession,
5990
6094
  validatePresignedUrl,