weave-typescript 0.5.1 → 0.8.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.
Files changed (31) hide show
  1. package/dist/weaveapi/llmx/v1/architecture.pb.d.ts +377 -0
  2. package/dist/weaveapi/llmx/v1/architecture.pb.js +2756 -0
  3. package/dist/weaveapi/llmx/v1/capabilities.pb.d.ts +320 -0
  4. package/dist/weaveapi/llmx/v1/capabilities.pb.js +2883 -0
  5. package/dist/weaveapi/{modex → llmx}/v1/model.pb.d.ts +85 -31
  6. package/dist/weaveapi/{modex → llmx}/v1/model.pb.js +113 -308
  7. package/dist/weaveapi/{modex → llmx}/v1/provider.pb.d.ts +1 -3
  8. package/dist/weaveapi/{modex → llmx}/v1/provider.pb.js +3 -57
  9. package/dist/weaveapi/{modex → llmx}/v1/service.pb.d.ts +20 -20
  10. package/dist/weaveapi/{modex → llmx}/v1/service.pb.js +17 -17
  11. package/dist/weavesql/llmxdb/capabilities_sql.d.ts +151 -0
  12. package/dist/weavesql/llmxdb/capabilities_sql.js +241 -0
  13. package/dist/weavesql/llmxdb/changes_sql.d.ts +81 -0
  14. package/dist/weavesql/llmxdb/changes_sql.js +118 -0
  15. package/dist/weavesql/llmxdb/models_sql.d.ts +198 -0
  16. package/dist/weavesql/llmxdb/models_sql.js +244 -0
  17. package/dist/weavesql/llmxdb/providers_sql.d.ts +122 -0
  18. package/dist/weavesql/llmxdb/providers_sql.js +179 -0
  19. package/dist/weavesql/llmxdb/scraper_runs_sql.d.ts +83 -0
  20. package/dist/weavesql/llmxdb/scraper_runs_sql.js +137 -0
  21. package/dist/weavesql/llmxdb/search_sql.d.ts +272 -0
  22. package/dist/weavesql/llmxdb/search_sql.js +348 -0
  23. package/dist/weavesql/weavedb/dataset_sql.d.ts +17 -0
  24. package/dist/weavesql/weavedb/dataset_sql.js +21 -0
  25. package/dist/weavesql/weavedb/relationships_sql.d.ts +16 -0
  26. package/dist/weavesql/weavedb/relationships_sql.js +32 -0
  27. package/dist/weavesql/weavedb/storage_sql.d.ts +33 -0
  28. package/dist/weavesql/weavedb/storage_sql.js +54 -0
  29. package/dist/weavesql/weavedb/synthesizer_sql.d.ts +28 -0
  30. package/dist/weavesql/weavedb/synthesizer_sql.js +42 -0
  31. package/package.json +4 -1
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateModelDeprecationQuery = exports.batchUpsertModelsQuery = exports.upsertModelQuery = exports.getModelsByProviderQuery = exports.getModelsQuery = exports.getModelQuery = void 0;
4
+ exports.getModel = getModel;
5
+ exports.getModels = getModels;
6
+ exports.getModelsByProvider = getModelsByProvider;
7
+ exports.upsertModel = upsertModel;
8
+ exports.updateModelDeprecation = updateModelDeprecation;
9
+ exports.getModelQuery = `-- name: GetModel :one
10
+ SELECT id, provider_id, model_id, slug, name, display_name, description, version, capabilities, classification, architecture, performance, token_info, pricing, api_details, training, licensing, safety, availability, technical_specs, release_date, training_data_cutoff, deprecation_date, metadata, last_scraped_at, is_active, is_deprecated, created_at, updated_at
11
+ FROM llm_models
12
+ WHERE slug = $1
13
+ AND is_active = true`;
14
+ async function getModel(client, args) {
15
+ const result = await client.query({
16
+ text: exports.getModelQuery,
17
+ values: [args.slug],
18
+ rowMode: "array"
19
+ });
20
+ if (result.rows.length !== 1) {
21
+ return null;
22
+ }
23
+ const row = result.rows[0];
24
+ return {
25
+ id: row[0],
26
+ providerId: row[1],
27
+ modelId: row[2],
28
+ slug: row[3],
29
+ name: row[4],
30
+ displayName: row[5],
31
+ description: row[6],
32
+ version: row[7],
33
+ capabilities: row[8],
34
+ classification: row[9],
35
+ architecture: row[10],
36
+ performance: row[11],
37
+ tokenInfo: row[12],
38
+ pricing: row[13],
39
+ apiDetails: row[14],
40
+ training: row[15],
41
+ licensing: row[16],
42
+ safety: row[17],
43
+ availability: row[18],
44
+ technicalSpecs: row[19],
45
+ releaseDate: row[20],
46
+ trainingDataCutoff: row[21],
47
+ deprecationDate: row[22],
48
+ metadata: row[23],
49
+ lastScrapedAt: row[24],
50
+ isActive: row[25],
51
+ isDeprecated: row[26],
52
+ createdAt: row[27],
53
+ updatedAt: row[28]
54
+ };
55
+ }
56
+ exports.getModelsQuery = `-- name: GetModels :many
57
+ SELECT id, provider_id, model_id, slug, name, display_name, description, version, capabilities, classification, architecture, performance, token_info, pricing, api_details, training, licensing, safety, availability, technical_specs, release_date, training_data_cutoff, deprecation_date, metadata, last_scraped_at, is_active, is_deprecated, created_at, updated_at
58
+ FROM llm_models
59
+ WHERE is_active = true
60
+ ORDER BY provider_id, name`;
61
+ async function getModels(client) {
62
+ const result = await client.query({
63
+ text: exports.getModelsQuery,
64
+ values: [],
65
+ rowMode: "array"
66
+ });
67
+ return result.rows.map(row => {
68
+ return {
69
+ id: row[0],
70
+ providerId: row[1],
71
+ modelId: row[2],
72
+ slug: row[3],
73
+ name: row[4],
74
+ displayName: row[5],
75
+ description: row[6],
76
+ version: row[7],
77
+ capabilities: row[8],
78
+ classification: row[9],
79
+ architecture: row[10],
80
+ performance: row[11],
81
+ tokenInfo: row[12],
82
+ pricing: row[13],
83
+ apiDetails: row[14],
84
+ training: row[15],
85
+ licensing: row[16],
86
+ safety: row[17],
87
+ availability: row[18],
88
+ technicalSpecs: row[19],
89
+ releaseDate: row[20],
90
+ trainingDataCutoff: row[21],
91
+ deprecationDate: row[22],
92
+ metadata: row[23],
93
+ lastScrapedAt: row[24],
94
+ isActive: row[25],
95
+ isDeprecated: row[26],
96
+ createdAt: row[27],
97
+ updatedAt: row[28]
98
+ };
99
+ });
100
+ }
101
+ exports.getModelsByProviderQuery = `-- name: GetModelsByProvider :many
102
+ SELECT id, provider_id, model_id, slug, name, display_name, description, version, capabilities, classification, architecture, performance, token_info, pricing, api_details, training, licensing, safety, availability, technical_specs, release_date, training_data_cutoff, deprecation_date, metadata, last_scraped_at, is_active, is_deprecated, created_at, updated_at
103
+ FROM llm_models
104
+ WHERE provider_id = $1
105
+ AND is_active = true
106
+ ORDER BY name`;
107
+ async function getModelsByProvider(client, args) {
108
+ const result = await client.query({
109
+ text: exports.getModelsByProviderQuery,
110
+ values: [args.providerId],
111
+ rowMode: "array"
112
+ });
113
+ return result.rows.map(row => {
114
+ return {
115
+ id: row[0],
116
+ providerId: row[1],
117
+ modelId: row[2],
118
+ slug: row[3],
119
+ name: row[4],
120
+ displayName: row[5],
121
+ description: row[6],
122
+ version: row[7],
123
+ capabilities: row[8],
124
+ classification: row[9],
125
+ architecture: row[10],
126
+ performance: row[11],
127
+ tokenInfo: row[12],
128
+ pricing: row[13],
129
+ apiDetails: row[14],
130
+ training: row[15],
131
+ licensing: row[16],
132
+ safety: row[17],
133
+ availability: row[18],
134
+ technicalSpecs: row[19],
135
+ releaseDate: row[20],
136
+ trainingDataCutoff: row[21],
137
+ deprecationDate: row[22],
138
+ metadata: row[23],
139
+ lastScrapedAt: row[24],
140
+ isActive: row[25],
141
+ isDeprecated: row[26],
142
+ createdAt: row[27],
143
+ updatedAt: row[28]
144
+ };
145
+ });
146
+ }
147
+ exports.upsertModelQuery = `-- name: UpsertModel :one
148
+ INSERT INTO llm_models (provider_id, model_id, slug, name, display_name, description, version,
149
+ classification, architecture, capabilities, performance, token_info,
150
+ pricing, api_details, training, licensing, safety, availability,
151
+ technical_specs, release_date, training_data_cutoff, deprecation_date,
152
+ metadata, last_scraped_at)
153
+ VALUES ($1, $2, $3, $4, $5, $6, $7,
154
+ $8, $9, $10, $11, $12,
155
+ $13, $14, $15, $16, $17, $18,
156
+ $19, $20, $21, $22,
157
+ $23, NOW())
158
+ ON CONFLICT (slug) DO UPDATE SET name = EXCLUDED.name,
159
+ display_name = EXCLUDED.display_name,
160
+ description = EXCLUDED.description,
161
+ version = EXCLUDED.version,
162
+ classification = EXCLUDED.classification,
163
+ architecture = EXCLUDED.architecture,
164
+ capabilities = EXCLUDED.capabilities,
165
+ performance = EXCLUDED.performance,
166
+ token_info = EXCLUDED.token_info,
167
+ pricing = EXCLUDED.pricing,
168
+ api_details = EXCLUDED.api_details,
169
+ training = EXCLUDED.training,
170
+ licensing = EXCLUDED.licensing,
171
+ safety = EXCLUDED.safety,
172
+ availability = EXCLUDED.availability,
173
+ technical_specs = EXCLUDED.technical_specs,
174
+ release_date = EXCLUDED.release_date,
175
+ training_data_cutoff = EXCLUDED.training_data_cutoff,
176
+ deprecation_date = EXCLUDED.deprecation_date,
177
+ metadata = EXCLUDED.metadata,
178
+ last_scraped_at = NOW(),
179
+ updated_at = NOW()
180
+ RETURNING id, provider_id, model_id, slug, name, display_name, description, version, capabilities, classification, architecture, performance, token_info, pricing, api_details, training, licensing, safety, availability, technical_specs, release_date, training_data_cutoff, deprecation_date, metadata, last_scraped_at, is_active, is_deprecated, created_at, updated_at`;
181
+ async function upsertModel(client, args) {
182
+ const result = await client.query({
183
+ text: exports.upsertModelQuery,
184
+ values: [args.providerId, args.modelId, args.slug, args.name, args.displayName, args.description, args.version, args.classification, args.architecture, args.capabilities, args.performance, args.tokenInfo, args.pricing, args.apiDetails, args.training, args.licensing, args.safety, args.availability, args.technicalSpecs, args.releaseDate, args.trainingDataCutoff, args.deprecationDate, args.metadata],
185
+ rowMode: "array"
186
+ });
187
+ if (result.rows.length !== 1) {
188
+ return null;
189
+ }
190
+ const row = result.rows[0];
191
+ return {
192
+ id: row[0],
193
+ providerId: row[1],
194
+ modelId: row[2],
195
+ slug: row[3],
196
+ name: row[4],
197
+ displayName: row[5],
198
+ description: row[6],
199
+ version: row[7],
200
+ capabilities: row[8],
201
+ classification: row[9],
202
+ architecture: row[10],
203
+ performance: row[11],
204
+ tokenInfo: row[12],
205
+ pricing: row[13],
206
+ apiDetails: row[14],
207
+ training: row[15],
208
+ licensing: row[16],
209
+ safety: row[17],
210
+ availability: row[18],
211
+ technicalSpecs: row[19],
212
+ releaseDate: row[20],
213
+ trainingDataCutoff: row[21],
214
+ deprecationDate: row[22],
215
+ metadata: row[23],
216
+ lastScrapedAt: row[24],
217
+ isActive: row[25],
218
+ isDeprecated: row[26],
219
+ createdAt: row[27],
220
+ updatedAt: row[28]
221
+ };
222
+ }
223
+ exports.batchUpsertModelsQuery = `-- name: BatchUpsertModels :copyfrom
224
+ INSERT INTO llm_models (provider_id, model_id, slug, name, display_name, description, version,
225
+ classification, architecture, capabilities, performance, token_info,
226
+ pricing, api_details, training, licensing, safety, availability,
227
+ technical_specs, metadata)
228
+ VALUES ($1, $2, $3, $4, $5, $6, $7,
229
+ $8, $9, $10, $11, $12,
230
+ $13, $14, $15, $16, $17, $18,
231
+ $19, $20)`;
232
+ exports.updateModelDeprecationQuery = `-- name: UpdateModelDeprecation :exec
233
+ UPDATE llm_models
234
+ SET is_deprecated = true,
235
+ deprecation_date = $1,
236
+ metadata = jsonb_set(metadata, '{replacement_model_id}', to_jsonb($2::text))
237
+ WHERE slug = $3`;
238
+ async function updateModelDeprecation(client, args) {
239
+ await client.query({
240
+ text: exports.updateModelDeprecationQuery,
241
+ values: [args.deprecationDate, args.replacementModelId, args.slug],
242
+ rowMode: "array"
243
+ });
244
+ }
@@ -0,0 +1,122 @@
1
+ import { QueryArrayConfig, QueryArrayResult } from "pg";
2
+ interface Client {
3
+ query: (config: QueryArrayConfig) => Promise<QueryArrayResult>;
4
+ }
5
+ export declare const getProviderQuery = "-- name: GetProvider :one\nSELECT id, slug, name, display_name, description, website_url, api_base_url, documentation_url, logo_url, provider_type, founding_year, headquarters, api_key_required, oauth_required, api_key_env_var, is_active, is_verified, created_at, updated_at\nFROM providers\nWHERE slug = $1\n AND is_active = true";
6
+ export interface GetProviderArgs {
7
+ slug: string;
8
+ }
9
+ export interface GetProviderRow {
10
+ id: string;
11
+ slug: string;
12
+ name: string;
13
+ displayName: string | null;
14
+ description: string | null;
15
+ websiteUrl: string | null;
16
+ apiBaseUrl: string | null;
17
+ documentationUrl: string | null;
18
+ logoUrl: string | null;
19
+ providerType: string | null;
20
+ foundingYear: number | null;
21
+ headquarters: string | null;
22
+ apiKeyRequired: boolean | null;
23
+ oauthRequired: boolean | null;
24
+ apiKeyEnvVar: string | null;
25
+ isActive: boolean | null;
26
+ isVerified: boolean | null;
27
+ createdAt: Date | null;
28
+ updatedAt: Date | null;
29
+ }
30
+ export declare function getProvider(client: Client, args: GetProviderArgs): Promise<GetProviderRow | null>;
31
+ export declare const getProvidersQuery = "-- name: GetProviders :many\nSELECT id, slug, name, display_name, description, website_url, api_base_url, documentation_url, logo_url, provider_type, founding_year, headquarters, api_key_required, oauth_required, api_key_env_var, is_active, is_verified, created_at, updated_at\nFROM providers\nWHERE is_active = true\nORDER BY name";
32
+ export interface GetProvidersRow {
33
+ id: string;
34
+ slug: string;
35
+ name: string;
36
+ displayName: string | null;
37
+ description: string | null;
38
+ websiteUrl: string | null;
39
+ apiBaseUrl: string | null;
40
+ documentationUrl: string | null;
41
+ logoUrl: string | null;
42
+ providerType: string | null;
43
+ foundingYear: number | null;
44
+ headquarters: string | null;
45
+ apiKeyRequired: boolean | null;
46
+ oauthRequired: boolean | null;
47
+ apiKeyEnvVar: string | null;
48
+ isActive: boolean | null;
49
+ isVerified: boolean | null;
50
+ createdAt: Date | null;
51
+ updatedAt: Date | null;
52
+ }
53
+ export declare function getProviders(client: Client): Promise<GetProvidersRow[]>;
54
+ export declare const getProviderByIDQuery = "-- name: GetProviderByID :one\nSELECT id, slug, name, display_name, description, website_url, api_base_url, documentation_url, logo_url, provider_type, founding_year, headquarters, api_key_required, oauth_required, api_key_env_var, is_active, is_verified, created_at, updated_at\nFROM providers\nWHERE id = $1";
55
+ export interface GetProviderByIDArgs {
56
+ id: string;
57
+ }
58
+ export interface GetProviderByIDRow {
59
+ id: string;
60
+ slug: string;
61
+ name: string;
62
+ displayName: string | null;
63
+ description: string | null;
64
+ websiteUrl: string | null;
65
+ apiBaseUrl: string | null;
66
+ documentationUrl: string | null;
67
+ logoUrl: string | null;
68
+ providerType: string | null;
69
+ foundingYear: number | null;
70
+ headquarters: string | null;
71
+ apiKeyRequired: boolean | null;
72
+ oauthRequired: boolean | null;
73
+ apiKeyEnvVar: string | null;
74
+ isActive: boolean | null;
75
+ isVerified: boolean | null;
76
+ createdAt: Date | null;
77
+ updatedAt: Date | null;
78
+ }
79
+ export declare function getProviderByID(client: Client, args: GetProviderByIDArgs): Promise<GetProviderByIDRow | null>;
80
+ export declare const upsertProviderQuery = "-- name: UpsertProvider :one\nINSERT INTO providers (slug, name, display_name, description,\n website_url, api_base_url, documentation_url, logo_url,\n provider_type, api_key_required, api_key_env_var)\nVALUES ($1, $2, $3, $4,\n $5, $6, $7, $8,\n $9, $10, $11)\nON CONFLICT (slug) DO UPDATE SET name = EXCLUDED.name,\n display_name = EXCLUDED.display_name,\n description = EXCLUDED.description,\n website_url = EXCLUDED.website_url,\n api_base_url = EXCLUDED.api_base_url,\n documentation_url = EXCLUDED.documentation_url,\n logo_url = EXCLUDED.logo_url,\n provider_type = EXCLUDED.provider_type,\n api_key_required = EXCLUDED.api_key_required,\n api_key_env_var = EXCLUDED.api_key_env_var,\n updated_at = NOW()\nRETURNING id, slug, name, display_name, description, website_url, api_base_url, documentation_url, logo_url, provider_type, founding_year, headquarters, api_key_required, oauth_required, api_key_env_var, is_active, is_verified, created_at, updated_at";
81
+ export interface UpsertProviderArgs {
82
+ slug: string;
83
+ name: string;
84
+ displayName: string | null;
85
+ description: string | null;
86
+ websiteUrl: string | null;
87
+ apiBaseUrl: string | null;
88
+ documentationUrl: string | null;
89
+ logoUrl: string | null;
90
+ providerType: string | null;
91
+ apiKeyRequired: boolean | null;
92
+ apiKeyEnvVar: string | null;
93
+ }
94
+ export interface UpsertProviderRow {
95
+ id: string;
96
+ slug: string;
97
+ name: string;
98
+ displayName: string | null;
99
+ description: string | null;
100
+ websiteUrl: string | null;
101
+ apiBaseUrl: string | null;
102
+ documentationUrl: string | null;
103
+ logoUrl: string | null;
104
+ providerType: string | null;
105
+ foundingYear: number | null;
106
+ headquarters: string | null;
107
+ apiKeyRequired: boolean | null;
108
+ oauthRequired: boolean | null;
109
+ apiKeyEnvVar: string | null;
110
+ isActive: boolean | null;
111
+ isVerified: boolean | null;
112
+ createdAt: Date | null;
113
+ updatedAt: Date | null;
114
+ }
115
+ export declare function upsertProvider(client: Client, args: UpsertProviderArgs): Promise<UpsertProviderRow | null>;
116
+ export declare const updateProviderStatusQuery = "-- name: UpdateProviderStatus :exec\nUPDATE providers\nSET is_active = $1,\n updated_at = NOW()\nWHERE slug = $2";
117
+ export interface UpdateProviderStatusArgs {
118
+ isActive: boolean | null;
119
+ slug: string;
120
+ }
121
+ export declare function updateProviderStatus(client: Client, args: UpdateProviderStatusArgs): Promise<void>;
122
+ export {};
@@ -0,0 +1,179 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateProviderStatusQuery = exports.upsertProviderQuery = exports.getProviderByIDQuery = exports.getProvidersQuery = exports.getProviderQuery = void 0;
4
+ exports.getProvider = getProvider;
5
+ exports.getProviders = getProviders;
6
+ exports.getProviderByID = getProviderByID;
7
+ exports.upsertProvider = upsertProvider;
8
+ exports.updateProviderStatus = updateProviderStatus;
9
+ exports.getProviderQuery = `-- name: GetProvider :one
10
+ SELECT id, slug, name, display_name, description, website_url, api_base_url, documentation_url, logo_url, provider_type, founding_year, headquarters, api_key_required, oauth_required, api_key_env_var, is_active, is_verified, created_at, updated_at
11
+ FROM providers
12
+ WHERE slug = $1
13
+ AND is_active = true`;
14
+ async function getProvider(client, args) {
15
+ const result = await client.query({
16
+ text: exports.getProviderQuery,
17
+ values: [args.slug],
18
+ rowMode: "array"
19
+ });
20
+ if (result.rows.length !== 1) {
21
+ return null;
22
+ }
23
+ const row = result.rows[0];
24
+ return {
25
+ id: row[0],
26
+ slug: row[1],
27
+ name: row[2],
28
+ displayName: row[3],
29
+ description: row[4],
30
+ websiteUrl: row[5],
31
+ apiBaseUrl: row[6],
32
+ documentationUrl: row[7],
33
+ logoUrl: row[8],
34
+ providerType: row[9],
35
+ foundingYear: row[10],
36
+ headquarters: row[11],
37
+ apiKeyRequired: row[12],
38
+ oauthRequired: row[13],
39
+ apiKeyEnvVar: row[14],
40
+ isActive: row[15],
41
+ isVerified: row[16],
42
+ createdAt: row[17],
43
+ updatedAt: row[18]
44
+ };
45
+ }
46
+ exports.getProvidersQuery = `-- name: GetProviders :many
47
+ SELECT id, slug, name, display_name, description, website_url, api_base_url, documentation_url, logo_url, provider_type, founding_year, headquarters, api_key_required, oauth_required, api_key_env_var, is_active, is_verified, created_at, updated_at
48
+ FROM providers
49
+ WHERE is_active = true
50
+ ORDER BY name`;
51
+ async function getProviders(client) {
52
+ const result = await client.query({
53
+ text: exports.getProvidersQuery,
54
+ values: [],
55
+ rowMode: "array"
56
+ });
57
+ return result.rows.map(row => {
58
+ return {
59
+ id: row[0],
60
+ slug: row[1],
61
+ name: row[2],
62
+ displayName: row[3],
63
+ description: row[4],
64
+ websiteUrl: row[5],
65
+ apiBaseUrl: row[6],
66
+ documentationUrl: row[7],
67
+ logoUrl: row[8],
68
+ providerType: row[9],
69
+ foundingYear: row[10],
70
+ headquarters: row[11],
71
+ apiKeyRequired: row[12],
72
+ oauthRequired: row[13],
73
+ apiKeyEnvVar: row[14],
74
+ isActive: row[15],
75
+ isVerified: row[16],
76
+ createdAt: row[17],
77
+ updatedAt: row[18]
78
+ };
79
+ });
80
+ }
81
+ exports.getProviderByIDQuery = `-- name: GetProviderByID :one
82
+ SELECT id, slug, name, display_name, description, website_url, api_base_url, documentation_url, logo_url, provider_type, founding_year, headquarters, api_key_required, oauth_required, api_key_env_var, is_active, is_verified, created_at, updated_at
83
+ FROM providers
84
+ WHERE id = $1`;
85
+ async function getProviderByID(client, args) {
86
+ const result = await client.query({
87
+ text: exports.getProviderByIDQuery,
88
+ values: [args.id],
89
+ rowMode: "array"
90
+ });
91
+ if (result.rows.length !== 1) {
92
+ return null;
93
+ }
94
+ const row = result.rows[0];
95
+ return {
96
+ id: row[0],
97
+ slug: row[1],
98
+ name: row[2],
99
+ displayName: row[3],
100
+ description: row[4],
101
+ websiteUrl: row[5],
102
+ apiBaseUrl: row[6],
103
+ documentationUrl: row[7],
104
+ logoUrl: row[8],
105
+ providerType: row[9],
106
+ foundingYear: row[10],
107
+ headquarters: row[11],
108
+ apiKeyRequired: row[12],
109
+ oauthRequired: row[13],
110
+ apiKeyEnvVar: row[14],
111
+ isActive: row[15],
112
+ isVerified: row[16],
113
+ createdAt: row[17],
114
+ updatedAt: row[18]
115
+ };
116
+ }
117
+ exports.upsertProviderQuery = `-- name: UpsertProvider :one
118
+ INSERT INTO providers (slug, name, display_name, description,
119
+ website_url, api_base_url, documentation_url, logo_url,
120
+ provider_type, api_key_required, api_key_env_var)
121
+ VALUES ($1, $2, $3, $4,
122
+ $5, $6, $7, $8,
123
+ $9, $10, $11)
124
+ ON CONFLICT (slug) DO UPDATE SET name = EXCLUDED.name,
125
+ display_name = EXCLUDED.display_name,
126
+ description = EXCLUDED.description,
127
+ website_url = EXCLUDED.website_url,
128
+ api_base_url = EXCLUDED.api_base_url,
129
+ documentation_url = EXCLUDED.documentation_url,
130
+ logo_url = EXCLUDED.logo_url,
131
+ provider_type = EXCLUDED.provider_type,
132
+ api_key_required = EXCLUDED.api_key_required,
133
+ api_key_env_var = EXCLUDED.api_key_env_var,
134
+ updated_at = NOW()
135
+ RETURNING id, slug, name, display_name, description, website_url, api_base_url, documentation_url, logo_url, provider_type, founding_year, headquarters, api_key_required, oauth_required, api_key_env_var, is_active, is_verified, created_at, updated_at`;
136
+ async function upsertProvider(client, args) {
137
+ const result = await client.query({
138
+ text: exports.upsertProviderQuery,
139
+ values: [args.slug, args.name, args.displayName, args.description, args.websiteUrl, args.apiBaseUrl, args.documentationUrl, args.logoUrl, args.providerType, args.apiKeyRequired, args.apiKeyEnvVar],
140
+ rowMode: "array"
141
+ });
142
+ if (result.rows.length !== 1) {
143
+ return null;
144
+ }
145
+ const row = result.rows[0];
146
+ return {
147
+ id: row[0],
148
+ slug: row[1],
149
+ name: row[2],
150
+ displayName: row[3],
151
+ description: row[4],
152
+ websiteUrl: row[5],
153
+ apiBaseUrl: row[6],
154
+ documentationUrl: row[7],
155
+ logoUrl: row[8],
156
+ providerType: row[9],
157
+ foundingYear: row[10],
158
+ headquarters: row[11],
159
+ apiKeyRequired: row[12],
160
+ oauthRequired: row[13],
161
+ apiKeyEnvVar: row[14],
162
+ isActive: row[15],
163
+ isVerified: row[16],
164
+ createdAt: row[17],
165
+ updatedAt: row[18]
166
+ };
167
+ }
168
+ exports.updateProviderStatusQuery = `-- name: UpdateProviderStatus :exec
169
+ UPDATE providers
170
+ SET is_active = $1,
171
+ updated_at = NOW()
172
+ WHERE slug = $2`;
173
+ async function updateProviderStatus(client, args) {
174
+ await client.query({
175
+ text: exports.updateProviderStatusQuery,
176
+ values: [args.isActive, args.slug],
177
+ rowMode: "array"
178
+ });
179
+ }
@@ -0,0 +1,83 @@
1
+ import { QueryArrayConfig, QueryArrayResult } from "pg";
2
+ interface Client {
3
+ query: (config: QueryArrayConfig) => Promise<QueryArrayResult>;
4
+ }
5
+ export declare const createScraperRunQuery = "-- name: CreateScraperRun :one\nINSERT INTO scraper_runs (provider_slug, status)\nVALUES ($1, $2)\nRETURNING id, provider_slug, status, models_found, models_updated, models_added, started_at, completed_at, error_message, created_at";
6
+ export interface CreateScraperRunArgs {
7
+ providerSlug: string | null;
8
+ status: string | null;
9
+ }
10
+ export interface CreateScraperRunRow {
11
+ id: string;
12
+ providerSlug: string | null;
13
+ status: string | null;
14
+ modelsFound: number | null;
15
+ modelsUpdated: number | null;
16
+ modelsAdded: number | null;
17
+ startedAt: Date | null;
18
+ completedAt: Date | null;
19
+ errorMessage: string | null;
20
+ createdAt: Date | null;
21
+ }
22
+ export declare function createScraperRun(client: Client, args: CreateScraperRunArgs): Promise<CreateScraperRunRow | null>;
23
+ export declare const updateScraperRunQuery = "-- name: UpdateScraperRun :exec\nUPDATE scraper_runs\nSET status = $1,\n models_found = $2,\n models_updated = $3,\n models_added = $4,\n completed_at = $5,\n error_message = $6\nWHERE id = $7";
24
+ export interface UpdateScraperRunArgs {
25
+ status: string | null;
26
+ modelsFound: number | null;
27
+ modelsUpdated: number | null;
28
+ modelsAdded: number | null;
29
+ completedAt: Date | null;
30
+ errorMessage: string | null;
31
+ id: string;
32
+ }
33
+ export declare function updateScraperRun(client: Client, args: UpdateScraperRunArgs): Promise<void>;
34
+ export declare const getLastSuccessfulRunQuery = "-- name: GetLastSuccessfulRun :one\nSELECT id, provider_slug, status, models_found, models_updated, models_added, started_at, completed_at, error_message, created_at\nFROM scraper_runs\nWHERE provider_slug = $1\n AND status = 'success'\nORDER BY completed_at DESC\nLIMIT 1";
35
+ export interface GetLastSuccessfulRunArgs {
36
+ providerSlug: string | null;
37
+ }
38
+ export interface GetLastSuccessfulRunRow {
39
+ id: string;
40
+ providerSlug: string | null;
41
+ status: string | null;
42
+ modelsFound: number | null;
43
+ modelsUpdated: number | null;
44
+ modelsAdded: number | null;
45
+ startedAt: Date | null;
46
+ completedAt: Date | null;
47
+ errorMessage: string | null;
48
+ createdAt: Date | null;
49
+ }
50
+ export declare function getLastSuccessfulRun(client: Client, args: GetLastSuccessfulRunArgs): Promise<GetLastSuccessfulRunRow | null>;
51
+ export declare const getRecentRunsQuery = "-- name: GetRecentRuns :many\nSELECT id, provider_slug, status, models_found, models_updated, models_added, started_at, completed_at, error_message, created_at\nFROM scraper_runs\nWHERE ($1::text IS NULL OR provider_slug = $1)\nORDER BY created_at DESC\nLIMIT $2";
52
+ export interface GetRecentRunsArgs {
53
+ providerSlug: string;
54
+ limitCount: string;
55
+ }
56
+ export interface GetRecentRunsRow {
57
+ id: string;
58
+ providerSlug: string | null;
59
+ status: string | null;
60
+ modelsFound: number | null;
61
+ modelsUpdated: number | null;
62
+ modelsAdded: number | null;
63
+ startedAt: Date | null;
64
+ completedAt: Date | null;
65
+ errorMessage: string | null;
66
+ createdAt: Date | null;
67
+ }
68
+ export declare function getRecentRuns(client: Client, args: GetRecentRunsArgs): Promise<GetRecentRunsRow[]>;
69
+ export declare const getRunStatsQuery = "-- name: GetRunStats :one\nSELECT COUNT(*) as total_runs,\n COUNT(*) FILTER (WHERE status = 'success') as successful_runs,\n COUNT(*) FILTER (WHERE status = 'failed') as failed_runs,\n AVG(EXTRACT(EPOCH FROM (completed_at - started_at))) as avg_duration_seconds,\n SUM(models_added) as total_models_added,\n SUM(models_updated) as total_models_updated\nFROM scraper_runs\nWHERE created_at > $1\n AND ($2::text IS NULL OR provider_slug = $2)";
70
+ export interface GetRunStatsArgs {
71
+ since: Date | null;
72
+ providerSlug: string;
73
+ }
74
+ export interface GetRunStatsRow {
75
+ totalRuns: string;
76
+ successfulRuns: string;
77
+ failedRuns: string;
78
+ avgDurationSeconds: string;
79
+ totalModelsAdded: string;
80
+ totalModelsUpdated: string;
81
+ }
82
+ export declare function getRunStats(client: Client, args: GetRunStatsArgs): Promise<GetRunStatsRow | null>;
83
+ export {};