Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions src/api-surface.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { LettermintClient } from './client';
import { Lettermint } from './lettermint';
import type * as Types from './types';

const mockFetch = jest.fn();

Expand Down Expand Up @@ -48,6 +49,33 @@ describe('public SDK surface', () => {
expect(mockFetch.mock.calls[0][1].headers).not.toHaveProperty('x-lettermint-token');
});

it('lists blocked file types with bearer token auth', async () => {
mockFetch.mockResolvedValueOnce({
ok: true,
json: async () => ({
extensions: ['exe'],
mime_types: ['application/x-msdownload'],
}),
text: async () => '',
} as Response);
const api = Lettermint.api('api-token');

await expect(api.blockedFileTypes()).resolves.toEqual({
extensions: ['exe'],
mime_types: ['application/x-msdownload'],
});

expect(mockFetch).toHaveBeenCalledWith(
'https://api.lettermint.co/v1/blocked-file-types',
expect.objectContaining({
method: 'GET',
headers: expect.objectContaining({
Authorization: 'Bearer api-token',
}),
})
);
});

it('does not let custom headers override SDK auth headers', async () => {
const client = new LettermintClient({ apiToken: 'api-token', authMode: 'api' });

Expand Down Expand Up @@ -92,6 +120,7 @@ describe('api endpoint coverage', () => {
'domain.verifySpecificDnsRecord': 'domains.verifyDnsRecord',
'domain.updateProjects': 'domains.updateProjects',
'v1.ping': 'ping',
'v1.blockedFileTypes': 'blockedFileTypes',
'message.index': 'messages.list',
'message.show': 'messages.retrieve',
'message.events': 'messages.events',
Expand Down Expand Up @@ -148,3 +177,64 @@ describe('api endpoint coverage', () => {
}
});
});

describe('generated api types', () => {
it('matches current Team API schema additions', () => {
const messageEvent: Types.MessageEventType = 'auto_replied';
const webhookEvent: Types.WebhookEvent = 'message.auto_replied';
const volumeTier: Types.VolumeTier = 300000;
const suppression: Types.StoreSuppressionData = {
reason: 'manual',
scope: 'global',
emails: ['blocked@example.com'],
};
const routeSettings: Types.UpdateRouteSettingsData = {
redact_email_content: true,
disable_plaintext_generation: false,
};
const routeInboundSettings: Types.UpdateRouteInboundSettingsData = {
inbound_domain: 'inbound.example.com',
inbound_spam_threshold: 3,
attachment_delivery: 'url',
};
const routeUpdate: Types.UpdateRouteData = {
settings: routeSettings,
inbound_settings: routeInboundSettings,
};
const projectCreate: Types.StoreProjectData = {
name: 'Production',
short_token: true,
};
const project: Types.ProjectData = {
id: 'project_123',
name: 'Production',
smtp_enabled: true,
redact_email_content: true,
default_route_id: null,
token_generated_at: null,
token_last_used_at: null,
token_last_used_ip: null,
created_at: '2026-06-28T00:00:00Z',
updated_at: '2026-06-28T00:00:00Z',
};
const projectUpdate: Types.UpdateProjectData = {
redact_email_content: false,
};
const blockedFileTypes: Types.BlockedFileTypesResponse = {
extensions: ['exe'],
mime_types: ['application/x-msdownload'],
};

expect({
messageEvent,
webhookEvent,
volumeTier,
suppression,
routeUpdate,
projectCreate,
project,
projectUpdate,
blockedFileTypes,
}).toBeDefined();
});
});
5 changes: 5 additions & 0 deletions src/lettermint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
WebhooksEndpoint,
} from './endpoints/api';
import { EmailEndpoint } from './endpoints/email';
import type * as Types from './types';

