@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.
- package/LICENSE +21 -0
- package/dist/app-state.d.ts +12 -0
- package/dist/app-state.js +18 -0
- package/dist/boot-checks.d.ts +56 -0
- package/dist/boot-checks.js +228 -0
- package/dist/classify.d.ts +6 -0
- package/dist/classify.js +75 -0
- package/dist/control-plane.d.ts +75 -0
- package/dist/control-plane.js +155 -0
- package/dist/delete-guard.d.ts +32 -0
- package/dist/delete-guard.js +62 -0
- package/dist/fenced-client.d.ts +35 -0
- package/dist/fenced-client.js +153 -0
- package/dist/grant-ro.d.ts +23 -0
- package/dist/grant-ro.js +49 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +10 -0
- package/dist/internal/control-pool.d.ts +20 -0
- package/dist/internal/control-pool.js +17 -0
- package/dist/loader.d.ts +15 -0
- package/dist/loader.js +82 -0
- package/dist/migrate.d.ts +54 -0
- package/dist/migrate.js +143 -0
- package/dist/migration-policy.d.ts +14 -0
- package/dist/migration-policy.js +85 -0
- package/dist/migrator.d.ts +9 -0
- package/dist/migrator.js +9 -0
- package/dist/roles.d.ts +47 -0
- package/dist/roles.js +112 -0
- package/dist/schema/app.d.ts +235 -0
- package/dist/schema/app.js +23 -0
- package/dist/schema/approvals.d.ts +352 -0
- package/dist/schema/approvals.js +43 -0
- package/dist/schema/auth.d.ts +1272 -0
- package/dist/schema/auth.js +120 -0
- package/dist/schema/index.d.ts +7 -0
- package/dist/schema/index.js +7 -0
- package/dist/schema/ledger.d.ts +722 -0
- package/dist/schema/ledger.js +68 -0
- package/dist/schema/machinery.d.ts +1343 -0
- package/dist/schema/machinery.js +146 -0
- package/dist/schema/records.d.ts +15 -0
- package/dist/schema/records.js +16 -0
- package/dist/schema/runs.d.ts +213 -0
- package/dist/schema/runs.js +26 -0
- package/dist/step-pool.d.ts +26 -0
- package/dist/step-pool.js +57 -0
- package/migrations/0000_core_schema.sql +185 -0
- package/migrations/0001_llm_call_reservation_index.sql +4 -0
- package/migrations/0002_approvals.sql +25 -0
- package/migrations/0003_auth_invitation.sql +13 -0
- package/migrations/0004_machinery.sql +105 -0
- package/migrations/0005_nullable_activity_task_record.sql +4 -0
- package/migrations/0006_activity_score_key.sql +5 -0
- package/migrations/0007_score_spec_name.sql +3 -0
- package/migrations/meta/0000_snapshot.json +1238 -0
- package/migrations/meta/0001_snapshot.json +1238 -0
- package/migrations/meta/0002_snapshot.json +1426 -0
- package/migrations/meta/0003_snapshot.json +1516 -0
- package/migrations/meta/0004_snapshot.json +2353 -0
- package/migrations/meta/0005_snapshot.json +2353 -0
- package/migrations/meta/0006_snapshot.json +2415 -0
- package/migrations/meta/0007_snapshot.json +2427 -0
- package/migrations/meta/_journal.json +62 -0
- 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
|
+
});
|