@appconda/nextjs 1.0.96 → 1.0.98

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.
@@ -1,8 +1,10 @@
1
- export declare const actionClient: () => import("next-safe-action").SafeActionClient<unknown, import("next-safe-action").DVES, import("zod").ZodType<any, import("zod").ZodTypeDef, any>, any, {}, undefined, undefined, undefined, readonly [], {
1
+ export declare const actionClient: import("next-safe-action").SafeActionClient<string, undefined, undefined, unknown, {}, undefined, undefined, undefined, readonly [], {
2
2
  formErrors: string[];
3
3
  fieldErrors: {};
4
4
  }, readonly []>;
5
- export declare const authenticatedActionClient: () => import("next-safe-action").SafeActionClient<unknown, import("next-safe-action").DVES, import("zod").ZodType<any, import("zod").ZodTypeDef, any>, any, {}, undefined, undefined, undefined, readonly [], {
5
+ export declare const authenticatedActionClient: import("next-safe-action").SafeActionClient<string, undefined, undefined, unknown, {
6
+ user: any;
7
+ }, undefined, undefined, undefined, readonly [], {
6
8
  formErrors: string[];
7
9
  fieldErrors: {};
8
10
  }, readonly []>;
@@ -2,52 +2,36 @@ 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
- 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
- })();
5
+ export const actionClient = createSafeActionClient({
6
+ handleServerError(e) {
7
+ /* if (
8
+ e instanceof ResourceNotFoundError ||
9
+ e instanceof AuthorizationError ||
10
+ e instanceof InvalidInputError ||
11
+ e instanceof UnknownError ||
12
+ e instanceof AuthenticationError ||
13
+ e instanceof OperationNotAllowedError ||
14
+ e instanceof AppcondaException
15
+ ) {
16
+ return e.message;
17
+ } */
18
+ // eslint-disable-next-line no-console -- This error needs to be logged for debugging server-side errors
19
+ console.error("SERVER ERROR: ", e);
20
+ return DEFAULT_SERVER_ERROR_MESSAGE;
21
+ },
22
+ });
23
+ export const authenticatedActionClient = actionClient.use(async ({ next }) => {
24
+ const session = await getServerSession(authOptions());
25
+ //@ts-ignore
26
+ if (!session?.user) {
27
+ throw new AuthenticationError("Not authenticated");
28
+ }
29
+ //@ts-ignore
30
+ const userId = session.user.id;
31
+ //@ts-ignore
32
+ const user = await getUser(userId);
33
+ if (!user) {
34
+ throw new AuthorizationError("User not found");
35
+ }
36
+ return next({ ctx: { user } });
37
+ });
@@ -1 +1,25 @@
1
- export declare const CreateUser: any;
1
+ import { User } from "./types";
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,9 +1,9 @@
1
1
  import { Agent, AIModel } from './types';
