@uipath/integrationservice-tool 1.201.0-preview.115 → 1.201.0-preview.121
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-w23k88b5.js → index-p50kx6jv.js} +202 -64
- package/dist/index.js +1 -1
- package/dist/{tool-jsd9bcge.js → tool-3r0c1q0j.js} +1283 -2537
- package/dist/tool.js +1 -1
- package/package.json +2 -2
|
@@ -2108,2369 +2108,11 @@ var require_commander = __commonJS((exports) => {
|
|
|
2108
2108
|
exports.InvalidArgumentError = InvalidArgumentError;
|
|
2109
2109
|
exports.InvalidOptionArgumentError = InvalidArgumentError;
|
|
2110
2110
|
});
|
|
2111
|
-
|
|
2112
|
-
// ../../node_modules/adm-zip/util/constants.js
|
|
2113
|
-
var require_constants = __commonJS((exports, module) => {
|
|
2114
|
-
module.exports = {
|
|
2115
|
-
LOCHDR: 30,
|
|
2116
|
-
LOCSIG: 67324752,
|
|
2117
|
-
LOCVER: 4,
|
|
2118
|
-
LOCFLG: 6,
|
|
2119
|
-
LOCHOW: 8,
|
|
2120
|
-
LOCTIM: 10,
|
|
2121
|
-
LOCCRC: 14,
|
|
2122
|
-
LOCSIZ: 18,
|
|
2123
|
-
LOCLEN: 22,
|
|
2124
|
-
LOCNAM: 26,
|
|
2125
|
-
LOCEXT: 28,
|
|
2126
|
-
EXTSIG: 134695760,
|
|
2127
|
-
EXTHDR: 16,
|
|
2128
|
-
EXTCRC: 4,
|
|
2129
|
-
EXTSIZ: 8,
|
|
2130
|
-
EXTLEN: 12,
|
|
2131
|
-
CENHDR: 46,
|
|
2132
|
-
CENSIG: 33639248,
|
|
2133
|
-
CENVEM: 4,
|
|
2134
|
-
CENVER: 6,
|
|
2135
|
-
CENFLG: 8,
|
|
2136
|
-
CENHOW: 10,
|
|
2137
|
-
CENTIM: 12,
|
|
2138
|
-
CENCRC: 16,
|
|
2139
|
-
CENSIZ: 20,
|
|
2140
|
-
CENLEN: 24,
|
|
2141
|
-
CENNAM: 28,
|
|
2142
|
-
CENEXT: 30,
|
|
2143
|
-
CENCOM: 32,
|
|
2144
|
-
CENDSK: 34,
|
|
2145
|
-
CENATT: 36,
|
|
2146
|
-
CENATX: 38,
|
|
2147
|
-
CENOFF: 42,
|
|
2148
|
-
ENDHDR: 22,
|
|
2149
|
-
ENDSIG: 101010256,
|
|
2150
|
-
ENDSUB: 8,
|
|
2151
|
-
ENDTOT: 10,
|
|
2152
|
-
ENDSIZ: 12,
|
|
2153
|
-
ENDOFF: 16,
|
|
2154
|
-
ENDCOM: 20,
|
|
2155
|
-
END64HDR: 20,
|
|
2156
|
-
END64SIG: 117853008,
|
|
2157
|
-
END64START: 4,
|
|
2158
|
-
END64OFF: 8,
|
|
2159
|
-
END64NUMDISKS: 16,
|
|
2160
|
-
ZIP64SIG: 101075792,
|
|
2161
|
-
ZIP64HDR: 56,
|
|
2162
|
-
ZIP64LEAD: 12,
|
|
2163
|
-
ZIP64SIZE: 4,
|
|
2164
|
-
ZIP64VEM: 12,
|
|
2165
|
-
ZIP64VER: 14,
|
|
2166
|
-
ZIP64DSK: 16,
|
|
2167
|
-
ZIP64DSKDIR: 20,
|
|
2168
|
-
ZIP64SUB: 24,
|
|
2169
|
-
ZIP64TOT: 32,
|
|
2170
|
-
ZIP64SIZB: 40,
|
|
2171
|
-
ZIP64OFF: 48,
|
|
2172
|
-
ZIP64EXTRA: 56,
|
|
2173
|
-
STORED: 0,
|
|
2174
|
-
SHRUNK: 1,
|
|
2175
|
-
REDUCED1: 2,
|
|
2176
|
-
REDUCED2: 3,
|
|
2177
|
-
REDUCED3: 4,
|
|
2178
|
-
REDUCED4: 5,
|
|
2179
|
-
IMPLODED: 6,
|
|
2180
|
-
DEFLATED: 8,
|
|
2181
|
-
ENHANCED_DEFLATED: 9,
|
|
2182
|
-
PKWARE: 10,
|
|
2183
|
-
BZIP2: 12,
|
|
2184
|
-
LZMA: 14,
|
|
2185
|
-
IBM_TERSE: 18,
|
|
2186
|
-
IBM_LZ77: 19,
|
|
2187
|
-
AES_ENCRYPT: 99,
|
|
2188
|
-
FLG_ENC: 1,
|
|
2189
|
-
FLG_COMP1: 2,
|
|
2190
|
-
FLG_COMP2: 4,
|
|
2191
|
-
FLG_DESC: 8,
|
|
2192
|
-
FLG_ENH: 16,
|
|
2193
|
-
FLG_PATCH: 32,
|
|
2194
|
-
FLG_STR: 64,
|
|
2195
|
-
FLG_EFS: 2048,
|
|
2196
|
-
FLG_MSK: 4096,
|
|
2197
|
-
FILE: 2,
|
|
2198
|
-
BUFFER: 1,
|
|
2199
|
-
NONE: 0,
|
|
2200
|
-
EF_ID: 0,
|
|
2201
|
-
EF_SIZE: 2,
|
|
2202
|
-
ID_ZIP64: 1,
|
|
2203
|
-
ID_AVINFO: 7,
|
|
2204
|
-
ID_PFS: 8,
|
|
2205
|
-
ID_OS2: 9,
|
|
2206
|
-
ID_NTFS: 10,
|
|
2207
|
-
ID_OPENVMS: 12,
|
|
2208
|
-
ID_UNIX: 13,
|
|
2209
|
-
ID_FORK: 14,
|
|
2210
|
-
ID_PATCH: 15,
|
|
2211
|
-
ID_X509_PKCS7: 20,
|
|
2212
|
-
ID_X509_CERTID_F: 21,
|
|
2213
|
-
ID_X509_CERTID_C: 22,
|
|
2214
|
-
ID_STRONGENC: 23,
|
|
2215
|
-
ID_RECORD_MGT: 24,
|
|
2216
|
-
ID_X509_PKCS7_RL: 25,
|
|
2217
|
-
ID_IBM1: 101,
|
|
2218
|
-
ID_IBM2: 102,
|
|
2219
|
-
ID_POSZIP: 18064,
|
|
2220
|
-
EF_ZIP64_OR_32: 4294967295,
|
|
2221
|
-
EF_ZIP64_OR_16: 65535,
|
|
2222
|
-
EF_ZIP64_SUNCOMP: 0,
|
|
2223
|
-
EF_ZIP64_SCOMP: 8,
|
|
2224
|
-
EF_ZIP64_RHO: 16,
|
|
2225
|
-
EF_ZIP64_DSN: 24
|
|
2226
|
-
};
|
|
2227
|
-
});
|
|
2228
|
-
|
|
2229
|
-
// ../../node_modules/adm-zip/util/errors.js
|
|
2230
|
-
var require_errors = __commonJS((exports) => {
|
|
2231
|
-
var errors = {
|
|
2232
|
-
INVALID_LOC: "Invalid LOC header (bad signature)",
|
|
2233
|
-
INVALID_CEN: "Invalid CEN header (bad signature)",
|
|
2234
|
-
INVALID_END: "Invalid END header (bad signature)",
|
|
2235
|
-
DESCRIPTOR_NOT_EXIST: "No descriptor present",
|
|
2236
|
-
DESCRIPTOR_UNKNOWN: "Unknown descriptor format",
|
|
2237
|
-
DESCRIPTOR_FAULTY: "Descriptor data is malformed",
|
|
2238
|
-
NO_DATA: "Nothing to decompress",
|
|
2239
|
-
BAD_CRC: "CRC32 checksum failed {0}",
|
|
2240
|
-
FILE_IN_THE_WAY: "There is a file in the way: {0}",
|
|
2241
|
-
UNKNOWN_METHOD: "Invalid/unsupported compression method",
|
|
2242
|
-
AVAIL_DATA: "inflate::Available inflate data did not terminate",
|
|
2243
|
-
INVALID_DISTANCE: "inflate::Invalid literal/length or distance code in fixed or dynamic block",
|
|
2244
|
-
TO_MANY_CODES: "inflate::Dynamic block code description: too many length or distance codes",
|
|
2245
|
-
INVALID_REPEAT_LEN: "inflate::Dynamic block code description: repeat more than specified lengths",
|
|
2246
|
-
INVALID_REPEAT_FIRST: "inflate::Dynamic block code description: repeat lengths with no first length",
|
|
2247
|
-
INCOMPLETE_CODES: "inflate::Dynamic block code description: code lengths codes incomplete",
|
|
2248
|
-
INVALID_DYN_DISTANCE: "inflate::Dynamic block code description: invalid distance code lengths",
|
|
2249
|
-
INVALID_CODES_LEN: "inflate::Dynamic block code description: invalid literal/length code lengths",
|
|
2250
|
-
INVALID_STORE_BLOCK: "inflate::Stored block length did not match one's complement",
|
|
2251
|
-
INVALID_BLOCK_TYPE: "inflate::Invalid block type (type == 3)",
|
|
2252
|
-
CANT_EXTRACT_FILE: "Could not extract the file",
|
|
2253
|
-
CANT_OVERRIDE: "Target file already exists",
|
|
2254
|
-
DISK_ENTRY_TOO_LARGE: "Number of disk entries is too large",
|
|
2255
|
-
NO_ZIP: "No zip file was loaded",
|
|
2256
|
-
NO_ENTRY: "Entry doesn't exist",
|
|
2257
|
-
DIRECTORY_CONTENT_ERROR: "A directory cannot have content",
|
|
2258
|
-
FILE_NOT_FOUND: 'File not found: "{0}"',
|
|
2259
|
-
NOT_IMPLEMENTED: "Not implemented",
|
|
2260
|
-
INVALID_FILENAME: "Invalid filename",
|
|
2261
|
-
INVALID_FORMAT: "Invalid or unsupported zip format. No END header found",
|
|
2262
|
-
INVALID_PASS_PARAM: "Incompatible password parameter",
|
|
2263
|
-
WRONG_PASSWORD: "Wrong Password",
|
|
2264
|
-
COMMENT_TOO_LONG: "Comment is too long",
|
|
2265
|
-
EXTRA_FIELD_PARSE_ERROR: "Extra field parsing error"
|
|
2266
|
-
};
|
|
2267
|
-
function E(message) {
|
|
2268
|
-
return function(...args) {
|
|
2269
|
-
if (args.length) {
|
|
2270
|
-
message = message.replace(/\{(\d)\}/g, (_, n) => args[n] || "");
|
|
2271
|
-
}
|
|
2272
|
-
return new Error("ADM-ZIP: " + message);
|
|
2273
|
-
};
|
|
2274
|
-
}
|
|
2275
|
-
for (const msg of Object.keys(errors)) {
|
|
2276
|
-
exports[msg] = E(errors[msg]);
|
|
2277
|
-
}
|
|
2278
|
-
});
|
|
2279
|
-
|
|
2280
|
-
// ../../node_modules/adm-zip/util/utils.js
|
|
2281
|
-
var require_utils = __commonJS((exports, module) => {
|
|
2282
|
-
var fsystem = __require("fs");
|
|
2283
|
-
var pth = __require("path");
|
|
2284
|
-
var Constants = require_constants();
|
|
2285
|
-
var Errors = require_errors();
|
|
2286
|
-
var isWin = typeof process === "object" && process.platform === "win32";
|
|
2287
|
-
var is_Obj = (obj) => typeof obj === "object" && obj !== null;
|
|
2288
|
-
var crcTable = new Uint32Array(256).map((t, c) => {
|
|
2289
|
-
for (let k = 0;k < 8; k++) {
|
|
2290
|
-
if ((c & 1) !== 0) {
|
|
2291
|
-
c = 3988292384 ^ c >>> 1;
|
|
2292
|
-
} else {
|
|
2293
|
-
c >>>= 1;
|
|
2294
|
-
}
|
|
2295
|
-
}
|
|
2296
|
-
return c >>> 0;
|
|
2297
|
-
});
|
|
2298
|
-
function Utils(opts) {
|
|
2299
|
-
this.sep = pth.sep;
|
|
2300
|
-
this.fs = fsystem;
|
|
2301
|
-
if (is_Obj(opts)) {
|
|
2302
|
-
if (is_Obj(opts.fs) && typeof opts.fs.statSync === "function") {
|
|
2303
|
-
this.fs = opts.fs;
|
|
2304
|
-
}
|
|
2305
|
-
}
|
|
2306
|
-
}
|
|
2307
|
-
module.exports = Utils;
|
|
2308
|
-
Utils.prototype.makeDir = function(folder) {
|
|
2309
|
-
const self = this;
|
|
2310
|
-
function mkdirSync(fpath) {
|
|
2311
|
-
let resolvedPath = fpath.split(self.sep)[0];
|
|
2312
|
-
fpath.split(self.sep).forEach(function(name) {
|
|
2313
|
-
if (!name || name.substr(-1, 1) === ":")
|
|
2314
|
-
return;
|
|
2315
|
-
resolvedPath += self.sep + name;
|
|
2316
|
-
var stat;
|
|
2317
|
-
try {
|
|
2318
|
-
stat = self.fs.statSync(resolvedPath);
|
|
2319
|
-
} catch (e) {
|
|
2320
|
-
if (e.message && e.message.startsWith("ENOENT")) {
|
|
2321
|
-
self.fs.mkdirSync(resolvedPath);
|
|
2322
|
-
} else {
|
|
2323
|
-
throw e;
|
|
2324
|
-
}
|
|
2325
|
-
}
|
|
2326
|
-
if (stat && stat.isFile())
|
|
2327
|
-
throw Errors.FILE_IN_THE_WAY(`"${resolvedPath}"`);
|
|
2328
|
-
});
|
|
2329
|
-
}
|
|
2330
|
-
mkdirSync(folder);
|
|
2331
|
-
};
|
|
2332
|
-
Utils.prototype.writeFileTo = function(path, content, overwrite, attr) {
|
|
2333
|
-
const self = this;
|
|
2334
|
-
if (self.fs.existsSync(path)) {
|
|
2335
|
-
if (!overwrite)
|
|
2336
|
-
return false;
|
|
2337
|
-
var stat = self.fs.statSync(path);
|
|
2338
|
-
if (stat.isDirectory()) {
|
|
2339
|
-
return false;
|
|
2340
|
-
}
|
|
2341
|
-
}
|
|
2342
|
-
var folder = pth.dirname(path);
|
|
2343
|
-
if (!self.fs.existsSync(folder)) {
|
|
2344
|
-
self.makeDir(folder);
|
|
2345
|
-
}
|
|
2346
|
-
var fd;
|
|
2347
|
-
try {
|
|
2348
|
-
fd = self.fs.openSync(path, "w", 438);
|
|
2349
|
-
} catch (e) {
|
|
2350
|
-
self.fs.chmodSync(path, 438);
|
|
2351
|
-
fd = self.fs.openSync(path, "w", 438);
|
|
2352
|
-
}
|
|
2353
|
-
if (fd) {
|
|
2354
|
-
try {
|
|
2355
|
-
self.fs.writeSync(fd, content, 0, content.length, 0);
|
|
2356
|
-
} finally {
|
|
2357
|
-
self.fs.closeSync(fd);
|
|
2358
|
-
}
|
|
2359
|
-
}
|
|
2360
|
-
self.fs.chmodSync(path, attr || 438);
|
|
2361
|
-
return true;
|
|
2362
|
-
};
|
|
2363
|
-
Utils.prototype.writeFileToAsync = function(path, content, overwrite, attr, callback) {
|
|
2364
|
-
if (typeof attr === "function") {
|
|
2365
|
-
callback = attr;
|
|
2366
|
-
attr = undefined;
|
|
2367
|
-
}
|
|
2368
|
-
const self = this;
|
|
2369
|
-
self.fs.exists(path, function(exist) {
|
|
2370
|
-
if (exist && !overwrite)
|
|
2371
|
-
return callback(false);
|
|
2372
|
-
self.fs.stat(path, function(err, stat) {
|
|
2373
|
-
if (exist && stat && stat.isDirectory()) {
|
|
2374
|
-
return callback(false);
|
|
2375
|
-
}
|
|
2376
|
-
var folder = pth.dirname(path);
|
|
2377
|
-
self.fs.exists(folder, function(exists) {
|
|
2378
|
-
if (!exists) {
|
|
2379
|
-
try {
|
|
2380
|
-
self.makeDir(folder);
|
|
2381
|
-
} catch (e) {
|
|
2382
|
-
return callback(false);
|
|
2383
|
-
}
|
|
2384
|
-
}
|
|
2385
|
-
const writeToFd = function(fd) {
|
|
2386
|
-
self.fs.write(fd, content, 0, content.length, 0, function(writeErr) {
|
|
2387
|
-
self.fs.close(fd, function() {
|
|
2388
|
-
if (writeErr)
|
|
2389
|
-
return callback(false);
|
|
2390
|
-
self.fs.chmod(path, attr || 438, function() {
|
|
2391
|
-
callback(true);
|
|
2392
|
-
});
|
|
2393
|
-
});
|
|
2394
|
-
});
|
|
2395
|
-
};
|
|
2396
|
-
self.fs.open(path, "w", 438, function(err2, fd) {
|
|
2397
|
-
if (err2) {
|
|
2398
|
-
self.fs.chmod(path, 438, function() {
|
|
2399
|
-
self.fs.open(path, "w", 438, function(retryErr, fd2) {
|
|
2400
|
-
if (retryErr || !fd2)
|
|
2401
|
-
return callback(false);
|
|
2402
|
-
writeToFd(fd2);
|
|
2403
|
-
});
|
|
2404
|
-
});
|
|
2405
|
-
} else if (fd) {
|
|
2406
|
-
writeToFd(fd);
|
|
2407
|
-
} else {
|
|
2408
|
-
callback(false);
|
|
2409
|
-
}
|
|
2410
|
-
});
|
|
2411
|
-
});
|
|
2412
|
-
});
|
|
2413
|
-
});
|
|
2414
|
-
};
|
|
2415
|
-
Utils.prototype.findFiles = function(path) {
|
|
2416
|
-
const self = this;
|
|
2417
|
-
function findSync(dir, pattern, recursive, visited) {
|
|
2418
|
-
if (typeof pattern === "boolean") {
|
|
2419
|
-
recursive = pattern;
|
|
2420
|
-
pattern = undefined;
|
|
2421
|
-
}
|
|
2422
|
-
let files = [];
|
|
2423
|
-
self.fs.readdirSync(dir).forEach(function(file) {
|
|
2424
|
-
const path2 = pth.join(dir, file);
|
|
2425
|
-
const stat = self.fs.statSync(path2);
|
|
2426
|
-
if (!pattern || pattern.test(path2)) {
|
|
2427
|
-
files.push(pth.normalize(path2) + (stat.isDirectory() ? self.sep : ""));
|
|
2428
|
-
}
|
|
2429
|
-
if (stat.isDirectory() && recursive) {
|
|
2430
|
-
const realDir = self.fs.realpathSync(path2);
|
|
2431
|
-
if (!visited.has(realDir)) {
|
|
2432
|
-
visited.add(realDir);
|
|
2433
|
-
files = files.concat(findSync(path2, pattern, recursive, visited));
|
|
2434
|
-
}
|
|
2435
|
-
}
|
|
2436
|
-
});
|
|
2437
|
-
return files;
|
|
2438
|
-
}
|
|
2439
|
-
return findSync(path, undefined, true, new Set([self.fs.realpathSync(path)]));
|
|
2440
|
-
};
|
|
2441
|
-
Utils.prototype.findFilesAsync = function(dir, cb) {
|
|
2442
|
-
const self = this;
|
|
2443
|
-
const results = [];
|
|
2444
|
-
let finished = false;
|
|
2445
|
-
const finish = function(err) {
|
|
2446
|
-
if (finished)
|
|
2447
|
-
return;
|
|
2448
|
-
finished = true;
|
|
2449
|
-
cb(err, err ? undefined : results);
|
|
2450
|
-
};
|
|
2451
|
-
const walk = function(dir2, visited, done) {
|
|
2452
|
-
self.fs.readdir(dir2, function(err, list) {
|
|
2453
|
-
if (err)
|
|
2454
|
-
return done(err);
|
|
2455
|
-
let pending = list.length;
|
|
2456
|
-
if (!pending)
|
|
2457
|
-
return done();
|
|
2458
|
-
list.forEach(function(name) {
|
|
2459
|
-
const file = pth.join(dir2, name);
|
|
2460
|
-
self.fs.stat(file, function(err2, stat) {
|
|
2461
|
-
if (err2)
|
|
2462
|
-
return done(err2);
|
|
2463
|
-
if (!stat) {
|
|
2464
|
-
if (!--pending)
|
|
2465
|
-
done();
|
|
2466
|
-
return;
|
|
2467
|
-
}
|
|
2468
|
-
results.push(pth.normalize(file) + (stat.isDirectory() ? self.sep : ""));
|
|
2469
|
-
if (!stat.isDirectory()) {
|
|
2470
|
-
if (!--pending)
|
|
2471
|
-
done();
|
|
2472
|
-
return;
|
|
2473
|
-
}
|
|
2474
|
-
self.fs.realpath(file, function(err3, realDir) {
|
|
2475
|
-
if (err3)
|
|
2476
|
-
return done(err3);
|
|
2477
|
-
if (visited.has(realDir)) {
|
|
2478
|
-
if (!--pending)
|
|
2479
|
-
done();
|
|
2480
|
-
return;
|
|
2481
|
-
}
|
|
2482
|
-
visited.add(realDir);
|
|
2483
|
-
walk(file, visited, function(err4) {
|
|
2484
|
-
if (err4)
|
|
2485
|
-
return done(err4);
|
|
2486
|
-
if (!--pending)
|
|
2487
|
-
done();
|
|
2488
|
-
});
|
|
2489
|
-
});
|
|
2490
|
-
});
|
|
2491
|
-
});
|
|
2492
|
-
});
|
|
2493
|
-
};
|
|
2494
|
-
self.fs.realpath(dir, function(err, realDir) {
|
|
2495
|
-
if (err)
|
|
2496
|
-
return finish(err);
|
|
2497
|
-
walk(dir, new Set([realDir]), finish);
|
|
2498
|
-
});
|
|
2499
|
-
};
|
|
2500
|
-
Utils.prototype.getAttributes = function() {};
|
|
2501
|
-
Utils.prototype.setAttributes = function() {};
|
|
2502
|
-
Utils.crc32update = function(crc, byte) {
|
|
2503
|
-
return crcTable[(crc ^ byte) & 255] ^ crc >>> 8;
|
|
2504
|
-
};
|
|
2505
|
-
Utils.crc32 = function(buf) {
|
|
2506
|
-
if (typeof buf === "string") {
|
|
2507
|
-
buf = Buffer.from(buf, "utf8");
|
|
2508
|
-
}
|
|
2509
|
-
let len = buf.length;
|
|
2510
|
-
let crc = ~0;
|
|
2511
|
-
for (let off = 0;off < len; )
|
|
2512
|
-
crc = Utils.crc32update(crc, buf[off++]);
|
|
2513
|
-
return ~crc >>> 0;
|
|
2514
|
-
};
|
|
2515
|
-
Utils.methodToString = function(method) {
|
|
2516
|
-
switch (method) {
|
|
2517
|
-
case Constants.STORED:
|
|
2518
|
-
return "STORED (" + method + ")";
|
|
2519
|
-
case Constants.DEFLATED:
|
|
2520
|
-
return "DEFLATED (" + method + ")";
|
|
2521
|
-
default:
|
|
2522
|
-
return "UNSUPPORTED (" + method + ")";
|
|
2523
|
-
}
|
|
2524
|
-
};
|
|
2525
|
-
Utils.canonical = function(path) {
|
|
2526
|
-
if (!path)
|
|
2527
|
-
return "";
|
|
2528
|
-
const safeSuffix = pth.posix.normalize("/" + path.split("\\").join("/"));
|
|
2529
|
-
return pth.join(".", safeSuffix);
|
|
2530
|
-
};
|
|
2531
|
-
Utils.zipnamefix = function(path) {
|
|
2532
|
-
if (!path)
|
|
2533
|
-
return "";
|
|
2534
|
-
const safeSuffix = pth.posix.normalize("/" + path.split("\\").join("/"));
|
|
2535
|
-
return pth.posix.join(".", safeSuffix);
|
|
2536
|
-
};
|
|
2537
|
-
Utils.findLast = function(arr, callback) {
|
|
2538
|
-
if (!Array.isArray(arr))
|
|
2539
|
-
throw new TypeError("arr is not array");
|
|
2540
|
-
const len = arr.length >>> 0;
|
|
2541
|
-
for (let i = len - 1;i >= 0; i--) {
|
|
2542
|
-
if (callback(arr[i], i, arr)) {
|
|
2543
|
-
return arr[i];
|
|
2544
|
-
}
|
|
2545
|
-
}
|
|
2546
|
-
return;
|
|
2547
|
-
};
|
|
2548
|
-
Utils.sanitize = function(prefix, name) {
|
|
2549
|
-
prefix = pth.resolve(pth.normalize(prefix));
|
|
2550
|
-
var parts = name.split("/");
|
|
2551
|
-
for (var i = 0, l = parts.length;i < l; i++) {
|
|
2552
|
-
var path = pth.normalize(pth.join(prefix, parts.slice(i, l).join(pth.sep)));
|
|
2553
|
-
if (path === prefix || path.startsWith(prefix + pth.sep)) {
|
|
2554
|
-
return path;
|
|
2555
|
-
}
|
|
2556
|
-
}
|
|
2557
|
-
return pth.normalize(pth.join(prefix, pth.basename(name)));
|
|
2558
|
-
};
|
|
2559
|
-
Utils.toBuffer = function toBuffer(input, encoder) {
|
|
2560
|
-
if (Buffer.isBuffer(input)) {
|
|
2561
|
-
return input;
|
|
2562
|
-
} else if (input instanceof Uint8Array) {
|
|
2563
|
-
return Buffer.from(input);
|
|
2564
|
-
} else {
|
|
2565
|
-
return typeof input === "string" ? encoder(input) : Buffer.alloc(0);
|
|
2566
|
-
}
|
|
2567
|
-
};
|
|
2568
|
-
Utils.readBigUInt64LE = function(buffer, index) {
|
|
2569
|
-
const lo = buffer.readUInt32LE(index);
|
|
2570
|
-
const hi = buffer.readUInt32LE(index + 4);
|
|
2571
|
-
return hi * 4294967296 + lo;
|
|
2572
|
-
};
|
|
2573
|
-
Utils.writeBigUInt64LE = function(buffer, value, index) {
|
|
2574
|
-
const lo = value >>> 0;
|
|
2575
|
-
const hi = Math.floor(value / 4294967296) >>> 0;
|
|
2576
|
-
buffer.writeUInt32LE(lo, index);
|
|
2577
|
-
buffer.writeUInt32LE(hi, index + 4);
|
|
2578
|
-
};
|
|
2579
|
-
Utils.fromDOS2Date = function(val) {
|
|
2580
|
-
return new Date((val >> 25 & 127) + 1980, Math.max((val >> 21 & 15) - 1, 0), Math.max(val >> 16 & 31, 1), val >> 11 & 31, val >> 5 & 63, (val & 31) << 1);
|
|
2581
|
-
};
|
|
2582
|
-
Utils.fromDate2DOS = function(val) {
|
|
2583
|
-
let date = 0;
|
|
2584
|
-
let time = 0;
|
|
2585
|
-
if (val.getFullYear() > 1979) {
|
|
2586
|
-
date = (val.getFullYear() - 1980 & 127) << 9 | val.getMonth() + 1 << 5 | val.getDate();
|
|
2587
|
-
time = val.getHours() << 11 | val.getMinutes() << 5 | val.getSeconds() >> 1;
|
|
2588
|
-
}
|
|
2589
|
-
return date << 16 | time;
|
|
2590
|
-
};
|
|
2591
|
-
Utils.isWin = isWin;
|
|
2592
|
-
Utils.crcTable = crcTable;
|
|
2593
|
-
});
|
|
2594
|
-
|
|
2595
|
-
// ../../node_modules/adm-zip/util/fattr.js
|
|
2596
|
-
var require_fattr = __commonJS((exports, module) => {
|
|
2597
|
-
var pth = __require("path");
|
|
2598
|
-
module.exports = function(path, { fs: fs2 }) {
|
|
2599
|
-
var _path = path || "", _obj = newAttr(), _stat = null;
|
|
2600
|
-
function newAttr() {
|
|
2601
|
-
return {
|
|
2602
|
-
directory: false,
|
|
2603
|
-
readonly: false,
|
|
2604
|
-
hidden: false,
|
|
2605
|
-
executable: false,
|
|
2606
|
-
mtime: 0,
|
|
2607
|
-
atime: 0
|
|
2608
|
-
};
|
|
2609
|
-
}
|
|
2610
|
-
if (_path && fs2.existsSync(_path)) {
|
|
2611
|
-
_stat = fs2.statSync(_path);
|
|
2612
|
-
_obj.directory = _stat.isDirectory();
|
|
2613
|
-
_obj.mtime = _stat.mtime;
|
|
2614
|
-
_obj.atime = _stat.atime;
|
|
2615
|
-
_obj.executable = (73 & _stat.mode) !== 0;
|
|
2616
|
-
_obj.readonly = (128 & _stat.mode) === 0;
|
|
2617
|
-
_obj.hidden = pth.basename(_path)[0] === ".";
|
|
2618
|
-
} else {
|
|
2619
|
-
console.warn("Invalid path: " + _path);
|
|
2620
|
-
}
|
|
2621
|
-
return {
|
|
2622
|
-
get directory() {
|
|
2623
|
-
return _obj.directory;
|
|
2624
|
-
},
|
|
2625
|
-
get readOnly() {
|
|
2626
|
-
return _obj.readonly;
|
|
2627
|
-
},
|
|
2628
|
-
get hidden() {
|
|
2629
|
-
return _obj.hidden;
|
|
2630
|
-
},
|
|
2631
|
-
get mtime() {
|
|
2632
|
-
return _obj.mtime;
|
|
2633
|
-
},
|
|
2634
|
-
get atime() {
|
|
2635
|
-
return _obj.atime;
|
|
2636
|
-
},
|
|
2637
|
-
get executable() {
|
|
2638
|
-
return _obj.executable;
|
|
2639
|
-
},
|
|
2640
|
-
decodeAttributes: function() {},
|
|
2641
|
-
encodeAttributes: function() {},
|
|
2642
|
-
toJSON: function() {
|
|
2643
|
-
return {
|
|
2644
|
-
path: _path,
|
|
2645
|
-
isDirectory: _obj.directory,
|
|
2646
|
-
isReadOnly: _obj.readonly,
|
|
2647
|
-
isHidden: _obj.hidden,
|
|
2648
|
-
isExecutable: _obj.executable,
|
|
2649
|
-
mTime: _obj.mtime,
|
|
2650
|
-
aTime: _obj.atime
|
|
2651
|
-
};
|
|
2652
|
-
},
|
|
2653
|
-
toString: function() {
|
|
2654
|
-
return JSON.stringify(this.toJSON(), null, "\t");
|
|
2655
|
-
}
|
|
2656
|
-
};
|
|
2657
|
-
};
|
|
2658
|
-
});
|
|
2659
|
-
|
|
2660
|
-
// ../../node_modules/adm-zip/util/decoder.js
|
|
2661
|
-
var require_decoder = __commonJS((exports, module) => {
|
|
2662
|
-
module.exports = {
|
|
2663
|
-
efs: true,
|
|
2664
|
-
encode: (data) => Buffer.from(data, "utf8"),
|
|
2665
|
-
decode: (data) => data.toString("utf8")
|
|
2666
|
-
};
|
|
2667
|
-
});
|
|
2668
|
-
|
|
2669
|
-
// ../../node_modules/adm-zip/util/index.js
|
|
2670
|
-
var require_util = __commonJS((exports, module) => {
|
|
2671
|
-
module.exports = require_utils();
|
|
2672
|
-
module.exports.Constants = require_constants();
|
|
2673
|
-
module.exports.Errors = require_errors();
|
|
2674
|
-
module.exports.FileAttr = require_fattr();
|
|
2675
|
-
module.exports.decoder = require_decoder();
|
|
2676
|
-
});
|
|
2677
|
-
|
|
2678
|
-
// ../../node_modules/adm-zip/headers/entryHeader.js
|
|
2679
|
-
var require_entryHeader = __commonJS((exports, module) => {
|
|
2680
|
-
var Utils = require_util();
|
|
2681
|
-
var Constants = Utils.Constants;
|
|
2682
|
-
module.exports = function() {
|
|
2683
|
-
var _verMade = 20, _version = 10, _flags = 0, _method = 0, _time = 0, _crc = 0, _compressedSize = 0, _size = 0, _fnameLen = 0, _extraLen = 0, _comLen = 0, _diskStart = 0, _inattr = 0, _attr = 0, _offset = 0;
|
|
2684
|
-
_verMade |= Utils.isWin ? 2560 : 768;
|
|
2685
|
-
_flags |= Constants.FLG_EFS;
|
|
2686
|
-
const _localHeader = {
|
|
2687
|
-
extraLen: 0
|
|
2688
|
-
};
|
|
2689
|
-
const uint32 = (val) => Math.max(0, val) >>> 0;
|
|
2690
|
-
const uint16 = (val) => Math.max(0, val) & 65535;
|
|
2691
|
-
const uint8 = (val) => Math.max(0, val) & 255;
|
|
2692
|
-
_time = Utils.fromDate2DOS(new Date);
|
|
2693
|
-
return {
|
|
2694
|
-
get made() {
|
|
2695
|
-
return _verMade;
|
|
2696
|
-
},
|
|
2697
|
-
set made(val) {
|
|
2698
|
-
_verMade = val;
|
|
2699
|
-
},
|
|
2700
|
-
get version() {
|
|
2701
|
-
return _version;
|
|
2702
|
-
},
|
|
2703
|
-
set version(val) {
|
|
2704
|
-
_version = val;
|
|
2705
|
-
},
|
|
2706
|
-
get flags() {
|
|
2707
|
-
return _flags;
|
|
2708
|
-
},
|
|
2709
|
-
set flags(val) {
|
|
2710
|
-
_flags = val;
|
|
2711
|
-
},
|
|
2712
|
-
get flags_efs() {
|
|
2713
|
-
return (_flags & Constants.FLG_EFS) > 0;
|
|
2714
|
-
},
|
|
2715
|
-
set flags_efs(val) {
|
|
2716
|
-
if (val) {
|
|
2717
|
-
_flags |= Constants.FLG_EFS;
|
|
2718
|
-
} else {
|
|
2719
|
-
_flags &= ~Constants.FLG_EFS;
|
|
2720
|
-
}
|
|
2721
|
-
},
|
|
2722
|
-
get flags_desc() {
|
|
2723
|
-
return (_flags & Constants.FLG_DESC) > 0;
|
|
2724
|
-
},
|
|
2725
|
-
set flags_desc(val) {
|
|
2726
|
-
if (val) {
|
|
2727
|
-
_flags |= Constants.FLG_DESC;
|
|
2728
|
-
} else {
|
|
2729
|
-
_flags &= ~Constants.FLG_DESC;
|
|
2730
|
-
}
|
|
2731
|
-
},
|
|
2732
|
-
get method() {
|
|
2733
|
-
return _method;
|
|
2734
|
-
},
|
|
2735
|
-
set method(val) {
|
|
2736
|
-
switch (val) {
|
|
2737
|
-
case Constants.STORED:
|
|
2738
|
-
this.version = 10;
|
|
2739
|
-
break;
|
|
2740
|
-
case Constants.DEFLATED:
|
|
2741
|
-
default:
|
|
2742
|
-
this.version = 20;
|
|
2743
|
-
}
|
|
2744
|
-
_method = val;
|
|
2745
|
-
},
|
|
2746
|
-
get time() {
|
|
2747
|
-
return Utils.fromDOS2Date(this.timeval);
|
|
2748
|
-
},
|
|
2749
|
-
set time(val) {
|
|
2750
|
-
val = new Date(val);
|
|
2751
|
-
this.timeval = Utils.fromDate2DOS(val);
|
|
2752
|
-
},
|
|
2753
|
-
get timeval() {
|
|
2754
|
-
return _time;
|
|
2755
|
-
},
|
|
2756
|
-
set timeval(val) {
|
|
2757
|
-
_time = uint32(val);
|
|
2758
|
-
},
|
|
2759
|
-
get timeHighByte() {
|
|
2760
|
-
return uint8(_time >>> 8);
|
|
2761
|
-
},
|
|
2762
|
-
get crc() {
|
|
2763
|
-
return _crc;
|
|
2764
|
-
},
|
|
2765
|
-
set crc(val) {
|
|
2766
|
-
_crc = uint32(val);
|
|
2767
|
-
},
|
|
2768
|
-
get compressedSize() {
|
|
2769
|
-
return _compressedSize;
|
|
2770
|
-
},
|
|
2771
|
-
set compressedSize(val) {
|
|
2772
|
-
_compressedSize = uint32(val);
|
|
2773
|
-
},
|
|
2774
|
-
get size() {
|
|
2775
|
-
return _size;
|
|
2776
|
-
},
|
|
2777
|
-
set size(val) {
|
|
2778
|
-
_size = uint32(val);
|
|
2779
|
-
},
|
|
2780
|
-
get fileNameLength() {
|
|
2781
|
-
return _fnameLen;
|
|
2782
|
-
},
|
|
2783
|
-
set fileNameLength(val) {
|
|
2784
|
-
_fnameLen = val;
|
|
2785
|
-
},
|
|
2786
|
-
get extraLength() {
|
|
2787
|
-
return _extraLen;
|
|
2788
|
-
},
|
|
2789
|
-
set extraLength(val) {
|
|
2790
|
-
_extraLen = val;
|
|
2791
|
-
},
|
|
2792
|
-
get extraLocalLength() {
|
|
2793
|
-
return _localHeader.extraLen;
|
|
2794
|
-
},
|
|
2795
|
-
set extraLocalLength(val) {
|
|
2796
|
-
_localHeader.extraLen = val;
|
|
2797
|
-
},
|
|
2798
|
-
get commentLength() {
|
|
2799
|
-
return _comLen;
|
|
2800
|
-
},
|
|
2801
|
-
set commentLength(val) {
|
|
2802
|
-
_comLen = val;
|
|
2803
|
-
},
|
|
2804
|
-
get diskNumStart() {
|
|
2805
|
-
return _diskStart;
|
|
2806
|
-
},
|
|
2807
|
-
set diskNumStart(val) {
|
|
2808
|
-
_diskStart = uint32(val);
|
|
2809
|
-
},
|
|
2810
|
-
get inAttr() {
|
|
2811
|
-
return _inattr;
|
|
2812
|
-
},
|
|
2813
|
-
set inAttr(val) {
|
|
2814
|
-
_inattr = uint32(val);
|
|
2815
|
-
},
|
|
2816
|
-
get attr() {
|
|
2817
|
-
return _attr;
|
|
2818
|
-
},
|
|
2819
|
-
set attr(val) {
|
|
2820
|
-
_attr = uint32(val);
|
|
2821
|
-
},
|
|
2822
|
-
get fileAttr() {
|
|
2823
|
-
return (_attr || 0) >> 16 & 4095;
|
|
2824
|
-
},
|
|
2825
|
-
get offset() {
|
|
2826
|
-
return _offset;
|
|
2827
|
-
},
|
|
2828
|
-
set offset(val) {
|
|
2829
|
-
_offset = uint32(val);
|
|
2830
|
-
},
|
|
2831
|
-
get encrypted() {
|
|
2832
|
-
return (_flags & Constants.FLG_ENC) === Constants.FLG_ENC;
|
|
2833
|
-
},
|
|
2834
|
-
get centralHeaderSize() {
|
|
2835
|
-
return Constants.CENHDR + _fnameLen + _extraLen + _comLen;
|
|
2836
|
-
},
|
|
2837
|
-
get realDataOffset() {
|
|
2838
|
-
return _offset + Constants.LOCHDR + _localHeader.fnameLen + _localHeader.extraLen;
|
|
2839
|
-
},
|
|
2840
|
-
get localHeader() {
|
|
2841
|
-
return _localHeader;
|
|
2842
|
-
},
|
|
2843
|
-
loadLocalHeaderFromBinary: function(input) {
|
|
2844
|
-
var data = input.slice(_offset, _offset + Constants.LOCHDR);
|
|
2845
|
-
if (data.readUInt32LE(0) !== Constants.LOCSIG) {
|
|
2846
|
-
throw Utils.Errors.INVALID_LOC();
|
|
2847
|
-
}
|
|
2848
|
-
_localHeader.version = data.readUInt16LE(Constants.LOCVER);
|
|
2849
|
-
_localHeader.flags = data.readUInt16LE(Constants.LOCFLG);
|
|
2850
|
-
_localHeader.flags_desc = (_localHeader.flags & Constants.FLG_DESC) > 0;
|
|
2851
|
-
_localHeader.method = data.readUInt16LE(Constants.LOCHOW);
|
|
2852
|
-
_localHeader.time = data.readUInt32LE(Constants.LOCTIM);
|
|
2853
|
-
_localHeader.crc = data.readUInt32LE(Constants.LOCCRC);
|
|
2854
|
-
_localHeader.compressedSize = data.readUInt32LE(Constants.LOCSIZ);
|
|
2855
|
-
_localHeader.size = data.readUInt32LE(Constants.LOCLEN);
|
|
2856
|
-
_localHeader.fnameLen = data.readUInt16LE(Constants.LOCNAM);
|
|
2857
|
-
_localHeader.extraLen = data.readUInt16LE(Constants.LOCEXT);
|
|
2858
|
-
const extraStart = _offset + Constants.LOCHDR + _localHeader.fnameLen;
|
|
2859
|
-
const extraEnd = extraStart + _localHeader.extraLen;
|
|
2860
|
-
return input.slice(extraStart, extraEnd);
|
|
2861
|
-
},
|
|
2862
|
-
loadFromBinary: function(data) {
|
|
2863
|
-
if (data.length !== Constants.CENHDR || data.readUInt32LE(0) !== Constants.CENSIG) {
|
|
2864
|
-
throw Utils.Errors.INVALID_CEN();
|
|
2865
|
-
}
|
|
2866
|
-
_verMade = data.readUInt16LE(Constants.CENVEM);
|
|
2867
|
-
_version = data.readUInt16LE(Constants.CENVER);
|
|
2868
|
-
_flags = data.readUInt16LE(Constants.CENFLG);
|
|
2869
|
-
_method = data.readUInt16LE(Constants.CENHOW);
|
|
2870
|
-
_time = data.readUInt32LE(Constants.CENTIM);
|
|
2871
|
-
_crc = data.readUInt32LE(Constants.CENCRC);
|
|
2872
|
-
_compressedSize = data.readUInt32LE(Constants.CENSIZ);
|
|
2873
|
-
_size = data.readUInt32LE(Constants.CENLEN);
|
|
2874
|
-
_fnameLen = data.readUInt16LE(Constants.CENNAM);
|
|
2875
|
-
_extraLen = data.readUInt16LE(Constants.CENEXT);
|
|
2876
|
-
_comLen = data.readUInt16LE(Constants.CENCOM);
|
|
2877
|
-
_diskStart = data.readUInt16LE(Constants.CENDSK);
|
|
2878
|
-
_inattr = data.readUInt16LE(Constants.CENATT);
|
|
2879
|
-
_attr = data.readUInt32LE(Constants.CENATX);
|
|
2880
|
-
_offset = data.readUInt32LE(Constants.CENOFF);
|
|
2881
|
-
},
|
|
2882
|
-
localHeaderToBinary: function() {
|
|
2883
|
-
var data = Buffer.alloc(Constants.LOCHDR);
|
|
2884
|
-
data.writeUInt32LE(Constants.LOCSIG, 0);
|
|
2885
|
-
data.writeUInt16LE(_version, Constants.LOCVER);
|
|
2886
|
-
data.writeUInt16LE(_flags & ~Constants.FLG_DESC, Constants.LOCFLG);
|
|
2887
|
-
data.writeUInt16LE(_method, Constants.LOCHOW);
|
|
2888
|
-
data.writeUInt32LE(_time, Constants.LOCTIM);
|
|
2889
|
-
data.writeUInt32LE(_crc, Constants.LOCCRC);
|
|
2890
|
-
data.writeUInt32LE(_compressedSize, Constants.LOCSIZ);
|
|
2891
|
-
data.writeUInt32LE(_size, Constants.LOCLEN);
|
|
2892
|
-
data.writeUInt16LE(_fnameLen, Constants.LOCNAM);
|
|
2893
|
-
data.writeUInt16LE(_localHeader.extraLen, Constants.LOCEXT);
|
|
2894
|
-
return data;
|
|
2895
|
-
},
|
|
2896
|
-
centralHeaderToBinary: function() {
|
|
2897
|
-
var data = Buffer.alloc(Constants.CENHDR + _fnameLen + _extraLen + _comLen);
|
|
2898
|
-
data.writeUInt32LE(Constants.CENSIG, 0);
|
|
2899
|
-
data.writeUInt16LE(_verMade, Constants.CENVEM);
|
|
2900
|
-
data.writeUInt16LE(_version, Constants.CENVER);
|
|
2901
|
-
data.writeUInt16LE(_flags & ~Constants.FLG_DESC, Constants.CENFLG);
|
|
2902
|
-
data.writeUInt16LE(_method, Constants.CENHOW);
|
|
2903
|
-
data.writeUInt32LE(_time, Constants.CENTIM);
|
|
2904
|
-
data.writeUInt32LE(_crc, Constants.CENCRC);
|
|
2905
|
-
data.writeUInt32LE(_compressedSize, Constants.CENSIZ);
|
|
2906
|
-
data.writeUInt32LE(_size, Constants.CENLEN);
|
|
2907
|
-
data.writeUInt16LE(_fnameLen, Constants.CENNAM);
|
|
2908
|
-
data.writeUInt16LE(_extraLen, Constants.CENEXT);
|
|
2909
|
-
data.writeUInt16LE(_comLen, Constants.CENCOM);
|
|
2910
|
-
data.writeUInt16LE(_diskStart, Constants.CENDSK);
|
|
2911
|
-
data.writeUInt16LE(_inattr, Constants.CENATT);
|
|
2912
|
-
data.writeUInt32LE(_attr, Constants.CENATX);
|
|
2913
|
-
data.writeUInt32LE(_offset, Constants.CENOFF);
|
|
2914
|
-
return data;
|
|
2915
|
-
},
|
|
2916
|
-
toJSON: function() {
|
|
2917
|
-
const bytes = function(nr) {
|
|
2918
|
-
return nr + " bytes";
|
|
2919
|
-
};
|
|
2920
|
-
return {
|
|
2921
|
-
made: _verMade,
|
|
2922
|
-
version: _version,
|
|
2923
|
-
flags: _flags,
|
|
2924
|
-
method: Utils.methodToString(_method),
|
|
2925
|
-
time: this.time,
|
|
2926
|
-
crc: "0x" + _crc.toString(16).toUpperCase(),
|
|
2927
|
-
compressedSize: bytes(_compressedSize),
|
|
2928
|
-
size: bytes(_size),
|
|
2929
|
-
fileNameLength: bytes(_fnameLen),
|
|
2930
|
-
extraLength: bytes(_extraLen),
|
|
2931
|
-
commentLength: bytes(_comLen),
|
|
2932
|
-
diskNumStart: _diskStart,
|
|
2933
|
-
inAttr: _inattr,
|
|
2934
|
-
attr: _attr,
|
|
2935
|
-
offset: _offset,
|
|
2936
|
-
centralHeaderSize: bytes(Constants.CENHDR + _fnameLen + _extraLen + _comLen)
|
|
2937
|
-
};
|
|
2938
|
-
},
|
|
2939
|
-
toString: function() {
|
|
2940
|
-
return JSON.stringify(this.toJSON(), null, "\t");
|
|
2941
|
-
}
|
|
2942
|
-
};
|
|
2943
|
-
};
|
|
2944
|
-
});
|
|
2945
|
-
|
|
2946
|
-
// ../../node_modules/adm-zip/headers/mainHeader.js
|
|
2947
|
-
var require_mainHeader = __commonJS((exports, module) => {
|
|
2948
|
-
var Utils = require_util();
|
|
2949
|
-
var Constants = Utils.Constants;
|
|
2950
|
-
module.exports = function() {
|
|
2951
|
-
var _volumeEntries = 0, _totalEntries = 0, _size = 0, _offset = 0, _commentLength = 0;
|
|
2952
|
-
const needsZip64 = () => _volumeEntries > Constants.EF_ZIP64_OR_16 || _totalEntries > Constants.EF_ZIP64_OR_16 || _size > Constants.EF_ZIP64_OR_32 || _offset > Constants.EF_ZIP64_OR_32;
|
|
2953
|
-
return {
|
|
2954
|
-
get diskEntries() {
|
|
2955
|
-
return _volumeEntries;
|
|
2956
|
-
},
|
|
2957
|
-
set diskEntries(val) {
|
|
2958
|
-
_volumeEntries = _totalEntries = val;
|
|
2959
|
-
},
|
|
2960
|
-
get totalEntries() {
|
|
2961
|
-
return _totalEntries;
|
|
2962
|
-
},
|
|
2963
|
-
set totalEntries(val) {
|
|
2964
|
-
_totalEntries = _volumeEntries = val;
|
|
2965
|
-
},
|
|
2966
|
-
get size() {
|
|
2967
|
-
return _size;
|
|
2968
|
-
},
|
|
2969
|
-
set size(val) {
|
|
2970
|
-
_size = val;
|
|
2971
|
-
},
|
|
2972
|
-
get offset() {
|
|
2973
|
-
return _offset;
|
|
2974
|
-
},
|
|
2975
|
-
set offset(val) {
|
|
2976
|
-
_offset = val;
|
|
2977
|
-
},
|
|
2978
|
-
get commentLength() {
|
|
2979
|
-
return _commentLength;
|
|
2980
|
-
},
|
|
2981
|
-
set commentLength(val) {
|
|
2982
|
-
_commentLength = val;
|
|
2983
|
-
},
|
|
2984
|
-
get mainHeaderSize() {
|
|
2985
|
-
return (needsZip64() ? Constants.ZIP64HDR + Constants.END64HDR : 0) + Constants.ENDHDR + _commentLength;
|
|
2986
|
-
},
|
|
2987
|
-
loadFromBinary: function(data) {
|
|
2988
|
-
if ((data.length !== Constants.ENDHDR || data.readUInt32LE(0) !== Constants.ENDSIG) && (data.length < Constants.ZIP64HDR || data.readUInt32LE(0) !== Constants.ZIP64SIG)) {
|
|
2989
|
-
throw Utils.Errors.INVALID_END();
|
|
2990
|
-
}
|
|
2991
|
-
if (data.readUInt32LE(0) === Constants.ENDSIG) {
|
|
2992
|
-
_volumeEntries = data.readUInt16LE(Constants.ENDSUB);
|
|
2993
|
-
_totalEntries = data.readUInt16LE(Constants.ENDTOT);
|
|
2994
|
-
_size = data.readUInt32LE(Constants.ENDSIZ);
|
|
2995
|
-
_offset = data.readUInt32LE(Constants.ENDOFF);
|
|
2996
|
-
_commentLength = data.readUInt16LE(Constants.ENDCOM);
|
|
2997
|
-
} else {
|
|
2998
|
-
_volumeEntries = Utils.readBigUInt64LE(data, Constants.ZIP64SUB);
|
|
2999
|
-
_totalEntries = Utils.readBigUInt64LE(data, Constants.ZIP64TOT);
|
|
3000
|
-
_size = Utils.readBigUInt64LE(data, Constants.ZIP64SIZB);
|
|
3001
|
-
_offset = Utils.readBigUInt64LE(data, Constants.ZIP64OFF);
|
|
3002
|
-
_commentLength = 0;
|
|
3003
|
-
}
|
|
3004
|
-
},
|
|
3005
|
-
toBinary: function() {
|
|
3006
|
-
if (!needsZip64()) {
|
|
3007
|
-
var b = Buffer.alloc(Constants.ENDHDR + _commentLength);
|
|
3008
|
-
b.writeUInt32LE(Constants.ENDSIG, 0);
|
|
3009
|
-
b.writeUInt32LE(0, 4);
|
|
3010
|
-
b.writeUInt16LE(_volumeEntries, Constants.ENDSUB);
|
|
3011
|
-
b.writeUInt16LE(_totalEntries, Constants.ENDTOT);
|
|
3012
|
-
b.writeUInt32LE(_size, Constants.ENDSIZ);
|
|
3013
|
-
b.writeUInt32LE(_offset, Constants.ENDOFF);
|
|
3014
|
-
b.writeUInt16LE(_commentLength, Constants.ENDCOM);
|
|
3015
|
-
b.fill(" ", Constants.ENDHDR);
|
|
3016
|
-
return b;
|
|
3017
|
-
}
|
|
3018
|
-
var b = Buffer.alloc(this.mainHeaderSize);
|
|
3019
|
-
let offset = 0;
|
|
3020
|
-
b.writeUInt32LE(Constants.ZIP64SIG, offset);
|
|
3021
|
-
Utils.writeBigUInt64LE(b, Constants.ZIP64HDR - Constants.ZIP64LEAD, offset + Constants.ZIP64SIZE);
|
|
3022
|
-
b.writeUInt16LE(45, offset + Constants.ZIP64VEM);
|
|
3023
|
-
b.writeUInt16LE(45, offset + Constants.ZIP64VER);
|
|
3024
|
-
b.writeUInt32LE(0, offset + Constants.ZIP64DSK);
|
|
3025
|
-
b.writeUInt32LE(0, offset + Constants.ZIP64DSKDIR);
|
|
3026
|
-
Utils.writeBigUInt64LE(b, _volumeEntries, offset + Constants.ZIP64SUB);
|
|
3027
|
-
Utils.writeBigUInt64LE(b, _totalEntries, offset + Constants.ZIP64TOT);
|
|
3028
|
-
Utils.writeBigUInt64LE(b, _size, offset + Constants.ZIP64SIZB);
|
|
3029
|
-
Utils.writeBigUInt64LE(b, _offset, offset + Constants.ZIP64OFF);
|
|
3030
|
-
const zip64EndOffset = _offset + _size;
|
|
3031
|
-
offset += Constants.ZIP64HDR;
|
|
3032
|
-
b.writeUInt32LE(Constants.END64SIG, offset);
|
|
3033
|
-
b.writeUInt32LE(0, offset + Constants.END64START);
|
|
3034
|
-
Utils.writeBigUInt64LE(b, zip64EndOffset, offset + Constants.END64OFF);
|
|
3035
|
-
b.writeUInt32LE(1, offset + Constants.END64NUMDISKS);
|
|
3036
|
-
offset += Constants.END64HDR;
|
|
3037
|
-
b.writeUInt32LE(Constants.ENDSIG, offset);
|
|
3038
|
-
b.writeUInt32LE(0, offset + 4);
|
|
3039
|
-
b.writeUInt16LE(Math.min(_volumeEntries, Constants.EF_ZIP64_OR_16), offset + Constants.ENDSUB);
|
|
3040
|
-
b.writeUInt16LE(Math.min(_totalEntries, Constants.EF_ZIP64_OR_16), offset + Constants.ENDTOT);
|
|
3041
|
-
b.writeUInt32LE(Math.min(_size, Constants.EF_ZIP64_OR_32), offset + Constants.ENDSIZ);
|
|
3042
|
-
b.writeUInt32LE(Math.min(_offset, Constants.EF_ZIP64_OR_32), offset + Constants.ENDOFF);
|
|
3043
|
-
b.writeUInt16LE(_commentLength, offset + Constants.ENDCOM);
|
|
3044
|
-
b.fill(" ", offset + Constants.ENDHDR);
|
|
3045
|
-
return b;
|
|
3046
|
-
},
|
|
3047
|
-
toJSON: function() {
|
|
3048
|
-
const offset = function(nr, len) {
|
|
3049
|
-
let offs = nr.toString(16).toUpperCase();
|
|
3050
|
-
while (offs.length < len)
|
|
3051
|
-
offs = "0" + offs;
|
|
3052
|
-
return "0x" + offs;
|
|
3053
|
-
};
|
|
3054
|
-
return {
|
|
3055
|
-
diskEntries: _volumeEntries,
|
|
3056
|
-
totalEntries: _totalEntries,
|
|
3057
|
-
size: _size + " bytes",
|
|
3058
|
-
offset: offset(_offset, 4),
|
|
3059
|
-
commentLength: _commentLength
|
|
3060
|
-
};
|
|
3061
|
-
},
|
|
3062
|
-
toString: function() {
|
|
3063
|
-
return JSON.stringify(this.toJSON(), null, "\t");
|
|
3064
|
-
}
|
|
3065
|
-
};
|
|
3066
|
-
};
|
|
3067
|
-
});
|
|
3068
|
-
|
|
3069
|
-
// ../../node_modules/adm-zip/headers/index.js
|
|
3070
|
-
var require_headers = __commonJS((exports) => {
|
|
3071
|
-
exports.EntryHeader = require_entryHeader();
|
|
3072
|
-
exports.MainHeader = require_mainHeader();
|
|
3073
|
-
});
|
|
3074
|
-
|
|
3075
|
-
// ../../node_modules/adm-zip/methods/deflater.js
|
|
3076
|
-
var require_deflater = __commonJS((exports, module) => {
|
|
3077
|
-
module.exports = function(inbuf) {
|
|
3078
|
-
var zlib = __require("zlib");
|
|
3079
|
-
var opts = { chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024 };
|
|
3080
|
-
return {
|
|
3081
|
-
deflate: function() {
|
|
3082
|
-
return zlib.deflateRawSync(inbuf, opts);
|
|
3083
|
-
},
|
|
3084
|
-
deflateAsync: function(callback) {
|
|
3085
|
-
var tmp = zlib.createDeflateRaw(opts), parts = [], total = 0;
|
|
3086
|
-
tmp.on("data", function(data) {
|
|
3087
|
-
parts.push(data);
|
|
3088
|
-
total += data.length;
|
|
3089
|
-
});
|
|
3090
|
-
tmp.on("end", function() {
|
|
3091
|
-
var buf = Buffer.alloc(total), written = 0;
|
|
3092
|
-
buf.fill(0);
|
|
3093
|
-
for (var i = 0;i < parts.length; i++) {
|
|
3094
|
-
var part = parts[i];
|
|
3095
|
-
part.copy(buf, written);
|
|
3096
|
-
written += part.length;
|
|
3097
|
-
}
|
|
3098
|
-
callback && callback(buf);
|
|
3099
|
-
});
|
|
3100
|
-
tmp.end(inbuf);
|
|
3101
|
-
}
|
|
3102
|
-
};
|
|
3103
|
-
};
|
|
3104
|
-
});
|
|
3105
|
-
|
|
3106
|
-
// ../../node_modules/adm-zip/methods/inflater.js
|
|
3107
|
-
var require_inflater = __commonJS((exports, module) => {
|
|
3108
|
-
var version = +(process?.versions?.node ?? "").split(".")[0] || 0;
|
|
3109
|
-
module.exports = function(inbuf, expectedLength) {
|
|
3110
|
-
var zlib = __require("zlib");
|
|
3111
|
-
const option = version >= 15 && expectedLength > 0 ? { maxOutputLength: expectedLength } : {};
|
|
3112
|
-
return {
|
|
3113
|
-
inflate: function() {
|
|
3114
|
-
return zlib.inflateRawSync(inbuf, option);
|
|
3115
|
-
},
|
|
3116
|
-
inflateAsync: function(callback) {
|
|
3117
|
-
var tmp = zlib.createInflateRaw(option), parts = [], total = 0;
|
|
3118
|
-
tmp.on("data", function(data) {
|
|
3119
|
-
parts.push(data);
|
|
3120
|
-
total += data.length;
|
|
3121
|
-
});
|
|
3122
|
-
tmp.on("end", function() {
|
|
3123
|
-
var buf = Buffer.alloc(total), written = 0;
|
|
3124
|
-
buf.fill(0);
|
|
3125
|
-
for (var i = 0;i < parts.length; i++) {
|
|
3126
|
-
var part = parts[i];
|
|
3127
|
-
part.copy(buf, written);
|
|
3128
|
-
written += part.length;
|
|
3129
|
-
}
|
|
3130
|
-
callback && callback(buf);
|
|
3131
|
-
});
|
|
3132
|
-
tmp.end(inbuf);
|
|
3133
|
-
}
|
|
3134
|
-
};
|
|
3135
|
-
};
|
|
3136
|
-
});
|
|
3137
|
-
|
|
3138
|
-
// ../../node_modules/adm-zip/methods/zipcrypto.js
|
|
3139
|
-
var require_zipcrypto = __commonJS((exports, module) => {
|
|
3140
|
-
var { randomFillSync } = __require("crypto");
|
|
3141
|
-
var Errors = require_errors();
|
|
3142
|
-
var crctable = new Uint32Array(256).map((t, crc) => {
|
|
3143
|
-
for (let j = 0;j < 8; j++) {
|
|
3144
|
-
if ((crc & 1) !== 0) {
|
|
3145
|
-
crc = crc >>> 1 ^ 3988292384;
|
|
3146
|
-
} else {
|
|
3147
|
-
crc >>>= 1;
|
|
3148
|
-
}
|
|
3149
|
-
}
|
|
3150
|
-
return crc >>> 0;
|
|
3151
|
-
});
|
|
3152
|
-
var uMul = (a, b) => Math.imul(a, b) >>> 0;
|
|
3153
|
-
var crc32update = (pCrc32, bval) => {
|
|
3154
|
-
return crctable[(pCrc32 ^ bval) & 255] ^ pCrc32 >>> 8;
|
|
3155
|
-
};
|
|
3156
|
-
var genSalt = () => {
|
|
3157
|
-
if (typeof randomFillSync === "function") {
|
|
3158
|
-
return randomFillSync(Buffer.alloc(12));
|
|
3159
|
-
} else {
|
|
3160
|
-
return genSalt.node();
|
|
3161
|
-
}
|
|
3162
|
-
};
|
|
3163
|
-
genSalt.node = () => {
|
|
3164
|
-
const salt = Buffer.alloc(12);
|
|
3165
|
-
const len = salt.length;
|
|
3166
|
-
for (let i = 0;i < len; i++)
|
|
3167
|
-
salt[i] = Math.random() * 256 & 255;
|
|
3168
|
-
return salt;
|
|
3169
|
-
};
|
|
3170
|
-
var config = {
|
|
3171
|
-
genSalt
|
|
3172
|
-
};
|
|
3173
|
-
function Initkeys(pw) {
|
|
3174
|
-
const pass = Buffer.isBuffer(pw) ? pw : Buffer.from(pw);
|
|
3175
|
-
this.keys = new Uint32Array([305419896, 591751049, 878082192]);
|
|
3176
|
-
for (let i = 0;i < pass.length; i++) {
|
|
3177
|
-
this.updateKeys(pass[i]);
|
|
3178
|
-
}
|
|
3179
|
-
}
|
|
3180
|
-
Initkeys.prototype.updateKeys = function(byteValue) {
|
|
3181
|
-
const keys = this.keys;
|
|
3182
|
-
keys[0] = crc32update(keys[0], byteValue);
|
|
3183
|
-
keys[1] += keys[0] & 255;
|
|
3184
|
-
keys[1] = uMul(keys[1], 134775813) + 1;
|
|
3185
|
-
keys[2] = crc32update(keys[2], keys[1] >>> 24);
|
|
3186
|
-
return byteValue;
|
|
3187
|
-
};
|
|
3188
|
-
Initkeys.prototype.next = function() {
|
|
3189
|
-
const k = (this.keys[2] | 2) >>> 0;
|
|
3190
|
-
return uMul(k, k ^ 1) >> 8 & 255;
|
|
3191
|
-
};
|
|
3192
|
-
function make_decrypter(pwd) {
|
|
3193
|
-
const keys = new Initkeys(pwd);
|
|
3194
|
-
return function(data) {
|
|
3195
|
-
const result = Buffer.alloc(data.length);
|
|
3196
|
-
let pos = 0;
|
|
3197
|
-
for (let c of data) {
|
|
3198
|
-
result[pos++] = keys.updateKeys(c ^ keys.next());
|
|
3199
|
-
}
|
|
3200
|
-
return result;
|
|
3201
|
-
};
|
|
3202
|
-
}
|
|
3203
|
-
function make_encrypter(pwd) {
|
|
3204
|
-
const keys = new Initkeys(pwd);
|
|
3205
|
-
return function(data, result, pos = 0) {
|
|
3206
|
-
if (!result)
|
|
3207
|
-
result = Buffer.alloc(data.length);
|
|
3208
|
-
for (let c of data) {
|
|
3209
|
-
const k = keys.next();
|
|
3210
|
-
result[pos++] = c ^ k;
|
|
3211
|
-
keys.updateKeys(c);
|
|
3212
|
-
}
|
|
3213
|
-
return result;
|
|
3214
|
-
};
|
|
3215
|
-
}
|
|
3216
|
-
function decrypt(data, header, pwd) {
|
|
3217
|
-
if (!data || !Buffer.isBuffer(data) || data.length < 12) {
|
|
3218
|
-
return Buffer.alloc(0);
|
|
3219
|
-
}
|
|
3220
|
-
const decrypter = make_decrypter(pwd);
|
|
3221
|
-
const salt = decrypter(data.slice(0, 12));
|
|
3222
|
-
const verifyByte = (header.flags & 8) === 8 ? header.timeHighByte : header.crc >>> 24;
|
|
3223
|
-
if (salt[11] !== verifyByte) {
|
|
3224
|
-
throw Errors.WRONG_PASSWORD();
|
|
3225
|
-
}
|
|
3226
|
-
return decrypter(data.slice(12));
|
|
3227
|
-
}
|
|
3228
|
-
function _salter(data) {
|
|
3229
|
-
if (Buffer.isBuffer(data) && data.length >= 12) {
|
|
3230
|
-
config.genSalt = function() {
|
|
3231
|
-
return data.slice(0, 12);
|
|
3232
|
-
};
|
|
3233
|
-
} else if (data === "node") {
|
|
3234
|
-
config.genSalt = genSalt.node;
|
|
3235
|
-
} else {
|
|
3236
|
-
config.genSalt = genSalt;
|
|
3237
|
-
}
|
|
3238
|
-
}
|
|
3239
|
-
function encrypt(data, header, pwd, oldlike = false) {
|
|
3240
|
-
if (data == null)
|
|
3241
|
-
data = Buffer.alloc(0);
|
|
3242
|
-
if (!Buffer.isBuffer(data))
|
|
3243
|
-
data = Buffer.from(data.toString());
|
|
3244
|
-
const encrypter = make_encrypter(pwd);
|
|
3245
|
-
const salt = config.genSalt();
|
|
3246
|
-
salt[11] = header.crc >>> 24 & 255;
|
|
3247
|
-
if (oldlike)
|
|
3248
|
-
salt[10] = header.crc >>> 16 & 255;
|
|
3249
|
-
const result = Buffer.alloc(data.length + 12);
|
|
3250
|
-
encrypter(salt, result);
|
|
3251
|
-
return encrypter(data, result, 12);
|
|
3252
|
-
}
|
|
3253
|
-
module.exports = { decrypt, encrypt, _salter };
|
|
3254
|
-
});
|
|
3255
|
-
|
|
3256
|
-
// ../../node_modules/adm-zip/methods/index.js
|
|
3257
|
-
var require_methods = __commonJS((exports) => {
|
|
3258
|
-
exports.Deflater = require_deflater();
|
|
3259
|
-
exports.Inflater = require_inflater();
|
|
3260
|
-
exports.ZipCrypto = require_zipcrypto();
|
|
3261
|
-
});
|
|
3262
|
-
|
|
3263
|
-
// ../../node_modules/adm-zip/zipEntry.js
|
|
3264
|
-
var require_zipEntry = __commonJS((exports, module) => {
|
|
3265
|
-
var Utils = require_util();
|
|
3266
|
-
var Headers2 = require_headers();
|
|
3267
|
-
var Constants = Utils.Constants;
|
|
3268
|
-
var Methods = require_methods();
|
|
3269
|
-
module.exports = function(options, input) {
|
|
3270
|
-
var _centralHeader = new Headers2.EntryHeader, _entryName = Buffer.alloc(0), _comment = Buffer.alloc(0), _isDirectory = false, uncompressedData = null, _extra = Buffer.alloc(0), _extralocal = Buffer.alloc(0), _efs = true;
|
|
3271
|
-
const opts = options;
|
|
3272
|
-
const decoder = typeof opts.decoder === "object" ? opts.decoder : Utils.decoder;
|
|
3273
|
-
_efs = decoder.hasOwnProperty("efs") ? decoder.efs : false;
|
|
3274
|
-
function getCompressedDataFromZip() {
|
|
3275
|
-
if (!input || !(input instanceof Uint8Array)) {
|
|
3276
|
-
return Buffer.alloc(0);
|
|
3277
|
-
}
|
|
3278
|
-
_extralocal = _centralHeader.loadLocalHeaderFromBinary(input);
|
|
3279
|
-
return input.slice(_centralHeader.realDataOffset, _centralHeader.realDataOffset + _centralHeader.compressedSize);
|
|
3280
|
-
}
|
|
3281
|
-
function crc32OK(data) {
|
|
3282
|
-
const expectedCrc = _centralHeader.flags_desc || _centralHeader.localHeader.flags_desc ? _centralHeader.crc : _centralHeader.localHeader.crc;
|
|
3283
|
-
return Utils.crc32(data) === expectedCrc;
|
|
3284
|
-
}
|
|
3285
|
-
function decompress(async, callback, pass) {
|
|
3286
|
-
if (typeof callback === "undefined" && typeof async === "string") {
|
|
3287
|
-
pass = async;
|
|
3288
|
-
async = undefined;
|
|
3289
|
-
}
|
|
3290
|
-
if (_isDirectory) {
|
|
3291
|
-
if (async && callback) {
|
|
3292
|
-
callback(Buffer.alloc(0), Utils.Errors.DIRECTORY_CONTENT_ERROR());
|
|
3293
|
-
}
|
|
3294
|
-
return Buffer.alloc(0);
|
|
3295
|
-
}
|
|
3296
|
-
var compressedData = getCompressedDataFromZip();
|
|
3297
|
-
if (compressedData.length === 0) {
|
|
3298
|
-
if (async && callback)
|
|
3299
|
-
callback(compressedData);
|
|
3300
|
-
return compressedData;
|
|
3301
|
-
}
|
|
3302
|
-
if (_centralHeader.encrypted) {
|
|
3303
|
-
if (typeof pass !== "string" && !Buffer.isBuffer(pass)) {
|
|
3304
|
-
throw Utils.Errors.INVALID_PASS_PARAM();
|
|
3305
|
-
}
|
|
3306
|
-
compressedData = Methods.ZipCrypto.decrypt(compressedData, _centralHeader, pass);
|
|
3307
|
-
}
|
|
3308
|
-
var data;
|
|
3309
|
-
switch (_centralHeader.method) {
|
|
3310
|
-
case Utils.Constants.STORED:
|
|
3311
|
-
data = Buffer.alloc(compressedData.length);
|
|
3312
|
-
compressedData.copy(data);
|
|
3313
|
-
if (!crc32OK(data)) {
|
|
3314
|
-
if (async && callback)
|
|
3315
|
-
callback(data, Utils.Errors.BAD_CRC());
|
|
3316
|
-
throw Utils.Errors.BAD_CRC();
|
|
3317
|
-
} else {
|
|
3318
|
-
if (async && callback)
|
|
3319
|
-
callback(data);
|
|
3320
|
-
return data;
|
|
3321
|
-
}
|
|
3322
|
-
case Utils.Constants.DEFLATED:
|
|
3323
|
-
var inflater = new Methods.Inflater(compressedData, _centralHeader.size);
|
|
3324
|
-
if (!async) {
|
|
3325
|
-
data = inflater.inflate();
|
|
3326
|
-
if (!crc32OK(data)) {
|
|
3327
|
-
throw Utils.Errors.BAD_CRC(`"${decoder.decode(_entryName)}"`);
|
|
3328
|
-
}
|
|
3329
|
-
return data;
|
|
3330
|
-
} else {
|
|
3331
|
-
inflater.inflateAsync(function(result) {
|
|
3332
|
-
if (callback) {
|
|
3333
|
-
if (!crc32OK(result)) {
|
|
3334
|
-
callback(result, Utils.Errors.BAD_CRC());
|
|
3335
|
-
} else {
|
|
3336
|
-
callback(result);
|
|
3337
|
-
}
|
|
3338
|
-
}
|
|
3339
|
-
});
|
|
3340
|
-
}
|
|
3341
|
-
break;
|
|
3342
|
-
default:
|
|
3343
|
-
if (async && callback)
|
|
3344
|
-
callback(Buffer.alloc(0), Utils.Errors.UNKNOWN_METHOD());
|
|
3345
|
-
throw Utils.Errors.UNKNOWN_METHOD();
|
|
3346
|
-
}
|
|
3347
|
-
}
|
|
3348
|
-
function compress(async, callback) {
|
|
3349
|
-
if ((!uncompressedData || !uncompressedData.length) && Buffer.isBuffer(input)) {
|
|
3350
|
-
if (async && callback)
|
|
3351
|
-
callback(getCompressedDataFromZip());
|
|
3352
|
-
return getCompressedDataFromZip();
|
|
3353
|
-
}
|
|
3354
|
-
if (uncompressedData.length && !_isDirectory) {
|
|
3355
|
-
var compressedData;
|
|
3356
|
-
switch (_centralHeader.method) {
|
|
3357
|
-
case Utils.Constants.STORED:
|
|
3358
|
-
_centralHeader.compressedSize = _centralHeader.size;
|
|
3359
|
-
compressedData = Buffer.alloc(uncompressedData.length);
|
|
3360
|
-
uncompressedData.copy(compressedData);
|
|
3361
|
-
if (async && callback)
|
|
3362
|
-
callback(compressedData);
|
|
3363
|
-
return compressedData;
|
|
3364
|
-
default:
|
|
3365
|
-
case Utils.Constants.DEFLATED:
|
|
3366
|
-
var deflater = new Methods.Deflater(uncompressedData);
|
|
3367
|
-
if (!async) {
|
|
3368
|
-
var deflated = deflater.deflate();
|
|
3369
|
-
_centralHeader.compressedSize = deflated.length;
|
|
3370
|
-
return deflated;
|
|
3371
|
-
} else {
|
|
3372
|
-
deflater.deflateAsync(function(data) {
|
|
3373
|
-
compressedData = Buffer.alloc(data.length);
|
|
3374
|
-
_centralHeader.compressedSize = data.length;
|
|
3375
|
-
data.copy(compressedData);
|
|
3376
|
-
callback && callback(compressedData);
|
|
3377
|
-
});
|
|
3378
|
-
}
|
|
3379
|
-
deflater = null;
|
|
3380
|
-
break;
|
|
3381
|
-
}
|
|
3382
|
-
} else if (async && callback) {
|
|
3383
|
-
callback(Buffer.alloc(0));
|
|
3384
|
-
} else {
|
|
3385
|
-
return Buffer.alloc(0);
|
|
3386
|
-
}
|
|
3387
|
-
}
|
|
3388
|
-
function readUInt64LE(buffer, offset) {
|
|
3389
|
-
return Utils.readBigUInt64LE(buffer, offset);
|
|
3390
|
-
}
|
|
3391
|
-
function parseExtra(data) {
|
|
3392
|
-
try {
|
|
3393
|
-
var offset = 0;
|
|
3394
|
-
var signature, size, part;
|
|
3395
|
-
while (offset + 4 < data.length) {
|
|
3396
|
-
signature = data.readUInt16LE(offset);
|
|
3397
|
-
offset += 2;
|
|
3398
|
-
size = data.readUInt16LE(offset);
|
|
3399
|
-
offset += 2;
|
|
3400
|
-
part = data.slice(offset, offset + size);
|
|
3401
|
-
offset += size;
|
|
3402
|
-
if (Constants.ID_ZIP64 === signature) {
|
|
3403
|
-
parseZip64ExtendedInformation(part);
|
|
3404
|
-
}
|
|
3405
|
-
}
|
|
3406
|
-
} catch (error) {
|
|
3407
|
-
throw Utils.Errors.EXTRA_FIELD_PARSE_ERROR();
|
|
3408
|
-
}
|
|
3409
|
-
}
|
|
3410
|
-
function parseZip64ExtendedInformation(data) {
|
|
3411
|
-
var size, compressedSize, offset, diskNumStart;
|
|
3412
|
-
if (data.length >= Constants.EF_ZIP64_SCOMP) {
|
|
3413
|
-
size = readUInt64LE(data, Constants.EF_ZIP64_SUNCOMP);
|
|
3414
|
-
if (_centralHeader.size === Constants.EF_ZIP64_OR_32) {
|
|
3415
|
-
_centralHeader.size = size;
|
|
3416
|
-
}
|
|
3417
|
-
}
|
|
3418
|
-
if (data.length >= Constants.EF_ZIP64_RHO) {
|
|
3419
|
-
compressedSize = readUInt64LE(data, Constants.EF_ZIP64_SCOMP);
|
|
3420
|
-
if (_centralHeader.compressedSize === Constants.EF_ZIP64_OR_32) {
|
|
3421
|
-
_centralHeader.compressedSize = compressedSize;
|
|
3422
|
-
}
|
|
3423
|
-
}
|
|
3424
|
-
if (data.length >= Constants.EF_ZIP64_DSN) {
|
|
3425
|
-
offset = readUInt64LE(data, Constants.EF_ZIP64_RHO);
|
|
3426
|
-
if (_centralHeader.offset === Constants.EF_ZIP64_OR_32) {
|
|
3427
|
-
_centralHeader.offset = offset;
|
|
3428
|
-
}
|
|
3429
|
-
}
|
|
3430
|
-
if (data.length >= Constants.EF_ZIP64_DSN + 4) {
|
|
3431
|
-
diskNumStart = data.readUInt32LE(Constants.EF_ZIP64_DSN);
|
|
3432
|
-
if (_centralHeader.diskNumStart === Constants.EF_ZIP64_OR_16) {
|
|
3433
|
-
_centralHeader.diskNumStart = diskNumStart;
|
|
3434
|
-
}
|
|
3435
|
-
}
|
|
3436
|
-
}
|
|
3437
|
-
return {
|
|
3438
|
-
get entryName() {
|
|
3439
|
-
return decoder.decode(_entryName);
|
|
3440
|
-
},
|
|
3441
|
-
get rawEntryName() {
|
|
3442
|
-
return _entryName;
|
|
3443
|
-
},
|
|
3444
|
-
set entryName(val) {
|
|
3445
|
-
_entryName = Utils.toBuffer(val, decoder.encode);
|
|
3446
|
-
var lastChar = _entryName[_entryName.length - 1];
|
|
3447
|
-
_isDirectory = lastChar === 47 || lastChar === 92;
|
|
3448
|
-
_centralHeader.fileNameLength = _entryName.length;
|
|
3449
|
-
},
|
|
3450
|
-
get efs() {
|
|
3451
|
-
if (typeof _efs === "function") {
|
|
3452
|
-
return _efs(this.entryName);
|
|
3453
|
-
} else {
|
|
3454
|
-
return _efs;
|
|
3455
|
-
}
|
|
3456
|
-
},
|
|
3457
|
-
get extra() {
|
|
3458
|
-
return _extra;
|
|
3459
|
-
},
|
|
3460
|
-
set extra(val) {
|
|
3461
|
-
_extra = val;
|
|
3462
|
-
_centralHeader.extraLength = val.length;
|
|
3463
|
-
parseExtra(val);
|
|
3464
|
-
},
|
|
3465
|
-
get comment() {
|
|
3466
|
-
return decoder.decode(_comment);
|
|
3467
|
-
},
|
|
3468
|
-
set comment(val) {
|
|
3469
|
-
_comment = Utils.toBuffer(val, decoder.encode);
|
|
3470
|
-
_centralHeader.commentLength = _comment.length;
|
|
3471
|
-
if (_comment.length > 65535)
|
|
3472
|
-
throw Utils.Errors.COMMENT_TOO_LONG();
|
|
3473
|
-
},
|
|
3474
|
-
get name() {
|
|
3475
|
-
const n = decoder.decode(_entryName);
|
|
3476
|
-
return _isDirectory ? n.replace(/[/\\]$/, "").split("/").pop() : n.split("/").pop();
|
|
3477
|
-
},
|
|
3478
|
-
get isDirectory() {
|
|
3479
|
-
return _isDirectory;
|
|
3480
|
-
},
|
|
3481
|
-
getCompressedData: function() {
|
|
3482
|
-
return compress(false, null);
|
|
3483
|
-
},
|
|
3484
|
-
getCompressedDataAsync: function(callback) {
|
|
3485
|
-
compress(true, callback);
|
|
3486
|
-
},
|
|
3487
|
-
setData: function(value) {
|
|
3488
|
-
uncompressedData = Utils.toBuffer(value, Utils.decoder.encode);
|
|
3489
|
-
if (!_isDirectory && uncompressedData.length) {
|
|
3490
|
-
_centralHeader.size = uncompressedData.length;
|
|
3491
|
-
_centralHeader.method = Utils.Constants.DEFLATED;
|
|
3492
|
-
_centralHeader.crc = Utils.crc32(value);
|
|
3493
|
-
_centralHeader.changed = true;
|
|
3494
|
-
} else {
|
|
3495
|
-
_centralHeader.method = Utils.Constants.STORED;
|
|
3496
|
-
}
|
|
3497
|
-
},
|
|
3498
|
-
getData: function(pass) {
|
|
3499
|
-
if (_centralHeader.changed) {
|
|
3500
|
-
return uncompressedData;
|
|
3501
|
-
} else {
|
|
3502
|
-
return decompress(false, null, pass);
|
|
3503
|
-
}
|
|
3504
|
-
},
|
|
3505
|
-
getDataAsync: function(callback, pass) {
|
|
3506
|
-
if (_centralHeader.changed) {
|
|
3507
|
-
callback(uncompressedData);
|
|
3508
|
-
} else {
|
|
3509
|
-
decompress(true, callback, pass);
|
|
3510
|
-
}
|
|
3511
|
-
},
|
|
3512
|
-
set attr(attr) {
|
|
3513
|
-
_centralHeader.attr = attr;
|
|
3514
|
-
},
|
|
3515
|
-
get attr() {
|
|
3516
|
-
return _centralHeader.attr;
|
|
3517
|
-
},
|
|
3518
|
-
set header(data) {
|
|
3519
|
-
_centralHeader.loadFromBinary(data);
|
|
3520
|
-
},
|
|
3521
|
-
get header() {
|
|
3522
|
-
return _centralHeader;
|
|
3523
|
-
},
|
|
3524
|
-
packCentralHeader: function() {
|
|
3525
|
-
_centralHeader.flags_efs = this.efs;
|
|
3526
|
-
_centralHeader.extraLength = _extra.length;
|
|
3527
|
-
var header = _centralHeader.centralHeaderToBinary();
|
|
3528
|
-
var addpos = Utils.Constants.CENHDR;
|
|
3529
|
-
_entryName.copy(header, addpos);
|
|
3530
|
-
addpos += _entryName.length;
|
|
3531
|
-
_extra.copy(header, addpos);
|
|
3532
|
-
addpos += _centralHeader.extraLength;
|
|
3533
|
-
_comment.copy(header, addpos);
|
|
3534
|
-
return header;
|
|
3535
|
-
},
|
|
3536
|
-
packLocalHeader: function() {
|
|
3537
|
-
let addpos = 0;
|
|
3538
|
-
_centralHeader.flags_efs = this.efs;
|
|
3539
|
-
_centralHeader.extraLocalLength = _extralocal.length;
|
|
3540
|
-
const localHeaderBuf = _centralHeader.localHeaderToBinary();
|
|
3541
|
-
const localHeader = Buffer.alloc(localHeaderBuf.length + _entryName.length + _centralHeader.extraLocalLength);
|
|
3542
|
-
localHeaderBuf.copy(localHeader, addpos);
|
|
3543
|
-
addpos += localHeaderBuf.length;
|
|
3544
|
-
_entryName.copy(localHeader, addpos);
|
|
3545
|
-
addpos += _entryName.length;
|
|
3546
|
-
_extralocal.copy(localHeader, addpos);
|
|
3547
|
-
addpos += _extralocal.length;
|
|
3548
|
-
return localHeader;
|
|
3549
|
-
},
|
|
3550
|
-
toJSON: function() {
|
|
3551
|
-
const bytes = function(nr) {
|
|
3552
|
-
return "<" + (nr && nr.length + " bytes buffer" || "null") + ">";
|
|
3553
|
-
};
|
|
3554
|
-
return {
|
|
3555
|
-
entryName: this.entryName,
|
|
3556
|
-
name: this.name,
|
|
3557
|
-
comment: this.comment,
|
|
3558
|
-
isDirectory: this.isDirectory,
|
|
3559
|
-
header: _centralHeader.toJSON(),
|
|
3560
|
-
compressedData: bytes(input),
|
|
3561
|
-
data: bytes(uncompressedData)
|
|
3562
|
-
};
|
|
3563
|
-
},
|
|
3564
|
-
toString: function() {
|
|
3565
|
-
return JSON.stringify(this.toJSON(), null, "\t");
|
|
3566
|
-
}
|
|
3567
|
-
};
|
|
3568
|
-
};
|
|
3569
|
-
});
|
|
3570
|
-
|
|
3571
|
-
// ../../node_modules/adm-zip/zipFile.js
|
|
3572
|
-
var require_zipFile = __commonJS((exports, module) => {
|
|
3573
|
-
var ZipEntry = require_zipEntry();
|
|
3574
|
-
var Headers2 = require_headers();
|
|
3575
|
-
var Utils = require_util();
|
|
3576
|
-
module.exports = function(inBuffer, options) {
|
|
3577
|
-
var entryList = [], entryTable = Object.create(null), _comment = Buffer.alloc(0), mainHeader = new Headers2.MainHeader, loadedEntries = false;
|
|
3578
|
-
var password = null;
|
|
3579
|
-
const temporary = new Set;
|
|
3580
|
-
const opts = options;
|
|
3581
|
-
const { noSort, decoder } = opts;
|
|
3582
|
-
if (inBuffer) {
|
|
3583
|
-
readMainHeader(opts.readEntries);
|
|
3584
|
-
} else {
|
|
3585
|
-
loadedEntries = true;
|
|
3586
|
-
}
|
|
3587
|
-
function makeTemporaryFolders() {
|
|
3588
|
-
const foldersList = new Set;
|
|
3589
|
-
for (const elem of Object.keys(entryTable)) {
|
|
3590
|
-
const elements = elem.split("/");
|
|
3591
|
-
elements.pop();
|
|
3592
|
-
if (!elements.length)
|
|
3593
|
-
continue;
|
|
3594
|
-
for (let i = 0;i < elements.length; i++) {
|
|
3595
|
-
const sub = elements.slice(0, i + 1).join("/") + "/";
|
|
3596
|
-
foldersList.add(sub);
|
|
3597
|
-
}
|
|
3598
|
-
}
|
|
3599
|
-
for (const elem of foldersList) {
|
|
3600
|
-
if (!(elem in entryTable)) {
|
|
3601
|
-
const tempfolder = new ZipEntry(opts);
|
|
3602
|
-
tempfolder.entryName = elem;
|
|
3603
|
-
tempfolder.attr = 16;
|
|
3604
|
-
tempfolder.temporary = true;
|
|
3605
|
-
entryList.push(tempfolder);
|
|
3606
|
-
entryTable[tempfolder.entryName] = tempfolder;
|
|
3607
|
-
temporary.add(tempfolder);
|
|
3608
|
-
}
|
|
3609
|
-
}
|
|
3610
|
-
}
|
|
3611
|
-
function readEntries() {
|
|
3612
|
-
loadedEntries = true;
|
|
3613
|
-
entryTable = Object.create(null);
|
|
3614
|
-
if (mainHeader.diskEntries > (inBuffer.length - mainHeader.offset) / Utils.Constants.CENHDR) {
|
|
3615
|
-
throw Utils.Errors.DISK_ENTRY_TOO_LARGE();
|
|
3616
|
-
}
|
|
3617
|
-
entryList = new Array(mainHeader.diskEntries);
|
|
3618
|
-
var index = mainHeader.offset;
|
|
3619
|
-
for (var i = 0;i < entryList.length; i++) {
|
|
3620
|
-
var tmp = index, entry = new ZipEntry(opts, inBuffer);
|
|
3621
|
-
entry.header = inBuffer.slice(tmp, tmp += Utils.Constants.CENHDR);
|
|
3622
|
-
entry.entryName = inBuffer.slice(tmp, tmp += entry.header.fileNameLength);
|
|
3623
|
-
if (entry.header.extraLength) {
|
|
3624
|
-
entry.extra = inBuffer.slice(tmp, tmp += entry.header.extraLength);
|
|
3625
|
-
}
|
|
3626
|
-
if (entry.header.commentLength)
|
|
3627
|
-
entry.comment = inBuffer.slice(tmp, tmp + entry.header.commentLength);
|
|
3628
|
-
index += entry.header.centralHeaderSize;
|
|
3629
|
-
entryList[i] = entry;
|
|
3630
|
-
entryTable[entry.entryName] = entry;
|
|
3631
|
-
}
|
|
3632
|
-
temporary.clear();
|
|
3633
|
-
makeTemporaryFolders();
|
|
3634
|
-
}
|
|
3635
|
-
function readMainHeader(readNow) {
|
|
3636
|
-
var i = inBuffer.length - Utils.Constants.ENDHDR, max = Math.max(0, i - 65535), n = max, endStart = inBuffer.length, endOffset = -1, commentEnd = 0;
|
|
3637
|
-
const trailingSpace = typeof opts.trailingSpace === "boolean" ? opts.trailingSpace : false;
|
|
3638
|
-
if (trailingSpace)
|
|
3639
|
-
max = 0;
|
|
3640
|
-
for (i;i >= n; i--) {
|
|
3641
|
-
if (inBuffer[i] !== 80)
|
|
3642
|
-
continue;
|
|
3643
|
-
if (inBuffer.readUInt32LE(i) === Utils.Constants.ENDSIG) {
|
|
3644
|
-
endOffset = i;
|
|
3645
|
-
commentEnd = i;
|
|
3646
|
-
endStart = i + Utils.Constants.ENDHDR;
|
|
3647
|
-
n = i - Utils.Constants.END64HDR;
|
|
3648
|
-
continue;
|
|
3649
|
-
}
|
|
3650
|
-
if (inBuffer.readUInt32LE(i) === Utils.Constants.END64SIG) {
|
|
3651
|
-
n = max;
|
|
3652
|
-
continue;
|
|
3653
|
-
}
|
|
3654
|
-
if (inBuffer.readUInt32LE(i) === Utils.Constants.ZIP64SIG) {
|
|
3655
|
-
endOffset = i;
|
|
3656
|
-
endStart = i + Utils.readBigUInt64LE(inBuffer, i + Utils.Constants.ZIP64SIZE) + Utils.Constants.ZIP64LEAD;
|
|
3657
|
-
break;
|
|
3658
|
-
}
|
|
3659
|
-
}
|
|
3660
|
-
if (endOffset == -1)
|
|
3661
|
-
throw Utils.Errors.INVALID_FORMAT();
|
|
3662
|
-
mainHeader.loadFromBinary(inBuffer.slice(endOffset, endStart));
|
|
3663
|
-
if (mainHeader.commentLength) {
|
|
3664
|
-
_comment = inBuffer.slice(commentEnd + Utils.Constants.ENDHDR);
|
|
3665
|
-
}
|
|
3666
|
-
if (readNow)
|
|
3667
|
-
readEntries();
|
|
3668
|
-
}
|
|
3669
|
-
function sortEntries() {
|
|
3670
|
-
if (entryList.length > 1 && !noSort) {
|
|
3671
|
-
entryList = entryList.map((entry) => ({ entry, key: entry.entryName.toLowerCase() })).sort((a, b) => a.key.localeCompare(b.key)).map((pair) => pair.entry);
|
|
3672
|
-
}
|
|
3673
|
-
}
|
|
3674
|
-
return {
|
|
3675
|
-
get entries() {
|
|
3676
|
-
if (!loadedEntries) {
|
|
3677
|
-
readEntries();
|
|
3678
|
-
}
|
|
3679
|
-
return entryList.filter((e) => !temporary.has(e));
|
|
3680
|
-
},
|
|
3681
|
-
get comment() {
|
|
3682
|
-
return decoder.decode(_comment);
|
|
3683
|
-
},
|
|
3684
|
-
set comment(val) {
|
|
3685
|
-
_comment = Utils.toBuffer(val, decoder.encode);
|
|
3686
|
-
mainHeader.commentLength = _comment.length;
|
|
3687
|
-
},
|
|
3688
|
-
getEntryCount: function() {
|
|
3689
|
-
if (!loadedEntries) {
|
|
3690
|
-
return mainHeader.diskEntries;
|
|
3691
|
-
}
|
|
3692
|
-
return entryList.length;
|
|
3693
|
-
},
|
|
3694
|
-
forEach: function(callback) {
|
|
3695
|
-
this.entries.forEach(callback);
|
|
3696
|
-
},
|
|
3697
|
-
getEntry: function(entryName) {
|
|
3698
|
-
if (!loadedEntries) {
|
|
3699
|
-
readEntries();
|
|
3700
|
-
}
|
|
3701
|
-
return entryTable[entryName] || null;
|
|
3702
|
-
},
|
|
3703
|
-
setEntry: function(entry) {
|
|
3704
|
-
if (!loadedEntries) {
|
|
3705
|
-
readEntries();
|
|
3706
|
-
}
|
|
3707
|
-
entryList.push(entry);
|
|
3708
|
-
entryTable[entry.entryName] = entry;
|
|
3709
|
-
mainHeader.totalEntries = entryList.length;
|
|
3710
|
-
},
|
|
3711
|
-
deleteFile: function(entryName, withsubfolders = true) {
|
|
3712
|
-
if (!loadedEntries) {
|
|
3713
|
-
readEntries();
|
|
3714
|
-
}
|
|
3715
|
-
const entry = entryTable[entryName];
|
|
3716
|
-
const list = this.getEntryChildren(entry, withsubfolders).map((child) => child.entryName);
|
|
3717
|
-
list.forEach(this.deleteEntry);
|
|
3718
|
-
},
|
|
3719
|
-
deleteEntry: function(entryName) {
|
|
3720
|
-
if (!loadedEntries) {
|
|
3721
|
-
readEntries();
|
|
3722
|
-
}
|
|
3723
|
-
const entry = entryTable[entryName];
|
|
3724
|
-
const index = entryList.indexOf(entry);
|
|
3725
|
-
if (index >= 0) {
|
|
3726
|
-
entryList.splice(index, 1);
|
|
3727
|
-
delete entryTable[entryName];
|
|
3728
|
-
mainHeader.totalEntries = entryList.length;
|
|
3729
|
-
}
|
|
3730
|
-
},
|
|
3731
|
-
getEntryChildren: function(entry, subfolders = true) {
|
|
3732
|
-
if (!loadedEntries) {
|
|
3733
|
-
readEntries();
|
|
3734
|
-
}
|
|
3735
|
-
if (typeof entry === "object") {
|
|
3736
|
-
if (entry.isDirectory && subfolders) {
|
|
3737
|
-
const list = [];
|
|
3738
|
-
const name = entry.entryName;
|
|
3739
|
-
for (const zipEntry of entryList) {
|
|
3740
|
-
if (zipEntry.entryName.startsWith(name)) {
|
|
3741
|
-
list.push(zipEntry);
|
|
3742
|
-
}
|
|
3743
|
-
}
|
|
3744
|
-
return list;
|
|
3745
|
-
} else {
|
|
3746
|
-
return [entry];
|
|
3747
|
-
}
|
|
3748
|
-
}
|
|
3749
|
-
return [];
|
|
3750
|
-
},
|
|
3751
|
-
getChildCount: function(entry) {
|
|
3752
|
-
if (entry && entry.isDirectory) {
|
|
3753
|
-
const list = this.getEntryChildren(entry);
|
|
3754
|
-
return list.includes(entry) ? list.length - 1 : list.length;
|
|
3755
|
-
}
|
|
3756
|
-
return 0;
|
|
3757
|
-
},
|
|
3758
|
-
compressToBuffer: function() {
|
|
3759
|
-
if (!loadedEntries) {
|
|
3760
|
-
readEntries();
|
|
3761
|
-
}
|
|
3762
|
-
sortEntries();
|
|
3763
|
-
const dataBlock = [];
|
|
3764
|
-
const headerBlocks = [];
|
|
3765
|
-
let totalSize = 0;
|
|
3766
|
-
let dindex = 0;
|
|
3767
|
-
mainHeader.size = 0;
|
|
3768
|
-
mainHeader.offset = 0;
|
|
3769
|
-
let totalEntries = 0;
|
|
3770
|
-
for (const entry of this.entries) {
|
|
3771
|
-
const compressedData = entry.getCompressedData();
|
|
3772
|
-
entry.header.offset = dindex;
|
|
3773
|
-
const localHeader = entry.packLocalHeader();
|
|
3774
|
-
const dataLength = localHeader.length + compressedData.length;
|
|
3775
|
-
dindex += dataLength;
|
|
3776
|
-
dataBlock.push(localHeader);
|
|
3777
|
-
dataBlock.push(compressedData);
|
|
3778
|
-
const centralHeader = entry.packCentralHeader();
|
|
3779
|
-
headerBlocks.push(centralHeader);
|
|
3780
|
-
mainHeader.size += centralHeader.length;
|
|
3781
|
-
totalSize += dataLength + centralHeader.length;
|
|
3782
|
-
totalEntries++;
|
|
3783
|
-
}
|
|
3784
|
-
totalSize += mainHeader.mainHeaderSize;
|
|
3785
|
-
mainHeader.offset = dindex;
|
|
3786
|
-
mainHeader.totalEntries = totalEntries;
|
|
3787
|
-
dindex = 0;
|
|
3788
|
-
const outBuffer = Buffer.alloc(totalSize);
|
|
3789
|
-
for (const content of dataBlock) {
|
|
3790
|
-
content.copy(outBuffer, dindex);
|
|
3791
|
-
dindex += content.length;
|
|
3792
|
-
}
|
|
3793
|
-
for (const content of headerBlocks) {
|
|
3794
|
-
content.copy(outBuffer, dindex);
|
|
3795
|
-
dindex += content.length;
|
|
3796
|
-
}
|
|
3797
|
-
const mh = mainHeader.toBinary();
|
|
3798
|
-
if (_comment) {
|
|
3799
|
-
_comment.copy(mh, mh.length - _comment.length);
|
|
3800
|
-
}
|
|
3801
|
-
mh.copy(outBuffer, dindex);
|
|
3802
|
-
inBuffer = outBuffer;
|
|
3803
|
-
loadedEntries = false;
|
|
3804
|
-
return outBuffer;
|
|
3805
|
-
},
|
|
3806
|
-
toAsyncBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
|
|
3807
|
-
try {
|
|
3808
|
-
if (!loadedEntries) {
|
|
3809
|
-
readEntries();
|
|
3810
|
-
}
|
|
3811
|
-
sortEntries();
|
|
3812
|
-
const dataBlock = [];
|
|
3813
|
-
const centralHeaders = [];
|
|
3814
|
-
let totalSize = 0;
|
|
3815
|
-
let dindex = 0;
|
|
3816
|
-
let totalEntries = 0;
|
|
3817
|
-
mainHeader.size = 0;
|
|
3818
|
-
mainHeader.offset = 0;
|
|
3819
|
-
const compress2Buffer = function(entryLists) {
|
|
3820
|
-
if (entryLists.length > 0) {
|
|
3821
|
-
const entry = entryLists.shift();
|
|
3822
|
-
const name = entry.entryName + entry.extra.toString();
|
|
3823
|
-
if (onItemStart)
|
|
3824
|
-
onItemStart(name);
|
|
3825
|
-
entry.getCompressedDataAsync(function(compressedData) {
|
|
3826
|
-
if (onItemEnd)
|
|
3827
|
-
onItemEnd(name);
|
|
3828
|
-
entry.header.offset = dindex;
|
|
3829
|
-
const localHeader = entry.packLocalHeader();
|
|
3830
|
-
const dataLength = localHeader.length + compressedData.length;
|
|
3831
|
-
dindex += dataLength;
|
|
3832
|
-
dataBlock.push(localHeader);
|
|
3833
|
-
dataBlock.push(compressedData);
|
|
3834
|
-
const centalHeader = entry.packCentralHeader();
|
|
3835
|
-
centralHeaders.push(centalHeader);
|
|
3836
|
-
mainHeader.size += centalHeader.length;
|
|
3837
|
-
totalSize += dataLength + centalHeader.length;
|
|
3838
|
-
totalEntries++;
|
|
3839
|
-
compress2Buffer(entryLists);
|
|
3840
|
-
});
|
|
3841
|
-
} else {
|
|
3842
|
-
totalSize += mainHeader.mainHeaderSize;
|
|
3843
|
-
mainHeader.offset = dindex;
|
|
3844
|
-
mainHeader.totalEntries = totalEntries;
|
|
3845
|
-
dindex = 0;
|
|
3846
|
-
const outBuffer = Buffer.alloc(totalSize);
|
|
3847
|
-
dataBlock.forEach(function(content) {
|
|
3848
|
-
content.copy(outBuffer, dindex);
|
|
3849
|
-
dindex += content.length;
|
|
3850
|
-
});
|
|
3851
|
-
centralHeaders.forEach(function(content) {
|
|
3852
|
-
content.copy(outBuffer, dindex);
|
|
3853
|
-
dindex += content.length;
|
|
3854
|
-
});
|
|
3855
|
-
const mh = mainHeader.toBinary();
|
|
3856
|
-
if (_comment) {
|
|
3857
|
-
_comment.copy(mh, mh.length - _comment.length);
|
|
3858
|
-
}
|
|
3859
|
-
mh.copy(outBuffer, dindex);
|
|
3860
|
-
inBuffer = outBuffer;
|
|
3861
|
-
loadedEntries = false;
|
|
3862
|
-
onSuccess(outBuffer);
|
|
3863
|
-
}
|
|
3864
|
-
};
|
|
3865
|
-
compress2Buffer(Array.from(this.entries));
|
|
3866
|
-
} catch (e) {
|
|
3867
|
-
onFail(e);
|
|
3868
|
-
}
|
|
3869
|
-
}
|
|
3870
|
-
};
|
|
3871
|
-
};
|
|
3872
|
-
});
|
|
3873
|
-
|
|
3874
|
-
// ../../node_modules/adm-zip/adm-zip.js
|
|
3875
|
-
var require_adm_zip = __commonJS((exports, module) => {
|
|
3876
|
-
var Utils = require_util();
|
|
3877
|
-
var pth = __require("path");
|
|
3878
|
-
var ZipEntry = require_zipEntry();
|
|
3879
|
-
var ZipFile = require_zipFile();
|
|
3880
|
-
var get_Bool = (...val) => Utils.findLast(val, (c) => typeof c === "boolean");
|
|
3881
|
-
var get_Str = (...val) => Utils.findLast(val, (c) => typeof c === "string");
|
|
3882
|
-
var get_Fun = (...val) => Utils.findLast(val, (c) => typeof c === "function");
|
|
3883
|
-
var defaultOptions = {
|
|
3884
|
-
noSort: false,
|
|
3885
|
-
readEntries: false,
|
|
3886
|
-
method: Utils.Constants.NONE,
|
|
3887
|
-
fs: null
|
|
3888
|
-
};
|
|
3889
|
-
module.exports = function(input, options) {
|
|
3890
|
-
let inBuffer = null;
|
|
3891
|
-
const opts = Object.assign(Object.create(null), defaultOptions);
|
|
3892
|
-
if (input && typeof input === "object") {
|
|
3893
|
-
if (!(input instanceof Uint8Array)) {
|
|
3894
|
-
Object.assign(opts, input);
|
|
3895
|
-
input = opts.input ? opts.input : undefined;
|
|
3896
|
-
if (opts.input)
|
|
3897
|
-
delete opts.input;
|
|
3898
|
-
}
|
|
3899
|
-
if (Buffer.isBuffer(input)) {
|
|
3900
|
-
inBuffer = input;
|
|
3901
|
-
opts.method = Utils.Constants.BUFFER;
|
|
3902
|
-
input = undefined;
|
|
3903
|
-
}
|
|
3904
|
-
}
|
|
3905
|
-
Object.assign(opts, options);
|
|
3906
|
-
const filetools = new Utils(opts);
|
|
3907
|
-
const applyDirAttributes = (dirEntries) => {
|
|
3908
|
-
dirEntries.filter((d) => d.attr).sort((a, b) => b.path.length - a.path.length).forEach((d) => filetools.fs.chmodSync(d.path, d.attr));
|
|
3909
|
-
};
|
|
3910
|
-
if (typeof opts.decoder !== "object" || typeof opts.decoder.encode !== "function" || typeof opts.decoder.decode !== "function") {
|
|
3911
|
-
opts.decoder = Utils.decoder;
|
|
3912
|
-
}
|
|
3913
|
-
if (input && typeof input === "string") {
|
|
3914
|
-
if (filetools.fs.existsSync(input)) {
|
|
3915
|
-
opts.method = Utils.Constants.FILE;
|
|
3916
|
-
opts.filename = input;
|
|
3917
|
-
inBuffer = filetools.fs.readFileSync(input);
|
|
3918
|
-
} else {
|
|
3919
|
-
throw Utils.Errors.INVALID_FILENAME();
|
|
3920
|
-
}
|
|
3921
|
-
}
|
|
3922
|
-
const _zip = new ZipFile(inBuffer, opts);
|
|
3923
|
-
const { canonical, sanitize, zipnamefix } = Utils;
|
|
3924
|
-
function getEntry(entry) {
|
|
3925
|
-
if (entry && _zip) {
|
|
3926
|
-
var item;
|
|
3927
|
-
if (typeof entry === "string")
|
|
3928
|
-
item = _zip.getEntry(pth.posix.normalize(entry));
|
|
3929
|
-
if (typeof entry === "object" && typeof entry.entryName !== "undefined" && typeof entry.header !== "undefined")
|
|
3930
|
-
item = _zip.getEntry(entry.entryName);
|
|
3931
|
-
if (item) {
|
|
3932
|
-
return item;
|
|
3933
|
-
}
|
|
3934
|
-
}
|
|
3935
|
-
return null;
|
|
3936
|
-
}
|
|
3937
|
-
function fixPath(zipPath) {
|
|
3938
|
-
const { join, normalize, sep } = pth.posix;
|
|
3939
|
-
return join(pth.isAbsolute(zipPath) ? "/" : ".", normalize(sep + zipPath.split("\\").join(sep) + sep));
|
|
3940
|
-
}
|
|
3941
|
-
function filenameFilter(filterfn) {
|
|
3942
|
-
if (filterfn instanceof RegExp) {
|
|
3943
|
-
return function(rx) {
|
|
3944
|
-
return function(filename) {
|
|
3945
|
-
return rx.test(filename);
|
|
3946
|
-
};
|
|
3947
|
-
}(filterfn);
|
|
3948
|
-
} else if (typeof filterfn !== "function") {
|
|
3949
|
-
return () => true;
|
|
3950
|
-
}
|
|
3951
|
-
return filterfn;
|
|
3952
|
-
}
|
|
3953
|
-
const relativePath = (local, entry) => {
|
|
3954
|
-
let lastChar = entry.slice(-1);
|
|
3955
|
-
lastChar = lastChar === filetools.sep ? filetools.sep : "";
|
|
3956
|
-
return pth.relative(local, entry) + lastChar;
|
|
3957
|
-
};
|
|
3958
|
-
return {
|
|
3959
|
-
readFile: function(entry, pass) {
|
|
3960
|
-
var item = getEntry(entry);
|
|
3961
|
-
return item && item.getData(pass) || null;
|
|
3962
|
-
},
|
|
3963
|
-
childCount: function(entry) {
|
|
3964
|
-
const item = getEntry(entry);
|
|
3965
|
-
if (item) {
|
|
3966
|
-
return _zip.getChildCount(item);
|
|
3967
|
-
}
|
|
3968
|
-
},
|
|
3969
|
-
readFileAsync: function(entry, callback) {
|
|
3970
|
-
var item = getEntry(entry);
|
|
3971
|
-
if (item) {
|
|
3972
|
-
item.getDataAsync(callback);
|
|
3973
|
-
} else {
|
|
3974
|
-
callback(null, "getEntry failed for:" + entry);
|
|
3975
|
-
}
|
|
3976
|
-
},
|
|
3977
|
-
readAsText: function(entry, encoding) {
|
|
3978
|
-
var item = getEntry(entry);
|
|
3979
|
-
if (item) {
|
|
3980
|
-
var data = item.getData();
|
|
3981
|
-
if (data && data.length) {
|
|
3982
|
-
return data.toString(encoding || "utf8");
|
|
3983
|
-
}
|
|
3984
|
-
}
|
|
3985
|
-
return "";
|
|
3986
|
-
},
|
|
3987
|
-
readAsTextAsync: function(entry, callback, encoding) {
|
|
3988
|
-
var item = getEntry(entry);
|
|
3989
|
-
if (item) {
|
|
3990
|
-
item.getDataAsync(function(data, err) {
|
|
3991
|
-
if (err) {
|
|
3992
|
-
callback(data, err);
|
|
3993
|
-
return;
|
|
3994
|
-
}
|
|
3995
|
-
if (data && data.length) {
|
|
3996
|
-
callback(data.toString(encoding || "utf8"));
|
|
3997
|
-
} else {
|
|
3998
|
-
callback("");
|
|
3999
|
-
}
|
|
4000
|
-
});
|
|
4001
|
-
} else {
|
|
4002
|
-
callback("");
|
|
4003
|
-
}
|
|
4004
|
-
},
|
|
4005
|
-
deleteFile: function(entry, withsubfolders = true) {
|
|
4006
|
-
var item = getEntry(entry);
|
|
4007
|
-
if (item) {
|
|
4008
|
-
_zip.deleteFile(item.entryName, withsubfolders);
|
|
4009
|
-
}
|
|
4010
|
-
},
|
|
4011
|
-
deleteEntry: function(entry) {
|
|
4012
|
-
var item = getEntry(entry);
|
|
4013
|
-
if (item) {
|
|
4014
|
-
_zip.deleteEntry(item.entryName);
|
|
4015
|
-
}
|
|
4016
|
-
},
|
|
4017
|
-
addZipComment: function(comment) {
|
|
4018
|
-
_zip.comment = comment;
|
|
4019
|
-
},
|
|
4020
|
-
getZipComment: function() {
|
|
4021
|
-
return _zip.comment || "";
|
|
4022
|
-
},
|
|
4023
|
-
addZipEntryComment: function(entry, comment) {
|
|
4024
|
-
var item = getEntry(entry);
|
|
4025
|
-
if (item) {
|
|
4026
|
-
item.comment = comment;
|
|
4027
|
-
}
|
|
4028
|
-
},
|
|
4029
|
-
getZipEntryComment: function(entry) {
|
|
4030
|
-
var item = getEntry(entry);
|
|
4031
|
-
if (item) {
|
|
4032
|
-
return item.comment || "";
|
|
4033
|
-
}
|
|
4034
|
-
return "";
|
|
4035
|
-
},
|
|
4036
|
-
updateFile: function(entry, content) {
|
|
4037
|
-
var item = getEntry(entry);
|
|
4038
|
-
if (item) {
|
|
4039
|
-
item.setData(content);
|
|
4040
|
-
}
|
|
4041
|
-
},
|
|
4042
|
-
addLocalFile: function(localPath, zipPath, zipName, comment) {
|
|
4043
|
-
if (filetools.fs.existsSync(localPath)) {
|
|
4044
|
-
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
4045
|
-
const p = pth.win32.basename(pth.win32.normalize(localPath));
|
|
4046
|
-
zipPath += zipName ? zipName : p;
|
|
4047
|
-
const _attr = filetools.fs.statSync(localPath);
|
|
4048
|
-
const data = _attr.isFile() ? filetools.fs.readFileSync(localPath) : Buffer.alloc(0);
|
|
4049
|
-
if (_attr.isDirectory())
|
|
4050
|
-
zipPath += filetools.sep;
|
|
4051
|
-
this.addFile(zipPath, data, comment, _attr);
|
|
4052
|
-
} else {
|
|
4053
|
-
throw Utils.Errors.FILE_NOT_FOUND(localPath);
|
|
4054
|
-
}
|
|
4055
|
-
},
|
|
4056
|
-
addLocalFileAsync: function(options2, callback) {
|
|
4057
|
-
options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
|
|
4058
|
-
const localPath = pth.resolve(options2.localPath);
|
|
4059
|
-
const { comment } = options2;
|
|
4060
|
-
let { zipPath, zipName } = options2;
|
|
4061
|
-
const self = this;
|
|
4062
|
-
filetools.fs.stat(localPath, function(err, stats) {
|
|
4063
|
-
if (err)
|
|
4064
|
-
return callback(err, false);
|
|
4065
|
-
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
4066
|
-
const p = pth.win32.basename(pth.win32.normalize(localPath));
|
|
4067
|
-
zipPath += zipName ? zipName : p;
|
|
4068
|
-
if (stats.isFile()) {
|
|
4069
|
-
filetools.fs.readFile(localPath, function(err2, data) {
|
|
4070
|
-
if (err2)
|
|
4071
|
-
return callback(err2, false);
|
|
4072
|
-
self.addFile(zipPath, data, comment, stats);
|
|
4073
|
-
return setImmediate(callback, undefined, true);
|
|
4074
|
-
});
|
|
4075
|
-
} else if (stats.isDirectory()) {
|
|
4076
|
-
zipPath += filetools.sep;
|
|
4077
|
-
self.addFile(zipPath, Buffer.alloc(0), comment, stats);
|
|
4078
|
-
return setImmediate(callback, undefined, true);
|
|
4079
|
-
}
|
|
4080
|
-
});
|
|
4081
|
-
},
|
|
4082
|
-
addLocalFolder: function(localPath, zipPath, filter) {
|
|
4083
|
-
filter = filenameFilter(filter);
|
|
4084
|
-
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
4085
|
-
localPath = pth.normalize(localPath);
|
|
4086
|
-
if (filetools.fs.existsSync(localPath)) {
|
|
4087
|
-
const items = filetools.findFiles(localPath);
|
|
4088
|
-
const self = this;
|
|
4089
|
-
if (items.length) {
|
|
4090
|
-
for (const filepath of items) {
|
|
4091
|
-
const p = pth.join(zipPath, relativePath(localPath, filepath));
|
|
4092
|
-
if (filter(p)) {
|
|
4093
|
-
self.addLocalFile(filepath, pth.dirname(p));
|
|
4094
|
-
}
|
|
4095
|
-
}
|
|
4096
|
-
}
|
|
4097
|
-
} else {
|
|
4098
|
-
throw Utils.Errors.FILE_NOT_FOUND(localPath);
|
|
4099
|
-
}
|
|
4100
|
-
},
|
|
4101
|
-
addLocalFolderAsync: function(localPath, callback, zipPath, filter) {
|
|
4102
|
-
filter = filenameFilter(filter);
|
|
4103
|
-
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
4104
|
-
localPath = pth.normalize(localPath);
|
|
4105
|
-
var self = this;
|
|
4106
|
-
filetools.fs.open(localPath, "r", function(err) {
|
|
4107
|
-
if (err && err.code === "ENOENT") {
|
|
4108
|
-
callback(undefined, Utils.Errors.FILE_NOT_FOUND(localPath));
|
|
4109
|
-
} else if (err) {
|
|
4110
|
-
callback(undefined, err);
|
|
4111
|
-
} else {
|
|
4112
|
-
var items = filetools.findFiles(localPath);
|
|
4113
|
-
var i = -1;
|
|
4114
|
-
var next = function() {
|
|
4115
|
-
i += 1;
|
|
4116
|
-
if (i < items.length) {
|
|
4117
|
-
var filepath = items[i];
|
|
4118
|
-
var p = relativePath(localPath, filepath).split("\\").join("/");
|
|
4119
|
-
p = p.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
|
|
4120
|
-
if (filter(p)) {
|
|
4121
|
-
filetools.fs.stat(filepath, function(er0, stats) {
|
|
4122
|
-
if (er0)
|
|
4123
|
-
callback(undefined, er0);
|
|
4124
|
-
if (stats.isFile()) {
|
|
4125
|
-
filetools.fs.readFile(filepath, function(er1, data) {
|
|
4126
|
-
if (er1) {
|
|
4127
|
-
callback(undefined, er1);
|
|
4128
|
-
} else {
|
|
4129
|
-
self.addFile(zipPath + p, data, "", stats);
|
|
4130
|
-
next();
|
|
4131
|
-
}
|
|
4132
|
-
});
|
|
4133
|
-
} else {
|
|
4134
|
-
self.addFile(zipPath + p + "/", Buffer.alloc(0), "", stats);
|
|
4135
|
-
next();
|
|
4136
|
-
}
|
|
4137
|
-
});
|
|
4138
|
-
} else {
|
|
4139
|
-
process.nextTick(() => {
|
|
4140
|
-
next();
|
|
4141
|
-
});
|
|
4142
|
-
}
|
|
4143
|
-
} else {
|
|
4144
|
-
callback(true, undefined);
|
|
4145
|
-
}
|
|
4146
|
-
};
|
|
4147
|
-
next();
|
|
4148
|
-
}
|
|
4149
|
-
});
|
|
4150
|
-
},
|
|
4151
|
-
addLocalFolderAsync2: function(options2, callback) {
|
|
4152
|
-
const self = this;
|
|
4153
|
-
options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
|
|
4154
|
-
const localPath = pth.resolve(fixPath(options2.localPath));
|
|
4155
|
-
let { zipPath, filter, namefix } = options2;
|
|
4156
|
-
if (filter instanceof RegExp) {
|
|
4157
|
-
filter = function(rx) {
|
|
4158
|
-
return function(filename) {
|
|
4159
|
-
return rx.test(filename);
|
|
4160
|
-
};
|
|
4161
|
-
}(filter);
|
|
4162
|
-
} else if (typeof filter !== "function") {
|
|
4163
|
-
filter = function() {
|
|
4164
|
-
return true;
|
|
4165
|
-
};
|
|
4166
|
-
}
|
|
4167
|
-
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
4168
|
-
if (namefix === "latin1") {
|
|
4169
|
-
namefix = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
|
|
4170
|
-
}
|
|
4171
|
-
if (typeof namefix !== "function")
|
|
4172
|
-
namefix = (str) => str;
|
|
4173
|
-
const relPathFix = (entry) => pth.join(zipPath, namefix(relativePath(localPath, entry)));
|
|
4174
|
-
const fileNameFix = (entry) => pth.win32.basename(pth.win32.normalize(namefix(entry)));
|
|
4175
|
-
filetools.fs.open(localPath, "r", function(err) {
|
|
4176
|
-
if (err && err.code === "ENOENT") {
|
|
4177
|
-
callback(undefined, Utils.Errors.FILE_NOT_FOUND(localPath));
|
|
4178
|
-
} else if (err) {
|
|
4179
|
-
callback(undefined, err);
|
|
4180
|
-
} else {
|
|
4181
|
-
filetools.findFilesAsync(localPath, function(err2, fileEntries) {
|
|
4182
|
-
if (err2)
|
|
4183
|
-
return callback(err2);
|
|
4184
|
-
fileEntries = fileEntries.filter((dir) => filter(relPathFix(dir)));
|
|
4185
|
-
if (!fileEntries.length)
|
|
4186
|
-
callback(undefined, false);
|
|
4187
|
-
setImmediate(fileEntries.reverse().reduce(function(next, entry) {
|
|
4188
|
-
return function(err3, done) {
|
|
4189
|
-
if (err3 || done === false)
|
|
4190
|
-
return setImmediate(next, err3, false);
|
|
4191
|
-
self.addLocalFileAsync({
|
|
4192
|
-
localPath: entry,
|
|
4193
|
-
zipPath: pth.dirname(relPathFix(entry)),
|
|
4194
|
-
zipName: fileNameFix(entry)
|
|
4195
|
-
}, next);
|
|
4196
|
-
};
|
|
4197
|
-
}, callback));
|
|
4198
|
-
});
|
|
4199
|
-
}
|
|
4200
|
-
});
|
|
4201
|
-
},
|
|
4202
|
-
addLocalFolderPromise: function(localPath, props) {
|
|
4203
|
-
return new Promise((resolve, reject) => {
|
|
4204
|
-
this.addLocalFolderAsync2(Object.assign({ localPath }, props), (err, done) => {
|
|
4205
|
-
if (err)
|
|
4206
|
-
reject(err);
|
|
4207
|
-
if (done)
|
|
4208
|
-
resolve(this);
|
|
4209
|
-
});
|
|
4210
|
-
});
|
|
4211
|
-
},
|
|
4212
|
-
addFile: function(entryName, content, comment, attr) {
|
|
4213
|
-
entryName = zipnamefix(entryName);
|
|
4214
|
-
let entry = getEntry(entryName);
|
|
4215
|
-
const update = entry != null;
|
|
4216
|
-
if (!update) {
|
|
4217
|
-
entry = new ZipEntry(opts);
|
|
4218
|
-
entry.entryName = entryName;
|
|
4219
|
-
}
|
|
4220
|
-
entry.comment = comment || "";
|
|
4221
|
-
const isStat = typeof attr === "object" && attr instanceof filetools.fs.Stats;
|
|
4222
|
-
if (isStat) {
|
|
4223
|
-
entry.header.time = attr.mtime;
|
|
4224
|
-
}
|
|
4225
|
-
var fileattr = entry.isDirectory ? 16 : 0;
|
|
4226
|
-
let unix = entry.isDirectory ? 16384 : 32768;
|
|
4227
|
-
if (isStat) {
|
|
4228
|
-
unix |= 4095 & attr.mode;
|
|
4229
|
-
} else if (typeof attr === "number") {
|
|
4230
|
-
unix |= 4095 & attr;
|
|
4231
|
-
} else {
|
|
4232
|
-
unix |= entry.isDirectory ? 493 : 420;
|
|
4233
|
-
}
|
|
4234
|
-
fileattr = (fileattr | unix << 16) >>> 0;
|
|
4235
|
-
entry.attr = fileattr;
|
|
4236
|
-
entry.setData(content);
|
|
4237
|
-
if (!update)
|
|
4238
|
-
_zip.setEntry(entry);
|
|
4239
|
-
return entry;
|
|
4240
|
-
},
|
|
4241
|
-
getEntries: function(password) {
|
|
4242
|
-
_zip.password = password;
|
|
4243
|
-
return _zip ? _zip.entries : [];
|
|
4244
|
-
},
|
|
4245
|
-
getEntry: function(name) {
|
|
4246
|
-
return getEntry(name);
|
|
4247
|
-
},
|
|
4248
|
-
getEntryCount: function() {
|
|
4249
|
-
return _zip.getEntryCount();
|
|
4250
|
-
},
|
|
4251
|
-
forEach: function(callback) {
|
|
4252
|
-
return _zip.forEach(callback);
|
|
4253
|
-
},
|
|
4254
|
-
extractEntryTo: function(entry, targetPath, maintainEntryPath, overwrite, keepOriginalPermission, outFileName) {
|
|
4255
|
-
overwrite = get_Bool(false, overwrite);
|
|
4256
|
-
keepOriginalPermission = get_Bool(false, keepOriginalPermission);
|
|
4257
|
-
maintainEntryPath = get_Bool(true, maintainEntryPath);
|
|
4258
|
-
outFileName = get_Str(keepOriginalPermission, outFileName);
|
|
4259
|
-
var item = getEntry(entry);
|
|
4260
|
-
if (!item) {
|
|
4261
|
-
throw Utils.Errors.NO_ENTRY();
|
|
4262
|
-
}
|
|
4263
|
-
var entryName = canonical(item.entryName);
|
|
4264
|
-
var target = sanitize(targetPath, outFileName && !item.isDirectory ? canonical(outFileName) : maintainEntryPath ? entryName : pth.basename(entryName));
|
|
4265
|
-
if (item.isDirectory) {
|
|
4266
|
-
var children = _zip.getEntryChildren(item);
|
|
4267
|
-
children.forEach(function(child) {
|
|
4268
|
-
if (child.isDirectory)
|
|
4269
|
-
return;
|
|
4270
|
-
var content2 = child.getData();
|
|
4271
|
-
if (!content2) {
|
|
4272
|
-
throw Utils.Errors.CANT_EXTRACT_FILE();
|
|
4273
|
-
}
|
|
4274
|
-
var name = canonical(maintainEntryPath ? child.entryName : child.entryName.substring(item.entryName.length));
|
|
4275
|
-
var childName = sanitize(targetPath, name);
|
|
4276
|
-
const fileAttr2 = keepOriginalPermission ? child.header.fileAttr : undefined;
|
|
4277
|
-
filetools.writeFileTo(childName, content2, overwrite, fileAttr2);
|
|
4278
|
-
});
|
|
4279
|
-
return true;
|
|
4280
|
-
}
|
|
4281
|
-
var content = item.getData(_zip.password);
|
|
4282
|
-
if (!content)
|
|
4283
|
-
throw Utils.Errors.CANT_EXTRACT_FILE();
|
|
4284
|
-
if (filetools.fs.existsSync(target) && !overwrite) {
|
|
4285
|
-
throw Utils.Errors.CANT_OVERRIDE();
|
|
4286
|
-
}
|
|
4287
|
-
const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
|
|
4288
|
-
filetools.writeFileTo(target, content, overwrite, fileAttr);
|
|
4289
|
-
return true;
|
|
4290
|
-
},
|
|
4291
|
-
test: function(pass) {
|
|
4292
|
-
if (!_zip) {
|
|
4293
|
-
return false;
|
|
4294
|
-
}
|
|
4295
|
-
for (var entry of _zip.entries) {
|
|
4296
|
-
try {
|
|
4297
|
-
if (entry.isDirectory) {
|
|
4298
|
-
continue;
|
|
4299
|
-
}
|
|
4300
|
-
var content = entry.getData(pass);
|
|
4301
|
-
if (!content) {
|
|
4302
|
-
return false;
|
|
4303
|
-
}
|
|
4304
|
-
} catch (err) {
|
|
4305
|
-
return false;
|
|
4306
|
-
}
|
|
4307
|
-
}
|
|
4308
|
-
return true;
|
|
4309
|
-
},
|
|
4310
|
-
extractAllTo: function(targetPath, overwrite, keepOriginalPermission, pass) {
|
|
4311
|
-
keepOriginalPermission = get_Bool(false, keepOriginalPermission);
|
|
4312
|
-
pass = get_Str(keepOriginalPermission, pass);
|
|
4313
|
-
overwrite = get_Bool(false, overwrite);
|
|
4314
|
-
if (!_zip)
|
|
4315
|
-
throw Utils.Errors.NO_ZIP();
|
|
4316
|
-
const dirEntries = [];
|
|
4317
|
-
_zip.entries.forEach(function(entry) {
|
|
4318
|
-
var entryName = sanitize(targetPath, canonical(entry.entryName));
|
|
4319
|
-
if (entry.isDirectory) {
|
|
4320
|
-
filetools.makeDir(entryName);
|
|
4321
|
-
if (keepOriginalPermission)
|
|
4322
|
-
dirEntries.push({ path: entryName, attr: entry.header.fileAttr });
|
|
4323
|
-
return;
|
|
4324
|
-
}
|
|
4325
|
-
var content = entry.getData(pass);
|
|
4326
|
-
if (!content) {
|
|
4327
|
-
throw Utils.Errors.CANT_EXTRACT_FILE();
|
|
4328
|
-
}
|
|
4329
|
-
const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
|
|
4330
|
-
filetools.writeFileTo(entryName, content, overwrite, fileAttr);
|
|
4331
|
-
try {
|
|
4332
|
-
filetools.fs.utimesSync(entryName, entry.header.time, entry.header.time);
|
|
4333
|
-
} catch (err) {}
|
|
4334
|
-
});
|
|
4335
|
-
applyDirAttributes(dirEntries);
|
|
4336
|
-
},
|
|
4337
|
-
extractAllToAsync: function(targetPath, overwrite, keepOriginalPermission, callback) {
|
|
4338
|
-
callback = get_Fun(overwrite, keepOriginalPermission, callback);
|
|
4339
|
-
keepOriginalPermission = get_Bool(false, keepOriginalPermission);
|
|
4340
|
-
overwrite = get_Bool(false, overwrite);
|
|
4341
|
-
if (!callback) {
|
|
4342
|
-
return new Promise((resolve, reject) => {
|
|
4343
|
-
this.extractAllToAsync(targetPath, overwrite, keepOriginalPermission, function(err) {
|
|
4344
|
-
if (err) {
|
|
4345
|
-
reject(err);
|
|
4346
|
-
} else {
|
|
4347
|
-
resolve(this);
|
|
4348
|
-
}
|
|
4349
|
-
});
|
|
4350
|
-
});
|
|
4351
|
-
}
|
|
4352
|
-
if (!_zip) {
|
|
4353
|
-
callback(Utils.Errors.NO_ZIP());
|
|
4354
|
-
return;
|
|
4355
|
-
}
|
|
4356
|
-
targetPath = pth.resolve(targetPath);
|
|
4357
|
-
const getPath = (entry) => sanitize(targetPath, pth.normalize(canonical(entry.entryName)));
|
|
4358
|
-
const getError = (msg, file) => new Error(msg + ': "' + file + '"');
|
|
4359
|
-
const dirEntries = [];
|
|
4360
|
-
const fileEntries = [];
|
|
4361
|
-
_zip.entries.forEach((e) => {
|
|
4362
|
-
if (e.isDirectory) {
|
|
4363
|
-
dirEntries.push(e);
|
|
4364
|
-
} else {
|
|
4365
|
-
fileEntries.push(e);
|
|
4366
|
-
}
|
|
4367
|
-
});
|
|
4368
|
-
const deferredDirAttr = [];
|
|
4369
|
-
for (const entry of dirEntries) {
|
|
4370
|
-
const dirPath = getPath(entry);
|
|
4371
|
-
const dirAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
|
|
4372
|
-
try {
|
|
4373
|
-
filetools.makeDir(dirPath);
|
|
4374
|
-
} catch (er) {
|
|
4375
|
-
callback(getError("Unable to create folder", dirPath));
|
|
4376
|
-
continue;
|
|
4377
|
-
}
|
|
4378
|
-
if (dirAttr)
|
|
4379
|
-
deferredDirAttr.push({ path: dirPath, attr: dirAttr });
|
|
4380
|
-
try {
|
|
4381
|
-
filetools.fs.utimesSync(dirPath, entry.header.time, entry.header.time);
|
|
4382
|
-
} catch (er) {}
|
|
4383
|
-
}
|
|
4384
|
-
const done = (err) => {
|
|
4385
|
-
if (!err) {
|
|
4386
|
-
try {
|
|
4387
|
-
applyDirAttributes(deferredDirAttr);
|
|
4388
|
-
} catch (er) {
|
|
4389
|
-
return callback(getError("Unable to set folder permissions", er.path || ""));
|
|
4390
|
-
}
|
|
4391
|
-
}
|
|
4392
|
-
callback(err);
|
|
4393
|
-
};
|
|
4394
|
-
fileEntries.reverse().reduce(function(next, entry) {
|
|
4395
|
-
return function(err) {
|
|
4396
|
-
if (err) {
|
|
4397
|
-
next(err);
|
|
4398
|
-
} else {
|
|
4399
|
-
const entryName = pth.normalize(canonical(entry.entryName));
|
|
4400
|
-
const filePath = sanitize(targetPath, entryName);
|
|
4401
|
-
entry.getDataAsync(function(content, err_1) {
|
|
4402
|
-
if (err_1) {
|
|
4403
|
-
next(err_1);
|
|
4404
|
-
} else if (!content) {
|
|
4405
|
-
next(Utils.Errors.CANT_EXTRACT_FILE());
|
|
4406
|
-
} else {
|
|
4407
|
-
const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
|
|
4408
|
-
filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function(succ) {
|
|
4409
|
-
if (!succ) {
|
|
4410
|
-
return next(getError("Unable to write file", filePath));
|
|
4411
|
-
}
|
|
4412
|
-
filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function() {
|
|
4413
|
-
next();
|
|
4414
|
-
});
|
|
4415
|
-
});
|
|
4416
|
-
}
|
|
4417
|
-
});
|
|
4418
|
-
}
|
|
4419
|
-
};
|
|
4420
|
-
}, done)();
|
|
4421
|
-
},
|
|
4422
|
-
writeZip: function(targetFileName, callback) {
|
|
4423
|
-
if (arguments.length === 1) {
|
|
4424
|
-
if (typeof targetFileName === "function") {
|
|
4425
|
-
callback = targetFileName;
|
|
4426
|
-
targetFileName = "";
|
|
4427
|
-
}
|
|
4428
|
-
}
|
|
4429
|
-
if (!targetFileName && opts.filename) {
|
|
4430
|
-
targetFileName = opts.filename;
|
|
4431
|
-
}
|
|
4432
|
-
if (!targetFileName)
|
|
4433
|
-
return;
|
|
4434
|
-
var zipData = _zip.compressToBuffer();
|
|
4435
|
-
if (zipData) {
|
|
4436
|
-
var ok = filetools.writeFileTo(targetFileName, zipData, true);
|
|
4437
|
-
if (typeof callback === "function")
|
|
4438
|
-
callback(!ok ? new Error("failed") : null, "");
|
|
4439
|
-
}
|
|
4440
|
-
},
|
|
4441
|
-
writeZipPromise: function(targetFileName, props) {
|
|
4442
|
-
const { overwrite, perm } = Object.assign({ overwrite: true }, props);
|
|
4443
|
-
return new Promise((resolve, reject) => {
|
|
4444
|
-
if (!targetFileName && opts.filename)
|
|
4445
|
-
targetFileName = opts.filename;
|
|
4446
|
-
if (!targetFileName)
|
|
4447
|
-
reject("ADM-ZIP: ZIP File Name Missing");
|
|
4448
|
-
this.toBufferPromise().then((zipData) => {
|
|
4449
|
-
const ret = (done) => done ? resolve(done) : reject("ADM-ZIP: Wasn't able to write zip file");
|
|
4450
|
-
filetools.writeFileToAsync(targetFileName, zipData, overwrite, perm, ret);
|
|
4451
|
-
}, reject);
|
|
4452
|
-
});
|
|
4453
|
-
},
|
|
4454
|
-
toBufferPromise: function() {
|
|
4455
|
-
return new Promise((resolve, reject) => {
|
|
4456
|
-
_zip.toAsyncBuffer(resolve, reject);
|
|
4457
|
-
});
|
|
4458
|
-
},
|
|
4459
|
-
toBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
|
|
4460
|
-
if (typeof onSuccess === "function") {
|
|
4461
|
-
_zip.toAsyncBuffer(onSuccess, onFail, onItemStart, onItemEnd);
|
|
4462
|
-
return null;
|
|
4463
|
-
}
|
|
4464
|
-
return _zip.compressToBuffer();
|
|
4465
|
-
}
|
|
4466
|
-
};
|
|
4467
|
-
};
|
|
4468
|
-
});
|
|
4469
2111
|
// package.json
|
|
4470
2112
|
var package_default = {
|
|
4471
2113
|
name: "@uipath/integrationservice-tool",
|
|
4472
2114
|
license: "MIT",
|
|
4473
|
-
version: "1.201.0-preview.
|
|
2115
|
+
version: "1.201.0-preview.121",
|
|
4474
2116
|
description: "Manage Integration Service connectors, connections, and triggers.",
|
|
4475
2117
|
private: false,
|
|
4476
2118
|
repository: {
|
|
@@ -4510,6 +2152,7 @@ var package_default = {
|
|
|
4510
2152
|
"@uipath/integrationservice-sdk": "workspace:*",
|
|
4511
2153
|
"@types/node": "^25.5.2",
|
|
4512
2154
|
"adm-zip": "^0.6.0",
|
|
2155
|
+
fflate: "^0.8.2",
|
|
4513
2156
|
commander: "^14.0.3",
|
|
4514
2157
|
typescript: "^7.0.2"
|
|
4515
2158
|
}
|
|
@@ -4572,17 +2215,18 @@ var TLS_ERROR_CODES = new Set([
|
|
|
4572
2215
|
]);
|
|
4573
2216
|
var TLS_INSTRUCTIONS = "The server's TLS certificate could not be verified. Most often a " + "corporate proxy/firewall re-signs HTTPS with a root CA that Node does " + "not trust — set NODE_EXTRA_CA_CERTS to that CA's PEM file (and HTTPS_PROXY " + "if you connect through a proxy). If the certificate is instead expired or " + "its hostname does not match, fix the endpoint URL or the system clock. " + "Then retry.";
|
|
4574
2217
|
var NETWORK_INSTRUCTIONS = "Could not reach the UiPath service. Check your network connection and " + "VPN, confirm any HTTP_PROXY/HTTPS_PROXY/NO_PROXY settings are correct, " + "then retry.";
|
|
2218
|
+
var LOCAL_PERMISSION_ERROR_CODES = new Set(["EACCES", "EPERM", "EROFS"]);
|
|
2219
|
+
var LOCAL_PERMISSION_MESSAGE_PATTERN = /\b(EACCES|EPERM|EROFS)\b/;
|
|
2220
|
+
function localPermissionInstructions(code, path) {
|
|
2221
|
+
const target = path !== undefined ? `'${path}'` : "a local file or resource";
|
|
2222
|
+
if (code === "EROFS") {
|
|
2223
|
+
return `The filesystem containing ${target} is read-only (EROFS), so the ` + "CLI could not write to it. This is a local environment problem, " + "not a UiPath service error — retrying will not help. Use a " + "writable location, or give this environment write access to the " + "path.";
|
|
2224
|
+
}
|
|
2225
|
+
const remedy = process.platform === "win32" ? "Re-run from an elevated terminal, close any program holding " + "the file open, or grant your user access to the path." : "Grant this user (or the sandbox the command runs in) access " + "to the path, or run the command outside the sandbox.";
|
|
2226
|
+
return `The operating system denied access to ${target} (${code}). This is ` + "a local permission problem, not a UiPath service error — retrying " + `without a permission change will not help. ${remedy}`;
|
|
2227
|
+
}
|
|
4575
2228
|
function describeConnectivityError(error) {
|
|
4576
|
-
const
|
|
4577
|
-
const seen = new Set;
|
|
4578
|
-
for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
|
|
4579
|
-
const current = queue.shift();
|
|
4580
|
-
if (current === null || typeof current !== "object")
|
|
4581
|
-
continue;
|
|
4582
|
-
if (seen.has(current))
|
|
4583
|
-
continue;
|
|
4584
|
-
seen.add(current);
|
|
4585
|
-
const cur = current;
|
|
2229
|
+
for (const cur of walkErrorGraph(error)) {
|
|
4586
2230
|
const code = typeof cur.code === "string" ? cur.code : undefined;
|
|
4587
2231
|
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
4588
2232
|
if (code && TLS_ERROR_CODES.has(code)) {
|
|
@@ -4601,6 +2245,49 @@ function describeConnectivityError(error) {
|
|
|
4601
2245
|
instructions: NETWORK_INSTRUCTIONS
|
|
4602
2246
|
};
|
|
4603
2247
|
}
|
|
2248
|
+
}
|
|
2249
|
+
return;
|
|
2250
|
+
}
|
|
2251
|
+
function describePermissionError(error) {
|
|
2252
|
+
for (const cur of walkErrorGraph(error)) {
|
|
2253
|
+
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
2254
|
+
const code = matchLocalPermissionCode(cur.code, message);
|
|
2255
|
+
if (!code)
|
|
2256
|
+
continue;
|
|
2257
|
+
const path = localPermissionPath(cur.path, message);
|
|
2258
|
+
return {
|
|
2259
|
+
code,
|
|
2260
|
+
message: message ?? code,
|
|
2261
|
+
...path !== undefined ? { path } : {},
|
|
2262
|
+
instructions: localPermissionInstructions(code, path)
|
|
2263
|
+
};
|
|
2264
|
+
}
|
|
2265
|
+
return;
|
|
2266
|
+
}
|
|
2267
|
+
function matchLocalPermissionCode(code, message) {
|
|
2268
|
+
if (typeof code === "string" && LOCAL_PERMISSION_ERROR_CODES.has(code)) {
|
|
2269
|
+
return code;
|
|
2270
|
+
}
|
|
2271
|
+
const match = message ? LOCAL_PERMISSION_MESSAGE_PATTERN.exec(message) : null;
|
|
2272
|
+
return match ? match[1] : undefined;
|
|
2273
|
+
}
|
|
2274
|
+
function localPermissionPath(path, message) {
|
|
2275
|
+
if (typeof path === "string")
|
|
2276
|
+
return path;
|
|
2277
|
+
return message ? /'([^']+)'/.exec(message)?.[1] : undefined;
|
|
2278
|
+
}
|
|
2279
|
+
function* walkErrorGraph(error) {
|
|
2280
|
+
const queue = [error];
|
|
2281
|
+
const seen = new Set;
|
|
2282
|
+
for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
|
|
2283
|
+
const current = queue.shift();
|
|
2284
|
+
if (current === null || typeof current !== "object")
|
|
2285
|
+
continue;
|
|
2286
|
+
if (seen.has(current))
|
|
2287
|
+
continue;
|
|
2288
|
+
seen.add(current);
|
|
2289
|
+
const cur = current;
|
|
2290
|
+
yield cur;
|
|
4604
2291
|
if (cur.cause !== undefined)
|
|
4605
2292
|
queue.push(cur.cause);
|
|
4606
2293
|
if (Array.isArray(cur.errors))
|
|
@@ -4661,6 +2348,12 @@ function classifyError(status, error) {
|
|
|
4661
2348
|
if (status !== undefined && status >= 500 && status < 600) {
|
|
4662
2349
|
return { errorCode: "server_error", retry: "RetryLater" };
|
|
4663
2350
|
}
|
|
2351
|
+
if (status === undefined && describePermissionError(error)) {
|
|
2352
|
+
return {
|
|
2353
|
+
errorCode: "local_permission_denied",
|
|
2354
|
+
retry: "RetryWillNotFix"
|
|
2355
|
+
};
|
|
2356
|
+
}
|
|
4664
2357
|
const connectivity = describeConnectivityError(error);
|
|
4665
2358
|
if (connectivity) {
|
|
4666
2359
|
return {
|
|
@@ -4763,6 +2456,16 @@ async function extractErrorDetails(error, options) {
|
|
|
4763
2456
|
message = `${message}: ${connectivity.message}`;
|
|
4764
2457
|
}
|
|
4765
2458
|
}
|
|
2459
|
+
const permission = status === undefined ? describePermissionError(error) : undefined;
|
|
2460
|
+
if (permission) {
|
|
2461
|
+
if (permission.message !== message && !message.includes(permission.message)) {
|
|
2462
|
+
message = `${message}: ${permission.message}`;
|
|
2463
|
+
}
|
|
2464
|
+
if (!message.includes(permission.instructions)) {
|
|
2465
|
+
const punctuated = message.endsWith(".") ? message : `${message}.`;
|
|
2466
|
+
message = `${punctuated} ${permission.instructions}`;
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
4766
2469
|
let details = rawMessage;
|
|
4767
2470
|
if (rawBody) {
|
|
4768
2471
|
if (parsedBody) {
|
|
@@ -4802,6 +2505,9 @@ async function extractErrorDetails(error, options) {
|
|
|
4802
2505
|
if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
|
|
4803
2506
|
context.traceId = parsedBody.traceId;
|
|
4804
2507
|
}
|
|
2508
|
+
if (permission?.path !== undefined) {
|
|
2509
|
+
context.path = permission.path;
|
|
2510
|
+
}
|
|
4805
2511
|
if (status === 429) {
|
|
4806
2512
|
const resp = response;
|
|
4807
2513
|
const headersObj = resp?.headers;
|
|
@@ -6035,6 +3741,7 @@ var CLI_ERROR_CODES = [
|
|
|
6035
3741
|
"invalid_argument",
|
|
6036
3742
|
"authentication_required",
|
|
6037
3743
|
"permission_denied",
|
|
3744
|
+
"local_permission_denied",
|
|
6038
3745
|
"not_found",
|
|
6039
3746
|
"rate_limited",
|
|
6040
3747
|
"network_error",
|
|
@@ -6470,12 +4177,16 @@ function defaultErrorCodeForHttpStatus(status) {
|
|
|
6470
4177
|
return "server_error";
|
|
6471
4178
|
return;
|
|
6472
4179
|
}
|
|
4180
|
+
var LOCAL_PERMISSION_TEXT_PATTERN = /(?:\b|\()(?:EACCES|EPERM|EROFS)(?::\s|\))/;
|
|
6473
4181
|
function defaultErrorCodeForFailure(data) {
|
|
6474
4182
|
if (data.Result === RESULTS.Failure) {
|
|
6475
4183
|
const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
|
|
6476
4184
|
const errorCode = defaultErrorCodeForHttpStatus(status);
|
|
6477
4185
|
if (errorCode)
|
|
6478
4186
|
return errorCode;
|
|
4187
|
+
if (status === undefined && (LOCAL_PERMISSION_TEXT_PATTERN.test(data.Message) || LOCAL_PERMISSION_TEXT_PATTERN.test(data.Instructions))) {
|
|
4188
|
+
return "local_permission_denied";
|
|
4189
|
+
}
|
|
6479
4190
|
}
|
|
6480
4191
|
return defaultErrorCodeForResult(data.Result);
|
|
6481
4192
|
}
|
|
@@ -7513,11 +5224,10 @@ function installRequestHeaderForwarding(BaseApiClass, patchKey, forward) {
|
|
|
7513
5224
|
function installSdkUserAgentHeader(BaseApiClass, userAgent) {
|
|
7514
5225
|
installRequestHeaderForwarding(BaseApiClass, userAgentPatchKey(userAgent), (headers) => addSdkUserAgentHeader(headers, userAgent));
|
|
7515
5226
|
}
|
|
7516
|
-
// ../common/src/tool-provider.ts
|
|
7517
|
-
var factorySlot = singleton("PackagerFactoryProvider");
|
|
7518
|
-
var moduleSlot = singleton("ToolModuleProvider");
|
|
7519
5227
|
// ../common/src/telemetry/ship-succeeded.ts
|
|
7520
5228
|
var shippedKeysSlot = singleton("ShipSucceededDedupeKeys");
|
|
5229
|
+
// ../common/src/tool-provider.ts
|
|
5230
|
+
var factorySlot = singleton("PackagerFactoryProvider");
|
|
7521
5231
|
// ../integrationservice-sdk/generated/connections/src/runtime.ts
|
|
7522
5232
|
var BASE_PATH = "https://alpha.uipath.com/entity/Azure/connections_".replace(/\/+$/, "");
|
|
7523
5233
|
|
|
@@ -8048,7 +5758,7 @@ class TextApiResponse {
|
|
|
8048
5758
|
var package_default2 = {
|
|
8049
5759
|
name: "@uipath/integrationservice-sdk",
|
|
8050
5760
|
license: "MIT",
|
|
8051
|
-
version: "1.201.0-preview.
|
|
5761
|
+
version: "1.201.0-preview.121",
|
|
8052
5762
|
repository: {
|
|
8053
5763
|
type: "git",
|
|
8054
5764
|
url: "https://github.com/UiPath/cli.git",
|
|
@@ -8089,7 +5799,7 @@ var package_default2 = {
|
|
|
8089
5799
|
typescript: "^7.0.2"
|
|
8090
5800
|
},
|
|
8091
5801
|
dependencies: {
|
|
8092
|
-
"@uipath/integration-service-design-time": "0.
|
|
5802
|
+
"@uipath/integration-service-design-time": "0.25.2"
|
|
8093
5803
|
}
|
|
8094
5804
|
};
|
|
8095
5805
|
|
|
@@ -15061,6 +12771,16 @@ var getAuthContext = async (options = {}) => {
|
|
|
15061
12771
|
};
|
|
15062
12772
|
};
|
|
15063
12773
|
// ../auth/src/tenantSelection.ts
|
|
12774
|
+
var LOGIN_STATUS_HINT = "Run 'uip login status' to see the organization the CLI is signed in to.";
|
|
12775
|
+
var organizationHint = (organizationId) => `The request used '${organizationId}' as the organization. ${LOGIN_STATUS_HINT}`;
|
|
12776
|
+
var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
|
|
12777
|
+
var describeNonJsonResponse = (organizationId, response, parseError) => {
|
|
12778
|
+
if (response.redirected) {
|
|
12779
|
+
return `Could not find organization '${organizationId}': the request was ` + `redirected to a sign-in page instead of the organization's tenant ` + `list. ${LOGIN_STATUS_HINT}`;
|
|
12780
|
+
}
|
|
12781
|
+
const contentType = response.headers.get("content-type") ?? "unknown";
|
|
12782
|
+
return `The organization service returned a '${contentType}' response instead ` + `of JSON: ${parseError.message}. ${organizationHint(organizationId)}`;
|
|
12783
|
+
};
|
|
15064
12784
|
var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId) => {
|
|
15065
12785
|
const url = `${baseUrl}/${organizationId}/portal_/api/filtering/leftnav/tenantsAndOrganizationInfo`;
|
|
15066
12786
|
const response = await fetch(url, {
|
|
@@ -15070,12 +12790,16 @@ var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId)
|
|
|
15070
12790
|
});
|
|
15071
12791
|
if (!response.ok) {
|
|
15072
12792
|
if (response.status === 401) {
|
|
15073
|
-
throw new Error(
|
|
12793
|
+
throw new Error(`Unauthorized: the access token was rejected, it was not ` + `issued for organization '${organizationId}', or ` + `'${organizationId}' was not accepted as an organization ` + `URL segment in this environment. ` + LOGIN_STATUS_HINT);
|
|
15074
12794
|
}
|
|
15075
12795
|
const errorText = await response.text();
|
|
15076
|
-
|
|
12796
|
+
const message = `Failed to get tenants and organizations: ${response.status} ${errorText}`;
|
|
12797
|
+
throw new Error(IDENTIFIER_STATUSES.has(response.status) ? `${message}. ${organizationHint(organizationId)}` : message);
|
|
12798
|
+
}
|
|
12799
|
+
const [parseError, data] = await catchError(response.json());
|
|
12800
|
+
if (parseError) {
|
|
12801
|
+
throw new Error(describeNonJsonResponse(organizationId, response, parseError));
|
|
15077
12802
|
}
|
|
15078
|
-
const data = await response.json();
|
|
15079
12803
|
return data;
|
|
15080
12804
|
};
|
|
15081
12805
|
|
|
@@ -15642,7 +13366,7 @@ async function resolveTenantId(tenantName) {
|
|
|
15642
13366
|
if (!status.baseUrl || !status.accessToken || !status.organizationId) {
|
|
15643
13367
|
throw new Error("Not logged in. Run 'uip login' first.");
|
|
15644
13368
|
}
|
|
15645
|
-
const { tenants } = await fetchTenantsAndOrganizations(status.baseUrl, status.accessToken, status.organizationId);
|
|
13369
|
+
const { tenants } = await fetchTenantsAndOrganizations(status.baseUrl, status.accessToken, status.organizationName || status.organizationId);
|
|
15646
13370
|
const match = tenants.find((t) => t.name === tenantName);
|
|
15647
13371
|
if (!match) {
|
|
15648
13372
|
throw new Error(`Tenant '${tenantName}' not found.`);
|
|
@@ -15735,9 +13459,12 @@ async function writeConnections(connectorKey, connections, folderKey, tenantName
|
|
|
15735
13459
|
connectorKey: c.connector?.key,
|
|
15736
13460
|
connectorName: c.connector?.name,
|
|
15737
13461
|
isDefault: c.isDefault,
|
|
13462
|
+
byoaConnection: c.byoaConnection,
|
|
13463
|
+
elementInstanceId: c.elementInstanceId,
|
|
15738
13464
|
folderName: c.folder?.name,
|
|
15739
13465
|
folderKey: c.folder?.key,
|
|
15740
|
-
createTime: c.createTime
|
|
13466
|
+
createTime: c.createTime,
|
|
13467
|
+
updateTime: c.updateTime
|
|
15741
13468
|
}));
|
|
15742
13469
|
await writeJson(await buildPath([connectorKey, connectionsFile(folderKey, allFolders)], tenantName), compact);
|
|
15743
13470
|
}
|
|
@@ -15942,6 +13669,8 @@ function formatConnectionList(connections) {
|
|
|
15942
13669
|
}));
|
|
15943
13670
|
}
|
|
15944
13671
|
function buildDisabledWarning(connections) {
|
|
13672
|
+
if (connections.length === 0)
|
|
13673
|
+
return;
|
|
15945
13674
|
const disabled = connections.filter((c) => c.state !== "Enabled" && c.state !== "enabled");
|
|
15946
13675
|
if (disabled.length === connections.length) {
|
|
15947
13676
|
return "All connections are not enabled. Run 'uip is connections edit <connection-id>' to re-authenticate, or 'uip is connections create <connector-key>' to create a new connection.";
|
|
@@ -16037,12 +13766,34 @@ var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
|
16037
13766
|
var LIST_CONNECTIONS_AUTH_INSTRUCTIONS = "Run 'uip login' to authenticate, then use 'uip login tenant set <tenant>' if you need to switch tenants.";
|
|
16038
13767
|
var LIST_CONNECTIONS_API_INSTRUCTIONS = "Verify the connector key and folder key, then retry. Use 'uip is connections list --help' for accepted options.";
|
|
16039
13768
|
var INVALID_CONNECTOR_KEY_INSTRUCTIONS = "Verify the connector key. Run 'uip is connectors list' to see available connectors.";
|
|
16040
|
-
var PERSONAL_WORKSPACE_UNAVAILABLE_INSTRUCTIONS = "Personal workspace is not configured on this tenant. Run 'uip is connections list --folder <folder-key>' against a shared folder, or contact your administrator.";
|
|
13769
|
+
var PERSONAL_WORKSPACE_UNAVAILABLE_INSTRUCTIONS = "Personal workspace is not configured on this tenant. Run 'uip is connections list --folder-key <folder-key>' against a shared folder, or contact your administrator.";
|
|
16041
13770
|
var CNS_CONNECTOR_KEY_INVALID = "CNS1001";
|
|
16042
13771
|
var CNS_NOT_FOUND = "CNS1049";
|
|
16043
13772
|
var EXPORT_CONNECTIONS_API_INSTRUCTIONS = "Verify the tenant and retry. Use 'uip is connections export --help' for accepted options.";
|
|
16044
13773
|
var CONNECTIONS_CONFIG_ERROR_INSTRUCTIONS = "Run 'uip login' and retry. Use 'uip login tenant set <tenant>' to switch tenants, or set UIPATH_TENANT_NAME for environment authentication.";
|
|
16045
13774
|
var CONNECTIONS_UPDATE_POLLING_INTERVAL_ERROR_INSTRUCTIONS = "Verify the connection ID with 'uip is connections list --refresh', confirm --polling-interval is supported for the connection, and retry.";
|
|
13775
|
+
var DELETE_CONNECTIONS_API_INSTRUCTIONS = "Run 'uip is connections list --all-folders' to find the connection and verify its ID, then retry.";
|
|
13776
|
+
var CONNECTION_NOT_FOUND_INSTRUCTIONS = "Run 'uip is connections list --all-folders' to see available connections.";
|
|
13777
|
+
function extractConnectionFolderKey(connection) {
|
|
13778
|
+
const conn = connection;
|
|
13779
|
+
const key = conn.folder?.key || conn.folderKey || "";
|
|
13780
|
+
return typeof key === "string" ? key : "";
|
|
13781
|
+
}
|
|
13782
|
+
var CONNECTIONS_FETCH_PAGE_SIZE = 200;
|
|
13783
|
+
async function fetchAllConnections(api) {
|
|
13784
|
+
const all = [];
|
|
13785
|
+
for (let pageIndex = 0;; pageIndex++) {
|
|
13786
|
+
const page = await api.apiV1ConnectionsGet({
|
|
13787
|
+
allFolders: true,
|
|
13788
|
+
pageIndex,
|
|
13789
|
+
pageSize: CONNECTIONS_FETCH_PAGE_SIZE
|
|
13790
|
+
});
|
|
13791
|
+
all.push(...page);
|
|
13792
|
+
if (page.length < CONNECTIONS_FETCH_PAGE_SIZE) {
|
|
13793
|
+
return all;
|
|
13794
|
+
}
|
|
13795
|
+
}
|
|
13796
|
+
}
|
|
16046
13797
|
async function emitListConnectionsFailure(fetchError) {
|
|
16047
13798
|
const { message, details, context } = await extractErrorDetails(fetchError);
|
|
16048
13799
|
if (context?.errorCode === CNS_CONNECTOR_KEY_INVALID) {
|
|
@@ -16081,6 +13832,37 @@ function appendListConnectionsHint(details, hint) {
|
|
|
16081
13832
|
|
|
16082
13833
|
Details: ${normalizedDetails}`;
|
|
16083
13834
|
}
|
|
13835
|
+
function describeConnectionListScope(folderKey, allFolders) {
|
|
13836
|
+
if (allFolders)
|
|
13837
|
+
return "all folders";
|
|
13838
|
+
if (folderKey !== undefined)
|
|
13839
|
+
return `folder '${folderKey}'`;
|
|
13840
|
+
return "default Integration Service scope";
|
|
13841
|
+
}
|
|
13842
|
+
function buildNoConnectionsInstructions(args) {
|
|
13843
|
+
const scope = describeConnectionListScope(args.folderKey, args.allFolders);
|
|
13844
|
+
if (args.connectionId && args.connectionIdEmptiedList) {
|
|
13845
|
+
const refreshHint = args.loadedFromCache ? " Run with --refresh to fetch current connections." : "";
|
|
13846
|
+
const scopeHint = args.allFolders ? "" : " Use --all-folders to search across all folders.";
|
|
13847
|
+
return `No connections found for connection ID '${args.connectionId}'. Scope: ${scope}. Verify the connection ID.${refreshHint}${scopeHint}`;
|
|
13848
|
+
}
|
|
13849
|
+
if (args.byoa && args.byoaEmptiedList) {
|
|
13850
|
+
const cacheHint = args.loadedFromCache ? " Results came from cache; run with --refresh to fetch current connection details before applying --byoa." : " Remove --byoa to list all connections in this scope.";
|
|
13851
|
+
return `No BYOA connections found for ${args.context}. Scope: ${scope}.${cacheHint}`;
|
|
13852
|
+
}
|
|
13853
|
+
const hints = [];
|
|
13854
|
+
if (args.connectorKey) {
|
|
13855
|
+
hints.push("Check the connector key with 'uip is connectors list'.");
|
|
13856
|
+
}
|
|
13857
|
+
if (args.loadedFromCache) {
|
|
13858
|
+
hints.push("Run with --refresh to fetch current connections.");
|
|
13859
|
+
}
|
|
13860
|
+
if (!args.allFolders) {
|
|
13861
|
+
hints.push("Use --all-folders to search across all folders.");
|
|
13862
|
+
}
|
|
13863
|
+
const suffix = hints.length > 0 ? ` ${hints.join(" ")}` : "";
|
|
13864
|
+
return `No connections found for ${args.context}. Scope: ${scope}.${suffix}`;
|
|
13865
|
+
}
|
|
16084
13866
|
var CONNECTIONS_LIST_EXAMPLES = [
|
|
16085
13867
|
{
|
|
16086
13868
|
Description: "List connections for a connector",
|
|
@@ -16255,7 +14037,7 @@ function resolveFolderKey(options) {
|
|
|
16255
14037
|
}
|
|
16256
14038
|
var registerConnectionsCommand = (program2) => {
|
|
16257
14039
|
const connections = program2.command("connections").description("Manage UiPath Integration Service connections");
|
|
16258
|
-
connections.command("list").description("List connections").argument("[connector-key]", "Connector key to filter by").option("--folder-key <key>", "
|
|
14040
|
+
connections.command("list").description("List connections in the default Integration Service scope. Use --all-folders to search across all folders.").argument("[connector-key]", "Connector key to filter by").option("--folder-key <key>", "Search connections in a specific folder").addOption(new Option("--folder <key>").hideHelp()).option("--connection-id <id>", "Filter to a specific connection ID").option("--byoa", "Filter to BYOA (Bring Your Own Account) connections only").option("--all-folders", "Search connections across all folders instead of the default scope (cannot be combined with --folder/--folder-key)").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).option("--refresh", "Force re-fetch from API, ignoring cache").examples(CONNECTIONS_LIST_EXAMPLES).trackedAction(processContext, async (connectorKey, options) => {
|
|
16259
14041
|
const { folderKey, hasError } = resolveFolderKey(options);
|
|
16260
14042
|
if (hasError) {
|
|
16261
14043
|
return;
|
|
@@ -16290,11 +14072,14 @@ var registerConnectionsCommand = (program2) => {
|
|
|
16290
14072
|
return;
|
|
16291
14073
|
}
|
|
16292
14074
|
let data = null;
|
|
14075
|
+
let loadedFromCache = false;
|
|
16293
14076
|
if (connectorKey) {
|
|
16294
14077
|
if (!options.refresh) {
|
|
16295
14078
|
data = await readConnections(connectorKey, folderKey, options.tenant, options.allFolders);
|
|
16296
|
-
if (data)
|
|
14079
|
+
if (data) {
|
|
14080
|
+
loadedFromCache = true;
|
|
16297
14081
|
logger.info(`Loaded ${data.length} connections from cache`);
|
|
14082
|
+
}
|
|
16298
14083
|
}
|
|
16299
14084
|
if (!data) {
|
|
16300
14085
|
const api = new ConnectorsApi(config);
|
|
@@ -16307,6 +14092,7 @@ var registerConnectionsCommand = (program2) => {
|
|
|
16307
14092
|
return;
|
|
16308
14093
|
}
|
|
16309
14094
|
data = fetched;
|
|
14095
|
+
loadedFromCache = false;
|
|
16310
14096
|
if (data && data.length > 0) {
|
|
16311
14097
|
await writeConnections(connectorKey, data, folderKey, options.tenant, options.allFolders);
|
|
16312
14098
|
}
|
|
@@ -16320,32 +14106,36 @@ var registerConnectionsCommand = (program2) => {
|
|
|
16320
14106
|
}
|
|
16321
14107
|
data = fetched;
|
|
16322
14108
|
}
|
|
16323
|
-
|
|
16324
|
-
|
|
16325
|
-
|
|
16326
|
-
|
|
16327
|
-
|
|
16328
|
-
|
|
16329
|
-
|
|
16330
|
-
|
|
16331
|
-
|
|
16332
|
-
|
|
16333
|
-
|
|
16334
|
-
|
|
16335
|
-
|
|
16336
|
-
|
|
16337
|
-
|
|
16338
|
-
|
|
16339
|
-
|
|
16340
|
-
|
|
16341
|
-
|
|
16342
|
-
|
|
16343
|
-
|
|
16344
|
-
|
|
16345
|
-
|
|
16346
|
-
|
|
16347
|
-
|
|
16348
|
-
}
|
|
14109
|
+
const connectionsBeforeFilters = data ?? [];
|
|
14110
|
+
let filtered = connectionsBeforeFilters;
|
|
14111
|
+
let connectionIdEmptiedList = false;
|
|
14112
|
+
let byoaEmptiedList = false;
|
|
14113
|
+
if (options.connectionId) {
|
|
14114
|
+
filtered = filtered.filter((c) => c.id === options.connectionId);
|
|
14115
|
+
connectionIdEmptiedList = connectionsBeforeFilters.length > 0 && filtered.length === 0;
|
|
14116
|
+
}
|
|
14117
|
+
if (options.byoa) {
|
|
14118
|
+
const connectionsBeforeByoaFilter = filtered;
|
|
14119
|
+
filtered = filtered.filter((c) => c.byoaConnection === true);
|
|
14120
|
+
byoaEmptiedList = connectionsBeforeByoaFilter.length > 0 && filtered.length === 0;
|
|
14121
|
+
}
|
|
14122
|
+
const context = options.connectionId ? `connection ID '${options.connectionId}'` : connectorKey ? `connector '${connectorKey}'` : "any connector";
|
|
14123
|
+
const formatted = formatConnectionList(filtered);
|
|
14124
|
+
const emptyInstructions = formatted.length === 0 ? buildNoConnectionsInstructions({
|
|
14125
|
+
context,
|
|
14126
|
+
connectorKey,
|
|
14127
|
+
folderKey,
|
|
14128
|
+
allFolders: options.allFolders,
|
|
14129
|
+
connectionId: options.connectionId,
|
|
14130
|
+
byoa: options.byoa,
|
|
14131
|
+
loadedFromCache,
|
|
14132
|
+
connectionIdEmptiedList,
|
|
14133
|
+
byoaEmptiedList
|
|
14134
|
+
}) : undefined;
|
|
14135
|
+
OutputFormatter.emitList("ConnectionList", formatted, {
|
|
14136
|
+
emptyInstructions,
|
|
14137
|
+
warning: buildDisabledWarning(filtered)
|
|
14138
|
+
});
|
|
16349
14139
|
});
|
|
16350
14140
|
connections.command("export").description("Export connections for audit").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).examples(CONNECTIONS_EXPORT_EXAMPLES).trackedAction(processContext, async (options) => {
|
|
16351
14141
|
logger.info("Exporting connections");
|
|
@@ -16360,8 +14150,30 @@ var registerConnectionsCommand = (program2) => {
|
|
|
16360
14150
|
return;
|
|
16361
14151
|
}
|
|
16362
14152
|
const api = new ConnectionsApi(config);
|
|
14153
|
+
const [fetchError, existingConnections] = await catchError2(fetchAllConnections(api));
|
|
14154
|
+
if (fetchError) {
|
|
14155
|
+
const msg = await extractErrorMessage(fetchError);
|
|
14156
|
+
OutputFormatter.error({
|
|
14157
|
+
Result: RESULTS.Failure,
|
|
14158
|
+
Message: msg,
|
|
14159
|
+
Instructions: appendListConnectionsHint(fetchError.message, EXPORT_CONNECTIONS_API_INSTRUCTIONS)
|
|
14160
|
+
});
|
|
14161
|
+
processContext.exit(1);
|
|
14162
|
+
return;
|
|
14163
|
+
}
|
|
14164
|
+
const connectionIds = existingConnections.map((c) => c.id).filter((id) => typeof id === "string" && id.length > 0);
|
|
14165
|
+
if (connectionIds.length === 0) {
|
|
14166
|
+
OutputFormatter.success({
|
|
14167
|
+
Result: RESULTS.Success,
|
|
14168
|
+
Code: "Message",
|
|
14169
|
+
Data: {
|
|
14170
|
+
Message: "No connections found to export."
|
|
14171
|
+
}
|
|
14172
|
+
});
|
|
14173
|
+
return;
|
|
14174
|
+
}
|
|
16363
14175
|
const [exportError, result] = await catchError2(api.apiV1ConnectionsExportPost({
|
|
16364
|
-
retrieveBulkConnectionRequest: {}
|
|
14176
|
+
retrieveBulkConnectionRequest: { connectionIds }
|
|
16365
14177
|
}));
|
|
16366
14178
|
if (exportError) {
|
|
16367
14179
|
const msg = await extractErrorMessage(exportError);
|
|
@@ -16551,13 +14363,28 @@ var registerConnectionsCommand = (program2) => {
|
|
|
16551
14363
|
return;
|
|
16552
14364
|
}
|
|
16553
14365
|
const api = new ConnectionsApi(config);
|
|
16554
|
-
const [
|
|
14366
|
+
const [fetchError, existingConnections] = await catchError2(fetchAllConnections(api));
|
|
14367
|
+
let folderKey = "";
|
|
14368
|
+
if (!fetchError) {
|
|
14369
|
+
const connection = existingConnections.find((c) => c.id === connectionId);
|
|
14370
|
+
if (!connection) {
|
|
14371
|
+
OutputFormatter.error({
|
|
14372
|
+
Result: RESULTS.Failure,
|
|
14373
|
+
Message: `Connection '${connectionId}' not found.`,
|
|
14374
|
+
Instructions: CONNECTION_NOT_FOUND_INSTRUCTIONS
|
|
14375
|
+
});
|
|
14376
|
+
processContext.exit(1);
|
|
14377
|
+
return;
|
|
14378
|
+
}
|
|
14379
|
+
folderKey = extractConnectionFolderKey(connection);
|
|
14380
|
+
}
|
|
14381
|
+
const [deleteError] = await catchError2(api.apiV1ConnectionsConnectionIdDelete({ connectionId }, folderOverride(folderKey)));
|
|
16555
14382
|
if (deleteError) {
|
|
16556
14383
|
const msg = await extractErrorMessage(deleteError);
|
|
16557
14384
|
OutputFormatter.error({
|
|
16558
14385
|
Result: RESULTS.Failure,
|
|
16559
14386
|
Message: msg,
|
|
16560
|
-
Instructions: appendListConnectionsHint(deleteError.message,
|
|
14387
|
+
Instructions: appendListConnectionsHint(deleteError.message, DELETE_CONNECTIONS_API_INSTRUCTIONS)
|
|
16561
14388
|
});
|
|
16562
14389
|
processContext.exit(1);
|
|
16563
14390
|
return;
|
|
@@ -17365,8 +15192,919 @@ function sleep(ms) {
|
|
|
17365
15192
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
17366
15193
|
}
|
|
17367
15194
|
|
|
15195
|
+
// ../../node_modules/fflate/esm/index.mjs
|
|
15196
|
+
import { createRequire } from "module";
|
|
15197
|
+
var require2 = createRequire("/");
|
|
15198
|
+
var _a;
|
|
15199
|
+
var Worker;
|
|
15200
|
+
var isMarkedAsUntransferable;
|
|
15201
|
+
try {
|
|
15202
|
+
_a = require2("worker_threads"), Worker = _a.Worker, isMarkedAsUntransferable = _a.isMarkedAsUntransferable;
|
|
15203
|
+
} catch (e) {}
|
|
15204
|
+
var u8 = Uint8Array;
|
|
15205
|
+
var u16 = Uint16Array;
|
|
15206
|
+
var i32 = Int32Array;
|
|
15207
|
+
var fleb = new u8([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0, 0]);
|
|
15208
|
+
var fdeb = new u8([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 0, 0]);
|
|
15209
|
+
var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
|
|
15210
|
+
var freb = function(eb, start) {
|
|
15211
|
+
var b = new u16(31);
|
|
15212
|
+
for (var i = 0;i < 31; ++i) {
|
|
15213
|
+
b[i] = start += 1 << eb[i - 1];
|
|
15214
|
+
}
|
|
15215
|
+
var r = new i32(b[30]);
|
|
15216
|
+
for (var i = 1;i < 30; ++i) {
|
|
15217
|
+
for (var j = b[i];j < b[i + 1]; ++j) {
|
|
15218
|
+
r[j] = j - b[i] << 5 | i;
|
|
15219
|
+
}
|
|
15220
|
+
}
|
|
15221
|
+
return { b, r };
|
|
15222
|
+
};
|
|
15223
|
+
var _a = freb(fleb, 2);
|
|
15224
|
+
var fl = _a.b;
|
|
15225
|
+
var revfl = _a.r;
|
|
15226
|
+
fl[28] = 258, revfl[258] = 28;
|
|
15227
|
+
var _b = freb(fdeb, 0);
|
|
15228
|
+
var fd = _b.b;
|
|
15229
|
+
var revfd = _b.r;
|
|
15230
|
+
var rev = new u16(32768);
|
|
15231
|
+
for (i = 0;i < 32768; ++i) {
|
|
15232
|
+
x = (i & 43690) >> 1 | (i & 21845) << 1;
|
|
15233
|
+
x = (x & 52428) >> 2 | (x & 13107) << 2;
|
|
15234
|
+
x = (x & 61680) >> 4 | (x & 3855) << 4;
|
|
15235
|
+
rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1;
|
|
15236
|
+
}
|
|
15237
|
+
var x;
|
|
15238
|
+
var i;
|
|
15239
|
+
var hMap = function(cd, mb, r) {
|
|
15240
|
+
var s = cd.length;
|
|
15241
|
+
var i2 = 0;
|
|
15242
|
+
var l = new u16(mb);
|
|
15243
|
+
for (;i2 < s; ++i2) {
|
|
15244
|
+
if (cd[i2])
|
|
15245
|
+
++l[cd[i2] - 1];
|
|
15246
|
+
}
|
|
15247
|
+
var le = new u16(mb);
|
|
15248
|
+
for (i2 = 1;i2 < mb; ++i2) {
|
|
15249
|
+
le[i2] = le[i2 - 1] + l[i2 - 1] << 1;
|
|
15250
|
+
}
|
|
15251
|
+
var co;
|
|
15252
|
+
if (r) {
|
|
15253
|
+
co = new u16(1 << mb);
|
|
15254
|
+
var rvb = 15 - mb;
|
|
15255
|
+
for (i2 = 0;i2 < s; ++i2) {
|
|
15256
|
+
if (cd[i2]) {
|
|
15257
|
+
var sv = i2 << 4 | cd[i2];
|
|
15258
|
+
var r_1 = mb - cd[i2];
|
|
15259
|
+
var v = le[cd[i2] - 1]++ << r_1;
|
|
15260
|
+
for (var m = v | (1 << r_1) - 1;v <= m; ++v) {
|
|
15261
|
+
co[rev[v] >> rvb] = sv;
|
|
15262
|
+
}
|
|
15263
|
+
}
|
|
15264
|
+
}
|
|
15265
|
+
} else {
|
|
15266
|
+
co = new u16(s);
|
|
15267
|
+
for (i2 = 0;i2 < s; ++i2) {
|
|
15268
|
+
if (cd[i2]) {
|
|
15269
|
+
co[i2] = rev[le[cd[i2] - 1]++] >> 15 - cd[i2];
|
|
15270
|
+
}
|
|
15271
|
+
}
|
|
15272
|
+
}
|
|
15273
|
+
return co;
|
|
15274
|
+
};
|
|
15275
|
+
var flt = new u8(288);
|
|
15276
|
+
for (i = 0;i < 144; ++i)
|
|
15277
|
+
flt[i] = 8;
|
|
15278
|
+
var i;
|
|
15279
|
+
for (i = 144;i < 256; ++i)
|
|
15280
|
+
flt[i] = 9;
|
|
15281
|
+
var i;
|
|
15282
|
+
for (i = 256;i < 280; ++i)
|
|
15283
|
+
flt[i] = 7;
|
|
15284
|
+
var i;
|
|
15285
|
+
for (i = 280;i < 288; ++i)
|
|
15286
|
+
flt[i] = 8;
|
|
15287
|
+
var i;
|
|
15288
|
+
var fdt = new u8(32);
|
|
15289
|
+
for (i = 0;i < 32; ++i)
|
|
15290
|
+
fdt[i] = 5;
|
|
15291
|
+
var i;
|
|
15292
|
+
var flm = /* @__PURE__ */ hMap(flt, 9, 0);
|
|
15293
|
+
var flrm = /* @__PURE__ */ hMap(flt, 9, 1);
|
|
15294
|
+
var fdm = /* @__PURE__ */ hMap(fdt, 5, 0);
|
|
15295
|
+
var fdrm = /* @__PURE__ */ hMap(fdt, 5, 1);
|
|
15296
|
+
var max = function(a) {
|
|
15297
|
+
var m = a[0];
|
|
15298
|
+
for (var i2 = 1;i2 < a.length; ++i2) {
|
|
15299
|
+
if (a[i2] > m)
|
|
15300
|
+
m = a[i2];
|
|
15301
|
+
}
|
|
15302
|
+
return m;
|
|
15303
|
+
};
|
|
15304
|
+
var bits = function(d, p, m) {
|
|
15305
|
+
var o = p / 8 | 0;
|
|
15306
|
+
return (d[o] | d[o + 1] << 8) >> (p & 7) & m;
|
|
15307
|
+
};
|
|
15308
|
+
var bits16 = function(d, p) {
|
|
15309
|
+
var o = p / 8 | 0;
|
|
15310
|
+
return (d[o] | d[o + 1] << 8 | d[o + 2] << 16) >> (p & 7);
|
|
15311
|
+
};
|
|
15312
|
+
var shft = function(p) {
|
|
15313
|
+
return (p + 7) / 8 | 0;
|
|
15314
|
+
};
|
|
15315
|
+
var slc = function(v, s, e) {
|
|
15316
|
+
if (s == null || s < 0)
|
|
15317
|
+
s = 0;
|
|
15318
|
+
if (e == null || e > v.length)
|
|
15319
|
+
e = v.length;
|
|
15320
|
+
return new u8(v.subarray(s, e));
|
|
15321
|
+
};
|
|
15322
|
+
var ec = [
|
|
15323
|
+
"unexpected EOF",
|
|
15324
|
+
"invalid block type",
|
|
15325
|
+
"invalid length/literal",
|
|
15326
|
+
"invalid distance",
|
|
15327
|
+
"stream finished",
|
|
15328
|
+
"no stream handler",
|
|
15329
|
+
,
|
|
15330
|
+
"no callback",
|
|
15331
|
+
"invalid UTF-8 data",
|
|
15332
|
+
"extra field too long",
|
|
15333
|
+
"date not in range 1980-2099",
|
|
15334
|
+
"filename too long",
|
|
15335
|
+
"stream finishing",
|
|
15336
|
+
"invalid zip data"
|
|
15337
|
+
];
|
|
15338
|
+
var err = function(ind, msg, nt) {
|
|
15339
|
+
var e = new Error(msg || ec[ind]);
|
|
15340
|
+
e.code = ind;
|
|
15341
|
+
if (Error.captureStackTrace)
|
|
15342
|
+
Error.captureStackTrace(e, err);
|
|
15343
|
+
if (!nt)
|
|
15344
|
+
throw e;
|
|
15345
|
+
return e;
|
|
15346
|
+
};
|
|
15347
|
+
var inflt = function(dat, st, buf, dict) {
|
|
15348
|
+
var sl = dat.length, dl = dict ? dict.length : 0;
|
|
15349
|
+
if (!sl || st.f && !st.l)
|
|
15350
|
+
return buf || new u8(0);
|
|
15351
|
+
var noBuf = !buf;
|
|
15352
|
+
var resize = noBuf || st.i != 2;
|
|
15353
|
+
var noSt = st.i;
|
|
15354
|
+
if (noBuf)
|
|
15355
|
+
buf = new u8(sl * 3);
|
|
15356
|
+
var cbuf = function(l2) {
|
|
15357
|
+
var bl = buf.length;
|
|
15358
|
+
if (l2 > bl) {
|
|
15359
|
+
var nbuf = new u8(Math.max(bl * 2, l2));
|
|
15360
|
+
nbuf.set(buf);
|
|
15361
|
+
buf = nbuf;
|
|
15362
|
+
}
|
|
15363
|
+
};
|
|
15364
|
+
var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
|
|
15365
|
+
var tbts = sl * 8;
|
|
15366
|
+
do {
|
|
15367
|
+
if (!lm) {
|
|
15368
|
+
final = bits(dat, pos, 1);
|
|
15369
|
+
var type = bits(dat, pos + 1, 3);
|
|
15370
|
+
pos += 3;
|
|
15371
|
+
if (!type) {
|
|
15372
|
+
var s = shft(pos) + 4, l = dat[s - 4] | dat[s - 3] << 8, t = s + l;
|
|
15373
|
+
if (t > sl) {
|
|
15374
|
+
if (noSt)
|
|
15375
|
+
err(0);
|
|
15376
|
+
break;
|
|
15377
|
+
}
|
|
15378
|
+
if (resize)
|
|
15379
|
+
cbuf(bt + l);
|
|
15380
|
+
buf.set(dat.subarray(s, t), bt);
|
|
15381
|
+
st.b = bt += l, st.p = pos = t * 8, st.f = final;
|
|
15382
|
+
continue;
|
|
15383
|
+
} else if (type == 1)
|
|
15384
|
+
lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
|
|
15385
|
+
else if (type == 2) {
|
|
15386
|
+
var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
|
|
15387
|
+
var tl = hLit + bits(dat, pos + 5, 31) + 1;
|
|
15388
|
+
pos += 14;
|
|
15389
|
+
var ldt = new u8(tl);
|
|
15390
|
+
var clt = new u8(19);
|
|
15391
|
+
for (var i2 = 0;i2 < hcLen; ++i2) {
|
|
15392
|
+
clt[clim[i2]] = bits(dat, pos + i2 * 3, 7);
|
|
15393
|
+
}
|
|
15394
|
+
pos += hcLen * 3;
|
|
15395
|
+
var clb = max(clt), clbmsk = (1 << clb) - 1;
|
|
15396
|
+
var clm = hMap(clt, clb, 1);
|
|
15397
|
+
for (var i2 = 0;i2 < tl; ) {
|
|
15398
|
+
var r = clm[bits(dat, pos, clbmsk)];
|
|
15399
|
+
pos += r & 15;
|
|
15400
|
+
var s = r >> 4;
|
|
15401
|
+
if (s < 16) {
|
|
15402
|
+
ldt[i2++] = s;
|
|
15403
|
+
} else {
|
|
15404
|
+
var c = 0, n = 0;
|
|
15405
|
+
if (s == 16)
|
|
15406
|
+
n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i2 - 1];
|
|
15407
|
+
else if (s == 17)
|
|
15408
|
+
n = 3 + bits(dat, pos, 7), pos += 3;
|
|
15409
|
+
else if (s == 18)
|
|
15410
|
+
n = 11 + bits(dat, pos, 127), pos += 7;
|
|
15411
|
+
while (n--)
|
|
15412
|
+
ldt[i2++] = c;
|
|
15413
|
+
}
|
|
15414
|
+
}
|
|
15415
|
+
var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
|
|
15416
|
+
lbt = max(lt);
|
|
15417
|
+
dbt = max(dt);
|
|
15418
|
+
lm = hMap(lt, lbt, 1);
|
|
15419
|
+
dm = hMap(dt, dbt, 1);
|
|
15420
|
+
} else
|
|
15421
|
+
err(1);
|
|
15422
|
+
if (pos > tbts) {
|
|
15423
|
+
if (noSt)
|
|
15424
|
+
err(0);
|
|
15425
|
+
break;
|
|
15426
|
+
}
|
|
15427
|
+
}
|
|
15428
|
+
if (resize)
|
|
15429
|
+
cbuf(bt + 131072);
|
|
15430
|
+
var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
|
|
15431
|
+
var lpos = pos;
|
|
15432
|
+
for (;; lpos = pos) {
|
|
15433
|
+
var c = lm[bits16(dat, pos) & lms], sym = c >> 4;
|
|
15434
|
+
pos += c & 15;
|
|
15435
|
+
if (pos > tbts) {
|
|
15436
|
+
if (noSt)
|
|
15437
|
+
err(0);
|
|
15438
|
+
break;
|
|
15439
|
+
}
|
|
15440
|
+
if (!c)
|
|
15441
|
+
err(2);
|
|
15442
|
+
if (sym < 256)
|
|
15443
|
+
buf[bt++] = sym;
|
|
15444
|
+
else if (sym == 256) {
|
|
15445
|
+
lpos = pos, lm = null;
|
|
15446
|
+
break;
|
|
15447
|
+
} else {
|
|
15448
|
+
var add = sym - 254;
|
|
15449
|
+
if (sym > 264) {
|
|
15450
|
+
var i2 = sym - 257, b = fleb[i2];
|
|
15451
|
+
add = bits(dat, pos, (1 << b) - 1) + fl[i2];
|
|
15452
|
+
pos += b;
|
|
15453
|
+
}
|
|
15454
|
+
var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;
|
|
15455
|
+
if (!d)
|
|
15456
|
+
err(3);
|
|
15457
|
+
pos += d & 15;
|
|
15458
|
+
var dt = fd[dsym];
|
|
15459
|
+
if (dsym > 3) {
|
|
15460
|
+
var b = fdeb[dsym];
|
|
15461
|
+
dt += bits16(dat, pos) & (1 << b) - 1, pos += b;
|
|
15462
|
+
}
|
|
15463
|
+
if (pos > tbts) {
|
|
15464
|
+
if (noSt)
|
|
15465
|
+
err(0);
|
|
15466
|
+
break;
|
|
15467
|
+
}
|
|
15468
|
+
if (resize)
|
|
15469
|
+
cbuf(bt + 131072);
|
|
15470
|
+
var end = bt + add;
|
|
15471
|
+
if (bt < dt) {
|
|
15472
|
+
var shift = dl - dt, dend = Math.min(dt, end);
|
|
15473
|
+
if (shift + bt < 0)
|
|
15474
|
+
err(3);
|
|
15475
|
+
for (;bt < dend; ++bt)
|
|
15476
|
+
buf[bt] = dict[shift + bt];
|
|
15477
|
+
}
|
|
15478
|
+
for (;bt < end; ++bt)
|
|
15479
|
+
buf[bt] = buf[bt - dt];
|
|
15480
|
+
}
|
|
15481
|
+
}
|
|
15482
|
+
st.l = lm, st.p = lpos, st.b = bt, st.f = final;
|
|
15483
|
+
if (lm)
|
|
15484
|
+
final = 1, st.m = lbt, st.d = dm, st.n = dbt;
|
|
15485
|
+
} while (!final);
|
|
15486
|
+
return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);
|
|
15487
|
+
};
|
|
15488
|
+
var wbits = function(d, p, v) {
|
|
15489
|
+
v <<= p & 7;
|
|
15490
|
+
var o = p / 8 | 0;
|
|
15491
|
+
d[o] |= v;
|
|
15492
|
+
d[o + 1] |= v >> 8;
|
|
15493
|
+
};
|
|
15494
|
+
var wbits16 = function(d, p, v) {
|
|
15495
|
+
v <<= p & 7;
|
|
15496
|
+
var o = p / 8 | 0;
|
|
15497
|
+
d[o] |= v;
|
|
15498
|
+
d[o + 1] |= v >> 8;
|
|
15499
|
+
d[o + 2] |= v >> 16;
|
|
15500
|
+
};
|
|
15501
|
+
var hTree = function(d, mb) {
|
|
15502
|
+
var t = [];
|
|
15503
|
+
for (var i2 = 0;i2 < d.length; ++i2) {
|
|
15504
|
+
if (d[i2])
|
|
15505
|
+
t.push({ s: i2, f: d[i2] });
|
|
15506
|
+
}
|
|
15507
|
+
var s = t.length;
|
|
15508
|
+
var t2 = t.slice();
|
|
15509
|
+
if (!s)
|
|
15510
|
+
return { t: et, l: 0 };
|
|
15511
|
+
if (s == 1) {
|
|
15512
|
+
var v = new u8(t[0].s + 1);
|
|
15513
|
+
v[t[0].s] = 1;
|
|
15514
|
+
return { t: v, l: 1 };
|
|
15515
|
+
}
|
|
15516
|
+
t.sort(function(a, b) {
|
|
15517
|
+
return a.f - b.f;
|
|
15518
|
+
});
|
|
15519
|
+
t.push({ s: -1, f: 25001 });
|
|
15520
|
+
var l = t[0], r = t[1], i0 = 0, i1 = 1, i22 = 2;
|
|
15521
|
+
t[0] = { s: -1, f: l.f + r.f, l, r };
|
|
15522
|
+
while (i1 != s - 1) {
|
|
15523
|
+
l = t[t[i0].f < t[i22].f ? i0++ : i22++];
|
|
15524
|
+
r = t[i0 != i1 && t[i0].f < t[i22].f ? i0++ : i22++];
|
|
15525
|
+
t[i1++] = { s: -1, f: l.f + r.f, l, r };
|
|
15526
|
+
}
|
|
15527
|
+
var maxSym = t2[0].s;
|
|
15528
|
+
for (var i2 = 1;i2 < s; ++i2) {
|
|
15529
|
+
if (t2[i2].s > maxSym)
|
|
15530
|
+
maxSym = t2[i2].s;
|
|
15531
|
+
}
|
|
15532
|
+
var tr = new u16(maxSym + 1);
|
|
15533
|
+
var mbt = ln(t[i1 - 1], tr, 0);
|
|
15534
|
+
if (mbt > mb) {
|
|
15535
|
+
var i2 = 0, dt = 0;
|
|
15536
|
+
var lft = mbt - mb, cst = 1 << lft;
|
|
15537
|
+
t2.sort(function(a, b) {
|
|
15538
|
+
return tr[b.s] - tr[a.s] || a.f - b.f;
|
|
15539
|
+
});
|
|
15540
|
+
for (;i2 < s; ++i2) {
|
|
15541
|
+
var i2_1 = t2[i2].s;
|
|
15542
|
+
if (tr[i2_1] > mb) {
|
|
15543
|
+
dt += cst - (1 << mbt - tr[i2_1]);
|
|
15544
|
+
tr[i2_1] = mb;
|
|
15545
|
+
} else
|
|
15546
|
+
break;
|
|
15547
|
+
}
|
|
15548
|
+
dt >>= lft;
|
|
15549
|
+
while (dt > 0) {
|
|
15550
|
+
var i2_2 = t2[i2].s;
|
|
15551
|
+
if (tr[i2_2] < mb)
|
|
15552
|
+
dt -= 1 << mb - tr[i2_2]++ - 1;
|
|
15553
|
+
else
|
|
15554
|
+
++i2;
|
|
15555
|
+
}
|
|
15556
|
+
for (;i2 >= 0 && dt; --i2) {
|
|
15557
|
+
var i2_3 = t2[i2].s;
|
|
15558
|
+
if (tr[i2_3] == mb) {
|
|
15559
|
+
--tr[i2_3];
|
|
15560
|
+
++dt;
|
|
15561
|
+
}
|
|
15562
|
+
}
|
|
15563
|
+
mbt = mb;
|
|
15564
|
+
}
|
|
15565
|
+
return { t: new u8(tr), l: mbt };
|
|
15566
|
+
};
|
|
15567
|
+
var ln = function(n, l, d) {
|
|
15568
|
+
return n.s == -1 ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1)) : l[n.s] = d;
|
|
15569
|
+
};
|
|
15570
|
+
var lc = function(c) {
|
|
15571
|
+
var s = c.length;
|
|
15572
|
+
while (s && !c[--s])
|
|
15573
|
+
;
|
|
15574
|
+
var cl = new u16(++s);
|
|
15575
|
+
var cli = 0, cln = c[0], cls = 1;
|
|
15576
|
+
var w = function(v) {
|
|
15577
|
+
cl[cli++] = v;
|
|
15578
|
+
};
|
|
15579
|
+
for (var i2 = 1;i2 <= s; ++i2) {
|
|
15580
|
+
if (c[i2] == cln && i2 != s)
|
|
15581
|
+
++cls;
|
|
15582
|
+
else {
|
|
15583
|
+
if (!cln && cls > 2) {
|
|
15584
|
+
for (;cls > 138; cls -= 138)
|
|
15585
|
+
w(32754);
|
|
15586
|
+
if (cls > 2) {
|
|
15587
|
+
w(cls > 10 ? cls - 11 << 5 | 28690 : cls - 3 << 5 | 12305);
|
|
15588
|
+
cls = 0;
|
|
15589
|
+
}
|
|
15590
|
+
} else if (cls > 3) {
|
|
15591
|
+
w(cln), --cls;
|
|
15592
|
+
for (;cls > 6; cls -= 6)
|
|
15593
|
+
w(8304);
|
|
15594
|
+
if (cls > 2)
|
|
15595
|
+
w(cls - 3 << 5 | 8208), cls = 0;
|
|
15596
|
+
}
|
|
15597
|
+
while (cls--)
|
|
15598
|
+
w(cln);
|
|
15599
|
+
cls = 1;
|
|
15600
|
+
cln = c[i2];
|
|
15601
|
+
}
|
|
15602
|
+
}
|
|
15603
|
+
return { c: cl.subarray(0, cli), n: s };
|
|
15604
|
+
};
|
|
15605
|
+
var clen = function(cf, cl) {
|
|
15606
|
+
var l = 0;
|
|
15607
|
+
for (var i2 = 0;i2 < cl.length; ++i2)
|
|
15608
|
+
l += cf[i2] * cl[i2];
|
|
15609
|
+
return l;
|
|
15610
|
+
};
|
|
15611
|
+
var wfblk = function(out, pos, dat) {
|
|
15612
|
+
var s = dat.length;
|
|
15613
|
+
var o = shft(pos + 2);
|
|
15614
|
+
out[o] = s & 255;
|
|
15615
|
+
out[o + 1] = s >> 8;
|
|
15616
|
+
out[o + 2] = out[o] ^ 255;
|
|
15617
|
+
out[o + 3] = out[o + 1] ^ 255;
|
|
15618
|
+
for (var i2 = 0;i2 < s; ++i2)
|
|
15619
|
+
out[o + i2 + 4] = dat[i2];
|
|
15620
|
+
return (o + 4 + s) * 8;
|
|
15621
|
+
};
|
|
15622
|
+
var wblk = function(dat, out, final, syms, lf, df, eb, li, bs, bl, p) {
|
|
15623
|
+
wbits(out, p++, final);
|
|
15624
|
+
++lf[256];
|
|
15625
|
+
var _a2 = hTree(lf, 15), dlt = _a2.t, mlb = _a2.l;
|
|
15626
|
+
var _b2 = hTree(df, 15), ddt = _b2.t, mdb = _b2.l;
|
|
15627
|
+
var _c = lc(dlt), lclt = _c.c, nlc = _c.n;
|
|
15628
|
+
var _d = lc(ddt), lcdt = _d.c, ndc = _d.n;
|
|
15629
|
+
var lcfreq = new u16(19);
|
|
15630
|
+
for (var i2 = 0;i2 < lclt.length; ++i2)
|
|
15631
|
+
++lcfreq[lclt[i2] & 31];
|
|
15632
|
+
for (var i2 = 0;i2 < lcdt.length; ++i2)
|
|
15633
|
+
++lcfreq[lcdt[i2] & 31];
|
|
15634
|
+
var _e = hTree(lcfreq, 7), lct = _e.t, mlcb = _e.l;
|
|
15635
|
+
var nlcc = 19;
|
|
15636
|
+
for (;nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc)
|
|
15637
|
+
;
|
|
15638
|
+
var flen = bl + 5 << 3;
|
|
15639
|
+
var ftlen = clen(lf, flt) + clen(df, fdt) + eb;
|
|
15640
|
+
var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + 2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18];
|
|
15641
|
+
if (bs >= 0 && flen <= ftlen && flen <= dtlen)
|
|
15642
|
+
return wfblk(out, p, dat.subarray(bs, bs + bl));
|
|
15643
|
+
var lm, ll, dm, dl;
|
|
15644
|
+
wbits(out, p, 1 + (dtlen < ftlen)), p += 2;
|
|
15645
|
+
if (dtlen < ftlen) {
|
|
15646
|
+
lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;
|
|
15647
|
+
var llm = hMap(lct, mlcb, 0);
|
|
15648
|
+
wbits(out, p, nlc - 257);
|
|
15649
|
+
wbits(out, p + 5, ndc - 1);
|
|
15650
|
+
wbits(out, p + 10, nlcc - 4);
|
|
15651
|
+
p += 14;
|
|
15652
|
+
for (var i2 = 0;i2 < nlcc; ++i2)
|
|
15653
|
+
wbits(out, p + 3 * i2, lct[clim[i2]]);
|
|
15654
|
+
p += 3 * nlcc;
|
|
15655
|
+
var lcts = [lclt, lcdt];
|
|
15656
|
+
for (var it = 0;it < 2; ++it) {
|
|
15657
|
+
var clct = lcts[it];
|
|
15658
|
+
for (var i2 = 0;i2 < clct.length; ++i2) {
|
|
15659
|
+
var len = clct[i2] & 31;
|
|
15660
|
+
wbits(out, p, llm[len]), p += lct[len];
|
|
15661
|
+
if (len > 15)
|
|
15662
|
+
wbits(out, p, clct[i2] >> 5 & 127), p += clct[i2] >> 12;
|
|
15663
|
+
}
|
|
15664
|
+
}
|
|
15665
|
+
} else {
|
|
15666
|
+
lm = flm, ll = flt, dm = fdm, dl = fdt;
|
|
15667
|
+
}
|
|
15668
|
+
for (var i2 = 0;i2 < li; ++i2) {
|
|
15669
|
+
var sym = syms[i2];
|
|
15670
|
+
if (sym > 255) {
|
|
15671
|
+
var len = sym >> 18 & 31;
|
|
15672
|
+
wbits16(out, p, lm[len + 257]), p += ll[len + 257];
|
|
15673
|
+
if (len > 7)
|
|
15674
|
+
wbits(out, p, sym >> 23 & 31), p += fleb[len];
|
|
15675
|
+
var dst = sym & 31;
|
|
15676
|
+
wbits16(out, p, dm[dst]), p += dl[dst];
|
|
15677
|
+
if (dst > 3)
|
|
15678
|
+
wbits16(out, p, sym >> 5 & 8191), p += fdeb[dst];
|
|
15679
|
+
} else {
|
|
15680
|
+
wbits16(out, p, lm[sym]), p += ll[sym];
|
|
15681
|
+
}
|
|
15682
|
+
}
|
|
15683
|
+
wbits16(out, p, lm[256]);
|
|
15684
|
+
return p + ll[256];
|
|
15685
|
+
};
|
|
15686
|
+
var deo = /* @__PURE__ */ new i32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);
|
|
15687
|
+
var et = /* @__PURE__ */ new u8(0);
|
|
15688
|
+
var dflt = function(dat, lvl, plvl, pre, post, st) {
|
|
15689
|
+
var s = st.z || dat.length;
|
|
15690
|
+
var o = new u8(pre + s + 5 * (1 + Math.ceil(s / 7000)) + post);
|
|
15691
|
+
var w = o.subarray(pre, o.length - post);
|
|
15692
|
+
var lst = st.l;
|
|
15693
|
+
var pos = (st.r || 0) & 7;
|
|
15694
|
+
if (lvl) {
|
|
15695
|
+
if (pos)
|
|
15696
|
+
w[0] = st.r >> 3;
|
|
15697
|
+
var opt = deo[lvl - 1];
|
|
15698
|
+
var n = opt >> 13, c = opt & 8191;
|
|
15699
|
+
var msk_1 = (1 << plvl) - 1;
|
|
15700
|
+
var prev = st.p || new u16(32768), head = st.h || new u16(msk_1 + 1);
|
|
15701
|
+
var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;
|
|
15702
|
+
var hsh = function(i3) {
|
|
15703
|
+
return (dat[i3] ^ dat[i3 + 1] << bs1_1 ^ dat[i3 + 2] << bs2_1) & msk_1;
|
|
15704
|
+
};
|
|
15705
|
+
var syms = new i32(25000);
|
|
15706
|
+
var lf = new u16(288), df = new u16(32);
|
|
15707
|
+
var lc_1 = 0, eb = 0, i2 = st.i || 0, li = 0, wi = st.w || 0, bs = 0;
|
|
15708
|
+
for (;i2 + 2 < s; ++i2) {
|
|
15709
|
+
var hv = hsh(i2);
|
|
15710
|
+
var imod = i2 & 32767, pimod = head[hv];
|
|
15711
|
+
prev[imod] = pimod;
|
|
15712
|
+
head[hv] = imod;
|
|
15713
|
+
if (wi <= i2) {
|
|
15714
|
+
var rem = s - i2;
|
|
15715
|
+
if ((lc_1 > 7000 || li > 24576) && (rem > 423 || !lst)) {
|
|
15716
|
+
pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i2 - bs, pos);
|
|
15717
|
+
li = lc_1 = eb = 0, bs = i2;
|
|
15718
|
+
for (var j = 0;j < 286; ++j)
|
|
15719
|
+
lf[j] = 0;
|
|
15720
|
+
for (var j = 0;j < 30; ++j)
|
|
15721
|
+
df[j] = 0;
|
|
15722
|
+
}
|
|
15723
|
+
var l = 2, d = 0, ch_1 = c, dif = imod - pimod & 32767;
|
|
15724
|
+
if (rem > 2 && hv == hsh(i2 - dif)) {
|
|
15725
|
+
var maxn = Math.min(n, rem) - 1;
|
|
15726
|
+
var maxd = Math.min(32767, i2);
|
|
15727
|
+
var ml = Math.min(258, rem);
|
|
15728
|
+
while (dif <= maxd && --ch_1 && imod != pimod) {
|
|
15729
|
+
if (dat[i2 + l] == dat[i2 + l - dif]) {
|
|
15730
|
+
var nl = 0;
|
|
15731
|
+
for (;nl < ml && dat[i2 + nl] == dat[i2 + nl - dif]; ++nl)
|
|
15732
|
+
;
|
|
15733
|
+
if (nl > l) {
|
|
15734
|
+
l = nl, d = dif;
|
|
15735
|
+
if (nl > maxn)
|
|
15736
|
+
break;
|
|
15737
|
+
var mmd = Math.min(dif, nl - 2);
|
|
15738
|
+
var md = 0;
|
|
15739
|
+
for (var j = 0;j < mmd; ++j) {
|
|
15740
|
+
var ti = i2 - dif + j & 32767;
|
|
15741
|
+
var pti = prev[ti];
|
|
15742
|
+
var cd = ti - pti & 32767;
|
|
15743
|
+
if (cd > md)
|
|
15744
|
+
md = cd, pimod = ti;
|
|
15745
|
+
}
|
|
15746
|
+
}
|
|
15747
|
+
}
|
|
15748
|
+
imod = pimod, pimod = prev[imod];
|
|
15749
|
+
dif += imod - pimod & 32767;
|
|
15750
|
+
}
|
|
15751
|
+
}
|
|
15752
|
+
if (d) {
|
|
15753
|
+
syms[li++] = 268435456 | revfl[l] << 18 | revfd[d];
|
|
15754
|
+
var lin = revfl[l] & 31, din = revfd[d] & 31;
|
|
15755
|
+
eb += fleb[lin] + fdeb[din];
|
|
15756
|
+
++lf[257 + lin];
|
|
15757
|
+
++df[din];
|
|
15758
|
+
wi = i2 + l;
|
|
15759
|
+
++lc_1;
|
|
15760
|
+
} else {
|
|
15761
|
+
syms[li++] = dat[i2];
|
|
15762
|
+
++lf[dat[i2]];
|
|
15763
|
+
}
|
|
15764
|
+
}
|
|
15765
|
+
}
|
|
15766
|
+
for (i2 = Math.max(i2, wi);i2 < s; ++i2) {
|
|
15767
|
+
syms[li++] = dat[i2];
|
|
15768
|
+
++lf[dat[i2]];
|
|
15769
|
+
}
|
|
15770
|
+
pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i2 - bs, pos);
|
|
15771
|
+
if (!lst) {
|
|
15772
|
+
st.r = pos & 7 | w[pos / 8 | 0] << 3;
|
|
15773
|
+
pos -= 7;
|
|
15774
|
+
st.h = head, st.p = prev, st.i = i2, st.w = wi;
|
|
15775
|
+
}
|
|
15776
|
+
} else {
|
|
15777
|
+
for (var i2 = st.w || 0;i2 < s + lst; i2 += 65535) {
|
|
15778
|
+
var e = i2 + 65535;
|
|
15779
|
+
if (e >= s) {
|
|
15780
|
+
w[pos / 8 | 0] = lst;
|
|
15781
|
+
e = s;
|
|
15782
|
+
}
|
|
15783
|
+
pos = wfblk(w, pos + 1, dat.subarray(i2, e));
|
|
15784
|
+
}
|
|
15785
|
+
st.i = s;
|
|
15786
|
+
}
|
|
15787
|
+
return slc(o, 0, pre + shft(pos) + post);
|
|
15788
|
+
};
|
|
15789
|
+
var crct = /* @__PURE__ */ function() {
|
|
15790
|
+
var t = new Int32Array(256);
|
|
15791
|
+
for (var i2 = 0;i2 < 256; ++i2) {
|
|
15792
|
+
var c = i2, k = 9;
|
|
15793
|
+
while (--k)
|
|
15794
|
+
c = (c & 1 && -306674912) ^ c >>> 1;
|
|
15795
|
+
t[i2] = c;
|
|
15796
|
+
}
|
|
15797
|
+
return t;
|
|
15798
|
+
}();
|
|
15799
|
+
var crc = function() {
|
|
15800
|
+
var c = -1;
|
|
15801
|
+
return {
|
|
15802
|
+
p: function(d) {
|
|
15803
|
+
var cr = c;
|
|
15804
|
+
for (var i2 = 0;i2 < d.length; ++i2)
|
|
15805
|
+
cr = crct[cr & 255 ^ d[i2]] ^ cr >>> 8;
|
|
15806
|
+
c = cr;
|
|
15807
|
+
},
|
|
15808
|
+
d: function() {
|
|
15809
|
+
return ~c;
|
|
15810
|
+
}
|
|
15811
|
+
};
|
|
15812
|
+
};
|
|
15813
|
+
var dopt = function(dat, opt, pre, post, st) {
|
|
15814
|
+
if (!st) {
|
|
15815
|
+
st = { l: 1 };
|
|
15816
|
+
if (opt.dictionary) {
|
|
15817
|
+
var dict = opt.dictionary.subarray(-32768);
|
|
15818
|
+
var newDat = new u8(dict.length + dat.length);
|
|
15819
|
+
newDat.set(dict);
|
|
15820
|
+
newDat.set(dat, dict.length);
|
|
15821
|
+
dat = newDat;
|
|
15822
|
+
st.w = dict.length;
|
|
15823
|
+
}
|
|
15824
|
+
}
|
|
15825
|
+
return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? st.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 20 : 12 + opt.mem, pre, post, st);
|
|
15826
|
+
};
|
|
15827
|
+
var mrg = function(a, b) {
|
|
15828
|
+
var o = {};
|
|
15829
|
+
for (var k in a)
|
|
15830
|
+
o[k] = a[k];
|
|
15831
|
+
for (var k in b)
|
|
15832
|
+
o[k] = b[k];
|
|
15833
|
+
return o;
|
|
15834
|
+
};
|
|
15835
|
+
var b2 = function(d, b) {
|
|
15836
|
+
return d[b] | d[b + 1] << 8;
|
|
15837
|
+
};
|
|
15838
|
+
var b4 = function(d, b) {
|
|
15839
|
+
return (d[b] | d[b + 1] << 8 | d[b + 2] << 16 | d[b + 3] << 24) >>> 0;
|
|
15840
|
+
};
|
|
15841
|
+
var b8 = function(d, b) {
|
|
15842
|
+
return b4(d, b) + b4(d, b + 4) * 4294967296;
|
|
15843
|
+
};
|
|
15844
|
+
var wbytes = function(d, b, v) {
|
|
15845
|
+
for (;v; ++b)
|
|
15846
|
+
d[b] = v, v >>>= 8;
|
|
15847
|
+
};
|
|
15848
|
+
function deflateSync(data, opts) {
|
|
15849
|
+
return dopt(data, opts || {}, 0, 0);
|
|
15850
|
+
}
|
|
15851
|
+
function inflateSync(data, opts) {
|
|
15852
|
+
return inflt(data, { i: 2 }, opts && opts.out, opts && opts.dictionary);
|
|
15853
|
+
}
|
|
15854
|
+
var fltn = function(d, p, t, o) {
|
|
15855
|
+
for (var k in d) {
|
|
15856
|
+
var val = d[k], n = p + k, op = o;
|
|
15857
|
+
if (Array.isArray(val))
|
|
15858
|
+
op = mrg(o, val[1]), val = val[0];
|
|
15859
|
+
if (ArrayBuffer.isView(val))
|
|
15860
|
+
t[n] = [val, op];
|
|
15861
|
+
else {
|
|
15862
|
+
t[n += "/"] = [new u8(0), op];
|
|
15863
|
+
fltn(val, n, t, o);
|
|
15864
|
+
}
|
|
15865
|
+
}
|
|
15866
|
+
};
|
|
15867
|
+
var te = typeof TextEncoder != "undefined" && /* @__PURE__ */ new TextEncoder;
|
|
15868
|
+
var td = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder;
|
|
15869
|
+
var tds = 0;
|
|
15870
|
+
try {
|
|
15871
|
+
td.decode(et, { stream: true });
|
|
15872
|
+
tds = 1;
|
|
15873
|
+
} catch (e) {}
|
|
15874
|
+
var dutf8 = function(d) {
|
|
15875
|
+
for (var r = "", i2 = 0;; ) {
|
|
15876
|
+
var c = d[i2++];
|
|
15877
|
+
var eb = (c > 127) + (c > 223) + (c > 239);
|
|
15878
|
+
if (i2 + eb > d.length)
|
|
15879
|
+
return { s: r, r: slc(d, i2 - 1) };
|
|
15880
|
+
if (!eb)
|
|
15881
|
+
r += String.fromCharCode(c);
|
|
15882
|
+
else if (eb == 3) {
|
|
15883
|
+
c = ((c & 15) << 18 | (d[i2++] & 63) << 12 | (d[i2++] & 63) << 6 | d[i2++] & 63) - 65536, r += String.fromCharCode(55296 | c >> 10, 56320 | c & 1023);
|
|
15884
|
+
} else if (eb & 1)
|
|
15885
|
+
r += String.fromCharCode((c & 31) << 6 | d[i2++] & 63);
|
|
15886
|
+
else
|
|
15887
|
+
r += String.fromCharCode((c & 15) << 12 | (d[i2++] & 63) << 6 | d[i2++] & 63);
|
|
15888
|
+
}
|
|
15889
|
+
};
|
|
15890
|
+
function strToU8(str, latin1) {
|
|
15891
|
+
if (latin1) {
|
|
15892
|
+
var ar_1 = new u8(str.length);
|
|
15893
|
+
for (var i2 = 0;i2 < str.length; ++i2)
|
|
15894
|
+
ar_1[i2] = str.charCodeAt(i2);
|
|
15895
|
+
return ar_1;
|
|
15896
|
+
}
|
|
15897
|
+
if (te)
|
|
15898
|
+
return te.encode(str);
|
|
15899
|
+
var l = str.length;
|
|
15900
|
+
var ar = new u8(str.length + (str.length >> 1));
|
|
15901
|
+
var ai = 0;
|
|
15902
|
+
var w = function(v) {
|
|
15903
|
+
ar[ai++] = v;
|
|
15904
|
+
};
|
|
15905
|
+
for (var i2 = 0;i2 < l; ++i2) {
|
|
15906
|
+
if (ai + 5 > ar.length) {
|
|
15907
|
+
var n = new u8(ai + 8 + (l - i2 << 1));
|
|
15908
|
+
n.set(ar);
|
|
15909
|
+
ar = n;
|
|
15910
|
+
}
|
|
15911
|
+
var c = str.charCodeAt(i2);
|
|
15912
|
+
if (c < 128 || latin1)
|
|
15913
|
+
w(c);
|
|
15914
|
+
else if (c < 2048)
|
|
15915
|
+
w(192 | c >> 6), w(128 | c & 63);
|
|
15916
|
+
else if (c > 55295 && c < 57344)
|
|
15917
|
+
c = 65536 + (c & 1023 << 10) | str.charCodeAt(++i2) & 1023, w(240 | c >> 18), w(128 | c >> 12 & 63), w(128 | c >> 6 & 63), w(128 | c & 63);
|
|
15918
|
+
else
|
|
15919
|
+
w(224 | c >> 12), w(128 | c >> 6 & 63), w(128 | c & 63);
|
|
15920
|
+
}
|
|
15921
|
+
return slc(ar, 0, ai);
|
|
15922
|
+
}
|
|
15923
|
+
function strFromU8(dat, latin1) {
|
|
15924
|
+
if (latin1) {
|
|
15925
|
+
var r = "";
|
|
15926
|
+
for (var i2 = 0;i2 < dat.length; i2 += 16384)
|
|
15927
|
+
r += String.fromCharCode.apply(null, dat.subarray(i2, i2 + 16384));
|
|
15928
|
+
return r;
|
|
15929
|
+
} else if (td) {
|
|
15930
|
+
return td.decode(dat);
|
|
15931
|
+
} else {
|
|
15932
|
+
var _a2 = dutf8(dat), s = _a2.s, r = _a2.r;
|
|
15933
|
+
if (r.length)
|
|
15934
|
+
err(8);
|
|
15935
|
+
return s;
|
|
15936
|
+
}
|
|
15937
|
+
}
|
|
15938
|
+
var slzh = function(d, b) {
|
|
15939
|
+
return b + 30 + b2(d, b + 26) + b2(d, b + 28);
|
|
15940
|
+
};
|
|
15941
|
+
var zh = function(d, b, z) {
|
|
15942
|
+
var fnl = b2(d, b + 28), efl = b2(d, b + 30), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl;
|
|
15943
|
+
var _a2 = z64hs(d, es, efl, z, b4(d, b + 20), b4(d, b + 24), b4(d, b + 42)), sc = _a2[0], su = _a2[1], off = _a2[2];
|
|
15944
|
+
return [b2(d, b + 10), sc, su, fn, es + efl + b2(d, b + 32), off];
|
|
15945
|
+
};
|
|
15946
|
+
var z64hs = function(d, b, l, z, sc, su, off) {
|
|
15947
|
+
var nsc = sc == 4294967295, nsu = su == 4294967295, noff = off == 4294967295, e = b + l;
|
|
15948
|
+
var nf = nsc + nsu + noff;
|
|
15949
|
+
if (z && nf) {
|
|
15950
|
+
for (;b + 4 < e; b += 4 + b2(d, b + 2)) {
|
|
15951
|
+
if (b2(d, b) == 1) {
|
|
15952
|
+
return [
|
|
15953
|
+
nsc ? b8(d, b + 4 + 8 * nsu) : sc,
|
|
15954
|
+
nsu ? b8(d, b + 4) : su,
|
|
15955
|
+
noff ? b8(d, b + 4 + 8 * (nsu + nsc)) : off,
|
|
15956
|
+
1
|
|
15957
|
+
];
|
|
15958
|
+
}
|
|
15959
|
+
}
|
|
15960
|
+
if (z < 2)
|
|
15961
|
+
err(13);
|
|
15962
|
+
}
|
|
15963
|
+
return [sc, su, off, 0];
|
|
15964
|
+
};
|
|
15965
|
+
var exfl = function(ex) {
|
|
15966
|
+
var le = 0;
|
|
15967
|
+
if (ex) {
|
|
15968
|
+
for (var k in ex) {
|
|
15969
|
+
var l = ex[k].length;
|
|
15970
|
+
if (l > 65535)
|
|
15971
|
+
err(9);
|
|
15972
|
+
le += l + 4;
|
|
15973
|
+
}
|
|
15974
|
+
}
|
|
15975
|
+
return le;
|
|
15976
|
+
};
|
|
15977
|
+
var wzh = function(d, b, f, fn, u, c, ce, co) {
|
|
15978
|
+
var fl2 = fn.length, ex = f.extra, col = co && co.length;
|
|
15979
|
+
var exl = exfl(ex);
|
|
15980
|
+
wbytes(d, b, ce != null ? 33639248 : 67324752), b += 4;
|
|
15981
|
+
if (ce != null)
|
|
15982
|
+
d[b++] = 20, d[b++] = f.os;
|
|
15983
|
+
d[b] = 20, b += 2;
|
|
15984
|
+
d[b++] = f.flag << 1 | (c < 0 && 8), d[b++] = u && 8;
|
|
15985
|
+
d[b++] = f.compression & 255, d[b++] = f.compression >> 8;
|
|
15986
|
+
var dt = new Date(f.mtime == null ? Date.now() : f.mtime), y = dt.getFullYear() - 1980;
|
|
15987
|
+
if (y < 0 || y > 119)
|
|
15988
|
+
err(10);
|
|
15989
|
+
wbytes(d, b, y << 25 | dt.getMonth() + 1 << 21 | dt.getDate() << 16 | dt.getHours() << 11 | dt.getMinutes() << 5 | dt.getSeconds() >> 1), b += 4;
|
|
15990
|
+
if (c != -1) {
|
|
15991
|
+
wbytes(d, b, f.crc);
|
|
15992
|
+
wbytes(d, b + 4, c < 0 ? -c - 2 : c);
|
|
15993
|
+
wbytes(d, b + 8, f.size);
|
|
15994
|
+
}
|
|
15995
|
+
wbytes(d, b + 12, fl2);
|
|
15996
|
+
wbytes(d, b + 14, exl), b += 16;
|
|
15997
|
+
if (ce != null) {
|
|
15998
|
+
wbytes(d, b, col);
|
|
15999
|
+
wbytes(d, b + 6, f.attrs);
|
|
16000
|
+
wbytes(d, b + 10, ce), b += 14;
|
|
16001
|
+
}
|
|
16002
|
+
d.set(fn, b);
|
|
16003
|
+
b += fl2;
|
|
16004
|
+
if (exl) {
|
|
16005
|
+
for (var k in ex) {
|
|
16006
|
+
var exf = ex[k], l = exf.length;
|
|
16007
|
+
wbytes(d, b, +k);
|
|
16008
|
+
wbytes(d, b + 2, l);
|
|
16009
|
+
d.set(exf, b + 4), b += 4 + l;
|
|
16010
|
+
}
|
|
16011
|
+
}
|
|
16012
|
+
if (col)
|
|
16013
|
+
d.set(co, b), b += col;
|
|
16014
|
+
return b;
|
|
16015
|
+
};
|
|
16016
|
+
var wzf = function(o, b, c, d, e) {
|
|
16017
|
+
wbytes(o, b, 101010256);
|
|
16018
|
+
wbytes(o, b + 8, c);
|
|
16019
|
+
wbytes(o, b + 10, c);
|
|
16020
|
+
wbytes(o, b + 12, d);
|
|
16021
|
+
wbytes(o, b + 16, e);
|
|
16022
|
+
};
|
|
16023
|
+
function zipSync(data, opts) {
|
|
16024
|
+
if (!opts)
|
|
16025
|
+
opts = {};
|
|
16026
|
+
var r = {};
|
|
16027
|
+
var files = [];
|
|
16028
|
+
fltn(data, "", r, opts);
|
|
16029
|
+
var o = 0;
|
|
16030
|
+
var tot = 0;
|
|
16031
|
+
for (var fn in r) {
|
|
16032
|
+
var _a2 = r[fn], file = _a2[0], p = _a2[1];
|
|
16033
|
+
var compression = p.level == 0 ? 0 : 8;
|
|
16034
|
+
var f = strToU8(fn), s = f.length;
|
|
16035
|
+
var com = p.comment, m = com && strToU8(com), ms = m && m.length;
|
|
16036
|
+
var exl = exfl(p.extra);
|
|
16037
|
+
if (s > 65535)
|
|
16038
|
+
err(11);
|
|
16039
|
+
var d = compression ? deflateSync(file, p) : file, l = d.length;
|
|
16040
|
+
var c = crc();
|
|
16041
|
+
c.p(file);
|
|
16042
|
+
files.push(mrg(p, {
|
|
16043
|
+
size: file.length,
|
|
16044
|
+
crc: c.d(),
|
|
16045
|
+
c: d,
|
|
16046
|
+
f,
|
|
16047
|
+
m,
|
|
16048
|
+
u: s != fn.length || m && com.length != ms,
|
|
16049
|
+
o,
|
|
16050
|
+
compression
|
|
16051
|
+
}));
|
|
16052
|
+
o += 30 + s + exl + l;
|
|
16053
|
+
tot += 76 + 2 * (s + exl) + (ms || 0) + l;
|
|
16054
|
+
}
|
|
16055
|
+
var out = new u8(tot + 22), oe = o, cdl = tot - o;
|
|
16056
|
+
for (var i2 = 0;i2 < files.length; ++i2) {
|
|
16057
|
+
var f = files[i2];
|
|
16058
|
+
wzh(out, f.o, f, f.f, f.u, f.c.length);
|
|
16059
|
+
var badd = 30 + f.f.length + exfl(f.extra);
|
|
16060
|
+
out.set(f.c, f.o + badd);
|
|
16061
|
+
wzh(out, o, f, f.f, f.u, f.c.length, f.o, f.m), o += 16 + badd + (f.m ? f.m.length : 0);
|
|
16062
|
+
}
|
|
16063
|
+
wzf(out, o, files.length, cdl, oe);
|
|
16064
|
+
return out;
|
|
16065
|
+
}
|
|
16066
|
+
function unzipSync(data, opts) {
|
|
16067
|
+
var files = {};
|
|
16068
|
+
var e = data.length - 22;
|
|
16069
|
+
for (;b4(data, e) != 101010256; --e) {
|
|
16070
|
+
if (!e || data.length - e > 65558)
|
|
16071
|
+
err(13);
|
|
16072
|
+
}
|
|
16073
|
+
var c = b2(data, e + 8);
|
|
16074
|
+
if (!c)
|
|
16075
|
+
return {};
|
|
16076
|
+
var o = b4(data, e + 16);
|
|
16077
|
+
var z = b4(data, e - 20) == 117853008;
|
|
16078
|
+
if (z) {
|
|
16079
|
+
var ze = b4(data, e - 12);
|
|
16080
|
+
z = b4(data, ze) == 101075792;
|
|
16081
|
+
if (z) {
|
|
16082
|
+
c = b4(data, ze + 32);
|
|
16083
|
+
o = b4(data, ze + 48);
|
|
16084
|
+
}
|
|
16085
|
+
}
|
|
16086
|
+
var fltr = opts && opts.filter;
|
|
16087
|
+
for (var i2 = 0;i2 < c; ++i2) {
|
|
16088
|
+
var _a2 = zh(data, o, z), c_2 = _a2[0], sc = _a2[1], su = _a2[2], fn = _a2[3], no = _a2[4], off = _a2[5], b = slzh(data, off);
|
|
16089
|
+
o = no;
|
|
16090
|
+
if (!fltr || fltr({
|
|
16091
|
+
name: fn,
|
|
16092
|
+
size: sc,
|
|
16093
|
+
originalSize: su,
|
|
16094
|
+
compression: c_2
|
|
16095
|
+
})) {
|
|
16096
|
+
if (!c_2)
|
|
16097
|
+
files[fn] = slc(data, b, b + sc);
|
|
16098
|
+
else if (c_2 == 8)
|
|
16099
|
+
files[fn] = inflateSync(data.subarray(b, b + sc), { out: new u8(su) });
|
|
16100
|
+
else
|
|
16101
|
+
err(14, "unknown compression type " + c_2);
|
|
16102
|
+
}
|
|
16103
|
+
}
|
|
16104
|
+
return files;
|
|
16105
|
+
}
|
|
16106
|
+
|
|
17368
16107
|
// src/services/connector-builder/util/packaging.ts
|
|
17369
|
-
var import_adm_zip = __toESM(require_adm_zip(), 1);
|
|
17370
16108
|
var JUNK_NAMES = new Set([
|
|
17371
16109
|
".DS_Store",
|
|
17372
16110
|
"__MACOSX",
|
|
@@ -17383,7 +16121,7 @@ async function resolveConnectorRoot2(inputPath) {
|
|
|
17383
16121
|
throw new Error(`Path '${inputPath}' does not exist.`);
|
|
17384
16122
|
}
|
|
17385
16123
|
let dir = start;
|
|
17386
|
-
for (let
|
|
16124
|
+
for (let i2 = 0;i2 <= MAX_WALKUP_DEPTH; i2++) {
|
|
17387
16125
|
const probe = fs2.path.join(dir, "app", "element", "element.json");
|
|
17388
16126
|
if (await fs2.exists(probe))
|
|
17389
16127
|
return dir;
|
|
@@ -17431,12 +16169,11 @@ async function packConnectorToBytes(connectorRoot) {
|
|
|
17431
16169
|
if (elementRel !== expectedRel) {
|
|
17432
16170
|
throw new Error("app/element must be a real directory under the connector root; refusing to package.");
|
|
17433
16171
|
}
|
|
17434
|
-
const
|
|
16172
|
+
const files = {};
|
|
17435
16173
|
const visited = new Set([elementDirReal]);
|
|
17436
|
-
await addDir(fs2, rootReal, elementDirReal, elementDirReal, `${topName}/app/element`,
|
|
17437
|
-
const buffer = zip.toBuffer();
|
|
16174
|
+
await addDir(fs2, rootReal, elementDirReal, elementDirReal, `${topName}/app/element`, files, visited);
|
|
17438
16175
|
return {
|
|
17439
|
-
bytes:
|
|
16176
|
+
bytes: zipSync(files),
|
|
17440
16177
|
fileName: `${topName}.zip`
|
|
17441
16178
|
};
|
|
17442
16179
|
}
|
|
@@ -17453,25 +16190,22 @@ function stripTrailingSlashes(value) {
|
|
|
17453
16190
|
async function unpackConnectorZip(zipBytes, targetBaseDir) {
|
|
17454
16191
|
const fs2 = getFileSystem();
|
|
17455
16192
|
const baseAbs = fs2.path.resolve(targetBaseDir);
|
|
17456
|
-
const
|
|
17457
|
-
const entries = zip.getEntries();
|
|
16193
|
+
const entries = Object.entries(unzipSync(zipBytes)).filter(([name]) => !name.endsWith("/"));
|
|
17458
16194
|
const ELEMENT_JSON_SUFFIX = "app/element/element.json";
|
|
17459
|
-
const anchor = entries.find((
|
|
16195
|
+
const anchor = entries.find(([name]) => normalizeZipPath(name).endsWith(ELEMENT_JSON_SUFFIX));
|
|
17460
16196
|
if (!anchor) {
|
|
17461
16197
|
throw new Error("Connector export did not contain 'app/element/element.json'.");
|
|
17462
16198
|
}
|
|
17463
|
-
const anchorPath = normalizeZipPath(anchor
|
|
16199
|
+
const anchorPath = normalizeZipPath(anchor[0]);
|
|
17464
16200
|
const topName = stripTrailingSlashes(anchorPath.slice(0, anchorPath.length - ELEMENT_JSON_SUFFIX.length));
|
|
17465
16201
|
if (!topName) {
|
|
17466
16202
|
throw new Error("Connector export has an unexpected layout (no top-level folder).");
|
|
17467
16203
|
}
|
|
17468
16204
|
const topPrefix = `${topName}/`;
|
|
17469
|
-
for (const
|
|
17470
|
-
|
|
17471
|
-
continue;
|
|
17472
|
-
const normalized = normalizeZipPath(entry.entryName);
|
|
16205
|
+
for (const [entryName, data] of entries) {
|
|
16206
|
+
const normalized = normalizeZipPath(entryName);
|
|
17473
16207
|
if (normalized !== topName && !normalized.startsWith(topPrefix)) {
|
|
17474
|
-
throw new Error(`Connector export contains an entry outside the connector folder '${topName}': '${
|
|
16208
|
+
throw new Error(`Connector export contains an entry outside the connector folder '${topName}': '${entryName}'.`);
|
|
17475
16209
|
}
|
|
17476
16210
|
const segments = normalized.split("/").filter((s) => s.length > 0);
|
|
17477
16211
|
if (segments.some((s) => JUNK_NAMES.has(s)))
|
|
@@ -17479,13 +16213,13 @@ async function unpackConnectorZip(zipBytes, targetBaseDir) {
|
|
|
17479
16213
|
const destAbs = fs2.path.resolve(baseAbs, ...segments);
|
|
17480
16214
|
const containment = fs2.path.relative(baseAbs, destAbs);
|
|
17481
16215
|
if (containment.startsWith("..") || fs2.path.isAbsolute(containment)) {
|
|
17482
|
-
throw new Error(`Refusing to extract entry outside the target directory: '${
|
|
16216
|
+
throw new Error(`Refusing to extract entry outside the target directory: '${entryName}'.`);
|
|
17483
16217
|
}
|
|
17484
|
-
await fs2.writeFile(destAbs,
|
|
16218
|
+
await fs2.writeFile(destAbs, data);
|
|
17485
16219
|
}
|
|
17486
16220
|
return { root: fs2.path.join(baseAbs, topName), key: topName };
|
|
17487
16221
|
}
|
|
17488
|
-
async function addDir(fs2, rootReal, boundaryReal, currentAbs, zipPrefix,
|
|
16222
|
+
async function addDir(fs2, rootReal, boundaryReal, currentAbs, zipPrefix, files, visited) {
|
|
17489
16223
|
const entries = await fs2.readdir(currentAbs);
|
|
17490
16224
|
for (const entry of entries) {
|
|
17491
16225
|
if (JUNK_NAMES.has(entry))
|
|
@@ -17509,9 +16243,13 @@ async function addDir(fs2, rootReal, boundaryReal, currentAbs, zipPrefix, zip, v
|
|
|
17509
16243
|
continue;
|
|
17510
16244
|
visited.add(real);
|
|
17511
16245
|
const subPrefix = `${zipPrefix}/${entry}`;
|
|
17512
|
-
await addDir(fs2, rootReal, boundaryReal, abs, subPrefix,
|
|
16246
|
+
await addDir(fs2, rootReal, boundaryReal, abs, subPrefix, files, visited);
|
|
17513
16247
|
} else if (stats.isFile()) {
|
|
17514
|
-
|
|
16248
|
+
const data = await fs2.readFile(abs);
|
|
16249
|
+
if (data === null) {
|
|
16250
|
+
throw new Error(`Could not read '${abs}' while packaging the connector.`);
|
|
16251
|
+
}
|
|
16252
|
+
files[`${zipPrefix}/${entry}`] = data;
|
|
17515
16253
|
}
|
|
17516
16254
|
}
|
|
17517
16255
|
}
|
|
@@ -18050,9 +16788,9 @@ function humanize2(name) {
|
|
|
18050
16788
|
return name;
|
|
18051
16789
|
}
|
|
18052
16790
|
const out = [];
|
|
18053
|
-
for (let
|
|
18054
|
-
const ch = name[
|
|
18055
|
-
if (isUpper(ch) &&
|
|
16791
|
+
for (let i2 = 0;i2 < name.length; i2++) {
|
|
16792
|
+
const ch = name[i2];
|
|
16793
|
+
if (isUpper(ch) && i2 > 0 && !isUpper(name[i2 - 1])) {
|
|
18056
16794
|
out.push(" ");
|
|
18057
16795
|
}
|
|
18058
16796
|
out.push(ch);
|
|
@@ -18433,9 +17171,9 @@ function upsertSrParamByName(sr, method, param) {
|
|
|
18433
17171
|
config.parameters = [];
|
|
18434
17172
|
const params = config.parameters;
|
|
18435
17173
|
const name = param.name;
|
|
18436
|
-
for (let
|
|
18437
|
-
if (params[
|
|
18438
|
-
params[
|
|
17174
|
+
for (let i2 = 0;i2 < params.length; i2++) {
|
|
17175
|
+
if (params[i2].name === name) {
|
|
17176
|
+
params[i2] = param;
|
|
18439
17177
|
return sr;
|
|
18440
17178
|
}
|
|
18441
17179
|
}
|
|
@@ -18448,9 +17186,9 @@ function removeSrParamByName(sr, method, paramName) {
|
|
|
18448
17186
|
throw new Error(`Method '${method}' not found in SR metadata.`);
|
|
18449
17187
|
}
|
|
18450
17188
|
const params = config.parameters ?? [];
|
|
18451
|
-
for (let
|
|
18452
|
-
if (params[
|
|
18453
|
-
params.splice(
|
|
17189
|
+
for (let i2 = 0;i2 < params.length; i2++) {
|
|
17190
|
+
if (params[i2].name === paramName) {
|
|
17191
|
+
params.splice(i2, 1);
|
|
18454
17192
|
return sr;
|
|
18455
17193
|
}
|
|
18456
17194
|
}
|
|
@@ -19523,8 +18261,8 @@ async function lookupVendorPath(root, config, method) {
|
|
|
19523
18261
|
if (internalPath === null)
|
|
19524
18262
|
return null;
|
|
19525
18263
|
const httpMethod = typeof config.method === "string" && config.method ? config.method : method === "GETBYID" ? "GET" : method;
|
|
19526
|
-
const [
|
|
19527
|
-
if (
|
|
18264
|
+
const [err2, element] = await catchError2(readElementJson(root));
|
|
18265
|
+
if (err2)
|
|
19528
18266
|
return null;
|
|
19529
18267
|
const resources = element.resources ?? [];
|
|
19530
18268
|
const entry = resources.find((r) => r.path === internalPath && r.method === httpMethod);
|
|
@@ -19995,15 +18733,15 @@ function normalizeEnumValues(parsed, label, errors) {
|
|
|
19995
18733
|
return;
|
|
19996
18734
|
}
|
|
19997
18735
|
const out = [];
|
|
19998
|
-
parsed.forEach((entry,
|
|
18736
|
+
parsed.forEach((entry, i2) => {
|
|
19999
18737
|
if (entry === null || entry === undefined) {
|
|
20000
|
-
errors.push(`${label}: enum entry #${
|
|
18738
|
+
errors.push(`${label}: enum entry #${i2 + 1} is null.`);
|
|
20001
18739
|
return;
|
|
20002
18740
|
}
|
|
20003
18741
|
if (typeof entry === "object") {
|
|
20004
18742
|
const obj = entry;
|
|
20005
18743
|
if (obj.value === undefined) {
|
|
20006
|
-
errors.push(`${label}: enum entry #${
|
|
18744
|
+
errors.push(`${label}: enum entry #${i2 + 1} is an object without a 'value' key.`);
|
|
20007
18745
|
return;
|
|
20008
18746
|
}
|
|
20009
18747
|
out.push({ ...obj, value: String(obj.value) });
|
|
@@ -20019,9 +18757,9 @@ function normalizeEnhancedEnum(parsed, label, errors) {
|
|
|
20019
18757
|
return;
|
|
20020
18758
|
}
|
|
20021
18759
|
const out = [];
|
|
20022
|
-
parsed.forEach((entry,
|
|
18760
|
+
parsed.forEach((entry, i2) => {
|
|
20023
18761
|
if (!isPlainObject(entry) || entry.name === undefined || entry.value === undefined) {
|
|
20024
|
-
errors.push(`${label}: enhancedEnum entry #${
|
|
18762
|
+
errors.push(`${label}: enhancedEnum entry #${i2 + 1} must be an object with both 'name' and 'value'.`);
|
|
20025
18763
|
return;
|
|
20026
18764
|
}
|
|
20027
18765
|
out.push({ ...entry, value: String(entry.value) });
|
|
@@ -20058,23 +18796,23 @@ function validateFieldActions(parsed, label, warnings) {
|
|
|
20058
18796
|
warnings.push(`${label}: 'design.fieldActions' is usually an array.`);
|
|
20059
18797
|
return;
|
|
20060
18798
|
}
|
|
20061
|
-
parsed.forEach((action,
|
|
18799
|
+
parsed.forEach((action, i2) => {
|
|
20062
18800
|
if (!isPlainObject(action)) {
|
|
20063
|
-
warnings.push(`${label}: fieldActions[${
|
|
18801
|
+
warnings.push(`${label}: fieldActions[${i2}] should be an object.`);
|
|
20064
18802
|
return;
|
|
20065
18803
|
}
|
|
20066
18804
|
const at = action.actionType;
|
|
20067
18805
|
if (typeof at !== "string" || !FIELD_ACTION_TYPES.has(at)) {
|
|
20068
|
-
warnings.push(`${label}: fieldActions[${
|
|
18806
|
+
warnings.push(`${label}: fieldActions[${i2}].actionType '${String(at)}' is uncommon (usual: ${[...FIELD_ACTION_TYPES].join(", ")}).`);
|
|
20069
18807
|
}
|
|
20070
18808
|
const rules = action.rules;
|
|
20071
18809
|
if (!Array.isArray(rules) || rules.length === 0) {
|
|
20072
|
-
warnings.push(`${label}: fieldActions[${
|
|
18810
|
+
warnings.push(`${label}: fieldActions[${i2}] needs a non-empty 'rules' array (each rule points at the field it reacts to).`);
|
|
20073
18811
|
return;
|
|
20074
18812
|
}
|
|
20075
18813
|
rules.forEach((rule, j) => {
|
|
20076
18814
|
if (!isPlainObject(rule) || typeof rule.refFieldName !== "string" || rule.refFieldName.length === 0) {
|
|
20077
|
-
warnings.push(`${label}: fieldActions[${
|
|
18815
|
+
warnings.push(`${label}: fieldActions[${i2}].rules[${j}] needs a non-empty 'refFieldName' (the field it depends on).`);
|
|
20078
18816
|
}
|
|
20079
18817
|
});
|
|
20080
18818
|
});
|
|
@@ -20246,16 +18984,16 @@ function validateAndNormalizeFieldSpecs(input) {
|
|
|
20246
18984
|
const items = coerceFieldSpecInput(input, warnings);
|
|
20247
18985
|
const specs = [];
|
|
20248
18986
|
const seen = new Map;
|
|
20249
|
-
items.forEach((raw,
|
|
20250
|
-
const spec = normalizeOne(raw,
|
|
18987
|
+
items.forEach((raw, i2) => {
|
|
18988
|
+
const spec = normalizeOne(raw, i2, errors, warnings);
|
|
20251
18989
|
if (!spec)
|
|
20252
18990
|
return;
|
|
20253
18991
|
if (spec.name) {
|
|
20254
18992
|
const prev = seen.get(spec.name);
|
|
20255
18993
|
if (prev !== undefined) {
|
|
20256
|
-
errors.push(`field '${spec.name}': duplicated at positions #${prev + 1} and #${
|
|
18994
|
+
errors.push(`field '${spec.name}': duplicated at positions #${prev + 1} and #${i2 + 1} — field names must be unique.`);
|
|
20257
18995
|
} else {
|
|
20258
|
-
seen.set(spec.name,
|
|
18996
|
+
seen.set(spec.name, i2);
|
|
20259
18997
|
}
|
|
20260
18998
|
}
|
|
20261
18999
|
specs.push(spec);
|
|
@@ -24248,13 +22986,13 @@ function validateParamShape(param, label = "") {
|
|
|
24248
22986
|
}
|
|
24249
22987
|
function validateParamList(params, locationLabel) {
|
|
24250
22988
|
const errors = [];
|
|
24251
|
-
for (let
|
|
24252
|
-
const p = params[
|
|
22989
|
+
for (let i2 = 0;i2 < params.length; i2++) {
|
|
22990
|
+
const p = params[i2];
|
|
24253
22991
|
let identity = "";
|
|
24254
22992
|
if (isRecord4(p)) {
|
|
24255
|
-
identity = stringOr2(p.vendorName) || stringOr2(p.name) || `index=${
|
|
22993
|
+
identity = stringOr2(p.vendorName) || stringOr2(p.name) || `index=${i2}`;
|
|
24256
22994
|
} else {
|
|
24257
|
-
identity = `index=${
|
|
22995
|
+
identity = `index=${i2}`;
|
|
24258
22996
|
}
|
|
24259
22997
|
const label = `${locationLabel} param ${repr2(identity)}`;
|
|
24260
22998
|
errors.push(...validateParamShape(p, label));
|
|
@@ -24293,7 +23031,7 @@ function repr2(v) {
|
|
|
24293
23031
|
return JSON.stringify(v) ?? "None";
|
|
24294
23032
|
}
|
|
24295
23033
|
function reprList(items) {
|
|
24296
|
-
return `[${items.map((
|
|
23034
|
+
return `[${items.map((i2) => repr2(i2)).join(", ")}]`;
|
|
24297
23035
|
}
|
|
24298
23036
|
|
|
24299
23037
|
// src/services/connector-builder/operations/validate.ts
|
|
@@ -24736,8 +23474,8 @@ async function checkParamDrift(elem, root) {
|
|
|
24736
23474
|
}
|
|
24737
23475
|
const srParams = asRecordArray2(asRecord2(methodMeta[matchedMethodKey]).parameters);
|
|
24738
23476
|
const elemParams = asRecordArray2(r.parameters);
|
|
24739
|
-
for (const
|
|
24740
|
-
errors.push(`${srName}.json [${matchedMethodKey}]: ${
|
|
23477
|
+
for (const err2 of detectParamDrift(srParams, elemParams)) {
|
|
23478
|
+
errors.push(`${srName}.json [${matchedMethodKey}]: ${err2}`);
|
|
24741
23479
|
}
|
|
24742
23480
|
}
|
|
24743
23481
|
return errors;
|
|
@@ -25069,12 +23807,12 @@ function registerConnectorCommands(builder) {
|
|
|
25069
23807
|
"Gating a connector in CI before import or release.",
|
|
25070
23808
|
"Finding errors, warnings, and suggestions across element.json, SR files, hooks, and metadata."
|
|
25071
23809
|
], ["Browsing a connector's structure — use `inspect` for that."])).option("--connector-dir <path>", FOLDER_OPTION_DESC).examples(VALIDATE_EXAMPLES).trackedAction(processContext, async (options) => {
|
|
25072
|
-
const [
|
|
25073
|
-
if (
|
|
23810
|
+
const [err2, result] = await catchError2(validateConnector(options.connectorDir));
|
|
23811
|
+
if (err2) {
|
|
25074
23812
|
OutputFormatter.error({
|
|
25075
23813
|
Result: RESULTS.Failure,
|
|
25076
23814
|
Message: "Validation failed",
|
|
25077
|
-
Instructions:
|
|
23815
|
+
Instructions: err2.message
|
|
25078
23816
|
});
|
|
25079
23817
|
processContext.exit(1);
|
|
25080
23818
|
return;
|
|
@@ -26068,9 +24806,9 @@ function metadataArgs(connectorRoot, options) {
|
|
|
26068
24806
|
async function applyBaseUrl(connectorRoot, baseUrl) {
|
|
26069
24807
|
const entry = JSON.parse(JSON.stringify(BASE_URL));
|
|
26070
24808
|
entry.defaultValue = baseUrl;
|
|
26071
|
-
const [
|
|
26072
|
-
if (
|
|
26073
|
-
return { ok: false, message:
|
|
24809
|
+
const [err2, result] = await catchError2(addConfig({ connectorRoot, entry, forceUpdateExisting: true }));
|
|
24810
|
+
if (err2)
|
|
24811
|
+
return { ok: false, message: err2.message };
|
|
26074
24812
|
if (!result.ok)
|
|
26075
24813
|
return { ok: false, message: result.error.message };
|
|
26076
24814
|
const [seedErr] = await catchError2(seedInterpolationConfigsOnDisk(connectorRoot));
|
|
@@ -26679,24 +25417,24 @@ function isObject(v) {
|
|
|
26679
25417
|
function asArray(v) {
|
|
26680
25418
|
return Array.isArray(v) ? v : [];
|
|
26681
25419
|
}
|
|
26682
|
-
function
|
|
25420
|
+
function err2(code, message, fixHint) {
|
|
26683
25421
|
return { ok: false, error: { code, message, fixHint } };
|
|
26684
25422
|
}
|
|
26685
25423
|
async function patchConnector(connectorRoot, pointer, value, op) {
|
|
26686
25424
|
if (op !== "upsert" && op !== "remove") {
|
|
26687
|
-
return
|
|
25425
|
+
return err2("invalidOp", `op must be 'upsert' or 'remove', got '${op}'.`, "Pass op: 'upsert' to write, or op: 'remove' to delete.");
|
|
26688
25426
|
}
|
|
26689
25427
|
let cp;
|
|
26690
25428
|
try {
|
|
26691
25429
|
cp = parsePointer(pointer);
|
|
26692
25430
|
} catch (e) {
|
|
26693
|
-
return
|
|
25431
|
+
return err2("invalidPointer", e instanceof Error ? e.message : String(e), "Use a valid pointer, e.g. 'element.json/configuration/base.url'.");
|
|
26694
25432
|
}
|
|
26695
25433
|
if (op === "upsert" && (value === null || value === undefined)) {
|
|
26696
|
-
return
|
|
25434
|
+
return err2("missingValue", "value is required for upsert operations.", "Pass the object/array/string to write.");
|
|
26697
25435
|
}
|
|
26698
25436
|
if (cp.pathType === PathType.RAW_FILE) {
|
|
26699
|
-
return
|
|
25437
|
+
return err2("readOnly", "Raw file paths are read-only.", "Use queryConnector to read raw files; edit them through a structured pointer.");
|
|
26700
25438
|
}
|
|
26701
25439
|
if (op === "remove") {
|
|
26702
25440
|
const removeErr = validateRemoveTarget(cp);
|
|
@@ -26705,7 +25443,7 @@ async function patchConnector(connectorRoot, pointer, value, op) {
|
|
|
26705
25443
|
}
|
|
26706
25444
|
}
|
|
26707
25445
|
if (isSummary(cp) && op === "upsert") {
|
|
26708
|
-
return
|
|
25446
|
+
return err2("notWritable", `Cannot write to summary path '${pointer}'.`, "Navigate to a specific item (a key, method+path, field, or param).");
|
|
26709
25447
|
}
|
|
26710
25448
|
const snapshot = await captureSnapshot(connectorRoot, cp);
|
|
26711
25449
|
try {
|
|
@@ -26727,9 +25465,9 @@ async function patchConnector(connectorRoot, pointer, value, op) {
|
|
|
26727
25465
|
await restoreSnapshot(connectorRoot, cp, snapshot);
|
|
26728
25466
|
const message = e instanceof Error ? e.message : String(e);
|
|
26729
25467
|
if (/not found/i.test(message)) {
|
|
26730
|
-
return
|
|
25468
|
+
return err2("notFound", message, "Check the connector root and that the addressed file exists.");
|
|
26731
25469
|
}
|
|
26732
|
-
return
|
|
25470
|
+
return err2("unexpected", `Unexpected error writing ${pointer}: ${message}`, "Inspect the connector files; changes were rolled back.");
|
|
26733
25471
|
}
|
|
26734
25472
|
}
|
|
26735
25473
|
function srFilePath2(root, name) {
|
|
@@ -26792,31 +25530,31 @@ async function restoreSnapshot(root, _cp, snap) {
|
|
|
26792
25530
|
}
|
|
26793
25531
|
function validateRemoveTarget(cp) {
|
|
26794
25532
|
if (isSummary(cp)) {
|
|
26795
|
-
return
|
|
25533
|
+
return err2("notRemovable", "Cannot remove a summary.", "Navigate to a specific item to remove.");
|
|
26796
25534
|
}
|
|
26797
25535
|
if (cp.pathType === PathType.ELEMENT_JSON) {
|
|
26798
25536
|
if (cp.section === Section.WHOLE_FILE) {
|
|
26799
|
-
return
|
|
25537
|
+
return err2("notRemovable", "Cannot remove element.json.", "Replace it via an upsert at 'element.json' instead.");
|
|
26800
25538
|
}
|
|
26801
25539
|
if (cp.section === Section.AUTHENTICATION) {
|
|
26802
|
-
return
|
|
25540
|
+
return err2("notRemovable", "Cannot remove authentication section.", "Replace it via an upsert at 'element.json/authentication'.");
|
|
26803
25541
|
}
|
|
26804
25542
|
if (cp.section === Section.HOOKS && cp.hookType === null && cp.resourceMethod === null) {
|
|
26805
|
-
return
|
|
25543
|
+
return err2("notRemovable", "Cannot remove global hooks array.", "Replace it via an upsert at 'element.json/hooks'.");
|
|
26806
25544
|
}
|
|
26807
25545
|
if (cp.section === Section.PARAMETERS && cp.paramIndex === null && cp.resourceMethod === null) {
|
|
26808
|
-
return
|
|
25546
|
+
return err2("notRemovable", "Cannot remove global parameters array.", "Replace it via an upsert at 'element.json/parameters'.");
|
|
26809
25547
|
}
|
|
26810
25548
|
}
|
|
26811
25549
|
if (cp.pathType === PathType.ELEMENT_METADATA) {
|
|
26812
|
-
return
|
|
25550
|
+
return err2("notRemovable", "Cannot remove element-metadata.json.", "Replace it via an upsert at 'element-metadata.json'.");
|
|
26813
25551
|
}
|
|
26814
25552
|
if (cp.pathType === PathType.STANDARD_RESOURCES) {
|
|
26815
25553
|
if (cp.srName !== null && cp.section === Section.WHOLE_FILE) {
|
|
26816
|
-
return
|
|
25554
|
+
return err2("notRemovable", "Cannot remove a whole SR file via patch.", "Delete the file manually if you intend to drop the resource.");
|
|
26817
25555
|
}
|
|
26818
25556
|
if (cp.section === Section.METADATA && cp.metadataKey === null) {
|
|
26819
|
-
return
|
|
25557
|
+
return err2("notRemovable", "Cannot remove the entire metadata object.", "Replace it via an upsert, or remove individual metadata keys.");
|
|
26820
25558
|
}
|
|
26821
25559
|
}
|
|
26822
25560
|
return null;
|
|
@@ -26837,21 +25575,21 @@ async function routePatch(cp, root, value, op) {
|
|
|
26837
25575
|
if (cp.pathType === PathType.HOOKS) {
|
|
26838
25576
|
return patchHooks(cp, root, value, op);
|
|
26839
25577
|
}
|
|
26840
|
-
return
|
|
25578
|
+
return err2("unexpected", `Unhandled path type ${cp.pathType}`, "This is a bug — report the pointer that triggered it.");
|
|
26841
25579
|
}
|
|
26842
25580
|
async function patchElementJson(cp, root, value, op) {
|
|
26843
25581
|
const element = await readElementJson(root);
|
|
26844
25582
|
const warnings = [];
|
|
26845
25583
|
if (cp.section === Section.WHOLE_FILE) {
|
|
26846
25584
|
if (!isObject(value)) {
|
|
26847
|
-
return
|
|
25585
|
+
return err2("validation", "element.json must be an object.", "Pass the full element.json object as the value.");
|
|
26848
25586
|
}
|
|
26849
25587
|
const incomingKey = value.key;
|
|
26850
25588
|
const incomingName = value.name;
|
|
26851
25589
|
const hasKey = typeof incomingKey === "string" && incomingKey.trim() !== "";
|
|
26852
25590
|
const hasName = typeof incomingName === "string" && incomingName.trim() !== "";
|
|
26853
25591
|
if (!hasKey || !hasName) {
|
|
26854
|
-
return
|
|
25592
|
+
return err2("notWritable", "Refusing to replace element.json: a whole-file value must include a non-empty 'key' and 'name'. An empty or identity-less object would discard the connector definition.", "Edit a specific slice via its pointer (e.g. element.json/configuration/<key>), or pass the full element.json including its 'key' and 'name' as the value.");
|
|
26855
25593
|
}
|
|
26856
25594
|
await writeElementJson(root, value);
|
|
26857
25595
|
return ok("Replaced element.json.");
|
|
@@ -26879,7 +25617,7 @@ async function patchElementJson(cp, root, value, op) {
|
|
|
26879
25617
|
}
|
|
26880
25618
|
if (cp.section === Section.PARAMETERS) {
|
|
26881
25619
|
if (!Array.isArray(value)) {
|
|
26882
|
-
return
|
|
25620
|
+
return err2("validation", "element.json/parameters must be an array.", "Pass the full parameters array as the value.");
|
|
26883
25621
|
}
|
|
26884
25622
|
element.parameters = value;
|
|
26885
25623
|
await writeElementJson(root, element);
|
|
@@ -26887,7 +25625,7 @@ async function patchElementJson(cp, root, value, op) {
|
|
|
26887
25625
|
}
|
|
26888
25626
|
if (cp.section === Section.HOOKS) {
|
|
26889
25627
|
if (!Array.isArray(value)) {
|
|
26890
|
-
return
|
|
25628
|
+
return err2("validation", "element.json/hooks must be an array.", "Pass the full hooks array as the value.");
|
|
26891
25629
|
}
|
|
26892
25630
|
element.hooks = value;
|
|
26893
25631
|
await writeElementJson(root, element);
|
|
@@ -26896,24 +25634,24 @@ async function patchElementJson(cp, root, value, op) {
|
|
|
26896
25634
|
}
|
|
26897
25635
|
if (cp.section === Section.AUTHENTICATION) {
|
|
26898
25636
|
if (!isObject(value)) {
|
|
26899
|
-
return
|
|
25637
|
+
return err2("validation", "element.json/authentication must be an object.", "Pass the authentication object as the value.");
|
|
26900
25638
|
}
|
|
26901
25639
|
element.authentication = value;
|
|
26902
25640
|
await writeElementJson(root, element);
|
|
26903
25641
|
return ok("Replaced element.json/authentication.");
|
|
26904
25642
|
}
|
|
26905
|
-
return
|
|
25643
|
+
return err2("unexpected", `Unhandled section ${cp.section}`, "This is a bug — report the pointer that triggered it.");
|
|
26906
25644
|
}
|
|
26907
25645
|
function patchConfiguration(cp, element, value, op, warnings) {
|
|
26908
25646
|
const key = cp.configKey;
|
|
26909
25647
|
if (key === null) {
|
|
26910
|
-
return
|
|
25648
|
+
return err2("notWritable", "Configuration writes require a specific key.", "Address a single config entry, e.g. 'element.json/configuration/base.url'.");
|
|
26911
25649
|
}
|
|
26912
25650
|
if (op === "remove") {
|
|
26913
25651
|
const config = getConfiguration(element);
|
|
26914
25652
|
const idx = config.findIndex((c) => c.key === key);
|
|
26915
25653
|
if (idx < 0) {
|
|
26916
|
-
return
|
|
25654
|
+
return err2("notFound", `Configuration key '${key}' not found.`, "List 'element.json/configuration' to see available keys.");
|
|
26917
25655
|
}
|
|
26918
25656
|
config.splice(idx, 1);
|
|
26919
25657
|
element.configuration = config;
|
|
@@ -26942,7 +25680,7 @@ function patchResource(cp, element, value, op, warnings) {
|
|
|
26942
25680
|
if (op === "remove") {
|
|
26943
25681
|
const idx2 = resources.findIndex((r) => r.method === method && r.path === resPath);
|
|
26944
25682
|
if (idx2 < 0) {
|
|
26945
|
-
return
|
|
25683
|
+
return err2("notFound", `Resource ${method} ${resPath} not found.`, "List 'element.json/resources' to see available resources.");
|
|
26946
25684
|
}
|
|
26947
25685
|
resources.splice(idx2, 1);
|
|
26948
25686
|
element.resources = resources;
|
|
@@ -26966,14 +25704,14 @@ function patchResource(cp, element, value, op, warnings) {
|
|
|
26966
25704
|
}
|
|
26967
25705
|
const resource = resources.find((r) => r.method === method && r.path === resPath);
|
|
26968
25706
|
if (resource === undefined) {
|
|
26969
|
-
return
|
|
25707
|
+
return err2("notFound", `Resource ${method} ${resPath} not found.`, "Create the resource first, then address its parameters/hooks.");
|
|
26970
25708
|
}
|
|
26971
25709
|
if (cp.section === Section.PARAMETERS) {
|
|
26972
25710
|
const params = asArray(resource.parameters);
|
|
26973
25711
|
if (cp.paramIndex !== null) {
|
|
26974
25712
|
if (op === "remove") {
|
|
26975
25713
|
if (cp.paramIndex < 0 || cp.paramIndex >= params.length) {
|
|
26976
|
-
return
|
|
25714
|
+
return err2("notFound", `Parameter index ${cp.paramIndex} out of range (array has ${params.length} items).`, "Query the parameters array to find valid indexes.");
|
|
26977
25715
|
}
|
|
26978
25716
|
params.splice(cp.paramIndex, 1);
|
|
26979
25717
|
resource.parameters = params;
|
|
@@ -26984,17 +25722,17 @@ function patchResource(cp, element, value, op, warnings) {
|
|
|
26984
25722
|
return validationErr;
|
|
26985
25723
|
}
|
|
26986
25724
|
if (cp.paramIndex < 0 || cp.paramIndex >= params.length) {
|
|
26987
|
-
return
|
|
25725
|
+
return err2("notFound", `Parameter index ${cp.paramIndex} out of range (array has ${params.length} items). To append, write the whole parameters array.`, "Replace the whole parameters array to append a new parameter.");
|
|
26988
25726
|
}
|
|
26989
25727
|
params[cp.paramIndex] = value;
|
|
26990
25728
|
resource.parameters = params;
|
|
26991
25729
|
return ok(`Replaced parameter at index ${cp.paramIndex} on ${method} ${resPath}.`);
|
|
26992
25730
|
}
|
|
26993
25731
|
if (op === "remove") {
|
|
26994
|
-
return
|
|
25732
|
+
return err2("notRemovable", "Cannot remove the entire parameters array.", "Remove individual parameters by index, or replace the array.");
|
|
26995
25733
|
}
|
|
26996
25734
|
if (!Array.isArray(value)) {
|
|
26997
|
-
return
|
|
25735
|
+
return err2("validation", "Resource parameters must be an array.", "Pass the full parameters array as the value.");
|
|
26998
25736
|
}
|
|
26999
25737
|
resource.parameters = value;
|
|
27000
25738
|
return ok(`Replaced parameters array on ${method} ${resPath}.`);
|
|
@@ -27005,14 +25743,14 @@ function patchResource(cp, element, value, op, warnings) {
|
|
|
27005
25743
|
if (op === "remove") {
|
|
27006
25744
|
const idx2 = hooks.map((h) => isObject(h) ? h.type : undefined).indexOf(cp.hookType);
|
|
27007
25745
|
if (idx2 < 0) {
|
|
27008
|
-
return
|
|
25746
|
+
return err2("notFound", `Hook type '${cp.hookType}' not found on resource.`, "Query the resource hooks to see available types.");
|
|
27009
25747
|
}
|
|
27010
25748
|
hooks.splice(idx2, 1);
|
|
27011
25749
|
resource.hooks = hooks;
|
|
27012
25750
|
return ok(`Removed hook '${cp.hookType}' from ${method} ${resPath}.`);
|
|
27013
25751
|
}
|
|
27014
25752
|
if (!isObject(value)) {
|
|
27015
|
-
return
|
|
25753
|
+
return err2("validation", "Resource hook must be an object.", "Pass the hook reference object as the value.");
|
|
27016
25754
|
}
|
|
27017
25755
|
const hookRef = value;
|
|
27018
25756
|
hookRef.type = cp.hookType;
|
|
@@ -27026,22 +25764,22 @@ function patchResource(cp, element, value, op, warnings) {
|
|
|
27026
25764
|
return ok(`Upserted hook '${cp.hookType}' on ${method} ${resPath}.`);
|
|
27027
25765
|
}
|
|
27028
25766
|
if (op === "remove") {
|
|
27029
|
-
return
|
|
25767
|
+
return err2("notRemovable", "Cannot remove the entire hooks array.", "Remove individual hooks by type, or replace the array.");
|
|
27030
25768
|
}
|
|
27031
25769
|
if (!Array.isArray(value)) {
|
|
27032
|
-
return
|
|
25770
|
+
return err2("validation", "Resource hooks must be an array.", "Pass the full hooks array as the value.");
|
|
27033
25771
|
}
|
|
27034
25772
|
resource.hooks = value;
|
|
27035
25773
|
return ok(`Replaced hooks array on ${method} ${resPath}.`);
|
|
27036
25774
|
}
|
|
27037
|
-
return
|
|
25775
|
+
return err2("unexpected", "Unhandled resource sub-path.", "This is a bug — report the pointer that triggered it.");
|
|
27038
25776
|
}
|
|
27039
25777
|
async function patchElementMetadata(root, value) {
|
|
27040
25778
|
if (!isObject(value)) {
|
|
27041
|
-
return
|
|
25779
|
+
return err2("validation", "element-metadata.json must be an object.", "Pass the full element-metadata.json object as the value.");
|
|
27042
25780
|
}
|
|
27043
25781
|
if (Object.keys(value).length === 0) {
|
|
27044
|
-
return
|
|
25782
|
+
return err2("notWritable", "Refusing to replace element-metadata.json with an empty object.", "Pass the full element-metadata.json object as the value (element-metadata.json has no addressable sub-paths). `state query element-metadata.json` returns the on-disk camelCase shape, safe to round-trip.");
|
|
27045
25783
|
}
|
|
27046
25784
|
const fs2 = getFileSystem();
|
|
27047
25785
|
const path = fs2.path.join(root, "app", "element", "element-metadata.json");
|
|
@@ -27053,14 +25791,14 @@ async function patchStandardResources(cp, root, value, op) {
|
|
|
27053
25791
|
const warnings = [];
|
|
27054
25792
|
const srName = cp.srName;
|
|
27055
25793
|
if (srName === null) {
|
|
27056
|
-
return
|
|
25794
|
+
return err2("notWritable", "Cannot write to the standard-resources directory listing.", "Address a specific standard resource by name.");
|
|
27057
25795
|
}
|
|
27058
25796
|
if (cp.section === Section.WHOLE_FILE) {
|
|
27059
25797
|
if (!isObject(value)) {
|
|
27060
|
-
return
|
|
25798
|
+
return err2("validation", `standard-resources/${srName} must be an object.`, "Pass the full standard-resource object as the value.");
|
|
27061
25799
|
}
|
|
27062
25800
|
if (!("fields" in value) && !("metadata" in value)) {
|
|
27063
|
-
return
|
|
25801
|
+
return err2("notWritable", `Refusing to replace standard-resources/${srName}: a whole-file value must include 'fields' or 'metadata'. An empty or shapeless object would wipe the standard resource.`, "Edit a specific slice via its pointer (e.g. .../fields/<name> or .../metadata/method/<VERB>), or pass the full SR object including its 'fields'/'metadata'.");
|
|
27064
25802
|
}
|
|
27065
25803
|
await writeStandardResource(root, srName, value);
|
|
27066
25804
|
const synced = await syncAllMethodsInSr(root, srName);
|
|
@@ -27087,12 +25825,12 @@ async function patchStandardResources(cp, root, value, op) {
|
|
|
27087
25825
|
if (cp.section === Section.METADATA) {
|
|
27088
25826
|
return patchSrMetadata(cp, root, srName, srData, value, op, warnings);
|
|
27089
25827
|
}
|
|
27090
|
-
return
|
|
25828
|
+
return err2("unexpected", `Unhandled SR section ${cp.section}`, "This is a bug — report the pointer that triggered it.");
|
|
27091
25829
|
}
|
|
27092
25830
|
async function patchSrMetadata(cp, root, srName, srData, value, op, warnings) {
|
|
27093
25831
|
if (cp.metadataKey === null) {
|
|
27094
25832
|
if (!isObject(value)) {
|
|
27095
|
-
return
|
|
25833
|
+
return err2("validation", `metadata in ${srName} must be an object.`, "Pass the full metadata object as the value.");
|
|
27096
25834
|
}
|
|
27097
25835
|
srData.metadata = value;
|
|
27098
25836
|
await writeStandardResource(root, srName, srData);
|
|
@@ -27110,13 +25848,13 @@ async function patchSrMetadata(cp, root, srName, srData, value, op, warnings) {
|
|
|
27110
25848
|
return ok(`Removed parameter '${srParamName}' from ${srName} method ${srMethod}.`, warnings, changed3 ? [`${srName}.json[${srMethod}]`] : []);
|
|
27111
25849
|
}
|
|
27112
25850
|
if (!isObject(value)) {
|
|
27113
|
-
return
|
|
25851
|
+
return err2("validation", "SR method parameter must be an object.", "Pass the parameter object as the value.");
|
|
27114
25852
|
}
|
|
27115
25853
|
if (!("type" in value)) {
|
|
27116
|
-
return
|
|
25854
|
+
return err2("validation", "SR method parameter requires 'type' field.", "Add a 'type' field to the parameter object.");
|
|
27117
25855
|
}
|
|
27118
25856
|
if (getSrMethodConfig(srData, srMethod) === null) {
|
|
27119
|
-
return
|
|
25857
|
+
return err2("notFound", `Method '${srMethod}' not found in ${srName} metadata.`, `Create the method config first via standard-resources/${srName}/metadata/method/${srMethod}.`);
|
|
27120
25858
|
}
|
|
27121
25859
|
const obj = value;
|
|
27122
25860
|
obj.name = srParamName;
|
|
@@ -27128,7 +25866,7 @@ async function patchSrMetadata(cp, root, srName, srData, value, op, warnings) {
|
|
|
27128
25866
|
if (op === "remove") {
|
|
27129
25867
|
const methodMap = srData.metadata?.method ?? {};
|
|
27130
25868
|
if (!(srMethod in methodMap)) {
|
|
27131
|
-
return
|
|
25869
|
+
return err2("notFound", `Method '${srMethod}' not found in ${srName} metadata.`, `Query 'standard-resources/${srName}/metadata' to list methods.`);
|
|
27132
25870
|
}
|
|
27133
25871
|
delete methodMap[srMethod];
|
|
27134
25872
|
await writeStandardResource(root, srName, srData);
|
|
@@ -27143,7 +25881,7 @@ async function patchSrMetadata(cp, root, srName, srData, value, op, warnings) {
|
|
|
27143
25881
|
if (op === "remove") {
|
|
27144
25882
|
const metadata = srData.metadata ?? {};
|
|
27145
25883
|
if (!(metadataKey in metadata)) {
|
|
27146
|
-
return
|
|
25884
|
+
return err2("notFound", `Metadata key '${metadataKey}' not found in ${srName}.`, `Query 'standard-resources/${srName}/metadata' to list keys.`);
|
|
27147
25885
|
}
|
|
27148
25886
|
delete metadata[metadataKey];
|
|
27149
25887
|
await writeStandardResource(root, srName, srData);
|
|
@@ -27155,24 +25893,24 @@ async function patchSrMetadata(cp, root, srName, srData, value, op, warnings) {
|
|
|
27155
25893
|
}
|
|
27156
25894
|
async function patchHooks(cp, root, value, op) {
|
|
27157
25895
|
if (cp.hookFilename === null) {
|
|
27158
|
-
return
|
|
25896
|
+
return err2("notWritable", "Cannot write to the hooks directory listing.", "Address a specific hook file, e.g. 'hooks/my-hook.js'.");
|
|
27159
25897
|
}
|
|
27160
25898
|
const fs2 = getFileSystem();
|
|
27161
25899
|
const hooksDir = fs2.path.join(root, "app", "element", "hooks");
|
|
27162
25900
|
const hookPath = fs2.path.join(hooksDir, cp.hookFilename);
|
|
27163
25901
|
const rel = fs2.path.relative(fs2.path.resolve(hooksDir), fs2.path.resolve(hookPath));
|
|
27164
25902
|
if (rel.startsWith("..") || fs2.path.isAbsolute(rel)) {
|
|
27165
|
-
return
|
|
25903
|
+
return err2("pathEscape", "Hook path escapes hooks directory.", "Pass a hook filename relative to app/element/hooks.");
|
|
27166
25904
|
}
|
|
27167
25905
|
if (op === "remove") {
|
|
27168
25906
|
if (!await fs2.exists(hookPath)) {
|
|
27169
|
-
return
|
|
25907
|
+
return err2("notFound", `Hook file not found: ${cp.hookFilename}`, "Query 'hooks' to list available hook files.");
|
|
27170
25908
|
}
|
|
27171
25909
|
await fs2.rm(hookPath);
|
|
27172
25910
|
return ok(`Deleted hook file ${cp.hookFilename}. Warning: check element.json resource hooks for dangling refs to this file and remove them separately.`);
|
|
27173
25911
|
}
|
|
27174
25912
|
if (typeof value !== "string" || value.trim() === "") {
|
|
27175
|
-
return
|
|
25913
|
+
return err2("validation", "Hook file content must be a non-empty string.", "Pass the hook's JavaScript source as a non-empty string.");
|
|
27176
25914
|
}
|
|
27177
25915
|
await fs2.mkdir(hooksDir);
|
|
27178
25916
|
await fs2.writeFile(hookPath, value);
|
|
@@ -27180,13 +25918,13 @@ async function patchHooks(cp, root, value, op) {
|
|
|
27180
25918
|
}
|
|
27181
25919
|
function validateConfigValue(value, key, warnings) {
|
|
27182
25920
|
if (!isObject(value)) {
|
|
27183
|
-
return
|
|
25921
|
+
return err2("validation", "Configuration value must be an object.", "Pass a config-entry object with at least a 'type' field.");
|
|
27184
25922
|
}
|
|
27185
25923
|
if ("key" in value && value.key !== key) {
|
|
27186
25924
|
warnings.push(`Value key '${String(value.key)}' differs from path key '${key}' — path wins.`);
|
|
27187
25925
|
}
|
|
27188
25926
|
if (!("type" in value)) {
|
|
27189
|
-
return
|
|
25927
|
+
return err2("validation", "Configuration entry requires 'type' field.", "Add a 'type' field (e.g. 'PROPERTY', 'PASSWORD').");
|
|
27190
25928
|
}
|
|
27191
25929
|
if (!("name" in value)) {
|
|
27192
25930
|
warnings.push("Missing 'name' field on config entry.");
|
|
@@ -27195,7 +25933,7 @@ function validateConfigValue(value, key, warnings) {
|
|
|
27195
25933
|
}
|
|
27196
25934
|
function validateResourceValue(value, method, path, warnings) {
|
|
27197
25935
|
if (!isObject(value)) {
|
|
27198
|
-
return
|
|
25936
|
+
return err2("validation", "Resource value must be an object.", "Pass a resource object with method, path, and parameters.");
|
|
27199
25937
|
}
|
|
27200
25938
|
if ("method" in value && value.method !== method) {
|
|
27201
25939
|
warnings.push(`Value method '${String(value.method)}' differs from path method '${method}' — path wins.`);
|
|
@@ -27210,13 +25948,13 @@ function validateResourceValue(value, method, path, warnings) {
|
|
|
27210
25948
|
}
|
|
27211
25949
|
function validateParameterValue(value, warnings) {
|
|
27212
25950
|
if (!isObject(value)) {
|
|
27213
|
-
return
|
|
25951
|
+
return err2("validation", "Parameter value must be an object.", "Pass a parameter object with 'name' and 'type'.");
|
|
27214
25952
|
}
|
|
27215
25953
|
if (!("name" in value)) {
|
|
27216
|
-
return
|
|
25954
|
+
return err2("validation", "Parameter requires 'name' field.", "Add a 'name' field to the parameter object.");
|
|
27217
25955
|
}
|
|
27218
25956
|
if (!("type" in value)) {
|
|
27219
|
-
return
|
|
25957
|
+
return err2("validation", "Parameter requires 'type' field.", "Add a 'type' field to the parameter object.");
|
|
27220
25958
|
}
|
|
27221
25959
|
if (!("vendorType" in value)) {
|
|
27222
25960
|
warnings.push("Missing 'vendorType' on parameter.");
|
|
@@ -27228,10 +25966,10 @@ function validateParameterValue(value, warnings) {
|
|
|
27228
25966
|
}
|
|
27229
25967
|
function validateFieldValue(value, _fieldName, warnings) {
|
|
27230
25968
|
if (!isObject(value)) {
|
|
27231
|
-
return
|
|
25969
|
+
return err2("validation", "Field value must be an object.", "Pass a field object with at least a 'type' field.");
|
|
27232
25970
|
}
|
|
27233
25971
|
if (!("type" in value)) {
|
|
27234
|
-
return
|
|
25972
|
+
return err2("validation", "Field requires 'type' field.", "Add a 'type' field to the field object.");
|
|
27235
25973
|
}
|
|
27236
25974
|
if (!("vendorPath" in value)) {
|
|
27237
25975
|
warnings.push("Missing 'vendorPath' on field.");
|
|
@@ -28346,17 +27084,17 @@ function registerConnectorLifecycleCommands(connectors) {
|
|
|
28346
27084
|
])).argument("<connector-key>", "Exact design connector key (e.g. design-myorg-acmewidgets).").option("--connector-dir <path>", "Target directory for the unpacked source (defaults to the current directory).").addOption(new Option("--path <dir>").hideHelp()).option("--tenant <tenant>", "Override the tenant for the API calls.").examples(DOWNLOAD_EXAMPLES).trackedAction(processContext, async (key, options) => {
|
|
28347
27085
|
const connectorDir = options.connectorDir ?? options.path;
|
|
28348
27086
|
const clientOptions = options.tenant ? { tenant: options.tenant } : undefined;
|
|
28349
|
-
const [
|
|
27087
|
+
const [err3, result] = await catchError2(getConnector(clientOptions, {
|
|
28350
27088
|
key,
|
|
28351
27089
|
include: "files",
|
|
28352
27090
|
path: connectorDir,
|
|
28353
27091
|
tenant: options.tenant
|
|
28354
27092
|
}));
|
|
28355
|
-
if (
|
|
27093
|
+
if (err3) {
|
|
28356
27094
|
OutputFormatter.error({
|
|
28357
27095
|
Result: RESULTS.Failure,
|
|
28358
27096
|
Message: "Connector download failed",
|
|
28359
|
-
Instructions:
|
|
27097
|
+
Instructions: err3.message
|
|
28360
27098
|
});
|
|
28361
27099
|
processContext.exit(1);
|
|
28362
27100
|
return;
|
|
@@ -30241,10 +28979,14 @@ var registerTriggersCommand = (program2) => {
|
|
|
30241
28979
|
}
|
|
30242
28980
|
const [error, objects] = await fetchTriggerObjects(api, connectorKey, normalizedOp, options.connectionId);
|
|
30243
28981
|
if (error) {
|
|
28982
|
+
const { result, errorCode: errorCode2, message, retry, context } = await extractErrorDetails(error);
|
|
30244
28983
|
OutputFormatter.error({
|
|
30245
|
-
Result:
|
|
28984
|
+
Result: result,
|
|
30246
28985
|
Message: `Error fetching trigger objects for '${normalizedOp}'`,
|
|
30247
|
-
Instructions:
|
|
28986
|
+
Instructions: message,
|
|
28987
|
+
ErrorCode: errorCode2,
|
|
28988
|
+
Retry: retry,
|
|
28989
|
+
Context: context
|
|
30248
28990
|
});
|
|
30249
28991
|
processContext.exit(1);
|
|
30250
28992
|
return;
|
|
@@ -30285,10 +29027,14 @@ var registerTriggersCommand = (program2) => {
|
|
|
30285
29027
|
}
|
|
30286
29028
|
const [error, metadata] = await fetchTriggerMetadata(api, connectorKey, normalizedOp, objectName, options.connectionId);
|
|
30287
29029
|
if (error) {
|
|
29030
|
+
const { result: result2, errorCode: errorCode2, message, retry, context } = await extractErrorDetails(error);
|
|
30288
29031
|
OutputFormatter.error({
|
|
30289
|
-
Result:
|
|
29032
|
+
Result: result2,
|
|
30290
29033
|
Message: `Error fetching trigger metadata for '${objectName}'`,
|
|
30291
|
-
Instructions:
|
|
29034
|
+
Instructions: message,
|
|
29035
|
+
ErrorCode: errorCode2,
|
|
29036
|
+
Retry: retry,
|
|
29037
|
+
Context: context
|
|
30292
29038
|
});
|
|
30293
29039
|
processContext.exit(1);
|
|
30294
29040
|
return;
|
|
@@ -30611,4 +29357,4 @@ var registerCommands = async (program2) => {
|
|
|
30611
29357
|
|
|
30612
29358
|
export { Command, metadata, registerCommands };
|
|
30613
29359
|
|
|
30614
|
-
//# debugId=
|
|
29360
|
+
//# debugId=5FEEF3A8DE7F1F2064756E2164756E21
|