@rustrak/client 0.14.2 → 0.14.3

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.d.cts CHANGED
@@ -1010,6 +1010,12 @@ declare const userSchema: z.ZodObject<{
1010
1010
  member: "member";
1011
1011
  }>;
1012
1012
  is_admin: z.ZodBoolean;
1013
+ language: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1014
+ timezone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1015
+ }, z.core.$strip>;
1016
+ declare const updatePreferencesRequestSchema: z.ZodObject<{
1017
+ language: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1018
+ timezone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1013
1019
  }, z.core.$strip>;
1014
1020
  declare const authResponseSchema: z.ZodObject<{
1015
1021
  user: z.ZodObject<{
@@ -1020,6 +1026,8 @@ declare const authResponseSchema: z.ZodObject<{
1020
1026
  member: "member";
1021
1027
  }>;
1022
1028
  is_admin: z.ZodBoolean;
1029
+ language: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1030
+ timezone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1023
1031
  }, z.core.$strip>;
1024
1032
  }, z.core.$strip>;
1025
1033
  declare const loginResultSchema: z.ZodObject<{
@@ -1031,6 +1039,8 @@ declare const loginResultSchema: z.ZodObject<{
1031
1039
  member: "member";
1032
1040
  }>;
1033
1041
  is_admin: z.ZodBoolean;
1042
+ language: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1043
+ timezone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1034
1044
  }, z.core.$strip>;
1035
1045
  cookies: z.ZodArray<z.ZodString>;
1036
1046
  }, z.core.$strip>;
@@ -1044,6 +1054,7 @@ declare const registerRequestSchema: z.ZodObject<{
1044
1054
  }, z.core.$strip>;
1045
1055
 
1046
1056
  type User = z.infer<typeof userSchema>;
1057
+ type UpdatePreferencesRequest = z.infer<typeof updatePreferencesRequestSchema>;
1047
1058
  type AuthResponse = z.infer<typeof authResponseSchema>;
1048
1059
  type LoginResult = z.infer<typeof loginResultSchema>;
1049
1060
  type LoginRequest = z.infer<typeof loginRequestSchema>;
@@ -1092,6 +1103,7 @@ declare class AuthResource extends BaseResource {
1092
1103
  login(credentials: LoginRequest): Promise<Result<LoginResult, RustrakError>>;
1093
1104
  logout(): Promise<Result<string[], RustrakError>>;
1094
1105
  getCurrentUser(): Promise<Result<User, RustrakError>>;
1106
+ updatePreferences(preferences: UpdatePreferencesRequest): Promise<Result<User, RustrakError>>;
1095
1107
  getInvitation(token: string): Promise<Result<InvitationInfo, RustrakError>>;
1096
1108
  acceptInvitation(input: AcceptInvitation): Promise<Result<LoginResult, RustrakError>>;
1097
1109
  private readLoginResult;
package/dist/index.d.ts CHANGED
@@ -1010,6 +1010,12 @@ declare const userSchema: z.ZodObject<{
1010
1010
  member: "member";
1011
1011
  }>;
1012
1012
  is_admin: z.ZodBoolean;
1013
+ language: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1014
+ timezone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1015
+ }, z.core.$strip>;
1016
+ declare const updatePreferencesRequestSchema: z.ZodObject<{
1017
+ language: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1018
+ timezone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1013
1019
  }, z.core.$strip>;
1014
1020
  declare const authResponseSchema: z.ZodObject<{
1015
1021
  user: z.ZodObject<{
@@ -1020,6 +1026,8 @@ declare const authResponseSchema: z.ZodObject<{
1020
1026
  member: "member";
1021
1027
  }>;
1022
1028
  is_admin: z.ZodBoolean;
1029
+ language: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1030
+ timezone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1023
1031
  }, z.core.$strip>;
1024
1032
  }, z.core.$strip>;
