@openfn/language-common 2.2.0 → 2.3.0

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/ast.json CHANGED
@@ -1544,6 +1544,59 @@
1544
1544
  },
1545
1545
  "valid": false
1546
1546
  },
1547
+ {
1548
+ "name": "assert",
1549
+ "params": [
1550
+ "expression",
1551
+ "errorMessage"
1552
+ ],
1553
+ "docs": {
1554
+ "description": "Asserts the given expression or function resolves to `true`, or else throws an exception. Optionally accepts and error message.",
1555
+ "tags": [
1556
+ {
1557
+ "title": "public",
1558
+ "description": null,
1559
+ "type": null
1560
+ },
1561
+ {
1562
+ "title": "function",
1563
+ "description": null,
1564
+ "name": null
1565
+ },
1566
+ {
1567
+ "title": "example",
1568
+ "description": "assert('a' === 'b', '\"a\" is not equal to \"b\"')"
1569
+ },
1570
+ {
1571
+ "title": "param",
1572
+ "description": "The expression or function to be evaluated.",
1573
+ "type": {
1574
+ "type": "NameExpression",
1575
+ "name": "any"
1576
+ },
1577
+ "name": "expression"
1578
+ },
1579
+ {
1580
+ "title": "param",
1581
+ "description": "The error message thrown in case of a failed state.",
1582
+ "type": {
1583
+ "type": "NameExpression",
1584
+ "name": "string"
1585
+ },
1586
+ "name": "errorMessage"
1587
+ },
1588
+ {
1589
+ "title": "returns",
1590
+ "description": null,
1591
+ "type": {
1592
+ "type": "NameExpression",
1593
+ "name": "operation"
1594
+ }
1595
+ }
1596
+ ]
1597
+ },
1598
+ "valid": true
1599
+ },
1547
1600
  {
1548
1601
  "name": "map",
1549
1602
  "params": [
package/dist/index.cjs CHANGED
@@ -28,6 +28,7 @@ __export(src_exports, {
28
28
  alterState: () => alterState,
29
29
  arrayToString: () => arrayToString,
30
30
  asData: () => asData,
31
+ assert: () => assert,
31
32
  beta: () => beta_exports,
32
33
  chunk: () => chunk,
33
34
  combine: () => combine,
@@ -71,6 +72,7 @@ __export(Adaptor_exports, {
71
72
  alterState: () => alterState,
72
73
  arrayToString: () => arrayToString,
73
74
  asData: () => asData,
75
+ assert: () => assert,
74
76
  chunk: () => chunk,
75
77
  combine: () => combine,
76
78
  composeNextState: () => composeNextState,
@@ -142,6 +144,25 @@ var import_http_status_codes = require("http-status-codes");
142
144
  var import_node_stream = require("stream");
143
145
  var import_node_querystring = __toESM(require("querystring"), 1);
144
146
  var import_node_path = __toESM(require("path"), 1);
147
+
148
+ // src/util/throw-error.js
149
+ var throw_error_default = (code, { description, fix, ...extras } = {}) => {
150
+ const message = description ? `${code}: ${description}` : code;
151
+ const e = new Error(message);
152
+ e.code = code;
153
+ if (description) {
154
+ e.description = description;
155
+ }
156
+ if (fix) {
157
+ e.fix = fix;
158
+ }
159
+ for (const key in extras) {
160
+ e[key] = extras[key];
161
+ }
162
+ throw e;
163
+ };
164
+
165
+ // src/util/http.js
145
166
  var clients = /* @__PURE__ */ new Map();
146
167
  var makeBasicAuthHeader = (username, password) => {
147
168
  const buff = Buffer.from(`${username}:${password}`);
@@ -303,16 +324,29 @@ function encodeRequestBody(body) {
303
324
  throw new Error("Unsupported body type");
304
325
  }
305
326
  async function readResponseBody(response, parseAs) {
306
- const contentType = response.headers["content-type"];
307
- switch (parseAs) {
308
- case "json":
309
- return response.body.json();
310
- case "text":
311
- return response.body.text();
312
- case "stream":
313
- return response.body;
314
- default:
315
- return contentType && contentType.includes("application/json") ? response.body.json() : response.body.text();
327
+ try {
328
+ const contentType = response.headers["content-type"];
329
+ if (+response.headers["content-length"] === 0) {
330
+ return void 0;
331
+ }
332
+ switch (parseAs) {
333
+ case "json":
334
+ return await response.body.json();
335
+ case "text":
336
+ return response.body.text();
337
+ case "stream":
338
+ return response.body;
339
+ default:
340
+ return contentType && contentType.includes("application/json") ? await response.body.json() : response.body.text();
341
+ }
342
+ } catch (error) {
343
+ throw_error_default(response.statusCode, {
344
+ description: "Error parsing the response body",
345
+ parseAs,
346
+ contentType: response.headers["content-type"],
347
+ bodyLength: +response.headers["content-length"],
348
+ error: error.message
349
+ });
316
350
  }
317
351
  }
318
352
  var get = (url, options2) => request("GET", url, options2);
@@ -337,7 +371,8 @@ var isStream = (value) => {
337
371
  return false;
338
372
  };
339
373
  function expandReference(state, value) {
340
- if (Buffer.isBuffer(value)) {
374
+ var _a;
375
+ if (Buffer.isBuffer(value) || ((_a = value == null ? void 0 : value.constructor) == null ? void 0 : _a.name) === "RegExp") {
341
376
  return value;
342
377
  }
343
378
  if (Array.isArray(value)) {
@@ -396,27 +431,31 @@ var parse_date_default = (d, startDate) => {
396
431
  return d;
397
432
  };
398
433
 
399
- // src/util/throw-error.js
400
- var throw_error_default = (code, { description, fix, ...extras } = {}) => {
401
- const message = description ? `${code}: ${description}` : code;
402
- const e = new Error(message);
403
- e.code = code;
404
- if (description) {
405
- e.description = description;
406
- }
407
- if (fix) {
408
- e.fix = fix;
434
+ // src/util/base64.js
435
+ var import_lodash = __toESM(require("lodash"), 1);
436
+ var encode = (data, options2 = { parseJson: true }) => {
437
+ let str = data;
438
+ if (typeof data !== "string" && options2.parseJson) {
439
+ try {
440
+ str = JSON.stringify(str);
441
+ } catch (e) {
442
+ console.log(e.message);
443
+ }
409
444
  }
410
- for (const key in extras) {
411
- e[key] = extras[key];
445
+ return Buffer.from(str, "utf-8").toString("base64");
446
+ };
447
+ var decode = (base64Data, options2 = { parseJson: true }) => {
448
+ let decodedValue = Buffer.from(base64Data, "base64").toString("utf-8");
449
+ if ((import_lodash.default.startsWith(decodedValue, "[") || import_lodash.default.startsWith(decodedValue, "{")) && options2.parseJson) {
450
+ try {
451
+ decodedValue = JSON.parse(decodedValue);
452
+ } catch (e) {
453
+ console.log(e.message);
454
+ }
412
455
  }
413
- throw e;
456
+ return decodedValue;
414
457
  };
415
458
 
416
- // src/util/base64.js
417
- var encode = (data) => Buffer.from(data, "utf-8").toString("base64");
418
- var decode = (base64Data) => Buffer.from(base64Data, "base64").toString("utf-8");
419
-
420
459
  // src/util/uuid.js
421
460
  var import_node_crypto = require("crypto");
422
461
  var uuid = () => (0, import_node_crypto.randomUUID)();
@@ -803,6 +842,21 @@ function cursor(value, options2 = {}) {
803
842
  return state;
804
843
  };
805
844
  }
845
+ function assert(expression, errorMessage) {
846
+ return (state) => {
847
+ const [resolvedValue, resolvedErrorMessage] = expandReferences(
848
+ state,
849
+ expression,
850
+ errorMessage
851
+ );
852
+ if (!resolvedValue) {
853
+ throw new Error(
854
+ resolvedErrorMessage || `assertion statement failed with ${resolvedValue}`
855
+ );
856
+ }
857
+ return state;
858
+ };
859
+ }
806
860
 
807
861
  // src/beta.js
808
862
  var beta_exports = {};
@@ -915,6 +969,7 @@ var src_default = Adaptor_exports;
915
969
  alterState,
916
970
  arrayToString,
917
971
  asData,
972
+ assert,
918
973
  beta,
919
974
  chunk,
920
975
  combine,
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ __export(Adaptor_exports, {
10
10
  alterState: () => alterState,
11
11
  arrayToString: () => arrayToString,
12
12
  asData: () => asData,
13
+ assert: () => assert,
13
14
  chunk: () => chunk,
14
15
  combine: () => combine,
15
16
  composeNextState: () => composeNextState,
@@ -81,6 +82,25 @@ import { getReasonPhrase } from "http-status-codes";
81
82
  import { Readable } from "stream";
82
83
  import querystring from "querystring";
83
84
  import path from "path";
85
+
86
+ // src/util/throw-error.js
87
+ var throw_error_default = (code, { description, fix, ...extras } = {}) => {
88
+ const message = description ? `${code}: ${description}` : code;
89
+ const e = new Error(message);
90
+ e.code = code;
91
+ if (description) {
92
+ e.description = description;
93
+ }
94
+ if (fix) {
95
+ e.fix = fix;
96
+ }
97
+ for (const key in extras) {
98
+ e[key] = extras[key];
99
+ }
100
+ throw e;
101
+ };
102
+
103
+ // src/util/http.js
84
104
  var clients = /* @__PURE__ */ new Map();
85
105
  var makeBasicAuthHeader = (username, password) => {
86
106
  const buff = Buffer.from(`${username}:${password}`);
@@ -242,16 +262,29 @@ function encodeRequestBody(body) {
242
262
  throw new Error("Unsupported body type");
243
263
  }
244
264
  async function readResponseBody(response, parseAs) {
245
- const contentType = response.headers["content-type"];
246
- switch (parseAs) {
247
- case "json":
248
- return response.body.json();
249
- case "text":
250
- return response.body.text();
251
- case "stream":
252
- return response.body;
253
- default:
254
- return contentType && contentType.includes("application/json") ? response.body.json() : response.body.text();
265
+ try {
266
+ const contentType = response.headers["content-type"];
267
+ if (+response.headers["content-length"] === 0) {
268
+ return void 0;
269
+ }
270
+ switch (parseAs) {
271
+ case "json":
272
+ return await response.body.json();
273
+ case "text":
274
+ return response.body.text();
275
+ case "stream":
276
+ return response.body;
277
+ default:
278
+ return contentType && contentType.includes("application/json") ? await response.body.json() : response.body.text();
279
+ }
280
+ } catch (error) {
281
+ throw_error_default(response.statusCode, {
282
+ description: "Error parsing the response body",
283
+ parseAs,
284
+ contentType: response.headers["content-type"],
285
+ bodyLength: +response.headers["content-length"],
286
+ error: error.message
287
+ });
255
288
  }
256
289
  }
257
290
  var get = (url, options2) => request("GET", url, options2);
@@ -276,7 +309,8 @@ var isStream = (value) => {
276
309
  return false;
277
310
  };
278
311
  function expandReference(state, value) {
279
- if (Buffer.isBuffer(value)) {
312
+ var _a;
313
+ if (Buffer.isBuffer(value) || ((_a = value == null ? void 0 : value.constructor) == null ? void 0 : _a.name) === "RegExp") {
280
314
  return value;
281
315
  }
282
316
  if (Array.isArray(value)) {
@@ -335,27 +369,31 @@ var parse_date_default = (d, startDate) => {
335
369
  return d;
336
370
  };
337
371
 
338
- // src/util/throw-error.js
339
- var throw_error_default = (code, { description, fix, ...extras } = {}) => {
340
- const message = description ? `${code}: ${description}` : code;
341
- const e = new Error(message);
342
- e.code = code;
343
- if (description) {
344
- e.description = description;
345
- }
346
- if (fix) {
347
- e.fix = fix;
372
+ // src/util/base64.js
373
+ import _ from "lodash";
374
+ var encode = (data, options2 = { parseJson: true }) => {
375
+ let str = data;
376
+ if (typeof data !== "string" && options2.parseJson) {
377
+ try {
378
+ str = JSON.stringify(str);
379
+ } catch (e) {
380
+ console.log(e.message);
381
+ }
348
382
  }
349
- for (const key in extras) {
350
- e[key] = extras[key];
383
+ return Buffer.from(str, "utf-8").toString("base64");
384
+ };
385
+ var decode = (base64Data, options2 = { parseJson: true }) => {
386
+ let decodedValue = Buffer.from(base64Data, "base64").toString("utf-8");
387
+ if ((_.startsWith(decodedValue, "[") || _.startsWith(decodedValue, "{")) && options2.parseJson) {
388
+ try {
389
+ decodedValue = JSON.parse(decodedValue);
390
+ } catch (e) {
391
+ console.log(e.message);
392
+ }
351
393
  }
352
- throw e;
394
+ return decodedValue;
353
395
  };
354
396
 
355
- // src/util/base64.js
356
- var encode = (data) => Buffer.from(data, "utf-8").toString("base64");
357
- var decode = (base64Data) => Buffer.from(base64Data, "base64").toString("utf-8");
358
-
359
397
  // src/util/uuid.js
360
398
  import { randomUUID } from "crypto";
361
399
  var uuid = () => randomUUID();
@@ -742,6 +780,21 @@ function cursor(value, options2 = {}) {
742
780
  return state;
743
781
  };
744
782
  }
783
+ function assert(expression, errorMessage) {
784
+ return (state) => {
785
+ const [resolvedValue, resolvedErrorMessage] = expandReferences(
786
+ state,
787
+ expression,
788
+ errorMessage
789
+ );
790
+ if (!resolvedValue) {
791
+ throw new Error(
792
+ resolvedErrorMessage || `assertion statement failed with ${resolvedValue}`
793
+ );
794
+ }
795
+ return state;
796
+ };
797
+ }
745
798
 
746
799
  // src/beta.js
747
800
  var beta_exports = {};
@@ -856,6 +909,7 @@ export {
856
909
  alterState,
857
910
  arrayToString,
858
911
  asData,
912
+ assert,
859
913
  beta_exports as beta,
860
914
  chunk,
861
915
  combine,
package/dist/util.cjs CHANGED
@@ -53,6 +53,25 @@ var import_http_status_codes = require("http-status-codes");
53
53
  var import_node_stream = require("stream");
54
54
  var import_node_querystring = __toESM(require("querystring"), 1);
55
55
  var import_node_path = __toESM(require("path"), 1);
56
+
57
+ // src/util/throw-error.js
58
+ var throw_error_default = (code, { description, fix, ...extras } = {}) => {
59
+ const message = description ? `${code}: ${description}` : code;
60
+ const e = new Error(message);
61
+ e.code = code;
62
+ if (description) {
63
+ e.description = description;
64
+ }
65
+ if (fix) {
66
+ e.fix = fix;
67
+ }
68
+ for (const key in extras) {
69
+ e[key] = extras[key];
70
+ }
71
+ throw e;
72
+ };
73
+
74
+ // src/util/http.js
56
75
  var clients = /* @__PURE__ */ new Map();
57
76
  var makeBasicAuthHeader = (username, password) => {
58
77
  const buff = Buffer.from(`${username}:${password}`);
@@ -214,16 +233,29 @@ function encodeRequestBody(body) {
214
233
  throw new Error("Unsupported body type");
215
234
  }
216
235
  async function readResponseBody(response, parseAs) {
217
- const contentType = response.headers["content-type"];
218
- switch (parseAs) {
219
- case "json":
220
- return response.body.json();
221
- case "text":
222
- return response.body.text();
223
- case "stream":
224
- return response.body;
225
- default:
226
- return contentType && contentType.includes("application/json") ? response.body.json() : response.body.text();
236
+ try {
237
+ const contentType = response.headers["content-type"];
238
+ if (+response.headers["content-length"] === 0) {
239
+ return void 0;
240
+ }
241
+ switch (parseAs) {
242
+ case "json":
243
+ return await response.body.json();
244
+ case "text":
245
+ return response.body.text();
246
+ case "stream":
247
+ return response.body;
248
+ default:
249
+ return contentType && contentType.includes("application/json") ? await response.body.json() : response.body.text();
250
+ }
251
+ } catch (error) {
252
+ throw_error_default(response.statusCode, {
253
+ description: "Error parsing the response body",
254
+ parseAs,
255
+ contentType: response.headers["content-type"],
256
+ bodyLength: +response.headers["content-length"],
257
+ error: error.message
258
+ });
227
259
  }
228
260
  }
229
261
  var get = (url, options) => request("GET", url, options);
@@ -248,7 +280,8 @@ var isStream = (value) => {
248
280
  return false;
249
281
  };
250
282
  function expandReference(state, value) {
251
- if (Buffer.isBuffer(value)) {
283
+ var _a;
284
+ if (Buffer.isBuffer(value) || ((_a = value == null ? void 0 : value.constructor) == null ? void 0 : _a.name) === "RegExp") {
252
285
  return value;
253
286
  }
254
287
  if (Array.isArray(value)) {
@@ -307,27 +340,31 @@ var parse_date_default = (d, startDate) => {
307
340
  return d;
308
341
  };
309
342
 
310
- // src/util/throw-error.js
311
- var throw_error_default = (code, { description, fix, ...extras } = {}) => {
312
- const message = description ? `${code}: ${description}` : code;
313
- const e = new Error(message);
314
- e.code = code;
315
- if (description) {
316
- e.description = description;
317
- }
318
- if (fix) {
319
- e.fix = fix;
343
+ // src/util/base64.js
344
+ var import_lodash = __toESM(require("lodash"), 1);
345
+ var encode = (data, options = { parseJson: true }) => {
346
+ let str = data;
347
+ if (typeof data !== "string" && options.parseJson) {
348
+ try {
349
+ str = JSON.stringify(str);
350
+ } catch (e) {
351
+ console.log(e.message);
352
+ }
320
353
  }
321
- for (const key in extras) {
322
- e[key] = extras[key];
354
+ return Buffer.from(str, "utf-8").toString("base64");
355
+ };
356
+ var decode = (base64Data, options = { parseJson: true }) => {
357
+ let decodedValue = Buffer.from(base64Data, "base64").toString("utf-8");
358
+ if ((import_lodash.default.startsWith(decodedValue, "[") || import_lodash.default.startsWith(decodedValue, "{")) && options.parseJson) {
359
+ try {
360
+ decodedValue = JSON.parse(decodedValue);
361
+ } catch (e) {
362
+ console.log(e.message);
363
+ }
323
364
  }
324
- throw e;
365
+ return decodedValue;
325
366
  };
326
367
 
327
- // src/util/base64.js
328
- var encode = (data) => Buffer.from(data, "utf-8").toString("base64");
329
- var decode = (base64Data) => Buffer.from(base64Data, "base64").toString("utf-8");
330
-
331
368
  // src/util/uuid.js
332
369
  var import_node_crypto = require("crypto");
333
370
  var uuid = () => (0, import_node_crypto.randomUUID)();
package/dist/util.js CHANGED
@@ -4,6 +4,25 @@ import { getReasonPhrase } from "http-status-codes";
4
4
  import { Readable } from "stream";
5
5
  import querystring from "querystring";
6
6
  import path from "path";
7
+
8
+ // src/util/throw-error.js
9
+ var throw_error_default = (code, { description, fix, ...extras } = {}) => {
10
+ const message = description ? `${code}: ${description}` : code;
11
+ const e = new Error(message);
12
+ e.code = code;
13
+ if (description) {
14
+ e.description = description;
15
+ }
16
+ if (fix) {
17
+ e.fix = fix;
18
+ }
19
+ for (const key in extras) {
20
+ e[key] = extras[key];
21
+ }
22
+ throw e;
23
+ };
24
+
25
+ // src/util/http.js
7
26
  var clients = /* @__PURE__ */ new Map();
8
27
  var makeBasicAuthHeader = (username, password) => {
9
28
  const buff = Buffer.from(`${username}:${password}`);
@@ -165,16 +184,29 @@ function encodeRequestBody(body) {
165
184
  throw new Error("Unsupported body type");
166
185
  }
167
186
  async function readResponseBody(response, parseAs) {
168
- const contentType = response.headers["content-type"];
169
- switch (parseAs) {
170
- case "json":
171
- return response.body.json();
172
- case "text":
173
- return response.body.text();
174
- case "stream":
175
- return response.body;
176
- default:
177
- return contentType && contentType.includes("application/json") ? response.body.json() : response.body.text();
187
+ try {
188
+ const contentType = response.headers["content-type"];
189
+ if (+response.headers["content-length"] === 0) {
190
+ return void 0;
191
+ }
192
+ switch (parseAs) {
193
+ case "json":
194
+ return await response.body.json();
195
+ case "text":
196
+ return response.body.text();
197
+ case "stream":
198
+ return response.body;
199
+ default:
200
+ return contentType && contentType.includes("application/json") ? await response.body.json() : response.body.text();
201
+ }
202
+ } catch (error) {
203
+ throw_error_default(response.statusCode, {
204
+ description: "Error parsing the response body",
205
+ parseAs,
206
+ contentType: response.headers["content-type"],
207
+ bodyLength: +response.headers["content-length"],
208
+ error: error.message
209
+ });
178
210
  }
179
211
  }
180
212
  var get = (url, options) => request("GET", url, options);
@@ -199,7 +231,8 @@ var isStream = (value) => {
199
231
  return false;
200
232
  };
201
233
  function expandReference(state, value) {
202
- if (Buffer.isBuffer(value)) {
234
+ var _a;
235
+ if (Buffer.isBuffer(value) || ((_a = value == null ? void 0 : value.constructor) == null ? void 0 : _a.name) === "RegExp") {
203
236
  return value;
204
237
  }
205
238
  if (Array.isArray(value)) {
@@ -258,27 +291,31 @@ var parse_date_default = (d, startDate) => {
258
291
  return d;
259
292
  };
260
293
 
261
- // src/util/throw-error.js
262
- var throw_error_default = (code, { description, fix, ...extras } = {}) => {
263
- const message = description ? `${code}: ${description}` : code;
264
- const e = new Error(message);
265
- e.code = code;
266
- if (description) {
267
- e.description = description;
268
- }
269
- if (fix) {
270
- e.fix = fix;
294
+ // src/util/base64.js
295
+ import _ from "lodash";
296
+ var encode = (data, options = { parseJson: true }) => {
297
+ let str = data;
298
+ if (typeof data !== "string" && options.parseJson) {
299
+ try {
300
+ str = JSON.stringify(str);
301
+ } catch (e) {
302
+ console.log(e.message);
303
+ }
271
304
  }
272
- for (const key in extras) {
273
- e[key] = extras[key];
305
+ return Buffer.from(str, "utf-8").toString("base64");
306
+ };
307
+ var decode = (base64Data, options = { parseJson: true }) => {
308
+ let decodedValue = Buffer.from(base64Data, "base64").toString("utf-8");
309
+ if ((_.startsWith(decodedValue, "[") || _.startsWith(decodedValue, "{")) && options.parseJson) {
310
+ try {
311
+ decodedValue = JSON.parse(decodedValue);
312
+ } catch (e) {
313
+ console.log(e.message);
314
+ }
274
315
  }
275
- throw e;
316
+ return decodedValue;
276
317
  };
277
318
 
278
- // src/util/base64.js
279
- var encode = (data) => Buffer.from(data, "utf-8").toString("base64");
280
- var decode = (base64Data) => Buffer.from(base64Data, "base64").toString("utf-8");
281
-
282
319
  // src/util/uuid.js
283
320
  import { randomUUID } from "crypto";
284
321
  var uuid = () => randomUUID();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-common",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Common Expressions for OpenFn",
5
5
  "homepage": "https://docs.openfn.org",
6
6
  "repository": {
@@ -423,6 +423,17 @@ export function cursor(value: any, options?: {
423
423
  defaultValue: any;
424
424
  format: Function;
425
425
  }): Operation;
426
+ /**
427
+ * Asserts the given expression or function resolves to `true`, or else throws an exception. Optionally accepts and error message.
428
+ * @public
429
+ * @function
430
+ * @example
431
+ * assert('a' === 'b', '"a" is not equal to "b"')
432
+ * @param {any} expression - The expression or function to be evaluated.
433
+ * @param {string} errorMessage - The error message thrown in case of a failed state.
434
+ * @returns {operation}
435
+ */
436
+ export function assert(expression: any, errorMessage: string): operation;
426
437
  /**
427
438
  * Scopes an array of data based on a JSONPath.
428
439
  * Useful when the source data has `n` items you would like to map to
@@ -1,2 +1,2 @@
1
- export function encode(data: string): string;
2
- export function decode(base64Data: string): string;
1
+ export function encode(data: string | object, options?: object): string;
2
+ export function decode(base64Data: string, options?: object): string | object;