@secondlayer/shared 0.2.3 → 0.3.0
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/db/index.d.ts +3 -1
- package/dist/src/db/index.js.map +2 -2
- package/dist/src/db/jsonb.d.ts +2 -1
- package/dist/src/db/jsonb.js.map +2 -2
- package/dist/src/db/queries/accounts.d.ts +2 -1
- package/dist/src/db/queries/accounts.js.map +2 -2
- package/dist/src/db/queries/integrity.d.ts +1 -0
- package/dist/src/db/queries/metrics.d.ts +6 -4
- package/dist/src/db/queries/metrics.js.map +2 -2
- package/dist/src/db/queries/usage.d.ts +1 -0
- package/dist/src/db/queries/views.d.ts +10 -8
- package/dist/src/db/queries/views.js.map +3 -3
- package/dist/src/db/schema.d.ts +1 -0
- package/dist/src/env.d.ts +9 -2
- package/dist/src/env.js.map +2 -2
- package/dist/src/errors.d.ts +15 -2
- package/dist/src/errors.js +7 -2
- package/dist/src/errors.js.map +3 -3
- package/dist/src/index.d.ts +217 -54
- package/dist/src/index.js +12 -6
- package/dist/src/index.js.map +10 -10
- package/dist/src/logger.d.ts +4 -4
- package/dist/src/logger.js.map +3 -3
- package/dist/src/node/hiro-client.js +2 -2
- package/dist/src/node/hiro-client.js.map +5 -5
- package/dist/src/node/local-client.d.ts +212 -0
- package/dist/src/node/local-client.js +70 -0
- package/dist/src/node/local-client.js.map +10 -0
- package/dist/src/queue/index.d.ts +1 -1
- package/dist/src/queue/index.js.map +3 -3
- package/dist/src/queue/recovery.js.map +2 -2
- package/dist/src/schemas/filters.d.ts +92 -28
- package/dist/src/schemas/filters.js.map +2 -2
- package/dist/src/schemas/index.d.ts +186 -43
- package/dist/src/schemas/index.js +6 -5
- package/dist/src/schemas/index.js.map +5 -5
- package/dist/src/schemas/views.d.ts +14 -3
- package/dist/src/schemas/views.js.map +2 -2
- package/dist/src/types.d.ts +9 -3
- package/dist/src/types.js +12 -1
- package/dist/src/types.js.map +1 -1
- package/migrations/0006_tx_index.ts +9 -0
- package/package.json +6 -3
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
interface DeployViewRequest {
|
|
3
|
+
name: string;
|
|
4
|
+
version?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
sources: string[];
|
|
7
|
+
schema: Record<string, unknown>;
|
|
8
|
+
handlerCode: string;
|
|
9
|
+
reindex?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const DeployViewRequestSchema: z.ZodType<DeployViewRequest>;
|
|
4
12
|
interface DeployViewResponse {
|
|
5
13
|
action: "created" | "unchanged" | "updated" | "reindexed";
|
|
6
14
|
viewId: string;
|
|
@@ -28,7 +36,10 @@ interface ViewDetail {
|
|
|
28
36
|
};
|
|
29
37
|
tables: Record<string, {
|
|
30
38
|
endpoint: string
|
|
31
|
-
columns: Record<string,
|
|
39
|
+
columns: Record<string, {
|
|
40
|
+
type: string
|
|
41
|
+
nullable?: boolean
|
|
42
|
+
}>
|
|
32
43
|
rowCount: number
|
|
33
44
|
example: string
|
|
34
45
|
}>;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/schemas/views.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { z } from \"zod\";\n\n// ── Deploy View Request ─────────────────────────────────────────────────\n\nexport const DeployViewRequestSchema = z.object({\n name: z.string().regex(/^[a-z0-9-]+$/, \"lowercase alphanumeric + hyphens only\").max(63),\n version: z.string().optional(),\n description: z.string().optional(),\n sources: z.array(z.string()).min(1),\n schema: z.record(z.unknown()),\n handlerCode: z.string().max(1_048_576, \"handler code exceeds 1MB limit\"),\n reindex: z.boolean().optional(),\n});\n\nexport
|
|
5
|
+
"import { z } from \"zod\";\n\n// ── Deploy View Request ─────────────────────────────────────────────────\n\nexport interface DeployViewRequest {\n name: string;\n version?: string;\n description?: string;\n sources: string[];\n schema: Record<string, unknown>;\n handlerCode: string;\n reindex?: boolean;\n}\n\nexport const DeployViewRequestSchema: z.ZodType<DeployViewRequest> = z.object({\n name: z.string().regex(/^[a-z0-9-]+$/, \"lowercase alphanumeric + hyphens only\").max(63),\n version: z.string().optional(),\n description: z.string().optional(),\n sources: z.array(z.string()).min(1),\n schema: z.record(z.unknown()),\n handlerCode: z.string().max(1_048_576, \"handler code exceeds 1MB limit\"),\n reindex: z.boolean().optional(),\n});\n\nexport interface DeployViewResponse {\n action: \"created\" | \"unchanged\" | \"updated\" | \"reindexed\";\n viewId: string;\n message: string;\n}\n\n// View API response types\n\nexport interface ViewSummary {\n name: string;\n version: string;\n status: string;\n lastProcessedBlock: number;\n tables: string[];\n createdAt: string;\n}\n\nexport interface ViewDetail {\n name: string;\n version: string;\n status: string;\n lastProcessedBlock: number;\n health: {\n totalProcessed: number;\n totalErrors: number;\n errorRate: number;\n lastError: string | null;\n lastErrorAt: string | null;\n };\n tables: Record<string, {\n endpoint: string;\n columns: Record<string, { type: string; nullable?: boolean }>;\n rowCount: number;\n example: string;\n }>;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface ReindexResponse {\n message: string;\n fromBlock: number;\n toBlock: number | string;\n}\n\nexport interface ViewQueryParams {\n sort?: string;\n order?: string;\n limit?: number;\n offset?: number;\n fields?: string;\n filters?: Record<string, string>;\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";;;;;;;;;;;;;AAAA;
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;AAAA;AAcO,IAAM,0BAAwD,EAAE,OAAO;AAAA,EAC5E,MAAM,EAAE,OAAO,EAAE,MAAM,gBAAgB,uCAAuC,EAAE,IAAI,EAAE;AAAA,EACtF,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC;AAAA,EAClC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC;AAAA,EAC5B,aAAa,EAAE,OAAO,EAAE,IAAI,SAAW,gCAAgC;AAAA,EACvE,SAAS,EAAE,QAAQ,EAAE,SAAS;AAChC,CAAC;",
|
|
8
8
|
"debugId": "F7D47497A7667C0064756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ interface BlocksTable {
|
|
|
11
11
|
interface TransactionsTable {
|
|
12
12
|
tx_id: string;
|
|
13
13
|
block_height: number;
|
|
14
|
+
tx_index: Generated<number>;
|
|
14
15
|
type: string;
|
|
15
16
|
sender: string;
|
|
16
17
|
status: string;
|
|
@@ -87,9 +88,14 @@ type IndexProgress = Selectable<IndexProgressTable>;
|
|
|
87
88
|
type InsertIndexProgress = Insertable<IndexProgressTable>;
|
|
88
89
|
type Delivery = Selectable<DeliveriesTable>;
|
|
89
90
|
type InsertDelivery = Insertable<DeliveriesTable>;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
interface EnvSchemaOutput {
|
|
92
|
+
DATABASE_URL?: string;
|
|
93
|
+
NETWORK?: "mainnet" | "testnet";
|
|
94
|
+
NETWORKS?: ("mainnet" | "testnet")[];
|
|
95
|
+
LOG_LEVEL: "debug" | "info" | "warn" | "error";
|
|
96
|
+
NODE_ENV: "development" | "production" | "test";
|
|
97
|
+
}
|
|
98
|
+
type Env = EnvSchemaOutput & {
|
|
93
99
|
enabledNetworks: ("mainnet" | "testnet")[]
|
|
94
100
|
};
|
|
95
101
|
interface QueueStats {
|
package/dist/src/types.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
set: (newValue) => all[name] = () => newValue
|
|
10
|
+
});
|
|
11
|
+
};
|
|
1
12
|
|
|
2
|
-
//# debugId=
|
|
13
|
+
//# debugId=6E26BDBC1FE19BB464756E2164756E21
|
|
3
14
|
//# sourceMappingURL=types.js.map
|
package/dist/src/types.js.map
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Kysely, sql } from "kysely";
|
|
2
|
+
|
|
3
|
+
export async function up(db: Kysely<any>): Promise<void> {
|
|
4
|
+
await sql`ALTER TABLE transactions ADD COLUMN IF NOT EXISTS tx_index INTEGER NOT NULL DEFAULT 0`.execute(db);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export async function down(db: Kysely<any>): Promise<void> {
|
|
8
|
+
await sql`ALTER TABLE transactions DROP COLUMN IF EXISTS tx_index`.execute(db);
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secondlayer/shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/src/index.js",
|
|
6
6
|
"types": "./dist/src/index.d.ts",
|
|
@@ -100,6 +100,10 @@
|
|
|
100
100
|
"./node/hiro-client": {
|
|
101
101
|
"types": "./dist/src/node/hiro-client.d.ts",
|
|
102
102
|
"import": "./dist/src/node/hiro-client.js"
|
|
103
|
+
},
|
|
104
|
+
"./node/local-client": {
|
|
105
|
+
"types": "./dist/src/node/local-client.d.ts",
|
|
106
|
+
"import": "./dist/src/node/local-client.js"
|
|
103
107
|
}
|
|
104
108
|
},
|
|
105
109
|
"files": [
|
|
@@ -113,11 +117,10 @@
|
|
|
113
117
|
"typecheck": "tsc --noEmit",
|
|
114
118
|
"migrate": "bun run src/db/migrate.ts",
|
|
115
119
|
"seed": "DATABASE_URL=${DATABASE_URL:-postgresql://ryanwaits@127.0.0.1:5432/streams_dev} bun run src/db/seed.ts",
|
|
116
|
-
"console": "DATABASE_URL=${DATABASE_URL:-postgresql://ryanwaits@127.0.0.1:5432/streams_dev} bun run src/console.ts",
|
|
117
120
|
"prepublishOnly": "bun run build"
|
|
118
121
|
},
|
|
119
122
|
"dependencies": {
|
|
120
|
-
"@secondlayer/stacks": "
|
|
123
|
+
"@secondlayer/stacks": "^0.1.0",
|
|
121
124
|
"kysely": "0.28.10",
|
|
122
125
|
"kysely-postgres-js": "3.0.0",
|
|
123
126
|
"postgres": "^3.4.6",
|