UNPKG

8.62 kBTypeScriptView Raw
1import { _SPCollection, _SPInstance, ISPInstance, IDeleteableWithETag, ISPQueryable } from "../spqueryable.js";
2import { IItem } from "../items/types.js";
3import { IResourcePath } from "../utils/to-resource-path.js";
4import "../context-info/index.js";
5import { IMoveCopyOptions } from "../types.js";
6export declare class _Folders extends _SPCollection<IFolderInfo[]> {
7 /**
8 * Gets a folder by it's name
9 *
10 * @param name Folder's name
11 */
12 getByUrl(name: string): IFolder;
13 /**
14 * Adds a new folder by path and should be prefered over add
15 *
16 * @param serverRelativeUrl The server relative url of the new folder to create
17 * @param overwrite True to overwrite an existing folder, default false
18 */
19 addUsingPath(serverRelativeUrl: string, overwrite?: boolean): Promise<IFolderAddResult>;
20}
21export interface IFolders extends _Folders {
22}
23export declare const Folders: import("../spqueryable.js").ISPInvokableFactory<IFolders>;
24export declare class _Folder extends _SPInstance<IFolderInfo> {
25 delete: (this: ISPQueryable<any>, eTag?: string) => Promise<void>;
26 /**
27 * Gets this folder's sub folders
28 *
29 */
30 get folders(): IFolders;
31 /**
32 * Gets this folder's list item field values
33 *
34 */
35 get listItemAllFields(): ISPInstance;
36 /**
37 * Gets the parent folder, if available
38 *
39 */
40 get parentFolder(): IFolder;
41 /**
42 * Gets this folder's properties
43 *
44 */
45 get properties(): ISPInstance;
46 /**
47 * Gets this folder's storage metrics information
48 *
49 */
50 get storageMetrics(): ISPInstance<IStorageMetrics>;
51 /**
52 * Updates folder's properties
53 * @param props Folder's properties to update
54 */
55 update(props: Partial<IFolderInfo>): Promise<IFolderUpdateResult>;
56 /**
57 * Moves the folder to the Recycle Bin and returns the identifier of the new Recycle Bin item.
58 */
59 recycle(): Promise<string>;
60 /**
61 * Gets the associated list item for this folder, loading the default properties
62 */
63 getItem<T>(...selects: string[]): Promise<IItem & T>;
64 /**
65 * Moves the file by path to the specified destination url.
66 * Also works with different site collections.
67 *
68 * @param destUrl The absolute url or server relative url of the destination file path to move to.
69 * @param shouldOverWrite Should a file with the same name in the same location be overwritten?
70 * @param options Allows you to supply the full set of options controlling the move behavior
71 */
72 moveByPath(destUrl: string, options: Partial<Omit<IMoveCopyOptions, "ResetAuthorAndCreatedOnCopy">>): Promise<IFolder>;
73 /**
74 * Moves the file by path to the specified destination url.
75 * Also works with different site collections.
76 *
77 * @param destUrl The absolute url or server relative url of the destination file path to move to.
78 * @param keepBoth Keep both if file with the same name in the same location already exists? Only relevant when shouldOverWrite is set to false.
79 */
80 moveByPath(destUrl: string, KeepBoth?: boolean): Promise<IFolder>;
81 /**
82 * Moves the folder by path to the specified destination url.
83 * Also works with different site collections.
84 *
85 * @param destUrl The absolute url or server relative url of the destination folder path to move to.
86 * @param shouldOverWrite Should a folder with the same name in the same location be overwritten?
87 * @param options Allows you to supply the full set of options controlling the copy behavior
88 */
89 copyByPath(destUrl: string, options: Partial<Omit<IMoveCopyOptions, "RetainEditorAndModifiedOnMove">>): Promise<IFolder>;
90 /**
91 * Copies a folder by path to destination path
92 * Also works with different site collections.
93 *
94 * @param destUrl Absolute or relative URL of the destination path
95 * @param keepBoth Keep both if folder with the same name in the same location already exists?
96 */
97 copyByPath(destUrl: string, KeepBoth?: boolean): Promise<IFolder>;
98 /**
99 * Deletes the folder object with options.
100 *
101 * @param parameters Specifies the options to use when deleting a folder.
102 */
103 deleteWithParams(parameters: Partial<IFolderDeleteParams>): Promise<void>;
104 /**
105 * Create the subfolder inside the current folder, as specified by the leafPath
106 *
107 * @param leafPath leafName of the new folder
108 */
109 addSubFolderUsingPath(leafPath: string): Promise<IFolder>;
110 /**
111 * Gets the parent information for this folder's list and web
112 */
113 getParentInfos(): Promise<IFolderParentInfos>;
114}
115export interface IFolder extends _Folder, IDeleteableWithETag {
116}
117export declare const Folder: import("../spqueryable.js").ISPInvokableFactory<IFolder>;
118/**
119 * Creates an IFolder instance given a base object and a server relative path
120 *
121 * @param base Valid SPQueryable from which the observers will be used and the web url extracted
122 * @param serverRelativePath The server relative url to the folder (ex: '/sites/dev/documents/folder3')
123 * @returns IFolder instance referencing the folder described by the supplied parameters
124 */
125export declare function folderFromServerRelativePath(base: ISPQueryable, serverRelativePath: string): IFolder;
126/**
127 * Creates an IFolder instance given a base object and an absolute path
128 *
129 * @param base Valid SPQueryable from which the observers will be used
130 * @param serverRelativePath The absolute url to the folder (ex: 'https://tenant.sharepoint.com/sites/dev/documents/folder/')
131 * @returns IFolder instance referencing the folder described by the supplied parameters
132 */
133export declare function folderFromAbsolutePath(base: ISPQueryable, absoluteFolderPath: string): Promise<IFolder>;
134/**
135 * Creates an IFolder intance given a base object and either an absolute or server relative path to a folder
136 *
137 * @param base Valid SPQueryable from which the observers will be used
138 * @param serverRelativePath server relative or absolute url to the file (ex: 'https://tenant.sharepoint.com/sites/dev/documents/folder' or '/sites/dev/documents/folder')
139 * @returns IFile instance referencing the file described by the supplied parameters
140 */
141export declare function folderFromPath(base: ISPQueryable, path: string): Promise<IFolder>;
142/**
143 * Describes result of adding a folder
144 */
145export interface IFolderAddResult {
146 /**
147 * A folder's instance
148 */
149 folder: IFolder;
150 /**
151 * Additional data from the server
152 */
153 data: any;
154}
155/**
156 * Describes result of updating a folder
157 */
158export interface IFolderUpdateResult {
159 /**
160 * A folder's instance
161 */
162 folder: IFolder;
163 /**
164 * Additional data from the server
165 */
166 data: any;
167}
168export interface IFolderInfo {
169 readonly "odata.id": string;
170 Exists: boolean;
171 IsWOPIEnabled: boolean;
172 ItemCount: number;
173 Name: string;
174 ProgID: string | null;
175 ServerRelativeUrl: string;
176 ServerRelativePath: IResourcePath;
177 TimeCreated: string;
178 TimeLastModified: string;
179 UniqueId: string;
180 WelcomePage: string;
181 ContentTypeOrder: string[];
182 UniqueContentTypeOrder: string[];
183 StorageMetrics?: IStorageMetrics;
184}
185export interface IStorageMetrics {
186 LastModified: string;
187 TotalFileCount: number;
188 TotalFileStreamSize: number;
189 TotalSize: number;
190}
191export interface IFolderDeleteParams {
192 /**
193 * If true, delete or recycle a folder iff all files have
194 * LockType values SPLockType.Shared or SPLockType.None.
195 * When false, delete or recycle the folder if all files
196 * have the LockType value SPLockType.None. See the <see cref="SPFile.SPLockType"/> enum.
197 */
198 BypassSharedLock: boolean;
199 /**
200 * Gets or sets a string value that allows SPFolder delete
201 * and recycle methods to target a folder with a matching value
202 */
203 ETagMatch: string;
204 /**
205 * Gets or sets a Boolean that controls the way in which folders
206 * are deleted. If set to true, only empty folders will be deleted.
207 * If set to false, folders that are not empty may be deleted.
208 */
209 DeleteIfEmpty: boolean;
210}
211export interface IFolderParentInfos {
212 Folder: {
213 ServerRelativeUrl: string;
214 };
215 ParentList: {
216 Id: string;
217 RootFolderServerRelativePath: IResourcePath;
218 RootFolderServerRelativeUrl: string;
219 RootFolderUniqueId: string;
220 };
221 ParentWeb: {
222 Id: string;
223 ServerRelativePath: IResourcePath;
224 ServerRelativeUrl: string;
225 Url: string;
226 };
227}
228//# sourceMappingURL=types.d.ts.map
\No newline at end of file