@managemint-solutions/sdk 0.9.0 → 0.16.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/audit/index.d.ts +15 -0
- package/dist/audit/index.js +37 -14
- package/dist/audit/index.js.map +1 -1
- package/dist/billing/dto.d.ts +33 -0
- package/dist/billing/dto.js +71 -0
- package/dist/billing/dto.js.map +1 -0
- package/dist/billing/index.d.ts +35 -0
- package/dist/billing/index.js +115 -0
- package/dist/billing/index.js.map +1 -0
- package/dist/client.d.ts +8 -0
- package/dist/client.js +12 -0
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/nest/index.d.ts +11 -0
- package/dist/nest/index.js +17 -1
- package/dist/nest/index.js.map +1 -1
- package/dist/notifications/dto.d.ts +10 -0
- package/dist/notifications/dto.js +63 -0
- package/dist/notifications/dto.js.map +1 -0
- package/dist/notifications/index.d.ts +139 -0
- package/dist/notifications/index.js +354 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/organizations/dto.d.ts +62 -0
- package/dist/organizations/dto.js +445 -0
- package/dist/organizations/dto.js.map +1 -0
- package/dist/organizations/index.d.ts +72 -0
- package/dist/organizations/index.js +221 -0
- package/dist/organizations/index.js.map +1 -0
- package/dist/permissions/dto.d.ts +27 -0
- package/dist/permissions/dto.js +215 -0
- package/dist/permissions/dto.js.map +1 -0
- package/dist/permissions/index.d.ts +36 -0
- package/dist/permissions/index.js +110 -0
- package/dist/permissions/index.js.map +1 -0
- package/dist/service-client/index.d.ts +72 -0
- package/dist/service-client/index.js +119 -0
- package/dist/service-client/index.js.map +1 -0
- package/dist/users/dto.d.ts +48 -0
- package/dist/users/dto.js +267 -0
- package/dist/users/dto.js.map +1 -0
- package/dist/users/index.d.ts +38 -0
- package/dist/users/index.js +144 -0
- package/dist/users/index.js.map +1 -0
- package/dist/webhook-events/index.d.ts +65 -0
- package/dist/webhook-events/index.js +109 -0
- package/dist/webhook-events/index.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { AuditResource, type AuditActor, type AuditedTable, type AuditedTableOptions, type AuditErrorHandler } from '../audit';
|
|
2
|
+
import type { TypedSupabaseClient } from '../client';
|
|
3
|
+
import { BillingResource } from '../billing';
|
|
4
|
+
import { NotificationsOutboxResource } from '../notifications';
|
|
5
|
+
import { OrganizationsResource, OrganizationSignupResource } from '../organizations';
|
|
6
|
+
import { PermissionsResource } from '../permissions';
|
|
7
|
+
import { UsersResource } from '../users';
|
|
8
|
+
import { WebhookEventsResource } from '../webhook-events';
|
|
9
|
+
export type SupabaseServiceClientConfig = {
|
|
10
|
+
url: string;
|
|
11
|
+
/** Service-role key — every query bypasses RLS. */
|
|
12
|
+
serviceRoleKey: string;
|
|
13
|
+
/** Where a failed audit insert is reported. Defaults to `console.error`. */
|
|
14
|
+
onAuditError?: AuditErrorHandler;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The organization-scoped half of the service client. Everything here is attributed to one
|
|
18
|
+
* `AuditActor`, so writes land in `audit_logs` the same way a caller's own would — with
|
|
19
|
+
* `mms_id: null` when the actor is the system (a webhook, a queue worker, provisioning).
|
|
20
|
+
*/
|
|
21
|
+
export declare class SupabaseOrganizationScope {
|
|
22
|
+
private readonly supabase;
|
|
23
|
+
readonly actor: AuditActor;
|
|
24
|
+
readonly audit: AuditResource;
|
|
25
|
+
readonly billing: BillingResource;
|
|
26
|
+
readonly organizations: OrganizationsResource;
|
|
27
|
+
readonly permissions: PermissionsResource;
|
|
28
|
+
readonly users: UsersResource;
|
|
29
|
+
constructor(supabase: TypedSupabaseClient, actor: AuditActor, onAuditError?: AuditErrorHandler);
|
|
30
|
+
/**
|
|
31
|
+
* An audited table bound to this organization and actor — the shape the api hand-rolls today
|
|
32
|
+
* as a local `auditedTables(client, organizationId)` factory in billing, provisioning,
|
|
33
|
+
* subscriptions and both webhook handler services.
|
|
34
|
+
*/
|
|
35
|
+
table(options: AuditedTableOptions): AuditedTable;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The client for work that has no caller and no RLS context to run under: inbound webhooks
|
|
39
|
+
* (Paystack, Resend, the Supabase `send_email` hook), the notification queue worker, unauthenticated
|
|
40
|
+
* signup, and the writes RLS reserves for the service role outright — the ledger, the outbox, the
|
|
41
|
+
* webhook event logs, `organizations` INSERT, `permissions` INSERT/DELETE.
|
|
42
|
+
*
|
|
43
|
+
* It decodes no JWT, because there is none. Cross-org lookups (find the organization behind a
|
|
44
|
+
* Paystack customer code) hang off the client itself; anything attributable goes through
|
|
45
|
+
* `forOrganization`, which supplies the audit actor the resources need.
|
|
46
|
+
*/
|
|
47
|
+
export declare class SupabaseServiceClient {
|
|
48
|
+
private readonly config;
|
|
49
|
+
readonly supabase: TypedSupabaseClient;
|
|
50
|
+
readonly notifications: NotificationsOutboxResource;
|
|
51
|
+
readonly signup: OrganizationSignupResource;
|
|
52
|
+
readonly paystackEvents: WebhookEventsResource;
|
|
53
|
+
readonly resendEvents: WebhookEventsResource;
|
|
54
|
+
constructor(config: SupabaseServiceClientConfig);
|
|
55
|
+
/**
|
|
56
|
+
* Scope to one organization once it is known. `actorMmsId` stays `null` for system work —
|
|
57
|
+
* `audit_logs.created_by` is nullable precisely so an unattributed write is still recorded.
|
|
58
|
+
*/
|
|
59
|
+
forOrganization(organizationId: string, actorMmsId?: string | null): SupabaseOrganizationScope;
|
|
60
|
+
/**
|
|
61
|
+
* Finds the organization behind an external identifier — a Paystack customer or subscription
|
|
62
|
+
* code. Deliberately unscoped: a webhook knows only the provider's own id, and which tenant
|
|
63
|
+
* it belongs to is exactly what this answers.
|
|
64
|
+
*/
|
|
65
|
+
findOrganizationBy(column: string, value: string): Promise<Record<string, unknown> | null>;
|
|
66
|
+
/**
|
|
67
|
+
* A ledger row by id alone. Also unscoped by necessity: a `charge.success` carries the
|
|
68
|
+
* transaction id in its metadata, and the row is what says which tenant it belongs to.
|
|
69
|
+
*/
|
|
70
|
+
findTransaction(transactionId: string): Promise<Record<string, unknown> | null>;
|
|
71
|
+
}
|
|
72
|
+
export declare const createSupabaseServiceClient: (config: SupabaseServiceClientConfig) => SupabaseServiceClient;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSupabaseServiceClient = exports.SupabaseServiceClient = exports.SupabaseOrganizationScope = void 0;
|
|
4
|
+
const supabase_js_1 = require("@supabase/supabase-js");
|
|
5
|
+
const audit_1 = require("../audit");
|
|
6
|
+
const enum_1 = require("@managemint-solutions/entities/audit-trail/enum");
|
|
7
|
+
const billing_1 = require("../billing");
|
|
8
|
+
const notifications_1 = require("../notifications");
|
|
9
|
+
const errors_1 = require("../errors");
|
|
10
|
+
const organizations_1 = require("../organizations");
|
|
11
|
+
const permissions_1 = require("../permissions");
|
|
12
|
+
const users_1 = require("../users");
|
|
13
|
+
const webhook_events_1 = require("../webhook-events");
|
|
14
|
+
/**
|
|
15
|
+
* The organization-scoped half of the service client. Everything here is attributed to one
|
|
16
|
+
* `AuditActor`, so writes land in `audit_logs` the same way a caller's own would — with
|
|
17
|
+
* `mms_id: null` when the actor is the system (a webhook, a queue worker, provisioning).
|
|
18
|
+
*/
|
|
19
|
+
class SupabaseOrganizationScope {
|
|
20
|
+
supabase;
|
|
21
|
+
actor;
|
|
22
|
+
audit;
|
|
23
|
+
billing;
|
|
24
|
+
organizations;
|
|
25
|
+
permissions;
|
|
26
|
+
users;
|
|
27
|
+
constructor(supabase, actor, onAuditError) {
|
|
28
|
+
this.supabase = supabase;
|
|
29
|
+
this.actor = actor;
|
|
30
|
+
this.audit = new audit_1.AuditResource(supabase, actor, onAuditError);
|
|
31
|
+
this.billing = new billing_1.BillingResource(supabase, actor, this.audit);
|
|
32
|
+
this.organizations = new organizations_1.OrganizationsResource(supabase, actor, this.audit);
|
|
33
|
+
this.permissions = new permissions_1.PermissionsResource(supabase, actor, this.audit);
|
|
34
|
+
this.users = new users_1.UsersResource(supabase, actor, this.audit);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* An audited table bound to this organization and actor — the shape the api hand-rolls today
|
|
38
|
+
* as a local `auditedTables(client, organizationId)` factory in billing, provisioning,
|
|
39
|
+
* subscriptions and both webhook handler services.
|
|
40
|
+
*/
|
|
41
|
+
table(options) {
|
|
42
|
+
return (0, audit_1.auditedTable)(this.supabase, this.actor, this.audit, options);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.SupabaseOrganizationScope = SupabaseOrganizationScope;
|
|
46
|
+
/**
|
|
47
|
+
* The client for work that has no caller and no RLS context to run under: inbound webhooks
|
|
48
|
+
* (Paystack, Resend, the Supabase `send_email` hook), the notification queue worker, unauthenticated
|
|
49
|
+
* signup, and the writes RLS reserves for the service role outright — the ledger, the outbox, the
|
|
50
|
+
* webhook event logs, `organizations` INSERT, `permissions` INSERT/DELETE.
|
|
51
|
+
*
|
|
52
|
+
* It decodes no JWT, because there is none. Cross-org lookups (find the organization behind a
|
|
53
|
+
* Paystack customer code) hang off the client itself; anything attributable goes through
|
|
54
|
+
* `forOrganization`, which supplies the audit actor the resources need.
|
|
55
|
+
*/
|
|
56
|
+
class SupabaseServiceClient {
|
|
57
|
+
config;
|
|
58
|
+
supabase; // escape hatch for not-yet-migrated queries
|
|
59
|
+
notifications;
|
|
60
|
+
signup;
|
|
61
|
+
paystackEvents;
|
|
62
|
+
resendEvents;
|
|
63
|
+
constructor(config) {
|
|
64
|
+
this.config = config;
|
|
65
|
+
this.supabase = (0, supabase_js_1.createClient)(config.url, config.serviceRoleKey, {
|
|
66
|
+
auth: { persistSession: false, autoRefreshToken: false, detectSessionInUrl: false },
|
|
67
|
+
});
|
|
68
|
+
this.paystackEvents = new webhook_events_1.WebhookEventsResource(this.supabase, 'paystack_webhook_events');
|
|
69
|
+
this.resendEvents = new webhook_events_1.WebhookEventsResource(this.supabase, 'resend_webhook_events');
|
|
70
|
+
this.signup = new organizations_1.OrganizationSignupResource(this.supabase, (organizationId) => this.forOrganization(organizationId).audit);
|
|
71
|
+
// The outbox spans organizations — the row it is about carries its own — so it takes a
|
|
72
|
+
// factory and scopes per write rather than being built inside one organization's scope.
|
|
73
|
+
this.notifications = new notifications_1.NotificationsOutboxResource(this.supabase, (organizationId) => this.forOrganization(organizationId).table({
|
|
74
|
+
table: 'notifications',
|
|
75
|
+
entityType: enum_1.AuditTrailEntityType.NOTIFICATION,
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Scope to one organization once it is known. `actorMmsId` stays `null` for system work —
|
|
80
|
+
* `audit_logs.created_by` is nullable precisely so an unattributed write is still recorded.
|
|
81
|
+
*/
|
|
82
|
+
forOrganization(organizationId, actorMmsId = null) {
|
|
83
|
+
return new SupabaseOrganizationScope(this.supabase, { mms_id: actorMmsId, organization_id: organizationId }, this.config.onAuditError);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Finds the organization behind an external identifier — a Paystack customer or subscription
|
|
87
|
+
* code. Deliberately unscoped: a webhook knows only the provider's own id, and which tenant
|
|
88
|
+
* it belongs to is exactly what this answers.
|
|
89
|
+
*/
|
|
90
|
+
async findOrganizationBy(column, value) {
|
|
91
|
+
const { data, error } = await this.supabase
|
|
92
|
+
.from('organizations')
|
|
93
|
+
.select('*')
|
|
94
|
+
.eq(column, value)
|
|
95
|
+
.limit(1)
|
|
96
|
+
.maybeSingle();
|
|
97
|
+
if (error)
|
|
98
|
+
throw (0, errors_1.mapPostgrestError)(error);
|
|
99
|
+
return (data ?? null);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* A ledger row by id alone. Also unscoped by necessity: a `charge.success` carries the
|
|
103
|
+
* transaction id in its metadata, and the row is what says which tenant it belongs to.
|
|
104
|
+
*/
|
|
105
|
+
async findTransaction(transactionId) {
|
|
106
|
+
const { data, error } = await this.supabase
|
|
107
|
+
.from('billing_transactions')
|
|
108
|
+
.select('*')
|
|
109
|
+
.eq('mms_id', transactionId)
|
|
110
|
+
.maybeSingle();
|
|
111
|
+
if (error)
|
|
112
|
+
throw (0, errors_1.mapPostgrestError)(error);
|
|
113
|
+
return (data ?? null);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.SupabaseServiceClient = SupabaseServiceClient;
|
|
117
|
+
const createSupabaseServiceClient = (config) => new SupabaseServiceClient(config);
|
|
118
|
+
exports.createSupabaseServiceClient = createSupabaseServiceClient;
|
|
119
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service-client/index.ts"],"names":[],"mappings":";;;AAAA,uDAAqD;AACrD,oCAOkB;AAClB,0EAAuF;AAEvF,wCAA6C;AAC7C,oDAA+D;AAC/D,sCAA8C;AAC9C,oDAAqF;AACrF,gDAAqD;AACrD,oCAAyC;AACzC,sDAA0D;AAU1D;;;;GAIG;AACH,MAAa,yBAAyB;IAQjB;IACR;IARF,KAAK,CAAgB;IACrB,OAAO,CAAkB;IACzB,aAAa,CAAwB;IACrC,WAAW,CAAsB;IACjC,KAAK,CAAgB;IAE9B,YACmB,QAA6B,EACrC,KAAiB,EAC1B,YAAgC;QAFf,aAAQ,GAAR,QAAQ,CAAqB;QACrC,UAAK,GAAL,KAAK,CAAY;QAG1B,IAAI,CAAC,KAAK,GAAG,IAAI,qBAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;QAC9D,IAAI,CAAC,OAAO,GAAG,IAAI,yBAAe,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAChE,IAAI,CAAC,aAAa,GAAG,IAAI,qCAAqB,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5E,IAAI,CAAC,WAAW,GAAG,IAA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I,IAAI,CAAmC,CAAC;IAC1D,CAAC;CACF;AAzED,sDAyEC;AAEM,MAAM,2BAA2B,GAAG,CACzC,MAAmC,EACZ,EAAE,CAAC,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAFjD,QAAA,2BAA2B,+BAEsB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { CreateUserDto as CreateUserDtoType, GetUsersDto as GetUsersDtoType, UpdateUserDto as UpdateUserDtoType, UserIdDto as UserIdDtoType } from '@managemint-solutions/entities/users/dto';
|
|
2
|
+
import { EmergencyContactRelationship, EmploymentType } from '@managemint-solutions/entities/users/enum';
|
|
3
|
+
export declare class UserIdDto implements UserIdDtoType {
|
|
4
|
+
readonly userId: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class AddUserDto implements CreateUserDtoType {
|
|
7
|
+
readonly email: string;
|
|
8
|
+
readonly password: string;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly surname: string;
|
|
11
|
+
readonly phone: string | null;
|
|
12
|
+
readonly profile_image: string | null;
|
|
13
|
+
readonly country_code: string;
|
|
14
|
+
/**
|
|
15
|
+
* The client's idempotency key for the pro-rata seat charge (principle 1).
|
|
16
|
+
* Optional: an internally created user - the owner at signup - has no client
|
|
17
|
+
* request behind it, and one is generated for it.
|
|
18
|
+
*/
|
|
19
|
+
readonly idempotency_key?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class GetUsersQueryDto implements Omit<GetUsersDtoType, 'active_in'> {
|
|
22
|
+
readonly search?: string | null;
|
|
23
|
+
readonly page: number;
|
|
24
|
+
readonly page_size: number;
|
|
25
|
+
readonly active_in?: boolean[] | null;
|
|
26
|
+
}
|
|
27
|
+
export declare class UpdateUserDto implements UpdateUserDtoType {
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly surname: string;
|
|
30
|
+
readonly phone: string;
|
|
31
|
+
readonly country_code: string;
|
|
32
|
+
readonly employment_type: EmploymentType;
|
|
33
|
+
readonly birthday?: string | null;
|
|
34
|
+
readonly start_date?: string | null;
|
|
35
|
+
readonly end_date?: string | null;
|
|
36
|
+
readonly job_title?: string | null;
|
|
37
|
+
readonly manager_id?: string | null;
|
|
38
|
+
readonly social_facebook?: string | null;
|
|
39
|
+
readonly social_linkedin?: string | null;
|
|
40
|
+
readonly social_twitter?: string | null;
|
|
41
|
+
readonly social_instagram?: string | null;
|
|
42
|
+
readonly social_github?: string | null;
|
|
43
|
+
readonly social_website?: string | null;
|
|
44
|
+
readonly emergency_contact_name?: string | null;
|
|
45
|
+
readonly emergency_contact_relationship?: EmergencyContactRelationship | null;
|
|
46
|
+
readonly emergency_contact_phone?: string | null;
|
|
47
|
+
readonly emergency_contact_email?: string | null;
|
|
48
|
+
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.UpdateUserDto = exports.GetUsersQueryDto = exports.AddUserDto = exports.UserIdDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
const class_transformer_1 = require("class-transformer");
|
|
15
|
+
const validators_1 = require("../validators");
|
|
16
|
+
const enum_1 = require("@managemint-solutions/entities/users/enum");
|
|
17
|
+
class UserIdDto {
|
|
18
|
+
userId;
|
|
19
|
+
}
|
|
20
|
+
exports.UserIdDto = UserIdDto;
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, class_validator_1.IsUUID)('4', { message: 'Invalid user ID format' }),
|
|
23
|
+
__metadata("design:type", String)
|
|
24
|
+
], UserIdDto.prototype, "userId", void 0);
|
|
25
|
+
class AddUserDto {
|
|
26
|
+
email;
|
|
27
|
+
password;
|
|
28
|
+
name;
|
|
29
|
+
surname;
|
|
30
|
+
phone;
|
|
31
|
+
profile_image;
|
|
32
|
+
country_code;
|
|
33
|
+
/**
|
|
34
|
+
* The client's idempotency key for the pro-rata seat charge (principle 1).
|
|
35
|
+
* Optional: an internally created user - the owner at signup - has no client
|
|
36
|
+
* request behind it, and one is generated for it.
|
|
37
|
+
*/
|
|
38
|
+
idempotency_key;
|
|
39
|
+
}
|
|
40
|
+
exports.AddUserDto = AddUserDto;
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, class_validator_1.IsEmail)({}, { message: 'Invalid email address' }),
|
|
43
|
+
__metadata("design:type", String)
|
|
44
|
+
], AddUserDto.prototype, "email", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, class_validator_1.IsString)({ message: 'Password is required' }),
|
|
47
|
+
(0, class_validator_1.MinLength)(8, { message: 'Password must be at least 8 characters' }),
|
|
48
|
+
(0, class_validator_1.Matches)(/^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[!@#$%^&*])/, { message: 'Password must contain at least 1 uppercase letter, 1 lowercase letter, 1 number, and 1 special character (!@#$%^&*)' }),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], AddUserDto.prototype, "password", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, class_validator_1.IsString)({ message: 'Name is required' }),
|
|
53
|
+
(0, class_validator_1.MinLength)(1, { message: 'Name is required' }),
|
|
54
|
+
(0, class_validator_1.MaxLength)(50, { message: 'Name cannot be longer than 50 characters' }),
|
|
55
|
+
__metadata("design:type", String)
|
|
56
|
+
], AddUserDto.prototype, "name", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, class_validator_1.IsString)({ message: 'Surname is required' }),
|
|
59
|
+
(0, class_validator_1.MinLength)(1, { message: 'Surname is required' }),
|
|
60
|
+
(0, class_validator_1.MaxLength)(50, { message: 'Surname cannot be longer than 50 characters' }),
|
|
61
|
+
__metadata("design:type", String)
|
|
62
|
+
], AddUserDto.prototype, "surname", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, validators_1.IsNullable)(),
|
|
65
|
+
(0, class_validator_1.IsString)({ message: 'Phone number' }),
|
|
66
|
+
__metadata("design:type", Object)
|
|
67
|
+
], AddUserDto.prototype, "phone", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
(0, validators_1.IsNullable)(),
|
|
70
|
+
(0, class_validator_1.IsString)({ message: 'Profile image URL' }),
|
|
71
|
+
__metadata("design:type", Object)
|
|
72
|
+
], AddUserDto.prototype, "profile_image", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
(0, class_validator_1.IsString)({ message: 'Country code is required' }),
|
|
75
|
+
(0, class_validator_1.MinLength)(1, { message: 'Country code is required' }),
|
|
76
|
+
__metadata("design:type", String)
|
|
77
|
+
], AddUserDto.prototype, "country_code", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, class_validator_1.IsOptional)(),
|
|
80
|
+
(0, class_validator_1.IsUUID)('4', { message: 'Invalid idempotency key format' }),
|
|
81
|
+
__metadata("design:type", String)
|
|
82
|
+
], AddUserDto.prototype, "idempotency_key", void 0);
|
|
83
|
+
// `active_in` arrives as a CSV string and is transformed to booleans, so it is omitted from the
|
|
84
|
+
// implemented contract — the same exception GetClientsDto makes for status_id_in.
|
|
85
|
+
class GetUsersQueryDto {
|
|
86
|
+
search;
|
|
87
|
+
page = 1;
|
|
88
|
+
page_size = 10;
|
|
89
|
+
// Comma-joined booleans on the wire, e.g. "true,false". Absent = all users.
|
|
90
|
+
active_in;
|
|
91
|
+
}
|
|
92
|
+
exports.GetUsersQueryDto = GetUsersQueryDto;
|
|
93
|
+
__decorate([
|
|
94
|
+
(0, class_validator_1.IsOptional)(),
|
|
95
|
+
(0, validators_1.IsNullable)(),
|
|
96
|
+
(0, class_validator_1.IsString)({ message: 'Invalid search query' }),
|
|
97
|
+
(0, class_validator_1.MinLength)(1, { message: 'Search query cannot be empty' }),
|
|
98
|
+
(0, class_validator_1.MaxLength)(255, { message: 'Search query cannot exceed 255 characters' }),
|
|
99
|
+
__metadata("design:type", Object)
|
|
100
|
+
], GetUsersQueryDto.prototype, "search", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
(0, class_validator_1.IsOptional)(),
|
|
103
|
+
(0, class_transformer_1.Transform)(({ value }) => value ? Number(value) : 1, { toClassOnly: true }),
|
|
104
|
+
(0, class_validator_1.IsNumber)({}, { message: 'Page must be a number' }),
|
|
105
|
+
(0, class_validator_1.Min)(1, { message: 'Page must be at least 1' }),
|
|
106
|
+
__metadata("design:type", Number)
|
|
107
|
+
], GetUsersQueryDto.prototype, "page", void 0);
|
|
108
|
+
__decorate([
|
|
109
|
+
(0, class_validator_1.IsOptional)(),
|
|
110
|
+
(0, class_transformer_1.Transform)(({ value }) => value ? Number(value) : 10, { toClassOnly: true }),
|
|
111
|
+
(0, class_validator_1.IsNumber)({}, { message: 'Page size must be a number' }),
|
|
112
|
+
(0, class_validator_1.Min)(1, { message: 'Page size must be at least 1' }),
|
|
113
|
+
(0, class_validator_1.Max)(100, { message: 'Page size cannot exceed 100' }),
|
|
114
|
+
__metadata("design:type", Number)
|
|
115
|
+
], GetUsersQueryDto.prototype, "page_size", void 0);
|
|
116
|
+
__decorate([
|
|
117
|
+
(0, class_validator_1.IsOptional)(),
|
|
118
|
+
(0, validators_1.IsNullable)(),
|
|
119
|
+
(0, class_transformer_1.Transform)(({ value }) => value ? value.split(',').map((entry) => entry.trim() === 'true') : null, { toClassOnly: true }),
|
|
120
|
+
(0, class_validator_1.IsBoolean)({ each: true, message: 'Active filter values must be booleans' }),
|
|
121
|
+
__metadata("design:type", Object)
|
|
122
|
+
], GetUsersQueryDto.prototype, "active_in", void 0);
|
|
123
|
+
class UpdateUserDto {
|
|
124
|
+
name;
|
|
125
|
+
surname;
|
|
126
|
+
phone;
|
|
127
|
+
country_code;
|
|
128
|
+
employment_type;
|
|
129
|
+
birthday;
|
|
130
|
+
start_date;
|
|
131
|
+
end_date;
|
|
132
|
+
job_title;
|
|
133
|
+
manager_id;
|
|
134
|
+
social_facebook;
|
|
135
|
+
social_linkedin;
|
|
136
|
+
social_twitter;
|
|
137
|
+
social_instagram;
|
|
138
|
+
social_github;
|
|
139
|
+
social_website;
|
|
140
|
+
emergency_contact_name;
|
|
141
|
+
emergency_contact_relationship;
|
|
142
|
+
emergency_contact_phone;
|
|
143
|
+
emergency_contact_email;
|
|
144
|
+
}
|
|
145
|
+
exports.UpdateUserDto = UpdateUserDto;
|
|
146
|
+
__decorate([
|
|
147
|
+
(0, class_validator_1.IsString)({ message: 'Invalid name' }),
|
|
148
|
+
(0, class_validator_1.MinLength)(1, { message: 'Name is required' }),
|
|
149
|
+
(0, class_validator_1.MaxLength)(50, { message: 'Name cannot be longer than 50 characters' }),
|
|
150
|
+
__metadata("design:type", String)
|
|
151
|
+
], UpdateUserDto.prototype, "name", void 0);
|
|
152
|
+
__decorate([
|
|
153
|
+
(0, class_validator_1.IsString)({ message: 'Invalid surname' }),
|
|
154
|
+
(0, class_validator_1.MinLength)(1, { message: 'Surname is required' }),
|
|
155
|
+
(0, class_validator_1.MaxLength)(50, { message: 'Surname cannot be longer than 50 characters' }),
|
|
156
|
+
__metadata("design:type", String)
|
|
157
|
+
], UpdateUserDto.prototype, "surname", void 0);
|
|
158
|
+
__decorate([
|
|
159
|
+
(0, class_validator_1.IsString)({ message: 'Invalid phone number' }),
|
|
160
|
+
__metadata("design:type", String)
|
|
161
|
+
], UpdateUserDto.prototype, "phone", void 0);
|
|
162
|
+
__decorate([
|
|
163
|
+
(0, class_validator_1.IsString)({ message: 'Country code is required' }),
|
|
164
|
+
(0, class_validator_1.MinLength)(1, { message: 'Country code is required' }),
|
|
165
|
+
__metadata("design:type", String)
|
|
166
|
+
], UpdateUserDto.prototype, "country_code", void 0);
|
|
167
|
+
__decorate([
|
|
168
|
+
(0, class_validator_1.IsOptional)(),
|
|
169
|
+
(0, class_validator_1.IsEnum)(enum_1.EmploymentType, { message: 'Invalid employment type' }),
|
|
170
|
+
__metadata("design:type", String)
|
|
171
|
+
], UpdateUserDto.prototype, "employment_type", void 0);
|
|
172
|
+
__decorate([
|
|
173
|
+
(0, class_validator_1.IsOptional)(),
|
|
174
|
+
(0, validators_1.IsNullable)(),
|
|
175
|
+
(0, class_validator_1.IsDateString)({}, { message: 'Birthday must be a valid ISO 8601 date string' }),
|
|
176
|
+
__metadata("design:type", Object)
|
|
177
|
+
], UpdateUserDto.prototype, "birthday", void 0);
|
|
178
|
+
__decorate([
|
|
179
|
+
(0, class_validator_1.IsOptional)(),
|
|
180
|
+
(0, validators_1.IsNullable)(),
|
|
181
|
+
(0, class_validator_1.IsDateString)({}, { message: 'Start date must be a valid ISO 8601 date string' }),
|
|
182
|
+
__metadata("design:type", Object)
|
|
183
|
+
], UpdateUserDto.prototype, "start_date", void 0);
|
|
184
|
+
__decorate([
|
|
185
|
+
(0, class_validator_1.IsOptional)(),
|
|
186
|
+
(0, validators_1.IsNullable)(),
|
|
187
|
+
(0, class_validator_1.IsDateString)({}, { message: 'End date must be a valid ISO 8601 date string' }),
|
|
188
|
+
__metadata("design:type", Object)
|
|
189
|
+
], UpdateUserDto.prototype, "end_date", void 0);
|
|
190
|
+
__decorate([
|
|
191
|
+
(0, class_validator_1.IsOptional)(),
|
|
192
|
+
(0, validators_1.IsNullable)(),
|
|
193
|
+
(0, class_validator_1.IsString)({ message: 'Invalid job title' }),
|
|
194
|
+
(0, class_validator_1.MaxLength)(100, { message: 'Job title cannot be longer than 100 characters' }),
|
|
195
|
+
__metadata("design:type", Object)
|
|
196
|
+
], UpdateUserDto.prototype, "job_title", void 0);
|
|
197
|
+
__decorate([
|
|
198
|
+
(0, class_validator_1.IsOptional)(),
|
|
199
|
+
(0, validators_1.IsNullable)(),
|
|
200
|
+
(0, class_validator_1.IsUUID)('4', { message: 'Invalid manager ID format' }),
|
|
201
|
+
__metadata("design:type", Object)
|
|
202
|
+
], UpdateUserDto.prototype, "manager_id", void 0);
|
|
203
|
+
__decorate([
|
|
204
|
+
(0, class_validator_1.IsOptional)(),
|
|
205
|
+
(0, validators_1.IsNullable)(),
|
|
206
|
+
(0, class_validator_1.IsUrl)({}, { message: 'Invalid Facebook URL' }),
|
|
207
|
+
__metadata("design:type", Object)
|
|
208
|
+
], UpdateUserDto.prototype, "social_facebook", void 0);
|
|
209
|
+
__decorate([
|
|
210
|
+
(0, class_validator_1.IsOptional)(),
|
|
211
|
+
(0, validators_1.IsNullable)(),
|
|
212
|
+
(0, class_validator_1.IsUrl)({}, { message: 'Invalid LinkedIn URL' }),
|
|
213
|
+
__metadata("design:type", Object)
|
|
214
|
+
], UpdateUserDto.prototype, "social_linkedin", void 0);
|
|
215
|
+
__decorate([
|
|
216
|
+
(0, class_validator_1.IsOptional)(),
|
|
217
|
+
(0, validators_1.IsNullable)(),
|
|
218
|
+
(0, class_validator_1.IsUrl)({}, { message: 'Invalid Twitter URL' }),
|
|
219
|
+
__metadata("design:type", Object)
|
|
220
|
+
], UpdateUserDto.prototype, "social_twitter", void 0);
|
|
221
|
+
__decorate([
|
|
222
|
+
(0, class_validator_1.IsOptional)(),
|
|
223
|
+
(0, validators_1.IsNullable)(),
|
|
224
|
+
(0, class_validator_1.IsUrl)({}, { message: 'Invalid Instagram URL' }),
|
|
225
|
+
__metadata("design:type", Object)
|
|
226
|
+
], UpdateUserDto.prototype, "social_instagram", void 0);
|
|
227
|
+
__decorate([
|
|
228
|
+
(0, class_validator_1.IsOptional)(),
|
|
229
|
+
(0, validators_1.IsNullable)(),
|
|
230
|
+
(0, class_validator_1.IsUrl)({}, { message: 'Invalid GitHub URL' }),
|
|
231
|
+
__metadata("design:type", Object)
|
|
232
|
+
], UpdateUserDto.prototype, "social_github", void 0);
|
|
233
|
+
__decorate([
|
|
234
|
+
(0, class_validator_1.IsOptional)(),
|
|
235
|
+
(0, validators_1.IsNullable)(),
|
|
236
|
+
(0, class_validator_1.IsUrl)({}, { message: 'Invalid website URL' }),
|
|
237
|
+
__metadata("design:type", Object)
|
|
238
|
+
], UpdateUserDto.prototype, "social_website", void 0);
|
|
239
|
+
__decorate([
|
|
240
|
+
(0, class_validator_1.IsOptional)(),
|
|
241
|
+
(0, validators_1.IsNullable)(),
|
|
242
|
+
(0, class_validator_1.IsString)({ message: 'Invalid emergency contact name' }),
|
|
243
|
+
(0, class_validator_1.MinLength)(1, { message: 'Emergency contact name is required' }),
|
|
244
|
+
(0, class_validator_1.MaxLength)(50, { message: 'Emergency contact name cannot be longer than 50 characters' }),
|
|
245
|
+
__metadata("design:type", Object)
|
|
246
|
+
], UpdateUserDto.prototype, "emergency_contact_name", void 0);
|
|
247
|
+
__decorate([
|
|
248
|
+
(0, class_validator_1.IsOptional)(),
|
|
249
|
+
(0, validators_1.IsNullable)(),
|
|
250
|
+
(0, class_validator_1.IsEnum)(enum_1.EmergencyContactRelationship, { message: 'Invalid emergency contact relationship' }),
|
|
251
|
+
(0, class_validator_1.MinLength)(1, { message: 'Emergency contact relationship is required' }),
|
|
252
|
+
(0, class_validator_1.MaxLength)(50, { message: 'Emergency contact relationship cannot be longer than 50 characters' }),
|
|
253
|
+
__metadata("design:type", Object)
|
|
254
|
+
], UpdateUserDto.prototype, "emergency_contact_relationship", void 0);
|
|
255
|
+
__decorate([
|
|
256
|
+
(0, class_validator_1.IsOptional)(),
|
|
257
|
+
(0, validators_1.IsNullable)(),
|
|
258
|
+
(0, class_validator_1.IsString)({ message: 'Invalid emergency contact phone number' }),
|
|
259
|
+
__metadata("design:type", Object)
|
|
260
|
+
], UpdateUserDto.prototype, "emergency_contact_phone", void 0);
|
|
261
|
+
__decorate([
|
|
262
|
+
(0, class_validator_1.IsOptional)(),
|
|
263
|
+
(0, validators_1.IsNullable)(),
|
|
264
|
+
(0, class_validator_1.IsEmail)({}, { message: 'Invalid emergency contact email address' }),
|
|
265
|
+
__metadata("design:type", Object)
|
|
266
|
+
], UpdateUserDto.prototype, "emergency_contact_email", void 0);
|
|
267
|
+
//# sourceMappingURL=dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dto.js","sourceRoot":"","sources":["../../src/users/dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAOA,qDAeyB;AACzB,yDAA8C;AAC9C,8CAA2C;AAC3C,oEAAyG;AAEzG,MAAa,SAAS;IAEX,MAAM,CAAU;CAC1B;AAHD,8BAGC;AADU;IADR,IAAA,wBAAM,EAAC,GAAG,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE,CAAC;;yCAC1B;AAG3B,MAAa,UAAU;IAEZ,KAAK,CAAU;IAQf,QAAQ,CAAU;IAKlB,IAAI,CAAU;IAKd,OAAO,CAAU;IAIjB,KAAK,CAAiB;IAItB,aAAa,CAAiB;IAI9B,YAAY,CAAU;IAE/B;;;;OAIG;IAGM,eAAe,CAAU;CACnC;AA1CD,gCA0CC;AAxCU;IADR,IAAA,yBAAO,EAAC,EAAE,EAAE,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC;;yCAC1B;AAQf;IANR,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC;IAC7C,IAAA,2BAAS,EAAC,CAAC,EAAE,EAAE,OAAO,EAAE,wCAAwC,EAAE,CAAC;IACnE,IAAA,yBAAO,EACN,iDAAiD,EACjD,EAAE,OAAO,EAAE,qHAAqH,EAAE,CACnI;;4CAC0B;AAKlB;IAHR,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;IACzC,I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AAE,OAAO,EAAE,wCAAwC,EAAE,CAAC;;8DACf;AAKxC;IAHR,IAAA,4BAAU,GAAE;IACZ,IAAA,uBAAU,GAAE;IACZ,IAAA,yBAAO,EAAC,EAAE,EAAE,EAAE,OAAO,EAAE,yCAAyC,EAAE,CAAC;;8DACnB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { MmsList } from '@managemint-solutions/entities/common';
|
|
2
|
+
import type { UserIdentity, UserSummary } from '@managemint-solutions/entities/users';
|
|
3
|
+
import { type AuditActor, type AuditResource, type AuditRow } from '../audit';
|
|
4
|
+
import type { TypedSupabaseClient } from '../client';
|
|
5
|
+
import type { GetUsersQueryDto } from './dto';
|
|
6
|
+
export * from './dto';
|
|
7
|
+
/** The full users row. The api resolves its manager/created_by/last_updated_by ids into identities. */
|
|
8
|
+
export type UserRow = Record<string, unknown> & {
|
|
9
|
+
mms_id: string;
|
|
10
|
+
manager_id: string | null;
|
|
11
|
+
created_by: string | null;
|
|
12
|
+
last_updated_by: string | null;
|
|
13
|
+
};
|
|
14
|
+
export declare class UsersResource {
|
|
15
|
+
private readonly supabase;
|
|
16
|
+
private readonly auth;
|
|
17
|
+
private readonly table;
|
|
18
|
+
constructor(supabase: TypedSupabaseClient, auth: AuditActor, audit: AuditResource);
|
|
19
|
+
list(query: GetUsersQueryDto): Promise<MmsList<UserSummary>>;
|
|
20
|
+
getRow(userId: string): Promise<UserRow>;
|
|
21
|
+
/**
|
|
22
|
+
* The public profile behind a `*_by` / `manager_id` column. `user_profiles` is a
|
|
23
|
+
* `security_invoker = off` view granted to `authenticated`, so this runs on the caller's own
|
|
24
|
+
* client — it needs no service role.
|
|
25
|
+
*/
|
|
26
|
+
identityById(userId?: string | null): Promise<UserIdentity | null>;
|
|
27
|
+
/** Seats in use. Counts rows rather than fetching them. */
|
|
28
|
+
activeCount(): Promise<number>;
|
|
29
|
+
isActive(userId: string): Promise<boolean>;
|
|
30
|
+
update(userId: string, patch: AuditRow): Promise<UserRow>;
|
|
31
|
+
/** `active` is not an archive flag, so a deactivation is recorded as a plain UPDATE. */
|
|
32
|
+
setActive(userId: string, active: boolean): Promise<UserRow>;
|
|
33
|
+
/**
|
|
34
|
+
* Stamps who created a user. Runs on the service client during signup: the row is written by
|
|
35
|
+
* the `on_auth_user_created` trigger, so there is nothing to attribute it to until afterwards.
|
|
36
|
+
*/
|
|
37
|
+
stampCreatedBy(userId: string, createdBy: string | null): Promise<AuditRow>;
|
|
38
|
+
}
|