@secondlayer/shared 4.1.1 → 4.3.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.
Files changed (32) hide show
  1. package/dist/src/db/index.d.ts +26 -1
  2. package/dist/src/db/queries/account-spend-caps.d.ts +22 -0
  3. package/dist/src/db/queries/account-usage.d.ts +22 -0
  4. package/dist/src/db/queries/accounts.d.ts +22 -0
  5. package/dist/src/db/queries/integrity.d.ts +22 -0
  6. package/dist/src/db/queries/projects.d.ts +22 -0
  7. package/dist/src/db/queries/provisioning-audit.d.ts +22 -0
  8. package/dist/src/db/queries/subgraph-gaps.d.ts +22 -0
  9. package/dist/src/db/queries/subgraph-operations.d.ts +461 -0
  10. package/dist/src/db/queries/subgraph-operations.js +124 -0
  11. package/dist/src/db/queries/subgraph-operations.js.map +10 -0
  12. package/dist/src/db/queries/subgraphs.d.ts +22 -0
  13. package/dist/src/db/queries/subscriptions.d.ts +22 -0
  14. package/dist/src/db/queries/tenant-compute-addons.d.ts +22 -0
  15. package/dist/src/db/queries/tenants.d.ts +22 -0
  16. package/dist/src/db/queries/usage.d.ts +22 -0
  17. package/dist/src/db/queries/usage.js +7 -9
  18. package/dist/src/db/queries/usage.js.map +3 -3
  19. package/dist/src/db/schema.d.ts +26 -1
  20. package/dist/src/index.d.ts +32 -1
  21. package/dist/src/index.js +2 -1
  22. package/dist/src/index.js.map +3 -3
  23. package/dist/src/node/local-client.d.ts +22 -0
  24. package/dist/src/schemas/index.d.ts +6 -0
  25. package/dist/src/schemas/index.js +2 -1
  26. package/dist/src/schemas/index.js.map +3 -3
  27. package/dist/src/schemas/subgraphs.d.ts +6 -0
  28. package/dist/src/schemas/subgraphs.js +2 -1
  29. package/dist/src/schemas/subgraphs.js.map +3 -3
  30. package/migrations/0059_usage_daily_account_null_tenant_key.ts +19 -0
  31. package/migrations/0060_subgraph_operations.ts +99 -0
  32. package/package.json +5 -1
@@ -91,6 +91,27 @@ interface SubgraphGapsTable {
91
91
  detected_at: Generated<Date>;
92
92
  resolved_at: Date | null;
93
93
  }
