@secondlayer/shared 0.10.1 → 0.11.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 +181 -2
- package/dist/src/db/queries/accounts.d.ts +158 -2
- package/dist/src/db/queries/accounts.js +17 -1
- package/dist/src/db/queries/accounts.js.map +3 -3
- package/dist/src/db/queries/integrity.d.ts +151 -1
- package/dist/src/db/queries/marketplace.d.ts +463 -0
- package/dist/src/db/queries/marketplace.js +142 -0
- package/dist/src/db/queries/marketplace.js.map +10 -0
- package/dist/src/db/queries/metrics.d.ts +151 -1
- package/dist/src/db/queries/projects.d.ts +423 -0
- package/dist/src/db/queries/projects.js +47 -0
- package/dist/src/db/queries/projects.js.map +10 -0
- package/dist/src/db/queries/subgraph-gaps.d.ts +151 -1
- package/dist/src/db/queries/subgraphs.d.ts +158 -6
- package/dist/src/db/queries/subgraphs.js +16 -13
- package/dist/src/db/queries/subgraphs.js.map +3 -3
- package/dist/src/db/queries/usage.d.ts +151 -1
- package/dist/src/db/queries/workflows.d.ts +439 -0
- package/dist/src/db/queries/workflows.js +115 -0
- package/dist/src/db/queries/workflows.js.map +11 -0
- package/dist/src/db/schema.d.ts +181 -2
- package/dist/src/index.d.ts +251 -10
- package/dist/src/index.js +91 -72
- package/dist/src/index.js.map +4 -3
- package/dist/src/node/hiro-pg-client.js +5 -3
- package/dist/src/node/hiro-pg-client.js.map +3 -3
- package/dist/src/node/local-client.d.ts +155 -1
- package/dist/src/node/local-client.js +19 -9
- package/dist/src/node/local-client.js.map +3 -3
- package/dist/src/schemas/index.d.ts +71 -9
- package/dist/src/schemas/index.js +93 -74
- package/dist/src/schemas/index.js.map +4 -3
- package/dist/src/schemas/marketplace.d.ts +63 -0
- package/dist/src/schemas/marketplace.js +39 -0
- package/dist/src/schemas/marketplace.js.map +10 -0
- package/dist/src/schemas/workflows.d.ts +66 -0
- package/dist/src/schemas/workflows.js +39 -0
- package/dist/src/schemas/workflows.js.map +10 -0
- package/dist/src/types.d.ts +3 -0
- package/migrations/0021_tx_function_args_result.ts +27 -0
- package/migrations/0022_marketplace.ts +88 -0
- package/migrations/0023_projects.ts +149 -0
- package/migrations/0024_chat_sessions.ts +51 -0
- package/migrations/0025_chat_session_summary.ts +15 -0
- package/migrations/0026_workflows.ts +204 -0
- package/migrations/0027_workflow_cursors.ts +16 -0
- package/migrations/0028_subgraph_account_scoping.ts +116 -0
- package/package.json +22 -2
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// src/db/queries/marketplace.ts
|
|
18
|
+
import { sql } from "kysely";
|
|
19
|
+
async function listPublicSubgraphs(db, opts = {}) {
|
|
20
|
+
const limit = Math.min(Math.max(1, opts.limit ?? 50), 100);
|
|
21
|
+
const offset = Math.max(0, opts.offset ?? 0);
|
|
22
|
+
let query = db.selectFrom("subgraphs").innerJoin("api_keys", "api_keys.id", "subgraphs.api_key_id").innerJoin("accounts", "accounts.id", "api_keys.account_id").select([
|
|
23
|
+
"subgraphs.id",
|
|
24
|
+
"subgraphs.name",
|
|
25
|
+
"subgraphs.description",
|
|
26
|
+
"subgraphs.tags",
|
|
27
|
+
"subgraphs.status",
|
|
28
|
+
"subgraphs.version",
|
|
29
|
+
"subgraphs.definition",
|
|
30
|
+
"subgraphs.last_processed_block",
|
|
31
|
+
"subgraphs.start_block",
|
|
32
|
+
"subgraphs.total_processed",
|
|
33
|
+
"subgraphs.created_at",
|
|
34
|
+
"subgraphs.forked_from_id",
|
|
35
|
+
"accounts.display_name",
|
|
36
|
+
"accounts.slug",
|
|
37
|
+
sql`(SELECT COALESCE(SUM(query_count), 0) FROM subgraph_usage_daily WHERE subgraph_id = subgraphs.id AND date >= CURRENT_DATE - 7)::int`.as("queries_7d"),
|
|
38
|
+
sql`(SELECT COUNT(*) FROM subgraphs s2 WHERE s2.forked_from_id = subgraphs.id)::int`.as("fork_count")
|
|
39
|
+
]).where("subgraphs.is_public", "=", true);
|
|
40
|
+
if (opts.tags && opts.tags.length > 0) {
|
|
41
|
+
query = query.where(sql`subgraphs.tags @> ${sql.val(opts.tags)}::text[]`);
|
|
42
|
+
}
|
|
43
|
+
if (opts.search) {
|
|
44
|
+
const term = `%${opts.search}%`;
|
|
45
|
+
query = query.where((eb) => eb.or([
|
|
46
|
+
eb("subgraphs.name", "ilike", term),
|
|
47
|
+
eb("subgraphs.description", "ilike", term)
|
|
48
|
+
]));
|
|
49
|
+
}
|
|
50
|
+
if (opts.sort === "popular") {
|
|
51
|
+
query = query.orderBy(sql`queries_7d`, "desc");
|
|
52
|
+
} else if (opts.sort === "name") {
|
|
53
|
+
query = query.orderBy("subgraphs.name", "asc");
|
|
54
|
+
} else {
|
|
55
|
+
query = query.orderBy("subgraphs.created_at", "desc");
|
|
56
|
+
}
|
|
57
|
+
let countQuery = db.selectFrom("subgraphs").select(sql`count(*)::int`.as("count")).where("is_public", "=", true);
|
|
58
|
+
if (opts.tags && opts.tags.length > 0) {
|
|
59
|
+
countQuery = countQuery.where(sql`tags @> ${sql.val(opts.tags)}::text[]`);
|
|
60
|
+
}
|
|
61
|
+
if (opts.search) {
|
|
62
|
+
const term = `%${opts.search}%`;
|
|
63
|
+
countQuery = countQuery.where((eb) => eb.or([
|
|
64
|
+
eb("name", "ilike", term),
|
|
65
|
+
eb("description", "ilike", term)
|
|
66
|
+
]));
|
|
67
|
+
}
|
|
68
|
+
const [rows, countRow] = await Promise.all([
|
|
69
|
+
query.limit(limit).offset(offset).execute(),
|
|
70
|
+
countQuery.executeTakeFirst()
|
|
71
|
+
]);
|
|
72
|
+
return {
|
|
73
|
+
data: rows,
|
|
74
|
+
meta: { total: countRow?.count ?? 0, limit, offset }
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
async function getPublicSubgraph(db, name) {
|
|
78
|
+
return db.selectFrom("subgraphs").innerJoin("api_keys", "api_keys.id", "subgraphs.api_key_id").innerJoin("accounts", "accounts.id", "api_keys.account_id").selectAll("subgraphs").select(["accounts.display_name", "accounts.slug"]).where("subgraphs.name", "=", name).where("subgraphs.is_public", "=", true).executeTakeFirst();
|
|
79
|
+
}
|
|
80
|
+
async function getCreatorProfile(db, slug) {
|
|
81
|
+
const account = await db.selectFrom("accounts").select(["id", "display_name", "bio", "avatar_url", "slug"]).where("slug", "=", slug).executeTakeFirst();
|
|
82
|
+
if (!account)
|
|
83
|
+
return null;
|
|
84
|
+
const subgraphs = await db.selectFrom("subgraphs").innerJoin("api_keys", "api_keys.id", "subgraphs.api_key_id").select([
|
|
85
|
+
"subgraphs.id",
|
|
86
|
+
"subgraphs.name",
|
|
87
|
+
"subgraphs.description",
|
|
88
|
+
"subgraphs.tags",
|
|
89
|
+
"subgraphs.status",
|
|
90
|
+
"subgraphs.version",
|
|
91
|
+
"subgraphs.definition",
|
|
92
|
+
"subgraphs.last_processed_block",
|
|
93
|
+
"subgraphs.start_block",
|
|
94
|
+
"subgraphs.total_processed",
|
|
95
|
+
"subgraphs.created_at",
|
|
96
|
+
sql`(SELECT COALESCE(SUM(query_count), 0) FROM subgraph_usage_daily WHERE subgraph_id = subgraphs.id AND date >= CURRENT_DATE - 7)::int`.as("queries_7d")
|
|
97
|
+
]).where("api_keys.account_id", "=", account.id).where("subgraphs.is_public", "=", true).orderBy("subgraphs.created_at", "desc").execute();
|
|
98
|
+
return { account, subgraphs };
|
|
99
|
+
}
|
|
100
|
+
async function publishSubgraph(db, subgraphId, opts) {
|
|
101
|
+
const set = {
|
|
102
|
+
is_public: true,
|
|
103
|
+
updated_at: new Date
|
|
104
|
+
};
|
|
105
|
+
if (opts?.tags)
|
|
106
|
+
set.tags = sql`${sql.val(opts.tags)}::text[]`;
|
|
107
|
+
if (opts?.description !== undefined)
|
|
108
|
+
set.description = opts.description;
|
|
109
|
+
return db.updateTable("subgraphs").set(set).where("id", "=", subgraphId).returningAll().executeTakeFirstOrThrow();
|
|
110
|
+
}
|
|
111
|
+
async function unpublishSubgraph(db, subgraphId) {
|
|
112
|
+
return db.updateTable("subgraphs").set({ is_public: false, updated_at: new Date }).where("id", "=", subgraphId).returningAll().executeTakeFirstOrThrow();
|
|
113
|
+
}
|
|
114
|
+
async function incrementSubgraphQueryCount(db, subgraphId) {
|
|
115
|
+
const today = new Date().toISOString().slice(0, 10);
|
|
116
|
+
await sql`
|
|
117
|
+
INSERT INTO subgraph_usage_daily (subgraph_id, date, query_count)
|
|
118
|
+
VALUES (${subgraphId}, ${today}, 1)
|
|
119
|
+
ON CONFLICT (subgraph_id, date)
|
|
120
|
+
DO UPDATE SET query_count = subgraph_usage_daily.query_count + 1
|
|
121
|
+
`.execute(db);
|
|
122
|
+
}
|
|
123
|
+
async function getSubgraphUsageHistory(db, subgraphId, days) {
|
|
124
|
+
return db.selectFrom("subgraph_usage_daily").select(["date", "query_count"]).where("subgraph_id", "=", subgraphId).where("date", ">=", sql`CURRENT_DATE - ${days}::int`).orderBy("date", "asc").execute();
|
|
125
|
+
}
|
|
126
|
+
async function getSubgraphQueryTotal(db, subgraphId, days) {
|
|
127
|
+
const row = await db.selectFrom("subgraph_usage_daily").select(sql`COALESCE(SUM(query_count), 0)::int`.as("total")).where("subgraph_id", "=", subgraphId).where("date", ">=", sql`CURRENT_DATE - ${days}::int`).executeTakeFirst();
|
|
128
|
+
return row?.total ?? 0;
|
|
129
|
+
}
|
|
130
|
+
export {
|
|
131
|
+
unpublishSubgraph,
|
|
132
|
+
publishSubgraph,
|
|
133
|
+
listPublicSubgraphs,
|
|
134
|
+
incrementSubgraphQueryCount,
|
|
135
|
+
getSubgraphUsageHistory,
|
|
136
|
+
getSubgraphQueryTotal,
|
|
137
|
+
getPublicSubgraph,
|
|
138
|
+
getCreatorProfile
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
//# debugId=3D863C761F66BE2664756E2164756E21
|
|
142
|
+
//# sourceMappingURL=marketplace.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/db/queries/marketplace.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { type Kysely, sql } from \"kysely\";\nimport type { Database, Subgraph } from \"../types.ts\";\n\n/**\n * List public subgraphs with creator info and usage stats.\n */\nexport async function listPublicSubgraphs(\n\tdb: Kysely<Database>,\n\topts: {\n\t\tlimit?: number;\n\t\toffset?: number;\n\t\ttags?: string[];\n\t\tsearch?: string;\n\t\tsort?: \"recent\" | \"popular\" | \"name\";\n\t} = {},\n): Promise<{ data: any[]; meta: { total: number; limit: number; offset: number } }> {\n\tconst limit = Math.min(Math.max(1, opts.limit ?? 50), 100);\n\tconst offset = Math.max(0, opts.offset ?? 0);\n\n\tlet query = db\n\t\t.selectFrom(\"subgraphs\")\n\t\t.innerJoin(\"api_keys\", \"api_keys.id\", \"subgraphs.api_key_id\")\n\t\t.innerJoin(\"accounts\", \"accounts.id\", \"api_keys.account_id\")\n\t\t.select([\n\t\t\t\"subgraphs.id\",\n\t\t\t\"subgraphs.name\",\n\t\t\t\"subgraphs.description\",\n\t\t\t\"subgraphs.tags\",\n\t\t\t\"subgraphs.status\",\n\t\t\t\"subgraphs.version\",\n\t\t\t\"subgraphs.definition\",\n\t\t\t\"subgraphs.last_processed_block\",\n\t\t\t\"subgraphs.start_block\",\n\t\t\t\"subgraphs.total_processed\",\n\t\t\t\"subgraphs.created_at\",\n\t\t\t\"subgraphs.forked_from_id\",\n\t\t\t\"accounts.display_name\",\n\t\t\t\"accounts.slug\",\n\t\t\tsql<number>`(SELECT COALESCE(SUM(query_count), 0) FROM subgraph_usage_daily WHERE subgraph_id = subgraphs.id AND date >= CURRENT_DATE - 7)::int`.as(\"queries_7d\"),\n\t\t\tsql<number>`(SELECT COUNT(*) FROM subgraphs s2 WHERE s2.forked_from_id = subgraphs.id)::int`.as(\"fork_count\"),\n\t\t])\n\t\t.where(\"subgraphs.is_public\", \"=\", true);\n\n\t// Filter by tags (AND — all must match)\n\tif (opts.tags && opts.tags.length > 0) {\n\t\tquery = query.where(\n\t\t\tsql<boolean>`subgraphs.tags @> ${sql.val(opts.tags)}::text[]`,\n\t\t);\n\t}\n\n\t// Search by name or description\n\tif (opts.search) {\n\t\tconst term = `%${opts.search}%`;\n\t\tquery = query.where((eb) =>\n\t\t\teb.or([\n\t\t\t\teb(\"subgraphs.name\", \"ilike\", term),\n\t\t\t\teb(\"subgraphs.description\", \"ilike\", term),\n\t\t\t]),\n\t\t);\n\t}\n\n\t// Sort\n\tif (opts.sort === \"popular\") {\n\t\tquery = query.orderBy(sql`queries_7d`, \"desc\");\n\t} else if (opts.sort === \"name\") {\n\t\tquery = query.orderBy(\"subgraphs.name\", \"asc\");\n\t} else {\n\t\t// Default: recent\n\t\tquery = query.orderBy(\"subgraphs.created_at\", \"desc\");\n\t}\n\n\t// Count\n\tlet countQuery = db\n\t\t.selectFrom(\"subgraphs\")\n\t\t.select(sql<number>`count(*)::int`.as(\"count\"))\n\t\t.where(\"is_public\", \"=\", true);\n\n\tif (opts.tags && opts.tags.length > 0) {\n\t\tcountQuery = countQuery.where(\n\t\t\tsql<boolean>`tags @> ${sql.val(opts.tags)}::text[]`,\n\t\t);\n\t}\n\tif (opts.search) {\n\t\tconst term = `%${opts.search}%`;\n\t\tcountQuery = countQuery.where((eb) =>\n\t\t\teb.or([\n\t\t\t\teb(\"name\", \"ilike\", term),\n\t\t\t\teb(\"description\", \"ilike\", term),\n\t\t\t]),\n\t\t);\n\t}\n\n\tconst [rows, countRow] = await Promise.all([\n\t\tquery.limit(limit).offset(offset).execute(),\n\t\tcountQuery.executeTakeFirst(),\n\t]);\n\n\treturn {\n\t\tdata: rows,\n\t\tmeta: { total: countRow?.count ?? 0, limit, offset },\n\t};\n}\n\n/**\n * Get a single public subgraph by name with creator info.\n */\nexport async function getPublicSubgraph(db: Kysely<Database>, name: string): Promise<any | undefined> {\n\treturn db\n\t\t.selectFrom(\"subgraphs\")\n\t\t.innerJoin(\"api_keys\", \"api_keys.id\", \"subgraphs.api_key_id\")\n\t\t.innerJoin(\"accounts\", \"accounts.id\", \"api_keys.account_id\")\n\t\t.selectAll(\"subgraphs\")\n\t\t.select([\"accounts.display_name\", \"accounts.slug\"])\n\t\t.where(\"subgraphs.name\", \"=\", name)\n\t\t.where(\"subgraphs.is_public\", \"=\", true)\n\t\t.executeTakeFirst();\n}\n\n/**\n * Get a creator profile by slug with their public subgraphs.\n */\nexport async function getCreatorProfile(db: Kysely<Database>, slug: string): Promise<{ account: any; subgraphs: any[] } | null> {\n\tconst account = await db\n\t\t.selectFrom(\"accounts\")\n\t\t.select([\"id\", \"display_name\", \"bio\", \"avatar_url\", \"slug\"])\n\t\t.where(\"slug\", \"=\", slug)\n\t\t.executeTakeFirst();\n\n\tif (!account) return null;\n\n\tconst subgraphs = await db\n\t\t.selectFrom(\"subgraphs\")\n\t\t.innerJoin(\"api_keys\", \"api_keys.id\", \"subgraphs.api_key_id\")\n\t\t.select([\n\t\t\t\"subgraphs.id\",\n\t\t\t\"subgraphs.name\",\n\t\t\t\"subgraphs.description\",\n\t\t\t\"subgraphs.tags\",\n\t\t\t\"subgraphs.status\",\n\t\t\t\"subgraphs.version\",\n\t\t\t\"subgraphs.definition\",\n\t\t\t\"subgraphs.last_processed_block\",\n\t\t\t\"subgraphs.start_block\",\n\t\t\t\"subgraphs.total_processed\",\n\t\t\t\"subgraphs.created_at\",\n\t\t\tsql<number>`(SELECT COALESCE(SUM(query_count), 0) FROM subgraph_usage_daily WHERE subgraph_id = subgraphs.id AND date >= CURRENT_DATE - 7)::int`.as(\"queries_7d\"),\n\t\t])\n\t\t.where(\"api_keys.account_id\", \"=\", account.id)\n\t\t.where(\"subgraphs.is_public\", \"=\", true)\n\t\t.orderBy(\"subgraphs.created_at\", \"desc\")\n\t\t.execute();\n\n\treturn { account, subgraphs };\n}\n\n/**\n * Publish a subgraph (set is_public = true).\n */\nexport async function publishSubgraph(\n\tdb: Kysely<Database>,\n\tsubgraphId: string,\n\topts?: { tags?: string[]; description?: string },\n): Promise<Subgraph> {\n\tconst set: Record<string, unknown> = {\n\t\tis_public: true,\n\t\tupdated_at: new Date(),\n\t};\n\tif (opts?.tags) set.tags = sql`${sql.val(opts.tags)}::text[]`;\n\tif (opts?.description !== undefined) set.description = opts.description;\n\n\treturn db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set(set)\n\t\t.where(\"id\", \"=\", subgraphId)\n\t\t.returningAll()\n\t\t.executeTakeFirstOrThrow();\n}\n\n/**\n * Unpublish a subgraph (set is_public = false).\n */\nexport async function unpublishSubgraph(\n\tdb: Kysely<Database>,\n\tsubgraphId: string,\n): Promise<Subgraph> {\n\treturn db\n\t\t.updateTable(\"subgraphs\")\n\t\t.set({ is_public: false, updated_at: new Date() })\n\t\t.where(\"id\", \"=\", subgraphId)\n\t\t.returningAll()\n\t\t.executeTakeFirstOrThrow();\n}\n\n/**\n * Increment per-subgraph query count for today. Fire-and-forget safe.\n */\nexport async function incrementSubgraphQueryCount(\n\tdb: Kysely<Database>,\n\tsubgraphId: string,\n): Promise<void> {\n\tconst today = new Date().toISOString().slice(0, 10);\n\tawait sql`\n\t\tINSERT INTO subgraph_usage_daily (subgraph_id, date, query_count)\n\t\tVALUES (${subgraphId}, ${today}, 1)\n\t\tON CONFLICT (subgraph_id, date)\n\t\tDO UPDATE SET query_count = subgraph_usage_daily.query_count + 1\n\t`.execute(db);\n}\n\n/**\n * Get daily usage history for a subgraph.\n */\nexport async function getSubgraphUsageHistory(\n\tdb: Kysely<Database>,\n\tsubgraphId: string,\n\tdays: number,\n): Promise<Array<{ date: string; query_count: number }>> {\n\treturn db\n\t\t.selectFrom(\"subgraph_usage_daily\")\n\t\t.select([\"date\", \"query_count\"])\n\t\t.where(\"subgraph_id\", \"=\", subgraphId)\n\t\t.where(\"date\", \">=\", sql<string>`CURRENT_DATE - ${days}::int`)\n\t\t.orderBy(\"date\", \"asc\")\n\t\t.execute();\n}\n\n/**\n * Get total query count for a subgraph over last N days.\n */\nexport async function getSubgraphQueryTotal(\n\tdb: Kysely<Database>,\n\tsubgraphId: string,\n\tdays: number,\n): Promise<number> {\n\tconst row = await db\n\t\t.selectFrom(\"subgraph_usage_daily\")\n\t\t.select(sql<number>`COALESCE(SUM(query_count), 0)::int`.as(\"total\"))\n\t\t.where(\"subgraph_id\", \"=\", subgraphId)\n\t\t.where(\"date\", \">=\", sql<string>`CURRENT_DATE - ${days}::int`)\n\t\t.executeTakeFirst();\n\treturn row?.total ?? 0;\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAMA,eAAsB,mBAAmB,CACxC,IACA,OAMI,CAAC,GAC8E;AAAA,EACnF,MAAM,QAAQ,KAAK,IAAI,KAAK,IAAI,GAAG,KAAK,SAAS,EAAE,GAAG,GAAG;AAAA,EACzD,MAAM,SAAS,KAAK,IAAI,GAAG,KAAK,UAAU,CAAC;AAAA,EAE3C,IAAI,QAAQ,GACV,WAAW,WAAW,EACtB,UAAU,YAAY,eAAe,sBAAsB,EAC3D,UAAU,YAAY,eAAe,qBAAqB,EAC1D,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,yIAAiJ,GAAG,YAAY;AAAA,IAChK,qFAA6F,GAAG,YAAY;AAAA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-18,6 +18,8 @@ interface TransactionsTable {
|
|
|
18
18
|
status: string;
|
|
19
19
|
contract_id: string | null;
|
|
20
20
|
function_name: string | null;
|
|
21
|
+
function_args: Generated<unknown | null>;
|
|
22
|
+
raw_result: Generated<string | null>;
|
|
21
23
|
raw_tx: string;
|
|
22
24
|
created_at: Generated<Date>;
|
|
23
25
|
}
|
|
@@ -39,6 +41,7 @@ interface StreamsTable {
|
|
|
39
41
|
endpoint_url: string;
|
|
40
42
|
signing_secret: string | null;
|
|
41
43
|
api_key_id: string;
|
|
44
|
+
project_id: string | null;
|
|
42
45
|
created_at: Generated<Date>;
|
|
43
46
|
updated_at: Generated<Date>;
|
|
44
47
|
}
|
|
@@ -100,7 +103,13 @@ interface SubgraphsTable {
|
|
|
100
103
|
last_error_at: Date | null;
|
|
101
104
|
total_processed: Generated<number>;
|
|
102
105
|
total_errors: Generated<number>;
|
|
103
|
-
api_key_id: string;
|
|
106
|
+
api_key_id: string | null;
|
|
107
|
+
account_id: string;
|
|
108
|
+
project_id: string | null;
|
|
109
|
+
is_public: Generated<boolean>;
|
|
110
|
+
tags: Generated<string[]>;
|
|
111
|
+
description: string | null;
|
|
112
|
+
forked_from_id: string | null;
|
|
104
113
|
created_at: Generated<Date>;
|
|
105
114
|
updated_at: Generated<Date>;
|
|
106
115
|
}
|
|
@@ -131,6 +140,10 @@ interface AccountsTable {
|
|
|
131
140
|
id: Generated<string>;
|
|
132
141
|
email: string;
|
|
133
142
|
plan: Generated<string>;
|
|
143
|
+
display_name: string | null;
|
|
144
|
+
bio: string | null;
|
|
145
|
+
avatar_url: string | null;
|
|
146
|
+
slug: string | null;
|
|
134
147
|
created_at: Generated<Date>;
|
|
135
148
|
}
|
|
136
149
|
interface SessionsTable {
|
|
@@ -231,6 +244,131 @@ interface SubgraphHealthSnapshotsTable {
|
|
|
231
244
|
last_processed_block: number | null;
|
|
232
245
|
captured_at: Generated<Date>;
|
|
233
246
|
}
|
|
247
|
+
interface SubgraphUsageDailyTable {
|
|
248
|
+
subgraph_id: string;
|
|
249
|
+
date: string;
|
|
250
|
+
query_count: Generated<number>;
|
|
251
|
+
}
|
|
252
|
+
interface ProjectsTable {
|
|
253
|
+
id: Generated<string>;
|
|
254
|
+
name: string;
|
|
255
|
+
slug: string;
|
|
256
|
+
account_id: string;
|
|
257
|
+
settings: Generated<Record<string, unknown>>;
|
|
258
|
+
network: Generated<string>;
|
|
259
|
+
node_rpc: string | null;
|
|
260
|
+
created_at: Generated<Date>;
|
|
261
|
+
updated_at: Generated<Date>;
|
|
262
|
+
}
|
|
263
|
+
interface TeamMembersTable {
|
|
264
|
+
id: Generated<string>;
|
|
265
|
+
project_id: string;
|
|
266
|
+
account_id: string;
|
|
267
|
+
role: Generated<string>;
|
|
268
|
+
invited_by: string | null;
|
|
269
|
+
created_at: Generated<Date>;
|
|
270
|
+
}
|
|
271
|
+
interface TeamInvitationsTable {
|
|
272
|
+
id: Generated<string>;
|
|
273
|
+
project_id: string;
|
|
274
|
+
email: string;
|
|
275
|
+
role: Generated<string>;
|
|
276
|
+
token: string;
|
|
277
|
+
invited_by: string | null;
|
|
278
|
+
expires_at: Date;
|
|
279
|
+
accepted_at: Date | null;
|
|
280
|
+
created_at: Generated<Date>;
|
|
281
|
+
}
|
|
282
|
+
interface ChatSessionsTable {
|
|
283
|
+
id: Generated<string>;
|
|
284
|
+
account_id: string;
|
|
285
|
+
title: string | null;
|
|
286
|
+
summary: unknown | null;
|
|
287
|
+
created_at: Generated<Date>;
|
|
288
|
+
updated_at: Generated<Date>;
|
|
289
|
+
}
|
|
290
|
+
interface ChatMessagesTable {
|
|
291
|
+
id: Generated<string>;
|
|
292
|
+
chat_session_id: string;
|
|
293
|
+
role: string;
|
|
294
|
+
parts: unknown;
|
|
295
|
+
metadata: unknown | null;
|
|
296
|
+
created_at: Generated<Date>;
|
|
297
|
+
}
|
|
298
|
+
interface WorkflowDefinitionsTable {
|
|
299
|
+
id: Generated<string>;
|
|
300
|
+
name: string;
|
|
301
|
+
version: Generated<string>;
|
|
302
|
+
status: Generated<string>;
|
|
303
|
+
trigger_type: string;
|
|
304
|
+
trigger_config: unknown;
|
|
305
|
+
handler_path: string;
|
|
306
|
+
retries_config: unknown | null;
|
|
307
|
+
timeout_ms: number | null;
|
|
308
|
+
api_key_id: string;
|
|
309
|
+
project_id: string | null;
|
|
310
|
+
created_at: Generated<Date>;
|
|
311
|
+
updated_at: Generated<Date>;
|
|
312
|
+
}
|
|
313
|
+
interface WorkflowRunsTable {
|
|
314
|
+
id: Generated<string>;
|
|
315
|
+
definition_id: string;
|
|
316
|
+
status: Generated<string>;
|
|
317
|
+
trigger_type: string;
|
|
318
|
+
trigger_data: unknown | null;
|
|
319
|
+
dedup_key: string | null;
|
|
320
|
+
error: string | null;
|
|
321
|
+
started_at: Date | null;
|
|
322
|
+
completed_at: Date | null;
|
|
323
|
+
duration_ms: number | null;
|
|
324
|
+
total_ai_tokens: Generated<number>;
|
|
325
|
+
created_at: Generated<Date>;
|
|
326
|
+
}
|
|
327
|
+
interface WorkflowStepsTable {
|
|
328
|
+
id: Generated<string>;
|
|
329
|
+
run_id: string;
|
|
330
|
+
step_index: number;
|
|
331
|
+
step_id: string;
|
|
332
|
+
step_type: string;
|
|
333
|
+
status: Generated<string>;
|
|
334
|
+
input: unknown | null;
|
|
335
|
+
output: unknown | null;
|
|
336
|
+
error: string | null;
|
|
337
|
+
retry_count: Generated<number>;
|
|
338
|
+
ai_tokens_used: Generated<number>;
|
|
339
|
+
started_at: Date | null;
|
|
340
|
+
completed_at: Date | null;
|
|
341
|
+
duration_ms: number | null;
|
|
342
|
+
created_at: Generated<Date>;
|
|
343
|
+
}
|
|
344
|
+
interface WorkflowQueueTable {
|
|
345
|
+
id: Generated<string>;
|
|
346
|
+
run_id: string;
|
|
347
|
+
status: Generated<string>;
|
|
348
|
+
attempts: Generated<number>;
|
|
349
|
+
max_attempts: Generated<number>;
|
|
350
|
+
scheduled_for: Generated<Date>;
|
|
351
|
+
locked_at: Date | null;
|
|
352
|
+
locked_by: string | null;
|
|
353
|
+
error: string | null;
|
|
354
|
+
created_at: Generated<Date>;
|
|
355
|
+
completed_at: Date | null;
|
|
356
|
+
}
|
|
357
|
+
interface WorkflowSchedulesTable {
|
|
358
|
+
id: Generated<string>;
|
|
359
|
+
definition_id: string;
|
|
360
|
+
cron_expr: string;
|
|
361
|
+
timezone: Generated<string>;
|
|
362
|
+
next_run_at: Date;
|
|
363
|
+
last_run_at: Date | null;
|
|
364
|
+
enabled: Generated<boolean>;
|
|
365
|
+
created_at: Generated<Date>;
|
|
366
|
+
}
|
|
367
|
+
interface WorkflowCursorsTable {
|
|
368
|
+
name: string;
|
|
369
|
+
block_height: Generated<number>;
|
|
370
|
+
updated_at: Generated<Date>;
|
|
371
|
+
}
|
|
234
372
|
interface Database {
|
|
235
373
|
blocks: BlocksTable;
|
|
236
374
|
transactions: TransactionsTable;
|
|
@@ -254,6 +392,18 @@ interface Database {
|
|
|
254
392
|
subgraph_processing_stats: SubgraphProcessingStatsTable;
|
|
255
393
|
subgraph_table_snapshots: SubgraphTableSnapshotsTable;
|
|
256
394
|
subgraph_gaps: SubgraphGapsTable;
|
|
395
|
+
subgraph_usage_daily: SubgraphUsageDailyTable;
|
|
396
|
+
projects: ProjectsTable;
|
|
397
|
+
team_members: TeamMembersTable;
|
|
398
|
+
team_invitations: TeamInvitationsTable;
|
|
399
|
+
chat_sessions: ChatSessionsTable;
|
|
400
|
+
chat_messages: ChatMessagesTable;
|
|
401
|
+
workflow_definitions: WorkflowDefinitionsTable;
|
|
402
|
+
workflow_runs: WorkflowRunsTable;
|
|
403
|
+
workflow_steps: WorkflowStepsTable;
|
|
404
|
+
workflow_queue: WorkflowQueueTable;
|
|
405
|
+
workflow_schedules: WorkflowSchedulesTable;
|
|
406
|
+
workflow_cursors: WorkflowCursorsTable;
|
|
257
407
|
}
|
|
258
408
|
type StreamMetrics = Selectable<StreamMetricsTable>;
|
|
259
409
|
declare function getStreamMetrics(db: Kysely<Database>, streamId: string): Promise<StreamMetrics | null>;
|