microsoft-graph 2.22.1 → 2.22.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.
@@ -129,6 +129,26 @@ export declare function countAddressRows(address: Address): number;
129
129
  * @returns The number of columns in the address.
130
130
  */
131
131
  export declare function countAddressColumns(address: Address): number;
132
+ /**
133
+ * Creates a range from a single cell address, extending by the specified number of rows and columns.
134
+ * If rows/cols is positive, the cell is the start of the range; if negative, the cell is the end of the range.
135
+ *
136
+ * @param cell - The cell address to use as the anchor.
137
+ * @param rows - The number of rows for the range. Positive: cell is start; Negative: cell is end.
138
+ * @param cols - The number of columns for the range. Positive: cell is start; Negative: cell is end.
139
+ * @returns The created address range.
140
+ *
141
+ * @throws {InvalidArgumentError} If the resulting address is out of bounds.
142
+ *
143
+ * @example
144
+ * // Creates a 2x2 range starting at B2
145
+ * cellToRangeAddress("B2", 2, 2); // "B2:C3"
146
+ * // Creates a 2x2 range ending at B2
147
+ * cellToRangeAddress("B2", -2, -2); // "A1:B2"
148
+ * // Creates a 2x2 range starting at C3, extending 2 rows down and 2 columns left
149
+ * cellToRangeAddress("B2", 2, -2)).toBe("A2:B3")
150
+ */
151
+ export declare function cellToRangeAddress(cell: CellAddress, rows: number, cols: number): Address;
132
152
  /**
133
153
  * Extracts a subrange from a spreadsheet-style A1 range (e.g., "A1:D10"),
134
154
  * allowing skip and take semantics on both rows and columns.
@@ -149,7 +169,7 @@ export declare function countAddressColumns(address: Address): number;
149
169
  * subaddress("A1:D10", 0, -1); // All but last row: "A1:D9"
150
170
  * subaddress("A1:D10", 0, Infinity, -2, 1); // Second last column: "C1:C10"
151
171
  */
