openvibers/openvibe.sdk Commits

Add ov.design.components() for the public component registry (#164)

OP OpenVibers committed 4 days ago · 43df321c20 · 18 files, +238 −49

* Add ov.design.components() for the public component registry

* Name openvibe-sdk/design in the README and docs

* Update the SDK surface, status and browser types for the design entry

* 0.118.0: the design client reads the public component registry; icons keep their token

Merge main (Design glyph API, #153) into the registry client: one createDesignClient with icons,
components() and component(name); accessToken is optional and only the icon API needs it.

Changes

ddiff --git a/CHANGELOG.md b/CHANGELOG.md
iindex 2bc7a7c..1c2fd21 100644
---- a/CHANGELOG.md
++++ b/CHANGELOG.md
@@@ -1,5 +1,11 @@
# Changelog
++## 0.118.0 (2026-11-09)
++
++- openvibe-sdk/design: `components()` and `component(name)` read OpenVibe.Design's public design.component@1 registry
++ (a missing name is null, a bad one is refused before a request). They are on the same `createDesignClient` as the
++ icons; `accessToken` is now optional and only the icon API needs it.
++
## 0.117.0 (2026-11-09)
- ov.cam loads Cam's kit at its versioned URL and its new hash (Cam #116 changed the kit)
ddiff --git a/README.md b/README.md
iindex 9cfb91a..ea47f02 100644
---- a/README.md
++++ b/README.md
@@@ -10,7 +10,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.117.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.118.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.
@@@ -19,7 +19,7 @@ npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags
After v0.97.1 is tagged:
```bash
--npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.117.0
++npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.118.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).
ddiff --git a/STATUS.json b/STATUS.json
iindex 031b585..5fc773d 100644
---- a/STATUS.json
++++ b/STATUS.json
@@@ -3,7 +3,7 @@
"stage": "alpha",
"code": true,
"wave": "W2",
-- "version": "0.117.0",
++ "version": "0.118.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.js b/browser.js
iindex 087cc19..33bb229 100644
---- a/browser.js
++++ b/browser.js
@@@ -23,6 +23,7 @@ module.exports = {
meme: require('./src/meme'),
vision: require('./src/vision'),
themes: require('./src/themes'),
++ design: require('./src/design'),
redact: require('./src/redact'),
chat: require('./src/chat'),
ai: require('./src/ai'),
ddiff --git a/browser/openvibe-sdk.mjs b/browser/openvibe-sdk.mjs
iindex 5c14cb5..a21c810 100644
---- a/browser/openvibe-sdk.mjs
++++ b/browser/openvibe-sdk.mjs
@@@ -1,6 +1,6 @@
--// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.117.0, MIT). Do not edit.
++// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.118.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, community, homeFeed, bot, search, bench, meme, vision, themes, redact, chat, ai, credentials, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity.
++// (auth, locker, registry, trust, modules, realtime, media, cam, 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 ──────────────────────────────────────────────────
@@@ -30,14 +30,15 @@ module.exports = {
meme: __load(32),
vision: __load(33),
themes: __load(34),
-- redact: __load(35),
-- chat: __load(36),
-- ai: __load(37),
-- credentials: __load(38),
-- jobs: __load(39),
-- tools: __load(41),
-- projects: __load(42),
-- geo: __load(43),
++ design: __load(35),
++ redact: __load(36),
++ chat: __load(37),
++ ai: __load(38),
++ credentials: __load(39),
++ jobs: __load(40),
++ tools: __load(42),
++ projects: __load(43),
++ geo: __load(44),
};
},
// ── 1: src/core/index.js ───────────────────────────────────────────
@@@ -52,7 +53,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.117.0';
++const SDK_VERSION = '0.118.0';
module.exports = {
createClient,
@@@ -4291,7 +4292,74 @@ function followTheme(fn, opts = {}) {
module.exports = { createThemesClient, followTheme, readTheme, applyTheme, seasonOn, onColor, DISPLAY_OPTIONS, TOKENS };
},
--// ── 35: src/redact.js ───────────────────────────────────────────────
++// ── 35: src/design.js ───────────────────────────────────────────────
++function (module, exports) {
++'use strict';
++
++/**
++ * OpenVibe.Design: the public component registry (design.component@1; no token) and the glyph API (icons; a token).
++ * Browser-safe.
++ */
++const DEFAULT_DESIGN_URL = 'https://openvibe.design';
++const STYLES = new Set(['thin', 'light', 'regular', 'bold', 'solid', 'duotone']);
++const COMPONENT = /^[a-z][a-z0-9-]{0,63}$/;
++
++function createDesignClient({ accessToken = null, baseUrl = DEFAULT_DESIGN_URL, fetchImpl = globalThis.fetch, timeoutMs = 15000 } = {}) {
++ if (accessToken != null && (typeof accessToken !== 'string' || !accessToken)) throw new TypeError('createDesignClient: accessToken must be a non-empty string');
++ if (typeof fetchImpl !== 'function') throw new TypeError('createDesignClient: fetch is unavailable');
++ const base = String(baseUrl).replace(/\/+$/, '');
++ if (!/^https?:\/\/[^/]+$/i.test(base)) throw new TypeError('createDesignClient: baseUrl must be an origin');
++ async function request(path, { method = 'GET', body, signal, open = false } = {}) {
++ if (!open && !accessToken) throw new TypeError('createDesignClient: the icon API needs accessToken');
++ const response = await fetchImpl(`${base}${path}`, {
++ method,
++ headers: { accept: 'application/json', ...(accessToken ? { authorization: `Bearer ${accessToken}` } : {}),
++ ...(body !== undefined ? { 'content-type': 'application/json' } : {}) },
++ ...(body !== undefined ? { body: JSON.stringify(body) } : {}),
++ signal: signal || AbortSignal.timeout(timeoutMs),
++ });
++ const data = await response.json().catch(() => ({}));
++ if (!response.ok) {
++ const err = new Error(data.detail || data.message || `Design API returned ${response.status}`);
++ err.status = response.status;
++ err.code = data.code || null;
++ throw err;
++ }
++ return data;
++ }
++ const icons = Object.freeze({
++ async draft({ name, sentence = '', styles = [...STYLES], sourceSvg = undefined }, { signal } = {}) {
++ if (!/^[a-z][a-z0-9-]{1,31}$/.test(String(name || ''))) throw new TypeError('icons.draft: name must be 2–32 lowercase letters, digits or dashes');
++ if (!Array.isArray(styles) || !styles.length || styles.some((s) => !STYLES.has(s))) throw new TypeError('icons.draft: styles must be thin, light, regular, bold, solid or duotone');
++ return request('/api/v1/glyphs/draft', { method: 'POST', body: { name, sentence, styles, ...(sourceSvg ? { sourceSvg } : {}) }, signal });
++ },
++ async get(name, { style = 'regular', signal } = {}) {
++ if (!/^[a-z][a-z0-9-]{1,31}$/.test(String(name || ''))) throw new TypeError('icons.get: name must be lowercase letters, digits or dashes');
++ if (!STYLES.has(style)) throw new TypeError('icons.get: unsupported style');
++ return request(`/api/v1/glyphs/${encodeURIComponent(name)}?style=${encodeURIComponent(style)}`, { signal });
++ },
++ async search(q, { limit = 24, signal } = {}) {
++ const query = String(q || '').trim();
++ if (!query) throw new TypeError('icons.search: q is required');
++ return request(`/api/v1/glyphs/search?q=${encodeURIComponent(query)}&limit=${encodeURIComponent(Math.min(Math.max(Number(limit) || 24, 1), 60))}`, { signal });
++ },
++ });
++ return Object.freeze({
++ icons,
++ /** The registry: → { schema: 'design.component@1', components: [definition], kitComponents: [...] }. No token. */
++ components({ signal } = {}) { return request('/api/v1/components', { signal, open: true }); },
++ /** One definition: → { schema, component, examples }, or null when no component has this name. No token. */
++ async component(name, { signal } = {}) {
++ if (!COMPONENT.test(String(name || ''))) throw new TypeError('component: pass a registry name (lowercase letters, digits and hyphens)');
++ try { return await request(`/api/v1/components/${encodeURIComponent(name)}`, { signal, open: true }); }
++ catch (error) { if (error && error.status === 404) return null; throw error; }
++ },
++ });
++}
++
++module.exports = { createDesignClient, DEFAULT_DESIGN_URL };
++},
++// ── 36: src/redact.js ───────────────────────────────────────────────
function (module, exports) {
'use strict';
/**
@@@ -4538,7 +4606,7 @@ function onlySecret(text) {
module.exports = { redact, onlySecret };
},
--// ── 36: src/chat.js ─────────────────────────────────────────────────
++// ── 37: src/chat.js ─────────────────────────────────────────────────
function (module, exports) {
'use strict';
/**
@@@ -4786,7 +4854,7 @@ function createFeedPublisher(client, { feed, key, baseUrl } = {}) {
module.exports = { createChatClient, createInboxVisitor, createFeedPublisher };
},
--// ── 37: src/ai.js ───────────────────────────────────────────────────
++// ── 38: src/ai.js ───────────────────────────────────────────────────
function (module, exports) {
'use strict';
/**
@@@ -4918,7 +4986,7 @@ function createAiClient(client, defaults = {}) {
module.exports = { createAiClient, TERMINAL, OPS, CLASSES };
},
--// ── 38: src/credentials.js ──────────────────────────────────────────
++// ── 39: src/credentials.js ──────────────────────────────────────────
function (module, exports) {
'use strict';
@@@ -4936,7 +5004,7 @@ function createCredentialsClient(client, defaults = {}) {
module.exports = { createCredentialsClient };
},
--// ── 39: src/jobs.js ─────────────────────────────────────────────────
++// ── 40: src/jobs.js ─────────────────────────────────────────────────
function (module, exports) {
'use strict';
/**
@@@ -4974,7 +5042,7 @@ function (module, exports) {
*/
const { OpenVibeError, isOpenVibeError } = __load(3);
const { newIdempotencyKey } = __load(5);
--const { appendFiles } = __load(40);
++const { appendFiles } = __load(41);
const { parseSSE } = __load(23);
const TERMINAL = new Set(['succeeded', 'failed', 'cancelled']);
@@@ -5138,7 +5206,7 @@ function createJobsClient(client, { baseUrl, service = 'tools', audience = 'open
module.exports = { createJobsClient, isTerminal, TERMINAL_STATES: [...TERMINAL] };
},
--// ── 40: src/core/form.js ────────────────────────────────────────────
++// ── 41: src/core/form.js ────────────────────────────────────────────
function (module, exports) {
'use strict';
/**
@@@ -5172,7 +5240,7 @@ function appendFiles(form, list, where) {
module.exports = { isBlob, isUpload, appendFiles };
},
--// ── 41: src/tools.js ────────────────────────────────────────────────
++// ── 42: src/tools.js ────────────────────────────────────────────────
function (module, exports) {
'use strict';
/**
@@@ -5206,8 +5274,8 @@ function (module, exports) {
*/
const { OpenVibeError, isOpenVibeError } = __load(3);
const { newIdempotencyKey } = __load(5);
--const { isUpload, appendFiles } = __load(40);
--const { createJobsClient } = __load(39);
++const { isUpload, appendFiles } = __load(41);
++const { createJobsClient } = __load(40);
const enc = encodeURIComponent;
const ID_RE = /^[a-z][a-z0-9-]{0,39}$/;
@@@ -5467,7 +5535,7 @@ function createToolsClient(client, { baseUrl, service = 'tools', audience = 'ope
module.exports = { createToolsClient, ToolRunError, isToolRunError };
},
--// ── 42: src/projects.js ─────────────────────────────────────────────
++// ── 43: src/projects.js ─────────────────────────────────────────────
function (module, exports) {
'use strict';
/**
@@@ -5583,7 +5651,7 @@ function createProjectsClient(client, { baseUrl } = {}) {
module.exports = { createProjectsClient };
},
--// ── 43: src/geo.js ──────────────────────────────────────────────────
++// ── 44: src/geo.js ──────────────────────────────────────────────────
function (module, exports) {
'use strict';
/**
@@@ -5664,7 +5732,7 @@ export const {
satisfiesRange, compareVersions, CONTRACTS_RANGE, DEFAULT_NETWORK, SDK_VERSION, auth,
locker, registry, trust, modules, realtime, media,
cam, community, homeFeed, bot, search, bench,
-- meme, vision, themes, redact, chat, ai,
-- credentials, jobs, tools, projects, geo,
++ meme, vision, themes, design, redact, chat,
++ ai, credentials, jobs, tools, projects, geo,
} = sdk;
export default sdk;
ddiff --git a/docs/design.md b/docs/design.md
nnew file mode 100644
iindex 0000000..ceeae1f
---- /dev/null
++++ b/docs/design.md
@@@ -0,0 +1,16 @@
++# Design component registry
++
++OpenVibe.Design publishes platform-neutral `design.component@1` definitions. Each definition gives the component's anatomy, props, states, tokens, behavior, accessibility, a web module and demo, and Android and iOS specifications.
++
++```js
++const { design } = require('openvibe-sdk');
++const d = design.createDesignClient(); // the registry is public: no token
++const { components } = await d.components();
++const sheet = await d.component('sheet'); // null when no component has that name
++```
++
++The same client draws and finds icons when it has a token
++(`design.createDesignClient({ accessToken })`, see [design-icons.md](design-icons.md)); without one, `icons.*` throws
++before any request.
++
++The public endpoints are `GET /api/v1/components` and `GET /api/v1/components/:name`. A missing name returns `null` in the SDK. The API also carries the older kit document specs under `kitComponents` for clients that render kit documents.
ddiff --git a/esm/design.mjs b/esm/design.mjs
iindex 4d37df8..c32477e 100644
---- a/esm/design.mjs
++++ b/esm/design.mjs
@@@ -1,3 +1,7 @@
++// Generated by scripts/esm.js from src/design.js. Do not edit.
import cjs from '../src/design.js';
--export const { createDesignClient, DEFAULT_DESIGN_URL } = cjs;
++
++export const {
++ createDesignClient, DEFAULT_DESIGN_URL,
++} = cjs;
export default cjs;
ddiff --git a/esm/index.mjs b/esm/index.mjs
iindex 16ce6bd..9b259d4 100644
---- a/esm/index.mjs
++++ b/esm/index.mjs
@@@ -8,12 +8,12 @@ export const {
share, locker, auth, registry, identity, trust,
modules, events, realtime, media, cam, community,
homeFeed, bot, search, bench, meme, vision,
-- themes, 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, work,
-- zone, play, download, openre, geo, usage,
-- commerce, telemetry, design,
++ 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,
++ work, zone, play, download, openre, geo,
++ usage, commerce, telemetry,
} = cjs;
export default cjs;
ddiff --git a/index.js b/index.js
iindex 6507a8e..e9530af 100644
---- a/index.js
++++ b/index.js
@@@ -28,6 +28,7 @@ module.exports = {
meme: require('./src/meme'),
vision: require('./src/vision'),
themes: require('./src/themes'),
++ design: require('./src/design'),
redact: require('./src/redact'),
chat: require('./src/chat'),
chatApps: require('./src/chat-apps'),
@@@ -65,5 +66,4 @@ module.exports = {
usage: require('./src/usage'),
commerce: require('./src/commerce'),
telemetry: require('./src/telemetry'),
-- design: require('./src/design'),
};
ddiff --git a/package-lock.json b/package-lock.json
iindex 95bec01..35302ec 100644
---- a/package-lock.json
++++ b/package-lock.json
@@@ -1,12 +1,12 @@
{
"name": "openvibe-sdk",
-- "version": "0.117.0",
++ "version": "0.118.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "openvibe-sdk",
-- "version": "0.117.0",
++ "version": "0.118.0",
"license": "MIT",
"bin": {
"openvibe-download": "bin/openvibe-download.js"
ddiff --git a/package.json b/package.json
iindex d844aa6..cf95214 100644
---- a/package.json
++++ b/package.json
@@@ -1,6 +1,6 @@
{
"name": "openvibe-sdk",
-- "version": "0.117.0",
++ "version": "0.118.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",
ddiff --git a/scripts/esm.js b/scripts/esm.js
iindex 14bac27..3ccc876 100644
---- a/scripts/esm.js
++++ b/scripts/esm.js
@@@ -40,6 +40,7 @@ const ENTRIES = {
'bench.mjs': '../src/bench.js',
'meme.mjs': '../src/meme.js',
'themes.mjs': '../src/themes.js',
++ 'design.mjs': '../src/design.js',
'limits.mjs': '../src/limits.js',
'account-data.mjs': '../src/account-data.js',
'govern.mjs': '../src/govern.js',
ddiff --git a/src/core/index.js b/src/core/index.js
iindex 504230b..d49ef13 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.117.0';
++const SDK_VERSION = '0.118.0';
module.exports = {
createClient,
ddiff --git a/src/design.js b/src/design.js
iindex d3fefd6..735d40e 100644
---- a/src/design.js
++++ b/src/design.js
@@@ -1,18 +1,23 @@
'use strict';
++/**
++ * OpenVibe.Design: the public component registry (design.component@1; no token) and the glyph API (icons; a token).
++ * Browser-safe.
++ */
const DEFAULT_DESIGN_URL = 'https://openvibe.design';
const STYLES = new Set(['thin', 'light', 'regular', 'bold', 'solid', 'duotone']);
++const COMPONENT = /^[a-z][a-z0-9-]{0,63}$/;
--/** A small authenticated client for the Design icon API. */
--function createDesignClient({ accessToken, baseUrl = DEFAULT_DESIGN_URL, fetchImpl = globalThis.fetch, timeoutMs = 15000 } = {}) {
-- if (typeof accessToken !== 'string' || !accessToken) throw new TypeError('createDesignClient: accessToken is required');
++function createDesignClient({ accessToken = null, baseUrl = DEFAULT_DESIGN_URL, fetchImpl = globalThis.fetch, timeoutMs = 15000 } = {}) {
++ if (accessToken != null && (typeof accessToken !== 'string' || !accessToken)) throw new TypeError('createDesignClient: accessToken must be a non-empty string');
if (typeof fetchImpl !== 'function') throw new TypeError('createDesignClient: fetch is unavailable');
const base = String(baseUrl).replace(/\/+$/, '');
if (!/^https?:\/\/[^/]+$/i.test(base)) throw new TypeError('createDesignClient: baseUrl must be an origin');
-- async function request(path, { method = 'GET', body, signal } = {}) {
++ async function request(path, { method = 'GET', body, signal, open = false } = {}) {
++ if (!open && !accessToken) throw new TypeError('createDesignClient: the icon API needs accessToken');
const response = await fetchImpl(`${base}${path}`, {
method,
-- headers: { accept: 'application/json', authorization: `Bearer ${accessToken}`,
++ headers: { accept: 'application/json', ...(accessToken ? { authorization: `Bearer ${accessToken}` } : {}),
...(body !== undefined ? { 'content-type': 'application/json' } : {}) },
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
signal: signal || AbortSignal.timeout(timeoutMs),
@@@ -43,7 +48,17 @@ function createDesignClient({ accessToken, baseUrl = DEFAULT_DESIGN_URL, fetchIm
return request(`/api/v1/glyphs/search?q=${encodeURIComponent(query)}&limit=${encodeURIComponent(Math.min(Math.max(Number(limit) || 24, 1), 60))}`, { signal });
},
});
-- return Object.freeze({ icons });
++ return Object.freeze({
++ icons,
++ /** The registry: → { schema: 'design.component@1', components: [definition], kitComponents: [...] }. No token. */
++ components({ signal } = {}) { return request('/api/v1/components', { signal, open: true }); },
++ /** One definition: → { schema, component, examples }, or null when no component has this name. No token. */
++ async component(name, { signal } = {}) {
++ if (!COMPONENT.test(String(name || ''))) throw new TypeError('component: pass a registry name (lowercase letters, digits and hyphens)');
++ try { return await request(`/api/v1/components/${encodeURIComponent(name)}`, { signal, open: true }); }
++ catch (error) { if (error && error.status === 404) return null; throw error; }
++ },
++ });
}
module.exports = { createDesignClient, DEFAULT_DESIGN_URL };
ddiff --git a/test/design.test.js b/test/design.test.js
nnew file mode 100644
iindex 0000000..999ea0e
---- /dev/null
++++ b/test/design.test.js
@@@ -0,0 +1,53 @@
++'use strict';
++/**
++ * Design: the public design.component@1 registry (paths, a missing component is null, a bad name is refused before a
++ * request), and the body the API returns unchanged. The registry needs no token; the icon API still does
++ * (test/design-icons.test.js covers the icons).
++ */
++const assert = require('node:assert/strict');
++const { stubServer, send, problem, run } = require('./helpers');
++const { createDesignClient } = require('../src/design');
++
++const DEFINITION = {
++ schema: 'design.component@1', name: 'sheet', title: 'Sheet', summary: 'A modal task surface.',
++ anatomy: [{ part: 'header', role: 'title and close' }], props: { title: 'string' }, states: ['closed', 'open'],
++ tokens: ['color.bg.raised'], behaviors: { keyboardAware: true, outsideTapCloses: true, scrollLock: true, reducedMotion: 'Crossfade.' },
++ accessibility: { name: 'Sheet', target: '44 × 44', focus: 'Trap focus.' },
++ platforms: { web: { module: 'openvibe-shared/kit', markup: 'kit.sheet()', demo: '/components/sheet' },
++ android: { toolkit: 'Jetpack Compose', material3: 'SurfaceContainerHigh', specification: 'ModalBottomSheet.' },
++ ios: { toolkit: 'SwiftUI', specification: '.sheet.' } },
++ examples: [{ title: 'Default', props: { title: 'Add a site' } }],
++};
++
++run([
++ ['components(): the registry body unchanged; component(name): one definition, null when missing; no token needed', async () => {
++ const srv = await stubServer((req, res) => {
++ if (req.url === '/api/v1/components') return send(res, 200, { schema: 'design.component@1', components: [DEFINITION], kitComponents: [] });
++ if (req.url === '/api/v1/components/sheet') return send(res, 200, { schema: 'design.component@1', component: DEFINITION, examples: DEFINITION.examples });
++ return problem(res, 404, 'design.component_not_found', 'No component by that name.');
++ });
++ const d = createDesignClient({ baseUrl: srv.url });
++ const all = await d.components();
++ assert.equal(all.components[0].name, 'sheet');
++ const one = await d.component('sheet');
++ assert.equal(one.component.behaviors.scrollLock, true);
++ assert.equal(await d.component('no-such-part'), null);
++ assert.equal(srv.requests[0].url, '/api/v1/components');
++ assert.equal(srv.requests[0].headers.authorization, undefined, 'no token: none sent');
++ assert.equal(srv.requests[1].url, '/api/v1/components/sheet');
++ const signed = createDesignClient({ baseUrl: srv.url, accessToken: 'user-jwt' });
++ await signed.components();
++ assert.equal(srv.requests[3].headers.authorization, 'Bearer user-jwt', 'a token, when given, goes along');
++ await assert.rejects(() => d.icons.get('heart'), /needs accessToken/, 'the icon API still needs a token');
++ await srv.close();
++ }],
++ ['a bad name is refused before a request; a server error still throws', async () => {
++ const srv = await stubServer((req, res) => send(res, 500, { error: 'boom' }));
++ const d = createDesignClient({ baseUrl: srv.url });
++ await assert.rejects(() => d.component('Sheet!'), TypeError);
++ await assert.rejects(() => d.component('sheet'), (err) => err.status === 500);
++ assert.equal(srv.requests.length, 1, 'the bad name made no request');
++ assert.throws(() => createDesignClient({ accessToken: '' }), TypeError, 'an empty token is a mistake, not "no token"');
++ await srv.close();
++ }],
++]);
ddiff --git a/types/bundle.d.ts b/types/bundle.d.ts
iindex 914cde1..bf52708 100644
---- a/types/bundle.d.ts
++++ b/types/bundle.d.ts
@@@ -13,6 +13,7 @@ import * as bench from './bench';
import * as meme from './meme';
import * as vision from './vision';
import * as themes from './themes';
++import * as design from './design';
import * as redact from './redact';
import * as chat from './chat';
import * as ai from './ai';
@@@ -40,6 +41,7 @@ export * as bench from './bench';
export * as meme from './meme';
export * as vision from './vision';
export * as themes from './themes';
++export * as design from './design';
export * as redact from './redact';
export * as chat from './chat';
export * as ai from './ai';
@@@ -53,6 +55,6 @@ export * as trust from './trust';
declare const sdk: typeof core & {
auth: typeof auth; registry: typeof registry; modules: typeof modules; realtime: typeof realtime;
-- media: typeof media; cam: typeof cam; community: typeof community; homeFeed: typeof homeFeed; bot: typeof bot; search: typeof search; bench: typeof bench; meme: typeof meme; vision: typeof vision; themes: typeof themes; 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; 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;
};
export default sdk;
ddiff --git a/types/design.d.ts b/types/design.d.ts
iindex c01d136..03940a7 100644
---- a/types/design.d.ts
++++ b/types/design.d.ts
@@@ -2,11 +2,33 @@ export type GlyphStyle = 'thin' | 'light' | 'regular' | 'bold' | 'solid' | 'duot
export interface DesignGlyph { name: string; style: GlyphStyle; svg: string; solid: string; strokeWidth: number | null; underlay: string; underlayOpacity: number; }
export interface DesignGlyphReference { name: string; set: string; setName: string; author: string; license: string; licenseUrl: string; preview: string; }
export interface DesignGlyphDraft { id: string; name: string; svg: string; solid_svg: string | null; styles: GlyphStyle[]; references: DesignGlyphReference[]; status: string; }
--export declare function createDesignClient(options: { accessToken: string; baseUrl?: string; fetchImpl?: typeof fetch; timeoutMs?: number }): {
++export interface DesignComponent {
++ schema: 'design.component@1';
++ name: string;
++ title: string;
++ summary: string;
++ anatomy: Array<{ part: string; role: string }>;
++ props: Record<string, string>;
++ states: string[];
++ tokens: string[];
++ behaviors: { keyboardAware: boolean; outsideTapCloses: boolean; scrollLock: boolean; reducedMotion: string };
++ accessibility: { name: string; target: string; focus: string };
++ platforms: {
++ web: { module: string; markup: string; demo: string };
++ android: { toolkit: 'Jetpack Compose'; material3: string; specification: string };
++ ios: { toolkit: 'SwiftUI'; specification: string };
++ };
++ examples: Array<{ title: string; props: Record<string, unknown> }>;
++}
++
++/** accessToken is needed for icons only; the component registry is public. */
++export declare function createDesignClient(options?: { accessToken?: string; baseUrl?: string; fetchImpl?: typeof fetch; timeoutMs?: number }): {
icons: {
draft(input: { name: string; sentence?: string; styles?: GlyphStyle[]; sourceSvg?: string }, opts?: { signal?: AbortSignal }): Promise<{ kept: DesignGlyphDraft[]; refused: string[] }>;
get(name: string, opts?: { style?: GlyphStyle; signal?: AbortSignal }): Promise<DesignGlyph>;
search(q: string, opts?: { limit?: number; signal?: AbortSignal }): Promise<{ query: string; glyphs: DesignGlyph[] }>;
};
++ components(opts?: { signal?: AbortSignal }): Promise<{ schema: 'design.component@1'; components: DesignComponent[]; kitComponents: unknown[] }>;
++ component(name: string, opts?: { signal?: AbortSignal }): Promise<{ schema: 'design.component@1'; component: DesignComponent; examples: DesignComponent['examples'] } | null>;
};
export declare const DEFAULT_DESIGN_URL: string;
ddiff --git a/types/index.d.ts b/types/index.d.ts
iindex e2b3146..b507640 100644
---- a/types/index.d.ts
++++ b/types/index.d.ts
@@@ -18,6 +18,7 @@ export * as search from './search';
export * as bench from './bench';
export * as vision from './vision';
export * as themes from './themes';
++export * as design from './design';
export * as redact from './redact';
export * as chat from './chat';
export * as chatApps from './chat-apps';