@almadar/integrations 2.19.0 → 2.21.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.
@@ -146,4 +146,4 @@ declare abstract class BaseIntegration {
146
146
  protected executeWithRetry<T>(fn: () => Promise<T>): Promise<T>;
147
147
  }
148
148
 
149
- export { BaseIntegration as B, type IntegrationConfig as I, type ValidationError as V, IntegrationError as a, type IntegrationErrorCode as b, type IntegrationLogger as c, type IntegrationParams as d, type IntegrationResult as e, type ValidationResult as f, validateParams as v };
149
+ export { BaseIntegration as B, type IntegrationConfig as I, type ValidationError as V, IntegrationError as a, type IntegrationErrorCode as b, type IntegrationLogger as c, type IntegrationParamValue as d, type IntegrationParams as e, type IntegrationResult as f, type ValidationResult as g, validateParams as v };
@@ -1,5 +1,29 @@
1
1
  import { ServiceParamsValue, ServiceParams } from '@almadar/core';
2
- import { d as IntegrationParams } from './BaseIntegration-B9lSTRQm.js';
2
+ import { d as IntegrationParamValue, e as IntegrationParams } from './BaseIntegration-MA-b4fh8.js';
3
+
4
+ /** Scalar value admissible as a SQL bind parameter. */
5
+ type DatabaseQueryParamValue = string | number | boolean | Date | null;
6
+ /** Params for the `query` action. */
7
+ type DatabaseQueryParams = {
8
+ connectionRef: string;
9
+ sql: string;
10
+ params?: DatabaseQueryParamValue[];
11
+ };
12
+ /** One result row, keyed by column name. */
13
+ type DatabaseRow = Record<string, IntegrationParamValue>;
14
+ /** Result of a read-only query. */
15
+ interface DatabaseQueryResult {
16
+ rows: DatabaseRow[];
17
+ rowCount: number;
18
+ }
19
+ /**
20
+ * Driver seam behind the `query` action. Postgres is the first
21
+ * implementation; MySQL/SQLite slot behind this interface later.
22
+ */
23
+ interface DatabaseDriver {
24
+ query(sql: string, params: readonly DatabaseQueryParamValue[]): Promise<DatabaseQueryResult>;
25
+ end(): Promise<void>;
26
+ }
3
27
 
4
28
  /**
5
29
  * ServiceContract type definitions for all @almadar/integrations.
@@ -848,6 +872,77 @@ type DeepAgentActions = {
848
872
  };
849
873
  };
850
874
  };
875
+ type DatabaseActions = {
876
+ query: {
877
+ params: {
878
+ connectionRef: string;
879
+ sql: string;
880
+ params?: DatabaseQueryParamValue[];
881
+ };
882
+ result: {
883
+ rows: DatabaseRow[];
884
+ rowCount: number;
885
+ };
886
+ };
887
+ };
888
+ type WikimediaActions = {
889
+ getPage: {
890
+ params: {
891
+ title: string;
892
+ };
893
+ result: {
894
+ title?: string;
895
+ description?: string;
896
+ portraitUrl?: string;
897
+ extract?: string;
898
+ };
899
+ };
900
+ };
901
+ type IconifyActions = {
902
+ svgExists: {
903
+ params: {
904
+ path: string;
905
+ };
906
+ result: {
907
+ exists: boolean;
908
+ };
909
+ };
910
+ search: {
911
+ params: {
912
+ query: string;
913
+ limit?: number;
914
+ };
915
+ result: {
916
+ icons: string[];
917
+ };
918
+ };
919
+ getIconBody: {
920
+ params: {
921
+ iconId: string;
922
+ };
923
+ result: {
924
+ body: string | null;
925
+ };
926
+ };
927
+ };
928
+ type ArxivActions = {
929
+ search: {
930
+ params: {
931
+ query: string;
932
+ maxResults?: number;
933
+ };
934
+ result: {
935
+ results: Array<{
936
+ id: string;
937
+ title: string;
938
+ summary: string;
939
+ authors: string[];
940
+ published: string;
941
+ url: string;
942
+ }>;
943
+ };
944
+ };
945
+ };
851
946
  /**
852
947
  * Maps each integration name (as used in `registerIntegration`) to its action
853
948
  * map type. Use with `ServiceContract<IntegrationContracts[K]>` to get a fully
@@ -877,6 +972,10 @@ type IntegrationContracts = {
877
972
  otel: OtelActions;
878
973
  cli: CLIActions;
879
974
  deepagent: DeepAgentActions;
975
+ database: DatabaseActions;
976
+ wikimedia: WikimediaActions;
977
+ iconify: IconifyActions;
978
+ arxiv: ArxivActions;
880
979
  };
881
980
  /** Integration name literal union. */
882
981
  type IntegrationName = keyof IntegrationContracts;
@@ -891,4 +990,4 @@ type IntegrationName = keyof IntegrationContracts;
891
990
  */
