@tstdl/base 0.93.89 → 0.93.90
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.
|
@@ -8,10 +8,12 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { defineEnum } from '../../enumeration/enumeration.js';
|
|
11
|
+
import { formatPersonName } from '../../formats/formats.js';
|
|
11
12
|
import { TenantEntity } from '../../orm/entity.js';
|
|
12
13
|
import { Inheritance, Table, Unique } from '../../orm/index.js';
|
|
13
14
|
import { TimestampProperty } from '../../orm/schemas/timestamp.js';
|
|
14
15
|
import { Enumeration } from '../../schema/index.js';
|
|
16
|
+
import { match } from 'ts-pattern';
|
|
15
17
|
export const SubjectType = defineEnum('SubjectType', {
|
|
16
18
|
System: 'system',
|
|
17
19
|
User: 'user',
|
|
@@ -55,3 +57,10 @@ Subject = __decorate([
|
|
|
55
57
|
Unique(['id']) // for external systems that might not support composite identities
|
|
56
58
|
], Subject);
|
|
57
59
|
export { Subject };
|
|
60
|
+
export function getSubjectDisplayName(subject) {
|
|
61
|
+
return match(subject.type)
|
|
62
|
+
.with(SubjectType.User, () => formatPersonName(subject))
|
|
63
|
+
.with(SubjectType.System, () => subject.displayName)
|
|
64
|
+
.with(SubjectType.ServiceAccount, () => subject.displayName)
|
|
65
|
+
.exhaustive();
|
|
66
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { LoadOptions } from '../../orm/repository.types.js';
|
|
2
2
|
import { ServiceAccount, Subject, SystemAccount, User } from '../models/index.js';
|
|
3
|
-
export type
|
|
4
|
-
export type
|
|
3
|
+
export type CreateUserData = Pick<User, 'tenantId' | 'email' | 'firstName' | 'lastName'> & Partial<Pick<User, 'status'>>;
|
|
4
|
+
export type CreateServiceAccountData = Pick<ServiceAccount, 'tenantId' | 'displayName' | 'description' | 'parent'> & Partial<Pick<ServiceAccount, 'status'>>;
|
|
5
5
|
export declare class SubjectService {
|
|
6
6
|
#private;
|
|
7
7
|
getSubject(id: string, options?: LoadOptions<Subject>): Promise<Subject>;
|
|
8
8
|
tryGetSubject(id: string, options?: LoadOptions<Subject>): Promise<Subject | undefined>;
|
|
9
9
|
getSystemAccount(tenantId: string, identifier: string): Promise<SystemAccount>;
|
|
10
|
-
createUser(data:
|
|
10
|
+
createUser(data: CreateUserData): Promise<User>;
|
|
11
11
|
updateUser(tenantId: string, userId: string, data: Partial<Pick<User, 'firstName' | 'lastName' | 'status'>>): Promise<void>;
|
|
12
12
|
updateUserEmail(tenantId: string, userId: string, email: string): Promise<void>;
|
|
13
13
|
getUser(tenantId: string, userId: string): Promise<User>;
|
|
@@ -16,7 +16,7 @@ export declare class SubjectService {
|
|
|
16
16
|
hasUserByEmail(tenantId: string, email: string): Promise<boolean>;
|
|
17
17
|
getUserBySubject(subject: Subject): Promise<User>;
|
|
18
18
|
loadManyUsersByEmails(tenantId: string, emails: string[]): Promise<User[]>;
|
|
19
|
-
createServiceAccount(data:
|
|
19
|
+
createServiceAccount(data: CreateServiceAccountData): Promise<ServiceAccount>;
|
|
20
20
|
updateServiceAccount(tenantId: string, serviceAccountId: string, data: Partial<Pick<ServiceAccount, 'description' | 'displayName' | 'status'>>): Promise<void>;
|
|
21
21
|
getServiceAccount(tenantId: string, serviceAccountId: string): Promise<ServiceAccount>;
|
|
22
22
|
getServiceAccountBySubject(subject: Subject): Promise<ServiceAccount>;
|