@secondlayer/shared 4.4.0 → 5.0.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 +3 -3
- package/dist/src/crypto/hmac.js.map +3 -3
- package/dist/src/crypto/secrets.js.map +2 -2
- package/dist/src/db/index.js.map +2 -2
- package/dist/src/db/queries/account-usage.js +137 -29
- package/dist/src/db/queries/account-usage.js.map +3 -3
- package/dist/src/db/queries/subscriptions.js +3 -3
- package/dist/src/db/queries/subscriptions.js.map +5 -5
- package/dist/src/db/queries/tenants.js.map +2 -2
- package/dist/src/errors.d.ts +1 -2
- package/dist/src/errors.js +3 -2
- package/dist/src/errors.js.map +3 -3
- package/dist/src/index.d.ts +1 -2
- package/dist/src/index.js +5 -4
- package/dist/src/index.js.map +6 -6
- package/dist/src/logger.js.map +2 -2
- package/dist/src/node/archive-client.js.map +2 -2
- package/dist/src/node/hiro-client.js +27 -23
- package/dist/src/node/hiro-client.js.map +4 -4
- package/dist/src/node/hiro-pg-client.js +2 -2
- package/dist/src/node/hiro-pg-client.js.map +3 -3
- package/dist/src/node/local-client.js.map +2 -2
- package/dist/src/pricing.d.ts +51 -7
- package/dist/src/pricing.js +143 -28
- package/dist/src/pricing.js.map +3 -3
- package/dist/src/schemas/filters.js.map +2 -2
- package/dist/src/schemas/index.js.map +2 -2
- package/migrations/0001_initial.ts +2 -0
- package/migrations/0002_api_keys.ts +2 -0
- package/migrations/0003_tenant_isolation.ts +5 -3
- package/migrations/0004_accounts_and_usage.ts +2 -0
- package/migrations/0005_sessions.ts +2 -0
- package/migrations/0006_tx_index.ts +2 -0
- package/migrations/0007_contracts.ts +2 -0
- package/migrations/0008_drop_contracts.ts +2 -0
- package/migrations/0009_waitlist.ts +2 -0
- package/migrations/0010_waitlist_status.ts +2 -0
- package/migrations/0011_account_insights.ts +2 -0
- package/migrations/0012_view_health_snapshots.ts +2 -0
- package/migrations/0013_view_processing_stats.ts +2 -0
- package/migrations/0014_view_table_snapshots.ts +2 -0
- package/migrations/0015_rename_views_to_subgraphs.ts +2 -0
- package/migrations/0016_rename_webhook_to_endpoint.ts +2 -0
- package/migrations/0017_security_hardening.ts +2 -0
- package/migrations/0018_subgraph_gaps.ts +2 -0
- package/migrations/0021_tx_function_args_result.ts +3 -4
- package/migrations/0022_marketplace.ts +4 -5
- package/migrations/0023_projects.ts +3 -1
- package/migrations/0024_chat_sessions.ts +3 -1
- package/migrations/0025_chat_session_summary.ts +3 -4
- package/migrations/0026_workflows.ts +4 -5
- package/migrations/0027_workflow_cursors.ts +3 -1
- package/migrations/0028_subgraph_account_scoping.ts +7 -2
- package/migrations/0029_subgraph_handler_code.ts +3 -4
- package/migrations/0030_workflow_source_code.ts +2 -0
- package/migrations/0031_subgraph_source_code.ts +2 -0
- package/migrations/0032_drop_streams_tables.ts +9 -9
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Kysely, sql } from "kysely";
|
|
2
2
|
|
|
3
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
3
4
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
4
5
|
// 1. Create accounts table
|
|
5
6
|
await db.schema
|
|
@@ -83,6 +84,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
83
84
|
.execute();
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
86
88
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
87
89
|
await db.schema.dropIndex("api_keys_account_id_idx").ifExists().execute();
|
|
88
90
|
await sql`ALTER TABLE api_keys ALTER COLUMN account_id DROP NOT NULL`.execute(
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Kysely, sql } from "kysely";
|
|
2
2
|
|
|
3
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
3
4
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
4
5
|
await db.schema
|
|
5
6
|
.createTable("sessions")
|
|
@@ -35,6 +36,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
35
36
|
.execute();
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
38
40
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
39
41
|
await db.schema.dropIndex("sessions_account_id_idx").ifExists().execute();
|
|
40
42
|
await db.schema.dropIndex("sessions_token_hash_idx").ifExists().execute();
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { type Kysely, sql } from "kysely";
|
|
2
2
|
|
|
3
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
3
4
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
4
5
|
await sql`ALTER TABLE transactions ADD COLUMN IF NOT EXISTS tx_index INTEGER NOT NULL DEFAULT 0`.execute(
|
|
5
6
|
db,
|
|
6
7
|
);
|
|
7
8
|
}
|
|
8
9
|
|
|
10
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
9
11
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
10
12
|
await sql`ALTER TABLE transactions DROP COLUMN IF EXISTS tx_index`.execute(
|
|
11
13
|
db,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Kysely, sql } from "kysely";
|
|
2
2
|
|
|
3
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
3
4
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
4
5
|
// Enable pg_trgm for fast ILIKE search
|
|
5
6
|
await sql`CREATE EXTENSION IF NOT EXISTS pg_trgm`.execute(db);
|
|
@@ -67,6 +68,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
67
68
|
`.execute(db);
|
|
68
69
|
}
|
|
69
70
|
|
|
71
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
70
72
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
71
73
|
await db.schema.dropTable("contracts").ifExists().cascade().execute();
|
|
72
74
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type Kysely, sql } from "kysely";
|
|
2
2
|
|
|
3
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
3
4
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
4
5
|
await db.schema.dropTable("contracts").ifExists().cascade().execute();
|
|
5
6
|
}
|
|
6
7
|
|
|
8
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
7
9
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
8
10
|
await sql`CREATE EXTENSION IF NOT EXISTS pg_trgm`.execute(db);
|
|
9
11
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Kysely } from "kysely";
|
|
2
2
|
|
|
3
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
3
4
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
4
5
|
await db.schema
|
|
5
6
|
.createTable("waitlist")
|
|
@@ -14,6 +15,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
14
15
|
.execute();
|
|
15
16
|
}
|
|
16
17
|
|
|
18
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
17
19
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
18
20
|
await db.schema.dropTable("waitlist").execute();
|
|
19
21
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Kysely } from "kysely";
|
|
2
2
|
|
|
3
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
3
4
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
4
5
|
await db.schema
|
|
5
6
|
.alterTable("waitlist")
|
|
@@ -7,6 +8,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
7
8
|
.execute();
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
10
12
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
11
13
|
await db.schema.alterTable("waitlist").dropColumn("status").execute();
|
|
12
14
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Kysely } from "kysely";
|
|
2
2
|
import { sql } from "kysely";
|
|
3
3
|
|
|
4
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
4
5
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
5
6
|
await db.schema
|
|
6
7
|
.createTable("account_insights")
|
|
@@ -57,6 +58,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
57
58
|
.execute();
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
60
62
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
61
63
|
await db.schema.dropTable("account_agent_runs").execute();
|
|
62
64
|
await db.schema.dropTable("account_insights").execute();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Kysely } from "kysely";
|
|
2
2
|
|
|
3
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
3
4
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
4
5
|
await db.schema
|
|
5
6
|
.createTable("view_health_snapshots")
|
|
@@ -24,6 +25,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
24
25
|
.execute();
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
27
29
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
28
30
|
await db.schema.dropTable("view_health_snapshots").execute();
|
|
29
31
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Kysely } from "kysely";
|
|
2
2
|
import { sql } from "kysely";
|
|
3
3
|
|
|
4
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
4
5
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
5
6
|
await db.schema
|
|
6
7
|
.createTable("view_processing_stats")
|
|
@@ -37,6 +38,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
37
38
|
.execute();
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
40
42
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
41
43
|
await db.schema.dropTable("view_processing_stats").execute();
|
|
42
44
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Kysely } from "kysely";
|
|
2
2
|
|
|
3
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
3
4
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
4
5
|
await db.schema
|
|
5
6
|
.createTable("view_table_snapshots")
|
|
@@ -28,6 +29,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
28
29
|
.execute();
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
31
33
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
32
34
|
await db.schema.dropTable("view_table_snapshots").execute();
|
|
33
35
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Kysely } from "kysely";
|
|
2
2
|
import { sql } from "kysely";
|
|
3
3
|
|
|
4
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
4
5
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
5
6
|
// Drop old trigger + function
|
|
6
7
|
await sql`DROP TRIGGER IF EXISTS views_notify_trigger ON "views"`.execute(db);
|
|
@@ -103,6 +104,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
103
104
|
);
|
|
104
105
|
}
|
|
105
106
|
|
|
107
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
106
108
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
107
109
|
// Drop new trigger + function
|
|
108
110
|
await sql`DROP TRIGGER IF EXISTS subgraphs_notify_trigger ON "subgraphs"`.execute(
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Kysely } from "kysely";
|
|
2
2
|
import { sql } from "kysely";
|
|
3
3
|
|
|
4
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
4
5
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
5
6
|
await sql`ALTER TABLE "streams" RENAME COLUMN "webhook_url" TO "endpoint_url"`.execute(
|
|
6
7
|
db,
|
|
@@ -10,6 +11,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
10
11
|
);
|
|
11
12
|
}
|
|
12
13
|
|
|
14
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
13
15
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
14
16
|
await sql`ALTER TABLE "streams" RENAME COLUMN "endpoint_url" TO "webhook_url"`.execute(
|
|
15
17
|
db,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Kysely, sql } from "kysely";
|
|
2
2
|
|
|
3
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
3
4
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
4
5
|
// Magic link: add failed attempt tracking
|
|
5
6
|
await sql`ALTER TABLE "magic_links" ADD COLUMN "failed_attempts" integer NOT NULL DEFAULT 0`.execute(
|
|
@@ -19,6 +20,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
19
20
|
);
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
22
24
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
23
25
|
await sql`ALTER TABLE "magic_links" DROP COLUMN "failed_attempts"`.execute(
|
|
24
26
|
db,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Kysely, sql } from "kysely";
|
|
2
2
|
|
|
3
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
3
4
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
4
5
|
// Add start_block to subgraphs (the intended first block from definition)
|
|
5
6
|
await sql`ALTER TABLE "subgraphs" ADD COLUMN "start_block" bigint NOT NULL DEFAULT 0`.execute(
|
|
@@ -33,6 +34,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
33
34
|
);
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
36
38
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
37
39
|
await sql`DROP TABLE IF EXISTS "subgraph_gaps"`.execute(db);
|
|
38
40
|
await sql`ALTER TABLE "subgraphs" DROP COLUMN "start_block"`.execute(db);
|
|
@@ -4,6 +4,7 @@ import type { Kysely } from "kysely";
|
|
|
4
4
|
* Add function_args and raw_result columns to transactions table.
|
|
5
5
|
* Enables contract_call arg decoding and tx result access in subgraph handlers.
|
|
6
6
|
*/
|
|
7
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
7
8
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
8
9
|
await db.schema
|
|
9
10
|
.alterTable("transactions")
|
|
@@ -15,13 +16,11 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
15
16
|
.execute();
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
18
20
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
19
21
|
await db.schema
|
|
20
22
|
.alterTable("transactions")
|
|
21
23
|
.dropColumn("function_args")
|
|
22
24
|
.execute();
|
|
23
|
-
await db.schema
|
|
24
|
-
.alterTable("transactions")
|
|
25
|
-
.dropColumn("raw_result")
|
|
26
|
-
.execute();
|
|
25
|
+
await db.schema.alterTable("transactions").dropColumn("raw_result").execute();
|
|
27
26
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Kysely, sql } from "kysely";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Add marketplace columns to subgraphs and accounts.
|
|
5
5
|
* Create per-subgraph usage tracking table.
|
|
6
6
|
*/
|
|
7
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
7
8
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
8
9
|
// Subgraph marketplace columns
|
|
9
10
|
await db.schema
|
|
@@ -48,10 +49,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
48
49
|
)
|
|
49
50
|
.addColumn("date", "date", (c) => c.notNull())
|
|
50
51
|
.addColumn("query_count", "integer", (c) => c.notNull().defaultTo(0))
|
|
51
|
-
.addPrimaryKeyConstraint("subgraph_usage_daily_pk", [
|
|
52
|
-
"subgraph_id",
|
|
53
|
-
"date",
|
|
54
|
-
])
|
|
52
|
+
.addPrimaryKeyConstraint("subgraph_usage_daily_pk", ["subgraph_id", "date"])
|
|
55
53
|
.execute();
|
|
56
54
|
|
|
57
55
|
// Indexes
|
|
@@ -66,6 +64,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
66
64
|
);
|
|
67
65
|
}
|
|
68
66
|
|
|
67
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
69
68
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
70
69
|
await db.schema.dropTable("subgraph_usage_daily").execute();
|
|
71
70
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Kysely, sql } from "kysely";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Add projects, team_members, and team_invitations tables.
|
|
5
5
|
* Add project_id to streams and subgraphs.
|
|
6
6
|
* Backfill: create a default project per account and assign existing resources.
|
|
7
7
|
*/
|
|
8
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
8
9
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
9
10
|
// Projects table
|
|
10
11
|
await db.schema
|
|
@@ -134,6 +135,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
134
135
|
);
|
|
135
136
|
}
|
|
136
137
|
|
|
138
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
137
139
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
138
140
|
await sql`DROP INDEX IF EXISTS subgraphs_project_id_idx`.execute(db);
|
|
139
141
|
await sql`DROP INDEX IF EXISTS streams_project_id_idx`.execute(db);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Kysely, sql } from "kysely";
|
|
2
2
|
|
|
3
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
3
4
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
4
5
|
await db.schema
|
|
5
6
|
.createTable("chat_sessions")
|
|
@@ -43,6 +44,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
43
44
|
);
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
46
48
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
47
49
|
await sql`DROP INDEX IF EXISTS chat_messages_session_idx`.execute(db);
|
|
48
50
|
await db.schema.dropTable("chat_messages").execute();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Kysely } from "kysely";
|
|
2
2
|
|
|
3
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
3
4
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
4
5
|
await db.schema
|
|
5
6
|
.alterTable("chat_sessions")
|
|
@@ -7,9 +8,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
7
8
|
.execute();
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
10
12
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
11
|
-
await db.schema
|
|
12
|
-
.alterTable("chat_sessions")
|
|
13
|
-
.dropColumn("summary")
|
|
14
|
-
.execute();
|
|
13
|
+
await db.schema.alterTable("chat_sessions").dropColumn("summary").execute();
|
|
15
14
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Kysely, sql } from "kysely";
|
|
2
2
|
|
|
3
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
3
4
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
4
5
|
// ── workflow_definitions ──────────────────────────────────────────
|
|
5
6
|
await db.schema
|
|
@@ -137,10 +138,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
137
138
|
c.primaryKey().defaultTo(sql`gen_random_uuid()`),
|
|
138
139
|
)
|
|
139
140
|
.addColumn("definition_id", "uuid", (c) =>
|
|
140
|
-
c
|
|
141
|
-
.notNull()
|
|
142
|
-
.references("workflow_definitions.id")
|
|
143
|
-
.onDelete("cascade"),
|
|
141
|
+
c.notNull().references("workflow_definitions.id").onDelete("cascade"),
|
|
144
142
|
)
|
|
145
143
|
.addColumn("cron_expr", "text", (c) => c.notNull())
|
|
146
144
|
.addColumn("timezone", "text", (c) => c.notNull().defaultTo("UTC"))
|
|
@@ -176,6 +174,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
176
174
|
`.execute(db);
|
|
177
175
|
}
|
|
178
176
|
|
|
177
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
179
178
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
180
179
|
await sql`DROP TRIGGER IF EXISTS workflow_queue_notify ON workflow_queue`.execute(
|
|
181
180
|
db,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Kysely, sql } from "kysely";
|
|
2
2
|
|
|
3
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
3
4
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
4
5
|
await db.schema
|
|
5
6
|
.createTable("workflow_cursors")
|
|
@@ -11,6 +12,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
11
12
|
.execute();
|
|
12
13
|
}
|
|
13
14
|
|
|
15
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
14
16
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
15
17
|
await db.schema.dropTable("workflow_cursors").execute();
|
|
16
18
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Kysely, sql } from "kysely";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Account-wide subgraph scoping.
|
|
@@ -13,6 +13,7 @@ import { sql, type Kysely } from "kysely";
|
|
|
13
13
|
* After this migration, any API key on the same account can deploy/update
|
|
14
14
|
* the same named subgraph without creating duplicates.
|
|
15
15
|
*/
|
|
16
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
16
17
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
17
18
|
// 1. Add account_id column (nullable first so we can backfill)
|
|
18
19
|
await db.schema
|
|
@@ -79,6 +80,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
79
80
|
`.execute(db);
|
|
80
81
|
|
|
81
82
|
for (const row of rows.rows) {
|
|
83
|
+
// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation
|
|
82
84
|
const oldSchema = row.schema_name!;
|
|
83
85
|
const accountPrefix = row.account_id.slice(0, 8).replace(/-/g, "_");
|
|
84
86
|
const safeName = row.name.replace(/-/g, "_");
|
|
@@ -95,7 +97,9 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
95
97
|
`.execute(db);
|
|
96
98
|
|
|
97
99
|
if (exists.rows[0]?.exists) {
|
|
98
|
-
await sql`ALTER SCHEMA ${sql.raw(`"${oldSchema}"`)} RENAME TO ${sql.raw(`"${newSchema}"`)}`.execute(
|
|
100
|
+
await sql`ALTER SCHEMA ${sql.raw(`"${oldSchema}"`)} RENAME TO ${sql.raw(`"${newSchema}"`)}`.execute(
|
|
101
|
+
db,
|
|
102
|
+
);
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
// Update schema_name column regardless of whether schema existed
|
|
@@ -105,6 +109,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
111
|
|
|
112
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
108
113
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
109
114
|
await db.schema.dropIndex("subgraphs_account_id_idx").ifExists().execute();
|
|
110
115
|
await db.schema
|
|
@@ -8,6 +8,7 @@ import type { Kysely } from "kysely";
|
|
|
8
8
|
* writable layer and are lost on container recreation (e.g. CI deploys).
|
|
9
9
|
* With handler_code stored in DB, the API can restore the file on startup.
|
|
10
10
|
*/
|
|
11
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
11
12
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
12
13
|
await db.schema
|
|
13
14
|
.alterTable("subgraphs")
|
|
@@ -15,9 +16,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
15
16
|
.execute();
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
18
20
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
19
|
-
await db.schema
|
|
20
|
-
.alterTable("subgraphs")
|
|
21
|
-
.dropColumn("handler_code")
|
|
22
|
-
.execute();
|
|
21
|
+
await db.schema.alterTable("subgraphs").dropColumn("handler_code").execute();
|
|
23
22
|
}
|
|
@@ -6,6 +6,7 @@ import type { Kysely } from "kysely";
|
|
|
6
6
|
* without re-hydrating from a file. Nullable: rows deployed before this
|
|
7
7
|
* migration remain read-only until their next redeploy.
|
|
8
8
|
*/
|
|
9
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
9
10
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
10
11
|
await db.schema
|
|
11
12
|
.alterTable("workflow_definitions")
|
|
@@ -13,6 +14,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
13
14
|
.execute();
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
16
18
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
17
19
|
await db.schema
|
|
18
20
|
.alterTable("workflow_definitions")
|
|
@@ -6,6 +6,7 @@ import type { Kysely } from "kysely";
|
|
|
6
6
|
* re-hydrating from a file. Nullable: rows deployed before this migration
|
|
7
7
|
* remain read-only until their next redeploy.
|
|
8
8
|
*/
|
|
9
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
9
10
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
10
11
|
await db.schema
|
|
11
12
|
.alterTable("subgraphs")
|
|
@@ -13,6 +14,7 @@ export async function up(db: Kysely<any>): Promise<void> {
|
|
|
13
14
|
.execute();
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety
|
|
16
18
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
17
19
|
await db.schema.alterTable("subgraphs").dropColumn("source_code").execute();
|
|
18
20
|
}
|
|
@@ -2,33 +2,33 @@ import type { Kysely, Sql } from "kysely";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Migration: Drop streams feature tables
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* This migration removes the entire streams feature from the database.
|
|
7
7
|
* Tables are dropped in dependency order (child tables first):
|
|
8
8
|
* 1. deliveries (references jobs and streams)
|
|
9
9
|
* 2. jobs (references streams)
|
|
10
10
|
* 3. stream_metrics (references streams)
|
|
11
11
|
* 4. streams (main table)
|
|
12
|
-
*
|
|
12
|
+
*
|
|
13
13
|
* Note: This is a destructive migration. All stream data will be lost.
|
|
14
14
|
* Ensure you have a backup if you need to preserve historical data.
|
|
15
|
-
*
|
|
15
|
+
*
|
|
16
16
|
* Associated code changes:
|
|
17
17
|
* - PG NOTIFY channel renamed from "streams:new_job" to "indexer:new_block"
|
|
18
18
|
* for subgraph processor block notifications.
|
|
19
19
|
*/
|
|
20
20
|
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
21
21
|
// Drop child tables first (in dependency order)
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
// Drop deliveries table
|
|
24
24
|
await db.schema.dropTable("deliveries").ifExists().execute();
|
|
25
|
-
|
|
26
|
-
// Drop jobs table
|
|
25
|
+
|
|
26
|
+
// Drop jobs table
|
|
27
27
|
await db.schema.dropTable("jobs").ifExists().execute();
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
// Drop stream_metrics table
|
|
30
30
|
await db.schema.dropTable("stream_metrics").ifExists().execute();
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
// Drop main streams table
|
|
33
33
|
await db.schema.dropTable("streams").ifExists().execute();
|
|
34
34
|
}
|
|
@@ -38,6 +38,6 @@ export async function down(_db: Kysely<Sql>): Promise<void> {
|
|
|
38
38
|
// To restore, you'd need to re-run the initial migration that created these tables
|
|
39
39
|
throw new Error(
|
|
40
40
|
"Down migration not supported for streams table removal. " +
|
|
41
|
-
|
|
41
|
+
"To restore, restore from a backup or recreate the streams feature.",
|
|
42
42
|
);
|
|
43
43
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secondlayer/shared",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/src/index.js",
|
|
6
6
|
"types": "./dist/src/index.d.ts",
|
|
@@ -184,7 +184,7 @@
|
|
|
184
184
|
"prepublishOnly": "bun run build"
|
|
185
185
|
},
|
|
186
186
|
"dependencies": {
|
|
187
|
-
"@secondlayer/stacks": "^2.0.
|
|
187
|
+
"@secondlayer/stacks": "^2.0.1",
|
|
188
188
|
"kysely": "0.28.15",
|
|
189
189
|
"kysely-postgres-js": "3.0.0",
|
|
190
190
|
"postgres": "^3.4.6",
|