@secondlayer/shared 2.1.0 → 3.0.0-beta.1
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/README.md +2 -2
- package/dist/src/crypto/secrets.js +47 -3
- package/dist/src/crypto/secrets.js.map +5 -4
- package/dist/src/db/index.d.ts +112 -137
- package/dist/src/db/index.js.map +2 -2
- package/dist/src/db/jsonb.d.ts +5 -1
- package/dist/src/db/jsonb.js.map +2 -2
- package/dist/src/db/queries/account-spend-caps.d.ts +444 -0
- package/dist/src/db/queries/account-spend-caps.js +60 -0
- package/dist/src/db/queries/account-spend-caps.js.map +10 -0
- package/dist/src/db/queries/account-usage.d.ts +468 -0
- package/dist/src/db/queries/account-usage.js +222 -0
- package/dist/src/db/queries/account-usage.js.map +11 -0
- package/dist/src/db/queries/accounts.d.ts +100 -109
- package/dist/src/db/queries/accounts.js +15 -1
- package/dist/src/db/queries/accounts.js.map +3 -3
- package/dist/src/db/queries/integrity.d.ts +85 -107
- package/dist/src/db/queries/projects.d.ts +87 -109
- package/dist/src/db/queries/provisioning-audit.d.ts +85 -107
- package/dist/src/db/queries/subgraph-gaps.d.ts +85 -107
- package/dist/src/db/queries/subgraphs.d.ts +86 -109
- package/dist/src/db/queries/subgraphs.js +2 -3
- package/dist/src/db/queries/subgraphs.js.map +4 -4
- package/dist/src/db/queries/{workflows.d.ts → tenant-compute-addons.d.ts} +108 -142
- package/dist/src/db/queries/tenant-compute-addons.js +47 -0
- package/dist/src/db/queries/tenant-compute-addons.js.map +10 -0
- package/dist/src/db/queries/tenants.d.ts +98 -110
- package/dist/src/db/queries/tenants.js +55 -8
- package/dist/src/db/queries/tenants.js.map +6 -5
- package/dist/src/db/queries/usage.d.ts +86 -132
- package/dist/src/db/queries/usage.js +5 -64
- package/dist/src/db/queries/usage.js.map +4 -5
- package/dist/src/db/schema.d.ts +107 -136
- package/dist/src/errors.d.ts +8 -7
- package/dist/src/errors.js +11 -12
- package/dist/src/errors.js.map +3 -3
- package/dist/src/index.d.ts +119 -143
- package/dist/src/index.js +11 -12
- package/dist/src/index.js.map +4 -4
- package/dist/src/node/local-client.d.ts +85 -107
- package/dist/src/pricing.d.ts +20 -1
- package/dist/src/pricing.js +58 -1
- package/dist/src/pricing.js.map +3 -3
- package/migrations/0045_drop_marketplace_columns.ts +47 -0
- package/migrations/0046_tenant_activity_signal.ts +47 -0
- package/migrations/0047_usage_daily_tenant_id.ts +73 -0
- package/migrations/0048_tenant_compute_addons.ts +49 -0
- package/migrations/0049_accounts_stripe_customer_id.ts +30 -0
- package/migrations/0050_account_spend_caps.ts +45 -0
- package/migrations/0051_workflow_ai_usage_daily.ts +40 -0
- package/migrations/0052_sentries.ts +61 -0
- package/migrations/0053_workflow_runtime.ts +88 -0
- package/migrations/0054_accounts_plan_hobby.ts +32 -0
- package/migrations/0055_ai_usage_account_scope.ts +108 -0
- package/migrations/0056_drop_workflow_sentry_residuals.ts +23 -0
- package/migrations/0057_subscriptions.ts +137 -0
- package/package.json +26 -14
- package/dist/src/db/queries/workflows.js +0 -260
- package/dist/src/db/queries/workflows.js.map +0 -12
- package/dist/src/lib/plans.d.ts +0 -9
- package/dist/src/lib/plans.js +0 -37
- package/dist/src/lib/plans.js.map +0 -10
- package/dist/src/schemas/workflows.d.ts +0 -70
- package/dist/src/schemas/workflows.js +0 -43
- package/dist/src/schemas/workflows.js.map +0 -10
|
@@ -60,10 +60,6 @@ interface SubgraphsTable {
|
|
|
60
60
|
handler_code: string | null;
|
|
61
61
|
source_code: string | null;
|
|
62
62
|
project_id: string | null;
|
|
63
|
-
is_public: Generated<boolean>;
|
|
64
|
-
tags: Generated<string[]>;
|
|
65
|
-
description: string | null;
|
|
66
|
-
forked_from_id: string | null;
|
|
67
63
|
created_at: Generated<Date>;
|
|
68
64
|
updated_at: Generated<Date>;
|
|
69
65
|
}
|
|
@@ -98,6 +94,7 @@ interface AccountsTable {
|
|
|
98
94
|
bio: string | null;
|
|
99
95
|
avatar_url: string | null;
|
|
100
96
|
slug: string | null;
|
|
97
|
+
stripe_customer_id: string | null;
|
|
101
98
|
created_at: Generated<Date>;
|
|
102
99
|
}
|
|
103
100
|
interface SessionsTable {
|
|
@@ -123,6 +120,7 @@ interface MagicLinksTable {
|
|
|
123
120
|
}
|
|
124
121
|
interface UsageDailyTable {
|
|
125
122
|
account_id: string;
|
|
123
|
+
tenant_id: string | null;
|
|
126
124
|
date: string;
|
|
127
125
|
api_requests: Generated<number>;
|
|
128
126
|
deliveries: Generated<number>;
|
|
@@ -249,83 +247,6 @@ interface ChatMessagesTable {
|
|
|
249
247
|
metadata: unknown | null;
|
|
250
248
|
created_at: Generated<Date>;
|
|
251
249
|
}
|
|
252
|
-
interface WorkflowDefinitionsTable {
|
|
253
|
-
id: Generated<string>;
|
|
254
|
-
name: string;
|
|
255
|
-
version: Generated<string>;
|
|
256
|
-
status: Generated<string>;
|
|
257
|
-
trigger_type: string;
|
|
258
|
-
trigger_config: unknown;
|
|
259
|
-
handler_path: string;
|
|
260
|
-
source_code: string | null;
|
|
261
|
-
retries_config: unknown | null;
|
|
262
|
-
timeout_ms: number | null;
|
|
263
|
-
api_key_id: string;
|
|
264
|
-
project_id: string | null;
|
|
265
|
-
created_at: Generated<Date>;
|
|
266
|
-
updated_at: Generated<Date>;
|
|
267
|
-
}
|
|
268
|
-
interface WorkflowRunsTable {
|
|
269
|
-
id: Generated<string>;
|
|
270
|
-
definition_id: string;
|
|
271
|
-
status: Generated<string>;
|
|
272
|
-
trigger_type: string;
|
|
273
|
-
trigger_data: unknown | null;
|
|
274
|
-
dedup_key: string | null;
|
|
275
|
-
error: string | null;
|
|
276
|
-
started_at: Date | null;
|
|
277
|
-
completed_at: Date | null;
|
|
278
|
-
duration_ms: number | null;
|
|
279
|
-
total_ai_tokens: Generated<number>;
|
|
280
|
-
created_at: Generated<Date>;
|
|
281
|
-
}
|
|
282
|
-
interface WorkflowStepsTable {
|
|
283
|
-
id: Generated<string>;
|
|
284
|
-
run_id: string;
|
|
285
|
-
step_index: number;
|
|
286
|
-
step_id: string;
|
|
287
|
-
step_type: string;
|
|
288
|
-
status: Generated<string>;
|
|
289
|
-
input: unknown | null;
|
|
290
|
-
output: unknown | null;
|
|
291
|
-
error: string | null;
|
|
292
|
-
retry_count: Generated<number>;
|
|
293
|
-
ai_tokens_used: Generated<number>;
|
|
294
|
-
started_at: Date | null;
|
|
295
|
-
completed_at: Date | null;
|
|
296
|
-
duration_ms: number | null;
|
|
297
|
-
memo_key: string | null;
|
|
298
|
-
parent_step_id: string | null;
|
|
299
|
-
created_at: Generated<Date>;
|
|
300
|
-
}
|
|
301
|
-
interface WorkflowQueueTable {
|
|
302
|
-
id: Generated<string>;
|
|
303
|
-
run_id: string;
|
|
304
|
-
status: Generated<string>;
|
|
305
|
-
attempts: Generated<number>;
|
|
306
|
-
max_attempts: Generated<number>;
|
|
307
|
-
scheduled_for: Generated<Date>;
|
|
308
|
-
locked_at: Date | null;
|
|
309
|
-
locked_by: string | null;
|
|
310
|
-
error: string | null;
|
|
311
|
-
created_at: Generated<Date>;
|
|
312
|
-
completed_at: Date | null;
|
|
313
|
-
}
|
|
314
|
-
interface WorkflowSchedulesTable {
|
|
315
|
-
id: Generated<string>;
|
|
316
|
-
definition_id: string;
|
|
317
|
-
cron_expr: string;
|
|
318
|
-
timezone: Generated<string>;
|
|
319
|
-
next_run_at: Date;
|
|
320
|
-
last_run_at: Date | null;
|
|
321
|
-
enabled: Generated<boolean>;
|
|
322
|
-
created_at: Generated<Date>;
|
|
323
|
-
}
|
|
324
|
-
interface WorkflowCursorsTable {
|
|
325
|
-
name: string;
|
|
326
|
-
block_height: Generated<number>;
|
|
327
|
-
updated_at: Generated<Date>;
|
|
328
|
-
}
|
|
329
250
|
interface Database {
|
|
330
251
|
blocks: BlocksTable;
|
|
331
252
|
transactions: TransactionsTable;
|
|
@@ -351,17 +272,14 @@ interface Database {
|
|
|
351
272
|
team_invitations: TeamInvitationsTable;
|
|
352
273
|
chat_sessions: ChatSessionsTable;
|
|
353
274
|
chat_messages: ChatMessagesTable;
|
|
354
|
-
workflow_definitions: WorkflowDefinitionsTable;
|
|
355
|
-
workflow_runs: WorkflowRunsTable;
|
|
356
|
-
workflow_steps: WorkflowStepsTable;
|
|
357
|
-
workflow_queue: WorkflowQueueTable;
|
|
358
|
-
workflow_schedules: WorkflowSchedulesTable;
|
|
359
|
-
workflow_cursors: WorkflowCursorsTable;
|
|
360
|
-
workflow_signer_secrets: WorkflowSignerSecretsTable;
|
|
361
|
-
workflow_budgets: WorkflowBudgetsTable;
|
|
362
275
|
tenants: TenantsTable;
|
|
363
276
|
tenant_usage_monthly: TenantUsageMonthlyTable;
|
|
277
|
+
tenant_compute_addons: TenantComputeAddonsTable;
|
|
278
|
+
account_spend_caps: AccountSpendCapsTable;
|
|
364
279
|
provisioning_audit_log: ProvisioningAuditLogTable;
|
|
280
|
+
subscriptions: SubscriptionsTable;
|
|
281
|
+
subscription_outbox: SubscriptionOutboxTable;
|
|
282
|
+
subscription_deliveries: SubscriptionDeliveriesTable;
|
|
365
283
|
}
|
|
366
284
|
type TenantStatus = "provisioning" | "active" | "suspended" | "error" | "deleted";
|
|
367
285
|
interface TenantsTable {
|
|
@@ -383,9 +301,9 @@ interface TenantsTable {
|
|
|
383
301
|
service_key_enc: Buffer;
|
|
384
302
|
api_url_internal: string;
|
|
385
303
|
api_url_public: string;
|
|
386
|
-
trial_ends_at: Date;
|
|
387
304
|
suspended_at: Date | null;
|
|
388
305
|
last_health_check_at: Date | null;
|
|
306
|
+
last_active_at: Generated<Date>;
|
|
389
307
|
service_gen: Generated<number>;
|
|
390
308
|
anon_gen: Generated<number>;
|
|
391
309
|
project_id: string | null;
|
|
@@ -403,6 +321,28 @@ interface TenantUsageMonthlyTable {
|
|
|
403
321
|
first_at: Generated<Date>;
|
|
404
322
|
last_at: Generated<Date>;
|
|
405
323
|
}
|
|
324
|
+
interface TenantComputeAddonsTable {
|
|
325
|
+
id: Generated<string>;
|
|
326
|
+
tenant_id: string;
|
|
327
|
+
memory_mb_delta: Generated<number>;
|
|
328
|
+
cpu_delta: Generated<number | string>;
|
|
329
|
+
storage_mb_delta: Generated<number>;
|
|
330
|
+
effective_from: Generated<Date>;
|
|
331
|
+
effective_until: Date | null;
|
|
332
|
+
stripe_subscription_item_id: string | null;
|
|
333
|
+
created_at: Generated<Date>;
|
|
334
|
+
}
|
|
335
|
+
interface AccountSpendCapsTable {
|
|
336
|
+
account_id: string;
|
|
337
|
+
monthly_cap_cents: number | null;
|
|
338
|
+
compute_cap_cents: number | null;
|
|
339
|
+
storage_cap_cents: number | null;
|
|
340
|
+
ai_cap_cents: number | null;
|
|
341
|
+
alert_threshold_pct: Generated<number>;
|
|
342
|
+
alert_sent_at: Date | null;
|
|
343
|
+
frozen_at: Date | null;
|
|
344
|
+
updated_at: Generated<Date>;
|
|
345
|
+
}
|
|
406
346
|
type ProvisioningAuditEvent = "provision.start" | "provision.success" | "provision.failure" | "suspend" | "resume" | "resize" | "keys.rotate" | "bastion.key.upload" | "bastion.key.revoke" | "teardown";
|
|
407
347
|
type ProvisioningAuditStatus = "ok" | "error";
|
|
408
348
|
interface ProvisioningAuditLogTable {
|
|
@@ -417,29 +357,67 @@ interface ProvisioningAuditLogTable {
|
|
|
417
357
|
error: string | null;
|
|
418
358
|
created_at: Generated<Date>;
|
|
419
359
|
}
|
|
420
|
-
|
|
360
|
+
type SubscriptionStatus = "active" | "paused" | "error";
|
|
361
|
+
type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
362
|
+
type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
363
|
+
interface SubscriptionsTable {
|
|
421
364
|
id: Generated<string>;
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
365
|
+
account_id: string;
|
|
366
|
+
project_id: string | null;
|
|
367
|
+
name: string;
|
|
368
|
+
status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
|
|
369
|
+
subgraph_name: string;
|
|
370
|
+
table_name: string;
|
|
371
|
+
filter: Generated<unknown>;
|
|
372
|
+
format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
|
|
373
|
+
runtime: SubscriptionRuntime | null;
|
|
374
|
+
url: string;
|
|
375
|
+
signing_secret_enc: Buffer;
|
|
376
|
+
auth_config: Generated<unknown>;
|
|
377
|
+
max_retries: Generated<number>;
|
|
378
|
+
timeout_ms: Generated<number>;
|
|
379
|
+
concurrency: Generated<number>;
|
|
380
|
+
circuit_failures: Generated<number>;
|
|
381
|
+
circuit_opened_at: Date | null;
|
|
382
|
+
last_delivery_at: Date | null;
|
|
383
|
+
last_success_at: Date | null;
|
|
384
|
+
last_error: string | null;
|
|
432
385
|
created_at: Generated<Date>;
|
|
433
386
|
updated_at: Generated<Date>;
|
|
434
387
|
}
|
|
435
|
-
|
|
388
|
+
type OutboxStatus = "pending" | "delivered" | "dead";
|
|
389
|
+
interface SubscriptionOutboxTable {
|
|
436
390
|
id: Generated<string>;
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
391
|
+
subscription_id: string;
|
|
392
|
+
subgraph_name: string;
|
|
393
|
+
table_name: string;
|
|
394
|
+
block_height: number | bigint;
|
|
395
|
+
tx_id: string | null;
|
|
396
|
+
row_pk: unknown;
|
|
397
|
+
event_type: string;
|
|
398
|
+
payload: unknown;
|
|
399
|
+
dedup_key: string;
|
|
400
|
+
attempt: Generated<number>;
|
|
401
|
+
next_attempt_at: Generated<Date>;
|
|
402
|
+
status: ColumnType<OutboxStatus, OutboxStatus | undefined, OutboxStatus>;
|
|
403
|
+
is_replay: Generated<boolean>;
|
|
404
|
+
delivered_at: Date | null;
|
|
405
|
+
failed_at: Date | null;
|
|
406
|
+
locked_by: string | null;
|
|
407
|
+
locked_until: Date | null;
|
|
441
408
|
created_at: Generated<Date>;
|
|
442
|
-
|
|
409
|
+
}
|
|
410
|
+
interface SubscriptionDeliveriesTable {
|
|
411
|
+
id: Generated<string>;
|
|
412
|
+
outbox_id: string;
|
|
413
|
+
subscription_id: string;
|
|
414
|
+
attempt: number;
|
|
415
|
+
status_code: number | null;
|
|
416
|
+
response_headers: unknown | null;
|
|
417
|
+
response_body: string | null;
|
|
418
|
+
error_message: string | null;
|
|
419
|
+
duration_ms: number | null;
|
|
420
|
+
dispatched_at: Generated<Date>;
|
|
443
421
|
}
|
|
444
422
|
interface Gap {
|
|
445
423
|
gapStart: number;
|
|
@@ -60,10 +60,6 @@ interface SubgraphsTable {
|
|
|
60
60
|
handler_code: string | null;
|
|
61
61
|
source_code: string | null;
|
|
62
62
|
project_id: string | null;
|
|
63
|
-
is_public: Generated<boolean>;
|
|
64
|
-
tags: Generated<string[]>;
|
|
65
|
-
description: string | null;
|
|
66
|
-
forked_from_id: string | null;
|
|
67
63
|
created_at: Generated<Date>;
|
|
68
64
|
updated_at: Generated<Date>;
|
|
69
65
|
}
|
|
@@ -98,6 +94,7 @@ interface AccountsTable {
|
|
|
98
94
|
bio: string | null;
|
|
99
95
|
avatar_url: string | null;
|
|
100
96
|
slug: string | null;
|
|
97
|
+
stripe_customer_id: string | null;
|
|
101
98
|
created_at: Generated<Date>;
|
|
102
99
|
}
|
|
103
100
|
interface SessionsTable {
|
|
@@ -123,6 +120,7 @@ interface MagicLinksTable {
|
|
|
123
120
|
}
|
|
124
121
|
interface UsageDailyTable {
|
|
125
122
|
account_id: string;
|
|
123
|
+
tenant_id: string | null;
|
|
126
124
|
date: string;
|
|
127
125
|
api_requests: Generated<number>;
|
|
128
126
|
deliveries: Generated<number>;
|
|
@@ -249,83 +247,6 @@ interface ChatMessagesTable {
|
|
|
249
247
|
metadata: unknown | null;
|
|
250
248
|
created_at: Generated<Date>;
|
|
251
249
|
}
|
|
252
|
-
interface WorkflowDefinitionsTable {
|
|
253
|
-
id: Generated<string>;
|
|
254
|
-
name: string;
|
|
255
|
-
version: Generated<string>;
|
|
256
|
-
status: Generated<string>;
|
|
257
|
-
trigger_type: string;
|
|
258
|
-
trigger_config: unknown;
|
|
259
|
-
handler_path: string;
|
|
260
|
-
source_code: string | null;
|
|
261
|
-
retries_config: unknown | null;
|
|
262
|
-
timeout_ms: number | null;
|
|
263
|
-
api_key_id: string;
|
|
264
|
-
project_id: string | null;
|
|
265
|
-
created_at: Generated<Date>;
|
|
266
|
-
updated_at: Generated<Date>;
|
|
267
|
-
}
|
|
268
|
-
interface WorkflowRunsTable {
|
|
269
|
-
id: Generated<string>;
|
|
270
|
-
definition_id: string;
|
|
271
|
-
status: Generated<string>;
|
|
272
|
-
trigger_type: string;
|
|
273
|
-
trigger_data: unknown | null;
|
|
274
|
-
dedup_key: string | null;
|
|
275
|
-
error: string | null;
|
|
276
|
-
started_at: Date | null;
|
|
277
|
-
completed_at: Date | null;
|
|
278
|
-
duration_ms: number | null;
|
|
279
|
-
total_ai_tokens: Generated<number>;
|
|
280
|
-
created_at: Generated<Date>;
|
|
281
|
-
}
|
|
282
|
-
interface WorkflowStepsTable {
|
|
283
|
-
id: Generated<string>;
|
|
284
|
-
run_id: string;
|
|
285
|
-
step_index: number;
|
|
286
|
-
step_id: string;
|
|
287
|
-
step_type: string;
|
|
288
|
-
status: Generated<string>;
|
|
289
|
-
input: unknown | null;
|
|
290
|
-
output: unknown | null;
|
|
291
|
-
error: string | null;
|
|
292
|
-
retry_count: Generated<number>;
|
|
293
|
-
ai_tokens_used: Generated<number>;
|
|
294
|
-
started_at: Date | null;
|
|
295
|
-
completed_at: Date | null;
|
|
296
|
-
duration_ms: number | null;
|
|
297
|
-
memo_key: string | null;
|
|
298
|
-
parent_step_id: string | null;
|
|
299
|
-
created_at: Generated<Date>;
|
|
300
|
-
}
|
|
301
|
-
interface WorkflowQueueTable {
|
|
302
|
-
id: Generated<string>;
|
|
303
|
-
run_id: string;
|
|
304
|
-
status: Generated<string>;
|
|
305
|
-
attempts: Generated<number>;
|
|
306
|
-
max_attempts: Generated<number>;
|
|
307
|
-
scheduled_for: Generated<Date>;
|
|
308
|
-
locked_at: Date | null;
|
|
309
|
-
locked_by: string | null;
|
|
310
|
-
error: string | null;
|
|
311
|
-
created_at: Generated<Date>;
|
|
312
|
-
completed_at: Date | null;
|
|
313
|
-
}
|
|
314
|
-
interface WorkflowSchedulesTable {
|
|
315
|
-
id: Generated<string>;
|
|
316
|
-
definition_id: string;
|
|
317
|
-
cron_expr: string;
|
|
318
|
-
timezone: Generated<string>;
|
|
319
|
-
next_run_at: Date;
|
|
320
|
-
last_run_at: Date | null;
|
|
321
|
-
enabled: Generated<boolean>;
|
|
322
|
-
created_at: Generated<Date>;
|
|
323
|
-
}
|
|
324
|
-
interface WorkflowCursorsTable {
|
|
325
|
-
name: string;
|
|
326
|
-
block_height: Generated<number>;
|
|
327
|
-
updated_at: Generated<Date>;
|
|
328
|
-
}
|
|
329
250
|
interface Database {
|
|
330
251
|
blocks: BlocksTable;
|
|
331
252
|
transactions: TransactionsTable;
|
|
@@ -351,17 +272,14 @@ interface Database {
|
|
|
351
272
|
team_invitations: TeamInvitationsTable;
|
|
352
273
|
chat_sessions: ChatSessionsTable;
|
|
353
274
|
chat_messages: ChatMessagesTable;
|
|
354
|
-
workflow_definitions: WorkflowDefinitionsTable;
|
|
355
|
-
workflow_runs: WorkflowRunsTable;
|
|
356
|
-
workflow_steps: WorkflowStepsTable;
|
|
357
|
-
workflow_queue: WorkflowQueueTable;
|
|
358
|
-
workflow_schedules: WorkflowSchedulesTable;
|
|
359
|
-
workflow_cursors: WorkflowCursorsTable;
|
|
360
|
-
workflow_signer_secrets: WorkflowSignerSecretsTable;
|
|
361
|
-
workflow_budgets: WorkflowBudgetsTable;
|
|
362
275
|
tenants: TenantsTable;
|
|
363
276
|
tenant_usage_monthly: TenantUsageMonthlyTable;
|
|
277
|
+
tenant_compute_addons: TenantComputeAddonsTable;
|
|
278
|
+
account_spend_caps: AccountSpendCapsTable;
|
|
364
279
|
provisioning_audit_log: ProvisioningAuditLogTable;
|
|
280
|
+
subscriptions: SubscriptionsTable;
|
|
281
|
+
subscription_outbox: SubscriptionOutboxTable;
|
|
282
|
+
subscription_deliveries: SubscriptionDeliveriesTable;
|
|
365
283
|
}
|
|
366
284
|
type TenantStatus = "provisioning" | "active" | "suspended" | "error" | "deleted";
|
|
367
285
|
interface TenantsTable {
|
|
@@ -383,9 +301,9 @@ interface TenantsTable {
|
|
|
383
301
|
service_key_enc: Buffer;
|
|
384
302
|
api_url_internal: string;
|
|
385
303
|
api_url_public: string;
|
|
386
|
-
trial_ends_at: Date;
|
|
387
304
|
suspended_at: Date | null;
|
|
388
305
|
last_health_check_at: Date | null;
|
|
306
|
+
last_active_at: Generated<Date>;
|
|
389
307
|
service_gen: Generated<number>;
|
|
390
308
|
anon_gen: Generated<number>;
|
|
391
309
|
project_id: string | null;
|
|
@@ -403,6 +321,28 @@ interface TenantUsageMonthlyTable {
|
|
|
403
321
|
first_at: Generated<Date>;
|
|
404
322
|
last_at: Generated<Date>;
|
|
405
323
|
}
|
|
324
|
+
interface TenantComputeAddonsTable {
|
|
325
|
+
id: Generated<string>;
|
|
326
|
+
tenant_id: string;
|
|
327
|
+
memory_mb_delta: Generated<number>;
|
|
328
|
+
cpu_delta: Generated<number | string>;
|
|
329
|
+
storage_mb_delta: Generated<number>;
|
|
330
|
+
effective_from: Generated<Date>;
|
|
331
|
+
effective_until: Date | null;
|
|
332
|
+
stripe_subscription_item_id: string | null;
|
|
333
|
+
created_at: Generated<Date>;
|
|
334
|
+
}
|
|
335
|
+
interface AccountSpendCapsTable {
|
|
336
|
+
account_id: string;
|
|
337
|
+
monthly_cap_cents: number | null;
|
|
338
|
+
compute_cap_cents: number | null;
|
|
339
|
+
storage_cap_cents: number | null;
|
|
340
|
+
ai_cap_cents: number | null;
|
|
341
|
+
alert_threshold_pct: Generated<number>;
|
|
342
|
+
alert_sent_at: Date | null;
|
|
343
|
+
frozen_at: Date | null;
|
|
344
|
+
updated_at: Generated<Date>;
|
|
345
|
+
}
|
|
406
346
|
type ProvisioningAuditEvent = "provision.start" | "provision.success" | "provision.failure" | "suspend" | "resume" | "resize" | "keys.rotate" | "bastion.key.upload" | "bastion.key.revoke" | "teardown";
|
|
407
347
|
type ProvisioningAuditStatus = "ok" | "error";
|
|
408
348
|
interface ProvisioningAuditLogTable {
|
|
@@ -417,32 +357,70 @@ interface ProvisioningAuditLogTable {
|
|
|
417
357
|
error: string | null;
|
|
418
358
|
created_at: Generated<Date>;
|
|
419
359
|
}
|
|
420
|
-
|
|
360
|
+
type Project = Selectable<ProjectsTable>;
|
|
361
|
+
type TeamInvitation = Selectable<TeamInvitationsTable>;
|
|
362
|
+
type SubscriptionStatus = "active" | "paused" | "error";
|
|
363
|
+
type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
364
|
+
type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
365
|
+
interface SubscriptionsTable {
|
|
421
366
|
id: Generated<string>;
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
367
|
+
account_id: string;
|
|
368
|
+
project_id: string | null;
|
|
369
|
+
name: string;
|
|
370
|
+
status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
|
|
371
|
+
subgraph_name: string;
|
|
372
|
+
table_name: string;
|
|
373
|
+
filter: Generated<unknown>;
|
|
374
|
+
format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
|
|
375
|
+
runtime: SubscriptionRuntime | null;
|
|
376
|
+
url: string;
|
|
377
|
+
signing_secret_enc: Buffer;
|
|
378
|
+
auth_config: Generated<unknown>;
|
|
379
|
+
max_retries: Generated<number>;
|
|
380
|
+
timeout_ms: Generated<number>;
|
|
381
|
+
concurrency: Generated<number>;
|
|
382
|
+
circuit_failures: Generated<number>;
|
|
383
|
+
circuit_opened_at: Date | null;
|
|
384
|
+
last_delivery_at: Date | null;
|
|
385
|
+
last_success_at: Date | null;
|
|
386
|
+
last_error: string | null;
|
|
432
387
|
created_at: Generated<Date>;
|
|
433
388
|
updated_at: Generated<Date>;
|
|
434
389
|
}
|
|
435
|
-
|
|
390
|
+
type OutboxStatus = "pending" | "delivered" | "dead";
|
|
391
|
+
interface SubscriptionOutboxTable {
|
|
436
392
|
id: Generated<string>;
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
393
|
+
subscription_id: string;
|
|
394
|
+
subgraph_name: string;
|
|
395
|
+
table_name: string;
|
|
396
|
+
block_height: number | bigint;
|
|
397
|
+
tx_id: string | null;
|
|
398
|
+
row_pk: unknown;
|
|
399
|
+
event_type: string;
|
|
400
|
+
payload: unknown;
|
|
401
|
+
dedup_key: string;
|
|
402
|
+
attempt: Generated<number>;
|
|
403
|
+
next_attempt_at: Generated<Date>;
|
|
404
|
+
status: ColumnType<OutboxStatus, OutboxStatus | undefined, OutboxStatus>;
|
|
405
|
+
is_replay: Generated<boolean>;
|
|
406
|
+
delivered_at: Date | null;
|
|
407
|
+
failed_at: Date | null;
|
|
408
|
+
locked_by: string | null;
|
|
409
|
+
locked_until: Date | null;
|
|
441
410
|
created_at: Generated<Date>;
|
|
442
|
-
updated_at: Generated<Date>;
|
|
443
411
|
}
|
|
444
|
-
|
|
445
|
-
|
|
412
|
+
interface SubscriptionDeliveriesTable {
|
|
413
|
+
id: Generated<string>;
|
|
414
|
+
outbox_id: string;
|
|
415
|
+
subscription_id: string;
|
|
416
|
+
attempt: number;
|
|
417
|
+
status_code: number | null;
|
|
418
|
+
response_headers: unknown | null;
|
|
419
|
+
response_body: string | null;
|
|
420
|
+
error_message: string | null;
|
|
421
|
+
duration_ms: number | null;
|
|
422
|
+
dispatched_at: Generated<Date>;
|
|
423
|
+
}
|
|
446
424
|
declare function getProjectsByAccount(db: Kysely<Database>, accountId: string): Promise<Project[]>;
|
|
447
425
|
declare function getProjectBySlug(db: Kysely<Database>, accountId: string, slug: string): Promise<Project | undefined>;
|
|
448
426
|
declare function getTeamMembers(db: Kysely<Database>, projectId: string): Promise<Array<{
|