152
- export declare function subaddress(address: Address, skipRows?: number, takeRows?: number, skipCols?: number, takeCols?: number): Address;
172
+ export declare function subAddress(address: Address, skipRows?: number, takeRows?: number, skipCols?: number, takeCols?: number): Address;
153
173
  /**
154
174
  * Extracts a subrange from a WorkbookRangeRef using skip/take semantics.
155
175
  * @param rangeRef Range reference to extract the sub-range from.
@@ -1 +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;AAGnJ,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAkBtE,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;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,UAAQ,GAAG,OAAO,CAE9E;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,iBAAiB,CAcpE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,iBAAiB,EAAE,UAAU,UAAQ,GAAG,OAAO,CAsBzF;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAGjE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAGhE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAS5D;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAS3D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAS/D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAS9D;AAED;;;;;;;;GAQG;AACH,wBAA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Q,SAA2B,GAAG,gBAAgB,CAM3K"}
@@ -22,7 +22,8 @@ exports.isAllColumnsAddress = isAllColumnsAddress;
22
22
  exports.isAllRowsAddress = isAllRowsAddress;
23
23
  exports.countAddressRows = countAddressRows;
24
24
  exports.countAddressColumns = countAddressColumns;
25
- exports.subaddress = subaddress;
25
+ exports.cellToRangeAddress = cellToRangeAddress;
26
+ exports.subAddress = subAddress;
26
27
  exports.subrange = subrange;
27
28
  const InvalidArgumentError_ts_1 = __importDefault(require("../errors/InvalidArgumentError.js"));
28
29
  const UnsupportedAddressTypeError_ts_1 = __importDefault(require("../errors/UnsupportedAddressTypeError.js"));
@@ -32,6 +33,10 @@ const firstColumn = "A";
32
33
  const lastColumn = "XFD";
33
34
  const firstRow = "1";
34
35
  const lastRow = "1048576";
36
+ const firstColumnOffset = (0, addressOffset_ts_1.columnAddressToOffset)(firstColumn);
37
+ const lastColumnOffset = (0, addressOffset_ts_1.columnAddressToOffset)(lastColumn);
38
+ const firstRowOffset = (0, addressOffset_ts_1.rowAddressToOffset)(firstRow);
39
+ const lastRowOffset = (0, addressOffset_ts_1.rowAddressToOffset)(lastRow);
35
40
  const addressPattern = /^(?<sheet>(?:'[^']+'|[A-Za-z0-9_]+)!)?(?:(?<startColumn>[A-Z]+)?(?<startRow>\d+)?(?::(?<endColumn>[A-Z]+)?(?<endRow>\d+)?)?)$/;
36
41
  /**
37
42
  * Fixes address, removing an optional sheet prefix and ensuring it is a valid range.
@@ -279,6 +284,64 @@ function countAddressColumns(address) {
279
284
  const components = decomposeAddress(address);
280
285
  return (0, addressOffset_ts_1.columnAddressToOffset)(components.endColumn) - (0, addressOffset_ts_1.columnAddressToOffset)(components.startColumn) + 1;
281
286
  }
287
+ /**
288
+ * Creates a range from a single cell address, extending by the specified number of rows and columns.
289
+ * If rows/cols is positive, the cell is the start of the range; if negative, the cell is the end of the range.
290
+ *
291
+ * @param cell - The cell address to use as the anchor.
292
+ * @param rows - The number of rows for the range. Positive: cell is start; Negative: cell is end.
293
+ * @param cols - The number of columns for the range. Positive: cell is start; Negative: cell is end.
294
+ * @returns The created address range.
295
+ *
296
+ * @throws {InvalidArgumentError} If the resulting address is out of bounds.
297
+ *
298
+ * @example
299
+ * // Creates a 2x2 range starting at B2
300
+ * cellToRangeAddress("B2", 2, 2); // "B2:C3"
301
+ * // Creates a 2x2 range ending at B2
302
+ * cellToRangeAddress("B2", -2, -2); // "A1:B2"
303
+ * // Creates a 2x2 range starting at C3, extending 2 rows down and 2 columns left
304
+ * cellToRangeAddress("B2", 2, -2)).toBe("A2:B3")
305
+ */
306
+ function cellToRangeAddress(cell, rows, cols) {
307
+ const { ax, ay } = (0, cartesianAddress_ts_1.addressToCartesian)(cell);
308
+ // Determine start and end coordinates
309
+ let startCol;
310
+ let endCol;
311
+ let startRow;
312
+ let endRow;
313
+ if (rows > 0) {
314
+ startRow = ay;
315
+ endRow = ay + rows - 1;
316
+ }
317
+ else if (rows < -1) {
318
+ startRow = ay + rows + 1;
319
+ endRow = ay;
320
+ }
321
+ else {
322
+ throw new InvalidArgumentError_ts_1.default("rows must not be zero or -1");
323
+ }
324
+ if (cols > 0) {
325
+ startCol = ax;
326
+ endCol = ax + cols - 1;
327
+ }
328
+ else if (cols < -1) {
329
+ startCol = ax + cols + 1;
330
+ endCol = ax;
331
+ }
332
+ else {
333
+ throw new InvalidArgumentError_ts_1.default("cols must not be zero or -1");
334
+ }
335
+ if (Math.min(startCol, endCol) < firstColumnOffset || Math.max(startCol, endCol) > lastColumnOffset || Math.min(startRow, endRow) < firstRowOffset || Math.max(startRow, endRow) > lastRowOffset) {
336
+ throw new InvalidArgumentError_ts_1.default(`Resulting address is out of bounds: rows [${Math.min(startRow, endRow) + 1},${Math.max(startRow, endRow) + 1}], cols [${Math.min(startCol, endCol) + 1},${Math.max(startCol, endCol) + 1}]`);
337
+ }
338
+ return (0, cartesianAddress_ts_1.cartesianToAddress)({
339
+ ax: Math.min(startCol, endCol),
340
+ bx: Math.max(startCol, endCol),
341
+ ay: Math.min(startRow, endRow),
342
+ by: Math.max(startRow, endRow),
343
+ });
344
+ }
282
345
  /**
283
346
  * Extracts a subrange from a spreadsheet-style A1 range (e.g., "A1:D10"),
284
347
  * allowing skip and take semantics on both rows and columns.
@@ -299,7 +362,7 @@ function countAddressColumns(address) {
299
362
  * subaddress("A1:D10", 0, -1); // All but last row: "A1:D9"
300
363
  * subaddress("A1:D10", 0, Infinity, -2, 1); // Second last column: "C1:C10"
301
364
  */
