openvibers/openvibe.sdk Commits
Add ov.community.feed and ov.community.posts.create (0.113.0) (#162)
Changes
@@@ -1,5 +1,11 @@# Changelog++## 0.113.0 — 2026-11-09++++- Add the Feed and status posts to `openvibe-sdk/community`: `feed({ kind, site, q, following, cursor, limit })` reads++ Community's `GET /api/v1/feed` (one stream over Pulse from every OpenVibe site) and `posts.create({ text, pictures })`++ posts up to four Media pictures with required alt text, in the Feed at once.++## 0.112.0 — 2026-11-09- Add the person's stats to `openvibe-sdk/report`: `report.me({ days })` (GET `/api/v1/me/stats`, the signed-in person's own numbers), `report.person(username)` (GET `/api/v1/u/:name/stats`, only the sections they published) and `report.publish({ sites, activity, made, ai, money }, { days })` (PUT `/api/v1/me/stats/published`, all five switches named). The answers are `report.me-stats@1`; a source that does not answer leaves its section out, never a zero. `me` and `publish` need the person's own session token; `person` is public and is a 404 when nothing is published.@@@ -2,7 +2,7 @@> Supported browser and server clients for the OpenVibe platform.--**Status:** alpha, v0.112.0 (the five 1.0 core entries — `core`, `auth`, `events`, `db` and `media` — are frozen: their exported names change only with a major release; roadmap Wave 2; developer apps from Wave 20; Media objects v2 from Wave 4; the Tools platform API; Search, Chat, AI, Vision and consent clients; sign-in with recovery and a client health check). Every release is tagged (see [CHANGELOG.md](CHANGELOG.md)). Tested against local stub servers and the built-in mock platform only, never against the live platform. Services pin release tags; each repository's `STATUS.json` names the one it uses.++**Status:** alpha, v0.113.0 (the five 1.0 core entries — `core`, `auth`, `events`, `db` and `media` — are frozen: their exported names change only with a major release; roadmap Wave 2; developer apps from Wave 20; Media objects v2 from Wave 4; the Tools platform API; Search, Chat, AI, Vision and consent clients; sign-in with recovery and a client health check). Every release is tagged (see [CHANGELOG.md](CHANGELOG.md)). Tested against local stub servers and the built-in mock platform only, never against the live platform. Services pin release tags; each repository's `STATUS.json` names the one it uses.**Plan:** OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), §3.2; roadmap §30.**License:** MIT ([LICENSE](LICENSE)). This package is a library that apps outside the network embed, so it uses MIT. The OpenVibe services themselves stay AGPL-3.0.@@@ -11,7 +11,7 @@After v0.97.1 is tagged:```bash--npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.112.0++npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.113.0```It has no runtime dependencies. It needs Node ≥ 20, or any browser with `fetch`, Web Crypto and `TextDecoder`. There is no build step. The package is CommonJS with ESM entry points (`import` works). Each subpath has its own `.d.ts`. For a page with no bundler, `browser/openvibe-sdk.mjs` is one self-contained ES module of the browser-safe subpaths (see [Browser without a bundler](#browser-without-a-bundler)). It does not depend on `openvibe-contracts` at runtime: it copies the contract types it uses (from the temporary Contracts sharing branch, a devDependency the tests check them against).@@@ -3,7 +3,7 @@"stage": "alpha","code": true,"wave": "W2",-- "version": "0.112.0",++ "version": "0.113.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.112.0, MIT). Do not edit.++// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.113.0, MIT). Do not edit.// One self-contained ES module: core at the top level plus the browser-safe subpaths as namespaces// (auth, locker, registry, trust, modules, realtime, media, cam, community, homeFeed, bot, search, bench, meme, vision, themes, redact, chat, ai, credentials, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity./* eslint-disable */@@@ -52,7 +52,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.112.0';++const SDK_VERSION = '0.113.0';module.exports = {createClient,@@@ -3332,8 +3332,9 @@ function (module, exports) {* staff: true -> X-OV-Staff: 1 (the acting person is staff; needs .moderate)* Community ignores X-OV-* headers from browsers.*-- * TODO: comments on other content, the forum and Pulse APIs are being added to Community now and-- * are not wrapped yet; paste comments are.++ * The Feed and status posts are here too: feed() reads GET /api/v1/feed (one stream from Pulse across every++ * OpenVibe site) and posts.create() posts text with up to four pictures. Comments on other content, the rest of++ * the forum and Pulse's service API are not wrapped yet; paste comments are.*/const { isOpenVibeError } = __load(3);const { isActingSubjectId } = __load(5);@@@ -3421,8 +3422,23 @@ function createCommunityClient(client, defaults = {}) {},};++ const feed = (query = {}, o = {}) => call({++ path: '/api/v1/feed',++ query: { kind: query.kind, site: query.site, q: query.q, cursor: query.cursor, limit: query.limit,++ following: query.following === true || query.following === 1 ? '1' : undefined },++ }, o);++ const posts = {++ /**++ * A status post in the Feed at once: { text, pictures?: [{ media_id, alt }] } (at most four, alt required,++ * each media_id a Media object the person owns). -> { id, post_id, text, url, pictures, created_at }++ */++ create: (input = {}, o = {}) => call({ method: 'POST', path: '/api/v1/posts', json: input, ...once }, o),++ };++return {pastes,++ feed,++ posts,/** The same client acting for someone else: as('usr_…') or as({ actingSubject, origin, sourceRef, staff }). */as(who) {const next = typeof who === 'string' ? { actingSubject: who } : { ...who };@@@ -1,12 +1,12 @@{"name": "openvibe-sdk",-- "version": "0.112.0",++ "version": "0.113.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "openvibe-sdk",-- "version": "0.112.0",++ "version": "0.113.0","license": "MIT","bin": {"openvibe-download": "bin/openvibe-download.js"@@@ -1,6 +1,6 @@{"name": "openvibe-sdk",-- "version": "0.112.0",++ "version": "0.113.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",@@@ -13,8 +13,9 @@* staff: true -> X-OV-Staff: 1 (the acting person is staff; needs .moderate)* Community ignores X-OV-* headers from browsers.*-- * TODO: comments on other content, the forum and Pulse APIs are being added to Community now and-- * are not wrapped yet; paste comments are.++ * The Feed and status posts are here too: feed() reads GET /api/v1/feed (one stream from Pulse across every++ * OpenVibe site) and posts.create() posts text with up to four pictures. Comments on other content, the rest of++ * the forum and Pulse's service API are not wrapped yet; paste comments are.*/const { isOpenVibeError } = require('./core/errors');const { isActingSubjectId } = require('./core/ids');@@@ -102,8 +103,23 @@ function createCommunityClient(client, defaults = {}) {},};++ const feed = (query = {}, o = {}) => call({++ path: '/api/v1/feed',++ query: { kind: query.kind, site: query.site, q: query.q, cursor: query.cursor, limit: query.limit,++ following: query.following === true || query.following === 1 ? '1' : undefined },++ }, o);++ const posts = {++ /**++ * A status post in the Feed at once: { text, pictures?: [{ media_id, alt }] } (at most four, alt required,++ * each media_id a Media object the person owns). -> { id, post_id, text, url, pictures, created_at }++ */++ create: (input = {}, o = {}) => call({ method: 'POST', path: '/api/v1/posts', json: input, ...once }, o),++ };++return {pastes,++ feed,++ posts,/** The same client acting for someone else: as('usr_…') or as({ actingSubject, origin, sourceRef, staff }). */as(who) {const next = typeof who === 'string' ? { actingSubject: who } : { ...who };@@@ -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.112.0';++const SDK_VERSION = '0.113.0';module.exports = {createClient,@@@ -117,4 +117,27 @@ run([assert.deepEqual(slugs, ['s1', 's2', 's3', 's4', 's5']);await srv.close();}],++++ ['the Feed and a status post: query, alt pictures in the body, acting subject, never retried', async () => {++ const srv = await echo();++ const community = createCommunityClient(createClient({ baseUrls: { community: srv.url } }), { actingSubject: USR });++ const body = await community.feed({ kind: 'wiki', site: 'wiki', q: 'cats', following: true, cursor: 'abc', limit: 10 });++ assert.deepEqual(body, { ok: true });++ let r = srv.requests[0];++ assert.equal(r.method, 'GET');++ const url = new URL(r.url, 'http://x');++ assert.equal(url.pathname, '/api/v1/feed');++ assert.deepEqual(Object.fromEntries(url.searchParams), { kind: 'wiki', site: 'wiki', q: 'cats', cursor: 'abc', limit: '10', following: '1' });++ assert.equal(hdr(r, 'X-OV-Subject'), USR);++ const media = 'med_01JAB2C3D4E5F6G7H8J9K0MNPQ';++ await community.posts.create({ text: 'Look', pictures: [{ media_id: media, alt: 'A white cat' }] });++ r = srv.requests[1];++ assert.equal(r.method, 'POST');++ assert.equal(r.url, '/api/v1/posts');++ assert.deepEqual(JSON.parse(r.body), { text: 'Look', pictures: [{ media_id: media, alt: 'A white cat' }] });++ assert.equal(hdr(r, 'idempotency-key'), undefined, 'a post is a write Community does not dedupe');++ await community.posts.create({ text: 'Plain' });++ assert.deepEqual(JSON.parse(srv.requests[2].body), { text: 'Plain' });++ await srv.close();++ }],]);@@@ -33,8 +33,33 @@ export interface PastesApi {delete(slug: string, commentId: string | number, opts?: CallOptions): Promise<unknown>;};}++export type FeedKind = 'live' | 'stream' | 'clip' | 'video' | 'pic' | 'post' | 'meme' | 'game' | 'update' | 'wiki' | 'quest' | 'chat' | 'event' | 'member';++export interface FeedQuery { kind?: FeedKind; site?: string; q?: string; following?: boolean | 1; cursor?: string; limit?: number; }++export interface FeedItem {++ id: string;++ kind: FeedKind;++ url: string;++ title: string;++ text: string;++ at: string | null;++ site: string;++ site_name: string;++ actor: { name: string | null; avatar: string | null } | null;++ media: { thumb: string; ratio: number; length?: number } | null;++ counts: { views?: number; likes?: number; comments?: number };++ label?: 'Trending' | 'AI' | 'System';++}++export interface CreatePostInput {++ text: string;++ pictures?: Array<{ media_id: string; alt: string }>;++}++export interface PostsApi {++ create(input: CreatePostInput, opts?: CallOptions): Promise<{ id: number; post_id: number; text: string; url: string; pictures: Array<{ media_id: string; alt: string | null; url?: string }>; created_at: string }>;++}export interface CommunityClient {pastes: PastesApi;++ feed(query?: FeedQuery, opts?: CallOptions): Promise<{ items: FeedItem[]; next_cursor: string | null }>;++ posts: PostsApi;as(who: string | ActingOptions): CommunityClient;headers(): Record<string, string>;}
@@ -1,5 +1,11 @@
@@ -1,5 +1,11 @@
# Changelog
# Changelog
+## 0.113.0 — 2026-11-09
+
+- Add the Feed and status posts to `openvibe-sdk/community`: `feed({ kind, site, q, following, cursor, limit })` reads
+ Community's `GET /api/v1/feed` (one stream over Pulse from every OpenVibe site) and `posts.create({ text, pictures })`
+ posts up to four Media pictures with required alt text, in the Feed at once.
+
## 0.112.0 — 2026-11-09
## 0.112.0 — 2026-11-09
- Add the person's stats to `openvibe-sdk/report`: `report.me({ days })` (GET `/api/v1/me/stats`, the signed-in person's own numbers), `report.person(username)` (GET `/api/v1/u/:name/stats`, only the sections they published) and `report.publish({ sites, activity, made, ai, money }, { days })` (PUT `/api/v1/me/stats/published`, all five switches named). The answers are `report.me-stats@1`; a source that does not answer leaves its section out, never a zero. `me` and `publish` need the person's own session token; `person` is public and is a 404 when nothing is published.
- Add the person's stats to `openvibe-sdk/report`: `report.me({ days })` (GET `/api/v1/me/stats`, the signed-in person's own numbers), `report.person(username)` (GET `/api/v1/u/:name/stats`, only the sections they published) and `report.publish({ sites, activity, made, ai, money }, { days })` (PUT `/api/v1/me/stats/published`, all five switches named). The answers are `report.me-stats@1`; a source that does not answer leaves its section out, never a zero. `me` and `publish` need the person's own session token; `person` is public and is a 404 when nothing is published.
@@ -2,7 +2,7 @@
@@ -2,7 +2,7 @@
> Supported browser and server clients for the OpenVibe platform.
> Supported browser and server clients for the OpenVibe platform.
-**Status:** alpha, v0.112.0 (the five 1.0 core entries — `core`, `auth`, `events`, `db` and `media` — are frozen: their exported names change only with a major release; roadmap Wave 2; developer apps from Wave 20; Media objects v2 from Wave 4; the Tools platform API; Search, Chat, AI, Vision and consent clients; sign-in with recovery and a client health check). Every release is tagged (see [CHANGELOG.md](CHANGELOG.md)). Tested against local stub servers and the built-in mock platform only, never against the live platform. Services pin release tags; each repository's `STATUS.json` names the one it uses.
+**Status:** alpha, v0.113.0 (the five 1.0 core entries — `core`, `auth`, `events`, `db` and `media` — are frozen: their exported names change only with a major release; roadmap Wave 2; developer apps from Wave 20; Media objects v2 from Wave 4; the Tools platform API; Search, Chat, AI, Vision and consent clients; sign-in with recovery and a client health check). Every release is tagged (see [CHANGELOG.md](CHANGELOG.md)). Tested against local stub servers and the built-in mock platform only, never against the live platform. Services pin release tags; each repository's `STATUS.json` names the one it uses.
**Plan:** OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), §3.2; roadmap §30.
**Plan:** OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), §3.2; roadmap §30.
**License:** MIT ([LICENSE](LICENSE)). This package is a library that apps outside the network embed, so it uses MIT. The OpenVibe services themselves stay AGPL-3.0.
**License:** MIT ([LICENSE](LICENSE)). This package is a library that apps outside the network embed, so it uses MIT. The OpenVibe services themselves stay AGPL-3.0.
@@ -11,7 +11,7 @@
@@ -11,7 +11,7 @@
After v0.97.1 is tagged:
After v0.97.1 is tagged:
```bash
```bash
-npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.112.0
+npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.113.0
```
```
It has no runtime dependencies. It needs Node ≥ 20, or any browser with `fetch`, Web Crypto and `TextDecoder`. There is no build step. The package is CommonJS with ESM entry points (`import` works). Each subpath has its own `.d.ts`. For a page with no bundler, `browser/openvibe-sdk.mjs` is one self-contained ES module of the browser-safe subpaths (see [Browser without a bundler](#browser-without-a-bundler)). It does not depend on `openvibe-contracts` at runtime: it copies the contract types it uses (from the temporary Contracts sharing branch, a devDependency the tests check them against).
It has no runtime dependencies. It needs Node ≥ 20, or any browser with `fetch`, Web Crypto and `TextDecoder`. There is no build step. The package is CommonJS with ESM entry points (`import` works). Each subpath has its own `.d.ts`. For a page with no bundler, `browser/openvibe-sdk.mjs` is one self-contained ES module of the browser-safe subpaths (see [Browser without a bundler](#browser-without-a-bundler)). It does not depend on `openvibe-contracts` at runtime: it copies the contract types it uses (from the temporary Contracts sharing branch, a devDependency the tests check them against).
@@ -3,7 +3,7 @@
@@ -3,7 +3,7 @@
"stage": "alpha",
"stage": "alpha",
"code": true,
"code": true,
"wave": "W2",
"wave": "W2",
- "version": "0.112.0",
+ "version": "0.113.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.112.0, MIT). Do not edit.
+// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.113.0, MIT). Do not edit.
// One self-contained ES module: core at the top level plus the browser-safe subpaths as namespaces
// One self-contained ES module: core at the top level plus the browser-safe subpaths as namespaces
// (auth, locker, registry, trust, modules, realtime, media, cam, community, homeFeed, bot, search, bench, meme, vision, themes, redact, chat, ai, credentials, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity.
// (auth, locker, registry, trust, modules, realtime, media, cam, community, homeFeed, bot, search, bench, meme, vision, themes, redact, chat, ai, credentials, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity.
/* eslint-disable */
/* eslint-disable */
@@ -52,7 +52,7 @@ const { paginate, offsetPager } = __load(7);
@@ -52,7 +52,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.112.0';
+const SDK_VERSION = '0.113.0';
module.exports = {
module.exports = {
createClient,
createClient,
@@ -3332,8 +3332,9 @@ function (module, exports) {
@@ -3332,8 +3332,9 @@ function (module, exports) {
* staff: true -> X-OV-Staff: 1 (the acting person is staff; needs .moderate)
* staff: true -> X-OV-Staff: 1 (the acting person is staff; needs .moderate)
* Community ignores X-OV-* headers from browsers.
* Community ignores X-OV-* headers from browsers.
*
*
- * TODO: comments on other content, the forum and Pulse APIs are being added to Community now and
- * are not wrapped yet; paste comments are.
+ * The Feed and status posts are here too: feed() reads GET /api/v1/feed (one stream from Pulse across every
+ * OpenVibe site) and posts.create() posts text with up to four pictures. Comments on other content, the rest of
+ * the forum and Pulse's service API are not wrapped yet; paste comments are.
*/
*/
const { isOpenVibeError } = __load(3);
const { isOpenVibeError } = __load(3);
const { isActingSubjectId } = __load(5);
const { isActingSubjectId } = __load(5);
@@ -3421,8 +3422,23 @@ function createCommunityClient(client, defaults = {}) {
@@ -3421,8 +3422,23 @@ function createCommunityClient(client, defaults = {}) {
},
},
};
};
+ const feed = (query = {}, o = {}) => call({
+ path: '/api/v1/feed',
+ query: { kind: query.kind, site: query.site, q: query.q, cursor: query.cursor, limit: query.limit,
+ following: query.following === true || query.following === 1 ? '1' : undefined },
+ }, o);
+ const posts = {
+ /**
+ * A status post in the Feed at once: { text, pictures?: [{ media_id, alt }] } (at most four, alt required,
+ * each media_id a Media object the person owns). -> { id, post_id, text, url, pictures, created_at }
+ */
+ create: (input = {}, o = {}) => call({ method: 'POST', path: '/api/v1/posts', json: input, ...once }, o),
+ };
+
return {
return {
pastes,
pastes,
+ feed,
+ posts,
/** The same client acting for someone else: as('usr_…') or as({ actingSubject, origin, sourceRef, staff }). */
/** The same client acting for someone else: as('usr_…') or as({ actingSubject, origin, sourceRef, staff }). */
as(who) {
as(who) {
const next = typeof who === 'string' ? { actingSubject: who } : { ...who };
const next = typeof who === 'string' ? { actingSubject: who } : { ...who };
@@ -1,12 +1,12 @@
@@ -1,12 +1,12 @@
{
{
"name": "openvibe-sdk",
"name": "openvibe-sdk",
- "version": "0.112.0",
+ "version": "0.113.0",
"lockfileVersion": 3,
"lockfileVersion": 3,
"requires": true,
"requires": true,
"packages": {
"packages": {
"": {
"": {
"name": "openvibe-sdk",
"name": "openvibe-sdk",
- "version": "0.112.0",
+ "version": "0.113.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.112.0",
+ "version": "0.113.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",
@@ -13,8 +13,9 @@
@@ -13,8 +13,9 @@
* staff: true -> X-OV-Staff: 1 (the acting person is staff; needs .moderate)
* staff: true -> X-OV-Staff: 1 (the acting person is staff; needs .moderate)
* Community ignores X-OV-* headers from browsers.
* Community ignores X-OV-* headers from browsers.
*
*
- * TODO: comments on other content, the forum and Pulse APIs are being added to Community now and
- * are not wrapped yet; paste comments are.
+ * The Feed and status posts are here too: feed() reads GET /api/v1/feed (one stream from Pulse across every
+ * OpenVibe site) and posts.create() posts text with up to four pictures. Comments on other content, the rest of
+ * the forum and Pulse's service API are not wrapped yet; paste comments are.
*/
*/
const { isOpenVibeError } = require('./core/errors');
const { isOpenVibeError } = require('./core/errors');
const { isActingSubjectId } = require('./core/ids');
const { isActingSubjectId } = require('./core/ids');
@@ -102,8 +103,23 @@ function createCommunityClient(client, defaults = {}) {
@@ -102,8 +103,23 @@ function createCommunityClient(client, defaults = {}) {
},
},
};
};
+ const feed = (query = {}, o = {}) => call({
+ path: '/api/v1/feed',
+ query: { kind: query.kind, site: query.site, q: query.q, cursor: query.cursor, limit: query.limit,
+ following: query.following === true || query.following === 1 ? '1' : undefined },
+ }, o);
+ const posts = {
+ /**
+ * A status post in the Feed at once: { text, pictures?: [{ media_id, alt }] } (at most four, alt required,
+ * each media_id a Media object the person owns). -> { id, post_id, text, url, pictures, created_at }
+ */
+ create: (input = {}, o = {}) => call({ method: 'POST', path: '/api/v1/posts', json: input, ...once }, o),
+ };
+
return {
return {
pastes,
pastes,
+ feed,
+ posts,
/** The same client acting for someone else: as('usr_…') or as({ actingSubject, origin, sourceRef, staff }). */
/** The same client acting for someone else: as('usr_…') or as({ actingSubject, origin, sourceRef, staff }). */
as(who) {
as(who) {
const next = typeof who === 'string' ? { actingSubject: who } : { ...who };
const next = typeof who === 'string' ? { actingSubject: who } : { ...who };
@@ -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.112.0';
+const SDK_VERSION = '0.113.0';
module.exports = {
module.exports = {
createClient,
createClient,
@@ -117,4 +117,27 @@ run([
@@ -117,4 +117,27 @@ run([
assert.deepEqual(slugs, ['s1', 's2', 's3', 's4', 's5']);
assert.deepEqual(slugs, ['s1', 's2', 's3', 's4', 's5']);
await srv.close();
await srv.close();
}],
}],
+
+ ['the Feed and a status post: query, alt pictures in the body, acting subject, never retried', async () => {
+ const srv = await echo();
+ const community = createCommunityClient(createClient({ baseUrls: { community: srv.url } }), { actingSubject: USR });
+ const body = await community.feed({ kind: 'wiki', site: 'wiki', q: 'cats', following: true, cursor: 'abc', limit: 10 });
+ assert.deepEqual(body, { ok: true });
+ let r = srv.requests[0];
+ assert.equal(r.method, 'GET');
+ const url = new URL(r.url, 'http://x');
+ assert.equal(url.pathname, '/api/v1/feed');
+ assert.deepEqual(Object.fromEntries(url.searchParams), { kind: 'wiki', site: 'wiki', q: 'cats', cursor: 'abc', limit: '10', following: '1' });
+ assert.equal(hdr(r, 'X-OV-Subject'), USR);
+ const media = 'med_01JAB2C3D4E5F6G7H8J9K0MNPQ';
+ await community.posts.create({ text: 'Look', pictures: [{ media_id: media, alt: 'A white cat' }] });
+ r = srv.requests[1];
+ assert.equal(r.method, 'POST');
+ assert.equal(r.url, '/api/v1/posts');
+ assert.deepEqual(JSON.parse(r.body), { text: 'Look', pictures: [{ media_id: media, alt: 'A white cat' }] });
+ assert.equal(hdr(r, 'idempotency-key'), undefined, 'a post is a write Community does not dedupe');
+ await community.posts.create({ text: 'Plain' });
+ assert.deepEqual(JSON.parse(srv.requests[2].body), { text: 'Plain' });
+ await srv.close();
+ }],
]);
]);
@@ -33,8 +33,33 @@ export interface PastesApi {
@@ -33,8 +33,33 @@ export interface PastesApi {
delete(slug: string, commentId: string | number, opts?: CallOptions): Promise<unknown>;
delete(slug: string, commentId: string | number, opts?: CallOptions): Promise<unknown>;
};
};
}
}
+export type FeedKind = 'live' | 'stream' | 'clip' | 'video' | 'pic' | 'post' | 'meme' | 'game' | 'update' | 'wiki' | 'quest' | 'chat' | 'event' | 'member';
+export interface FeedQuery { kind?: FeedKind; site?: string; q?: string; following?: boolean | 1; cursor?: string; limit?: number; }
+export interface FeedItem {
+ id: string;
+ kind: FeedKind;
+ url: string;
+ title: string;
+ text: string;
+ at: string | null;
+ site: string;
+ site_name: string;
+ actor: { name: string | null; avatar: string | null } | null;
+ media: { thumb: string; ratio: number; length?: number } | null;
+ counts: { views?: number; likes?: number; comments?: number };
+ label?: 'Trending' | 'AI' | 'System';
+}
+export interface CreatePostInput {
+ text: string;
+ pictures?: Array<{ media_id: string; alt: string }>;
+}
+export interface PostsApi {
+ create(input: CreatePostInput, opts?: CallOptions): Promise<{ id: number; post_id: number; text: string; url: string; pictures: Array<{ media_id: string; alt: string | null; url?: string }>; created_at: string }>;
+}
export interface CommunityClient {
export interface CommunityClient {
pastes: PastesApi;
pastes: PastesApi;
+ feed(query?: FeedQuery, opts?: CallOptions): Promise<{ items: FeedItem[]; next_cursor: string | null }>;
+ posts: PostsApi;
as(who: string | ActingOptions): CommunityClient;
as(who: string | ActingOptions): CommunityClient;
headers(): Record<string, string>;
headers(): Record<string, string>;
}
}