@openfn/language-satusehat 1.1.3 → 2.0.1
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 +4 -4
- package/dist/index.cjs +15 -10
- package/dist/index.js +11 -11
- package/package.json +4 -3
- package/types/Adaptor.d.ts +4 -4
package/ast.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"callback"
|
|
9
9
|
],
|
|
10
10
|
"docs": {
|
|
11
|
-
"description": "Make a
|
|
11
|
+
"description": "Make a GET request to Satusehat",
|
|
12
12
|
"tags": [
|
|
13
13
|
{
|
|
14
14
|
"title": "public",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"callback"
|
|
73
73
|
],
|
|
74
74
|
"docs": {
|
|
75
|
-
"description": "Make a
|
|
75
|
+
"description": "Make a POST request to Satusehat",
|
|
76
76
|
"tags": [
|
|
77
77
|
{
|
|
78
78
|
"title": "example",
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
"callback"
|
|
149
149
|
],
|
|
150
150
|
"docs": {
|
|
151
|
-
"description": "Make a
|
|
151
|
+
"description": "Make a PUT request to Satusehat",
|
|
152
152
|
"tags": [
|
|
153
153
|
{
|
|
154
154
|
"title": "example",
|
|
@@ -224,7 +224,7 @@
|
|
|
224
224
|
"callback"
|
|
225
225
|
],
|
|
226
226
|
"docs": {
|
|
227
|
-
"description": "Make a
|
|
227
|
+
"description": "Make a PATCH request to Satusehat",
|
|
228
228
|
"tags": [
|
|
229
229
|
{
|
|
230
230
|
"title": "example",
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
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
|
+
));
|
|
17
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
24
|
|
|
19
25
|
// src/index.js
|
|
@@ -70,6 +76,7 @@ var import_util2 = require("@openfn/language-common/util");
|
|
|
70
76
|
|
|
71
77
|
// src/Utils.js
|
|
72
78
|
var import_language_common = require("@openfn/language-common");
|
|
79
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
73
80
|
var import_util = require("@openfn/language-common/util");
|
|
74
81
|
var generateUserAgent = () => {
|
|
75
82
|
return `nodejs/${process.version} @openfn/language-satusehat`;
|
|
@@ -140,15 +147,17 @@ async function request(configuration, path, opts) {
|
|
|
140
147
|
"User-Agent": generateUserAgent(),
|
|
141
148
|
"content-type": contentType
|
|
142
149
|
};
|
|
150
|
+
(0, import_util.assertRelativeUrl)(path);
|
|
151
|
+
const safePath = import_node_path.default.join("fhir-r4/v1", path);
|
|
143
152
|
const options = {
|
|
144
153
|
body: data,
|
|
145
154
|
headers,
|
|
146
155
|
query: params,
|
|
147
156
|
parseAs,
|
|
148
157
|
maxRedirections: 1,
|
|
149
|
-
baseUrl
|
|
158
|
+
baseUrl
|
|
150
159
|
};
|
|
151
|
-
return (0, import_util.request)(method,
|
|
160
|
+
return (0, import_util.request)(method, safePath, options).then(import_util.logResponse);
|
|
152
161
|
}
|
|
153
162
|
|
|
154
163
|
// src/Adaptor.js
|
|
@@ -176,13 +185,12 @@ function get(path, params = {}, callback = (s) => s) {
|
|
|
176
185
|
params
|
|
177
186
|
);
|
|
178
187
|
try {
|
|
179
|
-
const response = await request(state.configuration,
|
|
188
|
+
const response = await request(state.configuration, resolvedPath, {
|
|
180
189
|
method: "GET",
|
|
181
190
|
params: resolvedParams
|
|
182
191
|
});
|
|
183
192
|
return prepareNextState(state, response, callback);
|
|
184
193
|
} catch (e) {
|
|
185
|
-
console.error(JSON.stringify(e.body, null, 2));
|
|
186
194
|
throw e;
|
|
187
195
|
}
|
|
188
196
|
};
|
|
@@ -196,14 +204,13 @@ function post(path, data, params = {}, callback = (s) => s) {
|
|
|
196
204
|
params
|
|
197
205
|
);
|
|
198
206
|
try {
|
|
199
|
-
const response = await request(state.configuration,
|
|
207
|
+
const response = await request(state.configuration, resolvedPath, {
|
|
200
208
|
method: "POST",
|
|
201
209
|
data: resolvedData,
|
|
202
210
|
params: resolvedParams
|
|
203
211
|
});
|
|
204
212
|
return prepareNextState(state, response, callback);
|
|
205
213
|
} catch (e) {
|
|
206
|
-
console.error(JSON.stringify(e.body, null, 2));
|
|
207
214
|
throw e;
|
|
208
215
|
}
|
|
209
216
|
};
|
|
@@ -217,14 +224,13 @@ function put(path, data, params = {}, callback = (s) => s) {
|
|
|
217
224
|
params
|
|
218
225
|
);
|
|
219
226
|
try {
|
|
220
|
-
const response = await request(state.configuration,
|
|
227
|
+
const response = await request(state.configuration, resolvedPath, {
|
|
221
228
|
method: "PUT",
|
|
222
229
|
data: resolvedData,
|
|
223
230
|
params: resolvedParams
|
|
224
231
|
});
|
|
225
232
|
return prepareNextState(state, response, callback);
|
|
226
233
|
} catch (e) {
|
|
227
|
-
console.error(JSON.stringify(e.body, null, 2));
|
|
228
234
|
throw e;
|
|
229
235
|
}
|
|
230
236
|
};
|
|
@@ -238,7 +244,7 @@ function patch(path, data, params = {}, callback = (s) => s) {
|
|
|
238
244
|
params
|
|
239
245
|
);
|
|
240
246
|
try {
|
|
241
|
-
const response = await request(state.configuration,
|
|
247
|
+
const response = await request(state.configuration, resolvedPath, {
|
|
242
248
|
method: "PATCH",
|
|
243
249
|
data: JSON.stringify(resolvedData),
|
|
244
250
|
params: resolvedParams,
|
|
@@ -246,7 +252,6 @@ function patch(path, data, params = {}, callback = (s) => s) {
|
|
|
246
252
|
});
|
|
247
253
|
return prepareNextState(state, response, callback);
|
|
248
254
|
} catch (e) {
|
|
249
|
-
console.error(JSON.stringify(e.body, null, 2));
|
|
250
255
|
throw e;
|
|
251
256
|
}
|
|
252
257
|
};
|
package/dist/index.js
CHANGED
|
@@ -32,9 +32,11 @@ import { expandReferences } from "@openfn/language-common/util";
|
|
|
32
32
|
|
|
33
33
|
// src/Utils.js
|
|
34
34
|
import { composeNextState } from "@openfn/language-common";
|
|
35
|
+
import nodepath from "path";
|
|
35
36
|
import {
|
|
36
37
|
request as commonRequest,
|
|
37
|
-
logResponse
|
|
38
|
+
logResponse,
|
|
39
|
+
assertRelativeUrl
|
|
38
40
|
} from "@openfn/language-common/util";
|
|
39
41
|
var generateUserAgent = () => {
|
|
40
42
|
return `nodejs/${process.version} @openfn/language-satusehat`;
|
|
@@ -105,15 +107,17 @@ async function request(configuration, path, opts) {
|
|
|
105
107
|
"User-Agent": generateUserAgent(),
|
|
106
108
|
"content-type": contentType
|
|
107
109
|
};
|
|
110
|
+
assertRelativeUrl(path);
|
|
111
|
+
const safePath = nodepath.join("fhir-r4/v1", path);
|
|
108
112
|
const options = {
|
|
109
113
|
body: data,
|
|
110
114
|
headers,
|
|
111
115
|
query: params,
|
|
112
116
|
parseAs,
|
|
113
117
|
maxRedirections: 1,
|
|
114
|
-
baseUrl
|
|
118
|
+
baseUrl
|
|
115
119
|
};
|
|
116
|
-
return commonRequest(method,
|
|
120
|
+
return commonRequest(method, safePath, options).then(logResponse);
|
|
117
121
|
}
|
|
118
122
|
|
|
119
123
|
// src/Adaptor.js
|
|
@@ -156,13 +160,12 @@ function get(path, params = {}, callback = (s) => s) {
|
|
|
156
160
|
params
|
|
157
161
|
);
|
|
158
162
|
try {
|
|
159
|
-
const response = await request(state.configuration,
|
|
163
|
+
const response = await request(state.configuration, resolvedPath, {
|
|
160
164
|
method: "GET",
|
|
161
165
|
params: resolvedParams
|
|
162
166
|
});
|
|
163
167
|
return prepareNextState(state, response, callback);
|
|
164
168
|
} catch (e) {
|
|
165
|
-
console.error(JSON.stringify(e.body, null, 2));
|
|
166
169
|
throw e;
|
|
167
170
|
}
|
|
168
171
|
};
|
|
@@ -176,14 +179,13 @@ function post(path, data, params = {}, callback = (s) => s) {
|
|
|
176
179
|
params
|
|
177
180
|
);
|
|
178
181
|
try {
|
|
179
|
-
const response = await request(state.configuration,
|
|
182
|
+
const response = await request(state.configuration, resolvedPath, {
|
|
180
183
|
method: "POST",
|
|
181
184
|
data: resolvedData,
|
|
182
185
|
params: resolvedParams
|
|
183
186
|
});
|
|
184
187
|
return prepareNextState(state, response, callback);
|
|
185
188
|
} catch (e) {
|
|
186
|
-
console.error(JSON.stringify(e.body, null, 2));
|
|
187
189
|
throw e;
|
|
188
190
|
}
|
|
189
191
|
};
|
|
@@ -197,14 +199,13 @@ function put(path, data, params = {}, callback = (s) => s) {
|
|
|
197
199
|
params
|
|
198
200
|
);
|
|
199
201
|
try {
|
|
200
|
-
const response = await request(state.configuration,
|
|
202
|
+
const response = await request(state.configuration, resolvedPath, {
|
|
201
203
|
method: "PUT",
|
|
202
204
|
data: resolvedData,
|
|
203
205
|
params: resolvedParams
|
|
204
206
|
});
|
|
205
207
|
return prepareNextState(state, response, callback);
|
|
206
208
|
} catch (e) {
|
|
207
|
-
console.error(JSON.stringify(e.body, null, 2));
|
|
208
209
|
throw e;
|
|
209
210
|
}
|
|
210
211
|
};
|
|
@@ -218,7 +219,7 @@ function patch(path, data, params = {}, callback = (s) => s) {
|
|
|
218
219
|
params
|
|
219
220
|
);
|
|
220
221
|
try {
|
|
221
|
-
const response = await request(state.configuration,
|
|
222
|
+
const response = await request(state.configuration, resolvedPath, {
|
|
222
223
|
method: "PATCH",
|
|
223
224
|
data: JSON.stringify(resolvedData),
|
|
224
225
|
params: resolvedParams,
|
|
@@ -226,7 +227,6 @@ function patch(path, data, params = {}, callback = (s) => s) {
|
|
|
226
227
|
});
|
|
227
228
|
return prepareNextState(state, response, callback);
|
|
228
229
|
} catch (e) {
|
|
229
|
-
console.error(JSON.stringify(e.body, null, 2));
|
|
230
230
|
throw e;
|
|
231
231
|
}
|
|
232
232
|
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/language-satusehat",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "OpenFn
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "OpenFn Satusehat adaptor",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
8
|
"import": "./dist/index.js",
|
|
9
|
+
"types": "./types/index.d.ts",
|
|
9
10
|
"require": "./dist/index.cjs"
|
|
10
11
|
},
|
|
11
12
|
"./package.json": "./package.json"
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
"configuration-schema.json"
|
|
20
21
|
],
|
|
21
22
|
"dependencies": {
|
|
22
|
-
"@openfn/language-common": "
|
|
23
|
+
"@openfn/language-common": "2.0.1"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
26
|
"assertion-error": "2.0.0",
|
package/types/Adaptor.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
export function execute(...operations: Operations): Operation;
|
|
14
14
|
/**
|
|
15
|
-
* Make a
|
|
15
|
+
* Make a GET request to Satusehat
|
|
16
16
|
* @public
|
|
17
17
|
* @example
|
|
18
18
|
* get("Organization", {"name": "somename"})
|
|
@@ -24,7 +24,7 @@ export function execute(...operations: Operations): Operation;
|
|
|
24
24
|
*/
|
|
25
25
|
export function get(path: string, params?: object, callback?: Function): Operation;
|
|
26
26
|
/**
|
|
27
|
-
* Make a
|
|
27
|
+
* Make a POST request to Satusehat
|
|
28
28
|
* @example
|
|
29
29
|
* post(
|
|
30
30
|
* "Organization",
|
|
@@ -41,7 +41,7 @@ export function get(path: string, params?: object, callback?: Function): Operati
|
|
|
41
41
|
*/
|
|
42
42
|
export function post(path: string, data: object, params?: any, callback?: Function): Operation;
|
|
43
43
|
/**
|
|
44
|
-
* Make a
|
|
44
|
+
* Make a PUT request to Satusehat
|
|
45
45
|
* @example
|
|
46
46
|
* put(
|
|
47
47
|
* "Organization/123",
|
|
@@ -58,7 +58,7 @@ export function post(path: string, data: object, params?: any, callback?: Functi
|
|
|
58
58
|
*/
|
|
59
59
|
export function put(path: string, data: object, params?: any, callback?: Function): Operation;
|
|
60
60
|
/**
|
|
61
|
-
* Make a
|
|
61
|
+
* Make a PATCH request to Satusehat
|
|
62
62
|
* @example
|
|
63
63
|
* patch(
|
|
64
64
|
* "Organization/123",
|