892
991
  type IntegrationActionName<K extends IntegrationName> = keyof IntegrationContracts[K] & string;
893
992
 
894
- export type { CLIActions as C, DeepAgentActions as D, EmailActions as E, GitHubActions as G, IntegrationActionName as I, LLMIntegrationActions as L, MLActions as M, OAuthActions as O, QueueActions as Q, RedisActions as R, StorageActions as S, TwilioActions as T, YouTubeActions as Y, DockerActions as a, IntegrationContracts as b, IntegrationName as c, OtelActions as d, StripeActions as e };
993
+ export type { ArxivActions as A, CLIActions as C, DatabaseActions as D, EmailActions as E, GitHubActions as G, IconifyActions as I, LLMIntegrationActions as L, MLActions as M, OAuthActions as O, QueueActions as Q, RedisActions as R, StorageActions as S, TwilioActions as T, WikimediaActions as W, YouTubeActions as Y, DatabaseDriver as a, DatabaseQueryParamValue as b, DatabaseQueryParams as c, DatabaseQueryResult as d, DatabaseRow as e, DeepAgentActions as f, DockerActions as g, IntegrationActionName as h, IntegrationContracts as i, IntegrationName as j, OtelActions as k, StripeActions as l };
@@ -1,4 +1,4 @@
1
- import { I as IntegrationConfig, B as BaseIntegration, d as IntegrationParams, e as IntegrationResult } from './BaseIntegration-B9lSTRQm.js';
1
+ import { I as IntegrationConfig, B as BaseIntegration, e as IntegrationParams, f as IntegrationResult } from './BaseIntegration-MA-b4fh8.js';
2
2
 
