@secondlayer/shared 0.4.0 → 0.5.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/crypto/hmac.js +6 -2
- package/dist/src/crypto/hmac.js.map +2 -2
- package/dist/src/db/index.d.ts +83 -6
- package/dist/src/db/index.js +6 -2
- package/dist/src/db/index.js.map +2 -2
- package/dist/src/db/jsonb.js +6 -2
- package/dist/src/db/jsonb.js.map +2 -2
- package/dist/src/db/queries/accounts.d.ts +75 -3
- package/dist/src/db/queries/accounts.js +17 -2
- package/dist/src/db/queries/accounts.js.map +3 -3
- package/dist/src/db/queries/integrity.d.ts +73 -2
- package/dist/src/db/queries/integrity.js +6 -2
- package/dist/src/db/queries/integrity.js.map +2 -2
- package/dist/src/db/queries/metrics.d.ts +73 -2
- package/dist/src/db/queries/metrics.js +6 -2
- package/dist/src/db/queries/metrics.js.map +2 -2
- package/dist/src/db/queries/{views.d.ts → subgraphs.d.ts} +87 -16
- package/dist/src/db/queries/{views.js → subgraphs.js} +37 -33
- package/dist/src/db/queries/subgraphs.js.map +11 -0
- package/dist/src/db/queries/usage.d.ts +76 -5
- package/dist/src/db/queries/usage.js +13 -9
- package/dist/src/db/queries/usage.js.map +4 -4
- package/dist/src/db/schema.d.ts +83 -6
- package/dist/src/env.js +6 -2
- package/dist/src/env.js.map +2 -2
- package/dist/src/errors.js +6 -2
- package/dist/src/errors.js.map +2 -2
- package/dist/src/index.d.ts +90 -13
- package/dist/src/index.js +9 -5
- package/dist/src/index.js.map +4 -4
- package/dist/src/lib/plans.d.ts +1 -1
- package/dist/src/lib/plans.js +7 -3
- package/dist/src/lib/plans.js.map +3 -3
- package/dist/src/logger.js +6 -2
- package/dist/src/logger.js.map +2 -2
- package/dist/src/node/client.js +6 -2
- package/dist/src/node/client.js.map +2 -2
- package/dist/src/node/hiro-client.js +6 -2
- package/dist/src/node/hiro-client.js.map +2 -2
- package/dist/src/node/local-client.d.ts +73 -2
- package/dist/src/node/local-client.js +6 -2
- package/dist/src/node/local-client.js.map +2 -2
- package/dist/src/queue/index.js +6 -2
- package/dist/src/queue/index.js.map +2 -2
- package/dist/src/queue/listener.js +6 -2
- package/dist/src/queue/listener.js.map +2 -2
- package/dist/src/queue/recovery.js +6 -2
- package/dist/src/queue/recovery.js.map +2 -2
- package/dist/src/schemas/filters.js +6 -2
- package/dist/src/schemas/filters.js.map +2 -2
- package/dist/src/schemas/index.d.ts +8 -8
- package/dist/src/schemas/index.js +9 -5
- package/dist/src/schemas/index.js.map +4 -4
- package/dist/src/schemas/{views.d.ts → subgraphs.d.ts} +8 -8
- package/dist/src/schemas/{views.js → subgraphs.js} +10 -6
- package/dist/src/schemas/subgraphs.js.map +10 -0
- package/dist/src/types.js +1 -12
- package/dist/src/types.js.map +1 -1
- package/migrations/0009_waitlist.ts +19 -0
- package/migrations/0010_waitlist_status.ts +12 -0
- package/migrations/0011_account_insights.ts +63 -0
- package/migrations/0012_view_health_snapshots.ts +29 -0
- package/migrations/0013_view_processing_stats.ts +42 -0
- package/migrations/0014_view_table_snapshots.ts +33 -0
- package/migrations/0015_rename_views_to_subgraphs.ts +136 -0
- package/package.json +7 -7
- package/dist/src/db/queries/views.js.map +0 -11
- package/dist/src/schemas/views.js.map +0 -10
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/lib/plans.ts", "../src/db/queries/usage.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"export interface PlanLimits {\n streams: number;\n
|
|
6
|
-
"import { sql, type Kysely } from \"kysely\";\nimport type { Database } from \"../types.ts\";\nimport { getPlanLimits } from \"../../lib/plans.ts\";\n\n/** Increment API request counter for today. Fire-and-forget safe. */\nexport async function incrementApiRequests(\n db: Kysely<Database>,\n accountId: string,\n): Promise<void> {\n const today = new Date().toISOString().slice(0, 10);\n await db\n .insertInto(\"usage_daily\")\n .values({ account_id: accountId, date: today, api_requests: 1, deliveries: 0 })\n .onConflict((oc) =>\n oc.columns([\"account_id\", \"date\"]).doUpdateSet({\n api_requests: sql`usage_daily.api_requests + 1`,\n }),\n )\n .execute();\n}\n\n/** Increment delivery counter for today. */\nexport async function incrementDeliveries(\n db: Kysely<Database>,\n accountId: string,\n count = 1,\n): Promise<void> {\n const today = new Date().toISOString().slice(0, 10);\n await db\n .insertInto(\"usage_daily\")\n .values({ account_id: accountId, date: today, api_requests: 0, deliveries: count })\n .onConflict((oc) =>\n oc.columns([\"account_id\", \"date\"]).doUpdateSet({\n deliveries: sql`usage_daily.deliveries + ${count}`,\n }),\n )\n .execute();\n}\n\nexport interface UsageSummary {\n apiRequestsToday: number;\n deliveriesThisMonth: number;\n storageBytes: number;\n}\n\n/** Get current usage for an account. */\nexport async function getUsage(\n db: Kysely<Database>,\n accountId: string,\n): Promise<UsageSummary> {\n const today = new Date().toISOString().slice(0, 10);\n const monthStart = today.slice(0, 7) + \"-01\"; // YYYY-MM-01\n\n // Today's API requests\n const dailyRow = await db\n .selectFrom(\"usage_daily\")\n .select(\"api_requests\")\n .where(\"account_id\", \"=\", accountId)\n .where(\"date\", \"=\", today)\n .executeTakeFirst();\n\n // This month's deliveries\n const monthlyRow = await db\n .selectFrom(\"usage_daily\")\n .select(sql<number>`COALESCE(SUM(deliveries), 0)`.as(\"total\"))\n .where(\"account_id\", \"=\", accountId)\n .where(\"date\", \">=\", monthStart)\n .executeTakeFirst();\n\n // Latest storage snapshot\n const storageRow = await db\n .selectFrom(\"usage_snapshots\")\n .select(\"storage_bytes\")\n .where(\"account_id\", \"=\", accountId)\n .orderBy(\"measured_at\", \"desc\")\n .limit(1)\n .executeTakeFirst();\n\n return {\n apiRequestsToday: dailyRow?.api_requests ?? 0,\n deliveriesThisMonth: Number(monthlyRow?.total ?? 0),\n storageBytes: Number(storageRow?.storage_bytes ?? 0),\n };\n}\n\nexport interface LimitCheck {\n allowed: boolean;\n limits: ReturnType<typeof getPlanLimits>;\n current: UsageSummary & { streams: number;
|
|
5
|
+
"export interface PlanLimits {\n streams: number;\n subgraphs: number;\n apiRequestsPerDay: number;\n deliveriesPerMonth: number;\n storageBytes: number;\n}\n\nexport const FREE_PLAN: PlanLimits = {\n streams: 3,\n subgraphs: 2,\n apiRequestsPerDay: 1_000,\n deliveriesPerMonth: 5_000,\n storageBytes: 100 * 1024 * 1024, // 100MB\n};\n\nexport function getPlanLimits(plan: string): PlanLimits {\n switch (plan) {\n case \"free\":\n default:\n return FREE_PLAN;\n }\n}\n",
|
|
6
|
+
"import { sql, type Kysely } from \"kysely\";\nimport type { Database } from \"../types.ts\";\nimport { getPlanLimits } from \"../../lib/plans.ts\";\n\n/** Increment API request counter for today. Fire-and-forget safe. */\nexport async function incrementApiRequests(\n db: Kysely<Database>,\n accountId: string,\n): Promise<void> {\n const today = new Date().toISOString().slice(0, 10);\n await db\n .insertInto(\"usage_daily\")\n .values({ account_id: accountId, date: today, api_requests: 1, deliveries: 0 })\n .onConflict((oc) =>\n oc.columns([\"account_id\", \"date\"]).doUpdateSet({\n api_requests: sql`usage_daily.api_requests + 1`,\n }),\n )\n .execute();\n}\n\n/** Increment delivery counter for today. */\nexport async function incrementDeliveries(\n db: Kysely<Database>,\n accountId: string,\n count = 1,\n): Promise<void> {\n const today = new Date().toISOString().slice(0, 10);\n await db\n .insertInto(\"usage_daily\")\n .values({ account_id: accountId, date: today, api_requests: 0, deliveries: count })\n .onConflict((oc) =>\n oc.columns([\"account_id\", \"date\"]).doUpdateSet({\n deliveries: sql`usage_daily.deliveries + ${count}`,\n }),\n )\n .execute();\n}\n\nexport interface UsageSummary {\n apiRequestsToday: number;\n deliveriesThisMonth: number;\n storageBytes: number;\n}\n\n/** Get current usage for an account. */\nexport async function getUsage(\n db: Kysely<Database>,\n accountId: string,\n): Promise<UsageSummary> {\n const today = new Date().toISOString().slice(0, 10);\n const monthStart = today.slice(0, 7) + \"-01\"; // YYYY-MM-01\n\n // Today's API requests\n const dailyRow = await db\n .selectFrom(\"usage_daily\")\n .select(\"api_requests\")\n .where(\"account_id\", \"=\", accountId)\n .where(\"date\", \"=\", today)\n .executeTakeFirst();\n\n // This month's deliveries\n const monthlyRow = await db\n .selectFrom(\"usage_daily\")\n .select(sql<number>`COALESCE(SUM(deliveries), 0)`.as(\"total\"))\n .where(\"account_id\", \"=\", accountId)\n .where(\"date\", \">=\", monthStart)\n .executeTakeFirst();\n\n // Latest storage snapshot\n const storageRow = await db\n .selectFrom(\"usage_snapshots\")\n .select(\"storage_bytes\")\n .where(\"account_id\", \"=\", accountId)\n .orderBy(\"measured_at\", \"desc\")\n .limit(1)\n .executeTakeFirst();\n\n return {\n apiRequestsToday: dailyRow?.api_requests ?? 0,\n deliveriesThisMonth: Number(monthlyRow?.total ?? 0),\n storageBytes: Number(storageRow?.storage_bytes ?? 0),\n };\n}\n\nexport interface LimitCheck {\n allowed: boolean;\n limits: ReturnType<typeof getPlanLimits>;\n current: UsageSummary & { streams: number; subgraphs: number };\n exceeded?: string;\n}\n\n/** Check if an account is within plan limits. */\nexport async function checkLimits(\n db: Kysely<Database>,\n accountId: string,\n plan: string,\n): Promise<LimitCheck> {\n const limits = getPlanLimits(plan);\n const usage = await getUsage(db, accountId);\n\n // Count streams owned by this account's keys\n const streamCount = await db\n .selectFrom(\"streams\")\n .innerJoin(\"api_keys\", \"streams.api_key_id\", \"api_keys.id\")\n .select(sql<number>`count(*)`.as(\"count\"))\n .where(\"api_keys.account_id\", \"=\", accountId)\n .executeTakeFirst();\n\n const subgraphCount = await db\n .selectFrom(\"subgraphs\")\n .innerJoin(\"api_keys\", \"subgraphs.api_key_id\", \"api_keys.id\")\n .select(sql<number>`count(*)`.as(\"count\"))\n .where(\"api_keys.account_id\", \"=\", accountId)\n .executeTakeFirst();\n\n const current = {\n ...usage,\n streams: Number(streamCount?.count ?? 0),\n subgraphs: Number(subgraphCount?.count ?? 0),\n };\n\n // Check each limit\n if (current.streams >= limits.streams) {\n return { allowed: false, limits, current, exceeded: \"streams\" };\n }\n if (current.subgraphs >= limits.subgraphs) {\n return { allowed: false, limits, current, exceeded: \"subgraphs\" };\n }\n if (current.apiRequestsToday >= limits.apiRequestsPerDay) {\n return { allowed: false, limits, current, exceeded: \"api_requests\" };\n }\n if (current.deliveriesThisMonth >= limits.deliveriesPerMonth) {\n return { allowed: false, limits, current, exceeded: \"deliveries\" };\n }\n if (current.storageBytes >= limits.storageBytes) {\n return { allowed: false, limits, current, exceeded: \"storage\" };\n }\n\n return { allowed: true, limits, current };\n}\n\n/**\n * Measure storage for all accounts by querying pg_total_relation_size\n * for each tenant's subgraph schemas.\n */\nexport async function measureStorage(db: Kysely<Database>): Promise<void> {\n // Get all accounts with subgraphs\n const accountSubgraphs = await db\n .selectFrom(\"subgraphs\")\n .innerJoin(\"api_keys\", \"subgraphs.api_key_id\", \"api_keys.id\")\n .select([\"api_keys.account_id\", \"subgraphs.schema_name\"])\n .where(\"subgraphs.schema_name\", \"is not\", null)\n .execute();\n\n // Group schemas by account\n const byAccount = new Map<string, string[]>();\n for (const row of accountSubgraphs) {\n const schemas = byAccount.get(row.account_id) ?? [];\n if (row.schema_name) schemas.push(row.schema_name);\n byAccount.set(row.account_id, schemas);\n }\n\n for (const [accountId, schemas] of byAccount) {\n let totalBytes = 0;\n for (const schema of schemas) {\n try {\n const result = await sql<{ size: string }>`\n SELECT COALESCE(SUM(pg_total_relation_size(quote_ident(schemaname) || '.' || quote_ident(tablename))), 0)::text as size\n FROM pg_tables WHERE schemaname = ${schema}\n `.execute(db);\n totalBytes += Number((result.rows[0] as any)?.size ?? 0);\n } catch {\n // Schema may not exist\n }\n }\n\n await db\n .insertInto(\"usage_snapshots\")\n .values({\n account_id: accountId,\n storage_bytes: totalBytes,\n })\n .execute();\n }\n}\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": "
|
|
9
|
-
"debugId": "
|
|
8
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAQO,IAAM,YAAwB;AAAA,EACnC,SAAS;AAAA,EACT,WAAW;AAAA,EACX,mBAAmB;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AAAA,MACN,YAAY;AAAA,MACZ,eAAe;AAAA,IACjB,CAAC,EACA,QAAQ;AAAA,EACb;AAAA;",
|
|
9
|
+
"debugId": "31E68DFE6E6CCA6264756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
package/dist/src/db/schema.d.ts
CHANGED
|
@@ -82,7 +82,7 @@ interface DeliveriesTable {
|
|
|
82
82
|
payload: unknown;
|
|
83
83
|
created_at: Generated<Date>;
|
|
84
84
|
}
|
|
85
|
-
interface
|
|
85
|
+
interface SubgraphsTable {
|
|
86
86
|
id: Generated<string>;
|
|
87
87
|
name: string;
|
|
88
88
|
version: Generated<string>;
|
|
@@ -150,6 +150,71 @@ interface UsageSnapshotsTable {
|
|
|
150
150
|
measured_at: Generated<Date>;
|
|
151
151
|
storage_bytes: Generated<number>;
|
|
152
152
|
}
|
|
153
|
+
interface WaitlistTable {
|
|
154
|
+
id: Generated<string>;
|
|
155
|
+
email: string;
|
|
156
|
+
source: Generated<string>;
|
|
157
|
+
status: Generated<string>;
|
|
158
|
+
created_at: Generated<Date>;
|
|
159
|
+
}
|
|
160
|
+
interface AccountInsightsTable {
|
|
161
|
+
id: Generated<string>;
|
|
162
|
+
account_id: string;
|
|
163
|
+
category: string;
|
|
164
|
+
insight_type: string;
|
|
165
|
+
resource_id: string | null;
|
|
166
|
+
severity: string;
|
|
167
|
+
title: string;
|
|
168
|
+
body: string;
|
|
169
|
+
data: unknown;
|
|
170
|
+
dismissed_at: Date | null;
|
|
171
|
+
expires_at: Date | null;
|
|
172
|
+
created_at: Generated<Date>;
|
|
173
|
+
}
|
|
174
|
+
interface AccountAgentRunsTable {
|
|
175
|
+
id: Generated<string>;
|
|
176
|
+
account_id: string;
|
|
177
|
+
started_at: Generated<Date>;
|
|
178
|
+
completed_at: Date | null;
|
|
179
|
+
status: Generated<string>;
|
|
180
|
+
input_tokens: Generated<number>;
|
|
181
|
+
output_tokens: Generated<number>;
|
|
182
|
+
cost_usd: Generated<number>;
|
|
183
|
+
insights_created: Generated<number>;
|
|
184
|
+
error: string | null;
|
|
185
|
+
}
|
|
186
|
+
interface SubgraphProcessingStatsTable {
|
|
187
|
+
id: Generated<string>;
|
|
188
|
+
subgraph_name: string;
|
|
189
|
+
api_key_id: string | null;
|
|
190
|
+
bucket_start: Date | null;
|
|
191
|
+
bucket_end: Date | null;
|
|
192
|
+
blocks_processed: number | null;
|
|
193
|
+
total_time_ms: number | null;
|
|
194
|
+
handler_time_ms: number | null;
|
|
195
|
+
flush_time_ms: number | null;
|
|
196
|
+
max_block_time_ms: number | null;
|
|
197
|
+
max_handler_time_ms: number | null;
|
|
198
|
+
avg_ops_per_block: number | null;
|
|
199
|
+
is_catchup: Generated<boolean>;
|
|
200
|
+
created_at: Generated<Date>;
|
|
201
|
+
}
|
|
202
|
+
interface SubgraphTableSnapshotsTable {
|
|
203
|
+
id: Generated<string>;
|
|
204
|
+
subgraph_name: string;
|
|
205
|
+
api_key_id: string | null;
|
|
206
|
+
table_name: string;
|
|
207
|
+
row_count: number | null;
|
|
208
|
+
created_at: Generated<Date>;
|
|
209
|
+
}
|
|
210
|
+
interface SubgraphHealthSnapshotsTable {
|
|
211
|
+
id: Generated<string>;
|
|
212
|
+
subgraph_id: string;
|
|
213
|
+
total_processed: number;
|
|
214
|
+
total_errors: number;
|
|
215
|
+
last_processed_block: number | null;
|
|
216
|
+
captured_at: Generated<Date>;
|
|
217
|
+
}
|
|
153
218
|
interface Database {
|
|
154
219
|
blocks: BlocksTable;
|
|
155
220
|
transactions: TransactionsTable;
|
|
@@ -159,13 +224,19 @@ interface Database {
|
|
|
159
224
|
jobs: JobsTable;
|
|
160
225
|
index_progress: IndexProgressTable;
|
|
161
226
|
deliveries: DeliveriesTable;
|
|
162
|
-
|
|
227
|
+
subgraphs: SubgraphsTable;
|
|
163
228
|
api_keys: ApiKeysTable;
|
|
164
229
|
accounts: AccountsTable;
|
|
165
230
|
sessions: SessionsTable;
|
|
166
231
|
magic_links: MagicLinksTable;
|
|
167
232
|
usage_daily: UsageDailyTable;
|
|
168
233
|
usage_snapshots: UsageSnapshotsTable;
|
|
234
|
+
waitlist: WaitlistTable;
|
|
235
|
+
account_insights: AccountInsightsTable;
|
|
236
|
+
account_agent_runs: AccountAgentRunsTable;
|
|
237
|
+
subgraph_health_snapshots: SubgraphHealthSnapshotsTable;
|
|
238
|
+
subgraph_processing_stats: SubgraphProcessingStatsTable;
|
|
239
|
+
subgraph_table_snapshots: SubgraphTableSnapshotsTable;
|
|
169
240
|
}
|
|
170
241
|
type Block = Selectable<BlocksTable>;
|
|
171
242
|
type InsertBlock = Insertable<BlocksTable>;
|
|
@@ -191,9 +262,9 @@ type UpdateIndexProgress = Updateable<IndexProgressTable>;
|
|
|
191
262
|
type Delivery = Selectable<DeliveriesTable>;
|
|
192
263
|
type InsertDelivery = Insertable<DeliveriesTable>;
|
|
193
264
|
type UpdateDelivery = Updateable<DeliveriesTable>;
|
|
194
|
-
type
|
|
195
|
-
type
|
|
196
|
-
type
|
|
265
|
+
type Subgraph = Selectable<SubgraphsTable>;
|
|
266
|
+
type InsertSubgraph = Insertable<SubgraphsTable>;
|
|
267
|
+
type UpdateSubgraph = Updateable<SubgraphsTable>;
|
|
197
268
|
type ApiKey = Selectable<ApiKeysTable>;
|
|
198
269
|
type InsertApiKey = Insertable<ApiKeysTable>;
|
|
199
270
|
type UpdateApiKey = Updateable<ApiKeysTable>;
|
|
@@ -205,4 +276,10 @@ type Session = Selectable<SessionsTable>;
|
|
|
205
276
|
type InsertSession = Insertable<SessionsTable>;
|
|
206
277
|
type UsageDaily = Selectable<UsageDailyTable>;
|
|
207
278
|
type UsageSnapshot = Selectable<UsageSnapshotsTable>;
|
|
208
|
-
|
|
279
|
+
type AccountInsight = Selectable<AccountInsightsTable>;
|
|
280
|
+
type InsertAccountInsight = Insertable<AccountInsightsTable>;
|
|
281
|
+
type AccountAgentRun = Selectable<AccountAgentRunsTable>;
|
|
282
|
+
type InsertAccountAgentRun = Insertable<AccountAgentRunsTable>;
|
|
283
|
+
type SubgraphHealthSnapshot = Selectable<SubgraphHealthSnapshotsTable>;
|
|
284
|
+
type InsertSubgraphHealthSnapshot = Insertable<SubgraphHealthSnapshotsTable>;
|
|
285
|
+
export { WaitlistTable, UsageSnapshotsTable, UsageSnapshot, UsageDailyTable, UsageDaily, UpdateTransaction, UpdateSubgraph, UpdateStreamRow, UpdateStreamMetrics, UpdateJob, UpdateIndexProgress, UpdateEvent, UpdateDelivery, UpdateBlock, UpdateApiKey, TransactionsTable, Transaction, SubgraphsTable, SubgraphTableSnapshotsTable, SubgraphProcessingStatsTable, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, Subgraph, StreamsTable, StreamMetricsTable, StreamMetrics, Stream, SessionsTable, Session, MagicLinksTable, MagicLink, JobsTable, Job, InsertTransaction, InsertSubgraphHealthSnapshot, InsertSubgraph, InsertStreamMetrics, InsertStream, InsertSession, InsertMagicLink, InsertJob, InsertIndexProgress, InsertEvent, InsertDelivery, InsertBlock, InsertApiKey, InsertAccountInsight, InsertAccountAgentRun, InsertAccount, IndexProgressTable, IndexProgress, EventsTable, Event, Delivery, DeliveriesTable, Database, BlocksTable, Block, ApiKeysTable, ApiKey, AccountsTable, AccountInsightsTable, AccountInsight, AccountAgentRunsTable, AccountAgentRun, Account };
|
package/dist/src/env.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
3
7
|
var __export = (target, all) => {
|
|
4
8
|
for (var name in all)
|
|
5
9
|
__defProp(target, name, {
|
|
6
10
|
get: all[name],
|
|
7
11
|
enumerable: true,
|
|
8
12
|
configurable: true,
|
|
9
|
-
set: (
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
10
14
|
});
|
|
11
15
|
};
|
|
12
16
|
|
|
@@ -56,5 +60,5 @@ export {
|
|
|
56
60
|
envSchema
|
|
57
61
|
};
|
|
58
62
|
|
|
59
|
-
//# debugId=
|
|
63
|
+
//# debugId=2CB7FF251202EACC64756E2164756E21
|
|
60
64
|
//# sourceMappingURL=env.js.map
|
package/dist/src/env.js.map
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import { z } from \"zod\";\n\n// Parse comma-separated networks\nconst networksSchema = z.string().transform((val) => {\n const networks = val.split(\",\").map((n) => n.trim()).filter(Boolean);\n const valid = [\"mainnet\", \"testnet\"];\n for (const n of networks) {\n if (!valid.includes(n)) {\n throw new Error(`Invalid network: ${n}. Must be one of: ${valid.join(\", \")}`);\n }\n }\n return networks as (\"mainnet\" | \"testnet\")[];\n});\n\ninterface EnvSchemaOutput {\n DATABASE_URL?: string;\n NETWORK?: \"mainnet\" | \"testnet\";\n NETWORKS?: (\"mainnet\" | \"testnet\")[];\n LOG_LEVEL: \"debug\" | \"info\" | \"warn\" | \"error\";\n NODE_ENV: \"development\" | \"production\" | \"test\";\n}\n\n// Cast needed: z.preprocess / z.default create different _input vs _output types\n// that z.ZodType<T> can't represent without explicit input type param\nconst envSchema: z.ZodType<EnvSchemaOutput> = z.object({\n DATABASE_URL: z.preprocess(\n (val) => (typeof val === \"string\" && val.length === 0) ? undefined : val,\n z.string().url().optional(),\n ),\n NETWORK: z.enum([\"mainnet\", \"testnet\"]).optional(),\n NETWORKS: networksSchema.optional(),\n LOG_LEVEL: z.enum([\"debug\", \"info\", \"warn\", \"error\"]).default(\"info\"),\n NODE_ENV: z.enum([\"development\", \"production\", \"test\"]).default(\"development\"),\n}) as unknown as z.ZodType<EnvSchemaOutput>;\n\nexport type Env = EnvSchemaOutput & {\n enabledNetworks: (\"mainnet\" | \"testnet\")[];\n};\n\nlet cachedEnv: Env | null = null;\n\nexport function getEnv(): Env {\n if (cachedEnv) {\n return cachedEnv;\n }\n\n const result = envSchema.safeParse(process.env);\n\n if (!result.success) {\n console.error(\"❌ Invalid environment configuration:\");\n console.error(result.error.format());\n throw new Error(\"Invalid environment configuration\");\n }\n\n // Compute enabled networks from NETWORKS or NETWORK\n let enabledNetworks: (\"mainnet\" | \"testnet\")[];\n if (result.data.NETWORKS && result.data.NETWORKS.length > 0) {\n enabledNetworks = result.data.NETWORKS;\n } else if (result.data.NETWORK) {\n enabledNetworks = [result.data.NETWORK];\n } else {\n enabledNetworks = [\"mainnet\"]; // Default\n }\n\n cachedEnv = { ...result.data, enabledNetworks };\n return cachedEnv;\n}\n\n// Export for testing\nexport { envSchema };\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAGA,IAAM,iBAAiB,EAAE,OAAO,EAAE,UAAU,CAAC,QAAQ;AAAA,EACnD,MAAM,WAAW,IAAI,MAAM,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,OAAO;AAAA,EACnE,MAAM,QAAQ,CAAC,WAAW,SAAS;AAAA,EACnC,WAAW,KAAK,UAAU;AAAA,IACxB,IAAI,CAAC,MAAM,SAAS,CAAC,GAAG;AAAA,MACtB,MAAM,IAAI,MAAM,oBAAoB,sBAAsB,MAAM,KAAK,IAAI,GAAG;AAAA,IAC9E;AAAA,EACF;AAAA,EACA,OAAO;AAAA,CACR;AAYD,IAAM,YAAwC,EAAE,OAAO;AAAA,EACrD,cAAc,EAAE,WACd,CAAC,QAAS,OAAO,QAAQ,YAAY,IAAI,WAAW,IAAK,YAAY,KACrE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAC5B;AAAA,EACA,SAAS,EAAE,KAAK,CAAC,WAAW,SAAS,CAAC,EAAE,SAAS;AAAA,EACjD,UAAU,eAAe,SAAS;AAAA,EAClC,WAAW,EAAE,KAAK,CAAC,SAAS,QAAQ,QAAQ,OAAO,CAAC,EAAE,QAAQ,MAAM;AAAA,EACpE,UAAU,EAAE,KAAK,CAAC,eAAe,cAAc,MAAM,CAAC,EAAE,QAAQ,aAAa;AAC/E,CAAC;AAMD,IAAI,YAAwB;AAErB,SAAS,MAAM,GAAQ;AAAA,EAC5B,IAAI,WAAW;AAAA,IACb,OAAO;AAAA,EACT;AAAA,EAEA,MAAM,SAAS,UAAU,UAAU,QAAQ,GAAG;AAAA,EAE9C,IAAI,CAAC,OAAO,SAAS;AAAA,IACnB,QAAQ,MAAM,sCAAqC;AAAA,IACnD,QAAQ,MAAM,OAAO,MAAM,OAAO,CAAC;AAAA,IACnC,MAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AAAA,EAGA,IAAI;AAAA,EACJ,IAAI,OAAO,KAAK,YAAY,OAAO,KAAK,SAAS,SAAS,GAAG;AAAA,IAC3D,kBAAkB,OAAO,KAAK;AAAA,EAChC,EAAO,SAAI,OAAO,KAAK,SAAS;AAAA,IAC9B,kBAAkB,CAAC,OAAO,KAAK,OAAO;AAAA,EACxC,EAAO;AAAA,IACL,kBAAkB,CAAC,SAAS;AAAA;AAAA,EAG9B,YAAY,KAAK,OAAO,MAAM,gBAAgB;AAAA,EAC9C,OAAO;AAAA;",
|
|
8
|
+
"debugId": "2CB7FF251202EACC64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/src/errors.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
3
7
|
var __export = (target, all) => {
|
|
4
8
|
for (var name in all)
|
|
5
9
|
__defProp(target, name, {
|
|
6
10
|
get: all[name],
|
|
7
11
|
enumerable: true,
|
|
8
12
|
configurable: true,
|
|
9
|
-
set: (
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
10
14
|
});
|
|
11
15
|
};
|
|
12
16
|
|
|
@@ -115,5 +119,5 @@ export {
|
|
|
115
119
|
AuthenticationError
|
|
116
120
|
};
|
|
117
121
|
|
|
118
|
-
//# debugId=
|
|
122
|
+
//# debugId=7794573A4C7CB51D64756E2164756E21
|
|
119
123
|
//# sourceMappingURL=errors.js.map
|
package/dist/src/errors.js.map
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"/**\n * Base error class for all Stacks Streams errors\n */\nexport class StreamsError extends Error {\n public code: string;\n public override cause?: unknown;\n\n constructor(\n code: string,\n message: string,\n cause?: unknown\n ) {\n super(message);\n this.code = code;\n this.cause = cause;\n this.name = this.constructor.name;\n Error.captureStackTrace?.(this, this.constructor);\n }\n\n toJSON(): { name: string; code: string; message: string; stack: string | undefined; cause: unknown } {\n return {\n name: this.name,\n code: this.code,\n message: this.message,\n stack: this.stack,\n cause: this.cause,\n };\n }\n}\n\n/**\n * Stream not found error\n */\nexport class StreamNotFoundError extends StreamsError {\n constructor(streamId: string) {\n super(\"STREAM_NOT_FOUND\", `Stream not found: ${streamId}`);\n }\n}\n\n/**\n * Validation error for invalid input\n */\nexport class ValidationError extends StreamsError {\n constructor(message: string, cause?: unknown) {\n super(\"VALIDATION_ERROR\", message, cause);\n }\n}\n\n/**\n * Database operation error\n */\nexport class DatabaseError extends StreamsError {\n constructor(message: string, cause?: unknown) {\n super(\"DATABASE_ERROR\", message, cause);\n }\n}\n\n/**\n * Webhook delivery error\n */\nexport class WebhookDeliveryError extends StreamsError {\n constructor(\n message: string,\n public statusCode?: number,\n cause?: unknown\n ) {\n super(\"WEBHOOK_DELIVERY_ERROR\", message, cause);\n }\n\n override toJSON(): { name: string; code: string; message: string; stack: string | undefined; cause: unknown; statusCode: number | undefined } {\n const base = super.toJSON();\n return {\n name: base.name,\n code: base.code,\n message: base.message,\n stack: base.stack,\n cause: base.cause,\n statusCode: this.statusCode,\n };\n }\n}\n\n/**\n * Filter evaluation error\n */\nexport class FilterEvaluationError extends StreamsError {\n constructor(message: string, cause?: unknown) {\n super(\"FILTER_EVALUATION_ERROR\", message, cause);\n }\n}\n\nexport class AuthenticationError extends StreamsError {\n constructor(message: string) {\n super(\"AUTHENTICATION_ERROR\", message);\n }\n}\n\nexport class AuthorizationError extends StreamsError {\n constructor(message: string) {\n super(\"AUTHORIZATION_ERROR\", message);\n }\n}\n\nexport class RateLimitError extends StreamsError {\n constructor(message: string) {\n super(\"RATE_LIMIT_ERROR\", message);\n }\n}\n\nexport class ForbiddenError extends StreamsError {\n constructor(message = \"Forbidden\") {\n super(\"FORBIDDEN\", message);\n }\n}\n\n/**\n * Safely extract error message from unknown error value\n */\nexport function getErrorMessage(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAGO,MAAM,qBAAqB,MAAM;AAAA,EAC/B;AAAA,EACS;AAAA,EAEhB,WAAW,CACT,MACA,SACA,OACA;AAAA,IACA,MAAM,OAAO;AAAA,IACb,KAAK,OAAO;AAAA,IACZ,KAAK,QAAQ;AAAA,IACb,KAAK,OAAO,KAAK,YAAY;AAAA,IAC7B,MAAM,oBAAoB,MAAM,KAAK,WAAW;AAAA;AAAA,EAGlD,MAAM,GAA+F;AAAA,IACnG,OAAO;AAAA,MACL,MAAM,KAAK;AAAA,MACX,MAAM,KAAK;AAAA,MACX,SAAS,KAAK;AAAA,MACd,OAAO,KAAK;AAAA,MACZ,OAAO,KAAK;AAAA,IACd;AAAA;AAEJ;AAAA;AAKO,MAAM,4BAA4B,aAAa;AAAA,EACpD,WAAW,CAAC,UAAkB;AAAA,IAC5B,MAAM,oBAAoB,qBAAqB,UAAU;AAAA;AAE7D;AAAA;AAKO,MAAM,wBAAwB,aAAa;AAAA,EAChD,WAAW,CAAC,SAAiB,OAAiB;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8
|
+
"debugId": "7794573A4C7CB51D64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -82,7 +82,7 @@ interface DeliveriesTable {
|
|
|
82
82
|
payload: unknown;
|
|
83
83
|
created_at: Generated<Date>;
|
|
84
84
|
}
|
|
85
|
-
interface
|
|
85
|
+
interface SubgraphsTable {
|
|
86
86
|
id: Generated<string>;
|
|
87
87
|
name: string;
|
|
88
88
|
version: Generated<string>;
|
|
@@ -150,6 +150,71 @@ interface UsageSnapshotsTable {
|
|
|
150
150
|
measured_at: Generated<Date>;
|
|
151
151
|
storage_bytes: Generated<number>;
|
|
152
152
|
}
|
|
153
|
+
interface WaitlistTable {
|
|
154
|
+
id: Generated<string>;
|
|
155
|
+
email: string;
|
|
156
|
+
source: Generated<string>;
|
|
157
|
+
status: Generated<string>;
|
|
158
|
+
created_at: Generated<Date>;
|
|
159
|
+
}
|
|
160
|
+
interface AccountInsightsTable {
|
|
161
|
+
id: Generated<string>;
|
|
162
|
+
account_id: string;
|
|
163
|
+
category: string;
|
|
164
|
+
insight_type: string;
|
|
165
|
+
resource_id: string | null;
|
|
166
|
+
severity: string;
|
|
167
|
+
title: string;
|
|
168
|
+
body: string;
|
|
169
|
+
data: unknown;
|
|
170
|
+
dismissed_at: Date | null;
|
|
171
|
+
expires_at: Date | null;
|
|
172
|
+
created_at: Generated<Date>;
|
|
173
|
+
}
|
|
174
|
+
interface AccountAgentRunsTable {
|
|
175
|
+
id: Generated<string>;
|
|
176
|
+
account_id: string;
|
|
177
|
+
started_at: Generated<Date>;
|
|
178
|
+
completed_at: Date | null;
|
|
179
|
+
status: Generated<string>;
|
|
180
|
+
input_tokens: Generated<number>;
|
|
181
|
+
output_tokens: Generated<number>;
|
|
182
|
+
cost_usd: Generated<number>;
|
|
183
|
+
insights_created: Generated<number>;
|
|
184
|
+
error: string | null;
|
|
185
|
+
}
|
|
186
|
+
interface SubgraphProcessingStatsTable {
|
|
187
|
+
id: Generated<string>;
|
|
188
|
+
subgraph_name: string;
|
|
189
|
+
api_key_id: string | null;
|
|
190
|
+
bucket_start: Date | null;
|
|
191
|
+
bucket_end: Date | null;
|
|
192
|
+
blocks_processed: number | null;
|
|
193
|
+
total_time_ms: number | null;
|
|
194
|
+
handler_time_ms: number | null;
|
|
195
|
+
flush_time_ms: number | null;
|
|
196
|
+
max_block_time_ms: number | null;
|
|
197
|
+
max_handler_time_ms: number | null;
|
|
198
|
+
avg_ops_per_block: number | null;
|
|
199
|
+
is_catchup: Generated<boolean>;
|
|
200
|
+
created_at: Generated<Date>;
|
|
201
|
+
}
|
|
202
|
+
interface SubgraphTableSnapshotsTable {
|
|
203
|
+
id: Generated<string>;
|
|
204
|
+
subgraph_name: string;
|
|
205
|
+
api_key_id: string | null;
|
|
206
|
+
table_name: string;
|
|
207
|
+
row_count: number | null;
|
|
208
|
+
created_at: Generated<Date>;
|
|
209
|
+
}
|
|
210
|
+
interface SubgraphHealthSnapshotsTable {
|
|
211
|
+
id: Generated<string>;
|
|
212
|
+
subgraph_id: string;
|
|
213
|
+
total_processed: number;
|
|
214
|
+
total_errors: number;
|
|
215
|
+
last_processed_block: number | null;
|
|
216
|
+
captured_at: Generated<Date>;
|
|
217
|
+
}
|
|
153
218
|
interface Database {
|
|
154
219
|
blocks: BlocksTable;
|
|
155
220
|
transactions: TransactionsTable;
|
|
@@ -159,13 +224,19 @@ interface Database {
|
|
|
159
224
|
jobs: JobsTable;
|
|
160
225
|
index_progress: IndexProgressTable;
|
|
161
226
|
deliveries: DeliveriesTable;
|
|
162
|
-
|
|
227
|
+
subgraphs: SubgraphsTable;
|
|
163
228
|
api_keys: ApiKeysTable;
|
|
164
229
|
accounts: AccountsTable;
|
|
165
230
|
sessions: SessionsTable;
|
|
166
231
|
magic_links: MagicLinksTable;
|
|
167
232
|
usage_daily: UsageDailyTable;
|
|
168
233
|
usage_snapshots: UsageSnapshotsTable;
|
|
234
|
+
waitlist: WaitlistTable;
|
|
235
|
+
account_insights: AccountInsightsTable;
|
|
236
|
+
account_agent_runs: AccountAgentRunsTable;
|
|
237
|
+
subgraph_health_snapshots: SubgraphHealthSnapshotsTable;
|
|
238
|
+
subgraph_processing_stats: SubgraphProcessingStatsTable;
|
|
239
|
+
subgraph_table_snapshots: SubgraphTableSnapshotsTable;
|
|
169
240
|
}
|
|
170
241
|
type Block = Selectable<BlocksTable>;
|
|
171
242
|
type InsertBlock = Insertable<BlocksTable>;
|
|
@@ -191,9 +262,9 @@ type UpdateIndexProgress = Updateable<IndexProgressTable>;
|
|
|
191
262
|
type Delivery = Selectable<DeliveriesTable>;
|
|
192
263
|
type InsertDelivery = Insertable<DeliveriesTable>;
|
|
193
264
|
type UpdateDelivery = Updateable<DeliveriesTable>;
|
|
194
|
-
type
|
|
195
|
-
type
|
|
196
|
-
type
|
|
265
|
+
type Subgraph = Selectable<SubgraphsTable>;
|
|
266
|
+
type InsertSubgraph = Insertable<SubgraphsTable>;
|
|
267
|
+
type UpdateSubgraph = Updateable<SubgraphsTable>;
|
|
197
268
|
type ApiKey = Selectable<ApiKeysTable>;
|
|
198
269
|
type InsertApiKey = Insertable<ApiKeysTable>;
|
|
199
270
|
type UpdateApiKey = Updateable<ApiKeysTable>;
|
|
@@ -205,6 +276,12 @@ type Session = Selectable<SessionsTable>;
|
|
|
205
276
|
type InsertSession = Insertable<SessionsTable>;
|
|
206
277
|
type UsageDaily = Selectable<UsageDailyTable>;
|
|
207
278
|
type UsageSnapshot = Selectable<UsageSnapshotsTable>;
|
|
279
|
+
type AccountInsight = Selectable<AccountInsightsTable>;
|
|
280
|
+
type InsertAccountInsight = Insertable<AccountInsightsTable>;
|
|
281
|
+
type AccountAgentRun = Selectable<AccountAgentRunsTable>;
|
|
282
|
+
type InsertAccountAgentRun = Insertable<AccountAgentRunsTable>;
|
|
283
|
+
type SubgraphHealthSnapshot = Selectable<SubgraphHealthSnapshotsTable>;
|
|
284
|
+
type InsertSubgraphHealthSnapshot = Insertable<SubgraphHealthSnapshotsTable>;
|
|
208
285
|
interface EnvSchemaOutput {
|
|
209
286
|
DATABASE_URL?: string;
|
|
210
287
|
NETWORK?: "mainnet" | "testnet";
|
|
@@ -460,7 +537,7 @@ declare const ContractDeployFilterSchema: z2.ZodType<ContractDeployFilter>;
|
|
|
460
537
|
declare const PrintEventFilterSchema: z2.ZodType<PrintEventFilter>;
|
|
461
538
|
declare const StreamFilterSchema: z2.ZodType<StreamFilter>;
|
|
462
539
|
import { z as z3 } from "zod";
|
|
463
|
-
interface
|
|
540
|
+
interface DeploySubgraphRequest {
|
|
464
541
|
name: string;
|
|
465
542
|
version?: string;
|
|
466
543
|
description?: string;
|
|
@@ -469,13 +546,13 @@ interface DeployViewRequest {
|
|
|
469
546
|
handlerCode: string;
|
|
470
547
|
reindex?: boolean;
|
|
471
548
|
}
|
|
472
|
-
declare const
|
|
473
|
-
interface
|
|
549
|
+
declare const DeploySubgraphRequestSchema: z3.ZodType<DeploySubgraphRequest>;
|
|
550
|
+
interface DeploySubgraphResponse {
|
|
474
551
|
action: "created" | "unchanged" | "updated" | "reindexed";
|
|
475
|
-
|
|
552
|
+
subgraphId: string;
|
|
476
553
|
message: string;
|
|
477
554
|
}
|
|
478
|
-
interface
|
|
555
|
+
interface SubgraphSummary {
|
|
479
556
|
name: string;
|
|
480
557
|
version: string;
|
|
481
558
|
status: string;
|
|
@@ -483,7 +560,7 @@ interface ViewSummary {
|
|
|
483
560
|
tables: string[];
|
|
484
561
|
createdAt: string;
|
|
485
562
|
}
|
|
486
|
-
interface
|
|
563
|
+
interface SubgraphDetail {
|
|
487
564
|
name: string;
|
|
488
565
|
version: string;
|
|
489
566
|
status: string;
|
|
@@ -512,7 +589,7 @@ interface ReindexResponse {
|
|
|
512
589
|
fromBlock: number;
|
|
513
590
|
toBlock: number | string;
|
|
514
591
|
}
|
|
515
|
-
interface
|
|
592
|
+
interface SubgraphQueryParams {
|
|
516
593
|
sort?: string;
|
|
517
594
|
order?: string;
|
|
518
595
|
limit?: number;
|
|
@@ -645,4 +722,4 @@ declare function createSignatureHeader(payload: string, secret: string, timestam
|
|
|
645
722
|
* Returns true if valid, false otherwise
|
|
646
723
|
*/
|
|
647
724
|
declare function verifySignatureHeader(payload: string, header: string, secret: string, toleranceSeconds?: number): boolean;
|
|
648
|
-
export { sql, exports_queue as queue, parseJsonb, logger, jsonb, getRawClient, getErrorMessage, getEnv, getDb, exports_hmac as crypto, closeDb, WebhookPayloadSchema, WebhookPayload, WebhookDeliveryError,
|
|
725
|
+
export { sql, exports_queue as queue, parseJsonb, logger, jsonb, getRawClient, getErrorMessage, getEnv, getDb, exports_hmac as crypto, closeDb, WebhookPayloadSchema, WebhookPayload, WebhookDeliveryError, WaitlistTable, ValidationError, UsageSnapshotsTable, UsageSnapshot, UsageDailyTable, UsageDaily, UpdateTransaction, UpdateSubgraph, UpdateStreamSchema, UpdateStreamRow, UpdateStreamMetrics, UpdateStream, UpdateJob, UpdateIndexProgress, UpdateEvent, UpdateDelivery, UpdateBlock, UpdateApiKey, TransactionsTable, Transaction, SubgraphsTable, SubgraphTableSnapshotsTable, SubgraphSummary, SubgraphQueryParams, SubgraphProcessingStatsTable, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphDetail, Subgraph, StxTransferFilterSchema, StxTransferFilter, StxMintFilterSchema, StxMintFilter, StxLockFilterSchema, StxLockFilter, StxBurnFilterSchema, StxBurnFilter, StreamsTable, StreamsError, StreamResponseSchema, StreamResponse, StreamOptionsSchema, StreamOptions, StreamNotFoundError, StreamMetricsTable, StreamMetricsSchema, StreamMetricsResponse, StreamMetrics, StreamFilterSchema, StreamFilter, Stream, SessionsTable, Session, ReindexResponse, RateLimitError, QueueStats, PrintEventFilterSchema, PrintEventFilter, NftTransferFilterSchema, NftTransferFilter, NftMintFilterSchema, NftMintFilter, NftBurnFilterSchema, NftBurnFilter, MagicLinksTable, MagicLink, ListStreamsResponse, JobsTable, Job, InsertTransaction, InsertSubgraphHealthSnapshot, InsertSubgraph, InsertStreamMetrics, InsertStream, InsertSession, InsertMagicLink, InsertJob, InsertIndexProgress, InsertEvent, InsertDelivery, InsertBlock, InsertApiKey, InsertAccountInsight, InsertAccountAgentRun, InsertAccount, IndexProgressTable, IndexProgress, FtTransferFilterSchema, FtTransferFilter, FtMintFilterSchema, FtMintFilter, FtBurnFilterSchema, FtBurnFilter, ForbiddenError, FilterEvaluationError, EventsTable, Event, Env, DeploySubgraphResponse, DeploySubgraphRequestSchema, DeploySubgraphRequest, Delivery, DeliveriesTable, DatabaseError, Database, CreateStreamSchema, CreateStreamResponse, CreateStream, ContractDeployFilterSchema, ContractDeployFilter, ContractCallFilterSchema, ContractCallFilter, BulkResumeResponse, BulkPauseResponse, BlocksTable, Block, AuthorizationError, AuthenticationError, ApiKeysTable, ApiKey, AccountsTable, AccountInsightsTable, AccountInsight, AccountAgentRunsTable, AccountAgentRun, Account };
|
package/dist/src/index.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
3
7
|
var __export = (target, all) => {
|
|
4
8
|
for (var name in all)
|
|
5
9
|
__defProp(target, name, {
|
|
6
10
|
get: all[name],
|
|
7
11
|
enumerable: true,
|
|
8
12
|
configurable: true,
|
|
9
|
-
set: (
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
10
14
|
});
|
|
11
15
|
};
|
|
12
16
|
// src/db/jsonb.ts
|
|
@@ -470,9 +474,9 @@ var StreamFilterSchema = z2.discriminatedUnion("type", [
|
|
|
470
474
|
PrintEventFilterSchema
|
|
471
475
|
]);
|
|
472
476
|
|
|
473
|
-
// src/schemas/
|
|
477
|
+
// src/schemas/subgraphs.ts
|
|
474
478
|
import { z as z3 } from "zod";
|
|
475
|
-
var
|
|
479
|
+
var DeploySubgraphRequestSchema = z3.object({
|
|
476
480
|
name: z3.string().regex(/^[a-z0-9-]+$/, "lowercase alphanumeric + hyphens only").max(63),
|
|
477
481
|
version: z3.string().optional(),
|
|
478
482
|
description: z3.string().optional(),
|
|
@@ -647,7 +651,7 @@ export {
|
|
|
647
651
|
FtBurnFilterSchema,
|
|
648
652
|
ForbiddenError,
|
|
649
653
|
FilterEvaluationError,
|
|
650
|
-
|
|
654
|
+
DeploySubgraphRequestSchema,
|
|
651
655
|
DatabaseError,
|
|
652
656
|
CreateStreamSchema,
|
|
653
657
|
ContractDeployFilterSchema,
|
|
@@ -656,5 +660,5 @@ export {
|
|
|
656
660
|
AuthenticationError
|
|
657
661
|
};
|
|
658
662
|
|
|
659
|
-
//# debugId=
|
|
663
|
+
//# debugId=360F9F394016C38364756E2164756E21
|
|
660
664
|
//# sourceMappingURL=index.js.map
|