@temboplus/afloat 0.1.77-beta.2 → 0.1.77-beta.20
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/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/lib/api/base-repository.d.ts +3 -1
- package/dist/lib/query/query.builder.d.ts +5 -1
- package/dist/modules/auth/auth.contract.d.ts +2 -2
- package/dist/modules/auth/company-membership.model.d.ts +122 -9
- package/dist/modules/auth/index.d.ts +0 -1
- package/dist/modules/auth/user.model.d.ts +238 -15
- package/dist/modules/contact/contact-info.model.d.ts +183 -533
- package/dist/modules/contact/contact.api-contract.d.ts +8 -8
- package/dist/modules/contact/contact.dtos.d.ts +2 -2
- package/dist/modules/contact/contact.model.d.ts +309 -32
- package/dist/modules/login/login.api-contract.d.ts +2 -2
- package/dist/modules/login/login.dtos.d.ts +4 -4
- package/dist/modules/login/login.model.d.ts +54 -24
- package/dist/modules/payout/payout.api-contract.d.ts +37 -37
- package/dist/modules/payout/payout.dtos.d.ts +47 -39
- package/dist/modules/payout/payout.model.d.ts +242 -2
- package/dist/modules/payout/payout.query.d.ts +11 -3
- package/dist/modules/payout/payout.repository.d.ts +48 -25
- package/dist/modules/profile/profile.model.d.ts +65 -30
- package/dist/modules/team-member/role.model.d.ts +49 -1
- package/dist/modules/team-member/team-member.contract.d.ts +44 -44
- package/dist/modules/team-member/team-member.dtos.d.ts +14 -14
- package/dist/modules/team-member/team-member.model.d.ts +106 -6
- package/dist/modules/wallet/index.d.ts +0 -1
- package/dist/modules/wallet/narration.model.d.ts +34 -38
- package/dist/modules/wallet/statement-entry.model.d.ts +172 -73
- package/dist/modules/wallet/wallet.contract.d.ts +6 -6
- package/dist/modules/wallet/wallet.dtos.d.ts +12 -12
- package/dist/modules/wallet/wallet.model.d.ts +56 -19
- package/dist/modules/wallet/wallet.query.d.ts +95 -0
- package/dist/modules/wallet/wallet.repository.d.ts +45 -13
- package/package.json +2 -2
- package/dist/modules/auth/auth.manager.d.ts +0 -249
- package/dist/modules/auth/auth.store.d.ts +0 -139
- package/dist/modules/auth/storage/client-store.d.ts +0 -29
- package/dist/modules/auth/storage/client-token-handler.d.ts +0 -31
- package/dist/modules/auth/storage/types.d.ts +0 -41
- package/dist/modules/wallet/wallet-manager.session.d.ts +0 -143
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AppRouter } from "@ts-rest/core";
|
|
2
2
|
import { InitClientArgs } from "@ts-rest/core";
|
|
3
|
+
export type TokenGetter = () => string | undefined;
|
|
4
|
+
export declare const setGlobalTokenGetter: (getter: TokenGetter) => void;
|
|
3
5
|
/**
|
|
4
6
|
* BaseRepository - Generic base class for API repositories
|
|
5
7
|
*
|
|
@@ -75,7 +77,7 @@ export declare class BaseRepository<TContract extends AppRouter> {
|
|
|
75
77
|
*
|
|
76
78
|
* Uses a fallback chain to find a valid token:
|
|
77
79
|
* 1. Instance token (set in constructor)
|
|
78
|
-
* 2. Global
|
|
80
|
+
* 2. Global token getter (set by host app)
|
|
79
81
|
* 3. Return an empty string if no token is found (e.g., for public/unauthenticated endpoints)
|
|
80
82
|
*
|
|
81
83
|
* @protected
|
|
@@ -27,7 +27,11 @@ export declare class QueryBuilder {
|
|
|
27
27
|
whereLessThan(field: string, value: any): this;
|
|
28
28
|
whereLessThanOrEqual(field: string, value: any): this;
|
|
29
29
|
whereBetween(field: string, min: any, max: any): this;
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Filter by date range with support for Date objects, strings, and null
|
|
32
|
+
* Internally converts to createdAt:gte and createdAt:lte filters
|
|
33
|
+
*/
|
|
34
|
+
whereDateBetween(startDate?: string | Date | null, endDate?: string | Date | null): this;
|
|
31
35
|
addSort(criteria: SortCriteria): this;
|
|
32
36
|
orderBy(field: string, direction?: SortDirection): this;
|
|
33
37
|
orderByAsc(field: string): this;
|
|
@@ -53,6 +53,7 @@ export declare const authContract: {
|
|
|
53
53
|
access: z.ZodArray<z.ZodString, "many">;
|
|
54
54
|
resetPassword: z.ZodBoolean;
|
|
55
55
|
}, "strip", z.ZodTypeAny, {
|
|
56
|
+
token: string;
|
|
56
57
|
resetPassword: boolean;
|
|
57
58
|
access: string[];
|
|
58
59
|
profile: {
|
|
@@ -65,8 +66,8 @@ export declare const authContract: {
|
|
|
65
66
|
email?: string | null | undefined;
|
|
66
67
|
autoApprove?: boolean | null | undefined;
|
|
67
68
|
};
|
|
68
|
-
token: string;
|
|
69
69
|
}, {
|
|
70
|
+
token: string;
|
|
70
71
|
resetPassword: boolean;
|
|
71
72
|
access: string[];
|
|
72
73
|
profile: {
|
|
@@ -79,7 +80,6 @@ export declare const authContract: {
|
|
|
79
80
|
email?: string | null | undefined;
|
|
80
81
|
autoApprove?: boolean | null | undefined;
|
|
81
82
|
};
|
|
82
|
-
token: string;
|
|
83
83
|
}>;
|
|
84
84
|
400: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
85
85
|
};
|
|
@@ -1,9 +1,117 @@
|
|
|
1
|
+
import z from "zod";
|
|
1
2
|
import { Profile } from "../profile/profile.model.js";
|
|
2
3
|
import { Role } from "../team-member/role.model.js";
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Zod schema for CompanyMembership JSON serialization
|
|
6
|
+
*/
|
|
7
|
+
export declare const CompanyMembershipJSONSchema: z.ZodObject<{
|
|
8
|
+
companyProfile: z.ZodObject<{
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
firstName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
11
|
+
lastName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
12
|
+
displayName: z.ZodString;
|
|
13
|
+
phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
14
|
+
accountNo: z.ZodString;
|
|
15
|
+
email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
16
|
+
autoApprove: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
17
|
+
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
id: string;
|
|
20
|
+
displayName: string;
|
|
21
|
+
accountNo: string;
|
|
22
|
+
version: string;
|
|
23
|
+
firstName?: string | null | undefined;
|
|
24
|
+
lastName?: string | null | undefined;
|
|
25
|
+
phone?: string | null | undefined;
|
|
26
|
+
email?: string | null | undefined;
|
|
27
|
+
autoApprove?: boolean | null | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
id: string;
|
|
30
|
+
displayName: string;
|
|
31
|
+
accountNo: string;
|
|
32
|
+
firstName?: string | null | undefined;
|
|
33
|
+
lastName?: string | null | undefined;
|
|
34
|
+
phone?: string | null | undefined;
|
|
35
|
+
email?: string | null | undefined;
|
|
36
|
+
autoApprove?: boolean | null | undefined;
|
|
37
|
+
version?: string | undefined;
|
|
38
|
+
}>;
|
|
39
|
+
role: z.ZodOptional<z.ZodObject<{
|
|
40
|
+
id: z.ZodString;
|
|
41
|
+
name: z.ZodString;
|
|
42
|
+
description: z.ZodOptional<z.ZodString>;
|
|
43
|
+
access: z.ZodArray<z.ZodString, "many">;
|
|
44
|
+
createdAt: z.ZodString;
|
|
45
|
+
updatedAt: z.ZodString;
|
|
46
|
+
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
name: string;
|
|
49
|
+
createdAt: string;
|
|
50
|
+
id: string;
|
|
51
|
+
version: string;
|
|
52
|
+
updatedAt: string;
|
|
53
|
+
access: string[];
|
|
54
|
+
description?: string | undefined;
|
|
55
|
+
}, {
|
|
56
|
+
name: string;
|
|
57
|
+
createdAt: string;
|
|
58
|
+
id: string;
|
|
59
|
+
updatedAt: string;
|
|
60
|
+
access: string[];
|
|
61
|
+
version?: string | undefined;
|
|
62
|
+
description?: string | undefined;
|
|
63
|
+
}>>;
|
|
64
|
+
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
version: string;
|
|
67
|
+
companyProfile: {
|
|
68
|
+
id: string;
|
|
69
|
+
displayName: string;
|
|
70
|
+
accountNo: string;
|
|
71
|
+
version: string;
|
|
72
|
+
firstName?: string | null | undefined;
|
|
73
|
+
lastName?: string | null | undefined;
|
|
74
|
+
phone?: string | null | undefined;
|
|
75
|
+
email?: string | null | undefined;
|
|
76
|
+
autoApprove?: boolean | null | undefined;
|
|
77
|
+
};
|
|
78
|
+
role?: {
|
|
79
|
+
name: string;
|
|
80
|
+
createdAt: string;
|
|
81
|
+
id: string;
|
|
82
|
+
version: string;
|
|
83
|
+
updatedAt: string;
|
|
84
|
+
access: string[];
|
|
85
|
+
description?: string | undefined;
|
|
86
|
+
} | undefined;
|
|
87
|
+
}, {
|
|
88
|
+
companyProfile: {
|
|
89
|
+
id: string;
|
|
90
|
+
displayName: string;
|
|
91
|
+
accountNo: string;
|
|
92
|
+
firstName?: string | null | undefined;
|
|
93
|
+
lastName?: string | null | undefined;
|
|
94
|
+
phone?: string | null | undefined;
|
|
95
|
+
email?: string | null | undefined;
|
|
96
|
+
autoApprove?: boolean | null | undefined;
|
|
97
|
+
version?: string | undefined;
|
|
98
|
+
};
|
|
99
|
+
version?: string | undefined;
|
|
100
|
+
role?: {
|
|
101
|
+
name: string;
|
|
102
|
+
createdAt: string;
|
|
103
|
+
id: string;
|
|
104
|
+
updatedAt: string;
|
|
105
|
+
access: string[];
|
|
106
|
+
version?: string | undefined;
|
|
107
|
+
description?: string | undefined;
|
|
108
|
+
} | undefined;
|
|
109
|
+
}>;
|
|
110
|
+
export type CompanyMembershipJSON = z.infer<typeof CompanyMembershipJSONSchema>;
|
|
111
|
+
export type CompanyMembershipData = {
|
|
4
112
|
companyProfile: Profile;
|
|
5
113
|
role?: Role;
|
|
6
|
-
}
|
|
114
|
+
};
|
|
7
115
|
/**
|
|
8
116
|
* Represents a user's membership within a company.
|
|
9
117
|
*
|
|
@@ -45,14 +153,19 @@ export declare class CompanyMembership {
|
|
|
45
153
|
*/
|
|
46
154
|
get role(): Role | undefined;
|
|
47
155
|
/**
|
|
48
|
-
|
|
156
|
+
* Serializes the CompanyMembership instance to a JSON-compatible object
|
|
157
|
+
*/
|
|
158
|
+
toJSON(): CompanyMembershipJSON;
|
|
159
|
+
/**
|
|
160
|
+
* Serializes the CompanyMembership instance to a JSON string
|
|
49
161
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
162
|
+
toJSONString(): string;
|
|
163
|
+
/**
|
|
164
|
+
* Creates a CompanyMembership instance from a JSON-compatible object or string
|
|
165
|
+
*/
|
|
166
|
+
static fromJSON(json: CompanyMembershipJSON | string): CompanyMembership | undefined;
|
|
54
167
|
/**
|
|
55
|
-
*
|
|
168
|
+
* Type guard using Zod schema validation
|
|
56
169
|
*/
|
|
57
|
-
|
|
170
|
+
static isCompanyMembershipJSON(obj: unknown): obj is CompanyMembershipJSON;
|
|
58
171
|
}
|
|
@@ -3,12 +3,200 @@ import { Profile } from "../profile/profile.model.js";
|
|
|
3
3
|
import { LogIn } from "../login/login.model.js";
|
|
4
4
|
import { CompanyMembership } from "./company-membership.model.js";
|
|
5
5
|
import { Role } from "../team-member/role.model.js";
|
|
6
|
-
|
|
6
|
+
import z from "zod";
|
|
7
|
+
/**
|
|
8
|
+
* Zod schema for User JSON serialization
|
|
9
|
+
* Composes the schemas from nested objects
|
|
10
|
+
*/
|
|
11
|
+
export declare const UserJSONSchema: z.ZodObject<{
|
|
12
|
+
logIn: z.ZodObject<{
|
|
13
|
+
id: z.ZodString;
|
|
14
|
+
profileId: z.ZodString;
|
|
15
|
+
name: z.ZodString;
|
|
16
|
+
identity: z.ZodString;
|
|
17
|
+
type: z.ZodString;
|
|
18
|
+
roleId: z.ZodString;
|
|
19
|
+
isActive: z.ZodBoolean;
|
|
20
|
+
isArchived: z.ZodBoolean;
|
|
21
|
+
resetPassword: z.ZodBoolean;
|
|
22
|
+
createdAt: z.ZodString;
|
|
23
|
+
updatedAt: z.ZodString;
|
|
24
|
+
access: z.ZodArray<z.ZodString, "many">;
|
|
25
|
+
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
type: string;
|
|
28
|
+
name: string;
|
|
29
|
+
createdAt: string;
|
|
30
|
+
id: string;
|
|
31
|
+
version: string;
|
|
32
|
+
profileId: string;
|
|
33
|
+
identity: string;
|
|
34
|
+
roleId: string;
|
|
35
|
+
isActive: boolean;
|
|
36
|
+
isArchived: boolean;
|
|
37
|
+
resetPassword: boolean;
|
|
38
|
+
updatedAt: string;
|
|
39
|
+
access: string[];
|
|
40
|
+
}, {
|
|
41
|
+
type: string;
|
|
42
|
+
name: string;
|
|
43
|
+
createdAt: string;
|
|
44
|
+
id: string;
|
|
45
|
+
profileId: string;
|
|
46
|
+
identity: string;
|
|
47
|
+
roleId: string;
|
|
48
|
+
isActive: boolean;
|
|
49
|
+
isArchived: boolean;
|
|
50
|
+
resetPassword: boolean;
|
|
51
|
+
updatedAt: string;
|
|
52
|
+
access: string[];
|
|
53
|
+
version?: string | undefined;
|
|
54
|
+
}>;
|
|
55
|
+
companyProfile: z.ZodObject<{
|
|
56
|
+
id: z.ZodString;
|
|
57
|
+
firstName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
58
|
+
lastName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
59
|
+
displayName: z.ZodString;
|
|
60
|
+
phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
61
|
+
accountNo: z.ZodString;
|
|
62
|
+
email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
63
|
+
autoApprove: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
64
|
+
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
id: string;
|
|
67
|
+
displayName: string;
|
|
68
|
+
accountNo: string;
|
|
69
|
+
version: string;
|
|
70
|
+
firstName?: string | null | undefined;
|
|
71
|
+
lastName?: string | null | undefined;
|
|
72
|
+
phone?: string | null | undefined;
|
|
73
|
+
email?: string | null | undefined;
|
|
74
|
+
autoApprove?: boolean | null | undefined;
|
|
75
|
+
}, {
|
|
76
|
+
id: string;
|
|
77
|
+
displayName: string;
|
|
78
|
+
accountNo: string;
|
|
79
|
+
firstName?: string | null | undefined;
|
|
80
|
+
lastName?: string | null | undefined;
|
|
81
|
+
phone?: string | null | undefined;
|
|
82
|
+
email?: string | null | undefined;
|
|
83
|
+
autoApprove?: boolean | null | undefined;
|
|
84
|
+
version?: string | undefined;
|
|
85
|
+
}>;
|
|
86
|
+
role: z.ZodOptional<z.ZodObject<{
|
|
87
|
+
id: z.ZodString;
|
|
88
|
+
name: z.ZodString;
|
|
89
|
+
description: z.ZodOptional<z.ZodString>;
|
|
90
|
+
access: z.ZodArray<z.ZodString, "many">;
|
|
91
|
+
createdAt: z.ZodString;
|
|
92
|
+
updatedAt: z.ZodString;
|
|
93
|
+
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
94
|
+
}, "strip", z.ZodTypeAny, {
|
|
95
|
+
name: string;
|
|
96
|
+
createdAt: string;
|
|
97
|
+
id: string;
|
|
98
|
+
version: string;
|
|
99
|
+
updatedAt: string;
|
|
100
|
+
access: string[];
|
|
101
|
+
description?: string | undefined;
|
|
102
|
+
}, {
|
|
103
|
+
name: string;
|
|
104
|
+
createdAt: string;
|
|
105
|
+
id: string;
|
|
106
|
+
updatedAt: string;
|
|
107
|
+
access: string[];
|
|
108
|
+
version?: string | undefined;
|
|
109
|
+
description?: string | undefined;
|
|
110
|
+
}>>;
|
|
111
|
+
token: z.ZodString;
|
|
112
|
+
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
113
|
+
}, "strip", z.ZodTypeAny, {
|
|
114
|
+
token: string;
|
|
115
|
+
version: string;
|
|
116
|
+
companyProfile: {
|
|
117
|
+
id: string;
|
|
118
|
+
displayName: string;
|
|
119
|
+
accountNo: string;
|
|
120
|
+
version: string;
|
|
121
|
+
firstName?: string | null | undefined;
|
|
122
|
+
lastName?: string | null | undefined;
|
|
123
|
+
phone?: string | null | undefined;
|
|
124
|
+
email?: string | null | undefined;
|
|
125
|
+
autoApprove?: boolean | null | undefined;
|
|
126
|
+
};
|
|
127
|
+
logIn: {
|
|
128
|
+
type: string;
|
|
129
|
+
name: string;
|
|
130
|
+
createdAt: string;
|
|
131
|
+
id: string;
|
|
132
|
+
version: string;
|
|
133
|
+
profileId: string;
|
|
134
|
+
identity: string;
|
|
135
|
+
roleId: string;
|
|
136
|
+
isActive: boolean;
|
|
137
|
+
isArchived: boolean;
|
|
138
|
+
resetPassword: boolean;
|
|
139
|
+
updatedAt: string;
|
|
140
|
+
access: string[];
|
|
141
|
+
};
|
|
142
|
+
role?: {
|
|
143
|
+
name: string;
|
|
144
|
+
createdAt: string;
|
|
145
|
+
id: string;
|
|
146
|
+
version: string;
|
|
147
|
+
updatedAt: string;
|
|
148
|
+
access: string[];
|
|
149
|
+
description?: string | undefined;
|
|
150
|
+
} | undefined;
|
|
151
|
+
}, {
|
|
152
|
+
token: string;
|
|
153
|
+
companyProfile: {
|
|
154
|
+
id: string;
|
|
155
|
+
displayName: string;
|
|
156
|
+
accountNo: string;
|
|
157
|
+
firstName?: string | null | undefined;
|
|
158
|
+
lastName?: string | null | undefined;
|
|
159
|
+
phone?: string | null | undefined;
|
|
160
|
+
email?: string | null | undefined;
|
|
161
|
+
autoApprove?: boolean | null | undefined;
|
|
162
|
+
version?: string | undefined;
|
|
163
|
+
};
|
|
164
|
+
logIn: {
|
|
165
|
+
type: string;
|
|
166
|
+
name: string;
|
|
167
|
+
createdAt: string;
|
|
168
|
+
id: string;
|
|
169
|
+
profileId: string;
|
|
170
|
+
identity: string;
|
|
171
|
+
roleId: string;
|
|
172
|
+
isActive: boolean;
|
|
173
|
+
isArchived: boolean;
|
|
174
|
+
resetPassword: boolean;
|
|
175
|
+
updatedAt: string;
|
|
176
|
+
access: string[];
|
|
177
|
+
version?: string | undefined;
|
|
178
|
+
};
|
|
179
|
+
version?: string | undefined;
|
|
180
|
+
role?: {
|
|
181
|
+
name: string;
|
|
182
|
+
createdAt: string;
|
|
183
|
+
id: string;
|
|
184
|
+
updatedAt: string;
|
|
185
|
+
access: string[];
|
|
186
|
+
version?: string | undefined;
|
|
187
|
+
description?: string | undefined;
|
|
188
|
+
} | undefined;
|
|
189
|
+
}>;
|
|
190
|
+
/**
|
|
191
|
+
* Infer the UserJSON type from the schema
|
|
192
|
+
*/
|
|
193
|
+
export type UserJSON = z.infer<typeof UserJSONSchema>;
|
|
194
|
+
export type UserData = {
|
|
7
195
|
logIn: LogIn;
|
|
8
196
|
companyProfile: Profile;
|
|
9
197
|
role?: Role;
|
|
10
198
|
token: string;
|
|
11
|
-
}
|
|
199
|
+
};
|
|
12
200
|
/**
|
|
13
201
|
* Represents the currently authenticated user session.
|
|
14
202
|
*
|
|
@@ -45,13 +233,6 @@ export declare class User {
|
|
|
45
233
|
* ```
|
|
46
234
|
*/
|
|
47
235
|
static from(data: UserData): User | undefined;
|
|
48
|
-
/**
|
|
49
|
-
* Creates a User instance from a JSON string.
|
|
50
|
-
*
|
|
51
|
-
* @param jsonString - JSON string containing user data
|
|
52
|
-
* @returns A new User instance, or undefined if parsing failed
|
|
53
|
-
*/
|
|
54
|
-
static fromJson(jsonString: string): User | undefined;
|
|
55
236
|
/**
|
|
56
237
|
* Gets the user's login data.
|
|
57
238
|
*/
|
|
@@ -126,15 +307,57 @@ export declare class User {
|
|
|
126
307
|
*/
|
|
127
308
|
canViewRoles(): boolean;
|
|
128
309
|
/**
|
|
129
|
-
|
|
310
|
+
* Serializes the User instance to a JSON-compatible object
|
|
311
|
+
*
|
|
312
|
+
* This method creates a complete snapshot of the user session including
|
|
313
|
+
* all nested objects (LogIn, Profile, Role). All data can be reconstructed
|
|
314
|
+
* from this JSON representation without needing backend calls.
|
|
315
|
+
*
|
|
316
|
+
* @returns {UserJSON} A plain object containing all necessary User data
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* ```typescript
|
|
320
|
+
* const user = User.from({ ... });
|
|
321
|
+
* const json = user.toJSON();
|
|
322
|
+
* // Store in localStorage
|
|
323
|
+
* localStorage.setItem('currentUser', JSON.stringify(json));
|
|
324
|
+
* ```
|
|
325
|
+
*/
|
|
326
|
+
toJSON(): UserJSON;
|
|
327
|
+
/**
|
|
328
|
+
* Serializes the User instance to a JSON string
|
|
130
329
|
*
|
|
131
|
-
* @returns
|
|
330
|
+
* @returns {string} JSON string representation of the User
|
|
132
331
|
*/
|
|
133
|
-
|
|
332
|
+
toJSONString(): string;
|
|
134
333
|
/**
|
|
135
|
-
*
|
|
334
|
+
* Creates a User instance from a JSON-compatible object or string
|
|
335
|
+
*
|
|
336
|
+
* This static method reconstructs a complete User instance from data that was
|
|
337
|
+
* previously serialized using toJSON(). It validates the input data and
|
|
338
|
+
* ensures all nested objects (LogIn, Profile, Role) are properly reconstructed.
|
|
339
|
+
*
|
|
340
|
+
* @param {UserJSON | string} json - Either a UserJSON object or a JSON string
|
|
341
|
+
* @returns {User | undefined} A User instance if valid, undefined otherwise
|
|
136
342
|
*
|
|
137
|
-
* @
|
|
343
|
+
* @example
|
|
344
|
+
* ```typescript
|
|
345
|
+
* // From localStorage
|
|
346
|
+
* const stored = localStorage.getItem('currentUser');
|
|
347
|
+
* const user = User.fromJSON(stored!);
|
|
348
|
+
*
|
|
349
|
+
* // From object
|
|
350
|
+
* const userJson = {
|
|
351
|
+
* logIn: { id: "...", ... },
|
|
352
|
+
* companyProfile: { id: "...", ... },
|
|
353
|
+
* token: "..."
|
|
354
|
+
* };
|
|
355
|
+
* const user = User.fromJSON(userJson);
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
358
|
+
static fromJSON(json: UserJSON | string): User | undefined;
|
|
359
|
+
/**
|
|
360
|
+
* Type guard using Zod schema validation
|
|
138
361
|
*/
|
|
139
|
-
|
|
362
|
+
static isUserJSON(obj: unknown): obj is UserJSON;
|
|
140
363
|
}
|