microsoft-graph 2.7.0 → 2.7.2
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/BadTemplateError.js +4 -1
- package/dist/cjs/errors/ContextNotRegisteredError.js +4 -1
- package/dist/cjs/errors/EnvironmentVariableMissingError.js +4 -1
- package/dist/cjs/errors/InconsistentContextError.js +4 -1
- package/dist/cjs/errors/InvalidArgumentError.js +4 -1
- package/dist/cjs/errors/NeverError.js +4 -1
- package/dist/cjs/errors/NotFoundError.js +4 -1
- package/dist/cjs/errors/NotImplementedError.js +4 -1
- package/dist/cjs/errors/ProtocolError.js +4 -1
- package/dist/cjs/errors/RequestFailedError.js +4 -1
- package/dist/cjs/errors/UnsupportedAddressTypeError.js +4 -1
- package/dist/cjs/graphApi.js +52 -43
- package/dist/cjs/index.d.ts +0 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/models/AccessToken.js +2 -1
- package/dist/cjs/models/Address.js +2 -1
- package/dist/cjs/models/CellRangeValues.js +2 -1
- package/dist/cjs/models/CellValue.js +2 -1
- package/dist/cjs/models/ClientId.js +2 -1
- package/dist/cjs/models/ClientSecret.js +2 -1
- package/dist/cjs/models/ColumnOffset.js +2 -1
- package/dist/cjs/models/Context.js +2 -1
- package/dist/cjs/models/ContextId.js +2 -1
- package/dist/cjs/models/ContextRef.js +2 -1
- package/dist/cjs/models/DriveId.js +2 -1
- package/dist/cjs/models/DriveItemId.js +2 -1
- package/dist/cjs/models/DriveItemPath.js +2 -1
- package/dist/cjs/models/DriveItemRef.js +2 -1
- package/dist/cjs/models/DriveRef.js +2 -1
- package/dist/cjs/models/GraphOperation.js +2 -1
- package/dist/cjs/models/GraphOperationDefinition.js +2 -1
- package/dist/cjs/models/HostName.js +2 -1
- package/dist/cjs/models/HttpProxy.js +2 -1
- package/dist/cjs/models/RowOffset.js +2 -1
- package/dist/cjs/models/RowRangeValues.js +2 -1
- package/dist/cjs/models/Scope.js +2 -1
- package/dist/cjs/models/SiteId.js +2 -1
- package/dist/cjs/models/SiteName.js +2 -1
- package/dist/cjs/models/SiteRef.js +2 -1
- package/dist/cjs/models/TenantId.js +2 -1
- package/dist/cjs/models/WorkbookNamedRangeRef.js +2 -1
- package/dist/cjs/models/WorkbookRangeName.js +2 -1
- package/dist/cjs/models/WorkbookRangeRef.js +2 -1
- package/dist/cjs/models/WorkbookRef.js +2 -1
- package/dist/cjs/models/WorkbookSessionId.js +2 -1
- package/dist/cjs/models/WorkbookTableColumnRef.js +2 -1
- package/dist/cjs/models/WorkbookTableId.js +2 -1
- package/dist/cjs/models/WorkbookTableRef.js +2 -1
- package/dist/cjs/models/WorkbookWorksheetId.js +2 -1
- package/dist/cjs/models/WorkbookWorksheetName.js +2 -1
- package/dist/cjs/models/WorkbookWorksheetRef.js +2 -1
- package/dist/cjs/operations/drive/createFolder.js +10 -7
- package/dist/cjs/operations/drive/createFolder.test.js +25 -20
- package/dist/cjs/operations/drive/listDrives.js +10 -7
- package/dist/cjs/operations/drive/listDrives.test.js +13 -8
- package/dist/cjs/operations/driveItem/deleteDriveItem.js +8 -5
- package/dist/cjs/operations/driveItem/deleteDriveItem.test.js +20 -15
- package/dist/cjs/operations/driveItem/getDriveItem.js +8 -5
- package/dist/cjs/operations/driveItem/getDriveItem.test.js +22 -17
- package/dist/cjs/operations/driveItem/getDriveItemByPath.js +10 -7
- package/dist/cjs/operations/driveItem/getDriveItemByPath.test.js +24 -19
- package/dist/cjs/operations/driveItem/getDriveItemContent.js +18 -12
- package/dist/cjs/operations/driveItem/getDriveItemContent.test.js +31 -26
- package/dist/cjs/operations/driveItem/initiateCopyDriveItem.js +8 -5
- package/dist/cjs/operations/driveItem/initiateCopyDriveItem.test.js +26 -21
- package/dist/cjs/operations/driveItem/listDriveItems.js +10 -7
- package/dist/cjs/operations/driveItem/listDriveItems.test.js +22 -17
- package/dist/cjs/operations/site/getSite.js +8 -5
- package/dist/cjs/operations/site/getSite.test.js +14 -9
- package/dist/cjs/operations/site/getSiteByName.js +10 -7
- package/dist/cjs/operations/site/getSiteByName.test.js +16 -11
- package/dist/cjs/operations/site/listSites.js +10 -7
- package/dist/cjs/operations/site/listSites.test.js +14 -9
- package/dist/cjs/operations/site/searchSites.js +10 -7
- package/dist/cjs/operations/site/searchSites.test.js +18 -13
- package/dist/cjs/operations/user/userSendMail.js +11 -5
- package/dist/cjs/operations/workbook/calculateWorkbook.js +10 -6
- package/dist/cjs/operations/workbook/calculateWorkbook.test.js +34 -29
- package/dist/cjs/operations/workbook/createWorkbook.js +16 -10
- package/dist/cjs/operations/workbook/createWorkbook.test.js +18 -13
- package/dist/cjs/operations/workbook/deleteWorkbook.js +9 -3
- package/dist/cjs/operations/workbookRange/clearWorkbookRange.js +8 -5
- package/dist/cjs/operations/workbookRange/clearWorkbookRange.test.js +43 -38
- package/dist/cjs/operations/workbookRange/deleteWorkbookRange.js +8 -5
- package/dist/cjs/operations/workbookRange/deleteWorkbookRange.test.js +43 -38
- package/dist/cjs/operations/workbookRange/getWorkbookNamedRange.js +8 -5
- package/dist/cjs/operations/workbookRange/getWorkbookRangeFormat.js +8 -5
- package/dist/cjs/operations/workbookRange/getWorkbookRangeFormat.test.js +27 -22
- package/dist/cjs/operations/workbookRange/getWorkbookUsedRange.js +15 -9
- package/dist/cjs/operations/workbookRange/getWorkbookVisibleRange.js +8 -5
- package/dist/cjs/operations/workbookRange/getWorkbookVisibleRange.test.js +67 -62
- package/dist/cjs/operations/workbookRange/getWorkbookWorksheetRange.js +8 -5
- package/dist/cjs/operations/workbookRange/getWorkbookWorksheetRange.test.js +25 -20
- package/dist/cjs/operations/workbookRange/insertWorkbookCells.js +15 -9
- package/dist/cjs/operations/workbookRange/insertWorkbookCells.test.js +30 -25
- package/dist/cjs/operations/workbookRange/updateWorkbookNamedRange.js +8 -5
- package/dist/cjs/operations/workbookRange/updateWorkbookRange.js +8 -5
- package/dist/cjs/operations/workbookRange/updateWorkbookRange.test.js +41 -36
- package/dist/cjs/operations/workbookSession/closeWorkbookSession.js +13 -7
- package/dist/cjs/operations/workbookSession/createWorkbookSession.js +8 -5
- package/dist/cjs/operations/workbookSession/refreshWorkbookSession.js +13 -7
- package/dist/cjs/operations/workbookTable/applyWorkbookTableColulmnFilter.test.js +34 -29
- package/dist/cjs/operations/workbookTable/applyWorkbookTableColumnFilter.js +8 -5
- package/dist/cjs/operations/workbookTable/clearWorkbookTableFilters.js +8 -5
- package/dist/cjs/operations/workbookTable/clearWorkbookTableFilters.test.js +36 -31
- package/dist/cjs/operations/workbookTable/createWorkbookTable.js +10 -7
- package/dist/cjs/operations/workbookTable/createWorkbookTable.test.js +24 -19
- package/dist/cjs/operations/workbookTable/deleteWorkbookTable.js +8 -5
- package/dist/cjs/operations/workbookTable/deleteWorkbookTable.test.js +34 -29
- package/dist/cjs/operations/workbookTable/deleteWorkbookTablePreservingValues.js +8 -5
- package/dist/cjs/operations/workbookTable/deleteWorkbookTablePreservingValues.test.js +34 -29
- package/dist/cjs/operations/workbookTable/getWorkbookTable.js +8 -5
- package/dist/cjs/operations/workbookTable/getWorkbookTable.test.js +29 -24
- package/dist/cjs/operations/workbookTable/getWorkbookTableBodyRange.js +15 -9
- package/dist/cjs/operations/workbookTable/getWorkbookTableBodyRange.test.js +33 -28
- package/dist/cjs/operations/workbookTable/getWorkbookTableBodyVisibleRange.js +10 -7
- package/dist/cjs/operations/workbookTable/getWorkbookTableBodyVisibleRange.test.js +34 -29
- package/dist/cjs/operations/workbookTable/getWorkbookTableHeaderRange.js +15 -9
- package/dist/cjs/operations/workbookTable/getWorkbookTableHeaderRange.test.js +33 -28
- package/dist/cjs/operations/workbookTable/listWorkbookTableColumns.js +8 -5
- package/dist/cjs/operations/workbookTable/listWorkbookTableColumns.test.js +28 -23
- package/dist/cjs/operations/workbookTable/listWorkbookTableRows.js +8 -5
- package/dist/cjs/operations/workbookTable/listWorkbookTableRows.test.js +28 -23
- package/dist/cjs/operations/workbookTable/listWorkbookTables.js +10 -7
- package/dist/cjs/operations/workbookTable/listWorkbookTables.test.js +29 -24
- package/dist/cjs/operations/workbookWorksheet/createWorkbookWorksheet.js +10 -7
- package/dist/cjs/operations/workbookWorksheet/createWorkbookWorksheet.test.js +29 -24
- package/dist/cjs/operations/workbookWorksheet/deleteWorkbookWorksheet.js +8 -5
- package/dist/cjs/operations/workbookWorksheet/deleteWorkbookWorksheet.test.js +27 -22
- package/dist/cjs/operations/workbookWorksheet/getWorkbookWorksheetUsedRange.js +15 -9
- package/dist/cjs/operations/workbookWorksheet/getWorkbookWorksheetUsedRange.test.js +41 -36
- package/dist/cjs/operations/workbookWorksheet/getWorkbookWorksheetUsedVisibleRange.js +10 -7
- package/dist/cjs/operations/workbookWorksheet/getWorkbookWorksheetUsedVisibleRange.test.js +31 -26
- package/dist/cjs/operations/workbookWorksheet/listWorkbookWorksheets.js +15 -9
- package/dist/cjs/operations/workbookWorksheet/listWorkbookWorksheets.test.js +37 -32
- package/dist/cjs/operations/workbookWorksheet/updateWorkbookWorksheet.js +8 -5
- package/dist/cjs/operations/workbookWorksheet/updateWorkbookWorksheet.test.js +36 -31
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/services/accessToken.js +6 -3
- package/dist/cjs/services/addressManipulation.js +64 -41
- package/dist/cjs/services/addressManipulation.test.js +239 -234
- package/dist/cjs/services/addressOffset.js +10 -4
- package/dist/cjs/services/addressOffset.test.js +32 -30
- package/dist/cjs/services/context.js +20 -12
- package/dist/cjs/services/drive.js +22 -15
- package/dist/cjs/services/driveItem.js +21 -13
- package/dist/cjs/services/driveItem.test.js +13 -8
- package/dist/cjs/services/environmentVariable.js +11 -4
- package/dist/cjs/services/httpAgent.js +6 -3
- package/dist/cjs/services/httpStatus.js +8 -3
- package/dist/cjs/services/operationId.js +6 -2
- package/dist/cjs/services/random.js +6 -3
- package/dist/cjs/services/sharepointUrl.js +11 -5
- package/dist/cjs/services/sharepointUrl.test.js +7 -5
- package/dist/cjs/services/site.js +15 -8
- package/dist/cjs/services/sleep.js +4 -1
- package/dist/cjs/services/stringCaseConversion.js +4 -1
- package/dist/cjs/services/stringCaseConversion.test.js +13 -11
- package/dist/cjs/services/templatedPaths.js +13 -7
- package/dist/cjs/services/templatedPaths.test.js +29 -24
- package/dist/cjs/services/temporaryFiles.js +6 -3
- package/dist/cjs/services/workbookRange.js +4 -1
- package/dist/cjs/services/workbookTable.js +4 -1
- package/dist/cjs/services/workbookTableColumn.js +4 -1
- package/dist/cjs/services/workbookWorksheet.js +9 -4
- package/dist/cjs/tasks/createWorkbookAndStartSession.js +11 -5
- package/dist/cjs/tasks/deleteDriveItemWithRetry.js +12 -6
- package/dist/cjs/tasks/downloadDriveItemContent.js +11 -5
- package/dist/cjs/tasks/getRangeLastUsedCell.js +17 -11
- package/dist/cjs/tasks/getRangeLastUsedCell.test.js +56 -51
- package/dist/cjs/tasks/getWorkbookTableVisibleBody.js +11 -5
- package/dist/cjs/tasks/getWorkbookWorksheetByName.js +11 -5
- package/dist/cjs/tasks/iterateWorkbookRangeValues.js +22 -16
- package/dist/cjs/tasks/iterateWorkbookRangeValues.test.js +41 -36
- package/dist/cjs/tasks/safeDeleteWorkbook.js +11 -5
- package/dist/cjs/tasks/setColumnHidden.js +12 -6
- package/dist/cjs/tasks/setColumnHidden.test.js +46 -41
- package/dist/cjs/tasks/setRowHidden.js +12 -6
- package/dist/cjs/tasks/setRowHidden.test.js +46 -41
- package/dist/cjs/tasks/setWorkbookRangeValues.js +15 -9
- package/dist/cjs/tasks/setWorkbookRangeValues.test.js +29 -24
- package/dist/cjs/tasks/setWorkbookTableBodyVisibleRows.js +23 -17
- package/dist/cjs/tasks/setWorkbookTableBodyVisibleRows.test.js +50 -45
- package/dist/cjs/tasks/tryDeleteDriveItem.js +9 -3
- package/dist/esm/package.json +3 -0
- package/package.json +655 -2
- package/tsconfig.cjs.json +4 -3
- package/update-exports.ts +47 -13
|
@@ -1,44 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const vitest_1 = require("vitest");
|
|
7
|
+
const drive_ts_1 = require("../../services/drive.js");
|
|
8
|
+
const driveItem_ts_1 = require("../../services/driveItem.js");
|
|
9
|
+
const temporaryFiles_ts_1 = require("../../services/temporaryFiles.js");
|
|
10
|
+
const workbookWorksheet_ts_1 = require("../../services/workbookWorksheet.js");
|
|
11
|
+
const getWorkbookWorksheetByName_ts_1 = __importDefault(require("../../tasks/getWorkbookWorksheetByName.js"));
|
|
12
|
+
const tryDeleteDriveItem_ts_1 = __importDefault(require("../../tasks/tryDeleteDriveItem.js"));
|
|
13
|
+
const calculateWorkbook_ts_1 = __importDefault(require("../workbook/calculateWorkbook.js"));
|
|
14
|
+
const createWorkbook_ts_1 = __importDefault(require("../workbook/createWorkbook.js"));
|
|
15
|
+
const createWorkbookWorksheet_ts_1 = __importDefault(require("./createWorkbookWorksheet.js"));
|
|
16
|
+
const updateWorkbookWorksheet_ts_1 = __importDefault(require("./updateWorkbookWorksheet.js"));
|
|
17
|
+
(0, vitest_1.describe)("updateWorkbookWorksheet", () => {
|
|
18
|
+
(0, vitest_1.it)("can update the name of an existing worksheet", async () => {
|
|
19
|
+
const workbookName = (0, temporaryFiles_ts_1.generateTempFileName)("xlsx");
|
|
20
|
+
const workbookPath = (0, driveItem_ts_1.driveItemPath)(workbookName);
|
|
21
|
+
const workbook = await (0, createWorkbook_ts_1.default)((0, drive_ts_1.getDefaultDriveRef)(), workbookPath);
|
|
17
22
|
try {
|
|
18
|
-
const worksheetRef = createDefaultWorkbookWorksheetRef(workbook);
|
|
23
|
+
const worksheetRef = (0, workbookWorksheet_ts_1.createDefaultWorkbookWorksheetRef)(workbook);
|
|
19
24
|
const newName = "UpdatedSheet";
|
|
20
|
-
await
|
|
21
|
-
await
|
|
22
|
-
const updatedWorksheet = await
|
|
23
|
-
expect(updatedWorksheet.name).toBe(newName);
|
|
25
|
+
await (0, updateWorkbookWorksheet_ts_1.default)(worksheetRef, { name: newName });
|
|
26
|
+
await (0, calculateWorkbook_ts_1.default)(workbook);
|
|
27
|
+
const updatedWorksheet = await (0, getWorkbookWorksheetByName_ts_1.default)(workbook, newName);
|
|
28
|
+
(0, vitest_1.expect)(updatedWorksheet.name).toBe(newName);
|
|
24
29
|
}
|
|
25
30
|
finally {
|
|
26
|
-
await
|
|
31
|
+
await (0, tryDeleteDriveItem_ts_1.default)(workbook);
|
|
27
32
|
}
|
|
28
33
|
});
|
|
29
|
-
it("can update the visibility of an existing worksheet", async () => {
|
|
30
|
-
const workbookName = generateTempFileName("xlsx");
|
|
31
|
-
const workbookPath = driveItemPath(workbookName);
|
|
32
|
-
const workbook = await
|
|
34
|
+
(0, vitest_1.it)("can update the visibility of an existing worksheet", async () => {
|
|
35
|
+
const workbookName = (0, temporaryFiles_ts_1.generateTempFileName)("xlsx");
|
|
36
|
+
const workbookPath = (0, driveItem_ts_1.driveItemPath)(workbookName);
|
|
37
|
+
const workbook = await (0, createWorkbook_ts_1.default)((0, drive_ts_1.getDefaultDriveRef)(), workbookPath);
|
|
33
38
|
try {
|
|
34
39
|
const worksheetName = "Sheet2";
|
|
35
|
-
const worksheet = await
|
|
36
|
-
await
|
|
37
|
-
const updatedWorksheet = await
|
|
38
|
-
expect(updatedWorksheet.visibility).toBe("Hidden");
|
|
40
|
+
const worksheet = await (0, createWorkbookWorksheet_ts_1.default)(workbook); // Can't hide the single worksheet
|
|
41
|
+
await (0, updateWorkbookWorksheet_ts_1.default)(worksheet, { visibility: "Hidden" });
|
|
42
|
+
const updatedWorksheet = await (0, getWorkbookWorksheetByName_ts_1.default)(worksheet, worksheetName);
|
|
43
|
+
(0, vitest_1.expect)(updatedWorksheet.visibility).toBe("Hidden");
|
|
39
44
|
}
|
|
40
45
|
finally {
|
|
41
|
-
await
|
|
46
|
+
await (0, tryDeleteDriveItem_ts_1.default)(workbook);
|
|
42
47
|
}
|
|
43
48
|
});
|
|
44
49
|
});
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCurrentAccessToken = getCurrentAccessToken;
|
|
4
|
+
const identity_1 = require("@azure/identity");
|
|
2
5
|
const innerTokenCache = {};
|
|
3
6
|
/**
|
|
4
7
|
* Retrieves the current access token for a given client and scope.
|
|
@@ -9,11 +12,11 @@ const innerTokenCache = {};
|
|
|
9
12
|
* @param scope - The scope for which the token is requested.
|
|
10
13
|
* @returns A promise that resolves to the access token.
|
|
11
14
|
*/
|
|
12
|
-
|
|
15
|
+
async function getCurrentAccessToken(tenantId, clientId, clientSecret, scope) {
|
|
13
16
|
const cacheKey = createCacheKey(tenantId, clientId, scope);
|
|
14
17
|
let innerToken = innerTokenCache[cacheKey];
|
|
15
18
|
if (!innerToken || innerToken.expiresOnTimestamp < Date.now()) {
|
|
16
|
-
const credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
|
|
19
|
+
const credential = new identity_1.ClientSecretCredential(tenantId, clientId, clientSecret);
|
|
17
20
|
innerTokenCache[cacheKey] = innerToken = await credential.getToken(scope);
|
|
18
21
|
}
|
|
19
22
|
return innerToken.token;
|
|
@@ -1,6 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.decomposeAddress = decomposeAddress;
|
|
7
|
+
exports.composeAddress = composeAddress;
|
|
8
|
+
exports.getFirstCellAddress = getFirstCellAddress;
|
|
9
|
+
exports.getLastCellAddress = getLastCellAddress;
|
|
10
|
+
exports.getFirstRowAddress = getFirstRowAddress;
|
|
11
|
+
exports.getLastRowAddress = getLastRowAddress;
|
|
12
|
+
exports.getFirstColumnAddress = getFirstColumnAddress;
|
|
13
|
+
exports.getLastColumnAddress = getLastColumnAddress;
|
|
14
|
+
exports.offsetAddress = offsetAddress;
|
|
15
|
+
exports.incrementRowAddress = incrementRowAddress;
|
|
16
|
+
exports.decrementRowAddress = decrementRowAddress;
|
|
17
|
+
exports.isAddressOverlapping = isAddressOverlapping;
|
|
18
|
+
exports.isSingleRowAddress = isSingleRowAddress;
|
|
19
|
+
exports.isSingleColumnAddress = isSingleColumnAddress;
|
|
20
|
+
exports.isAllColumnsAddress = isAllColumnsAddress;
|
|
21
|
+
exports.isAllRowsAddress = isAllRowsAddress;
|
|
22
|
+
exports.countAddressRows = countAddressRows;
|
|
23
|
+
exports.countAddressColumns = countAddressColumns;
|
|
24
|
+
const InvalidArgumentError_ts_1 = __importDefault(require("../errors/InvalidArgumentError.js"));
|
|
25
|
+
const UnsupportedAddressTypeError_ts_1 = __importDefault(require("../errors/UnsupportedAddressTypeError.js"));
|
|
26
|
+
const addressOffset_ts_1 = require("./addressOffset.js");
|
|
4
27
|
const firstColumn = "A";
|
|
5
28
|
const lastColumn = "XFD";
|
|
6
29
|
const firstRow = "1";
|
|
@@ -12,10 +35,10 @@ const addressPattern = /^(?<sheet>[A-Za-z0-9_]+!)?(?:(?<startColumn>[A-Z]+)?(?<s
|
|
|
12
35
|
* @returns The decomposed address components.
|
|
13
36
|
* @throws InvalidArgumentError if the address format is invalid.
|
|
14
37
|
*/
|
|
15
|
-
|
|
38
|
+
function decomposeAddress(address) {
|
|
16
39
|
const match = address.match(addressPattern);
|
|
17
40
|
if (!match?.groups) {
|
|
18
|
-
throw new
|
|
41
|
+
throw new InvalidArgumentError_ts_1.default(`Invalid address format. Must match pattern '${addressPattern}'`);
|
|
19
42
|
}
|
|
20
43
|
const groups = match.groups;
|
|
21
44
|
return {
|
|
@@ -31,7 +54,7 @@ export function decomposeAddress(address) {
|
|
|
31
54
|
* @returns The composed address.
|
|
32
55
|
* @throws InvalidArgumentError if the components are invalid.
|
|
33
56
|
*/
|
|
34
|
-
|
|
57
|
+
function composeAddress(components) {
|
|
35
58
|
if (isSingleColumn(components) && isAllRows(components)) {
|
|
36
59
|
return composeColumnAddress(components.startColumn);
|
|
37
60
|
}
|
|
@@ -48,10 +71,10 @@ export function composeAddress(components) {
|
|
|
48
71
|
return composeCellAddress(components.startColumn, components.startRow);
|
|
49
72
|
}
|
|
50
73
|
if (components.startColumn > components.endColumn) {
|
|
51
|
-
throw new
|
|
74
|
+
throw new InvalidArgumentError_ts_1.default("Invalid address. End column is before start column.");
|
|
52
75
|
}
|
|
53
76
|
if (components.startRow > components.endRow) {
|
|
54
|
-
throw new
|
|
77
|
+
throw new InvalidArgumentError_ts_1.default("Invalid address. End row is before start row.");
|
|
55
78
|
}
|
|
56
79
|
return composeCellRangeAddress(components.startColumn, components.startRow, components.endColumn, components.endRow);
|
|
57
80
|
}
|
|
@@ -60,7 +83,7 @@ export function composeAddress(components) {
|
|
|
60
83
|
* @param address - The address to analyze.
|
|
61
84
|
* @returns The first cell address.
|
|
62
85
|
*/
|
|
63
|
-
|
|
86
|
+
function getFirstCellAddress(address) {
|
|
64
87
|
const components = decomposeAddress(address);
|
|
65
88
|
return composeCellAddress(components.startColumn, components.startRow);
|
|
66
89
|
}
|
|
@@ -69,7 +92,7 @@ export function getFirstCellAddress(address) {
|
|
|
69
92
|
* @param address - The address to analyze.
|
|
70
93
|
* @returns The last cell address.
|
|
71
94
|
*/
|
|
72
|
-
|
|
95
|
+
function getLastCellAddress(address) {
|
|
73
96
|
const components = decomposeAddress(address);
|
|
74
97
|
return composeCellAddress(components.endColumn, components.endRow);
|
|
75
98
|
}
|
|
@@ -78,7 +101,7 @@ export function getLastCellAddress(address) {
|
|
|
78
101
|
* @param address - The address to analyze.
|
|
79
102
|
* @returns The first row address.
|
|
80
103
|
*/
|
|
81
|
-
|
|
104
|
+
function getFirstRowAddress(address) {
|
|
82
105
|
const components = decomposeAddress(address);
|
|
83
106
|
return composeAddress({
|
|
84
107
|
startColumn: components.startColumn,
|
|
@@ -92,7 +115,7 @@ export function getFirstRowAddress(address) {
|
|
|
92
115
|
* @param address - The address to analyze.
|
|
93
116
|
* @returns The last row address.
|
|
94
117
|
*/
|
|
95
|
-
|
|
118
|
+
function getLastRowAddress(address) {
|
|
96
119
|
const components = decomposeAddress(address);
|
|
97
120
|
return composeAddress({
|
|
98
121
|
startColumn: components.startColumn,
|
|
@@ -106,7 +129,7 @@ export function getLastRowAddress(address) {
|
|
|
106
129
|
* @param address - The address to analyze.
|
|
107
130
|
* @returns The first column address.
|
|
108
131
|
*/
|
|
109
|
-
|
|
132
|
+
function getFirstColumnAddress(address) {
|
|
110
133
|
const components = decomposeAddress(address);
|
|
111
134
|
return composeAddress({
|
|
112
135
|
startColumn: components.startColumn,
|
|
@@ -120,7 +143,7 @@ export function getFirstColumnAddress(address) {
|
|
|
120
143
|
* @param address - The address to analyze.
|
|
121
144
|
* @returns The last column address.
|
|
122
145
|
*/
|
|
123
|
-
|
|
146
|
+
function getLastColumnAddress(address) {
|
|
124
147
|
const components = decomposeAddress(address);
|
|
125
148
|
return composeAddress({
|
|
126
149
|
startColumn: components.endColumn,
|
|
@@ -138,28 +161,28 @@ export function getLastColumnAddress(address) {
|
|
|
138
161
|
* @throws UnsupportedAddressTypeError if the address cannot be offset.
|
|
139
162
|
* @throws InvalidArgumentError if the offset is out of bounds.
|
|
140
163
|
*/
|
|
141
|
-
|
|
164
|
+
function offsetAddress(address, columnOffset, rowOffset) {
|
|
142
165
|
const components = decomposeAddress(address);
|
|
143
166
|
if (isAllRows(components) && rowOffset !== 0) {
|
|
144
|
-
throw new
|
|
167
|
+
throw new UnsupportedAddressTypeError_ts_1.default("All rows are selected. Cannot offset rows.");
|
|
145
168
|
}
|
|
146
169
|
if (isAllColumns(components) && columnOffset !== 0) {
|
|
147
|
-
throw new
|
|
170
|
+
throw new UnsupportedAddressTypeError_ts_1.default("All columns are selected. Cannot offset columns.");
|
|
148
171
|
}
|
|
149
|
-
const newStartRowIndex = rowAddressToOffset(components.startRow) + rowOffset;
|
|
150
|
-
const newEndRowIndex = rowAddressToOffset(components.endRow) + rowOffset;
|
|
151
|
-
if (newStartRowIndex < rowAddressToOffset(firstRow) || newEndRowIndex > rowAddressToOffset(lastRow)) {
|
|
152
|
-
throw new
|
|
172
|
+
const newStartRowIndex = (0, addressOffset_ts_1.rowAddressToOffset)(components.startRow) + rowOffset;
|
|
173
|
+
const newEndRowIndex = (0, addressOffset_ts_1.rowAddressToOffset)(components.endRow) + rowOffset;
|
|
174
|
+
if (newStartRowIndex < (0, addressOffset_ts_1.rowAddressToOffset)(firstRow) || newEndRowIndex > (0, addressOffset_ts_1.rowAddressToOffset)(lastRow)) {
|
|
175
|
+
throw new InvalidArgumentError_ts_1.default(`Row offset out of bounds: ${newStartRowIndex + 1} to ${newEndRowIndex + 1}`);
|
|
153
176
|
}
|
|
154
|
-
const newStartRow = offsetToRowAddress(newStartRowIndex);
|
|
155
|
-
const newEndRow = offsetToRowAddress(newEndRowIndex);
|
|
156
|
-
const newStartColumnIndex = columnAddressToOffset(components.startColumn) + columnOffset;
|
|
157
|
-
const newEndColumnIndex = columnAddressToOffset(components.endColumn) + columnOffset;
|
|
158
|
-
if (newStartColumnIndex < columnAddressToOffset(firstColumn) || newEndColumnIndex > columnAddressToOffset(lastColumn)) {
|
|
159
|
-
throw new
|
|
177
|
+
const newStartRow = (0, addressOffset_ts_1.offsetToRowAddress)(newStartRowIndex);
|
|
178
|
+
const newEndRow = (0, addressOffset_ts_1.offsetToRowAddress)(newEndRowIndex);
|
|
179
|
+
const newStartColumnIndex = (0, addressOffset_ts_1.columnAddressToOffset)(components.startColumn) + columnOffset;
|
|
180
|
+
const newEndColumnIndex = (0, addressOffset_ts_1.columnAddressToOffset)(components.endColumn) + columnOffset;
|
|
181
|
+
if (newStartColumnIndex < (0, addressOffset_ts_1.columnAddressToOffset)(firstColumn) || newEndColumnIndex > (0, addressOffset_ts_1.columnAddressToOffset)(lastColumn)) {
|
|
182
|
+
throw new InvalidArgumentError_ts_1.default(`Column offset out of bounds: ${newStartColumnIndex + 1} to ${newEndColumnIndex + 1}`);
|
|
160
183
|
}
|
|
161
|
-
const newStartColumn = offsetToColumnAddress(newStartColumnIndex);
|
|
162
|
-
const newEndColumn = offsetToColumnAddress(newEndColumnIndex);
|
|
184
|
+
const newStartColumn = (0, addressOffset_ts_1.offsetToColumnAddress)(newStartColumnIndex);
|
|
185
|
+
const newEndColumn = (0, addressOffset_ts_1.offsetToColumnAddress)(newEndColumnIndex);
|
|
163
186
|
return composeAddress({
|
|
164
187
|
startColumn: newStartColumn,
|
|
165
188
|
endColumn: newEndColumn,
|
|
@@ -172,7 +195,7 @@ export function offsetAddress(address, columnOffset, rowOffset) {
|
|
|
172
195
|
* @param address - The address to increment.
|
|
173
196
|
* @returns The incremented address.
|
|
174
197
|
*/
|
|
175
|
-
|
|
198
|
+
function incrementRowAddress(address) {
|
|
176
199
|
return offsetAddress(address, 0, +1);
|
|
177
200
|
}
|
|
178
201
|
/**
|
|
@@ -180,7 +203,7 @@ export function incrementRowAddress(address) {
|
|
|
180
203
|
* @param address - The address to decrement.
|
|
181
204
|
* @returns The decremented address.
|
|
182
205
|
*/
|
|
183
|
-
|
|
206
|
+
function decrementRowAddress(address) {
|
|
184
207
|
return offsetAddress(address, 0, -1);
|
|
185
208
|
}
|
|
186
209
|
/**
|
|
@@ -189,17 +212,17 @@ export function decrementRowAddress(address) {
|
|
|
189
212
|
* @param address2 - The second address.
|
|
190
213
|
* @returns True if the addresses overlap, otherwise false.
|
|
191
214
|
*/
|
|
192
|
-
|
|
215
|
+
function isAddressOverlapping(address1, address2) {
|
|
193
216
|
const components1 = decomposeAddress(address1);
|
|
194
217
|
const components2 = decomposeAddress(address2);
|
|
195
|
-
return components1.startColumn <= components2.endColumn && components1.endColumn >= components2.startColumn && rowAddressToOffset(components1.startRow) <= rowAddressToOffset(components2.endRow) && rowAddressToOffset(components1.endRow) >= rowAddressToOffset(components2.startRow);
|
|
218
|
+
return components1.startColumn <= components2.endColumn && components1.endColumn >= components2.startColumn && (0, addressOffset_ts_1.rowAddressToOffset)(components1.startRow) <= (0, addressOffset_ts_1.rowAddressToOffset)(components2.endRow) && (0, addressOffset_ts_1.rowAddressToOffset)(components1.endRow) >= (0, addressOffset_ts_1.rowAddressToOffset)(components2.startRow);
|
|
196
219
|
}
|
|
197
220
|
/**
|
|
198
221
|
* Checks if the address components represent a single row.
|
|
199
222
|
* @param address - The address to check.
|
|
200
223
|
* @returns True if the components represent a single riw, otherwise false.
|
|
201
224
|
*/
|
|
202
|
-
|
|
225
|
+
function isSingleRowAddress(address) {
|
|
203
226
|
const components = decomposeAddress(address);
|
|
204
227
|
return isSingleRow(components);
|
|
205
228
|
}
|
|
@@ -208,7 +231,7 @@ export function isSingleRowAddress(address) {
|
|
|
208
231
|
* @param address - The address to check.
|
|
209
232
|
* @returns True if the components represent single columns, otherwise false.
|
|
210
233
|
*/
|
|
211
|
-
|
|
234
|
+
function isSingleColumnAddress(address) {
|
|
212
235
|
const components = decomposeAddress(address);
|
|
213
236
|
return isSingleColumn(components);
|
|
214
237
|
}
|
|
@@ -217,7 +240,7 @@ export function isSingleColumnAddress(address) {
|
|
|
217
240
|
* @param address - The address to check.
|
|
218
241
|
* @returns True if the components represent all columns, otherwise false.
|
|
219
242
|
*/
|
|
220
|
-
|
|
243
|
+
function isAllColumnsAddress(address) {
|
|
221
244
|
const components = decomposeAddress(address);
|
|
222
245
|
return isAllColumns(components);
|
|
223
246
|
}
|
|
@@ -226,7 +249,7 @@ export function isAllColumnsAddress(address) {
|
|
|
226
249
|
* @param address - The address to check.
|
|
227
250
|
* @returns True if the components represent all rows, otherwise false.
|
|
228
251
|
*/
|
|
229
|
-
|
|
252
|
+
function isAllRowsAddress(address) {
|
|
230
253
|
const components = decomposeAddress(address);
|
|
231
254
|
return isAllRows(components);
|
|
232
255
|
}
|
|
@@ -235,18 +258,18 @@ export function isAllRowsAddress(address) {
|
|
|
235
258
|
* @param address - The address to analyze.
|
|
236
259
|
* @returns The number of rows in the address.
|
|
237
260
|
*/
|
|
238
|
-
|
|
261
|
+
function countAddressRows(address) {
|
|
239
262
|
const components = decomposeAddress(address);
|
|
240
|
-
return rowAddressToOffset(components.endRow) - rowAddressToOffset(components.startRow) + 1;
|
|
263
|
+
return (0, addressOffset_ts_1.rowAddressToOffset)(components.endRow) - (0, addressOffset_ts_1.rowAddressToOffset)(components.startRow) + 1;
|
|
241
264
|
}
|
|
242
265
|
/**
|
|
243
266
|
* Counts the number of columns in a given address.
|
|
244
267
|
* @param address - The address to analyze.
|
|
245
268
|
* @returns The number of columns in the address.
|
|
246
269
|
*/
|
|
247
|
-
|
|
270
|
+
function countAddressColumns(address) {
|
|
248
271
|
const components = decomposeAddress(address);
|
|
249
|
-
return columnAddressToOffset(components.endColumn) - columnAddressToOffset(components.startColumn) + 1;
|
|
272
|
+
return (0, addressOffset_ts_1.columnAddressToOffset)(components.endColumn) - (0, addressOffset_ts_1.columnAddressToOffset)(components.startColumn) + 1;
|
|
250
273
|
}
|
|
251
274
|
function isSingleRow(components) {
|
|
252
275
|
return components.startRow === components.endRow;
|