@secondlayer/subgraphs 4.0.3 → 4.0.5
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/README.md +2 -4
- package/dist/src/index.js +9 -14
- package/dist/src/index.js.map +7 -7
- package/dist/src/runtime/block-processor.js +3 -8
- package/dist/src/runtime/block-processor.js.map +3 -3
- package/dist/src/runtime/catchup.js +3 -8
- package/dist/src/runtime/catchup.js.map +3 -3
- package/dist/src/runtime/processor.js +7 -15
- package/dist/src/runtime/processor.js.map +4 -4
- package/dist/src/runtime/reindex.js +3 -8
- package/dist/src/runtime/reindex.js.map +3 -3
- package/dist/src/runtime/reorg.js +3 -8
- package/dist/src/runtime/reorg.js.map +3 -3
- package/dist/src/runtime/replay.js +3 -8
- package/dist/src/runtime/replay.js.map +3 -3
- package/dist/src/service.js +7 -15
- package/dist/src/service.js.map +4 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Typed on-chain indexing for Stacks. Declare event filters + column schema with `defineSubgraph()`; the runtime decodes blocks, matches filters, runs your handlers inside a transactional context, and exposes the result as a Postgres schema you query over REST or SQL.
|
|
4
4
|
|
|
5
|
-
Subgraphs have a visibility: deploys default `visibility: public` — anon-readable at `/v1/subgraphs/<name>/<table>`, in a single global public namespace (409 `PUBLIC_NAME_TAKEN` if the name is taken). Override with `--visibility public|private` at deploy.
|
|
6
|
-
|
|
7
5
|
Subgraph rows fan out to HTTP subscribers through a post-flush outbox emitter — signed Standard Webhooks POSTs with retries, circuit breaker, and replay.
|
|
8
6
|
|
|
9
7
|
## Install
|
|
@@ -102,8 +100,8 @@ Delivery bodies and response previews land in `subscription_deliveries`. Rows wh
|
|
|
102
100
|
Once rows land in your DB, generate a typed schema for your ORM:
|
|
103
101
|
|
|
104
102
|
```bash
|
|
105
|
-
secondlayer
|
|
106
|
-
secondlayer
|
|
103
|
+
secondlayer codegen subgraph subgraphs/my.ts --target prisma -o prisma/schema.prisma
|
|
104
|
+
secondlayer codegen subgraph subgraphs/my.ts --target drizzle -o db/schema.ts
|
|
107
105
|
```
|
|
108
106
|
|
|
109
107
|
Prisma and Drizzle have first-class generators (`generatePrismaSchema` /
|
package/dist/src/index.js
CHANGED
|
@@ -1883,7 +1883,7 @@ import { sql as sql3 } from "kysely";
|
|
|
1883
1883
|
// src/runtime/block-source.ts
|
|
1884
1884
|
import { getSourceDb as getSourceDb2 } from "@secondlayer/shared/db";
|
|
1885
1885
|
import {
|
|
1886
|
-
|
|
1886
|
+
createInternalIndexHttpClient
|
|
1887
1887
|
} from "@secondlayer/shared/index-http";
|
|
1888
1888
|
import { logger as logger4 } from "@secondlayer/shared/logger";
|
|
1889
1889
|
|
|
@@ -2239,12 +2239,7 @@ class FallbackBlockSource {
|
|
|
2239
2239
|
}
|
|
2240
2240
|
var postgresBlockSource = new PostgresBlockSource;
|
|
2241
2241
|
function buildHttpClient() {
|
|
2242
|
-
|
|
2243
|
-
return new IndexHttpClient({
|
|
2244
|
-
indexBaseUrl: baseUrl,
|
|
2245
|
-
streamsBaseUrl: baseUrl,
|
|
2246
|
-
streamsApiKey: process.env.STREAMS_INTERNAL_API_KEY ?? "sk-sl_streams_decode_internal"
|
|
2247
|
-
});
|
|
2242
|
+
return createInternalIndexHttpClient();
|
|
2248
2243
|
}
|
|
2249
2244
|
function resolveBlockSource(subgraph) {
|
|
2250
2245
|
if (process.env.SUBGRAPH_SOURCE === "streams-index" && subgraph && isStreamsIndexEligible(subgraph)) {
|
|
@@ -4461,7 +4456,7 @@ function generatePrismaSchema(def, opts = {}) {
|
|
|
4461
4456
|
const schemaName = opts.schemaName ?? pgSchemaName(def.name);
|
|
4462
4457
|
const env = opts.datasourceEnv ?? "DATABASE_URL";
|
|
4463
4458
|
const header = [
|
|
4464
|
-
`// Generated by \`sl
|
|
4459
|
+
`// Generated by \`sl codegen subgraph --target prisma\` from subgraph "${def.name}". Do not edit by hand.`,
|
|
4465
4460
|
"",
|
|
4466
4461
|
"datasource db {",
|
|
4467
4462
|
' provider = "postgresql"',
|
|
@@ -4614,7 +4609,7 @@ function generateDrizzleSchema(def, opts = {}) {
|
|
|
4614
4609
|
const relationDecls = renderRelations(def.schema);
|
|
4615
4610
|
const typeExports = Object.keys(def.schema).map((name) => `export type ${pascalCase(name)} = typeof ${snakeToCamel(name)}.$inferSelect;`);
|
|
4616
4611
|
return [
|
|
4617
|
-
`// Generated by \`sl
|
|
4612
|
+
`// Generated by \`sl codegen subgraph --target drizzle\` from subgraph "${def.name}". Do not edit by hand.`,
|
|
4618
4613
|
imports,
|
|
4619
4614
|
"",
|
|
4620
4615
|
`export const sg = pgSchema("${schemaName}");`,
|
|
@@ -4673,7 +4668,7 @@ ${dbEntries.join(`
|
|
|
4673
4668
|
}`;
|
|
4674
4669
|
const rowExports = Object.keys(def.schema).map((name) => `export type ${pascalCase(name)}Row = Selectable<${pascalCase(name)}>;`);
|
|
4675
4670
|
return [
|
|
4676
|
-
`// Generated by \`sl
|
|
4671
|
+
`// Generated by \`sl codegen subgraph --target kysely\` from subgraph "${def.name}". Do not edit by hand.`,
|
|
4677
4672
|
`import type { Generated, Selectable } from "kysely";`,
|
|
4678
4673
|
"",
|
|
4679
4674
|
interfaces.join(`
|
|
@@ -4728,7 +4723,7 @@ ${lines.join(`
|
|
|
4728
4723
|
});
|
|
4729
4724
|
const rows = entries.map(([table]) => `export type ${pascalCase(table)}Row = Selectable<${pascalCase(table)}>;`);
|
|
4730
4725
|
return [
|
|
4731
|
-
"// Generated by `sl index
|
|
4726
|
+
"// Generated by `sl codegen index --target kysely`. Do not edit by hand.",
|
|
4732
4727
|
`import type { Selectable } from "kysely";`,
|
|
4733
4728
|
"",
|
|
4734
4729
|
interfaces.join(`
|
|
@@ -4784,7 +4779,7 @@ ${lines.join(`
|
|
|
4784
4779
|
});
|
|
4785
4780
|
const rows = entries.map(([table]) => `export type ${pascalCase(table)} = typeof ${snakeToCamel(table)}.$inferSelect;`);
|
|
4786
4781
|
return [
|
|
4787
|
-
"// Generated by `sl index
|
|
4782
|
+
"// Generated by `sl codegen index --target drizzle`. Do not edit by hand.",
|
|
4788
4783
|
`import { ${[...used].sort().join(", ")} } from "drizzle-orm/pg-core";`,
|
|
4789
4784
|
"",
|
|
4790
4785
|
...schemaName ? [`export const sg = pgSchema("${schemaName}");`, ""] : [],
|
|
@@ -4881,7 +4876,7 @@ ${block.join(`
|
|
|
4881
4876
|
}`);
|
|
4882
4877
|
}
|
|
4883
4878
|
const header = [
|
|
4884
|
-
"// Generated by `sl index
|
|
4879
|
+
"// Generated by `sl codegen index --target prisma`. Do not edit by hand.",
|
|
4885
4880
|
...skipped.length ? [
|
|
4886
4881
|
`// Omitted (no read-set primary key, query via another target): ${skipped.join(", ")}`
|
|
4887
4882
|
] : [],
|
|
@@ -5272,5 +5267,5 @@ export {
|
|
|
5272
5267
|
ChainReadError
|
|
5273
5268
|
};
|
|
5274
5269
|
|
|
5275
|
-
//# debugId=
|
|
5270
|
+
//# debugId=EAAE2F38AEB249FD64756E2164756E21
|
|
5276
5271
|
//# sourceMappingURL=index.js.map
|