@tulip-systems/create-app 0.12.4 → 0.13.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/index.mjs +2866 -2949
- package/dist/index.mjs.map +1 -1
- package/dist/templates/basic/package.json +37 -38
- package/dist/templates/basic/src/app/layout.tsx +20 -10
- package/dist/templates/code/package.json +80 -72
- package/dist/templates/code/public/sw.js +35 -0
- package/dist/templates/code/src/app/admin/contacts/_components/grid.tsx +1 -1
- package/dist/templates/code/src/app/admin/customers/_config/columns-data.tsx +1 -1
- package/dist/templates/code/src/app/admin/employees/_config/columns-data.tsx +1 -1
- package/dist/templates/code/src/app/admin/history/[id]/layout.tsx +33 -0
- package/dist/templates/code/src/app/admin/history/[id]/loading.tsx +11 -0
- package/dist/templates/code/src/app/admin/history/[id]/page.tsx +30 -0
- package/dist/templates/code/src/app/admin/history/_components/diff.client.tsx +377 -0
- package/dist/templates/code/src/app/admin/history/_components/field-comparison.tsx +153 -0
- package/dist/templates/code/src/app/admin/history/_components/tables.tsx +47 -0
- package/dist/templates/code/src/app/admin/history/_components/toolbars.tsx +54 -0
- package/dist/templates/code/src/app/admin/history/_config/columns-data.tsx +61 -0
- package/dist/templates/code/src/app/admin/history/_config/filters.ts +46 -0
- package/dist/templates/code/src/app/admin/history/_config/sorting.ts +30 -0
- package/dist/templates/code/src/app/admin/history/_lib/helpers.ts +98 -0
- package/dist/templates/code/src/app/admin/history/_lib/router.ts +100 -0
- package/dist/templates/code/src/app/admin/history/_lib/schema.ts +45 -0
- package/dist/templates/code/src/app/admin/history/_lib/service.server.ts +30 -0
- package/dist/templates/code/src/app/admin/history/_lib/validators.ts +118 -0
- package/dist/templates/code/src/app/admin/initiatives/_config/columns-data.tsx +1 -1
- package/dist/templates/code/src/app/admin/notifications/_components/command-toggle-push.tsx +115 -0
- package/dist/templates/code/src/app/admin/notifications/_components/tables.tsx +37 -0
- package/dist/templates/code/src/app/admin/notifications/_components/toolbars.tsx +21 -0
- package/dist/templates/code/src/app/admin/notifications/_config/columns-data.tsx +64 -0
- package/dist/templates/code/src/app/admin/notifications/_config/commands.tsx +40 -0
- package/dist/templates/code/src/app/admin/notifications/_lib/listeners.server.ts +69 -0
- package/dist/templates/code/src/app/admin/notifications/_lib/push.server.ts +80 -0
- package/dist/templates/code/src/app/admin/notifications/_lib/router.ts +82 -0
- package/dist/templates/code/src/app/admin/notifications/_lib/schema.ts +49 -0
- package/dist/templates/code/src/app/admin/notifications/_lib/validators.ts +19 -0
- package/dist/templates/code/src/app/admin/notifications/layout.tsx +17 -0
- package/dist/templates/code/src/app/admin/notifications/loading.tsx +9 -0
- package/dist/templates/code/src/app/admin/notifications/page.tsx +28 -0
- package/dist/templates/code/src/app/admin/projects/[id]/(default)/page.tsx +1 -1
- package/dist/templates/code/src/app/admin/projects/[id]/timeline/page.tsx +1 -1
- package/dist/templates/code/src/app/admin/projects/_config/columns-data.tsx +1 -1
- package/dist/templates/code/src/app/admin/projects/_lib/events.ts +64 -0
- package/dist/templates/code/src/app/admin/projects/_lib/listeners.server.ts +82 -0
- package/dist/templates/code/src/app/admin/projects/_lib/router.ts +145 -20
- package/dist/templates/code/src/app/admin/projects/timeline/page.tsx +1 -1
- package/dist/templates/code/src/app/admin/prospects/_config/columns-data.tsx +1 -1
- package/dist/templates/code/src/app/admin/queue/_components/create-command.tsx +97 -0
- package/dist/templates/code/src/app/admin/queue/_components/tables.tsx +37 -0
- package/dist/templates/code/src/app/admin/queue/_components/toolbars.tsx +16 -0
- package/dist/templates/code/src/app/admin/queue/_config/columns-data.tsx +44 -0
- package/dist/templates/code/src/app/admin/queue/_config/commands.tsx +39 -0
- package/dist/templates/code/src/app/admin/queue/_lib/queue.ts +27 -0
- package/dist/templates/code/src/app/admin/queue/_lib/router.ts +33 -0
- package/dist/templates/code/src/app/admin/queue/_lib/schema.ts +12 -0
- package/dist/templates/code/src/app/admin/queue/_lib/validators.ts +15 -0
- package/dist/templates/code/src/app/admin/quotations/_config/columns-data.tsx +1 -1
- package/dist/templates/code/src/app/admin/quotations/_config/commands.tsx +1 -1
- package/dist/templates/code/src/app/admin/settings/history/layout.tsx +6 -0
- package/dist/templates/code/src/app/admin/settings/history/loading.tsx +5 -0
- package/dist/templates/code/src/app/admin/settings/history/page.tsx +13 -0
- package/dist/templates/code/src/app/admin/settings/layout.tsx +11 -0
- package/dist/templates/code/src/app/admin/settings/queue/loading.tsx +9 -0
- package/dist/templates/code/src/app/admin/settings/queue/page.tsx +21 -0
- package/dist/templates/code/src/app/admin/tasks/_components/domains-tabs-grid.tsx +1 -1
- package/dist/templates/code/src/app/admin/tasks/_config/columns-data.tsx +1 -1
- package/dist/templates/code/src/app/admin/tasks/_config/columns-inline.tsx +1 -1
- package/dist/templates/code/src/app/admin/tasks/_lib/events.ts +40 -0
- package/dist/templates/code/src/app/admin/tasks/_lib/listeners.server.ts +46 -0
- package/dist/templates/code/src/app/admin/tasks/_lib/router.ts +222 -90
- package/dist/templates/code/src/app/admin/time/_config/columns-data.tsx +1 -1
- package/dist/templates/code/src/app/admin/time/_config/columns-inline.tsx +1 -1
- package/dist/templates/code/src/app/api/[transport]/route.ts +31 -21
- package/dist/templates/code/src/app/api/queue/dispatch/route.ts +4 -0
- package/dist/templates/code/src/app/auth/forget-password/page.tsx +1 -1
- package/dist/templates/code/src/app/auth/layout.tsx +1 -1
- package/dist/templates/code/src/app/auth/reset-password/page.tsx +1 -1
- package/dist/templates/code/src/app/layout.tsx +25 -13
- package/dist/templates/code/src/env.ts +12 -0
- package/dist/templates/code/src/lib/config/paths.tsx +8 -0
- package/dist/templates/code/src/server/auth/constants.ts +1 -1
- package/dist/templates/code/src/server/auth/init.ts +12 -5
- package/dist/templates/code/src/server/auth/permissions.ts +3 -0
- package/dist/templates/code/src/server/auth/schema.ts +100 -1
- package/dist/templates/code/src/server/db/schema.ts +3 -0
- package/dist/templates/code/src/server/events/handlers.ts +17 -0
- package/dist/templates/code/src/server/events/init.ts +18 -0
- package/dist/templates/code/src/server/events/listeners.ts +17 -0
- package/dist/templates/code/src/server/queue/handlers.ts +5 -0
- package/dist/templates/code/src/server/queue/init.ts +16 -0
- package/dist/templates/code/src/server/router/router.ts +13 -0
- package/dist/templates/spark/package.json +64 -65
- package/dist/templates/spark/src/app/admin/assignments/[id]/(default)/@dashboard/page.tsx +1 -1
- package/dist/templates/spark/src/app/admin/assignments/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/admin/companies/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/admin/contacts/_components/grid.tsx +1 -1
- package/dist/templates/spark/src/app/admin/customers/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/admin/drive/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/admin/emails/_components/send-email.tsx +1 -1
- package/dist/templates/spark/src/app/admin/emails/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/admin/employees/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/admin/executions/[id]/@dashboard/page.tsx +1 -1
- package/dist/templates/spark/src/app/admin/executions/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/admin/products/[id]/(preview)/page.tsx +1 -1
- package/dist/templates/spark/src/app/admin/products/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/admin/projects/[id]/(dashboard)/page.tsx +1 -1
- package/dist/templates/spark/src/app/admin/projects/[id]/messages/page.tsx +1 -1
- package/dist/templates/spark/src/app/admin/projects/[id]/statistics/page.tsx +1 -1
- package/dist/templates/spark/src/app/admin/projects/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/admin/purchase-order-items/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/admin/purchase-order-items/_config/columns-inline.tsx +1 -1
- package/dist/templates/spark/src/app/admin/purchase-order-items/_config/commands.tsx +1 -1
- package/dist/templates/spark/src/app/admin/purchase-orders/[id]/(default)/@dashboard/page.tsx +1 -1
- package/dist/templates/spark/src/app/admin/purchase-orders/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/admin/quotation-items/_config/commands.tsx +1 -1
- package/dist/templates/spark/src/app/admin/quotations/[id]/(default)/@dashboard/page.tsx +1 -1
- package/dist/templates/spark/src/app/admin/quotations/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/admin/run-tasks/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/admin/runs/[id]/@dashboard/page.tsx +1 -1
- package/dist/templates/spark/src/app/admin/runs/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/admin/sales-invoices/[id]/@dashboard/page.tsx +1 -1
- package/dist/templates/spark/src/app/admin/sales-invoices/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/admin/sales-order-executions/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/admin/sales-order-executions/_config/columns-inline.tsx +1 -1
- package/dist/templates/spark/src/app/admin/sales-order-executions/_config/commands.tsx +1 -1
- package/dist/templates/spark/src/app/admin/sales-order-items/_config/commands.tsx +1 -1
- package/dist/templates/spark/src/app/admin/sales-orders/[id]/(default)/@dashboard/page.tsx +1 -1
- package/dist/templates/spark/src/app/admin/sales-orders/[id]/(default)/layout.tsx +1 -1
- package/dist/templates/spark/src/app/admin/sales-orders/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/admin/schedule/_components/schedule-card.tsx +1 -1
- package/dist/templates/spark/src/app/admin/schedule/_components/schedule-month-view.tsx +1 -1
- package/dist/templates/spark/src/app/admin/suppliers/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/admin/tasks/_components/subproject-selector.tsx +1 -1
- package/dist/templates/spark/src/app/admin/tasks/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/admin/tasks/_config/columns-inline.tsx +1 -1
- package/dist/templates/spark/src/app/admin/tasks/_config/commands.tsx +1 -1
- package/dist/templates/spark/src/app/admin/technical-sheets/[id]/page.tsx +1 -1
- package/dist/templates/spark/src/app/admin/technical-sheets/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/admin/technical-sheets/_config/commands.tsx +1 -1
- package/dist/templates/spark/src/app/admin/templates/_config/columns-data.tsx +1 -1
- package/dist/templates/spark/src/app/auth/layout.tsx +1 -1
- package/dist/templates/spark/src/app/layout.tsx +25 -10
- package/dist/templates/spark/src/server/auth/init.ts +1 -0
- package/package.json +6 -6
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
AuthLayoutImageFooter,
|
|
7
7
|
AuthLayoutImageHeader,
|
|
8
8
|
} from "@tulip-systems/auth/components";
|
|
9
|
-
import Link from "
|
|
9
|
+
import { Link } from "@tulip-systems/core/navigation";
|
|
10
10
|
import type { PropsWithChildren } from "react";
|
|
11
11
|
import { config } from "@/lib/config/base";
|
|
12
12
|
import { authClient } from "@/server/auth/client";
|
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
ResetPasswordTitle,
|
|
11
11
|
ResetPasswordView,
|
|
12
12
|
} from "@tulip-systems/auth/components/client";
|
|
13
|
+
import { Link } from "@tulip-systems/core/navigation";
|
|
13
14
|
import type { Metadata } from "next";
|
|
14
|
-
import Link from "next/link";
|
|
15
15
|
import { Suspense } from "react";
|
|
16
16
|
|
|
17
17
|
export const metadata: Metadata = {
|
|
@@ -2,26 +2,38 @@ import "./globals.css";
|
|
|
2
2
|
import "../server/router/register";
|
|
3
3
|
|
|
4
4
|
import { ColorThemeProvider, Providers } from "@tulip-systems/app/components/client";
|
|
5
|
-
import {
|
|
6
|
-
ColorThemeScript,
|
|
7
|
-
generateRootLayoutMetadata,
|
|
8
|
-
RootLayout,
|
|
9
|
-
} from "@tulip-systems/app/components/server";
|
|
5
|
+
import { registerFonts, rootLayoutViewport } from "@tulip-systems/app/components/server";
|
|
10
6
|
import { DriveViewScript } from "@tulip-systems/drive/server";
|
|
7
|
+
import { cn } from "@tulip-systems/ui/cn";
|
|
8
|
+
import type { Metadata } from "next";
|
|
11
9
|
import type { PropsWithChildren } from "react";
|
|
12
10
|
import { config } from "@/lib/config/base";
|
|
13
11
|
|
|
14
|
-
export const
|
|
12
|
+
export const viewport = rootLayoutViewport;
|
|
13
|
+
|
|
14
|
+
export const metadata: Metadata = {
|
|
15
|
+
description: "Developed by NewCode",
|
|
16
|
+
appleWebApp: {
|
|
17
|
+
capable: true,
|
|
18
|
+
statusBarStyle: "black-translucent",
|
|
19
|
+
title: config.general.name,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const colorTheme = "sage";
|
|
15
24
|
|
|
16
25
|
export default function Layout({ children }: PropsWithChildren) {
|
|
17
26
|
return (
|
|
18
|
-
<
|
|
19
|
-
<
|
|
20
|
-
|
|
27
|
+
<html lang="nl" suppressHydrationWarning data-theme={colorTheme}>
|
|
28
|
+
<title>{config.general.name}</title>
|
|
29
|
+
|
|
30
|
+
<body className={cn("bg-background font-sans antialiased", registerFonts())}>
|
|
31
|
+
<DriveViewScript />
|
|
21
32
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
33
|
+
<ColorThemeProvider theme={colorTheme}>
|
|
34
|
+
<Providers>{children}</Providers>
|
|
35
|
+
</ColorThemeProvider>
|
|
36
|
+
</body>
|
|
37
|
+
</html>
|
|
26
38
|
);
|
|
27
39
|
}
|
|
@@ -11,6 +11,16 @@ export const env = createEnv({
|
|
|
11
11
|
S3_ENDPOINT: z.string().min(1),
|
|
12
12
|
S3_ACCESS_KEY_ID: z.string().min(1),
|
|
13
13
|
S3_SECRET_ACCESS_KEY: z.string().min(1),
|
|
14
|
+
QSTASH_URL: z.string().min(1),
|
|
15
|
+
QSTASH_TOKEN: z.string().min(1),
|
|
16
|
+
QSTASH_CURRENT_SIGNING_KEY: z.string().min(1),
|
|
17
|
+
QSTASH_NEXT_SIGNING_KEY: z.string().min(1),
|
|
18
|
+
QSTASH_DEV: z
|
|
19
|
+
.enum(["true", "false"])
|
|
20
|
+
.transform((value) => value === "true")
|
|
21
|
+
.optional(),
|
|
22
|
+
WEB_PUSH_PRIVATE_KEY: z.string().min(1).optional(),
|
|
23
|
+
WEB_PUSH_SUBJECT: z.string().min(1).optional(),
|
|
14
24
|
GOOGLE_SERVICE_ACCOUNT_EMAIL: z.string().min(1),
|
|
15
25
|
GOOGLE_SERVICE_ACCOUNT_PRIVATE_KEY: z
|
|
16
26
|
.string()
|
|
@@ -19,8 +29,10 @@ export const env = createEnv({
|
|
|
19
29
|
},
|
|
20
30
|
client: {
|
|
21
31
|
NEXT_PUBLIC_HOST: z.string().min(1),
|
|
32
|
+
NEXT_PUBLIC_WEB_PUSH_PUBLIC_KEY: z.string().min(1).optional(),
|
|
22
33
|
},
|
|
23
34
|
experimental__runtimeEnv: {
|
|
24
35
|
NEXT_PUBLIC_HOST: process.env.NEXT_PUBLIC_HOST ?? process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL,
|
|
36
|
+
NEXT_PUBLIC_WEB_PUSH_PUBLIC_KEY: process.env.NEXT_PUBLIC_WEB_PUSH_PUBLIC_KEY,
|
|
25
37
|
},
|
|
26
38
|
});
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
} from "@tulip-systems/app/components/client";
|
|
12
12
|
import { Sidebar, SidebarContent, SidebarHeader, SidebarRail } from "@tulip-systems/ui/sidebar";
|
|
13
13
|
import {
|
|
14
|
+
BellIcon,
|
|
14
15
|
BotIcon,
|
|
15
16
|
FoldersIcon,
|
|
16
17
|
HomeIcon,
|
|
@@ -48,6 +49,13 @@ export function AdminSidebar() {
|
|
|
48
49
|
</PathLink>
|
|
49
50
|
</Path>
|
|
50
51
|
|
|
52
|
+
<Path segment="notifications">
|
|
53
|
+
<PathLink href="/admin/notifications">
|
|
54
|
+
<BellIcon />
|
|
55
|
+
Notifications
|
|
56
|
+
</PathLink>
|
|
57
|
+
</Path>
|
|
58
|
+
|
|
51
59
|
<Path permission={{ drive: ["view"] }} segment="drive">
|
|
52
60
|
<PathLink href="/admin/drive">
|
|
53
61
|
<FoldersIcon />
|
|
@@ -10,7 +10,7 @@ export const OAUTH_SCOPES = ["openid", "profile", "email", "offline_access", "mc
|
|
|
10
10
|
/**
|
|
11
11
|
* This constant defines the audience URLs for the OAuth protected resource.
|
|
12
12
|
*/
|
|
13
|
-
export const
|
|
13
|
+
export const OAUTH_AUDIENCE = url("/api/mcp");
|
|
14
14
|
/**
|
|
15
15
|
* This constant defines the issuer URLs for the OAuth authorization server.
|
|
16
16
|
*/
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cimd } from "@better-auth/cimd";
|
|
2
|
+
import { fetchClientMetadataResource } from "@better-auth/cimd/node";
|
|
3
|
+
import { mcp } from "@better-auth/mcp";
|
|
2
4
|
import { passkey } from "@better-auth/passkey";
|
|
3
5
|
import { authAdditionalFields, authCookiePrefix } from "@tulip-systems/auth";
|
|
4
6
|
import { ForgetPasswordEmail } from "@tulip-systems/auth/react-email";
|
|
@@ -9,7 +11,7 @@ import { admin, emailOTP, jwt } from "better-auth/plugins";
|
|
|
9
11
|
import { config } from "@/lib/config/base";
|
|
10
12
|
import { db } from "../db/init";
|
|
11
13
|
import { email } from "../emails/init";
|
|
12
|
-
import {
|
|
14
|
+
import { OAUTH_AUDIENCE, OAUTH_SCOPES } from "./constants";
|
|
13
15
|
import { ac, roles } from "./permissions";
|
|
14
16
|
|
|
15
17
|
export const auth = betterAuth({
|
|
@@ -23,7 +25,8 @@ export const auth = betterAuth({
|
|
|
23
25
|
"*.tulip.systems",
|
|
24
26
|
"*.vercel.app",
|
|
25
27
|
"*.localhost:*",
|
|
26
|
-
"localhost
|
|
28
|
+
"*.localhost",
|
|
29
|
+
"localhost:*",
|
|
27
30
|
],
|
|
28
31
|
},
|
|
29
32
|
database: drizzleAdapter(db, {
|
|
@@ -63,15 +66,19 @@ export const auth = betterAuth({
|
|
|
63
66
|
},
|
|
64
67
|
}),
|
|
65
68
|
jwt(),
|
|
66
|
-
|
|
69
|
+
mcp({
|
|
67
70
|
loginPage: "/auth/login",
|
|
68
71
|
consentPage: "/auth/consent",
|
|
72
|
+
resource: OAUTH_AUDIENCE,
|
|
69
73
|
scopes: [...OAUTH_SCOPES],
|
|
70
|
-
validAudiences: [...OAUTH_AUDIENCES],
|
|
71
74
|
allowDynamicClientRegistration: true,
|
|
72
75
|
allowUnauthenticatedClientRegistration: true,
|
|
73
76
|
clientRegistrationDefaultScopes: [...OAUTH_SCOPES],
|
|
74
77
|
}),
|
|
78
|
+
cimd({
|
|
79
|
+
fetchClientMetadataResource,
|
|
80
|
+
metadataProfile: "mcp-2026-07-28",
|
|
81
|
+
}),
|
|
75
82
|
],
|
|
76
83
|
});
|
|
77
84
|
|
|
@@ -4,6 +4,7 @@ import { adminAc, createAccessControl, createStatements } from "@tulip-systems/a
|
|
|
4
4
|
* Statements
|
|
5
5
|
*/
|
|
6
6
|
const statement = createStatements({
|
|
7
|
+
history: ["view"],
|
|
7
8
|
developer: ["debug"],
|
|
8
9
|
dashboard: ["view.budget"],
|
|
9
10
|
drive: ["view", "create", "update", "archive", "delete"],
|
|
@@ -27,6 +28,7 @@ export const ac = createAccessControl(statement);
|
|
|
27
28
|
* Admin role
|
|
28
29
|
*/
|
|
29
30
|
const developer = ac.newRole({
|
|
31
|
+
history: ["view"],
|
|
30
32
|
developer: ["debug"],
|
|
31
33
|
dashboard: ["view.budget"],
|
|
32
34
|
drive: ["view", "create", "update", "archive", "delete"],
|
|
@@ -46,6 +48,7 @@ const developer = ac.newRole({
|
|
|
46
48
|
* Owner role
|
|
47
49
|
*/
|
|
48
50
|
const admin = ac.newRole({
|
|
51
|
+
history: ["view"],
|
|
49
52
|
dashboard: ["view.budget"],
|
|
50
53
|
drive: ["view", "create", "update", "archive", "delete"],
|
|
51
54
|
prospect: ["view", "create", "update", "archive", "delete"],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { relations, type SQL, sql } from "drizzle-orm";
|
|
2
|
-
import { index, pgTable } from "drizzle-orm/pg-core";
|
|
2
|
+
import { index, pgTable, uniqueIndex } from "drizzle-orm/pg-core";
|
|
3
3
|
import { baseColumns } from "@/server/db/helpers";
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -130,6 +130,8 @@ const jwkss = pgTable("jwkss", (t) => ({
|
|
|
130
130
|
publicKey: t.text().notNull(),
|
|
131
131
|
privateKey: t.text().notNull(),
|
|
132
132
|
expiresAt: t.timestamp(),
|
|
133
|
+
alg: t.text(),
|
|
134
|
+
crv: t.text(),
|
|
133
135
|
}));
|
|
134
136
|
|
|
135
137
|
/**
|
|
@@ -141,11 +143,13 @@ const oauthClients = pgTable(
|
|
|
141
143
|
...baseColumns,
|
|
142
144
|
clientId: t.text().notNull().unique(),
|
|
143
145
|
clientSecret: t.text(),
|
|
146
|
+
clientDiscoveryId: t.text(),
|
|
144
147
|
disabled: t.boolean().default(false),
|
|
145
148
|
skipConsent: t.boolean(),
|
|
146
149
|
enableEndSession: t.boolean(),
|
|
147
150
|
subjectType: t.text(),
|
|
148
151
|
scopes: t.text().array(),
|
|
152
|
+
clientCredentialsScopes: t.text().array().default([]),
|
|
149
153
|
userId: t.uuid().references(() => users.id, { onDelete: "cascade" }),
|
|
150
154
|
createdAt: t.timestamp(),
|
|
151
155
|
updatedAt: t.timestamp(),
|
|
@@ -160,12 +164,18 @@ const oauthClients = pgTable(
|
|
|
160
164
|
softwareStatement: t.text(),
|
|
161
165
|
redirectUris: t.text().array().notNull(),
|
|
162
166
|
postLogoutRedirectUris: t.text().array(),
|
|
167
|
+
backchannelLogoutUri: t.text(),
|
|
168
|
+
backchannelLogoutSessionRequired: t.boolean(),
|
|
163
169
|
tokenEndpointAuthMethod: t.text(),
|
|
170
|
+
applicationType: t.text(),
|
|
171
|
+
jwks: t.text(),
|
|
172
|
+
jwksUri: t.text(),
|
|
164
173
|
grantTypes: t.text().array(),
|
|
165
174
|
responseTypes: t.text().array(),
|
|
166
175
|
public: t.boolean(),
|
|
167
176
|
type: t.text(),
|
|
168
177
|
requirePKCE: t.boolean(),
|
|
178
|
+
dpopBoundAccessTokens: t.boolean().default(false),
|
|
169
179
|
referenceId: t.text(),
|
|
170
180
|
metadata: t.jsonb(),
|
|
171
181
|
}),
|
|
@@ -180,6 +190,68 @@ const oauthClientsRelations = relations(oauthClients, ({ one, many }) => ({
|
|
|
180
190
|
oauthRefreshTokens: many(oauthRefreshTokens),
|
|
181
191
|
oauthAccessTokens: many(oauthAccessTokens),
|
|
182
192
|
oauthConsents: many(oauthConsents),
|
|
193
|
+
oauthClientResources: many(oauthClientResources),
|
|
194
|
+
}));
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* The oauthResources table stores protected resource identifiers and per-resource token policy.
|
|
198
|
+
*/
|
|
199
|
+
const oauthResources = pgTable("oauth_resources", (t) => ({
|
|
200
|
+
...baseColumns,
|
|
201
|
+
identifier: t.text().notNull().unique(),
|
|
202
|
+
name: t.text().notNull(),
|
|
203
|
+
accessTokenTtl: t.integer(),
|
|
204
|
+
refreshTokenTtl: t.integer(),
|
|
205
|
+
signingAlgorithm: t.text(),
|
|
206
|
+
signingKeyId: t.text(),
|
|
207
|
+
allowedScopes: t.text().array(),
|
|
208
|
+
customClaims: t.jsonb(),
|
|
209
|
+
dpopBoundAccessTokensRequired: t.boolean().default(false),
|
|
210
|
+
disabled: t.boolean().default(false),
|
|
211
|
+
policyVersion: t.integer().default(1),
|
|
212
|
+
metadata: t.jsonb(),
|
|
213
|
+
}));
|
|
214
|
+
|
|
215
|
+
const oauthResourcesRelations = relations(oauthResources, ({ many }) => ({
|
|
216
|
+
oauthClientResources: many(oauthClientResources),
|
|
217
|
+
}));
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* The oauthClientResources table links OAuth clients to protected resources.
|
|
221
|
+
*/
|
|
222
|
+
const oauthClientResources = pgTable(
|
|
223
|
+
"oauth_client_resources",
|
|
224
|
+
(t) => ({
|
|
225
|
+
...baseColumns,
|
|
226
|
+
clientId: t
|
|
227
|
+
.text()
|
|
228
|
+
.notNull()
|
|
229
|
+
.references(() => oauthClients.clientId, { onDelete: "cascade" }),
|
|
230
|
+
resourceId: t
|
|
231
|
+
.text()
|
|
232
|
+
.notNull()
|
|
233
|
+
.references(() => oauthResources.identifier, { onDelete: "cascade" }),
|
|
234
|
+
metadata: t.jsonb(),
|
|
235
|
+
}),
|
|
236
|
+
(table) => [
|
|
237
|
+
index("oauthClientResources_clientId_idx").on(table.clientId),
|
|
238
|
+
index("oauthClientResources_resourceId_idx").on(table.resourceId),
|
|
239
|
+
uniqueIndex("oauthClientResources_clientId_resourceId_idx").on(
|
|
240
|
+
table.clientId,
|
|
241
|
+
table.resourceId,
|
|
242
|
+
),
|
|
243
|
+
],
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
const oauthClientResourcesRelations = relations(oauthClientResources, ({ one }) => ({
|
|
247
|
+
oauthClients: one(oauthClients, {
|
|
248
|
+
fields: [oauthClientResources.clientId],
|
|
249
|
+
references: [oauthClients.clientId],
|
|
250
|
+
}),
|
|
251
|
+
oauthResources: one(oauthResources, {
|
|
252
|
+
fields: [oauthClientResources.resourceId],
|
|
253
|
+
references: [oauthResources.identifier],
|
|
254
|
+
}),
|
|
183
255
|
}));
|
|
184
256
|
|
|
185
257
|
/**
|
|
@@ -200,9 +272,16 @@ const oauthRefreshTokens = pgTable(
|
|
|
200
272
|
.notNull()
|
|
201
273
|
.references(() => users.id, { onDelete: "cascade" }),
|
|
202
274
|
referenceId: t.text(),
|
|
275
|
+
authorizationCodeId: t.text(),
|
|
276
|
+
resources: t.text().array(),
|
|
277
|
+
requestedUserInfoClaims: t.text().array(),
|
|
203
278
|
expiresAt: t.timestamp().notNull(),
|
|
204
279
|
revoked: t.timestamp(),
|
|
280
|
+
rotatedAt: t.timestamp(),
|
|
281
|
+
rotationReplayResponse: t.text(),
|
|
282
|
+
rotationReplayExpiresAt: t.timestamp(),
|
|
205
283
|
authTime: t.timestamp(),
|
|
284
|
+
confirmation: t.jsonb(),
|
|
206
285
|
scopes: t.text().array().notNull(),
|
|
207
286
|
}),
|
|
208
287
|
(table) => [
|
|
@@ -243,8 +322,13 @@ const oauthAccessTokens = pgTable(
|
|
|
243
322
|
sessionId: t.uuid().references(() => sessions.id, { onDelete: "set null" }),
|
|
244
323
|
userId: t.uuid().references(() => users.id, { onDelete: "cascade" }),
|
|
245
324
|
referenceId: t.text(),
|
|
325
|
+
authorizationCodeId: t.text(),
|
|
326
|
+
resources: t.text().array(),
|
|
327
|
+
requestedUserInfoClaims: t.text().array(),
|
|
246
328
|
refreshId: t.uuid().references(() => oauthRefreshTokens.id, { onDelete: "cascade" }),
|
|
247
329
|
expiresAt: t.timestamp().notNull(),
|
|
330
|
+
revoked: t.timestamp(),
|
|
331
|
+
confirmation: t.jsonb(),
|
|
248
332
|
scopes: t.text().array().notNull(),
|
|
249
333
|
}),
|
|
250
334
|
(table) => [
|
|
@@ -286,6 +370,8 @@ const oauthConsents = pgTable(
|
|
|
286
370
|
.references(() => oauthClients.clientId, { onDelete: "cascade" }),
|
|
287
371
|
userId: t.uuid().references(() => users.id, { onDelete: "cascade" }),
|
|
288
372
|
referenceId: t.text(),
|
|
373
|
+
resources: t.text().array(),
|
|
374
|
+
requestedUserInfoClaims: t.text().array(),
|
|
289
375
|
scopes: t.text().array().notNull(),
|
|
290
376
|
}),
|
|
291
377
|
(table) => [
|
|
@@ -305,6 +391,14 @@ const oauthConsentsRelations = relations(oauthConsents, ({ one }) => ({
|
|
|
305
391
|
}),
|
|
306
392
|
}));
|
|
307
393
|
|
|
394
|
+
/**
|
|
395
|
+
* The oauthClientAssertions table stores used client assertion identifiers until they expire.
|
|
396
|
+
*/
|
|
397
|
+
const oauthClientAssertions = pgTable("oauth_client_assertions", (t) => ({
|
|
398
|
+
...baseColumns,
|
|
399
|
+
expiresAt: t.timestamp().notNull(),
|
|
400
|
+
}));
|
|
401
|
+
|
|
308
402
|
/**
|
|
309
403
|
* Exports
|
|
310
404
|
*/
|
|
@@ -312,10 +406,15 @@ export {
|
|
|
312
406
|
jwkss,
|
|
313
407
|
oauthAccessTokens,
|
|
314
408
|
oauthAccessTokensRelations,
|
|
409
|
+
oauthClientAssertions,
|
|
410
|
+
oauthClientResources,
|
|
411
|
+
oauthClientResourcesRelations,
|
|
315
412
|
oauthClients,
|
|
316
413
|
oauthClientsRelations,
|
|
317
414
|
oauthConsents,
|
|
318
415
|
oauthConsentsRelations,
|
|
319
416
|
oauthRefreshTokens,
|
|
320
417
|
oauthRefreshTokensRelations,
|
|
418
|
+
oauthResources,
|
|
419
|
+
oauthResourcesRelations,
|
|
321
420
|
};
|
|
@@ -12,8 +12,11 @@ export * from "@/app/admin/customers/_lib/schema";
|
|
|
12
12
|
export * from "@/app/admin/domains/_lib/schema";
|
|
13
13
|
export * from "@/app/admin/employees/_lib/schema";
|
|
14
14
|
export * from "@/app/admin/initiatives/_lib/schema";
|
|
15
|
+
export * from "@/app/admin/notifications/_lib/schema";
|
|
15
16
|
export * from "@/app/admin/projects/_lib/schema";
|
|
17
|
+
export * from "@/app/admin/queue/_lib/schema";
|
|
16
18
|
export * from "@/app/admin/quotations/_lib/schema";
|
|
17
19
|
export * from "@/app/admin/tasks/_lib/schema";
|
|
18
20
|
export * from "@/app/admin/time/_lib/schema";
|
|
19
21
|
export * from "@/app/admin/prospects/_lib/schema";
|
|
22
|
+
export * from "@/app/admin/history/_lib/schema";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "server-cli-only";
|
|
2
|
+
|
|
3
|
+
import { createEventDispatchHandler, defineEventDispatchTask } from "@tulip-systems/events/queue";
|
|
4
|
+
import { appEventListeners } from "./listeners";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Event dispatch task for the application.
|
|
8
|
+
*/
|
|
9
|
+
export const eventDispatchTask = defineEventDispatchTask("events.dispatch");
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Event dispatch task handler for the application.
|
|
13
|
+
*/
|
|
14
|
+
export const eventDispatchTaskHandler = eventDispatchTask.handle(
|
|
15
|
+
"dispatch-event-listener",
|
|
16
|
+
createEventDispatchHandler({ listeners: appEventListeners }),
|
|
17
|
+
);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import "server-cli-only";
|
|
2
|
+
|
|
3
|
+
import { queueEventAdapter } from "@tulip-systems/events/queue";
|
|
4
|
+
import { EventBus } from "@tulip-systems/events/server";
|
|
5
|
+
import { queue } from "@/server/queue/init";
|
|
6
|
+
import { eventDispatchTask } from "./handlers";
|
|
7
|
+
import { appEventListeners } from "./listeners";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Initializes the event bus for the application.
|
|
11
|
+
*/
|
|
12
|
+
export const events = EventBus.init({
|
|
13
|
+
listeners: appEventListeners,
|
|
14
|
+
adapter: queueEventAdapter({
|
|
15
|
+
queue,
|
|
16
|
+
task: eventDispatchTask,
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "server-cli-only";
|
|
2
|
+
|
|
3
|
+
import { createEventListeners } from "@tulip-systems/events";
|
|
4
|
+
import { notificationEventListeners } from "@/app/admin/notifications/_lib/listeners.server";
|
|
5
|
+
import { projectHistoryEventListeners } from "@/app/admin/projects/_lib/listeners.server";
|
|
6
|
+
import { taskHistoryEventListeners } from "@/app/admin/tasks/_lib/listeners.server";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Event listeners
|
|
10
|
+
*/
|
|
11
|
+
export const appEventListeners = createEventListeners({
|
|
12
|
+
notifications: notificationEventListeners,
|
|
13
|
+
history: {
|
|
14
|
+
...projectHistoryEventListeners,
|
|
15
|
+
...taskHistoryEventListeners,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createQueueHandlers } from "@tulip-systems/queue";
|
|
2
|
+
import { queueLogTaskHandler } from "@/app/admin/queue/_lib/queue";
|
|
3
|
+
import { eventDispatchTaskHandler } from "@/server/events/handlers";
|
|
4
|
+
|
|
5
|
+
export const queueHandlers = createQueueHandlers([queueLogTaskHandler, eventDispatchTaskHandler]);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { url } from "@tulip-systems/core";
|
|
2
|
+
import { qstashAdapter } from "@tulip-systems/queue/qstash";
|
|
3
|
+
import { Queue } from "@tulip-systems/queue/server";
|
|
4
|
+
import { env } from "@/env";
|
|
5
|
+
|
|
6
|
+
export const queue = Queue.init({
|
|
7
|
+
adapter: qstashAdapter({
|
|
8
|
+
baseUrl: env.QSTASH_URL,
|
|
9
|
+
token: env.QSTASH_TOKEN,
|
|
10
|
+
endpoint: url("/api/queue/dispatch"),
|
|
11
|
+
currentSigningKey: env.QSTASH_CURRENT_SIGNING_KEY,
|
|
12
|
+
nextSigningKey: env.QSTASH_NEXT_SIGNING_KEY,
|
|
13
|
+
label: "tulip-demo-code",
|
|
14
|
+
devMode: env.QSTASH_DEV,
|
|
15
|
+
}),
|
|
16
|
+
});
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { type InferRouterInputs, type InferRouterOutputs, lazy } from "@orpc/server";
|
|
2
2
|
|
|
3
3
|
export const appRouter = {
|
|
4
|
+
history: lazy(() =>
|
|
5
|
+
import("@/app/admin/history/_lib/router").then((module) => ({ default: module.historyRouter })),
|
|
6
|
+
),
|
|
4
7
|
assistant: lazy(() =>
|
|
5
8
|
import("@/app/admin/assistant/_lib/router").then((module) => ({
|
|
6
9
|
default: module.assistantRouter,
|
|
@@ -41,6 +44,16 @@ export const appRouter = {
|
|
|
41
44
|
default: module.projectsRouter,
|
|
42
45
|
})),
|
|
43
46
|
),
|
|
47
|
+
notifications: lazy(() =>
|
|
48
|
+
import("@/app/admin/notifications/_lib/router").then((module) => ({
|
|
49
|
+
default: module.notificationsRouter,
|
|
50
|
+
})),
|
|
51
|
+
),
|
|
52
|
+
queue: lazy(() =>
|
|
53
|
+
import("@/app/admin/queue/_lib/router").then((module) => ({
|
|
54
|
+
default: module.queueRouter,
|
|
55
|
+
})),
|
|
56
|
+
),
|
|
44
57
|
timeEntries: lazy(() =>
|
|
45
58
|
import("@/app/admin/time/_lib/router").then((module) => ({
|
|
46
59
|
default: module.timeEntriesRouter,
|