@almadar/integrations 2.23.0 → 2.24.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/{contracts-CLTh6gjT.d.ts → contracts-Dv9PM_Cz.d.ts} +17 -1
- package/dist/index.d.ts +13 -2
- package/dist/index.js +77 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +82 -0
- package/dist/runtime/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -353,6 +353,21 @@ type EmailActions = {
|
|
|
353
353
|
};
|
|
354
354
|
};
|
|
355
355
|
};
|
|
356
|
+
type WebhookActions = {
|
|
357
|
+
send: {
|
|
358
|
+
params: {
|
|
359
|
+
url: string;
|
|
360
|
+
event: string;
|
|
361
|
+
payload?: Record<string, string>;
|
|
362
|
+
secret?: string;
|
|
363
|
+
};
|
|
364
|
+
result: {
|
|
365
|
+
status: number;
|
|
366
|
+
ok: boolean;
|
|
367
|
+
durationMs: number;
|
|
368
|
+
};
|
|
369
|
+
};
|
|
370
|
+
};
|
|
356
371
|
type DockerActions = {
|
|
357
372
|
build: {
|
|
358
373
|
params: {
|
|
@@ -973,6 +988,7 @@ type IntegrationContracts = {
|
|
|
973
988
|
youtube: YouTubeActions;
|
|
974
989
|
twilio: TwilioActions;
|
|
975
990
|
email: EmailActions;
|
|
991
|
+
webhook: WebhookActions;
|
|
976
992
|
docker: DockerActions;
|
|
977
993
|
storage: StorageActions;
|
|
978
994
|
queue: QueueActions;
|
|
@@ -999,4 +1015,4 @@ type IntegrationName = keyof IntegrationContracts;
|
|
|
999
1015
|
*/
|
|
1000
1016
|
type IntegrationActionName<K extends IntegrationName> = keyof IntegrationContracts[K] & string;
|
|
1001
1017
|
|
|
1002
|
-
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,
|
|
1018
|
+
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, WebhookActions 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, WikimediaActions as m };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
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
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-
|
|
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 WebhookActions, m as WikimediaActions, Y as YouTubeActions } from './contracts-Dv9PM_Cz.js';
|
|
4
4
|
import { LogMeta } from '@almadar/core';
|
|
5
5
|
export { I as IntegrationFactory, g as getIntegrationFactory, r as resetIntegrationFactory } from './factory-DTdVeyAi.js';
|
|
6
6
|
export { GitHubIntegration } from './integrations/github/index.js';
|
|
@@ -341,6 +341,17 @@ declare class EmailIntegration extends BaseIntegration {
|
|
|
341
341
|
private sendViaResend;
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
+
/**
|
|
345
|
+
* Outbound webhook integration — signed HTTP POST notifications to external endpoints.
|
|
346
|
+
*/
|
|
347
|
+
declare class WebhookIntegration extends BaseIntegration {
|
|
348
|
+
private signingSecret;
|
|
349
|
+
private timeoutMs;
|
|
350
|
+
constructor(config: IntegrationConfig);
|
|
351
|
+
execute(action: string, params: IntegrationParams): Promise<IntegrationResult>;
|
|
352
|
+
private send;
|
|
353
|
+
}
|
|
354
|
+
|
|
344
355
|
/**
|
|
345
356
|
* LLM integration using @almadar/llm
|
|
346
357
|
*
|
|
@@ -647,4 +658,4 @@ declare class ArxivIntegration extends BaseIntegration {
|
|
|
647
658
|
private search;
|
|
648
659
|
}
|
|
649
660
|
|
|
650
|
-
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 };
|
|
661
|
+
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, WebhookIntegration, WikimediaIntegration, YouTubeIntegration, assertReadOnlySelect, getIntegration, getRegisteredIntegrations, isKnownIntegration, registerIntegration, verifyAndParseStripeEvent, withRetry };
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { google } from 'googleapis';
|
|
|
5
5
|
import twilio from 'twilio';
|
|
6
6
|
import sgMail from '@sendgrid/mail';
|
|
7
7
|
import { Resend } from 'resend';
|
|
8
|
+
import { createHmac } from 'crypto';
|
|
8
9
|
import { getAvailableProvider, LLMClient, EmbeddingClient } from '@almadar/llm';
|
|
9
10
|
import { z } from 'zod';
|
|
10
11
|
import { execSync, spawn } from 'child_process';
|
|
@@ -993,6 +994,81 @@ var EmailIntegration = class extends BaseIntegration {
|
|
|
993
994
|
}
|
|
994
995
|
};
|
|
995
996
|
registerIntegration("email", EmailIntegration);
|
|
997
|
+
var WebhookIntegration = class extends BaseIntegration {
|
|
998
|
+
constructor(config) {
|
|
999
|
+
super(config);
|
|
1000
|
+
this.signingSecret = config.env.WEBHOOK_SIGNING_SECRET || "";
|
|
1001
|
+
this.timeoutMs = Number(config.env.WEBHOOK_TIMEOUT_MS) || 1e4;
|
|
1002
|
+
this.logger.info("Webhook integration initialized");
|
|
1003
|
+
}
|
|
1004
|
+
async execute(action, params) {
|
|
1005
|
+
const validation = this.validateParams(action, params);
|
|
1006
|
+
if (!validation.valid) {
|
|
1007
|
+
return {
|
|
1008
|
+
success: false,
|
|
1009
|
+
error: {
|
|
1010
|
+
name: "IntegrationError",
|
|
1011
|
+
message: "Validation failed",
|
|
1012
|
+
code: "VALIDATION_ERROR",
|
|
1013
|
+
details: validation.errors
|
|
1014
|
+
},
|
|
1015
|
+
metadata: this.createMetadata(action, 0)
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1018
|
+
const startTime = Date.now();
|
|
1019
|
+
let retries = 0;
|
|
1020
|
+
try {
|
|
1021
|
+
let data;
|
|
1022
|
+
switch (action) {
|
|
1023
|
+
case "send":
|
|
1024
|
+
data = await this.executeWithRetry(() => this.send(params));
|
|
1025
|
+
break;
|
|
1026
|
+
default:
|
|
1027
|
+
throw new Error(`Unknown action: ${action}`);
|
|
1028
|
+
}
|
|
1029
|
+
return {
|
|
1030
|
+
success: true,
|
|
1031
|
+
data,
|
|
1032
|
+
metadata: this.createMetadata(action, Date.now() - startTime, retries)
|
|
1033
|
+
};
|
|
1034
|
+
} catch (error) {
|
|
1035
|
+
return this.handleError(action, error);
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
async send(params) {
|
|
1039
|
+
const { url, event, payload, secret } = params;
|
|
1040
|
+
const body = JSON.stringify({
|
|
1041
|
+
event,
|
|
1042
|
+
payload: payload ?? {},
|
|
1043
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1044
|
+
});
|
|
1045
|
+
const headers = {
|
|
1046
|
+
"Content-Type": "application/json",
|
|
1047
|
+
"X-Almadar-Event": event
|
|
1048
|
+
};
|
|
1049
|
+
const signingSecret = secret || this.signingSecret;
|
|
1050
|
+
if (signingSecret) {
|
|
1051
|
+
headers["X-Almadar-Signature"] = "sha256=" + createHmac("sha256", signingSecret).update(body).digest("hex");
|
|
1052
|
+
}
|
|
1053
|
+
this.logger.debug("Sending webhook", { url: String(url), event: String(event) });
|
|
1054
|
+
const startTime = Date.now();
|
|
1055
|
+
const response = await fetch(url, {
|
|
1056
|
+
method: "POST",
|
|
1057
|
+
headers,
|
|
1058
|
+
body,
|
|
1059
|
+
signal: AbortSignal.timeout(this.timeoutMs)
|
|
1060
|
+
});
|
|
1061
|
+
if (response.status >= 500) {
|
|
1062
|
+
throw new Error(`Webhook endpoint returned ${response.status}`);
|
|
1063
|
+
}
|
|
1064
|
+
return {
|
|
1065
|
+
status: response.status,
|
|
1066
|
+
ok: response.ok,
|
|
1067
|
+
durationMs: Date.now() - startTime
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1070
|
+
};
|
|
1071
|
+
registerIntegration("webhook", WebhookIntegration);
|
|
996
1072
|
var LLMIntegration = class extends BaseIntegration {
|
|
997
1073
|
constructor(config) {
|
|
998
1074
|
super(config);
|
|
@@ -3683,6 +3759,6 @@ var ArxivIntegration = class extends BaseIntegration {
|
|
|
3683
3759
|
};
|
|
3684
3760
|
registerIntegration("arxiv", ArxivIntegration);
|
|
3685
3761
|
|
|
3686
|
-
export { ArxivIntegration, BaseIntegration, CLIIntegration, ConsoleLogger, DatabaseIntegration, DeepAgentIntegration, DockerIntegration, EmailIntegration, GitHubIntegration, IconifyIntegration, IntegrationError, IntegrationFactory, LLMIntegration, MLIntegration, OAuthIntegration, OtelIntegration, QueueIntegration, RedisIntegration, StorageIntegration, StripeIntegration, TwilioIntegration, WikimediaIntegration, YouTubeIntegration, assertReadOnlySelect, getIntegration, getIntegrationFactory, getRegisteredIntegrations, isKnownIntegration, registerIntegration, resetIntegrationFactory, validateParams, verifyAndParseStripeEvent, withRetry };
|
|
3762
|
+
export { ArxivIntegration, BaseIntegration, CLIIntegration, ConsoleLogger, DatabaseIntegration, DeepAgentIntegration, DockerIntegration, EmailIntegration, GitHubIntegration, IconifyIntegration, IntegrationError, IntegrationFactory, LLMIntegration, MLIntegration, OAuthIntegration, OtelIntegration, QueueIntegration, RedisIntegration, StorageIntegration, StripeIntegration, TwilioIntegration, WebhookIntegration, WikimediaIntegration, YouTubeIntegration, assertReadOnlySelect, getIntegration, getIntegrationFactory, getRegisteredIntegrations, isKnownIntegration, registerIntegration, resetIntegrationFactory, validateParams, verifyAndParseStripeEvent, withRetry };
|
|
3687
3763
|
//# sourceMappingURL=index.js.map
|
|
3688
3764
|
//# sourceMappingURL=index.js.map
|