@openfn/language-msgraph 0.3.3 → 0.3.5

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/dist/index.cjs CHANGED
@@ -141,8 +141,9 @@ function handleResponseError(response, data, method) {
141
141
  var request = async (urlString, params = {}, method = "GET") => {
142
142
  let url = urlString;
143
143
  const defaultHeaders = { "Content-Type": "application/json" };
144
- const { headers } = params;
144
+ const { headers, parseAs } = params;
145
145
  const setHeaders = { ...headers, ...defaultHeaders };
146
+ delete params.parseAs;
146
147
  delete params.headers;
147
148
  let options = {
148
149
  method,
@@ -155,7 +156,15 @@ var request = async (urlString, params = {}, method = "GET") => {
155
156
  }
156
157
  const response = await (0, import_undici.fetch)(url, options);
157
158
  const contentType = response.headers.get("Content-Type");
158
- const data = (contentType == null ? void 0 : contentType.includes("application/json")) ? await response.json() : response.body;
159
+ let data;
160
+ if (parseAs) {
161
+ if (parseAs === "json")
162
+ data = await response.json();
163
+ if (parseAs === "text")
164
+ data = await response.text();
165
+ } else {
166
+ data = (contentType == null ? void 0 : contentType.includes("application/json")) ? await response.json() : response.body;
167
+ }
159
168
  handleResponseError(response, data, method);
160
169
  return data;
161
170
  };
@@ -269,11 +278,11 @@ function getFolder(pathOrId, options, callback = (s) => s) {
269
278
  };
270
279
  }
271
280
  function getFile(pathOrId, options, callback = (s) => s) {
281
+ const defaultOptions = {
282
+ driveName: "default",
283
+ metadata: false
284
+ };
272
285
  return async (state) => {
273
- const defaultOptions = {
274
- driveName: "default",
275
- metadata: false
276
- };
277
286
  const { accessToken, apiVersion } = state.configuration;
278
287
  const [resolvedPathOrId, resolvedOptions] = (0, import_util.expandReferences)(
279
288
  state,
@@ -299,9 +308,11 @@ function getFile(pathOrId, options, callback = (s) => s) {
299
308
  }
300
309
  const url = getUrl(resource, apiVersion);
301
310
  const auth = getAuth(accessToken);
302
- return request(url, { ...auth }).then(
303
- (response) => handleResponse(response, state, callback)
304
- );
311
+ const response = await request(url, {
312
+ ...auth,
313
+ parseAs: metadata ? "json" : "text"
314
+ });
315
+ return handleResponse(response, state, callback);
305
316
  };
306
317
  }
307
318
 
package/dist/index.js CHANGED
@@ -104,8 +104,9 @@ function handleResponseError(response, data, method) {
104
104
  var request = async (urlString, params = {}, method = "GET") => {
105
105
  let url = urlString;
106
106
  const defaultHeaders = { "Content-Type": "application/json" };
107
- const { headers } = params;
107
+ const { headers, parseAs } = params;
108
108
  const setHeaders = { ...headers, ...defaultHeaders };
109
+ delete params.parseAs;
109
110
  delete params.headers;
110
111
  let options = {
111
112
  method,
@@ -118,7 +119,15 @@ var request = async (urlString, params = {}, method = "GET") => {
118
119
  }
119
120
  const response = await fetch(url, options);
120
121
  const contentType = response.headers.get("Content-Type");
121
- const data = (contentType == null ? void 0 : contentType.includes("application/json")) ? await response.json() : response.body;
122
+ let data;
123
+ if (parseAs) {
124
+ if (parseAs === "json")
125
+ data = await response.json();
126
+ if (parseAs === "text")
127
+ data = await response.text();
128
+ } else {
129
+ data = (contentType == null ? void 0 : contentType.includes("application/json")) ? await response.json() : response.body;
130
+ }
122
131
  handleResponseError(response, data, method);
123
132
  return data;
124
133
  };
@@ -244,11 +253,11 @@ function getFolder(pathOrId, options, callback = (s) => s) {
244
253
  };
245
254
  }
246
255
  function getFile(pathOrId, options, callback = (s) => s) {
256
+ const defaultOptions = {
257
+ driveName: "default",
258
+ metadata: false
259
+ };
247
260
  return async (state) => {
248
- const defaultOptions = {
249
- driveName: "default",
250
- metadata: false
251
- };
252
261
  const { accessToken, apiVersion } = state.configuration;
253
262
  const [resolvedPathOrId, resolvedOptions] = expandReferences(
254
263
  state,
@@ -274,9 +283,11 @@ function getFile(pathOrId, options, callback = (s) => s) {
274
283
  }
275
284
  const url = getUrl(resource, apiVersion);
276
285
  const auth = getAuth(accessToken);
277
- return request(url, { ...auth }).then(
278
- (response) => handleResponse(response, state, callback)
279
- );
286
+ const response = await request(url, {
287
+ ...auth,
288
+ parseAs: metadata ? "json" : "text"
289
+ });
290
+ return handleResponse(response, state, callback);
280
291
  };
281
292
  }
282
293
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-msgraph",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Microsoft Graph Language Pack for OpenFn",
5
5
  "type": "module",
6
6
  "exports": {
@@ -19,8 +19,8 @@
19
19
  "configuration-schema.json"
20
20
  ],
21
21
  "dependencies": {
22
- "@openfn/language-common": "1.10.3",
23
- "undici": "^5.22.1"
22
+ "undici": "^5.22.1",
23
+ "@openfn/language-common": "1.11.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@openfn/buildtools": "^1.0.2",