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