@difizen/libro-kernel 0.0.2-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/es/basemanager.d.ts +94 -0
  4. package/es/basemanager.d.ts.map +1 -0
  5. package/es/basemanager.js +110 -0
  6. package/es/contents/contents-drive.d.ts +189 -0
  7. package/es/contents/contents-drive.d.ts.map +1 -0
  8. package/es/contents/contents-drive.js +792 -0
  9. package/es/contents/contents-manager.d.ts +229 -0
  10. package/es/contents/contents-manager.d.ts.map +1 -0
  11. package/es/contents/contents-manager.js +551 -0
  12. package/es/contents/contents-module.d.ts +3 -0
  13. package/es/contents/contents-module.d.ts.map +1 -0
  14. package/es/contents/contents-module.js +4 -0
  15. package/es/contents/contents-protocol.d.ts +487 -0
  16. package/es/contents/contents-protocol.d.ts.map +1 -0
  17. package/es/contents/contents-protocol.js +1 -0
  18. package/es/contents/index.d.ts +6 -0
  19. package/es/contents/index.d.ts.map +1 -0
  20. package/es/contents/index.js +5 -0
  21. package/es/contents/validate.d.ts +10 -0
  22. package/es/contents/validate.d.ts.map +1 -0
  23. package/es/contents/validate.js +22 -0
  24. package/es/index.d.ts +10 -0
  25. package/es/index.d.ts.map +1 -0
  26. package/es/index.js +9 -0
  27. package/es/index.less +0 -0
  28. package/es/kernel/comm.d.ts +92 -0
  29. package/es/kernel/comm.d.ts.map +1 -0
  30. package/es/kernel/comm.js +216 -0
  31. package/es/kernel/future.d.ts +178 -0
  32. package/es/kernel/future.d.ts.map +1 -0
  33. package/es/kernel/future.js +587 -0
  34. package/es/kernel/index.d.ts +8 -0
  35. package/es/kernel/index.d.ts.map +1 -0
  36. package/es/kernel/index.js +8 -0
  37. package/es/kernel/kernel-connection.d.ts +550 -0
  38. package/es/kernel/kernel-connection.d.ts.map +1 -0
  39. package/es/kernel/kernel-connection.js +1957 -0
  40. package/es/kernel/kernel-module.d.ts +3 -0
  41. package/es/kernel/kernel-module.d.ts.map +1 -0
  42. package/es/kernel/kernel-module.js +32 -0
  43. package/es/kernel/libro-kernel-manager.d.ts +69 -0
  44. package/es/kernel/libro-kernel-manager.d.ts.map +1 -0
  45. package/es/kernel/libro-kernel-manager.js +349 -0
  46. package/es/kernel/libro-kernel-protocol.d.ts +675 -0
  47. package/es/kernel/libro-kernel-protocol.d.ts.map +1 -0
  48. package/es/kernel/libro-kernel-protocol.js +60 -0
  49. package/es/kernel/libro-kernel-utils.d.ts +95 -0
  50. package/es/kernel/libro-kernel-utils.d.ts.map +1 -0
  51. package/es/kernel/libro-kernel-utils.js +130 -0
  52. package/es/kernel/libro-kernel.d.ts +14 -0
  53. package/es/kernel/libro-kernel.d.ts.map +1 -0
  54. package/es/kernel/libro-kernel.js +54 -0
  55. package/es/kernel/messages.d.ts +845 -0
  56. package/es/kernel/messages.d.ts.map +1 -0
  57. package/es/kernel/messages.js +457 -0
  58. package/es/kernel/restapi.d.ts +78 -0
  59. package/es/kernel/restapi.d.ts.map +1 -0
  60. package/es/kernel/restapi.js +367 -0
  61. package/es/kernel/serialize.d.ts +10 -0
  62. package/es/kernel/serialize.d.ts.map +1 -0
  63. package/es/kernel/serialize.js +214 -0
  64. package/es/kernel/validate.d.ts +15 -0
  65. package/es/kernel/validate.d.ts.map +1 -0
  66. package/es/kernel/validate.js +125 -0
  67. package/es/kernelspec/index.d.ts +5 -0
  68. package/es/kernelspec/index.d.ts.map +1 -0
  69. package/es/kernelspec/index.js +4 -0
  70. package/es/kernelspec/kernelspec-module.d.ts +3 -0
  71. package/es/kernelspec/kernelspec-module.d.ts.map +1 -0
  72. package/es/kernelspec/kernelspec-module.js +4 -0
  73. package/es/kernelspec/kernelspec.d.ts +33 -0
  74. package/es/kernelspec/kernelspec.d.ts.map +1 -0
  75. package/es/kernelspec/kernelspec.js +1 -0
  76. package/es/kernelspec/manager.d.ts +81 -0
  77. package/es/kernelspec/manager.d.ts.map +1 -0
  78. package/es/kernelspec/manager.js +248 -0
  79. package/es/kernelspec/restapi.d.ts +71 -0
  80. package/es/kernelspec/restapi.d.ts.map +1 -0
  81. package/es/kernelspec/restapi.js +107 -0
  82. package/es/kernelspec/validate.d.ts +10 -0
  83. package/es/kernelspec/validate.d.ts.map +1 -0
  84. package/es/kernelspec/validate.js +69 -0
  85. package/es/libro-kernel-connection-manager.d.ts +19 -0
  86. package/es/libro-kernel-connection-manager.d.ts.map +1 -0
  87. package/es/libro-kernel-connection-manager.js +142 -0
  88. package/es/module.d.ts +3 -0
  89. package/es/module.d.ts.map +1 -0
  90. package/es/module.js +9 -0
  91. package/es/page-config.d.ts +36 -0
  92. package/es/page-config.d.ts.map +1 -0
  93. package/es/page-config.js +129 -0
  94. package/es/protocol.d.ts +13 -0
  95. package/es/protocol.d.ts.map +1 -0
  96. package/es/protocol.js +8 -0
  97. package/es/server/connection-error.d.ts +36 -0
  98. package/es/server/connection-error.d.ts.map +1 -0
  99. package/es/server/connection-error.js +109 -0
  100. package/es/server/index.d.ts +6 -0
  101. package/es/server/index.d.ts.map +1 -0
  102. package/es/server/index.js +5 -0
  103. package/es/server/server-connection-protocol.d.ts +49 -0
  104. package/es/server/server-connection-protocol.d.ts.map +1 -0
  105. package/es/server/server-connection-protocol.js +0 -0
  106. package/es/server/server-connection.d.ts +25 -0
  107. package/es/server/server-connection.d.ts.map +1 -0
  108. package/es/server/server-connection.js +159 -0
  109. package/es/server/server-manager.d.ts +22 -0
  110. package/es/server/server-manager.d.ts.map +1 -0
  111. package/es/server/server-manager.js +163 -0
  112. package/es/server/server-module.d.ts +3 -0
  113. package/es/server/server-module.d.ts.map +1 -0
  114. package/es/server/server-module.js +4 -0
  115. package/es/session/index.d.ts +5 -0
  116. package/es/session/index.d.ts.map +1 -0
  117. package/es/session/index.js +4 -0
  118. package/es/session/libro-session-manager.d.ts +71 -0
  119. package/es/session/libro-session-manager.d.ts.map +1 -0
  120. package/es/session/libro-session-manager.js +539 -0
  121. package/es/session/libro-session-protocol.d.ts +50 -0
  122. package/es/session/libro-session-protocol.d.ts.map +1 -0
  123. package/es/session/libro-session-protocol.js +21 -0
  124. package/es/session/libro-session.d.ts +12 -0
  125. package/es/session/libro-session.d.ts.map +1 -0
  126. package/es/session/libro-session.js +19 -0
  127. package/es/session/restapi.d.ts +28 -0
  128. package/es/session/restapi.d.ts.map +1 -0
  129. package/es/session/restapi.js +214 -0
  130. package/es/session/session-module.d.ts +3 -0
  131. package/es/session/session-module.d.ts.map +1 -0
  132. package/es/session/session-module.js +18 -0
  133. package/es/session/validate.d.ts +14 -0
  134. package/es/session/validate.d.ts.map +1 -0
  135. package/es/session/validate.js +37 -0
  136. package/es/utils.d.ts +4 -0
  137. package/es/utils.d.ts.map +1 -0
  138. package/es/utils.js +29 -0
  139. package/es/validate-property.d.ts +2 -0
  140. package/es/validate-property.d.ts.map +1 -0
  141. package/es/validate-property.js +35 -0
  142. package/package.json +62 -0
  143. package/src/basemanager.ts +133 -0
  144. package/src/contents/contents-drive.ts +495 -0
  145. package/src/contents/contents-manager.ts +465 -0
  146. package/src/contents/contents-module.ts +6 -0
  147. package/src/contents/contents-protocol.ts +604 -0
  148. package/src/contents/index.ts +5 -0
  149. package/src/contents/validate.ts +29 -0
  150. package/src/index.tsx +9 -0
  151. package/src/kernel/comm.ts +220 -0
  152. package/src/kernel/future.ts +474 -0
  153. package/src/kernel/index.ts +7 -0
  154. package/src/kernel/kernel-connection.ts +1770 -0
  155. package/src/kernel/kernel-module.ts +50 -0
  156. package/src/kernel/libro-kernel-manager.ts +199 -0
  157. package/src/kernel/libro-kernel-protocol.ts +858 -0
  158. package/src/kernel/libro-kernel-utils.ts +152 -0
  159. package/src/kernel/libro-kernel.ts +39 -0
  160. package/src/kernel/messages.ts +1104 -0
  161. package/src/kernel/restapi.ts +183 -0
  162. package/src/kernel/serialize.ts +262 -0
  163. package/src/kernel/validate.ts +101 -0
  164. package/src/kernelspec/index.ts +5 -0
  165. package/src/kernelspec/kernelspec-module.ts +9 -0
  166. package/src/kernelspec/kernelspec.ts +37 -0
  167. package/src/kernelspec/manager.ts +173 -0
  168. package/src/kernelspec/restapi.ts +104 -0
  169. package/src/kernelspec/validate.ts +80 -0
  170. package/src/libro-kernel-connection-manager.ts +73 -0
  171. package/src/module.ts +19 -0
  172. package/src/page-config.ts +106 -0
  173. package/src/protocol.ts +24 -0
  174. package/src/server/connection-error.ts +60 -0
  175. package/src/server/index.ts +5 -0
  176. package/src/server/server-connection-protocol.ts +57 -0
  177. package/src/server/server-connection.ts +144 -0
  178. package/src/server/server-manager.ts +76 -0
  179. package/src/server/server-module.ts +9 -0
  180. package/src/session/index.ts +4 -0
  181. package/src/session/libro-session-manager.ts +377 -0
  182. package/src/session/libro-session-protocol.ts +61 -0
  183. package/src/session/libro-session.ts +33 -0
  184. package/src/session/restapi.ts +126 -0
  185. package/src/session/session-module.ts +26 -0
  186. package/src/session/validate.ts +39 -0
  187. package/src/utils.ts +28 -0
  188. package/src/validate-property.ts +38 -0
