openvibers/openvibe.sdk Commits
0.58.0: openvibe-sdk/coupons, /deals and /trade (what a person does for themselves on those sites) (#69)
Changes
@@@ -3,6 +3,15 @@All notable changes to `openvibe-sdk`. The package follows semver; while it is `0.x`, a minorrelease may change an API and says so here.++## 0.58.0 (2026-10-20)++++- **`openvibe-sdk/coupons`**, **`openvibe-sdk/deals`** and **`openvibe-sdk/trade`**: what a person does for themselves++ on those sites, public in openvibe-contracts 0.208.0. Coupons: which store a site is, its codes, submitting a code and++ reporting whether one worked (what a browser extension needs). Deals: hot and new offers, posting, price++ observations, votes, flags and watches. Trade: instruments with their sourced observations and filings, and the++ person's watchlists and alert rules. Moderation stays with each site. Writes that make a new row each time are++ never retried on their own.++## 0.57.0 (2026-10-20)- **`openvibe-sdk/reviews`** (`createReviewsClient`): OpenVibe.Reviews for apps, whose reads became public in@@@ -2,14 +2,14 @@> Supported browser and server clients for the OpenVibe platform.--**Status:** alpha, v0.57.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.58.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.57.0++npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.58.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).@@@ -193,6 +193,9 @@ Until OpenVibe.Tools serves the gateway facade (Tools S6), point the jobs client| `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/reviews` | server | `createReviewsClient(client)`: OpenVibe.Reviews. `resolve({name, url, gtin, sku, mpn, source, external})` (a match or candidates; a name alone never matches), `entities.list({q, limit, offset})/get(ref)/history/aggregate/summaryRevision(ref, n)`, `corrections.submit(ref, {body, target_type, target_id, evidence_url})` (to the editors' queue for the person, never retried on its own). Public capabilities since openvibe-contracts 0.207.0. Audience `openvibe.reviews` || `openvibe-sdk/wiki` | server | `createWikiClient(client)`: OpenVibe.Wiki's reads. `search(q, {space, limit})`, `spaces.list/get(space)`, `pages.get(id, {revision})/revisions(id, {before, limit})/revision(id, n)/diff(id, {from, to, mode})/citations(id, n)`: what the person may read (without one, public pages). Public capabilities since openvibe-contracts 0.207.0. Audience `openvibe.wiki` |++| `openvibe-sdk/coupons` | server | `createCouponsClient(client)`: OpenVibe.Coupons. `merchants.resolve(host)/get(id)/coupons(id)` and `get(cpn_…)` (public data), `submit({code, title, merchant_id \| host \| url, evidence_url, …})` (sensitive; never retried on its own) and `report(cpn_…, {outcome, reason})` for the person. Public capabilities since openvibe-contracts 0.208.0. Audience `openvibe.coupons` |++| `openvibe-sdk/deals` | server | `createDealsClient(client)`: OpenVibe.Deals. Public: `offers.list({sort, page})/get/hotness`, `products.get`, `stores.get`. For the person: `offers.submit` (sensitive), `update`, `observe` (a new price observation), `vote(id, 1 \| -1)` (sensitive), `unvote`, `flag(id, {kind, reason})`, `watches.list/create/remove`. Public capabilities since openvibe-contracts 0.208.0. Audience `openvibe.deals` |++| `openvibe-sdk/trade` | server | `createTradeClient(client)`: OpenVibe.Trade. `instruments.resolve(q)/list/get/observations(symbol, {metric, before, limit})/documents`, `sources()`; the person's `watchlists.list/get/create/rename/add/removeItem/remove` and `alerts.list/deliveries/create/remove`. Public capabilities since openvibe-contracts 0.208.0. Audience `openvibe.trade` || `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` |@@@ -479,7 +482,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 (Coupons, Deals, News, Space, Trade, Watch and others) have no module yet: there is nothing an outside app may call. Blog opened its posts to apps (openvibe-contracts 0.206.0, `openvibe-sdk/blog`), then Reviews and the Wiki their reads (0.207.0). News' published stories need no capability, but its editorial reads stay first-party. 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 (News, Space, Watch, Codes, Host and others) have no module yet: there is nothing an outside app may call. Blog opened its posts to apps (openvibe-contracts 0.206.0, `openvibe-sdk/blog`), then Reviews and the Wiki their reads (0.207.0), then Coupons, Deals and Trade what a person does for themselves (0.208.0). News' published stories need no capability, but its editorial reads stay first-party. 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.@@@ -3,7 +3,7 @@"stage": "alpha","code": true,"wave": "W2",-- "version": "0.57.0",++ "version": "0.58.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",@@@ -1,4 +1,4 @@--// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.57.0, MIT). Do not edit.++// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.58.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.57.0';++const SDK_VERSION = '0.58.0';module.exports = {createClient,nnew file mode 100644@@@ -0,0 +1,7 @@++// Generated by scripts/esm.js from src/coupons.js. Do not edit.++import cjs from '../src/coupons.js';++++export const {++ createCouponsClient,++} = cjs;++export default cjs;nnew file mode 100644@@@ -0,0 +1,7 @@++// Generated by scripts/esm.js from src/deals.js. Do not edit.++import cjs from '../src/deals.js';++++export const {++ createDealsClient,++} = cjs;++export default cjs;@@@ -8,8 +8,9 @@ export const {registry, identity, modules, events, realtime, media,community, bot, search, chat, ai, jobs,tools, projects, resources, vip, quest, live,-- inventory, tips, blog, reviews, wiki, food,-- actor, run, video, work, zone, play,-- download, openre, geo, usage, commerce, telemetry,++ inventory, tips, blog, reviews, wiki, coupons,++ deals, trade, food, actor, run, video,++ work, zone, 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/trade.js. Do not edit.++import cjs from '../src/trade.js';++++export const {++ createTradeClient,++} = cjs;++export default cjs;@@@ -32,6 +32,9 @@ module.exports = {blog: require('./src/blog'),reviews: require('./src/reviews'),wiki: require('./src/wiki'),++ coupons: require('./src/coupons'),++ deals: require('./src/deals'),++ trade: require('./src/trade'),food: require('./src/food'),actor: require('./src/actor'),run: require('./src/run'),@@@ -1,12 +1,12 @@{"name": "openvibe-sdk",-- "version": "0.57.0",++ "version": "0.58.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "openvibe-sdk",-- "version": "0.57.0",++ "version": "0.58.0","license": "MIT","bin": {"openvibe-download": "bin/openvibe-download.js"@@@ -1,6 +1,6 @@{"name": "openvibe-sdk",-- "version": "0.57.0",++ "version": "0.58.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",@@@ -326,6 +326,24 @@"import": "./esm/wiki.mjs","default": "./src/wiki.js"},++ "./coupons": {++ "types": "./types/coupons.d.ts",++ "browser": null,++ "import": "./esm/coupons.mjs",++ "default": "./src/coupons.js"++ },++ "./deals": {++ "types": "./types/deals.d.ts",++ "browser": null,++ "import": "./esm/deals.mjs",++ "default": "./src/deals.js"++ },++ "./trade": {++ "types": "./types/trade.d.ts",++ "browser": null,++ "import": "./esm/trade.mjs",++ "default": "./src/trade.js"++ },"./vip": {"types": "./types/vip.d.ts","browser": null,@@@ -61,6 +61,9 @@ const ENTRIES = {'blog.mjs': '../src/blog.js','reviews.mjs': '../src/reviews.js','wiki.mjs': '../src/wiki.js',++ 'coupons.mjs': '../src/coupons.js',++ 'deals.mjs': '../src/deals.js',++ 'trade.mjs': '../src/trade.js','food.mjs': '../src/food.js','actor.mjs': '../src/actor.js','run.mjs': '../src/run.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.57.0';++const SDK_VERSION = '0.58.0';module.exports = {createClient,nnew file mode 100644@@@ -0,0 +1,64 @@++'use strict';++/**++ * openvibe-sdk/coupons — OpenVibe.Coupons for apps (a browser extension, a shopping bot): which store a site is, its++ * active codes with their evidence, and, for the person who authorized the app, submitting a code and reporting++ * whether one worked. Routes at https://openvibe.coupons/api/v1; tokens for audience openvibe.coupons. An app acts++ * only for its on_behalf_of person.++ *++ * const coupons = createCouponsClient(createClient({ tokenProvider }));++ * const { merchant } = await coupons.merchants.resolve('www.example-store.com'); // public data++ * const { coupons: codes } = await coupons.merchants.coupons(merchant.id);++ * await coupons.report(codes[0].id, { outcome: 'failed', reason: 'expired' }); // one report a day per code++ * await coupons.submit({ host: 'example-store.com', code: 'SAVE10', title: '10% off', evidence_url: 'https://…' });++ *++ * Capabilities (public since openvibe-contracts 0.208.0): coupons.merchant.resolve, coupons.coupon.lookup,++ * coupons.coupon.submit (sensitive: a code under the person's name; it starts as status unknown, and a status,++ * confidence or "verified" field is refused) and coupons.report.create. Submitting is never retried on its own;++ * a report is (only the person's latest one counts).++ */++const enc = encodeURIComponent;++const COUPON_ID_RE = /^cpn_[0-9A-HJKMNP-TV-Z]{26}$/; // Coupons' own rule++const OUTCOMES = ['worked', 'failed'];++const REASONS = ['invalid', 'expired', 'min_spend_not_met', 'not_eligible', 'other'];++++function createCouponsClient(client, { baseUrl } = {}) {++ if (!client || typeof client.json !== 'function') throw new TypeError('createCouponsClient: pass an openvibe-sdk/core client');++ const at = { service: 'coupons', baseUrl, audience: 'openvibe.coupons' };++ const call = (opts) => client.json({ ...at, ...opts });++ const coupon = (id) => {++ if (!COUPON_ID_RE.test(String(id || ''))) throw new TypeError('coupons: a coupon is a cpn_ id');++ return `/api/v1/coupons/${enc(String(id))}`;++ };++ const merchant = (id) => {++ if (!id || typeof id !== 'string') throw new TypeError("coupons: a merchant's id");++ return `/api/v1/merchants/${enc(id)}`;++ };++++ return {++ merchants: {++ /** The store a hostname belongs to (subdomain rules; never a path rule). */++ resolve: (host, { signal } = {}) => {++ if (!host || typeof host !== 'string') throw new TypeError('coupons.merchants.resolve: a hostname');++ return call({ path: '/api/v1/merchants/resolve', query: { host }, signal });++ },++ get: (id, { signal } = {}) => call({ path: merchant(id), signal }),++ /** Its active codes: status, confidence, report aggregates, restrictions, expiry (or unknown), evidence. */++ coupons: (id, { signal } = {}) => call({ path: `${merchant(id)}/coupons`, signal }),++ },++ get: (id, { signal } = {}) => call({ path: coupon(id), signal }),++ /** A code for a store (by merchant_id, host or url): code and title required, evidence_url recommended. */++ submit: (fields, { signal } = {}) => {++ if (!fields || !fields.code || !fields.title) throw new TypeError('coupons.submit: code and title');++ if (!fields.merchant_id && !fields.host && !fields.url) throw new TypeError('coupons.submit: merchant_id, host or url');++ return call({ method: 'POST', path: '/api/v1/coupons/submit', json: fields, idempotencyKey: false, signal });++ },++ /** Did it work? { outcome: worked | failed, reason? } → the code's aggregates (never who reported). */++ report: (id, { outcome, reason } = {}, { signal } = {}) => {++ if (!OUTCOMES.includes(outcome)) throw new TypeError("coupons.report: outcome is 'worked' or 'failed'");++ if (reason != null && !REASONS.includes(reason)) throw new TypeError(`coupons.report: reason is one of ${REASONS.join(', ')}`);++ return call({ method: 'POST', path: `${coupon(id)}/report`, json: { outcome, reason }, idempotent: true, signal });++ },++ };++}++++module.exports = { createCouponsClient };nnew file mode 100644@@@ -0,0 +1,85 @@++'use strict';++/**++ * openvibe-sdk/deals — OpenVibe.Deals for apps: the hot and new offers, an offer with its hotness, products and stores++ * (public), and, for the person who authorized the app, posting deals, recording what a price is now, voting,++ * flagging and keeping watches. Routes at https://openvibe.deals/api/v1; tokens for audience openvibe.deals. An app++ * acts only for its on_behalf_of person.++ *++ * const deals = createDealsClient(createClient({ tokenProvider }));++ * const { offers } = await deals.offers.list({ sort: 'hot' }); // public++ * const { offer } = await deals.offers.submit({ url: 'https://…', title: 'GPU at $299', price: 299, currency: 'USD' });++ * await deals.offers.observe(offer.id, { price: 279, currency: 'USD', availability: 'in_stock' });++ * await deals.offers.vote(offers[0].id, 1);++ * await deals.watches.create({ kind: 'price_below', product: 'rtx-4070', max_price: 450, currency: 'USD' });++ *++ * Capabilities (public since openvibe-contracts 0.208.0): deals.offer.submit (sensitive), deals.offer.update (the++ * person's own offers, and price observations of any active offer), deals.vote.set (sensitive) and .remove,++ * deals.flag.create, deals.watch.create, .read and .delete. Votes and hotness are Deals' own (never from the request);++ * no votes on one's own offer. Submitting, observing, flagging and creating a watch make a new row each time and are++ * never retried on their own; a link already posted answers 409 offer.duplicate with the existing offer.++ */++const enc = encodeURIComponent;++const SORTS = ['hot', 'new'];++const FLAGS = ['expired', 'price_wrong', 'spam', 'duplicate', 'other'];++const WATCHES = ['keyword', 'product', 'price_below', 'search'];++++function createDealsClient(client, { baseUrl } = {}) {++ if (!client || typeof client.json !== 'function') throw new TypeError('createDealsClient: pass an openvibe-sdk/core client');++ const at = { service: 'deals', baseUrl, audience: 'openvibe.deals' };++ const call = (opts) => client.json({ ...at, ...opts });++ const once = (opts) => call({ ...opts, idempotencyKey: false });++ const offer = (id, rest = '') => {++ if (!id || typeof id !== 'string') throw new TypeError("deals: an offer's id or slug");++ return `/api/v1/offers/${enc(id)}${rest}`;++ };++++ return {++ offers: {++ /** Hot (Deals' hot@1 ranking) or new offers, a page at a time (public). */++ list: ({ sort, page, signal } = {}) => {++ if (sort != null && !SORTS.includes(sort)) throw new TypeError("deals.offers.list: sort is 'hot' or 'new'");++ return call({ path: '/api/v1/offers', query: { sort, page }, signal });++ },++ /** By id or slug; a merged offer answers with its canonical one (public). */++ get: (id, { signal } = {}) => call({ path: offer(id), signal }),++ hotness: (id, { signal } = {}) => call({ path: offer(id, '/hotness'), signal }),++ /** Post a deal: url and title, and what the person sees now (price, currency, shipping, condition, availability). */++ submit: (fields, { signal } = {}) => {++ if (!fields || !fields.url || !fields.title) throw new TypeError('deals.offers.submit: url and title');++ return once({ method: 'POST', path: '/api/v1/offers', json: fields, signal });++ },++ /** Edit the person's own offer: title, description, category, expires_at, product. */++ update: (id, patch, { signal } = {}) => call({ method: 'PATCH', path: offer(id), json: patch, idempotent: true, signal }),++ /** What the price is now (a new observation; prices are never edited in place). */++ observe: (id, observation, { signal } = {}) => once({ method: 'POST', path: offer(id, '/observations'), json: observation, signal }),++ /** +1 or -1 for the person (never on their own offer). */++ vote: (id, value, { signal } = {}) => {++ if (value !== 1 && value !== -1) throw new TypeError('deals.offers.vote: 1 or -1');++ return call({ method: 'PUT', path: offer(id, '/vote'), json: { value }, signal });++ },++ unvote: (id, { signal } = {}) => call({ method: 'DELETE', path: offer(id, '/vote'), signal }),++ /** Report a problem: { kind, reason?, duplicate_of? }; one open report per person and offer. */++ flag: (id, { kind, reason, duplicate_of: duplicateOf } = {}, { signal } = {}) => {++ if (!FLAGS.includes(kind)) throw new TypeError(`deals.offers.flag: kind is one of ${FLAGS.join(', ')}`);++ return once({ method: 'POST', path: offer(id, '/flags'), json: { kind, reason, duplicate_of: duplicateOf }, signal });++ },++ },++ products: {++ get: (slug, { signal } = {}) => call({ path: `/api/v1/products/${enc(String(slug))}`, signal }),++ },++ stores: {++ get: (domain, { signal } = {}) => call({ path: `/api/v1/stores/${enc(String(domain))}`, signal }),++ },++ watches: {++ list: ({ signal } = {}) => call({ path: '/api/v1/watches', signal }),++ /** A keyword, product or price-below watch, or a saved search (never notifies). */++ create: (fields, { signal } = {}) => {++ if (!fields || !WATCHES.includes(fields.kind)) throw new TypeError(`deals.watches.create: kind is one of ${WATCHES.join(', ')}`);++ return once({ method: 'POST', path: '/api/v1/watches', json: fields, signal });++ },++ remove: (id, { signal } = {}) => call({ method: 'DELETE', path: `/api/v1/watches/${enc(String(id))}`, signal }),++ },++ };++}++++module.exports = { createDealsClient };nnew file mode 100644@@@ -0,0 +1,73 @@++'use strict';++/**++ * openvibe-sdk/trade — OpenVibe.Trade for apps: instruments with their sourced observations and filings, the sources'++ * freshness (public), and, for the person who authorized the app, their watchlists and alert rules. Routes at++ * https://openvibe.trade/api/v1; tokens for audience openvibe.trade. An app acts only for its on_behalf_of person.++ * Trade states what sources said, with times; it gives no advice.++ *++ * const trade = createTradeClient(createClient({ tokenProvider }));++ * const { instrument } = await trade.instruments.resolve('AAPL'); // CIK, ticker, exact name++ * const obs = await trade.instruments.observations('AAPL', { metric: 'price', limit: 30 });++ * const { watchlist } = await trade.watchlists.create({ name: 'Robots' });++ * await trade.watchlists.add(watchlist.id, 'AAPL');++ * await trade.alerts.create({ symbol: 'AAPL', kind: 'filing_type', form_types: ['8-K'] });++ *++ * Capabilities (public since openvibe-contracts 0.208.0): trade.instrument.resolve, trade.watchlist.create, .read,++ * .update and .delete, trade.alert.create, .read and .delete. A person's watchlists and alerts are theirs alone++ * (another person's is 404). Creating a watchlist or an alert is never retried on its own. Alerts are delivered as++ * trade.alert.triggered events, never by email.++ */++const enc = encodeURIComponent;++const ALERT_KINDS = ['threshold', 'filing_type', 'new_document'];++++function createTradeClient(client, { baseUrl } = {}) {++ if (!client || typeof client.json !== 'function') throw new TypeError('createTradeClient: pass an openvibe-sdk/core client');++ const at = { service: 'trade', baseUrl, audience: 'openvibe.trade' };++ const call = (opts) => client.json({ ...at, ...opts });++ const sym = (s) => {++ if (!s || typeof s !== 'string') throw new TypeError("trade: an instrument's symbol");++ return enc(s);++ };++ const list = (id, rest = '') => {++ if (!id || typeof id !== 'string') throw new TypeError("trade: a watchlist's id");++ return `/api/v1/watchlists/${enc(id)}${rest}`;++ };++++ return {++ instruments: {++ /** A ticker, SEC CIK or exact company name → the instrument (several name matches are "ambiguous"). */++ resolve: (q, { kind, signal } = {}) => call({ path: '/api/v1/instruments/resolve', query: { q, kind }, signal }),++ list: ({ limit, offset, signal } = {}) => call({ path: '/api/v1/instruments', query: { limit, offset }, signal }),++ get: (symbol, { signal } = {}) => call({ path: `/api/v1/instruments/${sym(symbol)}`, signal }),++ /** History with freshness, for one metric or all. */++ observations: (symbol, { metric, before, limit, signal } = {}) => call({ path: `/api/v1/instruments/${sym(symbol)}/observations`, query: { metric, before, limit }, signal }),++ documents: (symbol, { limit, offset, signal } = {}) => call({ path: `/api/v1/instruments/${sym(symbol)}/documents`, query: { limit, offset }, signal }),++ },++ /** Every source and how fresh it is. */++ sources: ({ signal } = {}) => call({ path: '/api/v1/sources', signal }),++ watchlists: {++ list: ({ signal } = {}) => call({ path: '/api/v1/watchlists', signal }),++ get: (id, { signal } = {}) => call({ path: list(id), signal }),++ create: ({ name } = {}, { signal } = {}) => {++ if (!name || typeof name !== 'string') throw new TypeError('trade.watchlists.create: a name');++ return call({ method: 'POST', path: '/api/v1/watchlists', json: { name }, idempotencyKey: false, signal });++ },++ rename: (id, name, { signal } = {}) => call({ method: 'PATCH', path: list(id), json: { name }, idempotent: true, signal }),++ add: (id, symbol, { signal } = {}) => call({ method: 'PUT', path: list(id, `/items/${sym(symbol)}`), signal }),++ removeItem: (id, symbol, { signal } = {}) => call({ method: 'DELETE', path: list(id, `/items/${sym(symbol)}`), signal }),++ remove: (id, { signal } = {}) => call({ method: 'DELETE', path: list(id), signal }),++ },++ alerts: {++ list: ({ signal } = {}) => call({ path: '/api/v1/alerts', signal }),++ deliveries: ({ limit, signal } = {}) => call({ path: '/api/v1/alerts/deliveries', query: { limit }, signal }),++ /** threshold (metric, operator, threshold, unit), filing_type (form_types) or new_document, for a symbol. */++ create: (rule, { signal } = {}) => {++ if (!rule || !rule.symbol || !ALERT_KINDS.includes(rule.kind)) throw new TypeError(`trade.alerts.create: a symbol and kind (${ALERT_KINDS.join(', ')})`);++ return call({ method: 'POST', path: '/api/v1/alerts', json: rule, idempotencyKey: false, signal });++ },++ remove: (id, { signal } = {}) => call({ method: 'DELETE', path: `/api/v1/alerts/${enc(String(id))}`, signal }),++ },++ };++}++++module.exports = { createTradeClient };@@@ -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', './blog', './cache', './commerce', './cost', './db', './delivery', './download', './events', './food', './govern', './identity', './inventory', './limits', './live', './node', './notifications', './openre', './placement', './play', './pubsub', './quest', './queue', './resources', './reviews', './run', './runtime', './service', './sso', './storage', './telemetry', './testing', './tips', './usage', './valkey', './video', './vip', './wiki', './work', './zone']);++ assert.deepEqual(blocked.sort(), ['./account-data', './actor', './blog', './cache', './commerce', './cost', './coupons', './db', './deals', './delivery', './download', './events', './food', './govern', './identity', './inventory', './limits', './live', './node', './notifications', './openre', './placement', './play', './pubsub', './quest', './queue', './resources', './reviews', './run', './runtime', './service', './sso', './storage', './telemetry', './testing', './tips', './trade', './usage', './valkey', './video', './vip', './wiki', './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`);@@@ -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, 59);++ assert.equal(subpaths.length, 62);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 });@@@ -1,5 +1,5 @@'use strict';--// openvibe-sdk/food, /actor, /run, /video, /work, /zone, /blog, /reviews and /wiki through a real core client against one local stub: every++// openvibe-sdk/food, /actor, /run, /video, /work, /zone, /blog, /reviews, /wiki, /coupons, /deals and /trade 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');@@@ -14,9 +14,12 @@ const { createZoneClient } = require('../src/zone');const { createBlogClient } = require('../src/blog');const { createReviewsClient } = require('../src/reviews');const { createWikiClient } = require('../src/wiki');++const { createCouponsClient } = require('../src/coupons');++const { createDealsClient } = require('../src/deals');++const { createTradeClient } = require('../src/trade');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}`, post: `pst_${ULID}`, page: `pg_${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}`, page: `pg_${ULID}`, coupon: `cpn_${ULID}` };(async () => {const seen = [];@@@ -47,7 +50,7 @@ const ids = { plan: `pln_${ULID}`, task: `tsk_${ULID}`, agent: `agt_${ULID}`, meconst 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`, blog: `${base}/blog`, reviews: `${base}/reviews`, wiki: `${base}/wiki` },++ baseUrls: { food: `${base}/food`, actor: `${base}/actor`, run: `${base}/run`, 'media-hub': `${base}/video`, work: `${base}/work`, zone: `${base}/zone`, blog: `${base}/blog`, reviews: `${base}/reviews`, wiki: `${base}/wiki`, coupons: `${base}/coupons`, deals: `${base}/deals`, trade: `${base}/trade` },getToken: ({ audience }) => { audiences.push(audience); return `tok-${audience}`; },retries: 2, retryDelayMs: 1, maxRetryDelayMs: 2,});@@@ -290,13 +293,95 @@ const ids = { plan: `pln_${ULID}`, task: `tsk_${ULID}`, agent: `agt_${ULID}`, meassert.throws(() => wiki.pages.get('page_1'), /pg_/);assert.throws(() => wiki.pages.diff(ids.page, { from: 0, to: 2 }), /revision number/);++ // ── Coupons ───────────────────────────────────────────++ const coupons = createCouponsClient(client);++ mark = since();++ await coupons.merchants.resolve('www.example-store.com');++ await coupons.merchants.get('mer_1');++ await coupons.merchants.coupons('mer_1');++ await coupons.get(ids.coupon);++ await busyOnce(() => coupons.submit({ host: 'example-store.com', code: 'SAVE10', title: '10% off' }));++ await coupons.report(ids.coupon, { outcome: 'failed', reason: 'expired' }); // only the latest counts: retried++ const C = `/api/v1/coupons/${ids.coupon}`;++ const cp = mark();++ assert.deepStrictEqual(cp.map((x) => `${x.method} ${x.url}`), [++ 'GET /api/v1/merchants/resolve?host=www.example-store.com', 'GET /api/v1/merchants/mer_1', 'GET /api/v1/merchants/mer_1/coupons', `GET ${C}`,++ 'POST /api/v1/coupons/submit', `POST ${C}/report`, `POST ${C}/report`,++ ]);++ assert.deepStrictEqual(cp[5].body, { outcome: 'failed', reason: 'expired' });++ assert.throws(() => coupons.submit({ code: 'X', title: 'Y' }), /merchant_id, host or url/);++ assert.throws(() => coupons.report(ids.coupon, { outcome: 'maybe' }), /worked/);++ assert.throws(() => coupons.get('coupon_1'), /cpn_/);++++ // ── Deals ─────────────────────────────────────────────++ const deals = createDealsClient(client);++ mark = since();++ await deals.offers.list({ sort: 'hot', page: 2 });++ await deals.offers.get('gpu-299');++ await deals.offers.hotness('gpu-299');++ await busyOnce(() => deals.offers.submit({ url: 'https://shop.example/gpu', title: 'GPU at $299', price: 299, currency: 'USD' }));++ await deals.offers.update('off_1', { title: 'GPU at $279' });++ await busyOnce(() => deals.offers.observe('off_1', { price: 279, currency: 'USD' }));++ await deals.offers.vote('off_2', -1); // PUT: retried++ await deals.offers.unvote('off_2');++ await busyOnce(() => deals.offers.flag('off_2', { kind: 'expired' }));++ await deals.products.get('rtx-4070');++ await deals.stores.get('shop.example');++ await deals.watches.list();++ await busyOnce(() => deals.watches.create({ kind: 'price_below', product: 'rtx-4070', max_price: 450, currency: 'USD' }));++ await deals.watches.remove('wat_1');++ const dl = mark();++ assert.deepStrictEqual(dl.map((x) => `${x.method} ${x.url}`), [++ 'GET /api/v1/offers?sort=hot&page=2', 'GET /api/v1/offers/gpu-299', 'GET /api/v1/offers/gpu-299/hotness', 'POST /api/v1/offers',++ 'PATCH /api/v1/offers/off_1', 'PATCH /api/v1/offers/off_1', 'POST /api/v1/offers/off_1/observations', 'PUT /api/v1/offers/off_2/vote',++ 'PUT /api/v1/offers/off_2/vote', 'DELETE /api/v1/offers/off_2/vote', 'DELETE /api/v1/offers/off_2/vote', 'POST /api/v1/offers/off_2/flags',++ 'GET /api/v1/products/rtx-4070', 'GET /api/v1/stores/shop.example', 'GET /api/v1/watches', 'POST /api/v1/watches',++ 'DELETE /api/v1/watches/wat_1', 'DELETE /api/v1/watches/wat_1',++ ]);++ assert.deepStrictEqual(dl[7].body, { value: -1 });++ assert.throws(() => deals.offers.vote('off_2', 2), /1 or -1/);++ assert.throws(() => deals.offers.flag('off_2', { kind: 'meh' }), /kind is one of/);++ assert.throws(() => deals.offers.list({ sort: 'top' }), /hot/);++++ // ── Trade ─────────────────────────────────────────────++ const trade = createTradeClient(client);++ mark = since();++ await trade.instruments.resolve('AAPL');++ await trade.instruments.list({ limit: 5 });++ await trade.instruments.get('AAPL');++ await trade.instruments.observations('AAPL', { metric: 'price', limit: 30 });++ await trade.instruments.documents('AAPL', { limit: 3 });++ await trade.sources();++ await trade.watchlists.list();++ await busyOnce(() => trade.watchlists.create({ name: 'Robots' }));++ await trade.watchlists.get('wl_1');++ await trade.watchlists.rename('wl_1', 'Robot makers');++ await trade.watchlists.add('wl_1', 'AAPL');++ await trade.watchlists.removeItem('wl_1', 'AAPL');++ await trade.watchlists.remove('wl_1');++ await trade.alerts.list();++ await trade.alerts.deliveries({ limit: 10 });++ await busyOnce(() => trade.alerts.create({ symbol: 'AAPL', kind: 'filing_type', form_types: ['8-K'] }));++ await trade.alerts.remove('alr_1');++ const tr = mark();++ assert.deepStrictEqual(tr.map((x) => `${x.method} ${x.url}`), [++ 'GET /api/v1/instruments/resolve?q=AAPL', 'GET /api/v1/instruments?limit=5', 'GET /api/v1/instruments/AAPL',++ 'GET /api/v1/instruments/AAPL/observations?metric=price&limit=30', 'GET /api/v1/instruments/AAPL/documents?limit=3', 'GET /api/v1/sources',++ 'GET /api/v1/watchlists', 'POST /api/v1/watchlists', 'GET /api/v1/watchlists/wl_1', 'PATCH /api/v1/watchlists/wl_1', 'PATCH /api/v1/watchlists/wl_1',++ 'PUT /api/v1/watchlists/wl_1/items/AAPL', 'PUT /api/v1/watchlists/wl_1/items/AAPL', 'DELETE /api/v1/watchlists/wl_1/items/AAPL',++ 'DELETE /api/v1/watchlists/wl_1/items/AAPL', 'DELETE /api/v1/watchlists/wl_1', 'DELETE /api/v1/watchlists/wl_1', 'GET /api/v1/alerts',++ 'GET /api/v1/alerts/deliveries?limit=10', 'POST /api/v1/alerts', 'DELETE /api/v1/alerts/alr_1', 'DELETE /api/v1/alerts/alr_1',++ ]);++ assert.throws(() => trade.alerts.create({ symbol: 'AAPL', kind: 'rumour' }), /kind/);++ assert.throws(() => trade.watchlists.create({}), /name/);++// 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.blog', 'openvibe.download', 'openvibe.food', 'openvibe.reviews', 'openvibe.run', 'openvibe.wiki', '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', reviews: 'openvibe.reviews', wiki: 'openvibe.wiki' }[x.svc]}`));++ assert.deepStrictEqual([...new Set(audiences)].sort(), ['openvibe.actor', 'openvibe.blog', 'openvibe.coupons', 'openvibe.deals', 'openvibe.download', 'openvibe.food', 'openvibe.reviews', 'openvibe.run', 'openvibe.trade', 'openvibe.wiki', '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', reviews: 'openvibe.reviews', wiki: 'openvibe.wiki', coupons: 'openvibe.coupons', deals: 'openvibe.deals', trade: 'openvibe.trade' }[x.svc]}`));// Each client needs a core client.-- for (const make of [createFoodClient, createActorClient, createRunClient, createVideoClient, createWorkClient, createZoneClient, createBlogClient, createReviewsClient, createWikiClient]) assert.throws(() => make({}), /core client/);-- console.log('product modules (food, actor, run, video, work, zone, blog, reviews, wiki): all checks passed');++ for (const make of [createFoodClient, createActorClient, createRunClient, createVideoClient, createWorkClient, createZoneClient, createBlogClient, createReviewsClient, createWikiClient, createCouponsClient, createDealsClient, createTradeClient]) assert.throws(() => make({}), /core client/);++ console.log('product modules (food, actor, run, video, work, zone, blog, reviews, wiki, coupons, deals, trade): all checks passed');} finally {server.close();}nnew file mode 100644@@@ -0,0 +1,20 @@++/** openvibe-sdk/coupons: OpenVibe.Coupons — stores, their codes, and submitting and reporting codes for the person. */++type Opts = { signal?: AbortSignal };++type CouponsJson = Record<string, any>;++export type ReportOutcome = 'worked' | 'failed';++export type ReportReason = 'invalid' | 'expired' | 'min_spend_not_met' | 'not_eligible' | 'other';++export interface CouponSubmission {++ code: string; title: string; merchant_id?: string; host?: string; url?: string; description?: string | null; expires?: string | null;++ expiry_basis?: 'submitter' | 'evidence'; evidence_url?: string; restrictions?: Record<string, unknown>; hint?: string | null; [k: string]: unknown;++}++export interface CouponsClient {++ merchants: {++ resolve(host: string, opts?: Opts): Promise<CouponsJson>;++ get(id: string, opts?: Opts): Promise<CouponsJson>;++ coupons(id: string, opts?: Opts): Promise<CouponsJson>;++ };++ get(id: string, opts?: Opts): Promise<CouponsJson>;++ submit(fields: CouponSubmission, opts?: Opts): Promise<CouponsJson>;++ report(id: string, req: { outcome: ReportOutcome; reason?: ReportReason | null }, opts?: Opts): Promise<CouponsJson>;++}++export function createCouponsClient(client: { json(opts: Record<string, unknown>): Promise<any> }, options?: { baseUrl?: string }): CouponsClient;nnew file mode 100644@@@ -0,0 +1,27 @@++/** openvibe-sdk/deals: OpenVibe.Deals — offers, products and stores, and posting, voting, flagging and watches for the person. */++type Opts = { signal?: AbortSignal };++type DealsJson = Record<string, any>;++export type FlagKind = 'expired' | 'price_wrong' | 'spam' | 'duplicate' | 'other';++export type WatchKind = 'keyword' | 'product' | 'price_below' | 'search';++export interface Observation { price?: string | number | null; currency?: string | null; shipping?: string | number | null; shipping_note?: string | null; condition?: string | null; availability?: string | null; [k: string]: unknown }++export interface DealsClient {++ offers: {++ list(opts?: Opts & { sort?: 'hot' | 'new'; page?: number }): Promise<DealsJson>;++ get(id: string, opts?: Opts): Promise<DealsJson>;++ hotness(id: string, opts?: Opts): Promise<DealsJson>;++ submit(fields: Observation & { url: string; title: string; description?: string | null; category?: string | null; expires_at?: string | null; store_name?: string | null; product_slug?: string | null }, opts?: Opts): Promise<DealsJson>;++ update(id: string, patch: { title?: string; description?: string | null; category?: string | null; expires_at?: string | null; product?: unknown }, opts?: Opts): Promise<DealsJson>;++ observe(id: string, observation: Observation, opts?: Opts): Promise<DealsJson>;++ vote(id: string, value: 1 | -1, opts?: Opts): Promise<DealsJson>;++ unvote(id: string, opts?: Opts): Promise<DealsJson>;++ flag(id: string, req: { kind: FlagKind; reason?: string | null; duplicate_of?: string | null }, opts?: Opts): Promise<DealsJson>;++ };++ products: { get(slug: string, opts?: Opts): Promise<DealsJson> };++ stores: { get(domain: string, opts?: Opts): Promise<DealsJson> };++ watches: {++ list(opts?: Opts): Promise<DealsJson>;++ create(fields: { kind: WatchKind; query?: string | null; product?: string | null; max_price?: string | number | null; currency?: string | null; label?: string | null }, opts?: Opts): Promise<DealsJson>;++ remove(id: string, opts?: Opts): Promise<DealsJson>;++ };++}++export function createDealsClient(client: { json(opts: Record<string, unknown>): Promise<any> }, options?: { baseUrl?: string }): DealsClient;@@@ -23,6 +23,9 @@ export * as tips from './tips';export * as blog from './blog';export * as reviews from './reviews';export * as wiki from './wiki';++export * as coupons from './coupons';++export * as deals from './deals';++export * as trade from './trade';export * as food from './food';export * as actor from './actor';export * as run from './run';nnew file mode 100644@@@ -0,0 +1,34 @@++/** openvibe-sdk/trade: OpenVibe.Trade — instruments, observations, filings and sources, and the person's watchlists and alerts. */++type Opts = { signal?: AbortSignal };++type TradeJson = Record<string, any>;++export type AlertKind = 'threshold' | 'filing_type' | 'new_document';++export interface AlertRule {++ symbol: string; kind: AlertKind; metric?: string; operator?: 'above' | 'below'; threshold?: string | number; unit?: string;++ currency?: string | null; form_types?: string[] | string;++}++export interface TradeClient {++ instruments: {++ resolve(q: string, opts?: Opts & { kind?: string }): Promise<TradeJson>;++ list(opts?: Opts & { limit?: number; offset?: number }): Promise<TradeJson>;++ get(symbol: string, opts?: Opts): Promise<TradeJson>;++ observations(symbol: string, opts?: Opts & { metric?: string; before?: string; limit?: number }): Promise<TradeJson>;++ documents(symbol: string, opts?: Opts & { limit?: number; offset?: number }): Promise<TradeJson>;++ };++ sources(opts?: Opts): Promise<TradeJson>;++ watchlists: {++ list(opts?: Opts): Promise<TradeJson>;++ get(id: string, opts?: Opts): Promise<TradeJson>;++ create(req: { name: string }, opts?: Opts): Promise<TradeJson>;++ rename(id: string, name: string, opts?: Opts): Promise<TradeJson>;++ add(id: string, symbol: string, opts?: Opts): Promise<TradeJson>;++ removeItem(id: string, symbol: string, opts?: Opts): Promise<TradeJson>;++ remove(id: string, opts?: Opts): Promise<TradeJson>;++ };++ alerts: {++ list(opts?: Opts): Promise<TradeJson>;++ deliveries(opts?: Opts & { limit?: number }): Promise<TradeJson>;++ create(rule: AlertRule, opts?: Opts): Promise<TradeJson>;++ remove(id: string, opts?: Opts): Promise<TradeJson>;++ };++}++export function createTradeClient(client: { json(opts: Record<string, unknown>): Promise<any> }, options?: { baseUrl?: string }): TradeClient;
@@ -3,6 +3,15 @@
@@ -3,6 +3,15 @@
All notable changes to `openvibe-sdk`. The package follows semver; while it is `0.x`, a minor
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.
release may change an API and says so here.
+## 0.58.0 (2026-10-20)
+
+- **`openvibe-sdk/coupons`**, **`openvibe-sdk/deals`** and **`openvibe-sdk/trade`**: what a person does for themselves
+ on those sites, public in openvibe-contracts 0.208.0. Coupons: which store a site is, its codes, submitting a code and
+ reporting whether one worked (what a browser extension needs). Deals: hot and new offers, posting, price
+ observations, votes, flags and watches. Trade: instruments with their sourced observations and filings, and the
+ person's watchlists and alert rules. Moderation stays with each site. Writes that make a new row each time are
+ never retried on their own.
+
## 0.57.0 (2026-10-20)
## 0.57.0 (2026-10-20)
- **`openvibe-sdk/reviews`** (`createReviewsClient`): OpenVibe.Reviews for apps, whose reads became public in
- **`openvibe-sdk/reviews`** (`createReviewsClient`): OpenVibe.Reviews for apps, whose reads became public in
@@ -2,14 +2,14 @@
@@ -2,14 +2,14 @@
> Supported browser and server clients for the OpenVibe platform.
> Supported browser and server clients for the OpenVibe platform.
-**Status:** alpha, v0.57.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.58.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.
**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.
**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.
**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
```bash
-npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.57.0
+npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.58.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).
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).
@@ -193,6 +193,9 @@ Until OpenVibe.Tools serves the gateway facade (Tools S6), point the jobs client
@@ -193,6 +193,9 @@ Until OpenVibe.Tools serves the gateway facade (Tools S6), point the jobs client
| `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/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/reviews` | server | `createReviewsClient(client)`: OpenVibe.Reviews. `resolve({name, url, gtin, sku, mpn, source, external})` (a match or candidates; a name alone never matches), `entities.list({q, limit, offset})/get(ref)/history/aggregate/summaryRevision(ref, n)`, `corrections.submit(ref, {body, target_type, target_id, evidence_url})` (to the editors' queue for the person, never retried on its own). Public capabilities since openvibe-contracts 0.207.0. Audience `openvibe.reviews` |
| `openvibe-sdk/reviews` | server | `createReviewsClient(client)`: OpenVibe.Reviews. `resolve({name, url, gtin, sku, mpn, source, external})` (a match or candidates; a name alone never matches), `entities.list({q, limit, offset})/get(ref)/history/aggregate/summaryRevision(ref, n)`, `corrections.submit(ref, {body, target_type, target_id, evidence_url})` (to the editors' queue for the person, never retried on its own). Public capabilities since openvibe-contracts 0.207.0. Audience `openvibe.reviews` |
| `openvibe-sdk/wiki` | server | `createWikiClient(client)`: OpenVibe.Wiki's reads. `search(q, {space, limit})`, `spaces.list/get(space)`, `pages.get(id, {revision})/revisions(id, {before, limit})/revision(id, n)/diff(id, {from, to, mode})/citations(id, n)`: what the person may read (without one, public pages). Public capabilities since openvibe-contracts 0.207.0. Audience `openvibe.wiki` |
| `openvibe-sdk/wiki` | server | `createWikiClient(client)`: OpenVibe.Wiki's reads. `search(q, {space, limit})`, `spaces.list/get(space)`, `pages.get(id, {revision})/revisions(id, {before, limit})/revision(id, n)/diff(id, {from, to, mode})/citations(id, n)`: what the person may read (without one, public pages). Public capabilities since openvibe-contracts 0.207.0. Audience `openvibe.wiki` |
+| `openvibe-sdk/coupons` | server | `createCouponsClient(client)`: OpenVibe.Coupons. `merchants.resolve(host)/get(id)/coupons(id)` and `get(cpn_…)` (public data), `submit({code, title, merchant_id \| host \| url, evidence_url, …})` (sensitive; never retried on its own) and `report(cpn_…, {outcome, reason})` for the person. Public capabilities since openvibe-contracts 0.208.0. Audience `openvibe.coupons` |
+| `openvibe-sdk/deals` | server | `createDealsClient(client)`: OpenVibe.Deals. Public: `offers.list({sort, page})/get/hotness`, `products.get`, `stores.get`. For the person: `offers.submit` (sensitive), `update`, `observe` (a new price observation), `vote(id, 1 \| -1)` (sensitive), `unvote`, `flag(id, {kind, reason})`, `watches.list/create/remove`. Public capabilities since openvibe-contracts 0.208.0. Audience `openvibe.deals` |
+| `openvibe-sdk/trade` | server | `createTradeClient(client)`: OpenVibe.Trade. `instruments.resolve(q)/list/get/observations(symbol, {metric, before, limit})/documents`, `sources()`; the person's `watchlists.list/get/create/rename/add/removeItem/remove` and `alerts.list/deliveries/create/remove`. Public capabilities since openvibe-contracts 0.208.0. Audience `openvibe.trade` |
| `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/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/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` |
| `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` |
@@ -479,7 +482,7 @@ Install the drivers the service uses: `pg` and `iovalkey` (production), `@electr
@@ -479,7 +482,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:** 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`.
- **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.
- **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 (Coupons, Deals, News, Space, Trade, Watch and others) have no module yet: there is nothing an outside app may call. Blog opened its posts to apps (openvibe-contracts 0.206.0, `openvibe-sdk/blog`), then Reviews and the Wiki their reads (0.207.0). News' published stories need no capability, but its editorial reads stay first-party. 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 (News, Space, Watch, Codes, Host and others) have no module yet: there is nothing an outside app may call. Blog opened its posts to apps (openvibe-contracts 0.206.0, `openvibe-sdk/blog`), then Reviews and the Wiki their reads (0.207.0), then Coupons, Deals and Trade what a person does for themselves (0.208.0). News' published stories need no capability, but its editorial reads stay first-party. 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.
- **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.
- **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.
- **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.
@@ -3,7 +3,7 @@
@@ -3,7 +3,7 @@
"stage": "alpha",
"stage": "alpha",
"code": true,
"code": true,
"wave": "W2",
"wave": "W2",
- "version": "0.57.0",
+ "version": "0.58.0",
"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",
"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",
@@ -1,4 +1,4 @@
@@ -1,4 +1,4 @@
-// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.57.0, MIT). Do not edit.
+// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.58.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, registry, modules, realtime, media, community, bot, search, chat, ai, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity.
// (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 */
/* eslint-disable */
@@ -42,7 +42,7 @@ const { paginate, offsetPager } = __load(7);
@@ -42,7 +42,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.57.0';
+const SDK_VERSION = '0.58.0';
module.exports = {
module.exports = {
createClient,
createClient,
new file mode 100644
new file mode 100644
@@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
+// Generated by scripts/esm.js from src/coupons.js. Do not edit.
+import cjs from '../src/coupons.js';
+
+export const {
+ createCouponsClient,
+} = 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/deals.js. Do not edit.
+import cjs from '../src/deals.js';
+
+export const {
+ createDealsClient,
+} = cjs;
+export default cjs;
@@ -8,8 +8,9 @@ export const {
@@ -8,8 +8,9 @@ export const {
registry, identity, modules, events, realtime, media,
registry, identity, modules, events, realtime, media,
community, bot, search, chat, ai, jobs,
community, bot, search, chat, ai, jobs,
tools, projects, resources, vip, quest, live,
tools, projects, resources, vip, quest, live,
- inventory, tips, blog, reviews, wiki, food,
- actor, run, video, work, zone, play,
- download, openre, geo, usage, commerce, telemetry,
+ inventory, tips, blog, reviews, wiki, coupons,
+ deals, trade, food, actor, run, video,
+ work, zone, 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/trade.js. Do not edit.
+import cjs from '../src/trade.js';
+
+export const {
+ createTradeClient,
+} = cjs;
+export default cjs;
@@ -32,6 +32,9 @@ module.exports = {
@@ -32,6 +32,9 @@ module.exports = {
blog: require('./src/blog'),
blog: require('./src/blog'),
reviews: require('./src/reviews'),
reviews: require('./src/reviews'),
wiki: require('./src/wiki'),
wiki: require('./src/wiki'),
+ coupons: require('./src/coupons'),
+ deals: require('./src/deals'),
+ trade: require('./src/trade'),
food: require('./src/food'),
food: require('./src/food'),
actor: require('./src/actor'),
actor: require('./src/actor'),
run: require('./src/run'),
run: require('./src/run'),
@@ -1,12 +1,12 @@
@@ -1,12 +1,12 @@
{
{
"name": "openvibe-sdk",
"name": "openvibe-sdk",
- "version": "0.57.0",
+ "version": "0.58.0",
"lockfileVersion": 3,
"lockfileVersion": 3,
"requires": true,
"requires": true,
"packages": {
"packages": {
"": {
"": {
"name": "openvibe-sdk",
"name": "openvibe-sdk",
- "version": "0.57.0",
+ "version": "0.58.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.57.0",
+ "version": "0.58.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",
@@ -326,6 +326,24 @@
@@ -326,6 +326,24 @@
"import": "./esm/wiki.mjs",
"import": "./esm/wiki.mjs",
"default": "./src/wiki.js"
"default": "./src/wiki.js"
},
},
+ "./coupons": {
+ "types": "./types/coupons.d.ts",
+ "browser": null,
+ "import": "./esm/coupons.mjs",
+ "default": "./src/coupons.js"
+ },
+ "./deals": {
+ "types": "./types/deals.d.ts",
+ "browser": null,
+ "import": "./esm/deals.mjs",
+ "default": "./src/deals.js"
+ },
+ "./trade": {
+ "types": "./types/trade.d.ts",
+ "browser": null,
+ "import": "./esm/trade.mjs",
+ "default": "./src/trade.js"
+ },
"./vip": {
"./vip": {
"types": "./types/vip.d.ts",
"types": "./types/vip.d.ts",
"browser": null,
"browser": null,
@@ -61,6 +61,9 @@ const ENTRIES = {
@@ -61,6 +61,9 @@ const ENTRIES = {
'blog.mjs': '../src/blog.js',
'blog.mjs': '../src/blog.js',
'reviews.mjs': '../src/reviews.js',
'reviews.mjs': '../src/reviews.js',
'wiki.mjs': '../src/wiki.js',
'wiki.mjs': '../src/wiki.js',
+ 'coupons.mjs': '../src/coupons.js',
+ 'deals.mjs': '../src/deals.js',
+ 'trade.mjs': '../src/trade.js',
'food.mjs': '../src/food.js',
'food.mjs': '../src/food.js',
'actor.mjs': '../src/actor.js',
'actor.mjs': '../src/actor.js',
'run.mjs': '../src/run.js',
'run.mjs': '../src/run.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.57.0';
+const SDK_VERSION = '0.58.0';
module.exports = {
module.exports = {
createClient,
createClient,
new file mode 100644
new file mode 100644
@@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
+'use strict';
+/**
+ * openvibe-sdk/coupons — OpenVibe.Coupons for apps (a browser extension, a shopping bot): which store a site is, its
+ * active codes with their evidence, and, for the person who authorized the app, submitting a code and reporting
+ * whether one worked. Routes at https://openvibe.coupons/api/v1; tokens for audience openvibe.coupons. An app acts
+ * only for its on_behalf_of person.
+ *
+ * const coupons = createCouponsClient(createClient({ tokenProvider }));
+ * const { merchant } = await coupons.merchants.resolve('www.example-store.com'); // public data
+ * const { coupons: codes } = await coupons.merchants.coupons(merchant.id);
+ * await coupons.report(codes[0].id, { outcome: 'failed', reason: 'expired' }); // one report a day per code
+ * await coupons.submit({ host: 'example-store.com', code: 'SAVE10', title: '10% off', evidence_url: 'https://…' });
+ *
+ * Capabilities (public since openvibe-contracts 0.208.0): coupons.merchant.resolve, coupons.coupon.lookup,
+ * coupons.coupon.submit (sensitive: a code under the person's name; it starts as status unknown, and a status,
+ * confidence or "verified" field is refused) and coupons.report.create. Submitting is never retried on its own;
+ * a report is (only the person's latest one counts).
+ */
+const enc = encodeURIComponent;
+const COUPON_ID_RE = /^cpn_[0-9A-HJKMNP-TV-Z]{26}$/; // Coupons' own rule
+const OUTCOMES = ['worked', 'failed'];
+const REASONS = ['invalid', 'expired', 'min_spend_not_met', 'not_eligible', 'other'];
+
+function createCouponsClient(client, { baseUrl } = {}) {
+ if (!client || typeof client.json !== 'function') throw new TypeError('createCouponsClient: pass an openvibe-sdk/core client');
+ const at = { service: 'coupons', baseUrl, audience: 'openvibe.coupons' };
+ const call = (opts) => client.json({ ...at, ...opts });
+ const coupon = (id) => {
+ if (!COUPON_ID_RE.test(String(id || ''))) throw new TypeError('coupons: a coupon is a cpn_ id');
+ return `/api/v1/coupons/${enc(String(id))}`;
+ };
+ const merchant = (id) => {
+ if (!id || typeof id !== 'string') throw new TypeError("coupons: a merchant's id");
+ return `/api/v1/merchants/${enc(id)}`;
+ };
+
+ return {
+ merchants: {
+ /** The store a hostname belongs to (subdomain rules; never a path rule). */
+ resolve: (host, { signal } = {}) => {
+ if (!host || typeof host !== 'string') throw new TypeError('coupons.merchants.resolve: a hostname');
+ return call({ path: '/api/v1/merchants/resolve', query: { host }, signal });
+ },
+ get: (id, { signal } = {}) => call({ path: merchant(id), signal }),
+ /** Its active codes: status, confidence, report aggregates, restrictions, expiry (or unknown), evidence. */
+ coupons: (id, { signal } = {}) => call({ path: `${merchant(id)}/coupons`, signal }),
+ },
+ get: (id, { signal } = {}) => call({ path: coupon(id), signal }),
+ /** A code for a store (by merchant_id, host or url): code and title required, evidence_url recommended. */
+ submit: (fields, { signal } = {}) => {
+ if (!fields || !fields.code || !fields.title) throw new TypeError('coupons.submit: code and title');
+ if (!fields.merchant_id && !fields.host && !fields.url) throw new TypeError('coupons.submit: merchant_id, host or url');
+ return call({ method: 'POST', path: '/api/v1/coupons/submit', json: fields, idempotencyKey: false, signal });
+ },
+ /** Did it work? { outcome: worked | failed, reason? } → the code's aggregates (never who reported). */
+ report: (id, { outcome, reason } = {}, { signal } = {}) => {
+ if (!OUTCOMES.includes(outcome)) throw new TypeError("coupons.report: outcome is 'worked' or 'failed'");
+ if (reason != null && !REASONS.includes(reason)) throw new TypeError(`coupons.report: reason is one of ${REASONS.join(', ')}`);
+ return call({ method: 'POST', path: `${coupon(id)}/report`, json: { outcome, reason }, idempotent: true, signal });
+ },
+ };
+}
+
+module.exports = { createCouponsClient };
new file mode 100644
new file mode 100644
@@ -0,0 +1,85 @@
@@ -0,0 +1,85 @@
+'use strict';
+/**
+ * openvibe-sdk/deals — OpenVibe.Deals for apps: the hot and new offers, an offer with its hotness, products and stores
+ * (public), and, for the person who authorized the app, posting deals, recording what a price is now, voting,
+ * flagging and keeping watches. Routes at https://openvibe.deals/api/v1; tokens for audience openvibe.deals. An app
+ * acts only for its on_behalf_of person.
+ *
+ * const deals = createDealsClient(createClient({ tokenProvider }));
+ * const { offers } = await deals.offers.list({ sort: 'hot' }); // public
+ * const { offer } = await deals.offers.submit({ url: 'https://…', title: 'GPU at $299', price: 299, currency: 'USD' });
+ * await deals.offers.observe(offer.id, { price: 279, currency: 'USD', availability: 'in_stock' });
+ * await deals.offers.vote(offers[0].id, 1);
+ * await deals.watches.create({ kind: 'price_below', product: 'rtx-4070', max_price: 450, currency: 'USD' });
+ *
+ * Capabilities (public since openvibe-contracts 0.208.0): deals.offer.submit (sensitive), deals.offer.update (the
+ * person's own offers, and price observations of any active offer), deals.vote.set (sensitive) and .remove,
+ * deals.flag.create, deals.watch.create, .read and .delete. Votes and hotness are Deals' own (never from the request);
+ * no votes on one's own offer. Submitting, observing, flagging and creating a watch make a new row each time and are
+ * never retried on their own; a link already posted answers 409 offer.duplicate with the existing offer.
+ */
+const enc = encodeURIComponent;
+const SORTS = ['hot', 'new'];
+const FLAGS = ['expired', 'price_wrong', 'spam', 'duplicate', 'other'];
+const WATCHES = ['keyword', 'product', 'price_below', 'search'];
+
+function createDealsClient(client, { baseUrl } = {}) {
+ if (!client || typeof client.json !== 'function') throw new TypeError('createDealsClient: pass an openvibe-sdk/core client');
+ const at = { service: 'deals', baseUrl, audience: 'openvibe.deals' };
+ const call = (opts) => client.json({ ...at, ...opts });
+ const once = (opts) => call({ ...opts, idempotencyKey: false });
+ const offer = (id, rest = '') => {
+ if (!id || typeof id !== 'string') throw new TypeError("deals: an offer's id or slug");
+ return `/api/v1/offers/${enc(id)}${rest}`;
+ };
+
+ return {
+ offers: {
+ /** Hot (Deals' hot@1 ranking) or new offers, a page at a time (public). */
+ list: ({ sort, page, signal } = {}) => {
+ if (sort != null && !SORTS.includes(sort)) throw new TypeError("deals.offers.list: sort is 'hot' or 'new'");
+ return call({ path: '/api/v1/offers', query: { sort, page }, signal });
+ },
+ /** By id or slug; a merged offer answers with its canonical one (public). */
+ get: (id, { signal } = {}) => call({ path: offer(id), signal }),
+ hotness: (id, { signal } = {}) => call({ path: offer(id, '/hotness'), signal }),
+ /** Post a deal: url and title, and what the person sees now (price, currency, shipping, condition, availability). */
+ submit: (fields, { signal } = {}) => {
+ if (!fields || !fields.url || !fields.title) throw new TypeError('deals.offers.submit: url and title');
+ return once({ method: 'POST', path: '/api/v1/offers', json: fields, signal });
+ },
+ /** Edit the person's own offer: title, description, category, expires_at, product. */
+ update: (id, patch, { signal } = {}) => call({ method: 'PATCH', path: offer(id), json: patch, idempotent: true, signal }),
+ /** What the price is now (a new observation; prices are never edited in place). */
+ observe: (id, observation, { signal } = {}) => once({ method: 'POST', path: offer(id, '/observations'), json: observation, signal }),
+ /** +1 or -1 for the person (never on their own offer). */
+ vote: (id, value, { signal } = {}) => {
+ if (value !== 1 && value !== -1) throw new TypeError('deals.offers.vote: 1 or -1');
+ return call({ method: 'PUT', path: offer(id, '/vote'), json: { value }, signal });
+ },
+ unvote: (id, { signal } = {}) => call({ method: 'DELETE', path: offer(id, '/vote'), signal }),
+ /** Report a problem: { kind, reason?, duplicate_of? }; one open report per person and offer. */
+ flag: (id, { kind, reason, duplicate_of: duplicateOf } = {}, { signal } = {}) => {
+ if (!FLAGS.includes(kind)) throw new TypeError(`deals.offers.flag: kind is one of ${FLAGS.join(', ')}`);
+ return once({ method: 'POST', path: offer(id, '/flags'), json: { kind, reason, duplicate_of: duplicateOf }, signal });
+ },
+ },
+ products: {
+ get: (slug, { signal } = {}) => call({ path: `/api/v1/products/${enc(String(slug))}`, signal }),
+ },
+ stores: {
+ get: (domain, { signal } = {}) => call({ path: `/api/v1/stores/${enc(String(domain))}`, signal }),
+ },
+ watches: {
+ list: ({ signal } = {}) => call({ path: '/api/v1/watches', signal }),
+ /** A keyword, product or price-below watch, or a saved search (never notifies). */
+ create: (fields, { signal } = {}) => {
+ if (!fields || !WATCHES.includes(fields.kind)) throw new TypeError(`deals.watches.create: kind is one of ${WATCHES.join(', ')}`);
+ return once({ method: 'POST', path: '/api/v1/watches', json: fields, signal });
+ },
+ remove: (id, { signal } = {}) => call({ method: 'DELETE', path: `/api/v1/watches/${enc(String(id))}`, signal }),
+ },
+ };
+}
+
+module.exports = { createDealsClient };
new file mode 100644
new file mode 100644
@@ -0,0 +1,73 @@
@@ -0,0 +1,73 @@
+'use strict';
+/**
+ * openvibe-sdk/trade — OpenVibe.Trade for apps: instruments with their sourced observations and filings, the sources'
+ * freshness (public), and, for the person who authorized the app, their watchlists and alert rules. Routes at
+ * https://openvibe.trade/api/v1; tokens for audience openvibe.trade. An app acts only for its on_behalf_of person.
+ * Trade states what sources said, with times; it gives no advice.
+ *
+ * const trade = createTradeClient(createClient({ tokenProvider }));
+ * const { instrument } = await trade.instruments.resolve('AAPL'); // CIK, ticker, exact name
+ * const obs = await trade.instruments.observations('AAPL', { metric: 'price', limit: 30 });
+ * const { watchlist } = await trade.watchlists.create({ name: 'Robots' });
+ * await trade.watchlists.add(watchlist.id, 'AAPL');
+ * await trade.alerts.create({ symbol: 'AAPL', kind: 'filing_type', form_types: ['8-K'] });
+ *
+ * Capabilities (public since openvibe-contracts 0.208.0): trade.instrument.resolve, trade.watchlist.create, .read,
+ * .update and .delete, trade.alert.create, .read and .delete. A person's watchlists and alerts are theirs alone
+ * (another person's is 404). Creating a watchlist or an alert is never retried on its own. Alerts are delivered as
+ * trade.alert.triggered events, never by email.
+ */
+const enc = encodeURIComponent;
+const ALERT_KINDS = ['threshold', 'filing_type', 'new_document'];
+
+function createTradeClient(client, { baseUrl } = {}) {
+ if (!client || typeof client.json !== 'function') throw new TypeError('createTradeClient: pass an openvibe-sdk/core client');
+ const at = { service: 'trade', baseUrl, audience: 'openvibe.trade' };
+ const call = (opts) => client.json({ ...at, ...opts });
+ const sym = (s) => {
+ if (!s || typeof s !== 'string') throw new TypeError("trade: an instrument's symbol");
+ return enc(s);
+ };
+ const list = (id, rest = '') => {
+ if (!id || typeof id !== 'string') throw new TypeError("trade: a watchlist's id");
+ return `/api/v1/watchlists/${enc(id)}${rest}`;
+ };
+
+ return {
+ instruments: {
+ /** A ticker, SEC CIK or exact company name → the instrument (several name matches are "ambiguous"). */
+ resolve: (q, { kind, signal } = {}) => call({ path: '/api/v1/instruments/resolve', query: { q, kind }, signal }),
+ list: ({ limit, offset, signal } = {}) => call({ path: '/api/v1/instruments', query: { limit, offset }, signal }),
+ get: (symbol, { signal } = {}) => call({ path: `/api/v1/instruments/${sym(symbol)}`, signal }),
+ /** History with freshness, for one metric or all. */
+ observations: (symbol, { metric, before, limit, signal } = {}) => call({ path: `/api/v1/instruments/${sym(symbol)}/observations`, query: { metric, before, limit }, signal }),
+ documents: (symbol, { limit, offset, signal } = {}) => call({ path: `/api/v1/instruments/${sym(symbol)}/documents`, query: { limit, offset }, signal }),
+ },
+ /** Every source and how fresh it is. */
+ sources: ({ signal } = {}) => call({ path: '/api/v1/sources', signal }),
+ watchlists: {
+ list: ({ signal } = {}) => call({ path: '/api/v1/watchlists', signal }),
+ get: (id, { signal } = {}) => call({ path: list(id), signal }),
+ create: ({ name } = {}, { signal } = {}) => {
+ if (!name || typeof name !== 'string') throw new TypeError('trade.watchlists.create: a name');
+ return call({ method: 'POST', path: '/api/v1/watchlists', json: { name }, idempotencyKey: false, signal });
+ },
+ rename: (id, name, { signal } = {}) => call({ method: 'PATCH', path: list(id), json: { name }, idempotent: true, signal }),
+ add: (id, symbol, { signal } = {}) => call({ method: 'PUT', path: list(id, `/items/${sym(symbol)}`), signal }),
+ removeItem: (id, symbol, { signal } = {}) => call({ method: 'DELETE', path: list(id, `/items/${sym(symbol)}`), signal }),
+ remove: (id, { signal } = {}) => call({ method: 'DELETE', path: list(id), signal }),
+ },
+ alerts: {
+ list: ({ signal } = {}) => call({ path: '/api/v1/alerts', signal }),
+ deliveries: ({ limit, signal } = {}) => call({ path: '/api/v1/alerts/deliveries', query: { limit }, signal }),
+ /** threshold (metric, operator, threshold, unit), filing_type (form_types) or new_document, for a symbol. */
+ create: (rule, { signal } = {}) => {
+ if (!rule || !rule.symbol || !ALERT_KINDS.includes(rule.kind)) throw new TypeError(`trade.alerts.create: a symbol and kind (${ALERT_KINDS.join(', ')})`);
+ return call({ method: 'POST', path: '/api/v1/alerts', json: rule, idempotencyKey: false, signal });
+ },
+ remove: (id, { signal } = {}) => call({ method: 'DELETE', path: `/api/v1/alerts/${enc(String(id))}`, signal }),
+ },
+ };
+}
+
+module.exports = { createTradeClient };
@@ -76,7 +76,7 @@ run([
@@ -76,7 +76,7 @@ run([
for (const [re, why] of FORBIDDEN) if (re.test(src)) problems.push(`${path.relative(ROOT, file)}: ${why}`);
for (const [re, why] of FORBIDDEN) if (re.test(src)) problems.push(`${path.relative(ROOT, file)}: ${why}`);
}
}
assert.deepEqual(problems, []);
assert.deepEqual(problems, []);
- 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', './reviews', './run', './runtime', './service', './sso', './storage', './telemetry', './testing', './tips', './usage', './valkey', './video', './vip', './wiki', './work', './zone']);
+ assert.deepEqual(blocked.sort(), ['./account-data', './actor', './blog', './cache', './commerce', './cost', './coupons', './db', './deals', './delivery', './download', './events', './food', './govern', './identity', './inventory', './limits', './live', './node', './notifications', './openre', './placement', './play', './pubsub', './quest', './queue', './resources', './reviews', './run', './runtime', './service', './sso', './storage', './telemetry', './testing', './tips', './trade', './usage', './valkey', './video', './vip', './wiki', './work', './zone']);
const rel = [...scanned].map((f) => path.relative(ROOT, f));
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']) {
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`);
assert.ok(rel.includes(must), `${must} is scanned`);
@@ -66,7 +66,7 @@ run([
@@ -66,7 +66,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, 59);
+ assert.equal(subpaths.length, 62);
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 });
@@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
'use strict';
'use strict';
-// openvibe-sdk/food, /actor, /run, /video, /work, /zone, /blog, /reviews and /wiki through a real core client against one local stub: every
+// openvibe-sdk/food, /actor, /run, /video, /work, /zone, /blog, /reviews, /wiki, /coupons, /deals and /trade 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
// 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.
// followers (Actor's task events, Run's job stream), and the id checks done before any call.
const assert = require('assert');
const assert = require('assert');
@@ -14,9 +14,12 @@ const { createZoneClient } = require('../src/zone');
@@ -14,9 +14,12 @@ const { createZoneClient } = require('../src/zone');
const { createBlogClient } = require('../src/blog');
const { createBlogClient } = require('../src/blog');
const { createReviewsClient } = require('../src/reviews');
const { createReviewsClient } = require('../src/reviews');
const { createWikiClient } = require('../src/wiki');
const { createWikiClient } = require('../src/wiki');
+const { createCouponsClient } = require('../src/coupons');
+const { createDealsClient } = require('../src/deals');
+const { createTradeClient } = require('../src/trade');
const ULID = '01JAB2C3D4E5F6G7H8J9K0MNPQ';
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}`, post: `pst_${ULID}`, page: `pg_${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}`, page: `pg_${ULID}`, coupon: `cpn_${ULID}` };
(async () => {
(async () => {
const seen = [];
const seen = [];
@@ -47,7 +50,7 @@ const ids = { plan: `pln_${ULID}`, task: `tsk_${ULID}`, agent: `agt_${ULID}`, me
@@ -47,7 +50,7 @@ const ids = { plan: `pln_${ULID}`, task: `tsk_${ULID}`, agent: `agt_${ULID}`, me
const base = `http://127.0.0.1:${server.address().port}`;
const base = `http://127.0.0.1:${server.address().port}`;
const audiences = [];
const audiences = [];
const client = createClient({
const client = createClient({
- baseUrls: { food: `${base}/food`, actor: `${base}/actor`, run: `${base}/run`, 'media-hub': `${base}/video`, work: `${base}/work`, zone: `${base}/zone`, blog: `${base}/blog`, reviews: `${base}/reviews`, wiki: `${base}/wiki` },
+ baseUrls: { food: `${base}/food`, actor: `${base}/actor`, run: `${base}/run`, 'media-hub': `${base}/video`, work: `${base}/work`, zone: `${base}/zone`, blog: `${base}/blog`, reviews: `${base}/reviews`, wiki: `${base}/wiki`, coupons: `${base}/coupons`, deals: `${base}/deals`, trade: `${base}/trade` },
getToken: ({ audience }) => { audiences.push(audience); return `tok-${audience}`; },
getToken: ({ audience }) => { audiences.push(audience); return `tok-${audience}`; },
retries: 2, retryDelayMs: 1, maxRetryDelayMs: 2,
retries: 2, retryDelayMs: 1, maxRetryDelayMs: 2,
});
});
@@ -290,13 +293,95 @@ const ids = { plan: `pln_${ULID}`, task: `tsk_${ULID}`, agent: `agt_${ULID}`, me
@@ -290,13 +293,95 @@ const ids = { plan: `pln_${ULID}`, task: `tsk_${ULID}`, agent: `agt_${ULID}`, me
assert.throws(() => wiki.pages.get('page_1'), /pg_/);
assert.throws(() => wiki.pages.get('page_1'), /pg_/);
assert.throws(() => wiki.pages.diff(ids.page, { from: 0, to: 2 }), /revision number/);
assert.throws(() => wiki.pages.diff(ids.page, { from: 0, to: 2 }), /revision number/);
+ // ── Coupons ───────────────────────────────────────────
+ const coupons = createCouponsClient(client);
+ mark = since();
+ await coupons.merchants.resolve('www.example-store.com');
+ await coupons.merchants.get('mer_1');
+ await coupons.merchants.coupons('mer_1');
+ await coupons.get(ids.coupon);
+ await busyOnce(() => coupons.submit({ host: 'example-store.com', code: 'SAVE10', title: '10% off' }));
+ await coupons.report(ids.coupon, { outcome: 'failed', reason: 'expired' }); // only the latest counts: retried
+ const C = `/api/v1/coupons/${ids.coupon}`;
+ const cp = mark();
+ assert.deepStrictEqual(cp.map((x) => `${x.method} ${x.url}`), [
+ 'GET /api/v1/merchants/resolve?host=www.example-store.com', 'GET /api/v1/merchants/mer_1', 'GET /api/v1/merchants/mer_1/coupons', `GET ${C}`,
+ 'POST /api/v1/coupons/submit', `POST ${C}/report`, `POST ${C}/report`,
+ ]);
+ assert.deepStrictEqual(cp[5].body, { outcome: 'failed', reason: 'expired' });
+ assert.throws(() => coupons.submit({ code: 'X', title: 'Y' }), /merchant_id, host or url/);
+ assert.throws(() => coupons.report(ids.coupon, { outcome: 'maybe' }), /worked/);
+ assert.throws(() => coupons.get('coupon_1'), /cpn_/);
+
+ // ── Deals ─────────────────────────────────────────────
+ const deals = createDealsClient(client);
+ mark = since();
+ await deals.offers.list({ sort: 'hot', page: 2 });
+ await deals.offers.get('gpu-299');
+ await deals.offers.hotness('gpu-299');
+ await busyOnce(() => deals.offers.submit({ url: 'https://shop.example/gpu', title: 'GPU at $299', price: 299, currency: 'USD' }));
+ await deals.offers.update('off_1', { title: 'GPU at $279' });
+ await busyOnce(() => deals.offers.observe('off_1', { price: 279, currency: 'USD' }));
+ await deals.offers.vote('off_2', -1); // PUT: retried
+ await deals.offers.unvote('off_2');
+ await busyOnce(() => deals.offers.flag('off_2', { kind: 'expired' }));
+ await deals.products.get('rtx-4070');
+ await deals.stores.get('shop.example');
+ await deals.watches.list();
+ await busyOnce(() => deals.watches.create({ kind: 'price_below', product: 'rtx-4070', max_price: 450, currency: 'USD' }));
+ await deals.watches.remove('wat_1');
+ const dl = mark();
+ assert.deepStrictEqual(dl.map((x) => `${x.method} ${x.url}`), [
+ 'GET /api/v1/offers?sort=hot&page=2', 'GET /api/v1/offers/gpu-299', 'GET /api/v1/offers/gpu-299/hotness', 'POST /api/v1/offers',
+ 'PATCH /api/v1/offers/off_1', 'PATCH /api/v1/offers/off_1', 'POST /api/v1/offers/off_1/observations', 'PUT /api/v1/offers/off_2/vote',
+ 'PUT /api/v1/offers/off_2/vote', 'DELETE /api/v1/offers/off_2/vote', 'DELETE /api/v1/offers/off_2/vote', 'POST /api/v1/offers/off_2/flags',
+ 'GET /api/v1/products/rtx-4070', 'GET /api/v1/stores/shop.example', 'GET /api/v1/watches', 'POST /api/v1/watches',
+ 'DELETE /api/v1/watches/wat_1', 'DELETE /api/v1/watches/wat_1',
+ ]);
+ assert.deepStrictEqual(dl[7].body, { value: -1 });
+ assert.throws(() => deals.offers.vote('off_2', 2), /1 or -1/);
+ assert.throws(() => deals.offers.flag('off_2', { kind: 'meh' }), /kind is one of/);
+ assert.throws(() => deals.offers.list({ sort: 'top' }), /hot/);
+
+ // ── Trade ─────────────────────────────────────────────
+ const trade = createTradeClient(client);
+ mark = since();
+ await trade.instruments.resolve('AAPL');
+ await trade.instruments.list({ limit: 5 });
+ await trade.instruments.get('AAPL');
+ await trade.instruments.observations('AAPL', { metric: 'price', limit: 30 });
+ await trade.instruments.documents('AAPL', { limit: 3 });
+ await trade.sources();
+ await trade.watchlists.list();
+ await busyOnce(() => trade.watchlists.create({ name: 'Robots' }));
+ await trade.watchlists.get('wl_1');
+ await trade.watchlists.rename('wl_1', 'Robot makers');
+ await trade.watchlists.add('wl_1', 'AAPL');
+ await trade.watchlists.removeItem('wl_1', 'AAPL');
+ await trade.watchlists.remove('wl_1');
+ await trade.alerts.list();
+ await trade.alerts.deliveries({ limit: 10 });
+ await busyOnce(() => trade.alerts.create({ symbol: 'AAPL', kind: 'filing_type', form_types: ['8-K'] }));
+ await trade.alerts.remove('alr_1');
+ const tr = mark();
+ assert.deepStrictEqual(tr.map((x) => `${x.method} ${x.url}`), [
+ 'GET /api/v1/instruments/resolve?q=AAPL', 'GET /api/v1/instruments?limit=5', 'GET /api/v1/instruments/AAPL',
+ 'GET /api/v1/instruments/AAPL/observations?metric=price&limit=30', 'GET /api/v1/instruments/AAPL/documents?limit=3', 'GET /api/v1/sources',
+ 'GET /api/v1/watchlists', 'POST /api/v1/watchlists', 'GET /api/v1/watchlists/wl_1', 'PATCH /api/v1/watchlists/wl_1', 'PATCH /api/v1/watchlists/wl_1',
+ 'PUT /api/v1/watchlists/wl_1/items/AAPL', 'PUT /api/v1/watchlists/wl_1/items/AAPL', 'DELETE /api/v1/watchlists/wl_1/items/AAPL',
+ 'DELETE /api/v1/watchlists/wl_1/items/AAPL', 'DELETE /api/v1/watchlists/wl_1', 'DELETE /api/v1/watchlists/wl_1', 'GET /api/v1/alerts',
+ 'GET /api/v1/alerts/deliveries?limit=10', 'POST /api/v1/alerts', 'DELETE /api/v1/alerts/alr_1', 'DELETE /api/v1/alerts/alr_1',
+ ]);
+ assert.throws(() => trade.alerts.create({ symbol: 'AAPL', kind: 'rumour' }), /kind/);
+ assert.throws(() => trade.watchlists.create({}), /name/);
+
// Each product's token is for its own audience (Video's is the media hub's, openvibe.download).
// 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.blog', 'openvibe.download', 'openvibe.food', 'openvibe.reviews', 'openvibe.run', 'openvibe.wiki', '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', reviews: 'openvibe.reviews', wiki: 'openvibe.wiki' }[x.svc]}`));
+ assert.deepStrictEqual([...new Set(audiences)].sort(), ['openvibe.actor', 'openvibe.blog', 'openvibe.coupons', 'openvibe.deals', 'openvibe.download', 'openvibe.food', 'openvibe.reviews', 'openvibe.run', 'openvibe.trade', 'openvibe.wiki', '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', reviews: 'openvibe.reviews', wiki: 'openvibe.wiki', coupons: 'openvibe.coupons', deals: 'openvibe.deals', trade: 'openvibe.trade' }[x.svc]}`));
// Each client needs a core client.
// Each client needs a core client.
- for (const make of [createFoodClient, createActorClient, createRunClient, createVideoClient, createWorkClient, createZoneClient, createBlogClient, createReviewsClient, createWikiClient]) assert.throws(() => make({}), /core client/);
- console.log('product modules (food, actor, run, video, work, zone, blog, reviews, wiki): all checks passed');
+ for (const make of [createFoodClient, createActorClient, createRunClient, createVideoClient, createWorkClient, createZoneClient, createBlogClient, createReviewsClient, createWikiClient, createCouponsClient, createDealsClient, createTradeClient]) assert.throws(() => make({}), /core client/);
+ console.log('product modules (food, actor, run, video, work, zone, blog, reviews, wiki, coupons, deals, trade): all checks passed');
} finally {
} finally {
server.close();
server.close();
}
}
new file mode 100644
new file mode 100644
@@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
+/** openvibe-sdk/coupons: OpenVibe.Coupons — stores, their codes, and submitting and reporting codes for the person. */
+type Opts = { signal?: AbortSignal };
+type CouponsJson = Record<string, any>;
+export type ReportOutcome = 'worked' | 'failed';
+export type ReportReason = 'invalid' | 'expired' | 'min_spend_not_met' | 'not_eligible' | 'other';
+export interface CouponSubmission {
+ code: string; title: string; merchant_id?: string; host?: string; url?: string; description?: string | null; expires?: string | null;
+ expiry_basis?: 'submitter' | 'evidence'; evidence_url?: string; restrictions?: Record<string, unknown>; hint?: string | null; [k: string]: unknown;
+}
+export interface CouponsClient {
+ merchants: {
+ resolve(host: string, opts?: Opts): Promise<CouponsJson>;
+ get(id: string, opts?: Opts): Promise<CouponsJson>;
+ coupons(id: string, opts?: Opts): Promise<CouponsJson>;
+ };
+ get(id: string, opts?: Opts): Promise<CouponsJson>;
+ submit(fields: CouponSubmission, opts?: Opts): Promise<CouponsJson>;
+ report(id: string, req: { outcome: ReportOutcome; reason?: ReportReason | null }, opts?: Opts): Promise<CouponsJson>;
+}
+export function createCouponsClient(client: { json(opts: Record<string, unknown>): Promise<any> }, options?: { baseUrl?: string }): CouponsClient;
new file mode 100644
new file mode 100644
@@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
+/** openvibe-sdk/deals: OpenVibe.Deals — offers, products and stores, and posting, voting, flagging and watches for the person. */
+type Opts = { signal?: AbortSignal };
+type DealsJson = Record<string, any>;
+export type FlagKind = 'expired' | 'price_wrong' | 'spam' | 'duplicate' | 'other';
+export type WatchKind = 'keyword' | 'product' | 'price_below' | 'search';
+export interface Observation { price?: string | number | null; currency?: string | null; shipping?: string | number | null; shipping_note?: string | null; condition?: string | null; availability?: string | null; [k: string]: unknown }
+export interface DealsClient {
+ offers: {
+ list(opts?: Opts & { sort?: 'hot' | 'new'; page?: number }): Promise<DealsJson>;
+ get(id: string, opts?: Opts): Promise<DealsJson>;
+ hotness(id: string, opts?: Opts): Promise<DealsJson>;
+ submit(fields: Observation & { url: string; title: string; description?: string | null; category?: string | null; expires_at?: string | null; store_name?: string | null; product_slug?: string | null }, opts?: Opts): Promise<DealsJson>;
+ update(id: string, patch: { title?: string; description?: string | null; category?: string | null; expires_at?: string | null; product?: unknown }, opts?: Opts): Promise<DealsJson>;
+ observe(id: string, observation: Observation, opts?: Opts): Promise<DealsJson>;
+ vote(id: string, value: 1 | -1, opts?: Opts): Promise<DealsJson>;
+ unvote(id: string, opts?: Opts): Promise<DealsJson>;
+ flag(id: string, req: { kind: FlagKind; reason?: string | null; duplicate_of?: string | null }, opts?: Opts): Promise<DealsJson>;
+ };
+ products: { get(slug: string, opts?: Opts): Promise<DealsJson> };
+ stores: { get(domain: string, opts?: Opts): Promise<DealsJson> };
+ watches: {
+ list(opts?: Opts): Promise<DealsJson>;
+ create(fields: { kind: WatchKind; query?: string | null; product?: string | null; max_price?: string | number | null; currency?: string | null; label?: string | null }, opts?: Opts): Promise<DealsJson>;
+ remove(id: string, opts?: Opts): Promise<DealsJson>;
+ };
+}
+export function createDealsClient(client: { json(opts: Record<string, unknown>): Promise<any> }, options?: { baseUrl?: string }): DealsClient;
@@ -23,6 +23,9 @@ export * as tips from './tips';
@@ -23,6 +23,9 @@ export * as tips from './tips';
export * as blog from './blog';
export * as blog from './blog';
export * as reviews from './reviews';
export * as reviews from './reviews';
export * as wiki from './wiki';
export * as wiki from './wiki';
+export * as coupons from './coupons';
+export * as deals from './deals';
+export * as trade from './trade';
export * as food from './food';
export * as food from './food';
export * as actor from './actor';
export * as actor from './actor';
export * as run from './run';
export * as run from './run';
new file mode 100644
new file mode 100644
@@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
+/** openvibe-sdk/trade: OpenVibe.Trade — instruments, observations, filings and sources, and the person's watchlists and alerts. */
+type Opts = { signal?: AbortSignal };
+type TradeJson = Record<string, any>;
+export type AlertKind = 'threshold' | 'filing_type' | 'new_document';
+export interface AlertRule {
+ symbol: string; kind: AlertKind; metric?: string; operator?: 'above' | 'below'; threshold?: string | number; unit?: string;
+ currency?: string | null; form_types?: string[] | string;
+}
+export interface TradeClient {
+ instruments: {
+ resolve(q: string, opts?: Opts & { kind?: string }): Promise<TradeJson>;
+ list(opts?: Opts & { limit?: number; offset?: number }): Promise<TradeJson>;
+ get(symbol: string, opts?: Opts): Promise<TradeJson>;
+ observations(symbol: string, opts?: Opts & { metric?: string; before?: string; limit?: number }): Promise<TradeJson>;
+ documents(symbol: string, opts?: Opts & { limit?: number; offset?: number }): Promise<TradeJson>;
+ };
+ sources(opts?: Opts): Promise<TradeJson>;
+ watchlists: {
+ list(opts?: Opts): Promise<TradeJson>;
+ get(id: string, opts?: Opts): Promise<TradeJson>;
+ create(req: { name: string }, opts?: Opts): Promise<TradeJson>;
+ rename(id: string, name: string, opts?: Opts): Promise<TradeJson>;
+ add(id: string, symbol: string, opts?: Opts): Promise<TradeJson>;
+ removeItem(id: string, symbol: string, opts?: Opts): Promise<TradeJson>;
+ remove(id: string, opts?: Opts): Promise<TradeJson>;
+ };
+ alerts: {
+ list(opts?: Opts): Promise<TradeJson>;
+ deliveries(opts?: Opts & { limit?: number }): Promise<TradeJson>;
+ create(rule: AlertRule, opts?: Opts): Promise<TradeJson>;
+ remove(id: string, opts?: Opts): Promise<TradeJson>;
+ };
+}
+export function createTradeClient(client: { json(opts: Record<string, unknown>): Promise<any> }, options?: { baseUrl?: string }): TradeClient;