@openfn/language-http 6.2.1 → 6.2.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/ast.json +10 -1
- package/configuration-schema.json +7 -15
- package/dist/index.cjs +9 -4
- package/dist/index.js +9 -4
- package/package.json +3 -3
- package/types/Utils.d.ts +1 -1
package/ast.json
CHANGED
|
@@ -1312,7 +1312,7 @@
|
|
|
1312
1312
|
"options"
|
|
1313
1313
|
],
|
|
1314
1314
|
"docs": {
|
|
1315
|
-
"description": "Sets a cursor property on state.\nSupports natural language dates like `now`, `today`, `yesterday`, `n hours ago`, `n days ago`, and `start`,\nwhich will be converted relative to the environment (ie, the Lightning or CLI locale). Custom timezones \nare not yet supported.\nSee the usage guide at {@link https://docs.openfn.org/documentation/jobs/job-writing-guide#using-cursors}",
|
|
1315
|
+
"description": "Sets a cursor property on state.\nSupports natural language dates like `now`, `today`, `yesterday`, `n hours ago`, `n days ago`, and `start`,\nwhich will be converted relative to the environment (ie, the Lightning or CLI locale). Custom timezones \nare not yet supported.\nYou can provide a formatter to customise the final cursor value, which is useful for normalising\ndifferent inputs. The custom formatter runs after natural language date conversion.\nSee the usage guide at {@link https://docs.openfn.org/documentation/jobs/job-writing-guide#using-cursors}",
|
|
1316
1316
|
"tags": [
|
|
1317
1317
|
{
|
|
1318
1318
|
"title": "public",
|
|
@@ -1370,6 +1370,15 @@
|
|
|
1370
1370
|
},
|
|
1371
1371
|
"name": "options.defaultValue"
|
|
1372
1372
|
},
|
|
1373
|
+
{
|
|
1374
|
+
"title": "param",
|
|
1375
|
+
"description": "custom formatter for the final cursor value",
|
|
1376
|
+
"type": {
|
|
1377
|
+
"type": "NameExpression",
|
|
1378
|
+
"name": "Function"
|
|
1379
|
+
},
|
|
1380
|
+
"name": "options.format"
|
|
1381
|
+
},
|
|
1373
1382
|
{
|
|
1374
1383
|
"title": "returns",
|
|
1375
1384
|
"description": null,
|
|
@@ -5,27 +5,21 @@
|
|
|
5
5
|
"title": "Username",
|
|
6
6
|
"type": "string",
|
|
7
7
|
"description": "Username",
|
|
8
|
-
"examples": [
|
|
9
|
-
"test@openfn.org"
|
|
10
|
-
]
|
|
8
|
+
"examples": ["test@openfn.org"]
|
|
11
9
|
},
|
|
12
10
|
"password": {
|
|
13
11
|
"title": "Password",
|
|
14
12
|
"type": "string",
|
|
15
13
|
"description": "Password",
|
|
16
14
|
"writeOnly": true,
|
|
17
|
-
"examples": [
|
|
18
|
-
"@some(!)Password"
|
|
19
|
-
]
|
|
15
|
+
"examples": ["@some(!)Password"]
|
|
20
16
|
},
|
|
21
|
-
"
|
|
22
|
-
"title": "Token",
|
|
17
|
+
"access_token": {
|
|
18
|
+
"title": "Access Token",
|
|
23
19
|
"type": "string",
|
|
24
|
-
"description": "
|
|
20
|
+
"description": "OAuth Access token, API key or other Bearer token",
|
|
25
21
|
"writeOnly": true,
|
|
26
|
-
"examples": [
|
|
27
|
-
"00QCjAl4MlV-WPX"
|
|
28
|
-
]
|
|
22
|
+
"examples": ["00QCjAl4MlV-WPX"]
|
|
29
23
|
},
|
|
30
24
|
"baseUrl": {
|
|
31
25
|
"title": "Base URL",
|
|
@@ -40,9 +34,7 @@
|
|
|
40
34
|
"description": "The base URL (http://www.example.com)",
|
|
41
35
|
"format": "uri",
|
|
42
36
|
"minLength": 1,
|
|
43
|
-
"examples": [
|
|
44
|
-
"https://instance_name.surveycto.com"
|
|
45
|
-
]
|
|
37
|
+
"examples": ["https://instance_name.surveycto.com"]
|
|
46
38
|
}
|
|
47
39
|
},
|
|
48
40
|
"type": "object",
|
package/dist/index.cjs
CHANGED
|
@@ -96,9 +96,14 @@ var import_language_common = require("@openfn/language-common");
|
|
|
96
96
|
var import_util = require("@openfn/language-common/util");
|
|
97
97
|
var cheerio = __toESM(require("cheerio"), 1);
|
|
98
98
|
var import_cheerio_tableparser = __toESM(require("cheerio-tableparser"), 1);
|
|
99
|
-
function
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
function addAuth(configuration = {}, headers) {
|
|
100
|
+
if (headers.Authorization) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const { username, password, access_token } = configuration;
|
|
104
|
+
if (access_token) {
|
|
105
|
+
Object.assign(headers, { Authorization: `Bearer ${access_token}` });
|
|
106
|
+
} else if (username && password) {
|
|
102
107
|
Object.assign(headers, (0, import_util.makeBasicAuthHeader)(username, password));
|
|
103
108
|
}
|
|
104
109
|
}
|
|
@@ -128,7 +133,7 @@ function request(method, path, params, callback = (s) => s) {
|
|
|
128
133
|
body = encodeFormBody(resolvedParams.form);
|
|
129
134
|
}
|
|
130
135
|
const baseUrl = (_a = state.configuration) == null ? void 0 : _a.baseUrl;
|
|
131
|
-
|
|
136
|
+
addAuth(state.configuration, headers);
|
|
132
137
|
const maxRedirections = resolvedParams.maxRedirections ?? (resolvedParams.followAllRedirects === false ? 0 : 5);
|
|
133
138
|
const tls = resolvedParams.tls ?? resolvedParams.agentOptions;
|
|
134
139
|
if (resolvedParams.agentOptions) {
|
package/dist/index.js
CHANGED
|
@@ -48,9 +48,14 @@ import {
|
|
|
48
48
|
} from "@openfn/language-common/util";
|
|
49
49
|
import * as cheerio from "cheerio";
|
|
50
50
|
import cheerioTableparser from "cheerio-tableparser";
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
function addAuth(configuration = {}, headers) {
|
|
52
|
+
if (headers.Authorization) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const { username, password, access_token } = configuration;
|
|
56
|
+
if (access_token) {
|
|
57
|
+
Object.assign(headers, { Authorization: `Bearer ${access_token}` });
|
|
58
|
+
} else if (username && password) {
|
|
54
59
|
Object.assign(headers, makeBasicAuthHeader(username, password));
|
|
55
60
|
}
|
|
56
61
|
}
|
|
@@ -80,7 +85,7 @@ function request(method, path, params, callback = (s) => s) {
|
|
|
80
85
|
body = encodeFormBody(resolvedParams.form);
|
|
81
86
|
}
|
|
82
87
|
const baseUrl = (_a = state.configuration) == null ? void 0 : _a.baseUrl;
|
|
83
|
-
|
|
88
|
+
addAuth(state.configuration, headers);
|
|
84
89
|
const maxRedirections = resolvedParams.maxRedirections ?? (resolvedParams.followAllRedirects === false ? 0 : 5);
|
|
85
90
|
const tls = resolvedParams.tls ?? resolvedParams.agentOptions;
|
|
86
91
|
if (resolvedParams.agentOptions) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/language-http",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.3",
|
|
4
4
|
"description": "An HTTP request language package for use with Open Function",
|
|
5
5
|
"homepage": "https://docs.openfn.org",
|
|
6
6
|
"repository": {
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"configuration-schema.json"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@openfn/language-common": "^1.12.0",
|
|
29
28
|
"cheerio": "1.0.0-rc.12",
|
|
30
|
-
"cheerio-tableparser": "^1.0.1"
|
|
29
|
+
"cheerio-tableparser": "^1.0.1",
|
|
30
|
+
"@openfn/language-common": "1.13.5"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@openfn/simple-ast": "0.4.1",
|
package/types/Utils.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function addAuth(configuration: {}, headers: any): void;
|
|
2
2
|
export function request(method: any, path: any, params: any, callback?: (s: any) => any): (state: any) => any;
|
|
3
3
|
export function xmlParser(body: any, script: any, callback?: (s: any) => any): (state: any) => any;
|