302
- function subaddress(address, skipRows = 0, takeRows = Number.POSITIVE_INFINITY, skipCols = 0, takeCols = Number.POSITIVE_INFINITY) {
365
+ function subAddress(address, skipRows = 0, takeRows = Number.POSITIVE_INFINITY, skipCols = 0, takeCols = Number.POSITIVE_INFINITY) {
303
366
  const { ax, bx, ay, by } = (0, cartesianAddress_ts_1.addressToCartesian)(address);
304
367
  const [startRow, endRow] = slice(ay, by, skipRows, takeRows);
305
368
  const [startCol, endCol] = slice(ax, bx, skipCols, takeCols);
@@ -344,7 +407,7 @@ function subaddress(address, skipRows = 0, takeRows = Number.POSITIVE_INFINITY,
344
407
  * @throws InvalidArgumentError if the requested rows or columns exceed the available range.
345
408
  */
346
409
  function subrange(rangeRef, skipRows = 0, takeRows = Number.POSITIVE_INFINITY, skipCols = 0, takeCols = Number.POSITIVE_INFINITY) {
347
- const address = subaddress(rangeRef.address, skipRows, takeRows, skipCols, takeCols);
410
+ const address = subAddress(rangeRef.address, skipRows, takeRows, skipCols, takeCols);
348
411
  return {
349
412
  ...rangeRef,
350
413
  address,
@@ -129,6 +129,26 @@ export declare function countAddressRows(address: Address): number;
129
129
  * @returns The number of columns in the address.
130
130
  */
131
131
  export declare function countAddressColumns(address: Address): number;
132
+ /**
133
+ * Creates a range from a single cell address, extending by the specified number of rows and columns.
134
+ * If rows/cols is positive, the cell is the start of the range; if negative, the cell is the end of the range.
135
+ *
136
+ * @param cell - The cell address to use as the anchor.
137
+ * @param rows - The number of rows for the range. Positive: cell is start; Negative: cell is end.
138
+ * @param cols - The number of columns for the range. Positive: cell is start; Negative: cell is end.
139
+ * @returns The created address range.
140
+ *
141
+ * @throws {InvalidArgumentError} If the resulting address is out of bounds.
142
+ *
143
+ * @example
144
+ * // Creates a 2x2 range starting at B2
145
+ * cellToRangeAddress("B2", 2, 2); // "B2:C3"
146
+ * // Creates a 2x2 range ending at B2
147
+ * cellToRangeAddress("B2", -2, -2); // "A1:B2"
148
+ * // Creates a 2x2 range starting at C3, extending 2 rows down and 2 columns left
149
+ * cellToRangeAddress("B2", 2, -2)).toBe("A2:B3")
150
+ */
151
+ export declare function cellToRangeAddress(cell: CellAddress, rows: number, cols: number): Address;
132
152
  /**
133
153
  * Extracts a subrange from a spreadsheet-style A1 range (e.g., "A1:D10"),
134
154
  * allowing skip and take semantics on both rows and columns.
@@ -149,7 +169,7 @@ export declare function countAddressColumns(address: Address): number;
149
169
  * subaddress("A1:D10", 0, -1); // All but last row: "A1:D9"
150
170
  * subaddress("A1:D10", 0, Infinity, -2, 1); // Second last column: "C1:C10"
151
171
  */
152
- export declare function subaddress(address: Address, skipRows?: number, takeRows?: number, skipCols?: number, takeCols?: number): Address;
172
+ export declare function subAddress(address: Address, skipRows?: number, takeRows?: number, skipCols?: number, takeCols?: number): Address;
153
173
  /**
154
174
  * Extracts a subrange from a WorkbookRangeRef using skip/take semantics.
155
175
  * @param rangeRef Range reference to extract the sub-range from.
@@ -1 +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;AAGnJ,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAkBtE,MAAM,MAAM,iBAAiB,GAAG;IAC/B,WAAW,EAAE,aAAa,CAAC;IAC3B,SAAS,EAAE,aAAa,CAAC;IACzB,QAAQ,EAAE,UAAU,C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,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAG/D;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAG7D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAG1D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAGzD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAG5D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAuCzF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,SAAI,EAAE,QAAQ,SAA2B,EAAE,QAAQ,SAAI,EAAE,QAAQ,SAA2B,GAAG,OAAO,CAqC1J;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,SAAI,EAAE,QAAQ,SAA2B,EAAE,QAAQ,SAAI,EAAE,QAAQ,SAA2B,GAAG,gBAAgB,CAM3K"}
@@ -6,6 +6,10 @@ const firstColumn = "A";
6
6
  const lastColumn = "XFD";
7
7
  const firstRow = "1";
8
8
  const lastRow = "1048576";
9
+ const firstColumnOffset = columnAddressToOffset(firstColumn);
10
+ const lastColumnOffset = columnAddressToOffset(lastColumn);
11
+ const firstRowOffset = rowAddressToOffset(firstRow);
12
+ const lastRowOffset = rowAddressToOffset(lastRow);
9
13
  const addressPattern = /^(?<sheet>(?:'[^']+'|[A-Za-z0-9_]+)!)?(?:(?<startColumn>[A-Z]+)?(?<startRow>\d+)?(?::(?<endColumn>[A-Z]+)?(?<endRow>\d+)?)?)$/;
10
14
  /**
11
15
  * Fixes address, removing an optional sheet prefix and ensuring it is a valid range.
@@ -253,6 +257,64 @@ export function countAddressColumns(address) {
253
257
  const components = decomposeAddress(address);
254
258
  return columnAddressToOffset(components.endColumn) - columnAddressToOffset(components.startColumn) + 1;
255
259
  }
260
+ /**
261
+ * Creates a range from a single cell address, extending by the specified number of rows and columns.
262
+ * If rows/cols is positive, the cell is the start of the range; if negative, the cell is the end of the range.
263
+ *
264
+ * @param cell - The cell address to use as the anchor.
265
+ * @param rows - The number of rows for the range. Positive: cell is start; Negative: cell is end.
266
+ * @param cols - The number of columns for the range. Positive: cell is start; Negative: cell is end.
267
+ * @returns The created address range.
268
+ *
269
+ * @throws {InvalidArgumentError} If the resulting address is out of bounds.
270
+ *
271
+ * @example
272
+ * // Creates a 2x2 range starting at B2
273
+ * cellToRangeAddress("B2", 2, 2); // "B2:C3"
274
+ * // Creates a 2x2 range ending at B2
275
+ * cellToRangeAddress("B2", -2, -2); // "A1:B2"
276
+ * // Creates a 2x2 range starting at C3, extending 2 rows down and 2 columns left
277
+ * cellToRangeAddress("B2", 2, -2)).toBe("A2:B3")
278
+ */
279
+ export function cellToRangeAddress(cell, rows, cols) {
280
+ const { ax, ay } = addressToCartesian(cell);
281
+ // Determine start and end coordinates
282
+ let startCol;
283
+ let endCol;
284
+ let startRow;
285
+ let endRow;
286
+ if (rows > 0) {
287
+ startRow = ay;
288
+ endRow = ay + rows - 1;
289
+ }
290
+ else if (rows < -1) {
291
+ startRow = ay + rows + 1;
292
+ endRow = ay;
293
+ }
294
+ else {
295
+ throw new InvalidArgumentError("rows must not be zero or -1");
296
+ }
297
+ if (cols > 0) {
298
+ startCol = ax;
299
+ endCol = ax + cols - 1;
300
+ }
301
+ else if (cols < -1) {
302
+ startCol = ax + cols + 1;
303
+ endCol = ax;
304
+ }
305
+ else {
306
+ throw new InvalidArgumentError("cols must not be zero or -1");
307
+ }
308
+ if (Math.min(startCol, endCol) < firstColumnOffset || Math.max(startCol, endCol) > lastColumnOffset || Math.min(startRow, endRow) < firstRowOffset || Math.max(startRow, endRow) > lastRowOffset) {
309
+ throw new InvalidArgumentError(`Resulting address is out of bounds: rows [${Math.min(startRow, endRow) + 1},${Math.max(startRow, endRow) + 1}], cols [${Math.min(startCol, endCol) + 1},${Math.max(startCol, endCol) + 1}]`);
310
+ }
311
+ return cartesianToAddress({
312
+ ax: Math.min(startCol, endCol),
313
+ bx: Math.max(startCol, endCol),
314
+ ay: Math.min(startRow, endRow),
315
+ by: Math.max(startRow, endRow),
316
+ });
317
+ }
256
318
  /**
257
319
  * Extracts a subrange from a spreadsheet-style A1 range (e.g., "A1:D10"),
258
320
  * allowing skip and take semantics on both rows and columns.
@@ -273,7 +335,7 @@ export function countAddressColumns(address) {
273
335
  * subaddress("A1:D10", 0, -1); // All but last row: "A1:D9"
274
336
  * subaddress("A1:D10", 0, Infinity, -2, 1); // Second last column: "C1:C10"
275
337
  */
276
- export function subaddress(address, skipRows = 0, takeRows = Number.POSITIVE_INFINITY, skipCols = 0, takeCols = Number.POSITIVE_INFINITY) {
338
+ export function subAddress(address, skipRows = 0, takeRows = Number.POSITIVE_INFINITY, skipCols = 0, takeCols = Number.POSITIVE_INFINITY) {
277
339
  const { ax, bx, ay, by } = addressToCartesian(address);
278
340
  const [startRow, endRow] = slice(ay, by, skipRows, takeRows);
279
341
  const [startCol, endCol] = slice(ax, bx, skipCols, takeCols);
@@ -318,7 +380,7 @@ export function subaddress(address, skipRows = 0, takeRows = Number.POSITIVE_INF
318
380
  * @throws InvalidArgumentError if the requested rows or columns exceed the available range.
319
381
  */
320
382
  export function subrange(rangeRef, skipRows = 0, takeRows = Number.POSITIVE_INFINITY, skipCols = 0, takeCols = Number.POSITIVE_INFINITY) {
321
- const address = subaddress(rangeRef.address, skipRows, takeRows, skipCols, takeCols);
383
+ const address = subAddress(rangeRef.address, skipRows, takeRows, skipCols, takeCols);
322
384
  return {
323
385
  ...rangeRef,
324
386
  address,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microsoft-graph",
3
- "version": "2.22.1",
3
+ "version": "2.22.2",
4
4
  "description": "Microsoft GraphAPI SDK for NodeJS",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",