@secondlayer/shared 11.6.1 → 11.7.1
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/archive/range-digest.d.ts +46 -27
- package/dist/src/archive/semantic-digest-builder.d.ts +46 -27
- package/dist/src/coverage/index.d.ts +46 -27
- package/dist/src/db/index.d.ts +57 -39
- package/dist/src/db/index.js +5 -4
- package/dist/src/db/index.js.map +3 -3
- package/dist/src/db/queries/chain-reorgs.d.ts +46 -27
- package/dist/src/db/queries/chain-reorgs.js +5 -4
- package/dist/src/db/queries/chain-reorgs.js.map +3 -3
- package/dist/src/db/queries/contracts.d.ts +46 -27
- package/dist/src/db/queries/instance.d.ts +46 -27
- package/dist/src/db/queries/integrity.d.ts +47 -28
- package/dist/src/db/queries/integrity.js +4 -3
- package/dist/src/db/queries/integrity.js.map +3 -3
- package/dist/src/db/queries/subgraph-gaps.d.ts +46 -27
- package/dist/src/db/queries/subgraph-operations.d.ts +46 -27
- package/dist/src/db/queries/subgraphs.d.ts +47 -33
- package/dist/src/db/queries/subgraphs.js +1 -10
- package/dist/src/db/queries/subgraphs.js.map +3 -3
- package/dist/src/db/queries/sync-scope.d.ts +46 -27
- package/dist/src/db/queries/webhooks.d.ts +46 -27
- package/dist/src/db/schema.d.ts +53 -36
- package/dist/src/index-http.d.ts +23 -0
- package/dist/src/index-http.js +9 -2
- package/dist/src/index-http.js.map +3 -3
- package/dist/src/index.d.ts +86 -42
- package/dist/src/index.js +58 -6
- package/dist/src/index.js.map +5 -5
- package/dist/src/node/local-client.d.ts +67 -28
- package/dist/src/node/local-client.js +41 -2
- package/dist/src/node/local-client.js.map +5 -4
- package/dist/src/schemas/index.d.ts +23 -1
- package/dist/src/schemas/index.js +38 -1
- package/dist/src/schemas/index.js.map +3 -3
- package/dist/src/schemas/webhooks.d.ts +23 -1
- package/dist/src/schemas/webhooks.js +38 -1
- package/dist/src/schemas/webhooks.js.map +3 -3
- package/dist/src/streams-rows/index.d.ts +43 -1
- package/dist/src/streams-rows/index.js +14 -3
- package/dist/src/streams-rows/index.js.map +3 -3
- package/dist/src/types.d.ts +12 -1
- package/migrations/0131_vm_events.ts +81 -0
- package/migrations/0132_vm_events_type_ordinal_idx.ts +21 -0
- package/migrations/0133_vm_events_fk_cascade.ts +47 -0
- package/migrations/0134_waitlists.ts +64 -0
- package/migrations/0135_drop_hosted_play_and_meters.ts +58 -0
- package/package.json +2 -2
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type Kysely, sql } from "kysely";
|
|
2
|
+
import { onControlPlane } from "../src/db/migration-role.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Public waitlists. `waitlists` says what each list is for and whether it
|
|
6
|
+
* is open; `waitlist_signups` holds one row per (list, contact, token).
|
|
7
|
+
*
|
|
8
|
+
* `contact` is free text (Telegram, X handle, or email) because token
|
|
9
|
+
* communities live on Telegram, not in inboxes. `answers` holds the
|
|
10
|
+
* per-list questions (the bridge list asks role, token, contract, note);
|
|
11
|
+
* the API validates them per list before insert. Opening or closing an
|
|
12
|
+
* existing list is a `closed_at` update, not a deploy. Control plane,
|
|
13
|
+
* next to `accounts`; nothing here is an account.
|
|
14
|
+
*/
|
|
15
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
16
|
+
await onControlPlane(async () => {
|
|
17
|
+
await sql`SET lock_timeout = '30s'`.execute(db);
|
|
18
|
+
|
|
19
|
+
await sql`
|
|
20
|
+
CREATE TABLE waitlists (
|
|
21
|
+
slug text PRIMARY KEY,
|
|
22
|
+
title text NOT NULL,
|
|
23
|
+
description text NOT NULL,
|
|
24
|
+
url text NOT NULL,
|
|
25
|
+
opened_at timestamptz NOT NULL DEFAULT now(),
|
|
26
|
+
closed_at timestamptz
|
|
27
|
+
)
|
|
28
|
+
`.execute(db);
|
|
29
|
+
|
|
30
|
+
await sql`
|
|
31
|
+
CREATE TABLE waitlist_signups (
|
|
32
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
33
|
+
list text NOT NULL REFERENCES waitlists(slug),
|
|
34
|
+
contact text NOT NULL,
|
|
35
|
+
answers jsonb NOT NULL DEFAULT '{}'::jsonb,
|
|
36
|
+
created_at timestamptz NOT NULL DEFAULT now()
|
|
37
|
+
)
|
|
38
|
+
`.execute(db);
|
|
39
|
+
|
|
40
|
+
// A repeat submit from the same person for the same token is a no-op.
|
|
41
|
+
// Lists without a token answer dedupe on contact alone.
|
|
42
|
+
await sql`
|
|
43
|
+
CREATE UNIQUE INDEX waitlist_signups_list_contact_token_key
|
|
44
|
+
ON waitlist_signups (list, lower(contact), lower(coalesce(answers->>'token', '')))
|
|
45
|
+
`.execute(db);
|
|
46
|
+
|
|
47
|
+
await sql`
|
|
48
|
+
INSERT INTO waitlists (slug, title, description, url)
|
|
49
|
+
VALUES (
|
|
50
|
+
'robinhood',
|
|
51
|
+
'Stacks to Robinhood Chain',
|
|
52
|
+
'SIP-010 tokens that want to bridge Stacks to Robinhood Chain (chain 4663) and back; picks the first tokens for phase 1 testing.',
|
|
53
|
+
'https://www.secondlayer.tools/robinhood'
|
|
54
|
+
)
|
|
55
|
+
`.execute(db);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
60
|
+
await onControlPlane(async () => {
|
|
61
|
+
await sql`DROP TABLE IF EXISTS waitlist_signups`.execute(db);
|
|
62
|
+
await sql`DROP TABLE IF EXISTS waitlists`.execute(db);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type Kysely, sql } from "kysely";
|
|
2
|
+
import { onControlPlane } from "../src/db/migration-role.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Drop the hosted subgraph tables: accountless play (claim_tokens,
|
|
6
|
+
* play_provisions, from 0125) and the hosted meter ledger (hosted_meter_days,
|
|
7
|
+
* from 0124). Hosted subgraphs are not offered; subgraphs and webhooks run on
|
|
8
|
+
* self-host only. Prod 2026-09-23: count(*) = 0 on all three.
|
|
9
|
+
*
|
|
10
|
+
* `down` recreates the empty tables exactly as 0124/0125 created them.
|
|
11
|
+
*/
|
|
12
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
13
|
+
await sql`SET lock_timeout = '30s'`.execute(db);
|
|
14
|
+
await onControlPlane(async () => {
|
|
15
|
+
await sql`DROP TABLE IF EXISTS hosted_meter_days`.execute(db);
|
|
16
|
+
await sql`DROP TABLE IF EXISTS play_provisions`.execute(db);
|
|
17
|
+
await sql`DROP TABLE IF EXISTS claim_tokens`.execute(db);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
22
|
+
await sql`SET lock_timeout = '30s'`.execute(db);
|
|
23
|
+
await onControlPlane(async () => {
|
|
24
|
+
await sql`
|
|
25
|
+
CREATE TABLE IF NOT EXISTS claim_tokens (
|
|
26
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
27
|
+
account_id UUID NOT NULL REFERENCES accounts(id) ON DELETE CASCADE,
|
|
28
|
+
token_hash TEXT NOT NULL UNIQUE,
|
|
29
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
30
|
+
expires_at TIMESTAMPTZ NOT NULL,
|
|
31
|
+
used_at TIMESTAMPTZ
|
|
32
|
+
)
|
|
33
|
+
`.execute(db);
|
|
34
|
+
await sql`CREATE INDEX IF NOT EXISTS claim_tokens_account_id_idx ON claim_tokens (account_id)`.execute(
|
|
35
|
+
db,
|
|
36
|
+
);
|
|
37
|
+
await sql`
|
|
38
|
+
CREATE TABLE IF NOT EXISTS play_provisions (
|
|
39
|
+
ip_hash TEXT NOT NULL,
|
|
40
|
+
day DATE NOT NULL,
|
|
41
|
+
count INTEGER NOT NULL DEFAULT 1,
|
|
42
|
+
PRIMARY KEY (ip_hash, day)
|
|
43
|
+
)
|
|
44
|
+
`.execute(db);
|
|
45
|
+
await sql`
|
|
46
|
+
CREATE TABLE IF NOT EXISTS hosted_meter_days (
|
|
47
|
+
day date NOT NULL,
|
|
48
|
+
account_id text NOT NULL,
|
|
49
|
+
subgraph_name text NOT NULL,
|
|
50
|
+
kind text NOT NULL,
|
|
51
|
+
usd_micros bigint NOT NULL,
|
|
52
|
+
billed_at timestamptz NOT NULL DEFAULT now(),
|
|
53
|
+
PRIMARY KEY (day, account_id, subgraph_name, kind),
|
|
54
|
+
CHECK (kind IN ('running', 'storage'))
|
|
55
|
+
)
|
|
56
|
+
`.execute(db);
|
|
57
|
+
});
|
|
58
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secondlayer/shared",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.7.1",
|
|
4
4
|
"description": "Internal building blocks shared across Secondlayer packages.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -233,7 +233,7 @@
|
|
|
233
233
|
"prepublishOnly": "bun run build"
|
|
234
234
|
},
|
|
235
235
|
"dependencies": {
|
|
236
|
-
"@secondlayer/stacks": "^6.
|
|
236
|
+
"@secondlayer/stacks": "^6.1.0",
|
|
237
237
|
"kysely": "0.28.17",
|
|
238
238
|
"kysely-postgres-js": "3.0.0",
|
|
239
239
|
"postgres": "^3.4.6",
|