@appconda/nextjs 1.0.93 → 1.0.94

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.
@@ -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: Tenant;
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 Tenant(adminClient);
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);
@@ -2,3 +2,4 @@ export * from './waitlist';
2
2
  export * from './account';
3
3
  export * from './ai';
4
4
  export * from './agent';
5
+ export * from './tenant';
@@ -2,3 +2,4 @@ export * from './waitlist';
2
2
  export * from './account';
3
3
  export * from './ai';
4
4
  export * from './agent';
5
+ export * from './tenant';
@@ -0,0 +1,45 @@
1
+ import { z } from "zod";
2
+ export declare const getTenantAction: import("next-safe-action").SafeActionFn<string, z.ZodObject<{
3
+ tenantId: z.ZodString;
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>;
@@ -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,3 @@
1
+ export * from "./tenant";
2
+ export * from "./types";
3
+ export * from "./actions";
@@ -0,0 +1,3 @@
1
+ export * from "./tenant";
2
+ export * from "./types";
3
+ export * from "./actions";
@@ -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,11 @@
1
+ export type Tenant = {
2
+ id: string;
3
+ createdAt: Date;
4
+ updatedAt: Date;
5
+ slug: string;
6
+ name: string;
7
+ icon: string | null;
8
+ subscriptionId: string | null;
9
+ active: boolean;
10
+ deactivatedReason: string | null;
11
+ };
@@ -0,0 +1 @@
1
+ export {};
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.93",
5
+ "version": "1.0.94",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
@@ -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 Tenant(adminClient);
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);
@@ -1,4 +1,5 @@
1
1
  export * from './waitlist';
2
2
  export * from './account';
3
3
  export * from './ai';
4
- export * from './agent';
4
+ export * from './agent';
5
+ export * from './tenant';
@@ -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
+ });
@@ -0,0 +1,3 @@
1
+ export * from "./tenant";
2
+ export * from "./types";
3
+ export * from "./actions";
@@ -1,5 +1,5 @@
1
- import { AppcondaException, Client, Models, Payload } from "../client";
2
- import { ServiceClient } from "../service-client";
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 Tenant extends ServiceClient{
14
+ export class TenantService extends ServiceClient{
15
15
 
16
-
17
16
  public getServiceName(): string {
18
17
  return 'com.appconda.service.tenant';
19
18
  }
@@ -0,0 +1,12 @@
1
+
2
+ export type Tenant = {
3
+ id: string
4
+ createdAt: Date
5
+ updatedAt: Date
6
+ slug: string
7
+ name: string
8
+ icon: string | null
9
+ subscriptionId: string | null
10
+ active: boolean
11
+ deactivatedReason: string | null
12
+ }