@novu/js 3.11.0 → 3.11.1

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novu/js",
3
- "version": "3.11.0",
3
+ "version": "3.11.1",
4
4
  "repository": "https://github.com/novuhq/novu",
5
5
  "description": "Novu JavaScript SDK for <Inbox />",
6
6
  "author": "",
@@ -65,6 +65,21 @@
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  },
68
+ "scripts": {
69
+ "clean": "rimraf ./dist",
70
+ "start:server": "http-server ./dist -p 4010",
71
+ "prebuild": "cp ./src/ui/index.css ./src/ui/index.directcss",
72
+ "build": "pnpm run clean && NODE_ENV=production tsup",
73
+ "postbuild": "rm ./src/ui/index.directcss && ./scripts/copy-package-json.sh && node scripts/size-limit.mjs && pnpm run check-exports",
74
+ "build:umd": "webpack --config webpack.config.cjs",
75
+ "build:watch": "concurrently \"pnpm run prebuild\" \"NODE_ENV=development pnpm run tsup:watch\" \"pnpm run start:server\"",
76
+ "tsup:watch": "tsup --watch --onSuccess 'tsup --dts-only'",
77
+ "check-exports": "attw --pack .",
78
+ "check": "biome check .",
79
+ "check:fix": "biome check --write .",
80
+ "test": "jest",
81
+ "publish:rc": "pnpm publish --tag rc"
82
+ },
68
83
  "browserslist": {
69
84
  "production": [
70
85
  ">0.2%",
@@ -128,20 +143,5 @@
128
143
  "tags": [
129
144
  "type:package"
130
145
  ]
131
- },
132
- "scripts": {
133
- "clean": "rimraf ./dist",
134
- "start:server": "http-server ./dist -p 4010",
135
- "prebuild": "cp ./src/ui/index.css ./src/ui/index.directcss",
136
- "build": "pnpm run clean && NODE_ENV=production tsup",
137
- "postbuild": "rm ./src/ui/index.directcss && ./scripts/copy-package-json.sh && node scripts/size-limit.mjs && pnpm run check-exports",
138
- "build:umd": "webpack --config webpack.config.cjs",
139
- "build:watch": "concurrently \"pnpm run prebuild\" \"NODE_ENV=development pnpm run tsup:watch\" \"pnpm run start:server\"",
140
- "tsup:watch": "tsup --watch --onSuccess 'tsup --dts-only'",
141
- "check-exports": "attw --pack .",
142
- "check": "biome check .",
143
- "check:fix": "biome check --write .",
144
- "test": "jest",
145
- "publish:rc": "pnpm publish --tag rc"
146
146
  }
147
- }
147
+ }
@@ -1,66 +0,0 @@
1
- 'use strict';
2
-
3
- // src/ui/internal/buildContextKey.ts
4
- function buildContextKey(context) {
5
- if (!context) {
6
- return "";
7
- }
8
- const keys = [];
9
- for (const [type, value] of Object.entries(context)) {
10
- if (value) {
11
- const id = typeof value === "string" ? value : value.id;
12
- keys.push(`${type}:${id}`);
13
- }
14
- }
15
- return keys.sort().join(",");
16
- }
17
-
18
- // src/ui/internal/buildSubscriber.ts
19
- function buildSubscriber({
20
- subscriberId,
21
- subscriber
22
- }) {
23
- if (subscriber) {
24
- return typeof subscriber === "string" ? { subscriberId: subscriber } : subscriber;
25
- }
26
- if (subscriberId) {
27
- return { subscriberId };
28
- }
29
- return { subscriberId: "" };
30
- }
31
-
32
- // src/ui/internal/parseMarkdown.tsx
33
- var parseMarkdownIntoTokens = (text) => {
34
- const tokens = [];
35
- let buffer = "";
36
- let inBold = false;
37
- for (let i = 0; i < text.length; i += 1) {
38
- if (text[i] === "\\" && text[i + 1] === "*") {
39
- buffer += "*";
40
- i += 1;
41
- } else if (text[i] === "*" && text[i + 1] === "*") {
42
- if (buffer) {
43
- tokens.push({
44
- type: inBold ? "bold" : "text",
45
- content: buffer
46
- });
47
- buffer = "";
48
- }
49
- inBold = !inBold;
50
- i += 1;
51
- } else {
52
- buffer += text[i];
53
- }
54
- }
55
- if (buffer) {
56
- tokens.push({
57
- type: inBold ? "bold" : "text",
58
- content: buffer
59
- });
60
- }
61
- return tokens;
62
- };
63
-
64
- exports.buildContextKey = buildContextKey;
65
- exports.buildSubscriber = buildSubscriber;
66
- exports.parseMarkdownIntoTokens = parseMarkdownIntoTokens;
@@ -1,220 +0,0 @@
1
- declare class NovuError extends Error {
2
- originalError: Error;
3
- constructor(message: string, originalError: unknown);
4
- }
5
-
6
- declare global {
7
- /**
8
- * If you want to provide custom types for the notification.data object,
9
- * simply redeclare this rule in the global namespace.
10
- * Every notification object will use the provided type.
11
- */
12
- interface NotificationData {
13
- [k: string]: unknown;
14
- }
15
- }
16
- declare enum NotificationStatus {
17
- READ = "read",
18
- SEEN = "seen",
19
- SNOOZED = "snoozed",
20
- UNREAD = "unread",
21
- UNSEEN = "unseen",
22
- UNSNOOZED = "unsnoozed"
23
- }
24
- declare enum PreferenceLevel {
25
- GLOBAL = "global",
26
- TEMPLATE = "template"
27
- }
28
- declare enum ChannelType {
29
- IN_APP = "in_app",
30
- EMAIL = "email",
31
- SMS = "sms",
32
- CHAT = "chat",
33
- PUSH = "push"
34
- }
35
- declare enum WebSocketEvent {
36
- RECEIVED = "notification_received",
37
- UNREAD = "unread_count_changed",
38
- UNSEEN = "unseen_count_changed"
39
- }
40
- declare enum SeverityLevelEnum {
41
- HIGH = "high",
42
- MEDIUM = "medium",
43
- LOW = "low",
44
- NONE = "none"
45
- }
46
- declare enum WorkflowCriticalityEnum {
47
- CRITICAL = "critical",
48
- NON_CRITICAL = "nonCritical",
49
- ALL = "all"
50
- }
51
- type UnreadCount = {
52
- total: number;
53
- severity: Record<SeverityLevelEnum, number>;
54
- };
55
- type Session = {
56
- token: string;
57
- /** @deprecated Use unreadCount.total instead */
58
- totalUnreadCount: number;
59
- unreadCount: UnreadCount;
60
- removeNovuBranding: boolean;
61
- isDevelopmentMode: boolean;
62
- maxSnoozeDurationHours: number;
63
- applicationIdentifier?: string;
64
- contextKeys?: string[];
65
- };
66
- type Subscriber = {
67
- id?: string;
68
- subscriberId: string;
69
- firstName?: string;
70
- lastName?: string;
71
- email?: string;
72
- phone?: string;
73
- avatar?: string;
74
- locale?: string;
75
- data?: Record<string, unknown>;
76
- timezone?: string;
77
- };
78
- type Redirect = {
79
- url: string;
80
- target?: '_self' | '_blank' | '_parent' | '_top' | '_unfencedTop';
81
- };
82
- declare enum ActionTypeEnum {
83
- PRIMARY = "primary",
84
- SECONDARY = "secondary"
85
- }
86
- type Action = {
87
- label: string;
88
- isCompleted: boolean;
89
- redirect?: Redirect;
90
- };
91
- type Workflow = {
92
- id: string;
93
- identifier: string;
94
- name: string;
95
- critical: boolean;
96
- tags?: string[];
97
- severity: SeverityLevelEnum;
98
- };
99
- type InboxNotification = {
100
- id: string;
101
- transactionId: string;
102
- subject?: string;
103
- body: string;
104
- to: Subscriber;
105
- isRead: boolean;
106
- isSeen: boolean;
107
- isArchived: boolean;
108
- isSnoozed: boolean;
109
- snoozedUntil?: string | null;
110
- deliveredAt?: string[];
111
- createdAt: string;
112
- readAt?: string | null;
113
- firstSeenAt?: string | null;
114
- archivedAt?: string | null;
115
- avatar?: string;
116
- primaryAction?: Action;
117
- secondaryAction?: Action;
118
- channelType: ChannelType;
119
- tags?: string[];
120
- data?: NotificationData;
121
- redirect?: Redirect;
122
- workflow?: Workflow;
123
- severity: SeverityLevelEnum;
124
- };
125
- type NotificationFilter = {
126
- tags?: string[];
127
- read?: boolean;
128
- archived?: boolean;
129
- snoozed?: boolean;
130
- seen?: boolean;
131
- data?: Record<string, unknown>;
132
- severity?: SeverityLevelEnum | SeverityLevelEnum[];
133
- };
134
- type ChannelPreference = {
135
- email?: boolean;
136
- sms?: boolean;
137
- in_app?: boolean;
138
- chat?: boolean;
139
- push?: boolean;
140
- };
141
- type TimeRange = {
142
- start: string;
143
- end: string;
144
- };
145
- type DaySchedule = {
146
- isEnabled: boolean;
147
- hours?: Array<TimeRange>;
148
- };
149
- type WeeklySchedule = {
150
- monday?: DaySchedule;
151
- tuesday?: DaySchedule;
152
- wednesday?: DaySchedule;
153
- thursday?: DaySchedule;
154
- friday?: DaySchedule;
155
- saturday?: DaySchedule;
156
- sunday?: DaySchedule;
157
- };
158
- type DefaultSchedule = {
159
- isEnabled?: boolean;
160
- weeklySchedule?: WeeklySchedule;
161
- };
162
- type ContextValue = string | {
163
- id: string;
164
- data?: Record<string, unknown>;
165
- };
166
- type Context = Partial<Record<string, ContextValue>>;
167
- type PreferencesResponse = {
168
- level: PreferenceLevel;
169
- enabled: boolean;
170
- channels: ChannelPreference;
171
- overrides?: IPreferenceOverride[];
172
- workflow?: Workflow;
173
- schedule?: {
174
- isEnabled: boolean;
175
- weeklySchedule?: WeeklySchedule;
176
- };
177
- };
178
- declare enum PreferenceOverrideSourceEnum {
179
- SUBSCRIBER = "subscriber",
180
- TEMPLATE = "template",
181
- WORKFLOW_OVERRIDE = "workflowOverride"
182
- }
183
- type IPreferenceOverride = {
184
- channel: ChannelType;
185
- source: PreferenceOverrideSourceEnum;
186
- };
187
- type Result<D = undefined, E = NovuError> = Promise<{
188
- data?: D;
189
- error?: E;
190
- }>;
191
- type KeylessNovuOptions = {} & {
192
- [K in string]?: never;
193
- };
194
- type StandardNovuOptions = {
195
- /** @deprecated Use apiUrl instead */
196
- backendUrl?: string;
197
- /** @internal Should be used internally for testing purposes */
198
- __userAgent?: string;
199
- applicationIdentifier: string;
200
- subscriberHash?: string;
201
- contextHash?: string;
202
- apiUrl?: string;
203
- socketUrl?: string;
204
- useCache?: boolean;
205
- defaultSchedule?: DefaultSchedule;
206
- context?: Context;
207
- } & ({
208
- /** @deprecated Use subscriber prop instead */
209
- subscriberId: string;
210
- subscriber?: never;
211
- } | {
212
- subscriber: Subscriber | string;
213
- subscriberId?: never;
214
- });
215
- type NovuOptions = KeylessNovuOptions | StandardNovuOptions;
216
- type Prettify<T> = {
217
- [K in keyof T]: T[K];
218
- } & {};
219
-
220
- export { ActionTypeEnum as A, type ChannelPreference as C, type DaySchedule as D, type InboxNotification as I, type NotificationFilter as N, PreferenceLevel as P, type Result as R, SeverityLevelEnum as S, type TimeRange as T, type UnreadCount as U, WebSocketEvent as W, ChannelType as a, type Context as b, type DefaultSchedule as c, NotificationStatus as d, NovuError as e, type NovuOptions as f, type PreferencesResponse as g, type StandardNovuOptions as h, type Subscriber as i, type WeeklySchedule as j, WorkflowCriticalityEnum as k, type Session as l, type Workflow as m, type Prettify as n, type ContextValue as o };
@@ -1,62 +0,0 @@
1
- // src/ui/internal/buildContextKey.ts
2
- function buildContextKey(context) {
3
- if (!context) {
4
- return "";
5
- }
6
- const keys = [];
7
- for (const [type, value] of Object.entries(context)) {
8
- if (value) {
9
- const id = typeof value === "string" ? value : value.id;
10
- keys.push(`${type}:${id}`);
11
- }
12
- }
13
- return keys.sort().join(",");
14
- }
15
-
16
- // src/ui/internal/buildSubscriber.ts
17
- function buildSubscriber({
18
- subscriberId,
19
- subscriber
20
- }) {
21
- if (subscriber) {
22
- return typeof subscriber === "string" ? { subscriberId: subscriber } : subscriber;
23
- }
24
- if (subscriberId) {
25
- return { subscriberId };
26
- }
27
- return { subscriberId: "" };
28
- }
29
-
30
- // src/ui/internal/parseMarkdown.tsx
31
- var parseMarkdownIntoTokens = (text) => {
32
- const tokens = [];
33
- let buffer = "";
34
- let inBold = false;
35
- for (let i = 0; i < text.length; i += 1) {
36
- if (text[i] === "\\" && text[i + 1] === "*") {
37
- buffer += "*";
38
- i += 1;
39
- } else if (text[i] === "*" && text[i + 1] === "*") {
40
- if (buffer) {
41
- tokens.push({
42
- type: inBold ? "bold" : "text",
43
- content: buffer
44
- });
45
- buffer = "";
46
- }
47
- inBold = !inBold;
48
- i += 1;
49
- } else {
50
- buffer += text[i];
51
- }
52
- }
53
- if (buffer) {
54
- tokens.push({
55
- type: inBold ? "bold" : "text",
56
- content: buffer
57
- });
58
- }
59
- return tokens;
60
- };
61
-
62
- export { buildContextKey, buildSubscriber, parseMarkdownIntoTokens };
@@ -1,220 +0,0 @@
1
- declare class NovuError extends Error {
2
- originalError: Error;
3
- constructor(message: string, originalError: unknown);
4
- }
5
-
6
- declare global {
7
- /**
8
- * If you want to provide custom types for the notification.data object,
9
- * simply redeclare this rule in the global namespace.
10
- * Every notification object will use the provided type.
11
- */
12
- interface NotificationData {
13
- [k: string]: unknown;
14
- }
15
- }
16
- declare enum NotificationStatus {
17
- READ = "read",
18
- SEEN = "seen",
19
- SNOOZED = "snoozed",
20
- UNREAD = "unread",
21
- UNSEEN = "unseen",
22
- UNSNOOZED = "unsnoozed"
23
- }
24
- declare enum PreferenceLevel {
25
- GLOBAL = "global",
26
- TEMPLATE = "template"
27
- }
28
- declare enum ChannelType {
29
- IN_APP = "in_app",
30
- EMAIL = "email",
31
- SMS = "sms",
32
- CHAT = "chat",
33
- PUSH = "push"
34
- }
35
- declare enum WebSocketEvent {
36
- RECEIVED = "notification_received",
37
- UNREAD = "unread_count_changed",
38
- UNSEEN = "unseen_count_changed"
39
- }
40
- declare enum SeverityLevelEnum {
41
- HIGH = "high",
42
- MEDIUM = "medium",
43
- LOW = "low",
44
- NONE = "none"
45
- }
46
- declare enum WorkflowCriticalityEnum {
47
- CRITICAL = "critical",
48
- NON_CRITICAL = "nonCritical",
49
- ALL = "all"
50
- }
51
- type UnreadCount = {
52
- total: number;
53
- severity: Record<SeverityLevelEnum, number>;
54
- };
55
- type Session = {
56
- token: string;
57
- /** @deprecated Use unreadCount.total instead */
58
- totalUnreadCount: number;
59
- unreadCount: UnreadCount;
60
- removeNovuBranding: boolean;
61
- isDevelopmentMode: boolean;
62
- maxSnoozeDurationHours: number;
63
- applicationIdentifier?: string;
64
- contextKeys?: string[];
65
- };
66
- type Subscriber = {
67
- id?: string;
68
- subscriberId: string;
69
- firstName?: string;
70
- lastName?: string;
71
- email?: string;
72
- phone?: string;
73
- avatar?: string;
74
- locale?: string;
75
- data?: Record<string, unknown>;
76
- timezone?: string;
77
- };
78
- type Redirect = {
79
- url: string;
80
- target?: '_self' | '_blank' | '_parent' | '_top' | '_unfencedTop';
81
- };
82
- declare enum ActionTypeEnum {
83
- PRIMARY = "primary",
84
- SECONDARY = "secondary"
85
- }
86
- type Action = {
87
- label: string;
88
- isCompleted: boolean;
89
- redirect?: Redirect;
90
- };
91
- type Workflow = {
92
- id: string;
93
- identifier: string;
94
- name: string;
95
- critical: boolean;
96
- tags?: string[];
97
- severity: SeverityLevelEnum;
98
- };
99
- type InboxNotification = {
100
- id: string;
101
- transactionId: string;
102
- subject?: string;
103
- body: string;
104
- to: Subscriber;
105
- isRead: boolean;
106
- isSeen: boolean;
107
- isArchived: boolean;
108
- isSnoozed: boolean;
109
- snoozedUntil?: string | null;
110
- deliveredAt?: string[];
111
- createdAt: string;
112
- readAt?: string | null;
113
- firstSeenAt?: string | null;
114
- archivedAt?: string | null;
115
- avatar?: string;
116
- primaryAction?: Action;
117
- secondaryAction?: Action;
118
- channelType: ChannelType;
119
- tags?: string[];
120
- data?: NotificationData;
121
- redirect?: Redirect;
122
- workflow?: Workflow;
123
- severity: SeverityLevelEnum;
124
- };
125
- type NotificationFilter = {
126
- tags?: string[];
127
- read?: boolean;
128
- archived?: boolean;
129
- snoozed?: boolean;
130
- seen?: boolean;
131
- data?: Record<string, unknown>;
132
- severity?: SeverityLevelEnum | SeverityLevelEnum[];
133
- };
134
- type ChannelPreference = {
135
- email?: boolean;
136
- sms?: boolean;
137
- in_app?: boolean;
138
- chat?: boolean;
139
- push?: boolean;
140
- };
141
- type TimeRange = {
142
- start: string;
143
- end: string;
144
- };
145
- type DaySchedule = {
146
- isEnabled: boolean;
147
- hours?: Array<TimeRange>;
148
- };
149
- type WeeklySchedule = {
150
- monday?: DaySchedule;
151
- tuesday?: DaySchedule;
152
- wednesday?: DaySchedule;
153
- thursday?: DaySchedule;
154
- friday?: DaySchedule;
155
- saturday?: DaySchedule;
156
- sunday?: DaySchedule;
157
- };
158
- type DefaultSchedule = {
159
- isEnabled?: boolean;
160
- weeklySchedule?: WeeklySchedule;
161
- };
162
- type ContextValue = string | {
163
- id: string;
164
- data?: Record<string, unknown>;
165
- };
166
- type Context = Partial<Record<string, ContextValue>>;
167
- type PreferencesResponse = {
168
- level: PreferenceLevel;
169
- enabled: boolean;
170
- channels: ChannelPreference;
171
- overrides?: IPreferenceOverride[];
172
- workflow?: Workflow;
173
- schedule?: {
174
- isEnabled: boolean;
175
- weeklySchedule?: WeeklySchedule;
176
- };
177
- };
178
- declare enum PreferenceOverrideSourceEnum {
179
- SUBSCRIBER = "subscriber",
180
- TEMPLATE = "template",
181
- WORKFLOW_OVERRIDE = "workflowOverride"
182
- }
183
- type IPreferenceOverride = {
184
- channel: ChannelType;
185
- source: PreferenceOverrideSourceEnum;
186
- };
187
- type Result<D = undefined, E = NovuError> = Promise<{
188
- data?: D;
189
- error?: E;
190
- }>;
191
- type KeylessNovuOptions = {} & {
192
- [K in string]?: never;
193
- };
194
- type StandardNovuOptions = {
195
- /** @deprecated Use apiUrl instead */
196
- backendUrl?: string;
197
- /** @internal Should be used internally for testing purposes */
198
- __userAgent?: string;
199
- applicationIdentifier: string;
200
- subscriberHash?: string;
201
- contextHash?: string;
202
- apiUrl?: string;
203
- socketUrl?: string;
204
- useCache?: boolean;
205
- defaultSchedule?: DefaultSchedule;
206
- context?: Context;
207
- } & ({
208
- /** @deprecated Use subscriber prop instead */
209
- subscriberId: string;
210
- subscriber?: never;
211
- } | {
212
- subscriber: Subscriber | string;
213
- subscriberId?: never;
214
- });
215
- type NovuOptions = KeylessNovuOptions | StandardNovuOptions;
216
- type Prettify<T> = {
217
- [K in keyof T]: T[K];
218
- } & {};
219
-
220
- export { ActionTypeEnum as A, type ChannelPreference as C, type DaySchedule as D, type InboxNotification as I, type NotificationFilter as N, PreferenceLevel as P, type Result as R, SeverityLevelEnum as S, type TimeRange as T, type UnreadCount as U, WebSocketEvent as W, ChannelType as a, type Context as b, type DefaultSchedule as c, NotificationStatus as d, NovuError as e, type NovuOptions as f, type PreferencesResponse as g, type StandardNovuOptions as h, type Subscriber as i, type WeeklySchedule as j, WorkflowCriticalityEnum as k, type Session as l, type Workflow as m, type Prettify as n, type ContextValue as o };