@@ -0,0 +1,604 @@
1
+ import type { Disposable, Event as ManaEvent } from '@difizen/mana-app';
2
+
3
+ import type { ISettings } from '../server/index.js';
4
+
5
+ /**
6
+ * The options used to fetch a file.
7
+ */
8
+ export interface IContentsRequestOptions {
9
+ baseUrl?: string;
10
+ }
11
+
12
+ /**
13
+ * A contents file type. It can be anything but `jupyter-server`
14
+ * has special treatment for `notebook` and `directory` types.
15
+ * Anything else is considered as `file` type.
16
+ */
17
+ export type ContentType = string;
18
+
19
+ /**
20
+ * A contents file format.
21
+ */
22
+ export type ContentsFileFormat = 'json' | 'text' | 'base64' | null;
23
+
24
+ /**
25
+ * A contents model.
26
+ */
27
+ export interface IContentsModel extends IContentsRequestOptions {
28
+ /**
29
+ * Name of the contents file.
30
+ *
31
+ * #### Notes
32
+ * Equivalent to the last part of the `path` field.
33
+ */
34
+ readonly name: string;
35
+
36
+ /**
37
+ * The full file path.
38
+ *
39
+ * #### Notes
40
+ * It will *not* start with `/`, and it will be `/`-delimited.
41
+ */
42
+ readonly path: string;
43
+
44
+ /**
45
+ * The type of file.
46
+ */
47
+ readonly type: ContentType;
48
+
49
+ /**
50
+ * Whether the requester has permission to edit the file.
51
+ */
52
+ readonly writable: boolean;
53
+
54
+ /**
55
+ * File creation timestamp.
56
+ */
57
+ readonly created: string;
58
+
59
+ /**
60
+ * Last modified timestamp.
61
+ */
62
+ readonly last_modified: string;
63
+
64
+ /**
65
+ * Specify the mime-type of file contents.
66
+ *
67
+ * #### Notes
68
+ * Only non-`null` when `content` is present and `type` is `"file"`.
69
+ */
70
+ readonly mimetype?: string;
71
+
72
+ /**
73
+ * The optional file content.
74
+ */
75
+ readonly content: any;
76
+
77
+ /**
78
+ * The chunk of the file upload.
79
+ */
80
+ readonly chunk?: number;
81
+
82
+ /**
83
+ * The format of the file `content`.
84
+ *
85
+ * #### Notes
86
+ * Only relevant for type: 'file'
87
+ */
88
+ readonly format?: ContentsFileFormat;
89
+
90
+ /**
91
+ * The size of then file in bytes.
92
+ */
93
+ readonly size?: number;
94
+
95
+ /**
96
+ * The indices of the matched characters in the name.
97
+ */
98
+ indices?: readonly number[] | null;
99
+
100
+ message?: string;
101
+ }
102
+
103
+ /**
104
+ * The options used to fetch a file.
105
+ */
106
+ export interface IContentsFetchOptions extends IContentsRequestOptions {
107
+ /**
108
+ * The override file type for the request.
109
+ */
110
+ type?: ContentType;
111
+
112
+ /**
113
+ * The override file format for the request.
114
+ */
115
+ format?: ContentsFileFormat;
116
+
117
+ /**
118
+ * Whether to include the file content.
119
+ *
120
+ * The default is `true`.
121
+ */
122
+ content?: boolean;
123
+ }
124
+
125
+ /**
126
+ * The options used to create a file.
127
+ */
128
+ export interface IContentsCreateOptions extends IContentsRequestOptions {
129
+ /**
130
+ * The directory in which to create the file.
131
+ */
132
+ path?: string;
133
+
134
+ /**
135
+ * The optional file extension for the new file (e.g. `".txt"`).
136
+ *
137
+ * #### Notes
138
+ * This ignored if `type` is `'notebook'`.
139
+ */
140
+ ext?: string;
141
+
142
+ /**
143
+ * The file type.
144
+ */
145
+ type?: ContentType;
146
+ }
147
+
148
+ /**
149
+ * Checkpoint model.
150
+ */
151
+ export interface IContentsCheckpointModel {
152
+ /**
153
+ * The unique identifier for the checkpoint.
154
+ */
155
+ readonly id: string;
156
+
157
+ /**
158
+ * Last modified timestamp.
159
+ */
160
+ readonly last_modified: string;
161
+ }
162
+
163
+ /**
164
+ * The change args for a file change.
165
+ */
166
+ export interface IContentsChangedArgs {
167
+ /**
168
+ * The type of change.
169
+ */
170
+ type: 'new' | 'delete' | 'rename' | 'save';
171
+
172
+ /**
173
+ * The new contents.
174
+ */
175
+ oldValue: Partial<IContentsModel> | null;
176
+
177
+ /**
178
+ * The old contents.
179
+ */
180
+ newValue: Partial<IContentsModel> | null;
181
+ }
182
+ /**
183
+ * The interface for a contents manager.
184
+ */
185
+ export interface IContentsManager extends Disposable {
186
+ /**
187
+ * A signal emitted when a file operation takes place.
188
+ */
189
+ readonly fileChanged: ManaEvent<IContentsChangedArgs>;
190
+
191
+ /**
192
+ * The server settings associated with the manager.
193
+ */
194
+ // serverSettings: ISettings;
195
+
196
+ /**
197
+ * Add an `IContentsDrive` to the manager.
198
+ */
199
+ addDrive: (drive: IContentsDrive) => void;
200
+
201
+ /**
202
+ * Given a path of the form `drive:local/portion/of/it.txt`
203
+ * get the local part of it.
204
+ *
205
+ * @param path: the path.
206
+ *
207
+ * @returns The local part of the path.
208
+ */
209
+ localPath: (path: string) => string;
210
+
211
+ /**
212
+ * Normalize a global path. Reduces '..' and '.' parts, and removes
213
+ * leading slashes from the local part of the path, while retaining
214
+ * the drive name if it exists.
215
+ *
216
+ * @param path: the path.
217
+ *
218
+ * @returns The normalized path.
219
+ */
220
+ normalize: (path: string) => string;
221
+
222
+ /**
223
+ * Resolve a global path, starting from the root path. Behaves like
224
+ * posix-path.resolve, with 3 differences:
225
+ * - will never prepend cwd
226
+ * - if root has a drive name, the result is prefixed with "<drive>:"
227
+ * - before adding drive name, leading slashes are removed
228
+ *
229
+ * @param path: the path.
230
+ *
231
+ * @returns The normalized path.
232
+ */
233
+ resolvePath: (root: string, path: string) => string;
234
+
235
+ /**
236
+ * Given a path of the form `drive:local/portion/of/it.txt`
237
+ * get the name of the drive. If the path is missing
238
+ * a drive portion, returns an empty string.
239
+ *
240
+ * @param path: the path.
241
+ *
242
+ * @returns The drive name for the path, or the empty string.
243
+ */
244
+ driveName: (path: string) => string;
245
+
246
+ /**
247
+ * Given a path, get a ModelDB.IFactory from the
248
+ * relevant backend. Returns `null` if the backend
249
+ * does not provide one.
250
+ */
251
+ // getModelDBFactory(path: string): ModelDB.IFactory | null;
252
+
253
+ /**
254
+ * Get a file or directory.
255
+ *
256
+ * @param path: The path to the file.
257
+ *
258
+ * @param options: The options used to fetch the file.
259
+ *
260
+ * @returns A promise which resolves with the file content.
261
+ */
262
+ get: (path: string, options?: IContentsFetchOptions) => Promise<IContentsModel>;
263
+
264
+ /**
265
+ * Get an encoded download url given a file path.
266
+ *
267
+ * @param A promise which resolves with the absolute POSIX
268
+ * file path on the server.
269
+ *
270
+ * #### Notes
271
+ * The returned URL may include a query parameter.
272
+ */
273
+ getDownloadUrl: (path: string, options?: IContentsRequestOptions) => Promise<string>;
274
+
275
+ /**
276
+ * Create a new untitled file or directory in the specified directory path.
277
+ *
278
+ * @param options: The options used to create the file.
279
+ *
280
+ * @returns A promise which resolves with the created file content when the
281
+ * file is created.
282
+ */
283
+ newUntitled: (options?: IContentsCreateOptions) => Promise<IContentsModel>;
284
+
285
+ /**
286
+ * Delete a file.
287
+ *
288
+ * @param path - The path to the file.
289
+ *
290
+ * @returns A promise which resolves when the file is deleted.
291
+ */
292
+ delete: (path: string, options?: IContentsRequestOptions) => Promise<void>;
293
+
294
+ /**
295
+ * Rename a file or directory.
296
+ *
297
+ * @param path - The original file path.
298
+ *
299
+ * @param newPath - The new file path.
300
+ *
301
+ * @returns A promise which resolves with the new file content model when the
302
+ * file is renamed.
303
+ */
304
+ rename: (
305
+ path: string,
306
+ newPath: string,
307
+ options?: IContentsRequestOptions,
308
+ ) => Promise<IContentsModel>;
309
+
310
+ /**
311
+ * Save a file.
312
+ *
313
+ * @param path - The desired file path.
314
+ *
315
+ * @param options - Optional overrides to the model.
316
+ *
317
+ * @returns A promise which resolves with the file content model when the
318
+ * file is saved.
319
+ */
320
+ save: (path: string, options?: Partial<IContentsModel>) => Promise<IContentsModel>;
321
+
322
+ /**
323
+ * Copy a file into a given directory.
324
+ *
325
+ * @param path - The original file path.
326
+ *
327
+ * @param toDir - The destination directory path.
328
+ *
329
+ * @returns A promise which resolves with the new content model when the
330
+ * file is copied.
331
+ */
332
+ copy: (
333
+ path: string,
334
+ toDir: string,
335
+ options?: IContentsRequestOptions,
336
+ ) => Promise<IContentsModel>;
337
+
338
+ /**
339
+ * Create a checkpoint for a file.
340
+ *
341
+ * @param path - The path of the file.
342
+ *
343
+ * @returns A promise which resolves with the new checkpoint model when the
344
+ * checkpoint is created.
345
+ */
346
+ createCheckpoint: (
347
+ path: string,
348
+ options?: IContentsRequestOptions,
349
+ ) => Promise<IContentsCheckpointModel>;
350
+
351
+ /**
352
+ * List available checkpoints for a file.
353
+ *
354
+ * @param path - The path of the file.
355
+ *
356
+ * @returns A promise which resolves with a list of checkpoint models for
357
+ * the file.
358
+ */
359
+ listCheckpoints: (
360
+ path: string,
361
+ options?: IContentsRequestOptions,
362
+ ) => Promise<IContentsCheckpointModel[]>;
363
+
364
+ /**
365
+ * Restore a file to a known checkpoint state.
366
+ *
367
+ * @param path - The path of the file.
368
+ *
369
+ * @param checkpointID - The id of the checkpoint to restore.
370
+ *
371
+ * @returns A promise which resolves when the checkpoint is restored.
372
+ */
373
+ restoreCheckpoint: (
374
+ path: string,
375
+ checkpointID: string,
376
+ options?: IContentsRequestOptions,
377
+ ) => Promise<void>;
378
+
379
+ /**
380
+ * Delete a checkpoint for a file.
381
+ *
382
+ * @param path - The path of the file.
383
+ *
384
+ * @param checkpointID - The id of the checkpoint to delete.
385
+ *
386
+ * @returns A promise which resolves when the checkpoint is deleted.
387
+ */
388
+ deleteCheckpoint: (
389
+ path: string,
390
+ checkpointID: string,
391
+ options?: IContentsRequestOptions,
392
+ ) => Promise<void>;
393
+ }
394
+ /**
395
+ * The interface for a network drive that can be mounted
396
+ * in the contents manager.
397
+ */
398
+ export interface IContentsDrive extends Disposable {
399
+ /**
400
+ * The name of the drive, which is used at the leading
401
+ * component of file paths.
402
+ */
403
+ readonly name: string;
404
+
405
+ /**
406
+ * The server settings of the manager.
407
+ */
408
+ // readonly serverSettings: ISettings;
409
+
410
+ /**
411
+ * An optional ModelDB.IFactory instance for the
412
+ * drive.
413
+ */
414
+ // readonly modelDBFactory?: ModelDB.IFactory;
415
+
416
+ /**
417
+ * A signal emitted when a file operation takes place.
418
+ */
419
+ fileChanged: ManaEvent<IContentsChangedArgs>;
420
+
421
+ /**
422
+ * Get a file or directory.
423
+ *
424
+ * @param localPath: The path to the file.
425
+ *
426
+ * @param options: The options used to fetch the file.
427
+ *
428
+ * @returns A promise which resolves with the file content.
429
+ */
430
+ get: (localPath: string, options?: IContentsFetchOptions) => Promise<IContentsModel>;
431
+
432
+ /**
433
+ * Get an encoded download url given a file path.
434
+ *
435
+ * @param A promise which resolves with the absolute POSIX
436
+ * file path on the server.
437
+ *
438
+ * #### Notes
439
+ * The returned URL may include a query parameter.
440
+ */
441
+ getDownloadUrl: (
442
+ localPath: string,
443
+ options?: IContentsRequestOptions,
444
+ ) => Promise<string>;
445
+
446
+ /**
447
+ * Create a new untitled file or directory in the specified directory path.
448
+ *
449
+ * @param options: The options used to create the file.
450
+ *
451
+ * @returns A promise which resolves with the created file content when the
452
+ * file is created.
453
+ */
454
+ newUntitled: (options?: IContentsCreateOptions) => Promise<IContentsModel>;
455
+
456
+ /**
457
+ * Delete a file.
458
+ *
459
+ * @param localPath - The path to the file.
460
+ *
461
+ * @returns A promise which resolves when the file is deleted.
462
+ */
463
+ delete: (localPath: string, options?: IContentsRequestOptions) => Promise<void>;
464
+
465
+ /**
466
+ * Rename a file or directory.
467
+ *
468
+ * @param oldLocalPath - The original file path.
469
+ *
470
+ * @param newLocalPath - The new file path.
471
+ *
472
+ * @returns A promise which resolves with the new file content model when the
473
+ * file is renamed.
474
+ */
475
+ rename: (
476
+ oldLocalPath: string,
477
+ newLocalPath: string,
478
+ options?: IContentsRequestOptions,
479
+ ) => Promise<IContentsModel>;
480
+
481
+ /**
482
+ * Save a file.
483
+ *
484
+ * @param localPath - The desired file path.
485
+ *
486
+ * @param options - Optional overrides to the model.
487
+ *
488
+ * @returns A promise which resolves with the file content model when the
489
+ * file is saved.
490
+ */
491
+ save: (
492
+ localPath: string,
493
+ options?: Partial<IContentsModel>,
494
+ ) => Promise<IContentsModel>;
495
+
496
+ /**
497
+ * Copy a file into a given directory.
498
+ *
499
+ * @param localPath - The original file path.
500
+ *
501
+ * @param toLocalDir - The destination directory path.
502
+ *
503
+ * @returns A promise which resolves with the new content model when the
504
+ * file is copied.
505
+ */
506
+ copy: (
507
+ localPath: string,
508
+ toLocalDir: string,
509
+ options?: IContentsRequestOptions,
510
+ ) => Promise<IContentsModel>;
511
+
512
+ /**
513
+ * Create a checkpoint for a file.
514
+ *
515
+ * @param localPath - The path of the file.
516
+ *
517
+ * @returns A promise which resolves with the new checkpoint model when the
518
+ * checkpoint is created.
519
+ */
520
+ createCheckpoint: (
521
+ localPath: string,
522
+ options?: IContentsRequestOptions,
523
+ ) => Promise<IContentsCheckpointModel>;
524
+
525
+ /**
526
+ * List available checkpoints for a file.
527
+ *
528
+ * @param localPath - The path of the file.
529
+ *
530
+ * @returns A promise which resolves with a list of checkpoint models for
531
+ * the file.
532
+ */
533
+ listCheckpoints: (
534
+ localPath: string,
535
+ options?: IContentsRequestOptions,
536
+ ) => Promise<IContentsCheckpointModel[]>;
537
+
538
+ /**
539
+ * Restore a file to a known checkpoint state.
540
+ *
541
+ * @param localPath - The path of the file.
542
+ *
543
+ * @param checkpointID - The id of the checkpoint to restore.
544
+ *
545
+ * @returns A promise which resolves when the checkpoint is restored.
546
+ */
547
+ restoreCheckpoint: (
548
+ localPath: string,
549
+ checkpointID: string,
550
+ options?: IContentsRequestOptions,
551
+ ) => Promise<void>;
552
+
553
+ /**
554
+ * Delete a checkpoint for a file.
555
+ *
556
+ * @param localPath - The path of the file.
557
+ *
558
+ * @param checkpointID - The id of the checkpoint to delete.
559
+ *
560
+ * @returns A promise which resolves when the checkpoint is deleted.
561
+ */
562
+ deleteCheckpoint: (
563
+ localPath: string,
564
+ checkpointID: string,
565
+ options?: IContentsRequestOptions,
566
+ ) => Promise<void>;
567
+ }
568
+
569
+ /**
570
+ * The options used to initialize a contents manager.
571
+ */
572
+ export interface IContentsManagerOptions {
573
+ /**
574
+ * The default drive backend for the contents manager.
575
+ */
576
+ defaultDrive?: IContentsDrive;
577
+
578
+ /**
579
+ * The server settings associated with the manager.
580
+ */
581
+ serverSettings?: ISettings;
582
+ }
583
+ /**
584
+ * The options used to initialize a `Drive`.
585
+ */
586
+ export interface IDriveOptions {
587
+ /**
588
+ * The name for the `Drive`, which is used in file
589
+ * paths to disambiguate it from other drives.
590
+ */
591
+ name?: string;
592
+
593
+ /**
594
+ * The server settings for the server.
595
+ */
596
+ serverSettings?: ISettings;
597
+
598
+ /**
599
+ * A REST endpoint for drive requests.
600
+ * If not given, defaults to the Jupyter
601
+ * REST API given by [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/contents).
602
+ */
603
+ apiEndpoint?: string;
604
+ }
@@ -0,0 +1,5 @@
1
+ export * from './contents-drive.js';
2
+ export * from './contents-manager.js';
3
+ export * from './contents-module.js';
4
+ export * from './contents-protocol.js';
5
+ export * from './validate.js';
@@ -0,0 +1,29 @@
1
+ import { validateProperty } from '../validate-property.js';
2
+
3
+ import type { IContentsCheckpointModel, IContentsModel } from './contents-protocol.js';
4
+
5
+ /**
6
+ * Validate an `IContentsModel` object.
7
+ */
8
+ export function validateContentsModel(
9
+ model: IContentsModel,
10
+ ): asserts model is IContentsModel {
11
+ validateProperty(model, 'name', 'string');
12
+ validateProperty(model, 'path', 'string');
13
+ validateProperty(model, 'type', 'string');
14
+ validateProperty(model, 'created', 'string');
15
+ validateProperty(model, 'last_modified', 'string');
16
+ validateProperty(model, 'mimetype', 'object');
17
+ validateProperty(model, 'content', 'object');
18
+ validateProperty(model, 'format', 'object');
19
+ }
20
+
21
+ /**
22
+ * Validate an `IContentsCheckpointModel` object.
23
+ */
24
+ export function validateCheckpointModel(
25
+ model: IContentsCheckpointModel,
26
+ ): asserts model is IContentsCheckpointModel {
27
+ validateProperty(model, 'id', 'string');
28
+ validateProperty(model, 'last_modified', 'string');
29
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,9 @@
1
+ export * from './module.js';
2
+ export * from './contents/index.js';
3
+ export * from './kernel/index.js';
4
+ export * from './session/index.js';
5
+ export * from './server/index.js';
6
+ export * from './kernelspec/index.js';
7
+ export * from './libro-kernel-connection-manager.js';
8
+ export * from './page-config.js';
9
+ export * from './protocol.js';