@managemint-solutions/sdk 0.56.0 → 0.65.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.
Files changed (55) hide show
  1. package/README.md +209 -7
  2. package/dist/audit/document-changes.d.ts +39 -0
  3. package/dist/audit/document-changes.js +332 -0
  4. package/dist/audit/index.d.ts +50 -2
  5. package/dist/audit/index.js +87 -44
  6. package/dist/client.d.ts +6 -0
  7. package/dist/client.js +9 -0
  8. package/dist/clients/dto.d.ts +18 -3
  9. package/dist/clients/dto.js +72 -2
  10. package/dist/clients/index.js +16 -0
  11. package/dist/configs/dto.js +4 -12
  12. package/dist/documents/content.d.ts +39 -0
  13. package/dist/documents/content.js +443 -0
  14. package/dist/documents/document-templates.d.ts +37 -0
  15. package/dist/documents/document-templates.js +143 -0
  16. package/dist/documents/documents.d.ts +154 -0
  17. package/dist/documents/documents.js +330 -0
  18. package/dist/documents/dto.d.ts +138 -0
  19. package/dist/documents/dto.js +594 -0
  20. package/dist/documents/index.d.ts +4 -0
  21. package/dist/documents/index.js +24 -0
  22. package/dist/documents/render/html.d.ts +64 -0
  23. package/dist/documents/render/html.js +413 -0
  24. package/dist/documents/render/index.d.ts +2 -0
  25. package/dist/documents/render/index.js +23 -0
  26. package/dist/documents/render/values.d.ts +86 -0
  27. package/dist/documents/render/values.js +142 -0
  28. package/dist/feature-requests/dto.js +4 -13
  29. package/dist/index.d.ts +8 -1
  30. package/dist/index.js +31 -3
  31. package/dist/leads/index.js +1 -3
  32. package/dist/notifications/index.d.ts +6 -0
  33. package/dist/notifications/index.js +16 -0
  34. package/dist/organization-payment-methods/dto.d.ts +10 -0
  35. package/dist/organization-payment-methods/dto.js +56 -0
  36. package/dist/organization-payment-methods/index.d.ts +8 -1
  37. package/dist/organization-payment-methods/index.js +23 -0
  38. package/dist/payments/index.d.ts +67 -0
  39. package/dist/payments/index.js +137 -0
  40. package/dist/permissions/dto.d.ts +4 -0
  41. package/dist/permissions/dto.js +20 -8
  42. package/dist/service-client/index.d.ts +44 -0
  43. package/dist/service-client/index.js +77 -0
  44. package/dist/staff-client.d.ts +3 -0
  45. package/dist/staff-client.js +5 -0
  46. package/dist/supporting-files/index.js +4 -6
  47. package/dist/supporting-files/paths.d.ts +2 -0
  48. package/dist/supporting-files/paths.js +3 -1
  49. package/dist/validators.d.ts +12 -0
  50. package/dist/validators.js +23 -1
  51. package/dist/visibility/dto.d.ts +15 -0
  52. package/dist/visibility/dto.js +68 -0
  53. package/dist/visibility/index.d.ts +59 -0
  54. package/dist/visibility/index.js +165 -0
  55. package/package.json +6 -2