3
3
  /**
4
4
  * Factory for creating and managing integration instances
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { c as IntegrationLogger, b as IntegrationErrorCode, I as IntegrationConfig, B as BaseIntegration, d as IntegrationParams, e as IntegrationResult } from './BaseIntegration-B9lSTRQm.js';
2
- export { a as IntegrationError, V as ValidationError, f as ValidationResult, v as validateParams } from './BaseIntegration-B9lSTRQm.js';
3
- export { C as CLIActions, D as DeepAgentActions, a as DockerActions, E as EmailActions, G as GitHubActions, I as IntegrationActionName, b as IntegrationContracts, c as IntegrationName, L as LLMIntegrationActions, M as MLActions, O as OAuthActions, d as OtelActions, Q as QueueActions, R as RedisActions, S as StorageActions, e as StripeActions, T as TwilioActions, Y as YouTubeActions } from './contracts-B28G_7ur.js';
1
+ import { c as IntegrationLogger, b as IntegrationErrorCode, I as IntegrationConfig, B as BaseIntegration, e as IntegrationParams, f as IntegrationResult } from './BaseIntegration-MA-b4fh8.js';
2
+ export { a as IntegrationError, d as IntegrationParamValue, V as ValidationError, g as ValidationResult, v as validateParams } from './BaseIntegration-MA-b4fh8.js';
3
+ export { A as ArxivActions, C as CLIActions, D as DatabaseActions, a as DatabaseDriver, b as DatabaseQueryParamValue, c as DatabaseQueryParams, d as DatabaseQueryResult, e as DatabaseRow, f as DeepAgentActions, g as DockerActions, E as EmailActions, G as GitHubActions, I as IconifyActions, h as IntegrationActionName, i as IntegrationContracts, j as IntegrationName, L as LLMIntegrationActions, M as MLActions, O as OAuthActions, k as OtelActions, Q as QueueActions, R as RedisActions, S as StorageActions, l as StripeActions, T as TwilioActions, W as WikimediaActions, Y as YouTubeActions } from './contracts-CYtxZXrR.js';
4
4
  import { LogMeta } from '@almadar/core';
5
- export { I as IntegrationFactory, g as getIntegrationFactory, r as resetIntegrationFactory } from './factory-TNgVDujm.js';
5
+ export { I as IntegrationFactory, g as getIntegrationFactory, r as resetIntegrationFactory } from './factory-DTdVeyAi.js';
6
6
  export { GitHubIntegration } from './integrations/github/index.js';
7
7
 
8
8
  /**
@@ -560,4 +560,80 @@ declare class DockerIntegration extends BaseIntegration {
560
560
  private list;
561
561
  }
562
562
 
563
- export { type AlmadarCheckoutSession, type AlmadarCustomer, type AlmadarInvoiceFailure, type AlmadarInvoicePayment, type AlmadarPortalSession, type AlmadarStripeEvent, type AlmadarStripeEventOk, type AlmadarSubscription, type AlmadarSubscriptionStatus, type AlmadarTier, BaseIntegration, CLIIntegration, type CancelSubscriptionInput, ConsoleLogger, type CreateCheckoutInput, type CreateCustomerInput, type CreatePortalInput, DeepAgentIntegration, DockerIntegration, EmailIntegration, IntegrationConfig, type IntegrationConstructor, IntegrationErrorCode, IntegrationLogger, IntegrationResult, LLMIntegration, MLIntegration, OAuthIntegration, OtelIntegration, QueueIntegration, RedisIntegration, type RetryConfig, StorageIntegration, StripeIntegration, type StripePriceMap, TwilioIntegration, type UpdateSubscriptionInput, type VerifyAndParseInput, YouTubeIntegration, getIntegration, getRegisteredIntegrations, isKnownIntegration, registerIntegration, verifyAndParseStripeEvent, withRetry };
563
+ /**
564
+ * Read-only SQL enforcement for the database integration.
565
+ *
566
+ * The guard accepts exactly one SELECT statement (optionally CTE-led) and
567
+ * nothing else. Comments are stripped and string/identifier contents are
568
+ * blanked before keyword checks, so denied keywords inside literals (e.g.
569
+ * `WHERE note = 'delete this'`) never false-positive, and comment/quote
570
+ * tricks cannot smuggle a second statement past the check.
571
+ */
572
+ interface SqlGuardResult {
573
+ ok: boolean;
574
+ reason?: string;
575
+ }
576
+ /**
577
+ * Verify `sql` is a single read-only SELECT statement.
578
+ * Returns `{ ok: false, reason }` for anything else.
579
+ */
580
+ declare function assertReadOnlySelect(sql: string): SqlGuardResult;
581
+
582
+ /**
583
+ * Database Integration for Almadar
584
+ * Read-only SQL queries over external connections (migration fetch seam).
585
+ */
586
+
587
+ /**
588
+ * Generic database integration. One action — `query` — with read-only
589
+ * enforced in the integration itself (single SELECT only, statement
590
+ * timeout). `connectionRef` is an environment variable NAME, never the
591
+ * secret; the connection string is resolved from `process.env` at run time.
592
+ */
593
+ declare class DatabaseIntegration extends BaseIntegration {
594
+ private drivers;
595
+ private statementTimeoutMs;
596
+ constructor(config: IntegrationConfig);
597
+ execute(action: string, params: IntegrationParams): Promise<IntegrationResult>;
598
+ private runQuery;
599
+ /** Resolve (and cache) the driver for a connection reference. */
600
+ private driverFor;
601
+ }
602
+
603
+ declare class WikimediaIntegration extends BaseIntegration {
604
+ private readonly userAgent;
605
+ private readonly timeoutMs;
606
+ constructor(config: IntegrationConfig);
607
+ execute(action: string, params: IntegrationParams): Promise<IntegrationResult>;
608
+ /** Look up a title on Wikipedia: description, portrait, lead extract. Empty fields on miss. */
609
+ private getPage;
610
+ }
611
+
612
+ declare class IconifyIntegration extends BaseIntegration {
613
+ private readonly userAgent;
614
+ private readonly timeoutMs;
615
+ constructor(config: IntegrationConfig);
616
+ execute(action: string, params: IntegrationParams): Promise<IntegrationResult>;
617
+ private svgExists;
618
+ private search;
619
+ private getIconBody;
620
+ private headOk;
621
+ private getJson;
622
+ }
623
+
624
+ interface ArxivResult {
625
+ id: string;
626
+ title: string;
627
+ summary: string;
628
+ authors: string[];
629
+ published: string;
630
+ url: string;
631
+ }
632
+ declare class ArxivIntegration extends BaseIntegration {
633
+ private readonly timeoutMs;
634
+ constructor(config: IntegrationConfig);
635
+ execute(action: string, params: IntegrationParams): Promise<IntegrationResult>;
636
+ private search;
637
+ }
638
+
639
+ export { type AlmadarCheckoutSession, type AlmadarCustomer, type AlmadarInvoiceFailure, type AlmadarInvoicePayment, type AlmadarPortalSession, type AlmadarStripeEvent, type AlmadarStripeEventOk, type AlmadarSubscription, type AlmadarSubscriptionStatus, type AlmadarTier, ArxivIntegration, type ArxivResult, BaseIntegration, CLIIntegration, type CancelSubscriptionInput, ConsoleLogger, type CreateCheckoutInput, type CreateCustomerInput, type CreatePortalInput, DatabaseIntegration, DeepAgentIntegration, DockerIntegration, EmailIntegration, IconifyIntegration, IntegrationConfig, type IntegrationConstructor, IntegrationErrorCode, IntegrationLogger, IntegrationParams, IntegrationResult, LLMIntegration, MLIntegration, OAuthIntegration, OtelIntegration, QueueIntegration, RedisIntegration, type RetryConfig, type SqlGuardResult, StorageIntegration, StripeIntegration, type StripePriceMap, TwilioIntegration, type UpdateSubscriptionInput, type VerifyAndParseInput, WikimediaIntegration, YouTubeIntegration, assertReadOnlySelect, getIntegration, getRegisteredIntegrations, isKnownIntegration, registerIntegration, verifyAndParseStripeEvent, withRetry };