@openfn/language-common 2.3.2 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +28 -25
- package/dist/index.js +28 -25
- package/dist/util.cjs +28 -25
- package/dist/util.js +28 -25
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -162,6 +162,31 @@ var throw_error_default = (code, { description, fix, ...extras } = {}) => {
|
|
|
162
162
|
throw e;
|
|
163
163
|
};
|
|
164
164
|
|
|
165
|
+
// src/util/base64.js
|
|
166
|
+
var import_lodash = __toESM(require("lodash"), 1);
|
|
167
|
+
var encode = (data, options2 = { parseJson: true }) => {
|
|
168
|
+
let str = data;
|
|
169
|
+
if (typeof data !== "string" && options2.parseJson) {
|
|
170
|
+
try {
|
|
171
|
+
str = JSON.stringify(str);
|
|
172
|
+
} catch (e) {
|
|
173
|
+
console.log(e.message);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return Buffer.from(str, "utf-8").toString("base64");
|
|
177
|
+
};
|
|
178
|
+
var decode = (base64Data, options2 = { parseJson: true }) => {
|
|
179
|
+
let decodedValue = Buffer.from(base64Data, "base64").toString("utf-8");
|
|
180
|
+
if ((import_lodash.default.startsWith(decodedValue, "[") || import_lodash.default.startsWith(decodedValue, "{")) && options2.parseJson) {
|
|
181
|
+
try {
|
|
182
|
+
decodedValue = JSON.parse(decodedValue);
|
|
183
|
+
} catch (e) {
|
|
184
|
+
console.log(e.message);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return decodedValue;
|
|
188
|
+
};
|
|
189
|
+
|
|
165
190
|
// src/util/http.js
|
|
166
191
|
var clients = /* @__PURE__ */ new Map();
|
|
167
192
|
var makeBasicAuthHeader = (username, password) => {
|
|
@@ -341,6 +366,9 @@ async function readResponseBody(response, parseAs) {
|
|
|
341
366
|
return response.body.text();
|
|
342
367
|
case "stream":
|
|
343
368
|
return response.body;
|
|
369
|
+
case "base64":
|
|
370
|
+
const arrayBuffer = await response.body.arrayBuffer();
|
|
371
|
+
return encode(arrayBuffer, { parseJson: false });
|
|
344
372
|
default:
|
|
345
373
|
return contentType && contentType.includes("application/json") ? await response.body.json() : response.body.text();
|
|
346
374
|
}
|
|
@@ -436,31 +464,6 @@ var parse_date_default = (d, startDate) => {
|
|
|
436
464
|
return d;
|
|
437
465
|
};
|
|
438
466
|
|
|
439
|
-
// src/util/base64.js
|
|
440
|
-
var import_lodash = __toESM(require("lodash"), 1);
|
|
441
|
-
var encode = (data, options2 = { parseJson: true }) => {
|
|
442
|
-
let str = data;
|
|
443
|
-
if (typeof data !== "string" && options2.parseJson) {
|
|
444
|
-
try {
|
|
445
|
-
str = JSON.stringify(str);
|
|
446
|
-
} catch (e) {
|
|
447
|
-
console.log(e.message);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
return Buffer.from(str, "utf-8").toString("base64");
|
|
451
|
-
};
|
|
452
|
-
var decode = (base64Data, options2 = { parseJson: true }) => {
|
|
453
|
-
let decodedValue = Buffer.from(base64Data, "base64").toString("utf-8");
|
|
454
|
-
if ((import_lodash.default.startsWith(decodedValue, "[") || import_lodash.default.startsWith(decodedValue, "{")) && options2.parseJson) {
|
|
455
|
-
try {
|
|
456
|
-
decodedValue = JSON.parse(decodedValue);
|
|
457
|
-
} catch (e) {
|
|
458
|
-
console.log(e.message);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
return decodedValue;
|
|
462
|
-
};
|
|
463
|
-
|
|
464
467
|
// src/util/uuid.js
|
|
465
468
|
var import_node_crypto = require("crypto");
|
|
466
469
|
var uuid = () => (0, import_node_crypto.randomUUID)();
|
package/dist/index.js
CHANGED
|
@@ -100,6 +100,31 @@ var throw_error_default = (code, { description, fix, ...extras } = {}) => {
|
|
|
100
100
|
throw e;
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
+
// src/util/base64.js
|
|
104
|
+
import _ from "lodash";
|
|
105
|
+
var encode = (data, options2 = { parseJson: true }) => {
|
|
106
|
+
let str = data;
|
|
107
|
+
if (typeof data !== "string" && options2.parseJson) {
|
|
108
|
+
try {
|
|
109
|
+
str = JSON.stringify(str);
|
|
110
|
+
} catch (e) {
|
|
111
|
+
console.log(e.message);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return Buffer.from(str, "utf-8").toString("base64");
|
|
115
|
+
};
|
|
116
|
+
var decode = (base64Data, options2 = { parseJson: true }) => {
|
|
117
|
+
let decodedValue = Buffer.from(base64Data, "base64").toString("utf-8");
|
|
118
|
+
if ((_.startsWith(decodedValue, "[") || _.startsWith(decodedValue, "{")) && options2.parseJson) {
|
|
119
|
+
try {
|
|
120
|
+
decodedValue = JSON.parse(decodedValue);
|
|
121
|
+
} catch (e) {
|
|
122
|
+
console.log(e.message);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return decodedValue;
|
|
126
|
+
};
|
|
127
|
+
|
|
103
128
|
// src/util/http.js
|
|
104
129
|
var clients = /* @__PURE__ */ new Map();
|
|
105
130
|
var makeBasicAuthHeader = (username, password) => {
|
|
@@ -279,6 +304,9 @@ async function readResponseBody(response, parseAs) {
|
|
|
279
304
|
return response.body.text();
|
|
280
305
|
case "stream":
|
|
281
306
|
return response.body;
|
|
307
|
+
case "base64":
|
|
308
|
+
const arrayBuffer = await response.body.arrayBuffer();
|
|
309
|
+
return encode(arrayBuffer, { parseJson: false });
|
|
282
310
|
default:
|
|
283
311
|
return contentType && contentType.includes("application/json") ? await response.body.json() : response.body.text();
|
|
284
312
|
}
|
|
@@ -374,31 +402,6 @@ var parse_date_default = (d, startDate) => {
|
|
|
374
402
|
return d;
|
|
375
403
|
};
|
|
376
404
|
|
|
377
|
-
// src/util/base64.js
|
|
378
|
-
import _ from "lodash";
|
|
379
|
-
var encode = (data, options2 = { parseJson: true }) => {
|
|
380
|
-
let str = data;
|
|
381
|
-
if (typeof data !== "string" && options2.parseJson) {
|
|
382
|
-
try {
|
|
383
|
-
str = JSON.stringify(str);
|
|
384
|
-
} catch (e) {
|
|
385
|
-
console.log(e.message);
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
return Buffer.from(str, "utf-8").toString("base64");
|
|
389
|
-
};
|
|
390
|
-
var decode = (base64Data, options2 = { parseJson: true }) => {
|
|
391
|
-
let decodedValue = Buffer.from(base64Data, "base64").toString("utf-8");
|
|
392
|
-
if ((_.startsWith(decodedValue, "[") || _.startsWith(decodedValue, "{")) && options2.parseJson) {
|
|
393
|
-
try {
|
|
394
|
-
decodedValue = JSON.parse(decodedValue);
|
|
395
|
-
} catch (e) {
|
|
396
|
-
console.log(e.message);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
return decodedValue;
|
|
400
|
-
};
|
|
401
|
-
|
|
402
405
|
// src/util/uuid.js
|
|
403
406
|
import { randomUUID } from "crypto";
|
|
404
407
|
var uuid = () => randomUUID();
|
package/dist/util.cjs
CHANGED
|
@@ -71,6 +71,31 @@ var throw_error_default = (code, { description, fix, ...extras } = {}) => {
|
|
|
71
71
|
throw e;
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
+
// src/util/base64.js
|
|
75
|
+
var import_lodash = __toESM(require("lodash"), 1);
|
|
76
|
+
var encode = (data, options = { parseJson: true }) => {
|
|
77
|
+
let str = data;
|
|
78
|
+
if (typeof data !== "string" && options.parseJson) {
|
|
79
|
+
try {
|
|
80
|
+
str = JSON.stringify(str);
|
|
81
|
+
} catch (e) {
|
|
82
|
+
console.log(e.message);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return Buffer.from(str, "utf-8").toString("base64");
|
|
86
|
+
};
|
|
87
|
+
var decode = (base64Data, options = { parseJson: true }) => {
|
|
88
|
+
let decodedValue = Buffer.from(base64Data, "base64").toString("utf-8");
|
|
89
|
+
if ((import_lodash.default.startsWith(decodedValue, "[") || import_lodash.default.startsWith(decodedValue, "{")) && options.parseJson) {
|
|
90
|
+
try {
|
|
91
|
+
decodedValue = JSON.parse(decodedValue);
|
|
92
|
+
} catch (e) {
|
|
93
|
+
console.log(e.message);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return decodedValue;
|
|
97
|
+
};
|
|
98
|
+
|
|
74
99
|
// src/util/http.js
|
|
75
100
|
var clients = /* @__PURE__ */ new Map();
|
|
76
101
|
var makeBasicAuthHeader = (username, password) => {
|
|
@@ -250,6 +275,9 @@ async function readResponseBody(response, parseAs) {
|
|
|
250
275
|
return response.body.text();
|
|
251
276
|
case "stream":
|
|
252
277
|
return response.body;
|
|
278
|
+
case "base64":
|
|
279
|
+
const arrayBuffer = await response.body.arrayBuffer();
|
|
280
|
+
return encode(arrayBuffer, { parseJson: false });
|
|
253
281
|
default:
|
|
254
282
|
return contentType && contentType.includes("application/json") ? await response.body.json() : response.body.text();
|
|
255
283
|
}
|
|
@@ -345,31 +373,6 @@ var parse_date_default = (d, startDate) => {
|
|
|
345
373
|
return d;
|
|
346
374
|
};
|
|
347
375
|
|
|
348
|
-
// src/util/base64.js
|
|
349
|
-
var import_lodash = __toESM(require("lodash"), 1);
|
|
350
|
-
var encode = (data, options = { parseJson: true }) => {
|
|
351
|
-
let str = data;
|
|
352
|
-
if (typeof data !== "string" && options.parseJson) {
|
|
353
|
-
try {
|
|
354
|
-
str = JSON.stringify(str);
|
|
355
|
-
} catch (e) {
|
|
356
|
-
console.log(e.message);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
return Buffer.from(str, "utf-8").toString("base64");
|
|
360
|
-
};
|
|
361
|
-
var decode = (base64Data, options = { parseJson: true }) => {
|
|
362
|
-
let decodedValue = Buffer.from(base64Data, "base64").toString("utf-8");
|
|
363
|
-
if ((import_lodash.default.startsWith(decodedValue, "[") || import_lodash.default.startsWith(decodedValue, "{")) && options.parseJson) {
|
|
364
|
-
try {
|
|
365
|
-
decodedValue = JSON.parse(decodedValue);
|
|
366
|
-
} catch (e) {
|
|
367
|
-
console.log(e.message);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
return decodedValue;
|
|
371
|
-
};
|
|
372
|
-
|
|
373
376
|
// src/util/uuid.js
|
|
374
377
|
var import_node_crypto = require("crypto");
|
|
375
378
|
var uuid = () => (0, import_node_crypto.randomUUID)();
|
package/dist/util.js
CHANGED
|
@@ -22,6 +22,31 @@ var throw_error_default = (code, { description, fix, ...extras } = {}) => {
|
|
|
22
22
|
throw e;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
+
// src/util/base64.js
|
|
26
|
+
import _ from "lodash";
|
|
27
|
+
var encode = (data, options = { parseJson: true }) => {
|
|
28
|
+
let str = data;
|
|
29
|
+
if (typeof data !== "string" && options.parseJson) {
|
|
30
|
+
try {
|
|
31
|
+
str = JSON.stringify(str);
|
|
32
|
+
} catch (e) {
|
|
33
|
+
console.log(e.message);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return Buffer.from(str, "utf-8").toString("base64");
|
|
37
|
+
};
|
|
38
|
+
var decode = (base64Data, options = { parseJson: true }) => {
|
|
39
|
+
let decodedValue = Buffer.from(base64Data, "base64").toString("utf-8");
|
|
40
|
+
if ((_.startsWith(decodedValue, "[") || _.startsWith(decodedValue, "{")) && options.parseJson) {
|
|
41
|
+
try {
|
|
42
|
+
decodedValue = JSON.parse(decodedValue);
|
|
43
|
+
} catch (e) {
|
|
44
|
+
console.log(e.message);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return decodedValue;
|
|
48
|
+
};
|
|
49
|
+
|
|
25
50
|
// src/util/http.js
|
|
26
51
|
var clients = /* @__PURE__ */ new Map();
|
|
27
52
|
var makeBasicAuthHeader = (username, password) => {
|
|
@@ -201,6 +226,9 @@ async function readResponseBody(response, parseAs) {
|
|
|
201
226
|
return response.body.text();
|
|
202
227
|
case "stream":
|
|
203
228
|
return response.body;
|
|
229
|
+
case "base64":
|
|
230
|
+
const arrayBuffer = await response.body.arrayBuffer();
|
|
231
|
+
return encode(arrayBuffer, { parseJson: false });
|
|
204
232
|
default:
|
|
205
233
|
return contentType && contentType.includes("application/json") ? await response.body.json() : response.body.text();
|
|
206
234
|
}
|
|
@@ -296,31 +324,6 @@ var parse_date_default = (d, startDate) => {
|
|
|
296
324
|
return d;
|
|
297
325
|
};
|
|
298
326
|
|
|
299
|
-
// src/util/base64.js
|
|
300
|
-
import _ from "lodash";
|
|
301
|
-
var encode = (data, options = { parseJson: true }) => {
|
|
302
|
-
let str = data;
|
|
303
|
-
if (typeof data !== "string" && options.parseJson) {
|
|
304
|
-
try {
|
|
305
|
-
str = JSON.stringify(str);
|
|
306
|
-
} catch (e) {
|
|
307
|
-
console.log(e.message);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
return Buffer.from(str, "utf-8").toString("base64");
|
|
311
|
-
};
|
|
312
|
-
var decode = (base64Data, options = { parseJson: true }) => {
|
|
313
|
-
let decodedValue = Buffer.from(base64Data, "base64").toString("utf-8");
|
|
314
|
-
if ((_.startsWith(decodedValue, "[") || _.startsWith(decodedValue, "{")) && options.parseJson) {
|
|
315
|
-
try {
|
|
316
|
-
decodedValue = JSON.parse(decodedValue);
|
|
317
|
-
} catch (e) {
|
|
318
|
-
console.log(e.message);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
return decodedValue;
|
|
322
|
-
};
|
|
323
|
-
|
|
324
327
|
// src/util/uuid.js
|
|
325
328
|
import { randomUUID } from "crypto";
|
|
326
329
|
var uuid = () => randomUUID();
|