1 | import { _SPCollection, ISPInstance, IDeleteableWithETag, ISPQueryable, IDeleteable } from "../spqueryable.js";
|
2 | import { IItem } from "../items/index.js";
|
3 | import { ISiteUserProps } from "../site-users/types.js";
|
4 | import { IMoveCopyOptions } from "../types.js";
|
5 | import { ReadableFile } from "./readable-file.js";
|
6 | import "../context-info/index.js";
|
7 | /**
|
8 | * Describes a collection of File objects
|
9 | *
|
10 | */
|
11 | export declare class _Files extends _SPCollection<IFileInfo[]> {
|
12 | /**
|
13 | * Gets a File by filename
|
14 | *
|
15 | * @param name The name of the file, including extension.
|
16 | */
|
17 | getByUrl(name: string): IFile;
|
18 | /**
|
19 | * Adds a file using the pound percent safe methods
|
20 | *
|
21 | * @param url Encoded url of the file
|
22 | * @param content The file content
|
23 | * @param parameters Additional parameters to control method behavior
|
24 | */
|
25 | addUsingPath(url: string, content: string | ArrayBuffer | Blob, parameters?: IAddUsingPathProps): Promise<IFileAddResult>;
|
26 | /**
|
27 | * Uploads a file. Not supported for batching
|
28 | *
|
29 | * @param url The folder-relative url of the file.
|
30 | * @param content The Blob file content to add
|
31 | * @param progress A callback function which can be used to track the progress of the upload
|
32 | * @param shouldOverWrite Should a file with the same name in the same location be overwritten? (default: true)
|
33 | * @param chunkSize The size of each file slice, in bytes (default: 10485760)
|
34 | * @returns The new File and the raw response.
|
35 | */
|
36 | addChunked(url: string, content: Blob, progress?: (data: IFileUploadProgressData) => void, shouldOverWrite?: boolean, chunkSize?: number): Promise<IFileAddResult>;
|
37 | /**
|
38 | * Adds a ghosted file to an existing list or document library. Not supported for batching.
|
39 | *
|
40 | * @param fileUrl The server-relative url where you want to save the file.
|
41 | * @param templateFileType The type of use to create the file.
|
42 | * @returns The template file that was added and the raw response.
|
43 | */
|
44 | addTemplateFile(fileUrl: string, templateFileType: TemplateFileType): Promise<IFileAddResult>;
|
45 | }
|
46 | export interface IFiles extends _Files {
|
47 | }
|
48 | export declare const Files: import("../spqueryable.js").ISPInvokableFactory<IFiles>;
|
49 | /**
|
50 | * Describes a single File instance
|
51 | *
|
52 | */
|
53 | export declare class _File extends ReadableFile<IFileInfo> {
|
54 | delete: (this: ISPQueryable<any>, eTag?: string) => Promise<void>;
|
55 | /**
|
56 | * Gets a value that specifies the list item field values for the list item corresponding to the file.
|
57 | *
|
58 | */
|
59 | get listItemAllFields(): ISPInstance;
|
60 | /**
|
61 | * Gets a collection of versions
|
62 | *
|
63 | */
|
64 | get versions(): IVersions;
|
65 | /**
|
66 | * Gets the current locked by user
|
67 | *
|
68 | */
|
69 | getLockedByUser(): Promise<ISiteUserProps | null>;
|
70 | /**
|
71 | * Approves the file submitted for content approval with the specified comment.
|
72 | * Only documents in lists that are enabled for content approval can be approved.
|
73 | *
|
74 | * @param comment The comment for the approval.
|
75 | */
|
76 | approve(comment?: string): Promise<void>;
|
77 | /**
|
78 | * Stops the chunk upload session without saving the uploaded data. Does not support batching.
|
79 | * If the file doesn’t already exist in the library, the partially uploaded file will be deleted.
|
80 | * Use this in response to user action (as in a request to cancel an upload) or an error or exception.
|
81 | * Use the uploadId value that was passed to the StartUpload method that started the upload session.
|
82 | * This method is currently available only on Office 365.
|
83 | *
|
84 | * @param uploadId The unique identifier of the upload session.
|
85 | */
|
86 | cancelUpload(uploadId: string): Promise<void>;
|
87 | /**
|
88 | * Checks the file in to a document library based on the check-in type.
|
89 | *
|
90 | * @param comment A comment for the check-in. Its length must be <= 1023.
|
91 | * @param checkinType The check-in type for the file.
|
92 | */
|
93 | checkin(comment?: string, checkinType?: CheckinType): Promise<void>;
|
94 | /**
|
95 | * Checks out the file from a document library.
|
96 | */
|
97 | checkout(): Promise<void>;
|
98 | /**
|
99 | * Copies the file to the destination url.
|
100 | *
|
101 | * @param url The absolute url or server relative url of the destination file path to copy to.
|
102 | * @param shouldOverWrite Should a file with the same name in the same location be overwritten?
|
103 | */
|
104 | copyTo(url: string, shouldOverWrite?: boolean): Promise<void>;
|
105 | /**
|
106 | * Moves the file by path to the specified destination url.
|
107 | * Also works with different site collections.
|
108 | *
|
109 | * @param destUrl The absolute url or server relative url of the destination file path to move to.
|
110 | * @param shouldOverWrite Should a file with the same name in the same location be overwritten?
|
111 | * @param options Allows you to supply the full set of options controlling the copy behavior
|
112 | */
|
113 | copyByPath(destUrl: string, shouldOverWrite: boolean, options: Partial<Omit<IMoveCopyOptions, "RetainEditorAndModifiedOnMove">>): Promise<IFile>;
|
114 | /**
|
115 | * Moves the file by path to the specified destination url.
|
116 | * Also works with different site collections.
|
117 | *
|
118 | * @param destUrl The absolute url or server relative url of the destination file path to move to.
|
119 | * @param shouldOverWrite Should a file with the same name in the same location be overwritten?
|
120 | * @param keepBoth Keep both if file with the same name in the same location already exists? Only relevant when shouldOverWrite is set to false.
|
121 | */
|
122 | copyByPath(destUrl: string, shouldOverWrite: boolean, KeepBoth?: boolean): Promise<IFile>;
|
123 | /**
|
124 | * Denies approval for a file that was submitted for content approval.
|
125 | * Only documents in lists that are enabled for content approval can be denied.
|
126 | *
|
127 | * @param comment The comment for the denial.
|
128 | */
|
129 | deny(comment?: string): Promise<void>;
|
130 | /**
|
131 | * Moves the file by path to the specified destination url.
|
132 | * Also works with different site collections.
|
133 | *
|
134 | * @param destUrl The absolute url or server relative url of the destination file path to move to.
|
135 | * @param shouldOverWrite Should a file with the same name in the same location be overwritten?
|
136 | * @param options Allows you to supply the full set of options controlling the move behavior
|
137 | */
|
138 | moveByPath(destUrl: string, shouldOverWrite: boolean, options: Partial<Omit<IMoveCopyOptions, "ResetAuthorAndCreatedOnCopy">>): Promise<IFile>;
|
139 | /**
|
140 | * Moves the file by path to the specified destination url.
|
141 | * Also works with different site collections.
|
142 | *
|
143 | * @param destUrl The absolute url or server relative url of the destination file path to move to.
|
144 | * @param shouldOverWrite Should a file with the same name in the same location be overwritten?
|
145 | * @param keepBoth Keep both if file with the same name in the same location already exists? Only relevant when shouldOverWrite is set to false.
|
146 | */
|
147 | moveByPath(destUrl: string, shouldOverWrite: boolean, KeepBoth?: boolean): Promise<IFile>;
|
148 | /**
|
149 | * Submits the file for content approval with the specified comment.
|
150 | *
|
151 | * @param comment The comment for the published file. Its length must be <= 1023.
|
152 | */
|
153 | publish(comment?: string): Promise<void>;
|
154 | /**
|
155 | * Moves the file to the Recycle Bin and returns the identifier of the new Recycle Bin item.
|
156 | *
|
157 | * @returns The GUID of the recycled file.
|
158 | */
|
159 | recycle(): Promise<string>;
|
160 | /**
|
161 | * Deletes the file object with options.
|
162 | *
|
163 | * @param parameters Specifies the options to use when deleting a file.
|
164 | */
|
165 | deleteWithParams(parameters: Partial<IFileDeleteParams>): Promise<void>;
|
166 | /**
|
167 | * Reverts an existing checkout for the file.
|
168 | *
|
169 | */
|
170 | undoCheckout(): Promise<void>;
|
171 | /**
|
172 | * Removes the file from content approval or unpublish a major version.
|
173 | *
|
174 | * @param comment The comment for the unpublish operation. Its length must be <= 1023.
|
175 | */
|
176 | unpublish(comment?: string): Promise<void>;
|
177 | /**
|
178 | * Checks to see if the file represented by this object exists
|
179 | *
|
180 | */
|
181 | exists(): Promise<boolean>;
|
182 | /**
|
183 | * Sets the content of a file, for large files use setContentChunked. Not supported in batching.
|
184 | *
|
185 | * @param content The file content
|
186 | *
|
187 | */
|
188 | setContent(content: string | ArrayBuffer | Blob): Promise<IFile>;
|
189 | /**
|
190 | * Gets the associated list item for this folder, loading the default properties
|
191 | */
|
192 | getItem<T>(...selects: string[]): Promise<IItem & T>;
|
193 | /**
|
194 | * Sets the contents of a file using a chunked upload approach. Not supported in batching.
|
195 | *
|
196 | * @param file The file to upload
|
197 | * @param progress A callback function which can be used to track the progress of the upload
|
198 | * @param chunkSize The size of each file slice, in bytes (default: 10485760)
|
199 | */
|
200 | setContentChunked(file: Blob, progress?: (data: IFileUploadProgressData) => void, chunkSize?: number): Promise<IFileAddResult>;
|
201 | /**
|
202 | * Starts a new chunk upload session and uploads the first fragment.
|
203 | * The current file content is not changed when this method completes.
|
204 | * The method is idempotent (and therefore does not change the result) as long as you use the same values for uploadId and stream.
|
205 | * The upload session ends either when you use the CancelUpload method or when you successfully
|
206 | * complete the upload session by passing the rest of the file contents through the ContinueUpload and FinishUpload methods.
|
207 | * The StartUpload and ContinueUpload methods return the size of the running total of uploaded data in bytes,
|
208 | * so you can pass those return values to subsequent uses of ContinueUpload and FinishUpload.
|
209 | * This method is currently available only on Office 365.
|
210 | *
|
211 | * @param uploadId The unique identifier of the upload session.
|
212 | * @param fragment The file contents.
|
213 | * @returns The size of the total uploaded data in bytes.
|
214 | */
|
215 | protected startUpload(uploadId: string, fragment: ArrayBuffer | Blob): Promise<number>;
|
216 | /**
|
217 | * Continues the chunk upload session with an additional fragment.
|
218 | * The current file content is not changed.
|
219 | * Use the uploadId value that was passed to the StartUpload method that started the upload session.
|
220 | * This method is currently available only on Office 365.
|
221 | *
|
222 | * @param uploadId The unique identifier of the upload session.
|
223 | * @param fileOffset The size of the offset into the file where the fragment starts.
|
224 | * @param fragment The file contents.
|
225 | * @returns The size of the total uploaded data in bytes.
|
226 | */
|
227 | protected continueUpload(uploadId: string, fileOffset: number, fragment: ArrayBuffer | Blob): Promise<number>;
|
228 | /**
|
229 | * Uploads the last file fragment and commits the file. The current file content is changed when this method completes.
|
230 | * Use the uploadId value that was passed to the StartUpload method that started the upload session.
|
231 | * This method is currently available only on Office 365.
|
232 | *
|
233 | * @param uploadId The unique identifier of the upload session.
|
234 | * @param fileOffset The size of the offset into the file where the fragment starts.
|
235 | * @param fragment The file contents.
|
236 | * @returns The newly uploaded file.
|
237 | */
|
238 | protected finishUpload(uploadId: string, fileOffset: number, fragment: ArrayBuffer | Blob): Promise<IFileAddResult>;
|
239 | }
|
240 | export interface IFile extends _File, IDeleteableWithETag {
|
241 | }
|
242 | export declare const File: import("../spqueryable.js").ISPInvokableFactory<IFile>;
|
243 | /**
|
244 | * Creates an IFile instance given a base object and a server relative path
|
245 | *
|
246 | * @param base Valid SPQueryable from which the observers will be used and the web url extracted
|
247 | * @param serverRelativePath The server relative url to the file (ex: '/sites/dev/documents/file.txt')
|
248 | * @returns IFile instance referencing the file described by the supplied parameters
|
249 | */
|
250 | export declare function fileFromServerRelativePath(base: ISPQueryable, serverRelativePath: string): IFile;
|
251 | /**
|
252 | * Creates an IFile instance given a base object and an absolute path
|
253 | *
|
254 | * @param base Valid SPQueryable from which the observers will be used
|
255 | * @param serverRelativePath The absolute url to the file (ex: 'https://tenant.sharepoint.com/sites/dev/documents/file.txt')
|
256 | * @returns IFile instance referencing the file described by the supplied parameters
|
257 | */
|
258 | export declare function fileFromAbsolutePath(base: ISPQueryable, absoluteFilePath: string): Promise<IFile>;
|
259 | /**
|
260 | * Creates an IFile intance given a base object and either an absolute or server relative path to a file
|
261 | *
|
262 | * @param base Valid SPQueryable from which the observers will be used
|
263 | * @param serverRelativePath server relative or absolute url to the file (ex: 'https://tenant.sharepoint.com/sites/dev/documents/file.txt' or '/sites/dev/documents/file.txt')
|
264 | * @returns IFile instance referencing the file described by the supplied parameters
|
265 | */
|
266 | export declare function fileFromPath(base: ISPQueryable, path: string): Promise<IFile>;
|
267 | /**
|
268 | * Describes a collection of Version objects
|
269 | *
|
270 | */
|
271 | export declare class _Versions extends _SPCollection {
|
272 | /**
|
273 | * Gets a version by id
|
274 | *
|
275 | * @param versionId The id of the version to retrieve
|
276 | */
|
277 | getById(versionId: number): IVersion;
|
278 | /**
|
279 | * Deletes all the file version objects in the collection.
|
280 | *
|
281 | */
|
282 | deleteAll(): Promise<void>;
|
283 | /**
|
284 | * Deletes the specified version of the file.
|
285 | *
|
286 | * @param versionId The ID of the file version to delete.
|
287 | */
|
288 | deleteById(versionId: number): Promise<void>;
|
289 | /**
|
290 | * Recycles the specified version of the file.
|
291 | *
|
292 | * @param versionId The ID of the file version to delete.
|
293 | */
|
294 | recycleByID(versionId: number): Promise<void>;
|
295 | /**
|
296 | * Deletes the file version object with the specified version label.
|
297 | *
|
298 | * @param label The version label of the file version to delete, for example: 1.2
|
299 | */
|
300 | deleteByLabel(label: string): Promise<void>;
|
301 | /**
|
302 | * Recycles the file version object with the specified version label.
|
303 | *
|
304 | * @param label The version label of the file version to delete, for example: 1.2
|
305 | */
|
306 | recycleByLabel(label: string): Promise<void>;
|
307 | /**
|
308 | * Creates a new file version from the file specified by the version label.
|
309 | *
|
310 | * @param label The version label of the file version to restore, for example: 1.2
|
311 | */
|
312 | restoreByLabel(label: string): Promise<void>;
|
313 | }
|
314 | export interface IVersions extends _Versions {
|
315 | }
|
316 | export declare const Versions: import("../spqueryable.js").ISPInvokableFactory<IVersions>;
|
317 | /**
|
318 | * Describes a single Version instance
|
319 | *
|
320 | */
|
321 | export declare class _Version extends ReadableFile<IVersionInfo> {
|
322 | delete: (this: ISPQueryable<any>) => Promise<void>;
|
323 | }
|
324 | export interface IVersion extends _Version, IDeleteable {
|
325 | }
|
326 | export declare const Version: import("../spqueryable.js").ISPInvokableFactory<IVersion>;
|
327 | /**
|
328 | * Types for document check in.
|
329 | * Minor = 0
|
330 | * Major = 1
|
331 | * Overwrite = 2
|
332 | */
|
333 | export declare enum CheckinType {
|
334 | Minor = 0,
|
335 | Major = 1,
|
336 | Overwrite = 2
|
337 | }
|
338 | /**
|
339 | * Describes file and result
|
340 | */
|
341 | export interface IFileAddResult {
|
342 | file: IFile;
|
343 | data: IFileInfo;
|
344 | }
|
345 | /**
|
346 | * File move opertions
|
347 | */
|
348 | export declare enum MoveOperations {
|
349 | /**
|
350 | * Produce an error if a file with the same name exists in the destination
|
351 | */
|
352 | None = 0,
|
353 | /**
|
354 | * Overwrite a file with the same name if it exists. Value is 1.
|
355 | */
|
356 | Overwrite = 1,
|
357 | /**
|
358 | * Complete the move operation even if supporting files are separated from the file. Value is 8.
|
359 | */
|
360 | AllowBrokenThickets = 8,
|
361 | /**
|
362 | * Boolean specifying whether to retain the source of the move's editor and modified by datetime.
|
363 | */
|
364 | RetainEditorAndModifiedOnMove = 2048
|
365 | }
|
366 | export declare enum TemplateFileType {
|
367 | StandardPage = 0,
|
368 | WikiPage = 1,
|
369 | FormPage = 2,
|
370 | ClientSidePage = 3
|
371 | }
|
372 | /**
|
373 | * Describes SharePoint file upload progress data
|
374 | */
|
375 | export interface IFileUploadProgressData {
|
376 | uploadId: string;
|
377 | stage: "starting" | "continue" | "finishing";
|
378 | blockNumber: number;
|
379 | totalBlocks: number;
|
380 | chunkSize: number;
|
381 | currentPointer: number;
|
382 | fileSize: number;
|
383 | }
|
384 | export interface IAddUsingPathProps {
|
385 | /**
|
386 | * Overwrite the file if it exists
|
387 | */
|
388 | Overwrite: boolean;
|
389 | /**
|
390 | * specifies whether to auto checkout on invalid Data. It'll be useful if the list contains validation whose requirements upload will not be able to meet.
|
391 | */
|
392 | AutoCheckoutOnInvalidData?: boolean;
|
393 | /**
|
394 | * Specifies a XOR hash of the file data which should be used to ensure end-2-end data integrity, base64 representation
|
395 | */
|
396 | XorHash?: string;
|
397 | }
|
398 | export interface IFileInfo {
|
399 | readonly "odata.id": string;
|
400 | CheckInComment: string;
|
401 | CheckOutType: number;
|
402 | ContentTag: string;
|
403 | CustomizedPageStatus: number;
|
404 | ETag: string;
|
405 | Exists: boolean;
|
406 | IrmEnabled: boolean;
|
407 | Length: string;
|
408 | Level: number;
|
409 | LinkingUri: string | null;
|
410 | LinkingUrl: string;
|
411 | ListId: string;
|
412 | MajorVersion: number;
|
413 | MinorVersion: number;
|
414 | Name: string;
|
415 | ServerRelativeUrl: string;
|
416 | SiteId: string;
|
417 | TimeCreated: string;
|
418 | TimeLastModified: string;
|
419 | Title: string | null;
|
420 | UIVersion: number;
|
421 | UIVersionLabel: string;
|
422 | UniqueId: string;
|
423 | WebId: string;
|
424 | }
|
425 | export interface IVersionInfo {
|
426 | Created: string;
|
427 | ID: number;
|
428 | VersionLabel: string;
|
429 | Length: number;
|
430 | Size: number;
|
431 | CreatedBy: any;
|
432 | Url: string;
|
433 | IsCurrentVersion: boolean;
|
434 | CheckInComment: string;
|
435 | }
|
436 | export interface IFileDeleteParams {
|
437 | /**
|
438 | * If true, delete or recyle a file when the LockType
|
439 | * value is SPLockType.Shared or SPLockType.None.
|
440 | * When false, delete or recycle the file when
|
441 | * the LockType value SPLockType.None.
|
442 | */
|
443 | BypassSharedLock: boolean;
|
444 | /**
|
445 | * Gets or sets a string value that allows SPfile delete and recycle methods
|
446 | * to target a file with a matching value. Use null to unconditionally delete the file.
|
447 | */
|
448 | ETagMatch: string;
|
449 | }
|
450 | //# sourceMappingURL=types.d.ts.map |
\ | No newline at end of file |