@openfn/language-http 5.1.1 → 6.1.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 +152 -11
- package/dist/index.cjs +126 -296
- package/dist/index.js +93 -262
- package/package.json +9 -15
- package/types/Adaptor.d.ts +98 -31
- package/types/Utils.d.ts +3 -9
package/dist/index.cjs
CHANGED
|
@@ -25,354 +25,185 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
25
25
|
// src/index.js
|
|
26
26
|
var src_exports = {};
|
|
27
27
|
__export(src_exports, {
|
|
28
|
-
alterState: () =>
|
|
29
|
-
arrayToString: () =>
|
|
30
|
-
|
|
31
|
-
combine: () =>
|
|
32
|
-
dataPath: () =>
|
|
33
|
-
dataValue: () =>
|
|
34
|
-
dateFns: () =>
|
|
28
|
+
alterState: () => import_language_common3.alterState,
|
|
29
|
+
arrayToString: () => import_language_common3.arrayToString,
|
|
30
|
+
chunk: () => import_language_common3.chunk,
|
|
31
|
+
combine: () => import_language_common3.combine,
|
|
32
|
+
dataPath: () => import_language_common3.dataPath,
|
|
33
|
+
dataValue: () => import_language_common3.dataValue,
|
|
34
|
+
dateFns: () => import_language_common3.dateFns,
|
|
35
35
|
default: () => src_default,
|
|
36
36
|
del: () => del,
|
|
37
|
-
each: () =>
|
|
37
|
+
each: () => import_language_common3.each,
|
|
38
38
|
execute: () => execute,
|
|
39
|
-
field: () =>
|
|
40
|
-
fields: () =>
|
|
41
|
-
fn: () =>
|
|
39
|
+
field: () => import_language_common3.field,
|
|
40
|
+
fields: () => import_language_common3.fields,
|
|
41
|
+
fn: () => import_language_common3.fn,
|
|
42
42
|
get: () => get,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
parseCsv: () => import_language_common2.parseCsv,
|
|
43
|
+
humanProper: () => import_language_common3.humanProper,
|
|
44
|
+
lastReferenceValue: () => import_language_common3.lastReferenceValue,
|
|
45
|
+
merge: () => import_language_common3.merge,
|
|
46
|
+
parseCsv: () => import_language_common3.parseCsv,
|
|
48
47
|
parseXML: () => parseXML,
|
|
49
48
|
patch: () => patch,
|
|
50
49
|
post: () => post,
|
|
51
50
|
put: () => put,
|
|
52
|
-
request: () =>
|
|
53
|
-
scrubEmojis: () =>
|
|
54
|
-
sourceValue: () =>
|
|
55
|
-
splitKeys: () =>
|
|
56
|
-
toArray: () =>
|
|
51
|
+
request: () => request2,
|
|
52
|
+
scrubEmojis: () => import_language_common3.scrubEmojis,
|
|
53
|
+
sourceValue: () => import_language_common3.sourceValue,
|
|
54
|
+
splitKeys: () => import_language_common3.splitKeys,
|
|
55
|
+
toArray: () => import_language_common3.toArray
|
|
57
56
|
});
|
|
58
57
|
module.exports = __toCommonJS(src_exports);
|
|
59
58
|
|
|
60
59
|
// src/Adaptor.js
|
|
61
60
|
var Adaptor_exports = {};
|
|
62
61
|
__export(Adaptor_exports, {
|
|
63
|
-
alterState: () =>
|
|
64
|
-
arrayToString: () =>
|
|
65
|
-
|
|
66
|
-
combine: () =>
|
|
67
|
-
dataPath: () =>
|
|
68
|
-
dataValue: () =>
|
|
69
|
-
dateFns: () =>
|
|
62
|
+
alterState: () => import_language_common3.alterState,
|
|
63
|
+
arrayToString: () => import_language_common3.arrayToString,
|
|
64
|
+
chunk: () => import_language_common3.chunk,
|
|
65
|
+
combine: () => import_language_common3.combine,
|
|
66
|
+
dataPath: () => import_language_common3.dataPath,
|
|
67
|
+
dataValue: () => import_language_common3.dataValue,
|
|
68
|
+
dateFns: () => import_language_common3.dateFns,
|
|
70
69
|
del: () => del,
|
|
71
|
-
each: () =>
|
|
70
|
+
each: () => import_language_common3.each,
|
|
72
71
|
execute: () => execute,
|
|
73
|
-
field: () =>
|
|
74
|
-
fields: () =>
|
|
75
|
-
fn: () =>
|
|
72
|
+
field: () => import_language_common3.field,
|
|
73
|
+
fields: () => import_language_common3.fields,
|
|
74
|
+
fn: () => import_language_common3.fn,
|
|
76
75
|
get: () => get,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
parseCsv: () => import_language_common2.parseCsv,
|
|
76
|
+
humanProper: () => import_language_common3.humanProper,
|
|
77
|
+
lastReferenceValue: () => import_language_common3.lastReferenceValue,
|
|
78
|
+
merge: () => import_language_common3.merge,
|
|
79
|
+
parseCsv: () => import_language_common3.parseCsv,
|
|
82
80
|
parseXML: () => parseXML,
|
|
83
81
|
patch: () => patch,
|
|
84
82
|
post: () => post,
|
|
85
83
|
put: () => put,
|
|
86
|
-
request: () =>
|
|
87
|
-
scrubEmojis: () =>
|
|
88
|
-
sourceValue: () =>
|
|
89
|
-
splitKeys: () =>
|
|
90
|
-
toArray: () =>
|
|
84
|
+
request: () => request2,
|
|
85
|
+
scrubEmojis: () => import_language_common3.scrubEmojis,
|
|
86
|
+
sourceValue: () => import_language_common3.sourceValue,
|
|
87
|
+
splitKeys: () => import_language_common3.splitKeys,
|
|
88
|
+
toArray: () => import_language_common3.toArray
|
|
91
89
|
});
|
|
90
|
+
var import_language_common2 = require("@openfn/language-common");
|
|
92
91
|
|
|
93
92
|
// src/Utils.js
|
|
94
|
-
var
|
|
95
|
-
var
|
|
96
|
-
var
|
|
97
|
-
var
|
|
98
|
-
function
|
|
99
|
-
const
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
if (baseUrl)
|
|
103
|
-
return `${baseUrl.replace(/\/$/, "")}/${path.replace(/^\/+/g, "")}`;
|
|
104
|
-
return path;
|
|
105
|
-
}
|
|
106
|
-
function isValidHttpUrl(string) {
|
|
107
|
-
let url;
|
|
108
|
-
try {
|
|
109
|
-
url = new URL(string);
|
|
110
|
-
} catch (_2) {
|
|
111
|
-
return false;
|
|
93
|
+
var import_language_common = require("@openfn/language-common");
|
|
94
|
+
var import_util = require("@openfn/language-common/util");
|
|
95
|
+
var cheerio = __toESM(require("cheerio"), 1);
|
|
96
|
+
var import_cheerio_tableparser = __toESM(require("cheerio-tableparser"), 1);
|
|
97
|
+
function addBasicAuth(configuration = {}, headers) {
|
|
98
|
+
const { username, password } = configuration;
|
|
99
|
+
if (username && password) {
|
|
100
|
+
Object.assign(headers, (0, import_util.makeBasicAuthHeader)(username, password));
|
|
112
101
|
}
|
|
113
|
-
return url.protocol === "http:" || url.protocol === "https:";
|
|
114
102
|
}
|
|
115
|
-
function
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return {
|
|
120
|
-
username: configuration.username,
|
|
121
|
-
password: configuration.password
|
|
122
|
-
};
|
|
123
|
-
else
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
function assembleError({ response, error, params }) {
|
|
127
|
-
var _a;
|
|
128
|
-
if (response) {
|
|
129
|
-
const customCodes = (_a = params == null ? void 0 : params.options) == null ? void 0 : _a.successCodes;
|
|
130
|
-
const status = (response == null ? void 0 : response.status) || (response == null ? void 0 : response.statusCode);
|
|
131
|
-
if ((customCodes || [200, 201, 202]).indexOf(status) > -1) {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
103
|
+
function encodeFormBody(data) {
|
|
104
|
+
const form = new FormData();
|
|
105
|
+
for (const [key, value] of Object.entries(data)) {
|
|
106
|
+
form.append(key, value);
|
|
134
107
|
}
|
|
135
|
-
|
|
136
|
-
return error;
|
|
137
|
-
delete response.request;
|
|
138
|
-
delete response.connection;
|
|
139
|
-
return new Error((0, import_fast_safe_stringify.default)(response, null, 2));
|
|
108
|
+
return form;
|
|
140
109
|
}
|
|
141
|
-
function
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
110
|
+
function request(method, path, params, callback = (s) => s) {
|
|
111
|
+
return (state) => {
|
|
112
|
+
var _a;
|
|
113
|
+
const [resolvedPath, resolvedParams = {}] = (0, import_util.expandReferences)(
|
|
114
|
+
state,
|
|
115
|
+
path,
|
|
116
|
+
params
|
|
117
|
+
);
|
|
118
|
+
let { body, headers = {} } = resolvedParams;
|
|
119
|
+
if (resolvedParams.json) {
|
|
120
|
+
console.warn(
|
|
121
|
+
"WARNING: The `json` option has been deprecated. Use `body` instead"
|
|
122
|
+
);
|
|
123
|
+
body = resolvedParams.json;
|
|
147
124
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
125
|
+
if (resolvedParams.form) {
|
|
126
|
+
body = encodeFormBody(resolvedParams.form);
|
|
127
|
+
}
|
|
128
|
+
const baseUrl = (_a = state.configuration) == null ? void 0 : _a.baseUrl;
|
|
129
|
+
addBasicAuth(state.configuration, headers);
|
|
130
|
+
const maxRedirections = resolvedParams.maxRedirections ?? (resolvedParams.followAllRedirects === false ? 0 : 5);
|
|
131
|
+
const tls = resolvedParams.tls ?? resolvedParams.agentOptions;
|
|
132
|
+
if (resolvedParams.agentOptions) {
|
|
133
|
+
console.warn(
|
|
134
|
+
"WARNING: The `agentOptions` option has been deprecated. Use `tls` instead"
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
const options = {
|
|
138
|
+
...resolvedParams,
|
|
139
|
+
headers,
|
|
140
|
+
baseUrl,
|
|
141
|
+
body,
|
|
142
|
+
tls,
|
|
143
|
+
maxRedirections
|
|
144
|
+
};
|
|
145
|
+
return (0, import_util.request)(method, resolvedPath, options).then((response) => {
|
|
146
|
+
(0, import_util.logResponse)(response);
|
|
147
|
+
return {
|
|
148
|
+
...(0, import_language_common.composeNextState)(state, response.body),
|
|
149
|
+
response
|
|
150
|
+
};
|
|
151
|
+
}).then(callback).catch((err) => {
|
|
152
|
+
(0, import_util.logResponse)(err);
|
|
153
|
+
throw err;
|
|
162
154
|
});
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function xmlParser(body, script, callback = (s) => s) {
|
|
158
|
+
return (state) => {
|
|
159
|
+
const [resolvedBody] = (0, import_util.expandReferences)(state, body);
|
|
160
|
+
const $ = cheerio.load(resolvedBody);
|
|
161
|
+
(0, import_cheerio_tableparser.default)($);
|
|
162
|
+
if (script) {
|
|
163
|
+
const result = script($);
|
|
164
|
+
try {
|
|
165
|
+
const r = JSON.parse(result);
|
|
166
|
+
return callback((0, import_language_common.composeNextState)(state, r));
|
|
167
|
+
} catch (e) {
|
|
168
|
+
return callback((0, import_language_common.composeNextState)(state, { body: result }));
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
return callback((0, import_language_common.composeNextState)(state, { body: resolvedBody }));
|
|
170
172
|
}
|
|
171
|
-
}
|
|
172
|
-
const finalConfig = {
|
|
173
|
-
...requestConfig,
|
|
174
|
-
url: (requestConfig == null ? void 0 : requestConfig.url) ?? (requestConfig == null ? void 0 : requestConfig.uri),
|
|
175
|
-
headers,
|
|
176
|
-
params: {
|
|
177
|
-
...requestConfig == null ? void 0 : requestConfig.params,
|
|
178
|
-
...requestConfig == null ? void 0 : requestConfig.qs,
|
|
179
|
-
...requestConfig == null ? void 0 : requestConfig.query
|
|
180
|
-
},
|
|
181
|
-
data: (requestConfig == null ? void 0 : requestConfig.data) ?? ((requestConfig == null ? void 0 : requestConfig.body) || form),
|
|
182
|
-
auth: (requestConfig == null ? void 0 : requestConfig.auth) ?? (requestConfig == null ? void 0 : requestConfig.authentication),
|
|
183
|
-
responseType: (requestConfig == null ? void 0 : requestConfig.responseType) ?? "json",
|
|
184
|
-
responseEncoding: (requestConfig == null ? void 0 : requestConfig.responseEncoding) ?? (requestConfig == null ? void 0 : requestConfig.encoding),
|
|
185
|
-
validateStatus: (status) => {
|
|
186
|
-
var _a;
|
|
187
|
-
const customCodes = (_a = requestConfig == null ? void 0 : requestConfig.options) == null ? void 0 : _a.successCodes;
|
|
188
|
-
if (customCodes)
|
|
189
|
-
return customCodes.includes(status);
|
|
190
|
-
return status >= 200 && status < 300;
|
|
191
|
-
},
|
|
192
|
-
maxRedirects: (requestConfig == null ? void 0 : requestConfig.maxRedirects) ?? ((requestConfig == null ? void 0 : requestConfig.followAllRedirects) === false ? 0 : 5)
|
|
193
173
|
};
|
|
194
|
-
return finalConfig;
|
|
195
174
|
}
|
|
196
175
|
|
|
197
176
|
// src/Adaptor.js
|
|
198
|
-
var
|
|
199
|
-
var import_request = __toESM(require("request"), 1);
|
|
200
|
-
var import_cheerio = __toESM(require("cheerio"), 1);
|
|
201
|
-
var import_cheerio_tableparser = __toESM(require("cheerio-tableparser"), 1);
|
|
202
|
-
var import_tough_cookie = __toESM(require("tough-cookie"), 1);
|
|
203
|
-
var import_language_common2 = require("@openfn/language-common");
|
|
204
|
-
var { axios } = import_language_common.http;
|
|
177
|
+
var import_language_common3 = require("@openfn/language-common");
|
|
205
178
|
function execute(...operations) {
|
|
206
179
|
const initialState = {
|
|
207
180
|
references: [],
|
|
208
181
|
data: null
|
|
209
182
|
};
|
|
210
183
|
return (state) => {
|
|
211
|
-
return (0,
|
|
184
|
+
return (0, import_language_common2.execute)(...operations)({ ...initialState, ...state });
|
|
212
185
|
};
|
|
213
186
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
axios.interceptors.request.use((config) => {
|
|
217
|
-
cookiejar == null ? void 0 : cookiejar.getCookies(config.url, (err, cookies) => {
|
|
218
|
-
config.headers.cookie = cookies == null ? void 0 : cookies.join("; ");
|
|
219
|
-
});
|
|
220
|
-
return config;
|
|
221
|
-
});
|
|
222
|
-
function handleCookies(response) {
|
|
223
|
-
var _a, _b;
|
|
224
|
-
const { config, data, headers } = response;
|
|
225
|
-
if (config.keepCookie) {
|
|
226
|
-
let cookies;
|
|
227
|
-
let keepCookies = [];
|
|
228
|
-
if (headers["set-cookie"]) {
|
|
229
|
-
if (headers["set-cookie"] instanceof Array) {
|
|
230
|
-
cookies = (_a = headers["set-cookie"]) == null ? void 0 : _a.map(Cookie.parse);
|
|
231
|
-
} else {
|
|
232
|
-
cookies = [Cookie.parse(headers["set-cookie"])];
|
|
233
|
-
}
|
|
234
|
-
(_b = headers["set-cookie"]) == null ? void 0 : _b.forEach((c) => {
|
|
235
|
-
cookiejar.setCookie(Cookie.parse(c), config.url, (err, cookie) => {
|
|
236
|
-
keepCookies == null ? void 0 : keepCookies.push(cookie == null ? void 0 : cookie.cookieString());
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
const extendableData = Array.isArray(data) ? { body: data } : data;
|
|
241
|
-
return {
|
|
242
|
-
...response,
|
|
243
|
-
data: {
|
|
244
|
-
...extendableData,
|
|
245
|
-
__cookie: (keepCookies == null ? void 0 : keepCookies.length) === 1 ? keepCookies[0] : keepCookies,
|
|
246
|
-
__headers: response.headers
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
return response;
|
|
251
|
-
}
|
|
252
|
-
function handleResponse(state, response) {
|
|
253
|
-
console.log(
|
|
254
|
-
response.config.method.toUpperCase(),
|
|
255
|
-
"request succeeded with",
|
|
256
|
-
response.status,
|
|
257
|
-
"\u2713"
|
|
258
|
-
);
|
|
259
|
-
const { method, path, host, protocol, _headers } = response.request;
|
|
260
|
-
response.request = { method, path, host, protocol, _headers };
|
|
261
|
-
const compatibleResp = {
|
|
262
|
-
...response,
|
|
263
|
-
httpStatus: response.status,
|
|
264
|
-
message: response.statusText,
|
|
265
|
-
data: tryJson(response.data)
|
|
266
|
-
};
|
|
267
|
-
const respWithCookies = handleCookies(compatibleResp);
|
|
268
|
-
return {
|
|
269
|
-
...(0, import_language_common.composeNextState)(state, respWithCookies.data),
|
|
270
|
-
response: respWithCookies
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
function handleCallback(state, callback) {
|
|
274
|
-
if (callback)
|
|
275
|
-
return callback(state);
|
|
276
|
-
return state;
|
|
187
|
+
function request2(method, path, params, callback) {
|
|
188
|
+
return request(method, path, params, callback);
|
|
277
189
|
}
|
|
278
190
|
function get(path, params, callback) {
|
|
279
|
-
return (
|
|
280
|
-
const resolvedPath = (0, import_language_common.expandReferences)(path)(state);
|
|
281
|
-
const resolvedParams = import_language_common.http.expandRequestReferences(params)(state);
|
|
282
|
-
const url = setUrl(state.configuration, resolvedPath);
|
|
283
|
-
const auth = setAuth(
|
|
284
|
-
state.configuration,
|
|
285
|
-
(resolvedParams == null ? void 0 : resolvedParams.authentication) ?? (resolvedParams == null ? void 0 : resolvedParams.auth)
|
|
286
|
-
);
|
|
287
|
-
const config = mapToAxiosConfig({ ...resolvedParams, url, auth });
|
|
288
|
-
return import_language_common.http.get(config)(state).then((response) => handleResponse(state, response)).then((nextState) => handleCallback(nextState, callback));
|
|
289
|
-
};
|
|
191
|
+
return request("GET", path, params, callback);
|
|
290
192
|
}
|
|
291
193
|
function post(path, params, callback) {
|
|
292
|
-
return (
|
|
293
|
-
const resolvedPath = (0, import_language_common.expandReferences)(path)(state);
|
|
294
|
-
const resolvedParams = import_language_common.http.expandRequestReferences(params)(state);
|
|
295
|
-
const url = setUrl(state.configuration, resolvedPath);
|
|
296
|
-
const auth = setAuth(
|
|
297
|
-
state.configuration,
|
|
298
|
-
(resolvedParams == null ? void 0 : resolvedParams.authentication) ?? (resolvedParams == null ? void 0 : resolvedParams.auth)
|
|
299
|
-
);
|
|
300
|
-
const config = mapToAxiosConfig({ ...resolvedParams, url, auth });
|
|
301
|
-
return import_language_common.http.post(config)(state).then((response) => handleResponse(state, response)).then((nextState) => handleCallback(nextState, callback));
|
|
302
|
-
};
|
|
194
|
+
return request("POST", path, params, callback);
|
|
303
195
|
}
|
|
304
196
|
function put(path, params, callback) {
|
|
305
|
-
return (
|
|
306
|
-
const resolvedPath = (0, import_language_common.expandReferences)(path)(state);
|
|
307
|
-
const resolvedParams = import_language_common.http.expandRequestReferences(params)(state);
|
|
308
|
-
const url = setUrl(state.configuration, resolvedPath);
|
|
309
|
-
const auth = setAuth(
|
|
310
|
-
state.configuration,
|
|
311
|
-
(resolvedParams == null ? void 0 : resolvedParams.authentication) ?? (resolvedParams == null ? void 0 : resolvedParams.auth)
|
|
312
|
-
);
|
|
313
|
-
const config = mapToAxiosConfig({ ...resolvedParams, url, auth });
|
|
314
|
-
return import_language_common.http.put(config)(state).then((response) => handleResponse(state, response)).then((nextState) => handleCallback(nextState, callback));
|
|
315
|
-
};
|
|
197
|
+
return request("PUT", path, params, callback);
|
|
316
198
|
}
|
|
317
199
|
function patch(path, params, callback) {
|
|
318
|
-
return (
|
|
319
|
-
const resolvedPath = (0, import_language_common.expandReferences)(path)(state);
|
|
320
|
-
const resolvedParams = import_language_common.http.expandRequestReferences(params)(state);
|
|
321
|
-
const url = setUrl(state.configuration, resolvedPath);
|
|
322
|
-
const auth = setAuth(
|
|
323
|
-
state.configuration,
|
|
324
|
-
(resolvedParams == null ? void 0 : resolvedParams.authentication) ?? (resolvedParams == null ? void 0 : resolvedParams.auth)
|
|
325
|
-
);
|
|
326
|
-
const config = mapToAxiosConfig({ ...resolvedParams, url, auth });
|
|
327
|
-
return import_language_common.http.patch(config)(state).then((response) => handleResponse(state, response)).then((nextState) => handleCallback(nextState, callback));
|
|
328
|
-
};
|
|
200
|
+
return request("PATCH", path, params, callback);
|
|
329
201
|
}
|
|
330
202
|
function del(path, params, callback) {
|
|
331
|
-
return (
|
|
332
|
-
const resolvedPath = (0, import_language_common.expandReferences)(path)(state);
|
|
333
|
-
const resolvedParams = import_language_common.http.expandRequestReferences(params)(state);
|
|
334
|
-
const url = setUrl(state.configuration, resolvedPath);
|
|
335
|
-
const auth = setAuth(
|
|
336
|
-
state.configuration,
|
|
337
|
-
(resolvedParams == null ? void 0 : resolvedParams.authentication) ?? resolvedParams.auth
|
|
338
|
-
);
|
|
339
|
-
const config = mapToAxiosConfig({ ...resolvedParams, url, auth });
|
|
340
|
-
return import_language_common.http.delete(config)(state).then((response) => handleResponse(state, response)).then((nextState) => handleCallback(nextState, callback));
|
|
341
|
-
};
|
|
203
|
+
return request("DELETE", path, params, callback);
|
|
342
204
|
}
|
|
343
|
-
function parseXML(body, script) {
|
|
344
|
-
return (
|
|
345
|
-
const resolvedBody = (0, import_language_common.expandReferences)(body)(state);
|
|
346
|
-
const $ = import_cheerio.default.load(resolvedBody);
|
|
347
|
-
(0, import_cheerio_tableparser.default)($);
|
|
348
|
-
if (script) {
|
|
349
|
-
const result = script($);
|
|
350
|
-
try {
|
|
351
|
-
const r = JSON.parse(result);
|
|
352
|
-
return (0, import_language_common.composeNextState)(state, r);
|
|
353
|
-
} catch (e) {
|
|
354
|
-
return (0, import_language_common.composeNextState)(state, { body: result });
|
|
355
|
-
}
|
|
356
|
-
} else {
|
|
357
|
-
return (0, import_language_common.composeNextState)(state, { body: resolvedBody });
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
function request(params) {
|
|
362
|
-
return (state) => {
|
|
363
|
-
const resolvedParams = import_language_common.http.expandRequestReferences(params)(state);
|
|
364
|
-
return new Promise((resolve, reject) => {
|
|
365
|
-
(0, import_request.default)(resolvedParams, (err, response, body) => {
|
|
366
|
-
const error = assembleError({ error: err, response, resolvedParams });
|
|
367
|
-
error && reject(error);
|
|
368
|
-
console.log(
|
|
369
|
-
"\u2713 Request succeeded. (The response body available in state.)"
|
|
370
|
-
);
|
|
371
|
-
const resp = tryJson(body);
|
|
372
|
-
resolve(resp);
|
|
373
|
-
});
|
|
374
|
-
});
|
|
375
|
-
};
|
|
205
|
+
function parseXML(body, script, callback) {
|
|
206
|
+
return xmlParser(body, script, callback);
|
|
376
207
|
}
|
|
377
208
|
|
|
378
209
|
// src/index.js
|
|
@@ -381,7 +212,7 @@ var src_default = Adaptor_exports;
|
|
|
381
212
|
0 && (module.exports = {
|
|
382
213
|
alterState,
|
|
383
214
|
arrayToString,
|
|
384
|
-
|
|
215
|
+
chunk,
|
|
385
216
|
combine,
|
|
386
217
|
dataPath,
|
|
387
218
|
dataValue,
|
|
@@ -393,7 +224,6 @@ var src_default = Adaptor_exports;
|
|
|
393
224
|
fields,
|
|
394
225
|
fn,
|
|
395
226
|
get,
|
|
396
|
-
http,
|
|
397
227
|
humanProper,
|
|
398
228
|
lastReferenceValue,
|
|
399
229
|
merge,
|