@appconda/nextjs 1.0.12 → 1.0.13
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/cjs/sdk.js +2634 -0
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +2634 -1
- package/dist/esm/sdk.js.map +1 -1
- package/dist/iife/sdk.js +2634 -2
- package/package.json +2 -1
- package/src/getAppcondaClient.ts +44 -0
- package/src/getSDKForCurrentUser.ts +75 -0
- package/src/index.ts +1 -0
- package/types/getAppcondaClient.d.ts +2 -0
- package/types/getSDKForCurrentUser.d.ts +33 -0
- package/types/index.d.ts +1 -0
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.13",
|
6
6
|
"license": "BSD-3-Clause",
|
7
7
|
"main": "dist/cjs/sdk.js",
|
8
8
|
"exports": {
|
@@ -35,6 +35,7 @@
|
|
35
35
|
"jsdelivr": "dist/iife/sdk.js",
|
36
36
|
"unpkg": "dist/iife/sdk.js",
|
37
37
|
"dependencies": {
|
38
|
+
"next": "^15.2.3",
|
38
39
|
"node-fetch-native-with-agent": "^1.7.2",
|
39
40
|
"redis": "^4.7.0",
|
40
41
|
"zod": "^3.24.2"
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { Client } from "./client";
|
2
|
+
|
3
|
+
function getPortAndHostname(urlString: string): { hostname: string; port: string; protocol: string } {
|
4
|
+
try {
|
5
|
+
const url = new URL(urlString);
|
6
|
+
return {
|
7
|
+
hostname: url.hostname,
|
8
|
+
port: url.port || (url.protocol === 'https:' ? '443' : '80'), // Default ports if not specified
|
9
|
+
protocol: url.protocol
|
10
|
+
};
|
11
|
+
} catch (error) {
|
12
|
+
console.error('Invalid URL:', error);
|
13
|
+
return { hostname: '', port: '', protocol: '' };
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
export async function getAppcondaClient() {
|
18
|
+
|
19
|
+
let url;
|
20
|
+
if (process.env.NEXT_PUBLIC_APPCONDA_CLIENT_ENDPOINT) {
|
21
|
+
url = process.env.NEXT_PUBLIC_APPCONDA_CLIENT_ENDPOINT;
|
22
|
+
} else if (typeof window !== 'undefined') {
|
23
|
+
const hostInfo = getPortAndHostname(window.location.href);
|
24
|
+
if (hostInfo.port) {
|
25
|
+
url = `${hostInfo.protocol}//${hostInfo.hostname}:${hostInfo.port}/v1`
|
26
|
+
} else {
|
27
|
+
url = `${hostInfo.protocol}//${hostInfo.hostname}/v1`
|
28
|
+
}
|
29
|
+
} else {
|
30
|
+
url = 'http://appconda/v1'
|
31
|
+
}
|
32
|
+
|
33
|
+
/* if (ApplicationConfig.Port == null) {
|
34
|
+
url = `${ApplicationConfig.Protocol}://${ApplicationConfig.Domain}:${ApplicationConfig.Port}/v1`
|
35
|
+
} else {
|
36
|
+
url = `${ApplicationConfig.Protocol}://${ApplicationConfig.Domain}/v1`
|
37
|
+
} */
|
38
|
+
const adminClient = new Client()
|
39
|
+
.setEndpoint(url) // Your API Endpoint
|
40
|
+
.setProject('console');
|
41
|
+
|
42
|
+
return adminClient
|
43
|
+
|
44
|
+
}
|
@@ -0,0 +1,75 @@
|
|
1
|
+
import { cookies } from "next/headers";
|
2
|
+
import { getAppcondaClient } from "./getAppcondaClient";
|
3
|
+
import { Account } from "./services/account";
|
4
|
+
import { Community } from "./services/community";
|
5
|
+
import { Configuration } from "./services/configuration";
|
6
|
+
import { Databases } from "./services/databases";
|
7
|
+
import { Pricing } from "./services/pricing";
|
8
|
+
import { Projects } from "./services/projects";
|
9
|
+
import { Roles } from "./services/roles";
|
10
|
+
import { Schemas } from "./services/schema";
|
11
|
+
import { Subscription } from "./services/subscription";
|
12
|
+
import { Teams } from "./services/teams";
|
13
|
+
import { Tenant } from "./services/tenant";
|
14
|
+
import { TenantSubscription } from "./services/tenant-subscription";
|
15
|
+
import { Users } from "./services/users";
|
16
|
+
import { Node } from "./services/node";
|
17
|
+
import { Permissions } from "./services/permissions";
|
18
|
+
|
19
|
+
export async function getSDKForCurrentUser() {
|
20
|
+
const adminClient = await getAppcondaClient();
|
21
|
+
|
22
|
+
const c = await cookies()
|
23
|
+
const s = c.get('a_session') || c.get('a_session_console_legacy');
|
24
|
+
if (!s || !s.value) {
|
25
|
+
throw new Error("No session");
|
26
|
+
}
|
27
|
+
|
28
|
+
adminClient.setSession(s.value);
|
29
|
+
|
30
|
+
const accounts = new Account(adminClient);
|
31
|
+
const databases = new Databases(adminClient);
|
32
|
+
|
33
|
+
const projects = new Projects(adminClient);
|
34
|
+
|
35
|
+
const currentUser = await accounts.get();
|
36
|
+
|
37
|
+
const users = new Users(adminClient);
|
38
|
+
const teams = new Teams(adminClient);
|
39
|
+
|
40
|
+
const tenants = new Tenant(adminClient);
|
41
|
+
const roles = new Roles(adminClient);
|
42
|
+
const permissions = new Permissions(adminClient);
|
43
|
+
const schemas = new Schemas(adminClient);
|
44
|
+
|
45
|
+
const community = new Community(adminClient);
|
46
|
+
|
47
|
+
const tenantSubscriptions = new TenantSubscription(adminClient);
|
48
|
+
|
49
|
+
const subscription = new Subscription(adminClient);
|
50
|
+
const pricing = new Pricing(adminClient);
|
51
|
+
const configuration = new Configuration(adminClient);
|
52
|
+
//const acl = new Acl(adminClient);
|
53
|
+
|
54
|
+
const node = new Node(adminClient);
|
55
|
+
|
56
|
+
return {
|
57
|
+
currentUser,
|
58
|
+
accounts,
|
59
|
+
databases,
|
60
|
+
projects,
|
61
|
+
users,
|
62
|
+
teams,
|
63
|
+
tenants,
|
64
|
+
roles,
|
65
|
+
permissions,
|
66
|
+
schemas,
|
67
|
+
community,
|
68
|
+
tenantSubscriptions,
|
69
|
+
subscription,
|
70
|
+
pricing,
|
71
|
+
configuration,
|
72
|
+
// acl,
|
73
|
+
node
|
74
|
+
}
|
75
|
+
}
|
package/src/index.ts
CHANGED
@@ -34,3 +34,4 @@ export { ImageGravity } from './enums/image-gravity';
|
|
34
34
|
export { ImageFormat } from './enums/image-format';
|
35
35
|
export { PasswordHash } from './enums/password-hash';
|
36
36
|
export { MessagingProviderType } from './enums/messaging-provider-type';
|
37
|
+
export { getSDKForCurrentUser } from './getSDKForCurrentUser';
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { Account } from "./services/account";
|
2
|
+
import { Community } from "./services/community";
|
3
|
+
import { Configuration } from "./services/configuration";
|
4
|
+
import { Databases } from "./services/databases";
|
5
|
+
import { Pricing } from "./services/pricing";
|
6
|
+
import { Projects } from "./services/projects";
|
7
|
+
import { Roles } from "./services/roles";
|
8
|
+
import { Schemas } from "./services/schema";
|
9
|
+
import { Subscription } from "./services/subscription";
|
10
|
+
import { Teams } from "./services/teams";
|
11
|
+
import { Tenant } from "./services/tenant";
|
12
|
+
import { TenantSubscription } from "./services/tenant-subscription";
|
13
|
+
import { Users } from "./services/users";
|
14
|
+
import { Node } from "./services/node";
|
15
|
+
import { Permissions } from "./services/permissions";
|
16
|
+
export declare function getSDKForCurrentUser(): Promise<{
|
17
|
+
currentUser: import("./models").Models.User<import("./models").Models.Preferences>;
|
18
|
+
accounts: Account;
|
19
|
+
databases: Databases;
|
20
|
+
projects: Projects;
|
21
|
+
users: Users;
|
22
|
+
teams: Teams;
|
23
|
+
tenants: Tenant;
|
24
|
+
roles: Roles;
|
25
|
+
permissions: Permissions;
|
26
|
+
schemas: Schemas;
|
27
|
+
community: Community;
|
28
|
+
tenantSubscriptions: TenantSubscription;
|
29
|
+
subscription: Subscription;
|
30
|
+
pricing: Pricing;
|
31
|
+
configuration: Configuration;
|
32
|
+
node: Node;
|
33
|
+
}>;
|
package/types/index.d.ts
CHANGED
@@ -34,3 +34,4 @@ export { ImageGravity } from './enums/image-gravity';
|
|
34
34
|
export { ImageFormat } from './enums/image-format';
|
35
35
|
export { PasswordHash } from './enums/password-hash';
|
36
36
|
export { MessagingProviderType } from './enums/messaging-provider-type';
|
37
|
+
export { getSDKForCurrentUser } from './getSDKForCurrentUser';
|