@voltro/plugin-notifications 0.83.1 → 0.85.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.
@@ -5,66 +5,10 @@ property of its respective copyright holders and is used under the terms of
5
5
  its license. This file is provided for attribution; it grants no rights in
6
6
  @voltro/plugin-notifications itself, which is proprietary (see LICENSE).
7
7
 
8
- Generated from the resolved runtime dependency closure (13 packages).
8
+ Generated from the resolved runtime dependency closure (11 packages).
9
9
 
10
10
  ---
11
11
 
12
- ## @effect/experimental@0.61.1
13
-
14
- License: MIT
15
-
16
- ```
17
- MIT License
18
-
19
- Copyright (c) 2023-present The Contributors
20
-
21
- Permission is hereby granted, free of charge, to any person obtaining a copy
22
- of this software and associated documentation files (the "Software"), to deal
23
- in the Software without restriction, including without limitation the rights
24
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25
- copies of the Software, and to permit persons to whom the Software is
26
- furnished to do so, subject to the following conditions:
27
-
28
- The above copyright notice and this permission notice shall be included in all
29
- copies or substantial portions of the Software.
30
-
31
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37
- SOFTWARE.
38
- ```
39
-
40
- ## @effect/sql@0.52.1
41
-
42
- License: MIT
43
-
44
- ```
45
- MIT License
46
-
47
- Copyright (c) 2023-present The Contributors
48
-
49
- Permission is hereby granted, free of charge, to any person obtaining a copy
50
- of this software and associated documentation files (the "Software"), to deal
51
- in the Software without restriction, including without limitation the rights
52
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
53
- copies of the Software, and to permit persons to whom the Software is
54
- furnished to do so, subject to the following conditions:
55
-
56
- The above copyright notice and this permission notice shall be included in all
57
- copies or substantial portions of the Software.
58
-
59
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
60
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
61
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
62
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
63
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
64
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
65
- SOFTWARE.
66
- ```
67
-
68
12
  ## @tanstack/devtools-event-client@0.4.4
69
13
 
70
14
  License: MIT
