@gzl10/nexus-plugin-notifications 0.17.0 → 0.18.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/package.json +6 -8
- package/dist/client/index.d.ts +0 -56
- package/dist/client/index.js +0 -34
- package/dist/client/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gzl10/nexus-plugin-notifications",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Nexus Plugin: Real-time in-app notifications via Socket.IO",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,10 +8,6 @@
|
|
|
8
8
|
".": {
|
|
9
9
|
"import": "./dist/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts"
|
|
11
|
-
},
|
|
12
|
-
"./client": {
|
|
13
|
-
"import": "./dist/client/index.js",
|
|
14
|
-
"types": "./dist/client/index.d.ts"
|
|
15
11
|
}
|
|
16
12
|
},
|
|
17
13
|
"files": [
|
|
@@ -27,12 +23,14 @@
|
|
|
27
23
|
"zod": "^3.24.0"
|
|
28
24
|
},
|
|
29
25
|
"devDependencies": {
|
|
30
|
-
"@gzl10/nexus-
|
|
31
|
-
"@gzl10/nexus-
|
|
26
|
+
"@gzl10/nexus-backend": "0.19.0",
|
|
27
|
+
"@gzl10/nexus-sdk": "0.19.0"
|
|
32
28
|
},
|
|
33
29
|
"scripts": {
|
|
34
30
|
"build": "tsup",
|
|
35
31
|
"lint": "eslint .",
|
|
36
|
-
"typecheck": "tsc --noEmit"
|
|
32
|
+
"typecheck": "tsc --noEmit",
|
|
33
|
+
"migrate:dev": "nexus migrate dev",
|
|
34
|
+
"migrate:status": "nexus migrate status"
|
|
37
35
|
}
|
|
38
36
|
}
|
package/dist/client/index.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { NexusClient, NexusApi } from '@gzl10/nexus-client';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @module @gzl10/nexus-plugin-notifications/client
|
|
5
|
-
* @description Client API for the Notifications plugin with declaration merging.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
interface Notification {
|
|
9
|
-
id: string;
|
|
10
|
-
type: string;
|
|
11
|
-
title: string;
|
|
12
|
-
message: string;
|
|
13
|
-
read: boolean;
|
|
14
|
-
created_at: string;
|
|
15
|
-
expires_at?: string;
|
|
16
|
-
data?: Record<string, unknown>;
|
|
17
|
-
}
|
|
18
|
-
interface PaginatedNotifications {
|
|
19
|
-
items: Notification[];
|
|
20
|
-
total: number;
|
|
21
|
-
page: number;
|
|
22
|
-
limit: number;
|
|
23
|
-
totalPages: number;
|
|
24
|
-
hasNext: boolean;
|
|
25
|
-
}
|
|
26
|
-
interface NotificationsApi {
|
|
27
|
-
getUnread(): Promise<PaginatedNotifications>;
|
|
28
|
-
getAll(params?: {
|
|
29
|
-
page?: number;
|
|
30
|
-
limit?: number;
|
|
31
|
-
}): Promise<PaginatedNotifications>;
|
|
32
|
-
markRead(id: string): Promise<void>;
|
|
33
|
-
markAllRead(): Promise<{
|
|
34
|
-
count: number;
|
|
35
|
-
}>;
|
|
36
|
-
}
|
|
37
|
-
declare module '@gzl10/nexus-client' {
|
|
38
|
-
interface NexusPluginApis {
|
|
39
|
-
notifications: NotificationsApi;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
declare function createNotificationsApi(client: NexusClient): NotificationsApi;
|
|
43
|
-
/**
|
|
44
|
-
* Registers the Notifications API on a NexusApi instance.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```typescript
|
|
48
|
-
* import { registerNotificationsApi } from '@gzl10/nexus-plugin-notifications/client'
|
|
49
|
-
*
|
|
50
|
-
* registerNotificationsApi(nexus)
|
|
51
|
-
* nexus.plugin('notifications').getUnread()
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
declare function registerNotificationsApi(nexus: NexusApi): void;
|
|
55
|
-
|
|
56
|
-
export { type Notification, type NotificationsApi, type PaginatedNotifications, createNotificationsApi, registerNotificationsApi };
|
package/dist/client/index.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// src/client/index.ts
|
|
2
|
-
function createNotificationsApi(client) {
|
|
3
|
-
return {
|
|
4
|
-
async getUnread() {
|
|
5
|
-
const response = await client.get("/notifications/unread");
|
|
6
|
-
return response.data;
|
|
7
|
-
},
|
|
8
|
-
async getAll(params) {
|
|
9
|
-
const query = new URLSearchParams();
|
|
10
|
-
if (params?.page) query.set("page", String(params.page));
|
|
11
|
-
if (params?.limit) query.set("limit", String(params.limit));
|
|
12
|
-
const qs = query.toString();
|
|
13
|
-
const response = await client.get(
|
|
14
|
-
qs ? `/notifications?${qs}` : "/notifications"
|
|
15
|
-
);
|
|
16
|
-
return response.data;
|
|
17
|
-
},
|
|
18
|
-
async markRead(id) {
|
|
19
|
-
await client.post(`/notifications/${id}/read`);
|
|
20
|
-
},
|
|
21
|
-
async markAllRead() {
|
|
22
|
-
const response = await client.post("/notifications/read-all");
|
|
23
|
-
return response.data;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function registerNotificationsApi(nexus) {
|
|
28
|
-
nexus.extend("notifications", (client) => createNotificationsApi(client));
|
|
29
|
-
}
|
|
30
|
-
export {
|
|
31
|
-
createNotificationsApi,
|
|
32
|
-
registerNotificationsApi
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=index.js.map
|
package/dist/client/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/client/index.ts"],"sourcesContent":["/**\n * @module @gzl10/nexus-plugin-notifications/client\n * @description Client API for the Notifications plugin with declaration merging.\n */\n\nimport type { NexusClient, NexusApi } from '@gzl10/nexus-client'\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface Notification {\n id: string\n type: string\n title: string\n message: string\n read: boolean\n created_at: string\n expires_at?: string\n data?: Record<string, unknown>\n}\n\nexport interface PaginatedNotifications {\n items: Notification[]\n total: number\n page: number\n limit: number\n totalPages: number\n hasNext: boolean\n}\n\nexport interface NotificationsApi {\n getUnread(): Promise<PaginatedNotifications>\n getAll(params?: { page?: number; limit?: number }): Promise<PaginatedNotifications>\n markRead(id: string): Promise<void>\n markAllRead(): Promise<{ count: number }>\n}\n\n// ============================================================================\n// Declaration merging — typed plugin() calls\n// ============================================================================\n\ndeclare module '@gzl10/nexus-client' {\n interface NexusPluginApis {\n notifications: NotificationsApi\n }\n}\n\n// ============================================================================\n// Factory\n// ============================================================================\n\nexport function createNotificationsApi(client: NexusClient): NotificationsApi {\n return {\n async getUnread() {\n const response = await client.get<PaginatedNotifications>('/notifications/unread')\n return response.data\n },\n\n async getAll(params) {\n const query = new URLSearchParams()\n if (params?.page) query.set('page', String(params.page))\n if (params?.limit) query.set('limit', String(params.limit))\n const qs = query.toString()\n const response = await client.get<PaginatedNotifications>(\n qs ? `/notifications?${qs}` : '/notifications'\n )\n return response.data\n },\n\n async markRead(id: string) {\n await client.post(`/notifications/${id}/read`)\n },\n\n async markAllRead() {\n const response = await client.post<{ count: number }>('/notifications/read-all')\n return response.data\n }\n }\n}\n\n/**\n * Registers the Notifications API on a NexusApi instance.\n *\n * @example\n * ```typescript\n * import { registerNotificationsApi } from '@gzl10/nexus-plugin-notifications/client'\n *\n * registerNotificationsApi(nexus)\n * nexus.plugin('notifications').getUnread()\n * ```\n */\nexport function registerNotificationsApi(nexus: NexusApi): void {\n nexus.extend('notifications', (client) => createNotificationsApi(client))\n}\n"],"mappings":";AAoDO,SAAS,uBAAuB,QAAuC;AAC5E,SAAO;AAAA,IACL,MAAM,YAAY;AAChB,YAAM,WAAW,MAAM,OAAO,IAA4B,uBAAuB;AACjF,aAAO,SAAS;AAAA,IAClB;AAAA,IAEA,MAAM,OAAO,QAAQ;AACnB,YAAM,QAAQ,IAAI,gBAAgB;AAClC,UAAI,QAAQ,KAAM,OAAM,IAAI,QAAQ,OAAO,OAAO,IAAI,CAAC;AACvD,UAAI,QAAQ,MAAO,OAAM,IAAI,SAAS,OAAO,OAAO,KAAK,CAAC;AAC1D,YAAM,KAAK,MAAM,SAAS;AAC1B,YAAM,WAAW,MAAM,OAAO;AAAA,QAC5B,KAAK,kBAAkB,EAAE,KAAK;AAAA,MAChC;AACA,aAAO,SAAS;AAAA,IAClB;AAAA,IAEA,MAAM,SAAS,IAAY;AACzB,YAAM,OAAO,KAAK,kBAAkB,EAAE,OAAO;AAAA,IAC/C;AAAA,IAEA,MAAM,cAAc;AAClB,YAAM,WAAW,MAAM,OAAO,KAAwB,yBAAyB;AAC/E,aAAO,SAAS;AAAA,IAClB;AAAA,EACF;AACF;AAaO,SAAS,yBAAyB,OAAuB;AAC9D,QAAM,OAAO,iBAAiB,CAAC,WAAW,uBAAuB,MAAM,CAAC;AAC1E;","names":[]}
|