@krak-stack/notifications-admin 0.1.0 → 0.2.1

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.
@@ -1,6 +1,7 @@
1
1
  import { Atom, AsyncResult } from "effect/reactivity";
2
2
  import { type DeliveryOverview, type AdminDeliveryPage } from "@krak-stack/notifications/admin/delivery.schema";
3
3
  import { NotificationScope } from "@krak-stack/notifications/schema";
4
+ import type { NotificationAdminClientOptions } from "./client-options.js";
4
5
  export declare const deliveryQueryKey: (input: {
5
6
  readonly view: "activity" | "overview";
6
7
  readonly source?: "all" | "contacts" | "engine" | undefined;
@@ -51,16 +52,101 @@ interface Data {
51
52
  readonly overview?: typeof DeliveryOverview.Type;
52
53
  readonly activity?: typeof AdminDeliveryPage.Type;
53
54
  }
54
- interface Resource {
55
- readonly atom: Atom.Atom<AsyncResult.AsyncResult<Data, unknown>>;
56
- readonly refresh: Atom.Atom<unknown>;
55
+ export interface NotificationDeliveryAtomOptions extends NotificationAdminClientOptions {
56
+ readonly scope?: NotificationScope;
57
57
  }
58
- export declare const makeNotificationDeliveryAtoms: (options: {
59
- baseUrl: string;
60
- authorizationKey: string;
61
- scope?: NotificationScope;
62
- }) => {
63
- query: (arg: string) => Resource;
58
+ export declare const makeNotificationDeliveryAtoms: (options: NotificationDeliveryAtomOptions) => {
59
+ query: (arg: string) => {
60
+ atom: Atom.Writable<AsyncResult.AsyncResult<Data, import("effect/http-api/HttpApiError").Forbidden | import("effect/http-api/HttpApiError").InternalServerError | import("@krak-stack/notifications/admin/schema").SendNotFound | import("@krak-stack/notifications/admin/schema").SendValidationError | import("effect/http-api/HttpApiError").Unauthorized>, Atom.Atom<AsyncResult.AsyncResult<AsyncResult.AsyncResult<{
61
+ readonly total: number;
62
+ readonly queued: number;
63
+ readonly processing: number;
64
+ readonly retrying: number;
65
+ readonly accepted: number;
66
+ readonly failed: number;
67
+ readonly suppressed: number;
68
+ readonly cancelled: number;
69
+ readonly feedbackCovered: number;
70
+ readonly feedbackUnavailable: number;
71
+ readonly confirmed: number;
72
+ readonly hardBounced: number;
73
+ readonly softBounced: number;
74
+ readonly complained: number;
75
+ }, import("effect/http-api/HttpApiError").Forbidden | import("effect/http-api/HttpApiError").InternalServerError | import("@krak-stack/notifications/admin/schema").SendNotFound | import("@krak-stack/notifications/admin/schema").SendValidationError | import("effect/http-api/HttpApiError").Unauthorized>, unknown>>>;
76
+ refresh: Atom.Atom<AsyncResult.AsyncResult<{
77
+ readonly total: number;
78
+ readonly queued: number;
79
+ readonly processing: number;
80
+ readonly retrying: number;
81
+ readonly accepted: number;
82
+ readonly failed: number;
83
+ readonly suppressed: number;
84
+ readonly cancelled: number;
85
+ readonly feedbackCovered: number;
86
+ readonly feedbackUnavailable: number;
87
+ readonly confirmed: number;
88
+ readonly hardBounced: number;
89
+ readonly softBounced: number;
90
+ readonly complained: number;
91
+ }, import("effect/http-api/HttpApiError").Forbidden | import("effect/http-api/HttpApiError").InternalServerError | import("@krak-stack/notifications/admin/schema").SendNotFound | import("@krak-stack/notifications/admin/schema").SendValidationError | import("effect/http-api/HttpApiError").Unauthorized>>;
92
+ } | {
93
+ atom: Atom.Writable<AsyncResult.AsyncResult<Data, import("effect/http-api/HttpApiError").Forbidden | import("effect/http-api/HttpApiError").InternalServerError | import("@krak-stack/notifications/admin/schema").SendNotFound | import("@krak-stack/notifications/admin/schema").SendValidationError | import("effect/http-api/HttpApiError").Unauthorized>, Atom.Atom<AsyncResult.AsyncResult<AsyncResult.AsyncResult<{
94
+ readonly items: readonly {
95
+ readonly id: string;
96
+ readonly source: "contacts" | "engine";
97
+ readonly recipientUserId: string | null;
98
+ readonly organizationId: string | null;
99
+ readonly workspaceId: string | null;
100
+ readonly contactId: string | null;
101
+ readonly campaignId: string | null;
102
+ readonly campaignName: string | null;
103
+ readonly recipientAddress: string;
104
+ readonly recipientName: string | null;
105
+ readonly eventKey: string;
106
+ readonly purpose: "marketing" | "notification" | "transactional";
107
+ readonly template: string | null;
108
+ readonly status: "cancelled" | "failed" | "processing" | "queued" | "retrying" | "sent" | "suppressed";
109
+ readonly attempts: number;
110
+ readonly maxAttempts: number;
111
+ readonly provider: string | null;
112
+ readonly providerMessageId: string | null;
113
+ readonly errorMessage: string | null;
114
+ readonly createdAt: Date;
115
+ readonly updatedAt: Date;
116
+ readonly scheduledFor: Date;
117
+ readonly sentAt: Date | null;
118
+ }[];
119
+ readonly total: number;
120
+ }, import("effect/http-api/HttpApiError").Forbidden | import("effect/http-api/HttpApiError").InternalServerError | import("@krak-stack/notifications/admin/schema").SendNotFound | import("@krak-stack/notifications/admin/schema").SendValidationError | import("effect/http-api/HttpApiError").Unauthorized>, unknown>>>;
121
+ refresh: Atom.Atom<AsyncResult.AsyncResult<{
122
+ readonly items: readonly {
123
+ readonly id: string;
124
+ readonly source: "contacts" | "engine";
125
+ readonly recipientUserId: string | null;
126
+ readonly organizationId: string | null;
127
+ readonly workspaceId: string | null;
128
+ readonly contactId: string | null;
129
+ readonly campaignId: string | null;
130
+ readonly campaignName: string | null;
131
+ readonly recipientAddress: string;
132
+ readonly recipientName: string | null;
133
+ readonly eventKey: string;
134
+ readonly purpose: "marketing" | "notification" | "transactional";
135
+ readonly template: string | null;
136
+ readonly status: "cancelled" | "failed" | "processing" | "queued" | "retrying" | "sent" | "suppressed";
137
+ readonly attempts: number;
138
+ readonly maxAttempts: number;
139
+ readonly provider: string | null;
140
+ readonly providerMessageId: string | null;
141
+ readonly errorMessage: string | null;
142
+ readonly createdAt: Date;
143
+ readonly updatedAt: Date;
144
+ readonly scheduledFor: Date;
145
+ readonly sentAt: Date | null;
146
+ }[];
147
+ readonly total: number;
148
+ }, import("effect/http-api/HttpApiError").Forbidden | import("effect/http-api/HttpApiError").InternalServerError | import("@krak-stack/notifications/admin/schema").SendNotFound | import("@krak-stack/notifications/admin/schema").SendValidationError | import("effect/http-api/HttpApiError").Unauthorized>>;
149
+ };
64
150
  inspection: (arg: string) => Atom.Writable<AsyncResult.AsyncResult<{
65
151
  readonly delivery: {
66
152
  readonly id: string;
@@ -0,0 +1,21 @@
1
+ import { AsyncResult, type Atom } from "effect/reactivity";
2
+ export interface NotificationQueryResource<A, E> {
3
+ readonly atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>;
4
+ readonly refresh: Atom.Atom<unknown>;
5
+ }
6
+ export interface NotificationQueryOptions<A> {
7
+ /** Include session/grants, scope, source and view; omit pagination/search. */
8
+ readonly retentionKey: string;
9
+ readonly total?: (data: A) => number | undefined;
10
+ /** Poll only while mounted. Omit to refresh manually. */
11
+ readonly refreshIntervalMillis?: number;
12
+ }
13
+ /** Retain pagination counts while loading, never across a failed protected read. */
14
+ export declare const useNotificationQuery: <A, E>(resource: NotificationQueryResource<A, E>, options: NotificationQueryOptions<A>) => {
15
+ result: AsyncResult.AsyncResult<A, E>;
16
+ data: A | undefined;
17
+ total: number;
18
+ failed: boolean;
19
+ refresh: () => void;
20
+ pending: boolean;
21
+ };
package/dist/hooks.js ADDED
@@ -0,0 +1,6 @@
1
+ import {
2
+ useNotificationQuery2
3
+ } from "./chunk-ghs5tkqn.js";
4
+ export {
5
+ useNotificationQuery2 as useNotificationQuery
6
+ };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,7 @@
1
1
  export * from "./contacts.js";
2
2
  export * from "./campaigns.js";
3
3
  export * from "./operations.js";
4
+ export * from "./deliveries.js";
5
+ export * from "./hooks.js";
6
+ export { NotificationPresentationProvider } from "./presentation.js";
7
+ export type { NotificationPresentation, NotificationTableId, NotificationTableOptions, NotificationTableProps, NotificationTableRenderer, } from "./presentation.js";
package/dist/index.js CHANGED
@@ -7,19 +7,41 @@ import {
7
7
  SendCampaignAdmin2
8
8
  } from "./chunk-dxjvd9tb.js";
9
9
  import {
10
+ NotificationDeliveryOverview2,
11
+ NotificationDeliveryActivity2,
12
+ NotificationAttemptHistory2,
13
+ NotificationDeliveryDetails2,
10
14
  NotificationDeliveries2
11
- } from "./chunk-nk9ge6g9.js";
15
+ } from "./chunk-4r5x0qzz.js";
12
16
  import {
17
+ NotificationPresentationProvider2
18
+ } from "./chunk-aqmv7g24.js";
19
+ import {
20
+ NotificationFeedbackTable2,
21
+ NotificationSuppressions2,
22
+ NotificationSuppressionAudit2,
13
23
  SendOperationsAdmin2
14
- } from "./chunk-8nawv50q.js";
24
+ } from "./chunk-d32m2dmf.js";
25
+ import {
26
+ useNotificationQuery2
27
+ } from "./chunk-ghs5tkqn.js";
15
28
  export {
29
+ NotificationAttemptHistory2 as NotificationAttemptHistory,
16
30
  SendCampaignAdmin2 as NotificationCampaigns,
17
31
  SendContactDetails2 as NotificationContactDetails,
18
32
  SendContacts2 as NotificationContacts,
19
33
  NotificationDeliveries2 as NotificationDeliveries,
34
+ NotificationDeliveryActivity2 as NotificationDeliveryActivity,
35
+ NotificationDeliveryDetails2 as NotificationDeliveryDetails,
36
+ NotificationDeliveryOverview2 as NotificationDeliveryOverview,
37
+ NotificationFeedbackTable2 as NotificationFeedbackTable,
20
38
  SendOperationsAdmin2 as NotificationOperations,
39
+ NotificationPresentationProvider2 as NotificationPresentationProvider,
40
+ NotificationSuppressionAudit2 as NotificationSuppressionAudit,
41
+ NotificationSuppressions2 as NotificationSuppressions,
21
42
  SendCampaignAdmin2 as SendCampaignAdmin,
22
43
  SendContactDetails2 as SendContactDetails,
23
44
  SendContacts2 as SendContacts,
24
- SendOperationsAdmin2 as SendOperationsAdmin
45
+ SendOperationsAdmin2 as SendOperationsAdmin,
46
+ useNotificationQuery2 as useNotificationQuery
25
47
  };
@@ -1,6 +1,7 @@
1
1
  import { Schema } from "effect";
2
2
  import { Atom, AsyncResult } from "effect/reactivity";
3
3
  import * as S from "@krak-stack/notifications/admin/operations.schema";
4
+ import type { NotificationAdminClientOptions } from "./client-options.js";
4
5
  export declare const OperationsQueryKey: Schema.Struct<{
5
6
  readonly view: Schema.Literals<readonly ["overview", "activity", "feedback", "suppressions", "audit", "recipients"]>;
6
7
  readonly filters: Schema.Struct<{
@@ -108,12 +109,12 @@ export interface OperationsData {
108
109
  readonly audit?: typeof S.SuppressionAuditPage.Type;
109
110
  readonly recipients?: typeof S.RecipientPage.Type;
110
111
  }
111
- interface Resource {
112
- readonly atom: Atom.Atom<AsyncResult.AsyncResult<OperationsData, unknown>>;
112
+ interface Resource<E> {
113
+ readonly atom: Atom.Atom<AsyncResult.AsyncResult<OperationsData, E>>;
113
114
  readonly refresh: Atom.Atom<unknown>;
114
115
  }
115
- export declare const makeSendOperationsAtoms: (baseUrl: string) => {
116
- query: (arg: string) => Resource;
116
+ export declare const makeSendOperationsAtoms: (input: string | NotificationAdminClientOptions) => {
117
+ query: (arg: string) => Resource<import("effect/http-api/HttpApiError").Forbidden | import("effect/http-api/HttpApiError").InternalServerError | import("@krak-stack/notifications/admin/schema").SendConflict | import("@krak-stack/notifications/admin/schema").SendNotFound | import("@krak-stack/notifications/admin/schema").SendValidationError | import("effect/http-api/HttpApiError").Unauthorized>;
117
118
  inspection: (arg: string) => Atom.Writable<AsyncResult.AsyncResult<{
118
119
  readonly delivery: {
119
120
  readonly id: string;
@@ -240,5 +241,6 @@ export declare const makeSendOperationsAtoms: (baseUrl: string) => {
240
241
  }, {
241
242
  readonly suppressionId: string;
242
243
  }, import("effect/http-api/HttpApiError").Forbidden | import("effect/http-api/HttpApiError").InternalServerError | import("@krak-stack/notifications/admin/schema").SendConflict | import("@krak-stack/notifications/admin/schema").SendNotFound | import("@krak-stack/notifications/admin/schema").SendValidationError | import("effect/http-api/HttpApiError").Unauthorized>;
244
+ authorizationKey: string;
243
245
  };
244
246
  export {};
@@ -2,6 +2,7 @@ export { NotificationDeliveries } from "./deliveries.js";
2
2
  export type { NotificationDeliveriesProps, NotificationDeliveryMessages, } from "./deliveries.js";
3
3
  import * as S from "@krak-stack/notifications/admin/operations.schema";
4
4
  import type { DataTablePublicState } from "@krak-stack/registry/data-table";
5
+ import { type NotificationTableOptions } from "./presentation.js";
5
6
  export { SendOperationsAdmin as NotificationOperations };
6
7
  export type { SendOperationsProps as NotificationOperationsProps, SendOperationsMessages as NotificationOperationsMessages, };
7
8
  type View = typeof S.OperationsView.Type;
@@ -73,6 +74,9 @@ export interface SendOperationsMessages {
73
74
  readonly id: string;
74
75
  }
75
76
  export interface SendOperationsProps {
77
+ readonly header?: boolean;
78
+ readonly navigation?: boolean;
79
+ readonly views?: ReadonlyArray<View>;
76
80
  readonly tableState?: DataTablePublicState;
77
81
  readonly onTableStateChange?: (state: DataTablePublicState) => void;
78
82
  readonly total?: number;
@@ -103,4 +107,38 @@ export interface SendOperationsProps {
103
107
  payload: typeof S.RemoveSuppression.Type;
104
108
  }) => Promise<typeof S.SuppressionChange.Type | void>;
105
109
  }
106
- export declare const SendOperationsAdmin: (p: SendOperationsProps) => import("react").JSX.Element;
110
+ export interface NotificationOperationsTableProps<Row extends {
111
+ readonly id: string;
112
+ }, Messages = Pick<SendOperationsMessages, "empty" | "loading">> {
113
+ readonly messages: Messages;
114
+ readonly items?: ReadonlyArray<Row>;
115
+ readonly tableState?: DataTablePublicState;
116
+ readonly onTableStateChange?: (state: DataTablePublicState) => void;
117
+ readonly total?: number;
118
+ readonly pending?: boolean;
119
+ readonly error?: string;
120
+ readonly onRefresh?: () => void;
121
+ readonly tableOptions?: NotificationTableOptions<Row>;
122
+ }
123
+ export type NotificationFeedbackMessages = Pick<SendOperationsMessages, "empty" | "loading" | "never" | "email" | "kinds" | "correlation" | "pending" | "applied" | "provider" | "providerMessageId" | "eventId" | "occurred" | "received" | "checked" | "deliveryId" | "contactId" | "campaign" | "inspect"> & {
124
+ readonly views: Pick<SendOperationsMessages["views"], "feedback">;
125
+ };
126
+ export interface NotificationFeedbackTableProps extends NotificationOperationsTableProps<typeof S.FeedbackRecord.Type, NotificationFeedbackMessages> {
127
+ readonly onInspect: (id: string) => void;
128
+ }
129
+ export declare const NotificationFeedbackTable: (p: NotificationFeedbackTableProps) => import("react").JSX.Element;
130
+ export type NotificationSuppressionMessages = Pick<SendOperationsMessages, "empty" | "loading" | "never" | "email" | "purpose" | "all" | "reason" | "active" | "expired" | "status" | "created" | "expires" | "removeSuppression" | "addSuppression" | "previousReason" | "failed" | "confirm" | "suppressionWarning">;
131
+ export interface NotificationSuppressionsProps extends NotificationOperationsTableProps<typeof S.SuppressionRecord.Type, NotificationSuppressionMessages> {
132
+ readonly onAddSuppression?: SendOperationsProps["onAddSuppression"];
133
+ readonly onRemoveSuppression?: SendOperationsProps["onRemoveSuppression"];
134
+ }
135
+ export declare const NotificationSuppressions: (p: NotificationSuppressionsProps) => import("react").JSX.Element;
136
+ export type NotificationSuppressionAuditRow = typeof S.SuppressionAudit.Type & {
137
+ readonly id: string;
138
+ };
139
+ export type NotificationSuppressionAuditMessages = Pick<SendOperationsMessages, "empty" | "loading" | "never" | "email" | "action" | "add" | "remove" | "reason" | "previousReason" | "actor" | "occurred" | "requestId" | "id">;
140
+ export interface NotificationSuppressionAuditProps extends Omit<NotificationOperationsTableProps<NotificationSuppressionAuditRow, NotificationSuppressionAuditMessages>, "items"> {
141
+ readonly items?: ReadonlyArray<typeof S.SuppressionAudit.Type>;
142
+ }
143
+ export declare const NotificationSuppressionAudit: (p: NotificationSuppressionAuditProps) => import("react").JSX.Element;
144
+ export declare const SendOperationsAdmin: (p: SendOperationsProps) => import("react").JSX.Element | null;
@@ -1,12 +1,19 @@
1
1
  import {
2
+ NotificationFeedbackTable2,
3
+ NotificationSuppressions2,
4
+ NotificationSuppressionAudit2,
2
5
  SendOperationsAdmin2
3
- } from "./chunk-8nawv50q.js";
6
+ } from "./chunk-d32m2dmf.js";
4
7
  import {
5
8
  NotificationDeliveries2
6
- } from "./chunk-nk9ge6g9.js";
9
+ } from "./chunk-4r5x0qzz.js";
7
10
  import"./chunk-tck9drx2.js";
11
+ import"./chunk-aqmv7g24.js";
8
12
  export {
9
13
  NotificationDeliveries2 as NotificationDeliveries,
14
+ NotificationFeedbackTable2 as NotificationFeedbackTable,
10
15
  SendOperationsAdmin2 as NotificationOperations,
16
+ NotificationSuppressionAudit2 as NotificationSuppressionAudit,
17
+ NotificationSuppressions2 as NotificationSuppressions,
11
18
  SendOperationsAdmin2 as SendOperationsAdmin
12
19
  };
@@ -0,0 +1,25 @@
1
+ import { type ReactNode } from "react";
2
+ import type { DataTableColDef, DataTableProps } from "@krak-stack/registry/data-table";
3
+ export type NotificationTableId = "delivery-activity" | "delivery-attempts" | "operations-activity" | "feedback" | "suppressions" | "suppression-audit" | "campaign-recipients" | "operations-attempts";
4
+ export interface NotificationTableOptions<Row extends object> {
5
+ readonly columns?: (defaults: ReadonlyArray<DataTableColDef<Row>>) => ReadonlyArray<DataTableColDef<Row>>;
6
+ readonly initialState?: DataTableProps<Row>["initialState"];
7
+ readonly className?: string;
8
+ }
9
+ export type NotificationTableProps<Row extends object> = DataTableProps<Row> & {
10
+ readonly notificationTable?: NotificationTableId;
11
+ };
12
+ export type NotificationTableRenderer = <Row extends object>(props: NotificationTableProps<Row>) => ReactNode;
13
+ export interface NotificationPresentation {
14
+ readonly Table: NotificationTableRenderer;
15
+ readonly renderReference?: (kind: string, id: string) => ReactNode;
16
+ }
17
+ /** Host-owned appearance and identity labels; never supplies authorization. */
18
+ export declare const NotificationPresentationProvider: ({ children, ...presentation }: NotificationPresentation & {
19
+ children: ReactNode;
20
+ }) => import("react").JSX.Element;
21
+ export declare const NotificationTable: <Row extends object>(props: NotificationTableProps<Row>) => import("react").JSX.Element;
22
+ export declare const NotificationReference: ({ kind, id, }: {
23
+ kind: string;
24
+ id: string | null | undefined;
25
+ }) => ReactNode;
@@ -0,0 +1,10 @@
1
+ import {
2
+ NotificationPresentationProvider2,
3
+ NotificationTable2,
4
+ NotificationReference2
5
+ } from "./chunk-aqmv7g24.js";
6
+ export {
7
+ NotificationPresentationProvider2 as NotificationPresentationProvider,
8
+ NotificationReference2 as NotificationReference,
9
+ NotificationTable2 as NotificationTable
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krak-stack/notifications-admin",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Optional React administration screens and Effect Atom helpers for KrakStack notifications.",
5
5
  "homepage": "https://krakstack.net/docs/notifications",
6
6
  "license": "MIT",
@@ -9,17 +9,21 @@
9
9
  "url": "git+https://github.com/krakcons/krakstack.git",
10
10
  "directory": "packages/notifications-admin"
11
11
  },
12
- "type": "module",
13
- "sideEffects": [
14
- "./tailwind.css"
15
- ],
16
12
  "files": [
17
13
  "dist",
18
14
  "tailwind.css",
19
15
  "README.md",
20
16
  "CHANGELOG.md"
21
17
  ],
18
+ "type": "module",
19
+ "sideEffects": [
20
+ "./tailwind.css"
21
+ ],
22
22
  "exports": {
23
+ "./presentation": {
24
+ "types": "./dist/presentation.d.ts",
25
+ "import": "./dist/presentation.js"
26
+ },
23
27
  ".": {
24
28
  "types": "./dist/index.d.ts",
25
29
  "import": "./dist/index.js"
@@ -44,6 +48,10 @@
44
48
  "types": "./dist/atoms.d.ts",
45
49
  "import": "./dist/atoms.js"
46
50
  },
51
+ "./hooks": {
52
+ "types": "./dist/hooks.d.ts",
53
+ "import": "./dist/hooks.js"
54
+ },
47
55
  "./tailwind.css": "./tailwind.css",
48
56
  "./package.json": "./package.json"
49
57
  },
@@ -62,11 +70,11 @@
62
70
  "cn": "^0.3.0"
63
71
  },
64
72
  "peerDependencies": {
65
- "@krak-stack/notifications": "^0.3.0",
66
- "@krak-stack/registry": "^0.2.2",
67
73
  "@base-ui/react": "^1.5.0",
68
74
  "@effect/atom-react": "^4.1.0",
69
75
  "@effect/platform-browser": "^4.1.0",
76
+ "@krak-stack/notifications": "^0.3.0 || ^0.4.0",
77
+ "@krak-stack/registry": "^0.2.2 || ^0.10.3",
70
78
  "@tanstack/react-form": "^1.33.0",
71
79
  "@tanstack/react-router": "^1.170.15",
72
80
  "@tanstack/react-virtual": "^3.14.5",