@openfn/language-http 6.4.1 → 6.4.2

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
@@ -116,7 +116,7 @@
116
116
  "callback"
117
117
  ],
118
118
  "docs": {
119
- "description": "Make a HTTP request",
119
+ "description": "Make a HTTP request. If `configuration.baseUrl` is set, paths must be relative.",
120
120
  "tags": [
121
121
  {
122
122
  "title": "public",
@@ -134,7 +134,7 @@
134
134
  },
135
135
  {
136
136
  "title": "param",
137
- "description": "The HTTP method to use",
137
+ "description": "The HTTP method to use.",
138
138
  "type": {
139
139
  "type": "NameExpression",
140
140
  "name": "string"
@@ -143,7 +143,7 @@
143
143
  },
144
144
  {
145
145
  "title": "param",
146
- "description": "Path to resource",
146
+ "description": "Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.",
147
147
  "type": {
148
148
  "type": "NameExpression",
149
149
  "name": "string"
@@ -192,7 +192,7 @@
192
192
  "callback"
193
193
  ],
194
194
  "docs": {
195
- "description": "Make a GET request",
195
+ "description": "Make a GET request. If `configuration.baseUrl` is set, paths must be relative.",
196
196
  "tags": [
197
197
  {
198
198
  "title": "public",
@@ -210,7 +210,7 @@
210
210
  },
211
211
  {
212
212
  "title": "param",
213
- "description": "Path to resource",
213
+ "description": "Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.",
214
214
  "type": {
215
215
  "type": "NameExpression",
216
216
  "name": "string"
@@ -259,7 +259,7 @@
259
259
  "callback"
260
260
  ],
261
261
  "docs": {
262
- "description": "Make a POST request",
262
+ "description": "Make a POST request. If `configuration.baseUrl` is set, paths must be relative.",
263
263
  "tags": [
264
264
  {
265
265
  "title": "public",
@@ -277,7 +277,7 @@
277
277
  },
278
278
  {
279
279
  "title": "param",
280
- "description": "Path to resource",
280
+ "description": "Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.",
281
281
  "type": {
282
282
  "type": "NameExpression",
283
283
  "name": "string"
@@ -326,7 +326,7 @@
326
326
  "callback"
327
327
  ],
328
328
  "docs": {
329
- "description": "Make a PUT request",
329
+ "description": "Make a PUT request. If `configuration.baseUrl` is set, paths must be relative.",
330
330
  "tags": [
331
331
  {
332
332
  "title": "public",
@@ -344,7 +344,7 @@
344
344
  },
345
345
  {
346
346
  "title": "param",
347
- "description": "Path to resource",
347
+ "description": "Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.",
348
348
  "type": {
349
349
  "type": "NameExpression",
350
350
  "name": "string"
@@ -393,7 +393,7 @@
393
393
  "callback"
394
394
  ],
395
395
  "docs": {
396
- "description": "Make a PATCH request",
396
+ "description": "Make a PATCH request. If `configuration.baseUrl` is set, paths must be relative.",
397
397
  "tags": [
398
398
  {
399
399
  "title": "public",
@@ -411,7 +411,7 @@
411
411
  },
412
412
  {
413
413
  "title": "param",
414
- "description": "Path to resource",
414
+ "description": "Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.",
415
415
  "type": {
416
416
  "type": "NameExpression",
417
417
  "name": "string"
@@ -460,7 +460,7 @@
460
460
  "callback"
461
461
  ],
462
462
  "docs": {
463
- "description": "Make a DELETE request",
463
+ "description": "Make a DELETE request. If `configuration.baseUrl` is set, paths must be relative.",
464
464
  "tags": [
465
465
  {
466
466
  "title": "public",
@@ -478,7 +478,7 @@
478
478
  },
479
479
  {
480
480
  "title": "param",
481
- "description": "Path to resource",
481
+ "description": "Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.",
482
482
  "type": {
483
483
  "type": "NameExpression",
484
484
  "name": "string"
package/dist/index.cjs CHANGED
@@ -137,7 +137,9 @@ function request(method, path, params, callback = (s) => s) {
137
137
  body = encodeFormBody(resolvedParams.form);
138
138
  }
139
139
  const baseUrl = (_a = state.configuration) == null ? void 0 : _a.baseUrl;
140
- addAuth(state.configuration, headers);
140
+ if (baseUrl) {
141
+ addAuth(state.configuration, headers);
142
+ }
141
143
  const maxRedirections = resolvedParams.maxRedirections ?? (resolvedParams.followAllRedirects === false ? 0 : 5);
142
144
  const tls = resolvedParams.tls ?? resolvedParams.agentOptions;
143
145
  if (resolvedParams.agentOptions) {
package/dist/index.js CHANGED
@@ -87,7 +87,9 @@ function request(method, path, params, callback = (s) => s) {
87
87
  body = encodeFormBody(resolvedParams.form);
88
88
  }
89
89
  const baseUrl = (_a = state.configuration) == null ? void 0 : _a.baseUrl;
90
- addAuth(state.configuration, headers);
90
+ if (baseUrl) {
91
+ addAuth(state.configuration, headers);
92
+ }
91
93
  const maxRedirections = resolvedParams.maxRedirections ?? (resolvedParams.followAllRedirects === false ? 0 : 5);
92
94
  const tls = resolvedParams.tls ?? resolvedParams.agentOptions;
93
95
  if (resolvedParams.agentOptions) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-http",
3
- "version": "6.4.1",
3
+ "version": "6.4.2",
4
4
  "description": "An HTTP request language package for use with Open Function",
5
5
  "homepage": "https://docs.openfn.org",
6
6
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "cheerio": "1.0.0-rc.12",
29
29
  "cheerio-tableparser": "^1.0.1",
30
- "@openfn/language-common": "1.15.1"
30
+ "@openfn/language-common": "2.0.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@openfn/simple-ast": "0.4.1",
@@ -31,7 +31,7 @@
31
31
  */
32
32
  export function execute(...operations: Operations): Operation;
33
33
  /**
34
- * Make a HTTP request
34
+ * Make a HTTP request. If `configuration.baseUrl` is set, paths must be relative.
35
35
  * @public
36
36
  * @example
37
37
  * request(
@@ -43,8 +43,8 @@ export function execute(...operations: Operations): Operation;
43
43
  * }
44
44
  * )
45
45
  * @function
46
- * @param {string} method - The HTTP method to use
47
- * @param {string} path - Path to resource
46
+ * @param {string} method - The HTTP method to use.
47
+ * @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
48
48
  * @param {RequestOptions} params - Query, Headers and Authentication parameters
49
49
  * @param {function} callback - (Optional) Callback function
50
50
  * @state {HttpState}
@@ -52,7 +52,7 @@ export function execute(...operations: Operations): Operation;
52
52
  */
53
53
  export function request(method: string, path: string, params: RequestOptions, callback: Function): Operation;
54
54
  /**
55
- * Make a GET request
55
+ * Make a GET request. If `configuration.baseUrl` is set, paths must be relative.
56
56
  * @public
57
57
  * @example
58
58
  * get('/myEndpoint', {
@@ -60,7 +60,7 @@ export function request(method: string, path: string, params: RequestOptions, ca
60
60
  * headers: {'content-type': 'application/json'},
61
61
  * })
62
62
  * @function
63
- * @param {string} path - Path to resource
63
+ * @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
64
64
  * @param {RequestOptions} params - Query, Headers and Authentication parameters
65
65
  * @param {function} callback - (Optional) Callback function
66
66
  * @state {HttpState}
@@ -68,7 +68,7 @@ export function request(method: string, path: string, params: RequestOptions, ca
68
68
  */
69
69
  export function get(path: string, params: RequestOptions, callback: Function): Operation;
70
70
  /**
71
- * Make a POST request
71
+ * Make a POST request. If `configuration.baseUrl` is set, paths must be relative.
72
72
  * @public
73
73
  * @example
74
74
  * post('/myEndpoint', {
@@ -76,7 +76,7 @@ export function get(path: string, params: RequestOptions, callback: Function): O
76
76
  * headers: {'content-type': 'application/json'},
77
77
  * })
78
78
  * @function
79
- * @param {string} path - Path to resource
79
+ * @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
80
80
  * @param {RequestOptions} params - Body, Query, Headers and Authentication parameters
81
81
  * @param {function} callback - (Optional) Callback function
82
82
  * @state {HttpState}
@@ -84,7 +84,7 @@ export function get(path: string, params: RequestOptions, callback: Function): O
84
84
  */
85
85
  export function post(path: string, params: RequestOptions, callback: Function): operation;
86
86
  /**
87
- * Make a PUT request
87
+ * Make a PUT request. If `configuration.baseUrl` is set, paths must be relative.
88
88
  * @public
89
89
  * @example
90
90
  * put('/myEndpoint', {
@@ -92,7 +92,7 @@ export function post(path: string, params: RequestOptions, callback: Function):
92
92
  * headers: {'content-type': 'application/json'},
93
93
  * })
94
94
  * @function
95
- * @param {string} path - Path to resource
95
+ * @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
96
96
  * @param {RequestOptions} params - Body, Query, Headers and Auth parameters
97
97
  * @param {function} callback - (Optional) Callback function
98
98
  * @state {HttpState}
@@ -100,7 +100,7 @@ export function post(path: string, params: RequestOptions, callback: Function):
100
100
  */
101
101
  export function put(path: string, params: RequestOptions, callback: Function): Operation;
102
102
  /**
103
- * Make a PATCH request
103
+ * Make a PATCH request. If `configuration.baseUrl` is set, paths must be relative.
104
104
  * @public
105
105
  * @example
106
106
  * patch('/myEndpoint', {
@@ -108,7 +108,7 @@ export function put(path: string, params: RequestOptions, callback: Function): O
108
108
  * headers: {'content-type': 'application/json'},
109
109
  * })
110
110
  * @function
111
- * @param {string} path - Path to resource
111
+ * @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
112
112
  * @param {RequestOptions} params - Body, Query, Headers and Auth parameters
113
113
  * @param {function} callback - (Optional) Callback function
114
114
  * @state {HttpState}
@@ -116,14 +116,14 @@ export function put(path: string, params: RequestOptions, callback: Function): O
116
116
  */
117
117
  export function patch(path: string, params: RequestOptions, callback: Function): Operation;
118
118
  /**
119
- * Make a DELETE request
119
+ * Make a DELETE request. If `configuration.baseUrl` is set, paths must be relative.
120
120
  * @public
121
121
  * @example
122
122
  * del(`/myendpoint/${state => state.data.id}`, {
123
123
  * headers: {'content-type': 'application/json'}
124
124
  * })
125
125
  * @function
126
- * @param {string} path - Path to resource
126
+ * @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
127
127
  * @param {RequestOptions} params - Body, Query, Headers and Auth parameters
128
128
  * @param {function} callback - (Optional) Callback function
129
129
  * @state {HttpState}