@kaloma-ai/framework-api 0.0.0-stage → 0.6.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/dist/app-UFeIdPnm.d.ts +1166 -0
- package/dist/chunk-R6W6GTUR.js +215 -0
- package/dist/chunk-T6RJSNTZ.js +3486 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.js +100 -0
- package/dist/schema.d.ts +130 -0
- package/dist/schema.js +6 -0
- package/dist/testing.d.ts +73 -0
- package/dist/testing.js +209 -0
- package/drizzle/0000_init_auth.sql +92 -0
- package/drizzle/0001_authz_apikeys_audit.sql +54 -0
- package/drizzle/0002_ops_backup_runs.sql +10 -0
- package/drizzle/0003_app_settings.sql +6 -0
- package/drizzle/0004_connections.sql +35 -0
- package/drizzle/0005_groups.sql +19 -0
- package/drizzle/meta/0000_snapshot.json +676 -0
- package/drizzle/meta/0001_snapshot.json +1026 -0
- package/drizzle/meta/0002_snapshot.json +1089 -0
- package/drizzle/meta/0003_snapshot.json +1127 -0
- package/drizzle/meta/0004_snapshot.json +1345 -0
- package/drizzle/meta/0005_snapshot.json +1491 -0
- package/drizzle/meta/_journal.json +48 -0
- package/package.json +80 -3
- package/README.md +0 -3
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/auth/schema.ts
|
|
8
|
+
var schema_exports = {};
|
|
9
|
+
__export(schema_exports, {
|
|
10
|
+
account: () => account,
|
|
11
|
+
accountRelations: () => accountRelations,
|
|
12
|
+
apikey: () => apikey,
|
|
13
|
+
invitation: () => invitation,
|
|
14
|
+
invitationRelations: () => invitationRelations,
|
|
15
|
+
member: () => member,
|
|
16
|
+
memberRelations: () => memberRelations,
|
|
17
|
+
organization: () => organization,
|
|
18
|
+
organizationRelations: () => organizationRelations,
|
|
19
|
+
session: () => session,
|
|
20
|
+
sessionRelations: () => sessionRelations,
|
|
21
|
+
user: () => user,
|
|
22
|
+
userRelations: () => userRelations,
|
|
23
|
+
verification: () => verification
|
|
24
|
+
});
|
|
25
|
+
import { relations } from "drizzle-orm";
|
|
26
|
+
import {
|
|
27
|
+
pgTable,
|
|
28
|
+
text,
|
|
29
|
+
timestamp,
|
|
30
|
+
boolean,
|
|
31
|
+
index,
|
|
32
|
+
uniqueIndex,
|
|
33
|
+
integer
|
|
34
|
+
} from "drizzle-orm/pg-core";
|
|
35
|
+
var user = pgTable("user", {
|
|
36
|
+
id: text("id").primaryKey(),
|
|
37
|
+
name: text("name").notNull(),
|
|
38
|
+
email: text("email").notNull().unique(),
|
|
39
|
+
emailVerified: boolean("email_verified").default(false).notNull(),
|
|
40
|
+
image: text("image"),
|
|
41
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
42
|
+
updatedAt: timestamp("updated_at").defaultNow().$onUpdate(() => /* @__PURE__ */ new Date()).notNull()
|
|
43
|
+
});
|
|
44
|
+
var session = pgTable(
|
|
45
|
+
"session",
|
|
46
|
+
{
|
|
47
|
+
id: text("id").primaryKey(),
|
|
48
|
+
expiresAt: timestamp("expires_at").notNull(),
|
|
49
|
+
token: text("token").notNull().unique(),
|
|
50
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
51
|
+
updatedAt: timestamp("updated_at").$onUpdate(() => /* @__PURE__ */ new Date()).notNull(),
|
|
52
|
+
ipAddress: text("ip_address"),
|
|
53
|
+
userAgent: text("user_agent"),
|
|
54
|
+
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
55
|
+
activeOrganizationId: text("active_organization_id")
|
|
56
|
+
},
|
|
57
|
+
(table) => [index("session_userId_idx").on(table.userId)]
|
|
58
|
+
);
|
|
59
|
+
var account = pgTable(
|
|
60
|
+
"account",
|
|
61
|
+
{
|
|
62
|
+
id: text("id").primaryKey(),
|
|
63
|
+
accountId: text("account_id").notNull(),
|
|
64
|
+
providerId: text("provider_id").notNull(),
|
|
65
|
+
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
66
|
+
accessToken: text("access_token"),
|
|
67
|
+
refreshToken: text("refresh_token"),
|
|
68
|
+
idToken: text("id_token"),
|
|
69
|
+
accessTokenExpiresAt: timestamp("access_token_expires_at"),
|
|
70
|
+
refreshTokenExpiresAt: timestamp("refresh_token_expires_at"),
|
|
71
|
+
scope: text("scope"),
|
|
72
|
+
password: text("password"),
|
|
73
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
74
|
+
updatedAt: timestamp("updated_at").$onUpdate(() => /* @__PURE__ */ new Date()).notNull()
|
|
75
|
+
},
|
|
76
|
+
(table) => [index("account_userId_idx").on(table.userId)]
|
|
77
|
+
);
|
|
78
|
+
var verification = pgTable(
|
|
79
|
+
"verification",
|
|
80
|
+
{
|
|
81
|
+
id: text("id").primaryKey(),
|
|
82
|
+
identifier: text("identifier").notNull(),
|
|
83
|
+
value: text("value").notNull(),
|
|
84
|
+
expiresAt: timestamp("expires_at").notNull(),
|
|
85
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
86
|
+
updatedAt: timestamp("updated_at").defaultNow().$onUpdate(() => /* @__PURE__ */ new Date()).notNull()
|
|
87
|
+
},
|
|
88
|
+
(table) => [index("verification_identifier_idx").on(table.identifier)]
|
|
89
|
+
);
|
|
90
|
+
var organization = pgTable(
|
|
91
|
+
"organization",
|
|
92
|
+
{
|
|
93
|
+
id: text("id").primaryKey(),
|
|
94
|
+
name: text("name").notNull(),
|
|
95
|
+
slug: text("slug").notNull().unique(),
|
|
96
|
+
logo: text("logo"),
|
|
97
|
+
createdAt: timestamp("created_at").notNull(),
|
|
98
|
+
metadata: text("metadata")
|
|
99
|
+
},
|
|
100
|
+
(table) => [uniqueIndex("organization_slug_uidx").on(table.slug)]
|
|
101
|
+
);
|
|
102
|
+
var member = pgTable(
|
|
103
|
+
"member",
|
|
104
|
+
{
|
|
105
|
+
id: text("id").primaryKey(),
|
|
106
|
+
organizationId: text("organization_id").notNull().references(() => organization.id, { onDelete: "cascade" }),
|
|
107
|
+
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
108
|
+
role: text("role").default("member").notNull(),
|
|
109
|
+
createdAt: timestamp("created_at").notNull()
|
|
110
|
+
},
|
|
111
|
+
(table) => [
|
|
112
|
+
index("member_organizationId_idx").on(table.organizationId),
|
|
113
|
+
index("member_userId_idx").on(table.userId)
|
|
114
|
+
]
|
|
115
|
+
);
|
|
116
|
+
var invitation = pgTable(
|
|
117
|
+
"invitation",
|
|
118
|
+
{
|
|
119
|
+
id: text("id").primaryKey(),
|
|
120
|
+
organizationId: text("organization_id").notNull().references(() => organization.id, { onDelete: "cascade" }),
|
|
121
|
+
email: text("email").notNull(),
|
|
122
|
+
role: text("role"),
|
|
123
|
+
status: text("status").default("pending").notNull(),
|
|
124
|
+
expiresAt: timestamp("expires_at").notNull(),
|
|
125
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
126
|
+
inviterId: text("inviter_id").notNull().references(() => user.id, { onDelete: "cascade" })
|
|
127
|
+
},
|
|
128
|
+
(table) => [
|
|
129
|
+
index("invitation_organizationId_idx").on(table.organizationId),
|
|
130
|
+
index("invitation_email_idx").on(table.email)
|
|
131
|
+
]
|
|
132
|
+
);
|
|
133
|
+
var userRelations = relations(user, ({ many }) => ({
|
|
134
|
+
sessions: many(session),
|
|
135
|
+
accounts: many(account),
|
|
136
|
+
members: many(member),
|
|
137
|
+
invitations: many(invitation)
|
|
138
|
+
}));
|
|
139
|
+
var sessionRelations = relations(session, ({ one }) => ({
|
|
140
|
+
user: one(user, {
|
|
141
|
+
fields: [session.userId],
|
|
142
|
+
references: [user.id]
|
|
143
|
+
})
|
|
144
|
+
}));
|
|
145
|
+
var accountRelations = relations(account, ({ one }) => ({
|
|
146
|
+
user: one(user, {
|
|
147
|
+
fields: [account.userId],
|
|
148
|
+
references: [user.id]
|
|
149
|
+
})
|
|
150
|
+
}));
|
|
151
|
+
var organizationRelations = relations(organization, ({ many }) => ({
|
|
152
|
+
members: many(member),
|
|
153
|
+
invitations: many(invitation)
|
|
154
|
+
}));
|
|
155
|
+
var memberRelations = relations(member, ({ one }) => ({
|
|
156
|
+
organization: one(organization, {
|
|
157
|
+
fields: [member.organizationId],
|
|
158
|
+
references: [organization.id]
|
|
159
|
+
}),
|
|
160
|
+
user: one(user, {
|
|
161
|
+
fields: [member.userId],
|
|
162
|
+
references: [user.id]
|
|
163
|
+
})
|
|
164
|
+
}));
|
|
165
|
+
var invitationRelations = relations(invitation, ({ one }) => ({
|
|
166
|
+
organization: one(organization, {
|
|
167
|
+
fields: [invitation.organizationId],
|
|
168
|
+
references: [organization.id]
|
|
169
|
+
}),
|
|
170
|
+
user: one(user, {
|
|
171
|
+
fields: [invitation.inviterId],
|
|
172
|
+
references: [user.id]
|
|
173
|
+
})
|
|
174
|
+
}));
|
|
175
|
+
var apikey = pgTable(
|
|
176
|
+
"apikey",
|
|
177
|
+
{
|
|
178
|
+
id: text("id").primaryKey(),
|
|
179
|
+
configId: text("config_id").default("default").notNull(),
|
|
180
|
+
name: text("name"),
|
|
181
|
+
start: text("start"),
|
|
182
|
+
referenceId: text("reference_id").notNull(),
|
|
183
|
+
prefix: text("prefix"),
|
|
184
|
+
key: text("key").notNull(),
|
|
185
|
+
refillInterval: integer("refill_interval"),
|
|
186
|
+
refillAmount: integer("refill_amount"),
|
|
187
|
+
lastRefillAt: timestamp("last_refill_at"),
|
|
188
|
+
enabled: boolean("enabled").default(true),
|
|
189
|
+
rateLimitEnabled: boolean("rate_limit_enabled").default(true),
|
|
190
|
+
rateLimitTimeWindow: integer("rate_limit_time_window").default(6e4),
|
|
191
|
+
rateLimitMax: integer("rate_limit_max").default(100),
|
|
192
|
+
requestCount: integer("request_count").default(0),
|
|
193
|
+
remaining: integer("remaining"),
|
|
194
|
+
lastRequest: timestamp("last_request"),
|
|
195
|
+
expiresAt: timestamp("expires_at"),
|
|
196
|
+
createdAt: timestamp("created_at").notNull(),
|
|
197
|
+
updatedAt: timestamp("updated_at").notNull(),
|
|
198
|
+
permissions: text("permissions"),
|
|
199
|
+
metadata: text("metadata")
|
|
200
|
+
},
|
|
201
|
+
(table) => [
|
|
202
|
+
index("apikey_configId_idx").on(table.configId),
|
|
203
|
+
index("apikey_referenceId_idx").on(table.referenceId),
|
|
204
|
+
index("apikey_key_idx").on(table.key)
|
|
205
|
+
]
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
export {
|
|
209
|
+
user,
|
|
210
|
+
organization,
|
|
211
|
+
member,
|
|
212
|
+
invitation,
|
|
213
|
+
apikey,
|
|
214
|
+
schema_exports
|
|
215
|
+
};
|