@openfn/language-common 1.4.1 → 1.6.1

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/CHANGELOG.md ADDED
@@ -0,0 +1,18 @@
1
+ v0.4.0
2
+ ======
3
+
4
+ Bumped all package versions to their latest.
5
+
6
+ v0.0.4
7
+ ======
8
+
9
+ * Added `arrayToString` helper.
10
+ Allowing you to join an array of string'able primitives (strings and integers)
11
+ into a string.
12
+ * Added `toArray` helper.
13
+ This can be used to coerce certain types of data into an array, this can be
14
+ useful when the source data has an ambiguous format. For example a given
15
+ key in the data may have an object as it's value (when there is only one item),
16
+ and an array of objects when there is more than one. `toArray` can be used
17
+ to reconcile this inconsistency.
18
+
package/ast.json CHANGED
@@ -903,7 +903,7 @@
903
903
  "str"
904
904
  ],
905
905
  "docs": {
906
- "description": "Subsitutes underscores for spaces and proper-cases a string",
906
+ "description": "Substitutes underscores for spaces and proper-cases a string",
907
907
  "tags": [
908
908
  {
909
909
  "title": "public",
@@ -940,6 +940,59 @@
940
940
  },
941
941
  "valid": true
942
942
  },
943
+ {
944
+ "name": "scrubEmojis",
945
+ "params": [
946
+ "text",
947
+ "replacementChars"
948
+ ],
949
+ "docs": {
950
+ "description": "Replaces emojis in a string.",
951
+ "tags": [
952
+ {
953
+ "title": "public",
954
+ "description": null,
955
+ "type": null
956
+ },
957
+ {
958
+ "title": "example",
959
+ "description": "scrubEmojis('Dove🕊️⭐ 29')"
960
+ },
961
+ {
962
+ "title": "function",
963
+ "description": null,
964
+ "name": null
965
+ },
966
+ {
967
+ "title": "param",
968
+ "description": "String that needs to be cleaned",
969
+ "type": {
970
+ "type": "NameExpression",
971
+ "name": "string"
972
+ },
973
+ "name": "text"
974
+ },
975
+ {
976
+ "title": "param",
977
+ "description": "Characters that replace the emojis",
978
+ "type": {
979
+ "type": "NameExpression",
980
+ "name": "string"
981
+ },
982
+ "name": "replacementChars"
983
+ },
984
+ {
985
+ "title": "returns",
986
+ "description": null,
987
+ "type": {
988
+ "type": "NameExpression",
989
+ "name": "string"
990
+ }
991
+ }
992
+ ]
993
+ },
994
+ "valid": true
995
+ },
943
996
  {
944
997
  "name": "map",
945
998
  "params": [
package/lib/Adaptor.js CHANGED
@@ -26,6 +26,7 @@ exports.toArray = toArray;
26
26
  exports.composeNextState = composeNextState;
27
27
  exports.humanProper = humanProper;
28
28
  exports.splitKeys = splitKeys;
29
+ exports.scrubEmojis = scrubEmojis;
29
30
  exports.http = exports.beta = exports.map = void 0;
30
31
 
31
32
  var _fp = require("lodash/fp");
@@ -532,7 +533,7 @@ function composeNextState(state, response) {
532
533
  };
533
534
  }
534
535
  /**
535
- * Subsitutes underscores for spaces and proper-cases a string
536
+ * Substitutes underscores for spaces and proper-cases a string
536
537
  * @public
537
538
  * @example
538
539
  * field("destination_string__c", humanProper(state.data.path_to_string))
@@ -566,4 +567,23 @@ function splitKeys(obj, keys) {
566
567
  [key]: value
567
568
  }, split];
568
569
  }, [{}, {}]);
570
+ }
571
+ /**
572
+ * Replaces emojis in a string.
573
+ * @public
574
+ * @example
575
+ * scrubEmojis('Dove🕊️⭐ 29')
576
+ * @function
577
+ * @param {string} text - String that needs to be cleaned
578
+ * @param {string} replacementChars - Characters that replace the emojis
579
+ * @returns {string}
580
+ */
581
+
582
+
583
+ function scrubEmojis(text, replacementChars) {
584
+ if (!text) return text;
585
+ if (!replacementChars) replacementChars = '\uFFFD';
586
+ if (replacementChars == '') console.warn('Removing characters from a string may create injection vulnerabilities;', "It's better to replace than remove.", 'See https://www.unicode.org/reports/tr36/#Deletion_of_Noncharacters');
587
+ const emojisPattern = /(\uFE0F|\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g;
588
+ return text.replace(emojisPattern, replacementChars);
569
589
  }
@@ -1,18 +1,109 @@
1
1
  # Changelog
2
2
 
3
+ ### 0.21.4 (September 6, 2021)
4
+
5
+ Fixes and Functionality:
6
+ - Fixing JSON transform when data is stringified. Providing backward compatibility and complying to the JSON RFC standard ([#4020](https://github.com/axios/axios/pull/4020))
7
+
8
+ Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:
9
+
10
+ - [Jay](mailto:jasonsaayman@gmail.com)
11
+ - [Guillaume Fortaine](https://github.com/gfortaine)
12
+ - [Yusuke Kawasaki](https://github.com/kawanet)
13
+ - [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS)
14
+
15
+ ### 0.21.3 (September 4, 2021)
16
+
17
+ Fixes and Functionality:
18
+ - Fixing response interceptor not being called when request interceptor is attached ([#4013](https://github.com/axios/axios/pull/4013))
19
+
20
+ Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:
21
+
22
+ - [Jay](mailto:jasonsaayman@gmail.com)
23
+ - [Julian Hollmann](https://github.com/nerdbeere)
24
+
25
+ ### 0.21.2 (September 4, 2021)
26
+
27
+ Fixes and Functionality:
28
+
29
+ - Updating axios requests to be delayed by pre-emptive promise creation ([#2702](https://github.com/axios/axios/pull/2702))
30
+ - Adding "synchronous" and "runWhen" options to interceptors api ([#2702](https://github.com/axios/axios/pull/2702))
31
+ - Updating of transformResponse ([#3377](https://github.com/axios/axios/pull/3377))
32
+ - Adding ability to omit User-Agent header ([#3703](https://github.com/axios/axios/pull/3703))
33
+ - Adding multiple JSON improvements ([#3688](https://github.com/axios/axios/pull/3688), [#3763](https://github.com/axios/axios/pull/3763))
34
+ - Fixing quadratic runtime and extra memory usage when setting a maxContentLength ([#3738](https://github.com/axios/axios/pull/3738))
35
+ - Adding parseInt to config.timeout ([#3781](https://github.com/axios/axios/pull/3781))
36
+ - Adding custom return type support to interceptor ([#3783](https://github.com/axios/axios/pull/3783))
37
+ - Adding security fix for ReDoS vulnerability ([#3980](https://github.com/axios/axios/pull/3980))
38
+
39
+ Internal and Tests:
40
+
41
+ - Updating build dev dependancies ([#3401](https://github.com/axios/axios/pull/3401))
42
+ - Fixing builds running on Travis CI ([#3538](https://github.com/axios/axios/pull/3538))
43
+ - Updating follow rediect version ([#3694](https://github.com/axios/axios/pull/3694), [#3771](https://github.com/axios/axios/pull/3771))
44
+ - Updating karma sauce launcher to fix failing sauce tests ([#3712](https://github.com/axios/axios/pull/3712), [#3717](https://github.com/axios/axios/pull/3717))
45
+ - Updating content-type header for application/json to not contain charset field, according do RFC 8259 ([#2154](https://github.com/axios/axios/pull/2154))
46
+ - Fixing tests by bumping karma-sauce-launcher version ([#3813](https://github.com/axios/axios/pull/3813))
47
+ - Changing testing process from Travis CI to GitHub Actions ([#3938](https://github.com/axios/axios/pull/3938))
48
+
49
+ Documentation:
50
+
51
+ - Updating documentation around the use of `AUTH_TOKEN` with multiple domain endpoints ([#3539](https://github.com/axios/axios/pull/3539))
52
+ - Remove duplication of item in changelog ([#3523](https://github.com/axios/axios/pull/3523))
53
+ - Fixing gramatical errors ([#2642](https://github.com/axios/axios/pull/2642))
54
+ - Fixing spelling error ([#3567](https://github.com/axios/axios/pull/3567))
55
+ - Moving gitpod metion ([#2637](https://github.com/axios/axios/pull/2637))
56
+ - Adding new axios documentation website link ([#3681](https://github.com/axios/axios/pull/3681), [#3707](https://github.com/axios/axios/pull/3707))
57
+ - Updating documentation around dispatching requests ([#3772](https://github.com/axios/axios/pull/3772))
58
+ - Adding documentation for the type guard isAxiosError ([#3767](https://github.com/axios/axios/pull/3767))
59
+ - Adding explanation of cancel token ([#3803](https://github.com/axios/axios/pull/3803))
60
+ - Updating CI status badge ([#3953](https://github.com/axios/axios/pull/3953))
61
+ - Fixing errors with JSON documentation ([#3936](https://github.com/axios/axios/pull/3936))
62
+ - Fixing README typo under Request Config ([#3825](https://github.com/axios/axios/pull/3825))
63
+ - Adding axios-multi-api to the ecosystem file ([#3817](https://github.com/axios/axios/pull/3817))
64
+ - Adding SECURITY.md to properly disclose security vulnerabilities ([#3981](https://github.com/axios/axios/pull/3981))
65
+
66
+ Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:
67
+
68
+ - [Jay](mailto:jasonsaayman@gmail.com)
69
+ - [Sasha Korotkov](https://github.com/SashaKoro)
70
+ - [Daniel Lopretto](https://github.com/timemachine3030)
71
+ - [Mike Bishop](https://github.com/MikeBishop)
72
+ - [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS)
73
+ - [Mark](https://github.com/bimbiltu)
74
+ - [Philipe Gouveia Paixão](https://github.com/piiih)
75
+ - [hippo](https://github.com/hippo2cat)
76
+ - [ready-research](https://github.com/ready-research)
77
+ - [Xianming Zhong](https://github.com/chinesedfan)
78
+ - [Christopher Chrapka](https://github.com/OJezu)
79
+ - [Brian Anglin](https://github.com/anglinb)
80
+ - [Kohta Ito](https://github.com/koh110)
81
+ - [Ali Clark](https://github.com/aliclark)
82
+ - [caikan](https://github.com/caikan)
83
+ - [Elina Gorshkova](https://github.com/elinagorshkova)
84
+ - [Ryota Ikezawa](https://github.com/paveg)
85
+ - [Nisar Hassan Naqvi](https://github.com/nisarhassan12)
86
+ - [Jake](https://github.com/codemaster138)
87
+ - [TagawaHirotaka](https://github.com/wafuwafu13)
88
+ - [Johannes Jarbratt](https://github.com/johachi)
89
+ - [Mo Sattler](https://github.com/MoSattler)
90
+ - [Sam Carlton](https://github.com/ThatGuySam)
91
+ - [Matt Czapliński](https://github.com/MattCCC)
92
+ - [Ziding Zhang](https://github.com/zidingz)
93
+
3
94
  ### 0.21.1 (December 21, 2020)
4
95
 
5
96
  Fixes and Functionality:
6
97
 
7
- - Hotfix: Prevent SSRF (#3410)
8
- - Protocol not parsed when setting proxy config from env vars (#3070)
9
- - Updating axios in types to be lower case (#2797)
10
- - Adding a type guard for `AxiosError` (#2949)
98
+ - Hotfix: Prevent SSRF ([#3410](https://github.com/axios/axios/pull/3410))
99
+ - Protocol not parsed when setting proxy config from env vars ([#3070](https://github.com/axios/axios/pull/3070))
100
+ - Updating axios in types to be lower case ([#2797](https://github.com/axios/axios/pull/2797))
101
+ - Adding a type guard for `AxiosError` ([#2949](https://github.com/axios/axios/pull/2949))
11
102
 
12
103
  Internal and Tests:
13
104
 
14
- - Remove the skipping of the `socket` http test (#3364)
15
- - Use different socket for Win32 test (#3375)
105
+ - Remove the skipping of the `socket` http test ([#3364](https://github.com/axios/axios/pull/3364))
106
+ - Use different socket for Win32 test ([#3375](https://github.com/axios/axios/pull/3375))
16
107
 
17
108
  Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:
18
109
 
@@ -93,7 +184,7 @@ Fixes and Functionality:
93
184
  - Adding test to check if password with non-Latin1 characters pass
94
185
  - Fixing 'Network Error' in react native android ([#1487](https://github.com/axios/axios/pull/1487))
95
186
  There is a bug in react native Android platform when using get method. It will trigger a 'Network Error' when passing the requestData which is an empty string to request.send function. So if the requestData is an empty string we can set it to null as well to fix the bug.
96
- - Fixing Cookie Helper with Asyc Components ([#1105](https://github.com/axios/axios/pull/1105)) ([#1107](https://github.com/axios/axios/pull/1107))
187
+ - Fixing Cookie Helper with Async Components ([#1105](https://github.com/axios/axios/pull/1105)) ([#1107](https://github.com/axios/axios/pull/1107))
97
188
  - Fixing 'progressEvent' type ([#2851](https://github.com/axios/axios/pull/2851))
98
189
  - Fix 'progressEvent' type
99
190
  - Update axios.ts
@@ -305,7 +396,6 @@ Fixes and Functionality:
305
396
  - Fixing set `config.method` after mergeConfig for Axios.prototype.request ([#2383](https://github.com/axios/axios/pull/2383))
306
397
  - Axios create url bug ([#2290](https://github.com/axios/axios/pull/2290))
307
398
  - Do not modify config.url when using a relative baseURL (resolves [#1628](https://github.com/axios/axios/issues/1098)) ([#2391](https://github.com/axios/axios/pull/2391))
308
- - Add typescript HTTP method definition for LINK and UNLINK ([#2444](https://github.com/axios/axios/pull/2444))
309
399
 
310
400
  Internal:
311
401
 
@@ -2,7 +2,8 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/axios.svg?style=flat-square)](https://www.npmjs.org/package/axios)
4
4
  [![CDNJS](https://img.shields.io/cdnjs/v/axios.svg?style=flat-square)](https://cdnjs.com/libraries/axios)
5
- [![build status](https://img.shields.io/travis/axios/axios/master.svg?style=flat-square)](https://travis-ci.org/axios/axios)
5
+ ![Build status](https://github.com/axios/axios/actions/workflows/ci.yml/badge.svg)
6
+ [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/axios/axios)
6
7
  [![code coverage](https://img.shields.io/coveralls/mzabriskie/axios.svg?style=flat-square)](https://coveralls.io/r/mzabriskie/axios)
7
8
  [![install size](https://packagephobia.now.sh/badge?p=axios)](https://packagephobia.now.sh/result?p=axios)
8
9
  [![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](http://npm-stat.com/charts.html?package=axios)
@@ -10,6 +11,9 @@
10
11
  [![code helpers](https://www.codetriage.com/axios/axios/badges/users.svg)](https://www.codetriage.com/axios/axios)
11
12
 
12
13
  Promise based HTTP client for the browser and node.js
14
+
15
+ > New axios docs website: [click here](https://axios-http.com/)
16
+
13
17
  ## Table of Contents
14
18
 
15
19
  - [Features](#features)
@@ -452,8 +456,21 @@ These are the available config options for making requests. Only the `url` is re
452
456
  // automatically. If set to `true` will also remove the 'content-encoding' header
453
457
  // from the responses objects of all decompressed responses
454
458
  // - Node only (XHR cannot turn off decompression)
455
- decompress: true // default
456
-
459
+ decompress: true, // default
460
+
461
+ // transitional options for backward compatibility that may be removed in the newer versions
462
+ transitional: {
463
+ // silent JSON parsing mode
464
+ // `true` - ignore JSON parsing errors and set response.data to null if parsing failed (old behaviour)
465
+ // `false` - throw SyntaxError if JSON parsing failed (Note: responseType must be set to 'json')
466
+ silentJSONParsing: true, // default value for the current Axios version
467
+
468
+ // try to parse the response string as JSON even if `responseType` is not 'json'
469
+ forcedJSONParsing: true,
470
+
471
+ // throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts
472
+ clarifyTimeoutError: false,
473
+ }
457
474
  }
458
475
  ```
459
476
 
@@ -510,7 +527,11 @@ You can specify config defaults that will be applied to every request.
510
527
 
511
528
  ```js
512
529
  axios.defaults.baseURL = 'https://api.example.com';
530
+
531
+ // Important: If axios is used with multiple domains, the AUTH_TOKEN will be sent to all of them.
532
+ // See below for an example using Custom instance defaults instead.
513
533
  axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
534
+
514
535
  axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
515
536
  ```
516
537
 
@@ -585,6 +606,34 @@ const instance = axios.create();
585
606
  instance.interceptors.request.use(function () {/*...*/});
586
607
  ```
587
608
 
609
+ When you add request interceptors, they are presumed to be asynchronous by default. This can cause a delay
610
+ in the execution of your axios request when the main thread is blocked (a promise is created under the hood for
611
+ the interceptor and your request gets put on the bottom of the call stack). If your request interceptors are synchronous you can add a flag
612
+ to the options object that will tell axios to run the code synchronously and avoid any delays in request execution.
613
+
614
+ ```js
615
+ axios.interceptors.request.use(function (config) {
616
+ config.headers.test = 'I am only a header!';
617
+ return config;
618
+ }, null, { synchronous: true });
619
+ ```
620
+
621
+ If you want to execute a particular interceptor based on a runtime check,
622
+ you can add a `runWhen` function to the options object. The interceptor will not be executed **if and only if** the return
623
+ of `runWhen` is `false`. The function will be called with the config
624
+ object (don't forget that you can bind your own arguments to it as well.) This can be handy when you have an
625
+ asynchronous request interceptor that only needs to run at certain times.
626
+
627
+ ```js
628
+ function onGetCall(config) {
629
+ return config.method === 'get';
630
+ }
631
+ axios.interceptors.request.use(function (config) {
632
+ config.headers.test = 'special get headers';
633
+ return config;
634
+ }, null, { runWhen: onGetCall });
635
+ ```
636
+
588
637
  ## Handling Errors
589
638
 
590
639
  ```js
@@ -678,6 +727,7 @@ cancel();
678
727
  ```
679
728
 
680
729
  > Note: you can cancel several requests with the same cancel token.
730
+ > If a cancellation token is already cancelled at the moment of starting an Axios request, then the request is cancelled immediately, without any attempts to make real request.
681
731
 
682
732
  ## Using application/x-www-form-urlencoded format
683
733
 
@@ -777,12 +827,30 @@ axios depends on a native ES6 Promise implementation to be [supported](http://ca
777
827
  If your environment doesn't support ES6 Promises, you can [polyfill](https://github.com/jakearchibald/es6-promise).
778
828
 
779
829
  ## TypeScript
780
- axios includes [TypeScript](http://typescriptlang.org) definitions.
830
+
831
+ axios includes [TypeScript](http://typescriptlang.org) definitions and a type guard for axios errors.
832
+
781
833
  ```typescript
782
- import axios from 'axios';
783
- axios.get('/user?ID=12345');
834
+ let user: User = null;
835
+ try {
836
+ const { data } = await axios.get('/user?ID=12345');
837
+ user = data.userDetails;
838
+ } catch (error) {
839
+ if (axios.isAxiosError(error)) {
840
+ handleAxiosError(error);
841
+ } else {
842
+ handleUnexpectedError(error);
843
+ }
844
+ }
784
845
  ```
785
846
 
847
+ ## Online one-click setup
848
+
849
+ You can use Gitpod an online IDE(which is free for Open Source) for contributing or running the examples online.
850
+
851
+ [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/axios/axios/blob/master/examples/server.js)
852
+
853
+
786
854
  ## Resources
787
855
 
788
856
  * [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md)
@@ -0,0 +1,5 @@
1
+ # Security Policy
2
+
3
+ ## Reporting a Vulnerability
4
+
5
+ Please report security issues to jasonsaayman@gmail.com