Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(openapi): publish webhook lastTriggeredAt as a nullable date-time
Yudhi Armyndharise34af1076228
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 471ac278a..13fec9de9 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- `docs/29-engine-capability-matrix.md` (`docs/29`) now covers all 152 Baileys socket methods, all 81 whatsapp-web.js Client methods, all 34 + 31 library events and all five install-time patches, each mapped to the interface method that uses it or marked unexposed.- An onboarding modal the "What's new" probe does not recognise is now logged once with its heading and confirm-button labels (`onboarding_dialog_unrecognized`), so it can be covered via `WWEBJS_ONBOARDING_CONTINUE_LABELS` before WhatsApp unlinks the companion. Refs #1072.+### Fixed++- A webhook's `lastTriggeredAt` is published as a nullable date-time string instead of an object, so a client generated from the contract no longer rejects both of the values the field actually carries. The response itself is unchanged.+### Security- An advisory usage-statistics write no longer persists the whole API-key row. A key deleted while a request that had already loaded it was in flight was re-inserted with its original hash and authenticated again; a revocation or a narrowing of role, allowlist, IP allowlist or expiry was likewise reverted to the values that request loaded. The write is now scoped to the two usage columns and affects nothing if the row is gone.diff --git a/openapi.json b/openapi.jsonindex 8d82b2890..2ecdf7feb 100644--- a/openapi.json+++ b/openapi.json@@ -9967,7 +9967,9 @@"type": "number"},"lastTriggeredAt": {- "type": "object"+ "type": "string",+ "format": "date-time",+ "nullable": true},"createdAt": {"format": "date-time",diff --git a/src/config/openapi-contract.spec.ts b/src/config/openapi-contract.spec.tsindex e201a3c92..662f4cafe 100644--- a/src/config/openapi-contract.spec.ts+++ b/src/config/openapi-contract.spec.ts@@ -115,6 +115,29 @@ describe('openapi.json structural invariants', () => {expect(silent).toEqual([]);});++ it('never types a timestamp property as a bare object', () => {+ const doc = snapshot();+ // A `Date | null` member with no explicit @ApiProperty type is emitted as `type: object`, and the+ // published schema then rejects the ISO string the gateway actually sends. Restricted to+ // timestamp-named properties: the document's other bare objects are genuine Record maps, and the+ // Unix-seconds fields are legitimately `type: number`.+ const scanned: string[] = [];+ const bare: string[] = [];++ for (const [name, schema] of Object.entries(doc.components?.schemas ?? {})) {+ const properties = (schema as { properties?: Record<string, { type?: string }> }).properties ?? {};+ for (const [property, spec] of Object.entries(properties)) {+ if (!/(At|Timestamp)$/.test(property)) continue;+ scanned.push(`${name}.${property}`);+ if (spec.type === 'object') bare.push(`${name}.${property}`);+ }+ }++ // Guard the selector: if the naming convention changed, this would scan nothing and pass.+ expect(scanned.length).toBeGreaterThan(20);+ expect(bare).toEqual([]);+ });});// The document is produced in TWO places: scripts/export-openapi.ts for the committed snapshot, anddiff --git a/src/modules/webhook/dto/webhook.dto.ts b/src/modules/webhook/dto/webhook.dto.tsindex b4772960a..2aea7de5a 100644--- a/src/modules/webhook/dto/webhook.dto.ts+++ b/src/modules/webhook/dto/webhook.dto.ts@@ -218,7 +218,9 @@ export class WebhookResponseDto {retryCount!: number;@Expose()- @ApiPropertyOptional()+ // Spelled out because a bare @ApiPropertyOptional() on `Date | null` emits `type: object`, and the+ // published schema then rejects both values this field actually carries.+ @ApiPropertyOptional({ type: String, format: 'date-time', nullable: true })lastTriggeredAt?: Date | null;@Expose()