@secondlayer/shared 7.11.0 → 7.11.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.
@@ -989,6 +989,10 @@ interface AccountCreditsTable {
989
989
  /** Month bucket ("YYYY-MM") the spend counter applies to. */
990
990
  spent_month: string | null;
991
991
  spent_month_usd_micros: Generated<string | number | bigint>;
992
+ /** Null = auto-refill off. */
993
+ refill_below_usd_micros: string | number | bigint | null;
994
+ refill_pack_usd: number | null;
995
+ refill_last_at: Date | null;
992
996
  updated_at: Generated<Date>;
993
997
  }
994
998
  type ProvisioningAuditEvent = "provision.start" | "provision.success" | "provision.failure" | "suspend" | "resume" | "resize" | "keys.rotate" | "bastion.key.upload" | "bastion.key.revoke" | "teardown";
@@ -989,6 +989,10 @@ interface AccountCreditsTable {
989
989
  /** Month bucket ("YYYY-MM") the spend counter applies to. */
990
990
  spent_month: string | null;
991
991
  spent_month_usd_micros: Generated<string | number | bigint>;
992
+ /** Null = auto-refill off. */
993
+ refill_below_usd_micros: string | number | bigint | null;
994
+ refill_pack_usd: number | null;
995
+ refill_last_at: Date | null;
992
996
  updated_at: Generated<Date>;
993
997
  }
994
998
  type ProvisioningAuditEvent = "provision.start" | "provision.success" | "provision.failure" | "suspend" | "resume" | "resize" | "keys.rotate" | "bastion.key.upload" | "bastion.key.revoke" | "teardown";
@@ -1308,6 +1308,10 @@ interface AccountCreditsTable {
1308
1308
  /** Month bucket ("YYYY-MM") the spend counter applies to. */
1309
1309
  spent_month: string | null;
1310
1310
  spent_month_usd_micros: Generated<string | number | bigint>;
1311
+ /** Null = auto-refill off. */
1312
+ refill_below_usd_micros: string | number | bigint | null;
1313
+ refill_pack_usd: number | null;
1314
+ refill_last_at: Date | null;
1311
1315
  updated_at: Generated<Date>;
1312
1316
  }
1313
1317
  type ProvisioningAuditEvent = "provision.start" | "provision.success" | "provision.failure" | "suspend" | "resume" | "resize" | "keys.rotate" | "bastion.key.upload" | "bastion.key.revoke" | "teardown";
@@ -1020,6 +1020,10 @@ interface AccountCreditsTable {
1020
1020
  /** Month bucket ("YYYY-MM") the spend counter applies to. */
1021
1021
  spent_month: string | null;
1022
1022
  spent_month_usd_micros: Generated<string | number | bigint>;
1023
+ /** Null = auto-refill off. */
1024
+ refill_below_usd_micros: string | number | bigint | null;
1025
+ refill_pack_usd: number | null;
1026
+ refill_last_at: Date | null;
1023
1027
  updated_at: Generated<Date>;
1024
1028
  }
1025
1029
  type AccountCredits = Selectable<AccountCreditsTable>;
@@ -990,6 +990,10 @@ interface AccountCreditsTable {
990
990
  /** Month bucket ("YYYY-MM") the spend counter applies to. */
991
991
  spent_month: string | null;
992
992
  spent_month_usd_micros: Generated<string | number | bigint>;
993
+ /** Null = auto-refill off. */
994
+ refill_below_usd_micros: string | number | bigint | null;
995
+ refill_pack_usd: number | null;
996
+ refill_last_at: Date | null;
993
997
  updated_at: Generated<Date>;
994
998
  }
995
999
  type ProvisioningAuditEvent = "provision.start" | "provision.success" | "provision.failure" | "suspend" | "resume" | "resize" | "keys.rotate" | "bastion.key.upload" | "bastion.key.revoke" | "teardown";
@@ -990,6 +990,10 @@ interface AccountCreditsTable {
990
990
  /** Month bucket ("YYYY-MM") the spend counter applies to. */
991
991
  spent_month: string | null;
992
992
  spent_month_usd_micros: Generated<string | number | bigint>;
993
+ /** Null = auto-refill off. */
994
+ refill_below_usd_micros: string | number | bigint | null;
995
+ refill_pack_usd: number | null;
996
+ refill_last_at: Date | null;
993
997
  updated_at: Generated<Date>;
994
998
  }
