@latticexyz/store-indexer 2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2 → 2.2.18-c44207f620a38653497b78db0b71f5de7bc1a940
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/bin/postgres-decoded-indexer.js +1 -92
- package/dist/bin/postgres-decoded-indexer.js.map +1 -1
- package/dist/bin/postgres-frontend.js +5 -258
- package/dist/bin/postgres-frontend.js.map +1 -1
- package/dist/bin/postgres-indexer.js +1 -106
- package/dist/bin/postgres-indexer.js.map +1 -1
- package/dist/bin/sqlite-indexer.js +1 -243
- package/dist/bin/sqlite-indexer.js.map +1 -1
- package/dist/chunk-7O2ZWWUX.js +2 -0
- package/dist/{chunk-SJLOWI5M.js.map → chunk-7O2ZWWUX.js.map} +1 -1
- package/dist/chunk-AYPBOJNL.js +2 -0
- package/dist/{chunk-GDNGJPVT.js.map → chunk-AYPBOJNL.js.map} +1 -1
- package/dist/chunk-ED45N3IT.js +2 -0
- package/dist/{chunk-O4XAWAXU.js.map → chunk-ED45N3IT.js.map} +1 -1
- package/dist/chunk-JDWVOODJ.js +2 -0
- package/dist/{chunk-R7UQFYRA.js.map → chunk-JDWVOODJ.js.map} +1 -1
- package/dist/chunk-O2SDU7EQ.js +7 -0
- package/dist/{chunk-L5CWEDU6.js.map → chunk-O2SDU7EQ.js.map} +1 -1
- package/dist/chunk-R7HX5BT2.js +2 -0
- package/dist/{chunk-66BWQNF7.js.map → chunk-R7HX5BT2.js.map} +1 -1
- package/dist/chunk-YQ7E5W26.js +2 -0
- package/dist/{chunk-CGE4ONKA.js.map → chunk-YQ7E5W26.js.map} +1 -1
- package/dist/healthcheck-57YETUEX.js +2 -0
- package/dist/helloWorld-4VT4FZ7F.js +2 -0
- package/dist/metrics-4BMCDEZZ.js +2 -0
- package/package.json +9 -17
- package/dist/bin/postgres-decoded-indexer.cjs +0 -322
- package/dist/bin/postgres-decoded-indexer.cjs.map +0 -1
- package/dist/bin/postgres-decoded-indexer.d.cts +0 -1
- package/dist/bin/postgres-frontend.cjs +0 -567
- package/dist/bin/postgres-frontend.cjs.map +0 -1
- package/dist/bin/postgres-frontend.d.cts +0 -1
- package/dist/bin/postgres-indexer.cjs +0 -368
- package/dist/bin/postgres-indexer.cjs.map +0 -1
- package/dist/bin/postgres-indexer.d.cts +0 -1
- package/dist/bin/sqlite-indexer.cjs +0 -567
- package/dist/bin/sqlite-indexer.cjs.map +0 -1
- package/dist/bin/sqlite-indexer.d.cts +0 -1
- package/dist/chunk-66BWQNF7.js +0 -38
- package/dist/chunk-CGE4ONKA.js +0 -44
- package/dist/chunk-GDNGJPVT.js +0 -16
- package/dist/chunk-L5CWEDU6.js +0 -53
- package/dist/chunk-O4XAWAXU.js +0 -72
- package/dist/chunk-R7UQFYRA.js +0 -99
- package/dist/chunk-SJLOWI5M.js +0 -31
- package/dist/healthcheck-2DQWYXPX.js +0 -7
- package/dist/helloWorld-6IXGINV6.js +0 -7
- package/dist/index.cjs +0 -2
- package/dist/index.d.cts +0 -2
- package/dist/metrics-HO5SO4EX.js +0 -7
- package/dist/metrics-HO5SO4EX.js.map +0 -1
- /package/dist/{healthcheck-2DQWYXPX.js.map → healthcheck-57YETUEX.js.map} +0 -0
- /package/dist/{helloWorld-6IXGINV6.js.map → helloWorld-4VT4FZ7F.js.map} +0 -0
- /package/dist/{index.cjs.map → metrics-4BMCDEZZ.js.map} +0 -0
package/dist/chunk-66BWQNF7.js
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
// src/koa-middleware/compress.ts
|
2
|
-
import { Stream } from "node:stream";
|
3
|
-
import accepts from "accepts";
|
4
|
-
import { createBrotliCompress, createDeflate, createGzip } from "node:zlib";
|
5
|
-
import { includes } from "@latticexyz/common/utils";
|
6
|
-
var encodings = {
|
7
|
-
br: createBrotliCompress,
|
8
|
-
gzip: createGzip,
|
9
|
-
deflate: createDeflate
|
10
|
-
};
|
11
|
-
var encodingNames = Object.keys(encodings);
|
12
|
-
function flushEvery(stream, bytesThreshold) {
|
13
|
-
let bytesSinceFlush = 0;
|
14
|
-
stream.on("data", (data) => {
|
15
|
-
bytesSinceFlush += data.length;
|
16
|
-
if (bytesSinceFlush > bytesThreshold) {
|
17
|
-
bytesSinceFlush = 0;
|
18
|
-
stream.flush();
|
19
|
-
}
|
20
|
-
});
|
21
|
-
return stream;
|
22
|
-
}
|
23
|
-
function compress({ flushThreshold = 1024 * 4 } = {}) {
|
24
|
-
return async function compressMiddleware(ctx, next) {
|
25
|
-
ctx.vary("Accept-Encoding");
|
26
|
-
await next();
|
27
|
-
const encoding = accepts(ctx.req).encoding(encodingNames);
|
28
|
-
if (!includes(encodingNames, encoding)) return;
|
29
|
-
const compressed = flushEvery(encodings[encoding](), flushThreshold);
|
30
|
-
ctx.set("Content-Encoding", encoding);
|
31
|
-
ctx.body = ctx.body instanceof Stream ? ctx.body.pipe(compressed) : compressed.end(ctx.body);
|
32
|
-
};
|
33
|
-
}
|
34
|
-
|
35
|
-
export {
|
36
|
-
compress
|
37
|
-
};
|
38
|
-
//# sourceMappingURL=chunk-66BWQNF7.js.map
|
package/dist/chunk-CGE4ONKA.js
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
// src/bin/getClientOptions.ts
|
2
|
-
import { createClient, fallback, http, webSocket } from "viem";
|
3
|
-
import { isDefined } from "@latticexyz/common/utils";
|
4
|
-
import { getChainId } from "viem/actions";
|
5
|
-
async function getClientOptions(env) {
|
6
|
-
if (env.INTERNAL__VALIDATE_BLOCK_RANGE) {
|
7
|
-
const rpcHttpUrl = env.RPC_HTTP_URL;
|
8
|
-
if (!rpcHttpUrl) {
|
9
|
-
throw new Error("Must provide RPC_HTTP_URL when using INTERNAL__VALIDATE_BLOCK_RANGE.");
|
10
|
-
}
|
11
|
-
const chainId = await getChainId(createClient({ transport: http(rpcHttpUrl) }));
|
12
|
-
const chain = {
|
13
|
-
id: chainId,
|
14
|
-
name: "Unknown",
|
15
|
-
nativeCurrency: { decimals: 18, name: "Ether", symbol: "ETH" },
|
16
|
-
rpcUrls: { default: { http: [rpcHttpUrl] } }
|
17
|
-
};
|
18
|
-
return {
|
19
|
-
internal_clientOptions: {
|
20
|
-
chain,
|
21
|
-
pollingInterval: env.POLLING_INTERVAL,
|
22
|
-
validateBlockRange: env.INTERNAL__VALIDATE_BLOCK_RANGE
|
23
|
-
}
|
24
|
-
};
|
25
|
-
}
|
26
|
-
const transport = fallback(
|
27
|
-
[
|
28
|
-
// prefer WS when specified
|
29
|
-
env.RPC_WS_URL ? webSocket(env.RPC_WS_URL) : void 0,
|
30
|
-
// otherwise use or fallback to HTTP
|
31
|
-
env.RPC_HTTP_URL ? http(env.RPC_HTTP_URL) : void 0
|
32
|
-
].filter(isDefined)
|
33
|
-
);
|
34
|
-
const publicClient = createClient({
|
35
|
-
transport,
|
36
|
-
pollingInterval: env.POLLING_INTERVAL
|
37
|
-
});
|
38
|
-
return { publicClient };
|
39
|
-
}
|
40
|
-
|
41
|
-
export {
|
42
|
-
getClientOptions
|
43
|
-
};
|
44
|
-
//# sourceMappingURL=chunk-CGE4ONKA.js.map
|
package/dist/chunk-GDNGJPVT.js
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
// src/koa-middleware/helloWorld.ts
|
2
|
-
function helloWorld() {
|
3
|
-
return async function helloWorldMiddleware(ctx, next) {
|
4
|
-
if (ctx.path === "/") {
|
5
|
-
ctx.status = 200;
|
6
|
-
ctx.body = "emit HelloWorld();";
|
7
|
-
return;
|
8
|
-
}
|
9
|
-
await next();
|
10
|
-
};
|
11
|
-
}
|
12
|
-
|
13
|
-
export {
|
14
|
-
helloWorld
|
15
|
-
};
|
16
|
-
//# sourceMappingURL=chunk-GDNGJPVT.js.map
|
package/dist/chunk-L5CWEDU6.js
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
// src/bin/parseEnv.ts
|
2
|
-
import { isHex } from "viem";
|
3
|
-
import { z, ZodError } from "zod";
|
4
|
-
var frontendEnvSchema = z.object({
|
5
|
-
HOST: z.string().default("0.0.0.0"),
|
6
|
-
PORT: z.coerce.number().positive().default(3001)
|
7
|
-
});
|
8
|
-
var indexerEnvSchema = z.intersection(
|
9
|
-
z.object({
|
10
|
-
FOLLOW_BLOCK_TAG: z.enum(["latest", "safe", "finalized"]).default("safe"),
|
11
|
-
START_BLOCK: z.coerce.bigint().nonnegative().default(0n),
|
12
|
-
MAX_BLOCK_RANGE: z.coerce.bigint().positive().default(1000n),
|
13
|
-
POLLING_INTERVAL: z.coerce.number().positive().default(1e3),
|
14
|
-
STORE_ADDRESS: z.string().optional().transform((input) => input === "" ? void 0 : input).refine(isHexOrUndefined),
|
15
|
-
INTERNAL__VALIDATE_BLOCK_RANGE: z.string().optional().transform((input) => input === "true" || input === "1")
|
16
|
-
}),
|
17
|
-
z.union([
|
18
|
-
z.object({
|
19
|
-
RPC_HTTP_URL: z.string(),
|
20
|
-
RPC_WS_URL: z.string().optional()
|
21
|
-
}),
|
22
|
-
z.object({
|
23
|
-
RPC_HTTP_URL: z.string().optional(),
|
24
|
-
RPC_WS_URL: z.string()
|
25
|
-
})
|
26
|
-
])
|
27
|
-
);
|
28
|
-
function parseEnv(envSchema) {
|
29
|
-
try {
|
30
|
-
return envSchema.parse(process.env);
|
31
|
-
} catch (error) {
|
32
|
-
if (error instanceof ZodError) {
|
33
|
-
const { ...invalidEnvVars } = error.format();
|
34
|
-
console.error(`
|
35
|
-
Missing or invalid environment variables:
|
36
|
-
|
37
|
-
${Object.keys(invalidEnvVars).join("\n ")}
|
38
|
-
`);
|
39
|
-
process.exit(1);
|
40
|
-
}
|
41
|
-
throw error;
|
42
|
-
}
|
43
|
-
}
|
44
|
-
function isHexOrUndefined(input) {
|
45
|
-
return input === void 0 || isHex(input);
|
46
|
-
}
|
47
|
-
|
48
|
-
export {
|
49
|
-
frontendEnvSchema,
|
50
|
-
indexerEnvSchema,
|
51
|
-
parseEnv
|
52
|
-
};
|
53
|
-
//# sourceMappingURL=chunk-L5CWEDU6.js.map
|
package/dist/chunk-O4XAWAXU.js
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
// src/koa-middleware/metrics.ts
|
2
|
-
import promClient from "prom-client";
|
3
|
-
function metrics({
|
4
|
-
isHealthy,
|
5
|
-
isReady,
|
6
|
-
getLatestStoredBlockNumber,
|
7
|
-
getDistanceFromFollowBlock,
|
8
|
-
followBlockTag
|
9
|
-
} = {}) {
|
10
|
-
promClient.collectDefaultMetrics();
|
11
|
-
if (isHealthy != null) {
|
12
|
-
new promClient.Gauge({
|
13
|
-
name: "health_status",
|
14
|
-
help: "Health status (0 = unhealthy, 1 = healthy)",
|
15
|
-
collect() {
|
16
|
-
this.set(Number(isHealthy()));
|
17
|
-
}
|
18
|
-
});
|
19
|
-
}
|
20
|
-
if (isReady != null) {
|
21
|
-
new promClient.Gauge({
|
22
|
-
name: "readiness_status",
|
23
|
-
help: "Readiness status (whether the service is ready to receive requests, 0 = not ready, 1 = ready)",
|
24
|
-
collect() {
|
25
|
-
this.set(Number(isReady()));
|
26
|
-
}
|
27
|
-
});
|
28
|
-
}
|
29
|
-
if (getLatestStoredBlockNumber != null) {
|
30
|
-
new promClient.Gauge({
|
31
|
-
name: "latest_stored_block_number",
|
32
|
-
help: "Latest block number stored in the database",
|
33
|
-
async collect() {
|
34
|
-
this.set(Number(await getLatestStoredBlockNumber()));
|
35
|
-
}
|
36
|
-
});
|
37
|
-
}
|
38
|
-
if (followBlockTag != null) {
|
39
|
-
const blockTagGauge = new promClient.Gauge({
|
40
|
-
name: "follow_block_tag",
|
41
|
-
help: "Block tag the indexer is following (0 = finalized, 1 = safe, 2 = latest)"
|
42
|
-
});
|
43
|
-
const blockTagToValue = {
|
44
|
-
finalized: 0,
|
45
|
-
safe: 1,
|
46
|
-
latest: 2
|
47
|
-
};
|
48
|
-
blockTagGauge.set(blockTagToValue[followBlockTag]);
|
49
|
-
}
|
50
|
-
if (getDistanceFromFollowBlock != null) {
|
51
|
-
new promClient.Gauge({
|
52
|
-
name: "distance_from_follow_block",
|
53
|
-
help: "Block distance from the block tag this the indexer is following",
|
54
|
-
async collect() {
|
55
|
-
this.set(Number(await getDistanceFromFollowBlock()));
|
56
|
-
}
|
57
|
-
});
|
58
|
-
}
|
59
|
-
return async function metricsMiddleware(ctx, next) {
|
60
|
-
if (ctx.path === "/metrics") {
|
61
|
-
ctx.status = 200;
|
62
|
-
ctx.body = await promClient.register.metrics();
|
63
|
-
return;
|
64
|
-
}
|
65
|
-
await next();
|
66
|
-
};
|
67
|
-
}
|
68
|
-
|
69
|
-
export {
|
70
|
-
metrics
|
71
|
-
};
|
72
|
-
//# sourceMappingURL=chunk-O4XAWAXU.js.map
|
package/dist/chunk-R7UQFYRA.js
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
// src/koa-middleware/sentry.ts
|
2
|
-
import * as Sentry from "@sentry/node";
|
3
|
-
import { ProfilingIntegration } from "@sentry/profiling-node";
|
4
|
-
import { stripUrlQueryAndFragment } from "@sentry/utils";
|
5
|
-
|
6
|
-
// src/debug.ts
|
7
|
-
import createDebug from "debug";
|
8
|
-
var debug = createDebug("mud:store-indexer");
|
9
|
-
var error = createDebug("mud:store-indexer");
|
10
|
-
debug.log = console.debug.bind(console);
|
11
|
-
error.log = console.error.bind(console);
|
12
|
-
|
13
|
-
// src/koa-middleware/sentry.ts
|
14
|
-
import compose from "koa-compose";
|
15
|
-
function errorHandler() {
|
16
|
-
return async function errorHandlerMiddleware(ctx, next) {
|
17
|
-
try {
|
18
|
-
await next();
|
19
|
-
} catch (err) {
|
20
|
-
Sentry.withScope((scope) => {
|
21
|
-
scope.addEventProcessor((event) => {
|
22
|
-
return Sentry.addRequestDataToEvent(event, ctx.request);
|
23
|
-
});
|
24
|
-
Sentry.captureException(err);
|
25
|
-
});
|
26
|
-
throw err;
|
27
|
-
}
|
28
|
-
};
|
29
|
-
}
|
30
|
-
function requestHandler() {
|
31
|
-
return async function requestHandlerMiddleware(ctx, next) {
|
32
|
-
await Sentry.runWithAsyncContext(async () => {
|
33
|
-
const hub = Sentry.getCurrentHub();
|
34
|
-
hub.configureScope(
|
35
|
-
(scope) => scope.addEventProcessor(
|
36
|
-
(event) => Sentry.addRequestDataToEvent(event, ctx.request, {
|
37
|
-
include: {
|
38
|
-
user: false
|
39
|
-
}
|
40
|
-
})
|
41
|
-
)
|
42
|
-
);
|
43
|
-
await next();
|
44
|
-
});
|
45
|
-
};
|
46
|
-
}
|
47
|
-
function tracing() {
|
48
|
-
return async function tracingMiddleware(ctx, next) {
|
49
|
-
const reqMethod = (ctx.method || "").toUpperCase();
|
50
|
-
const reqUrl = ctx.url && stripUrlQueryAndFragment(ctx.url);
|
51
|
-
let traceparentData;
|
52
|
-
if (ctx.request.get("sentry-trace")) {
|
53
|
-
traceparentData = Sentry.extractTraceparentData(ctx.request.get("sentry-trace"));
|
54
|
-
}
|
55
|
-
const transaction = Sentry.startTransaction({
|
56
|
-
name: `${reqMethod} ${reqUrl}`,
|
57
|
-
op: "http.server",
|
58
|
-
...traceparentData
|
59
|
-
});
|
60
|
-
ctx.__sentry_transaction = transaction;
|
61
|
-
Sentry.getCurrentHub().configureScope((scope) => {
|
62
|
-
scope.setSpan(transaction);
|
63
|
-
});
|
64
|
-
ctx.res.on("finish", () => {
|
65
|
-
setImmediate(() => {
|
66
|
-
if (ctx._matchedRoute) {
|
67
|
-
const mountPath = ctx.mountPath || "";
|
68
|
-
transaction.setName(`${reqMethod} ${mountPath}${ctx._matchedRoute}`);
|
69
|
-
}
|
70
|
-
transaction.setHttpStatus(ctx.status);
|
71
|
-
transaction.finish();
|
72
|
-
});
|
73
|
-
});
|
74
|
-
await next();
|
75
|
-
};
|
76
|
-
}
|
77
|
-
function sentry(dsn) {
|
78
|
-
debug("Initializing Sentry");
|
79
|
-
Sentry.init({
|
80
|
-
dsn,
|
81
|
-
integrations: [
|
82
|
-
// Automatically instrument Node.js libraries and frameworks
|
83
|
-
...Sentry.autoDiscoverNodePerformanceMonitoringIntegrations(),
|
84
|
-
new ProfilingIntegration()
|
85
|
-
],
|
86
|
-
// Performance Monitoring
|
87
|
-
tracesSampleRate: 1,
|
88
|
-
// Set sampling rate for profiling - this is relative to tracesSampleRate
|
89
|
-
profilesSampleRate: 1
|
90
|
-
});
|
91
|
-
return compose([errorHandler(), requestHandler(), tracing()]);
|
92
|
-
}
|
93
|
-
|
94
|
-
export {
|
95
|
-
debug,
|
96
|
-
error,
|
97
|
-
sentry
|
98
|
-
};
|
99
|
-
//# sourceMappingURL=chunk-R7UQFYRA.js.map
|
package/dist/chunk-SJLOWI5M.js
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
// src/koa-middleware/healthcheck.ts
|
2
|
-
function healthcheck({ isHealthy, isReady } = {}) {
|
3
|
-
return async function healthcheckMiddleware(ctx, next) {
|
4
|
-
if (ctx.path === "/healthz") {
|
5
|
-
if (isHealthy == null || isHealthy()) {
|
6
|
-
ctx.status = 200;
|
7
|
-
ctx.body = "healthy";
|
8
|
-
} else {
|
9
|
-
ctx.status = 503;
|
10
|
-
ctx.body = "not healthy";
|
11
|
-
}
|
12
|
-
return;
|
13
|
-
}
|
14
|
-
if (ctx.path === "/readyz") {
|
15
|
-
if (isReady == null || isReady()) {
|
16
|
-
ctx.status = 200;
|
17
|
-
ctx.body = "ready";
|
18
|
-
} else {
|
19
|
-
ctx.status = 503;
|
20
|
-
ctx.body = "not ready";
|
21
|
-
}
|
22
|
-
return;
|
23
|
-
}
|
24
|
-
await next();
|
25
|
-
};
|
26
|
-
}
|
27
|
-
|
28
|
-
export {
|
29
|
-
healthcheck
|
30
|
-
};
|
31
|
-
//# sourceMappingURL=chunk-SJLOWI5M.js.map
|
package/dist/index.cjs
DELETED
package/dist/index.d.cts
DELETED
package/dist/metrics-HO5SO4EX.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
File without changes
|
File without changes
|
File without changes
|