Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
feat(sdk): expose deleteProfilePicture everywhere and gate SDK verbs on shared paths
Yudhi Armyndharisfb344eeacf55
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 302698906..041e469ea 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Fixed+- All five SDKs expose `deleteProfilePicture` (the contract's `DELETE /profile/picture` shipped in none of them), and the SDK coverage gate now checks verbs on multi-verb paths, not just path reachability.- The dashboard's manual WebSocket retry re-registers the message handler on the fresh socket; the handler effect only re-ran on events changes, so a reconnect left the new socket silent while reporting connected.- The Chats page honours the system dark theme: four dark-palette rules (outgoing bubble, document media, quote box, action menus) only matched an explicit data-theme and left the default 'system' theme rendering light popups inside a dark thread.- The Logs page resets to page 1 on a new search and its empty state distinguishes "no matches on this page" (search filters the fetched page only) from "no logs yet".diff --git a/docs/18-sdk-design.md b/docs/18-sdk-design.mdindex ec960690c..689c3d5f5 100644--- a/docs/18-sdk-design.md+++ b/docs/18-sdk-design.md@@ -40,7 +40,7 @@ All five SDKs expose the same fluent surface:| `status` | list, fromContact, media, sendText, sendImage, sendVideo, sendVoice, delete _(Stories)_ || `search` | search || `templates` | list, get, create, update, delete |-| `profile` | setProfileName, setProfileStatus, setProfilePicture |+| `profile` | setProfileName, setProfileStatus, setProfilePicture, deleteProfilePicture || `calls` | rejectCall, createLink || `media` | conversionStatus, convertVoice, convertVideo _(OPERATOR)_ || `health` | check, live, ready |@@ -316,11 +316,12 @@ Media bodies share the `SendMediaRequest` shape: `{ chatId, url? | base64?, mime#### `profile`-| Method | Signature | Description |-| ------------------- | ------------------------------------- | ------------------------------------------------------------------------------ |-| `setProfileName` | `setProfileName(sessionId, name)` | Set the account display name. **OPERATOR** |-| `setProfileStatus` | `setProfileStatus(sessionId, status)` | Set the account about/status text (empty clears it). **OPERATOR** |-| `setProfilePicture` | `setProfilePicture(sessionId, body)` | Set the account profile picture (`url` or `base64` + `mimetype`). **OPERATOR** |+| Method | Signature | Description |+| ---------------------- | ------------------------------------- | ------------------------------------------------------------------------------ |+| `setProfileName` | `setProfileName(sessionId, name)` | Set the account display name. **OPERATOR** |+| `setProfileStatus` | `setProfileStatus(sessionId, status)` | Set the account about/status text (empty clears it). **OPERATOR** |+| `setProfilePicture` | `setProfilePicture(sessionId, body)` | Set the account profile picture (`url` or `base64` + `mimetype`). **OPERATOR** |+| `deleteProfilePicture` | `deleteProfilePicture(sessionId)` | Remove the account profile picture. **OPERATOR** |#### `calls`@@ -682,11 +683,12 @@ Resources are accessed as properties on the client (e.g. `client.messages`). All#### `client.profile`-| Method | Signature | Description |-| --------------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------ |-| `set_profile_name` | `set_profile_name(session_id, body) -> SuccessResult` | Set the account display name. **OPERATOR** |-| `set_profile_status` | `set_profile_status(session_id, body) -> SuccessResult` | Set the account about/status text (empty clears it). **OPERATOR** |-| `set_profile_picture` | `set_profile_picture(session_id, body) -> SuccessResult` | Set the account profile picture (`url` or `base64` + `mimetype`). **OPERATOR** |+| Method | Signature | Description |+| ------------------------ | -------------------------------------------------------- | ------------------------------------------------------------------------------ |+| `set_profile_name` | `set_profile_name(session_id, body) -> SuccessResult` | Set the account display name. **OPERATOR** |+| `set_profile_status` | `set_profile_status(session_id, body) -> SuccessResult` | Set the account about/status text (empty clears it). **OPERATOR** |+| `set_profile_picture` | `set_profile_picture(session_id, body) -> SuccessResult` | Set the account profile picture (`url` or `base64` + `mimetype`). **OPERATOR** |+| `delete_profile_picture` | `delete_profile_picture(session_id) -> SuccessResult` | Remove the account profile picture. **OPERATOR** |#### `client.calls`@@ -1023,11 +1025,12 @@ All payloads are associative arrays; all listed methods are synchronous and retu#### `profile`-| Method | Signature | Description |-| ------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------ |-| `setProfileName` | `setProfileName(string $sessionId, string $name): array` | Set the account display name. **OPERATOR** |-| `setProfileStatus` | `setProfileStatus(string $sessionId, string $status): array` | Set the account about/status text (empty clears it). **OPERATOR** |-| `setProfilePicture` | `setProfilePicture(string $sessionId, array $body): array` | Set the account profile picture (`url` or `base64` + `mimetype`). **OPERATOR** |+| Method | Signature | Description |+| ---------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------ |+| `setProfileName` | `setProfileName(string $sessionId, string $name): array` | Set the account display name. **OPERATOR** |+| `setProfileStatus` | `setProfileStatus(string $sessionId, string $status): array` | Set the account about/status text (empty clears it). **OPERATOR** |+| `setProfilePicture` | `setProfilePicture(string $sessionId, array $body): array` | Set the account profile picture (`url` or `base64` + `mimetype`). **OPERATOR** |+| `deleteProfilePicture` | `deleteProfilePicture(string $sessionId): array` | Remove the account profile picture. **OPERATOR** |#### `calls`diff --git a/scripts/check-sdk-coverage.mjs b/scripts/check-sdk-coverage.mjsindex fb010680f..c0fbfcf1d 100644--- a/scripts/check-sdk-coverage.mjs+++ b/scripts/check-sdk-coverage.mjs@@ -242,6 +242,127 @@ if (!errors.length) {}}++// ─── Verb layer ──────────────────────────────────────────────────────────────────────────────+// The path layer above proves each client REACHES a route; a shared path can still miss a VERB+// entirely; the profile-picture route carried PUT in every client while its DELETE shipped in+// none, and the path gate stayed green because the PUT satisfied it. This layer asks the verb+// question: for every contract path published with MORE THAN ONE verb, each client must build+// that path with every verb the contract declares on it. Multi-verb paths only; a single-verb+// path is already fully proven by the layer above.+const VERBS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'];++/** Join a concatenated path expression: literals verbatim, code between them becomes a `*`. */+const literalsToPath = (expr) => {+ let path = '';+ let last = 0;+ for (const m of expr.matchAll(/["'`](\/[^"'`\n]*)["'`]/g)) {+ const between = expr.slice(last, m.index);+ if (path && /\S/.test(between.replace(/["'`+\s]+/g, ''))) path += '*';+ else if (!path && /\S/.test(between.replace(/\s+/g, ''))) path += '*';+ path += m[1];+ last = m.index + m[0].length;+ }+ // Trailing code after the LAST literal (`"/api/sessions/" + encodeSegment(id)`) is an id segment too.+ const trailing = expr.slice(last).replace(/["'`+\s,;)\n]+/g, '');+ if (path && trailing) path += '*';+ return path.startsWith('/api/') ? path : null;+};++/** Go resolves its base() helpers so `s.base(sessionID)+"/picture"` reattaches to a real path. */+const goVerbPairs = (dir) => {+ const pairs = new Set();+ for (const file of walk(dir, ['.go']).filter((f) => !f.endsWith('_test.go'))) {+ const source = strip(readFileSync(file, 'utf8'));+ const bases = new Map();+ for (const helper of source.matchAll(/func \(s \*\w+Service\) (\w+)\([^)]*\) string \{\s*return ([^\n]+)\n/g)) {+ const base = normalize(+ helper[2].split('+').map((t) => t.trim()).map((t) => /^"([^"]*)"$/.exec(t)?.[1] ?? '*').join(''),+ );+ if (base.startsWith('/api/')) bases.set(helper[1], base);+ }+ // Wrapper helpers route the verb through a parameter (`s.participants(ctx, "POST", ..., "/participants")`),+ // so the do() site only sees a variable. Harvest the verb + suffix literal from the wrapper call+ // and pair it with the file's service bases (base+suffix and base/*+suffix), same generosity as+ // the path layer's helper-argument rule.+ for (const m of source.matchAll(/\.\w+\(\s*ctx\s*,\s*"(GET|POST|PUT|PATCH|DELETE)"\s*,[^)]*?"(\/[a-z0-9][\w.\/-]*)"/g)) {+ for (const base of bases.values()) {+ pairs.add(`${m[1]} ${normalize(base + m[2])}`);+ pairs.add(`${m[1]} ${normalize(`${base}/*${m[2]}`)}`);+ }+ }+ for (const m of source.matchAll(/\.do\(\s*ctx\s*,\s*"(GET|POST|PUT|PATCH|DELETE)"\s*,\s*([^\n]+?),\s*(?:nil|[A-Za-z_&])/g)) {+ const expr = m[2]+ .split('+')+ .map((t) => t.trim())+ .map((t) => {+ const lit = /^"([^"]*)"$/.exec(t)?.[1];+ if (lit !== undefined) return lit;+ const helper = /^s\.(\w+)\(/.exec(t)?.[1];+ if (helper && bases.has(helper)) return bases.get(helper);+ return '*';+ })+ .join('');+ if (expr.startsWith('/api/')) pairs.add(`${m[1]} ${normalize(expr)}`);+ }+ }+ return pairs;+};++const verbPairsOf = (sdk) => {+ if (sdk.name === 'go') return goVerbPairs(join(root, sdk.dir));+ const pairs = new Set();+ for (const file of walk(join(root, sdk.dir), sdk.exts)) {+ const src = readFileSync(file, 'utf8');+ const patterns =+ sdk.name === 'javascript'+ ? [/(GET|POST|PUT|PATCH|DELETE)'\s*,\s*[\s\S]{0,80}?path:\s*[`'"]([^`'"]+)[`'"]/g]+ : sdk.name === 'python'+ ? [/\.request\(\s*"(GET|POST|PUT|PATCH|DELETE)"\s*,\s*f?"([^"]+)"/g]+ : sdk.name === 'php'+ ? [/->request\(\s*'(GET|POST|PUT|PATCH|DELETE)'\s*,\s*['"]([^'"]+)['"]/g]+ : [/HttpMethod\.(GET|POST|PUT|PATCH|DELETE)\s*,\s*([\s\S]{2,400}?)\s*,\s*\n?\s*(?:null|new |[a-z]\w)/g];+ for (const re of patterns) {+ for (const m of src.matchAll(re)) {+ const path = sdk.name === 'java' ? literalsToPath(m[2]) : m[2];+ if (path && path.startsWith('/api/')) pairs.add(`${m[1]} ${normalize(path)}`);+ }+ }+ }+ return pairs;+};++{+ const spec = JSON.parse(readFileSync(join(root, 'openapi.json'), 'utf8')).paths;+ // Same scope as the path layer: resources the README declares unexposed are not the SDKs' to build.+ const specByPath = new Map(Object.entries(spec).map(([k, v]) => [normalize(k), v]));+ const multi = [];+ for (const raw of inScope) {+ const verbs = VERBS.filter((v) => specByPath.get(raw)?.[v.toLowerCase()]);+ if (verbs.length > 1) multi.push({ path: raw, verbs });+ }+ const verbErrors = [];+ for (const sdk of SDKS) {+ const pairs = verbPairsOf(sdk);+ // Non-vacuity: a regex that stopped matching yields an empty set and the layer goes blind.+ if (pairs.size < 60) verbErrors.push(`${sdk.name}: harvested only ${pairs.size} verb/path pairs — the verb scan has drifted.`);+ for (const { path, verbs } of multi) {+ for (const verb of verbs) {+ if (!pairs.has(`${verb} ${path}`)) verbErrors.push(`${verb} ${path} — declared by the contract, built by no ${sdk.name} method`);+ }+ }+ }+ if (multi.length < 15) {+ console.error('check-sdk-coverage: expected 15+ in-scope multi-verb contract paths, found ' + multi.length);+ process.exit(1);+ }+ if (verbErrors.length) {+ console.error('\n✖ Verbs missing from SDK methods on shared paths:');+ for (const e of verbErrors) console.error(` - ${e}`);+ process.exit(1);+ }+}+if (errors.length) {console.error('\n✖ The contract publishes routes the SDKs do not expose:');for (const e of errors) console.error(` - ${e}`);diff --git a/sdk/README.md b/sdk/README.mdindex fba63b9d3..2f6e5ebd8 100644--- a/sdk/README.md+++ b/sdk/README.md@@ -36,7 +36,7 @@ All five SDKs expose the same fluent resource surface:| `status` | list, fromContact, media, sendText, sendImage, sendVideo, sendVoice, delete _(Stories)_ || `search` | search _(Operator)_ || `templates` | list, get, create, update, delete |-| `profile` | setProfileName, setProfileStatus, setProfilePicture _(OPERATOR)_ |+| `profile` | setProfileName, setProfileStatus, setProfilePicture, deleteProfilePicture _(OPERATOR)_ || `calls` | rejectCall, createLink _(OPERATOR)_ || `media` | conversionStatus, convertVoice, convertVideo _(OPERATOR)_ || `health` | check, live, ready |diff --git a/sdk/go/profile.go b/sdk/go/profile.goindex 7344a2927..9f271e627 100644--- a/sdk/go/profile.go+++ b/sdk/go/profile.go@@ -42,3 +42,13 @@ func (s *ProfileService) SetProfilePicture(ctx context.Context, sessionID string}return &out, nil}++// DeleteProfilePicture removes the account profile picture.+func (s *ProfileService) DeleteProfilePicture(ctx context.Context, sessionID string) (*SuccessResult, error) {+ var out SuccessResult+ err := s.client.do(ctx, "DELETE", s.base(sessionID)+"/picture", nil, nil, &out)+ if err != nil {+ return nil, err+ }+ return &out, nil+}diff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/resources/ProfileResource.java b/sdk/java/src/main/java/com/rmyndharis/openwa/resources/ProfileResource.javaindex 3ea30f288..221b3ed4a 100644--- a/sdk/java/src/main/java/com/rmyndharis/openwa/resources/ProfileResource.java+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/resources/ProfileResource.java@@ -46,4 +46,14 @@ public final class ProfileResource {body,SuccessResult.class);}++ /** Remove the account profile picture. */+ public SuccessResult deleteProfilePicture(String sessionId) {+ return client.request(+ HttpMethod.DELETE,+ "/api/sessions/" + encodeSegment(sessionId) + "/profile/picture",+ null,+ null,+ SuccessResult.class);+ }}diff --git a/sdk/javascript/src/resources/profile.ts b/sdk/javascript/src/resources/profile.tsindex 62d958b4c..fede9402a 100644--- a/sdk/javascript/src/resources/profile.ts+++ b/sdk/javascript/src/resources/profile.ts@@ -39,4 +39,12 @@ export class ProfileResource {body,});}++ /** Remove the account profile picture. */+ deleteProfilePicture(sessionId: string): Promise<SuccessResult> {+ return this.client.request<SuccessResult>({+ method: 'DELETE',+ path: `/api/sessions/${encodeSegment(sessionId)}/profile/picture`,+ });+ }}diff --git a/sdk/php/src/Resources/ProfileResource.php b/sdk/php/src/Resources/ProfileResource.phpindex a30ac81a2..f779c32f2 100644--- a/sdk/php/src/Resources/ProfileResource.php+++ b/sdk/php/src/Resources/ProfileResource.php@@ -52,4 +52,14 @@ class ProfileResource{return $this->http->request('PUT', "/api/sessions/{$this->http->encodeSegment($sessionId)}/profile/picture", [], $body);}++ /**+ * Remove the account profile picture. Requires an OPERATOR-level key.+ *+ * @return array<string,mixed>+ */+ public function deleteProfilePicture(string $sessionId): array+ {+ return $this->http->request('DELETE', "/api/sessions/{$this->http->encodeSegment($sessionId)}/profile/picture");+ }}diff --git a/sdk/python/openwa/resources/profile.py b/sdk/python/openwa/resources/profile.pyindex 3d5fe6c83..b671e64dc 100644--- a/sdk/python/openwa/resources/profile.py+++ b/sdk/python/openwa/resources/profile.py@@ -37,3 +37,7 @@ class ProfileResource:Requires an OPERATOR-level key."""return self._http.request("PUT", f"/api/sessions/{quote_segment(session_id)}/profile/picture", body=body)++ def delete_profile_picture(self, session_id: str) -> SuccessResult:+ """Remove the account profile picture. Requires an OPERATOR-level key."""+ return self._http.request("DELETE", f"/api/sessions/{quote_segment(session_id)}/profile/picture")