openvibers/openvibe.sdk Commits
Network levels client and SDK 0.136.0 (#185)
Changes
@@@ -1,3 +1,7 @@++## 0.136.0 — 2026-11-09++++- Network levels client: public person, batch and board reads, and service awards.++# Changelog## 0.135.0 (2026-11-10)@@@ -13,7 +13,7 @@ npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags> Supported browser and server clients for the OpenVibe platform.--**Status:** alpha, v0.135.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.136.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.135.0++npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.136.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).@@@ -3,7 +3,7 @@"stage": "alpha","code": true,"wave": "W2",-- "version": "0.135.0",++ "version": "0.136.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",@@@ -12,6 +12,7 @@ module.exports = {locker: require('./src/locker'),registry: require('./src/registry'),trust: require('./src/trust'),++ levels: require('./src/levels'),modules: require('./src/modules'),realtime: require('./src/realtime'),media: require('./src/media'),@@@ -1,6 +1,6 @@--// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.135.0, MIT). Do not edit.++// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.136.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, modules, realtime, media, cam, mediaUpload, ui, community, homeFeed, bot, search, bench, meme, vision, themes, design, redact, chat, ai, credentials, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity.++// (auth, locker, registry, trust, levels, modules, realtime, media, cam, mediaUpload, ui, community, homeFeed, bot, search, bench, meme, vision, themes, design, redact, chat, ai, credentials, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity./* eslint-disable */const __defs = [// ── 0: browser.js ──────────────────────────────────────────────────@@@ -19,29 +19,30 @@ module.exports = {locker: __load(10),registry: __load(21),trust: __load(22),-- modules: __load(23),-- realtime: __load(24),-- media: __load(25),-- cam: __load(27),-- mediaUpload: __load(28),-- ui: __load(29),-- community: __load(30),-- homeFeed: __load(31),-- bot: __load(32),-- search: __load(33),-- bench: __load(34),-- meme: __load(35),-- vision: __load(36),-- themes: __load(37),-- design: __load(38),-- redact: __load(39),-- chat: __load(40),-- ai: __load(41),-- credentials: __load(42),-- jobs: __load(43),-- tools: __load(45),-- projects: __load(46),-- geo: __load(47),++ levels: __load(23),++ modules: __load(24),++ realtime: __load(25),++ media: __load(26),++ cam: __load(28),++ mediaUpload: __load(29),++ ui: __load(30),++ community: __load(31),++ homeFeed: __load(32),++ bot: __load(33),++ search: __load(34),++ bench: __load(35),++ meme: __load(36),++ vision: __load(37),++ themes: __load(38),++ design: __load(39),++ redact: __load(40),++ chat: __load(41),++ ai: __load(42),++ credentials: __load(43),++ jobs: __load(44),++ tools: __load(46),++ projects: __load(47),++ geo: __load(48),};},// ── 1: src/core/index.js ───────────────────────────────────────────@@@ -56,7 +57,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.135.0';++const SDK_VERSION = '0.136.0';module.exports = {createClient,@@@ -2512,7 +2513,31 @@ function atLeast(signals, band) {module.exports = { createTrustClient, isNew, atLeast, AGE_BANDS };},--// ── 23: src/modules.js ──────────────────────────────────────────────++// ── 23: src/levels.js ───────────────────────────────────────────────++function (module, exports) {++'use strict';++/** Network owns experience. Reads are public; awards require network.levels.award. */++function createLevelsClient(client, { baseUrl } = {}) {++ if (!client || typeof client.json !== 'function') throw new TypeError('createLevelsClient: pass an SDK core client');++ const call = (options) => client.json({ service: 'network', audience: 'openvibe.network', baseUrl, ...options });++ return {++ get(username, { signal } = {}) {++ if (!/^[A-Za-z0-9_]{1,40}$/.test(username)) throw new TypeError('invalid username');++ return call({ path: `/api/v1/levels/people/${encodeURIComponent(username)}`, signal });++ },++ batch(subjects, { signal } = {}) {++ if (!Array.isArray(subjects) || subjects.length > 100 || subjects.some(s => !/^usr_[0-9A-HJKMNP-TV-Z]{26}$/.test(s))) throw new TypeError('batch requires up to 100 user subjects');++ return call({ path: `/api/v1/levels/batch?subjects=${encodeURIComponent(subjects.join(','))}`, signal });++ },++ board({ signal } = {}) { return call({ path: '/api/v1/levels/board', signal }); },++ award(body, { signal } = {}) {++ return call({ method: 'POST', path: '/internal/levels/award', json: body, signal, idempotencyKey: false });++ },++ };++}++module.exports = { createLevelsClient };++},++// ── 24: src/modules.js ──────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -2591,7 +2616,7 @@ function createModulesClient(client, { baseUrl, maxAttempts = 5 } = {}) {module.exports = { createModulesClient };},--// ── 24: src/realtime.js ─────────────────────────────────────────────++// ── 25: src/realtime.js ─────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -2844,7 +2869,7 @@ function createRealtimeClient(client, defaults = {}) {module.exports = { subscribe, createRealtimeClient, parseSSE, DEFAULT_ORIGIN };},--// ── 25: src/media.js ────────────────────────────────────────────────++// ── 26: src/media.js ────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -2867,7 +2892,7 @@ function (module, exports) {*/const { isOpenVibeError } = __load(3);const { paginate, offsetPager } = __load(7);--const { createObjectsClient } = __load(26);++const { createObjectsClient } = __load(27);const DEFAULT_PUBLIC_ORIGIN = 'https://openvibe.media';const enc = encodeURIComponent;@@@ -2959,7 +2984,7 @@ function createMediaClient(client, { app, apiKey, actingUserId, baseUrl, publicOmodule.exports = { createMediaClient, createObjectsClient, mediaUrls, DEFAULT_PUBLIC_ORIGIN };},--// ── 26: src/objects.js ──────────────────────────────────────────────++// ── 27: src/objects.js ──────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -3279,7 +3304,7 @@ function createObjectsClient({module.exports = { createObjectsClient };},--// ── 27: src/cam/index.js ────────────────────────────────────────────++// ── 28: src/cam/index.js ────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -3389,10 +3414,10 @@ function defineOvCamera(options = {}) {module.exports = { defineOvCamera, OV_CAMERA_SRC, CAM_KIT_SRC, CAM_KIT_SRI, loadCamKit, open, settings };},--// ── 28: src/media-upload.js ─────────────────────────────────────────++// ── 29: src/media-upload.js ─────────────────────────────────────────function (module, exports) {'use strict';--const { createObjectsClient } = __load(25);++const { createObjectsClient } = __load(26);const MIB = 1024 * 1024;/** Media's resumable multipart transport, configured for 8 MiB parts and three in flight. */@@@ -3409,7 +3434,7 @@ function createUploadClient(config) {module.exports = { createUploadClient };},--// ── 29: src/ui.js ───────────────────────────────────────────────────++// ── 30: src/ui.js ───────────────────────────────────────────────────function (module, exports) {'use strict';@@@ -3422,7 +3447,7 @@ function progress(el, options) {module.exports = { progress };},--// ── 30: src/community.js ────────────────────────────────────────────++// ── 31: src/community.js ────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -3562,7 +3587,7 @@ function createCommunityClient(client, defaults = {}) {module.exports = { createCommunityClient, actingHeaders };},--// ── 31: src/home-feed.js ────────────────────────────────────────────++// ── 32: src/home-feed.js ────────────────────────────────────────────function (module, exports) {'use strict';/** The menu's portable Home layout, network day counts and personal wall. Pass a user-token core client;@@@ -3589,7 +3614,7 @@ function createHomeFeedClient(client, { networkBaseUrl, communityBaseUrl } = {})module.exports = { createHomeFeedClient };},--// ── 32: src/bot.js ──────────────────────────────────────────────────++// ── 33: src/bot.js ──────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -3811,7 +3836,7 @@ function createBotClient(client, defaults = {}) {module.exports = { createBotClient, actingHeaders };},--// ── 33: src/search.js ───────────────────────────────────────────────++// ── 34: src/search.js ───────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -3924,7 +3949,7 @@ function createSearchClient(client, defaults = {}) {module.exports = { createSearchClient, queryOf, fabricOf };},--// ── 34: src/bench.js ────────────────────────────────────────────────++// ── 35: src/bench.js ────────────────────────────────────────────────function (module, exports) {'use strict';/** openvibe-sdk/bench: OpenVibe.Bench's JSON API and streamed open dataset. Browser-safe. */@@@ -4025,7 +4050,7 @@ function createBenchClient(client, defaults = {}) {module.exports = { createBenchClient };},--// ── 35: src/meme.js ─────────────────────────────────────────────────++// ── 36: src/meme.js ─────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -4108,7 +4133,7 @@ function createMemeClient(client, defaults = {}) {module.exports = { createMemeClient };},--// ── 36: src/vision.js ───────────────────────────────────────────────++// ── 37: src/vision.js ───────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -4266,7 +4291,7 @@ function pick(o, keys) {module.exports = { createVisionClient, DEFAULT_AUDIENCE };},--// ── 37: src/themes.js ───────────────────────────────────────────────++// ── 38: src/themes.js ───────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -4416,7 +4441,7 @@ function followTheme(fn, opts = {}) {module.exports = { createThemesClient, followTheme, readTheme, applyTheme, seasonOn, onColor, DISPLAY_OPTIONS, TOKENS };},--// ── 38: src/design.js ───────────────────────────────────────────────++// ── 39: src/design.js ───────────────────────────────────────────────function (module, exports) {'use strict';@@@ -4483,7 +4508,7 @@ function createDesignClient({ accessToken = null, baseUrl = DEFAULT_DESIGN_URL,module.exports = { createDesignClient, DEFAULT_DESIGN_URL };},--// ── 39: src/redact.js ───────────────────────────────────────────────++// ── 40: src/redact.js ───────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -4730,7 +4755,7 @@ function onlySecret(text) {module.exports = { redact, onlySecret };},--// ── 40: src/chat.js ─────────────────────────────────────────────────++// ── 41: src/chat.js ─────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -4981,7 +5006,7 @@ function createFeedPublisher(client, { feed, key, baseUrl } = {}) {module.exports = { createChatClient, createInboxVisitor, createFeedPublisher };},--// ── 41: src/ai.js ───────────────────────────────────────────────────++// ── 42: src/ai.js ───────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -5117,7 +5142,7 @@ function createAiClient(client, defaults = {}) {};// Files live in Media; turns carry only their Media object references.-- const fileObjects = defaults.objectsClient || (defaults.media ? __load(26).createObjectsClient(defaults.media) : null);++ const fileObjects = defaults.objectsClient || (defaults.media ? __load(27).createObjectsClient(defaults.media) : null);const requireFiles = (method) => { if (!fileObjects) throw new TypeError(`ai.files.${method}: configure defaults.media or defaults.objectsClient`); };const files = {async attach(data, { filename, mediaType, subject, signal, ...options } = {}) {@@@ -5171,7 +5196,7 @@ function createAiClient(client, defaults = {}) {module.exports = { createAiClient, TERMINAL, OPS, CLASSES };},--// ── 42: src/credentials.js ──────────────────────────────────────────++// ── 43: src/credentials.js ──────────────────────────────────────────function (module, exports) {'use strict';@@@ -5189,7 +5214,7 @@ function createCredentialsClient(client, defaults = {}) {module.exports = { createCredentialsClient };},--// ── 43: src/jobs.js ─────────────────────────────────────────────────++// ── 44: src/jobs.js ─────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -5227,8 +5252,8 @@ function (module, exports) {*/const { OpenVibeError, isOpenVibeError } = __load(3);const { newIdempotencyKey } = __load(5);--const { appendFiles } = __load(44);--const { parseSSE } = __load(24);++const { appendFiles } = __load(45);++const { parseSSE } = __load(25);const TERMINAL = new Set(['succeeded', 'failed', 'cancelled']);const TERMINAL_EVENTS = new Set(['job.succeeded', 'job.failed', 'job.cancelled']);@@@ -5391,7 +5416,7 @@ function createJobsClient(client, { baseUrl, service = 'tools', audience = 'openmodule.exports = { createJobsClient, isTerminal, TERMINAL_STATES: [...TERMINAL] };},--// ── 44: src/core/form.js ────────────────────────────────────────────++// ── 45: src/core/form.js ────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -5425,7 +5450,7 @@ function appendFiles(form, list, where) {module.exports = { isBlob, isUpload, appendFiles };},--// ── 45: src/tools.js ────────────────────────────────────────────────++// ── 46: src/tools.js ────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -5459,8 +5484,8 @@ function (module, exports) {*/const { OpenVibeError, isOpenVibeError } = __load(3);const { newIdempotencyKey } = __load(5);--const { isUpload, appendFiles } = __load(44);--const { createJobsClient } = __load(43);++const { isUpload, appendFiles } = __load(45);++const { createJobsClient } = __load(44);const enc = encodeURIComponent;const ID_RE = /^[a-z][a-z0-9-]{0,39}$/;@@@ -5720,7 +5745,7 @@ function createToolsClient(client, { baseUrl, service = 'tools', audience = 'opemodule.exports = { createToolsClient, ToolRunError, isToolRunError };},--// ── 46: src/projects.js ─────────────────────────────────────────────++// ── 47: src/projects.js ─────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -5836,7 +5861,7 @@ function createProjectsClient(client, { baseUrl } = {}) {module.exports = { createProjectsClient };},--// ── 47: src/geo.js ──────────────────────────────────────────────────++// ── 48: src/geo.js ──────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -5915,10 +5940,10 @@ export const {createWalletClient, createClient, OpenVibeError, isOpenVibeError, paginate, offsetPager,parseTraceparent, startSpan, contextFromHeaders, ulid, newEventId, newIdempotencyKey,isActingSubjectId, satisfiesRange, compareVersions, CONTRACTS_RANGE, DEFAULT_NETWORK, SDK_VERSION,-- auth, locker, registry, trust, modules, realtime,-- media, cam, mediaUpload, ui, community, homeFeed,-- bot, search, bench, meme, vision, themes,-- design, redact, chat, ai, credentials, jobs,-- tools, projects, geo,++ auth, locker, registry, trust, levels, modules,++ realtime, media, cam, mediaUpload, ui, community,++ homeFeed, bot, search, bench, meme, vision,++ themes, design, redact, chat, ai, credentials,++ jobs, tools, projects, geo,} = sdk;export default sdk;@@@ -211,6 +211,11 @@"isTerminal"]},++ "levels": {++ "object": [++ "createLevelsClient"++ ]++ },"live": {"object": ["createLiveClient"@@@ -814,6 +819,9 @@"createJobsClient": "function","isTerminal": "function"},++ "openvibe-sdk/levels": {++ "createLevelsClient": "function"++ },"openvibe-sdk/limits": {"WINDOWS": {"object": [@@@ -6,15 +6,15 @@ export const {parseTraceparent, startSpan, contextFromHeaders, ulid, newEventId, newIdempotencyKey,isActingSubjectId, satisfiesRange, compareVersions, CONTRACTS_RANGE, DEFAULT_NETWORK, SDK_VERSION,report, share, locker, auth, registry, identity,-- trust, modules, events, realtime, media, cam,-- mediaUpload, ui, community, homeFeed, bot, search,-- bench, meme, vision, themes, design, redact,-- chat, chatApps, ai, credentials, jobs, tools,-- projects, resources, vip, quest, live, inventory,-- tips, blog, reviews, wiki, coupons, deals,-- shoes, trade, space, host, news, food,-- actor, run, video, pics, work, zone,-- git, play, download, openre, geo, usage,-- commerce, telemetry,++ trust, levels, modules, events, realtime, media,++ cam, mediaUpload, ui, community, homeFeed, bot,++ search, bench, meme, vision, themes, design,++ redact, chat, chatApps, ai, credentials, jobs,++ tools, projects, resources, vip, quest, live,++ inventory, tips, blog, reviews, wiki, coupons,++ deals, shoes, trade, space, host, news,++ food, actor, run, video, pics, work,++ zone, git, play, download, openre, geo,++ usage, commerce, telemetry,} = cjs;export default cjs;nnew file mode 100644@@@ -0,0 +1,7 @@++// Generated by scripts/esm.js from src/levels.js. Do not edit.++import cjs from '../src/levels.js';++++export const {++ createLevelsClient,++} = cjs;++export default cjs;@@@ -16,6 +16,7 @@ module.exports = {registry: require('./src/registry'),identity: require('./src/identity'),trust: require('./src/trust'),++ levels: require('./src/levels'),modules: require('./src/modules'),events: require('./src/events'),realtime: require('./src/realtime'),@@@ -1,12 +1,12 @@{"name": "openvibe-sdk",-- "version": "0.135.0",++ "version": "0.136.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "openvibe-sdk",-- "version": "0.135.0",++ "version": "0.136.0","license": "MIT","bin": {"openvibe-download": "bin/openvibe-download.js"@@@ -1,6 +1,6 @@{"name": "openvibe-sdk",-- "version": "0.135.0",++ "version": "0.136.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",@@@ -579,6 +579,11 @@"browser": "./src/wallet.js","import": "./esm/wallet.mjs","default": "./src/wallet.js"++ },++ "./levels": {++ "types": "./types/levels.d.ts",++ "import": "./esm/levels.mjs",++ "default": "./src/levels.js"}},"bin": {@@@ -26,6 +26,7 @@ const ENTRIES = {'registry.mjs': '../src/registry.js','identity.mjs': '../src/identity.js','trust.mjs': '../src/trust.js',++ 'levels.mjs': '../src/levels.js','notifications.mjs': '../src/notifications.js','modules.mjs': '../src/modules.js','events.mjs': '../src/events.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.135.0';++const SDK_VERSION = '0.136.0';module.exports = {createClient,nnew file mode 100644@@@ -0,0 +1,21 @@++'use strict';++/** Network owns experience. Reads are public; awards require network.levels.award. */++function createLevelsClient(client, { baseUrl } = {}) {++ if (!client || typeof client.json !== 'function') throw new TypeError('createLevelsClient: pass an SDK core client');++ const call = (options) => client.json({ service: 'network', audience: 'openvibe.network', baseUrl, ...options });++ return {++ get(username, { signal } = {}) {++ if (!/^[A-Za-z0-9_]{1,40}$/.test(username)) throw new TypeError('invalid username');++ return call({ path: `/api/v1/levels/people/${encodeURIComponent(username)}`, signal });++ },++ batch(subjects, { signal } = {}) {++ if (!Array.isArray(subjects) || subjects.length > 100 || subjects.some(s => !/^usr_[0-9A-HJKMNP-TV-Z]{26}$/.test(s))) throw new TypeError('batch requires up to 100 user subjects');++ return call({ path: `/api/v1/levels/batch?subjects=${encodeURIComponent(subjects.join(','))}`, signal });++ },++ board({ signal } = {}) { return call({ path: '/api/v1/levels/board', signal }); },++ award(body, { signal } = {}) {++ return call({ method: 'POST', path: '/internal/levels/award', json: body, signal, idempotencyKey: false });++ },++ };++}++module.exports = { createLevelsClient };nnew file mode 100644@@@ -0,0 +1,18 @@++'use strict';++const assert = require('assert');++const { createLevelsClient } = require('../src/levels');++(async () => {++ const calls = []; const levels = createLevelsClient({ json: async o => { calls.push(o); return { level: 1 }; } });++ const subject = 'usr_01JAB2C3D4E5F6G7H8J9K0MNP1';++ await levels.get('alice'); await levels.batch([subject]); await levels.board();++ await levels.award({ subject, reason: 'quest.completed', amount: 25, idempotency_key: 'completion:1' });++ assert.equal(calls[0].path, '/api/v1/levels/people/alice');++ assert(calls[1].path.includes(subject)); assert.equal(calls[2].path, '/api/v1/levels/board');++ assert.equal(calls[3].method, 'POST'); assert.equal(calls[3].idempotencyKey, false);++ assert(calls.every(c => c.audience === 'openvibe.network'));++ assert.throws(() => levels.batch(Array(101).fill(subject))); assert.throws(() => levels.batch(['bad']));++ assert.throws(() => levels.get('../board'));++ const refused = createLevelsClient({ json: async () => { const e = new Error('duplicate'); e.status = 409; throw e; } });++ await assert.rejects(refused.award({}), e => e.status === 409);++ console.log('levels: public reads, bounded batches and service awards passed');++})().catch(e => { console.error(e); process.exitCode = 1; });@@@ -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, 100); // openvibe-sdk/git adds the 100th subpath (0.127.0).++ assert.equal(subpaths.length, 101); // levels adds the 101st subpath.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 });@@@ -26,6 +26,7 @@ import * as projects from './projects';import * as geo from './geo';import * as locker from './locker';import * as trust from './trust';++import * as levels from './levels';import * as core from './core';export const createWalletClient: typeof import('./wallet').createWalletClient;@@@ -57,10 +58,11 @@ export * as projects from './projects';export * as geo from './geo';export * as locker from './locker';export * as trust from './trust';++export * as levels from './levels';declare const sdk: typeof core & {createWalletClient: typeof createWalletClient;auth: typeof auth; registry: typeof registry; modules: typeof modules; realtime: typeof realtime;-- media: typeof media; cam: typeof cam; mediaUpload: typeof mediaUpload; ui: typeof ui; community: typeof community; homeFeed: typeof homeFeed; 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; tools: typeof tools; projects: typeof projects; geo: typeof geo; locker: typeof locker; trust: typeof trust;++ media: typeof media; cam: typeof cam; mediaUpload: typeof mediaUpload; ui: typeof ui; community: typeof community; homeFeed: typeof homeFeed; 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; tools: typeof tools; projects: typeof projects; geo: typeof geo; locker: typeof locker; trust: typeof trust; levels: typeof levels;};export default sdk;@@@ -65,3 +65,5 @@ export const share: typeof import('./share').share;export * as locker from './locker';export const createWalletClient: typeof import('./wallet').createWalletClient;++++export * as levels from './levels';nnew file mode 100644@@@ -0,0 +1,11 @@++import type { OpenVibeClient } from './core';++export interface Level { level: number; xp: number; into: number; span: number; next_at: number; rank: number | null; recent: Array<{ name: string; at: string; amount: number }>; }++export interface Entry { subject: string; username: string; level: number; xp: number; rank: number; }++export interface Period { top: Entry[]; me: Entry | null; around: Entry[]; }++export interface Award { subject: string; reason: 'quest.completed' | 'coins.earned' | 'video.published' | 'stream.watched'; amount: number; idempotency_key: string; }++export function createLevelsClient(client: OpenVibeClient, options?: { baseUrl?: string }): {++ get(username: string, options?: { signal?: AbortSignal }): Promise<Level>;++ batch(subjects: string[], options?: { signal?: AbortSignal }): Promise<{ levels: Record<string, number> }>;++ board(options?: { signal?: AbortSignal }): Promise<{ all_time: Period; week: Period }>;++ award(body: Award, options?: { signal?: AbortSignal }): Promise<Level>;++};
@@ -1,3 +1,7 @@
@@ -1,3 +1,7 @@
+## 0.136.0 — 2026-11-09
+
+- Network levels client: public person, batch and board reads, and service awards.
+
# Changelog
# Changelog
## 0.135.0 (2026-11-10)
## 0.135.0 (2026-11-10)
@@ -13,7 +13,7 @@ npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags
@@ -13,7 +13,7 @@ npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags
> Supported browser and server clients for the OpenVibe platform.
> Supported browser and server clients for the OpenVibe platform.
-**Status:** alpha, v0.135.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.136.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.135.0
+npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.136.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).
@@ -3,7 +3,7 @@
@@ -3,7 +3,7 @@
"stage": "alpha",
"stage": "alpha",
"code": true,
"code": true,
"wave": "W2",
"wave": "W2",
- "version": "0.135.0",
+ "version": "0.136.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",
@@ -12,6 +12,7 @@ module.exports = {
@@ -12,6 +12,7 @@ module.exports = {
locker: require('./src/locker'),
locker: require('./src/locker'),
registry: require('./src/registry'),
registry: require('./src/registry'),
trust: require('./src/trust'),
trust: require('./src/trust'),
+ levels: require('./src/levels'),
modules: require('./src/modules'),
modules: require('./src/modules'),
realtime: require('./src/realtime'),
realtime: require('./src/realtime'),
media: require('./src/media'),
media: require('./src/media'),
@@ -1,6 +1,6 @@
@@ -1,6 +1,6 @@
-// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.135.0, MIT). Do not edit.
+// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.136.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, modules, realtime, media, cam, mediaUpload, ui, community, homeFeed, bot, search, bench, meme, vision, themes, design, redact, chat, ai, credentials, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity.
+// (auth, locker, registry, trust, levels, modules, realtime, media, cam, mediaUpload, ui, community, homeFeed, bot, search, bench, meme, vision, themes, design, redact, chat, ai, credentials, jobs, tools, projects, geo). 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 ──────────────────────────────────────────────────
@@ -19,29 +19,30 @@ module.exports = {
@@ -19,29 +19,30 @@ module.exports = {
locker: __load(10),
locker: __load(10),
registry: __load(21),
registry: __load(21),
trust: __load(22),
trust: __load(22),
- modules: __load(23),
- realtime: __load(24),
- media: __load(25),
- cam: __load(27),
- mediaUpload: __load(28),
- ui: __load(29),
- community: __load(30),
- homeFeed: __load(31),
- bot: __load(32),
- search: __load(33),
- bench: __load(34),
- meme: __load(35),
- vision: __load(36),
- themes: __load(37),
- design: __load(38),
- redact: __load(39),
- chat: __load(40),
- ai: __load(41),
- credentials: __load(42),
- jobs: __load(43),
- tools: __load(45),
- projects: __load(46),
- geo: __load(47),
+ levels: __load(23),
+ modules: __load(24),
+ realtime: __load(25),
+ media: __load(26),
+ cam: __load(28),
+ mediaUpload: __load(29),
+ ui: __load(30),
+ community: __load(31),
+ homeFeed: __load(32),
+ bot: __load(33),
+ search: __load(34),
+ bench: __load(35),
+ meme: __load(36),
+ vision: __load(37),
+ themes: __load(38),
+ design: __load(39),
+ redact: __load(40),
+ chat: __load(41),
+ ai: __load(42),
+ credentials: __load(43),
+ jobs: __load(44),
+ tools: __load(46),
+ projects: __load(47),
+ geo: __load(48),
};
};
},
},
// ── 1: src/core/index.js ───────────────────────────────────────────
// ── 1: src/core/index.js ───────────────────────────────────────────
@@ -56,7 +57,7 @@ const { paginate, offsetPager } = __load(7);
@@ -56,7 +57,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.135.0';
+const SDK_VERSION = '0.136.0';
module.exports = {
module.exports = {
createClient,
createClient,
@@ -2512,7 +2513,31 @@ function atLeast(signals, band) {
@@ -2512,7 +2513,31 @@ function atLeast(signals, band) {
module.exports = { createTrustClient, isNew, atLeast, AGE_BANDS };
module.exports = { createTrustClient, isNew, atLeast, AGE_BANDS };
},
},
-// ── 23: src/modules.js ──────────────────────────────────────────────
+// ── 23: src/levels.js ───────────────────────────────────────────────
+function (module, exports) {
+'use strict';
+/** Network owns experience. Reads are public; awards require network.levels.award. */
+function createLevelsClient(client, { baseUrl } = {}) {
+ if (!client || typeof client.json !== 'function') throw new TypeError('createLevelsClient: pass an SDK core client');
+ const call = (options) => client.json({ service: 'network', audience: 'openvibe.network', baseUrl, ...options });
+ return {
+ get(username, { signal } = {}) {
+ if (!/^[A-Za-z0-9_]{1,40}$/.test(username)) throw new TypeError('invalid username');
+ return call({ path: `/api/v1/levels/people/${encodeURIComponent(username)}`, signal });
+ },
+ batch(subjects, { signal } = {}) {
+ if (!Array.isArray(subjects) || subjects.length > 100 || subjects.some(s => !/^usr_[0-9A-HJKMNP-TV-Z]{26}$/.test(s))) throw new TypeError('batch requires up to 100 user subjects');
+ return call({ path: `/api/v1/levels/batch?subjects=${encodeURIComponent(subjects.join(','))}`, signal });
+ },
+ board({ signal } = {}) { return call({ path: '/api/v1/levels/board', signal }); },
+ award(body, { signal } = {}) {
+ return call({ method: 'POST', path: '/internal/levels/award', json: body, signal, idempotencyKey: false });
+ },
+ };
+}
+module.exports = { createLevelsClient };
+},
+// ── 24: src/modules.js ──────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -2591,7 +2616,7 @@ function createModulesClient(client, { baseUrl, maxAttempts = 5 } = {}) {
@@ -2591,7 +2616,7 @@ function createModulesClient(client, { baseUrl, maxAttempts = 5 } = {}) {
module.exports = { createModulesClient };
module.exports = { createModulesClient };
},
},
-// ── 24: src/realtime.js ─────────────────────────────────────────────
+// ── 25: src/realtime.js ─────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -2844,7 +2869,7 @@ function createRealtimeClient(client, defaults = {}) {
@@ -2844,7 +2869,7 @@ function createRealtimeClient(client, defaults = {}) {
module.exports = { subscribe, createRealtimeClient, parseSSE, DEFAULT_ORIGIN };
module.exports = { subscribe, createRealtimeClient, parseSSE, DEFAULT_ORIGIN };
},
},
-// ── 25: src/media.js ────────────────────────────────────────────────
+// ── 26: src/media.js ────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -2867,7 +2892,7 @@ function (module, exports) {
@@ -2867,7 +2892,7 @@ function (module, exports) {
*/
*/
const { isOpenVibeError } = __load(3);
const { isOpenVibeError } = __load(3);
const { paginate, offsetPager } = __load(7);
const { paginate, offsetPager } = __load(7);
-const { createObjectsClient } = __load(26);
+const { createObjectsClient } = __load(27);
const DEFAULT_PUBLIC_ORIGIN = 'https://openvibe.media';
const DEFAULT_PUBLIC_ORIGIN = 'https://openvibe.media';
const enc = encodeURIComponent;
const enc = encodeURIComponent;
@@ -2959,7 +2984,7 @@ function createMediaClient(client, { app, apiKey, actingUserId, baseUrl, publicO
@@ -2959,7 +2984,7 @@ function createMediaClient(client, { app, apiKey, actingUserId, baseUrl, publicO
module.exports = { createMediaClient, createObjectsClient, mediaUrls, DEFAULT_PUBLIC_ORIGIN };
module.exports = { createMediaClient, createObjectsClient, mediaUrls, DEFAULT_PUBLIC_ORIGIN };
},
},
-// ── 26: src/objects.js ──────────────────────────────────────────────
+// ── 27: src/objects.js ──────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -3279,7 +3304,7 @@ function createObjectsClient({
@@ -3279,7 +3304,7 @@ function createObjectsClient({
module.exports = { createObjectsClient };
module.exports = { createObjectsClient };
},
},
-// ── 27: src/cam/index.js ────────────────────────────────────────────
+// ── 28: src/cam/index.js ────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -3389,10 +3414,10 @@ function defineOvCamera(options = {}) {
@@ -3389,10 +3414,10 @@ function defineOvCamera(options = {}) {
module.exports = { defineOvCamera, OV_CAMERA_SRC, CAM_KIT_SRC, CAM_KIT_SRI, loadCamKit, open, settings };
module.exports = { defineOvCamera, OV_CAMERA_SRC, CAM_KIT_SRC, CAM_KIT_SRI, loadCamKit, open, settings };
},
},
-// ── 28: src/media-upload.js ─────────────────────────────────────────
+// ── 29: src/media-upload.js ─────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
-const { createObjectsClient } = __load(25);
+const { createObjectsClient } = __load(26);
const MIB = 1024 * 1024;
const MIB = 1024 * 1024;
/** Media's resumable multipart transport, configured for 8 MiB parts and three in flight. */
/** Media's resumable multipart transport, configured for 8 MiB parts and three in flight. */
@@ -3409,7 +3434,7 @@ function createUploadClient(config) {
@@ -3409,7 +3434,7 @@ function createUploadClient(config) {
module.exports = { createUploadClient };
module.exports = { createUploadClient };
},
},
-// ── 29: src/ui.js ───────────────────────────────────────────────────
+// ── 30: src/ui.js ───────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
@@ -3422,7 +3447,7 @@ function progress(el, options) {
@@ -3422,7 +3447,7 @@ function progress(el, options) {
module.exports = { progress };
module.exports = { progress };
},
},
-// ── 30: src/community.js ────────────────────────────────────────────
+// ── 31: src/community.js ────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -3562,7 +3587,7 @@ function createCommunityClient(client, defaults = {}) {
@@ -3562,7 +3587,7 @@ function createCommunityClient(client, defaults = {}) {
module.exports = { createCommunityClient, actingHeaders };
module.exports = { createCommunityClient, actingHeaders };
},
},
-// ── 31: src/home-feed.js ────────────────────────────────────────────
+// ── 32: src/home-feed.js ────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/** The menu's portable Home layout, network day counts and personal wall. Pass a user-token core client;
/** The menu's portable Home layout, network day counts and personal wall. Pass a user-token core client;
@@ -3589,7 +3614,7 @@ function createHomeFeedClient(client, { networkBaseUrl, communityBaseUrl } = {})
@@ -3589,7 +3614,7 @@ function createHomeFeedClient(client, { networkBaseUrl, communityBaseUrl } = {})
module.exports = { createHomeFeedClient };
module.exports = { createHomeFeedClient };
},
},
-// ── 32: src/bot.js ──────────────────────────────────────────────────
+// ── 33: src/bot.js ──────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -3811,7 +3836,7 @@ function createBotClient(client, defaults = {}) {
@@ -3811,7 +3836,7 @@ function createBotClient(client, defaults = {}) {
module.exports = { createBotClient, actingHeaders };
module.exports = { createBotClient, actingHeaders };
},
},
-// ── 33: src/search.js ───────────────────────────────────────────────
+// ── 34: src/search.js ───────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -3924,7 +3949,7 @@ function createSearchClient(client, defaults = {}) {
@@ -3924,7 +3949,7 @@ function createSearchClient(client, defaults = {}) {
module.exports = { createSearchClient, queryOf, fabricOf };
module.exports = { createSearchClient, queryOf, fabricOf };
},
},
-// ── 34: src/bench.js ────────────────────────────────────────────────
+// ── 35: 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. */
@@ -4025,7 +4050,7 @@ function createBenchClient(client, defaults = {}) {
@@ -4025,7 +4050,7 @@ function createBenchClient(client, defaults = {}) {
module.exports = { createBenchClient };
module.exports = { createBenchClient };
},
},
-// ── 35: src/meme.js ─────────────────────────────────────────────────
+// ── 36: src/meme.js ─────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -4108,7 +4133,7 @@ function createMemeClient(client, defaults = {}) {
@@ -4108,7 +4133,7 @@ function createMemeClient(client, defaults = {}) {
module.exports = { createMemeClient };
module.exports = { createMemeClient };
},
},
-// ── 36: src/vision.js ───────────────────────────────────────────────
+// ── 37: src/vision.js ───────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -4266,7 +4291,7 @@ function pick(o, keys) {
@@ -4266,7 +4291,7 @@ function pick(o, keys) {
module.exports = { createVisionClient, DEFAULT_AUDIENCE };
module.exports = { createVisionClient, DEFAULT_AUDIENCE };
},
},
-// ── 37: src/themes.js ───────────────────────────────────────────────
+// ── 38: src/themes.js ───────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -4416,7 +4441,7 @@ function followTheme(fn, opts = {}) {
@@ -4416,7 +4441,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 };
},
},
-// ── 38: src/design.js ───────────────────────────────────────────────
+// ── 39: src/design.js ───────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
@@ -4483,7 +4508,7 @@ function createDesignClient({ accessToken = null, baseUrl = DEFAULT_DESIGN_URL,
@@ -4483,7 +4508,7 @@ function createDesignClient({ accessToken = null, baseUrl = DEFAULT_DESIGN_URL,
module.exports = { createDesignClient, DEFAULT_DESIGN_URL };
module.exports = { createDesignClient, DEFAULT_DESIGN_URL };
},
},
-// ── 39: src/redact.js ───────────────────────────────────────────────
+// ── 40: src/redact.js ───────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -4730,7 +4755,7 @@ function onlySecret(text) {
@@ -4730,7 +4755,7 @@ function onlySecret(text) {
module.exports = { redact, onlySecret };
module.exports = { redact, onlySecret };
},
},
-// ── 40: src/chat.js ─────────────────────────────────────────────────
+// ── 41: src/chat.js ─────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -4981,7 +5006,7 @@ function createFeedPublisher(client, { feed, key, baseUrl } = {}) {
@@ -4981,7 +5006,7 @@ function createFeedPublisher(client, { feed, key, baseUrl } = {}) {
module.exports = { createChatClient, createInboxVisitor, createFeedPublisher };
module.exports = { createChatClient, createInboxVisitor, createFeedPublisher };
},
},
-// ── 41: src/ai.js ───────────────────────────────────────────────────
+// ── 42: src/ai.js ───────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -5117,7 +5142,7 @@ function createAiClient(client, defaults = {}) {
@@ -5117,7 +5142,7 @@ function createAiClient(client, defaults = {}) {
};
};
// Files live in Media; turns carry only their Media object references.
// Files live in Media; turns carry only their Media object references.
- const fileObjects = defaults.objectsClient || (defaults.media ? __load(26).createObjectsClient(defaults.media) : null);
+ const fileObjects = defaults.objectsClient || (defaults.media ? __load(27).createObjectsClient(defaults.media) : null);
const requireFiles = (method) => { if (!fileObjects) throw new TypeError(`ai.files.${method}: configure defaults.media or defaults.objectsClient`); };
const requireFiles = (method) => { if (!fileObjects) throw new TypeError(`ai.files.${method}: configure defaults.media or defaults.objectsClient`); };
const files = {
const files = {
async attach(data, { filename, mediaType, subject, signal, ...options } = {}) {
async attach(data, { filename, mediaType, subject, signal, ...options } = {}) {
@@ -5171,7 +5196,7 @@ function createAiClient(client, defaults = {}) {
@@ -5171,7 +5196,7 @@ function createAiClient(client, defaults = {}) {
module.exports = { createAiClient, TERMINAL, OPS, CLASSES };
module.exports = { createAiClient, TERMINAL, OPS, CLASSES };
},
},
-// ── 42: src/credentials.js ──────────────────────────────────────────
+// ── 43: src/credentials.js ──────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
@@ -5189,7 +5214,7 @@ function createCredentialsClient(client, defaults = {}) {
@@ -5189,7 +5214,7 @@ function createCredentialsClient(client, defaults = {}) {
module.exports = { createCredentialsClient };
module.exports = { createCredentialsClient };
},
},
-// ── 43: src/jobs.js ─────────────────────────────────────────────────
+// ── 44: src/jobs.js ─────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -5227,8 +5252,8 @@ function (module, exports) {
@@ -5227,8 +5252,8 @@ function (module, exports) {
*/
*/
const { OpenVibeError, isOpenVibeError } = __load(3);
const { OpenVibeError, isOpenVibeError } = __load(3);
const { newIdempotencyKey } = __load(5);
const { newIdempotencyKey } = __load(5);
-const { appendFiles } = __load(44);
-const { parseSSE } = __load(24);
+const { appendFiles } = __load(45);
+const { parseSSE } = __load(25);
const TERMINAL = new Set(['succeeded', 'failed', 'cancelled']);
const TERMINAL = new Set(['succeeded', 'failed', 'cancelled']);
const TERMINAL_EVENTS = new Set(['job.succeeded', 'job.failed', 'job.cancelled']);
const TERMINAL_EVENTS = new Set(['job.succeeded', 'job.failed', 'job.cancelled']);
@@ -5391,7 +5416,7 @@ function createJobsClient(client, { baseUrl, service = 'tools', audience = 'open
@@ -5391,7 +5416,7 @@ function createJobsClient(client, { baseUrl, service = 'tools', audience = 'open
module.exports = { createJobsClient, isTerminal, TERMINAL_STATES: [...TERMINAL] };
module.exports = { createJobsClient, isTerminal, TERMINAL_STATES: [...TERMINAL] };
},
},
-// ── 44: src/core/form.js ────────────────────────────────────────────
+// ── 45: src/core/form.js ────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -5425,7 +5450,7 @@ function appendFiles(form, list, where) {
@@ -5425,7 +5450,7 @@ function appendFiles(form, list, where) {
module.exports = { isBlob, isUpload, appendFiles };
module.exports = { isBlob, isUpload, appendFiles };
},
},
-// ── 45: src/tools.js ────────────────────────────────────────────────
+// ── 46: src/tools.js ────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -5459,8 +5484,8 @@ function (module, exports) {
@@ -5459,8 +5484,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(44);
-const { createJobsClient } = __load(43);
+const { isUpload, appendFiles } = __load(45);
+const { createJobsClient } = __load(44);
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}$/;
@@ -5720,7 +5745,7 @@ function createToolsClient(client, { baseUrl, service = 'tools', audience = 'ope
@@ -5720,7 +5745,7 @@ function createToolsClient(client, { baseUrl, service = 'tools', audience = 'ope
module.exports = { createToolsClient, ToolRunError, isToolRunError };
module.exports = { createToolsClient, ToolRunError, isToolRunError };
},
},
-// ── 46: src/projects.js ─────────────────────────────────────────────
+// ── 47: src/projects.js ─────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -5836,7 +5861,7 @@ function createProjectsClient(client, { baseUrl } = {}) {
@@ -5836,7 +5861,7 @@ function createProjectsClient(client, { baseUrl } = {}) {
module.exports = { createProjectsClient };
module.exports = { createProjectsClient };
},
},
-// ── 47: src/geo.js ──────────────────────────────────────────────────
+// ── 48: src/geo.js ──────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -5915,10 +5940,10 @@ export const {
@@ -5915,10 +5940,10 @@ 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,
- auth, locker, registry, trust, modules, realtime,
- media, cam, mediaUpload, ui, community, homeFeed,
- bot, search, bench, meme, vision, themes,
- design, redact, chat, ai, credentials, jobs,
- tools, projects, geo,
+ auth, locker, registry, trust, levels, modules,
+ realtime, media, cam, mediaUpload, ui, community,
+ homeFeed, bot, search, bench, meme, vision,
+ themes, design, redact, chat, ai, credentials,
+ jobs, tools, projects, geo,
} = sdk;
} = sdk;
export default sdk;
export default sdk;
@@ -211,6 +211,11 @@
@@ -211,6 +211,11 @@
"isTerminal"
"isTerminal"
]
]
},
},
+ "levels": {
+ "object": [
+ "createLevelsClient"
+ ]
+ },
"live": {
"live": {
"object": [
"object": [
"createLiveClient"
"createLiveClient"
@@ -814,6 +819,9 @@
@@ -814,6 +819,9 @@
"createJobsClient": "function",
"createJobsClient": "function",
"isTerminal": "function"
"isTerminal": "function"
},
},
+ "openvibe-sdk/levels": {
+ "createLevelsClient": "function"
+ },
"openvibe-sdk/limits": {
"openvibe-sdk/limits": {
"WINDOWS": {
"WINDOWS": {
"object": [
"object": [
@@ -6,15 +6,15 @@ export const {
@@ -6,15 +6,15 @@ export const {
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,
report, share, locker, auth, registry, identity,
- trust, modules, events, realtime, media, cam,
- mediaUpload, ui, community, homeFeed, bot, search,
- bench, meme, vision, themes, design, redact,
- chat, chatApps, ai, credentials, jobs, tools,
- projects, resources, vip, quest, live, inventory,
- tips, blog, reviews, wiki, coupons, deals,
- shoes, trade, space, host, news, food,
- actor, run, video, pics, work, zone,
- git, play, download, openre, geo, usage,
- commerce, telemetry,
+ trust, levels, modules, events, realtime, media,
+ cam, mediaUpload, ui, community, homeFeed, bot,
+ search, bench, meme, vision, themes, design,
+ redact, chat, chatApps, ai, credentials, jobs,
+ tools, projects, resources, vip, quest, live,
+ inventory, tips, blog, reviews, wiki, coupons,
+ deals, shoes, trade, space, host, news,
+ food, actor, run, video, pics, work,
+ zone, git, play, download, openre, geo,
+ usage, commerce, telemetry,
} = 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/levels.js. Do not edit.
+import cjs from '../src/levels.js';
+
+export const {
+ createLevelsClient,
+} = cjs;
+export default cjs;
@@ -16,6 +16,7 @@ module.exports = {
@@ -16,6 +16,7 @@ module.exports = {
registry: require('./src/registry'),
registry: require('./src/registry'),
identity: require('./src/identity'),
identity: require('./src/identity'),
trust: require('./src/trust'),
trust: require('./src/trust'),
+ levels: require('./src/levels'),
modules: require('./src/modules'),
modules: require('./src/modules'),
events: require('./src/events'),
events: require('./src/events'),
realtime: require('./src/realtime'),
realtime: require('./src/realtime'),
@@ -1,12 +1,12 @@
@@ -1,12 +1,12 @@
{
{
"name": "openvibe-sdk",
"name": "openvibe-sdk",
- "version": "0.135.0",
+ "version": "0.136.0",
"lockfileVersion": 3,
"lockfileVersion": 3,
"requires": true,
"requires": true,
"packages": {
"packages": {
"": {
"": {
"name": "openvibe-sdk",
"name": "openvibe-sdk",
- "version": "0.135.0",
+ "version": "0.136.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.135.0",
+ "version": "0.136.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",
@@ -579,6 +579,11 @@
@@ -579,6 +579,11 @@
"browser": "./src/wallet.js",
"browser": "./src/wallet.js",
"import": "./esm/wallet.mjs",
"import": "./esm/wallet.mjs",
"default": "./src/wallet.js"
"default": "./src/wallet.js"
+ },
+ "./levels": {
+ "types": "./types/levels.d.ts",
+ "import": "./esm/levels.mjs",
+ "default": "./src/levels.js"
}
}
},
},
"bin": {
"bin": {
@@ -26,6 +26,7 @@ const ENTRIES = {
@@ -26,6 +26,7 @@ const ENTRIES = {
'registry.mjs': '../src/registry.js',
'registry.mjs': '../src/registry.js',
'identity.mjs': '../src/identity.js',
'identity.mjs': '../src/identity.js',
'trust.mjs': '../src/trust.js',
'trust.mjs': '../src/trust.js',
+ 'levels.mjs': '../src/levels.js',
'notifications.mjs': '../src/notifications.js',
'notifications.mjs': '../src/notifications.js',
'modules.mjs': '../src/modules.js',
'modules.mjs': '../src/modules.js',
'events.mjs': '../src/events.js',
'events.mjs': '../src/events.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.135.0';
+const SDK_VERSION = '0.136.0';
module.exports = {
module.exports = {
createClient,
createClient,
new file mode 100644
new file mode 100644
@@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
+'use strict';
+/** Network owns experience. Reads are public; awards require network.levels.award. */
+function createLevelsClient(client, { baseUrl } = {}) {
+ if (!client || typeof client.json !== 'function') throw new TypeError('createLevelsClient: pass an SDK core client');
+ const call = (options) => client.json({ service: 'network', audience: 'openvibe.network', baseUrl, ...options });
+ return {
+ get(username, { signal } = {}) {
+ if (!/^[A-Za-z0-9_]{1,40}$/.test(username)) throw new TypeError('invalid username');
+ return call({ path: `/api/v1/levels/people/${encodeURIComponent(username)}`, signal });
+ },
+ batch(subjects, { signal } = {}) {
+ if (!Array.isArray(subjects) || subjects.length > 100 || subjects.some(s => !/^usr_[0-9A-HJKMNP-TV-Z]{26}$/.test(s))) throw new TypeError('batch requires up to 100 user subjects');
+ return call({ path: `/api/v1/levels/batch?subjects=${encodeURIComponent(subjects.join(','))}`, signal });
+ },
+ board({ signal } = {}) { return call({ path: '/api/v1/levels/board', signal }); },
+ award(body, { signal } = {}) {
+ return call({ method: 'POST', path: '/internal/levels/award', json: body, signal, idempotencyKey: false });
+ },
+ };
+}
+module.exports = { createLevelsClient };
new file mode 100644
new file mode 100644
@@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
+'use strict';
+const assert = require('assert');
+const { createLevelsClient } = require('../src/levels');
+(async () => {
+ const calls = []; const levels = createLevelsClient({ json: async o => { calls.push(o); return { level: 1 }; } });
+ const subject = 'usr_01JAB2C3D4E5F6G7H8J9K0MNP1';
+ await levels.get('alice'); await levels.batch([subject]); await levels.board();
+ await levels.award({ subject, reason: 'quest.completed', amount: 25, idempotency_key: 'completion:1' });
+ assert.equal(calls[0].path, '/api/v1/levels/people/alice');
+ assert(calls[1].path.includes(subject)); assert.equal(calls[2].path, '/api/v1/levels/board');
+ assert.equal(calls[3].method, 'POST'); assert.equal(calls[3].idempotencyKey, false);
+ assert(calls.every(c => c.audience === 'openvibe.network'));
+ assert.throws(() => levels.batch(Array(101).fill(subject))); assert.throws(() => levels.batch(['bad']));
+ assert.throws(() => levels.get('../board'));
+ const refused = createLevelsClient({ json: async () => { const e = new Error('duplicate'); e.status = 409; throw e; } });
+ await assert.rejects(refused.award({}), e => e.status === 409);
+ console.log('levels: public reads, bounded batches and service awards passed');
+})().catch(e => { console.error(e); process.exitCode = 1; });
@@ -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, 100); // openvibe-sdk/git adds the 100th subpath (0.127.0).
+ assert.equal(subpaths.length, 101); // levels adds the 101st subpath.
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 });
@@ -26,6 +26,7 @@ import * as projects from './projects';
@@ -26,6 +26,7 @@ import * as projects from './projects';
import * as geo from './geo';
import * as geo from './geo';
import * as locker from './locker';
import * as locker from './locker';
import * as trust from './trust';
import * as trust from './trust';
+import * as levels from './levels';
import * as core from './core';
import * as core from './core';
export const createWalletClient: typeof import('./wallet').createWalletClient;
export const createWalletClient: typeof import('./wallet').createWalletClient;
@@ -57,10 +58,11 @@ export * as projects from './projects';
@@ -57,10 +58,11 @@ export * as projects from './projects';
export * as geo from './geo';
export * as geo from './geo';
export * as locker from './locker';
export * as locker from './locker';
export * as trust from './trust';
export * as trust from './trust';
+export * as levels from './levels';
declare const sdk: typeof core & {
declare const sdk: typeof core & {
createWalletClient: typeof createWalletClient;
createWalletClient: typeof createWalletClient;
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; cam: typeof cam; mediaUpload: typeof mediaUpload; ui: typeof ui; community: typeof community; homeFeed: typeof homeFeed; 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; tools: typeof tools; projects: typeof projects; geo: typeof geo; locker: typeof locker; trust: typeof trust;
+ media: typeof media; cam: typeof cam; mediaUpload: typeof mediaUpload; ui: typeof ui; community: typeof community; homeFeed: typeof homeFeed; 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; tools: typeof tools; projects: typeof projects; geo: typeof geo; locker: typeof locker; trust: typeof trust; levels: typeof levels;
};
};
export default sdk;
export default sdk;
@@ -65,3 +65,5 @@ export const share: typeof import('./share').share;
@@ -65,3 +65,5 @@ export const share: typeof import('./share').share;
export * as locker from './locker';
export * as locker from './locker';
export const createWalletClient: typeof import('./wallet').createWalletClient;
export const createWalletClient: typeof import('./wallet').createWalletClient;
+
+export * as levels from './levels';
new file mode 100644
new file mode 100644
@@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
+import type { OpenVibeClient } from './core';
+export interface Level { level: number; xp: number; into: number; span: number; next_at: number; rank: number | null; recent: Array<{ name: string; at: string; amount: number }>; }
+export interface Entry { subject: string; username: string; level: number; xp: number; rank: number; }
+export interface Period { top: Entry[]; me: Entry | null; around: Entry[]; }
+export interface Award { subject: string; reason: 'quest.completed' | 'coins.earned' | 'video.published' | 'stream.watched'; amount: number; idempotency_key: string; }
+export function createLevelsClient(client: OpenVibeClient, options?: { baseUrl?: string }): {
+ get(username: string, options?: { signal?: AbortSignal }): Promise<Level>;
+ batch(subjects: string[], options?: { signal?: AbortSignal }): Promise<{ levels: Record<string, number> }>;
+ board(options?: { signal?: AbortSignal }): Promise<{ all_time: Period; week: Period }>;
+ award(body: Award, options?: { signal?: AbortSignal }): Promise<Level>;
+};