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.
- package/dist/weaveapi/llmx/v1/architecture.pb.d.ts +377 -0
- package/dist/weaveapi/llmx/v1/architecture.pb.js +2756 -0
- package/dist/weaveapi/llmx/v1/capabilities.pb.d.ts +320 -0
- package/dist/weaveapi/llmx/v1/capabilities.pb.js +2883 -0
- package/dist/weaveapi/{modex → llmx}/v1/model.pb.d.ts +85 -31
- package/dist/weaveapi/{modex → llmx}/v1/model.pb.js +113 -308
- package/dist/weaveapi/{modex → llmx}/v1/provider.pb.d.ts +1 -3
- package/dist/weaveapi/{modex → llmx}/v1/provider.pb.js +3 -57
- package/dist/weaveapi/{modex → llmx}/v1/service.pb.d.ts +20 -20
- package/dist/weaveapi/{modex → llmx}/v1/service.pb.js +17 -17
- package/dist/weavesql/llmxdb/capabilities_sql.d.ts +151 -0
- package/dist/weavesql/llmxdb/capabilities_sql.js +241 -0
- package/dist/weavesql/llmxdb/changes_sql.d.ts +81 -0
- package/dist/weavesql/llmxdb/changes_sql.js +118 -0
- package/dist/weavesql/llmxdb/models_sql.d.ts +198 -0
- package/dist/weavesql/llmxdb/models_sql.js +244 -0
- package/dist/weavesql/llmxdb/providers_sql.d.ts +122 -0
- package/dist/weavesql/llmxdb/providers_sql.js +179 -0
- package/dist/weavesql/llmxdb/scraper_runs_sql.d.ts +83 -0
- package/dist/weavesql/llmxdb/scraper_runs_sql.js +137 -0
- package/dist/weavesql/llmxdb/search_sql.d.ts +272 -0
- package/dist/weavesql/llmxdb/search_sql.js +348 -0
- package/dist/weavesql/weavedb/dataset_sql.d.ts +17 -0
- package/dist/weavesql/weavedb/dataset_sql.js +21 -0
- package/dist/weavesql/weavedb/relationships_sql.d.ts +16 -0
- package/dist/weavesql/weavedb/relationships_sql.js +32 -0
- package/dist/weavesql/weavedb/storage_sql.d.ts +33 -0
- package/dist/weavesql/weavedb/storage_sql.js +54 -0
- package/dist/weavesql/weavedb/synthesizer_sql.d.ts +28 -0
- package/dist/weavesql/weavedb/synthesizer_sql.js +42 -0
- package/package.json +4 -1
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getModelsByPriceRangeQuery = exports.getModelsByContextWindowQuery = exports.getModelsByParameterCountQuery = exports.getModelsBySafetyQuery = exports.getOpenSourceModelsQuery = exports.searchModelsByArchitectureQuery = exports.searchModelsQuery = void 0;
|
|
4
|
+
exports.searchModels = searchModels;
|
|
5
|
+
exports.searchModelsByArchitecture = searchModelsByArchitecture;
|
|
6
|
+
exports.getOpenSourceModels = getOpenSourceModels;
|
|
7
|
+
exports.getModelsBySafety = getModelsBySafety;
|
|
8
|
+
exports.getModelsByParameterCount = getModelsByParameterCount;
|
|
9
|
+
exports.getModelsByContextWindow = getModelsByContextWindow;
|
|
10
|
+
exports.getModelsByPriceRange = getModelsByPriceRange;
|
|
11
|
+
exports.searchModelsQuery = `-- name: SearchModels :many
|
|
12
|
+
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
|
|
13
|
+
FROM llm_models
|
|
14
|
+
WHERE is_active = true
|
|
15
|
+
AND ($1::uuid IS NULL OR provider_id = $1)
|
|
16
|
+
AND ($2::text IS NULL OR classification ->> 'model_type' = $2)
|
|
17
|
+
AND ($3::int IS NULL OR (token_info ->> 'context_window')::int >= $3)
|
|
18
|
+
AND ($4::numeric IS NULL OR (pricing ->> 'input_price')::numeric <= $4)
|
|
19
|
+
AND ($5::text IS NULL OR capabilities->'configs' ? $5)
|
|
20
|
+
ORDER BY CASE WHEN $6 = 'price' THEN (pricing ->> 'input_price')::numeric END ASC,
|
|
21
|
+
CASE WHEN $6 = 'context' THEN (token_info ->> 'context_window')::int END DESC,
|
|
22
|
+
name ASC
|
|
23
|
+
LIMIT $8 OFFSET $7`;
|
|
24
|
+
async function searchModels(client, args) {
|
|
25
|
+
const result = await client.query({
|
|
26
|
+
text: exports.searchModelsQuery,
|
|
27
|
+
values: [args.providerId, args.modelType, args.minContext, args.maxInputPrice, args.hasCapability, args.orderBy, args.offsetCount, args.limitCount],
|
|
28
|
+
rowMode: "array"
|
|
29
|
+
});
|
|
30
|
+
return result.rows.map(row => {
|
|
31
|
+
return {
|
|
32
|
+
id: row[0],
|
|
33
|
+
providerId: row[1],
|
|
34
|
+
modelId: row[2],
|
|
35
|
+
slug: row[3],
|
|
36
|
+
name: row[4],
|
|
37
|
+
displayName: row[5],
|
|
38
|
+
description: row[6],
|
|
39
|
+
version: row[7],
|
|
40
|
+
capabilities: row[8],
|
|
41
|
+
classification: row[9],
|
|
42
|
+
architecture: row[10],
|
|
43
|
+
performance: row[11],
|
|
44
|
+
tokenInfo: row[12],
|
|
45
|
+
pricing: row[13],
|
|
46
|
+
apiDetails: row[14],
|
|
47
|
+
training: row[15],
|
|
48
|
+
licensing: row[16],
|
|
49
|
+
safety: row[17],
|
|
50
|
+
availability: row[18],
|
|
51
|
+
technicalSpecs: row[19],
|
|
52
|
+
releaseDate: row[20],
|
|
53
|
+
trainingDataCutoff: row[21],
|
|
54
|
+
deprecationDate: row[22],
|
|
55
|
+
metadata: row[23],
|
|
56
|
+
lastScrapedAt: row[24],
|
|
57
|
+
isActive: row[25],
|
|
58
|
+
isDeprecated: row[26],
|
|
59
|
+
createdAt: row[27],
|
|
60
|
+
updatedAt: row[28]
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
exports.searchModelsByArchitectureQuery = `-- name: SearchModelsByArchitecture :many
|
|
65
|
+
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
|
|
66
|
+
FROM llm_models
|
|
67
|
+
WHERE is_active = true
|
|
68
|
+
AND ($1::text IS NULL OR architecture->>'base_architecture' = $1)
|
|
69
|
+
AND ($2::bigint IS NULL OR (architecture->>'parameter_count')::bigint >= $2)
|
|
70
|
+
AND ($3::bigint IS NULL OR (architecture->>'parameter_count')::bigint <= $3)
|
|
71
|
+
AND ($4::boolean IS NULL OR (architecture->>'is_mixture_of_experts')::boolean = $4)
|
|
72
|
+
ORDER BY (architecture->>'parameter_count')::bigint DESC`;
|
|
73
|
+
async function searchModelsByArchitecture(client, args) {
|
|
74
|
+
const result = await client.query({
|
|
75
|
+
text: exports.searchModelsByArchitectureQuery,
|
|
76
|
+
values: [args.baseArchitecture, args.minParams, args.maxParams, args.isMoe],
|
|
77
|
+
rowMode: "array"
|
|
78
|
+
});
|
|
79
|
+
return result.rows.map(row => {
|
|
80
|
+
return {
|
|
81
|
+
id: row[0],
|
|
82
|
+
providerId: row[1],
|
|
83
|
+
modelId: row[2],
|
|
84
|
+
slug: row[3],
|
|
85
|
+
name: row[4],
|
|
86
|
+
displayName: row[5],
|
|
87
|
+
description: row[6],
|
|
88
|
+
version: row[7],
|
|
89
|
+
capabilities: row[8],
|
|
90
|
+
classification: row[9],
|
|
91
|
+
architecture: row[10],
|
|
92
|
+
performance: row[11],
|
|
93
|
+
tokenInfo: row[12],
|
|
94
|
+
pricing: row[13],
|
|
95
|
+
apiDetails: row[14],
|
|
96
|
+
training: row[15],
|
|
97
|
+
licensing: row[16],
|
|
98
|
+
safety: row[17],
|
|
99
|
+
availability: row[18],
|
|
100
|
+
technicalSpecs: row[19],
|
|
101
|
+
releaseDate: row[20],
|
|
102
|
+
trainingDataCutoff: row[21],
|
|
103
|
+
deprecationDate: row[22],
|
|
104
|
+
metadata: row[23],
|
|
105
|
+
lastScrapedAt: row[24],
|
|
106
|
+
isActive: row[25],
|
|
107
|
+
isDeprecated: row[26],
|
|
108
|
+
createdAt: row[27],
|
|
109
|
+
updatedAt: row[28]
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
exports.getOpenSourceModelsQuery = `-- name: GetOpenSourceModels :many
|
|
114
|
+
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
|
|
115
|
+
FROM llm_models
|
|
116
|
+
WHERE is_active = true
|
|
117
|
+
AND (licensing->>'is_open_source')::boolean = true
|
|
118
|
+
AND ($1::boolean IS NULL OR (licensing->>'commercial_use')::boolean = $1)
|
|
119
|
+
ORDER BY provider_id, name`;
|
|
120
|
+
async function getOpenSourceModels(client, args) {
|
|
121
|
+
const result = await client.query({
|
|
122
|
+
text: exports.getOpenSourceModelsQuery,
|
|
123
|
+
values: [args.commercialUse],
|
|
124
|
+
rowMode: "array"
|
|
125
|
+
});
|
|
126
|
+
return result.rows.map(row => {
|
|
127
|
+
return {
|
|
128
|
+
id: row[0],
|
|
129
|
+
providerId: row[1],
|
|
130
|
+
modelId: row[2],
|
|
131
|
+
slug: row[3],
|
|
132
|
+
name: row[4],
|
|
133
|
+
displayName: row[5],
|
|
134
|
+
description: row[6],
|
|
135
|
+
version: row[7],
|
|
136
|
+
capabilities: row[8],
|
|
137
|
+
classification: row[9],
|
|
138
|
+
architecture: row[10],
|
|
139
|
+
performance: row[11],
|
|
140
|
+
tokenInfo: row[12],
|
|
141
|
+
pricing: row[13],
|
|
142
|
+
apiDetails: row[14],
|
|
143
|
+
training: row[15],
|
|
144
|
+
licensing: row[16],
|
|
145
|
+
safety: row[17],
|
|
146
|
+
availability: row[18],
|
|
147
|
+
technicalSpecs: row[19],
|
|
148
|
+
releaseDate: row[20],
|
|
149
|
+
trainingDataCutoff: row[21],
|
|
150
|
+
deprecationDate: row[22],
|
|
151
|
+
metadata: row[23],
|
|
152
|
+
lastScrapedAt: row[24],
|
|
153
|
+
isActive: row[25],
|
|
154
|
+
isDeprecated: row[26],
|
|
155
|
+
createdAt: row[27],
|
|
156
|
+
updatedAt: row[28]
|
|
157
|
+
};
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
exports.getModelsBySafetyQuery = `-- name: GetModelsBySafety :many
|
|
161
|
+
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
|
|
162
|
+
FROM llm_models
|
|
163
|
+
WHERE is_active = true
|
|
164
|
+
AND ($1::text IS NULL OR safety->>'moderation_level' = $1)
|
|
165
|
+
AND ($2::boolean IS NULL OR (safety->>'gdpr_compliant')::boolean = $2)
|
|
166
|
+
AND ($3::boolean IS NULL OR (safety->>'hipaa_compliant')::boolean = $3)
|
|
167
|
+
ORDER BY provider_id, name`;
|
|
168
|
+
async function getModelsBySafety(client, args) {
|
|
169
|
+
const result = await client.query({
|
|
170
|
+
text: exports.getModelsBySafetyQuery,
|
|
171
|
+
values: [args.moderationLevel, args.gdprCompliant, args.hipaaCompliant],
|
|
172
|
+
rowMode: "array"
|
|
173
|
+
});
|
|
174
|
+
return result.rows.map(row => {
|
|
175
|
+
return {
|
|
176
|
+
id: row[0],
|
|
177
|
+
providerId: row[1],
|
|
178
|
+
modelId: row[2],
|
|
179
|
+
slug: row[3],
|
|
180
|
+
name: row[4],
|
|
181
|
+
displayName: row[5],
|
|
182
|
+
description: row[6],
|
|
183
|
+
version: row[7],
|
|
184
|
+
capabilities: row[8],
|
|
185
|
+
classification: row[9],
|
|
186
|
+
architecture: row[10],
|
|
187
|
+
performance: row[11],
|
|
188
|
+
tokenInfo: row[12],
|
|
189
|
+
pricing: row[13],
|
|
190
|
+
apiDetails: row[14],
|
|
191
|
+
training: row[15],
|
|
192
|
+
licensing: row[16],
|
|
193
|
+
safety: row[17],
|
|
194
|
+
availability: row[18],
|
|
195
|
+
technicalSpecs: row[19],
|
|
196
|
+
releaseDate: row[20],
|
|
197
|
+
trainingDataCutoff: row[21],
|
|
198
|
+
deprecationDate: row[22],
|
|
199
|
+
metadata: row[23],
|
|
200
|
+
lastScrapedAt: row[24],
|
|
201
|
+
isActive: row[25],
|
|
202
|
+
isDeprecated: row[26],
|
|
203
|
+
createdAt: row[27],
|
|
204
|
+
updatedAt: row[28]
|
|
205
|
+
};
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
exports.getModelsByParameterCountQuery = `-- name: GetModelsByParameterCount :many
|
|
209
|
+
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
|
|
210
|
+
FROM llm_models
|
|
211
|
+
WHERE is_active = true
|
|
212
|
+
AND ($1::bigint IS NULL OR (architecture->>'parameter_count')::bigint >= $1)
|
|
213
|
+
AND ($2::bigint IS NULL OR (architecture->>'parameter_count')::bigint <= $2)
|
|
214
|
+
ORDER BY (architecture->>'parameter_count')::bigint DESC`;
|
|
215
|
+
async function getModelsByParameterCount(client, args) {
|
|
216
|
+
const result = await client.query({
|
|
217
|
+
text: exports.getModelsByParameterCountQuery,
|
|
218
|
+
values: [args.minParams, args.maxParams],
|
|
219
|
+
rowMode: "array"
|
|
220
|
+
});
|
|
221
|
+
return result.rows.map(row => {
|
|
222
|
+
return {
|
|
223
|
+
id: row[0],
|
|
224
|
+
providerId: row[1],
|
|
225
|
+
modelId: row[2],
|
|
226
|
+
slug: row[3],
|
|
227
|
+
name: row[4],
|
|
228
|
+
displayName: row[5],
|
|
229
|
+
description: row[6],
|
|
230
|
+
version: row[7],
|
|
231
|
+
capabilities: row[8],
|
|
232
|
+
classification: row[9],
|
|
233
|
+
architecture: row[10],
|
|
234
|
+
performance: row[11],
|
|
235
|
+
tokenInfo: row[12],
|
|
236
|
+
pricing: row[13],
|
|
237
|
+
apiDetails: row[14],
|
|
238
|
+
training: row[15],
|
|
239
|
+
licensing: row[16],
|
|
240
|
+
safety: row[17],
|
|
241
|
+
availability: row[18],
|
|
242
|
+
technicalSpecs: row[19],
|
|
243
|
+
releaseDate: row[20],
|
|
244
|
+
trainingDataCutoff: row[21],
|
|
245
|
+
deprecationDate: row[22],
|
|
246
|
+
metadata: row[23],
|
|
247
|
+
lastScrapedAt: row[24],
|
|
248
|
+
isActive: row[25],
|
|
249
|
+
isDeprecated: row[26],
|
|
250
|
+
createdAt: row[27],
|
|
251
|
+
updatedAt: row[28]
|
|
252
|
+
};
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
exports.getModelsByContextWindowQuery = `-- name: GetModelsByContextWindow :many
|
|
256
|
+
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
|
|
257
|
+
FROM llm_models
|
|
258
|
+
WHERE is_active = true
|
|
259
|
+
AND ($1::int IS NULL OR (token_info->>'context_window')::int >= $1)
|
|
260
|
+
AND ($2::int IS NULL OR (token_info->>'context_window')::int <= $2)
|
|
261
|
+
ORDER BY (token_info->>'context_window')::int DESC`;
|
|
262
|
+
async function getModelsByContextWindow(client, args) {
|
|
263
|
+
const result = await client.query({
|
|
264
|
+
text: exports.getModelsByContextWindowQuery,
|
|
265
|
+
values: [args.minContext, args.maxContext],
|
|
266
|
+
rowMode: "array"
|
|
267
|
+
});
|
|
268
|
+
return result.rows.map(row => {
|
|
269
|
+
return {
|
|
270
|
+
id: row[0],
|
|
271
|
+
providerId: row[1],
|
|
272
|
+
modelId: row[2],
|
|
273
|
+
slug: row[3],
|
|
274
|
+
name: row[4],
|
|
275
|
+
displayName: row[5],
|
|
276
|
+
description: row[6],
|
|
277
|
+
version: row[7],
|
|
278
|
+
capabilities: row[8],
|
|
279
|
+
classification: row[9],
|
|
280
|
+
architecture: row[10],
|
|
281
|
+
performance: row[11],
|
|
282
|
+
tokenInfo: row[12],
|
|
283
|
+
pricing: row[13],
|
|
284
|
+
apiDetails: row[14],
|
|
285
|
+
training: row[15],
|
|
286
|
+
licensing: row[16],
|
|
287
|
+
safety: row[17],
|
|
288
|
+
availability: row[18],
|
|
289
|
+
technicalSpecs: row[19],
|
|
290
|
+
releaseDate: row[20],
|
|
291
|
+
trainingDataCutoff: row[21],
|
|
292
|
+
deprecationDate: row[22],
|
|
293
|
+
metadata: row[23],
|
|
294
|
+
lastScrapedAt: row[24],
|
|
295
|
+
isActive: row[25],
|
|
296
|
+
isDeprecated: row[26],
|
|
297
|
+
createdAt: row[27],
|
|
298
|
+
updatedAt: row[28]
|
|
299
|
+
};
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
exports.getModelsByPriceRangeQuery = `-- name: GetModelsByPriceRange :many
|
|
303
|
+
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
|
|
304
|
+
FROM llm_models
|
|
305
|
+
WHERE is_active = true
|
|
306
|
+
AND ($1::numeric IS NULL OR (pricing->>'input_price')::numeric <= $1)
|
|
307
|
+
AND ($2::numeric IS NULL OR (pricing->>'output_price')::numeric <= $2)
|
|
308
|
+
ORDER BY (pricing->>'input_price')::numeric ASC`;
|
|
309
|
+
async function getModelsByPriceRange(client, args) {
|
|
310
|
+
const result = await client.query({
|
|
311
|
+
text: exports.getModelsByPriceRangeQuery,
|
|
312
|
+
values: [args.maxInputPrice, args.maxOutputPrice],
|
|
313
|
+
rowMode: "array"
|
|
314
|
+
});
|
|
315
|
+
return result.rows.map(row => {
|
|
316
|
+
return {
|
|
317
|
+
id: row[0],
|
|
318
|
+
providerId: row[1],
|
|
319
|
+
modelId: row[2],
|
|
320
|
+
slug: row[3],
|
|
321
|
+
name: row[4],
|
|
322
|
+
displayName: row[5],
|
|
323
|
+
description: row[6],
|
|
324
|
+
version: row[7],
|
|
325
|
+
capabilities: row[8],
|
|
326
|
+
classification: row[9],
|
|
327
|
+
architecture: row[10],
|
|
328
|
+
performance: row[11],
|
|
329
|
+
tokenInfo: row[12],
|
|
330
|
+
pricing: row[13],
|
|
331
|
+
apiDetails: row[14],
|
|
332
|
+
training: row[15],
|
|
333
|
+
licensing: row[16],
|
|
334
|
+
safety: row[17],
|
|
335
|
+
availability: row[18],
|
|
336
|
+
technicalSpecs: row[19],
|
|
337
|
+
releaseDate: row[20],
|
|
338
|
+
trainingDataCutoff: row[21],
|
|
339
|
+
deprecationDate: row[22],
|
|
340
|
+
metadata: row[23],
|
|
341
|
+
lastScrapedAt: row[24],
|
|
342
|
+
isActive: row[25],
|
|
343
|
+
isDeprecated: row[26],
|
|
344
|
+
createdAt: row[27],
|
|
345
|
+
updatedAt: row[28]
|
|
346
|
+
};
|
|
347
|
+
});
|
|
348
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { QueryArrayConfig, QueryArrayResult } from "pg";
|
|
2
|
+
interface Client {
|
|
3
|
+
query: (config: QueryArrayConfig) => Promise<QueryArrayResult>;
|
|
4
|
+
}
|
|
5
|
+
export declare const upsertDatasetQuery = "-- name: UpsertDataset :exec\nINSERT INTO generate_v1.dataset (id, organization_id, name, description, storage_connection_id, schema_id,\n synthesizer_id, is_synthetic)\nVALUES ($1, $2, $3, $4, $5, $6, $7, $8)\nON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name,\n description = EXCLUDED.description,\n storage_connection_id = EXCLUDED.storage_connection_id,\n schema_id = EXCLUDED.schema_id,\n synthesizer_id = EXCLUDED.synthesizer_id,\n is_synthetic = EXCLUDED.is_synthetic";
|
|
6
|
+
export interface UpsertDatasetArgs {
|
|
7
|
+
id: string;
|
|
8
|
+
organizationId: string;
|
|
9
|
+
name: string;
|
|
10
|
+
description: string | null;
|
|
11
|
+
storageConnectionId: string;
|
|
12
|
+
schemaId: string | null;
|
|
13
|
+
synthesizerId: string | null;
|
|
14
|
+
isSynthetic: boolean | null;
|
|
15
|
+
}
|
|
16
|
+
export declare function upsertDataset(client: Client, args: UpsertDatasetArgs): Promise<void>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.upsertDatasetQuery = void 0;
|
|
4
|
+
exports.upsertDataset = upsertDataset;
|
|
5
|
+
exports.upsertDatasetQuery = `-- name: UpsertDataset :exec
|
|
6
|
+
INSERT INTO generate_v1.dataset (id, organization_id, name, description, storage_connection_id, schema_id,
|
|
7
|
+
synthesizer_id, is_synthetic)
|
|
8
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
9
|
+
ON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name,
|
|
10
|
+
description = EXCLUDED.description,
|
|
11
|
+
storage_connection_id = EXCLUDED.storage_connection_id,
|
|
12
|
+
schema_id = EXCLUDED.schema_id,
|
|
13
|
+
synthesizer_id = EXCLUDED.synthesizer_id,
|
|
14
|
+
is_synthetic = EXCLUDED.is_synthetic`;
|
|
15
|
+
async function upsertDataset(client, args) {
|
|
16
|
+
await client.query({
|
|
17
|
+
text: exports.upsertDatasetQuery,
|
|
18
|
+
values: [args.id, args.organizationId, args.name, args.description, args.storageConnectionId, args.schemaId, args.synthesizerId, args.isSynthetic],
|
|
19
|
+
rowMode: "array"
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { QueryArrayConfig, QueryArrayResult } from "pg";
|
|
2
|
+
interface Client {
|
|
3
|
+
query: (config: QueryArrayConfig) => Promise<QueryArrayResult>;
|
|
4
|
+
}
|
|
5
|
+
export declare const getForeignKeyRelationshipsQuery = "-- name: GetForeignKeyRelationships :many\nSELECT cr.source_dataset_id,\n cr.target_dataset_id,\n sc.name AS source_column_name,\n tc.name AS target_column_name\nFROM synthesize_v1.column_relationship cr\n JOIN\n synthesize_v1.data_column sc ON cr.source_column_id = sc.id\n JOIN\n synthesize_v1.data_column tc ON cr.target_column_id = tc.id\nWHERE cr.relationship_type IN ('context_foreign_key', 'non_context_foreign_key')\n AND cr.source_dataset_id = ANY ($1::UUID[])\n AND cr.target_dataset_id = ANY ($1::UUID[])";
|
|
6
|
+
export interface GetForeignKeyRelationshipsArgs {
|
|
7
|
+
datasetIds: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface GetForeignKeyRelationshipsRow {
|
|
10
|
+
sourceDatasetId: string;
|
|
11
|
+
targetDatasetId: string;
|
|
12
|
+
sourceColumnName: string;
|
|
13
|
+
targetColumnName: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function getForeignKeyRelationships(client: Client, args: GetForeignKeyRelationshipsArgs): Promise<GetForeignKeyRelationshipsRow[]>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getForeignKeyRelationshipsQuery = void 0;
|
|
4
|
+
exports.getForeignKeyRelationships = getForeignKeyRelationships;
|
|
5
|
+
exports.getForeignKeyRelationshipsQuery = `-- name: GetForeignKeyRelationships :many
|
|
6
|
+
SELECT cr.source_dataset_id,
|
|
7
|
+
cr.target_dataset_id,
|
|
8
|
+
sc.name AS source_column_name,
|
|
9
|
+
tc.name AS target_column_name
|
|
10
|
+
FROM synthesize_v1.column_relationship cr
|
|
11
|
+
JOIN
|
|
12
|
+
synthesize_v1.data_column sc ON cr.source_column_id = sc.id
|
|
13
|
+
JOIN
|
|
14
|
+
synthesize_v1.data_column tc ON cr.target_column_id = tc.id
|
|
15
|
+
WHERE cr.relationship_type IN ('context_foreign_key', 'non_context_foreign_key')
|
|
16
|
+
AND cr.source_dataset_id = ANY ($1::UUID[])
|
|
17
|
+
AND cr.target_dataset_id = ANY ($1::UUID[])`;
|
|
18
|
+
async function getForeignKeyRelationships(client, args) {
|
|
19
|
+
const result = await client.query({
|
|
20
|
+
text: exports.getForeignKeyRelationshipsQuery,
|
|
21
|
+
values: [args.datasetIds],
|
|
22
|
+
rowMode: "array"
|
|
23
|
+
});
|
|
24
|
+
return result.rows.map(row => {
|
|
25
|
+
return {
|
|
26
|
+
sourceDatasetId: row[0],
|
|
27
|
+
targetDatasetId: row[1],
|
|
28
|
+
sourceColumnName: row[2],
|
|
29
|
+
targetColumnName: row[3]
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { QueryArrayConfig, QueryArrayResult } from "pg";
|
|
2
|
+
interface Client {
|
|
3
|
+
query: (config: QueryArrayConfig) => Promise<QueryArrayResult>;
|
|
4
|
+
}
|
|
5
|
+
export declare const getStorageConnectionQuery = "-- name: GetStorageConnection :one\nSELECT id, organization_id, name, description, category, variant, details\nFROM storage_connection\nWHERE id = $1";
|
|
6
|
+
export interface GetStorageConnectionArgs {
|
|
7
|
+
id: string;
|
|
8
|
+
}
|
|
9
|
+
export interface GetStorageConnectionRow {
|
|
10
|
+
id: string;
|
|
11
|
+
organizationId: string;
|
|
12
|
+
name: string;
|
|
13
|
+
description: string | null;
|
|
14
|
+
category: string;
|
|
15
|
+
variant: string;
|
|
16
|
+
details: any;
|
|
17
|
+
}
|
|
18
|
+
export declare function getStorageConnection(client: Client, args: GetStorageConnectionArgs): Promise<GetStorageConnectionRow | null>;
|
|
19
|
+
export declare const getStorageConnectionByDatasetIDQuery = "-- name: GetStorageConnectionByDatasetID :one\nSELECT sc.id, sc.organization_id, sc.name, sc.description, sc.category, sc.variant, sc.details\nFROM storage_connection sc\n JOIN generate_v1.dataset d ON d.storage_connection_id = sc.id\nWHERE d.id = $1";
|
|
20
|
+
export interface GetStorageConnectionByDatasetIDArgs {
|
|
21
|
+
datasetId: string;
|
|
22
|
+
}
|
|
23
|
+
export interface GetStorageConnectionByDatasetIDRow {
|
|
24
|
+
id: string;
|
|
25
|
+
organizationId: string;
|
|
26
|
+
name: string;
|
|
27
|
+
description: string | null;
|
|
28
|
+
category: string;
|
|
29
|
+
variant: string;
|
|
30
|
+
details: any;
|
|
31
|
+
}
|
|
32
|
+
export declare function getStorageConnectionByDatasetID(client: Client, args: GetStorageConnectionByDatasetIDArgs): Promise<GetStorageConnectionByDatasetIDRow | null>;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStorageConnectionByDatasetIDQuery = exports.getStorageConnectionQuery = void 0;
|
|
4
|
+
exports.getStorageConnection = getStorageConnection;
|
|
5
|
+
exports.getStorageConnectionByDatasetID = getStorageConnectionByDatasetID;
|
|
6
|
+
exports.getStorageConnectionQuery = `-- name: GetStorageConnection :one
|
|
7
|
+
SELECT id, organization_id, name, description, category, variant, details
|
|
8
|
+
FROM storage_connection
|
|
9
|
+
WHERE id = $1`;
|
|
10
|
+
async function getStorageConnection(client, args) {
|
|
11
|
+
const result = await client.query({
|
|
12
|
+
text: exports.getStorageConnectionQuery,
|
|
13
|
+
values: [args.id],
|
|
14
|
+
rowMode: "array"
|
|
15
|
+
});
|
|
16
|
+
if (result.rows.length !== 1) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const row = result.rows[0];
|
|
20
|
+
return {
|
|
21
|
+
id: row[0],
|
|
22
|
+
organizationId: row[1],
|
|
23
|
+
name: row[2],
|
|
24
|
+
description: row[3],
|
|
25
|
+
category: row[4],
|
|
26
|
+
variant: row[5],
|
|
27
|
+
details: row[6]
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.getStorageConnectionByDatasetIDQuery = `-- name: GetStorageConnectionByDatasetID :one
|
|
31
|
+
SELECT sc.id, sc.organization_id, sc.name, sc.description, sc.category, sc.variant, sc.details
|
|
32
|
+
FROM storage_connection sc
|
|
33
|
+
JOIN generate_v1.dataset d ON d.storage_connection_id = sc.id
|
|
34
|
+
WHERE d.id = $1`;
|
|
35
|
+
async function getStorageConnectionByDatasetID(client, args) {
|
|
36
|
+
const result = await client.query({
|
|
37
|
+
text: exports.getStorageConnectionByDatasetIDQuery,
|
|
38
|
+
values: [args.datasetId],
|
|
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
|
+
organizationId: row[1],
|
|
48
|
+
name: row[2],
|
|
49
|
+
description: row[3],
|
|
50
|
+
category: row[4],
|
|
51
|
+
variant: row[5],
|
|
52
|
+
details: row[6]
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { QueryArrayConfig, QueryArrayResult } from "pg";
|
|
2
|
+
interface Client {
|
|
3
|
+
query: (config: QueryArrayConfig) => Promise<QueryArrayResult>;
|
|
4
|
+
}
|
|
5
|
+
export declare const upsertSynthesizerQuery = "-- name: UpsertSynthesizer :exec\nINSERT INTO synthesize_v1.synthesizer (id, organization_id, name, description, storage_connection_id, metadata)\nVALUES ($1, $2, $3, $4, $5, $6)\nON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name,\n description = EXCLUDED.description,\n storage_connection_id = EXCLUDED.storage_connection_id,\n metadata = EXCLUDED.metadata";
|
|
6
|
+
export interface UpsertSynthesizerArgs {
|
|
7
|
+
id: string;
|
|
8
|
+
organizationId: string;
|
|
9
|
+
name: string;
|
|
10
|
+
description: string | null;
|
|
11
|
+
storageConnectionId: string;
|
|
12
|
+
metadata: any | null;
|
|
13
|
+
}
|
|
14
|
+
export declare function upsertSynthesizer(client: Client, args: UpsertSynthesizerArgs): Promise<void>;
|
|
15
|
+
export declare const getSynthesizerQuery = "-- name: GetSynthesizer :one\nSELECT id, organization_id, name, description, storage_connection_id, metadata\nFROM synthesize_v1.synthesizer\nWHERE id = $1";
|
|
16
|
+
export interface GetSynthesizerArgs {
|
|
17
|
+
id: string;
|
|
18
|
+
}
|
|
19
|
+
export interface GetSynthesizerRow {
|
|
20
|
+
id: string;
|
|
21
|
+
organizationId: string;
|
|
22
|
+
name: string;
|
|
23
|
+
description: string | null;
|
|
24
|
+
storageConnectionId: string;
|
|
25
|
+
metadata: any | null;
|
|
26
|
+
}
|
|
27
|
+
export declare function getSynthesizer(client: Client, args: GetSynthesizerArgs): Promise<GetSynthesizerRow | null>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSynthesizerQuery = exports.upsertSynthesizerQuery = void 0;
|
|
4
|
+
exports.upsertSynthesizer = upsertSynthesizer;
|
|
5
|
+
exports.getSynthesizer = getSynthesizer;
|
|
6
|
+
exports.upsertSynthesizerQuery = `-- name: UpsertSynthesizer :exec
|
|
7
|
+
INSERT INTO synthesize_v1.synthesizer (id, organization_id, name, description, storage_connection_id, metadata)
|
|
8
|
+
VALUES ($1, $2, $3, $4, $5, $6)
|
|
9
|
+
ON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name,
|
|
10
|
+
description = EXCLUDED.description,
|
|
11
|
+
storage_connection_id = EXCLUDED.storage_connection_id,
|
|
12
|
+
metadata = EXCLUDED.metadata`;
|
|
13
|
+
async function upsertSynthesizer(client, args) {
|
|
14
|
+
await client.query({
|
|
15
|
+
text: exports.upsertSynthesizerQuery,
|
|
16
|
+
values: [args.id, args.organizationId, args.name, args.description, args.storageConnectionId, args.metadata],
|
|
17
|
+
rowMode: "array"
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
exports.getSynthesizerQuery = `-- name: GetSynthesizer :one
|
|
21
|
+
SELECT id, organization_id, name, description, storage_connection_id, metadata
|
|
22
|
+
FROM synthesize_v1.synthesizer
|
|
23
|
+
WHERE id = $1`;
|
|
24
|
+
async function getSynthesizer(client, args) {
|
|
25
|
+
const result = await client.query({
|
|
26
|
+
text: exports.getSynthesizerQuery,
|
|
27
|
+
values: [args.id],
|
|
28
|
+
rowMode: "array"
|
|
29
|
+
});
|
|
30
|
+
if (result.rows.length !== 1) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const row = result.rows[0];
|
|
34
|
+
return {
|
|
35
|
+
id: row[0],
|
|
36
|
+
organizationId: row[1],
|
|
37
|
+
name: row[2],
|
|
38
|
+
description: row[3],
|
|
39
|
+
storageConnectionId: row[4],
|
|
40
|
+
metadata: row[5]
|
|
41
|
+
};
|
|
42
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weave-typescript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -28,6 +28,9 @@
|
|
|
28
28
|
"default": "./dist/*.js"
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/pg": "^8.15.5"
|
|
33
|
+
},
|
|
31
34
|
"scripts": {
|
|
32
35
|
"test": "node tools/sqlcgen.test.js",
|
|
33
36
|
"test:sqlcgen": "node tools/sqlcgen.test.js",
|