@lssm/module.notifications 0.0.0-canary-20251206160926
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/README.md +118 -0
- package/dist/channels/index.d.ts +106 -0
- package/dist/channels/index.js +1 -0
- package/dist/contracts/index.d.ts +637 -0
- package/dist/contracts/index.js +1 -0
- package/dist/entities/index.d.ts +182 -0
- package/dist/entities/index.js +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1 -0
- package/dist/libs/contracts/dist/capabilities/openbanking.js +1 -0
- package/dist/libs/contracts/dist/client/index.js +1 -0
- package/dist/libs/contracts/dist/client/react/feature-render.js +1 -0
- package/dist/libs/contracts/dist/client/react/form-render.js +1 -0
- package/dist/libs/contracts/dist/client/react/index.js +1 -0
- package/dist/libs/contracts/dist/events.js +1 -0
- package/dist/libs/contracts/dist/experiments/evaluator.js +1 -0
- package/dist/libs/contracts/dist/graphql-federation/dist/index.js +1 -0
- package/dist/libs/contracts/dist/index.js +1 -0
- package/dist/libs/contracts/dist/install.js +1 -0
- package/dist/libs/contracts/dist/integrations/contracts.js +1 -0
- package/dist/libs/contracts/dist/integrations/index.js +1 -0
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/accounts.js +1 -0
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/balances.js +1 -0
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/index.js +1 -0
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/transactions.js +1 -0
- package/dist/libs/contracts/dist/integrations/openbanking/models.js +1 -0
- package/dist/libs/contracts/dist/integrations/openbanking/telemetry.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/elevenlabs.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/gcs-storage.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/gmail.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/google-calendar.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/impls/elevenlabs-voice.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/impls/gcs-storage.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/impls/gmail-inbound.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/impls/gmail-outbound.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/impls/google-calendar.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/impls/index.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/impls/mistral-embedding.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/impls/mistral-llm.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/impls/postmark-email.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/impls/powens-client.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/impls/powens-openbanking.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/impls/provider-factory.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/impls/qdrant-vector.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/impls/stripe-payments.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/impls/twilio-sms.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/index.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/mistral.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/postmark.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/powens.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/qdrant.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/stripe.js +1 -0
- package/dist/libs/contracts/dist/integrations/providers/twilio-sms.js +1 -0
- package/dist/libs/contracts/dist/integrations/runtime.js +1 -0
- package/dist/libs/contracts/dist/integrations/secrets/env-secret-provider.js +1 -0
- package/dist/libs/contracts/dist/integrations/secrets/gcp-secret-manager.js +1 -0
- package/dist/libs/contracts/dist/integrations/secrets/index.js +1 -0
- package/dist/libs/contracts/dist/integrations/secrets/manager.js +1 -0
- package/dist/libs/contracts/dist/integrations/secrets/provider.js +1 -0
- package/dist/libs/contracts/dist/jsonschema.js +1 -0
- package/dist/libs/contracts/dist/knowledge/contracts.js +1 -0
- package/dist/libs/contracts/dist/knowledge/index.js +1 -0
- package/dist/libs/contracts/dist/knowledge/spaces/email-threads.js +1 -0
- package/dist/libs/contracts/dist/knowledge/spaces/financial-docs.js +1 -0
- package/dist/libs/contracts/dist/knowledge/spaces/financial-overview.js +1 -0
- package/dist/libs/contracts/dist/knowledge/spaces/index.js +1 -0
- package/dist/libs/contracts/dist/knowledge/spaces/product-canon.js +1 -0
- package/dist/libs/contracts/dist/knowledge/spaces/support-faq.js +1 -0
- package/dist/libs/contracts/dist/knowledge/spaces/uploaded-docs.js +1 -0
- package/dist/libs/contracts/dist/onboarding-base.js +1 -0
- package/dist/libs/contracts/dist/ownership.js +1 -0
- package/dist/libs/contracts/dist/presentations.js +1 -0
- package/dist/libs/contracts/dist/presentations.v2.js +1 -0
- package/dist/libs/contracts/dist/prompt.js +1 -0
- package/dist/libs/contracts/dist/promptRegistry.js +1 -0
- package/dist/libs/contracts/dist/regenerator/index.js +1 -0
- package/dist/libs/contracts/dist/regenerator/service.js +1 -0
- package/dist/libs/contracts/dist/registry.js +1 -0
- package/dist/libs/contracts/dist/resources.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/EnumType.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/FieldType.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/ScalarTypeEnum.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/SchemaModel.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/entity/defineEntity.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/entity/index.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/entity/types.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/index.js +1 -0
- package/dist/libs/contracts/dist/server/graphql-pothos.js +1 -0
- package/dist/libs/contracts/dist/server/graphql-schema-export.js +1 -0
- package/dist/libs/contracts/dist/server/index.js +1 -0
- package/dist/libs/contracts/dist/server/provider-mcp.js +1 -0
- package/dist/libs/contracts/dist/server/rest-elysia.js +1 -0
- package/dist/libs/contracts/dist/server/rest-express.js +1 -0
- package/dist/libs/contracts/dist/server/rest-generic.js +1 -0
- package/dist/libs/contracts/dist/server/rest-next-app.js +1 -0
- package/dist/libs/contracts/dist/server/rest-next-pages.js +1 -0
- package/dist/libs/contracts/dist/spec.js +1 -0
- package/dist/libs/contracts/dist/telemetry/index.js +1 -0
- package/dist/libs/contracts/dist/telemetry/tracker.js +1 -0
- package/dist/libs/contracts/dist/tests/index.js +1 -0
- package/dist/libs/contracts/dist/tests/runner.js +1 -0
- package/dist/libs/contracts/dist/workflow/index.js +1 -0
- package/dist/libs/contracts/dist/workflow/runner.js +1 -0
- package/dist/libs/schema/dist/EnumType.js +1 -0
- package/dist/libs/schema/dist/FieldType.js +1 -0
- package/dist/libs/schema/dist/ScalarTypeEnum.js +1 -0
- package/dist/libs/schema/dist/SchemaModel.js +1 -0
- package/dist/libs/schema/dist/entity/defineEntity.js +1 -0
- package/dist/libs/schema/dist/entity/index.js +1 -0
- package/dist/libs/schema/dist/entity/types.js +1 -0
- package/dist/libs/schema/dist/index.js +1 -0
- package/dist/templates/index.d.ts +91 -0
- package/dist/templates/index.js +9 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# @lssm/module.notifications
|
|
2
|
+
|
|
3
|
+
Notification center module for ContractSpec applications.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
Provides a unified notification system supporting multiple delivery channels (email, in-app, push, webhook). Handles notification preferences, templates, and delivery tracking.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Multi-Channel Delivery**: Email, in-app, push notifications, webhooks
|
|
12
|
+
- **User Preferences**: Per-user notification preferences by type and channel
|
|
13
|
+
- **Templates**: Template-based notifications with variable substitution
|
|
14
|
+
- **Delivery Tracking**: Track delivery status and read receipts
|
|
15
|
+
- **Batching**: Digest and batch notifications to reduce noise
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
bun add @lssm/module.notifications
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
### Entity Specs (for schema generation)
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { notificationsSchemaContribution } from '@lssm/module.notifications/entities';
|
|
29
|
+
|
|
30
|
+
// Use in schema composition
|
|
31
|
+
const config = {
|
|
32
|
+
modules: [notificationsSchemaContribution],
|
|
33
|
+
};
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Send Notifications
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { NotificationService } from '@lssm/module.notifications';
|
|
40
|
+
|
|
41
|
+
const service = new NotificationService({
|
|
42
|
+
channels: {
|
|
43
|
+
email: emailChannel,
|
|
44
|
+
inApp: inAppChannel,
|
|
45
|
+
push: pushChannel,
|
|
46
|
+
},
|
|
47
|
+
defaultChannel: 'inApp',
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Send a notification
|
|
51
|
+
await service.send({
|
|
52
|
+
userId: 'user-123',
|
|
53
|
+
templateId: 'welcome',
|
|
54
|
+
variables: {
|
|
55
|
+
name: 'John',
|
|
56
|
+
actionUrl: 'https://app.example.com/onboarding',
|
|
57
|
+
},
|
|
58
|
+
channels: ['email', 'inApp'],
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Configure Templates
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { defineTemplate } from '@lssm/module.notifications/templates';
|
|
66
|
+
|
|
67
|
+
const welcomeTemplate = defineTemplate({
|
|
68
|
+
id: 'welcome',
|
|
69
|
+
name: 'Welcome Email',
|
|
70
|
+
channels: {
|
|
71
|
+
email: {
|
|
72
|
+
subject: 'Welcome to {{appName}}, {{name}}!',
|
|
73
|
+
body: `
|
|
74
|
+
<h1>Welcome, {{name}}!</h1>
|
|
75
|
+
<p>Thanks for joining. Get started by clicking below.</p>
|
|
76
|
+
<a href="{{actionUrl}}">Get Started</a>
|
|
77
|
+
`,
|
|
78
|
+
},
|
|
79
|
+
inApp: {
|
|
80
|
+
title: 'Welcome to {{appName}}!',
|
|
81
|
+
body: 'Click here to complete your profile.',
|
|
82
|
+
actionUrl: '{{actionUrl}}',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### User Preferences
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
// Get user preferences
|
|
92
|
+
const prefs = await service.getPreferences('user-123');
|
|
93
|
+
|
|
94
|
+
// Update preferences
|
|
95
|
+
await service.updatePreferences('user-123', {
|
|
96
|
+
email: { marketing: false, transactional: true },
|
|
97
|
+
push: { mentions: true, updates: false },
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Entity Overview
|
|
102
|
+
|
|
103
|
+
| Entity | Description |
|
|
104
|
+
|--------|-------------|
|
|
105
|
+
| Notification | Individual notification instance |
|
|
106
|
+
| NotificationTemplate | Notification templates |
|
|
107
|
+
| NotificationPreference | User notification preferences |
|
|
108
|
+
| DeliveryLog | Delivery attempt tracking |
|
|
109
|
+
|
|
110
|
+
## Channels
|
|
111
|
+
|
|
112
|
+
| Channel | Description |
|
|
113
|
+
|---------|-------------|
|
|
114
|
+
| email | Email delivery (SMTP, SendGrid, etc.) |
|
|
115
|
+
| inApp | In-application notifications |
|
|
116
|
+
| push | Push notifications (FCM, APNs) |
|
|
117
|
+
| webhook | Webhook delivery for integrations |
|
|
118
|
+
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
//#region src/channels/index.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Notification channel interface.
|
|
4
|
+
*/
|
|
5
|
+
interface NotificationChannel {
|
|
6
|
+
/** Channel identifier */
|
|
7
|
+
readonly channelId: string;
|
|
8
|
+
/** Deliver a notification */
|
|
9
|
+
send(notification: ChannelNotification): Promise<ChannelDeliveryResult>;
|
|
10
|
+
/** Check if channel is available */
|
|
11
|
+
isAvailable(): Promise<boolean>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Notification to deliver via a channel.
|
|
15
|
+
*/
|
|
16
|
+
interface ChannelNotification {
|
|
17
|
+
id: string;
|
|
18
|
+
userId: string;
|
|
19
|
+
title: string;
|
|
20
|
+
body: string;
|
|
21
|
+
actionUrl?: string;
|
|
22
|
+
imageUrl?: string;
|
|
23
|
+
metadata?: Record<string, unknown>;
|
|
24
|
+
email?: {
|
|
25
|
+
to: string;
|
|
26
|
+
subject: string;
|
|
27
|
+
html?: string;
|
|
28
|
+
text?: string;
|
|
29
|
+
};
|
|
30
|
+
push?: {
|
|
31
|
+
token: string;
|
|
32
|
+
badge?: number;
|
|
33
|
+
sound?: string;
|
|
34
|
+
data?: Record<string, unknown>;
|
|
35
|
+
};
|
|
36
|
+
webhook?: {
|
|
37
|
+
url: string;
|
|
38
|
+
headers?: Record<string, string>;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Result of channel delivery attempt.
|
|
43
|
+
*/
|
|
44
|
+
interface ChannelDeliveryResult {
|
|
45
|
+
success: boolean;
|
|
46
|
+
externalId?: string;
|
|
47
|
+
responseCode?: string;
|
|
48
|
+
responseMessage?: string;
|
|
49
|
+
metadata?: Record<string, unknown>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* In-app notification channel (stores in database).
|
|
53
|
+
*/
|
|
54
|
+
declare class InAppChannel implements NotificationChannel {
|
|
55
|
+
readonly channelId = "IN_APP";
|
|
56
|
+
send(notification: ChannelNotification): Promise<ChannelDeliveryResult>;
|
|
57
|
+
isAvailable(): Promise<boolean>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Console channel for development/testing.
|
|
61
|
+
*/
|
|
62
|
+
declare class ConsoleChannel implements NotificationChannel {
|
|
63
|
+
readonly channelId = "CONSOLE";
|
|
64
|
+
send(notification: ChannelNotification): Promise<ChannelDeliveryResult>;
|
|
65
|
+
isAvailable(): Promise<boolean>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Email channel interface (to be implemented with provider).
|
|
69
|
+
*/
|
|
70
|
+
declare abstract class EmailChannel implements NotificationChannel {
|
|
71
|
+
readonly channelId = "EMAIL";
|
|
72
|
+
abstract send(notification: ChannelNotification): Promise<ChannelDeliveryResult>;
|
|
73
|
+
isAvailable(): Promise<boolean>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Push notification channel interface (to be implemented with provider).
|
|
77
|
+
*/
|
|
78
|
+
declare abstract class PushChannel implements NotificationChannel {
|
|
79
|
+
readonly channelId = "PUSH";
|
|
80
|
+
abstract send(notification: ChannelNotification): Promise<ChannelDeliveryResult>;
|
|
81
|
+
isAvailable(): Promise<boolean>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Webhook channel for external integrations.
|
|
85
|
+
*/
|
|
86
|
+
declare class WebhookChannel implements NotificationChannel {
|
|
87
|
+
readonly channelId = "WEBHOOK";
|
|
88
|
+
send(notification: ChannelNotification): Promise<ChannelDeliveryResult>;
|
|
89
|
+
isAvailable(): Promise<boolean>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Channel registry for managing available channels.
|
|
93
|
+
*/
|
|
94
|
+
declare class ChannelRegistry {
|
|
95
|
+
private channels;
|
|
96
|
+
register(channel: NotificationChannel): void;
|
|
97
|
+
get(channelId: string): NotificationChannel | undefined;
|
|
98
|
+
getAll(): NotificationChannel[];
|
|
99
|
+
getAvailable(): Promise<NotificationChannel[]>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Create a default channel registry with standard channels.
|
|
103
|
+
*/
|
|
104
|
+
declare function createChannelRegistry(): ChannelRegistry;
|
|
105
|
+
//#endregion
|
|
106
|
+
export { ChannelDeliveryResult, ChannelNotification, ChannelRegistry, ConsoleChannel, EmailChannel, InAppChannel, NotificationChannel, PushChannel, WebhookChannel, createChannelRegistry };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class{channelId=`IN_APP`;async send(e){return{success:!0,responseMessage:`Stored in database`}}async isAvailable(){return!0}},t=class{channelId=`CONSOLE`;async send(e){return console.log(`📬 [${e.id}] ${e.title}`),console.log(` ${e.body}`),e.actionUrl&&console.log(` Action: ${e.actionUrl}`),{success:!0,responseMessage:`Logged to console`}}async isAvailable(){return!0}},n=class{channelId=`EMAIL`;async isAvailable(){return!0}},r=class{channelId=`PUSH`;async isAvailable(){return!0}},i=class{channelId=`WEBHOOK`;async send(e){if(!e.webhook?.url)return{success:!1,responseMessage:`No webhook URL configured`};try{let t=await fetch(e.webhook.url,{method:`POST`,headers:{"Content-Type":`application/json`,...e.webhook.headers},body:JSON.stringify({id:e.id,title:e.title,body:e.body,actionUrl:e.actionUrl,metadata:e.metadata})});return{success:t.ok,responseCode:String(t.status),responseMessage:t.statusText}}catch(e){return{success:!1,responseMessage:e instanceof Error?e.message:`Unknown error`}}}async isAvailable(){return!0}},a=class{channels=new Map;register(e){this.channels.set(e.channelId,e)}get(e){return this.channels.get(e)}getAll(){return Array.from(this.channels.values())}async getAvailable(){let e=[];for(let t of this.channels.values())await t.isAvailable()&&e.push(t);return e}};function o(){let n=new a;return n.register(new e),n.register(new t),n.register(new i),n}export{a as ChannelRegistry,t as ConsoleChannel,n as EmailChannel,e as InAppChannel,r as PushChannel,i as WebhookChannel,o as createChannelRegistry};
|