@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
package/dist/src/db/schema.d.ts
CHANGED
|
@@ -59,10 +59,6 @@ interface SubgraphsTable {
|
|
|
59
59
|
handler_code: string | null;
|
|
60
60
|
source_code: string | null;
|
|
61
61
|
project_id: string | null;
|
|
62
|
-
is_public: Generated<boolean>;
|
|
63
|
-
tags: Generated<string[]>;
|
|
64
|
-
description: string | null;
|
|
65
|
-
forked_from_id: string | null;
|
|
66
62
|
created_at: Generated<Date>;
|
|
67
63
|
updated_at: Generated<Date>;
|
|
68
64
|
}
|
|
@@ -97,6 +93,7 @@ interface AccountsTable {
|
|
|
97
93
|
bio: string | null;
|
|
98
94
|
avatar_url: string | null;
|
|
99
95
|
slug: string | null;
|
|
96
|
+
stripe_customer_id: string | null;
|
|
100
97
|
created_at: Generated<Date>;
|
|
101
98
|
}
|
|
102
99
|
interface SessionsTable {
|
|
@@ -122,6 +119,7 @@ interface MagicLinksTable {
|
|
|
122
119
|
}
|
|
123
120
|
interface UsageDailyTable {
|
|
124
121
|
account_id: string;
|
|
122
|
+
tenant_id: string | null;
|
|
125
123
|
date: string;
|
|
126
124
|
api_requests: Generated<number>;
|
|
127
125
|
deliveries: Generated<number>;
|
|
@@ -248,83 +246,6 @@ interface ChatMessagesTable {
|
|
|
248
246
|
metadata: unknown | null;
|
|
249
247
|
created_at: Generated<Date>;
|
|
250
248
|
}
|
|
251
|
-
interface WorkflowDefinitionsTable {
|
|
252
|
-
id: Generated<string>;
|
|
253
|
-
name: string;
|
|
254
|
-
version: Generated<string>;
|
|
255
|
-
status: Generated<string>;
|
|
256
|
-
trigger_type: string;
|
|
257
|
-
trigger_config: unknown;
|
|
258
|
-
handler_path: string;
|
|
259
|
-
source_code: string | null;
|
|
260
|
-
retries_config: unknown | null;
|
|
261
|
-
timeout_ms: number | null;
|
|
262
|
-
api_key_id: string;
|
|
263
|
-
project_id: string | null;
|
|
264
|
-
created_at: Generated<Date>;
|
|
265
|
-
updated_at: Generated<Date>;
|
|
266
|
-
}
|
|
267
|
-
interface WorkflowRunsTable {
|
|
268
|
-
id: Generated<string>;
|
|
269
|
-
definition_id: string;
|
|
270
|
-
status: Generated<string>;
|
|
271
|
-
trigger_type: string;
|
|
272
|
-
trigger_data: unknown | null;
|
|
273
|
-
dedup_key: string | null;
|
|
274
|
-
error: string | null;
|
|
275
|
-
started_at: Date | null;
|
|
276
|
-
completed_at: Date | null;
|
|
277
|
-
duration_ms: number | null;
|
|
278
|
-
total_ai_tokens: Generated<number>;
|
|
279
|
-
created_at: Generated<Date>;
|
|
280
|
-
}
|
|
281
|
-
interface WorkflowStepsTable {
|
|
282
|
-
id: Generated<string>;
|
|
283
|
-
run_id: string;
|
|
284
|
-
step_index: number;
|
|
285
|
-
step_id: string;
|
|
286
|
-
step_type: string;
|
|
287
|
-
status: Generated<string>;
|
|
288
|
-
input: unknown | null;
|
|
289
|
-
output: unknown | null;
|
|
290
|
-
error: string | null;
|
|
291
|
-
retry_count: Generated<number>;
|
|
292
|
-
ai_tokens_used: Generated<number>;
|
|
293
|
-
started_at: Date | null;
|
|
294
|
-
completed_at: Date | null;
|
|
295
|
-
duration_ms: number | null;
|
|
296
|
-
memo_key: string | null;
|
|
297
|
-
parent_step_id: string | null;
|
|
298
|
-
created_at: Generated<Date>;
|
|
299
|
-
}
|
|
300
|
-
interface WorkflowQueueTable {
|
|
301
|
-
id: Generated<string>;
|
|
302
|
-
run_id: string;
|
|
303
|
-
status: Generated<string>;
|
|
304
|
-
attempts: Generated<number>;
|
|
305
|
-
max_attempts: Generated<number>;
|
|
306
|
-
scheduled_for: Generated<Date>;
|
|
307
|
-
locked_at: Date | null;
|
|
308
|
-
locked_by: string | null;
|
|
309
|
-
error: string | null;
|
|
310
|
-
created_at: Generated<Date>;
|
|
311
|
-
completed_at: Date | null;
|
|
312
|
-
}
|
|
313
|
-
interface WorkflowSchedulesTable {
|
|
314
|
-
id: Generated<string>;
|
|
315
|
-
definition_id: string;
|
|
316
|
-
cron_expr: string;
|
|
317
|
-
timezone: Generated<string>;
|
|
318
|
-
next_run_at: Date;
|
|
319
|
-
last_run_at: Date | null;
|
|
320
|
-
enabled: Generated<boolean>;
|
|
321
|
-
created_at: Generated<Date>;
|
|
322
|
-
}
|
|
323
|
-
interface WorkflowCursorsTable {
|
|
324
|
-
name: string;
|
|
325
|
-
block_height: Generated<number>;
|
|
326
|
-
updated_at: Generated<Date>;
|
|
327
|
-
}
|
|
328
249
|
interface Database {
|
|
329
250
|
blocks: BlocksTable;
|
|
330
251
|
transactions: TransactionsTable;
|
|
@@ -350,17 +271,14 @@ interface Database {
|
|
|
350
271
|
team_invitations: TeamInvitationsTable;
|
|
351
272
|
chat_sessions: ChatSessionsTable;
|
|
352
273
|
chat_messages: ChatMessagesTable;
|
|
353
|
-
workflow_definitions: WorkflowDefinitionsTable;
|
|
354
|
-
workflow_runs: WorkflowRunsTable;
|
|
355
|
-
workflow_steps: WorkflowStepsTable;
|
|
356
|
-
workflow_queue: WorkflowQueueTable;
|
|
357
|
-
workflow_schedules: WorkflowSchedulesTable;
|
|
358
|
-
workflow_cursors: WorkflowCursorsTable;
|
|
359
|
-
workflow_signer_secrets: WorkflowSignerSecretsTable;
|
|
360
|
-
workflow_budgets: WorkflowBudgetsTable;
|
|
361
274
|
tenants: TenantsTable;
|
|
362
275
|
tenant_usage_monthly: TenantUsageMonthlyTable;
|
|
276
|
+
tenant_compute_addons: TenantComputeAddonsTable;
|
|
277
|
+
account_spend_caps: AccountSpendCapsTable;
|
|
363
278
|
provisioning_audit_log: ProvisioningAuditLogTable;
|
|
279
|
+
subscriptions: SubscriptionsTable;
|
|
280
|
+
subscription_outbox: SubscriptionOutboxTable;
|
|
281
|
+
subscription_deliveries: SubscriptionDeliveriesTable;
|
|
364
282
|
}
|
|
365
283
|
type TenantStatus = "provisioning" | "active" | "suspended" | "error" | "deleted";
|
|
366
284
|
interface TenantsTable {
|
|
@@ -382,9 +300,9 @@ interface TenantsTable {
|
|
|
382
300
|
service_key_enc: Buffer;
|
|
383
301
|
api_url_internal: string;
|
|
384
302
|
api_url_public: string;
|
|
385
|
-
trial_ends_at: Date;
|
|
386
303
|
suspended_at: Date | null;
|
|
387
304
|
last_health_check_at: Date | null;
|
|
305
|
+
last_active_at: Generated<Date>;
|
|
388
306
|
service_gen: Generated<number>;
|
|
389
307
|
anon_gen: Generated<number>;
|
|
390
308
|
project_id: string | null;
|
|
@@ -408,6 +326,34 @@ interface TenantUsageMonthlyTable {
|
|
|
408
326
|
type TenantUsageMonthly = Selectable<TenantUsageMonthlyTable>;
|
|
409
327
|
type InsertTenantUsageMonthly = Insertable<TenantUsageMonthlyTable>;
|
|
410
328
|
type UpdateTenantUsageMonthly = Updateable<TenantUsageMonthlyTable>;
|
|
329
|
+
interface TenantComputeAddonsTable {
|
|
330
|
+
id: Generated<string>;
|
|
331
|
+
tenant_id: string;
|
|
332
|
+
memory_mb_delta: Generated<number>;
|
|
333
|
+
cpu_delta: Generated<number | string>;
|
|
334
|
+
storage_mb_delta: Generated<number>;
|
|
335
|
+
effective_from: Generated<Date>;
|
|
336
|
+
effective_until: Date | null;
|
|
337
|
+
stripe_subscription_item_id: string | null;
|
|
338
|
+
created_at: Generated<Date>;
|
|
339
|
+
}
|
|
340
|
+
type TenantComputeAddon = Selectable<TenantComputeAddonsTable>;
|
|
341
|
+
type InsertTenantComputeAddon = Insertable<TenantComputeAddonsTable>;
|
|
342
|
+
type UpdateTenantComputeAddon = Updateable<TenantComputeAddonsTable>;
|
|
343
|
+
interface AccountSpendCapsTable {
|
|
344
|
+
account_id: string;
|
|
345
|
+
monthly_cap_cents: number | null;
|
|
346
|
+
compute_cap_cents: number | null;
|
|
347
|
+
storage_cap_cents: number | null;
|
|
348
|
+
ai_cap_cents: number | null;
|
|
349
|
+
alert_threshold_pct: Generated<number>;
|
|
350
|
+
alert_sent_at: Date | null;
|
|
351
|
+
frozen_at: Date | null;
|
|
352
|
+
updated_at: Generated<Date>;
|
|
353
|
+
}
|
|
354
|
+
type AccountSpendCap = Selectable<AccountSpendCapsTable>;
|
|
355
|
+
type InsertAccountSpendCap = Insertable<AccountSpendCapsTable>;
|
|
356
|
+
type UpdateAccountSpendCap = Updateable<AccountSpendCapsTable>;
|
|
411
357
|
type ProvisioningAuditEvent = "provision.start" | "provision.success" | "provision.failure" | "suspend" | "resume" | "resize" | "keys.rotate" | "bastion.key.upload" | "bastion.key.revoke" | "teardown";
|
|
412
358
|
type ProvisioningAuditStatus = "ok" | "error";
|
|
413
359
|
interface ProvisioningAuditLogTable {
|
|
@@ -424,30 +370,6 @@ interface ProvisioningAuditLogTable {
|
|
|
424
370
|
}
|
|
425
371
|
type ProvisioningAuditLog = Selectable<ProvisioningAuditLogTable>;
|
|
426
372
|
type InsertProvisioningAuditLog = Insertable<ProvisioningAuditLogTable>;
|
|
427
|
-
interface WorkflowBudgetsTable {
|
|
428
|
-
id: Generated<string>;
|
|
429
|
-
workflow_definition_id: string;
|
|
430
|
-
/** Period key: "daily:YYYY-MM-DD" | "weekly:YYYY-Www" | "per-run:<uuid>". */
|
|
431
|
-
period: string;
|
|
432
|
-
ai_usd_used: Generated<string>;
|
|
433
|
-
ai_tokens_used: Generated<string>;
|
|
434
|
-
chain_microstx_used: Generated<string>;
|
|
435
|
-
chain_tx_count: Generated<number>;
|
|
436
|
-
run_count: Generated<number>;
|
|
437
|
-
step_count: Generated<number>;
|
|
438
|
-
reset_at: Date;
|
|
439
|
-
created_at: Generated<Date>;
|
|
440
|
-
updated_at: Generated<Date>;
|
|
441
|
-
}
|
|
442
|
-
interface WorkflowSignerSecretsTable {
|
|
443
|
-
id: Generated<string>;
|
|
444
|
-
account_id: string;
|
|
445
|
-
name: string;
|
|
446
|
-
/** AES-GCM ciphertext bytes produced by the runner's KMS on write. */
|
|
447
|
-
encrypted_value: Buffer;
|
|
448
|
-
created_at: Generated<Date>;
|
|
449
|
-
updated_at: Generated<Date>;
|
|
450
|
-
}
|
|
451
373
|
type Block = Selectable<BlocksTable>;
|
|
452
374
|
type InsertBlock = Insertable<BlocksTable>;
|
|
453
375
|
type UpdateBlock = Updateable<BlocksTable>;
|
|
@@ -484,27 +406,6 @@ type SubgraphGap = Selectable<SubgraphGapsTable>;
|
|
|
484
406
|
type InsertSubgraphGap = Insertable<SubgraphGapsTable>;
|
|
485
407
|
type SubgraphUsageDaily = Selectable<SubgraphUsageDailyTable>;
|
|
486
408
|
type InsertSubgraphUsageDaily = Insertable<SubgraphUsageDailyTable>;
|
|
487
|
-
type WorkflowDefinition = Selectable<WorkflowDefinitionsTable>;
|
|
488
|
-
type InsertWorkflowDefinition = Insertable<WorkflowDefinitionsTable>;
|
|
489
|
-
type UpdateWorkflowDefinition = Updateable<WorkflowDefinitionsTable>;
|
|
490
|
-
type WorkflowRun = Selectable<WorkflowRunsTable>;
|
|
491
|
-
type InsertWorkflowRun = Insertable<WorkflowRunsTable>;
|
|
492
|
-
type UpdateWorkflowRun = Updateable<WorkflowRunsTable>;
|
|
493
|
-
type WorkflowStep = Selectable<WorkflowStepsTable>;
|
|
494
|
-
type InsertWorkflowStep = Insertable<WorkflowStepsTable>;
|
|
495
|
-
type UpdateWorkflowStep = Updateable<WorkflowStepsTable>;
|
|
496
|
-
type WorkflowQueueItem = Selectable<WorkflowQueueTable>;
|
|
497
|
-
type InsertWorkflowQueueItem = Insertable<WorkflowQueueTable>;
|
|
498
|
-
type WorkflowSchedule = Selectable<WorkflowSchedulesTable>;
|
|
499
|
-
type InsertWorkflowSchedule = Insertable<WorkflowSchedulesTable>;
|
|
500
|
-
type UpdateWorkflowSchedule = Updateable<WorkflowSchedulesTable>;
|
|
501
|
-
type WorkflowCursor = Selectable<WorkflowCursorsTable>;
|
|
502
|
-
type WorkflowSignerSecret = Selectable<WorkflowSignerSecretsTable>;
|
|
503
|
-
type InsertWorkflowSignerSecret = Insertable<WorkflowSignerSecretsTable>;
|
|
504
|
-
type UpdateWorkflowSignerSecret = Updateable<WorkflowSignerSecretsTable>;
|
|
505
|
-
type WorkflowBudget = Selectable<WorkflowBudgetsTable>;
|
|
506
|
-
type InsertWorkflowBudget = Insertable<WorkflowBudgetsTable>;
|
|
507
|
-
type UpdateWorkflowBudget = Updateable<WorkflowBudgetsTable>;
|
|
508
409
|
type Project = Selectable<ProjectsTable>;
|
|
509
410
|
type InsertProject = Insertable<ProjectsTable>;
|
|
510
411
|
type UpdateProject = Updateable<ProjectsTable>;
|
|
@@ -517,4 +418,74 @@ type InsertChatSession = Insertable<ChatSessionsTable>;
|
|
|
517
418
|
type UpdateChatSession = Updateable<ChatSessionsTable>;
|
|
518
419
|
type ChatMessage = Selectable<ChatMessagesTable>;
|
|
519
420
|
type InsertChatMessage = Insertable<ChatMessagesTable>;
|
|
520
|
-
|
|
421
|
+
type SubscriptionStatus = "active" | "paused" | "error";
|
|
422
|
+
type SubscriptionFormat = "standard-webhooks" | "inngest" | "trigger" | "cloudflare" | "cloudevents" | "raw";
|
|
423
|
+
type SubscriptionRuntime = "inngest" | "trigger" | "cloudflare" | "node";
|
|
424
|
+
interface SubscriptionsTable {
|
|
425
|
+
id: Generated<string>;
|
|
426
|
+
account_id: string;
|
|
427
|
+
project_id: string | null;
|
|
428
|
+
name: string;
|
|
429
|
+
status: ColumnType<SubscriptionStatus, SubscriptionStatus | undefined, SubscriptionStatus>;
|
|
430
|
+
subgraph_name: string;
|
|
431
|
+
table_name: string;
|
|
432
|
+
filter: Generated<unknown>;
|
|
433
|
+
format: ColumnType<SubscriptionFormat, SubscriptionFormat | undefined, SubscriptionFormat>;
|
|
434
|
+
runtime: SubscriptionRuntime | null;
|
|
435
|
+
url: string;
|
|
436
|
+
signing_secret_enc: Buffer;
|
|
437
|
+
auth_config: Generated<unknown>;
|
|
438
|
+
max_retries: Generated<number>;
|
|
439
|
+
timeout_ms: Generated<number>;
|
|
440
|
+
concurrency: Generated<number>;
|
|
441
|
+
circuit_failures: Generated<number>;
|
|
442
|
+
circuit_opened_at: Date | null;
|
|
443
|
+
last_delivery_at: Date | null;
|
|
444
|
+
last_success_at: Date | null;
|
|
445
|
+
last_error: string | null;
|
|
446
|
+
created_at: Generated<Date>;
|
|
447
|
+
updated_at: Generated<Date>;
|
|
448
|
+
}
|
|
449
|
+
type Subscription = Selectable<SubscriptionsTable>;
|
|
450
|
+
type InsertSubscription = Insertable<SubscriptionsTable>;
|
|
451
|
+
type UpdateSubscription = Updateable<SubscriptionsTable>;
|
|
452
|
+
type OutboxStatus = "pending" | "delivered" | "dead";
|
|
453
|
+
interface SubscriptionOutboxTable {
|
|
454
|
+
id: Generated<string>;
|
|
455
|
+
subscription_id: string;
|
|
456
|
+
subgraph_name: string;
|
|
457
|
+
table_name: string;
|
|
458
|
+
block_height: number | bigint;
|
|
459
|
+
tx_id: string | null;
|
|
460
|
+
row_pk: unknown;
|
|
461
|
+
event_type: string;
|
|
462
|
+
payload: unknown;
|
|
463
|
+
dedup_key: string;
|
|
464
|
+
attempt: Generated<number>;
|
|
465
|
+
next_attempt_at: Generated<Date>;
|
|
466
|
+
status: ColumnType<OutboxStatus, OutboxStatus | undefined, OutboxStatus>;
|
|
467
|
+
is_replay: Generated<boolean>;
|
|
468
|
+
delivered_at: Date | null;
|
|
469
|
+
failed_at: Date | null;
|
|
470
|
+
locked_by: string | null;
|
|
471
|
+
locked_until: Date | null;
|
|
472
|
+
created_at: Generated<Date>;
|
|
473
|
+
}
|
|
474
|
+
type SubscriptionOutbox = Selectable<SubscriptionOutboxTable>;
|
|
475
|
+
type InsertSubscriptionOutbox = Insertable<SubscriptionOutboxTable>;
|
|
476
|
+
type UpdateSubscriptionOutbox = Updateable<SubscriptionOutboxTable>;
|
|
477
|
+
interface SubscriptionDeliveriesTable {
|
|
478
|
+
id: Generated<string>;
|
|
479
|
+
outbox_id: string;
|
|
480
|
+
subscription_id: string;
|
|
481
|
+
attempt: number;
|
|
482
|
+
status_code: number | null;
|
|
483
|
+
response_headers: unknown | null;
|
|
484
|
+
response_body: string | null;
|
|
485
|
+
error_message: string | null;
|
|
486
|
+
duration_ms: number | null;
|
|
487
|
+
dispatched_at: Generated<Date>;
|
|
488
|
+
}
|
|
489
|
+
type SubscriptionDelivery = Selectable<SubscriptionDeliveriesTable>;
|
|
490
|
+
type InsertSubscriptionDelivery = Insertable<SubscriptionDeliveriesTable>;
|
|
491
|
+
export { WaitlistTable, UsageSnapshotsTable, UsageSnapshot, UsageDailyTable, UsageDaily, UpdateTransaction, UpdateTenantUsageMonthly, UpdateTenantComputeAddon, UpdateTenant, UpdateSubscriptionOutbox, UpdateSubscription, UpdateSubgraph, UpdateProject, UpdateIndexProgress, UpdateEvent, UpdateChatSession, UpdateBlock, UpdateApiKey, UpdateAccountSpendCap, TransactionsTable, Transaction, TenantsTable, TenantUsageMonthlyTable, TenantUsageMonthly, TenantStatus, TenantComputeAddonsTable, TenantComputeAddon, Tenant, TeamMembersTable, TeamMember, TeamInvitationsTable, TeamInvitation, SubscriptionsTable, SubscriptionStatus, SubscriptionRuntime, SubscriptionOutboxTable, SubscriptionOutbox, SubscriptionFormat, SubscriptionDelivery, SubscriptionDeliveriesTable, Subscription, SubgraphsTable, SubgraphUsageDailyTable, SubgraphUsageDaily, SubgraphTableSnapshotsTable, SubgraphProcessingStatsTable, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGap, Subgraph, SessionsTable, Session, ProvisioningAuditStatus, ProvisioningAuditLogTable, ProvisioningAuditLog, ProvisioningAuditEvent, ProjectsTable, Project, OutboxStatus, MagicLinksTable, MagicLink, InsertTransaction, InsertTenantUsageMonthly, InsertTenantComputeAddon, InsertTenant, InsertTeamMember, InsertTeamInvitation, InsertSubscriptionOutbox, InsertSubscriptionDelivery, InsertSubscription, InsertSubgraphUsageDaily, InsertSubgraphHealthSnapshot, InsertSubgraphGap, InsertSubgraph, InsertSession, InsertProvisioningAuditLog, InsertProject, InsertMagicLink, InsertIndexProgress, InsertEvent, InsertChatSession, InsertChatMessage, InsertBlock, InsertApiKey, InsertAccountSpendCap, InsertAccountInsight, InsertAccountAgentRun, InsertAccount, IndexProgressTable, IndexProgress, EventsTable, Event, Database, ChatSessionsTable, ChatSession, ChatMessagesTable, ChatMessage, BlocksTable, Block, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountInsightsTable, AccountInsight, AccountAgentRunsTable, AccountAgentRun, Account };
|
package/dist/src/errors.d.ts
CHANGED
|
@@ -8,10 +8,10 @@ declare const ErrorCodes: {
|
|
|
8
8
|
readonly VERSION_CONFLICT: "VERSION_CONFLICT"
|
|
9
9
|
readonly NOT_FOUND: "NOT_FOUND"
|
|
10
10
|
readonly KEY_ROTATED: "KEY_ROTATED"
|
|
11
|
-
readonly TRIAL_EXPIRED: "TRIAL_EXPIRED"
|
|
12
11
|
readonly TENANT_SUSPENDED: "TENANT_SUSPENDED"
|
|
13
12
|
readonly NO_TENANT_FOR_PROJECT: "NO_TENANT_FOR_PROJECT"
|
|
14
13
|
readonly INSTANCE_EXISTS: "INSTANCE_EXISTS"
|
|
14
|
+
readonly AI_CAP_REACHED: "AI_CAP_REACHED"
|
|
15
15
|
};
|
|
16
16
|
type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
17
17
|
/** Base error class for all Secondlayer errors. */
|
|
@@ -56,15 +56,16 @@ declare class VersionConflictError extends SecondLayerError {
|
|
|
56
56
|
declare class KeyRotatedError extends SecondLayerError {
|
|
57
57
|
constructor(message?: string);
|
|
58
58
|
}
|
|
59
|
-
declare class TrialExpiredError extends SecondLayerError {
|
|
60
|
-
constructor(message: string);
|
|
61
|
-
}
|
|
62
59
|
declare class TenantSuspendedError extends SecondLayerError {
|
|
63
60
|
constructor(message?: string);
|
|
64
61
|
}
|
|
62
|
+
/**\\n* Thrown by the workflow-runner when a step.ai / generateText /\\n* generateObject call would exceed the tenant's daily AI eval cap.\\n* The step fails cleanly; the workflow's condition-only path (if any)\\n* continues. Surface to users as "AI budget reached — increase tier or\\n* wait for daily reset".\\n*/
|
|
63
|
+
declare class AiCapReachedError extends SecondLayerError {
|
|
64
|
+
constructor(message?: string);
|
|
65
|
+
}
|
|
65
66
|
/** Error code → HTTP status. Used by API middleware for code-based matching
|
|
66
67
|
* (avoids cross-bundle instanceof failures from bunup class duplication). */
|
|
67
|
-
type MappedCode = Extract<ErrorCode, "AUTHENTICATION_ERROR" | "AUTHORIZATION_ERROR" | "RATE_LIMIT_ERROR" | "FORBIDDEN" | "NOT_FOUND" | "VALIDATION_ERROR" | "KEY_ROTATED" | "
|
|
68
|
-
declare const CODE_TO_STATUS: Record<MappedCode, 400 | 401 |
|
|
68
|
+
type MappedCode = Extract<ErrorCode, "AUTHENTICATION_ERROR" | "AUTHORIZATION_ERROR" | "RATE_LIMIT_ERROR" | "FORBIDDEN" | "NOT_FOUND" | "VALIDATION_ERROR" | "KEY_ROTATED" | "TENANT_SUSPENDED" | "NO_TENANT_FOR_PROJECT" | "INSTANCE_EXISTS">;
|
|
69
|
+
declare const CODE_TO_STATUS: Record<MappedCode, 400 | 401 | 403 | 404 | 409 | 423 | 429>;
|
|
69
70
|
declare function getErrorMessage(err: unknown): string;
|
|
70
|
-
export { getErrorMessage, VersionConflictError, ValidationError,
|
|
71
|
+
export { getErrorMessage, VersionConflictError, ValidationError, TenantSuspendedError, SecondLayerError, RateLimitError, NotFoundError, KeyRotatedError, ForbiddenError, ErrorCodes, ErrorCode, DatabaseError, CODE_TO_STATUS, AuthorizationError, AuthenticationError, AiCapReachedError };
|
package/dist/src/errors.js
CHANGED
|
@@ -25,10 +25,10 @@ var ErrorCodes = {
|
|
|
25
25
|
VERSION_CONFLICT: "VERSION_CONFLICT",
|
|
26
26
|
NOT_FOUND: "NOT_FOUND",
|
|
27
27
|
KEY_ROTATED: "KEY_ROTATED",
|
|
28
|
-
TRIAL_EXPIRED: "TRIAL_EXPIRED",
|
|
29
28
|
TENANT_SUSPENDED: "TENANT_SUSPENDED",
|
|
30
29
|
NO_TENANT_FOR_PROJECT: "NO_TENANT_FOR_PROJECT",
|
|
31
|
-
INSTANCE_EXISTS: "INSTANCE_EXISTS"
|
|
30
|
+
INSTANCE_EXISTS: "INSTANCE_EXISTS",
|
|
31
|
+
AI_CAP_REACHED: "AI_CAP_REACHED"
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
class SecondLayerError extends Error {
|
|
@@ -110,17 +110,17 @@ class KeyRotatedError extends SecondLayerError {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
class TrialExpiredError extends SecondLayerError {
|
|
114
|
-
constructor(message) {
|
|
115
|
-
super("TRIAL_EXPIRED", message);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
113
|
class TenantSuspendedError extends SecondLayerError {
|
|
120
114
|
constructor(message = "Instance is suspended") {
|
|
121
115
|
super("TENANT_SUSPENDED", message);
|
|
122
116
|
}
|
|
123
117
|
}
|
|
118
|
+
|
|
119
|
+
class AiCapReachedError extends SecondLayerError {
|
|
120
|
+
constructor(message = "Daily AI eval cap reached for this tenant's plan tier") {
|
|
121
|
+
super("AI_CAP_REACHED", message);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
124
|
var CODE_TO_STATUS = {
|
|
125
125
|
AUTHENTICATION_ERROR: 401,
|
|
126
126
|
AUTHORIZATION_ERROR: 403,
|
|
@@ -129,7 +129,6 @@ var CODE_TO_STATUS = {
|
|
|
129
129
|
NOT_FOUND: 404,
|
|
130
130
|
VALIDATION_ERROR: 400,
|
|
131
131
|
KEY_ROTATED: 401,
|
|
132
|
-
TRIAL_EXPIRED: 402,
|
|
133
132
|
TENANT_SUSPENDED: 423,
|
|
134
133
|
NO_TENANT_FOR_PROJECT: 404,
|
|
135
134
|
INSTANCE_EXISTS: 409
|
|
@@ -141,7 +140,6 @@ export {
|
|
|
141
140
|
getErrorMessage,
|
|
142
141
|
VersionConflictError,
|
|
143
142
|
ValidationError,
|
|
144
|
-
TrialExpiredError,
|
|
145
143
|
TenantSuspendedError,
|
|
146
144
|
SecondLayerError,
|
|
147
145
|
RateLimitError,
|
|
@@ -152,8 +150,9 @@ export {
|
|
|
152
150
|
DatabaseError,
|
|
153
151
|
CODE_TO_STATUS,
|
|
154
152
|
AuthorizationError,
|
|
155
|
-
AuthenticationError
|
|
153
|
+
AuthenticationError,
|
|
154
|
+
AiCapReachedError
|
|
156
155
|
};
|
|
157
156
|
|
|
158
|
-
//# debugId=
|
|
157
|
+
//# debugId=3D5A72D827A8C6D464756E2164756E21
|
|
159
158
|
//# sourceMappingURL=errors.js.map
|
package/dist/src/errors.js.map
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/errors.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"export const ErrorCodes = {\n\tVALIDATION_ERROR: \"VALIDATION_ERROR\",\n\tDATABASE_ERROR: \"DATABASE_ERROR\",\n\tAUTHENTICATION_ERROR: \"AUTHENTICATION_ERROR\",\n\tAUTHORIZATION_ERROR: \"AUTHORIZATION_ERROR\",\n\tRATE_LIMIT_ERROR: \"RATE_LIMIT_ERROR\",\n\tFORBIDDEN: \"FORBIDDEN\",\n\tVERSION_CONFLICT: \"VERSION_CONFLICT\",\n\tNOT_FOUND: \"NOT_FOUND\",\n\t// Tenant lifecycle (CLI surfaces these verbatim)\n\tKEY_ROTATED: \"KEY_ROTATED\",\n\
|
|
5
|
+
"export const ErrorCodes = {\n\tVALIDATION_ERROR: \"VALIDATION_ERROR\",\n\tDATABASE_ERROR: \"DATABASE_ERROR\",\n\tAUTHENTICATION_ERROR: \"AUTHENTICATION_ERROR\",\n\tAUTHORIZATION_ERROR: \"AUTHORIZATION_ERROR\",\n\tRATE_LIMIT_ERROR: \"RATE_LIMIT_ERROR\",\n\tFORBIDDEN: \"FORBIDDEN\",\n\tVERSION_CONFLICT: \"VERSION_CONFLICT\",\n\tNOT_FOUND: \"NOT_FOUND\",\n\t// Tenant lifecycle (CLI surfaces these verbatim)\n\tKEY_ROTATED: \"KEY_ROTATED\",\n\tTENANT_SUSPENDED: \"TENANT_SUSPENDED\",\n\tNO_TENANT_FOR_PROJECT: \"NO_TENANT_FOR_PROJECT\",\n\tINSTANCE_EXISTS: \"INSTANCE_EXISTS\",\n\t// Workflow runtime caps (runner throws; step fails cleanly)\n\tAI_CAP_REACHED: \"AI_CAP_REACHED\",\n} as const;\n\nexport type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];\n\n/** Base error class for all Secondlayer errors. */\nexport class SecondLayerError extends Error {\n\tpublic code: ErrorCode;\n\tpublic override cause?: unknown;\n\n\tconstructor(code: ErrorCode, message: string, cause?: unknown) {\n\t\tsuper(message);\n\t\tthis.code = code;\n\t\tthis.cause = cause;\n\t\tthis.name = this.constructor.name;\n\t\tError.captureStackTrace?.(this, this.constructor);\n\t}\n\n\ttoJSON(): {\n\t\tname: string;\n\t\tcode: string;\n\t\tmessage: string;\n\t\tstack: string | undefined;\n\t\tcause: unknown;\n\t} {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tcode: this.code,\n\t\t\tmessage: this.message,\n\t\t\tstack: this.stack,\n\t\t\tcause: this.cause,\n\t\t};\n\t}\n}\n\nexport class NotFoundError extends SecondLayerError {\n\tconstructor(message: string) {\n\t\tsuper(\"NOT_FOUND\", message);\n\t}\n}\n\nexport class ValidationError extends SecondLayerError {\n\tconstructor(message: string, cause?: unknown) {\n\t\tsuper(\"VALIDATION_ERROR\", message, cause);\n\t}\n}\n\nexport class DatabaseError extends SecondLayerError {\n\tconstructor(message: string, cause?: unknown) {\n\t\tsuper(\"DATABASE_ERROR\", message, cause);\n\t}\n}\n\nexport class AuthenticationError extends SecondLayerError {\n\tconstructor(message: string) {\n\t\tsuper(\"AUTHENTICATION_ERROR\", message);\n\t}\n}\n\nexport class AuthorizationError extends SecondLayerError {\n\tconstructor(message: string) {\n\t\tsuper(\"AUTHORIZATION_ERROR\", message);\n\t}\n}\n\nexport class RateLimitError extends SecondLayerError {\n\tconstructor(message: string) {\n\t\tsuper(\"RATE_LIMIT_ERROR\", message);\n\t}\n}\n\nexport class ForbiddenError extends SecondLayerError {\n\tconstructor(message = \"Forbidden\") {\n\t\tsuper(\"FORBIDDEN\", message);\n\t}\n}\n\nexport class VersionConflictError extends SecondLayerError {\n\tpublic currentVersion: string;\n\tpublic expectedVersion: string;\n\n\tconstructor(currentVersion: string, expectedVersion: string) {\n\t\tsuper(\n\t\t\t\"VERSION_CONFLICT\",\n\t\t\t`Version conflict: expected ${expectedVersion}, current ${currentVersion}`,\n\t\t);\n\t\tthis.currentVersion = currentVersion;\n\t\tthis.expectedVersion = expectedVersion;\n\t}\n}\n\nexport class KeyRotatedError extends SecondLayerError {\n\tconstructor(message = \"Token has been rotated\") {\n\t\tsuper(\"KEY_ROTATED\", message);\n\t}\n}\n\nexport class TenantSuspendedError extends SecondLayerError {\n\tconstructor(message = \"Instance is suspended\") {\n\t\tsuper(\"TENANT_SUSPENDED\", message);\n\t}\n}\n\n/**\n * Thrown by the workflow-runner when a step.ai / generateText /\n * generateObject call would exceed the tenant's daily AI eval cap.\n * The step fails cleanly; the workflow's condition-only path (if any)\n * continues. Surface to users as \"AI budget reached — increase tier or\n * wait for daily reset\".\n */\nexport class AiCapReachedError extends SecondLayerError {\n\tconstructor(\n\t\tmessage = \"Daily AI eval cap reached for this tenant's plan tier\",\n\t) {\n\t\tsuper(\"AI_CAP_REACHED\", message);\n\t}\n}\n\n/** Error code → HTTP status. Used by API middleware for code-based matching\n * (avoids cross-bundle instanceof failures from bunup class duplication). */\ntype MappedCode = Extract<\n\tErrorCode,\n\t| \"AUTHENTICATION_ERROR\"\n\t| \"AUTHORIZATION_ERROR\"\n\t| \"RATE_LIMIT_ERROR\"\n\t| \"FORBIDDEN\"\n\t| \"NOT_FOUND\"\n\t| \"VALIDATION_ERROR\"\n\t| \"KEY_ROTATED\"\n\t| \"TENANT_SUSPENDED\"\n\t| \"NO_TENANT_FOR_PROJECT\"\n\t| \"INSTANCE_EXISTS\"\n>;\nexport const CODE_TO_STATUS: Record<\n\tMappedCode,\n\t400 | 401 | 403 | 404 | 409 | 423 | 429\n> = {\n\tAUTHENTICATION_ERROR: 401,\n\tAUTHORIZATION_ERROR: 403,\n\tRATE_LIMIT_ERROR: 429,\n\tFORBIDDEN: 403,\n\tNOT_FOUND: 404,\n\tVALIDATION_ERROR: 400,\n\tKEY_ROTATED: 401,\n\tTENANT_SUSPENDED: 423,\n\tNO_TENANT_FOR_PROJECT: 404,\n\tINSTANCE_EXISTS: 409,\n} as const;\n\nexport function getErrorMessage(err: unknown): string {\n\treturn err instanceof Error ? err.message : String(err);\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";;;;;;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