@node-in-layers/notifications 0.0.0-stage → 1.0.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.
- package/README.md +605 -2
- package/backend/features.d.ts +5 -0
- package/backend/features.js +350 -0
- package/backend/features.js.map +1 -0
- package/backend/index.d.ts +6 -0
- package/backend/index.js +7 -0
- package/backend/index.js.map +1 -0
- package/backend/internal-libs.d.ts +63 -0
- package/backend/internal-libs.js +100 -0
- package/backend/internal-libs.js.map +1 -0
- package/backend/libs.d.ts +23 -0
- package/backend/libs.js +48 -0
- package/backend/libs.js.map +1 -0
- package/backend/services.d.ts +4 -0
- package/backend/services.js +57 -0
- package/backend/services.js.map +1 -0
- package/backend/types.d.ts +36 -0
- package/backend/types.js +2 -0
- package/backend/types.js.map +1 -0
- package/core/features.d.ts +4 -0
- package/core/features.js +6 -0
- package/core/features.js.map +1 -0
- package/core/index.d.ts +7 -0
- package/core/index.js +8 -0
- package/core/index.js.map +1 -0
- package/core/internal-libs.d.ts +5 -0
- package/core/internal-libs.js +34 -0
- package/core/internal-libs.js.map +1 -0
- package/core/libs.d.ts +28 -0
- package/core/libs.js +57 -0
- package/core/libs.js.map +1 -0
- package/core/models/NotificationConfigs.d.ts +13 -0
- package/core/models/NotificationConfigs.js +44 -0
- package/core/models/NotificationConfigs.js.map +1 -0
- package/core/models/NotificationTemplates.d.ts +11 -0
- package/core/models/NotificationTemplates.js +40 -0
- package/core/models/NotificationTemplates.js.map +1 -0
- package/core/models/Notifications.d.ts +49 -0
- package/core/models/Notifications.js +94 -0
- package/core/models/Notifications.js.map +1 -0
- package/core/models/index.d.ts +3 -0
- package/core/models/index.js +4 -0
- package/core/models/index.js.map +1 -0
- package/core/services.d.ts +4 -0
- package/core/services.js +6 -0
- package/core/services.js.map +1 -0
- package/core/types.d.ts +323 -0
- package/core/types.js +220 -0
- package/core/types.js.map +1 -0
- package/index.d.ts +4 -0
- package/index.js +5 -0
- package/index.js.map +1 -0
- package/package.json +99 -4
- package/types.d.ts +55 -0
- package/types.js +6 -0
- package/types.js.map +1 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import nodemailer from 'nodemailer';
|
|
11
|
+
import { createErrorObject, isErrorObject, } from '@node-in-layers/core';
|
|
12
|
+
import { NotificationsNamespace } from '../types.js';
|
|
13
|
+
export const create = (context) => {
|
|
14
|
+
const sendEmail = (props, crossLayerProps) => {
|
|
15
|
+
return Promise.resolve().then(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
var _a, _b, _c, _d, _e;
|
|
17
|
+
var _f, _g, _h, _j;
|
|
18
|
+
const log = context.log.getInnerLogger('sendEmail', crossLayerProps);
|
|
19
|
+
const emailConfig = (_a = context.config[NotificationsNamespace.Backend]) === null || _a === void 0 ? void 0 : _a.email;
|
|
20
|
+
if (!emailConfig) {
|
|
21
|
+
return createErrorObject('EMAIL_CONFIG_MISSING', 'Email configuration is required to send email notifications.');
|
|
22
|
+
}
|
|
23
|
+
if (props.to.length === 0) {
|
|
24
|
+
return createErrorObject('EMAIL_RECIPIENTS_MISSING', 'At least one email recipient is required.');
|
|
25
|
+
}
|
|
26
|
+
const transporter = nodemailer.createTransport(Object.assign({ host: emailConfig.host, port: emailConfig.port, secure: emailConfig.secure, auth: emailConfig.auth }, ((_f = emailConfig.transportOptions) !== null && _f !== void 0 ? _f : {})));
|
|
27
|
+
const result = yield transporter
|
|
28
|
+
.sendMail({
|
|
29
|
+
from: (_g = props.from) !== null && _g !== void 0 ? _g : emailConfig.from,
|
|
30
|
+
to: props.to.join(', '),
|
|
31
|
+
cc: (_b = props.cc) === null || _b === void 0 ? void 0 : _b.join(', '),
|
|
32
|
+
bcc: (_c = props.bcc) === null || _c === void 0 ? void 0 : _c.join(', '),
|
|
33
|
+
replyTo: props.replyTo,
|
|
34
|
+
subject: props.subject,
|
|
35
|
+
text: props.text,
|
|
36
|
+
html: props.html,
|
|
37
|
+
})
|
|
38
|
+
.catch(error => {
|
|
39
|
+
const errorObject = createErrorObject('EMAIL_SEND_FAILED', 'Failed to send email notification.', error);
|
|
40
|
+
log.error('Failed to send email notification', errorObject);
|
|
41
|
+
return errorObject;
|
|
42
|
+
});
|
|
43
|
+
if (isErrorObject(result)) {
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
messageId: result.messageId,
|
|
48
|
+
accepted: (_h = (_d = result.accepted) === null || _d === void 0 ? void 0 : _d.map(String)) !== null && _h !== void 0 ? _h : [],
|
|
49
|
+
rejected: (_j = (_e = result.rejected) === null || _e === void 0 ? void 0 : _e.map(String)) !== null && _j !== void 0 ? _j : [],
|
|
50
|
+
};
|
|
51
|
+
}));
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
sendEmail,
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=services.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.js","sourceRoot":"","sources":["../../src/backend/services.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,EAGL,iBAAiB,EACjB,aAAa,GACd,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAA2B,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAG7E,MAAM,CAAC,M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AC,OAAO;gBACtB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,IAAI,EAAE,KAAK,CAAC,IAAI;aACjB,CAAC;iBACD,KAAK,CAAC,KAAK,CAAC,EAAE;gBACb,MAAM,WAAW,GAAG,iBAAiB,CACnC,mBAAmB,EACnB,oCAAoC,EACpC,KAAK,CACN,CAAA;gBACD,GAAG,CAAC,KAAK,CAAC,mCAAmC,EAAE,WAAW,CAAC,CAAA;gBAC3D,OAAO,WAAW,CAAA;YACpB,CAAC,CAAC,CAAA;YAEJ,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC1B,OAAO,MAAM,CAAA;YACf,CAAC;YAED,OAAO;gBACL,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,QAAQ,QAAE,MAAA,MAAM,CAAC,QAAQ,0CAAE,GAAG,CAAC,MAAM,CAAC,mCAAI,EAAE;gBAC5C,QAAQ,QAAE,MAAA,MAAM,CAAC,QAAQ,0CAAE,GAAG,CAAC,MAAM,CAAC,mCAAI,EAAE;aAC7C,CAAA;QACH,CAAC,CAAA,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,OAAO;QACL,SAAS;KACV,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CrossLayerProps, LayerFunction, Response } from '@node-in-layers/core';
|
|
2
|
+
import { NotificationsPublicFeatures } from '../core/types.js';
|
|
3
|
+
import { ConfigWithNotifications, NotificationsNamespace } from '../types.js';
|
|
4
|
+
export type SendEmailServiceProps = Readonly<{
|
|
5
|
+
from?: string;
|
|
6
|
+
to: readonly string[];
|
|
7
|
+
cc?: readonly string[];
|
|
8
|
+
bcc?: readonly string[];
|
|
9
|
+
replyTo?: string;
|
|
10
|
+
subject: string;
|
|
11
|
+
text?: string;
|
|
12
|
+
html?: string;
|
|
13
|
+
}>;
|
|
14
|
+
export type SendEmailServiceResult = Readonly<{
|
|
15
|
+
messageId?: string;
|
|
16
|
+
accepted?: readonly string[];
|
|
17
|
+
rejected?: readonly string[];
|
|
18
|
+
}>;
|
|
19
|
+
export type BackendServices = Readonly<{
|
|
20
|
+
sendEmail: LayerFunction<(props: SendEmailServiceProps) => Promise<Response<SendEmailServiceResult>>>;
|
|
21
|
+
}>;
|
|
22
|
+
export type BackendServicesLayer = Readonly<{
|
|
23
|
+
[NotificationsNamespace.Backend]: BackendServices;
|
|
24
|
+
}>;
|
|
25
|
+
export type FailureNotificationMetadata = Readonly<{
|
|
26
|
+
domain: string;
|
|
27
|
+
functionName: string;
|
|
28
|
+
}>;
|
|
29
|
+
export type FailureWrappableFunction = (props: any, crossLayerProps?: CrossLayerProps) => any;
|
|
30
|
+
export type BackendFeatures = NotificationsPublicFeatures & Readonly<{
|
|
31
|
+
wrapWithFailureNotification: <TFunction extends FailureWrappableFunction>(metadata: FailureNotificationMetadata, method: TFunction) => TFunction;
|
|
32
|
+
}>;
|
|
33
|
+
export type BackendFeaturesLayer = Readonly<{
|
|
34
|
+
[NotificationsNamespace.Backend]: BackendFeatures;
|
|
35
|
+
}>;
|
|
36
|
+
export type BackendConfig = ConfigWithNotifications;
|
package/backend/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/backend/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2B,sBAAsB,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FeaturesContext } from '@node-in-layers/core';
|
|
2
|
+
import { ConfigWithNotifications } from '../types.js';
|
|
3
|
+
import { CoreFeatures, CoreFeaturesLayer, CoreServicesLayer } from './types.js';
|
|
4
|
+
export declare const create: (context: FeaturesContext<ConfigWithNotifications, CoreServicesLayer, CoreFeaturesLayer>) => CoreFeatures;
|
package/core/features.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features.js","sourceRoot":"","sources":["../../src/core/features.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,MAAM,GAAG;AACpB,6DAA6D;AAC7D,OAIC,EACa,EAAE;IAChB,OAAO,EAAE,CAAA;AACX,CAAC,CAAA"}
|
package/core/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NotificationsNamespace } from '../types.js';
|
|
2
|
+
export * as services from './services.js';
|
|
3
|
+
export * as features from './features.js';
|
|
4
|
+
export * as models from './models/index.js';
|
|
5
|
+
export * as libs from './libs.js';
|
|
6
|
+
export * from './types.js';
|
|
7
|
+
export declare const name = NotificationsNamespace.Core;
|
package/core/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NotificationsNamespace } from '../types.js';
|
|
2
|
+
export * as services from './services.js';
|
|
3
|
+
export * as features from './features.js';
|
|
4
|
+
export * as models from './models/index.js';
|
|
5
|
+
export * as libs from './libs.js';
|
|
6
|
+
export * from './types.js';
|
|
7
|
+
export const name = NotificationsNamespace.Core;
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEpD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,cAAc,YAAY,CAAA;AAE1B,MAAM,CAAC,MAAM,IAAI,GAAG,sBAAsB,CAAC,IAAI,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CoreNotificationsConfig } from '../types.js';
|
|
2
|
+
export declare const defaultNotificationTtlSeconds: number;
|
|
3
|
+
export declare const createNotificationTtlLazyLoadMethod: (args: Readonly<{
|
|
4
|
+
coreConfig: CoreNotificationsConfig | undefined;
|
|
5
|
+
}>) => (value: number | undefined) => number | undefined;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createTTL } from './libs.js';
|
|
2
|
+
const hoursPerDay = 24;
|
|
3
|
+
const minutesPerHour = 60;
|
|
4
|
+
const secondsPerMinute = 60;
|
|
5
|
+
const defaultNotificationTtlDays = 90;
|
|
6
|
+
const millisecondsPerSecond = 1000;
|
|
7
|
+
export const defaultNotificationTtlSeconds = defaultNotificationTtlDays * hoursPerDay * minutesPerHour * secondsPerMinute;
|
|
8
|
+
const resolveDefaultTtlSeconds = (coreConfig) => {
|
|
9
|
+
var _a;
|
|
10
|
+
if ((coreConfig === null || coreConfig === void 0 ? void 0 : coreConfig.noTTL) === true) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
return (_a = coreConfig === null || coreConfig === void 0 ? void 0 : coreConfig.defaultTtl) !== null && _a !== void 0 ? _a : defaultNotificationTtlSeconds;
|
|
14
|
+
};
|
|
15
|
+
const createNotificationTtlFromSecondsFromNow = (args) => {
|
|
16
|
+
return createTTL({
|
|
17
|
+
datetime: new Date(Date.now() + args.secondsFromNow * millisecondsPerSecond),
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
export const createNotificationTtlLazyLoadMethod = (args) => {
|
|
21
|
+
return (value) => {
|
|
22
|
+
if (value !== undefined && value !== null) {
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
const defaultTtlSeconds = resolveDefaultTtlSeconds(args.coreConfig);
|
|
26
|
+
if (defaultTtlSeconds === undefined) {
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
return createNotificationTtlFromSecondsFromNow({
|
|
30
|
+
secondsFromNow: defaultTtlSeconds,
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=internal-libs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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AAC;QACD,OAAO,uCAAuC,CAAC;YAC7C,cAAc,EAAE,iBAAiB;SAClC,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC,CAAA"}
|
package/core/libs.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { JsonObj } from 'functional-models';
|
|
2
|
+
import { Notification, NotificationChannel } from './types.js';
|
|
3
|
+
export declare const defaultSystemTextTemplate = "{{title}}\n\n{{message}}\n\nSystem: {{systemName}}\nEnvironment: {{environment}}\nRuntime: {{runtimeId}}\nTime: {{datetime}}";
|
|
4
|
+
export declare const defaultExecutionFailureTextTemplate = "{{domain}}.{{functionName}} failed\n\n{{error.message}}\n\n{{#if error.code}}Code: {{error.code}}\n{{/if}}{{#if error.details}}Details: {{error.details}}\n{{/if}}{{#if error.trace}}Trace:\n{{error.trace}}{{/if}}";
|
|
5
|
+
export declare const defaultUserTextTemplate = "{{message}}";
|
|
6
|
+
export declare const createTTL: (args: Readonly<{
|
|
7
|
+
datetime: Date | string;
|
|
8
|
+
}>) => number;
|
|
9
|
+
export declare const renderTemplate: (args: Readonly<{
|
|
10
|
+
template: string;
|
|
11
|
+
data: JsonObj;
|
|
12
|
+
noEscape?: boolean;
|
|
13
|
+
}>) => string;
|
|
14
|
+
export declare const buildTemplateData: (args: Readonly<{
|
|
15
|
+
notification: Notification;
|
|
16
|
+
channel: NotificationChannel | string;
|
|
17
|
+
}>) => JsonObj;
|
|
18
|
+
export declare const renderNotificationTemplate: (args: Readonly<{
|
|
19
|
+
template: string;
|
|
20
|
+
notification: Notification;
|
|
21
|
+
channel: NotificationChannel | string;
|
|
22
|
+
}>) => string;
|
|
23
|
+
export declare const parseNotifierTarget: (args: Readonly<{
|
|
24
|
+
notifier: string;
|
|
25
|
+
}>) => Readonly<{
|
|
26
|
+
domain: string;
|
|
27
|
+
feature: string;
|
|
28
|
+
}>;
|
package/core/libs.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import Handlebars from 'handlebars';
|
|
2
|
+
const millisecondsPerSecond = 1000;
|
|
3
|
+
export const defaultSystemTextTemplate = `{{title}}
|
|
4
|
+
|
|
5
|
+
{{message}}
|
|
6
|
+
|
|
7
|
+
System: {{systemName}}
|
|
8
|
+
Environment: {{environment}}
|
|
9
|
+
Runtime: {{runtimeId}}
|
|
10
|
+
Time: {{datetime}}`;
|
|
11
|
+
export const defaultExecutionFailureTextTemplate = `{{domain}}.{{functionName}} failed
|
|
12
|
+
|
|
13
|
+
{{error.message}}
|
|
14
|
+
|
|
15
|
+
{{#if error.code}}Code: {{error.code}}
|
|
16
|
+
{{/if}}{{#if error.details}}Details: {{error.details}}
|
|
17
|
+
{{/if}}{{#if error.trace}}Trace:
|
|
18
|
+
{{error.trace}}{{/if}}`;
|
|
19
|
+
export const defaultUserTextTemplate = '{{message}}';
|
|
20
|
+
export const createTTL = (args) => {
|
|
21
|
+
const date = args.datetime instanceof Date ? args.datetime : new Date(args.datetime);
|
|
22
|
+
return Math.floor(date.getTime() / millisecondsPerSecond);
|
|
23
|
+
};
|
|
24
|
+
export const renderTemplate = (args) => {
|
|
25
|
+
return Handlebars.compile(args.template, {
|
|
26
|
+
noEscape: args.noEscape,
|
|
27
|
+
})(args.data);
|
|
28
|
+
};
|
|
29
|
+
export const buildTemplateData = (args) => {
|
|
30
|
+
var _a;
|
|
31
|
+
return Object.assign({ title: args.notification.title, message: args.notification.message, severity: args.notification.severity, type: args.notification.type, channel: args.channel }, ((_a = args.notification.data) !== null && _a !== void 0 ? _a : {}));
|
|
32
|
+
};
|
|
33
|
+
export const renderNotificationTemplate = (args) => {
|
|
34
|
+
return renderTemplate({
|
|
35
|
+
template: args.template,
|
|
36
|
+
data: buildTemplateData({
|
|
37
|
+
notification: args.notification,
|
|
38
|
+
channel: args.channel,
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
export const parseNotifierTarget = (args) => {
|
|
43
|
+
const index = args.notifier.lastIndexOf('.');
|
|
44
|
+
if (index === -1) {
|
|
45
|
+
throw new Error(`Invalid notifier "${args.notifier}". Expected "domain.feature".`);
|
|
46
|
+
}
|
|
47
|
+
const domain = args.notifier.slice(0, index).trim();
|
|
48
|
+
const feature = args.notifier.slice(index + 1).trim();
|
|
49
|
+
if (!domain || !feature) {
|
|
50
|
+
throw new Error(`Invalid notifier "${args.notifier}". Expected "domain.feature".`);
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
domain,
|
|
54
|
+
feature,
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=libs.js.map
|
package/core/libs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libs.js","sourceRoot":"","sources":["../../src/core/libs.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAA;AAInC,MAAM,qBAAqB,GAAG,IAAI,CAAA;AAElC,MAAM,CAAC,MAAM,yBAAyB,GAAG;;;;;;;mBAOtB,CAAA;AAEnB,MAAM,CAAC,MAAM,mCAAmC,GAAG;;;;;;;uBAO5B,CAAA;AAEvB,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAAA;AAEpD,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,IAA2C,EACnC,EAAE;IACV,MAAM,IAAI,GACR,IAAI,CAAC,QAAQ,YAAY,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACzE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,qBAAqB,CAAC,CAAA;AAC3D,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,IAAuE,EAC/D,EAAE;IACV,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE;QACvC,QAAQ,EAAE,IAAI,CAAC,QAAQ;KACxB,CAAC,C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AAI,CAAC,OAAO,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,qBAAqB,IAAI,CAAC,QAAQ,+BAA+B,CAClE,CAAA;IACH,CAAC;IACD,OAAO;QACL,MAAM;QACN,OAAO;KACR,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ModelProps } from '@node-in-layers/core';
|
|
2
|
+
import { ConfigWithNotifications } from '../../types.js';
|
|
3
|
+
export declare const create: ({ Model, getPrimaryKeyProperty, }: ModelProps<ConfigWithNotifications>) => import("functional-models").ModelType<Readonly<{
|
|
4
|
+
id: import("functional-models").PrimaryKeyType;
|
|
5
|
+
key: string;
|
|
6
|
+
adminEmails?: readonly string[];
|
|
7
|
+
fromEmail?: string;
|
|
8
|
+
subjectPrefix?: string;
|
|
9
|
+
defaultChannels?: readonly (import("../types.js").NotificationChannel | string)[];
|
|
10
|
+
notifiers?: import("../types.js").NotifiersMap;
|
|
11
|
+
createdAt?: string;
|
|
12
|
+
updatedAt?: string;
|
|
13
|
+
}>, object, object>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ArrayProperty, DatetimeProperty, LastModifiedDateProperty, ObjectProperty, TextProperty, } from 'functional-models';
|
|
2
|
+
import { NotificationsNamespace } from '../../types.js';
|
|
3
|
+
export const create = ({ Model, getPrimaryKeyProperty, }) => {
|
|
4
|
+
return Model({
|
|
5
|
+
pluralName: 'NotificationConfigs',
|
|
6
|
+
singularName: 'NotificationConfig',
|
|
7
|
+
namespace: NotificationsNamespace.Core,
|
|
8
|
+
primaryKeyName: 'id',
|
|
9
|
+
description: 'Database-driven notification configuration overrides.',
|
|
10
|
+
properties: {
|
|
11
|
+
id: getPrimaryKeyProperty(NotificationsNamespace.Core, 'NotificationConfigs', {
|
|
12
|
+
required: true,
|
|
13
|
+
}),
|
|
14
|
+
key: TextProperty({
|
|
15
|
+
required: true,
|
|
16
|
+
description: 'Config lookup key, usually default.',
|
|
17
|
+
}),
|
|
18
|
+
adminEmails: ArrayProperty({
|
|
19
|
+
description: 'Default operational notification recipients.',
|
|
20
|
+
}),
|
|
21
|
+
fromEmail: TextProperty({
|
|
22
|
+
description: 'From address override for email notifications.',
|
|
23
|
+
}),
|
|
24
|
+
subjectPrefix: TextProperty({
|
|
25
|
+
description: 'Subject prefix for email notifications.',
|
|
26
|
+
}),
|
|
27
|
+
defaultChannels: ArrayProperty({
|
|
28
|
+
description: 'Default channel names used when a send omits channels.',
|
|
29
|
+
}),
|
|
30
|
+
notifiers: ObjectProperty({
|
|
31
|
+
description: 'Channel to domain.feature notifier map.',
|
|
32
|
+
}),
|
|
33
|
+
createdAt: DatetimeProperty({
|
|
34
|
+
autoNow: true,
|
|
35
|
+
description: 'When the config row was created.',
|
|
36
|
+
}),
|
|
37
|
+
updatedAt: LastModifiedDateProperty({
|
|
38
|
+
autoNow: true,
|
|
39
|
+
description: 'When the config row was last updated.',
|
|
40
|
+
}),
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=NotificationConfigs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationConfigs.js","sourceRoot":"","sources":["../../../src/core/models/NotificationConfigs.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,wBAAwB,EACxB,cAAc,EACd,YAAY,GACb,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAA2B,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAGhF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EACrB,KAAK,EACL,qBAAqB,GACe,EAAE,EAAE;IACxC,OAAO,KAAK,CAA2B;QACrC,UAAU,EAAE,qBAAqB;QACjC,YAAY,EAAE,oBAAoB;QAClC,SAAS,EAAE,sBAAsB,CAAC,IAAI;QACtC,cAAc,EAAE,IAAI;QACpB,WAAW,EAAE,uDAAuD;QACpE,UAAU,EAAE;YACV,EAAE,EAAE,qBAAqB,CACvB,sBAAsB,CAAC,IAAI,EAC3B,qBAAqB,EACrB;gBACE,QAAQ,EAAE,IAAI;aACf,CACF;YACD,GAAG,EAAE,YAAY,CAAC;gBAChB,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,qCAAqC;aACnD,CAAC;YACF,WAAW,EAAE,aAAa,CAAS;gBACjC,WAAW,EAAE,8CAA8C;aAC5D,CAAC;YACF,SAAS,EAAE,YAAY,CAAC;gBACtB,WAAW,EAAE,gDAAgD;aAC9D,CAAC;YACF,aAAa,EAAE,YAAY,CAAC;gBAC1B,WAAW,EAAE,yCAAyC;aACvD,CAAC;YACF,eAAe,EAAE,aAAa,CAAS;gBACrC,WAAW,EAAE,wDAAwD;aACtE,CAAC;YACF,SAAS,EAAE,cAAc,CAAyB;gBAChD,WAAW,EAAE,yCAAyC;aACvD,CAAC;YACF,SAAS,EAAE,gBAAgB,CAAC;gBAC1B,OAAO,EAAE,IAAI;gBACb,WAAW,EAAE,kCAAkC;aAChD,CAAC;YACF,SAAS,EAAE,wBAAwB,CAAC;gBAClC,OAAO,EAAE,IAAI;gBACb,WAAW,EAAE,uCAAuC;aACrD,CAAC;SACH;KACF,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ModelProps } from '@node-in-layers/core';
|
|
2
|
+
import { ConfigWithNotifications } from '../../types.js';
|
|
3
|
+
export declare const create: ({ Model, getPrimaryKeyProperty, }: ModelProps<ConfigWithNotifications>) => import("functional-models").ModelType<Readonly<{
|
|
4
|
+
id: import("functional-models").PrimaryKeyType;
|
|
5
|
+
channel: string;
|
|
6
|
+
type: string;
|
|
7
|
+
body: string;
|
|
8
|
+
htmlBody?: string;
|
|
9
|
+
createdAt?: string;
|
|
10
|
+
updatedAt?: string;
|
|
11
|
+
}>, object, object>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { DatetimeProperty, LastModifiedDateProperty, TextProperty, } from 'functional-models';
|
|
2
|
+
import { NotificationsNamespace } from '../../types.js';
|
|
3
|
+
export const create = ({ Model, getPrimaryKeyProperty, }) => {
|
|
4
|
+
return Model({
|
|
5
|
+
pluralName: 'NotificationTemplates',
|
|
6
|
+
singularName: 'NotificationTemplate',
|
|
7
|
+
namespace: NotificationsNamespace.Core,
|
|
8
|
+
primaryKeyName: 'id',
|
|
9
|
+
description: 'Database-backed notification templates by channel and type.',
|
|
10
|
+
properties: {
|
|
11
|
+
id: getPrimaryKeyProperty(NotificationsNamespace.Core, 'NotificationTemplates', {
|
|
12
|
+
required: true,
|
|
13
|
+
}),
|
|
14
|
+
channel: TextProperty({
|
|
15
|
+
required: true,
|
|
16
|
+
description: 'Channel name, such as email or sms.',
|
|
17
|
+
}),
|
|
18
|
+
type: TextProperty({
|
|
19
|
+
required: true,
|
|
20
|
+
description: 'Notification type rendered by this template.',
|
|
21
|
+
}),
|
|
22
|
+
body: TextProperty({
|
|
23
|
+
required: true,
|
|
24
|
+
description: 'Handlebars template source.',
|
|
25
|
+
}),
|
|
26
|
+
htmlBody: TextProperty({
|
|
27
|
+
description: 'Optional HTML Handlebars template source for email.',
|
|
28
|
+
}),
|
|
29
|
+
createdAt: DatetimeProperty({
|
|
30
|
+
autoNow: true,
|
|
31
|
+
description: 'When the template row was created.',
|
|
32
|
+
}),
|
|
33
|
+
updatedAt: LastModifiedDateProperty({
|
|
34
|
+
autoNow: true,
|
|
35
|
+
description: 'When the template row was last updated.',
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=NotificationTemplates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationTemplates.js","sourceRoot":"","sources":["../../../src/core/models/NotificationTemplates.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,YAAY,GACb,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAA2B,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAGhF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EACrB,KAAK,EACL,qBAAqB,GACe,EAAE,EAAE;IACxC,OAAO,KAAK,CAA6B;QACvC,UAAU,EAAE,uBAAuB;QACnC,YAAY,EAAE,sBAAsB;QACpC,SAAS,EAAE,sBAAsB,CAAC,IAAI;QACtC,cAAc,EAAE,IAAI;QACpB,WAAW,EAAE,6DAA6D;QAC1E,UAAU,EAAE;YACV,EAAE,EAAE,qBAAqB,CACvB,sBAAsB,CAAC,IAAI,EAC3B,uBAAuB,EACvB;gBACE,QAAQ,EAAE,IAAI;aACf,CACF;YACD,OAAO,EAAE,YAAY,CAAC;gBACpB,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,qCAAqC;aACnD,CAAC;YACF,IAAI,EAAE,YAAY,CAAC;gBACjB,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,8CAA8C;aAC5D,CAAC;YACF,IAAI,EAAE,YAAY,CAAC;gBACjB,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,6BAA6B;aAC3C,CAAC;YACF,QAAQ,EAAE,YAAY,CAAC;gBACrB,WAAW,EAAE,qDAAqD;aACnE,CAAC;YACF,SAAS,EAAE,gBAAgB,CAAC;gBAC1B,OAAO,EAAE,IAAI;gBACb,WAAW,EAAE,oCAAoC;aAClD,CAAC;YACF,SAAS,EAAE,wBAAwB,CAAC;gBAClC,OAAO,EAAE,IAAI;gBACb,WAAW,EAAE,yCAAyC;aACvD,CAAC;SACH;KACF,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { CrossLayerProps, ModelProps } from '@node-in-layers/core';
|
|
2
|
+
import { JsonAble } from 'functional-models';
|
|
3
|
+
import { ConfigWithNotifications } from '../../types.js';
|
|
4
|
+
import { NotificationStatus, NotificationSeverity } from '../types.js';
|
|
5
|
+
export declare const create: ({ context, Model, getModel, getPrimaryKeyProperty, getForeignKeyProperty, }: ModelProps<ConfigWithNotifications>) => import("functional-models").ModelType<Readonly<{
|
|
6
|
+
id: import("functional-models").PrimaryKeyType;
|
|
7
|
+
type: import("../types.js").NotificationType | string;
|
|
8
|
+
severity: NotificationSeverity;
|
|
9
|
+
title: string;
|
|
10
|
+
message: string;
|
|
11
|
+
htmlMessage?: string;
|
|
12
|
+
data?: Readonly<{
|
|
13
|
+
[s: string]: JsonAble;
|
|
14
|
+
}> | undefined;
|
|
15
|
+
userId?: import("functional-models").PrimaryKeyType;
|
|
16
|
+
recipients?: readonly string[];
|
|
17
|
+
targets?: readonly Readonly<{
|
|
18
|
+
channel: import("../types.js").NotificationChannel | string;
|
|
19
|
+
notifier?: string;
|
|
20
|
+
to?: readonly string[];
|
|
21
|
+
cc?: readonly string[];
|
|
22
|
+
bcc?: readonly string[];
|
|
23
|
+
replyTo?: string;
|
|
24
|
+
phoneNumbers?: readonly string[];
|
|
25
|
+
topicArn?: string;
|
|
26
|
+
targetArn?: string;
|
|
27
|
+
url?: string;
|
|
28
|
+
channelId?: string;
|
|
29
|
+
options?: import("functional-models").JsonObj;
|
|
30
|
+
}>[] | undefined;
|
|
31
|
+
channels?: readonly (import("../types.js").NotificationChannel | string)[];
|
|
32
|
+
notifiers?: import("../types.js").NotifiersMap;
|
|
33
|
+
idempotencyKey?: string;
|
|
34
|
+
status: NotificationStatus;
|
|
35
|
+
deliveryResults?: Readonly<Record<string, Readonly<{
|
|
36
|
+
channel: import("../types.js").NotificationChannel | string;
|
|
37
|
+
notifier: string;
|
|
38
|
+
success: boolean;
|
|
39
|
+
sentAt?: string;
|
|
40
|
+
details?: import("functional-models").JsonObj;
|
|
41
|
+
error?: import("@node-in-layers/core").ErrorObject['error'];
|
|
42
|
+
}>>> | undefined;
|
|
43
|
+
taskId?: import("functional-models").PrimaryKeyType;
|
|
44
|
+
crossLayerProps?: CrossLayerProps<Record<string, JsonAble>>;
|
|
45
|
+
ttl?: number;
|
|
46
|
+
sentAt?: string;
|
|
47
|
+
createdAt?: string;
|
|
48
|
+
updatedAt?: string;
|
|
49
|
+
}>, object, object>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { ArrayProperty, DatetimeProperty, LastModifiedDateProperty, ObjectProperty, TextProperty, TtlProperty, } from 'functional-models';
|
|
2
|
+
import { NotificationsNamespace } from '../../types.js';
|
|
3
|
+
import { NotificationStatus, NotificationSeverity, } from '../types.js';
|
|
4
|
+
import { createNotificationTtlLazyLoadMethod } from '../internal-libs.js';
|
|
5
|
+
export const create = ({ context, Model, getModel, getPrimaryKeyProperty, getForeignKeyProperty, }) => {
|
|
6
|
+
const coreConfig = context.config[NotificationsNamespace.Core];
|
|
7
|
+
const userIdProperty = getForeignKeyProperty('@node-in-layers/auth/core', 'Users', getModel('@node-in-layers/auth/core', 'Users'), {
|
|
8
|
+
required: false,
|
|
9
|
+
description: 'Optional user id associated with the notification.',
|
|
10
|
+
});
|
|
11
|
+
const taskIdProperty = getForeignKeyProperty('@node-in-layers/tasks', 'Tasks', getModel('@node-in-layers/tasks', 'Tasks'), {
|
|
12
|
+
required: false,
|
|
13
|
+
description: 'Optional task id when delivery was queued.',
|
|
14
|
+
});
|
|
15
|
+
return Model({
|
|
16
|
+
pluralName: 'Notifications',
|
|
17
|
+
singularName: 'Notification',
|
|
18
|
+
namespace: NotificationsNamespace.Core,
|
|
19
|
+
primaryKeyName: 'id',
|
|
20
|
+
description: 'Notifications sent by Node in Layers systems.',
|
|
21
|
+
properties: {
|
|
22
|
+
id: getPrimaryKeyProperty(NotificationsNamespace.Core, 'Notifications', {
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
type: TextProperty({
|
|
26
|
+
required: true,
|
|
27
|
+
description: 'Notification type, such as system, executionFailure, or user.',
|
|
28
|
+
}),
|
|
29
|
+
severity: TextProperty({
|
|
30
|
+
required: true,
|
|
31
|
+
choices: Object.values(NotificationSeverity),
|
|
32
|
+
description: 'How important the notification is.',
|
|
33
|
+
}),
|
|
34
|
+
title: TextProperty({
|
|
35
|
+
required: true,
|
|
36
|
+
description: 'Human-readable notification title.',
|
|
37
|
+
}),
|
|
38
|
+
message: TextProperty({
|
|
39
|
+
required: true,
|
|
40
|
+
description: 'Human-readable notification message.',
|
|
41
|
+
}),
|
|
42
|
+
htmlMessage: TextProperty({
|
|
43
|
+
description: 'Optional HTML message body.',
|
|
44
|
+
}),
|
|
45
|
+
data: ObjectProperty({
|
|
46
|
+
description: 'Template and channel data for this notification.',
|
|
47
|
+
}),
|
|
48
|
+
userId: userIdProperty,
|
|
49
|
+
recipients: ArrayProperty({
|
|
50
|
+
description: 'Simple recipient list, usually email addresses.',
|
|
51
|
+
}),
|
|
52
|
+
targets: ArrayProperty({
|
|
53
|
+
description: 'Channel-aware notification targets.',
|
|
54
|
+
}),
|
|
55
|
+
channels: ArrayProperty({
|
|
56
|
+
description: 'Channels requested for this notification.',
|
|
57
|
+
}),
|
|
58
|
+
notifiers: ObjectProperty({
|
|
59
|
+
description: 'Per-notification notifier map overrides.',
|
|
60
|
+
}),
|
|
61
|
+
idempotencyKey: TextProperty({
|
|
62
|
+
description: 'Optional deduplication key.',
|
|
63
|
+
}),
|
|
64
|
+
status: TextProperty({
|
|
65
|
+
required: true,
|
|
66
|
+
choices: Object.values(NotificationStatus),
|
|
67
|
+
description: 'Current delivery status.',
|
|
68
|
+
}),
|
|
69
|
+
deliveryResults: ObjectProperty({
|
|
70
|
+
description: 'Delivery result by channel.',
|
|
71
|
+
}),
|
|
72
|
+
taskId: taskIdProperty,
|
|
73
|
+
crossLayerProps: ObjectProperty({
|
|
74
|
+
description: 'Trace props captured for queued notification delivery.',
|
|
75
|
+
}),
|
|
76
|
+
ttl: TtlProperty({
|
|
77
|
+
description: 'Optional Unix timestamp in seconds for automatic database roll-out.',
|
|
78
|
+
lazyLoadMethod: createNotificationTtlLazyLoadMethod({ coreConfig }),
|
|
79
|
+
}),
|
|
80
|
+
sentAt: DatetimeProperty({
|
|
81
|
+
description: 'When all delivery attempts completed.',
|
|
82
|
+
}),
|
|
83
|
+
createdAt: DatetimeProperty({
|
|
84
|
+
autoNow: true,
|
|
85
|
+
description: 'When the notification row was created.',
|
|
86
|
+
}),
|
|
87
|
+
updatedAt: LastModifiedDateProperty({
|
|
88
|
+
autoNow: true,
|
|
89
|
+
description: 'When the notification row was last updated.',
|
|
90
|
+
}),
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=Notifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Notifications.js","sourceRoot":"","sources":["../../../src/core/models/Notifications.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,gBAAgB,EAEhB,wBAAwB,EACxB,cAAc,EACd,YAAY,EACZ,WAAW,GACZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAA2B,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAChF,OAAO,EAGL,kBAAkB,EAElB,oBAAoB,GACrB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,mCAAmC,EAAE,MAAM,qBAAqB,CAAA;AAEzE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EACrB,OAAO,EACP,KAAK,EACL,QAAQ,EACR,qBAAqB,EACrB,qBAAqB,GACe,EAAE,EAAE;IACxC,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAA;IAC9D,MAAM,cAAc,GAAG,qBAAqB,CAC1C,2BAA2B,EAC3B,OAAO,EACP,QAAQ,CAAC,2BAA2B,EAAE,OAAO,CAAC,EAC9C;QACE,QAAQ,EAAE,KAAK;QACf,WAAW,EAAE,oDAAoD;KAClE,CACF,CAAA;IACD,MAAM,cAAc,GAAG,qBAAqB,CAC1C,uBAAuB,EACvB,OAAO,EACP,QAAQ,CAAC,uBAAuB,EAAE,OAAO,CAAC,EAC1C;QACE,QAAQ,EAAE,KAAK;QACf,WAAW,EAAE,4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AAW,EAAE,6BAA6B;aAC3C,CAAC;YACF,MAAM,EAAE,YAAY,CAAC;gBACnB,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC;gBAC1C,WAAW,EAAE,0BAA0B;aACxC,CAAC;YACF,eAAe,EAAE,cAAc,CAE7B;gBACA,WAAW,EAAE,6BAA6B;aAC3C,CAAC;YACF,MAAM,EAAE,cAAc;YACtB,eAAe,EAAE,cAAc,CAE7B;gBACA,WAAW,EAAE,wDAAwD;aACtE,CAAC;YACF,GAAG,EAAE,WAAW,CAAC;gBACf,WAAW,EACT,qEAAqE;gBACvE,cAAc,EAAE,mCAAmC,CAAC,EAAE,UAAU,EAAE,CAAC;aACpE,CAAC;YACF,MAAM,EAAE,gBAAgB,CAAC;gBACvB,WAAW,EAAE,uCAAuC;aACrD,CAAC;YACF,SAAS,EAAE,gBAAgB,CAAC;gBAC1B,OAAO,EAAE,IAAI;gBACb,WAAW,EAAE,wCAAwC;aACtD,CAAC;YACF,SAAS,EAAE,wBAAwB,CAAC;gBAClC,OAAO,EAAE,IAAI;gBACb,WAAW,EAAE,6CAA6C;aAC3D,CAAC;SACH;KACF,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,mBAAmB,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,qBAAqB,MAAM,4BAA4B,CAAA"}
|
package/core/services.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.js","sourceRoot":"","sources":["../../src/core/services.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,MAAM,GAAG;AACpB,6DAA6D;AAC7D,OAAiD,EACnC,EAAE;IAChB,OAAO,EAAE,CAAA;AACX,CAAC,CAAA"}
|