995
999
  type ProvisioningAuditEvent = "provision.start" | "provision.success" | "provision.failure" | "suspend" | "resume" | "resize" | "keys.rotate" | "bastion.key.upload" | "bastion.key.revoke" | "teardown";
@@ -990,6 +990,10 @@ interface AccountCreditsTable {
990
990
  /** Month bucket ("YYYY-MM") the spend counter applies to. */
991
991
  spent_month: string | null;
992
992
  spent_month_usd_micros: Generated<string | number | bigint>;
993
+ /** Null = auto-refill off. */
994
+ refill_below_usd_micros: string | number | bigint | null;
995
+ refill_pack_usd: number | null;
996
+ refill_last_at: Date | null;
993
997
  updated_at: Generated<Date>;
994
998
  }
995
999
  type ProvisioningAuditEvent = "provision.start" | "provision.success" | "provision.failure" | "suspend" | "resume" | "resize" | "keys.rotate" | "bastion.key.upload" | "bastion.key.revoke" | "teardown";
@@ -990,6 +990,10 @@ interface AccountCreditsTable {
990
990
  /** Month bucket ("YYYY-MM") the spend counter applies to. */
991
991
  spent_month: string | null;
992
992
  spent_month_usd_micros: Generated<string | number | bigint>;
993
+ /** Null = auto-refill off. */
994
+ refill_below_usd_micros: string | number | bigint | null;
995
+ refill_pack_usd: number | null;
996
+ refill_last_at: Date | null;
993
997
  updated_at: Generated<Date>;
994
998
  }
995
999
  type ProvisioningAuditEvent = "provision.start" | "provision.success" | "provision.failure" | "suspend" | "resume" | "resize" | "keys.rotate" | "bastion.key.upload" | "bastion.key.revoke" | "teardown";
@@ -990,6 +990,10 @@ interface AccountCreditsTable {
990
990
  /** Month bucket ("YYYY-MM") the spend counter applies to. */
991
991
  spent_month: string | null;
992
992
  spent_month_usd_micros: Generated<string | number | bigint>;
993
+ /** Null = auto-refill off. */
994
+ refill_below_usd_micros: string | number | bigint | null;
995
+ refill_pack_usd: number | null;
996
+ refill_last_at: Date | null;
993
997
  updated_at: Generated<Date>;
994
998
  }
995
999
  type ProvisioningAuditEvent = "provision.start" | "provision.success" | "provision.failure" | "suspend" | "resume" | "resize" | "keys.rotate" | "bastion.key.upload" | "bastion.key.revoke" | "teardown";
@@ -990,6 +990,10 @@ interface AccountCreditsTable {
990
990
  /** Month bucket ("YYYY-MM") the spend counter applies to. */
991
991
  spent_month: string | null;
992
992
  spent_month_usd_micros: Generated<string | number | bigint>;
993
+ /** Null = auto-refill off. */
994
+ refill_below_usd_micros: string | number | bigint | null;
995
+ refill_pack_usd: number | null;
996
+ refill_last_at: Date | null;
993
997
  updated_at: Generated<Date>;
994
998
  }
995
999
  type ProvisioningAuditEvent = "provision.start" | "provision.success" | "provision.failure" | "suspend" | "resume" | "resize" | "keys.rotate" | "bastion.key.upload" | "bastion.key.revoke" | "teardown";
@@ -991,6 +991,10 @@ interface AccountCreditsTable {
991
991
  /** Month bucket ("YYYY-MM") the spend counter applies to. */
992
992
  spent_month: string | null;
993
993
  spent_month_usd_micros: Generated<string | number | bigint>;
994
+ /** Null = auto-refill off. */
995
+ refill_below_usd_micros: string | number | bigint | null;
996
+ refill_pack_usd: number | null;
997
+ refill_last_at: Date | null;
994
998
  updated_at: Generated<Date>;
995
999
  }
996
1000
  type ProvisioningAuditEvent = "provision.start" | "provision.success" | "provision.failure" | "suspend" | "resume" | "resize" | "keys.rotate" | "bastion.key.upload" | "bastion.key.revoke" | "teardown";
@@ -990,6 +990,10 @@ interface AccountCreditsTable {
990
990
  /** Month bucket ("YYYY-MM") the spend counter applies to. */
991
991
  spent_month: string | null;
992
992
  spent_month_usd_micros: Generated<string | number | bigint>;
993
+ /** Null = auto-refill off. */
994
+ refill_below_usd_micros: string | number | bigint | null;
995
+ refill_pack_usd: number | null;
996
+ refill_last_at: Date | null;
993
997
  updated_at: Generated<Date>;
994
998
  }
