@graphcore/react-kernel 0.0.0 → 0.1.0
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/LICENSE +202 -0
- package/NOTICE +2 -0
- package/dist/api/agentApi.d.ts +7 -0
- package/dist/api/entityApi.d.ts +37 -0
- package/dist/api/predicate.d.ts +37 -0
- package/dist/auth/oidc.d.ts +39 -0
- package/dist/components/Access/AccessPanel.d.ts +7 -0
- package/dist/components/Access/GroupView.d.ts +1 -0
- package/dist/components/Access/index.d.ts +5 -0
- package/dist/components/Access/useAccess.d.ts +42 -0
- package/dist/components/Admin/AdminPanel.d.ts +22 -0
- package/dist/components/Admin/index.d.ts +3 -0
- package/dist/components/Admin/useIsDeploymentAdmin.d.ts +2 -0
- package/dist/components/AgentMirror/AgentMirror.d.ts +15 -0
- package/dist/components/AgentMirror/index.d.ts +1 -0
- package/dist/components/Auth/AuthPage.d.ts +14 -0
- package/dist/components/Auth/index.d.ts +1 -0
- package/dist/components/Entity/BaseEntity.d.ts +6 -0
- package/dist/components/Entity/EntityRoute.d.ts +14 -0
- package/dist/components/Entity/index.d.ts +2 -0
- package/dist/components/Entity/renderGuard.d.ts +8 -0
- package/dist/components/Entity/types/UIHooks.d.ts +42 -0
- package/dist/components/Entity/types/index.d.ts +6 -0
- package/dist/components/Invite/InviteRoute.d.ts +20 -0
- package/dist/components/Invite/index.d.ts +2 -0
- package/dist/components/Routes/AppRoutes.d.ts +11 -0
- package/dist/components/Routes/GraphCoreApp.d.ts +11 -0
- package/dist/components/Routes/GraphCoreRouter.d.ts +28 -0
- package/dist/components/Routes/pageCollisions.d.ts +12 -0
- package/dist/components/TopBar/TopBar.d.ts +31 -0
- package/dist/components/ViewEntity/CompositeView/CompositeBox.d.ts +5 -0
- package/dist/components/ViewEntity/CompositeView/CompositeHBox.d.ts +2 -0
- package/dist/components/ViewEntity/CompositeView/CompositeTabs.d.ts +2 -0
- package/dist/components/ViewEntity/CompositeView/CompositeVBox.d.ts +2 -0
- package/dist/components/ViewEntity/CompositeView/index.d.ts +8 -0
- package/dist/components/ViewEntity/CompositeView/panels.d.ts +30 -0
- package/dist/components/ViewEntity/EntityAttributes/EntityAttributesView.d.ts +2 -0
- package/dist/components/ViewEntity/EntityAttributes/index.d.ts +2 -0
- package/dist/components/ViewEntity/EntityIDE/EntityExplorer.d.ts +29 -0
- package/dist/components/ViewEntity/EntityIDE/EntityIDE.d.ts +15 -0
- package/dist/components/ViewEntity/EntityIDE/index.d.ts +1 -0
- package/dist/components/ViewEntity/ListEntity/ListView.d.ts +6 -0
- package/dist/components/ViewEntity/ViewGallery/ViewGallery.d.ts +2 -0
- package/dist/components/common/EntityPicker.d.ts +15 -0
- package/dist/components/common/ErrorBoundary.d.ts +15 -0
- package/dist/components/common/ForbiddenGhost.d.ts +9 -0
- package/dist/components/common/Notification.d.ts +9 -0
- package/dist/components/common/ViewTypePicker.d.ts +10 -0
- package/dist/graphcore-react-kernel.cjs.js +3 -0
- package/dist/graphcore-react-kernel.es.js +7946 -0
- package/dist/hooks/useAuth.d.ts +14 -0
- package/dist/hooks/useEntities.d.ts +6 -0
- package/dist/hooks/useServerRoutes.d.ts +8 -0
- package/dist/hooks/useWebSocketConsumer.d.ts +15 -0
- package/dist/index.d.ts +2 -0
- package/dist/lib/GraphCoreProvider.d.ts +43 -0
- package/dist/lib/index.d.ts +57 -0
- package/dist/lib/runtimeConfig.d.ts +22 -0
- package/dist/pages/definePage.d.ts +31 -0
- package/dist/registry/EntityIcon.d.ts +12 -0
- package/dist/registry/baseViews.d.ts +2 -0
- package/dist/registry/entityTypeIds.d.ts +16 -0
- package/dist/registry/registry-context.d.ts +3 -0
- package/dist/registry/viewRegistry.d.ts +25 -0
- package/dist/setupTests.d.ts +1 -0
- package/dist/state/accessEvents.d.ts +4 -0
- package/dist/state/authStore.d.ts +14 -0
- package/dist/state/deploymentStore.d.ts +3 -0
- package/dist/state/entityGraph/entityAccessors.d.ts +8 -0
- package/dist/state/entityGraph/entityGraph.d.ts +7 -0
- package/dist/state/entityGraph/hooks.d.ts +5 -0
- package/dist/state/entityGraph/index.d.ts +5 -0
- package/dist/state/entityGraph/store.d.ts +14 -0
- package/dist/state/entityGraph/types.d.ts +47 -0
- package/dist/state/graphCoreBridge/StrategyError.d.ts +11 -0
- package/dist/state/graphCoreBridge/bridge-context.d.ts +4 -0
- package/dist/state/graphCoreBridge/bridge.d.ts +3 -0
- package/dist/state/graphCoreBridge/hooks.d.ts +4 -0
- package/dist/state/graphCoreBridge/statusStore.d.ts +4 -0
- package/dist/state/graphCoreBridge/types.d.ts +29 -0
- package/dist/state/notificationStore.d.ts +15 -0
- package/dist/state/registryDirectoryStore.d.ts +14 -0
- package/dist/state/resyncEvents.d.ts +6 -0
- package/dist/state/useEntityQuery.d.ts +23 -0
- package/dist/state/views/viewScopes.d.ts +11 -0
- package/dist/style.css +2 -0
- package/dist/utils/StrategyRequestBuilder.d.ts +198 -0
- package/dist/utils/dragDropInterface.d.ts +81 -0
- package/dist/utils/entityPath.d.ts +14 -0
- package/dist/views/EntityView.d.ts +15 -0
- package/dist/views/ViewContext.d.ts +13 -0
- package/dist/views/defineView.d.ts +45 -0
- package/dist/views/position.d.ts +24 -0
- package/dist/views/useEntityTypeIds.d.ts +2 -0
- package/dist/views/useViewState.d.ts +22 -0
- package/package.json +71 -5
- package/README.md +0 -3
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function useAuth(): {
|
|
2
|
+
isAuthenticated: boolean;
|
|
3
|
+
isLoading: boolean;
|
|
4
|
+
token: string;
|
|
5
|
+
principalEntityId: string;
|
|
6
|
+
username: string;
|
|
7
|
+
error: string;
|
|
8
|
+
login: () => Promise<void>;
|
|
9
|
+
register: () => Promise<void>;
|
|
10
|
+
logout: () => Promise<void>;
|
|
11
|
+
loadUserEntities: (principalEntityIdToLoad: any, tokenToUse: any) => Promise<void>;
|
|
12
|
+
validateToken: () => Promise<boolean>;
|
|
13
|
+
setAuthError: (newError: any) => void;
|
|
14
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface ServerRoute {
|
|
2
|
+
pattern: string;
|
|
3
|
+
view_name: string;
|
|
4
|
+
app_id: string;
|
|
5
|
+
}
|
|
6
|
+
/** The server's route table, fetched once per page load; null while loading or if it failed. */
|
|
7
|
+
export declare function useServerRoutes(): ServerRoute[] | null;
|
|
8
|
+
export declare function resetServerRoutesCache(): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for sending strategy requests through the GraphCore bridge.
|
|
3
|
+
*
|
|
4
|
+
* sendStrategyRequest has a stable identity across reconnects so callers
|
|
5
|
+
* don't need to list it as a useEffect dependency.
|
|
6
|
+
*
|
|
7
|
+
* @returns {Object} { sendStrategyRequest, isConnected, bridge }
|
|
8
|
+
*
|
|
9
|
+
* @example Fire-and-forget
|
|
10
|
+
* sendStrategyRequest({ strategy_name: 'SetAttributes', target_entity_id: id, param_config: {} });
|
|
11
|
+
*
|
|
12
|
+
* @example Awaitable
|
|
13
|
+
* const result = await sendStrategyRequest({ ... }, { awaitResponse: true });
|
|
14
|
+
*/
|
|
15
|
+
export function useWebSocketConsumer(): any;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ViewRegistry } from '../registry/viewRegistry';
|
|
3
|
+
export interface GraphCoreProviderProps {
|
|
4
|
+
/** Full API base URL, e.g. "https://api.example.com" */
|
|
5
|
+
apiUrl: string;
|
|
6
|
+
/** WebSocket host:port, e.g. "api.example.com" or "localhost:8000" */
|
|
7
|
+
wsUrl: string;
|
|
8
|
+
/**
|
|
9
|
+
* The composition root's view registry — built with `createViewRegistry()`
|
|
10
|
+
* and populated with `registry.use(baseViews)` / `registry.use(appViews)`.
|
|
11
|
+
* Required: the framework never renders a view the composition root didn't
|
|
12
|
+
* register.
|
|
13
|
+
*/
|
|
14
|
+
registry: ViewRegistry;
|
|
15
|
+
/** The issuer's public client the frontend signs in as. Default `graphcore-web`. */
|
|
16
|
+
oidcClientId?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Optional — supply to bypass AuthPage/useAuth (token injection path).
|
|
19
|
+
* The function is called once on mount and whenever re-injecting.
|
|
20
|
+
*/
|
|
21
|
+
getToken?: () => string | null;
|
|
22
|
+
/** Required when getToken is provided — the root entity ID for this user. */
|
|
23
|
+
principalEntityId?: string;
|
|
24
|
+
/** Offer every routed page a pane showing what an agent connected as the user reads at its address. */
|
|
25
|
+
agentMirror?: boolean;
|
|
26
|
+
/** Where the GraphCore app is mounted on the web, e.g. `/app`. Default `/`. `GraphCoreRouter` passes its own. */
|
|
27
|
+
basePath?: string;
|
|
28
|
+
children: React.ReactNode;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Root provider for @graphcore/react-kernel.
|
|
32
|
+
*
|
|
33
|
+
* Supplies runtime config (API/WS URLs) and the GraphCore bridge
|
|
34
|
+
* to all child components without relying on env vars.
|
|
35
|
+
*
|
|
36
|
+
* Primary flow: mount with apiUrl + wsUrl only, then render <AuthPage />
|
|
37
|
+
* inside. Users sign in at the issuer the backend names; the session survives
|
|
38
|
+
* reloads and its access token renews in the background.
|
|
39
|
+
*
|
|
40
|
+
* Token injection (escape hatch): pass getToken + principalEntityId to bypass
|
|
41
|
+
* AuthPage when you already have a valid GraphCore token from an external system.
|
|
42
|
+
*/
|
|
43
|
+
export declare function GraphCoreProvider({ apiUrl, wsUrl, registry, getToken, principalEntityId, oidcClientId, agentMirror, basePath, children, }: GraphCoreProviderProps): React.JSX.Element;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export { GraphCoreProvider } from './GraphCoreProvider';
|
|
2
|
+
export type { GraphCoreProviderProps } from './GraphCoreProvider';
|
|
3
|
+
export { AuthPage } from '../components/Auth';
|
|
4
|
+
export { TopBar } from '../components/TopBar/TopBar';
|
|
5
|
+
export type { TopBarPlace, TopBarProps } from '../components/TopBar/TopBar';
|
|
6
|
+
export { ViewGallery } from '../components/ViewEntity/ViewGallery/ViewGallery';
|
|
7
|
+
export { useAuth } from '../hooks/useAuth';
|
|
8
|
+
export { AccessPanel, GroupView, useAccess } from '../components/Access';
|
|
9
|
+
export { INVITE_ROUTE, InviteRoute, inviteUrl } from '../components/Invite';
|
|
10
|
+
export type { InviteRouteProps, RedeemedInvite } from '../components/Invite';
|
|
11
|
+
export { ADMIN_ROUTE, AdminPanel, useIsDeploymentAdmin } from '../components/Admin';
|
|
12
|
+
export type { AdminPanelProps, DeploymentRole } from '../components/Admin';
|
|
13
|
+
export { EntityPicker } from '../components/common/EntityPicker';
|
|
14
|
+
export { AgentMirror } from '../components/AgentMirror';
|
|
15
|
+
export type { EntityPickerProps } from '../components/common/EntityPicker';
|
|
16
|
+
export type { AccessGrant, AccessPanelProps, AccessRole, AccessSummary, SendStrategyRequest, } from '../components/Access';
|
|
17
|
+
export { useEntityQuery } from '../state/useEntityQuery';
|
|
18
|
+
export type { EntityQueryOptions } from '../state/useEntityQuery';
|
|
19
|
+
export { onResync } from '../state/resyncEvents';
|
|
20
|
+
export { allOf, anyOf, containsAny, containsValue, equal, inValues } from '../api/predicate';
|
|
21
|
+
export type { Predicate } from '../api/predicate';
|
|
22
|
+
export { collectPages, definePage } from '../pages/definePage';
|
|
23
|
+
export type { AppModule, DefinedPage, PageOptions } from '../pages/definePage';
|
|
24
|
+
export { GraphCoreRouter } from '../components/Routes/GraphCoreRouter';
|
|
25
|
+
export type { GraphCoreConfig, GraphCoreRouterProps } from '../components/Routes/GraphCoreRouter';
|
|
26
|
+
export { GraphCoreApp } from '../components/Routes/GraphCoreApp';
|
|
27
|
+
export { pageCollisions } from '../components/Routes/pageCollisions';
|
|
28
|
+
export { getBasePath, webPath } from './runtimeConfig';
|
|
29
|
+
export { defineView } from '../views/defineView';
|
|
30
|
+
export { AppRoutes } from '../components/Routes/AppRoutes';
|
|
31
|
+
export type { DefinedView, PlacementProps, ViewOptions, ViewProps } from '../views/defineView';
|
|
32
|
+
export { useCreateView, useViewState } from '../views/useViewState';
|
|
33
|
+
export type { CreateView, ViewStateUpdate } from '../views/useViewState';
|
|
34
|
+
export { EntityView } from '../views/EntityView';
|
|
35
|
+
export type { EntityViewProps } from '../views/EntityView';
|
|
36
|
+
export { BaseEntity } from '../components/Entity';
|
|
37
|
+
export type { UIHooks, UIHooksProps } from '../components/Entity';
|
|
38
|
+
export { EntityLinkRedirect, EntityRoute } from '../components/Entity/EntityRoute';
|
|
39
|
+
export { EntityAttributesView } from '../components/ViewEntity/EntityAttributes';
|
|
40
|
+
export { CompositeHBox, CompositeVBox, CompositeTabs } from '../components/ViewEntity/CompositeView';
|
|
41
|
+
export { ListView } from '../components/ViewEntity/ListEntity/ListView';
|
|
42
|
+
export { EntityIDE } from '../components/ViewEntity/EntityIDE';
|
|
43
|
+
export { EntityExplorer } from '../components/ViewEntity/EntityIDE/EntityExplorer';
|
|
44
|
+
export { createViewRegistry } from '../registry/viewRegistry';
|
|
45
|
+
export type { AppViews, ViewRegistry } from '../registry/viewRegistry';
|
|
46
|
+
export { baseViews } from '../registry/baseViews';
|
|
47
|
+
export { useViewRegistry } from '../registry/registry-context';
|
|
48
|
+
export { useWebSocketConsumer } from '../hooks/useWebSocketConsumer';
|
|
49
|
+
export { StrategyRequests } from '../utils/StrategyRequestBuilder';
|
|
50
|
+
export { useDeploymentEntityId } from '../state/deploymentStore';
|
|
51
|
+
export { ENTITY_ROUTE, entityIdFromParams, entityPath, findEntityId } from '../utils/entityPath';
|
|
52
|
+
export { entityGraph, useChildren, useEntities, useEntity, useRecursiveChildren, } from '../state/entityGraph';
|
|
53
|
+
export type { Entity, EntityStore } from '../state/entityGraph';
|
|
54
|
+
export { useStrategyRequest, useGraphCoreBridge, useBridgeStatus } from '../state/graphCoreBridge/hooks';
|
|
55
|
+
export type { GraphCoreBridge } from '../state/graphCoreBridge/types';
|
|
56
|
+
export { StrategyError } from '../state/graphCoreBridge/StrategyError';
|
|
57
|
+
export { getAttributes, getAttr, getFields, getDisplayName, typeShortName } from '../state/entityGraph/entityAccessors';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime configuration for @graphcore/react-kernel.
|
|
3
|
+
*
|
|
4
|
+
* GraphCoreProvider calls setRuntimeConfig once at mount so entityApi and the
|
|
5
|
+
* GraphCore bridge can read the correct URLs at call-time without relying on
|
|
6
|
+
* build-time env vars.
|
|
7
|
+
*/
|
|
8
|
+
export declare function setRuntimeConfig(apiUrl: string, wsUrl: string, getToken?: (() => string | null) | null, oidcClientId?: string): void;
|
|
9
|
+
/** `/app` from `/app/`, `app` or `/app`; the empty string for the root. */
|
|
10
|
+
export declare function normalizeBasePath(basePath?: string | null): string;
|
|
11
|
+
export declare function setBasePath(basePath?: string | null): void;
|
|
12
|
+
/** Where the signed-in GraphCore app is mounted on the web: `''` for the root, else e.g. `/app`. */
|
|
13
|
+
export declare function getBasePath(): string;
|
|
14
|
+
/** The web path of an in-app path such as `/e/…` or `/auth/callback`. */
|
|
15
|
+
export declare function webPath(path: string): string;
|
|
16
|
+
/** The issuer's public client the frontend signs in as. */
|
|
17
|
+
export declare function getOidcClientId(): string;
|
|
18
|
+
export declare function getApiUrl(): string;
|
|
19
|
+
export declare function getWsUrl(): string;
|
|
20
|
+
/** Returns a token from an externally-supplied getToken fn (token injection path). */
|
|
21
|
+
export declare function getExternalToken(): string | null;
|
|
22
|
+
export declare function hasExternalToken(): boolean;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A page: a web-only route that renders a plain component, with no entity,
|
|
4
|
+
* no view state, no agent counterpart and no sign-in. Anything that needs
|
|
5
|
+
* the signed-in user is a view on a server route instead.
|
|
6
|
+
*/
|
|
7
|
+
export interface DefinedPage {
|
|
8
|
+
readonly kind: 'graphcore.page';
|
|
9
|
+
/** Absolute web path, react-router syntax: `/`, `/travel`, `/rsvp/*`. */
|
|
10
|
+
readonly path: string;
|
|
11
|
+
readonly component: React.ComponentType;
|
|
12
|
+
}
|
|
13
|
+
export interface PageOptions {
|
|
14
|
+
path: string;
|
|
15
|
+
component: React.ComponentType;
|
|
16
|
+
}
|
|
17
|
+
export declare function definePage({ path, component }: PageOptions): DefinedPage;
|
|
18
|
+
export declare function isDefinedPage(value: unknown): value is DefinedPage;
|
|
19
|
+
/** `/travel` from `/travel/`; `/` stays `/`. */
|
|
20
|
+
export declare function normalizePagePath(path: string): string;
|
|
21
|
+
/** An installed app's frontend module, as the generated `installedApps` manifest lists it. */
|
|
22
|
+
export interface AppModule {
|
|
23
|
+
app: string;
|
|
24
|
+
exports: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Every page the apps export, either directly (`export const Travel =
|
|
28
|
+
* definePage(…)`) or in an array (`export const pages = [definePage(…), …]`).
|
|
29
|
+
* Throws when two pages claim one path.
|
|
30
|
+
*/
|
|
31
|
+
export declare function collectPages(apps: AppModule[]): DefinedPage[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
interface EntityIconProps {
|
|
3
|
+
entityTypeId: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
size?: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Wrapper component for rendering entity icons from react-icons.
|
|
9
|
+
* Handles the TypeScript typing issues with dynamic icon components.
|
|
10
|
+
*/
|
|
11
|
+
export declare const EntityIcon: React.FC<EntityIconProps>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IconType } from 'react-icons';
|
|
2
|
+
export declare const EntityTypeIds: Readonly<{
|
|
3
|
+
ENTITY: "graphcore.Entity";
|
|
4
|
+
VIEW: "graphcore.View";
|
|
5
|
+
USER: "graphcore.User";
|
|
6
|
+
GROUP: "graphcore.Group";
|
|
7
|
+
GRANT: "graphcore.Grant";
|
|
8
|
+
DEPLOYMENT: "graphcore.Deployment";
|
|
9
|
+
STRATEGY_REQUEST: "graphcore.StrategyRequest";
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Get the icon component for a given entity_type_id, falling back to a
|
|
13
|
+
* generic icon for app-defined types this package doesn't know about.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getEntityIcon(entityTypeId: string): IconType;
|
|
16
|
+
export default EntityTypeIds;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DefinedView } from '../views/defineView';
|
|
2
|
+
/** An app's frontend entry: every export declared with `defineView` is registered. */
|
|
3
|
+
export interface AppViews {
|
|
4
|
+
/** App id, e.g. 'stacks'. */
|
|
5
|
+
app: string;
|
|
6
|
+
exports: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
export interface ViewRegistry {
|
|
9
|
+
/** Register a `defineView` component under its view name. Throws on a duplicate name or `defaultFor` claim. */
|
|
10
|
+
register(view: DefinedView<any>): void;
|
|
11
|
+
/** Register every `defineView` export of an app, recording its `entry` views as entry points. */
|
|
12
|
+
use(module: AppViews): void;
|
|
13
|
+
/** Look up a view by name, or null if unregistered. */
|
|
14
|
+
get(name: string): DefinedView<any> | null;
|
|
15
|
+
/** The view name bound as the default view for an entity type, or null. */
|
|
16
|
+
defaultViewFor(entityTypeId: string): string | null;
|
|
17
|
+
/** Every registered `entry` view. */
|
|
18
|
+
entryPoints(): Array<{
|
|
19
|
+
app: string;
|
|
20
|
+
viewKey: string;
|
|
21
|
+
}>;
|
|
22
|
+
/** All registered view names. */
|
|
23
|
+
keys(): string[];
|
|
24
|
+
}
|
|
25
|
+
export declare function createViewRegistry(): ViewRegistry;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type GraphCoreAuthState = {
|
|
2
|
+
isAuthenticated: boolean;
|
|
3
|
+
/** The issuer's access token, renewed in place while the session lasts. */
|
|
4
|
+
token: string | null;
|
|
5
|
+
principalEntityId: string | null;
|
|
6
|
+
username: string | null;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
error: string | null;
|
|
9
|
+
};
|
|
10
|
+
export declare const getDefaultAuthState: () => GraphCoreAuthState;
|
|
11
|
+
export declare const authStore: import('zustand').StoreApi<GraphCoreAuthState>;
|
|
12
|
+
export declare const setAuthState: (nextState: GraphCoreAuthState | ((previousState: GraphCoreAuthState) => GraphCoreAuthState)) => void;
|
|
13
|
+
export declare const resetAuthState: () => void;
|
|
14
|
+
export declare const useAuthState: () => GraphCoreAuthState;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Entity } from './types';
|
|
2
|
+
type EntityData = Partial<Entity> | null | undefined;
|
|
3
|
+
export declare const getAttributes: (entity: EntityData) => Record<string, unknown>;
|
|
4
|
+
export declare const getAttr: (entity: EntityData, key: string) => unknown;
|
|
5
|
+
export declare const getFields: (entity: EntityData) => Record<string, unknown>;
|
|
6
|
+
export declare function typeShortName(entity: EntityData | string): string;
|
|
7
|
+
export declare function getDisplayName(entity: EntityData): string;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EntityGraphChildrenOptions, Entity, EntityGraphRecursiveChildrenOptions, EntityTreeNode } from './types';
|
|
2
|
+
export declare const entityGraph: {
|
|
3
|
+
readEntity(entityId: string | null | undefined): Entity | null;
|
|
4
|
+
readEntities(entityIds: string[]): Array<Entity | null>;
|
|
5
|
+
readChildren(parentId: string | null | undefined, options?: EntityGraphChildrenOptions): Entity[];
|
|
6
|
+
readRecursiveChildren(rootId: string | null | undefined, options?: EntityGraphRecursiveChildrenOptions): EntityTreeNode | null;
|
|
7
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EntityGraphChildrenOptions, Entity, EntityGraphRecursiveChildrenOptions, EntityTreeNode } from './types';
|
|
2
|
+
export declare const useEntity: (entityId: string | null | undefined) => Entity | null;
|
|
3
|
+
export declare const useEntities: (entityIds: string[]) => Entity[];
|
|
4
|
+
export declare const useChildren: (parentId: string | null | undefined, options?: EntityGraphChildrenOptions) => Entity[];
|
|
5
|
+
export declare const useRecursiveChildren: (rootId: string | null | undefined, options?: EntityGraphRecursiveChildrenOptions) => EntityTreeNode | null;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { entityGraph } from './entityGraph';
|
|
2
|
+
export { entityStore } from './store';
|
|
3
|
+
export { useChildren, useEntities, useEntity, useRecursiveChildren, } from './hooks';
|
|
4
|
+
export type { Entity, EntityGraphChildrenOptions, EntityGraphRecursiveChildrenOptions, EntityTreeNode, EntityStore, } from './types';
|
|
5
|
+
export { getAttributes, getAttr, getFields, getDisplayName, typeShortName } from './entityAccessors';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StoreApi } from 'zustand/vanilla';
|
|
2
|
+
import { Entity, EntityStore } from './types';
|
|
3
|
+
type EntityGraphState = {
|
|
4
|
+
entitiesById: Record<string, Entity>;
|
|
5
|
+
entityIds: string[];
|
|
6
|
+
requestedEntityIds: Set<string>;
|
|
7
|
+
notFoundEntityIds: Set<string>;
|
|
8
|
+
};
|
|
9
|
+
/** An entity older than the one held; tombstones and `forbidden` stubs always apply. */
|
|
10
|
+
export declare const isOlderThanHeld: (incoming: Entity | undefined, held: Entity | undefined) => boolean;
|
|
11
|
+
export declare const entityGraphStore: StoreApi<EntityGraphState>;
|
|
12
|
+
export declare const useEntityGraphStore: <T>(selector: (state: EntityGraphState) => T, equalityFn?: (a: T, b: T) => boolean) => T;
|
|
13
|
+
export declare const entityStore: EntityStore;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface Entity {
|
|
2
|
+
entity_id: string;
|
|
3
|
+
entity_type_id?: string;
|
|
4
|
+
children_ids?: string[];
|
|
5
|
+
parent_ids?: string[];
|
|
6
|
+
deleted?: boolean;
|
|
7
|
+
forbidden?: boolean;
|
|
8
|
+
attributes?: Record<string, unknown>;
|
|
9
|
+
parent_id?: string | null;
|
|
10
|
+
sibling_position?: number;
|
|
11
|
+
version?: number;
|
|
12
|
+
owner?: string | null;
|
|
13
|
+
ancestor_ids?: string[];
|
|
14
|
+
reference_ids?: string[];
|
|
15
|
+
/** Opaque hash of this view from the server, echoed back on resync. */
|
|
16
|
+
etag?: string;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}
|
|
19
|
+
export interface EntityGraphChildrenOptions {
|
|
20
|
+
types?: string[];
|
|
21
|
+
excludeTypes?: string[];
|
|
22
|
+
enabled?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface EntityGraphRecursiveChildrenOptions extends EntityGraphChildrenOptions {
|
|
25
|
+
includeRoot?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export type EntityTreeNode = {
|
|
28
|
+
entity: Entity;
|
|
29
|
+
children: Record<string, EntityTreeNode>;
|
|
30
|
+
};
|
|
31
|
+
export interface EntityStore {
|
|
32
|
+
getEntityIds(): string[];
|
|
33
|
+
readEntity(entityId: string | null | undefined): Entity | null;
|
|
34
|
+
readEntities(entityIds: string[]): Array<Entity | null>;
|
|
35
|
+
readChildren(parentId: string | null | undefined, options?: EntityGraphChildrenOptions): Entity[];
|
|
36
|
+
readRecursiveChildren(rootId: string | null | undefined, options?: EntityGraphRecursiveChildrenOptions): EntityTreeNode | null;
|
|
37
|
+
mergeEntities(input: Record<string, Entity> | Entity[] | null | undefined): string[];
|
|
38
|
+
removeEntity(entityId: string): void;
|
|
39
|
+
clearEntities(): void;
|
|
40
|
+
markRequested(entityId: string): void;
|
|
41
|
+
clearRequestedEntity(entityId: string): void;
|
|
42
|
+
clearRequestedEntities(): void;
|
|
43
|
+
isRequested(entityId: string): boolean;
|
|
44
|
+
markNotFound(entityId: string): void;
|
|
45
|
+
isNotFound(entityId: string): boolean;
|
|
46
|
+
clearEntityFlags(entityId?: string): void;
|
|
47
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** A strategy run that failed or was refused: the `KernelError`'s code and details, as the server sent them. */
|
|
2
|
+
export declare class StrategyError extends Error {
|
|
3
|
+
readonly code?: string;
|
|
4
|
+
readonly details?: Record<string, unknown>;
|
|
5
|
+
readonly strategyRequestId?: string;
|
|
6
|
+
constructor(message: string, options?: {
|
|
7
|
+
code?: string | null;
|
|
8
|
+
details?: Record<string, unknown> | null;
|
|
9
|
+
strategyRequestId?: string | null;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type GraphCoreBridgeStatus = 'idle' | 'connecting' | 'connected' | 'disconnected';
|
|
2
|
+
export declare const setBridgeStatus: (status: GraphCoreBridgeStatus) => void;
|
|
3
|
+
export declare const getBridgeStatus: () => GraphCoreBridgeStatus;
|
|
4
|
+
export declare const useBridgeStatus: () => GraphCoreBridgeStatus;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { GraphCoreBridgeStatus } from './statusStore';
|
|
2
|
+
export type PendingRequest = {
|
|
3
|
+
resolve: (value: unknown) => void;
|
|
4
|
+
reject: (error: Error) => void;
|
|
5
|
+
timeout: ReturnType<typeof setTimeout>;
|
|
6
|
+
/** The run's StrategyRequest id, from `strategy_queued`. */
|
|
7
|
+
requestId?: string;
|
|
8
|
+
};
|
|
9
|
+
export interface GraphCoreBridge {
|
|
10
|
+
readonly pendingRequests: Map<string, PendingRequest>;
|
|
11
|
+
readonly wsRef: {
|
|
12
|
+
current: WebSocket | null;
|
|
13
|
+
};
|
|
14
|
+
connect: (session: {
|
|
15
|
+
token: string;
|
|
16
|
+
principalEntityId?: string | null;
|
|
17
|
+
}) => void;
|
|
18
|
+
disconnect: (reason?: string) => void;
|
|
19
|
+
dispose: () => void;
|
|
20
|
+
fetchEntity: (id: string) => void;
|
|
21
|
+
subscribe: (ids: string[]) => void;
|
|
22
|
+
executeStrategy: (strategyRequest: any, options?: {
|
|
23
|
+
awaitResponse?: boolean;
|
|
24
|
+
timeout?: number;
|
|
25
|
+
}) => void | Promise<unknown>;
|
|
26
|
+
getStatus: () => GraphCoreBridgeStatus;
|
|
27
|
+
setOnAuthError: (handler: ((message: string) => void) | null) => void;
|
|
28
|
+
ping: () => void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type GraphCoreNotification = {
|
|
2
|
+
message: unknown;
|
|
3
|
+
type: 'error' | 'success' | 'info';
|
|
4
|
+
} | null;
|
|
5
|
+
export declare const notificationStore: import('zustand').StoreApi<{
|
|
6
|
+
message: unknown;
|
|
7
|
+
type: "error" | "success" | "info";
|
|
8
|
+
}>;
|
|
9
|
+
export declare const setNotification: (notification: GraphCoreNotification) => void;
|
|
10
|
+
/** Shows why a load failed, unless the session ended: the sign-in page says that. */
|
|
11
|
+
export declare const notifyLoadFailure: (what: string, error: unknown) => void;
|
|
12
|
+
export declare const useNotificationState: () => {
|
|
13
|
+
message: unknown;
|
|
14
|
+
type: "error" | "success" | "info";
|
|
15
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type ResourceState<T> = {
|
|
2
|
+
contents: T;
|
|
3
|
+
state: 'loading' | 'hasValue' | 'hasError';
|
|
4
|
+
error: unknown;
|
|
5
|
+
};
|
|
6
|
+
export declare const ensureStrategyDirectoryLoaded: () => Promise<Record<string, any>>;
|
|
7
|
+
export declare const refreshStrategyDirectory: () => Promise<Record<string, any>>;
|
|
8
|
+
export declare const ensureAvailableEntitiesLoaded: () => Promise<Record<string, any>>;
|
|
9
|
+
export declare const refreshAvailableEntities: () => Promise<Record<string, any>>;
|
|
10
|
+
export declare const useStrategyDirectoryState: () => ResourceState<Record<string, any>>;
|
|
11
|
+
export declare const useAvailableEntitiesState: () => ResourceState<Record<string, any>>;
|
|
12
|
+
export declare const useStrategyDirectoryLoadable: () => ResourceState<Record<string, any>>;
|
|
13
|
+
export declare const useAvailableEntitiesLoadable: () => ResourceState<Record<string, any>>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** `since`: when the resynced socket was joined to its channels (`Date.now()`). */
|
|
2
|
+
type ResyncListener = (since: number) => void;
|
|
3
|
+
/** Fires when a resync completes: anything read before `since` may have missed updates. */
|
|
4
|
+
export declare function onResync(listener: ResyncListener): () => void;
|
|
5
|
+
export declare function emitResync(since: number): void;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Predicate } from '../api/predicate';
|
|
2
|
+
export type EntityQueryOptions = {
|
|
3
|
+
typeIds: string[];
|
|
4
|
+
parentId?: string | null;
|
|
5
|
+
where?: Predicate;
|
|
6
|
+
/** Only entities granted to the viewer or their groups; grants to everyone do not count. */
|
|
7
|
+
grantedToMe?: boolean;
|
|
8
|
+
limit?: number;
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The readable entities of `typeIds` matching `parentId` and `where`, a page at
|
|
13
|
+
* a time. The first page is refetched when a save or delete of these types may
|
|
14
|
+
* change which entities match, and after a resync, so the server stays the
|
|
15
|
+
* judge of the predicate and of access.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useEntityQuery({ typeIds, parentId, where, grantedToMe, limit, enabled, }: EntityQueryOptions): {
|
|
18
|
+
ids: string[];
|
|
19
|
+
hasMore: boolean;
|
|
20
|
+
loading: boolean;
|
|
21
|
+
loadMore: () => void;
|
|
22
|
+
refresh: () => void;
|
|
23
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ViewPosition } from '../../views/position';
|
|
2
|
+
import { Entity } from '../entityGraph/types';
|
|
3
|
+
export declare const viewScopes: {
|
|
4
|
+
request(position: ViewPosition, owner: string): void;
|
|
5
|
+
/** Index views the store learns about from `entity_update`. */
|
|
6
|
+
noteEntities(entities: Entity[]): void;
|
|
7
|
+
find(position: ViewPosition, owner: string): string | null | undefined;
|
|
8
|
+
clear(): void;
|
|
9
|
+
};
|
|
10
|
+
/** The view stored at `position`: undefined while loading, null when none exists or nothing can be stored. */
|
|
11
|
+
export declare function useStoredView(position: ViewPosition | null): Entity | null | undefined;
|
package/dist/style.css
ADDED