qarpeo 0.1.13 → 0.1.15
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 +7 -13
- package/dist/chunks/auth-schema.mjs +119 -147
- package/dist/cli/index.mjs +1 -1
- package/dist/module.mjs +96 -21
- package/dist/runtime/ai.d.ts +4 -2
- package/dist/runtime/ai.mjs +8 -2
- package/dist/runtime/app/composables/ai.d.ts +74 -0
- package/dist/runtime/app/composables/ai.mjs +148 -0
- package/dist/runtime/app/composables/auth.d.ts +16 -1
- package/dist/runtime/app/composables/auth.mjs +23 -34
- package/dist/runtime/app/composables/void-client.d.ts +3 -0
- package/dist/runtime/app/composables/void-client.mjs +4 -0
- package/dist/runtime/blob.mjs +1 -1
- package/dist/runtime/db.mjs +1 -1
- package/dist/runtime/server/routes/agents/[agent]/history.get.d.ts +1 -1
- package/dist/runtime/server/routes/auth/handler.d.ts +2 -0
- package/dist/runtime/server/routes/auth/handler.mjs +11 -0
- package/dist/runtime/server/utils/auth.d.ts +66 -0
- package/dist/runtime/server/utils/auth.mjs +58 -0
- package/dist/runtime/server/utils/realtime.mjs +1 -1
- package/dist/runtime/server/utils/void-ai.d.ts +7 -0
- package/dist/runtime/server/utils/void-ai.mjs +47 -0
- package/dist/runtime/server/utils/void-auth.d.ts +2 -0
- package/dist/runtime/server/utils/void-auth.mjs +9 -0
- package/dist/runtime/server/utils/void-db.d.ts +8 -0
- package/dist/runtime/server/utils/void-db.mjs +38 -0
- package/dist/runtime/server/utils/void-seed.d.ts +11 -0
- package/dist/runtime/server/utils/void-seed.mjs +3 -0
- package/dist/runtime/types/ai.d.ts +2 -0
- package/dist/runtime/types/imports.d.ts +65 -6
- package/dist/types.d.ts +1 -1
- package/dist/utils/auth-schema.d.ts +3 -5
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -29,14 +29,9 @@ Documentation: [https://qarpeo.com](https://qarpeo.com)
|
|
|
29
29
|
### 1. Install
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
|
-
# Using Vite+
|
|
33
32
|
vp add qarpeo
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
pnpm add qarpeo
|
|
37
|
-
|
|
38
|
-
# Using npm
|
|
39
|
-
npm install qarpeo
|
|
33
|
+
# or
|
|
34
|
+
vp i qarpeo
|
|
40
35
|
```
|
|
41
36
|
|
|
42
37
|
### 2. Configure
|
|
@@ -84,15 +79,14 @@ Qarpeo includes an integrated CLI for health diagnostics, database migrations, a
|
|
|
84
79
|
|
|
85
80
|
```bash
|
|
86
81
|
# Validate Cloudflare bindings, migrations, and secrets
|
|
87
|
-
|
|
82
|
+
vpx qp doctor
|
|
88
83
|
|
|
89
84
|
# Validate against production/remote deployment criteria
|
|
90
|
-
|
|
85
|
+
vpx qp doctor --remote
|
|
91
86
|
|
|
92
|
-
#
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
pnpm qp migrate --remote
|
|
87
|
+
# List, create, and push D1 migrations
|
|
88
|
+
vpx qp db list
|
|
89
|
+
vpx qp db push
|
|
96
90
|
```
|
|
97
91
|
|
|
98
92
|
---
|
|
@@ -1,218 +1,190 @@
|
|
|
1
1
|
const ALL_AUTH_TABLE_NAMES = [
|
|
2
|
+
"user",
|
|
3
|
+
"account",
|
|
4
|
+
"session",
|
|
5
|
+
"verification",
|
|
6
|
+
"twoFactor",
|
|
7
|
+
"passkey",
|
|
8
|
+
"organization",
|
|
9
|
+
"member",
|
|
10
|
+
"invitation",
|
|
2
11
|
"_qarpeo_users",
|
|
3
12
|
"_qarpeo_accounts",
|
|
4
|
-
"_qarpeo_sessions"
|
|
5
|
-
"_qarpeo_two_factor",
|
|
6
|
-
"_qarpeo_authenticators",
|
|
7
|
-
"_qarpeo_organizations",
|
|
8
|
-
"_qarpeo_members",
|
|
9
|
-
"_qarpeo_invitations",
|
|
10
|
-
"_qarpeo_api_tokens"
|
|
13
|
+
"_qarpeo_sessions"
|
|
11
14
|
];
|
|
12
15
|
function getActiveAuthTableNames(auth) {
|
|
13
16
|
if (!auth) return [];
|
|
14
17
|
const opts = typeof auth === "object" ? auth : {};
|
|
15
|
-
const tables = ["
|
|
16
|
-
if (opts.twoFactor) tables.push("
|
|
17
|
-
if (opts.webauthn) tables.push("
|
|
18
|
-
if (opts.organizations)
|
|
19
|
-
tables.push("_qarpeo_organizations", "_qarpeo_members", "_qarpeo_invitations");
|
|
20
|
-
if (opts.apiTokens) tables.push("_qarpeo_api_tokens");
|
|
21
|
-
if (opts.sso) tables.push("_qarpeo_sso_connections");
|
|
18
|
+
const tables = ["user", "account", "session", "verification"];
|
|
19
|
+
if (opts.twoFactor) tables.push("twoFactor");
|
|
20
|
+
if (opts.webauthn || opts.webAuthn) tables.push("passkey");
|
|
21
|
+
if (opts.organizations) tables.push("organization", "member", "invitation");
|
|
22
22
|
return tables;
|
|
23
23
|
}
|
|
24
24
|
function compileExtendedField(key, def) {
|
|
25
25
|
switch (def.type) {
|
|
26
26
|
case "string": {
|
|
27
|
-
let chain = `text()`;
|
|
27
|
+
let chain = `text("${key}")`;
|
|
28
28
|
if (def.default !== void 0) chain += `.default(${JSON.stringify(def.default)})`;
|
|
29
29
|
if (def.nullable === false) chain += `.notNull()`;
|
|
30
|
-
if (def.enum) chain += ` /* enum: ${def.enum.join("|")} */`;
|
|
31
30
|
return ` ${key}: ${chain},`;
|
|
32
31
|
}
|
|
33
32
|
case "number": {
|
|
34
|
-
let chain = `integer()`;
|
|
33
|
+
let chain = `integer("${key}")`;
|
|
35
34
|
if (def.default !== void 0) chain += `.default(${Number(def.default)})`;
|
|
36
35
|
return ` ${key}: ${chain},`;
|
|
37
36
|
}
|
|
38
37
|
case "boolean": {
|
|
39
|
-
let chain = `integer({ mode: "boolean" })`;
|
|
38
|
+
let chain = `integer("${key}", { mode: "boolean" })`;
|
|
40
39
|
if (def.default !== void 0) chain += `.default(${def.default ? 1 : 0})`;
|
|
41
40
|
return ` ${key}: ${chain},`;
|
|
42
41
|
}
|
|
43
42
|
case "json": {
|
|
44
|
-
return ` ${key}: text({ mode: "json" }),`;
|
|
43
|
+
return ` ${key}: text("${key}", { mode: "json" }),`;
|
|
45
44
|
}
|
|
46
45
|
default:
|
|
47
|
-
return ` ${key}: text(),`;
|
|
46
|
+
return ` ${key}: text("${key}"),`;
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
function generateAuthSchema(auth) {
|
|
51
50
|
const opts = typeof auth === "object" ? auth : {};
|
|
52
51
|
const extendsFields = opts.fields?.extends || {};
|
|
53
52
|
const lines = [
|
|
54
|
-
`// Auto-generated by Qarpeo
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
`// Auto-generated by Qarpeo for Better Auth & void/auth on Cloudflare D1`,
|
|
54
|
+
`import { sql } from "drizzle-orm";
|
|
55
|
+
import { sqliteTable, text, integer, blob, index } from "drizzle-orm/sqlite-core";`,
|
|
57
56
|
``,
|
|
58
|
-
`// \u2500\u2500\u2500 1.
|
|
59
|
-
`export const
|
|
60
|
-
` id: text().primaryKey(),`,
|
|
61
|
-
`
|
|
62
|
-
`
|
|
63
|
-
`
|
|
64
|
-
`
|
|
57
|
+
`// \u2500\u2500\u2500 1. User Table \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
58
|
+
`export const user = sqliteTable("user", {`,
|
|
59
|
+
` id: text("id").primaryKey(),`,
|
|
60
|
+
` name: text("name").notNull(),`,
|
|
61
|
+
` email: text("email").notNull().unique(),`,
|
|
62
|
+
` emailVerified: integer("email_verified", { mode: "boolean" }).notNull().default(false),`,
|
|
63
|
+
` image: text("image"),`
|
|
65
64
|
];
|
|
66
65
|
if (!extendsFields.role) {
|
|
67
|
-
lines.push(` role: text().default("user"),`);
|
|
66
|
+
lines.push(` role: text("role").default("user"),`);
|
|
68
67
|
}
|
|
69
68
|
for (const [key, fieldDef] of Object.entries(extendsFields)) {
|
|
70
69
|
lines.push(compileExtendedField(key, fieldDef));
|
|
71
70
|
}
|
|
72
71
|
lines.push(
|
|
73
|
-
` createdAt: integer().notNull(),`,
|
|
74
|
-
` updatedAt: integer().notNull(),`,
|
|
72
|
+
` createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull().default(sql\`(cast(unixepoch('subsecond') * 1000 as integer))\`),`,
|
|
73
|
+
` updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull().default(sql\`(cast(unixepoch('subsecond') * 1000 as integer))\`).$onUpdate(() => new Date()),`,
|
|
75
74
|
`});`,
|
|
76
75
|
``,
|
|
77
|
-
`// \u2500\u2500\u2500 2.
|
|
78
|
-
`export const
|
|
79
|
-
` id: text().primaryKey(),`,
|
|
80
|
-
`
|
|
81
|
-
`
|
|
82
|
-
`
|
|
83
|
-
`
|
|
84
|
-
`
|
|
85
|
-
`
|
|
86
|
-
`
|
|
87
|
-
` expiresAt: integer(),`,
|
|
88
|
-
` createdAt: integer().notNull(),`,
|
|
76
|
+
`// \u2500\u2500\u2500 2. Session Table \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
77
|
+
`export const session = sqliteTable("session", {`,
|
|
78
|
+
` id: text("id").primaryKey(),`,
|
|
79
|
+
` expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull(),`,
|
|
80
|
+
` token: text("token").notNull().unique(),`,
|
|
81
|
+
` createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull().default(sql\`(cast(unixepoch('subsecond') * 1000 as integer))\`),`,
|
|
82
|
+
` updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull().default(sql\`(cast(unixepoch('subsecond') * 1000 as integer))\`).$onUpdate(() => new Date()),`,
|
|
83
|
+
` ipAddress: text("ip_address"),`,
|
|
84
|
+
` userAgent: text("user_agent"),`,
|
|
85
|
+
` userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),`,
|
|
89
86
|
`}, (table) => [`,
|
|
90
|
-
` index("
|
|
87
|
+
` index("session_user_id_idx").on(table.userId),`,
|
|
88
|
+
` index("session_token_idx").on(table.token),`,
|
|
91
89
|
`]);`,
|
|
92
90
|
``,
|
|
93
|
-
`// \u2500\u2500\u2500 3.
|
|
94
|
-
`export const
|
|
95
|
-
` id: text().primaryKey(),`,
|
|
96
|
-
`
|
|
97
|
-
`
|
|
98
|
-
`
|
|
99
|
-
`
|
|
100
|
-
`
|
|
101
|
-
`
|
|
102
|
-
`
|
|
91
|
+
`// \u2500\u2500\u2500 3. Account Table (OAuth & Passwords) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
92
|
+
`export const account = sqliteTable("account", {`,
|
|
93
|
+
` id: text("id").primaryKey(),`,
|
|
94
|
+
` accountId: text("account_id").notNull(),`,
|
|
95
|
+
` providerId: text("provider_id").notNull(),`,
|
|
96
|
+
` userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),`,
|
|
97
|
+
` accessToken: text("access_token"),`,
|
|
98
|
+
` refreshToken: text("refresh_token"),`,
|
|
99
|
+
` idToken: text("id_token"),`,
|
|
100
|
+
` accessTokenExpiresAt: integer("access_token_expires_at", { mode: "timestamp_ms" }),`,
|
|
101
|
+
` refreshTokenExpiresAt: integer("refresh_token_expires_at", { mode: "timestamp_ms" }),`,
|
|
102
|
+
` scope: text("scope"),`,
|
|
103
|
+
` password: text("password"),`,
|
|
104
|
+
` createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull().default(sql\`(cast(unixepoch('subsecond') * 1000 as integer))\`),`,
|
|
105
|
+
` updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull().default(sql\`(cast(unixepoch('subsecond') * 1000 as integer))\`).$onUpdate(() => new Date()),`,
|
|
103
106
|
`}, (table) => [`,
|
|
104
|
-
` index("
|
|
105
|
-
`
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
` index("account_user_id_idx").on(table.userId),`,
|
|
108
|
+
`]);`,
|
|
109
|
+
``,
|
|
110
|
+
`// \u2500\u2500\u2500 4. Verification Table (Tokens & OTP) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
111
|
+
`export const verification = sqliteTable("verification", {`,
|
|
112
|
+
` id: text("id").primaryKey(),`,
|
|
113
|
+
` identifier: text("identifier").notNull(),`,
|
|
114
|
+
` value: text("value").notNull(),`,
|
|
115
|
+
` expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull(),`,
|
|
116
|
+
` createdAt: integer("created_at", { mode: "timestamp_ms" }),`,
|
|
117
|
+
` updatedAt: integer("updated_at", { mode: "timestamp_ms" }),`,
|
|
118
|
+
`});`
|
|
108
119
|
);
|
|
109
120
|
if (opts.twoFactor) {
|
|
110
121
|
lines.push(
|
|
111
122
|
``,
|
|
112
|
-
`// \u2500\u2500\u2500
|
|
113
|
-
`export const twoFactor =
|
|
114
|
-
` id: text().primaryKey(),`,
|
|
115
|
-
` userId: text().notNull().unique().references(() =>
|
|
116
|
-
` secret: text().notNull(),`,
|
|
117
|
-
` backupCodes: text().notNull(),`,
|
|
118
|
-
`
|
|
119
|
-
` createdAt: integer().notNull(),`,
|
|
123
|
+
`// \u2500\u2500\u2500 5. Two-Factor Authentication Table (TOTP) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
124
|
+
`export const twoFactor = sqliteTable("two_factor", {`,
|
|
125
|
+
` id: text("id").primaryKey(),`,
|
|
126
|
+
` userId: text("user_id").notNull().unique().references(() => user.id, { onDelete: "cascade" }),`,
|
|
127
|
+
` secret: text("secret").notNull(),`,
|
|
128
|
+
` backupCodes: text("backup_codes").notNull(),`,
|
|
129
|
+
` createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull().default(sql\`(cast(unixepoch('subsecond') * 1000 as integer))\`),`,
|
|
120
130
|
`});`
|
|
121
131
|
);
|
|
122
132
|
}
|
|
123
|
-
if (opts.webauthn) {
|
|
133
|
+
if (opts.webauthn || opts.webAuthn) {
|
|
124
134
|
lines.push(
|
|
125
135
|
``,
|
|
126
|
-
`// \u2500\u2500\u2500
|
|
127
|
-
`export const
|
|
128
|
-
` id: text().primaryKey(),`,
|
|
129
|
-
`
|
|
130
|
-
`
|
|
131
|
-
`
|
|
132
|
-
`
|
|
133
|
-
`
|
|
134
|
-
`
|
|
136
|
+
`// \u2500\u2500\u2500 6. Passkeys Table \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
137
|
+
`export const passkey = sqliteTable("passkey", {`,
|
|
138
|
+
` id: text("id").primaryKey(),`,
|
|
139
|
+
` name: text("name"),`,
|
|
140
|
+
` publicKey: text("public_key").notNull(),`,
|
|
141
|
+
` userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),`,
|
|
142
|
+
` credentialId: text("credential_id").notNull().unique(),`,
|
|
143
|
+
` counter: integer("counter").notNull().default(0),`,
|
|
144
|
+
` deviceType: text("device_type").notNull(),`,
|
|
145
|
+
` backedUp: integer("backed_up", { mode: "boolean" }).notNull().default(false),`,
|
|
146
|
+
` transports: text("transports"),`,
|
|
147
|
+
` createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull().default(sql\`(cast(unixepoch('subsecond') * 1000 as integer))\`),`,
|
|
135
148
|
`});`
|
|
136
149
|
);
|
|
137
150
|
}
|
|
138
151
|
if (opts.organizations) {
|
|
139
152
|
lines.push(
|
|
140
153
|
``,
|
|
141
|
-
`// \u2500\u2500\u2500
|
|
142
|
-
`export const
|
|
143
|
-
` id: text().primaryKey(),`,
|
|
144
|
-
` name: text().notNull(),`,
|
|
145
|
-
` slug: text().notNull().unique(),`,
|
|
146
|
-
`
|
|
147
|
-
`
|
|
154
|
+
`// \u2500\u2500\u2500 7. Organizations & Members Tables \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
155
|
+
`export const organization = sqliteTable("organization", {`,
|
|
156
|
+
` id: text("id").primaryKey(),`,
|
|
157
|
+
` name: text("name").notNull(),`,
|
|
158
|
+
` slug: text("slug").notNull().unique(),`,
|
|
159
|
+
` logo: text("logo"),`,
|
|
160
|
+
` metadata: text("metadata"),`,
|
|
161
|
+
` createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull().default(sql\`(cast(unixepoch('subsecond') * 1000 as integer))\`),`,
|
|
148
162
|
`});`,
|
|
149
163
|
``,
|
|
150
|
-
`export const
|
|
151
|
-
` id: text().primaryKey(),`,
|
|
152
|
-
` organizationId: text().notNull().references(() =>
|
|
153
|
-
` userId: text().notNull().references(() =>
|
|
154
|
-
` role: text().notNull().default("member"),`,
|
|
155
|
-
` createdAt: integer().notNull(),`,
|
|
156
|
-
`}
|
|
157
|
-
` index("_qarpeo_members_user_id_idx").on(table.userId),`,
|
|
158
|
-
` index("_qarpeo_members_org_id_idx").on(table.organizationId),`,
|
|
159
|
-
`]);`,
|
|
164
|
+
`export const member = sqliteTable("member", {`,
|
|
165
|
+
` id: text("id").primaryKey(),`,
|
|
166
|
+
` organizationId: text("organization_id").notNull().references(() => organization.id, { onDelete: "cascade" }),`,
|
|
167
|
+
` userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),`,
|
|
168
|
+
` role: text("role").notNull().default("member"),`,
|
|
169
|
+
` createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull().default(sql\`(cast(unixepoch('subsecond') * 1000 as integer))\`),`,
|
|
170
|
+
`});`,
|
|
160
171
|
``,
|
|
161
|
-
`export const
|
|
162
|
-
` id: text().primaryKey(),`,
|
|
163
|
-
` organizationId: text().notNull().references(() =>
|
|
164
|
-
` email: text().notNull(),`,
|
|
165
|
-
` role: text().notNull().default("member"),`,
|
|
166
|
-
`
|
|
167
|
-
` expiresAt: integer().notNull(),`,
|
|
168
|
-
`
|
|
172
|
+
`export const invitation = sqliteTable("invitation", {`,
|
|
173
|
+
` id: text("id").primaryKey(),`,
|
|
174
|
+
` organizationId: text("organization_id").notNull().references(() => organization.id, { onDelete: "cascade" }),`,
|
|
175
|
+
` email: text("email").notNull(),`,
|
|
176
|
+
` role: text("role").notNull().default("member"),`,
|
|
177
|
+
` status: text("status").notNull().default("pending"),`,
|
|
178
|
+
` expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull(),`,
|
|
179
|
+
` inviterId: text("inviter_id").notNull().references(() => user.id, { onDelete: "cascade" }),`,
|
|
169
180
|
`});`
|
|
170
181
|
);
|
|
171
182
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
` id: text().primaryKey(),`,
|
|
178
|
-
` userId: text().notNull().references(() => users.id, { onDelete: "cascade" }),`,
|
|
179
|
-
` name: text().notNull(),`,
|
|
180
|
-
` tokenHash: text().notNull(),`,
|
|
181
|
-
` scopes: text().default('["*"]'),`,
|
|
182
|
-
` lastUsedAt: integer(),`,
|
|
183
|
-
` expiresAt: integer(),`,
|
|
184
|
-
` createdAt: integer().notNull(),`,
|
|
185
|
-
`}, (table) => [`,
|
|
186
|
-
` index("_qarpeo_api_tokens_user_id_idx").on(table.userId),`,
|
|
187
|
-
`]);`
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
if (opts.sso) {
|
|
191
|
-
lines.push(
|
|
192
|
-
``,
|
|
193
|
-
`// \u2500\u2500\u2500 8. Enterprise SSO (SAML 2.0 & OIDC) Table \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`,
|
|
194
|
-
`export const ssoConnections = snakeCase.table("_qarpeo_sso_connections", {`,
|
|
195
|
-
` id: text().primaryKey(),`,
|
|
196
|
-
` organizationId: text().references(() => organizations.id, { onDelete: "cascade" }),`,
|
|
197
|
-
` providerType: text().notNull(),`,
|
|
198
|
-
` name: text().notNull(),`,
|
|
199
|
-
` domain: text().unique(),`,
|
|
200
|
-
` clientId: text(),`,
|
|
201
|
-
` clientSecret: text(),`,
|
|
202
|
-
` issuer: text(),`,
|
|
203
|
-
` ssoUrl: text().notNull(),`,
|
|
204
|
-
` tokenUrl: text(),`,
|
|
205
|
-
` userinfoUrl: text(),`,
|
|
206
|
-
` cert: text(),`,
|
|
207
|
-
` enabled: integer().default(1),`,
|
|
208
|
-
` createdAt: integer().notNull(),`,
|
|
209
|
-
` updatedAt: integer().notNull(),`,
|
|
210
|
-
`}, (table) => [`,
|
|
211
|
-
` index("_qarpeo_sso_org_id_idx").on(table.organizationId),`,
|
|
212
|
-
` index("_qarpeo_sso_domain_idx").on(table.domain),`,
|
|
213
|
-
`]);`
|
|
214
|
-
);
|
|
215
|
-
}
|
|
183
|
+
lines.push(
|
|
184
|
+
``,
|
|
185
|
+
`// Backwards compatibility aliases`,
|
|
186
|
+
`export { user as users, session as sessions, account as accounts, verification as verifications };`
|
|
187
|
+
);
|
|
216
188
|
return lines.join("\n") + "\n";
|
|
217
189
|
}
|
|
218
190
|
|
package/dist/cli/index.mjs
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -19,7 +19,7 @@ import 'drizzle-orm/node-sqlite';
|
|
|
19
19
|
import 'node:process';
|
|
20
20
|
import 'node:readline/promises';
|
|
21
21
|
|
|
22
|
-
const version = "0.1.
|
|
22
|
+
const version = "0.1.15";
|
|
23
23
|
|
|
24
24
|
function ensureDevEnv(rootDir) {
|
|
25
25
|
const envPath = join(rootDir, ".env");
|
|
@@ -1226,6 +1226,12 @@ ${extraSources}
|
|
|
1226
1226
|
nuxt.options.alias["#qarpeo/notifications"] = resolver.resolve("./runtime/server/utils/notifications");
|
|
1227
1227
|
nuxt.options.alias["qarpeo/vapid"] = resolver.resolve("./runtime/server/utils/vapid");
|
|
1228
1228
|
nuxt.options.alias["#qarpeo/vapid"] = resolver.resolve("./runtime/server/utils/vapid");
|
|
1229
|
+
nuxt.options.alias["void/db"] = resolver.resolve("./runtime/server/utils/void-db");
|
|
1230
|
+
nuxt.options.alias["void/seed"] = resolver.resolve("./runtime/server/utils/void-seed");
|
|
1231
|
+
nuxt.options.alias["void/auth"] = resolver.resolve("./runtime/server/utils/void-auth");
|
|
1232
|
+
nuxt.options.alias["void/ai"] = resolver.resolve("./runtime/server/utils/void-ai");
|
|
1233
|
+
nuxt.options.alias["void/client/vue"] = resolver.resolve("./runtime/app/composables/void-client");
|
|
1234
|
+
nuxt.options.alias["void/client"] = resolver.resolve("./runtime/app/composables/void-client");
|
|
1229
1235
|
const emptyAgentsTemplate = addTemplate({
|
|
1230
1236
|
filename: "qarpeo/agents-empty.mjs",
|
|
1231
1237
|
write: true,
|
|
@@ -1271,9 +1277,12 @@ ${extraSources}
|
|
|
1271
1277
|
const drizzleSeedDir = resolvePkgDir("drizzle-seed");
|
|
1272
1278
|
nuxt.options.alias["drizzle-seed"] = drizzleSeedDir;
|
|
1273
1279
|
nuxt.options.alias["drizzle-seed/"] = `${drizzleSeedDir}/`;
|
|
1274
|
-
const
|
|
1275
|
-
nuxt.options.alias["
|
|
1276
|
-
nuxt.options.alias["
|
|
1280
|
+
const betterAuthDir = resolvePkgDir("better-auth");
|
|
1281
|
+
nuxt.options.alias["better-auth/vue"] = resolve(betterAuthDir, "dist/client/vue/index.mjs");
|
|
1282
|
+
nuxt.options.alias["better-auth/client"] = resolve(betterAuthDir, "dist/client/index.mjs");
|
|
1283
|
+
nuxt.options.alias["better-auth"] = resolve(betterAuthDir, "dist/index.mjs");
|
|
1284
|
+
const betterAuthAdapterDir = resolvePkgDir("@better-auth/drizzle-adapter");
|
|
1285
|
+
nuxt.options.alias["@better-auth/drizzle-adapter"] = resolve(betterAuthAdapterDir, "dist/index.mjs");
|
|
1277
1286
|
const comarkNuxtDir = resolvePkgDir("@comark/nuxt");
|
|
1278
1287
|
nuxt.options.alias["@comark/nuxt/utils"] = resolve(comarkNuxtDir, "dist/utils/index.js");
|
|
1279
1288
|
nuxt.options.alias["@comark/nuxt/render"] = resolve(comarkNuxtDir, "dist/render.js");
|
|
@@ -1367,7 +1376,9 @@ ${extraSources}
|
|
|
1367
1376
|
"@shikijs/engine-javascript",
|
|
1368
1377
|
"@shikijs/langs",
|
|
1369
1378
|
"@shikijs/themes",
|
|
1370
|
-
"@shikijs/vscode-textmate"
|
|
1379
|
+
"@shikijs/vscode-textmate",
|
|
1380
|
+
"better-auth",
|
|
1381
|
+
"@better-auth/drizzle-adapter"
|
|
1371
1382
|
);
|
|
1372
1383
|
nuxt.options.vite = nuxt.options.vite || {};
|
|
1373
1384
|
nuxt.options.vite.optimizeDeps = nuxt.options.vite.optimizeDeps || {};
|
|
@@ -1423,15 +1434,6 @@ ${extraSources}
|
|
|
1423
1434
|
if (webAuthnEnabled) {
|
|
1424
1435
|
nuxt.options.auth = defu(nuxt.options.auth || {}, { webAuthn: true });
|
|
1425
1436
|
}
|
|
1426
|
-
if (!hasNuxtModule("nuxt-auth-utils")) {
|
|
1427
|
-
const authModuleOptions = webAuthnEnabled ? { webAuthn: true } : {};
|
|
1428
|
-
try {
|
|
1429
|
-
const authModulePath = fileURLToPath(import.meta.resolve("nuxt-auth-utils"));
|
|
1430
|
-
await installModule(authModulePath, authModuleOptions);
|
|
1431
|
-
} catch {
|
|
1432
|
-
await installModule("nuxt-auth-utils", authModuleOptions);
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
1437
|
}
|
|
1436
1438
|
if (options.cms && !hasNuxtModule("@comark/nuxt")) {
|
|
1437
1439
|
try {
|
|
@@ -1765,6 +1767,7 @@ export default queueHandler;
|
|
|
1765
1767
|
});
|
|
1766
1768
|
schemaTemplateDst = template.dst;
|
|
1767
1769
|
nuxt.options.alias["#qarpeo/schema"] = schemaTemplateDst;
|
|
1770
|
+
nuxt.options.alias["@schema"] = schemaTemplateDst;
|
|
1768
1771
|
const typesTemplate = addTemplate({
|
|
1769
1772
|
filename: "qarpeo/db-types.ts",
|
|
1770
1773
|
write: true,
|
|
@@ -1895,12 +1898,19 @@ export default queueHandler;
|
|
|
1895
1898
|
const drizzleSeedDir = resolvePkgDir("drizzle-seed");
|
|
1896
1899
|
nitroConfig.alias["drizzle-seed"] = drizzleSeedDir;
|
|
1897
1900
|
nitroConfig.alias["drizzle-seed/"] = `${drizzleSeedDir}/`;
|
|
1898
|
-
const authUtilsDir = resolvePkgDir("nuxt-auth-utils");
|
|
1899
|
-
nitroConfig.alias["nuxt-auth-utils"] = authUtilsDir;
|
|
1900
|
-
nitroConfig.alias["nuxt-auth-utils/"] = `${authUtilsDir}/`;
|
|
1901
1901
|
const wranglerDir = resolvePkgDir("wrangler");
|
|
1902
1902
|
nitroConfig.alias["wrangler"] = wranglerDir;
|
|
1903
1903
|
nitroConfig.alias["wrangler/"] = `${wranglerDir}/`;
|
|
1904
|
+
const betterAuthDir = resolvePkgDir("better-auth");
|
|
1905
|
+
nitroConfig.alias["better-auth/vue"] = resolve(betterAuthDir, "dist/client/vue/index.mjs");
|
|
1906
|
+
nitroConfig.alias["better-auth/client"] = resolve(betterAuthDir, "dist/client/index.mjs");
|
|
1907
|
+
nitroConfig.alias["better-auth"] = resolve(betterAuthDir, "dist/index.mjs");
|
|
1908
|
+
const betterAuthAdapterDir = resolvePkgDir("@better-auth/drizzle-adapter");
|
|
1909
|
+
nitroConfig.alias["@better-auth/drizzle-adapter"] = resolve(betterAuthAdapterDir, "dist/index.mjs");
|
|
1910
|
+
nitroConfig.alias["void/db"] = resolver.resolve("./runtime/server/utils/void-db");
|
|
1911
|
+
nitroConfig.alias["void/seed"] = resolver.resolve("./runtime/server/utils/void-seed");
|
|
1912
|
+
nitroConfig.alias["void/auth"] = resolver.resolve("./runtime/server/utils/void-auth");
|
|
1913
|
+
nitroConfig.alias["void/ai"] = resolver.resolve("./runtime/server/utils/void-ai");
|
|
1904
1914
|
const comarkNuxtDir = resolvePkgDir("@comark/nuxt");
|
|
1905
1915
|
nitroConfig.alias["@comark/nuxt/utils"] = resolve(comarkNuxtDir, "dist/utils/index.js");
|
|
1906
1916
|
nitroConfig.alias["@comark/nuxt/render"] = resolve(comarkNuxtDir, "dist/render.js");
|
|
@@ -2085,6 +2095,7 @@ export default queueHandler;
|
|
|
2085
2095
|
if (isDrizzle && schemaTemplateDst) {
|
|
2086
2096
|
nitroConfig.alias = nitroConfig.alias || {};
|
|
2087
2097
|
nitroConfig.alias["#qarpeo/schema"] = schemaTemplateDst;
|
|
2098
|
+
nitroConfig.alias["@schema"] = schemaTemplateDst;
|
|
2088
2099
|
const typesAlias = nuxt.options.alias["#qarpeo/db/types"];
|
|
2089
2100
|
const zodAlias = nuxt.options.alias["#qarpeo/db/zod"];
|
|
2090
2101
|
if (typesAlias) {
|
|
@@ -2422,6 +2433,14 @@ export default queueHandler;
|
|
|
2422
2433
|
name: "schema",
|
|
2423
2434
|
from: resolver.resolve("./runtime/server/utils/drizzle")
|
|
2424
2435
|
},
|
|
2436
|
+
{
|
|
2437
|
+
name: "createDb",
|
|
2438
|
+
from: resolver.resolve("./runtime/server/utils/void-db")
|
|
2439
|
+
},
|
|
2440
|
+
{
|
|
2441
|
+
name: "defineSeed",
|
|
2442
|
+
from: resolver.resolve("./runtime/server/utils/void-seed")
|
|
2443
|
+
},
|
|
2425
2444
|
{
|
|
2426
2445
|
name: "useDB",
|
|
2427
2446
|
from: "qarpeo/runtime"
|
|
@@ -2505,6 +2524,16 @@ export default queueHandler;
|
|
|
2505
2524
|
]);
|
|
2506
2525
|
}
|
|
2507
2526
|
if (options.ai) {
|
|
2527
|
+
addImports([
|
|
2528
|
+
{
|
|
2529
|
+
name: "useAIStream",
|
|
2530
|
+
from: resolver.resolve("./runtime/app/composables/ai")
|
|
2531
|
+
},
|
|
2532
|
+
{
|
|
2533
|
+
name: "useVectorSearch",
|
|
2534
|
+
from: resolver.resolve("./runtime/app/composables/ai")
|
|
2535
|
+
}
|
|
2536
|
+
]);
|
|
2508
2537
|
addServerImports([
|
|
2509
2538
|
{
|
|
2510
2539
|
name: "ai",
|
|
@@ -2716,6 +2745,24 @@ export default queueHandler;
|
|
|
2716
2745
|
}
|
|
2717
2746
|
]);
|
|
2718
2747
|
}
|
|
2748
|
+
addImports([
|
|
2749
|
+
{
|
|
2750
|
+
name: "useUserSession",
|
|
2751
|
+
from: resolver.resolve("./runtime/app/composables/auth")
|
|
2752
|
+
},
|
|
2753
|
+
{
|
|
2754
|
+
name: "useAuth",
|
|
2755
|
+
from: resolver.resolve("./runtime/app/composables/auth")
|
|
2756
|
+
},
|
|
2757
|
+
{
|
|
2758
|
+
name: "useSession",
|
|
2759
|
+
from: resolver.resolve("./runtime/app/composables/auth")
|
|
2760
|
+
},
|
|
2761
|
+
{
|
|
2762
|
+
name: "authClient",
|
|
2763
|
+
from: resolver.resolve("./runtime/app/composables/auth")
|
|
2764
|
+
}
|
|
2765
|
+
]);
|
|
2719
2766
|
if (options.auth) {
|
|
2720
2767
|
const authConfig = typeof options.auth === "object" ? options.auth : {};
|
|
2721
2768
|
const authPrefix = authConfig.prefix || "/api/auth";
|
|
@@ -2753,6 +2800,10 @@ export default queueHandler;
|
|
|
2753
2800
|
path: resolver.resolve("./runtime/app/middleware/auth.global"),
|
|
2754
2801
|
global: true
|
|
2755
2802
|
});
|
|
2803
|
+
addServerHandler({
|
|
2804
|
+
route: `${authPrefix}/**`,
|
|
2805
|
+
handler: resolver.resolve("./runtime/server/routes/auth/handler")
|
|
2806
|
+
});
|
|
2756
2807
|
addServerHandler({
|
|
2757
2808
|
route: `${authPrefix}/user`,
|
|
2758
2809
|
handler: resolver.resolve("./runtime/server/routes/auth/user.get")
|
|
@@ -2923,10 +2974,6 @@ export default queueHandler;
|
|
|
2923
2974
|
handler: resolver.resolve("./runtime/server/routes/auth/organization/mfa.post")
|
|
2924
2975
|
});
|
|
2925
2976
|
addImports([
|
|
2926
|
-
{
|
|
2927
|
-
name: "useAuth",
|
|
2928
|
-
from: resolver.resolve("./runtime/app/composables/auth")
|
|
2929
|
-
},
|
|
2930
2977
|
{
|
|
2931
2978
|
name: "useOrganization",
|
|
2932
2979
|
from: resolver.resolve("./runtime/app/composables/organization")
|
|
@@ -2957,6 +3004,26 @@ export default queueHandler;
|
|
|
2957
3004
|
}
|
|
2958
3005
|
]);
|
|
2959
3006
|
addServerImports([
|
|
3007
|
+
{
|
|
3008
|
+
name: "serverAuth",
|
|
3009
|
+
from: resolver.resolve("./runtime/server/utils/auth")
|
|
3010
|
+
},
|
|
3011
|
+
{
|
|
3012
|
+
name: "createAuth",
|
|
3013
|
+
from: resolver.resolve("./runtime/server/utils/auth")
|
|
3014
|
+
},
|
|
3015
|
+
{
|
|
3016
|
+
name: "useServerAuth",
|
|
3017
|
+
from: resolver.resolve("./runtime/server/utils/auth")
|
|
3018
|
+
},
|
|
3019
|
+
{
|
|
3020
|
+
name: "getServerSession",
|
|
3021
|
+
from: resolver.resolve("./runtime/server/utils/auth")
|
|
3022
|
+
},
|
|
3023
|
+
{
|
|
3024
|
+
name: "requireServerSession",
|
|
3025
|
+
from: resolver.resolve("./runtime/server/utils/auth")
|
|
3026
|
+
},
|
|
2960
3027
|
{
|
|
2961
3028
|
name: "handleOAuthSuccess",
|
|
2962
3029
|
from: resolver.resolve("./runtime/server/utils/auth")
|
|
@@ -4038,6 +4105,14 @@ export const manifestCollections = ${JSON.stringify(cmsConfig.collections || {})
|
|
|
4038
4105
|
{
|
|
4039
4106
|
name: "useAgentChat",
|
|
4040
4107
|
from: resolver.resolve("./runtime/app/composables/chat")
|
|
4108
|
+
},
|
|
4109
|
+
{
|
|
4110
|
+
name: "useAIStream",
|
|
4111
|
+
from: resolver.resolve("./runtime/app/composables/ai")
|
|
4112
|
+
},
|
|
4113
|
+
{
|
|
4114
|
+
name: "useVectorSearch",
|
|
4115
|
+
from: resolver.resolve("./runtime/app/composables/ai")
|
|
4041
4116
|
}
|
|
4042
4117
|
]);
|
|
4043
4118
|
addServerImports([
|
package/dist/runtime/ai.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { AiBinding, QarpeoAI } from "./types/ai";
|
|
2
2
|
import type { CFEvent } from "./types/index";
|
|
3
|
-
import { generateImage, textToImage, generateSpeech, textToSpeech, transcribeAudio, speechToText, generateText, streamText, embedText } from "./server/utils/ai";
|
|
3
|
+
import { generateImage, textToImage, generateSpeech, textToSpeech, transcribeAudio, speechToText, generateText, streamText, embedText, similaritySearch } from "./server/utils/ai";
|
|
4
4
|
export type { AiBinding, AiOptions, QarpeoAI, GenerateImageOptions, GenerateImageResult, GenerateSpeechOptions, GenerateSpeechResult, TranscribeAudioInput, TranscribeAudioOptions, TranscribeAudioResult, StreamTextOptions, } from "./types/ai";
|
|
5
|
-
export { generateImage, textToImage, generateSpeech, textToSpeech, transcribeAudio, speechToText, generateText, streamText, embedText, };
|
|
5
|
+
export { generateImage, textToImage, generateSpeech, textToSpeech, transcribeAudio, speechToText, generateText, streamText, embedText, similaritySearch, };
|
|
6
6
|
/**
|
|
7
7
|
* Returns the raw Cloudflare Workers AI binding from the active environment.
|
|
8
8
|
*
|
|
@@ -23,3 +23,5 @@ export declare const useAI: (bindingName?: string, event?: CFEvent) => QarpeoAI;
|
|
|
23
23
|
export declare const ai: QarpeoAI;
|
|
24
24
|
export { useChat, useAgentChat } from "./app/composables/chat";
|
|
25
25
|
export type { UseChatOptions, UseAgentChatOptions } from "./app/composables/chat";
|
|
26
|
+
export { useAIStream, useVectorSearch } from "./app/composables/ai";
|
|
27
|
+
export type { UseAIStreamOptions, UseVectorSearchOptions } from "./app/composables/ai";
|