995
999
  type ProvisioningAuditEvent = "provision.start" | "provision.success" | "provision.failure" | "suspend" | "resume" | "resize" | "keys.rotate" | "bastion.key.upload" | "bastion.key.revoke" | "teardown";
@@ -1001,6 +1001,10 @@ interface AccountCreditsTable {
1001
1001
  /** Month bucket ("YYYY-MM") the spend counter applies to. */
1002
1002
  spent_month: string | null;
1003
1003
  spent_month_usd_micros: Generated<string | number | bigint>;
1004
+ /** Null = auto-refill off. */
1005
+ refill_below_usd_micros: string | number | bigint | null;
1006
+ refill_pack_usd: number | null;
1007
+ refill_last_at: Date | null;
1004
1008
  updated_at: Generated<Date>;
1005
1009
  }
1006
1010
  type AccountCredits = Selectable<AccountCreditsTable>;
@@ -1001,6 +1001,10 @@ interface AccountCreditsTable {
1001
1001
  /** Month bucket ("YYYY-MM") the spend counter applies to. */
1002
1002
  spent_month: string | null;
1003
1003
  spent_month_usd_micros: Generated<string | number | bigint>;
1004
+ /** Null = auto-refill off. */
1005
+ refill_below_usd_micros: string | number | bigint | null;
1006
+ refill_pack_usd: number | null;
1007
+ refill_last_at: Date | null;
1004
1008
  updated_at: Generated<Date>;
1005
1009
  }
1006
1010
  type AccountCredits = Selectable<AccountCreditsTable>;
@@ -990,6 +990,10 @@ interface AccountCreditsTable {
990
990
  /** Month bucket ("YYYY-MM") the spend counter applies to. */
991
991
  spent_month: string | null;
992
992
  spent_month_usd_micros: Generated<string | number | bigint>;
993
+ /** Null = auto-refill off. */
994
+ refill_below_usd_micros: string | number | bigint | null;
995
+ refill_pack_usd: number | null;
996
+ refill_last_at: Date | null;
993
997
  updated_at: Generated<Date>;
994
998
  }
995
999
  type ProvisioningAuditEvent = "provision.start" | "provision.success" | "provision.failure" | "suspend" | "resume" | "resize" | "keys.rotate" | "bastion.key.upload" | "bastion.key.revoke" | "teardown";
@@ -0,0 +1,44 @@
1
+ import { type Kysely, sql } from "kysely";
2
+ import { onControlPlane } from "../src/db/migration-role.ts";
3
+
4
+ /**
5
+ * Opt-in archive-credit auto-refill. Null below = off (default).
6
+ * Worker charges the saved card when balance drops under the threshold.
7
+ */
8
+ export async function up(db: Kysely<unknown>): Promise<void> {
9
+ await onControlPlane(async () => {
10
+ await sql`
11
+ ALTER TABLE account_credits
12
+ ADD COLUMN IF NOT EXISTS refill_below_usd_micros BIGINT,
13
+ ADD COLUMN IF NOT EXISTS refill_pack_usd INTEGER,
14
+ ADD COLUMN IF NOT EXISTS refill_last_at TIMESTAMPTZ
15
+ `.execute(db);
16
+ await sql`
17
+ ALTER TABLE account_credits
18
+ DROP CONSTRAINT IF EXISTS account_credits_refill_pack_usd_check
19
+ `.execute(db);
20
+ await sql`
21
+ ALTER TABLE account_credits
22
+ ADD CONSTRAINT account_credits_refill_pack_usd_check
23
+ CHECK (
24
+ refill_pack_usd IS NULL
25
+ OR refill_pack_usd IN (10, 25, 50, 100)
26
+ )
27
+ `.execute(db);
28
+ });
29
+ }
30
+
31
+ export async function down(db: Kysely<unknown>): Promise<void> {
32
+ await onControlPlane(async () => {
33
+ await sql`
34
+ ALTER TABLE account_credits
35
+ DROP CONSTRAINT IF EXISTS account_credits_refill_pack_usd_check
36
+ `.execute(db);
37
+ await sql`
38
+ ALTER TABLE account_credits
39
+ DROP COLUMN IF EXISTS refill_below_usd_micros,
40
+ DROP COLUMN IF EXISTS refill_pack_usd,
41
+ DROP COLUMN IF EXISTS refill_last_at
42
+ `.execute(db);
43
+ });
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@secondlayer/shared",
3
- "version": "7.11.0",
3
+ "version": "7.11.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",