microsoft-graph 2.2.5 → 2.3.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/errors/NeverError.d.ts +1 -1
- package/dist/errors/NeverError.d.ts.map +1 -1
- package/dist/errors/UnsupportedAddressTypeError.d.ts +4 -0
- package/dist/errors/UnsupportedAddressTypeError.d.ts.map +1 -0
- package/dist/errors/UnsupportedAddressTypeError.js +6 -0
- package/dist/models/ColumnOffset.d.ts +4 -0
- package/dist/models/ColumnOffset.d.ts.map +1 -0
- package/dist/models/ColumnOffset.js +1 -0
- package/dist/models/RowOffset.d.ts +4 -0
- package/dist/models/RowOffset.d.ts.map +1 -0
- package/dist/models/RowOffset.js +1 -0
- package/dist/operations/drive/listDrives.d.ts +1 -1
- package/dist/operations/drive/listDrives.d.ts.map +1 -1
- package/dist/operations/drive/listDrives.js +1 -2
- package/dist/operations/drive/listDrives.test.js +3 -1
- package/dist/services/addressManipulation.d.ts +20 -0
- package/dist/services/addressManipulation.d.ts.map +1 -0
- package/dist/services/addressManipulation.js +159 -0
- package/dist/services/addressManipulation.test.d.ts +2 -0
- package/dist/services/addressManipulation.test.d.ts.map +1 -0
- package/dist/services/addressManipulation.test.js +310 -0
- package/dist/services/addressOffset.d.ts +8 -0
- package/dist/services/addressOffset.d.ts.map +1 -0
- package/dist/services/addressOffset.js +23 -0
- package/dist/services/addressOffset.test.d.ts +2 -0
- package/dist/services/addressOffset.test.d.ts.map +1 -0
- package/dist/services/addressOffset.test.js +38 -0
- package/dist/tasks/deleteDriveItemWithRetry.d.ts.map +1 -1
- package/dist/tasks/deleteDriveItemWithRetry.js +0 -1
- package/dist/tasks/getRangeLastUsedCell.d.ts +0 -2
- package/dist/tasks/getRangeLastUsedCell.d.ts.map +1 -1
- package/dist/tasks/getRangeLastUsedCell.js +4 -5
- package/dist/tasks/getRangeLastUsedCell.test.js +0 -4
- package/dist/tasks/setWorkbookTableBodyVisibleRows.d.ts.map +1 -1
- package/dist/tasks/setWorkbookTableBodyVisibleRows.js +10 -15
- package/package.json +21 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeverError.d.ts","sourceRoot":"","sources":["../../src/errors/NeverError.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"NeverError.d.ts","sourceRoot":"","sources":["../../src/errors/NeverError.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,KAAK;gBACzB,OAAO,CAAC,EAAE,MAAM;CAInC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnsupportedAddressTypeError.d.ts","sourceRoot":"","sources":["../../src/errors/UnsupportedAddressTypeError.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,2BAA4B,SAAQ,KAAK;gBAC1C,OAAO,EAAE,MAAM;CAIlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColumnOffset.d.ts","sourceRoot":"","sources":["../../src/models/ColumnOffset.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IACnC,OAAO,EAAE,cAAc,CAAC;CACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RowOffset.d.ts","sourceRoot":"","sources":["../../src/models/RowOffset.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG;IAChC,OAAO,EAAE,WAAW,CAAC;CACrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,5 +3,5 @@ import type { DriveRef } from "../../models/DriveRef.ts";
|
|
|
3
3
|
import type { GraphOperation } from "../../models/GraphOperation.ts";
|
|
4
4
|
import type { SiteRef } from "../../models/SiteRef.ts";
|
|
5
5
|
/** Retrieve the list of Drive resources available for a Site. @see https://learn.microsoft.com/en-us/graph/api/drive-list */
|
|
6
|
-
export default function listDrives(siteRef
|
|
6
|
+
export default function listDrives(siteRef: SiteRef): GraphOperation<(DriveItem & DriveRef)[]>;
|
|
7
7
|
//# sourceMappingURL=listDrives.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listDrives.d.ts","sourceRoot":"","sources":["../../../src/operations/drive/listDrives.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAGlE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"listDrives.d.ts","sourceRoot":"","sources":["../../../src/operations/drive/listDrives.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAGlE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAIvD,6HAA6H;AAC7H,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,cAAc,CAAC,CAAC,SAAS,GAAG,QAAQ,CAAC,EAAE,CAAC,CAkB7F"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { operation } from "../../graphApi.js";
|
|
2
2
|
import { createDriveRef } from "../../services/drive.js";
|
|
3
|
-
import { getDefaultSiteRef } from "../../services/site.js";
|
|
4
3
|
import { generatePath } from "../../services/templatedPaths.js";
|
|
5
4
|
/** Retrieve the list of Drive resources available for a Site. @see https://learn.microsoft.com/en-us/graph/api/drive-list */
|
|
6
|
-
export default function listDrives(siteRef
|
|
5
|
+
export default function listDrives(siteRef) {
|
|
7
6
|
return operation({
|
|
8
7
|
contextId: siteRef.contextId,
|
|
9
8
|
method: "GET",
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { getDefaultSiteRef } from "../../services/site.js";
|
|
2
3
|
import listDrives from "./listDrives.js";
|
|
3
4
|
describe("listDrives", () => {
|
|
4
5
|
it("can listDrives", async () => {
|
|
5
|
-
const
|
|
6
|
+
const siteRef = getDefaultSiteRef();
|
|
7
|
+
const drives = await listDrives(siteRef);
|
|
6
8
|
console.debug("Drives:", drives.map((drive) => [drive.id, drive.name]));
|
|
7
9
|
expect(drives.length).toBeGreaterThan(0);
|
|
8
10
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Address, CellAddress, ColumnAddress, RowAddress } from "../models/Address.ts";
|
|
2
|
+
export type AddressComponents = {
|
|
3
|
+
startColumn: ColumnAddress;
|
|
4
|
+
endColumn: ColumnAddress;
|
|
5
|
+
startRow: RowAddress;
|
|
6
|
+
endRow: RowAddress;
|
|
7
|
+
};
|
|
8
|
+
export declare function decomposeAddress(address: Address): AddressComponents;
|
|
9
|
+
export declare function composeAddress(components: AddressComponents): Address;
|
|
10
|
+
export declare function getFirstCellAddress(address: Address): CellAddress;
|
|
11
|
+
export declare function getLastCellAddress(address: Address): CellAddress;
|
|
12
|
+
export declare function getFirstRowAddress(address: Address): Address;
|
|
13
|
+
export declare function getLastRowAddress(address: Address): Address;
|
|
14
|
+
export declare function getFirstColumnAddress(address: Address): Address;
|
|
15
|
+
export declare function getLastColumnAddress(address: Address): Address;
|
|
16
|
+
export declare function offsetAddress(address: Address, columnOffset: number, rowOffset: number): Address;
|
|
17
|
+
export declare function incrementRowAddress(address: Address): Address;
|
|
18
|
+
export declare function decrementRowAddress(address: Address): Address;
|
|
19
|
+
export declare function isAddressOverlapping(address1: Address, address2: Address): boolean;
|
|
20
|
+
//# sourceMappingURL=addressManipulation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addressManipulation.d.ts","sourceRoot":"","sources":["../../src/services/addressManipulation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAoB,aAAa,EAAsB,UAAU,EAAmB,MAAM,sBAAsB,CAAC;AAmBnJ,MAAM,MAAM,iBAAiB,GAAG;IAC/B,WAAW,EAAE,aAAa,CAAC;IAC3B,SAAS,EAAE,aAAa,CAAC;IACzB,QAAQ,EAAE,UAAU,CAAC;IACrB,MAAM,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,iBAAiB,CAcpE;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CA6BrE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAGjE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAGhE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAS5D;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAS3D;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAS/D;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAS9D;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAqChG;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAE7D;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAE7D;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAKlF"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import InvalidArgumentError from "../errors/InvalidArgumentError.js";
|
|
2
|
+
import UnsupportedAddressTypeError from "../errors/UnsupportedAddressTypeError.js";
|
|
3
|
+
import { columnAddressToOffset, offsetToColumnAddress, offsetToRowAddress, rowAddressToOffset } from "./addressOffset.js";
|
|
4
|
+
const firstColumn = "A";
|
|
5
|
+
const lastColumn = "XFD";
|
|
6
|
+
const firstRow = "1";
|
|
7
|
+
const lastRow = "1048576";
|
|
8
|
+
const addressPattern = /^(?<sheet>[A-Za-z0-9_]+!)?(?:(?<startColumn>[A-Z]+)?(?<startRow>\d+)?(?::(?<endColumn>[A-Z]+)?(?<endRow>\d+)?)?)$/;
|
|
9
|
+
export function decomposeAddress(address) {
|
|
10
|
+
const match = address.match(addressPattern);
|
|
11
|
+
if (!match?.groups) {
|
|
12
|
+
throw new InvalidArgumentError(`Invalid address format. Must match pattern '${addressPattern}'`);
|
|
13
|
+
}
|
|
14
|
+
const groups = match.groups;
|
|
15
|
+
return {
|
|
16
|
+
startColumn: groups.startColumn ?? firstColumn,
|
|
17
|
+
startRow: groups.startRow ?? firstRow,
|
|
18
|
+
endColumn: groups.endColumn ?? groups.startColumn ?? lastColumn,
|
|
19
|
+
endRow: groups.endRow ?? groups.startRow ?? lastRow,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function composeAddress(components) {
|
|
23
|
+
if (isSingleColumn(components) && isMaxRows(components)) {
|
|
24
|
+
return composeColumnAddress(components.startColumn);
|
|
25
|
+
}
|
|
26
|
+
if (isSingleRow(components) && isMaxColumns(components)) {
|
|
27
|
+
return composeRowAddress(components.startRow);
|
|
28
|
+
}
|
|
29
|
+
if (isMaxRows(components)) {
|
|
30
|
+
return composeColumnRangeAddress(components.startColumn, components.endColumn);
|
|
31
|
+
}
|
|
32
|
+
if (isMaxColumns(components)) {
|
|
33
|
+
return composeRowRangeAddress(components.startRow, components.endRow);
|
|
34
|
+
}
|
|
35
|
+
if (isSingleColumn(components) && isSingleRow(components)) {
|
|
36
|
+
return composeCellAddress(components.startColumn, components.startRow);
|
|
37
|
+
}
|
|
38
|
+
if (components.startColumn > components.endColumn) {
|
|
39
|
+
throw new InvalidArgumentError("Invalid address. End column is before start column.");
|
|
40
|
+
}
|
|
41
|
+
if (components.startRow > components.endRow) {
|
|
42
|
+
throw new InvalidArgumentError("Invalid address. End row is before start row.");
|
|
43
|
+
}
|
|
44
|
+
return composeCellRangeAddress(components.startColumn, components.startRow, components.endColumn, components.endRow);
|
|
45
|
+
}
|
|
46
|
+
export function getFirstCellAddress(address) {
|
|
47
|
+
const components = decomposeAddress(address);
|
|
48
|
+
return composeCellAddress(components.startColumn, components.startRow);
|
|
49
|
+
}
|
|
50
|
+
export function getLastCellAddress(address) {
|
|
51
|
+
const components = decomposeAddress(address);
|
|
52
|
+
return composeCellAddress(components.endColumn, components.endRow);
|
|
53
|
+
}
|
|
54
|
+
export function getFirstRowAddress(address) {
|
|
55
|
+
const components = decomposeAddress(address);
|
|
56
|
+
return composeAddress({
|
|
57
|
+
startColumn: components.startColumn,
|
|
58
|
+
startRow: components.startRow,
|
|
59
|
+
endColumn: components.endColumn,
|
|
60
|
+
endRow: components.startRow,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
export function getLastRowAddress(address) {
|
|
64
|
+
const components = decomposeAddress(address);
|
|
65
|
+
return composeAddress({
|
|
66
|
+
startColumn: components.startColumn,
|
|
67
|
+
startRow: components.endRow,
|
|
68
|
+
endColumn: components.endColumn,
|
|
69
|
+
endRow: components.endRow,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
export function getFirstColumnAddress(address) {
|
|
73
|
+
const components = decomposeAddress(address);
|
|
74
|
+
return composeAddress({
|
|
75
|
+
startColumn: components.startColumn,
|
|
76
|
+
startRow: components.startRow,
|
|
77
|
+
endColumn: components.startColumn,
|
|
78
|
+
endRow: components.endRow,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
export function getLastColumnAddress(address) {
|
|
82
|
+
const components = decomposeAddress(address);
|
|
83
|
+
return composeAddress({
|
|
84
|
+
startColumn: components.endColumn,
|
|
85
|
+
startRow: components.startRow,
|
|
86
|
+
endColumn: components.endColumn,
|
|
87
|
+
endRow: components.endRow,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
export function offsetAddress(address, columnOffset, rowOffset) {
|
|
91
|
+
const components = decomposeAddress(address);
|
|
92
|
+
if (isMaxRows(components) && rowOffset !== 0) {
|
|
93
|
+
throw new UnsupportedAddressTypeError("All rows are selected. Cannot offset rows.");
|
|
94
|
+
}
|
|
95
|
+
if (isMaxColumns(components) && columnOffset !== 0) {
|
|
96
|
+
throw new UnsupportedAddressTypeError("All columns are selected. Cannot offset columns.");
|
|
97
|
+
}
|
|
98
|
+
const newStartRowIndex = rowAddressToOffset(components.startRow) + rowOffset;
|
|
99
|
+
const newEndRowIndex = rowAddressToOffset(components.endRow) + rowOffset;
|
|
100
|
+
if (newStartRowIndex < rowAddressToOffset(firstRow) || newEndRowIndex > rowAddressToOffset(lastRow)) {
|
|
101
|
+
throw new InvalidArgumentError(`Row offset out of bounds: ${newStartRowIndex + 1} to ${newEndRowIndex + 1}`);
|
|
102
|
+
}
|
|
103
|
+
const newStartRow = offsetToRowAddress(newStartRowIndex);
|
|
104
|
+
const newEndRow = offsetToRowAddress(newEndRowIndex);
|
|
105
|
+
const newStartColumnIndex = columnAddressToOffset(components.startColumn) + columnOffset;
|
|
106
|
+
const newEndColumnIndex = columnAddressToOffset(components.endColumn) + columnOffset;
|
|
107
|
+
if (newStartColumnIndex < columnAddressToOffset(firstColumn) || newEndColumnIndex > columnAddressToOffset(lastColumn)) {
|
|
108
|
+
throw new InvalidArgumentError(`Column offset out of bounds: ${newStartColumnIndex + 1} to ${newEndColumnIndex + 1}`);
|
|
109
|
+
}
|
|
110
|
+
const newStartColumn = offsetToColumnAddress(newStartColumnIndex);
|
|
111
|
+
const newEndColumn = offsetToColumnAddress(newEndColumnIndex);
|
|
112
|
+
return composeAddress({
|
|
113
|
+
startColumn: newStartColumn,
|
|
114
|
+
endColumn: newEndColumn,
|
|
115
|
+
startRow: newStartRow,
|
|
116
|
+
endRow: newEndRow,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
export function incrementRowAddress(address) {
|
|
120
|
+
return offsetAddress(address, 0, +1);
|
|
121
|
+
}
|
|
122
|
+
export function decrementRowAddress(address) {
|
|
123
|
+
return offsetAddress(address, 0, -1);
|
|
124
|
+
}
|
|
125
|
+
export function isAddressOverlapping(address1, address2) {
|
|
126
|
+
const components1 = decomposeAddress(address1);
|
|
127
|
+
const components2 = decomposeAddress(address2);
|
|
128
|
+
return components1.startColumn <= components2.endColumn && components1.endColumn >= components2.startColumn && rowAddressToOffset(components1.startRow) <= rowAddressToOffset(components2.endRow) && rowAddressToOffset(components1.endRow) >= rowAddressToOffset(components2.startRow);
|
|
129
|
+
}
|
|
130
|
+
function composeCellRangeAddress(startColumn, startRow, endColumn, endRow) {
|
|
131
|
+
return `${startColumn}${startRow}:${endColumn}${endRow}`;
|
|
132
|
+
}
|
|
133
|
+
function composeCellAddress(startColumn, startRow) {
|
|
134
|
+
return `${startColumn}${startRow}`;
|
|
135
|
+
}
|
|
136
|
+
function composeRowRangeAddress(startRow, endRow) {
|
|
137
|
+
return `${startRow}:${endRow}`;
|
|
138
|
+
}
|
|
139
|
+
function composeColumnRangeAddress(startColumn, endColumn) {
|
|
140
|
+
return `${startColumn}:${endColumn}`;
|
|
141
|
+
}
|
|
142
|
+
function composeRowAddress(startRow) {
|
|
143
|
+
return startRow;
|
|
144
|
+
}
|
|
145
|
+
function composeColumnAddress(startColumn) {
|
|
146
|
+
return startColumn;
|
|
147
|
+
}
|
|
148
|
+
function isSingleRow(components) {
|
|
149
|
+
return components.startRow === components.endRow;
|
|
150
|
+
}
|
|
151
|
+
function isSingleColumn(components) {
|
|
152
|
+
return components.startColumn === components.endColumn;
|
|
153
|
+
}
|
|
154
|
+
function isMaxColumns(components) {
|
|
155
|
+
return components.startColumn === firstColumn && components.endColumn === lastColumn;
|
|
156
|
+
}
|
|
157
|
+
function isMaxRows(components) {
|
|
158
|
+
return components.startRow === firstRow && components.endRow === lastRow;
|
|
159
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addressManipulation.test.d.ts","sourceRoot":"","sources":["../../src/services/addressManipulation.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import InvalidArgumentError from "../errors/InvalidArgumentError.js";
|
|
3
|
+
import { composeAddress, decomposeAddress, decrementRowAddress, getFirstCellAddress, getFirstColumnAddress, getFirstRowAddress, getLastCellAddress, getLastColumnAddress, getLastRowAddress, incrementRowAddress, isAddressOverlapping, offsetAddress } from "./addressManipulation.js";
|
|
4
|
+
describe("getFirstCellAddress", () => {
|
|
5
|
+
it("should return the start cell of a range address", () => {
|
|
6
|
+
expect(getFirstCellAddress("C3:D4")).toBe("C3");
|
|
7
|
+
expect(getFirstCellAddress("Sheet!A1:B2")).toBe("A1");
|
|
8
|
+
expect(getFirstCellAddress("E5")).toBe("E5"); // Single cell address
|
|
9
|
+
expect(getFirstCellAddress("Sheet!E5")).toBe("E5"); // Single cell address
|
|
10
|
+
expect(getFirstCellAddress("C")).toBe("C1"); // ColumnAddress
|
|
11
|
+
expect(getFirstCellAddress("Sheet!C")).toBe("C1"); // ColumnAddress
|
|
12
|
+
expect(getFirstCellAddress("3")).toBe("A3"); // RowAddress
|
|
13
|
+
expect(getFirstCellAddress("Sheet!3")).toBe("A3"); // RowAddress
|
|
14
|
+
expect(getFirstCellAddress("A:Z")).toBe("A1"); // ColumnRangeAddress
|
|
15
|
+
expect(getFirstCellAddress("Sheet!A:Z")).toBe("A1"); // ColumnRangeAddress
|
|
16
|
+
expect(getFirstCellAddress("1:10")).toBe("A1"); // RowRangeAddress
|
|
17
|
+
expect(getFirstCellAddress("Sheet!1:10")).toBe("A1"); // RowRangeAddress
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
describe("getLastCellAddress", () => {
|
|
21
|
+
it("should return the end cell of a range address", () => {
|
|
22
|
+
expect(getLastCellAddress("C3:D4")).toBe("D4");
|
|
23
|
+
expect(getLastCellAddress("Sheet!A1:B2")).toBe("B2");
|
|
24
|
+
expect(getLastCellAddress("E5")).toBe("E5"); // Single cell address
|
|
25
|
+
expect(getLastCellAddress("Sheet!E5")).toBe("E5"); // Single cell address
|
|
26
|
+
expect(getLastCellAddress("C")).toBe("C1048576"); // ColumnAddress
|
|
27
|
+
expect(getLastCellAddress("Sheet!C")).toBe("C1048576"); // ColumnAddress
|
|
28
|
+
expect(getLastCellAddress("3")).toBe("XFD3"); // RowAddress
|
|
29
|
+
expect(getLastCellAddress("Sheet!3")).toBe("XFD3"); // RowAddress
|
|
30
|
+
expect(getLastCellAddress("A:Z")).toBe("Z1048576"); // ColumnRangeAddress
|
|
31
|
+
expect(getLastCellAddress("Sheet!A:Z")).toBe("Z1048576"); // ColumnRangeAddress
|
|
32
|
+
expect(getLastCellAddress("1:10")).toBe("XFD10"); // RowRangeAddress
|
|
33
|
+
expect(getLastCellAddress("Sheet!1:10")).toBe("XFD10"); // RowRangeAddress
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
describe("getFirstRowAddress", () => {
|
|
37
|
+
it("should return the first row of a row range", () => {
|
|
38
|
+
expect(getFirstRowAddress("1:5")).toBe("1");
|
|
39
|
+
expect(getFirstRowAddress("Sheet!1:10")).toBe("1");
|
|
40
|
+
});
|
|
41
|
+
it("should return the first row of a column range", () => {
|
|
42
|
+
expect(getFirstRowAddress("A")).toBe("A1");
|
|
43
|
+
expect(getFirstRowAddress("A:C")).toBe("A1:C1");
|
|
44
|
+
});
|
|
45
|
+
it("should handle cell ranges", () => {
|
|
46
|
+
expect(getFirstRowAddress("A1:C5")).toBe("A1:C1");
|
|
47
|
+
});
|
|
48
|
+
it("should return the first row of a single cell address", () => {
|
|
49
|
+
expect(getFirstRowAddress("A1")).toBe("A1");
|
|
50
|
+
expect(getFirstRowAddress("Sheet!B2")).toBe("B2");
|
|
51
|
+
});
|
|
52
|
+
it("should handle cell ranges", () => {
|
|
53
|
+
expect(getFirstRowAddress("A1:C5")).toBe("A1:C1");
|
|
54
|
+
});
|
|
55
|
+
it("should return the same cell address for a single cell", () => {
|
|
56
|
+
expect(getFirstRowAddress("C1")).toBe("C1");
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
describe("getLastRowAddress", () => {
|
|
60
|
+
it("should return the last row of a row range", () => {
|
|
61
|
+
expect(getLastRowAddress("1:5")).toBe("5");
|
|
62
|
+
expect(getLastRowAddress("Sheet!1:10")).toBe("10");
|
|
63
|
+
});
|
|
64
|
+
it("should return the last row of a column range", () => {
|
|
65
|
+
expect(getLastRowAddress("A")).toBe("A1048576");
|
|
66
|
+
expect(getLastRowAddress("A:C")).toBe("A1048576:C1048576");
|
|
67
|
+
});
|
|
68
|
+
it("should handle cell ranges", () => {
|
|
69
|
+
expect(getLastRowAddress("A1:C5")).toBe("A5:C5");
|
|
70
|
+
});
|
|
71
|
+
it("should return the last row of a single cell address", () => {
|
|
72
|
+
expect(getLastRowAddress("A1")).toBe("A1");
|
|
73
|
+
expect(getLastRowAddress("Sheet!B2")).toBe("B2");
|
|
74
|
+
});
|
|
75
|
+
it("should handle cell ranges", () => {
|
|
76
|
+
expect(getLastRowAddress("A1:C5")).toBe("A5:C5");
|
|
77
|
+
});
|
|
78
|
+
it("should return the same cell address for a single cell", () => {
|
|
79
|
+
expect(getLastRowAddress("C1")).toBe("C1");
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
describe("getFirstColumnAddress", () => {
|
|
83
|
+
it("should return the first column of a column range", () => {
|
|
84
|
+
expect(getFirstColumnAddress("A:C")).toBe("A");
|
|
85
|
+
expect(getFirstColumnAddress("Sheet!A:Z")).toBe("A");
|
|
86
|
+
});
|
|
87
|
+
it("should return the first column of a row range", () => {
|
|
88
|
+
expect(getFirstColumnAddress("1")).toBe("A1");
|
|
89
|
+
expect(getFirstColumnAddress("1:5")).toBe("A1:A5");
|
|
90
|
+
});
|
|
91
|
+
it("should handle cell ranges", () => {
|
|
92
|
+
expect(getFirstColumnAddress("A1:C5")).toBe("A1:A5");
|
|
93
|
+
});
|
|
94
|
+
it("should return the first column of a single cell address", () => {
|
|
95
|
+
expect(getFirstColumnAddress("A1")).toBe("A1");
|
|
96
|
+
expect(getFirstColumnAddress("Sheet!B2")).toBe("B2");
|
|
97
|
+
});
|
|
98
|
+
it("should handle cell ranges", () => {
|
|
99
|
+
expect(getFirstColumnAddress("A1:C5")).toBe("A1:A5");
|
|
100
|
+
});
|
|
101
|
+
it("should return the same cell address for a single cell", () => {
|
|
102
|
+
expect(getFirstColumnAddress("C1")).toBe("C1");
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
describe("getLastColumnAddress", () => {
|
|
106
|
+
it("should return the last column of a column range", () => {
|
|
107
|
+
expect(getLastColumnAddress("A:C")).toBe("C");
|
|
108
|
+
expect(getLastColumnAddress("Sheet!A:Z")).toBe("Z");
|
|
109
|
+
});
|
|
110
|
+
it("should return the last column of a row range", () => {
|
|
111
|
+
expect(getLastColumnAddress("1")).toBe("XFD1");
|
|
112
|
+
expect(getLastColumnAddress("1:5")).toBe("XFD1:XFD5");
|
|
113
|
+
});
|
|
114
|
+
it("should handle cell ranges", () => {
|
|
115
|
+
expect(getLastColumnAddress("A1:C5")).toBe("C1:C5");
|
|
116
|
+
});
|
|
117
|
+
it("should return the last column of a single cell address", () => {
|
|
118
|
+
expect(getLastColumnAddress("A1")).toBe("A1");
|
|
119
|
+
expect(getLastColumnAddress("Sheet!B2")).toBe("B2");
|
|
120
|
+
});
|
|
121
|
+
it("should handle cell ranges", () => {
|
|
122
|
+
expect(getLastColumnAddress("A1:C5")).toBe("C1:C5");
|
|
123
|
+
});
|
|
124
|
+
it("should return the same cell address for a single cell", () => {
|
|
125
|
+
expect(getLastColumnAddress("C1")).toBe("C1");
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
describe("offsetAddress", () => {
|
|
129
|
+
it("should offset rows and columns in a cell range", () => {
|
|
130
|
+
expect(offsetAddress("A1:C5", 2, 2)).toBe("C3:E7");
|
|
131
|
+
expect(offsetAddress("Sheet!B2:C5", 2, 2)).toBe("D4:E7");
|
|
132
|
+
});
|
|
133
|
+
it("should offset rows only", () => {
|
|
134
|
+
expect(offsetAddress("A1:C5", 0, 2)).toBe("A3:C7");
|
|
135
|
+
expect(offsetAddress("Sheet!B1:C5", 0, 2)).toBe("B3:C7");
|
|
136
|
+
});
|
|
137
|
+
it("should offset columns only", () => {
|
|
138
|
+
expect(offsetAddress("A1:C5", 2, 0)).toBe("C1:E5");
|
|
139
|
+
expect(offsetAddress("Sheet!A2:C5", 2, 0)).toBe("C2:E5");
|
|
140
|
+
});
|
|
141
|
+
it("should throw if offset exceeds valid range", () => {
|
|
142
|
+
expect(() => offsetAddress("A1:C5", 0, 1048577)).toThrow(InvalidArgumentError);
|
|
143
|
+
expect(() => offsetAddress("A1:C5", 16385, 0)).toThrow(InvalidArgumentError);
|
|
144
|
+
});
|
|
145
|
+
it("should offset rows and columns in a single cell address", () => {
|
|
146
|
+
expect(offsetAddress("A1", 2, 2)).toBe("C3");
|
|
147
|
+
expect(offsetAddress("Sheet!B2", 2, 2)).toBe("D4");
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
describe("incrementRowAddress", () => {
|
|
151
|
+
it("should increment the row of a row range", () => {
|
|
152
|
+
expect(incrementRowAddress("1:5")).toBe("2:6");
|
|
153
|
+
});
|
|
154
|
+
it("should increment the row of a cell range", () => {
|
|
155
|
+
expect(incrementRowAddress("A1:C5")).toBe("A2:C6");
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
describe("decrementRowAddress", () => {
|
|
159
|
+
it("should decrement the row of a row range", () => {
|
|
160
|
+
expect(decrementRowAddress("2:6")).toBe("1:5");
|
|
161
|
+
});
|
|
162
|
+
it("should decrement the row of a cell range", () => {
|
|
163
|
+
expect(decrementRowAddress("A2:C6")).toBe("A1:C5");
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
describe("decomposeAddress", () => {
|
|
167
|
+
it("should parse a column address", () => {
|
|
168
|
+
expect(decomposeAddress("A")).toEqual({
|
|
169
|
+
startColumn: "A",
|
|
170
|
+
endColumn: "A",
|
|
171
|
+
startRow: "1",
|
|
172
|
+
endRow: "1048576",
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
it("should parse a row address", () => {
|
|
176
|
+
expect(decomposeAddress("5")).toEqual({
|
|
177
|
+
startColumn: "A",
|
|
178
|
+
endColumn: "XFD",
|
|
179
|
+
startRow: "5",
|
|
180
|
+
endRow: "5",
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
it("should parse a cell address", () => {
|
|
184
|
+
expect(decomposeAddress("B3")).toEqual({
|
|
185
|
+
startColumn: "B",
|
|
186
|
+
endColumn: "B",
|
|
187
|
+
startRow: "3",
|
|
188
|
+
endRow: "3",
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
it("should parse a column range address", () => {
|
|
192
|
+
expect(decomposeAddress("A:C")).toEqual({
|
|
193
|
+
startColumn: "A",
|
|
194
|
+
endColumn: "C",
|
|
195
|
+
startRow: "1",
|
|
196
|
+
endRow: "1048576",
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
it("should parse a row range address", () => {
|
|
200
|
+
expect(decomposeAddress("1:10")).toEqual({
|
|
201
|
+
startColumn: "A",
|
|
202
|
+
endColumn: "XFD",
|
|
203
|
+
startRow: "1",
|
|
204
|
+
endRow: "10",
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
it("should parse a cell range address", () => {
|
|
208
|
+
expect(decomposeAddress("A1:C5")).toEqual({
|
|
209
|
+
startColumn: "A",
|
|
210
|
+
endColumn: "C",
|
|
211
|
+
startRow: "1",
|
|
212
|
+
endRow: "5",
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
it("should throw an error for invalid addresses", () => {
|
|
216
|
+
expect(() => decomposeAddress("InvalidAddress")).toThrow(InvalidArgumentError);
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
describe("composeAddress", () => {
|
|
220
|
+
it("should create a column address", () => {
|
|
221
|
+
expect(composeAddress({
|
|
222
|
+
startColumn: "A",
|
|
223
|
+
endColumn: "A",
|
|
224
|
+
startRow: "1",
|
|
225
|
+
endRow: "1048576",
|
|
226
|
+
})).toBe("A");
|
|
227
|
+
});
|
|
228
|
+
it("should create a row address", () => {
|
|
229
|
+
expect(composeAddress({
|
|
230
|
+
startColumn: "A",
|
|
231
|
+
endColumn: "XFD",
|
|
232
|
+
startRow: "5",
|
|
233
|
+
endRow: "5",
|
|
234
|
+
})).toBe("5");
|
|
235
|
+
});
|
|
236
|
+
it("should create a cell address", () => {
|
|
237
|
+
expect(composeAddress({
|
|
238
|
+
startColumn: "B",
|
|
239
|
+
endColumn: "B",
|
|
240
|
+
startRow: "3",
|
|
241
|
+
endRow: "3",
|
|
242
|
+
})).toBe("B3");
|
|
243
|
+
});
|
|
244
|
+
it("should create a column range address", () => {
|
|
245
|
+
expect(composeAddress({
|
|
246
|
+
startColumn: "A",
|
|
247
|
+
endColumn: "C",
|
|
248
|
+
startRow: "1",
|
|
249
|
+
endRow: "1048576",
|
|
250
|
+
})).toBe("A:C");
|
|
251
|
+
});
|
|
252
|
+
it("should create a row range address", () => {
|
|
253
|
+
expect(composeAddress({
|
|
254
|
+
startColumn: "A",
|
|
255
|
+
endColumn: "XFD",
|
|
256
|
+
startRow: "1",
|
|
257
|
+
endRow: "10",
|
|
258
|
+
})).toBe("1:10");
|
|
259
|
+
});
|
|
260
|
+
it("should create a cell range address", () => {
|
|
261
|
+
expect(composeAddress({
|
|
262
|
+
startColumn: "A",
|
|
263
|
+
endColumn: "C",
|
|
264
|
+
startRow: "1",
|
|
265
|
+
endRow: "5",
|
|
266
|
+
})).toBe("A1:C5");
|
|
267
|
+
});
|
|
268
|
+
it("should throw an error for invalid address components", () => {
|
|
269
|
+
expect(() => composeAddress({
|
|
270
|
+
startColumn: "C",
|
|
271
|
+
endColumn: "A",
|
|
272
|
+
startRow: "5",
|
|
273
|
+
endRow: "1",
|
|
274
|
+
})).toThrow(InvalidArgumentError);
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
describe("isAddressOverlapping", () => {
|
|
278
|
+
it("should return true for overlapping cell ranges", () => {
|
|
279
|
+
expect(isAddressOverlapping("A1:C3", "B2:D4")).toBe(true);
|
|
280
|
+
expect(isAddressOverlapping("A1:B2", "A1:B2")).toBe(true); // Exact overlap
|
|
281
|
+
expect(isAddressOverlapping("A1:D4", "B2:C3")).toBe(true); // Nested overlap
|
|
282
|
+
});
|
|
283
|
+
it("should return false for non-overlapping cell ranges", () => {
|
|
284
|
+
expect(isAddressOverlapping("A1:B2", "C3:D4")).toBe(false);
|
|
285
|
+
expect(isAddressOverlapping("A1:A1", "B1:B1")).toBe(false);
|
|
286
|
+
expect(isAddressOverlapping("A1:A10", "B11:B20")).toBe(false);
|
|
287
|
+
});
|
|
288
|
+
it("should return true for overlapping row ranges", () => {
|
|
289
|
+
expect(isAddressOverlapping("1:5", "3:7")).toBe(true);
|
|
290
|
+
expect(isAddressOverlapping("1:10", "5:15")).toBe(true);
|
|
291
|
+
});
|
|
292
|
+
it("should return false for non-overlapping row ranges", () => {
|
|
293
|
+
expect(isAddressOverlapping("1:5", "6:10")).toBe(false);
|
|
294
|
+
expect(isAddressOverlapping("1:1", "2:2")).toBe(false);
|
|
295
|
+
});
|
|
296
|
+
it("should return true for overlapping column ranges", () => {
|
|
297
|
+
expect(isAddressOverlapping("A:C", "B:D")).toBe(true);
|
|
298
|
+
expect(isAddressOverlapping("A:Z", "M:N")).toBe(true);
|
|
299
|
+
});
|
|
300
|
+
it("should return false for non-overlapping column ranges", () => {
|
|
301
|
+
expect(isAddressOverlapping("A:C", "D:F")).toBe(false);
|
|
302
|
+
expect(isAddressOverlapping("A:A", "B:B")).toBe(false);
|
|
303
|
+
});
|
|
304
|
+
it("should handle single cell addresses", () => {
|
|
305
|
+
expect(isAddressOverlapping("A1", "A1")).toBe(true); // Exact match
|
|
306
|
+
expect(isAddressOverlapping("A1", "B2")).toBe(false); // No overlap
|
|
307
|
+
expect(isAddressOverlapping("A1", "A2")).toBe(false); // Different rows
|
|
308
|
+
expect(isAddressOverlapping("A1", "B1")).toBe(false); // Different columns
|
|
309
|
+
});
|
|
310
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ColumnAddress, RowAddress } from "../models/Address.ts";
|
|
2
|
+
import type { ColumnOffset } from "../models/ColumnOffset.ts";
|
|
3
|
+
import type { RowOffset } from "../models/RowOffset.ts";
|
|
4
|
+
export declare function columnAddressToOffset(column: ColumnAddress): ColumnOffset;
|
|
5
|
+
export declare function offsetToColumnAddress(offset: ColumnOffset): ColumnAddress;
|
|
6
|
+
export declare function rowAddressToOffset(row: RowAddress): RowOffset;
|
|
7
|
+
export declare function offsetToRowAddress(offset: RowOffset): RowAddress;
|
|
8
|
+
//# sourceMappingURL=addressOffset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addressOffset.d.ts","sourceRoot":"","sources":["../../src/services/addressOffset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,aAAa,GAAG,YAAY,CAMzE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,GAAG,aAAa,CASzE;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,UAAU,GAAG,SAAS,CAE7D;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU,CAEhE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function columnAddressToOffset(column) {
|
|
2
|
+
let offset = 0;
|
|
3
|
+
for (let i = 0; i < column.length; i++) {
|
|
4
|
+
offset = offset * 26 + (column.charCodeAt(i) - 65 + 1);
|
|
5
|
+
}
|
|
6
|
+
return (offset - 1);
|
|
7
|
+
}
|
|
8
|
+
export function offsetToColumnAddress(offset) {
|
|
9
|
+
let result = "";
|
|
10
|
+
let currentOffset = offset + 1;
|
|
11
|
+
while (currentOffset > 0) {
|
|
12
|
+
currentOffset -= 1;
|
|
13
|
+
result = String.fromCharCode((currentOffset % 26) + 65) + result;
|
|
14
|
+
currentOffset = Math.floor(currentOffset / 26);
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
export function rowAddressToOffset(row) {
|
|
19
|
+
return (Number.parseInt(row, 10) - 1);
|
|
20
|
+
}
|
|
21
|
+
export function offsetToRowAddress(offset) {
|
|
22
|
+
return (offset + 1).toString();
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addressOffset.test.d.ts","sourceRoot":"","sources":["../../src/services/addressOffset.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { columnAddressToOffset, offsetToColumnAddress, offsetToRowAddress, rowAddressToOffset } from "./addressOffset.js";
|
|
3
|
+
describe("columnAddressToOffset", () => {
|
|
4
|
+
it("should convert column address to offset", () => {
|
|
5
|
+
expect(columnAddressToOffset("A")).toBe(0);
|
|
6
|
+
expect(columnAddressToOffset("B")).toBe(1);
|
|
7
|
+
expect(columnAddressToOffset("Z")).toBe(25);
|
|
8
|
+
expect(columnAddressToOffset("AA")).toBe(26);
|
|
9
|
+
expect(columnAddressToOffset("AB")).toBe(27);
|
|
10
|
+
expect(columnAddressToOffset("AZ")).toBe(51);
|
|
11
|
+
expect(columnAddressToOffset("BA")).toBe(52);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
describe("offsetToColumnAddress", () => {
|
|
15
|
+
it("should convert offset to column address", () => {
|
|
16
|
+
expect(offsetToColumnAddress(0)).toBe("A");
|
|
17
|
+
expect(offsetToColumnAddress(1)).toBe("B");
|
|
18
|
+
expect(offsetToColumnAddress(25)).toBe("Z");
|
|
19
|
+
expect(offsetToColumnAddress(26)).toBe("AA");
|
|
20
|
+
expect(offsetToColumnAddress(27)).toBe("AB");
|
|
21
|
+
expect(offsetToColumnAddress(51)).toBe("AZ");
|
|
22
|
+
expect(offsetToColumnAddress(52)).toBe("BA");
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe("rowAddressToOffset", () => {
|
|
26
|
+
it("should convert row address to offset", () => {
|
|
27
|
+
expect(rowAddressToOffset("1")).toBe(0);
|
|
28
|
+
expect(rowAddressToOffset("2")).toBe(1);
|
|
29
|
+
expect(rowAddressToOffset("10")).toBe(9);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe("offsetToRowAddress", () => {
|
|
33
|
+
it("should convert offset to row address", () => {
|
|
34
|
+
expect(offsetToRowAddress(0)).toBe("1");
|
|
35
|
+
expect(offsetToRowAddress(1)).toBe("2");
|
|
36
|
+
expect(offsetToRowAddress(9)).toBe("10");
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteDriveItemWithRetry.d.ts","sourceRoot":"","sources":["../../src/tasks/deleteDriveItemWithRetry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAI9D,8EAA8E;AAC9E,wBAA8B,wBAAwB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"deleteDriveItemWithRetry.d.ts","sourceRoot":"","sources":["../../src/tasks/deleteDriveItemWithRetry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAI9D,8EAA8E;AAC9E,wBAA8B,wBAAwB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAahG"}
|
|
@@ -3,7 +3,5 @@ import type { WorkbookRangeRef } from "../models/WorkbookRangeRef.ts";
|
|
|
3
3
|
export default function getRangeLastUsedCell(rangeRef: WorkbookRangeRef): Promise<{
|
|
4
4
|
value: string | number | boolean | null;
|
|
5
5
|
address: string;
|
|
6
|
-
rowIndex: number;
|
|
7
|
-
columnIndex: number;
|
|
8
6
|
} | null>;
|
|
9
7
|
//# sourceMappingURL=getRangeLastUsedCell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRangeLastUsedCell.d.ts","sourceRoot":"","sources":["../../src/tasks/getRangeLastUsedCell.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAItE,0EAA0E;AAC1E,wBAA8B,oBAAoB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"getRangeLastUsedCell.d.ts","sourceRoot":"","sources":["../../src/tasks/getRangeLastUsedCell.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAItE,0EAA0E;AAC1E,wBAA8B,oBAAoB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAyC3J"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ProtocolError from "../errors/ProtocolError.js";
|
|
2
2
|
import getWorkbookWorksheetRange from "../operations/workbookRange/getWorkbookWorksheetRange.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getFirstCellAddress, offsetAddress } from "../services/addressManipulation.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,12 +25,11 @@ export default async function getRangeLastUsedCell(rangeRef) {
|
|
|
25
25
|
throw new ProtocolError("Cell missing");
|
|
26
26
|
}
|
|
27
27
|
if (cell !== null && cell !== "") {
|
|
28
|
-
const
|
|
28
|
+
const firstCellAddress = getFirstCellAddress(rangeRef.address);
|
|
29
|
+
const lastUsedCellAddress = offsetAddress(firstCellAddress, columnIndex, rowIndex);
|
|
29
30
|
return {
|
|
30
31
|
value: cell,
|
|
31
|
-
address,
|
|
32
|
-
rowIndex: rowIndex,
|
|
33
|
-
columnIndex: columnIndex,
|
|
32
|
+
address: lastUsedCellAddress,
|
|
34
33
|
};
|
|
35
34
|
}
|
|
36
35
|
}
|
|
@@ -31,8 +31,6 @@ describe("getRangeLastUsedCell", () => {
|
|
|
31
31
|
}
|
|
32
32
|
expect(result.value).toBe(4);
|
|
33
33
|
expect(result.address).toBe("B2");
|
|
34
|
-
expect(result.rowIndex).toBe(1);
|
|
35
|
-
expect(result.columnIndex).toBe(1);
|
|
36
34
|
}
|
|
37
35
|
finally {
|
|
38
36
|
await deleteDriveItemWithRetry(workbook);
|
|
@@ -58,8 +56,6 @@ describe("getRangeLastUsedCell", () => {
|
|
|
58
56
|
}
|
|
59
57
|
expect(result.value).toBe(3);
|
|
60
58
|
expect(result.address).toBe("A2");
|
|
61
|
-
expect(result.rowIndex).toBe(1);
|
|
62
|
-
expect(result.columnIndex).toBe(0);
|
|
63
59
|
}
|
|
64
60
|
finally {
|
|
65
61
|
await deleteDriveItemWithRetry(workbook);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setWorkbookTableBodyVisibleRows.d.ts","sourceRoot":"","sources":["../../src/tasks/setWorkbookTableBodyVisibleRows.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setWorkbookTableBodyVisibleRows.d.ts","sourceRoot":"","sources":["../../src/tasks/setWorkbookTableBodyVisibleRows.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAQtE,oLAAoL;AACpL,wBAAsB,+BAA+B,CAAC,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA6BnH"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import InvalidArgumentError from "../errors/InvalidArgumentError.js";
|
|
2
|
-
import NeverError from "../errors/NeverError.js";
|
|
3
2
|
import getWorkbookWorksheetRange from "../operations/workbookRange/getWorkbookWorksheetRange.js";
|
|
4
3
|
import insertWorkbookCells from "../operations/workbookRange/insertWorkbookCells.js";
|
|
5
4
|
import updateWorkbookRange from "../operations/workbookRange/updateWorkbookRange.js";
|
|
6
5
|
import getWorkbookTableBodyRange from "../operations/workbookTable/getWorkbookTableBodyRange.js";
|
|
7
|
-
import {
|
|
6
|
+
import { getFirstRowAddress, incrementRowAddress, isAddressOverlapping } from "../services/addressManipulation.js";
|
|
8
7
|
import { createWorkbookRangeRef } from "../services/workbookRange.js";
|
|
9
8
|
/** 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
9
|
export async function setWorkbookTableBodyVisibleRows(tableRef, values) {
|
|
@@ -12,27 +11,23 @@ export async function setWorkbookTableBodyVisibleRows(tableRef, values) {
|
|
|
12
11
|
if (values.some((row) => row.length !== visibleRange.columnCount)) {
|
|
13
12
|
throw new InvalidArgumentError(`Invalid number of columns in input values. Expected all rows to have ${visibleRange.columnCount}.`);
|
|
14
13
|
}
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
if (endColumnIndex - startColumnIndex + 1 !== visibleRange.columnCount) {
|
|
18
|
-
throw new NeverError("Insane address");
|
|
19
|
-
}
|
|
20
|
-
let currentRowIndex = startRowIndex;
|
|
14
|
+
const dstFirstRowAddress = getFirstRowAddress(visibleRange.address);
|
|
15
|
+
let dstCurrentRowAddress = dstFirstRowAddress;
|
|
21
16
|
for (const srcRowValues of values) {
|
|
22
17
|
let dstRowRef;
|
|
23
18
|
let dstRow;
|
|
24
19
|
let dstRowHidden = false;
|
|
25
20
|
do {
|
|
26
|
-
dstRowRef = createWorkbookRangeRef(tableRef,
|
|
27
|
-
if (
|
|
28
|
-
await insertWorkbookCells(dstRowRef, dstRowRef.address, "Down");
|
|
29
|
-
dstRowHidden = false;
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
21
|
+
dstRowRef = createWorkbookRangeRef(tableRef, dstCurrentRowAddress);
|
|
22
|
+
if (isAddressOverlapping(dstCurrentRowAddress, visibleRange.address)) {
|
|
32
23
|
dstRow = await getWorkbookWorksheetRange(dstRowRef);
|
|
33
24
|
dstRowHidden = dstRow.rowHidden ?? false;
|
|
34
25
|
}
|
|
35
|
-
|
|
26
|
+
else {
|
|
27
|
+
await insertWorkbookCells(dstRowRef, dstRowRef.address, "Down");
|
|
28
|
+
dstRowHidden = false;
|
|
29
|
+
}
|
|
30
|
+
dstCurrentRowAddress = incrementRowAddress(dstCurrentRowAddress);
|
|
36
31
|
} while (dstRowHidden);
|
|
37
32
|
await updateWorkbookRange(dstRowRef, { values: [srcRowValues] });
|
|
38
33
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "microsoft-graph",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Microsoft GraphAPI SDK for NodeJS",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -85,6 +85,10 @@
|
|
|
85
85
|
"import": "./dist/errors/RequestFailedError.js",
|
|
86
86
|
"types": "./dist/errors/RequestFailedError.d.ts"
|
|
87
87
|
},
|
|
88
|
+
"./errors/UnsupportedAddressTypeError": {
|
|
89
|
+
"import": "./dist/errors/UnsupportedAddressTypeError.js",
|
|
90
|
+
"types": "./dist/errors/UnsupportedAddressTypeError.d.ts"
|
|
91
|
+
},
|
|
88
92
|
"./graphApi": {
|
|
89
93
|
"import": "./dist/graphApi.js",
|
|
90
94
|
"types": "./dist/graphApi.d.ts"
|
|
@@ -121,6 +125,10 @@
|
|
|
121
125
|
"import": "./dist/models/ColumnIndex.js",
|
|
122
126
|
"types": "./dist/models/ColumnIndex.d.ts"
|
|
123
127
|
},
|
|
128
|
+
"./models/ColumnOffset": {
|
|
129
|
+
"import": "./dist/models/ColumnOffset.js",
|
|
130
|
+
"types": "./dist/models/ColumnOffset.d.ts"
|
|
131
|
+
},
|
|
124
132
|
"./models/Context": {
|
|
125
133
|
"import": "./dist/models/Context.js",
|
|
126
134
|
"types": "./dist/models/Context.d.ts"
|
|
@@ -181,6 +189,10 @@
|
|
|
181
189
|
"import": "./dist/models/RowIndex.js",
|
|
182
190
|
"types": "./dist/models/RowIndex.d.ts"
|
|
183
191
|
},
|
|
192
|
+
"./models/RowOffset": {
|
|
193
|
+
"import": "./dist/models/RowOffset.js",
|
|
194
|
+
"types": "./dist/models/RowOffset.d.ts"
|
|
195
|
+
},
|
|
184
196
|
"./models/Scope": {
|
|
185
197
|
"import": "./dist/models/Scope.js",
|
|
186
198
|
"types": "./dist/models/Scope.d.ts"
|
|
@@ -413,6 +425,14 @@
|
|
|
413
425
|
"import": "./dist/services/address.js",
|
|
414
426
|
"types": "./dist/services/address.d.ts"
|
|
415
427
|
},
|
|
428
|
+
"./services/addressManipulation": {
|
|
429
|
+
"import": "./dist/services/addressManipulation.js",
|
|
430
|
+
"types": "./dist/services/addressManipulation.d.ts"
|
|
431
|
+
},
|
|
432
|
+
"./services/addressOffset": {
|
|
433
|
+
"import": "./dist/services/addressOffset.js",
|
|
434
|
+
"types": "./dist/services/addressOffset.d.ts"
|
|
435
|
+
},
|
|
416
436
|
"./services/context": {
|
|
417
437
|
"import": "./dist/services/context.js",
|
|
418
438
|
"types": "./dist/services/context.d.ts"
|