@burdenoff/fe-libs 2026.1113.1 → 2026.1113.3

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.
Files changed (60) hide show
  1. package/dist/shared/assistant/askAbout/AskAboutLayer.js +47 -47
  2. package/dist/shared/assistant/askAbout/askAboutStore.d.ts +7 -0
  3. package/dist/shared/assistant/askAbout/focus.js +1 -1
  4. package/dist/shared/assistant/askAbout/placement.d.ts +9 -0
  5. package/dist/shared/assistant/askAbout/placement.js +5 -1
  6. package/dist/shared/assistant/askAbout/useAskable.js +6 -5
  7. package/dist/shared/assistant/i18nManifest.d.ts +40 -0
  8. package/dist/shared/assistant/i18nManifest.js +40 -0
  9. package/dist/shared/proactive/ProactiveProvider.d.ts +67 -0
  10. package/dist/shared/proactive/ProactiveProvider.js +128 -0
  11. package/dist/shared/proactive/actions.d.ts +101 -0
  12. package/dist/shared/proactive/actions.js +71 -0
  13. package/dist/shared/proactive/activity.d.ts +27 -0
  14. package/dist/shared/proactive/activity.js +37 -0
  15. package/dist/shared/proactive/adapters.d.ts +54 -0
  16. package/dist/shared/proactive/adapters.js +62 -0
  17. package/dist/shared/proactive/anchors.d.ts +47 -0
  18. package/dist/shared/proactive/anchors.js +53 -0
  19. package/dist/shared/proactive/budget.d.ts +17 -0
  20. package/dist/shared/proactive/budget.js +30 -0
  21. package/dist/shared/proactive/capabilities.d.ts +26 -0
  22. package/dist/shared/proactive/capabilities.js +63 -0
  23. package/dist/shared/proactive/coalesce.d.ts +11 -0
  24. package/dist/shared/proactive/coalesce.js +15 -0
  25. package/dist/shared/proactive/context.d.ts +42 -0
  26. package/dist/shared/proactive/context.js +31 -0
  27. package/dist/shared/proactive/flags.d.ts +5 -0
  28. package/dist/shared/proactive/flags.js +11 -0
  29. package/dist/shared/proactive/index.d.ts +40 -0
  30. package/dist/shared/proactive/metadata.d.ts +48 -0
  31. package/dist/shared/proactive/metadata.js +126 -0
  32. package/dist/shared/proactive/operations.d.ts +96 -0
  33. package/dist/shared/proactive/operations.js +117 -0
  34. package/dist/shared/proactive/severityCopy.d.ts +4 -0
  35. package/dist/shared/proactive/severityCopy.js +10 -0
  36. package/dist/shared/proactive/snooze.d.ts +4 -0
  37. package/dist/shared/proactive/snooze.js +9 -0
  38. package/dist/shared/proactive/transport.d.ts +32 -0
  39. package/dist/shared/proactive/transport.js +124 -0
  40. package/dist/shared/proactive/types.d.ts +83 -0
  41. package/dist/shared/proactive/ui/ProactiveInbox.d.ts +20 -0
  42. package/dist/shared/proactive/ui/ProactiveInbox.js +78 -0
  43. package/dist/shared/proactive/ui/ProactiveSettingsPanel.d.ts +8 -0
  44. package/dist/shared/proactive/ui/ProactiveSettingsPanel.js +210 -0
  45. package/dist/shared/proactive/ui/SuggestionAnchorsLayer.d.ts +9 -0
  46. package/dist/shared/proactive/ui/SuggestionAnchorsLayer.js +140 -0
  47. package/dist/shared/proactive/ui/SuggestionBadge.d.ts +11 -0
  48. package/dist/shared/proactive/ui/SuggestionBadge.js +53 -0
  49. package/dist/shared/proactive/ui/SuggestionCard.d.ts +23 -0
  50. package/dist/shared/proactive/ui/SuggestionCard.js +119 -0
  51. package/dist/shared/proactive/ui/anchorLayerDom.d.ts +28 -0
  52. package/dist/shared/proactive/ui/anchorLayerDom.js +23 -0
  53. package/dist/shared/proactive/useProactiveSession.d.ts +56 -0
  54. package/dist/shared/proactive/useProactiveSession.js +150 -0
  55. package/dist/shared/proactive/useSuggestionControls.d.ts +25 -0
  56. package/dist/shared/proactive/useSuggestionControls.js +118 -0
  57. package/dist/shared-assistant.js +301 -301
  58. package/dist/shared-proactive.d.ts +2 -0
  59. package/dist/shared-proactive.js +21 -0
  60. package/package.json +5 -1
