@susilkumar006/widgets-test 1.0.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/README.md +445 -0
- package/dist/api/FacePeApiClient.d.cts +74 -0
- package/dist/api/FacePeApiClient.d.ts +74 -0
- package/dist/api/FacePeApiContext.d.cts +8 -0
- package/dist/api/FacePeApiContext.d.ts +8 -0
- package/dist/api/decoders.d.cts +48 -0
- package/dist/api/decoders.d.ts +48 -0
- package/dist/api/index.d.cts +8 -0
- package/dist/api/index.d.ts +8 -0
- package/dist/api/json.d.cts +5 -0
- package/dist/api/json.d.ts +5 -0
- package/dist/api/useFacePeResource.d.cts +21 -0
- package/dist/api/useFacePeResource.d.ts +21 -0
- package/dist/components/Avatar/FacePeAvatar.d.cts +23 -0
- package/dist/components/Avatar/FacePeAvatar.d.ts +23 -0
- package/dist/components/Avatar/engines.d.cts +30 -0
- package/dist/components/Avatar/engines.d.ts +30 -0
- package/dist/components/Avatar/index.d.cts +1 -0
- package/dist/components/Avatar/index.d.ts +1 -0
- package/dist/components/Form/FacePeForm.d.cts +19 -0
- package/dist/components/Form/FacePeForm.d.ts +19 -0
- package/dist/components/Form/index.d.cts +1 -0
- package/dist/components/Form/index.d.ts +1 -0
- package/dist/components/Picker/FacePePicker.d.cts +22 -0
- package/dist/components/Picker/FacePePicker.d.ts +22 -0
- package/dist/components/Picker/index.d.cts +1 -0
- package/dist/components/Picker/index.d.ts +1 -0
- package/dist/components/Placement/FacePeOverlay.d.cts +13 -0
- package/dist/components/Placement/FacePeOverlay.d.ts +13 -0
- package/dist/components/Placement/FacePePage.d.cts +10 -0
- package/dist/components/Placement/FacePePage.d.ts +10 -0
- package/dist/components/Placement/index.d.cts +2 -0
- package/dist/components/Placement/index.d.ts +2 -0
- package/dist/components/Timeline/FacePeTimeline.d.cts +23 -0
- package/dist/components/Timeline/FacePeTimeline.d.ts +23 -0
- package/dist/components/Timeline/index.d.cts +1 -0
- package/dist/components/Timeline/index.d.ts +1 -0
- package/dist/components/shared/FacePeErrorBoundary.d.cts +28 -0
- package/dist/components/shared/FacePeErrorBoundary.d.ts +28 -0
- package/dist/components/shared/surface.d.cts +6 -0
- package/dist/components/shared/surface.d.ts +6 -0
- package/dist/context/FacePeContext.d.cts +22 -0
- package/dist/context/FacePeContext.d.ts +22 -0
- package/dist/context/avatar.d.cts +6 -0
- package/dist/context/avatar.d.ts +6 -0
- package/dist/context/index.d.cts +5 -0
- package/dist/context/index.d.ts +5 -0
- package/dist/context/navigation.d.cts +10 -0
- package/dist/context/navigation.d.ts +10 -0
- package/dist/events/FacePeEventEmitter.d.cts +59 -0
- package/dist/events/FacePeEventEmitter.d.ts +59 -0
- package/dist/events/createCorrelationId.d.cts +9 -0
- package/dist/events/createCorrelationId.d.ts +9 -0
- package/dist/events/index.d.cts +8 -0
- package/dist/events/index.d.ts +8 -0
- package/dist/events/telemetry.d.cts +11 -0
- package/dist/events/telemetry.d.ts +11 -0
- package/dist/events/useFacePeEmitter.d.cts +15 -0
- package/dist/events/useFacePeEmitter.d.ts +15 -0
- package/dist/index.cjs +1925 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +26 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +1903 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/FacePeCustomerPayload.schema.json +31 -0
- package/dist/schemas/FacePeError.schema.json +63 -0
- package/dist/schemas/FacePeEventMeta.schema.json +53 -0
- package/dist/schemas/FacePeFormValues.schema.json +27 -0
- package/dist/schemas/FacePeNavigationRequest.schema.json +33 -0
- package/dist/schemas/FacePePickerOption.schema.json +34 -0
- package/dist/schemas/FacePePickerOptionsPayload.schema.json +49 -0
- package/dist/schemas/FacePeTelemetryEvent.schema.json +66 -0
- package/dist/schemas/FacePeTimelineItem.schema.json +91 -0
- package/dist/schemas/FacePeTimelinePayload.schema.json +109 -0
- package/dist/styles.css +887 -0
- package/dist/types/api.d.cts +60 -0
- package/dist/types/api.d.ts +60 -0
- package/dist/types/avatar.d.cts +102 -0
- package/dist/types/avatar.d.ts +102 -0
- package/dist/types/common.d.cts +42 -0
- package/dist/types/common.d.ts +42 -0
- package/dist/types/components.d.cts +53 -0
- package/dist/types/components.d.ts +53 -0
- package/dist/types/config.d.cts +27 -0
- package/dist/types/config.d.ts +27 -0
- package/dist/types/events.d.cts +85 -0
- package/dist/types/events.d.ts +85 -0
- package/dist/types/form.d.cts +83 -0
- package/dist/types/form.d.ts +83 -0
- package/dist/types/index.d.cts +18 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/picker.d.cts +82 -0
- package/dist/types/picker.d.ts +82 -0
- package/dist/types/placement.d.cts +69 -0
- package/dist/types/placement.d.ts +69 -0
- package/dist/types/provider.d.cts +75 -0
- package/dist/types/provider.d.ts +75 -0
- package/dist/types/results.d.cts +28 -0
- package/dist/types/results.d.ts +28 -0
- package/dist/types/telemetry.d.cts +38 -0
- package/dist/types/telemetry.d.ts +38 -0
- package/dist/types/timeline.d.cts +103 -0
- package/dist/types/timeline.d.ts +103 -0
- package/dist/version.d.cts +2 -0
- package/dist/version.d.ts +2 -0
- package/package.json +71 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contracts of the provider: what the host passes in, and what components
|
|
3
|
+
* read back through `useFacePe()`.
|
|
4
|
+
*/
|
|
5
|
+
import type { ReactNode } from 'react';
|
|
6
|
+
import type { FacePeProviderEvents, FacePeTokenProvider } from './api.cjs';
|
|
7
|
+
import type { FacePeConfig } from './config.cjs';
|
|
8
|
+
import type { FacePeEvent, FacePeEventHandler } from './events.cjs';
|
|
9
|
+
import type { FacePeColorScheme, FacePeThemeTokens } from './placement.cjs';
|
|
10
|
+
import type { FacePeTelemetry } from './telemetry.cjs';
|
|
11
|
+
/**
|
|
12
|
+
* Props of `<FacePeProvider>`.
|
|
13
|
+
*
|
|
14
|
+
* `config` is per-component configuration. The rest are SDK-wide settings for
|
|
15
|
+
* this provider only — two providers on one page each have their own.
|
|
16
|
+
*/
|
|
17
|
+
export interface FacePeProviderProps {
|
|
18
|
+
/** Shared configuration for every FacePe component below the provider. Passed through unchanged. */
|
|
19
|
+
readonly config: FacePeConfig;
|
|
20
|
+
readonly children?: ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* Base URL of the FacePe API, e.g. "https://api.example.com/api/v1".
|
|
23
|
+
* @default none: API requests fail with `API_NOT_CONFIGURED`
|
|
24
|
+
*/
|
|
25
|
+
readonly apiBaseUrl?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Supplies the bearer token for API requests. Asked again, with
|
|
28
|
+
* `forceRefresh: true`, after a 401. Implement it by calling YOUR server,
|
|
29
|
+
* which exchanges the user's access key + secret key at
|
|
30
|
+
* `POST /api/v1/sdk/token` — the secret key must never be in browser code.
|
|
31
|
+
* @default none: requests are sent without an Authorization header
|
|
32
|
+
*/
|
|
33
|
+
readonly getToken?: FacePeTokenProvider;
|
|
34
|
+
/**
|
|
35
|
+
* The avatar_id `<FacePeAvatar>` uses unless it is given its own. It must be
|
|
36
|
+
* assigned to the user whose keys the host uses. @default none
|
|
37
|
+
*/
|
|
38
|
+
readonly avatarId?: string;
|
|
39
|
+
/** Per-attempt request timeout in milliseconds. @default 15000 */
|
|
40
|
+
readonly requestTimeoutMs?: number;
|
|
41
|
+
/**
|
|
42
|
+
* The backend refused a request even with a freshly fetched token: the
|
|
43
|
+
* host should sign the user in again.
|
|
44
|
+
*/
|
|
45
|
+
readonly onSessionExpired?: FacePeEventHandler<FacePeEvent<'sessionExpired', FacePeProviderEvents['sessionExpired']>>;
|
|
46
|
+
/**
|
|
47
|
+
* Every navigation request from any component below this provider, so the
|
|
48
|
+
* host wires its router once. Receives the component's own event (its
|
|
49
|
+
* `source` names the component). The SDK never changes the URL itself.
|
|
50
|
+
*/
|
|
51
|
+
readonly onNavigate?: FacePeEventHandler<FacePeEvent<'navigate', FacePeProviderEvents['navigate']>>;
|
|
52
|
+
/** Design tokens (customization rung L1). @default none: styles inherit from the host */
|
|
53
|
+
readonly theme?: FacePeThemeTokens;
|
|
54
|
+
/**
|
|
55
|
+
* The second token scheme, for dark mode (§7.1): used instead of `theme`
|
|
56
|
+
* (falling back to it per token) while `colorScheme` is `'dark'`.
|
|
57
|
+
* @default none
|
|
58
|
+
*/
|
|
59
|
+
readonly darkTheme?: FacePeThemeTokens;
|
|
60
|
+
/**
|
|
61
|
+
* Which token scheme is active. The host switches it; the components never
|
|
62
|
+
* read the system preference themselves. @default 'light'
|
|
63
|
+
*/
|
|
64
|
+
readonly colorScheme?: FacePeColorScheme;
|
|
65
|
+
/**
|
|
66
|
+
* Receives a record of every component event and API call below this
|
|
67
|
+
* provider, stamped with the SDK version. @default none: nothing is sent
|
|
68
|
+
*/
|
|
69
|
+
readonly telemetry?: FacePeTelemetry;
|
|
70
|
+
}
|
|
71
|
+
/** What `useFacePe()` returns. */
|
|
72
|
+
export interface FacePeContextValue {
|
|
73
|
+
/** The configuration given to the nearest `<FacePeProvider>`, exactly as passed. */
|
|
74
|
+
readonly config: FacePeConfig;
|
|
75
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contracts of the provider: what the host passes in, and what components
|
|
3
|
+
* read back through `useFacePe()`.
|
|
4
|
+
*/
|
|
5
|
+
import type { ReactNode } from 'react';
|
|
6
|
+
import type { FacePeProviderEvents, FacePeTokenProvider } from './api.js';
|
|
7
|
+
import type { FacePeConfig } from './config.js';
|
|
8
|
+
import type { FacePeEvent, FacePeEventHandler } from './events.js';
|
|
9
|
+
import type { FacePeColorScheme, FacePeThemeTokens } from './placement.js';
|
|
10
|
+
import type { FacePeTelemetry } from './telemetry.js';
|
|
11
|
+
/**
|
|
12
|
+
* Props of `<FacePeProvider>`.
|
|
13
|
+
*
|
|
14
|
+
* `config` is per-component configuration. The rest are SDK-wide settings for
|
|
15
|
+
* this provider only — two providers on one page each have their own.
|
|
16
|
+
*/
|
|
17
|
+
export interface FacePeProviderProps {
|
|
18
|
+
/** Shared configuration for every FacePe component below the provider. Passed through unchanged. */
|
|
19
|
+
readonly config: FacePeConfig;
|
|
20
|
+
readonly children?: ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* Base URL of the FacePe API, e.g. "https://api.example.com/api/v1".
|
|
23
|
+
* @default none: API requests fail with `API_NOT_CONFIGURED`
|
|
24
|
+
*/
|
|
25
|
+
readonly apiBaseUrl?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Supplies the bearer token for API requests. Asked again, with
|
|
28
|
+
* `forceRefresh: true`, after a 401. Implement it by calling YOUR server,
|
|
29
|
+
* which exchanges the user's access key + secret key at
|
|
30
|
+
* `POST /api/v1/sdk/token` — the secret key must never be in browser code.
|
|
31
|
+
* @default none: requests are sent without an Authorization header
|
|
32
|
+
*/
|
|
33
|
+
readonly getToken?: FacePeTokenProvider;
|
|
34
|
+
/**
|
|
35
|
+
* The avatar_id `<FacePeAvatar>` uses unless it is given its own. It must be
|
|
36
|
+
* assigned to the user whose keys the host uses. @default none
|
|
37
|
+
*/
|
|
38
|
+
readonly avatarId?: string;
|
|
39
|
+
/** Per-attempt request timeout in milliseconds. @default 15000 */
|
|
40
|
+
readonly requestTimeoutMs?: number;
|
|
41
|
+
/**
|
|
42
|
+
* The backend refused a request even with a freshly fetched token: the
|
|
43
|
+
* host should sign the user in again.
|
|
44
|
+
*/
|
|
45
|
+
readonly onSessionExpired?: FacePeEventHandler<FacePeEvent<'sessionExpired', FacePeProviderEvents['sessionExpired']>>;
|
|
46
|
+
/**
|
|
47
|
+
* Every navigation request from any component below this provider, so the
|
|
48
|
+
* host wires its router once. Receives the component's own event (its
|
|
49
|
+
* `source` names the component). The SDK never changes the URL itself.
|
|
50
|
+
*/
|
|
51
|
+
readonly onNavigate?: FacePeEventHandler<FacePeEvent<'navigate', FacePeProviderEvents['navigate']>>;
|
|
52
|
+
/** Design tokens (customization rung L1). @default none: styles inherit from the host */
|
|
53
|
+
readonly theme?: FacePeThemeTokens;
|
|
54
|
+
/**
|
|
55
|
+
* The second token scheme, for dark mode (§7.1): used instead of `theme`
|
|
56
|
+
* (falling back to it per token) while `colorScheme` is `'dark'`.
|
|
57
|
+
* @default none
|
|
58
|
+
*/
|
|
59
|
+
readonly darkTheme?: FacePeThemeTokens;
|
|
60
|
+
/**
|
|
61
|
+
* Which token scheme is active. The host switches it; the components never
|
|
62
|
+
* read the system preference themselves. @default 'light'
|
|
63
|
+
*/
|
|
64
|
+
readonly colorScheme?: FacePeColorScheme;
|
|
65
|
+
/**
|
|
66
|
+
* Receives a record of every component event and API call below this
|
|
67
|
+
* provider, stamped with the SDK version. @default none: nothing is sent
|
|
68
|
+
*/
|
|
69
|
+
readonly telemetry?: FacePeTelemetry;
|
|
70
|
+
}
|
|
71
|
+
/** What `useFacePe()` returns. */
|
|
72
|
+
export interface FacePeContextValue {
|
|
73
|
+
/** The configuration given to the nearest `<FacePeProvider>`, exactly as passed. */
|
|
74
|
+
readonly config: FacePeConfig;
|
|
75
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Results: what imperative actions resolve to.
|
|
3
|
+
*
|
|
4
|
+
* No exception crosses the component boundary. Every imperative action resolves
|
|
5
|
+
* to a `Result`, and the host branches on `success`.
|
|
6
|
+
*/
|
|
7
|
+
import type { FacePeError } from './common.cjs';
|
|
8
|
+
/** A successful outcome carrying `data`. */
|
|
9
|
+
export interface Success<T> {
|
|
10
|
+
readonly success: true;
|
|
11
|
+
readonly data: T;
|
|
12
|
+
}
|
|
13
|
+
/** A failed outcome carrying `error`. */
|
|
14
|
+
export interface Failure<E extends FacePeError = FacePeError> {
|
|
15
|
+
readonly success: false;
|
|
16
|
+
readonly error: E;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Outcome of an action: `Success<T>` or `Failure<E>`, told apart by `success`.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const result = await handle.validate();
|
|
23
|
+
* if (result.success) use(result.data);
|
|
24
|
+
* else report(result.error.code);
|
|
25
|
+
*/
|
|
26
|
+
export type Result<T, E extends FacePeError = FacePeError> = Success<T> | Failure<E>;
|
|
27
|
+
/** A `Result` delivered asynchronously. The promise itself never rejects. */
|
|
28
|
+
export type AsyncResult<T, E extends FacePeError = FacePeError> = Promise<Result<T, E>>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Results: what imperative actions resolve to.
|
|
3
|
+
*
|
|
4
|
+
* No exception crosses the component boundary. Every imperative action resolves
|
|
5
|
+
* to a `Result`, and the host branches on `success`.
|
|
6
|
+
*/
|
|
7
|
+
import type { FacePeError } from './common.js';
|
|
8
|
+
/** A successful outcome carrying `data`. */
|
|
9
|
+
export interface Success<T> {
|
|
10
|
+
readonly success: true;
|
|
11
|
+
readonly data: T;
|
|
12
|
+
}
|
|
13
|
+
/** A failed outcome carrying `error`. */
|
|
14
|
+
export interface Failure<E extends FacePeError = FacePeError> {
|
|
15
|
+
readonly success: false;
|
|
16
|
+
readonly error: E;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Outcome of an action: `Success<T>` or `Failure<E>`, told apart by `success`.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const result = await handle.validate();
|
|
23
|
+
* if (result.success) use(result.data);
|
|
24
|
+
* else report(result.error.code);
|
|
25
|
+
*/
|
|
26
|
+
export type Result<T, E extends FacePeError = FacePeError> = Success<T> | Failure<E>;
|
|
27
|
+
/** A `Result` delivered asynchronously. The promise itself never rejects. */
|
|
28
|
+
export type AsyncResult<T, E extends FacePeError = FacePeError> = Promise<Result<T, E>>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The telemetry contract (architecture §6.1, §6.2): the host supplies the
|
|
3
|
+
* sink through the provider; the SDK makes no analytics calls of its own.
|
|
4
|
+
*/
|
|
5
|
+
import type { CorrelationId, EntityId } from './common.cjs';
|
|
6
|
+
/** Extra facts about an event. Primitive values only; never user-entered data. */
|
|
7
|
+
export type FacePeTelemetryAttributes = Readonly<Record<string, string | number | boolean>>;
|
|
8
|
+
/**
|
|
9
|
+
* One telemetry record. Every component event produces one (named after the
|
|
10
|
+
* event, e.g. `'submit'`), and so does every API call (`'api.request'`).
|
|
11
|
+
* Event payloads are never included: they can hold what the user typed.
|
|
12
|
+
*/
|
|
13
|
+
export type FacePeTelemetryEvent = {
|
|
14
|
+
/** The event type (`'ready'`, `'select'`, …) or `'api.request'`. */
|
|
15
|
+
readonly name: string;
|
|
16
|
+
/** Who produced it: a component name, or `'FacePeProvider'`. */
|
|
17
|
+
readonly source: string;
|
|
18
|
+
/** The same id as the event's `meta.correlationId` / the request's `X-Request-Id`. */
|
|
19
|
+
readonly correlationId: CorrelationId;
|
|
20
|
+
/** ISO 8601. */
|
|
21
|
+
readonly timestamp: string;
|
|
22
|
+
/** The package version, stamped on every record. */
|
|
23
|
+
readonly sdkVersion: string;
|
|
24
|
+
readonly entityId?: EntityId;
|
|
25
|
+
/**
|
|
26
|
+
* `api.request`: `method`, `path`, `status` (when a response came back),
|
|
27
|
+
* `outcome` (`'success'` or the failure code) and `durationMs`.
|
|
28
|
+
* `error` events: the error `code`. Otherwise absent.
|
|
29
|
+
*/
|
|
30
|
+
readonly attributes?: FacePeTelemetryAttributes;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Host-provided telemetry sink. `track` is called synchronously; a sink that
|
|
34
|
+
* throws is reported and ignored, never breaking the component.
|
|
35
|
+
*/
|
|
36
|
+
export interface FacePeTelemetry {
|
|
37
|
+
track(event: FacePeTelemetryEvent): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The telemetry contract (architecture §6.1, §6.2): the host supplies the
|
|
3
|
+
* sink through the provider; the SDK makes no analytics calls of its own.
|
|
4
|
+
*/
|
|
5
|
+
import type { CorrelationId, EntityId } from './common.js';
|
|
6
|
+
/** Extra facts about an event. Primitive values only; never user-entered data. */
|
|
7
|
+
export type FacePeTelemetryAttributes = Readonly<Record<string, string | number | boolean>>;
|
|
8
|
+
/**
|
|
9
|
+
* One telemetry record. Every component event produces one (named after the
|
|
10
|
+
* event, e.g. `'submit'`), and so does every API call (`'api.request'`).
|
|
11
|
+
* Event payloads are never included: they can hold what the user typed.
|
|
12
|
+
*/
|
|
13
|
+
export type FacePeTelemetryEvent = {
|
|
14
|
+
/** The event type (`'ready'`, `'select'`, …) or `'api.request'`. */
|
|
15
|
+
readonly name: string;
|
|
16
|
+
/** Who produced it: a component name, or `'FacePeProvider'`. */
|
|
17
|
+
readonly source: string;
|
|
18
|
+
/** The same id as the event's `meta.correlationId` / the request's `X-Request-Id`. */
|
|
19
|
+
readonly correlationId: CorrelationId;
|
|
20
|
+
/** ISO 8601. */
|
|
21
|
+
readonly timestamp: string;
|
|
22
|
+
/** The package version, stamped on every record. */
|
|
23
|
+
readonly sdkVersion: string;
|
|
24
|
+
readonly entityId?: EntityId;
|
|
25
|
+
/**
|
|
26
|
+
* `api.request`: `method`, `path`, `status` (when a response came back),
|
|
27
|
+
* `outcome` (`'success'` or the failure code) and `durationMs`.
|
|
28
|
+
* `error` events: the error `code`. Otherwise absent.
|
|
29
|
+
*/
|
|
30
|
+
readonly attributes?: FacePeTelemetryAttributes;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Host-provided telemetry sink. `track` is called synchronously; a sink that
|
|
34
|
+
* throws is reported and ignored, never breaking the component.
|
|
35
|
+
*/
|
|
36
|
+
export interface FacePeTelemetry {
|
|
37
|
+
track(event: FacePeTelemetryEvent): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contracts of `<FacePeTimeline>`.
|
|
3
|
+
*/
|
|
4
|
+
import type { FacePeComponentProps, FacePeHandleMethod } from './components.cjs';
|
|
5
|
+
import type { FacePeNavigationRequest, FacePeStandardEvents } from './events.cjs';
|
|
6
|
+
import type { FacePeFallbackContext } from './placement.cjs';
|
|
7
|
+
/**
|
|
8
|
+
* Where an item stands. Each status is shown by a distinct marker shape and a
|
|
9
|
+
* text label, never by colour alone.
|
|
10
|
+
*/
|
|
11
|
+
export type FacePeTimelineItemStatus = 'completed' | 'current' | 'pending' | 'error';
|
|
12
|
+
/** Extra facts shown under an item as label/value pairs, in the object's key order. */
|
|
13
|
+
export type FacePeTimelineMetadata = Readonly<Record<string, string | number | boolean>>;
|
|
14
|
+
/** One entry on the timeline. */
|
|
15
|
+
export type FacePeTimelineItem = {
|
|
16
|
+
/** Unique within the timeline. */
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly title: string;
|
|
19
|
+
readonly description?: string;
|
|
20
|
+
/**
|
|
21
|
+
* When it happened, as an ISO 8601 date-time, e.g. "2026-09-29T10:30:00+05:30".
|
|
22
|
+
* Shown in the viewer's time zone and the configured locale.
|
|
23
|
+
*/
|
|
24
|
+
readonly timestamp: string;
|
|
25
|
+
readonly status: FacePeTimelineItemStatus;
|
|
26
|
+
readonly metadata?: FacePeTimelineMetadata;
|
|
27
|
+
/**
|
|
28
|
+
* Where "View details" leads. Raised as a `navigate` event for the host's
|
|
29
|
+
* router; the timeline never changes the URL. @default none (no link shown)
|
|
30
|
+
*/
|
|
31
|
+
readonly link?: FacePeNavigationRequest;
|
|
32
|
+
};
|
|
33
|
+
/** Payload of the `select` event and of a successful `select()` call. */
|
|
34
|
+
export type FacePeTimelineSelection = {
|
|
35
|
+
readonly id: string;
|
|
36
|
+
readonly title: string;
|
|
37
|
+
readonly status: FacePeTimelineItemStatus;
|
|
38
|
+
/** The item selected before this one, or `null` if there was none. */
|
|
39
|
+
readonly previousId: string | null;
|
|
40
|
+
};
|
|
41
|
+
/** Events `<FacePeTimeline>` emits. `ready` carries no data (`null`). */
|
|
42
|
+
export type FacePeTimelineEvents = {
|
|
43
|
+
readonly ready: null;
|
|
44
|
+
readonly select: FacePeTimelineSelection;
|
|
45
|
+
readonly navigate: FacePeStandardEvents['navigate'];
|
|
46
|
+
readonly error: FacePeStandardEvents['error'];
|
|
47
|
+
};
|
|
48
|
+
/** What the `item` slot's render function receives. */
|
|
49
|
+
export type FacePeTimelineItemSlotContext = {
|
|
50
|
+
readonly item: FacePeTimelineItem;
|
|
51
|
+
readonly selected: boolean;
|
|
52
|
+
/** The timestamp as displayed, already formatted for the locale. */
|
|
53
|
+
readonly formattedTimestamp: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Host-rendered regions: `item` replaces an item's description and metadata
|
|
57
|
+
* (title, status and time stay, so the timeline keeps its structure);
|
|
58
|
+
* `emptyState` replaces the message shown when there are no items;
|
|
59
|
+
* `fallback` replaces the timeline if it fails to render. @default none
|
|
60
|
+
*/
|
|
61
|
+
export type FacePeTimelineSlots = {
|
|
62
|
+
readonly item: FacePeTimelineItemSlotContext;
|
|
63
|
+
readonly emptyState: void;
|
|
64
|
+
readonly fallback: FacePeFallbackContext;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Props of `<FacePeTimeline>`. Configuration props override the provider's;
|
|
68
|
+
* `featureFlags` are merged per flag, the timeline's own winning.
|
|
69
|
+
*
|
|
70
|
+
* Feature flags read: `timeline.relativeTime` (also show "2 hours ago").
|
|
71
|
+
*/
|
|
72
|
+
export type FacePeTimelineProps = FacePeComponentProps<FacePeTimelineEvents, FacePeTimelineSlots> & {
|
|
73
|
+
/**
|
|
74
|
+
* The items to show. Leave out to pass the entity by reference instead:
|
|
75
|
+
* with an `entityId` (an order id) the timeline fetches that order's status
|
|
76
|
+
* history through the gateway (architecture §7.5).
|
|
77
|
+
* @default fetched by `entityId`; none without one
|
|
78
|
+
*/
|
|
79
|
+
readonly items?: readonly FacePeTimelineItem[];
|
|
80
|
+
/** The timeline's accessible name. @default 'Timeline' */
|
|
81
|
+
readonly label?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Display order. `'none'` keeps the given order (preferred: pass items
|
|
84
|
+
* already in order). Sorting is by `timestamp`, stable, with unparseable
|
|
85
|
+
* timestamps last; the `items` array itself is never modified.
|
|
86
|
+
* @default 'none'
|
|
87
|
+
*/
|
|
88
|
+
readonly sort?: 'none' | 'ascending' | 'descending';
|
|
89
|
+
/** Shows a loading message instead of the items (also shown while fetching). @default false */
|
|
90
|
+
readonly loading?: boolean;
|
|
91
|
+
};
|
|
92
|
+
/** Imperative handle of `<FacePeTimeline>`, reached through a React `ref`. */
|
|
93
|
+
export interface FacePeTimelineHandle {
|
|
94
|
+
/** Moves keyboard focus to the selected item, else the first; needs interactive items. */
|
|
95
|
+
readonly focus: FacePeHandleMethod;
|
|
96
|
+
/** Clears the selection. Emits nothing. */
|
|
97
|
+
readonly reset: FacePeHandleMethod;
|
|
98
|
+
/**
|
|
99
|
+
* Scrolls the item (section) with this id into view, and focuses it when
|
|
100
|
+
* items are interactive.
|
|
101
|
+
*/
|
|
102
|
+
readonly scrollToSection: FacePeHandleMethod<[id: string]>;
|
|
103
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contracts of `<FacePeTimeline>`.
|
|
3
|
+
*/
|
|
4
|
+
import type { FacePeComponentProps, FacePeHandleMethod } from './components.js';
|
|
5
|
+
import type { FacePeNavigationRequest, FacePeStandardEvents } from './events.js';
|
|
6
|
+
import type { FacePeFallbackContext } from './placement.js';
|
|
7
|
+
/**
|
|
8
|
+
* Where an item stands. Each status is shown by a distinct marker shape and a
|
|
9
|
+
* text label, never by colour alone.
|
|
10
|
+
*/
|
|
11
|
+
export type FacePeTimelineItemStatus = 'completed' | 'current' | 'pending' | 'error';
|
|
12
|
+
/** Extra facts shown under an item as label/value pairs, in the object's key order. */
|
|
13
|
+
export type FacePeTimelineMetadata = Readonly<Record<string, string | number | boolean>>;
|
|
14
|
+
/** One entry on the timeline. */
|
|
15
|
+
export type FacePeTimelineItem = {
|
|
16
|
+
/** Unique within the timeline. */
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly title: string;
|
|
19
|
+
readonly description?: string;
|
|
20
|
+
/**
|
|
21
|
+
* When it happened, as an ISO 8601 date-time, e.g. "2026-09-29T10:30:00+05:30".
|
|
22
|
+
* Shown in the viewer's time zone and the configured locale.
|
|
23
|
+
*/
|
|
24
|
+
readonly timestamp: string;
|
|
25
|
+
readonly status: FacePeTimelineItemStatus;
|
|
26
|
+
readonly metadata?: FacePeTimelineMetadata;
|
|
27
|
+
/**
|
|
28
|
+
* Where "View details" leads. Raised as a `navigate` event for the host's
|
|
29
|
+
* router; the timeline never changes the URL. @default none (no link shown)
|
|
30
|
+
*/
|
|
31
|
+
readonly link?: FacePeNavigationRequest;
|
|
32
|
+
};
|
|
33
|
+
/** Payload of the `select` event and of a successful `select()` call. */
|
|
34
|
+
export type FacePeTimelineSelection = {
|
|
35
|
+
readonly id: string;
|
|
36
|
+
readonly title: string;
|
|
37
|
+
readonly status: FacePeTimelineItemStatus;
|
|
38
|
+
/** The item selected before this one, or `null` if there was none. */
|
|
39
|
+
readonly previousId: string | null;
|
|
40
|
+
};
|
|
41
|
+
/** Events `<FacePeTimeline>` emits. `ready` carries no data (`null`). */
|
|
42
|
+
export type FacePeTimelineEvents = {
|
|
43
|
+
readonly ready: null;
|
|
44
|
+
readonly select: FacePeTimelineSelection;
|
|
45
|
+
readonly navigate: FacePeStandardEvents['navigate'];
|
|
46
|
+
readonly error: FacePeStandardEvents['error'];
|
|
47
|
+
};
|
|
48
|
+
/** What the `item` slot's render function receives. */
|
|
49
|
+
export type FacePeTimelineItemSlotContext = {
|
|
50
|
+
readonly item: FacePeTimelineItem;
|
|
51
|
+
readonly selected: boolean;
|
|
52
|
+
/** The timestamp as displayed, already formatted for the locale. */
|
|
53
|
+
readonly formattedTimestamp: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Host-rendered regions: `item` replaces an item's description and metadata
|
|
57
|
+
* (title, status and time stay, so the timeline keeps its structure);
|
|
58
|
+
* `emptyState` replaces the message shown when there are no items;
|
|
59
|
+
* `fallback` replaces the timeline if it fails to render. @default none
|
|
60
|
+
*/
|
|
61
|
+
export type FacePeTimelineSlots = {
|
|
62
|
+
readonly item: FacePeTimelineItemSlotContext;
|
|
63
|
+
readonly emptyState: void;
|
|
64
|
+
readonly fallback: FacePeFallbackContext;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Props of `<FacePeTimeline>`. Configuration props override the provider's;
|
|
68
|
+
* `featureFlags` are merged per flag, the timeline's own winning.
|
|
69
|
+
*
|
|
70
|
+
* Feature flags read: `timeline.relativeTime` (also show "2 hours ago").
|
|
71
|
+
*/
|
|
72
|
+
export type FacePeTimelineProps = FacePeComponentProps<FacePeTimelineEvents, FacePeTimelineSlots> & {
|
|
73
|
+
/**
|
|
74
|
+
* The items to show. Leave out to pass the entity by reference instead:
|
|
75
|
+
* with an `entityId` (an order id) the timeline fetches that order's status
|
|
76
|
+
* history through the gateway (architecture §7.5).
|
|
77
|
+
* @default fetched by `entityId`; none without one
|
|
78
|
+
*/
|
|
79
|
+
readonly items?: readonly FacePeTimelineItem[];
|
|
80
|
+
/** The timeline's accessible name. @default 'Timeline' */
|
|
81
|
+
readonly label?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Display order. `'none'` keeps the given order (preferred: pass items
|
|
84
|
+
* already in order). Sorting is by `timestamp`, stable, with unparseable
|
|
85
|
+
* timestamps last; the `items` array itself is never modified.
|
|
86
|
+
* @default 'none'
|
|
87
|
+
*/
|
|
88
|
+
readonly sort?: 'none' | 'ascending' | 'descending';
|
|
89
|
+
/** Shows a loading message instead of the items (also shown while fetching). @default false */
|
|
90
|
+
readonly loading?: boolean;
|
|
91
|
+
};
|
|
92
|
+
/** Imperative handle of `<FacePeTimeline>`, reached through a React `ref`. */
|
|
93
|
+
export interface FacePeTimelineHandle {
|
|
94
|
+
/** Moves keyboard focus to the selected item, else the first; needs interactive items. */
|
|
95
|
+
readonly focus: FacePeHandleMethod;
|
|
96
|
+
/** Clears the selection. Emits nothing. */
|
|
97
|
+
readonly reset: FacePeHandleMethod;
|
|
98
|
+
/**
|
|
99
|
+
* Scrolls the item (section) with this id into view, and focuses it when
|
|
100
|
+
* items are interactive.
|
|
101
|
+
*/
|
|
102
|
+
readonly scrollToSection: FacePeHandleMethod<[id: string]>;
|
|
103
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@susilkumar006/widgets-test",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "FacePe SDK: embeddable React + TypeScript components for host applications.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "./dist/index.cjs",
|
|
11
|
+
"module": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"require": {
|
|
20
|
+
"types": "./dist/index.d.cts",
|
|
21
|
+
"default": "./dist/index.cjs"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"./styles.css": "./dist/styles.css",
|
|
25
|
+
"./schemas/*": "./dist/schemas/*",
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"sideEffects": [
|
|
32
|
+
"**/*.css"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "node scripts/lint-css.mjs && vite build && tsc -p tsconfig.json && node scripts/emit-cjs-types.mjs && node scripts/emit-schemas.mjs",
|
|
36
|
+
"lint:css": "node scripts/lint-css.mjs",
|
|
37
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
38
|
+
"test": "npm run build && node tests/run.mjs",
|
|
39
|
+
"test:only": "node tests/run.mjs",
|
|
40
|
+
"api:check": "api-extractor run",
|
|
41
|
+
"api:update": "api-extractor run --local",
|
|
42
|
+
"size": "node scripts/size-check.mjs",
|
|
43
|
+
"prepublishOnly": "node scripts/release-guard.mjs"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
47
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@microsoft/api-extractor": "^7.59.3",
|
|
51
|
+
"@types/react": "^18.3.0",
|
|
52
|
+
"@types/react-dom": "^18.3.0",
|
|
53
|
+
"css-loader": "^7.1.5",
|
|
54
|
+
"jsdom": "^24.1.3",
|
|
55
|
+
"react": "^18.3.1",
|
|
56
|
+
"react-dom": "^18.3.1",
|
|
57
|
+
"style-loader": "^4.0.0",
|
|
58
|
+
"ts-json-schema-generator": "^2.9.0",
|
|
59
|
+
"tsx": "^4.23.15",
|
|
60
|
+
"typescript": "~5.9.3",
|
|
61
|
+
"vite": "^7.0.0",
|
|
62
|
+
"webpack": "^5.111.1"
|
|
63
|
+
},
|
|
64
|
+
"engines": {
|
|
65
|
+
"node": ">=20.19"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"@anam-ai/js-sdk": "^4.27.1",
|
|
69
|
+
"livekit-client": "^2.22.3"
|
|
70
|
+
}
|
|
71
|
+
}
|