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,9 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.columnAddressToOffset = columnAddressToOffset;
|
|
4
|
+
exports.offsetToColumnAddress = offsetToColumnAddress;
|
|
5
|
+
exports.rowAddressToOffset = rowAddressToOffset;
|
|
6
|
+
exports.offsetToRowAddress = offsetToRowAddress;
|
|
1
7
|
/**
|
|
2
8
|
* Converts a column address (e.g., "A") to a zero-based column offset.
|
|
3
9
|
* @param column - The column address.
|
|
4
10
|
* @returns The zero-based column offset.
|
|
5
11
|
*/
|
|
6
|
-
|
|
12
|
+
function columnAddressToOffset(column) {
|
|
7
13
|
let offset = 0;
|
|
8
14
|
for (let i = 0; i < column.length; i++) {
|
|
9
15
|
offset = offset * 26 + (column.charCodeAt(i) - 65 + 1);
|
|
@@ -15,7 +21,7 @@ export function columnAddressToOffset(column) {
|
|
|
15
21
|
* @param offset - The zero-based column offset.
|
|
16
22
|
* @returns The column address.
|
|
17
23
|
*/
|
|
18
|
-
|
|
24
|
+
function offsetToColumnAddress(offset) {
|
|
19
25
|
let result = "";
|
|
20
26
|
let currentOffset = offset + 1;
|
|
21
27
|
while (currentOffset > 0) {
|
|
@@ -30,7 +36,7 @@ export function offsetToColumnAddress(offset) {
|
|
|
30
36
|
* @param row - The row address.
|
|
31
37
|
* @returns The zero-based row offset.
|
|
32
38
|
*/
|
|
33
|
-
|
|
39
|
+
function rowAddressToOffset(row) {
|
|
34
40
|
return (Number.parseInt(row, 10) - 1);
|
|
35
41
|
}
|
|
36
42
|
/**
|
|
@@ -38,6 +44,6 @@ export function rowAddressToOffset(row) {
|
|
|
38
44
|
* @param offset - The zero-based row offset.
|
|
39
45
|
* @returns The row address.
|
|
40
46
|
*/
|
|
41
|
-
|
|
47
|
+
function offsetToRowAddress(offset) {
|
|
42
48
|
return (offset + 1).toString();
|
|
43
49
|
}
|
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
expect(columnAddressToOffset("
|
|
8
|
-
expect(columnAddressToOffset("
|
|
9
|
-
expect(columnAddressToOffset("
|
|
10
|
-
expect(columnAddressToOffset("
|
|
11
|
-
expect(columnAddressToOffset("
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const addressOffset_ts_1 = require("./addressOffset.js");
|
|
5
|
+
(0, vitest_1.describe)("columnAddressToOffset", () => {
|
|
6
|
+
(0, vitest_1.it)("should convert column address to offset", () => {
|
|
7
|
+
(0, vitest_1.expect)((0, addressOffset_ts_1.columnAddressToOffset)("A")).toBe(0);
|
|
8
|
+
(0, vitest_1.expect)((0, addressOffset_ts_1.columnAddressToOffset)("B")).toBe(1);
|
|
9
|
+
(0, vitest_1.expect)((0, addressOffset_ts_1.columnAddressToOffset)("Z")).toBe(25);
|
|
10
|
+
(0, vitest_1.expect)((0, addressOffset_ts_1.columnAddressToOffset)("AA")).toBe(26);
|
|
11
|
+
(0, vitest_1.expect)((0, addressOffset_ts_1.columnAddressToOffset)("AB")).toBe(27);
|
|
12
|
+
(0, vitest_1.expect)((0, addressOffset_ts_1.columnAddressToOffset)("AZ")).toBe(51);
|
|
13
|
+
(0, vitest_1.expect)((0, addressOffset_ts_1.columnAddressToOffset)("BA")).toBe(52);
|
|
12
14
|
});
|
|
13
15
|
});
|
|
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");
|
|
16
|
+
(0, vitest_1.describe)("offsetToColumnAddress", () => {
|
|
17
|
+
(0, vitest_1.it)("should convert offset to column address", () => {
|
|
18
|
+
(0, vitest_1.expect)((0, addressOffset_ts_1.offsetToColumnAddress)(0)).toBe("A");
|
|
19
|
+
(0, vitest_1.expect)((0, addressOffset_ts_1.offsetToColumnAddress)(1)).toBe("B");
|
|
20
|
+
(0, vitest_1.expect)((0, addressOffset_ts_1.offsetToColumnAddress)(25)).toBe("Z");
|
|
21
|
+
(0, vitest_1.expect)((0, addressOffset_ts_1.offsetToColumnAddress)(26)).toBe("AA");
|
|
22
|
+
(0, vitest_1.expect)((0, addressOffset_ts_1.offsetToColumnAddress)(27)).toBe("AB");
|
|
23
|
+
(0, vitest_1.expect)((0, addressOffset_ts_1.offsetToColumnAddress)(51)).toBe("AZ");
|
|
24
|
+
(0, vitest_1.expect)((0, addressOffset_ts_1.offsetToColumnAddress)(52)).toBe("BA");
|
|
23
25
|
});
|
|
24
26
|
});
|
|
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);
|
|
27
|
+
(0, vitest_1.describe)("rowAddressToOffset", () => {
|
|
28
|
+
(0, vitest_1.it)("should convert row address to offset", () => {
|
|
29
|
+
(0, vitest_1.expect)((0, addressOffset_ts_1.rowAddressToOffset)("1")).toBe(0);
|
|
30
|
+
(0, vitest_1.expect)((0, addressOffset_ts_1.rowAddressToOffset)("2")).toBe(1);
|
|
31
|
+
(0, vitest_1.expect)((0, addressOffset_ts_1.rowAddressToOffset)("10")).toBe(9);
|
|
30
32
|
});
|
|
31
33
|
});
|
|
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");
|
|
34
|
+
(0, vitest_1.describe)("offsetToRowAddress", () => {
|
|
35
|
+
(0, vitest_1.it)("should convert offset to row address", () => {
|
|
36
|
+
(0, vitest_1.expect)((0, addressOffset_ts_1.offsetToRowAddress)(0)).toBe("1");
|
|
37
|
+
(0, vitest_1.expect)((0, addressOffset_ts_1.offsetToRowAddress)(1)).toBe("2");
|
|
38
|
+
(0, vitest_1.expect)((0, addressOffset_ts_1.offsetToRowAddress)(9)).toBe("10");
|
|
37
39
|
});
|
|
38
40
|
});
|
|
@@ -1,6 +1,14 @@
|
|
|
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.register = register;
|
|
7
|
+
exports.getContext = getContext;
|
|
8
|
+
exports.getDefaultContextRef = getDefaultContextRef;
|
|
9
|
+
const ContextNotRegisteredError_ts_1 = __importDefault(require("../errors/ContextNotRegisteredError.js"));
|
|
10
|
+
const environmentVariable_ts_1 = require("./environmentVariable.js");
|
|
11
|
+
const random_ts_1 = require("./random.js");
|
|
4
12
|
const contexts = {};
|
|
5
13
|
/**
|
|
6
14
|
* Registers a tenant+client so that its secret can be used later.
|
|
@@ -10,7 +18,7 @@ const contexts = {};
|
|
|
10
18
|
* @param httpProxy - Optional HTTP proxy configuration.
|
|
11
19
|
* @returns A reference to the registered context.
|
|
12
20
|
*/
|
|
13
|
-
|
|
21
|
+
function register(tenantId, clientId, clientSecret, httpProxy) {
|
|
14
22
|
const contextId = generateContextId();
|
|
15
23
|
const context = {
|
|
16
24
|
tenantId,
|
|
@@ -28,15 +36,15 @@ export function register(tenantId, clientId, clientSecret, httpProxy) {
|
|
|
28
36
|
* @returns The context associated with the given ID.
|
|
29
37
|
* @throws ContextNotRegisteredError if the context ID is not registered.
|
|
30
38
|
*/
|
|
31
|
-
|
|
39
|
+
function getContext(contextId) {
|
|
32
40
|
const context = contexts[contextId];
|
|
33
41
|
if (!context) {
|
|
34
|
-
throw new
|
|
42
|
+
throw new ContextNotRegisteredError_ts_1.default(`Context with ID ${contextId} is not registered`);
|
|
35
43
|
}
|
|
36
44
|
return context;
|
|
37
45
|
}
|
|
38
46
|
function generateContextId() {
|
|
39
|
-
return generateRandomString(16);
|
|
47
|
+
return (0, random_ts_1.generateRandomString)(16);
|
|
40
48
|
}
|
|
41
49
|
function createContextRef(contextId) {
|
|
42
50
|
return {
|
|
@@ -48,11 +56,11 @@ function createContextRef(contextId) {
|
|
|
48
56
|
* @returns A reference to the default context.
|
|
49
57
|
* @remarks This method is opinionated and not recommended for production use.
|
|
50
58
|
*/
|
|
51
|
-
|
|
52
|
-
const tenantId = getEnvironmentVariable("AZURE_TENANT_ID");
|
|
53
|
-
const clientId = getEnvironmentVariable("AZURE_CLIENT_ID");
|
|
54
|
-
const clientSecret = getEnvironmentVariable("AZURE_CLIENT_SECRET");
|
|
55
|
-
const httpProxy = (getEnvironmentVariable("HTTP_PROXY", "") || undefined);
|
|
59
|
+
function getDefaultContextRef() {
|
|
60
|
+
const tenantId = (0, environmentVariable_ts_1.getEnvironmentVariable)("AZURE_TENANT_ID");
|
|
61
|
+
const clientId = (0, environmentVariable_ts_1.getEnvironmentVariable)("AZURE_CLIENT_ID");
|
|
62
|
+
const clientSecret = (0, environmentVariable_ts_1.getEnvironmentVariable)("AZURE_CLIENT_SECRET");
|
|
63
|
+
const httpProxy = ((0, environmentVariable_ts_1.getEnvironmentVariable)("HTTP_PROXY", "") || undefined);
|
|
56
64
|
const contextRef = register(tenantId, clientId, clientSecret, httpProxy);
|
|
57
65
|
return contextRef;
|
|
58
66
|
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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.createDriveRef = createDriveRef;
|
|
7
|
+
exports.getDefaultDriveRef = getDefaultDriveRef;
|
|
8
|
+
const ProtocolError_ts_1 = __importDefault(require("../errors/ProtocolError.js"));
|
|
9
|
+
const context_ts_1 = require("./context.js");
|
|
10
|
+
const environmentVariable_ts_1 = require("./environmentVariable.js");
|
|
11
|
+
const site_ts_1 = require("./site.js");
|
|
5
12
|
/**
|
|
6
13
|
* Creates a reference to a drive.
|
|
7
14
|
* @param siteRef - The reference to the site.
|
|
@@ -9,9 +16,9 @@ import { createSiteRef } from "./site.js";
|
|
|
9
16
|
* @returns A reference to the drive.
|
|
10
17
|
* @throws ProtocolError if the drive ID is missing.
|
|
11
18
|
*/
|
|
12
|
-
|
|
19
|
+
function createDriveRef(siteRef, driveId) {
|
|
13
20
|
if (!driveId) {
|
|
14
|
-
throw new
|
|
21
|
+
throw new ProtocolError_ts_1.default("DriveID is missing");
|
|
15
22
|
}
|
|
16
23
|
return {
|
|
17
24
|
contextId: siteRef.contextId,
|
|
@@ -24,15 +31,15 @@ export function createDriveRef(siteRef, driveId) {
|
|
|
24
31
|
* @returns A reference to the default drive.
|
|
25
32
|
* @remarks This method is opinionated and not recommended for production use.
|
|
26
33
|
*/
|
|
27
|
-
|
|
28
|
-
const tenantId = getEnvironmentVariable("AZURE_TENANT_ID");
|
|
29
|
-
const clientId = getEnvironmentVariable("AZURE_CLIENT_ID");
|
|
30
|
-
const clientSecret = getEnvironmentVariable("AZURE_CLIENT_SECRET");
|
|
31
|
-
const siteId = getEnvironmentVariable("SHAREPOINT_DEFAULT_SITE_ID");
|
|
32
|
-
const driveId = getEnvironmentVariable("SHAREPOINT_DEFAULT_DRIVE_ID");
|
|
33
|
-
const httpProxy = (getEnvironmentVariable("HTTP_PROXY", "") || undefined);
|
|
34
|
-
const contextRef = register(tenantId, clientId, clientSecret, httpProxy);
|
|
35
|
-
const siteRef = createSiteRef(contextRef, siteId);
|
|
34
|
+
function getDefaultDriveRef() {
|
|
35
|
+
const tenantId = (0, environmentVariable_ts_1.getEnvironmentVariable)("AZURE_TENANT_ID");
|
|
36
|
+
const clientId = (0, environmentVariable_ts_1.getEnvironmentVariable)("AZURE_CLIENT_ID");
|
|
37
|
+
const clientSecret = (0, environmentVariable_ts_1.getEnvironmentVariable)("AZURE_CLIENT_SECRET");
|
|
38
|
+
const siteId = (0, environmentVariable_ts_1.getEnvironmentVariable)("SHAREPOINT_DEFAULT_SITE_ID");
|
|
39
|
+
const driveId = (0, environmentVariable_ts_1.getEnvironmentVariable)("SHAREPOINT_DEFAULT_DRIVE_ID");
|
|
40
|
+
const httpProxy = ((0, environmentVariable_ts_1.getEnvironmentVariable)("HTTP_PROXY", "") || undefined);
|
|
41
|
+
const contextRef = (0, context_ts_1.register)(tenantId, clientId, clientSecret, httpProxy);
|
|
42
|
+
const siteRef = (0, site_ts_1.createSiteRef)(contextRef, siteId);
|
|
36
43
|
const driveRef = createDriveRef(siteRef, driveId);
|
|
37
44
|
return driveRef;
|
|
38
45
|
}
|
|
@@ -1,28 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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.rootDriveItemPath = exports.workbookFileExtension = void 0;
|
|
7
|
+
exports.driveItemPath = driveItemPath;
|
|
8
|
+
exports.createDriveItemRef = createDriveItemRef;
|
|
9
|
+
const InvalidArgumentError_ts_1 = __importDefault(require("../errors/InvalidArgumentError.js"));
|
|
10
|
+
const ProtocolError_ts_1 = __importDefault(require("../errors/ProtocolError.js"));
|
|
3
11
|
const segmentPattern = /^[^"*:<>?\\|#]{1,256}$/;
|
|
4
12
|
const reservedNames = ["CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"];
|
|
5
|
-
|
|
6
|
-
|
|
13
|
+
exports.workbookFileExtension = "xlsx";
|
|
14
|
+
exports.rootDriveItemPath = driveItemPath("/");
|
|
7
15
|
/**
|
|
8
16
|
* Creates a drive item path from a given set of segments.
|
|
9
17
|
* @param segments - The segments of the path.
|
|
10
18
|
* @returns The constructed drive item path.
|
|
11
19
|
* @throws InvalidArgumentError if a segment is invalid or the path exceeds 400 characters.
|
|
12
20
|
*/
|
|
13
|
-
|
|
21
|
+
function driveItemPath(...segments) {
|
|
14
22
|
for (const segment of segments) {
|
|
15
23
|
if (segment === "") {
|
|
16
|
-
throw new
|
|
24
|
+
throw new InvalidArgumentError_ts_1.default("Segment cannot be an empty string.");
|
|
17
25
|
}
|
|
18
26
|
if (!segmentPattern.test(segment)) {
|
|
19
|
-
throw new
|
|
27
|
+
throw new InvalidArgumentError_ts_1.default(`Segment '${segment}' does not match required pattern '${segmentPattern}'.`);
|
|
20
28
|
}
|
|
21
29
|
if (reservedNames.includes(segment.toUpperCase())) {
|
|
22
|
-
throw new
|
|
30
|
+
throw new InvalidArgumentError_ts_1.default(`Segment '${segment}' is a reserved name.`);
|
|
23
31
|
}
|
|
24
32
|
if (segment.endsWith(".")) {
|
|
25
|
-
throw new
|
|
33
|
+
throw new InvalidArgumentError_ts_1.default(`Segment '${segment}' cannot end with a period.`);
|
|
26
34
|
}
|
|
27
35
|
}
|
|
28
36
|
let path = `${segments.join("/")}`;
|
|
@@ -30,10 +38,10 @@ export function driveItemPath(...segments) {
|
|
|
30
38
|
path = `/${path}`;
|
|
31
39
|
}
|
|
32
40
|
if (path.includes("//")) {
|
|
33
|
-
throw new
|
|
41
|
+
throw new InvalidArgumentError_ts_1.default("Path cannot contain consecutive slashes.");
|
|
34
42
|
}
|
|
35
43
|
if (path.length > 400) {
|
|
36
|
-
throw new
|
|
44
|
+
throw new InvalidArgumentError_ts_1.default("Path length exceeds 400 characters.");
|
|
37
45
|
}
|
|
38
46
|
return path;
|
|
39
47
|
}
|
|
@@ -44,9 +52,9 @@ export function driveItemPath(...segments) {
|
|
|
44
52
|
* @returns A reference to the drive item.
|
|
45
53
|
* @throws ProtocolError if the item ID is missing.
|
|
46
54
|
*/
|
|
47
|
-
|
|
55
|
+
function createDriveItemRef(driveRef, itemId) {
|
|
48
56
|
if (!itemId) {
|
|
49
|
-
throw new
|
|
57
|
+
throw new ProtocolError_ts_1.default("ItemID is missing");
|
|
50
58
|
}
|
|
51
59
|
return {
|
|
52
60
|
contextId: driveRef.contextId,
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 InvalidArgumentError_ts_1 = __importDefault(require("../errors/InvalidArgumentError.js"));
|
|
8
|
+
const driveItem_ts_1 = require("./driveItem.js");
|
|
9
|
+
(0, vitest_1.describe)("driveItemPath", () => {
|
|
10
|
+
(0, vitest_1.it)("throws an error for empty segment", () => {
|
|
11
|
+
(0, vitest_1.expect)(() => (0, driveItem_ts_1.driveItemPath)("")).toThrow(InvalidArgumentError_ts_1.default);
|
|
7
12
|
});
|
|
8
|
-
it.each([
|
|
13
|
+
vitest_1.it.each([
|
|
9
14
|
[["a"], "/a"],
|
|
10
15
|
[["a", "b"], "/a/b"],
|
|
11
16
|
[["a", "b", "c.txt"], "/a/b/c.txt"],
|
|
12
17
|
[["/a"], "/a"],
|
|
13
18
|
[[], "/"],
|
|
14
19
|
])("parses %s", (segments, expected) => {
|
|
15
|
-
expect(driveItemPath(...segments)).toEqual(expected);
|
|
20
|
+
(0, vitest_1.expect)((0, driveItem_ts_1.driveItemPath)(...segments)).toEqual(expected);
|
|
16
21
|
});
|
|
17
22
|
});
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
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.getEnvironmentVariable = getEnvironmentVariable;
|
|
7
|
+
exports.bindEnvironmentVariable = bindEnvironmentVariable;
|
|
8
|
+
const EnvironmentVariableMissingError_ts_1 = __importDefault(require("../errors/EnvironmentVariableMissingError.js"));
|
|
2
9
|
/**
|
|
3
10
|
* Retrieves the value of an environment variable.
|
|
4
11
|
* @param env - The name of the environment variable.
|
|
@@ -6,11 +13,11 @@ import EnvironmentVariableMissingError from "../errors/EnvironmentVariableMissin
|
|
|
6
13
|
* @returns The value of the environment variable or the fallback value.
|
|
7
14
|
* @throws EnvironmentVariableMissingError if the environment variable is not set and no fallback value is provided.
|
|
8
15
|
*/
|
|
9
|
-
|
|
16
|
+
function getEnvironmentVariable(env, fallbackValue = null) {
|
|
10
17
|
const value = process.env[env]?.trim() ?? "";
|
|
11
18
|
if (value === "") {
|
|
12
19
|
if (fallbackValue === null) {
|
|
13
|
-
throw new
|
|
20
|
+
throw new EnvironmentVariableMissingError_ts_1.default(env);
|
|
14
21
|
}
|
|
15
22
|
return fallbackValue ?? "";
|
|
16
23
|
}
|
|
@@ -22,6 +29,6 @@ export function getEnvironmentVariable(env, fallbackValue = null) {
|
|
|
22
29
|
* @param fallbackValue - The fallback value to use if the environment variable is not set. Defaults to null.
|
|
23
30
|
* @returns A function that retrieves the value of the environment variable or the fallback value.
|
|
24
31
|
*/
|
|
25
|
-
|
|
32
|
+
function bindEnvironmentVariable(env, fallbackValue = null) {
|
|
26
33
|
return () => getEnvironmentVariable(env, fallbackValue);
|
|
27
34
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tryGetHttpAgent = tryGetHttpAgent;
|
|
4
|
+
const https_proxy_agent_1 = require("https-proxy-agent");
|
|
2
5
|
/**
|
|
3
6
|
* Attempts to create an HTTP agent for a given proxy configuration.
|
|
4
7
|
* @param httpProxy - The HTTP proxy configuration.
|
|
5
8
|
* @returns An instance of HttpsProxyAgent if the proxy is defined, otherwise undefined.
|
|
6
9
|
*/
|
|
7
|
-
|
|
10
|
+
function tryGetHttpAgent(httpProxy) {
|
|
8
11
|
if (!httpProxy) {
|
|
9
12
|
return undefined;
|
|
10
13
|
}
|
|
11
|
-
return new HttpsProxyAgent(httpProxy);
|
|
14
|
+
return new https_proxy_agent_1.HttpsProxyAgent(httpProxy);
|
|
12
15
|
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isHttpOk = isHttpOk;
|
|
4
|
+
exports.isHttpTooManyRequests = isHttpTooManyRequests;
|
|
5
|
+
exports.isServiceUnavailable = isServiceUnavailable;
|
|
1
6
|
/**
|
|
2
7
|
* Checks if the HTTP status code indicates a successful response.
|
|
3
8
|
* @param status - The HTTP status code.
|
|
4
9
|
* @returns True if the status code is in the range 200-299, otherwise false.
|
|
5
10
|
*/
|
|
6
|
-
|
|
11
|
+
function isHttpOk(status) {
|
|
7
12
|
return status >= 200 && status < 300;
|
|
8
13
|
}
|
|
9
14
|
/**
|
|
@@ -11,7 +16,7 @@ export function isHttpOk(status) {
|
|
|
11
16
|
* @param status - The HTTP status code.
|
|
12
17
|
* @returns True if the status code is 429, otherwise false.
|
|
13
18
|
*/
|
|
14
|
-
|
|
19
|
+
function isHttpTooManyRequests(status) {
|
|
15
20
|
return status === 429;
|
|
16
21
|
}
|
|
17
22
|
/**
|
|
@@ -19,6 +24,6 @@ export function isHttpTooManyRequests(status) {
|
|
|
19
24
|
* @param status - The HTTP status code.
|
|
20
25
|
* @returns True if the status code is 503, otherwise false.
|
|
21
26
|
*/
|
|
22
|
-
|
|
27
|
+
function isServiceUnavailable(status) {
|
|
23
28
|
return status === 503;
|
|
24
29
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.operationIndexToId = operationIndexToId;
|
|
4
|
+
exports.operationIdToIndex = operationIdToIndex;
|
|
1
5
|
/**
|
|
2
6
|
* Converts an operation index to an operation ID.
|
|
3
7
|
* @param index - The operation index.
|
|
4
8
|
* @returns The operation ID as a string.
|
|
5
9
|
*/
|
|
6
|
-
|
|
10
|
+
function operationIndexToId(index) {
|
|
7
11
|
return index.toString();
|
|
8
12
|
}
|
|
9
13
|
/**
|
|
@@ -11,6 +15,6 @@ export function operationIndexToId(index) {
|
|
|
11
15
|
* @param id - The operation ID as a string.
|
|
12
16
|
* @returns The operation index as a number.
|
|
13
17
|
*/
|
|
14
|
-
|
|
18
|
+
function operationIdToIndex(id) {
|
|
15
19
|
return Number.parseInt(id, 10);
|
|
16
20
|
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateRandomString = generateRandomString;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
2
5
|
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
3
6
|
/**
|
|
4
7
|
* Generates a random alphanumeric string of the specified length.
|
|
5
8
|
* @param length - The length of the string to generate. Defaults to 16.
|
|
6
9
|
* @returns A random alphanumeric string.
|
|
7
10
|
*/
|
|
8
|
-
|
|
11
|
+
function generateRandomString(length = 16) {
|
|
9
12
|
let result = "";
|
|
10
13
|
for (let i = 0; i < length; i++) {
|
|
11
|
-
result += characters[randomInt(characters.length)];
|
|
14
|
+
result += characters[(0, node_crypto_1.randomInt)(characters.length)];
|
|
12
15
|
}
|
|
13
16
|
return result;
|
|
14
17
|
}
|
|
@@ -1,24 +1,30 @@
|
|
|
1
|
-
|
|
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.parseSharepointUrl = parseSharepointUrl;
|
|
7
|
+
const InvalidArgumentError_ts_1 = __importDefault(require("../errors/InvalidArgumentError.js"));
|
|
2
8
|
/**
|
|
3
9
|
* Parses a SharePoint document URL to extract the site name, host name, and item ID.
|
|
4
10
|
* @param url - The SharePoint document URL.
|
|
5
11
|
* @returns An object containing the host name, site name, and item ID.
|
|
6
12
|
* @throws InvalidArgumentError if the URL is invalid or required components are missing.
|
|
7
13
|
*/
|
|
8
|
-
|
|
14
|
+
function parseSharepointUrl(url) {
|
|
9
15
|
if (!url.hostname.endsWith(".sharepoint.com")) {
|
|
10
|
-
throw new
|
|
16
|
+
throw new InvalidArgumentError_ts_1.default("Invalid SharePoint URL. Hostname must end with '.sharepoint.com'.");
|
|
11
17
|
}
|
|
12
18
|
const hostName = url.hostname;
|
|
13
19
|
const pathSegments = url.pathname.split("/");
|
|
14
20
|
const siteNameIndex = pathSegments.indexOf("sites") + 1;
|
|
15
21
|
if (siteNameIndex <= 0 || !pathSegments[siteNameIndex]) {
|
|
16
|
-
throw new
|
|
22
|
+
throw new InvalidArgumentError_ts_1.default("Invalid SharePoint URL. Site name not found.");
|
|
17
23
|
}
|
|
18
24
|
const siteName = pathSegments[siteNameIndex];
|
|
19
25
|
const sourcedoc = url.searchParams.get("sourcedoc");
|
|
20
26
|
if (!sourcedoc) {
|
|
21
|
-
throw new
|
|
27
|
+
throw new InvalidArgumentError_ts_1.default("Invalid SharePoint URL. Path not found in parameters.");
|
|
22
28
|
}
|
|
23
29
|
const itemId = sourcedoc.replace(/[{}]/g, "").toLocaleUpperCase();
|
|
24
30
|
return {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const sharepointUrl_ts_1 = require("./sharepointUrl.js");
|
|
5
|
+
(0, vitest_1.describe)("parseSharepointUrl", () => {
|
|
6
|
+
vitest_1.it.each([
|
|
5
7
|
[
|
|
6
8
|
"https://msftfuturesecureai.sharepoint.com/sites/FSAI-MQG/_layouts/15/doc.aspx?sourcedoc={500ff055-1e0f-4c2e-8b32-d167fba4778b}&action=edit",
|
|
7
9
|
{
|
|
@@ -27,6 +29,6 @@ describe("parseSharepointUrl", () => {
|
|
|
27
29
|
},
|
|
28
30
|
],
|
|
29
31
|
])("parses %s", (url, expected) => {
|
|
30
|
-
expect(parseSharepointUrl(new URL(url))).toEqual(expected);
|
|
32
|
+
(0, vitest_1.expect)((0, sharepointUrl_ts_1.parseSharepointUrl)(new URL(url))).toEqual(expected);
|
|
31
33
|
});
|
|
32
34
|
});
|
|
@@ -1,6 +1,13 @@
|
|
|
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.createSiteRef = createSiteRef;
|
|
7
|
+
exports.getDefaultSiteRef = getDefaultSiteRef;
|
|
8
|
+
const ProtocolError_ts_1 = __importDefault(require("../errors/ProtocolError.js"));
|
|
9
|
+
const context_ts_1 = require("./context.js");
|
|
10
|
+
const environmentVariable_ts_1 = require("./environmentVariable.js");
|
|
4
11
|
/**
|
|
5
12
|
* Creates a reference to a site.
|
|
6
13
|
* @param contextRef - The reference to the context.
|
|
@@ -8,9 +15,9 @@ import { getEnvironmentVariable } from "./environmentVariable.js";
|
|
|
8
15
|
* @returns A reference to the site.
|
|
9
16
|
* @throws ProtocolError if the site ID is missing.
|
|
10
17
|
*/
|
|
11
|
-
|
|
18
|
+
function createSiteRef(contextRef, siteId) {
|
|
12
19
|
if (!siteId) {
|
|
13
|
-
throw new
|
|
20
|
+
throw new ProtocolError_ts_1.default("SiteID is missing");
|
|
14
21
|
}
|
|
15
22
|
return {
|
|
16
23
|
contextId: contextRef.contextId,
|
|
@@ -22,9 +29,9 @@ export function createSiteRef(contextRef, siteId) {
|
|
|
22
29
|
* @returns A reference to the default site.
|
|
23
30
|
* @remarks This method is opinionated and not recommended for production use.
|
|
24
31
|
*/
|
|
25
|
-
|
|
26
|
-
const contextRef = getDefaultContextRef();
|
|
27
|
-
const siteId = getEnvironmentVariable("SHAREPOINT_DEFAULT_SITE_ID");
|
|
32
|
+
function getDefaultSiteRef() {
|
|
33
|
+
const contextRef = (0, context_ts_1.getDefaultContextRef)();
|
|
34
|
+
const siteId = (0, environmentVariable_ts_1.getEnvironmentVariable)("SHAREPOINT_DEFAULT_SITE_ID");
|
|
28
35
|
const siteRef = createSiteRef(contextRef, siteId);
|
|
29
36
|
return siteRef;
|
|
30
37
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sleep = sleep;
|
|
1
4
|
/**
|
|
2
5
|
* Pauses execution for the specified number of milliseconds.
|
|
3
6
|
* @param ms - The number of milliseconds to sleep.
|
|
4
7
|
* @returns A promise that resolves after the specified time.
|
|
5
8
|
*/
|
|
6
|
-
|
|
9
|
+
function sleep(ms) {
|
|
7
10
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
8
11
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.kebabToCamelCase = kebabToCamelCase;
|
|
1
4
|
/**
|
|
2
5
|
* Converts a kebab-case string to camelCase.
|
|
3
6
|
* @param str - The kebab-case string.
|
|
4
7
|
* @returns The camelCase string.
|
|
5
8
|
*/
|
|
6
|
-
|
|
9
|
+
function kebabToCamelCase(str) {
|
|
7
10
|
return str
|
|
8
11
|
.replace(/^-+|-+$/g, "") // Remove leading and trailing dashes
|
|
9
12
|
.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const stringCaseConversion_ts_1 = require("./stringCaseConversion.js");
|
|
5
|
+
(0, vitest_1.describe)("kebabToCamelCase", () => {
|
|
6
|
+
(0, vitest_1.it)("should handle single word strings", () => {
|
|
7
|
+
(0, vitest_1.expect)((0, stringCaseConversion_ts_1.kebabToCamelCase)("single")).toBe("single");
|
|
6
8
|
});
|
|
7
|
-
it("should handle empty strings", () => {
|
|
8
|
-
expect(kebabToCamelCase("")).toBe("");
|
|
9
|
+
(0, vitest_1.it)("should handle empty strings", () => {
|
|
10
|
+
(0, vitest_1.expect)((0, stringCaseConversion_ts_1.kebabToCamelCase)("")).toBe("");
|
|
9
11
|
});
|
|
10
|
-
it("should handle strings with multiple dashes", () => {
|
|
11
|
-
expect(kebabToCamelCase("multiple-dashes-in-string")).toBe("multipleDashesInString");
|
|
12
|
+
(0, vitest_1.it)("should handle strings with multiple dashes", () => {
|
|
13
|
+
(0, vitest_1.expect)((0, stringCaseConversion_ts_1.kebabToCamelCase)("multiple-dashes-in-string")).toBe("multipleDashesInString");
|
|
12
14
|
});
|
|
13
|
-
it("should handle strings with leading and trailing dashes", () => {
|
|
14
|
-
expect(kebabToCamelCase("-leading-and-trailing-")).toBe("leadingAndTrailing");
|
|
15
|
+
(0, vitest_1.it)("should handle strings with leading and trailing dashes", () => {
|
|
16
|
+
(0, vitest_1.expect)((0, stringCaseConversion_ts_1.kebabToCamelCase)("-leading-and-trailing-")).toBe("leadingAndTrailing");
|
|
15
17
|
});
|
|
16
18
|
});
|