@cresium/cleric-client
v0.3.6
Published
Shared external API clients for Cresium services
Readme
@cresium/cleric-client
Shared external API clients for Cresium services.
Installation
yarn add @cresium/cleric-client
# or
npm install @cresium/cleric-clientAvailable Clients
| Client | Description |
| ------ | ----------- |
| BardClient | Bard ingest / onboarding sync / outbound webhook |
| TwilioClient | WhatsApp verification & messaging |
| ComplifClient | Compliance API with OAuth2 |
| SlackClient | Slack notifications via Incoming Webhooks |
| AfipClient | AFIP taxpayer lookup (Argentina) |
All clients extend ExternalAPIClient (axios-based, auth headers, error handling) and receive their config via constructor — they do NOT read env vars directly. The consumer app reads env and injects.
Bard Client
Client for the Bard API — receives ingest events, onboarding syncs, and outbound webhooks from Mage / Knight.
import { BardClient } from "@cresium/cleric-client";
const bardClient = new BardClient({
baseUrl: "https://bard.cresium.com",
apiKey: "your-bard-api-key",
});
// Ingest a lead (from Mage / marketing forms)
await bardClient.ingestLead({
contact: {
email: "[email protected]",
firstName: "John",
lastName: "Doe",
},
company: {
name: "Acme Inc",
industry: "Fintech",
size: "11-50",
},
meta: {
formType: "demo_request",
timestamp: new Date().toISOString(),
},
});
// Sync a registration (from Knight onboarding — when registration completes)
await bardClient.syncRegistration(registrationId);
// Sync an activation (from Mage / Knight — when company is activated, e.g. CVU active)
// companyId = Registration.externalId in Knight
await bardClient.syncActivation(companyId);
// Process an outbound webhook (from Bison outbound campaigns)
await bardClient.processOutboundWebhook({
event: { type: "reply_received" },
data: {
lead: { id: 1, email: "[email protected]" },
campaign: { id: 42, name: "Q1 Outbound" },
},
});Twilio Client
Client for Twilio API with support for:
- WhatsApp verification codes
- Message sending
- Media downloads
import { TwilioClient } from "@cresium/cleric-client";
const twilioClient = new TwilioClient({
baseUrl: "https://verify.twilio.com",
messagingBaseUrl: "https://api.twilio.com",
authUsername: "your-account-sid",
authPassword: "your-auth-token",
verificationId: "your-verification-service-id",
whatsappFrom: "+1234567890",
});
// Send verification code
await twilioClient.sendCode("+1234567890");
// Verify code
const isValid = await twilioClient.verifyCode("+1234567890", "123456");
// Send WhatsApp message
await twilioClient.sendMessage("+1234567890", "Hello!");
// Download media from Twilio
const buffer = await twilioClient.getFromUrl("https://api.twilio.com/media/...");Complif Client
Client for Complif API with support for:
- OAuth2 automatic authentication (token cached + refreshed)
- Account creation
- Transaction management
import {
ComplifClient,
ComplifAccountType,
ComplifAccountStatus,
ComplifTransactionType,
ComplifPersonType,
ComplifOwnerStatus,
} from "@cresium/cleric-client";
const complifClient = new ComplifClient({
baseUrl: "https://api.complif.io",
clientId: "your-client-id",
clientSecret: "your-client-secret",
});
// Create account
await complifClient.createAccount({
type: ComplifAccountType.COMITENTE_AR,
status: ComplifAccountStatus.OPENING,
name: "John Doe",
external_code: 12345,
alias: "john_doe_account",
owners: [
{
type: ComplifPersonType.HUMAN,
status: ComplifOwnerStatus.PENDING,
// ... more fields
},
],
});
// Create transaction
await complifClient.createTransaction({
type: ComplifTransactionType.CASH_IN,
account_external_code: 12345,
created_at: new Date().toISOString(),
external_code: 67890,
amount: "1000.00",
currency: "ARS",
});Slack Client
Client for sending Slack notifications via Incoming Webhooks. Routes are configured per-key so the consumer can define channels (alerts, onboarding, billing, etc.) and reference them by name.
import { SlackClient } from "@cresium/cleric-client";
const slackClient = new SlackClient({
baseUrl: "https://hooks.slack.com",
routes: {
alerts: "/services/T000/B000/XXXX",
onboarding: "/services/T000/B111/YYYY",
},
enabled: true, // optional — set false to no-op all notifications (useful in dev/tests)
});
await slackClient.sendNotification("alerts", {
text: "New incident",
blocks: [
{
type: "section",
text: { type: "mrkdwn", text: "*Prod API is down*" },
},
],
});AFIP Client
Client for AFIP (Argentina tax authority) taxpayer lookup. Wraps @afipsdk/afip.js.
import { AfipClient } from "@cresium/cleric-client";
const afipClient = new AfipClient({
cuit: "20123456789",
cert: "-----BEGIN CERTIFICATE-----...",
key: "-----BEGIN PRIVATE KEY-----...",
production: true,
accessToken: "your-afipsdk-access-token",
});
const taxpayer = await afipClient.getTaxpayerDetails("30999999990");
// -> { nombre, apellido, tipoPersona, domicilio[], ... }Base Classes & Utilities
ExternalAPIClient
Base class for building external API clients with built-in:
- Axios integration
- Error handling and logging
- Request/response interceptors
- Auth headers management via overridable
getAuthHeaders()
import { ExternalAPIClient, CLIENT_NAMES } from "@cresium/cleric-client";
class MyClient extends ExternalAPIClient {
constructor() {
super("https://api.example.com", "MY_CLIENT");
}
protected async getAuthHeaders() {
return { Authorization: `Bearer ${this.token}` };
}
async getData() {
return this.get("/endpoint");
}
}CLIENT_NAMES
String-constant map of known client names (used as the second arg of super()). Use this instead of hardcoding strings when extending ExternalAPIClient:
import { CLIENT_NAMES } from "@cresium/cleric-client";
super(config.baseUrl, CLIENT_NAMES.BARD);Exposed keys: AFIP, BARD, COMPLIF, SLACK, TWILIO.
BaseConfig
Every client config extends this:
export interface BaseConfig {
baseUrl: string;
}Publishing
Quick Release
cd /path/to/cleric/packages/clients
# 1. Build and verify (prepublishOnly runs this automatically)
yarn build
yarn typecheck
# 2. Bump version
npm version patch # 0.3.5 -> 0.3.6 (bug fixes)
npm version minor # 0.3.5 -> 0.4.0 (new features)
npm version major # 0.3.5 -> 1.0.0 (breaking changes)
# 3. Publish
npm publish
# 4. Push tags to git
git push && git push --tagsPre-publish Checklist
# Verify what will be published
npm pack --dry-run
# Should show:
# - dist/
# - README.md
# - package.jsonLicense
MIT
