@managemint-solutions/sdk 0.66.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.
Files changed (46) hide show
  1. package/dist/audit/index.d.ts +1 -1
  2. package/dist/audit/index.js +14 -0
  3. package/dist/billing/dto.d.ts +8 -0
  4. package/dist/billing/dto.js +22 -1
  5. package/dist/client.d.ts +7 -0
  6. package/dist/client.js +14 -0
  7. package/dist/documents/content.js +6 -1
  8. package/dist/documents/document-templates.js +12 -5
  9. package/dist/documents/documents.d.ts +7 -2
  10. package/dist/documents/documents.js +4 -0
  11. package/dist/documents/dto.d.ts +7 -2
  12. package/dist/documents/dto.js +21 -1
  13. package/dist/documents/render/html.d.ts +5 -0
  14. package/dist/documents/render/html.js +10 -3
  15. package/dist/documents/render/index.d.ts +1 -1
  16. package/dist/documents/render/index.js +2 -1
  17. package/dist/documents/render/values.d.ts +4 -1
  18. package/dist/documents/render/values.js +4 -2
  19. package/dist/index.d.ts +4 -2
  20. package/dist/index.js +35 -4
  21. package/dist/inventory/dto.d.ts +134 -0
  22. package/dist/inventory/dto.js +684 -0
  23. package/dist/inventory/index.d.ts +7 -0
  24. package/dist/inventory/index.js +30 -0
  25. package/dist/inventory/items.d.ts +65 -0
  26. package/dist/inventory/items.js +216 -0
  27. package/dist/inventory/levels.d.ts +52 -0
  28. package/dist/inventory/levels.js +157 -0
  29. package/dist/inventory/locations.d.ts +29 -0
  30. package/dist/inventory/locations.js +158 -0
  31. package/dist/inventory/movements.d.ts +36 -0
  32. package/dist/inventory/movements.js +103 -0
  33. package/dist/inventory/stocktakes.d.ts +36 -0
  34. package/dist/inventory/stocktakes.js +70 -0
  35. package/dist/inventory/transfers.d.ts +73 -0
  36. package/dist/inventory/transfers.js +134 -0
  37. package/dist/organizations/dto.d.ts +3 -1
  38. package/dist/organizations/dto.js +12 -0
  39. package/dist/organizations/index.js +3 -0
  40. package/dist/permissions/dto.d.ts +4 -0
  41. package/dist/permissions/dto.js +20 -0
  42. package/dist/service-client/index.d.ts +12 -0
  43. package/dist/service-client/index.js +20 -0
  44. package/dist/users/paths.d.ts +5 -6
  45. package/dist/users/paths.js +12 -12
  46. package/package.json +2 -2
