openvibers/openvibe.sdk Commits

0.56.0: openvibe-sdk/blog, OpenVibe.Blog for apps (posts and feed; create, edit, publish, schedule, revert and delete for the person who authorized the app) (#67)

OP OpenVibers committed 24 days ago · 07fb95cd57 · 17 files, +188 −22

Changes

ddiff --git a/CHANGELOG.md b/CHANGELOG.md
iindex 25918c5..50f94e9 100644
---- a/CHANGELOG.md
++++ b/CHANGELOG.md
@@@ -3,6 +3,14 @@
All notable changes to `openvibe-sdk`. The package follows semver; while it is `0.x`, a minor
release may change an API and says so here.
++## 0.56.0 (2026-10-20)
++
++- **`openvibe-sdk/blog`** (`createBlogClient`): OpenVibe.Blog, the first product whose API only its own site could use
++ (its capabilities became public in openvibe-contracts 0.206.0). Read a blog's published posts and feed; for the
++ person who authorized the app, create drafts, edit (a new revision, `expected_revision` guards a race), publish,
++ unpublish, schedule, revert and delete posts. Blog acts for an app only as its `on_behalf_of` person. Creating a
++ post or reverting makes a new one each time and is never retried on its own.
++
## 0.55.0 (2026-10-20)
- Six more products through the SDK, each a server module over the routes its capabilities name in Contracts:
ddiff --git a/README.md b/README.md
iindex 9f2035f..77eb5e0 100644
---- a/README.md
++++ b/README.md
@@@ -2,14 +2,14 @@
> Supported browser and server clients for the OpenVibe platform.
--**Status:** alpha, v0.55.0 (roadmap Wave 2; developer apps from Wave 20; Media objects v2 from Wave 4; the Tools platform API; Search, Chat and AI clients from WS-F task 4; per-actor limits from WS-R task 4). 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.56.0 (roadmap Wave 2; developer apps from Wave 20; Media objects v2 from Wave 4; the Tools platform API; Search, Chat and AI clients from WS-F task 4; per-actor limits from WS-R task 4). 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.
**If a capability is not in the SDK, it is not public.** Apps call services through `openvibe-sdk` and never build internal routes themselves. A route with no SDK wrapper is internal, even when you can reach it, and it can change without notice. To make a capability public, first define it in OpenVibe.Contracts, then wrap it here.
```bash
--npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.55.0
++npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.56.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 Contracts v0.86.0, a devDependency the tests check them against).
@@@ -190,6 +190,7 @@ Until OpenVibe.Tools serves the gateway facade (Tools S6), point the jobs client
| `openvibe-sdk/live` | server | `createLiveClient(client)`: OpenVibe.Live's documented routes. `streams.list/get/recentlyOnline/mine/update/end/heartbeat/endpoint`, `slots.list/create/update/remove/regenerateKey` (a slot is a saved setup with its own stream key), `goLive(slotId, {title, category, tags})` → `{ stream, endpoint }`, `channels.get/mine/update/toggleFollow/url`, `content.feed/moments({type, sort, window, cursor, limit})`; WHIP: `whip.url(streamKey)`, `whip.publish(url, offerSdp, {key?})` → `{ answer, location }` (the client's own token never goes to `/whip`), `whip.end(location)`. Writes are never retried |
| `openvibe-sdk/inventory` | server | `createInventoryClient(client)`: OpenVibe.Inventory, the network-wide inventory (ADR-054). Public reads: `kinds.list/get`, `definitions.list({kind, issuer})/get`, `people.items(subject)`, `people.equipped(subject)`, `equipped([subjects])` (≤ 100, for chat renders). The person's own: `me.items()`, `me.equip({kind, slot, instance_id | null})`. An issuer's: `definitions.create/update`, `grants.create({definition_id, subject, idempotency_key})` → `{ instance, created }` (retry-safe on the key), `instances.consume/revoke`. `forPerson(usr_…)` sends `X-OV-Subject` for a service acting for a person. Audience `openvibe.inventory` |
| `openvibe-sdk/tips` | server | `createTipsClient(client)`: OpenVibe.Tips' `/api/v1`. A creator's page: `profiles.get/update/totals/sounds/supporters`. Tipping: `tip({creator, amount, message?, goal_id?, pay_with})` → `{ interaction, checkout_url, checkout_ref }`, `send.message/tts/media/sound`. Receipts: `interactions.get/list/recordExternal/hide/restore`. `goals.list/get/create/update/close`, `moderation.queue/log/moderators.*`, `overlays.tokens.*/configs.*/simulate`, `me.export/erase`. Every write carries an Idempotency-Key, which Tips replays once, so retries are safe. Audience `openvibe.tips` |
++| `openvibe-sdk/blog` | server | `createBlogClient(client)`: OpenVibe.Blog for the person who authorized the app. `blogs.get/posts(handle, {limit, offset, all})/feed` (JSON Feed), `posts.create(handle, {title, body, summary, visibility, …})` → `{ post, revision }`, `posts.get/update(id, {…, expected_revision})/publish(id, {revision})/unpublish/schedule(id, {at, revision, action})/cancelSchedule/revert/remove/revisions/revision(id, n)`. Public capabilities since openvibe-contracts 0.206.0; publish, unpublish, schedule and delete are sensitive. Creating and reverting are never retried on their own. Audience `openvibe.blog` |
| `openvibe-sdk/food` | server | `createFoodClient(client)`: OpenVibe.Food. Public: `places({kind, q, lat, lon, radius})` (food banks, pantries, free meals from OpenStreetMap), `foods.list/get` (the food list with store prices). The caller's own: `plans.create({people, days, budget, title})/list/get` (deterministic meal plans with a shopping list and costs), `pantry.get/set(items)` (with "what can I make" matches), `recipes.suggest({ask, people})/list` (AI recipe ideas, 10 a day). Plans and recipe ideas are never retried on their own. Audience `openvibe.food` |
| `openvibe-sdk/actor` | server | `createActorClient(client)`: OpenVibe.Actor. `agents.list()` and `route({task, mode})` (a dry run) are public. `tasks.create({task, mode, budget, agent, idempotency_key, webhooks})` (retried only with an idempotency_key; `webhook_secret` comes back once), `tasks.list/get/cancel`, `tasks.events(id, {lastEventId})` (SSE until the task ends). A person's own agents: `me.agents.list/create/get/update/remove/run/runs` and `me.agents.memory.list/add/update/remove/clear`. Audience `openvibe.actor` |
| `openvibe-sdk/run` | server | `createRunClient(client, {project?})`: OpenVibe.Run, jobs on worker nodes. `jobs.submit({class, artifact, args, limits, …})` (Idempotency-Key, so retried safely) → `{ created, job }`, `jobs.list({state, limit, cursor})`, `jobs.get/cancel`, `jobs.events(id, {lastEventId})` (SSE until `end`), `jobs.streamTicket(id)` (a one-use URL for a browser's EventSource); `forProject(prj_…)` sends X-OV-Project. Audience `openvibe.run` |
@@@ -476,7 +477,7 @@ Install the drivers the service uses: `pg` and `iovalkey` (production), `@electr
- **Media:** the v1 files API, the object API v2 (`createObjectsClient`) and the public URL helpers are wrapped. Retention holds on v2 objects are not (app keys only). VOD, clip, thumbnail and admin-storage routes are not wrapped because apps reach them only through Live and Media's own servers. Media's own paste API is not wrapped because pastes moved to Community (ADR-011). The mock platform (`openvibe-sdk/testing`) models Media's v1 files only, not v2 objects.
- **Media from the browser:** Media refuses user JWTs on `/api/v1/:app/files`, so a browser uploads through its own app server. That server holds the app key and names the user with `actingUserId`.
- **Network coins, notifications and legacy-map writes** are internal service-to-service routes with no public capability, so they are not wrapped. Staff-only paste routes are also internal: admin stats, bulk, censor and the AI pass.
--- **Billing and Games** from the original charter come when those services publish their capabilities in Contracts (Live has its module since v0.52.0). Products whose capabilities are all first-party (Blog, Coupons, Deals, News, Reviews, Space, Trade, Watch, Wiki and others) have no module yet: there is nothing an outside app may call. Chat is wrapped over REST as the token's person (`openvibe-sdk/chat`, v0.11.0), but it has no app principal (`chat.message.send` is `first-party`) and the mock platform has no Chat.
++- **Billing and Games** from the original charter come when those services publish their capabilities in Contracts (Live has its module since v0.52.0). Products whose capabilities are all first-party (Coupons, Deals, News, Reviews, Space, Trade, Watch, Wiki and others) have no module yet: there is nothing an outside app may call. Blog was the first to open its posts to apps (openvibe-contracts 0.206.0, `openvibe-sdk/blog`). Chat is wrapped over REST as the token's person (`openvibe-sdk/chat`, v0.11.0), but it has no app principal (`chat.message.send` is `first-party`) and the mock platform has no Chat.
- **Tools** are not wrapped one by one: `openvibe-sdk/tools` runs any tool with `api: true` by id, and its descriptor (`tools.get(id)`) gives the input schema, files and limits. `openvibe-sdk/jobs` still submits any job `type` directly. The YouTube downloader is page-only (`api: false`), so it is not in the SDK.
- **Realtime over WebSocket and presence** don't exist in Events yet (ADR-005). SSE is the only transport.
- **Bot:** the REST robots, public kits/profiles and pairing routes are wrapped (`openvibe-sdk/bot`). The operator WebSocket (`/control`, Realtime frames `bot.command@1`), device bootstrap (`POST /devices/bind`, a Network node token) and the internal Run→Bot job dispatch (`bot.job.dispatch`, service-to-service and never delegated to people or apps) are not.
ddiff --git a/STATUS.json b/STATUS.json
iindex ed0ac6c..8694227 100644
---- a/STATUS.json
++++ b/STATUS.json
@@@ -3,7 +3,7 @@
"stage": "alpha",
"code": true,
"wave": "W2",
-- "version": "0.55.0",
++ "version": "0.56.0",
"plan": "OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), §3.2; roadmap §30",
"deployed": false,
"deployment": "none: a package released as git tags; services and apps pin a tag",
ddiff --git a/browser/openvibe-sdk.mjs b/browser/openvibe-sdk.mjs
iindex b3320ca..0a62d6f 100644
---- a/browser/openvibe-sdk.mjs
++++ b/browser/openvibe-sdk.mjs
@@@ -1,4 +1,4 @@
--// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.55.0, MIT). Do not edit.
++// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.56.0, MIT). Do not edit.
// One self-contained ES module: core at the top level plus the browser-safe subpaths as namespaces
// (auth, registry, modules, realtime, media, community, bot, search, chat, ai, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity.
/* eslint-disable */
@@@ -42,7 +42,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.55.0';
++const SDK_VERSION = '0.56.0';
module.exports = {
createClient,
ddiff --git a/esm/blog.mjs b/esm/blog.mjs
nnew file mode 100644
iindex 0000000..7284d78
---- /dev/null
++++ b/esm/blog.mjs
@@@ -0,0 +1,7 @@
++// Generated by scripts/esm.js from src/blog.js. Do not edit.
++import cjs from '../src/blog.js';
++
++export const {
++ createBlogClient,
++} = cjs;
++export default cjs;
ddiff --git a/esm/index.mjs b/esm/index.mjs
iindex 041b4f1..e1a07c4 100644
---- a/esm/index.mjs
++++ b/esm/index.mjs
@@@ -8,8 +8,8 @@ export const {
registry, identity, modules, events, realtime, media,
community, bot, search, chat, ai, jobs,
tools, projects, resources, vip, quest, live,
-- inventory, tips, food, actor, run, video,
-- work, zone, play, download, openre, geo,
-- usage, commerce, telemetry,
++ inventory, tips, blog, food, actor, run,
++ video, work, zone, play, download, openre,
++ geo, usage, commerce, telemetry,
} = cjs;
export default cjs;
ddiff --git a/index.js b/index.js
iindex dbf5af5..b9749f5 100644
---- a/index.js
++++ b/index.js
@@@ -29,6 +29,7 @@ module.exports = {
live: require('./src/live'),
inventory: require('./src/inventory'),
tips: require('./src/tips'),
++ blog: require('./src/blog'),
food: require('./src/food'),
actor: require('./src/actor'),
run: require('./src/run'),
ddiff --git a/package-lock.json b/package-lock.json
iindex d1a30f6..cd7eccc 100644
---- a/package-lock.json
++++ b/package-lock.json
@@@ -1,12 +1,12 @@
{
"name": "openvibe-sdk",
-- "version": "0.55.0",
++ "version": "0.56.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "openvibe-sdk",
-- "version": "0.55.0",
++ "version": "0.56.0",
"license": "MIT",
"bin": {
"openvibe-download": "bin/openvibe-download.js"
ddiff --git a/package.json b/package.json
iindex b200806..19ed1a0 100644
---- a/package.json
++++ b/package.json
@@@ -1,6 +1,6 @@
{
"name": "openvibe-sdk",
-- "version": "0.55.0",
++ "version": "0.56.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",
@@@ -272,6 +272,12 @@
"import": "./esm/tips.mjs",
"default": "./src/tips.js"
},
++ "./blog": {
++ "types": "./types/blog.d.ts",
++ "browser": null,
++ "import": "./esm/blog.mjs",
++ "default": "./src/blog.js"
++ },
"./food": {
"types": "./types/food.d.ts",
"browser": null,
ddiff --git a/scripts/esm.js b/scripts/esm.js
iindex 50892c2..d47205e 100644
---- a/scripts/esm.js
++++ b/scripts/esm.js
@@@ -58,6 +58,7 @@ const ENTRIES = {
'live.mjs': '../src/live.js',
'inventory.mjs': '../src/inventory.js',
'tips.mjs': '../src/tips.js',
++ 'blog.mjs': '../src/blog.js',
'food.mjs': '../src/food.js',
'actor.mjs': '../src/actor.js',
'run.mjs': '../src/run.js',
ddiff --git a/src/blog.js b/src/blog.js
nnew file mode 100644
iindex 0000000..dbcf670
---- /dev/null
++++ b/src/blog.js
@@@ -0,0 +1,80 @@
++'use strict';
++/**
++ * openvibe-sdk/blog — OpenVibe.Blog for apps: read a blog's published posts and feed, and write posts on a blog the
++ * person belongs to: drafts, revisions, publishing (now or scheduled), unpublishing and deleting. Routes at
++ * https://openvibe.blog/api/v1; tokens for audience openvibe.blog. A developer app acts only for the person who
++ * authorized it (its token's on_behalf_of): Blog refuses any other X-OV-Subject, and sandbox tokens.
++ *
++ * const blog = createBlogClient(createClient({ tokenProvider }));
++ * const { posts, total } = await blog.blogs.posts('goosely', { limit: 10 }); // published, public
++ * const { post } = await blog.posts.create('goosely', { title: 'Tonight on stream', body: '…', visibility: 'public' });
++ * await blog.posts.update(post.id, { body: '… (edited)', expected_revision: 1 }); // a new revision
++ * await blog.posts.publish(post.id); // the latest revision
++ * await blog.posts.schedule(post.id, { at: '2026-10-21T18:00:00Z' });
++ * const feed = await blog.blogs.feed('goosely'); // JSON Feed 1.1
++ *
++ * Capabilities (public since openvibe-contracts 0.206.0): blog.feed.read, blog.post.read, .create, .update, .publish,
++ * .unpublish, .schedule and .delete; publishing, unpublishing, scheduling and deleting are sensitive. Creating a post
++ * or reverting makes a new one each time and is never retried on its own; publishing, unpublishing, scheduling, edits
++ * (Blog keeps an identical edit as the same revision) and deletes are.
++ * Errors are OpenVibeError: blog.not_found, blog.forbidden, post.not_found, post.members_only, revision.conflict,
++ * revision.expected_required, post.review_required (an AI draft a person has not reviewed), capability.denied,
++ * subject.not_delegated, …
++ */
++const enc = encodeURIComponent;
++const POST_ID_RE = /^pst_[0-9A-HJKMNP-TV-Z]{26}$/; // Blog's own rule
++const HANDLE_RE = /^[a-z0-9][a-z0-9_-]{0,63}$/i;
++
++function createBlogClient(client, { baseUrl } = {}) {
++ if (!client || typeof client.json !== 'function') throw new TypeError('createBlogClient: pass an openvibe-sdk/core client');
++ const at = { service: 'blog', baseUrl, audience: 'openvibe.blog' };
++ const call = (opts) => client.json({ ...at, ...opts });
++ const handle = (h) => {
++ if (!HANDLE_RE.test(String(h || ''))) throw new TypeError('blog: a blog handle');
++ return `/api/v1/blogs/${enc(String(h))}`;
++ };
++ const post = (id, rest = '') => {
++ if (!POST_ID_RE.test(String(id || ''))) throw new TypeError('blog: a post is a pst_ id');
++ return `/api/v1/posts/${enc(String(id))}${rest}`;
++ };
++
++ return {
++ blogs: {
++ /** A blog's public profile. */
++ get: (h, { signal } = {}) => call({ path: handle(h), signal }),
++ /** Its published posts, newest first: { total, posts }; all: true lists drafts too (members, blog.post.read). */
++ posts: (h, { limit, offset, all, signal } = {}) => call({ path: `${handle(h)}/posts`, query: { limit, offset, all: all ? '1' : undefined }, signal }),
++ /** Its feed as JSON Feed 1.1. */
++ feed: (h, { signal } = {}) => call({ path: `${handle(h)}/feed`, signal }),
++ },
++ posts: {
++ /** A draft on a blog the person belongs to (blog.post-create-request@1: title required) → { post, revision }. */
++ create: (h, fields, { signal } = {}) => {
++ if (!fields || typeof fields.title !== 'string' || !fields.title.trim()) throw new TypeError('blog.posts.create: a title');
++ return call({ method: 'POST', path: `${handle(h)}/posts`, json: fields, idempotencyKey: false, signal });
++ },
++ get: (id, { signal } = {}) => call({ path: post(id), signal }),
++ /** Edit: a new revision unless nothing changed ({ post, revision, created }); expected_revision guards a race. */
++ update: (id, fields, { signal } = {}) => call({ method: 'PATCH', path: post(id), json: fields, idempotent: true, signal }),
++ /** Publish a revision (the latest when omitted). */
++ publish: (id, { revision } = {}, { signal } = {}) => call({ method: 'POST', path: post(id, '/publish'), json: { revision }, idempotent: true, signal }),
++ unpublish: (id, { signal } = {}) => call({ method: 'POST', path: post(id, '/unpublish'), json: {}, idempotent: true, signal }),
++ /** Publish (or unpublish, action: 'unpublish') at a time: { at: ISO 8601, revision?, action? } → { job, created, post }. */
++ schedule: (id, { at: when, revision, action } = {}, { signal } = {}) => {
++ if (!when || Number.isNaN(Date.parse(when))) throw new TypeError('blog.posts.schedule: at is an ISO 8601 time');
++ return call({ method: 'POST', path: post(id, '/schedule'), json: { at: when, revision, action }, idempotent: true, signal });
++ },
++ cancelSchedule: (id, { signal } = {}) => call({ method: 'DELETE', path: post(id, '/schedule'), signal }),
++ /** Make an earlier revision the newest one (a new revision). */
++ revert: (id, { to_revision: to, expected_revision: expected } = {}, { signal } = {}) => call({ method: 'POST', path: post(id, '/revert'), json: { to_revision: to, expected_revision: expected }, idempotencyKey: false, signal }),
++ remove: (id, { signal } = {}) => call({ method: 'DELETE', path: post(id), signal }),
++ revisions: (id, { signal } = {}) => call({ path: post(id, '/revisions'), signal }),
++ revision: (id, n, { signal } = {}) => {
++ if (!Number.isInteger(Number(n)) || Number(n) < 1) throw new TypeError('blog.posts.revision: a revision number');
++ return call({ path: post(id, `/revisions/${Number(n)}`), signal });
++ },
++ },
++ };
++}
++
++module.exports = { createBlogClient };
ddiff --git a/src/core/index.js b/src/core/index.js
iindex df90975..68dd00a 100644
---- a/src/core/index.js
++++ b/src/core/index.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.55.0';
++const SDK_VERSION = '0.56.0';
module.exports = {
createClient,
ddiff --git a/test/browser-entries.test.js b/test/browser-entries.test.js
iindex bfe42ea..8ac3305 100644
---- a/test/browser-entries.test.js
++++ b/test/browser-entries.test.js
@@@ -76,7 +76,7 @@ run([
for (const [re, why] of FORBIDDEN) if (re.test(src)) problems.push(`${path.relative(ROOT, file)}: ${why}`);
}
assert.deepEqual(problems, []);
-- assert.deepEqual(blocked.sort(), ['./account-data', './actor', './cache', './commerce', './cost', './db', './delivery', './download', './events', './food', './govern', './identity', './inventory', './limits', './live', './node', './notifications', './openre', './placement', './play', './pubsub', './quest', './queue', './resources', './run', './runtime', './service', './sso', './storage', './telemetry', './testing', './tips', './usage', './valkey', './video', './vip', './work', './zone']);
++ assert.deepEqual(blocked.sort(), ['./account-data', './actor', './blog', './cache', './commerce', './cost', './db', './delivery', './download', './events', './food', './govern', './identity', './inventory', './limits', './live', './node', './notifications', './openre', './placement', './play', './pubsub', './quest', './queue', './resources', './run', './runtime', './service', './sso', './storage', './telemetry', './testing', './tips', './usage', './valkey', './video', './vip', './work', './zone']);
const rel = [...scanned].map((f) => path.relative(ROOT, f));
for (const must of ['browser.js', 'src/core/client.js', 'src/auth/browser.js', 'src/realtime.js', 'src/media.js', 'src/community.js', 'src/bot.js', 'src/modules.js', 'src/registry.js', 'src/jobs.js', 'src/tools.js', 'src/core/form.js', 'src/projects.js', 'browser/openvibe-sdk.mjs']) {
assert.ok(rel.includes(must), `${must} is scanned`);
ddiff --git a/test/pack.test.js b/test/pack.test.js
iindex 04bebe3..ea2fe6f 100644
---- a/test/pack.test.js
++++ b/test/pack.test.js
@@@ -66,7 +66,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, 56);
++ assert.equal(subpaths.length, 57);
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 });
ddiff --git a/test/product-modules.test.js b/test/product-modules.test.js
iindex 8629878..09a53e0 100644
---- a/test/product-modules.test.js
++++ b/test/product-modules.test.js
@@@ -1,5 +1,5 @@
'use strict';
--// openvibe-sdk/food, /actor, /run, /video, /work and /zone through a real core client against one local stub: every
++// openvibe-sdk/food, /actor, /run, /video, /work, /zone and /blog through a real core client against one local stub: every
// route and method, the token audience, which writes are retried (keyed or idempotent) and which never are, the SSE
// followers (Actor's task events, Run's job stream), and the id checks done before any call.
const assert = require('assert');
@@@ -11,9 +11,10 @@ const { createRunClient } = require('../src/run');
const { createVideoClient } = require('../src/video');
const { createWorkClient } = require('../src/work');
const { createZoneClient } = require('../src/zone');
++const { createBlogClient } = require('../src/blog');
const ULID = '01JAB2C3D4E5F6G7H8J9K0MNPQ';
--const ids = { plan: `pln_${ULID}`, task: `tsk_${ULID}`, agent: `agt_${ULID}`, mem: `mem_${ULID}`, job: `job_${ULID}`, playlist: `vpl_${ULID}`, app: `wap_${ULID}`, project: `prj_${ULID}`, zone: `zon_${ULID}` };
++const ids = { plan: `pln_${ULID}`, task: `tsk_${ULID}`, agent: `agt_${ULID}`, mem: `mem_${ULID}`, job: `job_${ULID}`, playlist: `vpl_${ULID}`, app: `wap_${ULID}`, project: `prj_${ULID}`, zone: `zon_${ULID}`, post: `pst_${ULID}` };
(async () => {
const seen = [];
@@@ -44,7 +45,7 @@ const ids = { plan: `pln_${ULID}`, task: `tsk_${ULID}`, agent: `agt_${ULID}`, me
const base = `http://127.0.0.1:${server.address().port}`;
const audiences = [];
const client = createClient({
-- baseUrls: { food: `${base}/food`, actor: `${base}/actor`, run: `${base}/run`, 'media-hub': `${base}/video`, work: `${base}/work`, zone: `${base}/zone` },
++ baseUrls: { food: `${base}/food`, actor: `${base}/actor`, run: `${base}/run`, 'media-hub': `${base}/video`, work: `${base}/work`, zone: `${base}/zone`, blog: `${base}/blog` },
getToken: ({ audience }) => { audiences.push(audience); return `tok-${audience}`; },
retries: 2, retryDelayMs: 1, maxRetryDelayMs: 2,
});
@@@ -216,13 +217,43 @@ const ids = { plan: `pln_${ULID}`, task: `tsk_${ULID}`, agent: `agt_${ULID}`, me
assert.throws(() => zone.zones.create(ids.project, { name: 'x' }), /env is required/);
assert.throws(() => zone.zones.get('zone_1'), /zon_/);
++ // ── Blog ──────────────────────────────────────────────
++ const blog = createBlogClient(client);
++ mark = since();
++ await blog.blogs.get('goosely');
++ await blog.blogs.posts('goosely', { limit: 10, all: true });
++ await blog.blogs.feed('goosely');
++ await busyOnce(() => blog.posts.create('goosely', { title: 'Tonight on stream', body: 'Hi', visibility: 'public' }));
++ await blog.posts.get(ids.post);
++ await blog.posts.update(ids.post, { body: 'Hi again', expected_revision: 1 });
++ await blog.posts.publish(ids.post);
++ await blog.posts.unpublish(ids.post);
++ await blog.posts.schedule(ids.post, { at: '2026-10-21T18:00:00Z', revision: 2 });
++ await blog.posts.cancelSchedule(ids.post);
++ await busyOnce(() => blog.posts.revert(ids.post, { to_revision: 1, expected_revision: 2 }));
++ await blog.posts.revisions(ids.post);
++ await blog.posts.revision(ids.post, 2);
++ await blog.posts.remove(ids.post);
++ const b = mark();
++ const P = `/api/v1/posts/${ids.post}`;
++ assert.deepStrictEqual(b.map((x) => `${x.method} ${x.url}`), [
++ 'GET /api/v1/blogs/goosely', 'GET /api/v1/blogs/goosely/posts?limit=10&all=1', 'GET /api/v1/blogs/goosely/feed',
++ 'POST /api/v1/blogs/goosely/posts', `GET ${P}`, `PATCH ${P}`, `PATCH ${P}`, `POST ${P}/publish`, `POST ${P}/publish`,
++ `POST ${P}/unpublish`, `POST ${P}/unpublish`, `POST ${P}/schedule`, `POST ${P}/schedule`, `DELETE ${P}/schedule`,
++ `DELETE ${P}/schedule`, `POST ${P}/revert`, `GET ${P}/revisions`, `GET ${P}/revisions/2`, `DELETE ${P}`, `DELETE ${P}`,
++ ]);
++ assert.deepStrictEqual(b[11].body, { at: '2026-10-21T18:00:00Z', revision: 2 });
++ assert.throws(() => blog.posts.get('post_1'), /pst_/);
++ assert.throws(() => blog.posts.create('goosely', { body: 'no title' }), /title/);
++ assert.throws(() => blog.posts.schedule(ids.post, { at: 'tomorrow' }), /ISO 8601/);
++
// Each product's token is for its own audience (Video's is the media hub's, openvibe.download).
-- assert.deepStrictEqual([...new Set(audiences)].sort(), ['openvibe.actor', 'openvibe.download', 'openvibe.food', 'openvibe.run', 'openvibe.work', 'openvibe.zone']);
-- assert.ok(seen.every((x) => x.auth === `Bearer tok-${{ food: 'openvibe.food', actor: 'openvibe.actor', run: 'openvibe.run', video: 'openvibe.download', work: 'openvibe.work', zone: 'openvibe.zone' }[x.svc]}`));
++ assert.deepStrictEqual([...new Set(audiences)].sort(), ['openvibe.actor', 'openvibe.blog', 'openvibe.download', 'openvibe.food', 'openvibe.run', 'openvibe.work', 'openvibe.zone']);
++ assert.ok(seen.every((x) => x.auth === `Bearer tok-${{ food: 'openvibe.food', actor: 'openvibe.actor', run: 'openvibe.run', video: 'openvibe.download', work: 'openvibe.work', zone: 'openvibe.zone', blog: 'openvibe.blog' }[x.svc]}`));
// Each client needs a core client.
-- for (const make of [createFoodClient, createActorClient, createRunClient, createVideoClient, createWorkClient, createZoneClient]) assert.throws(() => make({}), /core client/);
-- console.log('product modules (food, actor, run, video, work, zone): all checks passed');
++ for (const make of [createFoodClient, createActorClient, createRunClient, createVideoClient, createWorkClient, createZoneClient, createBlogClient]) assert.throws(() => make({}), /core client/);
++ console.log('product modules (food, actor, run, video, work, zone, blog): all checks passed');
} finally {
server.close();
}
ddiff --git a/types/blog.d.ts b/types/blog.d.ts
nnew file mode 100644
iindex 0000000..4f5d3ad
---- /dev/null
++++ b/types/blog.d.ts
@@@ -0,0 +1,30 @@
++/** openvibe-sdk/blog: OpenVibe.Blog — a blog's posts and feed, and writing posts for the person who authorized the app. */
++type Opts = { signal?: AbortSignal };
++type BlogJson = Record<string, any>;
++export type PostVisibility = 'public' | 'unlisted' | 'members' | 'private';
++export interface PostFields {
++ title?: string; body?: string; summary?: string | null; visibility?: PostVisibility; slug?: string; entitlement_key?: string;
++ allow_comments?: boolean; noindex?: boolean; series_id?: string | null; series_position?: number | null;
++ citations?: unknown[]; message?: string | null; expected_revision?: number; [k: string]: unknown;
++}
++export interface BlogClient {
++ blogs: {
++ get(handle: string, opts?: Opts): Promise<BlogJson>;
++ posts(handle: string, opts?: Opts & { limit?: number; offset?: number; all?: boolean }): Promise<{ total?: number; posts: BlogJson[] }>;
++ feed(handle: string, opts?: Opts): Promise<BlogJson>;
++ };
++ posts: {
++ create(handle: string, fields: PostFields & { title: string }, opts?: Opts): Promise<{ post: BlogJson; revision: number }>;
++ get(id: string, opts?: Opts): Promise<{ post: BlogJson }>;
++ update(id: string, fields: PostFields, opts?: Opts): Promise<{ post: BlogJson; revision: number; created: boolean }>;
++ publish(id: string, req?: { revision?: number }, opts?: Opts): Promise<{ post: BlogJson; changed: boolean }>;
++ unpublish(id: string, opts?: Opts): Promise<{ post: BlogJson; changed: boolean }>;
++ schedule(id: string, req: { at: string; revision?: number; action?: 'publish' | 'unpublish' }, opts?: Opts): Promise<{ job: BlogJson; created: boolean; post: BlogJson }>;
++ cancelSchedule(id: string, opts?: Opts): Promise<{ cancelled: boolean; post: BlogJson }>;
++ revert(id: string, req: { to_revision: number; expected_revision?: number }, opts?: Opts): Promise<{ revision: number; post: BlogJson }>;
++ remove(id: string, opts?: Opts): Promise<{ deleted: boolean; id: string }>;
++ revisions(id: string, opts?: Opts): Promise<BlogJson>;
++ revision(id: string, n: number, opts?: Opts): Promise<BlogJson>;
++ };
++}
++export function createBlogClient(client: { json(opts: Record<string, unknown>): Promise<any> }, options?: { baseUrl?: string }): BlogClient;
ddiff --git a/types/index.d.ts b/types/index.d.ts
iindex 1af23fb..2007c51 100644
---- a/types/index.d.ts
++++ b/types/index.d.ts
@@@ -20,6 +20,7 @@ export * as quest from './quest';
export * as live from './live';
export * as inventory from './inventory';
export * as tips from './tips';
++export * as blog from './blog';
export * as food from './food';
export * as actor from './actor';
export * as run from './run';