@secondlayer/shared 0.10.1 → 0.11.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/src/db/index.d.ts +181 -2
- package/dist/src/db/queries/accounts.d.ts +158 -2
- package/dist/src/db/queries/accounts.js +17 -1
- package/dist/src/db/queries/accounts.js.map +3 -3
- package/dist/src/db/queries/integrity.d.ts +151 -1
- package/dist/src/db/queries/marketplace.d.ts +463 -0
- package/dist/src/db/queries/marketplace.js +142 -0
- package/dist/src/db/queries/marketplace.js.map +10 -0
- package/dist/src/db/queries/metrics.d.ts +151 -1
- package/dist/src/db/queries/projects.d.ts +423 -0
- package/dist/src/db/queries/projects.js +47 -0
- package/dist/src/db/queries/projects.js.map +10 -0
- package/dist/src/db/queries/subgraph-gaps.d.ts +151 -1
- package/dist/src/db/queries/subgraphs.d.ts +158 -6
- package/dist/src/db/queries/subgraphs.js +16 -13
- package/dist/src/db/queries/subgraphs.js.map +3 -3
- package/dist/src/db/queries/usage.d.ts +151 -1
- package/dist/src/db/queries/workflows.d.ts +439 -0
- package/dist/src/db/queries/workflows.js +115 -0
- package/dist/src/db/queries/workflows.js.map +11 -0
- package/dist/src/db/schema.d.ts +181 -2
- package/dist/src/index.d.ts +251 -10
- package/dist/src/index.js +91 -72
- package/dist/src/index.js.map +4 -3
- package/dist/src/node/hiro-pg-client.js +5 -3
- package/dist/src/node/hiro-pg-client.js.map +3 -3
- package/dist/src/node/local-client.d.ts +155 -1
- package/dist/src/node/local-client.js +19 -9
- package/dist/src/node/local-client.js.map +3 -3
- package/dist/src/schemas/index.d.ts +71 -9
- package/dist/src/schemas/index.js +93 -74
- package/dist/src/schemas/index.js.map +4 -3
- package/dist/src/schemas/marketplace.d.ts +63 -0
- package/dist/src/schemas/marketplace.js +39 -0
- package/dist/src/schemas/marketplace.js.map +10 -0
- package/dist/src/schemas/workflows.d.ts +66 -0
- package/dist/src/schemas/workflows.js +39 -0
- package/dist/src/schemas/workflows.js.map +10 -0
- package/dist/src/types.d.ts +3 -0
- package/migrations/0021_tx_function_args_result.ts +27 -0
- package/migrations/0022_marketplace.ts +88 -0
- package/migrations/0023_projects.ts +149 -0
- package/migrations/0024_chat_sessions.ts +51 -0
- package/migrations/0025_chat_session_summary.ts +15 -0
- package/migrations/0026_workflows.ts +204 -0
- package/migrations/0027_workflow_cursors.ts +16 -0
- package/migrations/0028_subgraph_account_scoping.ts +116 -0
- package/package.json +22 -2
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import { Kysely } from "kysely";
|
|
2
|
+
import { Generated, Selectable } from "kysely";
|
|
3
|
+
interface BlocksTable {
|
|
4
|
+
height: number;
|
|
5
|
+
hash: string;
|
|
6
|
+
parent_hash: string;
|
|
7
|
+
burn_block_height: number;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
canonical: Generated<boolean>;
|
|
10
|
+
created_at: Generated<Date>;
|
|
11
|
+
}
|
|
12
|
+
interface TransactionsTable {
|
|
13
|
+
tx_id: string;
|
|
14
|
+
block_height: number;
|
|
15
|
+
tx_index: Generated<number>;
|
|
16
|
+
type: string;
|
|
17
|
+
sender: string;
|
|
18
|
+
status: string;
|
|
19
|
+
contract_id: string | null;
|
|
20
|
+
function_name: string | null;
|
|
21
|
+
function_args: Generated<unknown | null>;
|
|
22
|
+
raw_result: Generated<string | null>;
|
|
23
|
+
raw_tx: string;
|
|
24
|
+
created_at: Generated<Date>;
|
|
25
|
+
}
|
|
26
|
+
interface EventsTable {
|
|
27
|
+
id: Generated<string>;
|
|
28
|
+
tx_id: string;
|
|
29
|
+
block_height: number;
|
|
30
|
+
event_index: number;
|
|
31
|
+
type: string;
|
|
32
|
+
data: unknown;
|
|
33
|
+
created_at: Generated<Date>;
|
|
34
|
+
}
|
|
35
|
+
interface StreamsTable {
|
|
36
|
+
id: Generated<string>;
|
|
37
|
+
name: string;
|
|
38
|
+
status: Generated<string>;
|
|
39
|
+
filters: unknown;
|
|
40
|
+
options: Generated<unknown>;
|
|
41
|
+
endpoint_url: string;
|
|
42
|
+
signing_secret: string | null;
|
|
43
|
+
api_key_id: string;
|
|
44
|
+
project_id: string | null;
|
|
45
|
+
created_at: Generated<Date>;
|
|
46
|
+
updated_at: Generated<Date>;
|
|
47
|
+
}
|
|
48
|
+
interface StreamMetricsTable {
|
|
49
|
+
stream_id: string;
|
|
50
|
+
last_triggered_at: Date | null;
|
|
51
|
+
last_triggered_block: number | null;
|
|
52
|
+
total_deliveries: Generated<number>;
|
|
53
|
+
failed_deliveries: Generated<number>;
|
|
54
|
+
error_message: string | null;
|
|
55
|
+
}
|
|
56
|
+
interface JobsTable {
|
|
57
|
+
id: Generated<string>;
|
|
58
|
+
stream_id: string;
|
|
59
|
+
block_height: number;
|
|
60
|
+
status: Generated<string>;
|
|
61
|
+
attempts: Generated<number>;
|
|
62
|
+
locked_at: Date | null;
|
|
63
|
+
locked_by: string | null;
|
|
64
|
+
error: string | null;
|
|
65
|
+
backfill: Generated<boolean>;
|
|
66
|
+
created_at: Generated<Date>;
|
|
67
|
+
completed_at: Date | null;
|
|
68
|
+
}
|
|
69
|
+
interface IndexProgressTable {
|
|
70
|
+
network: string;
|
|
71
|
+
last_indexed_block: Generated<number>;
|
|
72
|
+
last_contiguous_block: Generated<number>;
|
|
73
|
+
highest_seen_block: Generated<number>;
|
|
74
|
+
updated_at: Generated<Date>;
|
|
75
|
+
}
|
|
76
|
+
interface DeliveriesTable {
|
|
77
|
+
id: Generated<string>;
|
|
78
|
+
stream_id: string;
|
|
79
|
+
job_id: string | null;
|
|
80
|
+
block_height: number;
|
|
81
|
+
status: string;
|
|
82
|
+
status_code: number | null;
|
|
83
|
+
response_time_ms: number | null;
|
|
84
|
+
attempts: Generated<number>;
|
|
85
|
+
error: string | null;
|
|
86
|
+
payload: unknown;
|
|
87
|
+
created_at: Generated<Date>;
|
|
88
|
+
}
|
|
89
|
+
interface SubgraphsTable {
|
|
90
|
+
id: Generated<string>;
|
|
91
|
+
name: string;
|
|
92
|
+
version: Generated<string>;
|
|
93
|
+
status: Generated<string>;
|
|
94
|
+
definition: Record<string, unknown>;
|
|
95
|
+
schema_hash: string;
|
|
96
|
+
handler_path: string;
|
|
97
|
+
schema_name: string | null;
|
|
98
|
+
start_block: Generated<number>;
|
|
99
|
+
last_processed_block: Generated<number>;
|
|
100
|
+
reindex_from_block: number | null;
|
|
101
|
+
reindex_to_block: number | null;
|
|
102
|
+
last_error: string | null;
|
|
103
|
+
last_error_at: Date | null;
|
|
104
|
+
total_processed: Generated<number>;
|
|
105
|
+
total_errors: Generated<number>;
|
|
106
|
+
api_key_id: string | null;
|
|
107
|
+
account_id: string;
|
|
108
|
+
project_id: string | null;
|
|
109
|
+
is_public: Generated<boolean>;
|
|
110
|
+
tags: Generated<string[]>;
|
|
111
|
+
description: string | null;
|
|
112
|
+
forked_from_id: string | null;
|
|
113
|
+
created_at: Generated<Date>;
|
|
114
|
+
updated_at: Generated<Date>;
|
|
115
|
+
}
|
|
116
|
+
interface SubgraphGapsTable {
|
|
117
|
+
id: Generated<string>;
|
|
118
|
+
subgraph_id: string;
|
|
119
|
+
subgraph_name: string;
|
|
120
|
+
gap_start: number;
|
|
121
|
+
gap_end: number;
|
|
122
|
+
reason: string;
|
|
123
|
+
detected_at: Generated<Date>;
|
|
124
|
+
resolved_at: Date | null;
|
|
125
|
+
}
|
|
126
|
+
interface ApiKeysTable {
|
|
127
|
+
id: Generated<string>;
|
|
128
|
+
key_hash: string;
|
|
129
|
+
key_prefix: string;
|
|
130
|
+
name: string | null;
|
|
131
|
+
status: Generated<string>;
|
|
132
|
+
rate_limit: Generated<number>;
|
|
133
|
+
ip_address: string;
|
|
134
|
+
account_id: string;
|
|
135
|
+
last_used_at: Date | null;
|
|
136
|
+
revoked_at: Date | null;
|
|
137
|
+
created_at: Generated<Date>;
|
|
138
|
+
}
|
|
139
|
+
interface AccountsTable {
|
|
140
|
+
id: Generated<string>;
|
|
141
|
+
email: string;
|
|
142
|
+
plan: Generated<string>;
|
|
143
|
+
display_name: string | null;
|
|
144
|
+
bio: string | null;
|
|
145
|
+
avatar_url: string | null;
|
|
146
|
+
slug: string | null;
|
|
147
|
+
created_at: Generated<Date>;
|
|
148
|
+
}
|
|
149
|
+
interface SessionsTable {
|
|
150
|
+
id: Generated<string>;
|
|
151
|
+
token_hash: string;
|
|
152
|
+
token_prefix: string;
|
|
153
|
+
account_id: string;
|
|
154
|
+
ip_address: string;
|
|
155
|
+
expires_at: Generated<Date>;
|
|
156
|
+
revoked_at: Date | null;
|
|
157
|
+
last_used_at: Date | null;
|
|
158
|
+
created_at: Generated<Date>;
|
|
159
|
+
}
|
|
160
|
+
interface MagicLinksTable {
|
|
161
|
+
id: Generated<string>;
|
|
162
|
+
email: string;
|
|
163
|
+
token: string;
|
|
164
|
+
code: string | null;
|
|
165
|
+
expires_at: Date;
|
|
166
|
+
used_at: Date | null;
|
|
167
|
+
failed_attempts: Generated<number>;
|
|
168
|
+
created_at: Generated<Date>;
|
|
169
|
+
}
|
|
170
|
+
interface UsageDailyTable {
|
|
171
|
+
account_id: string;
|
|
172
|
+
date: string;
|
|
173
|
+
api_requests: Generated<number>;
|
|
174
|
+
deliveries: Generated<number>;
|
|
175
|
+
}
|
|
176
|
+
interface UsageSnapshotsTable {
|
|
177
|
+
id: Generated<string>;
|
|
178
|
+
account_id: string;
|
|
179
|
+
measured_at: Generated<Date>;
|
|
180
|
+
storage_bytes: Generated<number>;
|
|
181
|
+
}
|
|
182
|
+
interface WaitlistTable {
|
|
183
|
+
id: Generated<string>;
|
|
184
|
+
email: string;
|
|
185
|
+
source: Generated<string>;
|
|
186
|
+
status: Generated<string>;
|
|
187
|
+
created_at: Generated<Date>;
|
|
188
|
+
}
|
|
189
|
+
interface AccountInsightsTable {
|
|
190
|
+
id: Generated<string>;
|
|
191
|
+
account_id: string;
|
|
192
|
+
category: string;
|
|
193
|
+
insight_type: string;
|
|
194
|
+
resource_id: string | null;
|
|
195
|
+
severity: string;
|
|
196
|
+
title: string;
|
|
197
|
+
body: string;
|
|
198
|
+
data: unknown;
|
|
199
|
+
dismissed_at: Date | null;
|
|
200
|
+
expires_at: Date | null;
|
|
201
|
+
created_at: Generated<Date>;
|
|
202
|
+
}
|
|
203
|
+
interface AccountAgentRunsTable {
|
|
204
|
+
id: Generated<string>;
|
|
205
|
+
account_id: string;
|
|
206
|
+
started_at: Generated<Date>;
|
|
207
|
+
completed_at: Date | null;
|
|
208
|
+
status: Generated<string>;
|
|
209
|
+
input_tokens: Generated<number>;
|
|
210
|
+
output_tokens: Generated<number>;
|
|
211
|
+
cost_usd: Generated<number>;
|
|
212
|
+
insights_created: Generated<number>;
|
|
213
|
+
error: string | null;
|
|
214
|
+
}
|
|
215
|
+
interface SubgraphProcessingStatsTable {
|
|
216
|
+
id: Generated<string>;
|
|
217
|
+
subgraph_name: string;
|
|
218
|
+
api_key_id: string | null;
|
|
219
|
+
bucket_start: Date | null;
|
|
220
|
+
bucket_end: Date | null;
|
|
221
|
+
blocks_processed: number | null;
|
|
222
|
+
total_time_ms: number | null;
|
|
223
|
+
handler_time_ms: number | null;
|
|
224
|
+
flush_time_ms: number | null;
|
|
225
|
+
max_block_time_ms: number | null;
|
|
226
|
+
max_handler_time_ms: number | null;
|
|
227
|
+
avg_ops_per_block: number | null;
|
|
228
|
+
is_catchup: Generated<boolean>;
|
|
229
|
+
created_at: Generated<Date>;
|
|
230
|
+
}
|
|
231
|
+
interface SubgraphTableSnapshotsTable {
|
|
232
|
+
id: Generated<string>;
|
|
233
|
+
subgraph_name: string;
|
|
234
|
+
api_key_id: string | null;
|
|
235
|
+
table_name: string;
|
|
236
|
+
row_count: number | null;
|
|
237
|
+
created_at: Generated<Date>;
|
|
238
|
+
}
|
|
239
|
+
interface SubgraphHealthSnapshotsTable {
|
|
240
|
+
id: Generated<string>;
|
|
241
|
+
subgraph_id: string;
|
|
242
|
+
total_processed: number;
|
|
243
|
+
total_errors: number;
|
|
244
|
+
last_processed_block: number | null;
|
|
245
|
+
captured_at: Generated<Date>;
|
|
246
|
+
}
|
|
247
|
+
interface SubgraphUsageDailyTable {
|
|
248
|
+
subgraph_id: string;
|
|
249
|
+
date: string;
|
|
250
|
+
query_count: Generated<number>;
|
|
251
|
+
}
|
|
252
|
+
interface ProjectsTable {
|
|
253
|
+
id: Generated<string>;
|
|
254
|
+
name: string;
|
|
255
|
+
slug: string;
|
|
256
|
+
account_id: string;
|
|
257
|
+
settings: Generated<Record<string, unknown>>;
|
|
258
|
+
network: Generated<string>;
|
|
259
|
+
node_rpc: string | null;
|
|
260
|
+
created_at: Generated<Date>;
|
|
261
|
+
updated_at: Generated<Date>;
|
|
262
|
+
}
|
|
263
|
+
interface TeamMembersTable {
|
|
264
|
+
id: Generated<string>;
|
|
265
|
+
project_id: string;
|
|
266
|
+
account_id: string;
|
|
267
|
+
role: Generated<string>;
|
|
268
|
+
invited_by: string | null;
|
|
269
|
+
created_at: Generated<Date>;
|
|
270
|
+
}
|
|
271
|
+
interface TeamInvitationsTable {
|
|
272
|
+
id: Generated<string>;
|
|
273
|
+
project_id: string;
|
|
274
|
+
email: string;
|
|
275
|
+
role: Generated<string>;
|
|
276
|
+
token: string;
|
|
277
|
+
invited_by: string | null;
|
|
278
|
+
expires_at: Date;
|
|
279
|
+
accepted_at: Date | null;
|
|
280
|
+
created_at: Generated<Date>;
|
|
281
|
+
}
|
|
282
|
+
interface ChatSessionsTable {
|
|
283
|
+
id: Generated<string>;
|
|
284
|
+
account_id: string;
|
|
285
|
+
title: string | null;
|
|
286
|
+
summary: unknown | null;
|
|
287
|
+
created_at: Generated<Date>;
|
|
288
|
+
updated_at: Generated<Date>;
|
|
289
|
+
}
|
|
290
|
+
interface ChatMessagesTable {
|
|
291
|
+
id: Generated<string>;
|
|
292
|
+
chat_session_id: string;
|
|
293
|
+
role: string;
|
|
294
|
+
parts: unknown;
|
|
295
|
+
metadata: unknown | null;
|
|
296
|
+
created_at: Generated<Date>;
|
|
297
|
+
}
|
|
298
|
+
interface WorkflowDefinitionsTable {
|
|
299
|
+
id: Generated<string>;
|
|
300
|
+
name: string;
|
|
301
|
+
version: Generated<string>;
|
|
302
|
+
status: Generated<string>;
|
|
303
|
+
trigger_type: string;
|
|
304
|
+
trigger_config: unknown;
|
|
305
|
+
handler_path: string;
|
|
306
|
+
retries_config: unknown | null;
|
|
307
|
+
timeout_ms: number | null;
|
|
308
|
+
api_key_id: string;
|
|
309
|
+
project_id: string | null;
|
|
310
|
+
created_at: Generated<Date>;
|
|
311
|
+
updated_at: Generated<Date>;
|
|
312
|
+
}
|
|
313
|
+
interface WorkflowRunsTable {
|
|
314
|
+
id: Generated<string>;
|
|
315
|
+
definition_id: string;
|
|
316
|
+
status: Generated<string>;
|
|
317
|
+
trigger_type: string;
|
|
318
|
+
trigger_data: unknown | null;
|
|
319
|
+
dedup_key: string | null;
|
|
320
|
+
error: string | null;
|
|
321
|
+
started_at: Date | null;
|
|
322
|
+
completed_at: Date | null;
|
|
323
|
+
duration_ms: number | null;
|
|
324
|
+
total_ai_tokens: Generated<number>;
|
|
325
|
+
created_at: Generated<Date>;
|
|
326
|
+
}
|
|
327
|
+
interface WorkflowStepsTable {
|
|
328
|
+
id: Generated<string>;
|
|
329
|
+
run_id: string;
|
|
330
|
+
step_index: number;
|
|
331
|
+
step_id: string;
|
|
332
|
+
step_type: string;
|
|
333
|
+
status: Generated<string>;
|
|
334
|
+
input: unknown | null;
|
|
335
|
+
output: unknown | null;
|
|
336
|
+
error: string | null;
|
|
337
|
+
retry_count: Generated<number>;
|
|
338
|
+
ai_tokens_used: Generated<number>;
|
|
339
|
+
started_at: Date | null;
|
|
340
|
+
completed_at: Date | null;
|
|
341
|
+
duration_ms: number | null;
|
|
342
|
+
created_at: Generated<Date>;
|
|
343
|
+
}
|
|
344
|
+
interface WorkflowQueueTable {
|
|
345
|
+
id: Generated<string>;
|
|
346
|
+
run_id: string;
|
|
347
|
+
status: Generated<string>;
|
|
348
|
+
attempts: Generated<number>;
|
|
349
|
+
max_attempts: Generated<number>;
|
|
350
|
+
scheduled_for: Generated<Date>;
|
|
351
|
+
locked_at: Date | null;
|
|
352
|
+
locked_by: string | null;
|
|
353
|
+
error: string | null;
|
|
354
|
+
created_at: Generated<Date>;
|
|
355
|
+
completed_at: Date | null;
|
|
356
|
+
}
|
|
357
|
+
interface WorkflowSchedulesTable {
|
|
358
|
+
id: Generated<string>;
|
|
359
|
+
definition_id: string;
|
|
360
|
+
cron_expr: string;
|
|
361
|
+
timezone: Generated<string>;
|
|
362
|
+
next_run_at: Date;
|
|
363
|
+
last_run_at: Date | null;
|
|
364
|
+
enabled: Generated<boolean>;
|
|
365
|
+
created_at: Generated<Date>;
|
|
366
|
+
}
|
|
367
|
+
interface WorkflowCursorsTable {
|
|
368
|
+
name: string;
|
|
369
|
+
block_height: Generated<number>;
|
|
370
|
+
updated_at: Generated<Date>;
|
|
371
|
+
}
|
|
372
|
+
interface Database {
|
|
373
|
+
blocks: BlocksTable;
|
|
374
|
+
transactions: TransactionsTable;
|
|
375
|
+
events: EventsTable;
|
|
376
|
+
streams: StreamsTable;
|
|
377
|
+
stream_metrics: StreamMetricsTable;
|
|
378
|
+
jobs: JobsTable;
|
|
379
|
+
index_progress: IndexProgressTable;
|
|
380
|
+
deliveries: DeliveriesTable;
|
|
381
|
+
subgraphs: SubgraphsTable;
|
|
382
|
+
api_keys: ApiKeysTable;
|
|
383
|
+
accounts: AccountsTable;
|
|
384
|
+
sessions: SessionsTable;
|
|
385
|
+
magic_links: MagicLinksTable;
|
|
386
|
+
usage_daily: UsageDailyTable;
|
|
387
|
+
usage_snapshots: UsageSnapshotsTable;
|
|
388
|
+
waitlist: WaitlistTable;
|
|
389
|
+
account_insights: AccountInsightsTable;
|
|
390
|
+
account_agent_runs: AccountAgentRunsTable;
|
|
391
|
+
subgraph_health_snapshots: SubgraphHealthSnapshotsTable;
|
|
392
|
+
subgraph_processing_stats: SubgraphProcessingStatsTable;
|
|
393
|
+
subgraph_table_snapshots: SubgraphTableSnapshotsTable;
|
|
394
|
+
subgraph_gaps: SubgraphGapsTable;
|
|
395
|
+
subgraph_usage_daily: SubgraphUsageDailyTable;
|
|
396
|
+
projects: ProjectsTable;
|
|
397
|
+
team_members: TeamMembersTable;
|
|
398
|
+
team_invitations: TeamInvitationsTable;
|
|
399
|
+
chat_sessions: ChatSessionsTable;
|
|
400
|
+
chat_messages: ChatMessagesTable;
|
|
401
|
+
workflow_definitions: WorkflowDefinitionsTable;
|
|
402
|
+
workflow_runs: WorkflowRunsTable;
|
|
403
|
+
workflow_steps: WorkflowStepsTable;
|
|
404
|
+
workflow_queue: WorkflowQueueTable;
|
|
405
|
+
workflow_schedules: WorkflowSchedulesTable;
|
|
406
|
+
workflow_cursors: WorkflowCursorsTable;
|
|
407
|
+
}
|
|
408
|
+
type Project = Selectable<ProjectsTable>;
|
|
409
|
+
type TeamInvitation = Selectable<TeamInvitationsTable>;
|
|
410
|
+
declare function getProjectsByAccount(db: Kysely<Database>, accountId: string): Promise<Project[]>;
|
|
411
|
+
declare function getProjectBySlug(db: Kysely<Database>, accountId: string, slug: string): Promise<Project | undefined>;
|
|
412
|
+
declare function getTeamMembers(db: Kysely<Database>, projectId: string): Promise<Array<{
|
|
413
|
+
id: string
|
|
414
|
+
role: string
|
|
415
|
+
created_at: Date
|
|
416
|
+
account_id: string
|
|
417
|
+
email: string
|
|
418
|
+
display_name: string | null
|
|
419
|
+
avatar_url: string | null
|
|
420
|
+
account_slug: string | null
|
|
421
|
+
}>>;
|
|
422
|
+
declare function getTeamInvitations(db: Kysely<Database>, projectId: string): Promise<TeamInvitation[]>;
|
|
423
|
+
export { getTeamMembers, getTeamInvitations, getProjectsByAccount, getProjectBySlug };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// src/db/queries/projects.ts
|
|
18
|
+
async function getProjectsByAccount(db, accountId) {
|
|
19
|
+
return db.selectFrom("projects").selectAll().where("account_id", "=", accountId).orderBy("created_at", "asc").execute();
|
|
20
|
+
}
|
|
21
|
+
async function getProjectBySlug(db, accountId, slug) {
|
|
22
|
+
return db.selectFrom("projects").selectAll().where("account_id", "=", accountId).where("slug", "=", slug).executeTakeFirst();
|
|
23
|
+
}
|
|
24
|
+
async function getTeamMembers(db, projectId) {
|
|
25
|
+
return db.selectFrom("team_members").innerJoin("accounts", "accounts.id", "team_members.account_id").select([
|
|
26
|
+
"team_members.id",
|
|
27
|
+
"team_members.role",
|
|
28
|
+
"team_members.created_at",
|
|
29
|
+
"accounts.id as account_id",
|
|
30
|
+
"accounts.email",
|
|
31
|
+
"accounts.display_name",
|
|
32
|
+
"accounts.avatar_url",
|
|
33
|
+
"accounts.slug as account_slug"
|
|
34
|
+
]).where("team_members.project_id", "=", projectId).orderBy("team_members.created_at", "asc").execute();
|
|
35
|
+
}
|
|
36
|
+
async function getTeamInvitations(db, projectId) {
|
|
37
|
+
return db.selectFrom("team_invitations").selectAll().where("project_id", "=", projectId).where("accepted_at", "is", null).orderBy("created_at", "desc").execute();
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
getTeamMembers,
|
|
41
|
+
getTeamInvitations,
|
|
42
|
+
getProjectsByAccount,
|
|
43
|
+
getProjectBySlug
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
//# debugId=F62DBD8C7A91B89F64756E2164756E21
|
|
47
|
+
//# sourceMappingURL=projects.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/db/queries/projects.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { Kysely } from \"kysely\";\nimport type { Database, Project, TeamInvitation } from \"../types.ts\";\n\nexport async function getProjectsByAccount(\n\tdb: Kysely<Database>,\n\taccountId: string,\n): Promise<Project[]> {\n\treturn db\n\t\t.selectFrom(\"projects\")\n\t\t.selectAll()\n\t\t.where(\"account_id\", \"=\", accountId)\n\t\t.orderBy(\"created_at\", \"asc\")\n\t\t.execute();\n}\n\nexport async function getProjectBySlug(\n\tdb: Kysely<Database>,\n\taccountId: string,\n\tslug: string,\n): Promise<Project | undefined> {\n\treturn db\n\t\t.selectFrom(\"projects\")\n\t\t.selectAll()\n\t\t.where(\"account_id\", \"=\", accountId)\n\t\t.where(\"slug\", \"=\", slug)\n\t\t.executeTakeFirst();\n}\n\nexport async function getTeamMembers(\n\tdb: Kysely<Database>,\n\tprojectId: string,\n): Promise<Array<{\n\tid: string;\n\trole: string;\n\tcreated_at: Date;\n\taccount_id: string;\n\temail: string;\n\tdisplay_name: string | null;\n\tavatar_url: string | null;\n\taccount_slug: string | null;\n}>> {\n\treturn db\n\t\t.selectFrom(\"team_members\")\n\t\t.innerJoin(\"accounts\", \"accounts.id\", \"team_members.account_id\")\n\t\t.select([\n\t\t\t\"team_members.id\",\n\t\t\t\"team_members.role\",\n\t\t\t\"team_members.created_at\",\n\t\t\t\"accounts.id as account_id\",\n\t\t\t\"accounts.email\",\n\t\t\t\"accounts.display_name\",\n\t\t\t\"accounts.avatar_url\",\n\t\t\t\"accounts.slug as account_slug\",\n\t\t])\n\t\t.where(\"team_members.project_id\", \"=\", projectId)\n\t\t.orderBy(\"team_members.created_at\", \"asc\")\n\t\t.execute();\n}\n\nexport async function getTeamInvitations(\n\tdb: Kysely<Database>,\n\tprojectId: string,\n): Promise<TeamInvitation[]> {\n\treturn db\n\t\t.selectFrom(\"team_invitations\")\n\t\t.selectAll()\n\t\t.where(\"project_id\", \"=\", projectId)\n\t\t.where(\"accepted_at\", \"is\", null)\n\t\t.orderBy(\"created_at\", \"desc\")\n\t\t.execute();\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAGA,eAAsB,oBAAoB,CACzC,IACA,WACqB;AAAA,EACrB,OAAO,GACL,WAAW,UAAU,EACrB,UAAU,EACV,MAAM,cAAc,KAAK,SAAS,EAClC,QAAQ,cAAc,KAAK,EAC3B,QAAQ;AAAA;AAGX,eAAsB,gBAAgB,CACrC,IACA,WACA,MAC+B;AAAA,EAC/B,OAAO,GACL,WAAW,UAAU,EACrB,UAAU,EACV,MAAM,cAAc,KAAK,SAAS,EAClC,MAAM,QAAQ,KAAK,IAAI,EACvB,iBAAiB;AAAA;AAGpB,eAAsB,cAAc,CACnC,IACA,WAUG;AAAA,EACH,OAAO,GACL,WAAW,cAAc,EACzB,UAAU,YAAY,eAAe,yBAAyB,EAC9D,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAC,EACA,MAAM,2BAA2B,KAAK,SAAS,EAC/C,QAAQ,2BAA2B,KAAK,EACxC,QAAQ;AAAA;AAGX,eAAsB,kBAAkB,CACvC,IACA,WAC4B;AAAA,EAC5B,OAAO,GACL,WAAW,kBAAkB,EAC7B,UAAU,EACV,MAAM,cAAc,KAAK,SAAS,EAClC,MAAM,eAAe,MAAM,IAAI,EAC/B,QAAQ,cAAc,MAAM,EAC5B,QAAQ;AAAA;",
|
|
8
|
+
"debugId": "F62DBD8C7A91B89F64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -18,6 +18,8 @@ interface TransactionsTable {
|
|
|
18
18
|
status: string;
|
|
19
19
|
contract_id: string | null;
|
|
20
20
|
function_name: string | null;
|
|
21
|
+
function_args: Generated<unknown | null>;
|
|
22
|
+
raw_result: Generated<string | null>;
|
|
21
23
|
raw_tx: string;
|
|
22
24
|
created_at: Generated<Date>;
|
|
23
25
|
}
|
|
@@ -39,6 +41,7 @@ interface StreamsTable {
|
|
|
39
41
|
endpoint_url: string;
|
|
40
42
|
signing_secret: string | null;
|
|
41
43
|
api_key_id: string;
|
|
44
|
+
project_id: string | null;
|
|
42
45
|
created_at: Generated<Date>;
|
|
43
46
|
updated_at: Generated<Date>;
|
|
44
47
|
}
|
|
@@ -100,7 +103,13 @@ interface SubgraphsTable {
|
|
|
100
103
|
last_error_at: Date | null;
|
|
101
104
|
total_processed: Generated<number>;
|
|
102
105
|
total_errors: Generated<number>;
|
|
103
|
-
api_key_id: string;
|
|
106
|
+
api_key_id: string | null;
|
|
107
|
+
account_id: string;
|
|
108
|
+
project_id: string | null;
|
|
109
|
+
is_public: Generated<boolean>;
|
|
110
|
+
tags: Generated<string[]>;
|
|
111
|
+
description: string | null;
|
|
112
|
+
forked_from_id: string | null;
|
|
104
113
|
created_at: Generated<Date>;
|
|
105
114
|
updated_at: Generated<Date>;
|
|
106
115
|
}
|
|
@@ -131,6 +140,10 @@ interface AccountsTable {
|
|
|
131
140
|
id: Generated<string>;
|
|
132
141
|
email: string;
|
|
133
142
|
plan: Generated<string>;
|
|
143
|
+
display_name: string | null;
|
|
144
|
+
bio: string | null;
|
|
145
|
+
avatar_url: string | null;
|
|
146
|
+
slug: string | null;
|
|
134
147
|
created_at: Generated<Date>;
|
|
135
148
|
}
|
|
136
149
|
interface SessionsTable {
|
|
@@ -231,6 +244,131 @@ interface SubgraphHealthSnapshotsTable {
|
|
|
231
244
|
last_processed_block: number | null;
|
|
232
245
|
captured_at: Generated<Date>;
|
|
233
246
|
}
|
|
247
|
+
interface SubgraphUsageDailyTable {
|
|
248
|
+
subgraph_id: string;
|
|
249
|
+
date: string;
|
|
250
|
+
query_count: Generated<number>;
|
|
251
|
+
}
|
|
252
|
+
interface ProjectsTable {
|
|
253
|
+
id: Generated<string>;
|
|
254
|
+
name: string;
|
|
255
|
+
slug: string;
|
|
256
|
+
account_id: string;
|
|
257
|
+
settings: Generated<Record<string, unknown>>;
|
|
258
|
+
network: Generated<string>;
|
|
259
|
+
node_rpc: string | null;
|
|
260
|
+
created_at: Generated<Date>;
|
|
261
|
+
updated_at: Generated<Date>;
|
|
262
|
+
}
|
|
263
|
+
interface TeamMembersTable {
|
|
264
|
+
id: Generated<string>;
|
|
265
|
+
project_id: string;
|
|
266
|
+
account_id: string;
|
|
267
|
+
role: Generated<string>;
|
|
268
|
+
invited_by: string | null;
|
|
269
|
+
created_at: Generated<Date>;
|
|
270
|
+
}
|
|
271
|
+
interface TeamInvitationsTable {
|
|
272
|
+
id: Generated<string>;
|
|
273
|
+
project_id: string;
|
|
274
|
+
email: string;
|
|
275
|
+
role: Generated<string>;
|
|
276
|
+
token: string;
|
|
277
|
+
invited_by: string | null;
|
|
278
|
+
expires_at: Date;
|
|
279
|
+
accepted_at: Date | null;
|
|
280
|
+
created_at: Generated<Date>;
|
|
281
|
+
}
|
|
282
|
+
interface ChatSessionsTable {
|
|
283
|
+
id: Generated<string>;
|
|
284
|
+
account_id: string;
|
|
285
|
+
title: string | null;
|
|
286
|
+
summary: unknown | null;
|
|
287
|
+
created_at: Generated<Date>;
|
|
288
|
+
updated_at: Generated<Date>;
|
|
289
|
+
}
|
|
290
|
+
interface ChatMessagesTable {
|
|
291
|
+
id: Generated<string>;
|
|
292
|
+
chat_session_id: string;
|
|
293
|
+
role: string;
|
|
294
|
+
parts: unknown;
|
|
295
|
+
metadata: unknown | null;
|
|
296
|
+
created_at: Generated<Date>;
|
|
297
|
+
}
|
|
298
|
+
interface WorkflowDefinitionsTable {
|
|
299
|
+
id: Generated<string>;
|
|
300
|
+
name: string;
|
|
301
|
+
version: Generated<string>;
|
|
302
|
+
status: Generated<string>;
|
|
303
|
+
trigger_type: string;
|
|
304
|
+
trigger_config: unknown;
|
|
305
|
+
handler_path: string;
|
|
306
|
+
retries_config: unknown | null;
|
|
307
|
+
timeout_ms: number | null;
|
|
308
|
+
api_key_id: string;
|
|
309
|
+
project_id: string | null;
|
|
310
|
+
created_at: Generated<Date>;
|
|
311
|
+
updated_at: Generated<Date>;
|
|
312
|
+
}
|
|
313
|
+
interface WorkflowRunsTable {
|
|
314
|
+
id: Generated<string>;
|
|
315
|
+
definition_id: string;
|
|
316
|
+
status: Generated<string>;
|
|
317
|
+
trigger_type: string;
|
|
318
|
+
trigger_data: unknown | null;
|
|
319
|
+
dedup_key: string | null;
|
|
320
|
+
error: string | null;
|
|
321
|
+
started_at: Date | null;
|
|
322
|
+
completed_at: Date | null;
|
|
323
|
+
duration_ms: number | null;
|
|
324
|
+
total_ai_tokens: Generated<number>;
|
|
325
|
+
created_at: Generated<Date>;
|
|
326
|
+
}
|
|
327
|
+
interface WorkflowStepsTable {
|
|
328
|
+
id: Generated<string>;
|
|
329
|
+
run_id: string;
|
|
330
|
+
step_index: number;
|
|
331
|
+
step_id: string;
|
|
332
|
+
step_type: string;
|
|
333
|
+
status: Generated<string>;
|
|
334
|
+
input: unknown | null;
|
|
335
|
+
output: unknown | null;
|
|
336
|
+
error: string | null;
|
|
337
|
+
retry_count: Generated<number>;
|
|
338
|
+
ai_tokens_used: Generated<number>;
|
|
339
|
+
started_at: Date | null;
|
|
340
|
+
completed_at: Date | null;
|
|
341
|
+
duration_ms: number | null;
|
|
342
|
+
created_at: Generated<Date>;
|
|
343
|
+
}
|
|
344
|
+
interface WorkflowQueueTable {
|
|
345
|
+
id: Generated<string>;
|
|
346
|
+
run_id: string;
|
|
347
|
+
status: Generated<string>;
|
|
348
|
+
attempts: Generated<number>;
|
|
349
|
+
max_attempts: Generated<number>;
|
|
350
|
+
scheduled_for: Generated<Date>;
|
|
351
|
+
locked_at: Date | null;
|
|
352
|
+
locked_by: string | null;
|
|
353
|
+
error: string | null;
|
|
354
|
+
created_at: Generated<Date>;
|
|
355
|
+
completed_at: Date | null;
|
|
356
|
+
}
|
|
357
|
+
interface WorkflowSchedulesTable {
|
|
358
|
+
id: Generated<string>;
|
|
359
|
+
definition_id: string;
|
|
360
|
+
cron_expr: string;
|
|
361
|
+
timezone: Generated<string>;
|
|
362
|
+
next_run_at: Date;
|
|
363
|
+
last_run_at: Date | null;
|
|
364
|
+
enabled: Generated<boolean>;
|
|
365
|
+
created_at: Generated<Date>;
|
|
366
|
+
}
|
|
367
|
+
interface WorkflowCursorsTable {
|
|
368
|
+
name: string;
|
|
369
|
+
block_height: Generated<number>;
|
|
370
|
+
updated_at: Generated<Date>;
|
|
371
|
+
}
|
|
234
372
|
interface Database {
|
|
235
373
|
blocks: BlocksTable;
|
|
236
374
|
transactions: TransactionsTable;
|
|
@@ -254,6 +392,18 @@ interface Database {
|
|
|
254
392
|
subgraph_processing_stats: SubgraphProcessingStatsTable;
|
|
255
393
|
subgraph_table_snapshots: SubgraphTableSnapshotsTable;
|
|
256
394
|
subgraph_gaps: SubgraphGapsTable;
|
|
395
|
+
subgraph_usage_daily: SubgraphUsageDailyTable;
|
|
396
|
+
projects: ProjectsTable;
|
|
397
|
+
team_members: TeamMembersTable;
|
|
398
|
+
team_invitations: TeamInvitationsTable;
|
|
399
|
+
chat_sessions: ChatSessionsTable;
|
|
400
|
+
chat_messages: ChatMessagesTable;
|
|
401
|
+
workflow_definitions: WorkflowDefinitionsTable;
|
|
402
|
+
workflow_runs: WorkflowRunsTable;
|
|
403
|
+
workflow_steps: WorkflowStepsTable;
|
|
404
|
+
workflow_queue: WorkflowQueueTable;
|
|
405
|
+
workflow_schedules: WorkflowSchedulesTable;
|
|
406
|
+
workflow_cursors: WorkflowCursorsTable;
|
|
257
407
|
}
|
|
258
408
|
interface GapRange {
|
|
259
409
|
start: number;
|