microsoft-graph 2.16.0 → 2.17.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/dist/cjs/errors/InvalidOperationError.d.ts +4 -0
- package/dist/cjs/errors/InvalidOperationError.d.ts.map +1 -0
- package/dist/cjs/errors/InvalidOperationError.js +9 -0
- package/dist/cjs/graphApi.js +2 -2
- package/dist/cjs/models/Item.d.ts +9 -0
- package/dist/cjs/models/Item.d.ts.map +1 -0
- package/dist/cjs/models/Item.js +2 -0
- package/dist/cjs/models/RecordBase.d.ts +3 -0
- package/dist/cjs/models/RecordBase.d.ts.map +1 -0
- package/dist/cjs/models/RecordBase.js +2 -0
- package/dist/cjs/models/RowNumber.d.ts +4 -0
- package/dist/cjs/models/RowNumber.d.ts.map +1 -0
- package/dist/cjs/models/RowNumber.js +2 -0
- package/dist/cjs/models/Source.d.ts +15 -0
- package/dist/cjs/models/Source.d.ts.map +1 -0
- package/dist/cjs/models/Source.js +2 -0
- package/dist/cjs/models/SourceDecoder.d.ts +4 -0
- package/dist/cjs/models/SourceDecoder.d.ts.map +1 -0
- package/dist/cjs/models/SourceDecoder.js +2 -0
- package/dist/cjs/models/SourceEncoder.d.ts +4 -0
- package/dist/cjs/models/SourceEncoder.d.ts.map +1 -0
- package/dist/cjs/models/SourceEncoder.js +2 -0
- package/dist/cjs/models/SourceRow.d.ts +4 -0
- package/dist/cjs/models/SourceRow.d.ts.map +1 -0
- package/dist/cjs/models/SourceRow.js +2 -0
- package/dist/cjs/models/SourceRowValue.d.ts +4 -0
- package/dist/cjs/models/SourceRowValue.d.ts.map +1 -0
- package/dist/cjs/models/SourceRowValue.js +2 -0
- package/dist/cjs/services/addressOffset.d.ts +1 -1
- package/dist/cjs/services/addressOffset.js +1 -1
- package/dist/cjs/services/httpStatus.d.ts +6 -0
- package/dist/cjs/services/httpStatus.d.ts.map +1 -1
- package/dist/cjs/services/httpStatus.js +9 -0
- package/dist/cjs/services/numberFormat.d.ts +3 -0
- package/dist/cjs/services/numberFormat.d.ts.map +1 -0
- package/dist/cjs/services/numberFormat.js +4 -0
- package/dist/cjs/services/source.d.ts +1 -0
- package/dist/cjs/services/source.d.ts.map +1 -0
- package/dist/cjs/services/source.js +178 -0
- package/dist/cjs/tasks/iterateWorkbookRange.d.ts +5 -1
- package/dist/cjs/tasks/iterateWorkbookRange.d.ts.map +1 -1
- package/dist/cjs/tasks/iterateWorkbookRange.js +7 -1
- package/dist/esm/errors/InvalidOperationError.d.ts +4 -0
- package/dist/esm/errors/InvalidOperationError.d.ts.map +1 -0
- package/dist/esm/errors/InvalidOperationError.js +6 -0
- package/dist/esm/graphApi.js +3 -3
- package/dist/esm/models/Item.d.ts +9 -0
- package/dist/esm/models/Item.d.ts.map +1 -0
- package/dist/esm/models/Item.js +1 -0
- package/dist/esm/models/RecordBase.d.ts +3 -0
- package/dist/esm/models/RecordBase.d.ts.map +1 -0
- package/dist/esm/models/RecordBase.js +1 -0
- package/dist/esm/models/RowNumber.d.ts +4 -0
- package/dist/esm/models/RowNumber.d.ts.map +1 -0
- package/dist/esm/models/RowNumber.js +1 -0
- package/dist/esm/models/Source.d.ts +15 -0
- package/dist/esm/models/Source.d.ts.map +1 -0
- package/dist/esm/models/Source.js +1 -0
- package/dist/esm/models/SourceDecoder.d.ts +4 -0
- package/dist/esm/models/SourceDecoder.d.ts.map +1 -0
- package/dist/esm/models/SourceDecoder.js +1 -0
- package/dist/esm/models/SourceEncoder.d.ts +4 -0
- package/dist/esm/models/SourceEncoder.d.ts.map +1 -0
- package/dist/esm/models/SourceEncoder.js +1 -0
- package/dist/esm/models/SourceRow.d.ts +4 -0
- package/dist/esm/models/SourceRow.d.ts.map +1 -0
- package/dist/esm/models/SourceRow.js +1 -0
- package/dist/esm/models/SourceRowValue.d.ts +4 -0
- package/dist/esm/models/SourceRowValue.d.ts.map +1 -0
- package/dist/esm/models/SourceRowValue.js +1 -0
- package/dist/esm/services/addressOffset.d.ts +1 -1
- package/dist/esm/services/addressOffset.js +1 -1
- package/dist/esm/services/httpStatus.d.ts +6 -0
- package/dist/esm/services/httpStatus.d.ts.map +1 -1
- package/dist/esm/services/httpStatus.js +8 -0
- package/dist/esm/services/numberFormat.d.ts +3 -0
- package/dist/esm/services/numberFormat.d.ts.map +1 -0
- package/dist/esm/services/numberFormat.js +1 -0
- package/dist/esm/services/source.d.ts +2 -0
- package/dist/esm/services/source.d.ts.map +1 -0
- package/dist/esm/services/source.js +178 -0
- package/dist/esm/tasks/iterateWorkbookRange.d.ts +5 -1
- package/dist/esm/tasks/iterateWorkbookRange.d.ts.map +1 -1
- package/dist/esm/tasks/iterateWorkbookRange.js +7 -1
- package/package.json +279 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InvalidOperationError.d.ts","sourceRoot":"","sources":["../../../src/errors/InvalidOperationError.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,KAAK;gBACpC,OAAO,CAAC,EAAE,MAAM;CAInC"}
|
package/dist/cjs/graphApi.js
CHANGED
|
@@ -45,7 +45,7 @@ async function sequential(...operations) {
|
|
|
45
45
|
return (await executeBatch(...definitions));
|
|
46
46
|
}
|
|
47
47
|
const maxBatchOperations = 20; // https://learn.microsoft.com/en-us/graph/json-batching?tabs=http#batch-size-limitations
|
|
48
|
-
const maxRetries =
|
|
48
|
+
const maxRetries = 5;
|
|
49
49
|
const defaultRetryDelayMilliseconds = 1000;
|
|
50
50
|
const consecutiveRetryDelayMultiplier = 2;
|
|
51
51
|
async function executeSingle(definition) {
|
|
@@ -139,7 +139,7 @@ async function innerFetch(args) {
|
|
|
139
139
|
catch (error) {
|
|
140
140
|
if (axios_1.default.isAxiosError(error) && error.response) {
|
|
141
141
|
response = error.response;
|
|
142
|
-
if (!((0, httpStatus_ts_1.isHttpTooManyRequests)(response.status) || (0, httpStatus_ts_1.isServiceUnavailable)(response.status) || (0, httpStatus_ts_1.isGatewayTimeout)(response.status))) {
|
|
142
|
+
if (!((0, httpStatus_ts_1.isHttpTooManyRequests)(response.status) || (0, httpStatus_ts_1.isServiceUnavailable)(response.status) || (0, httpStatus_ts_1.isGatewayTimeout)(response.status) || (0, httpStatus_ts_1.isLocked)(response.status))) {
|
|
143
143
|
throw error;
|
|
144
144
|
}
|
|
145
145
|
const requestedRetryAfterSeconds = Number.parseInt(response.headers["retry-after"] ?? "0", 10);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RowOffset } from "../models/RowOffset.ts";
|
|
2
|
+
import type { RecordBase } from "./RecordBase.ts";
|
|
3
|
+
import type { RowNumber } from "./RowNumber.ts";
|
|
4
|
+
export type Item<T extends RecordBase> = {
|
|
5
|
+
rowOffset: RowOffset;
|
|
6
|
+
rowNumber: RowNumber;
|
|
7
|
+
record: T;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=Item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Item.d.ts","sourceRoot":"","sources":["../../../src/models/Item.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,IAAI,CAAC,CAAC,SAAS,UAAU,IAAI;IACxC,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,CAAC,CAAC;CACV,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecordBase.d.ts","sourceRoot":"","sources":["../../../src/models/RecordBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RowNumber.d.ts","sourceRoot":"","sources":["../../../src/models/RowNumber.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG;IAChC,OAAO,EAAE,WAAW,CAAC;CACrB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ColumnName } from "./ColumnName.ts";
|
|
2
|
+
import type { Item } from "./Item.ts";
|
|
3
|
+
import type { RecordBase } from "./RecordBase.ts";
|
|
4
|
+
import type { SourceDecoder } from "./SourceDecoder.ts";
|
|
5
|
+
import type { SourceEncoder } from "./SourceEncoder.ts";
|
|
6
|
+
import type { WorkbookRangeRef } from "./WorkbookRangeRef.ts";
|
|
7
|
+
export type Source<T extends RecordBase> = {
|
|
8
|
+
rangeRef: WorkbookRangeRef;
|
|
9
|
+
head: ColumnName[];
|
|
10
|
+
coding: {
|
|
11
|
+
decode: SourceDecoder<T>;
|
|
12
|
+
encode: SourceEncoder<T>;
|
|
13
|
+
};
|
|
14
|
+
} & AsyncIterable<Item<T>>;
|
|
15
|
+
//# sourceMappingURL=Source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Source.d.ts","sourceRoot":"","sources":["../../../src/models/Source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,UAAU,IAAI;IAC1C,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,MAAM,EAAE;QACP,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;KACzB,CAAC;CACF,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceDecoder.d.ts","sourceRoot":"","sources":["../../../src/models/SourceDecoder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,UAAU,IAAI,CAAC,GAAG,EAAE,SAAS,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceEncoder.d.ts","sourceRoot":"","sources":["../../../src/models/SourceEncoder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,UAAU,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceRow.d.ts","sourceRoot":"","sources":["../../../src/models/SourceRow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceRowValue.d.ts","sourceRoot":"","sources":["../../../src/models/SourceRowValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC"}
|
|
@@ -13,7 +13,7 @@ export declare function columnAddressToOffset(column: ColumnAddress): ColumnOffs
|
|
|
13
13
|
* @returns The column address.
|
|
14
14
|
*/
|
|
15
15
|
export declare function columnOffsetToAddress(offset: ColumnOffset): ColumnAddress;
|
|
16
|
-
/** @deprecated Use
|
|
16
|
+
/** @deprecated Use columnOffsetToAddress instead. */
|
|
17
17
|
export declare function offsetToColumnAddress(offset: ColumnOffset): ColumnAddress;
|
|
18
18
|
/**
|
|
19
19
|
* Converts a row address (e.g., "1") to a zero-based row offset.
|
|
@@ -33,7 +33,7 @@ function columnOffsetToAddress(offset) {
|
|
|
33
33
|
}
|
|
34
34
|
return result;
|
|
35
35
|
}
|
|
36
|
-
/** @deprecated Use
|
|
36
|
+
/** @deprecated Use columnOffsetToAddress instead. */
|
|
37
37
|
function offsetToColumnAddress(offset) {
|
|
38
38
|
return columnOffsetToAddress(offset);
|
|
39
39
|
}
|
|
@@ -34,4 +34,10 @@ export declare function isServiceUnavailable(status: number): boolean;
|
|
|
34
34
|
* @returns True if the status code is 504, otherwise false.
|
|
35
35
|
*/
|
|
36
36
|
export declare function isGatewayTimeout(status: number): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Checks if the HTTP status code indicates the resource is locked
|
|
39
|
+
* @param status - The HTTP status code.
|
|
40
|
+
* @returns True if the status code is 423, otherwise false.
|
|
41
|
+
*/
|
|
42
|
+
export declare function isLocked(status: number): boolean;
|
|
37
43
|
//# sourceMappingURL=httpStatus.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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
|
+
{"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;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhD"}
|
|
@@ -6,6 +6,7 @@ exports.isHttpNotFound = isHttpNotFound;
|
|
|
6
6
|
exports.isHttpTooManyRequests = isHttpTooManyRequests;
|
|
7
7
|
exports.isServiceUnavailable = isServiceUnavailable;
|
|
8
8
|
exports.isGatewayTimeout = isGatewayTimeout;
|
|
9
|
+
exports.isLocked = isLocked;
|
|
9
10
|
/**
|
|
10
11
|
* Checks if the HTTP status code indicates a successful response.
|
|
11
12
|
* @param status - The HTTP status code.
|
|
@@ -54,3 +55,11 @@ function isServiceUnavailable(status) {
|
|
|
54
55
|
function isGatewayTimeout(status) {
|
|
55
56
|
return status === 504;
|
|
56
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Checks if the HTTP status code indicates the resource is locked
|
|
60
|
+
* @param status - The HTTP status code.
|
|
61
|
+
* @returns True if the status code is 423, otherwise false.
|
|
62
|
+
*/
|
|
63
|
+
function isLocked(status) {
|
|
64
|
+
return status === 423;
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numberFormat.d.ts","sourceRoot":"","sources":["../../../src/services/numberFormat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,eAAO,MAAM,mBAAmB,EAAgB,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../../src/services/source.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import InvalidOperationError from "../errors/InvalidOperationError.ts";
|
|
3
|
+
// import NeverError from "../errors/NeverError.ts";
|
|
4
|
+
// import type { Cell } from "../models/Cell.ts";
|
|
5
|
+
// import type { ColumnName } from "../models/ColumnName.ts";
|
|
6
|
+
// import type { ColumnOffset } from "../models/ColumnOffset.ts";
|
|
7
|
+
// import type { Item } from "../models/Item.ts";
|
|
8
|
+
// import type { RecordBase } from "../models/RecordBase.ts";
|
|
9
|
+
// import type { RowNumber } from "../models/RowNumber.ts";
|
|
10
|
+
// import type { RowOffset } from "../models/RowOffset.ts";
|
|
11
|
+
// import type { Source } from "../models/source.ts";
|
|
12
|
+
// import type { SourceDecoder } from "../models/SourceDecoder.ts";
|
|
13
|
+
// import type { SourceEncoder } from "../models/SourceEncoder.ts";
|
|
14
|
+
// import type { SourceRow } from "../models/SourceRow.ts";
|
|
15
|
+
// import type { WorkbookWorksheetRef } from "../models/WorkbookWorksheetRef.ts";
|
|
16
|
+
// import deleteWorkbookRange from "../operations/workbookRange/deleteWorkbookRange.ts";
|
|
17
|
+
// import insertWorkbookCells from "../operations/workbookRange/insertWorkbookCells.ts";
|
|
18
|
+
// import setWorkbookRangeFont from "../operations/workbookRange/setWorkbookRangeFont.ts";
|
|
19
|
+
// import updateWorkbookRange from "../operations/workbookRange/updateWorkbookRange.ts";
|
|
20
|
+
// import getWorkbookWorksheetUsedRangeAddress from "../operations/workbookWorksheet/getWorkbookWorksheetUsedRangeAddress.ts";
|
|
21
|
+
// import iterateWorkbookRange from "../tasks/iterateWorkbookRange.ts";
|
|
22
|
+
// import { countAddressColumns, countAddressRows } from "./addressManipulation.ts";
|
|
23
|
+
// import { rowOffsetToAddress } from "./addressOffset.ts";
|
|
24
|
+
// import { addressToCartesian, cartesianToAddress } from "./cartesianAddress.ts";
|
|
25
|
+
// import { createWorkbookRangeRef } from "./workbookRange.ts";
|
|
26
|
+
// export async function defineSource<T extends RecordBase>(worksheetRef: WorkbookWorksheetRef, decode: SourceDecoder<T>, encode: SourceEncoder<T>): Promise<Source<T>> {
|
|
27
|
+
// const usedRange = await getWorkbookWorksheetUsedRangeAddress(worksheetRef);
|
|
28
|
+
// const rangeRef = createWorkbookRangeRef(worksheetRef, usedRange);
|
|
29
|
+
// const b = addressToCartesian(usedRange);
|
|
30
|
+
// // TODO: Header
|
|
31
|
+
// const a = await getWorkbookWorksheetRange();
|
|
32
|
+
// const source: Source<T> = {
|
|
33
|
+
// rangeRef,
|
|
34
|
+
// coding: {
|
|
35
|
+
// decode,
|
|
36
|
+
// encode,
|
|
37
|
+
// },
|
|
38
|
+
// head: [],
|
|
39
|
+
// async *[Symbol.asyncIterator](): AsyncGenerator<Item<T>> {
|
|
40
|
+
// let hasHead = false;
|
|
41
|
+
// for await (const { rowOffset, row } of iterateWorkbookRange(rangeRef)) {
|
|
42
|
+
// if (!hasHead) {
|
|
43
|
+
// source.head = row.map((cell) => cell.text) as ColumnName[];
|
|
44
|
+
// hasHead = true;
|
|
45
|
+
// continue;
|
|
46
|
+
// }
|
|
47
|
+
// const record = rowToRecord<T>(row, source);
|
|
48
|
+
// const rowNumber = rowOffsetToNumber(rowOffset);
|
|
49
|
+
// yield {
|
|
50
|
+
// rowOffset,
|
|
51
|
+
// rowNumber,
|
|
52
|
+
// record,
|
|
53
|
+
// };
|
|
54
|
+
// }
|
|
55
|
+
// },
|
|
56
|
+
// };
|
|
57
|
+
// return source;
|
|
58
|
+
// }
|
|
59
|
+
// export async function initializeSource<T extends RecordBase>(source: Source<T>, empty: T): Promise<void> {
|
|
60
|
+
// if (!isEmpty(source)) {
|
|
61
|
+
// throw new InvalidOperationError("Cannot initialize source with non-empty worksheet.");
|
|
62
|
+
// }
|
|
63
|
+
// source.head = Object.keys(empty) as ColumnName[];
|
|
64
|
+
// const address = cartesianToAddress({
|
|
65
|
+
// ax: 0 as ColumnOffset,
|
|
66
|
+
// bx: (source.head.length - 1) as ColumnOffset,
|
|
67
|
+
// ay: 0 as RowOffset,
|
|
68
|
+
// by: 0 as RowOffset,
|
|
69
|
+
// });
|
|
70
|
+
// source.rangeRef = createWorkbookRangeRef(source.rangeRef, address);
|
|
71
|
+
// await updateWorkbookRange(source.rangeRef, {
|
|
72
|
+
// values: [source.head],
|
|
73
|
+
// });
|
|
74
|
+
// await setWorkbookRangeFont(source.rangeRef, {
|
|
75
|
+
// bold: true,
|
|
76
|
+
// });
|
|
77
|
+
// }
|
|
78
|
+
// export async function readAllItems<T extends RecordBase>(source: Source<T>): Promise<Item<T>[]> {
|
|
79
|
+
// const result: Item<T>[] = [];
|
|
80
|
+
// for await (const item of source) {
|
|
81
|
+
// result.push(item);
|
|
82
|
+
// }
|
|
83
|
+
// return result;
|
|
84
|
+
// }
|
|
85
|
+
// export async function createItem<T extends RecordBase>(source: Source<T>, record: T, after: RowOffset = 0 as RowOffset): Promise<Item<T>> {
|
|
86
|
+
// if (!isInitialized(source)) {
|
|
87
|
+
// throw new InvalidOperationError("Source not initialized.");
|
|
88
|
+
// }
|
|
89
|
+
// await insertWorkbookCells(source.rangeRef, rowOffsetToAddress(after), "Down");
|
|
90
|
+
// const row = recordToRow(record, source);
|
|
91
|
+
// const address = cartesianToAddress({
|
|
92
|
+
// ax: 0 as ColumnOffset,
|
|
93
|
+
// bx: (row.length - 1) as ColumnOffset,
|
|
94
|
+
// ay: after,
|
|
95
|
+
// by: after,
|
|
96
|
+
// });
|
|
97
|
+
// const rangeRef = createWorkbookRangeRef(source.rangeRef, address);
|
|
98
|
+
// await updateWorkbookRange(rangeRef, {
|
|
99
|
+
// values: [row],
|
|
100
|
+
// // TODO: Format
|
|
101
|
+
// });
|
|
102
|
+
// const { ax, bx, ay, by } = addressToCartesian(source.rangeRef.address);
|
|
103
|
+
// source.rangeRef.address = cartesianToAddress({
|
|
104
|
+
// ax,
|
|
105
|
+
// bx,
|
|
106
|
+
// ay,
|
|
107
|
+
// by: (by + 1) as RowOffset,
|
|
108
|
+
// });
|
|
109
|
+
// return {
|
|
110
|
+
// rowOffset: after,
|
|
111
|
+
// rowNumber: rowOffsetToNumber(after),
|
|
112
|
+
// record,
|
|
113
|
+
// };
|
|
114
|
+
// }
|
|
115
|
+
// export async function updateItem<T extends RecordBase>(source: Source<T>, offset: RowOffset, record: T): Promise<void> {
|
|
116
|
+
// if (!isInitialized(source)) {
|
|
117
|
+
// throw new InvalidOperationError("Source not initialized.");
|
|
118
|
+
// }
|
|
119
|
+
// const row = recordToRow(record, source);
|
|
120
|
+
// const address = cartesianToAddress({
|
|
121
|
+
// ax: 0 as ColumnOffset,
|
|
122
|
+
// bx: (row.length - 1) as ColumnOffset,
|
|
123
|
+
// ay: offset,
|
|
124
|
+
// by: offset,
|
|
125
|
+
// });
|
|
126
|
+
// const rangeRef = createWorkbookRangeRef(source.rangeRef, address);
|
|
127
|
+
// await updateWorkbookRange(rangeRef, {
|
|
128
|
+
// values: [row],
|
|
129
|
+
// // TODO: format
|
|
130
|
+
// });
|
|
131
|
+
// }
|
|
132
|
+
// export async function deleteItem<T extends RecordBase>(source: Source<T>, offset: RowOffset): Promise<void> {
|
|
133
|
+
// if (!isInitialized(source)) {
|
|
134
|
+
// throw new InvalidOperationError("Source not initialized.");
|
|
135
|
+
// }
|
|
136
|
+
// const rangeRef = createWorkbookRangeRef(source.rangeRef, rowOffsetToAddress(offset));
|
|
137
|
+
// await deleteWorkbookRange(rangeRef, "Up");
|
|
138
|
+
// const { ax, bx, ay, by } = addressToCartesian(source.rangeRef.address);
|
|
139
|
+
// source.rangeRef.address = cartesianToAddress({
|
|
140
|
+
// ax,
|
|
141
|
+
// bx,
|
|
142
|
+
// ay,
|
|
143
|
+
// by: (by - 1) as RowOffset,
|
|
144
|
+
// });
|
|
145
|
+
// }
|
|
146
|
+
// function rowToRecord<T extends RecordBase>(row: Cell[], source: Source<T>): T {
|
|
147
|
+
// const sourceRow = source.head.reduce((acc, heading, columnIndex) => {
|
|
148
|
+
// const cell = row[columnIndex];
|
|
149
|
+
// if (!cell) {
|
|
150
|
+
// throw new NeverError(`Cell at index ${columnIndex} is undefined`);
|
|
151
|
+
// }
|
|
152
|
+
// acc[heading] = cell;
|
|
153
|
+
// return acc;
|
|
154
|
+
// }, {} as SourceRow);
|
|
155
|
+
// const record = source.coding.decode(sourceRow);
|
|
156
|
+
// return record;
|
|
157
|
+
// }
|
|
158
|
+
// function recordToRow<T extends RecordBase>(record: T, source: Source<T>): Cell[] {
|
|
159
|
+
// const sourceRow = source.coding.encode(record);
|
|
160
|
+
// const row = source.head.map((heading) => {
|
|
161
|
+
// const cell = sourceRow[heading];
|
|
162
|
+
// if (cell === undefined) {
|
|
163
|
+
// throw new NeverError(`Cell at index ${heading} is undefined`);
|
|
164
|
+
// }
|
|
165
|
+
// return cell;
|
|
166
|
+
// });
|
|
167
|
+
// return row;
|
|
168
|
+
// }
|
|
169
|
+
// function rowOffsetToNumber(offset: RowOffset): RowNumber {
|
|
170
|
+
// return (offset + 1) as RowNumber;
|
|
171
|
+
// }
|
|
172
|
+
// function isEmpty<T extends RecordBase>(source: Source<T>) {
|
|
173
|
+
// return countAddressRows(source.rangeRef.address) <= 1 && countAddressColumns(source.rangeRef.address) <= 1;
|
|
174
|
+
// }
|
|
175
|
+
// function isInitialized<T extends RecordBase>(source: Source<T>) {
|
|
176
|
+
// return source.head.length > 0;
|
|
177
|
+
// }
|
|
178
|
+
// // TODO: Tidy Cell/CellValue types
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Cell } from "../models/Cell.ts";
|
|
2
|
+
import type { RowOffset } from "../models/RowOffset.ts";
|
|
2
3
|
import type { WorkbookRangeRef } from "../models/WorkbookRangeRef.ts";
|
|
3
4
|
/**
|
|
4
5
|
* Iterates over the values of a workbook range in chunks, fetching data in manageable sizes.
|
|
@@ -7,5 +8,8 @@ import type { WorkbookRangeRef } from "../models/WorkbookRangeRef.ts";
|
|
|
7
8
|
* @param overwriteRowsPerRequest - Optional. The number of rows to fetch per request. If omitted, it is automatically calculated.
|
|
8
9
|
* @returns An async iterable that yields rows of range values.
|
|
9
10
|
*/
|
|
10
|
-
export default function iterateWorkbookRange(rangeRef: WorkbookRangeRef, overwriteRowsPerRequest?: number | null): AsyncIterable<
|
|
11
|
+
export default function iterateWorkbookRange(rangeRef: WorkbookRangeRef, overwriteRowsPerRequest?: number | null): AsyncIterable<{
|
|
12
|
+
rowOffset: RowOffset;
|
|
13
|
+
row: Cell[];
|
|
14
|
+
}>;
|
|
11
15
|
//# sourceMappingURL=iterateWorkbookRange.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iterateWorkbookRange.d.ts","sourceRoot":"","sources":["../../../src/tasks/iterateWorkbookRange.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"iterateWorkbookRange.d.ts","sourceRoot":"","sources":["../../../src/tasks/iterateWorkbookRange.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AActE;;;;;;GAMG;AACH,wBAA+B,oBAAoB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,uBAAuB,GAAE,MAAM,GAAG,IAAW,GAAG,aAAa,CAAC;IAAE,SAAS,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,IAAI,EAAE,CAAA;CAAE,CAAC,CAsDnL"}
|
|
@@ -34,6 +34,7 @@ async function* iterateWorkbookRange(rangeRef, overwriteRowsPerRequest = null) {
|
|
|
34
34
|
const rowsPerRequest = overwriteRowsPerRequest ?? Math.floor(maxCellsPerRequest / columnsPerRow);
|
|
35
35
|
const rangeStartRowOffset = (0, addressOffset_ts_1.rowAddressToOffset)(components.startRow);
|
|
36
36
|
const rangeEndRowOffset = (0, addressOffset_ts_1.rowAddressToOffset)(components.endRow);
|
|
37
|
+
let offset = 0;
|
|
37
38
|
for (let chunkRowOffset = rangeStartRowOffset; chunkRowOffset <= rangeEndRowOffset; chunkRowOffset = (chunkRowOffset + rowsPerRequest)) {
|
|
38
39
|
const requestStartRowOffset = chunkRowOffset;
|
|
39
40
|
const requestEndRowOffset = Math.min(chunkRowOffset + rowsPerRequest - 1, rangeEndRowOffset);
|
|
@@ -52,11 +53,16 @@ async function* iterateWorkbookRange(rangeRef, overwriteRowsPerRequest = null) {
|
|
|
52
53
|
const numberFormat = range.numberFormat;
|
|
53
54
|
const rowCount = values.length;
|
|
54
55
|
for (let r = 0; r < rowCount; r++) {
|
|
55
|
-
|
|
56
|
+
const row = Array.from({ length: columnCount }, (_, c) => ({
|
|
56
57
|
text: text[r]?.[c] ?? "",
|
|
57
58
|
value: values[r]?.[c] ?? "",
|
|
58
59
|
numberFormat: numberFormat?.[r]?.[c] ?? "",
|
|
59
60
|
}));
|
|
61
|
+
yield {
|
|
62
|
+
rowOffset: offset,
|
|
63
|
+
row,
|
|
64
|
+
};
|
|
65
|
+
offset++;
|
|
60
66
|
}
|
|
61
67
|
}
|
|
62
68
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InvalidOperationError.d.ts","sourceRoot":"","sources":["../../../src/errors/InvalidOperationError.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,KAAK;gBACpC,OAAO,CAAC,EAAE,MAAM;CAInC"}
|
package/dist/esm/graphApi.js
CHANGED
|
@@ -7,7 +7,7 @@ import RequestFailedError from "./errors/RequestFailedError.js";
|
|
|
7
7
|
import { getCurrentAccessToken } from "./services/accessToken.js";
|
|
8
8
|
import { getContext } from "./services/context.js";
|
|
9
9
|
import { executeHttpRequest } from "./services/http.js";
|
|
10
|
-
import { isGatewayTimeout, isHttpSuccess, isHttpTooManyRequests, isServiceUnavailable } from "./services/httpStatus.js";
|
|
10
|
+
import { isGatewayTimeout, isHttpSuccess, isHttpTooManyRequests, isLocked, isServiceUnavailable } from "./services/httpStatus.js";
|
|
11
11
|
import { operationIdToIndex, operationIndexToId } from "./services/operationId.js";
|
|
12
12
|
import { sleep } from "./services/sleep.js";
|
|
13
13
|
export const authenticationScope = "https://graph.microsoft.com/.default";
|
|
@@ -36,7 +36,7 @@ export async function sequential(...operations) {
|
|
|
36
36
|
return (await executeBatch(...definitions));
|
|
37
37
|
}
|
|
38
38
|
const maxBatchOperations = 20; // https://learn.microsoft.com/en-us/graph/json-batching?tabs=http#batch-size-limitations
|
|
39
|
-
const maxRetries =
|
|
39
|
+
const maxRetries = 5;
|
|
40
40
|
const defaultRetryDelayMilliseconds = 1000;
|
|
41
41
|
const consecutiveRetryDelayMultiplier = 2;
|
|
42
42
|
async function executeSingle(definition) {
|
|
@@ -130,7 +130,7 @@ async function innerFetch(args) {
|
|
|
130
130
|
catch (error) {
|
|
131
131
|
if (axios.isAxiosError(error) && error.response) {
|
|
132
132
|
response = error.response;
|
|
133
|
-
if (!(isHttpTooManyRequests(response.status) || isServiceUnavailable(response.status) || isGatewayTimeout(response.status))) {
|
|
133
|
+
if (!(isHttpTooManyRequests(response.status) || isServiceUnavailable(response.status) || isGatewayTimeout(response.status) || isLocked(response.status))) {
|
|
134
134
|
throw error;
|
|
135
135
|
}
|
|
136
136
|
const requestedRetryAfterSeconds = Number.parseInt(response.headers["retry-after"] ?? "0", 10);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RowOffset } from "../models/RowOffset.ts";
|
|
2
|
+
import type { RecordBase } from "./RecordBase.ts";
|
|
3
|
+
import type { RowNumber } from "./RowNumber.ts";
|
|
4
|
+
export type Item<T extends RecordBase> = {
|
|
5
|
+
rowOffset: RowOffset;
|
|
6
|
+
rowNumber: RowNumber;
|
|
7
|
+
record: T;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=Item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Item.d.ts","sourceRoot":"","sources":["../../../src/models/Item.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,IAAI,CAAC,CAAC,SAAS,UAAU,IAAI;IACxC,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,CAAC,CAAC;CACV,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecordBase.d.ts","sourceRoot":"","sources":["../../../src/models/RecordBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RowNumber.d.ts","sourceRoot":"","sources":["../../../src/models/RowNumber.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG;IAChC,OAAO,EAAE,WAAW,CAAC;CACrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ColumnName } from "./ColumnName.ts";
|
|
2
|
+
import type { Item } from "./Item.ts";
|
|
3
|
+
import type { RecordBase } from "./RecordBase.ts";
|
|
4
|
+
import type { SourceDecoder } from "./SourceDecoder.ts";
|
|
5
|
+
import type { SourceEncoder } from "./SourceEncoder.ts";
|
|
6
|
+
import type { WorkbookRangeRef } from "./WorkbookRangeRef.ts";
|
|
7
|
+
export type Source<T extends RecordBase> = {
|
|
8
|
+
rangeRef: WorkbookRangeRef;
|
|
9
|
+
head: ColumnName[];
|
|
10
|
+
coding: {
|
|
11
|
+
decode: SourceDecoder<T>;
|
|
12
|
+
encode: SourceEncoder<T>;
|
|
13
|
+
};
|
|
14
|
+
} & AsyncIterable<Item<T>>;
|
|
15
|
+
//# sourceMappingURL=Source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Source.d.ts","sourceRoot":"","sources":["../../../src/models/Source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,UAAU,IAAI;IAC1C,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,MAAM,EAAE;QACP,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;KACzB,CAAC;CACF,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceDecoder.d.ts","sourceRoot":"","sources":["../../../src/models/SourceDecoder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,UAAU,IAAI,CAAC,GAAG,EAAE,SAAS,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceEncoder.d.ts","sourceRoot":"","sources":["../../../src/models/SourceEncoder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,UAAU,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|