weave-typescript 0.15.0 → 0.17.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/weaveapi/atc/v1/event.pb.d.ts +101 -0
- package/dist/weaveapi/atc/v1/event.pb.js +862 -1
- package/dist/weaveapi/atc/v1/service.pb.d.ts +99 -1
- package/dist/weaveapi/atc/v1/service.pb.js +921 -1
- package/dist/weaveapi/provider/v1/provider.pb.d.ts +123 -0
- package/dist/weaveapi/provider/v1/provider.pb.js +914 -0
- package/dist/weaveapi/provider/v1/service.pb.d.ts +198 -0
- package/dist/weaveapi/provider/v1/service.pb.js +1569 -0
- package/dist/weavesql/atcdb/event_sql.d.ts +68 -0
- package/dist/weavesql/atcdb/event_sql.js +143 -1
- package/dist/weavesql/atcdb/inspection_sql.d.ts +139 -0
- package/dist/weavesql/atcdb/inspection_sql.js +316 -0
- package/dist/weavesql/atcdb/run_template_sql.d.ts +122 -0
- package/dist/weavesql/atcdb/run_template_sql.js +197 -0
- package/dist/weavesql/atcdb/snapshot_sql.d.ts +58 -0
- package/dist/weavesql/atcdb/snapshot_sql.js +124 -0
- package/dist/weavesql/atcdb/team_sql.d.ts +111 -0
- package/dist/weavesql/atcdb/team_sql.js +235 -0
- package/dist/weavesql/atcdb/workflow_template_sql.d.ts +122 -0
- package/dist/weavesql/atcdb/workflow_template_sql.js +197 -0
- package/dist/weavesql/weavedb/provider_sql.d.ts +162 -0
- package/dist/weavesql/weavedb/provider_sql.js +358 -0
- package/package.json +2 -2
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { QueryArrayConfig, QueryArrayResult } from "pg";
|
|
2
|
+
interface Client {
|
|
3
|
+
query: (config: QueryArrayConfig) => Promise<QueryArrayResult>;
|
|
4
|
+
}
|
|
5
|
+
export declare const createProviderConfigurationQuery = "-- name: CreateProviderConfiguration :one\nINSERT INTO weave.llm_provider_configurations (\n id,\n organization_id,\n provider_kind,\n display_name,\n base_url,\n status,\n created_by_user_id,\n updated_by_user_id\n) VALUES (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7,\n $8\n)\nRETURNING\n id,\n organization_id,\n provider_kind,\n display_name,\n base_url,\n status,\n created_by_user_id,\n updated_by_user_id,\n created_at,\n updated_at";
|
|
6
|
+
export interface CreateProviderConfigurationArgs {
|
|
7
|
+
id: string;
|
|
8
|
+
organizationId: string;
|
|
9
|
+
providerKind: string;
|
|
10
|
+
displayName: string;
|
|
11
|
+
baseUrl: string | null;
|
|
12
|
+
status: string;
|
|
13
|
+
createdByUserId: string;
|
|
14
|
+
updatedByUserId: string;
|
|
15
|
+
}
|
|
16
|
+
export interface CreateProviderConfigurationRow {
|
|
17
|
+
id: string;
|
|
18
|
+
organizationId: string;
|
|
19
|
+
providerKind: string;
|
|
20
|
+
displayName: string;
|
|
21
|
+
baseUrl: string | null;
|
|
22
|
+
status: string;
|
|
23
|
+
createdByUserId: string;
|
|
24
|
+
updatedByUserId: string;
|
|
25
|
+
createdAt: Date;
|
|
26
|
+
updatedAt: Date;
|
|
27
|
+
}
|
|
28
|
+
export declare function createProviderConfiguration(client: Client, args: CreateProviderConfigurationArgs): Promise<CreateProviderConfigurationRow | null>;
|
|
29
|
+
export declare const getProviderConfigurationByIDQuery = "-- name: GetProviderConfigurationByID :one\nSELECT\n id,\n organization_id,\n provider_kind,\n display_name,\n base_url,\n status,\n created_by_user_id,\n updated_by_user_id,\n created_at,\n updated_at\nFROM weave.llm_provider_configurations\nWHERE organization_id = $1\n AND id = $2";
|
|
30
|
+
export interface GetProviderConfigurationByIDArgs {
|
|
31
|
+
organizationId: string;
|
|
32
|
+
id: string;
|
|
33
|
+
}
|
|
34
|
+
export interface GetProviderConfigurationByIDRow {
|
|
35
|
+
id: string;
|
|
36
|
+
organizationId: string;
|
|
37
|
+
providerKind: string;
|
|
38
|
+
displayName: string;
|
|
39
|
+
baseUrl: string | null;
|
|
40
|
+
status: string;
|
|
41
|
+
createdByUserId: string;
|
|
42
|
+
updatedByUserId: string;
|
|
43
|
+
createdAt: Date;
|
|
44
|
+
updatedAt: Date;
|
|
45
|
+
}
|
|
46
|
+
export declare function getProviderConfigurationByID(client: Client, args: GetProviderConfigurationByIDArgs): Promise<GetProviderConfigurationByIDRow | null>;
|
|
47
|
+
export declare const getProviderConfigurationByKindQuery = "-- name: GetProviderConfigurationByKind :one\nSELECT\n id,\n organization_id,\n provider_kind,\n display_name,\n base_url,\n status,\n created_by_user_id,\n updated_by_user_id,\n created_at,\n updated_at\nFROM weave.llm_provider_configurations\nWHERE organization_id = $1\n AND provider_kind = $2";
|
|
48
|
+
export interface GetProviderConfigurationByKindArgs {
|
|
49
|
+
organizationId: string;
|
|
50
|
+
providerKind: string;
|
|
51
|
+
}
|
|
52
|
+
export interface GetProviderConfigurationByKindRow {
|
|
53
|
+
id: string;
|
|
54
|
+
organizationId: string;
|
|
55
|
+
providerKind: string;
|
|
56
|
+
displayName: string;
|
|
57
|
+
baseUrl: string | null;
|
|
58
|
+
status: string;
|
|
59
|
+
createdByUserId: string;
|
|
60
|
+
updatedByUserId: string;
|
|
61
|
+
createdAt: Date;
|
|
62
|
+
updatedAt: Date;
|
|
63
|
+
}
|
|
64
|
+
export declare function getProviderConfigurationByKind(client: Client, args: GetProviderConfigurationByKindArgs): Promise<GetProviderConfigurationByKindRow | null>;
|
|
65
|
+
export declare const listProviderConfigurationsQuery = "-- name: ListProviderConfigurations :many\nSELECT\n id,\n organization_id,\n provider_kind,\n display_name,\n base_url,\n status,\n created_by_user_id,\n updated_by_user_id,\n created_at,\n updated_at\nFROM weave.llm_provider_configurations\nWHERE organization_id = $1\nORDER BY updated_at DESC, created_at DESC";
|
|
66
|
+
export interface ListProviderConfigurationsArgs {
|
|
67
|
+
organizationId: string;
|
|
68
|
+
}
|
|
69
|
+
export interface ListProviderConfigurationsRow {
|
|
70
|
+
id: string;
|
|
71
|
+
organizationId: string;
|
|
72
|
+
providerKind: string;
|
|
73
|
+
displayName: string;
|
|
74
|
+
baseUrl: string | null;
|
|
75
|
+
status: string;
|
|
76
|
+
createdByUserId: string;
|
|
77
|
+
updatedByUserId: string;
|
|
78
|
+
createdAt: Date;
|
|
79
|
+
updatedAt: Date;
|
|
80
|
+
}
|
|
81
|
+
export declare function listProviderConfigurations(client: Client, args: ListProviderConfigurationsArgs): Promise<ListProviderConfigurationsRow[]>;
|
|
82
|
+
export declare const updateProviderConfigurationByIDQuery = "-- name: UpdateProviderConfigurationByID :one\nUPDATE weave.llm_provider_configurations\nSET\n display_name = $1,\n base_url = $2,\n status = $3,\n updated_by_user_id = $4,\n updated_at = now()\nWHERE organization_id = $5\n AND id = $6\nRETURNING\n id,\n organization_id,\n provider_kind,\n display_name,\n base_url,\n status,\n created_by_user_id,\n updated_by_user_id,\n created_at,\n updated_at";
|
|
83
|
+
export interface UpdateProviderConfigurationByIDArgs {
|
|
84
|
+
displayName: string;
|
|
85
|
+
baseUrl: string | null;
|
|
86
|
+
status: string;
|
|
87
|
+
updatedByUserId: string;
|
|
88
|
+
organizationId: string;
|
|
89
|
+
id: string;
|
|
90
|
+
}
|
|
91
|
+
export interface UpdateProviderConfigurationByIDRow {
|
|
92
|
+
id: string;
|
|
93
|
+
organizationId: string;
|
|
94
|
+
providerKind: string;
|
|
95
|
+
displayName: string;
|
|
96
|
+
baseUrl: string | null;
|
|
97
|
+
status: string;
|
|
98
|
+
createdByUserId: string;
|
|
99
|
+
updatedByUserId: string;
|
|
100
|
+
createdAt: Date;
|
|
101
|
+
updatedAt: Date;
|
|
102
|
+
}
|
|
103
|
+
export declare function updateProviderConfigurationByID(client: Client, args: UpdateProviderConfigurationByIDArgs): Promise<UpdateProviderConfigurationByIDRow | null>;
|
|
104
|
+
export declare const disableProviderConfigurationByIDQuery = "-- name: DisableProviderConfigurationByID :one\nUPDATE weave.llm_provider_configurations\nSET\n status = 'PROVIDER_CONFIGURATION_STATUS_DISABLED',\n updated_by_user_id = $1,\n updated_at = now()\nWHERE organization_id = $2\n AND id = $3\nRETURNING\n id,\n organization_id,\n provider_kind,\n display_name,\n base_url,\n status,\n created_by_user_id,\n updated_by_user_id,\n created_at,\n updated_at";
|
|
105
|
+
export interface DisableProviderConfigurationByIDArgs {
|
|
106
|
+
updatedByUserId: string;
|
|
107
|
+
organizationId: string;
|
|
108
|
+
id: string;
|
|
109
|
+
}
|
|
110
|
+
export interface DisableProviderConfigurationByIDRow {
|
|
111
|
+
id: string;
|
|
112
|
+
organizationId: string;
|
|
113
|
+
providerKind: string;
|
|
114
|
+
displayName: string;
|
|
115
|
+
baseUrl: string | null;
|
|
116
|
+
status: string;
|
|
117
|
+
createdByUserId: string;
|
|
118
|
+
updatedByUserId: string;
|
|
119
|
+
createdAt: Date;
|
|
120
|
+
updatedAt: Date;
|
|
121
|
+
}
|
|
122
|
+
export declare function disableProviderConfigurationByID(client: Client, args: DisableProviderConfigurationByIDArgs): Promise<DisableProviderConfigurationByIDRow | null>;
|
|
123
|
+
export declare const upsertProviderCredentialQuery = "-- name: UpsertProviderCredential :one\nINSERT INTO weave.llm_provider_credentials (\n provider_configuration_id,\n organization_id,\n encrypted_credentials,\n credential_hint,\n credential_status,\n key_version,\n last_rotated_at\n) VALUES (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7\n)\nON CONFLICT (provider_configuration_id) DO UPDATE\nSET\n organization_id = EXCLUDED.organization_id,\n encrypted_credentials = EXCLUDED.encrypted_credentials,\n credential_hint = EXCLUDED.credential_hint,\n credential_status = EXCLUDED.credential_status,\n key_version = EXCLUDED.key_version,\n last_rotated_at = EXCLUDED.last_rotated_at,\n updated_at = now()\nRETURNING\n provider_configuration_id,\n organization_id,\n encrypted_credentials,\n credential_hint,\n credential_status,\n key_version,\n last_rotated_at,\n created_at,\n updated_at";
|
|
124
|
+
export interface UpsertProviderCredentialArgs {
|
|
125
|
+
providerConfigurationId: string;
|
|
126
|
+
organizationId: string;
|
|
127
|
+
encryptedCredentials: Buffer;
|
|
128
|
+
credentialHint: string;
|
|
129
|
+
credentialStatus: string;
|
|
130
|
+
keyVersion: string | null;
|
|
131
|
+
lastRotatedAt: Date;
|
|
132
|
+
}
|
|
133
|
+
export interface UpsertProviderCredentialRow {
|
|
134
|
+
providerConfigurationId: string;
|
|
135
|
+
organizationId: string;
|
|
136
|
+
encryptedCredentials: Buffer;
|
|
137
|
+
credentialHint: string;
|
|
138
|
+
credentialStatus: string;
|
|
139
|
+
keyVersion: string | null;
|
|
140
|
+
lastRotatedAt: Date;
|
|
141
|
+
createdAt: Date;
|
|
142
|
+
updatedAt: Date;
|
|
143
|
+
}
|
|
144
|
+
export declare function upsertProviderCredential(client: Client, args: UpsertProviderCredentialArgs): Promise<UpsertProviderCredentialRow | null>;
|
|
145
|
+
export declare const getProviderCredentialByProviderIDQuery = "-- name: GetProviderCredentialByProviderID :one\nSELECT\n provider_configuration_id,\n organization_id,\n encrypted_credentials,\n credential_hint,\n credential_status,\n key_version,\n last_rotated_at,\n created_at,\n updated_at\nFROM weave.llm_provider_credentials\nWHERE organization_id = $1\n AND provider_configuration_id = $2";
|
|
146
|
+
export interface GetProviderCredentialByProviderIDArgs {
|
|
147
|
+
organizationId: string;
|
|
148
|
+
providerConfigurationId: string;
|
|
149
|
+
}
|
|
150
|
+
export interface GetProviderCredentialByProviderIDRow {
|
|
151
|
+
providerConfigurationId: string;
|
|
152
|
+
organizationId: string;
|
|
153
|
+
encryptedCredentials: Buffer;
|
|
154
|
+
credentialHint: string;
|
|
155
|
+
credentialStatus: string;
|
|
156
|
+
keyVersion: string | null;
|
|
157
|
+
lastRotatedAt: Date;
|
|
158
|
+
createdAt: Date;
|
|
159
|
+
updatedAt: Date;
|
|
160
|
+
}
|
|
161
|
+
export declare function getProviderCredentialByProviderID(client: Client, args: GetProviderCredentialByProviderIDArgs): Promise<GetProviderCredentialByProviderIDRow | null>;
|
|
162
|
+
export {};
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getProviderCredentialByProviderIDQuery = exports.upsertProviderCredentialQuery = exports.disableProviderConfigurationByIDQuery = exports.updateProviderConfigurationByIDQuery = exports.listProviderConfigurationsQuery = exports.getProviderConfigurationByKindQuery = exports.getProviderConfigurationByIDQuery = exports.createProviderConfigurationQuery = void 0;
|
|
4
|
+
exports.createProviderConfiguration = createProviderConfiguration;
|
|
5
|
+
exports.getProviderConfigurationByID = getProviderConfigurationByID;
|
|
6
|
+
exports.getProviderConfigurationByKind = getProviderConfigurationByKind;
|
|
7
|
+
exports.listProviderConfigurations = listProviderConfigurations;
|
|
8
|
+
exports.updateProviderConfigurationByID = updateProviderConfigurationByID;
|
|
9
|
+
exports.disableProviderConfigurationByID = disableProviderConfigurationByID;
|
|
10
|
+
exports.upsertProviderCredential = upsertProviderCredential;
|
|
11
|
+
exports.getProviderCredentialByProviderID = getProviderCredentialByProviderID;
|
|
12
|
+
exports.createProviderConfigurationQuery = `-- name: CreateProviderConfiguration :one
|
|
13
|
+
INSERT INTO weave.llm_provider_configurations (
|
|
14
|
+
id,
|
|
15
|
+
organization_id,
|
|
16
|
+
provider_kind,
|
|
17
|
+
display_name,
|
|
18
|
+
base_url,
|
|
19
|
+
status,
|
|
20
|
+
created_by_user_id,
|
|
21
|
+
updated_by_user_id
|
|
22
|
+
) VALUES (
|
|
23
|
+
$1,
|
|
24
|
+
$2,
|
|
25
|
+
$3,
|
|
26
|
+
$4,
|
|
27
|
+
$5,
|
|
28
|
+
$6,
|
|
29
|
+
$7,
|
|
30
|
+
$8
|
|
31
|
+
)
|
|
32
|
+
RETURNING
|
|
33
|
+
id,
|
|
34
|
+
organization_id,
|
|
35
|
+
provider_kind,
|
|
36
|
+
display_name,
|
|
37
|
+
base_url,
|
|
38
|
+
status,
|
|
39
|
+
created_by_user_id,
|
|
40
|
+
updated_by_user_id,
|
|
41
|
+
created_at,
|
|
42
|
+
updated_at`;
|
|
43
|
+
async function createProviderConfiguration(client, args) {
|
|
44
|
+
const result = await client.query({
|
|
45
|
+
text: exports.createProviderConfigurationQuery,
|
|
46
|
+
values: [args.id, args.organizationId, args.providerKind, args.displayName, args.baseUrl, args.status, args.createdByUserId, args.updatedByUserId],
|
|
47
|
+
rowMode: "array"
|
|
48
|
+
});
|
|
49
|
+
if (result.rows.length !== 1) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const row = result.rows[0];
|
|
53
|
+
return {
|
|
54
|
+
id: row[0],
|
|
55
|
+
organizationId: row[1],
|
|
56
|
+
providerKind: row[2],
|
|
57
|
+
displayName: row[3],
|
|
58
|
+
baseUrl: row[4],
|
|
59
|
+
status: row[5],
|
|
60
|
+
createdByUserId: row[6],
|
|
61
|
+
updatedByUserId: row[7],
|
|
62
|
+
createdAt: row[8],
|
|
63
|
+
updatedAt: row[9]
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
exports.getProviderConfigurationByIDQuery = `-- name: GetProviderConfigurationByID :one
|
|
67
|
+
SELECT
|
|
68
|
+
id,
|
|
69
|
+
organization_id,
|
|
70
|
+
provider_kind,
|
|
71
|
+
display_name,
|
|
72
|
+
base_url,
|
|
73
|
+
status,
|
|
74
|
+
created_by_user_id,
|
|
75
|
+
updated_by_user_id,
|
|
76
|
+
created_at,
|
|
77
|
+
updated_at
|
|
78
|
+
FROM weave.llm_provider_configurations
|
|
79
|
+
WHERE organization_id = $1
|
|
80
|
+
AND id = $2`;
|
|
81
|
+
async function getProviderConfigurationByID(client, args) {
|
|
82
|
+
const result = await client.query({
|
|
83
|
+
text: exports.getProviderConfigurationByIDQuery,
|
|
84
|
+
values: [args.organizationId, args.id],
|
|
85
|
+
rowMode: "array"
|
|
86
|
+
});
|
|
87
|
+
if (result.rows.length !== 1) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
const row = result.rows[0];
|
|
91
|
+
return {
|
|
92
|
+
id: row[0],
|
|
93
|
+
organizationId: row[1],
|
|
94
|
+
providerKind: row[2],
|
|
95
|
+
displayName: row[3],
|
|
96
|
+
baseUrl: row[4],
|
|
97
|
+
status: row[5],
|
|
98
|
+
createdByUserId: row[6],
|
|
99
|
+
updatedByUserId: row[7],
|
|
100
|
+
createdAt: row[8],
|
|
101
|
+
updatedAt: row[9]
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
exports.getProviderConfigurationByKindQuery = `-- name: GetProviderConfigurationByKind :one
|
|
105
|
+
SELECT
|
|
106
|
+
id,
|
|
107
|
+
organization_id,
|
|
108
|
+
provider_kind,
|
|
109
|
+
display_name,
|
|
110
|
+
base_url,
|
|
111
|
+
status,
|
|
112
|
+
created_by_user_id,
|
|
113
|
+
updated_by_user_id,
|
|
114
|
+
created_at,
|
|
115
|
+
updated_at
|
|
116
|
+
FROM weave.llm_provider_configurations
|
|
117
|
+
WHERE organization_id = $1
|
|
118
|
+
AND provider_kind = $2`;
|
|
119
|
+
async function getProviderConfigurationByKind(client, args) {
|
|
120
|
+
const result = await client.query({
|
|
121
|
+
text: exports.getProviderConfigurationByKindQuery,
|
|
122
|
+
values: [args.organizationId, args.providerKind],
|
|
123
|
+
rowMode: "array"
|
|
124
|
+
});
|
|
125
|
+
if (result.rows.length !== 1) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
const row = result.rows[0];
|
|
129
|
+
return {
|
|
130
|
+
id: row[0],
|
|
131
|
+
organizationId: row[1],
|
|
132
|
+
providerKind: row[2],
|
|
133
|
+
displayName: row[3],
|
|
134
|
+
baseUrl: row[4],
|
|
135
|
+
status: row[5],
|
|
136
|
+
createdByUserId: row[6],
|
|
137
|
+
updatedByUserId: row[7],
|
|
138
|
+
createdAt: row[8],
|
|
139
|
+
updatedAt: row[9]
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
exports.listProviderConfigurationsQuery = `-- name: ListProviderConfigurations :many
|
|
143
|
+
SELECT
|
|
144
|
+
id,
|
|
145
|
+
organization_id,
|
|
146
|
+
provider_kind,
|
|
147
|
+
display_name,
|
|
148
|
+
base_url,
|
|
149
|
+
status,
|
|
150
|
+
created_by_user_id,
|
|
151
|
+
updated_by_user_id,
|
|
152
|
+
created_at,
|
|
153
|
+
updated_at
|
|
154
|
+
FROM weave.llm_provider_configurations
|
|
155
|
+
WHERE organization_id = $1
|
|
156
|
+
ORDER BY updated_at DESC, created_at DESC`;
|
|
157
|
+
async function listProviderConfigurations(client, args) {
|
|
158
|
+
const result = await client.query({
|
|
159
|
+
text: exports.listProviderConfigurationsQuery,
|
|
160
|
+
values: [args.organizationId],
|
|
161
|
+
rowMode: "array"
|
|
162
|
+
});
|
|
163
|
+
return result.rows.map(row => {
|
|
164
|
+
return {
|
|
165
|
+
id: row[0],
|
|
166
|
+
organizationId: row[1],
|
|
167
|
+
providerKind: row[2],
|
|
168
|
+
displayName: row[3],
|
|
169
|
+
baseUrl: row[4],
|
|
170
|
+
status: row[5],
|
|
171
|
+
createdByUserId: row[6],
|
|
172
|
+
updatedByUserId: row[7],
|
|
173
|
+
createdAt: row[8],
|
|
174
|
+
updatedAt: row[9]
|
|
175
|
+
};
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
exports.updateProviderConfigurationByIDQuery = `-- name: UpdateProviderConfigurationByID :one
|
|
179
|
+
UPDATE weave.llm_provider_configurations
|
|
180
|
+
SET
|
|
181
|
+
display_name = $1,
|
|
182
|
+
base_url = $2,
|
|
183
|
+
status = $3,
|
|
184
|
+
updated_by_user_id = $4,
|
|
185
|
+
updated_at = now()
|
|
186
|
+
WHERE organization_id = $5
|
|
187
|
+
AND id = $6
|
|
188
|
+
RETURNING
|
|
189
|
+
id,
|
|
190
|
+
organization_id,
|
|
191
|
+
provider_kind,
|
|
192
|
+
display_name,
|
|
193
|
+
base_url,
|
|
194
|
+
status,
|
|
195
|
+
created_by_user_id,
|
|
196
|
+
updated_by_user_id,
|
|
197
|
+
created_at,
|
|
198
|
+
updated_at`;
|
|
199
|
+
async function updateProviderConfigurationByID(client, args) {
|
|
200
|
+
const result = await client.query({
|
|
201
|
+
text: exports.updateProviderConfigurationByIDQuery,
|
|
202
|
+
values: [args.displayName, args.baseUrl, args.status, args.updatedByUserId, args.organizationId, args.id],
|
|
203
|
+
rowMode: "array"
|
|
204
|
+
});
|
|
205
|
+
if (result.rows.length !== 1) {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
const row = result.rows[0];
|
|
209
|
+
return {
|
|
210
|
+
id: row[0],
|
|
211
|
+
organizationId: row[1],
|
|
212
|
+
providerKind: row[2],
|
|
213
|
+
displayName: row[3],
|
|
214
|
+
baseUrl: row[4],
|
|
215
|
+
status: row[5],
|
|
216
|
+
createdByUserId: row[6],
|
|
217
|
+
updatedByUserId: row[7],
|
|
218
|
+
createdAt: row[8],
|
|
219
|
+
updatedAt: row[9]
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
exports.disableProviderConfigurationByIDQuery = `-- name: DisableProviderConfigurationByID :one
|
|
223
|
+
UPDATE weave.llm_provider_configurations
|
|
224
|
+
SET
|
|
225
|
+
status = 'PROVIDER_CONFIGURATION_STATUS_DISABLED',
|
|
226
|
+
updated_by_user_id = $1,
|
|
227
|
+
updated_at = now()
|
|
228
|
+
WHERE organization_id = $2
|
|
229
|
+
AND id = $3
|
|
230
|
+
RETURNING
|
|
231
|
+
id,
|
|
232
|
+
organization_id,
|
|
233
|
+
provider_kind,
|
|
234
|
+
display_name,
|
|
235
|
+
base_url,
|
|
236
|
+
status,
|
|
237
|
+
created_by_user_id,
|
|
238
|
+
updated_by_user_id,
|
|
239
|
+
created_at,
|
|
240
|
+
updated_at`;
|
|
241
|
+
async function disableProviderConfigurationByID(client, args) {
|
|
242
|
+
const result = await client.query({
|
|
243
|
+
text: exports.disableProviderConfigurationByIDQuery,
|
|
244
|
+
values: [args.updatedByUserId, args.organizationId, args.id],
|
|
245
|
+
rowMode: "array"
|
|
246
|
+
});
|
|
247
|
+
if (result.rows.length !== 1) {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
const row = result.rows[0];
|
|
251
|
+
return {
|
|
252
|
+
id: row[0],
|
|
253
|
+
organizationId: row[1],
|
|
254
|
+
providerKind: row[2],
|
|
255
|
+
displayName: row[3],
|
|
256
|
+
baseUrl: row[4],
|
|
257
|
+
status: row[5],
|
|
258
|
+
createdByUserId: row[6],
|
|
259
|
+
updatedByUserId: row[7],
|
|
260
|
+
createdAt: row[8],
|
|
261
|
+
updatedAt: row[9]
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
exports.upsertProviderCredentialQuery = `-- name: UpsertProviderCredential :one
|
|
265
|
+
INSERT INTO weave.llm_provider_credentials (
|
|
266
|
+
provider_configuration_id,
|
|
267
|
+
organization_id,
|
|
268
|
+
encrypted_credentials,
|
|
269
|
+
credential_hint,
|
|
270
|
+
credential_status,
|
|
271
|
+
key_version,
|
|
272
|
+
last_rotated_at
|
|
273
|
+
) VALUES (
|
|
274
|
+
$1,
|
|
275
|
+
$2,
|
|
276
|
+
$3,
|
|
277
|
+
$4,
|
|
278
|
+
$5,
|
|
279
|
+
$6,
|
|
280
|
+
$7
|
|
281
|
+
)
|
|
282
|
+
ON CONFLICT (provider_configuration_id) DO UPDATE
|
|
283
|
+
SET
|
|
284
|
+
organization_id = EXCLUDED.organization_id,
|
|
285
|
+
encrypted_credentials = EXCLUDED.encrypted_credentials,
|
|
286
|
+
credential_hint = EXCLUDED.credential_hint,
|
|
287
|
+
credential_status = EXCLUDED.credential_status,
|
|
288
|
+
key_version = EXCLUDED.key_version,
|
|
289
|
+
last_rotated_at = EXCLUDED.last_rotated_at,
|
|
290
|
+
updated_at = now()
|
|
291
|
+
RETURNING
|
|
292
|
+
provider_configuration_id,
|
|
293
|
+
organization_id,
|
|
294
|
+
encrypted_credentials,
|
|
295
|
+
credential_hint,
|
|
296
|
+
credential_status,
|
|
297
|
+
key_version,
|
|
298
|
+
last_rotated_at,
|
|
299
|
+
created_at,
|
|
300
|
+
updated_at`;
|
|
301
|
+
async function upsertProviderCredential(client, args) {
|
|
302
|
+
const result = await client.query({
|
|
303
|
+
text: exports.upsertProviderCredentialQuery,
|
|
304
|
+
values: [args.providerConfigurationId, args.organizationId, args.encryptedCredentials, args.credentialHint, args.credentialStatus, args.keyVersion, args.lastRotatedAt],
|
|
305
|
+
rowMode: "array"
|
|
306
|
+
});
|
|
307
|
+
if (result.rows.length !== 1) {
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
const row = result.rows[0];
|
|
311
|
+
return {
|
|
312
|
+
providerConfigurationId: row[0],
|
|
313
|
+
organizationId: row[1],
|
|
314
|
+
encryptedCredentials: row[2],
|
|
315
|
+
credentialHint: row[3],
|
|
316
|
+
credentialStatus: row[4],
|
|
317
|
+
keyVersion: row[5],
|
|
318
|
+
lastRotatedAt: row[6],
|
|
319
|
+
createdAt: row[7],
|
|
320
|
+
updatedAt: row[8]
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
exports.getProviderCredentialByProviderIDQuery = `-- name: GetProviderCredentialByProviderID :one
|
|
324
|
+
SELECT
|
|
325
|
+
provider_configuration_id,
|
|
326
|
+
organization_id,
|
|
327
|
+
encrypted_credentials,
|
|
328
|
+
credential_hint,
|
|
329
|
+
credential_status,
|
|
330
|
+
key_version,
|
|
331
|
+
last_rotated_at,
|
|
332
|
+
created_at,
|
|
333
|
+
updated_at
|
|
334
|
+
FROM weave.llm_provider_credentials
|
|
335
|
+
WHERE organization_id = $1
|
|
336
|
+
AND provider_configuration_id = $2`;
|
|
337
|
+
async function getProviderCredentialByProviderID(client, args) {
|
|
338
|
+
const result = await client.query({
|
|
339
|
+
text: exports.getProviderCredentialByProviderIDQuery,
|
|
340
|
+
values: [args.organizationId, args.providerConfigurationId],
|
|
341
|
+
rowMode: "array"
|
|
342
|
+
});
|
|
343
|
+
if (result.rows.length !== 1) {
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
const row = result.rows[0];
|
|
347
|
+
return {
|
|
348
|
+
providerConfigurationId: row[0],
|
|
349
|
+
organizationId: row[1],
|
|
350
|
+
encryptedCredentials: row[2],
|
|
351
|
+
credentialHint: row[3],
|
|
352
|
+
credentialStatus: row[4],
|
|
353
|
+
keyVersion: row[5],
|
|
354
|
+
lastRotatedAt: row[6],
|
|
355
|
+
createdAt: row[7],
|
|
356
|
+
updatedAt: row[8]
|
|
357
|
+
};
|
|
358
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weave-typescript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^25.2.0",
|
|
33
33
|
"@types/pg": "^8.15.5",
|
|
34
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
34
|
+
"@typescript/native-preview": "7.0.0-dev.20260416.2"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"test": "node tools/sqlcgen.test.js",
|