@paddockai/client 0.0.3 → 0.0.5

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.
package/dist/index.js CHANGED
@@ -11,8 +11,10 @@ var streamEventNames = [
11
11
  "config.applied",
12
12
  "session.status",
13
13
  "outbox.queued",
14
+ "outbox.retrying",
14
15
  "outbox.delivered",
15
16
  "outbox.failed",
17
+ "inbox.failed",
16
18
  "status.update",
17
19
  "error"
18
20
  ];
@@ -512,9 +514,12 @@ var SessionOperations = class {
512
514
  get base() {
513
515
  return `/sessions/${segment(this.id)}`;
514
516
  }
515
- /** Stores a user message; resolves with its event once stored (002#operations_2). */
516
- send(text) {
517
- return this.transport.request({ method: "POST", path: `${this.base}/messages`, json: { text } });
517
+ /**
518
+ * Stores a user message; resolves with its event once stored (004#messages). author, the person
519
+ * the message speaks for, is allowed with an API key or a function token, never a session token.
520
+ */
521
+ send(text, options = {}) {
522
+ return this.transport.request({ method: "POST", path: `${this.base}/messages`, json: { text, ...options } });
518
523
  }
519
524
  /** Stores a stop.requested event and resolves with it. */
520
525
  stop() {
@@ -524,13 +529,15 @@ var SessionOperations = class {
524
529
  stream(options = {}) {
525
530
  return new EventStream(this.transport, `${this.base}/stream`, options);
526
531
  }
527
- /** Mints a session token for the browser. */
532
+ /**
533
+ * Mints a session token for the browser: ttl in seconds; participant authors the token's
534
+ * messages; readOnly makes a token that can only read and follow the session (004#credentials).
535
+ */
528
536
  createToken(options) {
529
- return this.transport.request({
530
- method: "POST",
531
- path: `${this.base}/tokens`,
532
- json: { ttlSeconds: options.ttl }
533
- });
537
+ const json = { ttlSeconds: options.ttl };
538
+ if (options.participant) json.participant = options.participant;
539
+ if (options.readOnly) json.readOnly = true;
540
+ return this.transport.request({ method: "POST", path: `${this.base}/tokens`, json });
534
541
  }
535
542
  /** Reads the session. */
536
543
  get() {
@@ -677,7 +684,7 @@ var SessionFold = class {
677
684
  };
678
685
 
679
686
  // src/version.ts
680
- var version = "0.0.3";
687
+ var version = "0.0.5";
681
688
 
682
689
  // src/client.ts
683
690
  var loadPage = 200;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paddockai/client",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "The paddock client SDK: a session token turned into live session state in the browser.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",