@hyperfixation/db 0.1.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.
Files changed (65) hide show
  1. package/LICENSE +21 -0
  2. package/dist/app-state.d.ts +12 -0
  3. package/dist/app-state.js +18 -0
  4. package/dist/boot-checks.d.ts +56 -0
  5. package/dist/boot-checks.js +228 -0
  6. package/dist/classify.d.ts +6 -0
  7. package/dist/classify.js +75 -0
  8. package/dist/control-plane.d.ts +75 -0
  9. package/dist/control-plane.js +155 -0
  10. package/dist/delete-guard.d.ts +32 -0
  11. package/dist/delete-guard.js +62 -0
  12. package/dist/fenced-client.d.ts +35 -0
  13. package/dist/fenced-client.js +153 -0
  14. package/dist/grant-ro.d.ts +23 -0
  15. package/dist/grant-ro.js +49 -0
  16. package/dist/index.d.ts +12 -0
  17. package/dist/index.js +10 -0
  18. package/dist/internal/control-pool.d.ts +20 -0
  19. package/dist/internal/control-pool.js +17 -0
  20. package/dist/loader.d.ts +15 -0
  21. package/dist/loader.js +82 -0
  22. package/dist/migrate.d.ts +54 -0
  23. package/dist/migrate.js +143 -0
  24. package/dist/migration-policy.d.ts +14 -0
  25. package/dist/migration-policy.js +85 -0
  26. package/dist/migrator.d.ts +9 -0
  27. package/dist/migrator.js +9 -0
  28. package/dist/roles.d.ts +47 -0
  29. package/dist/roles.js +112 -0
  30. package/dist/schema/app.d.ts +235 -0
  31. package/dist/schema/app.js +23 -0
  32. package/dist/schema/approvals.d.ts +352 -0
  33. package/dist/schema/approvals.js +43 -0
  34. package/dist/schema/auth.d.ts +1272 -0
  35. package/dist/schema/auth.js +120 -0
  36. package/dist/schema/index.d.ts +7 -0
  37. package/dist/schema/index.js +7 -0
  38. package/dist/schema/ledger.d.ts +722 -0
  39. package/dist/schema/ledger.js +68 -0
  40. package/dist/schema/machinery.d.ts +1343 -0
  41. package/dist/schema/machinery.js +146 -0
  42. package/dist/schema/records.d.ts +15 -0
  43. package/dist/schema/records.js +16 -0
  44. package/dist/schema/runs.d.ts +213 -0
  45. package/dist/schema/runs.js +26 -0
  46. package/dist/step-pool.d.ts +26 -0
  47. package/dist/step-pool.js +57 -0
  48. package/migrations/0000_core_schema.sql +185 -0
  49. package/migrations/0001_llm_call_reservation_index.sql +4 -0
  50. package/migrations/0002_approvals.sql +25 -0
  51. package/migrations/0003_auth_invitation.sql +13 -0
  52. package/migrations/0004_machinery.sql +105 -0
  53. package/migrations/0005_nullable_activity_task_record.sql +4 -0
  54. package/migrations/0006_activity_score_key.sql +5 -0
  55. package/migrations/0007_score_spec_name.sql +3 -0
  56. package/migrations/meta/0000_snapshot.json +1238 -0
  57. package/migrations/meta/0001_snapshot.json +1238 -0
  58. package/migrations/meta/0002_snapshot.json +1426 -0
  59. package/migrations/meta/0003_snapshot.json +1516 -0
  60. package/migrations/meta/0004_snapshot.json +2353 -0
  61. package/migrations/meta/0005_snapshot.json +2353 -0
  62. package/migrations/meta/0006_snapshot.json +2415 -0
  63. package/migrations/meta/0007_snapshot.json +2427 -0
  64. package/migrations/meta/_journal.json +62 -0
  65. package/package.json +58 -0
