@meowinc/meow-sdk 0.13.2 → 0.14.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.
- package/README.md +23 -23
- package/dist/notification/index.d.ts +2 -0
- package/dist/notification/index.js +3 -0
- package/dist/notification/notification/get-my-notifications.d.ts +33 -0
- package/dist/notification/notification/get-my-notifications.js +15 -0
- package/dist/notification/notification/index.d.ts +8 -0
- package/dist/notification/notification/index.js +14 -0
- package/dist/notification/notification/set-notification-read.d.ts +3 -0
- package/dist/notification/notification/set-notification-read.js +11 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
# Meow SDK (TypeScript) 🐾
|
|
2
|
-
|
|
3
|
-
Официальный TypeScript SDK для быстрой интеграции с сервисами экосистемы **Meow**. Упрощает работу с Auth, Profile, API и уведомлениями.
|
|
4
|
-
|
|
5
|
-

|
|
6
|
-

|
|
7
|
-

|
|
8
|
-
|
|
9
|
-
## ✨ Возможности
|
|
10
|
-
|
|
11
|
-
- **Type-safe:** Полная типизация всех ответов API и моделей данных.
|
|
12
|
-
- **Auth Provider:** Встроенные методы для работы с сессиями и JWT.
|
|
13
|
-
- **Auto-refresh:** Автоматическое обновление токенов доступа "под капотом".
|
|
14
|
-
|
|
15
|
-
## 📦 Установка
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npm install @meowinc/meow-sdk
|
|
19
|
-
# или
|
|
20
|
-
pnpm add @meowinc/meow-sdk
|
|
21
|
-
# или
|
|
22
|
-
yarn add @meowinc/meow-sdk
|
|
23
|
-
```
|
|
1
|
+
# Meow SDK (TypeScript) 🐾
|
|
2
|
+
|
|
3
|
+
Официальный TypeScript SDK для быстрой интеграции с сервисами экосистемы **Meow**. Упрощает работу с Auth, Profile, API и уведомлениями.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## ✨ Возможности
|
|
10
|
+
|
|
11
|
+
- **Type-safe:** Полная типизация всех ответов API и моделей данных.
|
|
12
|
+
- **Auth Provider:** Встроенные методы для работы с сессиями и JWT.
|
|
13
|
+
- **Auto-refresh:** Автоматическое обновление токенов доступа "под капотом".
|
|
14
|
+
|
|
15
|
+
## 📦 Установка
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @meowinc/meow-sdk
|
|
19
|
+
# или
|
|
20
|
+
pnpm add @meowinc/meow-sdk
|
|
21
|
+
# или
|
|
22
|
+
yarn add @meowinc/meow-sdk
|
|
23
|
+
```
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { AuthorizationProvider } from "..";
|
|
2
|
+
import { NotificationRequests } from "./notification";
|
|
2
3
|
import { PushSubscriptionRequests } from "./push-subscription";
|
|
3
4
|
export declare const NOTIFICATION_API = "https://notification.meowinc.tech/api";
|
|
4
5
|
export declare class NotificationClient {
|
|
5
6
|
pushSubscription: PushSubscriptionRequests;
|
|
7
|
+
notification: NotificationRequests;
|
|
6
8
|
constructor(authorizationProvider: AuthorizationProvider);
|
|
7
9
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { NotificationRequests } from "./notification";
|
|
1
2
|
import { PushSubscriptionRequests } from "./push-subscription";
|
|
2
3
|
export const NOTIFICATION_API = "https://notification.meowinc.tech/api";
|
|
3
4
|
export class NotificationClient {
|
|
4
5
|
pushSubscription;
|
|
6
|
+
notification;
|
|
5
7
|
constructor(authorizationProvider) {
|
|
6
8
|
this.pushSubscription = new PushSubscriptionRequests(authorizationProvider);
|
|
9
|
+
this.notification = new NotificationRequests(authorizationProvider);
|
|
7
10
|
}
|
|
8
11
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AuthorizationProvider } from "../..";
|
|
2
|
+
import { MeowResult } from "../../types";
|
|
3
|
+
export interface Response {
|
|
4
|
+
items: {
|
|
5
|
+
channel: string;
|
|
6
|
+
createdAt: string;
|
|
7
|
+
id: number;
|
|
8
|
+
isRead: boolean;
|
|
9
|
+
payload: NotificationPayload;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
type NotificationPayload = {
|
|
13
|
+
type: "nonAction";
|
|
14
|
+
title: string;
|
|
15
|
+
description: string;
|
|
16
|
+
} | {
|
|
17
|
+
type: "withRedirect";
|
|
18
|
+
title: string;
|
|
19
|
+
description: string;
|
|
20
|
+
redirectUrl: string;
|
|
21
|
+
} | {
|
|
22
|
+
type: "withParams";
|
|
23
|
+
title: string;
|
|
24
|
+
description: string;
|
|
25
|
+
params: Record<string, string>;
|
|
26
|
+
};
|
|
27
|
+
export interface Params {
|
|
28
|
+
channel: string;
|
|
29
|
+
offset?: number;
|
|
30
|
+
limit?: number;
|
|
31
|
+
}
|
|
32
|
+
export declare function request(params: Params, auth: AuthorizationProvider): Promise<MeowResult<Response>>;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NOTIFICATION_API } from "..";
|
|
2
|
+
import { ErrorToMessage } from "../../error";
|
|
3
|
+
import { HttpClient } from "../../http-client";
|
|
4
|
+
export async function request(params, auth) {
|
|
5
|
+
const { channel, offset, limit } = params;
|
|
6
|
+
return await new HttpClient()
|
|
7
|
+
.withAuthorization(auth)
|
|
8
|
+
.withMethodGet()
|
|
9
|
+
.withUrl(`${NOTIFICATION_API}/v1/notification/my`)
|
|
10
|
+
.withParam("channel", channel)
|
|
11
|
+
.withParam("offset", offset)
|
|
12
|
+
.withParam("limit", limit)
|
|
13
|
+
.send()
|
|
14
|
+
.then((r) => r.mapError(ErrorToMessage));
|
|
15
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AuthorizationProvider } from "../..";
|
|
2
|
+
import { Params as GetMyNotificationsParams } from "./get-my-notifications";
|
|
3
|
+
export declare class NotificationRequests {
|
|
4
|
+
private auth;
|
|
5
|
+
constructor(auth: AuthorizationProvider);
|
|
6
|
+
getMyNotifications(params: GetMyNotificationsParams): Promise<import("../../types").MeowResult<import("./get-my-notifications").Response>>;
|
|
7
|
+
setNotificationRead(notificationId: number): Promise<import("../../types").MeowResult<void>>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { request as getMyNotifications } from "./get-my-notifications";
|
|
2
|
+
import { request as setNotificationRead } from "./set-notification-read";
|
|
3
|
+
export class NotificationRequests {
|
|
4
|
+
auth;
|
|
5
|
+
constructor(auth) {
|
|
6
|
+
this.auth = auth;
|
|
7
|
+
}
|
|
8
|
+
async getMyNotifications(params) {
|
|
9
|
+
return await getMyNotifications(params, this.auth);
|
|
10
|
+
}
|
|
11
|
+
async setNotificationRead(notificationId) {
|
|
12
|
+
return await setNotificationRead(notificationId, this.auth);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NOTIFICATION_API } from "..";
|
|
2
|
+
import { ErrorToMessage } from "../../error";
|
|
3
|
+
import { HttpClient } from "../../http-client";
|
|
4
|
+
export async function request(notificationId, auth) {
|
|
5
|
+
return await new HttpClient()
|
|
6
|
+
.withAuthorization(auth)
|
|
7
|
+
.withMethodPut()
|
|
8
|
+
.withUrl(`${NOTIFICATION_API}/v1/notification/my/${notificationId}/read`)
|
|
9
|
+
.send()
|
|
10
|
+
.then((r) => r.mapError(ErrorToMessage));
|
|
11
|
+
}
|