@krak-stack/auth 0.1.53 → 0.1.55

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.
@@ -12,12 +12,55 @@ export declare const ExtraApiGroup: HttpApiGroup.HttpApiGroup<"authExtra", HttpA
12
12
  readonly key: import("effect/Schema").String;
13
13
  }>>, HttpApiEndpoint.Json<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getOrganizationPublicProfile", "GET", "/auth/organization-profile", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<import("effect/Schema").Struct<{
14
14
  readonly organizationId: import("effect/Schema").String;
15
+ readonly locale: import("effect/Schema").optional<import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>>;
15
16
  }>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
16
17
  readonly id: import("effect/Schema").String;
17
18
  readonly name: import("effect/Schema").String;
18
19
  readonly slug: import("effect/Schema").String;
19
20
  readonly displayName: import("effect/Schema").String;
20
21
  readonly contactEmail: import("effect/Schema").NullOr<import("effect/Schema").String>;
22
+ readonly emails: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
23
+ readonly email: import("effect/Schema").NonEmptyString;
24
+ readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
25
+ readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
26
+ readonly label: import("effect/Schema").NonEmptyString;
27
+ }>>;
28
+ }>>>;
29
+ readonly phones: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
30
+ readonly number: import("effect/Schema").NonEmptyString;
31
+ readonly extension: import("effect/Schema").optional<import("effect/Schema").String>;
32
+ readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
33
+ readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
34
+ readonly label: import("effect/Schema").NonEmptyString;
35
+ }>>;
36
+ }>>>;
37
+ readonly websites: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
38
+ readonly url: import("effect/Schema").NonEmptyString;
39
+ readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
40
+ readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
41
+ readonly label: import("effect/Schema").NonEmptyString;
42
+ }>>;
43
+ }>>>;
44
+ readonly socials: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
45
+ readonly platform: import("effect/Schema").Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
46
+ readonly url: import("effect/Schema").NonEmptyString;
47
+ readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
48
+ readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
49
+ readonly label: import("effect/Schema").NonEmptyString;
50
+ }>>;
51
+ }>>>;
52
+ readonly addresses: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
53
+ readonly streetAddress: import("effect/Schema").optional<import("effect/Schema").String>;
54
+ readonly locality: import("effect/Schema").optional<import("effect/Schema").String>;
55
+ readonly region: import("effect/Schema").optional<import("effect/Schema").String>;
56
+ readonly postalCode: import("effect/Schema").optional<import("effect/Schema").String>;
57
+ readonly country: import("effect/Schema").optional<import("effect/Schema").String>;
58
+ readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
59
+ readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
60
+ readonly label: import("effect/Schema").NonEmptyString;
61
+ }>>;
62
+ readonly formatted: import("effect/Schema").String;
63
+ }>>>;
21
64
  readonly logo: import("effect/Schema").NullOr<import("effect/Schema").String>;
22
65
  readonly icon: import("effect/Schema").NullOr<import("effect/Schema").String>;
23
66
  }>>, HttpApiEndpoint.Json<typeof HttpApiError.NotFound | typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getProjectPublicConfig", "GET", "/auth/project-config", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<import("effect/Schema").Struct<{
@@ -99,6 +99,7 @@ export declare const ExtraProjectPublicConfig: Schema.Struct<{
99
99
  }>;
100
100
  export declare const ExtraOrganizationPublicProfileQuery: Schema.Struct<{
101
101
  readonly organizationId: Schema.String;
102
+ readonly locale: Schema.optional<Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>>;
102
103
  }>;
