@taruvi/sdk 1.3.5 → 1.3.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taruvi/sdk",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "description": "Taruvi SDK",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
package/src/index.ts CHANGED
@@ -24,7 +24,7 @@ export type { TaruviConfig, TaruviResponse, PaginationInfo, StorageFilters, Data
24
24
  export type { AuthTokens } from "./lib-internal/token/TokenClient.js"
25
25
 
26
26
  // User types
27
- export type { UserCreateRequest, UserData, UserUpdateRequest, UserListFilters, UserApp, UserResponse, UserListResponse, UserAppsResponse, AssignRolesRequest, RevokeRolesRequest, RolesResponse, UserGroup, UserPermission, UserRole } from "./lib/users/types.js"
27
+ export type { UserCreateRequest, UserData, UserUpdateRequest, UserListFilters, UserApp, UserResponse, UserListResponse, UserAppsResponse, AssignRolesRequest, RevokeRolesRequest, RolesResponse, UserGroup, UserPermission, UserRole, UserPreferences, UserPreferencesUpdate, UserPreferencesResponse } from "./lib/users/types.js"
28
28
 
29
29
  // Policy types
30
30
  export type { Principal, Resource, Resources, PolicyCheckResult, PolicyCheckBatchResult, ResourceCheckResponse } from "./lib/policy/types.js"
@@ -19,15 +19,17 @@ export class Storage {
19
19
  private operation: HttpMethod | undefined
20
20
  private body: object | undefined
21
21
  private filters: StorageFilters | undefined
22
+ private queryParams: Record<string, string> | undefined
22
23
 
23
24
 
24
- constructor(client: Client, urlParams: BucketUrlParams = {} as BucketUrlParams, operation?: HttpMethod | undefined, body?: object, filters?: StorageFilters) {
25
+ constructor(client: Client, urlParams: BucketUrlParams = {} as BucketUrlParams, operation?: HttpMethod | undefined, body?: object, filters?: StorageFilters, queryParams?: Record<string, string>) {
25
26
  this.client = client
26
27
  this.urlParams = urlParams
27
28
  this.operation = operation
28
29
  this.config = this.client.getConfig()
29
30
  this.body = body
30
31
  this.filters = filters
32
+ this.queryParams = queryParams
31
33
  }
32
34
 
33
35
 
@@ -50,7 +52,7 @@ export class Storage {
50
52
  }
51
53
 
52
54
  download(path: string): Storage {
53
- return new Storage(this.client, { ...this.urlParams, path }, HttpMethod.GET, undefined, { metadata: 'true' } as unknown as StorageFilters)
55
+ return new Storage(this.client, { ...this.urlParams, path }, HttpMethod.GET, undefined, undefined, { metadata: 'true' })
54
56
  }
55
57
 
56
58
  upload(filesData: { files: File[], metadatas: object[], paths: string[] }): Storage {
@@ -86,7 +88,7 @@ export class Storage {
86
88
  return acc
87
89
  }, '') +
88
90
  '/' +
89
- buildQueryString(this.filters as Record<string, unknown>)
91
+ buildQueryString({ ...this.filters as Record<string, unknown>, ...this.queryParams })
90
92
  )
91
93
  }
92
94
 
@@ -1,5 +1,5 @@
1
1
  import type { Client } from "../../client.js";
2
- import type { UserCreateRequest, UserResponse, UserListResponse, UserListFilters, UserUpdateRequest, UserAppsResponse, AssignRolesRequest, RevokeRolesRequest, RolesResponse } from "./types.js";
2
+ import type { UserCreateRequest, UserResponse, UserListResponse, UserListFilters, UserUpdateRequest, UserAppsResponse, AssignRolesRequest, RevokeRolesRequest, RolesResponse, UserPreferencesResponse, UserPreferencesUpdate } from "./types.js";
3
3
  import { UserRoutes } from "../../lib-internal/routes/UserRoutes.js";
4
4
  import { buildQueryString } from "../../utils/utils.js";
5
5
 
@@ -52,4 +52,12 @@ export class User {
52
52
  request
53
53
  )
54
54
  }
55
+
56
+ async getPreferences(): Promise<UserPreferencesResponse> {
57
+ return await this.client.httpClient.get<UserPreferencesResponse>(UserRoutes.getPreferences())
58
+ }
59
+
60
+ async updatePreferences(body: UserPreferencesUpdate): Promise<UserPreferencesResponse> {
61
+ return await this.client.httpClient.put<UserPreferencesResponse>(UserRoutes.getPreferences(), body)
62
+ }
55
63
  }
@@ -88,6 +88,24 @@ export type UserResponse = TaruviResponse<UserData>
88
88
  export type UserListResponse = TaruviResponse<UserData[]>
89
89
  export type UserAppsResponse = TaruviResponse<UserApp[]>
90
90
 
91
+ export interface UserPreferences {
92
+ date_format: string
93
+ time_format: string
94
+ timezone: string
95
+ theme: string
96
+ widget_config: Record<string, unknown>
97
+ }
98
+
99
+ export interface UserPreferencesUpdate {
100
+ date_format?: string
101
+ time_format?: string
102
+ timezone?: string
103
+ theme?: string
104
+ widget_config?: Record<string, unknown>
105
+ }
106
+
107
+ export type UserPreferencesResponse = TaruviResponse<UserPreferences>
108
+
91
109
  export interface AssignRolesRequest {
92
110
  roles: string[]
93
111
  usernames: string[]
@@ -6,6 +6,7 @@ export const UserRoutes = {
6
6
  deleteUser: (username: string) => `${UserRoutes.baseUrl}${username}/`,
7
7
  listUser: (filter: string) => `${UserRoutes.baseUrl}${filter}`,
8
8
  getUserApps: (username: string) => `${UserRoutes.baseUrl}${username}/apps/`,
9
+ getPreferences: () => `${UserRoutes.baseUrl}me/preferences/`,
9
10
  assignRoles: () => `api/assign/roles/`,
10
11
  revokeRoles: () => `api/revoke/roles/`
11
12
  } as const