@@ -0,0 +1,48 @@
1
+ import { ProactiveSeverity, ProactiveSuggestion } from './types';
2
+ /** The notification category every proactive suggestion carries (contract C3). */
3
+ export declare const PROACTIVE_CATEGORY = "proactive";
4
+ /** The payload discriminator and version this client understands (contract C4). */
5
+ export declare const PROACTIVE_SUGGESTION_KIND = "proactive-suggestion";
6
+ export declare const PROACTIVE_SUGGESTION_VERSION = 1;
7
+ export declare const PROACTIVE_TITLE_MAX = 80;
8
+ export declare const PROACTIVE_WHY_MAX = 400;
9
+ export declare const PROACTIVE_ACTION_LABEL_MAX = 60;
10
+ /** At most this many actions are kept per suggestion; the rest are ignored. */
11
+ export declare const PROACTIVE_MAX_ACTIONS = 4;
12
+ export declare const PROACTIVE_SEVERITIES: readonly ProactiveSeverity[];
13
+ /** Product slug: the same shape the assistant accepts for `x-product-id`. */
14
+ export declare const PROACTIVE_PRODUCT_PATTERN: RegExp;
15
+ /** An action type: a built-in (`navigate`, …) or a product-registered one. */
16
+ export declare const PROACTIVE_ACTION_TYPE_PATTERN: RegExp;
17
+ /**
18
+ * Plain text, safe to render as one line or paragraph: unsafe characters become
19
+ * spaces, runs of whitespace collapse to one space, and the ends are trimmed.
20
+ */
21
+ export declare function normalizePlainText(value: string): string;
22
+ /** The fields of a notification row this module reads. */
23
+ export interface ProactiveNotificationRow {
24
+ id: string;
25
+ appName?: string | null;
26
+ category?: string | null;
27
+ isRead?: boolean | null;
28
+ createdAt?: string | null;
29
+ snoozedUntil?: string | null;
30
+ archivedAt?: string | null;
31
+ metadata?: unknown;
32
+ }
33
+ /**
34
+ * One notification row to a suggestion, or null when it is not a valid, active
35
+ * proactive suggestion for `product`.
36
+ *
37
+ * Refused: another category, another product (on the row or in the payload),
38
+ * an archived row, a row snoozed into the future, and any payload that does not
39
+ * match contract C4 version 1.
40
+ */
41
+ export declare function parseProactiveSuggestion(row: ProactiveNotificationRow, product: string, now?: number): ProactiveSuggestion | null;
42
+ /**
43
+ * Every valid suggestion among `rows`, one per finding: when two notifications
44
+ * carry the same `findingKey`, the newer one wins.
45
+ */
46
+ export declare function parseProactiveSuggestions(rows: readonly ProactiveNotificationRow[], product: string, now?: number): ProactiveSuggestion[];
47
+ /** A suggestion's creation time in ms, or 0 when it cannot be read. */
48
+ export declare function createdAtMs(suggestion: Pick<ProactiveSuggestion, 'createdAt'>): number;
@@ -0,0 +1,126 @@
1
+ import { z as e } from "zod";
2
+ // src/shared/proactive/metadata.ts
3
+ var t = "proactive", n = "proactive-suggestion", r = 1, i = 80, a = 400, o = 60, s = 4, c = [
4
+ "low",
5
+ "medium",
6
+ "high",
7
+ "urgent"
8
+ ], l = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/, u = /^[a-z][a-z0-9-]{0,63}$/;
9
+ function d(e) {
10
+ return e <= 31 || e >= 127 && e <= 159 || e === 8206 || e === 8207 || e >= 8234 && e <= 8238 || e >= 8294 && e <= 8297;
11
+ }
12
+ function f(e) {
13
+ for (let t = 0; t < e.length; t += 1) if (d(e.charCodeAt(t)) || /\s/.test(e[t] ?? "")) return !1;
14
+ return !0;
15
+ }
16
+ function p(e) {
17
+ let t = "";
18
+ for (let n = 0; n < e.length; n += 1) t += d(e.charCodeAt(n)) ? " " : e[n];
19
+ return t.replace(/\s+/g, " ").trim();
20
+ }
21
+ var m = (t) => e.string().transform(p).pipe(e.string().min(1).max(t)), h = (t) => e.string().min(1).max(t).refine(f, "must be one segment of printable text"), g = e.object({
22
+ entityType: h(64),
23
+ entityId: h(256),
24
+ part: h(128).optional()
25
+ }), _ = e.object({
26
+ id: h(64),
27
+ type: e.string().regex(u),
28
+ label: m(60),
29
+ args: e.record(e.string(), e.unknown()).optional()
30
+ }), v = e.object({
31
+ jobId: e.string().max(256).optional(),
32
+ model: e.string().max(256).optional(),
33
+ packVersion: e.string().min(1).max(64),
34
+ createdAt: e.string().min(1).max(64)
35
+ }), y = e.object({
36
+ kind: e.literal(n),
37
+ v: e.literal(1),
38
+ suggestionId: h(128),
39
+ findingKey: e.string().min(1).max(512),
40
+ product: e.string().regex(l),
41
+ anchor: g,
42
+ severity: e.enum([
43
+ "low",
44
+ "medium",
45
+ "high",
46
+ "urgent"
47
+ ]),
48
+ title: m(80),
49
+ why: m(400),
50
+ ai: e.literal(!0),
51
+ actions: e.array(e.unknown()).max(32).optional(),
52
+ provenance: v
53
+ });
54
+ function b(e) {
55
+ if (!e) return [];
56
+ let t = [], n = /* @__PURE__ */ new Set();
57
+ for (let r of e) {
58
+ let e = _.safeParse(r);
59
+ if (e.success && !n.has(e.data.id) && (n.add(e.data.id), t.push({
60
+ id: e.data.id,
61
+ type: e.data.type,
62
+ label: e.data.label,
63
+ args: e.data.args ?? {}
64
+ }), t.length === 4)) break;
65
+ }
66
+ return t;
67
+ }
68
+ function x(e) {
69
+ if (typeof e != "string") return e;
70
+ try {
71
+ return JSON.parse(e);
72
+ } catch {
73
+ return null;
74
+ }
75
+ }
76
+ function S(e, t) {
77
+ if (!e) return !1;
78
+ let n = Date.parse(e);
79
+ return Number.isFinite(n) && n > t;
80
+ }
81
+ function C(e, t, n = Date.now()) {
82
+ if (!e || typeof e.id != "string" || e.id.length === 0 || e.category !== "proactive" || e.appName !== t || e.archivedAt || S(e.snoozedUntil, n)) return null;
83
+ let r = y.safeParse(x(e.metadata));
84
+ if (!r.success) return null;
85
+ let i = r.data;
86
+ if (i.product !== t) return null;
87
+ let a = {
88
+ entityType: i.anchor.entityType,
89
+ entityId: i.anchor.entityId,
90
+ ...i.anchor.part ? { part: i.anchor.part } : {}
91
+ }, o = {
92
+ packVersion: i.provenance.packVersion,
93
+ createdAt: i.provenance.createdAt,
94
+ ...i.provenance.jobId ? { jobId: i.provenance.jobId } : {},
95
+ ...i.provenance.model ? { model: i.provenance.model } : {}
96
+ };
97
+ return {
98
+ notificationId: e.id,
99
+ suggestionId: i.suggestionId,
100
+ findingKey: i.findingKey,
101
+ product: i.product,
102
+ anchor: a,
103
+ severity: i.severity,
104
+ title: i.title,
105
+ why: i.why,
106
+ actions: b(i.actions),
107
+ provenance: o,
108
+ isRead: e.isRead === !0,
109
+ createdAt: typeof e.createdAt == "string" ? e.createdAt : i.provenance.createdAt
110
+ };
111
+ }
112
+ function w(e, t, n = Date.now()) {
113
+ let r = /* @__PURE__ */ new Map();
114
+ for (let i of e) {
115
+ let e = C(i, t, n);
116
+ if (!e) continue;
117
+ let a = r.get(e.findingKey);
118
+ (!a || T(e) > T(a)) && r.set(e.findingKey, e);
119
+ }
120
+ return [...r.values()];
121
+ }
122
+ function T(e) {
123
+ let t = Date.parse(e.createdAt);
124
+ return Number.isFinite(t) ? t : 0;
125
+ }
126
+ export { o as PROACTIVE_ACTION_LABEL_MAX, u as PROACTIVE_ACTION_TYPE_PATTERN, t as PROACTIVE_CATEGORY, s as PROACTIVE_MAX_ACTIONS, l as PROACTIVE_PRODUCT_PATTERN, c as PROACTIVE_SEVERITIES, n as PROACTIVE_SUGGESTION_KIND, r as PROACTIVE_SUGGESTION_VERSION, i as PROACTIVE_TITLE_MAX, a as PROACTIVE_WHY_MAX, T as createdAtMs, p as normalizePlainText, C as parseProactiveSuggestion, w as parseProactiveSuggestions };
@@ -0,0 +1,96 @@
1
+ import { TypedDocumentNode } from '@apollo/client';
2
+ import { ProactiveActivityEntity, ProactiveFrequency, ProactiveSettings, ProactiveSettingsInput } from './types';
3
+ /** The notification fields a suggestion needs. */
4
+ export interface ProactiveNotificationItem {
5
+ id: string;
6
+ appName: string | null;
7
+ category: string | null;
8
+ isRead: boolean;
9
+ createdAt: string;
10
+ snoozedUntil: string | null;
11
+ archivedAt: string | null;
12
+ metadata: unknown;
13
+ }
14
+ export interface ProactiveNotificationsData {
15
+ notifications: {
16
+ items: ProactiveNotificationItem[];
17
+ total: number;
18
+ hasMore: boolean;
19
+ };
20
+ }
21
+ /** The filter every proactive read uses: this product's live in-app suggestions. */
22
+ export declare function proactiveNotificationFilter(product: string): Record<string, unknown>;
23
+ /** How many suggestions one read loads. The inbox is a short list by design. */
24
+ export declare const PROACTIVE_LIST_LIMIT = 50;
25
+ export declare const PROACTIVE_NOTIFICATIONS_QUERY: TypedDocumentNode<ProactiveNotificationsData, {
26
+ filter: Record<string, unknown>;
27
+ limit: number;
28
+ offset: number;
29
+ }>;
30
+ /**
31
+ * The unread-count stream the notification bell already uses, narrowed to this
32
+ * product's suggestions. Self-scoped, so it needs no user id. Every new value is
33
+ * a signal that the list may have changed.
34
+ */
35
+ export declare const PROACTIVE_UNREAD_COUNT_SUBSCRIPTION: TypedDocumentNode<{
36
+ myUnreadNotificationCountStream: number;
37
+ }, {
38
+ filter: Record<string, unknown>;
39
+ }>;
40
+ /** New and resurfaced notifications for one user (needs the user id). */
41
+ export declare const PROACTIVE_NOTIFICATION_RECEIVED_SUBSCRIPTION: TypedDocumentNode<{
42
+ notificationReceived: {
43
+ id: string;
44
+ appName: string | null;
45
+ category: string | null;
46
+ } | null;
47
+ }, {
48
+ userId: string;
49
+ }>;
50
+ /** Dismiss = archive (contract C4). */
51
+ export declare const PROACTIVE_ARCHIVE_MUTATION: TypedDocumentNode<{
52
+ archiveNotification: {
53
+ id: string;
54
+ archivedAt: string | null;
55
+ };
56
+ }, {
57
+ id: string;
58
+ }>;
59
+ export declare const PROACTIVE_SNOOZE_MUTATION: TypedDocumentNode<{
60
+ snoozeNotification: {
61
+ id: string;
62
+ snoozedUntil: string | null;
63
+ };
64
+ }, {
65
+ id: string;
66
+ until: string;
67
+ }>;
68
+ export declare const PROACTIVE_UNSNOOZE_MUTATION: TypedDocumentNode<{
69
+ unsnoozeNotification: {
70
+ id: string;
71
+ snoozedUntil: string | null;
72
+ };
73
+ }, {
74
+ id: string;
75
+ }>;
76
+ export declare const PROACTIVE_MARK_READ_MUTATION: TypedDocumentNode<{
77
+ markNotificationAsRead: {
78
+ id: string;
79
+ isRead: boolean;
80
+ };
81
+ }, {
82
+ id: string;
83
+ }>;
84
+ export declare const PROACTIVE_FREQUENCIES: readonly ProactiveFrequency[];
85
+ /** Entity types and ids the activity report accepts. */
86
+ export declare const ACTIVITY_ENTITY_TYPE_PATTERN: RegExp;
87
+ export declare const ACTIVITY_ENTITY_ID_PATTERN: RegExp;
88
+ export declare class ProactiveInputError extends Error {
89
+ constructor(what: string);
90
+ }
91
+ /** `reportProactiveActivity` for this product and, when given, the open entity. */
92
+ export declare function reportActivityDocument(product: string, entity: ProactiveActivityEntity | null): string;
93
+ export declare function mySettingsDocument(product: string): string;
94
+ export declare function setSettingsDocument(product: string, input: ProactiveSettingsInput): string;
95
+ /** A settings object from the wire, or null when it does not have the C5 shape. */
96
+ export declare function readSettings(value: unknown): ProactiveSettings | null;
@@ -0,0 +1,117 @@
1
+ import { PROACTIVE_CATEGORY as e, PROACTIVE_PRODUCT_PATTERN as t } from "./metadata.js";
2
+ import { gql as n } from "@apollo/client";
3
+ // src/shared/proactive/operations.ts
4
+ function r(t) {
5
+ return {
6
+ channel: "IN_APP",
7
+ archived: !1,
8
+ category: e,
9
+ appName: t
10
+ };
11
+ }
12
+ var i = 50, a = n`
13
+ query ProactiveSuggestions($filter: NotificationFilterInput, $limit: Int, $offset: Int) {
14
+ notifications(filter: $filter, limit: $limit, offset: $offset) {
15
+ items {
16
+ id
17
+ appName
18
+ category
19
+ isRead
20
+ createdAt
21
+ snoozedUntil
22
+ archivedAt
23
+ metadata
24
+ }
25
+ total
26
+ hasMore
27
+ }
28
+ }
29
+ `, o = n`
30
+ subscription ProactiveSuggestionCount($filter: NotificationFilterInput) {
31
+ myUnreadNotificationCountStream(filter: $filter)
32
+ }
33
+ `, s = n`
34
+ subscription ProactiveNotificationReceived($userId: ID!) {
35
+ notificationReceived(userId: $userId) {
36
+ id
37
+ appName
38
+ category
39
+ }
40
+ }
41
+ `, c = n`
42
+ mutation ProactiveDismissSuggestion($id: ID!) {
43
+ archiveNotification(id: $id) {
44
+ id
45
+ archivedAt
46
+ }
47
+ }
48
+ `, l = n`
49
+ mutation ProactiveSnoozeSuggestion($id: ID!, $until: DateTime!) {
50
+ snoozeNotification(id: $id, until: $until) {
51
+ id
52
+ snoozedUntil
53
+ }
54
+ }
55
+ `, u = n`
56
+ mutation ProactiveUnsnoozeSuggestion($id: ID!) {
57
+ unsnoozeNotification(id: $id) {
58
+ id
59
+ snoozedUntil
60
+ }
61
+ }
62
+ `, d = n`
63
+ mutation ProactiveMarkSuggestionRead($id: ID!) {
64
+ markNotificationAsRead(id: $id) {
65
+ id
66
+ isRead
67
+ }
68
+ }
69
+ `, f = [
70
+ "IMMEDIATE",
71
+ "DAILY_DIGEST",
72
+ "WEEKLY_DIGEST"
73
+ ], p = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$/, m = /^[A-Za-z0-9][A-Za-z0-9_.:@-]{0,127}$/, h = class extends Error {
74
+ constructor(e) {
75
+ super(`Refused to send an invalid proactive ${e}.`), this.name = "ProactiveInputError";
76
+ }
77
+ };
78
+ function g(e) {
79
+ if (!t.test(e)) throw new h("product");
80
+ return JSON.stringify(e);
81
+ }
82
+ function _(e) {
83
+ return typeof e == "string" && f.includes(e);
84
+ }
85
+ var v = "enabled consentExpiresAt frequency";
86
+ function y(e, t) {
87
+ let n = [`product: ${g(e)}`];
88
+ if (t) {
89
+ if (!p.test(t.entityType) || !m.test(t.entityId)) throw new h("entity");
90
+ n.push(`entityType: ${JSON.stringify(t.entityType)}`), n.push(`entityId: ${JSON.stringify(t.entityId)}`);
91
+ }
92
+ return `mutation ReportProactiveActivity { reportProactiveActivity(input: { ${n.join(", ")} }) }`;
93
+ }
94
+ function b(e) {
95
+ return `query MyProactiveSettings { myProactiveSettings(product: ${g(e)}) { ${v} } }`;
96
+ }
97
+ function x(e, t) {
98
+ if (typeof t.enabled != "boolean") throw new h("setting");
99
+ let n = [`product: ${g(e)}`, `enabled: ${t.enabled}`];
100
+ if (t.frequency !== void 0) {
101
+ if (!_(t.frequency)) throw new h("frequency");
102
+ n.push(`frequency: ${t.frequency}`);
103
+ }
104
+ return `mutation SetMyProactiveSettings { setMyProactiveSettings(input: { ${n.join(", ")} }) { ${v} } }`;
105
+ }
106
+ function S(e) {
107
+ if (!e || typeof e != "object") return null;
108
+ let t = e;
109
+ if (typeof t.enabled != "boolean") return null;
110
+ let n = typeof t.consentExpiresAt == "string" && t.consentExpiresAt.length > 0 ? t.consentExpiresAt : null;
111
+ return {
112
+ enabled: t.enabled,
113
+ consentExpiresAt: n,
114
+ frequency: _(t.frequency) ? t.frequency : "IMMEDIATE"
115
+ };
116
+ }
117
+ export { m as ACTIVITY_ENTITY_ID_PATTERN, p as ACTIVITY_ENTITY_TYPE_PATTERN, c as PROACTIVE_ARCHIVE_MUTATION, f as PROACTIVE_FREQUENCIES, i as PROACTIVE_LIST_LIMIT, d as PROACTIVE_MARK_READ_MUTATION, a as PROACTIVE_NOTIFICATIONS_QUERY, s as PROACTIVE_NOTIFICATION_RECEIVED_SUBSCRIPTION, l as PROACTIVE_SNOOZE_MUTATION, o as PROACTIVE_UNREAD_COUNT_SUBSCRIPTION, u as PROACTIVE_UNSNOOZE_MUTATION, h as ProactiveInputError, b as mySettingsDocument, r as proactiveNotificationFilter, S as readSettings, y as reportActivityDocument, x as setSettingsDocument };
@@ -0,0 +1,4 @@
1
+ import { AssistantTr } from '../assistant/i18n';
2
+ import { ProactiveSeverity } from './types';
3
+ /** The severity in words. Literal keys, one per severity, so each is seeded. */
4
+ export declare function severityLabel(tr: AssistantTr, severity: ProactiveSeverity): string;
@@ -0,0 +1,10 @@
1
+ // src/shared/proactive/severityCopy.ts
2
+ function e(e, t) {
3
+ switch (t) {
4
+ case "urgent": return e("proactive.severity.urgent", "Urgent");
5
+ case "high": return e("proactive.severity.high", "High");
6
+ case "medium": return e("proactive.severity.medium", "Medium");
7
+ case "low": return e("proactive.severity.low", "Low");
8
+ }
9
+ }
10
+ export { e as severityLabel };
@@ -0,0 +1,4 @@
1
+ import { ProactiveSnoozeDuration } from './types';
2
+ export declare const SNOOZE_DURATION_MS: Readonly<Record<ProactiveSnoozeDuration, number>>;
3
+ /** The ISO-8601 instant a snooze of `duration` started at `now` ends. */
4
+ export declare function snoozeUntil(duration: ProactiveSnoozeDuration, now?: number): string;
@@ -0,0 +1,9 @@
1
+ // src/shared/proactive/snooze.ts
2
+ var e = 864e5, t = {
3
+ "1d": e,
4
+ "1w": 7 * e
5
+ };
6
+ function n(e, n = Date.now()) {
7
+ return new Date(n + t[e]).toISOString();
8
+ }
9
+ export { t as SNOOZE_DURATION_MS, n as snoozeUntil };
@@ -0,0 +1,32 @@
1
+ import { ApolloClient } from '@apollo/client';
2
+ import { ProactiveNotificationItem } from './operations';
3
+ import { ProactiveActivityEntity, ProactiveSettings, ProactiveSettingsInput } from './types';
4
+ export interface ProactiveTransport {
5
+ /** This product's live suggestion notifications (unvalidated rows). */
6
+ listSuggestionRows(product: string): Promise<ProactiveNotificationItem[]>;
7
+ /**
8
+ * Call `onChange` whenever the suggestion list may have changed. `onError`
9
+ * gets subscription failures (the caller decides whether they mean
10
+ * "unsupported"). Returns the unsubscribe.
11
+ */
12
+ watchSuggestions(product: string, onChange: () => void, onError: (error: unknown) => void): () => void;
13
+ dismiss(notificationId: string): Promise<void>;
14
+ snooze(notificationId: string, until: string): Promise<void>;
15
+ unsnooze(notificationId: string): Promise<void>;
16
+ markRead(notificationId: string): Promise<void>;
17
+ reportActivity(product: string, entity: ProactiveActivityEntity | null): Promise<void>;
18
+ getSettings(product: string): Promise<ProactiveSettings>;
19
+ setSettings(product: string, input: ProactiveSettingsInput): Promise<ProactiveSettings>;
20
+ }
21
+ export interface ApolloProactiveTransportOptions {
22
+ /** The global-gateway client (notifications). */
23
+ globalClient: ApolloClient;
24
+ /** The workspace-gateway client (the orchestrator in wspace-sandbox-svc). */
25
+ workspaceClient: ApolloClient;
26
+ /**
27
+ * The signed-in user's id. With it, `notificationReceived` is watched too, so a
28
+ * new suggestion appears at once even when the unread count did not change.
29
+ */
30
+ userId?: string | null;
31
+ }
32
+ export declare function createApolloProactiveTransport({ globalClient, workspaceClient, userId, }: ApolloProactiveTransportOptions): ProactiveTransport;
@@ -0,0 +1,124 @@
1
+ import { PROACTIVE_ARCHIVE_MUTATION as e, PROACTIVE_MARK_READ_MUTATION as t, PROACTIVE_NOTIFICATIONS_QUERY as n, PROACTIVE_NOTIFICATION_RECEIVED_SUBSCRIPTION as r, PROACTIVE_SNOOZE_MUTATION as i, PROACTIVE_UNREAD_COUNT_SUBSCRIPTION as a, PROACTIVE_UNSNOOZE_MUTATION as o, mySettingsDocument as s, proactiveNotificationFilter as c, readSettings as l, reportActivityDocument as u, setSettingsDocument as d } from "./operations.js";
2
+ import "./metadata.js";
3
+ import { gql as f } from "@apollo/client";
4
+ // src/shared/proactive/transport.ts
5
+ var p = { preferWorkspaceAuth: !0 }, m = /* @__PURE__ */ new Map();
6
+ function h(e) {
7
+ let t = m.get(e);
8
+ if (t) return t;
9
+ let n = f(e);
10
+ return m.size > 200 && m.clear(), m.set(e, n), n;
11
+ }
12
+ var g = class extends Error {
13
+ constructor(e) {
14
+ super(`${e} returned no usable data.`), this.name = "ProactiveResponseError";
15
+ }
16
+ };
17
+ function _({ globalClient: f, workspaceClient: m, userId: _ }) {
18
+ return {
19
+ async listSuggestionRows(e) {
20
+ let t = (await f.query({
21
+ query: n,
22
+ variables: {
23
+ filter: c(e),
24
+ limit: 50,
25
+ offset: 0
26
+ },
27
+ fetchPolicy: "no-cache",
28
+ context: p
29
+ })).data?.notifications?.items;
30
+ if (!Array.isArray(t)) throw new g("notifications");
31
+ return t;
32
+ },
33
+ watchSuggestions(e, t, n) {
34
+ let i = [], o = null;
35
+ return i.push(f.subscribe({
36
+ query: a,
37
+ variables: { filter: c(e) },
38
+ fetchPolicy: "no-cache",
39
+ context: p
40
+ }).subscribe({
41
+ next: (e) => {
42
+ if (e.error) {
43
+ n(e.error);
44
+ return;
45
+ }
46
+ let r = e.data?.myUnreadNotificationCountStream;
47
+ typeof r == "number" && (o !== null && r !== o && t(), o = r);
48
+ },
49
+ error: n
50
+ })), _ && i.push(f.subscribe({
51
+ query: r,
52
+ variables: { userId: _ },
53
+ fetchPolicy: "no-cache",
54
+ context: p
55
+ }).subscribe({
56
+ next: (n) => {
57
+ let r = n.data?.notificationReceived;
58
+ r?.category === "proactive" && r.appName === e && t();
59
+ },
60
+ error: () => {}
61
+ })), () => {
62
+ for (let e of i) e.unsubscribe();
63
+ };
64
+ },
65
+ async dismiss(t) {
66
+ await f.mutate({
67
+ mutation: e,
68
+ variables: { id: t },
69
+ fetchPolicy: "no-cache",
70
+ context: p
71
+ });
72
+ },
73
+ async snooze(e, t) {
74
+ await f.mutate({
75
+ mutation: i,
76
+ variables: {
77
+ id: e,
78
+ until: t
79
+ },
80
+ fetchPolicy: "no-cache",
81
+ context: p
82
+ });
83
+ },
84
+ async unsnooze(e) {
85
+ await f.mutate({
86
+ mutation: o,
87
+ variables: { id: e },
88
+ fetchPolicy: "no-cache",
89
+ context: p
90
+ });
91
+ },
92
+ async markRead(e) {
93
+ await f.mutate({
94
+ mutation: t,
95
+ variables: { id: e },
96
+ fetchPolicy: "no-cache",
97
+ context: p
98
+ });
99
+ },
100
+ async reportActivity(e, t) {
101
+ await m.mutate({
102
+ mutation: h(u(e, t)),
103
+ fetchPolicy: "no-cache"
104
+ });
105
+ },
106
+ async getSettings(e) {
107
+ let t = await m.query({
108
+ query: h(s(e)),
109
+ fetchPolicy: "no-cache"
110
+ }), n = l(t.data?.myProactiveSettings);
111
+ if (!n) throw new g("myProactiveSettings");
112
+ return n;
113
+ },
114
+ async setSettings(e, t) {
115
+ let n = await m.mutate({
116
+ mutation: h(d(e, t)),
117
+ fetchPolicy: "no-cache"
118
+ }), r = l(n.data?.setMyProactiveSettings);
119
+ if (!r) throw new g("setMyProactiveSettings");
120
+ return r;
121
+ }
122
+ };
123
+ }
124
+ export { _ as createApolloProactiveTransport };
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Public types of the proactive suggestions module (BOFF-13165, epic BOFF-13159).
3
+ *
4
+ * A suggestion is an IN_APP notification in global-notification-svc with
5
+ * `category = "proactive"`, `appName = <product>` and a `metadata` payload that
6
+ * follows contract C4. Everything here is the CLIENT view of that payload after
7
+ * validation: anything that failed validation never becomes one of these.
8
+ */
9
+ /** Contract C4 severities, lowest first. */
10
+ export type ProactiveSeverity = 'low' | 'medium' | 'high' | 'urgent';
11
+ /** Where a suggestion belongs in the UI (contract C4 `anchor`, C7 attribute). */
12
+ export interface ProactiveAnchor {
13
+ entityType: string;
14
+ entityId: string;
15
+ /** A part of the entity, e.g. one node of a workflow. */
16
+ part?: string;
17
+ }
18
+ /** One action a suggestion offers. `args` were produced by the detector, never by a model. */
19
+ export interface ProactiveSuggestionAction {
20
+ id: string;
21
+ type: string;
22
+ label: string;
23
+ args: Readonly<Record<string, unknown>>;
24
+ }
25
+ export interface ProactiveProvenance {
26
+ jobId?: string;
27
+ model?: string;
28
+ packVersion: string;
29
+ createdAt: string;
30
+ }
31
+ /** A validated suggestion, ready to render. `title` and `why` are plain text. */
32
+ export interface ProactiveSuggestion {
33
+ /** The notification row it came from: dismiss archives it, snooze snoozes it. */
34
+ notificationId: string;
35
+ suggestionId: string;
36
+ findingKey: string;
37
+ product: string;
38
+ anchor: ProactiveAnchor;
39
+ severity: ProactiveSeverity;
40
+ title: string;
41
+ why: string;
42
+ actions: readonly ProactiveSuggestionAction[];
43
+ provenance: ProactiveProvenance;
44
+ isRead: boolean;
45
+ /** When the notification was created (ISO-8601). */
46
+ createdAt: string;
47
+ }
48
+ /** Contract C5 delivery frequency for a user who is away. */
49
+ export type ProactiveFrequency = 'IMMEDIATE' | 'DAILY_DIGEST' | 'WEEKLY_DIGEST';
50
+ /** Contract C5 `ProactiveSettings`. */
51
+ export interface ProactiveSettings {
52
+ enabled: boolean;
53
+ consentExpiresAt: string | null;
54
+ frequency: ProactiveFrequency;
55
+ }
56
+ /** What `setMyProactiveSettings` is asked to store. */
57
+ export interface ProactiveSettingsInput {
58
+ enabled: boolean;
59
+ /** Omitted: the stored frequency is left as it is. */
60
+ frequency?: ProactiveFrequency;
61
+ }
62
+ /** The entity the user has open, as reported by `reportProactiveActivity`. */
63
+ export interface ProactiveActivityEntity {
64
+ entityType: string;
65
+ entityId: string;
66
+ }
67
+ /** How long a snooze lasts. */
68
+ export type ProactiveSnoozeDuration = '1d' | '1w';
69
+ /**
70
+ * Where the module is, for the current product and user.
71
+ *
72
+ * - `disabled`: a feature flag is off, no product is known, or the host gave no
73
+ * gateway client. Nothing is requested and nothing is shown.
74
+ * - `unsupported`: the gateway does not know the proactive fields yet (the
75
+ * backends are not deployed). Nothing is shown, and nothing is retried on this
76
+ * page load.
77
+ * - `loading`: the settings are being read.
78
+ * - `opted-out`: the user has not turned proactive suggestions on.
79
+ * - `ready`: suggestions are loaded and live.
80
+ * - `error`: a read failed for another reason; the last good state is kept and
81
+ * the read is retried on the next change signal.
82
+ */
83
+ export type ProactiveStatus = 'disabled' | 'unsupported' | 'loading' | 'opted-out' | 'ready' | 'error';
@@ -0,0 +1,20 @@
1
+ export interface ProactiveInboxProps {
2
+ className?: string;
3
+ /** Called after a suggestion's action ran, or it was dismissed or snoozed. */
4
+ onSettled?: () => void;
5
+ /** Hide the inbox's own heading (when the host already titles it). */
6
+ hideHeading?: boolean;
7
+ }
8
+ export declare function ProactiveInbox({ className, onSettled, hideHeading }: ProactiveInboxProps): import('react').JSX.Element | null;
9
+ export interface ProactiveInboxButtonProps {
10
+ className?: string;
11
+ side?: 'top' | 'right' | 'bottom' | 'left';
12
+ align?: 'start' | 'center' | 'end';
13
+ }
14
+ /**
15
+ * A header button with the live suggestion count, opening the inbox in a
16
+ * popover. The count is in the button's `aria-label`; the ONE polite live
17
+ * region that announces changes belongs to the provider, so the count is never
18
+ * read out twice.
19
+ */
20
+ export declare function ProactiveInboxButton({ className, side, align, }: ProactiveInboxButtonProps): import('react').JSX.Element | null;