@almadar/integrations 2.3.0 → 2.5.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.
@@ -66,14 +66,26 @@ declare class IntegrationError extends Error {
66
66
  details: unknown;
67
67
  };
68
68
  }
69
+ /** Metadata attached to log entries */
70
+ interface LogMeta {
71
+ [key: string]: string | number | boolean | null | undefined | Error | string[] | LogMeta;
72
+ }
69
73
  /**
70
74
  * Logger interface
71
75
  */
72
76
  interface IntegrationLogger {
73
- debug(message: string, meta?: Record<string, unknown>): void;
74
- info(message: string, meta?: Record<string, unknown>): void;
75
- warn(message: string, meta?: Record<string, unknown>): void;
76
- error(message: string, meta?: Record<string, unknown>): void;
77
+ debug(message: string, meta?: LogMeta): void;
78
+ info(message: string, meta?: LogMeta): void;
79
+ warn(message: string, meta?: LogMeta): void;
80
+ error(message: string, meta?: LogMeta): void;
81
+ }
82
+ /**
83
+ * Integration action parameters.
84
+ * Each integration's execute() method receives params as this type.
85
+ * Individual methods cast to specific param shapes from their contracts.
86
+ */
87
+ interface IntegrationParams {
88
+ [key: string]: string | number | boolean | null | undefined | string[] | IntegrationParams;
77
89
  }
78
90
  /**
79
91
  * Validation result
@@ -93,7 +105,7 @@ interface ValidationError {
93
105
  /**
94
106
  * Validate action params against registry schema
95
107
  */
96
- declare function validateParams(integration: string, action: string, params: Record<string, unknown>): ValidationResult;
108
+ declare function validateParams(integration: string, action: string, params: IntegrationParams): ValidationResult;
97
109
 
98
110
  /**
99
111
  * Base class for all integrations
@@ -105,11 +117,11 @@ declare abstract class BaseIntegration {
105
117
  /**
106
118
  * Execute an action
107
119
  */
108
- abstract execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
120
+ abstract execute(action: string, params: IntegrationParams): Promise<IntegrationResult>;
109
121
  /**
110
122
  * Validate action params against registry
111
123
  */
112
- protected validateParams(action: string, params: Record<string, unknown>): ReturnType<typeof validateParams>;
124
+ protected validateParams(action: string, params: IntegrationParams): ReturnType<typeof validateParams>;
113
125
  /**
114
126
  * Handle errors uniformly
115
127
  */
@@ -124,4 +136,4 @@ declare abstract class BaseIntegration {
124
136
  protected executeWithRetry<T>(fn: () => Promise<T>): Promise<T>;
125
137
  }
126
138
 
127
- export { BaseIntegration as B, type IntegrationLogger as I, type ValidationError as V, type IntegrationErrorCode as a, type IntegrationConfig as b, type IntegrationResult as c, IntegrationError as d, type ValidationResult as e, validateParams as v };
139
+ export { BaseIntegration as B, type IntegrationParams as I, type LogMeta as L, type ValidationError as V, type IntegrationLogger as a, type IntegrationErrorCode as b, type IntegrationConfig as c, type IntegrationResult as d, IntegrationError as e, type ValidationResult as f, validateParams as v };
@@ -1,4 +1,4 @@
1
- import { b as IntegrationConfig, B as BaseIntegration, c as IntegrationResult } from './BaseIntegration-DNSuiUnG.js';
1
+ import { c as IntegrationConfig, B as BaseIntegration, I as IntegrationParams, d as IntegrationResult } from './BaseIntegration-B9X5vK3f.js';
2
2
 
3
3
  /**
4
4
  * Factory for creating and managing integration instances
@@ -17,7 +17,7 @@ declare class IntegrationFactory {
17
17
  /**
18
18
  * Execute an action on an integration
19
19
  */