package/dist/define.d.ts CHANGED
@@ -7,8 +7,8 @@ export declare interface DefineNotificationConfig<Audience, Payload> {
7
7
  readonly name: string;
8
8
  /** The notifications category preferences are keyed by. Default: `name`. */
9
9
  readonly category?: string;
10
- readonly audience: Schema.Schema<Audience, any>;
11
- readonly payload: Schema.Schema<Payload, any>;
10
+ readonly audience: Schema.Codec<Audience, any>;
11
+ readonly payload: Schema.Codec<Payload, any>;
12
12
  /** PURE: payload + locale → what the recipient sees. No IO. */
13
13
  readonly render: (payload: Payload, ctx: RenderContext) => RenderedNotification;
14
14
  /** Restrict to these channels (ids); default: every configured channel,
@@ -20,8 +20,8 @@ export declare interface NotificationDescriptor<Audience = unknown, Payload = un
20
20
  readonly _tag: 'VoltroNotification';
21
21
  readonly name: string;
22
22
  readonly category: string;
23
- readonly audience: Schema.Schema<Audience, any>;
24
- readonly payload: Schema.Schema<Payload, any>;
23
+ readonly audience: Schema.Codec<Audience, any>;
24
+ readonly payload: Schema.Codec<Payload, any>;
25
25
  readonly render: (payload: Payload, ctx: RenderContext) => RenderedNotification;
26
26
  readonly channels?: ReadonlyArray<string>;
27
27
  }
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ import { FieldDefinitions } from '@voltro/database';
5
5
  import { Schema } from 'effect';
6
6
  import { Table } from '@voltro/database';
7
7
  import { VoltroPlugin } from '@voltro/protocol';
8
+ import { YieldableError } from 'effect/Cause';
8
9
 
9
10
  export declare const APNS_HOSTS: {
10
11
  readonly production: "https://api.push.apple.com";
@@ -135,8 +136,8 @@ export declare interface DefineNotificationConfig<Audience, Payload> {
135
136
  readonly name: string;
136
137
  /** The notifications category preferences are keyed by. Default: `name`. */
137
138
  readonly category?: string;
138
- readonly audience: Schema.Schema<Audience, any>;
139
- readonly payload: Schema.Schema<Payload, any>;
139
+ readonly audience: Schema.Codec<Audience, any>;
140
+ readonly payload: Schema.Codec<Payload, any>;
140
141
  /** PURE: payload + locale → what the recipient sees. No IO. */
141
142
  readonly render: (payload: Payload, ctx: RenderContext) => RenderedNotification;
142
143
  /** Restrict to these channels (ids); default: every configured channel,
@@ -413,8 +414,8 @@ export declare interface NotificationDescriptor<Audience = unknown, Payload = un
413
414
  readonly _tag: 'VoltroNotification';
414
415
  readonly name: string;
415
416
  readonly category: string;
416
- readonly audience: Schema.Schema<Audience, any>;
417
- readonly payload: Schema.Schema<Payload, any>;
417
+ readonly audience: Schema.Codec<Audience, any>;
418
+ readonly payload: Schema.Codec<Payload, any>;
418
419
  readonly render: (payload: Payload, ctx: RenderContext) => RenderedNotification;
419
420
  readonly channels?: ReadonlyArray<string>;
420
421
  }
@@ -442,7 +443,7 @@ export declare interface NotificationOutboxHandlerOptions {
442
443
  export declare class NotificationService extends NotificationService_base {
443
444
  }
444
445
 
445
- declare const NotificationService_base: Context.TagClass<NotificationService, "@voltro/plugin-notifications/NotificationService", NotificationServiceShape>;
446
+ declare const NotificationService_base: Context.ServiceClass<NotificationService, "@voltro/plugin-notifications/NotificationService", NotificationServiceShape>;
446
447
 
447
448
  export declare interface NotificationServiceShape {
448
449
  readonly send: (input: SendInput) => Promise<SendResult>;
@@ -758,12 +759,10 @@ export declare interface PushSubscriptionStore {
758
759
  export declare class PushTokenRejected extends PushTokenRejected_base {
759
760
  }
760
761
 
761
- declare const PushTokenRejected_base: Schema.TaggedErrorClass<PushTokenRejected, "PushTokenRejected", {
762
- readonly _tag: Schema.tag<"PushTokenRejected">;
763
- } & {
764
- token: typeof Schema.String;
765
- reason: typeof Schema.String;
766
- }>;
762
+ declare const PushTokenRejected_base: Schema.Class<PushTokenRejected, Schema.TaggedStruct<"PushTokenRejected", {
763
+ readonly token: Schema.String;
764
+ readonly reason: Schema.String;
765
+ }>, YieldableError>;
767
766
 
768
767
  /** A per-subject Do-Not-Disturb window, expressed in minutes-of-day in the
769
768
  * subject's `tz` (an IANA zone). A window may WRAP midnight (`startMinute` >
package/dist/index.js CHANGED
@@ -259,13 +259,26 @@ var I = class extends _.TaggedError()("PushTokenRejected", {
259
259
  },
260
260
  markRead: async (n, r) => (await t("_voltro_notification_inbox", v(b("id", n), b("subjectId", r)), [], 1))[0] ? (await e.update("_voltro_notification_inbox", n, { readAt: (/* @__PURE__ */ new Date()).toISOString() }), !0) : !1,
261
261
  markUnread: async (n, r) => (await t("_voltro_notification_inbox", v(b("id", n), b("subjectId", r)), [], 1))[0] ? (await e.update("_voltro_notification_inbox", n, { readAt: null }), !0) : !1,
