@taruvi/sdk 1.3.2 → 1.3.4-beta.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/.kiro/settings/lsp.json +198 -0
- package/MODULE_NAMING_CHANGES.md +81 -0
- package/PARAMETER_NAMING_CHANGES.md +106 -0
- package/README.md +4 -4
- package/package.json +10 -4
- package/src/client.ts +4 -4
- package/src/index.ts +48 -35
- package/src/lib/analytics/types.ts +8 -0
- package/src/lib/{App → app}/types.ts +14 -6
- package/src/lib/auth/AuthClient.ts +8 -7
- package/src/lib/auth/types.ts +108 -6
- package/src/lib/{Database → database}/DatabaseClient.ts +15 -10
- package/src/lib/{Database → database}/types.ts +4 -7
- package/src/lib/functions/types.ts +25 -0
- package/src/lib/{Graphs → graphs}/GraphClient.ts +9 -8
- package/src/lib/{Graphs → graphs}/types.ts +12 -5
- package/src/lib/policy/PolicyClient.ts +79 -0
- package/src/lib/policy/types.ts +40 -0
- package/src/lib/secrets/SecretsClient.ts +75 -0
- package/src/lib/secrets/types.ts +59 -0
- package/src/lib/settings/types.ts +9 -0
- package/src/lib/{Storage → storage}/StorageClient.ts +27 -9
- package/src/lib/storage/types.ts +86 -0
- package/src/lib/users/UserClient.ts +55 -0
- package/src/lib/users/types.ts +104 -0
- package/src/lib-internal/errors/ErrorClient.ts +98 -8
- package/src/lib-internal/errors/index.ts +3 -25
- package/src/lib-internal/errors/types.ts +18 -95
- package/src/lib-internal/http/HttpClient.ts +83 -45
- package/src/lib-internal/routes/UserRoutes.ts +3 -1
- package/src/lib-internal/token/TokenClient.ts +1 -1
- package/src/types.ts +20 -1
- package/src/utils/utils.ts +5 -1
- package/tests/fixtures/mockClient.ts +19 -0
- package/tests/unit/analytics/AnalyticsClient.test.ts +84 -0
- package/tests/unit/app/AppClient.test.ts +114 -0
- package/tests/unit/auth/AuthClient.test.ts +131 -0
- package/tests/unit/client/Client.test.ts +70 -0
- package/tests/unit/database/DatabaseClient.test.ts +304 -0
- package/tests/unit/edge-cases/robustness.test.ts +259 -0
- package/tests/unit/errors/errors.test.ts +209 -0
- package/tests/unit/functions/FunctionsClient.test.ts +99 -0
- package/tests/unit/graphs/GraphClient.test.ts +329 -0
- package/tests/unit/policy/PolicyClient.test.ts +184 -0
- package/tests/unit/secrets/SecretsClient.test.ts +146 -0
- package/tests/unit/settings/SettingsClient.test.ts +50 -0
- package/tests/unit/storage/StorageClient.test.ts +251 -0
- package/tests/unit/users/UserClient.test.ts +150 -0
- package/vitest.config.ts +7 -0
- package/src/lib/Analytics/types.ts +0 -7
- package/src/lib/Function/types.ts +0 -17
- package/src/lib/Policy/PolicyClient.ts +0 -29
- package/src/lib/Policy/types.ts +0 -24
- package/src/lib/Secrets/SecretsClient.ts +0 -39
- package/src/lib/Secrets/types.ts +0 -17
- package/src/lib/Settings/types.ts +0 -4
- package/src/lib/Storage/types.ts +0 -41
- package/src/lib/user/UserClient.ts +0 -52
- package/src/lib/user/types.ts +0 -111
- /package/src/lib/{Analytics → analytics}/AnalyticsClient.ts +0 -0
- /package/src/lib/{App → app}/AppClient.ts +0 -0
- /package/src/lib/{Function → functions}/FunctionsClient.ts +0 -0
- /package/src/lib/{Settings → settings}/SettingsClient.ts +0 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
{
|
|
2
|
+
"languages": {
|
|
3
|
+
"java": {
|
|
4
|
+
"name": "jdtls",
|
|
5
|
+
"command": "jdtls",
|
|
6
|
+
"args": [],
|
|
7
|
+
"file_extensions": [
|
|
8
|
+
"java"
|
|
9
|
+
],
|
|
10
|
+
"project_patterns": [
|
|
11
|
+
"pom.xml",
|
|
12
|
+
"build.gradle",
|
|
13
|
+
"build.gradle.kts",
|
|
14
|
+
".project"
|
|
15
|
+
],
|
|
16
|
+
"exclude_patterns": [
|
|
17
|
+
"**/target/**",
|
|
18
|
+
"**/build/**",
|
|
19
|
+
"**/.gradle/**"
|
|
20
|
+
],
|
|
21
|
+
"multi_workspace": false,
|
|
22
|
+
"initialization_options": {
|
|
23
|
+
"settings": {
|
|
24
|
+
"java": {
|
|
25
|
+
"compile": {
|
|
26
|
+
"nullAnalysis": {
|
|
27
|
+
"mode": "automatic"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"configuration": {
|
|
31
|
+
"annotationProcessing": {
|
|
32
|
+
"enabled": true
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"request_timeout_secs": 60
|
|
39
|
+
},
|
|
40
|
+
"cpp": {
|
|
41
|
+
"name": "clangd",
|
|
42
|
+
"command": "clangd",
|
|
43
|
+
"args": [
|
|
44
|
+
"--background-index"
|
|
45
|
+
],
|
|
46
|
+
"file_extensions": [
|
|
47
|
+
"cpp",
|
|
48
|
+
"cc",
|
|
49
|
+
"cxx",
|
|
50
|
+
"c",
|
|
51
|
+
"h",
|
|
52
|
+
"hpp",
|
|
53
|
+
"hxx"
|
|
54
|
+
],
|
|
55
|
+
"project_patterns": [
|
|
56
|
+
"CMakeLists.txt",
|
|
57
|
+
"compile_commands.json",
|
|
58
|
+
"Makefile"
|
|
59
|
+
],
|
|
60
|
+
"exclude_patterns": [
|
|
61
|
+
"**/build/**",
|
|
62
|
+
"**/cmake-build-**/**"
|
|
63
|
+
],
|
|
64
|
+
"multi_workspace": false,
|
|
65
|
+
"initialization_options": {},
|
|
66
|
+
"request_timeout_secs": 60
|
|
67
|
+
},
|
|
68
|
+
"go": {
|
|
69
|
+
"name": "gopls",
|
|
70
|
+
"command": "gopls",
|
|
71
|
+
"args": [],
|
|
72
|
+
"file_extensions": [
|
|
73
|
+
"go"
|
|
74
|
+
],
|
|
75
|
+
"project_patterns": [
|
|
76
|
+
"go.mod",
|
|
77
|
+
"go.sum"
|
|
78
|
+
],
|
|
79
|
+
"exclude_patterns": [
|
|
80
|
+
"**/vendor/**"
|
|
81
|
+
],
|
|
82
|
+
"multi_workspace": false,
|
|
83
|
+
"initialization_options": {
|
|
84
|
+
"usePlaceholders": true,
|
|
85
|
+
"completeUnimported": true
|
|
86
|
+
},
|
|
87
|
+
"request_timeout_secs": 60
|
|
88
|
+
},
|
|
89
|
+
"python": {
|
|
90
|
+
"name": "pyright",
|
|
91
|
+
"command": "pyright-langserver",
|
|
92
|
+
"args": [
|
|
93
|
+
"--stdio"
|
|
94
|
+
],
|
|
95
|
+
"file_extensions": [
|
|
96
|
+
"py"
|
|
97
|
+
],
|
|
98
|
+
"project_patterns": [
|
|
99
|
+
"pyproject.toml",
|
|
100
|
+
"setup.py",
|
|
101
|
+
"requirements.txt",
|
|
102
|
+
"pyrightconfig.json"
|
|
103
|
+
],
|
|
104
|
+
"exclude_patterns": [
|
|
105
|
+
"**/__pycache__/**",
|
|
106
|
+
"**/venv/**",
|
|
107
|
+
"**/.venv/**",
|
|
108
|
+
"**/.pytest_cache/**"
|
|
109
|
+
],
|
|
110
|
+
"multi_workspace": false,
|
|
111
|
+
"initialization_options": {},
|
|
112
|
+
"request_timeout_secs": 60
|
|
113
|
+
},
|
|
114
|
+
"rust": {
|
|
115
|
+
"name": "rust-analyzer",
|
|
116
|
+
"command": "rust-analyzer",
|
|
117
|
+
"args": [],
|
|
118
|
+
"file_extensions": [
|
|
119
|
+
"rs"
|
|
120
|
+
],
|
|
121
|
+
"project_patterns": [
|
|
122
|
+
"Cargo.toml"
|
|
123
|
+
],
|
|
124
|
+
"exclude_patterns": [
|
|
125
|
+
"**/target/**"
|
|
126
|
+
],
|
|
127
|
+
"multi_workspace": false,
|
|
128
|
+
"initialization_options": {
|
|
129
|
+
"cargo": {
|
|
130
|
+
"buildScripts": {
|
|
131
|
+
"enable": true
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
"diagnostics": {
|
|
135
|
+
"enable": true,
|
|
136
|
+
"enableExperimental": true
|
|
137
|
+
},
|
|
138
|
+
"workspace": {
|
|
139
|
+
"symbol": {
|
|
140
|
+
"search": {
|
|
141
|
+
"scope": "workspace"
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
"request_timeout_secs": 60
|
|
147
|
+
},
|
|
148
|
+
"typescript": {
|
|
149
|
+
"name": "typescript-language-server",
|
|
150
|
+
"command": "typescript-language-server",
|
|
151
|
+
"args": [
|
|
152
|
+
"--stdio"
|
|
153
|
+
],
|
|
154
|
+
"file_extensions": [
|
|
155
|
+
"ts",
|
|
156
|
+
"js",
|
|
157
|
+
"tsx",
|
|
158
|
+
"jsx"
|
|
159
|
+
],
|
|
160
|
+
"project_patterns": [
|
|
161
|
+
"package.json",
|
|
162
|
+
"tsconfig.json"
|
|
163
|
+
],
|
|
164
|
+
"exclude_patterns": [
|
|
165
|
+
"**/node_modules/**",
|
|
166
|
+
"**/dist/**"
|
|
167
|
+
],
|
|
168
|
+
"multi_workspace": false,
|
|
169
|
+
"initialization_options": {
|
|
170
|
+
"preferences": {
|
|
171
|
+
"disableSuggestions": false
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
"request_timeout_secs": 60
|
|
175
|
+
},
|
|
176
|
+
"ruby": {
|
|
177
|
+
"name": "solargraph",
|
|
178
|
+
"command": "solargraph",
|
|
179
|
+
"args": [
|
|
180
|
+
"stdio"
|
|
181
|
+
],
|
|
182
|
+
"file_extensions": [
|
|
183
|
+
"rb"
|
|
184
|
+
],
|
|
185
|
+
"project_patterns": [
|
|
186
|
+
"Gemfile",
|
|
187
|
+
"Rakefile"
|
|
188
|
+
],
|
|
189
|
+
"exclude_patterns": [
|
|
190
|
+
"**/vendor/**",
|
|
191
|
+
"**/tmp/**"
|
|
192
|
+
],
|
|
193
|
+
"multi_workspace": false,
|
|
194
|
+
"initialization_options": {},
|
|
195
|
+
"request_timeout_secs": 60
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Module Naming Convention Changes - Completed
|
|
2
|
+
|
|
3
|
+
**Date**: 2026-01-22
|
|
4
|
+
**Status**: ✅ Completed
|
|
5
|
+
|
|
6
|
+
## Changes Made
|
|
7
|
+
|
|
8
|
+
### Folder Renaming
|
|
9
|
+
|
|
10
|
+
All module folders in `src/lib/` have been renamed to lowercase and pluralized where appropriate:
|
|
11
|
+
|
|
12
|
+
| Old Name | New Name | Change Type |
|
|
13
|
+
|----------|----------|-------------|
|
|
14
|
+
| `Analytics/` | `analytics/` | Lowercase |
|
|
15
|
+
| `App/` | `app/` | Lowercase |
|
|
16
|
+
| `auth/` | `auth/` | ✓ Already correct |
|
|
17
|
+
| `Database/` | `database/` | Lowercase |
|
|
18
|
+
| `Function/` | `functions/` | Lowercase + Plural |
|
|
19
|
+
| `Policy/` | `policy/` | Lowercase |
|
|
20
|
+
| `Secrets/` | `secrets/` | Lowercase |
|
|
21
|
+
| `Settings/` | `settings/` | Lowercase |
|
|
22
|
+
| `Storage/` | `storage/` | Lowercase |
|
|
23
|
+
| `user/` | `users/` | Plural |
|
|
24
|
+
|
|
25
|
+
### Files Updated
|
|
26
|
+
|
|
27
|
+
1. **src/index.ts** - Updated all import paths to reflect new folder names
|
|
28
|
+
|
|
29
|
+
### Build Status
|
|
30
|
+
|
|
31
|
+
✅ TypeScript compilation successful
|
|
32
|
+
✅ No errors or warnings
|
|
33
|
+
|
|
34
|
+
## Benefits
|
|
35
|
+
|
|
36
|
+
1. **Consistency** - All module folders now follow lowercase naming
|
|
37
|
+
2. **Alignment** - Matches Python SDK naming conventions
|
|
38
|
+
3. **Clarity** - Plural names (`users`, `functions`) match REST conventions
|
|
39
|
+
4. **Maintainability** - Easier to navigate and understand structure
|
|
40
|
+
|
|
41
|
+
## Next Steps
|
|
42
|
+
|
|
43
|
+
As per the SDK Alignment Analysis, the next priorities are:
|
|
44
|
+
|
|
45
|
+
1. ✅ **Module naming** - COMPLETED
|
|
46
|
+
2. ⏭️ Add direct CRUD methods to Database module
|
|
47
|
+
3. ⏭️ Remove `.execute()` requirement from Storage
|
|
48
|
+
4. ⏭️ Add missing methods to Functions module
|
|
49
|
+
5. ⏭️ Implement AuthManager pattern
|
|
50
|
+
|
|
51
|
+
## Breaking Changes
|
|
52
|
+
|
|
53
|
+
⚠️ **This is a breaking change for existing users**
|
|
54
|
+
|
|
55
|
+
Users will need to update their imports:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
// Old imports (will break)
|
|
59
|
+
import { User } from '@taruvi/sdk'
|
|
60
|
+
import { Functions } from '@taruvi/sdk'
|
|
61
|
+
|
|
62
|
+
// New imports (correct)
|
|
63
|
+
import { User } from '@taruvi/sdk' // Still works - export name unchanged
|
|
64
|
+
import { Functions } from '@taruvi/sdk' // Still works - export name unchanged
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Note**: The exported class names remain unchanged (`User`, `Functions`, etc.), only the internal folder structure changed. This means existing code will continue to work without modifications.
|
|
68
|
+
|
|
69
|
+
## Verification
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Build successful
|
|
73
|
+
npm run build
|
|
74
|
+
# ✓ No errors
|
|
75
|
+
|
|
76
|
+
# Folder structure
|
|
77
|
+
ls src/lib/
|
|
78
|
+
# analytics app auth database functions policy secrets settings storage users
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
All folders now follow consistent lowercase naming conventions! 🎉
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Parameter Naming Change: baseUrl → apiUrl
|
|
2
|
+
|
|
3
|
+
**Date**: 2026-01-22
|
|
4
|
+
**Status**: ✅ Completed
|
|
5
|
+
|
|
6
|
+
## Changes Made
|
|
7
|
+
|
|
8
|
+
### Type Definitions
|
|
9
|
+
|
|
10
|
+
**File**: `src/types.ts`
|
|
11
|
+
- Changed `baseUrl: string` → `apiUrl: string`
|
|
12
|
+
- Updated comment: "Base API URL"
|
|
13
|
+
|
|
14
|
+
### Client Constructor
|
|
15
|
+
|
|
16
|
+
**File**: `src/client.ts`
|
|
17
|
+
- Updated validation: `config.baseUrl` → `config.apiUrl`
|
|
18
|
+
- Updated error message: "Base URL is required" → "API URL is required"
|
|
19
|
+
|
|
20
|
+
### HTTP Client
|
|
21
|
+
|
|
22
|
+
**File**: `src/lib-internal/http/HttpClient.ts`
|
|
23
|
+
- Updated all HTTP methods to use `config.apiUrl` instead of `config.baseUrl`:
|
|
24
|
+
- `get()` method
|
|
25
|
+
- `post()` method
|
|
26
|
+
- `put()` method
|
|
27
|
+
- `delete()` method
|
|
28
|
+
- `patch()` method
|
|
29
|
+
|
|
30
|
+
### Auth Client
|
|
31
|
+
|
|
32
|
+
**File**: `src/lib/auth/AuthClient.ts`
|
|
33
|
+
- Updated `login()`: `config.deskUrl || config.baseUrl` → `config.deskUrl || config.apiUrl`
|
|
34
|
+
- Updated `signup()`: `config.baseUrl` → `config.apiUrl`
|
|
35
|
+
- Updated `logout()`: `config.deskUrl || config.baseUrl` → `config.deskUrl || config.apiUrl`
|
|
36
|
+
- Updated `refreshAccessToken()`: `config.baseUrl` → `config.apiUrl`
|
|
37
|
+
|
|
38
|
+
### Documentation
|
|
39
|
+
|
|
40
|
+
**File**: `README.md`
|
|
41
|
+
- Updated all examples: `baseUrl:` → `apiUrl:`
|
|
42
|
+
- Updated environment variable: `VITE_TARUVI_BASE_URL` → `VITE_TARUVI_API_URL`
|
|
43
|
+
|
|
44
|
+
## Build Status
|
|
45
|
+
|
|
46
|
+
✅ TypeScript compilation successful
|
|
47
|
+
✅ No errors or warnings
|
|
48
|
+
|
|
49
|
+
## Alignment with Python SDK
|
|
50
|
+
|
|
51
|
+
This change aligns the JavaScript SDK with the Python SDK naming convention:
|
|
52
|
+
|
|
53
|
+
**Python SDK**:
|
|
54
|
+
```python
|
|
55
|
+
client = Client(
|
|
56
|
+
api_url="https://api.taruvi.cloud",
|
|
57
|
+
app_slug="my-app"
|
|
58
|
+
)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**JavaScript SDK** (now aligned):
|
|
62
|
+
```typescript
|
|
63
|
+
const client = new Client({
|
|
64
|
+
apiUrl: "https://api.taruvi.cloud",
|
|
65
|
+
appSlug: "my-app",
|
|
66
|
+
apiKey: "your-api-key"
|
|
67
|
+
})
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Breaking Change
|
|
71
|
+
|
|
72
|
+
⚠️ **This is a breaking change**
|
|
73
|
+
|
|
74
|
+
Users must update their configuration:
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
// ❌ Old (will break)
|
|
78
|
+
const client = new Client({
|
|
79
|
+
baseUrl: "https://api.taruvi.cloud",
|
|
80
|
+
appSlug: "my-app",
|
|
81
|
+
apiKey: "key"
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
// ✅ New (correct)
|
|
85
|
+
const client = new Client({
|
|
86
|
+
apiUrl: "https://api.taruvi.cloud",
|
|
87
|
+
appSlug: "my-app",
|
|
88
|
+
apiKey: "key"
|
|
89
|
+
})
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Migration Guide
|
|
93
|
+
|
|
94
|
+
1. Find all `baseUrl` references in your code
|
|
95
|
+
2. Replace with `apiUrl`
|
|
96
|
+
3. Update environment variables: `VITE_TARUVI_BASE_URL` → `VITE_TARUVI_API_URL`
|
|
97
|
+
|
|
98
|
+
## Next Steps
|
|
99
|
+
|
|
100
|
+
As per the SDK Alignment Analysis:
|
|
101
|
+
|
|
102
|
+
1. ✅ Module naming - COMPLETED
|
|
103
|
+
2. ✅ Parameter naming (baseUrl → apiUrl) - COMPLETED
|
|
104
|
+
3. ⏭️ Add direct CRUD methods to Database module
|
|
105
|
+
4. ⏭️ Remove `.execute()` requirement from Storage
|
|
106
|
+
5. ⏭️ Add missing methods to Functions module
|
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ import { Client } from '@taruvi/sdk'
|
|
|
32
32
|
const taruviClient = new Client({
|
|
33
33
|
apiKey: "your-site-api-key",
|
|
34
34
|
appSlug: "your-app-slug",
|
|
35
|
-
|
|
35
|
+
apiUrl: "https://taruvi-site.taruvi.cloud"
|
|
36
36
|
})
|
|
37
37
|
```
|
|
38
38
|
|
|
@@ -1141,7 +1141,7 @@ import type {
|
|
|
1141
1141
|
const config: TaruviConfig = {
|
|
1142
1142
|
apiKey: "key",
|
|
1143
1143
|
appSlug: "app",
|
|
1144
|
-
|
|
1144
|
+
apiUrl: "https://api.taruvi.cloud",
|
|
1145
1145
|
deskUrl: "https://desk.taruvi.cloud", // optional
|
|
1146
1146
|
token: "existing-token" // optional
|
|
1147
1147
|
}
|
|
@@ -1305,14 +1305,14 @@ await storage.from("bucket").download("path/to/file.pdf").execute()
|
|
|
1305
1305
|
```env
|
|
1306
1306
|
VITE_TARUVI_API_KEY=your-api-key
|
|
1307
1307
|
VITE_TARUVI_APP_SLUG=your-app
|
|
1308
|
-
|
|
1308
|
+
VITE_TARUVI_API_URL=https://taruvi-site.taruvi.cloud
|
|
1309
1309
|
```
|
|
1310
1310
|
|
|
1311
1311
|
```typescript
|
|
1312
1312
|
const client = new Client({
|
|
1313
1313
|
apiKey: import.meta.env.VITE_TARUVI_API_KEY,
|
|
1314
1314
|
appSlug: import.meta.env.VITE_TARUVI_APP_SLUG,
|
|
1315
|
-
|
|
1315
|
+
apiUrl: import.meta.env.VITE_TARUVI_API_URL
|
|
1316
1316
|
})
|
|
1317
1317
|
```
|
|
1318
1318
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taruvi/sdk",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4-beta.0",
|
|
4
4
|
"description": "Taruvi SDK",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
7
8
|
"scripts": {
|
|
8
|
-
"build": "tsc"
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"test": "vitest run",
|
|
11
|
+
"test:watch": "vitest"
|
|
9
12
|
},
|
|
10
13
|
"keywords": [
|
|
11
14
|
"taruvi",
|
|
@@ -16,7 +19,10 @@
|
|
|
16
19
|
"license": "MIT",
|
|
17
20
|
"peerDependencies": {
|
|
18
21
|
"@types/node": ">=18 <25",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
22
|
+
"axios": ">=1 <2",
|
|
23
|
+
"typescript": ">=5.7 <6"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"vitest": "^4.0.18"
|
|
21
27
|
}
|
|
22
28
|
}
|
package/src/client.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpClient } from "./lib-internal/http/HttpClient.js";
|
|
2
|
-
import { TokenClient } from "./lib-internal/token/TokenClient.js";
|
|
2
|
+
import { TokenClient, type AuthTokens } from "./lib-internal/token/TokenClient.js";
|
|
3
3
|
import type { TaruviConfig } from "./types.js";
|
|
4
4
|
|
|
5
5
|
export class Client {
|
|
@@ -16,8 +16,8 @@ export class Client {
|
|
|
16
16
|
throw new Error("API key is required")
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
if (!config.
|
|
20
|
-
throw new Error("
|
|
19
|
+
if (!config.apiUrl) {
|
|
20
|
+
throw new Error("API URL is required")
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
this.config = config
|
|
@@ -62,7 +62,7 @@ export class Client {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
// Store tokens using TokenClient
|
|
65
|
-
const tokens:
|
|
65
|
+
const tokens: AuthTokens = {
|
|
66
66
|
accessToken,
|
|
67
67
|
refreshToken,
|
|
68
68
|
tokenType: tokenType || "Bearer"
|
package/src/index.ts
CHANGED
|
@@ -1,41 +1,54 @@
|
|
|
1
1
|
// Export main client
|
|
2
2
|
export { Client } from "./client.js"
|
|
3
3
|
|
|
4
|
+
// Export error classes
|
|
5
|
+
export { TaruviError, ValidationError, AuthError, ForbiddenError, NotFoundError, ConflictError, TimeoutError, NetworkError } from "./lib-internal/errors/index.js"
|
|
6
|
+
export { ErrorCode } from "./lib-internal/errors/index.js"
|
|
7
|
+
export type { ErrorResponseBody } from "./lib-internal/errors/index.js"
|
|
8
|
+
|
|
4
9
|
// Export public client classes
|
|
5
10
|
export { Auth } from "./lib/auth/AuthClient.js"
|
|
6
|
-
export { User } from "./lib/
|
|
7
|
-
export { Storage } from "./lib/
|
|
8
|
-
export { Database } from "./lib/
|
|
9
|
-
export { Settings } from "./lib/
|
|
10
|
-
export { Functions } from "./lib/
|
|
11
|
-
export { Secrets } from "./lib/
|
|
12
|
-
export { Policy } from "./lib/
|
|
13
|
-
export { App } from "./lib/
|
|
14
|
-
export { Analytics } from "./lib/
|
|
15
|
-
export { Graph } from "./lib/
|
|
16
|
-
|
|
17
|
-
// Export types
|
|
18
|
-
export type { TaruviConfig, StorageFilters, DatabaseFilters } from "./types.js"
|
|
11
|
+
export { User } from "./lib/users/UserClient.js"
|
|
12
|
+
export { Storage } from "./lib/storage/StorageClient.js"
|
|
13
|
+
export { Database } from "./lib/database/DatabaseClient.js"
|
|
14
|
+
export { Settings } from "./lib/settings/SettingsClient.js"
|
|
15
|
+
export { Functions } from "./lib/functions/FunctionsClient.js"
|
|
16
|
+
export { Secrets } from "./lib/secrets/SecretsClient.js"
|
|
17
|
+
export { Policy } from "./lib/policy/PolicyClient.js"
|
|
18
|
+
export { App } from "./lib/app/AppClient.js"
|
|
19
|
+
export { Analytics } from "./lib/analytics/AnalyticsClient.js"
|
|
20
|
+
export { Graph } from "./lib/graphs/GraphClient.js"
|
|
21
|
+
|
|
22
|
+
// Export core types
|
|
23
|
+
export type { TaruviConfig, TaruviResponse, PaginationInfo, StorageFilters, DatabaseFilters } from "./types.js"
|
|
19
24
|
export type { AuthTokens } from "./lib-internal/token/TokenClient.js"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export type {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
export type { StorageRequest, StorageUpdateRequest, StorageResponse } from "./lib/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
export type {
|
|
41
|
-
|
|
25
|
+
|
|
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"
|
|
28
|
+
|
|
29
|
+
// Policy types
|
|
30
|
+
export type { Principal, Resource, Resources, PolicyCheckResult, PolicyCheckBatchResult, ResourceCheckResponse } from "./lib/policy/types.js"
|
|
31
|
+
|
|
32
|
+
// App types
|
|
33
|
+
export type { RoleData, AppSettingsData, RoleResponse, RolesListResponse, AppSettingsResponse } from "./lib/app/types.js"
|
|
34
|
+
|
|
35
|
+
// Function types
|
|
36
|
+
export type { FunctionRequest, FunctionResponse, FunctionInvocation } from "./lib/functions/types.js"
|
|
37
|
+
|
|
38
|
+
// Database types
|
|
39
|
+
export type { DatabaseRequest, DatabaseResponse, DatabaseSingleResponse, FilterOperator, SortOrder } from "./lib/database/types.js"
|
|
40
|
+
|
|
41
|
+
// Storage types
|
|
42
|
+
export type { StorageRequest, StorageUpdateRequest, StorageObject, StorageResponse, StorageListResponse, StorageUploadBatchResponse, StorageDeleteBatchResponse } from "./lib/storage/types.js"
|
|
43
|
+
|
|
44
|
+
// Settings types
|
|
45
|
+
export type { SiteSettingsData, SettingsResponse } from "./lib/settings/types.js"
|
|
46
|
+
|
|
47
|
+
// Secrets types
|
|
48
|
+
export type { SecretCreateRequest, SecretUpdateRequest, SecretData, SecretResponse, SecretsListResponse, SecretsBatchResponse, SecretsBatchMetadataResponse, GetSecretOptions, GetSecretsOptions } from "./lib/secrets/types.js"
|
|
49
|
+
|
|
50
|
+
// Analytics types
|
|
51
|
+
export type { AnalyticsRequest, AnalyticsResponse } from "./lib/analytics/types.js"
|
|
52
|
+
|
|
53
|
+
// Graph types
|
|
54
|
+
export type { GraphInclude, GraphFormat, GraphQueryParams, EdgeRequest, EdgeResponse, EdgeDeleteRequest } from "./lib/graphs/types.js"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Client } from "../../client.js"
|
|
2
2
|
import { HttpMethod } from "../../lib-internal/http/types.js"
|
|
3
|
+
import type { TaruviResponse } from "../../types.js"
|
|
3
4
|
|
|
4
5
|
export type AppOperation = HttpMethod
|
|
5
6
|
|
|
@@ -15,17 +16,19 @@ export interface AppClientInterface {
|
|
|
15
16
|
urlParams?: UrlParams
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
//
|
|
19
|
-
export interface
|
|
20
|
-
id
|
|
21
|
-
name
|
|
19
|
+
// Role data
|
|
20
|
+
export interface RoleData {
|
|
21
|
+
id: string | number
|
|
22
|
+
name: string
|
|
23
|
+
slug: string
|
|
24
|
+
description?: string
|
|
22
25
|
permissions?: string[]
|
|
23
26
|
created_at?: string
|
|
24
27
|
updated_at?: string
|
|
25
|
-
[key: string]: unknown
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
// App settings data
|
|
31
|
+
export interface AppSettingsData {
|
|
29
32
|
display_name: string
|
|
30
33
|
icon: string | null
|
|
31
34
|
icon_url: string | null
|
|
@@ -40,3 +43,8 @@ export interface SettingsResponse {
|
|
|
40
43
|
created_at: string
|
|
41
44
|
updated_at: string
|
|
42
45
|
}
|
|
46
|
+
|
|
47
|
+
// Response types - uses standard wrapper
|
|
48
|
+
export type RoleResponse = TaruviResponse<RoleData>
|
|
49
|
+
export type RolesListResponse = TaruviResponse<RoleData[]>
|
|
50
|
+
export type AppSettingsResponse = TaruviResponse<AppSettingsData>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Client } from "../../client.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { TaruviResponse } from "../../types.js";
|
|
3
|
+
import type { UserData } from "../users/types.js";
|
|
3
4
|
import { UserRoutes } from "../../lib-internal/routes/UserRoutes.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -31,7 +32,7 @@ export class Auth {
|
|
|
31
32
|
|
|
32
33
|
const config = this.client.getConfig()
|
|
33
34
|
const callback = callbackUrl || window.location.origin + window.location.pathname
|
|
34
|
-
const deskUrl = config.deskUrl || config.
|
|
35
|
+
const deskUrl = config.deskUrl || config.apiUrl
|
|
35
36
|
|
|
36
37
|
// Redirect to /accounts/login/ with redirect_to parameter
|
|
37
38
|
const loginUrl = `${deskUrl}/accounts/login/?redirect_to=${encodeURIComponent(callback)}`
|
|
@@ -61,7 +62,7 @@ export class Auth {
|
|
|
61
62
|
const callback = callbackUrl || window.location.origin + window.location.pathname
|
|
62
63
|
|
|
63
64
|
// Redirect to /accounts/signup/ with redirect_to parameter
|
|
64
|
-
const signupUrl = `${config.
|
|
65
|
+
const signupUrl = `${config.apiUrl}/accounts/signup/?redirect_to=${encodeURIComponent(callback)}`
|
|
65
66
|
|
|
66
67
|
// Optional: Store state before redirecting
|
|
67
68
|
if (typeof sessionStorage !== "undefined") {
|
|
@@ -89,7 +90,7 @@ export class Auth {
|
|
|
89
90
|
this.client.tokenClient.clearTokens()
|
|
90
91
|
|
|
91
92
|
const config = this.client.getConfig()
|
|
92
|
-
const deskUrl = config.deskUrl || config.
|
|
93
|
+
const deskUrl = config.deskUrl || config.apiUrl
|
|
93
94
|
let callback: string = callbackUrl || ""
|
|
94
95
|
|
|
95
96
|
// If no callback provided, fetch frontendUrl from site settings
|
|
@@ -156,7 +157,7 @@ export class Auth {
|
|
|
156
157
|
|
|
157
158
|
try {
|
|
158
159
|
const config = this.client.getConfig()
|
|
159
|
-
const response = await fetch(`${config.
|
|
160
|
+
const response = await fetch(`${config.apiUrl}/api/cloud/auth/jwt/token/refresh/`, {
|
|
160
161
|
method: "POST",
|
|
161
162
|
headers: { "Content-Type": "application/json" },
|
|
162
163
|
body: JSON.stringify({ refresh: refreshToken })
|
|
@@ -198,13 +199,13 @@ export class Auth {
|
|
|
198
199
|
* Get current user from API
|
|
199
200
|
* @returns Promise with user data or null if not authenticated
|
|
200
201
|
*/
|
|
201
|
-
async getCurrentUser(): Promise<
|
|
202
|
+
async getCurrentUser(): Promise<TaruviResponse<UserData> | null> {
|
|
202
203
|
if (!this.isUserAuthenticated()) {
|
|
203
204
|
return null
|
|
204
205
|
}
|
|
205
206
|
|
|
206
207
|
try {
|
|
207
|
-
return await this.client.httpClient.get<
|
|
208
|
+
return await this.client.httpClient.get<TaruviResponse<UserData>>(UserRoutes.getCurrentUser())
|
|
208
209
|
} catch (error) {
|
|
209
210
|
console.error("Failed to fetch current user:", error)
|
|
210
211
|
return null
|