@secondlayer/shared 4.0.1 → 4.1.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/db/index.js +130 -2
- package/dist/src/db/index.js.map +6 -4
- package/dist/src/index.d.ts +142 -1
- package/dist/src/index.js +283 -117
- package/dist/src/index.js.map +7 -6
- package/dist/src/schemas/index.d.ts +142 -1
- package/dist/src/schemas/index.js +154 -1
- package/dist/src/schemas/index.js.map +5 -4
- package/dist/src/schemas/subscriptions.d.ts +142 -0
- package/dist/src/schemas/subscriptions.js +173 -0
- package/dist/src/schemas/subscriptions.js.map +10 -0
- package/package.json +5 -1
package/dist/src/db/index.js
CHANGED
|
@@ -14,6 +14,121 @@ var __export = (target, all) => {
|
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
// src/env.ts
|
|
18
|
+
import { z } from "zod/v4";
|
|
19
|
+
var networksSchema = z.string().transform((val) => {
|
|
20
|
+
const networks = val.split(",").map((n) => n.trim()).filter(Boolean);
|
|
21
|
+
const valid = ["mainnet", "testnet"];
|
|
22
|
+
for (const n of networks) {
|
|
23
|
+
if (!valid.includes(n)) {
|
|
24
|
+
throw new Error(`Invalid network: ${n}. Must be one of: ${valid.join(", ")}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return networks;
|
|
28
|
+
});
|
|
29
|
+
var envSchema = z.object({
|
|
30
|
+
DATABASE_URL: z.preprocess((val) => typeof val === "string" && val.length === 0 ? undefined : val, z.string().url().optional()),
|
|
31
|
+
SOURCE_DATABASE_URL: z.preprocess((val) => typeof val === "string" && val.length === 0 ? undefined : val, z.string().url().optional()),
|
|
32
|
+
TARGET_DATABASE_URL: z.preprocess((val) => typeof val === "string" && val.length === 0 ? undefined : val, z.string().url().optional()),
|
|
33
|
+
NETWORK: z.enum(["mainnet", "testnet"]).optional(),
|
|
34
|
+
NETWORKS: networksSchema.optional(),
|
|
35
|
+
LOG_LEVEL: z.enum(["debug", "info", "warn", "error"]).default("info"),
|
|
36
|
+
NODE_ENV: z.enum(["development", "production", "test"]).default("development")
|
|
37
|
+
});
|
|
38
|
+
var cachedEnv = null;
|
|
39
|
+
function getEnv() {
|
|
40
|
+
if (cachedEnv) {
|
|
41
|
+
return cachedEnv;
|
|
42
|
+
}
|
|
43
|
+
const result = envSchema.safeParse(process.env);
|
|
44
|
+
if (!result.success) {
|
|
45
|
+
console.error("❌ Invalid environment configuration:");
|
|
46
|
+
console.error(z.treeifyError(result.error));
|
|
47
|
+
throw new Error("Invalid environment configuration");
|
|
48
|
+
}
|
|
49
|
+
let enabledNetworks;
|
|
50
|
+
if (result.data.NETWORKS && result.data.NETWORKS.length > 0) {
|
|
51
|
+
enabledNetworks = result.data.NETWORKS;
|
|
52
|
+
} else if (result.data.NETWORK) {
|
|
53
|
+
enabledNetworks = [result.data.NETWORK];
|
|
54
|
+
} else {
|
|
55
|
+
enabledNetworks = ["mainnet"];
|
|
56
|
+
}
|
|
57
|
+
cachedEnv = { ...result.data, enabledNetworks };
|
|
58
|
+
return cachedEnv;
|
|
59
|
+
}
|
|
60
|
+
// src/logger.ts
|
|
61
|
+
var LOG_LEVELS = {
|
|
62
|
+
debug: 0,
|
|
63
|
+
info: 1,
|
|
64
|
+
warn: 2,
|
|
65
|
+
error: 3
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
class Logger {
|
|
69
|
+
_level;
|
|
70
|
+
_isProduction;
|
|
71
|
+
_initialized = false;
|
|
72
|
+
init() {
|
|
73
|
+
if (this._initialized)
|
|
74
|
+
return;
|
|
75
|
+
this._initialized = true;
|
|
76
|
+
try {
|
|
77
|
+
const env = getEnv();
|
|
78
|
+
this._level = env.LOG_LEVEL;
|
|
79
|
+
this._isProduction = env.NODE_ENV === "production";
|
|
80
|
+
} catch {
|
|
81
|
+
this._level = "info";
|
|
82
|
+
this._isProduction = false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
get level() {
|
|
86
|
+
this.init();
|
|
87
|
+
return this._level;
|
|
88
|
+
}
|
|
89
|
+
get isProduction() {
|
|
90
|
+
this.init();
|
|
91
|
+
return this._isProduction;
|
|
92
|
+
}
|
|
93
|
+
shouldLog(level) {
|
|
94
|
+
return LOG_LEVELS[level] >= LOG_LEVELS[this.level];
|
|
95
|
+
}
|
|
96
|
+
formatMessage(level, message, meta) {
|
|
97
|
+
const timestamp = new Date().toISOString();
|
|
98
|
+
if (this.isProduction) {
|
|
99
|
+
return JSON.stringify({
|
|
100
|
+
timestamp,
|
|
101
|
+
level,
|
|
102
|
+
message,
|
|
103
|
+
...meta
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const metaStr = meta ? ` ${JSON.stringify(meta)}` : "";
|
|
107
|
+
return `[${timestamp}] ${level.toUpperCase()}: ${message}${metaStr}`;
|
|
108
|
+
}
|
|
109
|
+
debug(message, meta) {
|
|
110
|
+
if (this.shouldLog("debug")) {
|
|
111
|
+
console.debug(this.formatMessage("debug", message, meta));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
info(message, meta) {
|
|
115
|
+
if (this.shouldLog("info")) {
|
|
116
|
+
console.info(this.formatMessage("info", message, meta));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
warn(message, meta) {
|
|
120
|
+
if (this.shouldLog("warn")) {
|
|
121
|
+
console.warn(this.formatMessage("warn", message, meta));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
error(message, meta) {
|
|
125
|
+
if (this.shouldLog("error")) {
|
|
126
|
+
console.error(this.formatMessage("error", message, meta));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
var logger = new Logger;
|
|
131
|
+
|
|
17
132
|
// src/db/jsonb.ts
|
|
18
133
|
import { sql } from "kysely";
|
|
19
134
|
function jsonb(value) {
|
|
@@ -64,7 +179,20 @@ function getOrCreatePool(url) {
|
|
|
64
179
|
}
|
|
65
180
|
});
|
|
66
181
|
const db = new Kysely({
|
|
67
|
-
dialect: new PostgresJSDialect({ postgres: rawClient })
|
|
182
|
+
dialect: new PostgresJSDialect({ postgres: rawClient }),
|
|
183
|
+
log: (event) => {
|
|
184
|
+
if (event.level !== "error")
|
|
185
|
+
return;
|
|
186
|
+
const err = event.error;
|
|
187
|
+
if (err?.code !== "42P10")
|
|
188
|
+
return;
|
|
189
|
+
logger.warn("db.on_conflict_constraint_missing", {
|
|
190
|
+
code: err.code,
|
|
191
|
+
message: err.message,
|
|
192
|
+
sql: event.query.sql,
|
|
193
|
+
params: event.query.parameters
|
|
194
|
+
});
|
|
195
|
+
}
|
|
68
196
|
});
|
|
69
197
|
const entry = { db, rawClient };
|
|
70
198
|
pools.set(url, entry);
|
|
@@ -103,5 +231,5 @@ export {
|
|
|
103
231
|
closeDb
|
|
104
232
|
};
|
|
105
233
|
|
|
106
|
-
//# debugId=
|
|
234
|
+
//# debugId=83F7FBE5F90E372264756E2164756E21
|
|
107
235
|
//# sourceMappingURL=index.js.map
|
package/dist/src/db/index.js.map
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/db/jsonb.ts", "../src/db/index.ts"],
|
|
3
|
+
"sources": ["../src/env.ts", "../src/logger.ts", "../src/db/jsonb.ts", "../src/db/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
+
"import { z } from \"zod/v4\";\n\n// Parse comma-separated networks\nconst networksSchema = z.string().transform((val) => {\n\tconst networks = val\n\t\t.split(\",\")\n\t\t.map((n) => n.trim())\n\t\t.filter(Boolean);\n\tconst valid = [\"mainnet\", \"testnet\"];\n\tfor (const n of networks) {\n\t\tif (!valid.includes(n)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid network: ${n}. Must be one of: ${valid.join(\", \")}`,\n\t\t\t);\n\t\t}\n\t}\n\treturn networks as (\"mainnet\" | \"testnet\")[];\n});\n\ninterface EnvSchemaOutput {\n\tDATABASE_URL?: string;\n\t/**\n\t * Shared indexer DB (blocks/txs/events). Falls back to DATABASE_URL.\n\t * Set this alongside TARGET_DATABASE_URL to enable dual-DB mode.\n\t */\n\tSOURCE_DATABASE_URL?: string;\n\t/**\n\t * Tenant DB (subgraph schemas + subgraphs table). Falls back to DATABASE_URL.\n\t * Set this alongside SOURCE_DATABASE_URL to enable dual-DB mode.\n\t */\n\tTARGET_DATABASE_URL?: string;\n\tNETWORK?: \"mainnet\" | \"testnet\";\n\tNETWORKS?: (\"mainnet\" | \"testnet\")[];\n\tLOG_LEVEL: \"debug\" | \"info\" | \"warn\" | \"error\";\n\tNODE_ENV: \"development\" | \"production\" | \"test\";\n}\n\n// Cast needed: z.preprocess / z.default create different _input vs _output types\n// that z.ZodType<T> can't represent without explicit input type param\nconst envSchema: z.ZodType<EnvSchemaOutput> = z.object({\n\tDATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tSOURCE_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tTARGET_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tNETWORK: z.enum([\"mainnet\", \"testnet\"]).optional(),\n\tNETWORKS: networksSchema.optional(),\n\tLOG_LEVEL: z.enum([\"debug\", \"info\", \"warn\", \"error\"]).default(\"info\"),\n\tNODE_ENV: z\n\t\t.enum([\"development\", \"production\", \"test\"])\n\t\t.default(\"development\"),\n}) as unknown as z.ZodType<EnvSchemaOutput>;\n\nexport type Env = EnvSchemaOutput & {\n\tenabledNetworks: (\"mainnet\" | \"testnet\")[];\n};\n\nlet cachedEnv: Env | null = null;\n\nexport function getEnv(): Env {\n\tif (cachedEnv) {\n\t\treturn cachedEnv;\n\t}\n\n\tconst result = envSchema.safeParse(process.env);\n\n\tif (!result.success) {\n\t\tconsole.error(\"❌ Invalid environment configuration:\");\n\t\tconsole.error(z.treeifyError(result.error));\n\t\tthrow new Error(\"Invalid environment configuration\");\n\t}\n\n\t// Compute enabled networks from NETWORKS or NETWORK\n\tlet enabledNetworks: (\"mainnet\" | \"testnet\")[];\n\tif (result.data.NETWORKS && result.data.NETWORKS.length > 0) {\n\t\tenabledNetworks = result.data.NETWORKS;\n\t} else if (result.data.NETWORK) {\n\t\tenabledNetworks = [result.data.NETWORK];\n\t} else {\n\t\tenabledNetworks = [\"mainnet\"]; // Default\n\t}\n\n\tcachedEnv = { ...result.data, enabledNetworks };\n\treturn cachedEnv;\n}\n\n// Export for testing\nexport { envSchema };\n",
|
|
6
|
+
"import { getEnv } from \"./env.ts\";\n\ntype LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\nconst LOG_LEVELS: Record<LogLevel, number> = {\n\tdebug: 0,\n\tinfo: 1,\n\twarn: 2,\n\terror: 3,\n};\n\nclass Logger {\n\tprivate _level?: LogLevel;\n\tprivate _isProduction?: boolean;\n\tprivate _initialized = false;\n\n\tprivate init() {\n\t\tif (this._initialized) return;\n\t\tthis._initialized = true;\n\t\ttry {\n\t\t\tconst env = getEnv();\n\t\t\tthis._level = env.LOG_LEVEL;\n\t\t\tthis._isProduction = env.NODE_ENV === \"production\";\n\t\t} catch {\n\t\t\t// Fallback when env is unavailable (e.g. tests without DATABASE_URL)\n\t\t\tthis._level = \"info\";\n\t\t\tthis._isProduction = false;\n\t\t}\n\t}\n\n\tprivate get level(): LogLevel {\n\t\tthis.init();\n\t\treturn this._level!;\n\t}\n\n\tprivate get isProduction(): boolean {\n\t\tthis.init();\n\t\treturn this._isProduction!;\n\t}\n\n\tprivate shouldLog(level: LogLevel): boolean {\n\t\treturn LOG_LEVELS[level] >= LOG_LEVELS[this.level];\n\t}\n\n\tprivate formatMessage(\n\t\tlevel: LogLevel,\n\t\tmessage: string,\n\t\tmeta?: Record<string, any>,\n\t) {\n\t\tconst timestamp = new Date().toISOString();\n\n\t\tif (this.isProduction) {\n\t\t\t// JSON output for production\n\t\t\treturn JSON.stringify({\n\t\t\t\ttimestamp,\n\t\t\t\tlevel,\n\t\t\t\tmessage,\n\t\t\t\t...meta,\n\t\t\t});\n\t\t}\n\n\t\t// Human-readable output for development\n\t\tconst metaStr = meta ? ` ${JSON.stringify(meta)}` : \"\";\n\t\treturn `[${timestamp}] ${level.toUpperCase()}: ${message}${metaStr}`;\n\t}\n\n\tdebug(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"debug\")) {\n\t\t\tconsole.debug(this.formatMessage(\"debug\", message, meta));\n\t\t}\n\t}\n\n\tinfo(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"info\")) {\n\t\t\tconsole.info(this.formatMessage(\"info\", message, meta));\n\t\t}\n\t}\n\n\twarn(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"warn\")) {\n\t\t\tconsole.warn(this.formatMessage(\"warn\", message, meta));\n\t\t}\n\t}\n\n\terror(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"error\")) {\n\t\t\tconsole.error(this.formatMessage(\"error\", message, meta));\n\t\t}\n\t}\n}\n\n// Export singleton instance\nexport const logger: Logger = new Logger();\n",
|
|
5
7
|
"import { type RawBuilder, sql } from \"kysely\";\n\n/**\n * Safely encode a JS value as a JSONB literal for Kysely inserts/updates.\n * Kysely + postgres.js double-encodes JSON when using parameterized queries\n * with ::jsonb casts. This uses sql.raw to inline a properly escaped literal.\n *\n * Generic parameter lets callers set the RawBuilder's output type so they\n * don't need to cast at the insert site. Default is `unknown` — widen at\n * the call site when the column type is narrower, e.g. `jsonb<MyShape>(...)`.\n */\nexport function jsonb<T = unknown>(value: T): RawBuilder<T> {\n\tconst escaped = JSON.stringify(value, (_k, v) =>\n\t\ttypeof v === \"bigint\" ? v.toString() : v,\n\t).replace(/'/g, \"''\");\n\treturn sql`${sql.raw(`'${escaped}'::jsonb`)}`;\n}\n\n/**\n * Safely parse a JSONB value from the database.\n * Handles double-encoded strings where postgres.js returns a JSON string\n * instead of a parsed object.\n */\nexport function parseJsonb<T = unknown>(value: unknown): T {\n\tif (typeof value === \"string\") {\n\t\ttry {\n\t\t\treturn JSON.parse(value) as T;\n\t\t} catch {\n\t\t\treturn value as T;\n\t\t}\n\t}\n\treturn (value ?? {}) as T;\n}\n",
|
|
6
|
-
"import { Kysely } from \"kysely\";\nimport { PostgresJSDialect } from \"kysely-postgres-js\";\nimport postgres from \"postgres\";\nimport type { Database } from \"./types.ts\";\n\nconst DEFAULT_URL =\n\t\"postgres://postgres:postgres@localhost:5432/secondlayer_dev\";\n\ninterface PoolEntry {\n\tdb: Kysely<Database>;\n\trawClient: ReturnType<typeof postgres>;\n}\n\n/**\n * Cache of Kysely + raw postgres.js pools keyed by resolved URL.\n * Two getters resolving to the same URL share one entry (single pool) —\n * this is the single-DB backward-compat contract: when only `DATABASE_URL`\n * is set, `getSourceDb() === getTargetDb()` (zero regression vs. pre-dual-DB).\n */\nconst pools = new Map<string, PoolEntry>();\n\nfunction resolveSourceUrl(): string {\n\treturn (\n\t\tprocess.env.SOURCE_DATABASE_URL || process.env.DATABASE_URL || DEFAULT_URL\n\t);\n}\n\nfunction resolveTargetUrl(): string {\n\treturn (\n\t\tprocess.env.TARGET_DATABASE_URL || process.env.DATABASE_URL || DEFAULT_URL\n\t);\n}\n\nfunction getOrCreatePool(url: string): PoolEntry {\n\tconst existing = pools.get(url);\n\tif (existing) return existing;\n\n\t// \"Local\" = we skip TLS. Any Docker service alias (single-label hostname\n\t// with no dots) is on an internal network and won't serve TLS.\n\tconst host = (() => {\n\t\ttry {\n\t\t\treturn new URL(url).hostname;\n\t\t} catch {\n\t\t\treturn \"\";\n\t\t}\n\t})();\n\tconst isLocal =\n\t\thost === \"localhost\" || host === \"127.0.0.1\" || !host.includes(\".\");\n\tconst poolMax = Number.parseInt(process.env.DATABASE_POOL_MAX ?? \"20\", 10);\n\tconst rawClient = postgres(url, {\n\t\tmax: poolMax,\n\t\tssl: isLocal\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\trejectUnauthorized: process.env.NODE_TLS_REJECT_UNAUTHORIZED !== \"0\",\n\t\t\t\t},\n\t});\n\tconst db = new Kysely<Database>({\n\t\tdialect: new PostgresJSDialect({ postgres: rawClient }),\n\t});\n\tconst entry: PoolEntry = { db, rawClient };\n\tpools.set(url, entry);\n\treturn entry;\n}\n\n/**\n * Kysely instance for the SOURCE DB (block/tx/event reads from the shared\n * indexer). Resolution: `SOURCE_DATABASE_URL || DATABASE_URL`.\n */\nexport function getSourceDb(): Kysely<Database> {\n\treturn getOrCreatePool(resolveSourceUrl()).db;\n}\n\n/**\n * Kysely instance for the TARGET DB (subgraph schemas, subgraphs table,\n * account-scoped data — tenant-side writes). Resolution:\n * `TARGET_DATABASE_URL || DATABASE_URL`.\n */\nexport function getTargetDb(): Kysely<Database> {\n\treturn getOrCreatePool(resolveTargetUrl()).db;\n}\n\n/**\n * Backward-compat alias for `getTargetDb()`. Accepts an optional\n * `connectionString` override used by seed/test helpers — when supplied,\n * bypasses env resolution and uses the provided URL directly (still cached).\n */\nexport function getDb(connectionString?: string): Kysely<Database> {\n\tif (connectionString) return getOrCreatePool(connectionString).db;\n\treturn getTargetDb();\n}\n\n/**\n * Raw postgres.js client for dynamic schema DDL (CREATE SCHEMA, DROP, etc.).\n * Defaults to the target role (tenant schemas live in the target DB).\n */\nexport function getRawClient(\n\trole: \"source\" | \"target\" = \"target\",\n): ReturnType<typeof postgres> {\n\tconst url = role === \"source\" ? resolveSourceUrl() : resolveTargetUrl();\n\treturn getOrCreatePool(url).rawClient;\n}\n\n/** Close all DB connection pools. Call in CLI commands to allow process exit. */\nexport async function closeDb(): Promise<void> {\n\tfor (const entry of pools.values()) {\n\t\tawait entry.db.destroy();\n\t\tawait entry.rawClient.end();\n\t}\n\tpools.clear();\n}\n\nimport { sql } from \"kysely\";\nexport { sql };\nexport * from \"./types.ts\";\nexport { jsonb, parseJsonb } from \"./jsonb.ts\";\n"
|
|
8
|
+
"import { Kysely } from \"kysely\";\nimport { PostgresJSDialect } from \"kysely-postgres-js\";\nimport postgres from \"postgres\";\nimport { logger } from \"../logger.ts\";\nimport type { Database } from \"./types.ts\";\n\nconst DEFAULT_URL =\n\t\"postgres://postgres:postgres@localhost:5432/secondlayer_dev\";\n\ninterface PoolEntry {\n\tdb: Kysely<Database>;\n\trawClient: ReturnType<typeof postgres>;\n}\n\n/**\n * Cache of Kysely + raw postgres.js pools keyed by resolved URL.\n * Two getters resolving to the same URL share one entry (single pool) —\n * this is the single-DB backward-compat contract: when only `DATABASE_URL`\n * is set, `getSourceDb() === getTargetDb()` (zero regression vs. pre-dual-DB).\n */\nconst pools = new Map<string, PoolEntry>();\n\nfunction resolveSourceUrl(): string {\n\treturn (\n\t\tprocess.env.SOURCE_DATABASE_URL || process.env.DATABASE_URL || DEFAULT_URL\n\t);\n}\n\nfunction resolveTargetUrl(): string {\n\treturn (\n\t\tprocess.env.TARGET_DATABASE_URL || process.env.DATABASE_URL || DEFAULT_URL\n\t);\n}\n\nfunction getOrCreatePool(url: string): PoolEntry {\n\tconst existing = pools.get(url);\n\tif (existing) return existing;\n\n\t// \"Local\" = we skip TLS. Any Docker service alias (single-label hostname\n\t// with no dots) is on an internal network and won't serve TLS.\n\tconst host = (() => {\n\t\ttry {\n\t\t\treturn new URL(url).hostname;\n\t\t} catch {\n\t\t\treturn \"\";\n\t\t}\n\t})();\n\tconst isLocal =\n\t\thost === \"localhost\" || host === \"127.0.0.1\" || !host.includes(\".\");\n\tconst poolMax = Number.parseInt(process.env.DATABASE_POOL_MAX ?? \"20\", 10);\n\tconst rawClient = postgres(url, {\n\t\tmax: poolMax,\n\t\tssl: isLocal\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\trejectUnauthorized: process.env.NODE_TLS_REJECT_UNAUTHORIZED !== \"0\",\n\t\t\t\t},\n\t});\n\tconst db = new Kysely<Database>({\n\t\tdialect: new PostgresJSDialect({ postgres: rawClient }),\n\t\t// Diagnostic hook: surface the failing SQL whenever postgres rejects\n\t\t// with code 42P10 (ON CONFLICT target doesn't match any unique\n\t\t// constraint). Temporary — remove once we've caught the culprit\n\t\t// query in prod logs and fixed the schema drift.\n\t\tlog: (event) => {\n\t\t\tif (event.level !== \"error\") return;\n\t\t\tconst err = event.error as {\n\t\t\t\tcode?: string;\n\t\t\t\tmessage?: string;\n\t\t\t} | null;\n\t\t\tif (err?.code !== \"42P10\") return;\n\t\t\tlogger.warn(\"db.on_conflict_constraint_missing\", {\n\t\t\t\tcode: err.code,\n\t\t\t\tmessage: err.message,\n\t\t\t\tsql: event.query.sql,\n\t\t\t\tparams: event.query.parameters,\n\t\t\t});\n\t\t},\n\t});\n\tconst entry: PoolEntry = { db, rawClient };\n\tpools.set(url, entry);\n\treturn entry;\n}\n\n/**\n * Kysely instance for the SOURCE DB (block/tx/event reads from the shared\n * indexer). Resolution: `SOURCE_DATABASE_URL || DATABASE_URL`.\n */\nexport function getSourceDb(): Kysely<Database> {\n\treturn getOrCreatePool(resolveSourceUrl()).db;\n}\n\n/**\n * Kysely instance for the TARGET DB (subgraph schemas, subgraphs table,\n * account-scoped data — tenant-side writes). Resolution:\n * `TARGET_DATABASE_URL || DATABASE_URL`.\n */\nexport function getTargetDb(): Kysely<Database> {\n\treturn getOrCreatePool(resolveTargetUrl()).db;\n}\n\n/**\n * Backward-compat alias for `getTargetDb()`. Accepts an optional\n * `connectionString` override used by seed/test helpers — when supplied,\n * bypasses env resolution and uses the provided URL directly (still cached).\n */\nexport function getDb(connectionString?: string): Kysely<Database> {\n\tif (connectionString) return getOrCreatePool(connectionString).db;\n\treturn getTargetDb();\n}\n\n/**\n * Raw postgres.js client for dynamic schema DDL (CREATE SCHEMA, DROP, etc.).\n * Defaults to the target role (tenant schemas live in the target DB).\n */\nexport function getRawClient(\n\trole: \"source\" | \"target\" = \"target\",\n): ReturnType<typeof postgres> {\n\tconst url = role === \"source\" ? resolveSourceUrl() : resolveTargetUrl();\n\treturn getOrCreatePool(url).rawClient;\n}\n\n/** Close all DB connection pools. Call in CLI commands to allow process exit. */\nexport async function closeDb(): Promise<void> {\n\tfor (const entry of pools.values()) {\n\t\tawait entry.db.destroy();\n\t\tawait entry.rawClient.end();\n\t}\n\tpools.clear();\n}\n\nimport { sql } from \"kysely\";\nexport { sql };\nexport * from \"./types.ts\";\nexport { jsonb, parseJsonb } from \"./jsonb.ts\";\n"
|
|
7
9
|
],
|
|
8
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAWO,SAAS,KAAkB,CAAC,OAAyB;AAAA,EAC3D,MAAM,UAAU,KAAK,UAAU,OAAO,CAAC,IAAI,MAC1C,OAAO,MAAM,WAAW,EAAE,SAAS,IAAI,CACxC,EAAE,QAAQ,MAAM,IAAI;AAAA,EACpB,OAAO,MAAM,IAAI,IAAI,IAAI,iBAAiB;AAAA;AAQpC,SAAS,UAAuB,CAAC,OAAmB;AAAA,EAC1D,IAAI,OAAO,UAAU,UAAU;AAAA,IAC9B,IAAI;AAAA,MACH,OAAO,KAAK,MAAM,KAAK;AAAA,MACtB,MAAM;AAAA,MACP,OAAO;AAAA;AAAA,EAET;AAAA,EACA,OAAQ,SAAS,CAAC;AAAA;;;AC/BnB;AACA;AACA;
|
|
9
|
-
"debugId": "
|
|
10
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAGA,IAAM,iBAAiB,EAAE,OAAO,EAAE,UAAU,CAAC,QAAQ;AAAA,EACpD,MAAM,WAAW,IACf,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO;AAAA,EAChB,MAAM,QAAQ,CAAC,WAAW,SAAS;AAAA,EACnC,WAAW,KAAK,UAAU;AAAA,IACzB,IAAI,CAAC,MAAM,SAAS,CAAC,GAAG;AAAA,MACvB,MAAM,IAAI,MACT,oBAAoB,sBAAsB,MAAM,KAAK,IAAI,GAC1D;A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AC/C,OAAO,gBAAgB,iBAAiB,CAAC,EAAE;AAAA;AAQrC,SAAS,WAAW,GAAqB;AAAA,EAC/C,OAAO,gBAAgB,iBAAiB,CAAC,EAAE;AAAA;AAQrC,SAAS,KAAK,CAAC,kBAA6C;AAAA,EAClE,IAAI;AAAA,IAAkB,OAAO,gBAAgB,gBAAgB,EAAE;AAAA,EAC/D,OAAO,YAAY;AAAA;AAOb,SAAS,YAAY,CAC3B,OAA4B,UACE;AAAA,EAC9B,MAAM,MAAM,SAAS,WAAW,iBAAiB,IAAI,iBAAiB;AAAA,EACtE,OAAO,gBAAgB,GAAG,EAAE;AAAA;AAI7B,eAAsB,OAAO,GAAkB;AAAA,EAC9C,WAAW,SAAS,MAAM,OAAO,GAAG;AAAA,IACnC,MAAM,MAAM,GAAG,QAAQ;AAAA,IACvB,MAAM,MAAM,UAAU,IAAI;AAAA,EAC3B;AAAA,EACA,MAAM,MAAM;AAAA;",
|
|
11
|
+
"debugId": "83F7FBE5F90E372264756E2164756E21",
|
|
10
12
|
"names": []
|
|
11
13
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -851,6 +851,147 @@ interface SubgraphQueryParams {
|
|
|
851
851
|
fields?: string;
|
|
852
852
|
filters?: Record<string, string>;
|
|
853
853
|
}
|
|
854
|
+
import { z as z5 } from "zod/v4";
|
|
855
|
+
declare const SUBSCRIPTION_FORMATS: readonly ["standard-webhooks", "inngest", "trigger", "cloudflare", "cloudevents", "raw"];
|
|
856
|
+
declare const SUBSCRIPTION_RUNTIMES: readonly ["inngest", "trigger", "cloudflare", "node"];
|
|
857
|
+
declare const SUBSCRIPTION_STATUSES: readonly ["active", "paused", "error"];
|
|
858
|
+
declare const SUBSCRIPTION_FILTER_OPERATORS: readonly ["eq", "neq", "gt", "gte", "lt", "lte", "in"];
|
|
859
|
+
declare const SubscriptionStatusSchema: z5.ZodType<SubscriptionStatus2>;
|
|
860
|
+
declare const SubscriptionFormatSchema: z5.ZodType<SubscriptionFormat2>;
|
|
861
|
+
declare const SubscriptionRuntimeSchema: z5.ZodType<SubscriptionRuntime2>;
|
|
862
|
+
declare const SubscriptionFilterPrimitiveSchema: z5.ZodType<SubscriptionFilterPrimitive>;
|
|
863
|
+
declare const SubscriptionFilterOperatorSchema: z5.ZodType<SubscriptionFilterOperator>;
|
|
864
|
+
declare const SubscriptionFilterClauseSchema: z5.ZodType<SubscriptionFilterClause>;
|
|
865
|
+
declare const SubscriptionFilterSchema: z5.ZodType<SubscriptionFilter>;
|
|
866
|
+
declare const CreateSubscriptionRequestSchema: z5.ZodType<ParsedCreateSubscriptionRequest>;
|
|
867
|
+
declare const UpdateSubscriptionRequestSchema: z5.ZodType<UpdateSubscriptionRequest>;
|
|
868
|
+
declare const ReplaySubscriptionRequestSchema: z5.ZodType<ReplaySubscriptionRequest>;
|
|
869
|
+
type SubscriptionStatus2 = (typeof SUBSCRIPTION_STATUSES)[number];
|
|
870
|
+
type SubscriptionFormat2 = (typeof SUBSCRIPTION_FORMATS)[number];
|
|
871
|
+
type SubscriptionRuntime2 = (typeof SUBSCRIPTION_RUNTIMES)[number];
|
|
872
|
+
type SubscriptionFilterPrimitive = string | number | boolean;
|
|
873
|
+
type SubscriptionFilterOperator = {
|
|
874
|
+
eq: SubscriptionFilterPrimitive
|
|
875
|
+
} | {
|
|
876
|
+
neq: SubscriptionFilterPrimitive
|
|
877
|
+
} | {
|
|
878
|
+
gt: string | number
|
|
879
|
+
} | {
|
|
880
|
+
gte: string | number
|
|
881
|
+
} | {
|
|
882
|
+
lt: string | number
|
|
883
|
+
} | {
|
|
884
|
+
lte: string | number
|
|
885
|
+
} | {
|
|
886
|
+
in: SubscriptionFilterPrimitive[]
|
|
887
|
+
};
|
|
888
|
+
type SubscriptionFilterClause = SubscriptionFilterPrimitive | SubscriptionFilterOperator;
|
|
889
|
+
type SubscriptionFilter = Record<string, SubscriptionFilterClause>;
|
|
890
|
+
interface CreateSubscriptionRequest {
|
|
891
|
+
name: string;
|
|
892
|
+
subgraphName: string;
|
|
893
|
+
tableName: string;
|
|
894
|
+
url: string;
|
|
895
|
+
filter?: SubscriptionFilter;
|
|
896
|
+
format?: SubscriptionFormat2;
|
|
897
|
+
runtime?: SubscriptionRuntime2 | null;
|
|
898
|
+
authConfig?: Record<string, unknown>;
|
|
899
|
+
maxRetries?: number;
|
|
900
|
+
timeoutMs?: number;
|
|
901
|
+
concurrency?: number;
|
|
902
|
+
}
|
|
903
|
+
interface ParsedCreateSubscriptionRequest extends Omit<CreateSubscriptionRequest, "format"> {
|
|
904
|
+
format: SubscriptionFormat2;
|
|
905
|
+
}
|
|
906
|
+
interface UpdateSubscriptionRequest {
|
|
907
|
+
name?: string;
|
|
908
|
+
url?: string;
|
|
909
|
+
filter?: SubscriptionFilter;
|
|
910
|
+
format?: SubscriptionFormat2;
|
|
911
|
+
runtime?: SubscriptionRuntime2 | null;
|
|
912
|
+
authConfig?: Record<string, unknown>;
|
|
913
|
+
maxRetries?: number;
|
|
914
|
+
timeoutMs?: number;
|
|
915
|
+
concurrency?: number;
|
|
916
|
+
}
|
|
917
|
+
type ParsedUpdateSubscriptionRequest = UpdateSubscriptionRequest;
|
|
918
|
+
interface ReplaySubscriptionRequest {
|
|
919
|
+
fromBlock: number;
|
|
920
|
+
toBlock: number;
|
|
921
|
+
force?: string;
|
|
922
|
+
}
|
|
923
|
+
type ParsedReplaySubscriptionRequest = ReplaySubscriptionRequest;
|
|
924
|
+
interface SubscriptionSummary {
|
|
925
|
+
id: string;
|
|
926
|
+
name: string;
|
|
927
|
+
status: SubscriptionStatus2;
|
|
928
|
+
subgraphName: string;
|
|
929
|
+
tableName: string;
|
|
930
|
+
format: SubscriptionFormat2;
|
|
931
|
+
runtime: SubscriptionRuntime2 | null;
|
|
932
|
+
url: string;
|
|
933
|
+
lastDeliveryAt: string | null;
|
|
934
|
+
lastSuccessAt: string | null;
|
|
935
|
+
createdAt: string;
|
|
936
|
+
updatedAt: string;
|
|
937
|
+
}
|
|
938
|
+
interface SubscriptionDetail extends SubscriptionSummary {
|
|
939
|
+
filter: Record<string, unknown>;
|
|
940
|
+
authConfig: Record<string, unknown>;
|
|
941
|
+
maxRetries: number;
|
|
942
|
+
timeoutMs: number;
|
|
943
|
+
concurrency: number;
|
|
944
|
+
circuitFailures: number;
|
|
945
|
+
circuitOpenedAt: string | null;
|
|
946
|
+
lastError: string | null;
|
|
947
|
+
}
|
|
948
|
+
interface CreateSubscriptionResponse {
|
|
949
|
+
subscription: SubscriptionDetail;
|
|
950
|
+
/** Plaintext signing secret — surfaced ONCE. Store it server-side. */
|
|
951
|
+
signingSecret: string;
|
|
952
|
+
}
|
|
953
|
+
interface RotateSecretResponse {
|
|
954
|
+
subscription: SubscriptionDetail;
|
|
955
|
+
signingSecret: string;
|
|
956
|
+
}
|
|
957
|
+
interface DeliveryRow {
|
|
958
|
+
id: string;
|
|
959
|
+
attempt: number;
|
|
960
|
+
statusCode: number | null;
|
|
961
|
+
errorMessage: string | null;
|
|
962
|
+
durationMs: number | null;
|
|
963
|
+
responseBody: string | null;
|
|
964
|
+
dispatchedAt: string;
|
|
965
|
+
}
|
|
966
|
+
interface ReplayResult {
|
|
967
|
+
replayId: string;
|
|
968
|
+
enqueuedCount: number;
|
|
969
|
+
scannedCount: number;
|
|
970
|
+
}
|
|
971
|
+
interface DeadRow {
|
|
972
|
+
id: string;
|
|
973
|
+
eventType: string;
|
|
974
|
+
attempt: number;
|
|
975
|
+
blockHeight: number;
|
|
976
|
+
txId: string | null;
|
|
977
|
+
payload: Record<string, unknown>;
|
|
978
|
+
failedAt: string | null;
|
|
979
|
+
createdAt: string;
|
|
980
|
+
}
|
|
981
|
+
interface SubscriptionSchemaColumn {
|
|
982
|
+
type?: unknown;
|
|
983
|
+
}
|
|
984
|
+
interface SubscriptionSchemaTable {
|
|
985
|
+
columns: Record<string, SubscriptionSchemaColumn>;
|
|
986
|
+
}
|
|
987
|
+
type SubscriptionSchemaTables = Record<string, SubscriptionSchemaTable>;
|
|
988
|
+
declare function formatSubscriptionSchemaErrors(error: z5.ZodError): string[];
|
|
989
|
+
declare function validateSubscriptionFilterForTable(input: {
|
|
990
|
+
subgraphName?: string
|
|
991
|
+
tableName: string
|
|
992
|
+
filter?: unknown
|
|
993
|
+
tables: SubscriptionSchemaTables
|
|
994
|
+
}): string[];
|
|
854
995
|
declare namespace exports_hmac {
|
|
855
996
|
export { verifySignatureHeader, verifySignature, signPayload, generateSecret, createSignatureHeader };
|
|
856
997
|
}
|
|
@@ -879,4 +1020,4 @@ declare function createSignatureHeader(payload: string, secret: string, timestam
|
|
|
879
1020
|
* Returns true if valid, false otherwise
|
|
880
1021
|
*/
|
|
881
1022
|
declare function verifySignatureHeader(payload: string, header: string, secret: string, toleranceSeconds?: number): boolean;
|
|
882
|
-
export { sql, parseJsonb, logger, jsonb, getTargetDb, getSourceDb, getRawClient, getErrorMessage, getEnv, getDb, exports_hmac as crypto, closeDb, WaitlistTable, VersionConflictError, ValidationError, UsageSnapshotsTable, UsageSnapshot, UsageDailyTable, UsageDaily, UpdateTransaction, UpdateTenantUsageMonthly, UpdateTenantComputeAddon, UpdateTenant, UpdateSubscriptionOutbox, UpdateSubscription, UpdateSubgraph, UpdateProject, UpdateProfileRequestSchema, UpdateProfileRequest, UpdateIndexProgress, UpdateEvent, UpdateChatSession, UpdateBlock, UpdateApiKey, UpdateAccountSpendCap, TransactionsTable, Transaction, TenantsTable, TenantUsageMonthlyTable, TenantUsageMonthly, TenantSuspendedError, TenantStatus, TenantComputeAddonsTable, TenantComputeAddon, Tenant, TeamMembersTable, TeamMember, TeamInvitationsTable, TeamInvitation, SubscriptionsTable, SubscriptionStatus, SubscriptionRuntime, SubscriptionOutboxTable, SubscriptionOutbox, SubscriptionFormat, SubscriptionDelivery, SubscriptionDeliveriesTable, Subscription, SubgraphsTable, SubgraphUsageDailyTable, SubgraphUsageDaily, SubgraphTableSnapshotsTable, SubgraphSyncInfo, SubgraphSummary, SubgraphQueryParams, SubgraphProcessingStatsTable, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGapsResponse, SubgraphGapRange, SubgraphGapEntry, SubgraphGap, SubgraphDetail, Subgraph, StxTransferFilterSchema, StxTransferFilter, StxMintFilterSchema, StxMintFilter, StxLockFilterSchema, StxLockFilter, StxBurnFilterSchema, StxBurnFilter, SessionsTable, Session, SecondLayerError, ReindexResponse, RateLimitError, ProvisioningAuditStatus, ProvisioningAuditLogTable, ProvisioningAuditLog, ProvisioningAuditEvent, ProjectsTable, Project, PrintEventFilterSchema, PrintEventFilter, OutboxStatus, NotFoundError, NftTransferFilterSchema, NftTransferFilter, NftMintFilterSchema, NftMintFilter, NftBurnFilterSchema, NftBurnFilter, MagicLinksTable, MagicLink, KeyRotatedError, 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, FtTransferFilterSchema, FtTransferFilter, FtMintFilterSchema, FtMintFilter, FtBurnFilterSchema, FtBurnFilter, ForbiddenError, EventsTable, EventFilterSchema, EventFilter, Event, ErrorCodes, ErrorCode, Env, DeploySubgraphResponse, DeploySubgraphRequestSchema, DeploySubgraphRequest, DatabaseError, Database, ContractDeployFilterSchema, ContractDeployFilter, ContractCallFilterSchema, ContractCallFilter, ChatSessionsTable, ChatSession, ChatMessagesTable, ChatMessage, CODE_TO_STATUS, BlocksTable, Block, AuthorizationError, AuthenticationError, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountInsightsTable, AccountInsight, AccountAgentRunsTable, AccountAgentRun, Account };
|
|
1023
|
+
export { validateSubscriptionFilterForTable, sql, parseJsonb, logger, jsonb, getTargetDb, getSourceDb, getRawClient, getErrorMessage, getEnv, getDb, formatSubscriptionSchemaErrors, exports_hmac as crypto, closeDb, WaitlistTable, VersionConflictError, ValidationError, UsageSnapshotsTable, UsageSnapshot, UsageDailyTable, UsageDaily, UpdateTransaction, UpdateTenantUsageMonthly, UpdateTenantComputeAddon, UpdateTenant, UpdateSubscriptionRequestSchema, UpdateSubscriptionRequest, UpdateSubscriptionOutbox, UpdateSubscription, UpdateSubgraph, UpdateProject, UpdateProfileRequestSchema, UpdateProfileRequest, UpdateIndexProgress, UpdateEvent, UpdateChatSession, UpdateBlock, UpdateApiKey, UpdateAccountSpendCap, TransactionsTable, Transaction, TenantsTable, TenantUsageMonthlyTable, TenantUsageMonthly, TenantSuspendedError, TenantStatus, TenantComputeAddonsTable, TenantComputeAddon, Tenant, TeamMembersTable, TeamMember, TeamInvitationsTable, TeamInvitation, SubscriptionsTable, SubscriptionSummary, SubscriptionStatusSchema, SubscriptionStatus, SubscriptionSchemaTables, SubscriptionSchemaTable, SubscriptionSchemaColumn, SubscriptionRuntimeSchema, SubscriptionRuntime, SubscriptionOutboxTable, SubscriptionOutbox, SubscriptionFormatSchema, SubscriptionFormat, SubscriptionFilterSchema, SubscriptionFilterPrimitiveSchema, SubscriptionFilterPrimitive, SubscriptionFilterOperatorSchema, SubscriptionFilterOperator, SubscriptionFilterClauseSchema, SubscriptionFilterClause, SubscriptionFilter, SubscriptionDetail, SubscriptionDelivery, SubscriptionDeliveriesTable, Subscription, SubgraphsTable, SubgraphUsageDailyTable, SubgraphUsageDaily, SubgraphTableSnapshotsTable, SubgraphSyncInfo, SubgraphSummary, SubgraphQueryParams, SubgraphProcessingStatsTable, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGapsResponse, SubgraphGapRange, SubgraphGapEntry, SubgraphGap, SubgraphDetail, Subgraph, StxTransferFilterSchema, StxTransferFilter, StxMintFilterSchema, StxMintFilter, StxLockFilterSchema, StxLockFilter, StxBurnFilterSchema, StxBurnFilter, SessionsTable, Session, SecondLayerError, SUBSCRIPTION_STATUSES, SUBSCRIPTION_RUNTIMES, SUBSCRIPTION_FORMATS, SUBSCRIPTION_FILTER_OPERATORS, RotateSecretResponse, ReplaySubscriptionRequestSchema, ReplaySubscriptionRequest, ReplayResult, ReindexResponse, RateLimitError, ProvisioningAuditStatus, ProvisioningAuditLogTable, ProvisioningAuditLog, ProvisioningAuditEvent, ProjectsTable, Project, PrintEventFilterSchema, PrintEventFilter, ParsedUpdateSubscriptionRequest, ParsedReplaySubscriptionRequest, ParsedCreateSubscriptionRequest, OutboxStatus, NotFoundError, NftTransferFilterSchema, NftTransferFilter, NftMintFilterSchema, NftMintFilter, NftBurnFilterSchema, NftBurnFilter, MagicLinksTable, MagicLink, KeyRotatedError, 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, FtTransferFilterSchema, FtTransferFilter, FtMintFilterSchema, FtMintFilter, FtBurnFilterSchema, FtBurnFilter, ForbiddenError, EventsTable, EventFilterSchema, EventFilter, Event, ErrorCodes, ErrorCode, Env, DeploySubgraphResponse, DeploySubgraphRequestSchema, DeploySubgraphRequest, DeliveryRow, DeadRow, DatabaseError, Database, CreateSubscriptionResponse, CreateSubscriptionRequestSchema, CreateSubscriptionRequest, ContractDeployFilterSchema, ContractDeployFilter, ContractCallFilterSchema, ContractCallFilter, ChatSessionsTable, ChatSession, ChatMessagesTable, ChatMessage, CODE_TO_STATUS, BlocksTable, Block, AuthorizationError, AuthenticationError, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountInsightsTable, AccountInsight, AccountAgentRunsTable, AccountAgentRun, Account };
|