@openfn/language-mailchimp 0.6.0 → 0.7.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 +53 -0
- package/dist/index.cjs +13 -4
- package/dist/index.js +13 -4
- package/package.json +1 -1
- package/types/Adaptor.d.ts +1 -1
package/ast.json
CHANGED
|
@@ -418,6 +418,59 @@
|
|
|
418
418
|
]
|
|
419
419
|
},
|
|
420
420
|
"valid": true
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
"name": "chunk",
|
|
424
|
+
"params": [
|
|
425
|
+
"array",
|
|
426
|
+
"chunkSize"
|
|
427
|
+
],
|
|
428
|
+
"docs": {
|
|
429
|
+
"description": "Chunks an array into an array of arrays, each with no more than a certain size.",
|
|
430
|
+
"tags": [
|
|
431
|
+
{
|
|
432
|
+
"title": "public",
|
|
433
|
+
"description": null,
|
|
434
|
+
"type": null
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
"title": "example",
|
|
438
|
+
"description": "chunk([1,2,3,4,5], 2)"
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
"title": "function",
|
|
442
|
+
"description": null,
|
|
443
|
+
"name": null
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
"title": "param",
|
|
447
|
+
"description": "Array to be chunked",
|
|
448
|
+
"type": {
|
|
449
|
+
"type": "NameExpression",
|
|
450
|
+
"name": "Object"
|
|
451
|
+
},
|
|
452
|
+
"name": "array"
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
"title": "param",
|
|
456
|
+
"description": "The maxiumum size of each chunks",
|
|
457
|
+
"type": {
|
|
458
|
+
"type": "NameExpression",
|
|
459
|
+
"name": "Integer"
|
|
460
|
+
},
|
|
461
|
+
"name": "chunkSize"
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
"title": "returns",
|
|
465
|
+
"description": null,
|
|
466
|
+
"type": {
|
|
467
|
+
"type": "NameExpression",
|
|
468
|
+
"name": "Object"
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
]
|
|
472
|
+
},
|
|
473
|
+
"valid": true
|
|
421
474
|
}
|
|
422
475
|
]
|
|
423
476
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -29,6 +29,7 @@ __export(src_exports, {
|
|
|
29
29
|
alterState: () => import_language_common3.alterState,
|
|
30
30
|
archiveMember: () => archiveMember,
|
|
31
31
|
axios: () => import_axios.default,
|
|
32
|
+
chunk: () => import_language_common3.chunk,
|
|
32
33
|
dataPath: () => import_language_common3.dataPath,
|
|
33
34
|
dataValue: () => import_language_common3.dataValue,
|
|
34
35
|
default: () => src_default,
|
|
@@ -64,6 +65,7 @@ __export(Adaptor_exports, {
|
|
|
64
65
|
alterState: () => import_language_common3.alterState,
|
|
65
66
|
archiveMember: () => archiveMember,
|
|
66
67
|
axios: () => import_axios.default,
|
|
68
|
+
chunk: () => import_language_common3.chunk,
|
|
67
69
|
dataPath: () => import_language_common3.dataPath,
|
|
68
70
|
dataValue: () => import_language_common3.dataValue,
|
|
69
71
|
deleteMember: () => deleteMember,
|
|
@@ -250,11 +252,16 @@ var defaultOptions = {
|
|
|
250
252
|
body: void 0
|
|
251
253
|
};
|
|
252
254
|
var assertOK = (response, fullUrl) => {
|
|
253
|
-
if (response.
|
|
254
|
-
const defaultErrorMesssage = `Request to ${fullUrl} failed with status: ${response.
|
|
255
|
+
if (response.status >= 400) {
|
|
256
|
+
const defaultErrorMesssage = `Request to ${fullUrl} failed with status: ${response.status}`;
|
|
255
257
|
const error = new Error(defaultErrorMesssage);
|
|
256
|
-
error.code = response.statusCode;
|
|
257
258
|
error.url = fullUrl;
|
|
259
|
+
error.type = response.type;
|
|
260
|
+
error.title = response.title;
|
|
261
|
+
error.status = response.status;
|
|
262
|
+
error.detail = response.detail;
|
|
263
|
+
error.instance = response.instance;
|
|
264
|
+
error.errors = response.errors;
|
|
258
265
|
throw error;
|
|
259
266
|
}
|
|
260
267
|
};
|
|
@@ -284,9 +291,10 @@ var request = (method, path, options, callback) => {
|
|
|
284
291
|
query,
|
|
285
292
|
body: body ? JSON.stringify(body) : void 0
|
|
286
293
|
});
|
|
287
|
-
assertOK(response, `https://${server}.api.mailchimp.com${urlPath}`);
|
|
288
294
|
const responseBody = await response.body.json();
|
|
295
|
+
assertOK(responseBody, `https://${server}.api.mailchimp.com${urlPath}`);
|
|
289
296
|
const nextState = {
|
|
297
|
+
...state,
|
|
290
298
|
data: responseBody,
|
|
291
299
|
response: responseBody
|
|
292
300
|
};
|
|
@@ -306,6 +314,7 @@ var src_default = Adaptor_exports;
|
|
|
306
314
|
alterState,
|
|
307
315
|
archiveMember,
|
|
308
316
|
axios,
|
|
317
|
+
chunk,
|
|
309
318
|
dataPath,
|
|
310
319
|
dataValue,
|
|
311
320
|
deleteMember,
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ __export(Adaptor_exports, {
|
|
|
11
11
|
alterState: () => alterState,
|
|
12
12
|
archiveMember: () => archiveMember,
|
|
13
13
|
axios: () => axios,
|
|
14
|
+
chunk: () => chunk,
|
|
14
15
|
dataPath: () => dataPath,
|
|
15
16
|
dataValue: () => dataValue,
|
|
16
17
|
deleteMember: () => deleteMember,
|
|
@@ -73,6 +74,7 @@ import {
|
|
|
73
74
|
fields,
|
|
74
75
|
lastReferenceValue,
|
|
75
76
|
merge,
|
|
77
|
+
chunk,
|
|
76
78
|
sourceValue
|
|
77
79
|
} from "@openfn/language-common";
|
|
78
80
|
function execute(...operations) {
|
|
@@ -208,11 +210,16 @@ var defaultOptions = {
|
|
|
208
210
|
body: void 0
|
|
209
211
|
};
|
|
210
212
|
var assertOK = (response, fullUrl) => {
|
|
211
|
-
if (response.
|
|
212
|
-
const defaultErrorMesssage = `Request to ${fullUrl} failed with status: ${response.
|
|
213
|
+
if (response.status >= 400) {
|
|
214
|
+
const defaultErrorMesssage = `Request to ${fullUrl} failed with status: ${response.status}`;
|
|
213
215
|
const error = new Error(defaultErrorMesssage);
|
|
214
|
-
error.code = response.statusCode;
|
|
215
216
|
error.url = fullUrl;
|
|
217
|
+
error.type = response.type;
|
|
218
|
+
error.title = response.title;
|
|
219
|
+
error.status = response.status;
|
|
220
|
+
error.detail = response.detail;
|
|
221
|
+
error.instance = response.instance;
|
|
222
|
+
error.errors = response.errors;
|
|
216
223
|
throw error;
|
|
217
224
|
}
|
|
218
225
|
};
|
|
@@ -242,9 +249,10 @@ var request = (method, path, options, callback) => {
|
|
|
242
249
|
query,
|
|
243
250
|
body: body ? JSON.stringify(body) : void 0
|
|
244
251
|
});
|
|
245
|
-
assertOK(response, `https://${server}.api.mailchimp.com${urlPath}`);
|
|
246
252
|
const responseBody = await response.body.json();
|
|
253
|
+
assertOK(responseBody, `https://${server}.api.mailchimp.com${urlPath}`);
|
|
247
254
|
const nextState = {
|
|
255
|
+
...state,
|
|
248
256
|
data: responseBody,
|
|
249
257
|
response: responseBody
|
|
250
258
|
};
|
|
@@ -263,6 +271,7 @@ export {
|
|
|
263
271
|
alterState,
|
|
264
272
|
archiveMember,
|
|
265
273
|
axios,
|
|
274
|
+
chunk,
|
|
266
275
|
dataPath,
|
|
267
276
|
dataValue,
|
|
268
277
|
src_default as default,
|
package/package.json
CHANGED
package/types/Adaptor.d.ts
CHANGED
|
@@ -138,4 +138,4 @@ export function get(path: string, query: object, callback?: Function): Operation
|
|
|
138
138
|
export function post(path: string, body: object, query: object, callback?: Function): Operation;
|
|
139
139
|
import axios from "axios";
|
|
140
140
|
export { axios, md5 };
|
|
141
|
-
export { fn, alterState, dataPath, dataValue, each, field, fields, lastReferenceValue, merge, sourceValue } from "@openfn/language-common";
|
|
141
|
+
export { fn, alterState, dataPath, dataValue, each, field, fields, lastReferenceValue, merge, chunk, sourceValue } from "@openfn/language-common";
|