microsoft-graph 3.10.3 → 3.10.5

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.
@@ -39,4 +39,10 @@ export declare function splitDriveItemPath(filePath: DriveItemPath): {
39
39
  * @returns File extension ie. "txt", "jpg"
40
40
  */
41
41
  export declare function getDriveItemExtension(item: DriveItem): string;
42
+ /**
43
+ * Gets the parent for a drive item. Typically this is the folder of a file.
44
+ * @param item Drive item.
45
+ * @returns Parent drive item.
46
+ */
47
+ export declare function getDriveItemParent(item: DriveItem & DriveItemRef): DriveItemRef;
42
48
  //# sourceMappingURL=driveItem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"driveItem.d.ts","sourceRoot":"","sources":["../../../src/services/driveItem.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAIlE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAMvF,eAAO,MAAM,qBAAqB,SAAS,CAAC;AAC5C,eAAO,MAAM,2BAA2B,SAAS,CAAC;AAElD,eAAO,MAAM,iBAAiB,eAAqB,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,aAAa,CAkClE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,YAAY,CAWpG;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,aAAa,GAAG;IAAE,UAAU,EAAE,aAAa,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAa3G;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAG7D"}
1
+ {"version":3,"file":"driveItem.d.ts","sourceRoot":"","sources":["../../../src/services/driveItem.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAIlE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAMvF,eAAO,MAAM,qBAAqB,SAAS,CAAC;AAC5C,eAAO,MAAM,2BAA2B,SAAS,CAAC;AAElD,eAAO,MAAM,iBAAiB,eAAqB,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,aAAa,CAkClE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,YAAY,CAWpG;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,aAAa,GAAG;IAAE,UAAU,EAAE,aAAa,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAa3G;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAG7D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,YAAY,CAc/E"}
@@ -13,6 +13,7 @@ exports.driveItemPath = driveItemPath;
13
13
  exports.createDriveItemRef = createDriveItemRef;
14
14
  exports.splitDriveItemPath = splitDriveItemPath;
15
15
  exports.getDriveItemExtension = getDriveItemExtension;
16
+ exports.getDriveItemParent = getDriveItemParent;
16
17
  const node_path_1 = __importDefault(require("node:path"));
17
18
  const InvalidArgumentError_ts_1 = __importDefault(require("../errors/InvalidArgumentError.js"));
18
19
  const ProtocolError_ts_1 = __importDefault(require("../errors/ProtocolError.js"));
@@ -98,3 +99,21 @@ function getDriveItemExtension(item) {
98
99
  const ext = node_path_1.default.extname(item.name ?? "").toLowerCase();
99
100
  return ext.startsWith(".") ? ext.slice(1) : ext;
100
101
  }
102
+ /**
103
+ * Gets the parent for a drive item. Typically this is the folder of a file.
104
+ * @param item Drive item.
105
+ * @returns Parent drive item.
106
+ */
107
+ function getDriveItemParent(item) {
108
+ const parentId = item.parentReference?.id;
109
+ if (!parentId) {
110
+ throw new Error("Parent reference not found for the item.");
111
+ }
112
+ const parentRef = {
113
+ context: item.context,
114
+ siteId: item.siteId,
115
+ driveId: item.driveId,
116
+ itemId: parentId,
117
+ };
118
+ return parentRef;
119
+ }
@@ -74,7 +74,7 @@ async function execute(request) {
74
74
  retryAfterMilliseconds = requestedRetryAfterSeconds * 1000;
75
75
  }
76
76
  else {
77
- retryAfterMilliseconds += Math.random() * 1000; // Add some randomness to the retry delay to avoid thundering herd problem
77
+ retryAfterMilliseconds += Math.round(Math.random() * 1000); // Add some randomness to the retry delay to avoid thundering herd problem
78
78
  }
79
79
  errorLog += waitToString(retryAfterMilliseconds);
80
80
  await (0, sleep_ts_1.sleep)(retryAfterMilliseconds);
@@ -196,7 +196,7 @@ function responseToString(response) {
196
196
  return message;
197
197
  }
198
198
  function waitToString(milliseconds) {
199
- return ` ⏳ Wait ${milliseconds}ms for retry.\n`;
199
+ return ` ⏳ Wait ${milliseconds.toLocaleString()}ms for retry.\n`;
200
200
  }
201
201
  function errorObjectToString(obj) {
202
202
  const maxLength = 1024;
@@ -39,4 +39,10 @@ export declare function splitDriveItemPath(filePath: DriveItemPath): {
39
39
  * @returns File extension ie. "txt", "jpg"
40
40
  */
41
41
  export declare function getDriveItemExtension(item: DriveItem): string;
42
+ /**
43
+ * Gets the parent for a drive item. Typically this is the folder of a file.
44
+ * @param item Drive item.
45
+ * @returns Parent drive item.
46
+ */
47
+ export declare function getDriveItemParent(item: DriveItem & DriveItemRef): DriveItemRef;
42
48
  //# sourceMappingURL=driveItem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"driveItem.d.ts","sourceRoot":"","sources":["../../../src/services/driveItem.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAIlE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAMvF,eAAO,MAAM,qBAAqB,SAAS,CAAC;AAC5C,eAAO,MAAM,2BAA2B,SAAS,CAAC;AAElD,eAAO,MAAM,iBAAiB,eAAqB,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,aAAa,CAkClE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,YAAY,CAWpG;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,aAAa,GAAG;IAAE,UAAU,EAAE,aAAa,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAa3G;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAG7D"}
1
+ {"version":3,"file":"driveItem.d.ts","sourceRoot":"","sources":["../../../src/services/driveItem.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAIlE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAMvF,eAAO,MAAM,qBAAqB,SAAS,CAAC;AAC5C,eAAO,MAAM,2BAA2B,SAAS,CAAC;AAElD,eAAO,MAAM,iBAAiB,eAAqB,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,aAAa,CAkClE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,YAAY,CAWpG;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,aAAa,GAAG;IAAE,UAAU,EAAE,aAAa,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAa3G;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAG7D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,YAAY,CAc/E"}
@@ -88,3 +88,21 @@ export function getDriveItemExtension(item) {
88
88
  const ext = path.extname(item.name ?? "").toLowerCase();
89
89
  return ext.startsWith(".") ? ext.slice(1) : ext;
90
90
  }
91
+ /**
92
+ * Gets the parent for a drive item. Typically this is the folder of a file.
93
+ * @param item Drive item.
94
+ * @returns Parent drive item.
95
+ */
96
+ export function getDriveItemParent(item) {
97
+ const parentId = item.parentReference?.id;
98
+ if (!parentId) {
99
+ throw new Error("Parent reference not found for the item.");
100
+ }
101
+ const parentRef = {
102
+ context: item.context,
103
+ siteId: item.siteId,
104
+ driveId: item.driveId,
105
+ itemId: parentId,
106
+ };
107
+ return parentRef;
108
+ }
@@ -66,7 +66,7 @@ export async function execute(request) {
66
66
  retryAfterMilliseconds = requestedRetryAfterSeconds * 1000;
67
67
  }
68
68
  else {
69
- retryAfterMilliseconds += Math.random() * 1000; // Add some randomness to the retry delay to avoid thundering herd problem
69
+ retryAfterMilliseconds += Math.round(Math.random() * 1000); // Add some randomness to the retry delay to avoid thundering herd problem
70
70
  }
71
71
  errorLog += waitToString(retryAfterMilliseconds);
72
72
  await sleep(retryAfterMilliseconds);
@@ -188,7 +188,7 @@ function responseToString(response) {
188
188
  return message;
189
189
  }
190
190
  function waitToString(milliseconds) {
191
- return ` ⏳ Wait ${milliseconds}ms for retry.\n`;
191
+ return ` ⏳ Wait ${milliseconds.toLocaleString()}ms for retry.\n`;
192
192
  }
193
193
  function errorObjectToString(obj) {
194
194
  const maxLength = 1024;
@@ -105,6 +105,28 @@ File extension ie. "txt", "jpg"
105
105
 
106
106
  ***
107
107
 
108
+ ### getDriveItemParent()
109
+
110
+ > **getDriveItemParent**(`item`): [`DriveItemRef`](DriveItem-1.md#driveitemref)
111
+
112
+ Defined in: [src/services/driveItem.ts:120](https://github.com/Future-Secure-AI/microsoft-graph/blob/main/src/services/driveItem.ts#L120)
113
+
114
+ Gets the parent for a drive item. Typically this is the folder of a file.
115
+
116
+ #### Parameters
117
+
118
+ | Parameter | Type | Description |
119
+ | ------ | ------ | ------ |
120
+ | `item` | `DriveItem` & [`SiteRef`](Site-1.md#siteref) & `object` & `object` | Drive item. |
121
+
122
+ #### Returns
123
+
124
+ [`DriveItemRef`](DriveItem-1.md#driveitemref)
125
+
126
+ Parent drive item.
127
+
128
+ ***
129
+
108
130
  ### splitDriveItemPath()
109
131
 
110
132
  > **splitDriveItemPath**(`filePath`): `object`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microsoft-graph",
3
- "version": "3.10.3",
3
+ "version": "3.10.5",
4
4
  "description": "Microsoft GraphAPI SDK for NodeJS",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",