@devx-commerce/loyaltyx-core
v0.2.1
Published
Shared types, zod schemas, and utilities for the LoyaltyX loyalty engine.
Maintainers
Keywords
Readme
@devx-commerce/loyaltyx-core
Shared types, zod schemas, enums, and utility functions for the LoyaltyX loyalty engine.
This package is the foundation for @devx-commerce/loyaltyx-api-client and @devx-commerce/loyaltyx-hooks. You usually don't install it directly — install one of those instead — but it's published separately so you can import its types and validators if you build integrations against the LoyaltyX API yourself.
Install
pnpm add @devx-commerce/loyaltyx-core
# or
npm install @devx-commerce/loyaltyx-corezod is a peer dependency:
pnpm add zodWhat's inside
Zod schemas + inferred TypeScript types
Validate API request/response shapes at runtime. Each schema exports a companion z.infer type:
import { CustomerSchema, type Customer } from '@devx-commerce/loyaltyx-core';
const result = CustomerSchema.safeParse(payload);
if (result.success) {
const customer: Customer = result.data;
}Schemas: TierSchema, EarningRuleSchema, SpendingRuleSchema, CustomerSchema, TransactionSchema, GlobalConfigSchema, AdminUserSchema, ImportJobSchema, ExportJobSchema, ShopifyConfigSchema, NectorConfigSchema, plus the corresponding Create*Body / Update*Body request shapes.
Enums
TransactionType, TransactionStatus, EventType, BenefitType, RuleType, PaymentMode, SalesChannel, SpendingType, OrderStatus, ImportJobStatus, ExportJobStatus.
Utilities
import { formatCurrency, normalizePhone } from '@devx-commerce/loyaltyx-core';
formatCurrency(1299.5); // "₹1,299.50"
formatCurrency(99, 'USD'); // "$99.00"
normalizePhone('8058677244', 'IN'); // "+918058677244"
normalizePhone('+91 80586 77244'); // "+918058677244"normalizePhone defaults to E.164 format and falls back to the supplied country code when no + prefix is present.
Sibling packages
| Package | Purpose |
| -------------------------------------------------------------------------------------------------------- | -------------------------------------- |
| @devx-commerce/loyaltyx-api-client | Typed HTTP client for the LoyaltyX API |
| @devx-commerce/loyaltyx-hooks | React Query hooks |
| @devx-commerce/loyaltyx-ui-kit | React component library |
License
Apache-2.0 — see LICENSE.
