@secondlayer/shared 12.1.0 → 12.1.2

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.
Files changed (41) hide show
  1. package/dist/src/archive/copy-loader.d.ts +1 -0
  2. package/dist/src/archive/copy-loader.js.map +2 -2
  3. package/dist/src/archive/instance-diagnosis.d.ts +1 -0
  4. package/dist/src/archive/instance-diagnosis.js.map +2 -2
  5. package/dist/src/archive/range-digest.d.ts +4 -2
  6. package/dist/src/archive/reference.d.ts +1 -0
  7. package/dist/src/archive/reference.js.map +2 -2
  8. package/dist/src/archive/semantic-digest-builder.d.ts +4 -2
  9. package/dist/src/archive/status.d.ts +1 -0
  10. package/dist/src/archive/status.js.map +2 -2
  11. package/dist/src/coverage/index.d.ts +4 -2
  12. package/dist/src/db/index.d.ts +4 -2
  13. package/dist/src/db/queries/chain-reorgs.d.ts +4 -2
  14. package/dist/src/db/queries/contracts.d.ts +4 -2
  15. package/dist/src/db/queries/instance.d.ts +4 -2
  16. package/dist/src/db/queries/integrity.d.ts +4 -2
  17. package/dist/src/db/queries/subgraph-gaps.d.ts +4 -2
  18. package/dist/src/db/queries/subgraph-operations.d.ts +4 -2
  19. package/dist/src/db/queries/subgraphs.d.ts +4 -2
  20. package/dist/src/db/queries/subgraphs.js.map +2 -2
  21. package/dist/src/db/queries/sync-scope.d.ts +4 -2
  22. package/dist/src/db/queries/webhooks.d.ts +4 -2
  23. package/dist/src/db/schema.d.ts +4 -2
  24. package/dist/src/index-http.d.ts +1 -0
  25. package/dist/src/index.d.ts +21 -2
  26. package/dist/src/index.js.map +4 -4
  27. package/dist/src/node/archive-client.d.ts +1 -0
  28. package/dist/src/node/archive-client.js.map +2 -2
  29. package/dist/src/node/local-client.d.ts +4 -2
  30. package/dist/src/schemas/index.d.ts +15 -0
  31. package/dist/src/schemas/index.js.map +3 -3
  32. package/dist/src/schemas/subgraphs.d.ts +6 -0
  33. package/dist/src/schemas/subgraphs.js.map +2 -2
  34. package/dist/src/schemas/webhooks.d.ts +18 -5
  35. package/dist/src/schemas/webhooks.js.map +2 -2
  36. package/dist/src/streams-rows/index.d.ts +8 -4
  37. package/dist/src/subgraphs/spec.d.ts +3 -0
  38. package/dist/src/subgraphs/spec.js.map +2 -2
  39. package/migrations/0161_observer_journal_retried.ts +50 -0
  40. package/migrations/0164_api_keys_docs_product.ts +52 -0
  41. package/package.json +2 -2
@@ -0,0 +1,52 @@
1
+ import { type Kysely, sql } from "kysely";
2
+ import { onControlPlane } from "../src/db/migration-role.ts";
3
+
4
+ /**
5
+ * Docs keys: `api_keys.product = 'docs'`, short-lived (24h) read keys minted
6
+ * for a signed-in reader so code samples can carry their own key. They resolve
7
+ * on the Streams and Index read planes only. `expires_at` is null for every
8
+ * other key. At most one active docs key per account (minting a new one revokes
9
+ * the previous).
10
+ */
11
+ export async function up(db: Kysely<unknown>): Promise<void> {
12
+ await onControlPlane(async () => {
13
+ await sql`SET lock_timeout = '30s'`.execute(db);
14
+ await sql`ALTER TABLE api_keys ADD COLUMN IF NOT EXISTS expires_at timestamptz`.execute(
15
+ db,
16
+ );
17
+ await sql`
18
+ ALTER TABLE api_keys DROP CONSTRAINT IF EXISTS api_keys_product_check
19
+ `.execute(db);
20
+ await sql`
21
+ ALTER TABLE api_keys
22
+ ADD CONSTRAINT api_keys_product_check
23
+ CHECK (product IN ('account', 'streams', 'index', 'sentinel', 'docs'))
24
+ `.execute(db);
25
+ await sql`
26
+ CREATE UNIQUE INDEX IF NOT EXISTS api_keys_one_active_docs_per_account
27
+ ON api_keys (account_id)
28
+ WHERE status = 'active' AND product = 'docs'
29
+ `.execute(db);
30
+ });
31
+ }
32
+
33
+ export async function down(db: Kysely<unknown>): Promise<void> {
34
+ await onControlPlane(async () => {
35
+ await sql`SET lock_timeout = '30s'`.execute(db);
36
+ await sql`DROP INDEX IF EXISTS api_keys_one_active_docs_per_account`.execute(
37
+ db,
38
+ );
39
+ await sql`DELETE FROM api_keys WHERE product = 'docs'`.execute(db);
40
+ await sql`
41
+ ALTER TABLE api_keys DROP CONSTRAINT IF EXISTS api_keys_product_check
42
+ `.execute(db);
43
+ await sql`
44
+ ALTER TABLE api_keys
45
+ ADD CONSTRAINT api_keys_product_check
46
+ CHECK (product IN ('account', 'streams', 'index', 'sentinel'))
47
+ `.execute(db);
48
+ await sql`ALTER TABLE api_keys DROP COLUMN IF EXISTS expires_at`.execute(
49
+ db,
50
+ );
51
+ });
52
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@secondlayer/shared",
3
- "version": "12.1.0",
3
+ "version": "12.1.2",
4
4
  "description": "Internal building blocks shared across Secondlayer packages.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -249,7 +249,7 @@
249
249
  "prepublishOnly": "bun run build"
250
250
  },
251
251
  "dependencies": {
252
- "@secondlayer/stacks": "^6.2.0",
252
+ "@secondlayer/stacks": "^6.2.2",
253
253
  "kysely": "0.28.17",
254
254
  "kysely-postgres-js": "3.0.0",
255
255
  "postgres": "^3.4.6",