262
- markAllRead: async (n) => {
263
- let r = await t("_voltro_notification_inbox", v(b("subjectId", n), w("readAt")), [], void 0), i = (/* @__PURE__ */ new Date()).toISOString();
264
- for (let t of r) await e.update("_voltro_notification_inbox", String(t.id), { readAt: i });
265
- return r.length;
262
+ markAllRead: async (t) => {
263
+ let n = /* @__PURE__ */ new Date();
264
+ return e.updateMany("_voltro_notification_inbox", { readAt: n }, { where: v(b("subjectId", t), w("readAt")) });
266
265
  },
267
266
  setArchived: async (n, r, i) => (await t("_voltro_notification_inbox", v(b("id", n), b("subjectId", r)), [], 1))[0] ? (await e.update("_voltro_notification_inbox", n, { archivedAt: i ? (/* @__PURE__ */ new Date()).toISOString() : null }), !0) : !1,
268
- unreadCount: async (e) => (await t("_voltro_notification_inbox", v(b("subjectId", e), w("readAt")), [], void 0)).length,
267
+ unreadCount: async (t) => {
268
+ let n = await e.query({
269
+ table: "_voltro_notification_inbox",
270
+ predicate: v(b("subjectId", t), w("readAt")),
271
+ order: [],
272
+ take: void 0,
273
+ skip: void 0,
274
+ projection: void 0,
275
+ aggregations: [{
276
+ op: "count",
277
+ alias: "count"
278
+ }]
279
+ });
280
+ return Number(n[0]?.count ?? 0);
281
+ },
269
282
  getPreferences: async (e) => (await t("_voltro_notification_preferences", b("subjectId", e), [], void 0)).map(r),
270
283
  setPreference: async (t) => {
271
284
  let n = x({
@@ -1172,7 +1185,7 @@ var I = class extends _.TaggedError()("PushTokenRejected", {
1172
1185
  subjectId: A(),
1173
1186
  send: T(),
1174
1187
  flushAt: j()
1175
- }).renamedFrom("notification_held").index("byHeldFlushAt", ["flushAt"]).index("byHeldSubjectKind", ["subjectId", "kind"]), $ = class extends oe.Tag("@voltro/plugin-notifications/NotificationService")() {}, Nt = (e) => async (t) => {
1188
+ }).renamedFrom("notification_held").index("byHeldFlushAt", ["flushAt"]).index("byHeldSubjectKind", ["subjectId", "kind"]), $ = class extends oe.Service()("@voltro/plugin-notifications/NotificationService") {}, Nt = (e) => async (t) => {
1176
1189
  if (e !== void 0) try {
1177
1190
  let n = await e(t);
1178
1191
  if (typeof n == "string" && n !== "") return n;
package/dist/rpc.d.ts CHANGED
@@ -5,10 +5,10 @@ import { ReactivityChannel } from '@voltro/protocol';
5
5
  import { Schema } from 'effect';
6
6
 
7
7
  export declare const archiveDescriptor: MutationProcedureDescriptor<"notifications.archive", Schema.Struct<{
8
- id: typeof Schema.String;
8
+ readonly id: Schema.String;
9
9
  }>, Schema.Struct<{
10
- ok: typeof Schema.Boolean;
11
- }>, typeof Schema.Never>;
10
+ readonly ok: Schema.Boolean;
11
+ }>, Schema.Never>;
12
12
 
13
13
  /**
14
14
  * The plugin's canonical package name — the key an app's `alias` is recorded
@@ -23,104 +23,104 @@ export declare const archiveDescriptor: MutationProcedureDescriptor<"notificatio
23
23
  export declare const BASE_NAME = "@voltro/plugin-notifications";
24
24
 
25
25
  export declare const clearQuietHoursDescriptor: MutationProcedureDescriptor<"notifications.clearQuietHours", Schema.Struct<{}>, Schema.Struct<{
26
- ok: typeof Schema.Boolean;
27
- }>, typeof Schema.Never>;
26
+ readonly ok: Schema.Boolean;
27
+ }>, Schema.Never>;
28
28
 
29
29
  export declare const inboxDescriptor: QueryProcedureDescriptor<"notifications.inbox", Schema.Struct<{
30
- unreadOnly: Schema.optional<typeof Schema.Boolean>;
31
- limit: Schema.optional<typeof Schema.Number>;
32
- }>, Schema.Array$<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>, typeof Schema.Never>;
30
+ readonly unreadOnly: Schema.optional<Schema.Boolean>;
31
+ readonly limit: Schema.optional<Schema.Number>;
32
+ }>, Schema.$Array<Schema.$Record<Schema.String, Schema.Unknown>>, Schema.Never>;
33
33
 
34
34
  /** One push channel for the inbox: every in-app delivery and read-state
35
35
  * change publishes, and `inbox` / `unreadCount` re-run for subscribers. */
36
36
  export declare const inboxFeed: ReactivityChannel;
37
37
 
38
38
  export declare const markAllReadDescriptor: MutationProcedureDescriptor<"notifications.markAllRead", Schema.Struct<{}>, Schema.Struct<{
39
- count: typeof Schema.Number;
40
- }>, typeof Schema.Never>;
39
+ readonly count: Schema.Number;
40
+ }>, Schema.Never>;
41
41
 
42
42
  export declare const markReadDescriptor: MutationProcedureDescriptor<"notifications.markRead", Schema.Struct<{
43
- id: typeof Schema.String;
43
+ readonly id: Schema.String;
44
44
  }>, Schema.Struct<{
45
- ok: typeof Schema.Boolean;
46
- }>, typeof Schema.Never>;
45
+ readonly ok: Schema.Boolean;
46
+ }>, Schema.Never>;
47
47
 
48
48
  export declare const markUnreadDescriptor: MutationProcedureDescriptor<"notifications.markUnread", Schema.Struct<{
49
- id: typeof Schema.String;
49
+ readonly id: Schema.String;
50
50
  }>, Schema.Struct<{
51
- ok: typeof Schema.Boolean;
52
- }>, typeof Schema.Never>;
51
+ readonly ok: Schema.Boolean;
52
+ }>, Schema.Never>;
53
53
 
54
54
  /** Declared for the codegen (`VoltroPlugin.rpcClientDescriptors`) so each tag is
55
55
  * emitted into the generated client group. Kept in lockstep with the exports. */
56
56
  export declare const notificationsRpcClientImports: ReadonlyArray<PluginRpcClientDescriptor>;
57
57
 
58
- export declare const preferencesDescriptor: QueryProcedureDescriptor<"notifications.preferences", Schema.Struct<{}>, Schema.Array$<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>, typeof Schema.Never>;
58
+ export declare const preferencesDescriptor: QueryProcedureDescriptor<"notifications.preferences", Schema.Struct<{}>, Schema.$Array<Schema.$Record<Schema.String, Schema.Unknown>>, Schema.Never>;
59
59
 
60
60
  export declare const setPreferenceDescriptor: MutationProcedureDescriptor<"notifications.setPreference", Schema.Struct<{
61
- category: typeof Schema.String;
62
- channel: typeof Schema.String;
63
- enabled: typeof Schema.Boolean;
61
+ readonly category: Schema.String;
62
+ readonly channel: Schema.String;
63
+ readonly enabled: Schema.Boolean;
64
64
  }>, Schema.Struct<{
65
- ok: typeof Schema.Boolean;
66
- }>, typeof Schema.Never>;
65
+ readonly ok: Schema.Boolean;
66
+ }>, Schema.Never>;
67
67
 
