@latticexyz/store-indexer 2.0.0-skystrife-playtest-9e9511d4 → 2.0.0-transaction-context-324984c5
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 +61 -0
- package/dist/bin/postgres-decoded-indexer.js +3 -0
- package/dist/bin/postgres-decoded-indexer.js.map +1 -0
- package/dist/bin/postgres-frontend.js +31 -0
- package/dist/bin/postgres-frontend.js.map +1 -0
- package/dist/bin/postgres-indexer.js +3 -0
- package/dist/bin/postgres-indexer.js.map +1 -0
- package/dist/bin/sqlite-indexer.js +3 -0
- package/dist/bin/sqlite-indexer.js.map +1 -0
- package/dist/chunk-2E5MDUA2.js +7 -0
- package/dist/chunk-2E5MDUA2.js.map +1 -0
- package/dist/chunk-KDDXIBYJ.js +2 -0
- package/dist/chunk-KDDXIBYJ.js.map +1 -0
- package/dist/chunk-LCVFDVT2.js +2 -0
- package/dist/chunk-LCVFDVT2.js.map +1 -0
- package/dist/chunk-OUZYPRYF.js +2 -0
- package/dist/chunk-OUZYPRYF.js.map +1 -0
- package/dist/chunk-ZS3IQEZ4.js +2 -0
- package/dist/chunk-ZS3IQEZ4.js.map +1 -0
- package/dist/healthcheck-7XXWJH5U.js +2 -0
- package/dist/helloWorld-BMBNVEA7.js +2 -0
- package/dist/helloWorld-BMBNVEA7.js.map +1 -0
- package/dist/src/index.js.map +1 -0
- package/package.json +41 -21
- package/src/debug.ts +7 -0
- package/src/koa-middleware/compress.ts +48 -0
- package/src/koa-middleware/healthcheck.ts +37 -0
- package/src/koa-middleware/helloWorld.ts +12 -0
- package/src/koa-middleware/sentry.ts +101 -0
- package/src/postgres/apiRoutes.ts +58 -0
- package/src/postgres/common.ts +21 -0
- package/src/postgres/deprecated/createQueryAdapter.ts +56 -0
- package/src/postgres/deprecated/getLogs.ts +81 -0
- package/src/postgres/queryLogs.ts +71 -0
- package/src/postgres/recordToLog.ts +19 -0
- package/src/sqlite/apiRoutes.ts +47 -0
- package/src/sqlite/createQueryAdapter.ts +9 -119
- package/src/sqlite/getTablesWithRecords.ts +75 -0
- package/src/postgres/createQueryAdapter.ts +0 -54
- /package/dist/{index.js.map → healthcheck-7XXWJH5U.js.map} +0 -0
- /package/dist/{index.js → src/index.js} +0 -0
@@ -1,54 +0,0 @@
|
|
1
|
-
import { eq } from "drizzle-orm";
|
2
|
-
import { PgDatabase } from "drizzle-orm/pg-core";
|
3
|
-
import { buildTable, buildInternalTables, getTables } from "@latticexyz/store-sync/postgres";
|
4
|
-
import { QueryAdapter } from "@latticexyz/store-sync/trpc-indexer";
|
5
|
-
import { debug } from "../debug";
|
6
|
-
import { getAddress } from "viem";
|
7
|
-
|
8
|
-
/**
|
9
|
-
* Creates a query adapter for the tRPC server/client to query data from Postgres.
|
10
|
-
*
|
11
|
-
* @param {PgDatabase<any>} database Postgres database object from Drizzle
|
12
|
-
* @returns {Promise<QueryAdapter>} A set of methods used by tRPC endpoints.
|
13
|
-
*/
|
14
|
-
export async function createQueryAdapter(database: PgDatabase<any>): Promise<QueryAdapter> {
|
15
|
-
const adapter: QueryAdapter = {
|
16
|
-
async findAll({ chainId, address, tableIds }) {
|
17
|
-
const internalTables = buildInternalTables();
|
18
|
-
const tables = (await getTables(database))
|
19
|
-
.filter((table) => address == null || getAddress(address) === getAddress(table.address))
|
20
|
-
.filter((table) => tableIds == null || tableIds.includes(table.tableId));
|
21
|
-
|
22
|
-
const tablesWithRecords = await Promise.all(
|
23
|
-
tables.map(async (table) => {
|
24
|
-
const sqliteTable = buildTable(table);
|
25
|
-
const records = await database.select().from(sqliteTable).where(eq(sqliteTable.__isDeleted, false)).execute();
|
26
|
-
return {
|
27
|
-
...table,
|
28
|
-
records: records.map((record) => ({
|
29
|
-
key: Object.fromEntries(Object.entries(table.keySchema).map(([name]) => [name, record[name]])),
|
30
|
-
value: Object.fromEntries(Object.entries(table.valueSchema).map(([name]) => [name, record[name]])),
|
31
|
-
})),
|
32
|
-
};
|
33
|
-
})
|
34
|
-
);
|
35
|
-
|
36
|
-
const metadata = await database
|
37
|
-
.select()
|
38
|
-
.from(internalTables.chain)
|
39
|
-
.where(eq(internalTables.chain.chainId, chainId))
|
40
|
-
.execute();
|
41
|
-
const { lastUpdatedBlockNumber } = metadata[0] ?? {};
|
42
|
-
|
43
|
-
const result = {
|
44
|
-
blockNumber: lastUpdatedBlockNumber ?? null,
|
45
|
-
tables: tablesWithRecords,
|
46
|
-
};
|
47
|
-
|
48
|
-
debug("findAll", chainId, address, result);
|
49
|
-
|
50
|
-
return result;
|
51
|
-
},
|
52
|
-
};
|
53
|
-
return adapter;
|
54
|
-
}
|
File without changes
|
File without changes
|