@perkamo/sdk-core
v0.8.0
Published
Runtime-independent types and security helpers for Perkamo SDKs.
Readme
@perkamo/sdk-core
Runtime-independent event types, response types, and helpers for Perkamo SDKs.
Use this package for shared TypeScript types and input helpers. Most
integrations should install @perkamo/sdk, which re-exports these utilities and
adds the API client.
Full SDK documentation: https://www.perkamo.com/docs/v1/sdk
npm install @perkamo/sdk-coreExports
Types
PerkamoContextValue/PerkamoEventContext/PerkamoEventInputPerkamoCustomerTraitValue/PerkamoCustomerTraits/PerkamoIdentifyInputEventIngestResponse/BatchIngestResponsePerkamoCustomer/PerkamoLevel/PerkamoUnlockedPerk/PerkamoCustomerFlagsPerkamoProgram/PerkamoProgramBlueprint/PerkamoProgramEventIdentifyResponse/RedeemRewardResponsePerkamoApiError— error class withstatus,body,requestId,retryAfterandrateLimitmetadata
Helpers
assertSafeEventInput(input)— validates fields and rejects server-authoritative context keyscreateTransactionId(prefix?)— generates atx_<uuid>idempotency keycanonicalJson(value)— deterministic JSON for comparison and logging
Example
import { assertSafeEventInput, createTransactionId } from "@perkamo/sdk-core";
const input = {
user_id: "customer_123",
event: "purchase.completed",
transaction_id: createTransactionId(),
context: { order_id: "order_1092" },
occurred_at: new Date().toISOString(),
};
assertSafeEventInput(input);Program earning rule rewards may expose a fixed amount or a safe arithmetic
formula such as {{product_price}} * 10. Formula inputs come from event
context and are evaluated server-side by Perkamo.
