@openfn/language-monnify 1.0.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/LICENSE +674 -0
- package/LICENSE.LESSER +165 -0
- package/README.md +27 -0
- package/ast.json +1128 -0
- package/configuration-schema.json +36 -0
- package/dist/index.cjs +242 -0
- package/dist/index.js +218 -0
- package/package.json +47 -0
- package/types/Adaptor.d.ts +132 -0
- package/types/Utils.d.ts +4 -0
- package/types/index.d.ts +3 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"properties": {
|
|
4
|
+
"baseUrl": {
|
|
5
|
+
"title": "Base URL",
|
|
6
|
+
"anyOf": [
|
|
7
|
+
{
|
|
8
|
+
"type": "string"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"type": "null"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"description": "The base URL",
|
|
15
|
+
"format": "uri",
|
|
16
|
+
"minLength": 1,
|
|
17
|
+
"examples": ["https://sandbox.monnify.com"]
|
|
18
|
+
},
|
|
19
|
+
"apiKey": {
|
|
20
|
+
"title": "API Key",
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "This is required together with your secret key to generate your bearer token",
|
|
23
|
+
"examples": ["MK_TEST_YRP3AJ7RQ2"]
|
|
24
|
+
},
|
|
25
|
+
"secretKey": {
|
|
26
|
+
"title": "Secret key",
|
|
27
|
+
"type": "string",
|
|
28
|
+
"description": "The secret key is used to authorize all your API calls on Monnify.",
|
|
29
|
+
"writeOnly": true,
|
|
30
|
+
"examples": ["JKML52W7XQ43L02VRFDNQ8KLAU459W8B"]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"type": "object",
|
|
34
|
+
"additionalProperties": true,
|
|
35
|
+
"required": ["baseUrl","apiKey", "secretKey"]
|
|
36
|
+
}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
|
|
25
|
+
// src/index.js
|
|
26
|
+
var src_exports = {};
|
|
27
|
+
__export(src_exports, {
|
|
28
|
+
as: () => import_language_common2.as,
|
|
29
|
+
combine: () => import_language_common2.combine,
|
|
30
|
+
cursor: () => import_language_common2.cursor,
|
|
31
|
+
dataPath: () => import_language_common2.dataPath,
|
|
32
|
+
dataValue: () => import_language_common2.dataValue,
|
|
33
|
+
dateFns: () => import_language_common2.dateFns,
|
|
34
|
+
default: () => src_default,
|
|
35
|
+
each: () => import_language_common2.each,
|
|
36
|
+
field: () => import_language_common2.field,
|
|
37
|
+
fields: () => import_language_common2.fields,
|
|
38
|
+
fn: () => import_language_common2.fn,
|
|
39
|
+
fnIf: () => import_language_common2.fnIf,
|
|
40
|
+
get: () => get,
|
|
41
|
+
group: () => import_language_common2.group,
|
|
42
|
+
lastReferenceValue: () => import_language_common2.lastReferenceValue,
|
|
43
|
+
list: () => list,
|
|
44
|
+
map: () => import_language_common2.map,
|
|
45
|
+
merge: () => import_language_common2.merge,
|
|
46
|
+
post: () => post,
|
|
47
|
+
request: () => request2,
|
|
48
|
+
scrubEmojis: () => import_language_common2.scrubEmojis,
|
|
49
|
+
sourceValue: () => import_language_common2.sourceValue,
|
|
50
|
+
util: () => import_language_common2.util
|
|
51
|
+
});
|
|
52
|
+
module.exports = __toCommonJS(src_exports);
|
|
53
|
+
|
|
54
|
+
// src/Adaptor.js
|
|
55
|
+
var Adaptor_exports = {};
|
|
56
|
+
__export(Adaptor_exports, {
|
|
57
|
+
as: () => import_language_common2.as,
|
|
58
|
+
combine: () => import_language_common2.combine,
|
|
59
|
+
cursor: () => import_language_common2.cursor,
|
|
60
|
+
dataPath: () => import_language_common2.dataPath,
|
|
61
|
+
dataValue: () => import_language_common2.dataValue,
|
|
62
|
+
dateFns: () => import_language_common2.dateFns,
|
|
63
|
+
each: () => import_language_common2.each,
|
|
64
|
+
field: () => import_language_common2.field,
|
|
65
|
+
fields: () => import_language_common2.fields,
|
|
66
|
+
fn: () => import_language_common2.fn,
|
|
67
|
+
fnIf: () => import_language_common2.fnIf,
|
|
68
|
+
get: () => get,
|
|
69
|
+
group: () => import_language_common2.group,
|
|
70
|
+
lastReferenceValue: () => import_language_common2.lastReferenceValue,
|
|
71
|
+
list: () => list,
|
|
72
|
+
map: () => import_language_common2.map,
|
|
73
|
+
merge: () => import_language_common2.merge,
|
|
74
|
+
post: () => post,
|
|
75
|
+
request: () => request2,
|
|
76
|
+
scrubEmojis: () => import_language_common2.scrubEmojis,
|
|
77
|
+
sourceValue: () => import_language_common2.sourceValue,
|
|
78
|
+
util: () => import_language_common2.util
|
|
79
|
+
});
|
|
80
|
+
var import_util2 = require("@openfn/language-common/util");
|
|
81
|
+
|
|
82
|
+
// src/Utils.js
|
|
83
|
+
var import_language_common = require("@openfn/language-common");
|
|
84
|
+
var import_util = require("@openfn/language-common/util");
|
|
85
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
86
|
+
var prepareNextState = (state, response) => {
|
|
87
|
+
const { body, ...responseWithoutBody } = response;
|
|
88
|
+
if (!state.references) {
|
|
89
|
+
state.references = [];
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
...(0, import_language_common.composeNextState)(state, body),
|
|
93
|
+
response: responseWithoutBody
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
var getAccessToken = async (configuration, headers) => {
|
|
97
|
+
const { apiKey, secretKey, baseUrl } = configuration;
|
|
98
|
+
const { body } = await (0, import_util.request)("POST", "api/v1/auth/login", {
|
|
99
|
+
headers: {
|
|
100
|
+
...headers,
|
|
101
|
+
...(0, import_util.makeBasicAuthHeader)(apiKey, secretKey)
|
|
102
|
+
},
|
|
103
|
+
baseUrl,
|
|
104
|
+
parseAs: "json"
|
|
105
|
+
});
|
|
106
|
+
return { ...configuration, access_token: body.responseBody.accessToken };
|
|
107
|
+
};
|
|
108
|
+
var requestWithPagination = async (configuration = {}, method, path, options = {}) => {
|
|
109
|
+
var _a;
|
|
110
|
+
const { query = {} } = options;
|
|
111
|
+
let { pageSize, pageNo } = query;
|
|
112
|
+
const hasPagination = pageSize !== void 0 || pageNo !== void 0;
|
|
113
|
+
if (pageSize && pageSize > 1e3) {
|
|
114
|
+
console.log("Warning: PageSize cannot exceed 1000, reducing to 1000");
|
|
115
|
+
pageSize = 1e3;
|
|
116
|
+
}
|
|
117
|
+
const allContent = [];
|
|
118
|
+
let currentPage = pageNo !== void 0 ? pageNo : 0;
|
|
119
|
+
let isLastPage = false;
|
|
120
|
+
do {
|
|
121
|
+
const response = await request(configuration, method, path, {
|
|
122
|
+
...options,
|
|
123
|
+
query: { ...query, pageSize: pageSize || 100, pageNo: currentPage }
|
|
124
|
+
});
|
|
125
|
+
const { body: { responseBody } } = response;
|
|
126
|
+
if (hasPagination)
|
|
127
|
+
return { body: responseBody.content };
|
|
128
|
+
if ((_a = responseBody.content) == null ? void 0 : _a.length) {
|
|
129
|
+
allContent.push(...responseBody.content);
|
|
130
|
+
}
|
|
131
|
+
isLastPage = responseBody.last === true;
|
|
132
|
+
currentPage++;
|
|
133
|
+
} while (!isLastPage);
|
|
134
|
+
return {
|
|
135
|
+
body: allContent
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
var request = async (configuration = {}, method, path, options) => {
|
|
139
|
+
let config = configuration;
|
|
140
|
+
const { baseUrl, access_token } = config;
|
|
141
|
+
if (!access_token)
|
|
142
|
+
config = await getAccessToken(config, options.headers);
|
|
143
|
+
const { query = {}, body = {} } = options;
|
|
144
|
+
const opts = {
|
|
145
|
+
parseAs: "json",
|
|
146
|
+
baseUrl,
|
|
147
|
+
headers: {
|
|
148
|
+
"content-type": "application/json",
|
|
149
|
+
Authorization: `Bearer ${config.access_token}`,
|
|
150
|
+
...options.headers
|
|
151
|
+
},
|
|
152
|
+
body,
|
|
153
|
+
query,
|
|
154
|
+
...options
|
|
155
|
+
};
|
|
156
|
+
const safePath = import_node_path.default.join(path);
|
|
157
|
+
return (0, import_util.request)(method, safePath, opts).then(import_util.logResponse);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// src/Adaptor.js
|
|
161
|
+
var import_language_common2 = require("@openfn/language-common");
|
|
162
|
+
function get(path, options = {}) {
|
|
163
|
+
return async (state) => {
|
|
164
|
+
const [resolvedPath, resolvedoptions] = (0, import_util2.expandReferences)(state, path, options);
|
|
165
|
+
const response = await request(
|
|
166
|
+
state.configuration,
|
|
167
|
+
"GET",
|
|
168
|
+
resolvedPath,
|
|
169
|
+
resolvedoptions
|
|
170
|
+
);
|
|
171
|
+
return prepareNextState(state, response);
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function list(path, query = {}) {
|
|
175
|
+
return async (state) => {
|
|
176
|
+
const [resolvedPath, resolvedQuery] = (0, import_util2.expandReferences)(state, path, query);
|
|
177
|
+
const response = await requestWithPagination(
|
|
178
|
+
state.configuration,
|
|
179
|
+
"GET",
|
|
180
|
+
resolvedPath,
|
|
181
|
+
{
|
|
182
|
+
query: resolvedQuery
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
return prepareNextState(state, response);
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function post(path, body, options = {}) {
|
|
189
|
+
return async (state) => {
|
|
190
|
+
const [resolvedPath, resolvedBody, resolvedOptions] = (0, import_util2.expandReferences)(state, path, body, options);
|
|
191
|
+
const response = await request(
|
|
192
|
+
state.configuration,
|
|
193
|
+
"POST",
|
|
194
|
+
resolvedPath,
|
|
195
|
+
{
|
|
196
|
+
body: resolvedBody,
|
|
197
|
+
...resolvedOptions
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
return prepareNextState(state, response);
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function request2(method, path, options = {}) {
|
|
204
|
+
return async (state) => {
|
|
205
|
+
const [resolvedMethod, resolvedPath, resolvedoptions] = (0, import_util2.expandReferences)(state, method, path, options);
|
|
206
|
+
const response = await request(
|
|
207
|
+
state.configuration,
|
|
208
|
+
resolvedMethod,
|
|
209
|
+
resolvedPath,
|
|
210
|
+
resolvedoptions
|
|
211
|
+
);
|
|
212
|
+
return prepareNextState(state, response);
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// src/index.js
|
|
217
|
+
var src_default = Adaptor_exports;
|
|
218
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
219
|
+
0 && (module.exports = {
|
|
220
|
+
as,
|
|
221
|
+
combine,
|
|
222
|
+
cursor,
|
|
223
|
+
dataPath,
|
|
224
|
+
dataValue,
|
|
225
|
+
dateFns,
|
|
226
|
+
each,
|
|
227
|
+
field,
|
|
228
|
+
fields,
|
|
229
|
+
fn,
|
|
230
|
+
fnIf,
|
|
231
|
+
get,
|
|
232
|
+
group,
|
|
233
|
+
lastReferenceValue,
|
|
234
|
+
list,
|
|
235
|
+
map,
|
|
236
|
+
merge,
|
|
237
|
+
post,
|
|
238
|
+
request,
|
|
239
|
+
scrubEmojis,
|
|
240
|
+
sourceValue,
|
|
241
|
+
util
|
|
242
|
+
});
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/Adaptor.js
|
|
8
|
+
var Adaptor_exports = {};
|
|
9
|
+
__export(Adaptor_exports, {
|
|
10
|
+
as: () => as,
|
|
11
|
+
combine: () => combine,
|
|
12
|
+
cursor: () => cursor,
|
|
13
|
+
dataPath: () => dataPath,
|
|
14
|
+
dataValue: () => dataValue,
|
|
15
|
+
dateFns: () => dateFns,
|
|
16
|
+
each: () => each,
|
|
17
|
+
field: () => field,
|
|
18
|
+
fields: () => fields,
|
|
19
|
+
fn: () => fn,
|
|
20
|
+
fnIf: () => fnIf,
|
|
21
|
+
get: () => get,
|
|
22
|
+
group: () => group,
|
|
23
|
+
lastReferenceValue: () => lastReferenceValue,
|
|
24
|
+
list: () => list,
|
|
25
|
+
map: () => map,
|
|
26
|
+
merge: () => merge,
|
|
27
|
+
post: () => post,
|
|
28
|
+
request: () => request2,
|
|
29
|
+
scrubEmojis: () => scrubEmojis,
|
|
30
|
+
sourceValue: () => sourceValue,
|
|
31
|
+
util: () => util
|
|
32
|
+
});
|
|
33
|
+
import { expandReferences } from "@openfn/language-common/util";
|
|
34
|
+
|
|
35
|
+
// src/Utils.js
|
|
36
|
+
import { composeNextState } from "@openfn/language-common";
|
|
37
|
+
import {
|
|
38
|
+
request as commonRequest,
|
|
39
|
+
logResponse,
|
|
40
|
+
makeBasicAuthHeader
|
|
41
|
+
} from "@openfn/language-common/util";
|
|
42
|
+
import nodepath from "path";
|
|
43
|
+
var prepareNextState = (state, response) => {
|
|
44
|
+
const { body, ...responseWithoutBody } = response;
|
|
45
|
+
if (!state.references) {
|
|
46
|
+
state.references = [];
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
...composeNextState(state, body),
|
|
50
|
+
response: responseWithoutBody
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
var getAccessToken = async (configuration, headers) => {
|
|
54
|
+
const { apiKey, secretKey, baseUrl } = configuration;
|
|
55
|
+
const { body } = await commonRequest("POST", "api/v1/auth/login", {
|
|
56
|
+
headers: {
|
|
57
|
+
...headers,
|
|
58
|
+
...makeBasicAuthHeader(apiKey, secretKey)
|
|
59
|
+
},
|
|
60
|
+
baseUrl,
|
|
61
|
+
parseAs: "json"
|
|
62
|
+
});
|
|
63
|
+
return { ...configuration, access_token: body.responseBody.accessToken };
|
|
64
|
+
};
|
|
65
|
+
var requestWithPagination = async (configuration = {}, method, path, options = {}) => {
|
|
66
|
+
var _a;
|
|
67
|
+
const { query = {} } = options;
|
|
68
|
+
let { pageSize, pageNo } = query;
|
|
69
|
+
const hasPagination = pageSize !== void 0 || pageNo !== void 0;
|
|
70
|
+
if (pageSize && pageSize > 1e3) {
|
|
71
|
+
console.log("Warning: PageSize cannot exceed 1000, reducing to 1000");
|
|
72
|
+
pageSize = 1e3;
|
|
73
|
+
}
|
|
74
|
+
const allContent = [];
|
|
75
|
+
let currentPage = pageNo !== void 0 ? pageNo : 0;
|
|
76
|
+
let isLastPage = false;
|
|
77
|
+
do {
|
|
78
|
+
const response = await request(configuration, method, path, {
|
|
79
|
+
...options,
|
|
80
|
+
query: { ...query, pageSize: pageSize || 100, pageNo: currentPage }
|
|
81
|
+
});
|
|
82
|
+
const { body: { responseBody } } = response;
|
|
83
|
+
if (hasPagination)
|
|
84
|
+
return { body: responseBody.content };
|
|
85
|
+
if ((_a = responseBody.content) == null ? void 0 : _a.length) {
|
|
86
|
+
allContent.push(...responseBody.content);
|
|
87
|
+
}
|
|
88
|
+
isLastPage = responseBody.last === true;
|
|
89
|
+
currentPage++;
|
|
90
|
+
} while (!isLastPage);
|
|
91
|
+
return {
|
|
92
|
+
body: allContent
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
var request = async (configuration = {}, method, path, options) => {
|
|
96
|
+
let config = configuration;
|
|
97
|
+
const { baseUrl, access_token } = config;
|
|
98
|
+
if (!access_token)
|
|
99
|
+
config = await getAccessToken(config, options.headers);
|
|
100
|
+
const { query = {}, body = {} } = options;
|
|
101
|
+
const opts = {
|
|
102
|
+
parseAs: "json",
|
|
103
|
+
baseUrl,
|
|
104
|
+
headers: {
|
|
105
|
+
"content-type": "application/json",
|
|
106
|
+
Authorization: `Bearer ${config.access_token}`,
|
|
107
|
+
...options.headers
|
|
108
|
+
},
|
|
109
|
+
body,
|
|
110
|
+
query,
|
|
111
|
+
...options
|
|
112
|
+
};
|
|
113
|
+
const safePath = nodepath.join(path);
|
|
114
|
+
return commonRequest(method, safePath, opts).then(logResponse);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// src/Adaptor.js
|
|
118
|
+
import {
|
|
119
|
+
as,
|
|
120
|
+
combine,
|
|
121
|
+
cursor,
|
|
122
|
+
dataPath,
|
|
123
|
+
dataValue,
|
|
124
|
+
dateFns,
|
|
125
|
+
each,
|
|
126
|
+
field,
|
|
127
|
+
fields,
|
|
128
|
+
fn,
|
|
129
|
+
fnIf,
|
|
130
|
+
group,
|
|
131
|
+
lastReferenceValue,
|
|
132
|
+
map,
|
|
133
|
+
merge,
|
|
134
|
+
scrubEmojis,
|
|
135
|
+
sourceValue,
|
|
136
|
+
util
|
|
137
|
+
} from "@openfn/language-common";
|
|
138
|
+
function get(path, options = {}) {
|
|
139
|
+
return async (state) => {
|
|
140
|
+
const [resolvedPath, resolvedoptions] = expandReferences(state, path, options);
|
|
141
|
+
const response = await request(
|
|
142
|
+
state.configuration,
|
|
143
|
+
"GET",
|
|
144
|
+
resolvedPath,
|
|
145
|
+
resolvedoptions
|
|
146
|
+
);
|
|
147
|
+
return prepareNextState(state, response);
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function list(path, query = {}) {
|
|
151
|
+
return async (state) => {
|
|
152
|
+
const [resolvedPath, resolvedQuery] = expandReferences(state, path, query);
|
|
153
|
+
const response = await requestWithPagination(
|
|
154
|
+
state.configuration,
|
|
155
|
+
"GET",
|
|
156
|
+
resolvedPath,
|
|
157
|
+
{
|
|
158
|
+
query: resolvedQuery
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
return prepareNextState(state, response);
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function post(path, body, options = {}) {
|
|
165
|
+
return async (state) => {
|
|
166
|
+
const [resolvedPath, resolvedBody, resolvedOptions] = expandReferences(state, path, body, options);
|
|
167
|
+
const response = await request(
|
|
168
|
+
state.configuration,
|
|
169
|
+
"POST",
|
|
170
|
+
resolvedPath,
|
|
171
|
+
{
|
|
172
|
+
body: resolvedBody,
|
|
173
|
+
...resolvedOptions
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
return prepareNextState(state, response);
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function request2(method, path, options = {}) {
|
|
180
|
+
return async (state) => {
|
|
181
|
+
const [resolvedMethod, resolvedPath, resolvedoptions] = expandReferences(state, method, path, options);
|
|
182
|
+
const response = await request(
|
|
183
|
+
state.configuration,
|
|
184
|
+
resolvedMethod,
|
|
185
|
+
resolvedPath,
|
|
186
|
+
resolvedoptions
|
|
187
|
+
);
|
|
188
|
+
return prepareNextState(state, response);
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// src/index.js
|
|
193
|
+
var src_default = Adaptor_exports;
|
|
194
|
+
export {
|
|
195
|
+
as,
|
|
196
|
+
combine,
|
|
197
|
+
cursor,
|
|
198
|
+
dataPath,
|
|
199
|
+
dataValue,
|
|
200
|
+
dateFns,
|
|
201
|
+
src_default as default,
|
|
202
|
+
each,
|
|
203
|
+
field,
|
|
204
|
+
fields,
|
|
205
|
+
fn,
|
|
206
|
+
fnIf,
|
|
207
|
+
get,
|
|
208
|
+
group,
|
|
209
|
+
lastReferenceValue,
|
|
210
|
+
list,
|
|
211
|
+
map,
|
|
212
|
+
merge,
|
|
213
|
+
post,
|
|
214
|
+
request2 as request,
|
|
215
|
+
scrubEmojis,
|
|
216
|
+
sourceValue,
|
|
217
|
+
util
|
|
218
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openfn/language-monnify",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "OpenFn monnify adaptor",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./dist/index.js",
|
|
9
|
+
"types": "./types/index.d.ts",
|
|
10
|
+
"require": "./dist/index.cjs"
|
|
11
|
+
},
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"author": "Open Function Group",
|
|
15
|
+
"license": "LGPLv3",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/",
|
|
18
|
+
"types/",
|
|
19
|
+
"ast.json",
|
|
20
|
+
"configuration-schema.json"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@openfn/language-common": "3.2.1"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"assertion-error": "2.0.0",
|
|
27
|
+
"chai": "4.3.6",
|
|
28
|
+
"deep-eql": "4.1.1",
|
|
29
|
+
"mocha": "^10.7.3",
|
|
30
|
+
"rimraf": "3.0.2",
|
|
31
|
+
"undici": "^5.22.1"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/openfn/adaptors.git"
|
|
36
|
+
},
|
|
37
|
+
"types": "types/index.d.ts",
|
|
38
|
+
"main": "dist/index.cjs",
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "pnpm clean && build-adaptor monnify",
|
|
41
|
+
"test": "mocha --experimental-specifier-resolution=node --no-warnings",
|
|
42
|
+
"test:watch": "mocha -w --experimental-specifier-resolution=node --no-warnings",
|
|
43
|
+
"clean": "rimraf dist types docs",
|
|
44
|
+
"pack": "pnpm pack --pack-destination ../../dist",
|
|
45
|
+
"lint": "eslint src"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State object
|
|
3
|
+
* @typedef {Object} HttpState
|
|
4
|
+
* @property data - the parsed response body
|
|
5
|
+
* @property response - the response from the HTTP server, including headers, statusCode, body, etc
|
|
6
|
+
* @property references - an array of all previous data objects used in the Job
|
|
7
|
+
**/
|
|
8
|
+
/**
|
|
9
|
+
* Query option for the `list` helper function
|
|
10
|
+
* @typedef {Object} ListQueryOptions
|
|
11
|
+
* @property {Number} pageNo - The page number. Please note that Monnify pagination starts at 0 not 1. (Default: 0)
|
|
12
|
+
* @property {Number} pageSize - The page size. (Default: 100)
|
|
13
|
+
* @property {Record<string, any>} [otherOptions] - Additional options.
|
|
14
|
+
**/
|
|
15
|
+
/**
|
|
16
|
+
* Options provided to the HTTP request
|
|
17
|
+
* @typedef {Object} RequestOptions
|
|
18
|
+
* @public
|
|
19
|
+
* @property {object|string} body - body data to append to the request. JSON will be converted to a string (but a content-type header will not be attached to the request).
|
|
20
|
+
* @property {object} query - An object of query parameters to be encoded into the URL.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Make a GET request
|
|
24
|
+
* @example <caption>Get all transactions</caption>
|
|
25
|
+
* get('/api/v1/transactions/search');
|
|
26
|
+
* @function
|
|
27
|
+
* @public
|
|
28
|
+
* @param {string} path - Path to resource
|
|
29
|
+
* @param {RequestOptions} options - Optional request options
|
|
30
|
+
* @returns {Operation}
|
|
31
|
+
* @state {HttpState}
|
|
32
|
+
*/
|
|
33
|
+
export function get(path: string, options?: RequestOptions): Operation;
|
|
34
|
+
/**
|
|
35
|
+
* Fetch a list of items.
|
|
36
|
+
* @example <caption>Get all transactions</caption>
|
|
37
|
+
* list('/api/v2/disbursements/search-transactions', {
|
|
38
|
+
* sourceAccountNumber: 4864192954
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* @example <caption>Get all transactions for a specific page and page number.</caption>
|
|
42
|
+
* list('/api/v2/disbursements/search-transactions', {
|
|
43
|
+
* sourceAccountNumber: 4864192954,
|
|
44
|
+
* pageNo: 0,
|
|
45
|
+
* pageSize: 10
|
|
46
|
+
* });
|
|
47
|
+
* @function
|
|
48
|
+
* @public
|
|
49
|
+
* @param {string} path - Path to resource
|
|
50
|
+
* @param {ListQueryOptions} query - Query options.
|
|
51
|
+
* @returns {Operation}
|
|
52
|
+
* @state {HttpState}
|
|
53
|
+
*/
|
|
54
|
+
export function list(path: string, query?: ListQueryOptions): Operation;
|
|
55
|
+
/**
|
|
56
|
+
* Make a POST request
|
|
57
|
+
* @example <caption>Resend all failed notifications over a time period</caption>
|
|
58
|
+
* post("/api/v1/transaction-notification/resend-failed-notifications", {
|
|
59
|
+
"startDate": "2021-01-16T13:56:39.492",
|
|
60
|
+
"endDate": "2021-10-16T13:56:39.492"
|
|
61
|
+
});
|
|
62
|
+
* @function
|
|
63
|
+
* @public
|
|
64
|
+
* @param {string} path - Path to resource
|
|
65
|
+
* @param {object} body - The Post request body
|
|
66
|
+
* @param {RequestOptions} options - Optional request options
|
|
67
|
+
* @returns {Operation}
|
|
68
|
+
* @state {HttpState}
|
|
69
|
+
*/
|
|
70
|
+
export function post(path: string, body: object, options?: RequestOptions): Operation;
|
|
71
|
+
/**
|
|
72
|
+
* Make a generic request
|
|
73
|
+
* @example <caption>Get disbursements from a wallet</caption>
|
|
74
|
+
* request(
|
|
75
|
+
* 'GET',
|
|
76
|
+
* '/api/v2/disbursements/search-transactions',
|
|
77
|
+
* {
|
|
78
|
+
* query: {
|
|
79
|
+
* sourceAccountNumber: 4864192954,
|
|
80
|
+
* pageNo: 0,
|
|
81
|
+
* pageSize: 10
|
|
82
|
+
* }
|
|
83
|
+
* }
|
|
84
|
+
* );
|
|
85
|
+
* @function
|
|
86
|
+
* @public
|
|
87
|
+
* @param {string} method - HTTP method to use
|
|
88
|
+
* @param {string} path - Path to resource
|
|
89
|
+
* @param {RequestOptions} options - Optional request options
|
|
90
|
+
* @returns {Operation}
|
|
91
|
+
* @state {HttpState}
|
|
92
|
+
*/
|
|
93
|
+
export function request(method: string, path: string, options?: RequestOptions): Operation;
|
|
94
|
+
/**
|
|
95
|
+
* State object
|
|
96
|
+
*/
|
|
97
|
+
export type HttpState = {
|
|
98
|
+
/**
|
|
99
|
+
* - the parsed response body
|
|
100
|
+
*/
|
|
101
|
+
data: any;
|
|
102
|
+
/**
|
|
103
|
+
* - the response from the HTTP server, including headers, statusCode, body, etc
|
|
104
|
+
*/
|
|
105
|
+
response: any;
|
|
106
|
+
/**
|
|
107
|
+
* - an array of all previous data objects used in the Job
|
|
108
|
+
*/
|
|
109
|
+
references: any;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Query option for the `list` helper function
|
|
113
|
+
*/
|
|
114
|
+
export type ListQueryOptions = {
|
|
115
|
+
/**
|
|
116
|
+
* - The page number. Please note that Monnify pagination starts at 0 not 1. (Default: 0)
|
|
117
|
+
*/
|
|
118
|
+
pageNo: number;
|
|
119
|
+
/**
|
|
120
|
+
* - The page size. (Default: 100)
|
|
121
|
+
*/
|
|
122
|
+
pageSize: number;
|
|
123
|
+
/**
|
|
124
|
+
* - Additional options.
|
|
125
|
+
*/
|
|
126
|
+
otherOptions?: Record<string, any>;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Options provided to the HTTP request
|
|
130
|
+
*/
|
|
131
|
+
export type RequestOptions = any;
|
|
132
|
+
export { as, combine, cursor, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf, group, lastReferenceValue, map, merge, scrubEmojis, sourceValue, util } from "@openfn/language-common";
|
package/types/Utils.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export function prepareNextState(state: any, response: any): any;
|
|
2
|
+
export function getAccessToken(configuration: any, headers: any): Promise<any>;
|
|
3
|
+
export function requestWithPagination(configuration: {}, method: any, path: any, options?: {}): Promise<any>;
|
|
4
|
+
export function request(configuration: {}, method: any, path: any, options: any): Promise<any>;
|
package/types/index.d.ts
ADDED