pulse-cli-divakar 1.0.2 → 1.0.4
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/package.json +8 -6
- package/src/cli/chat/chat-with-aiAgent.js +0 -1
- package/src/cli/chat/chat-with-aitool.js +1 -1
- package/src/cli/chat/utils/chataiutils.js +40 -19
- package/src/cli/commands/ai/wakeup.js +77 -73
- package/src/cli/commands/auth/login.js +2 -3
- package/src/cli/commands/auth/whoami.js +24 -18
- package/src/cli/commands/config/config.js +72 -0
- package/src/cli/main.js +3 -1
- package/src/config/google.config.js +21 -6
- package/src/service/chat.service.js +120 -0
- package/src/generated/prisma/browser.ts +0 -24
- package/src/generated/prisma/client.d.ts +0 -1
- package/src/generated/prisma/client.js +0 -5
- package/src/generated/prisma/client.ts +0 -48
- package/src/generated/prisma/commonInputTypes.ts +0 -92
- package/src/generated/prisma/default.d.ts +0 -1
- package/src/generated/prisma/default.js +0 -5
- package/src/generated/prisma/edge.d.ts +0 -1
- package/src/generated/prisma/edge.js +0 -234
- package/src/generated/prisma/enums.ts +0 -15
- package/src/generated/prisma/index-browser.js +0 -260
- package/src/generated/prisma/index.d.ts +0 -13151
- package/src/generated/prisma/index.js +0 -234
- package/src/generated/prisma/internal/class.ts +0 -204
- package/src/generated/prisma/internal/prismaNamespace.ts +0 -804
- package/src/generated/prisma/internal/prismaNamespaceBrowser.ts +0 -95
- package/src/generated/prisma/models/Test.ts +0 -1069
- package/src/generated/prisma/models.ts +0 -12
- package/src/generated/prisma/package.json +0 -139
- package/src/generated/prisma/query_compiler_fast_bg.js +0 -2
- package/src/generated/prisma/query_compiler_fast_bg.wasm +0 -0
- package/src/generated/prisma/query_compiler_fast_bg.wasm-base64.js +0 -2
- package/src/generated/prisma/runtime/client.d.ts +0 -3490
- package/src/generated/prisma/runtime/client.js +0 -105
- package/src/generated/prisma/runtime/index-browser.d.ts +0 -90
- package/src/generated/prisma/runtime/index-browser.js +0 -6
- package/src/generated/prisma/runtime/wasm-compiler-edge.js +0 -100
- package/src/generated/prisma/schema.prisma +0 -119
- package/src/generated/prisma/wasm-edge-light-loader.mjs +0 -5
- package/src/generated/prisma/wasm-worker-loader.mjs +0 -5
- package/src/index.js +0 -66
- package/src/lib/auth.js +0 -29
- package/src/lib/db.js +0 -9
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
generator client {
|
|
2
|
-
provider = "prisma-client-js"
|
|
3
|
-
output = "../src/generated/prisma"
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
datasource db {
|
|
7
|
-
provider = "postgresql"
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
model Test {
|
|
11
|
-
id String @id @default(cuid())
|
|
12
|
-
name String
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
model User {
|
|
16
|
-
id String @id
|
|
17
|
-
name String
|
|
18
|
-
email String
|
|
19
|
-
emailVerified Boolean @default(false)
|
|
20
|
-
image String?
|
|
21
|
-
createdAt DateTime @default(now())
|
|
22
|
-
updatedAt DateTime @updatedAt
|
|
23
|
-
sessions Session[]
|
|
24
|
-
accounts Account[]
|
|
25
|
-
|
|
26
|
-
conversation Conversation[]
|
|
27
|
-
|
|
28
|
-
@@unique([email])
|
|
29
|
-
@@map("user")
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
model Session {
|
|
33
|
-
id String @id
|
|
34
|
-
expiresAt DateTime
|
|
35
|
-
token String
|
|
36
|
-
createdAt DateTime @default(now())
|
|
37
|
-
updatedAt DateTime @updatedAt
|
|
38
|
-
ipAddress String?
|
|
39
|
-
userAgent String?
|
|
40
|
-
userId String
|
|
41
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
42
|
-
|
|
43
|
-
@@unique([token])
|
|
44
|
-
@@index([userId])
|
|
45
|
-
@@map("session")
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
model Account {
|
|
49
|
-
id String @id
|
|
50
|
-
accountId String
|
|
51
|
-
providerId String
|
|
52
|
-
userId String
|
|
53
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
54
|
-
accessToken String?
|
|
55
|
-
refreshToken String?
|
|
56
|
-
idToken String?
|
|
57
|
-
accessTokenExpiresAt DateTime?
|
|
58
|
-
refreshTokenExpiresAt DateTime?
|
|
59
|
-
scope String?
|
|
60
|
-
password String?
|
|
61
|
-
createdAt DateTime @default(now())
|
|
62
|
-
updatedAt DateTime @updatedAt
|
|
63
|
-
|
|
64
|
-
@@index([userId])
|
|
65
|
-
@@map("account")
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
model Verification {
|
|
69
|
-
id String @id
|
|
70
|
-
identifier String
|
|
71
|
-
value String
|
|
72
|
-
expiresAt DateTime
|
|
73
|
-
createdAt DateTime @default(now())
|
|
74
|
-
updatedAt DateTime @updatedAt
|
|
75
|
-
|
|
76
|
-
@@index([identifier])
|
|
77
|
-
@@map("verification")
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
model DeviceCode {
|
|
81
|
-
id String @id
|
|
82
|
-
deviceCode String
|
|
83
|
-
userCode String
|
|
84
|
-
userId String?
|
|
85
|
-
expiresAt DateTime
|
|
86
|
-
status String
|
|
87
|
-
lastPolledAt DateTime?
|
|
88
|
-
pollingInterval Int?
|
|
89
|
-
clientId String?
|
|
90
|
-
scope String?
|
|
91
|
-
|
|
92
|
-
@@unique([deviceCode], map: "deviceCode_deviceCode_uidx")
|
|
93
|
-
@@unique([userCode], map: "deviceCode_userCode_uidx")
|
|
94
|
-
@@map("deviceCode")
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
model Conversation {
|
|
98
|
-
id String @id @default(cuid())
|
|
99
|
-
userId String
|
|
100
|
-
title String
|
|
101
|
-
mode String @default("chat")
|
|
102
|
-
createdAt DateTime @default(now())
|
|
103
|
-
updatedAt DateTime @default(now()) @updatedAt
|
|
104
|
-
|
|
105
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
106
|
-
messages Message[]
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
model Message {
|
|
110
|
-
id String @id @default(cuid())
|
|
111
|
-
conversationId String
|
|
112
|
-
role String
|
|
113
|
-
content String
|
|
114
|
-
createdAt DateTime @default(now())
|
|
115
|
-
|
|
116
|
-
conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
|
|
117
|
-
|
|
118
|
-
@@index([conversationId])
|
|
119
|
-
}
|
package/src/index.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import "dotenv/config";
|
|
3
|
-
|
|
4
|
-
import express from "express";
|
|
5
|
-
import cors from "cors";
|
|
6
|
-
import { toNodeHandler, fromNodeHeaders } from "better-auth/node";
|
|
7
|
-
import { auth } from "./lib/auth.js";
|
|
8
|
-
|
|
9
|
-
const app = express();
|
|
10
|
-
|
|
11
|
-
const frontendUrl =
|
|
12
|
-
process.env.CLIENT_URL || "http://localhost:3000";
|
|
13
|
-
|
|
14
|
-
const allowedOrigins = [
|
|
15
|
-
"http://localhost:3000",
|
|
16
|
-
frontendUrl,
|
|
17
|
-
].filter(Boolean);
|
|
18
|
-
|
|
19
|
-
app.set("trust proxy", 1);
|
|
20
|
-
|
|
21
|
-
app.use(
|
|
22
|
-
cors({
|
|
23
|
-
origin: allowedOrigins,
|
|
24
|
-
methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
|
|
25
|
-
credentials: true,
|
|
26
|
-
})
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
// Better Auth handler must come before express.json().
|
|
30
|
-
app.all("/api/auth/*splat", toNodeHandler(auth));
|
|
31
|
-
|
|
32
|
-
app.use(express.json());
|
|
33
|
-
|
|
34
|
-
app.get("/api/me", async (req, res, next) => {
|
|
35
|
-
try {
|
|
36
|
-
const session = await auth.api.getSession({
|
|
37
|
-
headers: fromNodeHeaders(req.headers),
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
return res.json(session);
|
|
41
|
-
} catch (error) {
|
|
42
|
-
next(error);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
app.get("/device", (req, res) => {
|
|
47
|
-
const userCode = req.query.user_code;
|
|
48
|
-
|
|
49
|
-
const destination = new URL("/device", frontendUrl);
|
|
50
|
-
|
|
51
|
-
if (typeof userCode === "string") {
|
|
52
|
-
destination.searchParams.set("user_code", userCode);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return res.redirect(destination.toString());
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
app.get("/", (_req, res) => {
|
|
59
|
-
res.status(200).send("Pulse API is running");
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
const port = process.env.PORT || 3004;
|
|
63
|
-
|
|
64
|
-
app.listen(port, "0.0.0.0", () => {
|
|
65
|
-
console.log(`Pulse API listening on port ${port}`);
|
|
66
|
-
});
|
package/src/lib/auth.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { betterAuth } from "better-auth";
|
|
2
|
-
import { prismaAdapter } from "better-auth/adapters/prisma";
|
|
3
|
-
import { deviceAuthorization } from "better-auth/plugins";
|
|
4
|
-
|
|
5
|
-
import { prisma } from "./db.js";
|
|
6
|
-
|
|
7
|
-
export const auth = betterAuth({
|
|
8
|
-
baseURL: process.env.BETTER_AUTH_URL,
|
|
9
|
-
database: prismaAdapter(prisma, {
|
|
10
|
-
provider: "postgresql",
|
|
11
|
-
}),
|
|
12
|
-
basePath:"/api/auth",
|
|
13
|
-
trustedOrigins:["http://localhost:3000",
|
|
14
|
-
process.env.CLIENT_URL,
|
|
15
|
-
],
|
|
16
|
-
socialProviders: {
|
|
17
|
-
github: {
|
|
18
|
-
clientId: process.env.GITHUB_CLIENT_ID,
|
|
19
|
-
clientSecret: process.env.GITHUB_CLIENT_SECRET,
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
plugins: [
|
|
23
|
-
deviceAuthorization({
|
|
24
|
-
verificationUri: "/device",
|
|
25
|
-
expiresIn:"30m",
|
|
26
|
-
interval:"5s"
|
|
27
|
-
}),
|
|
28
|
-
],
|
|
29
|
-
});
|
package/src/lib/db.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
import { PrismaNeon } from "@prisma/adapter-neon";
|
|
3
|
-
import { PrismaClient } from "../generated/prisma/client.js";
|
|
4
|
-
|
|
5
|
-
const adapter = new PrismaNeon({
|
|
6
|
-
connectionString: process.env.DATABASE_URL,
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
export const prisma = new PrismaClient({ adapter });
|