@marinade.finance/notifications-ts-subscription-client 1.0.2-beta.2 → 1.0.2-beta.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.
- package/client.ts +29 -0
- package/dist/client.d.ts +2 -1
- package/dist/client.js +24 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/types.d.ts +10 -0
- package/index.ts +3 -0
- package/package.json +1 -1
- package/types.ts +13 -0
package/client.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
type ListSubscriptionsAuth,
|
|
10
10
|
type Subscription,
|
|
11
11
|
type ListNotificationsQuery,
|
|
12
|
+
type ListBroadcastNotificationsQuery,
|
|
12
13
|
type Notification,
|
|
13
14
|
NetworkError,
|
|
14
15
|
} from './types'
|
|
@@ -110,6 +111,34 @@ export class SubscriptionClient {
|
|
|
110
111
|
})
|
|
111
112
|
}
|
|
112
113
|
|
|
114
|
+
async listBroadcastNotifications(
|
|
115
|
+
query: ListBroadcastNotificationsQuery,
|
|
116
|
+
): Promise<Notification[]> {
|
|
117
|
+
const params = new URLSearchParams()
|
|
118
|
+
if (query.notification_type) {
|
|
119
|
+
params.set('notification_type', query.notification_type)
|
|
120
|
+
}
|
|
121
|
+
if (query.priority) {
|
|
122
|
+
params.set('priority', query.priority)
|
|
123
|
+
}
|
|
124
|
+
if (query.inner_type) {
|
|
125
|
+
params.set('inner_type', query.inner_type)
|
|
126
|
+
}
|
|
127
|
+
if (query.limit !== undefined) {
|
|
128
|
+
params.set('limit', query.limit.toString())
|
|
129
|
+
}
|
|
130
|
+
if (query.offset !== undefined) {
|
|
131
|
+
params.set('offset', query.offset.toString())
|
|
132
|
+
}
|
|
133
|
+
const paramsStr = params.toString()
|
|
134
|
+
const path = `${PATH_NOTIFICATIONS}/broadcast${paramsStr ? '?' + paramsStr : ''}`
|
|
135
|
+
|
|
136
|
+
this.logger?.debug(`GET ${path}`)
|
|
137
|
+
return this.fetch<Notification[]>(path, {
|
|
138
|
+
method: 'GET',
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
|
|
113
142
|
private async fetch<T>(path: string, init: RequestInit): Promise<T> {
|
|
114
143
|
const url = `${this.base_url}${path}`
|
|
115
144
|
const method = init.method ?? 'GET'
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type SubscriptionClientConfig, type SubscribeRequest, type SubscribeResponse, type UnsubscribeRequest, type UnsubscribeResponse, type ListSubscriptionsQuery, type ListSubscriptionsAuth, type Subscription, type ListNotificationsQuery, type Notification } from './types';
|
|
1
|
+
import { type SubscriptionClientConfig, type SubscribeRequest, type SubscribeResponse, type UnsubscribeRequest, type UnsubscribeResponse, type ListSubscriptionsQuery, type ListSubscriptionsAuth, type Subscription, type ListNotificationsQuery, type ListBroadcastNotificationsQuery, type Notification } from './types';
|
|
2
2
|
export declare class SubscriptionClient {
|
|
3
3
|
private readonly base_url;
|
|
4
4
|
private readonly timeout_ms;
|
|
@@ -8,5 +8,6 @@ export declare class SubscriptionClient {
|
|
|
8
8
|
unsubscribe(request: UnsubscribeRequest): Promise<UnsubscribeResponse>;
|
|
9
9
|
listSubscriptions(query: ListSubscriptionsQuery, auth: ListSubscriptionsAuth): Promise<Subscription[]>;
|
|
10
10
|
listNotifications(query: ListNotificationsQuery): Promise<Notification[]>;
|
|
11
|
+
listBroadcastNotifications(query: ListBroadcastNotificationsQuery): Promise<Notification[]>;
|
|
11
12
|
private fetch;
|
|
12
13
|
}
|
package/dist/client.js
CHANGED
|
@@ -76,6 +76,30 @@ class SubscriptionClient {
|
|
|
76
76
|
method: 'GET',
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
|
+
async listBroadcastNotifications(query) {
|
|
80
|
+
const params = new URLSearchParams();
|
|
81
|
+
if (query.notification_type) {
|
|
82
|
+
params.set('notification_type', query.notification_type);
|
|
83
|
+
}
|
|
84
|
+
if (query.priority) {
|
|
85
|
+
params.set('priority', query.priority);
|
|
86
|
+
}
|
|
87
|
+
if (query.inner_type) {
|
|
88
|
+
params.set('inner_type', query.inner_type);
|
|
89
|
+
}
|
|
90
|
+
if (query.limit !== undefined) {
|
|
91
|
+
params.set('limit', query.limit.toString());
|
|
92
|
+
}
|
|
93
|
+
if (query.offset !== undefined) {
|
|
94
|
+
params.set('offset', query.offset.toString());
|
|
95
|
+
}
|
|
96
|
+
const paramsStr = params.toString();
|
|
97
|
+
const path = `${PATH_NOTIFICATIONS}/broadcast${paramsStr ? '?' + paramsStr : ''}`;
|
|
98
|
+
this.logger?.debug(`GET ${path}`);
|
|
99
|
+
return this.fetch(path, {
|
|
100
|
+
method: 'GET',
|
|
101
|
+
});
|
|
102
|
+
}
|
|
79
103
|
async fetch(path, init) {
|
|
80
104
|
const url = `${this.base_url}${path}`;
|
|
81
105
|
const method = init.method ?? 'GET';
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { SubscriptionClientConfig } from './types';
|
|
|
3
3
|
export { SubscriptionClient };
|
|
4
4
|
export { subscribeMessage, unsubscribeMessage, listSubscriptionsMessage, } from './message';
|
|
5
5
|
export { NetworkError } from './types';
|
|
6
|
-
export type { Logger, SubscriptionClientConfig, SubscribeRequest, SubscribeResponse, UnsubscribeRequest, UnsubscribeResponse, ListSubscriptionsQuery, ListSubscriptionsAuth, Subscription, ListNotificationsQuery, Notification, } from './types';
|
|
6
|
+
export type { Logger, SubscriptionClientConfig, SubscribeRequest, SubscribeResponse, UnsubscribeRequest, UnsubscribeResponse, ListSubscriptionsQuery, ListSubscriptionsAuth, Subscription, ListNotificationsQuery, ListBroadcastNotificationsQuery, Notification, NotificationScope, } from './types';
|
|
7
7
|
export declare const NOTIFICATION_TYPE_SAM_AUCTION = "sam_auction";
|
|
8
|
+
export declare const NOTIFICATION_TYPE_INSTITUTIONAL_SELECT = "institutional_select";
|
|
8
9
|
export declare function createSubscriptionClient(config: SubscriptionClientConfig): SubscriptionClient;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NOTIFICATION_TYPE_SAM_AUCTION = exports.NetworkError = exports.listSubscriptionsMessage = exports.unsubscribeMessage = exports.subscribeMessage = exports.SubscriptionClient = void 0;
|
|
3
|
+
exports.NOTIFICATION_TYPE_INSTITUTIONAL_SELECT = exports.NOTIFICATION_TYPE_SAM_AUCTION = exports.NetworkError = exports.listSubscriptionsMessage = exports.unsubscribeMessage = exports.subscribeMessage = exports.SubscriptionClient = void 0;
|
|
4
4
|
exports.createSubscriptionClient = createSubscriptionClient;
|
|
5
5
|
const client_1 = require("./client");
|
|
6
6
|
Object.defineProperty(exports, "SubscriptionClient", { enumerable: true, get: function () { return client_1.SubscriptionClient; } });
|
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "listSubscriptionsMessage", { enumerable: true, g
|
|
|
11
11
|
var types_1 = require("./types");
|
|
12
12
|
Object.defineProperty(exports, "NetworkError", { enumerable: true, get: function () { return types_1.NetworkError; } });
|
|
13
13
|
exports.NOTIFICATION_TYPE_SAM_AUCTION = 'sam_auction';
|
|
14
|
+
exports.NOTIFICATION_TYPE_INSTITUTIONAL_SELECT = 'institutional_select';
|
|
14
15
|
function createSubscriptionClient(config) {
|
|
15
16
|
return new client_1.SubscriptionClient(config);
|
|
16
17
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -71,12 +71,22 @@ export interface ListNotificationsQuery {
|
|
|
71
71
|
limit?: number;
|
|
72
72
|
offset?: number;
|
|
73
73
|
}
|
|
74
|
+
/** GET /v1/notifications/broadcast query (public, no auth required) */
|
|
75
|
+
export interface ListBroadcastNotificationsQuery {
|
|
76
|
+
notification_type?: string;
|
|
77
|
+
priority?: string;
|
|
78
|
+
inner_type?: string;
|
|
79
|
+
limit?: number;
|
|
80
|
+
offset?: number;
|
|
81
|
+
}
|
|
82
|
+
export type NotificationScope = 'broadcast' | 'individual';
|
|
74
83
|
/** GET /v1/notifications response item */
|
|
75
84
|
export interface Notification {
|
|
76
85
|
id: number;
|
|
77
86
|
notification_type: string;
|
|
78
87
|
inner_type: string;
|
|
79
88
|
user_id: string;
|
|
89
|
+
scope: NotificationScope;
|
|
80
90
|
priority: string;
|
|
81
91
|
message: string;
|
|
82
92
|
data: Record<string, unknown>;
|
package/index.ts
CHANGED
|
@@ -20,10 +20,13 @@ export type {
|
|
|
20
20
|
ListSubscriptionsAuth,
|
|
21
21
|
Subscription,
|
|
22
22
|
ListNotificationsQuery,
|
|
23
|
+
ListBroadcastNotificationsQuery,
|
|
23
24
|
Notification,
|
|
25
|
+
NotificationScope,
|
|
24
26
|
} from './types'
|
|
25
27
|
|
|
26
28
|
export const NOTIFICATION_TYPE_SAM_AUCTION = 'sam_auction'
|
|
29
|
+
export const NOTIFICATION_TYPE_INSTITUTIONAL_SELECT = 'institutional_select'
|
|
27
30
|
|
|
28
31
|
export function createSubscriptionClient(
|
|
29
32
|
config: SubscriptionClientConfig,
|
package/package.json
CHANGED
package/types.ts
CHANGED
|
@@ -93,12 +93,25 @@ export interface ListNotificationsQuery {
|
|
|
93
93
|
offset?: number
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
/** GET /v1/notifications/broadcast query (public, no auth required) */
|
|
97
|
+
export interface ListBroadcastNotificationsQuery {
|
|
98
|
+
notification_type?: string
|
|
99
|
+
priority?: string
|
|
100
|
+
inner_type?: string
|
|
101
|
+
limit?: number
|
|
102
|
+
offset?: number
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Keep in sync with notification-service/notifications/notifications.constants.ts NotificationScope
|
|
106
|
+
export type NotificationScope = 'broadcast' | 'individual'
|
|
107
|
+
|
|
96
108
|
/** GET /v1/notifications response item */
|
|
97
109
|
export interface Notification {
|
|
98
110
|
id: number
|
|
99
111
|
notification_type: string
|
|
100
112
|
inner_type: string
|
|
101
113
|
user_id: string
|
|
114
|
+
scope: NotificationScope
|
|
102
115
|
priority: string
|
|
103
116
|
message: string
|
|
104
117
|
data: Record<string, unknown>
|