@appconda/nextjs 1.0.94 → 1.0.95
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/actions/actionClient.d.ts +2 -10
- package/dist/actions/actionClient.js +49 -33
- package/dist/modules/account/actions.d.ts +1 -25
- package/dist/modules/agent/action.d.ts +5 -53
- package/dist/modules/agent/action.js +5 -5
- package/dist/modules/ai/node/actions.d.ts +1 -4
- package/dist/modules/ai/node/actions.js +1 -1
- package/dist/modules/tenant/actions.d.ts +3 -45
- package/dist/modules/tenant/actions.js +3 -3
- package/dist/modules/waitlist/action.d.ts +6 -69
- package/dist/modules/waitlist/action.js +6 -6
- package/package.json +1 -1
- package/src/actions/actionClient.ts +52 -37
- package/src/modules/agent/action.ts +5 -5
- package/src/modules/ai/node/actions.ts +1 -1
- package/src/modules/tenant/actions.ts +3 -3
- package/src/modules/waitlist/action.ts +6 -6
@@ -1,10 +1,2 @@
|
|
1
|
-
export declare const actionClient:
|
2
|
-
|
3
|
-
fieldErrors: {};
|
4
|
-
}, readonly []>;
|
5
|
-
export declare const authenticatedActionClient: import("next-safe-action").SafeActionClient<string, undefined, undefined, unknown, {
|
6
|
-
user: any;
|
7
|
-
}, undefined, undefined, undefined, readonly [], {
|
8
|
-
formErrors: string[];
|
9
|
-
fieldErrors: {};
|
10
|
-
}, readonly []>;
|
1
|
+
export declare const actionClient: () => any;
|
2
|
+
export declare const authenticatedActionClient: () => any;
|
@@ -2,36 +2,52 @@ import { getServerSession } from "next-auth";
|
|
2
2
|
import { DEFAULT_SERVER_ERROR_MESSAGE, createSafeActionClient } from "next-safe-action";
|
3
3
|
import { authOptions } from "./authOptions";
|
4
4
|
import { AuthenticationError, AuthorizationError } from "../lib/errors";
|
5
|
-
export const actionClient =
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
5
|
+
export const actionClient = (() => {
|
6
|
+
let internalActionClient = null;
|
7
|
+
return () => {
|
8
|
+
if (internalActionClient == null) {
|
9
|
+
internalActionClient = createSafeActionClient({
|
10
|
+
handleServerError(e) {
|
11
|
+
/* if (
|
12
|
+
e instanceof ResourceNotFoundError ||
|
13
|
+
e instanceof AuthorizationError ||
|
14
|
+
e instanceof InvalidInputError ||
|
15
|
+
e instanceof UnknownError ||
|
16
|
+
e instanceof AuthenticationError ||
|
17
|
+
e instanceof OperationNotAllowedError ||
|
18
|
+
e instanceof AppcondaException
|
19
|
+
) {
|
20
|
+
return e.message;
|
21
|
+
} */
|
22
|
+
// eslint-disable-next-line no-console -- This error needs to be logged for debugging server-side errors
|
23
|
+
console.error("SERVER ERROR: ", e);
|
24
|
+
return DEFAULT_SERVER_ERROR_MESSAGE;
|
25
|
+
},
|
26
|
+
});
|
27
|
+
}
|
28
|
+
return internalActionClient;
|
29
|
+
};
|
30
|
+
})();
|
31
|
+
export const authenticatedActionClient = (() => {
|
32
|
+
let internalActionClient = null;
|
33
|
+
return () => {
|
34
|
+
if (internalActionClient == null) {
|
35
|
+
internalActionClient = actionClient().use(async ({ next }) => {
|
36
|
+
const session = await getServerSession(authOptions());
|
37
|
+
//@ts-ignore
|
38
|
+
if (!session?.user) {
|
39
|
+
throw new AuthenticationError("Not authenticated");
|
40
|
+
}
|
41
|
+
//@ts-ignore
|
42
|
+
const userId = session.user.id;
|
43
|
+
//@ts-ignore
|
44
|
+
const user = await getUser(userId);
|
45
|
+
if (!user) {
|
46
|
+
throw new AuthorizationError("User not found");
|
47
|
+
}
|
48
|
+
return next({ ctx: { user } });
|
49
|
+
});
|
50
|
+
}
|
51
|
+
return internalActionClient;
|
52
|
+
};
|
53
|
+
})();
|
@@ -1,25 +1 @@
|
|
1
|
-
|
2
|
-
export declare const CreateUser: import("next-safe-action").SafeActionFn<string, import("zod").ZodObject<{
|
3
|
-
userId: import("zod").ZodOptional<import("zod").ZodString>;
|
4
|
-
email: import("zod").ZodString;
|
5
|
-
password: import("zod").ZodString;
|
6
|
-
name: import("zod").ZodOptional<import("zod").ZodString>;
|
7
|
-
}, "strip", import("zod").ZodTypeAny, {
|
8
|
-
name?: string;
|
9
|
-
password?: string;
|
10
|
-
email?: string;
|
11
|
-
userId?: string;
|
12
|
-
}, {
|
13
|
-
name?: string;
|
14
|
-
password?: string;
|
15
|
-
email?: string;
|
16
|
-
userId?: string;
|
17
|
-
}>, readonly [], {
|
18
|
-
formErrors: string[];
|
19
|
-
fieldErrors: {
|
20
|
-
name?: string[];
|
21
|
-
password?: string[];
|
22
|
-
email?: string[];
|
23
|
-
userId?: string[];
|
24
|
-
};
|
25
|
-
}, readonly [], User>;
|
1
|
+
export declare const CreateUser: any;
|
@@ -1,53 +1,5 @@
|
|
1
|
-
|
2
|
-
export declare const
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
export declare const CreateAgent: import("next-safe-action").SafeActionFn<string, import("zod").ZodObject<{
|
7
|
-
id: import("zod").ZodOptional<import("zod").ZodString>;
|
8
|
-
name: import("zod").ZodString;
|
9
|
-
modelId: import("zod").ZodString;
|
10
|
-
}, "strip", import("zod").ZodTypeAny, {
|
11
|
-
name?: string;
|
12
|
-
id?: string;
|
13
|
-
modelId?: string;
|
14
|
-
}, {
|
15
|
-
name?: string;
|
16
|
-
id?: string;
|
17
|
-
modelId?: string;
|
18
|
-
}>, readonly [], {
|
19
|
-
formErrors: string[];
|
20
|
-
fieldErrors: {
|
21
|
-
name?: string[];
|
22
|
-
id?: string[];
|
23
|
-
modelId?: string[];
|
24
|
-
};
|
25
|
-
}, readonly [], Agent>;
|
26
|
-
export declare const GetAgent: import("next-safe-action").SafeActionFn<string, import("zod").ZodObject<{
|
27
|
-
id: import("zod").ZodString;
|
28
|
-
}, "strip", import("zod").ZodTypeAny, {
|
29
|
-
id?: string;
|
30
|
-
}, {
|
31
|
-
id?: string;
|
32
|
-
}>, readonly [], {
|
33
|
-
formErrors: string[];
|
34
|
-
fieldErrors: {
|
35
|
-
id?: string[];
|
36
|
-
};
|
37
|
-
}, readonly [], Agent>;
|
38
|
-
export declare const ListModelProviders: import("next-safe-action").SafeActionFn<string, undefined, readonly [], {
|
39
|
-
formErrors: string[];
|
40
|
-
fieldErrors: {};
|
41
|
-
}, readonly [], Agent[]>;
|
42
|
-
export declare const ListModels: import("next-safe-action").SafeActionFn<string, import("zod").ZodObject<{
|
43
|
-
modelProviderId: import("zod").ZodString;
|
44
|
-
}, "strip", import("zod").ZodTypeAny, {
|
45
|
-
modelProviderId?: string;
|
46
|
-
}, {
|
47
|
-
modelProviderId?: string;
|
48
|
-
}>, readonly [], {
|
49
|
-
formErrors: string[];
|
50
|
-
fieldErrors: {
|
51
|
-
modelProviderId?: string[];
|
52
|
-
};
|
53
|
-
}, readonly [], AIModel[]>;
|
1
|
+
export declare const ListAgents: any;
|
2
|
+
export declare const CreateAgent: any;
|
3
|
+
export declare const GetAgent: any;
|
4
|
+
export declare const ListModelProviders: any;
|
5
|
+
export declare const ListModels: any;
|
@@ -2,7 +2,7 @@
|
|
2
2
|
import { actionClient } from '../../actions/actionClient';
|
3
3
|
import { getSDKForCurrentUser } from '../../getSDKForCurrentUser';
|
4
4
|
import { CreateAgentSchema, GetAgentSchema, ListModelsSchema } from './schema';
|
5
|
-
export const ListAgents = actionClient
|
5
|
+
export const ListAgents = actionClient()
|
6
6
|
//.schema(ListWaitlistSignupsSchema)
|
7
7
|
.action(async ({ parsedInput }) => {
|
8
8
|
try {
|
@@ -14,7 +14,7 @@ export const ListAgents = actionClient
|
|
14
14
|
throw new Error('Failed to fetch ListWaitlistSignups');
|
15
15
|
}
|
16
16
|
});
|
17
|
-
export const CreateAgent = actionClient
|
17
|
+
export const CreateAgent = actionClient()
|
18
18
|
.schema(CreateAgentSchema)
|
19
19
|
.action(async ({ parsedInput }) => {
|
20
20
|
try {
|
@@ -26,7 +26,7 @@ export const CreateAgent = actionClient
|
|
26
26
|
throw new Error('Failed to fetch ListWaitlists');
|
27
27
|
}
|
28
28
|
});
|
29
|
-
export const GetAgent = actionClient
|
29
|
+
export const GetAgent = actionClient()
|
30
30
|
.schema(GetAgentSchema)
|
31
31
|
.action(async ({ parsedInput }) => {
|
32
32
|
try {
|
@@ -38,7 +38,7 @@ export const GetAgent = actionClient
|
|
38
38
|
throw new Error('Failed to fetch ListWaitlists');
|
39
39
|
}
|
40
40
|
});
|
41
|
-
export const ListModelProviders = actionClient
|
41
|
+
export const ListModelProviders = actionClient()
|
42
42
|
.action(async ({ parsedInput }) => {
|
43
43
|
try {
|
44
44
|
const { agent } = await getSDKForCurrentUser();
|
@@ -49,7 +49,7 @@ export const ListModelProviders = actionClient
|
|
49
49
|
throw new Error('Failed to fetch ListModelProviders');
|
50
50
|
}
|
51
51
|
});
|
52
|
-
export const ListModels = actionClient
|
52
|
+
export const ListModels = actionClient()
|
53
53
|
.schema(ListModelsSchema)
|
54
54
|
.action(async ({ parsedInput }) => {
|
55
55
|
try {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
'use server';
|
2
2
|
import { actionClient } from "../../../actions/actionClient";
|
3
3
|
import { getSDKForCurrentUser } from "../../../getSDKForCurrentUser";
|
4
|
-
export const getAllNodesAction = actionClient
|
4
|
+
export const getAllNodesAction = actionClient()
|
5
5
|
// .schema(listModelsSchema)
|
6
6
|
.action(async ({ parsedInput }) => {
|
7
7
|
try {
|
@@ -1,45 +1,3 @@
|
|
1
|
-
|
2
|
-
export declare const
|
3
|
-
|
4
|
-
}, "strip", z.ZodTypeAny, {
|
5
|
-
tenantId?: string;
|
6
|
-
}, {
|
7
|
-
tenantId?: string;
|
8
|
-
}>, readonly [], {
|
9
|
-
formErrors: string[];
|
10
|
-
fieldErrors: {
|
11
|
-
tenantId?: string[];
|
12
|
-
};
|
13
|
-
}, readonly [], import("@appconda/nextjs").Models.Tenant>;
|
14
|
-
export declare const listUserTenantsAction: import("next-safe-action").SafeActionFn<string, z.ZodObject<{
|
15
|
-
userId: z.ZodString;
|
16
|
-
}, "strip", z.ZodTypeAny, {
|
17
|
-
userId?: string;
|
18
|
-
}, {
|
19
|
-
userId?: string;
|
20
|
-
}>, readonly [], {
|
21
|
-
formErrors: string[];
|
22
|
-
fieldErrors: {
|
23
|
-
userId?: string[];
|
24
|
-
};
|
25
|
-
}, readonly [], import("@appconda/nextjs").Models.TenantUserList>;
|
26
|
-
export declare const createTenantAction: import("next-safe-action").SafeActionFn<string, z.ZodObject<{
|
27
|
-
id: z.ZodString;
|
28
|
-
name: z.ZodString;
|
29
|
-
slug: z.ZodString;
|
30
|
-
}, "strip", z.ZodTypeAny, {
|
31
|
-
name?: string;
|
32
|
-
id?: string;
|
33
|
-
slug?: string;
|
34
|
-
}, {
|
35
|
-
name?: string;
|
36
|
-
id?: string;
|
37
|
-
slug?: string;
|
38
|
-
}>, readonly [], {
|
39
|
-
formErrors: string[];
|
40
|
-
fieldErrors: {
|
41
|
-
name?: string[];
|
42
|
-
id?: string[];
|
43
|
-
slug?: string[];
|
44
|
-
};
|
45
|
-
}, readonly [], import("@appconda/nextjs").Models.Tenant>;
|
1
|
+
export declare const getTenantAction: any;
|
2
|
+
export declare const listUserTenantsAction: any;
|
3
|
+
export declare const createTenantAction: any;
|
@@ -5,7 +5,7 @@ import { actionClient } from "../../actions/actionClient";
|
|
5
5
|
const getTenantActionSchema = z.object({
|
6
6
|
tenantId: z.string()
|
7
7
|
});
|
8
|
-
export const getTenantAction = actionClient
|
8
|
+
export const getTenantAction = actionClient()
|
9
9
|
.schema(getTenantActionSchema)
|
10
10
|
.action(async ({ parsedInput }) => {
|
11
11
|
const { tenantId } = parsedInput;
|
@@ -15,7 +15,7 @@ export const getTenantAction = actionClient
|
|
15
15
|
const listUserTenantsScheema = z.object({
|
16
16
|
userId: z.string()
|
17
17
|
});
|
18
|
-
export const listUserTenantsAction = actionClient
|
18
|
+
export const listUserTenantsAction = actionClient()
|
19
19
|
.schema(listUserTenantsScheema)
|
20
20
|
.action(async ({ parsedInput }) => {
|
21
21
|
const { userId } = parsedInput;
|
@@ -27,7 +27,7 @@ const createTenantScheema = z.object({
|
|
27
27
|
name: z.string(),
|
28
28
|
slug: z.string()
|
29
29
|
});
|
30
|
-
export const createTenantAction = actionClient
|
30
|
+
export const createTenantAction = actionClient()
|
31
31
|
.schema(createTenantScheema)
|
32
32
|
.action(async ({ parsedInput }) => {
|
33
33
|
const { id, name, slug } = parsedInput;
|
@@ -1,69 +1,6 @@
|
|
1
|
-
|
2
|
-
export declare const
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
waitlistId?: string;
|
8
|
-
}>, readonly [], {
|
9
|
-
formErrors: string[];
|
10
|
-
fieldErrors: {
|
11
|
-
waitlistId?: string[];
|
12
|
-
};
|
13
|
-
}, readonly [], WaitlistSignup[]>;
|
14
|
-
export declare const ListWaitlists: import("next-safe-action").SafeActionFn<string, undefined, readonly [], {
|
15
|
-
formErrors: string[];
|
16
|
-
fieldErrors: {};
|
17
|
-
}, readonly [], Waitlist[]>;
|
18
|
-
export declare const CreateWaitlist: import("next-safe-action").SafeActionFn<string, import("zod").ZodObject<{
|
19
|
-
name: import("zod").ZodString;
|
20
|
-
}, "strip", import("zod").ZodTypeAny, {
|
21
|
-
name?: string;
|
22
|
-
}, {
|
23
|
-
name?: string;
|
24
|
-
}>, readonly [], {
|
25
|
-
formErrors: string[];
|
26
|
-
fieldErrors: {
|
27
|
-
name?: string[];
|
28
|
-
};
|
29
|
-
}, readonly [], Waitlist>;
|
30
|
-
export declare const CreateWaitlistSignup: import("next-safe-action").SafeActionFn<string, import("zod").ZodObject<{
|
31
|
-
waitlistId: import("zod").ZodString;
|
32
|
-
email: import("zod").ZodString;
|
33
|
-
}, "strip", import("zod").ZodTypeAny, {
|
34
|
-
email?: string;
|
35
|
-
waitlistId?: string;
|
36
|
-
}, {
|
37
|
-
email?: string;
|
38
|
-
waitlistId?: string;
|
39
|
-
}>, readonly [], {
|
40
|
-
formErrors: string[];
|
41
|
-
fieldErrors: {
|
42
|
-
email?: string[];
|
43
|
-
waitlistId?: string[];
|
44
|
-
};
|
45
|
-
}, readonly [], WaitlistSignup>;
|
46
|
-
export declare const CreateWaitlistOffboardedSignup: import("next-safe-action").SafeActionFn<string, import("zod").ZodObject<{
|
47
|
-
waitlistSignupId: import("zod").ZodString;
|
48
|
-
}, "strip", import("zod").ZodTypeAny, {
|
49
|
-
waitlistSignupId?: string;
|
50
|
-
}, {
|
51
|
-
waitlistSignupId?: string;
|
52
|
-
}>, readonly [], {
|
53
|
-
formErrors: string[];
|
54
|
-
fieldErrors: {
|
55
|
-
waitlistSignupId?: string[];
|
56
|
-
};
|
57
|
-
}, readonly [], WaitlistSignup>;
|
58
|
-
export declare const ListWaitlistOffboardedSignups: import("next-safe-action").SafeActionFn<string, import("zod").ZodObject<{
|
59
|
-
waitlistId: import("zod").ZodString;
|
60
|
-
}, "strip", import("zod").ZodTypeAny, {
|
61
|
-
waitlistId?: string;
|
62
|
-
}, {
|
63
|
-
waitlistId?: string;
|
64
|
-
}>, readonly [], {
|
65
|
-
formErrors: string[];
|
66
|
-
fieldErrors: {
|
67
|
-
waitlistId?: string[];
|
68
|
-
};
|
69
|
-
}, readonly [], WaitlistSignup>;
|
1
|
+
export declare const ListWaitlistSignups: any;
|
2
|
+
export declare const ListWaitlists: any;
|
3
|
+
export declare const CreateWaitlist: any;
|
4
|
+
export declare const CreateWaitlistSignup: any;
|
5
|
+
export declare const CreateWaitlistOffboardedSignup: any;
|
6
|
+
export declare const ListWaitlistOffboardedSignups: any;
|
@@ -3,7 +3,7 @@ import { actionClient } from '../../actions/actionClient';
|
|
3
3
|
import { getSDKForCurrentUser } from '../../getSDKForCurrentUser';
|
4
4
|
import { getSDKForService } from '../../getSDKForService';
|
5
5
|
import { CreateWaitlistOffboardedSignupSchema, CreateWaitlistSchema, CreateWaitlistSignupSchema, ListWaitlistOffboardedSignupsSchema, ListWaitlistSignupsSchema } from "./schema";
|
6
|
-
export const ListWaitlistSignups = actionClient
|
6
|
+
export const ListWaitlistSignups = actionClient()
|
7
7
|
.schema(ListWaitlistSignupsSchema)
|
8
8
|
.action(async ({ parsedInput }) => {
|
9
9
|
try {
|
@@ -16,7 +16,7 @@ export const ListWaitlistSignups = actionClient
|
|
16
16
|
throw new Error('Failed to fetch ListWaitlistSignups');
|
17
17
|
}
|
18
18
|
});
|
19
|
-
export const ListWaitlists = actionClient
|
19
|
+
export const ListWaitlists = actionClient()
|
20
20
|
.action(async () => {
|
21
21
|
try {
|
22
22
|
const { waitlist } = await getSDKForService();
|
@@ -27,7 +27,7 @@ export const ListWaitlists = actionClient
|
|
27
27
|
throw new Error('Failed to fetch ListWaitlists');
|
28
28
|
}
|
29
29
|
});
|
30
|
-
export const CreateWaitlist = actionClient
|
30
|
+
export const CreateWaitlist = actionClient()
|
31
31
|
.schema(CreateWaitlistSchema)
|
32
32
|
.action(async ({ parsedInput }) => {
|
33
33
|
try {
|
@@ -39,7 +39,7 @@ export const CreateWaitlist = actionClient
|
|
39
39
|
throw new Error('Failed to fetch ListWaitlists');
|
40
40
|
}
|
41
41
|
});
|
42
|
-
export const CreateWaitlistSignup = actionClient
|
42
|
+
export const CreateWaitlistSignup = actionClient()
|
43
43
|
.schema(CreateWaitlistSignupSchema)
|
44
44
|
.action(async ({ parsedInput }) => {
|
45
45
|
try {
|
@@ -51,7 +51,7 @@ export const CreateWaitlistSignup = actionClient
|
|
51
51
|
throw new Error('Failed to fetch ListWaitlists');
|
52
52
|
}
|
53
53
|
});
|
54
|
-
export const CreateWaitlistOffboardedSignup = actionClient
|
54
|
+
export const CreateWaitlistOffboardedSignup = actionClient()
|
55
55
|
.schema(CreateWaitlistOffboardedSignupSchema)
|
56
56
|
.action(async ({ parsedInput }) => {
|
57
57
|
try {
|
@@ -63,7 +63,7 @@ export const CreateWaitlistOffboardedSignup = actionClient
|
|
63
63
|
throw new Error('Failed to fetch ListWaitlists');
|
64
64
|
}
|
65
65
|
});
|
66
|
-
export const ListWaitlistOffboardedSignups = actionClient
|
66
|
+
export const ListWaitlistOffboardedSignups = actionClient()
|
67
67
|
.schema(ListWaitlistOffboardedSignupsSchema)
|
68
68
|
.action(async ({ parsedInput }) => {
|
69
69
|
try {
|
package/package.json
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
"name": "@appconda/nextjs",
|
3
3
|
"homepage": "https://appconda.io/support",
|
4
4
|
"description": "Appconda is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
|
5
|
-
"version": "1.0.
|
5
|
+
"version": "1.0.95",
|
6
6
|
"license": "BSD-3-Clause",
|
7
7
|
"main": "dist/index.js",
|
8
8
|
"types": "dist/index.d.ts",
|
@@ -5,42 +5,57 @@ import { authOptions } from "./authOptions";
|
|
5
5
|
import { AuthenticationError, AuthorizationError } from "../lib/errors";
|
6
6
|
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
throw new AuthenticationError("Not authenticated");
|
8
|
+
export const actionClient = (() => {
|
9
|
+
let internalActionClient = null;
|
10
|
+
return () => {
|
11
|
+
if (internalActionClient == null) {
|
12
|
+
internalActionClient = createSafeActionClient({
|
13
|
+
handleServerError(e: Error) {
|
14
|
+
/* if (
|
15
|
+
e instanceof ResourceNotFoundError ||
|
16
|
+
e instanceof AuthorizationError ||
|
17
|
+
e instanceof InvalidInputError ||
|
18
|
+
e instanceof UnknownError ||
|
19
|
+
e instanceof AuthenticationError ||
|
20
|
+
e instanceof OperationNotAllowedError ||
|
21
|
+
e instanceof AppcondaException
|
22
|
+
) {
|
23
|
+
return e.message;
|
24
|
+
} */
|
25
|
+
|
26
|
+
// eslint-disable-next-line no-console -- This error needs to be logged for debugging server-side errors
|
27
|
+
console.error("SERVER ERROR: ", e);
|
28
|
+
return DEFAULT_SERVER_ERROR_MESSAGE;
|
29
|
+
},
|
30
|
+
})
|
31
|
+
}
|
32
|
+
return internalActionClient;
|
34
33
|
}
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
34
|
+
})();
|
35
|
+
|
36
|
+
export const authenticatedActionClient = (() => {
|
37
|
+
let internalActionClient = null;
|
38
|
+
return () => {
|
39
|
+
if (internalActionClient == null) {
|
40
|
+
internalActionClient = actionClient().use(async ({ next }) => {
|
41
|
+
const session = await getServerSession(authOptions());
|
42
|
+
//@ts-ignore
|
43
|
+
if (!session?.user) {
|
44
|
+
throw new AuthenticationError("Not authenticated");
|
45
|
+
}
|
46
|
+
|
47
|
+
//@ts-ignore
|
48
|
+
const userId = session.user.id;
|
49
|
+
|
50
|
+
//@ts-ignore
|
51
|
+
const user = await getUser(userId);
|
52
|
+
if (!user) {
|
53
|
+
throw new AuthorizationError("User not found");
|
54
|
+
}
|
55
|
+
|
56
|
+
return next({ ctx: { user } });
|
57
|
+
});
|
58
|
+
}
|
59
|
+
return internalActionClient;
|
43
60
|
}
|
44
|
-
|
45
|
-
return next({ ctx: { user } });
|
46
|
-
});
|
61
|
+
})();
|
@@ -8,7 +8,7 @@ import { CreateAgentSchema, GetAgentSchema, ListModelsSchema } from './schema';
|
|
8
8
|
import { Agent, AIModel } from './types';
|
9
9
|
|
10
10
|
|
11
|
-
export const ListAgents = actionClient
|
11
|
+
export const ListAgents = actionClient()
|
12
12
|
//.schema(ListWaitlistSignupsSchema)
|
13
13
|
.action(async ({ parsedInput }): Promise<Agent[]> => {
|
14
14
|
try {
|
@@ -23,7 +23,7 @@ export const ListAgents = actionClient
|
|
23
23
|
|
24
24
|
|
25
25
|
|
26
|
-
export const CreateAgent = actionClient
|
26
|
+
export const CreateAgent = actionClient()
|
27
27
|
.schema(CreateAgentSchema)
|
28
28
|
.action(async ({ parsedInput }): Promise<Agent> => {
|
29
29
|
try {
|
@@ -37,7 +37,7 @@ export const CreateAgent = actionClient
|
|
37
37
|
}
|
38
38
|
});
|
39
39
|
|
40
|
-
export const GetAgent = actionClient
|
40
|
+
export const GetAgent = actionClient()
|
41
41
|
.schema(GetAgentSchema)
|
42
42
|
.action(async ({ parsedInput }): Promise<Agent> => {
|
43
43
|
try {
|
@@ -51,7 +51,7 @@ export const GetAgent = actionClient
|
|
51
51
|
}
|
52
52
|
});
|
53
53
|
|
54
|
-
export const ListModelProviders = actionClient
|
54
|
+
export const ListModelProviders = actionClient()
|
55
55
|
.action(async ({ parsedInput }): Promise<Agent[]> => {
|
56
56
|
try {
|
57
57
|
|
@@ -63,7 +63,7 @@ export const ListModelProviders = actionClient
|
|
63
63
|
}
|
64
64
|
});
|
65
65
|
|
66
|
-
export const ListModels = actionClient
|
66
|
+
export const ListModels = actionClient()
|
67
67
|
.schema(ListModelsSchema)
|
68
68
|
.action(async ({ parsedInput }): Promise<AIModel[]> => {
|
69
69
|
try {
|
@@ -4,7 +4,7 @@ import { z } from "zod";
|
|
4
4
|
import { actionClient } from "../../../actions/actionClient";
|
5
5
|
import { getSDKForCurrentUser } from "../../../getSDKForCurrentUser";
|
6
6
|
|
7
|
-
export const getAllNodesAction = actionClient
|
7
|
+
export const getAllNodesAction = actionClient()
|
8
8
|
// .schema(listModelsSchema)
|
9
9
|
.action(async ({ parsedInput }) => {
|
10
10
|
try {
|
@@ -8,7 +8,7 @@ const getTenantActionSchema = z.object({
|
|
8
8
|
tenantId: z.string()
|
9
9
|
});
|
10
10
|
|
11
|
-
export const getTenantAction = actionClient
|
11
|
+
export const getTenantAction = actionClient()
|
12
12
|
.schema(getTenantActionSchema)
|
13
13
|
.action(async ({ parsedInput }) => {
|
14
14
|
const { tenantId } = parsedInput;
|
@@ -22,7 +22,7 @@ const listUserTenantsScheema = z.object({
|
|
22
22
|
userId: z.string()
|
23
23
|
});
|
24
24
|
|
25
|
-
export const listUserTenantsAction = actionClient
|
25
|
+
export const listUserTenantsAction = actionClient()
|
26
26
|
.schema(listUserTenantsScheema)
|
27
27
|
.action(async ({ parsedInput }) => {
|
28
28
|
const { userId } = parsedInput;
|
@@ -37,7 +37,7 @@ const createTenantScheema = z.object({
|
|
37
37
|
slug: z.string()
|
38
38
|
});
|
39
39
|
|
40
|
-
export const createTenantAction = actionClient
|
40
|
+
export const createTenantAction = actionClient()
|
41
41
|
.schema(createTenantScheema)
|
42
42
|
.action(async ({ parsedInput }) => {
|
43
43
|
const { id, name, slug } = parsedInput;
|
@@ -10,7 +10,7 @@ import { Waitlist, WaitlistSignup } from './types';
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
-
export const ListWaitlistSignups = actionClient
|
13
|
+
export const ListWaitlistSignups = actionClient()
|
14
14
|
.schema(ListWaitlistSignupsSchema)
|
15
15
|
.action(async ({ parsedInput }): Promise<WaitlistSignup[]> => {
|
16
16
|
try {
|
@@ -23,7 +23,7 @@ export const ListWaitlistSignups = actionClient
|
|
23
23
|
}
|
24
24
|
});
|
25
25
|
|
26
|
-
export const ListWaitlists = actionClient
|
26
|
+
export const ListWaitlists = actionClient()
|
27
27
|
.action(async (): Promise<Waitlist[]> => {
|
28
28
|
try {
|
29
29
|
const { waitlist } = await getSDKForService();
|
@@ -35,7 +35,7 @@ export const ListWaitlists = actionClient
|
|
35
35
|
});
|
36
36
|
|
37
37
|
|
38
|
-
export const CreateWaitlist = actionClient
|
38
|
+
export const CreateWaitlist = actionClient()
|
39
39
|
.schema(CreateWaitlistSchema)
|
40
40
|
.action(async ({ parsedInput }): Promise<Waitlist> => {
|
41
41
|
try {
|
@@ -50,7 +50,7 @@ export const CreateWaitlist = actionClient
|
|
50
50
|
});
|
51
51
|
|
52
52
|
|
53
|
-
export const CreateWaitlistSignup = actionClient
|
53
|
+
export const CreateWaitlistSignup = actionClient()
|
54
54
|
.schema(CreateWaitlistSignupSchema)
|
55
55
|
.action(async ({ parsedInput }): Promise<WaitlistSignup> => {
|
56
56
|
try {
|
@@ -64,7 +64,7 @@ export const CreateWaitlistSignup = actionClient
|
|
64
64
|
}
|
65
65
|
});
|
66
66
|
|
67
|
-
export const CreateWaitlistOffboardedSignup = actionClient
|
67
|
+
export const CreateWaitlistOffboardedSignup = actionClient()
|
68
68
|
.schema(CreateWaitlistOffboardedSignupSchema)
|
69
69
|
.action(async ({ parsedInput }): Promise<WaitlistSignup> => {
|
70
70
|
try {
|
@@ -78,7 +78,7 @@ export const CreateWaitlistSignup = actionClient
|
|
78
78
|
}
|
79
79
|
});
|
80
80
|
|
81
|
-
export const ListWaitlistOffboardedSignups = actionClient
|
81
|
+
export const ListWaitlistOffboardedSignups = actionClient()
|
82
82
|
.schema(ListWaitlistOffboardedSignupsSchema)
|
83
83
|
.action(async ({ parsedInput }): Promise<WaitlistSignup> => {
|
84
84
|
try {
|