grm-shared-library 1.1.213 → 1.1.215

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.
Files changed (60) hide show
  1. package/README.md +16 -0
  2. package/dist/cjs/index.js +1 -0
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/modules/alert-intake/dtos/alert-intake.dto.js +306 -0
  5. package/dist/cjs/modules/alert-intake/dtos/alert-intake.dto.js.map +1 -0
  6. package/dist/cjs/modules/alert-intake/enums/alert-intake.enum.js +116 -0
  7. package/dist/cjs/modules/alert-intake/enums/alert-intake.enum.js.map +1 -0
  8. package/dist/cjs/modules/alert-intake/index.js +25 -0
  9. package/dist/cjs/modules/alert-intake/index.js.map +1 -0
  10. package/dist/cjs/modules/alert-intake/interfaces/alert-intake.js +3 -0
  11. package/dist/cjs/modules/alert-intake/interfaces/alert-intake.js.map +1 -0
  12. package/dist/cjs/modules/alert-intake/utils/alert-intake.util.js +48 -0
  13. package/dist/cjs/modules/alert-intake/utils/alert-intake.util.js.map +1 -0
  14. package/dist/cjs/modules/notification/dtos/alert-acknowledgement.dto.js +55 -0
  15. package/dist/cjs/modules/notification/dtos/alert-acknowledgement.dto.js.map +1 -0
  16. package/dist/cjs/modules/notification/index.js +2 -0
  17. package/dist/cjs/modules/notification/index.js.map +1 -1
  18. package/dist/cjs/modules/permission/data/permissions.data.js +8 -0
  19. package/dist/cjs/modules/permission/data/permissions.data.js.map +1 -1
  20. package/dist/cjs/modules/permission/enums/permission-actions.enum.js +16 -0
  21. package/dist/cjs/modules/permission/enums/permission-actions.enum.js.map +1 -1
  22. package/dist/cjs/modules/permission/enums/permissions-module.enum.js +1 -0
  23. package/dist/cjs/modules/permission/enums/permissions-module.enum.js.map +1 -1
  24. package/dist/cjs/modules/role/data/roles.data.js +8 -0
  25. package/dist/cjs/modules/role/data/roles.data.js.map +1 -1
  26. package/dist/esm/index.js +1 -0
  27. package/dist/esm/index.js.map +1 -1
  28. package/dist/esm/modules/alert-intake/dtos/alert-intake.dto.js +296 -0
  29. package/dist/esm/modules/alert-intake/dtos/alert-intake.dto.js.map +1 -0
  30. package/dist/esm/modules/alert-intake/enums/alert-intake.enum.js +113 -0
  31. package/dist/esm/modules/alert-intake/enums/alert-intake.enum.js.map +1 -0
  32. package/dist/esm/modules/alert-intake/index.js +9 -0
  33. package/dist/esm/modules/alert-intake/index.js.map +1 -0
  34. package/dist/esm/modules/alert-intake/interfaces/alert-intake.js +2 -0
  35. package/dist/esm/modules/alert-intake/interfaces/alert-intake.js.map +1 -0
  36. package/dist/esm/modules/alert-intake/utils/alert-intake.util.js +42 -0
  37. package/dist/esm/modules/alert-intake/utils/alert-intake.util.js.map +1 -0
  38. package/dist/esm/modules/notification/dtos/alert-acknowledgement.dto.js +51 -0
  39. package/dist/esm/modules/notification/dtos/alert-acknowledgement.dto.js.map +1 -0
  40. package/dist/esm/modules/notification/index.js +2 -0
  41. package/dist/esm/modules/notification/index.js.map +1 -1
  42. package/dist/esm/modules/permission/data/permissions.data.js +8 -0
  43. package/dist/esm/modules/permission/data/permissions.data.js.map +1 -1
  44. package/dist/esm/modules/permission/enums/permission-actions.enum.js +16 -0
  45. package/dist/esm/modules/permission/enums/permission-actions.enum.js.map +1 -1
  46. package/dist/esm/modules/permission/enums/permissions-module.enum.js +1 -0
  47. package/dist/esm/modules/permission/enums/permissions-module.enum.js.map +1 -1
  48. package/dist/esm/modules/role/data/roles.data.js +8 -0
  49. package/dist/esm/modules/role/data/roles.data.js.map +1 -1
  50. package/dist/types/index.d.ts +1 -0
  51. package/dist/types/modules/alert-intake/dtos/alert-intake.dto.d.ts +55 -0
  52. package/dist/types/modules/alert-intake/enums/alert-intake.enum.d.ts +101 -0
  53. package/dist/types/modules/alert-intake/index.d.ts +4 -0
  54. package/dist/types/modules/alert-intake/interfaces/alert-intake.d.ts +230 -0
  55. package/dist/types/modules/alert-intake/utils/alert-intake.util.d.ts +24 -0
  56. package/dist/types/modules/notification/dtos/alert-acknowledgement.dto.d.ts +17 -0
  57. package/dist/types/modules/notification/index.d.ts +1 -0
  58. package/dist/types/modules/permission/enums/permission-actions.enum.d.ts +4 -1
  59. package/dist/types/modules/permission/enums/permissions-module.enum.d.ts +2 -1
  60. package/package.json +1 -1
package/README.md CHANGED
@@ -175,6 +175,22 @@ clarion-authentication (emitter):
175
175
  - Every send result records `sender` and `senderSource`
176
176
  (`ORGANIZATION` | `PLATFORM_DEFAULT`), so "why was this Upesy-branded?" is a query.
177
177
 
178
+ ### clarion-billing → clarion-notification (HTTP)
179
+
180
+ `BillingEmailNotificationDto`, `BillingSmsNotificationDto`, `BillingPushNotificationDto`
181
+ and their result types are the contract for `POST /billing/notifications/email | sms |
182
+ push` — the synchronous path clarion-billing uses when it wants to know a message left.
183
+ clarion-billing's `NotificationClientService` types its requests from these; do not
184
+ redeclare the fields there.
185
+
186
+ - `BillingEmailTemplate` is a **closed set**. The route renders a template by name on
187
+ another service's say-so, so an open string would let a caller render any template.
188
+ A new value needs copy defaults in clarion-notification (`api/billing`).
189
+ - Attachments go **by reference** (`documents[].signedUrl`), because billing PDFs are
190
+ private and their signed URLs expire within the hour. `signedUrl` must be `https`,
191
+ file names must be bare names, and a subject may not contain a line break.
192
+ - Every list and string is bounded; `billing-notification.spec.ts` pins the limits.
193
+
178
194
  Values that end up inside email CSS or headers are validated as such: colours are
