@managemint-solutions/sdk 0.64.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.
@@ -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 class_transformer_1 = require("class-transformer");
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)
@@ -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;
@@ -122,4 +122,17 @@ export declare class DocumentPaymentIdDto implements DocumentPaymentIdDtoType {
122
122
  readonly documentId: string;
123
123
  readonly paymentId: string;
124
124
  }
125
+ export declare class GetCatalogueTemplatesDto implements GetCatalogueTemplatesDtoType {
126
+ readonly search?: string | null;
127
+ readonly category?: string | null;
128
+ }
129
+ export declare class CatalogueTemplateSlugDto implements CatalogueTemplateSlugDtoType {
130
+ readonly slug: string;
131
+ }
132
+ /** The copy's own name and prefix are optional and held to a template save's rules when given. */
133
+ export declare class CopyCatalogueTemplateDto implements CopyCatalogueTemplateDtoType {
134
+ readonly slug: string;
135
+ readonly name?: string;
136
+ readonly number_prefix?: string;
137
+ }
125
138
  export {};
@@ -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");
@@ -89,6 +89,7 @@ class UpdateDocumentTemplateDto {
89
89
  }
90
90
  exports.UpdateDocumentTemplateDto = UpdateDocumentTemplateDto;
91
91
  __decorate([
92
+ (0, validators_1.Trim)(),
92
93
  (0, class_validator_1.MaxLength)(100, { message: 'Name cannot exceed 100 characters' }),
93
94
  (0, class_validator_1.MinLength)(1, { message: 'Name cannot be empty' }),
94
95
  (0, class_validator_1.IsString)({ message: 'Name must be text' }),
@@ -101,6 +102,7 @@ __decorate([
101
102
  ], UpdateDocumentTemplateDto.prototype, "category", void 0);
102
103
  __decorate([
103
104
  (0, class_validator_1.IsOptional)(),
105
+ (0, validators_1.Trim)(),
104
106
  (0, content_1.IsDocumentNumberPrefix)(),
105
107
  __metadata("design:type", String)
106
108
  ], UpdateDocumentTemplateDto.prototype, "number_prefix", void 0);
@@ -350,6 +352,7 @@ __decorate([
350
352
  __metadata("design:type", String)
351
353
  ], UpdateDocumentDto.prototype, "category", void 0);
352
354
  __decorate([
355
+ (0, validators_1.Trim)(),
353
356
  (0, content_1.IsDocumentNumberPrefix)(),
354
357
  __metadata("design:type", String)
355
358
  ], UpdateDocumentDto.prototype, "number_prefix", void 0);
@@ -528,3 +531,64 @@ __decorate([
528
531
  (0, class_validator_1.IsUUID)('7', { message: 'Invalid payment ID format' }),
529
532
  __metadata("design:type", String)
530
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);
@@ -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
- let html = '';
60
- let last = 0;
61
- for (const match of text.matchAll(values_1.DOCUMENT_VARIABLE_PATTERN)) {
62
- html += (0, values_1.escapeHtml)(text.slice(last, match.index)) + valueHtml(match[1], ctx);
63
- last = match.index + match[0].length;
64
- }
65
- return (html + (0, values_1.escapeHtml)(text.slice(last))).replace(/\r?\n/g, '<br>');
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 nothing on either side, and the block with no rows left.
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 label.trim() || value.trim() ? [`<tr><th>${label}</th><td>${value}</td></tr>`] : [];
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
  }
@@ -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.VoidDocumentDto = exports.UpdateDocumentTemplateDto = exports.UpdateDocumentDto = exports.SendDocumentDto = exports.RecordDocumentPaymentDto = exports.PayDocumentDto = exports.GetDocumentTemplatesDto = exports.GetDocumentsDto = exports.documentProblem = exports.DocumentTemplateIdDto = exports.DocumentPaymentIdDto = exports.DocumentPayTokenDto = exports.DocumentPayQueryDto = exports.DocumentImageUrlsDto = exports.DocumentImageNameDto = exports.DocumentIdDto = exports.CreateDocumentTemplateDto = exports.CreateDocumentDto = 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.monthlyTotalMinor = exports.weekStartOf = exports.minutesBetween = 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 = void 0;
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.
@@ -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
@@ -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.64.0",
3
+ "version": "0.65.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.46.0"
58
+ "@managemint-solutions/entities": "^1.47.0"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "@nestjs/common": "^11.0.0",