@almadar/integrations 2.25.0 → 2.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{BaseIntegration-MA-b4fh8.d.ts → BaseIntegration-C_5q54DM.d.ts} +64 -3
- package/dist/index.d.ts +127 -19
- package/dist/index.js +505 -198
- package/dist/index.js.map +1 -1
- package/dist/integrations/github/index.d.ts +1 -1
- package/dist/integrations/github/index.js +11 -0
- package/dist/integrations/github/index.js.map +1 -1
- package/dist/mocks/index.d.ts +1 -2
- package/dist/mocks/index.js +12 -1
- package/dist/mocks/index.js.map +1 -1
- package/dist/runtime/index.d.ts +14 -4
- package/dist/runtime/index.js +379 -193
- package/dist/runtime/index.js.map +1 -1
- package/dist/{store-CW1v7Apc.d.ts → store-tehIm2rt.d.ts} +68 -4
- package/package.json +2 -2
- package/dist/factory-BPVhvv5q.d.ts +0 -59
package/dist/mocks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/logger.ts","../../src/core/validation.ts","../../src/core/retry.ts","../../src/core/BaseIntegration.ts","../../src/types.ts","../../src/mocks/MockIntegration.ts","../../src/registry.ts","../../src/factory.ts","../../src/mocks/MockIntegrationFactory.ts"],"names":[],"mappings":";;;;AAeO,IAAM,gBAAN,MAAiD;AAAA,EAGtD,WAAA,CAAY,SAA8C,MAAA,EAAQ;AAEhE,IAAA,IAAA,CAAK,GAAA,GAAM,aAAa,sBAAsB,CAAA;AAAA,EAChD;AAAA,EAEA,KAAA,CAAM,SAAiB,IAAA,EAAsB;AAC3C,IAAA,IAAA,CAAK,GAAA,CAAI,KAAA,CAAM,OAAA,EAAS,IAAI,CAAA;AAAA,EAC9B;AAAA,EACA,IAAA,CAAK,SAAiB,IAAA,EAAsB;AAC1C,IAAA,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,EAAS,IAAI,CAAA;AAAA,EAC7B;AAAA,EACA,IAAA,CAAK,S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/logger';\nimport type { IntegrationLogger, LogMeta } from '../types';\n\n/**\n * Console-based logger implementation.\n *\n * Routes through `@almadar/logger`'s shared gate so namespace filtering\n * (`ALMADAR_DEBUG`, `globalThis.__ALMADAR_DEBUG__`) and the production\n * level default (WARN+) apply uniformly with the rest of `@almadar/*`.\n *\n * The constructor's `level` argument is retained for backwards\n * compatibility but is now a no-op — the active level is owned by the\n * shared logger (compile-time + env). To filter integration logs at\n * runtime, set `globalThis.__ALMADAR_DEBUG__ = 'almadar:integrations:*'`.\n */\nexport class ConsoleLogger implements IntegrationLogger {\n private readonly log: Logger;\n\n constructor(_level: 'debug' | 'info' | 'warn' | 'error' = 'info') {\n void _level;\n this.log = createLogger('almadar:integrations');\n }\n\n debug(message: string, meta?: LogMeta): void {\n this.log.debug(message, meta);\n }\n info(message: string, meta?: LogMeta): void {\n this.log.info(message, meta);\n }\n warn(message: string, meta?: LogMeta): void {\n this.log.warn(message, meta);\n }\n error(message: string, meta?: LogMeta): void {\n this.log.error(message, meta);\n }\n}\n","import type { ValidationResult, ValidationError, IntegrationParams } from '../types';\n\n// Import integrators registry from the package main export (JSON is inlined in the bundle)\nimport { integratorsRegistry } from '@almadar/core/patterns';\n\ninterface ActionParam {\n name: string;\n type: string;\n required?: boolean;\n description?: string;\n}\n\ninterface ActionDef {\n name: string;\n description?: string;\n params: ActionParam[];\n}\n\ninterface IntegratorEntry {\n name: string;\n description?: string;\n category?: string;\n actions: ActionDef[];\n}\n\ntype IntegratorsRegistry = Record<string, {\n version?: string;\n exportedAt?: string;\n integrators: Record<string, IntegratorEntry>;\n}>;\n\n/**\n * Validate action params against registry schema\n */\nexport function validateParams(\n integration: string,\n action: string,\n params: IntegrationParams,\n): ValidationResult {\n const typedRegistry = integratorsRegistry as IntegratorsRegistry[string];\n const registry = typedRegistry.integrators[integration];\n\n if (!registry) {\n return {\n valid: false,\n errors: [\n {\n param: 'integration',\n message: `Unknown integration: ${integration}`,\n },\n ],\n };\n }\n\n const actionDef = registry.actions.find((a: ActionDef) => a.name === action);\n\n if (!actionDef) {\n return {\n valid: false,\n errors: [{ param: 'action', message: `Unknown action: ${action}` }],\n };\n }\n\n const errors: ValidationError[] = [];\n\n // Check required params\n for (const paramDef of actionDef.params) {\n if (paramDef.required && !(paramDef.name in params)) {\n errors.push({\n param: paramDef.name,\n message: `Missing required parameter: ${paramDef.name}`,\n });\n }\n\n // Type validation\n if (paramDef.name in params) {\n const value = params[paramDef.name];\n const expectedType = paramDef.type;\n const actualType = typeof value;\n\n if (expectedType === 'number' && actualType !== 'number') {\n errors.push({\n param: paramDef.name,\n message: `Expected ${expectedType}, got ${actualType}`,\n });\n }\n\n if (expectedType === 'string' && actualType !== 'string') {\n errors.push({\n param: paramDef.name,\n message: `Expected ${expectedType}, got ${actualType}`,\n });\n }\n\n if (expectedType === 'array' && !Array.isArray(value)) {\n errors.push({\n param: paramDef.name,\n message: `Expected array, got ${actualType}`,\n });\n }\n\n if (\n expectedType === 'object' &&\n (actualType !== 'object' || Array.isArray(value) || value === null)\n ) {\n errors.push({\n param: paramDef.name,\n message: `Expected object, got ${actualType}`,\n });\n }\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n };\n}\n","import type { IntegrationError, IntegrationErrorCode } from '../types';\n\n/**\n * Retry configuration\n */\nexport interface RetryConfig {\n maxAttempts: number;\n backoffMs: number;\n maxBackoffMs?: number;\n retryableErrors?: IntegrationErrorCode[];\n}\n\n/**\n * Execute a function with retry logic\n */\nexport async function withRetry<T>(\n fn: () => Promise<T>,\n config: RetryConfig,\n): Promise<T> {\n const {\n maxAttempts,\n backoffMs,\n maxBackoffMs = 30000,\n retryableErrors,\n } = config;\n\n let lastError: unknown;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error;\n\n // Check if error is retryable\n if (\n error &&\n typeof error === 'object' &&\n 'code' in error &&\n retryableErrors\n ) {\n const integrationError = error as IntegrationError;\n if (!retryableErrors.includes(integrationError.code)) {\n throw error;\n }\n }\n\n // Last attempt, throw\n if (attempt === maxAttempts) {\n throw error;\n }\n\n // Wait before retry (exponential backoff)\n const delay = Math.min(\n backoffMs * Math.pow(2, attempt - 1),\n maxBackoffMs,\n );\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n }\n\n throw lastError;\n}\n","import type {\n IntegrationConfig,\n IntegrationResult,\n IntegrationLogger,\n IntegrationError,\n IntegrationParams,\n} from '../types';\nimport { ConsoleLogger } from './logger';\nimport { validateParams } from './validation';\nimport { withRetry } from './retry';\n\n/**\n * Base class for all integrations\n */\nexport abstract class BaseIntegration {\n protected config: IntegrationConfig;\n protected logger: IntegrationLogger;\n\n constructor(config: IntegrationConfig) {\n this.config = config;\n this.logger = config.logger || new ConsoleLogger();\n }\n\n /**\n * Execute an action\n */\n abstract execute(\n action: string,\n params: IntegrationParams,\n ): Promise<IntegrationResult>;\n\n /**\n * Validate action params against registry\n */\n protected validateParams(\n action: string,\n params: IntegrationParams,\n ): ReturnType<typeof validateParams> {\n return validateParams(this.config.name, action, params);\n }\n\n /**\n * Handle errors uniformly\n */\n protected handleError(action: string, error: unknown): IntegrationResult {\n this.logger.error(`Integration error in ${this.config.name}.${action}`, {\n error: error instanceof Error ? error : new Error(String(error)),\n });\n\n const integrationError =\n error instanceof Error\n ? error\n : new Error(String(error));\n\n return {\n success: false,\n error: integrationError as IntegrationError,\n metadata: this.createMetadata(action, 0, 0),\n };\n }\n\n /**\n * Create metadata for result\n */\n protected createMetadata(\n action: string,\n duration: number,\n retries: number = 0,\n ): IntegrationResult['metadata'] {\n return {\n integration: this.config.name,\n action,\n duration,\n retries,\n timestamp: Date.now(),\n };\n }\n\n /**\n * Execute with retry logic\n */\n protected async executeWithRetry<T>(\n fn: () => Promise<T>,\n ): Promise<T> {\n if (!this.config.retry) {\n return fn();\n }\n\n return withRetry(fn, {\n maxAttempts: this.config.retry.maxAttempts,\n backoffMs: this.config.retry.backoffMs,\n maxBackoffMs: this.config.retry.maxBackoffMs,\n retryableErrors: [\n 'TIMEOUT_ERROR',\n 'NETWORK_ERROR',\n 'RATE_LIMIT_ERROR',\n ],\n });\n }\n}\n","/**\n * Core types for Almadar integrations\n */\n\n/**\n * Configuration for an integration instance\n */\nexport interface IntegrationConfig {\n /** Integration name (matches registry) */\n name: string;\n\n /** Environment variables (API keys, secrets) */\n env: Record<string, string>;\n\n /** Optional logger */\n logger?: IntegrationLogger;\n\n /** Optional rate limiting config */\n rateLimit?: {\n requestsPerSecond: number;\n burstSize: number;\n };\n\n /** Optional timeout (ms) */\n timeout?: number;\n\n /** Optional retry config */\n retry?: {\n maxAttempts: number;\n backoffMs: number;\n maxBackoffMs?: number;\n };\n}\n\n/**\n * Result of an integration action call\n */\nexport interface IntegrationResult<T = unknown> {\n /** Success flag */\n success: boolean;\n\n /** Response data (on success) */\n data?: T;\n\n /** Error (on failure) */\n error?: IntegrationError;\n\n /** Metadata (timing, retries, etc.) */\n metadata: {\n integration: string;\n action: string;\n duration: number;\n retries: number;\n timestamp: number;\n };\n}\n\n/**\n * Integration error codes\n */\nexport type IntegrationErrorCode =\n | 'VALIDATION_ERROR'\n | 'AUTH_ERROR'\n | 'RATE_LIMIT_ERROR'\n | 'TIMEOUT_ERROR'\n | 'NETWORK_ERROR'\n | 'SERVICE_ERROR'\n | 'UNKNOWN_ERROR';\n\n/**\n * Integration error\n */\nexport class IntegrationError extends Error {\n code: IntegrationErrorCode;\n integration?: string;\n action?: string;\n details?: unknown;\n\n constructor(\n message: string,\n code: IntegrationErrorCode = 'UNKNOWN_ERROR',\n details?: unknown,\n ) {\n super(message);\n this.name = 'IntegrationError';\n this.code = code;\n this.details = details;\n }\n\n toJSON() {\n return {\n name: this.name,\n message: this.message,\n code: this.code,\n integration: this.integration,\n action: this.action,\n details: this.details,\n };\n }\n}\n\nimport type { LogMeta } from '@almadar/core';\n\n/** Re-export LogMeta from @almadar/core as the canonical log metadata type. */\nexport type { LogMeta };\n\n/**\n * Logger interface\n */\nexport interface IntegrationLogger {\n debug(message: string, meta?: LogMeta): void;\n info(message: string, meta?: LogMeta): void;\n warn(message: string, meta?: LogMeta): void;\n error(message: string, meta?: LogMeta): void;\n}\n\n/**\n * Integration action parameters.\n * Each integration's execute() method receives params as this type.\n * Individual methods cast to specific param shapes from their contracts.\n *\n * Per-key value union is widened to admit `@almadar/core`'s `FieldValue`\n * shape (entity / payload values flowing into call-service args): `Date`\n * for date fields, `IntegrationParams[]` for nested object arrays, and a\n * raw-value array catch-all so `string[]` / `number[]` / mixed payload\n * arrays satisfy the index signature without requiring `as unknown as`\n * casts at the call site. Adapters narrow these to their canonical input\n * types (typically JSON-string serialisation for `Date`).\n */\nexport type IntegrationParamValue =\n | string\n | number\n | boolean\n | Date\n | null\n | undefined\n | ReadonlyArray<IntegrationParamValue>\n | { readonly [key: string]: IntegrationParamValue };\n\nexport interface IntegrationParams {\n [key: string]: IntegrationParamValue;\n}\n\n/**\n * Validation result\n */\nexport interface ValidationResult {\n valid: boolean;\n errors: ValidationError[];\n}\n\n/**\n * Validation error\n */\nexport interface ValidationError {\n param: string;\n message: string;\n}\n","import { BaseIntegration } from '../core/BaseIntegration';\nimport type { IntegrationConfig, IntegrationResult, IntegrationParams } from '../types';\nimport { IntegrationError } from '../types';\n\n/**\n * Mock integration for testing\n */\nexport class MockIntegration extends BaseIntegration {\n private responses: Map<string, unknown> = new Map();\n private calls: Array<{ action: string; params: IntegrationParams }> =\n [];\n\n constructor(config: IntegrationConfig) {\n super(config);\n }\n\n /**\n * Set mock response for an action\n */\n setResponse(action: string, data: unknown): void {\n this.responses.set(action, data);\n }\n\n /**\n * Get all calls made to this integration\n */\n getCalls(): Array<{ action: string; params: IntegrationParams }> {\n return this.calls;\n }\n\n /**\n * Clear all calls\n */\n clearCalls(): void {\n this.calls = [];\n }\n\n async execute(\n action: string,\n params: IntegrationParams,\n ): Promise<IntegrationResult> {\n // Record the call\n this.calls.push({ action, params });\n\n const data = this.responses.get(action);\n\n if (!data) {\n return {\n success: false,\n error: new IntegrationError(\n `No mock response for action: ${action}`,\n 'UNKNOWN_ERROR',\n ),\n metadata: this.createMetadata(action, 0),\n };\n }\n\n return {\n success: true,\n data,\n metadata: this.createMetadata(action, 0),\n };\n }\n}\n","import type { IntegrationConfig } from './types';\nimport { BaseIntegration } from './core/BaseIntegration';\n\n/**\n * Integration constructor type\n */\nexport type IntegrationConstructor = new (\n config: IntegrationConfig,\n) => BaseIntegration;\n\n/**\n * Integration registry (populated as integrations are imported)\n */\nexport const INTEGRATION_REGISTRY: Record<string, IntegrationConstructor> = {};\n\n/**\n * Register an integration\n */\nexport function registerIntegration(\n name: string,\n constructor: IntegrationConstructor,\n): void {\n INTEGRATION_REGISTRY[name] = constructor;\n}\n\n/**\n * Get integration constructor by name\n */\nexport function getIntegration(\n name: string,\n): IntegrationConstructor | undefined {\n return INTEGRATION_REGISTRY[name];\n}\n\n/**\n * Check if integration is known\n */\nexport function isKnownIntegration(name: string): boolean {\n return name in INTEGRATION_REGISTRY;\n}\n\n/**\n * Get all registered integration names\n */\nexport function getRegisteredIntegrations(): string[] {\n return Object.keys(INTEGRATION_REGISTRY);\n}\n","import type { IntegrationConfig, IntegrationResult, IntegrationParams } from './types';\nimport { BaseIntegration } from './core/BaseIntegration';\nimport { getIntegration } from './registry';\n\n/**\n * Optional per-call context for principal-scoped resolution (W4). The\n * default — absent — means the tenant/app-wide credential set; a `principal`\n * selects a per-principal configuration when one was registered. Additive:\n * every existing call site is untouched.\n */\nexport interface IntegrationCallContext {\n principal?: string;\n}\n\n/** Cache key for (name, principal?) — NUL never appears in either part. */\nfunction instanceKey(name: string, principal?: string): string {\n return principal ? `${name}\\u0000${principal}` : name;\n}\n\n/**\n * Factory for creating and managing integration instances\n */\nexport class IntegrationFactory {\n private instances: Map<string, BaseIntegration> = new Map();\n private configs: Map<string, IntegrationConfig> = new Map();\n\n /**\n * Configure an integration (doesn't instantiate yet). A `principal` scopes\n * the config to that principal; the app-wide config (no principal) is the\n * fallback for every principal.\n */\n configure(name: string, config: Omit<IntegrationConfig, 'name'>, principal?: string): void {\n this.configs.set(instanceKey(name, principal), { name, ...config });\n }\n\n /**\n * Get or create an integration instance. Principal-scoped lookups fall\n * back to the app-wide config when no per-principal config exists.\n */\n get(name: string, principal?: string): BaseIntegration {\n const key = instanceKey(name, principal);\n const cached = this.instances.get(key);\n if (cached) {\n return cached;\n }\n\n // Get constructor\n const Constructor = getIntegration(name);\n if (!Constructor) {\n throw new Error(`Unknown integration: ${name}. Make sure it's imported.`);\n }\n\n // Get config — per-principal first, app-wide fallback\n const config = this.configs.get(key) ?? this.configs.get(name);\n if (!config) {\n throw new Error(\n `Integration not configured: ${name}. Call configure() first.`,\n );\n }\n\n // Create instance\n const instance = new Constructor(config);\n this.instances.set(key, instance);\n\n return instance;\n }\n\n /**\n * Execute an action on an integration\n */\n async execute(\n integration: string,\n action: string,\n params: IntegrationParams,\n context?: IntegrationCallContext,\n ): Promise<IntegrationResult> {\n const instance = this.get(integration, context?.principal);\n return await instance.execute(action, params);\n }\n\n /**\n * Check if integration is configured\n */\n isConfigured(name: string, principal?: string): boolean {\n return this.configs.has(instanceKey(name, principal)) || this.configs.has(name);\n }\n\n /**\n * Register an integration instance directly (used by mock infrastructure)\n */\n registerInstance(name: string, instance: BaseIntegration, principal?: string): void {\n this.instances.set(instanceKey(name, principal), instance);\n }\n\n /**\n * Drop the cached instance(s) for a name so the next `get` rebuilds from\n * the current config — how a credential change goes live without restart.\n * Configs are kept; without a name, every instance is dropped.\n */\n invalidate(name?: string): void {\n if (name === undefined) {\n this.instances.clear();\n return;\n }\n for (const key of this.instances.keys()) {\n if (key === name || key.startsWith(`${name}\\u0000`)) {\n this.instances.delete(key);\n }\n }\n }\n\n /**\n * Clear all instances (useful for testing)\n */\n clear(): void {\n this.instances.clear();\n }\n\n /**\n * Clear all instances and configs\n */\n reset(): void {\n this.instances.clear();\n this.configs.clear();\n }\n}\n\nlet _factory: IntegrationFactory | null = null;\n\nexport function getIntegrationFactory(): IntegrationFactory {\n if (!_factory) {\n _factory = new IntegrationFactory();\n }\n return _factory;\n}\n\nexport function resetIntegrationFactory(): void {\n _factory?.reset();\n _factory = null;\n}\n","import { IntegrationFactory } from '../factory';\nimport { MockIntegration } from './MockIntegration';\nimport { registerIntegration } from '../registry';\nimport type { IntegrationParams } from '../types';\n\n/**\n * Mock integration factory for testing\n */\nexport class MockIntegrationFactory extends IntegrationFactory {\n constructor() {\n super();\n \n // Register mock integration for all known services\n const services = ['stripe', 'youtube', 'twilio', 'email', 'llm', 'deepagent'];\n services.forEach((service) => {\n registerIntegration(`mock-${service}`, MockIntegration);\n \n // Configure with mock config\n this.configure(service, {\n env: {},\n });\n });\n }\n\n /**\n * Set mock response for an integration action\n */\n setMockResponse(integration: string, action: string, data: unknown): void {\n const instance = this.get(integration) as MockIntegration;\n instance.setResponse(action, data);\n }\n\n /**\n * Get calls made to an integration\n */\n getMockCalls(\n integration: string,\n ): Array<{ action: string; params: IntegrationParams }> {\n const instance = this.get(integration) as MockIntegration;\n return instance.getCalls();\n }\n\n /**\n * Clear calls for an integration\n */\n clearMockCalls(integration: string): void {\n const instance = this.get(integration) as MockIntegration;\n instance.clearCalls();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/core/logger.ts","../../src/core/validation.ts","../../src/core/retry.ts","../../src/core/BaseIntegration.ts","../../src/types.ts","../../src/mocks/MockIntegration.ts","../../src/registry.ts","../../src/factory.ts","../../src/mocks/MockIntegrationFactory.ts"],"names":[],"mappings":";;;;AAeO,IAAM,gBAAN,MAAiD;AAAA,EAGtD,WAAA,CAAY,SAA8C,MAAA,EAAQ;AAEhE,IAAA,IAAA,CAAK,GAAA,GAAM,aAAa,sBAAsB,CAAA;AAAA,EAChD;AAAA,EAEA,KAAA,CAAM,SAAiB,IAAA,EAAsB;AAC3C,IAAA,IAAA,CAAK,GAAA,CAAI,KAAA,CAAM,OAAA,EAAS,IAAI,CAAA;AAAA,EAC9B;AAAA,EACA,IAAA,CAAK,SAAiB,I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,CAAS,OAAA,CAAQ,CAAC,OAAA,KAAY;AAC5B,MAAA,mBAAA,CAAoB,CAAA,KAAA,EAAQ,OAAO,CAAA,CAAA,EAAI,eAAe,CAAA;AAGtD,MAAA,IAAA,CAAK,UAAU,OAAA,EAAS;AAAA,QACtB,KAAK;AAAC,OACP,CAAA;AAAA,IACH,CAAC,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,eAAA,CAAgB,WAAA,EAAqB,MAAA,EAAgB,IAAA,EAAqB;AACxE,IAAA,MAAM,QAAA,GAAW,IAAA,CAAK,GAAA,CAAI,WAAW,CAAA;AACrC,IAAA,QAAA,CAAS,WAAA,CAAY,QAAQ,IAAI,CAAA;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA,EAKA,aACE,WAAA,EACsD;AACtD,IAAA,MAAM,QAAA,GAAW,IAAA,CAAK,GAAA,CAAI,WAAW,CAAA;AACrC,IAAA,OAAO,SAAS,QAAA,EAAS;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA,EAKA,eAAe,WAAA,EAA2B;AACxC,IAAA,MAAM,QAAA,GAAW,IAAA,CAAK,GAAA,CAAI,WAAW,CAAA;AACrC,IAAA,QAAA,CAAS,UAAA,EAAW;AAAA,EACtB;AACF","file":"index.js","sourcesContent":["import { createLogger, type Logger } from '@almadar/logger';\nimport type { IntegrationLogger, LogMeta } from '../types';\n\n/**\n * Console-based logger implementation.\n *\n * Routes through `@almadar/logger`'s shared gate so namespace filtering\n * (`ALMADAR_DEBUG`, `globalThis.__ALMADAR_DEBUG__`) and the production\n * level default (WARN+) apply uniformly with the rest of `@almadar/*`.\n *\n * The constructor's `level` argument is retained for backwards\n * compatibility but is now a no-op — the active level is owned by the\n * shared logger (compile-time + env). To filter integration logs at\n * runtime, set `globalThis.__ALMADAR_DEBUG__ = 'almadar:integrations:*'`.\n */\nexport class ConsoleLogger implements IntegrationLogger {\n private readonly log: Logger;\n\n constructor(_level: 'debug' | 'info' | 'warn' | 'error' = 'info') {\n void _level;\n this.log = createLogger('almadar:integrations');\n }\n\n debug(message: string, meta?: LogMeta): void {\n this.log.debug(message, meta);\n }\n info(message: string, meta?: LogMeta): void {\n this.log.info(message, meta);\n }\n warn(message: string, meta?: LogMeta): void {\n this.log.warn(message, meta);\n }\n error(message: string, meta?: LogMeta): void {\n this.log.error(message, meta);\n }\n}\n","import type { ValidationResult, ValidationError, IntegrationParams } from '../types';\n\n// Import integrators registry from the package main export (JSON is inlined in the bundle)\nimport { integratorsRegistry } from '@almadar/core/patterns';\n\ninterface ActionParam {\n name: string;\n type: string;\n required?: boolean;\n description?: string;\n}\n\ninterface ActionDef {\n name: string;\n description?: string;\n params: ActionParam[];\n}\n\ninterface IntegratorEntry {\n name: string;\n description?: string;\n category?: string;\n actions: ActionDef[];\n}\n\ntype IntegratorsRegistry = Record<string, {\n version?: string;\n exportedAt?: string;\n integrators: Record<string, IntegratorEntry>;\n}>;\n\n/** Envelope keys owned by the call-service form, never action params. */\nconst RESERVED_ENVELOPE_KEYS = new Set(['emit', 'onSuccess', 'onError', 'timeout']);\n\n/**\n * Validate action params against registry schema\n */\nexport function validateParams(\n integration: string,\n action: string,\n params: IntegrationParams,\n): ValidationResult {\n const typedRegistry = integratorsRegistry as IntegratorsRegistry[string];\n const registry = typedRegistry.integrators[integration];\n\n if (!registry) {\n return {\n valid: false,\n errors: [\n {\n param: 'integration',\n message: `Unknown integration: ${integration}`,\n },\n ],\n };\n }\n\n const actionDef = registry.actions.find((a: ActionDef) => a.name === action);\n\n if (!actionDef) {\n return {\n valid: false,\n errors: [{ param: 'action', message: `Unknown action: ${action}` }],\n };\n }\n\n const errors: ValidationError[] = [];\n\n // Unknown-key check (I-13 runtime parity with orb validate): a param the\n // contract does not declare is an error, not a silent drop. Envelope keys\n // belong to the call-service form itself, never to the action contract.\n const declaredNames = new Set(actionDef.params.map((p: ActionParam) => p.name));\n for (const key of Object.keys(params)) {\n if (RESERVED_ENVELOPE_KEYS.has(key)) continue;\n if (!declaredNames.has(key)) {\n errors.push({\n param: key,\n message: `Unknown parameter: ${key} (declared: ${[...declaredNames].sort().join(', ')})`,\n });\n }\n }\n\n // Check required params\n for (const paramDef of actionDef.params) {\n if (paramDef.required && !(paramDef.name in params)) {\n errors.push({\n param: paramDef.name,\n message: `Missing required parameter: ${paramDef.name}`,\n });\n }\n\n // Type validation\n if (paramDef.name in params) {\n const value = params[paramDef.name];\n const expectedType = paramDef.type;\n const actualType = typeof value;\n\n if (expectedType === 'number' && actualType !== 'number') {\n errors.push({\n param: paramDef.name,\n message: `Expected ${expectedType}, got ${actualType}`,\n });\n }\n\n if (expectedType === 'string' && actualType !== 'string') {\n errors.push({\n param: paramDef.name,\n message: `Expected ${expectedType}, got ${actualType}`,\n });\n }\n\n if (expectedType === 'array' && !Array.isArray(value)) {\n errors.push({\n param: paramDef.name,\n message: `Expected array, got ${actualType}`,\n });\n }\n\n if (\n expectedType === 'object' &&\n (actualType !== 'object' || Array.isArray(value) || value === null)\n ) {\n errors.push({\n param: paramDef.name,\n message: `Expected object, got ${actualType}`,\n });\n }\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n };\n}\n","import type { IntegrationError, IntegrationErrorCode } from '../types';\n\n/**\n * Retry configuration\n */\nexport interface RetryConfig {\n maxAttempts: number;\n backoffMs: number;\n maxBackoffMs?: number;\n retryableErrors?: IntegrationErrorCode[];\n}\n\n/**\n * Execute a function with retry logic\n */\nexport async function withRetry<T>(\n fn: () => Promise<T>,\n config: RetryConfig,\n): Promise<T> {\n const {\n maxAttempts,\n backoffMs,\n maxBackoffMs = 30000,\n retryableErrors,\n } = config;\n\n let lastError: unknown;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error;\n\n // Check if error is retryable\n if (\n error &&\n typeof error === 'object' &&\n 'code' in error &&\n retryableErrors\n ) {\n const integrationError = error as IntegrationError;\n if (!retryableErrors.includes(integrationError.code)) {\n throw error;\n }\n }\n\n // Last attempt, throw\n if (attempt === maxAttempts) {\n throw error;\n }\n\n // Wait before retry (exponential backoff)\n const delay = Math.min(\n backoffMs * Math.pow(2, attempt - 1),\n maxBackoffMs,\n );\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n }\n\n throw lastError;\n}\n","import type {\n IntegrationConfig,\n IntegrationResult,\n IntegrationLogger,\n IntegrationError,\n IntegrationParams,\n} from '../types';\nimport { ConsoleLogger } from './logger';\nimport { validateParams } from './validation';\nimport { withRetry } from './retry';\nimport type { IntegrationCallContext } from '../factory';\n\n/**\n * Base class for all integrations\n */\nexport abstract class BaseIntegration {\n protected config: IntegrationConfig;\n protected logger: IntegrationLogger;\n\n constructor(config: IntegrationConfig) {\n this.config = config;\n this.logger = config.logger || new ConsoleLogger();\n }\n\n /**\n * Execute an action. `context` carries the caller's identity when the host\n * supplies one; integrations that gate actions by role read it and fail\n * closed when it is absent.\n */\n abstract execute(\n action: string,\n params: IntegrationParams,\n context?: IntegrationCallContext,\n ): Promise<IntegrationResult>;\n\n /**\n * Validate action params against registry\n */\n protected validateParams(\n action: string,\n params: IntegrationParams,\n ): ReturnType<typeof validateParams> {\n return validateParams(this.config.name, action, params);\n }\n\n /**\n * Handle errors uniformly\n */\n protected handleError(action: string, error: unknown): IntegrationResult {\n this.logger.error(`Integration error in ${this.config.name}.${action}`, {\n error: error instanceof Error ? error : new Error(String(error)),\n });\n\n const integrationError =\n error instanceof Error\n ? error\n : new Error(String(error));\n\n return {\n success: false,\n error: integrationError as IntegrationError,\n metadata: this.createMetadata(action, 0, 0),\n };\n }\n\n /**\n * Create metadata for result\n */\n protected createMetadata(\n action: string,\n duration: number,\n retries: number = 0,\n ): IntegrationResult['metadata'] {\n return {\n integration: this.config.name,\n action,\n duration,\n retries,\n timestamp: Date.now(),\n };\n }\n\n /**\n * Execute with retry logic\n */\n protected async executeWithRetry<T>(\n fn: () => Promise<T>,\n ): Promise<T> {\n if (!this.config.retry) {\n return fn();\n }\n\n return withRetry(fn, {\n maxAttempts: this.config.retry.maxAttempts,\n backoffMs: this.config.retry.backoffMs,\n maxBackoffMs: this.config.retry.maxBackoffMs,\n retryableErrors: [\n 'TIMEOUT_ERROR',\n 'NETWORK_ERROR',\n 'RATE_LIMIT_ERROR',\n ],\n });\n }\n}\n","/**\n * Core types for Almadar integrations\n */\n\n/**\n * Configuration for an integration instance\n */\nexport interface IntegrationConfig {\n /** Integration name (matches registry) */\n name: string;\n\n /** Environment variables (API keys, secrets) */\n env: Record<string, string>;\n\n /** Optional logger */\n logger?: IntegrationLogger;\n\n /** Optional rate limiting config */\n rateLimit?: {\n requestsPerSecond: number;\n burstSize: number;\n };\n\n /** Optional timeout (ms) */\n timeout?: number;\n\n /** Optional retry config */\n retry?: {\n maxAttempts: number;\n backoffMs: number;\n maxBackoffMs?: number;\n };\n}\n\n/**\n * Result of an integration action call\n */\nexport interface IntegrationResult<T = unknown> {\n /** Success flag */\n success: boolean;\n\n /** Response data (on success) */\n data?: T;\n\n /** Error (on failure) */\n error?: IntegrationError;\n\n /** Metadata (timing, retries, etc.) */\n metadata: {\n integration: string;\n action: string;\n duration: number;\n retries: number;\n timestamp: number;\n };\n}\n\n/**\n * Integration error codes\n */\nexport type IntegrationErrorCode =\n | 'VALIDATION_ERROR'\n | 'AUTH_ERROR'\n | 'RATE_LIMIT_ERROR'\n | 'TIMEOUT_ERROR'\n | 'NETWORK_ERROR'\n | 'SERVICE_ERROR'\n | 'UNKNOWN_ERROR';\n\n/**\n * Integration error\n */\nexport class IntegrationError extends Error {\n code: IntegrationErrorCode;\n integration?: string;\n action?: string;\n details?: unknown;\n\n constructor(\n message: string,\n code: IntegrationErrorCode = 'UNKNOWN_ERROR',\n details?: unknown,\n ) {\n super(message);\n this.name = 'IntegrationError';\n this.code = code;\n this.details = details;\n }\n\n toJSON() {\n return {\n name: this.name,\n message: this.message,\n code: this.code,\n integration: this.integration,\n action: this.action,\n details: this.details,\n };\n }\n}\n\nimport type { LogMeta } from '@almadar/core';\n\n/** Re-export LogMeta from @almadar/core as the canonical log metadata type. */\nexport type { LogMeta };\n\n/**\n * Logger interface\n */\nexport interface IntegrationLogger {\n debug(message: string, meta?: LogMeta): void;\n info(message: string, meta?: LogMeta): void;\n warn(message: string, meta?: LogMeta): void;\n error(message: string, meta?: LogMeta): void;\n}\n\n/**\n * Integration action parameters.\n * Each integration's execute() method receives params as this type.\n * Individual methods cast to specific param shapes from their contracts.\n *\n * Per-key value union is widened to admit `@almadar/core`'s `FieldValue`\n * shape (entity / payload values flowing into call-service args): `Date`\n * for date fields, `IntegrationParams[]` for nested object arrays, and a\n * raw-value array catch-all so `string[]` / `number[]` / mixed payload\n * arrays satisfy the index signature without requiring `as unknown as`\n * casts at the call site. Adapters narrow these to their canonical input\n * types (typically JSON-string serialisation for `Date`).\n */\nexport type IntegrationParamValue =\n | string\n | number\n | boolean\n | Date\n | null\n | undefined\n | ReadonlyArray<IntegrationParamValue>\n | { readonly [key: string]: IntegrationParamValue };\n\nexport interface IntegrationParams {\n [key: string]: IntegrationParamValue;\n}\n\n/**\n * Validation result\n */\nexport interface ValidationResult {\n valid: boolean;\n errors: ValidationError[];\n}\n\n/**\n * Validation error\n */\nexport interface ValidationError {\n param: string;\n message: string;\n}\n","import { BaseIntegration } from '../core/BaseIntegration';\nimport type { IntegrationConfig, IntegrationResult, IntegrationParams } from '../types';\nimport { IntegrationError } from '../types';\n\n/**\n * Mock integration for testing\n */\nexport class MockIntegration extends BaseIntegration {\n private responses: Map<string, unknown> = new Map();\n private calls: Array<{ action: string; params: IntegrationParams }> =\n [];\n\n constructor(config: IntegrationConfig) {\n super(config);\n }\n\n /**\n * Set mock response for an action\n */\n setResponse(action: string, data: unknown): void {\n this.responses.set(action, data);\n }\n\n /**\n * Get all calls made to this integration\n */\n getCalls(): Array<{ action: string; params: IntegrationParams }> {\n return this.calls;\n }\n\n /**\n * Clear all calls\n */\n clearCalls(): void {\n this.calls = [];\n }\n\n async execute(\n action: string,\n params: IntegrationParams,\n ): Promise<IntegrationResult> {\n // Record the call\n this.calls.push({ action, params });\n\n const data = this.responses.get(action);\n\n if (!data) {\n return {\n success: false,\n error: new IntegrationError(\n `No mock response for action: ${action}`,\n 'UNKNOWN_ERROR',\n ),\n metadata: this.createMetadata(action, 0),\n };\n }\n\n return {\n success: true,\n data,\n metadata: this.createMetadata(action, 0),\n };\n }\n}\n","import type { IntegrationConfig } from './types';\nimport { BaseIntegration } from './core/BaseIntegration';\n\n/**\n * Integration constructor type\n */\nexport type IntegrationConstructor = new (\n config: IntegrationConfig,\n) => BaseIntegration;\n\n/**\n * Integration registry (populated as integrations are imported)\n */\nexport const INTEGRATION_REGISTRY: Record<string, IntegrationConstructor> = {};\n\n/**\n * Register an integration\n */\nexport function registerIntegration(\n name: string,\n constructor: IntegrationConstructor,\n): void {\n INTEGRATION_REGISTRY[name] = constructor;\n}\n\n/**\n * Get integration constructor by name\n */\nexport function getIntegration(\n name: string,\n): IntegrationConstructor | undefined {\n return INTEGRATION_REGISTRY[name];\n}\n\n/**\n * Check if integration is known\n */\nexport function isKnownIntegration(name: string): boolean {\n return name in INTEGRATION_REGISTRY;\n}\n\n/**\n * Get all registered integration names\n */\nexport function getRegisteredIntegrations(): string[] {\n return Object.keys(INTEGRATION_REGISTRY);\n}\n","import type { IntegrationConfig, IntegrationResult, IntegrationParams } from './types';\nimport { BaseIntegration } from './core/BaseIntegration';\nimport { getIntegration } from './registry';\n\n/**\n * Optional per-call context for principal-scoped resolution (W4) and\n * caller-identity enforcement (I-25). The default — absent — means the\n * tenant/app-wide credential set with an anonymous caller; role-gated\n * integrations (credentials) fail closed without it. Additive: every\n * existing call site is untouched.\n */\nexport interface IntegrationCallContext {\n principal?: string;\n /** The caller's roster role, from the same identity entity-ACL enforces against. */\n role?: string;\n}\n\n/** Cache key for (name, principal?) — NUL never appears in either part. */\nfunction instanceKey(name: string, principal?: string): string {\n return principal ? `${name}\\u0000${principal}` : name;\n}\n\n/**\n * Factory for creating and managing integration instances\n */\nexport class IntegrationFactory {\n private instances: Map<string, BaseIntegration> = new Map();\n private configs: Map<string, IntegrationConfig> = new Map();\n\n /**\n * Configure an integration (doesn't instantiate yet). A `principal` scopes\n * the config to that principal; the app-wide config (no principal) is the\n * fallback for every principal.\n */\n configure(name: string, config: Omit<IntegrationConfig, 'name'>, principal?: string): void {\n this.configs.set(instanceKey(name, principal), { name, ...config });\n }\n\n /**\n * Get or create an integration instance. Principal-scoped lookups fall\n * back to the app-wide config when no per-principal config exists.\n */\n get(name: string, principal?: string): BaseIntegration {\n const key = instanceKey(name, principal);\n const cached = this.instances.get(key);\n if (cached) {\n return cached;\n }\n\n // Get constructor\n const Constructor = getIntegration(name);\n if (!Constructor) {\n throw new Error(`Unknown integration: ${name}. Make sure it's imported.`);\n }\n\n // Get config — per-principal first, app-wide fallback\n const config = this.configs.get(key) ?? this.configs.get(name);\n if (!config) {\n throw new Error(\n `Integration not configured: ${name}. Call configure() first.`,\n );\n }\n\n // Create instance\n const instance = new Constructor(config);\n this.instances.set(key, instance);\n\n return instance;\n }\n\n /**\n * Execute an action on an integration\n */\n async execute(\n integration: string,\n action: string,\n params: IntegrationParams,\n context?: IntegrationCallContext,\n ): Promise<IntegrationResult> {\n const instance = this.get(integration, context?.principal);\n return await instance.execute(action, params, context);\n }\n\n /**\n * Check if integration is configured\n */\n isConfigured(name: string, principal?: string): boolean {\n return this.configs.has(instanceKey(name, principal)) || this.configs.has(name);\n }\n\n /**\n * Register an integration instance directly (used by mock infrastructure)\n */\n registerInstance(name: string, instance: BaseIntegration, principal?: string): void {\n this.instances.set(instanceKey(name, principal), instance);\n }\n\n /**\n * Drop the cached instance(s) for a name so the next `get` rebuilds from\n * the current config — how a credential change goes live without restart.\n * Configs are kept; without a name, every instance is dropped.\n */\n invalidate(name?: string): void {\n if (name === undefined) {\n this.instances.clear();\n return;\n }\n for (const key of this.instances.keys()) {\n if (key === name || key.startsWith(`${name}\\u0000`)) {\n this.instances.delete(key);\n }\n }\n }\n\n /**\n * Clear all instances (useful for testing)\n */\n clear(): void {\n this.instances.clear();\n }\n\n /**\n * Clear all instances and configs\n */\n reset(): void {\n this.instances.clear();\n this.configs.clear();\n }\n}\n\nlet _factory: IntegrationFactory | null = null;\n\nexport function getIntegrationFactory(): IntegrationFactory {\n if (!_factory) {\n _factory = new IntegrationFactory();\n }\n return _factory;\n}\n\nexport function resetIntegrationFactory(): void {\n _factory?.reset();\n _factory = null;\n}\n","import { IntegrationFactory } from '../factory';\nimport { MockIntegration } from './MockIntegration';\nimport { registerIntegration } from '../registry';\nimport type { IntegrationParams } from '../types';\n\n/**\n * Mock integration factory for testing\n */\nexport class MockIntegrationFactory extends IntegrationFactory {\n constructor() {\n super();\n \n // Register mock integration for all known services\n const services = ['stripe', 'youtube', 'twilio', 'email', 'llm', 'deepagent'];\n services.forEach((service) => {\n registerIntegration(`mock-${service}`, MockIntegration);\n \n // Configure with mock config\n this.configure(service, {\n env: {},\n });\n });\n }\n\n /**\n * Set mock response for an integration action\n */\n setMockResponse(integration: string, action: string, data: unknown): void {\n const instance = this.get(integration) as MockIntegration;\n instance.setResponse(action, data);\n }\n\n /**\n * Get calls made to an integration\n */\n getMockCalls(\n integration: string,\n ): Array<{ action: string; params: IntegrationParams }> {\n const instance = this.get(integration) as MockIntegration;\n return instance.getCalls();\n }\n\n /**\n * Clear calls for an integration\n */\n clearMockCalls(integration: string): void {\n const instance = this.get(integration) as MockIntegration;\n instance.clearCalls();\n }\n}\n"]}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { I as IntegrationCallContext,
|
|
2
|
-
import { e as
|
|
3
|
-
import { o as IntegrationName, m as IntegrationActionName, n as IntegrationContracts, e as CredentialStore } from '../store-CW1v7Apc.js';
|
|
1
|
+
import { g as IntegrationParams, I as IntegrationCallContext, d as IntegrationFactory } from '../BaseIntegration-C_5q54DM.js';
|
|
2
|
+
import { o as IntegrationName, m as IntegrationActionName, n as IntegrationContracts, e as CredentialStore } from '../store-tehIm2rt.js';
|
|
4
3
|
import '@almadar/core';
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -50,6 +49,7 @@ declare class RuntimeIntegrationManager {
|
|
|
50
49
|
private factory;
|
|
51
50
|
private credentialStore;
|
|
52
51
|
private storeEnvBase;
|
|
52
|
+
private storeFirst;
|
|
53
53
|
constructor();
|
|
54
54
|
/**
|
|
55
55
|
* W4: configure with the tenant credential store layered over the env —
|
|
@@ -60,7 +60,17 @@ declare class RuntimeIntegrationManager {
|
|
|
60
60
|
* exactly as before, so verify harnesses are unaffected.
|
|
61
61
|
*/
|
|
62
62
|
configureFromStore(store: CredentialStore, envOverride?: Record<string, string | undefined>): Promise<void>;
|
|
63
|
-
/**
|
|
63
|
+
/** Whether store-first custody (I-31) is active on this manager. */
|
|
64
|
+
get credentialsStoreFirst(): boolean;
|
|
65
|
+
/** Copy each declared credential present in env but absent from the store. */
|
|
66
|
+
private seedStoreFromEnv;
|
|
67
|
+
/**
|
|
68
|
+
* Re-derive configs from base env + warmed store values. `reset()` (not
|
|
69
|
+
* `invalidate()`): configs must go too, or a REMOVED credential's service
|
|
70
|
+
* resurrects from its stale config on the next `get()` — removal must
|
|
71
|
+
* revoke. `configureFromEnv` below rebuilds every configured service from
|
|
72
|
+
* the merged env.
|
|
73
|
+
*/
|
|
64
74
|
private refreshFromStore;
|
|
65
75
|
/**
|
|
66
76
|
* Wrap `factory.execute` so an unknown/unconfigured service echoes its
|