UNPKG

ai-sync

Version:

AI-native sync infrastructure SDK - Your code gains conversational intelligence

85 lines 2.68 kB
/** * @syncapis/sdk - AI-Native Sync Infrastructure * * Make your code conversational. Your applications gain native sync intelligence. * * @example * ```typescript * import { SyncClient } from '@syncapis/sdk'; * * const sync = new SyncClient({ * apiKey: 'your-api-key', * tenantId: 'your-tenant-id' * }); * * // Your code understands natural language * const config = await sync.ai("sync stripe customers to hubspot"); * * // Your runtime gains sync capabilities * const link = await sync.createLink(config.syncConfig); * * // Your infrastructure reports on itself * link.on('sync:success', (data) => { * console.log('Your code synced:', data.entityId); * }); * ``` */ export { SyncClient } from './SyncClient.js'; // Import the class for use in functions import { SyncClient } from './SyncClient.js'; /** * Quick start helper - Create a sync client with minimal configuration */ export function createSyncClient(apiKey, tenantId) { return new SyncClient({ apiKey, tenantId: tenantId || 'default_tenant', environment: process.env.NODE_ENV === 'production' ? 'production' : 'sandbox' }); } /** * Common sync patterns for instant setup * Universal architecture - supports any source/target combination */ export const SyncTemplates = { /** * Bidirectional sync between any two systems */ bidirectional: (sourceType, targetType, tenantId) => ({ source: { type: sourceType, tenantId }, target: { type: targetType, tenantId }, entity: 'customer', bidirectional: true, conflictStrategy: 'field-level-merge', options: { fieldMappings: { 'email': { sourceField: 'email', targetField: 'email', conflictResolution: 'prefer-source' }, 'name': { sourceField: 'name', targetField: 'name', conflictResolution: 'last-write-wins' } } } }), /** * Unidirectional sync (source -> target only) */ unidirectional: (sourceType, targetType, tenantId) => ({ source: { type: sourceType, tenantId }, target: { type: targetType, tenantId }, entity: 'customer', bidirectional: false, conflictStrategy: 'prefer-source' }), /** * Common patterns - backwards compatibility */ stripeToHubSpot: (tenantId) => SyncTemplates.bidirectional('stripe', 'hubspot', tenantId), billingSync: (tenantId) => SyncTemplates.unidirectional('stripe', 'hubspot', tenantId) }; /** * Version information */ export const version = '1.0.0'; /** * Default export for convenience */ export default SyncClient; //# sourceMappingURL=index.js.map