94
+ type SubgraphOperationKind = "reindex" | "backfill";
95
+ type SubgraphOperationStatus = "queued" | "running" | "completed" | "failed" | "cancelled";
96
+ interface SubgraphOperationsTable {
97
+ id: Generated<string>;
98
+ subgraph_id: string;
99
+ subgraph_name: string;
100
+ account_id: string | null;
101
+ kind: ColumnType<SubgraphOperationKind, SubgraphOperationKind, SubgraphOperationKind>;
102
+ status: ColumnType<SubgraphOperationStatus, SubgraphOperationStatus | undefined, SubgraphOperationStatus>;
103
+ from_block: number | null;
104
+ to_block: number | null;
105
+ cancel_requested: Generated<boolean>;
106
+ locked_by: string | null;
107
+ locked_until: Date | null;
108
+ started_at: Date | null;
109
+ finished_at: Date | null;
110
+ processed_blocks: number | null;
111
+ error: string | null;
112
+ created_at: Generated<Date>;
113
+ updated_at: Generated<Date>;
114
+ }
94
115
  interface ApiKeysTable {
95
116
  id: Generated<string>;
96
117
  key_hash: string;
@@ -284,6 +305,7 @@ interface Database {
284
305
  subgraph_processing_stats: SubgraphProcessingStatsTable;
285
306
  subgraph_table_snapshots: SubgraphTableSnapshotsTable;
286
307
  subgraph_gaps: SubgraphGapsTable;
308
+ subgraph_operations: SubgraphOperationsTable;
287
309
  subgraph_usage_daily: SubgraphUsageDailyTable;
288
310
  projects: ProjectsTable;
289
311
  team_members: TeamMembersTable;
@@ -403,6 +425,9 @@ type UpdateIndexProgress = Updateable<IndexProgressTable>;
403
425
  type Subgraph = Selectable<SubgraphsTable>;
404
426
  type InsertSubgraph = Insertable<SubgraphsTable>;
405
427
  type UpdateSubgraph = Updateable<SubgraphsTable>;
428
+ type SubgraphOperation = Selectable<SubgraphOperationsTable>;
429
+ type InsertSubgraphOperation = Insertable<SubgraphOperationsTable>;
430
+ type UpdateSubgraphOperation = Updateable<SubgraphOperationsTable>;
406
431
  type ApiKey = Selectable<ApiKeysTable>;
407
432
  type InsertApiKey = Insertable<ApiKeysTable>;
408
433
  type UpdateApiKey = Updateable<ApiKeysTable>;
@@ -531,4 +556,4 @@ declare function getDb(connectionString?: string): Kysely<Database>;
531
556
  declare function getRawClient(role?: "source" | "target"): ReturnType<typeof postgres>;
532
557
  /** Close all DB connection pools. Call in CLI commands to allow process exit. */
533
558
  declare function closeDb(): Promise<void>;
534
- export { sql, parseJsonb, jsonb, getTargetDb, getSourceDb, getRawClient, getDb, closeDb, 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 };
559
+ export { sql, parseJsonb, jsonb, getTargetDb, getSourceDb, getRawClient, getDb, closeDb, WaitlistTable, UsageSnapshotsTable, UsageSnapshot, UsageDailyTable, UsageDaily, UpdateTransaction, UpdateTenantUsageMonthly, UpdateTenantComputeAddon, UpdateTenant, UpdateSubscriptionOutbox, UpdateSubscription, UpdateSubgraphOperation, 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, SubgraphOperationsTable, SubgraphOperationStatus, SubgraphOperationKind, SubgraphOperation, 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, InsertSubgraphOperation, 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 };
@@ -73,6 +73,27 @@ interface SubgraphGapsTable {
73
73
  detected_at: Generated<Date>;
74
74
  resolved_at: Date | null;
75
75
  }
76
+ type SubgraphOperationKind = "reindex" | "backfill";
77
+ type SubgraphOperationStatus = "queued" | "running" | "completed" | "failed" | "cancelled";
78
+ interface SubgraphOperationsTable {
79
+ id: Generated<string>;
80
+ subgraph_id: string;
81
+ subgraph_name: string;
82
+ account_id: string | null;
83
+ kind: ColumnType<SubgraphOperationKind, SubgraphOperationKind, SubgraphOperationKind>;
84
+ status: ColumnType<SubgraphOperationStatus, SubgraphOperationStatus | undefined, SubgraphOperationStatus>;
85
+ from_block: number | null;
86
+ to_block: number | null;
87
+ cancel_requested: Generated<boolean>;
88
+ locked_by: string | null;
89
+ locked_until: Date | null;
90
+ started_at: Date | null;
91
+ finished_at: Date | null;
92
+ processed_blocks: number | null;
93
+ error: string | null;
94
+ created_at: Generated<Date>;
95
+ updated_at: Generated<Date>;
96
+ }
76
97
  interface ApiKeysTable {
77
98
  id: Generated<string>;
78
99
  key_hash: string;
@@ -266,6 +287,7 @@ interface Database {
266
287
  subgraph_processing_stats: SubgraphProcessingStatsTable;
267
288
  subgraph_table_snapshots: SubgraphTableSnapshotsTable;
268
289
  subgraph_gaps: SubgraphGapsTable;
290
+ subgraph_operations: SubgraphOperationsTable;
269
291
  subgraph_usage_daily: SubgraphUsageDailyTable;
270
292
  projects: ProjectsTable;
271
293
  team_members: TeamMembersTable;
@@ -73,6 +73,27 @@ interface SubgraphGapsTable {
73
73
  detected_at: Generated<Date>;
74
74
  resolved_at: Date | null;
75
75
  }
76
+ type SubgraphOperationKind = "reindex" | "backfill";
77
+ type SubgraphOperationStatus = "queued" | "running" | "completed" | "failed" | "cancelled";
78
+ interface SubgraphOperationsTable {
79
+ id: Generated<string>;
80
+ subgraph_id: string;
81
+ subgraph_name: string;
82
+ account_id: string | null;
83
+ kind: ColumnType<SubgraphOperationKind, SubgraphOperationKind, SubgraphOperationKind>;
84
+ status: ColumnType<SubgraphOperationStatus, SubgraphOperationStatus | undefined, SubgraphOperationStatus>;
85
+ from_block: number | null;
86
+ to_block: number | null;
87
+ cancel_requested: Generated<boolean>;
88
+ locked_by: string | null;
89
+ locked_until: Date | null;
90
+ started_at: Date | null;
91
+ finished_at: Date | null;
92
+ processed_blocks: number | null;
93
+ error: string | null;
94
+ created_at: Generated<Date>;
95
+ updated_at: Generated<Date>;
96
+ }
76
97
  interface ApiKeysTable {
77
98
  id: Generated<string>;
78
99
  key_hash: string;
@@ -266,6 +287,7 @@ interface Database {
266
287
  subgraph_processing_stats: SubgraphProcessingStatsTable;
267
288
  subgraph_table_snapshots: SubgraphTableSnapshotsTable;
268
289
  subgraph_gaps: SubgraphGapsTable;
290
+ subgraph_operations: SubgraphOperationsTable;
269
291
  subgraph_usage_daily: SubgraphUsageDailyTable;
270
292
  projects: ProjectsTable;
271
293
  team_members: TeamMembersTable;
@@ -74,6 +74,27 @@ interface SubgraphGapsTable {
74
74
  detected_at: Generated<Date>;
75
75
  resolved_at: Date | null;
76
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
+ }
77
98
  interface ApiKeysTable {
78
99
  id: Generated<string>;
79
100
  key_hash: string;
@@ -267,6 +288,7 @@ interface Database {
267
288
  subgraph_processing_stats: SubgraphProcessingStatsTable;
268
289
  subgraph_table_snapshots: SubgraphTableSnapshotsTable;
269
290
  subgraph_gaps: SubgraphGapsTable;
291
+ subgraph_operations: SubgraphOperationsTable;
270
292
  subgraph_usage_daily: SubgraphUsageDailyTable;
271
293
  projects: ProjectsTable;
272
294
  team_members: TeamMembersTable;
@@ -73,6 +73,27 @@ interface SubgraphGapsTable {
73
73
  detected_at: Generated<Date>;
74
74
  resolved_at: Date | null;
75
75
  }
76
+ type SubgraphOperationKind = "reindex" | "backfill";
77
+ type SubgraphOperationStatus = "queued" | "running" | "completed" | "failed" | "cancelled";
78
+ interface SubgraphOperationsTable {
79
+ id: Generated<string>;
80
+ subgraph_id: string;
81
+ subgraph_name: string;
82
+ account_id: string | null;
83
+ kind: ColumnType<SubgraphOperationKind, SubgraphOperationKind, SubgraphOperationKind>;
84
+ status: ColumnType<SubgraphOperationStatus, SubgraphOperationStatus | undefined, SubgraphOperationStatus>;
85
+ from_block: number | null;
86
+ to_block: number | null;
87
+ cancel_requested: Generated<boolean>;
88
+ locked_by: string | null;
89
+ locked_until: Date | null;
90
+ started_at: Date | null;
91
+ finished_at: Date | null;
92
+ processed_blocks: number | null;
93
+ error: string | null;
94
+ created_at: Generated<Date>;
95
+ updated_at: Generated<Date>;
96
+ }
76
97
  interface ApiKeysTable {
77
98
  id: Generated<string>;
78
99
  key_hash: string;
@@ -266,6 +287,7 @@ interface Database {
266
287
  subgraph_processing_stats: SubgraphProcessingStatsTable;
267
288
  subgraph_table_snapshots: SubgraphTableSnapshotsTable;
268
289
  subgraph_gaps: SubgraphGapsTable;
290
+ subgraph_operations: SubgraphOperationsTable;
269
291
  subgraph_usage_daily: SubgraphUsageDailyTable;
270
292
  projects: ProjectsTable;
271
293
  team_members: TeamMembersTable;
@@ -73,6 +73,27 @@ interface SubgraphGapsTable {
73
73
  detected_at: Generated<Date>;
74
74
  resolved_at: Date | null;
75
75
  }
76
+ type SubgraphOperationKind = "reindex" | "backfill";
77
+ type SubgraphOperationStatus = "queued" | "running" | "completed" | "failed" | "cancelled";
78
+ interface SubgraphOperationsTable {
79
+ id: Generated<string>;
80
+ subgraph_id: string;
81
+ subgraph_name: string;
82
+ account_id: string | null;
83
+ kind: ColumnType<SubgraphOperationKind, SubgraphOperationKind, SubgraphOperationKind>;
84
+ status: ColumnType<SubgraphOperationStatus, SubgraphOperationStatus | undefined, SubgraphOperationStatus>;
85
+ from_block: number | null;
86
+ to_block: number | null;
87
+ cancel_requested: Generated<boolean>;
88
+ locked_by: string | null;
89
+ locked_until: Date | null;
90
+ started_at: Date | null;
91
+ finished_at: Date | null;
92
+ processed_blocks: number | null;
93
+ error: string | null;
94
+ created_at: Generated<Date>;
95
+ updated_at: Generated<Date>;
96
+ }
76
97
  interface ApiKeysTable {
77
98
  id: Generated<string>;
78
99
  key_hash: string;
@@ -266,6 +287,7 @@ interface Database {
266
287
  subgraph_processing_stats: SubgraphProcessingStatsTable;
267
288
  subgraph_table_snapshots: SubgraphTableSnapshotsTable;
268
289
  subgraph_gaps: SubgraphGapsTable;
290
+ subgraph_operations: SubgraphOperationsTable;
269
291
  subgraph_usage_daily: SubgraphUsageDailyTable;
270
292
  projects: ProjectsTable;
271
293
  team_members: TeamMembersTable;
@@ -73,6 +73,27 @@ interface SubgraphGapsTable {
73
73
  detected_at: Generated<Date>;
74
74
  resolved_at: Date | null;
75
75
  }
76
+ type SubgraphOperationKind = "reindex" | "backfill";
77
+ type SubgraphOperationStatus = "queued" | "running" | "completed" | "failed" | "cancelled";
78
+ interface SubgraphOperationsTable {
79
+ id: Generated<string>;
80
+ subgraph_id: string;
81
+ subgraph_name: string;
82
+ account_id: string | null;
83
+ kind: ColumnType<SubgraphOperationKind, SubgraphOperationKind, SubgraphOperationKind>;
84
+ status: ColumnType<SubgraphOperationStatus, SubgraphOperationStatus | undefined, SubgraphOperationStatus>;
85
+ from_block: number | null;
86
+ to_block: number | null;
87
+ cancel_requested: Generated<boolean>;
88
+ locked_by: string | null;
89
+ locked_until: Date | null;
90
+ started_at: Date | null;
91
+ finished_at: Date | null;
92
+ processed_blocks: number | null;
93
+ error: string | null;
94
+ created_at: Generated<Date>;
95
+ updated_at: Generated<Date>;
96
+ }
76
97
  interface ApiKeysTable {
77
98
  id: Generated<string>;
78
99
  key_hash: string;
@@ -266,6 +287,7 @@ interface Database {
266
287
  subgraph_processing_stats: SubgraphProcessingStatsTable;
267
288
  subgraph_table_snapshots: SubgraphTableSnapshotsTable;
268
289
  subgraph_gaps: SubgraphGapsTable;
290
+ subgraph_operations: SubgraphOperationsTable;
269
291
  subgraph_usage_daily: SubgraphUsageDailyTable;
270
292
  projects: ProjectsTable;
271
293
  team_members: TeamMembersTable;
@@ -73,6 +73,27 @@ interface SubgraphGapsTable {
73
73
  detected_at: Generated<Date>;
74
74
  resolved_at: Date | null;
75
75
  }
76
+ type SubgraphOperationKind = "reindex" | "backfill";
77
+ type SubgraphOperationStatus = "queued" | "running" | "completed" | "failed" | "cancelled";
78
+ interface SubgraphOperationsTable {
79
+ id: Generated<string>;
80
+ subgraph_id: string;
81
+ subgraph_name: string;
82
+ account_id: string | null;
83
+ kind: ColumnType<SubgraphOperationKind, SubgraphOperationKind, SubgraphOperationKind>;
84
+ status: ColumnType<SubgraphOperationStatus, SubgraphOperationStatus | undefined, SubgraphOperationStatus>;
85
+ from_block: number | null;
86
+ to_block: number | null;
87
+ cancel_requested: Generated<boolean>;
88
+ locked_by: string | null;
89
+ locked_until: Date | null;
90
+ started_at: Date | null;
91
+ finished_at: Date | null;
92
+ processed_blocks: number | null;
93
+ error: string | null;
94
+ created_at: Generated<Date>;
95
+ updated_at: Generated<Date>;
96
+ }
76
97
  interface ApiKeysTable {
77
98
  id: Generated<string>;
78
99
  key_hash: string;
@@ -266,6 +287,7 @@ interface Database {
266
287
  subgraph_processing_stats: SubgraphProcessingStatsTable;
267
288
  subgraph_table_snapshots: SubgraphTableSnapshotsTable;
268
289
  subgraph_gaps: SubgraphGapsTable;
290
+ subgraph_operations: SubgraphOperationsTable;
269
291
  subgraph_usage_daily: SubgraphUsageDailyTable;
270
292
  projects: ProjectsTable;
271
293
  team_members: TeamMembersTable;