@rio.js/enterprise 1.4.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/README.md +89 -0
- package/dist/adapter-factory-BTRALCLD-kJBwe70v.mjs +836 -0
- package/dist/better-auth-CStoaWiq.d.mts +10 -0
- package/dist/better-auth-CqfhQJYE.mjs +558 -0
- package/dist/better-auth.d.mts +2 -0
- package/dist/better-auth.mjs +17 -0
- package/dist/bun-sqlite-dialect-2R9nCsVF-DFs6tpGr.mjs +155 -0
- package/dist/client--1_AEBPu-8Ae9icC9.mjs +125 -0
- package/dist/client.d.mts +17 -0
- package/dist/client.mjs +381 -0
- package/dist/db-BVXTgOd3.mjs +681 -0
- package/dist/db-BadqSwVl.d.mts +9542 -0
- package/dist/db-schema.final-DWleoQm0.mjs +785 -0
- package/dist/db.d.mts +2 -0
- package/dist/db.mjs +3 -0
- package/dist/dialect-C6_pK3V9-CPJHWkYR.mjs +72 -0
- package/dist/dist-CygcgJYk.mjs +422 -0
- package/dist/env-DwlNAN_D-C1zHd0cf-Cdlw8sNp.mjs +289 -0
- package/dist/esm-C5TuvtGn.mjs +15816 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +17 -0
- package/dist/init-D8lwWc90.mjs +27 -0
- package/dist/json-oFuWgANh-O1U6k3bL.mjs +3811 -0
- package/dist/kysely-adapter-D_seG51p.mjs +297 -0
- package/dist/memory-adapter-CY-oDozb.mjs +215 -0
- package/dist/misc-CbURQDlR-sLtUwwQY.mjs +7 -0
- package/dist/node-sqlite-dialect-CdC7L-ji-QLbJGmDc.mjs +155 -0
- package/dist/parser-bL7W2mQ0-YdTgjtji.mjs +140 -0
- package/dist/plugins-BNFht2HW.mjs +23358 -0
- package/dist/plugins.d.mts +1 -0
- package/dist/plugins.mjs +13 -0
- package/dist/react--VZQu7s1.mjs +560 -0
- package/dist/react.d.mts +1 -0
- package/dist/react.mjs +6 -0
- package/dist/server.d.mts +10 -0
- package/dist/server.mjs +45 -0
- package/dist/social-providers-DNfE9Ak7-Be5zMAEe.mjs +2920 -0
- package/dist/social-providers.d.mts +1 -0
- package/dist/social-providers.mjs +6 -0
- package/dist/verify-CN5Qc0e-.mjs +1183 -0
- package/package.json +98 -0
|
@@ -0,0 +1,681 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { relations } from "drizzle-orm";
|
|
3
|
+
import { boolean, index, integer, jsonb, pgSchema, text, timestamp } from "drizzle-orm/pg-core";
|
|
4
|
+
|
|
5
|
+
//#region rolldown:runtime
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __export = (all, symbols) => {
|
|
8
|
+
let target = {};
|
|
9
|
+
for (var name in all) {
|
|
10
|
+
__defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
if (symbols) {
|
|
16
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/db-schema.default.ts
|
|
24
|
+
const enterpriseSchema = pgSchema("enterprise");
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/db-schema.generated.ts
|
|
28
|
+
var db_schema_generated_exports = /* @__PURE__ */ __export({
|
|
29
|
+
account: () => account,
|
|
30
|
+
accountRelations: () => accountRelations,
|
|
31
|
+
agent: () => agent,
|
|
32
|
+
agentRelations: () => agentRelations,
|
|
33
|
+
apikey: () => apikey,
|
|
34
|
+
apikeyRelations: () => apikeyRelations,
|
|
35
|
+
asset: () => asset,
|
|
36
|
+
assetRelations: () => assetRelations,
|
|
37
|
+
assetRole: () => assetRole,
|
|
38
|
+
assetRoleRelations: () => assetRoleRelations,
|
|
39
|
+
assetShare: () => assetShare,
|
|
40
|
+
assetShareLink: () => assetShareLink,
|
|
41
|
+
assetShareLinkRelations: () => assetShareLinkRelations,
|
|
42
|
+
assetShareRelations: () => assetShareRelations,
|
|
43
|
+
assetType: () => assetType,
|
|
44
|
+
assetTypeRelations: () => assetTypeRelations,
|
|
45
|
+
invitation: () => invitation,
|
|
46
|
+
invitationRelations: () => invitationRelations,
|
|
47
|
+
member: () => member,
|
|
48
|
+
memberAssetRole: () => memberAssetRole,
|
|
49
|
+
memberAssetRoleRelations: () => memberAssetRoleRelations,
|
|
50
|
+
memberOrganizationRole: () => memberOrganizationRole,
|
|
51
|
+
memberOrganizationRoleRelations: () => memberOrganizationRoleRelations,
|
|
52
|
+
memberRelations: () => memberRelations,
|
|
53
|
+
memberTeamRole: () => memberTeamRole,
|
|
54
|
+
memberTeamRoleRelations: () => memberTeamRoleRelations,
|
|
55
|
+
oauthAccessToken: () => oauthAccessToken,
|
|
56
|
+
oauthAccessTokenRelations: () => oauthAccessTokenRelations,
|
|
57
|
+
oauthApplication: () => oauthApplication,
|
|
58
|
+
oauthApplicationRelations: () => oauthApplicationRelations,
|
|
59
|
+
oauthConsent: () => oauthConsent,
|
|
60
|
+
oauthConsentRelations: () => oauthConsentRelations,
|
|
61
|
+
object: () => object,
|
|
62
|
+
objectRelations: () => objectRelations,
|
|
63
|
+
organization: () => organization,
|
|
64
|
+
organizationRelations: () => organizationRelations,
|
|
65
|
+
organizationRole: () => organizationRole,
|
|
66
|
+
organizationRoleRelations: () => organizationRoleRelations,
|
|
67
|
+
person: () => person,
|
|
68
|
+
platformRole: () => platformRole,
|
|
69
|
+
relationship: () => relationship,
|
|
70
|
+
relationshipRelations: () => relationshipRelations,
|
|
71
|
+
schemaDefinition: () => schemaDefinition,
|
|
72
|
+
schemaDefinitionRelations: () => schemaDefinitionRelations,
|
|
73
|
+
session: () => session,
|
|
74
|
+
sessionRelations: () => sessionRelations,
|
|
75
|
+
team: () => team,
|
|
76
|
+
teamMember: () => teamMember,
|
|
77
|
+
teamMemberRelations: () => teamMemberRelations,
|
|
78
|
+
teamRelations: () => teamRelations,
|
|
79
|
+
teamRole: () => teamRole,
|
|
80
|
+
teamRoleRelations: () => teamRoleRelations,
|
|
81
|
+
twoFactor: () => twoFactor,
|
|
82
|
+
twoFactorRelations: () => twoFactorRelations,
|
|
83
|
+
user: () => user,
|
|
84
|
+
userRelations: () => userRelations,
|
|
85
|
+
verification: () => verification
|
|
86
|
+
});
|
|
87
|
+
const user = enterpriseSchema.table("user", {
|
|
88
|
+
id: text("id").primaryKey(),
|
|
89
|
+
name: text("name").notNull(),
|
|
90
|
+
email: text("email").notNull().unique(),
|
|
91
|
+
emailVerified: boolean("email_verified").default(false).notNull(),
|
|
92
|
+
image: text("image"),
|
|
93
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
94
|
+
updatedAt: timestamp("updated_at").defaultNow().$onUpdate(() => /* @__PURE__ */ new Date()).notNull(),
|
|
95
|
+
banned: boolean("banned").default(false),
|
|
96
|
+
banReason: text("ban_reason"),
|
|
97
|
+
banExpires: timestamp("ban_expires"),
|
|
98
|
+
twoFactorEnabled: boolean("two_factor_enabled").default(false),
|
|
99
|
+
actorType: text("actor_type").default("person"),
|
|
100
|
+
actorId: text("actor_id")
|
|
101
|
+
});
|
|
102
|
+
const session = enterpriseSchema.table("session", {
|
|
103
|
+
id: text("id").primaryKey(),
|
|
104
|
+
expiresAt: timestamp("expires_at").notNull(),
|
|
105
|
+
token: text("token").notNull().unique(),
|
|
106
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
107
|
+
updatedAt: timestamp("updated_at").$onUpdate(() => /* @__PURE__ */ new Date()).notNull(),
|
|
108
|
+
ipAddress: text("ip_address"),
|
|
109
|
+
userAgent: text("user_agent"),
|
|
110
|
+
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
111
|
+
impersonatedBy: text("impersonated_by"),
|
|
112
|
+
activeOrganizationId: text("active_organization_id"),
|
|
113
|
+
activeTeamId: text("active_team_id")
|
|
114
|
+
}, (table) => [index("session_userId_idx").on(table.userId)]);
|
|
115
|
+
const account = enterpriseSchema.table("account", {
|
|
116
|
+
id: text("id").primaryKey(),
|
|
117
|
+
accountId: text("account_id").notNull(),
|
|
118
|
+
providerId: text("provider_id").notNull(),
|
|
119
|
+
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
120
|
+
accessToken: text("access_token"),
|
|
121
|
+
refreshToken: text("refresh_token"),
|
|
122
|
+
idToken: text("id_token"),
|
|
123
|
+
accessTokenExpiresAt: timestamp("access_token_expires_at"),
|
|
124
|
+
refreshTokenExpiresAt: timestamp("refresh_token_expires_at"),
|
|
125
|
+
scope: text("scope"),
|
|
126
|
+
password: text("password"),
|
|
127
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
128
|
+
updatedAt: timestamp("updated_at").$onUpdate(() => /* @__PURE__ */ new Date()).notNull()
|
|
129
|
+
}, (table) => [index("account_userId_idx").on(table.userId)]);
|
|
130
|
+
const verification = enterpriseSchema.table("verification", {
|
|
131
|
+
id: text("id").primaryKey(),
|
|
132
|
+
identifier: text("identifier").notNull(),
|
|
133
|
+
value: text("value").notNull(),
|
|
134
|
+
expiresAt: timestamp("expires_at").notNull(),
|
|
135
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
136
|
+
updatedAt: timestamp("updated_at").defaultNow().$onUpdate(() => /* @__PURE__ */ new Date()).notNull()
|
|
137
|
+
}, (table) => [index("verification_identifier_idx").on(table.identifier)]);
|
|
138
|
+
const platformRole = enterpriseSchema.table("platform_role", {
|
|
139
|
+
id: text("id").primaryKey(),
|
|
140
|
+
role: text("role").notNull(),
|
|
141
|
+
name: text("name").notNull(),
|
|
142
|
+
description: text("description").notNull(),
|
|
143
|
+
metadata: jsonb("metadata")
|
|
144
|
+
});
|
|
145
|
+
const apikey = enterpriseSchema.table("apikey", {
|
|
146
|
+
id: text("id").primaryKey(),
|
|
147
|
+
name: text("name"),
|
|
148
|
+
start: text("start"),
|
|
149
|
+
prefix: text("prefix"),
|
|
150
|
+
key: text("key").notNull(),
|
|
151
|
+
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
152
|
+
refillInterval: integer("refill_interval"),
|
|
153
|
+
refillAmount: integer("refill_amount"),
|
|
154
|
+
lastRefillAt: timestamp("last_refill_at"),
|
|
155
|
+
enabled: boolean("enabled").default(true),
|
|
156
|
+
rateLimitEnabled: boolean("rate_limit_enabled").default(true),
|
|
157
|
+
rateLimitTimeWindow: integer("rate_limit_time_window").default(864e5),
|
|
158
|
+
rateLimitMax: integer("rate_limit_max").default(10),
|
|
159
|
+
requestCount: integer("request_count").default(0),
|
|
160
|
+
remaining: integer("remaining"),
|
|
161
|
+
lastRequest: timestamp("last_request"),
|
|
162
|
+
expiresAt: timestamp("expires_at"),
|
|
163
|
+
createdAt: timestamp("created_at").notNull(),
|
|
164
|
+
updatedAt: timestamp("updated_at").notNull(),
|
|
165
|
+
permissions: text("permissions"),
|
|
166
|
+
metadata: text("metadata")
|
|
167
|
+
}, (table) => [index("apikey_key_idx").on(table.key), index("apikey_userId_idx").on(table.userId)]);
|
|
168
|
+
const organization = enterpriseSchema.table("organization", {
|
|
169
|
+
id: text("id").primaryKey(),
|
|
170
|
+
name: text("name").notNull(),
|
|
171
|
+
slug: text("slug").notNull().unique(),
|
|
172
|
+
logo: text("logo"),
|
|
173
|
+
createdAt: timestamp("created_at").notNull(),
|
|
174
|
+
metadata: text("metadata")
|
|
175
|
+
});
|
|
176
|
+
const member = enterpriseSchema.table("member", {
|
|
177
|
+
id: text("id").primaryKey(),
|
|
178
|
+
organizationId: text("organization_id").notNull().references(() => organization.id, { onDelete: "cascade" }),
|
|
179
|
+
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
180
|
+
createdAt: timestamp("created_at").notNull()
|
|
181
|
+
}, (table) => [index("member_organizationId_idx").on(table.organizationId), index("member_userId_idx").on(table.userId)]);
|
|
182
|
+
const invitation = enterpriseSchema.table("invitation", {
|
|
183
|
+
id: text("id").primaryKey(),
|
|
184
|
+
organizationId: text("organization_id").notNull().references(() => organization.id, { onDelete: "cascade" }),
|
|
185
|
+
email: text("email").notNull(),
|
|
186
|
+
organizationRoles: jsonb("organization_roles"),
|
|
187
|
+
teamRoles: jsonb("team_roles"),
|
|
188
|
+
teamIds: text("team_ids"),
|
|
189
|
+
status: text("status").default("pending").notNull(),
|
|
190
|
+
expiresAt: timestamp("expires_at").notNull(),
|
|
191
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
192
|
+
inviterId: text("inviter_id").notNull().references(() => user.id, { onDelete: "cascade" })
|
|
193
|
+
}, (table) => [index("invitation_organizationId_idx").on(table.organizationId), index("invitation_email_idx").on(table.email)]);
|
|
194
|
+
const organizationRole = enterpriseSchema.table("organization_role", {
|
|
195
|
+
id: text("id").primaryKey(),
|
|
196
|
+
organizationId: text("organization_id").notNull().references(() => organization.id, { onDelete: "cascade" }),
|
|
197
|
+
type: text("type").notNull(),
|
|
198
|
+
name: text("name").notNull(),
|
|
199
|
+
description: text("description"),
|
|
200
|
+
isBuiltIn: boolean("is_built_in").default(false).notNull(),
|
|
201
|
+
permissions: jsonb("permissions"),
|
|
202
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
203
|
+
updatedAt: timestamp("updated_at").$onUpdate(() => /* @__PURE__ */ new Date())
|
|
204
|
+
}, (table) => [index("organizationRole_organizationId_idx").on(table.organizationId), index("organizationRole_type_idx").on(table.type)]);
|
|
205
|
+
const teamRole = enterpriseSchema.table("team_role", {
|
|
206
|
+
id: text("id").primaryKey(),
|
|
207
|
+
teamId: text("team_id").notNull().references(() => team.id, { onDelete: "cascade" }),
|
|
208
|
+
type: text("type").notNull(),
|
|
209
|
+
name: text("name").notNull(),
|
|
210
|
+
description: text("description"),
|
|
211
|
+
isBuiltIn: boolean("is_built_in").default(false).notNull(),
|
|
212
|
+
permissions: jsonb("permissions"),
|
|
213
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
214
|
+
updatedAt: timestamp("updated_at").$onUpdate(() => /* @__PURE__ */ new Date())
|
|
215
|
+
}, (table) => [index("teamRole_teamId_idx").on(table.teamId), index("teamRole_type_idx").on(table.type)]);
|
|
216
|
+
const memberOrganizationRole = enterpriseSchema.table("member_organization_role", {
|
|
217
|
+
id: text("id").primaryKey(),
|
|
218
|
+
memberId: text("member_id").notNull().references(() => member.id, { onDelete: "cascade" }),
|
|
219
|
+
organizationId: text("organization_id").notNull(),
|
|
220
|
+
role: text("role").notNull(),
|
|
221
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
222
|
+
}, (table) => [
|
|
223
|
+
index("memberOrganizationRole_memberId_idx").on(table.memberId),
|
|
224
|
+
index("memberOrganizationRole_organizationId_idx").on(table.organizationId),
|
|
225
|
+
index("memberOrganizationRole_role_idx").on(table.role)
|
|
226
|
+
]);
|
|
227
|
+
const memberTeamRole = enterpriseSchema.table("member_team_role", {
|
|
228
|
+
id: text("id").primaryKey(),
|
|
229
|
+
team_member_id: text("team_member_id").notNull().references(() => teamMember.id, { onDelete: "cascade" }),
|
|
230
|
+
teamId: text("team_id").notNull(),
|
|
231
|
+
role: text("role").notNull(),
|
|
232
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
233
|
+
}, (table) => [
|
|
234
|
+
index("memberTeamRole_team_member_id_idx").on(table.team_member_id),
|
|
235
|
+
index("memberTeamRole_teamId_idx").on(table.teamId),
|
|
236
|
+
index("memberTeamRole_role_idx").on(table.role)
|
|
237
|
+
]);
|
|
238
|
+
const team = enterpriseSchema.table("team", {
|
|
239
|
+
id: text("id").primaryKey(),
|
|
240
|
+
name: text("name").notNull(),
|
|
241
|
+
organizationId: text("organization_id").notNull().references(() => organization.id, { onDelete: "cascade" }),
|
|
242
|
+
createdAt: timestamp("created_at").notNull(),
|
|
243
|
+
updatedAt: timestamp("updated_at").$onUpdate(() => /* @__PURE__ */ new Date())
|
|
244
|
+
}, (table) => [index("team_organizationId_idx").on(table.organizationId)]);
|
|
245
|
+
const teamMember = enterpriseSchema.table("team_member", {
|
|
246
|
+
id: text("id").primaryKey(),
|
|
247
|
+
teamId: text("team_id").notNull().references(() => team.id, { onDelete: "cascade" }),
|
|
248
|
+
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
249
|
+
createdAt: timestamp("created_at")
|
|
250
|
+
}, (table) => [index("teamMember_teamId_idx").on(table.teamId), index("teamMember_userId_idx").on(table.userId)]);
|
|
251
|
+
const oauthApplication = enterpriseSchema.table("oauth_application", {
|
|
252
|
+
id: text("id").primaryKey(),
|
|
253
|
+
name: text("name"),
|
|
254
|
+
icon: text("icon"),
|
|
255
|
+
metadata: text("metadata"),
|
|
256
|
+
clientId: text("client_id").unique(),
|
|
257
|
+
clientSecret: text("client_secret"),
|
|
258
|
+
redirectUrls: text("redirect_urls"),
|
|
259
|
+
type: text("type"),
|
|
260
|
+
disabled: boolean("disabled").default(false),
|
|
261
|
+
userId: text("user_id").references(() => user.id, { onDelete: "cascade" }),
|
|
262
|
+
createdAt: timestamp("created_at"),
|
|
263
|
+
updatedAt: timestamp("updated_at")
|
|
264
|
+
}, (table) => [index("oauthApplication_userId_idx").on(table.userId)]);
|
|
265
|
+
const oauthAccessToken = enterpriseSchema.table("oauth_access_token", {
|
|
266
|
+
id: text("id").primaryKey(),
|
|
267
|
+
accessToken: text("access_token").unique(),
|
|
268
|
+
refreshToken: text("refresh_token").unique(),
|
|
269
|
+
accessTokenExpiresAt: timestamp("access_token_expires_at"),
|
|
270
|
+
refreshTokenExpiresAt: timestamp("refresh_token_expires_at"),
|
|
271
|
+
clientId: text("client_id").references(() => oauthApplication.clientId, { onDelete: "cascade" }),
|
|
272
|
+
userId: text("user_id").references(() => user.id, { onDelete: "cascade" }),
|
|
273
|
+
scopes: text("scopes"),
|
|
274
|
+
createdAt: timestamp("created_at"),
|
|
275
|
+
updatedAt: timestamp("updated_at")
|
|
276
|
+
}, (table) => [index("oauthAccessToken_clientId_idx").on(table.clientId), index("oauthAccessToken_userId_idx").on(table.userId)]);
|
|
277
|
+
const oauthConsent = enterpriseSchema.table("oauth_consent", {
|
|
278
|
+
id: text("id").primaryKey(),
|
|
279
|
+
clientId: text("client_id").references(() => oauthApplication.clientId, { onDelete: "cascade" }),
|
|
280
|
+
userId: text("user_id").references(() => user.id, { onDelete: "cascade" }),
|
|
281
|
+
scopes: text("scopes"),
|
|
282
|
+
createdAt: timestamp("created_at"),
|
|
283
|
+
updatedAt: timestamp("updated_at"),
|
|
284
|
+
consentGiven: boolean("consent_given")
|
|
285
|
+
}, (table) => [index("oauthConsent_clientId_idx").on(table.clientId), index("oauthConsent_userId_idx").on(table.userId)]);
|
|
286
|
+
const twoFactor = enterpriseSchema.table("two_factor", {
|
|
287
|
+
id: text("id").primaryKey(),
|
|
288
|
+
secret: text("secret").notNull(),
|
|
289
|
+
backupCodes: text("backup_codes").notNull(),
|
|
290
|
+
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" })
|
|
291
|
+
}, (table) => [index("twoFactor_secret_idx").on(table.secret), index("twoFactor_userId_idx").on(table.userId)]);
|
|
292
|
+
const person = enterpriseSchema.table("person", {
|
|
293
|
+
id: text("id").primaryKey(),
|
|
294
|
+
name: text("name")
|
|
295
|
+
});
|
|
296
|
+
const agent = enterpriseSchema.table("agent", {
|
|
297
|
+
id: text("id").primaryKey(),
|
|
298
|
+
name: text("name").notNull(),
|
|
299
|
+
type: text("type").default("custom").notNull(),
|
|
300
|
+
status: text("status").default("active").notNull(),
|
|
301
|
+
configuration: text("configuration"),
|
|
302
|
+
ownerId: text("owner_id"),
|
|
303
|
+
ownerType: text("owner_type").default("user").notNull(),
|
|
304
|
+
organizationId: text("organization_id").references(() => organization.id, { onDelete: "set null" }),
|
|
305
|
+
metadata: text("metadata"),
|
|
306
|
+
createdAt: timestamp("created_at"),
|
|
307
|
+
updatedAt: timestamp("updated_at")
|
|
308
|
+
});
|
|
309
|
+
const assetType = enterpriseSchema.table("asset_type", {
|
|
310
|
+
id: text("id").primaryKey(),
|
|
311
|
+
organizationId: text("organization_id").references(() => organization.id, { onDelete: "cascade" }),
|
|
312
|
+
scope: text("scope").default("organization").notNull(),
|
|
313
|
+
name: text("name").notNull(),
|
|
314
|
+
description: text("description"),
|
|
315
|
+
metadata: jsonb("metadata"),
|
|
316
|
+
source: text("source"),
|
|
317
|
+
defaultVisibility: text("default_visibility").default("private").notNull(),
|
|
318
|
+
allowedVisibilities: jsonb("allowed_visibilities").notNull(),
|
|
319
|
+
isBuiltIn: boolean("is_built_in").default(false).notNull(),
|
|
320
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
321
|
+
updatedAt: timestamp("updated_at").$onUpdate(() => /* @__PURE__ */ new Date())
|
|
322
|
+
}, (table) => [index("assetType_organizationId_idx").on(table.organizationId)]);
|
|
323
|
+
const asset = enterpriseSchema.table("asset", {
|
|
324
|
+
id: text("id").primaryKey(),
|
|
325
|
+
organizationId: text("organization_id").references(() => organization.id, { onDelete: "cascade" }),
|
|
326
|
+
ownerId: text("owner_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
327
|
+
assetTypeId: text("asset_type_id").notNull().references(() => assetType.id, { onDelete: "cascade" }),
|
|
328
|
+
teamId: text("team_id").references(() => team.id, { onDelete: "cascade" }),
|
|
329
|
+
name: text("name").notNull(),
|
|
330
|
+
visibility: text("visibility").default("private").notNull(),
|
|
331
|
+
visibilityLocked: boolean("visibility_locked").default(false).notNull(),
|
|
332
|
+
metadata: jsonb("metadata"),
|
|
333
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
334
|
+
updatedAt: timestamp("updated_at").$onUpdate(() => /* @__PURE__ */ new Date())
|
|
335
|
+
}, (table) => [
|
|
336
|
+
index("asset_organizationId_idx").on(table.organizationId),
|
|
337
|
+
index("asset_ownerId_idx").on(table.ownerId),
|
|
338
|
+
index("asset_assetTypeId_idx").on(table.assetTypeId),
|
|
339
|
+
index("asset_teamId_idx").on(table.teamId)
|
|
340
|
+
]);
|
|
341
|
+
const assetRole = enterpriseSchema.table("asset_role", {
|
|
342
|
+
id: text("id").primaryKey(),
|
|
343
|
+
assetTypeId: text("asset_type_id").notNull().references(() => assetType.id, { onDelete: "cascade" }),
|
|
344
|
+
type: text("type").notNull(),
|
|
345
|
+
name: text("name").notNull(),
|
|
346
|
+
description: text("description"),
|
|
347
|
+
isBuiltIn: boolean("is_built_in").default(false).notNull(),
|
|
348
|
+
permissions: jsonb("permissions"),
|
|
349
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
350
|
+
updatedAt: timestamp("updated_at").$onUpdate(() => /* @__PURE__ */ new Date())
|
|
351
|
+
}, (table) => [index("assetRole_assetTypeId_idx").on(table.assetTypeId), index("assetRole_type_idx").on(table.type)]);
|
|
352
|
+
const memberAssetRole = enterpriseSchema.table("member_asset_role", {
|
|
353
|
+
id: text("id").primaryKey(),
|
|
354
|
+
memberId: text("member_id").references(() => member.id, { onDelete: "cascade" }),
|
|
355
|
+
userId: text("user_id").references(() => user.id, { onDelete: "cascade" }),
|
|
356
|
+
assetId: text("asset_id").notNull().references(() => asset.id, { onDelete: "cascade" }),
|
|
357
|
+
role: text("role").notNull(),
|
|
358
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
359
|
+
}, (table) => [
|
|
360
|
+
index("memberAssetRole_memberId_idx").on(table.memberId),
|
|
361
|
+
index("memberAssetRole_userId_idx").on(table.userId),
|
|
362
|
+
index("memberAssetRole_assetId_idx").on(table.assetId),
|
|
363
|
+
index("memberAssetRole_role_idx").on(table.role)
|
|
364
|
+
]);
|
|
365
|
+
const assetShare = enterpriseSchema.table("asset_share", {
|
|
366
|
+
id: text("id").primaryKey(),
|
|
367
|
+
assetId: text("asset_id").notNull().references(() => asset.id, { onDelete: "cascade" }),
|
|
368
|
+
grantType: text("grant_type").notNull(),
|
|
369
|
+
memberId: text("member_id").references(() => member.id, { onDelete: "cascade" }),
|
|
370
|
+
teamId: text("team_id").references(() => team.id, { onDelete: "cascade" }),
|
|
371
|
+
organizationId: text("organization_id").references(() => organization.id, { onDelete: "cascade" }),
|
|
372
|
+
externalEmail: text("external_email"),
|
|
373
|
+
role: text("role").notNull(),
|
|
374
|
+
status: text("status").default("pending").notNull(),
|
|
375
|
+
invitedByMemberId: text("invited_by_member_id").references(() => member.id, { onDelete: "cascade" }),
|
|
376
|
+
expiresAt: timestamp("expires_at"),
|
|
377
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
378
|
+
updatedAt: timestamp("updated_at").$onUpdate(() => /* @__PURE__ */ new Date())
|
|
379
|
+
}, (table) => [
|
|
380
|
+
index("assetShare_assetId_idx").on(table.assetId),
|
|
381
|
+
index("assetShare_grantType_idx").on(table.grantType),
|
|
382
|
+
index("assetShare_memberId_idx").on(table.memberId),
|
|
383
|
+
index("assetShare_teamId_idx").on(table.teamId),
|
|
384
|
+
index("assetShare_organizationId_idx").on(table.organizationId),
|
|
385
|
+
index("assetShare_externalEmail_idx").on(table.externalEmail),
|
|
386
|
+
index("assetShare_role_idx").on(table.role),
|
|
387
|
+
index("assetShare_status_idx").on(table.status)
|
|
388
|
+
]);
|
|
389
|
+
const assetShareLink = enterpriseSchema.table("asset_share_link", {
|
|
390
|
+
id: text("id").primaryKey(),
|
|
391
|
+
assetId: text("asset_id").notNull().references(() => asset.id, { onDelete: "cascade" }),
|
|
392
|
+
tokenHash: text("token_hash").notNull(),
|
|
393
|
+
role: text("role").notNull(),
|
|
394
|
+
linkVisibility: text("link_visibility").default("organization").notNull(),
|
|
395
|
+
requiresAuth: boolean("requires_auth").default(true).notNull(),
|
|
396
|
+
passwordHash: text("password_hash"),
|
|
397
|
+
expiresAt: timestamp("expires_at"),
|
|
398
|
+
createdByMemberId: text("created_by_member_id").notNull().references(() => member.id, { onDelete: "cascade" }),
|
|
399
|
+
revokedAt: timestamp("revoked_at"),
|
|
400
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
401
|
+
}, (table) => [index("assetShareLink_assetId_idx").on(table.assetId), index("assetShareLink_tokenHash_idx").on(table.tokenHash)]);
|
|
402
|
+
const object = enterpriseSchema.table("object", {
|
|
403
|
+
id: text("id").primaryKey(),
|
|
404
|
+
type: text("type").notNull(),
|
|
405
|
+
externalId: text("external_id"),
|
|
406
|
+
externalType: text("external_type"),
|
|
407
|
+
attributes: text("attributes"),
|
|
408
|
+
metadata: text("metadata"),
|
|
409
|
+
createdAt: timestamp("created_at").notNull(),
|
|
410
|
+
updatedAt: timestamp("updated_at")
|
|
411
|
+
});
|
|
412
|
+
const relationship = enterpriseSchema.table("relationship", {
|
|
413
|
+
id: text("id").primaryKey(),
|
|
414
|
+
subjectId: text("subject_id").notNull().references(() => object.id, { onDelete: "cascade" }),
|
|
415
|
+
subjectType: text("subject_type").notNull(),
|
|
416
|
+
objectId: text("object_id").notNull().references(() => object.id, { onDelete: "cascade" }),
|
|
417
|
+
objectType: text("object_type").notNull(),
|
|
418
|
+
relationshipType: text("relationship_type").notNull(),
|
|
419
|
+
attributes: text("attributes"),
|
|
420
|
+
metadata: text("metadata"),
|
|
421
|
+
createdAt: timestamp("created_at").notNull(),
|
|
422
|
+
updatedAt: timestamp("updated_at")
|
|
423
|
+
});
|
|
424
|
+
const schemaDefinition = enterpriseSchema.table("schema_definition", {
|
|
425
|
+
id: text("id").primaryKey(),
|
|
426
|
+
version: text("version").notNull(),
|
|
427
|
+
definition: text("definition").notNull(),
|
|
428
|
+
isActive: boolean("is_active").default(true),
|
|
429
|
+
metadata: text("metadata"),
|
|
430
|
+
createdAt: timestamp("created_at").notNull(),
|
|
431
|
+
updatedAt: timestamp("updated_at"),
|
|
432
|
+
createdBy: text("created_by").references(() => user.id, { onDelete: "set null" })
|
|
433
|
+
});
|
|
434
|
+
const userRelations = relations(user, ({ many }) => ({
|
|
435
|
+
sessions: many(session),
|
|
436
|
+
accounts: many(account),
|
|
437
|
+
apikeys: many(apikey),
|
|
438
|
+
members: many(member),
|
|
439
|
+
invitations: many(invitation),
|
|
440
|
+
teamMembers: many(teamMember),
|
|
441
|
+
oauthApplications: many(oauthApplication),
|
|
442
|
+
oauthAccessTokens: many(oauthAccessToken),
|
|
443
|
+
oauthConsents: many(oauthConsent),
|
|
444
|
+
twoFactors: many(twoFactor),
|
|
445
|
+
assets: many(asset),
|
|
446
|
+
memberAssetRoles: many(memberAssetRole),
|
|
447
|
+
schemaDefinitions: many(schemaDefinition)
|
|
448
|
+
}));
|
|
449
|
+
const sessionRelations = relations(session, ({ one }) => ({ user: one(user, {
|
|
450
|
+
fields: [session.userId],
|
|
451
|
+
references: [user.id]
|
|
452
|
+
}) }));
|
|
453
|
+
const accountRelations = relations(account, ({ one }) => ({ user: one(user, {
|
|
454
|
+
fields: [account.userId],
|
|
455
|
+
references: [user.id]
|
|
456
|
+
}) }));
|
|
457
|
+
const apikeyRelations = relations(apikey, ({ one }) => ({ user: one(user, {
|
|
458
|
+
fields: [apikey.userId],
|
|
459
|
+
references: [user.id]
|
|
460
|
+
}) }));
|
|
461
|
+
const organizationRelations = relations(organization, ({ many }) => ({
|
|
462
|
+
members: many(member),
|
|
463
|
+
invitations: many(invitation),
|
|
464
|
+
organizationRoles: many(organizationRole),
|
|
465
|
+
teams: many(team),
|
|
466
|
+
agents: many(agent),
|
|
467
|
+
assetTypes: many(assetType),
|
|
468
|
+
assets: many(asset),
|
|
469
|
+
assetShares: many(assetShare)
|
|
470
|
+
}));
|
|
471
|
+
const memberRelations = relations(member, ({ one, many }) => ({
|
|
472
|
+
organization: one(organization, {
|
|
473
|
+
fields: [member.organizationId],
|
|
474
|
+
references: [organization.id]
|
|
475
|
+
}),
|
|
476
|
+
user: one(user, {
|
|
477
|
+
fields: [member.userId],
|
|
478
|
+
references: [user.id]
|
|
479
|
+
}),
|
|
480
|
+
memberOrganizationRoles: many(memberOrganizationRole),
|
|
481
|
+
memberAssetRoles: many(memberAssetRole),
|
|
482
|
+
inviteeAssetShares: many(assetShare, { relationName: "invitee" }),
|
|
483
|
+
inviterAssetShares: many(assetShare, { relationName: "inviter" }),
|
|
484
|
+
assetShareLinks: many(assetShareLink)
|
|
485
|
+
}));
|
|
486
|
+
const invitationRelations = relations(invitation, ({ one }) => ({
|
|
487
|
+
organization: one(organization, {
|
|
488
|
+
fields: [invitation.organizationId],
|
|
489
|
+
references: [organization.id]
|
|
490
|
+
}),
|
|
491
|
+
user: one(user, {
|
|
492
|
+
fields: [invitation.inviterId],
|
|
493
|
+
references: [user.id]
|
|
494
|
+
})
|
|
495
|
+
}));
|
|
496
|
+
const organizationRoleRelations = relations(organizationRole, ({ one }) => ({ organization: one(organization, {
|
|
497
|
+
fields: [organizationRole.organizationId],
|
|
498
|
+
references: [organization.id]
|
|
499
|
+
}) }));
|
|
500
|
+
const teamRoleRelations = relations(teamRole, ({ one }) => ({ team: one(team, {
|
|
501
|
+
fields: [teamRole.teamId],
|
|
502
|
+
references: [team.id]
|
|
503
|
+
}) }));
|
|
504
|
+
const memberOrganizationRoleRelations = relations(memberOrganizationRole, ({ one }) => ({ member: one(member, {
|
|
505
|
+
fields: [memberOrganizationRole.memberId],
|
|
506
|
+
references: [member.id]
|
|
507
|
+
}) }));
|
|
508
|
+
const memberTeamRoleRelations = relations(memberTeamRole, ({ one }) => ({ teamMember: one(teamMember, {
|
|
509
|
+
fields: [memberTeamRole.team_member_id],
|
|
510
|
+
references: [teamMember.id]
|
|
511
|
+
}) }));
|
|
512
|
+
const teamRelations = relations(team, ({ one, many }) => ({
|
|
513
|
+
organization: one(organization, {
|
|
514
|
+
fields: [team.organizationId],
|
|
515
|
+
references: [organization.id]
|
|
516
|
+
}),
|
|
517
|
+
teamRoles: many(teamRole),
|
|
518
|
+
teamMembers: many(teamMember),
|
|
519
|
+
assets: many(asset),
|
|
520
|
+
assetShares: many(assetShare)
|
|
521
|
+
}));
|
|
522
|
+
const teamMemberRelations = relations(teamMember, ({ one, many }) => ({
|
|
523
|
+
team: one(team, {
|
|
524
|
+
fields: [teamMember.teamId],
|
|
525
|
+
references: [team.id]
|
|
526
|
+
}),
|
|
527
|
+
user: one(user, {
|
|
528
|
+
fields: [teamMember.userId],
|
|
529
|
+
references: [user.id]
|
|
530
|
+
}),
|
|
531
|
+
memberTeamRoles: many(memberTeamRole)
|
|
532
|
+
}));
|
|
533
|
+
const oauthApplicationRelations = relations(oauthApplication, ({ one, many }) => ({
|
|
534
|
+
user: one(user, {
|
|
535
|
+
fields: [oauthApplication.userId],
|
|
536
|
+
references: [user.id]
|
|
537
|
+
}),
|
|
538
|
+
oauthAccessTokens: many(oauthAccessToken),
|
|
539
|
+
oauthConsents: many(oauthConsent)
|
|
540
|
+
}));
|
|
541
|
+
const oauthAccessTokenRelations = relations(oauthAccessToken, ({ one }) => ({
|
|
542
|
+
oauthApplication: one(oauthApplication, {
|
|
543
|
+
fields: [oauthAccessToken.clientId],
|
|
544
|
+
references: [oauthApplication.clientId]
|
|
545
|
+
}),
|
|
546
|
+
user: one(user, {
|
|
547
|
+
fields: [oauthAccessToken.userId],
|
|
548
|
+
references: [user.id]
|
|
549
|
+
})
|
|
550
|
+
}));
|
|
551
|
+
const oauthConsentRelations = relations(oauthConsent, ({ one }) => ({
|
|
552
|
+
oauthApplication: one(oauthApplication, {
|
|
553
|
+
fields: [oauthConsent.clientId],
|
|
554
|
+
references: [oauthApplication.clientId]
|
|
555
|
+
}),
|
|
556
|
+
user: one(user, {
|
|
557
|
+
fields: [oauthConsent.userId],
|
|
558
|
+
references: [user.id]
|
|
559
|
+
})
|
|
560
|
+
}));
|
|
561
|
+
const twoFactorRelations = relations(twoFactor, ({ one }) => ({ user: one(user, {
|
|
562
|
+
fields: [twoFactor.userId],
|
|
563
|
+
references: [user.id]
|
|
564
|
+
}) }));
|
|
565
|
+
const agentRelations = relations(agent, ({ one }) => ({ organization: one(organization, {
|
|
566
|
+
fields: [agent.organizationId],
|
|
567
|
+
references: [organization.id]
|
|
568
|
+
}) }));
|
|
569
|
+
const assetTypeRelations = relations(assetType, ({ one, many }) => ({
|
|
570
|
+
organization: one(organization, {
|
|
571
|
+
fields: [assetType.organizationId],
|
|
572
|
+
references: [organization.id]
|
|
573
|
+
}),
|
|
574
|
+
assets: many(asset),
|
|
575
|
+
assetRoles: many(assetRole)
|
|
576
|
+
}));
|
|
577
|
+
const assetRelations = relations(asset, ({ one, many }) => ({
|
|
578
|
+
organization: one(organization, {
|
|
579
|
+
fields: [asset.organizationId],
|
|
580
|
+
references: [organization.id]
|
|
581
|
+
}),
|
|
582
|
+
user: one(user, {
|
|
583
|
+
fields: [asset.ownerId],
|
|
584
|
+
references: [user.id]
|
|
585
|
+
}),
|
|
586
|
+
assetType: one(assetType, {
|
|
587
|
+
fields: [asset.assetTypeId],
|
|
588
|
+
references: [assetType.id]
|
|
589
|
+
}),
|
|
590
|
+
team: one(team, {
|
|
591
|
+
fields: [asset.teamId],
|
|
592
|
+
references: [team.id]
|
|
593
|
+
}),
|
|
594
|
+
memberAssetRoles: many(memberAssetRole),
|
|
595
|
+
assetShares: many(assetShare),
|
|
596
|
+
assetShareLinks: many(assetShareLink)
|
|
597
|
+
}));
|
|
598
|
+
const assetRoleRelations = relations(assetRole, ({ one }) => ({ assetType: one(assetType, {
|
|
599
|
+
fields: [assetRole.assetTypeId],
|
|
600
|
+
references: [assetType.id]
|
|
601
|
+
}) }));
|
|
602
|
+
const memberAssetRoleRelations = relations(memberAssetRole, ({ one }) => ({
|
|
603
|
+
member: one(member, {
|
|
604
|
+
fields: [memberAssetRole.memberId],
|
|
605
|
+
references: [member.id]
|
|
606
|
+
}),
|
|
607
|
+
user: one(user, {
|
|
608
|
+
fields: [memberAssetRole.userId],
|
|
609
|
+
references: [user.id]
|
|
610
|
+
}),
|
|
611
|
+
asset: one(asset, {
|
|
612
|
+
fields: [memberAssetRole.assetId],
|
|
613
|
+
references: [asset.id]
|
|
614
|
+
})
|
|
615
|
+
}));
|
|
616
|
+
const assetShareRelations = relations(assetShare, ({ one }) => ({
|
|
617
|
+
asset: one(asset, {
|
|
618
|
+
fields: [assetShare.assetId],
|
|
619
|
+
references: [asset.id]
|
|
620
|
+
}),
|
|
621
|
+
invitee: one(member, {
|
|
622
|
+
fields: [assetShare.memberId],
|
|
623
|
+
references: [member.id],
|
|
624
|
+
relationName: "invitee"
|
|
625
|
+
}),
|
|
626
|
+
team: one(team, {
|
|
627
|
+
fields: [assetShare.teamId],
|
|
628
|
+
references: [team.id]
|
|
629
|
+
}),
|
|
630
|
+
organization: one(organization, {
|
|
631
|
+
fields: [assetShare.organizationId],
|
|
632
|
+
references: [organization.id]
|
|
633
|
+
}),
|
|
634
|
+
inviter: one(member, {
|
|
635
|
+
fields: [assetShare.invitedByMemberId],
|
|
636
|
+
references: [member.id],
|
|
637
|
+
relationName: "inviter"
|
|
638
|
+
})
|
|
639
|
+
}));
|
|
640
|
+
const assetShareLinkRelations = relations(assetShareLink, ({ one }) => ({
|
|
641
|
+
asset: one(asset, {
|
|
642
|
+
fields: [assetShareLink.assetId],
|
|
643
|
+
references: [asset.id]
|
|
644
|
+
}),
|
|
645
|
+
member: one(member, {
|
|
646
|
+
fields: [assetShareLink.createdByMemberId],
|
|
647
|
+
references: [member.id]
|
|
648
|
+
})
|
|
649
|
+
}));
|
|
650
|
+
const objectRelations = relations(object, ({ many }) => ({
|
|
651
|
+
subjectRelationships: many(relationship, { relationName: "subject" }),
|
|
652
|
+
objectRelationships: many(relationship, { relationName: "object" })
|
|
653
|
+
}));
|
|
654
|
+
const relationshipRelations = relations(relationship, ({ one }) => ({
|
|
655
|
+
subject: one(object, {
|
|
656
|
+
fields: [relationship.subjectId],
|
|
657
|
+
references: [object.id],
|
|
658
|
+
relationName: "subject"
|
|
659
|
+
}),
|
|
660
|
+
object: one(object, {
|
|
661
|
+
fields: [relationship.objectId],
|
|
662
|
+
references: [object.id],
|
|
663
|
+
relationName: "object"
|
|
664
|
+
})
|
|
665
|
+
}));
|
|
666
|
+
const schemaDefinitionRelations = relations(schemaDefinition, ({ one }) => ({ user: one(user, {
|
|
667
|
+
fields: [schemaDefinition.createdBy],
|
|
668
|
+
references: [user.id]
|
|
669
|
+
}) }));
|
|
670
|
+
|
|
671
|
+
//#endregion
|
|
672
|
+
//#region src/db.ts
|
|
673
|
+
const schema = { ...db_schema_generated_exports };
|
|
674
|
+
const databaseSchema = schema;
|
|
675
|
+
let drizzle;
|
|
676
|
+
if (process.env.BUN) drizzle = __require("drizzle-orm/bun-sql").drizzle;
|
|
677
|
+
else drizzle = __require("drizzle-orm/node-postgres").drizzle;
|
|
678
|
+
const db = drizzle(process.env.DATABASE_URL + "?options=-c search_path=enterprise", { schema });
|
|
679
|
+
|
|
680
|
+
//#endregion
|
|
681
|
+
export { teamRole as $, oauthAccessTokenRelations as A, organizationRoleRelations as B, memberAssetRoleRelations as C, memberTeamRole as D, memberRelations as E, object as F, schemaDefinition as G, platformRole as H, objectRelations as I, sessionRelations as J, schemaDefinitionRelations as K, organization as L, oauthApplicationRelations as M, oauthConsent as N, memberTeamRoleRelations as O, oauthConsentRelations as P, teamRelations as Q, organizationRelations as R, memberAssetRole as S, memberOrganizationRoleRelations as T, relationship as U, person as V, relationshipRelations as W, teamMember as X, team as Y, teamMemberRelations as Z, assetType as _, agent as a, verification as at, invitationRelations as b, apikeyRelations as c, assetRole as d, teamRoleRelations as et, assetRoleRelations as f, assetShareRelations as g, assetShareLinkRelations as h, accountRelations as i, userRelations as it, oauthApplication as j, oauthAccessToken as k, asset as l, assetShareLink as m, db as n, twoFactorRelations as nt, agentRelations as o, enterpriseSchema as ot, assetShare as p, session as q, account as r, user as rt, apikey as s, __export as st, databaseSchema as t, twoFactor as tt, assetRelations as u, assetTypeRelations as v, memberOrganizationRole as w, member as x, invitation as y, organizationRole as z };
|