@rixl/sdk 0.39.0 → 0.40.0

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.js CHANGED
@@ -5,15 +5,6 @@ import * as v from "valibot";
5
5
  //#region src/generated/core/bodySerializer.gen.ts
6
6
  const jsonBodySerializer = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
7
7
 
8
- //#endregion
9
- //#region src/generated/core/params.gen.ts
10
- const extraPrefixes = Object.entries({
11
- $body_: "body",
12
- $headers_: "headers",
13
- $path_: "path",
14
- $query_: "query"
15
- });
16
-
17
8
  //#endregion
18
9
  //#region src/generated/core/serverSentEvents.gen.ts
19
10
  function createSseClient({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) {
@@ -2684,7 +2675,7 @@ const createOAuthProvider = ({ provider, metadata }) => {
2684
2675
 
2685
2676
  //#endregion
2686
2677
  //#region src/auth/providers/google.ts
2687
- const googleProvider = createOAuthProvider({
2678
+ const googleProvider = /* @__PURE__ */ createOAuthProvider({
2688
2679
  provider: "google",
2689
2680
  metadata: {
2690
2681
  name: "Google",
@@ -2703,7 +2694,7 @@ const updateGoogleAuthUrl = googleProvider.updateAuthUrl;
2703
2694
 
2704
2695
  //#endregion
2705
2696
  //#region src/auth/providers/microsoft.ts
2706
- const microsoftProvider = createOAuthProvider({
2697
+ const microsoftProvider = /* @__PURE__ */ createOAuthProvider({
2707
2698
  provider: "microsoft",
2708
2699
  metadata: {
2709
2700
  name: "Microsoft",
@@ -2723,7 +2714,7 @@ const updateMicrosoftAuthUrl = microsoftProvider.updateAuthUrl;
2723
2714
 
2724
2715
  //#endregion
2725
2716
  //#region src/auth/providers/apple.ts
2726
- const appleProvider = createOAuthProvider({
2717
+ const appleProvider = /* @__PURE__ */ createOAuthProvider({
2727
2718
  provider: "apple",
2728
2719
  metadata: {
2729
2720
  name: "Apple",
@@ -3398,23 +3389,59 @@ const onLogoutElsewhere = (handler) => {
3398
3389
 
3399
3390
  //#endregion
3400
3391
  //#region src/auth/authStore.ts
3401
- const isLogged = shared("isLogged", () => atom(initVals["isLogged"] === "true"));
3402
- const accessToken = shared("accessToken", () => atom(initVals["accessToken"]));
3403
- const refreshToken = shared("refreshToken", () => atom(initVals["refreshToken"]));
3404
- const expireAt = shared("expireAt", () => atom(Number(initVals["expireAt"])));
3392
+ const ensureSessionSync = () => {
3393
+ shared("sessionSyncInitialized", () => {
3394
+ onLogoutElsewhere(() => removeTokens());
3395
+ return true;
3396
+ });
3397
+ };
3398
+ const isLogged = shared("isLogged", () => {
3399
+ ensureSessionSync();
3400
+ const store = atom(initVals["isLogged"] === "true");
3401
+ store.subscribe((value) => setStoreCookie("isLogged", value));
3402
+ return store;
3403
+ });
3404
+ const accessToken = shared("accessToken", () => {
3405
+ ensureSessionSync();
3406
+ const store = atom(initVals["accessToken"]);
3407
+ store.subscribe((value) => setStoreCookie("accessToken", value));
3408
+ return store;
3409
+ });
3410
+ const refreshToken = shared("refreshToken", () => {
3411
+ ensureSessionSync();
3412
+ const store = atom(initVals["refreshToken"]);
3413
+ store.subscribe((value) => setStoreCookie("refreshToken", value));
3414
+ return store;
3415
+ });
3416
+ const expireAt = shared("expireAt", () => {
3417
+ const store = atom(Number(initVals["expireAt"]));
3418
+ store.subscribe((value) => setStoreCookie("expireAt", value));
3419
+ return store;
3420
+ });
3405
3421
  const authError = shared("authError", () => atom(null));
3406
- const requiresAction = shared("requiresAction", () => atom(initVals["requiresAction"] || null));
3407
- const limitedAccessToken = shared("limitedAccessToken", () => atom(initVals["limitedAccessToken"] || null));
3422
+ const requiresAction = shared("requiresAction", () => {
3423
+ const store = atom(initVals["requiresAction"] || null);
3424
+ store.subscribe((value) => setStoreCookie("requiresAction", value));
3425
+ return store;
3426
+ });
3427
+ const limitedAccessToken = shared("limitedAccessToken", () => {
3428
+ const store = atom(initVals["limitedAccessToken"] || null);
3429
+ store.subscribe((value) => setStoreCookie("limitedAccessToken", value));
3430
+ return store;
3431
+ });
3408
3432
  const inFlight = shared("getTokenPromise", () => ({ promise: null }));
3409
- const PROVIDER_URL_MAP = {
3410
- google: googleAuthUrl,
3411
- apple: appleAuthUrl,
3412
- microsoft: microsoftAuthUrl,
3413
- telegram: telegramAuthUrl
3433
+ const getProviderUrlAtom = (provider) => {
3434
+ switch (provider) {
3435
+ case "google": return googleAuthUrl;
3436
+ case "apple": return appleAuthUrl;
3437
+ case "microsoft": return microsoftAuthUrl;
3438
+ case "telegram": return telegramAuthUrl;
3439
+ default: return;
3440
+ }
3414
3441
  };
3415
3442
  const login = async (provider) => {
3416
3443
  await initDeferred.promise;
3417
- const authUrlAtom = PROVIDER_URL_MAP[provider];
3444
+ const authUrlAtom = getProviderUrlAtom(provider);
3418
3445
  if (!authUrlAtom) throw new Error(`Unsupported provider: ${provider}`);
3419
3446
  const authUrl = authUrlAtom.get();
3420
3447
  if (authUrl) window.location.href = authUrl;
@@ -3565,13 +3592,6 @@ const clearLimitedAccessState = () => {
3565
3592
  requiresAction.set(null);
3566
3593
  if (!(!!accessToken.get() && !!refreshToken.get())) isLogged.set(false);
3567
3594
  };
3568
- isLogged.subscribe((value) => setStoreCookie("isLogged", value));
3569
- accessToken.subscribe((value) => setStoreCookie("accessToken", value));
3570
- refreshToken.subscribe((value) => setStoreCookie("refreshToken", value));
3571
- expireAt.subscribe((value) => setStoreCookie("expireAt", value));
3572
- requiresAction.subscribe((value) => setStoreCookie("requiresAction", value));
3573
- limitedAccessToken.subscribe((value) => setStoreCookie("limitedAccessToken", value));
3574
- onLogoutElsewhere(removeTokens);
3575
3595
 
3576
3596
  //#endregion
3577
3597
  //#region src/auth/api-url.ts
@@ -3847,19 +3867,19 @@ const validateInput = (schema, data) => {
3847
3867
  throw error;
3848
3868
  }
3849
3869
  };
3850
- const EmailSchema = v.pipe(v.string("Email must be text"), v.email("Please enter a valid email address"), v.minLength(1, "Email is required"));
3851
- const PasswordSchema = v.pipe(v.string("Password must be text"), v.minLength(8, "Password must be at least 8 characters long"), v.regex(/[A-Z]/, "Password must contain at least one uppercase letter"), v.regex(/[a-z]/, "Password must contain at least one lowercase letter"), v.regex(/[0-9]/, "Password must contain at least one number"));
3870
+ const EmailSchema = /* @__PURE__ */ v.pipe(/* @__PURE__ */ v.string("Email must be text"), /* @__PURE__ */ v.email("Please enter a valid email address"), /* @__PURE__ */ v.minLength(1, "Email is required"));
3871
+ const PasswordSchema = /* @__PURE__ */ v.pipe(/* @__PURE__ */ v.string("Password must be text"), /* @__PURE__ */ v.minLength(8, "Password must be at least 8 characters long"), /* @__PURE__ */ v.regex(/[A-Z]/, "Password must contain at least one uppercase letter"), /* @__PURE__ */ v.regex(/[a-z]/, "Password must contain at least one lowercase letter"), /* @__PURE__ */ v.regex(/[0-9]/, "Password must contain at least one number"));
3852
3872
  /**
3853
3873
  * Username validation schema
3854
3874
  * - Must be 4-24 characters
3855
3875
  * - Only letters, numbers, underscores, and periods
3856
3876
  */
3857
- const UsernameSchema = v.pipe(v.string("Username must be text"), v.minLength(4, "Username must be 4-24 characters long"), v.maxLength(24, "Username must be 4-24 characters long"), v.regex(/^[a-z0-9_.]+$/, "Username can only contain lowercase letters, numbers, dots and underscores"));
3877
+ const UsernameSchema = /* @__PURE__ */ v.pipe(/* @__PURE__ */ v.string("Username must be text"), /* @__PURE__ */ v.minLength(4, "Username must be 4-24 characters long"), /* @__PURE__ */ v.maxLength(24, "Username must be 4-24 characters long"), /* @__PURE__ */ v.regex(/^[a-z0-9_.]+$/, "Username can only contain lowercase letters, numbers, dots and underscores"));
3858
3878
  /**
3859
3879
  * Name validation schema
3860
3880
  * - Must be 1-30 characters
3861
3881
  */
3862
- const NameSchema = v.pipe(v.string("Name must be text"), v.minLength(1, "Name must be 1-30 characters long"), v.maxLength(30, "Name must be 1-30 characters long"));
3882
+ const NameSchema = /* @__PURE__ */ v.pipe(/* @__PURE__ */ v.string("Name must be text"), /* @__PURE__ */ v.minLength(1, "Name must be 1-30 characters long"), /* @__PURE__ */ v.maxLength(30, "Name must be 1-30 characters long"));
3863
3883
  /**
3864
3884
  * Domain validation schema
3865
3885
  * - Must be lowercase
@@ -3867,47 +3887,47 @@ const NameSchema = v.pipe(v.string("Name must be text"), v.minLength(1, "Name mu
3867
3887
  * - Only alphanumeric characters, hyphens, and dots
3868
3888
  * - Cannot start or end with hyphen in any part
3869
3889
  */
3870
- const DomainSchema = v.pipe(v.string("Domain must be text"), v.trim(), v.toLowerCase(), v.minLength(1, "Domain is required"), v.regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/, "Invalid domain format. Please enter a valid domain like company.com"));
3890
+ const DomainSchema = /* @__PURE__ */ v.pipe(/* @__PURE__ */ v.string("Domain must be text"), /* @__PURE__ */ v.trim(), /* @__PURE__ */ v.toLowerCase(), /* @__PURE__ */ v.minLength(1, "Domain is required"), /* @__PURE__ */ v.regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/, "Invalid domain format. Please enter a valid domain like company.com"));
3871
3891
 
3872
3892
  //#endregion
3873
3893
  //#region src/auth/validation/auth.ts
3874
- const EmailAuthRequestSchema = v.object({
3894
+ const EmailAuthRequestSchema = /* @__PURE__ */ v.object({
3875
3895
  email: EmailSchema,
3876
3896
  password: PasswordSchema
3877
3897
  });
3878
- const RegisterRequestSchema = v.object({
3898
+ const RegisterRequestSchema = /* @__PURE__ */ v.object({
3879
3899
  email: EmailSchema,
3880
3900
  password: PasswordSchema,
3881
- country_code: v.optional(v.string()),
3882
- subscribe_to_blog: v.optional(v.boolean())
3901
+ country_code: /* @__PURE__ */ v.optional(/* @__PURE__ */ v.string()),
3902
+ subscribe_to_blog: /* @__PURE__ */ v.optional(/* @__PURE__ */ v.boolean())
3883
3903
  });
3884
- const ResetPasswordRequestSchema = v.object({
3885
- token: v.string(),
3904
+ const ResetPasswordRequestSchema = /* @__PURE__ */ v.object({
3905
+ token: /* @__PURE__ */ v.string(),
3886
3906
  new_password: PasswordSchema
3887
3907
  });
3888
- const LoginOTPVerifyRequestSchema = v.object({
3889
- code: v.pipe(v.string("TOTP or backup code must be text"), v.minLength(1, "TOTP or backup code is required")),
3890
- session_id: v.pipe(v.string("Session ID must be text"), v.minLength(1, "Session ID is required"))
3908
+ const LoginOTPVerifyRequestSchema = /* @__PURE__ */ v.object({
3909
+ code: /* @__PURE__ */ v.pipe(/* @__PURE__ */ v.string("TOTP or backup code must be text"), /* @__PURE__ */ v.minLength(1, "TOTP or backup code is required")),
3910
+ session_id: /* @__PURE__ */ v.pipe(/* @__PURE__ */ v.string("Session ID must be text"), /* @__PURE__ */ v.minLength(1, "Session ID is required"))
3891
3911
  });
3892
- const ResendEmailRequestSchema = v.object({ email: EmailSchema });
3893
- const ChangeEmailRequestSchema = v.object({ new_email: EmailSchema });
3894
- const verifyEmailChangeRequestSchema = v.object({
3895
- code: v.pipe(v.string("OTP code must be text"), v.minLength(6, "OTP code must be at least 6 characters"), v.maxLength(8, "OTP code must be at most 8 characters"), v.regex(/^\d+$/, "OTP code must contain only numbers")),
3896
- new_email: v.optional(EmailSchema),
3897
- type: v.union([v.literal("verification"), v.literal("email_change")]),
3898
- verification_id: v.string("Verification ID is required")
3912
+ const ResendEmailRequestSchema = /* @__PURE__ */ v.object({ email: EmailSchema });
3913
+ const ChangeEmailRequestSchema = /* @__PURE__ */ v.object({ new_email: EmailSchema });
3914
+ const verifyEmailChangeRequestSchema = /* @__PURE__ */ v.object({
3915
+ code: /* @__PURE__ */ v.pipe(/* @__PURE__ */ v.string("OTP code must be text"), /* @__PURE__ */ v.minLength(6, "OTP code must be at least 6 characters"), /* @__PURE__ */ v.maxLength(8, "OTP code must be at most 8 characters"), /* @__PURE__ */ v.regex(/^\d+$/, "OTP code must contain only numbers")),
3916
+ new_email: /* @__PURE__ */ v.optional(EmailSchema),
3917
+ type: /* @__PURE__ */ v.union([/* @__PURE__ */ v.literal("verification"), /* @__PURE__ */ v.literal("email_change")]),
3918
+ verification_id: /* @__PURE__ */ v.string("Verification ID is required")
3899
3919
  });
3900
3920
  /**
3901
3921
  * Social provider schemas
3902
3922
  */
3903
- const ConnectProviderSchema = v.object({
3904
- provider: v.pipe(v.string("Provider must be text"), v.minLength(1, "Provider is required")),
3905
- token: v.pipe(v.string("Token must be text"), v.minLength(1, "Token is required"))
3923
+ const ConnectProviderSchema = /* @__PURE__ */ v.object({
3924
+ provider: /* @__PURE__ */ v.pipe(/* @__PURE__ */ v.string("Provider must be text"), /* @__PURE__ */ v.minLength(1, "Provider is required")),
3925
+ token: /* @__PURE__ */ v.pipe(/* @__PURE__ */ v.string("Token must be text"), /* @__PURE__ */ v.minLength(1, "Token is required"))
3906
3926
  });
3907
3927
  /**
3908
3928
  * OTP verification schema (for user OTP operations)
3909
3929
  */
3910
- const VerifyOTPCodeSchema = v.object({ code: v.pipe(v.string("OTP code must be text"), v.minLength(6, "OTP code must be at least 6 characters"), v.regex(/^\d+$/, "OTP code must contain only numbers")) });
3930
+ const VerifyOTPCodeSchema = /* @__PURE__ */ v.object({ code: /* @__PURE__ */ v.pipe(/* @__PURE__ */ v.string("OTP code must be text"), /* @__PURE__ */ v.minLength(6, "OTP code must be at least 6 characters"), /* @__PURE__ */ v.regex(/^\d+$/, "OTP code must contain only numbers")) });
3911
3931
 
3912
3932
  //#endregion
3913
3933
  //#region src/auth/social/socialConnections.ts
@@ -4355,17 +4375,17 @@ const listOrganizationMembers = async (orgId, paginationParams) => {
4355
4375
  /**
4356
4376
  * Membership state schemas
4357
4377
  */
4358
- const AcceptDeclineMembershipSchema = v.object({ state: v.union([v.literal("accepted"), v.literal("declined")]) });
4359
- const PublicInviteResponseSchema = v.object({ state: v.union([v.literal("accept"), v.literal("decline")]) });
4378
+ const AcceptDeclineMembershipSchema = /* @__PURE__ */ v.object({ state: /* @__PURE__ */ v.union([/* @__PURE__ */ v.literal("accepted"), /* @__PURE__ */ v.literal("declined")]) });
4379
+ const PublicInviteResponseSchema = /* @__PURE__ */ v.object({ state: /* @__PURE__ */ v.union([/* @__PURE__ */ v.literal("accept"), /* @__PURE__ */ v.literal("decline")]) });
4360
4380
  /**
4361
4381
  * Membership management schemas
4362
4382
  */
4363
- const InviteMemberSchema = v.object({
4383
+ const InviteMemberSchema = /* @__PURE__ */ v.object({
4364
4384
  username: UsernameSchema,
4365
- role: v.union([v.literal("admin"), v.literal("member")])
4385
+ role: /* @__PURE__ */ v.union([/* @__PURE__ */ v.literal("admin"), /* @__PURE__ */ v.literal("member")])
4366
4386
  });
4367
- const UpdateMemberRoleSchema = v.object({ role: v.union([v.literal("admin"), v.literal("member")]) });
4368
- const ResendInviteSchema = v.object({ user_id: v.pipe(v.string("User ID must be text"), v.minLength(1, "User ID is required")) });
4387
+ const UpdateMemberRoleSchema = /* @__PURE__ */ v.object({ role: /* @__PURE__ */ v.union([/* @__PURE__ */ v.literal("admin"), /* @__PURE__ */ v.literal("member")]) });
4388
+ const ResendInviteSchema = /* @__PURE__ */ v.object({ user_id: /* @__PURE__ */ v.pipe(/* @__PURE__ */ v.string("User ID must be text"), /* @__PURE__ */ v.minLength(1, "User ID is required")) });
4369
4389
 
4370
4390
  //#endregion
4371
4391
  //#region src/auth/membership/invite.ts
@@ -4514,11 +4534,11 @@ const leaveOrganization = async (orgId) => {
4514
4534
  /**
4515
4535
  * Update username request schema
4516
4536
  */
4517
- const UpdateUsernameSchema = v.object({ username: UsernameSchema });
4537
+ const UpdateUsernameSchema = /* @__PURE__ */ v.object({ username: UsernameSchema });
4518
4538
  /**
4519
4539
  * Update name request schema
4520
4540
  */
4521
- const UpdateNameSchema = v.object({ full_name: NameSchema });
4541
+ const UpdateNameSchema = /* @__PURE__ */ v.object({ full_name: NameSchema });
4522
4542
 
4523
4543
  //#endregion
4524
4544
  //#region src/auth/user.ts
@@ -4900,11 +4920,11 @@ const getEmailVerificationStatus = async () => {
4900
4920
  /**
4901
4921
  * Add domain request schema
4902
4922
  */
4903
- const AddDomainSchema = v.object({ domain: DomainSchema });
4923
+ const AddDomainSchema = /* @__PURE__ */ v.object({ domain: DomainSchema });
4904
4924
  /**
4905
4925
  * Update auto-join setting schema
4906
4926
  */
4907
- const UpdateAutoJoinSchema = v.object({ enabled: v.boolean("Auto-join setting must be a boolean") });
4927
+ const UpdateAutoJoinSchema = /* @__PURE__ */ v.object({ enabled: /* @__PURE__ */ v.boolean("Auto-join setting must be a boolean") });
4908
4928
 
4909
4929
  //#endregion
4910
4930
  //#region src/auth/domain/types.ts