@openfn/language-zata 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 +29 -0
- package/ast.json +1123 -0
- package/configuration-schema.json +38 -0
- package/dist/index.cjs +200 -0
- package/dist/index.js +172 -0
- package/package.json +47 -0
- package/types/Adaptor.d.ts +162 -0
- package/types/Utils.d.ts +2 -0
- package/types/index.d.ts +3 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"properties": {
|
|
4
|
+
"apiToken": {
|
|
5
|
+
"title": "API token",
|
|
6
|
+
"type": "string",
|
|
7
|
+
"description": "The Zata API token",
|
|
8
|
+
"writeOnly": true,
|
|
9
|
+
"minLength": 1,
|
|
10
|
+
"examples": ["EAAZAq6ZBYUd64BO83b46fn2MdraueL5s9I5IRZCtWUpYsfmEZARN2HDmL8BE5UhFf98EuTnpkhZBWTR9xippoN1a9MzY8Giw3pjSp55YMAF1nowqsy9aLODz48dm8TpXk8ZADUt6qX3vnYJzcn4OH9jrOIiW5ivt3By0beSjbX0E32ZCUMQpS9xRirepvc7qgGKurWQKIcPLPVSGjXQlZCSZBmLdCL8IW07qfjISupZA3HIniORAZDZD"]
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
"apiVersion": {
|
|
14
|
+
"title": "API Version",
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "The Zata API version",
|
|
17
|
+
"examples": ["v1"]
|
|
18
|
+
},
|
|
19
|
+
"baseUrl": {
|
|
20
|
+
"title": "Base URL",
|
|
21
|
+
"anyOf": [
|
|
22
|
+
{
|
|
23
|
+
"type": "string"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"type": "null"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"description": "The base URL (http://www.example.com)",
|
|
30
|
+
"format": "uri",
|
|
31
|
+
"minLength": 1,
|
|
32
|
+
"examples": ["https://example.com"]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"type": "object",
|
|
36
|
+
"additionalProperties": true,
|
|
37
|
+
"required": ["apiToken"]
|
|
38
|
+
}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
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
|
+
map: () => import_language_common2.map,
|
|
44
|
+
merge: () => import_language_common2.merge,
|
|
45
|
+
post: () => post,
|
|
46
|
+
put: () => put,
|
|
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
|
+
map: () => import_language_common2.map,
|
|
72
|
+
merge: () => import_language_common2.merge,
|
|
73
|
+
post: () => post,
|
|
74
|
+
put: () => put,
|
|
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, response.body),
|
|
93
|
+
response: responseWithoutBody
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
var request = (configuration = {}, method, path, options = {}) => {
|
|
97
|
+
const { apiToken, apiVersion = "v1", baseUrl = "https://ebm.zata.rw/api" } = configuration;
|
|
98
|
+
const { headers = {} } = options;
|
|
99
|
+
const errors = {
|
|
100
|
+
404: "Page not found"
|
|
101
|
+
};
|
|
102
|
+
const opts = {
|
|
103
|
+
parseAs: "json",
|
|
104
|
+
errors,
|
|
105
|
+
baseUrl,
|
|
106
|
+
...options,
|
|
107
|
+
headers: {
|
|
108
|
+
"content-type": "application/json",
|
|
109
|
+
"Authorization": `Bearer ${apiToken}`,
|
|
110
|
+
...headers
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const safePath = import_node_path.default.join(apiVersion, path);
|
|
114
|
+
return (0, import_util.request)(method, safePath, opts);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// src/Adaptor.js
|
|
118
|
+
var import_language_common2 = require("@openfn/language-common");
|
|
119
|
+
function get(path, options) {
|
|
120
|
+
return async (state) => {
|
|
121
|
+
const [resolvedPath, resolvedOptions] = (0, import_util2.expandReferences)(state, path, options);
|
|
122
|
+
const response = await request(
|
|
123
|
+
state.configuration,
|
|
124
|
+
"GET",
|
|
125
|
+
resolvedPath,
|
|
126
|
+
resolvedOptions
|
|
127
|
+
);
|
|
128
|
+
return prepareNextState(state, response);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function post(path, options) {
|
|
132
|
+
return async (state) => {
|
|
133
|
+
const [resolvedPath, resolvedBody, resolvedOptions] = (0, import_util2.expandReferences)(state, path, options);
|
|
134
|
+
const response = await request(
|
|
135
|
+
state.configuration,
|
|
136
|
+
"POST",
|
|
137
|
+
resolvedPath,
|
|
138
|
+
{
|
|
139
|
+
body: resolvedBody,
|
|
140
|
+
...resolvedOptions
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
return prepareNextState(state, response);
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function put(path, options) {
|
|
147
|
+
return async (state) => {
|
|
148
|
+
const [resolvedPath, resolvedBody, resolvedOptions] = (0, import_util2.expandReferences)(state, path, options);
|
|
149
|
+
const response = await request(
|
|
150
|
+
state.configuration,
|
|
151
|
+
"PUT",
|
|
152
|
+
resolvedPath,
|
|
153
|
+
{
|
|
154
|
+
body: resolvedBody,
|
|
155
|
+
...resolvedOptions
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
return prepareNextState(state, response);
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function request2(method, path, options = {}) {
|
|
162
|
+
return async (state) => {
|
|
163
|
+
const [resolvedMethod, resolvedPath, resolvedOptions] = (0, import_util2.expandReferences)(state, method, path, options);
|
|
164
|
+
const response = await request(
|
|
165
|
+
state.configuration,
|
|
166
|
+
resolvedMethod,
|
|
167
|
+
resolvedPath,
|
|
168
|
+
resolvedOptions
|
|
169
|
+
);
|
|
170
|
+
return prepareNextState(state, response);
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/index.js
|
|
175
|
+
var src_default = Adaptor_exports;
|
|
176
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
177
|
+
0 && (module.exports = {
|
|
178
|
+
as,
|
|
179
|
+
combine,
|
|
180
|
+
cursor,
|
|
181
|
+
dataPath,
|
|
182
|
+
dataValue,
|
|
183
|
+
dateFns,
|
|
184
|
+
each,
|
|
185
|
+
field,
|
|
186
|
+
fields,
|
|
187
|
+
fn,
|
|
188
|
+
fnIf,
|
|
189
|
+
get,
|
|
190
|
+
group,
|
|
191
|
+
lastReferenceValue,
|
|
192
|
+
map,
|
|
193
|
+
merge,
|
|
194
|
+
post,
|
|
195
|
+
put,
|
|
196
|
+
request,
|
|
197
|
+
scrubEmojis,
|
|
198
|
+
sourceValue,
|
|
199
|
+
util
|
|
200
|
+
});
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
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
|
+
map: () => map,
|
|
25
|
+
merge: () => merge,
|
|
26
|
+
post: () => post,
|
|
27
|
+
put: () => put,
|
|
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 { request as commonRequest } from "@openfn/language-common/util";
|
|
38
|
+
import nodepath from "path";
|
|
39
|
+
var prepareNextState = (state, response) => {
|
|
40
|
+
const { body, ...responseWithoutBody } = response;
|
|
41
|
+
if (!state.references) {
|
|
42
|
+
state.references = [];
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
...composeNextState(state, response.body),
|
|
46
|
+
response: responseWithoutBody
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
var request = (configuration = {}, method, path, options = {}) => {
|
|
50
|
+
const { apiToken, apiVersion = "v1", baseUrl = "https://ebm.zata.rw/api" } = configuration;
|
|
51
|
+
const { headers = {} } = options;
|
|
52
|
+
const errors = {
|
|
53
|
+
404: "Page not found"
|
|
54
|
+
};
|
|
55
|
+
const opts = {
|
|
56
|
+
parseAs: "json",
|
|
57
|
+
errors,
|
|
58
|
+
baseUrl,
|
|
59
|
+
...options,
|
|
60
|
+
headers: {
|
|
61
|
+
"content-type": "application/json",
|
|
62
|
+
"Authorization": `Bearer ${apiToken}`,
|
|
63
|
+
...headers
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const safePath = nodepath.join(apiVersion, path);
|
|
67
|
+
return commonRequest(method, safePath, opts);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// src/Adaptor.js
|
|
71
|
+
import {
|
|
72
|
+
as,
|
|
73
|
+
combine,
|
|
74
|
+
cursor,
|
|
75
|
+
dataPath,
|
|
76
|
+
dataValue,
|
|
77
|
+
dateFns,
|
|
78
|
+
each,
|
|
79
|
+
field,
|
|
80
|
+
fields,
|
|
81
|
+
fn,
|
|
82
|
+
fnIf,
|
|
83
|
+
group,
|
|
84
|
+
lastReferenceValue,
|
|
85
|
+
map,
|
|
86
|
+
merge,
|
|
87
|
+
scrubEmojis,
|
|
88
|
+
sourceValue,
|
|
89
|
+
util
|
|
90
|
+
} from "@openfn/language-common";
|
|
91
|
+
function get(path, options) {
|
|
92
|
+
return async (state) => {
|
|
93
|
+
const [resolvedPath, resolvedOptions] = expandReferences(state, path, options);
|
|
94
|
+
const response = await request(
|
|
95
|
+
state.configuration,
|
|
96
|
+
"GET",
|
|
97
|
+
resolvedPath,
|
|
98
|
+
resolvedOptions
|
|
99
|
+
);
|
|
100
|
+
return prepareNextState(state, response);
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function post(path, options) {
|
|
104
|
+
return async (state) => {
|
|
105
|
+
const [resolvedPath, resolvedBody, resolvedOptions] = expandReferences(state, path, options);
|
|
106
|
+
const response = await request(
|
|
107
|
+
state.configuration,
|
|
108
|
+
"POST",
|
|
109
|
+
resolvedPath,
|
|
110
|
+
{
|
|
111
|
+
body: resolvedBody,
|
|
112
|
+
...resolvedOptions
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
return prepareNextState(state, response);
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function put(path, options) {
|
|
119
|
+
return async (state) => {
|
|
120
|
+
const [resolvedPath, resolvedBody, resolvedOptions] = expandReferences(state, path, options);
|
|
121
|
+
const response = await request(
|
|
122
|
+
state.configuration,
|
|
123
|
+
"PUT",
|
|
124
|
+
resolvedPath,
|
|
125
|
+
{
|
|
126
|
+
body: resolvedBody,
|
|
127
|
+
...resolvedOptions
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
return prepareNextState(state, response);
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function request2(method, path, options = {}) {
|
|
134
|
+
return async (state) => {
|
|
135
|
+
const [resolvedMethod, resolvedPath, resolvedOptions] = expandReferences(state, method, path, options);
|
|
136
|
+
const response = await request(
|
|
137
|
+
state.configuration,
|
|
138
|
+
resolvedMethod,
|
|
139
|
+
resolvedPath,
|
|
140
|
+
resolvedOptions
|
|
141
|
+
);
|
|
142
|
+
return prepareNextState(state, response);
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// src/index.js
|
|
147
|
+
var src_default = Adaptor_exports;
|
|
148
|
+
export {
|
|
149
|
+
as,
|
|
150
|
+
combine,
|
|
151
|
+
cursor,
|
|
152
|
+
dataPath,
|
|
153
|
+
dataValue,
|
|
154
|
+
dateFns,
|
|
155
|
+
src_default as default,
|
|
156
|
+
each,
|
|
157
|
+
field,
|
|
158
|
+
fields,
|
|
159
|
+
fn,
|
|
160
|
+
fnIf,
|
|
161
|
+
get,
|
|
162
|
+
group,
|
|
163
|
+
lastReferenceValue,
|
|
164
|
+
map,
|
|
165
|
+
merge,
|
|
166
|
+
post,
|
|
167
|
+
put,
|
|
168
|
+
request2 as request,
|
|
169
|
+
scrubEmojis,
|
|
170
|
+
sourceValue,
|
|
171
|
+
util
|
|
172
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openfn/language-zata",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "An OpenFn adaptor for Zata tax compliance",
|
|
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.0.2"
|
|
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 zata",
|
|
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,162 @@
|
|
|
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
|
+
* Options provided to the HTTP request
|
|
10
|
+
* @typedef {Object} RequestOptions
|
|
11
|
+
* @public
|
|
12
|
+
* @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).
|
|
13
|
+
* @property {object} errors - Map of errorCodes -> error messages, ie, `{ 404: 'Resource not found;' }`. Pass `false` to suppress errors for this code.
|
|
14
|
+
* @property {object} form - Pass a JSON object to be serialised into a multipart HTML form (as FormData) in the body.
|
|
15
|
+
* @property {object} query - An object of query parameters to be encoded into the URL.
|
|
16
|
+
* @property {object} headers - An object of headers to append to the request.
|
|
17
|
+
* @property {string} parseAs - Parse the response body as json, text or stream. By default will use the response headers.
|
|
18
|
+
* @property {number} timeout - Request timeout in ms. Default: 300 seconds.
|
|
19
|
+
* @property {object} tls - TLS/SSL authentication options. See https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Make a GET request to the Zata API
|
|
23
|
+
* @example <caption>Get all product types</caption>
|
|
24
|
+
* get('data/product-type')
|
|
25
|
+
* @example <caption>Test Zata API connectivity</caption>
|
|
26
|
+
* get('test')
|
|
27
|
+
* @function
|
|
28
|
+
* @public
|
|
29
|
+
* @param {string} path - Path to resource
|
|
30
|
+
* @param {RequestOptions} options - Additional request options
|
|
31
|
+
* @returns {Operation}
|
|
32
|
+
* @state {HttpState}
|
|
33
|
+
*/
|
|
34
|
+
export function get(path: string, options: RequestOptions): Operation;
|
|
35
|
+
/**
|
|
36
|
+
* Make a POST request to the Zata API
|
|
37
|
+
* @example <caption> Create a sale transaction</caption>
|
|
38
|
+
* post('transaction/sale', {
|
|
39
|
+
* body: {
|
|
40
|
+
* "purchaseCode": "43034",
|
|
41
|
+
* "paymentMethodID": 1,
|
|
42
|
+
* "customerID": 1,
|
|
43
|
+
* "transactionDate": "2024-01-01",
|
|
44
|
+
* "note": "string",
|
|
45
|
+
* "customerTIN": "123456789",
|
|
46
|
+
* "customerName": "John Doe",
|
|
47
|
+
* "customerPhone": "123456789",
|
|
48
|
+
* "items": [
|
|
49
|
+
* {
|
|
50
|
+
* "productID": 1,
|
|
51
|
+
* "units": 12.5,
|
|
52
|
+
* "unitPrice": 1000,
|
|
53
|
+
* "discountRate": 100,
|
|
54
|
+
* "batchNumber": "string"
|
|
55
|
+
* }
|
|
56
|
+
* ]
|
|
57
|
+
* },
|
|
58
|
+
* header: {
|
|
59
|
+
* companyId: 1,
|
|
60
|
+
* branchId: 1
|
|
61
|
+
* }
|
|
62
|
+
*})
|
|
63
|
+
* @example <caption>Create a company </caption>
|
|
64
|
+
* post('company', {
|
|
65
|
+
* body: {
|
|
66
|
+
* name: "Zata Point Global Service",
|
|
67
|
+
* address: "No 1, Zata Point Street, Zata Point",
|
|
68
|
+
* phone: "08012345678",
|
|
69
|
+
* email: "sample@sample.com",
|
|
70
|
+
* tin: "123456789"
|
|
71
|
+
* }
|
|
72
|
+
* })
|
|
73
|
+
* @function
|
|
74
|
+
* @public
|
|
75
|
+
* @param {string} path
|
|
76
|
+
* @param {RequestOptions} options
|
|
77
|
+
* @returns {Operation}
|
|
78
|
+
* @state {HttpState}
|
|
79
|
+
*/
|
|
80
|
+
export function post(path: string, options: RequestOptions): Operation;
|
|
81
|
+
/**
|
|
82
|
+
* Make a PUT request to the Zata API
|
|
83
|
+
* @example <caption>Reduce product quantity</caption>
|
|
84
|
+
* put('product/reduce-quantity/{productId}', {
|
|
85
|
+
* body: {
|
|
86
|
+
* quantity: 10,
|
|
87
|
+
* description: 'reason for reducing quantity',
|
|
88
|
+
* batchNumber: 'Batch Number'
|
|
89
|
+
* },
|
|
90
|
+
* header: {
|
|
91
|
+
* companyId: 1,
|
|
92
|
+
* branchId: 1
|
|
93
|
+
* }
|
|
94
|
+
* })
|
|
95
|
+
* @function
|
|
96
|
+
* @public
|
|
97
|
+
* @param {string} path
|
|
98
|
+
* @param {RequestOptions} options
|
|
99
|
+
* @returns {Operation}
|
|
100
|
+
* @state {HttpState}
|
|
101
|
+
*/
|
|
102
|
+
export function put(path: string, options: RequestOptions): Operation;
|
|
103
|
+
/**
|
|
104
|
+
* Make a general HTTP request
|
|
105
|
+
* @example <caption>Create a new sale transaction</caption>
|
|
106
|
+
* request("POST", "transaction/sale",
|
|
107
|
+
* {
|
|
108
|
+
* body: {
|
|
109
|
+
* "purchaseCode": "43034",
|
|
110
|
+
* "paymentMethodID": 1,
|
|
111
|
+
* "customerID": 1,
|
|
112
|
+
* "transactionDate": "2024-01-01",
|
|
113
|
+
* "note": "string",
|
|
114
|
+
* "customerTIN": "123456789",
|
|
115
|
+
* "customerName": "John Doe",
|
|
116
|
+
* "customerPhone": "12345678910",
|
|
117
|
+
* "items": [
|
|
118
|
+
* {
|
|
119
|
+
* "productID": 1,
|
|
120
|
+
* "units": 12.5,
|
|
121
|
+
* "unitPrice": 1000,
|
|
122
|
+
* "discountRate": 100,
|
|
123
|
+
* "batchNumber": "string"
|
|
124
|
+
* }
|
|
125
|
+
* ]
|
|
126
|
+
* },
|
|
127
|
+
* headers: {
|
|
128
|
+
* companyId: 1,
|
|
129
|
+
* branchId: 1
|
|
130
|
+
* }
|
|
131
|
+
* });
|
|
132
|
+
* @function
|
|
133
|
+
* @public
|
|
134
|
+
* @param {string} method - HTTP method to use
|
|
135
|
+
* @param {string} path - Path to resource
|
|
136
|
+
* @param {RequestOptions} options - Additional request options
|
|
137
|
+
* @returns {Operation}
|
|
138
|
+
* @state {HttpState}
|
|
139
|
+
*/
|
|
140
|
+
export function request(method: string, path: string, options?: RequestOptions): Operation;
|
|
141
|
+
/**
|
|
142
|
+
* State object
|
|
143
|
+
*/
|
|
144
|
+
export type HttpState = {
|
|
145
|
+
/**
|
|
146
|
+
* - the parsed response body
|
|
147
|
+
*/
|
|
148
|
+
data: any;
|
|
149
|
+
/**
|
|
150
|
+
* - the response from the HTTP server, including headers, statusCode, body, etc
|
|
151
|
+
*/
|
|
152
|
+
response: any;
|
|
153
|
+
/**
|
|
154
|
+
* - an array of all previous data objects used in the Job
|
|
155
|
+
*/
|
|
156
|
+
references: any;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Options provided to the HTTP request
|
|
160
|
+
*/
|
|
161
|
+
export type RequestOptions = any;
|
|
162
|
+
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
package/types/index.d.ts
ADDED