2
- export declare const ListAgents: import("next-safe-action").SafeActionFn<unknown, undefined, readonly [], {
2
+ export declare const ListAgents: import("next-safe-action").SafeActionFn<string, undefined, readonly [], {
3
3
  formErrors: string[];
4
4
  fieldErrors: {};
5
5
  }, readonly [], Agent[]>;
6
- export declare const CreateAgent: import("next-safe-action").SafeActionFn<unknown, import("zod").ZodObject<{
6
+ export declare const CreateAgent: import("next-safe-action").SafeActionFn<string, import("zod").ZodObject<{
7
7
  id: import("zod").ZodOptional<import("zod").ZodString>;
8
8
  name: import("zod").ZodString;
9
9
  modelId: import("zod").ZodString;
@@ -16,17 +16,6 @@ export declare const CreateAgent: import("next-safe-action").SafeActionFn<unknow
16
16
  id?: string;
17
17
  modelId?: string;
18
18
  }>, readonly [], {
19
- _errors?: string[];
20
- name?: {
21
- _errors?: string[];
22
- };
23
- id?: {
24
- _errors?: string[];
25
- };
26
- modelId?: {
27
- _errors?: string[];
28
- };
29
- } | {
30
19
  formErrors: string[];
31
20
  fieldErrors: {
32
21
  name?: string[];
@@ -34,39 +23,29 @@ export declare const CreateAgent: import("next-safe-action").SafeActionFn<unknow
34
23
  modelId?: string[];
35
24
  };
36
25
  }, readonly [], Agent>;
37
- export declare const GetAgent: import("next-safe-action").SafeActionFn<unknown, import("zod").ZodObject<{
26
+ export declare const GetAgent: import("next-safe-action").SafeActionFn<string, import("zod").ZodObject<{
38
27
  id: import("zod").ZodString;
39
28
  }, "strip", import("zod").ZodTypeAny, {
40
29
  id?: string;
41
30
  }, {
42
31
  id?: string;
43
32
  }>, readonly [], {
44
- _errors?: string[];
45
- id?: {
46
- _errors?: string[];
47
- };
48
- } | {
49
33
  formErrors: string[];
50
34
  fieldErrors: {
51
35
  id?: string[];
52
36
  };
53
37
  }, readonly [], Agent>;
54
- export declare const ListModelProviders: import("next-safe-action").SafeActionFn<unknown, undefined, readonly [], {
38
+ export declare const ListModelProviders: import("next-safe-action").SafeActionFn<string, undefined, readonly [], {
55
39
  formErrors: string[];
56
40
  fieldErrors: {};
57
41
  }, readonly [], Agent[]>;
58
- export declare const ListModels: import("next-safe-action").SafeActionFn<unknown, import("zod").ZodObject<{
42
+ export declare const ListModels: import("next-safe-action").SafeActionFn<string, import("zod").ZodObject<{
59
43
  modelProviderId: import("zod").ZodString;
60
44
  }, "strip", import("zod").ZodTypeAny, {
61
45
  modelProviderId?: string;
62
46
  }, {
63
47
  modelProviderId?: string;
64
48
  }>, readonly [], {
65
- _errors?: string[];
66
- modelProviderId?: {
67
- _errors?: string[];
68
- };
69
- } | {
70
49
  formErrors: string[];
71
50
  fieldErrors: {
72
51
  modelProviderId?: string[];
@@ -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,4 +1,4 @@
1
- export declare const getAllNodesAction: import("next-safe-action").SafeActionFn<unknown, undefined, readonly [], {
1
+ export declare const getAllNodesAction: import("next-safe-action").SafeActionFn<string, undefined, readonly [], {
2
2
  formErrors: string[];
3
3
  fieldErrors: {};
4
4
  }, readonly [], any[]>;
@@ -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,39 +1,29 @@
1
1
  import { z } from "zod";
2
- export declare const getTenantAction: import("next-safe-action").SafeActionFn<unknown, z.ZodObject<{
2
+ export declare const getTenantAction: import("next-safe-action").SafeActionFn<string, z.ZodObject<{
3
3
  tenantId: z.ZodString;
4
4
  }, "strip", z.ZodTypeAny, {
5
5
  tenantId?: string;
6
6
  }, {
7
7
  tenantId?: string;
8
8
  }>, readonly [], {
9
- _errors?: string[];
10
- tenantId?: {
11
- _errors?: string[];
12
- };
13
- } | {
14
9
  formErrors: string[];
15
10
  fieldErrors: {
16
11
  tenantId?: string[];
17
12
  };
18
13
  }, readonly [], import("@appconda/nextjs").Models.Tenant>;
19
- export declare const listUserTenantsAction: import("next-safe-action").SafeActionFn<unknown, z.ZodObject<{
14
+ export declare const listUserTenantsAction: import("next-safe-action").SafeActionFn<string, z.ZodObject<{
20
15
  userId: z.ZodString;
21
16
  }, "strip", z.ZodTypeAny, {
22
17
  userId?: string;
23
18
  }, {
24
19
  userId?: string;
25
20
  }>, readonly [], {
26
- _errors?: string[];
27
- userId?: {
28
- _errors?: string[];
29
- };
30
- } | {
31
21
  formErrors: string[];
32
22
  fieldErrors: {
33
23
  userId?: string[];
34
24
  };
35
25
  }, readonly [], import("@appconda/nextjs").Models.TenantUserList>;
36
- export declare const createTenantAction: import("next-safe-action").SafeActionFn<unknown, z.ZodObject<{
26
+ export declare const createTenantAction: import("next-safe-action").SafeActionFn<string, z.ZodObject<{
37
27
  id: z.ZodString;
38
28
  name: z.ZodString;
39
29
  slug: z.ZodString;
@@ -46,17 +36,6 @@ export declare const createTenantAction: import("next-safe-action").SafeActionFn
46
36
  id?: string;
47
37
  slug?: string;
48
38
  }>, readonly [], {
49
- _errors?: string[];
50
- name?: {
51
- _errors?: string[];
52
- };
53
- id?: {
54
- _errors?: string[];
55
- };
56
- slug?: {
57
- _errors?: string[];
58
- };
59
- } | {
60
39
  formErrors: string[];
61
40
  fieldErrors: {
62
41
  name?: string[];
@@ -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,43 +1,33 @@
1
1
  import { Waitlist, WaitlistSignup } from './types';
2
- export declare const ListWaitlistSignups: import("next-safe-action").SafeActionFn<unknown, import("zod").ZodObject<{
2
+ export declare const ListWaitlistSignups: import("next-safe-action").SafeActionFn<string, import("zod").ZodObject<{
3
3
  waitlistId: import("zod").ZodString;
4
4
  }, "strip", import("zod").ZodTypeAny, {
5
5
  waitlistId?: string;
6
6
  }, {
7
7
  waitlistId?: string;
8
8
  }>, readonly [], {
9
- _errors?: string[];
10
- waitlistId?: {
11
- _errors?: string[];
12
- };
13
- } | {
14
9
  formErrors: string[];
15
10
  fieldErrors: {
16
11
  waitlistId?: string[];
17
12
  };
18
13
  }, readonly [], WaitlistSignup[]>;
19
- export declare const ListWaitlists: import("next-safe-action").SafeActionFn<unknown, undefined, readonly [], {
14
+ export declare const ListWaitlists: import("next-safe-action").SafeActionFn<string, undefined, readonly [], {
20
15
  formErrors: string[];
21
16
  fieldErrors: {};
22
17
  }, readonly [], Waitlist[]>;
23
- export declare const CreateWaitlist: import("next-safe-action").SafeActionFn<unknown, import("zod").ZodObject<{
18
+ export declare const CreateWaitlist: import("next-safe-action").SafeActionFn<string, import("zod").ZodObject<{
24
19
  name: import("zod").ZodString;
25
20
  }, "strip", import("zod").ZodTypeAny, {
26
21
  name?: string;
27
22
  }, {
28
23
  name?: string;
29
24
  }>, readonly [], {
30
- _errors?: string[];
31
- name?: {
32
- _errors?: string[];
33
- };
34
- } | {
35
25
  formErrors: string[];
36
26
  fieldErrors: {
37
27
  name?: string[];
38
28
  };
39
29
  }, readonly [], Waitlist>;
40
- export declare const CreateWaitlistSignup: import("next-safe-action").SafeActionFn<unknown, import("zod").ZodObject<{
30
+ export declare const CreateWaitlistSignup: import("next-safe-action").SafeActionFn<string, import("zod").ZodObject<{
41
31
  waitlistId: import("zod").ZodString;
42
32
  email: import("zod").ZodString;
43
33
  }, "strip", import("zod").ZodTypeAny, {
@@ -47,49 +37,31 @@ export declare const CreateWaitlistSignup: import("next-safe-action").SafeAction
47
37
  email?: string;
48
38
  waitlistId?: string;
49
39
  }>, readonly [], {
50
- _errors?: string[];
51
- email?: {
52
- _errors?: string[];
53
- };
54
- waitlistId?: {
55
- _errors?: string[];
56
- };
57
- } | {
58
40
  formErrors: string[];
59
41
  fieldErrors: {
60
42
  email?: string[];
61
43
  waitlistId?: string[];
62
44
  };
63
45
  }, readonly [], WaitlistSignup>;
64
- export declare const CreateWaitlistOffboardedSignup: import("next-safe-action").SafeActionFn<unknown, import("zod").ZodObject<{
46
+ export declare const CreateWaitlistOffboardedSignup: import("next-safe-action").SafeActionFn<string, import("zod").ZodObject<{
65
47
  waitlistSignupId: import("zod").ZodString;
66
48
  }, "strip", import("zod").ZodTypeAny, {
67
49
  waitlistSignupId?: string;
68
50
  }, {
69
51
  waitlistSignupId?: string;
70
52
  }>, readonly [], {
71
- _errors?: string[];
72
- waitlistSignupId?: {
73
- _errors?: string[];
74
- };
75
- } | {
76
53
  formErrors: string[];
77
54
  fieldErrors: {
78
55
  waitlistSignupId?: string[];
79
56
  };
80
57
  }, readonly [], WaitlistSignup>;
81
- export declare const ListWaitlistOffboardedSignups: import("next-safe-action").SafeActionFn<unknown, import("zod").ZodObject<{
58
+ export declare const ListWaitlistOffboardedSignups: import("next-safe-action").SafeActionFn<string, import("zod").ZodObject<{
82
59
  waitlistId: import("zod").ZodString;
83
60
  }, "strip", import("zod").ZodTypeAny, {
84
61
  waitlistId?: string;
85
62
  }, {
86
63
  waitlistId?: string;
87
64
  }>, readonly [], {
88
- _errors?: string[];
89
- waitlistId?: {
90
- _errors?: string[];
91
- };
92
- } | {
93
65
  formErrors: string[];
94
66
  fieldErrors: {
95
67
  waitlistId?: string[];
@@ -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.96",
5
+ "version": "1.0.98",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
@@ -5,57 +5,42 @@ import { authOptions } from "./authOptions";
5
5
  import { AuthenticationError, AuthorizationError } from "../lib/errors";
6
6
 
7
7
 
8
- export const actionClient = (() => {
9
- let internalActionClient: ReturnType<typeof createSafeActionClient> = 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;
8
+ export const actionClient = createSafeActionClient({
9
+ handleServerError(e: Error) {
10
+ /* if (
11
+ e instanceof ResourceNotFoundError ||
12
+ e instanceof AuthorizationError ||
13
+ e instanceof InvalidInputError ||
14
+ e instanceof UnknownError ||
15
+ e instanceof AuthenticationError ||
16
+ e instanceof OperationNotAllowedError ||
17
+ e instanceof AppcondaException
18
+ ) {
19
+ return e.message;
20
+ } */
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
+
29
+ export const authenticatedActionClient = actionClient.use(async ({ next }) => {
30
+ const session = await getServerSession(authOptions());
31
+ //@ts-ignore
32
+ if (!session?.user) {
33
+ throw new AuthenticationError("Not authenticated");
33
34
  }
34
- })();
35
-
36
- export const authenticatedActionClient = (() => {
37
- let internalActionClient: ReturnType<typeof createSafeActionClient> = 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;
35
+
36
+ //@ts-ignore
37
+ const userId = session.user.id;
38
+
39
+ //@ts-ignore
40
+ const user = await getUser(userId);
41
+ if (!user) {
42
+ throw new AuthorizationError("User not found");
60
43
  }
61
- })();
44
+
45
+ return next({ ctx: { user } });
46
+ });
@@ -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 {
@@ -1,10 +1,9 @@
1
1
  'use server';
2
2
 
3
- import { z } from "zod";
4
3
  import { actionClient } from "../../../actions/actionClient";
5
4
  import { getSDKForCurrentUser } from "../../../getSDKForCurrentUser";
6
5
 
7
- export const getAllNodesAction = actionClient()
6
+ export const getAllNodesAction = actionClient
8
7
  // .schema(listModelsSchema)
9
8
  .action(async ({ parsedInput }) => {
10
9
  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 {