@loomcore/common 0.0.44 → 0.0.46
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/models/index.d.ts +3 -0
- package/dist/models/index.js +3 -0
- package/dist/models/person.model.d.ts +0 -15
- package/dist/models/person.model.js +1 -5
- package/dist/models/user-context.model.js +1 -19
- package/dist/models/user.model.d.ts +7 -49
- package/dist/models/user.model.js +5 -5
- package/package.json +1 -1
package/dist/models/index.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ export * from './login-response.model.js';
|
|
|
7
7
|
export * from './token-response.model.js';
|
|
8
8
|
export * from './auditable.model.js';
|
|
9
9
|
export * from './query-options.model.js';
|
|
10
|
+
export * from './person.model.js';
|
|
11
|
+
export * from './phone-number.model.js';
|
|
12
|
+
export * from './email-address.model.js';
|
|
10
13
|
export * from './address.interface.js';
|
|
11
14
|
export * from './api-response.interface.js';
|
|
12
15
|
export * from './auth.state.interface.js';
|
package/dist/models/index.js
CHANGED
|
@@ -7,6 +7,9 @@ export * from './login-response.model.js';
|
|
|
7
7
|
export * from './token-response.model.js';
|
|
8
8
|
export * from './auditable.model.js';
|
|
9
9
|
export * from './query-options.model.js';
|
|
10
|
+
export * from './person.model.js';
|
|
11
|
+
export * from './phone-number.model.js';
|
|
12
|
+
export * from './email-address.model.js';
|
|
10
13
|
export * from './address.interface.js';
|
|
11
14
|
export * from './api-response.interface.js';
|
|
12
15
|
export * from './auth.state.interface.js';
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import type { IAuditable, IEntity } from "@loomcore/common/models";
|
|
2
|
-
import { IEmailAddressModel } from "./email-address.model.js";
|
|
3
|
-
import { IPhoneNumberModel } from "./phone-number.model.js";
|
|
4
2
|
export interface IPersonModel extends IEntity, IAuditable {
|
|
5
3
|
externalId: string | null;
|
|
6
4
|
firstName: string;
|
|
7
5
|
middleName: string | null;
|
|
8
6
|
lastName: string;
|
|
9
|
-
emailAddresses: IEmailAddressModel[];
|
|
10
|
-
phoneNumbers: IPhoneNumberModel[];
|
|
11
7
|
isAgent: boolean;
|
|
12
8
|
isClient: boolean;
|
|
13
9
|
isEmployee: boolean;
|
|
@@ -19,17 +15,6 @@ export declare const personSchema: import("@sinclair/typebox").TObject<{
|
|
|
19
15
|
firstName: import("@sinclair/typebox").TString;
|
|
20
16
|
middleName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
21
17
|
lastName: import("@sinclair/typebox").TString;
|
|
22
|
-
emailAddresses: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
23
|
-
personId: import("@sinclair/typebox").TSchema;
|
|
24
|
-
emailAddress: import("@sinclair/typebox").TString;
|
|
25
|
-
emailAddressType: import("@sinclair/typebox").TString;
|
|
26
|
-
isDefault: import("@sinclair/typebox").TBoolean;
|
|
27
|
-
}>>;
|
|
28
|
-
phoneNumbers: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
29
|
-
phoneNumber: import("@sinclair/typebox").TString;
|
|
30
|
-
phoneNumberType: import("@sinclair/typebox").TString;
|
|
31
|
-
isDefault: import("@sinclair/typebox").TBoolean;
|
|
32
|
-
}>>;
|
|
33
18
|
isAgent: import("@sinclair/typebox").TBoolean;
|
|
34
19
|
isClient: import("@sinclair/typebox").TBoolean;
|
|
35
20
|
isEmployee: import("@sinclair/typebox").TBoolean;
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { entityUtils } from "@loomcore/common/utils";
|
|
2
2
|
import { Type } from "@sinclair/typebox";
|
|
3
|
-
import { emailAddressSchema } from "./email-address.model.js";
|
|
4
|
-
import { phoneNumberSchema } from "./phone-number.model.js";
|
|
5
3
|
export const personSchema = Type.Object({
|
|
6
4
|
externalId: Type.Optional(Type.String()),
|
|
7
5
|
firstName: Type.String(),
|
|
8
6
|
middleName: Type.Optional(Type.String()),
|
|
9
7
|
lastName: Type.String(),
|
|
10
|
-
emailAddresses: Type.Array(emailAddressSchema),
|
|
11
|
-
phoneNumbers: Type.Array(phoneNumberSchema),
|
|
12
8
|
isAgent: Type.Boolean(),
|
|
13
9
|
isClient: Type.Boolean(),
|
|
14
10
|
isEmployee: Type.Boolean(),
|
|
15
11
|
dateOfBirth: Type.Optional(Type.String()),
|
|
16
12
|
extendedTypes: Type.Number(),
|
|
17
13
|
});
|
|
18
|
-
export const personModelSpec = entityUtils.getModelSpec(personSchema);
|
|
14
|
+
export const personModelSpec = entityUtils.getModelSpec(personSchema, { isAuditable: true });
|
|
@@ -28,28 +28,10 @@ export function initializeSystemUserContext(systemEmail, metaOrg) {
|
|
|
28
28
|
user: {
|
|
29
29
|
_id: systemId,
|
|
30
30
|
_orgId: metaOrg?._id,
|
|
31
|
-
|
|
31
|
+
externalId: 'system',
|
|
32
32
|
email: systemEmail,
|
|
33
33
|
displayName: 'System User',
|
|
34
34
|
password: 'systemPassword',
|
|
35
|
-
person: {
|
|
36
|
-
_id: systemId,
|
|
37
|
-
externalId: 'system',
|
|
38
|
-
firstName: 'System',
|
|
39
|
-
middleName: null,
|
|
40
|
-
lastName: 'User',
|
|
41
|
-
emailAddresses: [],
|
|
42
|
-
phoneNumbers: [],
|
|
43
|
-
isAgent: true,
|
|
44
|
-
isClient: false,
|
|
45
|
-
isEmployee: false,
|
|
46
|
-
dateOfBirth: null,
|
|
47
|
-
extendedTypes: 0,
|
|
48
|
-
_created: new Date(),
|
|
49
|
-
_createdBy: systemId,
|
|
50
|
-
_updated: new Date(),
|
|
51
|
-
_updatedBy: systemId,
|
|
52
|
-
},
|
|
53
35
|
_created: new Date(),
|
|
54
36
|
_createdBy: systemId,
|
|
55
37
|
_updated: new Date(),
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { IAuditable } from './auditable.model.js';
|
|
2
2
|
import { IEntity } from './entity.model.js';
|
|
3
|
-
import {
|
|
3
|
+
import { AppIdType } from '../types/app.types.js';
|
|
4
4
|
export interface IUser extends IEntity, IAuditable {
|
|
5
|
-
|
|
5
|
+
externalId: string | null;
|
|
6
6
|
email: string;
|
|
7
7
|
displayName?: string;
|
|
8
8
|
password: string;
|
|
9
|
-
|
|
9
|
+
personId?: AppIdType;
|
|
10
10
|
_lastLoggedIn?: Date;
|
|
11
11
|
_lastPasswordChange?: Date;
|
|
12
12
|
}
|
|
@@ -17,62 +17,20 @@ export declare const passwordValidator: import("@sinclair/typebox/compiler").Typ
|
|
|
17
17
|
password: import("@sinclair/typebox").TString;
|
|
18
18
|
}>>;
|
|
19
19
|
export declare const UserSchema: import("@sinclair/typebox").TObject<{
|
|
20
|
-
|
|
20
|
+
externalId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
21
21
|
email: import("@sinclair/typebox").TString;
|
|
22
22
|
displayName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
23
23
|
password: import("@sinclair/typebox").TString;
|
|
24
|
-
|
|
25
|
-
externalId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
26
|
-
firstName: import("@sinclair/typebox").TString;
|
|
27
|
-
middleName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
28
|
-
lastName: import("@sinclair/typebox").TString;
|
|
29
|
-
emailAddresses: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
30
|
-
personId: import("@sinclair/typebox").TSchema;
|
|
31
|
-
emailAddress: import("@sinclair/typebox").TString;
|
|
32
|
-
emailAddressType: import("@sinclair/typebox").TString;
|
|
33
|
-
isDefault: import("@sinclair/typebox").TBoolean;
|
|
34
|
-
}>>;
|
|
35
|
-
phoneNumbers: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
36
|
-
phoneNumber: import("@sinclair/typebox").TString;
|
|
37
|
-
phoneNumberType: import("@sinclair/typebox").TString;
|
|
38
|
-
isDefault: import("@sinclair/typebox").TBoolean;
|
|
39
|
-
}>>;
|
|
40
|
-
isAgent: import("@sinclair/typebox").TBoolean;
|
|
41
|
-
isClient: import("@sinclair/typebox").TBoolean;
|
|
42
|
-
isEmployee: import("@sinclair/typebox").TBoolean;
|
|
43
|
-
dateOfBirth: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
44
|
-
extendedTypes: import("@sinclair/typebox").TNumber;
|
|
45
|
-
}>;
|
|
24
|
+
personId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TSchema>;
|
|
46
25
|
_lastLoggedIn: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TString, Date>>;
|
|
47
26
|
_lastPasswordChange: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TString, Date>>;
|
|
48
27
|
}>;
|
|
49
28
|
export declare const UserSpec: import("./model-spec.interface.js").IModelSpec<import("@sinclair/typebox").TSchema>;
|
|
50
29
|
export declare const PublicUserSchema: import("@sinclair/typebox").TObject<{
|
|
30
|
+
externalId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
51
31
|
email: import("@sinclair/typebox").TString;
|
|
52
|
-
|
|
32
|
+
personId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TSchema>;
|
|
53
33
|
displayName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
54
|
-
person: import("@sinclair/typebox").TObject<{
|
|
55
|
-
externalId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
56
|
-
firstName: import("@sinclair/typebox").TString;
|
|
57
|
-
middleName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
58
|
-
lastName: import("@sinclair/typebox").TString;
|
|
59
|
-
emailAddresses: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
60
|
-
personId: import("@sinclair/typebox").TSchema;
|
|
61
|
-
emailAddress: import("@sinclair/typebox").TString;
|
|
62
|
-
emailAddressType: import("@sinclair/typebox").TString;
|
|
63
|
-
isDefault: import("@sinclair/typebox").TBoolean;
|
|
64
|
-
}>>;
|
|
65
|
-
phoneNumbers: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
66
|
-
phoneNumber: import("@sinclair/typebox").TString;
|
|
67
|
-
phoneNumberType: import("@sinclair/typebox").TString;
|
|
68
|
-
isDefault: import("@sinclair/typebox").TBoolean;
|
|
69
|
-
}>>;
|
|
70
|
-
isAgent: import("@sinclair/typebox").TBoolean;
|
|
71
|
-
isClient: import("@sinclair/typebox").TBoolean;
|
|
72
|
-
isEmployee: import("@sinclair/typebox").TBoolean;
|
|
73
|
-
dateOfBirth: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
74
|
-
extendedTypes: import("@sinclair/typebox").TNumber;
|
|
75
|
-
}>;
|
|
76
34
|
_lastLoggedIn: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TString, Date>>;
|
|
77
35
|
_lastPasswordChange: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TString, Date>>;
|
|
78
36
|
}>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { TypeboxIsoDate } from '../validation/typebox-extensions.js';
|
|
1
|
+
import { getIdSchema, TypeboxIsoDate } from '../validation/typebox-extensions.js';
|
|
2
2
|
import { Type } from '@sinclair/typebox';
|
|
3
3
|
import { entityUtils } from '../utils/entity.utils.js';
|
|
4
4
|
import { TypeCompiler } from '@sinclair/typebox/compiler';
|
|
5
|
-
import { personSchema } from './person.model.js';
|
|
6
5
|
export const UserPasswordSchema = Type.Object({
|
|
7
6
|
password: Type.String({
|
|
8
7
|
title: 'Password',
|
|
@@ -11,8 +10,9 @@ export const UserPasswordSchema = Type.Object({
|
|
|
11
10
|
}),
|
|
12
11
|
});
|
|
13
12
|
export const passwordValidator = TypeCompiler.Compile(UserPasswordSchema);
|
|
13
|
+
const idSchema = getIdSchema();
|
|
14
14
|
export const UserSchema = Type.Object({
|
|
15
|
-
|
|
15
|
+
externalId: Type.Optional(Type.String()),
|
|
16
16
|
email: Type.String({
|
|
17
17
|
title: 'Email',
|
|
18
18
|
format: 'email'
|
|
@@ -21,10 +21,10 @@ export const UserSchema = Type.Object({
|
|
|
21
21
|
title: 'Display Name'
|
|
22
22
|
})),
|
|
23
23
|
password: UserPasswordSchema.properties.password,
|
|
24
|
-
|
|
24
|
+
personId: Type.Optional(idSchema),
|
|
25
25
|
_lastLoggedIn: Type.Optional(TypeboxIsoDate({ title: 'Last Login Date' })),
|
|
26
26
|
_lastPasswordChange: Type.Optional(TypeboxIsoDate({ title: 'Last Password Change Date' })),
|
|
27
27
|
});
|
|
28
28
|
export const UserSpec = entityUtils.getModelSpec(UserSchema, { isAuditable: true });
|
|
29
29
|
export const PublicUserSchema = Type.Omit(UserSchema, ['password']);
|
|
30
|
-
export const PublicUserSpec = entityUtils.getModelSpec(PublicUserSchema
|
|
30
|
+
export const PublicUserSpec = entityUtils.getModelSpec(PublicUserSchema);
|
package/package.json
CHANGED