@artemis-apps/app-react 0.0.0-stage → 0.1.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/app-account-menu.d.ts +2 -0
- package/dist/app-account-menu.js +12 -0
- package/dist/app-launcher.d.ts +5 -0
- package/dist/app-launcher.js +20 -0
- package/dist/app-session.api.d.ts +85 -0
- package/dist/app-session.api.js +8 -0
- package/dist/directory.api.d.ts +32 -0
- package/dist/directory.api.js +14 -0
- package/dist/entities/entities.api.d.ts +603 -0
- package/dist/entities/entities.api.js +147 -0
- package/dist/entities/entity-share-dialog.d.ts +24 -0
- package/dist/entities/entity-share-dialog.js +101 -0
- package/dist/entities/use-entities.d.ts +140 -0
- package/dist/entities/use-entities.js +92 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/launcher.api.d.ts +10 -0
- package/dist/launcher.api.js +7 -0
- package/dist/platform-provider.d.ts +10 -0
- package/dist/platform-provider.js +56 -0
- package/dist/session-redirect.d.ts +9 -0
- package/dist/session-redirect.js +18 -0
- package/dist/unenrolled-page.d.ts +14 -0
- package/dist/unenrolled-page.js +19 -0
- package/dist/use-app-session.d.ts +31 -0
- package/dist/use-app-session.js +12 -0
- package/dist/use-directory-accounts.d.ts +6 -0
- package/dist/use-directory-accounts.js +20 -0
- package/dist/use-directory-search.d.ts +17 -0
- package/dist/use-directory-search.js +19 -0
- package/dist/use-launcher.d.ts +13 -0
- package/dist/use-launcher.js +23 -0
- package/dist/use-sign-out.d.ts +4 -0
- package/dist/use-sign-out.js +10 -0
- package/package.json +52 -3
- package/README.md +0 -3
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CORE_PROTOCOL_PATHS } from '@artemis-apps/contracts';
|
|
3
|
+
import { AccountMenu } from '@artemis-apps/ui';
|
|
4
|
+
import { useAppSession } from './use-app-session.js';
|
|
5
|
+
import { useSignOut } from './use-sign-out.js';
|
|
6
|
+
/** Account menu of an app: manage the account (on the core), or sign out. */
|
|
7
|
+
export function AppAccountMenu() {
|
|
8
|
+
const { account, coreUrl } = useAppSession();
|
|
9
|
+
const signOut = useSignOut();
|
|
10
|
+
const accountPageUrl = new URL(CORE_PROTOCOL_PATHS.accountPage, coreUrl).href;
|
|
11
|
+
return (_jsx(AccountMenu, { avatarSeed: account.avatar.kind === 'generated' ? account.avatar.seed : account.id, avatarUrl: account.avatar.kind === 'file' ? account.avatar.url : undefined, name: account.name, email: account.email, onSignOut: () => signOut.mutate(), signingOut: signOut.isPending, manageAccountLink: _jsx("a", { href: accountPageUrl }) }));
|
|
12
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { AppSwitcher } from '@artemis-apps/ui';
|
|
3
|
+
import { isCurrentAppEntry, useLauncher } from './use-launcher.js';
|
|
4
|
+
/**
|
|
5
|
+
* The topbar's app switcher of an app (next to `AppAccountMenu`): what the account can open on
|
|
6
|
+
* the platform, this app marked as current. Hidden until the core answers.
|
|
7
|
+
*/
|
|
8
|
+
export function AppLauncher() {
|
|
9
|
+
const launcher = useLauncher();
|
|
10
|
+
if (!launcher.data?.entries.length)
|
|
11
|
+
return null;
|
|
12
|
+
const apps = launcher.data.entries.map((entry) => ({
|
|
13
|
+
id: entry.id,
|
|
14
|
+
name: entry.name,
|
|
15
|
+
href: entry.url,
|
|
16
|
+
icon: _jsx("img", { src: entry.iconUrl, alt: "", className: "size-12" }),
|
|
17
|
+
current: isCurrentAppEntry(entry),
|
|
18
|
+
}));
|
|
19
|
+
return _jsx(AppSwitcher, { apps: apps });
|
|
20
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export declare function fetchAppSessionState(signal?: AbortSignal): Promise<{
|
|
2
|
+
status: "unenrolled";
|
|
3
|
+
manifest: {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string | undefined;
|
|
7
|
+
permissions: import("@artemis-apps/contracts").DelegablePermission[];
|
|
8
|
+
types: {
|
|
9
|
+
id: string;
|
|
10
|
+
version: number;
|
|
11
|
+
parent: string | null;
|
|
12
|
+
titleFields: string[];
|
|
13
|
+
schema: Record<string, import("zod").JSONType>;
|
|
14
|
+
permissions: Record<string, string | null>;
|
|
15
|
+
operations: Record<string, string>;
|
|
16
|
+
kinds: string[];
|
|
17
|
+
actions: Record<string, {
|
|
18
|
+
permission: string;
|
|
19
|
+
target: "page" | "server";
|
|
20
|
+
}>;
|
|
21
|
+
messages: Partial<Record<"en" | "fr", {
|
|
22
|
+
name: string;
|
|
23
|
+
plural: string;
|
|
24
|
+
permissions: Record<string, {
|
|
25
|
+
label: string;
|
|
26
|
+
description: string;
|
|
27
|
+
}>;
|
|
28
|
+
operations: Record<string, string>;
|
|
29
|
+
kinds: Record<string, string>;
|
|
30
|
+
actions: Record<string, string>;
|
|
31
|
+
}>>;
|
|
32
|
+
}[];
|
|
33
|
+
listed?: boolean | undefined;
|
|
34
|
+
kinds?: Record<string, {
|
|
35
|
+
kind: string;
|
|
36
|
+
icon: string;
|
|
37
|
+
template?: string | undefined;
|
|
38
|
+
}[]> | undefined;
|
|
39
|
+
handles?: Record<string, Record<string, string[]>> | undefined;
|
|
40
|
+
url: string;
|
|
41
|
+
provides: Record<string, {
|
|
42
|
+
operations: string[];
|
|
43
|
+
}>;
|
|
44
|
+
jwks: {
|
|
45
|
+
keys: {
|
|
46
|
+
kty: "EC";
|
|
47
|
+
crv: "P-256";
|
|
48
|
+
x: string;
|
|
49
|
+
y: string;
|
|
50
|
+
kid: string;
|
|
51
|
+
alg: "ES256";
|
|
52
|
+
use: "sig";
|
|
53
|
+
}[];
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
coreUrl: string;
|
|
57
|
+
} | {
|
|
58
|
+
status: "unauthenticated";
|
|
59
|
+
signInUrl: string;
|
|
60
|
+
} | {
|
|
61
|
+
status: "authenticated";
|
|
62
|
+
appId: string;
|
|
63
|
+
account: {
|
|
64
|
+
id: string;
|
|
65
|
+
email: string;
|
|
66
|
+
name: string;
|
|
67
|
+
avatar: {
|
|
68
|
+
kind: "generated";
|
|
69
|
+
seed: string;
|
|
70
|
+
} | {
|
|
71
|
+
kind: "file";
|
|
72
|
+
fileId: string;
|
|
73
|
+
url: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
permissions: import("@artemis-apps/contracts").DelegablePermission[];
|
|
77
|
+
preferences: {
|
|
78
|
+
locale: "en" | "fr";
|
|
79
|
+
};
|
|
80
|
+
administrator: boolean;
|
|
81
|
+
coreUrl: string;
|
|
82
|
+
}>;
|
|
83
|
+
export declare function signOut(): Promise<{
|
|
84
|
+
redirectTo: string;
|
|
85
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { APP_PROTOCOL_PATHS, AppSessionStateSchema, SignOutResponseSchema, } from '@artemis-apps/contracts';
|
|
2
|
+
import { fetchJson } from '@artemis-apps/web-kit';
|
|
3
|
+
export function fetchAppSessionState(signal) {
|
|
4
|
+
return fetchJson(APP_PROTOCOL_PATHS.session, AppSessionStateSchema, { signal });
|
|
5
|
+
}
|
|
6
|
+
export function signOut() {
|
|
7
|
+
return fetchJson(APP_PROTOCOL_PATHS.signOut, SignOutResponseSchema, { method: 'POST' });
|
|
8
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Accounts matching a name or an email, from the core's directory through the app's relay. */
|
|
2
|
+
export declare function searchDirectory(search: string, signal?: AbortSignal): Promise<{
|
|
3
|
+
accounts: {
|
|
4
|
+
id: string;
|
|
5
|
+
email: string;
|
|
6
|
+
name: string;
|
|
7
|
+
avatar: {
|
|
8
|
+
kind: "generated";
|
|
9
|
+
seed: string;
|
|
10
|
+
} | {
|
|
11
|
+
kind: "file";
|
|
12
|
+
fileId: string;
|
|
13
|
+
url: string;
|
|
14
|
+
};
|
|
15
|
+
}[];
|
|
16
|
+
}>;
|
|
17
|
+
/** The accounts of these ids still on the platform (deleted ones are simply missing). */
|
|
18
|
+
export declare function lookupDirectory(ids: readonly string[], signal?: AbortSignal): Promise<{
|
|
19
|
+
accounts: {
|
|
20
|
+
id: string;
|
|
21
|
+
email: string;
|
|
22
|
+
name: string;
|
|
23
|
+
avatar: {
|
|
24
|
+
kind: "generated";
|
|
25
|
+
seed: string;
|
|
26
|
+
} | {
|
|
27
|
+
kind: "file";
|
|
28
|
+
fileId: string;
|
|
29
|
+
url: string;
|
|
30
|
+
};
|
|
31
|
+
}[];
|
|
32
|
+
}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CORE_API_PATHS, DirectoryAccountListSchema, formatDirectoryQuery, } from '@artemis-apps/contracts';
|
|
2
|
+
import { fetchJson } from '@artemis-apps/web-kit';
|
|
3
|
+
import { relayed } from './entities/entities.api.js';
|
|
4
|
+
const directoryPath = relayed(CORE_API_PATHS.directory);
|
|
5
|
+
/** Accounts matching a name or an email, from the core's directory through the app's relay. */
|
|
6
|
+
export function searchDirectory(search, signal) {
|
|
7
|
+
return fetchJson(`${directoryPath}?${formatDirectoryQuery({ search })}`, DirectoryAccountListSchema, {
|
|
8
|
+
signal,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
/** The accounts of these ids still on the platform (deleted ones are simply missing). */
|
|
12
|
+
export function lookupDirectory(ids, signal) {
|
|
13
|
+
return fetchJson(`${directoryPath}?${formatDirectoryQuery({ ids: [...ids] })}`, DirectoryAccountListSchema, { signal });
|
|
14
|
+
}
|