103
104
  export declare const ExtraOrganizationPublicProfile: Schema.Struct<{
104
105
  readonly id: Schema.String;
@@ -106,6 +107,48 @@ export declare const ExtraOrganizationPublicProfile: Schema.Struct<{
106
107
  readonly slug: Schema.String;
107
108
  readonly displayName: Schema.String;
108
109
  readonly contactEmail: Schema.NullOr<Schema.String>;
110
+ readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
111
+ readonly email: Schema.NonEmptyString;
112
+ readonly translations: Schema.$Array<Schema.Struct<{
113
+ readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
114
+ readonly label: Schema.NonEmptyString;
115
+ }>>;
116
+ }>>>;
117
+ readonly phones: Schema.optional<Schema.$Array<Schema.Struct<{
118
+ readonly number: Schema.NonEmptyString;
119
+ readonly extension: Schema.optional<Schema.String>;
120
+ readonly translations: Schema.$Array<Schema.Struct<{
121
+ readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
122
+ readonly label: Schema.NonEmptyString;
123
+ }>>;
124
+ }>>>;
125
+ readonly websites: Schema.optional<Schema.$Array<Schema.Struct<{
126
+ readonly url: Schema.NonEmptyString;
127
+ readonly translations: Schema.$Array<Schema.Struct<{
128
+ readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
129
+ readonly label: Schema.NonEmptyString;
130
+ }>>;
131
+ }>>>;
132
+ readonly socials: Schema.optional<Schema.$Array<Schema.Struct<{
133
+ readonly platform: Schema.Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
134
+ readonly url: Schema.NonEmptyString;
135
+ readonly translations: Schema.$Array<Schema.Struct<{
136
+ readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
137
+ readonly label: Schema.NonEmptyString;
138
+ }>>;
139
+ }>>>;
140
+ readonly addresses: Schema.optional<Schema.$Array<Schema.Struct<{
141
+ readonly streetAddress: Schema.optional<Schema.String>;
142
+ readonly locality: Schema.optional<Schema.String>;
143
+ readonly region: Schema.optional<Schema.String>;
144
+ readonly postalCode: Schema.optional<Schema.String>;
145
+ readonly country: Schema.optional<Schema.String>;
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
+ readonly formatted: Schema.String;
151
+ }>>>;
109
152
  readonly logo: Schema.NullOr<Schema.String>;
110
153
  readonly icon: Schema.NullOr<Schema.String>;
111
154
  }>;
@@ -1,6 +1,7 @@
1
1
  import { Schema } from "effect";
2
2
  import { Multipart } from "effect/unstable/http";
3
3
  import { HttpApiSchema } from "effect/unstable/httpapi";
