@secondlayer/subgraphs 3.15.0 → 3.15.2
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.js +18 -10
- package/dist/src/index.js.map +5 -5
- package/dist/src/runtime/block-processor.js +10 -3
- package/dist/src/runtime/block-processor.js.map +4 -4
- package/dist/src/runtime/catchup.js +10 -3
- package/dist/src/runtime/catchup.js.map +4 -4
- package/dist/src/runtime/context.js +9 -2
- package/dist/src/runtime/context.js.map +3 -3
- package/dist/src/runtime/processor.js +13 -5
- package/dist/src/runtime/processor.js.map +6 -6
- package/dist/src/runtime/reindex.js +10 -3
- package/dist/src/runtime/reindex.js.map +4 -4
- package/dist/src/runtime/reorg.js +12 -4
- package/dist/src/runtime/reorg.js.map +5 -5
- package/dist/src/runtime/replay.js +2 -2
- package/dist/src/runtime/replay.js.map +2 -2
- package/dist/src/schema/index.js +9 -8
- package/dist/src/schema/index.js.map +3 -3
- package/dist/src/service.js +13 -5
- package/dist/src/service.js.map +6 -6
- package/dist/src/validate.d.ts +8 -1
- package/dist/src/validate.js +10 -8
- package/dist/src/validate.js.map +3 -3
- package/package.json +2 -2
package/dist/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
4
4
|
// src/validate.ts
|
|
5
5
|
import { z } from "zod/v4";
|
|
6
6
|
var SubgraphNameSchema = z.string().min(1).max(63).regex(/^[a-z][a-z0-9-]*$/, "Must start with lowercase letter, contain only lowercase alphanumeric and hyphens");
|
|
7
|
+
var SqlIdentifierSchema = z.string().min(1).max(63).regex(/^[a-z_][a-z0-9_]*$/i, "Must be a valid SQL identifier: start with a letter or underscore, then letters/digits/underscores only");
|
|
7
8
|
var ColumnTypeSchema = z.enum([
|
|
8
9
|
"text",
|
|
9
10
|
"uint",
|
|
@@ -21,17 +22,17 @@ var SubgraphColumnSchema = z.object({
|
|
|
21
22
|
default: z.union([z.string(), z.number(), z.boolean()]).optional()
|
|
22
23
|
});
|
|
23
24
|
var SubgraphTableSchema = z.object({
|
|
24
|
-
columns: z.record(
|
|
25
|
-
indexes: z.array(z.array(
|
|
26
|
-
uniqueKeys: z.array(z.array(
|
|
25
|
+
columns: z.record(SqlIdentifierSchema, SubgraphColumnSchema).refine((c) => Object.keys(c).length > 0, "Table must have at least one column"),
|
|
26
|
+
indexes: z.array(z.array(SqlIdentifierSchema)).optional(),
|
|
27
|
+
uniqueKeys: z.array(z.array(SqlIdentifierSchema)).optional(),
|
|
27
28
|
relations: z.array(z.object({
|
|
28
29
|
name: z.string(),
|
|
29
|
-
references:
|
|
30
|
-
fields: z.array(
|
|
31
|
-
referencedColumns: z.array(
|
|
30
|
+
references: SqlIdentifierSchema,
|
|
31
|
+
fields: z.array(SqlIdentifierSchema).min(1),
|
|
32
|
+
referencedColumns: z.array(SqlIdentifierSchema).min(1)
|
|
32
33
|
})).optional()
|
|
33
34
|
});
|
|
34
|
-
var SubgraphSchemaSchema = z.record(
|
|
35
|
+
var SubgraphSchemaSchema = z.record(SqlIdentifierSchema, SubgraphTableSchema).refine((s) => Object.keys(s).length > 0, "Schema must have at least one table");
|
|
35
36
|
var VALID_FILTER_TYPES = [
|
|
36
37
|
"stx_transfer",
|
|
37
38
|
"stx_mint",
|
|
@@ -359,6 +360,8 @@ class SubgraphContext {
|
|
|
359
360
|
return this.overlayMany(table, where, dbRows);
|
|
360
361
|
}
|
|
361
362
|
overlayOne(table, where, dbRow) {
|
|
363
|
+
if (this.ops.length === 0)
|
|
364
|
+
return dbRow;
|
|
362
365
|
let row = dbRow;
|
|
363
366
|
for (const op of this.ops) {
|
|
364
367
|
if (op.table !== table)
|
|
@@ -368,12 +371,17 @@ class SubgraphContext {
|
|
|
368
371
|
return row;
|
|
369
372
|
}
|
|
370
373
|
overlayMany(table, where, dbRows) {
|
|
374
|
+
if (this.ops.length === 0)
|
|
375
|
+
return [...dbRows];
|
|
371
376
|
let result = [...dbRows];
|
|
372
377
|
for (const op of this.ops) {
|
|
373
378
|
if (op.table !== table)
|
|
374
379
|
continue;
|
|
375
380
|
if (op.kind === "update") {
|
|
376
|
-
|
|
381
|
+
for (let i = 0;i < result.length; i++) {
|
|
382
|
+
if (rowMatches(result[i], op.data))
|
|
383
|
+
result[i] = { ...result[i], ...op.set ?? {} };
|
|
384
|
+
}
|
|
377
385
|
} else if (op.kind === "delete") {
|
|
378
386
|
result = result.filter((r) => !rowMatches(r, op.data));
|
|
379
387
|
} else {
|
|
@@ -1752,7 +1760,7 @@ function buildHttpClient() {
|
|
|
1752
1760
|
return new IndexHttpClient({
|
|
1753
1761
|
indexBaseUrl: baseUrl,
|
|
1754
1762
|
streamsBaseUrl: baseUrl,
|
|
1755
|
-
streamsApiKey: process.env.STREAMS_INTERNAL_API_KEY ?? "sk-
|
|
1763
|
+
streamsApiKey: process.env.STREAMS_INTERNAL_API_KEY ?? "sk-sl_streams_decode_internal"
|
|
1756
1764
|
});
|
|
1757
1765
|
}
|
|
1758
1766
|
function resolveBlockSource(subgraph) {
|
|
@@ -4029,5 +4037,5 @@ export {
|
|
|
4029
4037
|
ByoBreakingChangeError
|
|
4030
4038
|
};
|
|
4031
4039
|
|
|
4032
|
-
//# debugId=
|
|
4040
|
+
//# debugId=D13A7E4F60723ACE64756E2164756E21
|
|
4033
4041
|
//# sourceMappingURL=index.js.map
|