1025
1033
  declare const loginResultSchema: z.ZodObject<{
@@ -1031,6 +1039,8 @@ declare const loginResultSchema: z.ZodObject<{
1031
1039
  member: "member";
1032
1040
  }>;
1033
1041
  is_admin: z.ZodBoolean;
1042
+ language: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1043
+ timezone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1034
1044
  }, z.core.$strip>;
1035
1045
  cookies: z.ZodArray<z.ZodString>;
1036
1046
  }, z.core.$strip>;
@@ -1044,6 +1054,7 @@ declare const registerRequestSchema: z.ZodObject<{
1044
1054
  }, z.core.$strip>;
1045
1055
 
1046
1056
  type User = z.infer<typeof userSchema>;
1057
+ type UpdatePreferencesRequest = z.infer<typeof updatePreferencesRequestSchema>;
1047
1058
  type AuthResponse = z.infer<typeof authResponseSchema>;
1048
1059
  type LoginResult = z.infer<typeof loginResultSchema>;
1049
1060
  type LoginRequest = z.infer<typeof loginRequestSchema>;
@@ -1092,6 +1103,7 @@ declare class AuthResource extends BaseResource {
1092
1103
  login(credentials: LoginRequest): Promise<Result<LoginResult, RustrakError>>;
1093
1104
  logout(): Promise<Result<string[], RustrakError>>;
1094
1105
  getCurrentUser(): Promise<Result<User, RustrakError>>;
1106
+ updatePreferences(preferences: UpdatePreferencesRequest): Promise<Result<User, RustrakError>>;
1095
1107
  getInvitation(token: string): Promise<Result<InvitationInfo, RustrakError>>;
1096
1108
  acceptInvitation(input: AcceptInvitation): Promise<Result<LoginResult, RustrakError>>;
1097
1109
  private readLoginResult;
package/dist/index.js CHANGED
@@ -620,7 +620,21 @@ var userSchema = z.object({
620
620
  id: z.number().int().positive(),
621
621
  email: z.string().email(),
622
622
  role: globalRoleSchema,
623
- is_admin: z.boolean()
623
+ is_admin: z.boolean(),
624
+ /**
625
+ * The dashboard language this user chose.
626
+ *
627
+ * `null` means they never chose one, which a consumer should treat as
628
+ * "infer it" rather than as English. Optional as well as nullable so a
629
+ * client stays compatible with a server predating the column.
630
+ */
631
+ language: z.string().nullable().optional(),
632
+ /** The IANA timezone this user chose, `null` when they never chose one. */
633
+ timezone: z.string().nullable().optional()
634
+ });
635
+ var updatePreferencesRequestSchema = z.object({
636
+ language: z.string().nullable().optional(),
637
+ timezone: z.string().nullable().optional()
624
638
  });
625
639
  var authResponseSchema = z.object({
626
640
  user: userSchema
@@ -1301,6 +1315,24 @@ var AuthResource = class extends BaseResource {
1301
1315
  async getCurrentUser() {
1302
1316
  return this.request(() => this.http.get("auth/me"), userSchema);
1303
1317
  }
1318
+ /**
1319
+ * Stores how this reader wants the dashboard presented to them.
1320
+ *
1321
+ * A key left out is left alone; a key sent as `null` is cleared. That is why
1322
+ * the request type is optional *and* nullable rather than one or the other:
1323
+ * "do not touch" and "forget my choice" are different instructions.
1324
+ */
1325
+ async updatePreferences(preferences) {
1326
+ const validatedInput = this.validateInput(
1327
+ preferences,
1328
+ updatePreferencesRequestSchema
1329
+ );
1330
+ if (!validatedInput.success) return validatedInput;
1331
+ return this.request(
1332
+ () => this.http.patch("auth/me", { json: validatedInput.data }),
1333
+ userSchema
1334
+ );
1335
+ }
1304
1336
  /**
1305
1337
  * Get the details of a pending invitation by its token (public endpoint)
1306
1338
  * Used by the accept-invitation page before the user has an account