@goplusvn/core 0.1.1 → 0.1.3
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/package.json +31 -175
- package/dist/audit/index.d.mts +0 -115
- package/dist/audit/index.d.ts +0 -115
- package/dist/audit/index.js +0 -204
- package/dist/audit/index.js.map +0 -1
- package/dist/audit/index.mjs +0 -200
- package/dist/audit/index.mjs.map +0 -1
- package/dist/auth/index.d.mts +0 -86
- package/dist/auth/index.d.ts +0 -86
- package/dist/auth/index.js +0 -210
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/index.mjs +0 -198
- package/dist/auth/index.mjs.map +0 -1
- package/dist/button-1dWvP9Ib.d.mts +0 -30
- package/dist/button-1dWvP9Ib.d.ts +0 -30
- package/dist/calendar-2QzdEo1z.d.mts +0 -20
- package/dist/calendar-2QzdEo1z.d.ts +0 -20
- package/dist/code-generation/index.d.mts +0 -30
- package/dist/code-generation/index.d.ts +0 -30
- package/dist/code-generation/index.js +0 -31
- package/dist/code-generation/index.js.map +0 -1
- package/dist/code-generation/index.mjs +0 -28
- package/dist/code-generation/index.mjs.map +0 -1
- package/dist/configs/index.d.mts +0 -175
- package/dist/configs/index.d.ts +0 -175
- package/dist/configs/index.js +0 -254
- package/dist/configs/index.js.map +0 -1
- package/dist/configs/index.mjs +0 -233
- package/dist/configs/index.mjs.map +0 -1
- package/dist/crud/index.d.mts +0 -646
- package/dist/crud/index.d.ts +0 -646
- package/dist/crud/index.js +0 -11772
- package/dist/crud/index.js.map +0 -1
- package/dist/crud/index.mjs +0 -11665
- package/dist/crud/index.mjs.map +0 -1
- package/dist/crud/server.d.mts +0 -20
- package/dist/crud/server.d.ts +0 -20
- package/dist/crud/server.js +0 -123
- package/dist/crud/server.js.map +0 -1
- package/dist/crud/server.mjs +0 -120
- package/dist/crud/server.mjs.map +0 -1
- package/dist/data-table-skeleton-12NA8Mjx.d.mts +0 -39
- package/dist/data-table-skeleton-12NA8Mjx.d.ts +0 -39
- package/dist/dialog-bKfjZMTd.d.mts +0 -22
- package/dist/dialog-bKfjZMTd.d.ts +0 -22
- package/dist/dynamic-icon-DrGIiu2N.d.mts +0 -10
- package/dist/dynamic-icon-DrGIiu2N.d.ts +0 -10
- package/dist/home/index.d.mts +0 -269
- package/dist/home/index.d.ts +0 -269
- package/dist/home/index.js +0 -1678
- package/dist/home/index.js.map +0 -1
- package/dist/home/index.mjs +0 -1635
- package/dist/home/index.mjs.map +0 -1
- package/dist/hooks/index.d.mts +0 -7
- package/dist/hooks/index.d.ts +0 -7
- package/dist/hooks/index.js +0 -8316
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/index.mjs +0 -8255
- package/dist/hooks/index.mjs.map +0 -1
- package/dist/index-50hpiPrV.d.ts +0 -116
- package/dist/index-B9zQVEVi.d.mts +0 -116
- package/dist/index.d.mts +0 -5
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -123
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -118
- package/dist/index.mjs.map +0 -1
- package/dist/infrastructure/index.d.mts +0 -423
- package/dist/infrastructure/index.d.ts +0 -423
- package/dist/infrastructure/index.js +0 -633
- package/dist/infrastructure/index.js.map +0 -1
- package/dist/infrastructure/index.mjs +0 -619
- package/dist/infrastructure/index.mjs.map +0 -1
- package/dist/label-DWTEkNPo.d.ts +0 -226
- package/dist/label-LPpdcoBx.d.mts +0 -226
- package/dist/layout/index.d.mts +0 -48
- package/dist/layout/index.d.ts +0 -48
- package/dist/layout/index.js +0 -117
- package/dist/layout/index.js.map +0 -1
- package/dist/layout/index.mjs +0 -90
- package/dist/layout/index.mjs.map +0 -1
- package/dist/navigation/index.d.mts +0 -16
- package/dist/navigation/index.d.ts +0 -16
- package/dist/navigation/index.js +0 -53
- package/dist/navigation/index.js.map +0 -1
- package/dist/navigation/index.mjs +0 -50
- package/dist/navigation/index.mjs.map +0 -1
- package/dist/notification/index.d.mts +0 -105
- package/dist/notification/index.d.ts +0 -105
- package/dist/notification/index.js +0 -278
- package/dist/notification/index.js.map +0 -1
- package/dist/notification/index.mjs +0 -274
- package/dist/notification/index.mjs.map +0 -1
- package/dist/organization/index.d.mts +0 -99
- package/dist/organization/index.d.ts +0 -99
- package/dist/organization/index.js +0 -360
- package/dist/organization/index.js.map +0 -1
- package/dist/organization/index.mjs +0 -352
- package/dist/organization/index.mjs.map +0 -1
- package/dist/plugin/index.d.mts +0 -83
- package/dist/plugin/index.d.ts +0 -83
- package/dist/plugin/index.js +0 -86
- package/dist/plugin/index.js.map +0 -1
- package/dist/plugin/index.mjs +0 -84
- package/dist/plugin/index.mjs.map +0 -1
- package/dist/providers/index.d.mts +0 -25
- package/dist/providers/index.d.ts +0 -25
- package/dist/providers/index.js +0 -84
- package/dist/providers/index.js.map +0 -1
- package/dist/providers/index.mjs +0 -77
- package/dist/providers/index.mjs.map +0 -1
- package/dist/rbac/index.d.mts +0 -226
- package/dist/rbac/index.d.ts +0 -226
- package/dist/rbac/index.js +0 -4784
- package/dist/rbac/index.js.map +0 -1
- package/dist/rbac/index.mjs +0 -4722
- package/dist/rbac/index.mjs.map +0 -1
- package/dist/rbac/permissions.d.mts +0 -26
- package/dist/rbac/permissions.d.ts +0 -26
- package/dist/rbac/permissions.js +0 -94
- package/dist/rbac/permissions.js.map +0 -1
- package/dist/rbac/permissions.mjs +0 -90
- package/dist/rbac/permissions.mjs.map +0 -1
- package/dist/rbac/server.d.mts +0 -1
- package/dist/rbac/server.d.ts +0 -1
- package/dist/rbac/server.js +0 -128
- package/dist/rbac/server.js.map +0 -1
- package/dist/rbac/server.mjs +0 -124
- package/dist/rbac/server.mjs.map +0 -1
- package/dist/schemas/index.d.mts +0 -1257
- package/dist/schemas/index.d.ts +0 -1257
- package/dist/schemas/index.js +0 -572
- package/dist/schemas/index.js.map +0 -1
- package/dist/schemas/index.mjs +0 -523
- package/dist/schemas/index.mjs.map +0 -1
- package/dist/server-QuYCTa89.d.mts +0 -83
- package/dist/server-QuYCTa89.d.ts +0 -83
- package/dist/sonner-C74GlRDQ.d.mts +0 -71
- package/dist/sonner-C74GlRDQ.d.ts +0 -71
- package/dist/status-BOXZgIqX.d.mts +0 -12
- package/dist/status-BOXZgIqX.d.ts +0 -12
- package/dist/system/index.d.mts +0 -77
- package/dist/system/index.d.ts +0 -77
- package/dist/system/index.js +0 -102
- package/dist/system/index.js.map +0 -1
- package/dist/system/index.mjs +0 -100
- package/dist/system/index.mjs.map +0 -1
- package/dist/tabs-C6FfBwPY.d.mts +0 -18
- package/dist/tabs-C6FfBwPY.d.ts +0 -18
- package/dist/tenant-provider-B8eC_Wpb.d.mts +0 -27
- package/dist/tenant-provider-B8eC_Wpb.d.ts +0 -27
- package/dist/types/index.d.mts +0 -469
- package/dist/types/index.d.ts +0 -469
- package/dist/types/index.js +0 -25
- package/dist/types/index.js.map +0 -1
- package/dist/types/index.mjs +0 -21
- package/dist/types/index.mjs.map +0 -1
- package/dist/ui/auth.d.mts +0 -39
- package/dist/ui/auth.d.ts +0 -39
- package/dist/ui/auth.js +0 -4941
- package/dist/ui/auth.js.map +0 -1
- package/dist/ui/auth.mjs +0 -4896
- package/dist/ui/auth.mjs.map +0 -1
- package/dist/ui/crud.d.mts +0 -2
- package/dist/ui/crud.d.ts +0 -2
- package/dist/ui/crud.js +0 -4
- package/dist/ui/crud.js.map +0 -1
- package/dist/ui/crud.mjs +0 -3
- package/dist/ui/crud.mjs.map +0 -1
- package/dist/ui/data-display.d.mts +0 -596
- package/dist/ui/data-display.d.ts +0 -596
- package/dist/ui/data-display.js +0 -5307
- package/dist/ui/data-display.js.map +0 -1
- package/dist/ui/data-display.mjs +0 -5212
- package/dist/ui/data-display.mjs.map +0 -1
- package/dist/ui/feedback.d.mts +0 -55
- package/dist/ui/feedback.d.ts +0 -55
- package/dist/ui/feedback.js +0 -2608
- package/dist/ui/feedback.js.map +0 -1
- package/dist/ui/feedback.mjs +0 -2526
- package/dist/ui/feedback.mjs.map +0 -1
- package/dist/ui/forms.d.mts +0 -309
- package/dist/ui/forms.d.ts +0 -309
- package/dist/ui/forms.js +0 -4656
- package/dist/ui/forms.js.map +0 -1
- package/dist/ui/forms.mjs +0 -4571
- package/dist/ui/forms.mjs.map +0 -1
- package/dist/ui/index.d.mts +0 -331
- package/dist/ui/index.d.ts +0 -331
- package/dist/ui/index.js +0 -16953
- package/dist/ui/index.js.map +0 -1
- package/dist/ui/index.mjs +0 -16598
- package/dist/ui/index.mjs.map +0 -1
- package/dist/ui/primitives/client.d.mts +0 -61
- package/dist/ui/primitives/client.d.ts +0 -61
- package/dist/ui/primitives/client.js +0 -3408
- package/dist/ui/primitives/client.js.map +0 -1
- package/dist/ui/primitives/client.mjs +0 -3256
- package/dist/ui/primitives/client.mjs.map +0 -1
- package/dist/ui/primitives.d.mts +0 -113
- package/dist/ui/primitives.d.ts +0 -113
- package/dist/ui/primitives.js +0 -3356
- package/dist/ui/primitives.js.map +0 -1
- package/dist/ui/primitives.mjs +0 -3227
- package/dist/ui/primitives.mjs.map +0 -1
- package/dist/user/index.d.mts +0 -228
- package/dist/user/index.d.ts +0 -228
- package/dist/user/index.js +0 -4306
- package/dist/user/index.js.map +0 -1
- package/dist/user/index.mjs +0 -4260
- package/dist/user/index.mjs.map +0 -1
- package/dist/utils/index.d.mts +0 -205
- package/dist/utils/index.d.ts +0 -205
- package/dist/utils/index.js +0 -574
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/index.mjs +0 -514
- package/dist/utils/index.mjs.map +0 -1
- package/dist/workflow/index.d.mts +0 -40
- package/dist/workflow/index.d.ts +0 -40
- package/dist/workflow/index.js +0 -3710
- package/dist/workflow/index.js.map +0 -1
- package/dist/workflow/index.mjs +0 -3677
- package/dist/workflow/index.mjs.map +0 -1
package/dist/plugin/index.mjs
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
// src/plugin/apps-registry.ts
|
|
2
|
-
var AppsRegistry = class {
|
|
3
|
-
constructor() {
|
|
4
|
-
this.apps = [];
|
|
5
|
-
this.appsById = /* @__PURE__ */ new Map();
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Register an app. Later registrations override earlier entity configs for same entity.
|
|
9
|
-
*/
|
|
10
|
-
register(app) {
|
|
11
|
-
if (this.appsById.has(app.appId)) {
|
|
12
|
-
console.warn(`[AppsRegistry] App "${app.appId}" already registered. Replacing.`);
|
|
13
|
-
}
|
|
14
|
-
this.appsById.set(app.appId, app);
|
|
15
|
-
this.apps = Array.from(this.appsById.values());
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Register multiple apps in order
|
|
19
|
-
*/
|
|
20
|
-
registerAll(apps) {
|
|
21
|
-
for (const app of apps) {
|
|
22
|
-
this.register(app);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Get app by appId
|
|
27
|
-
*/
|
|
28
|
-
getApp(appId) {
|
|
29
|
-
return this.appsById.get(appId);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Get all registered apps
|
|
33
|
-
*/
|
|
34
|
-
getAllApps() {
|
|
35
|
-
return [...this.apps];
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Get merged navigation from all apps (order: registration order)
|
|
39
|
-
* Groups with same title have their items merged
|
|
40
|
-
*/
|
|
41
|
-
getNavigation() {
|
|
42
|
-
const byTitle = /* @__PURE__ */ new Map();
|
|
43
|
-
for (const app of this.apps) {
|
|
44
|
-
for (const group of app.navigation) {
|
|
45
|
-
const existing = byTitle.get(group.title);
|
|
46
|
-
const items = group.items ?? [];
|
|
47
|
-
if (existing) {
|
|
48
|
-
existing.items = [...existing.items ?? [], ...items];
|
|
49
|
-
} else {
|
|
50
|
-
byTitle.set(group.title, { ...group, items: [...items] });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return Array.from(byTitle.values());
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Get entity config for entity key.
|
|
58
|
-
* Later-registered apps override earlier for same entity.
|
|
59
|
-
*/
|
|
60
|
-
getEntityConfig(entity) {
|
|
61
|
-
for (let i = this.apps.length - 1; i >= 0; i--) {
|
|
62
|
-
const config = this.apps[i].entityConfigs[entity];
|
|
63
|
-
if (config) return config;
|
|
64
|
-
}
|
|
65
|
-
return void 0;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Check if entity exists in any app
|
|
69
|
-
*/
|
|
70
|
-
hasEntity(entity) {
|
|
71
|
-
return this.getEntityConfig(entity) !== void 0;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Clear all registrations (for testing)
|
|
75
|
-
*/
|
|
76
|
-
clear() {
|
|
77
|
-
this.apps = [];
|
|
78
|
-
this.appsById.clear();
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export { AppsRegistry };
|
|
83
|
-
//# sourceMappingURL=index.mjs.map
|
|
84
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugin/apps-registry.ts"],"names":[],"mappings":";AAWO,IAAM,eAAN,MAAmB;AAAA,EAAnB,WAAA,GAAA;AACL,IAAA,IAAA,CAAQ,OAAmB,EAAC;AAC5B,IAAA,IAAA,CAAQ,QAAA,uBAAe,GAAA,EAAsB;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAK7C,SAAS,GAAA,EAAqB;AAC5B,IAAA,IAAI,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,GAAA,CAAI,KAAK,CAAA,EAAG;AAChC,MAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,oBAAA,EAAuB,GAAA,CAAI,KAAK,CAAA,gCAAA,CAAkC,CAAA;AAAA,IACjF;AACA,IAAA,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,GAAA,CAAI,KAAA,EAAO,GAAG,CAAA;AAChC,IAAA,IAAA,CAAK,OAAO,KAAA,CAAM,IAAA,CAAK,IAAA,C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,MAAA,EAA0C;AACxD,IAAA,KAAA,IAAS,IAAI,IAAA,CAAK,IAAA,CAAK,SAAS,CAAA,EAAG,CAAA,IAAK,GAAG,CAAA,EAAA,EAAK;AAC9C,MAAA,MAAM,SAAS,IAAA,CAAK,IAAA,CAAK,CAAC,CAAA,CAAE,cAAc,MAAM,CAAA;AAChD,MAAA,IAAI,QAAQ,OAAO,MAAA;AAAA,IACrB;AACA,IAAA,OAAO,MAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU,MAAA,EAAyB;AACjC,IAAA,OAAO,IAAA,CAAK,eAAA,CAAgB,MAAM,CAAA,KAAM,MAAA;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA,EAKA,KAAA,GAAc;AACZ,IAAA,IAAA,CAAK,OAAO,EAAC;AACb,IAAA,IAAA,CAAK,SAAS,KAAA,EAAM;AAAA,EACtB;AACF","file":"index.mjs","sourcesContent":["// @goerp/core/plugin\n// AppsRegistry - Central registry for GoerpApp instances\n\nimport type { EntityConfig, NavigationType } from \"../types\"\n\nimport type { GoerpApp } from \"./types\"\n\n/**\n * AppsRegistry - Manages registration and lookup of GoerpApp\n * Host app registers installed apps; registry merges navigation and entity configs\n */\nexport class AppsRegistry {\n private apps: GoerpApp[] = []\n private appsById = new Map<string, GoerpApp>()\n\n /**\n * Register an app. Later registrations override earlier entity configs for same entity.\n */\n register(app: GoerpApp): void {\n if (this.appsById.has(app.appId)) {\n console.warn(`[AppsRegistry] App \"${app.appId}\" already registered. Replacing.`)\n }\n this.appsById.set(app.appId, app)\n this.apps = Array.from(this.appsById.values())\n }\n\n /**\n * Register multiple apps in order\n */\n registerAll(apps: GoerpApp[]): void {\n for (const app of apps) {\n this.register(app)\n }\n }\n\n /**\n * Get app by appId\n */\n getApp(appId: string): GoerpApp | undefined {\n return this.appsById.get(appId)\n }\n\n /**\n * Get all registered apps\n */\n getAllApps(): GoerpApp[] {\n return [...this.apps]\n }\n\n /**\n * Get merged navigation from all apps (order: registration order)\n * Groups with same title have their items merged\n */\n getNavigation(): NavigationType[] {\n const byTitle = new Map<string, NavigationType>()\n\n for (const app of this.apps) {\n for (const group of app.navigation) {\n const existing = byTitle.get(group.title)\n const items = group.items ?? []\n if (existing) {\n existing.items = [...(existing.items ?? []), ...items]\n } else {\n byTitle.set(group.title, { ...group, items: [...items] })\n }\n }\n }\n return Array.from(byTitle.values())\n }\n\n /**\n * Get entity config for entity key.\n * Later-registered apps override earlier for same entity.\n */\n getEntityConfig(entity: string): EntityConfig | undefined {\n for (let i = this.apps.length - 1; i >= 0; i--) {\n const config = this.apps[i].entityConfigs[entity]\n if (config) return config\n }\n return undefined\n }\n\n /**\n * Check if entity exists in any app\n */\n hasEntity(entity: string): boolean {\n return this.getEntityConfig(entity) !== undefined\n }\n\n /**\n * Clear all registrations (for testing)\n */\n clear(): void {\n this.apps = []\n this.appsById.clear()\n }\n}\n"]}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { ReactNode } from 'react';
|
|
4
|
-
import { DirectionType, SettingsType, LocaleType } from '../types/index.mjs';
|
|
5
|
-
export { T as TenantBranding, a as TenantConfig, b as TenantContextValue, c as TenantProvider, u as useTenantContext } from '../tenant-provider-B8eC_Wpb.mjs';
|
|
6
|
-
import 'lucide-react';
|
|
7
|
-
import 'zod';
|
|
8
|
-
|
|
9
|
-
declare const defaultSettings: SettingsType;
|
|
10
|
-
declare const SettingsContext: React.Context<{
|
|
11
|
-
settings: SettingsType;
|
|
12
|
-
updateSettings: (newSettings: SettingsType) => void;
|
|
13
|
-
resetSettings: () => void;
|
|
14
|
-
} | undefined>;
|
|
15
|
-
declare function SettingsProvider({ locale, children, }: {
|
|
16
|
-
locale: LocaleType;
|
|
17
|
-
children: ReactNode;
|
|
18
|
-
}): react_jsx_runtime.JSX.Element;
|
|
19
|
-
interface DirectionProviderProps {
|
|
20
|
-
direction: DirectionType;
|
|
21
|
-
children: React.ReactNode;
|
|
22
|
-
}
|
|
23
|
-
declare function DirectionProvider({ direction, children, }: DirectionProviderProps): react_jsx_runtime.JSX.Element;
|
|
24
|
-
|
|
25
|
-
export { DirectionProvider, SettingsContext, SettingsProvider, defaultSettings };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { ReactNode } from 'react';
|
|
4
|
-
import { DirectionType, SettingsType, LocaleType } from '../types/index.js';
|
|
5
|
-
export { T as TenantBranding, a as TenantConfig, b as TenantContextValue, c as TenantProvider, u as useTenantContext } from '../tenant-provider-B8eC_Wpb.js';
|
|
6
|
-
import 'lucide-react';
|
|
7
|
-
import 'zod';
|
|
8
|
-
|
|
9
|
-
declare const defaultSettings: SettingsType;
|
|
10
|
-
declare const SettingsContext: React.Context<{
|
|
11
|
-
settings: SettingsType;
|
|
12
|
-
updateSettings: (newSettings: SettingsType) => void;
|
|
13
|
-
resetSettings: () => void;
|
|
14
|
-
} | undefined>;
|
|
15
|
-
declare function SettingsProvider({ locale, children, }: {
|
|
16
|
-
locale: LocaleType;
|
|
17
|
-
children: ReactNode;
|
|
18
|
-
}): react_jsx_runtime.JSX.Element;
|
|
19
|
-
interface DirectionProviderProps {
|
|
20
|
-
direction: DirectionType;
|
|
21
|
-
children: React.ReactNode;
|
|
22
|
-
}
|
|
23
|
-
declare function DirectionProvider({ direction, children, }: DirectionProviderProps): react_jsx_runtime.JSX.Element;
|
|
24
|
-
|
|
25
|
-
export { DirectionProvider, SettingsContext, SettingsProvider, defaultSettings };
|
package/dist/providers/index.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var react = require('react');
|
|
4
|
-
var reactUse = require('react-use');
|
|
5
|
-
var reactDirection = require('@radix-ui/react-direction');
|
|
6
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
-
|
|
8
|
-
var TenantContext = react.createContext(void 0);
|
|
9
|
-
function TenantProvider({ children, tenant }) {
|
|
10
|
-
return /* @__PURE__ */ jsxRuntime.jsx(TenantContext.Provider, { value: { tenant }, children });
|
|
11
|
-
}
|
|
12
|
-
function useTenantContext() {
|
|
13
|
-
const context = react.useContext(TenantContext);
|
|
14
|
-
if (context === void 0) {
|
|
15
|
-
throw new Error("useTenantContext must be used within a TenantProvider");
|
|
16
|
-
}
|
|
17
|
-
return context;
|
|
18
|
-
}
|
|
19
|
-
var defaultSettings = {
|
|
20
|
-
theme: "blue",
|
|
21
|
-
mode: "system",
|
|
22
|
-
radius: 0.5,
|
|
23
|
-
layout: "vertical",
|
|
24
|
-
locale: "vi",
|
|
25
|
-
sidebarVariant: "sidebar",
|
|
26
|
-
sidebarCollapsible: "icon",
|
|
27
|
-
density: "comfortable"
|
|
28
|
-
};
|
|
29
|
-
var SettingsContext = react.createContext(void 0);
|
|
30
|
-
function SettingsProvider({
|
|
31
|
-
locale,
|
|
32
|
-
children
|
|
33
|
-
}) {
|
|
34
|
-
const [storedSettings, setStoredSettings, deleteStoredSettings] = reactUse.useCookie("settings");
|
|
35
|
-
const [settings, setSettings] = react.useState(() => ({
|
|
36
|
-
...defaultSettings,
|
|
37
|
-
locale
|
|
38
|
-
}));
|
|
39
|
-
react.useEffect(() => {
|
|
40
|
-
if (storedSettings) {
|
|
41
|
-
try {
|
|
42
|
-
const parsedSettings = JSON.parse(storedSettings);
|
|
43
|
-
setSettings({ ...defaultSettings, ...parsedSettings });
|
|
44
|
-
} catch {
|
|
45
|
-
setSettings({ ...defaultSettings, locale });
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
setSettings({ ...defaultSettings, locale });
|
|
49
|
-
}
|
|
50
|
-
}, [storedSettings, locale]);
|
|
51
|
-
const updateSettings = react.useCallback(
|
|
52
|
-
(newSettings) => {
|
|
53
|
-
setStoredSettings(JSON.stringify(newSettings));
|
|
54
|
-
setSettings(newSettings);
|
|
55
|
-
},
|
|
56
|
-
[setStoredSettings]
|
|
57
|
-
);
|
|
58
|
-
const resetSettings = react.useCallback(() => {
|
|
59
|
-
deleteStoredSettings();
|
|
60
|
-
setSettings(defaultSettings);
|
|
61
|
-
}, [deleteStoredSettings]);
|
|
62
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
63
|
-
SettingsContext.Provider,
|
|
64
|
-
{
|
|
65
|
-
value: { settings, updateSettings, resetSettings },
|
|
66
|
-
children
|
|
67
|
-
}
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
function DirectionProvider({
|
|
71
|
-
direction,
|
|
72
|
-
children
|
|
73
|
-
}) {
|
|
74
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactDirection.DirectionProvider, { dir: direction, children });
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
exports.DirectionProvider = DirectionProvider;
|
|
78
|
-
exports.SettingsContext = SettingsContext;
|
|
79
|
-
exports.SettingsProvider = SettingsProvider;
|
|
80
|
-
exports.TenantProvider = TenantProvider;
|
|
81
|
-
exports.defaultSettings = defaultSettings;
|
|
82
|
-
exports.useTenantContext = useTenantContext;
|
|
83
|
-
//# sourceMappingURL=index.js.map
|
|
84
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/providers/tenant-provider.tsx","../../src/providers/index.tsx"],"names":["createContext","jsx","useContext","useCookie","useState","useEffect","useCallback","RadixDirectionProvider"],"mappings":";;;;;;;AAuBA,IAAM,aAAA,GAAgBA,oBAA8C,MAAS,CAAA;AAOtE,SAAS,cAAA,CAAe,EAAE,QAAA,EAAU,MAAA,EAAO,EAAwB;AACxE,EAAA,uBACEC,cAAA,CAAC,cAAc,QAAA,EAAd,EAAuB,OAAO,EAAE,MAAA,IAC9B,QAAA,EACH,CAAA;AAEJ;AAEO,SAAS,gBAAA,GAAmB;AACjC,EAAA,MAAM,OAAA,GAAUC,iBAAW,a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,EAAA,MAAM,cAAA,GAAiBC,iBAAA;AAAA,IACrB,CAAC,WAAA,KAA8B;AAC7B,MAAA,iBAAA,CAAkB,IAAA,CAAK,SAAA,CAAU,WAAW,CAAC,CAAA;AAC7C,MAAA,WAAA,CAAY,WAAW,CAAA;AAAA,IACzB,CAAA;AAAA,IACA,CAAC,iBAAiB;AAAA,GACpB;AAEA,EAAA,MAAM,aAAA,GAAgBA,kBAAY,MAAM;AACtC,IAAA,oBAAA,EAAqB;AACrB,IAAA,WAAA,CAAY,eAAe,CAAA;AAAA,EAC7B,CAAA,EAAG,CAAC,oBAAoB,CAAC,CAAA;AAEzB,EAAA,uBACEL,cAAAA;AAAA,IAAC,eAAA,CAAgB,QAAA;AAAA,IAAhB;AAAA,MACC,KAAA,EAAO,EAAE,QAAA,EAAU,cAAA,EAAgB,aAAA,EAAc;AAAA,MAEhD;AAAA;AAAA,GACH;AAEJ;AAWO,SAAS,iBAAA,CAAkB;AAAA,EAChC,SAAA;AAAA,EACA;AACF,CAAA,EAA2B;AACzB,EAAA,uBACEA,cAAAA,CAACM,gCAAA,EAAA,EAAuB,GAAA,EAAK,WAAY,QAAA,EAAS,CAAA;AAEtD","file":"index.js","sourcesContent":["import type { ReactNode } from \"react\";\nimport React, { createContext, useContext } from \"react\";\n\nexport interface TenantBranding {\n logo?: string;\n companyName: string;\n primaryColor?: string;\n favicon?: string;\n}\n\nexport interface TenantConfig {\n id: string;\n name: string;\n branding: TenantBranding;\n // Add more tenant-specific configs here (e.g., date formats, currency)\n dateFormat?: string;\n currency?: string;\n}\n\nexport interface TenantContextValue {\n tenant: TenantConfig;\n}\n\nconst TenantContext = createContext<TenantContextValue | undefined>(undefined);\n\ninterface TenantProviderProps {\n children: ReactNode;\n tenant: TenantConfig;\n}\n\nexport function TenantProvider({ children, tenant }: TenantProviderProps) {\n return (\n <TenantContext.Provider value={{ tenant }}>\n {children}\n </TenantContext.Provider>\n );\n}\n\nexport function useTenantContext() {\n const context = useContext(TenantContext);\n if (context === undefined) {\n throw new Error(\"useTenantContext must be used within a TenantProvider\");\n }\n return context;\n}\n","// @goerp/core/providers\n// Core React context providers for GoERP platform\n// Consolidated from packages/shared/providers\n\n\"use client\";\n\nimport * as React from \"react\";\nimport { createContext, useCallback, useEffect, useState } from \"react\";\nimport { useCookie } from \"react-use\";\nimport { DirectionProvider as RadixDirectionProvider } from \"@radix-ui/react-direction\";\n\nimport type { LocaleType, SettingsType, DirectionType } from \"../types\";\nimport type { ReactNode } from \"react\";\n\n// ============================================================================\n// Settings Provider\n// ============================================================================\n\nexport const defaultSettings: SettingsType = {\n theme: \"blue\",\n mode: \"system\",\n radius: 0.5,\n layout: \"vertical\",\n locale: \"vi\",\n sidebarVariant: \"sidebar\",\n sidebarCollapsible: \"icon\",\n density: \"comfortable\",\n};\n\nexport const SettingsContext = createContext<\n | {\n settings: SettingsType;\n updateSettings: (newSettings: SettingsType) => void;\n resetSettings: () => void;\n }\n | undefined\n>(undefined);\n\nexport function SettingsProvider({\n locale,\n children,\n}: {\n locale: LocaleType;\n children: ReactNode;\n}) {\n const [storedSettings, setStoredSettings, deleteStoredSettings] =\n useCookie(\"settings\");\n const [settings, setSettings] = useState<SettingsType>(() => ({\n ...defaultSettings,\n locale,\n }));\n\n useEffect(() => {\n if (storedSettings) {\n try {\n const parsedSettings = JSON.parse(storedSettings);\n setSettings({ ...defaultSettings, ...parsedSettings });\n } catch {\n setSettings({ ...defaultSettings, locale });\n }\n } else {\n setSettings({ ...defaultSettings, locale });\n }\n }, [storedSettings, locale]);\n\n const updateSettings = useCallback(\n (newSettings: SettingsType) => {\n setStoredSettings(JSON.stringify(newSettings));\n setSettings(newSettings);\n },\n [setStoredSettings],\n );\n\n const resetSettings = useCallback(() => {\n deleteStoredSettings();\n setSettings(defaultSettings);\n }, [deleteStoredSettings]);\n\n return (\n <SettingsContext.Provider\n value={{ settings, updateSettings, resetSettings }}\n >\n {children}\n </SettingsContext.Provider>\n );\n}\n\n// ============================================================================\n// Direction Provider\n// ============================================================================\n\ninterface DirectionProviderProps {\n direction: DirectionType;\n children: React.ReactNode;\n}\n\nexport function DirectionProvider({\n direction,\n children,\n}: DirectionProviderProps) {\n return (\n <RadixDirectionProvider dir={direction}>{children}</RadixDirectionProvider>\n );\n}\n// ============================================================================\n// Tenant Provider\n// ============================================================================\n\nexport * from \"./tenant-provider\";\n"]}
|
package/dist/providers/index.mjs
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext, useState, useEffect, useCallback } from 'react';
|
|
2
|
-
import { useCookie } from 'react-use';
|
|
3
|
-
import { DirectionProvider as DirectionProvider$1 } from '@radix-ui/react-direction';
|
|
4
|
-
import { jsx } from 'react/jsx-runtime';
|
|
5
|
-
|
|
6
|
-
var TenantContext = createContext(void 0);
|
|
7
|
-
function TenantProvider({ children, tenant }) {
|
|
8
|
-
return /* @__PURE__ */ jsx(TenantContext.Provider, { value: { tenant }, children });
|
|
9
|
-
}
|
|
10
|
-
function useTenantContext() {
|
|
11
|
-
const context = useContext(TenantContext);
|
|
12
|
-
if (context === void 0) {
|
|
13
|
-
throw new Error("useTenantContext must be used within a TenantProvider");
|
|
14
|
-
}
|
|
15
|
-
return context;
|
|
16
|
-
}
|
|
17
|
-
var defaultSettings = {
|
|
18
|
-
theme: "blue",
|
|
19
|
-
mode: "system",
|
|
20
|
-
radius: 0.5,
|
|
21
|
-
layout: "vertical",
|
|
22
|
-
locale: "vi",
|
|
23
|
-
sidebarVariant: "sidebar",
|
|
24
|
-
sidebarCollapsible: "icon",
|
|
25
|
-
density: "comfortable"
|
|
26
|
-
};
|
|
27
|
-
var SettingsContext = createContext(void 0);
|
|
28
|
-
function SettingsProvider({
|
|
29
|
-
locale,
|
|
30
|
-
children
|
|
31
|
-
}) {
|
|
32
|
-
const [storedSettings, setStoredSettings, deleteStoredSettings] = useCookie("settings");
|
|
33
|
-
const [settings, setSettings] = useState(() => ({
|
|
34
|
-
...defaultSettings,
|
|
35
|
-
locale
|
|
36
|
-
}));
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
if (storedSettings) {
|
|
39
|
-
try {
|
|
40
|
-
const parsedSettings = JSON.parse(storedSettings);
|
|
41
|
-
setSettings({ ...defaultSettings, ...parsedSettings });
|
|
42
|
-
} catch {
|
|
43
|
-
setSettings({ ...defaultSettings, locale });
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
setSettings({ ...defaultSettings, locale });
|
|
47
|
-
}
|
|
48
|
-
}, [storedSettings, locale]);
|
|
49
|
-
const updateSettings = useCallback(
|
|
50
|
-
(newSettings) => {
|
|
51
|
-
setStoredSettings(JSON.stringify(newSettings));
|
|
52
|
-
setSettings(newSettings);
|
|
53
|
-
},
|
|
54
|
-
[setStoredSettings]
|
|
55
|
-
);
|
|
56
|
-
const resetSettings = useCallback(() => {
|
|
57
|
-
deleteStoredSettings();
|
|
58
|
-
setSettings(defaultSettings);
|
|
59
|
-
}, [deleteStoredSettings]);
|
|
60
|
-
return /* @__PURE__ */ jsx(
|
|
61
|
-
SettingsContext.Provider,
|
|
62
|
-
{
|
|
63
|
-
value: { settings, updateSettings, resetSettings },
|
|
64
|
-
children
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
function DirectionProvider({
|
|
69
|
-
direction,
|
|
70
|
-
children
|
|
71
|
-
}) {
|
|
72
|
-
return /* @__PURE__ */ jsx(DirectionProvider$1, { dir: direction, children });
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export { DirectionProvider, SettingsContext, SettingsProvider, TenantProvider, defaultSettings, useTenantContext };
|
|
76
|
-
//# sourceMappingURL=index.mjs.map
|
|
77
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/providers/tenant-provider.tsx","../../src/providers/index.tsx"],"names":["createContext","jsx","RadixDirectionProvider"],"mappings":";;;;;AAuBA,IAAM,aAAA,GAAgB,cAA8C,MAAS,CAAA;AAOtE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AG,eAAA,EAAiB,MAAA,EAAQ,CAAA;AAAA,MAC5C;AAAA,IACF,CAAA,MAAO;AACL,MAAA,WAAA,CAAY,EAAE,GAAG,eAAA,EAAiB,MAAA,EAAQ,CAAA;AAAA,IAC5C;AAAA,EACF,CAAA,EAAG,CAAC,cAAA,EAAgB,MAAM,CAAC,CAAA;AAE3B,EAAA,MAAM,cAAA,GAAiB,WAAA;AAAA,IACrB,CAAC,WAAA,KAA8B;AAC7B,MAAA,iBAAA,CAAkB,IAAA,CAAK,SAAA,CAAU,WAAW,CAAC,CAAA;AAC7C,MAAA,WAAA,CAAY,WAAW,CAAA;AAAA,IACzB,CAAA;AAAA,IACA,CAAC,iBAAiB;AAAA,GACpB;AAEA,EAAA,MAAM,aAAA,GAAgB,YAAY,MAAM;AACtC,IAAA,oBAAA,EAAqB;AACrB,IAAA,WAAA,CAAY,eAAe,CAAA;AAAA,EAC7B,CAAA,EAAG,CAAC,oBAAoB,CAAC,CAAA;AAEzB,EAAA,uBACEC,GAAAA;AAAA,IAAC,eAAA,CAAgB,QAAA;AAAA,IAAhB;AAAA,MACC,KAAA,EAAO,EAAE,QAAA,EAAU,cAAA,EAAgB,aAAA,EAAc;AAAA,MAEhD;AAAA;AAAA,GACH;AAEJ;AAWO,SAAS,iBAAA,CAAkB;AAAA,EAChC,SAAA;AAAA,EACA;AACF,CAAA,EAA2B;AACzB,EAAA,uBACEA,GAAAA,CAACC,mBAAA,EAAA,EAAuB,GAAA,EAAK,WAAY,QAAA,EAAS,CAAA;AAEtD","file":"index.mjs","sourcesContent":["import type { ReactNode } from \"react\";\nimport React, { createContext, useContext } from \"react\";\n\nexport interface TenantBranding {\n logo?: string;\n companyName: string;\n primaryColor?: string;\n favicon?: string;\n}\n\nexport interface TenantConfig {\n id: string;\n name: string;\n branding: TenantBranding;\n // Add more tenant-specific configs here (e.g., date formats, currency)\n dateFormat?: string;\n currency?: string;\n}\n\nexport interface TenantContextValue {\n tenant: TenantConfig;\n}\n\nconst TenantContext = createContext<TenantContextValue | undefined>(undefined);\n\ninterface TenantProviderProps {\n children: ReactNode;\n tenant: TenantConfig;\n}\n\nexport function TenantProvider({ children, tenant }: TenantProviderProps) {\n return (\n <TenantContext.Provider value={{ tenant }}>\n {children}\n </TenantContext.Provider>\n );\n}\n\nexport function useTenantContext() {\n const context = useContext(TenantContext);\n if (context === undefined) {\n throw new Error(\"useTenantContext must be used within a TenantProvider\");\n }\n return context;\n}\n","// @goerp/core/providers\n// Core React context providers for GoERP platform\n// Consolidated from packages/shared/providers\n\n\"use client\";\n\nimport * as React from \"react\";\nimport { createContext, useCallback, useEffect, useState } from \"react\";\nimport { useCookie } from \"react-use\";\nimport { DirectionProvider as RadixDirectionProvider } from \"@radix-ui/react-direction\";\n\nimport type { LocaleType, SettingsType, DirectionType } from \"../types\";\nimport type { ReactNode } from \"react\";\n\n// ============================================================================\n// Settings Provider\n// ============================================================================\n\nexport const defaultSettings: SettingsType = {\n theme: \"blue\",\n mode: \"system\",\n radius: 0.5,\n layout: \"vertical\",\n locale: \"vi\",\n sidebarVariant: \"sidebar\",\n sidebarCollapsible: \"icon\",\n density: \"comfortable\",\n};\n\nexport const SettingsContext = createContext<\n | {\n settings: SettingsType;\n updateSettings: (newSettings: SettingsType) => void;\n resetSettings: () => void;\n }\n | undefined\n>(undefined);\n\nexport function SettingsProvider({\n locale,\n children,\n}: {\n locale: LocaleType;\n children: ReactNode;\n}) {\n const [storedSettings, setStoredSettings, deleteStoredSettings] =\n useCookie(\"settings\");\n const [settings, setSettings] = useState<SettingsType>(() => ({\n ...defaultSettings,\n locale,\n }));\n\n useEffect(() => {\n if (storedSettings) {\n try {\n const parsedSettings = JSON.parse(storedSettings);\n setSettings({ ...defaultSettings, ...parsedSettings });\n } catch {\n setSettings({ ...defaultSettings, locale });\n }\n } else {\n setSettings({ ...defaultSettings, locale });\n }\n }, [storedSettings, locale]);\n\n const updateSettings = useCallback(\n (newSettings: SettingsType) => {\n setStoredSettings(JSON.stringify(newSettings));\n setSettings(newSettings);\n },\n [setStoredSettings],\n );\n\n const resetSettings = useCallback(() => {\n deleteStoredSettings();\n setSettings(defaultSettings);\n }, [deleteStoredSettings]);\n\n return (\n <SettingsContext.Provider\n value={{ settings, updateSettings, resetSettings }}\n >\n {children}\n </SettingsContext.Provider>\n );\n}\n\n// ============================================================================\n// Direction Provider\n// ============================================================================\n\ninterface DirectionProviderProps {\n direction: DirectionType;\n children: React.ReactNode;\n}\n\nexport function DirectionProvider({\n direction,\n children,\n}: DirectionProviderProps) {\n return (\n <RadixDirectionProvider dir={direction}>{children}</RadixDirectionProvider>\n );\n}\n// ============================================================================\n// Tenant Provider\n// ============================================================================\n\nexport * from \"./tenant-provider\";\n"]}
|
package/dist/rbac/index.d.mts
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import { Permission, CrudPermissions } from '../types/index.mjs';
|
|
2
|
-
import { Session } from 'next-auth';
|
|
3
|
-
export { R as ResourcePrismaClient, a as RoleData, b as RoleFilters, c as RolePrismaClient, g as getActionsForPermissionMatrix, d as getResourcesData, e as getResourcesForPermissionMatrix, f as getRolesData } from '../server-QuYCTa89.mjs';
|
|
4
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
-
import 'lucide-react';
|
|
6
|
-
import 'react';
|
|
7
|
-
import 'zod';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Interface defining the subset of Prisma Client required for RBAC operations.
|
|
11
|
-
* This allows the service to be agnostic of the actual PrismaClient instance.
|
|
12
|
-
*/
|
|
13
|
-
interface RBACPrismaClient {
|
|
14
|
-
userRole: {
|
|
15
|
-
findMany: (args: {
|
|
16
|
-
where: {
|
|
17
|
-
userId: string;
|
|
18
|
-
};
|
|
19
|
-
select: {
|
|
20
|
-
roleCode: boolean;
|
|
21
|
-
role: {
|
|
22
|
-
select: {
|
|
23
|
-
rolePermissions: {
|
|
24
|
-
select: {
|
|
25
|
-
resourceCode: boolean;
|
|
26
|
-
actionCode: boolean;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
}) => Promise<Array<{
|
|
33
|
-
roleCode: string;
|
|
34
|
-
role: {
|
|
35
|
-
rolePermissions: Array<{
|
|
36
|
-
resourceCode: string;
|
|
37
|
-
actionCode: string;
|
|
38
|
-
}>;
|
|
39
|
-
};
|
|
40
|
-
}>>;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Fetch user permissions from database based on roles.
|
|
45
|
-
* Deduplicates permissions by resourceCode:actionCode.
|
|
46
|
-
*
|
|
47
|
-
* @param db - The tenant-specific Prisma Client instance
|
|
48
|
-
* @param userId - The user ID to fetch permissions for
|
|
49
|
-
*/
|
|
50
|
-
declare function getUserPermissionsFromDB(db: RBACPrismaClient, userId: string): Promise<Permission[]>;
|
|
51
|
-
/**
|
|
52
|
-
* Get permissions with caching.
|
|
53
|
-
*
|
|
54
|
-
* @param db - The tenant-specific Prisma Client instance
|
|
55
|
-
* @param userId - The user ID
|
|
56
|
-
* @param opts.forceRefresh - Bypass cache
|
|
57
|
-
*/
|
|
58
|
-
declare function getCachedUserPermissions(db: RBACPrismaClient, userId: string, opts?: {
|
|
59
|
-
forceRefresh?: boolean;
|
|
60
|
-
}): Promise<Permission[]>;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Resource Validator
|
|
64
|
-
* Validates resource codes against DB with caching
|
|
65
|
-
*/
|
|
66
|
-
interface ResourcePrismaClient {
|
|
67
|
-
resource: {
|
|
68
|
-
findUnique: (args: {
|
|
69
|
-
where: {
|
|
70
|
-
code: string;
|
|
71
|
-
};
|
|
72
|
-
}) => Promise<{
|
|
73
|
-
code: string;
|
|
74
|
-
} | null>;
|
|
75
|
-
findMany: (args?: {
|
|
76
|
-
select?: {
|
|
77
|
-
code: boolean;
|
|
78
|
-
};
|
|
79
|
-
}) => Promise<{
|
|
80
|
-
code: string;
|
|
81
|
-
}[]>;
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Check if a resource code exists.
|
|
86
|
-
* Checks cache first, then DB if not found.
|
|
87
|
-
*
|
|
88
|
-
* @param db - Prisma client
|
|
89
|
-
* @param resourceCode - Resource code to validate
|
|
90
|
-
* @returns true if valid, false otherwise
|
|
91
|
-
*/
|
|
92
|
-
declare function isValidResourceCode(db: ResourcePrismaClient, resourceCode: string): Promise<boolean>;
|
|
93
|
-
/**
|
|
94
|
-
* Get the correct resource code for permission checking.
|
|
95
|
-
* Priority: config.permissionResource > config.name > entity param
|
|
96
|
-
*
|
|
97
|
-
* @param config - Entity config (may be partial)
|
|
98
|
-
* @param entityParam - Entity param from URL
|
|
99
|
-
* @returns Resource code to use for permission check
|
|
100
|
-
*/
|
|
101
|
-
declare function getPermissionResourceCode(config: {
|
|
102
|
-
permissionResource?: string;
|
|
103
|
-
name?: string;
|
|
104
|
-
} | null | undefined, entityParam: string): string;
|
|
105
|
-
/**
|
|
106
|
-
* Validate and get resource code for permission checking.
|
|
107
|
-
* Combines getPermissionResourceCode with DB validation.
|
|
108
|
-
*
|
|
109
|
-
* @param db - Prisma client
|
|
110
|
-
* @param config - Entity config
|
|
111
|
-
* @param entityParam - Entity param from URL
|
|
112
|
-
* @returns Object with resourceCode and isValid flag
|
|
113
|
-
*/
|
|
114
|
-
declare function validatePermissionResource(db: ResourcePrismaClient, config: {
|
|
115
|
-
permissionResource?: string;
|
|
116
|
-
name?: string;
|
|
117
|
-
} | null | undefined, entityParam: string): Promise<{
|
|
118
|
-
resourceCode: string;
|
|
119
|
-
isValid: boolean;
|
|
120
|
-
}>;
|
|
121
|
-
/**
|
|
122
|
-
* Preload all resource codes into cache.
|
|
123
|
-
* Call this on app startup for better performance.
|
|
124
|
-
*
|
|
125
|
-
* @param db - Prisma client
|
|
126
|
-
*/
|
|
127
|
-
declare function preloadResourceCodes(db: ResourcePrismaClient): Promise<void>;
|
|
128
|
-
/**
|
|
129
|
-
* Clear resource cache.
|
|
130
|
-
* Call when resources are added/removed.
|
|
131
|
-
*/
|
|
132
|
-
declare function clearResourceCache(): Promise<void>;
|
|
133
|
-
|
|
134
|
-
type User = {
|
|
135
|
-
id: string;
|
|
136
|
-
name: string | null;
|
|
137
|
-
email: string | null;
|
|
138
|
-
image: string | null;
|
|
139
|
-
isActive: boolean;
|
|
140
|
-
jobTitle?: string;
|
|
141
|
-
};
|
|
142
|
-
type Role = {
|
|
143
|
-
id: string;
|
|
144
|
-
name: string;
|
|
145
|
-
code: string;
|
|
146
|
-
description?: string | null | undefined;
|
|
147
|
-
status: string;
|
|
148
|
-
permissions: string[];
|
|
149
|
-
usersCount: number;
|
|
150
|
-
users: User[];
|
|
151
|
-
createdAt: string;
|
|
152
|
-
updatedAt: string;
|
|
153
|
-
createdBy?: string | null | undefined;
|
|
154
|
-
updatedBy?: string | null | undefined;
|
|
155
|
-
};
|
|
156
|
-
type RolesResponse = {
|
|
157
|
-
total: number;
|
|
158
|
-
page: number;
|
|
159
|
-
pageSize: number;
|
|
160
|
-
items: Role[];
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
interface RoleListPageProps {
|
|
164
|
-
dictionary: any;
|
|
165
|
-
permissions: CrudPermissions;
|
|
166
|
-
lang: string;
|
|
167
|
-
initialData: RolesResponse;
|
|
168
|
-
resources: Array<{
|
|
169
|
-
id: string;
|
|
170
|
-
code: string;
|
|
171
|
-
name: string;
|
|
172
|
-
group: string | null;
|
|
173
|
-
description: string | null;
|
|
174
|
-
icon: string | null;
|
|
175
|
-
order: number | null;
|
|
176
|
-
config: any;
|
|
177
|
-
}>;
|
|
178
|
-
actions: Array<{
|
|
179
|
-
id: string;
|
|
180
|
-
code: string;
|
|
181
|
-
name: string;
|
|
182
|
-
description: string | null;
|
|
183
|
-
isDefault?: boolean;
|
|
184
|
-
}>;
|
|
185
|
-
}
|
|
186
|
-
declare function RoleListPage({ dictionary, permissions, lang, initialData, resources, actions, }: RoleListPageProps): react_jsx_runtime.JSX.Element;
|
|
187
|
-
|
|
188
|
-
declare const CRUD_ACTIONS: {
|
|
189
|
-
readonly create: "create";
|
|
190
|
-
readonly view: "view";
|
|
191
|
-
readonly update: "update";
|
|
192
|
-
readonly delete: "delete";
|
|
193
|
-
readonly export: "export";
|
|
194
|
-
readonly import: "import";
|
|
195
|
-
readonly approve: "approve";
|
|
196
|
-
readonly reject: "reject";
|
|
197
|
-
};
|
|
198
|
-
type CrudAction = keyof typeof CRUD_ACTIONS;
|
|
199
|
-
declare function getActionCode(operation: CrudAction): string;
|
|
200
|
-
declare function getAllCrudActionCodes(): string[];
|
|
201
|
-
declare function isCrudAction(actionCode: string): boolean;
|
|
202
|
-
declare function getFromCache(userId: string): Promise<Permission[] | undefined>;
|
|
203
|
-
declare function setToCache(userId: string, data: Permission[]): Promise<void>;
|
|
204
|
-
declare const pendingQueries: Map<string, Promise<Permission[]>>;
|
|
205
|
-
declare function clearAllPermissionsCache(): Promise<void>;
|
|
206
|
-
declare function clearUserPermissionsCache(userId: string): Promise<void>;
|
|
207
|
-
declare function invalidateUserPermissions(userId: string): Promise<void>;
|
|
208
|
-
|
|
209
|
-
declare function getUserPermissions(session: Session | null): Permission[];
|
|
210
|
-
declare function getCrudPermissionsFromSession(session: Session | null, entity: string): {
|
|
211
|
-
create: boolean;
|
|
212
|
-
view: boolean;
|
|
213
|
-
update: boolean;
|
|
214
|
-
delete: boolean;
|
|
215
|
-
export: boolean;
|
|
216
|
-
import: boolean;
|
|
217
|
-
approve: boolean;
|
|
218
|
-
reject: boolean;
|
|
219
|
-
};
|
|
220
|
-
declare function checkPermission(session: Session | null, resourceCode: string, actionCode: string): boolean;
|
|
221
|
-
declare function hasPermission(session: Session | null, resourceCode: string, actionCode: string): boolean;
|
|
222
|
-
declare function requirePermission(session: Session | null, resourceCode: string, actionCode: string): void;
|
|
223
|
-
declare function hasRole(session: Session | null, roleCode: string): boolean;
|
|
224
|
-
declare function hasAnyRole(session: Session | null, roleCodes: string[]): boolean;
|
|
225
|
-
|
|
226
|
-
export { CRUD_ACTIONS, type CrudAction, type RBACPrismaClient, RoleListPage, checkPermission, clearAllPermissionsCache, clearResourceCache, clearUserPermissionsCache, getActionCode, getAllCrudActionCodes, getCachedUserPermissions, getCrudPermissionsFromSession, getFromCache, getPermissionResourceCode, getUserPermissions, getUserPermissionsFromDB, hasAnyRole, hasPermission, hasRole, invalidateUserPermissions, isCrudAction, isValidResourceCode, pendingQueries, preloadResourceCodes, requirePermission, setToCache, validatePermissionResource };
|