@managemint-solutions/sdk 0.64.0 → 0.66.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/dist/configs/dto.js +4 -12
- package/dist/documents/document-templates.js +3 -0
- package/dist/documents/documents.d.ts +7 -3
- package/dist/documents/documents.js +10 -2
- package/dist/documents/dto.d.ts +19 -1
- package/dist/documents/dto.js +105 -1
- package/dist/documents/render/html.js +24 -10
- package/dist/documents/render/index.d.ts +1 -1
- package/dist/documents/render/index.js +2 -1
- package/dist/documents/render/values.d.ts +8 -4
- package/dist/documents/render/values.js +13 -5
- package/dist/feature-requests/dto.js +4 -13
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -2
- package/dist/service-client/index.d.ts +12 -0
- package/dist/service-client/index.js +17 -0
- package/dist/validators.d.ts +6 -0
- package/dist/validators.js +9 -0
- package/package.json +2 -2
package/dist/configs/dto.js
CHANGED
|
@@ -11,17 +11,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.UpdateConfigDto = exports.CreateConfigDto = void 0;
|
|
13
13
|
const class_validator_1 = require("class-validator");
|
|
14
|
-
const
|
|
14
|
+
const validators_1 = require("../validators");
|
|
15
15
|
// class-validator version of the shared DTO type from @managemint-solutions/entities, so the
|
|
16
16
|
// wire contract cannot drift.
|
|
17
|
-
/**
|
|
18
|
-
* Whitespace on either side of a pasted value is not part of the answer. Trimming here rather
|
|
19
|
-
* than in the api means the length rules below measure what will actually be stored - a name of
|
|
20
|
-
* three spaces is empty, not three characters long.
|
|
21
|
-
*/
|
|
22
|
-
const Trim = () => (0, class_transformer_1.Transform)(({ value }) => (typeof value === 'string' ? value.trim() : value), {
|
|
23
|
-
toClassOnly: true,
|
|
24
|
-
});
|
|
25
17
|
class CreateConfigDto {
|
|
26
18
|
name;
|
|
27
19
|
description;
|
|
@@ -34,7 +26,7 @@ class CreateConfigDto {
|
|
|
34
26
|
}
|
|
35
27
|
exports.CreateConfigDto = CreateConfigDto;
|
|
36
28
|
__decorate([
|
|
37
|
-
Trim(),
|
|
29
|
+
(0, validators_1.Trim)(),
|
|
38
30
|
(0, class_validator_1.IsString)({ message: 'Invalid name' }),
|
|
39
31
|
(0, class_validator_1.MinLength)(1, { message: 'Name cannot be empty' }),
|
|
40
32
|
(0, class_validator_1.MaxLength)(100, { message: 'Name cannot exceed 100 characters' }),
|
|
@@ -42,7 +34,7 @@ __decorate([
|
|
|
42
34
|
], CreateConfigDto.prototype, "name", void 0);
|
|
43
35
|
__decorate([
|
|
44
36
|
(0, class_validator_1.IsOptional)(),
|
|
45
|
-
Trim(),
|
|
37
|
+
(0, validators_1.Trim)(),
|
|
46
38
|
(0, class_validator_1.IsString)({ message: 'Invalid description' }),
|
|
47
39
|
(0, class_validator_1.MaxLength)(1000, { message: 'Description cannot exceed 1000 characters' }),
|
|
48
40
|
__metadata("design:type", String)
|
|
@@ -61,7 +53,7 @@ class UpdateConfigDto {
|
|
|
61
53
|
exports.UpdateConfigDto = UpdateConfigDto;
|
|
62
54
|
__decorate([
|
|
63
55
|
(0, class_validator_1.IsOptional)(),
|
|
64
|
-
Trim(),
|
|
56
|
+
(0, validators_1.Trim)(),
|
|
65
57
|
(0, class_validator_1.IsString)({ message: 'Invalid description' }),
|
|
66
58
|
(0, class_validator_1.MaxLength)(1000, { message: 'Description cannot exceed 1000 characters' }),
|
|
67
59
|
__metadata("design:type", String)
|
|
@@ -15,6 +15,7 @@ const TEMPLATE_LIST_SELECT = `
|
|
|
15
15
|
name,
|
|
16
16
|
category,
|
|
17
17
|
number_prefix,
|
|
18
|
+
due_days,
|
|
18
19
|
archived,
|
|
19
20
|
visibility
|
|
20
21
|
`;
|
|
@@ -27,6 +28,7 @@ const TEMPLATE_DETAIL_SELECT = `
|
|
|
27
28
|
name,
|
|
28
29
|
category,
|
|
29
30
|
number_prefix,
|
|
31
|
+
due_days,
|
|
30
32
|
variables,
|
|
31
33
|
blocks,
|
|
32
34
|
blocks_version,
|
|
@@ -43,6 +45,7 @@ const templateRow = (input) => ({
|
|
|
43
45
|
name: input.name,
|
|
44
46
|
category: input.category ?? '',
|
|
45
47
|
number_prefix: input.number_prefix ?? '',
|
|
48
|
+
due_days: input.due_days ?? null,
|
|
46
49
|
variables: input.variables,
|
|
47
50
|
blocks: input.blocks,
|
|
48
51
|
});
|
|
@@ -41,6 +41,9 @@ type DocumentRow = {
|
|
|
41
41
|
repeat_from: string | null;
|
|
42
42
|
issue_at: string | null;
|
|
43
43
|
email: DocumentEmail | null;
|
|
44
|
+
/** When it falls due: days after issue on a draft, the date itself (YYYY-MM-DD) once picked or issued. */
|
|
45
|
+
due_days: number | null;
|
|
46
|
+
due_at: string | null;
|
|
44
47
|
};
|
|
45
48
|
/**
|
|
46
49
|
* A document as the sdk reads it. `my_role` (what the caller may do with it), `payments` (read
|
|
@@ -58,7 +61,7 @@ export type DocumentSendEvent = Pick<DocumentSend, 'recipients' | 'cc' | 'subjec
|
|
|
58
61
|
* the cron's, for the drafts it makes.
|
|
59
62
|
*/
|
|
60
63
|
export type CreateDocumentRow = Omit<DocumentRow, 'status' | 'number_sequence' | 'number' | 'issued_at' | 'issued_by' | 'voided_at' | 'voided_by' | 'void_reason' | keyof DocumentScheduleRow> & Partial<DocumentScheduleRow>;
|
|
61
|
-
type DocumentScheduleRow = Pick<DocumentRow, 'repeat' | 'repeat_next_at' | 'repeat_until' | 'repeat_paused' | 'repeat_from' | 'issue_at' | 'email'>;
|
|
64
|
+
type DocumentScheduleRow = Pick<DocumentRow, 'repeat' | 'repeat_next_at' | 'repeat_until' | 'repeat_paused' | 'repeat_from' | 'issue_at' | 'email' | 'due_days' | 'due_at'>;
|
|
62
65
|
/**
|
|
63
66
|
* A draft save, an issue or a void: whichever columns it changes - never the visibility, which
|
|
64
67
|
* members hold no grant on after create (the visibility route changes it on the service role).
|
|
@@ -82,8 +85,9 @@ export declare class DocumentsResource {
|
|
|
82
85
|
* Newest first; `search` matches the title and the number. Recurring parents are a list of
|
|
83
86
|
* their own: `recurring` lists them alone, and every other list leaves them out. `ids` keeps
|
|
84
87
|
* the list to (`in`) or away from (`not_in`) the documents named - the api's payment filter
|
|
85
|
-
* passes the paid ones - and `payable` to issued documents with a total above zero
|
|
86
|
-
*
|
|
88
|
+
* passes the paid ones - and `payable` to issued documents with a total above zero;
|
|
89
|
+
* `due_before` to documents due on or before that date. The DTO's `payment` and `overdue`
|
|
90
|
+
* are the api's to turn into those; the list ignores them.
|
|
87
91
|
*/
|
|
88
92
|
list(query: GetDocumentsDto & {
|
|
89
93
|
organization_id?: string | null;
|
|
@@ -31,6 +31,8 @@ const DOCUMENT_LIST_SELECT = `
|
|
|
31
31
|
repeat_paused,
|
|
32
32
|
repeat_from,
|
|
33
33
|
issue_at,
|
|
34
|
+
due_days,
|
|
35
|
+
due_at,
|
|
34
36
|
visibility
|
|
35
37
|
`;
|
|
36
38
|
const DOCUMENT_DETAIL_SELECT = `
|
|
@@ -67,6 +69,8 @@ const DOCUMENT_DETAIL_SELECT = `
|
|
|
67
69
|
repeat_from,
|
|
68
70
|
issue_at,
|
|
69
71
|
email,
|
|
72
|
+
due_days,
|
|
73
|
+
due_at,
|
|
70
74
|
visibility
|
|
71
75
|
`;
|
|
72
76
|
/** How long a signed image URL in rendered HTML stays valid - long enough to keep a preview open. */
|
|
@@ -102,8 +106,9 @@ class DocumentsResource {
|
|
|
102
106
|
* Newest first; `search` matches the title and the number. Recurring parents are a list of
|
|
103
107
|
* their own: `recurring` lists them alone, and every other list leaves them out. `ids` keeps
|
|
104
108
|
* the list to (`in`) or away from (`not_in`) the documents named - the api's payment filter
|
|
105
|
-
* passes the paid ones - and `payable` to issued documents with a total above zero
|
|
106
|
-
*
|
|
109
|
+
* passes the paid ones - and `payable` to issued documents with a total above zero;
|
|
110
|
+
* `due_before` to documents due on or before that date. The DTO's `payment` and `overdue`
|
|
111
|
+
* are the api's to turn into those; the list ignores them.
|
|
107
112
|
*/
|
|
108
113
|
async list(query) {
|
|
109
114
|
const page = query.page;
|
|
@@ -146,6 +151,9 @@ class DocumentsResource {
|
|
|
146
151
|
if (query.payable) {
|
|
147
152
|
documentsQuery = documentsQuery.eq('status', enum_1.DocumentStatus.ISSUED).gt('total_minor', 0);
|
|
148
153
|
}
|
|
154
|
+
if (query.due_before) {
|
|
155
|
+
documentsQuery = documentsQuery.lte('due_at', query.due_before);
|
|
156
|
+
}
|
|
149
157
|
if (trimmedSearch) {
|
|
150
158
|
documentsQuery = documentsQuery.or((0, transforms_1.orIlike)(['title', 'number'], trimmedSearch));
|
|
151
159
|
}
|
package/dist/documents/dto.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DocumentBlock, DocumentEmail, DocumentVariable, DocumentVariableValues } from '@managemint-solutions/entities/documents';
|
|
2
|
-
import type { CreateDocumentDto as CreateDocumentDtoType, CreateDocumentTemplateDto as CreateDocumentTemplateDtoType, DocumentIdDto as DocumentIdDtoType, DocumentImageNameDto as DocumentImageNameDtoType, DocumentImageUrlsDto as DocumentImageUrlsDtoType, DocumentPayQueryDto as DocumentPayQueryDtoType, DocumentPayTokenDto as DocumentPayTokenDtoType, DocumentPaymentIdDto as DocumentPaymentIdDtoType, DocumentTemplateIdDto as DocumentTemplateIdDtoType, GetDocumentsDto as GetDocumentsDtoType, GetDocumentTemplatesDto as GetDocumentTemplatesDtoType, PayDocumentDto as PayDocumentDtoType, RecordDocumentPaymentDto as RecordDocumentPaymentDtoType, ReassignPrivateDocumentsDto as ReassignPrivateDocumentsDtoType, SendDocumentDto as SendDocumentDtoType, UpdateDocumentDto as UpdateDocumentDtoType, UpdateDocumentTemplateDto as UpdateDocumentTemplateDtoType, VoidDocumentDto as VoidDocumentDtoType } from '@managemint-solutions/entities/documents/dto';
|
|
2
|
+
import type { CatalogueTemplateSlugDto as CatalogueTemplateSlugDtoType, CopyCatalogueTemplateDto as CopyCatalogueTemplateDtoType, CreateDocumentDto as CreateDocumentDtoType, CreateDocumentTemplateDto as CreateDocumentTemplateDtoType, DocumentIdDto as DocumentIdDtoType, DocumentImageNameDto as DocumentImageNameDtoType, DocumentImageUrlsDto as DocumentImageUrlsDtoType, DocumentPayQueryDto as DocumentPayQueryDtoType, DocumentPayTokenDto as DocumentPayTokenDtoType, DocumentPaymentIdDto as DocumentPaymentIdDtoType, DocumentTemplateIdDto as DocumentTemplateIdDtoType, GetCatalogueTemplatesDto as GetCatalogueTemplatesDtoType, GetDocumentsDto as GetDocumentsDtoType, GetDocumentTemplatesDto as GetDocumentTemplatesDtoType, PayDocumentDto as PayDocumentDtoType, RecordDocumentPaymentDto as RecordDocumentPaymentDtoType, ReassignPrivateDocumentsDto as ReassignPrivateDocumentsDtoType, SendDocumentDto as SendDocumentDtoType, UpdateDocumentDto as UpdateDocumentDtoType, UpdateDocumentTemplateDto as UpdateDocumentTemplateDtoType, VoidDocumentDto as VoidDocumentDtoType } from '@managemint-solutions/entities/documents/dto';
|
|
3
3
|
import { DocumentPaymentFilter, DocumentRepeat, DocumentStatus, DocumentVisibility } from '@managemint-solutions/entities/documents/enum';
|
|
4
4
|
export declare class GetDocumentTemplatesDto implements GetDocumentTemplatesDtoType {
|
|
5
5
|
readonly search?: string | null;
|
|
@@ -16,6 +16,7 @@ export declare class UpdateDocumentTemplateDto implements UpdateDocumentTemplate
|
|
|
16
16
|
readonly name: string;
|
|
17
17
|
readonly category?: string;
|
|
18
18
|
readonly number_prefix?: string;
|
|
19
|
+
readonly due_days?: number | null;
|
|
19
20
|
readonly variables: DocumentVariable[];
|
|
20
21
|
readonly blocks: DocumentBlock[];
|
|
21
22
|
}
|
|
@@ -32,6 +33,8 @@ export declare class GetDocumentsDto implements GetDocumentsDtoType {
|
|
|
32
33
|
readonly recurring?: boolean;
|
|
33
34
|
readonly repeat_from?: string | null;
|
|
34
35
|
readonly payment?: DocumentPaymentFilter | null;
|
|
36
|
+
readonly due_before?: string | null;
|
|
37
|
+
readonly overdue?: boolean;
|
|
35
38
|
readonly page: number;
|
|
36
39
|
readonly page_size: number;
|
|
37
40
|
}
|
|
@@ -50,6 +53,8 @@ declare class DocumentScheduleDto {
|
|
|
50
53
|
readonly repeat_paused?: boolean;
|
|
51
54
|
readonly issue_at?: string | null;
|
|
52
55
|
readonly email?: DocumentEmail | null;
|
|
56
|
+
readonly due_days?: number | null;
|
|
57
|
+
readonly due_at?: string | null;
|
|
53
58
|
}
|
|
54
59
|
/**
|
|
55
60
|
* A new draft. Its values cannot be checked here - with a template, the variables they fill are
|
|
@@ -122,4 +127,17 @@ export declare class DocumentPaymentIdDto implements DocumentPaymentIdDtoType {
|
|
|
122
127
|
readonly documentId: string;
|
|
123
128
|
readonly paymentId: string;
|
|
124
129
|
}
|
|
130
|
+
export declare class GetCatalogueTemplatesDto implements GetCatalogueTemplatesDtoType {
|
|
131
|
+
readonly search?: string | null;
|
|
132
|
+
readonly category?: string | null;
|
|
133
|
+
}
|
|
134
|
+
export declare class CatalogueTemplateSlugDto implements CatalogueTemplateSlugDtoType {
|
|
135
|
+
readonly slug: string;
|
|
136
|
+
}
|
|
137
|
+
/** The copy's own name and prefix are optional and held to a template save's rules when given. */
|
|
138
|
+
export declare class CopyCatalogueTemplateDto implements CopyCatalogueTemplateDtoType {
|
|
139
|
+
readonly slug: string;
|
|
140
|
+
readonly name?: string;
|
|
141
|
+
readonly number_prefix?: string;
|
|
142
|
+
}
|
|
125
143
|
export {};
|
package/dist/documents/dto.js
CHANGED
|
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
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;
|
|
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
13
|
const class_validator_1 = require("class-validator");
|
|
14
14
|
const class_transformer_1 = require("class-transformer");
|
|
15
15
|
const enum_1 = require("@managemint-solutions/entities/documents/enum");
|
|
@@ -79,16 +79,22 @@ __decorate([
|
|
|
79
79
|
(0, class_validator_1.IsUUID)('7', { message: 'Invalid template ID format' }),
|
|
80
80
|
__metadata("design:type", String)
|
|
81
81
|
], DocumentTemplateIdDto.prototype, "templateId", void 0);
|
|
82
|
+
/** Days after issue a document falls due: a whole number from 0 to 365. */
|
|
83
|
+
const IsDueDays = (0, validators_1.fromProblem)('isDueDays', (value) => Number.isInteger(value) && value >= 0 && value <= 365
|
|
84
|
+
? null
|
|
85
|
+
: 'Due days must be a whole number from 0 to 365');
|
|
82
86
|
/** Saving replaces the whole template. Its visibility changes only through the visibility route. */
|
|
83
87
|
class UpdateDocumentTemplateDto {
|
|
84
88
|
name;
|
|
85
89
|
category;
|
|
86
90
|
number_prefix;
|
|
91
|
+
due_days;
|
|
87
92
|
variables;
|
|
88
93
|
blocks;
|
|
89
94
|
}
|
|
90
95
|
exports.UpdateDocumentTemplateDto = UpdateDocumentTemplateDto;
|
|
91
96
|
__decorate([
|
|
97
|
+
(0, validators_1.Trim)(),
|
|
92
98
|
(0, class_validator_1.MaxLength)(100, { message: 'Name cannot exceed 100 characters' }),
|
|
93
99
|
(0, class_validator_1.MinLength)(1, { message: 'Name cannot be empty' }),
|
|
94
100
|
(0, class_validator_1.IsString)({ message: 'Name must be text' }),
|
|
@@ -101,9 +107,16 @@ __decorate([
|
|
|
101
107
|
], UpdateDocumentTemplateDto.prototype, "category", void 0);
|
|
102
108
|
__decorate([
|
|
103
109
|
(0, class_validator_1.IsOptional)(),
|
|
110
|
+
(0, validators_1.Trim)(),
|
|
104
111
|
(0, content_1.IsDocumentNumberPrefix)(),
|
|
105
112
|
__metadata("design:type", String)
|
|
106
113
|
], UpdateDocumentTemplateDto.prototype, "number_prefix", void 0);
|
|
114
|
+
__decorate([
|
|
115
|
+
(0, class_validator_1.IsOptional)(),
|
|
116
|
+
(0, validators_1.IsNullable)(),
|
|
117
|
+
IsDueDays(),
|
|
118
|
+
__metadata("design:type", Object)
|
|
119
|
+
], UpdateDocumentTemplateDto.prototype, "due_days", void 0);
|
|
107
120
|
__decorate([
|
|
108
121
|
(0, content_1.IsDocumentVariables)(),
|
|
109
122
|
__metadata("design:type", Array)
|
|
@@ -136,6 +149,9 @@ class GetDocumentsDto {
|
|
|
136
149
|
recurring;
|
|
137
150
|
repeat_from;
|
|
138
151
|
payment;
|
|
152
|
+
due_before;
|
|
153
|
+
// Issued, due before today, nothing settled - resolved by the api; the sdk list ignores it.
|
|
154
|
+
overdue;
|
|
139
155
|
page = 1;
|
|
140
156
|
page_size = 10;
|
|
141
157
|
}
|
|
@@ -191,6 +207,18 @@ __decorate([
|
|
|
191
207
|
(0, class_validator_1.IsEnum)(enum_1.DocumentPaymentFilter, { message: `Payment must be one of: ${Object.values(enum_1.DocumentPaymentFilter).join(', ')}` }),
|
|
192
208
|
__metadata("design:type", Object)
|
|
193
209
|
], GetDocumentsDto.prototype, "payment", void 0);
|
|
210
|
+
__decorate([
|
|
211
|
+
(0, class_validator_1.IsOptional)(),
|
|
212
|
+
(0, validators_1.IsNullable)(),
|
|
213
|
+
(0, validators_1.IsCalendarDate)({ message: 'Due before must be a calendar date (YYYY-MM-DD)' }),
|
|
214
|
+
__metadata("design:type", Object)
|
|
215
|
+
], GetDocumentsDto.prototype, "due_before", void 0);
|
|
216
|
+
__decorate([
|
|
217
|
+
(0, class_validator_1.IsOptional)(),
|
|
218
|
+
(0, class_transformer_1.Transform)(({ value }) => value === true || value === 'true', { toClassOnly: true }),
|
|
219
|
+
(0, class_validator_1.IsBoolean)({ message: 'Overdue must be a boolean' }),
|
|
220
|
+
__metadata("design:type", Boolean)
|
|
221
|
+
], GetDocumentsDto.prototype, "overdue", void 0);
|
|
194
222
|
__decorate([
|
|
195
223
|
(0, class_validator_1.IsOptional)(),
|
|
196
224
|
(0, class_transformer_1.Transform)(({ value }) => value ? Number(value) : 1, { toClassOnly: true }),
|
|
@@ -240,6 +268,8 @@ class DocumentScheduleDto {
|
|
|
240
268
|
repeat_paused;
|
|
241
269
|
issue_at;
|
|
242
270
|
email;
|
|
271
|
+
due_days;
|
|
272
|
+
due_at;
|
|
243
273
|
}
|
|
244
274
|
__decorate([
|
|
245
275
|
(0, class_validator_1.IsOptional)(),
|
|
@@ -276,6 +306,18 @@ __decorate([
|
|
|
276
306
|
IsDocumentEmail(),
|
|
277
307
|
__metadata("design:type", Object)
|
|
278
308
|
], DocumentScheduleDto.prototype, "email", void 0);
|
|
309
|
+
__decorate([
|
|
310
|
+
(0, class_validator_1.IsOptional)(),
|
|
311
|
+
(0, validators_1.IsNullable)(),
|
|
312
|
+
IsDueDays(),
|
|
313
|
+
__metadata("design:type", Object)
|
|
314
|
+
], DocumentScheduleDto.prototype, "due_days", void 0);
|
|
315
|
+
__decorate([
|
|
316
|
+
(0, class_validator_1.IsOptional)(),
|
|
317
|
+
(0, validators_1.IsNullable)(),
|
|
318
|
+
(0, validators_1.IsCalendarDate)({ message: 'Due date must be a calendar date (YYYY-MM-DD)' }),
|
|
319
|
+
__metadata("design:type", Object)
|
|
320
|
+
], DocumentScheduleDto.prototype, "due_at", void 0);
|
|
279
321
|
/**
|
|
280
322
|
* A new draft. Its values cannot be checked here - with a template, the variables they fill are
|
|
281
323
|
* the template's - so the api checks the draft it composes with `documentProblem`.
|
|
@@ -350,6 +392,7 @@ __decorate([
|
|
|
350
392
|
__metadata("design:type", String)
|
|
351
393
|
], UpdateDocumentDto.prototype, "category", void 0);
|
|
352
394
|
__decorate([
|
|
395
|
+
(0, validators_1.Trim)(),
|
|
353
396
|
(0, content_1.IsDocumentNumberPrefix)(),
|
|
354
397
|
__metadata("design:type", String)
|
|
355
398
|
], UpdateDocumentDto.prototype, "number_prefix", void 0);
|
|
@@ -528,3 +571,64 @@ __decorate([
|
|
|
528
571
|
(0, class_validator_1.IsUUID)('7', { message: 'Invalid payment ID format' }),
|
|
529
572
|
__metadata("design:type", String)
|
|
530
573
|
], DocumentPaymentIdDto.prototype, "paymentId", void 0);
|
|
574
|
+
// ------------------------------------------------------------
|
|
575
|
+
// Template catalogue
|
|
576
|
+
// ------------------------------------------------------------
|
|
577
|
+
/** A catalogue slug: lower-case letters and digits in hyphen-joined words, e.g. `residential-lease-za`. */
|
|
578
|
+
const CATALOGUE_SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
579
|
+
class GetCatalogueTemplatesDto {
|
|
580
|
+
search;
|
|
581
|
+
category;
|
|
582
|
+
}
|
|
583
|
+
exports.GetCatalogueTemplatesDto = GetCatalogueTemplatesDto;
|
|
584
|
+
__decorate([
|
|
585
|
+
(0, class_validator_1.IsOptional)(),
|
|
586
|
+
(0, validators_1.IsNullable)(),
|
|
587
|
+
(0, class_validator_1.MaxLength)(100, { message: 'Search query cannot exceed 100 characters' }),
|
|
588
|
+
(0, class_validator_1.MinLength)(1, { message: 'Search query cannot be empty' }),
|
|
589
|
+
(0, class_validator_1.IsString)({ message: 'Search query must be a string' }),
|
|
590
|
+
__metadata("design:type", Object)
|
|
591
|
+
], GetCatalogueTemplatesDto.prototype, "search", void 0);
|
|
592
|
+
__decorate([
|
|
593
|
+
(0, class_validator_1.IsOptional)(),
|
|
594
|
+
(0, validators_1.IsNullable)(),
|
|
595
|
+
(0, content_1.IsDocumentCategory)(),
|
|
596
|
+
__metadata("design:type", Object)
|
|
597
|
+
], GetCatalogueTemplatesDto.prototype, "category", void 0);
|
|
598
|
+
class CatalogueTemplateSlugDto {
|
|
599
|
+
slug;
|
|
600
|
+
}
|
|
601
|
+
exports.CatalogueTemplateSlugDto = CatalogueTemplateSlugDto;
|
|
602
|
+
__decorate([
|
|
603
|
+
(0, class_validator_1.MaxLength)(80, { message: 'Unknown template' }),
|
|
604
|
+
(0, class_validator_1.Matches)(CATALOGUE_SLUG, { message: 'Unknown template' }),
|
|
605
|
+
(0, class_validator_1.IsString)({ message: 'Unknown template' }),
|
|
606
|
+
__metadata("design:type", String)
|
|
607
|
+
], CatalogueTemplateSlugDto.prototype, "slug", void 0);
|
|
608
|
+
/** The copy's own name and prefix are optional and held to a template save's rules when given. */
|
|
609
|
+
class CopyCatalogueTemplateDto {
|
|
610
|
+
slug;
|
|
611
|
+
name;
|
|
612
|
+
number_prefix;
|
|
613
|
+
}
|
|
614
|
+
exports.CopyCatalogueTemplateDto = CopyCatalogueTemplateDto;
|
|
615
|
+
__decorate([
|
|
616
|
+
(0, class_validator_1.MaxLength)(80, { message: 'Unknown template' }),
|
|
617
|
+
(0, class_validator_1.Matches)(CATALOGUE_SLUG, { message: 'Unknown template' }),
|
|
618
|
+
(0, class_validator_1.IsString)({ message: 'Give the template to copy' }),
|
|
619
|
+
__metadata("design:type", String)
|
|
620
|
+
], CopyCatalogueTemplateDto.prototype, "slug", void 0);
|
|
621
|
+
__decorate([
|
|
622
|
+
(0, class_validator_1.IsOptional)(),
|
|
623
|
+
(0, validators_1.Trim)(),
|
|
624
|
+
(0, class_validator_1.MaxLength)(100, { message: 'Name cannot exceed 100 characters' }),
|
|
625
|
+
(0, class_validator_1.MinLength)(1, { message: 'Name cannot be empty' }),
|
|
626
|
+
(0, class_validator_1.IsString)({ message: 'Name must be text' }),
|
|
627
|
+
__metadata("design:type", String)
|
|
628
|
+
], CopyCatalogueTemplateDto.prototype, "name", void 0);
|
|
629
|
+
__decorate([
|
|
630
|
+
(0, class_validator_1.IsOptional)(),
|
|
631
|
+
(0, validators_1.Trim)(),
|
|
632
|
+
(0, content_1.IsDocumentNumberPrefix)(),
|
|
633
|
+
__metadata("design:type", String)
|
|
634
|
+
], CopyCatalogueTemplateDto.prototype, "number_prefix", void 0);
|
|
@@ -51,18 +51,32 @@ const filledText = (text, ctx) => text.replace(values_1.DOCUMENT_VARIABLE_PATTER
|
|
|
51
51
|
* Plain text with each `{{key}}` replaced by its value; everything else escaped, and every line
|
|
52
52
|
* break a `<br>`. A break left as a newline would hang on `white-space: pre-wrap`, and between two
|
|
53
53
|
* placeholders it is a text node of whitespace alone, which the portal's paged preview drops -
|
|
54
|
-
* the two lines then print as one.
|
|
54
|
+
* the two lines then print as one. On an issued document a line whose variables are all empty
|
|
55
|
+
* is left out - "VAT no. {{client_vat_number}}" for a client with no VAT number, or
|
|
56
|
+
* `{{client_address}}` with no address - rather than printing its words with nothing after them;
|
|
57
|
+
* a line with one value filled, or with no variable at all (a blank line included), stays.
|
|
55
58
|
*/
|
|
56
59
|
const plainHtml = (text, ctx) => {
|
|
57
60
|
if (typeof text !== 'string')
|
|
58
61
|
return '';
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
html
|
|
63
|
-
last =
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
return text
|
|
63
|
+
.split(/\r?\n/)
|
|
64
|
+
.flatMap((line) => {
|
|
65
|
+
let html = '';
|
|
66
|
+
let last = 0;
|
|
67
|
+
let variables = 0;
|
|
68
|
+
let filled = 0;
|
|
69
|
+
for (const match of line.matchAll(values_1.DOCUMENT_VARIABLE_PATTERN)) {
|
|
70
|
+
variables += 1;
|
|
71
|
+
if (PAGE_COUNTERS[match[1]] || valueText(match[1], ctx) !== null)
|
|
72
|
+
filled += 1;
|
|
73
|
+
html += (0, values_1.escapeHtml)(line.slice(last, match.index)) + valueHtml(match[1], ctx);
|
|
74
|
+
last = match.index + match[0].length;
|
|
75
|
+
}
|
|
76
|
+
html += (0, values_1.escapeHtml)(line.slice(last));
|
|
77
|
+
return !ctx.placeholders && variables > 0 && filled === 0 ? [] : [html];
|
|
78
|
+
})
|
|
79
|
+
.join('<br>');
|
|
66
80
|
};
|
|
67
81
|
/** Bold, italic, underline and links around `html`; any other mark is ignored. */
|
|
68
82
|
const withMarks = (html, marks) => (Array.isArray(marks) ? marks : []).reduce((inner, mark) => {
|
|
@@ -151,14 +165,14 @@ const blockHtml = (block, ctx, imageUrls) => {
|
|
|
151
165
|
return `<div class="block text">${richTextHtml(block.content, ctx)}</div>`;
|
|
152
166
|
case enum_1.DocumentBlockType.FIELDS: {
|
|
153
167
|
// A blank side shows where it prints on a template or draft; an issued document leaves out a
|
|
154
|
-
// row with
|
|
168
|
+
// row with no value - its label alone says nothing - and the block with no rows left.
|
|
155
169
|
const rows = block.fields.flatMap((field) => {
|
|
156
170
|
const label = plainHtml(field.label, ctx);
|
|
157
171
|
const value = plainHtml(field.value, ctx);
|
|
158
172
|
if (ctx.placeholders) {
|
|
159
173
|
return [`<tr><th>${label.trim() || placeholder('Label')}</th><td>${value.trim() || placeholder('Value')}</td></tr>`];
|
|
160
174
|
}
|
|
161
|
-
return
|
|
175
|
+
return value.trim() ? [`<tr><th>${label}</th><td>${value}</td></tr>`] : [];
|
|
162
176
|
});
|
|
163
177
|
return rows.length > 0 ? `<div class="block"><table class="fields"><tbody>${rows.join('')}</tbody></table></div>` : '';
|
|
164
178
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { DOCUMENT_PAGE_MARGINS, fillText, renderBand, renderDocument, type DocumentBand, type PrintableDocument, type RenderedDocument, } from './html';
|
|
2
|
-
export { documentTotals, escapeHtml, formatDocumentDate, johannesburgDate, money, MONO_FONT, printsMoney, startingValues, SYSTEM_VARIABLES, systemValues, type DocumentTotals, type SystemValueInputs, } from './values';
|
|
2
|
+
export { documentTotals, dueDateFrom, escapeHtml, formatDocumentDate, johannesburgDate, money, MONO_FONT, printsMoney, startingValues, SYSTEM_VARIABLES, systemValues, type DocumentTotals, type SystemValueInputs, } from './values';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.systemValues = exports.SYSTEM_VARIABLES = exports.startingValues = exports.printsMoney = exports.MONO_FONT = exports.money = exports.johannesburgDate = exports.formatDocumentDate = exports.escapeHtml = exports.documentTotals = exports.renderDocument = exports.renderBand = exports.fillText = exports.DOCUMENT_PAGE_MARGINS = void 0;
|
|
3
|
+
exports.systemValues = exports.SYSTEM_VARIABLES = exports.startingValues = exports.printsMoney = exports.MONO_FONT = exports.money = exports.johannesburgDate = exports.formatDocumentDate = exports.escapeHtml = exports.dueDateFrom = exports.documentTotals = exports.renderDocument = exports.renderBand = exports.fillText = exports.DOCUMENT_PAGE_MARGINS = void 0;
|
|
4
4
|
// `@managemint-solutions/sdk/documents`: the document renderer and the values it prints, as pure
|
|
5
5
|
// functions with no dependency beyond the shared entities - no Node, no Nest, no supabase-js, no
|
|
6
6
|
// DOM - so the api's PDF and the portal's in-browser preview are one renderer. The caller loads
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "renderBand", { enumerable: true, get: function (
|
|
|
12
12
|
Object.defineProperty(exports, "renderDocument", { enumerable: true, get: function () { return html_1.renderDocument; } });
|
|
13
13
|
var values_1 = require("./values");
|
|
14
14
|
Object.defineProperty(exports, "documentTotals", { enumerable: true, get: function () { return values_1.documentTotals; } });
|
|
15
|
+
Object.defineProperty(exports, "dueDateFrom", { enumerable: true, get: function () { return values_1.dueDateFrom; } });
|
|
15
16
|
Object.defineProperty(exports, "escapeHtml", { enumerable: true, get: function () { return values_1.escapeHtml; } });
|
|
16
17
|
Object.defineProperty(exports, "formatDocumentDate", { enumerable: true, get: function () { return values_1.formatDocumentDate; } });
|
|
17
18
|
Object.defineProperty(exports, "johannesburgDate", { enumerable: true, get: function () { return values_1.johannesburgDate; } });
|
|
@@ -75,12 +75,16 @@ export type SystemValueInputs = {
|
|
|
75
75
|
number: string | null;
|
|
76
76
|
/** `YYYY-MM-DD`: today on a draft (`johannesburgDate(new Date())`), the issue date once issued. */
|
|
77
77
|
issueDate: string;
|
|
78
|
+
/** `YYYY-MM-DD`: when the document falls due; left out (prints as missing) without one. */
|
|
79
|
+
dueDate?: string | null;
|
|
78
80
|
};
|
|
81
|
+
/** `issueDate` plus `days`, as a calendar date: the due date of a document issued that day. */
|
|
82
|
+
export declare const dueDateFrom: (issueDate: string, days: number) => string;
|
|
79
83
|
/**
|
|
80
84
|
* The values filled in for the system variables: the organization's name (its trading name
|
|
81
85
|
* first), address, registration and VAT numbers, email and phone; the client's name, email, phone,
|
|
82
|
-
* address, registration and VAT numbers; the document number;
|
|
83
|
-
* name and year. A value that is empty is left out, so it prints as missing.
|
|
84
|
-
* page number and count are not values: they are counted page by page as the PDF prints.
|
|
86
|
+
* address, registration and VAT numbers; the document number; the issue date with its month
|
|
87
|
+
* name and year; and the due date. A value that is empty is left out, so it prints as missing.
|
|
88
|
+
* The page number and count are not values: they are counted page by page as the PDF prints.
|
|
85
89
|
*/
|
|
86
|
-
export declare const systemValues: ({ organization, client, number, issueDate }: SystemValueInputs) => DocumentVariableValues;
|
|
90
|
+
export declare const systemValues: ({ organization, client, number, issueDate, dueDate }: SystemValueInputs) => DocumentVariableValues;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.systemValues = exports.johannesburgDate = exports.startingValues = exports.printsMoney = exports.documentTotals = exports.lineAmounts = exports.MONO_FONT = exports.formatDocumentDate = exports.money = exports.escapeHtml = exports.safeHref = exports.isObject = exports.SYSTEM_VARIABLES = exports.DOCUMENT_VARIABLE_PATTERN = void 0;
|
|
3
|
+
exports.systemValues = exports.dueDateFrom = exports.johannesburgDate = exports.startingValues = exports.printsMoney = exports.documentTotals = exports.lineAmounts = exports.MONO_FONT = exports.formatDocumentDate = exports.money = exports.escapeHtml = exports.safeHref = exports.isObject = exports.SYSTEM_VARIABLES = exports.DOCUMENT_VARIABLE_PATTERN = void 0;
|
|
4
4
|
const enum_1 = require("@managemint-solutions/entities/documents/enum");
|
|
5
5
|
// The values a document prints that nobody types in: one line's amounts, the totals of every line
|
|
6
6
|
// items block, the system values, and how a value is escaped and formatted. Pure functions with
|
|
@@ -33,6 +33,7 @@ exports.SYSTEM_VARIABLES = {
|
|
|
33
33
|
[enum_1.DocumentSystemVariable.CLIENT_ADDRESS]: { label: 'Client address', type: enum_1.DocumentVariableType.TEXT },
|
|
34
34
|
[enum_1.DocumentSystemVariable.CLIENT_REGISTRATION_NUMBER]: { label: 'Client registration number', type: enum_1.DocumentVariableType.TEXT },
|
|
35
35
|
[enum_1.DocumentSystemVariable.CLIENT_VAT_NUMBER]: { label: 'Client VAT number', type: enum_1.DocumentVariableType.TEXT },
|
|
36
|
+
[enum_1.DocumentSystemVariable.DUE_DATE]: { label: 'Due date', type: enum_1.DocumentVariableType.DATE },
|
|
36
37
|
};
|
|
37
38
|
const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
38
39
|
exports.isObject = isObject;
|
|
@@ -108,14 +109,20 @@ exports.startingValues = startingValues;
|
|
|
108
109
|
/** The calendar date (`YYYY-MM-DD`) `now` falls on in Africa/Johannesburg - a draft's issue date. */
|
|
109
110
|
const johannesburgDate = (now) => new Intl.DateTimeFormat('en-CA', { timeZone: 'Africa/Johannesburg' }).format(now);
|
|
110
111
|
exports.johannesburgDate = johannesburgDate;
|
|
112
|
+
/** `issueDate` plus `days`, as a calendar date: the due date of a document issued that day. */
|
|
113
|
+
const dueDateFrom = (issueDate, days) => {
|
|
114
|
+
const [year, month, day] = issueDate.split('-').map(Number);
|
|
115
|
+
return new Date(Date.UTC(year, month - 1, day + days)).toISOString().slice(0, 10);
|
|
116
|
+
};
|
|
117
|
+
exports.dueDateFrom = dueDateFrom;
|
|
111
118
|
/**
|
|
112
119
|
* The values filled in for the system variables: the organization's name (its trading name
|
|
113
120
|
* first), address, registration and VAT numbers, email and phone; the client's name, email, phone,
|
|
114
|
-
* address, registration and VAT numbers; the document number;
|
|
115
|
-
* name and year. A value that is empty is left out, so it prints as missing.
|
|
116
|
-
* page number and count are not values: they are counted page by page as the PDF prints.
|
|
121
|
+
* address, registration and VAT numbers; the document number; the issue date with its month
|
|
122
|
+
* name and year; and the due date. A value that is empty is left out, so it prints as missing.
|
|
123
|
+
* The page number and count are not values: they are counted page by page as the PDF prints.
|
|
117
124
|
*/
|
|
118
|
-
const systemValues = ({ organization, client, number, issueDate }) => {
|
|
125
|
+
const systemValues = ({ organization, client, number, issueDate, dueDate }) => {
|
|
119
126
|
const text = (value) => (typeof value === 'string' ? value.trim() : '');
|
|
120
127
|
const address = (parts) => (parts ?? []).map(text).filter(Boolean).join(', ');
|
|
121
128
|
const [year, month] = issueDate.split('-');
|
|
@@ -136,6 +143,7 @@ const systemValues = ({ organization, client, number, issueDate }) => {
|
|
|
136
143
|
[enum_1.DocumentSystemVariable.ISSUE_DATE]: issueDate,
|
|
137
144
|
[enum_1.DocumentSystemVariable.MONTH]: new Intl.DateTimeFormat('en-ZA', { month: 'long', timeZone: 'UTC' }).format(new Date(Date.UTC(Number(year), Number(month) - 1, 1))),
|
|
138
145
|
[enum_1.DocumentSystemVariable.YEAR]: year,
|
|
146
|
+
[enum_1.DocumentSystemVariable.DUE_DATE]: dueDate ?? '',
|
|
139
147
|
};
|
|
140
148
|
return Object.fromEntries(Object.entries(values).filter(([, value]) => value !== ''));
|
|
141
149
|
};
|
|
@@ -11,18 +11,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.CreateFeatureRequestDto = void 0;
|
|
13
13
|
const class_validator_1 = require("class-validator");
|
|
14
|
-
const class_transformer_1 = require("class-transformer");
|
|
15
14
|
const validators_1 = require("../validators");
|
|
16
15
|
// class-validator version of the shared DTO type from @managemint-solutions/entities, so the
|
|
17
16
|
// wire contract cannot drift.
|
|
18
|
-
/**
|
|
19
|
-
* Whitespace on either side of a pasted value is not part of the answer. Trimming here rather
|
|
20
|
-
* than in the api means the length rules below measure what will actually be stored - a name of
|
|
21
|
-
* three spaces is empty, not three characters long.
|
|
22
|
-
*/
|
|
23
|
-
const Trim = () => (0, class_transformer_1.Transform)(({ value }) => (typeof value === 'string' ? value.trim() : value), {
|
|
24
|
-
toClassOnly: true,
|
|
25
|
-
});
|
|
26
17
|
class CreateFeatureRequestDto {
|
|
27
18
|
name;
|
|
28
19
|
// Markdown, and optional: a one-line request is a perfectly good request. `@Trim` sits above
|
|
@@ -44,7 +35,7 @@ class CreateFeatureRequestDto {
|
|
|
44
35
|
}
|
|
45
36
|
exports.CreateFeatureRequestDto = CreateFeatureRequestDto;
|
|
46
37
|
__decorate([
|
|
47
|
-
Trim(),
|
|
38
|
+
(0, validators_1.Trim)(),
|
|
48
39
|
(0, class_validator_1.IsString)({ message: 'Invalid name' }),
|
|
49
40
|
(0, class_validator_1.MinLength)(1, { message: 'Name cannot be empty' }),
|
|
50
41
|
(0, class_validator_1.MaxLength)(200, { message: 'Name cannot exceed 200 characters' }),
|
|
@@ -52,7 +43,7 @@ __decorate([
|
|
|
52
43
|
], CreateFeatureRequestDto.prototype, "name", void 0);
|
|
53
44
|
__decorate([
|
|
54
45
|
(0, class_validator_1.IsOptional)(),
|
|
55
|
-
Trim(),
|
|
46
|
+
(0, validators_1.Trim)(),
|
|
56
47
|
(0, validators_1.EmptyToNull)(),
|
|
57
48
|
(0, validators_1.IsNullable)(),
|
|
58
49
|
(0, class_validator_1.ValidateIf)((o) => o.specification !== null && o.specification !== undefined),
|
|
@@ -61,14 +52,14 @@ __decorate([
|
|
|
61
52
|
__metadata("design:type", Object)
|
|
62
53
|
], CreateFeatureRequestDto.prototype, "specification", void 0);
|
|
63
54
|
__decorate([
|
|
64
|
-
Trim(),
|
|
55
|
+
(0, validators_1.Trim)(),
|
|
65
56
|
(0, class_validator_1.IsString)({ message: 'Invalid requester name' }),
|
|
66
57
|
(0, class_validator_1.MinLength)(1, { message: 'Requester name cannot be empty' }),
|
|
67
58
|
(0, class_validator_1.MaxLength)(200, { message: 'Requester name cannot exceed 200 characters' }),
|
|
68
59
|
__metadata("design:type", String)
|
|
69
60
|
], CreateFeatureRequestDto.prototype, "requester_name", void 0);
|
|
70
61
|
__decorate([
|
|
71
|
-
Trim(),
|
|
62
|
+
(0, validators_1.Trim)(),
|
|
72
63
|
(0, class_validator_1.IsEmail)({}, { message: 'Invalid email address' }),
|
|
73
64
|
(0, class_validator_1.MaxLength)(320, { message: 'Email address cannot exceed 320 characters' }),
|
|
74
65
|
__metadata("design:type", String)
|
package/dist/index.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export { ClientIdDto, CreateClientDto, GetClientsDto, StaffGetClientsDto, Update
|
|
|
43
43
|
export { ConvertLeadDto, CreateLeadDto, GetLeadsDto, LeadIdDto, StaffGetLeadsDto, UpdateLeadDto } from './leads';
|
|
44
44
|
export type { CreateDocumentRow, DocumentListRecord, DocumentSendEvent, UpdateDocumentRow } from './documents';
|
|
45
45
|
export type { CreatePaymentRow, OpenPaymentRecord, PaymentRecord, SettlePaymentRow } from './payments';
|
|
46
|
-
export { CreateDocumentDto, CreateDocumentTemplateDto, DocumentIdDto, DocumentImageNameDto, DocumentImageUrlsDto, DocumentPayQueryDto, DocumentPayTokenDto, DocumentPaymentIdDto, DocumentTemplateIdDto, documentProblem, GetDocumentsDto, GetDocumentTemplatesDto, PayDocumentDto, RecordDocumentPaymentDto, SendDocumentDto, UpdateDocumentDto, UpdateDocumentTemplateDto, VoidDocumentDto, ReassignPrivateDocumentsDto, } from './documents';
|
|
46
|
+
export { CatalogueTemplateSlugDto, CopyCatalogueTemplateDto, CreateDocumentDto, CreateDocumentTemplateDto, DocumentIdDto, DocumentImageNameDto, DocumentImageUrlsDto, DocumentPayQueryDto, DocumentPayTokenDto, DocumentPaymentIdDto, DocumentTemplateIdDto, documentProblem, GetCatalogueTemplatesDto, GetDocumentsDto, GetDocumentTemplatesDto, PayDocumentDto, RecordDocumentPaymentDto, SendDocumentDto, UpdateDocumentDto, UpdateDocumentTemplateDto, VoidDocumentDto, ReassignPrivateDocumentsDto, } from './documents';
|
|
47
47
|
export type { DocumentRecord, DocumentTemplateRecord } from './documents';
|
|
48
48
|
export type { VisibilityRecord, VisibilityShareInput } from './visibility';
|
|
49
49
|
export { UpdateVisibilityDto } from './visibility';
|
package/dist/index.js
CHANGED
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
// to keep. The row and input types they produce and accept are exported for annotations.
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.UpdateOrganizationPayoutsDto = exports.NotificationIdDto = exports.GetNotificationsDto = exports.NoteIdDto = exports.GetNotesDto = exports.AddNoteDto = exports.UpdateAdditionalDetailsDto = exports.IsAdditionalDetailsValueByType = exports.GetAdditionalDetailsDto = exports.AdditionalDetailsIdDto = exports.AddAdditionalDetailsDto = exports.UpdateLabelDto = exports.LabelIdDto = exports.GetLabelsDto = exports.AddLabelDto = exports.UpdateStatusDto = exports.StatusIdDto = exports.ReorderStatusesDto = exports.GetStatusesDto = exports.AddStatusDto = exports.CreateSupportRequestDto = exports.UpdateConfigDto = exports.CreateConfigDto = exports.CreateFeatureRequestDto = exports.InvoiceIdDto = exports.GetInvoicesQueryDto = exports.ReinstateSubscriptionDto = exports.PurchaseModuleDto = exports.PaymentIdDto = exports.InitialPaymentDto = exports.GetPaymentsQueryDto = exports.CancelSubscriptionDto = exports.withAuditBatch = exports.GetAuditTrailDto = exports.IsNullable = exports.EmptyToNull = exports.SupabaseClientError = exports.createSupabaseServiceClient = exports.SupabaseServiceClient = exports.SignInDto = exports.SendPasswordResetEmailDto = exports.ResetPasswordDto = exports.ExchangeTokenHashDto = exports.ExchangeRefreshTokenDto = exports.createSupabaseAuthClient = exports.SupabaseAuthClient = exports.createSupabaseStaffClient = exports.SupabaseStaffClient = exports.createSupabaseClient = exports.SupabaseClient = void 0;
|
|
11
|
-
exports.
|
|
12
|
-
exports.
|
|
11
|
+
exports.SendDocumentDto = exports.RecordDocumentPaymentDto = exports.PayDocumentDto = exports.GetDocumentTemplatesDto = exports.GetDocumentsDto = exports.GetCatalogueTemplatesDto = exports.documentProblem = exports.DocumentTemplateIdDto = exports.DocumentPaymentIdDto = exports.DocumentPayTokenDto = exports.DocumentPayQueryDto = exports.DocumentImageUrlsDto = exports.DocumentImageNameDto = exports.DocumentIdDto = exports.CreateDocumentTemplateDto = exports.CreateDocumentDto = exports.CopyCatalogueTemplateDto = exports.CatalogueTemplateSlugDto = exports.UpdateLeadDto = exports.StaffGetLeadsDto = exports.LeadIdDto = exports.GetLeadsDto = exports.CreateLeadDto = exports.ConvertLeadDto = exports.UpdateClientDto = exports.StaffGetClientsDto = exports.GetClientsDto = exports.CreateClientDto = exports.ClientIdDto = exports.SupportingFileNamesDto = exports.SupportingFileIdDto = exports.GetSupportingFilesDto = exports.UserIdDto = exports.UpdateUserDto = exports.UpdateMyProfileDto = exports.StaffGetUsersDto = exports.GetUsersQueryDto = exports.AddUserDto = exports.UserApiCredentialIdDto = exports.MintEmulationTokenDto = exports.CreateUserApiCredentialDto = exports.UpdateStaffPermissionsDto = exports.StaffIdDto = exports.CreateStaffDto = exports.UpdatePermissionsDto = exports.PermissionsResource = exports.UpdateOrganizationDto = exports.OrganizationIdDto = exports.GetOrganizationsDto = exports.CreateOrganizationDto = void 0;
|
|
12
|
+
exports.UpdateTimesheetEntryDto = exports.TimesheetIdDto = exports.TimesheetEntryIdDto = exports.ReviewTimesheetDto = exports.GetTimesheetsDto = exports.GetTimesheetReportDto = exports.CreateTimesheetEntryDto = exports.todayInJohannesburg = exports.shiftDays = exports.proRataDays = exports.isWithinPeriod = exports.initialUntil = exports.cyclePeriodFor = exports.countWorkingDays = exports.completedMonths = exports.addMonths = exports.GetPublicHolidaysDto = exports.UpdateLeaveTypeDto = exports.UpdateLeaveRequestDto = exports.UpdateLeaveEntitlementDto = exports.ReviewLeaveRequestDto = exports.LeaveTypeIdDto = exports.LeaveRequestIdDto = exports.LeaveEntitlementIdDto = exports.GetLeaveTypesDto = exports.GetLeaveRequestsDto = exports.GetLeaveEntitlementsDto = exports.GetLeaveCalendarDto = exports.CreateLeaveTypeDto = exports.CreateLeaveRequestDto = exports.CreateLeaveEntitlementDto = exports.CreateLeaveAdjustmentDto = exports.BulkCreateLeaveEntitlementsDto = exports.UpdateTaskDto = exports.TaskLinkIdDto = exports.TaskIdDto = exports.StaffGetTasksDto = exports.GetTasksDto = exports.CreateTaskDto = exports.AddTaskLinkDto = exports.UpdateProjectDto = exports.StaffGetProjectsDto = exports.ProjectIdDto = exports.GetProjectsDto = exports.CreateProjectDto = exports.UpdateVisibilityDto = exports.ReassignPrivateDocumentsDto = exports.VoidDocumentDto = exports.UpdateDocumentTemplateDto = exports.UpdateDocumentDto = void 0;
|
|
13
|
+
exports.monthlyTotalMinor = exports.weekStartOf = exports.minutesBetween = void 0;
|
|
13
14
|
var client_1 = require("./client");
|
|
14
15
|
Object.defineProperty(exports, "SupabaseClient", { enumerable: true, get: function () { return client_1.SupabaseClient; } });
|
|
15
16
|
Object.defineProperty(exports, "createSupabaseClient", { enumerable: true, get: function () { return client_1.createSupabaseClient; } });
|
|
@@ -123,6 +124,8 @@ Object.defineProperty(exports, "LeadIdDto", { enumerable: true, get: function ()
|
|
|
123
124
|
Object.defineProperty(exports, "StaffGetLeadsDto", { enumerable: true, get: function () { return leads_1.StaffGetLeadsDto; } });
|
|
124
125
|
Object.defineProperty(exports, "UpdateLeadDto", { enumerable: true, get: function () { return leads_1.UpdateLeadDto; } });
|
|
125
126
|
var documents_1 = require("./documents");
|
|
127
|
+
Object.defineProperty(exports, "CatalogueTemplateSlugDto", { enumerable: true, get: function () { return documents_1.CatalogueTemplateSlugDto; } });
|
|
128
|
+
Object.defineProperty(exports, "CopyCatalogueTemplateDto", { enumerable: true, get: function () { return documents_1.CopyCatalogueTemplateDto; } });
|
|
126
129
|
Object.defineProperty(exports, "CreateDocumentDto", { enumerable: true, get: function () { return documents_1.CreateDocumentDto; } });
|
|
127
130
|
Object.defineProperty(exports, "CreateDocumentTemplateDto", { enumerable: true, get: function () { return documents_1.CreateDocumentTemplateDto; } });
|
|
128
131
|
Object.defineProperty(exports, "DocumentIdDto", { enumerable: true, get: function () { return documents_1.DocumentIdDto; } });
|
|
@@ -133,6 +136,7 @@ Object.defineProperty(exports, "DocumentPayTokenDto", { enumerable: true, get: f
|
|
|
133
136
|
Object.defineProperty(exports, "DocumentPaymentIdDto", { enumerable: true, get: function () { return documents_1.DocumentPaymentIdDto; } });
|
|
134
137
|
Object.defineProperty(exports, "DocumentTemplateIdDto", { enumerable: true, get: function () { return documents_1.DocumentTemplateIdDto; } });
|
|
135
138
|
Object.defineProperty(exports, "documentProblem", { enumerable: true, get: function () { return documents_1.documentProblem; } });
|
|
139
|
+
Object.defineProperty(exports, "GetCatalogueTemplatesDto", { enumerable: true, get: function () { return documents_1.GetCatalogueTemplatesDto; } });
|
|
136
140
|
Object.defineProperty(exports, "GetDocumentsDto", { enumerable: true, get: function () { return documents_1.GetDocumentsDto; } });
|
|
137
141
|
Object.defineProperty(exports, "GetDocumentTemplatesDto", { enumerable: true, get: function () { return documents_1.GetDocumentTemplatesDto; } });
|
|
138
142
|
Object.defineProperty(exports, "PayDocumentDto", { enumerable: true, get: function () { return documents_1.PayDocumentDto; } });
|
|
@@ -64,6 +64,18 @@ export declare class SupabaseOrganizationScope {
|
|
|
64
64
|
* subscriptions and both webhook handler services.
|
|
65
65
|
*/
|
|
66
66
|
table(options: AuditedTableOptions): AuditedTable;
|
|
67
|
+
/**
|
|
68
|
+
* The organization's templates whose `column` starts with `start` (literally, any case),
|
|
69
|
+
* private and archived ones included. Service role because both columns are unique across the
|
|
70
|
+
* whole organization (`uq_document_templates_organization_name`,
|
|
71
|
+
* `uq_document_templates_organization_prefix`) while a caller reads only the templates shared
|
|
72
|
+
* with them.
|
|
73
|
+
*/
|
|
74
|
+
templatesStartingWith(column: 'name' | 'number_prefix', start: string): Promise<{
|
|
75
|
+
mms_id: string;
|
|
76
|
+
name: string;
|
|
77
|
+
number_prefix: string;
|
|
78
|
+
}[]>;
|
|
67
79
|
/**
|
|
68
80
|
* Gives `userId` a new leave calendar feed token (stored as its SHA-256), which also retires
|
|
69
81
|
* any address they subscribed with before. Service role only: the token is a credential.
|
|
@@ -84,6 +84,23 @@ class SupabaseOrganizationScope {
|
|
|
84
84
|
table(options) {
|
|
85
85
|
return (0, audit_1.auditedTable)(this.supabase, this.actor, this.audit, options);
|
|
86
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* The organization's templates whose `column` starts with `start` (literally, any case),
|
|
89
|
+
* private and archived ones included. Service role because both columns are unique across the
|
|
90
|
+
* whole organization (`uq_document_templates_organization_name`,
|
|
91
|
+
* `uq_document_templates_organization_prefix`) while a caller reads only the templates shared
|
|
92
|
+
* with them.
|
|
93
|
+
*/
|
|
94
|
+
async templatesStartingWith(column, start) {
|
|
95
|
+
const { data, error } = await this.supabase
|
|
96
|
+
.from('document_templates')
|
|
97
|
+
.select('mms_id, name, number_prefix')
|
|
98
|
+
.eq('organization_id', this.actor.organization_id)
|
|
99
|
+
.ilike(column, `${start.replace(/[\\%_]/g, '\\$&')}%`);
|
|
100
|
+
if (error)
|
|
101
|
+
throw (0, errors_1.mapPostgrestError)(error);
|
|
102
|
+
return (data ?? []);
|
|
103
|
+
}
|
|
87
104
|
/**
|
|
88
105
|
* Gives `userId` a new leave calendar feed token (stored as its SHA-256), which also retires
|
|
89
106
|
* any address they subscribed with before. Service role only: the token is a credential.
|
package/dist/validators.d.ts
CHANGED
|
@@ -26,6 +26,12 @@ export declare function IsNullable(validationOptions?: ValidationOptions): Prope
|
|
|
26
26
|
* blank submission tripping it. Goes above `IsNullable()`, which then skips the rules.
|
|
27
27
|
*/
|
|
28
28
|
export declare function EmptyToNull(): PropertyDecorator;
|
|
29
|
+
/**
|
|
30
|
+
* Whitespace on either side of a pasted value is not part of the answer. Trimming here rather
|
|
31
|
+
* than in the api means the rules measure what will actually be stored - a name of three spaces
|
|
32
|
+
* is empty, not three characters long. Goes above `EmptyToNull()`, so a blank box becomes null.
|
|
33
|
+
*/
|
|
34
|
+
export declare function Trim(): PropertyDecorator;
|
|
29
35
|
/**
|
|
30
36
|
* A class-validator decorator from a check that returns the first problem it finds, or null. The
|
|
31
37
|
* problem is the message, so a 400 always says exactly what is wrong and where. `object` is the
|
package/dist/validators.js
CHANGED
|
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.fromProblem = exports.MatchesPasswordRules = exports.IsClockTime = exports.isClockTime = exports.IsCalendarDate = exports.isCalendarDate = void 0;
|
|
10
10
|
exports.IsNullable = IsNullable;
|
|
11
11
|
exports.EmptyToNull = EmptyToNull;
|
|
12
|
+
exports.Trim = Trim;
|
|
12
13
|
const class_validator_1 = require("class-validator");
|
|
13
14
|
const class_transformer_1 = require("class-transformer");
|
|
14
15
|
const CALENDAR_DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
@@ -72,6 +73,14 @@ function IsNullable(validationOptions) {
|
|
|
72
73
|
function EmptyToNull() {
|
|
73
74
|
return (0, class_transformer_1.Transform)(({ value }) => (value === '' ? null : value), { toClassOnly: true });
|
|
74
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Whitespace on either side of a pasted value is not part of the answer. Trimming here rather
|
|
78
|
+
* than in the api means the rules measure what will actually be stored - a name of three spaces
|
|
79
|
+
* is empty, not three characters long. Goes above `EmptyToNull()`, so a blank box becomes null.
|
|
80
|
+
*/
|
|
81
|
+
function Trim() {
|
|
82
|
+
return (0, class_transformer_1.Transform)(({ value }) => (typeof value === 'string' ? value.trim() : value), { toClassOnly: true });
|
|
83
|
+
}
|
|
75
84
|
/**
|
|
76
85
|
* A class-validator decorator from a check that returns the first problem it finds, or null. The
|
|
77
86
|
* problem is the message, so a 400 always says exactly what is wrong and where. `object` is the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@managemint-solutions/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.66.0",
|
|
4
4
|
"description": "Typed Supabase data-access SDK for ManageMint Solutions",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Scott Bebington <scottbebington@gmail.com>",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"testEnvironment": "node"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@managemint-solutions/entities": "^1.
|
|
58
|
+
"@managemint-solutions/entities": "^1.48.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@nestjs/common": "^11.0.0",
|