@forklaunch/implementation-messaging-base 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/lib/domain/enum/index.d.ts +2 -0
- package/lib/domain/enum/index.d.ts.map +1 -0
- package/lib/domain/enum/index.js +38 -0
- package/lib/domain/enum/index.mjs +11 -0
- package/lib/domain/enum/smsStatus.enum.d.ts +9 -0
- package/lib/domain/enum/smsStatus.enum.d.ts.map +1 -0
- package/lib/domain/schemas/index.d.ts +2 -0
- package/lib/domain/schemas/index.d.ts.map +1 -0
- package/lib/domain/schemas/index.js +84 -0
- package/lib/domain/schemas/index.mjs +73 -0
- package/lib/domain/schemas/sms.schema.d.ts +44 -0
- package/lib/domain/schemas/sms.schema.d.ts.map +1 -0
- package/lib/domain/schemas/typebox/sms.schema.d.ts +40 -0
- package/lib/domain/schemas/typebox/sms.schema.d.ts.map +1 -0
- package/lib/domain/schemas/zod/sms.schema.d.ts +40 -0
- package/lib/domain/schemas/zod/sms.schema.d.ts.map +1 -0
- package/lib/domain/types/baseSmsDto.types.d.ts +6 -0
- package/lib/domain/types/baseSmsDto.types.d.ts.map +1 -0
- package/lib/domain/types/baseSmsEntity.types.d.ts +15 -0
- package/lib/domain/types/baseSmsEntity.types.d.ts.map +1 -0
- package/lib/domain/types/index.d.ts +4 -0
- package/lib/domain/types/index.d.ts.map +1 -0
- package/lib/domain/types/index.js +18 -0
- package/lib/domain/types/index.mjs +0 -0
- package/lib/domain/types/sms.mapper.types.d.ts +14 -0
- package/lib/domain/types/sms.mapper.types.d.ts.map +1 -0
- package/lib/eject/domain/enum/index.ts +1 -0
- package/lib/eject/domain/enum/smsStatus.enum.ts +8 -0
- package/lib/eject/domain/schemas/index.ts +1 -0
- package/lib/eject/domain/schemas/sms.schema.ts +35 -0
- package/lib/eject/domain/types/baseSmsDto.types.ts +10 -0
- package/lib/eject/domain/types/baseSmsEntity.types.ts +16 -0
- package/lib/eject/domain/types/index.ts +3 -0
- package/lib/eject/domain/types/sms.mapper.types.ts +24 -0
- package/lib/eject/services/index.ts +4 -0
- package/lib/eject/services/sms.service.ts +103 -0
- package/lib/persistence/entities/index.d.ts +92 -0
- package/lib/persistence/entities/index.d.ts.map +1 -0
- package/lib/persistence/entities/index.js +42 -0
- package/lib/persistence/entities/index.mjs +17 -0
- package/lib/services/index.d.ts +4 -0
- package/lib/services/index.d.ts.map +1 -0
- package/lib/services/index.js +101 -0
- package/lib/services/index.mjs +73 -0
- package/lib/services/sms.service.d.ts +22 -0
- package/lib/services/sms.service.d.ts.map +1 -0
- package/package.json +96 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 forklaunch
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../domain/enum/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// domain/enum/index.ts
|
|
21
|
+
var enum_exports = {};
|
|
22
|
+
__export(enum_exports, {
|
|
23
|
+
SmsStatusEnum: () => SmsStatusEnum
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(enum_exports);
|
|
26
|
+
|
|
27
|
+
// domain/enum/smsStatus.enum.ts
|
|
28
|
+
var SmsStatusEnum = {
|
|
29
|
+
QUEUED: "queued",
|
|
30
|
+
SENT: "sent",
|
|
31
|
+
DELIVERED: "delivered",
|
|
32
|
+
FAILED: "failed",
|
|
33
|
+
UNDELIVERED: "undelivered"
|
|
34
|
+
};
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
SmsStatusEnum
|
|
38
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const SmsStatusEnum: {
|
|
2
|
+
readonly QUEUED: 'queued';
|
|
3
|
+
readonly SENT: 'sent';
|
|
4
|
+
readonly DELIVERED: 'delivered';
|
|
5
|
+
readonly FAILED: 'failed';
|
|
6
|
+
readonly UNDELIVERED: 'undelivered';
|
|
7
|
+
};
|
|
8
|
+
export type SmsStatusEnum = (typeof SmsStatusEnum)[keyof typeof SmsStatusEnum];
|
|
9
|
+
//# sourceMappingURL=smsStatus.enum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smsStatus.enum.d.ts","sourceRoot":"","sources":["../../../domain/enum/smsStatus.enum.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;aACxB,MAAM,EAAE,QAAQ;aAChB,IAAI,EAAE,MAAM;aACZ,SAAS,EAAE,WAAW;aACtB,MAAM,EAAE,QAAQ;aAChB,WAAW,EAAE,aAAa;CAClB,CAAC;AACX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../domain/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// domain/schemas/index.ts
|
|
21
|
+
var schemas_exports = {};
|
|
22
|
+
__export(schemas_exports, {
|
|
23
|
+
BaseSmsServiceSchemas: () => BaseSmsServiceSchemas3
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(schemas_exports);
|
|
26
|
+
|
|
27
|
+
// domain/schemas/sms.schema.ts
|
|
28
|
+
var import_internal = require("@forklaunch/internal");
|
|
29
|
+
|
|
30
|
+
// domain/schemas/typebox/sms.schema.ts
|
|
31
|
+
var import_typebox = require("@forklaunch/validator/typebox");
|
|
32
|
+
var SendSmsSchema = {
|
|
33
|
+
to: import_typebox.string,
|
|
34
|
+
body: import_typebox.string,
|
|
35
|
+
metadata: (0, import_typebox.optional)((0, import_typebox.record)(import_typebox.string, import_typebox.unknown))
|
|
36
|
+
};
|
|
37
|
+
var SmsRecordSchema = ({ uuidId }) => (StatusEnum) => ({
|
|
38
|
+
id: uuidId ? import_typebox.uuid : import_typebox.string,
|
|
39
|
+
to: import_typebox.string,
|
|
40
|
+
body: import_typebox.string,
|
|
41
|
+
status: (0, import_typebox.enum_)(StatusEnum),
|
|
42
|
+
providerMessageId: (0, import_typebox.optional)(import_typebox.string),
|
|
43
|
+
error: (0, import_typebox.optional)(import_typebox.string),
|
|
44
|
+
metadata: (0, import_typebox.optional)((0, import_typebox.record)(import_typebox.string, import_typebox.unknown)),
|
|
45
|
+
createdAt: (0, import_typebox.optional)(import_typebox.date),
|
|
46
|
+
updatedAt: (0, import_typebox.optional)(import_typebox.date)
|
|
47
|
+
});
|
|
48
|
+
var BaseSmsServiceSchemas = (options) => ({
|
|
49
|
+
SendSmsSchema,
|
|
50
|
+
SmsRecordSchema: SmsRecordSchema(options)
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// domain/schemas/zod/sms.schema.ts
|
|
54
|
+
var import_zod = require("@forklaunch/validator/zod");
|
|
55
|
+
var SendSmsSchema2 = {
|
|
56
|
+
to: import_zod.string,
|
|
57
|
+
body: import_zod.string,
|
|
58
|
+
metadata: (0, import_zod.optional)((0, import_zod.record)(import_zod.string, import_zod.unknown))
|
|
59
|
+
};
|
|
60
|
+
var SmsRecordSchema2 = ({ uuidId }) => (StatusEnum) => ({
|
|
61
|
+
id: uuidId ? import_zod.uuid : import_zod.string,
|
|
62
|
+
to: import_zod.string,
|
|
63
|
+
body: import_zod.string,
|
|
64
|
+
status: (0, import_zod.enum_)(StatusEnum),
|
|
65
|
+
providerMessageId: (0, import_zod.optional)(import_zod.string),
|
|
66
|
+
error: (0, import_zod.optional)(import_zod.string),
|
|
67
|
+
metadata: (0, import_zod.optional)((0, import_zod.record)(import_zod.string, import_zod.unknown)),
|
|
68
|
+
createdAt: (0, import_zod.optional)(import_zod.date),
|
|
69
|
+
updatedAt: (0, import_zod.optional)(import_zod.date)
|
|
70
|
+
});
|
|
71
|
+
var BaseSmsServiceSchemas2 = (options) => ({
|
|
72
|
+
SendSmsSchema: SendSmsSchema2,
|
|
73
|
+
SmsRecordSchema: SmsRecordSchema2(options)
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// domain/schemas/sms.schema.ts
|
|
77
|
+
var BaseSmsServiceSchemas3 = (0, import_internal.serviceSchemaResolver)(
|
|
78
|
+
BaseSmsServiceSchemas,
|
|
79
|
+
BaseSmsServiceSchemas2
|
|
80
|
+
);
|
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
+
0 && (module.exports = {
|
|
83
|
+
BaseSmsServiceSchemas
|
|
84
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// domain/schemas/sms.schema.ts
|
|
2
|
+
import { serviceSchemaResolver } from "@forklaunch/internal";
|
|
3
|
+
|
|
4
|
+
// domain/schemas/typebox/sms.schema.ts
|
|
5
|
+
import {
|
|
6
|
+
date,
|
|
7
|
+
enum_,
|
|
8
|
+
optional,
|
|
9
|
+
record,
|
|
10
|
+
string,
|
|
11
|
+
unknown,
|
|
12
|
+
uuid
|
|
13
|
+
} from "@forklaunch/validator/typebox";
|
|
14
|
+
var SendSmsSchema = {
|
|
15
|
+
to: string,
|
|
16
|
+
body: string,
|
|
17
|
+
metadata: optional(record(string, unknown))
|
|
18
|
+
};
|
|
19
|
+
var SmsRecordSchema = ({ uuidId }) => (StatusEnum) => ({
|
|
20
|
+
id: uuidId ? uuid : string,
|
|
21
|
+
to: string,
|
|
22
|
+
body: string,
|
|
23
|
+
status: enum_(StatusEnum),
|
|
24
|
+
providerMessageId: optional(string),
|
|
25
|
+
error: optional(string),
|
|
26
|
+
metadata: optional(record(string, unknown)),
|
|
27
|
+
createdAt: optional(date),
|
|
28
|
+
updatedAt: optional(date)
|
|
29
|
+
});
|
|
30
|
+
var BaseSmsServiceSchemas = (options) => ({
|
|
31
|
+
SendSmsSchema,
|
|
32
|
+
SmsRecordSchema: SmsRecordSchema(options)
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// domain/schemas/zod/sms.schema.ts
|
|
36
|
+
import {
|
|
37
|
+
date as date2,
|
|
38
|
+
enum_ as enum_2,
|
|
39
|
+
optional as optional2,
|
|
40
|
+
record as record2,
|
|
41
|
+
string as string2,
|
|
42
|
+
unknown as unknown2,
|
|
43
|
+
uuid as uuid2
|
|
44
|
+
} from "@forklaunch/validator/zod";
|
|
45
|
+
var SendSmsSchema2 = {
|
|
46
|
+
to: string2,
|
|
47
|
+
body: string2,
|
|
48
|
+
metadata: optional2(record2(string2, unknown2))
|
|
49
|
+
};
|
|
50
|
+
var SmsRecordSchema2 = ({ uuidId }) => (StatusEnum) => ({
|
|
51
|
+
id: uuidId ? uuid2 : string2,
|
|
52
|
+
to: string2,
|
|
53
|
+
body: string2,
|
|
54
|
+
status: enum_2(StatusEnum),
|
|
55
|
+
providerMessageId: optional2(string2),
|
|
56
|
+
error: optional2(string2),
|
|
57
|
+
metadata: optional2(record2(string2, unknown2)),
|
|
58
|
+
createdAt: optional2(date2),
|
|
59
|
+
updatedAt: optional2(date2)
|
|
60
|
+
});
|
|
61
|
+
var BaseSmsServiceSchemas2 = (options) => ({
|
|
62
|
+
SendSmsSchema: SendSmsSchema2,
|
|
63
|
+
SmsRecordSchema: SmsRecordSchema2(options)
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// domain/schemas/sms.schema.ts
|
|
67
|
+
var BaseSmsServiceSchemas3 = serviceSchemaResolver(
|
|
68
|
+
BaseSmsServiceSchemas,
|
|
69
|
+
BaseSmsServiceSchemas2
|
|
70
|
+
);
|
|
71
|
+
export {
|
|
72
|
+
BaseSmsServiceSchemas3 as BaseSmsServiceSchemas
|
|
73
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare const BaseSmsServiceSchemas: <SchemaValidator extends import("@forklaunch/validator").AnySchemaValidator>(options: {
|
|
2
|
+
uuidId: boolean;
|
|
3
|
+
} & {
|
|
4
|
+
validator: SchemaValidator;
|
|
5
|
+
}) => import("@forklaunch/internal").SchemasByValidator<SchemaValidator, (options: {
|
|
6
|
+
uuidId: boolean;
|
|
7
|
+
}) => {
|
|
8
|
+
SendSmsSchema: {
|
|
9
|
+
to: import("@sinclair/typebox").TString;
|
|
10
|
+
body: import("@sinclair/typebox").TString;
|
|
11
|
+
metadata: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
|
|
12
|
+
};
|
|
13
|
+
SmsRecordSchema: <T extends Record<string, import("@forklaunch/validator").LiteralSchema>>(StatusEnum: T) => {
|
|
14
|
+
id: import("@sinclair/typebox").TString;
|
|
15
|
+
to: import("@sinclair/typebox").TString;
|
|
16
|
+
body: import("@sinclair/typebox").TString;
|
|
17
|
+
status: import("@sinclair/typebox").TUnion<[{ [K in keyof T]: import("@sinclair/typebox").TLiteral<T[K]>; }[keyof T]]>;
|
|
18
|
+
providerMessageId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
19
|
+
error: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
20
|
+
metadata: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
|
|
21
|
+
createdAt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TDate]>, Date>>;
|
|
22
|
+
updatedAt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TDate]>, Date>>;
|
|
23
|
+
};
|
|
24
|
+
}, (options: {
|
|
25
|
+
uuidId: boolean;
|
|
26
|
+
}) => {
|
|
27
|
+
SendSmsSchema: {
|
|
28
|
+
to: import("zod/v3").ZodString;
|
|
29
|
+
body: import("zod/v3").ZodString;
|
|
30
|
+
metadata: import("zod/v3").ZodOptional<import("zod/v3").ZodRecord<import("zod/v3").ZodString, import("zod/v3").ZodUnknown>>;
|
|
31
|
+
};
|
|
32
|
+
SmsRecordSchema: <T extends Record<string, import("@forklaunch/validator").LiteralSchema>>(StatusEnum: T) => {
|
|
33
|
+
id: import("zod/v3").ZodString;
|
|
34
|
+
to: import("zod/v3").ZodString;
|
|
35
|
+
body: import("zod/v3").ZodString;
|
|
36
|
+
status: import("zod/v3").ZodUnion<[{ [K in keyof T]: import("zod/v3").ZodLiteral<T[K]>; }[keyof T]]>;
|
|
37
|
+
providerMessageId: import("zod/v3").ZodOptional<import("zod/v3").ZodString>;
|
|
38
|
+
error: import("zod/v3").ZodOptional<import("zod/v3").ZodString>;
|
|
39
|
+
metadata: import("zod/v3").ZodOptional<import("zod/v3").ZodRecord<import("zod/v3").ZodString, import("zod/v3").ZodUnknown>>;
|
|
40
|
+
createdAt: import("zod/v3").ZodOptional<import("zod/v3").ZodEffects<import("zod/v3").ZodDate, Date, unknown>>;
|
|
41
|
+
updatedAt: import("zod/v3").ZodOptional<import("zod/v3").ZodEffects<import("zod/v3").ZodDate, Date, unknown>>;
|
|
42
|
+
};
|
|
43
|
+
}>;
|
|
44
|
+
//# sourceMappingURL=sms.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sms.schema.d.ts","sourceRoot":"","sources":["../../../domain/schemas/sms.schema.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGjC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { LiteralSchema } from '@forklaunch/validator';
|
|
2
|
+
export declare const SendSmsSchema: {
|
|
3
|
+
to: import("@sinclair/typebox").TString;
|
|
4
|
+
body: import("@sinclair/typebox").TString;
|
|
5
|
+
metadata: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
|
|
6
|
+
};
|
|
7
|
+
export declare const SmsRecordSchema: ({ uuidId }: {
|
|
8
|
+
uuidId: boolean;
|
|
9
|
+
}) => <T extends Record<string, LiteralSchema>>(StatusEnum: T) => {
|
|
10
|
+
id: import("@sinclair/typebox").TString;
|
|
11
|
+
to: import("@sinclair/typebox").TString;
|
|
12
|
+
body: import("@sinclair/typebox").TString;
|
|
13
|
+
status: import("@sinclair/typebox").TUnion<[{ [K in keyof T]: import("@sinclair/typebox").TLiteral<T[K]>; }[keyof T]]>;
|
|
14
|
+
providerMessageId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
15
|
+
error: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
16
|
+
metadata: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
|
|
17
|
+
createdAt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TDate]>, Date>>;
|
|
18
|
+
updatedAt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TDate]>, Date>>;
|
|
19
|
+
};
|
|
20
|
+
export declare const BaseSmsServiceSchemas: (options: {
|
|
21
|
+
uuidId: boolean;
|
|
22
|
+
}) => {
|
|
23
|
+
SendSmsSchema: {
|
|
24
|
+
to: import("@sinclair/typebox").TString;
|
|
25
|
+
body: import("@sinclair/typebox").TString;
|
|
26
|
+
metadata: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
|
|
27
|
+
};
|
|
28
|
+
SmsRecordSchema: <T extends Record<string, LiteralSchema>>(StatusEnum: T) => {
|
|
29
|
+
id: import("@sinclair/typebox").TString;
|
|
30
|
+
to: import("@sinclair/typebox").TString;
|
|
31
|
+
body: import("@sinclair/typebox").TString;
|
|
32
|
+
status: import("@sinclair/typebox").TUnion<[{ [K in keyof T]: import("@sinclair/typebox").TLiteral<T[K]>; }[keyof T]]>;
|
|
33
|
+
providerMessageId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
34
|
+
error: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
35
|
+
metadata: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
|
|
36
|
+
createdAt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TDate]>, Date>>;
|
|
37
|
+
updatedAt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TDate]>, Date>>;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=sms.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sms.schema.d.ts","sourceRoot":"","sources":["../../../../domain/schemas/typebox/sms.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAWtD,eAAO,MAAM,aAAa;IACxB,EAAE;IACF,IAAI;IACJ,QAAQ;CACT,CAAC;AAEF,eAAO,MAAM,eAAe,eACb;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,MAC/B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,cAAc,CAAC;IACrD,EAAE;IACF,EAAE;IACF,IAAI;IACJ,MAAM;IACN,iBAAiB;IACjB,KAAK;IACL,QAAQ;IACR,SAAS;IACT,SAAS;CACT,CAAC;AAEL,eAAO,MAAM,qBAAqB,YAAa;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE;;;;;;sBAZ/D,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,cAAc,CAAC;QACrD,EAAE;QACF,EAAE;QACF,IAAI;QACJ,MAAM;QACN,iBAAiB;QACjB,KAAK;QACL,QAAQ;QACR,SAAS;QACT,SAAS;;CAMX,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { LiteralSchema } from '@forklaunch/validator';
|
|
2
|
+
export declare const SendSmsSchema: {
|
|
3
|
+
to: import("zod/v3").ZodString;
|
|
4
|
+
body: import("zod/v3").ZodString;
|
|
5
|
+
metadata: import("zod/v3").ZodOptional<import("zod/v3").ZodRecord<import("zod/v3").ZodString, import("zod/v3").ZodUnknown>>;
|
|
6
|
+
};
|
|
7
|
+
export declare const SmsRecordSchema: ({ uuidId }: {
|
|
8
|
+
uuidId: boolean;
|
|
9
|
+
}) => <T extends Record<string, LiteralSchema>>(StatusEnum: T) => {
|
|
10
|
+
id: import("zod/v3").ZodString;
|
|
11
|
+
to: import("zod/v3").ZodString;
|
|
12
|
+
body: import("zod/v3").ZodString;
|
|
13
|
+
status: import("zod/v3").ZodUnion<[{ [K in keyof T]: import("zod/v3").ZodLiteral<T[K]>; }[keyof T]]>;
|
|
14
|
+
providerMessageId: import("zod/v3").ZodOptional<import("zod/v3").ZodString>;
|
|
15
|
+
error: import("zod/v3").ZodOptional<import("zod/v3").ZodString>;
|
|
16
|
+
metadata: import("zod/v3").ZodOptional<import("zod/v3").ZodRecord<import("zod/v3").ZodString, import("zod/v3").ZodUnknown>>;
|
|
17
|
+
createdAt: import("zod/v3").ZodOptional<import("zod/v3").ZodEffects<import("zod/v3").ZodDate, Date, unknown>>;
|
|
18
|
+
updatedAt: import("zod/v3").ZodOptional<import("zod/v3").ZodEffects<import("zod/v3").ZodDate, Date, unknown>>;
|
|
19
|
+
};
|
|
20
|
+
export declare const BaseSmsServiceSchemas: (options: {
|
|
21
|
+
uuidId: boolean;
|
|
22
|
+
}) => {
|
|
23
|
+
SendSmsSchema: {
|
|
24
|
+
to: import("zod/v3").ZodString;
|
|
25
|
+
body: import("zod/v3").ZodString;
|
|
26
|
+
metadata: import("zod/v3").ZodOptional<import("zod/v3").ZodRecord<import("zod/v3").ZodString, import("zod/v3").ZodUnknown>>;
|
|
27
|
+
};
|
|
28
|
+
SmsRecordSchema: <T extends Record<string, LiteralSchema>>(StatusEnum: T) => {
|
|
29
|
+
id: import("zod/v3").ZodString;
|
|
30
|
+
to: import("zod/v3").ZodString;
|
|
31
|
+
body: import("zod/v3").ZodString;
|
|
32
|
+
status: import("zod/v3").ZodUnion<[{ [K in keyof T]: import("zod/v3").ZodLiteral<T[K]>; }[keyof T]]>;
|
|
33
|
+
providerMessageId: import("zod/v3").ZodOptional<import("zod/v3").ZodString>;
|
|
34
|
+
error: import("zod/v3").ZodOptional<import("zod/v3").ZodString>;
|
|
35
|
+
metadata: import("zod/v3").ZodOptional<import("zod/v3").ZodRecord<import("zod/v3").ZodString, import("zod/v3").ZodUnknown>>;
|
|
36
|
+
createdAt: import("zod/v3").ZodOptional<import("zod/v3").ZodEffects<import("zod/v3").ZodDate, Date, unknown>>;
|
|
37
|
+
updatedAt: import("zod/v3").ZodOptional<import("zod/v3").ZodEffects<import("zod/v3").ZodDate, Date, unknown>>;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=sms.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sms.schema.d.ts","sourceRoot":"","sources":["../../../../domain/schemas/zod/sms.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAWtD,eAAO,MAAM,aAAa;IACxB,EAAE;IACF,IAAI;IACJ,QAAQ;CACT,CAAC;AAEF,eAAO,MAAM,eAAe,eACb;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,MAC/B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,cAAc,CAAC;IACrD,EAAE;IACF,EAAE;IACF,IAAI;IACJ,MAAM;IACN,iBAAiB;IACjB,KAAK;IACL,QAAQ;IACR,SAAS;IACT,SAAS;CACT,CAAC;AAEL,eAAO,MAAM,qBAAqB,YAAa;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE;;;;;;sBAZ/D,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,cAAc,CAAC;QACrD,EAAE;QACF,EAAE;QACF,IAAI;QACJ,MAAM;QACN,iBAAiB;QACjB,KAAK;QACL,QAAQ;QACR,SAAS;QACT,SAAS;;CAMX,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseSmsDto.types.d.ts","sourceRoot":"","sources":["../../../domain/types/baseSmsDto.types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,YAAY,EACb,MAAM,wCAAwC,CAAC;AAGhD,MAAM,MAAM,WAAW,CAAC,UAAU,IAAI;IACpC,eAAe,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;IAC1C,aAAa,EAAE,UAAU,CAAC;CAC3B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ResolvedEntity } from '@forklaunch/core/persistence';
|
|
2
|
+
import { SmsRecord } from '../../persistence/entities';
|
|
3
|
+
export type BaseSmsEntities<StatusEnum> = {
|
|
4
|
+
SmsRecordMapper: {
|
|
5
|
+
'~entity': ResolvedEntity<(typeof SmsRecord)['~entity']> & {
|
|
6
|
+
status: StatusEnum[keyof StatusEnum];
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
SendSmsMapper: {
|
|
10
|
+
'~entity': ResolvedEntity<(typeof SmsRecord)['~entity']> & {
|
|
11
|
+
status: StatusEnum[keyof StatusEnum];
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=baseSmsEntity.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseSmsEntity.types.d.ts","sourceRoot":"","sources":["../../../domain/types/baseSmsEntity.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAGvD,MAAM,MAAM,eAAe,CAAC,UAAU,IAAI;IACxC,eAAe,EAAE;QACf,SAAS,EAAE,cAAc,CAAC,CAAC,OAAO,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG;YACzD,MAAM,EAAE,UAAU,CAAC,MAAM,UAAU,CAAC,CAAC;SACtC,CAAC;KACH,CAAC;IACF,aAAa,EAAE;QACb,SAAS,EAAE,cAAc,CAAC,CAAC,OAAO,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG;YACzD,MAAM,EAAE,UAAU,CAAC,MAAM,UAAU,CAAC,CAAC;SACtC,CAAC;KACH,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../domain/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// domain/types/index.ts
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EntityManager, InferEntity } from '@mikro-orm/core';
|
|
2
|
+
import { BaseSmsDtos } from './baseSmsDto.types';
|
|
3
|
+
import { BaseSmsEntities } from './baseSmsEntity.types';
|
|
4
|
+
export type SmsMappers<StatusEnum, MapperEntities extends BaseSmsEntities<StatusEnum>, MapperDomains extends BaseSmsDtos<StatusEnum>> = {
|
|
5
|
+
SmsRecordMapper: {
|
|
6
|
+
entity: MapperEntities['SmsRecordMapper'];
|
|
7
|
+
toDto: (entity: InferEntity<MapperEntities['SmsRecordMapper']>) => Promise<MapperDomains['SmsRecordMapper']>;
|
|
8
|
+
};
|
|
9
|
+
SendSmsMapper: {
|
|
10
|
+
entity: MapperEntities['SendSmsMapper'];
|
|
11
|
+
toEntity: (dto: MapperDomains['SendSmsMapper'], em: EntityManager, ...args: unknown[]) => Promise<InferEntity<MapperEntities['SendSmsMapper']>>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=sms.mapper.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sms.mapper.types.d.ts","sourceRoot":"","sources":["../../../domain/types/sms.mapper.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,MAAM,UAAU,CACpB,UAAU,EACV,cAAc,SAAS,eAAe,CAAC,UAAU,CAAC,EAClD,aAAa,SAAS,WAAW,CAAC,UAAU,CAAC,IAC3C;IACF,eAAe,EAAE;QACf,MAAM,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAAC;QAC1C,KAAK,EAAE,CACL,MAAM,EAAE,WAAW,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC,KACnD,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC;KAChD,CAAC;IACF,aAAa,EAAE;QACb,MAAM,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;QACxC,QAAQ,EAAE,CACR,GAAG,EAAE,aAAa,CAAC,eAAe,CAAC,EACnC,EAAE,EAAE,aAAa,EACjB,GAAG,IAAI,EAAE,OAAO,EAAE,KACf,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;KAC5D,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './smsStatus.enum';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './sms.schema';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { LiteralSchema } from '@forklaunch/validator';
|
|
2
|
+
import {
|
|
3
|
+
date,
|
|
4
|
+
enum_,
|
|
5
|
+
optional,
|
|
6
|
+
record,
|
|
7
|
+
string,
|
|
8
|
+
unknown,
|
|
9
|
+
uuid
|
|
10
|
+
} from '@{{app_name}}/core';
|
|
11
|
+
|
|
12
|
+
export const SendSmsSchema = {
|
|
13
|
+
to: string,
|
|
14
|
+
body: string,
|
|
15
|
+
metadata: optional(record(string, unknown))
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const SmsRecordSchema =
|
|
19
|
+
({ uuidId }: { uuidId: boolean }) =>
|
|
20
|
+
<T extends Record<string, LiteralSchema>>(StatusEnum: T) => ({
|
|
21
|
+
id: uuidId ? uuid : string,
|
|
22
|
+
to: string,
|
|
23
|
+
body: string,
|
|
24
|
+
status: enum_(StatusEnum),
|
|
25
|
+
providerMessageId: optional(string),
|
|
26
|
+
error: optional(string),
|
|
27
|
+
metadata: optional(record(string, unknown)),
|
|
28
|
+
createdAt: optional(date),
|
|
29
|
+
updatedAt: optional(date)
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export const BaseSmsServiceSchemas = (options: { uuidId: boolean }) => ({
|
|
33
|
+
SendSmsSchema,
|
|
34
|
+
SmsRecordSchema: SmsRecordSchema(options)
|
|
35
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ResolvedEntity } from '@forklaunch/core/persistence';
|
|
2
|
+
import { SmsRecord } from '../../persistence/entities';
|
|
3
|
+
|
|
4
|
+
// sms record entity types
|
|
5
|
+
export type BaseSmsEntities<StatusEnum> = {
|
|
6
|
+
SmsRecordMapper: {
|
|
7
|
+
'~entity': ResolvedEntity<(typeof SmsRecord)['~entity']> & {
|
|
8
|
+
status: StatusEnum[keyof StatusEnum];
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
SendSmsMapper: {
|
|
12
|
+
'~entity': ResolvedEntity<(typeof SmsRecord)['~entity']> & {
|
|
13
|
+
status: StatusEnum[keyof StatusEnum];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { EntityManager, InferEntity } from '@mikro-orm/core';
|
|
2
|
+
import { BaseSmsDtos } from './baseSmsDto.types';
|
|
3
|
+
import { BaseSmsEntities } from './baseSmsEntity.types';
|
|
4
|
+
|
|
5
|
+
export type SmsMappers<
|
|
6
|
+
StatusEnum,
|
|
7
|
+
MapperEntities extends BaseSmsEntities<StatusEnum>,
|
|
8
|
+
MapperDomains extends BaseSmsDtos<StatusEnum>
|
|
9
|
+
> = {
|
|
10
|
+
SmsRecordMapper: {
|
|
11
|
+
entity: MapperEntities['SmsRecordMapper'];
|
|
12
|
+
toDto: (
|
|
13
|
+
entity: InferEntity<MapperEntities['SmsRecordMapper']>
|
|
14
|
+
) => Promise<MapperDomains['SmsRecordMapper']>;
|
|
15
|
+
};
|
|
16
|
+
SendSmsMapper: {
|
|
17
|
+
entity: MapperEntities['SendSmsMapper'];
|
|
18
|
+
toEntity: (
|
|
19
|
+
dto: MapperDomains['SendSmsMapper'],
|
|
20
|
+
em: EntityManager,
|
|
21
|
+
...args: unknown[]
|
|
22
|
+
) => Promise<InferEntity<MapperEntities['SendSmsMapper']>>;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { IdDto } from '@forklaunch/common';
|
|
2
|
+
import {
|
|
3
|
+
evaluateTelemetryOptions,
|
|
4
|
+
MetricsDefinition,
|
|
5
|
+
OpenTelemetryCollector,
|
|
6
|
+
TelemetryOptions
|
|
7
|
+
} from '@forklaunch/core/http';
|
|
8
|
+
import { SmsService } from '@forklaunch/interfaces-messaging/interfaces';
|
|
9
|
+
import { SendSmsDto } from '@forklaunch/interfaces-messaging/types';
|
|
10
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
11
|
+
import { EntityManager, InferEntity } from '@mikro-orm/core';
|
|
12
|
+
import { SmsStatusEnum } from '../domain/enum';
|
|
13
|
+
import { BaseSmsDtos } from '../domain/types/baseSmsDto.types';
|
|
14
|
+
import { BaseSmsEntities } from '../domain/types/baseSmsEntity.types';
|
|
15
|
+
import { SmsMappers } from '../domain/types/sms.mapper.types';
|
|
16
|
+
import { SmsRecord } from '../persistence/entities';
|
|
17
|
+
|
|
18
|
+
export class BaseSmsService<
|
|
19
|
+
SchemaValidator extends AnySchemaValidator,
|
|
20
|
+
StatusEnum,
|
|
21
|
+
MapperEntities extends BaseSmsEntities<StatusEnum>,
|
|
22
|
+
MapperDomains extends BaseSmsDtos<StatusEnum> = BaseSmsDtos<StatusEnum>
|
|
23
|
+
> implements SmsService<StatusEnum>
|
|
24
|
+
{
|
|
25
|
+
private evaluatedTelemetryOptions: {
|
|
26
|
+
logging?: boolean;
|
|
27
|
+
metrics?: boolean;
|
|
28
|
+
tracing?: boolean;
|
|
29
|
+
};
|
|
30
|
+
public em: EntityManager;
|
|
31
|
+
protected openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
|
32
|
+
protected schemaValidator: SchemaValidator;
|
|
33
|
+
protected mappers: SmsMappers<StatusEnum, MapperEntities, MapperDomains>;
|
|
34
|
+
|
|
35
|
+
constructor(
|
|
36
|
+
em: EntityManager,
|
|
37
|
+
openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
|
|
38
|
+
schemaValidator: SchemaValidator,
|
|
39
|
+
mappers: SmsMappers<StatusEnum, MapperEntities, MapperDomains>,
|
|
40
|
+
options?: {
|
|
41
|
+
telemetry?: TelemetryOptions;
|
|
42
|
+
}
|
|
43
|
+
) {
|
|
44
|
+
this.em = em;
|
|
45
|
+
this.openTelemetryCollector = openTelemetryCollector;
|
|
46
|
+
this.schemaValidator = schemaValidator;
|
|
47
|
+
this.mappers = mappers;
|
|
48
|
+
this.evaluatedTelemetryOptions = options?.telemetry
|
|
49
|
+
? evaluateTelemetryOptions(options.telemetry).enabled
|
|
50
|
+
: {
|
|
51
|
+
logging: false,
|
|
52
|
+
metrics: false,
|
|
53
|
+
tracing: false
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async sendSms(
|
|
58
|
+
smsDto: SendSmsDto,
|
|
59
|
+
em?: EntityManager,
|
|
60
|
+
...args: unknown[]
|
|
61
|
+
): Promise<MapperDomains['SmsRecordMapper']> {
|
|
62
|
+
//! the base implementation does not dispatch to a provider — it logs the
|
|
63
|
+
//! message via the OpenTelemetryCollector and marks the record as sent
|
|
64
|
+
this.openTelemetryCollector.info('Sending sms (base implementation)', {
|
|
65
|
+
to: smsDto.to,
|
|
66
|
+
body: smsDto.body
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const smsRecord = await this.mappers.SendSmsMapper.toEntity(
|
|
70
|
+
smsDto,
|
|
71
|
+
em ?? this.em,
|
|
72
|
+
...(args[0] instanceof EntityManager ? args.slice(1) : args)
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
(smsRecord as { status: SmsStatusEnum }).status = SmsStatusEnum.SENT;
|
|
76
|
+
|
|
77
|
+
await (em ?? this.em).transactional(async (innerEm) => {
|
|
78
|
+
await innerEm.persist(smsRecord);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return this.mappers.SmsRecordMapper.toDto(
|
|
82
|
+
smsRecord as InferEntity<MapperEntities['SmsRecordMapper']>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async getSmsRecord(
|
|
87
|
+
{ id }: IdDto,
|
|
88
|
+
em?: EntityManager
|
|
89
|
+
): Promise<MapperDomains['SmsRecordMapper']> {
|
|
90
|
+
if (this.evaluatedTelemetryOptions.logging) {
|
|
91
|
+
this.openTelemetryCollector.info('Getting sms record', { id });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const smsRecord = await (em ?? this.em).findOneOrFail(
|
|
95
|
+
this.mappers.SmsRecordMapper.entity as typeof SmsRecord,
|
|
96
|
+
{ id }
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
return this.mappers.SmsRecordMapper.toDto(
|
|
100
|
+
smsRecord as InferEntity<MapperEntities['SmsRecordMapper']>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export declare const SmsRecord: import("@mikro-orm/core").EntitySchemaWithMeta<"SmsRecord", string, import("@mikro-orm/core").InferEntityFromProperties<{
|
|
2
|
+
readonly id: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<string, Omit<import("@mikro-orm/core").EmptyOptions, "primary"> & {
|
|
3
|
+
primary: true;
|
|
4
|
+
} & {
|
|
5
|
+
readonly '~c': true;
|
|
6
|
+
}, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>;
|
|
7
|
+
readonly to: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<string, import("@mikro-orm/core").EmptyOptions & {
|
|
8
|
+
readonly '~c': true;
|
|
9
|
+
}, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>;
|
|
10
|
+
readonly body: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<string, import("@mikro-orm/core").EmptyOptions & {
|
|
11
|
+
readonly '~c': true;
|
|
12
|
+
}, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>;
|
|
13
|
+
readonly status: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<any, import("@mikro-orm/core").EmptyOptions & {
|
|
14
|
+
readonly '~c': true;
|
|
15
|
+
}, "accessor" | "array" | "autoincrement" | "check" | "collation" | "columnType" | "columnTypes" | "comment" | "compliance" | "concurrencyCheck" | "customOrder" | "default" | "defaultRaw" | "extra" | "fieldName" | "fieldNames" | "formula" | "generated" | "getter" | "getterName" | "groups" | "hidden" | "hydrate" | "ignoreSchemaChanges" | "index" | "lazy" | "length" | "name" | "nativeEnumName" | "nullable" | "onCreate" | "onUpdate" | "persist" | "precision" | "primary" | "ref" | "returning" | "runtimeType" | "scale" | "serializedName" | "serializedPrimaryKey" | "serializer" | "setter" | "type" | "unique" | "unsigned" | "version" | ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type")>, "accessor" | "array" | "autoincrement" | "check" | "collation" | "columnType" | "columnTypes" | "comment" | "compliance" | "concurrencyCheck" | "customOrder" | "default" | "defaultRaw" | "extra" | "fieldName" | "fieldNames" | "formula" | "generated" | "getter" | "getterName" | "groups" | "hidden" | "hydrate" | "ignoreSchemaChanges" | "index" | "lazy" | "length" | "name" | "nativeEnumName" | "nullable" | "onCreate" | "onUpdate" | "persist" | "precision" | "primary" | "ref" | "returning" | "runtimeType" | "scale" | "serializedName" | "serializedPrimaryKey" | "serializer" | "setter" | "type" | "unique" | "unsigned" | "version" | ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type")>;
|
|
16
|
+
readonly providerMessageId: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<string, Omit<import("@mikro-orm/core").EmptyOptions, "nullable"> & {
|
|
17
|
+
nullable: true;
|
|
18
|
+
} & {
|
|
19
|
+
readonly '~c': true;
|
|
20
|
+
}, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>;
|
|
21
|
+
readonly error: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<string, Omit<import("@mikro-orm/core").EmptyOptions, "nullable"> & {
|
|
22
|
+
nullable: true;
|
|
23
|
+
} & {
|
|
24
|
+
readonly '~c': true;
|
|
25
|
+
}, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>;
|
|
26
|
+
readonly metadata: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<unknown, Omit<import("@mikro-orm/core").EmptyOptions, "nullable"> & {
|
|
27
|
+
nullable: true;
|
|
28
|
+
} & {
|
|
29
|
+
readonly '~c': true;
|
|
30
|
+
}, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>;
|
|
31
|
+
}, undefined, never, never, false>, never, {
|
|
32
|
+
readonly id: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<string, Omit<import("@mikro-orm/core").EmptyOptions, "primary"> & {
|
|
33
|
+
primary: true;
|
|
34
|
+
} & {
|
|
35
|
+
readonly '~c': true;
|
|
36
|
+
}, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>;
|
|
37
|
+
readonly to: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<string, import("@mikro-orm/core").EmptyOptions & {
|
|
38
|
+
readonly '~c': true;
|
|
39
|
+
}, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>;
|
|
40
|
+
readonly body: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<string, import("@mikro-orm/core").EmptyOptions & {
|
|
41
|
+
readonly '~c': true;
|
|
42
|
+
}, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>;
|
|
43
|
+
readonly status: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<any, import("@mikro-orm/core").EmptyOptions & {
|
|
44
|
+
readonly '~c': true;
|
|
45
|
+
}, "accessor" | "array" | "autoincrement" | "check" | "collation" | "columnType" | "columnTypes" | "comment" | "compliance" | "concurrencyCheck" | "customOrder" | "default" | "defaultRaw" | "extra" | "fieldName" | "fieldNames" | "formula" | "generated" | "getter" | "getterName" | "groups" | "hidden" | "hydrate" | "ignoreSchemaChanges" | "index" | "lazy" | "length" | "name" | "nativeEnumName" | "nullable" | "onCreate" | "onUpdate" | "persist" | "precision" | "primary" | "ref" | "returning" | "runtimeType" | "scale" | "serializedName" | "serializedPrimaryKey" | "serializer" | "setter" | "type" | "unique" | "unsigned" | "version" | ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type")>, "accessor" | "array" | "autoincrement" | "check" | "collation" | "columnType" | "columnTypes" | "comment" | "compliance" | "concurrencyCheck" | "customOrder" | "default" | "defaultRaw" | "extra" | "fieldName" | "fieldNames" | "formula" | "generated" | "getter" | "getterName" | "groups" | "hidden" | "hydrate" | "ignoreSchemaChanges" | "index" | "lazy" | "length" | "name" | "nativeEnumName" | "nullable" | "onCreate" | "onUpdate" | "persist" | "precision" | "primary" | "ref" | "returning" | "runtimeType" | "scale" | "serializedName" | "serializedPrimaryKey" | "serializer" | "setter" | "type" | "unique" | "unsigned" | "version" | ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type")>;
|
|
46
|
+
readonly providerMessageId: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<string, Omit<import("@mikro-orm/core").EmptyOptions, "nullable"> & {
|
|
47
|
+
nullable: true;
|
|
48
|
+
} & {
|
|
49
|
+
readonly '~c': true;
|
|
50
|
+
}, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>;
|
|
51
|
+
readonly error: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<string, Omit<import("@mikro-orm/core").EmptyOptions, "nullable"> & {
|
|
52
|
+
nullable: true;
|
|
53
|
+
} & {
|
|
54
|
+
readonly '~c': true;
|
|
55
|
+
}, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>;
|
|
56
|
+
readonly metadata: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<unknown, Omit<import("@mikro-orm/core").EmptyOptions, "nullable"> & {
|
|
57
|
+
nullable: true;
|
|
58
|
+
} & {
|
|
59
|
+
readonly '~c': true;
|
|
60
|
+
}, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>;
|
|
61
|
+
}, import("@mikro-orm/core").EntityCtor<import("@mikro-orm/core").InferEntityFromProperties<{
|
|
62
|
+
readonly id: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<string, Omit<import("@mikro-orm/core").EmptyOptions, "primary"> & {
|
|
63
|
+
primary: true;
|
|
64
|
+
} & {
|
|
65
|
+
readonly '~c': true;
|
|
66
|
+
}, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>;
|
|
67
|
+
readonly to: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<string, import("@mikro-orm/core").EmptyOptions & {
|
|
68
|
+
readonly '~c': true;
|
|
69
|
+
}, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>;
|
|
70
|
+
readonly body: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<string, import("@mikro-orm/core").EmptyOptions & {
|
|
71
|
+
readonly '~c': true;
|
|
72
|
+
}, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>;
|
|
73
|
+
readonly status: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<any, import("@mikro-orm/core").EmptyOptions & {
|
|
74
|
+
readonly '~c': true;
|
|
75
|
+
}, "accessor" | "array" | "autoincrement" | "check" | "collation" | "columnType" | "columnTypes" | "comment" | "compliance" | "concurrencyCheck" | "customOrder" | "default" | "defaultRaw" | "extra" | "fieldName" | "fieldNames" | "formula" | "generated" | "getter" | "getterName" | "groups" | "hidden" | "hydrate" | "ignoreSchemaChanges" | "index" | "lazy" | "length" | "name" | "nativeEnumName" | "nullable" | "onCreate" | "onUpdate" | "persist" | "precision" | "primary" | "ref" | "returning" | "runtimeType" | "scale" | "serializedName" | "serializedPrimaryKey" | "serializer" | "setter" | "type" | "unique" | "unsigned" | "version" | ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type")>, "accessor" | "array" | "autoincrement" | "check" | "collation" | "columnType" | "columnTypes" | "comment" | "compliance" | "concurrencyCheck" | "customOrder" | "default" | "defaultRaw" | "extra" | "fieldName" | "fieldNames" | "formula" | "generated" | "getter" | "getterName" | "groups" | "hidden" | "hydrate" | "ignoreSchemaChanges" | "index" | "lazy" | "length" | "name" | "nativeEnumName" | "nullable" | "onCreate" | "onUpdate" | "persist" | "precision" | "primary" | "ref" | "returning" | "runtimeType" | "scale" | "serializedName" | "serializedPrimaryKey" | "serializer" | "setter" | "type" | "unique" | "unsigned" | "version" | ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type")>;
|
|
76
|
+
readonly providerMessageId: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<string, Omit<import("@mikro-orm/core").EmptyOptions, "nullable"> & {
|
|
77
|
+
nullable: true;
|
|
78
|
+
} & {
|
|
79
|
+
readonly '~c': true;
|
|
80
|
+
}, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>;
|
|
81
|
+
readonly error: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<string, Omit<import("@mikro-orm/core").EmptyOptions, "nullable"> & {
|
|
82
|
+
nullable: true;
|
|
83
|
+
} & {
|
|
84
|
+
readonly '~c': true;
|
|
85
|
+
}, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>;
|
|
86
|
+
readonly metadata: Pick<import("@mikro-orm/core").UniversalPropertyOptionsBuilder<unknown, Omit<import("@mikro-orm/core").EmptyOptions, "nullable"> & {
|
|
87
|
+
nullable: true;
|
|
88
|
+
} & {
|
|
89
|
+
readonly '~c': true;
|
|
90
|
+
}, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>, ("$type" | "lazyRef" | "strictNullable" | "~options" | "~type") | keyof import("@mikro-orm/core").PropertyOptions<any>>;
|
|
91
|
+
}, undefined, never, never, false>>, undefined>;
|
|
92
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../persistence/entities/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+CAWpB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// persistence/entities/index.ts
|
|
21
|
+
var entities_exports = {};
|
|
22
|
+
__export(entities_exports, {
|
|
23
|
+
SmsRecord: () => SmsRecord
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(entities_exports);
|
|
26
|
+
var import_persistence = require("@forklaunch/core/persistence");
|
|
27
|
+
var SmsRecord = (0, import_persistence.defineComplianceEntity)({
|
|
28
|
+
name: "SmsRecord",
|
|
29
|
+
properties: {
|
|
30
|
+
id: import_persistence.fp.string().primary().compliance("none"),
|
|
31
|
+
to: import_persistence.fp.string().compliance("pii"),
|
|
32
|
+
body: import_persistence.fp.string().compliance("pii"),
|
|
33
|
+
status: import_persistence.fp.enum().compliance("none"),
|
|
34
|
+
providerMessageId: import_persistence.fp.string().nullable().compliance("none"),
|
|
35
|
+
error: import_persistence.fp.string().nullable().compliance("none"),
|
|
36
|
+
metadata: import_persistence.fp.json().nullable().compliance("none")
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
SmsRecord
|
|
42
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// persistence/entities/index.ts
|
|
2
|
+
import { defineComplianceEntity, fp } from "@forklaunch/core/persistence";
|
|
3
|
+
var SmsRecord = defineComplianceEntity({
|
|
4
|
+
name: "SmsRecord",
|
|
5
|
+
properties: {
|
|
6
|
+
id: fp.string().primary().compliance("none"),
|
|
7
|
+
to: fp.string().compliance("pii"),
|
|
8
|
+
body: fp.string().compliance("pii"),
|
|
9
|
+
status: fp.enum().compliance("none"),
|
|
10
|
+
providerMessageId: fp.string().nullable().compliance("none"),
|
|
11
|
+
error: fp.string().nullable().compliance("none"),
|
|
12
|
+
metadata: fp.json().nullable().compliance("none")
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
export {
|
|
16
|
+
SmsRecord
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../services/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAE9B,cAAc,6CAA6C,CAAC;AAC5D,cAAc,wCAAwC,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// services/index.ts
|
|
22
|
+
var services_exports = {};
|
|
23
|
+
__export(services_exports, {
|
|
24
|
+
BaseSmsService: () => BaseSmsService
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(services_exports);
|
|
27
|
+
|
|
28
|
+
// services/sms.service.ts
|
|
29
|
+
var import_http = require("@forklaunch/core/http");
|
|
30
|
+
var import_core = require("@mikro-orm/core");
|
|
31
|
+
|
|
32
|
+
// domain/enum/smsStatus.enum.ts
|
|
33
|
+
var SmsStatusEnum = {
|
|
34
|
+
QUEUED: "queued",
|
|
35
|
+
SENT: "sent",
|
|
36
|
+
DELIVERED: "delivered",
|
|
37
|
+
FAILED: "failed",
|
|
38
|
+
UNDELIVERED: "undelivered"
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// services/sms.service.ts
|
|
42
|
+
var BaseSmsService = class {
|
|
43
|
+
evaluatedTelemetryOptions;
|
|
44
|
+
em;
|
|
45
|
+
openTelemetryCollector;
|
|
46
|
+
schemaValidator;
|
|
47
|
+
mappers;
|
|
48
|
+
constructor(em, openTelemetryCollector, schemaValidator, mappers, options) {
|
|
49
|
+
this.em = em;
|
|
50
|
+
this.openTelemetryCollector = openTelemetryCollector;
|
|
51
|
+
this.schemaValidator = schemaValidator;
|
|
52
|
+
this.mappers = mappers;
|
|
53
|
+
this.evaluatedTelemetryOptions = options?.telemetry ? (0, import_http.evaluateTelemetryOptions)(options.telemetry).enabled : {
|
|
54
|
+
logging: false,
|
|
55
|
+
metrics: false,
|
|
56
|
+
tracing: false
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
async sendSms(smsDto, em, ...args) {
|
|
60
|
+
this.openTelemetryCollector.info("Sending sms (base implementation)", {
|
|
61
|
+
to: smsDto.to,
|
|
62
|
+
body: smsDto.body
|
|
63
|
+
});
|
|
64
|
+
const smsRecord = await this.mappers.SendSmsMapper.toEntity(
|
|
65
|
+
smsDto,
|
|
66
|
+
em ?? this.em,
|
|
67
|
+
...args[0] instanceof import_core.EntityManager ? args.slice(1) : args
|
|
68
|
+
);
|
|
69
|
+
smsRecord.status = SmsStatusEnum.SENT;
|
|
70
|
+
await (em ?? this.em).transactional(async (innerEm) => {
|
|
71
|
+
await innerEm.persist(smsRecord);
|
|
72
|
+
});
|
|
73
|
+
return this.mappers.SmsRecordMapper.toDto(
|
|
74
|
+
smsRecord
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
async getSmsRecord({ id }, em) {
|
|
78
|
+
if (this.evaluatedTelemetryOptions.logging) {
|
|
79
|
+
this.openTelemetryCollector.info("Getting sms record", { id });
|
|
80
|
+
}
|
|
81
|
+
const smsRecord = await (em ?? this.em).findOneOrFail(
|
|
82
|
+
this.mappers.SmsRecordMapper.entity,
|
|
83
|
+
{ id }
|
|
84
|
+
);
|
|
85
|
+
return this.mappers.SmsRecordMapper.toDto(
|
|
86
|
+
smsRecord
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// services/index.ts
|
|
92
|
+
__reExport(services_exports, require("@forklaunch/interfaces-messaging/interfaces"), module.exports);
|
|
93
|
+
__reExport(services_exports, require("@forklaunch/interfaces-messaging/types"), module.exports);
|
|
94
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
95
|
+
0 && (module.exports = {
|
|
96
|
+
BaseSmsService,
|
|
97
|
+
...require("@forklaunch/interfaces-messaging/interfaces"),
|
|
98
|
+
...require("@forklaunch/interfaces-messaging/types")
|
|
99
|
+
});
|
|
100
|
+
//! the base implementation does not dispatch to a provider — it logs the
|
|
101
|
+
//! message via the OpenTelemetryCollector and marks the record as sent
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// services/sms.service.ts
|
|
2
|
+
import {
|
|
3
|
+
evaluateTelemetryOptions
|
|
4
|
+
} from "@forklaunch/core/http";
|
|
5
|
+
import { EntityManager } from "@mikro-orm/core";
|
|
6
|
+
|
|
7
|
+
// domain/enum/smsStatus.enum.ts
|
|
8
|
+
var SmsStatusEnum = {
|
|
9
|
+
QUEUED: "queued",
|
|
10
|
+
SENT: "sent",
|
|
11
|
+
DELIVERED: "delivered",
|
|
12
|
+
FAILED: "failed",
|
|
13
|
+
UNDELIVERED: "undelivered"
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// services/sms.service.ts
|
|
17
|
+
var BaseSmsService = class {
|
|
18
|
+
evaluatedTelemetryOptions;
|
|
19
|
+
em;
|
|
20
|
+
openTelemetryCollector;
|
|
21
|
+
schemaValidator;
|
|
22
|
+
mappers;
|
|
23
|
+
constructor(em, openTelemetryCollector, schemaValidator, mappers, options) {
|
|
24
|
+
this.em = em;
|
|
25
|
+
this.openTelemetryCollector = openTelemetryCollector;
|
|
26
|
+
this.schemaValidator = schemaValidator;
|
|
27
|
+
this.mappers = mappers;
|
|
28
|
+
this.evaluatedTelemetryOptions = options?.telemetry ? evaluateTelemetryOptions(options.telemetry).enabled : {
|
|
29
|
+
logging: false,
|
|
30
|
+
metrics: false,
|
|
31
|
+
tracing: false
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
async sendSms(smsDto, em, ...args) {
|
|
35
|
+
this.openTelemetryCollector.info("Sending sms (base implementation)", {
|
|
36
|
+
to: smsDto.to,
|
|
37
|
+
body: smsDto.body
|
|
38
|
+
});
|
|
39
|
+
const smsRecord = await this.mappers.SendSmsMapper.toEntity(
|
|
40
|
+
smsDto,
|
|
41
|
+
em ?? this.em,
|
|
42
|
+
...args[0] instanceof EntityManager ? args.slice(1) : args
|
|
43
|
+
);
|
|
44
|
+
smsRecord.status = SmsStatusEnum.SENT;
|
|
45
|
+
await (em ?? this.em).transactional(async (innerEm) => {
|
|
46
|
+
await innerEm.persist(smsRecord);
|
|
47
|
+
});
|
|
48
|
+
return this.mappers.SmsRecordMapper.toDto(
|
|
49
|
+
smsRecord
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
async getSmsRecord({ id }, em) {
|
|
53
|
+
if (this.evaluatedTelemetryOptions.logging) {
|
|
54
|
+
this.openTelemetryCollector.info("Getting sms record", { id });
|
|
55
|
+
}
|
|
56
|
+
const smsRecord = await (em ?? this.em).findOneOrFail(
|
|
57
|
+
this.mappers.SmsRecordMapper.entity,
|
|
58
|
+
{ id }
|
|
59
|
+
);
|
|
60
|
+
return this.mappers.SmsRecordMapper.toDto(
|
|
61
|
+
smsRecord
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// services/index.ts
|
|
67
|
+
export * from "@forklaunch/interfaces-messaging/interfaces";
|
|
68
|
+
export * from "@forklaunch/interfaces-messaging/types";
|
|
69
|
+
export {
|
|
70
|
+
BaseSmsService
|
|
71
|
+
};
|
|
72
|
+
//! the base implementation does not dispatch to a provider — it logs the
|
|
73
|
+
//! message via the OpenTelemetryCollector and marks the record as sent
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IdDto } from '@forklaunch/common';
|
|
2
|
+
import { MetricsDefinition, OpenTelemetryCollector, TelemetryOptions } from '@forklaunch/core/http';
|
|
3
|
+
import { SmsService } from '@forklaunch/interfaces-messaging/interfaces';
|
|
4
|
+
import { SendSmsDto } from '@forklaunch/interfaces-messaging/types';
|
|
5
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
6
|
+
import { EntityManager } from '@mikro-orm/core';
|
|
7
|
+
import { BaseSmsDtos } from '../domain/types/baseSmsDto.types';
|
|
8
|
+
import { BaseSmsEntities } from '../domain/types/baseSmsEntity.types';
|
|
9
|
+
import { SmsMappers } from '../domain/types/sms.mapper.types';
|
|
10
|
+
export declare class BaseSmsService<SchemaValidator extends AnySchemaValidator, StatusEnum, MapperEntities extends BaseSmsEntities<StatusEnum>, MapperDomains extends BaseSmsDtos<StatusEnum> = BaseSmsDtos<StatusEnum>> implements SmsService<StatusEnum> {
|
|
11
|
+
private evaluatedTelemetryOptions;
|
|
12
|
+
em: EntityManager;
|
|
13
|
+
protected openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
|
14
|
+
protected schemaValidator: SchemaValidator;
|
|
15
|
+
protected mappers: SmsMappers<StatusEnum, MapperEntities, MapperDomains>;
|
|
16
|
+
constructor(em: EntityManager, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: SmsMappers<StatusEnum, MapperEntities, MapperDomains>, options?: {
|
|
17
|
+
telemetry?: TelemetryOptions;
|
|
18
|
+
});
|
|
19
|
+
sendSms(smsDto: SendSmsDto, em?: EntityManager, ...args: unknown[]): Promise<MapperDomains['SmsRecordMapper']>;
|
|
20
|
+
getSmsRecord({ id }: IdDto, em?: EntityManager): Promise<MapperDomains['SmsRecordMapper']>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=sms.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sms.service.d.ts","sourceRoot":"","sources":["../../services/sms.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAEL,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAe,MAAM,iBAAiB,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAG9D,qBAAa,cAAc,CACzB,eAAe,SAAS,kBAAkB,EAC1C,UAAU,EACV,cAAc,SAAS,eAAe,CAAC,UAAU,CAAC,EAClD,aAAa,SAAS,WAAW,CAAC,UAAU,CAAC,GAAG,WAAW,CAAC,UAAU,CAAC,CACvE,YAAW,UAAU,CAAC,UAAU,CAAC;IAEjC,OAAO,CAAC,yBAAyB,CAI/B;IACK,EAAE,EAAE,aAAa,CAAC;IACzB,SAAS,CAAC,sBAAsB,EAAE,sBAAsB,CAAC,iBAAiB,CAAC,CAAC;IAC5E,SAAS,CAAC,eAAe,EAAE,eAAe,CAAC;IAC3C,SAAS,CAAC,OAAO,EAAE,UAAU,CAAC,UAAU,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC;IAEzE,YACE,EAAE,EAAE,aAAa,EACjB,sBAAsB,EAAE,sBAAsB,CAAC,iBAAiB,CAAC,EACjE,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,UAAU,CAAC,UAAU,EAAE,cAAc,EAAE,aAAa,CAAC,EAC9D,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,gBAAgB,CAAC;KAC9B,EAaF;IAEK,OAAO,CACX,MAAM,EAAE,UAAU,EAClB,EAAE,CAAC,EAAE,aAAa,EAClB,GAAG,IAAI,EAAE,OAAO,EAAE,GACjB,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAuB3C;IAEK,YAAY,CAChB,EAAE,EAAE,EAAE,EAAE,KAAK,EACb,EAAE,CAAC,EAAE,aAAa,GACjB,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAa3C;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@forklaunch/implementation-messaging-base",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Messaging basic implementation for forklaunch",
|
|
5
|
+
"homepage": "https://github.com/forklaunch/forklaunch-js#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/forklaunch/forklaunch-js/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/forklaunch/forklaunch-js.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "Forklift Technologies, Inc.",
|
|
15
|
+
"exports": {
|
|
16
|
+
"./enum": {
|
|
17
|
+
"types": "./lib/domain/enum/index.d.ts",
|
|
18
|
+
"import": "./lib/domain/enum/index.mjs",
|
|
19
|
+
"require": "./lib/domain/enum/index.js",
|
|
20
|
+
"default": "./lib/domain/enum/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./schemas": {
|
|
23
|
+
"types": "./lib/domain/schemas/index.d.ts",
|
|
24
|
+
"import": "./lib/domain/schemas/index.mjs",
|
|
25
|
+
"require": "./lib/domain/schemas/index.js",
|
|
26
|
+
"default": "./lib/domain/schemas/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./services": {
|
|
29
|
+
"types": "./lib/services/index.d.ts",
|
|
30
|
+
"import": "./lib/services/index.mjs",
|
|
31
|
+
"require": "./lib/services/index.js",
|
|
32
|
+
"default": "./lib/services/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./types": {
|
|
35
|
+
"types": "./lib/domain/types/index.d.ts",
|
|
36
|
+
"import": "./lib/domain/types/index.mjs",
|
|
37
|
+
"require": "./lib/domain/types/index.js",
|
|
38
|
+
"default": "./lib/domain/types/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./enum/*": {
|
|
41
|
+
"types": "./lib/domain/enum/*.d.ts"
|
|
42
|
+
},
|
|
43
|
+
"./schemas/*": {
|
|
44
|
+
"types": "./lib/domain/schemas/*.d.ts"
|
|
45
|
+
},
|
|
46
|
+
"./services/*": {
|
|
47
|
+
"types": "./lib/services/*.d.ts"
|
|
48
|
+
},
|
|
49
|
+
"./types/*": {
|
|
50
|
+
"types": "./lib/domain/types/*.d.ts"
|
|
51
|
+
},
|
|
52
|
+
"./persistence": {
|
|
53
|
+
"types": "./lib/persistence/entities/index.d.ts",
|
|
54
|
+
"import": "./lib/persistence/entities/index.mjs",
|
|
55
|
+
"require": "./lib/persistence/entities/index.js",
|
|
56
|
+
"default": "./lib/persistence/entities/index.js"
|
|
57
|
+
},
|
|
58
|
+
"./persistence/*": {
|
|
59
|
+
"types": "./lib/persistence/entities/*.d.ts"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"files": [
|
|
63
|
+
"lib/**"
|
|
64
|
+
],
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"@forklaunch/common": "^1.2.23",
|
|
67
|
+
"@forklaunch/core": "^1.5.15",
|
|
68
|
+
"@forklaunch/internal": "^1.2.24",
|
|
69
|
+
"@forklaunch/validator": "^1.2.24",
|
|
70
|
+
"@mikro-orm/core": "^7.1.11",
|
|
71
|
+
"@sinclair/typebox": "^0.34.52",
|
|
72
|
+
"ajv": "^8.20.0",
|
|
73
|
+
"zod": "^4.4.3",
|
|
74
|
+
"@forklaunch/interfaces-messaging": "^1.0.0"
|
|
75
|
+
},
|
|
76
|
+
"devDependencies": {
|
|
77
|
+
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
78
|
+
"depcheck": "^1.4.7",
|
|
79
|
+
"prettier": "^3.9.6",
|
|
80
|
+
"typedoc": "^0.28.20"
|
|
81
|
+
},
|
|
82
|
+
"publishConfig": {
|
|
83
|
+
"access": "public"
|
|
84
|
+
},
|
|
85
|
+
"scripts": {
|
|
86
|
+
"build": "tsgo --noEmit && tsup persistence/entities/index.ts domain/schemas/index.ts services/index.ts domain/enum/index.ts domain/types/index.ts --format cjs,esm --no-splitting --tsconfig tsconfig.json --out-dir lib --clean && tsgo -p tsconfig.build.json --emitDeclarationOnly && if [ -f eject-package.bash ]; then pnpm package:eject; fi",
|
|
87
|
+
"clean": "rm -rf lib pnpm.lock.yaml node_modules",
|
|
88
|
+
"docs": "typedoc --out docs *",
|
|
89
|
+
"format": "prettier --ignore-path=.prettierignore --config .prettierrc '**/*.{ts,tsx,json}' --write",
|
|
90
|
+
"lint": "eslint . -c eslint.config.mjs",
|
|
91
|
+
"lint:fix": "eslint . -c eslint.config.mjs --fix",
|
|
92
|
+
"package:eject": "./eject-package.bash",
|
|
93
|
+
"publish:package": "./publish-package.bash",
|
|
94
|
+
"test": "vitest --passWithNoTests"
|
|
95
|
+
}
|
|
96
|
+
}
|