|
2 | 2 | // Distributed under the MIT software license, see the accompanying
|
3 | 3 | // file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
4 | 4 |
|
5 |
| -// TODO Make sure all requirements on the implementator are given for each method. |
6 |
| - |
7 | 5 | /**
|
8 | 6 | * Interface for a Bubble server.
|
9 | 7 | *
|
@@ -390,90 +388,94 @@ export class DataServer {
|
390 | 388 | // root directory).
|
391 | 389 | //
|
392 | 390 | // [req-ds-sub-2] If the subscription was successful, the data server shall resolve with a
|
393 |
| - // plain object containing a unique subscriptionId field (any type) and the |
394 |
| - // long form listing of the file/directory (not directory contents). |
395 |
| - // |
396 |
| - // [req-ds-sub-3] The data server shall reject with a FILE_DOES_NOT_EXIST error if the |
397 |
| - // file does not exist. |
| 391 | + // plain object containing a unique subscriptionId field (any type) and, if |
| 392 | + // the file/directory exists, the long form listing of the file/directory |
| 393 | + // (not directory contents). |
398 | 394 | //
|
399 |
| - // [req-ds-sub-4] The data server shall reject with a BUBBLE_DOES_NOT_EXIST error if the |
| 395 | + // [req-ds-sub-3] The data server shall reject with a BUBBLE_DOES_NOT_EXIST error if the |
400 | 396 | // bubble does not exist on the server.
|
401 | 397 | //
|
402 | 398 | // Options:
|
403 | 399 | //
|
404 |
| - // [req-ds-sub-5] If the 'list' option is given and the subscription is for a directory, the |
405 |
| - // data server shall include, in the resolved object, a `list` field containing |
| 400 | + // [req-ds-sub-4] If the 'list' option is given and the subscription is for a directory, the |
| 401 | + // data server shall include, in the resolved object, a `data` field containing |
406 | 402 | // the long form listing of the directory contents (see requirements req-ds-ls-5..10).
|
407 | 403 | //
|
408 |
| - // [req-ds-sub-6] If the 'list' option is given and the subscription is for a file, the |
| 404 | + // [req-ds-sub-5] If the 'list' option is given and the subscription is for a file, the |
409 | 405 | // data server shall omit the `data` field in all notifications.
|
410 | 406 | //
|
411 |
| - // [req-ds-sub-7] If the 'since' option is given and the subscription is for a directory, the |
412 |
| - // data server shall include, in the resolved object, a `list` field containing |
| 407 | + // [req-ds-sub-6] If the 'since' option is given and the subscription is for a directory, the |
| 408 | + // data server shall include, in the resolved object, a `data` field containing |
413 | 409 | // the long form listing of the directory contents created or updated since (but not
|
414 | 410 | // on) the option's timestamp (integer UNIX timestamp in ms). (See requirements
|
415 | 411 | // req-ds-ls-5..10 for the long form listing format).
|
416 | 412 | //
|
417 |
| - // [req-ds-sub-8] If the 'read' option is given and the subscription is for a file, the |
| 413 | + // [req-ds-sub-7] If the 'read' option is given and the subscription is for a file, the |
418 | 414 | // data server shall include, in the resolved object, a `data` field containing
|
419 | 415 | // the file contents.
|
420 | 416 | //
|
421 | 417 | // Notifications:
|
422 | 418 | //
|
423 |
| - // [req-ds-sub-9] The data server shall notify the client `listener` function whenever the file |
| 419 | + // [req-ds-sub-8] The data server shall notify the client `listener` function whenever the file |
424 | 420 | // or directory changes, subject to the subscription options.
|
425 | 421 | //
|
426 |
| - // [req-ds-sub-10] By default, when a subscribed file is written to using the `write` command, |
| 422 | + // [req-ds-sub-9] By default, when a subscribed file is written to using the `write` command, |
427 | 423 | // the data server shall notify the client with a `write` event and, unless the
|
428 | 424 | // 'list' option was given (see req-ds-sub-6), the full contents of the file.
|
429 | 425 | //
|
430 |
| - // [req-ds-sub-11] By default, when a subscribed file is appended to using the `append` command, |
| 426 | + // [req-ds-sub-10] By default, when a subscribed file is appended to using the `append` command, |
431 | 427 | // the data server shall notify the client with a `append` event and, unless the
|
432 | 428 | // 'list' option was given (see req-ds-sub-6), the appended data.
|
433 | 429 | //
|
434 |
| - // [req-ds-sub-12] By default, when a subscribed file is deleted using the `delete` command, |
| 430 | + // [req-ds-sub-11] By default, when a subscribed file is deleted using the `delete` command, |
435 | 431 | // the data server shall notify the client with a `delete` event.
|
436 | 432 | //
|
437 |
| - // [req-ds-sub-13] By default, when a new directory is added to a subscribed root (via mkdir) |
| 433 | + // [req-ds-sub-12] By default, when a new directory is added to a subscribed root (via mkdir) |
438 | 434 | // the data server shall notify the client of an `update` event and include a list
|
439 | 435 | // (array) of files that have changed.
|
440 | 436 | //
|
441 |
| - // [req-ds-sub-14] By default, when a file is written to a subscribed directory (including the |
| 437 | + // [req-ds-sub-13] By default, when a file is written to a subscribed directory (including the |
442 | 438 | // ROOT_PATH), the data server shall notify the client of an `update` event and
|
443 | 439 | // include the updated file in its data array in the following format:
|
444 | 440 | // {event: 'write', <...long format listing of the file>}
|
445 | 441 | //
|
446 |
| - // [req-ds-sub-15] By default, when a file is appended to in a subscribed directory (including the |
| 442 | + // [req-ds-sub-14] By default, when a file is appended to in a subscribed directory (including the |
447 | 443 | // ROOT_PATH), the data server shall notify the client of an `update` event and
|
448 | 444 | // include the updated file in its data array in the following format:
|
449 | 445 | // {event: 'append', <...long format listing of the file>}
|
450 | 446 | //
|
451 |
| - // [req-ds-sub-16] By default, when a file is deleted from a subscribed directory (including the |
| 447 | + // [req-ds-sub-15] By default, when a file is deleted from a subscribed directory (including the |
452 | 448 | // ROOT_PATH), the data server shall notify the client of an `update` event and
|
453 | 449 | // include the updated file in its data array in the following format:
|
454 | 450 | // {event: 'delete', file: <fileId>, type: 'file'}
|
455 | 451 | //
|
| 452 | + // [req-ds-sub-16] By default, when a subscribed directory is created using the `mkdir` command, |
| 453 | + // the data server shall notify the client with an `mkdir` event. |
| 454 | + // |
| 455 | + // [req-ds-sub-17] By default, when a subscribed directory is deleted using the `delete` command, |
| 456 | + // the data server shall notify the client with a `delete` event. |
| 457 | + // |
456 | 458 | // Notification Format:
|
457 | 459 | //
|
458 |
| - // [req-ds-sub-17] The type of each notification shall be a plain object. |
| 460 | + // [req-ds-sub-18] The type of each notification shall be a plain object. |
459 | 461 | //
|
460 |
| - // [req-ds-sub-18] Each notification shall contain a `subscriptionId` field containing the id |
461 |
| - // of the subscription. |
| 462 | + // [req-ds-sub-19] Each notification shall contain an `subscriptionId` field containing the id of |
| 463 | + // the subscription. |
462 | 464 | //
|
463 |
| - // [req-ds-sub-19] Each notification shall contain an `event` field indicating the type of |
| 465 | + // [req-ds-sub-20] Each notification shall contain an `event` field indicating the type of |
464 | 466 | // event that caused the notification: 'write', 'append', 'delete', or 'update'.
|
465 | 467 | //
|
466 |
| - // [req-ds-sub-20] Each update, write or append notification shall contain a `file` field |
| 468 | + // [req-ds-sub-21] Each update, write or append notification shall contain a `file` field |
467 | 469 | // containing the long form listing of the updated file or directory
|
468 | 470 | // (see requirements req-ds-ls-5..10).
|
469 | 471 | //
|
470 |
| - // [req-ds-sub-21] Each file delete notification shall contain a `file` field containing the short |
| 472 | + // [req-ds-sub-22] Each file delete notification shall contain a `file` field containing the short |
471 | 473 | // listing of the updated file, i.e. {file: <fileId>, type: 'file}.
|
472 | 474 | //
|
473 |
| - // [req-ds-sub-22] A file notification containing file contents shall include the contents as a |
| 475 | + // [req-ds-sub-23] A file notification containing file contents shall include the contents as a |
474 | 476 | // `data` field.
|
475 | 477 | //
|
476 |
| - // [req-ds-sub-23] A directory notification shall contain a `list` field containing an array |
| 478 | + // [req-ds-sub-24] A directory notification shall contain a `list` field containing an array |
477 | 479 | // of changed files in the long form listing format (see requirements req-ds-ls-5..10).
|
478 | 480 | //
|
479 | 481 | subscribe(contract, file, listener, options) {
|
|
0 commit comments