microsoft-graph 1.0.5 → 1.0.6
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/operations/driveItem/initiateCopyDriveItem.d.ts +5 -0
- package/dist/operations/driveItem/initiateCopyDriveItem.d.ts.map +1 -0
- package/dist/operations/driveItem/initiateCopyDriveItem.js +21 -0
- package/dist/operations/driveItem/initiateCopyDriveItem.test.d.ts +2 -0
- package/dist/operations/driveItem/initiateCopyDriveItem.test.d.ts.map +1 -0
- package/dist/operations/driveItem/initiateCopyDriveItem.test.js +28 -0
- package/package.json +5 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DriveItemRef } from "../../models/DriveItemRef.ts";
|
|
2
|
+
import type { GraphOperation } from "../../models/GraphOperation.ts";
|
|
3
|
+
/** Initiate an asynchronous copy of an item. NOTE: The copied file may not be immediately available and polling is required. @see https://learn.microsoft.com/en-us/graph/api/driveitem-copy */
|
|
4
|
+
export default function initiateCopyDriveItem(srcFileRef: DriveItemRef, dstFolderRef: DriveItemRef, dstFileName: string): GraphOperation<void>;
|
|
5
|
+
//# sourceMappingURL=initiateCopyDriveItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initiateCopyDriveItem.d.ts","sourceRoot":"","sources":["../../../src/operations/driveItem/initiateCopyDriveItem.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGrE,gMAAgM;AAChM,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,GAAG,cAAc,CAAC,IAAI,CAAC,CAiB7I"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { operation } from "../../graphApi.js";
|
|
2
|
+
import { generatePath } from "../../services/templatedPaths.js";
|
|
3
|
+
/** Initiate an asynchronous copy of an item. NOTE: The copied file may not be immediately available and polling is required. @see https://learn.microsoft.com/en-us/graph/api/driveitem-copy */
|
|
4
|
+
export default function initiateCopyDriveItem(srcFileRef, dstFolderRef, dstFileName) {
|
|
5
|
+
return operation({
|
|
6
|
+
method: "POST",
|
|
7
|
+
path: generatePath("/sites/{site-id}/drives/{drive-id}/items/{item-id}/copy", srcFileRef),
|
|
8
|
+
headers: {
|
|
9
|
+
"content-type": "application/json",
|
|
10
|
+
},
|
|
11
|
+
body: {
|
|
12
|
+
name: dstFileName,
|
|
13
|
+
parentReference: {
|
|
14
|
+
siteId: dstFolderRef.siteId,
|
|
15
|
+
driveId: dstFolderRef.driveId,
|
|
16
|
+
id: dstFolderRef.itemId,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
responseTransform: () => undefined
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initiateCopyDriveItem.test.d.ts","sourceRoot":"","sources":["../../../src/operations/driveItem/initiateCopyDriveItem.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { getDefaultDriveRef } from "../../services/drive.js";
|
|
3
|
+
import { driveItemPath, } from "../../services/driveItem.js";
|
|
4
|
+
import { generateTempFileName } from "../../services/temporaryFiles.js";
|
|
5
|
+
import deleteDriveItemWithRetry from "../../tasks/deleteDriveItemWithRetry.js";
|
|
6
|
+
import createFolder from "../drive/createFolder.js";
|
|
7
|
+
import getDriveItemByPath from "./getDriveItemByPath.js";
|
|
8
|
+
import initiateCopyDriveItem from "./initiateCopyDriveItem.js";
|
|
9
|
+
describe("initiateCopyDriveItem", () => {
|
|
10
|
+
it("can copy an item to a new folder", { timeout: 10000 }, async () => {
|
|
11
|
+
const driveRef = getDefaultDriveRef();
|
|
12
|
+
const srcFolderName = generateTempFileName();
|
|
13
|
+
const srcFolder = await createFolder(driveRef, srcFolderName);
|
|
14
|
+
const dstFolderName = generateTempFileName();
|
|
15
|
+
const dstFolder = await createFolder(driveRef, dstFolderName);
|
|
16
|
+
try {
|
|
17
|
+
const copiedItemName = `${srcFolderName}-copy`;
|
|
18
|
+
await initiateCopyDriveItem(srcFolder, dstFolder, copiedItemName);
|
|
19
|
+
const copyPath = driveItemPath(dstFolderName, copiedItemName);
|
|
20
|
+
const copyFolder = await getDriveItemByPath(driveRef, copyPath);
|
|
21
|
+
expect(copyFolder.webUrl?.endsWith(copyPath)).toBeTruthy();
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
await deleteDriveItemWithRetry(srcFolder);
|
|
25
|
+
await deleteDriveItemWithRetry(dstFolder);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "microsoft-graph",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Microsoft GraphAPI SDK for NodeJS",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -190,6 +190,10 @@
|
|
|
190
190
|
"import": "./dist/operations/driveItem/getDriveItemContent.js",
|
|
191
191
|
"types": "./dist/operations/driveItem/getDriveItemContent.d.ts"
|
|
192
192
|
},
|
|
193
|
+
"./operations/driveItem/initiateCopyDriveItem": {
|
|
194
|
+
"import": "./dist/operations/driveItem/initiateCopyDriveItem.js",
|
|
195
|
+
"types": "./dist/operations/driveItem/initiateCopyDriveItem.d.ts"
|
|
196
|
+
},
|
|
193
197
|
"./operations/driveItem/listDriveItems": {
|
|
194
198
|
"import": "./dist/operations/driveItem/listDriveItems.js",
|
|
195
199
|
"types": "./dist/operations/driveItem/listDriveItems.d.ts"
|