@taruvi/sdk 1.2.2 → 1.2.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/README.md CHANGED
@@ -564,6 +564,7 @@ const storage = new Storage(taruviClient)
564
564
  await storage
565
565
  .from("documents")
566
566
  .update("path/to/file.pdf", {
567
+ filename: "newname.pdf",
567
568
  visibility: "public",
568
569
  metadata: { category: "reports" }
569
570
  })
@@ -892,7 +893,14 @@ console.log(secret) // Secret object with value
892
893
  const secrets = new Secrets(taruviClient)
893
894
 
894
895
  await secrets.update("MY_SECRET", {
895
- value: "my-secret-value"
896
+ value: {
897
+ hostname: "db.example.com",
898
+ port_number: 3306,
899
+ username: "admin",
900
+ password: "secret123"
901
+ },
902
+ tags: ["mysql", "production"],
903
+ secret_type: "Mysql"
896
904
  }).execute()
897
905
  ```
898
906
 
@@ -1154,8 +1162,7 @@ const userData: UserCreateRequest = {
1154
1162
  first_name: "John",
1155
1163
  last_name: "Doe",
1156
1164
  is_active: true,
1157
- is_staff: false,
1158
- attributes: ""
1165
+ is_staff: false
1159
1166
  }
1160
1167
 
1161
1168
  // Database filters with operators
@@ -1318,4 +1325,4 @@ const client = new Client({
1318
1325
 
1319
1326
  ---
1320
1327
 
1321
- **Generated from production code examples • Last updated: 2026-01-12**
1328
+ **Generated from production code examples • Last updated: 2026-01-05**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taruvi/sdk",
3
- "version": "1.2.02",
3
+ "version": "1.2.3",
4
4
  "description": "Taruvi SDK",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -19,4 +19,4 @@
19
19
  "typescript": ">=5.7 <6",
20
20
  "axios": ">=1 <2"
21
21
  }
22
- }
22
+ }
package/src/index.ts CHANGED
@@ -20,7 +20,7 @@ export type { UserCreateRequest, UserCreateResponse as UserResponse, UserDataRes
20
20
  export type { Principal, Resource, Resources } from "./lib/Policy/types.js"
21
21
  export type { RoleResponse } from "./lib/App/types.js"
22
22
  export type { FunctionRequest, FunctionResponse, FunctionInvocation } from "./lib/Function/types.js"
23
- export type { DatabaseRequest, DatabaseResponse, FilterOperator, SortOrder } from "./lib/Database/types.js"
23
+ export type { DatabaseRequest, DatabaseResponse } from "./lib/Database/types.js"
24
24
  export type { StorageRequest, StorageUpdateRequest, StorageResponse } from "./lib/Storage/types.js"
25
25
  export type { SettingsResponse } from "./lib/Settings/types.js"
26
26
  export type { SecretRequest, SecretResponse } from "./lib/Secrets/types.js"
@@ -2,11 +2,11 @@ import type { Client } from "../../client.js";
2
2
  import { DatabaseRoutes, type DatabaseRouteKey } from "../../lib-internal/routes/DatabaseRoutes.js";
3
3
  import { HttpMethod } from "../../lib-internal/http/types.js";
4
4
  import type { TaruviConfig, DatabaseFilters } from "../../types.js";
5
- import type { UrlParams, FilterOperator, SortOrder } from "./types.js";
5
+ import type { UrlParams } from "./types.js";
6
6
  import { buildQueryString } from "../../utils/utils.js";
7
7
 
8
8
  // Used to access app data
9
- export class Database<T = Record<string, unknown>> {
9
+ export class Database {
10
10
  private client: Client
11
11
  private urlParams: UrlParams
12
12
  private config: TaruviConfig
@@ -21,83 +21,35 @@ export class Database<T = Record<string, unknown>> {
21
21
  this.body = body
22
22
  this.config = this.client.getConfig()
23
23
  this.queryParams = queryParams
24
- }
25
-
26
- from<U = Record<string, unknown>>(dataTables: string): Database<U> {
27
- return new Database<U>(this.client, { ...this.urlParams, dataTables }, undefined, undefined)
28
- }
29
-
30
- filter(field: string, operator: FilterOperator, value: string | number | boolean | (string | number)[]): Database<T> {
31
- const filterKey = operator === 'eq' ? field : `${field}__${operator}`
32
- // For 'in' and 'nin' operators, join array values with comma
33
- const filterValue = Array.isArray(value) ? value.join(',') : value
34
- return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, {
35
- ...this.queryParams,
36
- [filterKey]: filterValue
37
- })
38
- }
39
-
40
- sort(field: string, order: SortOrder = 'asc'): Database<T> {
41
- const ordering = order === 'desc' ? `-${field}` : field
42
- return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, {
43
- ...this.queryParams,
44
- ordering
45
- })
46
- }
47
-
48
- pageSize(size: number): Database<T> {
49
- return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, {
50
- ...this.queryParams,
51
- page_size: size
52
- })
53
- }
54
-
55
- page(num: number): Database<T> {
56
- return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, {
57
- ...this.queryParams,
58
- page: num
59
- })
60
- }
24
+ }
61
25
 
62
- populate(populate: string[]): Database<T> {
63
- return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, {
64
- ...this.queryParams,
65
- populate: populate.join(',')
66
- })
26
+ from(dataTables: string): Database {
27
+ return new Database(this.client, { ...this.urlParams, dataTables }, undefined, undefined)
67
28
  }
68
29
 
69
- get(recordId: string): Database<T> {
70
- return new Database<T>(this.client, { ...this.urlParams, recordId }, HttpMethod.GET)
30
+ filter(filters: DatabaseFilters): Database {
31
+ return new Database(this.client, { ...this.urlParams }, undefined, undefined, {...this.queryParams, ...filters})
71
32
  }
72
33
 
73
- create(body: Partial<T> | Partial<T>[]): Database<T> {
74
- return new Database<T>(this.client, { ...this.urlParams }, HttpMethod.POST, body as object)
34
+ populate(populate: string[]): Database {
35
+ return new Database(this.client, { ...this.urlParams, }, undefined, undefined, {...this.queryParams, populate: populate.join(',')})
75
36
  }
76
37
 
77
- update(body: Partial<T> | Partial<T>[]): Database<T> {
78
- return new Database<T>(this.client, { ...this.urlParams }, HttpMethod.PATCH, body as object)
38
+ get(recordId: string): Database {
39
+ return new Database(this.client, this.urlParams = { ...this.urlParams, recordId }, HttpMethod.GET)
79
40
  }
80
41
 
81
- delete(recordId: string): Database<T> {
82
- return new Database<T>(this.client, { ...this.urlParams, recordId }, HttpMethod.DELETE)
42
+ create(body: any): Database {
43
+ return new Database(this.client, this.urlParams = { ...this.urlParams }, HttpMethod.POST, body)
83
44
  }
84
45
 
85
- async first(): Promise<T | null> {
86
- const results = await this.execute()
87
- if (Array.isArray(results)) {
88
- return results[0] ?? null
89
- }
90
- return results ?? null
46
+ update(body: any): Database {
47
+ return new Database(this.client, this.urlParams = { ...this.urlParams }, HttpMethod.PATCH, body)
91
48
  }
92
49
 
93
- async count(): Promise<number> {
94
- const results = await this.execute()
95
- if (Array.isArray(results)) {
96
- return results.length
97
- }
98
- return 0
50
+ delete(recordId?: any): Database {
51
+ return new Database(this.client, this.urlParams = { ...this.urlParams, recordId }, HttpMethod.DELETE)
99
52
  }
100
-
101
53
  private buildRoute(): string {
102
54
  return (
103
55
  DatabaseRoutes.baseUrl(this.config.appSlug) +
@@ -116,7 +68,7 @@ export class Database<T = Record<string, unknown>> {
116
68
  )
117
69
  }
118
70
 
119
- async execute(): Promise<T | T[]> {
71
+ async execute() {
120
72
  // Build the API URL
121
73
  const url = this.buildRoute()
122
74
 
@@ -141,3 +93,10 @@ export class Database<T = Record<string, unknown>> {
141
93
  }
142
94
  }
143
95
  }
96
+
97
+
98
+ // TODO: Implement storage operations
99
+ // - upload files
100
+ // - download files
101
+ // - delete files
102
+ // - list files
@@ -3,26 +3,6 @@ import { HttpMethod } from "../../lib-internal/http/types.js"
3
3
 
4
4
  export type DatabaseOperation = HttpMethod
5
5
 
6
- // Filter operators matching Python SDK
7
- export type FilterOperator =
8
- | 'eq' // Equal
9
- | 'ne' // Not equal
10
- | 'gt' // Greater than
11
- | 'gte' // Greater than or equal
12
- | 'lt' // Less than
13
- | 'lte' // Less than or equal
14
- | 'in' // In array
15
- | 'nin' // Not in array
16
- | 'contains' // String contains (case-sensitive)
17
- | 'icontains' // String contains (case-insensitive)
18
- | 'startswith' // String starts with (case-sensitive)
19
- | 'istartswith' // String starts with (case-insensitive)
20
- | 'endswith' // String ends with (case-sensitive)
21
- | 'iendswith' // String ends with (case-insensitive)
22
- | 'isnull' // Is null
23
-
24
- export type SortOrder = 'asc' | 'desc'
25
-
26
6
  // Internal types
27
7
  export interface UrlParams {
28
8
  appSlug?: string
@@ -1,6 +1,6 @@
1
1
  export const StorageRoutes = {
2
2
  baseUrl: (appslug: string, bucket: string) => `api/apps/${appslug}/storage/buckets/${bucket}/objects`,
3
- path: (path: string) => "/" + encodeURIComponent(path),
3
+ path: (path: string) => "/" + path,
4
4
  upload: () => "/batch-upload",
5
5
  delete: () => "/batch-delete"
6
6
  // bucket: (appslug: string, bucketslug: string) => `${StorageRoutesClone.baseUrl(appslug)}/${bucketslug}`
package/src/types.ts CHANGED
@@ -11,7 +11,7 @@ export interface TaruviConfig {
11
11
  export interface StorageFilters {
12
12
  // Pagination (DRF style)
13
13
  page?: number
14
- page_size?: number
14
+ pageSize?: number
15
15
 
16
16
  // Range Filters - Size (in bytes)
17
17
  size__gte?: number
@@ -58,14 +58,11 @@ export interface StorageFilters {
58
58
  export interface DatabaseFilters {
59
59
  // Pagination (DRF style)
60
60
  page?: number
61
- page_size?: number
61
+ pageSize?: number
62
62
 
63
63
  // Sorting (DRF style: "-field" for desc, "field" for asc)
64
64
  ordering?: string
65
65
 
66
- // Populate relations
67
- populate?: string
68
-
69
66
  // Dynamic filters - allows any field with operators
70
67
  [key: string]: string | number | boolean | undefined
71
68
  }