@sdods/db 0.2.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/LICENSE +17 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/col.d.ts +32 -0
- package/dist/col.js +58 -0
- package/dist/create-db.d.ts +14 -0
- package/dist/create-db.js +58 -0
- package/dist/driver.d.ts +10 -0
- package/dist/driver.js +16 -0
- package/dist/ids.d.ts +2 -0
- package/dist/ids.js +2 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +22 -0
- package/dist/ingest/attachments.d.ts +40 -0
- package/dist/ingest/attachments.js +154 -0
- package/dist/ingest/cucumber-ingest.d.ts +40 -0
- package/dist/ingest/cucumber-ingest.js +543 -0
- package/dist/ingest/finalize.d.ts +28 -0
- package/dist/ingest/finalize.js +132 -0
- package/dist/ingest/index.d.ts +26 -0
- package/dist/ingest/index.js +193 -0
- package/dist/ingest/message-index.d.ts +64 -0
- package/dist/ingest/message-index.js +146 -0
- package/dist/ingest/parse-ndjson.d.ts +10 -0
- package/dist/ingest/parse-ndjson.js +35 -0
- package/dist/ingest/pw-json-ingest.d.ts +14 -0
- package/dist/ingest/pw-json-ingest.js +259 -0
- package/dist/ingest/runner-json-ingest.d.ts +14 -0
- package/dist/ingest/runner-json-ingest.js +259 -0
- package/dist/ingest/types.d.ts +62 -0
- package/dist/ingest/types.js +89 -0
- package/dist/insights.d.ts +62 -0
- package/dist/insights.js +184 -0
- package/dist/migrate.d.ts +30 -0
- package/dist/migrate.js +114 -0
- package/dist/migrations/0001_platform_init.d.ts +5 -0
- package/dist/migrations/0001_platform_init.js +48 -0
- package/dist/migrations/0002_results.d.ts +5 -0
- package/dist/migrations/0002_results.js +124 -0
- package/dist/migrations/0003_improvement.d.ts +5 -0
- package/dist/migrations/0003_improvement.js +56 -0
- package/dist/migrations/0004_test_data.d.ts +5 -0
- package/dist/migrations/0004_test_data.js +48 -0
- package/dist/migrations/0005_integrations_agents_audit.d.ts +5 -0
- package/dist/migrations/0005_integrations_agents_audit.js +100 -0
- package/dist/migrations/0006_schedules.d.ts +5 -0
- package/dist/migrations/0006_schedules.js +34 -0
- package/dist/migrations/0007_hierarchy.d.ts +5 -0
- package/dist/migrations/0007_hierarchy.js +76 -0
- package/dist/migrations/0008_runner_naming.d.ts +14 -0
- package/dist/migrations/0008_runner_naming.js +35 -0
- package/dist/migrations/helpers.d.ts +15 -0
- package/dist/migrations/helpers.js +30 -0
- package/dist/migrations/index.d.ts +6 -0
- package/dist/migrations/index.js +22 -0
- package/dist/repos/auth.d.ts +109 -0
- package/dist/repos/auth.js +258 -0
- package/dist/repos/hierarchy.d.ts +151 -0
- package/dist/repos/hierarchy.js +465 -0
- package/dist/repos/improvement.d.ts +84 -0
- package/dist/repos/improvement.js +242 -0
- package/dist/repos/index.d.ts +8 -0
- package/dist/repos/index.js +8 -0
- package/dist/repos/platform.d.ts +250 -0
- package/dist/repos/platform.js +429 -0
- package/dist/repos/projects.d.ts +87 -0
- package/dist/repos/projects.js +118 -0
- package/dist/repos/runs.d.ts +306 -0
- package/dist/repos/runs.js +321 -0
- package/dist/repos/test-data.d.ts +84 -0
- package/dist/repos/test-data.js +291 -0
- package/dist/schema.d.ts +514 -0
- package/dist/schema.js +37 -0
- package/dist/scopes.d.ts +2 -0
- package/dist/scopes.js +2 -0
- package/dist/switch/export.d.ts +15 -0
- package/dist/switch/export.js +67 -0
- package/dist/switch/import.d.ts +16 -0
- package/dist/switch/import.js +106 -0
- package/dist/switch/index.d.ts +5 -0
- package/dist/switch/index.js +5 -0
- package/dist/switch/prune.d.ts +19 -0
- package/dist/switch/prune.js +50 -0
- package/dist/switch/switch.d.ts +34 -0
- package/dist/switch/switch.js +133 -0
- package/dist/test-data.d.ts +22 -0
- package/dist/test-data.js +79 -0
- package/package.json +50 -0
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kysely `Database` interface. One schema serves both dialects:
|
|
3
|
+
* - ids: app-generated UUIDv7 text
|
|
4
|
+
* - timestamps: ISO-8601 text on sqlite, timestamptz on Postgres (read back as ISO strings)
|
|
5
|
+
* - json: text on sqlite (parsed by ParseJSONResultsPlugin), jsonb on Postgres
|
|
6
|
+
* - booleans: integer 0/1 on sqlite, boolean on Postgres (normalise with readBool)
|
|
7
|
+
*/
|
|
8
|
+
import type { ColumnType } from 'kysely';
|
|
9
|
+
/** JSON column: reads come back parsed, writes are JSON strings (enc.json / jsonVal). */
|
|
10
|
+
export type Json<T = unknown> = ColumnType<T, string | ReturnType<typeof String>, string>;
|
|
11
|
+
export type Bool = ColumnType<boolean | number, boolean | number, boolean | number>;
|
|
12
|
+
export type Ts = ColumnType<string, string, string>;
|
|
13
|
+
export interface OrganizationsTable {
|
|
14
|
+
id: string;
|
|
15
|
+
slug: string;
|
|
16
|
+
name: string;
|
|
17
|
+
description: string | null;
|
|
18
|
+
url: string | null;
|
|
19
|
+
created_at: Ts;
|
|
20
|
+
updated_at: Ts;
|
|
21
|
+
}
|
|
22
|
+
export interface WorkspacesTable {
|
|
23
|
+
id: string;
|
|
24
|
+
organization_id: string;
|
|
25
|
+
slug: string;
|
|
26
|
+
name: string;
|
|
27
|
+
description: string | null;
|
|
28
|
+
created_at: Ts;
|
|
29
|
+
updated_at: Ts;
|
|
30
|
+
}
|
|
31
|
+
export interface OrgMembersTable {
|
|
32
|
+
id: string;
|
|
33
|
+
organization_id: string;
|
|
34
|
+
user_id: string;
|
|
35
|
+
role: string;
|
|
36
|
+
created_at: Ts;
|
|
37
|
+
}
|
|
38
|
+
export interface WorkspaceMembersTable {
|
|
39
|
+
id: string;
|
|
40
|
+
workspace_id: string;
|
|
41
|
+
user_id: string;
|
|
42
|
+
role: string;
|
|
43
|
+
created_at: Ts;
|
|
44
|
+
}
|
|
45
|
+
export interface ModulesTable {
|
|
46
|
+
id: string;
|
|
47
|
+
project_id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
title: string | null;
|
|
50
|
+
description: string | null;
|
|
51
|
+
path: string | null;
|
|
52
|
+
layers_json: Json<string[]>;
|
|
53
|
+
testing_types_json: Json<string[]>;
|
|
54
|
+
tags_json: Json<string[]>;
|
|
55
|
+
owner: string | null;
|
|
56
|
+
jira_component: string | null;
|
|
57
|
+
routes_json: Json<string[]>;
|
|
58
|
+
endpoints_json: Json<string[]>;
|
|
59
|
+
created_at: Ts;
|
|
60
|
+
updated_at: Ts;
|
|
61
|
+
}
|
|
62
|
+
export interface ProcessesTable {
|
|
63
|
+
id: string;
|
|
64
|
+
project_id: string | null;
|
|
65
|
+
workspace_id: string | null;
|
|
66
|
+
name: string;
|
|
67
|
+
title: string | null;
|
|
68
|
+
description: string | null;
|
|
69
|
+
trigger: string;
|
|
70
|
+
config_json: Json<Record<string, unknown>>;
|
|
71
|
+
enabled: Bool;
|
|
72
|
+
last_run_id: string | null;
|
|
73
|
+
last_status: string | null;
|
|
74
|
+
created_at: Ts;
|
|
75
|
+
updated_at: Ts;
|
|
76
|
+
}
|
|
77
|
+
export interface ProjectsTable {
|
|
78
|
+
id: string;
|
|
79
|
+
workspace_id: string | null;
|
|
80
|
+
slug: string;
|
|
81
|
+
name: string;
|
|
82
|
+
description: string | null;
|
|
83
|
+
root_path: string | null;
|
|
84
|
+
config_json: Json<Record<string, unknown>>;
|
|
85
|
+
config_hash: string | null;
|
|
86
|
+
layers_json: Json<string[]>;
|
|
87
|
+
browsers_json: Json<string[]>;
|
|
88
|
+
tags_policy_json: Json<Record<string, unknown>>;
|
|
89
|
+
screenshot_policy_json: Json<Record<string, unknown>>;
|
|
90
|
+
archived: Bool;
|
|
91
|
+
created_at: Ts;
|
|
92
|
+
updated_at: Ts;
|
|
93
|
+
}
|
|
94
|
+
export interface EnvironmentsTable {
|
|
95
|
+
id: string;
|
|
96
|
+
project_id: string;
|
|
97
|
+
name: string;
|
|
98
|
+
base_url: string | null;
|
|
99
|
+
api_base_url: string | null;
|
|
100
|
+
config_json: Json<Record<string, unknown>>;
|
|
101
|
+
secret_keys_json: Json<string[]>;
|
|
102
|
+
is_default: Bool;
|
|
103
|
+
created_at: Ts;
|
|
104
|
+
updated_at: Ts;
|
|
105
|
+
}
|
|
106
|
+
export interface RunsTable {
|
|
107
|
+
id: string;
|
|
108
|
+
project_id: string;
|
|
109
|
+
workspace_id: string | null;
|
|
110
|
+
environment_id: string | null;
|
|
111
|
+
env_name: string;
|
|
112
|
+
process: string | null;
|
|
113
|
+
trigger: string;
|
|
114
|
+
status: string;
|
|
115
|
+
suite_tag: string | null;
|
|
116
|
+
tags_expr: string | null;
|
|
117
|
+
layers_json: Json<string[]>;
|
|
118
|
+
browsers_json: Json<string[]>;
|
|
119
|
+
shard_total: number | null;
|
|
120
|
+
shards_ingested: number;
|
|
121
|
+
git_sha: string | null;
|
|
122
|
+
git_branch: string | null;
|
|
123
|
+
ci_provider: string | null;
|
|
124
|
+
ci_run_id: string | null;
|
|
125
|
+
ci_url: string | null;
|
|
126
|
+
started_by: string | null;
|
|
127
|
+
command: string | null;
|
|
128
|
+
started_at: Ts | null;
|
|
129
|
+
finished_at: Ts | null;
|
|
130
|
+
duration_ms: number | null;
|
|
131
|
+
totals_json: Json<Record<string, unknown>>;
|
|
132
|
+
artifacts_dir: string | null;
|
|
133
|
+
html_report_rel: string | null;
|
|
134
|
+
exit_code: number | null;
|
|
135
|
+
error_text: string | null;
|
|
136
|
+
created_at: Ts;
|
|
137
|
+
updated_at: Ts;
|
|
138
|
+
}
|
|
139
|
+
export interface ScenariosTable {
|
|
140
|
+
id: string;
|
|
141
|
+
run_id: string;
|
|
142
|
+
project_id: string;
|
|
143
|
+
natural_key: string;
|
|
144
|
+
fingerprint: string;
|
|
145
|
+
source: string;
|
|
146
|
+
feature_uri: string;
|
|
147
|
+
feature_name: string | null;
|
|
148
|
+
scenario_name: string;
|
|
149
|
+
module: string | null;
|
|
150
|
+
examples_row: number | null;
|
|
151
|
+
runner_project: string;
|
|
152
|
+
layer: string;
|
|
153
|
+
browser: string | null;
|
|
154
|
+
suite_tag: string | null;
|
|
155
|
+
tags_json: Json<string[]>;
|
|
156
|
+
jira_keys_json: Json<string[]>;
|
|
157
|
+
status: string;
|
|
158
|
+
attempts_count: number;
|
|
159
|
+
flaky: Bool;
|
|
160
|
+
duration_ms: number | null;
|
|
161
|
+
error_message: string | null;
|
|
162
|
+
error_stack: string | null;
|
|
163
|
+
started_at: Ts | null;
|
|
164
|
+
finished_at: Ts | null;
|
|
165
|
+
created_at: Ts;
|
|
166
|
+
updated_at: Ts;
|
|
167
|
+
}
|
|
168
|
+
export interface ScenarioAttemptsTable {
|
|
169
|
+
id: string;
|
|
170
|
+
scenario_id: string;
|
|
171
|
+
run_id: string;
|
|
172
|
+
attempt: number;
|
|
173
|
+
test_case_started_id: string;
|
|
174
|
+
status: string;
|
|
175
|
+
duration_ms: number | null;
|
|
176
|
+
error_message: string | null;
|
|
177
|
+
error_stack: string | null;
|
|
178
|
+
will_be_retried: Bool;
|
|
179
|
+
worker_index: number | null;
|
|
180
|
+
started_at: Ts | null;
|
|
181
|
+
finished_at: Ts | null;
|
|
182
|
+
created_at: Ts;
|
|
183
|
+
}
|
|
184
|
+
export interface StepsTable {
|
|
185
|
+
id: string;
|
|
186
|
+
attempt_id: string;
|
|
187
|
+
scenario_id: string;
|
|
188
|
+
run_id: string;
|
|
189
|
+
step_index: number;
|
|
190
|
+
kind: string;
|
|
191
|
+
hook_type: string | null;
|
|
192
|
+
keyword: string | null;
|
|
193
|
+
text: string;
|
|
194
|
+
argument_json: Json<unknown> | null;
|
|
195
|
+
status: string;
|
|
196
|
+
duration_ms: number | null;
|
|
197
|
+
error_message: string | null;
|
|
198
|
+
error_stack: string | null;
|
|
199
|
+
definition_location: string | null;
|
|
200
|
+
test_step_id: string;
|
|
201
|
+
pickle_step_id: string | null;
|
|
202
|
+
layer_hint: string | null;
|
|
203
|
+
api_snapshot_json: Json<unknown> | null;
|
|
204
|
+
perf_json: Json<unknown> | null;
|
|
205
|
+
started_at: Ts | null;
|
|
206
|
+
finished_at: Ts | null;
|
|
207
|
+
created_at: Ts;
|
|
208
|
+
}
|
|
209
|
+
export interface ArtifactsTable {
|
|
210
|
+
id: string;
|
|
211
|
+
run_id: string;
|
|
212
|
+
scenario_id: string | null;
|
|
213
|
+
attempt_id: string | null;
|
|
214
|
+
step_id: string | null;
|
|
215
|
+
step_index: number | null;
|
|
216
|
+
kind: string;
|
|
217
|
+
phase: string | null;
|
|
218
|
+
media_type: string;
|
|
219
|
+
file_name: string;
|
|
220
|
+
rel_path: string;
|
|
221
|
+
size_bytes: number;
|
|
222
|
+
sha256: string | null;
|
|
223
|
+
width: number | null;
|
|
224
|
+
height: number | null;
|
|
225
|
+
meta_json: Json<Record<string, unknown>> | null;
|
|
226
|
+
created_at: Ts;
|
|
227
|
+
}
|
|
228
|
+
export interface HealEventsTable {
|
|
229
|
+
id: string;
|
|
230
|
+
project_id: string;
|
|
231
|
+
run_id: string;
|
|
232
|
+
scenario_id: string | null;
|
|
233
|
+
attempt_id: string | null;
|
|
234
|
+
step_id: string | null;
|
|
235
|
+
page_url: string | null;
|
|
236
|
+
original_selector: string;
|
|
237
|
+
context_json: Json<Record<string, unknown>>;
|
|
238
|
+
strategy_used: string | null;
|
|
239
|
+
healed_selector: string | null;
|
|
240
|
+
candidates_json: Json<unknown[]>;
|
|
241
|
+
succeeded: Bool;
|
|
242
|
+
duration_ms: number | null;
|
|
243
|
+
source: string;
|
|
244
|
+
accepted: Bool | null;
|
|
245
|
+
accepted_by: string | null;
|
|
246
|
+
created_at: Ts;
|
|
247
|
+
}
|
|
248
|
+
export interface LocatorStatsTable {
|
|
249
|
+
id: string;
|
|
250
|
+
project_id: string;
|
|
251
|
+
selector: string;
|
|
252
|
+
page_hint: string | null;
|
|
253
|
+
fail_count: number;
|
|
254
|
+
heal_count: number;
|
|
255
|
+
use_count: number;
|
|
256
|
+
last_failed_at: Ts | null;
|
|
257
|
+
last_healed_at: Ts | null;
|
|
258
|
+
last_strategy: string | null;
|
|
259
|
+
suggested_selector: string | null;
|
|
260
|
+
updated_at: Ts;
|
|
261
|
+
}
|
|
262
|
+
export interface FlakyStatsTable {
|
|
263
|
+
id: string;
|
|
264
|
+
project_id: string;
|
|
265
|
+
fingerprint: string;
|
|
266
|
+
runner_project: string;
|
|
267
|
+
feature_uri: string | null;
|
|
268
|
+
scenario_name: string | null;
|
|
269
|
+
window_size: number;
|
|
270
|
+
runs_count: number;
|
|
271
|
+
pass_count: number;
|
|
272
|
+
fail_count: number;
|
|
273
|
+
flaky_count: number;
|
|
274
|
+
flaky_rate: number;
|
|
275
|
+
fail_streak: number;
|
|
276
|
+
last_status: string | null;
|
|
277
|
+
last_run_id: string | null;
|
|
278
|
+
last_failed_at: Ts | null;
|
|
279
|
+
quarantined: Bool;
|
|
280
|
+
updated_at: Ts;
|
|
281
|
+
}
|
|
282
|
+
export interface DatasetsTable {
|
|
283
|
+
id: string;
|
|
284
|
+
project_id: string;
|
|
285
|
+
env_key: string;
|
|
286
|
+
name: string;
|
|
287
|
+
kind: string;
|
|
288
|
+
storage: string;
|
|
289
|
+
source_path: string | null;
|
|
290
|
+
columns_json: Json<string[]>;
|
|
291
|
+
row_count: number;
|
|
292
|
+
content_hash: string | null;
|
|
293
|
+
created_by: string | null;
|
|
294
|
+
created_at: Ts;
|
|
295
|
+
updated_at: Ts;
|
|
296
|
+
}
|
|
297
|
+
export interface DatasetRowsTable {
|
|
298
|
+
id: string;
|
|
299
|
+
dataset_id: string;
|
|
300
|
+
row_index: number;
|
|
301
|
+
data_json: Json<Record<string, unknown>>;
|
|
302
|
+
tags_json: Json<string[]>;
|
|
303
|
+
created_at: Ts;
|
|
304
|
+
}
|
|
305
|
+
export interface UserPoolTable {
|
|
306
|
+
id: string;
|
|
307
|
+
project_id: string;
|
|
308
|
+
environment_id: string | null;
|
|
309
|
+
env_name: string;
|
|
310
|
+
pool_name: string;
|
|
311
|
+
username: string;
|
|
312
|
+
secret_ref: string | null;
|
|
313
|
+
role: string;
|
|
314
|
+
storage_state_rel: string | null;
|
|
315
|
+
attributes_json: Json<Record<string, unknown>>;
|
|
316
|
+
enabled: Bool;
|
|
317
|
+
created_at: Ts;
|
|
318
|
+
updated_at: Ts;
|
|
319
|
+
}
|
|
320
|
+
export interface UserLeasesTable {
|
|
321
|
+
id: string;
|
|
322
|
+
pool_user_id: string;
|
|
323
|
+
run_id: string | null;
|
|
324
|
+
worker_index: number | null;
|
|
325
|
+
holder: string;
|
|
326
|
+
leased_at: Ts;
|
|
327
|
+
expires_at: Ts;
|
|
328
|
+
released_at: Ts | null;
|
|
329
|
+
}
|
|
330
|
+
export interface RolesTable {
|
|
331
|
+
id: string;
|
|
332
|
+
name: string;
|
|
333
|
+
permissions_json: Json<string[]>;
|
|
334
|
+
created_at: Ts;
|
|
335
|
+
}
|
|
336
|
+
export interface UsersTable {
|
|
337
|
+
id: string;
|
|
338
|
+
username: string;
|
|
339
|
+
email: string | null;
|
|
340
|
+
password_hash: string;
|
|
341
|
+
role_id: string;
|
|
342
|
+
active: Bool;
|
|
343
|
+
auth_provider: string;
|
|
344
|
+
external_id: string | null;
|
|
345
|
+
last_login_at: Ts | null;
|
|
346
|
+
created_at: Ts;
|
|
347
|
+
updated_at: Ts;
|
|
348
|
+
}
|
|
349
|
+
export interface SessionsTable {
|
|
350
|
+
id: string;
|
|
351
|
+
user_id: string;
|
|
352
|
+
csrf_token: string;
|
|
353
|
+
ip: string | null;
|
|
354
|
+
user_agent: string | null;
|
|
355
|
+
created_at: Ts;
|
|
356
|
+
expires_at: Ts;
|
|
357
|
+
last_seen_at: Ts;
|
|
358
|
+
}
|
|
359
|
+
export interface ApiTokensTable {
|
|
360
|
+
id: string;
|
|
361
|
+
user_id: string;
|
|
362
|
+
name: string;
|
|
363
|
+
token_prefix: string;
|
|
364
|
+
hash: string;
|
|
365
|
+
scopes_json: Json<string[]>;
|
|
366
|
+
expires_at: Ts | null;
|
|
367
|
+
last_used_at: Ts | null;
|
|
368
|
+
revoked_at: Ts | null;
|
|
369
|
+
created_at: Ts;
|
|
370
|
+
}
|
|
371
|
+
export interface IntegrationsTable {
|
|
372
|
+
id: string;
|
|
373
|
+
project_id: string;
|
|
374
|
+
provider: string;
|
|
375
|
+
config_json: Json<Record<string, unknown>>;
|
|
376
|
+
secret_env_json: Json<Record<string, string>>;
|
|
377
|
+
enabled: Bool;
|
|
378
|
+
last_sync_at: Ts | null;
|
|
379
|
+
created_at: Ts;
|
|
380
|
+
updated_at: Ts;
|
|
381
|
+
}
|
|
382
|
+
export interface IssueLinksTable {
|
|
383
|
+
id: string;
|
|
384
|
+
project_id: string;
|
|
385
|
+
integration_id: string | null;
|
|
386
|
+
provider: string;
|
|
387
|
+
fingerprint: string;
|
|
388
|
+
scenario_name: string | null;
|
|
389
|
+
external_key: string;
|
|
390
|
+
external_url: string | null;
|
|
391
|
+
status: string;
|
|
392
|
+
source: string;
|
|
393
|
+
last_run_id: string | null;
|
|
394
|
+
last_synced_at: Ts | null;
|
|
395
|
+
created_at: Ts;
|
|
396
|
+
updated_at: Ts;
|
|
397
|
+
}
|
|
398
|
+
export interface AgentJobsTable {
|
|
399
|
+
id: string;
|
|
400
|
+
project_id: string;
|
|
401
|
+
kind: string;
|
|
402
|
+
goal: string | null;
|
|
403
|
+
status: string;
|
|
404
|
+
input_json: Json<Record<string, unknown>>;
|
|
405
|
+
output_json: Json<Record<string, unknown>> | null;
|
|
406
|
+
diff_text: string | null;
|
|
407
|
+
log_rel: string | null;
|
|
408
|
+
provider: string | null;
|
|
409
|
+
model: string | null;
|
|
410
|
+
tokens_in: number | null;
|
|
411
|
+
tokens_out: number | null;
|
|
412
|
+
cost_usd: number | null;
|
|
413
|
+
turns: number | null;
|
|
414
|
+
proposal_id: string | null;
|
|
415
|
+
started_by: string | null;
|
|
416
|
+
reviewed_by: string | null;
|
|
417
|
+
started_at: Ts | null;
|
|
418
|
+
finished_at: Ts | null;
|
|
419
|
+
reviewed_at: Ts | null;
|
|
420
|
+
error: string | null;
|
|
421
|
+
created_at: Ts;
|
|
422
|
+
}
|
|
423
|
+
export interface ProposalsTable {
|
|
424
|
+
id: string;
|
|
425
|
+
project_id: string;
|
|
426
|
+
role: string;
|
|
427
|
+
status: string;
|
|
428
|
+
summary: string | null;
|
|
429
|
+
manifest_json: Json<Record<string, unknown>>;
|
|
430
|
+
cost_usd: number | null;
|
|
431
|
+
model: string | null;
|
|
432
|
+
created_by: string | null;
|
|
433
|
+
reviewed_by: string | null;
|
|
434
|
+
created_at: Ts;
|
|
435
|
+
reviewed_at: Ts | null;
|
|
436
|
+
}
|
|
437
|
+
export interface SchedulesTable {
|
|
438
|
+
id: string;
|
|
439
|
+
project_id: string;
|
|
440
|
+
environment_id: string | null;
|
|
441
|
+
name: string;
|
|
442
|
+
cron_expr: string;
|
|
443
|
+
timezone: string;
|
|
444
|
+
run_input_json: Json<Record<string, unknown>>;
|
|
445
|
+
overlap_policy: string;
|
|
446
|
+
jitter_seconds: number;
|
|
447
|
+
catch_up: Bool;
|
|
448
|
+
enabled: Bool;
|
|
449
|
+
notify_json: Json<unknown>;
|
|
450
|
+
retention_runs: number | null;
|
|
451
|
+
next_run_at: Ts | null;
|
|
452
|
+
last_run_id: string | null;
|
|
453
|
+
last_status: string | null;
|
|
454
|
+
created_by: string | null;
|
|
455
|
+
created_at: Ts;
|
|
456
|
+
updated_at: Ts;
|
|
457
|
+
}
|
|
458
|
+
export interface ScheduleRunsTable {
|
|
459
|
+
id: string;
|
|
460
|
+
schedule_id: string;
|
|
461
|
+
run_id: string | null;
|
|
462
|
+
fired_at: Ts;
|
|
463
|
+
status: string;
|
|
464
|
+
note: string | null;
|
|
465
|
+
}
|
|
466
|
+
export interface AuditLogTable {
|
|
467
|
+
id: string;
|
|
468
|
+
actor_user_id: string | null;
|
|
469
|
+
actor_type: string;
|
|
470
|
+
action: string;
|
|
471
|
+
target_type: string | null;
|
|
472
|
+
target_id: string | null;
|
|
473
|
+
details_json: Json<Record<string, unknown>> | null;
|
|
474
|
+
ip: string | null;
|
|
475
|
+
created_at: Ts;
|
|
476
|
+
}
|
|
477
|
+
export interface Database {
|
|
478
|
+
organizations: OrganizationsTable;
|
|
479
|
+
workspaces: WorkspacesTable;
|
|
480
|
+
org_members: OrgMembersTable;
|
|
481
|
+
workspace_members: WorkspaceMembersTable;
|
|
482
|
+
projects: ProjectsTable;
|
|
483
|
+
modules: ModulesTable;
|
|
484
|
+
processes: ProcessesTable;
|
|
485
|
+
environments: EnvironmentsTable;
|
|
486
|
+
runs: RunsTable;
|
|
487
|
+
scenarios: ScenariosTable;
|
|
488
|
+
scenario_attempts: ScenarioAttemptsTable;
|
|
489
|
+
steps: StepsTable;
|
|
490
|
+
artifacts: ArtifactsTable;
|
|
491
|
+
heal_events: HealEventsTable;
|
|
492
|
+
locator_stats: LocatorStatsTable;
|
|
493
|
+
flaky_stats: FlakyStatsTable;
|
|
494
|
+
datasets: DatasetsTable;
|
|
495
|
+
dataset_rows: DatasetRowsTable;
|
|
496
|
+
user_pool: UserPoolTable;
|
|
497
|
+
user_leases: UserLeasesTable;
|
|
498
|
+
roles: RolesTable;
|
|
499
|
+
users: UsersTable;
|
|
500
|
+
sessions: SessionsTable;
|
|
501
|
+
api_tokens: ApiTokensTable;
|
|
502
|
+
integrations: IntegrationsTable;
|
|
503
|
+
issue_links: IssueLinksTable;
|
|
504
|
+
agent_jobs: AgentJobsTable;
|
|
505
|
+
proposals: ProposalsTable;
|
|
506
|
+
schedules: SchedulesTable;
|
|
507
|
+
schedule_runs: ScheduleRunsTable;
|
|
508
|
+
audit_log: AuditLogTable;
|
|
509
|
+
}
|
|
510
|
+
/** Platform tables in foreign-key order (parents first). Used by export/import/switch/prune. */
|
|
511
|
+
export declare const TABLES_IN_FK_ORDER: Array<keyof Database>;
|
|
512
|
+
export declare const MIGRATION_TABLE = "sdods_migrations";
|
|
513
|
+
export declare const MIGRATION_LOCK_TABLE = "sdods_migrations_lock";
|
|
514
|
+
//# sourceMappingURL=schema.d.ts.map
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Platform tables in foreign-key order (parents first). Used by export/import/switch/prune. */
|
|
2
|
+
export const TABLES_IN_FK_ORDER = [
|
|
3
|
+
'roles',
|
|
4
|
+
'users',
|
|
5
|
+
'sessions',
|
|
6
|
+
'api_tokens',
|
|
7
|
+
'organizations',
|
|
8
|
+
'workspaces',
|
|
9
|
+
'org_members',
|
|
10
|
+
'workspace_members',
|
|
11
|
+
'projects',
|
|
12
|
+
'modules',
|
|
13
|
+
'processes',
|
|
14
|
+
'environments',
|
|
15
|
+
'runs',
|
|
16
|
+
'scenarios',
|
|
17
|
+
'scenario_attempts',
|
|
18
|
+
'steps',
|
|
19
|
+
'artifacts',
|
|
20
|
+
'heal_events',
|
|
21
|
+
'locator_stats',
|
|
22
|
+
'flaky_stats',
|
|
23
|
+
'datasets',
|
|
24
|
+
'dataset_rows',
|
|
25
|
+
'user_pool',
|
|
26
|
+
'user_leases',
|
|
27
|
+
'integrations',
|
|
28
|
+
'issue_links',
|
|
29
|
+
'proposals',
|
|
30
|
+
'agent_jobs',
|
|
31
|
+
'schedules',
|
|
32
|
+
'schedule_runs',
|
|
33
|
+
'audit_log',
|
|
34
|
+
];
|
|
35
|
+
export const MIGRATION_TABLE = 'sdods_migrations';
|
|
36
|
+
export const MIGRATION_LOCK_TABLE = 'sdods_migrations_lock';
|
|
37
|
+
//# sourceMappingURL=schema.js.map
|
package/dist/scopes.d.ts
ADDED
package/dist/scopes.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SdodsDb } from '../create-db.js';
|
|
2
|
+
export interface ExportResult {
|
|
3
|
+
dir: string;
|
|
4
|
+
tables: Array<{
|
|
5
|
+
table: string;
|
|
6
|
+
rows: number;
|
|
7
|
+
file: string;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
/** Stream every platform table (+ td_* tables) to `<dir>/<table>.jsonl` in FK order. */
|
|
11
|
+
export declare function exportAll(adb: SdodsDb, dir: string, opts?: {
|
|
12
|
+
batch?: number;
|
|
13
|
+
}): Promise<ExportResult>;
|
|
14
|
+
export declare function countRows(adb: SdodsDb, table: string): Promise<number>;
|
|
15
|
+
//# sourceMappingURL=export.d.ts.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { createWriteStream, mkdirSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { sql } from 'kysely';
|
|
4
|
+
import { TABLES_IN_FK_ORDER } from '../schema.js';
|
|
5
|
+
import { listTdTables } from '../test-data.js';
|
|
6
|
+
/** Stream every platform table (+ td_* tables) to `<dir>/<table>.jsonl` in FK order. */
|
|
7
|
+
export async function exportAll(adb, dir, opts = {}) {
|
|
8
|
+
mkdirSync(dir, { recursive: true });
|
|
9
|
+
const batch = opts.batch ?? 1000;
|
|
10
|
+
const tables = [...TABLES_IN_FK_ORDER, ...(await listTdTables(adb.db, adb.driver))];
|
|
11
|
+
const out = { dir, tables: [] };
|
|
12
|
+
for (const table of tables) {
|
|
13
|
+
const file = join(dir, `${table}.jsonl`);
|
|
14
|
+
const stream = createWriteStream(file);
|
|
15
|
+
let offset = 0;
|
|
16
|
+
let count = 0;
|
|
17
|
+
for (;;) {
|
|
18
|
+
const rows = (await adb.db
|
|
19
|
+
.selectFrom(table)
|
|
20
|
+
.selectAll()
|
|
21
|
+
.orderBy('id')
|
|
22
|
+
.limit(batch)
|
|
23
|
+
.offset(offset)
|
|
24
|
+
.execute()
|
|
25
|
+
.catch(async () => {
|
|
26
|
+
// td_* tables have no id column
|
|
27
|
+
const res = await sql `select * from ${sql.table(table)} limit ${batch} offset ${offset}`.execute(adb.db);
|
|
28
|
+
return res.rows;
|
|
29
|
+
}));
|
|
30
|
+
for (const row of rows)
|
|
31
|
+
stream.write(JSON.stringify(normalizeRow(row)) + '\n');
|
|
32
|
+
count += rows.length;
|
|
33
|
+
offset += rows.length;
|
|
34
|
+
if (rows.length < batch)
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
await new Promise((resolve, reject) => stream.end((e) => (e ? reject(e) : resolve())));
|
|
38
|
+
out.tables.push({ table, rows: count, file });
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
/** JSON columns decoded, Dates → ISO, Buffers → base64 so both dialects produce the same JSONL. */
|
|
43
|
+
function normalizeRow(row) {
|
|
44
|
+
const out = {};
|
|
45
|
+
for (const [k, v] of Object.entries(row)) {
|
|
46
|
+
if (v instanceof Date)
|
|
47
|
+
out[k] = v.toISOString();
|
|
48
|
+
else if (Buffer.isBuffer(v))
|
|
49
|
+
out[k] = { $base64: v.toString('base64') };
|
|
50
|
+
else if (k.endsWith('_json') && typeof v === 'string') {
|
|
51
|
+
try {
|
|
52
|
+
out[k] = JSON.parse(v);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
out[k] = v;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else
|
|
59
|
+
out[k] = v;
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
export async function countRows(adb, table) {
|
|
64
|
+
const res = await sql `select count(*) as n from ${sql.table(table)}`.execute(adb.db);
|
|
65
|
+
return Number(res.rows[0]?.n ?? 0);
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=export.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SdodsDb } from '../create-db.js';
|
|
2
|
+
export interface ImportResult {
|
|
3
|
+
tables: Array<{
|
|
4
|
+
table: string;
|
|
5
|
+
rows: number;
|
|
6
|
+
skipped: number;
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Load `<dir>/<table>.jsonl` files in FK order inside one transaction, `ON CONFLICT DO NOTHING`.
|
|
11
|
+
* td_* tables are created on the fly (text columns) when missing.
|
|
12
|
+
*/
|
|
13
|
+
export declare function importAll(adb: SdodsDb, dir: string, opts?: {
|
|
14
|
+
batch?: number;
|
|
15
|
+
}): Promise<ImportResult>;
|
|
16
|
+
//# sourceMappingURL=import.d.ts.map
|