@loomcore/common 0.0.43 → 0.0.45
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/email-address.model.d.ts +15 -0
- package/dist/models/email-address.model.js +11 -0
- package/dist/models/person.model.d.ts +24 -0
- package/dist/models/person.model.js +14 -0
- package/dist/models/phone-number.model.d.ts +12 -0
- package/dist/models/phone-number.model.js +8 -0
- package/dist/models/user-context.model.js +1 -2
- package/dist/models/user.model.d.ts +7 -6
- package/dist/models/user.model.js +5 -8
- package/package.json +51 -51
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IAuditable, IEntity } from "@loomcore/common/models";
|
|
2
|
+
import { AppIdType } from "../types/app.types.js";
|
|
3
|
+
export interface IEmailAddressModel extends IEntity, IAuditable {
|
|
4
|
+
personId: AppIdType;
|
|
5
|
+
emailAddress: string;
|
|
6
|
+
emailAddressType: string;
|
|
7
|
+
isDefault: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const emailAddressSchema: import("@sinclair/typebox").TObject<{
|
|
10
|
+
personId: import("@sinclair/typebox").TSchema;
|
|
11
|
+
emailAddress: import("@sinclair/typebox").TString;
|
|
12
|
+
emailAddressType: import("@sinclair/typebox").TString;
|
|
13
|
+
isDefault: import("@sinclair/typebox").TBoolean;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const emailAddressModelSpec: import("@loomcore/common/models").IModelSpec<import("@sinclair/typebox").TSchema>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { entityUtils } from "@loomcore/common/utils";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
|
+
import { getIdSchema } from "../validation/index.js";
|
|
4
|
+
const idSchema = getIdSchema();
|
|
5
|
+
export const emailAddressSchema = Type.Object({
|
|
6
|
+
personId: idSchema,
|
|
7
|
+
emailAddress: Type.String(),
|
|
8
|
+
emailAddressType: Type.String(),
|
|
9
|
+
isDefault: Type.Boolean(),
|
|
10
|
+
});
|
|
11
|
+
export const emailAddressModelSpec = entityUtils.getModelSpec(emailAddressSchema, { isAuditable: true });
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { IAuditable, IEntity } from "@loomcore/common/models";
|
|
2
|
+
export interface IPersonModel extends IEntity, IAuditable {
|
|
3
|
+
externalId: string | null;
|
|
4
|
+
firstName: string;
|
|
5
|
+
middleName: string | null;
|
|
6
|
+
lastName: string;
|
|
7
|
+
isAgent: boolean;
|
|
8
|
+
isClient: boolean;
|
|
9
|
+
isEmployee: boolean;
|
|
10
|
+
dateOfBirth: Date | null;
|
|
11
|
+
extendedTypes: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const personSchema: import("@sinclair/typebox").TObject<{
|
|
14
|
+
externalId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
15
|
+
firstName: import("@sinclair/typebox").TString;
|
|
16
|
+
middleName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
17
|
+
lastName: import("@sinclair/typebox").TString;
|
|
18
|
+
isAgent: import("@sinclair/typebox").TBoolean;
|
|
19
|
+
isClient: import("@sinclair/typebox").TBoolean;
|
|
20
|
+
isEmployee: import("@sinclair/typebox").TBoolean;
|
|
21
|
+
dateOfBirth: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
22
|
+
extendedTypes: import("@sinclair/typebox").TNumber;
|
|
23
|
+
}>;
|
|
24
|
+
export declare const personModelSpec: import("@loomcore/common/models").IModelSpec<import("@sinclair/typebox").TSchema>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { entityUtils } from "@loomcore/common/utils";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
|
+
export const personSchema = Type.Object({
|
|
4
|
+
externalId: Type.Optional(Type.String()),
|
|
5
|
+
firstName: Type.String(),
|
|
6
|
+
middleName: Type.Optional(Type.String()),
|
|
7
|
+
lastName: Type.String(),
|
|
8
|
+
isAgent: Type.Boolean(),
|
|
9
|
+
isClient: Type.Boolean(),
|
|
10
|
+
isEmployee: Type.Boolean(),
|
|
11
|
+
dateOfBirth: Type.Optional(Type.String()),
|
|
12
|
+
extendedTypes: Type.Number(),
|
|
13
|
+
});
|
|
14
|
+
export const personModelSpec = entityUtils.getModelSpec(personSchema, { isAuditable: true });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IAuditable, IEntity } from "@loomcore/common/models";
|
|
2
|
+
export interface IPhoneNumberModel extends IEntity, IAuditable {
|
|
3
|
+
phoneNumber: string;
|
|
4
|
+
phoneNumberType: string;
|
|
5
|
+
isDefault: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const phoneNumberSchema: import("@sinclair/typebox").TObject<{
|
|
8
|
+
phoneNumber: import("@sinclair/typebox").TString;
|
|
9
|
+
phoneNumberType: import("@sinclair/typebox").TString;
|
|
10
|
+
isDefault: import("@sinclair/typebox").TBoolean;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const phoneNumberModelSpec: import("@loomcore/common/models").IModelSpec<import("@sinclair/typebox").TSchema>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { entityUtils } from "@loomcore/common/utils";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
|
+
export const phoneNumberSchema = Type.Object({
|
|
4
|
+
phoneNumber: Type.String(),
|
|
5
|
+
phoneNumberType: Type.String(),
|
|
6
|
+
isDefault: Type.Boolean(),
|
|
7
|
+
});
|
|
8
|
+
export const phoneNumberModelSpec = entityUtils.getModelSpec(phoneNumberSchema, { isAuditable: true });
|
|
@@ -28,9 +28,8 @@ export function initializeSystemUserContext(systemEmail, metaOrg) {
|
|
|
28
28
|
user: {
|
|
29
29
|
_id: systemId,
|
|
30
30
|
_orgId: metaOrg?._id,
|
|
31
|
+
externalId: 'system',
|
|
31
32
|
email: systemEmail,
|
|
32
|
-
firstName: 'System',
|
|
33
|
-
lastName: 'User',
|
|
34
33
|
displayName: 'System User',
|
|
35
34
|
password: 'systemPassword',
|
|
36
35
|
_created: new Date(),
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { IAuditable } from './auditable.model.js';
|
|
2
2
|
import { IEntity } from './entity.model.js';
|
|
3
|
+
import { AppIdType } from '../types/app.types.js';
|
|
3
4
|
export interface IUser extends IEntity, IAuditable {
|
|
5
|
+
externalId: string | null;
|
|
4
6
|
email: string;
|
|
5
|
-
firstName?: string;
|
|
6
|
-
lastName?: string;
|
|
7
7
|
displayName?: string;
|
|
8
8
|
password: string;
|
|
9
|
+
personId?: AppIdType;
|
|
9
10
|
_lastLoggedIn?: Date;
|
|
10
11
|
_lastPasswordChange?: Date;
|
|
11
12
|
}
|
|
@@ -16,20 +17,20 @@ export declare const passwordValidator: import("@sinclair/typebox/compiler").Typ
|
|
|
16
17
|
password: import("@sinclair/typebox").TString;
|
|
17
18
|
}>>;
|
|
18
19
|
export declare const UserSchema: import("@sinclair/typebox").TObject<{
|
|
20
|
+
externalId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
19
21
|
email: import("@sinclair/typebox").TString;
|
|
20
|
-
firstName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
21
|
-
lastName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
22
22
|
displayName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
23
23
|
password: import("@sinclair/typebox").TString;
|
|
24
|
+
personId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TSchema>;
|
|
24
25
|
_lastLoggedIn: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TString, Date>>;
|
|
25
26
|
_lastPasswordChange: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TString, Date>>;
|
|
26
27
|
}>;
|
|
27
28
|
export declare const UserSpec: import("./model-spec.interface.js").IModelSpec<import("@sinclair/typebox").TSchema>;
|
|
28
29
|
export declare const PublicUserSchema: import("@sinclair/typebox").TObject<{
|
|
29
30
|
email: import("@sinclair/typebox").TString;
|
|
30
|
-
|
|
31
|
-
lastName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
31
|
+
externalId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
32
32
|
displayName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
33
|
+
personId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TSchema>;
|
|
33
34
|
_lastLoggedIn: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TString, Date>>;
|
|
34
35
|
_lastPasswordChange: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TString, Date>>;
|
|
35
36
|
}>;
|
|
@@ -1,4 +1,4 @@
|
|
|
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';
|
|
@@ -10,24 +10,21 @@ export const UserPasswordSchema = Type.Object({
|
|
|
10
10
|
}),
|
|
11
11
|
});
|
|
12
12
|
export const passwordValidator = TypeCompiler.Compile(UserPasswordSchema);
|
|
13
|
+
const idSchema = getIdSchema();
|
|
13
14
|
export const UserSchema = Type.Object({
|
|
15
|
+
externalId: Type.Optional(Type.String()),
|
|
14
16
|
email: Type.String({
|
|
15
17
|
title: 'Email',
|
|
16
18
|
format: 'email'
|
|
17
19
|
}),
|
|
18
|
-
firstName: Type.Optional(Type.String({
|
|
19
|
-
title: 'First Name'
|
|
20
|
-
})),
|
|
21
|
-
lastName: Type.Optional(Type.String({
|
|
22
|
-
title: 'Last Name'
|
|
23
|
-
})),
|
|
24
20
|
displayName: Type.Optional(Type.String({
|
|
25
21
|
title: 'Display Name'
|
|
26
22
|
})),
|
|
27
23
|
password: UserPasswordSchema.properties.password,
|
|
24
|
+
personId: Type.Optional(idSchema),
|
|
28
25
|
_lastLoggedIn: Type.Optional(TypeboxIsoDate({ title: 'Last Login Date' })),
|
|
29
26
|
_lastPasswordChange: Type.Optional(TypeboxIsoDate({ title: 'Last Password Change Date' })),
|
|
30
27
|
});
|
|
31
28
|
export const UserSpec = entityUtils.getModelSpec(UserSchema, { isAuditable: true });
|
|
32
29
|
export const PublicUserSchema = Type.Omit(UserSchema, ['password']);
|
|
33
|
-
export const PublicUserSpec = entityUtils.getModelSpec(PublicUserSchema
|
|
30
|
+
export const PublicUserSpec = entityUtils.getModelSpec(PublicUserSchema);
|
package/package.json
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@loomcore/common",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"private": false,
|
|
5
|
-
"description": "Loom Core Models- common models, interfaces, types, and utils for Loom Core. All things common to both api and client apps.",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"clean": "rm -rf dist",
|
|
8
|
-
"tsc": "tsc --project tsconfig.prod.json",
|
|
9
|
-
"build": "npm-run-all -s clean tsc",
|
|
10
|
-
"add": "git add .",
|
|
11
|
-
"commit": "git commit -m \"Updates\"",
|
|
12
|
-
"patch": "npm version patch",
|
|
13
|
-
"push": "git push",
|
|
14
|
-
"gar-login": "npx --yes google-artifactregistry-auth",
|
|
15
|
-
"publishMe": "npm publish --access public",
|
|
16
|
-
"pub": "npm-run-all -s add commit patch build push publishMe",
|
|
17
|
-
"auth-and-pub": "npm-run-all -s add commit patch build push gar-login publishMe",
|
|
18
|
-
"test": "cross-env NODE_ENV=test vitest run",
|
|
19
|
-
"test:ci": "cross-env NODE_ENV=test vitest run --reporter=json --outputFile=test-results.json",
|
|
20
|
-
"test:watch": "cross-env NODE_ENV=test vitest"
|
|
21
|
-
},
|
|
22
|
-
"keywords": [],
|
|
23
|
-
"author": "Tim Hardy",
|
|
24
|
-
"license": "Apache-2.0",
|
|
25
|
-
"main": "dist/index.js",
|
|
26
|
-
"type": "module",
|
|
27
|
-
"types": "dist/index.d.ts",
|
|
28
|
-
"files": [
|
|
29
|
-
"dist/**/*"
|
|
30
|
-
],
|
|
31
|
-
"exports": {
|
|
32
|
-
"./errors": "./dist/errors/index.js",
|
|
33
|
-
"./models": "./dist/models/index.js",
|
|
34
|
-
"./types": "./dist/types/index.js",
|
|
35
|
-
"./utils": "./dist/utils/index.js",
|
|
36
|
-
"./validation": "./dist/validation/index.js"
|
|
37
|
-
},
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"decimal.js": "^10.5.0"
|
|
40
|
-
},
|
|
41
|
-
"peerDependencies": {
|
|
42
|
-
"@types/node": "^24.10.2",
|
|
43
|
-
"@sinclair/typebox": "0.34.33"
|
|
44
|
-
},
|
|
45
|
-
"devDependencies": {
|
|
46
|
-
"cross-env": "^7.0.3",
|
|
47
|
-
"npm-run-all": "^4.1.5",
|
|
48
|
-
"typescript": "^5.8.3",
|
|
49
|
-
"vitest": "^3.0.9"
|
|
50
|
-
}
|
|
51
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@loomcore/common",
|
|
3
|
+
"version": "0.0.45",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Loom Core Models- common models, interfaces, types, and utils for Loom Core. All things common to both api and client apps.",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"clean": "rm -rf dist",
|
|
8
|
+
"tsc": "tsc --project tsconfig.prod.json",
|
|
9
|
+
"build": "npm-run-all -s clean tsc",
|
|
10
|
+
"add": "git add .",
|
|
11
|
+
"commit": "git commit -m \"Updates\"",
|
|
12
|
+
"patch": "npm version patch",
|
|
13
|
+
"push": "git push",
|
|
14
|
+
"gar-login": "npx --yes google-artifactregistry-auth",
|
|
15
|
+
"publishMe": "npm publish --access public",
|
|
16
|
+
"pub": "npm-run-all -s add commit patch build push publishMe",
|
|
17
|
+
"auth-and-pub": "npm-run-all -s add commit patch build push gar-login publishMe",
|
|
18
|
+
"test": "cross-env NODE_ENV=test vitest run",
|
|
19
|
+
"test:ci": "cross-env NODE_ENV=test vitest run --reporter=json --outputFile=test-results.json",
|
|
20
|
+
"test:watch": "cross-env NODE_ENV=test vitest"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [],
|
|
23
|
+
"author": "Tim Hardy",
|
|
24
|
+
"license": "Apache-2.0",
|
|
25
|
+
"main": "dist/index.js",
|
|
26
|
+
"type": "module",
|
|
27
|
+
"types": "dist/index.d.ts",
|
|
28
|
+
"files": [
|
|
29
|
+
"dist/**/*"
|
|
30
|
+
],
|
|
31
|
+
"exports": {
|
|
32
|
+
"./errors": "./dist/errors/index.js",
|
|
33
|
+
"./models": "./dist/models/index.js",
|
|
34
|
+
"./types": "./dist/types/index.js",
|
|
35
|
+
"./utils": "./dist/utils/index.js",
|
|
36
|
+
"./validation": "./dist/validation/index.js"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"decimal.js": "^10.5.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@types/node": "^24.10.2",
|
|
43
|
+
"@sinclair/typebox": "0.34.33"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"cross-env": "^7.0.3",
|
|
47
|
+
"npm-run-all": "^4.1.5",
|
|
48
|
+
"typescript": "^5.8.3",
|
|
49
|
+
"vitest": "^3.0.9"
|
|
50
|
+
}
|
|
51
|
+
}
|