@openfn/language-msgraph 0.3.2 → 0.3.3

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
@@ -68,6 +68,7 @@ var import_util = require("@openfn/language-common/util");
68
68
 
69
69
  // src/Utils.js
70
70
  var import_undici = require("undici");
71
+ var import_node_stream = require("stream");
71
72
  var import_language_common = require("@openfn/language-common");
72
73
  function assertDrive(state, driveName) {
73
74
  if (!state.drives[driveName]) {
@@ -97,11 +98,30 @@ function isValidHttpUrl(string) {
97
98
  function getAuth(token) {
98
99
  return token ? { headers: { Authorization: `Bearer ${token}` } } : null;
99
100
  }
101
+ var isStream = (value) => {
102
+ if (value && typeof value == "object") {
103
+ if (value instanceof import_node_stream.Readable || value instanceof import_node_stream.Writable) {
104
+ return true;
105
+ }
106
+ if (value.pipeTo || value.pipe) {
107
+ return true;
108
+ }
109
+ }
110
+ return false;
111
+ };
100
112
  function handleResponse(response, state, callback) {
101
- const nextState = {
102
- ...(0, import_language_common.composeNextState)(state, response),
103
- response
104
- };
113
+ let nextState;
114
+ if (isStream(response)) {
115
+ nextState = {
116
+ ...state,
117
+ data: response
118
+ };
119
+ } else {
120
+ nextState = {
121
+ ...(0, import_language_common.composeNextState)(state, response),
122
+ response
123
+ };
124
+ }
105
125
  if (callback)
106
126
  return callback(nextState);
107
127
  return nextState;
@@ -135,7 +155,7 @@ var request = async (urlString, params = {}, method = "GET") => {
135
155
  }
136
156
  const response = await (0, import_undici.fetch)(url, options);
137
157
  const contentType = response.headers.get("Content-Type");
138
- const data = (contentType == null ? void 0 : contentType.includes("application/json")) ? await response.json() : await response.text();
158
+ const data = (contentType == null ? void 0 : contentType.includes("application/json")) ? await response.json() : response.body;
139
159
  handleResponseError(response, data, method);
140
160
  return data;
141
161
  };
package/dist/index.js CHANGED
@@ -31,6 +31,7 @@ import { expandReferences } from "@openfn/language-common/util";
31
31
 
32
32
  // src/Utils.js
33
33
  import { fetch } from "undici";
34
+ import { Readable, Writable } from "stream";
34
35
  import { composeNextState } from "@openfn/language-common";
35
36
  function assertDrive(state, driveName) {
36
37
  if (!state.drives[driveName]) {
@@ -60,11 +61,30 @@ function isValidHttpUrl(string) {
60
61
  function getAuth(token) {
61
62
  return token ? { headers: { Authorization: `Bearer ${token}` } } : null;
62
63
  }
64
+ var isStream = (value) => {
65
+ if (value && typeof value == "object") {
66
+ if (value instanceof Readable || value instanceof Writable) {
67
+ return true;
68
+ }
69
+ if (value.pipeTo || value.pipe) {
70
+ return true;
71
+ }
72
+ }
73
+ return false;
74
+ };
63
75
  function handleResponse(response, state, callback) {
64
- const nextState = {
65
- ...composeNextState(state, response),
66
- response
67
- };
76
+ let nextState;
77
+ if (isStream(response)) {
78
+ nextState = {
79
+ ...state,
80
+ data: response
81
+ };
82
+ } else {
83
+ nextState = {
84
+ ...composeNextState(state, response),
85
+ response
86
+ };
87
+ }
68
88
  if (callback)
69
89
  return callback(nextState);
70
90
  return nextState;
@@ -98,7 +118,7 @@ var request = async (urlString, params = {}, method = "GET") => {
98
118
  }
99
119
  const response = await fetch(url, options);
100
120
  const contentType = response.headers.get("Content-Type");
101
- const data = (contentType == null ? void 0 : contentType.includes("application/json")) ? await response.json() : await response.text();
121
+ const data = (contentType == null ? void 0 : contentType.includes("application/json")) ? await response.json() : response.body;
102
122
  handleResponseError(response, data, method);
103
123
  return data;
104
124
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-msgraph",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Microsoft Graph Language Pack for OpenFn",
5
5
  "type": "module",
6
6
  "exports": {
@@ -19,7 +19,7 @@
19
19
  "configuration-schema.json"
20
20
  ],
21
21
  "dependencies": {
22
- "@openfn/language-common": "^1.10.1",
22
+ "@openfn/language-common": "1.10.3",
23
23
  "undici": "^5.22.1"
24
24
  },
25
25
  "devDependencies": {