@managemint-solutions/sdk 0.67.0 → 0.68.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.
@@ -28,6 +28,14 @@ export declare class CancelSubscriptionDto {
28
28
  export declare class ReinstateSubscriptionDto {
29
29
  readonly idempotency_key: string;
30
30
  }
31
+ /** POST /billing/modules/quote: the module set the organization wants, by pricebook module id. */
32
+ export declare class ModuleSetDto {
33
+ readonly module_ids: string[];
34
+ }
35
+ /** PUT /billing/modules: the set, and the key a retry replays the same change under. */
36
+ export declare class ChangeModulesDto extends ModuleSetDto {
37
+ readonly idempotency_key: string;
38
+ }
31
39
  /**
32
40
  * A purchase names the module by *id*, which is checked against the active
33
41
  * pricebook - never a module key from a hardcoded enum
@@ -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.GetPaymentsQueryDto = exports.PaymentIdDto = exports.PurchaseModuleDto = exports.ReinstateSubscriptionDto = exports.CancelSubscriptionDto = exports.InitialPaymentDto = void 0;
12
+ exports.GetPaymentsQueryDto = exports.PaymentIdDto = exports.PurchaseModuleDto = exports.ChangeModulesDto = exports.ModuleSetDto = exports.ReinstateSubscriptionDto = exports.CancelSubscriptionDto = exports.InitialPaymentDto = 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/billing/enum");
@@ -57,6 +57,27 @@ __decorate([
57
57
  (0, class_validator_1.IsUUID)('4', { message: 'An idempotency key is required and must be a v4 uuid' }),
58
58
  __metadata("design:type", String)
59
59
  ], ReinstateSubscriptionDto.prototype, "idempotency_key", void 0);
60
+ /** POST /billing/modules/quote: the module set the organization wants, by pricebook module id. */
61
+ class ModuleSetDto {
62
+ module_ids;
63
+ }
64
+ exports.ModuleSetDto = ModuleSetDto;
65
+ __decorate([
66
+ (0, class_validator_1.IsArray)({ message: 'module_ids must be a list' }),
67
+ (0, class_validator_1.ArrayMinSize)(1, { message: 'Pick at least one module' }),
68
+ (0, class_validator_1.ArrayMaxSize)(20, { message: 'Too many modules' }),
69
+ (0, class_validator_1.IsUUID)('7', { each: true, message: 'Invalid module ID format' }),
70
+ __metadata("design:type", Array)
71
+ ], ModuleSetDto.prototype, "module_ids", void 0);
72
+ /** PUT /billing/modules: the set, and the key a retry replays the same change under. */
73
+ class ChangeModulesDto extends ModuleSetDto {
74
+ idempotency_key;
75
+ }
76
+ exports.ChangeModulesDto = ChangeModulesDto;
77
+ __decorate([
78
+ (0, class_validator_1.IsUUID)('4', { message: 'An idempotency key is required and must be a v4 uuid' }),
79
+ __metadata("design:type", String)
80
+ ], ChangeModulesDto.prototype, "idempotency_key", void 0);
60
81
  /**
61
82
  * A purchase names the module by *id*, which is checked against the active
62
83
  * pricebook - never a module key from a hardcoded enum
package/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@ export type { SupabaseClientErrorInit } from './errors';
12
12
  export { EmptyToNull, IsNullable } from './validators';
13
13
  export type { AuditActor, AuditChanges, AuditDeleteGuard, AuditEntry, AuditErrorHandler, AuditGuard, AuditNameTable, AuditRow, AuditedTable, AuditedTableOptions, EntityAuditTrail, OrganizationTableFactory, } from './audit';
14
14
  export { GetAuditTrailDto, withAuditBatch } from './audit';
15
- export { CancelSubscriptionDto, GetPaymentsQueryDto, InitialPaymentDto, PaymentIdDto, PurchaseModuleDto, ReinstateSubscriptionDto, } from './billing';
15
+ export { CancelSubscriptionDto, GetPaymentsQueryDto, InitialPaymentDto, PaymentIdDto, ChangeModulesDto, ModuleSetDto, PurchaseModuleDto, ReinstateSubscriptionDto, } from './billing';
16
16
  export { GetInvoicesQueryDto, InvoiceIdDto } from './billing/invoices';
17
17
  export type { CreateFeatureRequestRow, CreatedFeatureRequest } from './feature-requests';
18
18
  export { CreateFeatureRequestDto } from './feature-requests';
package/dist/index.js CHANGED
@@ -7,10 +7,10 @@
7
7
  // their classes are not exported: a consumer never constructs one, and every export is a contract
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
- 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.InventoryLocationIdDto = exports.InventoryLevelKeyDto = exports.InventoryItemIdDto = exports.ImportInventoryItemsDto = exports.ImportInventoryItemDto = exports.GetInventoryTransfersDto = exports.GetInventoryStocktakesDto = exports.GetInventoryMovementsDto = exports.GetInventoryLocationsDto = exports.GetInventoryItemsDto = exports.GeocodeAddressDto = exports.CreateInventoryTransferLineDto = exports.CreateInventoryTransferDto = exports.CreateInventoryMovementDto = exports.CreateInventoryLocationDto = exports.CreateInventoryItemDto = exports.CountInventoryLineDto = exports.CountInventoryDto = 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.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.ConvertDocumentDto = exports.VoidDocumentDto = exports.UpdateDocumentTemplateDto = exports.UpdateDocumentDto = 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.UpdateInventoryTransferDto = exports.UpdateInventoryLocationDto = exports.UpdateInventoryLevelDto = exports.UpdateInventoryItemDto = exports.SuggestAddressesDto = exports.StaffGetInventoryItemsDto = exports.ReceiveInventoryTransferDto = exports.InventoryTransferIdDto = exports.InventoryStocktakeIdDto = void 0;
13
- 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 = void 0;
10
+ 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.ModuleSetDto = exports.ChangeModulesDto = 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.InventoryItemIdDto = exports.ImportInventoryItemsDto = exports.ImportInventoryItemDto = exports.GetInventoryTransfersDto = exports.GetInventoryStocktakesDto = exports.GetInventoryMovementsDto = exports.GetInventoryLocationsDto = exports.GetInventoryItemsDto = exports.GeocodeAddressDto = exports.CreateInventoryTransferLineDto = exports.CreateInventoryTransferDto = exports.CreateInventoryMovementDto = exports.CreateInventoryLocationDto = exports.CreateInventoryItemDto = exports.CountInventoryLineDto = exports.CountInventoryDto = 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 = exports.UpdateOrganizationPayoutsDto = exports.NotificationIdDto = void 0;
12
+ 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.ConvertDocumentDto = exports.VoidDocumentDto = exports.UpdateDocumentTemplateDto = exports.UpdateDocumentDto = 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.UpdateInventoryTransferDto = exports.UpdateInventoryLocationDto = exports.UpdateInventoryLevelDto = exports.UpdateInventoryItemDto = exports.SuggestAddressesDto = exports.StaffGetInventoryItemsDto = exports.ReceiveInventoryTransferDto = exports.InventoryTransferIdDto = exports.InventoryStocktakeIdDto = exports.InventoryLocationIdDto = exports.InventoryLevelKeyDto = void 0;
13
+ 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 = void 0;
14
14
  var client_1 = require("./client");
15
15
  Object.defineProperty(exports, "SupabaseClient", { enumerable: true, get: function () { return client_1.SupabaseClient; } });
16
16
  Object.defineProperty(exports, "createSupabaseClient", { enumerable: true, get: function () { return client_1.createSupabaseClient; } });
@@ -42,6 +42,8 @@ Object.defineProperty(exports, "CancelSubscriptionDto", { enumerable: true, get:
42
42
  Object.defineProperty(exports, "GetPaymentsQueryDto", { enumerable: true, get: function () { return billing_1.GetPaymentsQueryDto; } });
43
43
  Object.defineProperty(exports, "InitialPaymentDto", { enumerable: true, get: function () { return billing_1.InitialPaymentDto; } });
44
44
  Object.defineProperty(exports, "PaymentIdDto", { enumerable: true, get: function () { return billing_1.PaymentIdDto; } });
45
+ Object.defineProperty(exports, "ChangeModulesDto", { enumerable: true, get: function () { return billing_1.ChangeModulesDto; } });
46
+ Object.defineProperty(exports, "ModuleSetDto", { enumerable: true, get: function () { return billing_1.ModuleSetDto; } });
45
47
  Object.defineProperty(exports, "PurchaseModuleDto", { enumerable: true, get: function () { return billing_1.PurchaseModuleDto; } });
46
48
  Object.defineProperty(exports, "ReinstateSubscriptionDto", { enumerable: true, get: function () { return billing_1.ReinstateSubscriptionDto; } });
47
49
  var invoices_1 = require("./billing/invoices");
@@ -36,6 +36,7 @@ const SUBSCRIPTION_COLUMNS = [
36
36
  'active_seat_count',
37
37
  'paid_seat_count',
38
38
  'modules',
39
+ 'modules_after_cycle',
39
40
  'pricebook_id',
40
41
  'card_brand',
41
42
  'card_description',
@@ -160,6 +160,12 @@ export declare class SupabaseServiceClient {
160
160
  * payment method itself.
161
161
  */
162
162
  findOrganizationByPaymentMethod(column: PaymentMethodLookupColumn, value: string): Promise<Record<string, unknown> | null>;
163
+ /** Every organization with a module removal waiting for the anchor day: its id and both sets. */
164
+ organizationsWithPendingModules(): Promise<Array<{
165
+ mms_id: string;
166
+ modules: string[];
167
+ modules_after_cycle: string[];
168
+ }>>;
163
169
  /**
164
170
  * Every organization that has reached Paystack - the set the monthly invoice reconcile walks.
165
171
  * Unscoped by nature: the cron has no tenant until it picks one.
@@ -267,6 +267,16 @@ class SupabaseServiceClient {
267
267
  ?.organization;
268
268
  return organization ? (0, audit_1.withoutInternalId)(organization) : null;
269
269
  }
270
+ /** Every organization with a module removal waiting for the anchor day: its id and both sets. */
271
+ async organizationsWithPendingModules() {
272
+ const { data, error } = await this.supabase
273
+ .from('organizations')
274
+ .select('mms_id, modules, modules_after_cycle')
275
+ .not('modules_after_cycle', 'is', null);
276
+ if (error)
277
+ throw (0, errors_1.mapPostgrestError)(error);
278
+ return (data ?? []);
279
+ }
270
280
  /**
271
281
  * Every organization that has reached Paystack - the set the monthly invoice reconcile walks.
272
282
  * Unscoped by nature: the cron has no tenant until it picks one.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managemint-solutions/sdk",
3
- "version": "0.67.0",
3
+ "version": "0.68.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.49.0"
58
+ "@managemint-solutions/entities": "^1.50.0"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "@nestjs/common": "^11.0.0",