@@ -0,0 +1,120 @@
1
+ import { boolean, integer, pgTable, text, timestamp } from "drizzle-orm/pg-core";
2
+ const createdAt = () => timestamp("created_at", { withTimezone: true, mode: "date" }).notNull().defaultNow();
3
+ const updatedAt = () => timestamp("updated_at", { withTimezone: true, mode: "date" }).notNull().defaultNow();
4
+ export const sessionFactors = ["code", "passkey"];
5
+ export const hfUser = pgTable("hf_user", {
6
+ id: text("id").primaryKey(),
7
+ name: text("name").notNull(),
8
+ email: text("email").notNull().unique(),
9
+ emailVerified: boolean("email_verified").notNull().default(false),
10
+ image: text("image"),
11
+ createdAt: createdAt(),
12
+ updatedAt: updatedAt(),
13
+ role: text("role"),
14
+ banned: boolean("banned").default(false),
15
+ banReason: text("ban_reason"),
16
+ banExpires: timestamp("ban_expires", { withTimezone: true, mode: "date" }),
17
+ });
18
+ export const hfSession = pgTable("hf_session", {
19
+ id: text("id").primaryKey(),
20
+ expiresAt: timestamp("expires_at", { withTimezone: true, mode: "date" }).notNull(),
21
+ token: text("token").notNull().unique(),
22
+ createdAt: createdAt(),
23
+ updatedAt: updatedAt(),
24
+ ipAddress: text("ip_address"),
25
+ userAgent: text("user_agent"),
26
+ userId: text("user_id")
27
+ .notNull()
28
+ .references(() => hfUser.id, { onDelete: "cascade" }),
29
+ activeOrganizationId: text("active_organization_id"),
30
+ impersonatedBy: text("impersonated_by"),
31
+ // Defaults to the weaker factor: a session created by a path that does not yet
32
+ // stamp one must not pass a passkey-gated check by omission.
33
+ factor: text("factor", { enum: sessionFactors }).notNull().default("code"),
34
+ });
35
+ export const hfAccount = pgTable("hf_account", {
36
+ id: text("id").primaryKey(),
37
+ accountId: text("account_id").notNull(),
38
+ providerId: text("provider_id").notNull(),
39
+ userId: text("user_id")
40
+ .notNull()
41
+ .references(() => hfUser.id, { onDelete: "cascade" }),
42
+ accessToken: text("access_token"),
43
+ refreshToken: text("refresh_token"),
44
+ idToken: text("id_token"),
45
+ accessTokenExpiresAt: timestamp("access_token_expires_at", {
46
+ withTimezone: true,
47
+ mode: "date",
48
+ }),
49
+ refreshTokenExpiresAt: timestamp("refresh_token_expires_at", {
50
+ withTimezone: true,
51
+ mode: "date",
52
+ }),
53
+ scope: text("scope"),
54
+ password: text("password"),
55
+ createdAt: createdAt(),
56
+ updatedAt: updatedAt(),
57
+ });
58
+ export const hfVerification = pgTable("hf_verification", {
59
+ id: text("id").primaryKey(),
60
+ identifier: text("identifier").notNull(),
61
+ value: text("value").notNull(),
62
+ expiresAt: timestamp("expires_at", { withTimezone: true, mode: "date" }).notNull(),
63
+ createdAt: createdAt(),
64
+ updatedAt: updatedAt(),
65
+ });
66
+ export const hfPasskey = pgTable("hf_passkey", {
67
+ id: text("id").primaryKey(),
68
+ name: text("name"),
69
+ publicKey: text("public_key").notNull(),
70
+ userId: text("user_id")
71
+ .notNull()
72
+ .references(() => hfUser.id, { onDelete: "cascade" }),
73
+ credentialID: text("credential_id").notNull(),
74
+ counter: integer("counter").notNull(),
75
+ deviceType: text("device_type").notNull(),
76
+ backedUp: boolean("backed_up").notNull(),
77
+ transports: text("transports"),
78
+ createdAt: timestamp("created_at", { withTimezone: true, mode: "date" }).defaultNow(),
79
+ aaguid: text("aaguid"),
80
+ });
81
+ export const hfOrganization = pgTable("hf_organization", {
82
+ id: text("id").primaryKey(),
83
+ name: text("name").notNull(),
84
+ slug: text("slug").notNull().unique(),
85
+ logo: text("logo"),
86
+ createdAt: createdAt(),
87
+ metadata: text("metadata"),
88
+ });
89
+ /**
90
+ * Added by track C, not by chunk 2: better-auth's `organization` plugin refuses to initialise
91
+ * at all when a model it writes has no table, so the seven this file started with were one
92
+ * short of a plugin the plan requires. Nothing in Phase 1 sends an invitation — `disableSignUp`
93
+ * leaves an invited stranger nowhere to land — but the table has to exist for the rest of the
94
+ * plugin to work.
95
+ */
96
+ export const hfInvitation = pgTable("hf_invitation", {
97
+ id: text("id").primaryKey(),
98
+ organizationId: text("organization_id")
99
+ .notNull()
100
+ .references(() => hfOrganization.id, { onDelete: "cascade" }),
101
+ email: text("email").notNull(),
102
+ role: text("role"),
103
+ status: text("status").notNull().default("pending"),
104
+ expiresAt: timestamp("expires_at", { withTimezone: true, mode: "date" }).notNull(),
105
+ inviterId: text("inviter_id")
106
+ .notNull()
107
+ .references(() => hfUser.id, { onDelete: "cascade" }),
108
+ createdAt: createdAt(),
109
+ });
110
+ export const hfMember = pgTable("hf_member", {
111
+ id: text("id").primaryKey(),
112
+ organizationId: text("organization_id")
113
+ .notNull()
114
+ .references(() => hfOrganization.id, { onDelete: "cascade" }),
115
+ userId: text("user_id")
116
+ .notNull()
117
+ .references(() => hfUser.id, { onDelete: "cascade" }),
118
+ role: text("role").notNull().default("member"),
119
+ createdAt: createdAt(),
120
+ });
@@ -0,0 +1,7 @@
1
+ export * from "./app.js";
2
+ export * from "./approvals.js";
3
+ export * from "./auth.js";
4
+ export * from "./ledger.js";
5
+ export * from "./machinery.js";
6
+ export * from "./records.js";
7
+ export * from "./runs.js";
@@ -0,0 +1,7 @@
1
+ export * from "./app.js";
2
+ export * from "./approvals.js";
3
+ export * from "./auth.js";
4
+ export * from "./ledger.js";
5
+ export * from "./machinery.js";
6
+ export * from "./records.js";
7
+ export * from "./runs.js";