@arch-cadre/core 0.0.6
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/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/_virtual/_rolldown/runtime.mjs +18 -0
- package/dist/core/auth/augment.cjs +71 -0
- package/dist/core/auth/augment.d.cts +20 -0
- package/dist/core/auth/augment.d.cts.map +1 -0
- package/dist/core/auth/augment.d.mts +20 -0
- package/dist/core/auth/augment.d.mts.map +1 -0
- package/dist/core/auth/augment.mjs +66 -0
- package/dist/core/auth/augment.mjs.map +1 -0
- package/dist/core/auth/email-verification.cjs +99 -0
- package/dist/core/auth/email-verification.d.cts +62 -0
- package/dist/core/auth/email-verification.d.cts.map +1 -0
- package/dist/core/auth/email-verification.d.mts +62 -0
- package/dist/core/auth/email-verification.d.mts.map +1 -0
- package/dist/core/auth/email-verification.mjs +92 -0
- package/dist/core/auth/email-verification.mjs.map +1 -0
- package/dist/core/auth/logic.cjs +224 -0
- package/dist/core/auth/logic.d.cts +110 -0
- package/dist/core/auth/logic.d.cts.map +1 -0
- package/dist/core/auth/logic.d.mts +110 -0
- package/dist/core/auth/logic.d.mts.map +1 -0
- package/dist/core/auth/logic.mjs +213 -0
- package/dist/core/auth/logic.mjs.map +1 -0
- package/dist/core/auth/password-reset.cjs +118 -0
- package/dist/core/auth/password-reset.d.cts +39 -0
- package/dist/core/auth/password-reset.d.cts.map +1 -0
- package/dist/core/auth/password-reset.d.mts +39 -0
- package/dist/core/auth/password-reset.d.mts.map +1 -0
- package/dist/core/auth/password-reset.mjs +111 -0
- package/dist/core/auth/password-reset.mjs.map +1 -0
- package/dist/core/auth/rbac.cjs +118 -0
- package/dist/core/auth/rbac.d.cts +61 -0
- package/dist/core/auth/rbac.d.cts.map +1 -0
- package/dist/core/auth/rbac.d.mts +61 -0
- package/dist/core/auth/rbac.d.mts.map +1 -0
- package/dist/core/auth/rbac.mjs +104 -0
- package/dist/core/auth/rbac.mjs.map +1 -0
- package/dist/core/auth/session.cjs +161 -0
- package/dist/core/auth/session.d.cts +54 -0
- package/dist/core/auth/session.d.cts.map +1 -0
- package/dist/core/auth/session.d.mts +54 -0
- package/dist/core/auth/session.d.mts.map +1 -0
- package/dist/core/auth/session.mjs +150 -0
- package/dist/core/auth/session.mjs.map +1 -0
- package/dist/core/auth/types.d.cts +55 -0
- package/dist/core/auth/types.d.cts.map +1 -0
- package/dist/core/auth/types.d.mts +55 -0
- package/dist/core/auth/types.d.mts.map +1 -0
- package/dist/core/auth/utils/encode.cjs +27 -0
- package/dist/core/auth/utils/encode.d.cts +15 -0
- package/dist/core/auth/utils/encode.d.cts.map +1 -0
- package/dist/core/auth/utils/encode.d.mts +15 -0
- package/dist/core/auth/utils/encode.d.mts.map +1 -0
- package/dist/core/auth/utils/encode.mjs +26 -0
- package/dist/core/auth/utils/encode.mjs.map +1 -0
- package/dist/core/auth/utils/encryption.cjs +67 -0
- package/dist/core/auth/utils/encryption.d.cts +28 -0
- package/dist/core/auth/utils/encryption.d.cts.map +1 -0
- package/dist/core/auth/utils/encryption.d.mts +28 -0
- package/dist/core/auth/utils/encryption.d.mts.map +1 -0
- package/dist/core/auth/utils/encryption.mjs +64 -0
- package/dist/core/auth/utils/encryption.mjs.map +1 -0
- package/dist/core/auth/validation.cjs +39 -0
- package/dist/core/auth/validation.d.cts +48 -0
- package/dist/core/auth/validation.d.cts.map +1 -0
- package/dist/core/auth/validation.d.mts +48 -0
- package/dist/core/auth/validation.d.mts.map +1 -0
- package/dist/core/auth/validation.mjs +31 -0
- package/dist/core/auth/validation.mjs.map +1 -0
- package/dist/core/bootstrap.cjs +32 -0
- package/dist/core/bootstrap.d.cts +5 -0
- package/dist/core/bootstrap.d.cts.map +1 -0
- package/dist/core/bootstrap.d.mts +5 -0
- package/dist/core/bootstrap.d.mts.map +1 -0
- package/dist/core/bootstrap.mjs +33 -0
- package/dist/core/bootstrap.mjs.map +1 -0
- package/dist/core/config.cjs +6 -0
- package/dist/core/config.d.cts +11 -0
- package/dist/core/config.d.cts.map +1 -0
- package/dist/core/config.d.mts +11 -0
- package/dist/core/config.d.mts.map +1 -0
- package/dist/core/config.mjs +6 -0
- package/dist/core/config.mjs.map +1 -0
- package/dist/core/config.server.cjs +60 -0
- package/dist/core/config.server.d.cts +16 -0
- package/dist/core/config.server.d.cts.map +1 -0
- package/dist/core/config.server.d.mts +16 -0
- package/dist/core/config.server.d.mts.map +1 -0
- package/dist/core/config.server.mjs +57 -0
- package/dist/core/config.server.mjs.map +1 -0
- package/dist/core/event-bus.cjs +48 -0
- package/dist/core/event-bus.d.cts +17 -0
- package/dist/core/event-bus.d.cts.map +1 -0
- package/dist/core/event-bus.d.mts +17 -0
- package/dist/core/event-bus.d.mts.map +1 -0
- package/dist/core/event-bus.mjs +48 -0
- package/dist/core/event-bus.mjs.map +1 -0
- package/dist/core/filesystem/service.cjs +43 -0
- package/dist/core/filesystem/service.d.cts +19 -0
- package/dist/core/filesystem/service.d.cts.map +1 -0
- package/dist/core/filesystem/service.d.mts +19 -0
- package/dist/core/filesystem/service.d.mts.map +1 -0
- package/dist/core/filesystem/service.mjs +43 -0
- package/dist/core/filesystem/service.mjs.map +1 -0
- package/dist/core/filesystem/types.d.cts +22 -0
- package/dist/core/filesystem/types.d.cts.map +1 -0
- package/dist/core/filesystem/types.d.mts +22 -0
- package/dist/core/filesystem/types.d.mts.map +1 -0
- package/dist/core/notifications/actions.cjs +36 -0
- package/dist/core/notifications/actions.d.cts +58 -0
- package/dist/core/notifications/actions.d.cts.map +1 -0
- package/dist/core/notifications/actions.d.mts +58 -0
- package/dist/core/notifications/actions.d.mts.map +1 -0
- package/dist/core/notifications/actions.mjs +33 -0
- package/dist/core/notifications/actions.mjs.map +1 -0
- package/dist/core/notifications/index.cjs +2 -0
- package/dist/core/notifications/index.mjs +4 -0
- package/dist/core/notifications/service.cjs +30 -0
- package/dist/core/notifications/service.d.cts +9 -0
- package/dist/core/notifications/service.d.cts.map +1 -0
- package/dist/core/notifications/service.d.mts +9 -0
- package/dist/core/notifications/service.d.mts.map +1 -0
- package/dist/core/notifications/service.mjs +31 -0
- package/dist/core/notifications/service.mjs.map +1 -0
- package/dist/core/notifications/types.d.cts +21 -0
- package/dist/core/notifications/types.d.cts.map +1 -0
- package/dist/core/notifications/types.d.mts +21 -0
- package/dist/core/notifications/types.d.mts.map +1 -0
- package/dist/core/setup.cjs +25 -0
- package/dist/core/setup.d.cts +9 -0
- package/dist/core/setup.d.cts.map +1 -0
- package/dist/core/setup.d.mts +9 -0
- package/dist/core/setup.d.mts.map +1 -0
- package/dist/core/setup.mjs +25 -0
- package/dist/core/setup.mjs.map +1 -0
- package/dist/core/types.d.cts +13 -0
- package/dist/core/types.d.cts.map +1 -0
- package/dist/core/types.d.mts +13 -0
- package/dist/core/types.d.mts.map +1 -0
- package/dist/index.cjs +30 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.mts +8 -0
- package/dist/index.mjs +6 -0
- package/dist/server/auth/email.cjs +24 -0
- package/dist/server/auth/email.d.cts +13 -0
- package/dist/server/auth/email.d.cts.map +1 -0
- package/dist/server/auth/email.d.mts +13 -0
- package/dist/server/auth/email.d.mts.map +1 -0
- package/dist/server/auth/email.mjs +23 -0
- package/dist/server/auth/email.mjs.map +1 -0
- package/dist/server/auth/password.cjs +37 -0
- package/dist/server/auth/password.d.cts +23 -0
- package/dist/server/auth/password.d.cts.map +1 -0
- package/dist/server/auth/password.d.mts +23 -0
- package/dist/server/auth/password.d.mts.map +1 -0
- package/dist/server/auth/password.mjs +34 -0
- package/dist/server/auth/password.mjs.map +1 -0
- package/dist/server/auth/user.cjs +165 -0
- package/dist/server/auth/user.d.cts +58 -0
- package/dist/server/auth/user.d.cts.map +1 -0
- package/dist/server/auth/user.d.mts +58 -0
- package/dist/server/auth/user.d.mts.map +1 -0
- package/dist/server/auth/user.mjs +153 -0
- package/dist/server/auth/user.mjs.map +1 -0
- package/dist/server/database/inject.cjs +24 -0
- package/dist/server/database/inject.d.cts +15 -0
- package/dist/server/database/inject.d.cts.map +1 -0
- package/dist/server/database/inject.d.mts +15 -0
- package/dist/server/database/inject.d.mts.map +1 -0
- package/dist/server/database/inject.mjs +23 -0
- package/dist/server/database/inject.mjs.map +1 -0
- package/dist/server/database/schema.cjs +163 -0
- package/dist/server/database/schema.d.cts +2962 -0
- package/dist/server/database/schema.d.cts.map +1 -0
- package/dist/server/database/schema.d.mts +2962 -0
- package/dist/server/database/schema.d.mts.map +1 -0
- package/dist/server/database/schema.mjs +151 -0
- package/dist/server/database/schema.mjs.map +1 -0
- package/dist/server/emails/index.cjs +32 -0
- package/dist/server/emails/index.d.cts +26 -0
- package/dist/server/emails/index.d.cts.map +1 -0
- package/dist/server/emails/index.d.mts +26 -0
- package/dist/server/emails/index.d.mts.map +1 -0
- package/dist/server/emails/index.mjs +29 -0
- package/dist/server/emails/index.mjs.map +1 -0
- package/dist/server.cjs +145 -0
- package/dist/server.d.cts +26 -0
- package/dist/server.d.mts +26 -0
- package/dist/server.mjs +23 -0
- package/package.json +60 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { CreateNotificationPayload } from "./types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/core/notifications/actions.d.ts
|
|
4
|
+
declare function getUserNotifications(): Promise<{
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
content: string | null;
|
|
8
|
+
target: string | null;
|
|
9
|
+
type: string | null;
|
|
10
|
+
isRead: boolean;
|
|
11
|
+
resourceId: string | null;
|
|
12
|
+
resourceType: string | null;
|
|
13
|
+
userId: string;
|
|
14
|
+
createdAt: Date;
|
|
15
|
+
updatedAt: Date | null;
|
|
16
|
+
}[] | null>;
|
|
17
|
+
declare function createNotification(data: CreateNotificationPayload): Promise<{
|
|
18
|
+
id: string;
|
|
19
|
+
createdAt: Date;
|
|
20
|
+
updatedAt: Date | null;
|
|
21
|
+
userId: string;
|
|
22
|
+
title: string;
|
|
23
|
+
content: string | null;
|
|
24
|
+
target: string | null;
|
|
25
|
+
type: string | null;
|
|
26
|
+
isRead: boolean;
|
|
27
|
+
resourceId: string | null;
|
|
28
|
+
resourceType: string | null;
|
|
29
|
+
}>;
|
|
30
|
+
declare function markNotificationAsRead(id: string): Promise<{
|
|
31
|
+
id: string;
|
|
32
|
+
title: string;
|
|
33
|
+
content: string | null;
|
|
34
|
+
target: string | null;
|
|
35
|
+
type: string | null;
|
|
36
|
+
isRead: boolean;
|
|
37
|
+
resourceId: string | null;
|
|
38
|
+
resourceType: string | null;
|
|
39
|
+
userId: string;
|
|
40
|
+
createdAt: Date;
|
|
41
|
+
updatedAt: Date | null;
|
|
42
|
+
}>;
|
|
43
|
+
declare function markAllNotificationsAsRead(): Promise<{
|
|
44
|
+
id: string;
|
|
45
|
+
title: string;
|
|
46
|
+
content: string | null;
|
|
47
|
+
target: string | null;
|
|
48
|
+
type: string | null;
|
|
49
|
+
isRead: boolean;
|
|
50
|
+
resourceId: string | null;
|
|
51
|
+
resourceType: string | null;
|
|
52
|
+
userId: string;
|
|
53
|
+
createdAt: Date;
|
|
54
|
+
updatedAt: Date | null;
|
|
55
|
+
}[] | null>;
|
|
56
|
+
//#endregion
|
|
57
|
+
export { createNotification, getUserNotifications, markAllNotificationsAsRead, markNotificationAsRead };
|
|
58
|
+
//# sourceMappingURL=actions.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.cts","names":[],"sources":["../../../src/core/notifications/actions.ts"],"mappings":";;;iBAQsB,oBAAA,CAAA,GAAoB,OAAA;;;;;;;;;;;;;iBAWpB,kBAAA,CAAmB,IAAA,EAAM,yBAAA,GAAyB,OAAA;;;;;;;;;;;;;iBAYlD,sBAAA,CAAuB,EAAA,WAAU,OAAA;;;;;;;;;;;;;iBAUjC,0BAAA,CAAA,GAA0B,OAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { CreateNotificationPayload } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/core/notifications/actions.d.ts
|
|
4
|
+
declare function getUserNotifications(): Promise<{
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
content: string | null;
|
|
8
|
+
target: string | null;
|
|
9
|
+
type: string | null;
|
|
10
|
+
isRead: boolean;
|
|
11
|
+
resourceId: string | null;
|
|
12
|
+
resourceType: string | null;
|
|
13
|
+
userId: string;
|
|
14
|
+
createdAt: Date;
|
|
15
|
+
updatedAt: Date | null;
|
|
16
|
+
}[] | null>;
|
|
17
|
+
declare function createNotification(data: CreateNotificationPayload): Promise<{
|
|
18
|
+
id: string;
|
|
19
|
+
createdAt: Date;
|
|
20
|
+
updatedAt: Date | null;
|
|
21
|
+
userId: string;
|
|
22
|
+
title: string;
|
|
23
|
+
content: string | null;
|
|
24
|
+
target: string | null;
|
|
25
|
+
type: string | null;
|
|
26
|
+
isRead: boolean;
|
|
27
|
+
resourceId: string | null;
|
|
28
|
+
resourceType: string | null;
|
|
29
|
+
}>;
|
|
30
|
+
declare function markNotificationAsRead(id: string): Promise<{
|
|
31
|
+
id: string;
|
|
32
|
+
title: string;
|
|
33
|
+
content: string | null;
|
|
34
|
+
target: string | null;
|
|
35
|
+
type: string | null;
|
|
36
|
+
isRead: boolean;
|
|
37
|
+
resourceId: string | null;
|
|
38
|
+
resourceType: string | null;
|
|
39
|
+
userId: string;
|
|
40
|
+
createdAt: Date;
|
|
41
|
+
updatedAt: Date | null;
|
|
42
|
+
}>;
|
|
43
|
+
declare function markAllNotificationsAsRead(): Promise<{
|
|
44
|
+
id: string;
|
|
45
|
+
title: string;
|
|
46
|
+
content: string | null;
|
|
47
|
+
target: string | null;
|
|
48
|
+
type: string | null;
|
|
49
|
+
isRead: boolean;
|
|
50
|
+
resourceId: string | null;
|
|
51
|
+
resourceType: string | null;
|
|
52
|
+
userId: string;
|
|
53
|
+
createdAt: Date;
|
|
54
|
+
updatedAt: Date | null;
|
|
55
|
+
}[] | null>;
|
|
56
|
+
//#endregion
|
|
57
|
+
export { createNotification, getUserNotifications, markAllNotificationsAsRead, markNotificationAsRead };
|
|
58
|
+
//# sourceMappingURL=actions.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.mts","names":[],"sources":["../../../src/core/notifications/actions.ts"],"mappings":";;;iBAQsB,oBAAA,CAAA,GAAoB,OAAA;;;;;;;;;;;;;iBAWpB,kBAAA,CAAmB,IAAA,EAAM,yBAAA,GAAyB,OAAA;;;;;;;;;;;;;iBAYlD,sBAAA,CAAuB,EAAA,WAAU,OAAA;;;;;;;;;;;;;iBAUjC,0BAAA,CAAA,GAA0B,OAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
|
|
3
|
+
import { db } from "../../server/database/inject.mjs";
|
|
4
|
+
import { notificationTable } from "../../server/database/schema.mjs";
|
|
5
|
+
import { getCurrentSession } from "../auth/session.mjs";
|
|
6
|
+
import { desc, eq } from "drizzle-orm";
|
|
7
|
+
|
|
8
|
+
//#region src/core/notifications/actions.ts
|
|
9
|
+
async function getUserNotifications() {
|
|
10
|
+
const { user } = await getCurrentSession();
|
|
11
|
+
if (!user) return null;
|
|
12
|
+
return await db.select().from(notificationTable).where(eq(notificationTable.userId, user.id)).orderBy(desc(notificationTable.createdAt));
|
|
13
|
+
}
|
|
14
|
+
async function createNotification(data) {
|
|
15
|
+
const [notification] = await db.insert(notificationTable).values({
|
|
16
|
+
...data,
|
|
17
|
+
isRead: false
|
|
18
|
+
}).returning();
|
|
19
|
+
return notification;
|
|
20
|
+
}
|
|
21
|
+
async function markNotificationAsRead(id) {
|
|
22
|
+
const [updated] = await db.update(notificationTable).set({ isRead: true }).where(eq(notificationTable.id, id)).returning();
|
|
23
|
+
return updated;
|
|
24
|
+
}
|
|
25
|
+
async function markAllNotificationsAsRead() {
|
|
26
|
+
const { user } = await getCurrentSession();
|
|
27
|
+
if (!user) return null;
|
|
28
|
+
return await db.update(notificationTable).set({ isRead: true }).where(eq(notificationTable.userId, user.id)).returning();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { createNotification, getUserNotifications, markAllNotificationsAsRead, markNotificationAsRead };
|
|
33
|
+
//# sourceMappingURL=actions.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.mjs","names":[],"sources":["../../../src/core/notifications/actions.ts"],"sourcesContent":["\"use server\";\n\nimport { desc, eq } from \"drizzle-orm\";\nimport { getCurrentSession } from \"../auth/session\";\nimport { db } from \"../../server/database/inject\";\nimport { notificationTable } from \"../../server/database/schema\";\nimport type { CreateNotificationPayload } from \"./types\";\n\nexport async function getUserNotifications() {\n const { user } = await getCurrentSession();\n if (!user) return null;\n\n return await db\n .select()\n .from(notificationTable)\n .where(eq(notificationTable.userId, user.id))\n .orderBy(desc(notificationTable.createdAt));\n}\n\nexport async function createNotification(data: CreateNotificationPayload) {\n const [notification] = await db\n .insert(notificationTable)\n .values({\n ...data,\n isRead: false,\n })\n .returning();\n\n return notification;\n}\n\nexport async function markNotificationAsRead(id: string) {\n const [updated] = await db\n .update(notificationTable)\n .set({ isRead: true })\n .where(eq(notificationTable.id, id))\n .returning();\n\n return updated;\n}\n\nexport async function markAllNotificationsAsRead() {\n const { user } = await getCurrentSession();\n if (!user) return null;\n\n return await db\n .update(notificationTable)\n .set({ isRead: true })\n .where(eq(notificationTable.userId, user.id))\n .returning();\n}\n"],"mappings":";;;;;;;;AAQA,eAAsB,uBAAuB;CAC3C,MAAM,EAAE,SAAS,MAAM,mBAAmB;AAC1C,KAAI,CAAC,KAAM,QAAO;AAElB,QAAO,MAAM,GACV,QAAQ,CACR,KAAK,kBAAkB,CACvB,MAAM,GAAG,kBAAkB,QAAQ,KAAK,GAAG,CAAC,CAC5C,QAAQ,KAAK,kBAAkB,UAAU,CAAC;;AAG/C,eAAsB,mBAAmB,MAAiC;CACxE,MAAM,CAAC,gBAAgB,MAAM,GAC1B,OAAO,kBAAkB,CACzB,OAAO;EACN,GAAG;EACH,QAAQ;EACT,CAAC,CACD,WAAW;AAEd,QAAO;;AAGT,eAAsB,uBAAuB,IAAY;CACvD,MAAM,CAAC,WAAW,MAAM,GACrB,OAAO,kBAAkB,CACzB,IAAI,EAAE,QAAQ,MAAM,CAAC,CACrB,MAAM,GAAG,kBAAkB,IAAI,GAAG,CAAC,CACnC,WAAW;AAEd,QAAO;;AAGT,eAAsB,6BAA6B;CACjD,MAAM,EAAE,SAAS,MAAM,mBAAmB;AAC1C,KAAI,CAAC,KAAM,QAAO;AAElB,QAAO,MAAM,GACV,OAAO,kBAAkB,CACzB,IAAI,EAAE,QAAQ,MAAM,CAAC,CACrB,MAAM,GAAG,kBAAkB,QAAQ,KAAK,GAAG,CAAC,CAC5C,WAAW"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const require_event_bus = require('../event-bus.cjs');
|
|
2
|
+
const require_actions = require('./actions.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/core/notifications/service.ts
|
|
5
|
+
var NotificationService = class {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.initialized = false;
|
|
8
|
+
}
|
|
9
|
+
init() {
|
|
10
|
+
if (this.initialized) return;
|
|
11
|
+
console.log("[Notification Service] Subscribing to notification:send...");
|
|
12
|
+
require_event_bus.eventBus.subscribe("notification:send", "notification-service", async (event) => {
|
|
13
|
+
console.log("[Notification Service] Received notification:send event", event.payload);
|
|
14
|
+
try {
|
|
15
|
+
const result = await require_actions.createNotification(event.payload);
|
|
16
|
+
console.log("[Notification Service] Notification created successfully:", result.id);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error("[Notification Service] Failed to process notification:send", error);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
this.initialized = true;
|
|
22
|
+
console.log("[NotificationService] Initialized and listening for events.");
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const globalForNotifications = globalThis;
|
|
26
|
+
const notificationService = globalForNotifications.__WINKLY_NOTIFICATION_SERVICE__ ?? new NotificationService();
|
|
27
|
+
globalForNotifications.__WINKLY_NOTIFICATION_SERVICE__ = notificationService;
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.notificationService = notificationService;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/core/notifications/service.d.ts
|
|
2
|
+
declare class NotificationService {
|
|
3
|
+
private initialized;
|
|
4
|
+
init(): void;
|
|
5
|
+
}
|
|
6
|
+
declare const notificationService: NotificationService;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { notificationService };
|
|
9
|
+
//# sourceMappingURL=service.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.cts","names":[],"sources":["../../../src/core/notifications/service.ts"],"mappings":";cAIM,mBAAA;EAAA,QACI,WAAA;EAED,IAAA,CAAA;AAAA;AAAA,cA4CI,mBAAA,EAAmB,mBAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/core/notifications/service.d.ts
|
|
2
|
+
declare class NotificationService {
|
|
3
|
+
private initialized;
|
|
4
|
+
init(): void;
|
|
5
|
+
}
|
|
6
|
+
declare const notificationService: NotificationService;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { notificationService };
|
|
9
|
+
//# sourceMappingURL=service.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.mts","names":[],"sources":["../../../src/core/notifications/service.ts"],"mappings":";cAIM,mBAAA;EAAA,QACI,WAAA;EAED,IAAA,CAAA;AAAA;AAAA,cA4CI,mBAAA,EAAmB,mBAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { eventBus } from "../event-bus.mjs";
|
|
2
|
+
import { createNotification } from "./actions.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/core/notifications/service.ts
|
|
5
|
+
var NotificationService = class {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.initialized = false;
|
|
8
|
+
}
|
|
9
|
+
init() {
|
|
10
|
+
if (this.initialized) return;
|
|
11
|
+
console.log("[Notification Service] Subscribing to notification:send...");
|
|
12
|
+
eventBus.subscribe("notification:send", "notification-service", async (event) => {
|
|
13
|
+
console.log("[Notification Service] Received notification:send event", event.payload);
|
|
14
|
+
try {
|
|
15
|
+
const result = await createNotification(event.payload);
|
|
16
|
+
console.log("[Notification Service] Notification created successfully:", result.id);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error("[Notification Service] Failed to process notification:send", error);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
this.initialized = true;
|
|
22
|
+
console.log("[NotificationService] Initialized and listening for events.");
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const globalForNotifications = globalThis;
|
|
26
|
+
const notificationService = globalForNotifications.__WINKLY_NOTIFICATION_SERVICE__ ?? new NotificationService();
|
|
27
|
+
globalForNotifications.__WINKLY_NOTIFICATION_SERVICE__ = notificationService;
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { notificationService };
|
|
31
|
+
//# sourceMappingURL=service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.mjs","names":[],"sources":["../../../src/core/notifications/service.ts"],"sourcesContent":["import { eventBus } from \"../event-bus\";\nimport { createNotification } from \"./actions\";\nimport type { CreateNotificationPayload } from \"./types\";\n\nclass NotificationService {\n private initialized = false;\n\n public init() {\n if (this.initialized) {\n // console.log(\"[Notification Service] Already initialized.\");\n return;\n }\n\n console.log(\"[Notification Service] Subscribing to notification:send...\");\n\n eventBus.subscribe(\n \"notification:send\",\n \"notification-service\",\n async (event) => {\n console.log(\n \"[Notification Service] Received notification:send event\",\n event.payload,\n );\n try {\n // const { createNotification } = await import(\"./actions\");\n const result = await createNotification(\n event.payload as CreateNotificationPayload,\n );\n console.log(\n \"[Notification Service] Notification created successfully:\",\n result.id,\n );\n } catch (error) {\n console.error(\n \"[Notification Service] Failed to process notification:send\",\n error,\n );\n }\n },\n );\n\n this.initialized = true;\n console.log(\"[NotificationService] Initialized and listening for events.\");\n }\n}\n\n// Global Singleton Pattern\nconst globalForNotifications = globalThis as unknown as {\n __WINKLY_NOTIFICATION_SERVICE__: NotificationService | undefined;\n};\n\nexport const notificationService =\n globalForNotifications.__WINKLY_NOTIFICATION_SERVICE__ ??\n new NotificationService();\n\nglobalForNotifications.__WINKLY_NOTIFICATION_SERVICE__ = notificationService;\n"],"mappings":";;;;AAIA,IAAM,sBAAN,MAA0B;;qBACF;;CAEtB,AAAO,OAAO;AACZ,MAAI,KAAK,YAEP;AAGF,UAAQ,IAAI,6DAA6D;AAEzE,WAAS,UACP,qBACA,wBACA,OAAO,UAAU;AACf,WAAQ,IACN,2DACA,MAAM,QACP;AACD,OAAI;IAEF,MAAM,SAAS,MAAM,mBACnB,MAAM,QACP;AACD,YAAQ,IACN,6DACA,OAAO,GACR;YACM,OAAO;AACd,YAAQ,MACN,8DACA,MACD;;IAGN;AAED,OAAK,cAAc;AACnB,UAAQ,IAAI,8DAA8D;;;AAK9E,MAAM,yBAAyB;AAI/B,MAAa,sBACX,uBAAuB,mCACvB,IAAI,qBAAqB;AAE3B,uBAAuB,kCAAkC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { notificationTable } from "../../server/database/schema.cjs";
|
|
2
|
+
import { InferSelectModel } from "drizzle-orm";
|
|
3
|
+
|
|
4
|
+
//#region src/core/notifications/types.d.ts
|
|
5
|
+
type Notification = InferSelectModel<typeof notificationTable>;
|
|
6
|
+
type CreateNotificationPayload = {
|
|
7
|
+
title: string;
|
|
8
|
+
content?: string;
|
|
9
|
+
type?: string;
|
|
10
|
+
target?: string;
|
|
11
|
+
userId: string;
|
|
12
|
+
resourceId?: string;
|
|
13
|
+
resourceType?: string;
|
|
14
|
+
};
|
|
15
|
+
type NotificationEvents = {
|
|
16
|
+
"notification:send": CreateNotificationPayload;
|
|
17
|
+
"notification:created": Notification;
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { CreateNotificationPayload, Notification, NotificationEvents };
|
|
21
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../../src/core/notifications/types.ts"],"mappings":";;;;KAGY,YAAA,GAAe,gBAAA,QAAwB,iBAAA;AAAA,KAEvC,yBAAA;EACV,KAAA;EACA,OAAA;EACA,IAAA;EACA,MAAA;EACA,MAAA;EACA,UAAA;EACA,YAAA;AAAA;AAAA,KAGU,kBAAA;EACV,mBAAA,EAAqB,yBAAA;EACrB,sBAAA,EAAwB,YAAA;AAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { notificationTable } from "../../server/database/schema.mjs";
|
|
2
|
+
import { InferSelectModel } from "drizzle-orm";
|
|
3
|
+
|
|
4
|
+
//#region src/core/notifications/types.d.ts
|
|
5
|
+
type Notification = InferSelectModel<typeof notificationTable>;
|
|
6
|
+
type CreateNotificationPayload = {
|
|
7
|
+
title: string;
|
|
8
|
+
content?: string;
|
|
9
|
+
type?: string;
|
|
10
|
+
target?: string;
|
|
11
|
+
userId: string;
|
|
12
|
+
resourceId?: string;
|
|
13
|
+
resourceType?: string;
|
|
14
|
+
};
|
|
15
|
+
type NotificationEvents = {
|
|
16
|
+
"notification:send": CreateNotificationPayload;
|
|
17
|
+
"notification:created": Notification;
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { CreateNotificationPayload, Notification, NotificationEvents };
|
|
21
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../../src/core/notifications/types.ts"],"mappings":";;;;KAGY,YAAA,GAAe,gBAAA,QAAwB,iBAAA;AAAA,KAEvC,yBAAA;EACV,KAAA;EACA,OAAA;EACA,IAAA;EACA,MAAA;EACA,MAAA;EACA,UAAA;EACA,YAAA;AAAA;AAAA,KAGU,kBAAA;EACV,mBAAA,EAAqB,yBAAA;EACrB,sBAAA,EAAwB,YAAA;AAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_inject = require('../server/database/inject.cjs');
|
|
3
|
+
const require_schema = require('../server/database/schema.cjs');
|
|
4
|
+
let drizzle_orm = require("drizzle-orm");
|
|
5
|
+
|
|
6
|
+
//#region src/core/setup.ts
|
|
7
|
+
/**
|
|
8
|
+
* Checks if the system is installed.
|
|
9
|
+
* A system is considered installed if at least one user exists in the database.
|
|
10
|
+
*/
|
|
11
|
+
async function isSystemInstalled() {
|
|
12
|
+
try {
|
|
13
|
+
console.log("[Kernel:Setup] Checking if system is installed...");
|
|
14
|
+
const result = await require_inject.db.select({ count: drizzle_orm.sql`count(*)` }).from(require_schema.userTable);
|
|
15
|
+
const count = Number(result[0]?.count || 0);
|
|
16
|
+
console.log(`[Kernel:Setup] User count: ${count}`);
|
|
17
|
+
return count > 0;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.log(`[Kernel:Setup] System not installed or error: ${error.message}`);
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.isSystemInstalled = isSystemInstalled;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/core/setup.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the system is installed.
|
|
4
|
+
* A system is considered installed if at least one user exists in the database.
|
|
5
|
+
*/
|
|
6
|
+
declare function isSystemInstalled(): Promise<boolean>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { isSystemInstalled };
|
|
9
|
+
//# sourceMappingURL=setup.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.cts","names":[],"sources":["../../src/core/setup.ts"],"mappings":";;AAQA;;;iBAAsB,iBAAA,CAAA,GAAqB,OAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/core/setup.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the system is installed.
|
|
4
|
+
* A system is considered installed if at least one user exists in the database.
|
|
5
|
+
*/
|
|
6
|
+
declare function isSystemInstalled(): Promise<boolean>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { isSystemInstalled };
|
|
9
|
+
//# sourceMappingURL=setup.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.mts","names":[],"sources":["../../src/core/setup.ts"],"mappings":";;AAQA;;;iBAAsB,iBAAA,CAAA,GAAqB,OAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { db } from "../server/database/inject.mjs";
|
|
2
|
+
import { userTable } from "../server/database/schema.mjs";
|
|
3
|
+
import { sql } from "drizzle-orm";
|
|
4
|
+
|
|
5
|
+
//#region src/core/setup.ts
|
|
6
|
+
/**
|
|
7
|
+
* Checks if the system is installed.
|
|
8
|
+
* A system is considered installed if at least one user exists in the database.
|
|
9
|
+
*/
|
|
10
|
+
async function isSystemInstalled() {
|
|
11
|
+
try {
|
|
12
|
+
console.log("[Kernel:Setup] Checking if system is installed...");
|
|
13
|
+
const result = await db.select({ count: sql`count(*)` }).from(userTable);
|
|
14
|
+
const count = Number(result[0]?.count || 0);
|
|
15
|
+
console.log(`[Kernel:Setup] User count: ${count}`);
|
|
16
|
+
return count > 0;
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.log(`[Kernel:Setup] System not installed or error: ${error.message}`);
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { isSystemInstalled };
|
|
25
|
+
//# sourceMappingURL=setup.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.mjs","names":[],"sources":["../../src/core/setup.ts"],"sourcesContent":["import { sql } from \"drizzle-orm\";\nimport { db } from \"../server/database/inject\";\nimport { userTable } from \"../server/database/schema\";\n\n/**\n * Checks if the system is installed.\n * A system is considered installed if at least one user exists in the database.\n */\nexport async function isSystemInstalled(): Promise<boolean> {\n try {\n // We check if the users table exists and has at least one record\n console.log(\"[Kernel:Setup] Checking if system is installed...\");\n const result = await db\n .select({ count: sql<string | number>`count(*)` })\n .from(userTable);\n const count = Number(result[0]?.count || 0);\n console.log(`[Kernel:Setup] User count: ${count}`);\n return count > 0;\n } catch (error: any) {\n console.log(\n `[Kernel:Setup] System not installed or error: ${error.message}`,\n );\n // If table doesn't exist, it's definitely not installed\n return false;\n }\n}\n"],"mappings":";;;;;;;;;AAQA,eAAsB,oBAAsC;AAC1D,KAAI;AAEF,UAAQ,IAAI,oDAAoD;EAChE,MAAM,SAAS,MAAM,GAClB,OAAO,EAAE,OAAO,GAAoB,YAAY,CAAC,CACjD,KAAK,UAAU;EAClB,MAAM,QAAQ,OAAO,OAAO,IAAI,SAAS,EAAE;AAC3C,UAAQ,IAAI,8BAA8B,QAAQ;AAClD,SAAO,QAAQ;UACR,OAAY;AACnB,UAAQ,IACN,iDAAiD,MAAM,UACxD;AAED,SAAO"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/core/types.d.ts
|
|
2
|
+
type UserRole = "user" | "admin" | string;
|
|
3
|
+
type UserPermission = string;
|
|
4
|
+
interface SystemEvent<T = any> {
|
|
5
|
+
type: string;
|
|
6
|
+
payload: T;
|
|
7
|
+
timestamp: number;
|
|
8
|
+
source: string;
|
|
9
|
+
}
|
|
10
|
+
type EventHandler<T = any> = (event: SystemEvent<T>) => Promise<void> | void;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { EventHandler, SystemEvent, UserPermission, UserRole };
|
|
13
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/core/types.ts"],"mappings":";KAAY,QAAA;AAAA,KACA,cAAA;AAAA,UAEK,WAAA;EACf,IAAA;EACA,OAAA,EAAS,CAAA;EACT,SAAA;EACA,MAAA;AAAA;AAAA,KAGU,YAAA,aACV,KAAA,EAAO,WAAA,CAAY,CAAA,MAChB,OAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/core/types.d.ts
|
|
2
|
+
type UserRole = "user" | "admin" | string;
|
|
3
|
+
type UserPermission = string;
|
|
4
|
+
interface SystemEvent<T = any> {
|
|
5
|
+
type: string;
|
|
6
|
+
payload: T;
|
|
7
|
+
timestamp: number;
|
|
8
|
+
source: string;
|
|
9
|
+
}
|
|
10
|
+
type EventHandler<T = any> = (event: SystemEvent<T>) => Promise<void> | void;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { EventHandler, SystemEvent, UserPermission, UserRole };
|
|
13
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/core/types.ts"],"mappings":";KAAY,QAAA;AAAA,KACA,cAAA;AAAA,UAEK,WAAA;EACf,IAAA;EACA,OAAA,EAAS,CAAA;EACT,SAAA;EACA,MAAA;AAAA;AAAA,KAGU,YAAA,aACV,KAAA,EAAO,WAAA,CAAY,CAAA,MAChB,OAAA"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_validation = require('./core/auth/validation.cjs');
|
|
3
|
+
const require_event_bus = require('./core/event-bus.cjs');
|
|
4
|
+
const require_schema = require('./server/database/schema.cjs');
|
|
5
|
+
const require_service = require('./core/notifications/service.cjs');
|
|
6
|
+
|
|
7
|
+
exports.coreSchema = require_schema.coreSchema;
|
|
8
|
+
exports.emailVerificationTable = require_schema.emailVerificationTable;
|
|
9
|
+
exports.eventBus = require_event_bus.eventBus;
|
|
10
|
+
exports.forgotPasswordSchema = require_validation.forgotPasswordSchema;
|
|
11
|
+
exports.loginSchema = require_validation.loginSchema;
|
|
12
|
+
exports.notificationService = require_service.notificationService;
|
|
13
|
+
exports.notificationTable = require_schema.notificationTable;
|
|
14
|
+
exports.passkeysSetupSchema = require_validation.passkeysSetupSchema;
|
|
15
|
+
exports.passwordResetSessionTable = require_schema.passwordResetSessionTable;
|
|
16
|
+
exports.permissionsTable = require_schema.permissionsTable;
|
|
17
|
+
exports.recoveryCodeVerifySchema = require_validation.recoveryCodeVerifySchema;
|
|
18
|
+
exports.registerSchema = require_validation.registerSchema;
|
|
19
|
+
exports.relations = require_schema.relations;
|
|
20
|
+
exports.resetPasswordSchema = require_validation.resetPasswordSchema;
|
|
21
|
+
exports.rolesTable = require_schema.rolesTable;
|
|
22
|
+
exports.rolesToPermissionsTable = require_schema.rolesToPermissionsTable;
|
|
23
|
+
exports.sessionTable = require_schema.sessionTable;
|
|
24
|
+
exports.systemModulesTable = require_schema.systemModulesTable;
|
|
25
|
+
exports.totpSetupSchema = require_validation.totpSetupSchema;
|
|
26
|
+
exports.totpVerifySchema = require_validation.totpVerifySchema;
|
|
27
|
+
exports.userTable = require_schema.userTable;
|
|
28
|
+
exports.usersToPermissionsTable = require_schema.usersToPermissionsTable;
|
|
29
|
+
exports.usersToRolesTable = require_schema.usersToRolesTable;
|
|
30
|
+
exports.verifyEmailSchema = require_validation.verifyEmailSchema;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DatabaseSchema, coreSchema, emailVerificationTable, notificationTable, passwordResetSessionTable, permissionsTable, relations, rolesTable, rolesToPermissionsTable, sessionTable, systemModulesTable, userTable, usersToPermissionsTable, usersToRolesTable } from "./server/database/schema.cjs";
|
|
2
|
+
import { EventHandler, SystemEvent, UserPermission, UserRole } from "./core/types.cjs";
|
|
3
|
+
import { AuthResponse, AuthSession, FullUser, PasswordResetAuthSession, PasswordResetSession, Session, SessionFlags, User, UserSession } from "./core/auth/types.cjs";
|
|
4
|
+
import { ForgotPasswordInput, LoginInput, PasskeysSetupInput, RecoveryVerifyInput, RegisterInput, ResetPasswordInput, TOTPSetupInput, TOTPVerifyInput, VerifyEmailInput, forgotPasswordSchema, loginSchema, passkeysSetupSchema, recoveryCodeVerifySchema, registerSchema, resetPasswordSchema, totpSetupSchema, totpVerifySchema, verifyEmailSchema } from "./core/auth/validation.cjs";
|
|
5
|
+
import { eventBus } from "./core/event-bus.cjs";
|
|
6
|
+
import { notificationService } from "./core/notifications/service.cjs";
|
|
7
|
+
import { CreateNotificationPayload, Notification, NotificationEvents } from "./core/notifications/types.cjs";
|
|
8
|
+
export { AuthResponse, AuthSession, CreateNotificationPayload, DatabaseSchema, EventHandler, ForgotPasswordInput, FullUser, LoginInput, Notification, NotificationEvents, PasskeysSetupInput, PasswordResetAuthSession, PasswordResetSession, RecoveryVerifyInput, RegisterInput, ResetPasswordInput, Session, SessionFlags, SystemEvent, TOTPSetupInput, TOTPVerifyInput, User, UserPermission, UserRole, UserSession, VerifyEmailInput, coreSchema, emailVerificationTable, eventBus, forgotPasswordSchema, loginSchema, notificationService, notificationTable, passkeysSetupSchema, passwordResetSessionTable, permissionsTable, recoveryCodeVerifySchema, registerSchema, relations, resetPasswordSchema, rolesTable, rolesToPermissionsTable, sessionTable, systemModulesTable, totpSetupSchema, totpVerifySchema, userTable, usersToPermissionsTable, usersToRolesTable, verifyEmailSchema };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DatabaseSchema, coreSchema, emailVerificationTable, notificationTable, passwordResetSessionTable, permissionsTable, relations, rolesTable, rolesToPermissionsTable, sessionTable, systemModulesTable, userTable, usersToPermissionsTable, usersToRolesTable } from "./server/database/schema.mjs";
|
|
2
|
+
import { EventHandler, SystemEvent, UserPermission, UserRole } from "./core/types.mjs";
|
|
3
|
+
import { AuthResponse, AuthSession, FullUser, PasswordResetAuthSession, PasswordResetSession, Session, SessionFlags, User, UserSession } from "./core/auth/types.mjs";
|
|
4
|
+
import { ForgotPasswordInput, LoginInput, PasskeysSetupInput, RecoveryVerifyInput, RegisterInput, ResetPasswordInput, TOTPSetupInput, TOTPVerifyInput, VerifyEmailInput, forgotPasswordSchema, loginSchema, passkeysSetupSchema, recoveryCodeVerifySchema, registerSchema, resetPasswordSchema, totpSetupSchema, totpVerifySchema, verifyEmailSchema } from "./core/auth/validation.mjs";
|
|
5
|
+
import { eventBus } from "./core/event-bus.mjs";
|
|
6
|
+
import { notificationService } from "./core/notifications/service.mjs";
|
|
7
|
+
import { CreateNotificationPayload, Notification, NotificationEvents } from "./core/notifications/types.mjs";
|
|
8
|
+
export { AuthResponse, AuthSession, CreateNotificationPayload, DatabaseSchema, EventHandler, ForgotPasswordInput, FullUser, LoginInput, Notification, NotificationEvents, PasskeysSetupInput, PasswordResetAuthSession, PasswordResetSession, RecoveryVerifyInput, RegisterInput, ResetPasswordInput, Session, SessionFlags, SystemEvent, TOTPSetupInput, TOTPVerifyInput, User, UserPermission, UserRole, UserSession, VerifyEmailInput, coreSchema, emailVerificationTable, eventBus, forgotPasswordSchema, loginSchema, notificationService, notificationTable, passkeysSetupSchema, passwordResetSessionTable, permissionsTable, recoveryCodeVerifySchema, registerSchema, relations, resetPasswordSchema, rolesTable, rolesToPermissionsTable, sessionTable, systemModulesTable, totpSetupSchema, totpVerifySchema, userTable, usersToPermissionsTable, usersToRolesTable, verifyEmailSchema };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { forgotPasswordSchema, loginSchema, passkeysSetupSchema, recoveryCodeVerifySchema, registerSchema, resetPasswordSchema, totpSetupSchema, totpVerifySchema, verifyEmailSchema } from "./core/auth/validation.mjs";
|
|
2
|
+
import { eventBus } from "./core/event-bus.mjs";
|
|
3
|
+
import { coreSchema, emailVerificationTable, notificationTable, passwordResetSessionTable, permissionsTable, relations, rolesTable, rolesToPermissionsTable, sessionTable, systemModulesTable, userTable, usersToPermissionsTable, usersToRolesTable } from "./server/database/schema.mjs";
|
|
4
|
+
import { notificationService } from "./core/notifications/service.mjs";
|
|
5
|
+
|
|
6
|
+
export { coreSchema, emailVerificationTable, eventBus, forgotPasswordSchema, loginSchema, notificationService, notificationTable, passkeysSetupSchema, passwordResetSessionTable, permissionsTable, recoveryCodeVerifySchema, registerSchema, relations, resetPasswordSchema, rolesTable, rolesToPermissionsTable, sessionTable, systemModulesTable, totpSetupSchema, totpVerifySchema, userTable, usersToPermissionsTable, usersToRolesTable, verifyEmailSchema };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_inject = require('../database/inject.cjs');
|
|
3
|
+
const require_schema = require('../database/schema.cjs');
|
|
4
|
+
let drizzle_orm = require("drizzle-orm");
|
|
5
|
+
|
|
6
|
+
//#region src/server/auth/email.ts
|
|
7
|
+
/**
|
|
8
|
+
* Validates the email format and length.
|
|
9
|
+
*/
|
|
10
|
+
function verifyEmailInput(email) {
|
|
11
|
+
return /^.+@.+\..+$/.test(email) && email.length < 256;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Checks if an email address is already in use.
|
|
15
|
+
* @returns True if the email is available, false otherwise.
|
|
16
|
+
*/
|
|
17
|
+
async function checkEmailAvailability(email) {
|
|
18
|
+
const [entries] = await require_inject.db.select({ count: (0, drizzle_orm.count)() }).from(require_schema.userTable).where((0, drizzle_orm.eq)(require_schema.userTable.email, email));
|
|
19
|
+
return entries.count === 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.checkEmailAvailability = checkEmailAvailability;
|
|
24
|
+
exports.verifyEmailInput = verifyEmailInput;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/server/auth/email.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Validates the email format and length.
|
|
4
|
+
*/
|
|
5
|
+
declare function verifyEmailInput(email: string): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Checks if an email address is already in use.
|
|
8
|
+
* @returns True if the email is available, false otherwise.
|
|
9
|
+
*/
|
|
10
|
+
declare function checkEmailAvailability(email: string): Promise<boolean>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { checkEmailAvailability, verifyEmailInput };
|
|
13
|
+
//# sourceMappingURL=email.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.d.cts","names":[],"sources":["../../../src/server/auth/email.ts"],"mappings":";;AAOA;;iBAAgB,gBAAA,CAAiB,KAAA;;;AAQjC;;iBAAsB,sBAAA,CAAuB,KAAA,WAAgB,OAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/server/auth/email.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Validates the email format and length.
|
|
4
|
+
*/
|
|
5
|
+
declare function verifyEmailInput(email: string): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Checks if an email address is already in use.
|
|
8
|
+
* @returns True if the email is available, false otherwise.
|
|
9
|
+
*/
|
|
10
|
+
declare function checkEmailAvailability(email: string): Promise<boolean>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { checkEmailAvailability, verifyEmailInput };
|
|
13
|
+
//# sourceMappingURL=email.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.d.mts","names":[],"sources":["../../../src/server/auth/email.ts"],"mappings":";;AAOA;;iBAAgB,gBAAA,CAAiB,KAAA;;;AAQjC;;iBAAsB,sBAAA,CAAuB,KAAA,WAAgB,OAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { db } from "../database/inject.mjs";
|
|
2
|
+
import { userTable } from "../database/schema.mjs";
|
|
3
|
+
import { count, eq } from "drizzle-orm";
|
|
4
|
+
|
|
5
|
+
//#region src/server/auth/email.ts
|
|
6
|
+
/**
|
|
7
|
+
* Validates the email format and length.
|
|
8
|
+
*/
|
|
9
|
+
function verifyEmailInput(email) {
|
|
10
|
+
return /^.+@.+\..+$/.test(email) && email.length < 256;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Checks if an email address is already in use.
|
|
14
|
+
* @returns True if the email is available, false otherwise.
|
|
15
|
+
*/
|
|
16
|
+
async function checkEmailAvailability(email) {
|
|
17
|
+
const [entries] = await db.select({ count: count() }).from(userTable).where(eq(userTable.email, email));
|
|
18
|
+
return entries.count === 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { checkEmailAvailability, verifyEmailInput };
|
|
23
|
+
//# sourceMappingURL=email.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.mjs","names":[],"sources":["../../../src/server/auth/email.ts"],"sourcesContent":["import { count, eq } from \"drizzle-orm\";\nimport { db } from \"../database/inject\";\nimport { userTable } from \"../database/schema\";\n\n/**\n * Validates the email format and length.\n */\nexport function verifyEmailInput(email: string): boolean {\n return /^.+@.+\\..+$/.test(email) && email.length < 256;\n}\n\n/**\n * Checks if an email address is already in use.\n * @returns True if the email is available, false otherwise.\n */\nexport async function checkEmailAvailability(email: string): Promise<boolean> {\n const [entries] = await db\n .select({ count: count() })\n .from(userTable)\n .where(eq(userTable.email, email));\n\n return entries.count === 0;\n}\n"],"mappings":";;;;;;;;AAOA,SAAgB,iBAAiB,OAAwB;AACvD,QAAO,cAAc,KAAK,MAAM,IAAI,MAAM,SAAS;;;;;;AAOrD,eAAsB,uBAAuB,OAAiC;CAC5E,MAAM,CAAC,WAAW,MAAM,GACrB,OAAO,EAAE,OAAO,OAAO,EAAE,CAAC,CAC1B,KAAK,UAAU,CACf,MAAM,GAAG,UAAU,OAAO,MAAM,CAAC;AAEpC,QAAO,QAAQ,UAAU"}
|