@uipath/agent-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/{agent-project-service-wyh0r5cb.js → agent-project-service-j4pgc7gk.js} +2 -2
- package/dist/{de-LVBY3VVG-tc58p3x6.js → de-WMKOGI7B-r1821wpe.js} +16 -7
- package/dist/{en-4UFXRW7N-mqabr9tf.js → en-X4DLPKLJ-dt1wtdm7.js} +17 -5
- package/dist/{es-CI4AE5B5-55sgqk64.js → es-BVPGJUWA-9gk2g9yb.js} +16 -7
- package/dist/{es-MX-OLZNAYY5-30cmv1dx.js → es-MX-U6YL5KQX-ynwxdjr8.js} +16 -7
- package/dist/executor-tool.js +6 -5
- package/dist/{fr-CCN6ZO5E-x2akzsjt.js → fr-EKTTDR7Z-bmpwp31r.js} +16 -7
- package/dist/index-26bymy67.js +17359 -0
- package/dist/{index-3pq4x5b7.js → index-byw2z4xp.js} +1 -1
- package/dist/{index-p052hv12.js → index-f97359cb.js} +2 -2
- package/dist/{index-w23k88b5.js → index-p50kx6jv.js} +202 -64
- package/dist/index.js +9 -8
- package/dist/{integration-tool-service-dgk5br9n.js → integration-tool-service-n214kzdn.js} +2 -2
- package/dist/{is-client-7pyb4pet.js → is-client-9b6sp9ag.js} +2 -2
- package/dist/{ja-O2NEV5D6-nt9rhd8c.js → ja-Y2YBTXNN-96cvy5av.js} +16 -7
- package/dist/{ko-7XWV2SEQ-chk3y7aj.js → ko-S33XAV26-cxf4dn2t.js} +16 -7
- package/dist/{packager-tool-973f0r2g.js → packager-tool-1yy9x4vk.js} +17 -5
- package/dist/{packager-tool-fz1pzt1z.js → packager-tool-5xdkh3vm.js} +18 -4
- package/dist/{packager-tool-rev4tnf6.js → packager-tool-bpegrcj1.js} +4098 -7102
- package/dist/packager-tool-fhrpdder.js +4492 -0
- package/dist/{packager-tool-ty88v0fy.js → packager-tool-fpj7v9y3.js} +9 -9
- package/dist/{packager-tool-xz142g61.js → packager-tool-ggg5bx2h.js} +24826 -2156
- package/dist/{packager-tool-hxd8e3e6.js → packager-tool-gkvdytpj.js} +87 -48
- package/dist/{packager-tool-ftfbnjpc.js → packager-tool-wzknj3dr.js} +1 -1
- package/dist/{pt-BR-Z4J3LEEO-cf33d2zv.js → pt-BR-JO45SCNI-4kbfnzc4.js} +16 -7
- package/dist/{pt-CRSN3TCU-txxbbcxm.js → pt-W3NA4LIZ-f02gapvs.js} +16 -7
- package/dist/{ro-WMQEVD7D-6mtq0e6b.js → ro-WLKX6HF5-fcbe2zz8.js} +16 -7
- package/dist/tool.js +9 -8
- package/dist/{tr-UCMB7W3T-xmxp2naq.js → tr-3U2W2XCA-zg3zcmq3.js} +15 -6
- package/dist/{zh-CN-2QOHEFC5-ryjb2byk.js → zh-CN-IPZYQR3P-1h76csc4.js} +16 -7
- package/dist/{zh-TW-Q5QSSTS6-6y7yjbbn.js → zh-TW-YPVSQVGT-wbybwpwt.js} +16 -7
- package/package.json +2 -2
|
@@ -0,0 +1,4492 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentProjectService
|
|
3
|
+
} from "./packager-tool-wzknj3dr.js";
|
|
4
|
+
import {
|
|
5
|
+
PersonalWorkspacesApi,
|
|
6
|
+
createApiClient,
|
|
7
|
+
findSolutionFile,
|
|
8
|
+
readUipxFile,
|
|
9
|
+
updateSolutionFile,
|
|
10
|
+
updateUipxSolutionId
|
|
11
|
+
} from "./packager-tool-bpegrcj1.js";
|
|
12
|
+
import {
|
|
13
|
+
getLoginStatusAsync
|
|
14
|
+
} from "./packager-tool-5xdkh3vm.js";
|
|
15
|
+
import {
|
|
16
|
+
catchError,
|
|
17
|
+
logger
|
|
18
|
+
} from "./packager-tool-gkvdytpj.js";
|
|
19
|
+
import {
|
|
20
|
+
addSdkUserAgentHeader,
|
|
21
|
+
getSdkUserAgentToken,
|
|
22
|
+
installSdkUserAgentHeader
|
|
23
|
+
} from "./packager-tool-nsrs2tm5.js";
|
|
24
|
+
import {
|
|
25
|
+
getFileSystem
|
|
26
|
+
} from "./packager-tool-yv3rvyas.js";
|
|
27
|
+
import {
|
|
28
|
+
zipSync
|
|
29
|
+
} from "./packager-tool-b098y4a2.js";
|
|
30
|
+
import {
|
|
31
|
+
__commonJS,
|
|
32
|
+
__require,
|
|
33
|
+
__toESM
|
|
34
|
+
} from "./packager-tool-wckvcay0.js";
|
|
35
|
+
|
|
36
|
+
// ../../node_modules/adm-zip/util/constants.js
|
|
37
|
+
var require_constants = __commonJS((exports, module) => {
|
|
38
|
+
module.exports = {
|
|
39
|
+
LOCHDR: 30,
|
|
40
|
+
LOCSIG: 67324752,
|
|
41
|
+
LOCVER: 4,
|
|
42
|
+
LOCFLG: 6,
|
|
43
|
+
LOCHOW: 8,
|
|
44
|
+
LOCTIM: 10,
|
|
45
|
+
LOCCRC: 14,
|
|
46
|
+
LOCSIZ: 18,
|
|
47
|
+
LOCLEN: 22,
|
|
48
|
+
LOCNAM: 26,
|
|
49
|
+
LOCEXT: 28,
|
|
50
|
+
EXTSIG: 134695760,
|
|
51
|
+
EXTHDR: 16,
|
|
52
|
+
EXTCRC: 4,
|
|
53
|
+
EXTSIZ: 8,
|
|
54
|
+
EXTLEN: 12,
|
|
55
|
+
CENHDR: 46,
|
|
56
|
+
CENSIG: 33639248,
|
|
57
|
+
CENVEM: 4,
|
|
58
|
+
CENVER: 6,
|
|
59
|
+
CENFLG: 8,
|
|
60
|
+
CENHOW: 10,
|
|
61
|
+
CENTIM: 12,
|
|
62
|
+
CENCRC: 16,
|
|
63
|
+
CENSIZ: 20,
|
|
64
|
+
CENLEN: 24,
|
|
65
|
+
CENNAM: 28,
|
|
66
|
+
CENEXT: 30,
|
|
67
|
+
CENCOM: 32,
|
|
68
|
+
CENDSK: 34,
|
|
69
|
+
CENATT: 36,
|
|
70
|
+
CENATX: 38,
|
|
71
|
+
CENOFF: 42,
|
|
72
|
+
ENDHDR: 22,
|
|
73
|
+
ENDSIG: 101010256,
|
|
74
|
+
ENDSUB: 8,
|
|
75
|
+
ENDTOT: 10,
|
|
76
|
+
ENDSIZ: 12,
|
|
77
|
+
ENDOFF: 16,
|
|
78
|
+
ENDCOM: 20,
|
|
79
|
+
END64HDR: 20,
|
|
80
|
+
END64SIG: 117853008,
|
|
81
|
+
END64START: 4,
|
|
82
|
+
END64OFF: 8,
|
|
83
|
+
END64NUMDISKS: 16,
|
|
84
|
+
ZIP64SIG: 101075792,
|
|
85
|
+
ZIP64HDR: 56,
|
|
86
|
+
ZIP64LEAD: 12,
|
|
87
|
+
ZIP64SIZE: 4,
|
|
88
|
+
ZIP64VEM: 12,
|
|
89
|
+
ZIP64VER: 14,
|
|
90
|
+
ZIP64DSK: 16,
|
|
91
|
+
ZIP64DSKDIR: 20,
|
|
92
|
+
ZIP64SUB: 24,
|
|
93
|
+
ZIP64TOT: 32,
|
|
94
|
+
ZIP64SIZB: 40,
|
|
95
|
+
ZIP64OFF: 48,
|
|
96
|
+
ZIP64EXTRA: 56,
|
|
97
|
+
STORED: 0,
|
|
98
|
+
SHRUNK: 1,
|
|
99
|
+
REDUCED1: 2,
|
|
100
|
+
REDUCED2: 3,
|
|
101
|
+
REDUCED3: 4,
|
|
102
|
+
REDUCED4: 5,
|
|
103
|
+
IMPLODED: 6,
|
|
104
|
+
DEFLATED: 8,
|
|
105
|
+
ENHANCED_DEFLATED: 9,
|
|
106
|
+
PKWARE: 10,
|
|
107
|
+
BZIP2: 12,
|
|
108
|
+
LZMA: 14,
|
|
109
|
+
IBM_TERSE: 18,
|
|
110
|
+
IBM_LZ77: 19,
|
|
111
|
+
AES_ENCRYPT: 99,
|
|
112
|
+
FLG_ENC: 1,
|
|
113
|
+
FLG_COMP1: 2,
|
|
114
|
+
FLG_COMP2: 4,
|
|
115
|
+
FLG_DESC: 8,
|
|
116
|
+
FLG_ENH: 16,
|
|
117
|
+
FLG_PATCH: 32,
|
|
118
|
+
FLG_STR: 64,
|
|
119
|
+
FLG_EFS: 2048,
|
|
120
|
+
FLG_MSK: 4096,
|
|
121
|
+
FILE: 2,
|
|
122
|
+
BUFFER: 1,
|
|
123
|
+
NONE: 0,
|
|
124
|
+
EF_ID: 0,
|
|
125
|
+
EF_SIZE: 2,
|
|
126
|
+
ID_ZIP64: 1,
|
|
127
|
+
ID_AVINFO: 7,
|
|
128
|
+
ID_PFS: 8,
|
|
129
|
+
ID_OS2: 9,
|
|
130
|
+
ID_NTFS: 10,
|
|
131
|
+
ID_OPENVMS: 12,
|
|
132
|
+
ID_UNIX: 13,
|
|
133
|
+
ID_FORK: 14,
|
|
134
|
+
ID_PATCH: 15,
|
|
135
|
+
ID_X509_PKCS7: 20,
|
|
136
|
+
ID_X509_CERTID_F: 21,
|
|
137
|
+
ID_X509_CERTID_C: 22,
|
|
138
|
+
ID_STRONGENC: 23,
|
|
139
|
+
ID_RECORD_MGT: 24,
|
|
140
|
+
ID_X509_PKCS7_RL: 25,
|
|
141
|
+
ID_IBM1: 101,
|
|
142
|
+
ID_IBM2: 102,
|
|
143
|
+
ID_POSZIP: 18064,
|
|
144
|
+
EF_ZIP64_OR_32: 4294967295,
|
|
145
|
+
EF_ZIP64_OR_16: 65535,
|
|
146
|
+
EF_ZIP64_SUNCOMP: 0,
|
|
147
|
+
EF_ZIP64_SCOMP: 8,
|
|
148
|
+
EF_ZIP64_RHO: 16,
|
|
149
|
+
EF_ZIP64_DSN: 24
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// ../../node_modules/adm-zip/util/errors.js
|
|
154
|
+
var require_errors = __commonJS((exports) => {
|
|
155
|
+
var errors = {
|
|
156
|
+
INVALID_LOC: "Invalid LOC header (bad signature)",
|
|
157
|
+
INVALID_CEN: "Invalid CEN header (bad signature)",
|
|
158
|
+
INVALID_END: "Invalid END header (bad signature)",
|
|
159
|
+
DESCRIPTOR_NOT_EXIST: "No descriptor present",
|
|
160
|
+
DESCRIPTOR_UNKNOWN: "Unknown descriptor format",
|
|
161
|
+
DESCRIPTOR_FAULTY: "Descriptor data is malformed",
|
|
162
|
+
NO_DATA: "Nothing to decompress",
|
|
163
|
+
BAD_CRC: "CRC32 checksum failed {0}",
|
|
164
|
+
FILE_IN_THE_WAY: "There is a file in the way: {0}",
|
|
165
|
+
UNKNOWN_METHOD: "Invalid/unsupported compression method",
|
|
166
|
+
AVAIL_DATA: "inflate::Available inflate data did not terminate",
|
|
167
|
+
INVALID_DISTANCE: "inflate::Invalid literal/length or distance code in fixed or dynamic block",
|
|
168
|
+
TO_MANY_CODES: "inflate::Dynamic block code description: too many length or distance codes",
|
|
169
|
+
INVALID_REPEAT_LEN: "inflate::Dynamic block code description: repeat more than specified lengths",
|
|
170
|
+
INVALID_REPEAT_FIRST: "inflate::Dynamic block code description: repeat lengths with no first length",
|
|
171
|
+
INCOMPLETE_CODES: "inflate::Dynamic block code description: code lengths codes incomplete",
|
|
172
|
+
INVALID_DYN_DISTANCE: "inflate::Dynamic block code description: invalid distance code lengths",
|
|
173
|
+
INVALID_CODES_LEN: "inflate::Dynamic block code description: invalid literal/length code lengths",
|
|
174
|
+
INVALID_STORE_BLOCK: "inflate::Stored block length did not match one's complement",
|
|
175
|
+
INVALID_BLOCK_TYPE: "inflate::Invalid block type (type == 3)",
|
|
176
|
+
CANT_EXTRACT_FILE: "Could not extract the file",
|
|
177
|
+
CANT_OVERRIDE: "Target file already exists",
|
|
178
|
+
DISK_ENTRY_TOO_LARGE: "Number of disk entries is too large",
|
|
179
|
+
NO_ZIP: "No zip file was loaded",
|
|
180
|
+
NO_ENTRY: "Entry doesn't exist",
|
|
181
|
+
DIRECTORY_CONTENT_ERROR: "A directory cannot have content",
|
|
182
|
+
FILE_NOT_FOUND: 'File not found: "{0}"',
|
|
183
|
+
NOT_IMPLEMENTED: "Not implemented",
|
|
184
|
+
INVALID_FILENAME: "Invalid filename",
|
|
185
|
+
INVALID_FORMAT: "Invalid or unsupported zip format. No END header found",
|
|
186
|
+
INVALID_PASS_PARAM: "Incompatible password parameter",
|
|
187
|
+
WRONG_PASSWORD: "Wrong Password",
|
|
188
|
+
COMMENT_TOO_LONG: "Comment is too long",
|
|
189
|
+
EXTRA_FIELD_PARSE_ERROR: "Extra field parsing error"
|
|
190
|
+
};
|
|
191
|
+
function E(message) {
|
|
192
|
+
return function(...args) {
|
|
193
|
+
if (args.length) {
|
|
194
|
+
message = message.replace(/\{(\d)\}/g, (_, n) => args[n] || "");
|
|
195
|
+
}
|
|
196
|
+
return new Error("ADM-ZIP: " + message);
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
for (const msg of Object.keys(errors)) {
|
|
200
|
+
exports[msg] = E(errors[msg]);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// ../../node_modules/adm-zip/util/utils.js
|
|
205
|
+
var require_utils = __commonJS((exports, module) => {
|
|
206
|
+
var fsystem = __require("fs");
|
|
207
|
+
var pth = __require("path");
|
|
208
|
+
var Constants = require_constants();
|
|
209
|
+
var Errors = require_errors();
|
|
210
|
+
var isWin = typeof process === "object" && process.platform === "win32";
|
|
211
|
+
var is_Obj = (obj) => typeof obj === "object" && obj !== null;
|
|
212
|
+
var crcTable = new Uint32Array(256).map((t, c) => {
|
|
213
|
+
for (let k = 0;k < 8; k++) {
|
|
214
|
+
if ((c & 1) !== 0) {
|
|
215
|
+
c = 3988292384 ^ c >>> 1;
|
|
216
|
+
} else {
|
|
217
|
+
c >>>= 1;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return c >>> 0;
|
|
221
|
+
});
|
|
222
|
+
function Utils(opts) {
|
|
223
|
+
this.sep = pth.sep;
|
|
224
|
+
this.fs = fsystem;
|
|
225
|
+
if (is_Obj(opts)) {
|
|
226
|
+
if (is_Obj(opts.fs) && typeof opts.fs.statSync === "function") {
|
|
227
|
+
this.fs = opts.fs;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
module.exports = Utils;
|
|
232
|
+
Utils.prototype.makeDir = function(folder) {
|
|
233
|
+
const self = this;
|
|
234
|
+
function mkdirSync(fpath) {
|
|
235
|
+
let resolvedPath = fpath.split(self.sep)[0];
|
|
236
|
+
fpath.split(self.sep).forEach(function(name) {
|
|
237
|
+
if (!name || name.substr(-1, 1) === ":")
|
|
238
|
+
return;
|
|
239
|
+
resolvedPath += self.sep + name;
|
|
240
|
+
var stat;
|
|
241
|
+
try {
|
|
242
|
+
stat = self.fs.statSync(resolvedPath);
|
|
243
|
+
} catch (e) {
|
|
244
|
+
if (e.message && e.message.startsWith("ENOENT")) {
|
|
245
|
+
self.fs.mkdirSync(resolvedPath);
|
|
246
|
+
} else {
|
|
247
|
+
throw e;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (stat && stat.isFile())
|
|
251
|
+
throw Errors.FILE_IN_THE_WAY(`"${resolvedPath}"`);
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
mkdirSync(folder);
|
|
255
|
+
};
|
|
256
|
+
Utils.prototype.writeFileTo = function(path, content, overwrite, attr) {
|
|
257
|
+
const self = this;
|
|
258
|
+
if (self.fs.existsSync(path)) {
|
|
259
|
+
if (!overwrite)
|
|
260
|
+
return false;
|
|
261
|
+
var stat = self.fs.statSync(path);
|
|
262
|
+
if (stat.isDirectory()) {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
var folder = pth.dirname(path);
|
|
267
|
+
if (!self.fs.existsSync(folder)) {
|
|
268
|
+
self.makeDir(folder);
|
|
269
|
+
}
|
|
270
|
+
var fd;
|
|
271
|
+
try {
|
|
272
|
+
fd = self.fs.openSync(path, "w", 438);
|
|
273
|
+
} catch (e) {
|
|
274
|
+
self.fs.chmodSync(path, 438);
|
|
275
|
+
fd = self.fs.openSync(path, "w", 438);
|
|
276
|
+
}
|
|
277
|
+
if (fd) {
|
|
278
|
+
try {
|
|
279
|
+
self.fs.writeSync(fd, content, 0, content.length, 0);
|
|
280
|
+
} finally {
|
|
281
|
+
self.fs.closeSync(fd);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
self.fs.chmodSync(path, attr || 438);
|
|
285
|
+
return true;
|
|
286
|
+
};
|
|
287
|
+
Utils.prototype.writeFileToAsync = function(path, content, overwrite, attr, callback) {
|
|
288
|
+
if (typeof attr === "function") {
|
|
289
|
+
callback = attr;
|
|
290
|
+
attr = undefined;
|
|
291
|
+
}
|
|
292
|
+
const self = this;
|
|
293
|
+
self.fs.exists(path, function(exist) {
|
|
294
|
+
if (exist && !overwrite)
|
|
295
|
+
return callback(false);
|
|
296
|
+
self.fs.stat(path, function(err, stat) {
|
|
297
|
+
if (exist && stat && stat.isDirectory()) {
|
|
298
|
+
return callback(false);
|
|
299
|
+
}
|
|
300
|
+
var folder = pth.dirname(path);
|
|
301
|
+
self.fs.exists(folder, function(exists) {
|
|
302
|
+
if (!exists) {
|
|
303
|
+
try {
|
|
304
|
+
self.makeDir(folder);
|
|
305
|
+
} catch (e) {
|
|
306
|
+
return callback(false);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
const writeToFd = function(fd) {
|
|
310
|
+
self.fs.write(fd, content, 0, content.length, 0, function(writeErr) {
|
|
311
|
+
self.fs.close(fd, function() {
|
|
312
|
+
if (writeErr)
|
|
313
|
+
return callback(false);
|
|
314
|
+
self.fs.chmod(path, attr || 438, function() {
|
|
315
|
+
callback(true);
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
};
|
|
320
|
+
self.fs.open(path, "w", 438, function(err2, fd) {
|
|
321
|
+
if (err2) {
|
|
322
|
+
self.fs.chmod(path, 438, function() {
|
|
323
|
+
self.fs.open(path, "w", 438, function(retryErr, fd2) {
|
|
324
|
+
if (retryErr || !fd2)
|
|
325
|
+
return callback(false);
|
|
326
|
+
writeToFd(fd2);
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
} else if (fd) {
|
|
330
|
+
writeToFd(fd);
|
|
331
|
+
} else {
|
|
332
|
+
callback(false);
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
Utils.prototype.findFiles = function(path) {
|
|
340
|
+
const self = this;
|
|
341
|
+
function findSync(dir, pattern, recursive, visited) {
|
|
342
|
+
if (typeof pattern === "boolean") {
|
|
343
|
+
recursive = pattern;
|
|
344
|
+
pattern = undefined;
|
|
345
|
+
}
|
|
346
|
+
let files = [];
|
|
347
|
+
self.fs.readdirSync(dir).forEach(function(file) {
|
|
348
|
+
const path2 = pth.join(dir, file);
|
|
349
|
+
const stat = self.fs.statSync(path2);
|
|
350
|
+
if (!pattern || pattern.test(path2)) {
|
|
351
|
+
files.push(pth.normalize(path2) + (stat.isDirectory() ? self.sep : ""));
|
|
352
|
+
}
|
|
353
|
+
if (stat.isDirectory() && recursive) {
|
|
354
|
+
const realDir = self.fs.realpathSync(path2);
|
|
355
|
+
if (!visited.has(realDir)) {
|
|
356
|
+
visited.add(realDir);
|
|
357
|
+
files = files.concat(findSync(path2, pattern, recursive, visited));
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
return files;
|
|
362
|
+
}
|
|
363
|
+
return findSync(path, undefined, true, new Set([self.fs.realpathSync(path)]));
|
|
364
|
+
};
|
|
365
|
+
Utils.prototype.findFilesAsync = function(dir, cb) {
|
|
366
|
+
const self = this;
|
|
367
|
+
const results = [];
|
|
368
|
+
let finished = false;
|
|
369
|
+
const finish = function(err) {
|
|
370
|
+
if (finished)
|
|
371
|
+
return;
|
|
372
|
+
finished = true;
|
|
373
|
+
cb(err, err ? undefined : results);
|
|
374
|
+
};
|
|
375
|
+
const walk = function(dir2, visited, done) {
|
|
376
|
+
self.fs.readdir(dir2, function(err, list) {
|
|
377
|
+
if (err)
|
|
378
|
+
return done(err);
|
|
379
|
+
let pending = list.length;
|
|
380
|
+
if (!pending)
|
|
381
|
+
return done();
|
|
382
|
+
list.forEach(function(name) {
|
|
383
|
+
const file = pth.join(dir2, name);
|
|
384
|
+
self.fs.stat(file, function(err2, stat) {
|
|
385
|
+
if (err2)
|
|
386
|
+
return done(err2);
|
|
387
|
+
if (!stat) {
|
|
388
|
+
if (!--pending)
|
|
389
|
+
done();
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
results.push(pth.normalize(file) + (stat.isDirectory() ? self.sep : ""));
|
|
393
|
+
if (!stat.isDirectory()) {
|
|
394
|
+
if (!--pending)
|
|
395
|
+
done();
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
self.fs.realpath(file, function(err3, realDir) {
|
|
399
|
+
if (err3)
|
|
400
|
+
return done(err3);
|
|
401
|
+
if (visited.has(realDir)) {
|
|
402
|
+
if (!--pending)
|
|
403
|
+
done();
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
visited.add(realDir);
|
|
407
|
+
walk(file, visited, function(err4) {
|
|
408
|
+
if (err4)
|
|
409
|
+
return done(err4);
|
|
410
|
+
if (!--pending)
|
|
411
|
+
done();
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
};
|
|
418
|
+
self.fs.realpath(dir, function(err, realDir) {
|
|
419
|
+
if (err)
|
|
420
|
+
return finish(err);
|
|
421
|
+
walk(dir, new Set([realDir]), finish);
|
|
422
|
+
});
|
|
423
|
+
};
|
|
424
|
+
Utils.prototype.getAttributes = function() {};
|
|
425
|
+
Utils.prototype.setAttributes = function() {};
|
|
426
|
+
Utils.crc32update = function(crc, byte) {
|
|
427
|
+
return crcTable[(crc ^ byte) & 255] ^ crc >>> 8;
|
|
428
|
+
};
|
|
429
|
+
Utils.crc32 = function(buf) {
|
|
430
|
+
if (typeof buf === "string") {
|
|
431
|
+
buf = Buffer.from(buf, "utf8");
|
|
432
|
+
}
|
|
433
|
+
let len = buf.length;
|
|
434
|
+
let crc = ~0;
|
|
435
|
+
for (let off = 0;off < len; )
|
|
436
|
+
crc = Utils.crc32update(crc, buf[off++]);
|
|
437
|
+
return ~crc >>> 0;
|
|
438
|
+
};
|
|
439
|
+
Utils.methodToString = function(method) {
|
|
440
|
+
switch (method) {
|
|
441
|
+
case Constants.STORED:
|
|
442
|
+
return "STORED (" + method + ")";
|
|
443
|
+
case Constants.DEFLATED:
|
|
444
|
+
return "DEFLATED (" + method + ")";
|
|
445
|
+
default:
|
|
446
|
+
return "UNSUPPORTED (" + method + ")";
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
Utils.canonical = function(path) {
|
|
450
|
+
if (!path)
|
|
451
|
+
return "";
|
|
452
|
+
const safeSuffix = pth.posix.normalize("/" + path.split("\\").join("/"));
|
|
453
|
+
return pth.join(".", safeSuffix);
|
|
454
|
+
};
|
|
455
|
+
Utils.zipnamefix = function(path) {
|
|
456
|
+
if (!path)
|
|
457
|
+
return "";
|
|
458
|
+
const safeSuffix = pth.posix.normalize("/" + path.split("\\").join("/"));
|
|
459
|
+
return pth.posix.join(".", safeSuffix);
|
|
460
|
+
};
|
|
461
|
+
Utils.findLast = function(arr, callback) {
|
|
462
|
+
if (!Array.isArray(arr))
|
|
463
|
+
throw new TypeError("arr is not array");
|
|
464
|
+
const len = arr.length >>> 0;
|
|
465
|
+
for (let i = len - 1;i >= 0; i--) {
|
|
466
|
+
if (callback(arr[i], i, arr)) {
|
|
467
|
+
return arr[i];
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return;
|
|
471
|
+
};
|
|
472
|
+
Utils.sanitize = function(prefix, name) {
|
|
473
|
+
prefix = pth.resolve(pth.normalize(prefix));
|
|
474
|
+
var parts = name.split("/");
|
|
475
|
+
for (var i = 0, l = parts.length;i < l; i++) {
|
|
476
|
+
var path = pth.normalize(pth.join(prefix, parts.slice(i, l).join(pth.sep)));
|
|
477
|
+
if (path === prefix || path.startsWith(prefix + pth.sep)) {
|
|
478
|
+
return path;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return pth.normalize(pth.join(prefix, pth.basename(name)));
|
|
482
|
+
};
|
|
483
|
+
Utils.toBuffer = function toBuffer(input, encoder) {
|
|
484
|
+
if (Buffer.isBuffer(input)) {
|
|
485
|
+
return input;
|
|
486
|
+
} else if (input instanceof Uint8Array) {
|
|
487
|
+
return Buffer.from(input);
|
|
488
|
+
} else {
|
|
489
|
+
return typeof input === "string" ? encoder(input) : Buffer.alloc(0);
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
Utils.readBigUInt64LE = function(buffer, index) {
|
|
493
|
+
const lo = buffer.readUInt32LE(index);
|
|
494
|
+
const hi = buffer.readUInt32LE(index + 4);
|
|
495
|
+
return hi * 4294967296 + lo;
|
|
496
|
+
};
|
|
497
|
+
Utils.writeBigUInt64LE = function(buffer, value, index) {
|
|
498
|
+
const lo = value >>> 0;
|
|
499
|
+
const hi = Math.floor(value / 4294967296) >>> 0;
|
|
500
|
+
buffer.writeUInt32LE(lo, index);
|
|
501
|
+
buffer.writeUInt32LE(hi, index + 4);
|
|
502
|
+
};
|
|
503
|
+
Utils.fromDOS2Date = function(val) {
|
|
504
|
+
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);
|
|
505
|
+
};
|
|
506
|
+
Utils.fromDate2DOS = function(val) {
|
|
507
|
+
let date = 0;
|
|
508
|
+
let time = 0;
|
|
509
|
+
if (val.getFullYear() > 1979) {
|
|
510
|
+
date = (val.getFullYear() - 1980 & 127) << 9 | val.getMonth() + 1 << 5 | val.getDate();
|
|
511
|
+
time = val.getHours() << 11 | val.getMinutes() << 5 | val.getSeconds() >> 1;
|
|
512
|
+
}
|
|
513
|
+
return date << 16 | time;
|
|
514
|
+
};
|
|
515
|
+
Utils.isWin = isWin;
|
|
516
|
+
Utils.crcTable = crcTable;
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
// ../../node_modules/adm-zip/util/fattr.js
|
|
520
|
+
var require_fattr = __commonJS((exports, module) => {
|
|
521
|
+
var pth = __require("path");
|
|
522
|
+
module.exports = function(path, { fs }) {
|
|
523
|
+
var _path = path || "", _obj = newAttr(), _stat = null;
|
|
524
|
+
function newAttr() {
|
|
525
|
+
return {
|
|
526
|
+
directory: false,
|
|
527
|
+
readonly: false,
|
|
528
|
+
hidden: false,
|
|
529
|
+
executable: false,
|
|
530
|
+
mtime: 0,
|
|
531
|
+
atime: 0
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
if (_path && fs.existsSync(_path)) {
|
|
535
|
+
_stat = fs.statSync(_path);
|
|
536
|
+
_obj.directory = _stat.isDirectory();
|
|
537
|
+
_obj.mtime = _stat.mtime;
|
|
538
|
+
_obj.atime = _stat.atime;
|
|
539
|
+
_obj.executable = (73 & _stat.mode) !== 0;
|
|
540
|
+
_obj.readonly = (128 & _stat.mode) === 0;
|
|
541
|
+
_obj.hidden = pth.basename(_path)[0] === ".";
|
|
542
|
+
} else {
|
|
543
|
+
console.warn("Invalid path: " + _path);
|
|
544
|
+
}
|
|
545
|
+
return {
|
|
546
|
+
get directory() {
|
|
547
|
+
return _obj.directory;
|
|
548
|
+
},
|
|
549
|
+
get readOnly() {
|
|
550
|
+
return _obj.readonly;
|
|
551
|
+
},
|
|
552
|
+
get hidden() {
|
|
553
|
+
return _obj.hidden;
|
|
554
|
+
},
|
|
555
|
+
get mtime() {
|
|
556
|
+
return _obj.mtime;
|
|
557
|
+
},
|
|
558
|
+
get atime() {
|
|
559
|
+
return _obj.atime;
|
|
560
|
+
},
|
|
561
|
+
get executable() {
|
|
562
|
+
return _obj.executable;
|
|
563
|
+
},
|
|
564
|
+
decodeAttributes: function() {},
|
|
565
|
+
encodeAttributes: function() {},
|
|
566
|
+
toJSON: function() {
|
|
567
|
+
return {
|
|
568
|
+
path: _path,
|
|
569
|
+
isDirectory: _obj.directory,
|
|
570
|
+
isReadOnly: _obj.readonly,
|
|
571
|
+
isHidden: _obj.hidden,
|
|
572
|
+
isExecutable: _obj.executable,
|
|
573
|
+
mTime: _obj.mtime,
|
|
574
|
+
aTime: _obj.atime
|
|
575
|
+
};
|
|
576
|
+
},
|
|
577
|
+
toString: function() {
|
|
578
|
+
return JSON.stringify(this.toJSON(), null, "\t");
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
};
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
// ../../node_modules/adm-zip/util/decoder.js
|
|
585
|
+
var require_decoder = __commonJS((exports, module) => {
|
|
586
|
+
module.exports = {
|
|
587
|
+
efs: true,
|
|
588
|
+
encode: (data) => Buffer.from(data, "utf8"),
|
|
589
|
+
decode: (data) => data.toString("utf8")
|
|
590
|
+
};
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
// ../../node_modules/adm-zip/util/index.js
|
|
594
|
+
var require_util = __commonJS((exports, module) => {
|
|
595
|
+
module.exports = require_utils();
|
|
596
|
+
module.exports.Constants = require_constants();
|
|
597
|
+
module.exports.Errors = require_errors();
|
|
598
|
+
module.exports.FileAttr = require_fattr();
|
|
599
|
+
module.exports.decoder = require_decoder();
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
// ../../node_modules/adm-zip/headers/entryHeader.js
|
|
603
|
+
var require_entryHeader = __commonJS((exports, module) => {
|
|
604
|
+
var Utils = require_util();
|
|
605
|
+
var Constants = Utils.Constants;
|
|
606
|
+
module.exports = function() {
|
|
607
|
+
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;
|
|
608
|
+
_verMade |= Utils.isWin ? 2560 : 768;
|
|
609
|
+
_flags |= Constants.FLG_EFS;
|
|
610
|
+
const _localHeader = {
|
|
611
|
+
extraLen: 0
|
|
612
|
+
};
|
|
613
|
+
const uint32 = (val) => Math.max(0, val) >>> 0;
|
|
614
|
+
const uint16 = (val) => Math.max(0, val) & 65535;
|
|
615
|
+
const uint8 = (val) => Math.max(0, val) & 255;
|
|
616
|
+
_time = Utils.fromDate2DOS(new Date);
|
|
617
|
+
return {
|
|
618
|
+
get made() {
|
|
619
|
+
return _verMade;
|
|
620
|
+
},
|
|
621
|
+
set made(val) {
|
|
622
|
+
_verMade = val;
|
|
623
|
+
},
|
|
624
|
+
get version() {
|
|
625
|
+
return _version;
|
|
626
|
+
},
|
|
627
|
+
set version(val) {
|
|
628
|
+
_version = val;
|
|
629
|
+
},
|
|
630
|
+
get flags() {
|
|
631
|
+
return _flags;
|
|
632
|
+
},
|
|
633
|
+
set flags(val) {
|
|
634
|
+
_flags = val;
|
|
635
|
+
},
|
|
636
|
+
get flags_efs() {
|
|
637
|
+
return (_flags & Constants.FLG_EFS) > 0;
|
|
638
|
+
},
|
|
639
|
+
set flags_efs(val) {
|
|
640
|
+
if (val) {
|
|
641
|
+
_flags |= Constants.FLG_EFS;
|
|
642
|
+
} else {
|
|
643
|
+
_flags &= ~Constants.FLG_EFS;
|
|
644
|
+
}
|
|
645
|
+
},
|
|
646
|
+
get flags_desc() {
|
|
647
|
+
return (_flags & Constants.FLG_DESC) > 0;
|
|
648
|
+
},
|
|
649
|
+
set flags_desc(val) {
|
|
650
|
+
if (val) {
|
|
651
|
+
_flags |= Constants.FLG_DESC;
|
|
652
|
+
} else {
|
|
653
|
+
_flags &= ~Constants.FLG_DESC;
|
|
654
|
+
}
|
|
655
|
+
},
|
|
656
|
+
get method() {
|
|
657
|
+
return _method;
|
|
658
|
+
},
|
|
659
|
+
set method(val) {
|
|
660
|
+
switch (val) {
|
|
661
|
+
case Constants.STORED:
|
|
662
|
+
this.version = 10;
|
|
663
|
+
break;
|
|
664
|
+
case Constants.DEFLATED:
|
|
665
|
+
default:
|
|
666
|
+
this.version = 20;
|
|
667
|
+
}
|
|
668
|
+
_method = val;
|
|
669
|
+
},
|
|
670
|
+
get time() {
|
|
671
|
+
return Utils.fromDOS2Date(this.timeval);
|
|
672
|
+
},
|
|
673
|
+
set time(val) {
|
|
674
|
+
val = new Date(val);
|
|
675
|
+
this.timeval = Utils.fromDate2DOS(val);
|
|
676
|
+
},
|
|
677
|
+
get timeval() {
|
|
678
|
+
return _time;
|
|
679
|
+
},
|
|
680
|
+
set timeval(val) {
|
|
681
|
+
_time = uint32(val);
|
|
682
|
+
},
|
|
683
|
+
get timeHighByte() {
|
|
684
|
+
return uint8(_time >>> 8);
|
|
685
|
+
},
|
|
686
|
+
get crc() {
|
|
687
|
+
return _crc;
|
|
688
|
+
},
|
|
689
|
+
set crc(val) {
|
|
690
|
+
_crc = uint32(val);
|
|
691
|
+
},
|
|
692
|
+
get compressedSize() {
|
|
693
|
+
return _compressedSize;
|
|
694
|
+
},
|
|
695
|
+
set compressedSize(val) {
|
|
696
|
+
_compressedSize = uint32(val);
|
|
697
|
+
},
|
|
698
|
+
get size() {
|
|
699
|
+
return _size;
|
|
700
|
+
},
|
|
701
|
+
set size(val) {
|
|
702
|
+
_size = uint32(val);
|
|
703
|
+
},
|
|
704
|
+
get fileNameLength() {
|
|
705
|
+
return _fnameLen;
|
|
706
|
+
},
|
|
707
|
+
set fileNameLength(val) {
|
|
708
|
+
_fnameLen = val;
|
|
709
|
+
},
|
|
710
|
+
get extraLength() {
|
|
711
|
+
return _extraLen;
|
|
712
|
+
},
|
|
713
|
+
set extraLength(val) {
|
|
714
|
+
_extraLen = val;
|
|
715
|
+
},
|
|
716
|
+
get extraLocalLength() {
|
|
717
|
+
return _localHeader.extraLen;
|
|
718
|
+
},
|
|
719
|
+
set extraLocalLength(val) {
|
|
720
|
+
_localHeader.extraLen = val;
|
|
721
|
+
},
|
|
722
|
+
get commentLength() {
|
|
723
|
+
return _comLen;
|
|
724
|
+
},
|
|
725
|
+
set commentLength(val) {
|
|
726
|
+
_comLen = val;
|
|
727
|
+
},
|
|
728
|
+
get diskNumStart() {
|
|
729
|
+
return _diskStart;
|
|
730
|
+
},
|
|
731
|
+
set diskNumStart(val) {
|
|
732
|
+
_diskStart = uint32(val);
|
|
733
|
+
},
|
|
734
|
+
get inAttr() {
|
|
735
|
+
return _inattr;
|
|
736
|
+
},
|
|
737
|
+
set inAttr(val) {
|
|
738
|
+
_inattr = uint32(val);
|
|
739
|
+
},
|
|
740
|
+
get attr() {
|
|
741
|
+
return _attr;
|
|
742
|
+
},
|
|
743
|
+
set attr(val) {
|
|
744
|
+
_attr = uint32(val);
|
|
745
|
+
},
|
|
746
|
+
get fileAttr() {
|
|
747
|
+
return (_attr || 0) >> 16 & 4095;
|
|
748
|
+
},
|
|
749
|
+
get offset() {
|
|
750
|
+
return _offset;
|
|
751
|
+
},
|
|
752
|
+
set offset(val) {
|
|
753
|
+
_offset = uint32(val);
|
|
754
|
+
},
|
|
755
|
+
get encrypted() {
|
|
756
|
+
return (_flags & Constants.FLG_ENC) === Constants.FLG_ENC;
|
|
757
|
+
},
|
|
758
|
+
get centralHeaderSize() {
|
|
759
|
+
return Constants.CENHDR + _fnameLen + _extraLen + _comLen;
|
|
760
|
+
},
|
|
761
|
+
get realDataOffset() {
|
|
762
|
+
return _offset + Constants.LOCHDR + _localHeader.fnameLen + _localHeader.extraLen;
|
|
763
|
+
},
|
|
764
|
+
get localHeader() {
|
|
765
|
+
return _localHeader;
|
|
766
|
+
},
|
|
767
|
+
loadLocalHeaderFromBinary: function(input) {
|
|
768
|
+
var data = input.slice(_offset, _offset + Constants.LOCHDR);
|
|
769
|
+
if (data.readUInt32LE(0) !== Constants.LOCSIG) {
|
|
770
|
+
throw Utils.Errors.INVALID_LOC();
|
|
771
|
+
}
|
|
772
|
+
_localHeader.version = data.readUInt16LE(Constants.LOCVER);
|
|
773
|
+
_localHeader.flags = data.readUInt16LE(Constants.LOCFLG);
|
|
774
|
+
_localHeader.flags_desc = (_localHeader.flags & Constants.FLG_DESC) > 0;
|
|
775
|
+
_localHeader.method = data.readUInt16LE(Constants.LOCHOW);
|
|
776
|
+
_localHeader.time = data.readUInt32LE(Constants.LOCTIM);
|
|
777
|
+
_localHeader.crc = data.readUInt32LE(Constants.LOCCRC);
|
|
778
|
+
_localHeader.compressedSize = data.readUInt32LE(Constants.LOCSIZ);
|
|
779
|
+
_localHeader.size = data.readUInt32LE(Constants.LOCLEN);
|
|
780
|
+
_localHeader.fnameLen = data.readUInt16LE(Constants.LOCNAM);
|
|
781
|
+
_localHeader.extraLen = data.readUInt16LE(Constants.LOCEXT);
|
|
782
|
+
const extraStart = _offset + Constants.LOCHDR + _localHeader.fnameLen;
|
|
783
|
+
const extraEnd = extraStart + _localHeader.extraLen;
|
|
784
|
+
return input.slice(extraStart, extraEnd);
|
|
785
|
+
},
|
|
786
|
+
loadFromBinary: function(data) {
|
|
787
|
+
if (data.length !== Constants.CENHDR || data.readUInt32LE(0) !== Constants.CENSIG) {
|
|
788
|
+
throw Utils.Errors.INVALID_CEN();
|
|
789
|
+
}
|
|
790
|
+
_verMade = data.readUInt16LE(Constants.CENVEM);
|
|
791
|
+
_version = data.readUInt16LE(Constants.CENVER);
|
|
792
|
+
_flags = data.readUInt16LE(Constants.CENFLG);
|
|
793
|
+
_method = data.readUInt16LE(Constants.CENHOW);
|
|
794
|
+
_time = data.readUInt32LE(Constants.CENTIM);
|
|
795
|
+
_crc = data.readUInt32LE(Constants.CENCRC);
|
|
796
|
+
_compressedSize = data.readUInt32LE(Constants.CENSIZ);
|
|
797
|
+
_size = data.readUInt32LE(Constants.CENLEN);
|
|
798
|
+
_fnameLen = data.readUInt16LE(Constants.CENNAM);
|
|
799
|
+
_extraLen = data.readUInt16LE(Constants.CENEXT);
|
|
800
|
+
_comLen = data.readUInt16LE(Constants.CENCOM);
|
|
801
|
+
_diskStart = data.readUInt16LE(Constants.CENDSK);
|
|
802
|
+
_inattr = data.readUInt16LE(Constants.CENATT);
|
|
803
|
+
_attr = data.readUInt32LE(Constants.CENATX);
|
|
804
|
+
_offset = data.readUInt32LE(Constants.CENOFF);
|
|
805
|
+
},
|
|
806
|
+
localHeaderToBinary: function() {
|
|
807
|
+
var data = Buffer.alloc(Constants.LOCHDR);
|
|
808
|
+
data.writeUInt32LE(Constants.LOCSIG, 0);
|
|
809
|
+
data.writeUInt16LE(_version, Constants.LOCVER);
|
|
810
|
+
data.writeUInt16LE(_flags & ~Constants.FLG_DESC, Constants.LOCFLG);
|
|
811
|
+
data.writeUInt16LE(_method, Constants.LOCHOW);
|
|
812
|
+
data.writeUInt32LE(_time, Constants.LOCTIM);
|
|
813
|
+
data.writeUInt32LE(_crc, Constants.LOCCRC);
|
|
814
|
+
data.writeUInt32LE(_compressedSize, Constants.LOCSIZ);
|
|
815
|
+
data.writeUInt32LE(_size, Constants.LOCLEN);
|
|
816
|
+
data.writeUInt16LE(_fnameLen, Constants.LOCNAM);
|
|
817
|
+
data.writeUInt16LE(_localHeader.extraLen, Constants.LOCEXT);
|
|
818
|
+
return data;
|
|
819
|
+
},
|
|
820
|
+
centralHeaderToBinary: function() {
|
|
821
|
+
var data = Buffer.alloc(Constants.CENHDR + _fnameLen + _extraLen + _comLen);
|
|
822
|
+
data.writeUInt32LE(Constants.CENSIG, 0);
|
|
823
|
+
data.writeUInt16LE(_verMade, Constants.CENVEM);
|
|
824
|
+
data.writeUInt16LE(_version, Constants.CENVER);
|
|
825
|
+
data.writeUInt16LE(_flags & ~Constants.FLG_DESC, Constants.CENFLG);
|
|
826
|
+
data.writeUInt16LE(_method, Constants.CENHOW);
|
|
827
|
+
data.writeUInt32LE(_time, Constants.CENTIM);
|
|
828
|
+
data.writeUInt32LE(_crc, Constants.CENCRC);
|
|
829
|
+
data.writeUInt32LE(_compressedSize, Constants.CENSIZ);
|
|
830
|
+
data.writeUInt32LE(_size, Constants.CENLEN);
|
|
831
|
+
data.writeUInt16LE(_fnameLen, Constants.CENNAM);
|
|
832
|
+
data.writeUInt16LE(_extraLen, Constants.CENEXT);
|
|
833
|
+
data.writeUInt16LE(_comLen, Constants.CENCOM);
|
|
834
|
+
data.writeUInt16LE(_diskStart, Constants.CENDSK);
|
|
835
|
+
data.writeUInt16LE(_inattr, Constants.CENATT);
|
|
836
|
+
data.writeUInt32LE(_attr, Constants.CENATX);
|
|
837
|
+
data.writeUInt32LE(_offset, Constants.CENOFF);
|
|
838
|
+
return data;
|
|
839
|
+
},
|
|
840
|
+
toJSON: function() {
|
|
841
|
+
const bytes = function(nr) {
|
|
842
|
+
return nr + " bytes";
|
|
843
|
+
};
|
|
844
|
+
return {
|
|
845
|
+
made: _verMade,
|
|
846
|
+
version: _version,
|
|
847
|
+
flags: _flags,
|
|
848
|
+
method: Utils.methodToString(_method),
|
|
849
|
+
time: this.time,
|
|
850
|
+
crc: "0x" + _crc.toString(16).toUpperCase(),
|
|
851
|
+
compressedSize: bytes(_compressedSize),
|
|
852
|
+
size: bytes(_size),
|
|
853
|
+
fileNameLength: bytes(_fnameLen),
|
|
854
|
+
extraLength: bytes(_extraLen),
|
|
855
|
+
commentLength: bytes(_comLen),
|
|
856
|
+
diskNumStart: _diskStart,
|
|
857
|
+
inAttr: _inattr,
|
|
858
|
+
attr: _attr,
|
|
859
|
+
offset: _offset,
|
|
860
|
+
centralHeaderSize: bytes(Constants.CENHDR + _fnameLen + _extraLen + _comLen)
|
|
861
|
+
};
|
|
862
|
+
},
|
|
863
|
+
toString: function() {
|
|
864
|
+
return JSON.stringify(this.toJSON(), null, "\t");
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
};
|
|
868
|
+
});
|
|
869
|
+
|
|
870
|
+
// ../../node_modules/adm-zip/headers/mainHeader.js
|
|
871
|
+
var require_mainHeader = __commonJS((exports, module) => {
|
|
872
|
+
var Utils = require_util();
|
|
873
|
+
var Constants = Utils.Constants;
|
|
874
|
+
module.exports = function() {
|
|
875
|
+
var _volumeEntries = 0, _totalEntries = 0, _size = 0, _offset = 0, _commentLength = 0;
|
|
876
|
+
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;
|
|
877
|
+
return {
|
|
878
|
+
get diskEntries() {
|
|
879
|
+
return _volumeEntries;
|
|
880
|
+
},
|
|
881
|
+
set diskEntries(val) {
|
|
882
|
+
_volumeEntries = _totalEntries = val;
|
|
883
|
+
},
|
|
884
|
+
get totalEntries() {
|
|
885
|
+
return _totalEntries;
|
|
886
|
+
},
|
|
887
|
+
set totalEntries(val) {
|
|
888
|
+
_totalEntries = _volumeEntries = val;
|
|
889
|
+
},
|
|
890
|
+
get size() {
|
|
891
|
+
return _size;
|
|
892
|
+
},
|
|
893
|
+
set size(val) {
|
|
894
|
+
_size = val;
|
|
895
|
+
},
|
|
896
|
+
get offset() {
|
|
897
|
+
return _offset;
|
|
898
|
+
},
|
|
899
|
+
set offset(val) {
|
|
900
|
+
_offset = val;
|
|
901
|
+
},
|
|
902
|
+
get commentLength() {
|
|
903
|
+
return _commentLength;
|
|
904
|
+
},
|
|
905
|
+
set commentLength(val) {
|
|
906
|
+
_commentLength = val;
|
|
907
|
+
},
|
|
908
|
+
get mainHeaderSize() {
|
|
909
|
+
return (needsZip64() ? Constants.ZIP64HDR + Constants.END64HDR : 0) + Constants.ENDHDR + _commentLength;
|
|
910
|
+
},
|
|
911
|
+
loadFromBinary: function(data) {
|
|
912
|
+
if ((data.length !== Constants.ENDHDR || data.readUInt32LE(0) !== Constants.ENDSIG) && (data.length < Constants.ZIP64HDR || data.readUInt32LE(0) !== Constants.ZIP64SIG)) {
|
|
913
|
+
throw Utils.Errors.INVALID_END();
|
|
914
|
+
}
|
|
915
|
+
if (data.readUInt32LE(0) === Constants.ENDSIG) {
|
|
916
|
+
_volumeEntries = data.readUInt16LE(Constants.ENDSUB);
|
|
917
|
+
_totalEntries = data.readUInt16LE(Constants.ENDTOT);
|
|
918
|
+
_size = data.readUInt32LE(Constants.ENDSIZ);
|
|
919
|
+
_offset = data.readUInt32LE(Constants.ENDOFF);
|
|
920
|
+
_commentLength = data.readUInt16LE(Constants.ENDCOM);
|
|
921
|
+
} else {
|
|
922
|
+
_volumeEntries = Utils.readBigUInt64LE(data, Constants.ZIP64SUB);
|
|
923
|
+
_totalEntries = Utils.readBigUInt64LE(data, Constants.ZIP64TOT);
|
|
924
|
+
_size = Utils.readBigUInt64LE(data, Constants.ZIP64SIZB);
|
|
925
|
+
_offset = Utils.readBigUInt64LE(data, Constants.ZIP64OFF);
|
|
926
|
+
_commentLength = 0;
|
|
927
|
+
}
|
|
928
|
+
},
|
|
929
|
+
toBinary: function() {
|
|
930
|
+
if (!needsZip64()) {
|
|
931
|
+
var b = Buffer.alloc(Constants.ENDHDR + _commentLength);
|
|
932
|
+
b.writeUInt32LE(Constants.ENDSIG, 0);
|
|
933
|
+
b.writeUInt32LE(0, 4);
|
|
934
|
+
b.writeUInt16LE(_volumeEntries, Constants.ENDSUB);
|
|
935
|
+
b.writeUInt16LE(_totalEntries, Constants.ENDTOT);
|
|
936
|
+
b.writeUInt32LE(_size, Constants.ENDSIZ);
|
|
937
|
+
b.writeUInt32LE(_offset, Constants.ENDOFF);
|
|
938
|
+
b.writeUInt16LE(_commentLength, Constants.ENDCOM);
|
|
939
|
+
b.fill(" ", Constants.ENDHDR);
|
|
940
|
+
return b;
|
|
941
|
+
}
|
|
942
|
+
var b = Buffer.alloc(this.mainHeaderSize);
|
|
943
|
+
let offset = 0;
|
|
944
|
+
b.writeUInt32LE(Constants.ZIP64SIG, offset);
|
|
945
|
+
Utils.writeBigUInt64LE(b, Constants.ZIP64HDR - Constants.ZIP64LEAD, offset + Constants.ZIP64SIZE);
|
|
946
|
+
b.writeUInt16LE(45, offset + Constants.ZIP64VEM);
|
|
947
|
+
b.writeUInt16LE(45, offset + Constants.ZIP64VER);
|
|
948
|
+
b.writeUInt32LE(0, offset + Constants.ZIP64DSK);
|
|
949
|
+
b.writeUInt32LE(0, offset + Constants.ZIP64DSKDIR);
|
|
950
|
+
Utils.writeBigUInt64LE(b, _volumeEntries, offset + Constants.ZIP64SUB);
|
|
951
|
+
Utils.writeBigUInt64LE(b, _totalEntries, offset + Constants.ZIP64TOT);
|
|
952
|
+
Utils.writeBigUInt64LE(b, _size, offset + Constants.ZIP64SIZB);
|
|
953
|
+
Utils.writeBigUInt64LE(b, _offset, offset + Constants.ZIP64OFF);
|
|
954
|
+
const zip64EndOffset = _offset + _size;
|
|
955
|
+
offset += Constants.ZIP64HDR;
|
|
956
|
+
b.writeUInt32LE(Constants.END64SIG, offset);
|
|
957
|
+
b.writeUInt32LE(0, offset + Constants.END64START);
|
|
958
|
+
Utils.writeBigUInt64LE(b, zip64EndOffset, offset + Constants.END64OFF);
|
|
959
|
+
b.writeUInt32LE(1, offset + Constants.END64NUMDISKS);
|
|
960
|
+
offset += Constants.END64HDR;
|
|
961
|
+
b.writeUInt32LE(Constants.ENDSIG, offset);
|
|
962
|
+
b.writeUInt32LE(0, offset + 4);
|
|
963
|
+
b.writeUInt16LE(Math.min(_volumeEntries, Constants.EF_ZIP64_OR_16), offset + Constants.ENDSUB);
|
|
964
|
+
b.writeUInt16LE(Math.min(_totalEntries, Constants.EF_ZIP64_OR_16), offset + Constants.ENDTOT);
|
|
965
|
+
b.writeUInt32LE(Math.min(_size, Constants.EF_ZIP64_OR_32), offset + Constants.ENDSIZ);
|
|
966
|
+
b.writeUInt32LE(Math.min(_offset, Constants.EF_ZIP64_OR_32), offset + Constants.ENDOFF);
|
|
967
|
+
b.writeUInt16LE(_commentLength, offset + Constants.ENDCOM);
|
|
968
|
+
b.fill(" ", offset + Constants.ENDHDR);
|
|
969
|
+
return b;
|
|
970
|
+
},
|
|
971
|
+
toJSON: function() {
|
|
972
|
+
const offset = function(nr, len) {
|
|
973
|
+
let offs = nr.toString(16).toUpperCase();
|
|
974
|
+
while (offs.length < len)
|
|
975
|
+
offs = "0" + offs;
|
|
976
|
+
return "0x" + offs;
|
|
977
|
+
};
|
|
978
|
+
return {
|
|
979
|
+
diskEntries: _volumeEntries,
|
|
980
|
+
totalEntries: _totalEntries,
|
|
981
|
+
size: _size + " bytes",
|
|
982
|
+
offset: offset(_offset, 4),
|
|
983
|
+
commentLength: _commentLength
|
|
984
|
+
};
|
|
985
|
+
},
|
|
986
|
+
toString: function() {
|
|
987
|
+
return JSON.stringify(this.toJSON(), null, "\t");
|
|
988
|
+
}
|
|
989
|
+
};
|
|
990
|
+
};
|
|
991
|
+
});
|
|
992
|
+
|
|
993
|
+
// ../../node_modules/adm-zip/headers/index.js
|
|
994
|
+
var require_headers = __commonJS((exports) => {
|
|
995
|
+
exports.EntryHeader = require_entryHeader();
|
|
996
|
+
exports.MainHeader = require_mainHeader();
|
|
997
|
+
});
|
|
998
|
+
|
|
999
|
+
// ../../node_modules/adm-zip/methods/deflater.js
|
|
1000
|
+
var require_deflater = __commonJS((exports, module) => {
|
|
1001
|
+
module.exports = function(inbuf) {
|
|
1002
|
+
var zlib = __require("zlib");
|
|
1003
|
+
var opts = { chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024 };
|
|
1004
|
+
return {
|
|
1005
|
+
deflate: function() {
|
|
1006
|
+
return zlib.deflateRawSync(inbuf, opts);
|
|
1007
|
+
},
|
|
1008
|
+
deflateAsync: function(callback) {
|
|
1009
|
+
var tmp = zlib.createDeflateRaw(opts), parts = [], total = 0;
|
|
1010
|
+
tmp.on("data", function(data) {
|
|
1011
|
+
parts.push(data);
|
|
1012
|
+
total += data.length;
|
|
1013
|
+
});
|
|
1014
|
+
tmp.on("end", function() {
|
|
1015
|
+
var buf = Buffer.alloc(total), written = 0;
|
|
1016
|
+
buf.fill(0);
|
|
1017
|
+
for (var i = 0;i < parts.length; i++) {
|
|
1018
|
+
var part = parts[i];
|
|
1019
|
+
part.copy(buf, written);
|
|
1020
|
+
written += part.length;
|
|
1021
|
+
}
|
|
1022
|
+
callback && callback(buf);
|
|
1023
|
+
});
|
|
1024
|
+
tmp.end(inbuf);
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
};
|
|
1028
|
+
});
|
|
1029
|
+
|
|
1030
|
+
// ../../node_modules/adm-zip/methods/inflater.js
|
|
1031
|
+
var require_inflater = __commonJS((exports, module) => {
|
|
1032
|
+
var version = +(process?.versions?.node ?? "").split(".")[0] || 0;
|
|
1033
|
+
module.exports = function(inbuf, expectedLength) {
|
|
1034
|
+
var zlib = __require("zlib");
|
|
1035
|
+
const option = version >= 15 && expectedLength > 0 ? { maxOutputLength: expectedLength } : {};
|
|
1036
|
+
return {
|
|
1037
|
+
inflate: function() {
|
|
1038
|
+
return zlib.inflateRawSync(inbuf, option);
|
|
1039
|
+
},
|
|
1040
|
+
inflateAsync: function(callback) {
|
|
1041
|
+
var tmp = zlib.createInflateRaw(option), parts = [], total = 0;
|
|
1042
|
+
tmp.on("data", function(data) {
|
|
1043
|
+
parts.push(data);
|
|
1044
|
+
total += data.length;
|
|
1045
|
+
});
|
|
1046
|
+
tmp.on("end", function() {
|
|
1047
|
+
var buf = Buffer.alloc(total), written = 0;
|
|
1048
|
+
buf.fill(0);
|
|
1049
|
+
for (var i = 0;i < parts.length; i++) {
|
|
1050
|
+
var part = parts[i];
|
|
1051
|
+
part.copy(buf, written);
|
|
1052
|
+
written += part.length;
|
|
1053
|
+
}
|
|
1054
|
+
callback && callback(buf);
|
|
1055
|
+
});
|
|
1056
|
+
tmp.end(inbuf);
|
|
1057
|
+
}
|
|
1058
|
+
};
|
|
1059
|
+
};
|
|
1060
|
+
});
|
|
1061
|
+
|
|
1062
|
+
// ../../node_modules/adm-zip/methods/zipcrypto.js
|
|
1063
|
+
var require_zipcrypto = __commonJS((exports, module) => {
|
|
1064
|
+
var { randomFillSync } = __require("crypto");
|
|
1065
|
+
var Errors = require_errors();
|
|
1066
|
+
var crctable = new Uint32Array(256).map((t, crc) => {
|
|
1067
|
+
for (let j = 0;j < 8; j++) {
|
|
1068
|
+
if ((crc & 1) !== 0) {
|
|
1069
|
+
crc = crc >>> 1 ^ 3988292384;
|
|
1070
|
+
} else {
|
|
1071
|
+
crc >>>= 1;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
return crc >>> 0;
|
|
1075
|
+
});
|
|
1076
|
+
var uMul = (a, b) => Math.imul(a, b) >>> 0;
|
|
1077
|
+
var crc32update = (pCrc32, bval) => {
|
|
1078
|
+
return crctable[(pCrc32 ^ bval) & 255] ^ pCrc32 >>> 8;
|
|
1079
|
+
};
|
|
1080
|
+
var genSalt = () => {
|
|
1081
|
+
if (typeof randomFillSync === "function") {
|
|
1082
|
+
return randomFillSync(Buffer.alloc(12));
|
|
1083
|
+
} else {
|
|
1084
|
+
return genSalt.node();
|
|
1085
|
+
}
|
|
1086
|
+
};
|
|
1087
|
+
genSalt.node = () => {
|
|
1088
|
+
const salt = Buffer.alloc(12);
|
|
1089
|
+
const len = salt.length;
|
|
1090
|
+
for (let i = 0;i < len; i++)
|
|
1091
|
+
salt[i] = Math.random() * 256 & 255;
|
|
1092
|
+
return salt;
|
|
1093
|
+
};
|
|
1094
|
+
var config = {
|
|
1095
|
+
genSalt
|
|
1096
|
+
};
|
|
1097
|
+
function Initkeys(pw) {
|
|
1098
|
+
const pass = Buffer.isBuffer(pw) ? pw : Buffer.from(pw);
|
|
1099
|
+
this.keys = new Uint32Array([305419896, 591751049, 878082192]);
|
|
1100
|
+
for (let i = 0;i < pass.length; i++) {
|
|
1101
|
+
this.updateKeys(pass[i]);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
Initkeys.prototype.updateKeys = function(byteValue) {
|
|
1105
|
+
const keys = this.keys;
|
|
1106
|
+
keys[0] = crc32update(keys[0], byteValue);
|
|
1107
|
+
keys[1] += keys[0] & 255;
|
|
1108
|
+
keys[1] = uMul(keys[1], 134775813) + 1;
|
|
1109
|
+
keys[2] = crc32update(keys[2], keys[1] >>> 24);
|
|
1110
|
+
return byteValue;
|
|
1111
|
+
};
|
|
1112
|
+
Initkeys.prototype.next = function() {
|
|
1113
|
+
const k = (this.keys[2] | 2) >>> 0;
|
|
1114
|
+
return uMul(k, k ^ 1) >> 8 & 255;
|
|
1115
|
+
};
|
|
1116
|
+
function make_decrypter(pwd) {
|
|
1117
|
+
const keys = new Initkeys(pwd);
|
|
1118
|
+
return function(data) {
|
|
1119
|
+
const result = Buffer.alloc(data.length);
|
|
1120
|
+
let pos = 0;
|
|
1121
|
+
for (let c of data) {
|
|
1122
|
+
result[pos++] = keys.updateKeys(c ^ keys.next());
|
|
1123
|
+
}
|
|
1124
|
+
return result;
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1127
|
+
function make_encrypter(pwd) {
|
|
1128
|
+
const keys = new Initkeys(pwd);
|
|
1129
|
+
return function(data, result, pos = 0) {
|
|
1130
|
+
if (!result)
|
|
1131
|
+
result = Buffer.alloc(data.length);
|
|
1132
|
+
for (let c of data) {
|
|
1133
|
+
const k = keys.next();
|
|
1134
|
+
result[pos++] = c ^ k;
|
|
1135
|
+
keys.updateKeys(c);
|
|
1136
|
+
}
|
|
1137
|
+
return result;
|
|
1138
|
+
};
|
|
1139
|
+
}
|
|
1140
|
+
function decrypt(data, header, pwd) {
|
|
1141
|
+
if (!data || !Buffer.isBuffer(data) || data.length < 12) {
|
|
1142
|
+
return Buffer.alloc(0);
|
|
1143
|
+
}
|
|
1144
|
+
const decrypter = make_decrypter(pwd);
|
|
1145
|
+
const salt = decrypter(data.slice(0, 12));
|
|
1146
|
+
const verifyByte = (header.flags & 8) === 8 ? header.timeHighByte : header.crc >>> 24;
|
|
1147
|
+
if (salt[11] !== verifyByte) {
|
|
1148
|
+
throw Errors.WRONG_PASSWORD();
|
|
1149
|
+
}
|
|
1150
|
+
return decrypter(data.slice(12));
|
|
1151
|
+
}
|
|
1152
|
+
function _salter(data) {
|
|
1153
|
+
if (Buffer.isBuffer(data) && data.length >= 12) {
|
|
1154
|
+
config.genSalt = function() {
|
|
1155
|
+
return data.slice(0, 12);
|
|
1156
|
+
};
|
|
1157
|
+
} else if (data === "node") {
|
|
1158
|
+
config.genSalt = genSalt.node;
|
|
1159
|
+
} else {
|
|
1160
|
+
config.genSalt = genSalt;
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
function encrypt(data, header, pwd, oldlike = false) {
|
|
1164
|
+
if (data == null)
|
|
1165
|
+
data = Buffer.alloc(0);
|
|
1166
|
+
if (!Buffer.isBuffer(data))
|
|
1167
|
+
data = Buffer.from(data.toString());
|
|
1168
|
+
const encrypter = make_encrypter(pwd);
|
|
1169
|
+
const salt = config.genSalt();
|
|
1170
|
+
salt[11] = header.crc >>> 24 & 255;
|
|
1171
|
+
if (oldlike)
|
|
1172
|
+
salt[10] = header.crc >>> 16 & 255;
|
|
1173
|
+
const result = Buffer.alloc(data.length + 12);
|
|
1174
|
+
encrypter(salt, result);
|
|
1175
|
+
return encrypter(data, result, 12);
|
|
1176
|
+
}
|
|
1177
|
+
module.exports = { decrypt, encrypt, _salter };
|
|
1178
|
+
});
|
|
1179
|
+
|
|
1180
|
+
// ../../node_modules/adm-zip/methods/index.js
|
|
1181
|
+
var require_methods = __commonJS((exports) => {
|
|
1182
|
+
exports.Deflater = require_deflater();
|
|
1183
|
+
exports.Inflater = require_inflater();
|
|
1184
|
+
exports.ZipCrypto = require_zipcrypto();
|
|
1185
|
+
});
|
|
1186
|
+
|
|
1187
|
+
// ../../node_modules/adm-zip/zipEntry.js
|
|
1188
|
+
var require_zipEntry = __commonJS((exports, module) => {
|
|
1189
|
+
var Utils = require_util();
|
|
1190
|
+
var Headers = require_headers();
|
|
1191
|
+
var Constants = Utils.Constants;
|
|
1192
|
+
var Methods = require_methods();
|
|
1193
|
+
module.exports = function(options, input) {
|
|
1194
|
+
var _centralHeader = new Headers.EntryHeader, _entryName = Buffer.alloc(0), _comment = Buffer.alloc(0), _isDirectory = false, uncompressedData = null, _extra = Buffer.alloc(0), _extralocal = Buffer.alloc(0), _efs = true;
|
|
1195
|
+
const opts = options;
|
|
1196
|
+
const decoder = typeof opts.decoder === "object" ? opts.decoder : Utils.decoder;
|
|
1197
|
+
_efs = decoder.hasOwnProperty("efs") ? decoder.efs : false;
|
|
1198
|
+
function getCompressedDataFromZip() {
|
|
1199
|
+
if (!input || !(input instanceof Uint8Array)) {
|
|
1200
|
+
return Buffer.alloc(0);
|
|
1201
|
+
}
|
|
1202
|
+
_extralocal = _centralHeader.loadLocalHeaderFromBinary(input);
|
|
1203
|
+
return input.slice(_centralHeader.realDataOffset, _centralHeader.realDataOffset + _centralHeader.compressedSize);
|
|
1204
|
+
}
|
|
1205
|
+
function crc32OK(data) {
|
|
1206
|
+
const expectedCrc = _centralHeader.flags_desc || _centralHeader.localHeader.flags_desc ? _centralHeader.crc : _centralHeader.localHeader.crc;
|
|
1207
|
+
return Utils.crc32(data) === expectedCrc;
|
|
1208
|
+
}
|
|
1209
|
+
function decompress(async, callback, pass) {
|
|
1210
|
+
if (typeof callback === "undefined" && typeof async === "string") {
|
|
1211
|
+
pass = async;
|
|
1212
|
+
async = undefined;
|
|
1213
|
+
}
|
|
1214
|
+
if (_isDirectory) {
|
|
1215
|
+
if (async && callback) {
|
|
1216
|
+
callback(Buffer.alloc(0), Utils.Errors.DIRECTORY_CONTENT_ERROR());
|
|
1217
|
+
}
|
|
1218
|
+
return Buffer.alloc(0);
|
|
1219
|
+
}
|
|
1220
|
+
var compressedData = getCompressedDataFromZip();
|
|
1221
|
+
if (compressedData.length === 0) {
|
|
1222
|
+
if (async && callback)
|
|
1223
|
+
callback(compressedData);
|
|
1224
|
+
return compressedData;
|
|
1225
|
+
}
|
|
1226
|
+
if (_centralHeader.encrypted) {
|
|
1227
|
+
if (typeof pass !== "string" && !Buffer.isBuffer(pass)) {
|
|
1228
|
+
throw Utils.Errors.INVALID_PASS_PARAM();
|
|
1229
|
+
}
|
|
1230
|
+
compressedData = Methods.ZipCrypto.decrypt(compressedData, _centralHeader, pass);
|
|
1231
|
+
}
|
|
1232
|
+
var data;
|
|
1233
|
+
switch (_centralHeader.method) {
|
|
1234
|
+
case Utils.Constants.STORED:
|
|
1235
|
+
data = Buffer.alloc(compressedData.length);
|
|
1236
|
+
compressedData.copy(data);
|
|
1237
|
+
if (!crc32OK(data)) {
|
|
1238
|
+
if (async && callback)
|
|
1239
|
+
callback(data, Utils.Errors.BAD_CRC());
|
|
1240
|
+
throw Utils.Errors.BAD_CRC();
|
|
1241
|
+
} else {
|
|
1242
|
+
if (async && callback)
|
|
1243
|
+
callback(data);
|
|
1244
|
+
return data;
|
|
1245
|
+
}
|
|
1246
|
+
case Utils.Constants.DEFLATED:
|
|
1247
|
+
var inflater = new Methods.Inflater(compressedData, _centralHeader.size);
|
|
1248
|
+
if (!async) {
|
|
1249
|
+
data = inflater.inflate();
|
|
1250
|
+
if (!crc32OK(data)) {
|
|
1251
|
+
throw Utils.Errors.BAD_CRC(`"${decoder.decode(_entryName)}"`);
|
|
1252
|
+
}
|
|
1253
|
+
return data;
|
|
1254
|
+
} else {
|
|
1255
|
+
inflater.inflateAsync(function(result) {
|
|
1256
|
+
if (callback) {
|
|
1257
|
+
if (!crc32OK(result)) {
|
|
1258
|
+
callback(result, Utils.Errors.BAD_CRC());
|
|
1259
|
+
} else {
|
|
1260
|
+
callback(result);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
break;
|
|
1266
|
+
default:
|
|
1267
|
+
if (async && callback)
|
|
1268
|
+
callback(Buffer.alloc(0), Utils.Errors.UNKNOWN_METHOD());
|
|
1269
|
+
throw Utils.Errors.UNKNOWN_METHOD();
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
function compress(async, callback) {
|
|
1273
|
+
if ((!uncompressedData || !uncompressedData.length) && Buffer.isBuffer(input)) {
|
|
1274
|
+
if (async && callback)
|
|
1275
|
+
callback(getCompressedDataFromZip());
|
|
1276
|
+
return getCompressedDataFromZip();
|
|
1277
|
+
}
|
|
1278
|
+
if (uncompressedData.length && !_isDirectory) {
|
|
1279
|
+
var compressedData;
|
|
1280
|
+
switch (_centralHeader.method) {
|
|
1281
|
+
case Utils.Constants.STORED:
|
|
1282
|
+
_centralHeader.compressedSize = _centralHeader.size;
|
|
1283
|
+
compressedData = Buffer.alloc(uncompressedData.length);
|
|
1284
|
+
uncompressedData.copy(compressedData);
|
|
1285
|
+
if (async && callback)
|
|
1286
|
+
callback(compressedData);
|
|
1287
|
+
return compressedData;
|
|
1288
|
+
default:
|
|
1289
|
+
case Utils.Constants.DEFLATED:
|
|
1290
|
+
var deflater = new Methods.Deflater(uncompressedData);
|
|
1291
|
+
if (!async) {
|
|
1292
|
+
var deflated = deflater.deflate();
|
|
1293
|
+
_centralHeader.compressedSize = deflated.length;
|
|
1294
|
+
return deflated;
|
|
1295
|
+
} else {
|
|
1296
|
+
deflater.deflateAsync(function(data) {
|
|
1297
|
+
compressedData = Buffer.alloc(data.length);
|
|
1298
|
+
_centralHeader.compressedSize = data.length;
|
|
1299
|
+
data.copy(compressedData);
|
|
1300
|
+
callback && callback(compressedData);
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
deflater = null;
|
|
1304
|
+
break;
|
|
1305
|
+
}
|
|
1306
|
+
} else if (async && callback) {
|
|
1307
|
+
callback(Buffer.alloc(0));
|
|
1308
|
+
} else {
|
|
1309
|
+
return Buffer.alloc(0);
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
function readUInt64LE(buffer, offset) {
|
|
1313
|
+
return Utils.readBigUInt64LE(buffer, offset);
|
|
1314
|
+
}
|
|
1315
|
+
function parseExtra(data) {
|
|
1316
|
+
try {
|
|
1317
|
+
var offset = 0;
|
|
1318
|
+
var signature, size, part;
|
|
1319
|
+
while (offset + 4 < data.length) {
|
|
1320
|
+
signature = data.readUInt16LE(offset);
|
|
1321
|
+
offset += 2;
|
|
1322
|
+
size = data.readUInt16LE(offset);
|
|
1323
|
+
offset += 2;
|
|
1324
|
+
part = data.slice(offset, offset + size);
|
|
1325
|
+
offset += size;
|
|
1326
|
+
if (Constants.ID_ZIP64 === signature) {
|
|
1327
|
+
parseZip64ExtendedInformation(part);
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
} catch (error) {
|
|
1331
|
+
throw Utils.Errors.EXTRA_FIELD_PARSE_ERROR();
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
function parseZip64ExtendedInformation(data) {
|
|
1335
|
+
var size, compressedSize, offset, diskNumStart;
|
|
1336
|
+
if (data.length >= Constants.EF_ZIP64_SCOMP) {
|
|
1337
|
+
size = readUInt64LE(data, Constants.EF_ZIP64_SUNCOMP);
|
|
1338
|
+
if (_centralHeader.size === Constants.EF_ZIP64_OR_32) {
|
|
1339
|
+
_centralHeader.size = size;
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
if (data.length >= Constants.EF_ZIP64_RHO) {
|
|
1343
|
+
compressedSize = readUInt64LE(data, Constants.EF_ZIP64_SCOMP);
|
|
1344
|
+
if (_centralHeader.compressedSize === Constants.EF_ZIP64_OR_32) {
|
|
1345
|
+
_centralHeader.compressedSize = compressedSize;
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
if (data.length >= Constants.EF_ZIP64_DSN) {
|
|
1349
|
+
offset = readUInt64LE(data, Constants.EF_ZIP64_RHO);
|
|
1350
|
+
if (_centralHeader.offset === Constants.EF_ZIP64_OR_32) {
|
|
1351
|
+
_centralHeader.offset = offset;
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
if (data.length >= Constants.EF_ZIP64_DSN + 4) {
|
|
1355
|
+
diskNumStart = data.readUInt32LE(Constants.EF_ZIP64_DSN);
|
|
1356
|
+
if (_centralHeader.diskNumStart === Constants.EF_ZIP64_OR_16) {
|
|
1357
|
+
_centralHeader.diskNumStart = diskNumStart;
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
return {
|
|
1362
|
+
get entryName() {
|
|
1363
|
+
return decoder.decode(_entryName);
|
|
1364
|
+
},
|
|
1365
|
+
get rawEntryName() {
|
|
1366
|
+
return _entryName;
|
|
1367
|
+
},
|
|
1368
|
+
set entryName(val) {
|
|
1369
|
+
_entryName = Utils.toBuffer(val, decoder.encode);
|
|
1370
|
+
var lastChar = _entryName[_entryName.length - 1];
|
|
1371
|
+
_isDirectory = lastChar === 47 || lastChar === 92;
|
|
1372
|
+
_centralHeader.fileNameLength = _entryName.length;
|
|
1373
|
+
},
|
|
1374
|
+
get efs() {
|
|
1375
|
+
if (typeof _efs === "function") {
|
|
1376
|
+
return _efs(this.entryName);
|
|
1377
|
+
} else {
|
|
1378
|
+
return _efs;
|
|
1379
|
+
}
|
|
1380
|
+
},
|
|
1381
|
+
get extra() {
|
|
1382
|
+
return _extra;
|
|
1383
|
+
},
|
|
1384
|
+
set extra(val) {
|
|
1385
|
+
_extra = val;
|
|
1386
|
+
_centralHeader.extraLength = val.length;
|
|
1387
|
+
parseExtra(val);
|
|
1388
|
+
},
|
|
1389
|
+
get comment() {
|
|
1390
|
+
return decoder.decode(_comment);
|
|
1391
|
+
},
|
|
1392
|
+
set comment(val) {
|
|
1393
|
+
_comment = Utils.toBuffer(val, decoder.encode);
|
|
1394
|
+
_centralHeader.commentLength = _comment.length;
|
|
1395
|
+
if (_comment.length > 65535)
|
|
1396
|
+
throw Utils.Errors.COMMENT_TOO_LONG();
|
|
1397
|
+
},
|
|
1398
|
+
get name() {
|
|
1399
|
+
const n = decoder.decode(_entryName);
|
|
1400
|
+
return _isDirectory ? n.replace(/[/\\]$/, "").split("/").pop() : n.split("/").pop();
|
|
1401
|
+
},
|
|
1402
|
+
get isDirectory() {
|
|
1403
|
+
return _isDirectory;
|
|
1404
|
+
},
|
|
1405
|
+
getCompressedData: function() {
|
|
1406
|
+
return compress(false, null);
|
|
1407
|
+
},
|
|
1408
|
+
getCompressedDataAsync: function(callback) {
|
|
1409
|
+
compress(true, callback);
|
|
1410
|
+
},
|
|
1411
|
+
setData: function(value) {
|
|
1412
|
+
uncompressedData = Utils.toBuffer(value, Utils.decoder.encode);
|
|
1413
|
+
if (!_isDirectory && uncompressedData.length) {
|
|
1414
|
+
_centralHeader.size = uncompressedData.length;
|
|
1415
|
+
_centralHeader.method = Utils.Constants.DEFLATED;
|
|
1416
|
+
_centralHeader.crc = Utils.crc32(value);
|
|
1417
|
+
_centralHeader.changed = true;
|
|
1418
|
+
} else {
|
|
1419
|
+
_centralHeader.method = Utils.Constants.STORED;
|
|
1420
|
+
}
|
|
1421
|
+
},
|
|
1422
|
+
getData: function(pass) {
|
|
1423
|
+
if (_centralHeader.changed) {
|
|
1424
|
+
return uncompressedData;
|
|
1425
|
+
} else {
|
|
1426
|
+
return decompress(false, null, pass);
|
|
1427
|
+
}
|
|
1428
|
+
},
|
|
1429
|
+
getDataAsync: function(callback, pass) {
|
|
1430
|
+
if (_centralHeader.changed) {
|
|
1431
|
+
callback(uncompressedData);
|
|
1432
|
+
} else {
|
|
1433
|
+
decompress(true, callback, pass);
|
|
1434
|
+
}
|
|
1435
|
+
},
|
|
1436
|
+
set attr(attr) {
|
|
1437
|
+
_centralHeader.attr = attr;
|
|
1438
|
+
},
|
|
1439
|
+
get attr() {
|
|
1440
|
+
return _centralHeader.attr;
|
|
1441
|
+
},
|
|
1442
|
+
set header(data) {
|
|
1443
|
+
_centralHeader.loadFromBinary(data);
|
|
1444
|
+
},
|
|
1445
|
+
get header() {
|
|
1446
|
+
return _centralHeader;
|
|
1447
|
+
},
|
|
1448
|
+
packCentralHeader: function() {
|
|
1449
|
+
_centralHeader.flags_efs = this.efs;
|
|
1450
|
+
_centralHeader.extraLength = _extra.length;
|
|
1451
|
+
var header = _centralHeader.centralHeaderToBinary();
|
|
1452
|
+
var addpos = Utils.Constants.CENHDR;
|
|
1453
|
+
_entryName.copy(header, addpos);
|
|
1454
|
+
addpos += _entryName.length;
|
|
1455
|
+
_extra.copy(header, addpos);
|
|
1456
|
+
addpos += _centralHeader.extraLength;
|
|
1457
|
+
_comment.copy(header, addpos);
|
|
1458
|
+
return header;
|
|
1459
|
+
},
|
|
1460
|
+
packLocalHeader: function() {
|
|
1461
|
+
let addpos = 0;
|
|
1462
|
+
_centralHeader.flags_efs = this.efs;
|
|
1463
|
+
_centralHeader.extraLocalLength = _extralocal.length;
|
|
1464
|
+
const localHeaderBuf = _centralHeader.localHeaderToBinary();
|
|
1465
|
+
const localHeader = Buffer.alloc(localHeaderBuf.length + _entryName.length + _centralHeader.extraLocalLength);
|
|
1466
|
+
localHeaderBuf.copy(localHeader, addpos);
|
|
1467
|
+
addpos += localHeaderBuf.length;
|
|
1468
|
+
_entryName.copy(localHeader, addpos);
|
|
1469
|
+
addpos += _entryName.length;
|
|
1470
|
+
_extralocal.copy(localHeader, addpos);
|
|
1471
|
+
addpos += _extralocal.length;
|
|
1472
|
+
return localHeader;
|
|
1473
|
+
},
|
|
1474
|
+
toJSON: function() {
|
|
1475
|
+
const bytes = function(nr) {
|
|
1476
|
+
return "<" + (nr && nr.length + " bytes buffer" || "null") + ">";
|
|
1477
|
+
};
|
|
1478
|
+
return {
|
|
1479
|
+
entryName: this.entryName,
|
|
1480
|
+
name: this.name,
|
|
1481
|
+
comment: this.comment,
|
|
1482
|
+
isDirectory: this.isDirectory,
|
|
1483
|
+
header: _centralHeader.toJSON(),
|
|
1484
|
+
compressedData: bytes(input),
|
|
1485
|
+
data: bytes(uncompressedData)
|
|
1486
|
+
};
|
|
1487
|
+
},
|
|
1488
|
+
toString: function() {
|
|
1489
|
+
return JSON.stringify(this.toJSON(), null, "\t");
|
|
1490
|
+
}
|
|
1491
|
+
};
|
|
1492
|
+
};
|
|
1493
|
+
});
|
|
1494
|
+
|
|
1495
|
+
// ../../node_modules/adm-zip/zipFile.js
|
|
1496
|
+
var require_zipFile = __commonJS((exports, module) => {
|
|
1497
|
+
var ZipEntry = require_zipEntry();
|
|
1498
|
+
var Headers = require_headers();
|
|
1499
|
+
var Utils = require_util();
|
|
1500
|
+
module.exports = function(inBuffer, options) {
|
|
1501
|
+
var entryList = [], entryTable = Object.create(null), _comment = Buffer.alloc(0), mainHeader = new Headers.MainHeader, loadedEntries = false;
|
|
1502
|
+
var password = null;
|
|
1503
|
+
const temporary = new Set;
|
|
1504
|
+
const opts = options;
|
|
1505
|
+
const { noSort, decoder } = opts;
|
|
1506
|
+
if (inBuffer) {
|
|
1507
|
+
readMainHeader(opts.readEntries);
|
|
1508
|
+
} else {
|
|
1509
|
+
loadedEntries = true;
|
|
1510
|
+
}
|
|
1511
|
+
function makeTemporaryFolders() {
|
|
1512
|
+
const foldersList = new Set;
|
|
1513
|
+
for (const elem of Object.keys(entryTable)) {
|
|
1514
|
+
const elements = elem.split("/");
|
|
1515
|
+
elements.pop();
|
|
1516
|
+
if (!elements.length)
|
|
1517
|
+
continue;
|
|
1518
|
+
for (let i = 0;i < elements.length; i++) {
|
|
1519
|
+
const sub = elements.slice(0, i + 1).join("/") + "/";
|
|
1520
|
+
foldersList.add(sub);
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
for (const elem of foldersList) {
|
|
1524
|
+
if (!(elem in entryTable)) {
|
|
1525
|
+
const tempfolder = new ZipEntry(opts);
|
|
1526
|
+
tempfolder.entryName = elem;
|
|
1527
|
+
tempfolder.attr = 16;
|
|
1528
|
+
tempfolder.temporary = true;
|
|
1529
|
+
entryList.push(tempfolder);
|
|
1530
|
+
entryTable[tempfolder.entryName] = tempfolder;
|
|
1531
|
+
temporary.add(tempfolder);
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
function readEntries() {
|
|
1536
|
+
loadedEntries = true;
|
|
1537
|
+
entryTable = Object.create(null);
|
|
1538
|
+
if (mainHeader.diskEntries > (inBuffer.length - mainHeader.offset) / Utils.Constants.CENHDR) {
|
|
1539
|
+
throw Utils.Errors.DISK_ENTRY_TOO_LARGE();
|
|
1540
|
+
}
|
|
1541
|
+
entryList = new Array(mainHeader.diskEntries);
|
|
1542
|
+
var index = mainHeader.offset;
|
|
1543
|
+
for (var i = 0;i < entryList.length; i++) {
|
|
1544
|
+
var tmp = index, entry = new ZipEntry(opts, inBuffer);
|
|
1545
|
+
entry.header = inBuffer.slice(tmp, tmp += Utils.Constants.CENHDR);
|
|
1546
|
+
entry.entryName = inBuffer.slice(tmp, tmp += entry.header.fileNameLength);
|
|
1547
|
+
if (entry.header.extraLength) {
|
|
1548
|
+
entry.extra = inBuffer.slice(tmp, tmp += entry.header.extraLength);
|
|
1549
|
+
}
|
|
1550
|
+
if (entry.header.commentLength)
|
|
1551
|
+
entry.comment = inBuffer.slice(tmp, tmp + entry.header.commentLength);
|
|
1552
|
+
index += entry.header.centralHeaderSize;
|
|
1553
|
+
entryList[i] = entry;
|
|
1554
|
+
entryTable[entry.entryName] = entry;
|
|
1555
|
+
}
|
|
1556
|
+
temporary.clear();
|
|
1557
|
+
makeTemporaryFolders();
|
|
1558
|
+
}
|
|
1559
|
+
function readMainHeader(readNow) {
|
|
1560
|
+
var i = inBuffer.length - Utils.Constants.ENDHDR, max = Math.max(0, i - 65535), n = max, endStart = inBuffer.length, endOffset = -1, commentEnd = 0;
|
|
1561
|
+
const trailingSpace = typeof opts.trailingSpace === "boolean" ? opts.trailingSpace : false;
|
|
1562
|
+
if (trailingSpace)
|
|
1563
|
+
max = 0;
|
|
1564
|
+
for (i;i >= n; i--) {
|
|
1565
|
+
if (inBuffer[i] !== 80)
|
|
1566
|
+
continue;
|
|
1567
|
+
if (inBuffer.readUInt32LE(i) === Utils.Constants.ENDSIG) {
|
|
1568
|
+
endOffset = i;
|
|
1569
|
+
commentEnd = i;
|
|
1570
|
+
endStart = i + Utils.Constants.ENDHDR;
|
|
1571
|
+
n = i - Utils.Constants.END64HDR;
|
|
1572
|
+
continue;
|
|
1573
|
+
}
|
|
1574
|
+
if (inBuffer.readUInt32LE(i) === Utils.Constants.END64SIG) {
|
|
1575
|
+
n = max;
|
|
1576
|
+
continue;
|
|
1577
|
+
}
|
|
1578
|
+
if (inBuffer.readUInt32LE(i) === Utils.Constants.ZIP64SIG) {
|
|
1579
|
+
endOffset = i;
|
|
1580
|
+
endStart = i + Utils.readBigUInt64LE(inBuffer, i + Utils.Constants.ZIP64SIZE) + Utils.Constants.ZIP64LEAD;
|
|
1581
|
+
break;
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
if (endOffset == -1)
|
|
1585
|
+
throw Utils.Errors.INVALID_FORMAT();
|
|
1586
|
+
mainHeader.loadFromBinary(inBuffer.slice(endOffset, endStart));
|
|
1587
|
+
if (mainHeader.commentLength) {
|
|
1588
|
+
_comment = inBuffer.slice(commentEnd + Utils.Constants.ENDHDR);
|
|
1589
|
+
}
|
|
1590
|
+
if (readNow)
|
|
1591
|
+
readEntries();
|
|
1592
|
+
}
|
|
1593
|
+
function sortEntries() {
|
|
1594
|
+
if (entryList.length > 1 && !noSort) {
|
|
1595
|
+
entryList = entryList.map((entry) => ({ entry, key: entry.entryName.toLowerCase() })).sort((a, b) => a.key.localeCompare(b.key)).map((pair) => pair.entry);
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
return {
|
|
1599
|
+
get entries() {
|
|
1600
|
+
if (!loadedEntries) {
|
|
1601
|
+
readEntries();
|
|
1602
|
+
}
|
|
1603
|
+
return entryList.filter((e) => !temporary.has(e));
|
|
1604
|
+
},
|
|
1605
|
+
get comment() {
|
|
1606
|
+
return decoder.decode(_comment);
|
|
1607
|
+
},
|
|
1608
|
+
set comment(val) {
|
|
1609
|
+
_comment = Utils.toBuffer(val, decoder.encode);
|
|
1610
|
+
mainHeader.commentLength = _comment.length;
|
|
1611
|
+
},
|
|
1612
|
+
getEntryCount: function() {
|
|
1613
|
+
if (!loadedEntries) {
|
|
1614
|
+
return mainHeader.diskEntries;
|
|
1615
|
+
}
|
|
1616
|
+
return entryList.length;
|
|
1617
|
+
},
|
|
1618
|
+
forEach: function(callback) {
|
|
1619
|
+
this.entries.forEach(callback);
|
|
1620
|
+
},
|
|
1621
|
+
getEntry: function(entryName) {
|
|
1622
|
+
if (!loadedEntries) {
|
|
1623
|
+
readEntries();
|
|
1624
|
+
}
|
|
1625
|
+
return entryTable[entryName] || null;
|
|
1626
|
+
},
|
|
1627
|
+
setEntry: function(entry) {
|
|
1628
|
+
if (!loadedEntries) {
|
|
1629
|
+
readEntries();
|
|
1630
|
+
}
|
|
1631
|
+
entryList.push(entry);
|
|
1632
|
+
entryTable[entry.entryName] = entry;
|
|
1633
|
+
mainHeader.totalEntries = entryList.length;
|
|
1634
|
+
},
|
|
1635
|
+
deleteFile: function(entryName, withsubfolders = true) {
|
|
1636
|
+
if (!loadedEntries) {
|
|
1637
|
+
readEntries();
|
|
1638
|
+
}
|
|
1639
|
+
const entry = entryTable[entryName];
|
|
1640
|
+
const list = this.getEntryChildren(entry, withsubfolders).map((child) => child.entryName);
|
|
1641
|
+
list.forEach(this.deleteEntry);
|
|
1642
|
+
},
|
|
1643
|
+
deleteEntry: function(entryName) {
|
|
1644
|
+
if (!loadedEntries) {
|
|
1645
|
+
readEntries();
|
|
1646
|
+
}
|
|
1647
|
+
const entry = entryTable[entryName];
|
|
1648
|
+
const index = entryList.indexOf(entry);
|
|
1649
|
+
if (index >= 0) {
|
|
1650
|
+
entryList.splice(index, 1);
|
|
1651
|
+
delete entryTable[entryName];
|
|
1652
|
+
mainHeader.totalEntries = entryList.length;
|
|
1653
|
+
}
|
|
1654
|
+
},
|
|
1655
|
+
getEntryChildren: function(entry, subfolders = true) {
|
|
1656
|
+
if (!loadedEntries) {
|
|
1657
|
+
readEntries();
|
|
1658
|
+
}
|
|
1659
|
+
if (typeof entry === "object") {
|
|
1660
|
+
if (entry.isDirectory && subfolders) {
|
|
1661
|
+
const list = [];
|
|
1662
|
+
const name = entry.entryName;
|
|
1663
|
+
for (const zipEntry of entryList) {
|
|
1664
|
+
if (zipEntry.entryName.startsWith(name)) {
|
|
1665
|
+
list.push(zipEntry);
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
return list;
|
|
1669
|
+
} else {
|
|
1670
|
+
return [entry];
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
return [];
|
|
1674
|
+
},
|
|
1675
|
+
getChildCount: function(entry) {
|
|
1676
|
+
if (entry && entry.isDirectory) {
|
|
1677
|
+
const list = this.getEntryChildren(entry);
|
|
1678
|
+
return list.includes(entry) ? list.length - 1 : list.length;
|
|
1679
|
+
}
|
|
1680
|
+
return 0;
|
|
1681
|
+
},
|
|
1682
|
+
compressToBuffer: function() {
|
|
1683
|
+
if (!loadedEntries) {
|
|
1684
|
+
readEntries();
|
|
1685
|
+
}
|
|
1686
|
+
sortEntries();
|
|
1687
|
+
const dataBlock = [];
|
|
1688
|
+
const headerBlocks = [];
|
|
1689
|
+
let totalSize = 0;
|
|
1690
|
+
let dindex = 0;
|
|
1691
|
+
mainHeader.size = 0;
|
|
1692
|
+
mainHeader.offset = 0;
|
|
1693
|
+
let totalEntries = 0;
|
|
1694
|
+
for (const entry of this.entries) {
|
|
1695
|
+
const compressedData = entry.getCompressedData();
|
|
1696
|
+
entry.header.offset = dindex;
|
|
1697
|
+
const localHeader = entry.packLocalHeader();
|
|
1698
|
+
const dataLength = localHeader.length + compressedData.length;
|
|
1699
|
+
dindex += dataLength;
|
|
1700
|
+
dataBlock.push(localHeader);
|
|
1701
|
+
dataBlock.push(compressedData);
|
|
1702
|
+
const centralHeader = entry.packCentralHeader();
|
|
1703
|
+
headerBlocks.push(centralHeader);
|
|
1704
|
+
mainHeader.size += centralHeader.length;
|
|
1705
|
+
totalSize += dataLength + centralHeader.length;
|
|
1706
|
+
totalEntries++;
|
|
1707
|
+
}
|
|
1708
|
+
totalSize += mainHeader.mainHeaderSize;
|
|
1709
|
+
mainHeader.offset = dindex;
|
|
1710
|
+
mainHeader.totalEntries = totalEntries;
|
|
1711
|
+
dindex = 0;
|
|
1712
|
+
const outBuffer = Buffer.alloc(totalSize);
|
|
1713
|
+
for (const content of dataBlock) {
|
|
1714
|
+
content.copy(outBuffer, dindex);
|
|
1715
|
+
dindex += content.length;
|
|
1716
|
+
}
|
|
1717
|
+
for (const content of headerBlocks) {
|
|
1718
|
+
content.copy(outBuffer, dindex);
|
|
1719
|
+
dindex += content.length;
|
|
1720
|
+
}
|
|
1721
|
+
const mh = mainHeader.toBinary();
|
|
1722
|
+
if (_comment) {
|
|
1723
|
+
_comment.copy(mh, mh.length - _comment.length);
|
|
1724
|
+
}
|
|
1725
|
+
mh.copy(outBuffer, dindex);
|
|
1726
|
+
inBuffer = outBuffer;
|
|
1727
|
+
loadedEntries = false;
|
|
1728
|
+
return outBuffer;
|
|
1729
|
+
},
|
|
1730
|
+
toAsyncBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
|
|
1731
|
+
try {
|
|
1732
|
+
if (!loadedEntries) {
|
|
1733
|
+
readEntries();
|
|
1734
|
+
}
|
|
1735
|
+
sortEntries();
|
|
1736
|
+
const dataBlock = [];
|
|
1737
|
+
const centralHeaders = [];
|
|
1738
|
+
let totalSize = 0;
|
|
1739
|
+
let dindex = 0;
|
|
1740
|
+
let totalEntries = 0;
|
|
1741
|
+
mainHeader.size = 0;
|
|
1742
|
+
mainHeader.offset = 0;
|
|
1743
|
+
const compress2Buffer = function(entryLists) {
|
|
1744
|
+
if (entryLists.length > 0) {
|
|
1745
|
+
const entry = entryLists.shift();
|
|
1746
|
+
const name = entry.entryName + entry.extra.toString();
|
|
1747
|
+
if (onItemStart)
|
|
1748
|
+
onItemStart(name);
|
|
1749
|
+
entry.getCompressedDataAsync(function(compressedData) {
|
|
1750
|
+
if (onItemEnd)
|
|
1751
|
+
onItemEnd(name);
|
|
1752
|
+
entry.header.offset = dindex;
|
|
1753
|
+
const localHeader = entry.packLocalHeader();
|
|
1754
|
+
const dataLength = localHeader.length + compressedData.length;
|
|
1755
|
+
dindex += dataLength;
|
|
1756
|
+
dataBlock.push(localHeader);
|
|
1757
|
+
dataBlock.push(compressedData);
|
|
1758
|
+
const centalHeader = entry.packCentralHeader();
|
|
1759
|
+
centralHeaders.push(centalHeader);
|
|
1760
|
+
mainHeader.size += centalHeader.length;
|
|
1761
|
+
totalSize += dataLength + centalHeader.length;
|
|
1762
|
+
totalEntries++;
|
|
1763
|
+
compress2Buffer(entryLists);
|
|
1764
|
+
});
|
|
1765
|
+
} else {
|
|
1766
|
+
totalSize += mainHeader.mainHeaderSize;
|
|
1767
|
+
mainHeader.offset = dindex;
|
|
1768
|
+
mainHeader.totalEntries = totalEntries;
|
|
1769
|
+
dindex = 0;
|
|
1770
|
+
const outBuffer = Buffer.alloc(totalSize);
|
|
1771
|
+
dataBlock.forEach(function(content) {
|
|
1772
|
+
content.copy(outBuffer, dindex);
|
|
1773
|
+
dindex += content.length;
|
|
1774
|
+
});
|
|
1775
|
+
centralHeaders.forEach(function(content) {
|
|
1776
|
+
content.copy(outBuffer, dindex);
|
|
1777
|
+
dindex += content.length;
|
|
1778
|
+
});
|
|
1779
|
+
const mh = mainHeader.toBinary();
|
|
1780
|
+
if (_comment) {
|
|
1781
|
+
_comment.copy(mh, mh.length - _comment.length);
|
|
1782
|
+
}
|
|
1783
|
+
mh.copy(outBuffer, dindex);
|
|
1784
|
+
inBuffer = outBuffer;
|
|
1785
|
+
loadedEntries = false;
|
|
1786
|
+
onSuccess(outBuffer);
|
|
1787
|
+
}
|
|
1788
|
+
};
|
|
1789
|
+
compress2Buffer(Array.from(this.entries));
|
|
1790
|
+
} catch (e) {
|
|
1791
|
+
onFail(e);
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
};
|
|
1795
|
+
};
|
|
1796
|
+
});
|
|
1797
|
+
|
|
1798
|
+
// ../../node_modules/adm-zip/adm-zip.js
|
|
1799
|
+
var require_adm_zip = __commonJS((exports, module) => {
|
|
1800
|
+
var Utils = require_util();
|
|
1801
|
+
var pth = __require("path");
|
|
1802
|
+
var ZipEntry = require_zipEntry();
|
|
1803
|
+
var ZipFile = require_zipFile();
|
|
1804
|
+
var get_Bool = (...val) => Utils.findLast(val, (c) => typeof c === "boolean");
|
|
1805
|
+
var get_Str = (...val) => Utils.findLast(val, (c) => typeof c === "string");
|
|
1806
|
+
var get_Fun = (...val) => Utils.findLast(val, (c) => typeof c === "function");
|
|
1807
|
+
var defaultOptions = {
|
|
1808
|
+
noSort: false,
|
|
1809
|
+
readEntries: false,
|
|
1810
|
+
method: Utils.Constants.NONE,
|
|
1811
|
+
fs: null
|
|
1812
|
+
};
|
|
1813
|
+
module.exports = function(input, options) {
|
|
1814
|
+
let inBuffer = null;
|
|
1815
|
+
const opts = Object.assign(Object.create(null), defaultOptions);
|
|
1816
|
+
if (input && typeof input === "object") {
|
|
1817
|
+
if (!(input instanceof Uint8Array)) {
|
|
1818
|
+
Object.assign(opts, input);
|
|
1819
|
+
input = opts.input ? opts.input : undefined;
|
|
1820
|
+
if (opts.input)
|
|
1821
|
+
delete opts.input;
|
|
1822
|
+
}
|
|
1823
|
+
if (Buffer.isBuffer(input)) {
|
|
1824
|
+
inBuffer = input;
|
|
1825
|
+
opts.method = Utils.Constants.BUFFER;
|
|
1826
|
+
input = undefined;
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
Object.assign(opts, options);
|
|
1830
|
+
const filetools = new Utils(opts);
|
|
1831
|
+
const applyDirAttributes = (dirEntries) => {
|
|
1832
|
+
dirEntries.filter((d) => d.attr).sort((a, b) => b.path.length - a.path.length).forEach((d) => filetools.fs.chmodSync(d.path, d.attr));
|
|
1833
|
+
};
|
|
1834
|
+
if (typeof opts.decoder !== "object" || typeof opts.decoder.encode !== "function" || typeof opts.decoder.decode !== "function") {
|
|
1835
|
+
opts.decoder = Utils.decoder;
|
|
1836
|
+
}
|
|
1837
|
+
if (input && typeof input === "string") {
|
|
1838
|
+
if (filetools.fs.existsSync(input)) {
|
|
1839
|
+
opts.method = Utils.Constants.FILE;
|
|
1840
|
+
opts.filename = input;
|
|
1841
|
+
inBuffer = filetools.fs.readFileSync(input);
|
|
1842
|
+
} else {
|
|
1843
|
+
throw Utils.Errors.INVALID_FILENAME();
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
const _zip = new ZipFile(inBuffer, opts);
|
|
1847
|
+
const { canonical, sanitize, zipnamefix } = Utils;
|
|
1848
|
+
function getEntry(entry) {
|
|
1849
|
+
if (entry && _zip) {
|
|
1850
|
+
var item;
|
|
1851
|
+
if (typeof entry === "string")
|
|
1852
|
+
item = _zip.getEntry(pth.posix.normalize(entry));
|
|
1853
|
+
if (typeof entry === "object" && typeof entry.entryName !== "undefined" && typeof entry.header !== "undefined")
|
|
1854
|
+
item = _zip.getEntry(entry.entryName);
|
|
1855
|
+
if (item) {
|
|
1856
|
+
return item;
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
return null;
|
|
1860
|
+
}
|
|
1861
|
+
function fixPath(zipPath) {
|
|
1862
|
+
const { join, normalize, sep } = pth.posix;
|
|
1863
|
+
return join(pth.isAbsolute(zipPath) ? "/" : ".", normalize(sep + zipPath.split("\\").join(sep) + sep));
|
|
1864
|
+
}
|
|
1865
|
+
function filenameFilter(filterfn) {
|
|
1866
|
+
if (filterfn instanceof RegExp) {
|
|
1867
|
+
return function(rx) {
|
|
1868
|
+
return function(filename) {
|
|
1869
|
+
return rx.test(filename);
|
|
1870
|
+
};
|
|
1871
|
+
}(filterfn);
|
|
1872
|
+
} else if (typeof filterfn !== "function") {
|
|
1873
|
+
return () => true;
|
|
1874
|
+
}
|
|
1875
|
+
return filterfn;
|
|
1876
|
+
}
|
|
1877
|
+
const relativePath = (local, entry) => {
|
|
1878
|
+
let lastChar = entry.slice(-1);
|
|
1879
|
+
lastChar = lastChar === filetools.sep ? filetools.sep : "";
|
|
1880
|
+
return pth.relative(local, entry) + lastChar;
|
|
1881
|
+
};
|
|
1882
|
+
return {
|
|
1883
|
+
readFile: function(entry, pass) {
|
|
1884
|
+
var item = getEntry(entry);
|
|
1885
|
+
return item && item.getData(pass) || null;
|
|
1886
|
+
},
|
|
1887
|
+
childCount: function(entry) {
|
|
1888
|
+
const item = getEntry(entry);
|
|
1889
|
+
if (item) {
|
|
1890
|
+
return _zip.getChildCount(item);
|
|
1891
|
+
}
|
|
1892
|
+
},
|
|
1893
|
+
readFileAsync: function(entry, callback) {
|
|
1894
|
+
var item = getEntry(entry);
|
|
1895
|
+
if (item) {
|
|
1896
|
+
item.getDataAsync(callback);
|
|
1897
|
+
} else {
|
|
1898
|
+
callback(null, "getEntry failed for:" + entry);
|
|
1899
|
+
}
|
|
1900
|
+
},
|
|
1901
|
+
readAsText: function(entry, encoding) {
|
|
1902
|
+
var item = getEntry(entry);
|
|
1903
|
+
if (item) {
|
|
1904
|
+
var data = item.getData();
|
|
1905
|
+
if (data && data.length) {
|
|
1906
|
+
return data.toString(encoding || "utf8");
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
return "";
|
|
1910
|
+
},
|
|
1911
|
+
readAsTextAsync: function(entry, callback, encoding) {
|
|
1912
|
+
var item = getEntry(entry);
|
|
1913
|
+
if (item) {
|
|
1914
|
+
item.getDataAsync(function(data, err) {
|
|
1915
|
+
if (err) {
|
|
1916
|
+
callback(data, err);
|
|
1917
|
+
return;
|
|
1918
|
+
}
|
|
1919
|
+
if (data && data.length) {
|
|
1920
|
+
callback(data.toString(encoding || "utf8"));
|
|
1921
|
+
} else {
|
|
1922
|
+
callback("");
|
|
1923
|
+
}
|
|
1924
|
+
});
|
|
1925
|
+
} else {
|
|
1926
|
+
callback("");
|
|
1927
|
+
}
|
|
1928
|
+
},
|
|
1929
|
+
deleteFile: function(entry, withsubfolders = true) {
|
|
1930
|
+
var item = getEntry(entry);
|
|
1931
|
+
if (item) {
|
|
1932
|
+
_zip.deleteFile(item.entryName, withsubfolders);
|
|
1933
|
+
}
|
|
1934
|
+
},
|
|
1935
|
+
deleteEntry: function(entry) {
|
|
1936
|
+
var item = getEntry(entry);
|
|
1937
|
+
if (item) {
|
|
1938
|
+
_zip.deleteEntry(item.entryName);
|
|
1939
|
+
}
|
|
1940
|
+
},
|
|
1941
|
+
addZipComment: function(comment) {
|
|
1942
|
+
_zip.comment = comment;
|
|
1943
|
+
},
|
|
1944
|
+
getZipComment: function() {
|
|
1945
|
+
return _zip.comment || "";
|
|
1946
|
+
},
|
|
1947
|
+
addZipEntryComment: function(entry, comment) {
|
|
1948
|
+
var item = getEntry(entry);
|
|
1949
|
+
if (item) {
|
|
1950
|
+
item.comment = comment;
|
|
1951
|
+
}
|
|
1952
|
+
},
|
|
1953
|
+
getZipEntryComment: function(entry) {
|
|
1954
|
+
var item = getEntry(entry);
|
|
1955
|
+
if (item) {
|
|
1956
|
+
return item.comment || "";
|
|
1957
|
+
}
|
|
1958
|
+
return "";
|
|
1959
|
+
},
|
|
1960
|
+
updateFile: function(entry, content) {
|
|
1961
|
+
var item = getEntry(entry);
|
|
1962
|
+
if (item) {
|
|
1963
|
+
item.setData(content);
|
|
1964
|
+
}
|
|
1965
|
+
},
|
|
1966
|
+
addLocalFile: function(localPath, zipPath, zipName, comment) {
|
|
1967
|
+
if (filetools.fs.existsSync(localPath)) {
|
|
1968
|
+
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
1969
|
+
const p = pth.win32.basename(pth.win32.normalize(localPath));
|
|
1970
|
+
zipPath += zipName ? zipName : p;
|
|
1971
|
+
const _attr = filetools.fs.statSync(localPath);
|
|
1972
|
+
const data = _attr.isFile() ? filetools.fs.readFileSync(localPath) : Buffer.alloc(0);
|
|
1973
|
+
if (_attr.isDirectory())
|
|
1974
|
+
zipPath += filetools.sep;
|
|
1975
|
+
this.addFile(zipPath, data, comment, _attr);
|
|
1976
|
+
} else {
|
|
1977
|
+
throw Utils.Errors.FILE_NOT_FOUND(localPath);
|
|
1978
|
+
}
|
|
1979
|
+
},
|
|
1980
|
+
addLocalFileAsync: function(options2, callback) {
|
|
1981
|
+
options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
|
|
1982
|
+
const localPath = pth.resolve(options2.localPath);
|
|
1983
|
+
const { comment } = options2;
|
|
1984
|
+
let { zipPath, zipName } = options2;
|
|
1985
|
+
const self = this;
|
|
1986
|
+
filetools.fs.stat(localPath, function(err, stats) {
|
|
1987
|
+
if (err)
|
|
1988
|
+
return callback(err, false);
|
|
1989
|
+
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
1990
|
+
const p = pth.win32.basename(pth.win32.normalize(localPath));
|
|
1991
|
+
zipPath += zipName ? zipName : p;
|
|
1992
|
+
if (stats.isFile()) {
|
|
1993
|
+
filetools.fs.readFile(localPath, function(err2, data) {
|
|
1994
|
+
if (err2)
|
|
1995
|
+
return callback(err2, false);
|
|
1996
|
+
self.addFile(zipPath, data, comment, stats);
|
|
1997
|
+
return setImmediate(callback, undefined, true);
|
|
1998
|
+
});
|
|
1999
|
+
} else if (stats.isDirectory()) {
|
|
2000
|
+
zipPath += filetools.sep;
|
|
2001
|
+
self.addFile(zipPath, Buffer.alloc(0), comment, stats);
|
|
2002
|
+
return setImmediate(callback, undefined, true);
|
|
2003
|
+
}
|
|
2004
|
+
});
|
|
2005
|
+
},
|
|
2006
|
+
addLocalFolder: function(localPath, zipPath, filter) {
|
|
2007
|
+
filter = filenameFilter(filter);
|
|
2008
|
+
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
2009
|
+
localPath = pth.normalize(localPath);
|
|
2010
|
+
if (filetools.fs.existsSync(localPath)) {
|
|
2011
|
+
const items = filetools.findFiles(localPath);
|
|
2012
|
+
const self = this;
|
|
2013
|
+
if (items.length) {
|
|
2014
|
+
for (const filepath of items) {
|
|
2015
|
+
const p = pth.join(zipPath, relativePath(localPath, filepath));
|
|
2016
|
+
if (filter(p)) {
|
|
2017
|
+
self.addLocalFile(filepath, pth.dirname(p));
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
} else {
|
|
2022
|
+
throw Utils.Errors.FILE_NOT_FOUND(localPath);
|
|
2023
|
+
}
|
|
2024
|
+
},
|
|
2025
|
+
addLocalFolderAsync: function(localPath, callback, zipPath, filter) {
|
|
2026
|
+
filter = filenameFilter(filter);
|
|
2027
|
+
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
2028
|
+
localPath = pth.normalize(localPath);
|
|
2029
|
+
var self = this;
|
|
2030
|
+
filetools.fs.open(localPath, "r", function(err) {
|
|
2031
|
+
if (err && err.code === "ENOENT") {
|
|
2032
|
+
callback(undefined, Utils.Errors.FILE_NOT_FOUND(localPath));
|
|
2033
|
+
} else if (err) {
|
|
2034
|
+
callback(undefined, err);
|
|
2035
|
+
} else {
|
|
2036
|
+
var items = filetools.findFiles(localPath);
|
|
2037
|
+
var i = -1;
|
|
2038
|
+
var next = function() {
|
|
2039
|
+
i += 1;
|
|
2040
|
+
if (i < items.length) {
|
|
2041
|
+
var filepath = items[i];
|
|
2042
|
+
var p = relativePath(localPath, filepath).split("\\").join("/");
|
|
2043
|
+
p = p.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
|
|
2044
|
+
if (filter(p)) {
|
|
2045
|
+
filetools.fs.stat(filepath, function(er0, stats) {
|
|
2046
|
+
if (er0)
|
|
2047
|
+
callback(undefined, er0);
|
|
2048
|
+
if (stats.isFile()) {
|
|
2049
|
+
filetools.fs.readFile(filepath, function(er1, data) {
|
|
2050
|
+
if (er1) {
|
|
2051
|
+
callback(undefined, er1);
|
|
2052
|
+
} else {
|
|
2053
|
+
self.addFile(zipPath + p, data, "", stats);
|
|
2054
|
+
next();
|
|
2055
|
+
}
|
|
2056
|
+
});
|
|
2057
|
+
} else {
|
|
2058
|
+
self.addFile(zipPath + p + "/", Buffer.alloc(0), "", stats);
|
|
2059
|
+
next();
|
|
2060
|
+
}
|
|
2061
|
+
});
|
|
2062
|
+
} else {
|
|
2063
|
+
process.nextTick(() => {
|
|
2064
|
+
next();
|
|
2065
|
+
});
|
|
2066
|
+
}
|
|
2067
|
+
} else {
|
|
2068
|
+
callback(true, undefined);
|
|
2069
|
+
}
|
|
2070
|
+
};
|
|
2071
|
+
next();
|
|
2072
|
+
}
|
|
2073
|
+
});
|
|
2074
|
+
},
|
|
2075
|
+
addLocalFolderAsync2: function(options2, callback) {
|
|
2076
|
+
const self = this;
|
|
2077
|
+
options2 = typeof options2 === "object" ? options2 : { localPath: options2 };
|
|
2078
|
+
const localPath = pth.resolve(fixPath(options2.localPath));
|
|
2079
|
+
let { zipPath, filter, namefix } = options2;
|
|
2080
|
+
if (filter instanceof RegExp) {
|
|
2081
|
+
filter = function(rx) {
|
|
2082
|
+
return function(filename) {
|
|
2083
|
+
return rx.test(filename);
|
|
2084
|
+
};
|
|
2085
|
+
}(filter);
|
|
2086
|
+
} else if (typeof filter !== "function") {
|
|
2087
|
+
filter = function() {
|
|
2088
|
+
return true;
|
|
2089
|
+
};
|
|
2090
|
+
}
|
|
2091
|
+
zipPath = zipPath ? fixPath(zipPath) : "";
|
|
2092
|
+
if (namefix === "latin1") {
|
|
2093
|
+
namefix = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
|
|
2094
|
+
}
|
|
2095
|
+
if (typeof namefix !== "function")
|
|
2096
|
+
namefix = (str) => str;
|
|
2097
|
+
const relPathFix = (entry) => pth.join(zipPath, namefix(relativePath(localPath, entry)));
|
|
2098
|
+
const fileNameFix = (entry) => pth.win32.basename(pth.win32.normalize(namefix(entry)));
|
|
2099
|
+
filetools.fs.open(localPath, "r", function(err) {
|
|
2100
|
+
if (err && err.code === "ENOENT") {
|
|
2101
|
+
callback(undefined, Utils.Errors.FILE_NOT_FOUND(localPath));
|
|
2102
|
+
} else if (err) {
|
|
2103
|
+
callback(undefined, err);
|
|
2104
|
+
} else {
|
|
2105
|
+
filetools.findFilesAsync(localPath, function(err2, fileEntries) {
|
|
2106
|
+
if (err2)
|
|
2107
|
+
return callback(err2);
|
|
2108
|
+
fileEntries = fileEntries.filter((dir) => filter(relPathFix(dir)));
|
|
2109
|
+
if (!fileEntries.length)
|
|
2110
|
+
callback(undefined, false);
|
|
2111
|
+
setImmediate(fileEntries.reverse().reduce(function(next, entry) {
|
|
2112
|
+
return function(err3, done) {
|
|
2113
|
+
if (err3 || done === false)
|
|
2114
|
+
return setImmediate(next, err3, false);
|
|
2115
|
+
self.addLocalFileAsync({
|
|
2116
|
+
localPath: entry,
|
|
2117
|
+
zipPath: pth.dirname(relPathFix(entry)),
|
|
2118
|
+
zipName: fileNameFix(entry)
|
|
2119
|
+
}, next);
|
|
2120
|
+
};
|
|
2121
|
+
}, callback));
|
|
2122
|
+
});
|
|
2123
|
+
}
|
|
2124
|
+
});
|
|
2125
|
+
},
|
|
2126
|
+
addLocalFolderPromise: function(localPath, props) {
|
|
2127
|
+
return new Promise((resolve, reject) => {
|
|
2128
|
+
this.addLocalFolderAsync2(Object.assign({ localPath }, props), (err, done) => {
|
|
2129
|
+
if (err)
|
|
2130
|
+
reject(err);
|
|
2131
|
+
if (done)
|
|
2132
|
+
resolve(this);
|
|
2133
|
+
});
|
|
2134
|
+
});
|
|
2135
|
+
},
|
|
2136
|
+
addFile: function(entryName, content, comment, attr) {
|
|
2137
|
+
entryName = zipnamefix(entryName);
|
|
2138
|
+
let entry = getEntry(entryName);
|
|
2139
|
+
const update = entry != null;
|
|
2140
|
+
if (!update) {
|
|
2141
|
+
entry = new ZipEntry(opts);
|
|
2142
|
+
entry.entryName = entryName;
|
|
2143
|
+
}
|
|
2144
|
+
entry.comment = comment || "";
|
|
2145
|
+
const isStat = typeof attr === "object" && attr instanceof filetools.fs.Stats;
|
|
2146
|
+
if (isStat) {
|
|
2147
|
+
entry.header.time = attr.mtime;
|
|
2148
|
+
}
|
|
2149
|
+
var fileattr = entry.isDirectory ? 16 : 0;
|
|
2150
|
+
let unix = entry.isDirectory ? 16384 : 32768;
|
|
2151
|
+
if (isStat) {
|
|
2152
|
+
unix |= 4095 & attr.mode;
|
|
2153
|
+
} else if (typeof attr === "number") {
|
|
2154
|
+
unix |= 4095 & attr;
|
|
2155
|
+
} else {
|
|
2156
|
+
unix |= entry.isDirectory ? 493 : 420;
|
|
2157
|
+
}
|
|
2158
|
+
fileattr = (fileattr | unix << 16) >>> 0;
|
|
2159
|
+
entry.attr = fileattr;
|
|
2160
|
+
entry.setData(content);
|
|
2161
|
+
if (!update)
|
|
2162
|
+
_zip.setEntry(entry);
|
|
2163
|
+
return entry;
|
|
2164
|
+
},
|
|
2165
|
+
getEntries: function(password) {
|
|
2166
|
+
_zip.password = password;
|
|
2167
|
+
return _zip ? _zip.entries : [];
|
|
2168
|
+
},
|
|
2169
|
+
getEntry: function(name) {
|
|
2170
|
+
return getEntry(name);
|
|
2171
|
+
},
|
|
2172
|
+
getEntryCount: function() {
|
|
2173
|
+
return _zip.getEntryCount();
|
|
2174
|
+
},
|
|
2175
|
+
forEach: function(callback) {
|
|
2176
|
+
return _zip.forEach(callback);
|
|
2177
|
+
},
|
|
2178
|
+
extractEntryTo: function(entry, targetPath, maintainEntryPath, overwrite, keepOriginalPermission, outFileName) {
|
|
2179
|
+
overwrite = get_Bool(false, overwrite);
|
|
2180
|
+
keepOriginalPermission = get_Bool(false, keepOriginalPermission);
|
|
2181
|
+
maintainEntryPath = get_Bool(true, maintainEntryPath);
|
|
2182
|
+
outFileName = get_Str(keepOriginalPermission, outFileName);
|
|
2183
|
+
var item = getEntry(entry);
|
|
2184
|
+
if (!item) {
|
|
2185
|
+
throw Utils.Errors.NO_ENTRY();
|
|
2186
|
+
}
|
|
2187
|
+
var entryName = canonical(item.entryName);
|
|
2188
|
+
var target = sanitize(targetPath, outFileName && !item.isDirectory ? canonical(outFileName) : maintainEntryPath ? entryName : pth.basename(entryName));
|
|
2189
|
+
if (item.isDirectory) {
|
|
2190
|
+
var children = _zip.getEntryChildren(item);
|
|
2191
|
+
children.forEach(function(child) {
|
|
2192
|
+
if (child.isDirectory)
|
|
2193
|
+
return;
|
|
2194
|
+
var content2 = child.getData();
|
|
2195
|
+
if (!content2) {
|
|
2196
|
+
throw Utils.Errors.CANT_EXTRACT_FILE();
|
|
2197
|
+
}
|
|
2198
|
+
var name = canonical(maintainEntryPath ? child.entryName : child.entryName.substring(item.entryName.length));
|
|
2199
|
+
var childName = sanitize(targetPath, name);
|
|
2200
|
+
const fileAttr2 = keepOriginalPermission ? child.header.fileAttr : undefined;
|
|
2201
|
+
filetools.writeFileTo(childName, content2, overwrite, fileAttr2);
|
|
2202
|
+
});
|
|
2203
|
+
return true;
|
|
2204
|
+
}
|
|
2205
|
+
var content = item.getData(_zip.password);
|
|
2206
|
+
if (!content)
|
|
2207
|
+
throw Utils.Errors.CANT_EXTRACT_FILE();
|
|
2208
|
+
if (filetools.fs.existsSync(target) && !overwrite) {
|
|
2209
|
+
throw Utils.Errors.CANT_OVERRIDE();
|
|
2210
|
+
}
|
|
2211
|
+
const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
|
|
2212
|
+
filetools.writeFileTo(target, content, overwrite, fileAttr);
|
|
2213
|
+
return true;
|
|
2214
|
+
},
|
|
2215
|
+
test: function(pass) {
|
|
2216
|
+
if (!_zip) {
|
|
2217
|
+
return false;
|
|
2218
|
+
}
|
|
2219
|
+
for (var entry of _zip.entries) {
|
|
2220
|
+
try {
|
|
2221
|
+
if (entry.isDirectory) {
|
|
2222
|
+
continue;
|
|
2223
|
+
}
|
|
2224
|
+
var content = entry.getData(pass);
|
|
2225
|
+
if (!content) {
|
|
2226
|
+
return false;
|
|
2227
|
+
}
|
|
2228
|
+
} catch (err) {
|
|
2229
|
+
return false;
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
return true;
|
|
2233
|
+
},
|
|
2234
|
+
extractAllTo: function(targetPath, overwrite, keepOriginalPermission, pass) {
|
|
2235
|
+
keepOriginalPermission = get_Bool(false, keepOriginalPermission);
|
|
2236
|
+
pass = get_Str(keepOriginalPermission, pass);
|
|
2237
|
+
overwrite = get_Bool(false, overwrite);
|
|
2238
|
+
if (!_zip)
|
|
2239
|
+
throw Utils.Errors.NO_ZIP();
|
|
2240
|
+
const dirEntries = [];
|
|
2241
|
+
_zip.entries.forEach(function(entry) {
|
|
2242
|
+
var entryName = sanitize(targetPath, canonical(entry.entryName));
|
|
2243
|
+
if (entry.isDirectory) {
|
|
2244
|
+
filetools.makeDir(entryName);
|
|
2245
|
+
if (keepOriginalPermission)
|
|
2246
|
+
dirEntries.push({ path: entryName, attr: entry.header.fileAttr });
|
|
2247
|
+
return;
|
|
2248
|
+
}
|
|
2249
|
+
var content = entry.getData(pass);
|
|
2250
|
+
if (!content) {
|
|
2251
|
+
throw Utils.Errors.CANT_EXTRACT_FILE();
|
|
2252
|
+
}
|
|
2253
|
+
const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
|
|
2254
|
+
filetools.writeFileTo(entryName, content, overwrite, fileAttr);
|
|
2255
|
+
try {
|
|
2256
|
+
filetools.fs.utimesSync(entryName, entry.header.time, entry.header.time);
|
|
2257
|
+
} catch (err) {}
|
|
2258
|
+
});
|
|
2259
|
+
applyDirAttributes(dirEntries);
|
|
2260
|
+
},
|
|
2261
|
+
extractAllToAsync: function(targetPath, overwrite, keepOriginalPermission, callback) {
|
|
2262
|
+
callback = get_Fun(overwrite, keepOriginalPermission, callback);
|
|
2263
|
+
keepOriginalPermission = get_Bool(false, keepOriginalPermission);
|
|
2264
|
+
overwrite = get_Bool(false, overwrite);
|
|
2265
|
+
if (!callback) {
|
|
2266
|
+
return new Promise((resolve, reject) => {
|
|
2267
|
+
this.extractAllToAsync(targetPath, overwrite, keepOriginalPermission, function(err) {
|
|
2268
|
+
if (err) {
|
|
2269
|
+
reject(err);
|
|
2270
|
+
} else {
|
|
2271
|
+
resolve(this);
|
|
2272
|
+
}
|
|
2273
|
+
});
|
|
2274
|
+
});
|
|
2275
|
+
}
|
|
2276
|
+
if (!_zip) {
|
|
2277
|
+
callback(Utils.Errors.NO_ZIP());
|
|
2278
|
+
return;
|
|
2279
|
+
}
|
|
2280
|
+
targetPath = pth.resolve(targetPath);
|
|
2281
|
+
const getPath = (entry) => sanitize(targetPath, pth.normalize(canonical(entry.entryName)));
|
|
2282
|
+
const getError = (msg, file) => new Error(msg + ': "' + file + '"');
|
|
2283
|
+
const dirEntries = [];
|
|
2284
|
+
const fileEntries = [];
|
|
2285
|
+
_zip.entries.forEach((e) => {
|
|
2286
|
+
if (e.isDirectory) {
|
|
2287
|
+
dirEntries.push(e);
|
|
2288
|
+
} else {
|
|
2289
|
+
fileEntries.push(e);
|
|
2290
|
+
}
|
|
2291
|
+
});
|
|
2292
|
+
const deferredDirAttr = [];
|
|
2293
|
+
for (const entry of dirEntries) {
|
|
2294
|
+
const dirPath = getPath(entry);
|
|
2295
|
+
const dirAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
|
|
2296
|
+
try {
|
|
2297
|
+
filetools.makeDir(dirPath);
|
|
2298
|
+
} catch (er) {
|
|
2299
|
+
callback(getError("Unable to create folder", dirPath));
|
|
2300
|
+
continue;
|
|
2301
|
+
}
|
|
2302
|
+
if (dirAttr)
|
|
2303
|
+
deferredDirAttr.push({ path: dirPath, attr: dirAttr });
|
|
2304
|
+
try {
|
|
2305
|
+
filetools.fs.utimesSync(dirPath, entry.header.time, entry.header.time);
|
|
2306
|
+
} catch (er) {}
|
|
2307
|
+
}
|
|
2308
|
+
const done = (err) => {
|
|
2309
|
+
if (!err) {
|
|
2310
|
+
try {
|
|
2311
|
+
applyDirAttributes(deferredDirAttr);
|
|
2312
|
+
} catch (er) {
|
|
2313
|
+
return callback(getError("Unable to set folder permissions", er.path || ""));
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
callback(err);
|
|
2317
|
+
};
|
|
2318
|
+
fileEntries.reverse().reduce(function(next, entry) {
|
|
2319
|
+
return function(err) {
|
|
2320
|
+
if (err) {
|
|
2321
|
+
next(err);
|
|
2322
|
+
} else {
|
|
2323
|
+
const entryName = pth.normalize(canonical(entry.entryName));
|
|
2324
|
+
const filePath = sanitize(targetPath, entryName);
|
|
2325
|
+
entry.getDataAsync(function(content, err_1) {
|
|
2326
|
+
if (err_1) {
|
|
2327
|
+
next(err_1);
|
|
2328
|
+
} else if (!content) {
|
|
2329
|
+
next(Utils.Errors.CANT_EXTRACT_FILE());
|
|
2330
|
+
} else {
|
|
2331
|
+
const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
|
|
2332
|
+
filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function(succ) {
|
|
2333
|
+
if (!succ) {
|
|
2334
|
+
return next(getError("Unable to write file", filePath));
|
|
2335
|
+
}
|
|
2336
|
+
filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function() {
|
|
2337
|
+
next();
|
|
2338
|
+
});
|
|
2339
|
+
});
|
|
2340
|
+
}
|
|
2341
|
+
});
|
|
2342
|
+
}
|
|
2343
|
+
};
|
|
2344
|
+
}, done)();
|
|
2345
|
+
},
|
|
2346
|
+
writeZip: function(targetFileName, callback) {
|
|
2347
|
+
if (arguments.length === 1) {
|
|
2348
|
+
if (typeof targetFileName === "function") {
|
|
2349
|
+
callback = targetFileName;
|
|
2350
|
+
targetFileName = "";
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
if (!targetFileName && opts.filename) {
|
|
2354
|
+
targetFileName = opts.filename;
|
|
2355
|
+
}
|
|
2356
|
+
if (!targetFileName)
|
|
2357
|
+
return;
|
|
2358
|
+
var zipData = _zip.compressToBuffer();
|
|
2359
|
+
if (zipData) {
|
|
2360
|
+
var ok = filetools.writeFileTo(targetFileName, zipData, true);
|
|
2361
|
+
if (typeof callback === "function")
|
|
2362
|
+
callback(!ok ? new Error("failed") : null, "");
|
|
2363
|
+
}
|
|
2364
|
+
},
|
|
2365
|
+
writeZipPromise: function(targetFileName, props) {
|
|
2366
|
+
const { overwrite, perm } = Object.assign({ overwrite: true }, props);
|
|
2367
|
+
return new Promise((resolve, reject) => {
|
|
2368
|
+
if (!targetFileName && opts.filename)
|
|
2369
|
+
targetFileName = opts.filename;
|
|
2370
|
+
if (!targetFileName)
|
|
2371
|
+
reject("ADM-ZIP: ZIP File Name Missing");
|
|
2372
|
+
this.toBufferPromise().then((zipData) => {
|
|
2373
|
+
const ret = (done) => done ? resolve(done) : reject("ADM-ZIP: Wasn't able to write zip file");
|
|
2374
|
+
filetools.writeFileToAsync(targetFileName, zipData, overwrite, perm, ret);
|
|
2375
|
+
}, reject);
|
|
2376
|
+
});
|
|
2377
|
+
},
|
|
2378
|
+
toBufferPromise: function() {
|
|
2379
|
+
return new Promise((resolve, reject) => {
|
|
2380
|
+
_zip.toAsyncBuffer(resolve, reject);
|
|
2381
|
+
});
|
|
2382
|
+
},
|
|
2383
|
+
toBuffer: function(onSuccess, onFail, onItemStart, onItemEnd) {
|
|
2384
|
+
if (typeof onSuccess === "function") {
|
|
2385
|
+
_zip.toAsyncBuffer(onSuccess, onFail, onItemStart, onItemEnd);
|
|
2386
|
+
return null;
|
|
2387
|
+
}
|
|
2388
|
+
return _zip.compressToBuffer();
|
|
2389
|
+
}
|
|
2390
|
+
};
|
|
2391
|
+
};
|
|
2392
|
+
});
|
|
2393
|
+
|
|
2394
|
+
// ../solution-sdk/generated/src/runtime.ts
|
|
2395
|
+
var BASE_PATH = "https://alpha.uipath.com/uipattycyrhx/abizon_1/automationsolutions_".replace(/\/+$/, "");
|
|
2396
|
+
|
|
2397
|
+
class Configuration {
|
|
2398
|
+
configuration;
|
|
2399
|
+
constructor(configuration = {}) {
|
|
2400
|
+
this.configuration = configuration;
|
|
2401
|
+
}
|
|
2402
|
+
set config(configuration) {
|
|
2403
|
+
this.configuration = configuration;
|
|
2404
|
+
}
|
|
2405
|
+
get basePath() {
|
|
2406
|
+
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
|
|
2407
|
+
}
|
|
2408
|
+
get fetchApi() {
|
|
2409
|
+
return this.configuration.fetchApi;
|
|
2410
|
+
}
|
|
2411
|
+
get middleware() {
|
|
2412
|
+
return this.configuration.middleware || [];
|
|
2413
|
+
}
|
|
2414
|
+
get queryParamsStringify() {
|
|
2415
|
+
return this.configuration.queryParamsStringify || querystring;
|
|
2416
|
+
}
|
|
2417
|
+
get username() {
|
|
2418
|
+
return this.configuration.username;
|
|
2419
|
+
}
|
|
2420
|
+
get password() {
|
|
2421
|
+
return this.configuration.password;
|
|
2422
|
+
}
|
|
2423
|
+
get apiKey() {
|
|
2424
|
+
const apiKey = this.configuration.apiKey;
|
|
2425
|
+
if (apiKey) {
|
|
2426
|
+
return typeof apiKey === "function" ? apiKey : () => apiKey;
|
|
2427
|
+
}
|
|
2428
|
+
return;
|
|
2429
|
+
}
|
|
2430
|
+
get accessToken() {
|
|
2431
|
+
const accessToken = this.configuration.accessToken;
|
|
2432
|
+
if (accessToken) {
|
|
2433
|
+
return typeof accessToken === "function" ? accessToken : async () => accessToken;
|
|
2434
|
+
}
|
|
2435
|
+
return;
|
|
2436
|
+
}
|
|
2437
|
+
get headers() {
|
|
2438
|
+
return this.configuration.headers;
|
|
2439
|
+
}
|
|
2440
|
+
get credentials() {
|
|
2441
|
+
return this.configuration.credentials;
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
var DefaultConfig = new Configuration;
|
|
2445
|
+
|
|
2446
|
+
class BaseAPI {
|
|
2447
|
+
configuration;
|
|
2448
|
+
static jsonRegex = new RegExp("^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$", "i");
|
|
2449
|
+
middleware;
|
|
2450
|
+
constructor(configuration = DefaultConfig) {
|
|
2451
|
+
this.configuration = configuration;
|
|
2452
|
+
this.middleware = configuration.middleware;
|
|
2453
|
+
}
|
|
2454
|
+
withMiddleware(...middlewares) {
|
|
2455
|
+
const next = this.clone();
|
|
2456
|
+
next.middleware = next.middleware.concat(...middlewares);
|
|
2457
|
+
return next;
|
|
2458
|
+
}
|
|
2459
|
+
withPreMiddleware(...preMiddlewares) {
|
|
2460
|
+
const middlewares = preMiddlewares.map((pre) => ({ pre }));
|
|
2461
|
+
return this.withMiddleware(...middlewares);
|
|
2462
|
+
}
|
|
2463
|
+
withPostMiddleware(...postMiddlewares) {
|
|
2464
|
+
const middlewares = postMiddlewares.map((post) => ({ post }));
|
|
2465
|
+
return this.withMiddleware(...middlewares);
|
|
2466
|
+
}
|
|
2467
|
+
isJsonMime(mime) {
|
|
2468
|
+
if (!mime) {
|
|
2469
|
+
return false;
|
|
2470
|
+
}
|
|
2471
|
+
return BaseAPI.jsonRegex.test(mime);
|
|
2472
|
+
}
|
|
2473
|
+
async request(context, initOverrides) {
|
|
2474
|
+
const { url, init } = await this.createFetchParams(context, initOverrides);
|
|
2475
|
+
const response = await this.fetchApi(url, init);
|
|
2476
|
+
if (response && (response.status >= 200 && response.status < 300)) {
|
|
2477
|
+
return response;
|
|
2478
|
+
}
|
|
2479
|
+
throw new ResponseError(response, "Response returned an error code");
|
|
2480
|
+
}
|
|
2481
|
+
async createFetchParams(context, initOverrides) {
|
|
2482
|
+
let url = this.configuration.basePath + context.path;
|
|
2483
|
+
if (context.query !== undefined && Object.keys(context.query).length !== 0) {
|
|
2484
|
+
url += "?" + this.configuration.queryParamsStringify(context.query);
|
|
2485
|
+
}
|
|
2486
|
+
const headers = Object.assign({}, this.configuration.headers, context.headers);
|
|
2487
|
+
Object.keys(headers).forEach((key) => headers[key] === undefined ? delete headers[key] : {});
|
|
2488
|
+
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : async () => initOverrides;
|
|
2489
|
+
const initParams = {
|
|
2490
|
+
method: context.method,
|
|
2491
|
+
headers,
|
|
2492
|
+
body: context.body,
|
|
2493
|
+
credentials: this.configuration.credentials
|
|
2494
|
+
};
|
|
2495
|
+
const overriddenInit = {
|
|
2496
|
+
...initParams,
|
|
2497
|
+
...await initOverrideFn({
|
|
2498
|
+
init: initParams,
|
|
2499
|
+
context
|
|
2500
|
+
})
|
|
2501
|
+
};
|
|
2502
|
+
let body;
|
|
2503
|
+
if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
|
|
2504
|
+
body = overriddenInit.body;
|
|
2505
|
+
} else if (this.isJsonMime(headers["Content-Type"])) {
|
|
2506
|
+
body = JSON.stringify(overriddenInit.body);
|
|
2507
|
+
} else {
|
|
2508
|
+
body = overriddenInit.body;
|
|
2509
|
+
}
|
|
2510
|
+
const init = {
|
|
2511
|
+
...overriddenInit,
|
|
2512
|
+
body
|
|
2513
|
+
};
|
|
2514
|
+
return { url, init };
|
|
2515
|
+
}
|
|
2516
|
+
fetchApi = async (url, init) => {
|
|
2517
|
+
let fetchParams = { url, init };
|
|
2518
|
+
for (const middleware of this.middleware) {
|
|
2519
|
+
if (middleware.pre) {
|
|
2520
|
+
fetchParams = await middleware.pre({
|
|
2521
|
+
fetch: this.fetchApi,
|
|
2522
|
+
...fetchParams
|
|
2523
|
+
}) || fetchParams;
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2526
|
+
let response = undefined;
|
|
2527
|
+
try {
|
|
2528
|
+
response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
|
|
2529
|
+
} catch (e) {
|
|
2530
|
+
for (const middleware of this.middleware) {
|
|
2531
|
+
if (middleware.onError) {
|
|
2532
|
+
response = await middleware.onError({
|
|
2533
|
+
fetch: this.fetchApi,
|
|
2534
|
+
url: fetchParams.url,
|
|
2535
|
+
init: fetchParams.init,
|
|
2536
|
+
error: e,
|
|
2537
|
+
response: response ? response.clone() : undefined
|
|
2538
|
+
}) || response;
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
if (response === undefined) {
|
|
2542
|
+
if (e instanceof Error) {
|
|
2543
|
+
throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
|
|
2544
|
+
} else {
|
|
2545
|
+
throw e;
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
for (const middleware of this.middleware) {
|
|
2550
|
+
if (middleware.post) {
|
|
2551
|
+
response = await middleware.post({
|
|
2552
|
+
fetch: this.fetchApi,
|
|
2553
|
+
url: fetchParams.url,
|
|
2554
|
+
init: fetchParams.init,
|
|
2555
|
+
response: response.clone()
|
|
2556
|
+
}) || response;
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
return response;
|
|
2560
|
+
};
|
|
2561
|
+
clone() {
|
|
2562
|
+
const constructor = this.constructor;
|
|
2563
|
+
const next = new constructor(this.configuration);
|
|
2564
|
+
next.middleware = this.middleware.slice();
|
|
2565
|
+
return next;
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
function isBlob(value) {
|
|
2569
|
+
return typeof Blob !== "undefined" && value instanceof Blob;
|
|
2570
|
+
}
|
|
2571
|
+
function isFormData(value) {
|
|
2572
|
+
return typeof FormData !== "undefined" && value instanceof FormData;
|
|
2573
|
+
}
|
|
2574
|
+
|
|
2575
|
+
class ResponseError extends Error {
|
|
2576
|
+
response;
|
|
2577
|
+
name = "ResponseError";
|
|
2578
|
+
constructor(response, msg) {
|
|
2579
|
+
super(msg);
|
|
2580
|
+
this.response = response;
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
class FetchError extends Error {
|
|
2585
|
+
cause;
|
|
2586
|
+
name = "FetchError";
|
|
2587
|
+
constructor(cause, msg) {
|
|
2588
|
+
super(msg);
|
|
2589
|
+
this.cause = cause;
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2593
|
+
class RequiredError extends Error {
|
|
2594
|
+
field;
|
|
2595
|
+
name = "RequiredError";
|
|
2596
|
+
constructor(field, msg) {
|
|
2597
|
+
super(msg);
|
|
2598
|
+
this.field = field;
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
function querystring(params, prefix = "") {
|
|
2602
|
+
return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
|
|
2603
|
+
}
|
|
2604
|
+
function querystringSingleKey(key, value, keyPrefix = "") {
|
|
2605
|
+
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
|
|
2606
|
+
if (value instanceof Array) {
|
|
2607
|
+
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
|
|
2608
|
+
return `${encodeURIComponent(fullKey)}=${multiValue}`;
|
|
2609
|
+
}
|
|
2610
|
+
if (value instanceof Set) {
|
|
2611
|
+
const valueAsArray = Array.from(value);
|
|
2612
|
+
return querystringSingleKey(key, valueAsArray, keyPrefix);
|
|
2613
|
+
}
|
|
2614
|
+
if (value instanceof Date) {
|
|
2615
|
+
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
|
|
2616
|
+
}
|
|
2617
|
+
if (value instanceof Object) {
|
|
2618
|
+
return querystring(value, fullKey);
|
|
2619
|
+
}
|
|
2620
|
+
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
|
|
2621
|
+
}
|
|
2622
|
+
class JSONApiResponse {
|
|
2623
|
+
raw;
|
|
2624
|
+
transformer;
|
|
2625
|
+
constructor(raw, transformer = (jsonValue) => jsonValue) {
|
|
2626
|
+
this.raw = raw;
|
|
2627
|
+
this.transformer = transformer;
|
|
2628
|
+
}
|
|
2629
|
+
async value() {
|
|
2630
|
+
return this.transformer(await this.raw.json());
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2633
|
+
|
|
2634
|
+
class VoidApiResponse {
|
|
2635
|
+
raw;
|
|
2636
|
+
constructor(raw) {
|
|
2637
|
+
this.raw = raw;
|
|
2638
|
+
}
|
|
2639
|
+
async value() {
|
|
2640
|
+
return;
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
class TextApiResponse {
|
|
2644
|
+
raw;
|
|
2645
|
+
constructor(raw) {
|
|
2646
|
+
this.raw = raw;
|
|
2647
|
+
}
|
|
2648
|
+
async value() {
|
|
2649
|
+
return await this.raw.text();
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2653
|
+
// ../solution-sdk/generated/src/models/ResponseDictionaryDto.ts
|
|
2654
|
+
function ResponseDictionaryDtoFromJSON(json) {
|
|
2655
|
+
return ResponseDictionaryDtoFromJSONTyped(json, false);
|
|
2656
|
+
}
|
|
2657
|
+
function ResponseDictionaryDtoFromJSONTyped(json, ignoreDiscriminator) {
|
|
2658
|
+
if (json == null) {
|
|
2659
|
+
return json;
|
|
2660
|
+
}
|
|
2661
|
+
return {
|
|
2662
|
+
keys: json["keys"] == null ? undefined : json["keys"],
|
|
2663
|
+
values: json["values"] == null ? undefined : json["values"]
|
|
2664
|
+
};
|
|
2665
|
+
}
|
|
2666
|
+
|
|
2667
|
+
// ../solution-sdk/generated/src/models/BlobFileAccessDto.ts
|
|
2668
|
+
function BlobFileAccessDtoFromJSON(json) {
|
|
2669
|
+
return BlobFileAccessDtoFromJSONTyped(json, false);
|
|
2670
|
+
}
|
|
2671
|
+
function BlobFileAccessDtoFromJSONTyped(json, ignoreDiscriminator) {
|
|
2672
|
+
if (json == null) {
|
|
2673
|
+
return json;
|
|
2674
|
+
}
|
|
2675
|
+
return {
|
|
2676
|
+
uri: json["uri"],
|
|
2677
|
+
verb: json["verb"],
|
|
2678
|
+
headers: json["headers"] == null ? undefined : ResponseDictionaryDtoFromJSON(json["headers"])
|
|
2679
|
+
};
|
|
2680
|
+
}
|
|
2681
|
+
// ../solution-sdk/generated/src/models/CreateConfigurationCommand.ts
|
|
2682
|
+
function CreateConfigurationCommandToJSON(json) {
|
|
2683
|
+
return CreateConfigurationCommandToJSONTyped(json, false);
|
|
2684
|
+
}
|
|
2685
|
+
function CreateConfigurationCommandToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2686
|
+
if (value == null) {
|
|
2687
|
+
return value;
|
|
2688
|
+
}
|
|
2689
|
+
return {
|
|
2690
|
+
packageVersionKey: value["packageVersionKey"],
|
|
2691
|
+
name: value["name"]
|
|
2692
|
+
};
|
|
2693
|
+
}
|
|
2694
|
+
// ../solution-sdk/generated/src/models/DeploymentActivationStatus.ts
|
|
2695
|
+
function DeploymentActivationStatusFromJSON(json) {
|
|
2696
|
+
return DeploymentActivationStatusFromJSONTyped(json, false);
|
|
2697
|
+
}
|
|
2698
|
+
function DeploymentActivationStatusFromJSONTyped(json, ignoreDiscriminator) {
|
|
2699
|
+
return json;
|
|
2700
|
+
}
|
|
2701
|
+
// ../solution-sdk/generated/src/models/OverwriteType.ts
|
|
2702
|
+
function OverwriteTypeToJSON(value) {
|
|
2703
|
+
return value;
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
// ../solution-sdk/generated/src/models/Overwrite.ts
|
|
2707
|
+
function OverwriteToJSON(json) {
|
|
2708
|
+
return OverwriteToJSONTyped(json, false);
|
|
2709
|
+
}
|
|
2710
|
+
function OverwriteToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2711
|
+
if (value == null) {
|
|
2712
|
+
return value;
|
|
2713
|
+
}
|
|
2714
|
+
return {
|
|
2715
|
+
resourceKey: value["resourceKey"],
|
|
2716
|
+
resourceName: value["resourceName"],
|
|
2717
|
+
folderKey: value["folderKey"],
|
|
2718
|
+
folderFullyQualifiedName: value["folderFullyQualifiedName"],
|
|
2719
|
+
folderPath: value["folderPath"],
|
|
2720
|
+
type: OverwriteTypeToJSON(value["type"])
|
|
2721
|
+
};
|
|
2722
|
+
}
|
|
2723
|
+
|
|
2724
|
+
// ../solution-sdk/generated/src/models/ResourceOverwrite.ts
|
|
2725
|
+
function ResourceOverwriteToJSON(json) {
|
|
2726
|
+
return ResourceOverwriteToJSONTyped(json, false);
|
|
2727
|
+
}
|
|
2728
|
+
function ResourceOverwriteToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2729
|
+
if (value == null) {
|
|
2730
|
+
return value;
|
|
2731
|
+
}
|
|
2732
|
+
return {
|
|
2733
|
+
solutionResourceKey: value["solutionResourceKey"],
|
|
2734
|
+
reprovisioningIndex: value["reprovisioningIndex"],
|
|
2735
|
+
overwrite: OverwriteToJSON(value["overwrite"])
|
|
2736
|
+
};
|
|
2737
|
+
}
|
|
2738
|
+
|
|
2739
|
+
// ../solution-sdk/generated/src/models/RuntimeSetup.ts
|
|
2740
|
+
function RuntimeSetupFromJSON(json) {
|
|
2741
|
+
return RuntimeSetupFromJSONTyped(json, false);
|
|
2742
|
+
}
|
|
2743
|
+
function RuntimeSetupFromJSONTyped(json, ignoreDiscriminator) {
|
|
2744
|
+
if (json == null) {
|
|
2745
|
+
return json;
|
|
2746
|
+
}
|
|
2747
|
+
return {
|
|
2748
|
+
requireServerlessTemplate: json["requireServerlessTemplate"]
|
|
2749
|
+
};
|
|
2750
|
+
}
|
|
2751
|
+
function RuntimeSetupToJSON(json) {
|
|
2752
|
+
return RuntimeSetupToJSONTyped(json, false);
|
|
2753
|
+
}
|
|
2754
|
+
function RuntimeSetupToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2755
|
+
if (value == null) {
|
|
2756
|
+
return value;
|
|
2757
|
+
}
|
|
2758
|
+
return {
|
|
2759
|
+
requireServerlessTemplate: value["requireServerlessTemplate"]
|
|
2760
|
+
};
|
|
2761
|
+
}
|
|
2762
|
+
|
|
2763
|
+
// ../solution-sdk/generated/src/models/DeploymentAutoRequest.ts
|
|
2764
|
+
function DeploymentAutoRequestToJSON(json) {
|
|
2765
|
+
return DeploymentAutoRequestToJSONTyped(json, false);
|
|
2766
|
+
}
|
|
2767
|
+
function DeploymentAutoRequestToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2768
|
+
if (value == null) {
|
|
2769
|
+
return value;
|
|
2770
|
+
}
|
|
2771
|
+
return {
|
|
2772
|
+
packageVersionKey: value["packageVersionKey"],
|
|
2773
|
+
folderFQN: value["folderFQN"],
|
|
2774
|
+
overwrites: value["overwrites"].map(ResourceOverwriteToJSON),
|
|
2775
|
+
runtimeSetup: RuntimeSetupToJSON(value["runtimeSetup"])
|
|
2776
|
+
};
|
|
2777
|
+
}
|
|
2778
|
+
// ../solution-sdk/generated/src/models/DeploymentDto.ts
|
|
2779
|
+
function DeploymentDtoFromJSON(json) {
|
|
2780
|
+
return DeploymentDtoFromJSONTyped(json, false);
|
|
2781
|
+
}
|
|
2782
|
+
function DeploymentDtoFromJSONTyped(json, ignoreDiscriminator) {
|
|
2783
|
+
if (json == null) {
|
|
2784
|
+
return json;
|
|
2785
|
+
}
|
|
2786
|
+
return {
|
|
2787
|
+
packageName: json["packageName"],
|
|
2788
|
+
deploymentName: json["deploymentName"]
|
|
2789
|
+
};
|
|
2790
|
+
}
|
|
2791
|
+
// ../solution-sdk/generated/src/models/WorkflowAction.ts
|
|
2792
|
+
function WorkflowActionFromJSON(json) {
|
|
2793
|
+
return WorkflowActionFromJSONTyped(json, false);
|
|
2794
|
+
}
|
|
2795
|
+
function WorkflowActionFromJSONTyped(json, ignoreDiscriminator) {
|
|
2796
|
+
return json;
|
|
2797
|
+
}
|
|
2798
|
+
|
|
2799
|
+
// ../solution-sdk/generated/src/models/DeploymentOperation.ts
|
|
2800
|
+
function DeploymentOperationFromJSON(json) {
|
|
2801
|
+
return DeploymentOperationFromJSONTyped(json, false);
|
|
2802
|
+
}
|
|
2803
|
+
function DeploymentOperationFromJSONTyped(json, ignoreDiscriminator) {
|
|
2804
|
+
return json;
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
// ../solution-sdk/generated/src/models/PackageVersionOrigin.ts
|
|
2808
|
+
function PackageVersionOriginFromJSON(json) {
|
|
2809
|
+
return PackageVersionOriginFromJSONTyped(json, false);
|
|
2810
|
+
}
|
|
2811
|
+
function PackageVersionOriginFromJSONTyped(json, ignoreDiscriminator) {
|
|
2812
|
+
return json;
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2815
|
+
// ../solution-sdk/generated/src/models/DeploymentOperationStatus.ts
|
|
2816
|
+
function DeploymentOperationStatusFromJSON(json) {
|
|
2817
|
+
return DeploymentOperationStatusFromJSONTyped(json, false);
|
|
2818
|
+
}
|
|
2819
|
+
function DeploymentOperationStatusFromJSONTyped(json, ignoreDiscriminator) {
|
|
2820
|
+
return json;
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
// ../solution-sdk/generated/src/models/DeploymentUpgradeType.ts
|
|
2824
|
+
function DeploymentUpgradeTypeFromJSON(json) {
|
|
2825
|
+
return DeploymentUpgradeTypeFromJSONTyped(json, false);
|
|
2826
|
+
}
|
|
2827
|
+
function DeploymentUpgradeTypeFromJSONTyped(json, ignoreDiscriminator) {
|
|
2828
|
+
return json;
|
|
2829
|
+
}
|
|
2830
|
+
|
|
2831
|
+
// ../solution-sdk/generated/src/models/DeploymentStatus.ts
|
|
2832
|
+
function DeploymentStatusFromJSON(json) {
|
|
2833
|
+
return DeploymentStatusFromJSONTyped(json, false);
|
|
2834
|
+
}
|
|
2835
|
+
function DeploymentStatusFromJSONTyped(json, ignoreDiscriminator) {
|
|
2836
|
+
return json;
|
|
2837
|
+
}
|
|
2838
|
+
|
|
2839
|
+
// ../solution-sdk/generated/src/models/DeploymentItemDto.ts
|
|
2840
|
+
function DeploymentItemDtoFromJSON(json) {
|
|
2841
|
+
return DeploymentItemDtoFromJSONTyped(json, false);
|
|
2842
|
+
}
|
|
2843
|
+
function DeploymentItemDtoFromJSONTyped(json, ignoreDiscriminator) {
|
|
2844
|
+
if (json == null) {
|
|
2845
|
+
return json;
|
|
2846
|
+
}
|
|
2847
|
+
return {
|
|
2848
|
+
key: json["key"],
|
|
2849
|
+
installDeploymentKey: json["installDeploymentKey"],
|
|
2850
|
+
name: json["name"],
|
|
2851
|
+
configurationKey: json["configurationKey"],
|
|
2852
|
+
packageVersionKey: json["packageVersionKey"],
|
|
2853
|
+
packageKey: json["packageKey"],
|
|
2854
|
+
packageName: json["packageName"],
|
|
2855
|
+
packageVersion: json["packageVersion"],
|
|
2856
|
+
currentPackageVersion: json["currentPackageVersion"] == null ? undefined : json["currentPackageVersion"],
|
|
2857
|
+
targetPackageVersion: json["targetPackageVersion"] == null ? undefined : json["targetPackageVersion"],
|
|
2858
|
+
folderPath: json["folderPath"] == null ? undefined : json["folderPath"],
|
|
2859
|
+
installedRootFolderKey: json["installedRootFolderKey"] == null ? undefined : json["installedRootFolderKey"],
|
|
2860
|
+
installedRootFolderName: json["installedRootFolderName"] == null ? undefined : json["installedRootFolderName"],
|
|
2861
|
+
packageVersionOrigin: PackageVersionOriginFromJSON(json["packageVersionOrigin"]),
|
|
2862
|
+
deploymentCreationTime: new Date(json["deploymentCreationTime"]),
|
|
2863
|
+
status: DeploymentStatusFromJSON(json["status"]),
|
|
2864
|
+
startTime: json["startTime"] == null ? undefined : new Date(json["startTime"]),
|
|
2865
|
+
endTime: json["endTime"] == null ? undefined : new Date(json["endTime"]),
|
|
2866
|
+
upgradeType: json["upgradeType"] == null ? undefined : DeploymentUpgradeTypeFromJSON(json["upgradeType"]),
|
|
2867
|
+
operation: DeploymentOperationFromJSON(json["operation"]),
|
|
2868
|
+
operationStatus: DeploymentOperationStatusFromJSON(json["operationStatus"]),
|
|
2869
|
+
activationStatus: DeploymentActivationStatusFromJSON(json["activationStatus"]),
|
|
2870
|
+
instanceId: json["instanceId"] == null ? undefined : json["instanceId"],
|
|
2871
|
+
newPackageVersionAvailable: json["newPackageVersionAvailable"] == null ? undefined : json["newPackageVersionAvailable"],
|
|
2872
|
+
packageVersionDescription: json["packageVersionDescription"] == null ? undefined : json["packageVersionDescription"],
|
|
2873
|
+
packageVersionReleaseNotes: json["packageVersionReleaseNotes"] == null ? undefined : json["packageVersionReleaseNotes"],
|
|
2874
|
+
authorName: json["authorName"],
|
|
2875
|
+
previousDeploymentKey: json["previousDeploymentKey"] == null ? undefined : json["previousDeploymentKey"],
|
|
2876
|
+
runtimeSetup: json["runtimeSetup"] == null ? undefined : RuntimeSetupFromJSON(json["runtimeSetup"]),
|
|
2877
|
+
actions: json["actions"].map(WorkflowActionFromJSON)
|
|
2878
|
+
};
|
|
2879
|
+
}
|
|
2880
|
+
// ../solution-sdk/generated/src/models/DeploymentRequest.ts
|
|
2881
|
+
function DeploymentRequestToJSON(json) {
|
|
2882
|
+
return DeploymentRequestToJSONTyped(json, false);
|
|
2883
|
+
}
|
|
2884
|
+
function DeploymentRequestToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2885
|
+
if (value == null) {
|
|
2886
|
+
return value;
|
|
2887
|
+
}
|
|
2888
|
+
return {
|
|
2889
|
+
configurationKey: value["configurationKey"],
|
|
2890
|
+
deploymentName: value["deploymentName"],
|
|
2891
|
+
installationFolderKey: value["installationFolderKey"],
|
|
2892
|
+
pathFullyQualifiedName: value["pathFullyQualifiedName"],
|
|
2893
|
+
solutionRootFolderName: value["solutionRootFolderName"],
|
|
2894
|
+
forceActivate: value["forceActivate"],
|
|
2895
|
+
runtimeSetup: RuntimeSetupToJSON(value["runtimeSetup"])
|
|
2896
|
+
};
|
|
2897
|
+
}
|
|
2898
|
+
// ../solution-sdk/generated/src/models/DeploymentUpgradeRequest.ts
|
|
2899
|
+
function DeploymentUpgradeRequestToJSON(json) {
|
|
2900
|
+
return DeploymentUpgradeRequestToJSONTyped(json, false);
|
|
2901
|
+
}
|
|
2902
|
+
function DeploymentUpgradeRequestToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2903
|
+
if (value == null) {
|
|
2904
|
+
return value;
|
|
2905
|
+
}
|
|
2906
|
+
return {
|
|
2907
|
+
deploymentName: value["deploymentName"],
|
|
2908
|
+
packageVersionKey: value["packageVersionKey"]
|
|
2909
|
+
};
|
|
2910
|
+
}
|
|
2911
|
+
// ../solution-sdk/generated/src/models/ExtendedPackageVersionState.ts
|
|
2912
|
+
function ExtendedPackageVersionStateFromJSON(json) {
|
|
2913
|
+
return ExtendedPackageVersionStateFromJSONTyped(json, false);
|
|
2914
|
+
}
|
|
2915
|
+
function ExtendedPackageVersionStateFromJSONTyped(json, ignoreDiscriminator) {
|
|
2916
|
+
return json;
|
|
2917
|
+
}
|
|
2918
|
+
// ../solution-sdk/generated/src/models/FolderInfo.ts
|
|
2919
|
+
function FolderInfoFromJSON(json) {
|
|
2920
|
+
return FolderInfoFromJSONTyped(json, false);
|
|
2921
|
+
}
|
|
2922
|
+
function FolderInfoFromJSONTyped(json, ignoreDiscriminator) {
|
|
2923
|
+
if (json == null) {
|
|
2924
|
+
return json;
|
|
2925
|
+
}
|
|
2926
|
+
return {
|
|
2927
|
+
fullyQualifiedName: json["fullyQualifiedName"],
|
|
2928
|
+
path: json["path"] == null ? undefined : json["path"],
|
|
2929
|
+
folderKey: json["folderKey"] == null ? undefined : json["folderKey"]
|
|
2930
|
+
};
|
|
2931
|
+
}
|
|
2932
|
+
// ../solution-sdk/generated/src/models/LocationDto.ts
|
|
2933
|
+
function LocationDtoFromJSON(json) {
|
|
2934
|
+
return LocationDtoFromJSONTyped(json, false);
|
|
2935
|
+
}
|
|
2936
|
+
function LocationDtoFromJSONTyped(json, ignoreDiscriminator) {
|
|
2937
|
+
if (json == null) {
|
|
2938
|
+
return json;
|
|
2939
|
+
}
|
|
2940
|
+
return {
|
|
2941
|
+
name: json["name"],
|
|
2942
|
+
key: json["key"],
|
|
2943
|
+
isPersonalWorkspace: json["isPersonalWorkspace"]
|
|
2944
|
+
};
|
|
2945
|
+
}
|
|
2946
|
+
// ../solution-sdk/generated/src/models/PackageInfo.ts
|
|
2947
|
+
function PackageInfoFromJSON(json) {
|
|
2948
|
+
return PackageInfoFromJSONTyped(json, false);
|
|
2949
|
+
}
|
|
2950
|
+
function PackageInfoFromJSONTyped(json, ignoreDiscriminator) {
|
|
2951
|
+
if (json == null) {
|
|
2952
|
+
return json;
|
|
2953
|
+
}
|
|
2954
|
+
return {
|
|
2955
|
+
key: json["key"],
|
|
2956
|
+
name: json["name"],
|
|
2957
|
+
latestVersion: json["latestVersion"],
|
|
2958
|
+
packageVersionKey: json["packageVersionKey"],
|
|
2959
|
+
authorName: json["authorName"],
|
|
2960
|
+
authorEmail: json["authorEmail"] == null ? undefined : json["authorEmail"],
|
|
2961
|
+
publishDate: new Date(json["publishDate"]),
|
|
2962
|
+
description: json["description"] == null ? undefined : json["description"],
|
|
2963
|
+
releaseNotes: json["releaseNotes"] == null ? undefined : json["releaseNotes"],
|
|
2964
|
+
state: ExtendedPackageVersionStateFromJSON(json["state"]),
|
|
2965
|
+
solutionRootFolderName: json["solutionRootFolderName"],
|
|
2966
|
+
hasUpgradeableDeployments: json["hasUpgradeableDeployments"]
|
|
2967
|
+
};
|
|
2968
|
+
}
|
|
2969
|
+
// ../solution-sdk/generated/src/models/ResourceStats.ts
|
|
2970
|
+
function ResourceStatsFromJSON(json) {
|
|
2971
|
+
return ResourceStatsFromJSONTyped(json, false);
|
|
2972
|
+
}
|
|
2973
|
+
function ResourceStatsFromJSONTyped(json, ignoreDiscriminator) {
|
|
2974
|
+
if (json == null) {
|
|
2975
|
+
return json;
|
|
2976
|
+
}
|
|
2977
|
+
return {
|
|
2978
|
+
count: json["count"],
|
|
2979
|
+
kind: json["kind"],
|
|
2980
|
+
serviceName: json["serviceName"]
|
|
2981
|
+
};
|
|
2982
|
+
}
|
|
2983
|
+
|
|
2984
|
+
// ../solution-sdk/generated/src/models/PackageVersionResourceDto.ts
|
|
2985
|
+
function PackageVersionResourceDtoFromJSON(json) {
|
|
2986
|
+
return PackageVersionResourceDtoFromJSONTyped(json, false);
|
|
2987
|
+
}
|
|
2988
|
+
function PackageVersionResourceDtoFromJSONTyped(json, ignoreDiscriminator) {
|
|
2989
|
+
if (json == null) {
|
|
2990
|
+
return json;
|
|
2991
|
+
}
|
|
2992
|
+
return {
|
|
2993
|
+
key: json["key"],
|
|
2994
|
+
name: json["name"],
|
|
2995
|
+
kind: json["kind"],
|
|
2996
|
+
type: json["type"] == null ? undefined : json["type"],
|
|
2997
|
+
apiVersion: json["apiVersion"],
|
|
2998
|
+
folders: json["folders"].map(FolderInfoFromJSON)
|
|
2999
|
+
};
|
|
3000
|
+
}
|
|
3001
|
+
|
|
3002
|
+
// ../solution-sdk/generated/src/models/PackageVersionComponentsDto.ts
|
|
3003
|
+
function PackageVersionComponentsDtoFromJSON(json) {
|
|
3004
|
+
return PackageVersionComponentsDtoFromJSONTyped(json, false);
|
|
3005
|
+
}
|
|
3006
|
+
function PackageVersionComponentsDtoFromJSONTyped(json, ignoreDiscriminator) {
|
|
3007
|
+
if (json == null) {
|
|
3008
|
+
return json;
|
|
3009
|
+
}
|
|
3010
|
+
return {
|
|
3011
|
+
count: json["count"],
|
|
3012
|
+
resources: json["resources"].map(PackageVersionResourceDtoFromJSON),
|
|
3013
|
+
stats: json["stats"].map(ResourceStatsFromJSON)
|
|
3014
|
+
};
|
|
3015
|
+
}
|
|
3016
|
+
// ../solution-sdk/generated/src/models/PackageVersionInfoDto.ts
|
|
3017
|
+
function PackageVersionInfoDtoFromJSON(json) {
|
|
3018
|
+
return PackageVersionInfoDtoFromJSONTyped(json, false);
|
|
3019
|
+
}
|
|
3020
|
+
function PackageVersionInfoDtoFromJSONTyped(json, ignoreDiscriminator) {
|
|
3021
|
+
if (json == null) {
|
|
3022
|
+
return json;
|
|
3023
|
+
}
|
|
3024
|
+
return {
|
|
3025
|
+
key: json["key"],
|
|
3026
|
+
packageName: json["packageName"],
|
|
3027
|
+
packageVersion: json["packageVersion"],
|
|
3028
|
+
publishDate: new Date(json["publishDate"]),
|
|
3029
|
+
authorName: json["authorName"],
|
|
3030
|
+
authorEmail: json["authorEmail"] == null ? undefined : json["authorEmail"],
|
|
3031
|
+
description: json["description"] == null ? undefined : json["description"],
|
|
3032
|
+
releaseNotes: json["releaseNotes"] == null ? undefined : json["releaseNotes"],
|
|
3033
|
+
state: ExtendedPackageVersionStateFromJSON(json["state"]),
|
|
3034
|
+
solutionRootFolderName: json["solutionRootFolderName"],
|
|
3035
|
+
locationKey: json["locationKey"] == null ? undefined : json["locationKey"],
|
|
3036
|
+
components: json["components"] == null ? undefined : PackageVersionComponentsDtoFromJSON(json["components"])
|
|
3037
|
+
};
|
|
3038
|
+
}
|
|
3039
|
+
// ../solution-sdk/generated/src/apis/ConfigurationsApi.ts
|
|
3040
|
+
class ConfigurationsApi extends BaseAPI {
|
|
3041
|
+
async configurationsPostRaw(requestParameters, initOverrides) {
|
|
3042
|
+
if (requestParameters["createConfigurationCommand"] == null) {
|
|
3043
|
+
throw new RequiredError("createConfigurationCommand", 'Required parameter "createConfigurationCommand" was null or undefined when calling configurationsPost().');
|
|
3044
|
+
}
|
|
3045
|
+
const queryParameters = {};
|
|
3046
|
+
const headerParameters = {};
|
|
3047
|
+
headerParameters["Content-Type"] = "application/json";
|
|
3048
|
+
if (requestParameters["xUipathAsVersion"] != null) {
|
|
3049
|
+
headerParameters["x-uipath-as-version"] = String(requestParameters["xUipathAsVersion"]);
|
|
3050
|
+
}
|
|
3051
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
3052
|
+
const token = this.configuration.accessToken;
|
|
3053
|
+
const tokenString = await token("Bearer", []);
|
|
3054
|
+
if (tokenString) {
|
|
3055
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
3056
|
+
}
|
|
3057
|
+
}
|
|
3058
|
+
let urlPath = `/api/configurations`;
|
|
3059
|
+
const response = await this.request({
|
|
3060
|
+
path: urlPath,
|
|
3061
|
+
method: "POST",
|
|
3062
|
+
headers: headerParameters,
|
|
3063
|
+
query: queryParameters,
|
|
3064
|
+
body: CreateConfigurationCommandToJSON(requestParameters["createConfigurationCommand"])
|
|
3065
|
+
}, initOverrides);
|
|
3066
|
+
if (this.isJsonMime(response.headers.get("content-type"))) {
|
|
3067
|
+
return new JSONApiResponse(response);
|
|
3068
|
+
} else {
|
|
3069
|
+
return new TextApiResponse(response);
|
|
3070
|
+
}
|
|
3071
|
+
}
|
|
3072
|
+
async configurationsPost(requestParameters, initOverrides) {
|
|
3073
|
+
const response = await this.configurationsPostRaw(requestParameters, initOverrides);
|
|
3074
|
+
return await response.value();
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
3077
|
+
|
|
3078
|
+
// ../solution-sdk/generated/src/apis/DeploymentsApi.ts
|
|
3079
|
+
class DeploymentsApi extends BaseAPI {
|
|
3080
|
+
async deploymentsDeployRaw(requestParameters, initOverrides) {
|
|
3081
|
+
if (requestParameters["deploymentAutoRequest"] == null) {
|
|
3082
|
+
throw new RequiredError("deploymentAutoRequest", 'Required parameter "deploymentAutoRequest" was null or undefined when calling deploymentsDeploy().');
|
|
3083
|
+
}
|
|
3084
|
+
const queryParameters = {};
|
|
3085
|
+
const headerParameters = {};
|
|
3086
|
+
headerParameters["Content-Type"] = "application/json";
|
|
3087
|
+
if (requestParameters["xUIPATHFolderKey"] != null) {
|
|
3088
|
+
headerParameters["X-UIPATH-FolderKey"] = String(requestParameters["xUIPATHFolderKey"]);
|
|
3089
|
+
}
|
|
3090
|
+
if (requestParameters["xUipathAsVersion"] != null) {
|
|
3091
|
+
headerParameters["x-uipath-as-version"] = String(requestParameters["xUipathAsVersion"]);
|
|
3092
|
+
}
|
|
3093
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
3094
|
+
const token = this.configuration.accessToken;
|
|
3095
|
+
const tokenString = await token("Bearer", []);
|
|
3096
|
+
if (tokenString) {
|
|
3097
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
3098
|
+
}
|
|
3099
|
+
}
|
|
3100
|
+
let urlPath = `/api/deployments/deploy`;
|
|
3101
|
+
const response = await this.request({
|
|
3102
|
+
path: urlPath,
|
|
3103
|
+
method: "POST",
|
|
3104
|
+
headers: headerParameters,
|
|
3105
|
+
query: queryParameters,
|
|
3106
|
+
body: DeploymentAutoRequestToJSON(requestParameters["deploymentAutoRequest"])
|
|
3107
|
+
}, initOverrides);
|
|
3108
|
+
return new JSONApiResponse(response, (jsonValue) => DeploymentDtoFromJSON(jsonValue));
|
|
3109
|
+
}
|
|
3110
|
+
async deploymentsDeploy(requestParameters, initOverrides) {
|
|
3111
|
+
const response = await this.deploymentsDeployRaw(requestParameters, initOverrides);
|
|
3112
|
+
return await response.value();
|
|
3113
|
+
}
|
|
3114
|
+
async deploymentsGetByKeyRaw(requestParameters, initOverrides) {
|
|
3115
|
+
if (requestParameters["deploymentKey"] == null) {
|
|
3116
|
+
throw new RequiredError("deploymentKey", 'Required parameter "deploymentKey" was null or undefined when calling deploymentsGetByKey().');
|
|
3117
|
+
}
|
|
3118
|
+
const queryParameters = {};
|
|
3119
|
+
const headerParameters = {};
|
|
3120
|
+
if (requestParameters["xUipathAsVersion"] != null) {
|
|
3121
|
+
headerParameters["x-uipath-as-version"] = String(requestParameters["xUipathAsVersion"]);
|
|
3122
|
+
}
|
|
3123
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
3124
|
+
const token = this.configuration.accessToken;
|
|
3125
|
+
const tokenString = await token("Bearer", []);
|
|
3126
|
+
if (tokenString) {
|
|
3127
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
3128
|
+
}
|
|
3129
|
+
}
|
|
3130
|
+
let urlPath = `/api/deployments/{deploymentKey}`;
|
|
3131
|
+
urlPath = urlPath.replace(`{${"deploymentKey"}}`, encodeURIComponent(String(requestParameters["deploymentKey"])));
|
|
3132
|
+
const response = await this.request({
|
|
3133
|
+
path: urlPath,
|
|
3134
|
+
method: "GET",
|
|
3135
|
+
headers: headerParameters,
|
|
3136
|
+
query: queryParameters
|
|
3137
|
+
}, initOverrides);
|
|
3138
|
+
return new JSONApiResponse(response, (jsonValue) => DeploymentItemDtoFromJSON(jsonValue));
|
|
3139
|
+
}
|
|
3140
|
+
async deploymentsGetByKey(requestParameters, initOverrides) {
|
|
3141
|
+
const response = await this.deploymentsGetByKeyRaw(requestParameters, initOverrides);
|
|
3142
|
+
return await response.value();
|
|
3143
|
+
}
|
|
3144
|
+
async deploymentsPostRaw(requestParameters, initOverrides) {
|
|
3145
|
+
if (requestParameters["deploymentRequest"] == null) {
|
|
3146
|
+
throw new RequiredError("deploymentRequest", 'Required parameter "deploymentRequest" was null or undefined when calling deploymentsPost().');
|
|
3147
|
+
}
|
|
3148
|
+
const queryParameters = {};
|
|
3149
|
+
const headerParameters = {};
|
|
3150
|
+
headerParameters["Content-Type"] = "application/json";
|
|
3151
|
+
if (requestParameters["xUipathAsVersion"] != null) {
|
|
3152
|
+
headerParameters["x-uipath-as-version"] = String(requestParameters["xUipathAsVersion"]);
|
|
3153
|
+
}
|
|
3154
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
3155
|
+
const token = this.configuration.accessToken;
|
|
3156
|
+
const tokenString = await token("Bearer", []);
|
|
3157
|
+
if (tokenString) {
|
|
3158
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
let urlPath = `/api/deployments`;
|
|
3162
|
+
const response = await this.request({
|
|
3163
|
+
path: urlPath,
|
|
3164
|
+
method: "POST",
|
|
3165
|
+
headers: headerParameters,
|
|
3166
|
+
query: queryParameters,
|
|
3167
|
+
body: DeploymentRequestToJSON(requestParameters["deploymentRequest"])
|
|
3168
|
+
}, initOverrides);
|
|
3169
|
+
return new JSONApiResponse(response, (jsonValue) => DeploymentItemDtoFromJSON(jsonValue));
|
|
3170
|
+
}
|
|
3171
|
+
async deploymentsPost(requestParameters, initOverrides) {
|
|
3172
|
+
const response = await this.deploymentsPostRaw(requestParameters, initOverrides);
|
|
3173
|
+
return await response.value();
|
|
3174
|
+
}
|
|
3175
|
+
async deploymentsUpgradeRaw(requestParameters, initOverrides) {
|
|
3176
|
+
if (requestParameters["deploymentKey"] == null) {
|
|
3177
|
+
throw new RequiredError("deploymentKey", 'Required parameter "deploymentKey" was null or undefined when calling deploymentsUpgrade().');
|
|
3178
|
+
}
|
|
3179
|
+
const queryParameters = {};
|
|
3180
|
+
if (requestParameters["packageVersionKey"] != null) {
|
|
3181
|
+
queryParameters["packageVersionKey"] = requestParameters["packageVersionKey"];
|
|
3182
|
+
}
|
|
3183
|
+
const headerParameters = {};
|
|
3184
|
+
headerParameters["Content-Type"] = "application/json";
|
|
3185
|
+
if (requestParameters["xUipathAsVersion"] != null) {
|
|
3186
|
+
headerParameters["x-uipath-as-version"] = String(requestParameters["xUipathAsVersion"]);
|
|
3187
|
+
}
|
|
3188
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
3189
|
+
const token = this.configuration.accessToken;
|
|
3190
|
+
const tokenString = await token("Bearer", []);
|
|
3191
|
+
if (tokenString) {
|
|
3192
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
let urlPath = `/api/deployments/{deploymentKey}/upgrade`;
|
|
3196
|
+
urlPath = urlPath.replace(`{${"deploymentKey"}}`, encodeURIComponent(String(requestParameters["deploymentKey"])));
|
|
3197
|
+
const response = await this.request({
|
|
3198
|
+
path: urlPath,
|
|
3199
|
+
method: "POST",
|
|
3200
|
+
headers: headerParameters,
|
|
3201
|
+
query: queryParameters,
|
|
3202
|
+
body: DeploymentUpgradeRequestToJSON(requestParameters["deploymentUpgradeRequest"])
|
|
3203
|
+
}, initOverrides);
|
|
3204
|
+
return new JSONApiResponse(response, (jsonValue) => DeploymentItemDtoFromJSON(jsonValue));
|
|
3205
|
+
}
|
|
3206
|
+
async deploymentsUpgrade(requestParameters, initOverrides) {
|
|
3207
|
+
const response = await this.deploymentsUpgradeRaw(requestParameters, initOverrides);
|
|
3208
|
+
return await response.value();
|
|
3209
|
+
}
|
|
3210
|
+
}
|
|
3211
|
+
|
|
3212
|
+
// ../solution-sdk/generated/src/apis/PackagesApi.ts
|
|
3213
|
+
class PackagesApi extends BaseAPI {
|
|
3214
|
+
async packagesDeletePackageRaw(requestParameters, initOverrides) {
|
|
3215
|
+
if (requestParameters["packageKey"] == null) {
|
|
3216
|
+
throw new RequiredError("packageKey", 'Required parameter "packageKey" was null or undefined when calling packagesDeletePackage().');
|
|
3217
|
+
}
|
|
3218
|
+
const queryParameters = {};
|
|
3219
|
+
const headerParameters = {};
|
|
3220
|
+
if (requestParameters["xUipathAsVersion"] != null) {
|
|
3221
|
+
headerParameters["x-uipath-as-version"] = String(requestParameters["xUipathAsVersion"]);
|
|
3222
|
+
}
|
|
3223
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
3224
|
+
const token = this.configuration.accessToken;
|
|
3225
|
+
const tokenString = await token("Bearer", []);
|
|
3226
|
+
if (tokenString) {
|
|
3227
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
3228
|
+
}
|
|
3229
|
+
}
|
|
3230
|
+
let urlPath = `/api/packages/{packageKey}`;
|
|
3231
|
+
urlPath = urlPath.replace(`{${"packageKey"}}`, encodeURIComponent(String(requestParameters["packageKey"])));
|
|
3232
|
+
const response = await this.request({
|
|
3233
|
+
path: urlPath,
|
|
3234
|
+
method: "DELETE",
|
|
3235
|
+
headers: headerParameters,
|
|
3236
|
+
query: queryParameters
|
|
3237
|
+
}, initOverrides);
|
|
3238
|
+
return new VoidApiResponse(response);
|
|
3239
|
+
}
|
|
3240
|
+
async packagesDeletePackage(requestParameters, initOverrides) {
|
|
3241
|
+
await this.packagesDeletePackageRaw(requestParameters, initOverrides);
|
|
3242
|
+
}
|
|
3243
|
+
async packagesDeleteVersionRaw(requestParameters, initOverrides) {
|
|
3244
|
+
if (requestParameters["packageVersionKey"] == null) {
|
|
3245
|
+
throw new RequiredError("packageVersionKey", 'Required parameter "packageVersionKey" was null or undefined when calling packagesDeleteVersion().');
|
|
3246
|
+
}
|
|
3247
|
+
const queryParameters = {};
|
|
3248
|
+
const headerParameters = {};
|
|
3249
|
+
if (requestParameters["xUipathAsVersion"] != null) {
|
|
3250
|
+
headerParameters["x-uipath-as-version"] = String(requestParameters["xUipathAsVersion"]);
|
|
3251
|
+
}
|
|
3252
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
3253
|
+
const token = this.configuration.accessToken;
|
|
3254
|
+
const tokenString = await token("Bearer", []);
|
|
3255
|
+
if (tokenString) {
|
|
3256
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3259
|
+
let urlPath = `/api/packages/versions/{packageVersionKey}`;
|
|
3260
|
+
urlPath = urlPath.replace(`{${"packageVersionKey"}}`, encodeURIComponent(String(requestParameters["packageVersionKey"])));
|
|
3261
|
+
const response = await this.request({
|
|
3262
|
+
path: urlPath,
|
|
3263
|
+
method: "DELETE",
|
|
3264
|
+
headers: headerParameters,
|
|
3265
|
+
query: queryParameters
|
|
3266
|
+
}, initOverrides);
|
|
3267
|
+
return new VoidApiResponse(response);
|
|
3268
|
+
}
|
|
3269
|
+
async packagesDeleteVersion(requestParameters, initOverrides) {
|
|
3270
|
+
await this.packagesDeleteVersionRaw(requestParameters, initOverrides);
|
|
3271
|
+
}
|
|
3272
|
+
async packagesDownloadRaw(requestParameters, initOverrides) {
|
|
3273
|
+
if (requestParameters["packageVersionKey"] == null) {
|
|
3274
|
+
throw new RequiredError("packageVersionKey", 'Required parameter "packageVersionKey" was null or undefined when calling packagesDownload().');
|
|
3275
|
+
}
|
|
3276
|
+
const queryParameters = {};
|
|
3277
|
+
const headerParameters = {};
|
|
3278
|
+
if (requestParameters["xUipathAsVersion"] != null) {
|
|
3279
|
+
headerParameters["x-uipath-as-version"] = String(requestParameters["xUipathAsVersion"]);
|
|
3280
|
+
}
|
|
3281
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
3282
|
+
const token = this.configuration.accessToken;
|
|
3283
|
+
const tokenString = await token("Bearer", []);
|
|
3284
|
+
if (tokenString) {
|
|
3285
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
3286
|
+
}
|
|
3287
|
+
}
|
|
3288
|
+
let urlPath = `/api/packages/{packageVersionKey}/download`;
|
|
3289
|
+
urlPath = urlPath.replace(`{${"packageVersionKey"}}`, encodeURIComponent(String(requestParameters["packageVersionKey"])));
|
|
3290
|
+
const response = await this.request({
|
|
3291
|
+
path: urlPath,
|
|
3292
|
+
method: "GET",
|
|
3293
|
+
headers: headerParameters,
|
|
3294
|
+
query: queryParameters
|
|
3295
|
+
}, initOverrides);
|
|
3296
|
+
return new JSONApiResponse(response, (jsonValue) => BlobFileAccessDtoFromJSON(jsonValue));
|
|
3297
|
+
}
|
|
3298
|
+
async packagesDownload(requestParameters, initOverrides) {
|
|
3299
|
+
const response = await this.packagesDownloadRaw(requestParameters, initOverrides);
|
|
3300
|
+
return await response.value();
|
|
3301
|
+
}
|
|
3302
|
+
async packagesGetPackageRaw(requestParameters, initOverrides) {
|
|
3303
|
+
if (requestParameters["packageKey"] == null) {
|
|
3304
|
+
throw new RequiredError("packageKey", 'Required parameter "packageKey" was null or undefined when calling packagesGetPackage().');
|
|
3305
|
+
}
|
|
3306
|
+
const queryParameters = {};
|
|
3307
|
+
const headerParameters = {};
|
|
3308
|
+
if (requestParameters["xUipathAsVersion"] != null) {
|
|
3309
|
+
headerParameters["x-uipath-as-version"] = String(requestParameters["xUipathAsVersion"]);
|
|
3310
|
+
}
|
|
3311
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
3312
|
+
const token = this.configuration.accessToken;
|
|
3313
|
+
const tokenString = await token("Bearer", []);
|
|
3314
|
+
if (tokenString) {
|
|
3315
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
3318
|
+
let urlPath = `/api/packages/{packageKey}`;
|
|
3319
|
+
urlPath = urlPath.replace(`{${"packageKey"}}`, encodeURIComponent(String(requestParameters["packageKey"])));
|
|
3320
|
+
const response = await this.request({
|
|
3321
|
+
path: urlPath,
|
|
3322
|
+
method: "GET",
|
|
3323
|
+
headers: headerParameters,
|
|
3324
|
+
query: queryParameters
|
|
3325
|
+
}, initOverrides);
|
|
3326
|
+
return new JSONApiResponse(response, (jsonValue) => PackageInfoFromJSON(jsonValue));
|
|
3327
|
+
}
|
|
3328
|
+
async packagesGetPackage(requestParameters, initOverrides) {
|
|
3329
|
+
const response = await this.packagesGetPackageRaw(requestParameters, initOverrides);
|
|
3330
|
+
return await response.value();
|
|
3331
|
+
}
|
|
3332
|
+
async packagesGetPublishLocationsRaw(requestParameters, initOverrides) {
|
|
3333
|
+
const queryParameters = {};
|
|
3334
|
+
const headerParameters = {};
|
|
3335
|
+
if (requestParameters["xUipathAsVersion"] != null) {
|
|
3336
|
+
headerParameters["x-uipath-as-version"] = String(requestParameters["xUipathAsVersion"]);
|
|
3337
|
+
}
|
|
3338
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
3339
|
+
const token = this.configuration.accessToken;
|
|
3340
|
+
const tokenString = await token("Bearer", []);
|
|
3341
|
+
if (tokenString) {
|
|
3342
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
3343
|
+
}
|
|
3344
|
+
}
|
|
3345
|
+
let urlPath = `/api/packages/publish-locations`;
|
|
3346
|
+
const response = await this.request({
|
|
3347
|
+
path: urlPath,
|
|
3348
|
+
method: "GET",
|
|
3349
|
+
headers: headerParameters,
|
|
3350
|
+
query: queryParameters
|
|
3351
|
+
}, initOverrides);
|
|
3352
|
+
return new JSONApiResponse(response, (jsonValue) => jsonValue.map(LocationDtoFromJSON));
|
|
3353
|
+
}
|
|
3354
|
+
async packagesGetPublishLocations(requestParameters = {}, initOverrides) {
|
|
3355
|
+
const response = await this.packagesGetPublishLocationsRaw(requestParameters, initOverrides);
|
|
3356
|
+
return await response.value();
|
|
3357
|
+
}
|
|
3358
|
+
async packagesGetVersionRaw(requestParameters, initOverrides) {
|
|
3359
|
+
if (requestParameters["packageVersionKey"] == null) {
|
|
3360
|
+
throw new RequiredError("packageVersionKey", 'Required parameter "packageVersionKey" was null or undefined when calling packagesGetVersion().');
|
|
3361
|
+
}
|
|
3362
|
+
const queryParameters = {};
|
|
3363
|
+
const headerParameters = {};
|
|
3364
|
+
if (requestParameters["xUipathAsVersion"] != null) {
|
|
3365
|
+
headerParameters["x-uipath-as-version"] = String(requestParameters["xUipathAsVersion"]);
|
|
3366
|
+
}
|
|
3367
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
3368
|
+
const token = this.configuration.accessToken;
|
|
3369
|
+
const tokenString = await token("Bearer", []);
|
|
3370
|
+
if (tokenString) {
|
|
3371
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
3372
|
+
}
|
|
3373
|
+
}
|
|
3374
|
+
let urlPath = `/api/packages/versions/{packageVersionKey}`;
|
|
3375
|
+
urlPath = urlPath.replace(`{${"packageVersionKey"}}`, encodeURIComponent(String(requestParameters["packageVersionKey"])));
|
|
3376
|
+
const response = await this.request({
|
|
3377
|
+
path: urlPath,
|
|
3378
|
+
method: "GET",
|
|
3379
|
+
headers: headerParameters,
|
|
3380
|
+
query: queryParameters
|
|
3381
|
+
}, initOverrides);
|
|
3382
|
+
return new JSONApiResponse(response, (jsonValue) => PackageVersionInfoDtoFromJSON(jsonValue));
|
|
3383
|
+
}
|
|
3384
|
+
async packagesGetVersion(requestParameters, initOverrides) {
|
|
3385
|
+
const response = await this.packagesGetVersionRaw(requestParameters, initOverrides);
|
|
3386
|
+
return await response.value();
|
|
3387
|
+
}
|
|
3388
|
+
async packagesUploadRaw(requestParameters, initOverrides) {
|
|
3389
|
+
const queryParameters = {};
|
|
3390
|
+
if (requestParameters["locationKey"] != null) {
|
|
3391
|
+
queryParameters["locationKey"] = requestParameters["locationKey"];
|
|
3392
|
+
}
|
|
3393
|
+
const headerParameters = {};
|
|
3394
|
+
headerParameters["Content-Type"] = "application/zip";
|
|
3395
|
+
if (requestParameters["xUipathAsVersion"] != null) {
|
|
3396
|
+
headerParameters["x-uipath-as-version"] = String(requestParameters["xUipathAsVersion"]);
|
|
3397
|
+
}
|
|
3398
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
3399
|
+
const token = this.configuration.accessToken;
|
|
3400
|
+
const tokenString = await token("Bearer", []);
|
|
3401
|
+
if (tokenString) {
|
|
3402
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
3403
|
+
}
|
|
3404
|
+
}
|
|
3405
|
+
let urlPath = `/api/packages/upload`;
|
|
3406
|
+
const response = await this.request({
|
|
3407
|
+
path: urlPath,
|
|
3408
|
+
method: "POST",
|
|
3409
|
+
headers: headerParameters,
|
|
3410
|
+
query: queryParameters,
|
|
3411
|
+
body: requestParameters["body"]
|
|
3412
|
+
}, initOverrides);
|
|
3413
|
+
if (this.isJsonMime(response.headers.get("content-type"))) {
|
|
3414
|
+
return new JSONApiResponse(response);
|
|
3415
|
+
} else {
|
|
3416
|
+
return new TextApiResponse(response);
|
|
3417
|
+
}
|
|
3418
|
+
}
|
|
3419
|
+
async packagesUpload(requestParameters = {}, initOverrides) {
|
|
3420
|
+
const response = await this.packagesUploadRaw(requestParameters, initOverrides);
|
|
3421
|
+
return await response.value();
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
3424
|
+
// ../solution-sdk/package.json
|
|
3425
|
+
var package_default = {
|
|
3426
|
+
name: "@uipath/solution-sdk",
|
|
3427
|
+
license: "MIT",
|
|
3428
|
+
version: "1.201.0-preview.121",
|
|
3429
|
+
repository: {
|
|
3430
|
+
type: "git",
|
|
3431
|
+
url: "https://github.com/UiPath/cli.git",
|
|
3432
|
+
directory: "packages/solution-sdk"
|
|
3433
|
+
},
|
|
3434
|
+
publishConfig: {
|
|
3435
|
+
registry: "https://npm.pkg.github.com/@uipath"
|
|
3436
|
+
},
|
|
3437
|
+
keywords: [
|
|
3438
|
+
"uipath",
|
|
3439
|
+
"solution",
|
|
3440
|
+
"sdk"
|
|
3441
|
+
],
|
|
3442
|
+
type: "module",
|
|
3443
|
+
main: "./dist/index.js",
|
|
3444
|
+
types: "./dist/src/index.d.ts",
|
|
3445
|
+
exports: {
|
|
3446
|
+
".": {
|
|
3447
|
+
types: "./dist/src/index.d.ts",
|
|
3448
|
+
default: "./dist/index.js"
|
|
3449
|
+
},
|
|
3450
|
+
"./resources": {
|
|
3451
|
+
types: "./dist/src/resources/index.d.ts",
|
|
3452
|
+
default: "./dist/resources/index.js"
|
|
3453
|
+
},
|
|
3454
|
+
"./auth": {
|
|
3455
|
+
types: "./dist/src/solution-auth.d.ts",
|
|
3456
|
+
default: "./dist/solution-auth.js"
|
|
3457
|
+
}
|
|
3458
|
+
},
|
|
3459
|
+
bin: {
|
|
3460
|
+
"generate-sdk": "./dist/scripts/generate-sdk.js"
|
|
3461
|
+
},
|
|
3462
|
+
files: [
|
|
3463
|
+
"dist"
|
|
3464
|
+
],
|
|
3465
|
+
private: false,
|
|
3466
|
+
scripts: {
|
|
3467
|
+
build: "bun build ./src/index.ts ./src/resources/index.ts ./src/solution-auth.ts --outdir dist --format esm --target node --sourcemap=linked && bun build ./src/scripts/generate-sdk.ts --outdir dist/scripts --format esm --target node --sourcemap=linked && tsc -p tsconfig.build.json --noCheck",
|
|
3468
|
+
generate: "bun run src/scripts/generate-sdk.ts",
|
|
3469
|
+
lint: "biome check .",
|
|
3470
|
+
test: "vitest run",
|
|
3471
|
+
"test:coverage": "vitest run --coverage"
|
|
3472
|
+
},
|
|
3473
|
+
devDependencies: {
|
|
3474
|
+
"@openapitools/openapi-generator-cli": "^2.31.1",
|
|
3475
|
+
"@uipath/auth": "workspace:*",
|
|
3476
|
+
"@uipath/common": "workspace:*",
|
|
3477
|
+
"@uipath/filesystem": "workspace:*",
|
|
3478
|
+
"@uipath/orchestrator-sdk": "workspace:*",
|
|
3479
|
+
"@uipath/resource-builder-sdk": "^2025.11.0-alpha4202-3459",
|
|
3480
|
+
"@uipath/solutionpackager-tool-core": "workspace:*",
|
|
3481
|
+
"@uipath/studioweb-sdk": "workspace:*",
|
|
3482
|
+
"@types/node": "^25.5.2",
|
|
3483
|
+
fflate: "^0.8.2",
|
|
3484
|
+
typescript: "^7.0.2"
|
|
3485
|
+
}
|
|
3486
|
+
};
|
|
3487
|
+
|
|
3488
|
+
// ../solution-sdk/src/user-agent.ts
|
|
3489
|
+
var SDK_USER_AGENT = getSdkUserAgentToken(package_default);
|
|
3490
|
+
installSdkUserAgentHeader(BaseAPI, SDK_USER_AGENT);
|
|
3491
|
+
|
|
3492
|
+
// ../studioweb-sdk/generated/src/runtime.ts
|
|
3493
|
+
var BASE_PATH2 = "https://alpha.uipath.com/studio_/backend".replace(/\/+$/, "");
|
|
3494
|
+
|
|
3495
|
+
class Configuration2 {
|
|
3496
|
+
configuration;
|
|
3497
|
+
constructor(configuration = {}) {
|
|
3498
|
+
this.configuration = configuration;
|
|
3499
|
+
}
|
|
3500
|
+
set config(configuration) {
|
|
3501
|
+
this.configuration = configuration;
|
|
3502
|
+
}
|
|
3503
|
+
get basePath() {
|
|
3504
|
+
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH2;
|
|
3505
|
+
}
|
|
3506
|
+
get fetchApi() {
|
|
3507
|
+
return this.configuration.fetchApi;
|
|
3508
|
+
}
|
|
3509
|
+
get middleware() {
|
|
3510
|
+
return this.configuration.middleware || [];
|
|
3511
|
+
}
|
|
3512
|
+
get queryParamsStringify() {
|
|
3513
|
+
return this.configuration.queryParamsStringify || querystring2;
|
|
3514
|
+
}
|
|
3515
|
+
get username() {
|
|
3516
|
+
return this.configuration.username;
|
|
3517
|
+
}
|
|
3518
|
+
get password() {
|
|
3519
|
+
return this.configuration.password;
|
|
3520
|
+
}
|
|
3521
|
+
get apiKey() {
|
|
3522
|
+
const apiKey = this.configuration.apiKey;
|
|
3523
|
+
if (apiKey) {
|
|
3524
|
+
return typeof apiKey === "function" ? apiKey : () => apiKey;
|
|
3525
|
+
}
|
|
3526
|
+
return;
|
|
3527
|
+
}
|
|
3528
|
+
get accessToken() {
|
|
3529
|
+
const accessToken = this.configuration.accessToken;
|
|
3530
|
+
if (accessToken) {
|
|
3531
|
+
return typeof accessToken === "function" ? accessToken : async () => accessToken;
|
|
3532
|
+
}
|
|
3533
|
+
return;
|
|
3534
|
+
}
|
|
3535
|
+
get headers() {
|
|
3536
|
+
return this.configuration.headers;
|
|
3537
|
+
}
|
|
3538
|
+
get credentials() {
|
|
3539
|
+
return this.configuration.credentials;
|
|
3540
|
+
}
|
|
3541
|
+
}
|
|
3542
|
+
var DefaultConfig2 = new Configuration2;
|
|
3543
|
+
|
|
3544
|
+
class BaseAPI2 {
|
|
3545
|
+
configuration;
|
|
3546
|
+
static jsonRegex = new RegExp("^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$", "i");
|
|
3547
|
+
middleware;
|
|
3548
|
+
constructor(configuration = DefaultConfig2) {
|
|
3549
|
+
this.configuration = configuration;
|
|
3550
|
+
this.middleware = configuration.middleware;
|
|
3551
|
+
}
|
|
3552
|
+
withMiddleware(...middlewares) {
|
|
3553
|
+
const next = this.clone();
|
|
3554
|
+
next.middleware = next.middleware.concat(...middlewares);
|
|
3555
|
+
return next;
|
|
3556
|
+
}
|
|
3557
|
+
withPreMiddleware(...preMiddlewares) {
|
|
3558
|
+
const middlewares = preMiddlewares.map((pre) => ({ pre }));
|
|
3559
|
+
return this.withMiddleware(...middlewares);
|
|
3560
|
+
}
|
|
3561
|
+
withPostMiddleware(...postMiddlewares) {
|
|
3562
|
+
const middlewares = postMiddlewares.map((post) => ({ post }));
|
|
3563
|
+
return this.withMiddleware(...middlewares);
|
|
3564
|
+
}
|
|
3565
|
+
isJsonMime(mime) {
|
|
3566
|
+
if (!mime) {
|
|
3567
|
+
return false;
|
|
3568
|
+
}
|
|
3569
|
+
return BaseAPI2.jsonRegex.test(mime);
|
|
3570
|
+
}
|
|
3571
|
+
async request(context, initOverrides) {
|
|
3572
|
+
const { url, init } = await this.createFetchParams(context, initOverrides);
|
|
3573
|
+
const response = await this.fetchApi(url, init);
|
|
3574
|
+
if (response && (response.status >= 200 && response.status < 300)) {
|
|
3575
|
+
return response;
|
|
3576
|
+
}
|
|
3577
|
+
throw new ResponseError2(response, "Response returned an error code");
|
|
3578
|
+
}
|
|
3579
|
+
async createFetchParams(context, initOverrides) {
|
|
3580
|
+
let url = this.configuration.basePath + context.path;
|
|
3581
|
+
if (context.query !== undefined && Object.keys(context.query).length !== 0) {
|
|
3582
|
+
url += "?" + this.configuration.queryParamsStringify(context.query);
|
|
3583
|
+
}
|
|
3584
|
+
const headers = Object.assign({}, this.configuration.headers, context.headers);
|
|
3585
|
+
Object.keys(headers).forEach((key) => headers[key] === undefined ? delete headers[key] : {});
|
|
3586
|
+
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : async () => initOverrides;
|
|
3587
|
+
const initParams = {
|
|
3588
|
+
method: context.method,
|
|
3589
|
+
headers,
|
|
3590
|
+
body: context.body,
|
|
3591
|
+
credentials: this.configuration.credentials
|
|
3592
|
+
};
|
|
3593
|
+
const overriddenInit = {
|
|
3594
|
+
...initParams,
|
|
3595
|
+
...await initOverrideFn({
|
|
3596
|
+
init: initParams,
|
|
3597
|
+
context
|
|
3598
|
+
})
|
|
3599
|
+
};
|
|
3600
|
+
let body;
|
|
3601
|
+
if (isFormData2(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob2(overriddenInit.body)) {
|
|
3602
|
+
body = overriddenInit.body;
|
|
3603
|
+
} else if (this.isJsonMime(headers["Content-Type"])) {
|
|
3604
|
+
body = JSON.stringify(overriddenInit.body);
|
|
3605
|
+
} else {
|
|
3606
|
+
body = overriddenInit.body;
|
|
3607
|
+
}
|
|
3608
|
+
const init = {
|
|
3609
|
+
...overriddenInit,
|
|
3610
|
+
body
|
|
3611
|
+
};
|
|
3612
|
+
return { url, init };
|
|
3613
|
+
}
|
|
3614
|
+
fetchApi = async (url, init) => {
|
|
3615
|
+
let fetchParams = { url, init };
|
|
3616
|
+
for (const middleware of this.middleware) {
|
|
3617
|
+
if (middleware.pre) {
|
|
3618
|
+
fetchParams = await middleware.pre({
|
|
3619
|
+
fetch: this.fetchApi,
|
|
3620
|
+
...fetchParams
|
|
3621
|
+
}) || fetchParams;
|
|
3622
|
+
}
|
|
3623
|
+
}
|
|
3624
|
+
let response = undefined;
|
|
3625
|
+
try {
|
|
3626
|
+
response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
|
|
3627
|
+
} catch (e) {
|
|
3628
|
+
for (const middleware of this.middleware) {
|
|
3629
|
+
if (middleware.onError) {
|
|
3630
|
+
response = await middleware.onError({
|
|
3631
|
+
fetch: this.fetchApi,
|
|
3632
|
+
url: fetchParams.url,
|
|
3633
|
+
init: fetchParams.init,
|
|
3634
|
+
error: e,
|
|
3635
|
+
response: response ? response.clone() : undefined
|
|
3636
|
+
}) || response;
|
|
3637
|
+
}
|
|
3638
|
+
}
|
|
3639
|
+
if (response === undefined) {
|
|
3640
|
+
if (e instanceof Error) {
|
|
3641
|
+
throw new FetchError2(e, "The request failed and the interceptors did not return an alternative response");
|
|
3642
|
+
} else {
|
|
3643
|
+
throw e;
|
|
3644
|
+
}
|
|
3645
|
+
}
|
|
3646
|
+
}
|
|
3647
|
+
for (const middleware of this.middleware) {
|
|
3648
|
+
if (middleware.post) {
|
|
3649
|
+
response = await middleware.post({
|
|
3650
|
+
fetch: this.fetchApi,
|
|
3651
|
+
url: fetchParams.url,
|
|
3652
|
+
init: fetchParams.init,
|
|
3653
|
+
response: response.clone()
|
|
3654
|
+
}) || response;
|
|
3655
|
+
}
|
|
3656
|
+
}
|
|
3657
|
+
return response;
|
|
3658
|
+
};
|
|
3659
|
+
clone() {
|
|
3660
|
+
const constructor = this.constructor;
|
|
3661
|
+
const next = new constructor(this.configuration);
|
|
3662
|
+
next.middleware = this.middleware.slice();
|
|
3663
|
+
return next;
|
|
3664
|
+
}
|
|
3665
|
+
}
|
|
3666
|
+
function isBlob2(value) {
|
|
3667
|
+
return typeof Blob !== "undefined" && value instanceof Blob;
|
|
3668
|
+
}
|
|
3669
|
+
function isFormData2(value) {
|
|
3670
|
+
return typeof FormData !== "undefined" && value instanceof FormData;
|
|
3671
|
+
}
|
|
3672
|
+
|
|
3673
|
+
class ResponseError2 extends Error {
|
|
3674
|
+
response;
|
|
3675
|
+
name = "ResponseError";
|
|
3676
|
+
constructor(response, msg) {
|
|
3677
|
+
super(msg);
|
|
3678
|
+
this.response = response;
|
|
3679
|
+
}
|
|
3680
|
+
}
|
|
3681
|
+
|
|
3682
|
+
class FetchError2 extends Error {
|
|
3683
|
+
cause;
|
|
3684
|
+
name = "FetchError";
|
|
3685
|
+
constructor(cause, msg) {
|
|
3686
|
+
super(msg);
|
|
3687
|
+
this.cause = cause;
|
|
3688
|
+
}
|
|
3689
|
+
}
|
|
3690
|
+
function querystring2(params, prefix = "") {
|
|
3691
|
+
return Object.keys(params).map((key) => querystringSingleKey2(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
|
|
3692
|
+
}
|
|
3693
|
+
function querystringSingleKey2(key, value, keyPrefix = "") {
|
|
3694
|
+
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
|
|
3695
|
+
if (value instanceof Array) {
|
|
3696
|
+
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
|
|
3697
|
+
return `${encodeURIComponent(fullKey)}=${multiValue}`;
|
|
3698
|
+
}
|
|
3699
|
+
if (value instanceof Set) {
|
|
3700
|
+
const valueAsArray = Array.from(value);
|
|
3701
|
+
return querystringSingleKey2(key, valueAsArray, keyPrefix);
|
|
3702
|
+
}
|
|
3703
|
+
if (value instanceof Date) {
|
|
3704
|
+
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
|
|
3705
|
+
}
|
|
3706
|
+
if (value instanceof Object) {
|
|
3707
|
+
return querystring2(value, fullKey);
|
|
3708
|
+
}
|
|
3709
|
+
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
|
|
3710
|
+
}
|
|
3711
|
+
// ../solution-sdk/src/zip-utils.ts
|
|
3712
|
+
var DEFAULT_EXCLUDED_DIR_NAMES = new Set([
|
|
3713
|
+
".venv",
|
|
3714
|
+
"node_modules",
|
|
3715
|
+
"__pycache__",
|
|
3716
|
+
".git"
|
|
3717
|
+
]);
|
|
3718
|
+
var DEFAULT_EXCLUDED_FILE_PATTERNS = [
|
|
3719
|
+
/^\.env($|\..+)/
|
|
3720
|
+
];
|
|
3721
|
+
function isDefaultExcludedFileName(name) {
|
|
3722
|
+
for (const pattern of DEFAULT_EXCLUDED_FILE_PATTERNS) {
|
|
3723
|
+
if (pattern.test(name)) {
|
|
3724
|
+
return true;
|
|
3725
|
+
}
|
|
3726
|
+
}
|
|
3727
|
+
return false;
|
|
3728
|
+
}
|
|
3729
|
+
var UIPIGNORE_FILENAME = ".uipignore";
|
|
3730
|
+
function parseUipignore(body) {
|
|
3731
|
+
const names = new Set;
|
|
3732
|
+
for (const rawLine of body.split(/\r?\n/)) {
|
|
3733
|
+
const line = rawLine.split("#")[0]?.trim();
|
|
3734
|
+
if (!line) {
|
|
3735
|
+
continue;
|
|
3736
|
+
}
|
|
3737
|
+
if (line.includes("/") || line.includes("\\")) {
|
|
3738
|
+
continue;
|
|
3739
|
+
}
|
|
3740
|
+
names.add(line);
|
|
3741
|
+
}
|
|
3742
|
+
return names;
|
|
3743
|
+
}
|
|
3744
|
+
async function collectTree(fs, dir, options = {}) {
|
|
3745
|
+
const files = [];
|
|
3746
|
+
const emptyDirs = [];
|
|
3747
|
+
const excluded = new Set(DEFAULT_EXCLUDED_DIR_NAMES);
|
|
3748
|
+
if (options.additionalExcludeDirs) {
|
|
3749
|
+
for (const name of options.additionalExcludeDirs) {
|
|
3750
|
+
excluded.add(name);
|
|
3751
|
+
}
|
|
3752
|
+
}
|
|
3753
|
+
async function walk(current, isRoot) {
|
|
3754
|
+
const entries = await fs.readdir(current);
|
|
3755
|
+
if (entries.length === 0) {
|
|
3756
|
+
if (!isRoot) {
|
|
3757
|
+
emptyDirs.push(current);
|
|
3758
|
+
}
|
|
3759
|
+
return;
|
|
3760
|
+
}
|
|
3761
|
+
for (const entryName of entries) {
|
|
3762
|
+
const fullPath = fs.path.join(current, entryName);
|
|
3763
|
+
const entryStat = await fs.stat(fullPath);
|
|
3764
|
+
if (entryStat?.isDirectory()) {
|
|
3765
|
+
if (excluded.has(entryName)) {
|
|
3766
|
+
continue;
|
|
3767
|
+
}
|
|
3768
|
+
await walk(fullPath, false);
|
|
3769
|
+
} else if (entryStat?.isFile()) {
|
|
3770
|
+
if (isDefaultExcludedFileName(entryName)) {
|
|
3771
|
+
continue;
|
|
3772
|
+
}
|
|
3773
|
+
files.push(fullPath);
|
|
3774
|
+
}
|
|
3775
|
+
}
|
|
3776
|
+
}
|
|
3777
|
+
await walk(dir, true);
|
|
3778
|
+
return { files, emptyDirs };
|
|
3779
|
+
}
|
|
3780
|
+
async function createZipFromDir(fs, dir, options = {}) {
|
|
3781
|
+
const { files, emptyDirs } = await collectTree(fs, dir, options);
|
|
3782
|
+
const zippable = {};
|
|
3783
|
+
for (const filePath of files) {
|
|
3784
|
+
const relPath = fs.path.relative(dir, filePath).replace(/\\/g, "/");
|
|
3785
|
+
const data = await fs.readFile(filePath);
|
|
3786
|
+
if (data) {
|
|
3787
|
+
zippable[relPath] = new Uint8Array(data);
|
|
3788
|
+
}
|
|
3789
|
+
}
|
|
3790
|
+
for (const emptyDir of emptyDirs) {
|
|
3791
|
+
const relPath = fs.path.relative(dir, emptyDir).replace(/\\/g, "/");
|
|
3792
|
+
if (!relPath) {
|
|
3793
|
+
continue;
|
|
3794
|
+
}
|
|
3795
|
+
zippable[`${relPath}/`] = new Uint8Array(0);
|
|
3796
|
+
}
|
|
3797
|
+
return zipSync(zippable, { level: 6 });
|
|
3798
|
+
}
|
|
3799
|
+
|
|
3800
|
+
// ../solution-sdk/src/bundle-service.ts
|
|
3801
|
+
async function readUipignore(fs, dir) {
|
|
3802
|
+
const ignorePath = fs.path.join(dir, UIPIGNORE_FILENAME);
|
|
3803
|
+
if (!await fs.exists(ignorePath)) {
|
|
3804
|
+
return new Set;
|
|
3805
|
+
}
|
|
3806
|
+
try {
|
|
3807
|
+
const body = await fs.readFile(ignorePath, "utf-8");
|
|
3808
|
+
if (!body) {
|
|
3809
|
+
return new Set;
|
|
3810
|
+
}
|
|
3811
|
+
return parseUipignore(body);
|
|
3812
|
+
} catch (err) {
|
|
3813
|
+
logger.warn(`Could not read ${UIPIGNORE_FILENAME}; ignoring it: ${String(err)}`);
|
|
3814
|
+
return new Set;
|
|
3815
|
+
}
|
|
3816
|
+
}
|
|
3817
|
+
async function mergeProjectUipignore(fs, projectPath, projectLabel, solutionExcludeDirs) {
|
|
3818
|
+
const projectExtra = await readUipignore(fs, projectPath);
|
|
3819
|
+
if (projectExtra.size === 0) {
|
|
3820
|
+
return solutionExcludeDirs;
|
|
3821
|
+
}
|
|
3822
|
+
const merged = new Set(solutionExcludeDirs);
|
|
3823
|
+
for (const name of projectExtra) {
|
|
3824
|
+
merged.add(name);
|
|
3825
|
+
}
|
|
3826
|
+
logger.info(`[${projectLabel}] Applying ${projectExtra.size} extra exclude(s) from project ${UIPIGNORE_FILENAME}: ${[...projectExtra].join(", ")}`);
|
|
3827
|
+
return merged;
|
|
3828
|
+
}
|
|
3829
|
+
var toForwardSlash = (p) => p.replace(/\\/g, "/");
|
|
3830
|
+
async function mirrorTree(fs, srcDir, relativeBase, destBaseDir, additionalExcludeDirs) {
|
|
3831
|
+
const { files, emptyDirs } = await collectTree(fs, srcDir, {
|
|
3832
|
+
additionalExcludeDirs
|
|
3833
|
+
});
|
|
3834
|
+
if (files.length === 0 && emptyDirs.length === 0) {
|
|
3835
|
+
const rootRel = fs.path.relative(relativeBase, srcDir);
|
|
3836
|
+
if (rootRel) {
|
|
3837
|
+
await fs.mkdir(fs.path.join(destBaseDir, rootRel));
|
|
3838
|
+
}
|
|
3839
|
+
return;
|
|
3840
|
+
}
|
|
3841
|
+
for (const f of files) {
|
|
3842
|
+
const relPath = fs.path.relative(relativeBase, f);
|
|
3843
|
+
const destPath = fs.path.join(destBaseDir, relPath);
|
|
3844
|
+
const data = await fs.readFile(f);
|
|
3845
|
+
if (data) {
|
|
3846
|
+
await fs.writeFile(destPath, data);
|
|
3847
|
+
} else {
|
|
3848
|
+
logger.warn(`Skipping empty or unreadable file: ${f}`);
|
|
3849
|
+
}
|
|
3850
|
+
}
|
|
3851
|
+
for (const dir of emptyDirs) {
|
|
3852
|
+
const relPath = fs.path.relative(relativeBase, dir);
|
|
3853
|
+
if (!relPath) {
|
|
3854
|
+
continue;
|
|
3855
|
+
}
|
|
3856
|
+
await fs.mkdir(fs.path.join(destBaseDir, relPath));
|
|
3857
|
+
}
|
|
3858
|
+
}
|
|
3859
|
+
async function flattenProjectDir(fs, srcProjectDir, destProjectDir, additionalExcludeDirs) {
|
|
3860
|
+
await fs.mkdir(destProjectDir);
|
|
3861
|
+
const topLevelExclude = new Set(DEFAULT_EXCLUDED_DIR_NAMES);
|
|
3862
|
+
if (additionalExcludeDirs) {
|
|
3863
|
+
for (const name of additionalExcludeDirs) {
|
|
3864
|
+
topLevelExclude.add(name);
|
|
3865
|
+
}
|
|
3866
|
+
}
|
|
3867
|
+
const entries = await fs.readdir(srcProjectDir);
|
|
3868
|
+
for (const entryName of entries) {
|
|
3869
|
+
const srcPath = fs.path.join(srcProjectDir, entryName);
|
|
3870
|
+
const entryStat = await fs.stat(srcPath);
|
|
3871
|
+
if (!entryStat) {
|
|
3872
|
+
continue;
|
|
3873
|
+
}
|
|
3874
|
+
if (entryStat.isFile()) {
|
|
3875
|
+
if (isDefaultExcludedFileName(entryName)) {
|
|
3876
|
+
continue;
|
|
3877
|
+
}
|
|
3878
|
+
const data = await fs.readFile(srcPath);
|
|
3879
|
+
if (data) {
|
|
3880
|
+
await fs.writeFile(fs.path.join(destProjectDir, entryName), data);
|
|
3881
|
+
}
|
|
3882
|
+
} else if (entryStat.isDirectory()) {
|
|
3883
|
+
if (topLevelExclude.has(entryName)) {
|
|
3884
|
+
continue;
|
|
3885
|
+
}
|
|
3886
|
+
if (entryName === "content" || entryName === "flow_files") {
|
|
3887
|
+
await mirrorTree(fs, srcPath, srcPath, destProjectDir, additionalExcludeDirs);
|
|
3888
|
+
} else {
|
|
3889
|
+
await mirrorTree(fs, srcPath, srcProjectDir, destProjectDir, additionalExcludeDirs);
|
|
3890
|
+
}
|
|
3891
|
+
}
|
|
3892
|
+
}
|
|
3893
|
+
}
|
|
3894
|
+
async function bundleSolution(fs, solutionDir, outputDir, outputName) {
|
|
3895
|
+
const resolvedPath = fs.path.resolve(solutionDir);
|
|
3896
|
+
const solStat = await fs.stat(resolvedPath);
|
|
3897
|
+
if (!solStat) {
|
|
3898
|
+
throw new Error(`Path not found: ${resolvedPath}`);
|
|
3899
|
+
}
|
|
3900
|
+
if (!solStat.isDirectory()) {
|
|
3901
|
+
throw new Error(`Not a directory: ${resolvedPath}. Provide the solution directory containing a .uipx file.`);
|
|
3902
|
+
}
|
|
3903
|
+
const { uipx, uipxFileName } = await readUipxFile(fs, resolvedPath);
|
|
3904
|
+
const additionalExcludeDirs = await readUipignore(fs, resolvedPath);
|
|
3905
|
+
if (additionalExcludeDirs.size > 0) {
|
|
3906
|
+
logger.info(`Applying ${additionalExcludeDirs.size} extra exclude(s) from .uipignore: ${[...additionalExcludeDirs].join(", ")}`);
|
|
3907
|
+
}
|
|
3908
|
+
const effectiveExclude = new Set(DEFAULT_EXCLUDED_DIR_NAMES);
|
|
3909
|
+
for (const name of additionalExcludeDirs) {
|
|
3910
|
+
effectiveExclude.add(name);
|
|
3911
|
+
}
|
|
3912
|
+
for (const project of uipx.Projects) {
|
|
3913
|
+
project.ProjectRelativePath = toForwardSlash(project.ProjectRelativePath);
|
|
3914
|
+
}
|
|
3915
|
+
const solutionStorage = {
|
|
3916
|
+
SolutionId: uipx.SolutionId,
|
|
3917
|
+
Projects: uipx.Projects.map((p) => ({
|
|
3918
|
+
ProjectId: p.Id,
|
|
3919
|
+
ProjectRelativePath: p.ProjectRelativePath
|
|
3920
|
+
}))
|
|
3921
|
+
};
|
|
3922
|
+
const solutionName = outputName || fs.path.basename(uipxFileName, ".uipx");
|
|
3923
|
+
const stagingDir = fs.path.join(resolvedPath, `.uis-staging-${Date.now()}`);
|
|
3924
|
+
await fs.mkdir(stagingDir);
|
|
3925
|
+
try {
|
|
3926
|
+
await fs.writeFile(fs.path.join(stagingDir, "SolutionStorage.json"), JSON.stringify(solutionStorage));
|
|
3927
|
+
await fs.writeFile(fs.path.join(stagingDir, uipxFileName), JSON.stringify(uipx));
|
|
3928
|
+
for (const project of uipx.Projects) {
|
|
3929
|
+
const projectDir = fs.path.dirname(project.ProjectRelativePath);
|
|
3930
|
+
const srcProjectPath = fs.path.join(resolvedPath, projectDir);
|
|
3931
|
+
const projectStat = await fs.stat(srcProjectPath);
|
|
3932
|
+
if (!projectStat) {
|
|
3933
|
+
throw new Error(`Project directory not found: ${srcProjectPath}`);
|
|
3934
|
+
}
|
|
3935
|
+
const projectExcludeDirs = await mergeProjectUipignore(fs, srcProjectPath, projectDir, additionalExcludeDirs);
|
|
3936
|
+
await flattenProjectDir(fs, srcProjectPath, fs.path.join(stagingDir, projectDir), projectExcludeDirs);
|
|
3937
|
+
}
|
|
3938
|
+
const resourcesPath = fs.path.join(resolvedPath, "resources");
|
|
3939
|
+
if (!effectiveExclude.has("resources") && await fs.exists(resourcesPath)) {
|
|
3940
|
+
await mirrorTree(fs, resourcesPath, resolvedPath, stagingDir, additionalExcludeDirs);
|
|
3941
|
+
}
|
|
3942
|
+
const userProfilePath = fs.path.join(resolvedPath, "userProfile");
|
|
3943
|
+
if (!effectiveExclude.has("userProfile") && await fs.exists(userProfilePath)) {
|
|
3944
|
+
await mirrorTree(fs, userProfilePath, resolvedPath, stagingDir, additionalExcludeDirs);
|
|
3945
|
+
}
|
|
3946
|
+
const resolvedOutputDir = fs.path.resolve(outputDir);
|
|
3947
|
+
if (!await fs.exists(resolvedOutputDir)) {
|
|
3948
|
+
await fs.mkdir(resolvedOutputDir);
|
|
3949
|
+
}
|
|
3950
|
+
const uisPath = fs.path.join(resolvedOutputDir, `${solutionName}.uis`);
|
|
3951
|
+
const zipData = await createZipFromDir(fs, stagingDir);
|
|
3952
|
+
await fs.writeFile(uisPath, zipData);
|
|
3953
|
+
const uipxPath = fs.path.join(resolvedPath, uipxFileName);
|
|
3954
|
+
return {
|
|
3955
|
+
uisPath,
|
|
3956
|
+
solutionName,
|
|
3957
|
+
solutionId: uipx.SolutionId,
|
|
3958
|
+
uipxPath,
|
|
3959
|
+
projects: uipx.Projects.map((p) => ({
|
|
3960
|
+
Name: fs.path.dirname(p.ProjectRelativePath),
|
|
3961
|
+
Type: p.Type
|
|
3962
|
+
}))
|
|
3963
|
+
};
|
|
3964
|
+
} finally {
|
|
3965
|
+
await fs.rm(stagingDir);
|
|
3966
|
+
}
|
|
3967
|
+
}
|
|
3968
|
+
// ../solution-sdk/src/project-debug-status.ts
|
|
3969
|
+
var SUCCEEDED = "creationsucceeded";
|
|
3970
|
+
var TERMINAL = new Set([SUCCEEDED, "creationfailed", "validationfailed"]);
|
|
3971
|
+
// ../solution-sdk/src/upload-service.ts
|
|
3972
|
+
class HttpError extends Error {
|
|
3973
|
+
status;
|
|
3974
|
+
constructor(status, message) {
|
|
3975
|
+
super(message);
|
|
3976
|
+
this.status = status;
|
|
3977
|
+
}
|
|
3978
|
+
}
|
|
3979
|
+
var DEFAULT_UPLOAD_TIMEOUT_MS = 120000;
|
|
3980
|
+
function resolveUploadTimeoutMs() {
|
|
3981
|
+
const raw = Number(process.env?.UIPATH_SOLUTION_UPLOAD_TIMEOUT_MS);
|
|
3982
|
+
return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_UPLOAD_TIMEOUT_MS;
|
|
3983
|
+
}
|
|
3984
|
+
function formatTimeout(timeoutMs) {
|
|
3985
|
+
return timeoutMs < 1000 ? `${Math.round(timeoutMs)}ms` : `${Math.round(timeoutMs / 1000)}s`;
|
|
3986
|
+
}
|
|
3987
|
+
function timeoutMessage(what, timeoutMs) {
|
|
3988
|
+
return `${what} timed out after ${formatTimeout(timeoutMs)} — the connection ` + `stalled with no response from Studio Web. Retry the command; if it keeps ` + `timing out, check connectivity (VPN/proxy) to the tenant, or raise the ` + `ceiling with UIPATH_SOLUTION_UPLOAD_TIMEOUT_MS.`;
|
|
3989
|
+
}
|
|
3990
|
+
function isTimeoutError(error) {
|
|
3991
|
+
let current = error;
|
|
3992
|
+
for (let depth = 0;depth < 5 && current instanceof Error; depth += 1) {
|
|
3993
|
+
if (current.name === "TimeoutError")
|
|
3994
|
+
return true;
|
|
3995
|
+
current = current.cause;
|
|
3996
|
+
}
|
|
3997
|
+
return false;
|
|
3998
|
+
}
|
|
3999
|
+
async function fetchWithUploadTimeout(url, init, what) {
|
|
4000
|
+
const timeoutMs = resolveUploadTimeoutMs();
|
|
4001
|
+
const [error, response] = await catchError(fetch(url, { ...init, signal: AbortSignal.timeout(timeoutMs) }));
|
|
4002
|
+
if (error) {
|
|
4003
|
+
if (isTimeoutError(error)) {
|
|
4004
|
+
throw new Error(timeoutMessage(what, timeoutMs));
|
|
4005
|
+
}
|
|
4006
|
+
throw error;
|
|
4007
|
+
}
|
|
4008
|
+
return response;
|
|
4009
|
+
}
|
|
4010
|
+
async function importSolution(config, organizationName, fileBuffer, fileName) {
|
|
4011
|
+
const importUrl = `${config.baseUrl}/${organizationName}/studio_/backend/api/Solution/Import?desktopJit=true&useFileRest=true&enableUnifiedBuild=true`;
|
|
4012
|
+
const formData = new FormData;
|
|
4013
|
+
const fileBlob = new Blob([fileBuffer], {
|
|
4014
|
+
type: "application/octet-stream"
|
|
4015
|
+
});
|
|
4016
|
+
formData.append("uploadFile", fileBlob, fileName);
|
|
4017
|
+
formData.append("telemetryData", JSON.stringify({ FirstRun: false }));
|
|
4018
|
+
const headers = addSdkUserAgentHeader({
|
|
4019
|
+
Authorization: `Bearer ${config.authToken}`
|
|
4020
|
+
}, SDK_USER_AGENT);
|
|
4021
|
+
if (config.tenantId) {
|
|
4022
|
+
headers["x-uipath-tenantid"] = config.tenantId;
|
|
4023
|
+
}
|
|
4024
|
+
const response = await fetchWithUploadTimeout(importUrl, { method: "POST", headers, body: formData }, "Studio Web solution import");
|
|
4025
|
+
if (!response.ok) {
|
|
4026
|
+
const text = await response.text();
|
|
4027
|
+
throw new HttpError(response.status, `Import failed (${response.status}): ${text}`);
|
|
4028
|
+
}
|
|
4029
|
+
return await response.json();
|
|
4030
|
+
}
|
|
4031
|
+
async function overwriteSolution(config, organizationName, fileBuffer, fileName, solutionId) {
|
|
4032
|
+
const overwriteUrl = `${config.baseUrl}/${organizationName}/studio_/backend/api/Solution/${solutionId}/Overwrite`;
|
|
4033
|
+
const formData = new FormData;
|
|
4034
|
+
const fileBlob = new Blob([fileBuffer], {
|
|
4035
|
+
type: "application/octet-stream"
|
|
4036
|
+
});
|
|
4037
|
+
formData.append("UploadFile", fileBlob, fileName);
|
|
4038
|
+
const headers = addSdkUserAgentHeader({
|
|
4039
|
+
Authorization: `Bearer ${config.authToken}`
|
|
4040
|
+
}, SDK_USER_AGENT);
|
|
4041
|
+
if (config.tenantId) {
|
|
4042
|
+
headers["x-uipath-tenantid"] = config.tenantId;
|
|
4043
|
+
}
|
|
4044
|
+
const response = await fetchWithUploadTimeout(overwriteUrl, { method: "POST", headers, body: formData }, "Studio Web solution overwrite");
|
|
4045
|
+
if (!response.ok) {
|
|
4046
|
+
const text = await response.text();
|
|
4047
|
+
throw new HttpError(response.status, `Overwrite failed (${response.status}): ${text}`);
|
|
4048
|
+
}
|
|
4049
|
+
return await response.json();
|
|
4050
|
+
}
|
|
4051
|
+
async function uploadOrOverwriteSolution(config, organizationName, fileBufferOrPath, solutionId, fs) {
|
|
4052
|
+
let fileBuffer;
|
|
4053
|
+
let fileName;
|
|
4054
|
+
if (typeof fileBufferOrPath === "string") {
|
|
4055
|
+
if (!fs) {
|
|
4056
|
+
throw new Error("IFileSystem is required when passing a file path to uploadOrOverwriteSolution");
|
|
4057
|
+
}
|
|
4058
|
+
const content = await fs.readFile(fileBufferOrPath);
|
|
4059
|
+
if (content === null) {
|
|
4060
|
+
throw new Error(`Failed to read file: ${fileBufferOrPath}`);
|
|
4061
|
+
}
|
|
4062
|
+
fileBuffer = new Uint8Array(content);
|
|
4063
|
+
fileName = fs.path.basename(fileBufferOrPath);
|
|
4064
|
+
} else {
|
|
4065
|
+
fileBuffer = fileBufferOrPath;
|
|
4066
|
+
fileName = "solution.uis";
|
|
4067
|
+
}
|
|
4068
|
+
if (solutionId) {
|
|
4069
|
+
logger.info(`Attempting to overwrite existing solution ${solutionId} on Studio Web...`);
|
|
4070
|
+
const [overwriteError, overwriteResult] = await catchError(overwriteSolution(config, organizationName, fileBuffer, fileName, solutionId));
|
|
4071
|
+
if (!overwriteError) {
|
|
4072
|
+
logger.info("Solution overwritten successfully.");
|
|
4073
|
+
return overwriteResult;
|
|
4074
|
+
}
|
|
4075
|
+
if (overwriteError instanceof HttpError && overwriteError.status === 404) {
|
|
4076
|
+
logger.info(`Solution ${solutionId} not found on Studio Web. Importing as new solution...`);
|
|
4077
|
+
} else {
|
|
4078
|
+
throw overwriteError;
|
|
4079
|
+
}
|
|
4080
|
+
}
|
|
4081
|
+
logger.info("Importing new solution to Studio Web...");
|
|
4082
|
+
return importSolution(config, organizationName, fileBuffer, fileName);
|
|
4083
|
+
}
|
|
4084
|
+
// src/services/pack-helpers.ts
|
|
4085
|
+
var import_adm_zip = __toESM(require_adm_zip(), 1);
|
|
4086
|
+
async function collectProjectFiles(rootDir) {
|
|
4087
|
+
const files = [];
|
|
4088
|
+
await collectRecursive(rootDir, rootDir, files);
|
|
4089
|
+
return files;
|
|
4090
|
+
}
|
|
4091
|
+
async function collectRecursive(rootDir, currentDir, files) {
|
|
4092
|
+
const fs = getFileSystem();
|
|
4093
|
+
const entries = await fs.readdir(currentDir);
|
|
4094
|
+
for (const entry of entries) {
|
|
4095
|
+
const fullPath = fs.path.join(currentDir, entry);
|
|
4096
|
+
const stats = await fs.stat(fullPath);
|
|
4097
|
+
if (stats?.isDirectory()) {
|
|
4098
|
+
await collectRecursive(rootDir, fullPath, files);
|
|
4099
|
+
} else if (stats) {
|
|
4100
|
+
files.push(fs.path.relative(rootDir, fullPath).replace(/\\/g, "/"));
|
|
4101
|
+
}
|
|
4102
|
+
}
|
|
4103
|
+
}
|
|
4104
|
+
function matchesExclude(relPath, exclude) {
|
|
4105
|
+
for (const pattern of exclude) {
|
|
4106
|
+
const cleaned = pattern.replace(/^\.\//, "").replace(/\/\*$/, "");
|
|
4107
|
+
if (cleaned.startsWith("*")) {
|
|
4108
|
+
const suffix = cleaned.slice(1).replace(/^\//, "");
|
|
4109
|
+
if (relPath.includes(`/${suffix}/`) || relPath.includes(`/${suffix}`)) {
|
|
4110
|
+
return true;
|
|
4111
|
+
}
|
|
4112
|
+
}
|
|
4113
|
+
if (relPath === cleaned || relPath.startsWith(`${cleaned}/`)) {
|
|
4114
|
+
return true;
|
|
4115
|
+
}
|
|
4116
|
+
}
|
|
4117
|
+
return false;
|
|
4118
|
+
}
|
|
4119
|
+
async function createArchive(sourceDir, outputPath, exclude) {
|
|
4120
|
+
const fs = getFileSystem();
|
|
4121
|
+
const zip = new import_adm_zip.default;
|
|
4122
|
+
const files = await collectProjectFiles(sourceDir);
|
|
4123
|
+
for (const relPath of files) {
|
|
4124
|
+
if (exclude && matchesExclude(relPath, exclude)) {
|
|
4125
|
+
continue;
|
|
4126
|
+
}
|
|
4127
|
+
const fullPath = fs.path.join(sourceDir, relPath);
|
|
4128
|
+
const dirInZip = relPath.includes("/") ? relPath.substring(0, relPath.lastIndexOf("/")) : "";
|
|
4129
|
+
zip.addLocalFile(fullPath, dirInZip);
|
|
4130
|
+
}
|
|
4131
|
+
zip.writeZip(outputPath);
|
|
4132
|
+
}
|
|
4133
|
+
async function extractArchive(archivePath, destDir) {
|
|
4134
|
+
const zip = new import_adm_zip.default(archivePath);
|
|
4135
|
+
zip.extractAllTo(destDir, true);
|
|
4136
|
+
}
|
|
4137
|
+
|
|
4138
|
+
// src/services/agent-debug-service.ts
|
|
4139
|
+
import { randomUUID } from "node:crypto";
|
|
4140
|
+
|
|
4141
|
+
// src/services/agent-local-workspace-eval-preparer.ts
|
|
4142
|
+
var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
4143
|
+
function isUUID(value) {
|
|
4144
|
+
return UUID_PATTERN.test(value);
|
|
4145
|
+
}
|
|
4146
|
+
function isRecord(value) {
|
|
4147
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4148
|
+
}
|
|
4149
|
+
function toForwardSlash2(path) {
|
|
4150
|
+
return path.replace(/\\/g, "/");
|
|
4151
|
+
}
|
|
4152
|
+
async function resolveStudioWebConfig() {
|
|
4153
|
+
const [loginError, login] = await catchError(getLoginStatusAsync());
|
|
4154
|
+
if (loginError) {
|
|
4155
|
+
throw new Error(loginError.message);
|
|
4156
|
+
}
|
|
4157
|
+
if (login.loginStatus !== "Logged in" || !login.baseUrl) {
|
|
4158
|
+
throw new Error("Not logged in. Run 'uip login' first.");
|
|
4159
|
+
}
|
|
4160
|
+
if (!login.accessToken) {
|
|
4161
|
+
throw new Error("Access token not available from login.");
|
|
4162
|
+
}
|
|
4163
|
+
if (!login.organizationName) {
|
|
4164
|
+
throw new Error("Organization name not available from login. Required for Studio Web evaluation.");
|
|
4165
|
+
}
|
|
4166
|
+
return {
|
|
4167
|
+
baseUrl: login.baseUrl,
|
|
4168
|
+
tenantId: login.tenantId,
|
|
4169
|
+
authToken: login.accessToken,
|
|
4170
|
+
organizationName: login.organizationName
|
|
4171
|
+
};
|
|
4172
|
+
}
|
|
4173
|
+
|
|
4174
|
+
class AgentLocalWorkspaceEvalPreparer {
|
|
4175
|
+
fs;
|
|
4176
|
+
constructor(fs = getFileSystem()) {
|
|
4177
|
+
this.fs = fs;
|
|
4178
|
+
}
|
|
4179
|
+
async isLocalWorkspace(projectPath) {
|
|
4180
|
+
return await this.readLocalWorkspaceMarker(projectPath) !== undefined;
|
|
4181
|
+
}
|
|
4182
|
+
async prepare(projectPath, config, existingSolutionIdOverride) {
|
|
4183
|
+
const absoluteProjectPath = this.fs.path.resolve(projectPath);
|
|
4184
|
+
const marker = await this.readLocalWorkspaceMarker(absoluteProjectPath);
|
|
4185
|
+
const packageRoot = marker?.rootPath ?? absoluteProjectPath;
|
|
4186
|
+
const projectService = new AgentProjectService;
|
|
4187
|
+
const agentDir = await projectService.resolveAgentDir(absoluteProjectPath);
|
|
4188
|
+
const agent = await projectService.readAgentJson(absoluteProjectPath);
|
|
4189
|
+
const projectFilePath = this.fs.path.join(agentDir, "project.uiproj");
|
|
4190
|
+
if (!await this.fs.exists(projectFilePath)) {
|
|
4191
|
+
throw new Error(`Not a valid agent project directory: missing project.uiproj in ${agentDir}`);
|
|
4192
|
+
}
|
|
4193
|
+
const projectFileContent = await this.fs.readFile(projectFilePath, "utf-8");
|
|
4194
|
+
const [projectFileError, parsedProjectFile] = catchError(() => JSON.parse(String(projectFileContent)));
|
|
4195
|
+
if (projectFileError || !isRecord(parsedProjectFile)) {
|
|
4196
|
+
throw new Error(`Invalid project.uiproj in ${agentDir}: ${projectFileError?.message ?? "expected a JSON object"}`);
|
|
4197
|
+
}
|
|
4198
|
+
const projectFile = {
|
|
4199
|
+
Name: typeof parsedProjectFile.Name === "string" ? parsedProjectFile.Name : undefined
|
|
4200
|
+
};
|
|
4201
|
+
const solutionInfo = await findSolutionFile(this.fs, agentDir);
|
|
4202
|
+
const solutionId = existingSolutionIdOverride ?? marker?.solutionId ?? solutionInfo?.solutionId;
|
|
4203
|
+
const solutionName = projectFile.Name ?? agent.metadata.name ?? this.fs.path.basename(agentDir);
|
|
4204
|
+
const safeSolutionName = solutionName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
4205
|
+
const stagingDir = this.fs.path.join(this.fs.env.tmpdir(), `.agent-eval-staging-${safeSolutionName}-${Date.now()}`);
|
|
4206
|
+
await this.fs.mkdir(stagingDir);
|
|
4207
|
+
const uisPath = this.fs.path.join(stagingDir, `${safeSolutionName}.uis`);
|
|
4208
|
+
try {
|
|
4209
|
+
logger.info("Building agent package for local workspace eval...");
|
|
4210
|
+
await createArchive(packageRoot, uisPath, [
|
|
4211
|
+
"./.agent-builder/*",
|
|
4212
|
+
"*/.agent-builder/*",
|
|
4213
|
+
".sw-path-marker",
|
|
4214
|
+
"*/.sw-path-marker"
|
|
4215
|
+
]);
|
|
4216
|
+
logger.info("Uploading local workspace agent for eval...");
|
|
4217
|
+
const importResult = await uploadOrOverwriteSolution({
|
|
4218
|
+
baseUrl: config.baseUrl,
|
|
4219
|
+
tenantId: config.tenantId,
|
|
4220
|
+
authToken: config.authToken
|
|
4221
|
+
}, config.organizationName, uisPath, solutionId, this.fs);
|
|
4222
|
+
const matchedProject = this.resolveImportedProject(importResult, solutionName);
|
|
4223
|
+
await this.persistSolutionStorage(projectService, absoluteProjectPath, packageRoot, projectFilePath, importResult.id, agent.projectId, matchedProject.id);
|
|
4224
|
+
if (packageRoot !== absoluteProjectPath) {
|
|
4225
|
+
await this.persistSolutionStorage(projectService, packageRoot, packageRoot, projectFilePath, importResult.id, agent.projectId, matchedProject.id);
|
|
4226
|
+
}
|
|
4227
|
+
await updateSolutionFile(this.fs, agentDir, importResult.id);
|
|
4228
|
+
if (marker) {
|
|
4229
|
+
await this.updateLocalWorkspaceMarker(marker.rootPath, importResult.id);
|
|
4230
|
+
}
|
|
4231
|
+
return {
|
|
4232
|
+
solutionId: importResult.id,
|
|
4233
|
+
agentProjectId: matchedProject.id
|
|
4234
|
+
};
|
|
4235
|
+
} finally {
|
|
4236
|
+
const [cleanupError] = await catchError(this.fs.rm(stagingDir, { recursive: true }));
|
|
4237
|
+
if (cleanupError) {
|
|
4238
|
+
logger.warn(`Cleanup failed: ${cleanupError.message}`);
|
|
4239
|
+
}
|
|
4240
|
+
}
|
|
4241
|
+
}
|
|
4242
|
+
async readLocalWorkspaceMarker(projectPath) {
|
|
4243
|
+
const absoluteProjectPath = this.fs.path.resolve(projectPath);
|
|
4244
|
+
const candidates = [
|
|
4245
|
+
absoluteProjectPath,
|
|
4246
|
+
this.fs.path.dirname(absoluteProjectPath)
|
|
4247
|
+
];
|
|
4248
|
+
for (const candidate of candidates) {
|
|
4249
|
+
const markerPath = this.fs.path.join(candidate, ".sw-path-marker");
|
|
4250
|
+
if (!await this.fs.exists(markerPath)) {
|
|
4251
|
+
continue;
|
|
4252
|
+
}
|
|
4253
|
+
const content = String(await this.fs.readFile(markerPath, "utf-8"));
|
|
4254
|
+
const solutionId = content.trim();
|
|
4255
|
+
return {
|
|
4256
|
+
rootPath: candidate,
|
|
4257
|
+
...isUUID(solutionId) ? { solutionId } : {}
|
|
4258
|
+
};
|
|
4259
|
+
}
|
|
4260
|
+
return;
|
|
4261
|
+
}
|
|
4262
|
+
resolveImportedProject(importResult, agentName) {
|
|
4263
|
+
const exactProject = importResult.projects.find((project) => project.name === agentName);
|
|
4264
|
+
if (exactProject?.id) {
|
|
4265
|
+
return exactProject;
|
|
4266
|
+
}
|
|
4267
|
+
const [onlyProject] = importResult.projects;
|
|
4268
|
+
if (importResult.projects.length === 1 && onlyProject?.id) {
|
|
4269
|
+
return onlyProject;
|
|
4270
|
+
}
|
|
4271
|
+
throw new Error(`Upload response had ${importResult.projects.length} projects and none matched "${agentName}"; refusing to guess.`);
|
|
4272
|
+
}
|
|
4273
|
+
async persistSolutionStorage(projectService, storagePath, packageRoot, projectFilePath, solutionId, localProjectId, cloudProjectId) {
|
|
4274
|
+
const projectRelativePath = toForwardSlash2(this.fs.path.relative(packageRoot, projectFilePath));
|
|
4275
|
+
const projectEntry = {
|
|
4276
|
+
ProjectId: localProjectId,
|
|
4277
|
+
ProjectRelativePath: projectRelativePath || "project.uiproj",
|
|
4278
|
+
CloudProjectId: cloudProjectId
|
|
4279
|
+
};
|
|
4280
|
+
const [, existingStorage] = await catchError(projectService.readSolutionStorage(storagePath));
|
|
4281
|
+
const existingProjects = existingStorage?.Projects ?? [];
|
|
4282
|
+
const projectIndex = existingProjects.findIndex((project) => project.ProjectId === localProjectId);
|
|
4283
|
+
const projects = projectIndex === -1 ? [...existingProjects, projectEntry] : existingProjects.map((project, index) => index === projectIndex ? { ...project, ...projectEntry } : project);
|
|
4284
|
+
await projectService.writeSolutionStorage(storagePath, {
|
|
4285
|
+
SolutionId: solutionId,
|
|
4286
|
+
Projects: projects
|
|
4287
|
+
});
|
|
4288
|
+
}
|
|
4289
|
+
async updateLocalWorkspaceMarker(workspaceRoot, solutionId) {
|
|
4290
|
+
await this.fs.writeFile(this.fs.path.join(workspaceRoot, ".sw-path-marker"), solutionId);
|
|
4291
|
+
}
|
|
4292
|
+
}
|
|
4293
|
+
|
|
4294
|
+
// src/services/agent-debug-service.ts
|
|
4295
|
+
class AgentDebugCancelledError extends Error {
|
|
4296
|
+
jobKey;
|
|
4297
|
+
constructor(jobKey) {
|
|
4298
|
+
super(jobKey ? `Debug run cancelled. Job ${jobKey} may still be running on the serverless runtime.` : "Debug run cancelled before the job started.");
|
|
4299
|
+
this.name = "AgentDebugCancelledError";
|
|
4300
|
+
this.jobKey = jobKey;
|
|
4301
|
+
}
|
|
4302
|
+
}
|
|
4303
|
+
var TERMINAL_STATES = new Set([
|
|
4304
|
+
"Successful",
|
|
4305
|
+
"Faulted",
|
|
4306
|
+
"Stopped",
|
|
4307
|
+
"Suspended"
|
|
4308
|
+
]);
|
|
4309
|
+
var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
4310
|
+
|
|
4311
|
+
class AgentDebugService {
|
|
4312
|
+
fs = getFileSystem();
|
|
4313
|
+
projectService = new AgentProjectService;
|
|
4314
|
+
async debug(options, auth) {
|
|
4315
|
+
throwIfAborted(options.signal);
|
|
4316
|
+
const projectId = await this.resolveProjectId(options.projectPath);
|
|
4317
|
+
throwIfAborted(options.signal);
|
|
4318
|
+
const folderKey = await this.resolvePersonalWorkspaceKey();
|
|
4319
|
+
throwIfAborted(options.signal);
|
|
4320
|
+
const { jobKey, traceId } = await asCancellation(() => this.startDebugJob(auth, folderKey, projectId, options.inputs, options.signal));
|
|
4321
|
+
const job = await asCancellation(() => this.pollJob(auth, folderKey, jobKey, options), jobKey);
|
|
4322
|
+
return {
|
|
4323
|
+
jobKey,
|
|
4324
|
+
traceId,
|
|
4325
|
+
finalState: job.state,
|
|
4326
|
+
success: job.state === "Successful",
|
|
4327
|
+
output: job.output,
|
|
4328
|
+
info: job.info
|
|
4329
|
+
};
|
|
4330
|
+
}
|
|
4331
|
+
async resolveProjectId(projectPath) {
|
|
4332
|
+
const preparer = new AgentLocalWorkspaceEvalPreparer;
|
|
4333
|
+
if (await preparer.isLocalWorkspace(projectPath)) {
|
|
4334
|
+
const [, storage] = await catchError(this.projectService.readSolutionStorage(projectPath));
|
|
4335
|
+
const config = await resolveStudioWebConfig();
|
|
4336
|
+
const prepared = await preparer.prepare(projectPath, config, storage?.SolutionId);
|
|
4337
|
+
return prepared.agentProjectId;
|
|
4338
|
+
}
|
|
4339
|
+
return this.uploadSolutionAndResolveProjectId(projectPath);
|
|
4340
|
+
}
|
|
4341
|
+
async uploadSolutionAndResolveProjectId(projectPath) {
|
|
4342
|
+
const solution = await findSolutionFile(this.fs, projectPath);
|
|
4343
|
+
if (!solution) {
|
|
4344
|
+
throw new Error(`No enclosing .uipx solution found for '${projectPath}'. Create one with 'uip solution init' and add the agent to it.`);
|
|
4345
|
+
}
|
|
4346
|
+
const config = await resolveStudioWebConfig();
|
|
4347
|
+
const solutionDir = this.fs.path.resolve(projectPath, "..");
|
|
4348
|
+
const tempDir = await this.fs.getTempDir();
|
|
4349
|
+
try {
|
|
4350
|
+
const bundle = await bundleSolution(this.fs, solutionDir, tempDir);
|
|
4351
|
+
const importResult = await uploadOrOverwriteSolution(config, config.organizationName, bundle.uisPath, bundle.solutionId, this.fs);
|
|
4352
|
+
if (importResult.id && bundle.uipxPath) {
|
|
4353
|
+
await updateUipxSolutionId(this.fs, bundle.uipxPath, importResult.id);
|
|
4354
|
+
}
|
|
4355
|
+
const projectName = await this.readProjectName(projectPath);
|
|
4356
|
+
const byName = importResult.projects.find((p) => p.name === projectName);
|
|
4357
|
+
if (byName?.id) {
|
|
4358
|
+
return byName.id;
|
|
4359
|
+
}
|
|
4360
|
+
const [only] = importResult.projects;
|
|
4361
|
+
if (importResult.projects.length === 1 && only?.id) {
|
|
4362
|
+
return only.id;
|
|
4363
|
+
}
|
|
4364
|
+
throw new Error(`Could not resolve the Studio Web project for "${projectName}": the upload returned ${importResult.projects.length} projects and none is named "${projectName}". Ensure the Name in project.uiproj matches the agent project in the solution.`);
|
|
4365
|
+
} finally {
|
|
4366
|
+
const [cleanupError] = await catchError(this.fs.rm(tempDir));
|
|
4367
|
+
if (cleanupError) {
|
|
4368
|
+
logger.debug(`Failed to clean up temp dir: ${cleanupError.message}`);
|
|
4369
|
+
}
|
|
4370
|
+
}
|
|
4371
|
+
}
|
|
4372
|
+
async readProjectName(projectPath) {
|
|
4373
|
+
const [, content] = await catchError(this.fs.readFile(this.fs.path.join(projectPath, "project.uiproj"), "utf-8"));
|
|
4374
|
+
const [, parsed] = catchError(() => JSON.parse(String(content)));
|
|
4375
|
+
return parsed?.Name ?? this.fs.path.basename(projectPath);
|
|
4376
|
+
}
|
|
4377
|
+
async resolvePersonalWorkspaceKey() {
|
|
4378
|
+
const wsApi = await createApiClient(PersonalWorkspacesApi, {});
|
|
4379
|
+
const workspace = await wsApi.personalWorkspacesGetPersonalWorkspace();
|
|
4380
|
+
if (!workspace?.key) {
|
|
4381
|
+
throw new Error("Could not resolve your personal workspace. Ensure it is enabled for your account.");
|
|
4382
|
+
}
|
|
4383
|
+
return workspace.key;
|
|
4384
|
+
}
|
|
4385
|
+
orchestratorBaseUrl(auth) {
|
|
4386
|
+
return `${auth.baseUrl}/${auth.organizationId}/${auth.tenantName}/orchestrator_`;
|
|
4387
|
+
}
|
|
4388
|
+
async startDebugJob(auth, folderKey, projectId, inputs, signal) {
|
|
4389
|
+
const traceId = randomUUID();
|
|
4390
|
+
const inputArguments = JSON.stringify({
|
|
4391
|
+
Command: "debug",
|
|
4392
|
+
EntryPoint: "agent.json",
|
|
4393
|
+
Input: JSON.stringify(inputs),
|
|
4394
|
+
args: "--attach=none"
|
|
4395
|
+
});
|
|
4396
|
+
const response = await fetch(`${this.orchestratorBaseUrl(auth)}/api/serverless/jobs`, {
|
|
4397
|
+
method: "POST",
|
|
4398
|
+
headers: {
|
|
4399
|
+
Authorization: `Bearer ${auth.accessToken}`,
|
|
4400
|
+
"Content-Type": "application/json",
|
|
4401
|
+
"X-UIPATH-FolderKey": folderKey
|
|
4402
|
+
},
|
|
4403
|
+
body: JSON.stringify({
|
|
4404
|
+
JobType: "PythonAgent",
|
|
4405
|
+
InputArguments: inputArguments,
|
|
4406
|
+
Source: "StudioWeb",
|
|
4407
|
+
RunAsMe: true,
|
|
4408
|
+
EnvironmentVariables: `UIPATH_PROJECT_ID=${projectId}`,
|
|
4409
|
+
TraceId: traceId,
|
|
4410
|
+
Reference: randomUUID()
|
|
4411
|
+
}),
|
|
4412
|
+
signal
|
|
4413
|
+
});
|
|
4414
|
+
if (!response.ok) {
|
|
4415
|
+
throw new Error(`Failed to start debug job: ${response.status} ${await response.text()}`);
|
|
4416
|
+
}
|
|
4417
|
+
const data = await response.json();
|
|
4418
|
+
if (!data.key) {
|
|
4419
|
+
throw new Error("Debug job started but no job key was returned.");
|
|
4420
|
+
}
|
|
4421
|
+
return { jobKey: data.key, traceId };
|
|
4422
|
+
}
|
|
4423
|
+
async pollJob(auth, folderKey, jobKey, options) {
|
|
4424
|
+
const url = `${this.orchestratorBaseUrl(auth)}/odata/Jobs/UiPath.Server.Configuration.OData.GetByKey(identifier=${jobKey})`;
|
|
4425
|
+
const headers = {
|
|
4426
|
+
Authorization: `Bearer ${auth.accessToken}`,
|
|
4427
|
+
"X-UIPATH-FolderKey": folderKey
|
|
4428
|
+
};
|
|
4429
|
+
let lastState = "";
|
|
4430
|
+
let consecutiveErrors = 0;
|
|
4431
|
+
const maxConsecutiveErrors = 3;
|
|
4432
|
+
for (let poll = 0;poll < options.maxPolls; poll++) {
|
|
4433
|
+
await delay(options.pollIntervalMs);
|
|
4434
|
+
throwIfAborted(options.signal, jobKey);
|
|
4435
|
+
const response = await fetch(url, {
|
|
4436
|
+
headers,
|
|
4437
|
+
signal: options.signal
|
|
4438
|
+
});
|
|
4439
|
+
if (!response.ok) {
|
|
4440
|
+
consecutiveErrors++;
|
|
4441
|
+
if (response.status < 500 || consecutiveErrors > maxConsecutiveErrors) {
|
|
4442
|
+
const body = await response.text();
|
|
4443
|
+
throw new Error(`Failed to poll debug job (HTTP ${response.status}): ${body.slice(0, 300)}`);
|
|
4444
|
+
}
|
|
4445
|
+
continue;
|
|
4446
|
+
}
|
|
4447
|
+
consecutiveErrors = 0;
|
|
4448
|
+
const job = await response.json();
|
|
4449
|
+
if (job.State !== lastState) {
|
|
4450
|
+
lastState = job.State;
|
|
4451
|
+
options.onState?.(job.State);
|
|
4452
|
+
}
|
|
4453
|
+
if (TERMINAL_STATES.has(job.State)) {
|
|
4454
|
+
return {
|
|
4455
|
+
state: job.State,
|
|
4456
|
+
output: parseOutput(job.OutputArguments),
|
|
4457
|
+
info: job.Info?.trim() || undefined
|
|
4458
|
+
};
|
|
4459
|
+
}
|
|
4460
|
+
}
|
|
4461
|
+
throw new Error(`Debug run did not reach a terminal state within the timeout (last state: ${lastState || "unknown"}). Increase --timeout and retry.`);
|
|
4462
|
+
}
|
|
4463
|
+
}
|
|
4464
|
+
function throwIfAborted(signal, jobKey) {
|
|
4465
|
+
if (signal?.aborted) {
|
|
4466
|
+
throw new AgentDebugCancelledError(jobKey);
|
|
4467
|
+
}
|
|
4468
|
+
}
|
|
4469
|
+
async function asCancellation(step, jobKey) {
|
|
4470
|
+
try {
|
|
4471
|
+
return await step();
|
|
4472
|
+
} catch (error) {
|
|
4473
|
+
if (isAbortError(error)) {
|
|
4474
|
+
throw new AgentDebugCancelledError(jobKey);
|
|
4475
|
+
}
|
|
4476
|
+
throw error;
|
|
4477
|
+
}
|
|
4478
|
+
}
|
|
4479
|
+
function isAbortError(error) {
|
|
4480
|
+
return error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError");
|
|
4481
|
+
}
|
|
4482
|
+
function parseOutput(outputArguments) {
|
|
4483
|
+
if (!outputArguments) {
|
|
4484
|
+
return;
|
|
4485
|
+
}
|
|
4486
|
+
const [error, parsed] = catchError(() => JSON.parse(outputArguments));
|
|
4487
|
+
return error ? outputArguments : parsed;
|
|
4488
|
+
}
|
|
4489
|
+
|
|
4490
|
+
export { Configuration, ConfigurationsApi, DeploymentsApi, PackagesApi, createArchive, extractArchive, resolveStudioWebConfig, AgentLocalWorkspaceEvalPreparer, AgentDebugCancelledError, AgentDebugService };
|
|
4491
|
+
|
|
4492
|
+
//# debugId=9E43C54B7330E6BC64756E2164756E21
|