179
195
  `#RRGGBB` only, logos are `https` only, and a sender display name may not contain a
180
196
  line break. `notification-sender.spec.ts` pins each of those.
package/dist/cjs/index.js CHANGED
@@ -41,6 +41,7 @@ __exportStar(require("./modules/alert-dispatch/index"), exports);
41
41
  __exportStar(require("./modules/system-user/index"), exports);
42
42
  __exportStar(require("./modules/partner/index"), exports);
43
43
  __exportStar(require("./modules/support/index"), exports);
44
+ __exportStar(require("./modules/alert-intake/index"), exports);
44
45
  // Interfaces
45
46
  __exportStar(require("./interfaces/server-message"), exports);
46
47
  __exportStar(require("./interfaces/i-request-with-user"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,UAAU;AACV,uDAAqC;AACrC,+DAA6C;AAC7C,yDAAuC;AACvC,6DAA2C;AAC3C,uDAAqC;AACrC,uDAAqC;AACrC,iEAA+C;AAC/C,wDAAsC;AACtC,gEAA8C;AAC9C,2DAAyC;AACzC,2DAAyC;AACzC,sDAAoC;AACpC,sDAAoC;AACpC,sDAAoC;AACpC,yDAAuC;AACvC,mEAAiD;AACjD,+DAA6C;AAC7C,uDAAqC;AACrC,0DAAwC;AACxC,wDAAsC;AACtC,2DAAyC;AACzC,8DAA4C;AAC5C,iEAA+C;AAC/C,8DAA4C;AAC5C,0DAAwC;AACxC,0DAAwC;AAExC,aAAa;AACb,8DAA4C;AAC5C,mEAAiD;AACjD,8DAA4C;AAC5C,2DAAyC;AACzC,0DAAwC;AAExC,YAAY;AACZ,2DAAyC;AAEzC,QAAQ;AACR,gDAA8B;AAE9B,YAAY;AACZ,+DAA6C;AAC7C,wFAAsE;AAEtE,aAAa;AACb,qDAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,UAAU;AACV,uDAAqC;AACrC,+DAA6C;AAC7C,yDAAuC;AACvC,6DAA2C;AAC3C,uDAAqC;AACrC,uDAAqC;AACrC,iEAA+C;AAC/C,wDAAsC;AACtC,gEAA8C;AAC9C,2DAAyC;AACzC,2DAAyC;AACzC,sDAAoC;AACpC,sDAAoC;AACpC,sDAAoC;AACpC,yDAAuC;AACvC,mEAAiD;AACjD,+DAA6C;AAC7C,uDAAqC;AACrC,0DAAwC;AACxC,wDAAsC;AACtC,2DAAyC;AACzC,8DAA4C;AAC5C,iEAA+C;AAC/C,8DAA4C;AAC5C,0DAAwC;AACxC,0DAAwC;AACxC,+DAA6C;AAE7C,aAAa;AACb,8DAA4C;AAC5C,mEAAiD;AACjD,8DAA4C;AAC5C,2DAAyC;AACzC,0DAAwC;AAExC,YAAY;AACZ,2DAAyC;AAEzC,QAAQ;AACR,gDAA8B;AAE9B,YAAY;AACZ,+DAA6C;AAC7C,wFAAsE;AAEtE,aAAa;AACb,qDAAmC"}
@@ -0,0 +1,306 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AssignAlertIntakeMessageDto = exports.ListPlatformAlertIntakeMessagesQueryDto = exports.ListAlertIntakeMessagesQueryDto = exports.UpdateAlertIntakeRouteDto = exports.CreateAlertIntakeRouteDto = exports.UpdateAlertIntakeConnectionDto = exports.CreateAlertIntakeConnectionDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const class_transformer_1 = require("class-transformer");
15
+ const class_validator_1 = require("class-validator");
16
+ const alert_intake_enum_1 = require("../enums/alert-intake.enum");
17
+ const alert_intake_util_1 = require("../utils/alert-intake.util");
18
+ const trim = ({ value }) => (typeof value === 'string' ? value.trim() : value);
19
+ const SINGLE_LINE = /^[^\r\n]*$/;
20
+ const MAX_SETTINGS = 40;
21
+ /**
22
+ * A flat bag of provider settings: a handful of short primitive values, keyed by the
23
+ * names the provider's descriptor declares. WHICH keys are allowed is the service's
24
+ * job (it has the descriptor); this only guarantees the bag cannot be a way to post
25
+ * a megabyte of nested JSON at a settings table.
26
+ */
27
+ function IsFlatSettings(options = {}, validationOptions) {
28
+ return (object, propertyName) => (0, class_validator_1.registerDecorator)({
29
+ name: 'isFlatSettings',
30
+ target: object.constructor,
31
+ propertyName,
32
+ options: validationOptions,
33
+ validator: {
34
+ validate(value) {
35
+ if (value === null || typeof value !== 'object' || Array.isArray(value))
36
+ return false;
37
+ const entries = Object.entries(value);
38
+ if (entries.length > MAX_SETTINGS)
39
+ return false;
40
+ return entries.every(([key, item]) => {
41
+ if (!/^[A-Za-z][A-Za-z0-9_]{0,59}$/.test(key))
42
+ return false;
43
+ if (typeof item === 'string')
44
+ return item.length <= alert_intake_util_1.MAX_ALERT_INTAKE_SETTING_LENGTH;
45
+ if (options.stringsOnly)
46
+ return false;
47
+ return typeof item === 'boolean' || (typeof item === 'number' && Number.isFinite(item));
48
+ });
49
+ },
50
+ defaultMessage(args) {
51
+ return `${args.property} must be a flat object of at most ${MAX_SETTINGS} short ${options.stringsOnly ? 'string' : 'string, number or boolean'} values`;
52
+ },
53
+ },
54
+ });
55
+ }
56
+ class CreateAlertIntakeConnectionDto {
57
+ }
58
+ exports.CreateAlertIntakeConnectionDto = CreateAlertIntakeConnectionDto;
59
+ __decorate([
60
+ (0, swagger_1.ApiProperty)({ enum: alert_intake_enum_1.AlertIntakeChannel }),
61
+ (0, class_validator_1.IsEnum)(alert_intake_enum_1.AlertIntakeChannel),
62
+ __metadata("design:type", String)
63
+ ], CreateAlertIntakeConnectionDto.prototype, "channel", void 0);
64
+ __decorate([
65
+ (0, swagger_1.ApiProperty)({ enum: alert_intake_enum_1.AlertIntakeProvider }),
66
+ (0, class_validator_1.IsEnum)(alert_intake_enum_1.AlertIntakeProvider),
67
+ __metadata("design:type", String)
68
+ ], CreateAlertIntakeConnectionDto.prototype, "provider", void 0);
69
+ __decorate([
70
+ (0, swagger_1.ApiProperty)({ example: 'G4S emergency short code' }),
71
+ (0, class_transformer_1.Transform)(trim),
72
+ (0, class_validator_1.IsString)(),
73
+ (0, class_validator_1.MinLength)(2),
74
+ (0, class_validator_1.MaxLength)(100),
75
+ (0, class_validator_1.Matches)(SINGLE_LINE),
76
+ __metadata("design:type", String)
77
+ ], CreateAlertIntakeConnectionDto.prototype, "name", void 0);
78
+ __decorate([
79
+ (0, swagger_1.ApiProperty)({
80
+ example: '22384',
81
+ description: 'What people send to: the short code or number, the WhatsApp phone-number id, the mailbox address.',
82
+ }),
83
+ (0, class_transformer_1.Transform)(trim),
84
+ (0, class_validator_1.IsString)(),
85
+ (0, class_validator_1.MinLength)(1),
86
+ (0, class_validator_1.MaxLength)(254),
87
+ (0, class_validator_1.Matches)(SINGLE_LINE),
88
+ __metadata("design:type", String)
89
+ ], CreateAlertIntakeConnectionDto.prototype, "address", void 0);
90
+ __decorate([
91
+ (0, swagger_1.ApiPropertyOptional)({ default: true }),
92
+ (0, class_validator_1.IsBoolean)(),
93
+ (0, class_validator_1.IsOptional)(),
94
+ __metadata("design:type", Boolean)
95
+ ], CreateAlertIntakeConnectionDto.prototype, "enabled", void 0);
96
+ __decorate([
97
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Non-secret provider settings, as the provider descriptor declares them.' }),
98
+ IsFlatSettings(),
99
+ (0, class_validator_1.IsOptional)(),
100
+ __metadata("design:type", Object)
101
+ ], CreateAlertIntakeConnectionDto.prototype, "config", void 0);
102
+ __decorate([
103
+ (0, swagger_1.ApiPropertyOptional)({
104
+ description: 'Credentials. WRITE-ONLY: encrypted at rest and never returned. Keys are the descriptor\'s secret fields.',
105
+ }),
106
+ IsFlatSettings({ stringsOnly: true }),
107
+ (0, class_validator_1.IsOptional)(),
108
+ __metadata("design:type", Object)
109
+ ], CreateAlertIntakeConnectionDto.prototype, "secrets", void 0);
110
+ __decorate([
111
+ (0, swagger_1.ApiPropertyOptional)({
112
+ description: 'Platform operators only. NAMES of provisioned secrets, used instead of `secrets`. ' +
113
+ 'A connection uses one or the other, never both.',
114
+ }),
115
+ IsFlatSettings({ stringsOnly: true }),
116
+ (0, class_validator_1.IsOptional)(),
117
+ __metadata("design:type", Object)
118
+ ], CreateAlertIntakeConnectionDto.prototype, "secretReferences", void 0);
119
+ __decorate([
120
+ (0, swagger_1.ApiPropertyOptional)({ enum: alert_intake_enum_1.AlertIntakeEmergencyPolicy, default: alert_intake_enum_1.AlertIntakeEmergencyPolicy.AUTO }),
121
+ (0, class_validator_1.IsEnum)(alert_intake_enum_1.AlertIntakeEmergencyPolicy),
122
+ (0, class_validator_1.IsOptional)(),
123
+ __metadata("design:type", String)
124
+ ], CreateAlertIntakeConnectionDto.prototype, "emergencyPolicy", void 0);
125
+ /**
126
+ * Channel and provider cannot change: a connection IS its provider link, and the
127
+ * webhook URL registered with that provider would silently start meaning something
128
+ * else. Create a new connection instead.
129
+ */
130
+ class UpdateAlertIntakeConnectionDto {
131
+ }
132
+ exports.UpdateAlertIntakeConnectionDto = UpdateAlertIntakeConnectionDto;
133
+ __decorate([
134
+ (0, swagger_1.ApiPropertyOptional)(),
135
+ (0, class_transformer_1.Transform)(trim),
136
+ (0, class_validator_1.IsString)(),
137
+ (0, class_validator_1.MinLength)(2),
138
+ (0, class_validator_1.MaxLength)(100),
139
+ (0, class_validator_1.Matches)(SINGLE_LINE),
140
+ (0, class_validator_1.IsOptional)(),
141
+ __metadata("design:type", String)
142
+ ], UpdateAlertIntakeConnectionDto.prototype, "name", void 0);
143
+ __decorate([
144
+ (0, swagger_1.ApiPropertyOptional)(),
145
+ (0, class_transformer_1.Transform)(trim),
146
+ (0, class_validator_1.IsString)(),
147
+ (0, class_validator_1.MinLength)(1),
148
+ (0, class_validator_1.MaxLength)(254),
149
+ (0, class_validator_1.Matches)(SINGLE_LINE),
150
+ (0, class_validator_1.IsOptional)(),
151
+ __metadata("design:type", String)
152
+ ], UpdateAlertIntakeConnectionDto.prototype, "address", void 0);
153
+ __decorate([
154
+ (0, swagger_1.ApiPropertyOptional)(),
155
+ (0, class_validator_1.IsBoolean)(),
156
+ (0, class_validator_1.IsOptional)(),
157
+ __metadata("design:type", Boolean)
158
+ ], UpdateAlertIntakeConnectionDto.prototype, "enabled", void 0);
159
+ __decorate([
160
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Merged over the stored settings. A key sent as "" is removed.' }),
161
+ IsFlatSettings(),
162
+ (0, class_validator_1.IsOptional)(),
163
+ __metadata("design:type", Object)
164
+ ], UpdateAlertIntakeConnectionDto.prototype, "config", void 0);
165
+ __decorate([
166
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Only the secrets sent are replaced; the rest are kept. A key sent as "" is removed.' }),
167
+ IsFlatSettings({ stringsOnly: true }),
168
+ (0, class_validator_1.IsOptional)(),
169
+ __metadata("design:type", Object)
170
+ ], UpdateAlertIntakeConnectionDto.prototype, "secrets", void 0);
171
+ __decorate([
172
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Platform operators only.' }),
173
+ IsFlatSettings({ stringsOnly: true }),
174
+ (0, class_validator_1.IsOptional)(),
175
+ __metadata("design:type", Object)
176
+ ], UpdateAlertIntakeConnectionDto.prototype, "secretReferences", void 0);
177
+ __decorate([
178
+ (0, swagger_1.ApiPropertyOptional)({ enum: alert_intake_enum_1.AlertIntakeEmergencyPolicy }),
179
+ (0, class_validator_1.IsEnum)(alert_intake_enum_1.AlertIntakeEmergencyPolicy),
180
+ (0, class_validator_1.IsOptional)(),
181
+ __metadata("design:type", String)
182
+ ], UpdateAlertIntakeConnectionDto.prototype, "emergencyPolicy", void 0);
183
+ /** Platform operators only: sends a PLATFORM connection's messages to an organization. */
184
+ class CreateAlertIntakeRouteDto {
185
+ }
186
+ exports.CreateAlertIntakeRouteDto = CreateAlertIntakeRouteDto;
187
+ __decorate([
188
+ (0, swagger_1.ApiProperty)({ enum: alert_intake_enum_1.AlertIntakeRouteMatch }),
189
+ (0, class_validator_1.IsEnum)(alert_intake_enum_1.AlertIntakeRouteMatch),
190
+ __metadata("design:type", String)
191
+ ], CreateAlertIntakeRouteDto.prototype, "match", void 0);
192
+ __decorate([
193
+ (0, swagger_1.ApiPropertyOptional)({ example: 'G4S', description: 'Required for KEYWORD; must be absent for DEFAULT.' }),
194
+ (0, class_transformer_1.Transform)(({ value }) => (typeof value === 'string' ? value.trim().toUpperCase() : value)),
195
+ (0, class_validator_1.ValidateIf)((dto) => dto.match === alert_intake_enum_1.AlertIntakeRouteMatch.KEYWORD || dto.keyword !== undefined),
196
+ (0, class_validator_1.Matches)(alert_intake_util_1.ALERT_INTAKE_KEYWORD_PATTERN, { message: 'keyword must be 2-20 letters or digits' }),
197
+ __metadata("design:type", String)
198
+ ], CreateAlertIntakeRouteDto.prototype, "keyword", void 0);
199
+ __decorate([
200
+ (0, swagger_1.ApiProperty)(),
201
+ (0, class_transformer_1.Type)(() => Number),
202
+ (0, class_validator_1.IsInt)(),
203
+ (0, class_validator_1.IsPositive)(),
204
+ __metadata("design:type", Number)
205
+ ], CreateAlertIntakeRouteDto.prototype, "organizationId", void 0);
206
+ __decorate([
207
+ (0, swagger_1.ApiPropertyOptional)({ default: true }),
208
+ (0, class_validator_1.IsBoolean)(),
209
+ (0, class_validator_1.IsOptional)(),
210
+ __metadata("design:type", Boolean)
211
+ ], CreateAlertIntakeRouteDto.prototype, "enabled", void 0);
212
+ class UpdateAlertIntakeRouteDto {
213
+ }
214
+ exports.UpdateAlertIntakeRouteDto = UpdateAlertIntakeRouteDto;
215
+ __decorate([
216
+ (0, swagger_1.ApiPropertyOptional)(),
217
+ (0, class_transformer_1.Type)(() => Number),
218
+ (0, class_validator_1.IsInt)(),
219
+ (0, class_validator_1.IsPositive)(),
220
+ (0, class_validator_1.IsOptional)(),
221
+ __metadata("design:type", Number)
222
+ ], UpdateAlertIntakeRouteDto.prototype, "organizationId", void 0);
223
+ __decorate([
224
+ (0, swagger_1.ApiPropertyOptional)(),
225
+ (0, class_validator_1.IsBoolean)(),
226
+ (0, class_validator_1.IsOptional)(),
227
+ __metadata("design:type", Boolean)
228
+ ], UpdateAlertIntakeRouteDto.prototype, "enabled", void 0);
229
+ const toBoolean = ({ value }) => (value === true || value === 'true' ? true : value === false || value === 'false' ? false : value);
230
+ /** Filters for an organization's stored messages. Query-string values, so numbers and booleans are coerced. */
231
+ class ListAlertIntakeMessagesQueryDto {
232
+ }
233
+ exports.ListAlertIntakeMessagesQueryDto = ListAlertIntakeMessagesQueryDto;
234
+ __decorate([
235
+ (0, swagger_1.ApiPropertyOptional)({ enum: alert_intake_enum_1.AlertIntakeMessageState }),
236
+ (0, class_validator_1.IsEnum)(alert_intake_enum_1.AlertIntakeMessageState),
237
+ (0, class_validator_1.IsOptional)(),
238
+ __metadata("design:type", String)
239
+ ], ListAlertIntakeMessagesQueryDto.prototype, "state", void 0);
240
+ __decorate([
241
+ (0, swagger_1.ApiPropertyOptional)({ enum: alert_intake_enum_1.AlertIntakeChannel }),
242
+ (0, class_validator_1.IsEnum)(alert_intake_enum_1.AlertIntakeChannel),
243
+ (0, class_validator_1.IsOptional)(),
244
+ __metadata("design:type", String)
245
+ ], ListAlertIntakeMessagesQueryDto.prototype, "channel", void 0);
246
+ __decorate([
247
+ (0, swagger_1.ApiPropertyOptional)(),
248
+ (0, class_validator_1.IsUUID)(),
249
+ (0, class_validator_1.IsOptional)(),
250
+ __metadata("design:type", String)
251
+ ], ListAlertIntakeMessagesQueryDto.prototype, "connectionId", void 0);
252
+ __decorate([
253
+ (0, swagger_1.ApiPropertyOptional)({ enum: alert_intake_enum_1.AlertIntakeRejectionReason }),
254
+ (0, class_validator_1.IsEnum)(alert_intake_enum_1.AlertIntakeRejectionReason),
255
+ (0, class_validator_1.IsOptional)(),
256
+ __metadata("design:type", String)
257
+ ], ListAlertIntakeMessagesQueryDto.prototype, "reason", void 0);
258
+ __decorate([
259
+ (0, swagger_1.ApiPropertyOptional)({ default: 1 }),
260
+ (0, class_transformer_1.Type)(() => Number),
261
+ (0, class_validator_1.IsInt)(),
262
+ (0, class_validator_1.Min)(1),
263
+ (0, class_validator_1.Max)(10000),
264
+ (0, class_validator_1.IsOptional)(),
265
+ __metadata("design:type", Number)
266
+ ], ListAlertIntakeMessagesQueryDto.prototype, "page", void 0);
267
+ __decorate([
268
+ (0, swagger_1.ApiPropertyOptional)({ default: 25, maximum: 100 }),
269
+ (0, class_transformer_1.Type)(() => Number),
270
+ (0, class_validator_1.IsInt)(),
271
+ (0, class_validator_1.Min)(1),
272
+ (0, class_validator_1.Max)(100),
273
+ (0, class_validator_1.IsOptional)(),
274
+ __metadata("design:type", Number)
275
+ ], ListAlertIntakeMessagesQueryDto.prototype, "limit", void 0);
276
+ /** Platform operators: every organization's messages, and those no organization has yet. */
277
+ class ListPlatformAlertIntakeMessagesQueryDto extends ListAlertIntakeMessagesQueryDto {
278
+ }
279
+ exports.ListPlatformAlertIntakeMessagesQueryDto = ListPlatformAlertIntakeMessagesQueryDto;
280
+ __decorate([
281
+ (0, swagger_1.ApiPropertyOptional)(),
282
+ (0, class_transformer_1.Type)(() => Number),
283
+ (0, class_validator_1.IsInt)(),
284
+ (0, class_validator_1.IsPositive)(),
285
+ (0, class_validator_1.IsOptional)(),
286
+ __metadata("design:type", Number)
287
+ ], ListPlatformAlertIntakeMessagesQueryDto.prototype, "organizationId", void 0);
288
+ __decorate([
289
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Only messages no organization has been found for.' }),
290
+ (0, class_transformer_1.Transform)(toBoolean),
291
+ (0, class_validator_1.IsBoolean)(),
292
+ (0, class_validator_1.IsOptional)(),
293
+ __metadata("design:type", Boolean)
294
+ ], ListPlatformAlertIntakeMessagesQueryDto.prototype, "unrouted", void 0);
295
+ /** Platform operators: give a message no route claimed to an organization, and raise it. */
296
+ class AssignAlertIntakeMessageDto {
297
+ }
298
+ exports.AssignAlertIntakeMessageDto = AssignAlertIntakeMessageDto;
299
+ __decorate([
300
+ (0, swagger_1.ApiProperty)(),
301
+ (0, class_transformer_1.Type)(() => Number),
302
+ (0, class_validator_1.IsInt)(),
303
+ (0, class_validator_1.IsPositive)(),
304
+ __metadata("design:type", Number)
305
+ ], AssignAlertIntakeMessageDto.prototype, "organizationId", void 0);
306
+ //# sourceMappingURL=alert-intake.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-intake.dto.js","sourceRoot":"","sources":["../../../../../src/modules/alert-intake/dtos/alert-intake.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAmE;AACnE,yDAAoD;AACpD,qDAkByB;AACzB,kEAOoC;AACpC,kEAA2G;AAE3G,MAAM,IAAI,GAAG,CAAC,EAAE,KAAK,EAAsB,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AACnG,MAAM,WAAW,GAAG,YAAY,CAAC;AACjC,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB;;;;;GAKG;AACH,SAAS,cAAc,CAAC,UAAqC,EAAE,EAAE,iBAAqC;IAClG,OAAO,CAAC,MAAc,EAAE,YAAoB,EAAE,EAAE,CAC5C,IAAA,mCAAiB,EAAC;QACd,IAAI,EAAE,gBAAgB;QACtB,MAAM,EAAE,MAAM,CAAC,WAAW;QAC1B,YAAY;QACZ,OAAO,EAAE,iBAAiB;QAC1B,SAAS,EAAE;YACP,QAAQ,CAAC,KAAc;gBACnB,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;oBAAE,OAAO,KAAK,CAAC;gBACtF,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,CAAC;gBACjE,IAAI,OAAO,CAAC,MAAM,GAAG,YAAY;oBAAE,OAAO,KAAK,CAAC;gBAChD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;oBACjC,IAAI,CAAC,8BAA8B,CAAC,IAAI,CAAC,GAAG,CAAC;wBAAE,OAAO,KAAK,CAAC;oBAC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,IAAA,uBAAK,GAAE;IAAE,IAAA,4BAAU,GAAE;IAAE,IAAA,4BAAU,GAAE;;+EAChC;AAIxB;IAFC,IAAA,6BAAmB,EAAC,EAAE,WAAW,EAAE,mDAAmD,EAAE,CAAC;IACzF,IAAA,6BAAS,EAAC,SAAS,CAAC;IAAE,IAAA,2BAAS,GAAE;IAAE,IAAA,4BAAU,GAAE;;yEAC7B;AAGvB,4FAA4F;AAC5F,MAAa,2BAA2B;CAIvC;AAJD,kEAIC;AADG;IAFC,IAAA,qBAAW,GAAE;IACb,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAAE,IAAA,uBAAK,GAAE;IAAE,IAAA,4BAAU,GAAE;;mEAClB"}
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ /**
3
+ * Alert intake: how a member of the public reaches an organization WITHOUT the app -
4
+ * an SMS, a WhatsApp message or an email that clarion-alerts turns into an incident.
5
+ *
6
+ * Not to be confused with `alert-dispatch`, which is about who an SOS raised IN the
7
+ * app is sent to.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.AlertIntakeMessageState = exports.AlertIntakeRejectionReason = exports.AlertIntakeWebhookVerification = exports.AlertIntakeRouteMatch = exports.AlertIntakeEmergencyPolicy = exports.AlertIntakeSecretSource = exports.AlertIntakeProvider = exports.AlertIntakeChannel = void 0;
11
+ /** The channel a message arrived on. */
12
+ var AlertIntakeChannel;
13
+ (function (AlertIntakeChannel) {
14
+ AlertIntakeChannel["SMS"] = "SMS";
15
+ AlertIntakeChannel["WHATSAPP"] = "WHATSAPP";
16
+ AlertIntakeChannel["EMAIL"] = "EMAIL";
17
+ })(AlertIntakeChannel || (exports.AlertIntakeChannel = AlertIntakeChannel = {}));
18
+ /**
19
+ * The provider a connection talks to.
20
+ *
21
+ * A code here only RESERVES the name. Whether a provider can be connected is
22
+ * answered by clarion-alerts' provider catalogue (`AlertIntakeProviderDescriptor`),
23
+ * which lists only providers with a registered adapter. UWAZII and CELCOM are
24
+ * reserved without an adapter on purpose: their inbound callback formats have not
25
+ * been confirmed, and until they are, GENERIC_SMS connects them by configuration.
26
+ */
27
+ var AlertIntakeProvider;
28
+ (function (AlertIntakeProvider) {
29
+ // SMS
30
+ AlertIntakeProvider["AFRICASTALKING"] = "africastalking";
31
+ AlertIntakeProvider["UWAZII"] = "uwazii";
32
+ AlertIntakeProvider["CELCOM"] = "celcom";
33
+ /** Any gateway that POSTs flat JSON or form fields; the field names are configured. */
34
+ AlertIntakeProvider["GENERIC_SMS"] = "generic_sms";
35
+ // WhatsApp
36
+ AlertIntakeProvider["WHATSAPP_CLOUD"] = "whatsapp_cloud";
37
+ // Email
38
+ AlertIntakeProvider["IMAP"] = "imap";
39
+ /** An inbound-parse webhook (Mailgun routes, SendGrid Inbound Parse, or a generic JSON post). */
40
+ AlertIntakeProvider["EMAIL_WEBHOOK"] = "email_webhook";
41
+ })(AlertIntakeProvider || (exports.AlertIntakeProvider = AlertIntakeProvider = {}));
42
+ /**
43
+ * Where a connection's credentials live. Never in a plaintext column.
44
+ *
45
+ * ENCRYPTED entered by the organization, encrypted at rest by clarion-alerts
46
+ * (AES-256-GCM, bound to the connection and the field). Write-only:
47
+ * the API never returns them.
48
+ * SECRET_REFERENCE the NAME of a secret the platform operator provisioned (Secret
49
+ * Manager / environment). How the legacy per-tenant credentials
50
+ * keep working, and the option for an operator who does not want
51
+ * a credential in the database at all.
52
+ */
53
+ var AlertIntakeSecretSource;
54
+ (function (AlertIntakeSecretSource) {
55
+ AlertIntakeSecretSource["ENCRYPTED"] = "ENCRYPTED";
56
+ AlertIntakeSecretSource["SECRET_REFERENCE"] = "SECRET_REFERENCE";
57
+ })(AlertIntakeSecretSource || (exports.AlertIntakeSecretSource = AlertIntakeSecretSource = {}));
58
+ /**
59
+ * How the emergency type of an incident raised from a message is decided.
60
+ * AUTO derives it from the organization: a grievance desk never raises an
61
+ * emergency; an incident desk decides from the message's category and priority.
62
+ */
63
+ var AlertIntakeEmergencyPolicy;
64
+ (function (AlertIntakeEmergencyPolicy) {
65
+ AlertIntakeEmergencyPolicy["AUTO"] = "AUTO";
66
+ AlertIntakeEmergencyPolicy["ALWAYS_EMERGENCY"] = "ALWAYS_EMERGENCY";
67
+ AlertIntakeEmergencyPolicy["ALWAYS_NON_EMERGENCY"] = "ALWAYS_NON_EMERGENCY";
68
+ })(AlertIntakeEmergencyPolicy || (exports.AlertIntakeEmergencyPolicy = AlertIntakeEmergencyPolicy = {}));
69
+ /** How a message on a PLATFORM connection finds its organization. */
70
+ var AlertIntakeRouteMatch;
71
+ (function (AlertIntakeRouteMatch) {
72
+ /** The first word of the message, e.g. `G4S fire at ...` on a shared short code. */
73
+ AlertIntakeRouteMatch["KEYWORD"] = "KEYWORD";
74
+ /** Everything no other route claimed. At most one per connection. */
75
+ AlertIntakeRouteMatch["DEFAULT"] = "DEFAULT";
76
+ })(AlertIntakeRouteMatch || (exports.AlertIntakeRouteMatch = AlertIntakeRouteMatch = {}));
77
+ /** How a provider proves a webhook call really came from it. */
78
+ var AlertIntakeWebhookVerification;
79
+ (function (AlertIntakeWebhookVerification) {
80
+ /** The unguessable URL is the only proof (Africa's Talking signs nothing). */
81
+ AlertIntakeWebhookVerification["SECRET_URL"] = "SECRET_URL";
82
+ /** A shared secret the gateway sends in a header, compared in constant time. */
83
+ AlertIntakeWebhookVerification["SHARED_SECRET_HEADER"] = "SHARED_SECRET_HEADER";
84
+ /** `X-Hub-Signature-256`: HMAC-SHA256 of the raw body with the Meta app secret. */
85
+ AlertIntakeWebhookVerification["META_SIGNATURE"] = "META_SIGNATURE";
86
+ })(AlertIntakeWebhookVerification || (exports.AlertIntakeWebhookVerification = AlertIntakeWebhookVerification = {}));
87
+ /** Why a message that arrived did not become an incident. Stored; shown to operators. */
88
+ var AlertIntakeRejectionReason;
89
+ (function (AlertIntakeRejectionReason) {
90
+ AlertIntakeRejectionReason["UNKNOWN_CONNECTION"] = "UNKNOWN_CONNECTION";
91
+ AlertIntakeRejectionReason["CONNECTION_DISABLED"] = "CONNECTION_DISABLED";
92
+ AlertIntakeRejectionReason["VERIFICATION_FAILED"] = "VERIFICATION_FAILED";
93
+ AlertIntakeRejectionReason["NO_ORGANIZATION"] = "NO_ORGANIZATION";
94
+ AlertIntakeRejectionReason["ORGANIZATION_INACTIVE"] = "ORGANIZATION_INACTIVE";
95
+ AlertIntakeRejectionReason["RATE_LIMITED"] = "RATE_LIMITED";
96
+ })(AlertIntakeRejectionReason || (exports.AlertIntakeRejectionReason = AlertIntakeRejectionReason = {}));
97
+ /**
98
+ * Where a stored message stands, as an operator reads it. Derived from the pipeline's
99
+ * processing status, retry schedule and rejection reason - not stored.
100
+ *
101
+ * QUEUED waiting for, or being worked on by, the pipeline
102
+ * RAISED became an incident
103
+ * RETRYING failed; another attempt is scheduled
104
+ * PARKED failed and will not be retried on its own: it ran out of attempts, or it
105
+ * has a `rejectionReason` (no organization, organization inactive)
106
+ * DUPLICATE the same sender repeating themselves; not raised
107
+ */
108
+ var AlertIntakeMessageState;
109
+ (function (AlertIntakeMessageState) {
110
+ AlertIntakeMessageState["QUEUED"] = "QUEUED";
111
+ AlertIntakeMessageState["RAISED"] = "RAISED";
112
+ AlertIntakeMessageState["RETRYING"] = "RETRYING";
113
+ AlertIntakeMessageState["PARKED"] = "PARKED";
114
+ AlertIntakeMessageState["DUPLICATE"] = "DUPLICATE";
115
+ })(AlertIntakeMessageState || (exports.AlertIntakeMessageState = AlertIntakeMessageState = {}));
116
+ //# sourceMappingURL=alert-intake.enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-intake.enum.js","sourceRoot":"","sources":["../../../../../src/modules/alert-intake/enums/alert-intake.enum.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,wCAAwC;AACxC,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC1B,iCAAW,CAAA;IACX,2CAAqB,CAAA;IACrB,qCAAe,CAAA;AACnB,CAAC,EAJW,kBAAkB,kCAAlB,kB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AA1B,0BAA0B,QAOrC;AAED;;;;;;;;;;GAUG;AACH,IAAY,uBAMX;AAND,WAAY,uBAAuB;IAC/B,4CAAiB,CAAA;IACjB,4CAAiB,CAAA;IACjB,gDAAqB,CAAA;IACrB,4CAAiB,CAAA;IACjB,kDAAuB,CAAA;AAC3B,CAAC,EANW,uBAAuB,uCAAvB,uBAAuB,QAMlC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ // Enums
18
+ __exportStar(require("./enums/alert-intake.enum"), exports);
19
+ // Interfaces
20
+ __exportStar(require("./interfaces/alert-intake"), exports);
21
+ // DTOs
22
+ __exportStar(require("./dtos/alert-intake.dto"), exports);
23
+ // Utilities
24
+ __exportStar(require("./utils/alert-intake.util"), exports);
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/alert-intake/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,QAAQ;AACR,4DAA0C;AAE1C,aAAa;AACb,4DAA0C;AAE1C,OAAO;AACP,0DAAwC;AAExC,YAAY;AACZ,4DAA0C"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=alert-intake.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-intake.js","sourceRoot":"","sources":["../../../../../src/modules/alert-intake/interfaces/alert-intake.ts"],"names":[],"mappings":""}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAX_ALERT_INTAKE_SETTING_LENGTH = exports.MAX_ALERT_INTAKE_ROUTES_PER_CONNECTION = exports.MAX_ALERT_INTAKE_CONNECTIONS_PER_ORGANIZATION = exports.ALERT_INTAKE_KEYWORD_PATTERN = void 0;
4
+ exports.normaliseAlertIntakeKeyword = normaliseAlertIntakeKeyword;
5
+ exports.extractAlertIntakeKeyword = extractAlertIntakeKeyword;
6
+ exports.stripAlertIntakeKeyword = stripAlertIntakeKeyword;
7
+ /** A routing keyword: 2-20 letters or digits, stored upper-cased. */
8
+ exports.ALERT_INTAKE_KEYWORD_PATTERN = /^[A-Z0-9]{2,20}$/;
9
+ /** Upper bounds that keep one organization's settings a form rather than a list to page through. */
10
+ exports.MAX_ALERT_INTAKE_CONNECTIONS_PER_ORGANIZATION = 20;
11
+ exports.MAX_ALERT_INTAKE_ROUTES_PER_CONNECTION = 200;
12
+ /** One settings value (config or secret). An access token is the longest thing that goes here. */
13
+ exports.MAX_ALERT_INTAKE_SETTING_LENGTH = 4096;
14
+ /** Normalises what an operator typed into the stored form. Null when it is not a valid keyword. */
15
+ function normaliseAlertIntakeKeyword(value) {
16
+ const keyword = (value !== null && value !== void 0 ? value : '').trim().toUpperCase();
17
+ return exports.ALERT_INTAKE_KEYWORD_PATTERN.test(keyword) ? keyword : null;
18
+ }
19
+ /**
20
+ * The routing keyword of a message: its first word, upper-cased, punctuation
21
+ * stripped - `g4s, fire at the gate` and `G4S: fire` both give `G4S`.
22
+ * Null when the first word could not be a keyword.
23
+ *
24
+ * Deliberately only the FIRST word. Matching a keyword anywhere in the text would
25
+ * route "I was robbed near the G4S office" to G4S.
26
+ */
27
+ function extractAlertIntakeKeyword(text) {
28
+ var _a;
29
+ const first = (_a = (text !== null && text !== void 0 ? text : '').trim().split(/\s+/)[0]) !== null && _a !== void 0 ? _a : '';
30
+ return normaliseAlertIntakeKeyword(first.replace(/^[^A-Za-z0-9]+|[^A-Za-z0-9]+$/g, ''));
31
+ }
32
+ /**
33
+ * The message with its routing keyword removed, so "G4S fire at the gate" is
34
+ * analysed as "fire at the gate". Returns the text unchanged when it does not start
35
+ * with that keyword.
36
+ */
37
+ function stripAlertIntakeKeyword(text, keyword) {
38
+ const trimmed = (text !== null && text !== void 0 ? text : '').trim();
39
+ // Keywords are [A-Z0-9] by construction; escaping keeps this safe for a caller that skipped normalising.
40
+ const literal = keyword.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
41
+ const match = new RegExp(`^[^A-Za-z0-9]*${literal}(?![A-Za-z0-9])[^A-Za-z0-9]*`, 'i').exec(trimmed);
42
+ if (!match)
43
+ return text;
44
+ const rest = trimmed.slice(match[0].length).trim();
45
+ // A message that was ONLY the keyword is still a message; do not turn it into nothing.
46
+ return rest.length > 0 ? rest : trimmed;
47
+ }
48
+ //# sourceMappingURL=alert-intake.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-intake.util.js","sourceRoot":"","sources":["../../../../../src/modules/alert-intake/utils/alert-intake.util.ts"],"names":[],"mappings":";;;AAUA,kEAGC;AAUD,8DAGC;AAOD,0DASC;AA1CD,qEAAqE;AACxD,QAAA,4BAA4B,GAAG,kBAAkB,CAAC;AAE/D,oGAAoG;AACvF,QAAA,6CAA6C,GAAG,EAAE,CAAC;AACnD,QAAA,sCAAsC,GAAG,GAAG,CAAC;AAC1D,kGAAkG;AACrF,QAAA,+BAA+B,GAAG,IAAI,CAAC;AAEpD,mGAAmG;AACnG,SAAgB,2BAA2B,CAAC,KAAgC;IACxE,MAAM,OAAO,GAAG,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CA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? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AlertAcknowledgementSmsDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const class_transformer_1 = require("class-transformer");
15
+ const class_validator_1 = require("class-validator");
16
+ /**
17
+ * clarion-alerts -> clarion-notification: tell the person who texted an alert that it
18
+ * was received (POST /alert-intake/notifications/sms). Sent under the ORGANIZATION's
19
+ * SMS sender ID, so the reply comes from the organization they reached.
20
+ *
21
+ * One recipient: an acknowledgement answers one message. The caller decides whether
22
+ * one is due (opt-in per connection, throttled per sender); this route only sends.
23
+ */
24
+ class AlertAcknowledgementSmsDto {
25
+ }
26
+ exports.AlertAcknowledgementSmsDto = AlertAcknowledgementSmsDto;
27
+ __decorate([
28
+ (0, swagger_1.ApiProperty)({ description: 'The sender of the alert: E.164, or a local number of a supported country.' }),
29
+ (0, class_validator_1.IsString)(),
30
+ (0, class_validator_1.MinLength)(3),
31
+ (0, class_validator_1.MaxLength)(20),
32
+ __metadata("design:type", String)
33
+ ], AlertAcknowledgementSmsDto.prototype, "phoneNumber", void 0);
34
+ __decorate([
35
+ (0, swagger_1.ApiProperty)({ description: 'At most 480 characters (three SMS segments).' }),
36
+ (0, class_validator_1.IsString)(),
37
+ (0, class_validator_1.MinLength)(1),
38
+ (0, class_validator_1.MaxLength)(480),
39
+ __metadata("design:type", String)
40
+ ], AlertAcknowledgementSmsDto.prototype, "message", void 0);
41
+ __decorate([
42
+ (0, swagger_1.ApiProperty)({ description: 'The organization the alert was raised for: decides the sender ID.' }),
43
+ (0, class_transformer_1.Type)(() => Number),
44
+ (0, class_validator_1.IsInt)(),
45
+ (0, class_validator_1.IsPositive)(),
46
+ __metadata("design:type", Number)
47
+ ], AlertAcknowledgementSmsDto.prototype, "organizationId", void 0);
48
+ __decorate([
49
+ (0, swagger_1.ApiPropertyOptional)({ description: 'The alerts message id, for tracing. Never shown to the recipient.' }),
50
+ (0, class_validator_1.IsString)(),
51
+ (0, class_validator_1.Matches)(/^[A-Za-z0-9-]{1,64}$/),
52
+ (0, class_validator_1.IsOptional)(),
53
+ __metadata("design:type", String)
54
+ ], AlertAcknowledgementSmsDto.prototype, "reference", void 0);
55
+ //# sourceMappingURL=alert-acknowledgement.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-acknowledgement.dto.js","sourceRoot":"","sources":["../../../../../src/modules/notification/dtos/alert-acknowledgement.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAmE;AACnE,yDAAyC;AACzC,qDAAyG;AAGzG;;;;;;;GAOG;AACH,MAAa,0BAA0B;CAgBtC;AAhBD,gEAgBC;AAbG;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,2EAA2E,EAAE,CAAC;IACzG,IAAA,0BAAQ,GAAE;IAAE,IAAA,2BAAS,EAAC,CAAC,CAAC;IAAE,IAAA,2BAAS,EAAC,EAAE,CAAC;;+DACnB;AAIrB;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,8CAA8C,EAAE,CAAC;IAC5E,IAAA,0BAAQ,GAAE;IAAE,IAAA,2BAAS,EAAC,CAAC,CAAC;IAAE,IAAA,2BAAS,EAAC,GAAG,CAAC;;2DACxB;AAIjB;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,mEAAmE,EAAE,CAAC;IACjG,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAAE,IAAA,uBAAK,GAAE;IAAE,IAAA,4BAAU,GAAE;;kEAClB;AAIxB;IAFC,IAAA,6BAAmB,EAAC,EAAE,WAAW,EAAE,mEAAmE,EAAE,CAAC;IACzG,IAAA,0BAAQ,GAAE;IAAE,IAAA,yBAAO,EAAC,sBAAsB,CAAC;IAAE,IAAA,4BAAU,GAAE;;6DACvC"}
@@ -43,4 +43,6 @@ __exportStar(require("./utils/notification-sender.util"), exports);
43
43
  __exportStar(require("./enums/billing-notification.enum"), exports);
44
44
  __exportStar(require("./dtos/billing-notification.dto"), exports);
45
45
  __exportStar(require("./interfaces/billing-notification-result"), exports);
46
+ // clarion-alerts -> clarion-notification: acknowledge an alert to its sender (POST /alert-intake/notifications/sms)
47
+ __exportStar(require("./dtos/alert-acknowledgement.dto"), exports);
46
48
  //# sourceMappingURL=index.js.map