@temboplus/afloat 0.1.77-beta.7 → 0.1.77-beta.9

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.
@@ -55,6 +55,7 @@ export declare const authContract: {
55
55
  }, "strip", z.ZodTypeAny, {
56
56
  resetPassword: boolean;
57
57
  access: string[];
58
+ token: string;
58
59
  profile: {
59
60
  id: string;
60
61
  displayName: string;
@@ -65,10 +66,10 @@ export declare const authContract: {
65
66
  email?: string | null | undefined;
66
67
  autoApprove?: boolean | null | undefined;
67
68
  };
68
- token: string;
69
69
  }, {
70
70
  resetPassword: boolean;
71
71
  access: string[];
72
+ token: string;
72
73
  profile: {
73
74
  id: string;
74
75
  displayName: string;
@@ -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
- export interface CompanyMembershipData {
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
+ id: string;
50
+ version: string;
51
+ createdAt: string;
52
+ updatedAt: string;
53
+ access: string[];
54
+ description?: string | undefined;
55
+ }, {
56
+ name: string;
57
+ id: string;
58
+ createdAt: 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
+ id: string;
81
+ version: string;
82
+ createdAt: 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
+ id: string;
103
+ createdAt: 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
- * Converts the membership to a plain object.
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
- toObject(): {
51
- companyProfile: ReturnType<Profile['toObject']>;
52
- role?: ReturnType<Role['toJSON']>;
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
- * Converts the membership to a JSON string.
168
+ * Type guard using Zod schema validation
56
169
  */
57
- toJson(): string;
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
- export interface UserData {
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
+ id: string;
30
+ version: string;
31
+ profileId: string;
32
+ identity: string;
33
+ roleId: string;
34
+ isActive: boolean;
35
+ isArchived: boolean;
36
+ resetPassword: boolean;
37
+ createdAt: string;
38
+ updatedAt: string;
39
+ access: string[];
40
+ }, {
41
+ type: string;
42
+ name: string;
43
+ id: string;
44
+ profileId: string;
45
+ identity: string;
46
+ roleId: string;
47
+ isActive: boolean;
48
+ isArchived: boolean;
49
+ resetPassword: boolean;
50
+ createdAt: string;
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
+ id: string;
97
+ version: string;
98
+ createdAt: string;
99
+ updatedAt: string;
100
+ access: string[];
101
+ description?: string | undefined;
102
+ }, {
103
+ name: string;
104
+ id: string;
105
+ createdAt: 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
+ version: string;
115
+ companyProfile: {
116
+ id: string;
117
+ displayName: string;
118
+ accountNo: string;
119
+ version: string;
120
+ firstName?: string | null | undefined;
121
+ lastName?: string | null | undefined;
122
+ phone?: string | null | undefined;
123
+ email?: string | null | undefined;
124
+ autoApprove?: boolean | null | undefined;
125
+ };
126
+ logIn: {
127
+ type: string;
128
+ name: string;
129
+ id: string;
130
+ version: string;
131
+ profileId: string;
132
+ identity: string;
133
+ roleId: string;
134
+ isActive: boolean;
135
+ isArchived: boolean;
136
+ resetPassword: boolean;
137
+ createdAt: string;
138
+ updatedAt: string;
139
+ access: string[];
140
+ };
141
+ token: string;
142
+ role?: {
143
+ name: string;
144
+ id: string;
145
+ version: string;
146
+ createdAt: string;
147
+ updatedAt: string;
148
+ access: string[];
149
+ description?: string | undefined;
150
+ } | undefined;
151
+ }, {
152
+ companyProfile: {
153
+ id: string;
154
+ displayName: string;
155
+ accountNo: string;
156
+ firstName?: string | null | undefined;
157
+ lastName?: string | null | undefined;
158
+ phone?: string | null | undefined;
159
+ email?: string | null | undefined;
160
+ autoApprove?: boolean | null | undefined;
161
+ version?: string | undefined;
162
+ };
163
+ logIn: {
164
+ type: string;
165
+ name: string;
166
+ id: string;
167
+ profileId: string;
168
+ identity: string;
169
+ roleId: string;
170
+ isActive: boolean;
171
+ isArchived: boolean;
172
+ resetPassword: boolean;
173
+ createdAt: string;
174
+ updatedAt: string;
175
+ access: string[];
176
+ version?: string | undefined;
177
+ };
178
+ token: string;
179
+ version?: string | undefined;
180
+ role?: {
181
+ name: string;
182
+ id: string;
183
+ createdAt: 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
- * Converts the User instance to a plain object.
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 A plain object representation suitable for serialization
330
+ * @returns {string} JSON string representation of the User
132
331
  */
133
- toObject(): Record<string, any>;
332
+ toJSONString(): string;
134
333
  /**
135
- * Converts the User instance to a JSON string.
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
- * @returns A JSON string representation
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
- toJson(): string;
362
+ static isUserJSON(obj: unknown): obj is UserJSON;
140
363
  }