@voltro/plugin-notifications 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +52 -0
- package/LICENSE +57 -0
- package/README.md +26 -0
- package/SECURITY.md +56 -0
- package/THIRD-PARTY-NOTICES.md +347 -0
- package/dist/index.d.ts +322 -0
- package/dist/index.js +689 -0
- package/dist/rpc.d.ts +60 -0
- package/dist/rpc.js +133 -0
- package/dist/web.d.ts +46 -0
- package/dist/web.js +38 -0
- package/package.json +55 -0
package/dist/rpc.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { MutationProcedureDescriptor } from '@voltro/protocol';
|
|
2
|
+
import { PluginRpcClientDescriptor } from '@voltro/protocol';
|
|
3
|
+
import { QueryProcedureDescriptor } from '@voltro/protocol';
|
|
4
|
+
import { Schema } from 'effect';
|
|
5
|
+
|
|
6
|
+
export declare const clearQuietHoursDescriptor: MutationProcedureDescriptor<"notifications.clearQuietHours", Schema.Struct<{}>, Schema.Struct<{
|
|
7
|
+
ok: typeof Schema.Boolean;
|
|
8
|
+
}>, typeof Schema.Never>;
|
|
9
|
+
|
|
10
|
+
export declare const inboxDescriptor: QueryProcedureDescriptor<"notifications.inbox", Schema.Struct<{
|
|
11
|
+
unreadOnly: Schema.optional<typeof Schema.Boolean>;
|
|
12
|
+
limit: Schema.optional<typeof Schema.Number>;
|
|
13
|
+
}>, Schema.Array$<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>, typeof Schema.Never>;
|
|
14
|
+
|
|
15
|
+
export declare const markReadDescriptor: MutationProcedureDescriptor<"notifications.markRead", Schema.Struct<{
|
|
16
|
+
id: typeof Schema.String;
|
|
17
|
+
}>, Schema.Struct<{
|
|
18
|
+
ok: typeof Schema.Boolean;
|
|
19
|
+
}>, typeof Schema.Never>;
|
|
20
|
+
|
|
21
|
+
/** Declared for the codegen (`VoltroPlugin.rpcClientDescriptors`) so each tag is
|
|
22
|
+
* emitted into the generated client group. Kept in lockstep with the exports. */
|
|
23
|
+
export declare const notificationsRpcClientImports: ReadonlyArray<PluginRpcClientDescriptor>;
|
|
24
|
+
|
|
25
|
+
export declare const preferencesDescriptor: QueryProcedureDescriptor<"notifications.preferences", Schema.Struct<{}>, Schema.Array$<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>, typeof Schema.Never>;
|
|
26
|
+
|
|
27
|
+
export declare const setPreferenceDescriptor: MutationProcedureDescriptor<"notifications.setPreference", Schema.Struct<{
|
|
28
|
+
category: typeof Schema.String;
|
|
29
|
+
channel: typeof Schema.String;
|
|
30
|
+
enabled: typeof Schema.Boolean;
|
|
31
|
+
}>, Schema.Struct<{
|
|
32
|
+
ok: typeof Schema.Boolean;
|
|
33
|
+
}>, typeof Schema.Never>;
|
|
34
|
+
|
|
35
|
+
export declare const setQuietHoursDescriptor: MutationProcedureDescriptor<"notifications.setQuietHours", Schema.Struct<{
|
|
36
|
+
startMinute: typeof Schema.Number;
|
|
37
|
+
endMinute: typeof Schema.Number;
|
|
38
|
+
tz: Schema.optional<typeof Schema.String>;
|
|
39
|
+
policy: Schema.optional<Schema.Literal<["hold", "drop"]>>;
|
|
40
|
+
}>, Schema.Struct<{
|
|
41
|
+
ok: typeof Schema.Boolean;
|
|
42
|
+
}>, typeof Schema.Never>;
|
|
43
|
+
|
|
44
|
+
export declare const subscribeDescriptor: MutationProcedureDescriptor<"notifications.subscribe", Schema.Struct<{
|
|
45
|
+
topic: typeof Schema.String;
|
|
46
|
+
}>, Schema.Struct<{
|
|
47
|
+
ok: typeof Schema.Boolean;
|
|
48
|
+
}>, typeof Schema.Never>;
|
|
49
|
+
|
|
50
|
+
export declare const unreadCountDescriptor: QueryProcedureDescriptor<"notifications.unreadCount", Schema.Struct<{}>, Schema.Struct<{
|
|
51
|
+
count: typeof Schema.Number;
|
|
52
|
+
}>, typeof Schema.Never>;
|
|
53
|
+
|
|
54
|
+
export declare const unsubscribeDescriptor: MutationProcedureDescriptor<"notifications.unsubscribe", Schema.Struct<{
|
|
55
|
+
topic: typeof Schema.String;
|
|
56
|
+
}>, Schema.Struct<{
|
|
57
|
+
ok: typeof Schema.Boolean;
|
|
58
|
+
}>, typeof Schema.Never>;
|
|
59
|
+
|
|
60
|
+
export { }
|
package/dist/rpc.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Schema as e } from "effect";
|
|
2
|
+
import { defineMutation as t, defineQuery as n } from "@voltro/protocol";
|
|
3
|
+
//#region src/rpc.ts
|
|
4
|
+
var r = n({
|
|
5
|
+
name: "notifications.inbox",
|
|
6
|
+
input: e.Struct({
|
|
7
|
+
unreadOnly: e.optional(e.Boolean),
|
|
8
|
+
limit: e.optional(e.Number)
|
|
9
|
+
}),
|
|
10
|
+
output: e.Array(e.Record({
|
|
11
|
+
key: e.String,
|
|
12
|
+
value: e.Unknown
|
|
13
|
+
}))
|
|
14
|
+
}), i = n({
|
|
15
|
+
name: "notifications.unreadCount",
|
|
16
|
+
input: e.Struct({}),
|
|
17
|
+
output: e.Struct({ count: e.Number })
|
|
18
|
+
}), a = t({
|
|
19
|
+
name: "notifications.markRead",
|
|
20
|
+
input: e.Struct({ id: e.String }),
|
|
21
|
+
output: e.Struct({ ok: e.Boolean })
|
|
22
|
+
}), o = n({
|
|
23
|
+
name: "notifications.preferences",
|
|
24
|
+
input: e.Struct({}),
|
|
25
|
+
output: e.Array(e.Record({
|
|
26
|
+
key: e.String,
|
|
27
|
+
value: e.Unknown
|
|
28
|
+
}))
|
|
29
|
+
}), s = t({
|
|
30
|
+
name: "notifications.setPreference",
|
|
31
|
+
input: e.Struct({
|
|
32
|
+
category: e.String,
|
|
33
|
+
channel: e.String,
|
|
34
|
+
enabled: e.Boolean
|
|
35
|
+
}),
|
|
36
|
+
output: e.Struct({ ok: e.Boolean })
|
|
37
|
+
}), c = t({
|
|
38
|
+
name: "notifications.subscribe",
|
|
39
|
+
input: e.Struct({ topic: e.String }),
|
|
40
|
+
output: e.Struct({ ok: e.Boolean })
|
|
41
|
+
}), l = t({
|
|
42
|
+
name: "notifications.unsubscribe",
|
|
43
|
+
input: e.Struct({ topic: e.String }),
|
|
44
|
+
output: e.Struct({ ok: e.Boolean })
|
|
45
|
+
}), u = t({
|
|
46
|
+
name: "notifications.setQuietHours",
|
|
47
|
+
input: e.Struct({
|
|
48
|
+
startMinute: e.Number,
|
|
49
|
+
endMinute: e.Number,
|
|
50
|
+
tz: e.optional(e.String),
|
|
51
|
+
policy: e.optional(e.Literal("hold", "drop"))
|
|
52
|
+
}),
|
|
53
|
+
output: e.Struct({ ok: e.Boolean })
|
|
54
|
+
}), d = t({
|
|
55
|
+
name: "notifications.clearQuietHours",
|
|
56
|
+
input: e.Struct({}),
|
|
57
|
+
output: e.Struct({ ok: e.Boolean })
|
|
58
|
+
}), f = [
|
|
59
|
+
{
|
|
60
|
+
tag: "notifications.inbox",
|
|
61
|
+
kind: "query",
|
|
62
|
+
import: {
|
|
63
|
+
module: "@voltro/plugin-notifications/rpc",
|
|
64
|
+
name: "inboxDescriptor"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
tag: "notifications.unreadCount",
|
|
69
|
+
kind: "query",
|
|
70
|
+
import: {
|
|
71
|
+
module: "@voltro/plugin-notifications/rpc",
|
|
72
|
+
name: "unreadCountDescriptor"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
tag: "notifications.markRead",
|
|
77
|
+
kind: "mutation",
|
|
78
|
+
import: {
|
|
79
|
+
module: "@voltro/plugin-notifications/rpc",
|
|
80
|
+
name: "markReadDescriptor"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
tag: "notifications.preferences",
|
|
85
|
+
kind: "query",
|
|
86
|
+
import: {
|
|
87
|
+
module: "@voltro/plugin-notifications/rpc",
|
|
88
|
+
name: "preferencesDescriptor"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
tag: "notifications.setPreference",
|
|
93
|
+
kind: "mutation",
|
|
94
|
+
import: {
|
|
95
|
+
module: "@voltro/plugin-notifications/rpc",
|
|
96
|
+
name: "setPreferenceDescriptor"
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
tag: "notifications.subscribe",
|
|
101
|
+
kind: "mutation",
|
|
102
|
+
import: {
|
|
103
|
+
module: "@voltro/plugin-notifications/rpc",
|
|
104
|
+
name: "subscribeDescriptor"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
tag: "notifications.unsubscribe",
|
|
109
|
+
kind: "mutation",
|
|
110
|
+
import: {
|
|
111
|
+
module: "@voltro/plugin-notifications/rpc",
|
|
112
|
+
name: "unsubscribeDescriptor"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
tag: "notifications.setQuietHours",
|
|
117
|
+
kind: "mutation",
|
|
118
|
+
import: {
|
|
119
|
+
module: "@voltro/plugin-notifications/rpc",
|
|
120
|
+
name: "setQuietHoursDescriptor"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
tag: "notifications.clearQuietHours",
|
|
125
|
+
kind: "mutation",
|
|
126
|
+
import: {
|
|
127
|
+
module: "@voltro/plugin-notifications/rpc",
|
|
128
|
+
name: "clearQuietHoursDescriptor"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
];
|
|
132
|
+
//#endregion
|
|
133
|
+
export { d as clearQuietHoursDescriptor, r as inboxDescriptor, a as markReadDescriptor, f as notificationsRpcClientImports, o as preferencesDescriptor, s as setPreferenceDescriptor, u as setQuietHoursDescriptor, c as subscribeDescriptor, i as unreadCountDescriptor, l as unsubscribeDescriptor };
|
package/dist/web.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** An in-app inbox item. */
|
|
2
|
+
declare interface InboxItem {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly subjectId: string;
|
|
5
|
+
readonly category: string;
|
|
6
|
+
readonly title: string;
|
|
7
|
+
readonly body: string;
|
|
8
|
+
readonly data: Record<string, unknown>;
|
|
9
|
+
readonly readAt: string | null;
|
|
10
|
+
readonly createdAt: string;
|
|
11
|
+
readonly tenantId: string | null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** The caller's in-app inbox. (Plugin query route — re-reads on reconnect; for
|
|
15
|
+
* a fully live feed, mirror the inbox into a `source`-backed app query.) */
|
|
16
|
+
export declare const useInbox: (opts?: {
|
|
17
|
+
unreadOnly?: boolean;
|
|
18
|
+
limit?: number;
|
|
19
|
+
}, apiName?: string) => ReadonlyArray<InboxItem>;
|
|
20
|
+
|
|
21
|
+
/** Mark-read action. */
|
|
22
|
+
export declare const useMarkRead: (apiName?: string) => (id: string) => Promise<unknown>;
|
|
23
|
+
|
|
24
|
+
/** Set / clear the caller's quiet-hours (DND) window. Minutes are minutes past
|
|
25
|
+
* local midnight in `tz` (default UTC); `policy` is `hold` (default) or `drop`. */
|
|
26
|
+
export declare const useQuietHours: (apiName?: string) => {
|
|
27
|
+
set: (startMinute: number, endMinute: number, opts?: {
|
|
28
|
+
tz?: string;
|
|
29
|
+
policy?: "hold" | "drop";
|
|
30
|
+
}) => Promise<unknown>;
|
|
31
|
+
clear: () => Promise<unknown>;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** Toggle a channel preference for a category. */
|
|
35
|
+
export declare const useSetNotificationPreference: (apiName?: string) => (category: string, channel: string, enabled: boolean) => Promise<unknown>;
|
|
36
|
+
|
|
37
|
+
/** Subscribe / unsubscribe the caller to a broadcast topic. */
|
|
38
|
+
export declare const useTopicSubscription: (apiName?: string) => {
|
|
39
|
+
subscribe: (topic: string) => Promise<unknown>;
|
|
40
|
+
unsubscribe: (topic: string) => Promise<unknown>;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** The caller's unread count. */
|
|
44
|
+
export declare const useUnreadCount: (apiName?: string) => number;
|
|
45
|
+
|
|
46
|
+
export { }
|
package/dist/web.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useMutation as e, useSubscription as t } from "@voltro/client";
|
|
2
|
+
//#region src/web.ts
|
|
3
|
+
var n = (e = {}, n = "app") => {
|
|
4
|
+
let { data: r } = t(n, "notifications.inbox", e);
|
|
5
|
+
return r ?? [];
|
|
6
|
+
}, r = (e = "app") => {
|
|
7
|
+
let { data: n } = t(e, "notifications.unreadCount", {});
|
|
8
|
+
return n?.count ?? 0;
|
|
9
|
+
}, i = (t = "app") => {
|
|
10
|
+
let n = e(t, "notifications.markRead");
|
|
11
|
+
return (e) => n.mutate({ id: e });
|
|
12
|
+
}, a = (t = "app") => {
|
|
13
|
+
let n = e(t, "notifications.setPreference");
|
|
14
|
+
return (e, t, r) => n.mutate({
|
|
15
|
+
category: e,
|
|
16
|
+
channel: t,
|
|
17
|
+
enabled: r
|
|
18
|
+
});
|
|
19
|
+
}, o = (t = "app") => {
|
|
20
|
+
let n = e(t, "notifications.subscribe"), r = e(t, "notifications.unsubscribe");
|
|
21
|
+
return {
|
|
22
|
+
subscribe: (e) => n.mutate({ topic: e }),
|
|
23
|
+
unsubscribe: (e) => r.mutate({ topic: e })
|
|
24
|
+
};
|
|
25
|
+
}, s = (t = "app") => {
|
|
26
|
+
let n = e(t, "notifications.setQuietHours"), r = e(t, "notifications.clearQuietHours");
|
|
27
|
+
return {
|
|
28
|
+
set: (e, t, r) => n.mutate({
|
|
29
|
+
startMinute: e,
|
|
30
|
+
endMinute: t,
|
|
31
|
+
...r?.tz ? { tz: r.tz } : {},
|
|
32
|
+
...r?.policy ? { policy: r.policy } : {}
|
|
33
|
+
}),
|
|
34
|
+
clear: () => r.mutate({})
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { n as useInbox, i as useMarkRead, s as useQuietHours, a as useSetNotificationPreference, o as useTopicSubscription, r as useUnreadCount };
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voltro/plugin-notifications",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "One unified notification surface — email, Slack/webhook, SMS, push, in-app — with per-subject preference routing, an in-app inbox, and a delivery log. NotificationService + typed routes + useInbox/useUnreadCount hooks.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"voltro",
|
|
7
|
+
"typescript",
|
|
8
|
+
"framework"
|
|
9
|
+
],
|
|
10
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
11
|
+
"homepage": "https://voltro.dev",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"email": "support@voltro.dev"
|
|
14
|
+
},
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Voltro UG",
|
|
17
|
+
"url": "https://voltro.dev"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./web": {
|
|
27
|
+
"types": "./dist/web.d.ts",
|
|
28
|
+
"import": "./dist/web.js",
|
|
29
|
+
"default": "./dist/web.js"
|
|
30
|
+
},
|
|
31
|
+
"./rpc": {
|
|
32
|
+
"types": "./dist/rpc.d.ts",
|
|
33
|
+
"import": "./dist/rpc.js",
|
|
34
|
+
"default": "./dist/rpc.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"main": "./dist/index.js",
|
|
38
|
+
"module": "./dist/index.js",
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"sideEffects": false,
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=24.0.0"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@voltro/client": "0.1.0",
|
|
46
|
+
"@voltro/database": "0.1.0",
|
|
47
|
+
"@voltro/protocol": "0.1.0"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"effect": "^3.21.4"
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public"
|
|
54
|
+
}
|
|
55
|
+
}
|