Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(sdk-js): type readiness dependencies as status objects

Yudhi Armyndharis0b391769837a
diff --git a/sdk/javascript/src/types.ts b/sdk/javascript/src/types.ts
index d12c92055..92c84dbe4 100644
--- a/sdk/javascript/src/types.ts
+++ b/sdk/javascript/src/types.ts
@@ -1191,14 +1191,18 @@ export interface HealthResponse {
version?: string;
}
+export interface HealthDependencyStatus {
+ status: 'up' | 'down';
+}
+
export interface HealthReadyDetails {
- mainDatabase?: string;
- dataDatabase?: string;
+ mainDatabase?: HealthDependencyStatus;
+ dataDatabase?: HealthDependencyStatus;
}
export interface HealthReadyResponse {
status: string;
- details?: HealthReadyDetails;
+ details: HealthReadyDetails;
}
// ── Auth ──────────────────────────────────────────────────────────
diff --git a/sdk/javascript/test/wire-contract.test-d.ts b/sdk/javascript/test/wire-contract.test-d.ts
index 0be9447d8..bebb03335 100644
--- a/sdk/javascript/test/wire-contract.test-d.ts
+++ b/sdk/javascript/test/wire-contract.test-d.ts
@@ -21,6 +21,7 @@ import type {
ChannelMessageRecord,
ChannelRecord,
ChatHistoryMessage,
+ HealthReadyResponse,
LabelRecord,
StatusRecord,
} from '../src/types.js';
@@ -152,6 +153,15 @@ interface WireCatalog {
url: string;
}
+/**
+ * `ReadinessResponseDto`: the 200 body of `GET /api/health/ready`. Each dependency is an object
+ * carrying its own `status`, not a bare string.
+ */
+interface WireReadiness {
+ status: string;
+ details: { mainDatabase: { status: 'up' | 'down' }; dataDatabase: { status: 'up' | 'down' } };
+}
+
/**
* Resolves to `true` only when `Rec` is an honest view of `Wire`: it can hold every real response
* (so no field access that the server answers is a compile error), and it declares no field the
@@ -172,5 +182,6 @@ const channel: Mirrors<WireChannel, ChannelRecord> = true;
const channelMessage: Mirrors<WireChannelMessage, ChannelMessageRecord> = true;
const catalog: Mirrors<WireCatalog, CatalogInfo> = true;
const chatHistoryMessage: Mirrors<WireChatHistoryMessage, ChatHistoryMessage> = true;
+const readiness: Mirrors<WireReadiness, HealthReadyResponse> = true;
-export const contract = [label, status, channel, channelMessage, catalog, chatHistoryMessage];
+export const contract = [label, status, channel, channelMessage, catalog, chatHistoryMessage, readiness];