@tnf-dev/js 1.0.1-6 → 1.0.1-8
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/dist/cjs/client/client.cjs +1 -138
- package/dist/cjs/client/convex.cjs +1 -31
- package/dist/cjs/client/index.cjs +1 -140
- package/dist/cjs/client/notification.cjs +1 -105
- package/dist/cjs/index.cjs +1 -140
- package/dist/cjs/utils/const.cjs +1 -34
- package/dist/cjs/utils/index.cjs +1 -36
- package/dist/esm/client/client.js +1 -9
- package/dist/esm/client/convex.js +1 -6
- package/dist/esm/client/index.js +1 -10
- package/dist/esm/client/notification.js +1 -7
- package/dist/esm/index.js +1 -10
- package/dist/esm/utils/const.js +1 -9
- package/dist/esm/utils/index.js +1 -9
- package/package.json +2 -2
- package/dist/cjs/client/client.cjs.map +0 -1
- package/dist/cjs/client/convex.cjs.map +0 -1
- package/dist/cjs/client/index.cjs.map +0 -1
- package/dist/cjs/client/notification.cjs.map +0 -1
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/utils/const.cjs.map +0 -1
- package/dist/cjs/utils/index.cjs.map +0 -1
- package/dist/esm/chunk-FC6XFVCA.js +0 -72
- package/dist/esm/chunk-FC6XFVCA.js.map +0 -1
- package/dist/esm/chunk-J52CIUB2.js +0 -9
- package/dist/esm/chunk-J52CIUB2.js.map +0 -1
- package/dist/esm/chunk-QMITKG5M.js +0 -35
- package/dist/esm/chunk-QMITKG5M.js.map +0 -1
- package/dist/esm/chunk-ZX5OIIJX.js +0 -1
- package/dist/esm/chunk-ZX5OIIJX.js.map +0 -1
- package/dist/esm/client/client.js.map +0 -1
- package/dist/esm/client/convex.js.map +0 -1
- package/dist/esm/client/index.js.map +0 -1
- package/dist/esm/client/notification.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/utils/const.js.map +0 -1
- package/dist/esm/utils/index.js.map +0 -1
@@ -1,138 +1 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __typeError = (msg) => {
|
7
|
-
throw TypeError(msg);
|
8
|
-
};
|
9
|
-
var __export = (target, all) => {
|
10
|
-
for (var name in all)
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
12
|
-
};
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
15
|
-
for (let key of __getOwnPropNames(from))
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
18
|
-
}
|
19
|
-
return to;
|
20
|
-
};
|
21
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
22
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
23
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
24
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
25
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
26
|
-
|
27
|
-
// src/client/client.ts
|
28
|
-
var client_exports = {};
|
29
|
-
__export(client_exports, {
|
30
|
-
TeknifyClient: () => TeknifyClient
|
31
|
-
});
|
32
|
-
module.exports = __toCommonJS(client_exports);
|
33
|
-
var import_core = require("@tnf-dev/core");
|
34
|
-
var import_browser = require("convex/browser");
|
35
|
-
|
36
|
-
// src/utils/const.ts
|
37
|
-
var DEFAULT_BASE_URL = "https://tekify.teknix.services";
|
38
|
-
var DEFAULT_SOCKET_URL = "https://convex-be.teknix.services";
|
39
|
-
|
40
|
-
// src/client/notification.ts
|
41
|
-
var import_server = require("convex/server");
|
42
|
-
var _handlers;
|
43
|
-
var NotificationClient = class {
|
44
|
-
constructor(httpClient, convexClient, options) {
|
45
|
-
this.httpClient = httpClient;
|
46
|
-
this.convexClient = convexClient;
|
47
|
-
this.options = options;
|
48
|
-
__privateAdd(this, _handlers, []);
|
49
|
-
this.convexClient.onUpdate(
|
50
|
-
import_server.anyApi.notifications.listenToNotificationsCount,
|
51
|
-
{
|
52
|
-
subscriberId: this.options.subscriberId
|
53
|
-
},
|
54
|
-
({ latest }) => {
|
55
|
-
if (!latest) return;
|
56
|
-
__privateGet(this, _handlers).forEach((handler) => handler([latest]));
|
57
|
-
}
|
58
|
-
);
|
59
|
-
}
|
60
|
-
async getNotifications(params) {
|
61
|
-
const [res, { counts }] = await Promise.all([
|
62
|
-
this.convexClient.query(import_server.anyApi.notifications.get, {
|
63
|
-
numItems: params.numItems,
|
64
|
-
cursor: params.cursor,
|
65
|
-
filter: {
|
66
|
-
subscriberId: this.options.subscriberId,
|
67
|
-
appId: this.options.applicationId
|
68
|
-
}
|
69
|
-
}),
|
70
|
-
this.convexClient.query(import_server.anyApi.notifications.listenToNotificationsCount, {
|
71
|
-
subscriberId: this.options.subscriberId
|
72
|
-
})
|
73
|
-
]);
|
74
|
-
return {
|
75
|
-
data: res.page,
|
76
|
-
pagination: {
|
77
|
-
continueCursor: res.isDone ? null : res.continueCursor,
|
78
|
-
total: counts.total
|
79
|
-
},
|
80
|
-
status: "success",
|
81
|
-
unread: counts.unread
|
82
|
-
};
|
83
|
-
}
|
84
|
-
async getNotification(notificationId) {
|
85
|
-
return this.httpClient.get(`/notifications/${notificationId}`);
|
86
|
-
}
|
87
|
-
async markAsRead(notificationId) {
|
88
|
-
return await this.convexClient.mutation(import_server.anyApi.notifications.markAsRead, {
|
89
|
-
id: notificationId
|
90
|
-
});
|
91
|
-
}
|
92
|
-
async markAsUnread(notificationId) {
|
93
|
-
return this.httpClient.put(`/notifications/${notificationId}/unread`, {});
|
94
|
-
}
|
95
|
-
async archive(notificationId) {
|
96
|
-
return this.httpClient.put(`/notifications/${notificationId}/archive`, {});
|
97
|
-
}
|
98
|
-
async unarchive(notificationId) {
|
99
|
-
return this.httpClient.put(`/notifications/${notificationId}/unarchive`, {});
|
100
|
-
}
|
101
|
-
on(handler) {
|
102
|
-
__privateGet(this, _handlers).push(handler);
|
103
|
-
}
|
104
|
-
off(handler) {
|
105
|
-
__privateSet(this, _handlers, __privateGet(this, _handlers).filter((h) => h === handler));
|
106
|
-
}
|
107
|
-
};
|
108
|
-
_handlers = new WeakMap();
|
109
|
-
|
110
|
-
// src/client/client.ts
|
111
|
-
var _httpClient, _convexClient, _notification;
|
112
|
-
var TeknifyClient = class {
|
113
|
-
constructor(options) {
|
114
|
-
__privateAdd(this, _httpClient);
|
115
|
-
__privateAdd(this, _convexClient);
|
116
|
-
__privateAdd(this, _notification);
|
117
|
-
__privateSet(this, _httpClient, new import_core.HttpClient({
|
118
|
-
...options,
|
119
|
-
baseUrl: options.baseUrl || DEFAULT_BASE_URL
|
120
|
-
}));
|
121
|
-
__privateSet(this, _convexClient, new import_browser.ConvexClient(options.socketUrl || DEFAULT_SOCKET_URL));
|
122
|
-
__privateSet(this, _notification, new NotificationClient(__privateGet(this, _httpClient), __privateGet(this, _convexClient), {
|
123
|
-
applicationId: options.applicationId,
|
124
|
-
subscriberId: options.subscriberId
|
125
|
-
}));
|
126
|
-
}
|
127
|
-
get notification() {
|
128
|
-
return __privateGet(this, _notification);
|
129
|
-
}
|
130
|
-
};
|
131
|
-
_httpClient = new WeakMap();
|
132
|
-
_convexClient = new WeakMap();
|
133
|
-
_notification = new WeakMap();
|
134
|
-
// Annotate the CommonJS export names for ESM import in node:
|
135
|
-
0 && (module.exports = {
|
136
|
-
TeknifyClient
|
137
|
-
});
|
138
|
-
//# sourceMappingURL=client.cjs.map
|
1
|
+
"use strict";var C=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var m=i=>{throw TypeError(i)};var y=(i,t)=>{for(var n in t)C(i,n,{get:t[n],enumerable:!0})},A=(i,t,n,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of U(t))!P.call(i,o)&&o!==n&&C(i,o,{get:()=>t[o],enumerable:!(e=R(t,o))||e.enumerable});return i};var k=i=>A(C({},"__esModule",{value:!0}),i);var b=(i,t,n)=>t.has(i)||m("Cannot "+n);var s=(i,t,n)=>(b(i,t,"read from private field"),n?n.call(i):t.get(i)),a=(i,t,n)=>t.has(i)?m("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,n),c=(i,t,n,e)=>(b(i,t,"write to private field"),e?e.call(i,n):t.set(i,n),n);var E={};y(E,{TeknifyClient:()=>d});module.exports=k(E);var v=require("@tnf-dev/core"),N=require("convex/browser");var x="https://tekify.teknix.services",g="https://convex-be.teknix.services";var p=require("convex/server");var r,h=class{constructor(t,n,e){this.httpClient=t;this.convexClient=n;this.options=e;a(this,r,[]);this.convexClient.onUpdate(p.anyApi.notifications.listenToNotificationsCount,{subscriberId:this.options.subscriberId},({latest:o})=>{o&&s(this,r).forEach(I=>I([o]))})}async getNotifications(t){let[n,{counts:e}]=await Promise.all([this.convexClient.query(p.anyApi.notifications.get,{numItems:t.numItems,cursor:t.cursor,filter:{subscriberId:this.options.subscriberId,appId:this.options.applicationId}}),this.convexClient.query(p.anyApi.notifications.listenToNotificationsCount,{subscriberId:this.options.subscriberId})]);return{data:n.page,pagination:{continueCursor:n.isDone?null:n.continueCursor,total:e.total},status:"success",unread:e.unread}}async getNotification(t){return this.httpClient.get(`/notifications/${t}`)}async markAsRead(t){return await this.convexClient.mutation(p.anyApi.notifications.markAsRead,{id:t})}async markAsUnread(t){return this.httpClient.put(`/notifications/${t}/unread`,{})}async archive(t){return this.httpClient.put(`/notifications/${t}/archive`,{})}async unarchive(t){return this.httpClient.put(`/notifications/${t}/unarchive`,{})}on(t){s(this,r).push(t)}off(t){c(this,r,s(this,r).filter(n=>n===t))}};r=new WeakMap;var u,f,l,d=class{constructor(t){a(this,u);a(this,f);a(this,l);c(this,u,new v.HttpClient({...t,baseUrl:t.baseUrl||x})),c(this,f,new N.ConvexClient(t.socketUrl||g)),c(this,l,new h(s(this,u),s(this,f),{applicationId:t.applicationId,subscriberId:t.subscriberId}))}get notification(){return s(this,l)}};u=new WeakMap,f=new WeakMap,l=new WeakMap;0&&(module.exports={TeknifyClient});
|
@@ -1,31 +1 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __export = (target, all) => {
|
7
|
-
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
-
};
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
-
for (let key of __getOwnPropNames(from))
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
16
|
-
return to;
|
17
|
-
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
-
|
20
|
-
// src/client/convex.ts
|
21
|
-
var convex_exports = {};
|
22
|
-
__export(convex_exports, {
|
23
|
-
ConvexClient: () => import_browser.ConvexClient
|
24
|
-
});
|
25
|
-
module.exports = __toCommonJS(convex_exports);
|
26
|
-
var import_browser = require("convex/browser");
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
28
|
-
0 && (module.exports = {
|
29
|
-
ConvexClient
|
30
|
-
});
|
31
|
-
//# sourceMappingURL=convex.cjs.map
|
1
|
+
"use strict";var t=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var m=(o,e)=>{for(var r in e)t(o,r,{get:e[r],enumerable:!0})},p=(o,e,r,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of i(e))!l.call(o,n)&&n!==r&&t(o,n,{get:()=>e[n],enumerable:!(x=f(e,n))||x.enumerable});return o};var v=o=>p(t({},"__esModule",{value:!0}),o);var a={};m(a,{ConvexClient:()=>C.ConvexClient});module.exports=v(a);var C=require("convex/browser");0&&(module.exports={ConvexClient});
|
@@ -1,140 +1 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __typeError = (msg) => {
|
7
|
-
throw TypeError(msg);
|
8
|
-
};
|
9
|
-
var __export = (target, all) => {
|
10
|
-
for (var name in all)
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
12
|
-
};
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
15
|
-
for (let key of __getOwnPropNames(from))
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
18
|
-
}
|
19
|
-
return to;
|
20
|
-
};
|
21
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
22
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
23
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
24
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
25
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
26
|
-
|
27
|
-
// src/client/index.ts
|
28
|
-
var client_exports = {};
|
29
|
-
__export(client_exports, {
|
30
|
-
TeknifyClient: () => TeknifyClient
|
31
|
-
});
|
32
|
-
module.exports = __toCommonJS(client_exports);
|
33
|
-
|
34
|
-
// src/client/client.ts
|
35
|
-
var import_core = require("@tnf-dev/core");
|
36
|
-
var import_browser = require("convex/browser");
|
37
|
-
|
38
|
-
// src/utils/const.ts
|
39
|
-
var DEFAULT_BASE_URL = "https://tekify.teknix.services";
|
40
|
-
var DEFAULT_SOCKET_URL = "https://convex-be.teknix.services";
|
41
|
-
|
42
|
-
// src/client/notification.ts
|
43
|
-
var import_server = require("convex/server");
|
44
|
-
var _handlers;
|
45
|
-
var NotificationClient = class {
|
46
|
-
constructor(httpClient, convexClient, options) {
|
47
|
-
this.httpClient = httpClient;
|
48
|
-
this.convexClient = convexClient;
|
49
|
-
this.options = options;
|
50
|
-
__privateAdd(this, _handlers, []);
|
51
|
-
this.convexClient.onUpdate(
|
52
|
-
import_server.anyApi.notifications.listenToNotificationsCount,
|
53
|
-
{
|
54
|
-
subscriberId: this.options.subscriberId
|
55
|
-
},
|
56
|
-
({ latest }) => {
|
57
|
-
if (!latest) return;
|
58
|
-
__privateGet(this, _handlers).forEach((handler) => handler([latest]));
|
59
|
-
}
|
60
|
-
);
|
61
|
-
}
|
62
|
-
async getNotifications(params) {
|
63
|
-
const [res, { counts }] = await Promise.all([
|
64
|
-
this.convexClient.query(import_server.anyApi.notifications.get, {
|
65
|
-
numItems: params.numItems,
|
66
|
-
cursor: params.cursor,
|
67
|
-
filter: {
|
68
|
-
subscriberId: this.options.subscriberId,
|
69
|
-
appId: this.options.applicationId
|
70
|
-
}
|
71
|
-
}),
|
72
|
-
this.convexClient.query(import_server.anyApi.notifications.listenToNotificationsCount, {
|
73
|
-
subscriberId: this.options.subscriberId
|
74
|
-
})
|
75
|
-
]);
|
76
|
-
return {
|
77
|
-
data: res.page,
|
78
|
-
pagination: {
|
79
|
-
continueCursor: res.isDone ? null : res.continueCursor,
|
80
|
-
total: counts.total
|
81
|
-
},
|
82
|
-
status: "success",
|
83
|
-
unread: counts.unread
|
84
|
-
};
|
85
|
-
}
|
86
|
-
async getNotification(notificationId) {
|
87
|
-
return this.httpClient.get(`/notifications/${notificationId}`);
|
88
|
-
}
|
89
|
-
async markAsRead(notificationId) {
|
90
|
-
return await this.convexClient.mutation(import_server.anyApi.notifications.markAsRead, {
|
91
|
-
id: notificationId
|
92
|
-
});
|
93
|
-
}
|
94
|
-
async markAsUnread(notificationId) {
|
95
|
-
return this.httpClient.put(`/notifications/${notificationId}/unread`, {});
|
96
|
-
}
|
97
|
-
async archive(notificationId) {
|
98
|
-
return this.httpClient.put(`/notifications/${notificationId}/archive`, {});
|
99
|
-
}
|
100
|
-
async unarchive(notificationId) {
|
101
|
-
return this.httpClient.put(`/notifications/${notificationId}/unarchive`, {});
|
102
|
-
}
|
103
|
-
on(handler) {
|
104
|
-
__privateGet(this, _handlers).push(handler);
|
105
|
-
}
|
106
|
-
off(handler) {
|
107
|
-
__privateSet(this, _handlers, __privateGet(this, _handlers).filter((h) => h === handler));
|
108
|
-
}
|
109
|
-
};
|
110
|
-
_handlers = new WeakMap();
|
111
|
-
|
112
|
-
// src/client/client.ts
|
113
|
-
var _httpClient, _convexClient, _notification;
|
114
|
-
var TeknifyClient = class {
|
115
|
-
constructor(options) {
|
116
|
-
__privateAdd(this, _httpClient);
|
117
|
-
__privateAdd(this, _convexClient);
|
118
|
-
__privateAdd(this, _notification);
|
119
|
-
__privateSet(this, _httpClient, new import_core.HttpClient({
|
120
|
-
...options,
|
121
|
-
baseUrl: options.baseUrl || DEFAULT_BASE_URL
|
122
|
-
}));
|
123
|
-
__privateSet(this, _convexClient, new import_browser.ConvexClient(options.socketUrl || DEFAULT_SOCKET_URL));
|
124
|
-
__privateSet(this, _notification, new NotificationClient(__privateGet(this, _httpClient), __privateGet(this, _convexClient), {
|
125
|
-
applicationId: options.applicationId,
|
126
|
-
subscriberId: options.subscriberId
|
127
|
-
}));
|
128
|
-
}
|
129
|
-
get notification() {
|
130
|
-
return __privateGet(this, _notification);
|
131
|
-
}
|
132
|
-
};
|
133
|
-
_httpClient = new WeakMap();
|
134
|
-
_convexClient = new WeakMap();
|
135
|
-
_notification = new WeakMap();
|
136
|
-
// Annotate the CommonJS export names for ESM import in node:
|
137
|
-
0 && (module.exports = {
|
138
|
-
TeknifyClient
|
139
|
-
});
|
140
|
-
//# sourceMappingURL=index.cjs.map
|
1
|
+
"use strict";var C=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var m=i=>{throw TypeError(i)};var y=(i,t)=>{for(var n in t)C(i,n,{get:t[n],enumerable:!0})},A=(i,t,n,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of U(t))!P.call(i,o)&&o!==n&&C(i,o,{get:()=>t[o],enumerable:!(e=R(t,o))||e.enumerable});return i};var k=i=>A(C({},"__esModule",{value:!0}),i);var b=(i,t,n)=>t.has(i)||m("Cannot "+n);var s=(i,t,n)=>(b(i,t,"read from private field"),n?n.call(i):t.get(i)),a=(i,t,n)=>t.has(i)?m("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,n),c=(i,t,n,e)=>(b(i,t,"write to private field"),e?e.call(i,n):t.set(i,n),n);var E={};y(E,{TeknifyClient:()=>d});module.exports=k(E);var v=require("@tnf-dev/core"),N=require("convex/browser");var x="https://tekify.teknix.services",g="https://convex-be.teknix.services";var p=require("convex/server");var r,h=class{constructor(t,n,e){this.httpClient=t;this.convexClient=n;this.options=e;a(this,r,[]);this.convexClient.onUpdate(p.anyApi.notifications.listenToNotificationsCount,{subscriberId:this.options.subscriberId},({latest:o})=>{o&&s(this,r).forEach(I=>I([o]))})}async getNotifications(t){let[n,{counts:e}]=await Promise.all([this.convexClient.query(p.anyApi.notifications.get,{numItems:t.numItems,cursor:t.cursor,filter:{subscriberId:this.options.subscriberId,appId:this.options.applicationId}}),this.convexClient.query(p.anyApi.notifications.listenToNotificationsCount,{subscriberId:this.options.subscriberId})]);return{data:n.page,pagination:{continueCursor:n.isDone?null:n.continueCursor,total:e.total},status:"success",unread:e.unread}}async getNotification(t){return this.httpClient.get(`/notifications/${t}`)}async markAsRead(t){return await this.convexClient.mutation(p.anyApi.notifications.markAsRead,{id:t})}async markAsUnread(t){return this.httpClient.put(`/notifications/${t}/unread`,{})}async archive(t){return this.httpClient.put(`/notifications/${t}/archive`,{})}async unarchive(t){return this.httpClient.put(`/notifications/${t}/unarchive`,{})}on(t){s(this,r).push(t)}off(t){c(this,r,s(this,r).filter(n=>n===t))}};r=new WeakMap;var f,u,l,d=class{constructor(t){a(this,f);a(this,u);a(this,l);c(this,f,new v.HttpClient({...t,baseUrl:t.baseUrl||x})),c(this,u,new N.ConvexClient(t.socketUrl||g)),c(this,l,new h(s(this,f),s(this,u),{applicationId:t.applicationId,subscriberId:t.subscriberId}))}get notification(){return s(this,l)}};f=new WeakMap,u=new WeakMap,l=new WeakMap;0&&(module.exports={TeknifyClient});
|
@@ -1,105 +1 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __typeError = (msg) => {
|
7
|
-
throw TypeError(msg);
|
8
|
-
};
|
9
|
-
var __export = (target, all) => {
|
10
|
-
for (var name in all)
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
12
|
-
};
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
15
|
-
for (let key of __getOwnPropNames(from))
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
18
|
-
}
|
19
|
-
return to;
|
20
|
-
};
|
21
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
22
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
23
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
24
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
25
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
26
|
-
|
27
|
-
// src/client/notification.ts
|
28
|
-
var notification_exports = {};
|
29
|
-
__export(notification_exports, {
|
30
|
-
NotificationClient: () => NotificationClient
|
31
|
-
});
|
32
|
-
module.exports = __toCommonJS(notification_exports);
|
33
|
-
var import_server = require("convex/server");
|
34
|
-
var _handlers;
|
35
|
-
var NotificationClient = class {
|
36
|
-
constructor(httpClient, convexClient, options) {
|
37
|
-
this.httpClient = httpClient;
|
38
|
-
this.convexClient = convexClient;
|
39
|
-
this.options = options;
|
40
|
-
__privateAdd(this, _handlers, []);
|
41
|
-
this.convexClient.onUpdate(
|
42
|
-
import_server.anyApi.notifications.listenToNotificationsCount,
|
43
|
-
{
|
44
|
-
subscriberId: this.options.subscriberId
|
45
|
-
},
|
46
|
-
({ latest }) => {
|
47
|
-
if (!latest) return;
|
48
|
-
__privateGet(this, _handlers).forEach((handler) => handler([latest]));
|
49
|
-
}
|
50
|
-
);
|
51
|
-
}
|
52
|
-
async getNotifications(params) {
|
53
|
-
const [res, { counts }] = await Promise.all([
|
54
|
-
this.convexClient.query(import_server.anyApi.notifications.get, {
|
55
|
-
numItems: params.numItems,
|
56
|
-
cursor: params.cursor,
|
57
|
-
filter: {
|
58
|
-
subscriberId: this.options.subscriberId,
|
59
|
-
appId: this.options.applicationId
|
60
|
-
}
|
61
|
-
}),
|
62
|
-
this.convexClient.query(import_server.anyApi.notifications.listenToNotificationsCount, {
|
63
|
-
subscriberId: this.options.subscriberId
|
64
|
-
})
|
65
|
-
]);
|
66
|
-
return {
|
67
|
-
data: res.page,
|
68
|
-
pagination: {
|
69
|
-
continueCursor: res.isDone ? null : res.continueCursor,
|
70
|
-
total: counts.total
|
71
|
-
},
|
72
|
-
status: "success",
|
73
|
-
unread: counts.unread
|
74
|
-
};
|
75
|
-
}
|
76
|
-
async getNotification(notificationId) {
|
77
|
-
return this.httpClient.get(`/notifications/${notificationId}`);
|
78
|
-
}
|
79
|
-
async markAsRead(notificationId) {
|
80
|
-
return await this.convexClient.mutation(import_server.anyApi.notifications.markAsRead, {
|
81
|
-
id: notificationId
|
82
|
-
});
|
83
|
-
}
|
84
|
-
async markAsUnread(notificationId) {
|
85
|
-
return this.httpClient.put(`/notifications/${notificationId}/unread`, {});
|
86
|
-
}
|
87
|
-
async archive(notificationId) {
|
88
|
-
return this.httpClient.put(`/notifications/${notificationId}/archive`, {});
|
89
|
-
}
|
90
|
-
async unarchive(notificationId) {
|
91
|
-
return this.httpClient.put(`/notifications/${notificationId}/unarchive`, {});
|
92
|
-
}
|
93
|
-
on(handler) {
|
94
|
-
__privateGet(this, _handlers).push(handler);
|
95
|
-
}
|
96
|
-
off(handler) {
|
97
|
-
__privateSet(this, _handlers, __privateGet(this, _handlers).filter((h) => h === handler));
|
98
|
-
}
|
99
|
-
};
|
100
|
-
_handlers = new WeakMap();
|
101
|
-
// Annotate the CommonJS export names for ESM import in node:
|
102
|
-
0 && (module.exports = {
|
103
|
-
NotificationClient
|
104
|
-
});
|
105
|
-
//# sourceMappingURL=notification.cjs.map
|
1
|
+
"use strict";var c=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var u=t=>{throw TypeError(t)};var g=(t,i)=>{for(var n in i)c(t,n,{get:i[n],enumerable:!0})},v=(t,i,n,o)=>{if(i&&typeof i=="object"||typeof i=="function")for(let e of C(i))!N.call(t,e)&&e!==n&&c(t,e,{get:()=>i[e],enumerable:!(o=m(i,e))||o.enumerable});return t};var b=t=>v(c({},"__esModule",{value:!0}),t);var f=(t,i,n)=>i.has(t)||u("Cannot "+n);var r=(t,i,n)=>(f(t,i,"read from private field"),n?n.call(t):i.get(t)),h=(t,i,n)=>i.has(t)?u("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(t):i.set(t,n),l=(t,i,n,o)=>(f(t,i,"write to private field"),o?o.call(t,n):i.set(t,n),n);var R={};g(R,{NotificationClient:()=>p});module.exports=b(R);var a=require("convex/server");var s,p=class{constructor(i,n,o){this.httpClient=i;this.convexClient=n;this.options=o;h(this,s,[]);this.convexClient.onUpdate(a.anyApi.notifications.listenToNotificationsCount,{subscriberId:this.options.subscriberId},({latest:e})=>{e&&r(this,s).forEach(d=>d([e]))})}async getNotifications(i){let[n,{counts:o}]=await Promise.all([this.convexClient.query(a.anyApi.notifications.get,{numItems:i.numItems,cursor:i.cursor,filter:{subscriberId:this.options.subscriberId,appId:this.options.applicationId}}),this.convexClient.query(a.anyApi.notifications.listenToNotificationsCount,{subscriberId:this.options.subscriberId})]);return{data:n.page,pagination:{continueCursor:n.isDone?null:n.continueCursor,total:o.total},status:"success",unread:o.unread}}async getNotification(i){return this.httpClient.get(`/notifications/${i}`)}async markAsRead(i){return await this.convexClient.mutation(a.anyApi.notifications.markAsRead,{id:i})}async markAsUnread(i){return this.httpClient.put(`/notifications/${i}/unread`,{})}async archive(i){return this.httpClient.put(`/notifications/${i}/archive`,{})}async unarchive(i){return this.httpClient.put(`/notifications/${i}/unarchive`,{})}on(i){r(this,s).push(i)}off(i){l(this,s,r(this,s).filter(n=>n===i))}};s=new WeakMap;0&&(module.exports={NotificationClient});
|
package/dist/cjs/index.cjs
CHANGED
@@ -1,140 +1 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __typeError = (msg) => {
|
7
|
-
throw TypeError(msg);
|
8
|
-
};
|
9
|
-
var __export = (target, all) => {
|
10
|
-
for (var name in all)
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
12
|
-
};
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
15
|
-
for (let key of __getOwnPropNames(from))
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
18
|
-
}
|
19
|
-
return to;
|
20
|
-
};
|
21
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
22
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
23
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
24
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
25
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
26
|
-
|
27
|
-
// src/index.ts
|
28
|
-
var index_exports = {};
|
29
|
-
__export(index_exports, {
|
30
|
-
TeknifyClient: () => TeknifyClient
|
31
|
-
});
|
32
|
-
module.exports = __toCommonJS(index_exports);
|
33
|
-
|
34
|
-
// src/client/client.ts
|
35
|
-
var import_core = require("@tnf-dev/core");
|
36
|
-
var import_browser = require("convex/browser");
|
37
|
-
|
38
|
-
// src/utils/const.ts
|
39
|
-
var DEFAULT_BASE_URL = "https://tekify.teknix.services";
|
40
|
-
var DEFAULT_SOCKET_URL = "https://convex-be.teknix.services";
|
41
|
-
|
42
|
-
// src/client/notification.ts
|
43
|
-
var import_server = require("convex/server");
|
44
|
-
var _handlers;
|
45
|
-
var NotificationClient = class {
|
46
|
-
constructor(httpClient, convexClient, options) {
|
47
|
-
this.httpClient = httpClient;
|
48
|
-
this.convexClient = convexClient;
|
49
|
-
this.options = options;
|
50
|
-
__privateAdd(this, _handlers, []);
|
51
|
-
this.convexClient.onUpdate(
|
52
|
-
import_server.anyApi.notifications.listenToNotificationsCount,
|
53
|
-
{
|
54
|
-
subscriberId: this.options.subscriberId
|
55
|
-
},
|
56
|
-
({ latest }) => {
|
57
|
-
if (!latest) return;
|
58
|
-
__privateGet(this, _handlers).forEach((handler) => handler([latest]));
|
59
|
-
}
|
60
|
-
);
|
61
|
-
}
|
62
|
-
async getNotifications(params) {
|
63
|
-
const [res, { counts }] = await Promise.all([
|
64
|
-
this.convexClient.query(import_server.anyApi.notifications.get, {
|
65
|
-
numItems: params.numItems,
|
66
|
-
cursor: params.cursor,
|
67
|
-
filter: {
|
68
|
-
subscriberId: this.options.subscriberId,
|
69
|
-
appId: this.options.applicationId
|
70
|
-
}
|
71
|
-
}),
|
72
|
-
this.convexClient.query(import_server.anyApi.notifications.listenToNotificationsCount, {
|
73
|
-
subscriberId: this.options.subscriberId
|
74
|
-
})
|
75
|
-
]);
|
76
|
-
return {
|
77
|
-
data: res.page,
|
78
|
-
pagination: {
|
79
|
-
continueCursor: res.isDone ? null : res.continueCursor,
|
80
|
-
total: counts.total
|
81
|
-
},
|
82
|
-
status: "success",
|
83
|
-
unread: counts.unread
|
84
|
-
};
|
85
|
-
}
|
86
|
-
async getNotification(notificationId) {
|
87
|
-
return this.httpClient.get(`/notifications/${notificationId}`);
|
88
|
-
}
|
89
|
-
async markAsRead(notificationId) {
|
90
|
-
return await this.convexClient.mutation(import_server.anyApi.notifications.markAsRead, {
|
91
|
-
id: notificationId
|
92
|
-
});
|
93
|
-
}
|
94
|
-
async markAsUnread(notificationId) {
|
95
|
-
return this.httpClient.put(`/notifications/${notificationId}/unread`, {});
|
96
|
-
}
|
97
|
-
async archive(notificationId) {
|
98
|
-
return this.httpClient.put(`/notifications/${notificationId}/archive`, {});
|
99
|
-
}
|
100
|
-
async unarchive(notificationId) {
|
101
|
-
return this.httpClient.put(`/notifications/${notificationId}/unarchive`, {});
|
102
|
-
}
|
103
|
-
on(handler) {
|
104
|
-
__privateGet(this, _handlers).push(handler);
|
105
|
-
}
|
106
|
-
off(handler) {
|
107
|
-
__privateSet(this, _handlers, __privateGet(this, _handlers).filter((h) => h === handler));
|
108
|
-
}
|
109
|
-
};
|
110
|
-
_handlers = new WeakMap();
|
111
|
-
|
112
|
-
// src/client/client.ts
|
113
|
-
var _httpClient, _convexClient, _notification;
|
114
|
-
var TeknifyClient = class {
|
115
|
-
constructor(options) {
|
116
|
-
__privateAdd(this, _httpClient);
|
117
|
-
__privateAdd(this, _convexClient);
|
118
|
-
__privateAdd(this, _notification);
|
119
|
-
__privateSet(this, _httpClient, new import_core.HttpClient({
|
120
|
-
...options,
|
121
|
-
baseUrl: options.baseUrl || DEFAULT_BASE_URL
|
122
|
-
}));
|
123
|
-
__privateSet(this, _convexClient, new import_browser.ConvexClient(options.socketUrl || DEFAULT_SOCKET_URL));
|
124
|
-
__privateSet(this, _notification, new NotificationClient(__privateGet(this, _httpClient), __privateGet(this, _convexClient), {
|
125
|
-
applicationId: options.applicationId,
|
126
|
-
subscriberId: options.subscriberId
|
127
|
-
}));
|
128
|
-
}
|
129
|
-
get notification() {
|
130
|
-
return __privateGet(this, _notification);
|
131
|
-
}
|
132
|
-
};
|
133
|
-
_httpClient = new WeakMap();
|
134
|
-
_convexClient = new WeakMap();
|
135
|
-
_notification = new WeakMap();
|
136
|
-
// Annotate the CommonJS export names for ESM import in node:
|
137
|
-
0 && (module.exports = {
|
138
|
-
TeknifyClient
|
139
|
-
});
|
140
|
-
//# sourceMappingURL=index.cjs.map
|
1
|
+
"use strict";var C=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var m=i=>{throw TypeError(i)};var y=(i,t)=>{for(var n in t)C(i,n,{get:t[n],enumerable:!0})},A=(i,t,n,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of U(t))!P.call(i,o)&&o!==n&&C(i,o,{get:()=>t[o],enumerable:!(e=R(t,o))||e.enumerable});return i};var k=i=>A(C({},"__esModule",{value:!0}),i);var b=(i,t,n)=>t.has(i)||m("Cannot "+n);var s=(i,t,n)=>(b(i,t,"read from private field"),n?n.call(i):t.get(i)),a=(i,t,n)=>t.has(i)?m("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,n),c=(i,t,n,e)=>(b(i,t,"write to private field"),e?e.call(i,n):t.set(i,n),n);var E={};y(E,{TeknifyClient:()=>d});module.exports=k(E);var v=require("@tnf-dev/core"),N=require("convex/browser");var x="https://tekify.teknix.services",g="https://convex-be.teknix.services";var p=require("convex/server");var r,h=class{constructor(t,n,e){this.httpClient=t;this.convexClient=n;this.options=e;a(this,r,[]);this.convexClient.onUpdate(p.anyApi.notifications.listenToNotificationsCount,{subscriberId:this.options.subscriberId},({latest:o})=>{o&&s(this,r).forEach(I=>I([o]))})}async getNotifications(t){let[n,{counts:e}]=await Promise.all([this.convexClient.query(p.anyApi.notifications.get,{numItems:t.numItems,cursor:t.cursor,filter:{subscriberId:this.options.subscriberId,appId:this.options.applicationId}}),this.convexClient.query(p.anyApi.notifications.listenToNotificationsCount,{subscriberId:this.options.subscriberId})]);return{data:n.page,pagination:{continueCursor:n.isDone?null:n.continueCursor,total:e.total},status:"success",unread:e.unread}}async getNotification(t){return this.httpClient.get(`/notifications/${t}`)}async markAsRead(t){return await this.convexClient.mutation(p.anyApi.notifications.markAsRead,{id:t})}async markAsUnread(t){return this.httpClient.put(`/notifications/${t}/unread`,{})}async archive(t){return this.httpClient.put(`/notifications/${t}/archive`,{})}async unarchive(t){return this.httpClient.put(`/notifications/${t}/unarchive`,{})}on(t){s(this,r).push(t)}off(t){c(this,r,s(this,r).filter(n=>n===t))}};r=new WeakMap;var f,u,l,d=class{constructor(t){a(this,f);a(this,u);a(this,l);c(this,f,new v.HttpClient({...t,baseUrl:t.baseUrl||x})),c(this,u,new N.ConvexClient(t.socketUrl||g)),c(this,l,new h(s(this,f),s(this,u),{applicationId:t.applicationId,subscriberId:t.subscriberId}))}get notification(){return s(this,l)}};f=new WeakMap,u=new WeakMap,l=new WeakMap;0&&(module.exports={TeknifyClient});
|
package/dist/cjs/utils/const.cjs
CHANGED
@@ -1,34 +1 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __export = (target, all) => {
|
7
|
-
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
-
};
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
-
for (let key of __getOwnPropNames(from))
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
16
|
-
return to;
|
17
|
-
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
-
|
20
|
-
// src/utils/const.ts
|
21
|
-
var const_exports = {};
|
22
|
-
__export(const_exports, {
|
23
|
-
DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
|
24
|
-
DEFAULT_SOCKET_URL: () => DEFAULT_SOCKET_URL
|
25
|
-
});
|
26
|
-
module.exports = __toCommonJS(const_exports);
|
27
|
-
var DEFAULT_BASE_URL = "https://tekify.teknix.services";
|
28
|
-
var DEFAULT_SOCKET_URL = "https://convex-be.teknix.services";
|
29
|
-
// Annotate the CommonJS export names for ESM import in node:
|
30
|
-
0 && (module.exports = {
|
31
|
-
DEFAULT_BASE_URL,
|
32
|
-
DEFAULT_SOCKET_URL
|
33
|
-
});
|
34
|
-
//# sourceMappingURL=const.cjs.map
|
1
|
+
"use strict";var i=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var r=(t,e)=>{for(var c in e)i(t,c,{get:e[c],enumerable:!0})},E=(t,e,c,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of x(e))!p.call(t,s)&&s!==c&&i(t,s,{get:()=>e[s],enumerable:!(n=o(e,s))||n.enumerable});return t};var L=t=>E(i({},"__esModule",{value:!0}),t);var k={};r(k,{DEFAULT_BASE_URL:()=>U,DEFAULT_SOCKET_URL:()=>_});module.exports=L(k);var U="https://tekify.teknix.services",_="https://convex-be.teknix.services";0&&(module.exports={DEFAULT_BASE_URL,DEFAULT_SOCKET_URL});
|
package/dist/cjs/utils/index.cjs
CHANGED
@@ -1,36 +1 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __export = (target, all) => {
|
7
|
-
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
-
};
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
-
for (let key of __getOwnPropNames(from))
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
16
|
-
return to;
|
17
|
-
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
-
|
20
|
-
// src/utils/index.ts
|
21
|
-
var utils_exports = {};
|
22
|
-
__export(utils_exports, {
|
23
|
-
DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
|
24
|
-
DEFAULT_SOCKET_URL: () => DEFAULT_SOCKET_URL
|
25
|
-
});
|
26
|
-
module.exports = __toCommonJS(utils_exports);
|
27
|
-
|
28
|
-
// src/utils/const.ts
|
29
|
-
var DEFAULT_BASE_URL = "https://tekify.teknix.services";
|
30
|
-
var DEFAULT_SOCKET_URL = "https://convex-be.teknix.services";
|
31
|
-
// Annotate the CommonJS export names for ESM import in node:
|
32
|
-
0 && (module.exports = {
|
33
|
-
DEFAULT_BASE_URL,
|
34
|
-
DEFAULT_SOCKET_URL
|
35
|
-
});
|
36
|
-
//# sourceMappingURL=index.cjs.map
|
1
|
+
"use strict";var r=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var p=(t,e)=>{for(var o in e)r(t,o,{get:e[o],enumerable:!0})},E=(t,e,o,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of i(e))!n.call(t,s)&&s!==o&&r(t,s,{get:()=>e[s],enumerable:!(x=c(e,s))||x.enumerable});return t};var L=t=>E(r({},"__esModule",{value:!0}),t);var k={};p(k,{DEFAULT_BASE_URL:()=>U,DEFAULT_SOCKET_URL:()=>_});module.exports=L(k);var U="https://tekify.teknix.services",_="https://convex-be.teknix.services";0&&(module.exports={DEFAULT_BASE_URL,DEFAULT_SOCKET_URL});
|
@@ -1,9 +1 @@
|
|
1
|
-
import {
|
2
|
-
TeknifyClient
|
3
|
-
} from "../chunk-QMITKG5M.js";
|
4
|
-
import "../chunk-FC6XFVCA.js";
|
5
|
-
import "../chunk-J52CIUB2.js";
|
6
|
-
export {
|
7
|
-
TeknifyClient
|
8
|
-
};
|
9
|
-
//# sourceMappingURL=client.js.map
|
1
|
+
import{HttpClient as f}from"@tnf-dev/core";import{ConvexClient as l}from"convex/browser";var r="https://tekify.teknix.services",a="https://convex-be.teknix.services";import{anyApi as n}from"convex/server";var e=class{constructor(t,i,o){this.httpClient=t;this.convexClient=i;this.options=o;this.convexClient.onUpdate(n.notifications.listenToNotificationsCount,{subscriberId:this.options.subscriberId},({latest:s})=>{s&&this.#t.forEach(u=>u([s]))})}#t=[];async getNotifications(t){let[i,{counts:o}]=await Promise.all([this.convexClient.query(n.notifications.get,{numItems:t.numItems,cursor:t.cursor,filter:{subscriberId:this.options.subscriberId,appId:this.options.applicationId}}),this.convexClient.query(n.notifications.listenToNotificationsCount,{subscriberId:this.options.subscriberId})]);return{data:i.page,pagination:{continueCursor:i.isDone?null:i.continueCursor,total:o.total},status:"success",unread:o.unread}}async getNotification(t){return this.httpClient.get(`/notifications/${t}`)}async markAsRead(t){return await this.convexClient.mutation(n.notifications.markAsRead,{id:t})}async markAsUnread(t){return this.httpClient.put(`/notifications/${t}/unread`,{})}async archive(t){return this.httpClient.put(`/notifications/${t}/archive`,{})}async unarchive(t){return this.httpClient.put(`/notifications/${t}/unarchive`,{})}on(t){this.#t.push(t)}off(t){this.#t=this.#t.filter(i=>i===t)}};var c=class{#t;#i;#n;constructor(t){this.#t=new f({...t,baseUrl:t.baseUrl||r}),this.#i=new l(t.socketUrl||a),this.#n=new e(this.#t,this.#i,{applicationId:t.applicationId,subscriberId:t.subscriberId})}get notification(){return this.#n}};export{c as TeknifyClient};
|
package/dist/esm/client/index.js
CHANGED
@@ -1,10 +1 @@
|
|
1
|
-
import "
|
2
|
-
import {
|
3
|
-
TeknifyClient
|
4
|
-
} from "../chunk-QMITKG5M.js";
|
5
|
-
import "../chunk-FC6XFVCA.js";
|
6
|
-
import "../chunk-J52CIUB2.js";
|
7
|
-
export {
|
8
|
-
TeknifyClient
|
9
|
-
};
|
10
|
-
//# sourceMappingURL=index.js.map
|
1
|
+
import{HttpClient as u}from"@tnf-dev/core";import{ConvexClient as l}from"convex/browser";var r="https://tekify.teknix.services",a="https://convex-be.teknix.services";import{anyApi as n}from"convex/server";var e=class{constructor(t,i,o){this.httpClient=t;this.convexClient=i;this.options=o;this.convexClient.onUpdate(n.notifications.listenToNotificationsCount,{subscriberId:this.options.subscriberId},({latest:s})=>{s&&this.#t.forEach(f=>f([s]))})}#t=[];async getNotifications(t){let[i,{counts:o}]=await Promise.all([this.convexClient.query(n.notifications.get,{numItems:t.numItems,cursor:t.cursor,filter:{subscriberId:this.options.subscriberId,appId:this.options.applicationId}}),this.convexClient.query(n.notifications.listenToNotificationsCount,{subscriberId:this.options.subscriberId})]);return{data:i.page,pagination:{continueCursor:i.isDone?null:i.continueCursor,total:o.total},status:"success",unread:o.unread}}async getNotification(t){return this.httpClient.get(`/notifications/${t}`)}async markAsRead(t){return await this.convexClient.mutation(n.notifications.markAsRead,{id:t})}async markAsUnread(t){return this.httpClient.put(`/notifications/${t}/unread`,{})}async archive(t){return this.httpClient.put(`/notifications/${t}/archive`,{})}async unarchive(t){return this.httpClient.put(`/notifications/${t}/unarchive`,{})}on(t){this.#t.push(t)}off(t){this.#t=this.#t.filter(i=>i===t)}};var c=class{#t;#i;#n;constructor(t){this.#t=new u({...t,baseUrl:t.baseUrl||r}),this.#i=new l(t.socketUrl||a),this.#n=new e(this.#t,this.#i,{applicationId:t.applicationId,subscriberId:t.subscriberId})}get notification(){return this.#n}};export{c as TeknifyClient};
|
@@ -1,7 +1 @@
|
|
1
|
-
import {
|
2
|
-
NotificationClient
|
3
|
-
} from "../chunk-FC6XFVCA.js";
|
4
|
-
export {
|
5
|
-
NotificationClient
|
6
|
-
};
|
7
|
-
//# sourceMappingURL=notification.js.map
|
1
|
+
import{anyApi as n}from"convex/server";var s=class{constructor(i,t,o){this.httpClient=i;this.convexClient=t;this.options=o;this.convexClient.onUpdate(n.notifications.listenToNotificationsCount,{subscriberId:this.options.subscriberId},({latest:e})=>{e&&this.#i.forEach(a=>a([e]))})}#i=[];async getNotifications(i){let[t,{counts:o}]=await Promise.all([this.convexClient.query(n.notifications.get,{numItems:i.numItems,cursor:i.cursor,filter:{subscriberId:this.options.subscriberId,appId:this.options.applicationId}}),this.convexClient.query(n.notifications.listenToNotificationsCount,{subscriberId:this.options.subscriberId})]);return{data:t.page,pagination:{continueCursor:t.isDone?null:t.continueCursor,total:o.total},status:"success",unread:o.unread}}async getNotification(i){return this.httpClient.get(`/notifications/${i}`)}async markAsRead(i){return await this.convexClient.mutation(n.notifications.markAsRead,{id:i})}async markAsUnread(i){return this.httpClient.put(`/notifications/${i}/unread`,{})}async archive(i){return this.httpClient.put(`/notifications/${i}/archive`,{})}async unarchive(i){return this.httpClient.put(`/notifications/${i}/unarchive`,{})}on(i){this.#i.push(i)}off(i){this.#i=this.#i.filter(t=>t===i)}};export{s as NotificationClient};
|
package/dist/esm/index.js
CHANGED
@@ -1,10 +1 @@
|
|
1
|
-
import "
|
2
|
-
import {
|
3
|
-
TeknifyClient
|
4
|
-
} from "./chunk-QMITKG5M.js";
|
5
|
-
import "./chunk-FC6XFVCA.js";
|
6
|
-
import "./chunk-J52CIUB2.js";
|
7
|
-
export {
|
8
|
-
TeknifyClient
|
9
|
-
};
|
10
|
-
//# sourceMappingURL=index.js.map
|
1
|
+
import{HttpClient as u}from"@tnf-dev/core";import{ConvexClient as l}from"convex/browser";var r="https://tekify.teknix.services",a="https://convex-be.teknix.services";import{anyApi as n}from"convex/server";var e=class{constructor(t,i,o){this.httpClient=t;this.convexClient=i;this.options=o;this.convexClient.onUpdate(n.notifications.listenToNotificationsCount,{subscriberId:this.options.subscriberId},({latest:s})=>{s&&this.#t.forEach(f=>f([s]))})}#t=[];async getNotifications(t){let[i,{counts:o}]=await Promise.all([this.convexClient.query(n.notifications.get,{numItems:t.numItems,cursor:t.cursor,filter:{subscriberId:this.options.subscriberId,appId:this.options.applicationId}}),this.convexClient.query(n.notifications.listenToNotificationsCount,{subscriberId:this.options.subscriberId})]);return{data:i.page,pagination:{continueCursor:i.isDone?null:i.continueCursor,total:o.total},status:"success",unread:o.unread}}async getNotification(t){return this.httpClient.get(`/notifications/${t}`)}async markAsRead(t){return await this.convexClient.mutation(n.notifications.markAsRead,{id:t})}async markAsUnread(t){return this.httpClient.put(`/notifications/${t}/unread`,{})}async archive(t){return this.httpClient.put(`/notifications/${t}/archive`,{})}async unarchive(t){return this.httpClient.put(`/notifications/${t}/unarchive`,{})}on(t){this.#t.push(t)}off(t){this.#t=this.#t.filter(i=>i===t)}};var c=class{#t;#i;#n;constructor(t){this.#t=new u({...t,baseUrl:t.baseUrl||r}),this.#i=new l(t.socketUrl||a),this.#n=new e(this.#t,this.#i,{applicationId:t.applicationId,subscriberId:t.subscriberId})}get notification(){return this.#n}};export{c as TeknifyClient};
|
package/dist/esm/utils/const.js
CHANGED
@@ -1,9 +1 @@
|
|
1
|
-
|
2
|
-
DEFAULT_BASE_URL,
|
3
|
-
DEFAULT_SOCKET_URL
|
4
|
-
} from "../chunk-J52CIUB2.js";
|
5
|
-
export {
|
6
|
-
DEFAULT_BASE_URL,
|
7
|
-
DEFAULT_SOCKET_URL
|
8
|
-
};
|
9
|
-
//# sourceMappingURL=const.js.map
|
1
|
+
var e="https://tekify.teknix.services",t="https://convex-be.teknix.services";export{e as DEFAULT_BASE_URL,t as DEFAULT_SOCKET_URL};
|
package/dist/esm/utils/index.js
CHANGED
@@ -1,9 +1 @@
|
|
1
|
-
|
2
|
-
DEFAULT_BASE_URL,
|
3
|
-
DEFAULT_SOCKET_URL
|
4
|
-
} from "../chunk-J52CIUB2.js";
|
5
|
-
export {
|
6
|
-
DEFAULT_BASE_URL,
|
7
|
-
DEFAULT_SOCKET_URL
|
8
|
-
};
|
9
|
-
//# sourceMappingURL=index.js.map
|
1
|
+
var e="https://tekify.teknix.services",t="https://convex-be.teknix.services";export{e as DEFAULT_BASE_URL,t as DEFAULT_SOCKET_URL};
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"browser": "./dist/esm/index.js",
|
3
3
|
"dependencies": {
|
4
|
-
"@tnf-dev/core": "1.0.1-
|
4
|
+
"@tnf-dev/core": "1.0.1-8",
|
5
5
|
"convex": "^1.24.8"
|
6
6
|
},
|
7
7
|
"devDependencies": {
|
@@ -49,5 +49,5 @@
|
|
49
49
|
"sideEffects": false,
|
50
50
|
"type": "module",
|
51
51
|
"types": "./dist/esm/index.d.ts",
|
52
|
-
"version": "1.0.1-
|
52
|
+
"version": "1.0.1-8"
|
53
53
|
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/client/client.ts","../../../src/utils/const.ts","../../../src/client/notification.ts"],"sourcesContent":["import { HttpClient, HttpClientOptions } from '@tnf-dev/core';\nimport { ConvexClient } from 'convex/browser';\nimport { DEFAULT_BASE_URL, DEFAULT_SOCKET_URL } from '../utils/const';\nimport { NotificationClient } from './notification';\n\nexport interface TeknifyClientOptions extends Omit<HttpClientOptions, 'baseUrl'> {\n baseUrl?: string;\n socketUrl?: string;\n applicationId: string;\n subscriberId: string;\n}\n\nexport class TeknifyClient {\n #httpClient: HttpClient;\n #convexClient: ConvexClient;\n\n #notification: NotificationClient;\n\n constructor(options: TeknifyClientOptions) {\n this.#httpClient = new HttpClient({\n ...options,\n baseUrl: options.baseUrl || DEFAULT_BASE_URL,\n });\n this.#convexClient = new ConvexClient(options.socketUrl || DEFAULT_SOCKET_URL);\n\n this.#notification = new NotificationClient(this.#httpClient, this.#convexClient, {\n applicationId: options.applicationId,\n subscriberId: options.subscriberId,\n });\n }\n\n public get notification() {\n return this.#notification;\n }\n}\n","export const DEFAULT_BASE_URL = 'https://tekify.teknix.services';\nexport const DEFAULT_SOCKET_URL = 'https://convex-be.teknix.services';\n","import { BaseResponse, HttpClient, Notification, PaginatedResponse, PaginationRequest } from '@tnf-dev/core';\nimport { ConvexClient } from 'convex/browser';\nimport { anyApi } from 'convex/server';\n\nexport interface GetNotificationParams extends PaginationRequest {}\n\nexport interface GetNotificationsResponse extends PaginatedResponse<Notification> {\n unread: number;\n}\n\nexport interface NotificationClientOptions {\n subscriberId: string;\n applicationId: string;\n}\n\nexport class NotificationClient {\n #handlers: Array<Function> = [];\n\n constructor(\n private httpClient: HttpClient,\n private convexClient: ConvexClient,\n private options: NotificationClientOptions,\n ) {\n this.convexClient.onUpdate(\n anyApi.notifications.listenToNotificationsCount,\n {\n subscriberId: this.options.subscriberId,\n },\n ({ latest }) => {\n if (!latest) return;\n this.#handlers.forEach((handler) => handler([latest]));\n },\n );\n }\n\n async getNotifications(params: GetNotificationParams): Promise<GetNotificationsResponse> {\n const [res, { counts }] = await Promise.all([\n this.convexClient.query(anyApi.notifications.get, {\n numItems: params.numItems,\n cursor: params.cursor,\n filter: {\n subscriberId: this.options.subscriberId,\n appId: this.options.applicationId,\n },\n }),\n\n this.convexClient.query(anyApi.notifications.listenToNotificationsCount, {\n subscriberId: this.options.subscriberId,\n }),\n ]);\n\n return {\n data: res.page,\n pagination: {\n continueCursor: res.isDone ? null : res.continueCursor,\n total: counts.total,\n },\n status: 'success',\n unread: counts.unread,\n };\n }\n\n async getNotification(notificationId: string): Promise<BaseResponse<Notification>> {\n return this.httpClient.get(`/notifications/${notificationId}`);\n }\n\n async markAsRead(notificationId: string): Promise<BaseResponse<Notification>> {\n return await this.convexClient.mutation(anyApi.notifications.markAsRead, {\n id: notificationId,\n });\n }\n\n async markAsUnread(notificationId: string): Promise<BaseResponse<Notification>> {\n return this.httpClient.put(`/notifications/${notificationId}/unread`, {});\n }\n\n async archive(notificationId: string): Promise<BaseResponse<Notification>> {\n return this.httpClient.put(`/notifications/${notificationId}/archive`, {});\n }\n\n async unarchive(notificationId: string): Promise<BaseResponse<Notification>> {\n return this.httpClient.put(`/notifications/${notificationId}/unarchive`, {});\n }\n\n on(handler: (notifications: Notification[]) => void) {\n this.#handlers.push(handler);\n }\n\n off(handler: (notifications: Notification[]) => void) {\n this.#handlers = this.#handlers.filter((h) => h === handler);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA8C;AAC9C,qBAA6B;;;ACDtB,IAAM,mBAAmB;AACzB,IAAM,qBAAqB;;;ACClC,oBAAuB;AAFvB;AAeO,IAAM,qBAAN,MAAyB;AAAA,EAG9B,YACU,YACA,cACA,SACR;AAHQ;AACA;AACA;AALV,kCAA6B,CAAC;AAO5B,SAAK,aAAa;AAAA,MAChB,qBAAO,cAAc;AAAA,MACrB;AAAA,QACE,cAAc,KAAK,QAAQ;AAAA,MAC7B;AAAA,MACA,CAAC,EAAE,OAAO,MAAM;AACd,YAAI,CAAC,OAAQ;AACb,2BAAK,WAAU,QAAQ,CAAC,YAAY,QAAQ,CAAC,MAAM,CAAC,CAAC;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,iBAAiB,QAAkE;AACvF,UAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,MAAM,QAAQ,IAAI;AAAA,MAC1C,KAAK,aAAa,MAAM,qBAAO,cAAc,KAAK;AAAA,QAChD,UAAU,OAAO;AAAA,QACjB,QAAQ,OAAO;AAAA,QACf,QAAQ;AAAA,UACN,cAAc,KAAK,QAAQ;AAAA,UAC3B,OAAO,KAAK,QAAQ;AAAA,QACtB;AAAA,MACF,CAAC;AAAA,MAED,KAAK,aAAa,MAAM,qBAAO,cAAc,4BAA4B;AAAA,QACvE,cAAc,KAAK,QAAQ;AAAA,MAC7B,CAAC;AAAA,IACH,CAAC;AAED,WAAO;AAAA,MACL,MAAM,IAAI;AAAA,MACV,YAAY;AAAA,QACV,gBAAgB,IAAI,SAAS,OAAO,IAAI;AAAA,QACxC,OAAO,OAAO;AAAA,MAChB;AAAA,MACA,QAAQ;AAAA,MACR,QAAQ,OAAO;AAAA,IACjB;AAAA,EACF;AAAA,EAEA,MAAM,gBAAgB,gBAA6D;AACjF,WAAO,KAAK,WAAW,IAAI,kBAAkB,cAAc,EAAE;AAAA,EAC/D;AAAA,EAEA,MAAM,WAAW,gBAA6D;AAC5E,WAAO,MAAM,KAAK,aAAa,SAAS,qBAAO,cAAc,YAAY;AAAA,MACvE,IAAI;AAAA,IACN,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,aAAa,gBAA6D;AAC9E,WAAO,KAAK,WAAW,IAAI,kBAAkB,cAAc,WAAW,CAAC,CAAC;AAAA,EAC1E;AAAA,EAEA,MAAM,QAAQ,gBAA6D;AACzE,WAAO,KAAK,WAAW,IAAI,kBAAkB,cAAc,YAAY,CAAC,CAAC;AAAA,EAC3E;AAAA,EAEA,MAAM,UAAU,gBAA6D;AAC3E,WAAO,KAAK,WAAW,IAAI,kBAAkB,cAAc,cAAc,CAAC,CAAC;AAAA,EAC7E;AAAA,EAEA,GAAG,SAAkD;AACnD,uBAAK,WAAU,KAAK,OAAO;AAAA,EAC7B;AAAA,EAEA,IAAI,SAAkD;AACpD,uBAAK,WAAY,mBAAK,WAAU,OAAO,CAAC,MAAM,MAAM,OAAO;AAAA,EAC7D;AACF;AA3EE;;;AFhBF;AAYO,IAAM,gBAAN,MAAoB;AAAA,EAMzB,YAAY,SAA+B;AAL3C;AACA;AAEA;AAGE,uBAAK,aAAc,IAAI,uBAAW;AAAA,MAChC,GAAG;AAAA,MACH,SAAS,QAAQ,WAAW;AAAA,IAC9B,CAAC;AACD,uBAAK,eAAgB,IAAI,4BAAa,QAAQ,aAAa,kBAAkB;AAE7E,uBAAK,eAAgB,IAAI,mBAAmB,mBAAK,cAAa,mBAAK,gBAAe;AAAA,MAChF,eAAe,QAAQ;AAAA,MACvB,cAAc,QAAQ;AAAA,IACxB,CAAC;AAAA,EACH;AAAA,EAEA,IAAW,eAAe;AACxB,WAAO,mBAAK;AAAA,EACd;AACF;AArBE;AACA;AAEA;","names":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/client/convex.ts"],"sourcesContent":["export { ConvexClient } from 'convex/browser';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA6B;","names":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/client/index.ts","../../../src/client/client.ts","../../../src/utils/const.ts","../../../src/client/notification.ts"],"sourcesContent":["export * from './client';\n","import { HttpClient, HttpClientOptions } from '@tnf-dev/core';\nimport { ConvexClient } from 'convex/browser';\nimport { DEFAULT_BASE_URL, DEFAULT_SOCKET_URL } from '../utils/const';\nimport { NotificationClient } from './notification';\n\nexport interface TeknifyClientOptions extends Omit<HttpClientOptions, 'baseUrl'> {\n baseUrl?: string;\n socketUrl?: string;\n applicationId: string;\n subscriberId: string;\n}\n\nexport class TeknifyClient {\n #httpClient: HttpClient;\n #convexClient: ConvexClient;\n\n #notification: NotificationClient;\n\n constructor(options: TeknifyClientOptions) {\n this.#httpClient = new HttpClient({\n ...options,\n baseUrl: options.baseUrl || DEFAULT_BASE_URL,\n });\n this.#convexClient = new ConvexClient(options.socketUrl || DEFAULT_SOCKET_URL);\n\n this.#notification = new NotificationClient(this.#httpClient, this.#convexClient, {\n applicationId: options.applicationId,\n subscriberId: options.subscriberId,\n });\n }\n\n public get notification() {\n return this.#notification;\n }\n}\n","export const DEFAULT_BASE_URL = 'https://tekify.teknix.services';\nexport const DEFAULT_SOCKET_URL = 'https://convex-be.teknix.services';\n","import { BaseResponse, HttpClient, Notification, PaginatedResponse, PaginationRequest } from '@tnf-dev/core';\nimport { ConvexClient } from 'convex/browser';\nimport { anyApi } from 'convex/server';\n\nexport interface GetNotificationParams extends PaginationRequest {}\n\nexport interface GetNotificationsResponse extends PaginatedResponse<Notification> {\n unread: number;\n}\n\nexport interface NotificationClientOptions {\n subscriberId: string;\n applicationId: string;\n}\n\nexport class NotificationClient {\n #handlers: Array<Function> = [];\n\n constructor(\n private httpClient: HttpClient,\n private convexClient: ConvexClient,\n private options: NotificationClientOptions,\n ) {\n this.convexClient.onUpdate(\n anyApi.notifications.listenToNotificationsCount,\n {\n subscriberId: this.options.subscriberId,\n },\n ({ latest }) => {\n if (!latest) return;\n this.#handlers.forEach((handler) => handler([latest]));\n },\n );\n }\n\n async getNotifications(params: GetNotificationParams): Promise<GetNotificationsResponse> {\n const [res, { counts }] = await Promise.all([\n this.convexClient.query(anyApi.notifications.get, {\n numItems: params.numItems,\n cursor: params.cursor,\n filter: {\n subscriberId: this.options.subscriberId,\n appId: this.options.applicationId,\n },\n }),\n\n this.convexClient.query(anyApi.notifications.listenToNotificationsCount, {\n subscriberId: this.options.subscriberId,\n }),\n ]);\n\n return {\n data: res.page,\n pagination: {\n continueCursor: res.isDone ? null : res.continueCursor,\n total: counts.total,\n },\n status: 'success',\n unread: counts.unread,\n };\n }\n\n async getNotification(notificationId: string): Promise<BaseResponse<Notification>> {\n return this.httpClient.get(`/notifications/${notificationId}`);\n }\n\n async markAsRead(notificationId: string): Promise<BaseResponse<Notification>> {\n return await this.convexClient.mutation(anyApi.notifications.markAsRead, {\n id: notificationId,\n });\n }\n\n async markAsUnread(notificationId: string): Promise<BaseResponse<Notification>> {\n return this.httpClient.put(`/notifications/${notificationId}/unread`, {});\n }\n\n async archive(notificationId: string): Promise<BaseResponse<Notification>> {\n return this.httpClient.put(`/notifications/${notificationId}/archive`, {});\n }\n\n async unarchive(notificationId: string): Promise<BaseResponse<Notification>> {\n return this.httpClient.put(`/notifications/${notificationId}/unarchive`, {});\n }\n\n on(handler: (notifications: Notification[]) => void) {\n this.#handlers.push(handler);\n }\n\n off(handler: (notifications: Notification[]) => void) {\n this.#handlers = this.#handlers.filter((h) => h === handler);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAA8C;AAC9C,qBAA6B;;;ACDtB,IAAM,mBAAmB;AACzB,IAAM,qBAAqB;;;ACClC,oBAAuB;AAFvB;AAeO,IAAM,qBAAN,MAAyB;AAAA,EAG9B,YACU,YACA,cACA,SACR;AAHQ;AACA;AACA;AALV,kCAA6B,CAAC;AAO5B,SAAK,aAAa;AAAA,MAChB,qBAAO,cAAc;AAAA,MACrB;AAAA,QACE,cAAc,KAAK,QAAQ;AAAA,MAC7B;AAAA,MACA,CAAC,EAAE,OAAO,MAAM;AACd,YAAI,CAAC,OAAQ;AACb,2BAAK,WAAU,QAAQ,CAAC,YAAY,QAAQ,CAAC,MAAM,CAAC,CAAC;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,iBAAiB,QAAkE;AACvF,UAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,MAAM,QAAQ,IAAI;AAAA,MAC1C,KAAK,aAAa,MAAM,qBAAO,cAAc,KAAK;AAAA,QAChD,UAAU,OAAO;AAAA,QACjB,QAAQ,OAAO;AAAA,QACf,QAAQ;AAAA,UACN,cAAc,KAAK,QAAQ;AAAA,UAC3B,OAAO,KAAK,QAAQ;AAAA,QACtB;AAAA,MACF,CAAC;AAAA,MAED,KAAK,aAAa,MAAM,qBAAO,cAAc,4BAA4B;AAAA,QACvE,cAAc,KAAK,QAAQ;AAAA,MAC7B,CAAC;AAAA,IACH,CAAC;AAED,WAAO;AAAA,MACL,MAAM,IAAI;AAAA,MACV,YAAY;AAAA,QACV,gBAAgB,IAAI,SAAS,OAAO,IAAI;AAAA,QACxC,OAAO,OAAO;AAAA,MAChB;AAAA,MACA,QAAQ;AAAA,MACR,QAAQ,OAAO;AAAA,IACjB;AAAA,EACF;AAAA,EAEA,MAAM,gBAAgB,gBAA6D;AACjF,WAAO,KAAK,WAAW,IAAI,kBAAkB,cAAc,EAAE;AAAA,EAC/D;AAAA,EAEA,MAAM,WAAW,gBAA6D;AAC5E,WAAO,MAAM,KAAK,aAAa,SAAS,qBAAO,cAAc,YAAY;AAAA,MACvE,IAAI;AAAA,IACN,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,aAAa,gBAA6D;AAC9E,WAAO,KAAK,WAAW,IAAI,kBAAkB,cAAc,WAAW,CAAC,CAAC;AAAA,EAC1E;AAAA,EAEA,MAAM,QAAQ,gBAA6D;AACzE,WAAO,KAAK,WAAW,IAAI,kBAAkB,cAAc,YAAY,CAAC,CAAC;AAAA,EAC3E;AAAA,EAEA,MAAM,UAAU,gBAA6D;AAC3E,WAAO,KAAK,WAAW,IAAI,kBAAkB,cAAc,cAAc,CAAC,CAAC;AAAA,EAC7E;AAAA,EAEA,GAAG,SAAkD;AACnD,uBAAK,WAAU,KAAK,OAAO;AAAA,EAC7B;AAAA,EAEA,IAAI,SAAkD;AACpD,uBAAK,WAAY,mBAAK,WAAU,OAAO,CAAC,MAAM,MAAM,OAAO;AAAA,EAC7D;AACF;AA3EE;;;AFhBF;AAYO,IAAM,gBAAN,MAAoB;AAAA,EAMzB,YAAY,SAA+B;AAL3C;AACA;AAEA;AAGE,uBAAK,aAAc,IAAI,uBAAW;AAAA,MAChC,GAAG;AAAA,MACH,SAAS,QAAQ,WAAW;AAAA,IAC9B,CAAC;AACD,uBAAK,eAAgB,IAAI,4BAAa,QAAQ,aAAa,kBAAkB;AAE7E,uBAAK,eAAgB,IAAI,mBAAmB,mBAAK,cAAa,mBAAK,gBAAe;AAAA,MAChF,eAAe,QAAQ;AAAA,MACvB,cAAc,QAAQ;AAAA,IACxB,CAAC;AAAA,EACH;AAAA,EAEA,IAAW,eAAe;AACxB,WAAO,mBAAK;AAAA,EACd;AACF;AArBE;AACA;AAEA;","names":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/client/notification.ts"],"sourcesContent":["import { BaseResponse, HttpClient, Notification, PaginatedResponse, PaginationRequest } from '@tnf-dev/core';\nimport { ConvexClient } from 'convex/browser';\nimport { anyApi } from 'convex/server';\n\nexport interface GetNotificationParams extends PaginationRequest {}\n\nexport interface GetNotificationsResponse extends PaginatedResponse<Notification> {\n unread: number;\n}\n\nexport interface NotificationClientOptions {\n subscriberId: string;\n applicationId: string;\n}\n\nexport class NotificationClient {\n #handlers: Array<Function> = [];\n\n constructor(\n private httpClient: HttpClient,\n private convexClient: ConvexClient,\n private options: NotificationClientOptions,\n ) {\n this.convexClient.onUpdate(\n anyApi.notifications.listenToNotificationsCount,\n {\n subscriberId: this.options.subscriberId,\n },\n ({ latest }) => {\n if (!latest) return;\n this.#handlers.forEach((handler) => handler([latest]));\n },\n );\n }\n\n async getNotifications(params: GetNotificationParams): Promise<GetNotificationsResponse> {\n const [res, { counts }] = await Promise.all([\n this.convexClient.query(anyApi.notifications.get, {\n numItems: params.numItems,\n cursor: params.cursor,\n filter: {\n subscriberId: this.options.subscriberId,\n appId: this.options.applicationId,\n },\n }),\n\n this.convexClient.query(anyApi.notifications.listenToNotificationsCount, {\n subscriberId: this.options.subscriberId,\n }),\n ]);\n\n return {\n data: res.page,\n pagination: {\n continueCursor: res.isDone ? null : res.continueCursor,\n total: counts.total,\n },\n status: 'success',\n unread: counts.unread,\n };\n }\n\n async getNotification(notificationId: string): Promise<BaseResponse<Notification>> {\n return this.httpClient.get(`/notifications/${notificationId}`);\n }\n\n async markAsRead(notificationId: string): Promise<BaseResponse<Notification>> {\n return await this.convexClient.mutation(anyApi.notifications.markAsRead, {\n id: notificationId,\n });\n }\n\n async markAsUnread(notificationId: string): Promise<BaseResponse<Notification>> {\n return this.httpClient.put(`/notifications/${notificationId}/unread`, {});\n }\n\n async archive(notificationId: string): Promise<BaseResponse<Notification>> {\n return this.httpClient.put(`/notifications/${notificationId}/archive`, {});\n }\n\n async unarchive(notificationId: string): Promise<BaseResponse<Notification>> {\n return this.httpClient.put(`/notifications/${notificationId}/unarchive`, {});\n }\n\n on(handler: (notifications: Notification[]) => void) {\n this.#handlers.push(handler);\n }\n\n off(handler: (notifications: Notification[]) => void) {\n this.#handlers = this.#handlers.filter((h) => h === handler);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAuB;AAFvB;AAeO,IAAM,qBAAN,MAAyB;AAAA,EAG9B,YACU,YACA,cACA,SACR;AAHQ;AACA;AACA;AALV,kCAA6B,CAAC;AAO5B,SAAK,aAAa;AAAA,MAChB,qBAAO,cAAc;AAAA,MACrB;AAAA,QACE,cAAc,KAAK,QAAQ;AAAA,MAC7B;AAAA,MACA,CAAC,EAAE,OAAO,MAAM;AACd,YAAI,CAAC,OAAQ;AACb,2BAAK,WAAU,QAAQ,CAAC,YAAY,QAAQ,CAAC,MAAM,CAAC,CAAC;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,iBAAiB,QAAkE;AACvF,UAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,MAAM,QAAQ,IAAI;AAAA,MAC1C,KAAK,aAAa,MAAM,qBAAO,cAAc,KAAK;AAAA,QAChD,UAAU,OAAO;AAAA,QACjB,QAAQ,OAAO;AAAA,QACf,QAAQ;AAAA,UACN,cAAc,KAAK,QAAQ;AAAA,UAC3B,OAAO,KAAK,QAAQ;AAAA,QACtB;AAAA,MACF,CAAC;AAAA,MAED,KAAK,aAAa,MAAM,qBAAO,cAAc,4BAA4B;AAAA,QACvE,cAAc,KAAK,QAAQ;AAAA,MAC7B,CAAC;AAAA,IACH,CAAC;AAED,WAAO;AAAA,MACL,MAAM,IAAI;AAAA,MACV,YAAY;AAAA,QACV,gBAAgB,IAAI,SAAS,OAAO,IAAI;AAAA,QACxC,OAAO,OAAO;AAAA,MAChB;AAAA,MACA,QAAQ;AAAA,MACR,QAAQ,OAAO;AAAA,IACjB;AAAA,EACF;AAAA,EAEA,MAAM,gBAAgB,gBAA6D;AACjF,WAAO,KAAK,WAAW,IAAI,kBAAkB,cAAc,EAAE;AAAA,EAC/D;AAAA,EAEA,MAAM,WAAW,gBAA6D;AAC5E,WAAO,MAAM,KAAK,aAAa,SAAS,qBAAO,cAAc,YAAY;AAAA,MACvE,IAAI;AAAA,IACN,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,aAAa,gBAA6D;AAC9E,WAAO,KAAK,WAAW,IAAI,kBAAkB,cAAc,WAAW,CAAC,CAAC;AAAA,EAC1E;AAAA,EAEA,MAAM,QAAQ,gBAA6D;AACzE,WAAO,KAAK,WAAW,IAAI,kBAAkB,cAAc,YAAY,CAAC,CAAC;AAAA,EAC3E;AAAA,EAEA,MAAM,UAAU,gBAA6D;AAC3E,WAAO,KAAK,WAAW,IAAI,kBAAkB,cAAc,cAAc,CAAC,CAAC;AAAA,EAC7E;AAAA,EAEA,GAAG,SAAkD;AACnD,uBAAK,WAAU,KAAK,OAAO;AAAA,EAC7B;AAAA,EAEA,IAAI,SAAkD;AACpD,uBAAK,WAAY,mBAAK,WAAU,OAAO,CAAC,MAAM,MAAM,OAAO;AAAA,EAC7D;AACF;AA3EE;","names":[]}
|
package/dist/cjs/index.cjs.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/client/client.ts","../../src/utils/const.ts","../../src/client/notification.ts"],"sourcesContent":["export * from './client';\n","import { HttpClient, HttpClientOptions } from '@tnf-dev/core';\nimport { ConvexClient } from 'convex/browser';\nimport { DEFAULT_BASE_URL, DEFAULT_SOCKET_URL } from '../utils/const';\nimport { NotificationClient } from './notification';\n\nexport interface TeknifyClientOptions extends Omit<HttpClientOptions, 'baseUrl'> {\n baseUrl?: string;\n socketUrl?: string;\n applicationId: string;\n subscriberId: string;\n}\n\nexport class TeknifyClient {\n #httpClient: HttpClient;\n #convexClient: ConvexClient;\n\n #notification: NotificationClient;\n\n constructor(options: TeknifyClientOptions) {\n this.#httpClient = new HttpClient({\n ...options,\n baseUrl: options.baseUrl || DEFAULT_BASE_URL,\n });\n this.#convexClient = new ConvexClient(options.socketUrl || DEFAULT_SOCKET_URL);\n\n this.#notification = new NotificationClient(this.#httpClient, this.#convexClient, {\n applicationId: options.applicationId,\n subscriberId: options.subscriberId,\n });\n }\n\n public get notification() {\n return this.#notification;\n }\n}\n","export const DEFAULT_BASE_URL = 'https://tekify.teknix.services';\nexport const DEFAULT_SOCKET_URL = 'https://convex-be.teknix.services';\n","import { BaseResponse, HttpClient, Notification, PaginatedResponse, PaginationRequest } from '@tnf-dev/core';\nimport { ConvexClient } from 'convex/browser';\nimport { anyApi } from 'convex/server';\n\nexport interface GetNotificationParams extends PaginationRequest {}\n\nexport interface GetNotificationsResponse extends PaginatedResponse<Notification> {\n unread: number;\n}\n\nexport interface NotificationClientOptions {\n subscriberId: string;\n applicationId: string;\n}\n\nexport class NotificationClient {\n #handlers: Array<Function> = [];\n\n constructor(\n private httpClient: HttpClient,\n private convexClient: ConvexClient,\n private options: NotificationClientOptions,\n ) {\n this.convexClient.onUpdate(\n anyApi.notifications.listenToNotificationsCount,\n {\n subscriberId: this.options.subscriberId,\n },\n ({ latest }) => {\n if (!latest) return;\n this.#handlers.forEach((handler) => handler([latest]));\n },\n );\n }\n\n async getNotifications(params: GetNotificationParams): Promise<GetNotificationsResponse> {\n const [res, { counts }] = await Promise.all([\n this.convexClient.query(anyApi.notifications.get, {\n numItems: params.numItems,\n cursor: params.cursor,\n filter: {\n subscriberId: this.options.subscriberId,\n appId: this.options.applicationId,\n },\n }),\n\n this.convexClient.query(anyApi.notifications.listenToNotificationsCount, {\n subscriberId: this.options.subscriberId,\n }),\n ]);\n\n return {\n data: res.page,\n pagination: {\n continueCursor: res.isDone ? null : res.continueCursor,\n total: counts.total,\n },\n status: 'success',\n unread: counts.unread,\n };\n }\n\n async getNotification(notificationId: string): Promise<BaseResponse<Notification>> {\n return this.httpClient.get(`/notifications/${notificationId}`);\n }\n\n async markAsRead(notificationId: string): Promise<BaseResponse<Notification>> {\n return await this.convexClient.mutation(anyApi.notifications.markAsRead, {\n id: notificationId,\n });\n }\n\n async markAsUnread(notificationId: string): Promise<BaseResponse<Notification>> {\n return this.httpClient.put(`/notifications/${notificationId}/unread`, {});\n }\n\n async archive(notificationId: string): Promise<BaseResponse<Notification>> {\n return this.httpClient.put(`/notifications/${notificationId}/archive`, {});\n }\n\n async unarchive(notificationId: string): Promise<BaseResponse<Notification>> {\n return this.httpClient.put(`/notifications/${notificationId}/unarchive`, {});\n }\n\n on(handler: (notifications: Notification[]) => void) {\n this.#handlers.push(handler);\n }\n\n off(handler: (notifications: Notification[]) => void) {\n this.#handlers = this.#handlers.filter((h) => h === handler);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAA8C;AAC9C,qBAA6B;;;ACDtB,IAAM,mBAAmB;AACzB,IAAM,qBAAqB;;;ACClC,oBAAuB;AAFvB;AAeO,IAAM,qBAAN,MAAyB;AAAA,EAG9B,YACU,YACA,cACA,SACR;AAHQ;AACA;AACA;AALV,kCAA6B,CAAC;AAO5B,SAAK,aAAa;AAAA,MAChB,qBAAO,cAAc;AAAA,MACrB;AAAA,QACE,cAAc,KAAK,QAAQ;AAAA,MAC7B;AAAA,MACA,CAAC,EAAE,OAAO,MAAM;AACd,YAAI,CAAC,OAAQ;AACb,2BAAK,WAAU,QAAQ,CAAC,YAAY,QAAQ,CAAC,MAAM,CAAC,CAAC;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,iBAAiB,QAAkE;AACvF,UAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,MAAM,QAAQ,IAAI;AAAA,MAC1C,KAAK,aAAa,MAAM,qBAAO,cAAc,KAAK;AAAA,QAChD,UAAU,OAAO;AAAA,QACjB,QAAQ,OAAO;AAAA,QACf,QAAQ;AAAA,UACN,cAAc,KAAK,QAAQ;AAAA,UAC3B,OAAO,KAAK,QAAQ;AAAA,QACtB;AAAA,MACF,CAAC;AAAA,MAED,KAAK,aAAa,MAAM,qBAAO,cAAc,4BAA4B;AAAA,QACvE,cAAc,KAAK,QAAQ;AAAA,MAC7B,CAAC;AAAA,IACH,CAAC;AAED,WAAO;AAAA,MACL,MAAM,IAAI;AAAA,MACV,YAAY;AAAA,QACV,gBAAgB,IAAI,SAAS,OAAO,IAAI;AAAA,QACxC,OAAO,OAAO;AAAA,MAChB;AAAA,MACA,QAAQ;AAAA,MACR,QAAQ,OAAO;AAAA,IACjB;AAAA,EACF;AAAA,EAEA,MAAM,gBAAgB,gBAA6D;AACjF,WAAO,KAAK,WAAW,IAAI,kBAAkB,cAAc,EAAE;AAAA,EAC/D;AAAA,EAEA,MAAM,WAAW,gBAA6D;AAC5E,WAAO,MAAM,KAAK,aAAa,SAAS,qBAAO,cAAc,YAAY;AAAA,MACvE,IAAI;AAAA,IACN,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,aAAa,gBAA6D;AAC9E,WAAO,KAAK,WAAW,IAAI,kBAAkB,cAAc,WAAW,CAAC,CAAC;AAAA,EAC1E;AAAA,EAEA,MAAM,QAAQ,gBAA6D;AACzE,WAAO,KAAK,WAAW,IAAI,kBAAkB,cAAc,YAAY,CAAC,CAAC;AAAA,EAC3E;AAAA,EAEA,MAAM,UAAU,gBAA6D;AAC3E,WAAO,KAAK,WAAW,IAAI,kBAAkB,cAAc,cAAc,CAAC,CAAC;AAAA,EAC7E;AAAA,EAEA,GAAG,SAAkD;AACnD,uBAAK,WAAU,KAAK,OAAO;AAAA,EAC7B;AAAA,EAEA,IAAI,SAAkD;AACpD,uBAAK,WAAY,mBAAK,WAAU,OAAO,CAAC,MAAM,MAAM,OAAO;AAAA,EAC7D;AACF;AA3EE;;;AFhBF;AAYO,IAAM,gBAAN,MAAoB;AAAA,EAMzB,YAAY,SAA+B;AAL3C;AACA;AAEA;AAGE,uBAAK,aAAc,IAAI,uBAAW;AAAA,MAChC,GAAG;AAAA,MACH,SAAS,QAAQ,WAAW;AAAA,IAC9B,CAAC;AACD,uBAAK,eAAgB,IAAI,4BAAa,QAAQ,aAAa,kBAAkB;AAE7E,uBAAK,eAAgB,IAAI,mBAAmB,mBAAK,cAAa,mBAAK,gBAAe;AAAA,MAChF,eAAe,QAAQ;AAAA,MACvB,cAAc,QAAQ;AAAA,IACxB,CAAC;AAAA,EACH;AAAA,EAEA,IAAW,eAAe;AACxB,WAAO,mBAAK;AAAA,EACd;AACF;AArBE;AACA;AAEA;","names":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/const.ts"],"sourcesContent":["export const DEFAULT_BASE_URL = 'https://tekify.teknix.services';\nexport const DEFAULT_SOCKET_URL = 'https://convex-be.teknix.services';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,mBAAmB;AACzB,IAAM,qBAAqB;","names":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/index.ts","../../../src/utils/const.ts"],"sourcesContent":["export * from './const';\n","export const DEFAULT_BASE_URL = 'https://tekify.teknix.services';\nexport const DEFAULT_SOCKET_URL = 'https://convex-be.teknix.services';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,mBAAmB;AACzB,IAAM,qBAAqB;","names":[]}
|
@@ -1,72 +0,0 @@
|
|
1
|
-
// src/client/notification.ts
|
2
|
-
import { anyApi } from "convex/server";
|
3
|
-
var NotificationClient = class {
|
4
|
-
constructor(httpClient, convexClient, options) {
|
5
|
-
this.httpClient = httpClient;
|
6
|
-
this.convexClient = convexClient;
|
7
|
-
this.options = options;
|
8
|
-
this.convexClient.onUpdate(
|
9
|
-
anyApi.notifications.listenToNotificationsCount,
|
10
|
-
{
|
11
|
-
subscriberId: this.options.subscriberId
|
12
|
-
},
|
13
|
-
({ latest }) => {
|
14
|
-
if (!latest) return;
|
15
|
-
this.#handlers.forEach((handler) => handler([latest]));
|
16
|
-
}
|
17
|
-
);
|
18
|
-
}
|
19
|
-
#handlers = [];
|
20
|
-
async getNotifications(params) {
|
21
|
-
const [res, { counts }] = await Promise.all([
|
22
|
-
this.convexClient.query(anyApi.notifications.get, {
|
23
|
-
numItems: params.numItems,
|
24
|
-
cursor: params.cursor,
|
25
|
-
filter: {
|
26
|
-
subscriberId: this.options.subscriberId,
|
27
|
-
appId: this.options.applicationId
|
28
|
-
}
|
29
|
-
}),
|
30
|
-
this.convexClient.query(anyApi.notifications.listenToNotificationsCount, {
|
31
|
-
subscriberId: this.options.subscriberId
|
32
|
-
})
|
33
|
-
]);
|
34
|
-
return {
|
35
|
-
data: res.page,
|
36
|
-
pagination: {
|
37
|
-
continueCursor: res.isDone ? null : res.continueCursor,
|
38
|
-
total: counts.total
|
39
|
-
},
|
40
|
-
status: "success",
|
41
|
-
unread: counts.unread
|
42
|
-
};
|
43
|
-
}
|
44
|
-
async getNotification(notificationId) {
|
45
|
-
return this.httpClient.get(`/notifications/${notificationId}`);
|
46
|
-
}
|
47
|
-
async markAsRead(notificationId) {
|
48
|
-
return await this.convexClient.mutation(anyApi.notifications.markAsRead, {
|
49
|
-
id: notificationId
|
50
|
-
});
|
51
|
-
}
|
52
|
-
async markAsUnread(notificationId) {
|
53
|
-
return this.httpClient.put(`/notifications/${notificationId}/unread`, {});
|
54
|
-
}
|
55
|
-
async archive(notificationId) {
|
56
|
-
return this.httpClient.put(`/notifications/${notificationId}/archive`, {});
|
57
|
-
}
|
58
|
-
async unarchive(notificationId) {
|
59
|
-
return this.httpClient.put(`/notifications/${notificationId}/unarchive`, {});
|
60
|
-
}
|
61
|
-
on(handler) {
|
62
|
-
this.#handlers.push(handler);
|
63
|
-
}
|
64
|
-
off(handler) {
|
65
|
-
this.#handlers = this.#handlers.filter((h) => h === handler);
|
66
|
-
}
|
67
|
-
};
|
68
|
-
|
69
|
-
export {
|
70
|
-
NotificationClient
|
71
|
-
};
|
72
|
-
//# sourceMappingURL=chunk-FC6XFVCA.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/client/notification.ts"],"sourcesContent":["import { BaseResponse, HttpClient, Notification, PaginatedResponse, PaginationRequest } from '@tnf-dev/core';\nimport { ConvexClient } from 'convex/browser';\nimport { anyApi } from 'convex/server';\n\nexport interface GetNotificationParams extends PaginationRequest {}\n\nexport interface GetNotificationsResponse extends PaginatedResponse<Notification> {\n unread: number;\n}\n\nexport interface NotificationClientOptions {\n subscriberId: string;\n applicationId: string;\n}\n\nexport class NotificationClient {\n #handlers: Array<Function> = [];\n\n constructor(\n private httpClient: HttpClient,\n private convexClient: ConvexClient,\n private options: NotificationClientOptions,\n ) {\n this.convexClient.onUpdate(\n anyApi.notifications.listenToNotificationsCount,\n {\n subscriberId: this.options.subscriberId,\n },\n ({ latest }) => {\n if (!latest) return;\n this.#handlers.forEach((handler) => handler([latest]));\n },\n );\n }\n\n async getNotifications(params: GetNotificationParams): Promise<GetNotificationsResponse> {\n const [res, { counts }] = await Promise.all([\n this.convexClient.query(anyApi.notifications.get, {\n numItems: params.numItems,\n cursor: params.cursor,\n filter: {\n subscriberId: this.options.subscriberId,\n appId: this.options.applicationId,\n },\n }),\n\n this.convexClient.query(anyApi.notifications.listenToNotificationsCount, {\n subscriberId: this.options.subscriberId,\n }),\n ]);\n\n return {\n data: res.page,\n pagination: {\n continueCursor: res.isDone ? null : res.continueCursor,\n total: counts.total,\n },\n status: 'success',\n unread: counts.unread,\n };\n }\n\n async getNotification(notificationId: string): Promise<BaseResponse<Notification>> {\n return this.httpClient.get(`/notifications/${notificationId}`);\n }\n\n async markAsRead(notificationId: string): Promise<BaseResponse<Notification>> {\n return await this.convexClient.mutation(anyApi.notifications.markAsRead, {\n id: notificationId,\n });\n }\n\n async markAsUnread(notificationId: string): Promise<BaseResponse<Notification>> {\n return this.httpClient.put(`/notifications/${notificationId}/unread`, {});\n }\n\n async archive(notificationId: string): Promise<BaseResponse<Notification>> {\n return this.httpClient.put(`/notifications/${notificationId}/archive`, {});\n }\n\n async unarchive(notificationId: string): Promise<BaseResponse<Notification>> {\n return this.httpClient.put(`/notifications/${notificationId}/unarchive`, {});\n }\n\n on(handler: (notifications: Notification[]) => void) {\n this.#handlers.push(handler);\n }\n\n off(handler: (notifications: Notification[]) => void) {\n this.#handlers = this.#handlers.filter((h) => h === handler);\n }\n}\n"],"mappings":";AAEA,SAAS,cAAc;AAahB,IAAM,qBAAN,MAAyB;AAAA,EAG9B,YACU,YACA,cACA,SACR;AAHQ;AACA;AACA;AAER,SAAK,aAAa;AAAA,MAChB,OAAO,cAAc;AAAA,MACrB;AAAA,QACE,cAAc,KAAK,QAAQ;AAAA,MAC7B;AAAA,MACA,CAAC,EAAE,OAAO,MAAM;AACd,YAAI,CAAC,OAAQ;AACb,aAAK,UAAU,QAAQ,CAAC,YAAY,QAAQ,CAAC,MAAM,CAAC,CAAC;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAAA,EAjBA,YAA6B,CAAC;AAAA,EAmB9B,MAAM,iBAAiB,QAAkE;AACvF,UAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,MAAM,QAAQ,IAAI;AAAA,MAC1C,KAAK,aAAa,MAAM,OAAO,cAAc,KAAK;AAAA,QAChD,UAAU,OAAO;AAAA,QACjB,QAAQ,OAAO;AAAA,QACf,QAAQ;AAAA,UACN,cAAc,KAAK,QAAQ;AAAA,UAC3B,OAAO,KAAK,QAAQ;AAAA,QACtB;AAAA,MACF,CAAC;AAAA,MAED,KAAK,aAAa,MAAM,OAAO,cAAc,4BAA4B;AAAA,QACvE,cAAc,KAAK,QAAQ;AAAA,MAC7B,CAAC;AAAA,IACH,CAAC;AAED,WAAO;AAAA,MACL,MAAM,IAAI;AAAA,MACV,YAAY;AAAA,QACV,gBAAgB,IAAI,SAAS,OAAO,IAAI;AAAA,QACxC,OAAO,OAAO;AAAA,MAChB;AAAA,MACA,QAAQ;AAAA,MACR,QAAQ,OAAO;AAAA,IACjB;AAAA,EACF;AAAA,EAEA,MAAM,gBAAgB,gBAA6D;AACjF,WAAO,KAAK,WAAW,IAAI,kBAAkB,cAAc,EAAE;AAAA,EAC/D;AAAA,EAEA,MAAM,WAAW,gBAA6D;AAC5E,WAAO,MAAM,KAAK,aAAa,SAAS,OAAO,cAAc,YAAY;AAAA,MACvE,IAAI;AAAA,IACN,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,aAAa,gBAA6D;AAC9E,WAAO,KAAK,WAAW,IAAI,kBAAkB,cAAc,WAAW,CAAC,CAAC;AAAA,EAC1E;AAAA,EAEA,MAAM,QAAQ,gBAA6D;AACzE,WAAO,KAAK,WAAW,IAAI,kBAAkB,cAAc,YAAY,CAAC,CAAC;AAAA,EAC3E;AAAA,EAEA,MAAM,UAAU,gBAA6D;AAC3E,WAAO,KAAK,WAAW,IAAI,kBAAkB,cAAc,cAAc,CAAC,CAAC;AAAA,EAC7E;AAAA,EAEA,GAAG,SAAkD;AACnD,SAAK,UAAU,KAAK,OAAO;AAAA,EAC7B;AAAA,EAEA,IAAI,SAAkD;AACpD,SAAK,YAAY,KAAK,UAAU,OAAO,CAAC,MAAM,MAAM,OAAO;AAAA,EAC7D;AACF;","names":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/utils/const.ts"],"sourcesContent":["export const DEFAULT_BASE_URL = 'https://tekify.teknix.services';\nexport const DEFAULT_SOCKET_URL = 'https://convex-be.teknix.services';\n"],"mappings":";AAAO,IAAM,mBAAmB;AACzB,IAAM,qBAAqB;","names":[]}
|
@@ -1,35 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
NotificationClient
|
3
|
-
} from "./chunk-FC6XFVCA.js";
|
4
|
-
import {
|
5
|
-
DEFAULT_BASE_URL,
|
6
|
-
DEFAULT_SOCKET_URL
|
7
|
-
} from "./chunk-J52CIUB2.js";
|
8
|
-
|
9
|
-
// src/client/client.ts
|
10
|
-
import { HttpClient } from "@tnf-dev/core";
|
11
|
-
import { ConvexClient } from "convex/browser";
|
12
|
-
var TeknifyClient = class {
|
13
|
-
#httpClient;
|
14
|
-
#convexClient;
|
15
|
-
#notification;
|
16
|
-
constructor(options) {
|
17
|
-
this.#httpClient = new HttpClient({
|
18
|
-
...options,
|
19
|
-
baseUrl: options.baseUrl || DEFAULT_BASE_URL
|
20
|
-
});
|
21
|
-
this.#convexClient = new ConvexClient(options.socketUrl || DEFAULT_SOCKET_URL);
|
22
|
-
this.#notification = new NotificationClient(this.#httpClient, this.#convexClient, {
|
23
|
-
applicationId: options.applicationId,
|
24
|
-
subscriberId: options.subscriberId
|
25
|
-
});
|
26
|
-
}
|
27
|
-
get notification() {
|
28
|
-
return this.#notification;
|
29
|
-
}
|
30
|
-
};
|
31
|
-
|
32
|
-
export {
|
33
|
-
TeknifyClient
|
34
|
-
};
|
35
|
-
//# sourceMappingURL=chunk-QMITKG5M.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/client/client.ts"],"sourcesContent":["import { HttpClient, HttpClientOptions } from '@tnf-dev/core';\nimport { ConvexClient } from 'convex/browser';\nimport { DEFAULT_BASE_URL, DEFAULT_SOCKET_URL } from '../utils/const';\nimport { NotificationClient } from './notification';\n\nexport interface TeknifyClientOptions extends Omit<HttpClientOptions, 'baseUrl'> {\n baseUrl?: string;\n socketUrl?: string;\n applicationId: string;\n subscriberId: string;\n}\n\nexport class TeknifyClient {\n #httpClient: HttpClient;\n #convexClient: ConvexClient;\n\n #notification: NotificationClient;\n\n constructor(options: TeknifyClientOptions) {\n this.#httpClient = new HttpClient({\n ...options,\n baseUrl: options.baseUrl || DEFAULT_BASE_URL,\n });\n this.#convexClient = new ConvexClient(options.socketUrl || DEFAULT_SOCKET_URL);\n\n this.#notification = new NotificationClient(this.#httpClient, this.#convexClient, {\n applicationId: options.applicationId,\n subscriberId: options.subscriberId,\n });\n }\n\n public get notification() {\n return this.#notification;\n }\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,kBAAqC;AAC9C,SAAS,oBAAoB;AAWtB,IAAM,gBAAN,MAAoB;AAAA,EACzB;AAAA,EACA;AAAA,EAEA;AAAA,EAEA,YAAY,SAA+B;AACzC,SAAK,cAAc,IAAI,WAAW;AAAA,MAChC,GAAG;AAAA,MACH,SAAS,QAAQ,WAAW;AAAA,IAC9B,CAAC;AACD,SAAK,gBAAgB,IAAI,aAAa,QAAQ,aAAa,kBAAkB;AAE7E,SAAK,gBAAgB,IAAI,mBAAmB,KAAK,aAAa,KAAK,eAAe;AAAA,MAChF,eAAe,QAAQ;AAAA,MACvB,cAAc,QAAQ;AAAA,IACxB,CAAC;AAAA,EACH;AAAA,EAEA,IAAW,eAAe;AACxB,WAAO,KAAK;AAAA,EACd;AACF;","names":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
//# sourceMappingURL=chunk-ZX5OIIJX.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/client/convex.ts"],"sourcesContent":["export { ConvexClient } from 'convex/browser';\n"],"mappings":";AAAA,SAAS,oBAAoB;","names":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/esm/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|