@rivium/push-node 0.1.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.
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Segments = void 0;
4
+ class Segments {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Create a new segment.
10
+ */
11
+ async create(options) {
12
+ return this.client.post('/segments', options);
13
+ }
14
+ /**
15
+ * List all segments.
16
+ */
17
+ async list() {
18
+ return this.client.get('/segments');
19
+ }
20
+ /**
21
+ * Get a segment by ID.
22
+ */
23
+ async get(id) {
24
+ return this.client.get(`/segments/${id}`);
25
+ }
26
+ /**
27
+ * Update a segment.
28
+ */
29
+ async update(id, options) {
30
+ return this.client.put(`/segments/${id}`, options);
31
+ }
32
+ /**
33
+ * Delete a segment.
34
+ */
35
+ async delete(id) {
36
+ return this.client.delete(`/segments/${id}`);
37
+ }
38
+ /**
39
+ * Get devices in a segment.
40
+ */
41
+ async getDevices(id) {
42
+ return this.client.get(`/segments/${id}/devices`);
43
+ }
44
+ /**
45
+ * Recalculate segment membership.
46
+ */
47
+ async recalculate(id) {
48
+ return this.client.post(`/segments/${id}/recalculate`);
49
+ }
50
+ /**
51
+ * Recalculate all segments.
52
+ */
53
+ async recalculateAll() {
54
+ return this.client.post('/segments/recalculate-all');
55
+ }
56
+ }
57
+ exports.Segments = Segments;
@@ -0,0 +1,40 @@
1
+ import { HttpClient } from '../client';
2
+ import { Template, CreateTemplateOptions, UpdateTemplateOptions } from '../types';
3
+ export declare class Templates {
4
+ private client;
5
+ constructor(client: HttpClient);
6
+ /**
7
+ * Create a new notification template.
8
+ */
9
+ create(options: CreateTemplateOptions): Promise<Template>;
10
+ /**
11
+ * List all templates.
12
+ */
13
+ list(): Promise<Template[]>;
14
+ /**
15
+ * Get a template by ID.
16
+ */
17
+ get(id: string): Promise<Template>;
18
+ /**
19
+ * Update a template.
20
+ */
21
+ update(id: string, options: UpdateTemplateOptions): Promise<Template>;
22
+ /**
23
+ * Delete a template.
24
+ */
25
+ delete(id: string): Promise<{
26
+ success: boolean;
27
+ }>;
28
+ /**
29
+ * Render a template with variables.
30
+ */
31
+ render(id: string, variables?: Record<string, string>, locale?: string): Promise<{
32
+ title: string;
33
+ body: string;
34
+ data?: Record<string, any>;
35
+ }>;
36
+ /**
37
+ * Duplicate a template.
38
+ */
39
+ duplicate(id: string): Promise<Template>;
40
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Templates = void 0;
4
+ class Templates {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Create a new notification template.
10
+ */
11
+ async create(options) {
12
+ return this.client.post('/templates', options);
13
+ }
14
+ /**
15
+ * List all templates.
16
+ */
17
+ async list() {
18
+ return this.client.get('/templates');
19
+ }
20
+ /**
21
+ * Get a template by ID.
22
+ */
23
+ async get(id) {
24
+ return this.client.get(`/templates/${id}`);
25
+ }
26
+ /**
27
+ * Update a template.
28
+ */
29
+ async update(id, options) {
30
+ return this.client.put(`/templates/${id}`, options);
31
+ }
32
+ /**
33
+ * Delete a template.
34
+ */
35
+ async delete(id) {
36
+ return this.client.delete(`/templates/${id}`);
37
+ }
38
+ /**
39
+ * Render a template with variables.
40
+ */
41
+ async render(id, variables, locale) {
42
+ return this.client.post(`/templates/${id}/render`, { variables, locale });
43
+ }
44
+ /**
45
+ * Duplicate a template.
46
+ */
47
+ async duplicate(id) {
48
+ return this.client.post(`/templates/${id}/duplicate`);
49
+ }
50
+ }
51
+ exports.Templates = Templates;
@@ -0,0 +1,52 @@
1
+ import { HttpClient } from '../client';
2
+ import { Webhook, CreateWebhookOptions, UpdateWebhookOptions, WebhookEvent } from '../types';
3
+ export declare class Webhooks {
4
+ private client;
5
+ constructor(client: HttpClient);
6
+ /**
7
+ * Create a new webhook.
8
+ */
9
+ create(options: CreateWebhookOptions): Promise<Webhook>;
10
+ /**
11
+ * List all webhooks.
12
+ */
13
+ list(): Promise<Webhook[]>;
14
+ /**
15
+ * Get available webhook events.
16
+ */
17
+ getEvents(): Promise<{
18
+ value: WebhookEvent;
19
+ label: string;
20
+ }[]>;
21
+ /**
22
+ * Get a webhook by ID.
23
+ */
24
+ get(id: string): Promise<Webhook>;
25
+ /**
26
+ * Update a webhook.
27
+ */
28
+ update(id: string, options: UpdateWebhookOptions): Promise<Webhook>;
29
+ /**
30
+ * Delete a webhook.
31
+ */
32
+ delete(id: string): Promise<{
33
+ success: boolean;
34
+ }>;
35
+ /**
36
+ * Regenerate webhook secret.
37
+ */
38
+ regenerateSecret(id: string): Promise<{
39
+ secret: string;
40
+ }>;
41
+ /**
42
+ * Get webhook delivery logs.
43
+ */
44
+ getLogs(id: string, limit?: number): Promise<any[]>;
45
+ /**
46
+ * Test a webhook.
47
+ */
48
+ test(id: string, event?: WebhookEvent): Promise<{
49
+ success: boolean;
50
+ response: any;
51
+ }>;
52
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Webhooks = void 0;
4
+ class Webhooks {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Create a new webhook.
10
+ */
11
+ async create(options) {
12
+ return this.client.post('/webhooks', options);
13
+ }
14
+ /**
15
+ * List all webhooks.
16
+ */
17
+ async list() {
18
+ return this.client.get('/webhooks');
19
+ }
20
+ /**
21
+ * Get available webhook events.
22
+ */
23
+ async getEvents() {
24
+ return this.client.get('/webhooks/events');
25
+ }
26
+ /**
27
+ * Get a webhook by ID.
28
+ */
29
+ async get(id) {
30
+ return this.client.get(`/webhooks/${id}`);
31
+ }
32
+ /**
33
+ * Update a webhook.
34
+ */
35
+ async update(id, options) {
36
+ return this.client.put(`/webhooks/${id}`, options);
37
+ }
38
+ /**
39
+ * Delete a webhook.
40
+ */
41
+ async delete(id) {
42
+ return this.client.delete(`/webhooks/${id}`);
43
+ }
44
+ /**
45
+ * Regenerate webhook secret.
46
+ */
47
+ async regenerateSecret(id) {
48
+ return this.client.post(`/webhooks/${id}/regenerate-secret`);
49
+ }
50
+ /**
51
+ * Get webhook delivery logs.
52
+ */
53
+ async getLogs(id, limit) {
54
+ return this.client.get(`/webhooks/${id}/logs`, { limit });
55
+ }
56
+ /**
57
+ * Test a webhook.
58
+ */
59
+ async test(id, event) {
60
+ return this.client.post(`/webhooks/${id}/test`, { event });
61
+ }
62
+ }
63
+ exports.Webhooks = Webhooks;
@@ -0,0 +1,333 @@
1
+ export interface RiviumPushConfig {
2
+ /** Your Rivium API key (rv_live_xxx or rv_test_xxx) */
3
+ apiKey: string;
4
+ /** Server secret for server-side authentication (rv_srv_xxx) - required for all server operations */
5
+ serverSecret: string;
6
+ }
7
+ export interface PaginationParams {
8
+ limit?: number;
9
+ offset?: number;
10
+ }
11
+ export interface BillingInfo {
12
+ messagesCharged: number;
13
+ remaining: number;
14
+ }
15
+ export interface SendResult {
16
+ success: number;
17
+ failed: number;
18
+ billing?: BillingInfo;
19
+ }
20
+ export interface NotificationAction {
21
+ id: string;
22
+ title: string;
23
+ action?: string;
24
+ icon?: string;
25
+ destructive?: boolean;
26
+ authRequired?: boolean;
27
+ }
28
+ export interface Localization {
29
+ locale: string;
30
+ title: string;
31
+ body: string;
32
+ }
33
+ export interface SendPushOptions {
34
+ title?: string;
35
+ body?: string;
36
+ templateId?: string;
37
+ templateVariables?: Record<string, string>;
38
+ locale?: string;
39
+ data?: Record<string, any>;
40
+ silent?: boolean;
41
+ imageUrl?: string;
42
+ iconUrl?: string;
43
+ actions?: NotificationAction[];
44
+ deepLink?: string;
45
+ badge?: number;
46
+ badgeAction?: 'set' | 'increment' | 'decrement' | 'clear';
47
+ sound?: string;
48
+ threadId?: string;
49
+ collapseKey?: string;
50
+ category?: string;
51
+ priority?: 'default' | 'high' | 'low';
52
+ ttl?: number;
53
+ localizations?: Localization[];
54
+ timezone?: string;
55
+ campaignId?: string;
56
+ /** Optional app identifier to scope delivery to a specific app on the same device */
57
+ appIdentifier?: string;
58
+ }
59
+ export interface SendToDeviceOptions extends SendPushOptions {
60
+ deviceId: string;
61
+ }
62
+ export interface SendToUserOptions extends SendPushOptions {
63
+ userId: string;
64
+ }
65
+ export interface SendToDevicesOptions extends SendPushOptions {
66
+ deviceIds: string[];
67
+ }
68
+ export interface SendToTopicOptions extends SendPushOptions {
69
+ topic: string;
70
+ }
71
+ export interface SendToSegmentOptions extends SendPushOptions {
72
+ segmentId: string;
73
+ }
74
+ export type Platform = 'android' | 'ios' | 'web';
75
+ export interface Device {
76
+ id: string;
77
+ deviceId: string;
78
+ platform: Platform;
79
+ appId: string;
80
+ appIdentifier?: string;
81
+ userId?: string;
82
+ metadata?: Record<string, any>;
83
+ createdAt: string;
84
+ }
85
+ export interface CreateTemplateOptions {
86
+ name: string;
87
+ description?: string;
88
+ title: string;
89
+ body: string;
90
+ data?: Record<string, any>;
91
+ variables?: string[];
92
+ localizations?: Record<string, {
93
+ title: string;
94
+ body: string;
95
+ }>;
96
+ }
97
+ export interface UpdateTemplateOptions extends Partial<CreateTemplateOptions> {
98
+ }
99
+ export interface Template {
100
+ id: string;
101
+ name: string;
102
+ description?: string;
103
+ title: string;
104
+ body: string;
105
+ data?: Record<string, any>;
106
+ variables?: string[];
107
+ localizations?: Record<string, {
108
+ title: string;
109
+ body: string;
110
+ }>;
111
+ createdAt: string;
112
+ updatedAt: string;
113
+ }
114
+ export interface SegmentFilter {
115
+ field: string;
116
+ operator: 'equals' | 'contains' | 'starts_with' | 'in' | 'gt' | 'lt' | 'between';
117
+ value: string | number | string[];
118
+ }
119
+ export interface CreateSegmentOptions {
120
+ name: string;
121
+ description?: string;
122
+ color?: string;
123
+ filters?: SegmentFilter[];
124
+ }
125
+ export interface UpdateSegmentOptions extends Partial<CreateSegmentOptions> {
126
+ }
127
+ export interface Segment {
128
+ id: string;
129
+ name: string;
130
+ description?: string;
131
+ color?: string;
132
+ filters?: SegmentFilter[];
133
+ deviceCount?: number;
134
+ createdAt: string;
135
+ updatedAt: string;
136
+ }
137
+ export interface CreateScheduledOptions {
138
+ title: string;
139
+ body: string;
140
+ data?: Record<string, any>;
141
+ targetType: 'all' | 'user' | 'device' | 'topic' | 'segment';
142
+ targetValue?: string;
143
+ scheduledAt: string;
144
+ timezone?: string;
145
+ }
146
+ export interface UpdateScheduledOptions extends Partial<CreateScheduledOptions> {
147
+ }
148
+ export interface ScheduledMessage {
149
+ id: string;
150
+ title: string;
151
+ body: string;
152
+ data?: Record<string, any>;
153
+ targetType: string;
154
+ targetValue?: string;
155
+ scheduledAt: string;
156
+ timezone?: string;
157
+ status: string;
158
+ createdAt: string;
159
+ }
160
+ export interface InboxContent {
161
+ title: string;
162
+ body: string;
163
+ imageUrl?: string;
164
+ iconUrl?: string;
165
+ deepLink?: string;
166
+ data?: Record<string, any>;
167
+ }
168
+ export interface InboxLocalization {
169
+ locale: string;
170
+ content: InboxContent;
171
+ }
172
+ export interface SendInboxOptions {
173
+ content: InboxContent;
174
+ localizations?: InboxLocalization[];
175
+ appIdentifier?: string;
176
+ category?: string;
177
+ expiresAt?: string;
178
+ campaignId?: string;
179
+ }
180
+ export interface SendToUserInboxOptions extends SendInboxOptions {
181
+ userId: string;
182
+ }
183
+ export interface SendToUsersInboxOptions extends SendInboxOptions {
184
+ userIds: string[];
185
+ }
186
+ export interface SendToDeviceInboxOptions extends SendInboxOptions {
187
+ deviceId: string;
188
+ }
189
+ export interface InboxMessage {
190
+ id: string;
191
+ content: InboxContent;
192
+ status: 'unread' | 'read' | 'archived' | 'deleted';
193
+ category?: string;
194
+ createdAt: string;
195
+ }
196
+ export type InboxStatus = 'unread' | 'read' | 'archived' | 'deleted';
197
+ export interface GetInboxOptions extends PaginationParams {
198
+ userId?: string;
199
+ deviceId?: string;
200
+ status?: InboxStatus;
201
+ category?: string;
202
+ locale?: string;
203
+ }
204
+ export interface InAppButton {
205
+ id: string;
206
+ text: string;
207
+ action: 'dismiss' | 'deep_link' | 'url' | 'custom';
208
+ value?: string;
209
+ style?: 'primary' | 'secondary' | 'text' | 'destructive';
210
+ }
211
+ export interface InAppContent {
212
+ title: string;
213
+ body: string;
214
+ imageUrl?: string;
215
+ backgroundColor?: string;
216
+ textColor?: string;
217
+ buttons?: InAppButton[];
218
+ }
219
+ export interface CreateInAppOptions {
220
+ name: string;
221
+ type: 'modal' | 'banner' | 'card' | 'notification';
222
+ content: InAppContent;
223
+ localizations?: {
224
+ locale: string;
225
+ content: InAppContent;
226
+ }[];
227
+ triggerType?: 'on_app_open' | 'on_event' | 'on_screen_view' | 'manual';
228
+ triggerEvent?: string;
229
+ triggerConditions?: Record<string, any>;
230
+ segmentId?: string;
231
+ targetUserIds?: string[];
232
+ startDate?: string;
233
+ endDate?: string;
234
+ maxImpressions?: number;
235
+ minSessionCount?: number;
236
+ delaySeconds?: number;
237
+ priority?: number;
238
+ }
239
+ export interface UpdateInAppOptions extends Partial<CreateInAppOptions> {
240
+ }
241
+ export interface InAppMessage {
242
+ id: string;
243
+ name: string;
244
+ type: string;
245
+ content: InAppContent;
246
+ status: string;
247
+ createdAt: string;
248
+ }
249
+ export interface ABTestVariantDef {
250
+ name: string;
251
+ title: string;
252
+ body: string;
253
+ data?: Record<string, any>;
254
+ imageUrl?: string;
255
+ deepLink?: string;
256
+ actions?: NotificationAction[];
257
+ trafficPercentage: number;
258
+ }
259
+ export interface CreateABTestOptions {
260
+ name: string;
261
+ description?: string;
262
+ targetType?: string;
263
+ segmentId?: string;
264
+ targetPercentage?: number;
265
+ hasControlGroup?: boolean;
266
+ controlGroupPercentage?: number;
267
+ winningMetric?: string;
268
+ testDurationHours?: number;
269
+ autoSelectWinner?: boolean;
270
+ enableEarlyStopping?: boolean;
271
+ significanceThreshold?: number;
272
+ minimumSampleSize?: number;
273
+ variants: ABTestVariantDef[];
274
+ }
275
+ export interface ABTest {
276
+ id: string;
277
+ name: string;
278
+ status: string;
279
+ variants: any[];
280
+ createdAt: string;
281
+ }
282
+ export type WebhookEvent = 'message.sent' | 'message.delivered' | 'message.opened' | 'message.clicked' | 'device.registered' | 'device.unregistered';
283
+ export interface CreateWebhookOptions {
284
+ name: string;
285
+ url: string;
286
+ secret?: string;
287
+ events: WebhookEvent[];
288
+ isActive?: boolean;
289
+ maxRetries?: number;
290
+ timeoutMs?: number;
291
+ }
292
+ export interface UpdateWebhookOptions extends Partial<CreateWebhookOptions> {
293
+ }
294
+ export interface Webhook {
295
+ id: string;
296
+ name: string;
297
+ url: string;
298
+ events: WebhookEvent[];
299
+ isActive: boolean;
300
+ createdAt: string;
301
+ }
302
+ export interface AnalyticsOverview {
303
+ totalDevices: number;
304
+ activeDevices: number;
305
+ totalMessages: number;
306
+ totalDelivered: number;
307
+ totalFailed: number;
308
+ totalPending: number;
309
+ totalNoTargets: number;
310
+ totalAttempts: number;
311
+ deliveryRate: number;
312
+ platformDistribution: {
313
+ android: number;
314
+ ios: number;
315
+ web: number;
316
+ };
317
+ }
318
+ export interface DailyStats {
319
+ date: string;
320
+ sent: number;
321
+ delivered: number;
322
+ opened: number;
323
+ clicked: number;
324
+ }
325
+ export interface AppStats {
326
+ totalDevices: number;
327
+ activeDevices: number;
328
+ androidDevices: number;
329
+ iosDevices: number;
330
+ totalTopics: number;
331
+ topics: string[];
332
+ totalUsers: number;
333
+ }
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // ─── Configuration ───────────────────────────────────────────────
3
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@rivium/push-node",
3
+ "version": "0.1.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/Rivium-co/rivium-push-nodejs-sdk.git"
7
+ },
8
+ "homepage": "https://rivium.co/cloud/rivium-push",
9
+ "bugs": {
10
+ "url": "https://github.com/Rivium-co/rivium-push-nodejs-sdk/issues"
11
+ },
12
+ "description": "RiviumPush Node.js SDK \u2014 server-side push notifications, inbox, in-app messages, and more",
13
+ "main": "dist/index.js",
14
+ "types": "dist/index.d.ts",
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsc",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "keywords": [
23
+ "rivium-push",
24
+ "push-notifications",
25
+ "notifications",
26
+ "inbox",
27
+ "in-app-messages"
28
+ ],
29
+ "author": "Rivium <support@rivium.co>",
30
+ "license": "MIT",
31
+ "engines": {
32
+ "node": ">=16"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^25.2.0",
36
+ "typescript": "^5.9.3"
37
+ }
38
+ }