openvibers/openvibe.sdk Commits
openvibe-sdk 0.157.0: openvibe-sdk/views, one view API for every content kind (#241)
Changes
@@@ -1,5 +1,17 @@# Changelog++## 0.158.0 — 2026-11-12++++- **`openvibe-sdk/views`: one view API for every content kind** (Contracts `media.view-request@1`, the `media.viewed`++ and `media.engaged` events).++ - `createViewsClient(client).record(event | [events])` posts a preview, watch or live heartbeat for++ `ref: { service, kind, id }` to Media's `POST /api/v1/views`, up to 20 at once. `seconds` is cumulative for the++ session and item, so a retry does not count twice; a signed-out viewer keeps an opaque session id.++ - `.counts(ref)` reads one item's `{ views, engaged, previews, preview_share, peak_concurrent }` from++ `GET /api/v1/views/counts`. Media never stores an IP address or a user agent with a view, and a preview counts++ from 1 second.++++## 0.157.0 — 2026-11-12See it work: a run's desks, control and replay@@@ -8,6 +20,7 @@ See it work: a run's desks, control and replay`handBack(run, desk, note)` and `replay(run)` → the steps with the still each saw. They call the same-named routesunder the client's service (`/api/v1/runs/:id/desks/...`), so a page and a script make the same calls. No tag: themain session releases this after the sites' stage lands.++## 0.156.0 — 2026-11-12- **`openvibe-sdk/exchange`: reviewed compute prices, keyless.**@@@ -8,12 +8,12 @@**Install and test:** `npm ci && npm test` (Node 20 or newer)```bash--npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.157.0++npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.158.0```> Supported browser and server clients for the OpenVibe platform.--**Status:** alpha, v0.157.0 (the five 1.0 core entries — `core`, `auth`, `events`, `db` and `media` — are frozen: their exported names change only with a major release; roadmap Wave 2; developer apps from Wave 20; Media objects v2 from Wave 4; the Tools platform API; Search, Chat, AI, Vision and consent clients; sign-in with recovery and a client health check). Every release is tagged (see [CHANGELOG.md](CHANGELOG.md)). Tested against local stub servers and the built-in mock platform only, never against the live platform. Services pin release tags; each repository's `STATUS.json` names the one it uses.++**Status:** alpha, v0.158.0 (the five 1.0 core entries — `core`, `auth`, `events`, `db` and `media` — are frozen: their exported names change only with a major release; roadmap Wave 2; developer apps from Wave 20; Media objects v2 from Wave 4; the Tools platform API; Search, Chat, AI, Vision and consent clients; sign-in with recovery and a client health check). Every release is tagged (see [CHANGELOG.md](CHANGELOG.md)). Tested against local stub servers and the built-in mock platform only, never against the live platform. Services pin release tags; each repository's `STATUS.json` names the one it uses.**Plan:** OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), §3.2; roadmap §30.**License:** MIT ([LICENSE](LICENSE)). This package is a library that apps outside the network embed, so it uses MIT. The OpenVibe services themselves stay AGPL-3.0.@@@ -22,7 +22,7 @@ npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tagsAfter v0.97.1 is tagged:```bash--npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.157.0++npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.158.0```It has no runtime dependencies. It needs Node ≥ 20, or any browser with `fetch`, Web Crypto and `TextDecoder`. There is no build step. The package is CommonJS with ESM entry points (`import` works). Each subpath has its own `.d.ts`. For a page with no bundler, `browser/openvibe-sdk.mjs` is one self-contained ES module of the browser-safe subpaths (see [Browser without a bundler](#browser-without-a-bundler)). It does not depend on `openvibe-contracts` at runtime: it copies the contract types it uses (from the temporary Contracts sharing branch, a devDependency the tests check them against).@@@ -208,6 +208,7 @@ Until OpenVibe.Tools serves the gateway facade (Tools S6), point the jobs client| `openvibe-sdk/history` | both | Private history reads: cursor pages, title search, day/week summaries, recent agent reads, settings and owner-scoped deletes. || `openvibe-sdk/home-feed` | both | `createHomeFeedClient(client)` gives `ov.home.get()/set(layout)`, `ov.network.today()`, `ov.feed.list({ for: 'me', cursor })`, `ov.feed.post(text)`, and `ov.feed.contribute({ id, text, url })`. Personal calls need a user Bearer token; contribution needs an app token granted `community.pulse.contribute`. Today is public and cached by Network for five minutes. || `openvibe-sdk/feed` | both | `createFeedClient(client)` gives `ov.feed.list({ kind, cursor })` for the public cross-site Community Feed. Pass the returned `next_cursor` as `cursor` to read the next page. |++| `openvibe-sdk/views` | both | `createViewsClient(client)`: `record(event \| [events])` (up to 20 per call) sends a preview, watch or live heartbeat for `{ service, kind, id }` to `POST /api/v1/views`; `counts(ref)` reads `{ views, engaged, previews, preview_share, peak_concurrent }`. A signed-out viewer keeps an opaque session id; the service stores no IP or user agent and counts a preview from 1 s. || `openvibe-sdk/bot` | both | `createBotClient(client, {actingSubject?})`: OpenVibe.Bot robots. `robots.list/get/create/update/delete/pairingCode`, `robots.operators.list/add/remove`, `robots.devices`, `robots.streaming.get/set`, `robots.audit`/`iterateAudit`, `robots.estop`/`clearEstop`, `robots.command` (`bot.command@1`), `embedUrl(robotId, mode)` (panel, overlay or compact), `devices.rotate/revoke`, public `profiles.list/get` and `kits.list/get`, `pair` (the agent's one-time code, never retried), `as(subject)`; a service acts for a person with `X-OV-Subject` (capabilities `bot.robot.read`/`manage`/`control`, `bot.device.connect`) || `openvibe-sdk/themes` | both | `createThemesClient(client)`: `catalog({mode, search, sort, limit})` (seasonal themes carry `season`), `get(idOrSlug)` (null when missing), `export(idOrSlug)`, `active()` (`{theme_id, custom_variables, display}`), `set(themeId, {custom})`, `setDisplay({motion, text, seasonal})`, `seasons({date})`, `submissions()`, `submit(theme)`, `import(file)`. In the browser: `followTheme(fn)` calls back now and on every theme, display or season change with `readTheme()` (`{id, mode, tokens, display: {motion, text, textScale, seasonal, calm}, season, seasonMark}`) and returns `stop()`, for a canvas or game to keep up; `applyTheme(vars, {root})`, `seasonOn(date, seasons)`, `onColor(hex)`, `DISPLAY_OPTIONS`, `TOKENS` || `openvibe-sdk/bench` | both | `createBenchClient(client, {actingSubject?})`: `kinds.list/get`, `tasks.create/get`, `rounds.create/get`, `entries.submit`, `judgements.next/cast`, `boards.get`, `ratings.get` (public, at least twenty games), `models.get`, `datasets.get/iterate`, `evals.create/get/run/results`, `mcpTools()`. Audience `openvibe.bench`; service id `bench`. |@@@ -3,7 +3,7 @@"stage": "alpha","code": true,"wave": "W2",-- "version": "0.157.0",++ "version": "0.158.0","plan": "OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), \u00a73.2; roadmap \u00a730","deployed": false,"deployment": "none: a package released as git tags; services and apps pin a tag",@@@ -24,6 +24,7 @@ module.exports = {community: require('./src/community'),homeFeed: require('./src/home-feed'),feed: require('./src/feed'),++ views: require('./src/views'),bot: require('./src/bot'),search: require('./src/search'),bench: require('./src/bench'),@@@ -1,6 +1,6 @@--// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.157.0, MIT). Do not edit.++// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.158.0, MIT). Do not edit.// One self-contained ES module: core at the top level plus the browser-safe subpaths as namespaces--// (auth, locker, registry, trust, levels, modules, realtime, media, composer, cam, mediaUpload, ui, uiLayout, community, homeFeed, feed, bot, search, bench, meme, vision, themes, elements, design, redact, chat, ai, credentials, jobs, agents, frame, tools, projects, geo, history, userCard, player, agentSheet). No server-only code: no service tokens, JWT verification, events, identity.++// (auth, locker, registry, trust, levels, modules, realtime, media, composer, cam, mediaUpload, ui, uiLayout, community, homeFeed, feed, views, bot, search, bench, meme, vision, themes, elements, design, redact, chat, ai, credentials, jobs, agents, frame, tools, projects, geo, history, userCard, player, agentSheet). No server-only code: no service tokens, JWT verification, events, identity./* eslint-disable */const __defs = [// ── 0: browser.js ──────────────────────────────────────────────────@@@ -31,28 +31,29 @@ module.exports = {community: __load(33),homeFeed: __load(34),feed: __load(35),-- bot: __load(36),-- search: __load(37),-- bench: __load(38),-- meme: __load(39),-- vision: __load(40),-- themes: __load(41),-- elements: __load(42),-- design: __load(43),-- redact: __load(44),-- chat: __load(45),-- ai: __load(47),-- credentials: __load(49),-- jobs: __load(50),-- agents: __load(52),-- frame: __load(53),-- tools: __load(54),-- projects: __load(55),-- geo: __load(56),-- history: __load(57),-- userCard: __load(58),-- player: __load(59),-- agentSheet: __load(60),++ views: __load(36),++ bot: __load(37),++ search: __load(38),++ bench: __load(39),++ meme: __load(40),++ vision: __load(41),++ themes: __load(42),++ elements: __load(43),++ design: __load(44),++ redact: __load(45),++ chat: __load(46),++ ai: __load(48),++ credentials: __load(50),++ jobs: __load(51),++ agents: __load(53),++ frame: __load(54),++ tools: __load(55),++ projects: __load(56),++ geo: __load(57),++ history: __load(58),++ userCard: __load(59),++ player: __load(60),++ agentSheet: __load(61),};},// ── 1: src/core/index.js ───────────────────────────────────────────@@@ -67,7 +68,7 @@ const { paginate, offsetPager } = __load(7);const semver = __load(6);/** The package version (test/version.test.js keeps it equal to package.json). */--const SDK_VERSION = '0.157.0';++const SDK_VERSION = '0.158.0';module.exports = {createClient,@@@ -4154,7 +4155,106 @@ function createFeedClient(client, { communityBaseUrl } = {}) {module.exports = { createFeedClient };},--// ── 36: src/bot.js ──────────────────────────────────────────────────++// ── 36: src/views.js ────────────────────────────────────────────────++function (module, exports) {++'use strict';++++/**++ * openvibe-sdk/views — one view API for every content kind.++ *++ * const views = createViewsClient(client);++ * await views.record({ ref: { service: 'media', kind: 'vod', id: '42' }, how: 'preview', seconds: 2, session });++ * await views.record([ … up to 20 events … ]);++ * const counts = await views.counts({ service: 'media', kind: 'vod', id: '42' });++ * // → { ref, counts: { views, engaged, previews, preview_share, peak_concurrent } }++ *++ * OpenVibe.Media owns the numbers for every kind (a Media VOD or clip, a Live recording or stream, a Feed item):++ * POST /api/v1/views is public and CORS *, dedupes one view per person or anonymous session per item per 30 minutes,++ * counts a preview from 1 second and engagement at 30 seconds or a third of the length (60 seconds of a live stream),++ * and never stores an IP address or a user agent. `seconds` is cumulative for the session and item: a retry sends the++ * same number, playback sends a larger one, and neither counts the item twice.++ *++ * A signed-in viewer sends their Network token on the client and no session; a signed-out viewer keeps an opaque++ * `session` id of their own. The write is not retried for you: a retry is safe (same session, same item), but this++ * client leaves the decision to the caller, like the other beacon-shaped writes.++ */++const MEDIA_URL = 'https://openvibe.media';++const MAX_BATCH = 20;++const HOWS = ['preview', 'watch', 'live'];++const SERVICE_RE = /^[a-z][a-z0-9-]{1,39}$/;++const KIND_RE = /^[a-z][a-z0-9_]{1,39}$/;++const SESSION_RE = /^[A-Za-z0-9._~-]{8,128}$/;++++function refOf(ref) {++ if (!ref || typeof ref !== 'object' || Array.isArray(ref)) throw new TypeError('views: ref must be { service, kind, id }');++ const service = String(ref.service || '');++ const kind = String(ref.kind || '');++ const id = ref.id == null ? '' : String(ref.id);++ if (!SERVICE_RE.test(service)) throw new TypeError('views: ref.service is a service id (media, live, network…)');++ if (!KIND_RE.test(kind)) throw new TypeError('views: ref.kind is an item type (vod, clip, recording, stream…)');++ if (!id || id.length > 200) throw new TypeError('views: ref.id is 1–200 characters');++ const out = { service, kind, id };++ if (ref.site != null) {++ if (!/^[a-z][a-z0-9-]{0,39}$/.test(String(ref.site))) throw new TypeError('views: ref.site is a site id');++ out.site = String(ref.site);++ }++ if (ref.creator != null) {++ if (String(ref.creator).length > 200) throw new TypeError('views: ref.creator is at most 200 characters');++ out.creator = String(ref.creator);++ }++ return out;++}++++function eventOf(event) {++ if (!event || typeof event !== 'object' || Array.isArray(event)) throw new TypeError('views.record: each event is an object');++ const how = String(event.how || '');++ if (!HOWS.includes(how)) throw new TypeError(`views.record: how is ${HOWS.join(', ')}`);++ const seconds = Number(event.seconds);++ if (!Number.isFinite(seconds) || seconds < 0 || seconds > 86400) throw new TypeError('views.record: seconds is 0–86400');++ const out = { ref: refOf(event.ref), how, seconds };++ if (event.of_seconds != null) {++ const of = Number(event.of_seconds);++ if (!Number.isFinite(of) || of <= 0 || of > 86400) throw new TypeError('views.record: of_seconds is 1–86400');++ out.of_seconds = of;++ }++ if (event.session != null) {++ if (!SESSION_RE.test(String(event.session))) throw new TypeError('views.record: session is 8–128 letters, digits, . _ ~ or -');++ out.session = String(event.session);++ }++ return out;++}++++function createViewsClient(client, { baseUrl = MEDIA_URL } = {}) {++ if (!client || typeof client.json !== 'function') throw new TypeError('createViewsClient: pass an openvibe-sdk/core client');++ const base = String(baseUrl || MEDIA_URL).replace(/\/+$/, '');++ return {++ /**++ * Record one event or up to 20 at once. → { results: [{ accepted, counted, engaged, reason? }], counts? }++ * `session` is required by the service for a signed-out viewer; a signed-in viewer sends their token instead.++ */++ record(events, { signal } = {}) {++ const list = Array.isArray(events) ? events : [events];++ if (!list.length) throw new TypeError('views.record: send at least one event');++ if (list.length > MAX_BATCH) throw new TypeError(`views.record: at most ${MAX_BATCH} events in one call`);++ return client.json({++ baseUrl: base, path: '/api/v1/views', method: 'POST',++ json: { events: list.map(eventOf) }, signal, service: 'media',++ });++ },++ /** One item's numbers: views, engaged viewers, preview views, the feed-preview share and live peak concurrent. */++ counts(ref, { signal } = {}) {++ const r = refOf(ref);++ return client.json({++ baseUrl: base, path: '/api/v1/views/counts',++ query: { service: r.service, kind: r.kind, id: r.id }, signal, service: 'media',++ });++ },++ };++}++++module.exports = { createViewsClient, refOf, eventOf, MEDIA_URL, MAX_BATCH, HOWS };++},++// ── 37: src/bot.js ──────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -4395,7 +4495,7 @@ function createBotClient(client, defaults = {}) {module.exports = { createBotClient, actingHeaders };},--// ── 37: src/search.js ───────────────────────────────────────────────++// ── 38: src/search.js ───────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -4541,7 +4641,7 @@ function createSearchClient(client, defaults = {}) {module.exports = { createSearchClient, queryOf, fabricOf, codeOf };},--// ── 38: src/bench.js ────────────────────────────────────────────────++// ── 39: src/bench.js ────────────────────────────────────────────────function (module, exports) {'use strict';/** openvibe-sdk/bench: OpenVibe.Bench's JSON API and streamed open dataset. Browser-safe. */@@@ -4649,7 +4749,7 @@ function createBenchClient(client, defaults = {}) {module.exports = { createBenchClient };},--// ── 39: src/meme.js ─────────────────────────────────────────────────++// ── 40: src/meme.js ─────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -4732,7 +4832,7 @@ function createMemeClient(client, defaults = {}) {module.exports = { createMemeClient };},--// ── 40: src/vision.js ───────────────────────────────────────────────++// ── 41: src/vision.js ───────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -4890,7 +4990,7 @@ function pick(o, keys) {module.exports = { createVisionClient, DEFAULT_AUDIENCE };},--// ── 41: src/themes.js ───────────────────────────────────────────────++// ── 42: src/themes.js ───────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -5040,7 +5140,7 @@ function followTheme(fn, opts = {}) {module.exports = { createThemesClient, followTheme, readTheme, applyTheme, seasonOn, onColor, DISPLAY_OPTIONS, TOKENS };},--// ── 42: src/elements.js ─────────────────────────────────────────────++// ── 43: src/elements.js ─────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -5468,7 +5568,7 @@ module.exports = {PRODUCTS, ACTION_KINDS, ACTION_SET, TRIGGER_KINDS, TRIGGER_SET, ROBOT_ACTIONS, ROLES, ROLE_RANK,};},--// ── 43: src/design.js ───────────────────────────────────────────────++// ── 44: src/design.js ───────────────────────────────────────────────function (module, exports) {'use strict';@@@ -5543,7 +5643,7 @@ function createDesignClient({ accessToken = null, baseUrl = DEFAULT_DESIGN_URL,module.exports = { createDesignClient, DEFAULT_DESIGN_URL };},--// ── 44: src/redact.js ───────────────────────────────────────────────++// ── 45: src/redact.js ───────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -5790,7 +5890,7 @@ function onlySecret(text) {module.exports = { redact, onlySecret };},--// ── 45: src/chat.js ─────────────────────────────────────────────────++// ── 46: src/chat.js ─────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -5823,7 +5923,7 @@ function (module, exports) {const { isOpenVibeError } = __load(3);const enc = encodeURIComponent;--const history = __load(46);++const history = __load(47);/** The kinds chat.embed@1 names; anything else is not a preview this SDK returns. */const EMBED_KINDS = new Set(['link', 'video', 'image', 'live', 'picture', 'design', 'post', 'profile', 'game']);@@@ -6112,7 +6212,7 @@ function createFeedPublisher(client, { feed, key, baseUrl } = {}) {module.exports = { createChatClient, createInboxVisitor, createFeedPublisher, history, readEmbeds };},--// ── 46: src/chat-history.js ─────────────────────────────────────────++// ── 47: src/chat-history.js ─────────────────────────────────────────function (module, exports) {'use strict';@@@ -6191,7 +6291,7 @@ function attach({ feed, status = null, fetchPage, render, hasMore = true, threshmodule.exports = { pages, attach };},--// ── 47: src/ai.js ───────────────────────────────────────────────────++// ── 48: src/ai.js ───────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -6371,7 +6471,7 @@ function createAiClient(client, defaults = {}) {remove(id) { requireFiles('remove'); return fileObjects.delete(id); },};-- const metrics = __load(48).createMetricsClient(call);++ const metrics = __load(49).createMetricsClient(call);const api = { tasks, creations, choices, run, turn, admin, runs, batches, files, metrics, TERMINAL, CLASSES };// Direct operations: a run of workflow ai.<op> with the input as the body, waited for by AI.for (const op of OPS) {@@@ -6384,7 +6484,7 @@ function createAiClient(client, defaults = {}) {module.exports = { createAiClient, TERMINAL, OPS, CLASSES };},--// ── 48: src/ai-metrics.js ───────────────────────────────────────────++// ── 49: src/ai-metrics.js ───────────────────────────────────────────function (module, exports) {'use strict';// Public measured reads: no bearer token, prompt, person or site identifiers.@@@ -6413,7 +6513,7 @@ function createMetricsClient(call) {}module.exports = { createMetricsClient };},--// ── 49: src/credentials.js ──────────────────────────────────────────++// ── 50: src/credentials.js ──────────────────────────────────────────function (module, exports) {'use strict';@@@ -6431,7 +6531,7 @@ function createCredentialsClient(client, defaults = {}) {module.exports = { createCredentialsClient };},--// ── 50: src/jobs.js ─────────────────────────────────────────────────++// ── 51: src/jobs.js ─────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -6469,7 +6569,7 @@ function (module, exports) {*/const { OpenVibeError, isOpenVibeError } = __load(3);const { newIdempotencyKey } = __load(5);--const { appendFiles } = __load(51);++const { appendFiles } = __load(52);const { parseSSE } = __load(25);const TERMINAL = new Set(['succeeded', 'failed', 'cancelled']);@@@ -6633,7 +6733,7 @@ function createJobsClient(client, { baseUrl, service = 'tools', audience = 'openmodule.exports = { createJobsClient, isTerminal, TERMINAL_STATES: [...TERMINAL] };},--// ── 51: src/core/form.js ────────────────────────────────────────────++// ── 52: src/core/form.js ────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -6667,7 +6767,7 @@ function appendFiles(form, list, where) {module.exports = { isBlob, isUpload, appendFiles };},--// ── 52: src/agents.js ───────────────────────────────────────────────++// ── 53: src/agents.js ───────────────────────────────────────────────function (module, exports) {'use strict';/** Agent run snapshots, AG-UI event streams and approval responses. */@@@ -6750,10 +6850,10 @@ function createAgentsClient(client, { baseUrl, service = 'network', audience = '}module.exports = { createAgentsClient };},--// ── 53: src/frame.js ────────────────────────────────────────────────++// ── 54: src/frame.js ────────────────────────────────────────────────function (module, exports) {'use strict';--const { createAgentsClient } = __load(52);++const { createAgentsClient } = __load(53);/*** openvibe-sdk/frame — the OpenVibe Frame: the navbar, footer and themes every OpenVibe site sits in, for any app: the universal navbar (one@@@ -6973,7 +7073,7 @@ function createFrameClient(client, { baseUrl, networkBaseUrl } = {}) {module.exports = { mountFrame, frameTags, frameConfig, scriptUrls, online, createFrameClient, DEFAULT_BASE };},--// ── 54: src/tools.js ────────────────────────────────────────────────++// ── 55: src/tools.js ────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -7007,8 +7107,8 @@ function (module, exports) {*/const { OpenVibeError, isOpenVibeError } = __load(3);const { newIdempotencyKey } = __load(5);--const { isUpload, appendFiles } = __load(51);--const { createJobsClient } = __load(50);++const { isUpload, appendFiles } = __load(52);++const { createJobsClient } = __load(51);const enc = encodeURIComponent;const ID_RE = /^[a-z][a-z0-9-]{0,39}$/;@@@ -7270,7 +7370,7 @@ function createToolsClient(client, { baseUrl, service = 'tools', audience = 'opemodule.exports = { createToolsClient, ToolRunError, isToolRunError };},--// ── 55: src/projects.js ─────────────────────────────────────────────++// ── 56: src/projects.js ─────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -7386,7 +7486,7 @@ function createProjectsClient(client, { baseUrl } = {}) {module.exports = { createProjectsClient };},--// ── 56: src/geo.js ──────────────────────────────────────────────────++// ── 57: src/geo.js ──────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -7450,7 +7550,7 @@ function createGeoClient(client, { baseUrl, fetch: fetchImpl = null, samples = 3module.exports = { createGeoClient };},--// ── 57: src/history.js ──────────────────────────────────────────────++// ── 58: src/history.js ──────────────────────────────────────────────function (module, exports) {'use strict';@@@ -7478,7 +7578,7 @@ function createHistoryClient(client, { baseUrl } = {}) {module.exports = { createHistoryClient };},--// ── 58: src/user-card.js ────────────────────────────────────────────++// ── 59: src/user-card.js ────────────────────────────────────────────function (module, exports) {'use strict';/** One public Network aggregate. Hidden/unavailable fields stay absent; no credentials are needed. */@@@ -7494,7 +7594,7 @@ function createUserCardClient(client, { baseUrl } = {}) {}module.exports = { createUserCardClient };},--// ── 59: src/player.js ───────────────────────────────────────────────++// ── 60: src/player.js ───────────────────────────────────────────────function (module, exports) {'use strict';/** Browser facade for Shared's portable live player. */@@@ -7510,7 +7610,7 @@ function on(listener) {}module.exports = { current, handoff, on };},--// ── 60: src/agent-sheet.js ──────────────────────────────────────────++// ── 61: src/agent-sheet.js ──────────────────────────────────────────function (module, exports) {'use strict';/** Owner-only agent sheets through Network's fixed cross-site relay. The caller supplies their own Bearer. */@@@ -7558,10 +7658,10 @@ export const {isActingSubjectId, satisfiesRange, compareVersions, CONTRACTS_RANGE, DEFAULT_NETWORK, SDK_VERSION,auth, locker, registry, trust, levels, modules,realtime, media, composer, cam, mediaUpload, ui,-- uiLayout, community, homeFeed, feed, bot, search,-- bench, meme, vision, themes, elements, design,-- redact, chat, ai, credentials, jobs, agents,-- frame, tools, projects, geo, history, userCard,-- player, agentSheet,++ uiLayout, community, homeFeed, feed, views, bot,++ search, bench, meme, vision, themes, elements,++ design, redact, chat, ai, credentials, jobs,++ agents, frame, tools, projects, geo, history,++ userCard, player, agentSheet,} = sdk;export default sdk;@@@ -546,6 +546,16 @@"createVideoClient"]},++ "views": {++ "object": [++ "HOWS",++ "MAX_BATCH",++ "MEDIA_URL",++ "createViewsClient",++ "eventOf",++ "refOf"++ ]++ },"vip": {"object": ["createVipCache",@@@ -1433,6 +1443,14 @@"openvibe-sdk/video": {"createVideoClient": "function"},++ "openvibe-sdk/views": {++ "HOWS": "array",++ "MAX_BATCH": "number",++ "MEDIA_URL": "string",++ "createViewsClient": "function",++ "eventOf": "function",++ "refOf": "function"++ },"openvibe-sdk/vip": {"createVipCache": "function","createVipClient": "function"@@@ -5,18 +5,18 @@ export const {createWalletClient, createClient, OpenVibeError, isOpenVibeError, paginate, offsetPager,parseTraceparent, startSpan, contextFromHeaders, ulid, newEventId, newIdempotencyKey,isActingSubjectId, satisfiesRange, compareVersions, CONTRACTS_RANGE, DEFAULT_NETWORK, SDK_VERSION,-- report, share, locker, auth, registry, identity,-- trust, levels, modules, events, realtime, media,-- composer, cam, mediaUpload, ui, uiLayout, community,-- homeFeed, feed, bot, search, bench, meme,-- vision, themes, elements, design, redact, chat,-- chatApps, ai, credentials, jobs, agents, frame,-- tools, projects, resources, vip, quest, live,-- inventory, tips, blog, reviews, wiki, coupons,-- deals, shoes, trade, space, host, news,-- food, actor, codes, run, video, pics,-- work, zone, git, play, download, openre,-- geo, history, usage, commerce, moneyReasons, telemetry,-- userCard, player, agentSheet,++ report, views, share, locker, auth, registry,++ identity, trust, levels, modules, events, realtime,++ media, composer, cam, mediaUpload, ui, uiLayout,++ community, homeFeed, feed, bot, search, bench,++ meme, vision, themes, elements, design, redact,++ chat, chatApps, ai, credentials, jobs, agents,++ frame, tools, projects, resources, vip, quest,++ live, inventory, tips, blog, reviews, wiki,++ coupons, deals, shoes, trade, space, host,++ news, food, actor, codes, run, video,++ pics, work, zone, git, play, download,++ openre, geo, history, usage, commerce, moneyReasons,++ telemetry, userCard, player, agentSheet,} = cjs;export default cjs;nnew file mode 100644@@@ -0,0 +1,7 @@++// Generated by scripts/esm.js from src/views.js. Do not edit.++import cjs from '../src/views.js';++++export const {++ createViewsClient, refOf, eventOf, MEDIA_URL, MAX_BATCH, HOWS,++} = cjs;++export default cjs;@@@ -10,6 +10,7 @@ module.exports = {createWalletClient: require('./src/wallet').createWalletClient,...core,report: require('./src/report'),++ views: require('./src/views'),share: require('./src/share').share,locker: require('./src/locker'),auth: require('./src/auth'),@@@ -1,12 +1,12 @@{"name": "openvibe-sdk",-- "version": "0.157.0",++ "version": "0.158.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "openvibe-sdk",-- "version": "0.157.0",++ "version": "0.158.0","license": "MIT","bin": {"openvibe-download": "bin/openvibe-download.js"@@@ -1,6 +1,6 @@{"name": "openvibe-sdk",-- "version": "0.157.0",++ "version": "0.158.0","description": "Supported browser and server clients for the OpenVibe platform: auth (incl. developer apps), registry discovery, identity, user modules, events, realtime, media, community, Bot robots, search, chat, AI runs, Tools (registry, run API and jobs), VIP memberships and developer projects, the async PostgreSQL data layer (db) and the Valkey cache, limits store, queue and pub/sub, with deadlines, safe retries, problem errors and trace propagation.","main": "index.js","types": "types/index.d.ts",@@@ -234,6 +234,12 @@"import": "./esm/report.mjs","default": "./src/report.js"},++ "./views": {++ "types": "./types/views.d.ts",++ "browser": "./src/views.js",++ "import": "./esm/views.mjs",++ "default": "./src/views.js"++ },"./delivery": {"types": "./types/delivery.d.ts","browser": null,@@@ -63,6 +63,7 @@ const ENTRIES = {'commerce.mjs': '../src/commerce.js','exchange.mjs': '../src/exchange.js','report.mjs': '../src/report.js',++ 'views.mjs': '../src/views.js','vibes.mjs': '../src/vibes.js','delivery.mjs': '../src/delivery.js','link.mjs': '../src/link.js',@@@ -8,7 +8,7 @@ const { paginate, offsetPager } = require('./paginate');const semver = require('./semver');/** The package version (test/version.test.js keeps it equal to package.json). */--const SDK_VERSION = '0.157.0';++const SDK_VERSION = '0.158.0';module.exports = {createClient,nnew file mode 100644@@@ -0,0 +1,96 @@++'use strict';++++/**++ * openvibe-sdk/views — one view API for every content kind.++ *++ * const views = createViewsClient(client);++ * await views.record({ ref: { service: 'media', kind: 'vod', id: '42' }, how: 'preview', seconds: 2, session });++ * await views.record([ … up to 20 events … ]);++ * const counts = await views.counts({ service: 'media', kind: 'vod', id: '42' });++ * // → { ref, counts: { views, engaged, previews, preview_share, peak_concurrent } }++ *++ * OpenVibe.Media owns the numbers for every kind (a Media VOD or clip, a Live recording or stream, a Feed item):++ * POST /api/v1/views is public and CORS *, dedupes one view per person or anonymous session per item per 30 minutes,++ * counts a preview from 1 second and engagement at 30 seconds or a third of the length (60 seconds of a live stream),++ * and never stores an IP address or a user agent. `seconds` is cumulative for the session and item: a retry sends the++ * same number, playback sends a larger one, and neither counts the item twice.++ *++ * A signed-in viewer sends their Network token on the client and no session; a signed-out viewer keeps an opaque++ * `session` id of their own. The write is not retried for you: a retry is safe (same session, same item), but this++ * client leaves the decision to the caller, like the other beacon-shaped writes.++ */++const MEDIA_URL = 'https://openvibe.media';++const MAX_BATCH = 20;++const HOWS = ['preview', 'watch', 'live'];++const SERVICE_RE = /^[a-z][a-z0-9-]{1,39}$/;++const KIND_RE = /^[a-z][a-z0-9_]{1,39}$/;++const SESSION_RE = /^[A-Za-z0-9._~-]{8,128}$/;++++function refOf(ref) {++ if (!ref || typeof ref !== 'object' || Array.isArray(ref)) throw new TypeError('views: ref must be { service, kind, id }');++ const service = String(ref.service || '');++ const kind = String(ref.kind || '');++ const id = ref.id == null ? '' : String(ref.id);++ if (!SERVICE_RE.test(service)) throw new TypeError('views: ref.service is a service id (media, live, network…)');++ if (!KIND_RE.test(kind)) throw new TypeError('views: ref.kind is an item type (vod, clip, recording, stream…)');++ if (!id || id.length > 200) throw new TypeError('views: ref.id is 1–200 characters');++ const out = { service, kind, id };++ if (ref.site != null) {++ if (!/^[a-z][a-z0-9-]{0,39}$/.test(String(ref.site))) throw new TypeError('views: ref.site is a site id');++ out.site = String(ref.site);++ }++ if (ref.creator != null) {++ if (String(ref.creator).length > 200) throw new TypeError('views: ref.creator is at most 200 characters');++ out.creator = String(ref.creator);++ }++ return out;++}++++function eventOf(event) {++ if (!event || typeof event !== 'object' || Array.isArray(event)) throw new TypeError('views.record: each event is an object');++ const how = String(event.how || '');++ if (!HOWS.includes(how)) throw new TypeError(`views.record: how is ${HOWS.join(', ')}`);++ const seconds = Number(event.seconds);++ if (!Number.isFinite(seconds) || seconds < 0 || seconds > 86400) throw new TypeError('views.record: seconds is 0–86400');++ const out = { ref: refOf(event.ref), how, seconds };++ if (event.of_seconds != null) {++ const of = Number(event.of_seconds);++ if (!Number.isFinite(of) || of <= 0 || of > 86400) throw new TypeError('views.record: of_seconds is 1–86400');++ out.of_seconds = of;++ }++ if (event.session != null) {++ if (!SESSION_RE.test(String(event.session))) throw new TypeError('views.record: session is 8–128 letters, digits, . _ ~ or -');++ out.session = String(event.session);++ }++ return out;++}++++function createViewsClient(client, { baseUrl = MEDIA_URL } = {}) {++ if (!client || typeof client.json !== 'function') throw new TypeError('createViewsClient: pass an openvibe-sdk/core client');++ const base = String(baseUrl || MEDIA_URL).replace(/\/+$/, '');++ return {++ /**++ * Record one event or up to 20 at once. → { results: [{ accepted, counted, engaged, reason? }], counts? }++ * `session` is required by the service for a signed-out viewer; a signed-in viewer sends their token instead.++ */++ record(events, { signal } = {}) {++ const list = Array.isArray(events) ? events : [events];++ if (!list.length) throw new TypeError('views.record: send at least one event');++ if (list.length > MAX_BATCH) throw new TypeError(`views.record: at most ${MAX_BATCH} events in one call`);++ return client.json({++ baseUrl: base, path: '/api/v1/views', method: 'POST',++ json: { events: list.map(eventOf) }, signal, service: 'media',++ });++ },++ /** One item's numbers: views, engaged viewers, preview views, the feed-preview share and live peak concurrent. */++ counts(ref, { signal } = {}) {++ const r = refOf(ref);++ return client.json({++ baseUrl: base, path: '/api/v1/views/counts',++ query: { service: r.service, kind: r.kind, id: r.id }, signal, service: 'media',++ });++ },++ };++}++++module.exports = { createViewsClient, refOf, eventOf, MEDIA_URL, MAX_BATCH, HOWS };@@@ -72,7 +72,7 @@ run([})().catch((err) => { console.error(err); process.exit(1); });`;const res = execFileSync(process.execPath, ['-e', script], { cwd: app, encoding: 'utf8' });assert.match(res, new RegExp(`consumer ok: ${subpaths.length} subpaths \\+ the browser bundle`));-- assert.equal(subpaths.length, 111); // 0.152.0 train: elements (#227) and ui-layout (#226) add the 110th and 111th; // composer, feed and agents add the 104th-106th after user-card; the 0.148.0 train's codes, player and the rest bring 109; elements brings 110.++ assert.equal(subpaths.length, 112); // 0.152.0 train: elements (#227) and ui-layout (#226) add the 110th and 111th; // composer, feed and agents add the 104th-106th after user-card; the 0.148.0 train's codes, player and the rest bring 109; elements brings 110.assert.ok(!fs.existsSync(path.join(app, 'node_modules/openvibe-contracts')), 'the optional peer is not installed');} finally {fs.rmSync(tmp, { recursive: true, force: true });nnew file mode 100644@@@ -0,0 +1,31 @@++'use strict';++const assert = require('assert');++const { createViewsClient, eventOf, refOf } = require('../src/views');++++(async () => {++ const calls = [];++ const client = { json: async (input) => { calls.push(input); return { results: [{ accepted: true, counted: true, engaged: false }] }; } };++ const views = createViewsClient(client, { baseUrl: 'https://media.test/' });++++ await views.record({ ref: { service: 'media', kind: 'vod', id: 42 }, how: 'preview', seconds: 2, session: 'anon_9f2c1e7a4b' });++ assert.deepStrictEqual(calls[0], {++ baseUrl: 'https://media.test', path: '/api/v1/views', method: 'POST', service: 'media', signal: undefined,++ json: { events: [{ ref: { service: 'media', kind: 'vod', id: '42' }, how: 'preview', seconds: 2, session: 'anon_9f2c1e7a4b' }] },++ });++++ await views.record([++ { ref: { service: 'live', kind: 'stream', id: '7', site: 'network', creator: 'maticus' }, how: 'live', seconds: 61 },++ { ref: { service: 'media', kind: 'clip', id: '3' }, how: 'watch', seconds: 30, of_seconds: 90 },++ ]);++ assert.strictEqual(calls[1].json.events.length, 2);++ assert.strictEqual(calls[1].json.events[0].ref.site, 'network');++++ await views.counts({ service: 'media', kind: 'vod', id: 42 });++ assert.deepStrictEqual(calls[2].query, { service: 'media', kind: 'vod', id: '42' });++++ assert.throws(() => views.record(Array.from({ length: 21 }, () => ({ ref: { service: 'media', kind: 'clip', id: '1' }, how: 'preview', seconds: 2 }))), /at most 20/);++ assert.throws(() => eventOf({ ref: { service: 'media', kind: 'clip', id: '1' }, how: 'scroll', seconds: 2 }), /how is/);++ assert.throws(() => refOf({ service: 'Media', kind: 'clip', id: '1' }), /service is a service id/);++ assert.throws(() => eventOf({ ref: { service: 'media', kind: 'clip', id: '1' }, how: 'watch', seconds: 1, session: 'short' }), /session is/);++ console.log('views: record batches and counts a ref with the documented shapes');++})().catch((error) => { console.error(error); process.exitCode = 1; });@@@ -15,6 +15,7 @@ import * as uiLayout from './ui-layout';import * as community from './community';import * as homeFeed from './home-feed';import * as feed from './feed';++import * as views from './views';import * as bot from './bot';import * as search from './search';import * as bench from './bench';@@@ -55,6 +56,7 @@ export * as uiLayout from './ui-layout';export * as community from './community';export * as homeFeed from './home-feed';export * as feed from './feed';++export * as views from './views';export * as bot from './bot';export * as search from './search';export * as bench from './bench';@@@ -86,6 +88,6 @@ declare const sdk: typeof core & {userCard: typeof userCard;player: typeof player;auth: typeof auth; registry: typeof registry; modules: typeof modules; realtime: typeof realtime;-- media: typeof media; composer: typeof composer; cam: typeof cam; mediaUpload: typeof mediaUpload; ui: typeof ui; uiLayout: typeof uiLayout; community: typeof community; homeFeed: typeof homeFeed; feed: typeof feed; bot: typeof bot; search: typeof search; bench: typeof bench; meme: typeof meme; vision: typeof vision; themes: typeof themes; design: typeof design; redact: typeof redact; chat: typeof chat; ai: typeof ai; credentials: typeof credentials; jobs: typeof jobs; agents: typeof agents; tools: typeof tools; projects: typeof projects; geo: typeof geo; history: typeof history; locker: typeof locker; trust: typeof trust; levels: typeof levels;++ media: typeof media; composer: typeof composer; cam: typeof cam; mediaUpload: typeof mediaUpload; ui: typeof ui; uiLayout: typeof uiLayout; community: typeof community; homeFeed: typeof homeFeed; feed: typeof feed; views: typeof views; bot: typeof bot; search: typeof search; bench: typeof bench; meme: typeof meme; vision: typeof vision; themes: typeof themes; design: typeof design; redact: typeof redact; chat: typeof chat; ai: typeof ai; credentials: typeof credentials; jobs: typeof jobs; agents: typeof agents; tools: typeof tools; projects: typeof projects; geo: typeof geo; history: typeof history; locker: typeof locker; trust: typeof trust; levels: typeof levels;};export default sdk;@@@ -2,6 +2,7 @@ export * from './core';export * as auth from './auth';export * as design from './design';export * as report from './report';++export * as views from './views';export * as report from './report';export * as registry from './registry';export * as identity from './identity';nnew file mode 100644@@@ -0,0 +1,57 @@++import type { OpenVibeClient } from './core';++++export interface ViewRef {++ service: string;++ kind: string;++ id: string;++ /** The site the view happened on, when it differs from the owning service (the Feed counts a clip on network). */++ site?: string;++ /** The creator's canonical subject or channel username, for Report's per-creator numbers. */++ creator?: string;++}++++export interface ViewEvent {++ ref: ViewRef;++ /** preview: a silent preview in the feed; watch: a watch page; live: a live stream being watched now. */++ how: 'preview' | 'watch' | 'live';++ /** Cumulative seconds watched in this session for this item. A retry sends the same number. */++ seconds: number;++ /** The item's length when known: engaged comes at min(30, of_seconds / 3) for a watch. */++ of_seconds?: number;++ /** The anonymous session id a signed-out viewer keeps (8–128 characters); a signed-in viewer sends a token instead. */++ session?: string;++}++++export interface ViewResult {++ accepted: boolean;++ counted: boolean;++ engaged: boolean;++ reason?: string;++}++++export interface ViewCounts {++ views: number;++ engaged: number;++ previews: number;++ /** Preview views divided by all views, 0–1; null before the item has a view. */++ preview_share: number | null;++ /** The most live watchers seen at once (how = live); null when it was never watched live. */++ peak_concurrent: number | null;++}++++export interface ViewsClient {++ /** Record one event or up to 20 at once (a signed-in viewer's token, or an anonymous session id). */++ record(events: ViewEvent | ViewEvent[], options?: { signal?: AbortSignal }): Promise<{ results: ViewResult[]; counts?: ViewCounts }>;++ /** One item's numbers. */++ counts(ref: ViewRef, options?: { signal?: AbortSignal }): Promise<{ ref: ViewRef; counts: ViewCounts }>;++}++++export function createViewsClient(client: OpenVibeClient, options?: { baseUrl?: string }): ViewsClient;++export const MEDIA_URL: string;++export const MAX_BATCH: number;++export const HOWS: Array<'preview' | 'watch' | 'live'>;++++/** Validate and normalize one ref (throws a TypeError on a bad service, kind or id). */++export function refOf(ref: ViewRef): ViewRef;++/** Validate and normalize one event (throws a TypeError on a bad how, seconds or session). */++export function eventOf(event: ViewEvent): ViewEvent;
@@ -1,5 +1,17 @@
@@ -1,5 +1,17 @@
# Changelog
# Changelog
+## 0.158.0 — 2026-11-12
+
+- **`openvibe-sdk/views`: one view API for every content kind** (Contracts `media.view-request@1`, the `media.viewed`
+ and `media.engaged` events).
+ - `createViewsClient(client).record(event | [events])` posts a preview, watch or live heartbeat for
+ `ref: { service, kind, id }` to Media's `POST /api/v1/views`, up to 20 at once. `seconds` is cumulative for the
+ session and item, so a retry does not count twice; a signed-out viewer keeps an opaque session id.
+ - `.counts(ref)` reads one item's `{ views, engaged, previews, preview_share, peak_concurrent }` from
+ `GET /api/v1/views/counts`. Media never stores an IP address or a user agent with a view, and a preview counts
+ from 1 second.
+
+
## 0.157.0 — 2026-11-12
## 0.157.0 — 2026-11-12
See it work: a run's desks, control and replay
See it work: a run's desks, control and replay
@@ -8,6 +20,7 @@ See it work: a run's desks, control and replay
@@ -8,6 +20,7 @@ See it work: a run's desks, control and replay
`handBack(run, desk, note)` and `replay(run)` → the steps with the still each saw. They call the same-named routes
`handBack(run, desk, note)` and `replay(run)` → the steps with the still each saw. They call the same-named routes
under the client's service (`/api/v1/runs/:id/desks/...`), so a page and a script make the same calls. No tag: the
under the client's service (`/api/v1/runs/:id/desks/...`), so a page and a script make the same calls. No tag: the
main session releases this after the sites' stage lands.
main session releases this after the sites' stage lands.
+
## 0.156.0 — 2026-11-12
## 0.156.0 — 2026-11-12
- **`openvibe-sdk/exchange`: reviewed compute prices, keyless.**
- **`openvibe-sdk/exchange`: reviewed compute prices, keyless.**
@@ -8,12 +8,12 @@
@@ -8,12 +8,12 @@
**Install and test:** `npm ci && npm test` (Node 20 or newer)
**Install and test:** `npm ci && npm test` (Node 20 or newer)
```bash
```bash
-npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.157.0
+npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.158.0
```
```
> Supported browser and server clients for the OpenVibe platform.
> Supported browser and server clients for the OpenVibe platform.
-**Status:** alpha, v0.157.0 (the five 1.0 core entries — `core`, `auth`, `events`, `db` and `media` — are frozen: their exported names change only with a major release; roadmap Wave 2; developer apps from Wave 20; Media objects v2 from Wave 4; the Tools platform API; Search, Chat, AI, Vision and consent clients; sign-in with recovery and a client health check). Every release is tagged (see [CHANGELOG.md](CHANGELOG.md)). Tested against local stub servers and the built-in mock platform only, never against the live platform. Services pin release tags; each repository's `STATUS.json` names the one it uses.
+**Status:** alpha, v0.158.0 (the five 1.0 core entries — `core`, `auth`, `events`, `db` and `media` — are frozen: their exported names change only with a major release; roadmap Wave 2; developer apps from Wave 20; Media objects v2 from Wave 4; the Tools platform API; Search, Chat, AI, Vision and consent clients; sign-in with recovery and a client health check). Every release is tagged (see [CHANGELOG.md](CHANGELOG.md)). Tested against local stub servers and the built-in mock platform only, never against the live platform. Services pin release tags; each repository's `STATUS.json` names the one it uses.
**Plan:** OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), §3.2; roadmap §30.
**Plan:** OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), §3.2; roadmap §30.
**License:** MIT ([LICENSE](LICENSE)). This package is a library that apps outside the network embed, so it uses MIT. The OpenVibe services themselves stay AGPL-3.0.
**License:** MIT ([LICENSE](LICENSE)). This package is a library that apps outside the network embed, so it uses MIT. The OpenVibe services themselves stay AGPL-3.0.
@@ -22,7 +22,7 @@ npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags
@@ -22,7 +22,7 @@ npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags
After v0.97.1 is tagged:
After v0.97.1 is tagged:
```bash
```bash
-npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.157.0
+npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.158.0
```
```
It has no runtime dependencies. It needs Node ≥ 20, or any browser with `fetch`, Web Crypto and `TextDecoder`. There is no build step. The package is CommonJS with ESM entry points (`import` works). Each subpath has its own `.d.ts`. For a page with no bundler, `browser/openvibe-sdk.mjs` is one self-contained ES module of the browser-safe subpaths (see [Browser without a bundler](#browser-without-a-bundler)). It does not depend on `openvibe-contracts` at runtime: it copies the contract types it uses (from the temporary Contracts sharing branch, a devDependency the tests check them against).
It has no runtime dependencies. It needs Node ≥ 20, or any browser with `fetch`, Web Crypto and `TextDecoder`. There is no build step. The package is CommonJS with ESM entry points (`import` works). Each subpath has its own `.d.ts`. For a page with no bundler, `browser/openvibe-sdk.mjs` is one self-contained ES module of the browser-safe subpaths (see [Browser without a bundler](#browser-without-a-bundler)). It does not depend on `openvibe-contracts` at runtime: it copies the contract types it uses (from the temporary Contracts sharing branch, a devDependency the tests check them against).
@@ -208,6 +208,7 @@ Until OpenVibe.Tools serves the gateway facade (Tools S6), point the jobs client
@@ -208,6 +208,7 @@ Until OpenVibe.Tools serves the gateway facade (Tools S6), point the jobs client
| `openvibe-sdk/history` | both | Private history reads: cursor pages, title search, day/week summaries, recent agent reads, settings and owner-scoped deletes. |
| `openvibe-sdk/history` | both | Private history reads: cursor pages, title search, day/week summaries, recent agent reads, settings and owner-scoped deletes. |
| `openvibe-sdk/home-feed` | both | `createHomeFeedClient(client)` gives `ov.home.get()/set(layout)`, `ov.network.today()`, `ov.feed.list({ for: 'me', cursor })`, `ov.feed.post(text)`, and `ov.feed.contribute({ id, text, url })`. Personal calls need a user Bearer token; contribution needs an app token granted `community.pulse.contribute`. Today is public and cached by Network for five minutes. |
| `openvibe-sdk/home-feed` | both | `createHomeFeedClient(client)` gives `ov.home.get()/set(layout)`, `ov.network.today()`, `ov.feed.list({ for: 'me', cursor })`, `ov.feed.post(text)`, and `ov.feed.contribute({ id, text, url })`. Personal calls need a user Bearer token; contribution needs an app token granted `community.pulse.contribute`. Today is public and cached by Network for five minutes. |
| `openvibe-sdk/feed` | both | `createFeedClient(client)` gives `ov.feed.list({ kind, cursor })` for the public cross-site Community Feed. Pass the returned `next_cursor` as `cursor` to read the next page. |
| `openvibe-sdk/feed` | both | `createFeedClient(client)` gives `ov.feed.list({ kind, cursor })` for the public cross-site Community Feed. Pass the returned `next_cursor` as `cursor` to read the next page. |
+| `openvibe-sdk/views` | both | `createViewsClient(client)`: `record(event \| [events])` (up to 20 per call) sends a preview, watch or live heartbeat for `{ service, kind, id }` to `POST /api/v1/views`; `counts(ref)` reads `{ views, engaged, previews, preview_share, peak_concurrent }`. A signed-out viewer keeps an opaque session id; the service stores no IP or user agent and counts a preview from 1 s. |
| `openvibe-sdk/bot` | both | `createBotClient(client, {actingSubject?})`: OpenVibe.Bot robots. `robots.list/get/create/update/delete/pairingCode`, `robots.operators.list/add/remove`, `robots.devices`, `robots.streaming.get/set`, `robots.audit`/`iterateAudit`, `robots.estop`/`clearEstop`, `robots.command` (`bot.command@1`), `embedUrl(robotId, mode)` (panel, overlay or compact), `devices.rotate/revoke`, public `profiles.list/get` and `kits.list/get`, `pair` (the agent's one-time code, never retried), `as(subject)`; a service acts for a person with `X-OV-Subject` (capabilities `bot.robot.read`/`manage`/`control`, `bot.device.connect`) |
| `openvibe-sdk/bot` | both | `createBotClient(client, {actingSubject?})`: OpenVibe.Bot robots. `robots.list/get/create/update/delete/pairingCode`, `robots.operators.list/add/remove`, `robots.devices`, `robots.streaming.get/set`, `robots.audit`/`iterateAudit`, `robots.estop`/`clearEstop`, `robots.command` (`bot.command@1`), `embedUrl(robotId, mode)` (panel, overlay or compact), `devices.rotate/revoke`, public `profiles.list/get` and `kits.list/get`, `pair` (the agent's one-time code, never retried), `as(subject)`; a service acts for a person with `X-OV-Subject` (capabilities `bot.robot.read`/`manage`/`control`, `bot.device.connect`) |
| `openvibe-sdk/themes` | both | `createThemesClient(client)`: `catalog({mode, search, sort, limit})` (seasonal themes carry `season`), `get(idOrSlug)` (null when missing), `export(idOrSlug)`, `active()` (`{theme_id, custom_variables, display}`), `set(themeId, {custom})`, `setDisplay({motion, text, seasonal})`, `seasons({date})`, `submissions()`, `submit(theme)`, `import(file)`. In the browser: `followTheme(fn)` calls back now and on every theme, display or season change with `readTheme()` (`{id, mode, tokens, display: {motion, text, textScale, seasonal, calm}, season, seasonMark}`) and returns `stop()`, for a canvas or game to keep up; `applyTheme(vars, {root})`, `seasonOn(date, seasons)`, `onColor(hex)`, `DISPLAY_OPTIONS`, `TOKENS` |
| `openvibe-sdk/themes` | both | `createThemesClient(client)`: `catalog({mode, search, sort, limit})` (seasonal themes carry `season`), `get(idOrSlug)` (null when missing), `export(idOrSlug)`, `active()` (`{theme_id, custom_variables, display}`), `set(themeId, {custom})`, `setDisplay({motion, text, seasonal})`, `seasons({date})`, `submissions()`, `submit(theme)`, `import(file)`. In the browser: `followTheme(fn)` calls back now and on every theme, display or season change with `readTheme()` (`{id, mode, tokens, display: {motion, text, textScale, seasonal, calm}, season, seasonMark}`) and returns `stop()`, for a canvas or game to keep up; `applyTheme(vars, {root})`, `seasonOn(date, seasons)`, `onColor(hex)`, `DISPLAY_OPTIONS`, `TOKENS` |
| `openvibe-sdk/bench` | both | `createBenchClient(client, {actingSubject?})`: `kinds.list/get`, `tasks.create/get`, `rounds.create/get`, `entries.submit`, `judgements.next/cast`, `boards.get`, `ratings.get` (public, at least twenty games), `models.get`, `datasets.get/iterate`, `evals.create/get/run/results`, `mcpTools()`. Audience `openvibe.bench`; service id `bench`. |
| `openvibe-sdk/bench` | both | `createBenchClient(client, {actingSubject?})`: `kinds.list/get`, `tasks.create/get`, `rounds.create/get`, `entries.submit`, `judgements.next/cast`, `boards.get`, `ratings.get` (public, at least twenty games), `models.get`, `datasets.get/iterate`, `evals.create/get/run/results`, `mcpTools()`. Audience `openvibe.bench`; service id `bench`. |
@@ -3,7 +3,7 @@
@@ -3,7 +3,7 @@
"stage": "alpha",
"stage": "alpha",
"code": true,
"code": true,
"wave": "W2",
"wave": "W2",
- "version": "0.157.0",
+ "version": "0.158.0",
"plan": "OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), \u00a73.2; roadmap \u00a730",
"plan": "OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), \u00a73.2; roadmap \u00a730",
"deployed": false,
"deployed": false,
"deployment": "none: a package released as git tags; services and apps pin a tag",
"deployment": "none: a package released as git tags; services and apps pin a tag",
@@ -24,6 +24,7 @@ module.exports = {
@@ -24,6 +24,7 @@ module.exports = {
community: require('./src/community'),
community: require('./src/community'),
homeFeed: require('./src/home-feed'),
homeFeed: require('./src/home-feed'),
feed: require('./src/feed'),
feed: require('./src/feed'),
+ views: require('./src/views'),
bot: require('./src/bot'),
bot: require('./src/bot'),
search: require('./src/search'),
search: require('./src/search'),
bench: require('./src/bench'),
bench: require('./src/bench'),
@@ -1,6 +1,6 @@
@@ -1,6 +1,6 @@
-// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.157.0, MIT). Do not edit.
+// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.158.0, MIT). Do not edit.
// One self-contained ES module: core at the top level plus the browser-safe subpaths as namespaces
// One self-contained ES module: core at the top level plus the browser-safe subpaths as namespaces
-// (auth, locker, registry, trust, levels, modules, realtime, media, composer, cam, mediaUpload, ui, uiLayout, community, homeFeed, feed, bot, search, bench, meme, vision, themes, elements, design, redact, chat, ai, credentials, jobs, agents, frame, tools, projects, geo, history, userCard, player, agentSheet). No server-only code: no service tokens, JWT verification, events, identity.
+// (auth, locker, registry, trust, levels, modules, realtime, media, composer, cam, mediaUpload, ui, uiLayout, community, homeFeed, feed, views, bot, search, bench, meme, vision, themes, elements, design, redact, chat, ai, credentials, jobs, agents, frame, tools, projects, geo, history, userCard, player, agentSheet). No server-only code: no service tokens, JWT verification, events, identity.
/* eslint-disable */
/* eslint-disable */
const __defs = [
const __defs = [
// ── 0: browser.js ──────────────────────────────────────────────────
// ── 0: browser.js ──────────────────────────────────────────────────
@@ -31,28 +31,29 @@ module.exports = {
@@ -31,28 +31,29 @@ module.exports = {
community: __load(33),
community: __load(33),
homeFeed: __load(34),
homeFeed: __load(34),
feed: __load(35),
feed: __load(35),
- bot: __load(36),
- search: __load(37),
- bench: __load(38),
- meme: __load(39),
- vision: __load(40),
- themes: __load(41),
- elements: __load(42),
- design: __load(43),
- redact: __load(44),
- chat: __load(45),
- ai: __load(47),
- credentials: __load(49),
- jobs: __load(50),
- agents: __load(52),
- frame: __load(53),
- tools: __load(54),
- projects: __load(55),
- geo: __load(56),
- history: __load(57),
- userCard: __load(58),
- player: __load(59),
- agentSheet: __load(60),
+ views: __load(36),
+ bot: __load(37),
+ search: __load(38),
+ bench: __load(39),
+ meme: __load(40),
+ vision: __load(41),
+ themes: __load(42),
+ elements: __load(43),
+ design: __load(44),
+ redact: __load(45),
+ chat: __load(46),
+ ai: __load(48),
+ credentials: __load(50),
+ jobs: __load(51),
+ agents: __load(53),
+ frame: __load(54),
+ tools: __load(55),
+ projects: __load(56),
+ geo: __load(57),
+ history: __load(58),
+ userCard: __load(59),
+ player: __load(60),
+ agentSheet: __load(61),
};
};
},
},
// ── 1: src/core/index.js ───────────────────────────────────────────
// ── 1: src/core/index.js ───────────────────────────────────────────
@@ -67,7 +68,7 @@ const { paginate, offsetPager } = __load(7);
@@ -67,7 +68,7 @@ const { paginate, offsetPager } = __load(7);
const semver = __load(6);
const semver = __load(6);
/** The package version (test/version.test.js keeps it equal to package.json). */
/** The package version (test/version.test.js keeps it equal to package.json). */
-const SDK_VERSION = '0.157.0';
+const SDK_VERSION = '0.158.0';
module.exports = {
module.exports = {
createClient,
createClient,
@@ -4154,7 +4155,106 @@ function createFeedClient(client, { communityBaseUrl } = {}) {
@@ -4154,7 +4155,106 @@ function createFeedClient(client, { communityBaseUrl } = {}) {
module.exports = { createFeedClient };
module.exports = { createFeedClient };
},
},
-// ── 36: src/bot.js ──────────────────────────────────────────────────
+// ── 36: src/views.js ────────────────────────────────────────────────
+function (module, exports) {
+'use strict';
+
+/**
+ * openvibe-sdk/views — one view API for every content kind.
+ *
+ * const views = createViewsClient(client);
+ * await views.record({ ref: { service: 'media', kind: 'vod', id: '42' }, how: 'preview', seconds: 2, session });
+ * await views.record([ … up to 20 events … ]);
+ * const counts = await views.counts({ service: 'media', kind: 'vod', id: '42' });
+ * // → { ref, counts: { views, engaged, previews, preview_share, peak_concurrent } }
+ *
+ * OpenVibe.Media owns the numbers for every kind (a Media VOD or clip, a Live recording or stream, a Feed item):
+ * POST /api/v1/views is public and CORS *, dedupes one view per person or anonymous session per item per 30 minutes,
+ * counts a preview from 1 second and engagement at 30 seconds or a third of the length (60 seconds of a live stream),
+ * and never stores an IP address or a user agent. `seconds` is cumulative for the session and item: a retry sends the
+ * same number, playback sends a larger one, and neither counts the item twice.
+ *
+ * A signed-in viewer sends their Network token on the client and no session; a signed-out viewer keeps an opaque
+ * `session` id of their own. The write is not retried for you: a retry is safe (same session, same item), but this
+ * client leaves the decision to the caller, like the other beacon-shaped writes.
+ */
+const MEDIA_URL = 'https://openvibe.media';
+const MAX_BATCH = 20;
+const HOWS = ['preview', 'watch', 'live'];
+const SERVICE_RE = /^[a-z][a-z0-9-]{1,39}$/;
+const KIND_RE = /^[a-z][a-z0-9_]{1,39}$/;
+const SESSION_RE = /^[A-Za-z0-9._~-]{8,128}$/;
+
+function refOf(ref) {
+ if (!ref || typeof ref !== 'object' || Array.isArray(ref)) throw new TypeError('views: ref must be { service, kind, id }');
+ const service = String(ref.service || '');
+ const kind = String(ref.kind || '');
+ const id = ref.id == null ? '' : String(ref.id);
+ if (!SERVICE_RE.test(service)) throw new TypeError('views: ref.service is a service id (media, live, network…)');
+ if (!KIND_RE.test(kind)) throw new TypeError('views: ref.kind is an item type (vod, clip, recording, stream…)');
+ if (!id || id.length > 200) throw new TypeError('views: ref.id is 1–200 characters');
+ const out = { service, kind, id };
+ if (ref.site != null) {
+ if (!/^[a-z][a-z0-9-]{0,39}$/.test(String(ref.site))) throw new TypeError('views: ref.site is a site id');
+ out.site = String(ref.site);
+ }
+ if (ref.creator != null) {
+ if (String(ref.creator).length > 200) throw new TypeError('views: ref.creator is at most 200 characters');
+ out.creator = String(ref.creator);
+ }
+ return out;
+}
+
+function eventOf(event) {
+ if (!event || typeof event !== 'object' || Array.isArray(event)) throw new TypeError('views.record: each event is an object');
+ const how = String(event.how || '');
+ if (!HOWS.includes(how)) throw new TypeError(`views.record: how is ${HOWS.join(', ')}`);
+ const seconds = Number(event.seconds);
+ if (!Number.isFinite(seconds) || seconds < 0 || seconds > 86400) throw new TypeError('views.record: seconds is 0–86400');
+ const out = { ref: refOf(event.ref), how, seconds };
+ if (event.of_seconds != null) {
+ const of = Number(event.of_seconds);
+ if (!Number.isFinite(of) || of <= 0 || of > 86400) throw new TypeError('views.record: of_seconds is 1–86400');
+ out.of_seconds = of;
+ }
+ if (event.session != null) {
+ if (!SESSION_RE.test(String(event.session))) throw new TypeError('views.record: session is 8–128 letters, digits, . _ ~ or -');
+ out.session = String(event.session);
+ }
+ return out;
+}
+
+function createViewsClient(client, { baseUrl = MEDIA_URL } = {}) {
+ if (!client || typeof client.json !== 'function') throw new TypeError('createViewsClient: pass an openvibe-sdk/core client');
+ const base = String(baseUrl || MEDIA_URL).replace(/\/+$/, '');
+ return {
+ /**
+ * Record one event or up to 20 at once. → { results: [{ accepted, counted, engaged, reason? }], counts? }
+ * `session` is required by the service for a signed-out viewer; a signed-in viewer sends their token instead.
+ */
+ record(events, { signal } = {}) {
+ const list = Array.isArray(events) ? events : [events];
+ if (!list.length) throw new TypeError('views.record: send at least one event');
+ if (list.length > MAX_BATCH) throw new TypeError(`views.record: at most ${MAX_BATCH} events in one call`);
+ return client.json({
+ baseUrl: base, path: '/api/v1/views', method: 'POST',
+ json: { events: list.map(eventOf) }, signal, service: 'media',
+ });
+ },
+ /** One item's numbers: views, engaged viewers, preview views, the feed-preview share and live peak concurrent. */
+ counts(ref, { signal } = {}) {
+ const r = refOf(ref);
+ return client.json({
+ baseUrl: base, path: '/api/v1/views/counts',
+ query: { service: r.service, kind: r.kind, id: r.id }, signal, service: 'media',
+ });
+ },
+ };
+}
+
+module.exports = { createViewsClient, refOf, eventOf, MEDIA_URL, MAX_BATCH, HOWS };
+},
+// ── 37: src/bot.js ──────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -4395,7 +4495,7 @@ function createBotClient(client, defaults = {}) {
@@ -4395,7 +4495,7 @@ function createBotClient(client, defaults = {}) {
module.exports = { createBotClient, actingHeaders };
module.exports = { createBotClient, actingHeaders };
},
},
-// ── 37: src/search.js ───────────────────────────────────────────────
+// ── 38: src/search.js ───────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -4541,7 +4641,7 @@ function createSearchClient(client, defaults = {}) {
@@ -4541,7 +4641,7 @@ function createSearchClient(client, defaults = {}) {
module.exports = { createSearchClient, queryOf, fabricOf, codeOf };
module.exports = { createSearchClient, queryOf, fabricOf, codeOf };
},
},
-// ── 38: src/bench.js ────────────────────────────────────────────────
+// ── 39: src/bench.js ────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/** openvibe-sdk/bench: OpenVibe.Bench's JSON API and streamed open dataset. Browser-safe. */
/** openvibe-sdk/bench: OpenVibe.Bench's JSON API and streamed open dataset. Browser-safe. */
@@ -4649,7 +4749,7 @@ function createBenchClient(client, defaults = {}) {
@@ -4649,7 +4749,7 @@ function createBenchClient(client, defaults = {}) {
module.exports = { createBenchClient };
module.exports = { createBenchClient };
},
},
-// ── 39: src/meme.js ─────────────────────────────────────────────────
+// ── 40: src/meme.js ─────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -4732,7 +4832,7 @@ function createMemeClient(client, defaults = {}) {
@@ -4732,7 +4832,7 @@ function createMemeClient(client, defaults = {}) {
module.exports = { createMemeClient };
module.exports = { createMemeClient };
},
},
-// ── 40: src/vision.js ───────────────────────────────────────────────
+// ── 41: src/vision.js ───────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -4890,7 +4990,7 @@ function pick(o, keys) {
@@ -4890,7 +4990,7 @@ function pick(o, keys) {
module.exports = { createVisionClient, DEFAULT_AUDIENCE };
module.exports = { createVisionClient, DEFAULT_AUDIENCE };
},
},
-// ── 41: src/themes.js ───────────────────────────────────────────────
+// ── 42: src/themes.js ───────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -5040,7 +5140,7 @@ function followTheme(fn, opts = {}) {
@@ -5040,7 +5140,7 @@ function followTheme(fn, opts = {}) {
module.exports = { createThemesClient, followTheme, readTheme, applyTheme, seasonOn, onColor, DISPLAY_OPTIONS, TOKENS };
module.exports = { createThemesClient, followTheme, readTheme, applyTheme, seasonOn, onColor, DISPLAY_OPTIONS, TOKENS };
},
},
-// ── 42: src/elements.js ─────────────────────────────────────────────
+// ── 43: src/elements.js ─────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -5468,7 +5568,7 @@ module.exports = {
@@ -5468,7 +5568,7 @@ module.exports = {
PRODUCTS, ACTION_KINDS, ACTION_SET, TRIGGER_KINDS, TRIGGER_SET, ROBOT_ACTIONS, ROLES, ROLE_RANK,
PRODUCTS, ACTION_KINDS, ACTION_SET, TRIGGER_KINDS, TRIGGER_SET, ROBOT_ACTIONS, ROLES, ROLE_RANK,
};
};
},
},
-// ── 43: src/design.js ───────────────────────────────────────────────
+// ── 44: src/design.js ───────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
@@ -5543,7 +5643,7 @@ function createDesignClient({ accessToken = null, baseUrl = DEFAULT_DESIGN_URL,
@@ -5543,7 +5643,7 @@ function createDesignClient({ accessToken = null, baseUrl = DEFAULT_DESIGN_URL,
module.exports = { createDesignClient, DEFAULT_DESIGN_URL };
module.exports = { createDesignClient, DEFAULT_DESIGN_URL };
},
},
-// ── 44: src/redact.js ───────────────────────────────────────────────
+// ── 45: src/redact.js ───────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -5790,7 +5890,7 @@ function onlySecret(text) {
@@ -5790,7 +5890,7 @@ function onlySecret(text) {
module.exports = { redact, onlySecret };
module.exports = { redact, onlySecret };
},
},
-// ── 45: src/chat.js ─────────────────────────────────────────────────
+// ── 46: src/chat.js ─────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -5823,7 +5923,7 @@ function (module, exports) {
@@ -5823,7 +5923,7 @@ function (module, exports) {
const { isOpenVibeError } = __load(3);
const { isOpenVibeError } = __load(3);
const enc = encodeURIComponent;
const enc = encodeURIComponent;
-const history = __load(46);
+const history = __load(47);
/** The kinds chat.embed@1 names; anything else is not a preview this SDK returns. */
/** The kinds chat.embed@1 names; anything else is not a preview this SDK returns. */
const EMBED_KINDS = new Set(['link', 'video', 'image', 'live', 'picture', 'design', 'post', 'profile', 'game']);
const EMBED_KINDS = new Set(['link', 'video', 'image', 'live', 'picture', 'design', 'post', 'profile', 'game']);
@@ -6112,7 +6212,7 @@ function createFeedPublisher(client, { feed, key, baseUrl } = {}) {
@@ -6112,7 +6212,7 @@ function createFeedPublisher(client, { feed, key, baseUrl } = {}) {
module.exports = { createChatClient, createInboxVisitor, createFeedPublisher, history, readEmbeds };
module.exports = { createChatClient, createInboxVisitor, createFeedPublisher, history, readEmbeds };
},
},
-// ── 46: src/chat-history.js ─────────────────────────────────────────
+// ── 47: src/chat-history.js ─────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
@@ -6191,7 +6291,7 @@ function attach({ feed, status = null, fetchPage, render, hasMore = true, thresh
@@ -6191,7 +6291,7 @@ function attach({ feed, status = null, fetchPage, render, hasMore = true, thresh
module.exports = { pages, attach };
module.exports = { pages, attach };
},
},
-// ── 47: src/ai.js ───────────────────────────────────────────────────
+// ── 48: src/ai.js ───────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -6371,7 +6471,7 @@ function createAiClient(client, defaults = {}) {
@@ -6371,7 +6471,7 @@ function createAiClient(client, defaults = {}) {
remove(id) { requireFiles('remove'); return fileObjects.delete(id); },
remove(id) { requireFiles('remove'); return fileObjects.delete(id); },
};
};
- const metrics = __load(48).createMetricsClient(call);
+ const metrics = __load(49).createMetricsClient(call);
const api = { tasks, creations, choices, run, turn, admin, runs, batches, files, metrics, TERMINAL, CLASSES };
const api = { tasks, creations, choices, run, turn, admin, runs, batches, files, metrics, TERMINAL, CLASSES };
// Direct operations: a run of workflow ai.<op> with the input as the body, waited for by AI.
// Direct operations: a run of workflow ai.<op> with the input as the body, waited for by AI.
for (const op of OPS) {
for (const op of OPS) {
@@ -6384,7 +6484,7 @@ function createAiClient(client, defaults = {}) {
@@ -6384,7 +6484,7 @@ function createAiClient(client, defaults = {}) {
module.exports = { createAiClient, TERMINAL, OPS, CLASSES };
module.exports = { createAiClient, TERMINAL, OPS, CLASSES };
},
},
-// ── 48: src/ai-metrics.js ───────────────────────────────────────────
+// ── 49: src/ai-metrics.js ───────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
// Public measured reads: no bearer token, prompt, person or site identifiers.
// Public measured reads: no bearer token, prompt, person or site identifiers.
@@ -6413,7 +6513,7 @@ function createMetricsClient(call) {
@@ -6413,7 +6513,7 @@ function createMetricsClient(call) {
}
}
module.exports = { createMetricsClient };
module.exports = { createMetricsClient };
},
},
-// ── 49: src/credentials.js ──────────────────────────────────────────
+// ── 50: src/credentials.js ──────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
@@ -6431,7 +6531,7 @@ function createCredentialsClient(client, defaults = {}) {
@@ -6431,7 +6531,7 @@ function createCredentialsClient(client, defaults = {}) {
module.exports = { createCredentialsClient };
module.exports = { createCredentialsClient };
},
},
-// ── 50: src/jobs.js ─────────────────────────────────────────────────
+// ── 51: src/jobs.js ─────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -6469,7 +6569,7 @@ function (module, exports) {
@@ -6469,7 +6569,7 @@ function (module, exports) {
*/
*/
const { OpenVibeError, isOpenVibeError } = __load(3);
const { OpenVibeError, isOpenVibeError } = __load(3);
const { newIdempotencyKey } = __load(5);
const { newIdempotencyKey } = __load(5);
-const { appendFiles } = __load(51);
+const { appendFiles } = __load(52);
const { parseSSE } = __load(25);
const { parseSSE } = __load(25);
const TERMINAL = new Set(['succeeded', 'failed', 'cancelled']);
const TERMINAL = new Set(['succeeded', 'failed', 'cancelled']);
@@ -6633,7 +6733,7 @@ function createJobsClient(client, { baseUrl, service = 'tools', audience = 'open
@@ -6633,7 +6733,7 @@ function createJobsClient(client, { baseUrl, service = 'tools', audience = 'open
module.exports = { createJobsClient, isTerminal, TERMINAL_STATES: [...TERMINAL] };
module.exports = { createJobsClient, isTerminal, TERMINAL_STATES: [...TERMINAL] };
},
},
-// ── 51: src/core/form.js ────────────────────────────────────────────
+// ── 52: src/core/form.js ────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -6667,7 +6767,7 @@ function appendFiles(form, list, where) {
@@ -6667,7 +6767,7 @@ function appendFiles(form, list, where) {
module.exports = { isBlob, isUpload, appendFiles };
module.exports = { isBlob, isUpload, appendFiles };
},
},
-// ── 52: src/agents.js ───────────────────────────────────────────────
+// ── 53: src/agents.js ───────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/** Agent run snapshots, AG-UI event streams and approval responses. */
/** Agent run snapshots, AG-UI event streams and approval responses. */
@@ -6750,10 +6850,10 @@ function createAgentsClient(client, { baseUrl, service = 'network', audience = '
@@ -6750,10 +6850,10 @@ function createAgentsClient(client, { baseUrl, service = 'network', audience = '
}
}
module.exports = { createAgentsClient };
module.exports = { createAgentsClient };
},
},
-// ── 53: src/frame.js ────────────────────────────────────────────────
+// ── 54: src/frame.js ────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
-const { createAgentsClient } = __load(52);
+const { createAgentsClient } = __load(53);
/**
/**
* openvibe-sdk/frame — the OpenVibe Frame: the navbar, footer and themes every OpenVibe site sits in, for any app: the universal navbar (one
* openvibe-sdk/frame — the OpenVibe Frame: the navbar, footer and themes every OpenVibe site sits in, for any app: the universal navbar (one
@@ -6973,7 +7073,7 @@ function createFrameClient(client, { baseUrl, networkBaseUrl } = {}) {
@@ -6973,7 +7073,7 @@ function createFrameClient(client, { baseUrl, networkBaseUrl } = {}) {
module.exports = { mountFrame, frameTags, frameConfig, scriptUrls, online, createFrameClient, DEFAULT_BASE };
module.exports = { mountFrame, frameTags, frameConfig, scriptUrls, online, createFrameClient, DEFAULT_BASE };
},
},
-// ── 54: src/tools.js ────────────────────────────────────────────────
+// ── 55: src/tools.js ────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -7007,8 +7107,8 @@ function (module, exports) {
@@ -7007,8 +7107,8 @@ function (module, exports) {
*/
*/
const { OpenVibeError, isOpenVibeError } = __load(3);
const { OpenVibeError, isOpenVibeError } = __load(3);
const { newIdempotencyKey } = __load(5);
const { newIdempotencyKey } = __load(5);
-const { isUpload, appendFiles } = __load(51);
-const { createJobsClient } = __load(50);
+const { isUpload, appendFiles } = __load(52);
+const { createJobsClient } = __load(51);
const enc = encodeURIComponent;
const enc = encodeURIComponent;
const ID_RE = /^[a-z][a-z0-9-]{0,39}$/;
const ID_RE = /^[a-z][a-z0-9-]{0,39}$/;
@@ -7270,7 +7370,7 @@ function createToolsClient(client, { baseUrl, service = 'tools', audience = 'ope
@@ -7270,7 +7370,7 @@ function createToolsClient(client, { baseUrl, service = 'tools', audience = 'ope
module.exports = { createToolsClient, ToolRunError, isToolRunError };
module.exports = { createToolsClient, ToolRunError, isToolRunError };
},
},
-// ── 55: src/projects.js ─────────────────────────────────────────────
+// ── 56: src/projects.js ─────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -7386,7 +7486,7 @@ function createProjectsClient(client, { baseUrl } = {}) {
@@ -7386,7 +7486,7 @@ function createProjectsClient(client, { baseUrl } = {}) {
module.exports = { createProjectsClient };
module.exports = { createProjectsClient };
},
},
-// ── 56: src/geo.js ──────────────────────────────────────────────────
+// ── 57: src/geo.js ──────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -7450,7 +7550,7 @@ function createGeoClient(client, { baseUrl, fetch: fetchImpl = null, samples = 3
@@ -7450,7 +7550,7 @@ function createGeoClient(client, { baseUrl, fetch: fetchImpl = null, samples = 3
module.exports = { createGeoClient };
module.exports = { createGeoClient };
},
},
-// ── 57: src/history.js ──────────────────────────────────────────────
+// ── 58: src/history.js ──────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
@@ -7478,7 +7578,7 @@ function createHistoryClient(client, { baseUrl } = {}) {
@@ -7478,7 +7578,7 @@ function createHistoryClient(client, { baseUrl } = {}) {
module.exports = { createHistoryClient };
module.exports = { createHistoryClient };
},
},
-// ── 58: src/user-card.js ────────────────────────────────────────────
+// ── 59: src/user-card.js ────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/** One public Network aggregate. Hidden/unavailable fields stay absent; no credentials are needed. */
/** One public Network aggregate. Hidden/unavailable fields stay absent; no credentials are needed. */
@@ -7494,7 +7594,7 @@ function createUserCardClient(client, { baseUrl } = {}) {
@@ -7494,7 +7594,7 @@ function createUserCardClient(client, { baseUrl } = {}) {
}
}
module.exports = { createUserCardClient };
module.exports = { createUserCardClient };
},
},
-// ── 59: src/player.js ───────────────────────────────────────────────
+// ── 60: src/player.js ───────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/** Browser facade for Shared's portable live player. */
/** Browser facade for Shared's portable live player. */
@@ -7510,7 +7610,7 @@ function on(listener) {
@@ -7510,7 +7610,7 @@ function on(listener) {
}
}
module.exports = { current, handoff, on };
module.exports = { current, handoff, on };
},
},
-// ── 60: src/agent-sheet.js ──────────────────────────────────────────
+// ── 61: src/agent-sheet.js ──────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/** Owner-only agent sheets through Network's fixed cross-site relay. The caller supplies their own Bearer. */
/** Owner-only agent sheets through Network's fixed cross-site relay. The caller supplies their own Bearer. */
@@ -7558,10 +7658,10 @@ export const {
@@ -7558,10 +7658,10 @@ export const {
isActingSubjectId, satisfiesRange, compareVersions, CONTRACTS_RANGE, DEFAULT_NETWORK, SDK_VERSION,
isActingSubjectId, satisfiesRange, compareVersions, CONTRACTS_RANGE, DEFAULT_NETWORK, SDK_VERSION,
auth, locker, registry, trust, levels, modules,
auth, locker, registry, trust, levels, modules,
realtime, media, composer, cam, mediaUpload, ui,
realtime, media, composer, cam, mediaUpload, ui,
- uiLayout, community, homeFeed, feed, bot, search,
- bench, meme, vision, themes, elements, design,
- redact, chat, ai, credentials, jobs, agents,
- frame, tools, projects, geo, history, userCard,
- player, agentSheet,
+ uiLayout, community, homeFeed, feed, views, bot,
+ search, bench, meme, vision, themes, elements,
+ design, redact, chat, ai, credentials, jobs,
+ agents, frame, tools, projects, geo, history,
+ userCard, player, agentSheet,
} = sdk;
} = sdk;
export default sdk;
export default sdk;
@@ -546,6 +546,16 @@
@@ -546,6 +546,16 @@
"createVideoClient"
"createVideoClient"
]
]
},
},
+ "views": {
+ "object": [
+ "HOWS",
+ "MAX_BATCH",
+ "MEDIA_URL",
+ "createViewsClient",
+ "eventOf",
+ "refOf"
+ ]
+ },
"vip": {
"vip": {
"object": [
"object": [
"createVipCache",
"createVipCache",
@@ -1433,6 +1443,14 @@
@@ -1433,6 +1443,14 @@
"openvibe-sdk/video": {
"openvibe-sdk/video": {
"createVideoClient": "function"
"createVideoClient": "function"
},
},
+ "openvibe-sdk/views": {
+ "HOWS": "array",
+ "MAX_BATCH": "number",
+ "MEDIA_URL": "string",
+ "createViewsClient": "function",
+ "eventOf": "function",
+ "refOf": "function"
+ },
"openvibe-sdk/vip": {
"openvibe-sdk/vip": {
"createVipCache": "function",
"createVipCache": "function",
"createVipClient": "function"
"createVipClient": "function"
@@ -5,18 +5,18 @@ export const {
@@ -5,18 +5,18 @@ export const {
createWalletClient, createClient, OpenVibeError, isOpenVibeError, paginate, offsetPager,
createWalletClient, createClient, OpenVibeError, isOpenVibeError, paginate, offsetPager,
parseTraceparent, startSpan, contextFromHeaders, ulid, newEventId, newIdempotencyKey,
parseTraceparent, startSpan, contextFromHeaders, ulid, newEventId, newIdempotencyKey,
isActingSubjectId, satisfiesRange, compareVersions, CONTRACTS_RANGE, DEFAULT_NETWORK, SDK_VERSION,
isActingSubjectId, satisfiesRange, compareVersions, CONTRACTS_RANGE, DEFAULT_NETWORK, SDK_VERSION,
- report, share, locker, auth, registry, identity,
- trust, levels, modules, events, realtime, media,
- composer, cam, mediaUpload, ui, uiLayout, community,
- homeFeed, feed, bot, search, bench, meme,
- vision, themes, elements, design, redact, chat,
- chatApps, ai, credentials, jobs, agents, frame,
- tools, projects, resources, vip, quest, live,
- inventory, tips, blog, reviews, wiki, coupons,
- deals, shoes, trade, space, host, news,
- food, actor, codes, run, video, pics,
- work, zone, git, play, download, openre,
- geo, history, usage, commerce, moneyReasons, telemetry,
- userCard, player, agentSheet,
+ report, views, share, locker, auth, registry,
+ identity, trust, levels, modules, events, realtime,
+ media, composer, cam, mediaUpload, ui, uiLayout,
+ community, homeFeed, feed, bot, search, bench,
+ meme, vision, themes, elements, design, redact,
+ chat, chatApps, ai, credentials, jobs, agents,
+ frame, tools, projects, resources, vip, quest,
+ live, inventory, tips, blog, reviews, wiki,
+ coupons, deals, shoes, trade, space, host,
+ news, food, actor, codes, run, video,
+ pics, work, zone, git, play, download,
+ openre, geo, history, usage, commerce, moneyReasons,
+ telemetry, userCard, player, agentSheet,
} = cjs;
} = cjs;
export default cjs;
export default cjs;
new file mode 100644
new file mode 100644
@@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
+// Generated by scripts/esm.js from src/views.js. Do not edit.
+import cjs from '../src/views.js';
+
+export const {
+ createViewsClient, refOf, eventOf, MEDIA_URL, MAX_BATCH, HOWS,
+} = cjs;
+export default cjs;
@@ -10,6 +10,7 @@ module.exports = {
@@ -10,6 +10,7 @@ module.exports = {
createWalletClient: require('./src/wallet').createWalletClient,
createWalletClient: require('./src/wallet').createWalletClient,
...core,
...core,
report: require('./src/report'),
report: require('./src/report'),
+ views: require('./src/views'),
share: require('./src/share').share,
share: require('./src/share').share,
locker: require('./src/locker'),
locker: require('./src/locker'),
auth: require('./src/auth'),
auth: require('./src/auth'),
@@ -1,12 +1,12 @@
@@ -1,12 +1,12 @@
{
{
"name": "openvibe-sdk",
"name": "openvibe-sdk",
- "version": "0.157.0",
+ "version": "0.158.0",
"lockfileVersion": 3,
"lockfileVersion": 3,
"requires": true,
"requires": true,
"packages": {
"packages": {
"": {
"": {
"name": "openvibe-sdk",
"name": "openvibe-sdk",
- "version": "0.157.0",
+ "version": "0.158.0",
"license": "MIT",
"license": "MIT",
"bin": {
"bin": {
"openvibe-download": "bin/openvibe-download.js"
"openvibe-download": "bin/openvibe-download.js"
@@ -1,6 +1,6 @@
@@ -1,6 +1,6 @@
{
{
"name": "openvibe-sdk",
"name": "openvibe-sdk",
- "version": "0.157.0",
+ "version": "0.158.0",
"description": "Supported browser and server clients for the OpenVibe platform: auth (incl. developer apps), registry discovery, identity, user modules, events, realtime, media, community, Bot robots, search, chat, AI runs, Tools (registry, run API and jobs), VIP memberships and developer projects, the async PostgreSQL data layer (db) and the Valkey cache, limits store, queue and pub/sub, with deadlines, safe retries, problem errors and trace propagation.",
"description": "Supported browser and server clients for the OpenVibe platform: auth (incl. developer apps), registry discovery, identity, user modules, events, realtime, media, community, Bot robots, search, chat, AI runs, Tools (registry, run API and jobs), VIP memberships and developer projects, the async PostgreSQL data layer (db) and the Valkey cache, limits store, queue and pub/sub, with deadlines, safe retries, problem errors and trace propagation.",
"main": "index.js",
"main": "index.js",
"types": "types/index.d.ts",
"types": "types/index.d.ts",
@@ -234,6 +234,12 @@
@@ -234,6 +234,12 @@
"import": "./esm/report.mjs",
"import": "./esm/report.mjs",
"default": "./src/report.js"
"default": "./src/report.js"
},
},
+ "./views": {
+ "types": "./types/views.d.ts",
+ "browser": "./src/views.js",
+ "import": "./esm/views.mjs",
+ "default": "./src/views.js"
+ },
"./delivery": {
"./delivery": {
"types": "./types/delivery.d.ts",
"types": "./types/delivery.d.ts",
"browser": null,
"browser": null,
@@ -63,6 +63,7 @@ const ENTRIES = {
@@ -63,6 +63,7 @@ const ENTRIES = {
'commerce.mjs': '../src/commerce.js',
'commerce.mjs': '../src/commerce.js',
'exchange.mjs': '../src/exchange.js',
'exchange.mjs': '../src/exchange.js',
'report.mjs': '../src/report.js',
'report.mjs': '../src/report.js',
+ 'views.mjs': '../src/views.js',
'vibes.mjs': '../src/vibes.js',
'vibes.mjs': '../src/vibes.js',
'delivery.mjs': '../src/delivery.js',
'delivery.mjs': '../src/delivery.js',
'link.mjs': '../src/link.js',
'link.mjs': '../src/link.js',
@@ -8,7 +8,7 @@ const { paginate, offsetPager } = require('./paginate');
@@ -8,7 +8,7 @@ const { paginate, offsetPager } = require('./paginate');
const semver = require('./semver');
const semver = require('./semver');
/** The package version (test/version.test.js keeps it equal to package.json). */
/** The package version (test/version.test.js keeps it equal to package.json). */
-const SDK_VERSION = '0.157.0';
+const SDK_VERSION = '0.158.0';
module.exports = {
module.exports = {
createClient,
createClient,
new file mode 100644
new file mode 100644
@@ -0,0 +1,96 @@
@@ -0,0 +1,96 @@
+'use strict';
+
+/**
+ * openvibe-sdk/views — one view API for every content kind.
+ *
+ * const views = createViewsClient(client);
+ * await views.record({ ref: { service: 'media', kind: 'vod', id: '42' }, how: 'preview', seconds: 2, session });
+ * await views.record([ … up to 20 events … ]);
+ * const counts = await views.counts({ service: 'media', kind: 'vod', id: '42' });
+ * // → { ref, counts: { views, engaged, previews, preview_share, peak_concurrent } }
+ *
+ * OpenVibe.Media owns the numbers for every kind (a Media VOD or clip, a Live recording or stream, a Feed item):
+ * POST /api/v1/views is public and CORS *, dedupes one view per person or anonymous session per item per 30 minutes,
+ * counts a preview from 1 second and engagement at 30 seconds or a third of the length (60 seconds of a live stream),
+ * and never stores an IP address or a user agent. `seconds` is cumulative for the session and item: a retry sends the
+ * same number, playback sends a larger one, and neither counts the item twice.
+ *
+ * A signed-in viewer sends their Network token on the client and no session; a signed-out viewer keeps an opaque
+ * `session` id of their own. The write is not retried for you: a retry is safe (same session, same item), but this
+ * client leaves the decision to the caller, like the other beacon-shaped writes.
+ */
+const MEDIA_URL = 'https://openvibe.media';
+const MAX_BATCH = 20;
+const HOWS = ['preview', 'watch', 'live'];
+const SERVICE_RE = /^[a-z][a-z0-9-]{1,39}$/;
+const KIND_RE = /^[a-z][a-z0-9_]{1,39}$/;
+const SESSION_RE = /^[A-Za-z0-9._~-]{8,128}$/;
+
+function refOf(ref) {
+ if (!ref || typeof ref !== 'object' || Array.isArray(ref)) throw new TypeError('views: ref must be { service, kind, id }');
+ const service = String(ref.service || '');
+ const kind = String(ref.kind || '');
+ const id = ref.id == null ? '' : String(ref.id);
+ if (!SERVICE_RE.test(service)) throw new TypeError('views: ref.service is a service id (media, live, network…)');
+ if (!KIND_RE.test(kind)) throw new TypeError('views: ref.kind is an item type (vod, clip, recording, stream…)');
+ if (!id || id.length > 200) throw new TypeError('views: ref.id is 1–200 characters');
+ const out = { service, kind, id };
+ if (ref.site != null) {
+ if (!/^[a-z][a-z0-9-]{0,39}$/.test(String(ref.site))) throw new TypeError('views: ref.site is a site id');
+ out.site = String(ref.site);
+ }
+ if (ref.creator != null) {
+ if (String(ref.creator).length > 200) throw new TypeError('views: ref.creator is at most 200 characters');
+ out.creator = String(ref.creator);
+ }
+ return out;
+}
+
+function eventOf(event) {
+ if (!event || typeof event !== 'object' || Array.isArray(event)) throw new TypeError('views.record: each event is an object');
+ const how = String(event.how || '');
+ if (!HOWS.includes(how)) throw new TypeError(`views.record: how is ${HOWS.join(', ')}`);
+ const seconds = Number(event.seconds);
+ if (!Number.isFinite(seconds) || seconds < 0 || seconds > 86400) throw new TypeError('views.record: seconds is 0–86400');
+ const out = { ref: refOf(event.ref), how, seconds };
+ if (event.of_seconds != null) {
+ const of = Number(event.of_seconds);
+ if (!Number.isFinite(of) || of <= 0 || of > 86400) throw new TypeError('views.record: of_seconds is 1–86400');
+ out.of_seconds = of;
+ }
+ if (event.session != null) {
+ if (!SESSION_RE.test(String(event.session))) throw new TypeError('views.record: session is 8–128 letters, digits, . _ ~ or -');
+ out.session = String(event.session);
+ }
+ return out;
+}
+
+function createViewsClient(client, { baseUrl = MEDIA_URL } = {}) {
+ if (!client || typeof client.json !== 'function') throw new TypeError('createViewsClient: pass an openvibe-sdk/core client');
+ const base = String(baseUrl || MEDIA_URL).replace(/\/+$/, '');
+ return {
+ /**
+ * Record one event or up to 20 at once. → { results: [{ accepted, counted, engaged, reason? }], counts? }
+ * `session` is required by the service for a signed-out viewer; a signed-in viewer sends their token instead.
+ */
+ record(events, { signal } = {}) {
+ const list = Array.isArray(events) ? events : [events];
+ if (!list.length) throw new TypeError('views.record: send at least one event');
+ if (list.length > MAX_BATCH) throw new TypeError(`views.record: at most ${MAX_BATCH} events in one call`);
+ return client.json({
+ baseUrl: base, path: '/api/v1/views', method: 'POST',
+ json: { events: list.map(eventOf) }, signal, service: 'media',
+ });
+ },
+ /** One item's numbers: views, engaged viewers, preview views, the feed-preview share and live peak concurrent. */
+ counts(ref, { signal } = {}) {
+ const r = refOf(ref);
+ return client.json({
+ baseUrl: base, path: '/api/v1/views/counts',
+ query: { service: r.service, kind: r.kind, id: r.id }, signal, service: 'media',
+ });
+ },
+ };
+}
+
+module.exports = { createViewsClient, refOf, eventOf, MEDIA_URL, MAX_BATCH, HOWS };
@@ -72,7 +72,7 @@ run([
@@ -72,7 +72,7 @@ run([
})().catch((err) => { console.error(err); process.exit(1); });`;
})().catch((err) => { console.error(err); process.exit(1); });`;
const res = execFileSync(process.execPath, ['-e', script], { cwd: app, encoding: 'utf8' });
const res = execFileSync(process.execPath, ['-e', script], { cwd: app, encoding: 'utf8' });
assert.match(res, new RegExp(`consumer ok: ${subpaths.length} subpaths \\+ the browser bundle`));
assert.match(res, new RegExp(`consumer ok: ${subpaths.length} subpaths \\+ the browser bundle`));
- assert.equal(subpaths.length, 111); // 0.152.0 train: elements (#227) and ui-layout (#226) add the 110th and 111th; // composer, feed and agents add the 104th-106th after user-card; the 0.148.0 train's codes, player and the rest bring 109; elements brings 110.
+ assert.equal(subpaths.length, 112); // 0.152.0 train: elements (#227) and ui-layout (#226) add the 110th and 111th; // composer, feed and agents add the 104th-106th after user-card; the 0.148.0 train's codes, player and the rest bring 109; elements brings 110.
assert.ok(!fs.existsSync(path.join(app, 'node_modules/openvibe-contracts')), 'the optional peer is not installed');
assert.ok(!fs.existsSync(path.join(app, 'node_modules/openvibe-contracts')), 'the optional peer is not installed');
} finally {
} finally {
fs.rmSync(tmp, { recursive: true, force: true });
fs.rmSync(tmp, { recursive: true, force: true });
new file mode 100644
new file mode 100644
@@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
+'use strict';
+const assert = require('assert');
+const { createViewsClient, eventOf, refOf } = require('../src/views');
+
+(async () => {
+ const calls = [];
+ const client = { json: async (input) => { calls.push(input); return { results: [{ accepted: true, counted: true, engaged: false }] }; } };
+ const views = createViewsClient(client, { baseUrl: 'https://media.test/' });
+
+ await views.record({ ref: { service: 'media', kind: 'vod', id: 42 }, how: 'preview', seconds: 2, session: 'anon_9f2c1e7a4b' });
+ assert.deepStrictEqual(calls[0], {
+ baseUrl: 'https://media.test', path: '/api/v1/views', method: 'POST', service: 'media', signal: undefined,
+ json: { events: [{ ref: { service: 'media', kind: 'vod', id: '42' }, how: 'preview', seconds: 2, session: 'anon_9f2c1e7a4b' }] },
+ });
+
+ await views.record([
+ { ref: { service: 'live', kind: 'stream', id: '7', site: 'network', creator: 'maticus' }, how: 'live', seconds: 61 },
+ { ref: { service: 'media', kind: 'clip', id: '3' }, how: 'watch', seconds: 30, of_seconds: 90 },
+ ]);
+ assert.strictEqual(calls[1].json.events.length, 2);
+ assert.strictEqual(calls[1].json.events[0].ref.site, 'network');
+
+ await views.counts({ service: 'media', kind: 'vod', id: 42 });
+ assert.deepStrictEqual(calls[2].query, { service: 'media', kind: 'vod', id: '42' });
+
+ assert.throws(() => views.record(Array.from({ length: 21 }, () => ({ ref: { service: 'media', kind: 'clip', id: '1' }, how: 'preview', seconds: 2 }))), /at most 20/);
+ assert.throws(() => eventOf({ ref: { service: 'media', kind: 'clip', id: '1' }, how: 'scroll', seconds: 2 }), /how is/);
+ assert.throws(() => refOf({ service: 'Media', kind: 'clip', id: '1' }), /service is a service id/);
+ assert.throws(() => eventOf({ ref: { service: 'media', kind: 'clip', id: '1' }, how: 'watch', seconds: 1, session: 'short' }), /session is/);
+ console.log('views: record batches and counts a ref with the documented shapes');
+})().catch((error) => { console.error(error); process.exitCode = 1; });
@@ -15,6 +15,7 @@ import * as uiLayout from './ui-layout';
@@ -15,6 +15,7 @@ import * as uiLayout from './ui-layout';
import * as community from './community';
import * as community from './community';
import * as homeFeed from './home-feed';
import * as homeFeed from './home-feed';
import * as feed from './feed';
import * as feed from './feed';
+import * as views from './views';
import * as bot from './bot';
import * as bot from './bot';
import * as search from './search';
import * as search from './search';
import * as bench from './bench';
import * as bench from './bench';
@@ -55,6 +56,7 @@ export * as uiLayout from './ui-layout';
@@ -55,6 +56,7 @@ export * as uiLayout from './ui-layout';
export * as community from './community';
export * as community from './community';
export * as homeFeed from './home-feed';
export * as homeFeed from './home-feed';
export * as feed from './feed';
export * as feed from './feed';
+export * as views from './views';
export * as bot from './bot';
export * as bot from './bot';
export * as search from './search';
export * as search from './search';
export * as bench from './bench';
export * as bench from './bench';
@@ -86,6 +88,6 @@ declare const sdk: typeof core & {
@@ -86,6 +88,6 @@ declare const sdk: typeof core & {
userCard: typeof userCard;
userCard: typeof userCard;
player: typeof player;
player: typeof player;
auth: typeof auth; registry: typeof registry; modules: typeof modules; realtime: typeof realtime;
auth: typeof auth; registry: typeof registry; modules: typeof modules; realtime: typeof realtime;
- media: typeof media; composer: typeof composer; cam: typeof cam; mediaUpload: typeof mediaUpload; ui: typeof ui; uiLayout: typeof uiLayout; community: typeof community; homeFeed: typeof homeFeed; feed: typeof feed; bot: typeof bot; search: typeof search; bench: typeof bench; meme: typeof meme; vision: typeof vision; themes: typeof themes; design: typeof design; redact: typeof redact; chat: typeof chat; ai: typeof ai; credentials: typeof credentials; jobs: typeof jobs; agents: typeof agents; tools: typeof tools; projects: typeof projects; geo: typeof geo; history: typeof history; locker: typeof locker; trust: typeof trust; levels: typeof levels;
+ media: typeof media; composer: typeof composer; cam: typeof cam; mediaUpload: typeof mediaUpload; ui: typeof ui; uiLayout: typeof uiLayout; community: typeof community; homeFeed: typeof homeFeed; feed: typeof feed; views: typeof views; bot: typeof bot; search: typeof search; bench: typeof bench; meme: typeof meme; vision: typeof vision; themes: typeof themes; design: typeof design; redact: typeof redact; chat: typeof chat; ai: typeof ai; credentials: typeof credentials; jobs: typeof jobs; agents: typeof agents; tools: typeof tools; projects: typeof projects; geo: typeof geo; history: typeof history; locker: typeof locker; trust: typeof trust; levels: typeof levels;
};
};
export default sdk;
export default sdk;
@@ -2,6 +2,7 @@ export * from './core';
@@ -2,6 +2,7 @@ export * from './core';
export * as auth from './auth';
export * as auth from './auth';
export * as design from './design';
export * as design from './design';
export * as report from './report';
export * as report from './report';
+export * as views from './views';
export * as report from './report';
export * as report from './report';
export * as registry from './registry';
export * as registry from './registry';
export * as identity from './identity';
export * as identity from './identity';
new file mode 100644
new file mode 100644
@@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
+import type { OpenVibeClient } from './core';
+
+export interface ViewRef {
+ service: string;
+ kind: string;
+ id: string;
+ /** The site the view happened on, when it differs from the owning service (the Feed counts a clip on network). */
+ site?: string;
+ /** The creator's canonical subject or channel username, for Report's per-creator numbers. */
+ creator?: string;
+}
+
+export interface ViewEvent {
+ ref: ViewRef;
+ /** preview: a silent preview in the feed; watch: a watch page; live: a live stream being watched now. */
+ how: 'preview' | 'watch' | 'live';
+ /** Cumulative seconds watched in this session for this item. A retry sends the same number. */
+ seconds: number;
+ /** The item's length when known: engaged comes at min(30, of_seconds / 3) for a watch. */
+ of_seconds?: number;
+ /** The anonymous session id a signed-out viewer keeps (8–128 characters); a signed-in viewer sends a token instead. */
+ session?: string;
+}
+
+export interface ViewResult {
+ accepted: boolean;
+ counted: boolean;
+ engaged: boolean;
+ reason?: string;
+}
+
+export interface ViewCounts {
+ views: number;
+ engaged: number;
+ previews: number;
+ /** Preview views divided by all views, 0–1; null before the item has a view. */
+ preview_share: number | null;
+ /** The most live watchers seen at once (how = live); null when it was never watched live. */
+ peak_concurrent: number | null;
+}
+
+export interface ViewsClient {
+ /** Record one event or up to 20 at once (a signed-in viewer's token, or an anonymous session id). */
+ record(events: ViewEvent | ViewEvent[], options?: { signal?: AbortSignal }): Promise<{ results: ViewResult[]; counts?: ViewCounts }>;
+ /** One item's numbers. */
+ counts(ref: ViewRef, options?: { signal?: AbortSignal }): Promise<{ ref: ViewRef; counts: ViewCounts }>;
+}
+
+export function createViewsClient(client: OpenVibeClient, options?: { baseUrl?: string }): ViewsClient;
+export const MEDIA_URL: string;
+export const MAX_BATCH: number;
+export const HOWS: Array<'preview' | 'watch' | 'live'>;
+
+/** Validate and normalize one ref (throws a TypeError on a bad service, kind or id). */
+export function refOf(ref: ViewRef): ViewRef;
+/** Validate and normalize one event (throws a TypeError on a bad how, seconds or session). */
+export function eventOf(event: ViewEvent): ViewEvent;