constructor(options: PapierOptions & {
project: P & string;
}, projects: TProjects);Parameters
optionsPapierOptions & { project: P & string }projectsTProjects
packages/client/src/core/base.ts:168
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';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
constructor(options: PapierOptions & {
project: P & string;
}, projects: TProjects);optionsPapierOptions & { project: P & string }projectsTProjectspackages/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;
}>;payloadBuiltPayload<VariablesRoot>// 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
get projectName(): P & string;packages/client/src/core/base.ts:148
d65ea8f71fbf