@pnp/nodejs 3.21.0-v3nightly.20231220 → 4.0.0-alpha0
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/package.json +35 -35
- package/sp-extensions/stream.d.ts +0 -23
- package/sp-extensions/stream.d.ts.map +1 -1
- package/sp-extensions/stream.js +103 -71
- package/sp-extensions/stream.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
2
|
+
"name": "@pnp/nodejs",
|
|
3
|
+
"version": "4.0.0-alpha0",
|
|
4
|
+
"description": "pnp - provides functionality enabling the @pnp libraries within nodejs",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"typings": "./index",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@azure/msal-node": "1.18.3",
|
|
9
|
+
"@pnp/core": "4.0.0-alpha0",
|
|
10
|
+
"@pnp/logging": "4.0.0-alpha0",
|
|
11
|
+
"@pnp/queryable": "4.0.0-alpha0",
|
|
12
|
+
"@pnp/sp": "4.0.0-alpha0",
|
|
13
|
+
"@pnp/graph": "4.0.0-alpha0",
|
|
14
|
+
"node-fetch": "3.3.2",
|
|
15
|
+
"tslib": "2.6.2"
|
|
16
|
+
},
|
|
17
|
+
"funding": {
|
|
18
|
+
"type": "individual",
|
|
19
|
+
"url": "https://github.com/sponsors/patrick-rodgers/"
|
|
20
|
+
},
|
|
21
|
+
"type": "module",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=14.15.1"
|
|
24
|
+
},
|
|
25
|
+
"author": {
|
|
26
|
+
"name": "Microsoft and other contributors"
|
|
27
|
+
},
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/pnp/pnpjs/issues"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/pnp/pnpjs",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git:github.com/pnp/pnpjs"
|
|
36
|
+
}
|
|
37
37
|
}
|
|
@@ -1,30 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { IFileAddResult, IFileUploadProgressData } from "@pnp/sp/files/index.js";
|
|
3
|
-
import { ReadStream } from "fs";
|
|
4
2
|
import { PassThrough } from "stream";
|
|
5
3
|
export interface IResponseBodyStream {
|
|
6
4
|
body: PassThrough;
|
|
7
5
|
knownLength: number;
|
|
8
6
|
}
|
|
9
|
-
declare type ProgressFunc = (data: IFileUploadProgressData) => void;
|
|
10
|
-
declare type ChunkedResult = Promise<IFileAddResult>;
|
|
11
|
-
declare module "@pnp/sp/files/types" {
|
|
12
|
-
interface IFile {
|
|
13
|
-
/**
|
|
14
|
-
* Gets a PassThrough stream representing the file
|
|
15
|
-
*/
|
|
16
|
-
getStream(): Promise<IResponseBodyStream>;
|
|
17
|
-
/**
|
|
18
|
-
* Sets a file stream content chunk
|
|
19
|
-
*/
|
|
20
|
-
setStreamContentChunked(stream: ReadStream, progress?: ProgressFunc): ChunkedResult;
|
|
21
|
-
}
|
|
22
|
-
interface IFiles {
|
|
23
|
-
/**
|
|
24
|
-
* Adds a file stream in chunks
|
|
25
|
-
*/
|
|
26
|
-
addChunked(url: string, content: Blob | ReadStream, progress?: ProgressFunc, shouldOverWrite?: boolean, chunkSize?: number): ChunkedResult;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
export {};
|
|
30
7
|
//# sourceMappingURL=stream.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../../packages/nodejs/sp-extensions/stream.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../../packages/nodejs/sp-extensions/stream.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAKrC,MAAM,WAAW,mBAAmB;IAChC,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACvB"}
|
package/sp-extensions/stream.js
CHANGED
|
@@ -1,72 +1,104 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
})
|
|
1
|
+
export {};
|
|
2
|
+
// extendFactory(File, {
|
|
3
|
+
// getStream(): Promise<IResponseBodyStream> {
|
|
4
|
+
// return File(this, "$value").using(StreamParse())(headers({ "binaryStringResponseBody": "true" }));
|
|
5
|
+
// },
|
|
6
|
+
// /**
|
|
7
|
+
// * Sets the contents of a file using a chunked upload approach. Not supported in batching.
|
|
8
|
+
// *
|
|
9
|
+
// * @param stream The file to upload (as readable stream)
|
|
10
|
+
// * @param progress A callback function which can be used to track the progress of the upload
|
|
11
|
+
// */
|
|
12
|
+
// setStreamContentChunked: asCancelableScope(async function (this: IFile, stream: ReadStream, progress?: (data: IFileUploadProgressData) => void): Promise<IFileAddResult> {
|
|
13
|
+
// if (!isFunc(progress)) {
|
|
14
|
+
// progress = () => void (0);
|
|
15
|
+
// }
|
|
16
|
+
// const uploadId = getGUID();
|
|
17
|
+
// const fileRef = File(this).using(CancelAction(() => {
|
|
18
|
+
// return File(this).cancelUpload(uploadId);
|
|
19
|
+
// }));
|
|
20
|
+
// let blockNumber = -1;
|
|
21
|
+
// let pointer = 0;
|
|
22
|
+
// for await (const chunk of stream) {
|
|
23
|
+
// blockNumber++;
|
|
24
|
+
// progress({
|
|
25
|
+
// uploadId,
|
|
26
|
+
// blockNumber,
|
|
27
|
+
// chunkSize: chunk.length,
|
|
28
|
+
// currentPointer: pointer,
|
|
29
|
+
// fileSize: -1,
|
|
30
|
+
// stage: blockNumber === 0 ? "starting" : "continue",
|
|
31
|
+
// totalBlocks: -1,
|
|
32
|
+
// });
|
|
33
|
+
// if (blockNumber === 0) {
|
|
34
|
+
// pointer = await fileRef.startUpload(uploadId, chunk);
|
|
35
|
+
// } else {
|
|
36
|
+
// pointer = await fileRef.continueUpload(uploadId, pointer, chunk);
|
|
37
|
+
// }
|
|
38
|
+
// }
|
|
39
|
+
// progress({ uploadId, blockNumber, chunkSize: -1, currentPointer: -1, fileSize: -1, stage: "finishing", totalBlocks: -1 });
|
|
40
|
+
// return await fileRef.finishUpload(uploadId, pointer, Buffer.from([]));
|
|
41
|
+
// }),
|
|
42
|
+
// });
|
|
43
|
+
// extendFactory(Files, {
|
|
44
|
+
// /**
|
|
45
|
+
// * Uploads a file. Not supported for batching
|
|
46
|
+
// *
|
|
47
|
+
// * @param url The folder-relative url of the file
|
|
48
|
+
// * @param content The Blob file content or File readable stream to add
|
|
49
|
+
// * @param progress A callback function which can be used to track the progress of the upload
|
|
50
|
+
// * @param shouldOverWrite Should a file with the same name in the same location be overwritten? (default: true)
|
|
51
|
+
// * @param chunkSize The size of each file slice, in bytes (default: 10485760)
|
|
52
|
+
// * @returns The new File and the raw response.
|
|
53
|
+
// */
|
|
54
|
+
// addChunked: asCancelableScope(async function (
|
|
55
|
+
// this: IFiles,
|
|
56
|
+
// url: string,
|
|
57
|
+
// content: Blob | ReadStream,
|
|
58
|
+
// progress?: (data: IFileUploadProgressData) => void,
|
|
59
|
+
// shouldOverWrite = true,
|
|
60
|
+
// chunkSize = 10485760
|
|
61
|
+
// ) {
|
|
62
|
+
// const response = await spPost(Files(this, `add(overwrite=${shouldOverWrite},url='${encodePath(url)}')`));
|
|
63
|
+
// const file = fileFromServerRelativePath(this, response.ServerRelativeUrl);
|
|
64
|
+
// file.using(CancelAction(async () => {
|
|
65
|
+
// return File(file).delete();
|
|
66
|
+
// }));
|
|
67
|
+
// if ("function" === typeof (content as ReadStream).read) {
|
|
68
|
+
// return file.setStreamContentChunked(content as ReadStream, progress);
|
|
69
|
+
// }
|
|
70
|
+
// return file.setContentChunked(content as Blob, progress, chunkSize);
|
|
71
|
+
// }),
|
|
72
|
+
// });
|
|
73
|
+
// // these are needed to avoid a type/name not found issue where TSC doesn't properly keep
|
|
74
|
+
// // the references used within the module declarations below
|
|
75
|
+
// type ProgressFunc = (data: IFileUploadProgressData) => void;
|
|
76
|
+
// type ChunkedResult = Promise<IFileAddResult>;
|
|
77
|
+
// declare module "@pnp/sp/files/types" {
|
|
78
|
+
// interface IFile {
|
|
79
|
+
// /**
|
|
80
|
+
// * Gets a PassThrough stream representing the file
|
|
81
|
+
// */
|
|
82
|
+
// getStream(): Promise<IResponseBodyStream>;
|
|
83
|
+
// /**
|
|
84
|
+
// * Sets a file stream content chunk
|
|
85
|
+
// */
|
|
86
|
+
// setStreamContentChunked(
|
|
87
|
+
// stream: ReadStream,
|
|
88
|
+
// progress?: ProgressFunc,
|
|
89
|
+
// ): ChunkedResult;
|
|
90
|
+
// }
|
|
91
|
+
// interface IFiles {
|
|
92
|
+
// /**
|
|
93
|
+
// * Adds a file stream in chunks
|
|
94
|
+
// */
|
|
95
|
+
// addChunked(
|
|
96
|
+
// url: string,
|
|
97
|
+
// content: Blob | ReadStream,
|
|
98
|
+
// progress?: ProgressFunc,
|
|
99
|
+
// shouldOverWrite?: boolean,
|
|
100
|
+
// chunkSize?: number,
|
|
101
|
+
// ): ChunkedResult;
|
|
102
|
+
// }
|
|
103
|
+
// }
|
|
72
104
|
//# sourceMappingURL=stream.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../../../packages/nodejs/sp-extensions/stream.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../../../packages/nodejs/sp-extensions/stream.ts"],"names":[],"mappings":";AAcA,wBAAwB;AAExB,kDAAkD;AAClD,6GAA6G;AAC7G,SAAS;AAET,UAAU;AACV,iGAAiG;AACjG,SAAS;AACT,+DAA+D;AAC/D,mGAAmG;AACnG,UAAU;AACV,iLAAiL;AAEjL,mCAAmC;AACnC,yCAAyC;AACzC,YAAY;AAEZ,sCAAsC;AAEtC,gEAAgE;AAChE,wDAAwD;AACxD,eAAe;AAEf,gCAAgC;AAChC,2BAA2B;AAE3B,8CAA8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