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