@eintrek/erp-shell 0.1.52 → 0.1.54
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/README.md +4 -1
- package/dist/help/help-api.d.ts +53 -3
- package/dist/help/help-attach.d.ts +145 -0
- package/dist/help/help-dialog.d.ts +4 -2
- package/dist/help/help-images.d.ts +42 -0
- package/dist/help/help-link.d.ts +15 -0
- package/dist/help/help-store.d.ts +13 -1
- package/dist/http/platform-api.d.ts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +1661 -818
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1663 -815
- package/dist/index.js.map +1 -1
- package/dist/navigation/my-roles.d.ts +41 -0
- package/dist/navigation/nav-user.d.ts +12 -1
- package/dist/navigation/use-my-roles.d.ts +15 -0
- package/dist/version.d.ts +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The caller's roles in the current organisation, as platform-api answers
|
|
3
|
+
* GET /organizations/:id/my-roles, and how the user card words them.
|
|
4
|
+
*
|
|
5
|
+
* No runtime imports: the tests run this file in Node as it is.
|
|
6
|
+
*/
|
|
7
|
+
export interface MyRole {
|
|
8
|
+
/** Keycloak role-group name. Never shown. */
|
|
9
|
+
key: string;
|
|
10
|
+
/** Thai name from Platform's role catalog; a custom group's own name. */
|
|
11
|
+
name_th: string;
|
|
12
|
+
app: string;
|
|
13
|
+
kind: string;
|
|
14
|
+
}
|
|
15
|
+
export interface MyRoles {
|
|
16
|
+
organizationId: string;
|
|
17
|
+
isOwner: boolean;
|
|
18
|
+
/** In the order to show them: admins first, the base role last. */
|
|
19
|
+
roles: MyRole[];
|
|
20
|
+
}
|
|
21
|
+
/** The owner's chip. Ownership is a flag, not a role. */
|
|
22
|
+
export declare const OWNER_CHIP = "\u0E40\u0E08\u0E49\u0E32\u0E02\u0E2D\u0E07";
|
|
23
|
+
/** How many role names the card spells out before counting the rest. */
|
|
24
|
+
export declare const CARD_ROLE_LIMIT = 2;
|
|
25
|
+
/**
|
|
26
|
+
* The answer, checked. Anything that is not the shape the card needs — an
|
|
27
|
+
* older API, a proxy's error page, another organisation's answer — is null,
|
|
28
|
+
* and the card shows no role line.
|
|
29
|
+
*/
|
|
30
|
+
export declare function parseMyRoles(payload: unknown, organizationId: string): MyRoles | null;
|
|
31
|
+
export interface CardRoleLine {
|
|
32
|
+
shown: string[];
|
|
33
|
+
/** How many more roles the card does not name. */
|
|
34
|
+
more: number;
|
|
35
|
+
}
|
|
36
|
+
/** The card names the first two roles and counts the rest. */
|
|
37
|
+
export declare function cardRoleLine(roles: MyRole[], limit?: number): CardRoleLine;
|
|
38
|
+
/** Everything, for the tooltip: "เจ้าของ · ผู้ดูแลสูงสุด · พนักงานทั่วไป". */
|
|
39
|
+
export declare function roleSummary(my: MyRoles): string;
|
|
40
|
+
/** Whether there is anything to show at all. */
|
|
41
|
+
export declare function hasRoleLine(my: MyRoles | null | undefined): my is MyRoles;
|
|
@@ -55,5 +55,16 @@ export interface NavUserProps {
|
|
|
55
55
|
* rule above, a round avatar, and up/down chevrons. Default "brand".
|
|
56
56
|
*/
|
|
57
57
|
variant?: "brand" | "workspace";
|
|
58
|
+
/**
|
|
59
|
+
* The person's roles in the organisation, under their name (and in full in
|
|
60
|
+
* the menu), read from platform-api. Default: on wherever the organisation
|
|
61
|
+
* switcher is, i.e. in every organisation-scoped app.
|
|
62
|
+
*/
|
|
63
|
+
showRoles?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* The organisation whose roles to show. Default: the one the API client
|
|
66
|
+
* sends as X-Organization-ID.
|
|
67
|
+
*/
|
|
68
|
+
organizationId?: string | number | null;
|
|
58
69
|
}
|
|
59
|
-
export declare function NavUser({ organization, avatarSrc, profileHref, selectOrganizationHref, signInRedirectHref, systemLinks, showSelectOrganization, showLanguageSwitch, variant, }?: NavUserProps): import("react/jsx-runtime").JSX.Element | null;
|
|
70
|
+
export declare function NavUser({ organization, avatarSrc, profileHref, selectOrganizationHref, signInRedirectHref, systemLinks, showSelectOrganization, showLanguageSwitch, variant, showRoles, organizationId, }?: NavUserProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type MyRoles } from "./my-roles";
|
|
2
|
+
export declare const myRolesQueryKey: (organizationId: string | null) => readonly ["erp-shell", "my-roles", string | null];
|
|
3
|
+
/**
|
|
4
|
+
* The organisation the API client sends (X-Organization-ID). Null while
|
|
5
|
+
* server-rendering and hydrating, so the first client render matches the
|
|
6
|
+
* server's.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useStoredOrganizationId(): string | null;
|
|
9
|
+
/**
|
|
10
|
+
* The signed-in person's roles in an organisation, from platform-api
|
|
11
|
+
* (GET /organizations/:id/my-roles). Cached per organisation; a different
|
|
12
|
+
* organisation is a different query. A failure, or an API too old to have
|
|
13
|
+
* the route, leaves `data` empty — the caller shows nothing.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useMyRoles(organizationId: string | number | null | undefined, enabled?: boolean): import("@tanstack/react-query").UseQueryResult<MyRoles | null, Error>;
|
package/dist/version.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eintrek/erp-shell",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.54",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Shared frontend platform for ERP apps — HTTP client, providers, navigation, hooks.",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"build": "cross-env NODE_ENV=production rollup -c --silent",
|
|
15
15
|
"dev": "cross-env NODE_ENV=production rollup -c -w",
|
|
16
16
|
"clean": "rimraf dist",
|
|
17
|
-
"pack": "cross-env NODE_ENV=production pnpm build && pnpm pack"
|
|
17
|
+
"pack": "cross-env NODE_ENV=production pnpm build && pnpm pack",
|
|
18
|
+
"test": "node --test \"src/**/*.test.ts\""
|
|
18
19
|
},
|
|
19
20
|
"keywords": [
|
|
20
21
|
"erp",
|