@secondlayer/shared 6.3.5 → 6.4.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/crypto/secrets.js +2 -5
- package/dist/src/crypto/secrets.js.map +3 -3
- package/dist/src/db/queries/subscriptions.js +2 -5
- package/dist/src/db/queries/subscriptions.js.map +3 -3
- package/dist/src/mode.d.ts +6 -12
- package/dist/src/mode.js +2 -6
- package/dist/src/mode.js.map +3 -3
- package/migrations/0075_restore_subgraphs_on_platform.ts +166 -0
- package/migrations/0076_deprecate_tenants.ts +19 -0
- package/package.json +1 -1
- package/dist/src/db/queries/tenants.d.ts +0 -800
- package/dist/src/db/queries/tenants.js +0 -308
- package/dist/src/db/queries/tenants.js.map +0 -12
|
@@ -1,800 +0,0 @@
|
|
|
1
|
-
import { Kysely } from "kysely";
|
|
2
|
-
import { ColumnType, Generated, Selectable } from "kysely";
|
|
3
|
-
interface BlocksTable {
|
|
4
|
-
height: number;
|
|
5
|
-
hash: string;
|
|
6
|
-
parent_hash: string;
|
|
7
|
-
burn_block_height: number;
|
|
8
|
-
burn_block_hash: ColumnType<string | null, string | null | undefined, string | null>;
|
|
9
|
-
timestamp: number;
|
|
10
|
-
canonical: Generated<boolean>;
|
|
11
|
-
created_at: Generated<Date>;
|
|
12
|
-
}
|
|
13
|
-
interface TransactionsTable {
|
|
14
|
-
tx_id: string;
|
|
15
|
-
block_height: number;
|
|
16
|
-
tx_index: Generated<number>;
|
|
17
|
-
type: string;
|
|
18
|
-
sender: string;
|
|
19
|
-
status: string;
|
|
20
|
-
contract_id: string | null;
|
|
21
|
-
function_name: string | null;
|
|
22
|
-
function_args: Generated<unknown | null>;
|
|
23
|
-
raw_result: Generated<string | null>;
|
|
24
|
-
raw_tx: string;
|
|
25
|
-
created_at: Generated<Date>;
|
|
26
|
-
}
|
|
27
|
-
interface EventsTable {
|
|
28
|
-
id: Generated<string>;
|
|
29
|
-
tx_id: string;
|
|
30
|
-
block_height: number;
|
|
31
|
-
event_index: number;
|
|
32
|
-
type: string;
|
|
33
|
-
data: unknown;
|
|
34
|
-
created_at: Generated<Date>;
|
|
35
|
-
}
|
|
36
|
-
interface IndexProgressTable {
|
|
37
|
-
network: string;
|
|
38
|
-
last_indexed_block: Generated<number>;
|
|
39
|
-
last_contiguous_block: Generated<number>;
|
|
40
|
-
highest_seen_block: Generated<number>;
|
|
41
|
-
updated_at: Generated<Date>;
|
|
42
|
-
}
|
|
43
|
-
interface SubgraphsTable {
|
|
44
|
-
id: Generated<string>;
|
|
45
|
-
name: string;
|
|
46
|
-
version: Generated<string>;
|
|
47
|
-
status: Generated<string>;
|
|
48
|
-
definition: Record<string, unknown>;
|
|
49
|
-
schema_hash: string;
|
|
50
|
-
handler_path: string;
|
|
51
|
-
schema_name: string | null;
|
|
52
|
-
start_block: Generated<number>;
|
|
53
|
-
last_processed_block: Generated<number>;
|
|
54
|
-
reindex_from_block: number | null;
|
|
55
|
-
reindex_to_block: number | null;
|
|
56
|
-
last_error: string | null;
|
|
57
|
-
last_error_at: Date | null;
|
|
58
|
-
total_processed: Generated<number>;
|
|
59
|
-
total_errors: Generated<number>;
|
|
60
|
-
account_id: string;
|
|
61
|
-
handler_code: string | null;
|
|
62
|
-
source_code: string | null;
|
|
63
|
-
project_id: string | null;
|
|
64
|
-
created_at: Generated<Date>;
|
|
65
|
-
updated_at: Generated<Date>;
|
|
66
|
-
}
|
|
67
|
-
interface SubgraphGapsTable {
|
|
68
|
-
id: Generated<string>;
|
|
69
|
-
subgraph_id: string;
|
|
70
|
-
subgraph_name: string;
|
|
71
|
-
gap_start: number;
|
|
72
|
-
gap_end: number;
|
|
73
|
-
reason: string;
|
|
74
|
-
detected_at: Generated<Date>;
|
|
75
|
-
resolved_at: Date | null;
|
|
76
|
-
}
|
|
77
|
-
type SubgraphOperationKind = "reindex" | "backfill";
|
|
78
|
-
type SubgraphOperationStatus = "queued" | "running" | "completed" | "failed" | "cancelled";
|
|
79
|
-
interface SubgraphOperationsTable {
|
|
80
|
-
id: Generated<string>;
|
|
81
|
-
subgraph_id: string;
|
|
82
|
-
subgraph_name: string;
|
|
83
|
-
account_id: string | null;
|
|
84
|
-
kind: ColumnType<SubgraphOperationKind, SubgraphOperationKind, SubgraphOperationKind>;
|
|
85
|
-
status: ColumnType<SubgraphOperationStatus, SubgraphOperationStatus | undefined, SubgraphOperationStatus>;
|
|
86
|
-
from_block: number | null;
|
|
87
|
-
to_block: number | null;
|
|
88
|
-
cancel_requested: Generated<boolean>;
|
|
89
|
-
locked_by: string | null;
|
|
90
|
-
locked_until: Date | null;
|
|
91
|
-
started_at: Date | null;
|
|
92
|
-
finished_at: Date | null;
|
|
93
|
-
processed_blocks: number | null;
|
|
94
|
-
error: string | null;
|
|
95
|
-
created_at: Generated<Date>;
|
|
96
|
-
updated_at: Generated<Date>;
|
|
97
|
-
}
|
|
98
|
-
interface ApiKeysTable {
|
|
99
|
-
id: Generated<string>;
|
|
100
|
-
key_hash: string;
|
|
101
|
-
key_prefix: string;
|
|
102
|
-
name: string | null;
|
|
103
|
-
status: Generated<string>;
|
|
104
|
-
rate_limit: Generated<number>;
|
|
105
|
-
ip_address: string;
|
|
106
|
-
account_id: string;
|
|
107
|
-
product: Generated<"account" | "streams" | "index">;
|
|
108
|
-
tier: "free" | "build" | "scale" | "enterprise" | null;
|
|
109
|
-
last_used_at: Date | null;
|
|
110
|
-
revoked_at: Date | null;
|
|
111
|
-
created_at: Generated<Date>;
|
|
112
|
-
}
|
|
113
|
-
interface AccountsTable {
|
|
114
|
-
id: Generated<string>;
|
|
115
|
-
email: string;
|
|
116
|
-
plan: Generated<string>;
|
|
117
|
-
display_name: string | null;
|
|
118
|
-
bio: string | null;
|
|
119
|
-
avatar_url: string | null;
|
|
120
|
-
slug: string | null;
|
|
121
|
-
stripe_customer_id: string | null;
|
|
122
|
-
created_at: Generated<Date>;
|
|
123
|
-
}
|
|
124
|
-
interface SessionsTable {
|
|
125
|
-
id: Generated<string>;
|
|
126
|
-
token_hash: string;
|
|
127
|
-
token_prefix: string;
|
|
128
|
-
account_id: string;
|
|
129
|
-
ip_address: string;
|
|
130
|
-
expires_at: Generated<Date>;
|
|
131
|
-
revoked_at: Date | null;
|
|
132
|
-
last_used_at: Date | null;
|
|
133
|
-
created_at: Generated<Date>;
|
|
134
|
-
}
|
|
135
|
-
interface MagicLinksTable {
|
|
136
|
-
id: Generated<string>;
|
|
137
|
-
email: string;
|
|
138
|
-
token: string;
|
|
139
|
-
code: string | null;
|
|
140
|
-
expires_at: Date;
|
|
141
|
-
used_at: Date | null;
|
|
142
|
-
failed_attempts: Generated<number>;
|
|
143
|
-
created_at: Generated<Date>;
|
|
144
|
-
}
|
|
145
|
-
interface UsageDailyTable {
|
|
146
|
-
account_id: string;
|
|
147
|
-
tenant_id: string | null;
|
|
148
|
-
date: string;
|
|
149
|
-
api_requests: Generated<number>;
|
|
150
|
-
deliveries: Generated<number>;
|
|
151
|
-
streams_events_returned: Generated<number>;
|
|
152
|
-
index_decoded_events_returned: Generated<number>;
|
|
153
|
-
}
|
|
154
|
-
interface UsageSnapshotsTable {
|
|
155
|
-
id: Generated<string>;
|
|
156
|
-
account_id: string;
|
|
157
|
-
measured_at: Generated<Date>;
|
|
158
|
-
storage_bytes: Generated<number>;
|
|
159
|
-
}
|
|
160
|
-
interface WaitlistTable {
|
|
161
|
-
id: Generated<string>;
|
|
162
|
-
email: string;
|
|
163
|
-
source: Generated<string>;
|
|
164
|
-
status: Generated<string>;
|
|
165
|
-
created_at: Generated<Date>;
|
|
166
|
-
}
|
|
167
|
-
interface AccountInsightsTable {
|
|
168
|
-
id: Generated<string>;
|
|
169
|
-
account_id: string;
|
|
170
|
-
category: string;
|
|
171
|
-
insight_type: string;
|
|
172
|
-
resource_id: string | null;
|
|
173
|
-
severity: string;
|
|
174
|
-
title: string;
|
|
175
|
-
body: string;
|
|
176
|
-
data: unknown;
|
|
177
|
-
dismissed_at: Date | null;
|
|
178
|
-
expires_at: Date | null;
|
|
179
|
-
created_at: Generated<Date>;
|
|
180
|
-
}
|
|
181
|
-
interface AccountAgentRunsTable {
|
|
182
|
-
id: Generated<string>;
|
|
183
|
-
account_id: string;
|
|
184
|
-
started_at: Generated<Date>;
|
|
185
|
-
completed_at: Date | null;
|
|
186
|
-
status: Generated<string>;
|
|
187
|
-
input_tokens: Generated<number>;
|
|
188
|
-
output_tokens: Generated<number>;
|
|
189
|
-
cost_usd: Generated<number>;
|
|
190
|
-
insights_created: Generated<number>;
|
|
191
|
-
error: string | null;
|
|
192
|
-
}
|
|
193
|
-
interface SubgraphProcessingStatsTable {
|
|
194
|
-
id: Generated<string>;
|
|
195
|
-
subgraph_name: string;
|
|
196
|
-
api_key_id: string | null;
|
|
197
|
-
bucket_start: Date | null;
|
|
198
|
-
bucket_end: Date | null;
|
|
199
|
-
blocks_processed: number | null;
|
|
200
|
-
total_time_ms: number | null;
|
|
201
|
-
handler_time_ms: number | null;
|
|
202
|
-
flush_time_ms: number | null;
|
|
203
|
-
max_block_time_ms: number | null;
|
|
204
|
-
max_handler_time_ms: number | null;
|
|
205
|
-
avg_ops_per_block: number | null;
|
|
206
|
-
is_catchup: Generated<boolean>;
|
|
207
|
-
created_at: Generated<Date>;
|
|
208
|
-
}
|
|
209
|
-
interface SubgraphTableSnapshotsTable {
|
|
210
|
-
id: Generated<string>;
|
|
211
|
-
subgraph_name: string;
|
|
212
|
-
api_key_id: string | null;
|
|
213
|
-
table_name: string;
|
|
214
|
-
row_count: number | null;
|
|
215
|
-
created_at: Generated<Date>;
|
|
216
|
-
}
|
|
217
|
-
interface SubgraphHealthSnapshotsTable {
|
|
218
|
-
id: Generated<string>;
|
|
219
|
-
subgraph_id: string;
|
|
220
|
-
total_processed: number;
|
|
221
|
-
total_errors: number;
|
|
222
|
-
last_processed_block: number | null;
|
|
223
|
-
captured_at: Generated<Date>;
|
|
224
|
-
}
|
|
225
|
-
interface SubgraphUsageDailyTable {
|
|
226
|
-
subgraph_id: string;
|
|
227
|
-
date: string;
|
|
228
|
-
query_count: Generated<number>;
|
|
229
|
-
}
|
|
230
|
-
interface ProjectsTable {
|
|
231
|
-
id: Generated<string>;
|
|
232
|
-
name: string;
|
|
233
|
-
slug: string;
|
|
234
|
-
account_id: string;
|
|
235
|
-
settings: Generated<Record<string, unknown>>;
|
|
236
|
-
network: Generated<string>;
|
|
237
|
-
node_rpc: string | null;
|
|
238
|
-
created_at: Generated<Date>;
|
|
239
|
-
updated_at: Generated<Date>;
|
|
240
|
-
}
|
|
241
|
-
interface TeamMembersTable {
|
|
242
|
-
id: Generated<string>;
|
|
243
|
-
project_id: string;
|
|
244
|
-
account_id: string;
|
|
245
|
-
role: Generated<string>;
|
|
246
|
-
invited_by: string | null;
|
|
247
|
-
created_at: Generated<Date>;
|
|
248
|
-
}
|
|
249
|
-
interface TeamInvitationsTable {
|
|
250
|
-
id: Generated<string>;
|
|
251
|
-
project_id: string;
|
|
252
|
-
email: string;
|
|
253
|
-
role: Generated<string>;
|
|
254
|
-
token: string;
|
|
255
|
-
invited_by: string | null;
|
|
256
|
-
expires_at: Date;
|
|
257
|
-
accepted_at: Date | null;
|
|
258
|
-
created_at: Generated<Date>;
|
|
259
|
-
}
|
|
260
|
-
interface ChatSessionsTable {
|
|
261
|
-
id: Generated<string>;
|
|
262
|
-
account_id: string;
|
|
263
|
-
title: string | null;
|
|
264
|
-
summary: unknown | null;
|
|
265
|
-
created_at: Generated<Date>;
|
|
266
|
-
updated_at: Generated<Date>;
|
|
267
|
-
}
|
|
268
|
-
interface ChatMessagesTable {
|
|
269
|
-
id: Generated<string>;
|
|
270
|
-
chat_session_id: string;
|
|
271
|
-
role: string;
|
|
272
|
-
parts: unknown;
|
|
273
|
-
metadata: unknown | null;
|
|
274
|
-
created_at: Generated<Date>;
|
|
275
|
-
}
|
|
276
|
-
interface ProcessedStripeEventsTable {
|
|
277
|
-
event_id: string;
|
|
278
|
-
event_type: string;
|
|
279
|
-
processed_at: Generated<Date>;
|
|
280
|
-
}
|
|
281
|
-
interface DecodedEventsTable {
|
|
282
|
-
cursor: string;
|
|
283
|
-
block_height: number;
|
|
284
|
-
tx_id: string;
|
|
285
|
-
tx_index: number;
|
|
286
|
-
event_index: number;
|
|
287
|
-
event_type: string;
|
|
288
|
-
microblock_hash: string | null;
|
|
289
|
-
canonical: Generated<boolean>;
|
|
290
|
-
contract_id: string | null;
|
|
291
|
-
sender: string | null;
|
|
292
|
-
recipient: string | null;
|
|
293
|
-
amount: string | null;
|
|
294
|
-
asset_identifier: string | null;
|
|
295
|
-
value: string | null;
|
|
296
|
-
memo: string | null;
|
|
297
|
-
source_cursor: string;
|
|
298
|
-
created_at: Generated<Date>;
|
|
299
|
-
}
|
|
300
|
-
interface L2DecoderCheckpointsTable {
|
|
301
|
-
decoder_name: string;
|
|
302
|
-
last_cursor: string | null;
|
|
303
|
-
updated_at: Generated<Date>;
|
|
304
|
-
}
|
|
305
|
-
interface ChainReorgsTable {
|
|
306
|
-
id: Generated<string>;
|
|
307
|
-
detected_at: Generated<Date>;
|
|
308
|
-
fork_point_height: number;
|
|
309
|
-
old_index_block_hash: string | null;
|
|
310
|
-
new_index_block_hash: string | null;
|
|
311
|
-
orphaned_from_height: number;
|
|
312
|
-
orphaned_from_event_index: number;
|
|
313
|
-
orphaned_to_height: number;
|
|
314
|
-
orphaned_to_event_index: number;
|
|
315
|
-
new_canonical_height: number;
|
|
316
|
-
new_canonical_event_index: number;
|
|
317
|
-
created_at: Generated<Date>;
|
|
318
|
-
}
|
|
319
|
-
type Pox4FunctionName = "stack-stx" | "delegate-stx" | "stack-extend" | "stack-increase" | "revoke-delegate-stx" | "delegate-stack-stx" | "delegate-stack-extend" | "delegate-stack-increase" | "stack-aggregation-commit" | "stack-aggregation-commit-indexed" | "stack-aggregation-increase" | "set-signer-key-authorization";
|
|
320
|
-
interface Pox4CallsTable {
|
|
321
|
-
cursor: string;
|
|
322
|
-
block_height: number;
|
|
323
|
-
block_time: Date;
|
|
324
|
-
burn_block_height: number;
|
|
325
|
-
tx_id: string;
|
|
326
|
-
tx_index: number;
|
|
327
|
-
function_name: Pox4FunctionName;
|
|
328
|
-
caller: string;
|
|
329
|
-
stacker: string | null;
|
|
330
|
-
delegate_to: string | null;
|
|
331
|
-
amount_ustx: string | null;
|
|
332
|
-
lock_period: number | null;
|
|
333
|
-
pox_addr_version: number | null;
|
|
334
|
-
pox_addr_hashbytes: string | null;
|
|
335
|
-
pox_addr_btc: string | null;
|
|
336
|
-
start_cycle: number | null;
|
|
337
|
-
end_cycle: number | null;
|
|
338
|
-
signer_key: string | null;
|
|
339
|
-
signer_signature: string | null;
|
|
340
|
-
auth_id: string | null;
|
|
341
|
-
max_amount: string | null;
|
|
342
|
-
reward_cycle: number | null;
|
|
343
|
-
aggregated_amount_ustx: string | null;
|
|
344
|
-
aggregated_signer_index: number | null;
|
|
345
|
-
auth_period: number | null;
|
|
346
|
-
auth_topic: string | null;
|
|
347
|
-
auth_allowed: boolean | null;
|
|
348
|
-
result_ok: boolean;
|
|
349
|
-
result_raw: string;
|
|
350
|
-
canonical: Generated<boolean>;
|
|
351
|
-
source_cursor: string;
|
|
352
|
-
created_at: Generated<Date>;
|
|
353
|
-
}
|
|
354
|
-
interface Pox4CyclesDailyTable {
|
|
355
|
-
date: string;
|
|
356
|
-
reward_cycle: number;
|
|
357
|
-
total_stacked_ustx: Generated<string>;
|
|
358
|
-
solo_stackers: Generated<number>;
|
|
359
|
-
delegated_principals: Generated<number>;
|
|
360
|
-
unique_pools: Generated<number>;
|
|
361
|
-
unique_signers: Generated<number>;
|
|
362
|
-
calls_today: Generated<number>;
|
|
363
|
-
updated_at: Generated<Date>;
|
|
364
|
-
}
|
|
365
|
-
interface Pox4SignersDailyTable {
|
|
366
|
-
date: string;
|
|
367
|
-
reward_cycle: number;
|
|
368
|
-
signer_key: string;
|
|
369
|
-
weight_ustx: Generated<string>;
|
|
370
|
-
stacker_count: Generated<number>;
|
|
371
|
-
aggregation_calls: Generated<number>;
|
|
372
|
-
updated_at: Generated<Date>;
|
|
373
|
-
}
|
|
374
|
-
type SbtcEventTopic = "completed-deposit" | "withdrawal-create" | "withdrawal-accept" | "withdrawal-reject" | "key-rotation" | "update-protocol-contract";
|
|
375
|
-
interface SbtcEventsTable {
|
|
376
|
-
cursor: string;
|
|
377
|
-
block_height: number;
|
|
378
|
-
block_time: Date;
|
|
379
|
-
tx_id: string;
|
|
380
|
-
tx_index: number;
|
|
381
|
-
event_index: number;
|
|
382
|
-
topic: SbtcEventTopic;
|
|
383
|
-
request_id: number | null;
|
|
384
|
-
amount: string | null;
|
|
385
|
-
sender: string | null;
|
|
386
|
-
recipient_btc_version: number | null;
|
|
387
|
-
recipient_btc_hashbytes: string | null;
|
|
388
|
-
bitcoin_txid: string | null;
|
|
389
|
-
output_index: number | null;
|
|
390
|
-
sweep_txid: string | null;
|
|
391
|
-
burn_hash: string | null;
|
|
392
|
-
burn_height: number | null;
|
|
393
|
-
signer_bitmap: string | null;
|
|
394
|
-
max_fee: string | null;
|
|
395
|
-
fee: string | null;
|
|
396
|
-
block_height_at_request: number | null;
|
|
397
|
-
governance_contract_type: number | null;
|
|
398
|
-
governance_new_contract: string | null;
|
|
399
|
-
signer_aggregate_pubkey: string | null;
|
|
400
|
-
signer_threshold: number | null;
|
|
401
|
-
signer_address: string | null;
|
|
402
|
-
signer_keys_count: number | null;
|
|
403
|
-
canonical: Generated<boolean>;
|
|
404
|
-
source_cursor: string;
|
|
405
|
-
created_at: Generated<Date>;
|
|
406
|
-
}
|
|
407
|
-
type SbtcTokenEventType = "transfer" | "mint" | "burn";
|
|
408
|
-
interface SbtcTokenEventsTable {
|
|
409
|
-
cursor: string;
|
|
410
|
-
block_height: number;
|
|
411
|
-
block_time: Date;
|
|
412
|
-
tx_id: string;
|
|
413
|
-
tx_index: number;
|
|
414
|
-
event_index: number;
|
|
415
|
-
event_type: SbtcTokenEventType;
|
|
416
|
-
sender: string | null;
|
|
417
|
-
recipient: string | null;
|
|
418
|
-
amount: string;
|
|
419
|
-
memo: string | null;
|
|
420
|
-
canonical: Generated<boolean>;
|
|
421
|
-
source_cursor: string;
|
|
422
|
-
created_at: Generated<Date>;
|
|
423
|
-
}
|
|
424
|
-
interface SbtcSupplySnapshotsTable {
|
|
425
|
-
date: string;
|
|
426
|
-
total_supply: Generated<string>;
|
|
427
|
-
mints_today: Generated<string>;
|
|
428
|
-
burns_today: Generated<string>;
|
|
429
|
-
deposit_count: Generated<number>;
|
|
430
|
-
withdrawal_create_count: Generated<number>;
|
|
431
|
-
withdrawal_accept_count: Generated<number>;
|
|
432
|
-
withdrawal_reject_count: Generated<number>;
|
|
433
|
-
updated_at: Generated<Date>;
|
|
434
|
-
}
|
|
435
|
-
type BnsNameEventTopic = "new-name" | "transfer-name" | "renew-name" | "burn-name" | "new-airdrop";
|
|
436
|
-
interface BnsNameEventsTable {
|
|
437
|
-
cursor: string;
|
|
438
|
-
block_height: number;
|
|
439
|
-
block_time: Date;
|
|
440
|
-
tx_id: string;
|
|
441
|
-
tx_index: number;
|
|
442
|
-
event_index: number;
|
|
443
|
-
topic: BnsNameEventTopic;
|
|
444
|
-
namespace: string;
|
|
445
|
-
name: string;
|
|
446
|
-
fqn: string;
|
|
447
|
-
owner: string | null;
|
|
448
|
-
bns_id: string;
|
|
449
|
-
registered_at: number | null;
|
|
450
|
-
imported_at: number | null;
|
|
451
|
-
renewal_height: number | null;
|
|
452
|
-
stx_burn: string | null;
|
|
453
|
-
preordered_by: string | null;
|
|
454
|
-
hashed_salted_fqn_preorder: string | null;
|
|
455
|
-
canonical: Generated<boolean>;
|
|
456
|
-
source_cursor: string;
|
|
457
|
-
created_at: Generated<Date>;
|
|
458
|
-
}
|
|
459
|
-
type BnsNamespaceEventStatus = "launch" | "transfer-manager" | "freeze-manager" | "update-price-manager" | "freeze-price-manager" | "turn-off-manager-transfers";
|
|
460
|
-
interface BnsNamespaceEventsTable {
|
|
461
|
-
cursor: string;
|
|
462
|
-
block_height: number;
|
|
463
|
-
block_time: Date;
|
|
464
|
-
tx_id: string;
|
|
465
|
-
tx_index: number;
|
|
466
|
-
event_index: number;
|
|
467
|
-
status: BnsNamespaceEventStatus;
|
|
468
|
-
namespace: string;
|
|
469
|
-
manager: string | null;
|
|
470
|
-
manager_frozen: boolean | null;
|
|
471
|
-
manager_transfers_disabled: boolean | null;
|
|
472
|
-
price_function: string | null;
|
|
473
|
-
price_frozen: boolean | null;
|
|
474
|
-
lifetime: number | null;
|
|
475
|
-
revealed_at: number | null;
|
|
476
|
-
launched_at: number | null;
|
|
477
|
-
canonical: Generated<boolean>;
|
|
478
|
-
source_cursor: string;
|
|
479
|
-
created_at: Generated<Date>;
|
|
480
|
-
}
|
|
481
|
-
type BnsMarketplaceAction = "list-in-ustx" | "unlist-in-ustx" | "buy-in-ustx";
|
|
482
|
-
interface BnsMarketplaceEventsTable {
|
|
483
|
-
cursor: string;
|
|
484
|
-
block_height: number;
|
|
485
|
-
block_time: Date;
|
|
486
|
-
tx_id: string;
|
|
487
|
-
tx_index: number;
|
|
488
|
-
event_index: number;
|
|
489
|
-
action: BnsMarketplaceAction;
|
|
490
|
-
bns_id: string;
|
|
491
|
-
price_ustx: string | null;
|
|
492
|
-
commission: string | null;
|
|
493
|
-
canonical: Generated<boolean>;
|
|
494
|
-
source_cursor: string;
|
|
495
|
-
created_at: Generated<Date>;
|
|
496
|
-
}
|
|
497
|
-
interface BnsNamesTable {
|
|
498
|
-
fqn: string;
|
|
499
|
-
namespace: string;
|
|
500
|
-
name: string;
|
|
501
|
-
owner: string;
|
|
502
|
-
bns_id: string;
|
|
503
|
-
registered_at: number | null;
|
|
504
|
-
renewal_height: number | null;
|
|
505
|
-
last_event_cursor: string;
|
|
506
|
-
last_event_at: Date;
|
|
507
|
-
updated_at: Generated<Date>;
|
|
508
|
-
}
|
|
509
|
-
interface BnsNamespacesTable {
|
|
510
|
-
namespace: string;
|
|
511
|
-
manager: string | null;
|
|
512
|
-
manager_frozen: Generated<boolean>;
|
|
513
|
-
price_frozen: Generated<boolean>;
|
|
514
|
-
lifetime: number | null;
|
|
515
|
-
launched_at: number | null;
|
|
516
|
-
last_event_cursor: string;
|
|
517
|
-
last_event_at: Date;
|
|
518
|
-
name_count: Generated<number>;
|
|
519
|
-
updated_at: Generated<Date>;
|
|
520
|
-
}
|
|
521
|
-
interface Database {
|
|
522
|
-
blocks: BlocksTable;
|
|
523
|
-
transactions: TransactionsTable;
|
|
524
|
-
events: EventsTable;
|
|
525
|
-
index_progress: IndexProgressTable;
|
|
526
|
-
subgraphs: SubgraphsTable;
|
|
527
|
-
api_keys: ApiKeysTable;
|
|
528
|
-
accounts: AccountsTable;
|
|
529
|
-
sessions: SessionsTable;
|
|
530
|
-
magic_links: MagicLinksTable;
|
|
531
|
-
usage_daily: UsageDailyTable;
|
|
532
|
-
usage_snapshots: UsageSnapshotsTable;
|
|
533
|
-
waitlist: WaitlistTable;
|
|
534
|
-
account_insights: AccountInsightsTable;
|
|
535
|
-
account_agent_runs: AccountAgentRunsTable;
|
|
536
|
-
subgraph_health_snapshots: SubgraphHealthSnapshotsTable;
|
|
537
|
-
subgraph_processing_stats: SubgraphProcessingStatsTable;
|
|
538
|
-
subgraph_table_snapshots: SubgraphTableSnapshotsTable;
|
|
539
|
-
subgraph_gaps: SubgraphGapsTable;
|
|
540
|
-
subgraph_operations: SubgraphOperationsTable;
|
|
541
|
-
subgraph_usage_daily: SubgraphUsageDailyTable;
|
|
542
|
-
projects: ProjectsTable;
|
|
543
|
-
team_members: TeamMembersTable;
|
|
544
|
-
team_invitations: TeamInvitationsTable;
|
|
545
|
-
chat_sessions: ChatSessionsTable;
|
|
546
|
-
chat_messages: ChatMessagesTable;
|
|
547
|
-
processed_stripe_events: ProcessedStripeEventsTable;
|
|
548
|
-
tenants: TenantsTable;
|
|
549
|
-
tenant_usage_monthly: TenantUsageMonthlyTable;
|
|
550
|
-
tenant_compute_addons: TenantComputeAddonsTable;
|
|
551
|
-
account_spend_caps: AccountSpendCapsTable;
|
|
552
|
-
provisioning_audit_log: ProvisioningAuditLogTable;
|
|
553
|
-
subscriptions: SubscriptionsTable;
|
|
554
|
-
subscription_outbox: SubscriptionOutboxTable;
|
|
555
|
-
subscription_deliveries: SubscriptionDeliveriesTable;
|
|
556
|
-
decoded_events: DecodedEventsTable;
|
|
557
|
-
l2_decoder_checkpoints: L2DecoderCheckpointsTable;
|
|
558
|
-
chain_reorgs: ChainReorgsTable;
|
|
559
|
-
pox4_calls: Pox4CallsTable;
|
|
560
|
-
pox4_cycles_daily: Pox4CyclesDailyTable;
|
|
561
|
-
pox4_signers_daily: Pox4SignersDailyTable;
|
|
562
|
-
sbtc_events: SbtcEventsTable;
|
|
563
|
-
sbtc_token_events: SbtcTokenEventsTable;
|
|
564
|
-
sbtc_supply_snapshots: SbtcSupplySnapshotsTable;
|
|
565
|
-
bns_name_events: BnsNameEventsTable;
|
|
566
|
-
bns_namespace_events: BnsNamespaceEventsTable;
|
|
567
|
-
bns_marketplace_events: BnsMarketplaceEventsTable;
|
|
568
|
-
bns_names: BnsNamesTable;
|
|
569
|
-
bns_namespaces: BnsNamespacesTable;
|
|
570
|
-
service_heartbeats: ServiceHeartbeatsTable;
|
|
571
|
-
}
|
|
572
|
-
interface ServiceHeartbeatsTable {
|
|
573
|
-
name: string;
|
|
574
|
-
updated_at: Generated<Date>;
|
|
575
|
-
}
|
|
576
|
-
type TenantStatus = "provisioning" | "active" | "limit_warning" | "paused_limit" | "suspended" | "error" | "deleted";
|
|
577
|
-
interface TenantsTable {
|
|
578
|
-
id: Generated<string>;
|
|
579
|
-
account_id: string;
|
|
580
|
-
slug: string;
|
|
581
|
-
status: ColumnType<TenantStatus, TenantStatus | undefined, TenantStatus>;
|
|
582
|
-
plan: string;
|
|
583
|
-
cpus: ColumnType<number, number | string, number | string>;
|
|
584
|
-
memory_mb: number;
|
|
585
|
-
storage_limit_mb: number;
|
|
586
|
-
storage_used_mb: number | null;
|
|
587
|
-
pg_container_id: string | null;
|
|
588
|
-
api_container_id: string | null;
|
|
589
|
-
processor_container_id: string | null;
|
|
590
|
-
target_database_url_enc: Buffer;
|
|
591
|
-
tenant_jwt_secret_enc: Buffer;
|
|
592
|
-
anon_key_enc: Buffer;
|
|
593
|
-
service_key_enc: Buffer;
|
|
594
|
-
api_url_internal: string;
|
|
595
|
-
api_url_public: string;
|
|
596
|
-
suspended_at: Date | null;
|
|
597
|
-
last_health_check_at: Date | null;
|
|
598
|
-
last_active_at: Generated<Date>;
|
|
599
|
-
service_gen: Generated<number>;
|
|
600
|
-
anon_gen: Generated<number>;
|
|
601
|
-
project_id: string | null;
|
|
602
|
-
created_at: Generated<Date>;
|
|
603
|
-
updated_at: Generated<Date>;
|
|
604
|
-
}
|
|
605
|
-
type Tenant = Selectable<TenantsTable>;
|
|
606
|
-
interface TenantUsageMonthlyTable {
|
|
607
|
-
id: Generated<string>;
|
|
608
|
-
tenant_id: string;
|
|
609
|
-
period_month: Date;
|
|
610
|
-
storage_peak_mb: Generated<number>;
|
|
611
|
-
storage_avg_mb: Generated<number>;
|
|
612
|
-
storage_last_mb: Generated<number>;
|
|
613
|
-
measurements: Generated<number>;
|
|
614
|
-
first_at: Generated<Date>;
|
|
615
|
-
last_at: Generated<Date>;
|
|
616
|
-
}
|
|
617
|
-
interface TenantComputeAddonsTable {
|
|
618
|
-
id: Generated<string>;
|
|
619
|
-
tenant_id: string;
|
|
620
|
-
memory_mb_delta: Generated<number>;
|
|
621
|
-
cpu_delta: Generated<number | string>;
|
|
622
|
-
storage_mb_delta: Generated<number>;
|
|
623
|
-
effective_from: Generated<Date>;
|
|
624
|
-
effective_until: Date | null;
|
|
625
|
-
stripe_subscription_item_id: string | null;
|
|
626
|
-
created_at: Generated<Date>;
|
|
627
|
-
}
|
|
628
|
-
interface AccountSpendCapsTable {
|
|
629
|
-
account_id: string;
|
|
630
|
-
monthly_cap_cents: number | null;
|
|
631
|
-
compute_cap_cents: number | null;
|
|
632
|
-
storage_cap_cents: number | null;
|
|
633
|
-
alert_threshold_pct: Generated<number>;
|
|
634
|
-
alert_sent_at: Date | null;
|
|
635
|
-
frozen_at: Date | null;
|
|
636
|
-
updated_at: Generated<Date>;
|
|
637
|
-
}
|
|
638
|
-
type ProvisioningAuditEvent = "provision.start" | "provision.success" | "provision.failure" | "suspend" | "resume" | "resize" | "keys.rotate" | "bastion.key.upload" | "bastion.key.revoke" | "teardown";
|
|
639
|
-
type ProvisioningAuditStatus = "ok" | "error";
|
|
640
|
-
interface ProvisioningAuditLogTable {
|
|
641
|
-
id: Generated<string>;
|
|
642
|
-
tenant_id: string | null;
|
|
643
|
-
tenant_slug: string | null;
|
|
644
|
-
account_id: string | null;
|
|
645
|
-
actor: string;
|
|
646
|
-
event: ProvisioningAuditEvent;
|
|
647
|
-
status: ProvisioningAuditStatus;
|
|
648
|
-
detail: unknown | null;
|
|
649
|
-
error: string | null;
|
|
650
|
-
created_at: Generated<Date>;
|
|
651
|
-
}
|
|
652
|
-
type SubscriptionStatus = "active" | "paused" | "error";
|
|
653
|
-
type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
654
|
-
type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
655
|
-
interface SubscriptionsTable {
|
|
656
|
-
id: Generated<string>;
|
|
657
|
-
account_id: string;
|
|
658
|
-
project_id: string | null;
|
|
659
|
-
name: string;
|
|
660
|
-
status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
|
|
661
|
-
subgraph_name: string;
|
|
662
|
-
table_name: string;
|
|
663
|
-
filter: Generated<unknown>;
|
|
664
|
-
format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
|
|
665
|
-
runtime: SubscriptionRuntime | null;
|
|
666
|
-
url: string;
|
|
667
|
-
signing_secret_enc: Buffer;
|
|
668
|
-
auth_config: Generated<unknown>;
|
|
669
|
-
max_retries: Generated<number>;
|
|
670
|
-
timeout_ms: Generated<number>;
|
|
671
|
-
concurrency: Generated<number>;
|
|
672
|
-
circuit_failures: Generated<number>;
|
|
673
|
-
circuit_opened_at: Date | null;
|
|
674
|
-
last_delivery_at: Date | null;
|
|
675
|
-
last_success_at: Date | null;
|
|
676
|
-
last_error: string | null;
|
|
677
|
-
created_at: Generated<Date>;
|
|
678
|
-
updated_at: Generated<Date>;
|
|
679
|
-
}
|
|
680
|
-
type OutboxStatus = "pending" | "delivered" | "dead";
|
|
681
|
-
interface SubscriptionOutboxTable {
|
|
682
|
-
id: Generated<string>;
|
|
683
|
-
subscription_id: string;
|
|
684
|
-
subgraph_name: string;
|
|
685
|
-
table_name: string;
|
|
686
|
-
block_height: number | bigint;
|
|
687
|
-
tx_id: string | null;
|
|
688
|
-
row_pk: unknown;
|
|
689
|
-
event_type: string;
|
|
690
|
-
payload: unknown;
|
|
691
|
-
dedup_key: string;
|
|
692
|
-
attempt: Generated<number>;
|
|
693
|
-
next_attempt_at: Generated<Date>;
|
|
694
|
-
status: ColumnType<OutboxStatus, OutboxStatus | undefined, OutboxStatus>;
|
|
695
|
-
is_replay: Generated<boolean>;
|
|
696
|
-
delivered_at: Date | null;
|
|
697
|
-
failed_at: Date | null;
|
|
698
|
-
locked_by: string | null;
|
|
699
|
-
locked_until: Date | null;
|
|
700
|
-
created_at: Generated<Date>;
|
|
701
|
-
}
|
|
702
|
-
interface SubscriptionDeliveriesTable {
|
|
703
|
-
id: Generated<string>;
|
|
704
|
-
outbox_id: string;
|
|
705
|
-
subscription_id: string;
|
|
706
|
-
attempt: number;
|
|
707
|
-
status_code: number | null;
|
|
708
|
-
response_headers: unknown | null;
|
|
709
|
-
response_body: string | null;
|
|
710
|
-
error_message: string | null;
|
|
711
|
-
duration_ms: number | null;
|
|
712
|
-
dispatched_at: Generated<Date>;
|
|
713
|
-
}
|
|
714
|
-
/**
|
|
715
|
-
* Tenant registry queries. Encrypted columns are stored as `bytea` and
|
|
716
|
-
* transparently encrypted/decrypted via `encryptSecret`/`decryptSecret`.
|
|
717
|
-
*
|
|
718
|
-
* Never return decrypted values from listTenants — only `getTenantCredentials`
|
|
719
|
-
* surfaces plaintext, and only when explicitly called by a caller that
|
|
720
|
-
* needs to hand creds to a CLI or dashboard session.
|
|
721
|
-
*/
|
|
722
|
-
interface NewTenantInput {
|
|
723
|
-
accountId: string;
|
|
724
|
-
slug: string;
|
|
725
|
-
plan: string;
|
|
726
|
-
cpus: number;
|
|
727
|
-
memoryMb: number;
|
|
728
|
-
storageLimitMb: number;
|
|
729
|
-
pgContainerId: string;
|
|
730
|
-
apiContainerId: string;
|
|
731
|
-
processorContainerId: string;
|
|
732
|
-
targetDatabaseUrl: string;
|
|
733
|
-
tenantJwtSecret: string;
|
|
734
|
-
anonKey: string;
|
|
735
|
-
serviceKey: string;
|
|
736
|
-
apiUrlInternal: string;
|
|
737
|
-
apiUrlPublic: string;
|
|
738
|
-
projectId?: string;
|
|
739
|
-
}
|
|
740
|
-
declare function insertTenant(db: Kysely<Database>, input: NewTenantInput): Promise<Tenant>;
|
|
741
|
-
declare function getTenantByAccount(db: Kysely<Database>, accountId: string): Promise<Tenant | null>;
|
|
742
|
-
declare function getTenantBySlug(db: Kysely<Database>, slug: string): Promise<Tenant | null>;
|
|
743
|
-
declare function listTenantsByStatus(db: Kysely<Database>, status: TenantStatus): Promise<Tenant[]>;
|
|
744
|
-
/**
|
|
745
|
-
* Bump `last_active_at` for a tenant. Callers are expected to throttle
|
|
746
|
-
* (don't hammer on every request) — the tenant-API activity middleware
|
|
747
|
-
* enforces a 60s per-tenant min between writes.
|
|
748
|
-
*/
|
|
749
|
-
declare function bumpTenantActivity(db: Kysely<Database>, slug: string): Promise<void>;
|
|
750
|
-
declare function listSuspendedOlderThan(db: Kysely<Database>, olderThan: Date): Promise<Tenant[]>;
|
|
751
|
-
declare function setTenantStatus(db: Kysely<Database>, slug: string, status: TenantStatus): Promise<void>;
|
|
752
|
-
declare function recordHealthCheck(db: Kysely<Database>, slug: string, storageUsedMb: number | null): Promise<void>;
|
|
753
|
-
/**
|
|
754
|
-
* Record a storage measurement into the current calendar month's bucket.
|
|
755
|
-
* Maintains peak, running average, and the most recent value in a single
|
|
756
|
-
* upsert. Billing will consume this later; for now the table just gives
|
|
757
|
-
* us evidence of usage over time.
|
|
758
|
-
*/
|
|
759
|
-
declare function recordMonthlyUsage(db: Kysely<Database>, tenantId: string, storageMb: number): Promise<void>;
|
|
760
|
-
declare function updateTenantPlan(db: Kysely<Database>, slug: string, plan: string, cpus: number, memoryMb: number, storageLimitMb: number): Promise<void>;
|
|
761
|
-
type RotateType = "service" | "anon" | "both";
|
|
762
|
-
/**
|
|
763
|
-
* Bump the selected gen counter(s) by 1 and return the new values.
|
|
764
|
-
* Used by the key-rotate endpoint to force the tenant API to reject
|
|
765
|
-
* previously-issued tokens of the rotated role(s).
|
|
766
|
-
*/
|
|
767
|
-
declare function bumpTenantKeyGen(db: Kysely<Database>, slug: string, type: RotateType): Promise<{
|
|
768
|
-
serviceGen: number
|
|
769
|
-
anonGen: number
|
|
770
|
-
}>;
|
|
771
|
-
/**
|
|
772
|
-
* Replace the encrypted key columns after a successful rotate. Only the
|
|
773
|
-
* rotated column(s) are written — the other stays untouched.
|
|
774
|
-
*/
|
|
775
|
-
declare function updateTenantKeys(db: Kysely<Database>, slug: string, keys: {
|
|
776
|
-
serviceKey?: string
|
|
777
|
-
anonKey?: string
|
|
778
|
-
}): Promise<void>;
|
|
779
|
-
/**
|
|
780
|
-
* Hard-delete a tenant row. Call only AFTER the provisioner has torn down
|
|
781
|
-
* containers + volume; otherwise orphaned resources linger. Returns whether
|
|
782
|
-
* a row was actually deleted.
|
|
783
|
-
*/
|
|
784
|
-
declare function deleteTenant(db: Kysely<Database>, slug: string): Promise<boolean>;
|
|
785
|
-
interface TenantCredentials {
|
|
786
|
-
slug: string;
|
|
787
|
-
targetDatabaseUrl: string;
|
|
788
|
-
tenantJwtSecret: string;
|
|
789
|
-
anonKey: string;
|
|
790
|
-
serviceKey: string;
|
|
791
|
-
apiUrlInternal: string;
|
|
792
|
-
apiUrlPublic: string;
|
|
793
|
-
}
|
|
794
|
-
/**
|
|
795
|
-
* Decrypts the four encrypted columns and returns them plaintext. Call
|
|
796
|
-
* this only when surfacing credentials to an authorized caller (dashboard,
|
|
797
|
-
* CLI). Never log the returned object.
|
|
798
|
-
*/
|
|
799
|
-
declare function getTenantCredentials(db: Kysely<Database>, slug: string): Promise<TenantCredentials | null>;
|
|
800
|
-
export { updateTenantPlan, updateTenantKeys, setTenantStatus, recordMonthlyUsage, recordHealthCheck, listTenantsByStatus, listSuspendedOlderThan, insertTenant, getTenantCredentials, getTenantBySlug, getTenantByAccount, deleteTenant, bumpTenantKeyGen, bumpTenantActivity, TenantCredentials, RotateType, NewTenantInput };
|