microsoft-graph 2.9.2 → 2.10.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.
@@ -1 +1 @@
1
- {"version":3,"file":"graphApi.d.ts","sourceRoot":"","sources":["../../src/graphApi.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAgB,cAAc,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACzG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAO/C,eAAO,MAAM,mBAAmB,EAA6C,KAAK,CAAC;AACnF,eAAO,MAAM,QAAQ,qCAAqC,CAAC;AAC3D,eAAO,MAAM,aAAa,4CAAuB,CAAC;AAElD,8KAA8K;AAC9K,wBAAgB,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,wBAAwB,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAQvF;AAED,6LAA6L;AAC7L,wBAAsB,QAAQ,CAAC,CAAC,SAAS,cAAc,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,UAAU,EAAE,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAInH;AAED,2DAA2D;AAC3D,wBAAsB,UAAU,CAAC,CAAC,SAAS,cAAc,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,UAAU,EAAE,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAOrH;AAoBD,KAAK,iBAAiB,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;CAChE,CAAC"}
1
+ {"version":3,"file":"graphApi.d.ts","sourceRoot":"","sources":["../../src/graphApi.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAgB,cAAc,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACzG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAO/C,eAAO,MAAM,mBAAmB,EAA6C,KAAK,CAAC;AACnF,eAAO,MAAM,QAAQ,qCAAqC,CAAC;AAC3D,eAAO,MAAM,aAAa,4CAAuB,CAAC;AAElD,8KAA8K;AAC9K,wBAAgB,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,wBAAwB,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAQvF;AAED,6LAA6L;AAC7L,wBAAsB,QAAQ,CAAC,CAAC,SAAS,cAAc,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,UAAU,EAAE,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAInH;AAED,2DAA2D;AAC3D,wBAAsB,UAAU,CAAC,CAAC,SAAS,cAAc,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,UAAU,EAAE,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAOrH;AAoBD,KAAK,iBAAiB,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;CAChE,CAAC"}
@@ -8,6 +8,7 @@ exports.operation = operation;
8
8
  exports.parallel = parallel;
9
9
  exports.sequential = sequential;
10
10
  const axios_1 = __importDefault(require("axios"));
11
+ const https_proxy_agent_1 = require("https-proxy-agent");
11
12
  const InconsistentContextError_ts_1 = __importDefault(require("./errors/InconsistentContextError.js"));
12
13
  const InvalidArgumentError_ts_1 = __importDefault(require("./errors/InvalidArgumentError.js"));
13
14
  const NeverError_ts_1 = __importDefault(require("./errors/NeverError.js"));
@@ -105,7 +106,7 @@ async function executeBatch(...ops) {
105
106
  if (!op) {
106
107
  throw new ProtocolError_ts_1.default("Reference to operation that was not submitted in the batch");
107
108
  }
108
- if (!(0, httpStatus_ts_1.isHttpOk)(r.status)) {
109
+ if (!(0, httpStatus_ts_1.isHttpSuccess)(r.status)) {
109
110
  const bodyError = body;
110
111
  let errorMessage = `${r.status}`;
111
112
  if (bodyError?.error) {
@@ -127,9 +128,21 @@ async function innerFetch(args) {
127
128
  let retryAfterMilliseconds = defaultRetryDelayMilliseconds;
128
129
  let response = null;
129
130
  let attempts = 0; // Track the number of attempts
130
- const instance = axios_1.default.create({
131
- httpsAgent: options.httpAgent,
132
- });
131
+ // TODO: Tidy this proxy work-around:
132
+ let instance;
133
+ // biome-ignore lint/complexity/useLiteralKeys: <explanation>
134
+ const httpsProxy = process.env["HTTPS_PROXY"];
135
+ if (httpsProxy) {
136
+ instance = axios_1.default.create({
137
+ proxy: false,
138
+ httpsAgent: new https_proxy_agent_1.HttpsProxyAgent(httpsProxy),
139
+ });
140
+ }
141
+ else {
142
+ instance = axios_1.default.create({
143
+ httpsAgent: options.httpAgent,
144
+ });
145
+ }
133
146
  while (attempts < maxRetries) {
134
147
  try {
135
148
  response = await instance({
@@ -162,12 +175,9 @@ async function innerFetch(args) {
162
175
  }
163
176
  }
164
177
  if (!response) {
165
- throw new NeverError_ts_1.default("Response is null. Should be impossible");
166
- }
167
- if ((0, httpStatus_ts_1.isHttpTooManyRequests)(response.status)) {
168
- RequestFailedError_ts_1.default.throw("GraphAPI fetch failed after 3 retries due to too many requests.", args);
178
+ throw new NeverError_ts_1.default("Response is empty.");
169
179
  }
170
- if (!(0, httpStatus_ts_1.isHttpOk)(response.status)) {
180
+ if (!(0, httpStatus_ts_1.isHttpSuccess)(response.status)) {
171
181
  const bodyError = response.data;
172
182
  let errorMessage = `${response.status} '${response.statusText}'`;
173
183
  if (bodyError?.error) {
@@ -0,0 +1,10 @@
1
+ import type { DriveItemPath } from "../../models/DriveItemPath.ts";
2
+ import type { DriveRef } from "../../models/DriveRef.ts";
3
+ /**
4
+ * Check if a given drive item exists.
5
+ *
6
+ * @param itemRef - A reference to the drive item to be downloaded.
7
+ * @returns If the drive item exists.
8
+ */
9
+ export default function existsDriveItem(driveRef: DriveRef, itemPath: DriveItemPath): Promise<boolean>;
10
+ //# sourceMappingURL=existsDriveItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"existsDriveItem.d.ts","sourceRoot":"","sources":["../../../../src/operations/driveItem/existsDriveItem.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAMzD;;;;;GAKG;AACH,wBAA8B,eAAe,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAwB3G"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = existsDriveItem;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const graphApi_ts_1 = require("../../graphApi.js");
9
+ const accessToken_ts_1 = require("../../services/accessToken.js");
10
+ const context_ts_1 = require("../../services/context.js");
11
+ const httpStatus_ts_1 = require("../../services/httpStatus.js");
12
+ const templatedPaths_ts_1 = require("../../services/templatedPaths.js");
13
+ /**
14
+ * Check if a given drive item exists.
15
+ *
16
+ * @param itemRef - A reference to the drive item to be downloaded.
17
+ * @returns If the drive item exists.
18
+ */
19
+ async function existsDriveItem(driveRef, itemPath) {
20
+ // Note this method doesn't match the standard pattern since the batching library doesn't support non-JSON return types.
21
+ const url = `${graphApi_ts_1.endpoint}${(0, templatedPaths_ts_1.generatePath)(`/sites/{site-id}/drives/{drive-id}/root:${itemPath}`, driveRef)}`;
22
+ const context = (0, context_ts_1.getContext)(driveRef.contextId);
23
+ const accessToken = await (0, accessToken_ts_1.getCurrentAccessToken)(context.tenantId, context.clientId, context.clientSecret, graphApi_ts_1.authenticationScope);
24
+ const response = await (0, axios_1.default)({
25
+ url,
26
+ method: "GET",
27
+ headers: {
28
+ authorization: `Bearer ${accessToken}`,
29
+ },
30
+ validateStatus: () => true,
31
+ });
32
+ if ((0, httpStatus_ts_1.isHttpOk)(response.status)) {
33
+ return true;
34
+ }
35
+ if ((0, httpStatus_ts_1.isHttpNotFound)(response.status)) {
36
+ return false;
37
+ }
38
+ throw new Error(`Unexpected response status: ${response.status} ${response.statusText}`);
39
+ }
@@ -31,7 +31,7 @@ async function getDriveItemContent(itemRef) {
31
31
  },
32
32
  responseType: "arraybuffer",
33
33
  });
34
- if (!(0, httpStatus_ts_1.isHttpOk)(response.status)) {
34
+ if (!(0, httpStatus_ts_1.isHttpSuccess)(response.status)) {
35
35
  throw new Error(`Failed to download file: ${response.status} ${response.statusText}`);
36
36
  }
37
37
  if (!Buffer.isBuffer(response.data)) {
@@ -3,7 +3,19 @@
3
3
  * @param status - The HTTP status code.
4
4
  * @returns True if the status code is in the range 200-299, otherwise false.
5
5
  */
6
+ export declare function isHttpSuccess(status: number): boolean;
7
+ /**
8
+ * Checks if the HTTP status code is OK
9
+ * @param status - The HTTP status code.
10
+ * @returns True if the status code is 200, otherwise false.
11
+ */
6
12
  export declare function isHttpOk(status: number): boolean;
13
+ /**
14
+ * Checks if the HTTP status code indicates not found.
15
+ * @param status - The HTTP status code.
16
+ * @returns True if the status code is 404, otherwise false.
17
+ */
18
+ export declare function isHttpNotFound(status: number): boolean;
7
19
  /**
8
20
  * Checks if the HTTP status code indicates too many requests (rate limiting).
9
21
  * @param status - The HTTP status code.
@@ -1 +1 @@
1
- {"version":3,"file":"httpStatus.d.ts","sourceRoot":"","sources":["../../../src/services/httpStatus.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAExD"}
1
+ {"version":3,"file":"httpStatus.d.ts","sourceRoot":"","sources":["../../../src/services/httpStatus.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAExD"}
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isHttpSuccess = isHttpSuccess;
3
4
  exports.isHttpOk = isHttpOk;
5
+ exports.isHttpNotFound = isHttpNotFound;
4
6
  exports.isHttpTooManyRequests = isHttpTooManyRequests;
5
7
  exports.isServiceUnavailable = isServiceUnavailable;
6
8
  exports.isGatewayTimeout = isGatewayTimeout;
@@ -9,9 +11,25 @@ exports.isGatewayTimeout = isGatewayTimeout;
9
11
  * @param status - The HTTP status code.
10
12
  * @returns True if the status code is in the range 200-299, otherwise false.
11
13
  */
12
- function isHttpOk(status) {
14
+ function isHttpSuccess(status) {
13
15
  return status >= 200 && status < 300;
14
16
  }
17
+ /**
18
+ * Checks if the HTTP status code is OK
19
+ * @param status - The HTTP status code.
20
+ * @returns True if the status code is 200, otherwise false.
21
+ */
22
+ function isHttpOk(status) {
23
+ return status === 200;
24
+ }
25
+ /**
26
+ * Checks if the HTTP status code indicates not found.
27
+ * @param status - The HTTP status code.
28
+ * @returns True if the status code is 404, otherwise false.
29
+ */
30
+ function isHttpNotFound(status) {
31
+ return status === 404;
32
+ }
15
33
  /**
16
34
  * Checks if the HTTP status code indicates too many requests (rate limiting).
17
35
  * @param status - The HTTP status code.
@@ -1,7 +1,10 @@
1
1
  import type { WorkbookRef } from "../models/WorkbookRef.ts";
2
2
  import type { WorkbookWorksheetId } from "../models/WorkbookWorksheetId.ts";
3
3
  import type { WorkbookWorksheetRef } from "../models/WorkbookWorksheetRef.ts";
4
+ /** ID of the initial worksheet that is included in a new workbook. */
4
5
  export declare const defaultWorkbookWorksheetId: WorkbookWorksheetId;
6
+ /** Name of the initial worksheet that is included in a new workbook. */
7
+ export declare const defaultWorkbookWorksheetName = "Sheet1";
5
8
  /**
6
9
  * Creates a reference to a workbook worksheet.
7
10
  * @param workbookRef - The reference to the workbook.
@@ -1 +1 @@
1
- {"version":3,"file":"workbookWorksheet.d.ts","sourceRoot":"","sources":["../../../src/services/workbookWorksheet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,eAAO,MAAM,0BAA0B,EAA+C,mBAAmB,CAAC;AAE1G;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,mBAAmB,GAAG,SAAS,GAAG,oBAAoB,CAavI;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAAC,WAAW,EAAE,WAAW,GAAG,oBAAoB,CAEhG"}
1
+ {"version":3,"file":"workbookWorksheet.d.ts","sourceRoot":"","sources":["../../../src/services/workbookWorksheet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,sEAAsE;AACtE,eAAO,MAAM,0BAA0B,EAA+C,mBAAmB,CAAC;AAE1G,wEAAwE;AACxE,eAAO,MAAM,4BAA4B,WAAW,CAAC;AAErD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,mBAAmB,GAAG,SAAS,GAAG,oBAAoB,CAavI;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAAC,WAAW,EAAE,WAAW,GAAG,oBAAoB,CAEhG"}
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultWorkbookWorksheetId = void 0;
3
+ exports.defaultWorkbookWorksheetName = exports.defaultWorkbookWorksheetId = void 0;
4
4
  exports.createWorkbookWorksheetRef = createWorkbookWorksheetRef;
5
5
  exports.createDefaultWorkbookWorksheetRef = createDefaultWorkbookWorksheetRef;
6
+ /** ID of the initial worksheet that is included in a new workbook. */
6
7
  exports.defaultWorkbookWorksheetId = "{00000000-0001-0000-0000-000000000000}"; // Program Manager in Microsoft Office Extensibility team says this ID is used for the first sheet of all workbooks by design, but not documented. https://github.com/OfficeDev/office-js/issues/552#issuecomment-800841930
8
+ /** Name of the initial worksheet that is included in a new workbook. */
9
+ exports.defaultWorkbookWorksheetName = "Sheet1";
7
10
  /**
8
11
  * Creates a reference to a workbook worksheet.
9
12
  * @param workbookRef - The reference to the workbook.
@@ -1 +1 @@
1
- {"version":3,"file":"graphApi.d.ts","sourceRoot":"","sources":["../../src/graphApi.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAgB,cAAc,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACzG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAO/C,eAAO,MAAM,mBAAmB,EAA6C,KAAK,CAAC;AACnF,eAAO,MAAM,QAAQ,qCAAqC,CAAC;AAC3D,eAAO,MAAM,aAAa,4CAAuB,CAAC;AAElD,8KAA8K;AAC9K,wBAAgB,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,wBAAwB,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAQvF;AAED,6LAA6L;AAC7L,wBAAsB,QAAQ,CAAC,CAAC,SAAS,cAAc,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,UAAU,EAAE,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAInH;AAED,2DAA2D;AAC3D,wBAAsB,UAAU,CAAC,CAAC,SAAS,cAAc,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,UAAU,EAAE,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAOrH;AAoBD,KAAK,iBAAiB,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;CAChE,CAAC"}
1
+ {"version":3,"file":"graphApi.d.ts","sourceRoot":"","sources":["../../src/graphApi.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAgB,cAAc,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACzG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAO/C,eAAO,MAAM,mBAAmB,EAA6C,KAAK,CAAC;AACnF,eAAO,MAAM,QAAQ,qCAAqC,CAAC;AAC3D,eAAO,MAAM,aAAa,4CAAuB,CAAC;AAElD,8KAA8K;AAC9K,wBAAgB,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,wBAAwB,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAQvF;AAED,6LAA6L;AAC7L,wBAAsB,QAAQ,CAAC,CAAC,SAAS,cAAc,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,UAAU,EAAE,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAInH;AAED,2DAA2D;AAC3D,wBAAsB,UAAU,CAAC,CAAC,SAAS,cAAc,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,UAAU,EAAE,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAOrH;AAoBD,KAAK,iBAAiB,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;CAChE,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import axios from "axios";
2
+ import { HttpsProxyAgent } from "https-proxy-agent";
2
3
  import InconsistentContextError from "./errors/InconsistentContextError.js";
3
4
  import InvalidArgumentError from "./errors/InvalidArgumentError.js";
4
5
  import NeverError from "./errors/NeverError.js";
@@ -6,7 +7,7 @@ import ProtocolError from "./errors/ProtocolError.js";
6
7
  import RequestFailedError from "./errors/RequestFailedError.js";
7
8
  import { getCurrentAccessToken } from "./services/accessToken.js";
8
9
  import { getContext } from "./services/context.js";
9
- import { isGatewayTimeout, isHttpOk, isHttpTooManyRequests, isServiceUnavailable } from "./services/httpStatus.js";
10
+ import { isGatewayTimeout, isHttpSuccess, isHttpTooManyRequests, isServiceUnavailable } from "./services/httpStatus.js";
10
11
  import { operationIdToIndex, operationIndexToId } from "./services/operationId.js";
11
12
  import { sleep } from "./services/sleep.js";
12
13
  export const authenticationScope = "https://graph.microsoft.com/.default";
@@ -96,7 +97,7 @@ async function executeBatch(...ops) {
96
97
  if (!op) {
97
98
  throw new ProtocolError("Reference to operation that was not submitted in the batch");
98
99
  }
99
- if (!isHttpOk(r.status)) {
100
+ if (!isHttpSuccess(r.status)) {
100
101
  const bodyError = body;
101
102
  let errorMessage = `${r.status}`;
102
103
  if (bodyError?.error) {
@@ -118,9 +119,21 @@ async function innerFetch(args) {
118
119
  let retryAfterMilliseconds = defaultRetryDelayMilliseconds;
119
120
  let response = null;
120
121
  let attempts = 0; // Track the number of attempts
121
- const instance = axios.create({
122
- httpsAgent: options.httpAgent,
123
- });
122
+ // TODO: Tidy this proxy work-around:
123
+ let instance;
124
+ // biome-ignore lint/complexity/useLiteralKeys: <explanation>
125
+ const httpsProxy = process.env["HTTPS_PROXY"];
126
+ if (httpsProxy) {
127
+ instance = axios.create({
128
+ proxy: false,
129
+ httpsAgent: new HttpsProxyAgent(httpsProxy),
130
+ });
131
+ }
132
+ else {
133
+ instance = axios.create({
134
+ httpsAgent: options.httpAgent,
135
+ });
136
+ }
124
137
  while (attempts < maxRetries) {
125
138
  try {
126
139
  response = await instance({
@@ -153,12 +166,9 @@ async function innerFetch(args) {
153
166
  }
154
167
  }
155
168
  if (!response) {
156
- throw new NeverError("Response is null. Should be impossible");
157
- }
158
- if (isHttpTooManyRequests(response.status)) {
159
- RequestFailedError.throw("GraphAPI fetch failed after 3 retries due to too many requests.", args);
169
+ throw new NeverError("Response is empty.");
160
170
  }
161
- if (!isHttpOk(response.status)) {
171
+ if (!isHttpSuccess(response.status)) {
162
172
  const bodyError = response.data;
163
173
  let errorMessage = `${response.status} '${response.statusText}'`;
164
174
  if (bodyError?.error) {
@@ -0,0 +1,10 @@
1
+ import type { DriveItemPath } from "../../models/DriveItemPath.ts";
2
+ import type { DriveRef } from "../../models/DriveRef.ts";
3
+ /**
4
+ * Check if a given drive item exists.
5
+ *
6
+ * @param itemRef - A reference to the drive item to be downloaded.
7
+ * @returns If the drive item exists.
8
+ */
9
+ export default function existsDriveItem(driveRef: DriveRef, itemPath: DriveItemPath): Promise<boolean>;
10
+ //# sourceMappingURL=existsDriveItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"existsDriveItem.d.ts","sourceRoot":"","sources":["../../../../src/operations/driveItem/existsDriveItem.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAMzD;;;;;GAKG;AACH,wBAA8B,eAAe,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAwB3G"}
@@ -0,0 +1,33 @@
1
+ import axios from "axios";
2
+ import { authenticationScope, endpoint } from "../../graphApi.js";
3
+ import { getCurrentAccessToken } from "../../services/accessToken.js";
4
+ import { getContext } from "../../services/context.js";
5
+ import { isHttpNotFound, isHttpOk } from "../../services/httpStatus.js";
6
+ import { generatePath } from "../../services/templatedPaths.js";
7
+ /**
8
+ * Check if a given drive item exists.
9
+ *
10
+ * @param itemRef - A reference to the drive item to be downloaded.
11
+ * @returns If the drive item exists.
12
+ */
13
+ export default async function existsDriveItem(driveRef, itemPath) {
14
+ // Note this method doesn't match the standard pattern since the batching library doesn't support non-JSON return types.
15
+ const url = `${endpoint}${generatePath(`/sites/{site-id}/drives/{drive-id}/root:${itemPath}`, driveRef)}`;
16
+ const context = getContext(driveRef.contextId);
17
+ const accessToken = await getCurrentAccessToken(context.tenantId, context.clientId, context.clientSecret, authenticationScope);
18
+ const response = await axios({
19
+ url,
20
+ method: "GET",
21
+ headers: {
22
+ authorization: `Bearer ${accessToken}`,
23
+ },
24
+ validateStatus: () => true,
25
+ });
26
+ if (isHttpOk(response.status)) {
27
+ return true;
28
+ }
29
+ if (isHttpNotFound(response.status)) {
30
+ return false;
31
+ }
32
+ throw new Error(`Unexpected response status: ${response.status} ${response.statusText}`);
33
+ }
@@ -2,7 +2,7 @@ import axios from "axios";
2
2
  import { authenticationScope, endpoint } from "../../graphApi.js";
3
3
  import { getCurrentAccessToken } from "../../services/accessToken.js";
4
4
  import { getContext } from "../../services/context.js";
5
- import { isHttpOk } from "../../services/httpStatus.js";
5
+ import { isHttpSuccess } from "../../services/httpStatus.js";
6
6
  import { generatePath } from "../../services/templatedPaths.js";
7
7
  /**
8
8
  * Download the content of a drive item.
@@ -25,7 +25,7 @@ export default async function getDriveItemContent(itemRef) {
25
25
  },
26
26
  responseType: "arraybuffer",
27
27
  });
28
- if (!isHttpOk(response.status)) {
28
+ if (!isHttpSuccess(response.status)) {
29
29
  throw new Error(`Failed to download file: ${response.status} ${response.statusText}`);
30
30
  }
31
31
  if (!Buffer.isBuffer(response.data)) {
@@ -3,7 +3,19 @@
3
3
  * @param status - The HTTP status code.
4
4
  * @returns True if the status code is in the range 200-299, otherwise false.
5
5
  */
6
+ export declare function isHttpSuccess(status: number): boolean;
7
+ /**
8
+ * Checks if the HTTP status code is OK
9
+ * @param status - The HTTP status code.
10
+ * @returns True if the status code is 200, otherwise false.
11
+ */
6
12
  export declare function isHttpOk(status: number): boolean;
13
+ /**
14
+ * Checks if the HTTP status code indicates not found.
15
+ * @param status - The HTTP status code.
16
+ * @returns True if the status code is 404, otherwise false.
17
+ */
18
+ export declare function isHttpNotFound(status: number): boolean;
7
19
  /**
8
20
  * Checks if the HTTP status code indicates too many requests (rate limiting).
9
21
  * @param status - The HTTP status code.
@@ -1 +1 @@
1
- {"version":3,"file":"httpStatus.d.ts","sourceRoot":"","sources":["../../../src/services/httpStatus.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAExD"}
1
+ {"version":3,"file":"httpStatus.d.ts","sourceRoot":"","sources":["../../../src/services/httpStatus.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAExD"}
@@ -3,9 +3,25 @@
3
3
  * @param status - The HTTP status code.
4
4
  * @returns True if the status code is in the range 200-299, otherwise false.
5
5
  */
6
- export function isHttpOk(status) {
6
+ export function isHttpSuccess(status) {
7
7
  return status >= 200 && status < 300;
8
8
  }
9
+ /**
10
+ * Checks if the HTTP status code is OK
11
+ * @param status - The HTTP status code.
12
+ * @returns True if the status code is 200, otherwise false.
13
+ */
14
+ export function isHttpOk(status) {
15
+ return status === 200;
16
+ }
17
+ /**
18
+ * Checks if the HTTP status code indicates not found.
19
+ * @param status - The HTTP status code.
20
+ * @returns True if the status code is 404, otherwise false.
21
+ */
22
+ export function isHttpNotFound(status) {
23
+ return status === 404;
24
+ }
9
25
  /**
10
26
  * Checks if the HTTP status code indicates too many requests (rate limiting).
11
27
  * @param status - The HTTP status code.
@@ -1,7 +1,10 @@
1
1
  import type { WorkbookRef } from "../models/WorkbookRef.ts";
2
2
  import type { WorkbookWorksheetId } from "../models/WorkbookWorksheetId.ts";
3
3
  import type { WorkbookWorksheetRef } from "../models/WorkbookWorksheetRef.ts";
4
+ /** ID of the initial worksheet that is included in a new workbook. */
4
5
  export declare const defaultWorkbookWorksheetId: WorkbookWorksheetId;
6
+ /** Name of the initial worksheet that is included in a new workbook. */
7
+ export declare const defaultWorkbookWorksheetName = "Sheet1";
5
8
  /**
6
9
  * Creates a reference to a workbook worksheet.
7
10
  * @param workbookRef - The reference to the workbook.
@@ -1 +1 @@
1
- {"version":3,"file":"workbookWorksheet.d.ts","sourceRoot":"","sources":["../../../src/services/workbookWorksheet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,eAAO,MAAM,0BAA0B,EAA+C,mBAAmB,CAAC;AAE1G;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,mBAAmB,GAAG,SAAS,GAAG,oBAAoB,CAavI;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAAC,WAAW,EAAE,WAAW,GAAG,oBAAoB,CAEhG"}
1
+ {"version":3,"file":"workbookWorksheet.d.ts","sourceRoot":"","sources":["../../../src/services/workbookWorksheet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,sEAAsE;AACtE,eAAO,MAAM,0BAA0B,EAA+C,mBAAmB,CAAC;AAE1G,wEAAwE;AACxE,eAAO,MAAM,4BAA4B,WAAW,CAAC;AAErD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,mBAAmB,GAAG,SAAS,GAAG,oBAAoB,CAavI;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAAC,WAAW,EAAE,WAAW,GAAG,oBAAoB,CAEhG"}
@@ -1,4 +1,7 @@
1
+ /** ID of the initial worksheet that is included in a new workbook. */
1
2
  export const defaultWorkbookWorksheetId = "{00000000-0001-0000-0000-000000000000}"; // Program Manager in Microsoft Office Extensibility team says this ID is used for the first sheet of all workbooks by design, but not documented. https://github.com/OfficeDev/office-js/issues/552#issuecomment-800841930
3
+ /** Name of the initial worksheet that is included in a new workbook. */
4
+ export const defaultWorkbookWorksheetName = "Sheet1";
2
5
  /**
3
6
  * Creates a reference to a workbook worksheet.
4
7
  * @param workbookRef - The reference to the workbook.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microsoft-graph",
3
- "version": "2.9.2",
3
+ "version": "2.10.0",
4
4
  "description": "Microsoft GraphAPI SDK for NodeJS",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -317,6 +317,11 @@
317
317
  "require": "./dist/cjs/operations/driveItem/deleteDriveItem.js",
318
318
  "types": "./dist/esm/operations/driveItem/deleteDriveItem.d.ts"
319
319
  },
320
+ "./operations/driveItem/existsDriveItem": {
321
+ "import": "./dist/esm/operations/driveItem/existsDriveItem.js",
322
+ "require": "./dist/cjs/operations/driveItem/existsDriveItem.js",
323
+ "types": "./dist/esm/operations/driveItem/existsDriveItem.d.ts"
324
+ },
320
325
  "./operations/driveItem/getDriveItem": {
321
326
  "import": "./dist/esm/operations/driveItem/getDriveItem.js",
322
327
  "require": "./dist/cjs/operations/driveItem/getDriveItem.js",
@@ -1012,6 +1017,11 @@
1012
1017
  "import": "./dist/esm/operations/driveItem/deleteDriveItem.js",
1013
1018
  "types": "./dist/esm/operations/driveItem/deleteDriveItem.d.ts"
1014
1019
  },
1020
+ "./dist/cjs/operations/driveItem/existsDriveItem.js": {
1021
+ "require": "./dist/cjs/operations/driveItem/existsDriveItem.js",
1022
+ "import": "./dist/esm/operations/driveItem/existsDriveItem.js",
1023
+ "types": "./dist/esm/operations/driveItem/existsDriveItem.d.ts"
1024
+ },
1015
1025
  "./dist/cjs/operations/driveItem/getDriveItem.js": {
1016
1026
  "require": "./dist/cjs/operations/driveItem/getDriveItem.js",
1017
1027
  "import": "./dist/esm/operations/driveItem/getDriveItem.js",