@omnibase/core-js 0.4.2 → 0.5.1
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/chunk-767PUXYD.js +556 -0
- package/dist/chunk-DDFBRGMG.js +106 -0
- package/dist/chunk-LIS5WD3H.js +560 -0
- package/dist/index.cjs +1259 -0
- package/dist/index.d.cts +3 -10
- package/dist/index.d.ts +3 -3
- package/dist/index.js +51 -0
- package/dist/payments/index.cjs +474 -83
- package/dist/payments/index.d.cts +1862 -66
- package/dist/payments/index.d.ts +1862 -66
- package/dist/payments/index.js +12 -161
- package/dist/permissions/index.js +3 -102
- package/dist/tenants/index.cjs +535 -157
- package/dist/tenants/index.d.cts +3 -635
- package/dist/tenants/index.d.ts +3 -635
- package/dist/tenants/index.js +4 -175
- package/package.json +7 -2
package/dist/tenants/index.js
CHANGED
|
@@ -1,177 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (!baseUrl) {
|
|
5
|
-
throw new Error("OMNIBASE_AUTH_URL is not configured");
|
|
6
|
-
}
|
|
7
|
-
if (!tenantId) {
|
|
8
|
-
throw new Error("Tenant ID is required");
|
|
9
|
-
}
|
|
10
|
-
const requestBody = {
|
|
11
|
-
tenant_id: tenantId
|
|
12
|
-
};
|
|
13
|
-
try {
|
|
14
|
-
const response = await fetch(`${baseUrl}/api/v1/tenants/switch-active`, {
|
|
15
|
-
method: "PUT",
|
|
16
|
-
headers: {
|
|
17
|
-
"Content-Type": "application/json"
|
|
18
|
-
},
|
|
19
|
-
body: JSON.stringify(requestBody),
|
|
20
|
-
credentials: "include"
|
|
21
|
-
});
|
|
22
|
-
if (!response.ok) {
|
|
23
|
-
const errorData = await response.text();
|
|
24
|
-
throw new Error(
|
|
25
|
-
`Failed to switch tenant: ${response.status} - ${errorData}`
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
const data = await response.json();
|
|
29
|
-
return data;
|
|
30
|
-
} catch (error) {
|
|
31
|
-
console.error("Error switching active tenant:", error);
|
|
32
|
-
throw error;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// src/tenants/create-invite.ts
|
|
37
|
-
async function createTenantUserInvite(tenantId, inviteData) {
|
|
38
|
-
const baseUrl = process.env.OMNIBASE_AUTH_URL;
|
|
39
|
-
if (!baseUrl) {
|
|
40
|
-
throw new Error("OMNIBASE_AUTH_URL is not configured");
|
|
41
|
-
}
|
|
42
|
-
if (!tenantId) {
|
|
43
|
-
throw new Error("Tenant ID is required");
|
|
44
|
-
}
|
|
45
|
-
if (!inviteData.email || !inviteData.role) {
|
|
46
|
-
throw new Error("Email and role are required");
|
|
47
|
-
}
|
|
48
|
-
try {
|
|
49
|
-
const response = await fetch(
|
|
50
|
-
`${baseUrl}/api/v1/tenants/${tenantId}/invites`,
|
|
51
|
-
{
|
|
52
|
-
method: "POST",
|
|
53
|
-
headers: {
|
|
54
|
-
"Content-Type": "application/json"
|
|
55
|
-
},
|
|
56
|
-
body: JSON.stringify(inviteData),
|
|
57
|
-
credentials: "include"
|
|
58
|
-
}
|
|
59
|
-
);
|
|
60
|
-
if (!response.ok) {
|
|
61
|
-
const errorData = await response.text();
|
|
62
|
-
throw new Error(
|
|
63
|
-
`Failed to create invite: ${response.status} - ${errorData}`
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
const data = await response.json();
|
|
67
|
-
return data;
|
|
68
|
-
} catch (error) {
|
|
69
|
-
console.error("Error creating tenant user invite:", error);
|
|
70
|
-
throw error;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// src/tenants/create-tenant.ts
|
|
75
|
-
async function createTenant(tenantData) {
|
|
76
|
-
const baseUrl = process.env.OMNIBASE_AUTH_URL;
|
|
77
|
-
if (!baseUrl) {
|
|
78
|
-
throw new Error("OMNIBASE_AUTH_URL is not configured");
|
|
79
|
-
}
|
|
80
|
-
if (!tenantData.name || !tenantData.user_id) {
|
|
81
|
-
throw new Error("Name and user_id are required");
|
|
82
|
-
}
|
|
83
|
-
try {
|
|
84
|
-
const response = await fetch(`${baseUrl}/api/v1/tenants`, {
|
|
85
|
-
method: "POST",
|
|
86
|
-
headers: {
|
|
87
|
-
"Content-Type": "application/json"
|
|
88
|
-
},
|
|
89
|
-
body: JSON.stringify(tenantData),
|
|
90
|
-
credentials: "include"
|
|
91
|
-
});
|
|
92
|
-
if (!response.ok) {
|
|
93
|
-
const errorData = await response.text();
|
|
94
|
-
throw new Error(
|
|
95
|
-
`Failed to create tenant: ${response.status} - ${errorData}`
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
const data = await response.json();
|
|
99
|
-
return data;
|
|
100
|
-
} catch (error) {
|
|
101
|
-
console.error("Error creating tenant:", error);
|
|
102
|
-
throw error;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// src/tenants/accept-invite.ts
|
|
107
|
-
async function acceptTenantInvite(token) {
|
|
108
|
-
const baseUrl = process.env.OMNIBASE_AUTH_URL;
|
|
109
|
-
if (!baseUrl) {
|
|
110
|
-
throw new Error("OMNIBASE_AUTH_URL is not configured");
|
|
111
|
-
}
|
|
112
|
-
if (!token) {
|
|
113
|
-
throw new Error("Invite token is required");
|
|
114
|
-
}
|
|
115
|
-
const requestBody = {
|
|
116
|
-
token
|
|
117
|
-
};
|
|
118
|
-
try {
|
|
119
|
-
const response = await fetch(`${baseUrl}/api/v1/tenants/invites/accept`, {
|
|
120
|
-
method: "PUT",
|
|
121
|
-
headers: {
|
|
122
|
-
"Content-Type": "application/json"
|
|
123
|
-
},
|
|
124
|
-
body: JSON.stringify(requestBody),
|
|
125
|
-
credentials: "include"
|
|
126
|
-
});
|
|
127
|
-
if (!response.ok) {
|
|
128
|
-
const errorData = await response.text();
|
|
129
|
-
throw new Error(
|
|
130
|
-
`Failed to accept invite: ${response.status} - ${errorData}`
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
const data = await response.json();
|
|
134
|
-
return data;
|
|
135
|
-
} catch (error) {
|
|
136
|
-
console.error("Error accepting tenant invite:", error);
|
|
137
|
-
throw error;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// src/tenants/delete-tenant.ts
|
|
142
|
-
async function deleteTenant(tenantId) {
|
|
143
|
-
const baseUrl = process.env.OMNIBASE_AUTH_URL;
|
|
144
|
-
if (!baseUrl) {
|
|
145
|
-
throw new Error("OMNIBASE_AUTH_URL is not configured");
|
|
146
|
-
}
|
|
147
|
-
if (!tenantId) {
|
|
148
|
-
throw new Error("Tenant ID is required");
|
|
149
|
-
}
|
|
150
|
-
try {
|
|
151
|
-
const response = await fetch(`${baseUrl}/api/v1/tenants/${tenantId}`, {
|
|
152
|
-
method: "DELETE",
|
|
153
|
-
headers: {
|
|
154
|
-
"Content-Type": "application/json"
|
|
155
|
-
},
|
|
156
|
-
credentials: "include"
|
|
157
|
-
});
|
|
158
|
-
if (!response.ok) {
|
|
159
|
-
const errorData = await response.text();
|
|
160
|
-
throw new Error(
|
|
161
|
-
`Failed to delete tenant: ${response.status} - ${errorData}`
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
const data = await response.json();
|
|
165
|
-
return data;
|
|
166
|
-
} catch (error) {
|
|
167
|
-
console.error("Error deleting tenant:", error);
|
|
168
|
-
throw error;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
TenantHandler
|
|
3
|
+
} from "../chunk-LIS5WD3H.js";
|
|
171
4
|
export {
|
|
172
|
-
|
|
173
|
-
createTenant,
|
|
174
|
-
createTenantUserInvite,
|
|
175
|
-
deleteTenant,
|
|
176
|
-
switchActiveTenant
|
|
5
|
+
TenantHandler
|
|
177
6
|
};
|
package/package.json
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnibase/core-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "OmniBase core Javascript SDK - framework agnostic",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/**/*"
|
|
7
7
|
],
|
|
8
8
|
"type": "module",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "tsup src/permissions/index.ts src/database/index.ts src/tenants/index.ts src/auth/index.ts src/payments/index.ts --format cjs,esm --dts",
|
|
10
|
+
"build": "tsup src/index.ts src/permissions/index.ts src/database/index.ts src/tenants/index.ts src/auth/index.ts src/payments/index.ts --format cjs,esm --dts",
|
|
11
11
|
"prepublishOnly": "npm run build"
|
|
12
12
|
},
|
|
13
13
|
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./dist/index.d.ts",
|
|
16
|
+
"require": "./dist/index.cjs",
|
|
17
|
+
"types": "./dist/index.d.ts"
|
|
18
|
+
},
|
|
14
19
|
"./auth": {
|
|
15
20
|
"types": "./dist/auth/index.d.ts"
|
|
16
21
|
},
|