@taruvi/sdk 1.2.1 → 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.01",
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,81 +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): Database<T> {
31
- const filterKey = operator === 'eq' ? field : `${field}__${operator}`
32
- return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, {
33
- ...this.queryParams,
34
- [filterKey]: value
35
- })
36
- }
37
-
38
- sort(field: string, order: SortOrder = 'asc'): Database<T> {
39
- const ordering = order === 'desc' ? `-${field}` : field
40
- return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, {
41
- ...this.queryParams,
42
- ordering
43
- })
44
- }
45
-
46
- pageSize(size: number): Database<T> {
47
- return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, {
48
- ...this.queryParams,
49
- pageSize: size
50
- })
51
- }
52
-
53
- page(num: number): Database<T> {
54
- return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, {
55
- ...this.queryParams,
56
- page: num
57
- })
58
- }
24
+ }
59
25
 
60
- populate(populate: string[]): Database<T> {
61
- return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, {
62
- ...this.queryParams,
63
- populate: populate.join(',')
64
- })
26
+ from(dataTables: string): Database {
27
+ return new Database(this.client, { ...this.urlParams, dataTables }, undefined, undefined)
65
28
  }
66
29
 
67
- get(recordId: string): Database<T> {
68
- 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})
69
32
  }
70
33
 
71
- create(body: Partial<T> | Partial<T>[]): Database<T> {
72
- 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(',')})
73
36
  }
74
37
 
75
- update(body: Partial<T> | Partial<T>[]): Database<T> {
76
- 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)
77
40
  }
78
41
 
79
- delete(recordId: string): Database<T> {
80
- 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)
81
44
  }
82
45
 
83
- async first(): Promise<T | null> {
84
- const results = await this.execute()
85
- if (Array.isArray(results)) {
86
- return results[0] ?? null
87
- }
88
- return results ?? null
46
+ update(body: any): Database {
47
+ return new Database(this.client, this.urlParams = { ...this.urlParams }, HttpMethod.PATCH, body)
89
48
  }
90
49
 
91
- async count(): Promise<number> {
92
- const results = await this.execute()
93
- if (Array.isArray(results)) {
94
- return results.length
95
- }
96
- return 0
50
+ delete(recordId?: any): Database {
51
+ return new Database(this.client, this.urlParams = { ...this.urlParams, recordId }, HttpMethod.DELETE)
97
52
  }
98
-
99
53
  private buildRoute(): string {
100
54
  return (
101
55
  DatabaseRoutes.baseUrl(this.config.appSlug) +
@@ -114,7 +68,7 @@ export class Database<T = Record<string, unknown>> {
114
68
  )
115
69
  }
116
70
 
117
- async execute(): Promise<T | T[]> {
71
+ async execute() {
118
72
  // Build the API URL
119
73
  const url = this.buildRoute()
120
74
 
@@ -139,3 +93,10 @@ export class Database<T = Record<string, unknown>> {
139
93
  }
140
94
  }
141
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}`