68
68
  export declare const setQuietHoursDescriptor: MutationProcedureDescriptor<"notifications.setQuietHours", Schema.Struct<{
69
- startMinute: typeof Schema.Number;
70
- endMinute: typeof Schema.Number;
71
- tz: Schema.optional<typeof Schema.String>;
72
- policy: Schema.optional<Schema.Literal<["hold", "drop"]>>;
69
+ readonly startMinute: Schema.Number;
70
+ readonly endMinute: Schema.Number;
71
+ readonly tz: Schema.optional<Schema.String>;
72
+ readonly policy: Schema.optional<Schema.Literals<readonly ["hold", "drop"]>>;
73
73
  }>, Schema.Struct<{
74
- ok: typeof Schema.Boolean;
75
- }>, typeof Schema.Never>;
74
+ readonly ok: Schema.Boolean;
75
+ }>, Schema.Never>;
76
76
 
77
77
  export declare const subscribeDescriptor: MutationProcedureDescriptor<"notifications.subscribe", Schema.Struct<{
78
- topic: typeof Schema.String;
78
+ readonly topic: Schema.String;
79
79
  }>, Schema.Struct<{
80
- ok: typeof Schema.Boolean;
81
- }>, typeof Schema.Never>;
80
+ readonly ok: Schema.Boolean;
81
+ }>, Schema.Never>;
82
82
 
83
83
  export declare const unarchiveDescriptor: MutationProcedureDescriptor<"notifications.unarchive", Schema.Struct<{
84
- id: typeof Schema.String;
84
+ readonly id: Schema.String;
85
85
  }>, Schema.Struct<{
86
- ok: typeof Schema.Boolean;
87
- }>, typeof Schema.Never>;
86
+ readonly ok: Schema.Boolean;
87
+ }>, Schema.Never>;
88
88
 
89
89
  export declare const unreadCountDescriptor: QueryProcedureDescriptor<"notifications.unreadCount", Schema.Struct<{}>, Schema.Struct<{
90
- count: typeof Schema.Number;
91
- }>, typeof Schema.Never>;
90
+ readonly count: Schema.Number;
91
+ }>, Schema.Never>;
92
92
 
93
93
  export declare const unsubscribeDescriptor: MutationProcedureDescriptor<"notifications.unsubscribe", Schema.Struct<{
94
- topic: typeof Schema.String;
94
+ readonly topic: Schema.String;
95
95
  }>, Schema.Struct<{
96
- ok: typeof Schema.Boolean;
97
- }>, typeof Schema.Never>;
96
+ readonly ok: Schema.Boolean;
97
+ }>, Schema.Never>;
98
98
 
99
99
  export declare const webPushPublicKeyDescriptor: QueryProcedureDescriptor<"notifications.webPushPublicKey", Schema.Struct<{}>, Schema.Struct<{
100
- key: typeof Schema.String;
101
- }>, typeof Schema.Never>;
100
+ readonly key: Schema.String;
101
+ }>, Schema.Never>;
102
102
 
