@voltagent/core 1.2.18 → 1.2.19
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/index.d.mts +33 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +107 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +107 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1986,6 +1986,15 @@ type VoltOpsDiscordCredential = VoltOpsStoredCredentialRef | WithCredentialMetad
|
|
|
1986
1986
|
}> | WithCredentialMetadata<{
|
|
1987
1987
|
webhookUrl: string;
|
|
1988
1988
|
}>;
|
|
1989
|
+
type VoltOpsPostgresCredential = VoltOpsStoredCredentialRef | WithCredentialMetadata<{
|
|
1990
|
+
host: string;
|
|
1991
|
+
port?: number;
|
|
1992
|
+
user: string;
|
|
1993
|
+
password: string;
|
|
1994
|
+
database: string;
|
|
1995
|
+
ssl?: boolean;
|
|
1996
|
+
rejectUnauthorized?: boolean;
|
|
1997
|
+
}>;
|
|
1989
1998
|
type VoltOpsGmailCredential = VoltOpsStoredCredentialRef | WithCredentialMetadata<{
|
|
1990
1999
|
accessToken?: string;
|
|
1991
2000
|
refreshToken?: string;
|
|
@@ -2176,6 +2185,22 @@ interface VoltOpsDiscordMemberRoleParams extends VoltOpsDiscordBaseParams {
|
|
|
2176
2185
|
userId: string;
|
|
2177
2186
|
roleId: string;
|
|
2178
2187
|
}
|
|
2188
|
+
interface VoltOpsPostgresBaseParams {
|
|
2189
|
+
credential: VoltOpsPostgresCredential;
|
|
2190
|
+
actionId?: string;
|
|
2191
|
+
catalogId?: string;
|
|
2192
|
+
projectId?: string | null;
|
|
2193
|
+
}
|
|
2194
|
+
interface VoltOpsPostgresExecuteParams extends VoltOpsPostgresBaseParams {
|
|
2195
|
+
query: string;
|
|
2196
|
+
parameters?: unknown[];
|
|
2197
|
+
applicationName?: string;
|
|
2198
|
+
statementTimeoutMs?: number;
|
|
2199
|
+
connectionTimeoutMs?: number;
|
|
2200
|
+
ssl?: {
|
|
2201
|
+
rejectUnauthorized?: boolean;
|
|
2202
|
+
};
|
|
2203
|
+
}
|
|
2179
2204
|
interface VoltOpsGmailBaseParams {
|
|
2180
2205
|
credential: VoltOpsGmailCredential;
|
|
2181
2206
|
actionId?: string;
|
|
@@ -2258,6 +2283,9 @@ type VoltOpsActionsApi = {
|
|
|
2258
2283
|
getEmail: (params: VoltOpsGmailGetEmailParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2259
2284
|
getThread: (params: VoltOpsGmailGetThreadParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2260
2285
|
};
|
|
2286
|
+
postgres: {
|
|
2287
|
+
executeQuery: (params: VoltOpsPostgresExecuteParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2288
|
+
};
|
|
2261
2289
|
};
|
|
2262
2290
|
interface VoltOpsEvalsApi {
|
|
2263
2291
|
runs: {
|
|
@@ -2702,6 +2730,9 @@ declare class VoltOpsActionsClient {
|
|
|
2702
2730
|
getEmail: (params: VoltOpsGmailGetEmailParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2703
2731
|
getThread: (params: VoltOpsGmailGetThreadParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2704
2732
|
};
|
|
2733
|
+
readonly postgres: {
|
|
2734
|
+
executeQuery: (params: VoltOpsPostgresExecuteParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2735
|
+
};
|
|
2705
2736
|
constructor(transport: VoltOpsActionsTransport, options?: {
|
|
2706
2737
|
useProjectEndpoint?: boolean;
|
|
2707
2738
|
});
|
|
@@ -2722,6 +2753,7 @@ declare class VoltOpsActionsClient {
|
|
|
2722
2753
|
private searchGmailEmails;
|
|
2723
2754
|
private getGmailEmail;
|
|
2724
2755
|
private getGmailThread;
|
|
2756
|
+
private executePostgresQuery;
|
|
2725
2757
|
private sendDiscordMessage;
|
|
2726
2758
|
private sendDiscordWebhookMessage;
|
|
2727
2759
|
private deleteDiscordMessage;
|
|
@@ -2749,6 +2781,7 @@ declare class VoltOpsActionsClient {
|
|
|
2749
2781
|
private ensureSlackCredential;
|
|
2750
2782
|
private ensureDiscordCredential;
|
|
2751
2783
|
private ensureGmailCredential;
|
|
2784
|
+
private ensurePostgresCredential;
|
|
2752
2785
|
private normalizeCredentialMetadata;
|
|
2753
2786
|
private normalizeIdentifier;
|
|
2754
2787
|
private ensureRecord;
|
package/dist/index.d.ts
CHANGED
|
@@ -1986,6 +1986,15 @@ type VoltOpsDiscordCredential = VoltOpsStoredCredentialRef | WithCredentialMetad
|
|
|
1986
1986
|
}> | WithCredentialMetadata<{
|
|
1987
1987
|
webhookUrl: string;
|
|
1988
1988
|
}>;
|
|
1989
|
+
type VoltOpsPostgresCredential = VoltOpsStoredCredentialRef | WithCredentialMetadata<{
|
|
1990
|
+
host: string;
|
|
1991
|
+
port?: number;
|
|
1992
|
+
user: string;
|
|
1993
|
+
password: string;
|
|
1994
|
+
database: string;
|
|
1995
|
+
ssl?: boolean;
|
|
1996
|
+
rejectUnauthorized?: boolean;
|
|
1997
|
+
}>;
|
|
1989
1998
|
type VoltOpsGmailCredential = VoltOpsStoredCredentialRef | WithCredentialMetadata<{
|
|
1990
1999
|
accessToken?: string;
|
|
1991
2000
|
refreshToken?: string;
|
|
@@ -2176,6 +2185,22 @@ interface VoltOpsDiscordMemberRoleParams extends VoltOpsDiscordBaseParams {
|
|
|
2176
2185
|
userId: string;
|
|
2177
2186
|
roleId: string;
|
|
2178
2187
|
}
|
|
2188
|
+
interface VoltOpsPostgresBaseParams {
|
|
2189
|
+
credential: VoltOpsPostgresCredential;
|
|
2190
|
+
actionId?: string;
|
|
2191
|
+
catalogId?: string;
|
|
2192
|
+
projectId?: string | null;
|
|
2193
|
+
}
|
|
2194
|
+
interface VoltOpsPostgresExecuteParams extends VoltOpsPostgresBaseParams {
|
|
2195
|
+
query: string;
|
|
2196
|
+
parameters?: unknown[];
|
|
2197
|
+
applicationName?: string;
|
|
2198
|
+
statementTimeoutMs?: number;
|
|
2199
|
+
connectionTimeoutMs?: number;
|
|
2200
|
+
ssl?: {
|
|
2201
|
+
rejectUnauthorized?: boolean;
|
|
2202
|
+
};
|
|
2203
|
+
}
|
|
2179
2204
|
interface VoltOpsGmailBaseParams {
|
|
2180
2205
|
credential: VoltOpsGmailCredential;
|
|
2181
2206
|
actionId?: string;
|
|
@@ -2258,6 +2283,9 @@ type VoltOpsActionsApi = {
|
|
|
2258
2283
|
getEmail: (params: VoltOpsGmailGetEmailParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2259
2284
|
getThread: (params: VoltOpsGmailGetThreadParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2260
2285
|
};
|
|
2286
|
+
postgres: {
|
|
2287
|
+
executeQuery: (params: VoltOpsPostgresExecuteParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2288
|
+
};
|
|
2261
2289
|
};
|
|
2262
2290
|
interface VoltOpsEvalsApi {
|
|
2263
2291
|
runs: {
|
|
@@ -2702,6 +2730,9 @@ declare class VoltOpsActionsClient {
|
|
|
2702
2730
|
getEmail: (params: VoltOpsGmailGetEmailParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2703
2731
|
getThread: (params: VoltOpsGmailGetThreadParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2704
2732
|
};
|
|
2733
|
+
readonly postgres: {
|
|
2734
|
+
executeQuery: (params: VoltOpsPostgresExecuteParams) => Promise<VoltOpsActionExecutionResult>;
|
|
2735
|
+
};
|
|
2705
2736
|
constructor(transport: VoltOpsActionsTransport, options?: {
|
|
2706
2737
|
useProjectEndpoint?: boolean;
|
|
2707
2738
|
});
|
|
@@ -2722,6 +2753,7 @@ declare class VoltOpsActionsClient {
|
|
|
2722
2753
|
private searchGmailEmails;
|
|
2723
2754
|
private getGmailEmail;
|
|
2724
2755
|
private getGmailThread;
|
|
2756
|
+
private executePostgresQuery;
|
|
2725
2757
|
private sendDiscordMessage;
|
|
2726
2758
|
private sendDiscordWebhookMessage;
|
|
2727
2759
|
private deleteDiscordMessage;
|
|
@@ -2749,6 +2781,7 @@ declare class VoltOpsActionsClient {
|
|
|
2749
2781
|
private ensureSlackCredential;
|
|
2750
2782
|
private ensureDiscordCredential;
|
|
2751
2783
|
private ensureGmailCredential;
|
|
2784
|
+
private ensurePostgresCredential;
|
|
2752
2785
|
private normalizeCredentialMetadata;
|
|
2753
2786
|
private normalizeIdentifier;
|
|
2754
2787
|
private ensureRecord;
|
package/dist/index.js
CHANGED
|
@@ -8982,6 +8982,9 @@ var VoltOpsActionsClient = class {
|
|
|
8982
8982
|
getEmail: this.getGmailEmail.bind(this),
|
|
8983
8983
|
getThread: this.getGmailThread.bind(this)
|
|
8984
8984
|
};
|
|
8985
|
+
this.postgres = {
|
|
8986
|
+
executeQuery: this.executePostgresQuery.bind(this)
|
|
8987
|
+
};
|
|
8985
8988
|
}
|
|
8986
8989
|
static {
|
|
8987
8990
|
__name(this, "VoltOpsActionsClient");
|
|
@@ -8990,6 +8993,7 @@ var VoltOpsActionsClient = class {
|
|
|
8990
8993
|
slack;
|
|
8991
8994
|
discord;
|
|
8992
8995
|
gmail;
|
|
8996
|
+
postgres;
|
|
8993
8997
|
useProjectEndpoint;
|
|
8994
8998
|
get actionExecutionPath() {
|
|
8995
8999
|
return this.useProjectEndpoint ? "/actions/project/run" : "/actions/execute";
|
|
@@ -9453,6 +9457,60 @@ var VoltOpsActionsClient = class {
|
|
|
9453
9457
|
input
|
|
9454
9458
|
});
|
|
9455
9459
|
}
|
|
9460
|
+
async executePostgresQuery(params) {
|
|
9461
|
+
if (!params || typeof params !== "object") {
|
|
9462
|
+
throw new VoltOpsActionError("params must be provided", 400);
|
|
9463
|
+
}
|
|
9464
|
+
const credential = this.ensurePostgresCredential(params.credential);
|
|
9465
|
+
const query = this.trimString(params.query);
|
|
9466
|
+
if (!query) {
|
|
9467
|
+
throw new VoltOpsActionError("query must be provided", 400);
|
|
9468
|
+
}
|
|
9469
|
+
const parameters = Array.isArray(params.parameters) ? params.parameters : [];
|
|
9470
|
+
const applicationName = this.trimString(params.applicationName);
|
|
9471
|
+
const statementTimeoutMs = this.normalizePositiveInteger(
|
|
9472
|
+
params.statementTimeoutMs,
|
|
9473
|
+
"statementTimeoutMs",
|
|
9474
|
+
{ allowZero: false }
|
|
9475
|
+
);
|
|
9476
|
+
const connectionTimeoutMs = this.normalizePositiveInteger(
|
|
9477
|
+
params.connectionTimeoutMs,
|
|
9478
|
+
"connectionTimeoutMs",
|
|
9479
|
+
{ allowZero: false }
|
|
9480
|
+
);
|
|
9481
|
+
const ssl = params.ssl && typeof params.ssl === "object" && !Array.isArray(params.ssl) ? {
|
|
9482
|
+
rejectUnauthorized: typeof params.ssl.rejectUnauthorized === "boolean" ? params.ssl.rejectUnauthorized : void 0
|
|
9483
|
+
} : void 0;
|
|
9484
|
+
const input = {
|
|
9485
|
+
query
|
|
9486
|
+
};
|
|
9487
|
+
if (parameters.length) {
|
|
9488
|
+
input.parameters = parameters;
|
|
9489
|
+
}
|
|
9490
|
+
if (applicationName) {
|
|
9491
|
+
input.applicationName = applicationName;
|
|
9492
|
+
}
|
|
9493
|
+
if (typeof statementTimeoutMs === "number") {
|
|
9494
|
+
input.statementTimeoutMs = statementTimeoutMs;
|
|
9495
|
+
}
|
|
9496
|
+
if (typeof connectionTimeoutMs === "number") {
|
|
9497
|
+
input.connectionTimeoutMs = connectionTimeoutMs;
|
|
9498
|
+
}
|
|
9499
|
+
if (ssl) {
|
|
9500
|
+
input.ssl = ssl;
|
|
9501
|
+
}
|
|
9502
|
+
const payload = {
|
|
9503
|
+
credential,
|
|
9504
|
+
catalogId: params.catalogId ?? void 0,
|
|
9505
|
+
actionId: params.actionId ?? "postgres.executeQuery",
|
|
9506
|
+
projectId: params.projectId ?? void 0,
|
|
9507
|
+
payload: {
|
|
9508
|
+
input
|
|
9509
|
+
}
|
|
9510
|
+
};
|
|
9511
|
+
const response = await this.postActionExecution(this.actionExecutionPath, payload);
|
|
9512
|
+
return this.mapActionExecution(response);
|
|
9513
|
+
}
|
|
9456
9514
|
async sendDiscordMessage(params) {
|
|
9457
9515
|
if (!params || typeof params !== "object") {
|
|
9458
9516
|
throw new VoltOpsActionError("params must be provided", 400);
|
|
@@ -10052,6 +10110,51 @@ var VoltOpsActionsClient = class {
|
|
|
10052
10110
|
}
|
|
10053
10111
|
return payload;
|
|
10054
10112
|
}
|
|
10113
|
+
ensurePostgresCredential(value) {
|
|
10114
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
10115
|
+
throw new VoltOpsActionError("credential must be an object", 400);
|
|
10116
|
+
}
|
|
10117
|
+
const record = value;
|
|
10118
|
+
const metadata = this.normalizeCredentialMetadata(record.metadata);
|
|
10119
|
+
const storedId = this.trimString(
|
|
10120
|
+
typeof record.credentialId === "string" ? record.credentialId : typeof record.id === "string" ? record.id : void 0
|
|
10121
|
+
);
|
|
10122
|
+
if (storedId) {
|
|
10123
|
+
return metadata ? { credentialId: storedId, metadata } : { credentialId: storedId };
|
|
10124
|
+
}
|
|
10125
|
+
const host = this.trimString(record.host);
|
|
10126
|
+
const user = this.trimString(record.user);
|
|
10127
|
+
const password = this.trimString(record.password);
|
|
10128
|
+
const database = this.trimString(record.database);
|
|
10129
|
+
if (!host || !user || !password || !database) {
|
|
10130
|
+
throw new VoltOpsActionError(
|
|
10131
|
+
"credential must include host, user, password, and database for Postgres actions",
|
|
10132
|
+
400
|
|
10133
|
+
);
|
|
10134
|
+
}
|
|
10135
|
+
const port = typeof record.port === "number" && Number.isFinite(record.port) ? Math.trunc(record.port) : void 0;
|
|
10136
|
+
const ssl = typeof record.ssl === "boolean" ? record.ssl : void 0;
|
|
10137
|
+
const rejectUnauthorized = typeof record.rejectUnauthorized === "boolean" ? record.rejectUnauthorized : void 0;
|
|
10138
|
+
const payload = {
|
|
10139
|
+
host,
|
|
10140
|
+
user,
|
|
10141
|
+
password,
|
|
10142
|
+
database
|
|
10143
|
+
};
|
|
10144
|
+
if (port !== void 0) {
|
|
10145
|
+
payload.port = port;
|
|
10146
|
+
}
|
|
10147
|
+
if (ssl !== void 0) {
|
|
10148
|
+
payload.ssl = ssl;
|
|
10149
|
+
}
|
|
10150
|
+
if (rejectUnauthorized !== void 0) {
|
|
10151
|
+
payload.rejectUnauthorized = rejectUnauthorized;
|
|
10152
|
+
}
|
|
10153
|
+
if (metadata) {
|
|
10154
|
+
payload.metadata = metadata;
|
|
10155
|
+
}
|
|
10156
|
+
return payload;
|
|
10157
|
+
}
|
|
10055
10158
|
normalizeCredentialMetadata(metadata) {
|
|
10056
10159
|
if (metadata === void 0 || metadata === null) {
|
|
10057
10160
|
return void 0;
|
|
@@ -10116,7 +10219,7 @@ var VoltOpsActionsClient = class {
|
|
|
10116
10219
|
}
|
|
10117
10220
|
return entries.length > 0 ? entries : void 0;
|
|
10118
10221
|
}
|
|
10119
|
-
normalizePositiveInteger(value, field) {
|
|
10222
|
+
normalizePositiveInteger(value, field, options) {
|
|
10120
10223
|
if (value === void 0 || value === null) {
|
|
10121
10224
|
return void 0;
|
|
10122
10225
|
}
|
|
@@ -10124,8 +10227,9 @@ var VoltOpsActionsClient = class {
|
|
|
10124
10227
|
throw new VoltOpsActionError(`${field} must be a finite number`, 400);
|
|
10125
10228
|
}
|
|
10126
10229
|
const normalized = Math.floor(value);
|
|
10127
|
-
|
|
10128
|
-
|
|
10230
|
+
const allowZero = options?.allowZero ?? false;
|
|
10231
|
+
if (normalized < 0 || !allowZero && normalized === 0) {
|
|
10232
|
+
throw new VoltOpsActionError(`${field} must be greater than ${allowZero ? "-1" : "0"}`, 400);
|
|
10129
10233
|
}
|
|
10130
10234
|
return normalized;
|
|
10131
10235
|
}
|