20
- execute(integration: string, action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
20
+ execute(integration: string, action: string, params: IntegrationParams): Promise<IntegrationResult>;
21
21
  /**
22
22
  * Check if integration is configured
23
23
  */
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { I as IntegrationLogger, a as IntegrationErrorCode, b as IntegrationConfig, B as BaseIntegration, c as IntegrationResult } from './BaseIntegration-DNSuiUnG.js';
2
- export { d as IntegrationError, V as ValidationError, e as ValidationResult, v as validateParams } from './BaseIntegration-DNSuiUnG.js';
3
- export { I as IntegrationFactory, g as getIntegrationFactory, r as resetIntegrationFactory } from './factory-B1QtCI_c.js';
1
+ import { I as IntegrationParams, a as IntegrationLogger, L as LogMeta, b as IntegrationErrorCode, c as IntegrationConfig, B as BaseIntegration, d as IntegrationResult } from './BaseIntegration-B9X5vK3f.js';
2
+ export { e as IntegrationError, V as ValidationError, f as ValidationResult, v as validateParams } from './BaseIntegration-B9X5vK3f.js';
3
+ export { I as IntegrationFactory, g as getIntegrationFactory, r as resetIntegrationFactory } from './factory-CSJzotsJ.js';
4
4
  export { GitHubIntegration } from './integrations/github/index.js';
5
5
 
6
6
  /**
@@ -174,10 +174,10 @@ type LLMIntegrationActions = {
174
174
  extract: {
175
175
  params: {
176
176
  text: string;
177
- schema: Record<string, unknown>;
177
+ schema: IntegrationParams;
178
178
  model?: string;
179
179
  };
180
- result: Record<string, unknown>;
180
+ result: IntegrationParams;
181
181
  };
182
182
  summarize: {
183
183
  params: {
@@ -386,7 +386,7 @@ type StorageActions = {
386
386
  key: string;
387
387
  content: unknown;
388
388
  contentType?: string;
389
- metadata?: Record<string, unknown>;
389
+ metadata?: IntegrationParams;
390
390
  };
391
391
  result: {
392
392
  key: string;
@@ -404,7 +404,7 @@ type StorageActions = {
404
404
  content: unknown;
405
405
  contentType: string;
406
406
  size: number;
407
- metadata: Record<string, unknown>;
407
+ metadata: IntegrationParams;
408
408
  };
409
409
  };
410
410
  list: {
@@ -660,7 +660,7 @@ type OtelActions = {
660
660
  startSpan: {
661
661
  params: {
662
662
  name: string;
663
- attributes?: Record<string, unknown>;
663
+ attributes?: IntegrationParams;
664
664
  traceId?: string;
665
665
  };
666
666
  result: {
@@ -681,7 +681,7 @@ type OtelActions = {
681
681
  params: {
682
682
  spanId: string;
683
683
  name: string;
684
- attributes?: Record<string, unknown>;
684
+ attributes?: IntegrationParams;
685
685
  };
686
686
  result: {
687
687
  added: boolean;
@@ -692,7 +692,7 @@ type OtelActions = {
692
692
  name: string;
693
693
  value: number;
694
694
  type?: 'counter' | 'gauge' | 'histogram';
695
- labels?: Record<string, unknown>;
695
+ labels?: IntegrationParams;
696
696
  };
697
697
  result: {
698
698
  recorded: boolean;
@@ -709,7 +709,7 @@ type OtelActions = {
709
709
  startTime: number;
710
710
  endTime?: number;
711
711
  status?: 'ok' | 'error';
712
- attributes: Record<string, unknown>;
712
+ attributes: IntegrationParams;
713
713
  } | null;
714
714
  };
715
715
  getMetrics: {
@@ -719,7 +719,7 @@ type OtelActions = {
719
719
  type: string;
720
720
  value: number;
721
721
  values: number[];
722
- labels: Record<string, unknown>;
722
+ labels: IntegrationParams;
723
723
  }>;
724
724
  };
725
725
  };
@@ -742,7 +742,7 @@ type DeepAgentActions = {
742
742
  message: string;
743
743
  threadId?: string;
744
744
  skill?: string;
745
- context?: Record<string, unknown>;
745
+ context?: IntegrationParams;
746
746
  };
747
747
  result: {
748
748
  response: string;
@@ -837,10 +837,10 @@ type IntegrationActionName<K extends IntegrationName> = keyof IntegrationContrac
837
837
  declare class ConsoleLogger implements IntegrationLogger {
838
838
  private level;
839
839
  constructor(level?: 'debug' | 'info' | 'warn' | 'error');
840
- debug(message: string, meta?: Record<string, unknown>): void;
841
- info(message: string, meta?: Record<string, unknown>): void;
842
- warn(message: string, meta?: Record<string, unknown>): void;
843
- error(message: string, meta?: Record<string, unknown>): void;
840
+ debug(message: string, meta?: LogMeta): void;
841
+ info(message: string, meta?: LogMeta): void;
842
+ warn(message: string, meta?: LogMeta): void;
843
+ error(message: string, meta?: LogMeta): void;
844
844
  private shouldLog;
845
845
  }
846
846
 
@@ -885,7 +885,7 @@ declare function getRegisteredIntegrations(): string[];
885
885
  declare class StripeIntegration extends BaseIntegration {
886
886
  private client;
887
887
  constructor(config: IntegrationConfig);
888
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
888
+ execute(action: string, params: IntegrationParams): Promise<IntegrationResult>;
889
889
  private createPaymentIntent;
890
890
  private confirmPayment;
891
891
  private refund;
@@ -897,7 +897,7 @@ declare class StripeIntegration extends BaseIntegration {
897
897
  declare class YouTubeIntegration extends BaseIntegration {
898
898
  private client;
899
899
  constructor(config: IntegrationConfig);
900
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
900
+ execute(action: string, params: IntegrationParams): Promise<IntegrationResult>;
901
901
  private search;
902
902
  private getVideo;
903
903
  private getChannel;
@@ -910,7 +910,7 @@ declare class TwilioIntegration extends BaseIntegration {
910
910
  private client;
911
911
  private phoneNumber;
912
912
  constructor(config: IntegrationConfig);
913
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
913
+ execute(action: string, params: IntegrationParams): Promise<IntegrationResult>;
914
914
  private sendSMS;
915
915
  private sendWhatsApp;
916
916
  }
@@ -923,7 +923,7 @@ declare class EmailIntegration extends BaseIntegration {
923
923
  private fromEmail;
924
924
  private resendClient?;
925
925
  constructor(config: IntegrationConfig);
926
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
926
+ execute(action: string, params: IntegrationParams): Promise<IntegrationResult>;
927
927
  private send;
928
928
  private sendViaSendGrid;
929
929
  private sendViaResend;
@@ -947,7 +947,7 @@ declare class LLMIntegration extends BaseIntegration {
947
947
  * The client will throw a clear error when actually used without a key.
948
948
  */
949
949
  private getClient;
950
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
950
+ execute(action: string, params: IntegrationParams): Promise<IntegrationResult>;
951
951
  private generate;
952
952
  private classify;
953
953
  private extract;
@@ -961,7 +961,7 @@ declare class DeepAgentIntegration extends BaseIntegration {
961
961
  private apiUrl;
962
962
  private apiKey;
963
963
  constructor(config: IntegrationConfig);
964
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
964
+ execute(action: string, params: IntegrationParams): Promise<IntegrationResult>;
965
965
  private sendMessage;
966
966
  private cancelGeneration;
967
967
  private validateSchema;
@@ -981,7 +981,7 @@ declare class DeepAgentIntegration extends BaseIntegration {
981
981
  */
982
982
  declare class CLIIntegration extends BaseIntegration {
983
983
  constructor(config: IntegrationConfig);
984
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
984
+ execute(action: string, params: IntegrationParams): Promise<IntegrationResult>;
985
985
  private validate;
986
986
  }
987
987
 
@@ -998,7 +998,7 @@ declare class RedisIntegration extends BaseIntegration {
998
998
  private locks;
999
999
  private channels;
1000
1000
  constructor(config: IntegrationConfig);
1001
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
1001
+ execute(action: string, params: IntegrationParams): Promise<IntegrationResult>;
1002
1002
  /** Remove expired entries on access and return whether a key is alive. */
1003
1003
  private isAlive;
1004
1004
  /** Generate a unique lock identifier. */
@@ -1026,7 +1026,7 @@ declare class QueueIntegration extends BaseIntegration {
1026
1026
  /** Map from job ID to job data */
1027
1027
  private jobs;
1028
1028
  constructor(config: IntegrationConfig);
1029
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
1029
+ execute(action: string, params: IntegrationParams): Promise<IntegrationResult>;
1030
1030
  /** Generate a unique job identifier. */
1031
1031
  private generateJobId;
1032
1032
  /** Get or create the queue array for a given queue name. */
@@ -1050,7 +1050,7 @@ declare class OtelIntegration extends BaseIntegration {
1050
1050
  private spans;
1051
1051
  private metrics;
1052
1052
  constructor(config: IntegrationConfig);
1053
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
1053
+ execute(action: string, params: IntegrationParams): Promise<IntegrationResult>;
1054
1054
  private startSpan;
1055
1055
  private endSpan;
1056
1056
  private addEvent;
@@ -1076,7 +1076,7 @@ declare class OAuthIntegration extends BaseIntegration {
1076
1076
  /** Maps access token -> mock user session */
1077
1077
  private sessions;
1078
1078
  constructor(config: IntegrationConfig);
1079
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
1079
+ execute(action: string, params: IntegrationParams): Promise<IntegrationResult>;
1080
1080
  /** Generate a random hex token of the given byte length. */
1081
1081
  private generateToken;
1082
1082
  /** Generate a mock user profile from a provider and access token. */
@@ -1098,7 +1098,7 @@ declare class OAuthIntegration extends BaseIntegration {
1098
1098
  declare class StorageIntegration extends BaseIntegration {
1099
1099
  private objects;
1100
1100
  constructor(config: IntegrationConfig);
1101
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
1101
+ execute(action: string, params: IntegrationParams): Promise<IntegrationResult>;
1102
1102
  /** Build a composite key from bucket and object key. */
1103
1103
  private compositeKey;
1104
1104
  /** Generate a deterministic etag from content. */
@@ -1123,7 +1123,7 @@ declare class DockerIntegration extends BaseIntegration {
1123
1123
  private containers;
1124
1124
  private images;
1125
1125
  constructor(config: IntegrationConfig);
1126
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
1126
+ execute(action: string, params: IntegrationParams): Promise<IntegrationResult>;
1127
1127
  /** Generate a random hex container/image ID. */
1128
1128
  private generateId;
1129
1129
  /** Find a container by ID (prefix match supported). */
package/dist/index.js CHANGED
@@ -156,7 +156,7 @@ var BaseIntegration = class {
156
156
  */
157
157
  handleError(action, error) {
158
158
  this.logger.error(`Integration error in ${this.config.name}.${action}`, {
159
- error
159
+ error: error instanceof Error ? error : new Error(String(error))
160
160
  });
161
161
  const integrationError = error instanceof Error ? error : new Error(String(error));
162
162
  return {
@@ -600,7 +600,7 @@ var EmailIntegration = class extends BaseIntegration {
600
600
  }
601
601
  async send(params) {
602
602
  const { to, subject, body, from } = params;
603
- this.logger.debug("Sending email", { to, subject, provider: this.provider });
603
+ this.logger.debug("Sending email", { to: String(to), subject: String(subject), provider: this.provider });
604
604
  if (this.provider === "sendgrid") {
605
605
  return await this.sendViaSendGrid(
606
606
  to,
@@ -2547,7 +2547,7 @@ var DockerIntegration = class extends BaseIntegration {
2547
2547
  const env = params.env ?? {};
2548
2548
  const rawVolumes = params.volumes ?? [];
2549
2549
  const command = params.command ?? "";
2550
- this.logger.debug("Docker RUN", { image, name, ports: rawPorts, env, volumes: rawVolumes, command });
2550
+ this.logger.debug("Docker RUN", { image, name, ports: rawPorts.map((p) => `${p.host}:${p.container}`), volumes: rawVolumes.map((v) => `${v.host}:${v.container}`), command });
2551
2551
  const containerId = this.generateId();
2552
2552
  const ports = rawPorts.map((p) => ({
2553
2553
  host: p.host,