UNPKG

33.1 kBTypeScriptView Raw
1import type { ISharedDocument } from '@jupyter/ydoc';
2import { IDisposable } from '@lumino/disposable';
3import { ISignal } from '@lumino/signaling';
4import { ServerConnection } from '..';
5/**
6 * A namespace for contents interfaces.
7 */
8export declare namespace Contents {
9 /**
10 * A contents model.
11 */
12 interface IModel {
13 /**
14 * Name of the contents file.
15 *
16 * #### Notes
17 * Equivalent to the last part of the `path` field.
18 */
19 readonly name: string;
20 /**
21 * The full file path.
22 *
23 * #### Notes
24 * It will *not* start with `/`, and it will be `/`-delimited.
25 */
26 readonly path: string;
27 /**
28 * The path as returned by the server contents API.
29 *
30 * #### Notes
31 * Differently to `path` it does not include IDrive API prefix.
32 */
33 readonly serverPath?: string;
34 /**
35 * The type of file.
36 */
37 readonly type: ContentType;
38 /**
39 * Whether the requester has permission to edit the file.
40 */
41 readonly writable: boolean;
42 /**
43 * File creation timestamp.
44 */
45 readonly created: string;
46 /**
47 * Last modified timestamp.
48 */
49 readonly last_modified: string;
50 /**
51 * Specify the mime-type of file contents.
52 *
53 * #### Notes
54 * Only non-`null` when `content` is present and `type` is `"file"`.
55 */
56 readonly mimetype: string;
57 /**
58 * The optional file content.
59 */
60 readonly content: any;
61 /**
62 * The chunk of the file upload.
63 */
64 readonly chunk?: number;
65 /**
66 * The format of the file `content`.
67 *
68 * #### Notes
69 * Only relevant for type: 'file'
70 */
71 readonly format: FileFormat;
72 /**
73 * The size of then file in bytes.
74 */
75 readonly size?: number;
76 /**
77 * The indices of the matched characters in the name.
78 */
79 indices?: ReadonlyArray<number> | null;
80 /**
81 * The hexdigest hash string of content, if requested (otherwise null).
82 * It cannot be null if hash_algorithm is defined.
83 */
84 readonly hash?: string;
85 /**
86 * The algorithm used to compute hash value. It cannot be null if hash is defined.
87 */
88 readonly hash_algorithm?: string;
89 }
90 /**
91 * Validates an IModel, throwing an error if it does not pass.
92 */
93 function validateContentsModel(contents: IModel): void;
94 /**
95 * A contents file type. It can be anything but `jupyter-server`
96 * has special treatment for `notebook` and `directory` types.
97 * Anything else is considered as `file` type.
98 */
99 type ContentType = string;
100 /**
101 * A contents file format. Always `json` for `notebook` and
102 * `directory` types. It should be set to either `text` or
103 * `base64` for `file` type.
104 * See the
105 * [jupyter server data model for filesystem entities](https://jupyter-server.readthedocs.io/en/latest/developers/contents.html#filesystem-entities)
106 * for more details.
107 */
108 type FileFormat = 'json' | 'text' | 'base64' | null;
109 /**
110 * The options used to fetch a file.
111 */
112 interface IFetchOptions {
113 /**
114 * The override file type for the request.
115 */
116 type?: ContentType;
117 /**
118 * The override file format for the request.
119 */
120 format?: FileFormat;
121 /**
122 * Whether to include the file content.
123 *
124 * The default is `true`.
125 */
126 content?: boolean;
127 /**
128 * Whether to include a hash in the response.
129 *
130 * The default is `false`.
131 */
132 hash?: boolean;
133 }
134 /**
135 * The options used to create a file.
136 */
137 interface ICreateOptions {
138 /**
139 * The directory in which to create the file.
140 */
141 path?: string;
142 /**
143 * The optional file extension for the new file (e.g. `".txt"`).
144 *
145 * #### Notes
146 * This ignored if `type` is `'notebook'`.
147 */
148 ext?: string;
149 /**
150 * The file type.
151 */
152 type?: ContentType;
153 }
154 /**
155 * Checkpoint model.
156 */
157 interface ICheckpointModel {
158 /**
159 * The unique identifier for the checkpoint.
160 */
161 readonly id: string;
162 /**
163 * Last modified timestamp.
164 */
165 readonly last_modified: string;
166 }
167 /**
168 * Validates an ICheckpointModel, throwing an error if it does not pass.
169 */
170 function validateCheckpointModel(checkpoint: ICheckpointModel): void;
171 /**
172 * The change args for a file change.
173 */
174 interface IChangedArgs {
175 /**
176 * The type of change.
177 */
178 type: 'new' | 'delete' | 'rename' | 'save';
179 /**
180 * The old contents.
181 */
182 oldValue: Partial<IModel> | null;
183 /**
184 * The new contents.
185 */
186 newValue: Partial<IModel> | null;
187 }
188 /**
189 * A factory interface for creating `ISharedDocument` objects.
190 */
191 interface ISharedFactory {
192 /**
193 * Whether the IDrive supports real-time collaboration or not.
194 * Note: If it is not provided, it is false by default.
195 */
196 readonly collaborative?: boolean;
197 /**
198 * Create a new `ISharedDocument` instance.
199 *
200 * It should return `undefined` if the factory is not able to create a `ISharedDocument`.
201 */
202 createNew(options: ISharedFactoryOptions): ISharedDocument | undefined;
203 }
204 /**
205 * The options used to instantiate a ISharedDocument
206 */
207 interface ISharedFactoryOptions {
208 /**
209 * The path of the file.
210 */
211 path: string;
212 /**
213 * The format of the document. If null, the document won't be
214 * collaborative.
215 */
216 format: FileFormat;
217 /**
218 * The content type of the document.
219 */
220 contentType: ContentType;
221 /**
222 * Whether the document is collaborative or not.
223 *
224 * The default value is `true`.
225 */
226 collaborative?: boolean;
227 }
228 /**
229 * The interface for a contents manager.
230 */
231 interface IManager extends IDisposable {
232 /**
233 * A signal emitted when a file operation takes place.
234 */
235 readonly fileChanged: ISignal<IManager, IChangedArgs>;
236 /**
237 * The server settings associated with the manager.
238 */
239 readonly serverSettings: ServerConnection.ISettings;
240 /**
241 * Add an `IDrive` to the manager.
242 */
243 addDrive(drive: IDrive): void;
244 /**
245 * Given a path of the form `drive:local/portion/of/it.txt`
246 * get the local part of it.
247 *
248 * @param path the path.
249 *
250 * @returns The local part of the path.
251 */
252 localPath(path: string): string;
253 /**
254 * Normalize a global path. Reduces '..' and '.' parts, and removes
255 * leading slashes from the local part of the path, while retaining
256 * the drive name if it exists.
257 *
258 * @param path the path.
259 *
260 * @returns The normalized path.
261 */
262 normalize(path: string): string;
263 /**
264 * Resolve a global path, starting from the root path. Behaves like
265 * posix-path.resolve, with 3 differences:
266 * - will never prepend cwd
267 * - if root has a drive name, the result is prefixed with "<drive>:"
268 * - before adding drive name, leading slashes are removed
269 *
270 * @param path the path.
271 *
272 * @returns The normalized path.
273 */
274 resolvePath(root: string, path: string): string;
275 /**
276 * Given a path of the form `drive:local/portion/of/it.txt`
277 * get the name of the drive. If the path is missing
278 * a drive portion, returns an empty string.
279 *
280 * @param path the path.
281 *
282 * @returns The drive name for the path, or the empty string.
283 */
284 driveName(path: string): string;
285 /**
286 * Given a path, get a shared model IFactory from the
287 * relevant backend. Returns `null` if the backend
288 * does not provide one.
289 */
290 getSharedModelFactory(path: string): ISharedFactory | null;
291 /**
292 * Get a file or directory.
293 *
294 * @param path The path to the file.
295 *
296 * @param options The options used to fetch the file.
297 *
298 * @returns A promise which resolves with the file content.
299 */
300 get(path: string, options?: IFetchOptions): Promise<IModel>;
301 /**
302 * Get an encoded download url given a file path.
303 *
304 * @param A promise which resolves with the absolute POSIX
305 * file path on the server.
306 *
307 * #### Notes
308 * The returned URL may include a query parameter.
309 */
310 getDownloadUrl(path: string): Promise<string>;
311 /**
312 * Create a new untitled file or directory in the specified directory path.
313 *
314 * @param options The options used to create the file.
315 *
316 * @returns A promise which resolves with the created file content when the
317 * file is created.
318 */
319 newUntitled(options?: ICreateOptions): Promise<IModel>;
320 /**
321 * Delete a file.
322 *
323 * @param path - The path to the file.
324 *
325 * @returns A promise which resolves when the file is deleted.
326 */
327 delete(path: string): Promise<void>;
328 /**
329 * Rename a file or directory.
330 *
331 * @param path - The original file path.
332 *
333 * @param newPath - The new file path.
334 *
335 * @returns A promise which resolves with the new file content model when the
336 * file is renamed.
337 */
338 rename(path: string, newPath: string): Promise<IModel>;
339 /**
340 * Save a file.
341 *
342 * @param path - The desired file path.
343 *
344 * @param options - Optional overrides to the model.
345 *
346 * @returns A promise which resolves with the file content model when the
347 * file is saved.
348 */
349 save(path: string, options?: Partial<IModel>): Promise<IModel>;
350 /**
351 * Copy a file into a given directory.
352 *
353 * @param path - The original file path.
354 *
355 * @param toDir - The destination directory path.
356 *
357 * @returns A promise which resolves with the new content model when the
358 * file is copied.
359 */
360 copy(path: string, toDir: string): Promise<IModel>;
361 /**
362 * Create a checkpoint for a file.
363 *
364 * @param path - The path of the file.
365 *
366 * @returns A promise which resolves with the new checkpoint model when the
367 * checkpoint is created.
368 */
369 createCheckpoint(path: string): Promise<ICheckpointModel>;
370 /**
371 * List available checkpoints for a file.
372 *
373 * @param path - The path of the file.
374 *
375 * @returns A promise which resolves with a list of checkpoint models for
376 * the file.
377 */
378 listCheckpoints(path: string): Promise<ICheckpointModel[]>;
379 /**
380 * Restore a file to a known checkpoint state.
381 *
382 * @param path - The path of the file.
383 *
384 * @param checkpointID - The id of the checkpoint to restore.
385 *
386 * @returns A promise which resolves when the checkpoint is restored.
387 */
388 restoreCheckpoint(path: string, checkpointID: string): Promise<void>;
389 /**
390 * Delete a checkpoint for a file.
391 *
392 * @param path - The path of the file.
393 *
394 * @param checkpointID - The id of the checkpoint to delete.
395 *
396 * @returns A promise which resolves when the checkpoint is deleted.
397 */
398 deleteCheckpoint(path: string, checkpointID: string): Promise<void>;
399 }
400 /**
401 * The interface for a network drive that can be mounted
402 * in the contents manager.
403 */
404 interface IDrive extends IDisposable {
405 /**
406 * The name of the drive, which is used at the leading
407 * component of file paths.
408 */
409 readonly name: string;
410 /**
411 * The server settings of the manager.
412 */
413 readonly serverSettings: ServerConnection.ISettings;
414 /**
415 * An optional shared model factory instance for the
416 * drive.
417 */
418 readonly sharedModelFactory?: ISharedFactory;
419 /**
420 * A signal emitted when a file operation takes place.
421 */
422 fileChanged: ISignal<IDrive, IChangedArgs>;
423 /**
424 * Get a file or directory.
425 *
426 * @param localPath The path to the file.
427 *
428 * @param options The options used to fetch the file.
429 *
430 * @returns A promise which resolves with the file content.
431 */
432 get(localPath: string, options?: IFetchOptions): Promise<IModel>;
433 /**
434 * Get an encoded download url given a file path.
435 *
436 * @returns A promise which resolves with the absolute POSIX
437 * file path on the server.
438 *
439 * #### Notes
440 * The returned URL may include a query parameter.
441 */
442 getDownloadUrl(localPath: string): Promise<string>;
443 /**
444 * Create a new untitled file or directory in the specified directory path.
445 *
446 * @param options The options used to create the file.
447 *
448 * @returns A promise which resolves with the created file content when the
449 * file is created.
450 */
451 newUntitled(options?: ICreateOptions): Promise<IModel>;
452 /**
453 * Delete a file.
454 *
455 * @param localPath - The path to the file.
456 *
457 * @returns A promise which resolves when the file is deleted.
458 */
459 delete(localPath: string): Promise<void>;
460 /**
461 * Rename a file or directory.
462 *
463 * @param oldLocalPath - The original file path.
464 *
465 * @param newLocalPath - The new file path.
466 *
467 * @returns A promise which resolves with the new file content model when the
468 * file is renamed.
469 */
470 rename(oldLocalPath: string, newLocalPath: string): Promise<IModel>;
471 /**
472 * Save a file.
473 *
474 * @param localPath - The desired file path.
475 *
476 * @param options - Optional overrides to the model.
477 *
478 * @returns A promise which resolves with the file content model when the
479 * file is saved.
480 */
481 save(localPath: string, options?: Partial<IModel>): Promise<IModel>;
482 /**
483 * Copy a file into a given directory.
484 *
485 * @param localPath - The original file path.
486 *
487 * @param toLocalDir - The destination directory path.
488 *
489 * @returns A promise which resolves with the new content model when the
490 * file is copied.
491 */
492 copy(localPath: string, toLocalDir: string): Promise<IModel>;
493 /**
494 * Create a checkpoint for a file.
495 *
496 * @param localPath - The path of the file.
497 *
498 * @returns A promise which resolves with the new checkpoint model when the
499 * checkpoint is created.
500 */
501 createCheckpoint(localPath: string): Promise<ICheckpointModel>;
502 /**
503 * List available checkpoints for a file.
504 *
505 * @param localPath - The path of the file.
506 *
507 * @returns A promise which resolves with a list of checkpoint models for
508 * the file.
509 */
510 listCheckpoints(localPath: string): Promise<ICheckpointModel[]>;
511 /**
512 * Restore a file to a known checkpoint state.
513 *
514 * @param localPath - The path of the file.
515 *
516 * @param checkpointID - The id of the checkpoint to restore.
517 *
518 * @returns A promise which resolves when the checkpoint is restored.
519 */
520 restoreCheckpoint(localPath: string, checkpointID: string): Promise<void>;
521 /**
522 * Delete a checkpoint for a file.
523 *
524 * @param localPath - The path of the file.
525 *
526 * @param checkpointID - The id of the checkpoint to delete.
527 *
528 * @returns A promise which resolves when the checkpoint is deleted.
529 */
530 deleteCheckpoint(localPath: string, checkpointID: string): Promise<void>;
531 }
532}
533/**
534 * A contents manager that passes file operations to the server.
535 * Multiple servers implementing the `IDrive` interface can be
536 * attached to the contents manager, so that the same session can
537 * perform file operations on multiple backends.
538 *
539 * This includes checkpointing with the normal file operations.
540 */
541export declare class ContentsManager implements Contents.IManager {
542 /**
543 * Construct a new contents manager object.
544 *
545 * @param options - The options used to initialize the object.
546 */
547 constructor(options?: ContentsManager.IOptions);
548 /**
549 * The server settings associated with the manager.
550 */
551 readonly serverSettings: ServerConnection.ISettings;
552 /**
553 * A signal emitted when a file operation takes place.
554 */
555 get fileChanged(): ISignal<this, Contents.IChangedArgs>;
556 /**
557 * Test whether the manager has been disposed.
558 */
559 get isDisposed(): boolean;
560 /**
561 * Dispose of the resources held by the manager.
562 */
563 dispose(): void;
564 /**
565 * Add an `IDrive` to the manager.
566 */
567 addDrive(drive: Contents.IDrive): void;
568 /**
569 * Given a path, get a shared model factory from the
570 * relevant backend. Returns `null` if the backend
571 * does not provide one.
572 */
573 getSharedModelFactory(path: string): Contents.ISharedFactory | null;
574 /**
575 * Given a path of the form `drive:local/portion/of/it.txt`
576 * get the local part of it.
577 *
578 * @param path the path.
579 *
580 * @returns The local part of the path.
581 */
582 localPath(path: string): string;
583 /**
584 * Normalize a global path. Reduces '..' and '.' parts, and removes
585 * leading slashes from the local part of the path, while retaining
586 * the drive name if it exists.
587 *
588 * @param path the path.
589 *
590 * @returns The normalized path.
591 */
592 normalize(path: string): string;
593 /**
594 * Resolve a global path, starting from the root path. Behaves like
595 * posix-path.resolve, with 3 differences:
596 * - will never prepend cwd
597 * - if root has a drive name, the result is prefixed with "<drive>:"
598 * - before adding drive name, leading slashes are removed
599 *
600 * @param path the path.
601 *
602 * @returns The normalized path.
603 */
604 resolvePath(root: string, path: string): string;
605 /**
606 * Given a path of the form `drive:local/portion/of/it.txt`
607 * get the name of the drive. If the path is missing
608 * a drive portion, returns an empty string.
609 *
610 * @param path the path.
611 *
612 * @returns The drive name for the path, or the empty string.
613 */
614 driveName(path: string): string;
615 /**
616 * Get a file or directory.
617 *
618 * @param path The path to the file.
619 *
620 * @param options The options used to fetch the file.
621 *
622 * @returns A promise which resolves with the file content.
623 */
624 get(path: string, options?: Contents.IFetchOptions): Promise<Contents.IModel>;
625 /**
626 * Get an encoded download url given a file path.
627 *
628 * @param path - An absolute POSIX file path on the server.
629 *
630 * #### Notes
631 * It is expected that the path contains no relative paths.
632 *
633 * The returned URL may include a query parameter.
634 */
635 getDownloadUrl(path: string): Promise<string>;
636 /**
637 * Create a new untitled file or directory in the specified directory path.
638 *
639 * @param options The options used to create the file.
640 *
641 * @returns A promise which resolves with the created file content when the
642 * file is created.
643 */
644 newUntitled(options?: Contents.ICreateOptions): Promise<Contents.IModel>;
645 /**
646 * Delete a file.
647 *
648 * @param path - The path to the file.
649 *
650 * @returns A promise which resolves when the file is deleted.
651 */
652 delete(path: string): Promise<void>;
653 /**
654 * Rename a file or directory.
655 *
656 * @param path - The original file path.
657 *
658 * @param newPath - The new file path.
659 *
660 * @returns A promise which resolves with the new file contents model when
661 * the file is renamed.
662 */
663 rename(path: string, newPath: string): Promise<Contents.IModel>;
664 /**
665 * Save a file.
666 *
667 * @param path - The desired file path.
668 *
669 * @param options - Optional overrides to the model.
670 *
671 * @returns A promise which resolves with the file content model when the
672 * file is saved.
673 *
674 * #### Notes
675 * Ensure that `model.content` is populated for the file.
676 */
677 save(path: string, options?: Partial<Contents.IModel>): Promise<Contents.IModel>;
678 /**
679 * Copy a file into a given directory.
680 *
681 * @param path - The original file path.
682 *
683 * @param toDir - The destination directory path.
684 *
685 * @returns A promise which resolves with the new contents model when the
686 * file is copied.
687 *
688 * #### Notes
689 * The server will select the name of the copied file.
690 */
691 copy(fromFile: string, toDir: string): Promise<Contents.IModel>;
692 /**
693 * Create a checkpoint for a file.
694 *
695 * @param path - The path of the file.
696 *
697 * @returns A promise which resolves with the new checkpoint model when the
698 * checkpoint is created.
699 */
700 createCheckpoint(path: string): Promise<Contents.ICheckpointModel>;
701 /**
702 * List available checkpoints for a file.
703 *
704 * @param path - The path of the file.
705 *
706 * @returns A promise which resolves with a list of checkpoint models for
707 * the file.
708 */
709 listCheckpoints(path: string): Promise<Contents.ICheckpointModel[]>;
710 /**
711 * Restore a file to a known checkpoint state.
712 *
713 * @param path - The path of the file.
714 *
715 * @param checkpointID - The id of the checkpoint to restore.
716 *
717 * @returns A promise which resolves when the checkpoint is restored.
718 */
719 restoreCheckpoint(path: string, checkpointID: string): Promise<void>;
720 /**
721 * Delete a checkpoint for a file.
722 *
723 * @param path - The path of the file.
724 *
725 * @param checkpointID - The id of the checkpoint to delete.
726 *
727 * @returns A promise which resolves when the checkpoint is deleted.
728 */
729 deleteCheckpoint(path: string, checkpointID: string): Promise<void>;
730 /**
731 * Given a drive and a local path, construct a fully qualified
732 * path. The inverse of `_driveForPath`.
733 *
734 * @param drive an `IDrive`.
735 *
736 * @param localPath the local path on the drive.
737 *
738 * @returns the fully qualified path.
739 */
740 private _toGlobalPath;
741 /**
742 * Given a path, get the `IDrive to which it refers,
743 * where the path satisfies the pattern
744 * `'driveName:path/to/file'`. If there is no `driveName`
745 * prepended to the path, it returns the default drive.
746 *
747 * @param path a path to a file.
748 *
749 * @returns A tuple containing an `IDrive` object for the path,
750 * and a local path for that drive.
751 */
752 private _driveForPath;
753 /**
754 * Respond to fileChanged signals from the drives attached to
755 * the manager. This prepends the drive name to the path if necessary,
756 * and then forwards the signal.
757 */
758 private _onFileChanged;
759 private _isDisposed;
760 private _additionalDrives;
761 private _defaultDrive;
762 private _fileChanged;
763}
764/**
765 * A default implementation for an `IDrive`, talking to the
766 * server using the Jupyter REST API.
767 */
768export declare class Drive implements Contents.IDrive {
769 /**
770 * Construct a new contents manager object.
771 *
772 * @param options - The options used to initialize the object.
773 */
774 constructor(options?: Drive.IOptions);
775 /**
776 * The name of the drive, which is used at the leading
777 * component of file paths.
778 */
779 readonly name: string;
780 /**
781 * A signal emitted when a file operation takes place.
782 */
783 get fileChanged(): ISignal<this, Contents.IChangedArgs>;
784 /**
785 * The server settings of the drive.
786 */
787 readonly serverSettings: ServerConnection.ISettings;
788 /**
789 * Test whether the manager has been disposed.
790 */
791 get isDisposed(): boolean;
792 /**
793 * Dispose of the resources held by the manager.
794 */
795 dispose(): void;
796 /**
797 * Get a file or directory.
798 *
799 * @param localPath The path to the file.
800 *
801 * @param options The options used to fetch the file.
802 *
803 * @returns A promise which resolves with the file content.
804 *
805 * Uses the [Jupyter Server API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/contents) and validates the response model.
806 */
807 get(localPath: string, options?: Contents.IFetchOptions): Promise<Contents.IModel>;
808 /**
809 * Get an encoded download url given a file path.
810 *
811 * @param localPath - An absolute POSIX file path on the server.
812 *
813 * #### Notes
814 * It is expected that the path contains no relative paths.
815 *
816 * The returned URL may include a query parameter.
817 */
818 getDownloadUrl(localPath: string): Promise<string>;
819 /**
820 * Create a new untitled file or directory in the specified directory path.
821 *
822 * @param options The options used to create the file.
823 *
824 * @returns A promise which resolves with the created file content when the
825 * file is created.
826 *
827 * #### Notes
828 * Uses the [Jupyter Server API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/contents) and validates the response model.
829 */
830 newUntitled(options?: Contents.ICreateOptions): Promise<Contents.IModel>;
831 /**
832 * Delete a file.
833 *
834 * @param localPath - The path to the file.
835 *
836 * @returns A promise which resolves when the file is deleted.
837 *
838 * #### Notes
839 * Uses the [Jupyter Server API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/contents).
840 */
841 delete(localPath: string): Promise<void>;
842 /**
843 * Rename a file or directory.
844 *
845 * @param oldLocalPath - The original file path.
846 *
847 * @param newLocalPath - The new file path.
848 *
849 * @returns A promise which resolves with the new file contents model when
850 * the file is renamed.
851 *
852 * #### Notes
853 * Uses the [Jupyter Server API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/contents) and validates the response model.
854 */
855 rename(oldLocalPath: string, newLocalPath: string): Promise<Contents.IModel>;
856 /**
857 * Save a file.
858 *
859 * @param localPath - The desired file path.
860 *
861 * @param options - Optional overrides to the model.
862 *
863 * @returns A promise which resolves with the file content model when the
864 * file is saved.
865 *
866 * #### Notes
867 * Ensure that `model.content` is populated for the file.
868 *
869 * Uses the [Jupyter Server API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/contents) and validates the response model.
870 */
871 save(localPath: string, options?: Partial<Contents.IModel>): Promise<Contents.IModel>;
872 /**
873 * Copy a file into a given directory.
874 *
875 * @param localPath - The original file path.
876 *
877 * @param toDir - The destination directory path.
878 *
879 * @returns A promise which resolves with the new contents model when the
880 * file is copied.
881 *
882 * #### Notes
883 * The server will select the name of the copied file.
884 *
885 * Uses the [Jupyter Server API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/contents) and validates the response model.
886 */
887 copy(fromFile: string, toDir: string): Promise<Contents.IModel>;
888 /**
889 * Create a checkpoint for a file.
890 *
891 * @param localPath - The path of the file.
892 *
893 * @returns A promise which resolves with the new checkpoint model when the
894 * checkpoint is created.
895 *
896 * #### Notes
897 * Uses the [Jupyter Server API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/contents) and validates the response model.
898 */
899 createCheckpoint(localPath: string): Promise<Contents.ICheckpointModel>;
900 /**
901 * List available checkpoints for a file.
902 *
903 * @param localPath - The path of the file.
904 *
905 * @returns A promise which resolves with a list of checkpoint models for
906 * the file.
907 *
908 * #### Notes
909 * Uses the [Jupyter Server API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/contents) and validates the response model.
910 */
911 listCheckpoints(localPath: string): Promise<Contents.ICheckpointModel[]>;
912 /**
913 * Restore a file to a known checkpoint state.
914 *
915 * @param localPath - The path of the file.
916 *
917 * @param checkpointID - The id of the checkpoint to restore.
918 *
919 * @returns A promise which resolves when the checkpoint is restored.
920 *
921 * #### Notes
922 * Uses the [Jupyter Server API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/contents).
923 */
924 restoreCheckpoint(localPath: string, checkpointID: string): Promise<void>;
925 /**
926 * Delete a checkpoint for a file.
927 *
928 * @param localPath - The path of the file.
929 *
930 * @param checkpointID - The id of the checkpoint to delete.
931 *
932 * @returns A promise which resolves when the checkpoint is deleted.
933 *
934 * #### Notes
935 * Uses the [Jupyter Server API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/contents).
936 */
937 deleteCheckpoint(localPath: string, checkpointID: string): Promise<void>;
938 /**
939 * Get a REST url for a file given a path.
940 */
941 private _getUrl;
942 private _apiEndpoint;
943 private _isDisposed;
944 private _fileChanged;
945}
946/**
947 * A namespace for ContentsManager statics.
948 */
949export declare namespace ContentsManager {
950 /**
951 * The options used to initialize a contents manager.
952 */
953 interface IOptions {
954 /**
955 * The default drive backend for the contents manager.
956 */
957 defaultDrive?: Contents.IDrive;
958 /**
959 * The server settings associated with the manager.
960 */
961 serverSettings?: ServerConnection.ISettings;
962 }
963}
964/**
965 * A namespace for Drive statics.
966 */
967export declare namespace Drive {
968 /**
969 * The options used to initialize a `Drive`.
970 */
971 interface IOptions {
972 /**
973 * The name for the `Drive`, which is used in file
974 * paths to disambiguate it from other drives.
975 */
976 name?: string;
977 /**
978 * The server settings for the server.
979 */
980 serverSettings?: ServerConnection.ISettings;
981 /**
982 * A REST endpoint for drive requests.
983 * If not given, defaults to the Jupyter
984 * REST API given by [Jupyter Server API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/contents).
985 */
986 apiEndpoint?: string;
987 }
988}
989
\No newline at end of file