@nivaro/react 0.2.27 → 0.2.29

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/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { CascadeFilterRule } from '@nivaro/sdk';
2
+ import type { Command } from '@nivaro/sdk';
2
3
  import { Context } from 'react';
3
4
  import type { CSSProperties } from 'react';
4
5
  import { default as default_2 } from 'react';
@@ -545,10 +546,28 @@ export declare function BrowserPushCard({ serviceWorkerPath }: {
545
546
  serviceWorkerPath?: string;
546
547
  }): JSX.Element;
547
548
 
549
+ export declare function buildClientCrashBody(error: unknown, info: {
550
+ componentStack?: string | null;
551
+ } | null | undefined, url: string, replay: ReplayLink | null): ClientCrashBody;
552
+
548
553
  export declare function buildCopyAs(input: CopyAsInput): CopyAsSnippets;
549
554
 
550
555
  export declare function buildGroups<T extends QueueGroupingRow>(rows: T[], attribute: string): QueueGroup<T>[];
551
556
 
557
+ /** The POST /support/report-problem body (exported for tests). */
558
+ export declare function buildReportPayload(input: {
559
+ sentence: string;
560
+ route: string;
561
+ app?: string | null;
562
+ screenshot: string | null;
563
+ includeShot: boolean;
564
+ context: {
565
+ text: string;
566
+ fileId: string | null;
567
+ replay: ReplayLink | null;
568
+ } | null;
569
+ }): ReportProblemPayload;
570
+
552
571
  export declare function BulkActionButtons({ targets, enabledKeys, tone, disabled, onDone }: {
553
572
  targets: BulkTarget[];
554
573
  /** Surface allow-list (browser_config.bulk_actions / display_config.bulk_action_keys). */
@@ -656,13 +675,27 @@ declare interface CaptionStyle {
656
675
  position: 'bottom' | 'top';
657
676
  }
658
677
 
678
+ declare type Capture = (kind: ReplayClipKind) => Promise<ReplayLink | null>;
679
+
659
680
  /**
660
681
  * Grab the replay link for an error being reported right now. Resolves null
661
682
  * when no recorder is active (both settings off, recording failed, or the
662
683
  * clip upload took longer than 4s) — error reporting must never wait on or
663
684
  * break because of replay capture.
664
685
  */
665
- export declare function captureErrorClip(): Promise<ErrorReplayLink | null>;
686
+ export declare function captureErrorClip(kind?: ReplayClipKind): Promise<ErrorReplayLink | null>;
687
+
688
+ /**
689
+ * A downscaled JPEG data URI of the page (≤ 1280px wide), or null when
690
+ * html2canvas is missing or the capture fails. Elements carrying `ignoreAttr`
691
+ * (the reporter's own button) are left out.
692
+ */
693
+ export declare function captureMaskedScreenshot(opts?: {
694
+ ignoreAttr?: string;
695
+ maxWidth?: number;
696
+ }): Promise<string | null>;
697
+
698
+ export declare function captureReplayClip(kind?: ReplayClipKind, timeoutMs?: number): Promise<ReplayLink | null>;
666
699
 
667
700
  export { CascadeFilterRule }
668
701
 
@@ -1128,6 +1161,25 @@ declare interface ClientAction {
1128
1161
  itemId: string;
1129
1162
  }
1130
1163
 
1164
+ /**
1165
+ * Report a render crash into the issue log with its replay (#1370) — the one
1166
+ * call a host's error boundary makes from componentDidCatch:
1167
+ *
1168
+ * componentDidCatch(error, info) { void reportClientCrash(client, error, info) }
1169
+ *
1170
+ * It asks the registered session recorder for the last minute (or the live
1171
+ * recording's offset), then posts POST /issues/client with the replay link,
1172
+ * exactly as the admin's PageErrorBoundary does. Never throws and never
1173
+ * blocks rendering: the capture self-times-out and a failed post is dropped.
1174
+ */
1175
+ export declare interface ClientCrashBody {
1176
+ message: string;
1177
+ stack?: string;
1178
+ url: string;
1179
+ recording_id?: string;
1180
+ recording_offset_ms?: number | null;
1181
+ }
1182
+
1131
1183
  /** A short clip or GIF of a video (#1562), as GET /help-videos/:id/clips lists it. */
1132
1184
  declare interface ClipDto {
1133
1185
  id: string;
@@ -1151,6 +1203,13 @@ declare interface ClipDto {
1151
1203
  created_at: string;
1152
1204
  }
1153
1205
 
1206
+ /**
1207
+ * Where in a clip "the moment" is. An error clip has none (the whole clip is
1208
+ * the context); a support clip is the moment of asking — its last event,
1209
+ * measured from its first (the player's t=0).
1210
+ */
1211
+ export declare function clipEndOffset(events: unknown[], kind: ReplayClipKind): number | null;
1212
+
1154
1213
  declare type ClipKind = 'mp4' | 'gif';
1155
1214
 
1156
1215
  declare type ClipStatus = 'queued' | 'rendering' | 'ready' | 'failed';
@@ -2380,6 +2439,16 @@ export declare function formatNumber(n: number | null | undefined): string;
2380
2439
 
2381
2440
  export declare function formatRelative(date: string | Date): string;
2382
2441
 
2442
+ /**
2443
+ * The tail as a plain-text attachment a person can open from the ticket:
2444
+ * where they were, the console lines and the request log (route, status, ms).
2445
+ */
2446
+ export declare function formatReplayTail(tail: ReplayTail, ctx: {
2447
+ route: string;
2448
+ when?: Date;
2449
+ userAgent?: string | null;
2450
+ }): string;
2451
+
2383
2452
  export declare function formatStatusExpiry(expiresAt: string | null | undefined): string | null;
2384
2453
 
2385
2454
  export declare function formatValue(raw: string, cfg: ColumnFormatConfig): string;
@@ -2598,6 +2667,9 @@ export declare function getLayoutSlot(key: string | null | undefined): LayoutSlo
2598
2667
 
2599
2668
  export declare function getMentionQuery(text: string, cursorPos: number): string | null;
2600
2669
 
2670
+ /** A copy of the rings, oldest first. */
2671
+ export declare function getReplayTail(): ReplayTail;
2672
+
2601
2673
  export declare const GridFlushContext: React_2.Context<GridFlushContextValue | null>;
2602
2674
 
2603
2675
  export declare type GridFlushContextValue = {
@@ -3649,6 +3721,9 @@ declare interface InputBinding {
3649
3721
  binding_value: string;
3650
3722
  }
3651
3723
 
3724
+ /** Idempotent; a no-op outside a browser. Watches for the rest of the page's life. */
3725
+ export declare function installReplayTail(): void;
3726
+
3652
3727
  export declare type IntegrationActionResult = {
3653
3728
  key: string;
3654
3729
  ok: boolean;
@@ -4409,6 +4484,20 @@ export declare interface M2MStagingCtx {
4409
4484
  getDerivedOrigin?: (parentField: string) => string | null;
4410
4485
  }
4411
4486
 
4487
+ /**
4488
+ * A screenshot of the page for Report a problem (#1390), with every typed
4489
+ * value masked first — the same rule session replay applies (all inputs
4490
+ * masked, `.nvr-no-record` blocked). html2canvas renders a CLONE of the
4491
+ * document, and the masking happens on that clone, so the live page is never
4492
+ * touched.
4493
+ *
4494
+ * html2canvas is an optional peer dependency of @nivaro/react (the admin
4495
+ * already ships it): loaded on demand, and without it the report simply goes
4496
+ * without a screenshot.
4497
+ */
4498
+ /** Mask every typed value and blank every `.nvr-no-record` element under `root`. */
4499
+ export declare function maskInputsIn(root: Document | Element): void;
4500
+
4412
4501
  declare type MatchedDrawerConfig = {
4413
4502
  /** Rows selected by filter instead of an FK to the child row — values may be
4414
4503
  * '$parent.id', '$parent.<field>', '$row.<field>', or literals; dotted keys
@@ -5246,6 +5335,12 @@ export declare function OwnersSlot({ collection, item, title, defaultExpanded }:
5246
5335
  defaultExpanded?: boolean;
5247
5336
  }): JSX.Element | null;
5248
5337
 
5338
+ /** The ping body, or null when the path is not something the server keeps. */
5339
+ export declare function pageAtPayload(path: string, app: string): {
5340
+ path: string;
5341
+ app: string;
5342
+ } | null;
5343
+
5249
5344
  export declare function PageRenderer({ slug, hideHeader, className }: PageRendererProps): JSX.Element;
5250
5345
 
5251
5346
  export declare interface PageRendererPage {
@@ -5475,6 +5570,11 @@ export declare interface PersonProfileData {
5475
5570
  online: boolean;
5476
5571
  idle_minutes: number | null;
5477
5572
  last_seen: string | null;
5573
+ /** #1394 — admins and the person's manager only. */
5574
+ stuck?: {
5575
+ minutes: number;
5576
+ label: string | null;
5577
+ } | null;
5478
5578
  };
5479
5579
  teams: Array<{
5480
5580
  id: number;
@@ -5730,6 +5830,18 @@ declare function pollProposal(opts: {
5730
5830
  */
5731
5831
  export declare function precisionOf(options: unknown, fallback?: number): number;
5732
5832
 
5833
+ export declare interface PreparedReplayClip {
5834
+ /** Upload what was taken at prepare time; null when nothing is recording. */
5835
+ commit(timeoutMs?: number): Promise<ReplayLink | null>;
5836
+ }
5837
+
5838
+ /**
5839
+ * Take the moment now, upload on commit — nothing leaves the browser until
5840
+ * then, so a dialog that is cancelled uploads nothing. Without a recorder
5841
+ * snapshot it falls back to capturing at commit time.
5842
+ */
5843
+ export declare function prepareReplayClip(kind: ReplayClipKind): PreparedReplayClip;
5844
+
5733
5845
  /**
5734
5846
  * Inline attachment preview — click a file, see it, without a download round
5735
5847
  * trip. Images, PDFs, video and audio render in an overlay; anything else
@@ -6691,6 +6803,9 @@ export declare function registerHelpVideoPage(key: string): () => void;
6691
6803
 
6692
6804
  export declare function registerLayoutSlot(plugin: LayoutSlotPlugin): void;
6693
6805
 
6806
+ /** Called by a host's recorder module. Returns an undo for tests / HMR. */
6807
+ export declare function registerReplayCapture(fn: Capture, snap?: Snapshot): () => void;
6808
+
6694
6809
  export declare function registerRoomOpener(fn: RoomOpener): () => void;
6695
6810
 
6696
6811
  /** Register the host's opener. Returns an unregister function. */
@@ -6786,6 +6901,86 @@ export declare function RenderSettingsButton(): JSX.Element | null;
6786
6901
 
6787
6902
  declare type RenderStatus = 'none' | 'queued' | 'rendering' | 'ready' | 'failed' | 'unavailable';
6788
6903
 
6904
+ /** Why the clip is being cut: the server labels the recording by it
6905
+ * (error → app 'error-clip', support → app 'support-clip'). */
6906
+ export declare type ReplayClipKind = 'error' | 'support';
6907
+
6908
+ /** The admin's replay deep link: /session-replays?recording=<id>&t=<ms>. */
6909
+ export declare function replayHref(link: ReplayLink | {
6910
+ recording_id: string;
6911
+ offset_ms?: number | null;
6912
+ }, base?: string): string;
6913
+
6914
+ /**
6915
+ * One place every shared surface asks "what did they just see?" (#1370, #1377).
6916
+ *
6917
+ * The session recorder lives in the HOST — admin/src/lib/use-session-recorder.ts
6918
+ * or @nivaro/react's useSessionRecorder — but the surfaces that want its clip
6919
+ * (an error boundary helper, the support dialog, Report a problem) are shared
6920
+ * components. The recorder registers its capture function here once at module
6921
+ * load; shared code calls `captureReplayClip()` and never imports a host.
6922
+ *
6923
+ * Resolves null when no recorder is registered, both replay modes are off,
6924
+ * or the capture takes longer than the timeout — a report must never wait on
6925
+ * or break because of replay.
6926
+ */
6927
+ export declare interface ReplayLink {
6928
+ recording_id: string;
6929
+ /** Milliseconds into the recording where the moment happened. Null for a
6930
+ * clip — the whole clip IS the context (the moment is its end). */
6931
+ offset_ms: number | null;
6932
+ }
6933
+
6934
+ export declare interface ReplayTail {
6935
+ console: TailConsoleLine[];
6936
+ requests: TailRequest[];
6937
+ }
6938
+
6939
+ export declare function reportClientCrash(client: {
6940
+ request<T>(cmd: Command<T>): Promise<T>;
6941
+ }, error: unknown, info?: {
6942
+ componentStack?: string | null;
6943
+ } | null, opts?: {
6944
+ url?: string;
6945
+ }): Promise<void>;
6946
+
6947
+ export declare function ReportProblemButton({ app, floating, className, children, onReported }: {
6948
+ /** Your front end's label ('efp'), stored with the report. */
6949
+ app?: string;
6950
+ /** Pin a round button to the bottom-right corner (default) or render inline. */
6951
+ floating?: boolean;
6952
+ className?: string;
6953
+ /** Inline trigger content (when `floating` is false). */
6954
+ children?: ReactNode;
6955
+ onReported?: (r: {
6956
+ ticket: SupportTicket;
6957
+ issue_id: number;
6958
+ }) => void;
6959
+ }): JSX.Element;
6960
+
6961
+ /**
6962
+ * Report a problem (#1390) — the shared control a portal shell mounts
6963
+ * (exported from @nivaro/react), built on the admin's bug reporter.
6964
+ *
6965
+ * The person writes one sentence. With it go: a screenshot of the page taken
6966
+ * BEFORE the dialog covers it, every typed value masked (html2canvas, an
6967
+ * optional peer); the replay of the last minute when error replay is on (or
6968
+ * the live recording's moment); the console tail and the last twenty
6969
+ * requests; and the route. POST /support/report-problem files an ISSUE
6970
+ * (source client, raised by the person) and a support request linked to it,
6971
+ * which they follow under My requests. They can leave the screenshot and the
6972
+ * "what I was doing" context out.
6973
+ */
6974
+ export declare interface ReportProblemPayload {
6975
+ sentence: string;
6976
+ route: string;
6977
+ app?: string;
6978
+ screenshot: string | null;
6979
+ context: string | null;
6980
+ attachments: string[];
6981
+ replay?: ReplayLink;
6982
+ }
6983
+
6789
6984
  export declare function ReportView({ reportId, showFilterBar, dateRange, initialEntityFilters, refetchInterval, className, emptyState, reportUrl }: ReportViewProps & {
6790
6985
  reportUrl?: (id: string) => string;
6791
6986
  }): JSX.Element;
@@ -7142,18 +7337,6 @@ declare interface RowSnooze {
7142
7337
  note: string | null;
7143
7338
  }
7144
7339
 
7145
- /**
7146
- * Real-user monitoring collector. Hand-rolled (no web-vitals dep): one 'load'
7147
- * event per page load (TTFB / FCP / LCP / total) once LCP settles, plus one
7148
- * 'route' event per SPA navigation (time from route change to a settled
7149
- * frame). Batched and sent via sendBeacon/fetch to POST /api/rum — fire and
7150
- * forget, RUM must never affect the page it measures.
7151
- *
7152
- * Host wiring: call `startRum({app, routePattern})` once at app mount, and
7153
- * `rumRouteChange(pathname)` on every route change. `routePattern` turns a
7154
- * concrete path into its pattern ('/collections/workflows/123' →
7155
- * '/collections/:c/:id') so p75s aggregate per PAGE, not per record.
7156
- */
7157
7340
  /** Route-change timing: from the navigation to a settled double-rAF frame. */
7158
7341
  export declare function rumRouteChange(pathname: string): void;
7159
7342
 
@@ -7231,7 +7414,9 @@ declare interface SendInput {
7231
7414
  * NivaroProvider (or pass a client explicitly). Needs `rrweb` installed in
7232
7415
  * the host (optional peer dependency; without it the hook warns once and
7233
7416
  * no-ops). Privacy in both modes: every input masked, `nvr-no-record`
7234
- * class blocked; in clip mode events never leave the browser except on error.
7417
+ * class blocked, and record field values, rich text and file names masked by
7418
+ * the instance's masking rules (#1361); in clip mode events never leave the
7419
+ * browser except on error.
7235
7420
  *
7236
7421
  * `captureErrorClip` is a module singleton so an error boundary — a class
7237
7422
  * component far from this hook — can call it without plumbing.
@@ -7243,6 +7428,12 @@ export declare interface SessionRecorderOptions {
7243
7428
  client?: NivaroClient;
7244
7429
  /** Force-disable locally regardless of the instance setting. */
7245
7430
  disabled?: boolean;
7431
+ /**
7432
+ * Your app's build or version, stamped on every uploaded chunk so DB Health
7433
+ * can show recording cost per build (#1368). Defaults to the
7434
+ * @nivaro/react version.
7435
+ */
7436
+ build?: string;
7246
7437
  }
7247
7438
 
7248
7439
  export declare function setDisplayTimezone(tz: string | null): void;
@@ -7398,6 +7589,14 @@ export declare type SlotRendererProps = {
7398
7589
  defaultExpanded: boolean;
7399
7590
  };
7400
7591
 
7592
+ /**
7593
+ * Two-phase capture: take the moment NOW (the clip's events, or the live
7594
+ * recording's offset), upload later. A support dialog snapshots when it
7595
+ * opens — by the time the person has typed their question the rolling
7596
+ * buffer would hold mostly the dialog itself.
7597
+ */
7598
+ declare type Snapshot = (kind: ReplayClipKind) => (() => Promise<ReplayLink | null>) | null;
7599
+
7401
7600
  export declare interface SnoozeInput {
7402
7601
  signal: string;
7403
7602
  row_key?: string;
@@ -7501,6 +7700,21 @@ declare interface StepStyle {
7501
7700
  size: 'small' | 'medium' | 'large';
7502
7701
  }
7503
7702
 
7703
+ /**
7704
+ * Idle or stuck (#1394). /presence/online, the people page and the team view
7705
+ * answer `stuck: { minutes, label }` for someone at the keyboard, on the same
7706
+ * route, with nothing saved for ten minutes — shown to admins and the
7707
+ * person's manager only. One wording everywhere.
7708
+ */
7709
+ export declare interface StuckState {
7710
+ minutes: number;
7711
+ /** The record's friendly id ("CM26-80332") or the page path. */
7712
+ label: string | null;
7713
+ }
7714
+
7715
+ /** "stuck on CM26-80332 for 12m" (or "stuck for 12m" with no page). */
7716
+ export declare function stuckText(s: StuckState): string;
7717
+
7504
7718
  export declare function SubmissionRow({ sub, onRetry, retrying, onShowPath, initialOpen }: {
7505
7719
  sub: ErpSubmission;
7506
7720
  onRetry: (id: number) => void;
@@ -7586,6 +7800,12 @@ export declare interface SupportCategory {
7586
7800
  * that record and offers the types meant for its collection; without one it is
7587
7801
  * General Support. The request lands with the administrators (or the type's
7588
7802
  * team), who are told at once.
7803
+ *
7804
+ * #1377 — unless the person unticks it, the request carries what they were
7805
+ * looking at: the replay taken the moment the dialog OPENED (the error-replay
7806
+ * buffer cut as an app='support-clip' recording, or the live recording at
7807
+ * that moment) and a text attachment with the page, the console tail and the
7808
+ * last twenty requests. Nothing uploads unless the request is sent.
7589
7809
  */
7590
7810
  export declare function SupportRequestDialog({ open, onOpenChange, collection, item, recordLabel, onCreated }: {
7591
7811
  open: boolean;
@@ -7628,6 +7848,13 @@ export declare interface SupportTicket {
7628
7848
  created_by: string;
7629
7849
  requester_name: string | null;
7630
7850
  attachments: string[];
7851
+ /** #1390 — the issue a Report a problem filed alongside this request. */
7852
+ issue_id?: number | null;
7853
+ /** #1377 — the requester's replay at the moment they asked (admins open it). */
7854
+ replay?: {
7855
+ recording_id: string;
7856
+ offset_ms: number | null;
7857
+ } | null;
7631
7858
  replies: number;
7632
7859
  legacy: boolean;
7633
7860
  created_at: string;
@@ -7690,6 +7917,20 @@ export declare type TabState = {
7690
7917
  hasTabs: boolean;
7691
7918
  };
7692
7919
 
7920
+ declare interface TailConsoleLine {
7921
+ at: number;
7922
+ level: string;
7923
+ msg: string;
7924
+ }
7925
+
7926
+ declare interface TailRequest {
7927
+ at: number;
7928
+ method: string;
7929
+ route: string;
7930
+ status: number;
7931
+ ms: number;
7932
+ }
7933
+
7693
7934
  export declare function TaskPanel({ collection, item, title, defaultExpanded, queuedTasks, onQueueTask, onRemoveQueuedTask }: {
7694
7935
  collection: string;
7695
7936
  item: string;
@@ -7968,6 +8209,19 @@ export declare function useApiUpdate(): ApiVersionInfo | null;
7968
8209
  /** Every run the shell should show or a form may pick up. */
7969
8210
  export declare function useAutofillRuns(): AutofillRun[];
7970
8211
 
8212
+ /**
8213
+ * Auto-record on a signal (#1371) for headless hosts: listens for the
8214
+ * server's `replay:record` on the host's RealtimeAdapter (the socket the
8215
+ * portal already holds) and starts a three-minute recording labelled
8216
+ * auto:<signal> through the shared runner. useSessionRecorder calls it, so a
8217
+ * host that records needs nothing more; without a realtime adapter or rrweb
8218
+ * it does nothing.
8219
+ */
8220
+ export declare function useAutoRecord(opts?: {
8221
+ client?: NivaroClient | null;
8222
+ disabled?: boolean;
8223
+ }): void;
8224
+
7971
8225
  /** Available actions per collection, for the viewer. */
7972
8226
  export declare function useAvailableBulkActions(collections: string[]): UseQueryResult<NoInfer<Record<string, AvailableBulkAction[]>>, Error>;
7973
8227
 
@@ -8357,6 +8611,12 @@ export declare function useOverlayState<T>(key: string): {
8357
8611
  back: (steps?: number) => void;
8358
8612
  };
8359
8613
 
8614
+ export declare function usePageAt(opts: {
8615
+ app: string;
8616
+ path?: string;
8617
+ disabled?: boolean;
8618
+ }): void;
8619
+
8360
8620
  export declare function usePartner(id: number | null): UseQueryResult<NoInfer<IntegrationPartnerDetail>, Error>;
8361
8621
 
8362
8622
  export declare function usePartners(): UseQueryResult<NoInfer<{
@@ -8765,6 +9025,11 @@ declare interface WidgetSlotProps {
8765
9025
  onContentChange?: (hasContent: boolean) => void;
8766
9026
  }
8767
9027
 
9028
+ /** Add the clip kind to a session-recording start command (POST /start body). */
9029
+ export declare function withClipKind<T extends {
9030
+ _body?: unknown;
9031
+ }>(cmd: T, kind: ReplayClipKind): T;
9032
+
8768
9033
  export declare function withGetCoalescing(client: NivaroClient, opts?: CoalescingOptions): NivaroClient;
8769
9034
 
8770
9035
  export declare function WorkflowPanel({ collection, item }: {