microsoft-graph 2.2.3 → 2.2.4
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/graphApi.js +12 -6
- package/dist/models/Address.d.ts +8 -0
- package/dist/models/Address.d.ts.map +1 -0
- package/dist/models/Address.js +1 -0
- package/dist/models/WorkbookRangeRef.d.ts +2 -2
- package/dist/models/WorkbookRangeRef.d.ts.map +1 -1
- package/dist/operations/workbookRange/clearWorkbookRange.test.js +13 -21
- package/dist/operations/workbookRange/deleteWorkbookRange.test.js +13 -17
- package/dist/operations/workbookRange/getWorkbookUsedRange.d.ts.map +1 -1
- package/dist/operations/workbookRange/getWorkbookUsedRange.js +4 -0
- package/dist/operations/workbookRange/getWorkbookUsedRange.test.js +6 -12
- package/dist/operations/workbookRange/getWorkbookVisibleRange.test.js +6 -12
- package/dist/operations/workbookRange/getWorkbookWorksheetRange.d.ts +6 -0
- package/dist/operations/workbookRange/getWorkbookWorksheetRange.d.ts.map +1 -0
- package/dist/operations/workbookRange/getWorkbookWorksheetRange.js +21 -0
- package/dist/operations/workbookRange/getWorkbookWorksheetRange.test.d.ts +2 -0
- package/dist/operations/workbookRange/getWorkbookWorksheetRange.test.d.ts.map +1 -0
- package/dist/operations/workbookRange/getWorkbookWorksheetRange.test.js +32 -0
- package/dist/operations/workbookRange/insertWorkbookCells.d.ts +2 -2
- package/dist/operations/workbookRange/insertWorkbookCells.d.ts.map +1 -1
- package/dist/operations/workbookRange/insertWorkbookCells.js +4 -0
- package/dist/operations/workbookRange/insertWorkbookCells.test.js +1 -2
- package/dist/operations/workbookRange/updateWorkbookRange.test.js +7 -13
- package/dist/operations/workbookTable/createWorkbookTable.test.js +3 -3
- package/dist/operations/workbookTable/getWorkbookTable.test.js +3 -3
- package/dist/operations/workbookTable/getWorkbookTableBodyRange.d.ts.map +1 -1
- package/dist/operations/workbookTable/getWorkbookTableBodyRange.js +4 -0
- package/dist/operations/workbookTable/getWorkbookTableBodyRange.test.js +3 -3
- package/dist/operations/workbookTable/getWorkbookTableHeaderRange.d.ts.map +1 -1
- package/dist/operations/workbookTable/getWorkbookTableHeaderRange.js +4 -0
- package/dist/operations/workbookTable/getWorkbookTableHeaderRange.test.js +3 -3
- package/dist/operations/workbookTable/listWorkbookTableColumns.test.js +3 -3
- package/dist/operations/workbookTable/listWorkbookTableRows.test.js +3 -3
- package/dist/operations/workbookTable/listWorkbookTables.test.js +4 -4
- package/dist/operations/workbookWorksheet/updateWorkbookWorksheet.test.js +6 -3
- package/dist/services/address.d.ts +10 -13
- package/dist/services/address.d.ts.map +1 -1
- package/dist/services/address.js +104 -19
- package/dist/services/address.test.js +57 -39
- package/dist/services/httpStatus.d.ts +1 -0
- package/dist/services/httpStatus.d.ts.map +1 -1
- package/dist/services/httpStatus.js +3 -0
- package/dist/services/workbookRange.d.ts +2 -2
- package/dist/services/workbookRange.d.ts.map +1 -1
- package/dist/tasks/getRangeLastUsedCell.js +3 -3
- package/dist/tasks/getWorkbookTableVisibleBody.test.js +3 -0
- package/dist/tasks/setWorkbookTableBodyVisibleRows.js +5 -5
- package/package.json +9 -1
- package/vitest.config.ts +1 -1
|
@@ -4,11 +4,11 @@ import { getDefaultDriveRef } from "../../services/drive.js";
|
|
|
4
4
|
import { driveItemPath } from "../../services/driveItem.js";
|
|
5
5
|
import { generateTempFileName } from "../../services/temporaryFiles.js";
|
|
6
6
|
import { createWorkbookRangeRef } from "../../services/workbookRange.js";
|
|
7
|
+
import { createDefaultWorkbookWorksheetRef } from "../../services/workbookWorksheet.js";
|
|
7
8
|
import deleteDriveItemWithRetry from "../../tasks/deleteDriveItemWithRetry.js";
|
|
8
9
|
import calculateWorkbook from "../workbook/calculateWorkbook.js";
|
|
9
10
|
import createWorkbook from "../workbook/createWorkbook.js";
|
|
10
11
|
import updateWorkbookRange from "../workbookRange/updateWorkbookRange.js";
|
|
11
|
-
import createWorkbookWorksheet from "../workbookWorksheet/createWorkbookWorksheet.js";
|
|
12
12
|
import createWorkbookTable from "./createWorkbookTable.js";
|
|
13
13
|
import getWorkbookTableHeaderRange from "./getWorkbookTableHeaderRange.js";
|
|
14
14
|
describe("getWorkbookTableHeaderRange", () => {
|
|
@@ -18,8 +18,8 @@ describe("getWorkbookTableHeaderRange", () => {
|
|
|
18
18
|
const driveRef = getDefaultDriveRef();
|
|
19
19
|
const workbook = await createWorkbook(driveRef, workbookPath);
|
|
20
20
|
try {
|
|
21
|
-
const
|
|
22
|
-
const rangeRef = createWorkbookRangeRef(
|
|
21
|
+
const worksheetRef = createDefaultWorkbookWorksheetRef(workbook);
|
|
22
|
+
const rangeRef = createWorkbookRangeRef(worksheetRef, "A1:D4");
|
|
23
23
|
const table = await createWorkbookTable(rangeRef, true);
|
|
24
24
|
await updateWorkbookRange(rangeRef, {
|
|
25
25
|
values: [
|
|
@@ -3,10 +3,10 @@ import { getDefaultDriveRef } from "../../services/drive.js";
|
|
|
3
3
|
import { driveItemPath } from "../../services/driveItem.js";
|
|
4
4
|
import { generateTempFileName } from "../../services/temporaryFiles.js";
|
|
5
5
|
import { createWorkbookRangeRef } from "../../services/workbookRange.js";
|
|
6
|
+
import { createDefaultWorkbookWorksheetRef } from "../../services/workbookWorksheet.js";
|
|
6
7
|
import deleteDriveItemWithRetry from "../../tasks/deleteDriveItemWithRetry.js";
|
|
7
8
|
import calculateWorkbook from "../workbook/calculateWorkbook.js";
|
|
8
9
|
import createWorkbook from "../workbook/createWorkbook.js";
|
|
9
|
-
import createWorkbookWorksheet from "../workbookWorksheet/createWorkbookWorksheet.js";
|
|
10
10
|
import createWorkbookTable from "./createWorkbookTable.js";
|
|
11
11
|
import listWorkbookTableColumns from "./listWorkbookTableColumns.js";
|
|
12
12
|
describe("listWorkbookTableColumns", () => {
|
|
@@ -15,8 +15,8 @@ describe("listWorkbookTableColumns", () => {
|
|
|
15
15
|
const workbookPath = driveItemPath(workbookName);
|
|
16
16
|
const workbook = await createWorkbook(getDefaultDriveRef(), workbookPath);
|
|
17
17
|
try {
|
|
18
|
-
const
|
|
19
|
-
const rangeRef = createWorkbookRangeRef(
|
|
18
|
+
const worksheetRef = createDefaultWorkbookWorksheetRef(workbook);
|
|
19
|
+
const rangeRef = createWorkbookRangeRef(worksheetRef, "A1:D4");
|
|
20
20
|
const table = await createWorkbookTable(rangeRef, true);
|
|
21
21
|
await calculateWorkbook(workbook);
|
|
22
22
|
const columns = await listWorkbookTableColumns(table);
|
|
@@ -3,10 +3,10 @@ import { getDefaultDriveRef } from "../../services/drive.js";
|
|
|
3
3
|
import { driveItemPath } from "../../services/driveItem.js";
|
|
4
4
|
import { generateTempFileName } from "../../services/temporaryFiles.js";
|
|
5
5
|
import { createWorkbookRangeRef } from "../../services/workbookRange.js";
|
|
6
|
+
import { createDefaultWorkbookWorksheetRef } from "../../services/workbookWorksheet.js";
|
|
6
7
|
import deleteDriveItemWithRetry from "../../tasks/deleteDriveItemWithRetry.js";
|
|
7
8
|
import calculateWorkbook from "../workbook/calculateWorkbook.js";
|
|
8
9
|
import createWorkbook from "../workbook/createWorkbook.js";
|
|
9
|
-
import createWorkbookWorksheet from "../workbookWorksheet/createWorkbookWorksheet.js";
|
|
10
10
|
import createWorkbookTable from "./createWorkbookTable.js";
|
|
11
11
|
import listWorkbookTableRows from "./listWorkbookTableRows.js";
|
|
12
12
|
describe("listWorkbookTableRows", () => {
|
|
@@ -15,8 +15,8 @@ describe("listWorkbookTableRows", () => {
|
|
|
15
15
|
const workbookPath = driveItemPath(workbookName);
|
|
16
16
|
const workbook = await createWorkbook(getDefaultDriveRef(), workbookPath);
|
|
17
17
|
try {
|
|
18
|
-
const
|
|
19
|
-
const rangeRef = createWorkbookRangeRef(
|
|
18
|
+
const worksheetRef = createDefaultWorkbookWorksheetRef(workbook);
|
|
19
|
+
const rangeRef = createWorkbookRangeRef(worksheetRef, "A1:D4");
|
|
20
20
|
const table = await createWorkbookTable(rangeRef, true);
|
|
21
21
|
await calculateWorkbook(workbook);
|
|
22
22
|
const rows = await listWorkbookTableRows(table);
|
|
@@ -3,10 +3,10 @@ import { getDefaultDriveRef } from "../../services/drive.js";
|
|
|
3
3
|
import { driveItemPath } from "../../services/driveItem.js";
|
|
4
4
|
import { generateTempFileName } from "../../services/temporaryFiles.js";
|
|
5
5
|
import { createWorkbookRangeRef } from "../../services/workbookRange.js";
|
|
6
|
+
import { createDefaultWorkbookWorksheetRef } from "../../services/workbookWorksheet.js";
|
|
6
7
|
import deleteDriveItemWithRetry from "../../tasks/deleteDriveItemWithRetry.js";
|
|
7
8
|
import calculateWorkbook from "../workbook/calculateWorkbook.js";
|
|
8
9
|
import createWorkbook from "../workbook/createWorkbook.js";
|
|
9
|
-
import createWorkbookWorksheet from "../workbookWorksheet/createWorkbookWorksheet.js";
|
|
10
10
|
import createWorkbookTable from "./createWorkbookTable.js";
|
|
11
11
|
import listTables from "./listWorkbookTables.js";
|
|
12
12
|
describe("listWorkbookTables", () => {
|
|
@@ -16,11 +16,11 @@ describe("listWorkbookTables", () => {
|
|
|
16
16
|
const driveRef = getDefaultDriveRef();
|
|
17
17
|
const workbook = await createWorkbook(driveRef, workbookPath);
|
|
18
18
|
try {
|
|
19
|
-
const
|
|
20
|
-
const rangeRef = createWorkbookRangeRef(
|
|
19
|
+
const worksheetRef = createDefaultWorkbookWorksheetRef(workbook);
|
|
20
|
+
const rangeRef = createWorkbookRangeRef(worksheetRef, "A1:D4");
|
|
21
21
|
await createWorkbookTable(rangeRef, true);
|
|
22
22
|
await calculateWorkbook(workbook);
|
|
23
|
-
const tables = await listTables(
|
|
23
|
+
const tables = await listTables(worksheetRef);
|
|
24
24
|
expect(tables.length).toBeGreaterThan(0);
|
|
25
25
|
}
|
|
26
26
|
finally {
|
|
@@ -2,8 +2,10 @@ import { describe, expect, it } from "vitest";
|
|
|
2
2
|
import { getDefaultDriveRef } from "../../services/drive.js";
|
|
3
3
|
import { driveItemPath } from "../../services/driveItem.js";
|
|
4
4
|
import { generateTempFileName } from "../../services/temporaryFiles.js";
|
|
5
|
+
import { createDefaultWorkbookWorksheetRef } from "../../services/workbookWorksheet.js";
|
|
5
6
|
import deleteDriveItemWithRetry from "../../tasks/deleteDriveItemWithRetry.js";
|
|
6
7
|
import getWorkbookWorksheetByName from "../../tasks/getWorkbookWorksheetByName.js";
|
|
8
|
+
import calculateWorkbook from "../workbook/calculateWorkbook.js";
|
|
7
9
|
import createWorkbook from "../workbook/createWorkbook.js";
|
|
8
10
|
import createWorkbookWorksheet from "./createWorkbookWorksheet.js";
|
|
9
11
|
import updateWorkbookWorksheet from "./updateWorkbookWorksheet.js";
|
|
@@ -13,9 +15,10 @@ describe("updateWorkbookWorksheet", () => {
|
|
|
13
15
|
const workbookPath = driveItemPath(workbookName);
|
|
14
16
|
const workbook = await createWorkbook(getDefaultDriveRef(), workbookPath);
|
|
15
17
|
try {
|
|
16
|
-
const
|
|
18
|
+
const worksheetRef = createDefaultWorkbookWorksheetRef(workbook);
|
|
17
19
|
const newName = "UpdatedSheet";
|
|
18
|
-
await updateWorkbookWorksheet(
|
|
20
|
+
await updateWorkbookWorksheet(worksheetRef, { name: newName });
|
|
21
|
+
await calculateWorkbook(workbook);
|
|
19
22
|
const updatedWorksheet = await getWorkbookWorksheetByName(workbook, newName);
|
|
20
23
|
expect(updatedWorksheet.name).toBe(newName);
|
|
21
24
|
}
|
|
@@ -29,7 +32,7 @@ describe("updateWorkbookWorksheet", () => {
|
|
|
29
32
|
const workbook = await createWorkbook(getDefaultDriveRef(), workbookPath);
|
|
30
33
|
try {
|
|
31
34
|
const worksheetName = "Sheet2";
|
|
32
|
-
const worksheet = await createWorkbookWorksheet(workbook
|
|
35
|
+
const worksheet = await createWorkbookWorksheet(workbook); // Can't hide the single worksheet
|
|
33
36
|
await updateWorkbookWorksheet(worksheet, { visibility: "Hidden" });
|
|
34
37
|
const updatedWorksheet = await getWorkbookWorksheetByName(worksheet, worksheetName);
|
|
35
38
|
expect(updatedWorksheet.visibility).toBe("Hidden");
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Column } from "../models/Column.ts";
|
|
1
|
+
import type { Address, BoxRangeAddress, CellAddress, ColumnAddress, RowAddress } from "../models/Address.ts";
|
|
3
2
|
import type { ColumnIndex } from "../models/ColumnIndex.ts";
|
|
4
|
-
import type { RangeAddress } from "../models/RangeAddress.ts";
|
|
5
|
-
import type { Row } from "../models/Row.ts";
|
|
6
3
|
import type { RowIndex } from "../models/RowIndex.ts";
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
4
|
+
export declare function getAddressFirstCell(address: Address): CellAddress;
|
|
5
|
+
export declare function getAddressLastCell(address: Address): CellAddress;
|
|
6
|
+
export declare function cellAddressToIndexes(address: CellAddress): [RowIndex, ColumnIndex];
|
|
7
|
+
export declare function indexesToCellAddress(rowIndex: RowIndex, columnIndex: ColumnIndex): CellAddress;
|
|
8
|
+
export declare function indexesToBoxRangeAddress(startRowIndex: RowIndex, startColumnIndex: ColumnIndex, endRowIndex: RowIndex, endColumnIndex: ColumnIndex): BoxRangeAddress;
|
|
9
|
+
export declare function columnAddressToIndex(column: ColumnAddress): ColumnIndex;
|
|
10
|
+
export declare function indexToColumnAddress(index: ColumnIndex): ColumnAddress;
|
|
11
|
+
export declare function rowAddressToIndex(row: RowAddress): RowIndex;
|
|
12
|
+
export declare function indexToRowAddress(index: RowIndex): RowAddress;
|
|
16
13
|
//# sourceMappingURL=address.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/services/address.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/services/address.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC7G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AActD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CA8CjE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CA6ChE;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,CAclF;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,GAAG,WAAW,CAE9F;AAED,wBAAgB,wBAAwB,CAAC,aAAa,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,GAAG,eAAe,CAEpK;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,aAAa,GAAG,WAAW,CAMvE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,aAAa,CAStE;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,UAAU,GAAG,QAAQ,CAE3D;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,GAAG,UAAU,CAE7D"}
|
package/dist/services/address.js
CHANGED
|
@@ -1,38 +1,123 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import InvalidArgumentError from "../errors/InvalidArgumentError.js";
|
|
2
|
+
const firstColumn = "A";
|
|
3
|
+
const lastColumn = "XFD";
|
|
4
|
+
const firstRow = "1";
|
|
5
|
+
const lastRow = "1048576";
|
|
6
|
+
const columnAddressPattern = /^(?<sheet>[A-Za-z0-9_]+!)?(?<column>[A-Z]+)$/;
|
|
7
|
+
const rowAddressPattern = /^(?<sheet>[A-Za-z0-9_]+!)?(?<row>\d+)$/;
|
|
8
|
+
const columnRangeAddressPattern = /^(?<sheet>[A-Za-z0-9_]+!)?(?<startColumn>[A-Z]+):(?<endColumn>[A-Z]+)$/;
|
|
9
|
+
const rowRangeAddressPattern = /^(?<sheet>[A-Za-z0-9_]+!)?(?<startRow>\d+):(?<endRow>\d+)$/;
|
|
10
|
+
const cellAddressPattern = /^(?<sheet>[A-Za-z0-9_]+!)?(?<column>[A-Z]+)(?<row>\d+)$/;
|
|
11
|
+
const boxRangeAddressPattern = /^(?<sheet>[A-Za-z0-9_]+!)?(?<startCell>[A-Z]+\d+):(?<endCell>[A-Z]+\d+)$/;
|
|
12
|
+
export function getAddressFirstCell(address) {
|
|
13
|
+
const columnAddressMatch = address.match(columnAddressPattern);
|
|
14
|
+
if (columnAddressMatch) {
|
|
15
|
+
// biome-ignore lint/complexity/useLiteralKeys:Regex named capture groups are used
|
|
16
|
+
const column = columnAddressMatch?.groups?.["column"] ?? "";
|
|
17
|
+
return `${column}${firstRow}`;
|
|
18
|
+
}
|
|
19
|
+
const rowAddressMatch = address.match(rowAddressPattern);
|
|
20
|
+
if (rowAddressMatch) {
|
|
21
|
+
// biome-ignore lint/complexity/useLiteralKeys:Regex named capture groups are used
|
|
22
|
+
const row = rowAddressMatch?.groups?.["row"] ?? "";
|
|
23
|
+
return `${firstColumn}${row}`;
|
|
24
|
+
}
|
|
25
|
+
const columnRangeMatch = address.match(columnRangeAddressPattern);
|
|
26
|
+
if (columnRangeMatch) {
|
|
27
|
+
// biome-ignore lint/complexity/useLiteralKeys:Regex named capture groups are used
|
|
28
|
+
const startColumn = columnRangeMatch?.groups?.["startColumn"] ?? "";
|
|
29
|
+
return `${startColumn}${firstRow}`;
|
|
30
|
+
}
|
|
31
|
+
const rowRangeMatch = address.match(rowRangeAddressPattern);
|
|
32
|
+
if (rowRangeMatch) {
|
|
33
|
+
// biome-ignore lint/complexity/useLiteralKeys:Regex named capture groups are used
|
|
34
|
+
const startRow = rowRangeMatch?.groups?.["startRow"] ?? "";
|
|
35
|
+
return `${firstColumn}${startRow}`;
|
|
36
|
+
}
|
|
37
|
+
const boxRangeMatch = address.match(boxRangeAddressPattern);
|
|
38
|
+
if (boxRangeMatch) {
|
|
39
|
+
// biome-ignore lint/complexity/useLiteralKeys:Regex named capture groups are used
|
|
40
|
+
const startCell = boxRangeMatch?.groups?.["startCell"];
|
|
41
|
+
return startCell;
|
|
42
|
+
}
|
|
43
|
+
const cellAddressMatch = address.match(cellAddressPattern);
|
|
44
|
+
if (cellAddressMatch) {
|
|
45
|
+
// biome-ignore lint/complexity/useLiteralKeys:Regex named capture groups are used
|
|
46
|
+
const column = cellAddressMatch?.groups?.["column"] ?? "";
|
|
47
|
+
// biome-ignore lint/complexity/useLiteralKeys:Regex named capture groups are used
|
|
48
|
+
const row = cellAddressMatch?.groups?.["row"] ?? "";
|
|
49
|
+
return (column + row);
|
|
50
|
+
}
|
|
51
|
+
throw new InvalidArgumentError(`Invalid address format '${address}'`);
|
|
5
52
|
}
|
|
6
|
-
export function
|
|
7
|
-
|
|
53
|
+
export function getAddressLastCell(address) {
|
|
54
|
+
const columnAddressMatch = address.match(columnAddressPattern);
|
|
55
|
+
if (columnAddressMatch) {
|
|
56
|
+
// biome-ignore lint/complexity/useLiteralKeys:Regex named capture groups are used
|
|
57
|
+
const column = columnAddressMatch?.groups?.["column"] ?? "";
|
|
58
|
+
return `${column}${lastRow}`;
|
|
59
|
+
}
|
|
60
|
+
const rowAddressMatch = address.match(rowAddressPattern);
|
|
61
|
+
if (rowAddressMatch) {
|
|
62
|
+
// biome-ignore lint/complexity/useLiteralKeys:Regex named capture groups are used
|
|
63
|
+
const row = rowAddressMatch?.groups?.["row"] ?? "";
|
|
64
|
+
return `${lastColumn}${row}`;
|
|
65
|
+
}
|
|
66
|
+
const columnRangeMatch = address.match(columnRangeAddressPattern);
|
|
67
|
+
if (columnRangeMatch) {
|
|
68
|
+
// biome-ignore lint/complexity/useLiteralKeys:Regex named capture groups are used
|
|
69
|
+
const endColumn = columnRangeMatch?.groups?.["endColumn"] ?? "";
|
|
70
|
+
return `${endColumn}${lastRow}`;
|
|
71
|
+
}
|
|
72
|
+
const rowRangeMatch = address.match(rowRangeAddressPattern);
|
|
73
|
+
if (rowRangeMatch) {
|
|
74
|
+
// biome-ignore lint/complexity/useLiteralKeys:Regex named capture groups are used
|
|
75
|
+
const endRow = rowRangeMatch?.groups?.["endRow"] ?? "";
|
|
76
|
+
return `${lastColumn}${endRow}`;
|
|
77
|
+
}
|
|
78
|
+
const boxRangeMatch = address.match(boxRangeAddressPattern);
|
|
79
|
+
if (boxRangeMatch) {
|
|
80
|
+
// biome-ignore lint/complexity/useLiteralKeys:Regex named capture groups are used
|
|
81
|
+
const endCell = boxRangeMatch?.groups?.["endCell"];
|
|
82
|
+
return endCell;
|
|
83
|
+
}
|
|
84
|
+
const cellAddressMatch = address.match(cellAddressPattern);
|
|
85
|
+
if (cellAddressMatch) {
|
|
86
|
+
// biome-ignore lint/complexity/useLiteralKeys:Regex named capture groups are used
|
|
87
|
+
const column = cellAddressMatch?.groups?.["column"] ?? "";
|
|
88
|
+
// biome-ignore lint/complexity/useLiteralKeys:Regex named capture groups are used
|
|
89
|
+
const row = cellAddressMatch?.groups?.["row"] ?? "";
|
|
90
|
+
return (column + row);
|
|
91
|
+
}
|
|
92
|
+
throw new Error(`Invalid address format '${address}'`);
|
|
8
93
|
}
|
|
9
|
-
export function
|
|
10
|
-
const match =
|
|
94
|
+
export function cellAddressToIndexes(address) {
|
|
95
|
+
const match = address.match(cellAddressPattern);
|
|
11
96
|
if (!match?.groups) {
|
|
12
|
-
throw new Error(`Invalid cell format '${
|
|
97
|
+
throw new Error(`Invalid cell format '${address}', must match '${cellAddressPattern}`);
|
|
13
98
|
}
|
|
14
99
|
// biome-ignore lint/complexity/useLiteralKeys: Named capture groups are used
|
|
15
100
|
const column = match.groups["column"];
|
|
16
101
|
// biome-ignore lint/complexity/useLiteralKeys: Named capture groups are used
|
|
17
102
|
const row = match.groups["row"];
|
|
18
|
-
const rowIndex =
|
|
19
|
-
const columnIndex =
|
|
103
|
+
const rowIndex = rowAddressToIndex(row);
|
|
104
|
+
const columnIndex = columnAddressToIndex(column);
|
|
20
105
|
return [rowIndex, columnIndex];
|
|
21
106
|
}
|
|
22
|
-
export function
|
|
23
|
-
return `${
|
|
107
|
+
export function indexesToCellAddress(rowIndex, columnIndex) {
|
|
108
|
+
return `${indexToColumnAddress(columnIndex)}${indexToRowAddress(rowIndex)}`;
|
|
24
109
|
}
|
|
25
|
-
export function
|
|
26
|
-
return `${
|
|
110
|
+
export function indexesToBoxRangeAddress(startRowIndex, startColumnIndex, endRowIndex, endColumnIndex) {
|
|
111
|
+
return `${indexesToCellAddress(startRowIndex, startColumnIndex)}:${indexesToCellAddress(endRowIndex, endColumnIndex)}`;
|
|
27
112
|
}
|
|
28
|
-
export function
|
|
113
|
+
export function columnAddressToIndex(column) {
|
|
29
114
|
let index = 0;
|
|
30
115
|
for (let i = 0; i < column.length; i++) {
|
|
31
116
|
index = index * 26 + (column.charCodeAt(i) - 65 + 1);
|
|
32
117
|
}
|
|
33
118
|
return (index - 1);
|
|
34
119
|
}
|
|
35
|
-
export function
|
|
120
|
+
export function indexToColumnAddress(index) {
|
|
36
121
|
let result = "";
|
|
37
122
|
let currentIndex = index + 1;
|
|
38
123
|
while (currentIndex > 0) {
|
|
@@ -42,9 +127,9 @@ export function indexToColumn(index) {
|
|
|
42
127
|
}
|
|
43
128
|
return result;
|
|
44
129
|
}
|
|
45
|
-
export function
|
|
130
|
+
export function rowAddressToIndex(row) {
|
|
46
131
|
return (Number.parseInt(row, 10) - 1);
|
|
47
132
|
}
|
|
48
|
-
export function
|
|
133
|
+
export function indexToRowAddress(index) {
|
|
49
134
|
return (index + 1).toString();
|
|
50
135
|
}
|
|
@@ -1,64 +1,82 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
describe("
|
|
2
|
+
import { cellAddressToIndexes, columnAddressToIndex, getAddressFirstCell, getAddressLastCell, indexesToCellAddress, indexToColumnAddress, indexToRowAddress, rowAddressToIndex } from "./address.js";
|
|
3
|
+
describe("indexesToCellAddress", () => {
|
|
4
4
|
it("should convert row and column indexes to an address", () => {
|
|
5
|
-
expect(
|
|
6
|
-
expect(
|
|
7
|
-
expect(
|
|
5
|
+
expect(indexesToCellAddress(0, 0)).toBe("A1");
|
|
6
|
+
expect(indexesToCellAddress(4, 2)).toBe("C5");
|
|
7
|
+
expect(indexesToCellAddress(10, 25)).toBe("Z11");
|
|
8
8
|
});
|
|
9
9
|
});
|
|
10
|
-
describe("
|
|
10
|
+
describe("columnAddressToIndex", () => {
|
|
11
11
|
it("should convert column letters to a zero-based index", () => {
|
|
12
|
-
expect(
|
|
13
|
-
expect(
|
|
14
|
-
expect(
|
|
15
|
-
expect(
|
|
16
|
-
expect(
|
|
12
|
+
expect(columnAddressToIndex("A")).toBe(0);
|
|
13
|
+
expect(columnAddressToIndex("Z")).toBe(25);
|
|
14
|
+
expect(columnAddressToIndex("AA")).toBe(26);
|
|
15
|
+
expect(columnAddressToIndex("AB")).toBe(27);
|
|
16
|
+
expect(columnAddressToIndex("ZZ")).toBe(701);
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
|
-
describe("
|
|
19
|
+
describe("indexToColumnAddress", () => {
|
|
20
20
|
it("should convert a zero-based index to column letters", () => {
|
|
21
|
-
expect(
|
|
22
|
-
expect(
|
|
23
|
-
expect(
|
|
24
|
-
expect(
|
|
25
|
-
expect(
|
|
21
|
+
expect(indexToColumnAddress(0)).toBe("A");
|
|
22
|
+
expect(indexToColumnAddress(25)).toBe("Z");
|
|
23
|
+
expect(indexToColumnAddress(26)).toBe("AA");
|
|
24
|
+
expect(indexToColumnAddress(27)).toBe("AB");
|
|
25
|
+
expect(indexToColumnAddress(701)).toBe("ZZ");
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
|
-
describe("
|
|
28
|
+
describe("rowAddressToIndex", () => {
|
|
29
29
|
it("should convert a 1-based row to a 0-based index", () => {
|
|
30
|
-
expect(
|
|
31
|
-
expect(
|
|
32
|
-
expect(
|
|
30
|
+
expect(rowAddressToIndex("1")).toBe(0);
|
|
31
|
+
expect(rowAddressToIndex("5")).toBe(4);
|
|
32
|
+
expect(rowAddressToIndex("100")).toBe(99);
|
|
33
33
|
});
|
|
34
34
|
});
|
|
35
|
-
describe("
|
|
35
|
+
describe("indexToRowAddress", () => {
|
|
36
36
|
it("should convert a 0-based index to a 1-based row", () => {
|
|
37
|
-
expect(
|
|
38
|
-
expect(
|
|
39
|
-
expect(
|
|
37
|
+
expect(indexToRowAddress(0)).toBe("1");
|
|
38
|
+
expect(indexToRowAddress(4)).toBe("5");
|
|
39
|
+
expect(indexToRowAddress(99)).toBe("100");
|
|
40
40
|
});
|
|
41
41
|
});
|
|
42
|
-
describe("
|
|
42
|
+
describe("cellAddressToIndexes", () => {
|
|
43
43
|
it("should convert a cell address to row and column indexes", () => {
|
|
44
|
-
expect(
|
|
45
|
-
expect(
|
|
46
|
-
expect(
|
|
47
|
-
expect(
|
|
48
|
-
expect(
|
|
44
|
+
expect(cellAddressToIndexes("A1")).toEqual([0, 0]);
|
|
45
|
+
expect(cellAddressToIndexes("C5")).toEqual([4, 2]);
|
|
46
|
+
expect(cellAddressToIndexes("Z11")).toEqual([10, 25]);
|
|
47
|
+
expect(cellAddressToIndexes("AA1")).toEqual([0, 26]);
|
|
48
|
+
expect(cellAddressToIndexes("ZZ100")).toEqual([99, 701]);
|
|
49
49
|
});
|
|
50
50
|
});
|
|
51
|
-
describe("
|
|
51
|
+
describe("getAddressFirstCell", () => {
|
|
52
52
|
it("should return the start cell of a range address", () => {
|
|
53
|
-
expect(
|
|
54
|
-
expect(
|
|
55
|
-
expect(
|
|
53
|
+
expect(getAddressFirstCell("C3:D4")).toBe("C3");
|
|
54
|
+
expect(getAddressFirstCell("Sheet!A1:B2")).toBe("A1");
|
|
55
|
+
expect(getAddressFirstCell("E5")).toBe("E5"); // Single cell address
|
|
56
|
+
expect(getAddressFirstCell("Sheet!E5")).toBe("E5"); // Single cell address
|
|
57
|
+
expect(getAddressFirstCell("C")).toBe("C1"); // ColumnAddress
|
|
58
|
+
expect(getAddressFirstCell("Sheet!C")).toBe("C1"); // ColumnAddress
|
|
59
|
+
expect(getAddressFirstCell("3")).toBe("A3"); // RowAddress
|
|
60
|
+
expect(getAddressFirstCell("Sheet!3")).toBe("A3"); // RowAddress
|
|
61
|
+
expect(getAddressFirstCell("A:Z")).toBe("A1"); // ColumnRangeAddress
|
|
62
|
+
expect(getAddressFirstCell("Sheet!A:Z")).toBe("A1"); // ColumnRangeAddress
|
|
63
|
+
expect(getAddressFirstCell("1:10")).toBe("A1"); // RowRangeAddress
|
|
64
|
+
expect(getAddressFirstCell("Sheet!1:10")).toBe("A1"); // RowRangeAddress
|
|
56
65
|
});
|
|
57
66
|
});
|
|
58
|
-
describe("
|
|
67
|
+
describe("getAddressLastCell", () => {
|
|
59
68
|
it("should return the end cell of a range address", () => {
|
|
60
|
-
expect(
|
|
61
|
-
expect(
|
|
62
|
-
expect(
|
|
69
|
+
expect(getAddressLastCell("C3:D4")).toBe("D4");
|
|
70
|
+
expect(getAddressLastCell("Sheet!A1:B2")).toBe("B2");
|
|
71
|
+
expect(getAddressLastCell("E5")).toBe("E5"); // Single cell address
|
|
72
|
+
expect(getAddressLastCell("Sheet!E5")).toBe("E5"); // Single cell address
|
|
73
|
+
expect(getAddressLastCell("C")).toBe("C1048576"); // ColumnAddress
|
|
74
|
+
expect(getAddressLastCell("Sheet!C")).toBe("C1048576"); // ColumnAddress
|
|
75
|
+
expect(getAddressLastCell("3")).toBe("XFD3"); // RowAddress
|
|
76
|
+
expect(getAddressLastCell("Sheet!3")).toBe("XFD3"); // RowAddress
|
|
77
|
+
expect(getAddressLastCell("A:Z")).toBe("Z1048576"); // ColumnRangeAddress
|
|
78
|
+
expect(getAddressLastCell("Sheet!A:Z")).toBe("Z1048576"); // ColumnRangeAddress
|
|
79
|
+
expect(getAddressLastCell("1:10")).toBe("XFD10"); // RowRangeAddress
|
|
80
|
+
expect(getAddressLastCell("Sheet!1:10")).toBe("XFD10"); // RowRangeAddress
|
|
63
81
|
});
|
|
64
82
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpStatus.d.ts","sourceRoot":"","sources":["../../src/services/httpStatus.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE7D"}
|
|
1
|
+
{"version":3,"file":"httpStatus.d.ts","sourceRoot":"","sources":["../../src/services/httpStatus.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE5D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Address } from "../models/Address.ts";
|
|
2
2
|
import type { WorkbookRangeRef } from "../models/WorkbookRangeRef.ts";
|
|
3
3
|
import type { WorkbookWorksheetRef } from "../models/WorkbookWorksheetRef.ts";
|
|
4
|
-
export declare function createWorkbookRangeRef(worksheetRef: WorkbookWorksheetRef, address:
|
|
4
|
+
export declare function createWorkbookRangeRef(worksheetRef: WorkbookWorksheetRef, address: Address): WorkbookRangeRef;
|
|
5
5
|
//# sourceMappingURL=workbookRange.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workbookRange.d.ts","sourceRoot":"","sources":["../../src/services/workbookRange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"workbookRange.d.ts","sourceRoot":"","sources":["../../src/services/workbookRange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,oBAAoB,EAAE,OAAO,EAAE,OAAO,GAAG,gBAAgB,CAU7G"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ProtocolError from "../errors/ProtocolError.js";
|
|
2
|
-
import getWorkbookWorksheetRange from "../operations/
|
|
3
|
-
import {
|
|
2
|
+
import getWorkbookWorksheetRange from "../operations/workbookRange/getWorkbookWorksheetRange.js";
|
|
3
|
+
import { indexesToCellAddress } from "../services/address.js";
|
|
4
4
|
/** Get the last used cell (ie, the most-lower-right) in a given range. */
|
|
5
5
|
export default async function getRangeLastUsedCell(rangeRef) {
|
|
6
6
|
// TODO: Consider adding chunking if the range is too large
|
|
@@ -25,7 +25,7 @@ export default async function getRangeLastUsedCell(rangeRef) {
|
|
|
25
25
|
throw new ProtocolError("Cell missing");
|
|
26
26
|
}
|
|
27
27
|
if (cell !== null && cell !== "") {
|
|
28
|
-
const address =
|
|
28
|
+
const address = indexesToCellAddress(rowIndex, columnIndex);
|
|
29
29
|
return {
|
|
30
30
|
value: cell,
|
|
31
31
|
address,
|
|
@@ -5,6 +5,7 @@ import updateWorkbookRange from "../operations/workbookRange/updateWorkbookRange
|
|
|
5
5
|
import createWorkbookTable from "../operations/workbookTable/createWorkbookTable.js";
|
|
6
6
|
import { getDefaultDriveRef } from "../services/drive.js";
|
|
7
7
|
import { driveItemPath } from "../services/driveItem.js";
|
|
8
|
+
import { sleep } from "../services/sleep.js";
|
|
8
9
|
import { generateTempFileName } from "../services/temporaryFiles.js";
|
|
9
10
|
import { createWorkbookRangeRef } from "../services/workbookRange.js";
|
|
10
11
|
import { createWorkbookWorksheetRef, defaultWorkbookWorksheetId } from "../services/workbookWorksheet.js";
|
|
@@ -41,6 +42,7 @@ describe("getWorkbookTableVisibleBody", () => {
|
|
|
41
42
|
}
|
|
42
43
|
});
|
|
43
44
|
it("omits hidden rows from the visible body range of a table", async () => {
|
|
45
|
+
// TODO: This test is flappy and I haven't worked out why yet
|
|
44
46
|
const workbookName = generateTempFileName("xlsx");
|
|
45
47
|
const workbookPath = driveItemPath(workbookName);
|
|
46
48
|
const driveRef = getDefaultDriveRef();
|
|
@@ -60,6 +62,7 @@ describe("getWorkbookTableVisibleBody", () => {
|
|
|
60
62
|
const hiddenRange = createWorkbookRangeRef(worksheetRef, "2:2");
|
|
61
63
|
await updateWorkbookRange(hiddenRange, { rowHidden: true });
|
|
62
64
|
await calculateWorkbook(workbook);
|
|
65
|
+
await sleep(2000);
|
|
63
66
|
const visibleBodyRange = await getWorkbookTableVisibleBody(table);
|
|
64
67
|
expect(visibleBodyRange.values).toEqual([
|
|
65
68
|
["Value5", "Value6", "Value7", "Value8"],
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import InvalidArgumentError from "../errors/InvalidArgumentError.js";
|
|
2
2
|
import NeverError from "../errors/NeverError.js";
|
|
3
|
+
import getWorkbookWorksheetRange from "../operations/workbookRange/getWorkbookWorksheetRange.js";
|
|
3
4
|
import insertWorkbookCells from "../operations/workbookRange/insertWorkbookCells.js";
|
|
4
5
|
import updateWorkbookRange from "../operations/workbookRange/updateWorkbookRange.js";
|
|
5
6
|
import getWorkbookTableBodyRange from "../operations/workbookTable/getWorkbookTableBodyRange.js";
|
|
6
|
-
import
|
|
7
|
-
import { cellToIndexes, getAddressEnd, getAddressStart, indexesToBox } from "../services/address.js";
|
|
7
|
+
import { cellAddressToIndexes, getAddressFirstCell, getAddressLastCell, indexesToBoxRangeAddress } from "../services/address.js";
|
|
8
8
|
import { createWorkbookRangeRef } from "../services/workbookRange.js";
|
|
9
9
|
/** Overwrite visible rows of a workbook table with the provided 2D array of values, inserting new rows at the end if needed. THIS IS SLOW as it must check each rows visibility. */
|
|
10
10
|
export async function setWorkbookTableBodyVisibleRows(tableRef, values) {
|
|
@@ -12,8 +12,8 @@ export async function setWorkbookTableBodyVisibleRows(tableRef, values) {
|
|
|
12
12
|
if (values.some((row) => row.length !== visibleRange.columnCount)) {
|
|
13
13
|
throw new InvalidArgumentError(`Invalid number of columns in input values. Expected all rows to have ${visibleRange.columnCount}.`);
|
|
14
14
|
}
|
|
15
|
-
const [startRowIndex, startColumnIndex] =
|
|
16
|
-
const [endRowIndex, endColumnIndex] =
|
|
15
|
+
const [startRowIndex, startColumnIndex] = cellAddressToIndexes(getAddressFirstCell(visibleRange.address));
|
|
16
|
+
const [endRowIndex, endColumnIndex] = cellAddressToIndexes(getAddressLastCell(visibleRange.address));
|
|
17
17
|
if (endColumnIndex - startColumnIndex + 1 !== visibleRange.columnCount) {
|
|
18
18
|
throw new NeverError("Insane address");
|
|
19
19
|
}
|
|
@@ -23,7 +23,7 @@ export async function setWorkbookTableBodyVisibleRows(tableRef, values) {
|
|
|
23
23
|
let dstRow;
|
|
24
24
|
let dstRowHidden = false;
|
|
25
25
|
do {
|
|
26
|
-
dstRowRef = createWorkbookRangeRef(tableRef,
|
|
26
|
+
dstRowRef = createWorkbookRangeRef(tableRef, indexesToBoxRangeAddress(currentRowIndex, startColumnIndex, currentRowIndex, endColumnIndex));
|
|
27
27
|
if (currentRowIndex > endRowIndex) {
|
|
28
28
|
await insertWorkbookCells(dstRowRef, dstRowRef.address, "Down");
|
|
29
29
|
dstRowHidden = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "microsoft-graph",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"description": "Microsoft GraphAPI SDK for NodeJS",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -93,6 +93,10 @@
|
|
|
93
93
|
"import": "./dist/models/AccessToken.js",
|
|
94
94
|
"types": "./dist/models/AccessToken.d.ts"
|
|
95
95
|
},
|
|
96
|
+
"./models/Address": {
|
|
97
|
+
"import": "./dist/models/Address.js",
|
|
98
|
+
"types": "./dist/models/Address.d.ts"
|
|
99
|
+
},
|
|
96
100
|
"./models/Box": {
|
|
97
101
|
"import": "./dist/models/Box.js",
|
|
98
102
|
"types": "./dist/models/Box.d.ts"
|
|
@@ -325,6 +329,10 @@
|
|
|
325
329
|
"import": "./dist/operations/workbookRange/getWorkbookVisibleRange.js",
|
|
326
330
|
"types": "./dist/operations/workbookRange/getWorkbookVisibleRange.d.ts"
|
|
327
331
|
},
|
|
332
|
+
"./operations/workbookRange/getWorkbookWorksheetRange": {
|
|
333
|
+
"import": "./dist/operations/workbookRange/getWorkbookWorksheetRange.js",
|
|
334
|
+
"types": "./dist/operations/workbookRange/getWorkbookWorksheetRange.d.ts"
|
|
335
|
+
},
|
|
328
336
|
"./operations/workbookRange/insertWorkbookCells": {
|
|
329
337
|
"import": "./dist/operations/workbookRange/insertWorkbookCells.js",
|
|
330
338
|
"types": "./dist/operations/workbookRange/insertWorkbookCells.d.ts"
|