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