103
103
  /** Registered only when the app configures a web-push channel — see
104
104
  * `notificationsPlugin`. */
105
105
  export declare const webPushRpcClientImports: ReadonlyArray<PluginRpcClientDescriptor>;
106
106
 
107
107
  export declare const webPushStatusDescriptor: QueryProcedureDescriptor<"notifications.webPushStatus", Schema.Struct<{}>, Schema.Struct<{
108
- endpoints: typeof Schema.Number;
109
- }>, typeof Schema.Never>;
108
+ readonly endpoints: Schema.Number;
109
+ }>, Schema.Never>;
110
110
 
111
111
  export declare const webPushSubscribeDescriptor: MutationProcedureDescriptor<"notifications.webPushSubscribe", Schema.Struct<{
112
- endpoint: typeof Schema.String;
113
- p256dh: typeof Schema.String;
114
- auth: typeof Schema.String;
115
- ua: Schema.optional<typeof Schema.String>;
112
+ readonly endpoint: Schema.String;
113
+ readonly p256dh: Schema.String;
114
+ readonly auth: Schema.String;
115
+ readonly ua: Schema.optional<Schema.String>;
116
116
  }>, Schema.Struct<{
117
- ok: typeof Schema.Boolean;
118
- }>, typeof Schema.Never>;
117
+ readonly ok: Schema.Boolean;
118
+ }>, Schema.Never>;
119
119
 
120
120
  export declare const webPushUnsubscribeDescriptor: MutationProcedureDescriptor<"notifications.webPushUnsubscribe", Schema.Struct<{
121
- endpoint: typeof Schema.String;
121
+ readonly endpoint: Schema.String;
122
122
  }>, Schema.Struct<{
123
- ok: typeof Schema.Boolean;
124
- }>, typeof Schema.Never>;
123
+ readonly ok: Schema.Boolean;
124
+ }>, Schema.Never>;
125
125
 
126
126
  export { }
package/dist/rpc.js CHANGED
@@ -8,10 +8,7 @@ var i = "@voltro/plugin-notifications", a = r("notifications-inbox"), o = n({
8
8
  unreadOnly: e.optional(e.Boolean),
9
9
  limit: e.optional(e.Number)
10
10
  }),
11
- output: e.Array(e.Record({
12
- key: e.String,
13
- value: e.Unknown
14
- })),
11
+ output: e.Array(e.Record(e.String, e.Unknown)),
15
12
  openAccess: "self-scoped read: returns only the calling subject's own inbox items"
16
13
  }), s = n({
17
14
  name: "notifications.unreadCount",
@@ -47,10 +44,7 @@ var i = "@voltro/plugin-notifications", a = r("notifications-inbox"), o = n({
47
44
  }), p = n({
48
45
  name: "notifications.preferences",
49
46
  input: e.Struct({}),
50
- output: e.Array(e.Record({
51
- key: e.String,
52
- value: e.Unknown
53
- })),
47
+ output: e.Array(e.Record(e.String, e.Unknown)),
54
48
  openAccess: "self-scoped read: returns only the calling subject's own channel preferences"
55
49
  }), m = t({
56
50
  name: "notifications.setPreference",
@@ -77,7 +71,7 @@ var i = "@voltro/plugin-notifications", a = r("notifications-inbox"), o = n({
77
71
  startMinute: e.Number,
78
72
  endMinute: e.Number,
79
73
  tz: e.optional(e.String),
80
- policy: e.optional(e.Literal("hold", "drop"))
74
+ policy: e.optional(e.Literals(["hold", "drop"]))
81
75
  }),
82
76
  output: e.Struct({ ok: e.Boolean }),
83
77
  openAccess: "self-scoped write: sets only the calling subject's own quiet-hours window"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/plugin-notifications",
3
- "version": "0.83.1",
3
+ "version": "0.85.0",
4
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
5
  "keywords": [
6
6
  "voltro",
@@ -49,12 +49,12 @@
49
49
  "node": ">=24.0.0"
50
50
  },
51
51
  "dependencies": {
52
- "@voltro/client": "0.83.1",
53
- "@voltro/database": "0.83.1",
54
- "@voltro/protocol": "0.83.1"
52
+ "@voltro/client": "0.85.0",
53
+ "@voltro/database": "0.85.0",
54
+ "@voltro/protocol": "0.85.0"
55
55
  },
56
56
  "peerDependencies": {
57
- "effect": "^3.22.2",
57
+ "effect": "4.0.1",
58
58
  "react": "^19.0.0"
59
59
  },
60
60
  "publishConfig": {