@burdenoff/fe-libs 2026.1112.6 → 2026.1113.2
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/shared/assistant/i18nManifest.d.ts +40 -0
- package/dist/shared/assistant/i18nManifest.js +40 -0
- package/dist/shared/proactive/ProactiveProvider.d.ts +67 -0
- package/dist/shared/proactive/ProactiveProvider.js +128 -0
- package/dist/shared/proactive/actions.d.ts +101 -0
- package/dist/shared/proactive/actions.js +71 -0
- package/dist/shared/proactive/activity.d.ts +27 -0
- package/dist/shared/proactive/activity.js +37 -0
- package/dist/shared/proactive/adapters.d.ts +54 -0
- package/dist/shared/proactive/adapters.js +62 -0
- package/dist/shared/proactive/anchors.d.ts +47 -0
- package/dist/shared/proactive/anchors.js +53 -0
- package/dist/shared/proactive/budget.d.ts +17 -0
- package/dist/shared/proactive/budget.js +30 -0
- package/dist/shared/proactive/capabilities.d.ts +26 -0
- package/dist/shared/proactive/capabilities.js +63 -0
- package/dist/shared/proactive/coalesce.d.ts +11 -0
- package/dist/shared/proactive/coalesce.js +15 -0
- package/dist/shared/proactive/context.d.ts +42 -0
- package/dist/shared/proactive/context.js +31 -0
- package/dist/shared/proactive/flags.d.ts +5 -0
- package/dist/shared/proactive/flags.js +11 -0
- package/dist/shared/proactive/index.d.ts +40 -0
- package/dist/shared/proactive/metadata.d.ts +48 -0
- package/dist/shared/proactive/metadata.js +126 -0
- package/dist/shared/proactive/operations.d.ts +96 -0
- package/dist/shared/proactive/operations.js +117 -0
- package/dist/shared/proactive/severityCopy.d.ts +4 -0
- package/dist/shared/proactive/severityCopy.js +10 -0
- package/dist/shared/proactive/snooze.d.ts +4 -0
- package/dist/shared/proactive/snooze.js +9 -0
- package/dist/shared/proactive/transport.d.ts +32 -0
- package/dist/shared/proactive/transport.js +124 -0
- package/dist/shared/proactive/types.d.ts +83 -0
- package/dist/shared/proactive/ui/ProactiveInbox.d.ts +20 -0
- package/dist/shared/proactive/ui/ProactiveInbox.js +78 -0
- package/dist/shared/proactive/ui/ProactiveSettingsPanel.d.ts +8 -0
- package/dist/shared/proactive/ui/ProactiveSettingsPanel.js +210 -0
- package/dist/shared/proactive/ui/SuggestionAnchorsLayer.d.ts +9 -0
- package/dist/shared/proactive/ui/SuggestionAnchorsLayer.js +140 -0
- package/dist/shared/proactive/ui/SuggestionBadge.d.ts +11 -0
- package/dist/shared/proactive/ui/SuggestionBadge.js +53 -0
- package/dist/shared/proactive/ui/SuggestionCard.d.ts +23 -0
- package/dist/shared/proactive/ui/SuggestionCard.js +119 -0
- package/dist/shared/proactive/ui/anchorLayerDom.d.ts +28 -0
- package/dist/shared/proactive/ui/anchorLayerDom.js +23 -0
- package/dist/shared/proactive/useProactiveSession.d.ts +56 -0
- package/dist/shared/proactive/useProactiveSession.js +150 -0
- package/dist/shared/proactive/useSuggestionControls.d.ts +25 -0
- package/dist/shared/proactive/useSuggestionControls.js +118 -0
- package/dist/shared/providers/shell/PermissionProvider.d.ts +16 -0
- package/dist/shared/providers/shell/PermissionProvider.js +51 -30
- package/dist/shared/providers/shell/index.d.ts +1 -1
- package/dist/shared-proactive.d.ts +2 -0
- package/dist/shared-proactive.js +21 -0
- package/dist/shared-providers-shell.js +14 -14
- package/package.json +5 -1
|
@@ -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,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,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;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { usePrefersReducedMotion as e } from "../../assistant/ui/usePrefersReducedMotion.js";
|
|
2
|
+
import { Popover as t, PopoverContent as n, PopoverTrigger as r } from "../../../ui/popover.js";
|
|
3
|
+
import { cn as i } from "../../utils/cn.js";
|
|
4
|
+
import { useProactiveOrNull as a } from "../context.js";
|
|
5
|
+
import { SuggestionCard as o } from "./SuggestionCard.js";
|
|
6
|
+
import { useId as s, useState as c } from "react";
|
|
7
|
+
import { Sparkles as l } from "lucide-react";
|
|
8
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
9
|
+
// src/shared/proactive/ui/ProactiveInbox.tsx
|
|
10
|
+
function f({ className: e, onSettled: t, hideHeading: n = !1 }) {
|
|
11
|
+
let r = a(), c = s();
|
|
12
|
+
if (!r || r.status !== "ready") return null;
|
|
13
|
+
let l = r.controls.tr, { suggestions: f, controls: p } = r;
|
|
14
|
+
return /* @__PURE__ */ d("section", {
|
|
15
|
+
"aria-labelledby": n ? void 0 : c,
|
|
16
|
+
"aria-label": n ? l("proactive.inbox.title", "Suggestions") : void 0,
|
|
17
|
+
"data-agent": "deny",
|
|
18
|
+
"data-proactive-ui": "",
|
|
19
|
+
"data-testid": "proactive-inbox",
|
|
20
|
+
className: i("flex flex-col gap-3", e),
|
|
21
|
+
children: [n ? null : /* @__PURE__ */ u("h2", {
|
|
22
|
+
id: c,
|
|
23
|
+
className: "text-sm font-semibold text-text-primary",
|
|
24
|
+
children: l("proactive.inbox.title", "Suggestions")
|
|
25
|
+
}), f.length === 0 ? /* @__PURE__ */ u("p", {
|
|
26
|
+
className: "text-xs text-text-secondary",
|
|
27
|
+
children: l("proactive.inbox.empty", "No suggestions right now. When the assistant finds something worth a look, it shows up here.")
|
|
28
|
+
}) : /* @__PURE__ */ u("ul", {
|
|
29
|
+
className: "flex flex-col gap-2",
|
|
30
|
+
children: f.map((e) => /* @__PURE__ */ u("li", {
|
|
31
|
+
className: "rounded-card border border-border-subtle bg-bg-surface p-3",
|
|
32
|
+
children: /* @__PURE__ */ u(o, {
|
|
33
|
+
suggestion: e,
|
|
34
|
+
controls: p,
|
|
35
|
+
headingLevel: "h3",
|
|
36
|
+
...t ? { onSettled: t } : {}
|
|
37
|
+
})
|
|
38
|
+
}, e.notificationId))
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function p({ className: o, side: s = "bottom", align: p = "end" }) {
|
|
43
|
+
let m = a(), [h, g] = c(!1), _ = e();
|
|
44
|
+
if (!m || m.status !== "ready") return null;
|
|
45
|
+
let v = m.controls.tr, y = m.suggestions.length;
|
|
46
|
+
return /* @__PURE__ */ d(t, {
|
|
47
|
+
open: h,
|
|
48
|
+
onOpenChange: g,
|
|
49
|
+
children: [/* @__PURE__ */ u(r, {
|
|
50
|
+
asChild: !0,
|
|
51
|
+
children: /* @__PURE__ */ d("button", {
|
|
52
|
+
type: "button",
|
|
53
|
+
"aria-label": y === 0 ? v("proactive.inbox.button", "Suggestions") : v("proactive.inbox.buttonWithCount", "Suggestions ({{count}})", { count: y }),
|
|
54
|
+
"data-agent": "deny",
|
|
55
|
+
"data-proactive-ui": "",
|
|
56
|
+
"data-testid": "proactive-inbox-button",
|
|
57
|
+
className: i("relative inline-flex size-9 items-center justify-center rounded-button text-text-secondary outline-none", "hover:bg-action-ghost-bgHover hover:text-text-primary motion-safe:transition-colors", "focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]", o),
|
|
58
|
+
children: [/* @__PURE__ */ u(l, {
|
|
59
|
+
"aria-hidden": "true",
|
|
60
|
+
className: "size-4"
|
|
61
|
+
}), y > 0 ? /* @__PURE__ */ u("span", {
|
|
62
|
+
"aria-hidden": "true",
|
|
63
|
+
className: "absolute -top-0.5 -end-0.5 min-w-4 rounded-full bg-action-primary-bg px-1 text-[10px] font-semibold leading-4 text-action-primary-text",
|
|
64
|
+
children: y > 9 ? "9+" : y
|
|
65
|
+
}) : null]
|
|
66
|
+
})
|
|
67
|
+
}), /* @__PURE__ */ u(n, {
|
|
68
|
+
side: s,
|
|
69
|
+
align: p,
|
|
70
|
+
collisionPadding: 8,
|
|
71
|
+
"data-agent": "deny",
|
|
72
|
+
"data-proactive-ui": "",
|
|
73
|
+
className: i("max-h-[min(32rem,80vh)] w-96 max-w-[calc(100vw-1rem)] overflow-y-auto p-3", _ && "animate-none!"),
|
|
74
|
+
children: /* @__PURE__ */ u(f, { onSettled: y <= 1 ? () => g(!1) : void 0 })
|
|
75
|
+
})]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
export { f as ProactiveInbox, p as ProactiveInboxButton };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface ProactiveSettingsPanelProps {
|
|
2
|
+
/** The product's display name for the consent copy. Default: "this app". */
|
|
3
|
+
productName?: string;
|
|
4
|
+
/** Where the user's notification settings (quiet hours, channels) live. */
|
|
5
|
+
notificationSettingsHref?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function ProactiveSettingsPanel({ productName, notificationSettingsHref, className, }: ProactiveSettingsPanelProps): import('react').JSX.Element | null;
|