@appconda/nextjs 1.0.93 → 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/getSDKForCurrentUser.d.ts +2 -2
- package/dist/getSDKForCurrentUser.js +2 -2
- 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/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/modules/tenant/actions.d.ts +3 -0
- package/dist/modules/tenant/actions.js +37 -0
- package/dist/modules/tenant/index.d.ts +3 -0
- package/dist/modules/tenant/index.js +3 -0
- package/dist/modules/tenant/tenant.d.ts +32 -0
- package/dist/modules/tenant/tenant.js +124 -0
- package/dist/modules/tenant/types.d.ts +11 -0
- package/dist/modules/tenant/types.js +1 -0
- 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/getSDKForCurrentUser.ts +2 -2
- package/src/modules/agent/action.ts +5 -5
- package/src/modules/ai/node/actions.ts +1 -1
- package/src/modules/index.ts +2 -1
- package/src/modules/tenant/actions.ts +47 -0
- package/src/modules/tenant/index.ts +3 -0
- package/src/{services → modules/tenant}/tenant.ts +3 -4
- package/src/modules/tenant/types.ts +12 -0
- 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
|
+
})();
|
@@ -7,7 +7,6 @@ import { Roles } from "./services/roles";
|
|
7
7
|
import { Schemas } from "./services/schema";
|
8
8
|
import { Subscription } from "./services/subscription";
|
9
9
|
import { Teams } from "./services/teams";
|
10
|
-
import { Tenant } from "./services/tenant";
|
11
10
|
import { TenantSubscription } from "./services/tenant-subscription";
|
12
11
|
import { Users } from "./services/users";
|
13
12
|
import { Permissions } from "./services/permissions";
|
@@ -16,6 +15,7 @@ import { Account } from "./modules/account/service";
|
|
16
15
|
import { Node } from "./modules/ai/node/service";
|
17
16
|
import { AgentService } from "./modules/agent/service";
|
18
17
|
import { ChatFlow } from "./services/chat-flow";
|
18
|
+
import { TenantService } from "./modules";
|
19
19
|
export declare function getSDKForCurrentUser(): Promise<{
|
20
20
|
currentUser: import("./modules/account/types").User<import("./modules/account/types").Preferences>;
|
21
21
|
accounts: Account;
|
@@ -23,7 +23,7 @@ export declare function getSDKForCurrentUser(): Promise<{
|
|
23
23
|
projects: Projects;
|
24
24
|
users: Users;
|
25
25
|
teams: Teams;
|
26
|
-
tenants:
|
26
|
+
tenants: TenantService;
|
27
27
|
roles: Roles;
|
28
28
|
permissions: Permissions;
|
29
29
|
schemas: Schemas;
|
@@ -9,7 +9,6 @@ import { Roles } from "./services/roles";
|
|
9
9
|
import { Schemas } from "./services/schema";
|
10
10
|
import { Subscription } from "./services/subscription";
|
11
11
|
import { Teams } from "./services/teams";
|
12
|
-
import { Tenant } from "./services/tenant";
|
13
12
|
import { TenantSubscription } from "./services/tenant-subscription";
|
14
13
|
import { Users } from "./services/users";
|
15
14
|
import { Permissions } from "./services/permissions";
|
@@ -18,6 +17,7 @@ import { Account } from "./modules/account/service";
|
|
18
17
|
import { Node } from "./modules/ai/node/service";
|
19
18
|
import { AgentService } from "./modules/agent/service";
|
20
19
|
import { ChatFlow } from "./services/chat-flow";
|
20
|
+
import { TenantService } from "./modules";
|
21
21
|
export async function getSDKForCurrentUser() {
|
22
22
|
const adminClient = await getAppcondaClient();
|
23
23
|
const c = await cookies();
|
@@ -32,7 +32,7 @@ export async function getSDKForCurrentUser() {
|
|
32
32
|
const currentUser = await accounts.get();
|
33
33
|
const users = new Users(adminClient);
|
34
34
|
const teams = new Teams(adminClient);
|
35
|
-
const tenants = new
|
35
|
+
const tenants = new TenantService(adminClient);
|
36
36
|
const roles = new Roles(adminClient);
|
37
37
|
const permissions = new Permissions(adminClient);
|
38
38
|
const schemas = new Schemas(adminClient);
|
@@ -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 {
|
package/dist/modules/index.d.ts
CHANGED
package/dist/modules/index.js
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
'use server';
|
2
|
+
import { getSDKForCurrentUser } from "@appconda/nextjs";
|
3
|
+
import { z } from "zod";
|
4
|
+
import { actionClient } from "../../actions/actionClient";
|
5
|
+
const getTenantActionSchema = z.object({
|
6
|
+
tenantId: z.string()
|
7
|
+
});
|
8
|
+
export const getTenantAction = actionClient()
|
9
|
+
.schema(getTenantActionSchema)
|
10
|
+
.action(async ({ parsedInput }) => {
|
11
|
+
const { tenantId } = parsedInput;
|
12
|
+
const { tenants } = await getSDKForCurrentUser();
|
13
|
+
return await tenants.get(tenantId);
|
14
|
+
});
|
15
|
+
const listUserTenantsScheema = z.object({
|
16
|
+
userId: z.string()
|
17
|
+
});
|
18
|
+
export const listUserTenantsAction = actionClient()
|
19
|
+
.schema(listUserTenantsScheema)
|
20
|
+
.action(async ({ parsedInput }) => {
|
21
|
+
const { userId } = parsedInput;
|
22
|
+
const { tenants } = await getSDKForCurrentUser();
|
23
|
+
return await tenants.listUserTenants(userId);
|
24
|
+
});
|
25
|
+
const createTenantScheema = z.object({
|
26
|
+
id: z.string(),
|
27
|
+
name: z.string(),
|
28
|
+
slug: z.string()
|
29
|
+
});
|
30
|
+
export const createTenantAction = actionClient()
|
31
|
+
.schema(createTenantScheema)
|
32
|
+
.action(async ({ parsedInput }) => {
|
33
|
+
const { id, name, slug } = parsedInput;
|
34
|
+
const { tenants } = await getSDKForCurrentUser();
|
35
|
+
//@ts-ignore
|
36
|
+
return await tenants.create({ $id: id, name: name, slug: slug });
|
37
|
+
});
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { Models } from "../../client";
|
2
|
+
import { ServiceClient } from "../../service-client";
|
3
|
+
export type TenantSimple = {
|
4
|
+
id: string;
|
5
|
+
name: string;
|
6
|
+
slug: string;
|
7
|
+
icon: string | null;
|
8
|
+
deactivatedReason: string | null;
|
9
|
+
types: any[];
|
10
|
+
active: boolean;
|
11
|
+
};
|
12
|
+
export declare class TenantService extends ServiceClient {
|
13
|
+
getServiceName(): string;
|
14
|
+
get(tenantId: string): Promise<Models.Tenant>;
|
15
|
+
/**
|
16
|
+
* Create account
|
17
|
+
*
|
18
|
+
* Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appconda.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appconda.io/docs/references/cloud/client-web/account#createEmailSession).
|
19
|
+
*
|
20
|
+
* @param {string} tenantId
|
21
|
+
* @param {string} name
|
22
|
+
* @param {string} slug
|
23
|
+
* @throws {AppcondaException}
|
24
|
+
* @returns {Promise<Models.User<Preferences>>}
|
25
|
+
*/
|
26
|
+
create({ $id, name, slug }: Models.Tenant): Promise<Models.Tenant>;
|
27
|
+
list(queries?: string[], search?: string): Promise<Models.TenantList>;
|
28
|
+
listUserTenants(userId: string, queries?: string[], search?: string): Promise<Models.TenantUserList>;
|
29
|
+
listTenantUsers(tenantId: string, queries?: string[], search?: string): Promise<Models.TenantUserList>;
|
30
|
+
createTenantUser({ tenantId, userId }: Models.TenantUser): Promise<Models.TenantUser>;
|
31
|
+
adminGetAllTenantsIdsAndNames(): Promise<TenantSimple[]>;
|
32
|
+
}
|
@@ -0,0 +1,124 @@
|
|
1
|
+
import { AppcondaException } from "../../client";
|
2
|
+
import { ServiceClient } from "../../service-client";
|
3
|
+
export class TenantService extends ServiceClient {
|
4
|
+
getServiceName() {
|
5
|
+
return 'com.appconda.service.tenant';
|
6
|
+
}
|
7
|
+
async get(tenantId) {
|
8
|
+
if (typeof tenantId === 'undefined') {
|
9
|
+
throw new AppcondaException('Missing required parameter: "tenantId"');
|
10
|
+
}
|
11
|
+
const apiPath = '/tenants/{tenantId}'.replace('{tenantId}', tenantId);
|
12
|
+
const payload = {};
|
13
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
14
|
+
const apiHeaders = {
|
15
|
+
'content-type': 'application/json',
|
16
|
+
};
|
17
|
+
return await this.client.call('get', uri, apiHeaders, payload);
|
18
|
+
}
|
19
|
+
/**
|
20
|
+
* Create account
|
21
|
+
*
|
22
|
+
* Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appconda.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appconda.io/docs/references/cloud/client-web/account#createEmailSession).
|
23
|
+
*
|
24
|
+
* @param {string} tenantId
|
25
|
+
* @param {string} name
|
26
|
+
* @param {string} slug
|
27
|
+
* @throws {AppcondaException}
|
28
|
+
* @returns {Promise<Models.User<Preferences>>}
|
29
|
+
*/
|
30
|
+
async create({ $id, name, slug }) {
|
31
|
+
if (typeof $id === 'undefined') {
|
32
|
+
throw new AppcondaException('Missing required parameter: "tenantId"');
|
33
|
+
}
|
34
|
+
if (typeof name === 'undefined') {
|
35
|
+
throw new AppcondaException('Missing required parameter: "name"');
|
36
|
+
}
|
37
|
+
if (typeof slug === 'undefined') {
|
38
|
+
throw new AppcondaException('Missing required parameter: "slug"');
|
39
|
+
}
|
40
|
+
const apiPath = '/tenants';
|
41
|
+
const payload = {};
|
42
|
+
if (typeof $id !== 'undefined') {
|
43
|
+
payload['tenantId'] = $id;
|
44
|
+
}
|
45
|
+
if (typeof name !== 'undefined') {
|
46
|
+
payload['name'] = name;
|
47
|
+
}
|
48
|
+
if (typeof slug !== 'undefined') {
|
49
|
+
payload['slug'] = slug;
|
50
|
+
}
|
51
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
52
|
+
const apiHeaders = {
|
53
|
+
'content-type': 'application/json',
|
54
|
+
};
|
55
|
+
return await this.client.call('post', uri, apiHeaders, payload);
|
56
|
+
}
|
57
|
+
async list(queries, search) {
|
58
|
+
const apiPath = '/tenants';
|
59
|
+
const payload = {};
|
60
|
+
if (typeof queries !== 'undefined') {
|
61
|
+
payload['queries'] = queries;
|
62
|
+
}
|
63
|
+
if (typeof search !== 'undefined') {
|
64
|
+
payload['search'] = search;
|
65
|
+
}
|
66
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
67
|
+
const apiHeaders = {
|
68
|
+
'content-type': 'application/json',
|
69
|
+
};
|
70
|
+
return await this.client.call('get', uri, apiHeaders, payload);
|
71
|
+
}
|
72
|
+
async listUserTenants(userId, queries, search) {
|
73
|
+
const apiPath = `/tenants/${userId}/tenants`;
|
74
|
+
const payload = {};
|
75
|
+
if (typeof queries !== 'undefined') {
|
76
|
+
payload['queries'] = queries;
|
77
|
+
}
|
78
|
+
if (typeof search !== 'undefined') {
|
79
|
+
payload['search'] = search;
|
80
|
+
}
|
81
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
82
|
+
const apiHeaders = {
|
83
|
+
'content-type': 'application/json',
|
84
|
+
};
|
85
|
+
return await this.client.call('get', uri, apiHeaders, payload);
|
86
|
+
}
|
87
|
+
async listTenantUsers(tenantId, queries, search) {
|
88
|
+
const apiPath = `/tenants/${tenantId}/users`;
|
89
|
+
const payload = {};
|
90
|
+
if (typeof queries !== 'undefined') {
|
91
|
+
payload['queries'] = queries;
|
92
|
+
}
|
93
|
+
if (typeof search !== 'undefined') {
|
94
|
+
payload['search'] = search;
|
95
|
+
}
|
96
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
97
|
+
const apiHeaders = {
|
98
|
+
'content-type': 'application/json',
|
99
|
+
};
|
100
|
+
return await this.client.call('get', uri, apiHeaders, payload);
|
101
|
+
}
|
102
|
+
async createTenantUser({ tenantId, userId }) {
|
103
|
+
if (typeof tenantId === 'undefined') {
|
104
|
+
throw new AppcondaException('Missing required parameter: "tenantId"');
|
105
|
+
}
|
106
|
+
if (typeof userId === 'undefined') {
|
107
|
+
throw new AppcondaException('Missing required parameter: "userId"');
|
108
|
+
}
|
109
|
+
const apiPath = `/tenants/${tenantId}/users`;
|
110
|
+
const payload = {};
|
111
|
+
if (typeof userId !== 'undefined') {
|
112
|
+
payload['userId'] = userId;
|
113
|
+
}
|
114
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
115
|
+
const apiHeaders = {
|
116
|
+
'content-type': 'application/json',
|
117
|
+
};
|
118
|
+
return await this.client.call('post', uri, apiHeaders, payload);
|
119
|
+
}
|
120
|
+
async adminGetAllTenantsIdsAndNames() {
|
121
|
+
const payload = {};
|
122
|
+
return await this.actionCall('AdminGetAllTenantsIdsAndNames', payload);
|
123
|
+
}
|
124
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -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
|
+
})();
|
@@ -9,7 +9,6 @@ import { Roles } from "./services/roles";
|
|
9
9
|
import { Schemas } from "./services/schema";
|
10
10
|
import { Subscription } from "./services/subscription";
|
11
11
|
import { Teams } from "./services/teams";
|
12
|
-
import { Tenant } from "./services/tenant";
|
13
12
|
import { TenantSubscription } from "./services/tenant-subscription";
|
14
13
|
import { Users } from "./services/users";
|
15
14
|
import { Permissions } from "./services/permissions";
|
@@ -18,6 +17,7 @@ import { Account } from "./modules/account/service";
|
|
18
17
|
import { Node } from "./modules/ai/node/service";
|
19
18
|
import { AgentService } from "./modules/agent/service";
|
20
19
|
import { ChatFlow } from "./services/chat-flow";
|
20
|
+
import { TenantService } from "./modules";
|
21
21
|
|
22
22
|
export async function getSDKForCurrentUser() {
|
23
23
|
const adminClient = await getAppcondaClient();
|
@@ -40,7 +40,7 @@ export async function getSDKForCurrentUser() {
|
|
40
40
|
const users = new Users(adminClient);
|
41
41
|
const teams = new Teams(adminClient);
|
42
42
|
|
43
|
-
const tenants = new
|
43
|
+
const tenants = new TenantService(adminClient);
|
44
44
|
const roles = new Roles(adminClient);
|
45
45
|
const permissions = new Permissions(adminClient);
|
46
46
|
const schemas = new Schemas(adminClient);
|
@@ -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 {
|
package/src/modules/index.ts
CHANGED
@@ -0,0 +1,47 @@
|
|
1
|
+
'use server';
|
2
|
+
|
3
|
+
import { getSDKForCurrentUser } from "@appconda/nextjs";
|
4
|
+
import { z } from "zod";
|
5
|
+
import { actionClient } from "../../actions/actionClient";
|
6
|
+
|
7
|
+
const getTenantActionSchema = z.object({
|
8
|
+
tenantId: z.string()
|
9
|
+
});
|
10
|
+
|
11
|
+
export const getTenantAction = actionClient()
|
12
|
+
.schema(getTenantActionSchema)
|
13
|
+
.action(async ({ parsedInput }) => {
|
14
|
+
const { tenantId } = parsedInput;
|
15
|
+
const { tenants } = await getSDKForCurrentUser();
|
16
|
+
return await tenants.get(tenantId);
|
17
|
+
});
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
const listUserTenantsScheema = z.object({
|
22
|
+
userId: z.string()
|
23
|
+
});
|
24
|
+
|
25
|
+
export const listUserTenantsAction = actionClient()
|
26
|
+
.schema(listUserTenantsScheema)
|
27
|
+
.action(async ({ parsedInput }) => {
|
28
|
+
const { userId } = parsedInput;
|
29
|
+
const { tenants } = await getSDKForCurrentUser();
|
30
|
+
return await tenants.listUserTenants(userId);
|
31
|
+
});
|
32
|
+
|
33
|
+
|
34
|
+
const createTenantScheema = z.object({
|
35
|
+
id: z.string(),
|
36
|
+
name: z.string(),
|
37
|
+
slug: z.string()
|
38
|
+
});
|
39
|
+
|
40
|
+
export const createTenantAction = actionClient()
|
41
|
+
.schema(createTenantScheema)
|
42
|
+
.action(async ({ parsedInput }) => {
|
43
|
+
const { id, name, slug } = parsedInput;
|
44
|
+
const { tenants } = await getSDKForCurrentUser();
|
45
|
+
//@ts-ignore
|
46
|
+
return await tenants.create({ $id: id, name: name, slug: slug });
|
47
|
+
});
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { AppcondaException, Client, Models, Payload } from "
|
2
|
-
import { ServiceClient } from "
|
1
|
+
import { AppcondaException, Client, Models, Payload } from "../../client";
|
2
|
+
import { ServiceClient } from "../../service-client";
|
3
3
|
|
4
4
|
export type TenantSimple = {
|
5
5
|
id: string;
|
@@ -11,9 +11,8 @@ export type TenantSimple = {
|
|
11
11
|
active: boolean;
|
12
12
|
};
|
13
13
|
|
14
|
-
export class
|
14
|
+
export class TenantService extends ServiceClient{
|
15
15
|
|
16
|
-
|
17
16
|
public getServiceName(): string {
|
18
17
|
return 'com.appconda.service.tenant';
|
19
18
|
}
|
@@ -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 {
|