UNPKG

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