@pnp/sp 2.8.0 → 2.12.0
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/LICENSE +25 -25
- package/appcatalog/index.d.ts +8 -8
- package/appcatalog/index.js +30 -30
- package/appcatalog/types.d.ts +81 -81
- package/appcatalog/types.d.ts.map +1 -1
- package/appcatalog/types.js +177 -177
- package/appcatalog/types.js.map +1 -1
- package/appcatalog/web.d.ts +16 -16
- package/appcatalog/web.js +6 -6
- package/attachments/index.d.ts +2 -2
- package/attachments/index.js +2 -2
- package/attachments/item.d.ts +12 -12
- package/attachments/item.js +4 -4
- package/attachments/types.d.ts +92 -92
- package/attachments/types.js +240 -240
- package/batch.d.ts +17 -17
- package/batch.js +223 -223
- package/clientside-pages/funcs.d.ts +22 -22
- package/clientside-pages/funcs.js +25 -25
- package/clientside-pages/index.d.ts +2 -2
- package/clientside-pages/index.js +2 -2
- package/clientside-pages/types.d.ts +496 -494
- package/clientside-pages/types.d.ts.map +1 -1
- package/clientside-pages/types.js +1496 -1487
- package/clientside-pages/types.js.map +1 -1
- package/clientside-pages/web.d.ts +41 -41
- package/clientside-pages/web.js +57 -57
- package/column-defaults/folder.d.ts +27 -27
- package/column-defaults/folder.js +82 -82
- package/column-defaults/index.d.ts +3 -3
- package/column-defaults/index.js +2 -2
- package/column-defaults/list.d.ts +19 -19
- package/column-defaults/list.js +198 -198
- package/column-defaults/types.d.ts +21 -21
- package/column-defaults/types.js +1 -1
- package/comments/clientside-page.d.ts +57 -57
- package/comments/clientside-page.d.ts.map +1 -1
- package/comments/clientside-page.js +136 -136
- package/comments/index.d.ts +2 -2
- package/comments/index.js +2 -2
- package/comments/item.d.ts +29 -29
- package/comments/item.js +47 -47
- package/comments/item.js.map +1 -1
- package/comments/types.d.ts +107 -107
- package/comments/types.d.ts.map +1 -1
- package/comments/types.js +145 -145
- package/comments/types.js.map +1 -1
- package/content-types/index.d.ts +4 -4
- package/content-types/index.js +4 -4
- package/content-types/item.d.ts +12 -12
- package/content-types/item.js +4 -4
- package/content-types/list.d.ts +12 -12
- package/content-types/list.js +4 -4
- package/content-types/types.d.ts +107 -107
- package/content-types/types.js +166 -166
- package/content-types/web.d.ts +12 -12
- package/content-types/web.js +4 -4
- package/decorators.d.ts +11 -11
- package/decorators.js +28 -28
- package/features/index.d.ts +3 -3
- package/features/index.js +3 -3
- package/features/site.d.ts +12 -12
- package/features/site.js +4 -4
- package/features/types.d.ts +47 -47
- package/features/types.js +109 -109
- package/features/web.d.ts +12 -12
- package/features/web.js +4 -4
- package/fields/index.d.ts +4 -4
- package/fields/index.js +4 -4
- package/fields/list.d.ts +12 -12
- package/fields/list.js +4 -4
- package/fields/types.d.ts +368 -368
- package/fields/types.js +624 -624
- package/fields/web.d.ts +17 -17
- package/fields/web.js +5 -5
- package/files/folder.d.ts +12 -12
- package/files/folder.js +4 -4
- package/files/index.d.ts +4 -4
- package/files/index.js +4 -4
- package/files/item.d.ts +12 -12
- package/files/item.js +4 -4
- package/files/types.d.ts +421 -421
- package/files/types.js +853 -853
- package/files/types.js.map +1 -1
- package/files/web.d.ts +35 -35
- package/files/web.js +15 -15
- package/folders/index.d.ts +4 -4
- package/folders/index.js +4 -4
- package/folders/item.d.ts +9 -9
- package/folders/item.js +4 -4
- package/folders/list.d.ts +12 -12
- package/folders/list.js +4 -4
- package/folders/types.d.ts +207 -207
- package/folders/types.js +433 -433
- package/folders/types.js.map +1 -1
- package/folders/web.d.ts +39 -39
- package/folders/web.js +15 -15
- package/forms/index.d.ts +2 -2
- package/forms/index.js +2 -2
- package/forms/list.d.ts +9 -9
- package/forms/list.js +4 -4
- package/forms/types.d.ts +35 -35
- package/forms/types.js +41 -41
- package/hubsites/index.d.ts +12 -12
- package/hubsites/index.js +15 -15
- package/hubsites/site.d.ts +26 -26
- package/hubsites/site.js +39 -39
- package/hubsites/types.d.ts +55 -55
- package/hubsites/types.d.ts.map +1 -1
- package/hubsites/types.js +53 -53
- package/hubsites/web.d.ts +21 -21
- package/hubsites/web.js +23 -23
- package/index.d.ts +14 -14
- package/index.js +13 -13
- package/items/index.d.ts +2 -2
- package/items/index.js +2 -2
- package/items/list.d.ts +9 -9
- package/items/list.js +4 -4
- package/items/types.d.ts +226 -226
- package/items/types.js +549 -549
- package/lists/index.d.ts +2 -2
- package/lists/index.js +2 -2
- package/lists/types.d.ts +495 -495
- package/lists/types.js +522 -522
- package/lists/types.js.map +1 -1
- package/lists/web.d.ts +43 -43
- package/lists/web.js +27 -27
- package/navigation/index.d.ts +8 -8
- package/navigation/index.js +14 -14
- package/navigation/types.d.ts +154 -154
- package/navigation/types.js +219 -219
- package/navigation/web.d.ts +13 -13
- package/navigation/web.js +4 -4
- package/odata.d.ts +5 -5
- package/odata.js +90 -90
- package/odata.js.map +1 -1
- package/operations.d.ts +9 -9
- package/operations.js +63 -63
- package/package.json +4 -4
- package/presets/all.d.ts +72 -72
- package/presets/all.js +72 -72
- package/presets/core.d.ts +11 -11
- package/presets/core.js +11 -11
- package/profiles/index.d.ts +7 -7
- package/profiles/index.js +13 -13
- package/profiles/types.d.ts +357 -357
- package/profiles/types.js +454 -454
- package/readme.md +21 -21
- package/regional-settings/content-type.d.ts +7 -7
- package/regional-settings/content-type.js +4 -4
- package/regional-settings/field.d.ts +7 -7
- package/regional-settings/field.js +4 -4
- package/regional-settings/funcs.d.ts +2 -2
- package/regional-settings/funcs.js +8 -8
- package/regional-settings/index.d.ts +6 -6
- package/regional-settings/index.js +6 -6
- package/regional-settings/list.d.ts +7 -7
- package/regional-settings/list.js +4 -4
- package/regional-settings/types.d.ts +111 -111
- package/regional-settings/types.js +159 -159
- package/regional-settings/user-custom-actions.d.ts +7 -7
- package/regional-settings/user-custom-actions.js +4 -4
- package/regional-settings/web.d.ts +12 -12
- package/regional-settings/web.js +7 -7
- package/related-items/index.d.ts +1 -1
- package/related-items/index.js +1 -1
- package/related-items/types.d.ts +76 -76
- package/related-items/types.js +103 -103
- package/related-items/web.d.ts +12 -12
- package/related-items/web.js +9 -9
- package/rest.d.ts +44 -44
- package/rest.js +72 -72
- package/search/index.d.ts +30 -30
- package/search/index.js +25 -25
- package/search/query.d.ts +62 -62
- package/search/query.js +302 -302
- package/search/suggest.d.ts +76 -76
- package/search/suggest.js +66 -66
- package/search/types.d.ts +426 -426
- package/search/types.js +57 -57
- package/security/funcs.d.ts +43 -43
- package/security/funcs.js +142 -142
- package/security/index.d.ts +4 -4
- package/security/index.js +4 -4
- package/security/item.d.ts +7 -7
- package/security/item.js +14 -14
- package/security/list.d.ts +7 -7
- package/security/list.js +14 -14
- package/security/types.d.ts +318 -318
- package/security/types.js +399 -399
- package/security/web.d.ts +9 -9
- package/security/web.js +15 -15
- package/sharepointqueryable.d.ts +135 -135
- package/sharepointqueryable.js +265 -265
- package/sharing/file.d.ts +18 -18
- package/sharing/file.js +116 -116
- package/sharing/folder.d.ts +9 -9
- package/sharing/folder.js +136 -136
- package/sharing/funcs.d.ts +62 -62
- package/sharing/funcs.js +239 -239
- package/sharing/funcs.js.map +1 -1
- package/sharing/index.d.ts +5 -5
- package/sharing/index.js +5 -5
- package/sharing/item.d.ts +16 -16
- package/sharing/item.js +15 -15
- package/sharing/types.d.ts +583 -583
- package/sharing/types.js +113 -113
- package/sharing/web.d.ts +19 -19
- package/sharing/web.js +76 -76
- package/site-designs/index.d.ts +8 -8
- package/site-designs/index.js +14 -14
- package/site-designs/types.d.ts +319 -319
- package/site-designs/types.js +203 -203
- package/site-designs/web.d.ts +25 -25
- package/site-designs/web.js +11 -11
- package/site-groups/index.d.ts +2 -2
- package/site-groups/index.js +2 -2
- package/site-groups/types.d.ts +89 -89
- package/site-groups/types.js +125 -125
- package/site-groups/web.d.ts +40 -40
- package/site-groups/web.js +30 -30
- package/site-scripts/index.d.ts +9 -9
- package/site-scripts/index.js +15 -15
- package/site-scripts/list.d.ts +12 -12
- package/site-scripts/list.js +24 -24
- package/site-scripts/types.d.ts +183 -183
- package/site-scripts/types.js +141 -141
- package/site-scripts/web.d.ts +13 -13
- package/site-scripts/web.js +5 -5
- package/site-users/index.d.ts +2 -2
- package/site-users/index.js +2 -2
- package/site-users/types.d.ts +138 -138
- package/site-users/types.js +122 -122
- package/site-users/web.d.ts +31 -31
- package/site-users/web.js +27 -27
- package/sites/index.d.ts +7 -7
- package/sites/index.js +13 -13
- package/sites/types.d.ts +147 -147
- package/sites/types.js +321 -321
- package/social/index.d.ts +10 -10
- package/social/index.js +13 -13
- package/social/types.d.ts +309 -309
- package/social/types.js +322 -322
- package/sphttpclient.d.ts +18 -18
- package/sphttpclient.js +189 -189
- package/splibconfig.d.ts +22 -22
- package/splibconfig.js +13 -13
- package/sputilities/index.d.ts +7 -7
- package/sputilities/index.js +13 -13
- package/sputilities/types.d.ts +130 -130
- package/sputilities/types.js +118 -118
- package/subscriptions/index.d.ts +2 -2
- package/subscriptions/index.js +2 -2
- package/subscriptions/list.d.ts +13 -13
- package/subscriptions/list.js +4 -4
- package/subscriptions/types.d.ts +54 -54
- package/subscriptions/types.js +111 -111
- package/taxonomy/index.d.ts +7 -7
- package/taxonomy/index.js +13 -13
- package/taxonomy/types.d.ts +200 -200
- package/taxonomy/types.js +347 -347
- package/taxonomy/types.js.map +1 -1
- package/telemetry.d.ts +12 -12
- package/telemetry.js +48 -48
- package/types.d.ts +218 -218
- package/types.js +79 -79
- package/user-custom-actions/index.d.ts +4 -4
- package/user-custom-actions/index.js +4 -4
- package/user-custom-actions/list.d.ts +12 -12
- package/user-custom-actions/list.js +4 -4
- package/user-custom-actions/site.d.ts +12 -12
- package/user-custom-actions/site.js +4 -4
- package/user-custom-actions/types.d.ts +82 -82
- package/user-custom-actions/types.js +93 -93
- package/user-custom-actions/web.d.ts +15 -15
- package/user-custom-actions/web.js +4 -4
- package/utils/escapeQueryStrValue.d.ts +1 -1
- package/utils/escapeQueryStrValue.js +19 -19
- package/utils/extractweburl.d.ts +1 -1
- package/utils/extractweburl.js +15 -15
- package/utils/file-names.d.ts +17 -17
- package/utils/file-names.js +38 -38
- package/utils/metadata.d.ts +5 -5
- package/utils/metadata.js +5 -5
- package/utils/objectToSPKeyValueCollection.d.ts +20 -20
- package/utils/objectToSPKeyValueCollection.js +16 -16
- package/utils/toResourcePath.d.ts +7 -7
- package/utils/toResourcePath.js +6 -6
- package/utils/toabsoluteurl.d.ts +7 -7
- package/utils/toabsoluteurl.js +61 -61
- package/views/index.d.ts +2 -2
- package/views/index.js +2 -2
- package/views/list.d.ts +23 -23
- package/views/list.js +8 -8
- package/views/types.d.ts +140 -140
- package/views/types.js +184 -184
- package/webparts/file.d.ts +15 -15
- package/webparts/file.js +6 -6
- package/webparts/index.d.ts +2 -2
- package/webparts/index.js +2 -2
- package/webparts/types.d.ts +83 -83
- package/webparts/types.js +117 -117
- package/webs/index.d.ts +16 -16
- package/webs/index.js +16 -16
- package/webs/types.d.ts +210 -210
- package/webs/types.js +295 -295
package/files/types.js
CHANGED
|
@@ -1,854 +1,854 @@
|
|
|
1
|
-
import { __awaiter, __decorate, __extends, __generator, __read, __spreadArray } from "tslib";
|
|
2
|
-
import { _SharePointQueryableInstance, _SharePointQueryableCollection, spInvokableFactory, SharePointQueryableInstance, deleteableWithETag, } from "../sharepointqueryable.js";
|
|
3
|
-
import { TextParser, BlobParser, JSONParser, BufferParser, headers, body } from "@pnp/odata";
|
|
4
|
-
import { assign, getGUID, isFunc, stringIsNullOrEmpty, isUrlAbsolute } from "@pnp/common";
|
|
5
|
-
import { Item } from "../items/index.js";
|
|
6
|
-
import { odataUrlFrom } from "../odata.js";
|
|
7
|
-
import { defaultPath } from "../decorators.js";
|
|
8
|
-
import { spPost } from "../operations.js";
|
|
9
|
-
import { escapeQueryStrValue } from "../utils/escapeQueryStrValue.js";
|
|
10
|
-
import { extractWebUrl } from "../utils/extractweburl.js";
|
|
11
|
-
import { tag } from "../telemetry.js";
|
|
12
|
-
import { toResourcePath } from "../utils/toResourcePath.js";
|
|
13
|
-
/**
|
|
14
|
-
* Describes a collection of File objects
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
var _Files = /** @class */ (function (_super) {
|
|
18
|
-
__extends(_Files, _super);
|
|
19
|
-
function _Files() {
|
|
20
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Gets a File by filename
|
|
24
|
-
*
|
|
25
|
-
* @param name The name of the file, including extension.
|
|
26
|
-
*/
|
|
27
|
-
_Files.prototype.getByName = function (name) {
|
|
28
|
-
if (/%#/.test(name)) {
|
|
29
|
-
throw Error("For file names containing % or # please use web.getFileByServerRelativePath");
|
|
30
|
-
}
|
|
31
|
-
return tag.configure(File(this).concat("('" + escapeQueryStrValue(name) + "')"), "fis.getByName");
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Uploads a file. Not supported for batching
|
|
35
|
-
*
|
|
36
|
-
* @param url The folder-relative url of the file.
|
|
37
|
-
* @param content The file contents
|
|
38
|
-
* @param shouldOverWrite Should a file with the same name in the same location be overwritten? (default: true)
|
|
39
|
-
* @returns The new File and the raw response.
|
|
40
|
-
*/
|
|
41
|
-
_Files.prototype.add = function (url, content, shouldOverWrite) {
|
|
42
|
-
if (shouldOverWrite === void 0) { shouldOverWrite = true; }
|
|
43
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
-
var response;
|
|
45
|
-
return __generator(this, function (_a) {
|
|
46
|
-
switch (_a.label) {
|
|
47
|
-
case 0: return [4 /*yield*/, spPost(Files(this, "add(overwrite=" + shouldOverWrite + ",url='" + escapeQueryStrValue(url) + "')"), {
|
|
48
|
-
body: content,
|
|
49
|
-
})];
|
|
50
|
-
case 1:
|
|
51
|
-
response = _a.sent();
|
|
52
|
-
return [2 /*return*/, {
|
|
53
|
-
data: response,
|
|
54
|
-
file: this.getByName(url),
|
|
55
|
-
}];
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Adds a file using the pound percent safe methods
|
|
62
|
-
*
|
|
63
|
-
* @param url Excoded url of the file
|
|
64
|
-
* @param content The file content
|
|
65
|
-
* @param parameters Additional parameters to control method behavior
|
|
66
|
-
*/
|
|
67
|
-
_Files.prototype.addUsingPath = function (url, content, parameters) {
|
|
68
|
-
if (parameters === void 0) { parameters = { Overwrite: false }; }
|
|
69
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
-
var path, resp;
|
|
71
|
-
return __generator(this, function (_a) {
|
|
72
|
-
switch (_a.label) {
|
|
73
|
-
case 0:
|
|
74
|
-
path = ["AddUsingPath(decodedurl='" + escapeQueryStrValue(url) + "'"];
|
|
75
|
-
if (parameters) {
|
|
76
|
-
if (parameters.Overwrite) {
|
|
77
|
-
path.push(",Overwrite=true");
|
|
78
|
-
}
|
|
79
|
-
if (parameters.AutoCheckoutOnInvalidData) {
|
|
80
|
-
path.push(",AutoCheckoutOnInvalidData=true");
|
|
81
|
-
}
|
|
82
|
-
if (!stringIsNullOrEmpty(parameters.XorHash)) {
|
|
83
|
-
path.push(",XorHash=" + escapeQueryStrValue(parameters.XorHash));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
path.push(")");
|
|
87
|
-
return [4 /*yield*/, spPost(Files(this, path.join("")), { body: content })];
|
|
88
|
-
case 1:
|
|
89
|
-
resp = _a.sent();
|
|
90
|
-
return [2 /*return*/, {
|
|
91
|
-
data: resp,
|
|
92
|
-
file: File(odataUrlFrom(resp)),
|
|
93
|
-
}];
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Uploads a file. Not supported for batching
|
|
100
|
-
*
|
|
101
|
-
* @param url The folder-relative url of the file.
|
|
102
|
-
* @param content The Blob file content to add
|
|
103
|
-
* @param progress A callback function which can be used to track the progress of the upload
|
|
104
|
-
* @param shouldOverWrite Should a file with the same name in the same location be overwritten? (default: true)
|
|
105
|
-
* @param chunkSize The size of each file slice, in bytes (default: 10485760)
|
|
106
|
-
* @returns The new File and the raw response.
|
|
107
|
-
*/
|
|
108
|
-
_Files.prototype.addChunked = function (url, content, progress, shouldOverWrite, chunkSize) {
|
|
109
|
-
if (shouldOverWrite === void 0) { shouldOverWrite = true; }
|
|
110
|
-
if (chunkSize === void 0) { chunkSize = 10485760; }
|
|
111
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
112
|
-
var response, odataUrl, file;
|
|
113
|
-
return __generator(this, function (_a) {
|
|
114
|
-
switch (_a.label) {
|
|
115
|
-
case 0: return [4 /*yield*/, spPost(this.clone(Files, "add(overwrite=" + shouldOverWrite + ",url='" + escapeQueryStrValue(url) + "')", false))];
|
|
116
|
-
case 1:
|
|
117
|
-
response = _a.sent();
|
|
118
|
-
odataUrl = odataUrlFrom(response);
|
|
119
|
-
if (!stringIsNullOrEmpty(odataUrl) && /%27/i.test(odataUrl)) {
|
|
120
|
-
odataUrl = odataUrl.replace(/%27/ig, "''");
|
|
121
|
-
}
|
|
122
|
-
file = File(odataUrl);
|
|
123
|
-
return [4 /*yield*/, file.setContentChunked(content, progress, chunkSize)];
|
|
124
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
};
|
|
129
|
-
/**
|
|
130
|
-
* Adds a ghosted file to an existing list or document library. Not supported for batching.
|
|
131
|
-
*
|
|
132
|
-
* @param fileUrl The server-relative url where you want to save the file.
|
|
133
|
-
* @param templateFileType The type of use to create the file.
|
|
134
|
-
* @returns The template file that was added and the raw response.
|
|
135
|
-
*/
|
|
136
|
-
_Files.prototype.addTemplateFile = function (fileUrl, templateFileType) {
|
|
137
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
138
|
-
var response;
|
|
139
|
-
return __generator(this, function (_a) {
|
|
140
|
-
switch (_a.label) {
|
|
141
|
-
case 0: return [4 /*yield*/, spPost(this.clone(Files, "addTemplateFile(urloffile='" + escapeQueryStrValue(fileUrl) + "',templatefiletype=" + templateFileType + ")", false))];
|
|
142
|
-
case 1:
|
|
143
|
-
response = _a.sent();
|
|
144
|
-
return [2 /*return*/, {
|
|
145
|
-
data: response,
|
|
146
|
-
file: File(odataUrlFrom(response)),
|
|
147
|
-
}];
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
__decorate([
|
|
153
|
-
tag("fis.add")
|
|
154
|
-
], _Files.prototype, "add", null);
|
|
155
|
-
__decorate([
|
|
156
|
-
tag("fis.addUsingPath")
|
|
157
|
-
], _Files.prototype, "addUsingPath", null);
|
|
158
|
-
__decorate([
|
|
159
|
-
tag("fis.addChunked")
|
|
160
|
-
], _Files.prototype, "addChunked", null);
|
|
161
|
-
__decorate([
|
|
162
|
-
tag("fis.addTemplateFile")
|
|
163
|
-
], _Files.prototype, "addTemplateFile", null);
|
|
164
|
-
_Files = __decorate([
|
|
165
|
-
defaultPath("files")
|
|
166
|
-
], _Files);
|
|
167
|
-
return _Files;
|
|
168
|
-
}(_SharePointQueryableCollection));
|
|
169
|
-
export { _Files };
|
|
170
|
-
export var Files = spInvokableFactory(_Files);
|
|
171
|
-
/**
|
|
172
|
-
* Describes a single File instance
|
|
173
|
-
*
|
|
174
|
-
*/
|
|
175
|
-
var _File = /** @class */ (function (_super) {
|
|
176
|
-
__extends(_File, _super);
|
|
177
|
-
function _File() {
|
|
178
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
179
|
-
_this.delete = deleteableWithETag("fi");
|
|
180
|
-
return _this;
|
|
181
|
-
}
|
|
182
|
-
Object.defineProperty(_File.prototype, "listItemAllFields", {
|
|
183
|
-
/**
|
|
184
|
-
* Gets a value that specifies the list item field values for the list item corresponding to the file.
|
|
185
|
-
*
|
|
186
|
-
*/
|
|
187
|
-
get: function () {
|
|
188
|
-
return tag.configure(SharePointQueryableInstance(this, "listItemAllFields"), "fi.listItemAllFields");
|
|
189
|
-
},
|
|
190
|
-
enumerable: false,
|
|
191
|
-
configurable: true
|
|
192
|
-
});
|
|
193
|
-
Object.defineProperty(_File.prototype, "versions", {
|
|
194
|
-
/**
|
|
195
|
-
* Gets a collection of versions
|
|
196
|
-
*
|
|
197
|
-
*/
|
|
198
|
-
get: function () {
|
|
199
|
-
return tag.configure(Versions(this), "fi.versions");
|
|
200
|
-
},
|
|
201
|
-
enumerable: false,
|
|
202
|
-
configurable: true
|
|
203
|
-
});
|
|
204
|
-
/**
|
|
205
|
-
* Approves the file submitted for content approval with the specified comment.
|
|
206
|
-
* Only documents in lists that are enabled for content approval can be approved.
|
|
207
|
-
*
|
|
208
|
-
* @param comment The comment for the approval.
|
|
209
|
-
*/
|
|
210
|
-
_File.prototype.approve = function (comment) {
|
|
211
|
-
if (comment === void 0) { comment = ""; }
|
|
212
|
-
return spPost(this.clone(File, "approve(comment='" + escapeQueryStrValue(comment) + "')"));
|
|
213
|
-
};
|
|
214
|
-
/**
|
|
215
|
-
* Stops the chunk upload session without saving the uploaded data. Does not support batching.
|
|
216
|
-
* If the file doesn’t already exist in the library, the partially uploaded file will be deleted.
|
|
217
|
-
* Use this in response to user action (as in a request to cancel an upload) or an error or exception.
|
|
218
|
-
* Use the uploadId value that was passed to the StartUpload method that started the upload session.
|
|
219
|
-
* This method is currently available only on Office 365.
|
|
220
|
-
*
|
|
221
|
-
* @param uploadId The unique identifier of the upload session.
|
|
222
|
-
*/
|
|
223
|
-
_File.prototype.cancelUpload = function (uploadId) {
|
|
224
|
-
return spPost(this.clone(File, "cancelUpload(uploadId=guid'" + uploadId + "')", false));
|
|
225
|
-
};
|
|
226
|
-
/**
|
|
227
|
-
* Checks the file in to a document library based on the check-in type.
|
|
228
|
-
*
|
|
229
|
-
* @param comment A comment for the check-in. Its length must be <= 1023.
|
|
230
|
-
* @param checkinType The check-in type for the file.
|
|
231
|
-
*/
|
|
232
|
-
_File.prototype.checkin = function (comment, checkinType) {
|
|
233
|
-
if (comment === void 0) { comment = ""; }
|
|
234
|
-
if (checkinType === void 0) { checkinType = CheckinType.Major; }
|
|
235
|
-
if (comment.length > 1023) {
|
|
236
|
-
throw Error("The maximum comment length is 1023 characters.");
|
|
237
|
-
}
|
|
238
|
-
return spPost(this.clone(File, "checkin(comment='" + escapeQueryStrValue(comment) + "',checkintype=" + checkinType + ")"));
|
|
239
|
-
};
|
|
240
|
-
/**
|
|
241
|
-
* Checks out the file from a document library.
|
|
242
|
-
*/
|
|
243
|
-
_File.prototype.checkout = function () {
|
|
244
|
-
return spPost(this.clone(File, "checkout"));
|
|
245
|
-
};
|
|
246
|
-
/**
|
|
247
|
-
* Copies the file to the destination url.
|
|
248
|
-
*
|
|
249
|
-
* @param url The absolute url or server relative url of the destination file path to copy to.
|
|
250
|
-
* @param shouldOverWrite Should a file with the same name in the same location be overwritten?
|
|
251
|
-
*/
|
|
252
|
-
_File.prototype.copyTo = function (url, shouldOverWrite) {
|
|
253
|
-
if (shouldOverWrite === void 0) { shouldOverWrite = true; }
|
|
254
|
-
return spPost(this.clone(File, "copyTo(strnewurl='" + escapeQueryStrValue(url) + "',boverwrite=" + shouldOverWrite + ")"));
|
|
255
|
-
};
|
|
256
|
-
/**
|
|
257
|
-
* Copies the file by path to destination path.
|
|
258
|
-
* Also works with different site collections.
|
|
259
|
-
*
|
|
260
|
-
* @param destUrl The absolute url or server relative url of the destination file path to copy to.
|
|
261
|
-
* @param shouldOverWrite Should a file with the same name in the same location be overwritten?
|
|
262
|
-
* @param keepBoth Keep both if file with the same name in the same location already exists? Only relevant when shouldOverWrite is set to false.
|
|
263
|
-
*/
|
|
264
|
-
_File.prototype.copyByPath = function (destUrl, shouldOverWrite, KeepBoth) {
|
|
265
|
-
if (KeepBoth === void 0) { KeepBoth = false; }
|
|
266
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
267
|
-
var _a, srcUrl, absoluteUrl, webBaseUrl, hostUrl;
|
|
268
|
-
return __generator(this, function (_b) {
|
|
269
|
-
switch (_b.label) {
|
|
270
|
-
case 0: return [4 /*yield*/, this.select("ServerRelativeUrl")()];
|
|
271
|
-
case 1:
|
|
272
|
-
_a = _b.sent(), srcUrl = _a.ServerRelativeUrl, absoluteUrl = _a["odata.id"];
|
|
273
|
-
webBaseUrl = extractWebUrl(absoluteUrl);
|
|
274
|
-
hostUrl = webBaseUrl.replace("://", "___").split("/")[0].replace("___", "://");
|
|
275
|
-
return [4 /*yield*/, spPost(File(webBaseUrl, "/_api/SP.MoveCopyUtil.CopyFileByPath(overwrite=@a1)?@a1=" + shouldOverWrite), body({
|
|
276
|
-
destPath: toResourcePath(isUrlAbsolute(destUrl) ? destUrl : "" + hostUrl + destUrl),
|
|
277
|
-
options: {
|
|
278
|
-
KeepBoth: KeepBoth,
|
|
279
|
-
ResetAuthorAndCreatedOnCopy: true,
|
|
280
|
-
ShouldBypassSharedLocks: true,
|
|
281
|
-
__metadata: {
|
|
282
|
-
type: "SP.MoveCopyOptions",
|
|
283
|
-
},
|
|
284
|
-
},
|
|
285
|
-
srcPath: toResourcePath(isUrlAbsolute(srcUrl) ? srcUrl : "" + hostUrl + srcUrl),
|
|
286
|
-
}))];
|
|
287
|
-
case 2:
|
|
288
|
-
_b.sent();
|
|
289
|
-
return [2 /*return*/];
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
};
|
|
294
|
-
/**
|
|
295
|
-
* Denies approval for a file that was submitted for content approval.
|
|
296
|
-
* Only documents in lists that are enabled for content approval can be denied.
|
|
297
|
-
*
|
|
298
|
-
* @param comment The comment for the denial.
|
|
299
|
-
*/
|
|
300
|
-
_File.prototype.deny = function (comment) {
|
|
301
|
-
if (comment === void 0) { comment = ""; }
|
|
302
|
-
if (comment.length > 1023) {
|
|
303
|
-
throw Error("The maximum comment length is 1023 characters.");
|
|
304
|
-
}
|
|
305
|
-
return spPost(this.clone(File, "deny(comment='" + escapeQueryStrValue(comment) + "')"));
|
|
306
|
-
};
|
|
307
|
-
/**
|
|
308
|
-
* Moves the file to the specified destination url.
|
|
309
|
-
*
|
|
310
|
-
* @param url The absolute url or server relative url of the destination file path to move to.
|
|
311
|
-
* @param moveOperations The bitwise MoveOperations value for how to move the file.
|
|
312
|
-
*/
|
|
313
|
-
_File.prototype.moveTo = function (url, moveOperations) {
|
|
314
|
-
if (moveOperations === void 0) { moveOperations = MoveOperations.Overwrite; }
|
|
315
|
-
return spPost(this.clone(File, "moveTo(newurl='" + escapeQueryStrValue(url) + "',flags=" + moveOperations + ")"));
|
|
316
|
-
};
|
|
317
|
-
/**
|
|
318
|
-
* Moves the file by path to the specified destination url.
|
|
319
|
-
* Also works with different site collections.
|
|
320
|
-
*
|
|
321
|
-
* @param destUrl The absolute url or server relative url of the destination file path to move to.
|
|
322
|
-
* @param shouldOverWrite Should a file with the same name in the same location be overwritten?
|
|
323
|
-
* @param keepBoth Keep both if file with the same name in the same location already exists? Only relevant when shouldOverWrite is set to false.
|
|
324
|
-
*/
|
|
325
|
-
_File.prototype.moveByPath = function (destUrl, shouldOverWrite, KeepBoth) {
|
|
326
|
-
if (KeepBoth === void 0) { KeepBoth = false; }
|
|
327
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
328
|
-
var _a, srcUrl, absoluteUrl, webBaseUrl, hostUrl;
|
|
329
|
-
return __generator(this, function (_b) {
|
|
330
|
-
switch (_b.label) {
|
|
331
|
-
case 0: return [4 /*yield*/, this.select("ServerRelativeUrl")()];
|
|
332
|
-
case 1:
|
|
333
|
-
_a = _b.sent(), srcUrl = _a.ServerRelativeUrl, absoluteUrl = _a["odata.id"];
|
|
334
|
-
webBaseUrl = extractWebUrl(absoluteUrl);
|
|
335
|
-
hostUrl = webBaseUrl.replace("://", "___").split("/")[0].replace("___", "://");
|
|
336
|
-
return [4 /*yield*/, spPost(File(webBaseUrl, "/_api/SP.MoveCopyUtil.MoveFileByPath(overwrite=@a1)?@a1=" + shouldOverWrite), body({
|
|
337
|
-
destPath: toResourcePath(isUrlAbsolute(destUrl) ? destUrl : "" + hostUrl + destUrl),
|
|
338
|
-
options: {
|
|
339
|
-
KeepBoth: KeepBoth,
|
|
340
|
-
ResetAuthorAndCreatedOnCopy: false,
|
|
341
|
-
ShouldBypassSharedLocks: true,
|
|
342
|
-
__metadata: {
|
|
343
|
-
type: "SP.MoveCopyOptions",
|
|
344
|
-
},
|
|
345
|
-
},
|
|
346
|
-
srcPath: toResourcePath(isUrlAbsolute(srcUrl) ? srcUrl : "" + hostUrl + srcUrl),
|
|
347
|
-
}))];
|
|
348
|
-
case 2:
|
|
349
|
-
_b.sent();
|
|
350
|
-
return [2 /*return*/];
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
});
|
|
354
|
-
};
|
|
355
|
-
/**
|
|
356
|
-
* Submits the file for content approval with the specified comment.
|
|
357
|
-
*
|
|
358
|
-
* @param comment The comment for the published file. Its length must be <= 1023.
|
|
359
|
-
*/
|
|
360
|
-
_File.prototype.publish = function (comment) {
|
|
361
|
-
if (comment === void 0) { comment = ""; }
|
|
362
|
-
if (comment.length > 1023) {
|
|
363
|
-
throw Error("The maximum comment length is 1023 characters.");
|
|
364
|
-
}
|
|
365
|
-
return spPost(this.clone(File, "publish(comment='" + escapeQueryStrValue(comment) + "')"));
|
|
366
|
-
};
|
|
367
|
-
/**
|
|
368
|
-
* Moves the file to the Recycle Bin and returns the identifier of the new Recycle Bin item.
|
|
369
|
-
*
|
|
370
|
-
* @returns The GUID of the recycled file.
|
|
371
|
-
*/
|
|
372
|
-
_File.prototype.recycle = function () {
|
|
373
|
-
return spPost(this.clone(File, "recycle"));
|
|
374
|
-
};
|
|
375
|
-
/**
|
|
376
|
-
* Deletes the file object with options.
|
|
377
|
-
*
|
|
378
|
-
* @param parameters Specifies the options to use when deleting a file.
|
|
379
|
-
*/
|
|
380
|
-
_File.prototype.deleteWithParams = function (parameters) {
|
|
381
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
382
|
-
return __generator(this, function (_a) {
|
|
383
|
-
return [2 /*return*/, spPost(this.clone(File, "DeleteWithParameters"), body({ parameters: parameters }))];
|
|
384
|
-
});
|
|
385
|
-
});
|
|
386
|
-
};
|
|
387
|
-
/**
|
|
388
|
-
* Reverts an existing checkout for the file.
|
|
389
|
-
*
|
|
390
|
-
*/
|
|
391
|
-
_File.prototype.undoCheckout = function () {
|
|
392
|
-
return spPost(this.clone(File, "undoCheckout"));
|
|
393
|
-
};
|
|
394
|
-
/**
|
|
395
|
-
* Removes the file from content approval or unpublish a major version.
|
|
396
|
-
*
|
|
397
|
-
* @param comment The comment for the unpublish operation. Its length must be <= 1023.
|
|
398
|
-
*/
|
|
399
|
-
_File.prototype.unpublish = function (comment) {
|
|
400
|
-
if (comment === void 0) { comment = ""; }
|
|
401
|
-
if (comment.length > 1023) {
|
|
402
|
-
throw Error("The maximum comment length is 1023 characters.");
|
|
403
|
-
}
|
|
404
|
-
return spPost(this.clone(File, "unpublish(comment='" + escapeQueryStrValue(comment) + "')"));
|
|
405
|
-
};
|
|
406
|
-
/**
|
|
407
|
-
* Checks to see if the file represented by this object exists
|
|
408
|
-
*
|
|
409
|
-
*/
|
|
410
|
-
_File.prototype.exists = function () {
|
|
411
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
412
|
-
var r, e_1;
|
|
413
|
-
return __generator(this, function (_a) {
|
|
414
|
-
switch (_a.label) {
|
|
415
|
-
case 0:
|
|
416
|
-
_a.trys.push([0, 2, , 3]);
|
|
417
|
-
return [4 /*yield*/, this.clone(File).select("Exists")()];
|
|
418
|
-
case 1:
|
|
419
|
-
r = _a.sent();
|
|
420
|
-
return [2 /*return*/, r.Exists];
|
|
421
|
-
case 2:
|
|
422
|
-
e_1 = _a.sent();
|
|
423
|
-
// this treats any error here as the file not existing, which
|
|
424
|
-
// might not be true, but is good enough.
|
|
425
|
-
return [2 /*return*/, false];
|
|
426
|
-
case 3: return [2 /*return*/];
|
|
427
|
-
}
|
|
428
|
-
});
|
|
429
|
-
});
|
|
430
|
-
};
|
|
431
|
-
/**
|
|
432
|
-
* Gets the contents of the file as text. Not supported in batching.
|
|
433
|
-
*
|
|
434
|
-
*/
|
|
435
|
-
_File.prototype.getText = function () {
|
|
436
|
-
return this.clone(File, "$value", false).usingParser(new TextParser())(headers({ "binaryStringResponseBody": "true" }));
|
|
437
|
-
};
|
|
438
|
-
/**
|
|
439
|
-
* Gets the contents of the file as a blob, does not work in Node.js. Not supported in batching.
|
|
440
|
-
*
|
|
441
|
-
*/
|
|
442
|
-
_File.prototype.getBlob = function () {
|
|
443
|
-
return this.clone(File, "$value", false).usingParser(new BlobParser())(headers({ "binaryStringResponseBody": "true" }));
|
|
444
|
-
};
|
|
445
|
-
/**
|
|
446
|
-
* Gets the contents of a file as an ArrayBuffer, works in Node.js. Not supported in batching.
|
|
447
|
-
*/
|
|
448
|
-
_File.prototype.getBuffer = function () {
|
|
449
|
-
return this.clone(File, "$value", false).usingParser(new BufferParser())(headers({ "binaryStringResponseBody": "true" }));
|
|
450
|
-
};
|
|
451
|
-
/**
|
|
452
|
-
* Gets the contents of a file as an ArrayBuffer, works in Node.js. Not supported in batching.
|
|
453
|
-
*/
|
|
454
|
-
_File.prototype.getJSON = function () {
|
|
455
|
-
return this.clone(File, "$value", false).usingParser(new JSONParser())(headers({ "binaryStringResponseBody": "true" }));
|
|
456
|
-
};
|
|
457
|
-
/**
|
|
458
|
-
* Sets the content of a file, for large files use setContentChunked. Not supported in batching.
|
|
459
|
-
*
|
|
460
|
-
* @param content The file content
|
|
461
|
-
*
|
|
462
|
-
*/
|
|
463
|
-
_File.prototype.setContent = function (content) {
|
|
464
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
465
|
-
return __generator(this, function (_a) {
|
|
466
|
-
switch (_a.label) {
|
|
467
|
-
case 0: return [4 /*yield*/, spPost(this.clone(File, "$value", false), {
|
|
468
|
-
body: content,
|
|
469
|
-
headers: {
|
|
470
|
-
"X-HTTP-Method": "PUT",
|
|
471
|
-
},
|
|
472
|
-
})];
|
|
473
|
-
case 1:
|
|
474
|
-
_a.sent();
|
|
475
|
-
return [2 /*return*/, File(this)];
|
|
476
|
-
}
|
|
477
|
-
});
|
|
478
|
-
});
|
|
479
|
-
};
|
|
480
|
-
/**
|
|
481
|
-
* Gets the associated list item for this file, loading the default properties
|
|
482
|
-
*/
|
|
483
|
-
_File.prototype.getItem = function () {
|
|
484
|
-
var selects = [];
|
|
485
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
486
|
-
selects[_i] = arguments[_i];
|
|
487
|
-
}
|
|
488
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
489
|
-
var q, d;
|
|
490
|
-
return __generator(this, function (_a) {
|
|
491
|
-
switch (_a.label) {
|
|
492
|
-
case 0:
|
|
493
|
-
q = this.listItemAllFields;
|
|
494
|
-
return [4 /*yield*/, q.select.apply(q, __spreadArray([], __read(selects)))()];
|
|
495
|
-
case 1:
|
|
496
|
-
d = _a.sent();
|
|
497
|
-
return [2 /*return*/, assign(Item(odataUrlFrom(d)), d)];
|
|
498
|
-
}
|
|
499
|
-
});
|
|
500
|
-
});
|
|
501
|
-
};
|
|
502
|
-
/**
|
|
503
|
-
* Sets the contents of a file using a chunked upload approach. Not supported in batching.
|
|
504
|
-
*
|
|
505
|
-
* @param file The file to upload
|
|
506
|
-
* @param progress A callback function which can be used to track the progress of the upload
|
|
507
|
-
* @param chunkSize The size of each file slice, in bytes (default: 10485760)
|
|
508
|
-
*/
|
|
509
|
-
_File.prototype.setContentChunked = function (file, progress, chunkSize) {
|
|
510
|
-
if (chunkSize === void 0) { chunkSize = 10485760; }
|
|
511
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
512
|
-
var fileSize, totalBlocks, uploadId, currentPointer, i;
|
|
513
|
-
return __generator(this, function (_a) {
|
|
514
|
-
switch (_a.label) {
|
|
515
|
-
case 0:
|
|
516
|
-
if (!isFunc(progress)) {
|
|
517
|
-
progress = function () { return null; };
|
|
518
|
-
}
|
|
519
|
-
fileSize = file.size;
|
|
520
|
-
totalBlocks = parseInt((fileSize / chunkSize).toString(), 10) + ((fileSize % chunkSize === 0) ? 1 : 0);
|
|
521
|
-
uploadId = getGUID();
|
|
522
|
-
// report that we are starting
|
|
523
|
-
progress({ uploadId: uploadId, blockNumber: 1, chunkSize: chunkSize, currentPointer: 0, fileSize: fileSize, stage: "starting", totalBlocks: totalBlocks });
|
|
524
|
-
return [4 /*yield*/, this.startUpload(uploadId, file.slice(0, chunkSize))];
|
|
525
|
-
case 1:
|
|
526
|
-
currentPointer = _a.sent();
|
|
527
|
-
i = 2;
|
|
528
|
-
_a.label = 2;
|
|
529
|
-
case 2:
|
|
530
|
-
if (!(i < totalBlocks)) return [3 /*break*/, 5];
|
|
531
|
-
progress({ uploadId: uploadId, blockNumber: i, chunkSize: chunkSize, currentPointer: currentPointer, fileSize: fileSize, stage: "continue", totalBlocks: totalBlocks });
|
|
532
|
-
return [4 /*yield*/, this.continueUpload(uploadId, currentPointer, file.slice(currentPointer, currentPointer + chunkSize))];
|
|
533
|
-
case 3:
|
|
534
|
-
currentPointer = _a.sent();
|
|
535
|
-
_a.label = 4;
|
|
536
|
-
case 4:
|
|
537
|
-
i++;
|
|
538
|
-
return [3 /*break*/, 2];
|
|
539
|
-
case 5:
|
|
540
|
-
progress({ uploadId: uploadId, blockNumber: totalBlocks, chunkSize: chunkSize, currentPointer: currentPointer, fileSize: fileSize, stage: "finishing", totalBlocks: totalBlocks });
|
|
541
|
-
return [2 /*return*/, this.finishUpload(uploadId, currentPointer, file.slice(currentPointer))];
|
|
542
|
-
}
|
|
543
|
-
});
|
|
544
|
-
});
|
|
545
|
-
};
|
|
546
|
-
/**
|
|
547
|
-
* Starts a new chunk upload session and uploads the first fragment.
|
|
548
|
-
* The current file content is not changed when this method completes.
|
|
549
|
-
* The method is idempotent (and therefore does not change the result) as long as you use the same values for uploadId and stream.
|
|
550
|
-
* The upload session ends either when you use the CancelUpload method or when you successfully
|
|
551
|
-
* complete the upload session by passing the rest of the file contents through the ContinueUpload and FinishUpload methods.
|
|
552
|
-
* The StartUpload and ContinueUpload methods return the size of the running total of uploaded data in bytes,
|
|
553
|
-
* so you can pass those return values to subsequent uses of ContinueUpload and FinishUpload.
|
|
554
|
-
* This method is currently available only on Office 365.
|
|
555
|
-
*
|
|
556
|
-
* @param uploadId The unique identifier of the upload session.
|
|
557
|
-
* @param fragment The file contents.
|
|
558
|
-
* @returns The size of the total uploaded data in bytes.
|
|
559
|
-
*/
|
|
560
|
-
_File.prototype.startUpload = function (uploadId, fragment) {
|
|
561
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
562
|
-
var n;
|
|
563
|
-
return __generator(this, function (_a) {
|
|
564
|
-
switch (_a.label) {
|
|
565
|
-
case 0: return [4 /*yield*/, spPost(this.clone(File, "startUpload(uploadId=guid'" + uploadId + "')", false), { body: fragment })];
|
|
566
|
-
case 1:
|
|
567
|
-
n = _a.sent();
|
|
568
|
-
if (typeof n === "object") {
|
|
569
|
-
// When OData=verbose the payload has the following shape:
|
|
570
|
-
// { StartUpload: "10485760" }
|
|
571
|
-
n = n.StartUpload;
|
|
572
|
-
}
|
|
573
|
-
return [2 /*return*/, parseFloat(n)];
|
|
574
|
-
}
|
|
575
|
-
});
|
|
576
|
-
});
|
|
577
|
-
};
|
|
578
|
-
/**
|
|
579
|
-
* Continues the chunk upload session with an additional fragment.
|
|
580
|
-
* The current file content is not changed.
|
|
581
|
-
* Use the uploadId value that was passed to the StartUpload method that started the upload session.
|
|
582
|
-
* This method is currently available only on Office 365.
|
|
583
|
-
*
|
|
584
|
-
* @param uploadId The unique identifier of the upload session.
|
|
585
|
-
* @param fileOffset The size of the offset into the file where the fragment starts.
|
|
586
|
-
* @param fragment The file contents.
|
|
587
|
-
* @returns The size of the total uploaded data in bytes.
|
|
588
|
-
*/
|
|
589
|
-
_File.prototype.continueUpload = function (uploadId, fileOffset, fragment) {
|
|
590
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
591
|
-
var n;
|
|
592
|
-
return __generator(this, function (_a) {
|
|
593
|
-
switch (_a.label) {
|
|
594
|
-
case 0: return [4 /*yield*/, spPost(this.clone(File, "continueUpload(uploadId=guid'" + uploadId + "',fileOffset=" + fileOffset + ")", false), { body: fragment })];
|
|
595
|
-
case 1:
|
|
596
|
-
n = _a.sent();
|
|
597
|
-
if (typeof n === "object") {
|
|
598
|
-
// When OData=verbose the payload has the following shape:
|
|
599
|
-
// { ContinueUpload: "20971520" }
|
|
600
|
-
n = n.ContinueUpload;
|
|
601
|
-
}
|
|
602
|
-
return [2 /*return*/, parseFloat(n)];
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
|
-
});
|
|
606
|
-
};
|
|
607
|
-
/**
|
|
608
|
-
* Uploads the last file fragment and commits the file. The current file content is changed when this method completes.
|
|
609
|
-
* Use the uploadId value that was passed to the StartUpload method that started the upload session.
|
|
610
|
-
* This method is currently available only on Office 365.
|
|
611
|
-
*
|
|
612
|
-
* @param uploadId The unique identifier of the upload session.
|
|
613
|
-
* @param fileOffset The size of the offset into the file where the fragment starts.
|
|
614
|
-
* @param fragment The file contents.
|
|
615
|
-
* @returns The newly uploaded file.
|
|
616
|
-
*/
|
|
617
|
-
_File.prototype.finishUpload = function (uploadId, fileOffset, fragment) {
|
|
618
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
619
|
-
var response;
|
|
620
|
-
return __generator(this, function (_a) {
|
|
621
|
-
switch (_a.label) {
|
|
622
|
-
case 0: return [4 /*yield*/, spPost(this.clone(File, "finishUpload(uploadId=guid'" + uploadId + "',fileOffset=" + fileOffset + ")", false), { body: fragment })];
|
|
623
|
-
case 1:
|
|
624
|
-
response = _a.sent();
|
|
625
|
-
return [2 /*return*/, {
|
|
626
|
-
data: response,
|
|
627
|
-
file: File(odataUrlFrom(response)),
|
|
628
|
-
}];
|
|
629
|
-
}
|
|
630
|
-
});
|
|
631
|
-
});
|
|
632
|
-
};
|
|
633
|
-
__decorate([
|
|
634
|
-
tag("fi.approve")
|
|
635
|
-
], _File.prototype, "approve", null);
|
|
636
|
-
__decorate([
|
|
637
|
-
tag("fi.cancelUpload")
|
|
638
|
-
], _File.prototype, "cancelUpload", null);
|
|
639
|
-
__decorate([
|
|
640
|
-
tag("fi.checkin")
|
|
641
|
-
], _File.prototype, "checkin", null);
|
|
642
|
-
__decorate([
|
|
643
|
-
tag("fi.checkout")
|
|
644
|
-
], _File.prototype, "checkout", null);
|
|
645
|
-
__decorate([
|
|
646
|
-
tag("fi.copyTo")
|
|
647
|
-
], _File.prototype, "copyTo", null);
|
|
648
|
-
__decorate([
|
|
649
|
-
tag("fi.copyByPath")
|
|
650
|
-
], _File.prototype, "copyByPath", null);
|
|
651
|
-
__decorate([
|
|
652
|
-
tag("fi.deny")
|
|
653
|
-
], _File.prototype, "deny", null);
|
|
654
|
-
__decorate([
|
|
655
|
-
tag("fi.moveTo")
|
|
656
|
-
], _File.prototype, "moveTo", null);
|
|
657
|
-
__decorate([
|
|
658
|
-
tag("fi.moveByPath")
|
|
659
|
-
], _File.prototype, "moveByPath", null);
|
|
660
|
-
__decorate([
|
|
661
|
-
tag("fi.publish")
|
|
662
|
-
], _File.prototype, "publish", null);
|
|
663
|
-
__decorate([
|
|
664
|
-
tag("fi.recycle")
|
|
665
|
-
], _File.prototype, "recycle", null);
|
|
666
|
-
__decorate([
|
|
667
|
-
tag("fi.del-params")
|
|
668
|
-
], _File.prototype, "deleteWithParams", null);
|
|
669
|
-
__decorate([
|
|
670
|
-
tag("fi.undoCheckout")
|
|
671
|
-
], _File.prototype, "undoCheckout", null);
|
|
672
|
-
__decorate([
|
|
673
|
-
tag("fi.unpublish")
|
|
674
|
-
], _File.prototype, "unpublish", null);
|
|
675
|
-
__decorate([
|
|
676
|
-
tag("fi.exists")
|
|
677
|
-
], _File.prototype, "exists", null);
|
|
678
|
-
__decorate([
|
|
679
|
-
tag("fi.getText")
|
|
680
|
-
], _File.prototype, "getText", null);
|
|
681
|
-
__decorate([
|
|
682
|
-
tag("fi.getBlob")
|
|
683
|
-
], _File.prototype, "getBlob", null);
|
|
684
|
-
__decorate([
|
|
685
|
-
tag("fi.getBuffer")
|
|
686
|
-
], _File.prototype, "getBuffer", null);
|
|
687
|
-
__decorate([
|
|
688
|
-
tag("fi.getJSON")
|
|
689
|
-
], _File.prototype, "getJSON", null);
|
|
690
|
-
__decorate([
|
|
691
|
-
tag("fi.setContent")
|
|
692
|
-
], _File.prototype, "setContent", null);
|
|
693
|
-
__decorate([
|
|
694
|
-
tag("fi.getItem")
|
|
695
|
-
], _File.prototype, "getItem", null);
|
|
696
|
-
__decorate([
|
|
697
|
-
tag("fi.startUpload")
|
|
698
|
-
], _File.prototype, "startUpload", null);
|
|
699
|
-
__decorate([
|
|
700
|
-
tag("fi.continueUpload")
|
|
701
|
-
], _File.prototype, "continueUpload", null);
|
|
702
|
-
__decorate([
|
|
703
|
-
tag("fi.finishUpload")
|
|
704
|
-
], _File.prototype, "finishUpload", null);
|
|
705
|
-
return _File;
|
|
706
|
-
}(_SharePointQueryableInstance));
|
|
707
|
-
export { _File };
|
|
708
|
-
export var File = spInvokableFactory(_File);
|
|
709
|
-
/**
|
|
710
|
-
* Describes a collection of Version objects
|
|
711
|
-
*
|
|
712
|
-
*/
|
|
713
|
-
var _Versions = /** @class */ (function (_super) {
|
|
714
|
-
__extends(_Versions, _super);
|
|
715
|
-
function _Versions() {
|
|
716
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
717
|
-
}
|
|
718
|
-
/**
|
|
719
|
-
* Gets a version by id
|
|
720
|
-
*
|
|
721
|
-
* @param versionId The id of the version to retrieve
|
|
722
|
-
*/
|
|
723
|
-
_Versions.prototype.getById = function (versionId) {
|
|
724
|
-
return tag.configure(Version(this).concat("(" + versionId + ")"), "vers.getById");
|
|
725
|
-
};
|
|
726
|
-
/**
|
|
727
|
-
* Deletes all the file version objects in the collection.
|
|
728
|
-
*
|
|
729
|
-
*/
|
|
730
|
-
_Versions.prototype.deleteAll = function () {
|
|
731
|
-
return spPost(Versions(this, "deleteAll"));
|
|
732
|
-
};
|
|
733
|
-
/**
|
|
734
|
-
* Deletes the specified version of the file.
|
|
735
|
-
*
|
|
736
|
-
* @param versionId The ID of the file version to delete.
|
|
737
|
-
*/
|
|
738
|
-
_Versions.prototype.deleteById = function (versionId) {
|
|
739
|
-
return spPost(this.clone(Versions, "deleteById(vid=" + versionId + ")"));
|
|
740
|
-
};
|
|
741
|
-
/**
|
|
742
|
-
* Recycles the specified version of the file.
|
|
743
|
-
*
|
|
744
|
-
* @param versionId The ID of the file version to delete.
|
|
745
|
-
*/
|
|
746
|
-
_Versions.prototype.recycleByID = function (versionId) {
|
|
747
|
-
return spPost(this.clone(Versions, "recycleByID(vid=" + versionId + ")"));
|
|
748
|
-
};
|
|
749
|
-
/**
|
|
750
|
-
* Deletes the file version object with the specified version label.
|
|
751
|
-
*
|
|
752
|
-
* @param label The version label of the file version to delete, for example: 1.2
|
|
753
|
-
*/
|
|
754
|
-
_Versions.prototype.deleteByLabel = function (label) {
|
|
755
|
-
return spPost(this.clone(Versions, "deleteByLabel(versionlabel='" + escapeQueryStrValue(label) + "')"));
|
|
756
|
-
};
|
|
757
|
-
/**
|
|
758
|
-
* Recycles the file version object with the specified version label.
|
|
759
|
-
*
|
|
760
|
-
* @param label The version label of the file version to delete, for example: 1.2
|
|
761
|
-
*/
|
|
762
|
-
_Versions.prototype.recycleByLabel = function (label) {
|
|
763
|
-
return spPost(this.clone(Versions, "recycleByLabel(versionlabel='" + escapeQueryStrValue(label) + "')"));
|
|
764
|
-
};
|
|
765
|
-
/**
|
|
766
|
-
* Creates a new file version from the file specified by the version label.
|
|
767
|
-
*
|
|
768
|
-
* @param label The version label of the file version to restore, for example: 1.2
|
|
769
|
-
*/
|
|
770
|
-
_Versions.prototype.restoreByLabel = function (label) {
|
|
771
|
-
return spPost(this.clone(Versions, "restoreByLabel(versionlabel='" + escapeQueryStrValue(label) + "')"));
|
|
772
|
-
};
|
|
773
|
-
__decorate([
|
|
774
|
-
tag("vers.deleteAll")
|
|
775
|
-
], _Versions.prototype, "deleteAll", null);
|
|
776
|
-
__decorate([
|
|
777
|
-
tag("vers.deleteById")
|
|
778
|
-
], _Versions.prototype, "deleteById", null);
|
|
779
|
-
__decorate([
|
|
780
|
-
tag("vers.recycleByID")
|
|
781
|
-
], _Versions.prototype, "recycleByID", null);
|
|
782
|
-
__decorate([
|
|
783
|
-
tag("vers.deleteByLabel")
|
|
784
|
-
], _Versions.prototype, "deleteByLabel", null);
|
|
785
|
-
__decorate([
|
|
786
|
-
tag("vers.recycleByLabel")
|
|
787
|
-
], _Versions.prototype, "recycleByLabel", null);
|
|
788
|
-
__decorate([
|
|
789
|
-
tag("vers.restoreByLabel")
|
|
790
|
-
], _Versions.prototype, "restoreByLabel", null);
|
|
791
|
-
_Versions = __decorate([
|
|
792
|
-
defaultPath("versions")
|
|
793
|
-
], _Versions);
|
|
794
|
-
return _Versions;
|
|
795
|
-
}(_SharePointQueryableCollection));
|
|
796
|
-
export { _Versions };
|
|
797
|
-
export var Versions = spInvokableFactory(_Versions);
|
|
798
|
-
/**
|
|
799
|
-
* Describes a single Version instance
|
|
800
|
-
*
|
|
801
|
-
*/
|
|
802
|
-
var _Version = /** @class */ (function (_super) {
|
|
803
|
-
__extends(_Version, _super);
|
|
804
|
-
function _Version() {
|
|
805
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
806
|
-
_this.delete = deleteableWithETag("ver");
|
|
807
|
-
return _this;
|
|
808
|
-
}
|
|
809
|
-
return _Version;
|
|
810
|
-
}(_SharePointQueryableInstance));
|
|
811
|
-
export { _Version };
|
|
812
|
-
export var Version = spInvokableFactory(_Version);
|
|
813
|
-
/**
|
|
814
|
-
* Types for document check in.
|
|
815
|
-
* Minor = 0
|
|
816
|
-
* Major = 1
|
|
817
|
-
* Overwrite = 2
|
|
818
|
-
*/
|
|
819
|
-
export var CheckinType;
|
|
820
|
-
(function (CheckinType) {
|
|
821
|
-
CheckinType[CheckinType["Minor"] = 0] = "Minor";
|
|
822
|
-
CheckinType[CheckinType["Major"] = 1] = "Major";
|
|
823
|
-
CheckinType[CheckinType["Overwrite"] = 2] = "Overwrite";
|
|
824
|
-
})(CheckinType || (CheckinType = {}));
|
|
825
|
-
/**
|
|
826
|
-
* File move opertions
|
|
827
|
-
*/
|
|
828
|
-
export var MoveOperations;
|
|
829
|
-
(function (MoveOperations) {
|
|
830
|
-
/**
|
|
831
|
-
* Produce an error if a file with the same name exists in the destination
|
|
832
|
-
*/
|
|
833
|
-
MoveOperations[MoveOperations["None"] = 0] = "None";
|
|
834
|
-
/**
|
|
835
|
-
* Overwrite a file with the same name if it exists. Value is 1.
|
|
836
|
-
*/
|
|
837
|
-
MoveOperations[MoveOperations["Overwrite"] = 1] = "Overwrite";
|
|
838
|
-
/**
|
|
839
|
-
* Complete the move operation even if supporting files are separated from the file. Value is 8.
|
|
840
|
-
*/
|
|
841
|
-
MoveOperations[MoveOperations["AllowBrokenThickets"] = 8] = "AllowBrokenThickets";
|
|
842
|
-
/**
|
|
843
|
-
* Boolean specifying whether to retain the source of the move's editor and modified by datetime.
|
|
844
|
-
*/
|
|
845
|
-
MoveOperations[MoveOperations["RetainEditorAndModifiedOnMove"] = 2048] = "RetainEditorAndModifiedOnMove";
|
|
846
|
-
})(MoveOperations || (MoveOperations = {}));
|
|
847
|
-
export var TemplateFileType;
|
|
848
|
-
(function (TemplateFileType) {
|
|
849
|
-
TemplateFileType[TemplateFileType["StandardPage"] = 0] = "StandardPage";
|
|
850
|
-
TemplateFileType[TemplateFileType["WikiPage"] = 1] = "WikiPage";
|
|
851
|
-
TemplateFileType[TemplateFileType["FormPage"] = 2] = "FormPage";
|
|
852
|
-
TemplateFileType[TemplateFileType["ClientSidePage"] = 3] = "ClientSidePage";
|
|
853
|
-
})(TemplateFileType || (TemplateFileType = {}));
|
|
1
|
+
import { __awaiter, __decorate, __extends, __generator, __read, __spreadArray } from "tslib";
|
|
2
|
+
import { _SharePointQueryableInstance, _SharePointQueryableCollection, spInvokableFactory, SharePointQueryableInstance, deleteableWithETag, } from "../sharepointqueryable.js";
|
|
3
|
+
import { TextParser, BlobParser, JSONParser, BufferParser, headers, body } from "@pnp/odata";
|
|
4
|
+
import { assign, getGUID, isFunc, stringIsNullOrEmpty, isUrlAbsolute } from "@pnp/common";
|
|
5
|
+
import { Item } from "../items/index.js";
|
|
6
|
+
import { odataUrlFrom } from "../odata.js";
|
|
7
|
+
import { defaultPath } from "../decorators.js";
|
|
8
|
+
import { spPost } from "../operations.js";
|
|
9
|
+
import { escapeQueryStrValue } from "../utils/escapeQueryStrValue.js";
|
|
10
|
+
import { extractWebUrl } from "../utils/extractweburl.js";
|
|
11
|
+
import { tag } from "../telemetry.js";
|
|
12
|
+
import { toResourcePath } from "../utils/toResourcePath.js";
|
|
13
|
+
/**
|
|
14
|
+
* Describes a collection of File objects
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
var _Files = /** @class */ (function (_super) {
|
|
18
|
+
__extends(_Files, _super);
|
|
19
|
+
function _Files() {
|
|
20
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Gets a File by filename
|
|
24
|
+
*
|
|
25
|
+
* @param name The name of the file, including extension.
|
|
26
|
+
*/
|
|
27
|
+
_Files.prototype.getByName = function (name) {
|
|
28
|
+
if (/%#/.test(name)) {
|
|
29
|
+
throw Error("For file names containing % or # please use web.getFileByServerRelativePath");
|
|
30
|
+
}
|
|
31
|
+
return tag.configure(File(this).concat("('" + escapeQueryStrValue(name) + "')"), "fis.getByName");
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Uploads a file. Not supported for batching
|
|
35
|
+
*
|
|
36
|
+
* @param url The folder-relative url of the file.
|
|
37
|
+
* @param content The file contents
|
|
38
|
+
* @param shouldOverWrite Should a file with the same name in the same location be overwritten? (default: true)
|
|
39
|
+
* @returns The new File and the raw response.
|
|
40
|
+
*/
|
|
41
|
+
_Files.prototype.add = function (url, content, shouldOverWrite) {
|
|
42
|
+
if (shouldOverWrite === void 0) { shouldOverWrite = true; }
|
|
43
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
+
var response;
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
|
+
case 0: return [4 /*yield*/, spPost(Files(this, "add(overwrite=" + shouldOverWrite + ",url='" + escapeQueryStrValue(url) + "')"), {
|
|
48
|
+
body: content,
|
|
49
|
+
})];
|
|
50
|
+
case 1:
|
|
51
|
+
response = _a.sent();
|
|
52
|
+
return [2 /*return*/, {
|
|
53
|
+
data: response,
|
|
54
|
+
file: this.getByName(url),
|
|
55
|
+
}];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Adds a file using the pound percent safe methods
|
|
62
|
+
*
|
|
63
|
+
* @param url Excoded url of the file
|
|
64
|
+
* @param content The file content
|
|
65
|
+
* @param parameters Additional parameters to control method behavior
|
|
66
|
+
*/
|
|
67
|
+
_Files.prototype.addUsingPath = function (url, content, parameters) {
|
|
68
|
+
if (parameters === void 0) { parameters = { Overwrite: false }; }
|
|
69
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
+
var path, resp;
|
|
71
|
+
return __generator(this, function (_a) {
|
|
72
|
+
switch (_a.label) {
|
|
73
|
+
case 0:
|
|
74
|
+
path = ["AddUsingPath(decodedurl='" + escapeQueryStrValue(url) + "'"];
|
|
75
|
+
if (parameters) {
|
|
76
|
+
if (parameters.Overwrite) {
|
|
77
|
+
path.push(",Overwrite=true");
|
|
78
|
+
}
|
|
79
|
+
if (parameters.AutoCheckoutOnInvalidData) {
|
|
80
|
+
path.push(",AutoCheckoutOnInvalidData=true");
|
|
81
|
+
}
|
|
82
|
+
if (!stringIsNullOrEmpty(parameters.XorHash)) {
|
|
83
|
+
path.push(",XorHash=" + escapeQueryStrValue(parameters.XorHash));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
path.push(")");
|
|
87
|
+
return [4 /*yield*/, spPost(Files(this, path.join("")), { body: content })];
|
|
88
|
+
case 1:
|
|
89
|
+
resp = _a.sent();
|
|
90
|
+
return [2 /*return*/, {
|
|
91
|
+
data: resp,
|
|
92
|
+
file: File(odataUrlFrom(resp)),
|
|
93
|
+
}];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Uploads a file. Not supported for batching
|
|
100
|
+
*
|
|
101
|
+
* @param url The folder-relative url of the file.
|
|
102
|
+
* @param content The Blob file content to add
|
|
103
|
+
* @param progress A callback function which can be used to track the progress of the upload
|
|
104
|
+
* @param shouldOverWrite Should a file with the same name in the same location be overwritten? (default: true)
|
|
105
|
+
* @param chunkSize The size of each file slice, in bytes (default: 10485760)
|
|
106
|
+
* @returns The new File and the raw response.
|
|
107
|
+
*/
|
|
108
|
+
_Files.prototype.addChunked = function (url, content, progress, shouldOverWrite, chunkSize) {
|
|
109
|
+
if (shouldOverWrite === void 0) { shouldOverWrite = true; }
|
|
110
|
+
if (chunkSize === void 0) { chunkSize = 10485760; }
|
|
111
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
112
|
+
var response, odataUrl, file;
|
|
113
|
+
return __generator(this, function (_a) {
|
|
114
|
+
switch (_a.label) {
|
|
115
|
+
case 0: return [4 /*yield*/, spPost(this.clone(Files, "add(overwrite=" + shouldOverWrite + ",url='" + escapeQueryStrValue(url) + "')", false))];
|
|
116
|
+
case 1:
|
|
117
|
+
response = _a.sent();
|
|
118
|
+
odataUrl = odataUrlFrom(response);
|
|
119
|
+
if (!stringIsNullOrEmpty(odataUrl) && /%27/i.test(odataUrl)) {
|
|
120
|
+
odataUrl = odataUrl.replace(/%27/ig, "''");
|
|
121
|
+
}
|
|
122
|
+
file = File(odataUrl);
|
|
123
|
+
return [4 /*yield*/, file.setContentChunked(content, progress, chunkSize)];
|
|
124
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Adds a ghosted file to an existing list or document library. Not supported for batching.
|
|
131
|
+
*
|
|
132
|
+
* @param fileUrl The server-relative url where you want to save the file.
|
|
133
|
+
* @param templateFileType The type of use to create the file.
|
|
134
|
+
* @returns The template file that was added and the raw response.
|
|
135
|
+
*/
|
|
136
|
+
_Files.prototype.addTemplateFile = function (fileUrl, templateFileType) {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
138
|
+
var response;
|
|
139
|
+
return __generator(this, function (_a) {
|
|
140
|
+
switch (_a.label) {
|
|
141
|
+
case 0: return [4 /*yield*/, spPost(this.clone(Files, "addTemplateFile(urloffile='" + escapeQueryStrValue(fileUrl) + "',templatefiletype=" + templateFileType + ")", false))];
|
|
142
|
+
case 1:
|
|
143
|
+
response = _a.sent();
|
|
144
|
+
return [2 /*return*/, {
|
|
145
|
+
data: response,
|
|
146
|
+
file: File(odataUrlFrom(response)),
|
|
147
|
+
}];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
__decorate([
|
|
153
|
+
tag("fis.add")
|
|
154
|
+
], _Files.prototype, "add", null);
|
|
155
|
+
__decorate([
|
|
156
|
+
tag("fis.addUsingPath")
|
|
157
|
+
], _Files.prototype, "addUsingPath", null);
|
|
158
|
+
__decorate([
|
|
159
|
+
tag("fis.addChunked")
|
|
160
|
+
], _Files.prototype, "addChunked", null);
|
|
161
|
+
__decorate([
|
|
162
|
+
tag("fis.addTemplateFile")
|
|
163
|
+
], _Files.prototype, "addTemplateFile", null);
|
|
164
|
+
_Files = __decorate([
|
|
165
|
+
defaultPath("files")
|
|
166
|
+
], _Files);
|
|
167
|
+
return _Files;
|
|
168
|
+
}(_SharePointQueryableCollection));
|
|
169
|
+
export { _Files };
|
|
170
|
+
export var Files = spInvokableFactory(_Files);
|
|
171
|
+
/**
|
|
172
|
+
* Describes a single File instance
|
|
173
|
+
*
|
|
174
|
+
*/
|
|
175
|
+
var _File = /** @class */ (function (_super) {
|
|
176
|
+
__extends(_File, _super);
|
|
177
|
+
function _File() {
|
|
178
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
179
|
+
_this.delete = deleteableWithETag("fi");
|
|
180
|
+
return _this;
|
|
181
|
+
}
|
|
182
|
+
Object.defineProperty(_File.prototype, "listItemAllFields", {
|
|
183
|
+
/**
|
|
184
|
+
* Gets a value that specifies the list item field values for the list item corresponding to the file.
|
|
185
|
+
*
|
|
186
|
+
*/
|
|
187
|
+
get: function () {
|
|
188
|
+
return tag.configure(SharePointQueryableInstance(this, "listItemAllFields"), "fi.listItemAllFields");
|
|
189
|
+
},
|
|
190
|
+
enumerable: false,
|
|
191
|
+
configurable: true
|
|
192
|
+
});
|
|
193
|
+
Object.defineProperty(_File.prototype, "versions", {
|
|
194
|
+
/**
|
|
195
|
+
* Gets a collection of versions
|
|
196
|
+
*
|
|
197
|
+
*/
|
|
198
|
+
get: function () {
|
|
199
|
+
return tag.configure(Versions(this), "fi.versions");
|
|
200
|
+
},
|
|
201
|
+
enumerable: false,
|
|
202
|
+
configurable: true
|
|
203
|
+
});
|
|
204
|
+
/**
|
|
205
|
+
* Approves the file submitted for content approval with the specified comment.
|
|
206
|
+
* Only documents in lists that are enabled for content approval can be approved.
|
|
207
|
+
*
|
|
208
|
+
* @param comment The comment for the approval.
|
|
209
|
+
*/
|
|
210
|
+
_File.prototype.approve = function (comment) {
|
|
211
|
+
if (comment === void 0) { comment = ""; }
|
|
212
|
+
return spPost(this.clone(File, "approve(comment='" + escapeQueryStrValue(comment) + "')"));
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Stops the chunk upload session without saving the uploaded data. Does not support batching.
|
|
216
|
+
* If the file doesn’t already exist in the library, the partially uploaded file will be deleted.
|
|
217
|
+
* Use this in response to user action (as in a request to cancel an upload) or an error or exception.
|
|
218
|
+
* Use the uploadId value that was passed to the StartUpload method that started the upload session.
|
|
219
|
+
* This method is currently available only on Office 365.
|
|
220
|
+
*
|
|
221
|
+
* @param uploadId The unique identifier of the upload session.
|
|
222
|
+
*/
|
|
223
|
+
_File.prototype.cancelUpload = function (uploadId) {
|
|
224
|
+
return spPost(this.clone(File, "cancelUpload(uploadId=guid'" + uploadId + "')", false));
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Checks the file in to a document library based on the check-in type.
|
|
228
|
+
*
|
|
229
|
+
* @param comment A comment for the check-in. Its length must be <= 1023.
|
|
230
|
+
* @param checkinType The check-in type for the file.
|
|
231
|
+
*/
|
|
232
|
+
_File.prototype.checkin = function (comment, checkinType) {
|
|
233
|
+
if (comment === void 0) { comment = ""; }
|
|
234
|
+
if (checkinType === void 0) { checkinType = CheckinType.Major; }
|
|
235
|
+
if (comment.length > 1023) {
|
|
236
|
+
throw Error("The maximum comment length is 1023 characters.");
|
|
237
|
+
}
|
|
238
|
+
return spPost(this.clone(File, "checkin(comment='" + escapeQueryStrValue(comment) + "',checkintype=" + checkinType + ")"));
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Checks out the file from a document library.
|
|
242
|
+
*/
|
|
243
|
+
_File.prototype.checkout = function () {
|
|
244
|
+
return spPost(this.clone(File, "checkout"));
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* Copies the file to the destination url.
|
|
248
|
+
*
|
|
249
|
+
* @param url The absolute url or server relative url of the destination file path to copy to.
|
|
250
|
+
* @param shouldOverWrite Should a file with the same name in the same location be overwritten?
|
|
251
|
+
*/
|
|
252
|
+
_File.prototype.copyTo = function (url, shouldOverWrite) {
|
|
253
|
+
if (shouldOverWrite === void 0) { shouldOverWrite = true; }
|
|
254
|
+
return spPost(this.clone(File, "copyTo(strnewurl='" + escapeQueryStrValue(url) + "',boverwrite=" + shouldOverWrite + ")"));
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* Copies the file by path to destination path.
|
|
258
|
+
* Also works with different site collections.
|
|
259
|
+
*
|
|
260
|
+
* @param destUrl The absolute url or server relative url of the destination file path to copy to.
|
|
261
|
+
* @param shouldOverWrite Should a file with the same name in the same location be overwritten?
|
|
262
|
+
* @param keepBoth Keep both if file with the same name in the same location already exists? Only relevant when shouldOverWrite is set to false.
|
|
263
|
+
*/
|
|
264
|
+
_File.prototype.copyByPath = function (destUrl, shouldOverWrite, KeepBoth) {
|
|
265
|
+
if (KeepBoth === void 0) { KeepBoth = false; }
|
|
266
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
267
|
+
var _a, srcUrl, absoluteUrl, webBaseUrl, hostUrl;
|
|
268
|
+
return __generator(this, function (_b) {
|
|
269
|
+
switch (_b.label) {
|
|
270
|
+
case 0: return [4 /*yield*/, this.select("ServerRelativeUrl")()];
|
|
271
|
+
case 1:
|
|
272
|
+
_a = _b.sent(), srcUrl = _a.ServerRelativeUrl, absoluteUrl = _a["odata.id"];
|
|
273
|
+
webBaseUrl = extractWebUrl(absoluteUrl);
|
|
274
|
+
hostUrl = webBaseUrl.replace("://", "___").split("/")[0].replace("___", "://");
|
|
275
|
+
return [4 /*yield*/, spPost(File(webBaseUrl, "/_api/SP.MoveCopyUtil.CopyFileByPath(overwrite=@a1)?@a1=" + shouldOverWrite), body({
|
|
276
|
+
destPath: toResourcePath(isUrlAbsolute(destUrl) ? destUrl : "" + hostUrl + destUrl),
|
|
277
|
+
options: {
|
|
278
|
+
KeepBoth: KeepBoth,
|
|
279
|
+
ResetAuthorAndCreatedOnCopy: true,
|
|
280
|
+
ShouldBypassSharedLocks: true,
|
|
281
|
+
__metadata: {
|
|
282
|
+
type: "SP.MoveCopyOptions",
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
srcPath: toResourcePath(isUrlAbsolute(srcUrl) ? srcUrl : "" + hostUrl + srcUrl),
|
|
286
|
+
}))];
|
|
287
|
+
case 2:
|
|
288
|
+
_b.sent();
|
|
289
|
+
return [2 /*return*/];
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
};
|
|
294
|
+
/**
|
|
295
|
+
* Denies approval for a file that was submitted for content approval.
|
|
296
|
+
* Only documents in lists that are enabled for content approval can be denied.
|
|
297
|
+
*
|
|
298
|
+
* @param comment The comment for the denial.
|
|
299
|
+
*/
|
|
300
|
+
_File.prototype.deny = function (comment) {
|
|
301
|
+
if (comment === void 0) { comment = ""; }
|
|
302
|
+
if (comment.length > 1023) {
|
|
303
|
+
throw Error("The maximum comment length is 1023 characters.");
|
|
304
|
+
}
|
|
305
|
+
return spPost(this.clone(File, "deny(comment='" + escapeQueryStrValue(comment) + "')"));
|
|
306
|
+
};
|
|
307
|
+
/**
|
|
308
|
+
* Moves the file to the specified destination url.
|
|
309
|
+
*
|
|
310
|
+
* @param url The absolute url or server relative url of the destination file path to move to.
|
|
311
|
+
* @param moveOperations The bitwise MoveOperations value for how to move the file.
|
|
312
|
+
*/
|
|
313
|
+
_File.prototype.moveTo = function (url, moveOperations) {
|
|
314
|
+
if (moveOperations === void 0) { moveOperations = MoveOperations.Overwrite; }
|
|
315
|
+
return spPost(this.clone(File, "moveTo(newurl='" + escapeQueryStrValue(url) + "',flags=" + moveOperations + ")"));
|
|
316
|
+
};
|
|
317
|
+
/**
|
|
318
|
+
* Moves the file by path to the specified destination url.
|
|
319
|
+
* Also works with different site collections.
|
|
320
|
+
*
|
|
321
|
+
* @param destUrl The absolute url or server relative url of the destination file path to move to.
|
|
322
|
+
* @param shouldOverWrite Should a file with the same name in the same location be overwritten?
|
|
323
|
+
* @param keepBoth Keep both if file with the same name in the same location already exists? Only relevant when shouldOverWrite is set to false.
|
|
324
|
+
*/
|
|
325
|
+
_File.prototype.moveByPath = function (destUrl, shouldOverWrite, KeepBoth) {
|
|
326
|
+
if (KeepBoth === void 0) { KeepBoth = false; }
|
|
327
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
328
|
+
var _a, srcUrl, absoluteUrl, webBaseUrl, hostUrl;
|
|
329
|
+
return __generator(this, function (_b) {
|
|
330
|
+
switch (_b.label) {
|
|
331
|
+
case 0: return [4 /*yield*/, this.select("ServerRelativeUrl")()];
|
|
332
|
+
case 1:
|
|
333
|
+
_a = _b.sent(), srcUrl = _a.ServerRelativeUrl, absoluteUrl = _a["odata.id"];
|
|
334
|
+
webBaseUrl = extractWebUrl(absoluteUrl);
|
|
335
|
+
hostUrl = webBaseUrl.replace("://", "___").split("/")[0].replace("___", "://");
|
|
336
|
+
return [4 /*yield*/, spPost(File(webBaseUrl, "/_api/SP.MoveCopyUtil.MoveFileByPath(overwrite=@a1)?@a1=" + shouldOverWrite), body({
|
|
337
|
+
destPath: toResourcePath(isUrlAbsolute(destUrl) ? destUrl : "" + hostUrl + destUrl),
|
|
338
|
+
options: {
|
|
339
|
+
KeepBoth: KeepBoth,
|
|
340
|
+
ResetAuthorAndCreatedOnCopy: false,
|
|
341
|
+
ShouldBypassSharedLocks: true,
|
|
342
|
+
__metadata: {
|
|
343
|
+
type: "SP.MoveCopyOptions",
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
srcPath: toResourcePath(isUrlAbsolute(srcUrl) ? srcUrl : "" + hostUrl + srcUrl),
|
|
347
|
+
}))];
|
|
348
|
+
case 2:
|
|
349
|
+
_b.sent();
|
|
350
|
+
return [2 /*return*/];
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* Submits the file for content approval with the specified comment.
|
|
357
|
+
*
|
|
358
|
+
* @param comment The comment for the published file. Its length must be <= 1023.
|
|
359
|
+
*/
|
|
360
|
+
_File.prototype.publish = function (comment) {
|
|
361
|
+
if (comment === void 0) { comment = ""; }
|
|
362
|
+
if (comment.length > 1023) {
|
|
363
|
+
throw Error("The maximum comment length is 1023 characters.");
|
|
364
|
+
}
|
|
365
|
+
return spPost(this.clone(File, "publish(comment='" + escapeQueryStrValue(comment) + "')"));
|
|
366
|
+
};
|
|
367
|
+
/**
|
|
368
|
+
* Moves the file to the Recycle Bin and returns the identifier of the new Recycle Bin item.
|
|
369
|
+
*
|
|
370
|
+
* @returns The GUID of the recycled file.
|
|
371
|
+
*/
|
|
372
|
+
_File.prototype.recycle = function () {
|
|
373
|
+
return spPost(this.clone(File, "recycle"));
|
|
374
|
+
};
|
|
375
|
+
/**
|
|
376
|
+
* Deletes the file object with options.
|
|
377
|
+
*
|
|
378
|
+
* @param parameters Specifies the options to use when deleting a file.
|
|
379
|
+
*/
|
|
380
|
+
_File.prototype.deleteWithParams = function (parameters) {
|
|
381
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
382
|
+
return __generator(this, function (_a) {
|
|
383
|
+
return [2 /*return*/, spPost(this.clone(File, "DeleteWithParameters"), body({ parameters: parameters }))];
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
};
|
|
387
|
+
/**
|
|
388
|
+
* Reverts an existing checkout for the file.
|
|
389
|
+
*
|
|
390
|
+
*/
|
|
391
|
+
_File.prototype.undoCheckout = function () {
|
|
392
|
+
return spPost(this.clone(File, "undoCheckout"));
|
|
393
|
+
};
|
|
394
|
+
/**
|
|
395
|
+
* Removes the file from content approval or unpublish a major version.
|
|
396
|
+
*
|
|
397
|
+
* @param comment The comment for the unpublish operation. Its length must be <= 1023.
|
|
398
|
+
*/
|
|
399
|
+
_File.prototype.unpublish = function (comment) {
|
|
400
|
+
if (comment === void 0) { comment = ""; }
|
|
401
|
+
if (comment.length > 1023) {
|
|
402
|
+
throw Error("The maximum comment length is 1023 characters.");
|
|
403
|
+
}
|
|
404
|
+
return spPost(this.clone(File, "unpublish(comment='" + escapeQueryStrValue(comment) + "')"));
|
|
405
|
+
};
|
|
406
|
+
/**
|
|
407
|
+
* Checks to see if the file represented by this object exists
|
|
408
|
+
*
|
|
409
|
+
*/
|
|
410
|
+
_File.prototype.exists = function () {
|
|
411
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
412
|
+
var r, e_1;
|
|
413
|
+
return __generator(this, function (_a) {
|
|
414
|
+
switch (_a.label) {
|
|
415
|
+
case 0:
|
|
416
|
+
_a.trys.push([0, 2, , 3]);
|
|
417
|
+
return [4 /*yield*/, this.clone(File).select("Exists")()];
|
|
418
|
+
case 1:
|
|
419
|
+
r = _a.sent();
|
|
420
|
+
return [2 /*return*/, r.Exists];
|
|
421
|
+
case 2:
|
|
422
|
+
e_1 = _a.sent();
|
|
423
|
+
// this treats any error here as the file not existing, which
|
|
424
|
+
// might not be true, but is good enough.
|
|
425
|
+
return [2 /*return*/, false];
|
|
426
|
+
case 3: return [2 /*return*/];
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
});
|
|
430
|
+
};
|
|
431
|
+
/**
|
|
432
|
+
* Gets the contents of the file as text. Not supported in batching.
|
|
433
|
+
*
|
|
434
|
+
*/
|
|
435
|
+
_File.prototype.getText = function () {
|
|
436
|
+
return this.clone(File, "$value", false).usingParser(new TextParser())(headers({ "binaryStringResponseBody": "true" }));
|
|
437
|
+
};
|
|
438
|
+
/**
|
|
439
|
+
* Gets the contents of the file as a blob, does not work in Node.js. Not supported in batching.
|
|
440
|
+
*
|
|
441
|
+
*/
|
|
442
|
+
_File.prototype.getBlob = function () {
|
|
443
|
+
return this.clone(File, "$value", false).usingParser(new BlobParser())(headers({ "binaryStringResponseBody": "true" }));
|
|
444
|
+
};
|
|
445
|
+
/**
|
|
446
|
+
* Gets the contents of a file as an ArrayBuffer, works in Node.js. Not supported in batching.
|
|
447
|
+
*/
|
|
448
|
+
_File.prototype.getBuffer = function () {
|
|
449
|
+
return this.clone(File, "$value", false).usingParser(new BufferParser())(headers({ "binaryStringResponseBody": "true" }));
|
|
450
|
+
};
|
|
451
|
+
/**
|
|
452
|
+
* Gets the contents of a file as an ArrayBuffer, works in Node.js. Not supported in batching.
|
|
453
|
+
*/
|
|
454
|
+
_File.prototype.getJSON = function () {
|
|
455
|
+
return this.clone(File, "$value", false).usingParser(new JSONParser())(headers({ "binaryStringResponseBody": "true" }));
|
|
456
|
+
};
|
|
457
|
+
/**
|
|
458
|
+
* Sets the content of a file, for large files use setContentChunked. Not supported in batching.
|
|
459
|
+
*
|
|
460
|
+
* @param content The file content
|
|
461
|
+
*
|
|
462
|
+
*/
|
|
463
|
+
_File.prototype.setContent = function (content) {
|
|
464
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
465
|
+
return __generator(this, function (_a) {
|
|
466
|
+
switch (_a.label) {
|
|
467
|
+
case 0: return [4 /*yield*/, spPost(this.clone(File, "$value", false), {
|
|
468
|
+
body: content,
|
|
469
|
+
headers: {
|
|
470
|
+
"X-HTTP-Method": "PUT",
|
|
471
|
+
},
|
|
472
|
+
})];
|
|
473
|
+
case 1:
|
|
474
|
+
_a.sent();
|
|
475
|
+
return [2 /*return*/, File(this)];
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
};
|
|
480
|
+
/**
|
|
481
|
+
* Gets the associated list item for this file, loading the default properties
|
|
482
|
+
*/
|
|
483
|
+
_File.prototype.getItem = function () {
|
|
484
|
+
var selects = [];
|
|
485
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
486
|
+
selects[_i] = arguments[_i];
|
|
487
|
+
}
|
|
488
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
489
|
+
var q, d;
|
|
490
|
+
return __generator(this, function (_a) {
|
|
491
|
+
switch (_a.label) {
|
|
492
|
+
case 0:
|
|
493
|
+
q = this.listItemAllFields;
|
|
494
|
+
return [4 /*yield*/, q.select.apply(q, __spreadArray([], __read(selects), false))()];
|
|
495
|
+
case 1:
|
|
496
|
+
d = _a.sent();
|
|
497
|
+
return [2 /*return*/, assign(Item(odataUrlFrom(d)), d)];
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
});
|
|
501
|
+
};
|
|
502
|
+
/**
|
|
503
|
+
* Sets the contents of a file using a chunked upload approach. Not supported in batching.
|
|
504
|
+
*
|
|
505
|
+
* @param file The file to upload
|
|
506
|
+
* @param progress A callback function which can be used to track the progress of the upload
|
|
507
|
+
* @param chunkSize The size of each file slice, in bytes (default: 10485760)
|
|
508
|
+
*/
|
|
509
|
+
_File.prototype.setContentChunked = function (file, progress, chunkSize) {
|
|
510
|
+
if (chunkSize === void 0) { chunkSize = 10485760; }
|
|
511
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
512
|
+
var fileSize, totalBlocks, uploadId, currentPointer, i;
|
|
513
|
+
return __generator(this, function (_a) {
|
|
514
|
+
switch (_a.label) {
|
|
515
|
+
case 0:
|
|
516
|
+
if (!isFunc(progress)) {
|
|
517
|
+
progress = function () { return null; };
|
|
518
|
+
}
|
|
519
|
+
fileSize = file.size;
|
|
520
|
+
totalBlocks = parseInt((fileSize / chunkSize).toString(), 10) + ((fileSize % chunkSize === 0) ? 1 : 0);
|
|
521
|
+
uploadId = getGUID();
|
|
522
|
+
// report that we are starting
|
|
523
|
+
progress({ uploadId: uploadId, blockNumber: 1, chunkSize: chunkSize, currentPointer: 0, fileSize: fileSize, stage: "starting", totalBlocks: totalBlocks });
|
|
524
|
+
return [4 /*yield*/, this.startUpload(uploadId, file.slice(0, chunkSize))];
|
|
525
|
+
case 1:
|
|
526
|
+
currentPointer = _a.sent();
|
|
527
|
+
i = 2;
|
|
528
|
+
_a.label = 2;
|
|
529
|
+
case 2:
|
|
530
|
+
if (!(i < totalBlocks)) return [3 /*break*/, 5];
|
|
531
|
+
progress({ uploadId: uploadId, blockNumber: i, chunkSize: chunkSize, currentPointer: currentPointer, fileSize: fileSize, stage: "continue", totalBlocks: totalBlocks });
|
|
532
|
+
return [4 /*yield*/, this.continueUpload(uploadId, currentPointer, file.slice(currentPointer, currentPointer + chunkSize))];
|
|
533
|
+
case 3:
|
|
534
|
+
currentPointer = _a.sent();
|
|
535
|
+
_a.label = 4;
|
|
536
|
+
case 4:
|
|
537
|
+
i++;
|
|
538
|
+
return [3 /*break*/, 2];
|
|
539
|
+
case 5:
|
|
540
|
+
progress({ uploadId: uploadId, blockNumber: totalBlocks, chunkSize: chunkSize, currentPointer: currentPointer, fileSize: fileSize, stage: "finishing", totalBlocks: totalBlocks });
|
|
541
|
+
return [2 /*return*/, this.finishUpload(uploadId, currentPointer, file.slice(currentPointer))];
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
});
|
|
545
|
+
};
|
|
546
|
+
/**
|
|
547
|
+
* Starts a new chunk upload session and uploads the first fragment.
|
|
548
|
+
* The current file content is not changed when this method completes.
|
|
549
|
+
* The method is idempotent (and therefore does not change the result) as long as you use the same values for uploadId and stream.
|
|
550
|
+
* The upload session ends either when you use the CancelUpload method or when you successfully
|
|
551
|
+
* complete the upload session by passing the rest of the file contents through the ContinueUpload and FinishUpload methods.
|
|
552
|
+
* The StartUpload and ContinueUpload methods return the size of the running total of uploaded data in bytes,
|
|
553
|
+
* so you can pass those return values to subsequent uses of ContinueUpload and FinishUpload.
|
|
554
|
+
* This method is currently available only on Office 365.
|
|
555
|
+
*
|
|
556
|
+
* @param uploadId The unique identifier of the upload session.
|
|
557
|
+
* @param fragment The file contents.
|
|
558
|
+
* @returns The size of the total uploaded data in bytes.
|
|
559
|
+
*/
|
|
560
|
+
_File.prototype.startUpload = function (uploadId, fragment) {
|
|
561
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
562
|
+
var n;
|
|
563
|
+
return __generator(this, function (_a) {
|
|
564
|
+
switch (_a.label) {
|
|
565
|
+
case 0: return [4 /*yield*/, spPost(this.clone(File, "startUpload(uploadId=guid'" + uploadId + "')", false), { body: fragment })];
|
|
566
|
+
case 1:
|
|
567
|
+
n = _a.sent();
|
|
568
|
+
if (typeof n === "object") {
|
|
569
|
+
// When OData=verbose the payload has the following shape:
|
|
570
|
+
// { StartUpload: "10485760" }
|
|
571
|
+
n = n.StartUpload;
|
|
572
|
+
}
|
|
573
|
+
return [2 /*return*/, parseFloat(n)];
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
});
|
|
577
|
+
};
|
|
578
|
+
/**
|
|
579
|
+
* Continues the chunk upload session with an additional fragment.
|
|
580
|
+
* The current file content is not changed.
|
|
581
|
+
* Use the uploadId value that was passed to the StartUpload method that started the upload session.
|
|
582
|
+
* This method is currently available only on Office 365.
|
|
583
|
+
*
|
|
584
|
+
* @param uploadId The unique identifier of the upload session.
|
|
585
|
+
* @param fileOffset The size of the offset into the file where the fragment starts.
|
|
586
|
+
* @param fragment The file contents.
|
|
587
|
+
* @returns The size of the total uploaded data in bytes.
|
|
588
|
+
*/
|
|
589
|
+
_File.prototype.continueUpload = function (uploadId, fileOffset, fragment) {
|
|
590
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
591
|
+
var n;
|
|
592
|
+
return __generator(this, function (_a) {
|
|
593
|
+
switch (_a.label) {
|
|
594
|
+
case 0: return [4 /*yield*/, spPost(this.clone(File, "continueUpload(uploadId=guid'" + uploadId + "',fileOffset=" + fileOffset + ")", false), { body: fragment })];
|
|
595
|
+
case 1:
|
|
596
|
+
n = _a.sent();
|
|
597
|
+
if (typeof n === "object") {
|
|
598
|
+
// When OData=verbose the payload has the following shape:
|
|
599
|
+
// { ContinueUpload: "20971520" }
|
|
600
|
+
n = n.ContinueUpload;
|
|
601
|
+
}
|
|
602
|
+
return [2 /*return*/, parseFloat(n)];
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
});
|
|
606
|
+
};
|
|
607
|
+
/**
|
|
608
|
+
* Uploads the last file fragment and commits the file. The current file content is changed when this method completes.
|
|
609
|
+
* Use the uploadId value that was passed to the StartUpload method that started the upload session.
|
|
610
|
+
* This method is currently available only on Office 365.
|
|
611
|
+
*
|
|
612
|
+
* @param uploadId The unique identifier of the upload session.
|
|
613
|
+
* @param fileOffset The size of the offset into the file where the fragment starts.
|
|
614
|
+
* @param fragment The file contents.
|
|
615
|
+
* @returns The newly uploaded file.
|
|
616
|
+
*/
|
|
617
|
+
_File.prototype.finishUpload = function (uploadId, fileOffset, fragment) {
|
|
618
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
619
|
+
var response;
|
|
620
|
+
return __generator(this, function (_a) {
|
|
621
|
+
switch (_a.label) {
|
|
622
|
+
case 0: return [4 /*yield*/, spPost(this.clone(File, "finishUpload(uploadId=guid'" + uploadId + "',fileOffset=" + fileOffset + ")", false), { body: fragment })];
|
|
623
|
+
case 1:
|
|
624
|
+
response = _a.sent();
|
|
625
|
+
return [2 /*return*/, {
|
|
626
|
+
data: response,
|
|
627
|
+
file: File(odataUrlFrom(response)),
|
|
628
|
+
}];
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
});
|
|
632
|
+
};
|
|
633
|
+
__decorate([
|
|
634
|
+
tag("fi.approve")
|
|
635
|
+
], _File.prototype, "approve", null);
|
|
636
|
+
__decorate([
|
|
637
|
+
tag("fi.cancelUpload")
|
|
638
|
+
], _File.prototype, "cancelUpload", null);
|
|
639
|
+
__decorate([
|
|
640
|
+
tag("fi.checkin")
|
|
641
|
+
], _File.prototype, "checkin", null);
|
|
642
|
+
__decorate([
|
|
643
|
+
tag("fi.checkout")
|
|
644
|
+
], _File.prototype, "checkout", null);
|
|
645
|
+
__decorate([
|
|
646
|
+
tag("fi.copyTo")
|
|
647
|
+
], _File.prototype, "copyTo", null);
|
|
648
|
+
__decorate([
|
|
649
|
+
tag("fi.copyByPath")
|
|
650
|
+
], _File.prototype, "copyByPath", null);
|
|
651
|
+
__decorate([
|
|
652
|
+
tag("fi.deny")
|
|
653
|
+
], _File.prototype, "deny", null);
|
|
654
|
+
__decorate([
|
|
655
|
+
tag("fi.moveTo")
|
|
656
|
+
], _File.prototype, "moveTo", null);
|
|
657
|
+
__decorate([
|
|
658
|
+
tag("fi.moveByPath")
|
|
659
|
+
], _File.prototype, "moveByPath", null);
|
|
660
|
+
__decorate([
|
|
661
|
+
tag("fi.publish")
|
|
662
|
+
], _File.prototype, "publish", null);
|
|
663
|
+
__decorate([
|
|
664
|
+
tag("fi.recycle")
|
|
665
|
+
], _File.prototype, "recycle", null);
|
|
666
|
+
__decorate([
|
|
667
|
+
tag("fi.del-params")
|
|
668
|
+
], _File.prototype, "deleteWithParams", null);
|
|
669
|
+
__decorate([
|
|
670
|
+
tag("fi.undoCheckout")
|
|
671
|
+
], _File.prototype, "undoCheckout", null);
|
|
672
|
+
__decorate([
|
|
673
|
+
tag("fi.unpublish")
|
|
674
|
+
], _File.prototype, "unpublish", null);
|
|
675
|
+
__decorate([
|
|
676
|
+
tag("fi.exists")
|
|
677
|
+
], _File.prototype, "exists", null);
|
|
678
|
+
__decorate([
|
|
679
|
+
tag("fi.getText")
|
|
680
|
+
], _File.prototype, "getText", null);
|
|
681
|
+
__decorate([
|
|
682
|
+
tag("fi.getBlob")
|
|
683
|
+
], _File.prototype, "getBlob", null);
|
|
684
|
+
__decorate([
|
|
685
|
+
tag("fi.getBuffer")
|
|
686
|
+
], _File.prototype, "getBuffer", null);
|
|
687
|
+
__decorate([
|
|
688
|
+
tag("fi.getJSON")
|
|
689
|
+
], _File.prototype, "getJSON", null);
|
|
690
|
+
__decorate([
|
|
691
|
+
tag("fi.setContent")
|
|
692
|
+
], _File.prototype, "setContent", null);
|
|
693
|
+
__decorate([
|
|
694
|
+
tag("fi.getItem")
|
|
695
|
+
], _File.prototype, "getItem", null);
|
|
696
|
+
__decorate([
|
|
697
|
+
tag("fi.startUpload")
|
|
698
|
+
], _File.prototype, "startUpload", null);
|
|
699
|
+
__decorate([
|
|
700
|
+
tag("fi.continueUpload")
|
|
701
|
+
], _File.prototype, "continueUpload", null);
|
|
702
|
+
__decorate([
|
|
703
|
+
tag("fi.finishUpload")
|
|
704
|
+
], _File.prototype, "finishUpload", null);
|
|
705
|
+
return _File;
|
|
706
|
+
}(_SharePointQueryableInstance));
|
|
707
|
+
export { _File };
|
|
708
|
+
export var File = spInvokableFactory(_File);
|
|
709
|
+
/**
|
|
710
|
+
* Describes a collection of Version objects
|
|
711
|
+
*
|
|
712
|
+
*/
|
|
713
|
+
var _Versions = /** @class */ (function (_super) {
|
|
714
|
+
__extends(_Versions, _super);
|
|
715
|
+
function _Versions() {
|
|
716
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* Gets a version by id
|
|
720
|
+
*
|
|
721
|
+
* @param versionId The id of the version to retrieve
|
|
722
|
+
*/
|
|
723
|
+
_Versions.prototype.getById = function (versionId) {
|
|
724
|
+
return tag.configure(Version(this).concat("(" + versionId + ")"), "vers.getById");
|
|
725
|
+
};
|
|
726
|
+
/**
|
|
727
|
+
* Deletes all the file version objects in the collection.
|
|
728
|
+
*
|
|
729
|
+
*/
|
|
730
|
+
_Versions.prototype.deleteAll = function () {
|
|
731
|
+
return spPost(Versions(this, "deleteAll"));
|
|
732
|
+
};
|
|
733
|
+
/**
|
|
734
|
+
* Deletes the specified version of the file.
|
|
735
|
+
*
|
|
736
|
+
* @param versionId The ID of the file version to delete.
|
|
737
|
+
*/
|
|
738
|
+
_Versions.prototype.deleteById = function (versionId) {
|
|
739
|
+
return spPost(this.clone(Versions, "deleteById(vid=" + versionId + ")"));
|
|
740
|
+
};
|
|
741
|
+
/**
|
|
742
|
+
* Recycles the specified version of the file.
|
|
743
|
+
*
|
|
744
|
+
* @param versionId The ID of the file version to delete.
|
|
745
|
+
*/
|
|
746
|
+
_Versions.prototype.recycleByID = function (versionId) {
|
|
747
|
+
return spPost(this.clone(Versions, "recycleByID(vid=" + versionId + ")"));
|
|
748
|
+
};
|
|
749
|
+
/**
|
|
750
|
+
* Deletes the file version object with the specified version label.
|
|
751
|
+
*
|
|
752
|
+
* @param label The version label of the file version to delete, for example: 1.2
|
|
753
|
+
*/
|
|
754
|
+
_Versions.prototype.deleteByLabel = function (label) {
|
|
755
|
+
return spPost(this.clone(Versions, "deleteByLabel(versionlabel='" + escapeQueryStrValue(label) + "')"));
|
|
756
|
+
};
|
|
757
|
+
/**
|
|
758
|
+
* Recycles the file version object with the specified version label.
|
|
759
|
+
*
|
|
760
|
+
* @param label The version label of the file version to delete, for example: 1.2
|
|
761
|
+
*/
|
|
762
|
+
_Versions.prototype.recycleByLabel = function (label) {
|
|
763
|
+
return spPost(this.clone(Versions, "recycleByLabel(versionlabel='" + escapeQueryStrValue(label) + "')"));
|
|
764
|
+
};
|
|
765
|
+
/**
|
|
766
|
+
* Creates a new file version from the file specified by the version label.
|
|
767
|
+
*
|
|
768
|
+
* @param label The version label of the file version to restore, for example: 1.2
|
|
769
|
+
*/
|
|
770
|
+
_Versions.prototype.restoreByLabel = function (label) {
|
|
771
|
+
return spPost(this.clone(Versions, "restoreByLabel(versionlabel='" + escapeQueryStrValue(label) + "')"));
|
|
772
|
+
};
|
|
773
|
+
__decorate([
|
|
774
|
+
tag("vers.deleteAll")
|
|
775
|
+
], _Versions.prototype, "deleteAll", null);
|
|
776
|
+
__decorate([
|
|
777
|
+
tag("vers.deleteById")
|
|
778
|
+
], _Versions.prototype, "deleteById", null);
|
|
779
|
+
__decorate([
|
|
780
|
+
tag("vers.recycleByID")
|
|
781
|
+
], _Versions.prototype, "recycleByID", null);
|
|
782
|
+
__decorate([
|
|
783
|
+
tag("vers.deleteByLabel")
|
|
784
|
+
], _Versions.prototype, "deleteByLabel", null);
|
|
785
|
+
__decorate([
|
|
786
|
+
tag("vers.recycleByLabel")
|
|
787
|
+
], _Versions.prototype, "recycleByLabel", null);
|
|
788
|
+
__decorate([
|
|
789
|
+
tag("vers.restoreByLabel")
|
|
790
|
+
], _Versions.prototype, "restoreByLabel", null);
|
|
791
|
+
_Versions = __decorate([
|
|
792
|
+
defaultPath("versions")
|
|
793
|
+
], _Versions);
|
|
794
|
+
return _Versions;
|
|
795
|
+
}(_SharePointQueryableCollection));
|
|
796
|
+
export { _Versions };
|
|
797
|
+
export var Versions = spInvokableFactory(_Versions);
|
|
798
|
+
/**
|
|
799
|
+
* Describes a single Version instance
|
|
800
|
+
*
|
|
801
|
+
*/
|
|
802
|
+
var _Version = /** @class */ (function (_super) {
|
|
803
|
+
__extends(_Version, _super);
|
|
804
|
+
function _Version() {
|
|
805
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
806
|
+
_this.delete = deleteableWithETag("ver");
|
|
807
|
+
return _this;
|
|
808
|
+
}
|
|
809
|
+
return _Version;
|
|
810
|
+
}(_SharePointQueryableInstance));
|
|
811
|
+
export { _Version };
|
|
812
|
+
export var Version = spInvokableFactory(_Version);
|
|
813
|
+
/**
|
|
814
|
+
* Types for document check in.
|
|
815
|
+
* Minor = 0
|
|
816
|
+
* Major = 1
|
|
817
|
+
* Overwrite = 2
|
|
818
|
+
*/
|
|
819
|
+
export var CheckinType;
|
|
820
|
+
(function (CheckinType) {
|
|
821
|
+
CheckinType[CheckinType["Minor"] = 0] = "Minor";
|
|
822
|
+
CheckinType[CheckinType["Major"] = 1] = "Major";
|
|
823
|
+
CheckinType[CheckinType["Overwrite"] = 2] = "Overwrite";
|
|
824
|
+
})(CheckinType || (CheckinType = {}));
|
|
825
|
+
/**
|
|
826
|
+
* File move opertions
|
|
827
|
+
*/
|
|
828
|
+
export var MoveOperations;
|
|
829
|
+
(function (MoveOperations) {
|
|
830
|
+
/**
|
|
831
|
+
* Produce an error if a file with the same name exists in the destination
|
|
832
|
+
*/
|
|
833
|
+
MoveOperations[MoveOperations["None"] = 0] = "None";
|
|
834
|
+
/**
|
|
835
|
+
* Overwrite a file with the same name if it exists. Value is 1.
|
|
836
|
+
*/
|
|
837
|
+
MoveOperations[MoveOperations["Overwrite"] = 1] = "Overwrite";
|
|
838
|
+
/**
|
|
839
|
+
* Complete the move operation even if supporting files are separated from the file. Value is 8.
|
|
840
|
+
*/
|
|
841
|
+
MoveOperations[MoveOperations["AllowBrokenThickets"] = 8] = "AllowBrokenThickets";
|
|
842
|
+
/**
|
|
843
|
+
* Boolean specifying whether to retain the source of the move's editor and modified by datetime.
|
|
844
|
+
*/
|
|
845
|
+
MoveOperations[MoveOperations["RetainEditorAndModifiedOnMove"] = 2048] = "RetainEditorAndModifiedOnMove";
|
|
846
|
+
})(MoveOperations || (MoveOperations = {}));
|
|
847
|
+
export var TemplateFileType;
|
|
848
|
+
(function (TemplateFileType) {
|
|
849
|
+
TemplateFileType[TemplateFileType["StandardPage"] = 0] = "StandardPage";
|
|
850
|
+
TemplateFileType[TemplateFileType["WikiPage"] = 1] = "WikiPage";
|
|
851
|
+
TemplateFileType[TemplateFileType["FormPage"] = 2] = "FormPage";
|
|
852
|
+
TemplateFileType[TemplateFileType["ClientSidePage"] = 3] = "ClientSidePage";
|
|
853
|
+
})(TemplateFileType || (TemplateFileType = {}));
|
|
854
854
|
//# sourceMappingURL=types.js.map
|