@omnibase/core-js 0.7.2 → 0.7.4
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-DQBFDKRC.js +641 -0
- package/dist/chunk-V4FWENQQ.js +378 -0
- package/dist/index.cjs +61 -38
- package/dist/index.js +2 -2
- package/dist/payments/index.d.cts +52 -12
- package/dist/payments/index.d.ts +52 -12
- package/dist/permissions/index.cjs +52 -19
- package/dist/permissions/index.js +1 -1
- package/dist/tenants/index.cjs +9 -19
- package/dist/tenants/index.js +1 -1
- package/package.json +1 -1
|
@@ -1211,21 +1211,41 @@ interface UpdateRoleRequest {
|
|
|
1211
1211
|
/**
|
|
1212
1212
|
* Request body for assigning a role to a user
|
|
1213
1213
|
*
|
|
1214
|
+
* Supports assigning by either role ID or role name for flexibility.
|
|
1215
|
+
* When using role_name, the system will find the role by name within
|
|
1216
|
+
* the current tenant's scope (including system roles).
|
|
1217
|
+
*
|
|
1214
1218
|
* @example
|
|
1219
|
+
* By role ID:
|
|
1215
1220
|
* ```typescript
|
|
1216
1221
|
* {
|
|
1217
1222
|
* role_id: 'role_456'
|
|
1218
1223
|
* }
|
|
1219
1224
|
* ```
|
|
1220
1225
|
*
|
|
1226
|
+
* @example
|
|
1227
|
+
* By role name:
|
|
1228
|
+
* ```typescript
|
|
1229
|
+
* {
|
|
1230
|
+
* role_name: 'owner'
|
|
1231
|
+
* }
|
|
1232
|
+
* ```
|
|
1233
|
+
*
|
|
1221
1234
|
* @since 0.7.0
|
|
1222
1235
|
* @public
|
|
1223
1236
|
*/
|
|
1224
1237
|
interface AssignRoleRequest {
|
|
1225
1238
|
/**
|
|
1226
1239
|
* ID of the role to assign to the user
|
|
1240
|
+
* Use either role_id or role_name, not both
|
|
1227
1241
|
*/
|
|
1228
|
-
role_id
|
|
1242
|
+
role_id?: string;
|
|
1243
|
+
/**
|
|
1244
|
+
* Name of the role to assign to the user
|
|
1245
|
+
* Use either role_id or role_name, not both
|
|
1246
|
+
* @example 'owner', 'admin', 'billing_manager'
|
|
1247
|
+
*/
|
|
1248
|
+
role_name?: string;
|
|
1229
1249
|
}
|
|
1230
1250
|
|
|
1231
1251
|
/**
|
|
@@ -1378,18 +1398,42 @@ declare class RolesHandler {
|
|
|
1378
1398
|
* Keto relationship tuples based on the role's permissions. The user
|
|
1379
1399
|
* immediately gains all permissions defined in the role.
|
|
1380
1400
|
*
|
|
1401
|
+
* Supports assignment by either role ID or role name for flexibility.
|
|
1402
|
+
*
|
|
1381
1403
|
* @param userId - ID of user to assign role to
|
|
1382
|
-
* @param request - Assignment request with
|
|
1404
|
+
* @param request - Assignment request with either role_id or role_name
|
|
1383
1405
|
*
|
|
1384
1406
|
* @example
|
|
1407
|
+
* Assign by role ID:
|
|
1385
1408
|
* ```typescript
|
|
1386
|
-
* // Assign billing manager role to user
|
|
1387
1409
|
* await omnibase.permissions.roles.assign('user_123', {
|
|
1388
1410
|
* role_id: 'role_456'
|
|
1389
1411
|
* });
|
|
1412
|
+
* ```
|
|
1413
|
+
*
|
|
1414
|
+
* @example
|
|
1415
|
+
* Assign by role name (system or custom role):
|
|
1416
|
+
* ```typescript
|
|
1417
|
+
* // Assign system role
|
|
1418
|
+
* await omnibase.permissions.roles.assign('user_123', {
|
|
1419
|
+
* role_name: 'owner'
|
|
1420
|
+
* });
|
|
1390
1421
|
*
|
|
1391
|
-
* //
|
|
1392
|
-
*
|
|
1422
|
+
* // Assign custom role
|
|
1423
|
+
* await omnibase.permissions.roles.assign('user_456', {
|
|
1424
|
+
* role_name: 'billing_manager'
|
|
1425
|
+
* });
|
|
1426
|
+
* ```
|
|
1427
|
+
*
|
|
1428
|
+
* @example
|
|
1429
|
+
* Verify permissions after assignment:
|
|
1430
|
+
* ```typescript
|
|
1431
|
+
* await omnibase.permissions.roles.assign('user_123', {
|
|
1432
|
+
* role_name: 'admin'
|
|
1433
|
+
* });
|
|
1434
|
+
*
|
|
1435
|
+
* // User now has all permissions from the admin role
|
|
1436
|
+
* const canManage = await omnibase.permissions.permissions.checkPermission(
|
|
1393
1437
|
* undefined,
|
|
1394
1438
|
* {
|
|
1395
1439
|
* namespace: 'Tenant',
|
|
@@ -1398,7 +1442,7 @@ declare class RolesHandler {
|
|
|
1398
1442
|
* subjectId: 'user_123'
|
|
1399
1443
|
* }
|
|
1400
1444
|
* );
|
|
1401
|
-
* //
|
|
1445
|
+
* // canManage.data.allowed === true
|
|
1402
1446
|
* ```
|
|
1403
1447
|
*/
|
|
1404
1448
|
assign(userId: string, request: AssignRoleRequest): Promise<void>;
|
|
@@ -2314,8 +2358,6 @@ declare class TenantManger {
|
|
|
2314
2358
|
* - Billing subscriptions are cancelled (if applicable)
|
|
2315
2359
|
* - Audit logs for deletion are maintained for compliance
|
|
2316
2360
|
*
|
|
2317
|
-
* @param tenantId - The unique identifier of the tenant to delete
|
|
2318
|
-
*
|
|
2319
2361
|
* @returns Promise resolving to a confirmation message
|
|
2320
2362
|
*
|
|
2321
2363
|
* @throws {Error} When the tenantId parameter is missing or empty
|
|
@@ -2327,8 +2369,6 @@ declare class TenantManger {
|
|
|
2327
2369
|
*
|
|
2328
2370
|
* @example
|
|
2329
2371
|
* ```typescript
|
|
2330
|
-
* const tenantToDelete = 'tenant_abc123';
|
|
2331
|
-
*
|
|
2332
2372
|
* // Always confirm before deleting
|
|
2333
2373
|
* const userConfirmed = confirm(
|
|
2334
2374
|
* 'Are you sure you want to delete this tenant? This action cannot be undone.'
|
|
@@ -2336,7 +2376,7 @@ declare class TenantManger {
|
|
|
2336
2376
|
*
|
|
2337
2377
|
* if (userConfirmed) {
|
|
2338
2378
|
* try {
|
|
2339
|
-
* const result = await tenantManager.deleteTenant(
|
|
2379
|
+
* const result = await tenantManager.deleteTenant();
|
|
2340
2380
|
* console.log(result.data.message);
|
|
2341
2381
|
*
|
|
2342
2382
|
* // Redirect user away from deleted tenant
|
|
@@ -2351,7 +2391,7 @@ declare class TenantManger {
|
|
|
2351
2391
|
* @public
|
|
2352
2392
|
* @group Tenant Management
|
|
2353
2393
|
*/
|
|
2354
|
-
deleteTenant(
|
|
2394
|
+
deleteTenant(): Promise<DeleteTenantResponse>;
|
|
2355
2395
|
/**
|
|
2356
2396
|
* Switches the user's active tenant context
|
|
2357
2397
|
*
|
package/dist/payments/index.d.ts
CHANGED
|
@@ -1211,21 +1211,41 @@ interface UpdateRoleRequest {
|
|
|
1211
1211
|
/**
|
|
1212
1212
|
* Request body for assigning a role to a user
|
|
1213
1213
|
*
|
|
1214
|
+
* Supports assigning by either role ID or role name for flexibility.
|
|
1215
|
+
* When using role_name, the system will find the role by name within
|
|
1216
|
+
* the current tenant's scope (including system roles).
|
|
1217
|
+
*
|
|
1214
1218
|
* @example
|
|
1219
|
+
* By role ID:
|
|
1215
1220
|
* ```typescript
|
|
1216
1221
|
* {
|
|
1217
1222
|
* role_id: 'role_456'
|
|
1218
1223
|
* }
|
|
1219
1224
|
* ```
|
|
1220
1225
|
*
|
|
1226
|
+
* @example
|
|
1227
|
+
* By role name:
|
|
1228
|
+
* ```typescript
|
|
1229
|
+
* {
|
|
1230
|
+
* role_name: 'owner'
|
|
1231
|
+
* }
|
|
1232
|
+
* ```
|
|
1233
|
+
*
|
|
1221
1234
|
* @since 0.7.0
|
|
1222
1235
|
* @public
|
|
1223
1236
|
*/
|
|
1224
1237
|
interface AssignRoleRequest {
|
|
1225
1238
|
/**
|
|
1226
1239
|
* ID of the role to assign to the user
|
|
1240
|
+
* Use either role_id or role_name, not both
|
|
1227
1241
|
*/
|
|
1228
|
-
role_id
|
|
1242
|
+
role_id?: string;
|
|
1243
|
+
/**
|
|
1244
|
+
* Name of the role to assign to the user
|
|
1245
|
+
* Use either role_id or role_name, not both
|
|
1246
|
+
* @example 'owner', 'admin', 'billing_manager'
|
|
1247
|
+
*/
|
|
1248
|
+
role_name?: string;
|
|
1229
1249
|
}
|
|
1230
1250
|
|
|
1231
1251
|
/**
|
|
@@ -1378,18 +1398,42 @@ declare class RolesHandler {
|
|
|
1378
1398
|
* Keto relationship tuples based on the role's permissions. The user
|
|
1379
1399
|
* immediately gains all permissions defined in the role.
|
|
1380
1400
|
*
|
|
1401
|
+
* Supports assignment by either role ID or role name for flexibility.
|
|
1402
|
+
*
|
|
1381
1403
|
* @param userId - ID of user to assign role to
|
|
1382
|
-
* @param request - Assignment request with
|
|
1404
|
+
* @param request - Assignment request with either role_id or role_name
|
|
1383
1405
|
*
|
|
1384
1406
|
* @example
|
|
1407
|
+
* Assign by role ID:
|
|
1385
1408
|
* ```typescript
|
|
1386
|
-
* // Assign billing manager role to user
|
|
1387
1409
|
* await omnibase.permissions.roles.assign('user_123', {
|
|
1388
1410
|
* role_id: 'role_456'
|
|
1389
1411
|
* });
|
|
1412
|
+
* ```
|
|
1413
|
+
*
|
|
1414
|
+
* @example
|
|
1415
|
+
* Assign by role name (system or custom role):
|
|
1416
|
+
* ```typescript
|
|
1417
|
+
* // Assign system role
|
|
1418
|
+
* await omnibase.permissions.roles.assign('user_123', {
|
|
1419
|
+
* role_name: 'owner'
|
|
1420
|
+
* });
|
|
1390
1421
|
*
|
|
1391
|
-
* //
|
|
1392
|
-
*
|
|
1422
|
+
* // Assign custom role
|
|
1423
|
+
* await omnibase.permissions.roles.assign('user_456', {
|
|
1424
|
+
* role_name: 'billing_manager'
|
|
1425
|
+
* });
|
|
1426
|
+
* ```
|
|
1427
|
+
*
|
|
1428
|
+
* @example
|
|
1429
|
+
* Verify permissions after assignment:
|
|
1430
|
+
* ```typescript
|
|
1431
|
+
* await omnibase.permissions.roles.assign('user_123', {
|
|
1432
|
+
* role_name: 'admin'
|
|
1433
|
+
* });
|
|
1434
|
+
*
|
|
1435
|
+
* // User now has all permissions from the admin role
|
|
1436
|
+
* const canManage = await omnibase.permissions.permissions.checkPermission(
|
|
1393
1437
|
* undefined,
|
|
1394
1438
|
* {
|
|
1395
1439
|
* namespace: 'Tenant',
|
|
@@ -1398,7 +1442,7 @@ declare class RolesHandler {
|
|
|
1398
1442
|
* subjectId: 'user_123'
|
|
1399
1443
|
* }
|
|
1400
1444
|
* );
|
|
1401
|
-
* //
|
|
1445
|
+
* // canManage.data.allowed === true
|
|
1402
1446
|
* ```
|
|
1403
1447
|
*/
|
|
1404
1448
|
assign(userId: string, request: AssignRoleRequest): Promise<void>;
|
|
@@ -2314,8 +2358,6 @@ declare class TenantManger {
|
|
|
2314
2358
|
* - Billing subscriptions are cancelled (if applicable)
|
|
2315
2359
|
* - Audit logs for deletion are maintained for compliance
|
|
2316
2360
|
*
|
|
2317
|
-
* @param tenantId - The unique identifier of the tenant to delete
|
|
2318
|
-
*
|
|
2319
2361
|
* @returns Promise resolving to a confirmation message
|
|
2320
2362
|
*
|
|
2321
2363
|
* @throws {Error} When the tenantId parameter is missing or empty
|
|
@@ -2327,8 +2369,6 @@ declare class TenantManger {
|
|
|
2327
2369
|
*
|
|
2328
2370
|
* @example
|
|
2329
2371
|
* ```typescript
|
|
2330
|
-
* const tenantToDelete = 'tenant_abc123';
|
|
2331
|
-
*
|
|
2332
2372
|
* // Always confirm before deleting
|
|
2333
2373
|
* const userConfirmed = confirm(
|
|
2334
2374
|
* 'Are you sure you want to delete this tenant? This action cannot be undone.'
|
|
@@ -2336,7 +2376,7 @@ declare class TenantManger {
|
|
|
2336
2376
|
*
|
|
2337
2377
|
* if (userConfirmed) {
|
|
2338
2378
|
* try {
|
|
2339
|
-
* const result = await tenantManager.deleteTenant(
|
|
2379
|
+
* const result = await tenantManager.deleteTenant();
|
|
2340
2380
|
* console.log(result.data.message);
|
|
2341
2381
|
*
|
|
2342
2382
|
* // Redirect user away from deleted tenant
|
|
@@ -2351,7 +2391,7 @@ declare class TenantManger {
|
|
|
2351
2391
|
* @public
|
|
2352
2392
|
* @group Tenant Management
|
|
2353
2393
|
*/
|
|
2354
|
-
deleteTenant(
|
|
2394
|
+
deleteTenant(): Promise<DeleteTenantResponse>;
|
|
2355
2395
|
/**
|
|
2356
2396
|
* Switches the user's active tenant context
|
|
2357
2397
|
*
|
|
@@ -52,9 +52,12 @@ var RolesHandler = class {
|
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
54
|
async getDefinitions() {
|
|
55
|
-
const response = await this.client.fetch(
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
const response = await this.client.fetch(
|
|
56
|
+
"/api/v1/permissions/definitions",
|
|
57
|
+
{
|
|
58
|
+
method: "GET"
|
|
59
|
+
}
|
|
60
|
+
);
|
|
58
61
|
const data = await response.json();
|
|
59
62
|
if (!response.ok || data.error) {
|
|
60
63
|
throw new Error(data.error || "Failed to fetch definitions");
|
|
@@ -81,7 +84,7 @@ var RolesHandler = class {
|
|
|
81
84
|
* ```
|
|
82
85
|
*/
|
|
83
86
|
async list() {
|
|
84
|
-
const response = await this.client.fetch("/api/v1/
|
|
87
|
+
const response = await this.client.fetch("/api/v1/permissions/roles", {
|
|
85
88
|
method: "GET"
|
|
86
89
|
});
|
|
87
90
|
const data = await response.json();
|
|
@@ -127,7 +130,7 @@ var RolesHandler = class {
|
|
|
127
130
|
* ```
|
|
128
131
|
*/
|
|
129
132
|
async create(request) {
|
|
130
|
-
const response = await this.client.fetch("/api/v1/
|
|
133
|
+
const response = await this.client.fetch("/api/v1/permissions/roles", {
|
|
131
134
|
method: "POST",
|
|
132
135
|
headers: { "Content-Type": "application/json" },
|
|
133
136
|
body: JSON.stringify(request)
|
|
@@ -163,11 +166,14 @@ var RolesHandler = class {
|
|
|
163
166
|
* ```
|
|
164
167
|
*/
|
|
165
168
|
async update(roleId, request) {
|
|
166
|
-
const response = await this.client.fetch(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
const response = await this.client.fetch(
|
|
170
|
+
`/api/v1/permissions/roles/${roleId}`,
|
|
171
|
+
{
|
|
172
|
+
method: "PUT",
|
|
173
|
+
headers: { "Content-Type": "application/json" },
|
|
174
|
+
body: JSON.stringify(request)
|
|
175
|
+
}
|
|
176
|
+
);
|
|
171
177
|
const data = await response.json();
|
|
172
178
|
if (!response.ok || data.error) {
|
|
173
179
|
throw new Error(data.error || "Failed to update role");
|
|
@@ -189,9 +195,12 @@ var RolesHandler = class {
|
|
|
189
195
|
* ```
|
|
190
196
|
*/
|
|
191
197
|
async delete(roleId) {
|
|
192
|
-
const response = await this.client.fetch(
|
|
193
|
-
|
|
194
|
-
|
|
198
|
+
const response = await this.client.fetch(
|
|
199
|
+
`/api/v1/permissions/roles/${roleId}`,
|
|
200
|
+
{
|
|
201
|
+
method: "DELETE"
|
|
202
|
+
}
|
|
203
|
+
);
|
|
195
204
|
const data = await response.json();
|
|
196
205
|
if (!response.ok || data.error) {
|
|
197
206
|
throw new Error(data.error || "Failed to delete role");
|
|
@@ -204,18 +213,42 @@ var RolesHandler = class {
|
|
|
204
213
|
* Keto relationship tuples based on the role's permissions. The user
|
|
205
214
|
* immediately gains all permissions defined in the role.
|
|
206
215
|
*
|
|
216
|
+
* Supports assignment by either role ID or role name for flexibility.
|
|
217
|
+
*
|
|
207
218
|
* @param userId - ID of user to assign role to
|
|
208
|
-
* @param request - Assignment request with
|
|
219
|
+
* @param request - Assignment request with either role_id or role_name
|
|
209
220
|
*
|
|
210
221
|
* @example
|
|
222
|
+
* Assign by role ID:
|
|
211
223
|
* ```typescript
|
|
212
|
-
* // Assign billing manager role to user
|
|
213
224
|
* await omnibase.permissions.roles.assign('user_123', {
|
|
214
225
|
* role_id: 'role_456'
|
|
215
226
|
* });
|
|
227
|
+
* ```
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* Assign by role name (system or custom role):
|
|
231
|
+
* ```typescript
|
|
232
|
+
* // Assign system role
|
|
233
|
+
* await omnibase.permissions.roles.assign('user_123', {
|
|
234
|
+
* role_name: 'owner'
|
|
235
|
+
* });
|
|
236
|
+
*
|
|
237
|
+
* // Assign custom role
|
|
238
|
+
* await omnibase.permissions.roles.assign('user_456', {
|
|
239
|
+
* role_name: 'billing_manager'
|
|
240
|
+
* });
|
|
241
|
+
* ```
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* Verify permissions after assignment:
|
|
245
|
+
* ```typescript
|
|
246
|
+
* await omnibase.permissions.roles.assign('user_123', {
|
|
247
|
+
* role_name: 'admin'
|
|
248
|
+
* });
|
|
216
249
|
*
|
|
217
|
-
* // User now has all permissions from the role
|
|
218
|
-
* const
|
|
250
|
+
* // User now has all permissions from the admin role
|
|
251
|
+
* const canManage = await omnibase.permissions.permissions.checkPermission(
|
|
219
252
|
* undefined,
|
|
220
253
|
* {
|
|
221
254
|
* namespace: 'Tenant',
|
|
@@ -224,12 +257,12 @@ var RolesHandler = class {
|
|
|
224
257
|
* subjectId: 'user_123'
|
|
225
258
|
* }
|
|
226
259
|
* );
|
|
227
|
-
* //
|
|
260
|
+
* // canManage.data.allowed === true
|
|
228
261
|
* ```
|
|
229
262
|
*/
|
|
230
263
|
async assign(userId, request) {
|
|
231
264
|
const response = await this.client.fetch(
|
|
232
|
-
`/api/v1/
|
|
265
|
+
`/api/v1/permissions/users/${userId}/roles`,
|
|
233
266
|
{
|
|
234
267
|
method: "POST",
|
|
235
268
|
headers: { "Content-Type": "application/json" },
|
package/dist/tenants/index.cjs
CHANGED
|
@@ -303,8 +303,6 @@ var TenantManger = class {
|
|
|
303
303
|
* - Billing subscriptions are cancelled (if applicable)
|
|
304
304
|
* - Audit logs for deletion are maintained for compliance
|
|
305
305
|
*
|
|
306
|
-
* @param tenantId - The unique identifier of the tenant to delete
|
|
307
|
-
*
|
|
308
306
|
* @returns Promise resolving to a confirmation message
|
|
309
307
|
*
|
|
310
308
|
* @throws {Error} When the tenantId parameter is missing or empty
|
|
@@ -316,8 +314,6 @@ var TenantManger = class {
|
|
|
316
314
|
*
|
|
317
315
|
* @example
|
|
318
316
|
* ```typescript
|
|
319
|
-
* const tenantToDelete = 'tenant_abc123';
|
|
320
|
-
*
|
|
321
317
|
* // Always confirm before deleting
|
|
322
318
|
* const userConfirmed = confirm(
|
|
323
319
|
* 'Are you sure you want to delete this tenant? This action cannot be undone.'
|
|
@@ -325,7 +321,7 @@ var TenantManger = class {
|
|
|
325
321
|
*
|
|
326
322
|
* if (userConfirmed) {
|
|
327
323
|
* try {
|
|
328
|
-
* const result = await tenantManager.deleteTenant(
|
|
324
|
+
* const result = await tenantManager.deleteTenant();
|
|
329
325
|
* console.log(result.data.message);
|
|
330
326
|
*
|
|
331
327
|
* // Redirect user away from deleted tenant
|
|
@@ -340,21 +336,15 @@ var TenantManger = class {
|
|
|
340
336
|
* @public
|
|
341
337
|
* @group Tenant Management
|
|
342
338
|
*/
|
|
343
|
-
async deleteTenant(
|
|
344
|
-
if (!tenantId) {
|
|
345
|
-
throw new Error("Tenant ID is required");
|
|
346
|
-
}
|
|
339
|
+
async deleteTenant() {
|
|
347
340
|
try {
|
|
348
|
-
const response = await this.omnibaseClient.fetch(
|
|
349
|
-
|
|
350
|
-
{
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
credentials: "include"
|
|
356
|
-
}
|
|
357
|
-
);
|
|
341
|
+
const response = await this.omnibaseClient.fetch(`/api/v1/tenants`, {
|
|
342
|
+
method: "DELETE",
|
|
343
|
+
headers: {
|
|
344
|
+
"Content-Type": "application/json"
|
|
345
|
+
},
|
|
346
|
+
credentials: "include"
|
|
347
|
+
});
|
|
358
348
|
if (!response.ok) {
|
|
359
349
|
const errorData = await response.text();
|
|
360
350
|
throw new Error(
|
package/dist/tenants/index.js
CHANGED