diff --git a/CHANGELOG.md b/CHANGELOG.md index 1014e94..f6b9785 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- **New Feature**: `contacts.deleteByEmail()` method for deleting contacts by email address + - Added `deleteByEmail(email: string)` method to Contacts API + - Properly handles URL encoding of email addresses with special characters + - Returns same response format as existing `delete()` method: `{ isDeleted: boolean, contact: Contact }` + - Added comprehensive tests and example usage + - Integrates with new SMASHSEND backend endpoint `/v1/contacts/by-email/{email}` + +## [1.16.0] - 2025-01-21 + +### Changed + +- **BREAKING**: Simplified transactional email response format to match backend API changes + - `RawEmailSendResponse` now returns: `{ messageId, status, to, warning?, groupBy? }` + - `TemplatedEmailSendResponse` now returns: `{ messageId, status, to, warning? }` + - Removed deprecated fields: `from`, `subject`, `type`, `template`, `created`, `statusCode`, `message` + - Updated all tests to use the new response format + - This change aligns the Node.js SDK with the simplified backend response schema + +### Added + - **Dynamic Reply-To Addresses**: Added support for custom reply-to addresses in both raw and templated emails - 📧 **Multiple addresses**: Support for up to 5 reply-to addresses per email - 🔄 **Flexible input**: Accept single email string or array of email strings diff --git a/package.json b/package.json index afaaa96..e54e314 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@smashsend/node", - "version": "1.15.0", + "version": "1.16.0", "description": "SMASHSEND Node.js SDK - Official Node.js client for SMASHSEND API", "main": "dist/index.js", "module": "dist/index.mjs", diff --git a/src/interfaces/events.ts b/src/interfaces/events.ts index 6f84873..5904dd7 100644 --- a/src/interfaces/events.ts +++ b/src/interfaces/events.ts @@ -1,20 +1,49 @@ // Events API types for SMASHSEND +/** + * User traits/attributes to sync with contact record + */ +export interface EventTraits { + [key: string]: any; +} + +/** + * User identification information + */ +export interface EventIdentify { + /** User email address (required) */ + email: string; + /** + * User traits/attributes to sync with contact record + * This is optional, and will be ignored if not provided. + **/ + traits?: EventTraits; +} + /** * Event tracking payload for single event */ export interface EventPayload { - /** Event name (alphanumeric, underscores, hyphens, dots, colons only) */ + /** + * Event name (alphanumeric, underscores, hyphens, dots, colons only) + **/ event: string; - /** Event properties - key-value pairs with any data */ + + /** + * Event properties - key-value pairs with any data + **/ properties?: Record; - /** User identification information */ - identify: { - /** User email address (required) */ - email: string; - }; - /** Event timestamp (ISO string or Unix timestamp) */ + + /** + * User identification information + **/ + identify: EventIdentify; + + /** + * Event timestamp (ISO string or Unix timestamp) + **/ timestamp?: string | number; + /** * Optional message ID for deduplication. * If not provided, SMASHSEND will generate one automatically. diff --git a/src/interfaces/types.ts b/src/interfaces/types.ts index 33f62e5..2b35722 100644 --- a/src/interfaces/types.ts +++ b/src/interfaces/types.ts @@ -126,12 +126,6 @@ export interface RawEmailSendResponse { status: TransactionalEmailStatus; /** Recipient address. */ to: string; - /** Sender address. */ - from: string; - /** Subject line. */ - subject: string; - /** Discriminator – always `raw`. */ - type: 'raw'; /** Warning returned by backend when the email is accepted with caveats. */ warning?: string; /** Custom analytics group identifier if provided. */ @@ -145,10 +139,6 @@ export interface TemplatedEmailSendResponse { status: TransactionalEmailStatus; /** Recipient address. */ to: string; - /** Template identifier sent in the request. */ - template: string; - /** Discriminator – always `templated`. */ - type: 'templated'; /** Warning returned by backend when the email is accepted with caveats. */ warning?: string; }