@lssm/module.notifications 0.0.0-canary-20251217063201 → 0.0.0-canary-20251217072406
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/channels/index.js +126 -1
- package/dist/contracts/index.js +436 -1
- package/dist/entities/index.js +254 -1
- package/dist/index.js +7 -1
- package/dist/libs/contracts/dist/capabilities/openbanking.js +88 -1
- package/dist/libs/contracts/dist/client/index.js +5 -1
- package/dist/libs/contracts/dist/client/react/feature-render.js +2 -1
- package/dist/libs/contracts/dist/client/react/form-render.js +4 -1
- package/dist/libs/contracts/dist/client/react/index.js +4 -1
- package/dist/libs/contracts/dist/contract-registry/index.js +1 -1
- package/dist/libs/contracts/dist/contract-registry/schemas.js +60 -1
- package/dist/libs/contracts/dist/docs/PUBLISHING.docblock.js +16 -76
- package/dist/libs/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +16 -350
- package/dist/libs/contracts/dist/docs/index.js +29 -1
- package/dist/libs/contracts/dist/docs/presentations.js +71 -1
- package/dist/libs/contracts/dist/docs/registry.js +44 -1
- package/dist/libs/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +16 -383
- package/dist/libs/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +16 -68
- package/dist/libs/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +16 -140
- package/dist/libs/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +16 -86
- package/dist/libs/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +16 -1
- package/dist/libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +24 -2
- package/dist/libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +21 -2
- package/dist/libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +16 -213
- package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js +73 -5
- package/dist/libs/contracts/dist/docs/tech/mcp-endpoints.docblock.js +37 -1
- package/dist/libs/contracts/dist/docs/tech/presentation-runtime.docblock.js +16 -1
- package/dist/libs/contracts/dist/docs/tech/schema/README.docblock.js +20 -262
- package/dist/libs/contracts/dist/docs/tech/studio/learning-events.docblock.js +48 -1
- package/dist/libs/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +24 -2
- package/dist/libs/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +23 -2
- package/dist/libs/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +25 -16
- package/dist/libs/contracts/dist/docs/tech/studio/project-routing.docblock.js +67 -1
- package/dist/libs/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +22 -2
- package/dist/libs/contracts/dist/docs/tech/studio/team-invitations.docblock.js +40 -36
- package/dist/libs/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +47 -1
- package/dist/libs/contracts/dist/docs/tech/studio/workspaces.docblock.js +23 -2
- package/dist/libs/contracts/dist/docs/tech/telemetry-ingest.docblock.js +36 -3
- package/dist/libs/contracts/dist/docs/tech/templates/runtime.docblock.js +20 -1
- package/dist/libs/contracts/dist/docs/tech/vscode-extension.docblock.js +36 -3
- package/dist/libs/contracts/dist/docs/tech/workflows/overview.docblock.js +20 -1
- package/dist/libs/contracts/dist/events.js +1 -1
- package/dist/libs/contracts/dist/experiments/evaluator.js +1 -1
- package/dist/libs/contracts/dist/index.js +71 -1
- package/dist/libs/contracts/dist/install.js +2 -1
- package/dist/libs/contracts/dist/integrations/contracts.js +377 -1
- package/dist/libs/contracts/dist/integrations/index.js +18 -1
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/accounts.js +228 -1
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/balances.js +159 -1
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/index.js +3 -1
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/transactions.js +210 -1
- package/dist/libs/contracts/dist/integrations/openbanking/models.js +242 -1
- package/dist/libs/contracts/dist/integrations/openbanking/telemetry.js +13 -1
- package/dist/libs/contracts/dist/integrations/providers/elevenlabs.js +52 -1
- package/dist/libs/contracts/dist/integrations/providers/gcs-storage.js +75 -1
- package/dist/libs/contracts/dist/integrations/providers/gmail.js +87 -1
- package/dist/libs/contracts/dist/integrations/providers/google-calendar.js +66 -1
- package/dist/libs/contracts/dist/integrations/providers/index.js +11 -1
- package/dist/libs/contracts/dist/integrations/providers/mistral.js +68 -1
- package/dist/libs/contracts/dist/integrations/providers/postmark.js +68 -1
- package/dist/libs/contracts/dist/integrations/providers/powens.js +116 -1
- package/dist/libs/contracts/dist/integrations/providers/qdrant.js +73 -1
- package/dist/libs/contracts/dist/integrations/providers/registry.js +10 -1
- package/dist/libs/contracts/dist/integrations/providers/stripe.js +83 -1
- package/dist/libs/contracts/dist/integrations/providers/twilio-sms.js +61 -1
- package/dist/libs/contracts/dist/jsonschema.js +1 -1
- package/dist/libs/contracts/dist/knowledge/contracts.js +306 -1
- package/dist/libs/contracts/dist/knowledge/index.js +7 -1
- package/dist/libs/contracts/dist/knowledge/spaces/email-threads.js +34 -1
- package/dist/libs/contracts/dist/knowledge/spaces/financial-docs.js +34 -1
- package/dist/libs/contracts/dist/knowledge/spaces/financial-overview.js +38 -1
- package/dist/libs/contracts/dist/knowledge/spaces/index.js +6 -1
- package/dist/libs/contracts/dist/knowledge/spaces/product-canon.js +34 -1
- package/dist/libs/contracts/dist/knowledge/spaces/support-faq.js +37 -1
- package/dist/libs/contracts/dist/knowledge/spaces/uploaded-docs.js +34 -1
- package/dist/libs/contracts/dist/llm/exporters.js +19 -1
- package/dist/libs/contracts/dist/llm/index.js +2 -1
- package/dist/libs/contracts/dist/llm/prompts.js +1 -1
- package/dist/libs/contracts/dist/onboarding-base.js +196 -1
- package/dist/libs/contracts/dist/openapi.js +1 -1
- package/dist/libs/contracts/dist/ownership.js +21 -1
- package/dist/libs/contracts/dist/presentations.js +1 -1
- package/dist/libs/contracts/dist/presentations.v2.js +11 -1
- package/dist/libs/contracts/dist/prompt.js +1 -1
- package/dist/libs/contracts/dist/promptRegistry.js +1 -1
- package/dist/libs/contracts/dist/regenerator/index.js +1 -1
- package/dist/libs/contracts/dist/regenerator/service.js +6 -1
- package/dist/libs/contracts/dist/registry.js +2 -1
- package/dist/libs/contracts/dist/resources.js +1 -1
- package/dist/libs/contracts/dist/schema/dist/EnumType.js +2 -1
- package/dist/libs/contracts/dist/schema/dist/FieldType.js +49 -1
- package/dist/libs/contracts/dist/schema/dist/ScalarTypeEnum.js +236 -1
- package/dist/libs/contracts/dist/schema/dist/SchemaModel.js +39 -1
- package/dist/libs/contracts/dist/schema/dist/entity/defineEntity.js +1 -1
- package/dist/libs/contracts/dist/schema/dist/entity/index.js +2 -1
- package/dist/libs/contracts/dist/schema/dist/entity/types.js +1 -1
- package/dist/libs/contracts/dist/schema/dist/index.js +6 -1
- package/dist/libs/contracts/dist/server/graphql-pothos.js +6 -1
- package/dist/libs/contracts/dist/server/index.js +8 -1
- package/dist/libs/contracts/dist/server/mcp/createMcpServer.js +4 -1
- package/dist/libs/contracts/dist/server/mcp/registerPresentations.js +2 -1
- package/dist/libs/contracts/dist/server/mcp/registerPrompts.js +1 -1
- package/dist/libs/contracts/dist/server/mcp/registerResources.js +2 -1
- package/dist/libs/contracts/dist/server/mcp/registerTools.js +1 -1
- package/dist/libs/contracts/dist/server/provider-mcp.js +1 -1
- package/dist/libs/contracts/dist/server/rest-elysia.js +1 -1
- package/dist/libs/contracts/dist/server/rest-express.js +1 -1
- package/dist/libs/contracts/dist/server/rest-generic.js +1 -1
- package/dist/libs/contracts/dist/server/rest-next-app.js +1 -1
- package/dist/libs/contracts/dist/server/rest-next-pages.js +1 -1
- package/dist/libs/contracts/dist/spec.js +34 -1
- package/dist/libs/contracts/dist/telemetry/index.js +1 -1
- package/dist/libs/contracts/dist/telemetry/tracker.js +1 -1
- package/dist/libs/contracts/dist/tests/index.js +1 -1
- package/dist/libs/contracts/dist/tests/runner.js +2 -1
- package/dist/libs/contracts/dist/workflow/index.js +1 -1
- package/dist/libs/contracts/dist/workflow/runner.js +1 -1
- package/dist/libs/schema/dist/EnumType.js +56 -1
- package/dist/libs/schema/dist/FieldType.js +49 -1
- package/dist/libs/schema/dist/ScalarTypeEnum.js +236 -1
- package/dist/libs/schema/dist/SchemaModel.js +3 -1
- package/dist/libs/schema/dist/entity/defineEntity.js +236 -1
- package/dist/libs/schema/dist/entity/index.js +2 -1
- package/dist/libs/schema/dist/entity/types.js +1 -1
- package/dist/libs/schema/dist/index.js +6 -1
- package/dist/notifications.feature.js +68 -1
- package/dist/templates/index.js +195 -3
- package/package.json +6 -6
|
@@ -1 +1,236 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import * as z$1 from "zod";
|
|
2
|
+
|
|
3
|
+
//#region ../../libs/schema/dist/entity/defineEntity.js
|
|
4
|
+
/**
|
|
5
|
+
* Helper to define a database entity with full type safety.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const UserEntity = defineEntity({
|
|
10
|
+
* name: 'User',
|
|
11
|
+
* schema: 'lssm_sigil',
|
|
12
|
+
* description: 'A user of the platform.',
|
|
13
|
+
* fields: {
|
|
14
|
+
* id: field.id(),
|
|
15
|
+
* email: field.string({ isUnique: true, zod: z.string().email() }),
|
|
16
|
+
* name: field.string({ isOptional: true }),
|
|
17
|
+
* createdAt: field.createdAt(),
|
|
18
|
+
* updatedAt: field.updatedAt(),
|
|
19
|
+
* memberships: field.hasMany('Member'),
|
|
20
|
+
* },
|
|
21
|
+
* indexes: [{ fields: ['email'], unique: true }],
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
function defineEntity(spec) {
|
|
26
|
+
return spec;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Helper to define an enum that can be shared across entities.
|
|
30
|
+
*/
|
|
31
|
+
function defineEntityEnum(def) {
|
|
32
|
+
return def;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Field builder helpers for common field patterns.
|
|
36
|
+
*/
|
|
37
|
+
const field = {
|
|
38
|
+
string(opts) {
|
|
39
|
+
return {
|
|
40
|
+
kind: "scalar",
|
|
41
|
+
type: "String",
|
|
42
|
+
...opts
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
int(opts) {
|
|
46
|
+
return {
|
|
47
|
+
kind: "scalar",
|
|
48
|
+
type: "Int",
|
|
49
|
+
...opts
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
float(opts) {
|
|
53
|
+
return {
|
|
54
|
+
kind: "scalar",
|
|
55
|
+
type: "Float",
|
|
56
|
+
...opts
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
boolean(opts) {
|
|
60
|
+
return {
|
|
61
|
+
kind: "scalar",
|
|
62
|
+
type: "Boolean",
|
|
63
|
+
...opts
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
dateTime(opts) {
|
|
67
|
+
return {
|
|
68
|
+
kind: "scalar",
|
|
69
|
+
type: "DateTime",
|
|
70
|
+
...opts
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
json(opts) {
|
|
74
|
+
return {
|
|
75
|
+
kind: "scalar",
|
|
76
|
+
type: "Json",
|
|
77
|
+
...opts
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
bigInt(opts) {
|
|
81
|
+
return {
|
|
82
|
+
kind: "scalar",
|
|
83
|
+
type: "BigInt",
|
|
84
|
+
...opts
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
decimal(opts) {
|
|
88
|
+
return {
|
|
89
|
+
kind: "scalar",
|
|
90
|
+
type: "Decimal",
|
|
91
|
+
...opts
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
bytes(opts) {
|
|
95
|
+
return {
|
|
96
|
+
kind: "scalar",
|
|
97
|
+
type: "Bytes",
|
|
98
|
+
...opts
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
id(opts) {
|
|
102
|
+
return {
|
|
103
|
+
kind: "scalar",
|
|
104
|
+
type: "String",
|
|
105
|
+
isId: true,
|
|
106
|
+
default: "cuid()",
|
|
107
|
+
...opts
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
uuid(opts) {
|
|
111
|
+
return {
|
|
112
|
+
kind: "scalar",
|
|
113
|
+
type: "String",
|
|
114
|
+
isId: true,
|
|
115
|
+
default: "uuid()",
|
|
116
|
+
...opts
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
autoIncrement(opts) {
|
|
120
|
+
return {
|
|
121
|
+
kind: "scalar",
|
|
122
|
+
type: "Int",
|
|
123
|
+
isId: true,
|
|
124
|
+
default: "autoincrement()",
|
|
125
|
+
...opts
|
|
126
|
+
};
|
|
127
|
+
},
|
|
128
|
+
createdAt(opts) {
|
|
129
|
+
return {
|
|
130
|
+
kind: "scalar",
|
|
131
|
+
type: "DateTime",
|
|
132
|
+
default: "now()",
|
|
133
|
+
...opts
|
|
134
|
+
};
|
|
135
|
+
},
|
|
136
|
+
updatedAt(opts) {
|
|
137
|
+
return {
|
|
138
|
+
kind: "scalar",
|
|
139
|
+
type: "DateTime",
|
|
140
|
+
updatedAt: true,
|
|
141
|
+
...opts
|
|
142
|
+
};
|
|
143
|
+
},
|
|
144
|
+
email(opts) {
|
|
145
|
+
return {
|
|
146
|
+
kind: "scalar",
|
|
147
|
+
type: "String",
|
|
148
|
+
zod: z$1.email(),
|
|
149
|
+
...opts
|
|
150
|
+
};
|
|
151
|
+
},
|
|
152
|
+
url(opts) {
|
|
153
|
+
return {
|
|
154
|
+
kind: "scalar",
|
|
155
|
+
type: "String",
|
|
156
|
+
zod: z$1.url(),
|
|
157
|
+
...opts
|
|
158
|
+
};
|
|
159
|
+
},
|
|
160
|
+
enum(enumName, opts) {
|
|
161
|
+
return {
|
|
162
|
+
kind: "enum",
|
|
163
|
+
enumName,
|
|
164
|
+
...opts
|
|
165
|
+
};
|
|
166
|
+
},
|
|
167
|
+
inlineEnum(enumName, values, opts) {
|
|
168
|
+
return {
|
|
169
|
+
kind: "enum",
|
|
170
|
+
enumName,
|
|
171
|
+
values,
|
|
172
|
+
...opts
|
|
173
|
+
};
|
|
174
|
+
},
|
|
175
|
+
hasOne(target, opts) {
|
|
176
|
+
return {
|
|
177
|
+
kind: "relation",
|
|
178
|
+
type: "hasOne",
|
|
179
|
+
target,
|
|
180
|
+
...opts
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
hasMany(target, opts) {
|
|
184
|
+
return {
|
|
185
|
+
kind: "relation",
|
|
186
|
+
type: "hasMany",
|
|
187
|
+
target,
|
|
188
|
+
...opts
|
|
189
|
+
};
|
|
190
|
+
},
|
|
191
|
+
belongsTo(target, fields, references, opts) {
|
|
192
|
+
return {
|
|
193
|
+
kind: "relation",
|
|
194
|
+
type: "belongsTo",
|
|
195
|
+
target,
|
|
196
|
+
fields,
|
|
197
|
+
references,
|
|
198
|
+
...opts
|
|
199
|
+
};
|
|
200
|
+
},
|
|
201
|
+
foreignKey(opts) {
|
|
202
|
+
return {
|
|
203
|
+
kind: "scalar",
|
|
204
|
+
type: "String",
|
|
205
|
+
...opts
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Index builder helpers.
|
|
211
|
+
*/
|
|
212
|
+
const index = {
|
|
213
|
+
on(fields, opts) {
|
|
214
|
+
return {
|
|
215
|
+
fields,
|
|
216
|
+
...opts
|
|
217
|
+
};
|
|
218
|
+
},
|
|
219
|
+
unique(fields, opts) {
|
|
220
|
+
return {
|
|
221
|
+
fields,
|
|
222
|
+
unique: true,
|
|
223
|
+
...opts
|
|
224
|
+
};
|
|
225
|
+
},
|
|
226
|
+
compound(fields, sort, opts) {
|
|
227
|
+
return {
|
|
228
|
+
fields,
|
|
229
|
+
sort,
|
|
230
|
+
...opts
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
//#endregion
|
|
236
|
+
export { defineEntity, defineEntityEnum, field, index };
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { defineEntity, defineEntityEnum, field, index } from "./defineEntity.js";
|
|
2
|
+
import "./types.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"zod";
|
|
1
|
+
import "zod";
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { EnumType, defineEnum } from "./EnumType.js";
|
|
2
|
+
import { FieldType } from "./FieldType.js";
|
|
3
|
+
import { ScalarTypeEnum } from "./ScalarTypeEnum.js";
|
|
4
|
+
import "./SchemaModel.js";
|
|
5
|
+
import { defineEntity, defineEntityEnum, field, index } from "./entity/defineEntity.js";
|
|
6
|
+
import "./entity/index.js";
|
|
@@ -1 +1,68 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/notifications.feature.ts
|
|
2
|
+
/**
|
|
3
|
+
* Notifications feature module that bundles notification sending,
|
|
4
|
+
* listing, marking as read, and preference management capabilities.
|
|
5
|
+
*/
|
|
6
|
+
const NotificationsFeature = {
|
|
7
|
+
meta: {
|
|
8
|
+
key: "notifications",
|
|
9
|
+
title: "Notifications",
|
|
10
|
+
description: "Multi-channel notification delivery with preference management",
|
|
11
|
+
domain: "platform",
|
|
12
|
+
owners: ["@platform.notifications"],
|
|
13
|
+
tags: [
|
|
14
|
+
"notifications",
|
|
15
|
+
"email",
|
|
16
|
+
"push",
|
|
17
|
+
"in-app"
|
|
18
|
+
],
|
|
19
|
+
stability: "stable"
|
|
20
|
+
},
|
|
21
|
+
operations: [
|
|
22
|
+
{
|
|
23
|
+
name: "notifications.send",
|
|
24
|
+
version: 1
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "notifications.markRead",
|
|
28
|
+
version: 1
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "notifications.markAllRead",
|
|
32
|
+
version: 1
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "notifications.delete",
|
|
36
|
+
version: 1
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "notifications.list",
|
|
40
|
+
version: 1
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "notifications.preferences.update",
|
|
44
|
+
version: 1
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "notifications.preferences.get",
|
|
48
|
+
version: 1
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
events: [],
|
|
52
|
+
presentations: [],
|
|
53
|
+
opToPresentation: [],
|
|
54
|
+
presentationsTargets: [],
|
|
55
|
+
capabilities: {
|
|
56
|
+
provides: [{
|
|
57
|
+
key: "notifications",
|
|
58
|
+
version: 1
|
|
59
|
+
}],
|
|
60
|
+
requires: [{
|
|
61
|
+
key: "identity",
|
|
62
|
+
version: 1
|
|
63
|
+
}]
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
export { NotificationsFeature };
|
package/dist/templates/index.js
CHANGED
|
@@ -1,9 +1,201 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/templates/index.ts
|
|
2
|
+
/**
|
|
3
|
+
* Define a notification template.
|
|
4
|
+
*/
|
|
5
|
+
function defineTemplate(def) {
|
|
6
|
+
return def;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Render a template with variables.
|
|
10
|
+
*/
|
|
11
|
+
function renderTemplate(content, variables) {
|
|
12
|
+
return content.replace(/\{\{(\w+)\}\}/g, (match, key) => {
|
|
13
|
+
const value = variables[key];
|
|
14
|
+
if (value === void 0 || value === null) return match;
|
|
15
|
+
return String(value);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Render a notification template for a specific channel.
|
|
20
|
+
*/
|
|
21
|
+
function renderNotificationTemplate(template, channel, variables) {
|
|
22
|
+
const channelContent = template.channels[channel];
|
|
23
|
+
if (!channelContent) return null;
|
|
24
|
+
const title = channelContent.title ? renderTemplate(channelContent.title, variables) : template.name;
|
|
25
|
+
const body = renderTemplate(channelContent.body, variables);
|
|
26
|
+
const result = {
|
|
27
|
+
title,
|
|
28
|
+
body,
|
|
29
|
+
actionUrl: channelContent.actionUrl ? renderTemplate(channelContent.actionUrl, variables) : void 0
|
|
30
|
+
};
|
|
31
|
+
if (channel === "email" && channelContent.subject) result.email = {
|
|
32
|
+
subject: renderTemplate(channelContent.subject, variables),
|
|
33
|
+
html: body,
|
|
34
|
+
text: stripHtml(body)
|
|
35
|
+
};
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Strip HTML tags from content (for plain text).
|
|
40
|
+
*/
|
|
41
|
+
function stripHtml(html) {
|
|
42
|
+
return html.replace(/<[^>]*>/g, "").replace(/\s+/g, " ").trim();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Template registry for managing templates.
|
|
46
|
+
*/
|
|
47
|
+
var TemplateRegistry = class {
|
|
48
|
+
templates = /* @__PURE__ */ new Map();
|
|
49
|
+
register(template) {
|
|
50
|
+
this.templates.set(template.id, template);
|
|
51
|
+
}
|
|
52
|
+
get(templateId) {
|
|
53
|
+
return this.templates.get(templateId);
|
|
54
|
+
}
|
|
55
|
+
getAll() {
|
|
56
|
+
return Array.from(this.templates.values());
|
|
57
|
+
}
|
|
58
|
+
getByCategory(category) {
|
|
59
|
+
return this.getAll().filter((t) => t.category === category);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Create a template registry.
|
|
64
|
+
*/
|
|
65
|
+
function createTemplateRegistry() {
|
|
66
|
+
return new TemplateRegistry();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Welcome email template.
|
|
70
|
+
*/
|
|
71
|
+
const WelcomeTemplate = defineTemplate({
|
|
72
|
+
id: "welcome",
|
|
73
|
+
name: "Welcome",
|
|
74
|
+
description: "Sent when a user signs up.",
|
|
75
|
+
category: "onboarding",
|
|
76
|
+
variables: [
|
|
77
|
+
{
|
|
78
|
+
name: "name",
|
|
79
|
+
type: "string",
|
|
80
|
+
required: true
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "appName",
|
|
84
|
+
type: "string",
|
|
85
|
+
default: "ContractSpec"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "actionUrl",
|
|
89
|
+
type: "url"
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
defaultChannels: ["EMAIL", "IN_APP"],
|
|
93
|
+
channels: {
|
|
94
|
+
email: {
|
|
95
|
+
subject: "Welcome to {{appName}}, {{name}}!",
|
|
96
|
+
body: `
|
|
2
97
|
<h1>Welcome, {{name}}!</h1>
|
|
3
98
|
<p>Thanks for joining {{appName}}. We're excited to have you on board.</p>
|
|
4
99
|
<p><a href="{{actionUrl}}">Get started now</a></p>
|
|
5
|
-
`
|
|
100
|
+
`
|
|
101
|
+
},
|
|
102
|
+
inApp: {
|
|
103
|
+
title: "Welcome to {{appName}}!",
|
|
104
|
+
body: "Thanks for joining. Click to complete your profile.",
|
|
105
|
+
actionUrl: "{{actionUrl}}"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
/**
|
|
110
|
+
* Organization invite template.
|
|
111
|
+
*/
|
|
112
|
+
const OrgInviteTemplate = defineTemplate({
|
|
113
|
+
id: "org-invite",
|
|
114
|
+
name: "Organization Invitation",
|
|
115
|
+
description: "Sent when a user is invited to an organization.",
|
|
116
|
+
category: "organization",
|
|
117
|
+
variables: [
|
|
118
|
+
{
|
|
119
|
+
name: "inviterName",
|
|
120
|
+
type: "string",
|
|
121
|
+
required: true
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "orgName",
|
|
125
|
+
type: "string",
|
|
126
|
+
required: true
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: "role",
|
|
130
|
+
type: "string",
|
|
131
|
+
default: "member"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "actionUrl",
|
|
135
|
+
type: "url",
|
|
136
|
+
required: true
|
|
137
|
+
}
|
|
138
|
+
],
|
|
139
|
+
defaultChannels: ["EMAIL"],
|
|
140
|
+
channels: {
|
|
141
|
+
email: {
|
|
142
|
+
subject: "{{inviterName}} invited you to join {{orgName}}",
|
|
143
|
+
body: `
|
|
6
144
|
<h1>You've been invited!</h1>
|
|
7
145
|
<p>{{inviterName}} has invited you to join <strong>{{orgName}}</strong> as a {{role}}.</p>
|
|
8
146
|
<p><a href="{{actionUrl}}">Accept invitation</a></p>
|
|
9
|
-
`
|
|
147
|
+
`
|
|
148
|
+
},
|
|
149
|
+
inApp: {
|
|
150
|
+
title: "Invitation to {{orgName}}",
|
|
151
|
+
body: "{{inviterName}} invited you to join as {{role}}.",
|
|
152
|
+
actionUrl: "{{actionUrl}}",
|
|
153
|
+
actionText: "Accept"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
/**
|
|
158
|
+
* Mention template.
|
|
159
|
+
*/
|
|
160
|
+
const MentionTemplate = defineTemplate({
|
|
161
|
+
id: "mention",
|
|
162
|
+
name: "Mention",
|
|
163
|
+
description: "Sent when a user is mentioned.",
|
|
164
|
+
category: "social",
|
|
165
|
+
variables: [
|
|
166
|
+
{
|
|
167
|
+
name: "mentionerName",
|
|
168
|
+
type: "string",
|
|
169
|
+
required: true
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: "context",
|
|
173
|
+
type: "string",
|
|
174
|
+
required: true
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: "preview",
|
|
178
|
+
type: "string"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: "actionUrl",
|
|
182
|
+
type: "url",
|
|
183
|
+
required: true
|
|
184
|
+
}
|
|
185
|
+
],
|
|
186
|
+
defaultChannels: ["IN_APP", "PUSH"],
|
|
187
|
+
channels: {
|
|
188
|
+
inApp: {
|
|
189
|
+
title: "{{mentionerName}} mentioned you",
|
|
190
|
+
body: "In {{context}}: \"{{preview}}\"",
|
|
191
|
+
actionUrl: "{{actionUrl}}"
|
|
192
|
+
},
|
|
193
|
+
push: {
|
|
194
|
+
title: "{{mentionerName}} mentioned you",
|
|
195
|
+
body: "{{preview}}"
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
//#endregion
|
|
201
|
+
export { MentionTemplate, OrgInviteTemplate, TemplateRegistry, WelcomeTemplate, createTemplateRegistry, defineTemplate, renderNotificationTemplate, renderTemplate };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/module.notifications",
|
|
3
|
-
"version": "0.0.0-canary-
|
|
3
|
+
"version": "0.0.0-canary-20251217072406",
|
|
4
4
|
"description": "Notification center module for ContractSpec applications",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
"lint:check": "eslint src"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@lssm/lib.schema": "0.0.0-canary-
|
|
22
|
-
"@lssm/lib.contracts": "0.0.0-canary-
|
|
23
|
-
"@lssm/lib.bus": "0.0.0-canary-
|
|
21
|
+
"@lssm/lib.schema": "0.0.0-canary-20251217072406",
|
|
22
|
+
"@lssm/lib.contracts": "0.0.0-canary-20251217072406",
|
|
23
|
+
"@lssm/lib.bus": "0.0.0-canary-20251217072406",
|
|
24
24
|
"zod": "^4.1.13"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@lssm/tool.typescript": "0.0.0-canary-
|
|
28
|
-
"@lssm/tool.tsdown": "0.0.0-canary-
|
|
27
|
+
"@lssm/tool.typescript": "0.0.0-canary-20251217072406",
|
|
28
|
+
"@lssm/tool.tsdown": "0.0.0-canary-20251217072406",
|
|
29
29
|
"typescript": "^5.9.3"
|
|
30
30
|
},
|
|
31
31
|
"exports": {
|