ClassSDK v0.2.1

Papier

Generic Papier client with type-safe surfaces. This class can be extended in the generated code with specific project types.

import { Papier } from '@usepapier/client/base';

Declaration #

base.tsTypeScript
export class Papier<TProjects extends ProjectTemplates = ProjectTemplates, P extends keyof TProjects = keyof TProjects, TPayloadMap extends Record<string, any> = Record<string, any>> extends BasePapier<TProjects, P> {
    emails: EmailSurface<TProjects[P]["templates"], TPayloadMap>;
    sms: SmsSurface<TProjects[P]["templates"], TPayloadMap>;
    documents: DocumentSurface<TProjects[P]["templates"], TPayloadMap>;
    notifications: NotificationSurface<TProjects[P]["templates"], TPayloadMap>;
    constructor(options: PapierOptions & {
        project: P & string;
    }, projects: TProjects);
    send(payload: BuiltPayload<VariablesRoot>): Promise<{
        success: true;
        adapter: string;
        id?: string;
    }>;
}

Source: packages/client/src/core/base.ts:157

Members 7

constructor(options: PapierOptions & {
    project: P & string;
}, projects: TProjects);

Parameters

options
PapierOptions & { project: P & string }
projects
TProjects

packages/client/src/core/base.ts:168

emails: EmailSurface<TProjects[P]["templates"], TPayloadMap>;

packages/client/src/core/base.ts:163

sms: SmsSurface<TProjects[P]["templates"], TPayloadMap>;

packages/client/src/core/base.ts:164

documents: DocumentSurface<TProjects[P]["templates"], TPayloadMap>;

packages/client/src/core/base.ts:165

notifications: NotificationSurface<TProjects[P]["templates"], TPayloadMap>;

packages/client/src/core/base.ts:166

Send a previously built payload (outbox pattern).

send(payload: BuiltPayload<VariablesRoot>): Promise<{
    success: true;
    adapter: string;
    id?: string;
}>;

Parameters

payload
BuiltPayload<VariablesRoot>
Example from sourceTypeScript
// Build and store
const payload = await papier.emails["welcome"].build({ to: "user@example.com", data: {...} });
await db.outbox.insert(payload);

// Later, retrieve and send
const payload = await db.outbox.findOne();
await papier.send(payload);

packages/client/src/core/base.ts:202

projectName

From BasePapier
get projectName(): P & string;

packages/client/src/core/base.ts:148

Generated from TypeScript source.d65ea8f71fbf