@krak-stack/auth 0.2.0 → 0.2.2
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/access.d.ts +1 -3
- package/dist/access.js +1 -3
- package/dist/admin/api.group.d.ts +36 -36
- package/dist/admin/api.group.js +13 -13
- package/dist/api.d.ts +2109 -865
- package/dist/auth/api.group.d.ts +664 -106
- package/dist/auth/api.group.js +8 -8
- package/dist/auth/schema.d.ts +537 -70
- package/dist/auth/schema.js +26 -10
- package/dist/components/admin-organization-form.js +1 -0
- package/dist/components/admin-organizations.d.ts +4 -5
- package/dist/components/admin-organizations.js +34 -31
- package/dist/components/admin-users.d.ts +5 -6
- package/dist/components/admin-users.js +51 -50
- package/dist/components/api-key-edit-form.js +2 -1
- package/dist/components/auth-atoms.d.ts +213 -103
- package/dist/components/auth-client-api.d.ts +1412 -2371
- package/dist/components/auth-client-api.js +11 -7
- package/dist/components/auth-forms.js +6 -1
- package/dist/components/auth-provider.d.ts +13 -13
- package/dist/components/contact-fields.d.ts +40 -0
- package/dist/components/contact-fields.js +86 -0
- package/dist/components/member-required.js +2 -2
- package/dist/components/organization-switcher.js +101 -193
- package/dist/components/user-button.d.ts +73 -0
- package/dist/components/user-button.js +179 -29
- package/dist/extra/api.group.d.ts +19 -19
- package/dist/extra/api.group.js +3 -3
- package/dist/extra/schema.d.ts +1 -2
- package/dist/extra/schema.js +1 -2
- package/dist/query.js +5 -5
- package/dist/schema.d.ts +279 -12
- package/dist/schema.js +162 -42
- package/dist/server/api.group.d.ts +157 -29
- package/dist/server/api.group.js +12 -12
- package/dist/server/schema.d.ts +64 -0
- package/dist/service.d.ts +3380 -2446
- package/package.json +4 -4
package/dist/schema.d.ts
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
export declare const User: Schema.Struct<{
|
|
3
|
-
readonly id: Schema.String;
|
|
4
|
-
readonly name: Schema.String;
|
|
5
|
-
readonly email: Schema.String;
|
|
6
|
-
readonly emailVerified: Schema.Boolean;
|
|
7
|
-
readonly image: Schema.NullOr<Schema.String>;
|
|
8
|
-
readonly role: Schema.NullOr<Schema.String>;
|
|
9
|
-
readonly banned: Schema.NullOr<Schema.Boolean>;
|
|
10
|
-
readonly lastLoginMethod: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
11
|
-
readonly createdAt: Schema.Date;
|
|
12
|
-
readonly updatedAt: Schema.Date;
|
|
13
|
-
}>;
|
|
14
2
|
export declare const Session: Schema.Struct<{
|
|
15
3
|
readonly id: Schema.String;
|
|
16
4
|
readonly expiresAt: Schema.Date;
|
|
@@ -24,15 +12,27 @@ export declare const Session: Schema.Struct<{
|
|
|
24
12
|
readonly impersonatedByOrganizationId: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
25
13
|
readonly activeOrganizationId: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
26
14
|
}>;
|
|
15
|
+
export declare const ContactLocale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
27
16
|
export declare const OrganizationLocale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
28
17
|
export declare const EmailAddress: Schema.NonEmptyString;
|
|
29
18
|
export declare const PhoneNumber: Schema.NonEmptyString;
|
|
30
19
|
export declare const WebsiteUrl: Schema.NonEmptyString;
|
|
31
20
|
export declare const SocialPlatform: Schema.Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
|
|
21
|
+
export declare const ContactTranslation: Schema.Struct<{
|
|
22
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
23
|
+
readonly label: Schema.NonEmptyString;
|
|
24
|
+
}>;
|
|
32
25
|
export declare const OrganizationContactTranslation: Schema.Struct<{
|
|
33
26
|
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
34
27
|
readonly label: Schema.NonEmptyString;
|
|
35
28
|
}>;
|
|
29
|
+
export declare const ContactEmail: Schema.Struct<{
|
|
30
|
+
readonly email: Schema.NonEmptyString;
|
|
31
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
32
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
33
|
+
readonly label: Schema.NonEmptyString;
|
|
34
|
+
}>>;
|
|
35
|
+
}>;
|
|
36
36
|
export declare const OrganizationEmail: Schema.Struct<{
|
|
37
37
|
readonly email: Schema.NonEmptyString;
|
|
38
38
|
readonly translations: Schema.$Array<Schema.Struct<{
|
|
@@ -40,6 +40,14 @@ export declare const OrganizationEmail: Schema.Struct<{
|
|
|
40
40
|
readonly label: Schema.NonEmptyString;
|
|
41
41
|
}>>;
|
|
42
42
|
}>;
|
|
43
|
+
export declare const ContactPhone: Schema.Struct<{
|
|
44
|
+
readonly number: Schema.NonEmptyString;
|
|
45
|
+
readonly extension: Schema.optional<Schema.String>;
|
|
46
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
47
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
48
|
+
readonly label: Schema.NonEmptyString;
|
|
49
|
+
}>>;
|
|
50
|
+
}>;
|
|
43
51
|
export declare const OrganizationPhone: Schema.Struct<{
|
|
44
52
|
readonly number: Schema.NonEmptyString;
|
|
45
53
|
readonly extension: Schema.optional<Schema.String>;
|
|
@@ -48,6 +56,13 @@ export declare const OrganizationPhone: Schema.Struct<{
|
|
|
48
56
|
readonly label: Schema.NonEmptyString;
|
|
49
57
|
}>>;
|
|
50
58
|
}>;
|
|
59
|
+
export declare const ContactWebsite: Schema.Struct<{
|
|
60
|
+
readonly url: Schema.NonEmptyString;
|
|
61
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
62
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
63
|
+
readonly label: Schema.NonEmptyString;
|
|
64
|
+
}>>;
|
|
65
|
+
}>;
|
|
51
66
|
export declare const OrganizationWebsite: Schema.Struct<{
|
|
52
67
|
readonly url: Schema.NonEmptyString;
|
|
53
68
|
readonly translations: Schema.$Array<Schema.Struct<{
|
|
@@ -55,6 +70,14 @@ export declare const OrganizationWebsite: Schema.Struct<{
|
|
|
55
70
|
readonly label: Schema.NonEmptyString;
|
|
56
71
|
}>>;
|
|
57
72
|
}>;
|
|
73
|
+
export declare const ContactSocial: Schema.Struct<{
|
|
74
|
+
readonly platform: Schema.Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
|
|
75
|
+
readonly url: Schema.NonEmptyString;
|
|
76
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
77
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
78
|
+
readonly label: Schema.NonEmptyString;
|
|
79
|
+
}>>;
|
|
80
|
+
}>;
|
|
58
81
|
export declare const OrganizationSocial: Schema.Struct<{
|
|
59
82
|
readonly platform: Schema.Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
|
|
60
83
|
readonly url: Schema.NonEmptyString;
|
|
@@ -63,6 +86,210 @@ export declare const OrganizationSocial: Schema.Struct<{
|
|
|
63
86
|
readonly label: Schema.NonEmptyString;
|
|
64
87
|
}>>;
|
|
65
88
|
}>;
|
|
89
|
+
export declare const USER_CONTACT_LIMIT = 8;
|
|
90
|
+
export declare const UserContactEmails: Schema.$Array<Schema.Struct<{
|
|
91
|
+
readonly email: Schema.NonEmptyString;
|
|
92
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
93
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
94
|
+
readonly label: Schema.NonEmptyString;
|
|
95
|
+
}>>;
|
|
96
|
+
}>>;
|
|
97
|
+
export declare const UserContactPhones: Schema.$Array<Schema.Struct<{
|
|
98
|
+
readonly number: Schema.NonEmptyString;
|
|
99
|
+
readonly extension: Schema.optional<Schema.String>;
|
|
100
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
101
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
102
|
+
readonly label: Schema.NonEmptyString;
|
|
103
|
+
}>>;
|
|
104
|
+
}>>;
|
|
105
|
+
export declare const UserContactWebsites: Schema.$Array<Schema.Struct<{
|
|
106
|
+
readonly url: Schema.NonEmptyString;
|
|
107
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
108
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
109
|
+
readonly label: Schema.NonEmptyString;
|
|
110
|
+
}>>;
|
|
111
|
+
}>>;
|
|
112
|
+
export declare const UserContactSocials: Schema.$Array<Schema.Struct<{
|
|
113
|
+
readonly platform: Schema.Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
|
|
114
|
+
readonly url: Schema.NonEmptyString;
|
|
115
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
116
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
117
|
+
readonly label: Schema.NonEmptyString;
|
|
118
|
+
}>>;
|
|
119
|
+
}>>;
|
|
120
|
+
export declare const UserMetadata: Schema.Struct<{
|
|
121
|
+
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
122
|
+
readonly email: Schema.NonEmptyString;
|
|
123
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
124
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
125
|
+
readonly label: Schema.NonEmptyString;
|
|
126
|
+
}>>;
|
|
127
|
+
}>>>;
|
|
128
|
+
readonly phones: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
129
|
+
readonly number: Schema.NonEmptyString;
|
|
130
|
+
readonly extension: Schema.optional<Schema.String>;
|
|
131
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
132
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
133
|
+
readonly label: Schema.NonEmptyString;
|
|
134
|
+
}>>;
|
|
135
|
+
}>>>;
|
|
136
|
+
readonly websites: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
137
|
+
readonly url: Schema.NonEmptyString;
|
|
138
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
139
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
140
|
+
readonly label: Schema.NonEmptyString;
|
|
141
|
+
}>>;
|
|
142
|
+
}>>>;
|
|
143
|
+
readonly socials: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
144
|
+
readonly platform: Schema.Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
|
|
145
|
+
readonly url: Schema.NonEmptyString;
|
|
146
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
147
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
148
|
+
readonly label: Schema.NonEmptyString;
|
|
149
|
+
}>>;
|
|
150
|
+
}>>>;
|
|
151
|
+
}>;
|
|
152
|
+
declare const MetadataRecord: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
153
|
+
type MetadataRecord = typeof MetadataRecord.Type;
|
|
154
|
+
export declare const decodeUserMetadata: (metadata: MetadataRecord | null | undefined) => UserMetadata;
|
|
155
|
+
export declare const UserMetadataStandard: import("effect/StandardSchema").StandardSchemaV1<{
|
|
156
|
+
readonly emails?: readonly {
|
|
157
|
+
readonly email: string;
|
|
158
|
+
readonly translations: readonly {
|
|
159
|
+
readonly locale: "en" | "fr";
|
|
160
|
+
readonly label: string;
|
|
161
|
+
}[];
|
|
162
|
+
}[] | undefined;
|
|
163
|
+
readonly phones?: readonly {
|
|
164
|
+
readonly number: string;
|
|
165
|
+
readonly extension?: string | undefined;
|
|
166
|
+
readonly translations: readonly {
|
|
167
|
+
readonly locale: "en" | "fr";
|
|
168
|
+
readonly label: string;
|
|
169
|
+
}[];
|
|
170
|
+
}[] | undefined;
|
|
171
|
+
readonly websites?: readonly {
|
|
172
|
+
readonly url: string;
|
|
173
|
+
readonly translations: readonly {
|
|
174
|
+
readonly locale: "en" | "fr";
|
|
175
|
+
readonly label: string;
|
|
176
|
+
}[];
|
|
177
|
+
}[] | undefined;
|
|
178
|
+
readonly socials?: readonly {
|
|
179
|
+
readonly platform: "facebook" | "github" | "instagram" | "linkedin" | "tiktok" | "x" | "youtube";
|
|
180
|
+
readonly url: string;
|
|
181
|
+
readonly translations: readonly {
|
|
182
|
+
readonly locale: "en" | "fr";
|
|
183
|
+
readonly label: string;
|
|
184
|
+
}[];
|
|
185
|
+
}[] | undefined;
|
|
186
|
+
}, {
|
|
187
|
+
readonly emails?: readonly {
|
|
188
|
+
readonly email: string;
|
|
189
|
+
readonly translations: readonly {
|
|
190
|
+
readonly locale: "en" | "fr";
|
|
191
|
+
readonly label: string;
|
|
192
|
+
}[];
|
|
193
|
+
}[] | undefined;
|
|
194
|
+
readonly phones?: readonly {
|
|
195
|
+
readonly number: string;
|
|
196
|
+
readonly extension?: string | undefined;
|
|
197
|
+
readonly translations: readonly {
|
|
198
|
+
readonly locale: "en" | "fr";
|
|
199
|
+
readonly label: string;
|
|
200
|
+
}[];
|
|
201
|
+
}[] | undefined;
|
|
202
|
+
readonly websites?: readonly {
|
|
203
|
+
readonly url: string;
|
|
204
|
+
readonly translations: readonly {
|
|
205
|
+
readonly locale: "en" | "fr";
|
|
206
|
+
readonly label: string;
|
|
207
|
+
}[];
|
|
208
|
+
}[] | undefined;
|
|
209
|
+
readonly socials?: readonly {
|
|
210
|
+
readonly platform: "facebook" | "github" | "instagram" | "linkedin" | "tiktok" | "x" | "youtube";
|
|
211
|
+
readonly url: string;
|
|
212
|
+
readonly translations: readonly {
|
|
213
|
+
readonly locale: "en" | "fr";
|
|
214
|
+
readonly label: string;
|
|
215
|
+
}[];
|
|
216
|
+
}[] | undefined;
|
|
217
|
+
}> & Schema.Struct<{
|
|
218
|
+
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
219
|
+
readonly email: Schema.NonEmptyString;
|
|
220
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
221
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
222
|
+
readonly label: Schema.NonEmptyString;
|
|
223
|
+
}>>;
|
|
224
|
+
}>>>;
|
|
225
|
+
readonly phones: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
226
|
+
readonly number: Schema.NonEmptyString;
|
|
227
|
+
readonly extension: Schema.optional<Schema.String>;
|
|
228
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
229
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
230
|
+
readonly label: Schema.NonEmptyString;
|
|
231
|
+
}>>;
|
|
232
|
+
}>>>;
|
|
233
|
+
readonly websites: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
234
|
+
readonly url: Schema.NonEmptyString;
|
|
235
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
236
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
237
|
+
readonly label: Schema.NonEmptyString;
|
|
238
|
+
}>>;
|
|
239
|
+
}>>>;
|
|
240
|
+
readonly socials: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
241
|
+
readonly platform: Schema.Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
|
|
242
|
+
readonly url: Schema.NonEmptyString;
|
|
243
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
244
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
245
|
+
readonly label: Schema.NonEmptyString;
|
|
246
|
+
}>>;
|
|
247
|
+
}>>>;
|
|
248
|
+
}>;
|
|
249
|
+
export declare const User: Schema.Struct<{
|
|
250
|
+
readonly id: Schema.String;
|
|
251
|
+
readonly name: Schema.String;
|
|
252
|
+
readonly email: Schema.String;
|
|
253
|
+
readonly emailVerified: Schema.Boolean;
|
|
254
|
+
readonly image: Schema.NullOr<Schema.String>;
|
|
255
|
+
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
256
|
+
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
257
|
+
readonly email: Schema.NonEmptyString;
|
|
258
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
259
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
260
|
+
readonly label: Schema.NonEmptyString;
|
|
261
|
+
}>>;
|
|
262
|
+
}>>>;
|
|
263
|
+
readonly phones: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
264
|
+
readonly number: Schema.NonEmptyString;
|
|
265
|
+
readonly extension: Schema.optional<Schema.String>;
|
|
266
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
267
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
268
|
+
readonly label: Schema.NonEmptyString;
|
|
269
|
+
}>>;
|
|
270
|
+
}>>>;
|
|
271
|
+
readonly websites: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
272
|
+
readonly url: Schema.NonEmptyString;
|
|
273
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
274
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
275
|
+
readonly label: Schema.NonEmptyString;
|
|
276
|
+
}>>;
|
|
277
|
+
}>>>;
|
|
278
|
+
readonly socials: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
279
|
+
readonly platform: Schema.Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
|
|
280
|
+
readonly url: Schema.NonEmptyString;
|
|
281
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
282
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
283
|
+
readonly label: Schema.NonEmptyString;
|
|
284
|
+
}>>;
|
|
285
|
+
}>>>;
|
|
286
|
+
}>, Schema.Unknown, never, never>>>;
|
|
287
|
+
readonly role: Schema.NullOr<Schema.String>;
|
|
288
|
+
readonly banned: Schema.NullOr<Schema.Boolean>;
|
|
289
|
+
readonly lastLoginMethod: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
290
|
+
readonly createdAt: Schema.Date;
|
|
291
|
+
readonly updatedAt: Schema.Date;
|
|
292
|
+
}>;
|
|
66
293
|
export declare const PostalAddress: Schema.Struct<{
|
|
67
294
|
readonly streetAddress: Schema.optional<Schema.String>;
|
|
68
295
|
readonly locality: Schema.optional<Schema.String>;
|
|
@@ -224,6 +451,38 @@ export declare const Member: Schema.Struct<{
|
|
|
224
451
|
readonly email: Schema.String;
|
|
225
452
|
readonly emailVerified: Schema.Boolean;
|
|
226
453
|
readonly image: Schema.NullOr<Schema.String>;
|
|
454
|
+
readonly metadata: Schema.optional<Schema.NullOr<Schema.decodeTo<Schema.Struct<{
|
|
455
|
+
readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
456
|
+
readonly email: Schema.NonEmptyString;
|
|
457
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
458
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
459
|
+
readonly label: Schema.NonEmptyString;
|
|
460
|
+
}>>;
|
|
461
|
+
}>>>;
|
|
462
|
+
readonly phones: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
463
|
+
readonly number: Schema.NonEmptyString;
|
|
464
|
+
readonly extension: Schema.optional<Schema.String>;
|
|
465
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
466
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
467
|
+
readonly label: Schema.NonEmptyString;
|
|
468
|
+
}>>;
|
|
469
|
+
}>>>;
|
|
470
|
+
readonly websites: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
471
|
+
readonly url: Schema.NonEmptyString;
|
|
472
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
473
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
474
|
+
readonly label: Schema.NonEmptyString;
|
|
475
|
+
}>>;
|
|
476
|
+
}>>>;
|
|
477
|
+
readonly socials: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
478
|
+
readonly platform: Schema.Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
|
|
479
|
+
readonly url: Schema.NonEmptyString;
|
|
480
|
+
readonly translations: Schema.$Array<Schema.Struct<{
|
|
481
|
+
readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
|
482
|
+
readonly label: Schema.NonEmptyString;
|
|
483
|
+
}>>;
|
|
484
|
+
}>>>;
|
|
485
|
+
}>, Schema.Unknown, never, never>>>;
|
|
227
486
|
readonly role: Schema.NullOr<Schema.String>;
|
|
228
487
|
readonly banned: Schema.NullOr<Schema.Boolean>;
|
|
229
488
|
readonly lastLoginMethod: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
@@ -233,6 +492,13 @@ export declare const Member: Schema.Struct<{
|
|
|
233
492
|
}>;
|
|
234
493
|
export type User = typeof User.Type;
|
|
235
494
|
export type Session = typeof Session.Type;
|
|
495
|
+
export type ContactLocale = typeof ContactLocale.Type;
|
|
496
|
+
export type ContactTranslation = typeof ContactTranslation.Type;
|
|
497
|
+
export type ContactEmail = typeof ContactEmail.Type;
|
|
498
|
+
export type ContactPhone = typeof ContactPhone.Type;
|
|
499
|
+
export type ContactWebsite = typeof ContactWebsite.Type;
|
|
500
|
+
export type ContactSocial = typeof ContactSocial.Type;
|
|
501
|
+
export type UserMetadata = typeof UserMetadata.Type;
|
|
236
502
|
export type OrganizationLocale = typeof OrganizationLocale.Type;
|
|
237
503
|
export type EmailAddress = typeof EmailAddress.Type;
|
|
238
504
|
export type PhoneNumber = typeof PhoneNumber.Type;
|
|
@@ -250,3 +516,4 @@ export type OrganizationTranslation = typeof OrganizationTranslation.Type;
|
|
|
250
516
|
export type OrganizationMetadata = typeof OrganizationMetadata.Type;
|
|
251
517
|
export type Organization = typeof Organization.Type;
|
|
252
518
|
export type Member = typeof Member.Type;
|
|
519
|
+
export {};
|
package/dist/schema.js
CHANGED
|
@@ -1,34 +1,4 @@
|
|
|
1
1
|
import { Option, Schema, SchemaGetter } from "effect";
|
|
2
|
-
export const User = Schema.Struct({
|
|
3
|
-
id: Schema.String,
|
|
4
|
-
name: Schema.String,
|
|
5
|
-
email: Schema.String,
|
|
6
|
-
emailVerified: Schema.Boolean,
|
|
7
|
-
image: Schema.NullOr(Schema.String),
|
|
8
|
-
role: Schema.NullOr(Schema.String),
|
|
9
|
-
banned: Schema.NullOr(Schema.Boolean),
|
|
10
|
-
lastLoginMethod: Schema.optional(Schema.NullOr(Schema.String)),
|
|
11
|
-
createdAt: Schema.Date,
|
|
12
|
-
updatedAt: Schema.Date,
|
|
13
|
-
}).annotate({
|
|
14
|
-
identifier: "User",
|
|
15
|
-
title: "User",
|
|
16
|
-
description: "Stable central auth user record.",
|
|
17
|
-
examples: [
|
|
18
|
-
{
|
|
19
|
-
id: "user_1",
|
|
20
|
-
name: "Ada Lovelace",
|
|
21
|
-
email: "ada@example.com",
|
|
22
|
-
emailVerified: true,
|
|
23
|
-
image: null,
|
|
24
|
-
role: "admin",
|
|
25
|
-
banned: false,
|
|
26
|
-
lastLoginMethod: "email-otp",
|
|
27
|
-
createdAt: new Date("2026-01-01T00:00:00.000Z"),
|
|
28
|
-
updatedAt: new Date("2026-01-01T00:00:00.000Z"),
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
});
|
|
32
2
|
export const Session = Schema.Struct({
|
|
33
3
|
id: Schema.String,
|
|
34
4
|
expiresAt: Schema.Date,
|
|
@@ -61,10 +31,16 @@ export const Session = Schema.Struct({
|
|
|
61
31
|
},
|
|
62
32
|
],
|
|
63
33
|
});
|
|
64
|
-
export const
|
|
34
|
+
export const ContactLocale = Schema.Union([
|
|
65
35
|
Schema.Literal("en"),
|
|
66
36
|
Schema.Literal("fr"),
|
|
67
37
|
]).annotate({
|
|
38
|
+
identifier: "ContactLocale",
|
|
39
|
+
title: "Contact locale",
|
|
40
|
+
description: "Supported localized contact-label locale.",
|
|
41
|
+
examples: ["en", "fr"],
|
|
42
|
+
});
|
|
43
|
+
export const OrganizationLocale = ContactLocale.annotate({
|
|
68
44
|
identifier: "OrganizationLocale",
|
|
69
45
|
title: "Organization locale",
|
|
70
46
|
description: "Supported organization translation locale.",
|
|
@@ -74,7 +50,7 @@ export const EmailAddress = Schema.NonEmptyString.check(Schema.isPattern(/^[^\s@
|
|
|
74
50
|
identifier: "EmailAddress",
|
|
75
51
|
title: "Email address",
|
|
76
52
|
});
|
|
77
|
-
export const PhoneNumber = Schema.NonEmptyString.check(Schema.isPattern(
|
|
53
|
+
export const PhoneNumber = Schema.NonEmptyString.check(Schema.isPattern(/^(?=.*\d)\+?[0-9 ()-]{7,}$/)).annotate({
|
|
78
54
|
identifier: "PhoneNumber",
|
|
79
55
|
title: "Phone number",
|
|
80
56
|
});
|
|
@@ -94,43 +70,187 @@ export const SocialPlatform = Schema.Literals([
|
|
|
94
70
|
identifier: "SocialPlatform",
|
|
95
71
|
title: "Social platform",
|
|
96
72
|
});
|
|
97
|
-
export const
|
|
98
|
-
locale:
|
|
73
|
+
export const ContactTranslation = Schema.Struct({
|
|
74
|
+
locale: ContactLocale,
|
|
99
75
|
label: Schema.NonEmptyString.check(Schema.isPattern(/\S/)),
|
|
100
76
|
}).annotate({
|
|
77
|
+
identifier: "ContactTranslation",
|
|
78
|
+
title: "Contact translation",
|
|
79
|
+
});
|
|
80
|
+
export const OrganizationContactTranslation = ContactTranslation.annotate({
|
|
101
81
|
identifier: "OrganizationContactTranslation",
|
|
102
82
|
title: "Organization contact translation",
|
|
103
83
|
});
|
|
104
|
-
export const
|
|
84
|
+
export const ContactEmail = Schema.Struct({
|
|
105
85
|
email: EmailAddress,
|
|
106
|
-
translations: Schema.Array(
|
|
86
|
+
translations: Schema.Array(ContactTranslation).check(Schema.isMinLength(1)),
|
|
107
87
|
}).annotate({
|
|
88
|
+
identifier: "ContactEmail",
|
|
89
|
+
title: "Contact email",
|
|
90
|
+
});
|
|
91
|
+
export const OrganizationEmail = ContactEmail.annotate({
|
|
108
92
|
identifier: "OrganizationEmail",
|
|
109
93
|
title: "Organization email",
|
|
110
94
|
});
|
|
111
|
-
export const
|
|
95
|
+
export const ContactPhone = Schema.Struct({
|
|
112
96
|
number: PhoneNumber,
|
|
113
97
|
extension: Schema.optional(Schema.String),
|
|
114
|
-
translations: Schema.Array(
|
|
98
|
+
translations: Schema.Array(ContactTranslation).check(Schema.isMinLength(1)),
|
|
115
99
|
}).annotate({
|
|
100
|
+
identifier: "ContactPhone",
|
|
101
|
+
title: "Contact phone",
|
|
102
|
+
});
|
|
103
|
+
export const OrganizationPhone = ContactPhone.annotate({
|
|
116
104
|
identifier: "OrganizationPhone",
|
|
117
105
|
title: "Organization phone",
|
|
118
106
|
});
|
|
119
|
-
export const
|
|
107
|
+
export const ContactWebsite = Schema.Struct({
|
|
120
108
|
url: WebsiteUrl,
|
|
121
|
-
translations: Schema.Array(
|
|
109
|
+
translations: Schema.Array(ContactTranslation).check(Schema.isMinLength(1)),
|
|
122
110
|
}).annotate({
|
|
111
|
+
identifier: "ContactWebsite",
|
|
112
|
+
title: "Contact website",
|
|
113
|
+
});
|
|
114
|
+
export const OrganizationWebsite = ContactWebsite.annotate({
|
|
123
115
|
identifier: "OrganizationWebsite",
|
|
124
116
|
title: "Organization website",
|
|
125
117
|
});
|
|
126
|
-
export const
|
|
118
|
+
export const ContactSocial = Schema.Struct({
|
|
127
119
|
platform: SocialPlatform,
|
|
128
120
|
url: WebsiteUrl,
|
|
129
|
-
translations: Schema.Array(
|
|
121
|
+
translations: Schema.Array(ContactTranslation).check(Schema.isMinLength(1)),
|
|
130
122
|
}).annotate({
|
|
123
|
+
identifier: "ContactSocial",
|
|
124
|
+
title: "Contact social profile",
|
|
125
|
+
});
|
|
126
|
+
export const OrganizationSocial = ContactSocial.annotate({
|
|
131
127
|
identifier: "OrganizationSocial",
|
|
132
128
|
title: "Organization social profile",
|
|
133
129
|
});
|
|
130
|
+
export const USER_CONTACT_LIMIT = 8;
|
|
131
|
+
export const UserContactEmails = Schema.Array(ContactEmail)
|
|
132
|
+
.check(Schema.isMaxLength(USER_CONTACT_LIMIT))
|
|
133
|
+
.annotate({ identifier: "UserContactEmails" });
|
|
134
|
+
export const UserContactPhones = Schema.Array(ContactPhone)
|
|
135
|
+
.check(Schema.isMaxLength(USER_CONTACT_LIMIT))
|
|
136
|
+
.annotate({ identifier: "UserContactPhones" });
|
|
137
|
+
export const UserContactWebsites = Schema.Array(ContactWebsite)
|
|
138
|
+
.check(Schema.isMaxLength(USER_CONTACT_LIMIT))
|
|
139
|
+
.annotate({ identifier: "UserContactWebsites" });
|
|
140
|
+
export const UserContactSocials = Schema.Array(ContactSocial)
|
|
141
|
+
.check(Schema.isMaxLength(USER_CONTACT_LIMIT))
|
|
142
|
+
.annotate({ identifier: "UserContactSocials" });
|
|
143
|
+
const UserMetadataFields = Schema.Struct({
|
|
144
|
+
emails: Schema.optional(UserContactEmails),
|
|
145
|
+
phones: Schema.optional(UserContactPhones),
|
|
146
|
+
websites: Schema.optional(UserContactWebsites),
|
|
147
|
+
socials: Schema.optional(UserContactSocials),
|
|
148
|
+
});
|
|
149
|
+
const UserMetadataJson = Schema.fromJsonString(UserMetadataFields);
|
|
150
|
+
export const UserMetadata = UserMetadataFields.check(Schema.makeFilter((metadata) => {
|
|
151
|
+
const json = Schema.encodeSync(UserMetadataJson)(metadata);
|
|
152
|
+
return new TextEncoder().encode(json).byteLength <= 2048
|
|
153
|
+
? undefined
|
|
154
|
+
: "User contact metadata must not exceed 2 KB";
|
|
155
|
+
})).annotate({
|
|
156
|
+
identifier: "UserMetadata",
|
|
157
|
+
title: "User metadata",
|
|
158
|
+
description: "Localized contact details stored on a user record.",
|
|
159
|
+
examples: [
|
|
160
|
+
{
|
|
161
|
+
emails: [
|
|
162
|
+
{
|
|
163
|
+
email: "ada@example.com",
|
|
164
|
+
translations: [{ locale: "en", label: "Work" }],
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
phones: [
|
|
168
|
+
{
|
|
169
|
+
number: "+1 514 555 0100",
|
|
170
|
+
translations: [{ locale: "en", label: "Mobile" }],
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
websites: [
|
|
174
|
+
{
|
|
175
|
+
url: "https://example.com",
|
|
176
|
+
translations: [{ locale: "en", label: "Website" }],
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
socials: [
|
|
180
|
+
{
|
|
181
|
+
platform: "linkedin",
|
|
182
|
+
url: "https://linkedin.com/in/example",
|
|
183
|
+
translations: [{ locale: "en", label: "LinkedIn" }],
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
});
|
|
189
|
+
const MetadataRecord = Schema.Record(Schema.String, Schema.Unknown);
|
|
190
|
+
export const decodeUserMetadata = (metadata) => {
|
|
191
|
+
const value = metadata ?? {};
|
|
192
|
+
const emails = Schema.decodeUnknownOption(UserContactEmails)(value.emails);
|
|
193
|
+
const phones = Schema.decodeUnknownOption(UserContactPhones)(value.phones);
|
|
194
|
+
const websites = Schema.decodeUnknownOption(UserContactWebsites)(value.websites);
|
|
195
|
+
const socials = Schema.decodeUnknownOption(UserContactSocials)(value.socials);
|
|
196
|
+
let metadataValue = {};
|
|
197
|
+
if (Option.isSome(emails))
|
|
198
|
+
metadataValue = { ...metadataValue, emails: emails.value };
|
|
199
|
+
if (Option.isSome(phones))
|
|
200
|
+
metadataValue = { ...metadataValue, phones: phones.value };
|
|
201
|
+
if (Option.isSome(websites))
|
|
202
|
+
metadataValue = { ...metadataValue, websites: websites.value };
|
|
203
|
+
if (Option.isSome(socials))
|
|
204
|
+
metadataValue = { ...metadataValue, socials: socials.value };
|
|
205
|
+
return Option.getOrElse(Schema.decodeUnknownOption(UserMetadata)(metadataValue), () => ({}));
|
|
206
|
+
};
|
|
207
|
+
export const UserMetadataStandard = Schema.toStandardSchemaV1(UserMetadata);
|
|
208
|
+
const CompatibleUserMetadata = Schema.Unknown.pipe(Schema.decodeTo(UserMetadata, {
|
|
209
|
+
decode: SchemaGetter.transform((metadata) => {
|
|
210
|
+
const decoded = Schema.decodeUnknownOption(MetadataRecord)(metadata);
|
|
211
|
+
return decodeUserMetadata(Option.getOrNull(decoded));
|
|
212
|
+
}),
|
|
213
|
+
encode: SchemaGetter.transform((metadata) => metadata),
|
|
214
|
+
}));
|
|
215
|
+
export const User = Schema.Struct({
|
|
216
|
+
id: Schema.String,
|
|
217
|
+
name: Schema.String,
|
|
218
|
+
email: Schema.String,
|
|
219
|
+
emailVerified: Schema.Boolean,
|
|
220
|
+
image: Schema.NullOr(Schema.String),
|
|
221
|
+
metadata: Schema.optional(Schema.NullOr(CompatibleUserMetadata)),
|
|
222
|
+
role: Schema.NullOr(Schema.String),
|
|
223
|
+
banned: Schema.NullOr(Schema.Boolean),
|
|
224
|
+
lastLoginMethod: Schema.optional(Schema.NullOr(Schema.String)),
|
|
225
|
+
createdAt: Schema.Date,
|
|
226
|
+
updatedAt: Schema.Date,
|
|
227
|
+
}).annotate({
|
|
228
|
+
identifier: "User",
|
|
229
|
+
title: "User",
|
|
230
|
+
description: "Stable central auth user record.",
|
|
231
|
+
examples: [
|
|
232
|
+
{
|
|
233
|
+
id: "user_1",
|
|
234
|
+
name: "Ada Lovelace",
|
|
235
|
+
email: "ada@example.com",
|
|
236
|
+
emailVerified: true,
|
|
237
|
+
image: null,
|
|
238
|
+
metadata: {
|
|
239
|
+
websites: [
|
|
240
|
+
{
|
|
241
|
+
url: "https://example.com",
|
|
242
|
+
translations: [{ locale: "en", label: "Website" }],
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
},
|
|
246
|
+
role: "admin",
|
|
247
|
+
banned: false,
|
|
248
|
+
lastLoginMethod: "email-otp",
|
|
249
|
+
createdAt: new Date("2026-01-01T00:00:00.000Z"),
|
|
250
|
+
updatedAt: new Date("2026-01-01T00:00:00.000Z"),
|
|
251
|
+
},
|
|
252
|
+
],
|
|
253
|
+
});
|
|
134
254
|
export const PostalAddress = Schema.Struct({
|
|
135
255
|
streetAddress: Schema.optional(Schema.String),
|
|
136
256
|
locality: Schema.optional(Schema.String),
|