microsoft-graph 2.7.7 → 2.7.8

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.
@@ -1,5 +1,17 @@
1
1
  import type { Address } from "../models/Address.ts";
2
2
  import type { Cartesian } from "../models/Cartesian.ts";
3
+ /**
4
+ * Converts a cell range address to Cartesian coordinates.
5
+ *
6
+ * @param {Address} address - The cell range address (e.g., "A1:C3").
7
+ * @returns {Cartesian} The Cartesian representation of the address, with start and end coordinates.
8
+ */
3
9
  export declare function addressToCartesian(address: Address): Cartesian;
10
+ /**
11
+ * Converts Cartesian coordinates to a cell range address.
12
+ *
13
+ * @param {Cartesian} cartesian - The Cartesian coordinates, including start (ax, ay) and end (bx, by).
14
+ * @returns {Address} The cell range address (e.g., "A1:C3").
15
+ */
4
16
  export declare function cartesianToAddress(cartesian: Cartesian): Address;
5
17
  //# sourceMappingURL=cartesianAddress.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cartesianAddress.d.ts","sourceRoot":"","sources":["../../../src/services/cartesianAddress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAIxD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,CAU9D;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAchE"}
1
+ {"version":3,"file":"cartesianAddress.d.ts","sourceRoot":"","sources":["../../../src/services/cartesianAddress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAIxD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,CAU9D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAchE"}
@@ -4,6 +4,12 @@ exports.addressToCartesian = addressToCartesian;
4
4
  exports.cartesianToAddress = cartesianToAddress;
5
5
  const addressManipulation_ts_1 = require("./addressManipulation.js");
6
6
  const addressOffset_ts_1 = require("./addressOffset.js");
7
+ /**
8
+ * Converts a cell range address to Cartesian coordinates.
9
+ *
10
+ * @param {Address} address - The cell range address (e.g., "A1:C3").
11
+ * @returns {Cartesian} The Cartesian representation of the address, with start and end coordinates.
12
+ */
7
13
  function addressToCartesian(address) {
8
14
  const components = (0, addressManipulation_ts_1.decomposeAddress)(address);
9
15
  const ax = (0, addressOffset_ts_1.columnAddressToOffset)(components.startColumn);
@@ -12,6 +18,12 @@ function addressToCartesian(address) {
12
18
  const by = (0, addressOffset_ts_1.rowAddressToOffset)(components.endRow);
13
19
  return { ax, ay, bx, by };
14
20
  }
21
+ /**
22
+ * Converts Cartesian coordinates to a cell range address.
23
+ *
24
+ * @param {Cartesian} cartesian - The Cartesian coordinates, including start (ax, ay) and end (bx, by).
25
+ * @returns {Address} The cell range address (e.g., "A1:C3").
26
+ */
15
27
  function cartesianToAddress(cartesian) {
16
28
  const startColumn = (0, addressOffset_ts_1.columnOffsetToAddress)(cartesian.ax);
17
29
  const startRow = (0, addressOffset_ts_1.rowOffsetToAddress)(cartesian.ay);
@@ -0,0 +1,28 @@
1
+ import type { Address } from "../models/Address.ts";
2
+ import type { CellRangeValues } from "../models/CellRangeValues.ts";
3
+ /**
4
+ * Converts a 2D array of cell values into range address in the upper left.
5
+ *
6
+ * @param {CellRangeValues} values - A 2D array representing cell values.
7
+ * @returns {Address} The default cell range address (e.g., "A1:C3").
8
+ * @throws {InvalidArgumentError} If rows have inconsistent column counts.
9
+ */
10
+ export declare function inferRangeAddress(values: CellRangeValues): Address;
11
+ /**
12
+ * Converts a 2D array of cell values into an array of objects.
13
+ * Assumes the first row is a header and uses it as keys for the objects.
14
+ *
15
+ * @param {CellRangeValues} values - A 2D array representing cell values.
16
+ * @returns {unknown[]} An array of objects where each object represents a row.
17
+ * @throws {InvalidArgumentError} If rows have inconsistent column counts or no header row is present.
18
+ */
19
+ export declare function inferRangeObject(values: CellRangeValues): unknown[];
20
+ /**
21
+ * Converts an array of objects into a 2D array of cell values.
22
+ * The first row of the 2D array contains the keys as headers.
23
+ *
24
+ * @param {unknown[]} objs - An array of objects to convert.
25
+ * @returns {CellRangeValues} A 2D array where the first row is the header and subsequent rows are the object values.
26
+ */
27
+ export declare function inferObjectRange(objs: unknown[]): CellRangeValues;
28
+ //# sourceMappingURL=rangeManipulation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rangeManipulation.d.ts","sourceRoot":"","sources":["../../../src/services/rangeManipulation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAMpE;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CA4BlE;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,EAAE,CAoBnE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,eAAe,CASjE"}
@@ -0,0 +1,78 @@
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.inferRangeAddress = inferRangeAddress;
7
+ exports.inferRangeObject = inferRangeObject;
8
+ exports.inferObjectRange = inferObjectRange;
9
+ const InvalidArgumentError_ts_1 = __importDefault(require("../errors/InvalidArgumentError.js"));
10
+ const cartesianAddress_ts_1 = require("./cartesianAddress.js");
11
+ /**
12
+ * Converts a 2D array of cell values into range address in the upper left.
13
+ *
14
+ * @param {CellRangeValues} values - A 2D array representing cell values.
15
+ * @returns {Address} The default cell range address (e.g., "A1:C3").
16
+ * @throws {InvalidArgumentError} If rows have inconsistent column counts.
17
+ */
18
+ function inferRangeAddress(values) {
19
+ const first = values[0];
20
+ if (!first) {
21
+ return "A1";
22
+ }
23
+ for (const row of values) {
24
+ if (row.length !== first.length) {
25
+ throw new InvalidArgumentError_ts_1.default("All rows must have the same number of columns");
26
+ }
27
+ }
28
+ const rowCount = values.length;
29
+ const columnCount = first.length;
30
+ const startRow = 0;
31
+ const startColumn = 0;
32
+ const endRow = (rowCount - 1);
33
+ const endColumn = (columnCount - 1);
34
+ return (0, cartesianAddress_ts_1.cartesianToAddress)({
35
+ ax: startColumn,
36
+ ay: startRow,
37
+ bx: endColumn,
38
+ by: endRow,
39
+ });
40
+ }
41
+ /**
42
+ * Converts a 2D array of cell values into an array of objects.
43
+ * Assumes the first row is a header and uses it as keys for the objects.
44
+ *
45
+ * @param {CellRangeValues} values - A 2D array representing cell values.
46
+ * @returns {unknown[]} An array of objects where each object represents a row.
47
+ * @throws {InvalidArgumentError} If rows have inconsistent column counts or no header row is present.
48
+ */
49
+ function inferRangeObject(values) {
50
+ const [header, ...rows] = values;
51
+ if (!header) {
52
+ throw new InvalidArgumentError_ts_1.default("Does not contain a header row");
53
+ }
54
+ return rows.map((row, index) => {
55
+ if (row.length !== header.length) {
56
+ throw new InvalidArgumentError_ts_1.default(`Row ${index} length must match header length`);
57
+ }
58
+ return header.reduce((obj, key, index) => {
59
+ obj[key.toString()] = row[index];
60
+ return obj;
61
+ }, {});
62
+ });
63
+ }
64
+ /**
65
+ * Converts an array of objects into a 2D array of cell values.
66
+ * The first row of the 2D array contains the keys as headers.
67
+ *
68
+ * @param {unknown[]} objs - An array of objects to convert.
69
+ * @returns {CellRangeValues} A 2D array where the first row is the header and subsequent rows are the object values.
70
+ */
71
+ function inferObjectRange(objs) {
72
+ if (objs.length === 0) {
73
+ return [];
74
+ }
75
+ const header = Array.from(new Set(objs.flatMap((obj) => Object.keys(obj))));
76
+ const rows = objs.map((obj) => header.map((key) => obj[key]));
77
+ return [header, ...rows];
78
+ }
@@ -1,5 +1,17 @@
1
1
  import type { Address } from "../models/Address.ts";
2
2
  import type { Cartesian } from "../models/Cartesian.ts";
3
+ /**
4
+ * Converts a cell range address to Cartesian coordinates.
5
+ *
6
+ * @param {Address} address - The cell range address (e.g., "A1:C3").
7
+ * @returns {Cartesian} The Cartesian representation of the address, with start and end coordinates.
8
+ */
3
9
  export declare function addressToCartesian(address: Address): Cartesian;
10
+ /**
11
+ * Converts Cartesian coordinates to a cell range address.
12
+ *
13
+ * @param {Cartesian} cartesian - The Cartesian coordinates, including start (ax, ay) and end (bx, by).
14
+ * @returns {Address} The cell range address (e.g., "A1:C3").
15
+ */
4
16
  export declare function cartesianToAddress(cartesian: Cartesian): Address;
5
17
  //# sourceMappingURL=cartesianAddress.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cartesianAddress.d.ts","sourceRoot":"","sources":["../../../src/services/cartesianAddress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAIxD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,CAU9D;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAchE"}
1
+ {"version":3,"file":"cartesianAddress.d.ts","sourceRoot":"","sources":["../../../src/services/cartesianAddress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAIxD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,CAU9D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAchE"}
@@ -1,5 +1,11 @@
1
1
  import { composeAddress, decomposeAddress } from "./addressManipulation.js";
2
2
  import { columnAddressToOffset, columnOffsetToAddress, rowAddressToOffset, rowOffsetToAddress } from "./addressOffset.js";
3
+ /**
4
+ * Converts a cell range address to Cartesian coordinates.
5
+ *
6
+ * @param {Address} address - The cell range address (e.g., "A1:C3").
7
+ * @returns {Cartesian} The Cartesian representation of the address, with start and end coordinates.
8
+ */
3
9
  export function addressToCartesian(address) {
4
10
  const components = decomposeAddress(address);
5
11
  const ax = columnAddressToOffset(components.startColumn);
@@ -8,6 +14,12 @@ export function addressToCartesian(address) {
8
14
  const by = rowAddressToOffset(components.endRow);
9
15
  return { ax, ay, bx, by };
10
16
  }
17
+ /**
18
+ * Converts Cartesian coordinates to a cell range address.
19
+ *
20
+ * @param {Cartesian} cartesian - The Cartesian coordinates, including start (ax, ay) and end (bx, by).
21
+ * @returns {Address} The cell range address (e.g., "A1:C3").
22
+ */
11
23
  export function cartesianToAddress(cartesian) {
12
24
  const startColumn = columnOffsetToAddress(cartesian.ax);
13
25
  const startRow = rowOffsetToAddress(cartesian.ay);
@@ -0,0 +1,28 @@
1
+ import type { Address } from "../models/Address.ts";
2
+ import type { CellRangeValues } from "../models/CellRangeValues.ts";
3
+ /**
4
+ * Converts a 2D array of cell values into range address in the upper left.
5
+ *
6
+ * @param {CellRangeValues} values - A 2D array representing cell values.
7
+ * @returns {Address} The default cell range address (e.g., "A1:C3").
8
+ * @throws {InvalidArgumentError} If rows have inconsistent column counts.
9
+ */
10
+ export declare function inferRangeAddress(values: CellRangeValues): Address;
11
+ /**
12
+ * Converts a 2D array of cell values into an array of objects.
13
+ * Assumes the first row is a header and uses it as keys for the objects.
14
+ *
15
+ * @param {CellRangeValues} values - A 2D array representing cell values.
16
+ * @returns {unknown[]} An array of objects where each object represents a row.
17
+ * @throws {InvalidArgumentError} If rows have inconsistent column counts or no header row is present.
18
+ */
19
+ export declare function inferRangeObject(values: CellRangeValues): unknown[];
20
+ /**
21
+ * Converts an array of objects into a 2D array of cell values.
22
+ * The first row of the 2D array contains the keys as headers.
23
+ *
24
+ * @param {unknown[]} objs - An array of objects to convert.
25
+ * @returns {CellRangeValues} A 2D array where the first row is the header and subsequent rows are the object values.
26
+ */
27
+ export declare function inferObjectRange(objs: unknown[]): CellRangeValues;
28
+ //# sourceMappingURL=rangeManipulation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rangeManipulation.d.ts","sourceRoot":"","sources":["../../../src/services/rangeManipulation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAMpE;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CA4BlE;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,EAAE,CAoBnE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,eAAe,CASjE"}
@@ -0,0 +1,70 @@
1
+ import InvalidArgumentError from "../errors/InvalidArgumentError.js";
2
+ import { cartesianToAddress } from "./cartesianAddress.js";
3
+ /**
4
+ * Converts a 2D array of cell values into range address in the upper left.
5
+ *
6
+ * @param {CellRangeValues} values - A 2D array representing cell values.
7
+ * @returns {Address} The default cell range address (e.g., "A1:C3").
8
+ * @throws {InvalidArgumentError} If rows have inconsistent column counts.
9
+ */
10
+ export function inferRangeAddress(values) {
11
+ const first = values[0];
12
+ if (!first) {
13
+ return "A1";
14
+ }
15
+ for (const row of values) {
16
+ if (row.length !== first.length) {
17
+ throw new InvalidArgumentError("All rows must have the same number of columns");
18
+ }
19
+ }
20
+ const rowCount = values.length;
21
+ const columnCount = first.length;
22
+ const startRow = 0;
23
+ const startColumn = 0;
24
+ const endRow = (rowCount - 1);
25
+ const endColumn = (columnCount - 1);
26
+ return cartesianToAddress({
27
+ ax: startColumn,
28
+ ay: startRow,
29
+ bx: endColumn,
30
+ by: endRow,
31
+ });
32
+ }
33
+ /**
34
+ * Converts a 2D array of cell values into an array of objects.
35
+ * Assumes the first row is a header and uses it as keys for the objects.
36
+ *
37
+ * @param {CellRangeValues} values - A 2D array representing cell values.
38
+ * @returns {unknown[]} An array of objects where each object represents a row.
39
+ * @throws {InvalidArgumentError} If rows have inconsistent column counts or no header row is present.
40
+ */
41
+ export function inferRangeObject(values) {
42
+ const [header, ...rows] = values;
43
+ if (!header) {
44
+ throw new InvalidArgumentError("Does not contain a header row");
45
+ }
46
+ return rows.map((row, index) => {
47
+ if (row.length !== header.length) {
48
+ throw new InvalidArgumentError(`Row ${index} length must match header length`);
49
+ }
50
+ return header.reduce((obj, key, index) => {
51
+ obj[key.toString()] = row[index];
52
+ return obj;
53
+ }, {});
54
+ });
55
+ }
56
+ /**
57
+ * Converts an array of objects into a 2D array of cell values.
58
+ * The first row of the 2D array contains the keys as headers.
59
+ *
60
+ * @param {unknown[]} objs - An array of objects to convert.
61
+ * @returns {CellRangeValues} A 2D array where the first row is the header and subsequent rows are the object values.
62
+ */
63
+ export function inferObjectRange(objs) {
64
+ if (objs.length === 0) {
65
+ return [];
66
+ }
67
+ const header = Array.from(new Set(objs.flatMap((obj) => Object.keys(obj))));
68
+ const rows = objs.map((obj) => header.map((key) => obj[key]));
69
+ return [header, ...rows];
70
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microsoft-graph",
3
- "version": "2.7.7",
3
+ "version": "2.7.8",
4
4
  "description": "Microsoft GraphAPI SDK for NodeJS",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -597,6 +597,11 @@
597
597
  "require": "./dist/cjs/services/random.js",
598
598
  "types": "./dist/esm/services/random.d.ts"
599
599
  },
600
+ "./services/rangeManipulation": {
601
+ "import": "./dist/esm/services/rangeManipulation.js",
602
+ "require": "./dist/cjs/services/rangeManipulation.js",
603
+ "types": "./dist/esm/services/rangeManipulation.d.ts"
604
+ },
600
605
  "./services/sharepointUrl": {
601
606
  "import": "./dist/esm/services/sharepointUrl.js",
602
607
  "require": "./dist/cjs/services/sharepointUrl.js",
@@ -1262,6 +1267,11 @@
1262
1267
  "import": "./dist/esm/services/random.js",
1263
1268
  "types": "./dist/esm/services/random.d.ts"
1264
1269
  },
1270
+ "./dist/cjs/services/rangeManipulation.js": {
1271
+ "require": "./dist/cjs/services/rangeManipulation.js",
1272
+ "import": "./dist/esm/services/rangeManipulation.js",
1273
+ "types": "./dist/esm/services/rangeManipulation.d.ts"
1274
+ },
1265
1275
  "./dist/cjs/services/sharepointUrl.js": {
1266
1276
  "require": "./dist/cjs/services/sharepointUrl.js",
1267
1277
  "import": "./dist/esm/services/sharepointUrl.js",