@eintrek/erp-shell 0.1.60 → 0.1.62
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/http/axios.d.ts +8 -0
- package/dist/http/organization-fallback.d.ts +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.esm.js +287 -13
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +296 -11
- package/dist/index.js.map +1 -1
- package/dist/navigation/nav-user.d.ts +4 -1
- package/dist/navigation/platform-url.d.ts +23 -0
- package/dist/navigation/url-org-gate.d.ts +22 -0
- package/dist/organization/active-organization.d.ts +50 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -30,7 +30,10 @@ export interface NavUserProps {
|
|
|
30
30
|
* when the image sits behind an authenticated endpoint.
|
|
31
31
|
*/
|
|
32
32
|
avatarSrc?: string | null;
|
|
33
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Where "ตั้งค่าบัญชี" goes — `accountSettingsHref(orgCode)`, Platform's
|
|
35
|
+
* page. An absolute URL is opened with a full page load. Hidden if omitted.
|
|
36
|
+
*/
|
|
34
37
|
profileHref?: string;
|
|
35
38
|
/** Where to navigate on "เลือกธุรกิจ". Default: "/select-organization". */
|
|
36
39
|
selectOrganizationHref?: string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where Platform lives, and the pages every app sends people to on it.
|
|
3
|
+
*
|
|
4
|
+
* Personal settings — profile, password, signature, LINE — exist once, on
|
|
5
|
+
* Platform. Every other app links there instead of keeping its own copy.
|
|
6
|
+
*
|
|
7
|
+
* Plain .ts (no JSX) so node --test can import it; app-registry.tsx reads the
|
|
8
|
+
* base from here too, so the app switcher and the account link never disagree.
|
|
9
|
+
*/
|
|
10
|
+
/** Read per call: Next inlines NEXT_PUBLIC_* at the consuming app's build. */
|
|
11
|
+
export declare function platformBaseUrl(): string;
|
|
12
|
+
export interface AccountSettingsHrefOptions {
|
|
13
|
+
/**
|
|
14
|
+
* The app asking. Platform keeps the link relative so it stays a
|
|
15
|
+
* client-side navigation; every other app gets Platform's absolute URL.
|
|
16
|
+
*/
|
|
17
|
+
activeApp?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* ตั้งค่าบัญชี for an organisation: `/{code}/account/settings` on Platform.
|
|
21
|
+
* Undefined without an organisation code — there is no page to open then.
|
|
22
|
+
*/
|
|
23
|
+
export declare function accountSettingsHref(orgCode: string | null | undefined, { activeApp }?: AccountSettingsHrefOptions): string | undefined;
|
|
@@ -54,3 +54,25 @@ export interface UrlOrgGateInput {
|
|
|
54
54
|
/** The organisation a `[code]` segment names, among the caller's. */
|
|
55
55
|
export declare function findOrganizationForCode<T extends UrlOrgGateOrganization>(code: string | undefined, organizations: readonly T[]): T | null;
|
|
56
56
|
export declare function resolveUrlOrgGate({ code, organizations, organizationsStatus, organizationId, }: UrlOrgGateInput): UrlOrgGate;
|
|
57
|
+
/**
|
|
58
|
+
* What to do when the active organisation is not one of the user's — a
|
|
59
|
+
* browser that remembers an organisation that was deleted, or that the user
|
|
60
|
+
* has left. Pure, tested in url-org-gate.test.ts.
|
|
61
|
+
*
|
|
62
|
+
* none nothing to recover: the list has not loaded, there is no active
|
|
63
|
+
* organisation, or the active one is the user's.
|
|
64
|
+
* use make `targetId` active: the URL's organisation when the user is
|
|
65
|
+
* a member of it, otherwise the user's only organisation.
|
|
66
|
+
* forget clear it; the user has several organisations and the URL names
|
|
67
|
+
* none of them, so they pick one.
|
|
68
|
+
*/
|
|
69
|
+
export type StaleOrganizationRecovery = {
|
|
70
|
+
action: "none";
|
|
71
|
+
} | {
|
|
72
|
+
action: "use";
|
|
73
|
+
targetId: string;
|
|
74
|
+
fromUrl: boolean;
|
|
75
|
+
} | {
|
|
76
|
+
action: "forget";
|
|
77
|
+
};
|
|
78
|
+
export declare function resolveStaleOrganization({ code, organizations, organizationsStatus, organizationId, }: UrlOrgGateInput): StaleOrganizationRecovery;
|
|
@@ -20,14 +20,63 @@
|
|
|
20
20
|
export declare function getTabOrganizationId(): string | null;
|
|
21
21
|
/** Record the organisation this tab is working in (browser only). */
|
|
22
22
|
export declare function setTabOrganizationId(id: string | number | null | undefined): void;
|
|
23
|
+
/**
|
|
24
|
+
* Record the user's organisations (browser only). From then on a stored or
|
|
25
|
+
* tab organisation that is not among them loses to one that is: a browser
|
|
26
|
+
* that still remembers a deleted organisation — or one the user has left —
|
|
27
|
+
* must not keep sending it while the cookie names a good one.
|
|
28
|
+
*/
|
|
29
|
+
export declare function setKnownOrganizationIds(ids: Iterable<string | number> | null): void;
|
|
30
|
+
/** Whether the loaded list says the user is NOT a member of `id`. */
|
|
31
|
+
export declare function isKnownStaleOrganizationId(id: string | number | null | undefined): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Marks a request that must not carry X-Organization-ID: the user's own list
|
|
34
|
+
* of organisations is how a stale organisation id is found out, so it cannot
|
|
35
|
+
* depend on one. An app's interceptor honours it by passing the request's
|
|
36
|
+
* config to getRequestOrganizationId(config).
|
|
37
|
+
*
|
|
38
|
+
* axiosInstance.get("/organizations", withoutOrganization({ params }))
|
|
39
|
+
*/
|
|
40
|
+
export declare const WITHOUT_ORGANIZATION_FLAG = "erpWithoutOrganization";
|
|
41
|
+
export declare function withoutOrganization<T extends object = Record<never, never>>(config?: T): T & {
|
|
42
|
+
erpWithoutOrganization: true;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Marks a request for one particular organisation, whatever this tab has
|
|
46
|
+
* active. Used to retry the organisation list under each stored id when an
|
|
47
|
+
* API refuses it without one (see http/organization-fallback.ts).
|
|
48
|
+
*/
|
|
49
|
+
export declare const FOR_ORGANIZATION_FIELD = "erpOrganizationId";
|
|
50
|
+
/**
|
|
51
|
+
* Every organisation id this browser has stored for the tab — the tab's
|
|
52
|
+
* own, localStorage, the cookie — distinct, in that order.
|
|
53
|
+
*/
|
|
54
|
+
export declare function getStoredOrganizationIds(): string[];
|
|
23
55
|
/**
|
|
24
56
|
* The organisation a request from this tab belongs to: the tab's own, then
|
|
25
57
|
* localStorage, then the cookie. Use it for the X-Organization-ID header —
|
|
26
58
|
* and read it before any `await` in the interceptor, so the header names the
|
|
27
59
|
* organisation that was active when the request was made.
|
|
28
60
|
*
|
|
61
|
+
* Pass the request's config: a request marked withoutOrganization() gets
|
|
62
|
+
* null, so no header.
|
|
63
|
+
*
|
|
29
64
|
* localStorage before the cookie: setOrganizationId writes localStorage
|
|
30
65
|
* synchronously and then awaits a server action for the cookie, so during
|
|
31
66
|
* that round trip the cookie still names the previous organisation.
|
|
67
|
+
*
|
|
68
|
+
* Once the user's organisations are known (setKnownOrganizationIds), the
|
|
69
|
+
* first of those that is one of them wins: 0.1.60 let a deleted
|
|
70
|
+
* organisation's id left in localStorage beat a valid cookie, and every
|
|
71
|
+
* request — the organisation list included — was refused. If none is a
|
|
72
|
+
* member the first is still sent, as before: the list may simply be behind
|
|
73
|
+
* (an organisation created a moment ago).
|
|
74
|
+
*/
|
|
75
|
+
export declare function getRequestOrganizationId(config?: unknown): string | null;
|
|
76
|
+
/**
|
|
77
|
+
* Forget the active organisation everywhere this browser keeps it: the tab,
|
|
78
|
+
* localStorage and the `erp.organizationId` cookie. Call on sign-out, so the
|
|
79
|
+
* next person to sign in on this browser does not start in the previous
|
|
80
|
+
* person's organisation.
|
|
32
81
|
*/
|
|
33
|
-
export declare function
|
|
82
|
+
export declare function clearStoredOrganization(): void;
|
package/dist/version.d.ts
CHANGED