@@ -0,0 +1,594 @@
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.CopyCatalogueTemplateDto = exports.CatalogueTemplateSlugDto = exports.GetCatalogueTemplatesDto = exports.DocumentPaymentIdDto = exports.RecordDocumentPaymentDto = exports.PayDocumentDto = exports.DocumentPayQueryDto = exports.DocumentPayTokenDto = exports.SendDocumentDto = exports.ReassignPrivateDocumentsDto = exports.DocumentImageUrlsDto = exports.DocumentImageNameDto = exports.VoidDocumentDto = exports.UpdateDocumentDto = exports.CreateDocumentDto = exports.DocumentIdDto = exports.GetDocumentsDto = exports.CreateDocumentTemplateDto = exports.UpdateDocumentTemplateDto = exports.DocumentTemplateIdDto = exports.GetDocumentTemplatesDto = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ const class_transformer_1 = require("class-transformer");
15
+ const enum_1 = require("@managemint-solutions/entities/documents/enum");
16
+ const transforms_1 = require("../transforms");
17
+ const validators_1 = require("../validators");
18
+ const content_1 = require("./content");
19
+ const values_1 = require("./render/values");
20
+ // class-validator versions of the shared DTO types from @managemint-solutions/entities, so the
21
+ // wire contract cannot drift. The content rules (variables, blocks, values, currency) live in
22
+ // ./content.ts, once, and each decorator there answers with the specific problem it found.
23
+ //
24
+ // class-validator runs a property's decorators bottom-up, and the api answers with the first
25
+ // failure, so each property's type check sits last: a missing title says "Title must be text",
26
+ // not that it is too long.
27
+ // ------------------------------------------------------------
28
+ // Templates
29
+ // ------------------------------------------------------------
30
+ class GetDocumentTemplatesDto {
31
+ search;
32
+ category;
33
+ archive = false;
34
+ page = 1;
35
+ page_size = 10;
36
+ }
37
+ exports.GetDocumentTemplatesDto = GetDocumentTemplatesDto;
38
+ __decorate([
39
+ (0, class_validator_1.IsOptional)(),
40
+ (0, validators_1.IsNullable)(),
41
+ (0, class_validator_1.MaxLength)(255, { message: 'Search query cannot exceed 255 characters' }),
42
+ (0, class_validator_1.MinLength)(1, { message: 'Search query cannot be empty' }),
43
+ (0, class_validator_1.IsString)({ message: 'Search query must be a string' }),
44
+ __metadata("design:type", Object)
45
+ ], GetDocumentTemplatesDto.prototype, "search", void 0);
46
+ __decorate([
47
+ (0, class_validator_1.IsOptional)(),
48
+ (0, validators_1.IsNullable)(),
49
+ (0, content_1.IsDocumentCategory)(),
50
+ __metadata("design:type", Object)
51
+ ], GetDocumentTemplatesDto.prototype, "category", void 0);
52
+ __decorate([
53
+ (0, class_validator_1.IsOptional)(),
54
+ (0, validators_1.IsNullable)(),
55
+ (0, class_transformer_1.Transform)(({ value }) => value ? value === 'true' : false, { toClassOnly: true }),
56
+ (0, class_validator_1.IsBoolean)({ message: 'Include archived must be a boolean' }),
57
+ __metadata("design:type", Boolean)
58
+ ], GetDocumentTemplatesDto.prototype, "archive", void 0);
59
+ __decorate([
60
+ (0, class_validator_1.IsOptional)(),
61
+ (0, class_transformer_1.Transform)(({ value }) => value ? Number(value) : 1, { toClassOnly: true }),
62
+ (0, class_validator_1.Min)(1, { message: 'Page must be at least 1' }),
63
+ (0, class_validator_1.IsNumber)({}, { message: 'Page must be a number' }),
64
+ __metadata("design:type", Number)
65
+ ], GetDocumentTemplatesDto.prototype, "page", void 0);
66
+ __decorate([
67
+ (0, class_validator_1.IsOptional)(),
68
+ (0, class_transformer_1.Transform)(({ value }) => value ? Number(value) : 10, { toClassOnly: true }),
69
+ (0, class_validator_1.Max)(100, { message: 'Page size cannot exceed 100' }),
70
+ (0, class_validator_1.Min)(1, { message: 'Page size must be at least 1' }),
71
+ (0, class_validator_1.IsNumber)({}, { message: 'Page size must be a number' }),
72
+ __metadata("design:type", Number)
73
+ ], GetDocumentTemplatesDto.prototype, "page_size", void 0);
74
+ class DocumentTemplateIdDto {
75
+ templateId;
76
+ }
77
+ exports.DocumentTemplateIdDto = DocumentTemplateIdDto;
78
+ __decorate([
79
+ (0, class_validator_1.IsUUID)('7', { message: 'Invalid template ID format' }),
80
+ __metadata("design:type", String)
81
+ ], DocumentTemplateIdDto.prototype, "templateId", void 0);
82
+ /** Saving replaces the whole template. Its visibility changes only through the visibility route. */
83
+ class UpdateDocumentTemplateDto {
84
+ name;
85
+ category;
86
+ number_prefix;
87
+ variables;
88
+ blocks;
89
+ }
90
+ exports.UpdateDocumentTemplateDto = UpdateDocumentTemplateDto;
91
+ __decorate([
92
+ (0, validators_1.Trim)(),
93
+ (0, class_validator_1.MaxLength)(100, { message: 'Name cannot exceed 100 characters' }),
94
+ (0, class_validator_1.MinLength)(1, { message: 'Name cannot be empty' }),
95
+ (0, class_validator_1.IsString)({ message: 'Name must be text' }),
96
+ __metadata("design:type", String)
97
+ ], UpdateDocumentTemplateDto.prototype, "name", void 0);
98
+ __decorate([
99
+ (0, class_validator_1.IsOptional)(),
100
+ (0, content_1.IsDocumentCategory)(),
101
+ __metadata("design:type", String)
102
+ ], UpdateDocumentTemplateDto.prototype, "category", void 0);
103
+ __decorate([
104
+ (0, class_validator_1.IsOptional)(),
105
+ (0, validators_1.Trim)(),
106
+ (0, content_1.IsDocumentNumberPrefix)(),
107
+ __metadata("design:type", String)
108
+ ], UpdateDocumentTemplateDto.prototype, "number_prefix", void 0);
109
+ __decorate([
110
+ (0, content_1.IsDocumentVariables)(),
111
+ __metadata("design:type", Array)
112
+ ], UpdateDocumentTemplateDto.prototype, "variables", void 0);
113
+ __decorate([
114
+ (0, content_1.IsDocumentBlocks)(),
115
+ __metadata("design:type", Array)
116
+ ], UpdateDocumentTemplateDto.prototype, "blocks", void 0);
117
+ /** A new template: what a save holds, plus who sees it (omitted: the organization). */
118
+ class CreateDocumentTemplateDto extends UpdateDocumentTemplateDto {
119
+ visibility;
120
+ }
121
+ exports.CreateDocumentTemplateDto = CreateDocumentTemplateDto;
122
+ __decorate([
123
+ (0, class_validator_1.IsOptional)(),
124
+ (0, class_validator_1.IsEnum)(enum_1.DocumentVisibility, { message: `Visibility must be one of: ${Object.values(enum_1.DocumentVisibility).join(', ')}` }),
125
+ __metadata("design:type", String)
126
+ ], CreateDocumentTemplateDto.prototype, "visibility", void 0);
127
+ // ------------------------------------------------------------
128
+ // Documents
129
+ // ------------------------------------------------------------
130
+ class GetDocumentsDto {
131
+ search;
132
+ category;
133
+ status;
134
+ // A UUID, or the base64-JSON option value the portal's client select sends.
135
+ client_id;
136
+ template_id;
137
+ // Parents only when true; otherwise parents are left out of the list.
138
+ recurring;
139
+ repeat_from;
140
+ payment;
141
+ page = 1;
142
+ page_size = 10;
143
+ }
144
+ exports.GetDocumentsDto = GetDocumentsDto;
145
+ __decorate([
146
+ (0, class_validator_1.IsOptional)(),
147
+ (0, validators_1.IsNullable)(),
148
+ (0, class_validator_1.MaxLength)(255, { message: 'Search query cannot exceed 255 characters' }),
149
+ (0, class_validator_1.MinLength)(1, { message: 'Search query cannot be empty' }),
150
+ (0, class_validator_1.IsString)({ message: 'Search query must be a string' }),
151
+ __metadata("design:type", Object)
152
+ ], GetDocumentsDto.prototype, "search", void 0);
153
+ __decorate([
154
+ (0, class_validator_1.IsOptional)(),
155
+ (0, validators_1.IsNullable)(),
156
+ (0, content_1.IsDocumentCategory)(),
157
+ __metadata("design:type", Object)
158
+ ], GetDocumentsDto.prototype, "category", void 0);
159
+ __decorate([
160
+ (0, class_validator_1.IsOptional)(),
161
+ (0, validators_1.IsNullable)(),
162
+ (0, class_validator_1.IsEnum)(enum_1.DocumentStatus, { message: `Status must be one of: ${Object.values(enum_1.DocumentStatus).join(', ')}` }),
163
+ __metadata("design:type", Object)
164
+ ], GetDocumentsDto.prototype, "status", void 0);
165
+ __decorate([
166
+ (0, class_validator_1.IsOptional)(),
167
+ (0, validators_1.IsNullable)(),
168
+ (0, class_transformer_1.Transform)(({ value }) => (0, transforms_1.parseEntityIdFilter)(value), { toClassOnly: true }),
169
+ (0, class_validator_1.IsUUID)('7', { message: 'Invalid client ID format' }),
170
+ __metadata("design:type", Object)
171
+ ], GetDocumentsDto.prototype, "client_id", void 0);
172
+ __decorate([
173
+ (0, class_validator_1.IsOptional)(),
174
+ (0, validators_1.IsNullable)(),
175
+ (0, class_validator_1.IsUUID)('7', { message: 'Invalid template ID format' }),
176
+ __metadata("design:type", Object)
177
+ ], GetDocumentsDto.prototype, "template_id", void 0);
178
+ __decorate([
179
+ (0, class_validator_1.IsOptional)(),
180
+ (0, class_transformer_1.Transform)(({ value }) => value === true || value === 'true', { toClassOnly: true }),
181
+ (0, class_validator_1.IsBoolean)({ message: 'Recurring must be a boolean' }),
182
+ __metadata("design:type", Boolean)
183
+ ], GetDocumentsDto.prototype, "recurring", void 0);
184
+ __decorate([
185
+ (0, class_validator_1.IsOptional)(),
186
+ (0, validators_1.IsNullable)(),
187
+ (0, class_validator_1.IsUUID)('7', { message: 'Invalid recurring document ID format' }),
188
+ __metadata("design:type", Object)
189
+ ], GetDocumentsDto.prototype, "repeat_from", void 0);
190
+ __decorate([
191
+ (0, class_validator_1.IsOptional)(),
192
+ (0, validators_1.IsNullable)(),
193
+ (0, class_validator_1.IsEnum)(enum_1.DocumentPaymentFilter, { message: `Payment must be one of: ${Object.values(enum_1.DocumentPaymentFilter).join(', ')}` }),
194
+ __metadata("design:type", Object)
195
+ ], GetDocumentsDto.prototype, "payment", void 0);
196
+ __decorate([
197
+ (0, class_validator_1.IsOptional)(),
198
+ (0, class_transformer_1.Transform)(({ value }) => value ? Number(value) : 1, { toClassOnly: true }),
199
+ (0, class_validator_1.Min)(1, { message: 'Page must be at least 1' }),
200
+ (0, class_validator_1.IsNumber)({}, { message: 'Page must be a number' }),
201
+ __metadata("design:type", Number)
202
+ ], GetDocumentsDto.prototype, "page", void 0);
203
+ __decorate([
204
+ (0, class_validator_1.IsOptional)(),
205
+ (0, class_transformer_1.Transform)(({ value }) => value ? Number(value) : 10, { toClassOnly: true }),
206
+ (0, class_validator_1.Max)(100, { message: 'Page size cannot exceed 100' }),
207
+ (0, class_validator_1.Min)(1, { message: 'Page size must be at least 1' }),
208
+ (0, class_validator_1.IsNumber)({}, { message: 'Page size must be a number' }),
209
+ __metadata("design:type", Number)
210
+ ], GetDocumentsDto.prototype, "page_size", void 0);
211
+ class DocumentIdDto {
212
+ documentId;
213
+ }
214
+ exports.DocumentIdDto = DocumentIdDto;
215
+ __decorate([
216
+ (0, class_validator_1.IsUUID)('7', { message: 'Invalid document ID format' }),
217
+ __metadata("design:type", String)
218
+ ], DocumentIdDto.prototype, "documentId", void 0);
219
+ /** How many addresses one send may go to, and copy in, and how long its subject and message may be. */
220
+ const MAX_SEND_ADDRESSES = 5;
221
+ const MAX_SUBJECT_LENGTH = 200;
222
+ const MAX_MESSAGE_LENGTH = 5000;
223
+ /**
224
+ * A stored email (a recurring parent's, a scheduled draft's): exactly what `SendDocumentDto`
225
+ * takes, checked by the same rules, so what the cron sends later is what a send would accept now.
226
+ */
227
+ const IsDocumentEmail = (0, validators_1.fromProblem)('isDocumentEmail', (value) => {
228
+ if (!(0, values_1.isObject)(value))
229
+ return 'Email must be an object';
230
+ const errors = (0, class_validator_1.validateSync)((0, class_transformer_1.plainToInstance)(SendDocumentDto, value), { whitelist: true, forbidNonWhitelisted: true });
231
+ return errors.length === 0 ? null : `Email: ${Object.values(errors[0].constraints ?? {})[0] ?? 'is not valid'}`;
232
+ });
233
+ /**
234
+ * A recurring parent's schedule and a draft's issue date, on create and on a draft save. Each is
235
+ * checked alone here; how they go together (a parent needs its first date, never an issue date)
236
+ * is the api's.
237
+ */
238
+ class DocumentScheduleDto {
239
+ repeat;
240
+ repeat_next_at;
241
+ repeat_until;
242
+ repeat_paused;
243
+ issue_at;
244
+ email;
245
+ }
246
+ __decorate([
247
+ (0, class_validator_1.IsOptional)(),
248
+ (0, validators_1.IsNullable)(),
249
+ (0, class_validator_1.IsEnum)(enum_1.DocumentRepeat, { message: `Repeat must be one of: ${Object.values(enum_1.DocumentRepeat).join(', ')}` }),
250
+ __metadata("design:type", Object)
251
+ ], DocumentScheduleDto.prototype, "repeat", void 0);
252
+ __decorate([
253
+ (0, class_validator_1.IsOptional)(),
254
+ (0, validators_1.IsNullable)(),
255
+ (0, validators_1.IsCalendarDate)({ message: 'First issue date must be a calendar date (YYYY-MM-DD)' }),
256
+ __metadata("design:type", Object)
257
+ ], DocumentScheduleDto.prototype, "repeat_next_at", void 0);
258
+ __decorate([
259
+ (0, class_validator_1.IsOptional)(),
260
+ (0, validators_1.IsNullable)(),
261
+ (0, validators_1.IsCalendarDate)({ message: 'Repeat until must be a calendar date (YYYY-MM-DD)' }),
262
+ __metadata("design:type", Object)
263
+ ], DocumentScheduleDto.prototype, "repeat_until", void 0);
264
+ __decorate([
265
+ (0, class_validator_1.IsOptional)(),
266
+ (0, class_validator_1.IsBoolean)({ message: 'Paused must be true or false' }),
267
+ __metadata("design:type", Boolean)
268
+ ], DocumentScheduleDto.prototype, "repeat_paused", void 0);
269
+ __decorate([
270
+ (0, class_validator_1.IsOptional)(),
271
+ (0, validators_1.IsNullable)(),
272
+ (0, validators_1.IsCalendarDate)({ message: 'Issue date must be a calendar date (YYYY-MM-DD)' }),
273
+ __metadata("design:type", Object)
274
+ ], DocumentScheduleDto.prototype, "issue_at", void 0);
275
+ __decorate([
276
+ (0, class_validator_1.IsOptional)(),
277
+ (0, validators_1.IsNullable)(),
278
+ IsDocumentEmail(),
279
+ __metadata("design:type", Object)
280
+ ], DocumentScheduleDto.prototype, "email", void 0);
281
+ /**
282
+ * A new draft. Its values cannot be checked here - with a template, the variables they fill are
283
+ * the template's - so the api checks the draft it composes with `documentProblem`.
284
+ */
285
+ class CreateDocumentDto extends DocumentScheduleDto {
286
+ template_id;
287
+ client_id;
288
+ title;
289
+ currency;
290
+ variable_values;
291
+ // A blank draft's; one made from a template takes the template's, and its shares.
292
+ visibility;
293
+ }
294
+ exports.CreateDocumentDto = CreateDocumentDto;
295
+ __decorate([
296
+ (0, class_validator_1.IsOptional)(),
297
+ (0, validators_1.IsNullable)(),
298
+ (0, class_validator_1.IsUUID)('7', { message: 'Invalid template ID format' }),
299
+ __metadata("design:type", Object)
300
+ ], CreateDocumentDto.prototype, "template_id", void 0);
301
+ __decorate([
302
+ (0, class_validator_1.IsOptional)(),
303
+ (0, validators_1.IsNullable)(),
304
+ (0, class_validator_1.IsUUID)('7', { message: 'Invalid client ID format' }),
305
+ __metadata("design:type", Object)
306
+ ], CreateDocumentDto.prototype, "client_id", void 0);
307
+ __decorate([
308
+ (0, class_validator_1.IsOptional)(),
309
+ (0, class_validator_1.MaxLength)(200, { message: 'Title cannot exceed 200 characters' }),
310
+ (0, class_validator_1.IsString)({ message: 'Title must be text' }),
311
+ __metadata("design:type", String)
312
+ ], CreateDocumentDto.prototype, "title", void 0);
313
+ __decorate([
314
+ (0, class_validator_1.IsOptional)(),
315
+ (0, content_1.IsDocumentCurrency)(),
316
+ __metadata("design:type", Object)
317
+ ], CreateDocumentDto.prototype, "currency", void 0);
318
+ __decorate([
319
+ (0, class_validator_1.IsOptional)(),
320
+ (0, class_validator_1.IsObject)({ message: 'Variable values must be an object' }),
321
+ __metadata("design:type", Object)
322
+ ], CreateDocumentDto.prototype, "variable_values", void 0);
323
+ __decorate([
324
+ (0, class_validator_1.IsOptional)(),
325
+ (0, class_validator_1.IsEnum)(enum_1.DocumentVisibility, { message: `Visibility must be one of: ${Object.values(enum_1.DocumentVisibility).join(', ')}` }),
326
+ __metadata("design:type", String)
327
+ ], CreateDocumentDto.prototype, "visibility", void 0);
328
+ /** A whole draft, under the same content rules as a template, plus its values and currency. */
329
+ class UpdateDocumentDto extends DocumentScheduleDto {
330
+ client_id;
331
+ title;
332
+ category;
333
+ number_prefix;
334
+ currency;
335
+ variables;
336
+ variable_values;
337
+ blocks;
338
+ }
339
+ exports.UpdateDocumentDto = UpdateDocumentDto;
340
+ __decorate([
341
+ (0, validators_1.IsNullable)(),
342
+ (0, class_validator_1.IsUUID)('7', { message: 'Invalid client ID format' }),
343
+ __metadata("design:type", Object)
344
+ ], UpdateDocumentDto.prototype, "client_id", void 0);
345
+ __decorate([
346
+ (0, class_validator_1.MaxLength)(200, { message: 'Title cannot exceed 200 characters' }),
347
+ (0, class_validator_1.IsString)({ message: 'Title must be text' }),
348
+ __metadata("design:type", String)
349
+ ], UpdateDocumentDto.prototype, "title", void 0);
350
+ __decorate([
351
+ (0, content_1.IsDocumentCategory)(),
352
+ __metadata("design:type", String)
353
+ ], UpdateDocumentDto.prototype, "category", void 0);
354
+ __decorate([
355
+ (0, validators_1.Trim)(),
356
+ (0, content_1.IsDocumentNumberPrefix)(),
357
+ __metadata("design:type", String)
358
+ ], UpdateDocumentDto.prototype, "number_prefix", void 0);
359
+ __decorate([
360
+ (0, content_1.IsDocumentCurrency)(),
361
+ __metadata("design:type", Object)
362
+ ], UpdateDocumentDto.prototype, "currency", void 0);
363
+ __decorate([
364
+ (0, content_1.IsDocumentVariables)(),
365
+ __metadata("design:type", Array)
366
+ ], UpdateDocumentDto.prototype, "variables", void 0);
367
+ __decorate([
368
+ (0, content_1.IsDocumentVariableValues)(),
369
+ __metadata("design:type", Object)
370
+ ], UpdateDocumentDto.prototype, "variable_values", void 0);
371
+ __decorate([
372
+ (0, content_1.IsDocumentBlocks)(),
373
+ __metadata("design:type", Array)
374
+ ], UpdateDocumentDto.prototype, "blocks", void 0);
375
+ class VoidDocumentDto {
376
+ reason;
377
+ }
378
+ exports.VoidDocumentDto = VoidDocumentDto;
379
+ __decorate([
380
+ (0, class_validator_1.MaxLength)(500, { message: 'Reason cannot exceed 500 characters' }),
381
+ (0, class_validator_1.Matches)(/\S/, { message: 'Give a reason for voiding the document' }),
382
+ (0, class_validator_1.IsString)({ message: 'Give a reason for voiding the document' }),
383
+ __metadata("design:type", String)
384
+ ], VoidDocumentDto.prototype, "reason", void 0);
385
+ class DocumentImageNameDto {
386
+ // The resource checks the name itself (characters, length, an image extension) before it
387
+ // keeps the extension, which a decorator cannot.
388
+ name;
389
+ }
390
+ exports.DocumentImageNameDto = DocumentImageNameDto;
391
+ __decorate([
392
+ (0, class_validator_1.MinLength)(1, { message: 'Image name cannot be empty' }),
393
+ (0, class_validator_1.IsString)({ message: 'Image name must be text' }),
394
+ __metadata("design:type", String)
395
+ ], DocumentImageNameDto.prototype, "name", void 0);
396
+ /** How many image paths one call may sign - more than any document holds. */
397
+ const MAX_IMAGE_PATHS = 50;
398
+ /**
399
+ * Image paths to sign for reading, as a query (`?paths=a&paths=b`; one `paths` arrives as a plain
400
+ * string and is taken as a list of one). Each must be one `createImageUploadUrl` handed out
401
+ * (`documents/images/<uuid>.<ext>`); `imageUrls` then signs it under the caller's own
402
+ * organization, so nothing outside that folder can be named.
403
+ */
404
+ class DocumentImageUrlsDto {
405
+ paths;
406
+ }
407
+ exports.DocumentImageUrlsDto = DocumentImageUrlsDto;
408
+ __decorate([
409
+ (0, class_validator_1.Matches)(content_1.IMAGE_PATH, { each: true, message: 'Each path must be an image uploaded for documents' }),
410
+ (0, class_validator_1.IsString)({ each: true, message: 'Each path must be an image uploaded for documents' }),
411
+ (0, class_validator_1.ArrayMaxSize)(MAX_IMAGE_PATHS, { message: `Cannot sign more than ${MAX_IMAGE_PATHS} images at once` }),
412
+ (0, class_validator_1.ArrayMinSize)(1, { message: 'Give at least one image path' }),
413
+ (0, class_validator_1.IsArray)({ message: 'Paths must be a list' }),
414
+ (0, class_transformer_1.Transform)(({ value }) => (typeof value === 'string' ? [value] : value), { toClassOnly: true }),
415
+ __metadata("design:type", Array)
416
+ ], DocumentImageUrlsDto.prototype, "paths", void 0);
417
+ /** The owner's move of one person's private templates and documents to another; v4 user ids. */
418
+ class ReassignPrivateDocumentsDto {
419
+ from_user_id;
420
+ to_user_id;
421
+ }
422
+ exports.ReassignPrivateDocumentsDto = ReassignPrivateDocumentsDto;
423
+ __decorate([
424
+ (0, class_validator_1.IsUUID)('4', { message: 'Invalid from user ID format' }),
425
+ __metadata("design:type", String)
426
+ ], ReassignPrivateDocumentsDto.prototype, "from_user_id", void 0);
427
+ __decorate([
428
+ (0, class_validator_1.IsUUID)('4', { message: 'Invalid to user ID format' }),
429
+ __metadata("design:type", String)
430
+ ], ReassignPrivateDocumentsDto.prototype, "to_user_id", void 0);
431
+ // ------------------------------------------------------------
432
+ // Sending and paying
433
+ // ------------------------------------------------------------
434
+ /** A pay link's token: the document's mms_id, a dot, and the api's base64url HMAC-SHA256 of it. */
435
+ const PAY_TOKEN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.[A-Za-z0-9_-]{43}$/;
436
+ /** An issued document's email. Who may send it, and whether Pay now may go on it, is the api's. */
437
+ class SendDocumentDto {
438
+ to;
439
+ cc;
440
+ subject;
441
+ message;
442
+ pay_now;
443
+ }
444
+ exports.SendDocumentDto = SendDocumentDto;
445
+ __decorate([
446
+ (0, class_validator_1.IsEmail)({}, { each: true, message: 'Each recipient must be an email address' }),
447
+ (0, class_validator_1.ArrayMaxSize)(MAX_SEND_ADDRESSES, { message: `Send to ${MAX_SEND_ADDRESSES} addresses at most` }),
448
+ (0, class_validator_1.ArrayMinSize)(1, { message: 'Give at least one recipient' }),
449
+ (0, class_validator_1.IsArray)({ message: 'Recipients must be a list' }),
450
+ __metadata("design:type", Array)
451
+ ], SendDocumentDto.prototype, "to", void 0);
452
+ __decorate([
453
+ (0, class_validator_1.IsOptional)(),
454
+ (0, class_validator_1.IsEmail)({}, { each: true, message: 'Each copy address must be an email address' }),
455
+ (0, class_validator_1.ArrayMaxSize)(MAX_SEND_ADDRESSES, { message: `Copy ${MAX_SEND_ADDRESSES} addresses at most` }),
456
+ (0, class_validator_1.IsArray)({ message: 'Copy addresses must be a list' }),
457
+ __metadata("design:type", Array)
458
+ ], SendDocumentDto.prototype, "cc", void 0);
459
+ __decorate([
460
+ (0, class_validator_1.MaxLength)(MAX_SUBJECT_LENGTH, { message: `Subject cannot exceed ${MAX_SUBJECT_LENGTH} characters` }),
461
+ (0, class_validator_1.Matches)(/\S/, { message: 'Give the email a subject' }),
462
+ (0, class_validator_1.IsString)({ message: 'Give the email a subject' }),
463
+ __metadata("design:type", String)
464
+ ], SendDocumentDto.prototype, "subject", void 0);
465
+ __decorate([
466
+ (0, class_validator_1.MaxLength)(MAX_MESSAGE_LENGTH, { message: `Message cannot exceed ${MAX_MESSAGE_LENGTH} characters` }),
467
+ (0, class_validator_1.IsString)({ message: 'Message must be text' }),
468
+ __metadata("design:type", String)
469
+ ], SendDocumentDto.prototype, "message", void 0);
470
+ __decorate([
471
+ (0, class_validator_1.IsBoolean)({ message: 'Pay now must be true or false' }),
472
+ __metadata("design:type", Boolean)
473
+ ], SendDocumentDto.prototype, "pay_now", void 0);
474
+ /** A public pay link's token. Only its shape is checked here; the api checks the signature. */
475
+ class DocumentPayTokenDto {
476
+ token;
477
+ }
478
+ exports.DocumentPayTokenDto = DocumentPayTokenDto;
479
+ __decorate([
480
+ (0, class_validator_1.Matches)(PAY_TOKEN, { message: 'This payment link is not valid' }),
481
+ (0, class_validator_1.IsString)({ message: 'This payment link is not valid' }),
482
+ __metadata("design:type", String)
483
+ ], DocumentPayTokenDto.prototype, "token", void 0);
484
+ /** Paystack's return to the pay page: its reference - letters, digits and - . = only, as Paystack allows. */
485
+ class DocumentPayQueryDto {
486
+ reference;
487
+ }
488
+ exports.DocumentPayQueryDto = DocumentPayQueryDto;
489
+ __decorate([
490
+ (0, class_validator_1.IsOptional)(),
491
+ (0, class_validator_1.Matches)(/^[A-Za-z0-9.=-]{1,100}$/, { message: 'Invalid payment reference' }),
492
+ (0, class_validator_1.IsString)({ message: 'Invalid payment reference' }),
493
+ __metadata("design:type", String)
494
+ ], DocumentPayQueryDto.prototype, "reference", void 0);
495
+ class PayDocumentDto {
496
+ email;
497
+ }
498
+ exports.PayDocumentDto = PayDocumentDto;
499
+ __decorate([
500
+ (0, class_validator_1.MaxLength)(254, { message: 'Email cannot exceed 254 characters' }),
501
+ (0, class_validator_1.IsEmail)({}, { message: 'Give a valid email address for your receipt' }),
502
+ __metadata("design:type", String)
503
+ ], PayDocumentDto.prototype, "email", void 0);
504
+ /** A document marked paid by hand: the date the money arrived, and the bank reference if any. */
505
+ class RecordDocumentPaymentDto {
506
+ paid_at;
507
+ reference;
508
+ }
509
+ exports.RecordDocumentPaymentDto = RecordDocumentPaymentDto;
510
+ __decorate([
511
+ (0, validators_1.IsCalendarDate)({ message: 'Paid on must be a calendar date (YYYY-MM-DD)' }),
512
+ __metadata("design:type", String)
513
+ ], RecordDocumentPaymentDto.prototype, "paid_at", void 0);
514
+ __decorate([
515
+ (0, class_validator_1.IsOptional)(),
516
+ (0, validators_1.IsNullable)(),
517
+ (0, class_validator_1.MaxLength)(100, { message: 'Reference cannot exceed 100 characters' }),
518
+ (0, class_validator_1.IsString)({ message: 'Reference must be text' }),
519
+ __metadata("design:type", Object)
520
+ ], RecordDocumentPaymentDto.prototype, "reference", void 0);
521
+ class DocumentPaymentIdDto {
522
+ documentId;
523
+ paymentId;
524
+ }
525
+ exports.DocumentPaymentIdDto = DocumentPaymentIdDto;
526
+ __decorate([
527
+ (0, class_validator_1.IsUUID)('7', { message: 'Invalid document ID format' }),
528
+ __metadata("design:type", String)
529
+ ], DocumentPaymentIdDto.prototype, "documentId", void 0);
530
+ __decorate([
531
+ (0, class_validator_1.IsUUID)('7', { message: 'Invalid payment ID format' }),
532
+ __metadata("design:type", String)
533
+ ], DocumentPaymentIdDto.prototype, "paymentId", void 0);
534
+ // ------------------------------------------------------------
535
+ // Template catalogue
536
+ // ------------------------------------------------------------
537
+ /** A catalogue slug: lower-case letters and digits in hyphen-joined words, e.g. `residential-lease-za`. */
538
+ const CATALOGUE_SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
539
+ class GetCatalogueTemplatesDto {
540
+ search;
541
+ category;
542
+ }
543
+ exports.GetCatalogueTemplatesDto = GetCatalogueTemplatesDto;
544
+ __decorate([
545
+ (0, class_validator_1.IsOptional)(),
546
+ (0, validators_1.IsNullable)(),
547
+ (0, class_validator_1.MaxLength)(100, { message: 'Search query cannot exceed 100 characters' }),
548
+ (0, class_validator_1.MinLength)(1, { message: 'Search query cannot be empty' }),
549
+ (0, class_validator_1.IsString)({ message: 'Search query must be a string' }),
550
+ __metadata("design:type", Object)
551
+ ], GetCatalogueTemplatesDto.prototype, "search", void 0);
552
+ __decorate([
553
+ (0, class_validator_1.IsOptional)(),
554
+ (0, validators_1.IsNullable)(),
555
+ (0, content_1.IsDocumentCategory)(),
556
+ __metadata("design:type", Object)
557
+ ], GetCatalogueTemplatesDto.prototype, "category", void 0);
558
+ class CatalogueTemplateSlugDto {
559
+ slug;
560
+ }
561
+ exports.CatalogueTemplateSlugDto = CatalogueTemplateSlugDto;
562
+ __decorate([
563
+ (0, class_validator_1.MaxLength)(80, { message: 'Unknown template' }),
564
+ (0, class_validator_1.Matches)(CATALOGUE_SLUG, { message: 'Unknown template' }),
565
+ (0, class_validator_1.IsString)({ message: 'Unknown template' }),
566
+ __metadata("design:type", String)
567
+ ], CatalogueTemplateSlugDto.prototype, "slug", void 0);
568
+ /** The copy's own name and prefix are optional and held to a template save's rules when given. */
569
+ class CopyCatalogueTemplateDto {
570
+ slug;
571
+ name;
572
+ number_prefix;
573
+ }
574
+ exports.CopyCatalogueTemplateDto = CopyCatalogueTemplateDto;
575
+ __decorate([
576
+ (0, class_validator_1.MaxLength)(80, { message: 'Unknown template' }),
577
+ (0, class_validator_1.Matches)(CATALOGUE_SLUG, { message: 'Unknown template' }),
578
+ (0, class_validator_1.IsString)({ message: 'Give the template to copy' }),
579
+ __metadata("design:type", String)
580
+ ], CopyCatalogueTemplateDto.prototype, "slug", void 0);
581
+ __decorate([
582
+ (0, class_validator_1.IsOptional)(),
583
+ (0, validators_1.Trim)(),
584
+ (0, class_validator_1.MaxLength)(100, { message: 'Name cannot exceed 100 characters' }),
585
+ (0, class_validator_1.MinLength)(1, { message: 'Name cannot be empty' }),
586
+ (0, class_validator_1.IsString)({ message: 'Name must be text' }),
587
+ __metadata("design:type", String)
588
+ ], CopyCatalogueTemplateDto.prototype, "name", void 0);
589
+ __decorate([
590
+ (0, class_validator_1.IsOptional)(),
591
+ (0, validators_1.Trim)(),
592
+ (0, content_1.IsDocumentNumberPrefix)(),
593
+ __metadata("design:type", String)
594
+ ], CopyCatalogueTemplateDto.prototype, "number_prefix", void 0);
@@ -0,0 +1,4 @@
1
+ export * from './dto';
2
+ export { documentProblem } from './content';
3
+ export { DocumentTemplatesResource, type DocumentTemplateRecord } from './document-templates';
4
+ export { DocumentsResource, type CreateDocumentRow, type DocumentListRecord, type DocumentRecord, type DocumentSendEvent, type UpdateDocumentRow, } from './documents';
@@ -0,0 +1,24 @@
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
+ exports.DocumentsResource = exports.DocumentTemplatesResource = exports.documentProblem = void 0;
18
+ __exportStar(require("./dto"), exports);
19
+ var content_1 = require("./content");
20
+ Object.defineProperty(exports, "documentProblem", { enumerable: true, get: function () { return content_1.documentProblem; } });
21
+ var document_templates_1 = require("./document-templates");
22
+ Object.defineProperty(exports, "DocumentTemplatesResource", { enumerable: true, get: function () { return document_templates_1.DocumentTemplatesResource; } });
23
+ var documents_1 = require("./documents");
24
+ Object.defineProperty(exports, "DocumentsResource", { enumerable: true, get: function () { return documents_1.DocumentsResource; } });