@nivaro/react 0.1.57 → 0.1.59

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
@@ -1150,7 +1150,12 @@ declare interface MessageToken {
1150
1150
  mention?: string;
1151
1151
  }
1152
1152
 
1153
- export declare function MyWorkView(): JSX.Element;
1153
+ export declare function MyWorkView({ notificationRoutes, onOpenPath }?: {
1154
+ /** Host page map so notification clicks land on real pages (reports, queues,
1155
+ * alerts…); without it only record targets are clickable. */
1156
+ notificationRoutes?: NotificationRouteMap_2;
1157
+ onOpenPath?: (path: string) => void;
1158
+ }): JSX.Element;
1154
1159
 
1155
1160
  export declare const NavigationContext: React_2.Context<NavigationContextValue>;
1156
1161
 
@@ -1230,6 +1235,64 @@ export declare function NivaroProvider({ client, children }: {
1230
1235
  */
1231
1236
  export declare function normalizeFieldType(rawType: string, iface: string | null, relation: FormFieldDescriptor['relation']): FormFieldType;
1232
1237
 
1238
+ /**
1239
+ * Every in-app notification must land somewhere meaningful — this is the ONE
1240
+ * resolver both bells, the notifications page, and My Work use to decide what
1241
+ * a click does. A row that resolves to null renders as plain text (no hover,
1242
+ * no cursor), which is the honest state for broadcast-style messages; it must
1243
+ * never render as a link that goes nowhere.
1244
+ *
1245
+ * Server writers use `collection` + `item` as the target: business collections
1246
+ * point at records (or the collection list when item is null), a handful of
1247
+ * system collections map to their owning pages, and the pseudo-collection
1248
+ * `__chat__` carries a chat room key.
1249
+ */
1250
+
1251
+ export declare interface NotificationRouteMap {
1252
+ /** Record route for a business collection — return null when the host has none. */
1253
+ record: (collection: string, item: string) => string | null
1254
+ /** Collection listing (item-less business notifications, e.g. view digests). */
1255
+ list?: (collection: string) => string | null
1256
+ report?: (id: string) => string | null
1257
+ queue?: (id: string) => string | null
1258
+ dashboard?: (id: string) => string | null
1259
+ /** Alert-manager page (metric/anomaly/per-record alert notifications). */
1260
+ alerts?: () => string | null
1261
+ imports?: () => string | null
1262
+ issues?: () => string | null
1263
+ }
1264
+
1265
+ /**
1266
+ * Every in-app notification must land somewhere meaningful — this is the ONE
1267
+ * resolver both bells, the notifications page, and My Work use to decide what
1268
+ * a click does. A row that resolves to null renders as plain text (no hover,
1269
+ * no cursor), which is the honest state for broadcast-style messages; it must
1270
+ * never render as a link that goes nowhere.
1271
+ *
1272
+ * Server writers use `collection` + `item` as the target: business collections
1273
+ * point at records (or the collection list when item is null), a handful of
1274
+ * system collections map to their owning pages, and the pseudo-collection
1275
+ * `__chat__` carries a chat room key.
1276
+ */
1277
+ declare interface NotificationRouteMap_2 {
1278
+ /** Record route for a business collection — return null when the host has none. */
1279
+ record: (collection: string, item: string) => string | null;
1280
+ /** Collection listing (item-less business notifications, e.g. view digests). */
1281
+ list?: (collection: string) => string | null;
1282
+ report?: (id: string) => string | null;
1283
+ queue?: (id: string) => string | null;
1284
+ dashboard?: (id: string) => string | null;
1285
+ /** Alert-manager page (metric/anomaly/per-record alert notifications). */
1286
+ alerts?: () => string | null;
1287
+ imports?: () => string | null;
1288
+ issues?: () => string | null;
1289
+ }
1290
+
1291
+ export declare type NotificationTarget =
1292
+ | { type: 'path'; path: string }
1293
+ | { type: 'chat'; room: string }
1294
+ | null
1295
+
1233
1296
  export declare function NumberField({ field, value, onChange, error, disabled, readOnly, inputId, errorId }: FieldComponentProps): JSX.Element;
1234
1297
 
1235
1298
  declare interface O2MFieldInfo {
@@ -1597,6 +1660,57 @@ export declare interface ReportViewProps {
1597
1660
  emptyState?: React.ReactNode;
1598
1661
  }
1599
1662
 
1663
+ export declare function resolveNotificationTarget(
1664
+ collection: string | null | undefined,
1665
+ item: string | null | undefined,
1666
+ routes: NotificationRouteMap
1667
+ ): NotificationTarget {
1668
+ const c = collection?.trim()
1669
+ if (!c) return null
1670
+ const i = item != null && String(item).trim() !== '' ? String(item) : null
1671
+
1672
+ if (c === '__chat__') {
1673
+ // Opening a room needs a registered chat dock — without one there is no
1674
+ // chat surface to open, so the row stays plain.
1675
+ return i && canOpenChatRoom() ? { type: 'chat', room: i } : null
1676
+ }
1677
+
1678
+ if (c === 'nivaro_report_defs') {
1679
+ const p = i ? routes.report?.(i) : null
1680
+ return p ? { type: 'path', path: p } : null
1681
+ }
1682
+ if (c === 'nivaro_queues') {
1683
+ const p = i ? routes.queue?.(i) : null
1684
+ return p ? { type: 'path', path: p } : null
1685
+ }
1686
+ if (c === 'nivaro_dashboards') {
1687
+ const p = i ? routes.dashboard?.(i) : null
1688
+ return p ? { type: 'path', path: p } : null
1689
+ }
1690
+ if (ALERT_COLLECTIONS.has(c)) {
1691
+ const p = routes.alerts?.()
1692
+ return p ? { type: 'path', path: p } : null
1693
+ }
1694
+ if (IMPORT_COLLECTIONS.has(c)) {
1695
+ const p = routes.imports?.()
1696
+ return p ? { type: 'path', path: p } : null
1697
+ }
1698
+ if (c === 'nivaro_issues') {
1699
+ const p = routes.issues?.()
1700
+ return p ? { type: 'path', path: p } : null
1701
+ }
1702
+ // Any other system collection has no user-facing page — plain row, never a
1703
+ // /collections/nivaro_* route that would 404 or 403.
1704
+ if (/^nivaro_/i.test(c) || /^directus_/i.test(c)) return null
1705
+
1706
+ if (i) {
1707
+ const p = routes.record(c, i)
1708
+ return p ? { type: 'path', path: p } : null
1709
+ }
1710
+ const p = routes.list?.(c)
1711
+ return p ? { type: 'path', path: p } : null
1712
+ }
1713
+
1600
1714
  export declare function RevisionsPanel({ collection, item, onRollback, triggerClassName, inlineTableFields, open, onOpenChange }: {
1601
1715
  collection: string;
1602
1716
  item: string;
@@ -1629,6 +1743,20 @@ export declare interface RoomInfo {
1629
1743
  */
1630
1744
  declare type RoomOpener = (room: string, label?: string) => void;
1631
1745
 
1746
+ /** Convenience: run a resolved target (navigate or open the chat room). */
1747
+ export declare function runNotificationTarget(
1748
+ target: NotificationTarget,
1749
+ navigate: (path: string) => void
1750
+ ): boolean {
1751
+ if (!target) return false
1752
+ if (target.type === 'chat') {
1753
+ openChatRoom(target.room)
1754
+ return true
1755
+ }
1756
+ navigate(target.path)
1757
+ return true
1758
+ }
1759
+
1632
1760
  export declare type SectionState = {
1633
1761
  isCollapsed: (key: string) => boolean;
1634
1762
  toggle: (key: string) => void;