4
+ import { OrganizationEmail, OrganizationLocale, OrganizationPhone, OrganizationSocial, OrganizationWebsite, FormattedOrganizationAddress, } from "../schema";
4
5
  export const ExtraImageUploadPayload = Schema.Struct({
5
6
  file: Multipart.SingleFileSchema,
6
7
  }).annotate({
@@ -205,11 +206,12 @@ export const ExtraProjectPublicConfig = Schema.Struct({
205
206
  });
206
207
  export const ExtraOrganizationPublicProfileQuery = Schema.Struct({
207
208
  organizationId: Schema.String,
209
+ locale: Schema.optional(OrganizationLocale),
208
210
  }).annotate({
209
211
  identifier: "ExtraOrganizationPublicProfileQuery",
210
212
  title: "Extra organization public profile query",
211
213
  description: "Organization ID used to resolve public organization display metadata.",
212
- examples: [{ organizationId: "org_1" }],
214
+ examples: [{ organizationId: "org_1", locale: "en" }],
213
215
  });
214
216
  export const ExtraOrganizationPublicProfile = Schema.Struct({
215
217
  id: Schema.String,
@@ -217,6 +219,11 @@ export const ExtraOrganizationPublicProfile = Schema.Struct({
217
219
  slug: Schema.String,
218
220
  displayName: Schema.String,
219
221
  contactEmail: Schema.NullOr(Schema.String),
222
+ emails: Schema.optional(Schema.Array(OrganizationEmail)),
223
+ phones: Schema.optional(Schema.Array(OrganizationPhone)),
224
+ websites: Schema.optional(Schema.Array(OrganizationWebsite)),
225
+ socials: Schema.optional(Schema.Array(OrganizationSocial)),
226
+ addresses: Schema.optional(Schema.Array(FormattedOrganizationAddress)),
220
227
  logo: Schema.NullOr(Schema.String),
221
228
  icon: Schema.NullOr(Schema.String),
222
229
  }).annotate({
@@ -230,6 +237,11 @@ export const ExtraOrganizationPublicProfile = Schema.Struct({
230
237
  slug: "krak",
231
238
  displayName: "Krak",
232
239
  contactEmail: null,
240
+ emails: [],
241
+ phones: [],
242
+ websites: [],
243
+ socials: [],
244
+ addresses: [],
233
245
  logo: null,
234
246
  icon: null,
235
247
  },
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export { AuthClientApi, AuthServiceApi } from "./api";
5
5
  export { AuthService, type AuthServiceLayerOptions } from "./service";
6
6
  export { AuthClientConfig } from "./config";
7
7
  export { proxyAuthRequest } from "./server/proxy";
8
- export { OrganizationSwitcher, MemberRequired, KrakstackAuthProvider, ResetPassword, Signin, Signup, TwoFactor, VerifyEmail, AdminOrganizationForm, AdminOrganizationsTable, AdminUsersTable, UserButton, assetUrl, createAuthUiClient, type AuthUiClient, type MemberRequiredMessages, type MemberRequiredProps, type KrakstackAuthContextValue, type KrakstackAuthLocale, type KrakstackAuthProviderProps, type OrganizationSwitcherDialog, type OrganizationSwitcherProps, type UserButtonDialog, useAuthClient, useAdminUsersTotal, } from "./components";
8
+ export { OrganizationSwitcher, MemberRequired, KrakstackAuthProvider, ResetPassword, Signin, Signup, TwoFactor, VerifyEmail, AdminOrganizationForm, AdminOrganizationsTable, AdminUsersTable, UserButton, assetUrl, createAuthUiClient, type AuthUiClient, type MemberRequiredMessages, type MemberRequiredProps, type KrakstackAuthContextValue, type KrakstackAuthLocale, type KrakstackAuthProviderProps, type OrganizationSwitcherDialog, type OrganizationSwitcherFeatures, type OrganizationSwitcherProps, type UserButtonDialog, useAuthClient, useAdminUsersTotal, } from "./components";
9
9
  export * as BetterAuth from "./better-auth/api.group";
10
10
  export * as Extra from "./extra/api.group";
11
11
  export * as Server from "./server";
package/dist/schema.d.ts CHANGED
@@ -25,6 +25,74 @@ export declare const Session: Schema.Struct<{
25
25
  readonly activeOrganizationId: Schema.optional<Schema.NullOr<Schema.String>>;
26
26
  }>;
27
27
  export declare const OrganizationLocale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
28
+ export declare const EmailAddress: Schema.NonEmptyString;
29
+ export declare const PhoneNumber: Schema.NonEmptyString;
30
+ export declare const WebsiteUrl: Schema.NonEmptyString;
31
+ export declare const SocialPlatform: Schema.Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
32
+ export declare const OrganizationContactTranslation: Schema.Struct<{
33
+ readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
34
+ readonly label: Schema.NonEmptyString;
35
+ }>;
36
+ export declare const OrganizationEmail: Schema.Struct<{
37
+ readonly email: Schema.NonEmptyString;
38
+ readonly translations: Schema.$Array<Schema.Struct<{
39
+ readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
40
+ readonly label: Schema.NonEmptyString;
41
+ }>>;
42
+ }>;
43
+ export declare const OrganizationPhone: 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
+ }>;
51
+ export declare const OrganizationWebsite: Schema.Struct<{
52
+ readonly url: Schema.NonEmptyString;
53
+ readonly translations: Schema.$Array<Schema.Struct<{
54
+ readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
55
+ readonly label: Schema.NonEmptyString;
56
+ }>>;
57
+ }>;
58
+ export declare const OrganizationSocial: Schema.Struct<{
59
+ readonly platform: Schema.Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
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
+ }>;
66
+ export declare const PostalAddress: Schema.Struct<{
67
+ readonly streetAddress: Schema.optional<Schema.String>;
68
+ readonly locality: Schema.optional<Schema.String>;
69
+ readonly region: Schema.optional<Schema.String>;
70
+ readonly postalCode: Schema.optional<Schema.String>;
71
+ readonly country: Schema.optional<Schema.String>;
72
+ }>;
73
+ export declare const OrganizationAddress: Schema.Struct<{
74
+ readonly streetAddress: Schema.optional<Schema.String>;
75
+ readonly locality: Schema.optional<Schema.String>;
76
+ readonly region: Schema.optional<Schema.String>;
77
+ readonly postalCode: Schema.optional<Schema.String>;
78
+ readonly country: Schema.optional<Schema.String>;
79
+ readonly translations: Schema.$Array<Schema.Struct<{
80
+ readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
81
+ readonly label: Schema.NonEmptyString;
82
+ }>>;
83
+ }>;
84
+ export declare const FormattedOrganizationAddress: Schema.Struct<{
85
+ readonly streetAddress: Schema.optional<Schema.String>;
86
+ readonly locality: Schema.optional<Schema.String>;
87
+ readonly region: Schema.optional<Schema.String>;
88
+ readonly postalCode: Schema.optional<Schema.String>;
89
+ readonly country: Schema.optional<Schema.String>;
90
+ readonly translations: Schema.$Array<Schema.Struct<{
91
+ readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
92
+ readonly label: Schema.NonEmptyString;
93
+ }>>;
94
+ readonly formatted: Schema.String;
95
+ }>;
28
96
  export declare const OrganizationTranslation: Schema.Struct<{
29
97
  readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
30
98
  readonly name: Schema.String;
@@ -42,13 +110,55 @@ export declare const OrganizationMetadata: Schema.Struct<{
42
110
  readonly contactEmail: Schema.optional<Schema.NullOr<Schema.String>>;
43
111
  readonly location: Schema.optional<Schema.NullOr<Schema.String>>;
44
112
  }>>;
113
+ readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
114
+ readonly email: 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
+ readonly phones: Schema.optional<Schema.$Array<Schema.Struct<{
121
+ readonly number: Schema.NonEmptyString;
122
+ readonly extension: Schema.optional<Schema.String>;
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 websites: Schema.optional<Schema.$Array<Schema.Struct<{
129
+ readonly url: Schema.NonEmptyString;
130
+ readonly translations: Schema.$Array<Schema.Struct<{
131
+ readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
132
+ readonly label: Schema.NonEmptyString;
133
+ }>>;
134
+ }>>>;
135
+ readonly socials: Schema.optional<Schema.$Array<Schema.Struct<{
136
+ readonly platform: Schema.Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
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 addresses: Schema.optional<Schema.$Array<Schema.Struct<{
144
+ readonly streetAddress: Schema.optional<Schema.String>;
145
+ readonly locality: Schema.optional<Schema.String>;
146
+ readonly region: Schema.optional<Schema.String>;
147
+ readonly postalCode: Schema.optional<Schema.String>;
148
+ readonly country: Schema.optional<Schema.String>;
149
+ readonly translations: Schema.$Array<Schema.Struct<{
150
+ readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
151
+ readonly label: Schema.NonEmptyString;
152
+ }>>;
153
+ }>>>;
45
154
  }>;
155
+ export declare const decodeOrganizationMetadata: (metadata: unknown) => OrganizationMetadata;
46
156
  export declare const Organization: Schema.Struct<{
47
157
  readonly id: Schema.String;
48
158
  readonly name: Schema.String;
49
159
  readonly slug: Schema.String;
50
160
  readonly logo: Schema.NullOr<Schema.String>;
51
- readonly metadata: Schema.NullOr<Schema.Struct<{
161
+ readonly metadata: Schema.NullOr<Schema.decodeTo<Schema.Struct<{
52
162
  readonly translations: Schema.$Array<Schema.Struct<{
53
163
  readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
54
164
  readonly name: Schema.String;
@@ -57,7 +167,48 @@ export declare const Organization: Schema.Struct<{
57
167
  readonly contactEmail: Schema.optional<Schema.NullOr<Schema.String>>;
58
168
  readonly location: Schema.optional<Schema.NullOr<Schema.String>>;
59
169
  }>>;
60
- }>>;
170
+ readonly emails: Schema.optional<Schema.$Array<Schema.Struct<{
171
+ readonly email: Schema.NonEmptyString;
172
+ readonly translations: Schema.$Array<Schema.Struct<{
173
+ readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
174
+ readonly label: Schema.NonEmptyString;
175
+ }>>;
176
+ }>>>;
177
+ readonly phones: Schema.optional<Schema.$Array<Schema.Struct<{
178
+ readonly number: Schema.NonEmptyString;
179
+ readonly extension: Schema.optional<Schema.String>;
180
+ readonly translations: Schema.$Array<Schema.Struct<{
181
+ readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
182
+ readonly label: Schema.NonEmptyString;
183
+ }>>;
184
+ }>>>;
185
+ readonly websites: Schema.optional<Schema.$Array<Schema.Struct<{
186
+ readonly url: Schema.NonEmptyString;
187
+ readonly translations: Schema.$Array<Schema.Struct<{
188
+ readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
189
+ readonly label: Schema.NonEmptyString;
190
+ }>>;
191
+ }>>>;
192
+ readonly socials: Schema.optional<Schema.$Array<Schema.Struct<{
193
+ readonly platform: Schema.Literals<readonly ["facebook", "github", "instagram", "linkedin", "tiktok", "x", "youtube"]>;
194
+ readonly url: Schema.NonEmptyString;
195
+ readonly translations: Schema.$Array<Schema.Struct<{
196
+ readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
197
+ readonly label: Schema.NonEmptyString;
198
+ }>>;
199
+ }>>>;
200
+ readonly addresses: Schema.optional<Schema.$Array<Schema.Struct<{
201
+ readonly streetAddress: Schema.optional<Schema.String>;
202
+ readonly locality: Schema.optional<Schema.String>;
203
+ readonly region: Schema.optional<Schema.String>;
204
+ readonly postalCode: Schema.optional<Schema.String>;
205
+ readonly country: Schema.optional<Schema.String>;
206
+ readonly translations: Schema.$Array<Schema.Struct<{
207
+ readonly locale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
208
+ readonly label: Schema.NonEmptyString;
209
+ }>>;
210
+ }>>>;
211
+ }>, Schema.Unknown, never, never>>;
61
212
  readonly parentId: Schema.NullOr<Schema.String>;
62
213
  readonly createdAt: Schema.Date;
63
214
  }>;
@@ -83,6 +234,18 @@ export declare const Member: Schema.Struct<{
83
234
  export type User = typeof User.Type;
84
235
  export type Session = typeof Session.Type;
85
236
  export type OrganizationLocale = typeof OrganizationLocale.Type;
237
+ export type EmailAddress = typeof EmailAddress.Type;
238
+ export type PhoneNumber = typeof PhoneNumber.Type;
239
+ export type WebsiteUrl = typeof WebsiteUrl.Type;
240
+ export type SocialPlatform = typeof SocialPlatform.Type;
241
+ export type PostalAddress = typeof PostalAddress.Type;
242
+ export type OrganizationAddress = typeof OrganizationAddress.Type;
243
+ export type FormattedOrganizationAddress = typeof FormattedOrganizationAddress.Type;
244
+ export type OrganizationContactTranslation = typeof OrganizationContactTranslation.Type;
245
+ export type OrganizationEmail = typeof OrganizationEmail.Type;
246
+ export type OrganizationPhone = typeof OrganizationPhone.Type;
247
+ export type OrganizationWebsite = typeof OrganizationWebsite.Type;
248
+ export type OrganizationSocial = typeof OrganizationSocial.Type;
86
249
  export type OrganizationTranslation = typeof OrganizationTranslation.Type;
87
250
  export type OrganizationMetadata = typeof OrganizationMetadata.Type;
88
251
  export type Organization = typeof Organization.Type;
package/dist/schema.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Schema } from "effect";
1
+ import { Option, Schema, SchemaGetter } from "effect";
2
2
  export const User = Schema.Struct({
3
3
  id: Schema.String,
4
4
  name: Schema.String,
@@ -70,12 +70,110 @@ export const OrganizationLocale = Schema.Union([
70
70
  description: "Supported organization translation locale.",
71
71
  examples: ["en", "fr"],
72
72
  });
73
+ export const EmailAddress = Schema.NonEmptyString.check(Schema.isPattern(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)).annotate({
74
+ identifier: "EmailAddress",
75
+ title: "Email address",
76
+ });
77
+ export const PhoneNumber = Schema.NonEmptyString.check(Schema.isPattern(/^\+?[0-9 ()-]{7,}$/)).annotate({
78
+ identifier: "PhoneNumber",
79
+ title: "Phone number",
80
+ });
81
+ export const WebsiteUrl = Schema.NonEmptyString.check(Schema.isPattern(/^https?:\/\/[^\s]+$/)).annotate({
82
+ identifier: "WebsiteUrl",
83
+ title: "Website URL",
84
+ });
85
+ export const SocialPlatform = Schema.Literals([
86
+ "facebook",
87
+ "github",
88
+ "instagram",
89
+ "linkedin",
90
+ "tiktok",
91
+ "x",
92
+ "youtube",
93
+ ]).annotate({
94
+ identifier: "SocialPlatform",
95
+ title: "Social platform",
96
+ });
97
+ export const OrganizationContactTranslation = Schema.Struct({
98
+ locale: OrganizationLocale,
99
+ label: Schema.NonEmptyString.check(Schema.isPattern(/\S/)),
100
+ }).annotate({
101
+ identifier: "OrganizationContactTranslation",
102
+ title: "Organization contact translation",
103
+ });
104
+ export const OrganizationEmail = Schema.Struct({
105
+ email: EmailAddress,
106
+ translations: Schema.Array(OrganizationContactTranslation).check(Schema.isMinLength(1)),
107
+ }).annotate({
108
+ identifier: "OrganizationEmail",
109
+ title: "Organization email",
110
+ });
111
+ export const OrganizationPhone = Schema.Struct({
112
+ number: PhoneNumber,
113
+ extension: Schema.optional(Schema.String),
114
+ translations: Schema.Array(OrganizationContactTranslation).check(Schema.isMinLength(1)),
115
+ }).annotate({
116
+ identifier: "OrganizationPhone",
117
+ title: "Organization phone",
118
+ });
119
+ export const OrganizationWebsite = Schema.Struct({
120
+ url: WebsiteUrl,
121
+ translations: Schema.Array(OrganizationContactTranslation).check(Schema.isMinLength(1)),
122
+ }).annotate({
123
+ identifier: "OrganizationWebsite",
124
+ title: "Organization website",
125
+ });
126
+ export const OrganizationSocial = Schema.Struct({
127
+ platform: SocialPlatform,
128
+ url: WebsiteUrl,
129
+ translations: Schema.Array(OrganizationContactTranslation).check(Schema.isMinLength(1)),
130
+ }).annotate({
131
+ identifier: "OrganizationSocial",
132
+ title: "Organization social profile",
133
+ });
134
+ export const PostalAddress = Schema.Struct({
135
+ streetAddress: Schema.optional(Schema.String),
136
+ locality: Schema.optional(Schema.String),
137
+ region: Schema.optional(Schema.String),
138
+ postalCode: Schema.optional(Schema.String),
139
+ country: Schema.optional(Schema.String),
140
+ }).annotate({
141
+ identifier: "PostalAddress",
142
+ title: "Postal address",
143
+ description: "Structured postal address compatible with OIDC address claims.",
144
+ examples: [
145
+ {
146
+ streetAddress: "123 Example Street",
147
+ locality: "Montreal",
148
+ region: "QC",
149
+ postalCode: "H2X 1Y4",
150
+ country: "Canada",
151
+ },
152
+ ],
153
+ });
154
+ export const OrganizationAddress = Schema.Struct({
155
+ ...PostalAddress.fields,
156
+ translations: Schema.Array(OrganizationContactTranslation).check(Schema.isMinLength(1)),
157
+ }).annotate({
158
+ identifier: "OrganizationAddress",
159
+ title: "Organization address",
160
+ });
161
+ export const FormattedOrganizationAddress = Schema.Struct({
162
+ ...OrganizationAddress.fields,
163
+ formatted: Schema.String,
164
+ }).annotate({
165
+ identifier: "FormattedOrganizationAddress",
166
+ title: "Formatted organization address",
167
+ description: "Organization address with a server-generated display value.",
168
+ });
73
169
  export const OrganizationTranslation = Schema.Struct({
74
170
  locale: OrganizationLocale,
75
171
  name: Schema.String,
76
172
  logo: Schema.optional(Schema.NullOr(Schema.String)),
77
173
  icon: Schema.optional(Schema.NullOr(Schema.String)),
174
+ // Retained when decoding metadata written before repeatable contacts.
78
175
  contactEmail: Schema.optional(Schema.NullOr(Schema.String)),
176
+ // Retained when decoding metadata written before structured addresses.
79
177
  location: Schema.optional(Schema.NullOr(Schema.String)),
80
178
  }).annotate({
81
179
  identifier: "OrganizationTranslation",
@@ -87,17 +185,20 @@ export const OrganizationTranslation = Schema.Struct({
87
185
  name: "KrakStack",
88
186
  logo: "https://example.com/logo.svg",
89
187
  icon: "https://example.com/icon.png",
90
- contactEmail: "team@example.com",
91
- location: "Montreal, QC",
92
188
  },
93
189
  ],
94
190
  });
95
191
  export const OrganizationMetadata = Schema.Struct({
96
192
  translations: Schema.Array(OrganizationTranslation),
193
+ emails: Schema.optional(Schema.Array(OrganizationEmail)),
194
+ phones: Schema.optional(Schema.Array(OrganizationPhone)),
195
+ websites: Schema.optional(Schema.Array(OrganizationWebsite)),
196
+ socials: Schema.optional(Schema.Array(OrganizationSocial)),
197
+ addresses: Schema.optional(Schema.Array(OrganizationAddress)),
97
198
  }).annotate({
98
199
  identifier: "OrganizationMetadata",
99
200
  title: "Organization metadata",
100
- description: "Localized names, logos, icons, contact emails, and locations stored on an organization record.",
201
+ description: "Localized profile and contact details stored on an organization record.",
101
202
  examples: [
102
203
  {
103
204
  translations: [
@@ -106,19 +207,79 @@ export const OrganizationMetadata = Schema.Struct({
106
207
  name: "KrakStack",
107
208
  logo: "https://example.com/logo.svg",
108
209
  icon: "https://example.com/icon.png",
109
- contactEmail: "team@example.com",
110
- location: "Montreal, QC",
210
+ },
211
+ ],
212
+ emails: [
213
+ {
214
+ email: "team@example.com",
215
+ translations: [{ locale: "en", label: "General inquiries" }],
216
+ },
217
+ ],
218
+ phones: [
219
+ {
220
+ number: "+1 514 555 0100",
221
+ translations: [{ locale: "en", label: "Office" }],
222
+ },
223
+ ],
224
+ websites: [
225
+ {
226
+ url: "https://example.com",
227
+ translations: [{ locale: "en", label: "Website" }],
228
+ },
229
+ ],
230
+ socials: [
231
+ {
232
+ platform: "linkedin",
233
+ url: "https://linkedin.com/company/example",
234
+ translations: [{ locale: "en", label: "LinkedIn" }],
235
+ },
236
+ ],
237
+ addresses: [
238
+ {
239
+ streetAddress: "123 Example Street",
240
+ locality: "Montreal",
241
+ region: "QC",
242
+ postalCode: "H2X 1Y4",
243
+ country: "Canada",
244
+ translations: [{ locale: "en", label: "Head office" }],
111
245
  },
112
246
  ],
113
247
  },
114
248
  ],
115
249
  });
250
+ const decodeOrganizationMetadataJson = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Unknown));
251
+ export const decodeOrganizationMetadata = (metadata) => {
252
+ const value = typeof metadata === "string"
253
+ ? Option.getOrNull(decodeOrganizationMetadataJson(metadata))
254
+ : metadata;
255
+ if (typeof value !== "object" || value === null) {
256
+ return { translations: [] };
257
+ }
258
+ const translations = Schema.decodeUnknownOption(Schema.Array(OrganizationTranslation))(Reflect.get(value, "translations"));
259
+ const emails = Schema.decodeUnknownOption(Schema.Array(OrganizationEmail))(Reflect.get(value, "emails"));
260
+ const phones = Schema.decodeUnknownOption(Schema.Array(OrganizationPhone))(Reflect.get(value, "phones"));
261
+ const websites = Schema.decodeUnknownOption(Schema.Array(OrganizationWebsite))(Reflect.get(value, "websites"));
262
+ const socials = Schema.decodeUnknownOption(Schema.Array(OrganizationSocial))(Reflect.get(value, "socials"));
263
+ const addresses = Schema.decodeUnknownOption(Schema.Array(OrganizationAddress))(Reflect.get(value, "addresses"));
264
+ return {
265
+ translations: Option.getOrElse(translations, () => []),
266
+ ...(Option.isSome(emails) ? { emails: emails.value } : {}),
267
+ ...(Option.isSome(phones) ? { phones: phones.value } : {}),
268
+ ...(Option.isSome(websites) ? { websites: websites.value } : {}),
269
+ ...(Option.isSome(socials) ? { socials: socials.value } : {}),
270
+ ...(Option.isSome(addresses) ? { addresses: addresses.value } : {}),
271
+ };
272
+ };
273
+ const CompatibleOrganizationMetadata = Schema.Unknown.pipe(Schema.decodeTo(OrganizationMetadata, {
274
+ decode: SchemaGetter.transform(decodeOrganizationMetadata),
275
+ encode: SchemaGetter.transform((metadata) => metadata),
276
+ }));
116
277
  export const Organization = Schema.Struct({
117
278
  id: Schema.String,
118
279
  name: Schema.String,
119
280
  slug: Schema.String,
120
281
  logo: Schema.NullOr(Schema.String),
121
- metadata: Schema.NullOr(OrganizationMetadata),
282
+ metadata: Schema.NullOr(CompatibleOrganizationMetadata),
122
283
  parentId: Schema.NullOr(Schema.String),
123
284
  createdAt: Schema.Date,
124
285
  }).annotate({
@@ -139,8 +300,41 @@ export const Organization = Schema.Struct({
139
300
  name: "KrakStack",
140
301
  logo: null,
141
302
  icon: null,
142
- contactEmail: "team@example.com",
143
- location: "Montreal, QC",
303
+ },
304
+ ],
305
+ emails: [
306
+ {
307
+ email: "team@example.com",
308
+ translations: [{ locale: "en", label: "General inquiries" }],
309
+ },
310
+ ],
311
+ phones: [
312
+ {
313
+ number: "+1 514 555 0100",
314
+ translations: [{ locale: "en", label: "Office" }],
315
+ },
316
+ ],
317
+ websites: [
318
+ {
319
+ url: "https://example.com",
320
+ translations: [{ locale: "en", label: "Website" }],
321
+ },
322
+ ],
323
+ socials: [
324
+ {
325
+ platform: "linkedin",
326
+ url: "https://linkedin.com/company/example",
327
+ translations: [{ locale: "en", label: "LinkedIn" }],
328
+ },
329
+ ],
330
+ addresses: [
331
+ {
332
+ streetAddress: "123 Example Street",
333
+ locality: "Montreal",
334
+ region: "QC",
335
+ postalCode: "H2X 1Y4",
336
+ country: "Canada",
337
+ translations: [{ locale: "en", label: "Head office" }],
144
338
  },
145
339
  ],
146
340
  },