@webex/plugin-rooms 3.13.0-next.1 → 3.13.0-next.10
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/.repo-context.json +425 -0
- package/.sdd/manifest.json +396 -0
- package/AGENTS.md +207 -0
- package/dist/rooms.js +1 -1
- package/docs/adr/0001-retain-product-readme.md +98 -0
- package/docs/adr/index.md +25 -0
- package/docs/architecture.md +245 -0
- package/docs/getting-started.md +119 -0
- package/docs/index.md +42 -0
- package/docs/specs/README.md +68 -0
- package/package.json +11 -11
- package/schemas/repo-context.schema.json +796 -0
- package/src/docs/README.md +383 -0
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: Module Spec
|
|
3
|
+
title: 'Rooms plugin specification'
|
|
4
|
+
description: Responsibilities, boundaries, design, invariants, and verification for the Rooms plugin module.
|
|
5
|
+
tags: [module, specification]
|
|
6
|
+
---
|
|
7
|
+
<!-- sdd-generated-metadata
|
|
8
|
+
doc_kind: module-spec
|
|
9
|
+
generated_from: module-spec@0.3.0
|
|
10
|
+
generated_by: claude-code
|
|
11
|
+
approved_by: rarajes2@cisco.com
|
|
12
|
+
updated_at: 2026-11-12T17:06:43Z
|
|
13
|
+
validation_status: pass-with-warnings
|
|
14
|
+
-->
|
|
15
|
+
|
|
16
|
+
# Rooms plugin
|
|
17
|
+
|
|
18
|
+
This source-local document at `src/docs/README.md` owns the stable specification for **the Rooms
|
|
19
|
+
plugin**: the public plugin `webex.rooms`. It creates, reads, lists, updates, and deletes Webex rooms
|
|
20
|
+
(spaces) through the `rooms` resource of the Webex REST API (catalog service `hydra`); it reports per-room
|
|
21
|
+
read status from the internal conversation service; and, once `listen()` is called, it turns
|
|
22
|
+
conversation activities from the Mercury socket into webhook-shaped `created` and `updated` events.
|
|
23
|
+
Ground every claim in package evidence and link to the
|
|
24
|
+
[package architecture](../../docs/architecture.md) instead of repeating broader facts. No service
|
|
25
|
+
specification exists because this package is a library.
|
|
26
|
+
|
|
27
|
+
Related context: [documentation index](../../docs/index.md) ·
|
|
28
|
+
[package agent instructions](../../AGENTS.md)
|
|
29
|
+
|
|
30
|
+
## Metadata
|
|
31
|
+
|
|
32
|
+
| Field | Value |
|
|
33
|
+
| ----------------- | ----- |
|
|
34
|
+
| Owner | @webex/web-client, @webex/web-sdk |
|
|
35
|
+
| Source path | `src` |
|
|
36
|
+
| Resource kind | package |
|
|
37
|
+
| Status | Draft |
|
|
38
|
+
| Last verified | 2026-11-12 at `30598f6e9b` |
|
|
39
|
+
| Module id | `plugin-rooms` |
|
|
40
|
+
| Parent spec | — |
|
|
41
|
+
| Doc kind | Module spec |
|
|
42
|
+
| Coverage score | 100% assessed 2026-11-12 by the generator — 13 of 13 mandatory fields PRESENT, critical 7 of 7; the package has no unit tests and no `test:unit` script, so no requirement has running test evidence; `test/integration/spec/rooms.js` holds 11 live-service cases (1 skipped) that no script runs |
|
|
43
|
+
| Validation status | Pass with warnings — independently validated 2026-11-12; one Important coverage follow-up remains while the module stays Partial |
|
|
44
|
+
|
|
45
|
+
## Applicability
|
|
46
|
+
|
|
47
|
+
| Condition ID | Status | Evidence or reason | Owned section |
|
|
48
|
+
| ------------------------------------ | ---------- | ------------------ | ------------- |
|
|
49
|
+
| `module.has_tiers` | N/A | No tier policy exists in `package.json` or `src/rooms.js` | Tier |
|
|
50
|
+
| `module.has_ui` | N/A | `src/rooms.js` returns room records and emits events; it renders nothing | UI use-case flow |
|
|
51
|
+
| `module.crosses_service_boundaries` | Applicable | `src/rooms.js` calls the Webex REST API rooms resource, the conversation service through internal-plugin-conversation, and listens on the Mercury socket | Cross-boundary use-case flow |
|
|
52
|
+
| `module.holds_client_state` | N/A | The only instance property `src/rooms.js` sets is the event envelope, recorded under Business rules and invariants; no record is cached | Client state model |
|
|
53
|
+
| `module.enforces_domain_rules` | Applicable | The maxRecent check, the read-status shape, and the activity-verb mapping in `src/rooms.js` | Business rules and invariants |
|
|
54
|
+
| `module.is_concurrent_async` | Applicable | `src/rooms.js` returns promises, waits for the postauth catalog, and handles socket events asynchronously | Concurrency and reactive flow |
|
|
55
|
+
| `module.owns_persistence` | N/A | Nothing is stored; `src/rooms.js` resolves what the services return | Data, schema, and migration discipline |
|
|
56
|
+
| `module.stateful_transitions` | N/A | No entity moves through states in `src/rooms.js`; locked is a flag read from tags | State machine |
|
|
57
|
+
| `module.exposes_wire_protocol` | Applicable | The rooms requests, the read-status object, and the webhook-shaped event built in `src/rooms.js` | Protocol and wire format |
|
|
58
|
+
| `module.ui_multi_screen` | N/A | No UI | UI flow |
|
|
59
|
+
| `module.large_data_model` | N/A | Two shapes, the room object and the read-status object, typed only by JSDoc in `src/rooms.js`; covered under Protocol and wire format | Data model |
|
|
60
|
+
| `module.returns_caller_errors` | Applicable | The maxRecent rejection, request failures, and read-status failures reject from `src/rooms.js` | Caller-visible failure modes |
|
|
61
|
+
| `module.module_specific_conventions` | Applicable | Hydra room and person ids and the webhook-shaped event envelope in `src/rooms.js` | Module-specific rules |
|
|
62
|
+
| `module.published_package` | Applicable | `package.json` names the package @webex/plugin-rooms and defines deploy:npm | Export stability |
|
|
63
|
+
| `module.embedded_in_host` | N/A | No host theme or embed API | Host integration and theming |
|
|
64
|
+
| `module.has_design_tradeoff` | Applicable | Read status from the conversation service and events from the Mercury socket in `src/rooms.js` | Key design trade-off |
|
|
65
|
+
| `module.has_submodules` | N/A | The src directory has no child module | Sub-modules |
|
|
66
|
+
|
|
67
|
+
## Evidence register
|
|
68
|
+
|
|
69
|
+
| Evidence | What it establishes |
|
|
70
|
+
| -------- | ------------------- |
|
|
71
|
+
| `src/index.js` | Imports `@webex/internal-plugin-conversation` and `@webex/internal-plugin-mercury` for their registration side effects, then `registerPlugin('rooms', Rooms)` with no options; re-exports only the default `Rooms` |
|
|
72
|
+
| `src/rooms.js` | `Rooms` extends `WebexPlugin` with `listen`, `create`, `get`, `list`, `listWithReadStatus`, `getWithReadStatus`, `remove`, `update`, and the JSDoc-`@private` `onWebexApiEvent` and `getRoomEvent`; the module-level helpers `buildRoomInfo` and `buildRoomInfoList`; the `RoomObject` typedef. Its JSDoc and code comments are the only recorded rationale |
|
|
73
|
+
| `package.json` | Name, `main` (`dist/index.js`), `devMain` (`src/index.js`), `engines` (`node >=18`), dependencies, peer dependencies on `@webex/plugin-logger` and `@webex/plugin-people`, and scripts; `build`, `build:src`, `test:style`, `test:browser:broken`, `deploy:npm`, and `test` exist, and `test:unit`, `test:integration`, and `test:browser` do not |
|
|
74
|
+
| `test/integration/spec/rooms.js` | 11 live-service cases (1 skipped): `create` with the `created` event, a one-to-one space type, `get`, `list` with and without `max` and paging, `getWithReadStatus` and `listWithReadStatus` for two users, `update` with the `updated` event (skipped), and `remove`; no package script runs it (see Verification) |
|
|
75
|
+
| `README.md` | Retained npm page; context only. Its one example, `webex.rooms.get(id)`, and its scope note for `listen()` match the code; see `docs/adr/0001-retain-product-readme.md` |
|
|
76
|
+
| Sibling package common, file src/docs/README.md | Module spec consulted, agrees with code. Hydra ids are base64url of `ciscospark://<cluster>/<TYPE>/<id>` and `PEOPLE` ids always use cluster `us` (MOD-006, INV-001); the internal US clusters normalise to `us` (INV-005); `getHydraClusterString` throws below three cluster parts; `getHydraRoomType` maps the `ONE_ON_ONE` tag to `direct`, else `group`; `createEventEnvelope` resolves `undefined` when the identity lookup fails (MOD-011). The `SDK_EVENT` values and `deconstructHydraId` were read in the common code, which the spec only names |
|
|
77
|
+
| Sibling package webex-core, file src/docs/README.md | Module spec consulted, agrees with code. `registerPlugin` keeps the first registration of a name (MOD-013) and adds `webex.<name>` to later instances (MOD-014); `Page` wraps a list response with Link-header navigation (MOD-054). The spec is silent on the service catalog, so its code was the referee: `services.waitForCatalog('postauth')` waits up to 60 seconds and rejects on timeout, and `getClusterId` reads the cluster of a URL from the catalog |
|
|
78
|
+
| Sibling package internal-plugin-mercury, file src/docs/README.md | Module spec consulted, agrees with code. Importing the package registers internal plugin `mercury` (MOD-001); `connect()` shares a connect in flight and resolves at once when connected (MOD-002); an inbound envelope with event type `conversation.activity` is emitted as `event:conversation.activity` (MOD-009). Its code was read to confirm that a listener error is caught and logged by Mercury's `_emit` |
|
|
79
|
+
| Sibling package internal-plugin-conversation, file src/conversation.js | No module spec exists, so the code is the referee. `list(options)` sends the options as the query string of the conversation service and resolves an array of conversations; `get({id, cluster}, options)` builds the URL from the cluster and id, adds `uuidEntryFormat`, `personRefresh`, and other defaults to the query, rejects with an `Error` when no URL can be found, and resolves one conversation |
|
|
80
|
+
| Observation, no stated WHY | Behavior the code shows without stating a reason is recorded once, under Pitfalls and constraints or Caller-visible failure modes |
|
|
81
|
+
|
|
82
|
+
## Purpose and boundary
|
|
83
|
+
|
|
84
|
+
- Responsibility: give applications Webex rooms as Hydra-style records — create, read, list, update,
|
|
85
|
+
delete — plus a per-room read status and webhook-shaped room events over the existing Mercury socket.
|
|
86
|
+
- In scope: registration of `rooms`; the eight public methods; turning conversations into read-status
|
|
87
|
+
objects; turning `create`, `update`, `lock`, and `unlock` activities into `created` and `updated`
|
|
88
|
+
events.
|
|
89
|
+
- Out of scope: the request pipeline, authorization, service-catalog resolution, and paging
|
|
90
|
+
(`@webex/webex-core`); Hydra id encoding, the event envelope, and the event vocabulary
|
|
91
|
+
(`@webex/common`); the socket connection (`@webex/internal-plugin-mercury`); conversation requests and
|
|
92
|
+
decryption (`@webex/internal-plugin-conversation`); room membership and messages (the memberships and
|
|
93
|
+
messages plugins); caching room records; what Hydra stores or returns.
|
|
94
|
+
- Consumers: in this repository `webex` (`src/webex.js`) and `webex-node` (`src/webex-node.js`) import
|
|
95
|
+
the package to register it. No file under another package's `src/` calls `webex.rooms`; the
|
|
96
|
+
integration specs of plugin-memberships, plugin-teams, and the `webex` package call it, and the
|
|
97
|
+
workspace samples `docs/samples/browser-socket` and `docs/samples/browser-read-status` use `listen`
|
|
98
|
+
and the read-status methods. Applications reach the plugin as `webex.rooms`.
|
|
99
|
+
|
|
100
|
+
## Structure and key files
|
|
101
|
+
|
|
102
|
+
| Path | Responsibility |
|
|
103
|
+
| ---- | -------------- |
|
|
104
|
+
| `src/index.js` | Registers the conversation and Mercury internal plugins by import, registers public plugin `rooms`, and re-exports the class as default |
|
|
105
|
+
| `src/rooms.js` | `Rooms` and the read-status helpers `buildRoomInfo` and `buildRoomInfoList` |
|
|
106
|
+
| `package.json` | Package name, entry points, scripts, dependencies, and peer dependencies |
|
|
107
|
+
| `babel.config.js`, `jest.config.js` | Re-exports of the legacy Babel and Jest configurations; no unit spec uses the Jest one |
|
|
108
|
+
| `.eslintrc.js` | Sets `root: true` and extends `@webex/eslint-config-legacy` |
|
|
109
|
+
| `process` | Package-root file exporting `{browser: true}`; not imported by `src/` |
|
|
110
|
+
| `src/docs/README.md` | This module specification; ignored by the build and by lint |
|
|
111
|
+
| `test/integration/spec/rooms.js` | Live-service cases; only `test:browser:broken` would run them |
|
|
112
|
+
| dist/ (generated) | Build output of `build:src`; ignored by Git and never edited by hand |
|
|
113
|
+
|
|
114
|
+
## Public surface
|
|
115
|
+
|
|
116
|
+
| Surface | Consumer | Compatibility commitment | Source |
|
|
117
|
+
| ------- | -------- | ------------------------ | ------ |
|
|
118
|
+
| Import side effect: public plugin `rooms`, and internal plugins `conversation` and `mercury` | `webex`, `webex-node` | First registration of the name wins; reached as `webex.rooms` | `src/index.js` |
|
|
119
|
+
| `create(room)`, `get(room, options)`, `list(options)`, `update(room)`, `remove(room)` | Applications | Hydra room records; `list` resolves a webex-core `Page` | `src/rooms.js` |
|
|
120
|
+
| `listWithReadStatus(maxRecent)`, `getWithReadStatus(roomId)` | Applications; the read-status sample | Read-status objects; the JSDoc says each may be deprecated when the information is added to the room objects | `src/rooms.js` |
|
|
121
|
+
| `listen()` and the `created` and `updated` events | Applications; the socket sample | Webhook-shaped events triggered on `webex.rooms`; removed with the inherited `off` and `stopListening` | `src/rooms.js` |
|
|
122
|
+
| `onWebexApiEvent(event)`, `getRoomEvent(webex, activity, event)` | The Mercury listener | Marked `@private`; the JSDoc says SDK users should not call them | `src/rooms.js` |
|
|
123
|
+
| Default export `Rooms` | Hosts that mount the class themselves | The entry exports nothing else | `src/index.js` |
|
|
124
|
+
|
|
125
|
+
Contract ID `rooms-public-sdk` is indexed in the
|
|
126
|
+
[package architecture](../../docs/architecture.md#public-and-consumer-surfaces) and registered in
|
|
127
|
+
`.sdd/manifest.json`. Export stability is under [Export stability](#export-stability).
|
|
128
|
+
|
|
129
|
+
## Dependencies
|
|
130
|
+
|
|
131
|
+
| Dependency | Why it is required | Failure behavior |
|
|
132
|
+
| ---------- | ------------------ | ---------------- |
|
|
133
|
+
| `@webex/webex-core` plugin host (module spec consulted) | `registerPlugin`, `WebexPlugin` (`webex`, `request`, `logger`, and the event methods `on`, `off`, `trigger`, `listenTo`, `stopListening`), and `Page` | A request rejection rejects the method |
|
|
134
|
+
| `@webex/webex-core` services (code consulted) | Resolves `service: 'hydra'`; `waitForCatalog('postauth')` before read status; `getClusterId` for cluster strings | A catalog timeout rejects the read-status method |
|
|
135
|
+
| `@webex/common` (module spec consulted; code consulted for `SDK_EVENT` and `deconstructHydraId`) | `createEventEnvelope`, the Hydra id builders, `getHydraClusterString`, `getHydraRoomType`, `deconstructHydraId`, and `SDK_EVENT` | See Caller-visible failure modes |
|
|
136
|
+
| `@webex/internal-plugin-conversation` (no spec; code consulted) | Registered by import; `conversation.list` and `conversation.get` supply read status | Errors reject the read-status method |
|
|
137
|
+
| `@webex/internal-plugin-mercury` (module spec consulted) | Registered by import; `mercury.connect()` and the `event:conversation.activity` event | A connect failure rejects `listen()` |
|
|
138
|
+
| `@webex/plugin-people` (peer dependency) | `createEventEnvelope` calls `webex.people.get('me')` to fill the envelope | The envelope comes back `undefined`; see Caller-visible failure modes |
|
|
139
|
+
| `@webex/plugin-logger` (peer dependency) | Supplies `webex.logger` used by `getRoomEvent` | Not imported by `src/` |
|
|
140
|
+
| `lodash` | `cloneDeep` of the event envelope | — |
|
|
141
|
+
| `debug` | Namespace `rooms` trace lines for event payloads | Silent unless `DEBUG` enables `rooms`; then it prints full event payloads, room and person ids included |
|
|
142
|
+
| Webex REST API rooms resource and the conversation service (external) | Room records and read status | Errors propagate |
|
|
143
|
+
|
|
144
|
+
## Requirements
|
|
145
|
+
|
|
146
|
+
| ID | WHAT | WHY | Source evidence | Test or example evidence | Assumptions or gaps | Confidence |
|
|
147
|
+
| -- | ---- | --- | --------------- | ------------------------ | ------------------- | ---------- |
|
|
148
|
+
| `MOD-001` | Importing the package first imports `@webex/internal-plugin-conversation` and `@webex/internal-plugin-mercury`, registering both internal plugins, then registers `Rooms` as public plugin `rooms` with no config or other options. The entry re-exports only the default `Rooms`. | `listen()` needs `webex.internal.mercury` and the read-status methods need `webex.internal.conversation` (inferred from those calls); applications reach rooms as `webex.rooms`. | `src/index.js` | `test/integration/spec/rooms.js` imports the package and relies on it, but is not run | WHY inferred | Weak |
|
|
149
|
+
| `MOD-002` | `create(room)` sends `POST rooms` to service `hydra` with `room` as the body through `this.request` and resolves the response body. | The JSDoc: creates a room and adds the authenticated user as a member. | `src/rooms.js` | `test/integration/spec/rooms.js` create case (not run) | — | Present |
|
|
150
|
+
| `MOD-003` | `get(room, options)` takes `room.id`, else `room` itself, sends `GET rooms/<id>` to service `hydra` with `qs: options`, and resolves `res.body.items` when present, else `res.body`. | The JSDoc: returns a single room. | `src/rooms.js` | `test/integration/spec/rooms.js` get case (not run) | Why `items` is checked is not stated | Present |
|
|
151
|
+
| `MOD-004` | `list(options)` sends `GET rooms/` to service `hydra` with `qs: options` and resolves `new Page(res, webex)`. | The JSDoc: returns rooms, in most cases only those the user is a member of; `max` limits the number per page. Paging is the webex-core `Page` (webex-core MOD-054). | `src/rooms.js` | `test/integration/spec/rooms.js` list cases (not run) | — | Present |
|
|
152
|
+
| `MOD-005` | `update(room)` sends `PUT rooms/<room.id>` to service `hydra` with the whole `room` as the body and resolves the response body. | The JSDoc: updates a single room's properties. | `src/rooms.js` | `test/integration/spec/rooms.js` update case, skipped | — | Present |
|
|
153
|
+
| `MOD-006` | `remove(room)` takes `room.id`, else `room`, sends `DELETE rooms/<id>` to service `hydra`, and resolves `undefined` when the status is 204, else the response body. | The code comment: Firefox has issues with 204s or DELETE, and the handling should move to http-core. | `src/rooms.js` | `test/integration/spec/rooms.js` remove case (not run) | — | Present |
|
|
154
|
+
| `MOD-007` | `listWithReadStatus(maxRecent = 0)` calls `conversation.list` with `activitiesLimit: 0`, `computeTitleIfEmpty: true`, `conversationsLimit: 1000`, and `isActive: true`. When `maxRecent > 0` it sets `conversationsLimit` to `maxRecent` and `sinceDate` to the epoch milliseconds of 14 days ago. Otherwise a negative `maxRecent` rejects before any request (the unreachable `> 100` check is under Pitfalls). It first waits for the `postauth` catalog, and it resolves `{items}`, one read-status object per conversation (`MOD-009`), sorted by `lastActivityDate`, newest first. | The JSDoc: clients need read status on startup; all spaces up to 1000 can take time, so `maxRecent` (recommended 30, at most 100) returns only spaces active in the last two weeks; only `id`, `type`, `lastActivityDate`, and `lastSeenDate` are guaranteed, and `title` usually is. After startup, clients should track message and membership `seen` events. | `src/rooms.js` | `test/integration/spec/rooms.js` read-status cases for two users (not run) | JSDoc field-name drift; see Pitfalls | Present |
|
|
155
|
+
| `MOD-008` | `getWithReadStatus(roomId)` decodes `roomId` with `deconstructHydraId`, waits for the `postauth` catalog, calls `conversation.get({id, cluster}, {computeTitleIfEmpty: true, activitiesLimit: 0})`, and resolves the read-status object of that conversation (`MOD-009`). | The JSDoc: lets a client fetch one room "just in time" when an event names a room that was not in the original list; the code comment on `activitiesLimit`: do not send the whole activity history. | `src/rooms.js` | `test/integration/spec/rooms.js` read-status cases (not run) | — | Present |
|
|
156
|
+
| `MOD-009` | A read-status object is `{id, type, title?, lastActivityDate?, lastSeenActivityDate}`: `id` is the Hydra room id of the conversation id with the cluster from `getHydraClusterString` of the conversation URL; `type` is `direct` or `group` from the conversation tags; `title` is added when `displayName` or `computedTitle` is set, with the value of `displayName`; `lastActivityDate` is `lastReadableActivityDate`, else `lastRelevantActivityDate`, added only when set; `lastSeenActivityDate` is the conversation's value, else `new Date(0).toISOString()`. | The code comment: a user who has never been seen gets a date "a long time ago"; the JSDoc: a room whose `lastActivityDate` is after its last-seen date can be considered unread. | `src/rooms.js` | `test/integration/spec/rooms.js` read-status cases (not run) | The `title` value when only `computedTitle` is set; see Pitfalls | Present |
|
|
157
|
+
| `MOD-010` | `listen()` resolves `createEventEnvelope(webex, 'rooms')`, stores it as `this.eventEnvelope`, calls `webex.internal.mercury.connect()`, and then listens on Mercury for `event:conversation.activity`, passing each event to `onWebexApiEvent`. | The JSDoc: an alternative to rooms webhooks; it needs the `spark:all` and `spark:kms` scopes. | `src/rooms.js` | `test/integration/spec/rooms.js` create case checks a `created` event (not run) | No guard against a second `listen()`; see Pitfalls | Present |
|
|
158
|
+
| `MOD-011` | `onWebexApiEvent(event)` reads `event.data.activity`. Verb `create` triggers `created`; verbs `update`, `lock`, and `unlock` trigger `updated`; every other verb is ignored. An event is triggered only when `getRoomEvent` returns one. | The JSDoc: internal handler for activity events after `listen()`; SDK users should not call it. | `src/rooms.js` | None found | — | Present |
|
|
159
|
+
| `MOD-012` | `getRoomEvent(webex, activity, event)` deep-clones the envelope and sets `event`, `data.created` (`activity.published`), `actorId` (Hydra person id of `activity.actor.entryUUID`), and `data.id` (Hydra room id of `activity.object.id`, else `activity.target.id`), using the cluster of `activity.url`. For `created` it also sets `data.creatorId` to the actor and `data.lastActivity` to `activity.published`. For `updated` it reads the tags from `activity.target.tags` when the verb is `update`, else from `activity.object.tags`, and sets `data.creatorId` when `activity.object.creatorUUID` is present. It then sets `data.type` from the tags and `data.isLocked` to whether the tags include `LOCKED`. Any error is logged through `webex.logger.error` and returns `null`. | The JSDoc: build the event to match Hydra's webhook data. The code comments: tags are not in the object for an update; `creatorUUID` appears in lock and unlock but not update activities; `lastActivity` is not set for updates because the activity lacks `lastReadableActivityDate`. | `src/rooms.js` | `test/integration/spec/rooms.js` created and updated event checks (not run; the updated one is skipped) | — | Present |
|
|
160
|
+
|
|
161
|
+
## Design overview
|
|
162
|
+
|
|
163
|
+
`Rooms` is a `WebexPlugin` with three paths. The record path sends one Hydra request per call to the
|
|
164
|
+
`rooms` resource and resolves what Hydra returns; `list` wraps the response in a webex-core `Page`.
|
|
165
|
+
|
|
166
|
+
The read-status path does not use Hydra. It waits for the post-authentication service catalog, asks
|
|
167
|
+
the internal conversation service for one conversation or up to 1000, and converts each conversation
|
|
168
|
+
into a small object with a Hydra room id, a type, and the last-activity and last-seen dates.
|
|
169
|
+
|
|
170
|
+
The event path starts with `listen()`. It builds one webhook-style envelope for the current user,
|
|
171
|
+
connects the Mercury socket, and listens for conversation activities. Activities with the verbs
|
|
172
|
+
`create`, `update`, `lock`, and `unlock` become `created` or `updated` events with a cloned envelope;
|
|
173
|
+
the rest are ignored. Nothing is cached; every call reaches a service.
|
|
174
|
+
|
|
175
|
+
## Data flow and sequence coverage
|
|
176
|
+
|
|
177
|
+
Call style: in-process method calls on `webex.rooms`; outbound HTTPS through `webex.request` to catalog
|
|
178
|
+
service `hydra` or through the conversation plugin; inbound events from the Mercury socket. Three
|
|
179
|
+
operation groups differ in actors and outcome. The two that cross several components have a diagram;
|
|
180
|
+
the record path is one request per call.
|
|
181
|
+
|
|
182
|
+
| Operation group | Entry and outcome | Diagram or evidence | Failure and recovery coverage |
|
|
183
|
+
| --------------- | ----------------- | ------------------- | ----------------------------- |
|
|
184
|
+
| Room records | `create`, `get`, `list`, `update`, `remove`; one Hydra request each | `src/rooms.js` | The request error rejects; nothing is retried |
|
|
185
|
+
| Read status | `listWithReadStatus`, `getWithReadStatus`; catalog wait, conversation request, conversion | Diagram 1; `src/rooms.js` | A negative `maxRecent` rejects first; catalog, request, and conversion errors reject |
|
|
186
|
+
| Room events | `listen()`; Mercury activities become `created` and `updated` events | Diagram 2; `src/rooms.js` | A connect failure rejects `listen()`; a bad activity is logged and dropped |
|
|
187
|
+
|
|
188
|
+
Diagram 1 — read status:
|
|
189
|
+
|
|
190
|
+
```mermaid
|
|
191
|
+
sequenceDiagram
|
|
192
|
+
participant C as Caller
|
|
193
|
+
participant R as Rooms
|
|
194
|
+
participant S as services
|
|
195
|
+
participant V as conversation plugin
|
|
196
|
+
C->>R: listWithReadStatus(maxRecent) or getWithReadStatus(roomId)
|
|
197
|
+
R->>S: waitForCatalog('postauth')
|
|
198
|
+
R->>V: list(options) or get({id, cluster}, options)
|
|
199
|
+
V-->>R: conversation(s)
|
|
200
|
+
R->>R: buildRoomInfo per conversation; sort newest first
|
|
201
|
+
R-->>C: {items: [roomInfo]} or roomInfo
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Diagram 2 — room events:
|
|
205
|
+
|
|
206
|
+
```mermaid
|
|
207
|
+
sequenceDiagram
|
|
208
|
+
participant C as Caller
|
|
209
|
+
participant R as Rooms
|
|
210
|
+
participant P as common createEventEnvelope
|
|
211
|
+
participant M as mercury
|
|
212
|
+
C->>R: listen()
|
|
213
|
+
R->>P: createEventEnvelope(webex, 'rooms')
|
|
214
|
+
P-->>R: envelope (stored)
|
|
215
|
+
R->>M: connect(), then listenTo event:conversation.activity
|
|
216
|
+
M-->>R: activity (verb create, update, lock, or unlock)
|
|
217
|
+
R->>R: getRoomEvent: clone envelope, fill ids, type, isLocked
|
|
218
|
+
R-->>C: trigger created or updated
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Class and component relationships
|
|
222
|
+
|
|
223
|
+
```mermaid
|
|
224
|
+
classDiagram
|
|
225
|
+
class WebexPlugin
|
|
226
|
+
class Page
|
|
227
|
+
class Rooms {
|
|
228
|
+
eventEnvelope
|
|
229
|
+
listen()
|
|
230
|
+
create(room)
|
|
231
|
+
get(room, options)
|
|
232
|
+
list(options)
|
|
233
|
+
update(room)
|
|
234
|
+
remove(room)
|
|
235
|
+
listWithReadStatus(maxRecent)
|
|
236
|
+
getWithReadStatus(roomId)
|
|
237
|
+
onWebexApiEvent(event)
|
|
238
|
+
getRoomEvent(webex, activity, event)
|
|
239
|
+
}
|
|
240
|
+
class buildRoomInfo
|
|
241
|
+
class buildRoomInfoList
|
|
242
|
+
WebexPlugin <|-- Rooms
|
|
243
|
+
Rooms ..> Page : list(options)
|
|
244
|
+
Rooms ..> buildRoomInfoList : listWithReadStatus
|
|
245
|
+
Rooms ..> buildRoomInfo : getWithReadStatus
|
|
246
|
+
buildRoomInfoList ..> buildRoomInfo
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Use cases and flows
|
|
250
|
+
|
|
251
|
+
| Use case | Actor or caller | Primary steps and outcome | Failure or boundary behavior | Evidence |
|
|
252
|
+
| -------- | --------------- | ------------------------- | ---------------------------- | -------- |
|
|
253
|
+
| `UC-001` | Application managing rooms | `create`, `get`, `update`, or `remove` a room by object or id | The Hydra error rejects; `get` of a removed room rejects with status 404 | `src/rooms.js` |
|
|
254
|
+
| `UC-002` | Application listing rooms | `list({max, teamId, ...})` resolves a `Page`; `next()` fetches the next page | The request error rejects | `src/rooms.js` |
|
|
255
|
+
| `UC-003` | Client building an unread view at startup | `listWithReadStatus(30)`, then `listWithReadStatus()` for all spaces | A negative `maxRecent` rejects; a slow catalog or service delays or rejects | `src/rooms.js` |
|
|
256
|
+
| `UC-004` | Client receiving an event for an unknown room | `getWithReadStatus(roomId)` resolves that room's read status | An id that cannot be resolved to a conversation URL rejects | `src/rooms.js` |
|
|
257
|
+
| `UC-005` | Application replacing rooms webhooks | `listen()`, then `on('created')` and `on('updated')`; `stopListening()` and `off(...)` to stop | Needs `spark:all` and `spark:kms`; a connect failure rejects `listen()` | `src/rooms.js` |
|
|
258
|
+
|
|
259
|
+
### Cross-boundary use-case flow
|
|
260
|
+
|
|
261
|
+
| Boundary | Transport and ordering | Compatibility | Timeout, retry, and recovery |
|
|
262
|
+
| -------- | ---------------------- | ------------- | ---------------------------- |
|
|
263
|
+
| Webex REST API rooms resource (`UC-001`, `UC-002`) | HTTPS through `webex.request`, catalog service `hydra`, one per call | Requests under Protocol and wire format | No retry or timeout in this module; webex-core interceptors apply |
|
|
264
|
+
| Conversation service (`UC-003`, `UC-004`) | Through `webex.internal.conversation`, after the `postauth` catalog is ready | The conversation fields read by `buildRoomInfo` | The catalog wait rejects after 60 seconds (webex-core services code); no retry here |
|
|
265
|
+
| Mercury socket (`UC-005`) | `mercury.connect()`, then events in socket order | The activity fields read by `getRoomEvent` | Reconnects are Mercury's (internal-plugin-mercury MOD-005); events during a disconnect are not replayed here |
|
|
266
|
+
|
|
267
|
+
## Business rules and invariants
|
|
268
|
+
|
|
269
|
+
| ID | Invariant | WHY | Enforcement source | Test evidence |
|
|
270
|
+
| -- | --------- | --- | ------------------ | ------------- |
|
|
271
|
+
| `INV-001` | A negative `maxRecent` rejects before the catalog wait or any request. | The JSDoc: `maxRecent` must be an integer between 1 and 100. | `src/rooms.js` | None found |
|
|
272
|
+
| `INV-002` | Every read-status object has `id`, `type`, and `lastSeenActivityDate`; `lastSeenActivityDate` is never empty. | The JSDoc guarantees `id`, `type`, and the dates; the code comment sets an unseen room to a date long ago. | `src/rooms.js` | Only `test/integration/spec/rooms.js`, which is not run |
|
|
273
|
+
| `INV-003` | Read-status and event ids are Hydra ids built with the cluster of the conversation or activity URL, so they have the same form as the ids the rooms resource returns; person ids always use cluster `us`. | Callers match events and read status to rooms by id (inferred); common MOD-006 and INV-005. | `src/rooms.js` | Only `test/integration/spec/rooms.js`, which compares event ids with created room ids, and is not run |
|
|
274
|
+
| `INV-004` | Only the verbs `create`, `update`, `lock`, and `unlock` produce events, and an activity that cannot be converted produces none: the error is logged and the handler returns. | Events must keep the webhook shape (JSDoc of `getRoomEvent`); other verbs are not room changes (inferred). | `src/rooms.js` | None found |
|
|
275
|
+
| `INV-005` | Every event is built from a deep clone of the one envelope stored by `listen()`, so one event's fields never leak into the next. | The envelope is shared across events (inferred from `cloneDeep`). | `src/rooms.js` | None found |
|
|
276
|
+
|
|
277
|
+
## Concurrency and reactive flow
|
|
278
|
+
|
|
279
|
+
- Execution model: one JavaScript event loop; every public method returns a promise.
|
|
280
|
+
`onWebexApiEvent` and `getRoomEvent` are synchronous.
|
|
281
|
+
- Ordering guarantees: events are triggered in the order Mercury emits activities. `listWithReadStatus`
|
|
282
|
+
resolves only after every conversation is converted, sorted newest first.
|
|
283
|
+
- Parallel work: `buildRoomInfoList` converts every conversation and waits for all of them with
|
|
284
|
+
`Promise.all`.
|
|
285
|
+
- Idempotency and retry: `get`, `list`, and the read-status methods are reads and safe to repeat;
|
|
286
|
+
`create` makes a new room each time; `update` and `remove` repeat to the same end state on success.
|
|
287
|
+
Nothing is retried here.
|
|
288
|
+
- Fire-and-forget work: none; events are triggered synchronously inside the Mercury listener.
|
|
289
|
+
- Shared-state protection: `this.eventEnvelope` is replaced by each `listen()` and read by each event;
|
|
290
|
+
both run on the one event loop.
|
|
291
|
+
|
|
292
|
+
## Protocol and wire format
|
|
293
|
+
|
|
294
|
+
| Message or frame | Version | Producer or serializer | Consumer or parser | Compatibility and ordering rule |
|
|
295
|
+
| ---------------- | ------- | ---------------------- | ------------------ | ------------------------------- |
|
|
296
|
+
| `POST <hydra>/rooms` with the room body | Unversioned path under the catalog URL | `create` | Webex REST API | Body is the caller's object as given |
|
|
297
|
+
| `GET <hydra>/rooms/<id>?<options>` | Unversioned | `get` | Webex REST API | The id is interpolated without URL encoding |
|
|
298
|
+
| `GET <hydra>/rooms/?<options>` | Unversioned | `list` | Webex REST API | Every key of `options` becomes a query parameter; the response is read by `Page` |
|
|
299
|
+
| `PUT <hydra>/rooms/<id>` with the room body | Unversioned | `update` | Webex REST API | The whole object, `id` included, is the body |
|
|
300
|
+
| `DELETE <hydra>/rooms/<id>` | Unversioned | `remove` | Webex REST API | A 204 resolves `undefined` |
|
|
301
|
+
| Room object | — | Webex REST API | Callers | The JSDoc typedef names `id`, `title`, `teamId`, and `created` |
|
|
302
|
+
| Read-status object `{id, type, title?, lastActivityDate?, lastSeenActivityDate}` | — | `buildRoomInfo` | Callers | `type` is `direct` or `group`; dates are the conversation's strings; a list is `{items}` |
|
|
303
|
+
| Event `{createdBy, orgId, resource, ownedBy, status, created, data, event, actorId}` | — | `createEventEnvelope` plus `getRoomEvent` | `on('created')` and `on('updated')` listeners | `resource` is `rooms`, `ownedBy` `creator`, `status` `active`; `data` holds `id`, `created`, `type`, `isLocked`, and for `created` also `creatorId` and `lastActivity`; for `updated`, `creatorId` only when the activity carries `creatorUUID` |
|
|
304
|
+
|
|
305
|
+
## Caller-visible failure modes
|
|
306
|
+
|
|
307
|
+
| Condition | Signal or result | Caller behavior | Retry or recovery | Evidence |
|
|
308
|
+
| --------- | ---------------- | --------------- | ----------------- | -------- |
|
|
309
|
+
| `maxRecent` is negative | `listWithReadStatus` rejects with `rooms.listWithReadStatus: optional maxRecent parameter must be an integer between 1 and 100` | Pass 0 or a positive number | Call again | `src/rooms.js` |
|
|
310
|
+
| A Hydra request fails | `create`, `get`, `list`, `update`, or `remove` rejects with the webex-core request error; a missing room is status 404 | Handle the error | Call again | `src/rooms.js` |
|
|
311
|
+
| The `postauth` catalog is not ready within 60 seconds | The read-status method rejects with the services timeout error | Handle the error | Call again | `src/rooms.js` |
|
|
312
|
+
| `roomId` does not decode to a conversation the client can locate | `getWithReadStatus` rejects; when no URL can be built the conversation plugin rejects with an `Error` naming the missing URL | Pass a Hydra room id | — | `src/rooms.js` |
|
|
313
|
+
| A conversation URL has no known cluster | `getHydraClusterString` throws and the read-status method rejects with `Unable to determine cluster for convo` | — | — | `src/rooms.js` |
|
|
314
|
+
| `mercury.connect()` or the envelope lookup rejects | `listen()` rejects | Handle the error | Call `listen()` again | `src/rooms.js` |
|
|
315
|
+
| The current-user lookup inside `createEventEnvelope` fails | The envelope resolves `undefined` (common MOD-011) and `listen()` still resolves; every later activity fails in `getRoomEvent`, is logged, and produces no event | No signal reaches the caller; watch the logger | Call `listen()` again once `webex.people.get('me')` succeeds | `src/rooms.js` |
|
|
316
|
+
| An activity lacks the fields `getRoomEvent` reads (for example tags) | `webex.logger.error` logs `Unable to generate SDK event from mercury socket activity for rooms:<event> event: <message>`; no event | — | — | `src/rooms.js` |
|
|
317
|
+
| An event has no `data.activity` | `onWebexApiEvent` throws a `TypeError`; Mercury's `_emit` catches it and logs `error occurred in event handler` | — | — | `src/rooms.js` |
|
|
318
|
+
|
|
319
|
+
## Pitfalls and constraints
|
|
320
|
+
|
|
321
|
+
- The `maxRecent > 100` check sits in the `else` branch of `maxRecent > 0`, so a value above 100 is
|
|
322
|
+
sent as `conversationsLimit` instead of rejecting; a value that is not a number (such as `'abc'`)
|
|
323
|
+
matches neither branch and lists up to 1000 spaces.
|
|
324
|
+
- `sinceDate` is the number returned by `Date.prototype.setDate`, epoch milliseconds, not a date string.
|
|
325
|
+
- `buildRoomInfo` adds `title` when `displayName` or `computedTitle` is set but always copies
|
|
326
|
+
`displayName`, so a conversation with only `computedTitle` gets a `title` key whose value is
|
|
327
|
+
`undefined`.
|
|
328
|
+
- The `listWithReadStatus` and `getWithReadStatus` JSDoc name the field `lastSeenDate`; the object
|
|
329
|
+
carries `lastSeenActivityDate`.
|
|
330
|
+
- Each `listen()` call adds another Mercury listener, so calling it twice triggers every event twice.
|
|
331
|
+
`stopListening()` with no arguments removes every listener the plugin registered; it does not
|
|
332
|
+
disconnect Mercury.
|
|
333
|
+
- The `update` JSDoc example calls `update({title})` where it means `create`; the `list` JSDoc types
|
|
334
|
+
`options.max` as an object.
|
|
335
|
+
- `test:style` reports 3 warnings and no errors (the `require` of `debug`, and `buildRoomInfoList` and
|
|
336
|
+
`buildRoomInfo` used before they are defined), plus "File ignored" for this specification.
|
|
337
|
+
|
|
338
|
+
## Module-specific rules
|
|
339
|
+
|
|
340
|
+
- Do: send every room record request to service `hydra` through `this.request` so webex-core
|
|
341
|
+
interceptors and the catalog apply.
|
|
342
|
+
- Do: build ids only with the `@webex/common` Hydra helpers and the cluster from
|
|
343
|
+
`getHydraClusterString`, so `INV-003` holds.
|
|
344
|
+
- Do: keep `getRoomEvent` returning `null` on any error; a throw would reach Mercury's listener chain.
|
|
345
|
+
- Do not: add fields to an event without deep-cloning the stored envelope first (`INV-005`).
|
|
346
|
+
- Do not: change the event names `created` and `updated` or the `resource` `rooms`; listeners and the
|
|
347
|
+
samples rely on them.
|
|
348
|
+
- Do not: log room titles or ids with `webex.logger`; only the conversion error is logged today.
|
|
349
|
+
|
|
350
|
+
## Export stability
|
|
351
|
+
|
|
352
|
+
| Export or entry point | Consumer | Stability | Versioning and deprecation rule | Declaration or API report |
|
|
353
|
+
| --------------------- | -------- | --------- | ------------------------------- | ------------------------- |
|
|
354
|
+
| Import side effect: public plugin `rooms` | `webex`, `webex-node` | Public | No rule is declared in the package | `src/index.js` |
|
|
355
|
+
| Default export `Rooms`, its eight public methods, and the `created` and `updated` events | Applications | Public | Same; the JSDoc notes the two read-status methods may be deprecated | `src/index.js`, `src/rooms.js` |
|
|
356
|
+
|
|
357
|
+
The build writes JavaScript only; `package.json` has no `types` entry, so no declarations or API
|
|
358
|
+
report are published.
|
|
359
|
+
|
|
360
|
+
## Key design trade-off
|
|
361
|
+
|
|
362
|
+
| Chosen trade-off | Preserved invariant or benefit | Cost or limitation | Decision evidence |
|
|
363
|
+
| ---------------- | ------------------------------ | ------------------ | ----------------- |
|
|
364
|
+
| Read status from the internal conversation service, converted to Hydra ids | Unread state without a Hydra endpoint for it (`INV-002`, `INV-003`) | Waits for the `postauth` catalog; up to 1000 spaces with no paging; only some fields are guaranteed | `src/rooms.js` JSDoc of listWithReadStatus |
|
|
365
|
+
| Events from the Mercury socket instead of webhooks | No public endpoint needed; webhook-shaped payloads (`INV-004`) | Needs `spark:all` and `spark:kms`; `lastActivity` is missing from `updated`; a failed envelope silently drops all events | `src/rooms.js` JSDoc of listen and comments in getRoomEvent |
|
|
366
|
+
|
|
367
|
+
## Verification
|
|
368
|
+
|
|
369
|
+
| Requirement or invariant | Test level | Positive evidence | Negative or boundary evidence | Gap |
|
|
370
|
+
| ------------------------ | ---------- | ----------------- | ----------------------------- | --- |
|
|
371
|
+
| `MOD-001` | None run | `test/integration/spec/rooms.js` (not run) | None found | No unit case |
|
|
372
|
+
| `MOD-002` to `MOD-006` | None run | `test/integration/spec/rooms.js` (not run; the update case is skipped) | `test/integration/spec/rooms.js` remove case expects 404 on a later get (not run) | No unit case |
|
|
373
|
+
| `MOD-007` to `MOD-009`, `INV-001`, `INV-002` | None run | `test/integration/spec/rooms.js` (not run) | None found | The `maxRecent` checks and the object shape have no case |
|
|
374
|
+
| `MOD-010` to `MOD-012`, `INV-003` to `INV-005` | None run | `test/integration/spec/rooms.js` created and updated event checks (not run; updated skipped) | None found | Verb mapping, lock and unlock, and the error path have no case |
|
|
375
|
+
|
|
376
|
+
The package has no unit tests: `package.json` defines no `test:unit` script and there is no
|
|
377
|
+
`test/unit` directory. No package script runs `test/integration/spec/rooms.js` either: there is no
|
|
378
|
+
`test:integration`, and `test:browser:broken` reported 0 tests on 2026-11-12 because the karma bundle
|
|
379
|
+
failed to parse `isbot`, while still exiting 0. The aggregate `test` script exits 1 at the missing
|
|
380
|
+
`test:unit`. `build:src` and `test:style` exit 0. A module specification is complete only when its
|
|
381
|
+
public surface, invariants, failure modes, and test evidence agree with the implementation.
|
|
382
|
+
Generator-side field measurement is complete (100%, assessed 2026-11-12); independent validation has
|
|
383
|
+
not run, and the module stays Partial until a unit suite and a characterization baseline exist.
|