@loomcore/common 0.0.29 → 0.0.30
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/authorization.model.d.ts +18 -3
- package/dist/models/authorization.model.js +12 -3
- package/dist/models/user-context.model.d.ts +2 -2
- package/dist/models/user-context.model.js +0 -5
- package/dist/models/user.model.d.ts +19 -7
- package/dist/models/user.model.js +14 -21
- package/package.json +1 -1
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
import { IAuditable, IEntity } from "./index.js";
|
|
2
|
-
export interface
|
|
2
|
+
export interface IAuthorizationIn extends IEntity, IAuditable {
|
|
3
|
+
roleId: string;
|
|
4
|
+
featureId: string;
|
|
5
|
+
startDate?: Date;
|
|
6
|
+
endDate?: Date;
|
|
7
|
+
config?: any;
|
|
8
|
+
}
|
|
9
|
+
export declare const AuthorizationSchema: import("@sinclair/typebox").TObject<{
|
|
10
|
+
roleId: import("@sinclair/typebox").TString;
|
|
11
|
+
featureId: import("@sinclair/typebox").TString;
|
|
12
|
+
startDate: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TString, Date>>;
|
|
13
|
+
endDate: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TString, Date>>;
|
|
14
|
+
config: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TAny>;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const AuthorizationModelSpec: import("./model-spec.interface.js").IModelSpec<import("@sinclair/typebox").TSchema>;
|
|
17
|
+
export interface IAuthorizationOut extends IEntity {
|
|
3
18
|
role: string;
|
|
4
19
|
feature: string;
|
|
5
20
|
config?: any;
|
|
6
21
|
}
|
|
7
|
-
export declare const
|
|
22
|
+
export declare const PublicAuthorizationSchema: import("@sinclair/typebox").TObject<{
|
|
8
23
|
role: import("@sinclair/typebox").TString;
|
|
9
24
|
feature: import("@sinclair/typebox").TString;
|
|
10
25
|
config: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TAny>;
|
|
11
26
|
}>;
|
|
12
|
-
export declare const
|
|
27
|
+
export declare const PublicAuthorizationModelSpec: import("./model-spec.interface.js").IModelSpec<import("@sinclair/typebox").TSchema>;
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { Type } from "@sinclair/typebox";
|
|
2
2
|
import { entityUtils } from "../utils/index.js";
|
|
3
|
+
import { TypeboxIsoDate } from "../validation/index.js";
|
|
3
4
|
export const AuthorizationSchema = Type.Object({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
roleId: Type.String({ minLength: 1, title: 'Role ID' }),
|
|
6
|
+
featureId: Type.String({ minLength: 1, title: 'Feature ID' }),
|
|
7
|
+
startDate: Type.Optional(TypeboxIsoDate({ title: 'Start Date' })),
|
|
8
|
+
endDate: Type.Optional(TypeboxIsoDate({ title: 'End Date' })),
|
|
9
|
+
config: Type.Optional(Type.Any({ title: 'Config' }))
|
|
7
10
|
});
|
|
8
11
|
export const AuthorizationModelSpec = entityUtils.getModelSpec(AuthorizationSchema, { isAuditable: true });
|
|
12
|
+
export const PublicAuthorizationSchema = Type.Object({
|
|
13
|
+
role: Type.String({ minLength: 1, title: 'Role Name' }),
|
|
14
|
+
feature: Type.String({ minLength: 1, title: 'Feature Name' }),
|
|
15
|
+
config: Type.Optional(Type.Any({ title: 'Config' }))
|
|
16
|
+
});
|
|
17
|
+
export const PublicAuthorizationModelSpec = entityUtils.getModelSpec(PublicAuthorizationSchema);
|
|
@@ -25,16 +25,11 @@ export function initializeSystemUserContext(systemEmail, metaOrgId) {
|
|
|
25
25
|
lastName: 'User',
|
|
26
26
|
displayName: 'System User',
|
|
27
27
|
email: systemEmail,
|
|
28
|
-
password: '',
|
|
29
28
|
authorizations: [{
|
|
30
29
|
_id: 'system-authorization',
|
|
31
30
|
_orgId: metaOrgId,
|
|
32
31
|
role: 'system',
|
|
33
32
|
feature: 'system',
|
|
34
|
-
_created: new Date(),
|
|
35
|
-
_createdBy: 'system',
|
|
36
|
-
_updated: new Date(),
|
|
37
|
-
_updatedBy: 'system',
|
|
38
33
|
}],
|
|
39
34
|
_created: new Date(),
|
|
40
35
|
_createdBy: 'system',
|
|
@@ -1,43 +1,55 @@
|
|
|
1
1
|
import { IAuditable } from './auditable.model.js';
|
|
2
2
|
import { IEntity } from './entity.model.js';
|
|
3
|
-
import {
|
|
4
|
-
export interface
|
|
3
|
+
import { IAuthorizationOut } from './authorization.model.js';
|
|
4
|
+
export interface IUserBase extends IEntity, IAuditable {
|
|
5
5
|
email: string;
|
|
6
6
|
firstName?: string;
|
|
7
7
|
lastName?: string;
|
|
8
8
|
displayName?: string;
|
|
9
|
-
password: string;
|
|
10
|
-
authorizations?: IAuthorization[];
|
|
11
9
|
_lastLoggedIn?: Date;
|
|
12
10
|
_lastPasswordChange?: Date;
|
|
13
11
|
}
|
|
12
|
+
export interface IUserIn extends IUserBase {
|
|
13
|
+
password?: string;
|
|
14
|
+
}
|
|
14
15
|
export declare const UserPasswordSchema: import("@sinclair/typebox").TObject<{
|
|
15
16
|
password: import("@sinclair/typebox").TString;
|
|
16
17
|
}>;
|
|
17
18
|
export declare const passwordValidator: import("@sinclair/typebox/compiler").TypeCheck<import("@sinclair/typebox").TObject<{
|
|
18
19
|
password: import("@sinclair/typebox").TString;
|
|
19
20
|
}>>;
|
|
21
|
+
export declare const UserSchemaBase: import("@sinclair/typebox").TObject<{
|
|
22
|
+
email: import("@sinclair/typebox").TString;
|
|
23
|
+
firstName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
24
|
+
lastName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
25
|
+
displayName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
26
|
+
_lastLoggedIn: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TString, Date>>;
|
|
27
|
+
_lastPasswordChange: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TString, Date>>;
|
|
28
|
+
}>;
|
|
20
29
|
export declare const UserSchema: import("@sinclair/typebox").TObject<{
|
|
21
30
|
email: import("@sinclair/typebox").TString;
|
|
22
31
|
firstName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
23
32
|
lastName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
24
33
|
displayName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
25
|
-
password: import("@sinclair/typebox").TString;
|
|
26
34
|
_lastLoggedIn: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TString, Date>>;
|
|
27
35
|
_lastPasswordChange: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TString, Date>>;
|
|
36
|
+
password: import("@sinclair/typebox").TString;
|
|
28
37
|
}>;
|
|
29
38
|
export declare const UserSpec: import("./model-spec.interface.js").IModelSpec<import("@sinclair/typebox").TSchema>;
|
|
39
|
+
export interface IUserOut extends IUserBase {
|
|
40
|
+
authorizations?: IAuthorizationOut[];
|
|
41
|
+
}
|
|
30
42
|
export declare const PublicUserSchema: import("@sinclair/typebox").TObject<{
|
|
31
43
|
email: import("@sinclair/typebox").TString;
|
|
32
44
|
firstName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
33
45
|
lastName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
34
46
|
displayName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
47
|
+
_lastLoggedIn: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TString, Date>>;
|
|
48
|
+
_lastPasswordChange: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TString, Date>>;
|
|
35
49
|
authorizations: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
36
50
|
role: import("@sinclair/typebox").TString;
|
|
37
51
|
feature: import("@sinclair/typebox").TString;
|
|
38
52
|
config: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TAny>;
|
|
39
53
|
}>>>;
|
|
40
|
-
_lastLoggedIn: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TString, Date>>;
|
|
41
|
-
_lastPasswordChange: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TString, Date>>;
|
|
42
54
|
}>;
|
|
43
55
|
export declare const PublicUserSpec: import("./model-spec.interface.js").IModelSpec<import("@sinclair/typebox").TSchema>;
|
|
@@ -2,7 +2,7 @@ import { 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 {
|
|
5
|
+
import { PublicAuthorizationSchema } from './authorization.model.js';
|
|
6
6
|
export const UserPasswordSchema = Type.Object({
|
|
7
7
|
password: Type.String({
|
|
8
8
|
title: 'Password',
|
|
@@ -11,7 +11,7 @@ export const UserPasswordSchema = Type.Object({
|
|
|
11
11
|
}),
|
|
12
12
|
});
|
|
13
13
|
export const passwordValidator = TypeCompiler.Compile(UserPasswordSchema);
|
|
14
|
-
export const
|
|
14
|
+
export const UserSchemaBase = Type.Object({
|
|
15
15
|
email: Type.String({
|
|
16
16
|
title: 'Email',
|
|
17
17
|
format: 'email'
|
|
@@ -25,27 +25,20 @@ export const UserSchema = Type.Object({
|
|
|
25
25
|
displayName: Type.Optional(Type.String({
|
|
26
26
|
title: 'Display Name'
|
|
27
27
|
})),
|
|
28
|
-
password: UserPasswordSchema.properties.password,
|
|
29
28
|
_lastLoggedIn: Type.Optional(TypeboxIsoDate({ title: 'Last Login Date' })),
|
|
30
29
|
_lastPasswordChange: Type.Optional(TypeboxIsoDate({ title: 'Last Password Change Date' })),
|
|
31
30
|
});
|
|
31
|
+
export const UserSchema = Type.Composite([
|
|
32
|
+
UserSchemaBase,
|
|
33
|
+
Type.Object({
|
|
34
|
+
password: UserPasswordSchema.properties.password,
|
|
35
|
+
})
|
|
36
|
+
]);
|
|
32
37
|
export const UserSpec = entityUtils.getModelSpec(UserSchema, { isAuditable: true });
|
|
33
|
-
export const PublicUserSchema = Type.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
title: 'First Name'
|
|
40
|
-
})),
|
|
41
|
-
lastName: Type.Optional(Type.String({
|
|
42
|
-
title: 'Last Name'
|
|
43
|
-
})),
|
|
44
|
-
displayName: Type.Optional(Type.String({
|
|
45
|
-
title: 'Display Name'
|
|
46
|
-
})),
|
|
47
|
-
authorizations: Type.Optional(Type.Array(AuthorizationSchema)),
|
|
48
|
-
_lastLoggedIn: Type.Optional(TypeboxIsoDate({ title: 'Last Login Date' })),
|
|
49
|
-
_lastPasswordChange: Type.Optional(TypeboxIsoDate({ title: 'Last Password Change Date' })),
|
|
50
|
-
});
|
|
38
|
+
export const PublicUserSchema = Type.Composite([
|
|
39
|
+
UserSchemaBase,
|
|
40
|
+
Type.Object({
|
|
41
|
+
authorizations: Type.Optional(Type.Array(PublicAuthorizationSchema, { title: 'Authorizations' })),
|
|
42
|
+
})
|
|
43
|
+
]);
|
|
51
44
|
export const PublicUserSpec = entityUtils.getModelSpec(PublicUserSchema, { isAuditable: true });
|
package/package.json
CHANGED