@tolinax/ayoune-interfaces 2026.46.0 → 2026.47.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.
@@ -1,4 +1,6 @@
1
1
  import { IDefaultFields } from "./IDefaultFields";
2
+ import { INotificationAction } from "./INotificationAction";
3
+ import { INotificationAttachment, INotificationSender } from "./INotificationAttachment";
2
4
  export interface INotification extends IDefaultFields {
3
5
  _customerID: ObjectId;
4
6
  _clientID?: ObjectId[];
@@ -14,4 +16,22 @@ export interface INotification extends IDefaultFields {
14
16
  obj?: string;
15
17
  view?: string;
16
18
  params?: object;
19
+ /**
20
+ * Who triggered the notification. Optional — system events pass `null`
21
+ * and the consumer falls back to a generic `aYOUne` header.
22
+ */
23
+ sender?: INotificationSender;
24
+ /**
25
+ * Typed rich-content attachments — calendar entries, tasks, invoices,
26
+ * orders, etc. — rendered as inline preview cards in the notifications
27
+ * panel. See `INotificationAttachment` for the supported types and
28
+ * the enrichment contract (producer may provide `{ type, _id }` and the
29
+ * orchestrator fills `preview` via model lookup).
30
+ */
31
+ attachments?: INotificationAttachment[];
32
+ /**
33
+ * Action buttons rendered under the notification (1-3 typical), and —
34
+ * where the OS supports it — as native Web-Push action buttons (first two).
35
+ */
36
+ actions?: INotificationAction[];
17
37
  }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Action buttons attached to a notification. Rendered both as inline buttons
3
+ * in the in-app notifications panel and (up to two primary actions) as native
4
+ * Web-Push action buttons on supporting platforms.
5
+ *
6
+ * Four dispatch modes:
7
+ * - `link` — internal router navigation (`href` relative to the app)
8
+ * - `api` — `fetch()` call to an absolute endpoint, optionally with
9
+ * a confirm prompt; the service-worker can execute this
10
+ * without the PWA being open (Bearer-token attached).
11
+ * - `reply` — native browser reply text field (if supported) OR a
12
+ * dialog in the PWA; the text is POSTed to `endpoint`.
13
+ * - `ai-copilot` — opens the Comm-Sidebar Copilot panel with
14
+ * `copilotContext` pre-populated as the first user message.
15
+ */
16
+ export type NotificationActionType = "link" | "api" | "reply" | "ai-copilot";
17
+ /** Visual weight of the action button. */
18
+ export type NotificationActionStyle = "primary" | "secondary" | "danger";
19
+ export interface INotificationAction {
20
+ /** Stable identifier per notification — used as the Web-Push `action` id. */
21
+ id: string;
22
+ /** Button label. May be a literal or an i18n key. */
23
+ label: string;
24
+ type: NotificationActionType;
25
+ style?: NotificationActionStyle;
26
+ /** Material icon name rendered before the label. */
27
+ icon?: string;
28
+ /** For `type: "link"` — absolute or app-relative route. */
29
+ href?: string;
30
+ /** For `type: "api"` or `type: "reply"` — absolute endpoint (service-worker
31
+ * executable). POST is the default for mutation-ish actions. */
32
+ endpoint?: string;
33
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
34
+ /** Static payload merged with dynamic input (reply text, notification id). */
35
+ body?: Record<string, unknown>;
36
+ /** Confirmation prompt before firing (useful for destructive actions). */
37
+ confirmLabel?: string;
38
+ /** For `type: "ai-copilot"` — the prompt pre-populated into the Copilot
39
+ * panel when the user taps this action. Supports `{{variable}}` tokens
40
+ * that are rendered against the notification's `data` context before
41
+ * being inserted into the input. */
42
+ copilotContext?: string;
43
+ /** Should this action close/dismiss the notification after firing? */
44
+ dismissOnComplete?: boolean;
45
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Structured rich-content attachments for notifications (and — in phase 4 —
3
+ * chat messages). Mirrors the legacy AngularJS attachment system documented
4
+ * in `archive/legacy-angular1/pug/chatsidebar.pug:248-334`, where chat
5
+ * messages carried typed entity references (`type` + `content` + `preview`)
6
+ * that the renderer switched over to display inline entity cards.
7
+ *
8
+ * Producer contract:
9
+ * 1. The caller of `POST /notifications/send` may provide either:
10
+ * - a bare reference: `{ type, _id }` — the orchestrator enriches it by
11
+ * looking up the entity and projecting the relevant fields into
12
+ * `preview`, OR
13
+ * - a fully-formed attachment with `preview` already populated — skips
14
+ * the lookup (use when the caller already has the data loaded).
15
+ * 2. Consumers (comm-sidebar notifications-panel, mobile-app PWA) dispatch
16
+ * on `type` and render a type-specific preview component, falling back
17
+ * to a generic card for unknown types.
18
+ *
19
+ * Phase 1 ships 5 core types. Subsequent phases add the remaining 12+
20
+ * types from the legacy chat system (document, consumer, contract,
21
+ * shipping, productionorder, creditnote, internalorder, offer, assignment,
22
+ * question, snippet, media).
23
+ */
24
+ export type NotificationAttachmentType = "calendarentry" | "task" | "invoice" | "permissionrequest" | "supplierorder";
25
+ /** Shared shape — all previews carry an optional deep-link override. */
26
+ interface INotificationAttachmentBase {
27
+ /** Reference to the source entity (the document `_id`). Required for
28
+ * enrichment and deep-linking. */
29
+ _id: ObjectId;
30
+ /** Optional router path used when the user taps the preview card.
31
+ * When absent, the consumer falls back to `/{type}/{_id}`. */
32
+ href?: string;
33
+ }
34
+ export interface ICalendarEntryPreview extends INotificationAttachmentBase {
35
+ summary?: string;
36
+ description?: string;
37
+ start?: Date | string;
38
+ end?: Date | string;
39
+ typ?: string;
40
+ status?: string;
41
+ location?: string;
42
+ allDay?: boolean;
43
+ organizer?: {
44
+ _id?: ObjectId;
45
+ name?: string;
46
+ email?: string;
47
+ };
48
+ attendees?: Array<{
49
+ _id?: ObjectId;
50
+ name?: string;
51
+ email?: string;
52
+ rsvp?: "accepted" | "declined" | "tentative" | "pending";
53
+ }>;
54
+ }
55
+ export interface ITaskPreview extends INotificationAttachmentBase {
56
+ title?: string;
57
+ ticketIdentifier?: string;
58
+ status?: string;
59
+ priority?: string;
60
+ type?: string;
61
+ due?: Date | string;
62
+ assignee?: {
63
+ _id?: ObjectId;
64
+ name?: string;
65
+ avatar?: string;
66
+ };
67
+ project?: {
68
+ _id?: ObjectId;
69
+ name?: string;
70
+ };
71
+ points?: number;
72
+ }
73
+ export interface IInvoicePreview extends INotificationAttachmentBase {
74
+ nbr?: number;
75
+ referenceNumber?: string;
76
+ title?: string;
77
+ total?: number;
78
+ currency?: string;
79
+ dueDate?: Date | string;
80
+ paid?: boolean;
81
+ status?: string;
82
+ receiver?: {
83
+ _id?: ObjectId;
84
+ name?: string;
85
+ };
86
+ }
87
+ export interface IPermissionRequestPreview extends INotificationAttachmentBase {
88
+ reason?: string;
89
+ permissionName?: string;
90
+ askedOn?: Date | string;
91
+ fromUser?: {
92
+ _id?: ObjectId;
93
+ name?: string;
94
+ avatar?: string;
95
+ };
96
+ valid_from?: Date | string;
97
+ valid_till?: Date | string;
98
+ approved?: boolean;
99
+ declined?: boolean;
100
+ temporary?: boolean;
101
+ }
102
+ export interface ISupplierOrderPreview extends INotificationAttachmentBase {
103
+ nbr?: string | number;
104
+ shopOrderNbr?: string;
105
+ title?: string;
106
+ total?: number;
107
+ currency?: string;
108
+ confirmed?: boolean;
109
+ needsInternalApproval?: string;
110
+ internalApproved?: boolean;
111
+ internalDeclined?: boolean;
112
+ supplier?: {
113
+ _id?: ObjectId;
114
+ name?: string;
115
+ };
116
+ expectedDelivery?: Date | string;
117
+ }
118
+ export type INotificationAttachment = {
119
+ type: "calendarentry";
120
+ preview: ICalendarEntryPreview;
121
+ } | {
122
+ type: "task";
123
+ preview: ITaskPreview;
124
+ } | {
125
+ type: "invoice";
126
+ preview: IInvoicePreview;
127
+ } | {
128
+ type: "permissionrequest";
129
+ preview: IPermissionRequestPreview;
130
+ } | {
131
+ type: "supplierorder";
132
+ preview: ISupplierOrderPreview;
133
+ };
134
+ /** Producer-side shape — accepts either a bare reference (orchestrator will
135
+ * enrich) or a fully-populated attachment. */
136
+ export type INotificationAttachmentInput = {
137
+ type: NotificationAttachmentType;
138
+ _id: ObjectId;
139
+ } | INotificationAttachment;
140
+ /** Sender metadata carried on the notification document so the in-app panel
141
+ * can show "Alice assigned you a task" with the avatar of the triggering
142
+ * actor rather than a faceless system row. */
143
+ export interface INotificationSender {
144
+ _userId?: ObjectId;
145
+ name?: string;
146
+ avatar?: string;
147
+ email?: string;
148
+ }
149
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /**
3
+ * Structured rich-content attachments for notifications (and — in phase 4 —
4
+ * chat messages). Mirrors the legacy AngularJS attachment system documented
5
+ * in `archive/legacy-angular1/pug/chatsidebar.pug:248-334`, where chat
6
+ * messages carried typed entity references (`type` + `content` + `preview`)
7
+ * that the renderer switched over to display inline entity cards.
8
+ *
9
+ * Producer contract:
10
+ * 1. The caller of `POST /notifications/send` may provide either:
11
+ * - a bare reference: `{ type, _id }` — the orchestrator enriches it by
12
+ * looking up the entity and projecting the relevant fields into
13
+ * `preview`, OR
14
+ * - a fully-formed attachment with `preview` already populated — skips
15
+ * the lookup (use when the caller already has the data loaded).
16
+ * 2. Consumers (comm-sidebar notifications-panel, mobile-app PWA) dispatch
17
+ * on `type` and render a type-specific preview component, falling back
18
+ * to a generic card for unknown types.
19
+ *
20
+ * Phase 1 ships 5 core types. Subsequent phases add the remaining 12+
21
+ * types from the legacy chat system (document, consumer, contract,
22
+ * shipping, productionorder, creditnote, internalorder, offer, assignment,
23
+ * question, snippet, media).
24
+ */
25
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -462,6 +462,8 @@ export * from "./INewsletterType";
462
462
  export * from "./INewsSource";
463
463
  export * from "./INormalizedSerp";
464
464
  export * from "./INotification";
465
+ export * from "./INotificationAction";
466
+ export * from "./INotificationAttachment";
465
467
  export * from "./INotificationPolicy";
466
468
  export * from "./INotificationPreference";
467
469
  export * from "./IOffer";
@@ -478,6 +478,8 @@ __exportStar(require("./INewsletterType"), exports);
478
478
  __exportStar(require("./INewsSource"), exports);
479
479
  __exportStar(require("./INormalizedSerp"), exports);
480
480
  __exportStar(require("./INotification"), exports);
481
+ __exportStar(require("./INotificationAction"), exports);
482
+ __exportStar(require("./INotificationAttachment"), exports);
481
483
  __exportStar(require("./INotificationPolicy"), exports);
482
484
  __exportStar(require("./INotificationPreference"), exports);
483
485
  __exportStar(require("./IOffer"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tolinax/ayoune-interfaces",
3
- "version": "2026.46.0",
3
+ "version": "2026.47.0",
4
4
  "description": "Houses TypeScript interfaces for aYOUne",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",