@wtfalch/calls 0.5.0 → 0.6.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.
package/README.md CHANGED
@@ -12,6 +12,8 @@ await calls.joinAdmission(sessionId, { video: false, requestId: crypto.randomUUI
12
12
 
13
13
  `waiting(sessionId)` lists the guests waiting in the lobby, oldest first, for a host who holds `calls.participants:admit`. `record(sessionId)` reads what happened in a call: when it started and ended, and when each participant was admitted and left. Anyone who was in the call can read it, and so can holders of `calls.records:read`. A guest's copy carries no member's `actorId`.
14
14
 
15
+ `missedCalls({ since, limit })` lists, newest first, the calls in rooms you may join that started without you, that someone was in, and that you neither joined nor declined. Each entry is `{ sessionId, roomId, callerName, at }`. `since` is epoch milliseconds (default 7 days back, at most 30); `limit` is 1 to 50 (default 20). `callerName` is `''` when the host's directory has no name for the caller. Needs a signed-in member; a guest is refused.
16
+
15
17
  Member requests use same-origin cookies and exact-origin requests, unless `token` supplies a bearer instead. `baseUrl` may carry a path prefix, and `deviceId` is sent as `x-calls-device` on member requests. `createCallEndpoint` in the browser entry takes the same three options and sends every request, gateway included, under the prefix; see `docs/control-sdk.md`. Guest link redemption returns a handle whose opaque credential remains private to the handle. `guestPreview(secret)` answers for a valid guest link, without a name and without using up the link, `{ companyName, roomName, hostName, inCall: { displayName }[], expiresAt, recording }`; it needs the host to supply a `directory`, and answers `not_configured` until it does. Errors are typed `CallsError`; requests are bounded and are never retried automatically.
16
18
 
17
19
  `@wtfalch/calls/browser` is the media-ready call handle. `join()` returns a `CallHandle` with:
package/index.d.ts CHANGED
@@ -28,6 +28,7 @@ export function createCallsClient(options: CallsClientOptions): CallsClient;
28
28
  export interface CallsClient {
29
29
  createSession(input: { sessionId: string; roomId: string; validFrom: number; expiresAt: number; capacity: number; requestId: string }): Promise<OperationResult & { sessionId: string }>;
30
30
  roomStatus(roomId: string): Promise<{ live: false } | { live: true; sessionId: string; participantCount: number }>;
31
+ missedCalls(options?: { since?: number; limit?: number }): Promise<{ sessionId: string; roomId: string; callerName: string; at: number }[]>;
31
32
  invitation(roomId: string): Promise<{ invited: false } | { invited: true; sessionId: string; roomId: string; startedBy: string | null; members: string[]; decline: { reason: string; declinedAt: number } | null }>;
32
33
  joinAdmission(sessionId: string, input: { video: boolean; requestId: string }): Promise<OperationResult & { admissionId: string }>;
33
34
  admitGuest(sessionId: string, input: { admissionId: string; video: boolean; requestId: string }): Promise<OperationResult & { admissionId: string }>;
package/index.mjs CHANGED
@@ -63,6 +63,15 @@ function invitationResult(value) {
63
63
  }
64
64
  return { invited: true, sessionId: value.sessionId, roomId: value.roomId, startedBy: value.startedBy, members: value.members, decline };
65
65
  }
66
+ function missedResult(value) {
67
+ // run() already refuses a reply that is not an object; an array has no `missed`.
68
+ if (!Array.isArray(value.missed)) throw new CallsError('invalid_response');
69
+ return value.missed.map(entry => {
70
+ entry = object(entry); responseId(entry.sessionId);
71
+ if (typeof entry.roomId !== 'string' || entry.roomId.length < 1 || entry.roomId.length > 128 || typeof entry.callerName !== 'string') throw new CallsError('invalid_response');
72
+ return { sessionId: entry.sessionId, roomId: entry.roomId, callerName: entry.callerName, at: expires(entry.at) };
73
+ });
74
+ }
66
75
  function waitingResult(value) {
67
76
  value = object(value);
68
77
  if (!Array.isArray(value.waiting)) throw new CallsError('invalid_response');
@@ -158,6 +167,13 @@ export function createCallsClient(options) {
158
167
  if (typeof roomId !== 'string' || roomId.length < 1 || roomId.length > 128) throw new TypeError('invalid roomId');
159
168
  return run('/v1/rooms/invitation', { roomId }).then(v => invitationResult(v));
160
169
  },
170
+ missedCalls(options = {}) {
171
+ if (!options || typeof options !== 'object' || Array.isArray(options)) throw new TypeError('invalid options');
172
+ const { since, limit } = options, body = {};
173
+ if (since !== undefined) { if (!Number.isSafeInteger(since)) throw new TypeError('invalid since'); body.since = since; }
174
+ if (limit !== undefined) { if (!Number.isInteger(limit) || limit < 1 || limit > 50) throw new TypeError('invalid limit'); body.limit = limit; }
175
+ return run('/v1/calls/missed', body).then(v => missedResult(v));
176
+ },
161
177
  joinAdmission(sessionId, { video = false, requestId: rid } = {}) {
162
178
  if (typeof video !== 'boolean') throw new TypeError('invalid video');
163
179
  return run(sessionPath(sessionId, 'join'), { video, requestId: requestId(rid) }).then(v => operationResult(v, ['admissionId']));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wtfalch/calls",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Framework-independent SDK for Agora calls: session control (admission, guest links, moderation) and a media-ready browser call handle.",
5
5
  "license": "MIT",
6
6
  "type": "module",