Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
style(lint): format status + baileys status work to fix CI Lint
yudhi0b987ae18a0c
diff --git a/src/engine/adapters/baileys.adapter.spec.ts b/src/engine/adapters/baileys.adapter.spec.tsindex 1c57dcc46..7feb8ddec 100644--- a/src/engine/adapters/baileys.adapter.spec.ts+++ b/src/engine/adapters/baileys.adapter.spec.ts@@ -1697,11 +1697,15 @@ describe('BaileysAdapter status posting', () => {backgroundColor: '#25D366',font: 2,});- expect(fakeSock.sendMessage).toHaveBeenCalledWith('status@broadcast', { text: 'hello' }, {- statusJidList: ['[email protected]', '628222@lid'],- backgroundColor: '#25D366',- font: 2,- });+ expect(fakeSock.sendMessage).toHaveBeenCalledWith(+ 'status@broadcast',+ { text: 'hello' },+ {+ statusJidList: ['[email protected]', '628222@lid'],+ backgroundColor: '#25D366',+ font: 2,+ },+ );expect(result.statusId).toBe('STATUS1');expect(result.expiresAt.getTime() - result.timestamp.getTime()).toBe(24 * 3_600_000);expect(fakeStore.put).not.toHaveBeenCalled();@@ -1725,10 +1729,7 @@ describe('BaileysAdapter status posting', () => {it('postVideoStatus resolves media and threads recipients', async () => {fakeSock.sendMessage.mockResolvedValue({ key: { id: 'VID1' }, messageTimestamp: 1719600000 });const adapter = await ready();- await adapter.postVideoStatus(- { mimetype: 'video/mp4', data: 'AAAA' },- { recipients: ['[email protected]'] },- );+ await adapter.postVideoStatus({ mimetype: 'video/mp4', data: 'AAAA' }, { recipients: ['[email protected]'] });expect(fakeSock.sendMessage).toHaveBeenCalledWith('status@broadcast',{ video: Buffer.from('AAAA', 'base64'), caption: undefined, mimetype: 'video/mp4' },diff --git a/src/engine/adapters/baileys.adapter.ts b/src/engine/adapters/baileys.adapter.tsindex 2b185e787..141550c4a 100644--- a/src/engine/adapters/baileys.adapter.ts+++ b/src/engine/adapters/baileys.adapter.ts@@ -1358,9 +1358,7 @@ export class BaileysAdapter implements IWhatsAppEngine {/** Shape a Baileys send result into a StatusResult; expiresAt is timestamp + 24h (WhatsApp status TTL). */private toStatusResult(sent: WAMessage | undefined): StatusResult {- const ts = sent?.messageTimestamp- ? new Date(this.toUnixSeconds(sent.messageTimestamp) * 1000)- : new Date();+ const ts = sent?.messageTimestamp ? new Date(this.toUnixSeconds(sent.messageTimestamp) * 1000) : new Date();return {statusId: sent?.key?.id ?? '',timestamp: ts,diff --git a/src/modules/status/dto/send-media-status.dto.spec.ts b/src/modules/status/dto/send-media-status.dto.spec.tsindex 15b02572d..8e61aebf3 100644--- a/src/modules/status/dto/send-media-status.dto.spec.ts+++ b/src/modules/status/dto/send-media-status.dto.spec.ts@@ -13,23 +13,23 @@ describe('SendImageStatusDto recipients validation', () => {it('rejects missing recipients', async () => {const errors = await validate(plainToInstance(SendImageStatusDto, { image: valid.image }));- expect(errors.some((e) => e.property === 'recipients')).toBe(true);+ expect(errors.some(e => e.property === 'recipients')).toBe(true);});it('rejects an empty recipients array (-> 400)', async () => {const errors = await validate(plainToInstance(SendImageStatusDto, { image: valid.image, recipients: [] }));- expect(errors.some((e) => e.property === 'recipients')).toBe(true);+ expect(errors.some(e => e.property === 'recipients')).toBe(true);});it('rejects non-string entries', async () => {const errors = await validate(plainToInstance(SendImageStatusDto, { image: valid.image, recipients: [123] }));- expect(errors.some((e) => e.property === 'recipients')).toBe(true);+ expect(errors.some(e => e.property === 'recipients')).toBe(true);});it('rejects more than 256 recipients', async () => {const recipients = Array.from({ length: 257 }, (_, i) => `${i}@c.us`);const errors = await validate(plainToInstance(SendImageStatusDto, { image: valid.image, recipients }));- expect(errors.some((e) => e.property === 'recipients')).toBe(true);+ expect(errors.some(e => e.property === 'recipients')).toBe(true);});it('rejects malformed JIDs', async () => {@@ -39,11 +39,13 @@ describe('SendImageStatusDto recipients validation', () => {recipients: ['not-a-jid', '[email protected]', '@c.us', 'abc@lid'],}),);- expect(errors.some((e) => e.property === 'recipients')).toBe(true);+ expect(errors.some(e => e.property === 'recipients')).toBe(true);});it('accepts @lid recipients', async () => {- const errors = await validate(plainToInstance(SendImageStatusDto, { image: valid.image, recipients: ['6281@lid'] }));+ const errors = await validate(+ plainToInstance(SendImageStatusDto, { image: valid.image, recipients: ['6281@lid'] }),+ );expect(errors).toHaveLength(0);});});@@ -58,23 +60,23 @@ describe('SendVideoStatusDto recipients validation', () => {it('rejects missing recipients', async () => {const errors = await validate(plainToInstance(SendVideoStatusDto, { video: valid.video }));- expect(errors.some((e) => e.property === 'recipients')).toBe(true);+ expect(errors.some(e => e.property === 'recipients')).toBe(true);});it('rejects an empty recipients array (-> 400)', async () => {const errors = await validate(plainToInstance(SendVideoStatusDto, { video: valid.video, recipients: [] }));- expect(errors.some((e) => e.property === 'recipients')).toBe(true);+ expect(errors.some(e => e.property === 'recipients')).toBe(true);});it('rejects non-string entries', async () => {const errors = await validate(plainToInstance(SendVideoStatusDto, { video: valid.video, recipients: [123] }));- expect(errors.some((e) => e.property === 'recipients')).toBe(true);+ expect(errors.some(e => e.property === 'recipients')).toBe(true);});it('rejects more than 256 recipients', async () => {const recipients = Array.from({ length: 257 }, (_, i) => `${i}@c.us`);const errors = await validate(plainToInstance(SendVideoStatusDto, { video: valid.video, recipients }));- expect(errors.some((e) => e.property === 'recipients')).toBe(true);+ expect(errors.some(e => e.property === 'recipients')).toBe(true);});it('rejects malformed JIDs', async () => {@@ -84,11 +86,13 @@ describe('SendVideoStatusDto recipients validation', () => {recipients: ['not-a-jid', '[email protected]', '@c.us', 'abc@lid'],}),);- expect(errors.some((e) => e.property === 'recipients')).toBe(true);+ expect(errors.some(e => e.property === 'recipients')).toBe(true);});it('accepts @lid recipients', async () => {- const errors = await validate(plainToInstance(SendVideoStatusDto, { video: valid.video, recipients: ['6281@lid'] }));+ const errors = await validate(+ plainToInstance(SendVideoStatusDto, { video: valid.video, recipients: ['6281@lid'] }),+ );expect(errors).toHaveLength(0);});});diff --git a/src/modules/status/dto/send-media-status.dto.ts b/src/modules/status/dto/send-media-status.dto.tsindex 3ae6bdaab..6626da3bc 100644--- a/src/modules/status/dto/send-media-status.dto.ts+++ b/src/modules/status/dto/send-media-status.dto.ts@@ -1,12 +1,4 @@-import {- IsString,- IsOptional,- ValidateNested,- IsArray,- ArrayMinSize,- ArrayMaxSize,- Matches,-} from 'class-validator';+import { IsString, IsOptional, ValidateNested, IsArray, ArrayMinSize, ArrayMaxSize, Matches } from 'class-validator';import { Type } from 'class-transformer';class StatusMediaInput {diff --git a/src/modules/status/dto/send-text-status.dto.spec.ts b/src/modules/status/dto/send-text-status.dto.spec.tsindex e13a8afc9..640a3f0a5 100644--- a/src/modules/status/dto/send-text-status.dto.spec.ts+++ b/src/modules/status/dto/send-text-status.dto.spec.ts@@ -13,23 +13,23 @@ describe('SendTextStatusDto recipients validation', () => {it('rejects missing recipients', async () => {const errors = await validate(plainToInstance(SendTextStatusDto, { text: 'hi' }));- expect(errors.some((e) => e.property === 'recipients')).toBe(true);+ expect(errors.some(e => e.property === 'recipients')).toBe(true);});it('rejects an empty recipients array (-> 400)', async () => {const errors = await validate(plainToInstance(SendTextStatusDto, { text: 'hi', recipients: [] }));- expect(errors.some((e) => e.property === 'recipients')).toBe(true);+ expect(errors.some(e => e.property === 'recipients')).toBe(true);});it('rejects non-string entries', async () => {const errors = await validate(plainToInstance(SendTextStatusDto, { text: 'hi', recipients: [123] }));- expect(errors.some((e) => e.property === 'recipients')).toBe(true);+ expect(errors.some(e => e.property === 'recipients')).toBe(true);});it('rejects more than 256 recipients', async () => {const recipients = Array.from({ length: 257 }, (_, i) => `${i}@c.us`);const errors = await validate(plainToInstance(SendTextStatusDto, { text: 'hi', recipients }));- expect(errors.some((e) => e.property === 'recipients')).toBe(true);+ expect(errors.some(e => e.property === 'recipients')).toBe(true);});it('accepts exactly 256 recipients', async () => {@@ -42,7 +42,7 @@ describe('SendTextStatusDto recipients validation', () => {const errors = await validate(plainToInstance(SendTextStatusDto, { text: 'hi', recipients: ['not-a-jid', '[email protected]', '@c.us', 'abc@lid'] }),);- expect(errors.some((e) => e.property === 'recipients')).toBe(true);+ expect(errors.some(e => e.property === 'recipients')).toBe(true);});it('accepts @lid recipients', async () => {diff --git a/src/modules/status/dto/send-text-status.dto.ts b/src/modules/status/dto/send-text-status.dto.tsindex 7a5303b4a..df804cb38 100644--- a/src/modules/status/dto/send-text-status.dto.ts+++ b/src/modules/status/dto/send-text-status.dto.ts@@ -1,14 +1,4 @@-import {- IsString,- IsOptional,- IsInt,- Min,- Max,- Matches,- IsArray,- ArrayMinSize,- ArrayMaxSize,-} from 'class-validator';+import { IsString, IsOptional, IsInt, Min, Max, Matches, IsArray, ArrayMinSize, ArrayMaxSize } from 'class-validator';export class SendTextStatusDto {@IsString()