@@ -36,6 +36,10 @@ export declare class UpdatePermissionsDto implements UpdatePermissionsDtoType {
36
36
  readonly read_leave_requests: boolean;
37
37
  readonly update_leave_requests: boolean;
38
38
  readonly delete_leave_requests: boolean;
39
+ readonly create_inventory: boolean;
40
+ readonly read_inventory: boolean;
41
+ readonly update_inventory: boolean;
42
+ readonly delete_inventory: boolean;
39
43
  readonly read_invoices: boolean;
40
44
  readonly create_users: boolean;
41
45
  readonly read_users: boolean;
@@ -58,6 +58,10 @@ class UpdatePermissionsDto {
58
58
  read_leave_requests;
59
59
  update_leave_requests;
60
60
  delete_leave_requests;
61
+ create_inventory;
62
+ read_inventory;
63
+ update_inventory;
64
+ delete_inventory;
61
65
  // @IsBoolean({ message: 'Create Invoices must be a boolean' })
62
66
  // readonly create_invoices!: boolean;
63
67
  read_invoices;
@@ -252,6 +256,22 @@ __decorate([
252
256
  (0, class_validator_1.IsBoolean)({ message: 'Delete Leave Requests must be a boolean' }),
253
257
  __metadata("design:type", Boolean)
254
258
  ], UpdatePermissionsDto.prototype, "delete_leave_requests", void 0);
259
+ __decorate([
260
+ (0, class_validator_1.IsBoolean)({ message: 'Create Inventory must be a boolean' }),
261
+ __metadata("design:type", Boolean)
262
+ ], UpdatePermissionsDto.prototype, "create_inventory", void 0);
263
+ __decorate([
264
+ (0, class_validator_1.IsBoolean)({ message: 'Read Inventory must be a boolean' }),
265
+ __metadata("design:type", Boolean)
266
+ ], UpdatePermissionsDto.prototype, "read_inventory", void 0);
267
+ __decorate([
268
+ (0, class_validator_1.IsBoolean)({ message: 'Update Inventory must be a boolean' }),
269
+ __metadata("design:type", Boolean)
270
+ ], UpdatePermissionsDto.prototype, "update_inventory", void 0);
271
+ __decorate([
272
+ (0, class_validator_1.IsBoolean)({ message: 'Delete Inventory must be a boolean' }),
273
+ __metadata("design:type", Boolean)
274
+ ], UpdatePermissionsDto.prototype, "delete_inventory", void 0);
255
275
  __decorate([
256
276
  (0, class_validator_1.IsBoolean)({ message: 'Read Invoices must be a boolean' }),
257
277
  __metadata("design:type", Boolean)
@@ -13,6 +13,7 @@ import { OrganizationInvitesResource } from '../organization-invites';
13
13
  import { OrganizationPaymentMethodsResource, type PaymentMethodLookupColumn } from '../organization-payment-methods';
14
14
  import { OrganizationsResource, OrganizationSignupResource } from '../organizations';
15
15
  import { PaymentsResource } from '../payments';
16
+ import { InventoryItemsResource, InventoryLevelsResource, InventoryLocationsResource, InventoryMovementsResource } from '../inventory';
16
17
  import { PermissionsResource } from '../permissions';
17
18
  import { StaffPermissionsResource, StaffResource } from '../staff';
18
19
  import { SupportingFilesResource } from '../supporting-files';
@@ -46,6 +47,11 @@ export declare class SupabaseOrganizationScope {
46
47
  readonly payments: PaymentsResource;
47
48
  readonly invoices: InvoicesResource;
48
49
  readonly invites: OrganizationInvitesResource;
50
+ /** For stock that moves with a document paid through Paystack or issued by the cron. */
51
+ readonly inventoryItems: InventoryItemsResource;
52
+ readonly inventoryLocations: InventoryLocationsResource;
53
+ readonly inventoryLevels: InventoryLevelsResource;
54
+ readonly inventoryMovements: InventoryMovementsResource;
49
55
  readonly leaveTypes: LeaveTypesResource;
50
56
  readonly leaveEntitlements: LeaveEntitlementsResource;
51
57
  readonly leaveRequests: LeaveRequestsResource;
@@ -154,6 +160,12 @@ export declare class SupabaseServiceClient {
154
160
  * payment method itself.
155
161
  */
156
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
+ }>>;
157
169
  /**
158
170
  * Every organization that has reached Paystack - the set the monthly invoice reconcile walks.
159
171
  * Unscoped by nature: the cron has no tenant until it picks one.
@@ -19,6 +19,7 @@ const organization_invites_1 = require("../organization-invites");
19
19
  const organization_payment_methods_1 = require("../organization-payment-methods");
20
20
  const organizations_1 = require("../organizations");
21
21
  const payments_1 = require("../payments");
22
+ const inventory_1 = require("../inventory");
22
23
  const permissions_1 = require("../permissions");
23
24
  const staff_1 = require("../staff");
24
25
  const supporting_files_1 = require("../supporting-files");
@@ -45,6 +46,11 @@ class SupabaseOrganizationScope {
45
46
  payments;
46
47
  invoices;
47
48
  invites;
49
+ /** For stock that moves with a document paid through Paystack or issued by the cron. */
50
+ inventoryItems;
51
+ inventoryLocations;
52
+ inventoryLevels;
53
+ inventoryMovements;
48
54
  leaveTypes;
49
55
  leaveEntitlements;
50
56
  leaveRequests;
@@ -65,6 +71,10 @@ class SupabaseOrganizationScope {
65
71
  this.payments = new payments_1.PaymentsResource(supabase, actor, this.audit);
66
72
  this.invoices = new invoices_1.InvoicesResource(supabase, actor, this.audit);
67
73
  this.invites = new organization_invites_1.OrganizationInvitesResource(supabase, actor);
74
+ this.inventoryItems = new inventory_1.InventoryItemsResource(supabase, actor, this.audit);
75
+ this.inventoryLocations = new inventory_1.InventoryLocationsResource(supabase, actor, this.audit);
76
+ this.inventoryLevels = new inventory_1.InventoryLevelsResource(supabase, actor, this.audit);
77
+ this.inventoryMovements = new inventory_1.InventoryMovementsResource(supabase, actor, this.audit);
68
78
  // The leave-year rollover writes next period's entitlements as the system (`mms_id: null`).
69
79
  this.leaveTypes = new leave_1.LeaveTypesResource(supabase, actor, this.audit);
70
80
  this.leaveEntitlements = new leave_1.LeaveEntitlementsResource(supabase, actor, this.audit);
@@ -257,6 +267,16 @@ class SupabaseServiceClient {
257
267
  ?.organization;
258
268
  return organization ? (0, audit_1.withoutInternalId)(organization) : null;
259
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
+ }
260
280
  /**
261
281
  * Every organization that has reached Paystack - the set the monthly invoice reconcile walks.
262
282
  * Unscoped by nature: the cron has no tenant until it picks one.
@@ -14,11 +14,10 @@ export declare const PROFILE_PICTURES_BUCKET = "profile-pictures";
14
14
  */
15
15
  export declare const profileImagePath: (organizationId: string, userId: string, name: string, extension: string) => string;
16
16
  /**
17
- * The object key behind a stored `users.profile_image` URL, so the previous avatar can be
18
- * removed when a new one replaces it.
19
- *
20
- * Returns null for anything that is not one of our own public URLs - the column also holds
21
- * whatever `raw_user_meta_data` carried at signup (a Google or Gravatar URL), and those are
22
- * not ours to delete.
17
+ * The object key behind one of our own public-bucket URLs, so the previous object can be
18
+ * removed when a new one replaces it. Null for anything else (a Google or Gravatar URL from
19
+ * signup is not ours to delete).
23
20
  */
21
+ export declare const publicObjectPath: (bucket: string, url: unknown) => string | null;
22
+ /** The object key behind a stored `users.profile_image` URL. */
24
23
  export declare const profileImageObjectPath: (profileImage: unknown) => string | null;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.profileImageObjectPath = exports.profileImagePath = exports.PROFILE_PICTURES_BUCKET = void 0;
3
+ exports.profileImageObjectPath = exports.publicObjectPath = exports.profileImagePath = exports.PROFILE_PICTURES_BUCKET = void 0;
4
4
  /** Storage bucket every profile picture lives in. Public-read; writes are policy-scoped. */
5
5
  exports.PROFILE_PICTURES_BUCKET = 'profile-pictures';
6
6
  /**
@@ -18,21 +18,21 @@ exports.PROFILE_PICTURES_BUCKET = 'profile-pictures';
18
18
  const profileImagePath = (organizationId, userId, name, extension) => `${organizationId}/${userId}/${Date.now()}-${name}${extension ? `.${extension}` : ''}`;
19
19
  exports.profileImagePath = profileImagePath;
20
20
  /**
21
- * The object key behind a stored `users.profile_image` URL, so the previous avatar can be
22
- * removed when a new one replaces it.
23
- *
24
- * Returns null for anything that is not one of our own public URLs - the column also holds
25
- * whatever `raw_user_meta_data` carried at signup (a Google or Gravatar URL), and those are
26
- * not ours to delete.
21
+ * The object key behind one of our own public-bucket URLs, so the previous object can be
22
+ * removed when a new one replaces it. Null for anything else (a Google or Gravatar URL from
23
+ * signup is not ours to delete).
27
24
  */
28
- const profileImageObjectPath = (profileImage) => {
29
- if (typeof profileImage !== 'string')
25
+ const publicObjectPath = (bucket, url) => {
26
+ if (typeof url !== 'string')
30
27
  return null;
31
- const marker = `/storage/v1/object/public/${exports.PROFILE_PICTURES_BUCKET}/`;
32
- const index = profileImage.indexOf(marker);
28
+ const marker = `/storage/v1/object/public/${bucket}/`;
29
+ const index = url.indexOf(marker);
33
30
  if (index === -1)
34
31
  return null;
35
- const path = profileImage.slice(index + marker.length).split('?')[0];
32
+ const path = url.slice(index + marker.length).split('?')[0];
36
33
  return path ? decodeURIComponent(path) : null;
37
34
  };
35
+ exports.publicObjectPath = publicObjectPath;
36
+ /** The object key behind a stored `users.profile_image` URL. */
37
+ const profileImageObjectPath = (profileImage) => (0, exports.publicObjectPath)(exports.PROFILE_PICTURES_BUCKET, profileImage);
38
38
  exports.profileImageObjectPath = profileImageObjectPath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managemint-solutions/sdk",
3
- "version": "0.66.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.48.0"
58
+ "@managemint-solutions/entities": "^1.50.0"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "@nestjs/common": "^11.0.0",