@secondlayer/shared 11.7.1 → 11.8.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/dist/src/archive/copy-loader.d.ts +1 -1
- package/dist/src/archive/copy-loader.js +4 -20
- package/dist/src/archive/copy-loader.js.map +2 -2
- package/dist/src/archive/derived-stage-report.d.ts +1 -1
- package/dist/src/archive/derived-stage-report.js +3 -19
- package/dist/src/archive/derived-stage-report.js.map +2 -2
- package/dist/src/archive/disk-guard.d.ts +1 -1
- package/dist/src/archive/disk-guard.js +3 -19
- package/dist/src/archive/disk-guard.js.map +2 -2
- package/dist/src/archive/instance-diagnosis.d.ts +1 -1
- package/dist/src/archive/instance-diagnosis.js +6 -22
- package/dist/src/archive/instance-diagnosis.js.map +2 -2
- package/dist/src/archive/key-registry.d.ts +1 -1
- package/dist/src/archive/key-registry.js +12 -12
- package/dist/src/archive/key-registry.js.map +1 -1
- package/dist/src/archive/per-height-digest.d.ts +1 -1
- package/dist/src/archive/per-height-digest.js +3 -17
- package/dist/src/archive/per-height-digest.js.map +5 -5
- package/dist/src/archive/progress.d.ts +1 -1
- package/dist/src/archive/progress.js +4 -20
- package/dist/src/archive/progress.js.map +2 -2
- package/dist/src/archive/range-digest.d.ts +28 -3
- package/dist/src/archive/range-digest.js +4 -20
- package/dist/src/archive/range-digest.js.map +2 -2
- package/dist/src/archive/reference.d.ts +1 -1
- package/dist/src/archive/reference.js +14 -12
- package/dist/src/archive/reference.js.map +5 -5
- package/dist/src/archive/root-key.d.ts +1 -1
- package/dist/src/archive/root-key.js +3 -19
- package/dist/src/archive/root-key.js.map +2 -2
- package/dist/src/archive/semantic-digest-builder.d.ts +28 -3
- package/dist/src/archive/semantic-digest-builder.js +5 -19
- package/dist/src/archive/semantic-digest-builder.js.map +5 -5
- package/dist/src/archive/semantic-digest.d.ts +1 -1
- package/dist/src/archive/semantic-digest.js +4 -20
- package/dist/src/archive/semantic-digest.js.map +2 -2
- package/dist/src/archive/status.d.ts +1 -1
- package/dist/src/archive/status.js +4 -20
- package/dist/src/archive/status.js.map +2 -2
- package/dist/src/coverage/index.d.ts +27 -2
- package/dist/src/coverage/index.js +80 -96
- package/dist/src/coverage/index.js.map +2 -2
- package/dist/src/crypto/ed25519.d.ts +1 -1
- package/dist/src/crypto/ed25519.js +13 -13
- package/dist/src/crypto/ed25519.js.map +1 -1
- package/dist/src/crypto/hmac.d.ts +1 -1
- package/dist/src/crypto/hmac.js +9 -9
- package/dist/src/crypto/hmac.js.map +1 -1
- package/dist/src/crypto/secondlayer-webhook.d.ts +1 -1
- package/dist/src/crypto/secondlayer-webhook.js +14 -14
- package/dist/src/crypto/secondlayer-webhook.js.map +2 -2
- package/dist/src/crypto/secrets.d.ts +1 -1
- package/dist/src/crypto/secrets.js +15 -29
- package/dist/src/crypto/secrets.js.map +5 -5
- package/dist/src/crypto/standard-webhooks.d.ts +1 -1
- package/dist/src/crypto/standard-webhooks.js +3 -19
- package/dist/src/crypto/standard-webhooks.js.map +2 -2
- package/dist/src/db/index.d.ts +48 -19
- package/dist/src/db/index.js +41 -55
- package/dist/src/db/index.js.map +6 -6
- package/dist/src/db/jsonb.d.ts +1 -1
- package/dist/src/db/jsonb.js +3 -19
- package/dist/src/db/jsonb.js.map +2 -2
- package/dist/src/db/queries/chain-reorgs.d.ts +27 -2
- package/dist/src/db/queries/chain-reorgs.js +28 -42
- package/dist/src/db/queries/chain-reorgs.js.map +6 -6
- package/dist/src/db/queries/contracts.d.ts +27 -2
- package/dist/src/db/queries/contracts.js +9 -23
- package/dist/src/db/queries/contracts.js.map +5 -5
- package/dist/src/db/queries/instance.d.ts +27 -2
- package/dist/src/db/queries/instance.js +7 -23
- package/dist/src/db/queries/instance.js.map +2 -2
- package/dist/src/db/queries/integrity.d.ts +27 -2
- package/dist/src/db/queries/integrity.js +5 -21
- package/dist/src/db/queries/integrity.js.map +2 -2
- package/dist/src/db/queries/subgraph-gaps.d.ts +27 -2
- package/dist/src/db/queries/subgraph-gaps.js +5 -21
- package/dist/src/db/queries/subgraph-gaps.js.map +2 -2
- package/dist/src/db/queries/subgraph-operations.d.ts +27 -2
- package/dist/src/db/queries/subgraph-operations.js +17 -33
- package/dist/src/db/queries/subgraph-operations.js.map +2 -2
- package/dist/src/db/queries/subgraphs.d.ts +28 -14
- package/dist/src/db/queries/subgraphs.js +15 -37
- package/dist/src/db/queries/subgraphs.js.map +5 -5
- package/dist/src/db/queries/sync-scope.d.ts +27 -2
- package/dist/src/db/queries/sync-scope.js +6 -22
- package/dist/src/db/queries/sync-scope.js.map +2 -2
- package/dist/src/db/queries/webhooks.d.ts +27 -2
- package/dist/src/db/queries/webhooks.js +54 -50
- package/dist/src/db/queries/webhooks.js.map +5 -5
- package/dist/src/db/schema.d.ts +30 -2
- package/dist/src/env.d.ts +1 -1
- package/dist/src/env.js +7 -23
- package/dist/src/env.js.map +2 -2
- package/dist/src/errors.d.ts +4 -4
- package/dist/src/errors.js +15 -31
- package/dist/src/errors.js.map +3 -3
- package/dist/src/index-http.d.ts +1 -1
- package/dist/src/index-http.js +4 -20
- package/dist/src/index-http.js.map +3 -3
- package/dist/src/index-internal-auth.d.ts +4 -7
- package/dist/src/index-internal-auth.js +8 -24
- package/dist/src/index-internal-auth.js.map +3 -3
- package/dist/src/index.d.ts +176 -152
- package/dist/src/index.js +305 -317
- package/dist/src/index.js.map +15 -15
- package/dist/src/leader.d.ts +1 -1
- package/dist/src/leader.js +7 -21
- package/dist/src/leader.js.map +5 -5
- package/dist/src/logger.js +1 -17
- package/dist/src/logger.js.map +2 -2
- package/dist/src/mode.d.ts +1 -1
- package/dist/src/mode.js +5 -21
- package/dist/src/mode.js.map +2 -2
- package/dist/src/node/archive-client.d.ts +1 -1
- package/dist/src/node/archive-client.js +9 -23
- package/dist/src/node/archive-client.js.map +5 -5
- package/dist/src/node/client.d.ts +1 -1
- package/dist/src/node/client.js +4 -18
- package/dist/src/node/client.js.map +5 -5
- package/dist/src/node/consensus.d.ts +1 -1
- package/dist/src/node/consensus.js +5 -21
- package/dist/src/node/consensus.js.map +2 -2
- package/dist/src/node/hiro-client.d.ts +1 -1
- package/dist/src/node/hiro-client.js +1 -17
- package/dist/src/node/hiro-client.js.map +2 -2
- package/dist/src/node/hiro-pg-client.js +1 -17
- package/dist/src/node/hiro-pg-client.js.map +2 -2
- package/dist/src/node/local-client.d.ts +27 -2
- package/dist/src/node/local-client.js +3 -19
- package/dist/src/node/local-client.js.map +2 -2
- package/dist/src/node/nakamoto.d.ts +1 -1
- package/dist/src/node/nakamoto.js +12 -28
- package/dist/src/node/nakamoto.js.map +2 -2
- package/dist/src/queue/listener.d.ts +1 -1
- package/dist/src/queue/listener.js +4 -20
- package/dist/src/queue/listener.js.map +2 -2
- package/dist/src/runtime/index.d.ts +1 -1
- package/dist/src/runtime/index.js +51 -67
- package/dist/src/runtime/index.js.map +2 -2
- package/dist/src/schemas/index.d.ts +8 -4
- package/dist/src/schemas/index.js +64 -41
- package/dist/src/schemas/index.js.map +4 -4
- package/dist/src/schemas/subgraphs.d.ts +1 -4
- package/dist/src/schemas/subgraphs.js +1 -18
- package/dist/src/schemas/subgraphs.js.map +3 -3
- package/dist/src/schemas/webhooks.d.ts +19 -1
- package/dist/src/schemas/webhooks.js +70 -41
- package/dist/src/schemas/webhooks.js.map +3 -3
- package/dist/src/streams-bulk-manifest.d.ts +1 -1
- package/dist/src/streams-bulk-manifest.js +9 -9
- package/dist/src/streams-bulk-manifest.js.map +1 -1
- package/dist/src/streams-rows/index.d.ts +1 -1
- package/dist/src/streams-rows/index.js +32 -48
- package/dist/src/streams-rows/index.js.map +2 -2
- package/dist/src/subgraphs/spec.d.ts +1 -11
- package/dist/src/subgraphs/spec.js +27 -93
- package/dist/src/subgraphs/spec.js.map +3 -3
- package/dist/src/types.d.ts +1 -1
- package/migrations/0136_drop_subgraph_visibility.ts +34 -0
- package/migrations/0137_webhook_outbox_last_error.ts +27 -0
- package/migrations/0138_usage_ledger.ts +46 -0
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -13,6 +13,70 @@ var __export = (target, all) => {
|
|
|
13
13
|
set: __exportSetter.bind(all, name)
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
|
+
// src/event-types.ts
|
|
17
|
+
import {
|
|
18
|
+
DECODED_EVENT_TYPES
|
|
19
|
+
} from "@secondlayer/stacks/filters";
|
|
20
|
+
import {
|
|
21
|
+
DECODED_EVENT_TYPES as DECODED_EVENT_TYPES2,
|
|
22
|
+
VM_EVENT_TYPES,
|
|
23
|
+
VM_NODE_TO_STORED_TYPE
|
|
24
|
+
} from "@secondlayer/stacks/filters";
|
|
25
|
+
var VM_STORED_TO_NODE_TYPE = {
|
|
26
|
+
nested_contract_call: "contract_call_event",
|
|
27
|
+
var_set: "var_set_event",
|
|
28
|
+
map_set: "map_set_event",
|
|
29
|
+
map_insert: "map_insert_event",
|
|
30
|
+
map_delete: "map_delete_event"
|
|
31
|
+
};
|
|
32
|
+
var STREAMS_EVENT_TYPES = DECODED_EVENT_TYPES;
|
|
33
|
+
// src/db-event-types.ts
|
|
34
|
+
var STREAMS_DB_EVENT_TYPES = [
|
|
35
|
+
"stx_transfer_event",
|
|
36
|
+
"stx_mint_event",
|
|
37
|
+
"stx_burn_event",
|
|
38
|
+
"stx_lock_event",
|
|
39
|
+
"ft_transfer_event",
|
|
40
|
+
"ft_mint_event",
|
|
41
|
+
"ft_burn_event",
|
|
42
|
+
"nft_transfer_event",
|
|
43
|
+
"nft_mint_event",
|
|
44
|
+
"nft_burn_event",
|
|
45
|
+
"smart_contract_event",
|
|
46
|
+
"contract_event"
|
|
47
|
+
];
|
|
48
|
+
var DB_TO_STREAMS_EVENT_TYPE = {
|
|
49
|
+
stx_transfer_event: "stx_transfer",
|
|
50
|
+
stx_mint_event: "stx_mint",
|
|
51
|
+
stx_burn_event: "stx_burn",
|
|
52
|
+
stx_lock_event: "stx_lock",
|
|
53
|
+
ft_transfer_event: "ft_transfer",
|
|
54
|
+
ft_mint_event: "ft_mint",
|
|
55
|
+
ft_burn_event: "ft_burn",
|
|
56
|
+
nft_transfer_event: "nft_transfer",
|
|
57
|
+
nft_mint_event: "nft_mint",
|
|
58
|
+
nft_burn_event: "nft_burn",
|
|
59
|
+
smart_contract_event: "print",
|
|
60
|
+
contract_event: "print"
|
|
61
|
+
};
|
|
62
|
+
var STREAMS_TO_DB_EVENT_TYPES = {
|
|
63
|
+
stx_transfer: ["stx_transfer_event"],
|
|
64
|
+
stx_mint: ["stx_mint_event"],
|
|
65
|
+
stx_burn: ["stx_burn_event"],
|
|
66
|
+
stx_lock: ["stx_lock_event"],
|
|
67
|
+
ft_transfer: ["ft_transfer_event"],
|
|
68
|
+
ft_mint: ["ft_mint_event"],
|
|
69
|
+
ft_burn: ["ft_burn_event"],
|
|
70
|
+
nft_transfer: ["nft_transfer_event"],
|
|
71
|
+
nft_mint: ["nft_mint_event"],
|
|
72
|
+
nft_burn: ["nft_burn_event"],
|
|
73
|
+
print: ["smart_contract_event", "contract_event"]
|
|
74
|
+
};
|
|
75
|
+
// src/db/index.ts
|
|
76
|
+
import { Kysely } from "kysely";
|
|
77
|
+
import { PostgresJSDialect } from "kysely-postgres-js";
|
|
78
|
+
import postgres from "postgres";
|
|
79
|
+
|
|
16
80
|
// src/env.ts
|
|
17
81
|
import { z } from "zod";
|
|
18
82
|
var networksSchema = z.string().transform((val) => {
|
|
@@ -178,27 +242,7 @@ function isOssMode() {
|
|
|
178
242
|
return getInstanceMode() === "oss";
|
|
179
243
|
}
|
|
180
244
|
|
|
181
|
-
// src/db/jsonb.ts
|
|
182
|
-
import { sql } from "kysely";
|
|
183
|
-
function jsonb(value) {
|
|
184
|
-
const escaped = JSON.stringify(value, (_k, v) => typeof v === "bigint" ? v.toString() : v).replace(/'/g, "''");
|
|
185
|
-
return sql`${sql.raw(`'${escaped}'::jsonb`)}`;
|
|
186
|
-
}
|
|
187
|
-
function parseJsonb(value) {
|
|
188
|
-
if (typeof value === "string") {
|
|
189
|
-
try {
|
|
190
|
-
return JSON.parse(value);
|
|
191
|
-
} catch {
|
|
192
|
-
return value;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return value ?? {};
|
|
196
|
-
}
|
|
197
|
-
|
|
198
245
|
// src/db/index.ts
|
|
199
|
-
import { Kysely } from "kysely";
|
|
200
|
-
import { PostgresJSDialect } from "kysely-postgres-js";
|
|
201
|
-
import postgres from "postgres";
|
|
202
246
|
import { sql as sql2 } from "kysely";
|
|
203
247
|
|
|
204
248
|
// src/db/source-read-columns.ts
|
|
@@ -715,6 +759,22 @@ var SOURCE_READ_PKS = {
|
|
|
715
759
|
events: ["tx_id", "event_index"],
|
|
716
760
|
chain_reorgs: null
|
|
717
761
|
};
|
|
762
|
+
// src/db/jsonb.ts
|
|
763
|
+
import { sql } from "kysely";
|
|
764
|
+
function jsonb(value) {
|
|
765
|
+
const escaped = JSON.stringify(value, (_k, v) => typeof v === "bigint" ? v.toString() : v).replace(/'/g, "''");
|
|
766
|
+
return sql`${sql.raw(`'${escaped}'::jsonb`)}`;
|
|
767
|
+
}
|
|
768
|
+
function parseJsonb(value) {
|
|
769
|
+
if (typeof value === "string") {
|
|
770
|
+
try {
|
|
771
|
+
return JSON.parse(value);
|
|
772
|
+
} catch {
|
|
773
|
+
return value;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
return value ?? {};
|
|
777
|
+
}
|
|
718
778
|
// src/db/migration-role.ts
|
|
719
779
|
var currentRole = "both";
|
|
720
780
|
function setMigrationRole(role) {
|
|
@@ -787,6 +847,7 @@ var TABLE_TO_DB = {
|
|
|
787
847
|
subgraph_processing_stats: "target",
|
|
788
848
|
account_credits: "target",
|
|
789
849
|
archive_fetches: "target",
|
|
850
|
+
usage_ledger: "target",
|
|
790
851
|
waitlists: "target",
|
|
791
852
|
waitlist_signups: "target",
|
|
792
853
|
service_heartbeats: "both"
|
|
@@ -1098,12 +1159,58 @@ var CODE_TO_STATUS = {
|
|
|
1098
1159
|
function getErrorMessage(err) {
|
|
1099
1160
|
return err instanceof Error ? err.message : String(err);
|
|
1100
1161
|
}
|
|
1101
|
-
|
|
1162
|
+
// src/finality.ts
|
|
1163
|
+
var DEFAULT_BTC_CONFIRMATIONS = 6;
|
|
1164
|
+
function finalizedBurnHeight(burnTipHeight, confirmations = DEFAULT_BTC_CONFIRMATIONS) {
|
|
1165
|
+
if (!Number.isInteger(burnTipHeight) || burnTipHeight < 0) {
|
|
1166
|
+
throw new Error("burnTipHeight must be a non-negative integer");
|
|
1167
|
+
}
|
|
1168
|
+
if (!Number.isInteger(confirmations) || confirmations < 0) {
|
|
1169
|
+
throw new Error("confirmations must be a non-negative integer");
|
|
1170
|
+
}
|
|
1171
|
+
return Math.max(0, burnTipHeight - confirmations);
|
|
1172
|
+
}
|
|
1173
|
+
// src/streams-cursor.ts
|
|
1174
|
+
var EMPTY_RANGE_EVENT_INDEX_SENTINEL = 2147483647;
|
|
1175
|
+
function encodeStreamsCursor(cursor) {
|
|
1176
|
+
return `${cursor.block_height}:${cursor.event_index}`;
|
|
1177
|
+
}
|
|
1178
|
+
function decodeStreamsCursor(cursor) {
|
|
1179
|
+
const match = /^(0|[1-9]\d*):(0|[1-9]\d*)$/.exec(cursor);
|
|
1180
|
+
if (!match) {
|
|
1181
|
+
throw new Error("Invalid Streams cursor");
|
|
1182
|
+
}
|
|
1183
|
+
const decoded = {
|
|
1184
|
+
block_height: Number(match[1]),
|
|
1185
|
+
event_index: Number(match[2])
|
|
1186
|
+
};
|
|
1187
|
+
if (!Number.isSafeInteger(decoded.block_height) || !Number.isSafeInteger(decoded.event_index)) {
|
|
1188
|
+
throw new Error("Invalid Streams cursor");
|
|
1189
|
+
}
|
|
1190
|
+
return decoded;
|
|
1191
|
+
}
|
|
1192
|
+
function compareStreamsCursor(a, b) {
|
|
1193
|
+
if (a.block_height !== b.block_height) {
|
|
1194
|
+
return a.block_height < b.block_height ? -1 : 1;
|
|
1195
|
+
}
|
|
1196
|
+
if (a.event_index !== b.event_index) {
|
|
1197
|
+
return a.event_index < b.event_index ? -1 : 1;
|
|
1198
|
+
}
|
|
1199
|
+
return 0;
|
|
1200
|
+
}
|
|
1201
|
+
function isEmptyRangeCursor(cursor) {
|
|
1202
|
+
return cursor.event_index === EMPTY_RANGE_EVENT_INDEX_SENTINEL;
|
|
1203
|
+
}
|
|
1204
|
+
function blockEndCursor(height) {
|
|
1205
|
+
return {
|
|
1206
|
+
block_height: height,
|
|
1207
|
+
event_index: EMPTY_RANGE_EVENT_INDEX_SENTINEL
|
|
1208
|
+
};
|
|
1209
|
+
}
|
|
1102
1210
|
// src/schemas/subgraphs.ts
|
|
1103
1211
|
import { z as z2 } from "zod";
|
|
1104
1212
|
var DeploySubgraphRequestSchema = z2.object({
|
|
1105
1213
|
name: z2.string().regex(/^[a-z0-9-]+$/, "lowercase alphanumeric + hyphens only").max(63),
|
|
1106
|
-
version: z2.string().optional(),
|
|
1107
1214
|
description: z2.string().optional(),
|
|
1108
1215
|
sources: z2.record(z2.string(), z2.record(z2.string(), z2.unknown())).refine((s) => Object.keys(s).length > 0, "Must have at least one source"),
|
|
1109
1216
|
schema: z2.record(z2.string(), z2.unknown()),
|
|
@@ -1112,7 +1219,6 @@ var DeploySubgraphRequestSchema = z2.object({
|
|
|
1112
1219
|
sourceCode: z2.string().max(1048576, "source code exceeds 1MB limit").optional(),
|
|
1113
1220
|
dryRun: z2.boolean().optional()
|
|
1114
1221
|
});
|
|
1115
|
-
|
|
1116
1222
|
// src/schemas/webhooks.ts
|
|
1117
1223
|
import { z as z3 } from "zod";
|
|
1118
1224
|
var WEBHOOK_FORMATS = [
|
|
@@ -1130,6 +1236,47 @@ var WEBHOOK_RUNTIMES = [
|
|
|
1130
1236
|
"node"
|
|
1131
1237
|
];
|
|
1132
1238
|
var WEBHOOK_STATUSES = ["active", "paused", "error"];
|
|
1239
|
+
var WEBHOOK_MAX_RETRIES_CEILING_DEFAULT = 100;
|
|
1240
|
+
var WEBHOOK_TIMEOUT_MS_CEILING_DEFAULT = 300000;
|
|
1241
|
+
function ceilingFromEnv(envVar, fallback) {
|
|
1242
|
+
const raw = process.env[envVar];
|
|
1243
|
+
if (raw === undefined)
|
|
1244
|
+
return fallback;
|
|
1245
|
+
const parsed = Number.parseInt(raw, 10);
|
|
1246
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
|
|
1247
|
+
}
|
|
1248
|
+
function webhookMaxRetriesCeiling() {
|
|
1249
|
+
return ceilingFromEnv("WEBHOOK_MAX_RETRIES_CEILING", WEBHOOK_MAX_RETRIES_CEILING_DEFAULT);
|
|
1250
|
+
}
|
|
1251
|
+
function webhookTimeoutMsCeiling() {
|
|
1252
|
+
return ceilingFromEnv("WEBHOOK_TIMEOUT_MS_CEILING", WEBHOOK_TIMEOUT_MS_CEILING_DEFAULT);
|
|
1253
|
+
}
|
|
1254
|
+
function maxRetriesField() {
|
|
1255
|
+
return z3.number().int().min(0).optional().superRefine((v, ctx) => {
|
|
1256
|
+
if (v === undefined)
|
|
1257
|
+
return;
|
|
1258
|
+
const ceiling = webhookMaxRetriesCeiling();
|
|
1259
|
+
if (v > ceiling) {
|
|
1260
|
+
ctx.addIssue({
|
|
1261
|
+
code: "custom",
|
|
1262
|
+
message: `maxRetries exceeds ceiling (${ceiling})`
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
function timeoutMsField() {
|
|
1268
|
+
return z3.number().int().min(100).optional().superRefine((v, ctx) => {
|
|
1269
|
+
if (v === undefined)
|
|
1270
|
+
return;
|
|
1271
|
+
const ceiling = webhookTimeoutMsCeiling();
|
|
1272
|
+
if (v > ceiling) {
|
|
1273
|
+
ctx.addIssue({
|
|
1274
|
+
code: "custom",
|
|
1275
|
+
message: `timeoutMs exceeds ceiling (${ceiling})`
|
|
1276
|
+
});
|
|
1277
|
+
}
|
|
1278
|
+
});
|
|
1279
|
+
}
|
|
1133
1280
|
var WEBHOOK_FILTER_OPERATORS = [
|
|
1134
1281
|
"eq",
|
|
1135
1282
|
"neq",
|
|
@@ -1350,8 +1497,8 @@ var CreateWebhookRequestSchema = z3.object({
|
|
|
1350
1497
|
format: WebhookFormatSchema.default("standard-webhooks"),
|
|
1351
1498
|
runtime: WebhookRuntimeSchema.nullable().optional(),
|
|
1352
1499
|
authConfig: z3.record(z3.string(), z3.unknown()).optional(),
|
|
1353
|
-
maxRetries:
|
|
1354
|
-
timeoutMs:
|
|
1500
|
+
maxRetries: maxRetriesField(),
|
|
1501
|
+
timeoutMs: timeoutMsField(),
|
|
1355
1502
|
concurrency: z3.number().int().min(1).max(100).optional()
|
|
1356
1503
|
}).refine((v) => {
|
|
1357
1504
|
const subgraphMode = v.subgraphName !== undefined || v.tableName !== undefined;
|
|
@@ -1374,8 +1521,8 @@ var UpdateWebhookRequestSchema = z3.object({
|
|
|
1374
1521
|
format: WebhookFormatSchema.optional(),
|
|
1375
1522
|
runtime: WebhookRuntimeSchema.nullable().optional(),
|
|
1376
1523
|
authConfig: z3.record(z3.string(), z3.unknown()).optional(),
|
|
1377
|
-
maxRetries:
|
|
1378
|
-
timeoutMs:
|
|
1524
|
+
maxRetries: maxRetriesField(),
|
|
1525
|
+
timeoutMs: timeoutMsField(),
|
|
1379
1526
|
concurrency: z3.number().int().min(1).max(100).optional()
|
|
1380
1527
|
}).refine((value) => Object.keys(value).length > 0, {
|
|
1381
1528
|
message: "At least one field must be provided"
|
|
@@ -1517,24 +1664,19 @@ function validateWebhookFilterForTable(input) {
|
|
|
1517
1664
|
}
|
|
1518
1665
|
// src/subgraphs/spec.ts
|
|
1519
1666
|
var SYSTEM_COLUMNS = ["_id", "_block_height", "_tx_id", "_created_at"];
|
|
1520
|
-
var BASE_QUERY_PARAMS = ["_limit", "
|
|
1521
|
-
var PUBLIC_BASE_QUERY_PARAMS = ["_limit", "cursor", "_order", "_fields"];
|
|
1667
|
+
var BASE_QUERY_PARAMS = ["_limit", "cursor", "_order", "_fields"];
|
|
1522
1668
|
var COMPARISON_OPS = ["neq", "gt", "gte", "lt", "lte"];
|
|
1523
|
-
function isPublicRead(detail, options) {
|
|
1524
|
-
return options.forcePublicRead ?? detail.visibility === "public";
|
|
1525
|
-
}
|
|
1526
1669
|
function generatedAt(options) {
|
|
1527
1670
|
return options.generatedAt ?? new Date().toISOString();
|
|
1528
1671
|
}
|
|
1529
1672
|
function normalizeServerUrl(serverUrl) {
|
|
1530
1673
|
return (serverUrl ?? "http://127.0.0.1:3800").replace(/\/+$/, "");
|
|
1531
1674
|
}
|
|
1532
|
-
function tablePath(subgraphName, tableName
|
|
1533
|
-
|
|
1534
|
-
return `${base}/${subgraphName}/${tableName}`;
|
|
1675
|
+
function tablePath(subgraphName, tableName) {
|
|
1676
|
+
return `/v1/subgraphs/${subgraphName}/${tableName}`;
|
|
1535
1677
|
}
|
|
1536
|
-
function countPath(subgraphName, tableName
|
|
1537
|
-
return `${tablePath(subgraphName, tableName
|
|
1678
|
+
function countPath(subgraphName, tableName) {
|
|
1679
|
+
return `${tablePath(subgraphName, tableName)}/count`;
|
|
1538
1680
|
}
|
|
1539
1681
|
function isTextLike(type) {
|
|
1540
1682
|
return type === "text" || type === "principal" || type === "timestamp";
|
|
@@ -1601,50 +1743,50 @@ function columnEntries(table) {
|
|
|
1601
1743
|
return Object.entries(table.columns);
|
|
1602
1744
|
}
|
|
1603
1745
|
function selectableColumns(table) {
|
|
1604
|
-
return columnEntries(table).map(([
|
|
1746
|
+
return columnEntries(table).map(([name]) => name);
|
|
1605
1747
|
}
|
|
1606
1748
|
function searchableColumns(table) {
|
|
1607
|
-
return columnEntries(table).filter(([, col]) => col.searchable).map(([
|
|
1749
|
+
return columnEntries(table).filter(([, col]) => col.searchable).map(([name]) => name);
|
|
1608
1750
|
}
|
|
1609
1751
|
function filterNames(table) {
|
|
1610
1752
|
const result = [];
|
|
1611
|
-
for (const [
|
|
1612
|
-
result.push(
|
|
1613
|
-
result.push(`${
|
|
1753
|
+
for (const [name, col] of columnEntries(table)) {
|
|
1754
|
+
result.push(name);
|
|
1755
|
+
result.push(`${name}.neq`);
|
|
1614
1756
|
if (isComparable(col.type)) {
|
|
1615
|
-
for (const op of COMPARISON_OPS.filter((
|
|
1616
|
-
result.push(`${
|
|
1757
|
+
for (const op of COMPARISON_OPS.filter((op) => op !== "neq")) {
|
|
1758
|
+
result.push(`${name}.${op}`);
|
|
1617
1759
|
}
|
|
1618
1760
|
}
|
|
1619
1761
|
if (isTextLike(col.type))
|
|
1620
|
-
result.push(`${
|
|
1762
|
+
result.push(`${name}.like`);
|
|
1621
1763
|
}
|
|
1622
1764
|
return result;
|
|
1623
1765
|
}
|
|
1624
|
-
function queryParameters(table
|
|
1625
|
-
const params =
|
|
1766
|
+
function queryParameters(table) {
|
|
1767
|
+
const params = [...BASE_QUERY_PARAMS];
|
|
1626
1768
|
if (searchableColumns(table).length > 0)
|
|
1627
1769
|
params.push("_search");
|
|
1628
1770
|
return params;
|
|
1629
1771
|
}
|
|
1630
1772
|
function rowExample(table) {
|
|
1631
1773
|
const row = {};
|
|
1632
|
-
for (const [
|
|
1633
|
-
row[
|
|
1774
|
+
for (const [name, col] of columnEntries(table)) {
|
|
1775
|
+
row[name] = exampleForColumn(col.type);
|
|
1634
1776
|
}
|
|
1635
1777
|
return row;
|
|
1636
1778
|
}
|
|
1637
|
-
function openApiParameter(
|
|
1779
|
+
function openApiParameter(name, description, schema = { type: "string" }) {
|
|
1638
1780
|
return {
|
|
1639
|
-
name
|
|
1781
|
+
name,
|
|
1640
1782
|
in: "query",
|
|
1641
1783
|
required: false,
|
|
1642
1784
|
description,
|
|
1643
1785
|
schema
|
|
1644
1786
|
};
|
|
1645
1787
|
}
|
|
1646
|
-
function tableParameters(table
|
|
1647
|
-
const parameters =
|
|
1788
|
+
function tableParameters(table) {
|
|
1789
|
+
const parameters = [
|
|
1648
1790
|
openApiParameter("_limit", "Maximum rows to return.", {
|
|
1649
1791
|
type: "integer",
|
|
1650
1792
|
default: 50,
|
|
@@ -1660,52 +1802,28 @@ function tableParameters(table, publicRead) {
|
|
|
1660
1802
|
openApiParameter("_fields", "Comma-separated columns to include.", {
|
|
1661
1803
|
type: "string"
|
|
1662
1804
|
})
|
|
1663
|
-
] : [
|
|
1664
|
-
openApiParameter("_limit", "Maximum rows to return.", {
|
|
1665
|
-
type: "integer",
|
|
1666
|
-
default: 50,
|
|
1667
|
-
minimum: 1,
|
|
1668
|
-
maximum: 1000
|
|
1669
|
-
}),
|
|
1670
|
-
openApiParameter("_offset", "Rows to skip for pagination.", {
|
|
1671
|
-
type: "integer",
|
|
1672
|
-
default: 0,
|
|
1673
|
-
minimum: 0
|
|
1674
|
-
}),
|
|
1675
|
-
openApiParameter("_sort", "Column to sort by.", {
|
|
1676
|
-
type: "string",
|
|
1677
|
-
enum: selectableColumns(table)
|
|
1678
|
-
}),
|
|
1679
|
-
openApiParameter("_order", "Sort direction.", {
|
|
1680
|
-
type: "string",
|
|
1681
|
-
enum: ["asc", "desc"],
|
|
1682
|
-
default: "asc"
|
|
1683
|
-
}),
|
|
1684
|
-
openApiParameter("_fields", "Comma-separated columns to include.", {
|
|
1685
|
-
type: "string"
|
|
1686
|
-
})
|
|
1687
1805
|
];
|
|
1688
1806
|
if (searchableColumns(table).length > 0) {
|
|
1689
1807
|
parameters.push(openApiParameter("_search", "Search across searchable columns.", {
|
|
1690
1808
|
type: "string"
|
|
1691
1809
|
}));
|
|
1692
1810
|
}
|
|
1693
|
-
for (const [
|
|
1694
|
-
parameters.push(openApiParameter(
|
|
1811
|
+
for (const [name, col] of columnEntries(table)) {
|
|
1812
|
+
parameters.push(openApiParameter(name, `Filter ${name} by equality.`, {
|
|
1695
1813
|
type: "string"
|
|
1696
1814
|
}));
|
|
1697
|
-
parameters.push(openApiParameter(`${
|
|
1815
|
+
parameters.push(openApiParameter(`${name}.neq`, `Filter ${name} by inequality.`, {
|
|
1698
1816
|
type: "string"
|
|
1699
1817
|
}));
|
|
1700
1818
|
if (isComparable(col.type)) {
|
|
1701
1819
|
for (const op of ["gt", "gte", "lt", "lte"]) {
|
|
1702
|
-
parameters.push(openApiParameter(`${
|
|
1820
|
+
parameters.push(openApiParameter(`${name}.${op}`, `Filter ${name} with ${op}.`, {
|
|
1703
1821
|
type: "string"
|
|
1704
1822
|
}));
|
|
1705
1823
|
}
|
|
1706
1824
|
}
|
|
1707
1825
|
if (isTextLike(col.type)) {
|
|
1708
|
-
parameters.push(openApiParameter(`${
|
|
1826
|
+
parameters.push(openApiParameter(`${name}.like`, `Case-insensitive contains filter for ${name}.`, {
|
|
1709
1827
|
type: "string"
|
|
1710
1828
|
}));
|
|
1711
1829
|
}
|
|
@@ -1714,24 +1832,21 @@ function tableParameters(table, publicRead) {
|
|
|
1714
1832
|
}
|
|
1715
1833
|
function generateSubgraphAgentSchema(detail, options = {}) {
|
|
1716
1834
|
const serverUrl = normalizeServerUrl(options.serverUrl);
|
|
1717
|
-
const publicRead = isPublicRead(detail, options);
|
|
1718
1835
|
const tables = {};
|
|
1719
1836
|
for (const [tableName, table] of Object.entries(detail.tables)) {
|
|
1720
|
-
const path = tablePath(detail.name, tableName
|
|
1837
|
+
const path = tablePath(detail.name, tableName);
|
|
1721
1838
|
tables[tableName] = {
|
|
1722
1839
|
endpoint: `${serverUrl}${path}`,
|
|
1723
|
-
countEndpoint: `${serverUrl}${countPath(detail.name, tableName
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
streamEndpoint: `${serverUrl}${path}/stream`
|
|
1727
|
-
} : {},
|
|
1840
|
+
countEndpoint: `${serverUrl}${countPath(detail.name, tableName)}`,
|
|
1841
|
+
aggregateEndpoint: `${serverUrl}${path}/aggregate`,
|
|
1842
|
+
streamEndpoint: `${serverUrl}${path}/stream`,
|
|
1728
1843
|
rowCount: table.rowCount,
|
|
1729
1844
|
columns: table.columns,
|
|
1730
1845
|
...table.indexes ? { indexes: table.indexes } : {},
|
|
1731
1846
|
...table.uniqueKeys ? { uniqueKeys: table.uniqueKeys } : {},
|
|
1732
1847
|
query: {
|
|
1733
|
-
parameters: queryParameters(table
|
|
1734
|
-
sortable:
|
|
1848
|
+
parameters: queryParameters(table),
|
|
1849
|
+
sortable: [],
|
|
1735
1850
|
selectable: selectableColumns(table),
|
|
1736
1851
|
searchable: searchableColumns(table),
|
|
1737
1852
|
filters: filterNames(table)
|
|
@@ -1739,7 +1854,7 @@ function generateSubgraphAgentSchema(detail, options = {}) {
|
|
|
1739
1854
|
examples: {
|
|
1740
1855
|
list: rowExample(table),
|
|
1741
1856
|
count: { count: table.rowCount },
|
|
1742
|
-
curl:
|
|
1857
|
+
curl: `curl '${serverUrl}${path}?_limit=10&_order=desc'`
|
|
1743
1858
|
}
|
|
1744
1859
|
};
|
|
1745
1860
|
}
|
|
@@ -1756,7 +1871,6 @@ function generateSubgraphAgentSchema(detail, options = {}) {
|
|
|
1756
1871
|
}
|
|
1757
1872
|
function generateSubgraphOpenApi(detail, options = {}) {
|
|
1758
1873
|
const serverUrl = normalizeServerUrl(options.serverUrl);
|
|
1759
|
-
const publicRead = isPublicRead(detail, options);
|
|
1760
1874
|
const paths = {};
|
|
1761
1875
|
const schemas = {};
|
|
1762
1876
|
for (const [tableName, table] of Object.entries(detail.tables)) {
|
|
@@ -1774,7 +1888,7 @@ function generateSubgraphOpenApi(detail, options = {}) {
|
|
|
1774
1888
|
required,
|
|
1775
1889
|
example: rowExample(table)
|
|
1776
1890
|
};
|
|
1777
|
-
const responseSchema =
|
|
1891
|
+
const responseSchema = {
|
|
1778
1892
|
type: "object",
|
|
1779
1893
|
properties: {
|
|
1780
1894
|
rows: {
|
|
@@ -1791,28 +1905,12 @@ function generateSubgraphOpenApi(detail, options = {}) {
|
|
|
1791
1905
|
}
|
|
1792
1906
|
}
|
|
1793
1907
|
}
|
|
1794
|
-
} : {
|
|
1795
|
-
type: "object",
|
|
1796
|
-
properties: {
|
|
1797
|
-
data: {
|
|
1798
|
-
type: "array",
|
|
1799
|
-
items: { $ref: `#/components/schemas/${schemaName}` }
|
|
1800
|
-
},
|
|
1801
|
-
meta: {
|
|
1802
|
-
type: "object",
|
|
1803
|
-
properties: {
|
|
1804
|
-
total: { type: "integer" },
|
|
1805
|
-
limit: { type: "integer" },
|
|
1806
|
-
offset: { type: "integer" }
|
|
1807
|
-
}
|
|
1808
|
-
}
|
|
1809
|
-
}
|
|
1810
1908
|
};
|
|
1811
|
-
paths[tablePath(detail.name, tableName
|
|
1909
|
+
paths[tablePath(detail.name, tableName)] = {
|
|
1812
1910
|
get: {
|
|
1813
1911
|
summary: `Query ${detail.name}.${tableName}`,
|
|
1814
1912
|
operationId: `query_${detail.name.replace(/-/g, "_")}_${tableName}`,
|
|
1815
|
-
parameters: tableParameters(table
|
|
1913
|
+
parameters: tableParameters(table),
|
|
1816
1914
|
responses: {
|
|
1817
1915
|
"200": {
|
|
1818
1916
|
description: "Rows returned from the subgraph table.",
|
|
@@ -1825,11 +1923,11 @@ function generateSubgraphOpenApi(detail, options = {}) {
|
|
|
1825
1923
|
}
|
|
1826
1924
|
}
|
|
1827
1925
|
};
|
|
1828
|
-
paths[countPath(detail.name, tableName
|
|
1926
|
+
paths[countPath(detail.name, tableName)] = {
|
|
1829
1927
|
get: {
|
|
1830
1928
|
summary: `Count ${detail.name}.${tableName}`,
|
|
1831
1929
|
operationId: `count_${detail.name.replace(/-/g, "_")}_${tableName}`,
|
|
1832
|
-
parameters: tableParameters(table
|
|
1930
|
+
parameters: tableParameters(table),
|
|
1833
1931
|
responses: {
|
|
1834
1932
|
"200": {
|
|
1835
1933
|
description: "Row count for the filtered table query.",
|
|
@@ -1868,14 +1966,13 @@ function generateSubgraphOpenApi(detail, options = {}) {
|
|
|
1868
1966
|
}
|
|
1869
1967
|
function generateSubgraphMarkdown(detail, options = {}) {
|
|
1870
1968
|
const agent = generateSubgraphAgentSchema(detail, options);
|
|
1871
|
-
const publicRead = isPublicRead(detail, options);
|
|
1872
1969
|
const lines = [
|
|
1873
1970
|
`# ${detail.name} Subgraph API`,
|
|
1874
1971
|
"",
|
|
1875
1972
|
`Version: ${detail.version}`,
|
|
1876
1973
|
detail.schemaHash ? `Schema hash: ${detail.schemaHash}` : undefined,
|
|
1877
1974
|
`Server: ${agent.serverUrl}`,
|
|
1878
|
-
|
|
1975
|
+
"Responses use the `{ rows, next_cursor, tip }` envelope; paginate with `?cursor=<next_cursor>` and `_order=asc|desc` (`_offset` is rejected).",
|
|
1879
1976
|
"",
|
|
1880
1977
|
detail.description
|
|
1881
1978
|
].filter((line) => line !== undefined && line !== "");
|
|
@@ -1903,15 +2000,14 @@ function generateSubgraphSpec(detail, format, options = {}) {
|
|
|
1903
2000
|
return generateSubgraphAgentSchema(detail, options);
|
|
1904
2001
|
return generateSubgraphMarkdown(detail, options);
|
|
1905
2002
|
}
|
|
1906
|
-
|
|
1907
2003
|
// src/crypto/hmac.ts
|
|
1908
2004
|
var exports_hmac = {};
|
|
1909
2005
|
__export(exports_hmac, {
|
|
1910
|
-
|
|
1911
|
-
verifySignature: () => verifySignature,
|
|
1912
|
-
signPayload: () => signPayload,
|
|
2006
|
+
createSignatureHeader: () => createSignatureHeader,
|
|
1913
2007
|
generateSecret: () => generateSecret,
|
|
1914
|
-
|
|
2008
|
+
signPayload: () => signPayload,
|
|
2009
|
+
verifySignature: () => verifySignature,
|
|
2010
|
+
verifySignatureHeader: () => verifySignatureHeader
|
|
1915
2011
|
});
|
|
1916
2012
|
import { createHmac, randomBytes } from "node:crypto";
|
|
1917
2013
|
function generateSecret() {
|
|
@@ -1957,17 +2053,16 @@ function verifySignatureHeader(payload, header, secret, toleranceSeconds = 300)
|
|
|
1957
2053
|
const signedPayload = `${ts}.${payload}`;
|
|
1958
2054
|
return verifySignature(signedPayload, signature, secret);
|
|
1959
2055
|
}
|
|
1960
|
-
|
|
1961
2056
|
// src/crypto/ed25519.ts
|
|
1962
2057
|
var exports_ed25519 = {};
|
|
1963
2058
|
__export(exports_ed25519, {
|
|
1964
|
-
|
|
1965
|
-
signEd25519: () => signEd25519,
|
|
1966
|
-
publicKeyPemFromPrivate: () => publicKeyPemFromPrivate,
|
|
1967
|
-
loadEd25519PublicKey: () => loadEd25519PublicKey,
|
|
1968
|
-
loadEd25519PrivateKey: () => loadEd25519PrivateKey,
|
|
2059
|
+
ed25519KeyId: () => ed25519KeyId,
|
|
1969
2060
|
generateEd25519KeyPair: () => generateEd25519KeyPair,
|
|
1970
|
-
|
|
2061
|
+
loadEd25519PrivateKey: () => loadEd25519PrivateKey,
|
|
2062
|
+
loadEd25519PublicKey: () => loadEd25519PublicKey,
|
|
2063
|
+
publicKeyPemFromPrivate: () => publicKeyPemFromPrivate,
|
|
2064
|
+
signEd25519: () => signEd25519,
|
|
2065
|
+
verifyEd25519: () => verifyEd25519
|
|
1971
2066
|
});
|
|
1972
2067
|
import {
|
|
1973
2068
|
createHash,
|
|
@@ -2010,197 +2105,90 @@ function verifyEd25519(payload, signatureBase64, publicKey) {
|
|
|
2010
2105
|
return false;
|
|
2011
2106
|
}
|
|
2012
2107
|
}
|
|
2013
|
-
// src/event-types.ts
|
|
2014
|
-
import {
|
|
2015
|
-
DECODED_EVENT_TYPES
|
|
2016
|
-
} from "@secondlayer/stacks/filters";
|
|
2017
|
-
import {
|
|
2018
|
-
DECODED_EVENT_TYPES as DECODED_EVENT_TYPES2,
|
|
2019
|
-
VM_EVENT_TYPES,
|
|
2020
|
-
VM_NODE_TO_STORED_TYPE
|
|
2021
|
-
} from "@secondlayer/stacks/filters";
|
|
2022
|
-
var VM_STORED_TO_NODE_TYPE = {
|
|
2023
|
-
nested_contract_call: "contract_call_event",
|
|
2024
|
-
var_set: "var_set_event",
|
|
2025
|
-
map_set: "map_set_event",
|
|
2026
|
-
map_insert: "map_insert_event",
|
|
2027
|
-
map_delete: "map_delete_event"
|
|
2028
|
-
};
|
|
2029
|
-
var STREAMS_EVENT_TYPES = DECODED_EVENT_TYPES;
|
|
2030
|
-
// src/db-event-types.ts
|
|
2031
|
-
var STREAMS_DB_EVENT_TYPES = [
|
|
2032
|
-
"stx_transfer_event",
|
|
2033
|
-
"stx_mint_event",
|
|
2034
|
-
"stx_burn_event",
|
|
2035
|
-
"stx_lock_event",
|
|
2036
|
-
"ft_transfer_event",
|
|
2037
|
-
"ft_mint_event",
|
|
2038
|
-
"ft_burn_event",
|
|
2039
|
-
"nft_transfer_event",
|
|
2040
|
-
"nft_mint_event",
|
|
2041
|
-
"nft_burn_event",
|
|
2042
|
-
"smart_contract_event",
|
|
2043
|
-
"contract_event"
|
|
2044
|
-
];
|
|
2045
|
-
var DB_TO_STREAMS_EVENT_TYPE = {
|
|
2046
|
-
stx_transfer_event: "stx_transfer",
|
|
2047
|
-
stx_mint_event: "stx_mint",
|
|
2048
|
-
stx_burn_event: "stx_burn",
|
|
2049
|
-
stx_lock_event: "stx_lock",
|
|
2050
|
-
ft_transfer_event: "ft_transfer",
|
|
2051
|
-
ft_mint_event: "ft_mint",
|
|
2052
|
-
ft_burn_event: "ft_burn",
|
|
2053
|
-
nft_transfer_event: "nft_transfer",
|
|
2054
|
-
nft_mint_event: "nft_mint",
|
|
2055
|
-
nft_burn_event: "nft_burn",
|
|
2056
|
-
smart_contract_event: "print",
|
|
2057
|
-
contract_event: "print"
|
|
2058
|
-
};
|
|
2059
|
-
var STREAMS_TO_DB_EVENT_TYPES = {
|
|
2060
|
-
stx_transfer: ["stx_transfer_event"],
|
|
2061
|
-
stx_mint: ["stx_mint_event"],
|
|
2062
|
-
stx_burn: ["stx_burn_event"],
|
|
2063
|
-
stx_lock: ["stx_lock_event"],
|
|
2064
|
-
ft_transfer: ["ft_transfer_event"],
|
|
2065
|
-
ft_mint: ["ft_mint_event"],
|
|
2066
|
-
ft_burn: ["ft_burn_event"],
|
|
2067
|
-
nft_transfer: ["nft_transfer_event"],
|
|
2068
|
-
nft_mint: ["nft_mint_event"],
|
|
2069
|
-
nft_burn: ["nft_burn_event"],
|
|
2070
|
-
print: ["smart_contract_event", "contract_event"]
|
|
2071
|
-
};
|
|
2072
|
-
// src/finality.ts
|
|
2073
|
-
var DEFAULT_BTC_CONFIRMATIONS = 6;
|
|
2074
|
-
function finalizedBurnHeight(burnTipHeight, confirmations = DEFAULT_BTC_CONFIRMATIONS) {
|
|
2075
|
-
if (!Number.isInteger(burnTipHeight) || burnTipHeight < 0) {
|
|
2076
|
-
throw new Error("burnTipHeight must be a non-negative integer");
|
|
2077
|
-
}
|
|
2078
|
-
if (!Number.isInteger(confirmations) || confirmations < 0) {
|
|
2079
|
-
throw new Error("confirmations must be a non-negative integer");
|
|
2080
|
-
}
|
|
2081
|
-
return Math.max(0, burnTipHeight - confirmations);
|
|
2082
|
-
}
|
|
2083
|
-
// src/streams-cursor.ts
|
|
2084
|
-
var EMPTY_RANGE_EVENT_INDEX_SENTINEL = 2147483647;
|
|
2085
|
-
function encodeStreamsCursor(cursor) {
|
|
2086
|
-
return `${cursor.block_height}:${cursor.event_index}`;
|
|
2087
|
-
}
|
|
2088
|
-
function decodeStreamsCursor(cursor) {
|
|
2089
|
-
const match = /^(0|[1-9]\d*):(0|[1-9]\d*)$/.exec(cursor);
|
|
2090
|
-
if (!match) {
|
|
2091
|
-
throw new Error("Invalid Streams cursor");
|
|
2092
|
-
}
|
|
2093
|
-
const decoded = {
|
|
2094
|
-
block_height: Number(match[1]),
|
|
2095
|
-
event_index: Number(match[2])
|
|
2096
|
-
};
|
|
2097
|
-
if (!Number.isSafeInteger(decoded.block_height) || !Number.isSafeInteger(decoded.event_index)) {
|
|
2098
|
-
throw new Error("Invalid Streams cursor");
|
|
2099
|
-
}
|
|
2100
|
-
return decoded;
|
|
2101
|
-
}
|
|
2102
|
-
function compareStreamsCursor(a, b) {
|
|
2103
|
-
if (a.block_height !== b.block_height) {
|
|
2104
|
-
return a.block_height < b.block_height ? -1 : 1;
|
|
2105
|
-
}
|
|
2106
|
-
if (a.event_index !== b.event_index) {
|
|
2107
|
-
return a.event_index < b.event_index ? -1 : 1;
|
|
2108
|
-
}
|
|
2109
|
-
return 0;
|
|
2110
|
-
}
|
|
2111
|
-
function isEmptyRangeCursor(cursor) {
|
|
2112
|
-
return cursor.event_index === EMPTY_RANGE_EVENT_INDEX_SENTINEL;
|
|
2113
|
-
}
|
|
2114
|
-
function blockEndCursor(height) {
|
|
2115
|
-
return {
|
|
2116
|
-
block_height: height,
|
|
2117
|
-
event_index: EMPTY_RANGE_EVENT_INDEX_SENTINEL
|
|
2118
|
-
};
|
|
2119
|
-
}
|
|
2120
2108
|
export {
|
|
2121
|
-
|
|
2122
|
-
sql2 as sql,
|
|
2123
|
-
setMigrationRole,
|
|
2124
|
-
parseJsonb,
|
|
2125
|
-
onControlPlane,
|
|
2126
|
-
onChainPlane,
|
|
2127
|
-
logger,
|
|
2128
|
-
jsonb,
|
|
2129
|
-
isSbtcDecoderEnabled,
|
|
2130
|
-
isPox5DecoderEnabled,
|
|
2131
|
-
isPox4DecoderEnabled,
|
|
2132
|
-
isEmptyRangeCursor,
|
|
2133
|
-
isBnsDecoderEnabled,
|
|
2134
|
-
getTargetDb,
|
|
2135
|
-
getSourceDb,
|
|
2136
|
-
getRawClientFor,
|
|
2137
|
-
getRawClient,
|
|
2138
|
-
getMigrationRole,
|
|
2139
|
-
getErrorMessage,
|
|
2140
|
-
getEnv,
|
|
2141
|
-
getDbSplitStatus,
|
|
2142
|
-
getDb,
|
|
2143
|
-
generateSubgraphSpec,
|
|
2144
|
-
generateSubgraphOpenApi,
|
|
2145
|
-
generateSubgraphMarkdown,
|
|
2146
|
-
generateSubgraphAgentSchema,
|
|
2147
|
-
formatWebhookSchemaErrors,
|
|
2148
|
-
finalizedBurnHeight,
|
|
2149
|
-
encodeStreamsCursor,
|
|
2150
|
-
exports_ed25519 as ed25519,
|
|
2151
|
-
decodeStreamsCursor,
|
|
2152
|
-
exports_hmac as crypto,
|
|
2153
|
-
compareStreamsCursor,
|
|
2154
|
-
closeDb,
|
|
2155
|
-
blockEndCursor,
|
|
2156
|
-
assertDbSplit,
|
|
2157
|
-
applicationDatabaseUrl,
|
|
2158
|
-
WebhookStatusSchema,
|
|
2159
|
-
WebhookRuntimeSchema,
|
|
2160
|
-
WebhookFormatSchema,
|
|
2161
|
-
WebhookFilterSchema,
|
|
2162
|
-
WebhookFilterPrimitiveSchema,
|
|
2163
|
-
WebhookFilterOperatorSchema,
|
|
2164
|
-
WebhookFilterClauseSchema,
|
|
2165
|
-
WEBHOOK_STATUSES,
|
|
2166
|
-
WEBHOOK_RUNTIMES,
|
|
2167
|
-
WEBHOOK_FORMATS,
|
|
2168
|
-
WEBHOOK_FILTER_OPERATORS,
|
|
2169
|
-
VersionConflictError,
|
|
2170
|
-
ValidationError,
|
|
2171
|
-
VM_STORED_TO_NODE_TYPE,
|
|
2172
|
-
VM_NODE_TO_STORED_TYPE,
|
|
2173
|
-
VM_EVENT_TYPES,
|
|
2174
|
-
UpdateWebhookRequestSchema,
|
|
2175
|
-
TenantSuspendedError,
|
|
2176
|
-
TABLE_TO_DB,
|
|
2177
|
-
SecondLayerError,
|
|
2178
|
-
STREAMS_TO_DB_EVENT_TYPES,
|
|
2179
|
-
STREAMS_EVENT_TYPES,
|
|
2180
|
-
STREAMS_DB_EVENT_TYPES,
|
|
2181
|
-
SOURCE_READ_TYPES,
|
|
2182
|
-
SOURCE_READ_PKS,
|
|
2183
|
-
SOURCE_READ_COLUMNS,
|
|
2184
|
-
ReplayWebhookRequestSchema,
|
|
2185
|
-
RateLimitError,
|
|
2186
|
-
PaymentRequiredError,
|
|
2187
|
-
NotFoundError,
|
|
2188
|
-
KeyRotatedError,
|
|
2189
|
-
ForbiddenError,
|
|
2190
|
-
ErrorCodes,
|
|
2191
|
-
EMPTY_RANGE_EVENT_INDEX_SENTINEL,
|
|
2192
|
-
DeploySubgraphRequestSchema,
|
|
2193
|
-
DatabaseError,
|
|
2194
|
-
DEFAULT_BTC_CONFIRMATIONS,
|
|
2195
|
-
DECODED_EVENT_TYPES2 as DECODED_EVENT_TYPES,
|
|
2196
|
-
DB_TO_STREAMS_EVENT_TYPE,
|
|
2197
|
-
CreateWebhookRequestSchema,
|
|
2198
|
-
CODE_TO_STATUS,
|
|
2199
|
-
CHAIN_TRIGGER_TYPES,
|
|
2200
|
-
CHAIN_TRIGGER_FIELDS,
|
|
2109
|
+
AuthenticationError,
|
|
2201
2110
|
AuthorizationError,
|
|
2202
|
-
|
|
2111
|
+
CHAIN_TRIGGER_FIELDS,
|
|
2112
|
+
CHAIN_TRIGGER_TYPES,
|
|
2113
|
+
CODE_TO_STATUS,
|
|
2114
|
+
CreateWebhookRequestSchema,
|
|
2115
|
+
DB_TO_STREAMS_EVENT_TYPE,
|
|
2116
|
+
DECODED_EVENT_TYPES2 as DECODED_EVENT_TYPES,
|
|
2117
|
+
DEFAULT_BTC_CONFIRMATIONS,
|
|
2118
|
+
DatabaseError,
|
|
2119
|
+
DeploySubgraphRequestSchema,
|
|
2120
|
+
EMPTY_RANGE_EVENT_INDEX_SENTINEL,
|
|
2121
|
+
ErrorCodes,
|
|
2122
|
+
ForbiddenError,
|
|
2123
|
+
KeyRotatedError,
|
|
2124
|
+
NotFoundError,
|
|
2125
|
+
PaymentRequiredError,
|
|
2126
|
+
RateLimitError,
|
|
2127
|
+
ReplayWebhookRequestSchema,
|
|
2128
|
+
SOURCE_READ_COLUMNS,
|
|
2129
|
+
SOURCE_READ_PKS,
|
|
2130
|
+
SOURCE_READ_TYPES,
|
|
2131
|
+
STREAMS_DB_EVENT_TYPES,
|
|
2132
|
+
STREAMS_EVENT_TYPES,
|
|
2133
|
+
STREAMS_TO_DB_EVENT_TYPES,
|
|
2134
|
+
SecondLayerError,
|
|
2135
|
+
TABLE_TO_DB,
|
|
2136
|
+
TenantSuspendedError,
|
|
2137
|
+
UpdateWebhookRequestSchema,
|
|
2138
|
+
VM_EVENT_TYPES,
|
|
2139
|
+
VM_NODE_TO_STORED_TYPE,
|
|
2140
|
+
VM_STORED_TO_NODE_TYPE,
|
|
2141
|
+
ValidationError,
|
|
2142
|
+
VersionConflictError,
|
|
2143
|
+
WEBHOOK_FILTER_OPERATORS,
|
|
2144
|
+
WEBHOOK_FORMATS,
|
|
2145
|
+
WEBHOOK_RUNTIMES,
|
|
2146
|
+
WEBHOOK_STATUSES,
|
|
2147
|
+
WebhookFilterClauseSchema,
|
|
2148
|
+
WebhookFilterOperatorSchema,
|
|
2149
|
+
WebhookFilterPrimitiveSchema,
|
|
2150
|
+
WebhookFilterSchema,
|
|
2151
|
+
WebhookFormatSchema,
|
|
2152
|
+
WebhookRuntimeSchema,
|
|
2153
|
+
WebhookStatusSchema,
|
|
2154
|
+
applicationDatabaseUrl,
|
|
2155
|
+
assertDbSplit,
|
|
2156
|
+
blockEndCursor,
|
|
2157
|
+
closeDb,
|
|
2158
|
+
compareStreamsCursor,
|
|
2159
|
+
exports_hmac as crypto,
|
|
2160
|
+
decodeStreamsCursor,
|
|
2161
|
+
exports_ed25519 as ed25519,
|
|
2162
|
+
encodeStreamsCursor,
|
|
2163
|
+
finalizedBurnHeight,
|
|
2164
|
+
formatWebhookSchemaErrors,
|
|
2165
|
+
generateSubgraphAgentSchema,
|
|
2166
|
+
generateSubgraphMarkdown,
|
|
2167
|
+
generateSubgraphOpenApi,
|
|
2168
|
+
generateSubgraphSpec,
|
|
2169
|
+
getDb,
|
|
2170
|
+
getDbSplitStatus,
|
|
2171
|
+
getEnv,
|
|
2172
|
+
getErrorMessage,
|
|
2173
|
+
getMigrationRole,
|
|
2174
|
+
getRawClient,
|
|
2175
|
+
getRawClientFor,
|
|
2176
|
+
getSourceDb,
|
|
2177
|
+
getTargetDb,
|
|
2178
|
+
isBnsDecoderEnabled,
|
|
2179
|
+
isEmptyRangeCursor,
|
|
2180
|
+
isPox4DecoderEnabled,
|
|
2181
|
+
isPox5DecoderEnabled,
|
|
2182
|
+
isSbtcDecoderEnabled,
|
|
2183
|
+
jsonb,
|
|
2184
|
+
logger,
|
|
2185
|
+
onChainPlane,
|
|
2186
|
+
onControlPlane,
|
|
2187
|
+
parseJsonb,
|
|
2188
|
+
setMigrationRole,
|
|
2189
|
+
sql2 as sql,
|
|
2190
|
+
validateWebhookFilterForTable
|
|
2203
2191
|
};
|
|
2204
2192
|
|
|
2205
|
-
//# debugId=
|
|
2193
|
+
//# debugId=615FC1FF75B4DD1364756E2164756E21
|
|
2206
2194
|
//# sourceMappingURL=index.js.map
|