@secondlayer/subgraphs 0.6.0 → 0.7.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/index.d.ts +3 -1
- package/dist/src/index.js +233 -119
- package/dist/src/index.js.map +16 -16
- package/dist/src/runtime/block-processor.d.ts +2 -0
- package/dist/src/runtime/block-processor.js +130 -100
- package/dist/src/runtime/block-processor.js.map +9 -9
- package/dist/src/runtime/catchup.d.ts +2 -0
- package/dist/src/runtime/catchup.js +180 -104
- package/dist/src/runtime/catchup.js.map +12 -12
- package/dist/src/runtime/clarity.js.map +2 -2
- package/dist/src/runtime/context.d.ts +1 -1
- package/dist/src/runtime/context.js +17 -4
- package/dist/src/runtime/context.js.map +3 -3
- package/dist/src/runtime/processor.js +198 -110
- package/dist/src/runtime/processor.js.map +14 -14
- package/dist/src/runtime/reindex.d.ts +2 -0
- package/dist/src/runtime/reindex.js +223 -117
- package/dist/src/runtime/reindex.js.map +13 -13
- package/dist/src/runtime/reorg.d.ts +2 -0
- package/dist/src/runtime/reorg.js +143 -104
- package/dist/src/runtime/reorg.js.map +10 -10
- package/dist/src/runtime/runner.d.ts +3 -1
- package/dist/src/runtime/runner.js +7 -3
- package/dist/src/runtime/runner.js.map +4 -4
- package/dist/src/runtime/source-matcher.js.map +3 -3
- package/dist/src/runtime/stats.d.ts +1 -1
- package/dist/src/runtime/stats.js +2 -2
- package/dist/src/runtime/stats.js.map +3 -3
- package/dist/src/schema/index.d.ts +3 -1
- package/dist/src/schema/index.js +11 -3
- package/dist/src/schema/index.js.map +5 -5
- package/dist/src/service.js +199 -111
- package/dist/src/service.js.map +15 -15
- package/dist/src/templates.js.map +2 -2
- package/dist/src/types.d.ts +2 -0
- package/dist/src/types.js.map +2 -2
- package/dist/src/validate.d.ts +2 -0
- package/dist/src/validate.js.map +2 -2
- package/package.json +51 -51
package/dist/src/schema/index.js
CHANGED
|
@@ -186,11 +186,19 @@ async function deploySchema(db, def, handlerPath, opts) {
|
|
|
186
186
|
const regData = {
|
|
187
187
|
name: def.name,
|
|
188
188
|
version: def.version || "1.0.0",
|
|
189
|
-
definition: toJsonSafe({
|
|
189
|
+
definition: toJsonSafe({
|
|
190
|
+
name: def.name,
|
|
191
|
+
version: def.version,
|
|
192
|
+
description: def.description,
|
|
193
|
+
startBlock: def.startBlock,
|
|
194
|
+
sources: def.sources,
|
|
195
|
+
schema: def.schema
|
|
196
|
+
}),
|
|
190
197
|
schemaHash: hash,
|
|
191
198
|
handlerPath,
|
|
192
199
|
apiKeyId: opts?.apiKeyId,
|
|
193
|
-
schemaName
|
|
200
|
+
schemaName,
|
|
201
|
+
startBlock: def.startBlock
|
|
194
202
|
};
|
|
195
203
|
if (existing) {
|
|
196
204
|
if (existing.schema_hash === hash && !opts?.forceReindex) {
|
|
@@ -300,5 +308,5 @@ export {
|
|
|
300
308
|
deploySchema
|
|
301
309
|
};
|
|
302
310
|
|
|
303
|
-
//# debugId=
|
|
311
|
+
//# debugId=90E3287986D33A2A64756E2164756E21
|
|
304
312
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/validate.ts", "../src/schema/utils.ts", "../src/schema/generator.ts", "../src/schema/deployer.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { z } from \"zod/v4\";\nimport type {
|
|
5
|
+
"import { z } from \"zod/v4\";\nimport type {\n\tColumnType,\n\tSubgraphColumn,\n\tSubgraphDefinition,\n\tSubgraphSource,\n\tSubgraphTable,\n} from \"./types.ts\";\n\nexport const SubgraphNameSchema: z.ZodType<string> = z\n\t.string()\n\t.min(1)\n\t.max(63)\n\t.regex(\n\t\t/^[a-z][a-z0-9-]*$/,\n\t\t\"Must start with lowercase letter, contain only lowercase alphanumeric and hyphens\",\n\t);\n\nexport const ColumnTypeSchema: z.ZodType<ColumnType> = z.enum([\n\t\"text\",\n\t\"uint\",\n\t\"int\",\n\t\"principal\",\n\t\"boolean\",\n\t\"timestamp\",\n\t\"jsonb\",\n]);\n\nexport const SubgraphColumnSchema: z.ZodType<SubgraphColumn> = z.object({\n\ttype: ColumnTypeSchema,\n\tnullable: z.boolean().optional(),\n\tindexed: z.boolean().optional(),\n\tsearch: z.boolean().optional(),\n\tdefault: z.union([z.string(), z.number(), z.boolean()]).optional(),\n}) as z.ZodType<SubgraphColumn>;\n\nexport const SubgraphTableSchema: z.ZodType<SubgraphTable> = z.object({\n\tcolumns: z\n\t\t.record(z.string(), SubgraphColumnSchema)\n\t\t.refine(\n\t\t\t(c) => Object.keys(c).length > 0,\n\t\t\t\"Table must have at least one column\",\n\t\t),\n\tindexes: z.array(z.array(z.string())).optional(),\n\tuniqueKeys: z.array(z.array(z.string())).optional(),\n}) as z.ZodType<SubgraphTable>;\n\nexport const SubgraphSchemaSchema: z.ZodType<Record<string, SubgraphTable>> = z\n\t.record(z.string(), SubgraphTableSchema)\n\t.refine(\n\t\t(s) => Object.keys(s).length > 0,\n\t\t\"Schema must have at least one table\",\n\t) as z.ZodType<Record<string, SubgraphTable>>;\n\nexport const SubgraphSourceSchema: z.ZodType<SubgraphSource> = z\n\t.object({\n\t\tcontract: z.string().optional(),\n\t\tevent: z.string().optional(),\n\t\tfunction: z.string().optional(),\n\t\ttype: z.string().optional(),\n\t\tminAmount: z.bigint().optional(),\n\t})\n\t.refine(\n\t\t(s) => s.contract || s.type,\n\t\t\"Source must specify at least 'contract' or 'type'\",\n\t) as z.ZodType<SubgraphSource>;\n\nexport const SubgraphDefinitionSchema: z.ZodType<SubgraphDefinition> = z.object(\n\t{\n\t\tname: SubgraphNameSchema,\n\t\tversion: z.string().optional(),\n\t\tdescription: z.string().optional(),\n\t\tsources: z\n\t\t\t.array(SubgraphSourceSchema)\n\t\t\t.min(1, \"Must have at least one source\"),\n\t\tschema: SubgraphSchemaSchema,\n\t\thandlers: z.record(z.string(), z.any()),\n\t},\n) as unknown as z.ZodType<SubgraphDefinition>;\n\n/**\n * Validates a subgraph definition, returning the parsed result or throwing on failure.\n */\nexport function validateSubgraphDefinition(def: unknown): SubgraphDefinition {\n\treturn SubgraphDefinitionSchema.parse(def);\n}\n",
|
|
6
6
|
"// Re-export canonical pgSchemaName from shared\nexport { pgSchemaName } from \"@secondlayer/shared/db/queries/subgraphs\";\n",
|
|
7
|
-
"import type { ColumnType, SubgraphDefinition } from \"../types.ts\";\nimport { pgSchemaName } from \"./utils.ts\";\n\nexport const TYPE_MAP: Record<ColumnType, string> = {\n
|
|
8
|
-
"import { sql, type Kysely } from \"kysely\";\nimport type { Database } from \"@secondlayer/shared/db\";\nimport { validateSubgraphDefinition } from \"../validate.ts\";\nimport { generateSubgraphSQL, TYPE_MAP } from \"./generator.ts\";\nimport { pgSchemaName } from \"./utils.ts\";\nimport type { SubgraphDefinition, SubgraphSchema } from \"../types.ts\";\n\ntype AnyDb = Kysely<Database>;\n\n/** Deep-clone an object, converting BigInts to strings for JSON serialization. */\nfunction toJsonSafe(obj: unknown): unknown {\n return JSON.parse(JSON.stringify(obj, (_key, value) =>\n typeof value === \"bigint\" ? value.toString() : value\n ));\n}\n\nexport interface TableDiff {\n /** Tables added to the schema */\n addedTables: string[];\n /** Tables removed from the schema */\n removedTables: string[];\n /** Per-table column diffs (only for tables present in both) */\n tables: Record<string, ColumnDiff>;\n}\n\nexport interface ColumnDiff {\n added: string[];\n removed: string[];\n changed: string[];\n}\n\n/**\n * Compare two multi-table subgraph schemas and return differences.\n */\nexport function diffSchema(existing: SubgraphSchema, incoming: SubgraphSchema): TableDiff {\n const existingTables = new Set(Object.keys(existing));\n const incomingTables = new Set(Object.keys(incoming));\n\n const addedTables = [...incomingTables].filter((t) => !existingTables.has(t));\n const removedTables = [...existingTables].filter((t) => !incomingTables.has(t));\n\n const tables: Record<string, ColumnDiff> = {};\n for (const tableName of incomingTables) {\n if (!existingTables.has(tableName)) continue;\n const existingCols = existing[tableName]!.columns;\n const incomingCols = incoming[tableName]!.columns;\n\n const existingKeys = new Set(Object.keys(existingCols));\n const incomingKeys = new Set(Object.keys(incomingCols));\n\n tables[tableName] = {\n added: [...incomingKeys].filter((k) => !existingKeys.has(k)),\n removed: [...existingKeys].filter((k) => !incomingKeys.has(k)),\n changed: [...incomingKeys].filter((k) => {\n if (!existingKeys.has(k)) return false;\n return JSON.stringify(existingCols[k]) !== JSON.stringify(incomingCols[k]);\n }),\n };\n }\n\n return { addedTables, removedTables, tables };\n}\n\n/**\n * Returns true if the diff contains any breaking changes\n * (removed tables, removed columns, or changed column types).\n */\nfunction hasBreakingChanges(diff: TableDiff): { breaking: boolean; reasons: string[] } {\n const reasons: string[] = [];\n if (diff.removedTables.length > 0) {\n reasons.push(`removed tables: [${diff.removedTables.join(\", \")}]`);\n }\n for (const [table, colDiff] of Object.entries(diff.tables)) {\n if (colDiff.removed.length > 0) {\n reasons.push(`${table}: removed columns [${colDiff.removed.join(\", \")}]`);\n }\n if (colDiff.changed.length > 0) {\n reasons.push(`${table}: changed columns [${colDiff.changed.join(\", \")}]`);\n }\n }\n return { breaking: reasons.length > 0, reasons };\n}\n\n/**\n * Deploy a subgraph schema to the database.\n * - New subgraph → CREATE SCHEMA + tables + register\n * - Same hash → no-op\n * - Additive change → ALTER TABLE ADD COLUMN / CREATE TABLE for new tables\n * - Breaking change → throws error\n */\nexport async function deploySchema(\n db: AnyDb,\n def: SubgraphDefinition,\n handlerPath: string,\n opts?: { forceReindex?: boolean; apiKeyId?: string; schemaName?: string },\n): Promise<{ action: \"created\" | \"unchanged\" | \"updated\" | \"reindexed\"; subgraphId: string }> {\n validateSubgraphDefinition(def);\n\n const { statements, hash } = generateSubgraphSQL(def, opts?.schemaName);\n const { getSubgraph, registerSubgraph } = await import(\"@secondlayer/shared/db/queries/subgraphs\");\n\n const existing = await getSubgraph(db, def.name, opts?.apiKeyId);\n\n const schemaName = opts?.schemaName ?? pgSchemaName(def.name);\n const regData = {\n name: def.name,\n version: def.version || \"1.0.0\",\n definition: toJsonSafe({ name: def.name, version: def.version, description: def.description, sources: def.sources, schema: def.schema }) as Record<string, unknown>,\n schemaHash: hash,\n handlerPath,\n apiKeyId: opts?.apiKeyId,\n schemaName,\n };\n\n if (existing) {\n if (existing.schema_hash === hash && !opts?.forceReindex) {\n // Update handler path in case file moved\n const { updateSubgraphHandlerPath } = await import(\"@secondlayer/shared/db/queries/subgraphs\");\n await updateSubgraphHandlerPath(db, def.name, handlerPath);\n return { action: \"unchanged\", subgraphId: existing.id };\n }\n\n if (existing.schema_hash === hash && opts?.forceReindex) {\n // Same schema but force reindex requested — drop and recreate\n await sql.raw(`DROP SCHEMA IF EXISTS \"${schemaName}\" CASCADE`).execute(db);\n for (const stmt of statements) {\n await sql.raw(stmt).execute(db);\n }\n const sg = await registerSubgraph(db, regData);\n return { action: \"reindexed\", subgraphId: sg.id };\n }\n\n if (existing.definition.schema) {\n const diff = diffSchema(existing.definition.schema as SubgraphSchema, def.schema);\n const { breaking, reasons } = hasBreakingChanges(diff);\n\n if (breaking) {\n if (!opts?.forceReindex) {\n throw new Error(\n `Breaking schema change detected (${reasons.join(\"; \")}). ` +\n `Use --reindex to force rebuild, or delete the subgraph first.`,\n );\n }\n\n // Force reindex: drop schema, recreate, register, caller triggers reindex\n await sql.raw(`DROP SCHEMA IF EXISTS \"${schemaName}\" CASCADE`).execute(db);\n for (const stmt of statements) {\n await sql.raw(stmt).execute(db);\n }\n const sg = await registerSubgraph(db, regData);\n return { action: \"reindexed\", subgraphId: sg.id };\n }\n\n // Create new tables\n for (const tableName of diff.addedTables) {\n const tableDef = def.schema[tableName]!;\n const qualifiedName = `${schemaName}.${tableName}`;\n const colDefs = [\n `_id BIGSERIAL PRIMARY KEY`,\n `_block_height BIGINT NOT NULL`,\n `_tx_id TEXT NOT NULL`,\n `_created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()`,\n ];\n for (const [colName, col] of Object.entries(tableDef.columns)) {\n const nullable = col.nullable ? \"\" : \" NOT NULL\";\n colDefs.push(`${colName} ${TYPE_MAP[col.type]!}${nullable}`);\n }\n await sql.raw(\n `CREATE TABLE IF NOT EXISTS ${qualifiedName} (\\n ${colDefs.join(\",\\n \")}\\n)`,\n ).execute(db);\n await sql.raw(\n `CREATE INDEX IF NOT EXISTS idx_${schemaName}_${tableName}_block_height ON ${qualifiedName} (_block_height)`,\n ).execute(db);\n await sql.raw(\n `CREATE INDEX IF NOT EXISTS idx_${schemaName}_${tableName}_tx_id ON ${qualifiedName} (_tx_id)`,\n ).execute(db);\n for (const [colName, col] of Object.entries(tableDef.columns)) {\n if (col.indexed) {\n await sql.raw(\n `CREATE INDEX IF NOT EXISTS idx_${schemaName}_${tableName}_${colName} ON ${qualifiedName} (${colName})`,\n ).execute(db);\n }\n if (col.search) {\n await sql.raw(\n `CREATE INDEX IF NOT EXISTS idx_${schemaName}_${tableName}_${colName}_trgm ON ${qualifiedName} USING gin (${colName} gin_trgm_ops)`,\n ).execute(db);\n }\n }\n }\n\n // Add columns to existing tables\n for (const [tableName, colDiff] of Object.entries(diff.tables)) {\n if (colDiff.added.length === 0) continue;\n const qualifiedName = `${schemaName}.${tableName}`;\n const tableDef = def.schema[tableName]!;\n for (const colName of colDiff.added) {\n const col = tableDef.columns[colName]!;\n const sqlType = TYPE_MAP[col.type]!;\n const nullable = col.nullable ? \"\" : \" NOT NULL DEFAULT \" + getDefault(col.type);\n await sql.raw(\n `ALTER TABLE ${qualifiedName} ADD COLUMN ${colName} ${sqlType}${nullable}`,\n ).execute(db);\n if (col.indexed) {\n await sql.raw(\n `CREATE INDEX IF NOT EXISTS idx_${schemaName}_${tableName}_${colName} ON ${qualifiedName} (${colName})`,\n ).execute(db);\n }\n if (col.search) {\n await sql.raw(\n `CREATE INDEX IF NOT EXISTS idx_${schemaName}_${tableName}_${colName}_trgm ON ${qualifiedName} USING gin (${colName} gin_trgm_ops)`,\n ).execute(db);\n }\n }\n }\n }\n\n const sg = await registerSubgraph(db, regData);\n return { action: \"updated\", subgraphId: sg.id };\n }\n\n // New subgraph — execute all DDL\n for (const stmt of statements) {\n await sql.raw(stmt).execute(db);\n }\n\n const sg = await registerSubgraph(db, regData);\n return { action: \"created\", subgraphId: sg.id };\n}\n\nfunction getDefault(type: string): string {\n switch (type) {\n case \"text\":\n case \"principal\":\n return \"''\";\n case \"uint\":\n case \"int\":\n return \"0\";\n case \"boolean\":\n return \"false\";\n case \"timestamp\":\n return \"NOW()\";\n case \"jsonb\":\n return \"'{}'\";\n default:\n return \"''\";\n }\n}\n"
|
|
7
|
+
"import type { ColumnType, SubgraphDefinition } from \"../types.ts\";\nimport { pgSchemaName } from \"./utils.ts\";\n\nexport const TYPE_MAP: Record<ColumnType, string> = {\n\ttext: \"TEXT\",\n\tuint: \"NUMERIC\",\n\tint: \"NUMERIC\",\n\tprincipal: \"TEXT\",\n\tboolean: \"BOOLEAN\",\n\ttimestamp: \"TIMESTAMPTZ\",\n\tjsonb: \"JSONB\",\n};\n\nexport interface GeneratedSQL {\n\tstatements: string[];\n\thash: string;\n}\n\nfunction escapeLiteralDefault(value: unknown): string {\n\tif (value === null || value === undefined) return \"NULL\";\n\tif (typeof value === \"number\" || typeof value === \"bigint\")\n\t\treturn String(value);\n\tif (typeof value === \"boolean\") return value ? \"TRUE\" : \"FALSE\";\n\treturn `'${String(value).replace(/'/g, \"''\")}'`;\n}\n\n/**\n * Generates PostgreSQL DDL statements for a subgraph definition.\n * Creates a dedicated schema `subgraph_<name>` with one table per schema entry,\n * each with auto-columns and indexes.\n */\nexport function generateSubgraphSQL(\n\tdef: SubgraphDefinition,\n\tschemaNameOverride?: string,\n): GeneratedSQL {\n\tconst schemaName = schemaNameOverride ?? pgSchemaName(def.name);\n\tconst statements: string[] = [];\n\n\t// Check if any column uses search (trigram)\n\tconst needsTrgm = Object.values(def.schema).some((table) =>\n\t\tObject.values(table.columns).some((col) => col.search),\n\t);\n\n\tif (needsTrgm) {\n\t\tstatements.push(`CREATE EXTENSION IF NOT EXISTS pg_trgm`);\n\t}\n\n\t// Schema namespace\n\tstatements.push(`CREATE SCHEMA IF NOT EXISTS ${schemaName}`);\n\n\t// One table per schema entry\n\tfor (const [tableName, tableDef] of Object.entries(def.schema)) {\n\t\tconst qualifiedName = `${schemaName}.${tableName}`;\n\n\t\t// Auto-columns + user columns\n\t\tconst columnDefs: string[] = [\n\t\t\t`_id BIGSERIAL PRIMARY KEY`,\n\t\t\t`_block_height BIGINT NOT NULL`,\n\t\t\t`_tx_id TEXT NOT NULL`,\n\t\t\t`_created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()`,\n\t\t];\n\n\t\tfor (const [colName, col] of Object.entries(tableDef.columns)) {\n\t\t\tconst sqlType = TYPE_MAP[col.type];\n\t\t\tconst nullable = col.nullable ? \"\" : \" NOT NULL\";\n\t\t\tlet colDef = `${colName} ${sqlType}${nullable}`;\n\t\t\tif (col.default !== undefined) {\n\t\t\t\tcolDef += ` DEFAULT ${escapeLiteralDefault(col.default)}`;\n\t\t\t}\n\t\t\tcolumnDefs.push(colDef);\n\t\t}\n\n\t\tstatements.push(\n\t\t\t`CREATE TABLE IF NOT EXISTS ${qualifiedName} (\\n ${columnDefs.join(\",\\n \")}\\n)`,\n\t\t);\n\n\t\t// Auto-indexes on meta columns\n\t\tstatements.push(\n\t\t\t`CREATE INDEX IF NOT EXISTS idx_${schemaName}_${tableName}_block_height ON ${qualifiedName} (_block_height)`,\n\t\t);\n\t\tstatements.push(\n\t\t\t`CREATE INDEX IF NOT EXISTS idx_${schemaName}_${tableName}_tx_id ON ${qualifiedName} (_tx_id)`,\n\t\t);\n\n\t\t// Single-column indexes\n\t\tfor (const [colName, col] of Object.entries(tableDef.columns)) {\n\t\t\tif (col.indexed) {\n\t\t\t\tstatements.push(\n\t\t\t\t\t`CREATE INDEX IF NOT EXISTS idx_${schemaName}_${tableName}_${colName} ON ${qualifiedName} (${colName})`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Trigram GIN indexes for search columns\n\t\tfor (const [colName, col] of Object.entries(tableDef.columns)) {\n\t\t\tif (col.search) {\n\t\t\t\tstatements.push(\n\t\t\t\t\t`CREATE INDEX IF NOT EXISTS idx_${schemaName}_${tableName}_${colName}_trgm ON ${qualifiedName} USING gin (${colName} gin_trgm_ops)`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Composite indexes\n\t\tif (tableDef.indexes) {\n\t\t\tfor (let i = 0; i < tableDef.indexes.length; i++) {\n\t\t\t\tconst cols = tableDef.indexes[i]!;\n\t\t\t\tconst idxName = `idx_${schemaName}_${tableName}_composite_${i}`;\n\t\t\t\tstatements.push(\n\t\t\t\t\t`CREATE INDEX IF NOT EXISTS ${idxName} ON ${qualifiedName} (${cols.join(\", \")})`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Unique constraints (required for upsert ON CONFLICT)\n\t\tif (tableDef.uniqueKeys) {\n\t\t\tfor (let i = 0; i < tableDef.uniqueKeys.length; i++) {\n\t\t\t\tconst cols = tableDef.uniqueKeys[i]!;\n\t\t\t\tconst constraintName = `uq_${schemaName}_${tableName}_${cols.join(\"_\")}`;\n\t\t\t\tstatements.push(\n\t\t\t\t\t`ALTER TABLE ${qualifiedName} ADD CONSTRAINT ${constraintName} UNIQUE (${cols.join(\", \")})`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Hash based on schema structure (excludes handler)\n\tconst hashInput = JSON.stringify(\n\t\t{\n\t\t\tname: def.name,\n\t\t\tversion: def.version,\n\t\t\tschema: def.schema,\n\t\t\tsources: def.sources,\n\t\t},\n\t\t(_key, value) => (typeof value === \"bigint\" ? value.toString() : value),\n\t);\n\tconst hash = String(Bun.hash(hashInput));\n\n\treturn { statements, hash };\n}\n",
|
|
8
|
+
"import type { Database } from \"@secondlayer/shared/db\";\nimport { type Kysely, sql } from \"kysely\";\nimport type { SubgraphDefinition, SubgraphSchema } from \"../types.ts\";\nimport { validateSubgraphDefinition } from \"../validate.ts\";\nimport { TYPE_MAP, generateSubgraphSQL } from \"./generator.ts\";\nimport { pgSchemaName } from \"./utils.ts\";\n\ntype AnyDb = Kysely<Database>;\n\n/** Deep-clone an object, converting BigInts to strings for JSON serialization. */\nfunction toJsonSafe(obj: unknown): unknown {\n\treturn JSON.parse(\n\t\tJSON.stringify(obj, (_key, value) =>\n\t\t\ttypeof value === \"bigint\" ? value.toString() : value,\n\t\t),\n\t);\n}\n\nexport interface TableDiff {\n\t/** Tables added to the schema */\n\taddedTables: string[];\n\t/** Tables removed from the schema */\n\tremovedTables: string[];\n\t/** Per-table column diffs (only for tables present in both) */\n\ttables: Record<string, ColumnDiff>;\n}\n\nexport interface ColumnDiff {\n\tadded: string[];\n\tremoved: string[];\n\tchanged: string[];\n}\n\n/**\n * Compare two multi-table subgraph schemas and return differences.\n */\nexport function diffSchema(\n\texisting: SubgraphSchema,\n\tincoming: SubgraphSchema,\n): TableDiff {\n\tconst existingTables = new Set(Object.keys(existing));\n\tconst incomingTables = new Set(Object.keys(incoming));\n\n\tconst addedTables = [...incomingTables].filter((t) => !existingTables.has(t));\n\tconst removedTables = [...existingTables].filter(\n\t\t(t) => !incomingTables.has(t),\n\t);\n\n\tconst tables: Record<string, ColumnDiff> = {};\n\tfor (const tableName of incomingTables) {\n\t\tif (!existingTables.has(tableName)) continue;\n\t\tconst existingCols = existing[tableName]!.columns;\n\t\tconst incomingCols = incoming[tableName]!.columns;\n\n\t\tconst existingKeys = new Set(Object.keys(existingCols));\n\t\tconst incomingKeys = new Set(Object.keys(incomingCols));\n\n\t\ttables[tableName] = {\n\t\t\tadded: [...incomingKeys].filter((k) => !existingKeys.has(k)),\n\t\t\tremoved: [...existingKeys].filter((k) => !incomingKeys.has(k)),\n\t\t\tchanged: [...incomingKeys].filter((k) => {\n\t\t\t\tif (!existingKeys.has(k)) return false;\n\t\t\t\treturn (\n\t\t\t\t\tJSON.stringify(existingCols[k]) !== JSON.stringify(incomingCols[k])\n\t\t\t\t);\n\t\t\t}),\n\t\t};\n\t}\n\n\treturn { addedTables, removedTables, tables };\n}\n\n/**\n * Returns true if the diff contains any breaking changes\n * (removed tables, removed columns, or changed column types).\n */\nfunction hasBreakingChanges(diff: TableDiff): {\n\tbreaking: boolean;\n\treasons: string[];\n} {\n\tconst reasons: string[] = [];\n\tif (diff.removedTables.length > 0) {\n\t\treasons.push(`removed tables: [${diff.removedTables.join(\", \")}]`);\n\t}\n\tfor (const [table, colDiff] of Object.entries(diff.tables)) {\n\t\tif (colDiff.removed.length > 0) {\n\t\t\treasons.push(`${table}: removed columns [${colDiff.removed.join(\", \")}]`);\n\t\t}\n\t\tif (colDiff.changed.length > 0) {\n\t\t\treasons.push(`${table}: changed columns [${colDiff.changed.join(\", \")}]`);\n\t\t}\n\t}\n\treturn { breaking: reasons.length > 0, reasons };\n}\n\n/**\n * Deploy a subgraph schema to the database.\n * - New subgraph → CREATE SCHEMA + tables + register\n * - Same hash → no-op\n * - Additive change → ALTER TABLE ADD COLUMN / CREATE TABLE for new tables\n * - Breaking change → throws error\n */\nexport async function deploySchema(\n\tdb: AnyDb,\n\tdef: SubgraphDefinition,\n\thandlerPath: string,\n\topts?: { forceReindex?: boolean; apiKeyId?: string; schemaName?: string },\n): Promise<{\n\taction: \"created\" | \"unchanged\" | \"updated\" | \"reindexed\";\n\tsubgraphId: string;\n}> {\n\tvalidateSubgraphDefinition(def);\n\n\tconst { statements, hash } = generateSubgraphSQL(def, opts?.schemaName);\n\tconst { getSubgraph, registerSubgraph } = await import(\n\t\t\"@secondlayer/shared/db/queries/subgraphs\"\n\t);\n\n\tconst existing = await getSubgraph(db, def.name, opts?.apiKeyId);\n\n\tconst schemaName = opts?.schemaName ?? pgSchemaName(def.name);\n\tconst regData = {\n\t\tname: def.name,\n\t\tversion: def.version || \"1.0.0\",\n\t\tdefinition: toJsonSafe({\n\t\t\tname: def.name,\n\t\t\tversion: def.version,\n\t\t\tdescription: def.description,\n\t\t\tstartBlock: def.startBlock,\n\t\t\tsources: def.sources,\n\t\t\tschema: def.schema,\n\t\t}) as Record<string, unknown>,\n\t\tschemaHash: hash,\n\t\thandlerPath,\n\t\tapiKeyId: opts?.apiKeyId,\n\t\tschemaName,\n\t\tstartBlock: def.startBlock,\n\t};\n\n\tif (existing) {\n\t\tif (existing.schema_hash === hash && !opts?.forceReindex) {\n\t\t\t// Update handler path in case file moved\n\t\t\tconst { updateSubgraphHandlerPath } = await import(\n\t\t\t\t\"@secondlayer/shared/db/queries/subgraphs\"\n\t\t\t);\n\t\t\tawait updateSubgraphHandlerPath(db, def.name, handlerPath);\n\t\t\treturn { action: \"unchanged\", subgraphId: existing.id };\n\t\t}\n\n\t\tif (existing.schema_hash === hash && opts?.forceReindex) {\n\t\t\t// Same schema but force reindex requested — drop and recreate\n\t\t\tawait sql\n\t\t\t\t.raw(`DROP SCHEMA IF EXISTS \"${schemaName}\" CASCADE`)\n\t\t\t\t.execute(db);\n\t\t\tfor (const stmt of statements) {\n\t\t\t\tawait sql.raw(stmt).execute(db);\n\t\t\t}\n\t\t\tconst sg = await registerSubgraph(db, regData);\n\t\t\treturn { action: \"reindexed\", subgraphId: sg.id };\n\t\t}\n\n\t\tif (existing.definition.schema) {\n\t\t\tconst diff = diffSchema(\n\t\t\t\texisting.definition.schema as SubgraphSchema,\n\t\t\t\tdef.schema,\n\t\t\t);\n\t\t\tconst { breaking, reasons } = hasBreakingChanges(diff);\n\n\t\t\tif (breaking) {\n\t\t\t\tif (!opts?.forceReindex) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Breaking schema change detected (${reasons.join(\"; \")}). ` +\n\t\t\t\t\t\t\t`Use --reindex to force rebuild, or delete the subgraph first.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Force reindex: drop schema, recreate, register, caller triggers reindex\n\t\t\t\tawait sql\n\t\t\t\t\t.raw(`DROP SCHEMA IF EXISTS \"${schemaName}\" CASCADE`)\n\t\t\t\t\t.execute(db);\n\t\t\t\tfor (const stmt of statements) {\n\t\t\t\t\tawait sql.raw(stmt).execute(db);\n\t\t\t\t}\n\t\t\t\tconst sg = await registerSubgraph(db, regData);\n\t\t\t\treturn { action: \"reindexed\", subgraphId: sg.id };\n\t\t\t}\n\n\t\t\t// Create new tables\n\t\t\tfor (const tableName of diff.addedTables) {\n\t\t\t\tconst tableDef = def.schema[tableName]!;\n\t\t\t\tconst qualifiedName = `${schemaName}.${tableName}`;\n\t\t\t\tconst colDefs = [\n\t\t\t\t\t`_id BIGSERIAL PRIMARY KEY`,\n\t\t\t\t\t`_block_height BIGINT NOT NULL`,\n\t\t\t\t\t`_tx_id TEXT NOT NULL`,\n\t\t\t\t\t`_created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()`,\n\t\t\t\t];\n\t\t\t\tfor (const [colName, col] of Object.entries(tableDef.columns)) {\n\t\t\t\t\tconst nullable = col.nullable ? \"\" : \" NOT NULL\";\n\t\t\t\t\tcolDefs.push(`${colName} ${TYPE_MAP[col.type]!}${nullable}`);\n\t\t\t\t}\n\t\t\t\tawait sql\n\t\t\t\t\t.raw(\n\t\t\t\t\t\t`CREATE TABLE IF NOT EXISTS ${qualifiedName} (\\n ${colDefs.join(\",\\n \")}\\n)`,\n\t\t\t\t\t)\n\t\t\t\t\t.execute(db);\n\t\t\t\tawait sql\n\t\t\t\t\t.raw(\n\t\t\t\t\t\t`CREATE INDEX IF NOT EXISTS idx_${schemaName}_${tableName}_block_height ON ${qualifiedName} (_block_height)`,\n\t\t\t\t\t)\n\t\t\t\t\t.execute(db);\n\t\t\t\tawait sql\n\t\t\t\t\t.raw(\n\t\t\t\t\t\t`CREATE INDEX IF NOT EXISTS idx_${schemaName}_${tableName}_tx_id ON ${qualifiedName} (_tx_id)`,\n\t\t\t\t\t)\n\t\t\t\t\t.execute(db);\n\t\t\t\tfor (const [colName, col] of Object.entries(tableDef.columns)) {\n\t\t\t\t\tif (col.indexed) {\n\t\t\t\t\t\tawait sql\n\t\t\t\t\t\t\t.raw(\n\t\t\t\t\t\t\t\t`CREATE INDEX IF NOT EXISTS idx_${schemaName}_${tableName}_${colName} ON ${qualifiedName} (${colName})`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.execute(db);\n\t\t\t\t\t}\n\t\t\t\t\tif (col.search) {\n\t\t\t\t\t\tawait sql\n\t\t\t\t\t\t\t.raw(\n\t\t\t\t\t\t\t\t`CREATE INDEX IF NOT EXISTS idx_${schemaName}_${tableName}_${colName}_trgm ON ${qualifiedName} USING gin (${colName} gin_trgm_ops)`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.execute(db);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Add columns to existing tables\n\t\t\tfor (const [tableName, colDiff] of Object.entries(diff.tables)) {\n\t\t\t\tif (colDiff.added.length === 0) continue;\n\t\t\t\tconst qualifiedName = `${schemaName}.${tableName}`;\n\t\t\t\tconst tableDef = def.schema[tableName]!;\n\t\t\t\tfor (const colName of colDiff.added) {\n\t\t\t\t\tconst col = tableDef.columns[colName]!;\n\t\t\t\t\tconst sqlType = TYPE_MAP[col.type]!;\n\t\t\t\t\tconst nullable = col.nullable\n\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t: \" NOT NULL DEFAULT \" + getDefault(col.type);\n\t\t\t\t\tawait sql\n\t\t\t\t\t\t.raw(\n\t\t\t\t\t\t\t`ALTER TABLE ${qualifiedName} ADD COLUMN ${colName} ${sqlType}${nullable}`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.execute(db);\n\t\t\t\t\tif (col.indexed) {\n\t\t\t\t\t\tawait sql\n\t\t\t\t\t\t\t.raw(\n\t\t\t\t\t\t\t\t`CREATE INDEX IF NOT EXISTS idx_${schemaName}_${tableName}_${colName} ON ${qualifiedName} (${colName})`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.execute(db);\n\t\t\t\t\t}\n\t\t\t\t\tif (col.search) {\n\t\t\t\t\t\tawait sql\n\t\t\t\t\t\t\t.raw(\n\t\t\t\t\t\t\t\t`CREATE INDEX IF NOT EXISTS idx_${schemaName}_${tableName}_${colName}_trgm ON ${qualifiedName} USING gin (${colName} gin_trgm_ops)`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.execute(db);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst sg = await registerSubgraph(db, regData);\n\t\treturn { action: \"updated\", subgraphId: sg.id };\n\t}\n\n\t// New subgraph — execute all DDL\n\tfor (const stmt of statements) {\n\t\tawait sql.raw(stmt).execute(db);\n\t}\n\n\tconst sg = await registerSubgraph(db, regData);\n\treturn { action: \"created\", subgraphId: sg.id };\n}\n\nfunction getDefault(type: string): string {\n\tswitch (type) {\n\t\tcase \"text\":\n\t\tcase \"principal\":\n\t\t\treturn \"''\";\n\t\tcase \"uint\":\n\t\tcase \"int\":\n\t\t\treturn \"0\";\n\t\tcase \"boolean\":\n\t\t\treturn \"false\";\n\t\tcase \"timestamp\":\n\t\t\treturn \"NOW()\";\n\t\tcase \"jsonb\":\n\t\t\treturn \"'{}'\";\n\t\tdefault:\n\t\t\treturn \"''\";\n\t}\n}\n"
|
|
9
9
|
],
|
|
10
|
-
"mappings": ";;;;AAAA;
|
|
11
|
-
"debugId": "
|
|
10
|
+
"mappings": ";;;;AAAA;AASO,IAAM,qBAAwC,EACnD,OAAO,EACP,IAAI,CAAC,EACL,IAAI,EAAE,EACN,MACA,qBACA,mFACD;AAEM,IAAM,mBAA0C,EAAE,KAAK;AAAA,EAC7D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAC;AAEM,IAAM,uBAAkD,EAAE,OAAO;AAAA,EACvE,MAAM;AAAA,EACN,UAAU,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC/B,SAAS,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC9B,QAAQ,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC7B,SAAS,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,G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