@secondlayer/shared 11.19.3 → 11.21.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/archive/range-digest.d.ts +61 -1
- package/dist/src/archive/semantic-digest-builder.d.ts +61 -1
- package/dist/src/classify/index.d.ts +83 -0
- package/dist/src/classify/index.js +464 -0
- package/dist/src/classify/index.js.map +18 -0
- package/dist/src/coverage/index.d.ts +61 -1
- package/dist/src/db/index.d.ts +72 -2
- package/dist/src/db/index.js +5 -1
- package/dist/src/db/index.js.map +3 -3
- package/dist/src/db/queries/chain-reorgs.d.ts +61 -1
- package/dist/src/db/queries/chain-reorgs.js +5 -1
- package/dist/src/db/queries/chain-reorgs.js.map +3 -3
- package/dist/src/db/queries/contracts.d.ts +61 -1
- package/dist/src/db/queries/instance.d.ts +61 -1
- package/dist/src/db/queries/integrity.d.ts +61 -1
- package/dist/src/db/queries/subgraph-gaps.d.ts +61 -1
- package/dist/src/db/queries/subgraph-operations.d.ts +61 -1
- package/dist/src/db/queries/subgraphs.d.ts +61 -1
- package/dist/src/db/queries/sync-scope.d.ts +61 -1
- package/dist/src/db/queries/webhooks.d.ts +61 -1
- package/dist/src/db/schema.d.ts +68 -2
- package/dist/src/error-envelope.d.ts +48 -0
- package/dist/src/error-envelope.js +76 -0
- package/dist/src/error-envelope.js.map +10 -0
- package/dist/src/index.d.ts +72 -2
- package/dist/src/index.js +5 -1
- package/dist/src/index.js.map +3 -3
- package/dist/src/leader.d.ts +4 -1
- package/dist/src/leader.js +3 -1
- package/dist/src/leader.js.map +3 -3
- package/dist/src/node/local-client.d.ts +71 -2
- package/dist/src/node/local-client.js +4 -2
- package/dist/src/node/local-client.js.map +3 -3
- package/dist/src/queue/listener.js +5 -1
- package/dist/src/queue/listener.js.map +3 -3
- package/dist/src/types.d.ts +0 -1
- package/migrations/0153_vm_events_height_ordinal_pk.ts +80 -0
- package/migrations/0154_state_writes.ts +62 -0
- package/migrations/0155_api_failed_requests.ts +37 -0
- package/migrations/0156_feedback_tickets.ts +47 -0
- package/package.json +17 -1
|
@@ -87,7 +87,6 @@ interface EventsArchiveTable {
|
|
|
87
87
|
archived_at: Generated<Date>;
|
|
88
88
|
}
|
|
89
89
|
interface VmEventsTable {
|
|
90
|
-
id: Generated<string>;
|
|
91
90
|
tx_id: string;
|
|
92
91
|
block_height: number;
|
|
93
92
|
ordinal: number;
|
|
@@ -97,6 +96,7 @@ interface VmEventsTable {
|
|
|
97
96
|
}
|
|
98
97
|
interface VmEventsArchiveTable {
|
|
99
98
|
archive_id: Generated<string>;
|
|
99
|
+
/** `block_height:ordinal`; rows archived before migration 0153 hold the old uuid. */
|
|
100
100
|
id: string;
|
|
101
101
|
tx_id: string;
|
|
102
102
|
block_height: number;
|
|
@@ -107,6 +107,25 @@ interface VmEventsArchiveTable {
|
|
|
107
107
|
orphaned_block_hash: string | null;
|
|
108
108
|
archived_at: Generated<Date>;
|
|
109
109
|
}
|
|
110
|
+
interface StateWritesTable {
|
|
111
|
+
block_height: number;
|
|
112
|
+
ordinal: number;
|
|
113
|
+
tx_index: number | null;
|
|
114
|
+
key: string;
|
|
115
|
+
value_hex: string;
|
|
116
|
+
}
|
|
117
|
+
interface StateWritesArchiveTable {
|
|
118
|
+
archive_id: Generated<string>;
|
|
119
|
+
/** `block_height:ordinal`. */
|
|
120
|
+
id: string;
|
|
121
|
+
block_height: number;
|
|
122
|
+
ordinal: number;
|
|
123
|
+
tx_index: number | null;
|
|
124
|
+
key: string;
|
|
125
|
+
value_hex: string;
|
|
126
|
+
orphaned_block_hash: string | null;
|
|
127
|
+
archived_at: Generated<Date>;
|
|
128
|
+
}
|
|
110
129
|
interface DeadLetterEventsTable {
|
|
111
130
|
id: Generated<string>;
|
|
112
131
|
block_height: number;
|
|
@@ -768,9 +787,11 @@ interface Database {
|
|
|
768
787
|
transactions: TransactionsTable;
|
|
769
788
|
events: EventsTable;
|
|
770
789
|
vm_events: VmEventsTable;
|
|
790
|
+
state_writes: StateWritesTable;
|
|
771
791
|
transactions_archive: TransactionsArchiveTable;
|
|
772
792
|
events_archive: EventsArchiveTable;
|
|
773
793
|
vm_events_archive: VmEventsArchiveTable;
|
|
794
|
+
state_writes_archive: StateWritesArchiveTable;
|
|
774
795
|
dead_letter_events: DeadLetterEventsTable;
|
|
775
796
|
mempool_transactions: MempoolTransactionsTable;
|
|
776
797
|
index_progress: IndexProgressTable;
|
|
@@ -826,6 +847,8 @@ interface Database {
|
|
|
826
847
|
sentinel_accounts: SentinelAccountsTable;
|
|
827
848
|
waitlists: WaitlistsTable;
|
|
828
849
|
waitlist_signups: WaitlistSignupsTable;
|
|
850
|
+
api_failed_requests: ApiFailedRequestsTable;
|
|
851
|
+
feedback_tickets: FeedbackTicketsTable;
|
|
829
852
|
}
|
|
830
853
|
interface ServiceHeartbeatsTable {
|
|
831
854
|
name: string;
|
|
@@ -1034,6 +1057,43 @@ interface WaitlistSignupsTable {
|
|
|
1034
1057
|
answers: Record<string, unknown>;
|
|
1035
1058
|
created_at: Generated<Date>;
|
|
1036
1059
|
}
|
|
1060
|
+
/**
|
|
1061
|
+
* 24h hosted record of a failed API request, keyed by `request_id` and
|
|
1062
|
+
* scoped to the account that made it. `query` is redacted before insert.
|
|
1063
|
+
*/
|
|
1064
|
+
interface ApiFailedRequestsTable {
|
|
1065
|
+
request_id: string;
|
|
1066
|
+
account_id: string;
|
|
1067
|
+
method: string;
|
|
1068
|
+
path: string;
|
|
1069
|
+
status: number;
|
|
1070
|
+
code: string;
|
|
1071
|
+
message: Generated<string>;
|
|
1072
|
+
query: Record<string, unknown>;
|
|
1073
|
+
origin: string | null;
|
|
1074
|
+
created_at: Generated<Date>;
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* Hosted problem report. `attempted` is the server's own copy of the failed
|
|
1078
|
+
* request (never caller-supplied); `status` starts `new` until classified.
|
|
1079
|
+
*/
|
|
1080
|
+
interface FeedbackTicketsTable {
|
|
1081
|
+
id: Generated<string>;
|
|
1082
|
+
account_id: string;
|
|
1083
|
+
idempotency_key: string | null;
|
|
1084
|
+
request_id: string | null;
|
|
1085
|
+
intent: string;
|
|
1086
|
+
expected: Record<string, unknown> | null;
|
|
1087
|
+
kind_hint: string | null;
|
|
1088
|
+
evidence: Record<string, unknown> | null;
|
|
1089
|
+
attempted: Record<string, unknown> | null;
|
|
1090
|
+
origin: string;
|
|
1091
|
+
status: Generated<"new" | "classified">;
|
|
1092
|
+
route: string | null;
|
|
1093
|
+
classification: Record<string, unknown> | null;
|
|
1094
|
+
classified_at: Date | null;
|
|
1095
|
+
created_at: Generated<Date>;
|
|
1096
|
+
}
|
|
1037
1097
|
declare function isActiveSubgraphOperationConflict(err: unknown): boolean;
|
|
1038
1098
|
declare function createSubgraphOperation(db: Kysely<Database>, data: {
|
|
1039
1099
|
subgraphId: string
|
|
@@ -87,7 +87,6 @@ interface EventsArchiveTable {
|
|
|
87
87
|
archived_at: Generated<Date>;
|
|
88
88
|
}
|
|
89
89
|
interface VmEventsTable {
|
|
90
|
-
id: Generated<string>;
|
|
91
90
|
tx_id: string;
|
|
92
91
|
block_height: number;
|
|
93
92
|
ordinal: number;
|
|
@@ -97,6 +96,7 @@ interface VmEventsTable {
|
|
|
97
96
|
}
|
|
98
97
|
interface VmEventsArchiveTable {
|
|
99
98
|
archive_id: Generated<string>;
|
|
99
|
+
/** `block_height:ordinal`; rows archived before migration 0153 hold the old uuid. */
|
|
100
100
|
id: string;
|
|
101
101
|
tx_id: string;
|
|
102
102
|
block_height: number;
|
|
@@ -107,6 +107,25 @@ interface VmEventsArchiveTable {
|
|
|
107
107
|
orphaned_block_hash: string | null;
|
|
108
108
|
archived_at: Generated<Date>;
|
|
109
109
|
}
|
|
110
|
+
interface StateWritesTable {
|
|
111
|
+
block_height: number;
|
|
112
|
+
ordinal: number;
|
|
113
|
+
tx_index: number | null;
|
|
114
|
+
key: string;
|
|
115
|
+
value_hex: string;
|
|
116
|
+
}
|
|
117
|
+
interface StateWritesArchiveTable {
|
|
118
|
+
archive_id: Generated<string>;
|
|
119
|
+
/** `block_height:ordinal`. */
|
|
120
|
+
id: string;
|
|
121
|
+
block_height: number;
|
|
122
|
+
ordinal: number;
|
|
123
|
+
tx_index: number | null;
|
|
124
|
+
key: string;
|
|
125
|
+
value_hex: string;
|
|
126
|
+
orphaned_block_hash: string | null;
|
|
127
|
+
archived_at: Generated<Date>;
|
|
128
|
+
}
|
|
110
129
|
interface DeadLetterEventsTable {
|
|
111
130
|
id: Generated<string>;
|
|
112
131
|
block_height: number;
|
|
@@ -768,9 +787,11 @@ interface Database {
|
|
|
768
787
|
transactions: TransactionsTable;
|
|
769
788
|
events: EventsTable;
|
|
770
789
|
vm_events: VmEventsTable;
|
|
790
|
+
state_writes: StateWritesTable;
|
|
771
791
|
transactions_archive: TransactionsArchiveTable;
|
|
772
792
|
events_archive: EventsArchiveTable;
|
|
773
793
|
vm_events_archive: VmEventsArchiveTable;
|
|
794
|
+
state_writes_archive: StateWritesArchiveTable;
|
|
774
795
|
dead_letter_events: DeadLetterEventsTable;
|
|
775
796
|
mempool_transactions: MempoolTransactionsTable;
|
|
776
797
|
index_progress: IndexProgressTable;
|
|
@@ -826,6 +847,8 @@ interface Database {
|
|
|
826
847
|
sentinel_accounts: SentinelAccountsTable;
|
|
827
848
|
waitlists: WaitlistsTable;
|
|
828
849
|
waitlist_signups: WaitlistSignupsTable;
|
|
850
|
+
api_failed_requests: ApiFailedRequestsTable;
|
|
851
|
+
feedback_tickets: FeedbackTicketsTable;
|
|
829
852
|
}
|
|
830
853
|
interface ServiceHeartbeatsTable {
|
|
831
854
|
name: string;
|
|
@@ -1034,6 +1057,43 @@ interface WaitlistSignupsTable {
|
|
|
1034
1057
|
answers: Record<string, unknown>;
|
|
1035
1058
|
created_at: Generated<Date>;
|
|
1036
1059
|
}
|
|
1060
|
+
/**
|
|
1061
|
+
* 24h hosted record of a failed API request, keyed by `request_id` and
|
|
1062
|
+
* scoped to the account that made it. `query` is redacted before insert.
|
|
1063
|
+
*/
|
|
1064
|
+
interface ApiFailedRequestsTable {
|
|
1065
|
+
request_id: string;
|
|
1066
|
+
account_id: string;
|
|
1067
|
+
method: string;
|
|
1068
|
+
path: string;
|
|
1069
|
+
status: number;
|
|
1070
|
+
code: string;
|
|
1071
|
+
message: Generated<string>;
|
|
1072
|
+
query: Record<string, unknown>;
|
|
1073
|
+
origin: string | null;
|
|
1074
|
+
created_at: Generated<Date>;
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* Hosted problem report. `attempted` is the server's own copy of the failed
|
|
1078
|
+
* request (never caller-supplied); `status` starts `new` until classified.
|
|
1079
|
+
*/
|
|
1080
|
+
interface FeedbackTicketsTable {
|
|
1081
|
+
id: Generated<string>;
|
|
1082
|
+
account_id: string;
|
|
1083
|
+
idempotency_key: string | null;
|
|
1084
|
+
request_id: string | null;
|
|
1085
|
+
intent: string;
|
|
1086
|
+
expected: Record<string, unknown> | null;
|
|
1087
|
+
kind_hint: string | null;
|
|
1088
|
+
evidence: Record<string, unknown> | null;
|
|
1089
|
+
attempted: Record<string, unknown> | null;
|
|
1090
|
+
origin: string;
|
|
1091
|
+
status: Generated<"new" | "classified">;
|
|
1092
|
+
route: string | null;
|
|
1093
|
+
classification: Record<string, unknown> | null;
|
|
1094
|
+
classified_at: Date | null;
|
|
1095
|
+
created_at: Generated<Date>;
|
|
1096
|
+
}
|
|
1037
1097
|
/** Convert a subgraph name to its PostgreSQL schema name. */
|
|
1038
1098
|
declare function pgSchemaName(subgraphName: string): string;
|
|
1039
1099
|
/** OSS writes empty account_id — name is the local unique key. */
|
|
@@ -97,7 +97,6 @@ interface EventsArchiveTable {
|
|
|
97
97
|
archived_at: Generated<Date>;
|
|
98
98
|
}
|
|
99
99
|
interface VmEventsTable {
|
|
100
|
-
id: Generated<string>;
|
|
101
100
|
tx_id: string;
|
|
102
101
|
block_height: number;
|
|
103
102
|
ordinal: number;
|
|
@@ -107,6 +106,7 @@ interface VmEventsTable {
|
|
|
107
106
|
}
|
|
108
107
|
interface VmEventsArchiveTable {
|
|
109
108
|
archive_id: Generated<string>;
|
|
109
|
+
/** `block_height:ordinal`; rows archived before migration 0153 hold the old uuid. */
|
|
110
110
|
id: string;
|
|
111
111
|
tx_id: string;
|
|
112
112
|
block_height: number;
|
|
@@ -117,6 +117,25 @@ interface VmEventsArchiveTable {
|
|
|
117
117
|
orphaned_block_hash: string | null;
|
|
118
118
|
archived_at: Generated<Date>;
|
|
119
119
|
}
|
|
120
|
+
interface StateWritesTable {
|
|
121
|
+
block_height: number;
|
|
122
|
+
ordinal: number;
|
|
123
|
+
tx_index: number | null;
|
|
124
|
+
key: string;
|
|
125
|
+
value_hex: string;
|
|
126
|
+
}
|
|
127
|
+
interface StateWritesArchiveTable {
|
|
128
|
+
archive_id: Generated<string>;
|
|
129
|
+
/** `block_height:ordinal`. */
|
|
130
|
+
id: string;
|
|
131
|
+
block_height: number;
|
|
132
|
+
ordinal: number;
|
|
133
|
+
tx_index: number | null;
|
|
134
|
+
key: string;
|
|
135
|
+
value_hex: string;
|
|
136
|
+
orphaned_block_hash: string | null;
|
|
137
|
+
archived_at: Generated<Date>;
|
|
138
|
+
}
|
|
120
139
|
interface DeadLetterEventsTable {
|
|
121
140
|
id: Generated<string>;
|
|
122
141
|
block_height: number;
|
|
@@ -778,9 +797,11 @@ interface Database {
|
|
|
778
797
|
transactions: TransactionsTable;
|
|
779
798
|
events: EventsTable;
|
|
780
799
|
vm_events: VmEventsTable;
|
|
800
|
+
state_writes: StateWritesTable;
|
|
781
801
|
transactions_archive: TransactionsArchiveTable;
|
|
782
802
|
events_archive: EventsArchiveTable;
|
|
783
803
|
vm_events_archive: VmEventsArchiveTable;
|
|
804
|
+
state_writes_archive: StateWritesArchiveTable;
|
|
784
805
|
dead_letter_events: DeadLetterEventsTable;
|
|
785
806
|
mempool_transactions: MempoolTransactionsTable;
|
|
786
807
|
index_progress: IndexProgressTable;
|
|
@@ -836,6 +857,8 @@ interface Database {
|
|
|
836
857
|
sentinel_accounts: SentinelAccountsTable;
|
|
837
858
|
waitlists: WaitlistsTable;
|
|
838
859
|
waitlist_signups: WaitlistSignupsTable;
|
|
860
|
+
api_failed_requests: ApiFailedRequestsTable;
|
|
861
|
+
feedback_tickets: FeedbackTicketsTable;
|
|
839
862
|
}
|
|
840
863
|
interface ServiceHeartbeatsTable {
|
|
841
864
|
name: string;
|
|
@@ -1044,6 +1067,43 @@ interface WaitlistSignupsTable {
|
|
|
1044
1067
|
created_at: Generated<Date>;
|
|
1045
1068
|
}
|
|
1046
1069
|
/**
|
|
1070
|
+
* 24h hosted record of a failed API request, keyed by `request_id` and
|
|
1071
|
+
* scoped to the account that made it. `query` is redacted before insert.
|
|
1072
|
+
*/
|
|
1073
|
+
interface ApiFailedRequestsTable {
|
|
1074
|
+
request_id: string;
|
|
1075
|
+
account_id: string;
|
|
1076
|
+
method: string;
|
|
1077
|
+
path: string;
|
|
1078
|
+
status: number;
|
|
1079
|
+
code: string;
|
|
1080
|
+
message: Generated<string>;
|
|
1081
|
+
query: Record<string, unknown>;
|
|
1082
|
+
origin: string | null;
|
|
1083
|
+
created_at: Generated<Date>;
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* Hosted problem report. `attempted` is the server's own copy of the failed
|
|
1087
|
+
* request (never caller-supplied); `status` starts `new` until classified.
|
|
1088
|
+
*/
|
|
1089
|
+
interface FeedbackTicketsTable {
|
|
1090
|
+
id: Generated<string>;
|
|
1091
|
+
account_id: string;
|
|
1092
|
+
idempotency_key: string | null;
|
|
1093
|
+
request_id: string | null;
|
|
1094
|
+
intent: string;
|
|
1095
|
+
expected: Record<string, unknown> | null;
|
|
1096
|
+
kind_hint: string | null;
|
|
1097
|
+
evidence: Record<string, unknown> | null;
|
|
1098
|
+
attempted: Record<string, unknown> | null;
|
|
1099
|
+
origin: string;
|
|
1100
|
+
status: Generated<"new" | "classified">;
|
|
1101
|
+
route: string | null;
|
|
1102
|
+
classification: Record<string, unknown> | null;
|
|
1103
|
+
classified_at: Date | null;
|
|
1104
|
+
created_at: Generated<Date>;
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1047
1107
|
* The instance's declared sync scope.
|
|
1048
1108
|
*
|
|
1049
1109
|
* An instance that starts at height N is not an instance missing the first N
|
|
@@ -87,7 +87,6 @@ interface EventsArchiveTable {
|
|
|
87
87
|
archived_at: Generated<Date>;
|
|
88
88
|
}
|
|
89
89
|
interface VmEventsTable {
|
|
90
|
-
id: Generated<string>;
|
|
91
90
|
tx_id: string;
|
|
92
91
|
block_height: number;
|
|
93
92
|
ordinal: number;
|
|
@@ -97,6 +96,7 @@ interface VmEventsTable {
|
|
|
97
96
|
}
|
|
98
97
|
interface VmEventsArchiveTable {
|
|
99
98
|
archive_id: Generated<string>;
|
|
99
|
+
/** `block_height:ordinal`; rows archived before migration 0153 hold the old uuid. */
|
|
100
100
|
id: string;
|
|
101
101
|
tx_id: string;
|
|
102
102
|
block_height: number;
|
|
@@ -107,6 +107,25 @@ interface VmEventsArchiveTable {
|
|
|
107
107
|
orphaned_block_hash: string | null;
|
|
108
108
|
archived_at: Generated<Date>;
|
|
109
109
|
}
|
|
110
|
+
interface StateWritesTable {
|
|
111
|
+
block_height: number;
|
|
112
|
+
ordinal: number;
|
|
113
|
+
tx_index: number | null;
|
|
114
|
+
key: string;
|
|
115
|
+
value_hex: string;
|
|
116
|
+
}
|
|
117
|
+
interface StateWritesArchiveTable {
|
|
118
|
+
archive_id: Generated<string>;
|
|
119
|
+
/** `block_height:ordinal`. */
|
|
120
|
+
id: string;
|
|
121
|
+
block_height: number;
|
|
122
|
+
ordinal: number;
|
|
123
|
+
tx_index: number | null;
|
|
124
|
+
key: string;
|
|
125
|
+
value_hex: string;
|
|
126
|
+
orphaned_block_hash: string | null;
|
|
127
|
+
archived_at: Generated<Date>;
|
|
128
|
+
}
|
|
110
129
|
interface DeadLetterEventsTable {
|
|
111
130
|
id: Generated<string>;
|
|
112
131
|
block_height: number;
|
|
@@ -768,9 +787,11 @@ interface Database {
|
|
|
768
787
|
transactions: TransactionsTable;
|
|
769
788
|
events: EventsTable;
|
|
770
789
|
vm_events: VmEventsTable;
|
|
790
|
+
state_writes: StateWritesTable;
|
|
771
791
|
transactions_archive: TransactionsArchiveTable;
|
|
772
792
|
events_archive: EventsArchiveTable;
|
|
773
793
|
vm_events_archive: VmEventsArchiveTable;
|
|
794
|
+
state_writes_archive: StateWritesArchiveTable;
|
|
774
795
|
dead_letter_events: DeadLetterEventsTable;
|
|
775
796
|
mempool_transactions: MempoolTransactionsTable;
|
|
776
797
|
index_progress: IndexProgressTable;
|
|
@@ -826,6 +847,8 @@ interface Database {
|
|
|
826
847
|
sentinel_accounts: SentinelAccountsTable;
|
|
827
848
|
waitlists: WaitlistsTable;
|
|
828
849
|
waitlist_signups: WaitlistSignupsTable;
|
|
850
|
+
api_failed_requests: ApiFailedRequestsTable;
|
|
851
|
+
feedback_tickets: FeedbackTicketsTable;
|
|
829
852
|
}
|
|
830
853
|
interface ServiceHeartbeatsTable {
|
|
831
854
|
name: string;
|
|
@@ -1035,6 +1058,43 @@ interface WaitlistSignupsTable {
|
|
|
1035
1058
|
created_at: Generated<Date>;
|
|
1036
1059
|
}
|
|
1037
1060
|
/**
|
|
1061
|
+
* 24h hosted record of a failed API request, keyed by `request_id` and
|
|
1062
|
+
* scoped to the account that made it. `query` is redacted before insert.
|
|
1063
|
+
*/
|
|
1064
|
+
interface ApiFailedRequestsTable {
|
|
1065
|
+
request_id: string;
|
|
1066
|
+
account_id: string;
|
|
1067
|
+
method: string;
|
|
1068
|
+
path: string;
|
|
1069
|
+
status: number;
|
|
1070
|
+
code: string;
|
|
1071
|
+
message: Generated<string>;
|
|
1072
|
+
query: Record<string, unknown>;
|
|
1073
|
+
origin: string | null;
|
|
1074
|
+
created_at: Generated<Date>;
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* Hosted problem report. `attempted` is the server's own copy of the failed
|
|
1078
|
+
* request (never caller-supplied); `status` starts `new` until classified.
|
|
1079
|
+
*/
|
|
1080
|
+
interface FeedbackTicketsTable {
|
|
1081
|
+
id: Generated<string>;
|
|
1082
|
+
account_id: string;
|
|
1083
|
+
idempotency_key: string | null;
|
|
1084
|
+
request_id: string | null;
|
|
1085
|
+
intent: string;
|
|
1086
|
+
expected: Record<string, unknown> | null;
|
|
1087
|
+
kind_hint: string | null;
|
|
1088
|
+
evidence: Record<string, unknown> | null;
|
|
1089
|
+
attempted: Record<string, unknown> | null;
|
|
1090
|
+
origin: string;
|
|
1091
|
+
status: Generated<"new" | "classified">;
|
|
1092
|
+
route: string | null;
|
|
1093
|
+
classification: Record<string, unknown> | null;
|
|
1094
|
+
classified_at: Date | null;
|
|
1095
|
+
created_at: Generated<Date>;
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1038
1098
|
* Webhook CRUD. `signing_secret_enc` is transparently encrypted via
|
|
1039
1099
|
* `encryptSecret`/`decryptSecret`. Plaintext secrets only leave via the
|
|
1040
1100
|
* return value of `create` (one-time display) and `rotateSecret`.
|
package/dist/src/db/schema.d.ts
CHANGED
|
@@ -86,7 +86,6 @@ interface EventsArchiveTable {
|
|
|
86
86
|
archived_at: Generated<Date>;
|
|
87
87
|
}
|
|
88
88
|
interface VmEventsTable {
|
|
89
|
-
id: Generated<string>;
|
|
90
89
|
tx_id: string;
|
|
91
90
|
block_height: number;
|
|
92
91
|
ordinal: number;
|
|
@@ -96,6 +95,7 @@ interface VmEventsTable {
|
|
|
96
95
|
}
|
|
97
96
|
interface VmEventsArchiveTable {
|
|
98
97
|
archive_id: Generated<string>;
|
|
98
|
+
/** `block_height:ordinal`; rows archived before migration 0153 hold the old uuid. */
|
|
99
99
|
id: string;
|
|
100
100
|
tx_id: string;
|
|
101
101
|
block_height: number;
|
|
@@ -106,6 +106,25 @@ interface VmEventsArchiveTable {
|
|
|
106
106
|
orphaned_block_hash: string | null;
|
|
107
107
|
archived_at: Generated<Date>;
|
|
108
108
|
}
|
|
109
|
+
interface StateWritesTable {
|
|
110
|
+
block_height: number;
|
|
111
|
+
ordinal: number;
|
|
112
|
+
tx_index: number | null;
|
|
113
|
+
key: string;
|
|
114
|
+
value_hex: string;
|
|
115
|
+
}
|
|
116
|
+
interface StateWritesArchiveTable {
|
|
117
|
+
archive_id: Generated<string>;
|
|
118
|
+
/** `block_height:ordinal`. */
|
|
119
|
+
id: string;
|
|
120
|
+
block_height: number;
|
|
121
|
+
ordinal: number;
|
|
122
|
+
tx_index: number | null;
|
|
123
|
+
key: string;
|
|
124
|
+
value_hex: string;
|
|
125
|
+
orphaned_block_hash: string | null;
|
|
126
|
+
archived_at: Generated<Date>;
|
|
127
|
+
}
|
|
109
128
|
interface DeadLetterEventsTable {
|
|
110
129
|
id: Generated<string>;
|
|
111
130
|
block_height: number;
|
|
@@ -767,9 +786,11 @@ interface Database {
|
|
|
767
786
|
transactions: TransactionsTable;
|
|
768
787
|
events: EventsTable;
|
|
769
788
|
vm_events: VmEventsTable;
|
|
789
|
+
state_writes: StateWritesTable;
|
|
770
790
|
transactions_archive: TransactionsArchiveTable;
|
|
771
791
|
events_archive: EventsArchiveTable;
|
|
772
792
|
vm_events_archive: VmEventsArchiveTable;
|
|
793
|
+
state_writes_archive: StateWritesArchiveTable;
|
|
773
794
|
dead_letter_events: DeadLetterEventsTable;
|
|
774
795
|
mempool_transactions: MempoolTransactionsTable;
|
|
775
796
|
index_progress: IndexProgressTable;
|
|
@@ -825,6 +846,8 @@ interface Database {
|
|
|
825
846
|
sentinel_accounts: SentinelAccountsTable;
|
|
826
847
|
waitlists: WaitlistsTable;
|
|
827
848
|
waitlist_signups: WaitlistSignupsTable;
|
|
849
|
+
api_failed_requests: ApiFailedRequestsTable;
|
|
850
|
+
feedback_tickets: FeedbackTicketsTable;
|
|
828
851
|
}
|
|
829
852
|
interface ServiceHeartbeatsTable {
|
|
830
853
|
name: string;
|
|
@@ -939,6 +962,8 @@ type UpdateEvent = Updateable<EventsTable>;
|
|
|
939
962
|
type VmEvent = Selectable<VmEventsTable>;
|
|
940
963
|
type InsertVmEvent = Insertable<VmEventsTable>;
|
|
941
964
|
type UpdateVmEvent = Updateable<VmEventsTable>;
|
|
965
|
+
type StateWrite = Selectable<StateWritesTable>;
|
|
966
|
+
type InsertStateWrite = Insertable<StateWritesTable>;
|
|
942
967
|
type IndexProgress = Selectable<IndexProgressTable>;
|
|
943
968
|
type InsertIndexProgress = Insertable<IndexProgressTable>;
|
|
944
969
|
type UpdateIndexProgress = Updateable<IndexProgressTable>;
|
|
@@ -1096,7 +1121,48 @@ interface WaitlistSignupsTable {
|
|
|
1096
1121
|
answers: Record<string, unknown>;
|
|
1097
1122
|
created_at: Generated<Date>;
|
|
1098
1123
|
}
|
|
1124
|
+
/**
|
|
1125
|
+
* 24h hosted record of a failed API request, keyed by `request_id` and
|
|
1126
|
+
* scoped to the account that made it. `query` is redacted before insert.
|
|
1127
|
+
*/
|
|
1128
|
+
interface ApiFailedRequestsTable {
|
|
1129
|
+
request_id: string;
|
|
1130
|
+
account_id: string;
|
|
1131
|
+
method: string;
|
|
1132
|
+
path: string;
|
|
1133
|
+
status: number;
|
|
1134
|
+
code: string;
|
|
1135
|
+
message: Generated<string>;
|
|
1136
|
+
query: Record<string, unknown>;
|
|
1137
|
+
origin: string | null;
|
|
1138
|
+
created_at: Generated<Date>;
|
|
1139
|
+
}
|
|
1140
|
+
type ApiFailedRequest = Selectable<ApiFailedRequestsTable>;
|
|
1141
|
+
type InsertApiFailedRequest = Insertable<ApiFailedRequestsTable>;
|
|
1142
|
+
/**
|
|
1143
|
+
* Hosted problem report. `attempted` is the server's own copy of the failed
|
|
1144
|
+
* request (never caller-supplied); `status` starts `new` until classified.
|
|
1145
|
+
*/
|
|
1146
|
+
interface FeedbackTicketsTable {
|
|
1147
|
+
id: Generated<string>;
|
|
1148
|
+
account_id: string;
|
|
1149
|
+
idempotency_key: string | null;
|
|
1150
|
+
request_id: string | null;
|
|
1151
|
+
intent: string;
|
|
1152
|
+
expected: Record<string, unknown> | null;
|
|
1153
|
+
kind_hint: string | null;
|
|
1154
|
+
evidence: Record<string, unknown> | null;
|
|
1155
|
+
attempted: Record<string, unknown> | null;
|
|
1156
|
+
origin: string;
|
|
1157
|
+
status: Generated<"new" | "classified">;
|
|
1158
|
+
route: string | null;
|
|
1159
|
+
classification: Record<string, unknown> | null;
|
|
1160
|
+
classified_at: Date | null;
|
|
1161
|
+
created_at: Generated<Date>;
|
|
1162
|
+
}
|
|
1163
|
+
type FeedbackTicket = Selectable<FeedbackTicketsTable>;
|
|
1164
|
+
type InsertFeedbackTicket = Insertable<FeedbackTicketsTable>;
|
|
1099
1165
|
type Waitlist = Selectable<WaitlistsTable>;
|
|
1100
1166
|
type WaitlistSignup = Selectable<WaitlistSignupsTable>;
|
|
1101
1167
|
type InsertWaitlistSignup = Insertable<WaitlistSignupsTable>;
|
|
1102
|
-
export { Account, AccountBalanceAlerts, AccountBalanceAlertsTable, AccountCredits, AccountCreditsTable, AccountSpendCap, AccountSpendCapsTable, AccountsTable, ApiKey, ApiKeysTable, ArchiveFetch, ArchiveFetchesTable, Block, BlocksTable, BnsMarketplaceAction, BnsMarketplaceEventsTable, BnsNameEventTopic, BnsNameEventsTable, BnsNamesTable, BnsNamespaceEventStatus, BnsNamespaceEventsTable, BnsNamespacesTable, BurnBlockRewardSlotsTable, BurnBlockRewardsTable, ChainReadCacheTable, ChainReorgsTable, Contract, ContractsTable, CoverageSegmentsTable, Database, DeadLetterEventsTable, DecodedEventsTable, DecoderCheckpointsTable, Event, EventsArchiveTable, EventsTable, FailureClass, FailureUnit, IndexProgress, IndexProgressTable, InsertAccount, InsertAccountBalanceAlerts, InsertAccountCredits, InsertAccountSpendCap, InsertApiKey, InsertArchiveFetch, InsertBlock, InsertContract, InsertEvent, InsertIndexProgress, InsertMagicLink, InsertMempoolTransaction, InsertSession, InsertSubgraph, InsertSubgraphGap, InsertSubgraphHealthSnapshot, InsertSubgraphOperation, InsertTransaction, InsertUsageLedgerRow, InsertVmEvent, InsertWaitlistSignup, InsertWebhook, InsertWebhookDelivery, InsertWebhookOutbox, InstancesTable, MagicLink, MagicLinksTable, MempoolTransaction, MempoolTransactionsTable, NativeClock, ObserverJournalStatus, ObserverJournalTable, OutboxStatus, PendingForkBlocksTable, Pox4CallsTable, Pox4FunctionName, Pox5CycleSignersTable, Pox5CyclesTable, Pox5EventTopic, Pox5EventsTable, ProcessedStripeEventsTable, RepairMode, RetryState, RunStatus, SbtcEventTopic, SbtcEventsTable, SbtcSettlementsTable, SbtcTokenEventType, SbtcTokenEventsTable, SentinelAccount, SentinelAccountsTable, ServiceHeartbeatsTable, Session, SessionsTable, StageBlockReceiptsTable, StageFailuresTable, StageKind, StageRegistryTable, StageRunsTable, Subgraph, SubgraphGap, SubgraphGapsTable, SubgraphHealthSnapshot, SubgraphHealthSnapshotsTable, SubgraphOperation, SubgraphOperationKind, SubgraphOperationStatus, SubgraphOperationsTable, SubgraphProcessingStatsTable, SubgraphViolationsTable, SubgraphsTable, SyncScopesTable, Transaction, TransactionsArchiveTable, TransactionsTable, TriggerEvaluatorState, TriggerEvaluatorStateTable, UpdateAccountBalanceAlerts, UpdateAccountCredits, UpdateAccountSpendCap, UpdateApiKey, UpdateArchiveFetch, UpdateBlock, UpdateContract, UpdateEvent, UpdateIndexProgress, UpdateSubgraph, UpdateSubgraphOperation, UpdateTransaction, UpdateUsageLedgerRow, UpdateVmEvent, UpdateWebhook, UpdateWebhookOutbox, UsageLedgerRow, UsageLedgerTable, VmEvent, VmEventsArchiveTable, VmEventsTable, Waitlist, WaitlistSignup, WaitlistSignupsTable, WaitlistsTable, Webhook, WebhookDeliveriesTable, WebhookDelivery, WebhookFormat, WebhookKind, WebhookOutbox, WebhookOutboxTable, WebhookRuntime, WebhookStatus, WebhooksTable };
|
|
1168
|
+
export { Account, AccountBalanceAlerts, AccountBalanceAlertsTable, AccountCredits, AccountCreditsTable, AccountSpendCap, AccountSpendCapsTable, AccountsTable, ApiFailedRequest, ApiFailedRequestsTable, ApiKey, ApiKeysTable, ArchiveFetch, ArchiveFetchesTable, Block, BlocksTable, BnsMarketplaceAction, BnsMarketplaceEventsTable, BnsNameEventTopic, BnsNameEventsTable, BnsNamesTable, BnsNamespaceEventStatus, BnsNamespaceEventsTable, BnsNamespacesTable, BurnBlockRewardSlotsTable, BurnBlockRewardsTable, ChainReadCacheTable, ChainReorgsTable, Contract, ContractsTable, CoverageSegmentsTable, Database, DeadLetterEventsTable, DecodedEventsTable, DecoderCheckpointsTable, Event, EventsArchiveTable, EventsTable, FailureClass, FailureUnit, FeedbackTicket, FeedbackTicketsTable, IndexProgress, IndexProgressTable, InsertAccount, InsertAccountBalanceAlerts, InsertAccountCredits, InsertAccountSpendCap, InsertApiFailedRequest, InsertApiKey, InsertArchiveFetch, InsertBlock, InsertContract, InsertEvent, InsertFeedbackTicket, InsertIndexProgress, InsertMagicLink, InsertMempoolTransaction, InsertSession, InsertStateWrite, InsertSubgraph, InsertSubgraphGap, InsertSubgraphHealthSnapshot, InsertSubgraphOperation, InsertTransaction, InsertUsageLedgerRow, InsertVmEvent, InsertWaitlistSignup, InsertWebhook, InsertWebhookDelivery, InsertWebhookOutbox, InstancesTable, MagicLink, MagicLinksTable, MempoolTransaction, MempoolTransactionsTable, NativeClock, ObserverJournalStatus, ObserverJournalTable, OutboxStatus, PendingForkBlocksTable, Pox4CallsTable, Pox4FunctionName, Pox5CycleSignersTable, Pox5CyclesTable, Pox5EventTopic, Pox5EventsTable, ProcessedStripeEventsTable, RepairMode, RetryState, RunStatus, SbtcEventTopic, SbtcEventsTable, SbtcSettlementsTable, SbtcTokenEventType, SbtcTokenEventsTable, SentinelAccount, SentinelAccountsTable, ServiceHeartbeatsTable, Session, SessionsTable, StageBlockReceiptsTable, StageFailuresTable, StageKind, StageRegistryTable, StageRunsTable, StateWrite, StateWritesArchiveTable, StateWritesTable, Subgraph, SubgraphGap, SubgraphGapsTable, SubgraphHealthSnapshot, SubgraphHealthSnapshotsTable, SubgraphOperation, SubgraphOperationKind, SubgraphOperationStatus, SubgraphOperationsTable, SubgraphProcessingStatsTable, SubgraphViolationsTable, SubgraphsTable, SyncScopesTable, Transaction, TransactionsArchiveTable, TransactionsTable, TriggerEvaluatorState, TriggerEvaluatorStateTable, UpdateAccountBalanceAlerts, UpdateAccountCredits, UpdateAccountSpendCap, UpdateApiKey, UpdateArchiveFetch, UpdateBlock, UpdateContract, UpdateEvent, UpdateIndexProgress, UpdateSubgraph, UpdateSubgraphOperation, UpdateTransaction, UpdateUsageLedgerRow, UpdateVmEvent, UpdateWebhook, UpdateWebhookOutbox, UsageLedgerRow, UsageLedgerTable, VmEvent, VmEventsArchiveTable, VmEventsTable, Waitlist, WaitlistSignup, WaitlistSignupsTable, WaitlistsTable, Webhook, WebhookDeliveriesTable, WebhookDelivery, WebhookFormat, WebhookKind, WebhookOutbox, WebhookOutboxTable, WebhookRuntime, WebhookStatus, WebhooksTable };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure, dependency-free pieces of the API error envelope: request ids,
|
|
3
|
+
* default codes by status, feedback pointers and query redaction. Shared by
|
|
4
|
+
* the API middleware and the workload gateway so both emit the same shape.
|
|
5
|
+
*/
|
|
6
|
+
/** Default `code` for an error body that set none, keyed by HTTP status. */
|
|
7
|
+
declare const DEFAULT_CODE_BY_STATUS: Record<number, string>;
|
|
8
|
+
/** Where to report a gap: a path on hosted, the issue tracker on self-host. */
|
|
9
|
+
declare const FEEDBACK_URL: {
|
|
10
|
+
readonly platform: "/v1/feedback"
|
|
11
|
+
readonly oss: "https://github.com/ryanwaits/secondlayer/issues/new"
|
|
12
|
+
};
|
|
13
|
+
/** One hosted failed-request record (account-scoped, kept 24h). */
|
|
14
|
+
type FailedRequestRecord = {
|
|
15
|
+
request_id: string
|
|
16
|
+
account_id: string
|
|
17
|
+
method: string
|
|
18
|
+
path: string
|
|
19
|
+
status: number
|
|
20
|
+
code: string
|
|
21
|
+
message: string
|
|
22
|
+
query: Record<string, unknown>
|
|
23
|
+
origin: string | null
|
|
24
|
+
};
|
|
25
|
+
/** Incoming `X-Request-Id` values matching this are reused. */
|
|
26
|
+
declare const REQUEST_ID_PATTERN: RegExp;
|
|
27
|
+
/** `req_` plus 24 lowercase hex chars. */
|
|
28
|
+
declare function newRequestId(): string;
|
|
29
|
+
/**
|
|
30
|
+
* Query params safe to store: sensitive keys dropped, values capped at 200
|
|
31
|
+
* chars, and a `{ _truncated, keys }` stub when the result is over 2048 chars.
|
|
32
|
+
*/
|
|
33
|
+
declare function redactQuery(params: URLSearchParams): Record<string, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Additive error body: `request_id` always set, `code` only when absent or
|
|
36
|
+
* not a string, `feedback` only when absent (or always with
|
|
37
|
+
* `overrideFeedback`). Returns null when `body` is not an object carrying an
|
|
38
|
+
* `error` key, so callers leave such responses alone.
|
|
39
|
+
*/
|
|
40
|
+
declare function augmentErrorBody(body: unknown, opts: {
|
|
41
|
+
status: number
|
|
42
|
+
requestId: string
|
|
43
|
+
feedbackUrl: string
|
|
44
|
+
overrideFeedback?: boolean
|
|
45
|
+
}): Record<string, unknown> | null;
|
|
46
|
+
/** `x-sl-origin` header reduced to a known value, else null. */
|
|
47
|
+
declare function normalizeOrigin(header: string | undefined): string | null;
|
|
48
|
+
export { DEFAULT_CODE_BY_STATUS, FEEDBACK_URL, FailedRequestRecord, REQUEST_ID_PATTERN, augmentErrorBody, newRequestId, normalizeOrigin, redactQuery };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// src/error-envelope.ts
|
|
2
|
+
var DEFAULT_CODE_BY_STATUS = {
|
|
3
|
+
400: "VALIDATION_ERROR",
|
|
4
|
+
401: "AUTHENTICATION_ERROR",
|
|
5
|
+
402: "PAYMENT_REQUIRED",
|
|
6
|
+
403: "FORBIDDEN",
|
|
7
|
+
404: "NOT_FOUND",
|
|
8
|
+
409: "CONFLICT",
|
|
9
|
+
410: "GONE",
|
|
10
|
+
415: "UNSUPPORTED_MEDIA_TYPE",
|
|
11
|
+
422: "VALIDATION_ERROR",
|
|
12
|
+
429: "RATE_LIMIT_ERROR",
|
|
13
|
+
500: "INTERNAL_ERROR",
|
|
14
|
+
502: "UPSTREAM_ERROR",
|
|
15
|
+
503: "SERVICE_UNAVAILABLE"
|
|
16
|
+
};
|
|
17
|
+
var FEEDBACK_URL = {
|
|
18
|
+
platform: "/v1/feedback",
|
|
19
|
+
oss: "https://github.com/ryanwaits/secondlayer/issues/new"
|
|
20
|
+
};
|
|
21
|
+
var REQUEST_ID_PATTERN = /^[A-Za-z0-9._-]{8,64}$/;
|
|
22
|
+
function newRequestId() {
|
|
23
|
+
const bytes = crypto.getRandomValues(new Uint8Array(12));
|
|
24
|
+
let hex = "";
|
|
25
|
+
for (const b of bytes)
|
|
26
|
+
hex += b.toString(16).padStart(2, "0");
|
|
27
|
+
return `req_${hex}`;
|
|
28
|
+
}
|
|
29
|
+
var SENSITIVE_KEY = /token|key|secret|signature|password|auth/i;
|
|
30
|
+
var MAX_VALUE_CHARS = 200;
|
|
31
|
+
var MAX_QUERY_JSON_CHARS = 2048;
|
|
32
|
+
function redactQuery(params) {
|
|
33
|
+
const out = {};
|
|
34
|
+
for (const [key, value] of params) {
|
|
35
|
+
if (SENSITIVE_KEY.test(key))
|
|
36
|
+
continue;
|
|
37
|
+
out[key] = value.slice(0, MAX_VALUE_CHARS);
|
|
38
|
+
}
|
|
39
|
+
if (JSON.stringify(out).length > MAX_QUERY_JSON_CHARS) {
|
|
40
|
+
return { _truncated: true, keys: Object.keys(out) };
|
|
41
|
+
}
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
function augmentErrorBody(body, opts) {
|
|
45
|
+
if (typeof body !== "object" || body === null || Array.isArray(body)) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
if (!("error" in body))
|
|
49
|
+
return null;
|
|
50
|
+
const src = body;
|
|
51
|
+
const next = { ...src, request_id: opts.requestId };
|
|
52
|
+
if (typeof src.code !== "string") {
|
|
53
|
+
next.code = DEFAULT_CODE_BY_STATUS[opts.status] ?? "HTTP_ERROR";
|
|
54
|
+
}
|
|
55
|
+
if (opts.overrideFeedback || src.feedback === undefined) {
|
|
56
|
+
next.feedback = { url: opts.feedbackUrl };
|
|
57
|
+
}
|
|
58
|
+
return next;
|
|
59
|
+
}
|
|
60
|
+
var KNOWN_ORIGINS = ["cli", "mcp", "session"];
|
|
61
|
+
function normalizeOrigin(header) {
|
|
62
|
+
const v = header?.toLowerCase();
|
|
63
|
+
return v !== undefined && KNOWN_ORIGINS.includes(v) ? v : null;
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
DEFAULT_CODE_BY_STATUS,
|
|
67
|
+
FEEDBACK_URL,
|
|
68
|
+
REQUEST_ID_PATTERN,
|
|
69
|
+
augmentErrorBody,
|
|
70
|
+
newRequestId,
|
|
71
|
+
normalizeOrigin,
|
|
72
|
+
redactQuery
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
//# debugId=5A36C709A44A1A2864756E2164756E21
|
|
76
|
+
//# sourceMappingURL=error-envelope.js.map
|