weave-typescript 0.15.0 → 0.16.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.
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteWorkflowTemplateQuery = exports.updateWorkflowTemplateQuery = exports.listWorkflowTemplatesQuery = exports.getWorkflowTemplateByNameQuery = exports.getWorkflowTemplateQuery = exports.insertWorkflowTemplateQuery = void 0;
4
+ exports.insertWorkflowTemplate = insertWorkflowTemplate;
5
+ exports.getWorkflowTemplate = getWorkflowTemplate;
6
+ exports.getWorkflowTemplateByName = getWorkflowTemplateByName;
7
+ exports.listWorkflowTemplates = listWorkflowTemplates;
8
+ exports.updateWorkflowTemplate = updateWorkflowTemplate;
9
+ exports.deleteWorkflowTemplate = deleteWorkflowTemplate;
10
+ exports.insertWorkflowTemplateQuery = `-- name: InsertWorkflowTemplate :one
11
+ INSERT INTO atc.workflow_templates (
12
+ id,
13
+ tenant_id,
14
+ name,
15
+ version,
16
+ handler_type,
17
+ config,
18
+ security_context,
19
+ budget_context,
20
+ pinned_caller,
21
+ created_by
22
+ ) VALUES (
23
+ $1,
24
+ $2,
25
+ $3,
26
+ $4,
27
+ $5,
28
+ $6,
29
+ $7,
30
+ $8,
31
+ $9,
32
+ $10
33
+ )
34
+ RETURNING id, tenant_id, name, version, handler_type, config, security_context, budget_context, pinned_caller, created_by, created_at, updated_at`;
35
+ async function insertWorkflowTemplate(client, args) {
36
+ const result = await client.query({
37
+ text: exports.insertWorkflowTemplateQuery,
38
+ values: [args.id, args.tenantId, args.name, args.version, args.handlerType, args.config, args.securityContext, args.budgetContext, args.pinnedCaller, args.createdBy],
39
+ rowMode: "array"
40
+ });
41
+ if (result.rows.length !== 1) {
42
+ return null;
43
+ }
44
+ const row = result.rows[0];
45
+ return {
46
+ id: row[0],
47
+ tenantId: row[1],
48
+ name: row[2],
49
+ version: row[3],
50
+ handlerType: row[4],
51
+ config: row[5],
52
+ securityContext: row[6],
53
+ budgetContext: row[7],
54
+ pinnedCaller: row[8],
55
+ createdBy: row[9],
56
+ createdAt: row[10],
57
+ updatedAt: row[11]
58
+ };
59
+ }
60
+ exports.getWorkflowTemplateQuery = `-- name: GetWorkflowTemplate :one
61
+ SELECT id, tenant_id, name, version, handler_type, config, security_context, budget_context, pinned_caller, created_by, created_at, updated_at
62
+ FROM atc.workflow_templates
63
+ WHERE tenant_id = $1
64
+ AND id = $2`;
65
+ async function getWorkflowTemplate(client, args) {
66
+ const result = await client.query({
67
+ text: exports.getWorkflowTemplateQuery,
68
+ values: [args.tenantId, args.id],
69
+ rowMode: "array"
70
+ });
71
+ if (result.rows.length !== 1) {
72
+ return null;
73
+ }
74
+ const row = result.rows[0];
75
+ return {
76
+ id: row[0],
77
+ tenantId: row[1],
78
+ name: row[2],
79
+ version: row[3],
80
+ handlerType: row[4],
81
+ config: row[5],
82
+ securityContext: row[6],
83
+ budgetContext: row[7],
84
+ pinnedCaller: row[8],
85
+ createdBy: row[9],
86
+ createdAt: row[10],
87
+ updatedAt: row[11]
88
+ };
89
+ }
90
+ exports.getWorkflowTemplateByNameQuery = `-- name: GetWorkflowTemplateByName :one
91
+ SELECT id, tenant_id, name, version, handler_type, config, security_context, budget_context, pinned_caller, created_by, created_at, updated_at
92
+ FROM atc.workflow_templates
93
+ WHERE tenant_id = $1
94
+ AND name = $2
95
+ ORDER BY version DESC
96
+ LIMIT 1`;
97
+ async function getWorkflowTemplateByName(client, args) {
98
+ const result = await client.query({
99
+ text: exports.getWorkflowTemplateByNameQuery,
100
+ values: [args.tenantId, args.name],
101
+ rowMode: "array"
102
+ });
103
+ if (result.rows.length !== 1) {
104
+ return null;
105
+ }
106
+ const row = result.rows[0];
107
+ return {
108
+ id: row[0],
109
+ tenantId: row[1],
110
+ name: row[2],
111
+ version: row[3],
112
+ handlerType: row[4],
113
+ config: row[5],
114
+ securityContext: row[6],
115
+ budgetContext: row[7],
116
+ pinnedCaller: row[8],
117
+ createdBy: row[9],
118
+ createdAt: row[10],
119
+ updatedAt: row[11]
120
+ };
121
+ }
122
+ exports.listWorkflowTemplatesQuery = `-- name: ListWorkflowTemplates :many
123
+ SELECT id, tenant_id, name, version, handler_type, config, security_context, budget_context, pinned_caller, created_by, created_at, updated_at
124
+ FROM atc.workflow_templates
125
+ WHERE tenant_id = $1
126
+ ORDER BY name ASC, version DESC`;
127
+ async function listWorkflowTemplates(client, args) {
128
+ const result = await client.query({
129
+ text: exports.listWorkflowTemplatesQuery,
130
+ values: [args.tenantId],
131
+ rowMode: "array"
132
+ });
133
+ return result.rows.map(row => {
134
+ return {
135
+ id: row[0],
136
+ tenantId: row[1],
137
+ name: row[2],
138
+ version: row[3],
139
+ handlerType: row[4],
140
+ config: row[5],
141
+ securityContext: row[6],
142
+ budgetContext: row[7],
143
+ pinnedCaller: row[8],
144
+ createdBy: row[9],
145
+ createdAt: row[10],
146
+ updatedAt: row[11]
147
+ };
148
+ });
149
+ }
150
+ exports.updateWorkflowTemplateQuery = `-- name: UpdateWorkflowTemplate :one
151
+ UPDATE atc.workflow_templates
152
+ SET
153
+ config = $1,
154
+ security_context = $2,
155
+ budget_context = $3,
156
+ pinned_caller = $4,
157
+ version = version + 1,
158
+ updated_at = now()
159
+ WHERE tenant_id = $5
160
+ AND id = $6
161
+ RETURNING id, tenant_id, name, version, handler_type, config, security_context, budget_context, pinned_caller, created_by, created_at, updated_at`;
162
+ async function updateWorkflowTemplate(client, args) {
163
+ const result = await client.query({
164
+ text: exports.updateWorkflowTemplateQuery,
165
+ values: [args.config, args.securityContext, args.budgetContext, args.pinnedCaller, args.tenantId, args.id],
166
+ rowMode: "array"
167
+ });
168
+ if (result.rows.length !== 1) {
169
+ return null;
170
+ }
171
+ const row = result.rows[0];
172
+ return {
173
+ id: row[0],
174
+ tenantId: row[1],
175
+ name: row[2],
176
+ version: row[3],
177
+ handlerType: row[4],
178
+ config: row[5],
179
+ securityContext: row[6],
180
+ budgetContext: row[7],
181
+ pinnedCaller: row[8],
182
+ createdBy: row[9],
183
+ createdAt: row[10],
184
+ updatedAt: row[11]
185
+ };
186
+ }
187
+ exports.deleteWorkflowTemplateQuery = `-- name: DeleteWorkflowTemplate :exec
188
+ DELETE FROM atc.workflow_templates
189
+ WHERE tenant_id = $1
190
+ AND id = $2`;
191
+ async function deleteWorkflowTemplate(client, args) {
192
+ await client.query({
193
+ text: exports.deleteWorkflowTemplateQuery,
194
+ values: [args.tenantId, args.id],
195
+ rowMode: "array"
196
+ });
197
+ }
@@ -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 {};