/**
* Lettermint SDK
Expand Down Expand Up @@ -80,6 +81,10 @@ export class ApiClient {
public async ping(): Promise<string> {
return (await this.client.getRaw('/ping')).trim();
}

public async blockedFileTypes(): Promise<Types.BlockedFileTypesResponse> {
return this.client.get('/blocked-file-types');
}
}

export default Lettermint;
37 changes: 25 additions & 12 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export interface MessageEventData {
"timestamp": string;
}

export type MessageEventType = "queued" | "processed" | "suppressed" | "delivered" | "soft_bounced" | "hard_bounced" | "spam_complaint" | "failed" | "blocked" | "policy_rejected" | "unsubscribed" | "opened" | "clicked" | "inbound_received" | "inbound_queued" | "inbound_spam_blocked" | "inbound_processed" | "inbound_retry";
export type MessageEventType = "queued" | "processed" | "suppressed" | "delivered" | "auto_replied" | "soft_bounced" | "hard_bounced" | "spam_complaint" | "failed" | "blocked" | "policy_rejected" | "unsubscribed" | "opened" | "clicked" | "inbound_received" | "inbound_queued" | "inbound_spam_blocked" | "inbound_processed" | "inbound_retry";

export interface MessageListData {
"id": string;
Expand Down Expand Up @@ -165,6 +165,7 @@ export interface ProjectData {
"id": string;
"name": string;
"smtp_enabled": boolean;
"redact_email_content": boolean;
"default_route_id": string | null;
"token_generated_at": string | null;
"token_last_used_at": string | null;
Expand Down Expand Up @@ -313,6 +314,7 @@ export interface StoreProjectData {
"name": string;
"smtp_enabled"?: boolean;
"initial_routes"?: InitialRoutes;
"short_token"?: boolean;
}

export interface StoreRouteData {
Expand All @@ -324,7 +326,7 @@ export interface StoreRouteData {
export interface StoreSuppressionData {
"email"?: string | null;
"reason": SuppressionReason;
"scope": "team" | "project" | "route";
"scope": SuppressionScope;
"route_id"?: string | null;
"project_id"?: string | null;
"emails"?: string[] | null;
Expand Down Expand Up @@ -405,6 +407,7 @@ export interface UpdateDomainProjectsData {
export interface UpdateProjectData {
"name"?: string | null;
"smtp_enabled"?: boolean | null;
"redact_email_content"?: boolean | null;
"default_route_id"?: string | null;
}

Expand All @@ -414,16 +417,22 @@ export interface UpdateProjectMembersData {

export interface UpdateRouteData {
"name"?: string | null;
"settings"?: {
"settings"?: UpdateRouteSettingsData | unknown;
"inbound_settings"?: UpdateRouteInboundSettingsData | unknown;
}

export interface UpdateRouteInboundSettingsData {
"inbound_domain"?: string | null;
"inbound_spam_threshold"?: number | null;
"attachment_delivery"?: AttachmentDelivery | unknown;
}

export interface UpdateRouteSettingsData {
"track_opens"?: boolean | null;
"track_clicks"?: boolean | null;
"disable_plaintext_generation"?: boolean | null;
"disable_hosted_unsubscribe"?: boolean | null;
};
"inbound_settings"?: {
"inbound_domain"?: string | null;
"inbound_spam_threshold"?: number | null;
"attachment_delivery"?: AttachmentDelivery;
};
"redact_email_content"?: boolean | null;
}

export interface UpdateTeamData {
Expand All @@ -445,7 +454,7 @@ export interface UserData {
"avatar": string | null;
}

export type VolumeTier = 300 | 10000 | 50000 | 125000 | 500000 | 750000 | 1000000 | 1500000;
export type VolumeTier = 300 | 10000 | 50000 | 125000 | 300000 | 500000 | 750000 | 1000000 | 1500000;

export interface WebhookData {
"id": string;
Expand Down Expand Up @@ -491,7 +500,7 @@ export interface WebhookDeliveryListData {

export type WebhookDeliveryStatus = "pending" | "success" | "failed" | "client_error" | "server_error" | "timeout";

export type WebhookEvent = "message.created" | "message.sent" | "message.delivered" | "message.hard_bounced" | "message.soft_bounced" | "message.spam_complaint" | "message.failed" | "message.suppressed" | "message.unsubscribed" | "message.opened" | "message.clicked" | "message.inbound" | "message.policy_rejected" | "webhook.test";
export type WebhookEvent = "message.created" | "message.sent" | "message.delivered" | "message.auto_replied" | "message.hard_bounced" | "message.soft_bounced" | "message.spam_complaint" | "message.failed" | "message.suppressed" | "message.unsubscribed" | "message.opened" | "message.clicked" | "message.inbound" | "message.policy_rejected" | "webhook.test";

export interface WebhookListData {
"id": string;
Expand Down Expand Up @@ -543,6 +552,10 @@ export type DomainUpdateProjectsResponse = {
"data": DomainData;
"message": "Domain projects updated successfully.";
};
export type BlockedFileTypesResponse = {
"extensions": string[];
"mime_types": string[];
};
export type MessageIndexResponse = {
"data": MessageListData[];
"path": string | null;
Expand Down Expand Up @@ -589,7 +602,7 @@ export type ProjectDestroyResponse = {
export type ProjectRotateTokenResponse = {
"data": ProjectData;
"new_token": string;
"message": "API token rotated successfully. Please update your integrations.";
"message": "Project API token rotated successfully. Please update your integrations.";
};
export type ProjectUpdateMembersRequest = UpdateProjectMembersData;
export type ProjectUpdateMembersResponse = {
Expand Down
Loading