@taruvi/sdk 1.5.0 → 1.5.1-beta.4
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 +60 -1289
- package/dist/client.d.ts +27 -0
- package/dist/client.d.ts.map +1 -0
- package/{src/client.ts → dist/client.js} +30 -48
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/analytics/AnalyticsClient.d.ts +9 -0
- package/dist/lib/analytics/AnalyticsClient.d.ts.map +1 -0
- package/dist/lib/analytics/AnalyticsClient.js +17 -0
- package/dist/lib/analytics/AnalyticsClient.js.map +1 -0
- package/dist/lib/analytics/types.d.ts +6 -0
- package/dist/lib/analytics/types.d.ts.map +1 -0
- package/dist/lib/analytics/types.js +2 -0
- package/dist/lib/analytics/types.js.map +1 -0
- package/dist/lib/app/AppClient.d.ts +15 -0
- package/dist/lib/app/AppClient.d.ts.map +1 -0
- package/dist/lib/app/AppClient.js +41 -0
- package/dist/lib/app/AppClient.js.map +1 -0
- package/dist/lib/app/types.d.ts +41 -0
- package/dist/lib/app/types.d.ts.map +1 -0
- package/dist/lib/app/types.js +2 -0
- package/dist/lib/app/types.js.map +1 -0
- package/dist/lib/auth/AuthClient.d.ts +38 -0
- package/dist/lib/auth/AuthClient.d.ts.map +1 -0
- package/dist/lib/auth/AuthClient.js +105 -0
- package/dist/lib/auth/AuthClient.js.map +1 -0
- package/dist/lib/database/DatabaseClient.d.ts +76 -0
- package/dist/lib/database/DatabaseClient.d.ts.map +1 -0
- package/dist/lib/database/DatabaseClient.js +250 -0
- package/dist/lib/database/DatabaseClient.js.map +1 -0
- package/dist/lib/database/types.d.ts +66 -0
- package/dist/lib/database/types.d.ts.map +1 -0
- package/dist/lib/database/types.js +20 -0
- package/dist/lib/database/types.js.map +1 -0
- package/dist/lib/functions/FunctionsClient.d.ts +9 -0
- package/dist/lib/functions/FunctionsClient.d.ts.map +1 -0
- package/dist/lib/functions/FunctionsClient.js +20 -0
- package/dist/lib/functions/FunctionsClient.js.map +1 -0
- package/dist/lib/functions/types.d.ts +25 -0
- package/dist/lib/functions/types.d.ts.map +1 -0
- package/dist/lib/functions/types.js +2 -0
- package/dist/lib/functions/types.js.map +1 -0
- package/dist/lib/policy/PolicyClient.d.ts +25 -0
- package/dist/lib/policy/PolicyClient.d.ts.map +1 -0
- package/{src/lib/policy/PolicyClient.ts → dist/lib/policy/PolicyClient.js} +26 -40
- package/dist/lib/policy/PolicyClient.js.map +1 -0
- package/dist/lib/policy/types.d.ts +32 -0
- package/dist/lib/policy/types.d.ts.map +1 -0
- package/dist/lib/policy/types.js +2 -0
- package/dist/lib/policy/types.js.map +1 -0
- package/dist/lib/secrets/SecretsClient.d.ts +29 -0
- package/dist/lib/secrets/SecretsClient.d.ts.map +1 -0
- package/dist/lib/secrets/SecretsClient.js +66 -0
- package/dist/lib/secrets/SecretsClient.js.map +1 -0
- package/dist/lib/secrets/types.d.ts +43 -0
- package/dist/lib/secrets/types.d.ts.map +1 -0
- package/dist/lib/secrets/types.js +2 -0
- package/dist/lib/secrets/types.js.map +1 -0
- package/dist/lib/settings/SettingsClient.d.ts +9 -0
- package/dist/lib/settings/SettingsClient.d.ts.map +1 -0
- package/dist/lib/settings/SettingsClient.js +17 -0
- package/dist/lib/settings/SettingsClient.js.map +1 -0
- package/dist/lib/settings/types.d.ts +6 -0
- package/dist/lib/settings/types.d.ts.map +1 -0
- package/dist/lib/settings/types.js +2 -0
- package/dist/lib/settings/types.js.map +1 -0
- package/dist/lib/storage/StorageClient.d.ts +38 -0
- package/dist/lib/storage/StorageClient.d.ts.map +1 -0
- package/dist/lib/storage/StorageClient.js +102 -0
- package/dist/lib/storage/StorageClient.js.map +1 -0
- package/dist/lib/storage/types.d.ts +73 -0
- package/dist/lib/storage/types.d.ts.map +1 -0
- package/dist/lib/storage/types.js +2 -0
- package/dist/lib/storage/types.js.map +1 -0
- package/dist/lib/users/UserClient.d.ts +17 -0
- package/dist/lib/users/UserClient.d.ts.map +1 -0
- package/dist/lib/users/UserClient.js +40 -0
- package/dist/lib/users/UserClient.js.map +1 -0
- package/dist/lib/users/types.d.ts +108 -0
- package/dist/lib/users/types.d.ts.map +1 -0
- package/dist/lib/users/types.js +2 -0
- package/dist/lib/users/types.js.map +1 -0
- package/dist/lib-internal/errors/ErrorClient.d.ts +42 -0
- package/dist/lib-internal/errors/ErrorClient.d.ts.map +1 -0
- package/dist/lib-internal/errors/ErrorClient.js +102 -0
- package/dist/lib-internal/errors/ErrorClient.js.map +1 -0
- package/dist/lib-internal/errors/index.d.ts +4 -0
- package/dist/lib-internal/errors/index.d.ts.map +1 -0
- package/dist/lib-internal/errors/index.js +3 -0
- package/dist/lib-internal/errors/index.js.map +1 -0
- package/dist/lib-internal/errors/types.d.ts +29 -0
- package/dist/lib-internal/errors/types.d.ts.map +1 -0
- package/dist/lib-internal/errors/types.js +18 -0
- package/dist/lib-internal/errors/types.js.map +1 -0
- package/dist/lib-internal/http/HttpClient.d.ts +24 -0
- package/dist/lib-internal/http/HttpClient.d.ts.map +1 -0
- package/dist/lib-internal/http/HttpClient.js +103 -0
- package/dist/lib-internal/http/HttpClient.js.map +1 -0
- package/dist/lib-internal/http/types.d.ts +12 -0
- package/dist/lib-internal/http/types.d.ts.map +1 -0
- package/{src/lib-internal/http/types.ts → dist/lib-internal/http/types.js} +2 -3
- package/dist/lib-internal/http/types.js.map +1 -0
- package/dist/lib-internal/routes/AnalyticsRoutes.d.ts +4 -0
- package/dist/lib-internal/routes/AnalyticsRoutes.d.ts.map +1 -0
- package/dist/lib-internal/routes/AnalyticsRoutes.js +4 -0
- package/dist/lib-internal/routes/AnalyticsRoutes.js.map +1 -0
- package/dist/lib-internal/routes/AppRoutes.d.ts +10 -0
- package/dist/lib-internal/routes/AppRoutes.d.ts.map +1 -0
- package/dist/lib-internal/routes/AppRoutes.js +6 -0
- package/dist/lib-internal/routes/AppRoutes.js.map +1 -0
- package/dist/lib-internal/routes/AuthRoutes.d.ts +2 -0
- package/dist/lib-internal/routes/AuthRoutes.d.ts.map +1 -0
- package/dist/lib-internal/routes/AuthRoutes.js +2 -0
- package/dist/lib-internal/routes/AuthRoutes.js.map +1 -0
- package/dist/lib-internal/routes/DatabaseRoutes.d.ts +11 -0
- package/dist/lib-internal/routes/DatabaseRoutes.d.ts.map +1 -0
- package/dist/lib-internal/routes/DatabaseRoutes.js +7 -0
- package/dist/lib-internal/routes/DatabaseRoutes.js.map +1 -0
- package/dist/lib-internal/routes/FunctionRoutes.d.ts +4 -0
- package/dist/lib-internal/routes/FunctionRoutes.d.ts.map +1 -0
- package/dist/lib-internal/routes/FunctionRoutes.js +4 -0
- package/dist/lib-internal/routes/FunctionRoutes.js.map +1 -0
- package/dist/lib-internal/routes/PolicyRoutes.d.ts +5 -0
- package/dist/lib-internal/routes/PolicyRoutes.d.ts.map +1 -0
- package/dist/lib-internal/routes/PolicyRoutes.js +5 -0
- package/dist/lib-internal/routes/PolicyRoutes.js.map +1 -0
- package/dist/lib-internal/routes/SecretsRoutes.d.ts +6 -0
- package/dist/lib-internal/routes/SecretsRoutes.d.ts.map +1 -0
- package/dist/lib-internal/routes/SecretsRoutes.js +6 -0
- package/dist/lib-internal/routes/SecretsRoutes.js.map +1 -0
- package/dist/lib-internal/routes/SettingsRoutes.d.ts +5 -0
- package/dist/lib-internal/routes/SettingsRoutes.d.ts.map +1 -0
- package/{src/lib-internal/routes/SettingsRoutes.ts → dist/lib-internal/routes/SettingsRoutes.js} +2 -1
- package/dist/lib-internal/routes/SettingsRoutes.js.map +1 -0
- package/dist/lib-internal/routes/StorageRoutes.d.ts +11 -0
- package/dist/lib-internal/routes/StorageRoutes.d.ts.map +1 -0
- package/dist/lib-internal/routes/StorageRoutes.js +8 -0
- package/dist/lib-internal/routes/StorageRoutes.js.map +1 -0
- package/dist/lib-internal/routes/UserRoutes.d.ts +13 -0
- package/dist/lib-internal/routes/UserRoutes.d.ts.map +1 -0
- package/dist/lib-internal/routes/UserRoutes.js +13 -0
- package/dist/lib-internal/routes/UserRoutes.js.map +1 -0
- package/dist/lib-internal/routes/index.d.ts +2 -0
- package/dist/lib-internal/routes/index.d.ts.map +1 -0
- package/dist/lib-internal/routes/index.js +2 -0
- package/dist/lib-internal/routes/index.js.map +1 -0
- package/dist/lib-internal/token/TokenClient.d.ts +38 -0
- package/dist/lib-internal/token/TokenClient.d.ts.map +1 -0
- package/{src/lib-internal/token/TokenClient.ts → dist/lib-internal/token/TokenClient.js} +44 -59
- package/dist/lib-internal/token/TokenClient.js.map +1 -0
- package/dist/lib-internal/token/types.d.ts +2 -0
- package/dist/lib-internal/token/types.d.ts.map +1 -0
- package/dist/lib-internal/token/types.js +2 -0
- package/dist/lib-internal/token/types.js.map +1 -0
- package/dist/types.d.ts +74 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/enums.d.ts +31 -0
- package/dist/utils/enums.d.ts.map +1 -0
- package/dist/utils/enums.js +26 -0
- package/dist/utils/enums.js.map +1 -0
- package/dist/utils/utils.d.ts +6 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +38 -0
- package/dist/utils/utils.js.map +1 -0
- package/package.json +11 -2
- package/.github/worflows/publish.yml +0 -57
- package/.github/workflows/publish.yml +0 -58
- package/.kiro/settings/lsp.json +0 -198
- package/MODULE_NAMING_CHANGES.md +0 -81
- package/PARAMETER_NAMING_CHANGES.md +0 -106
- package/USAGE_EXAMPLE.md +0 -86
- package/src/index.ts +0 -50
- package/src/lib/analytics/AnalyticsClient.ts +0 -24
- package/src/lib/analytics/types.ts +0 -8
- package/src/lib/app/AppClient.ts +0 -54
- package/src/lib/app/types.ts +0 -50
- package/src/lib/auth/AuthClient.ts +0 -148
- package/src/lib/auth/types.ts +0 -123
- package/src/lib/database/DatabaseClient.ts +0 -244
- package/src/lib/database/types.ts +0 -90
- package/src/lib/functions/FunctionsClient.ts +0 -27
- package/src/lib/functions/types.ts +0 -27
- package/src/lib/policy/types.ts +0 -39
- package/src/lib/secrets/SecretsClient.ts +0 -75
- package/src/lib/secrets/types.ts +0 -59
- package/src/lib/settings/SettingsClient.ts +0 -22
- package/src/lib/settings/types.ts +0 -9
- package/src/lib/storage/StorageClient.ts +0 -131
- package/src/lib/storage/types.ts +0 -86
- package/src/lib/users/UserClient.ts +0 -63
- package/src/lib/users/types.ts +0 -123
- package/src/lib-internal/errors/ErrorClient.ts +0 -114
- package/src/lib-internal/errors/index.ts +0 -3
- package/src/lib-internal/errors/types.ts +0 -29
- package/src/lib-internal/http/HttpClient.ts +0 -117
- package/src/lib-internal/routes/AnalyticsRoutes.ts +0 -3
- package/src/lib-internal/routes/AppRoutes.ts +0 -9
- package/src/lib-internal/routes/AuthRoutes.ts +0 -3
- package/src/lib-internal/routes/DatabaseRoutes.ts +0 -10
- package/src/lib-internal/routes/FunctionRoutes.ts +0 -3
- package/src/lib-internal/routes/PolicyRoutes.ts +0 -4
- package/src/lib-internal/routes/SecretsRoutes.ts +0 -5
- package/src/lib-internal/routes/StorageRoutes.ts +0 -15
- package/src/lib-internal/routes/UserRoutes.ts +0 -12
- package/src/lib-internal/routes/index.ts +0 -0
- package/src/lib-internal/token/types.ts +0 -0
- package/src/types.ts +0 -98
- package/src/utils/enums.ts +0 -24
- package/src/utils/utils.ts +0 -37
- package/tests/fixtures/mockClient.ts +0 -19
- package/tests/mocks/db.json +0 -1
- package/tests/unit/analytics/AnalyticsClient.test.ts +0 -84
- package/tests/unit/app/AppClient.test.ts +0 -114
- package/tests/unit/auth/AuthClient.test.ts +0 -91
- package/tests/unit/client/Client.test.ts +0 -87
- package/tests/unit/database/DatabaseClient.test.ts +0 -565
- package/tests/unit/edge-cases/robustness.test.ts +0 -258
- package/tests/unit/errors/errors.test.ts +0 -236
- package/tests/unit/functions/FunctionsClient.test.ts +0 -99
- package/tests/unit/policy/PolicyClient.test.ts +0 -180
- package/tests/unit/secrets/SecretsClient.test.ts +0 -146
- package/tests/unit/settings/SettingsClient.test.ts +0 -50
- package/tests/unit/storage/StorageClient.test.ts +0 -252
- package/tests/unit/users/UserClient.test.ts +0 -150
- package/tsconfig.json +0 -44
- package/vitest.config.ts +0 -7
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import type { Client } from "../../client.js";
|
|
2
|
-
import type { TaruviResponse } from "../../types.js";
|
|
3
|
-
import type { UserData } from "../users/types.js";
|
|
4
|
-
import { AuthRoutes } from "../../lib-internal/routes/AuthRoutes.js";
|
|
5
|
-
import { UserRoutes } from "../../lib-internal/routes/UserRoutes.js";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Auth Client - Handles user authentication using Web UI Flow
|
|
9
|
-
* Uses session token for API authentication via X-Session-Token header.
|
|
10
|
-
* On 401/403, tokens are cleared automatically by HttpClient interceptor.
|
|
11
|
-
*/
|
|
12
|
-
export class Auth {
|
|
13
|
-
private client: Client
|
|
14
|
-
|
|
15
|
-
constructor(client: Client) {
|
|
16
|
-
this.client = client
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Redirect to login page (Web UI Flow)
|
|
21
|
-
*/
|
|
22
|
-
login(callbackUrl?: string): void {
|
|
23
|
-
if (typeof window === "undefined") {
|
|
24
|
-
console.error("login() can only be called in browser environment")
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const config = this.client.getConfig()
|
|
29
|
-
const callback = callbackUrl || window.location.origin + window.location.pathname
|
|
30
|
-
const deskUrl = config.deskUrl || config.apiUrl
|
|
31
|
-
const loginUrl = `${deskUrl}/accounts/login/?redirect_to=${encodeURIComponent(callback)}`
|
|
32
|
-
|
|
33
|
-
if (typeof sessionStorage !== "undefined") {
|
|
34
|
-
sessionStorage.setItem("auth_state", JSON.stringify({
|
|
35
|
-
returnTo: window.location.pathname,
|
|
36
|
-
timestamp: Date.now()
|
|
37
|
-
}))
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
window.location.href = loginUrl
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Redirect to signup page (Web UI Flow)
|
|
45
|
-
*/
|
|
46
|
-
signup(callbackUrl?: string): void {
|
|
47
|
-
if (typeof window === "undefined") {
|
|
48
|
-
console.error("signup() can only be called in browser environment")
|
|
49
|
-
return
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const config = this.client.getConfig()
|
|
53
|
-
const callback = callbackUrl || window.location.origin + window.location.pathname
|
|
54
|
-
const signupUrl = `${config.apiUrl}/accounts/signup/?redirect_to=${encodeURIComponent(callback)}`
|
|
55
|
-
|
|
56
|
-
if (typeof sessionStorage !== "undefined") {
|
|
57
|
-
sessionStorage.setItem("auth_state", JSON.stringify({
|
|
58
|
-
returnTo: window.location.pathname,
|
|
59
|
-
timestamp: Date.now()
|
|
60
|
-
}))
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
window.location.href = signupUrl
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Logout user and redirect to logout page
|
|
68
|
-
*/
|
|
69
|
-
async logout(callbackUrl?: string): Promise<void> {
|
|
70
|
-
if (typeof window === "undefined") {
|
|
71
|
-
console.error("logout() can only be called in browser environment")
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
this.client.tokenClient.clearTokens()
|
|
76
|
-
|
|
77
|
-
const config = this.client.getConfig()
|
|
78
|
-
const deskUrl = config.deskUrl || config.apiUrl
|
|
79
|
-
let callback: string = callbackUrl || ""
|
|
80
|
-
|
|
81
|
-
if (!callback) {
|
|
82
|
-
try {
|
|
83
|
-
const settings = await this.client.httpClient.get<{ frontend_url?: string }>(
|
|
84
|
-
`api/sites/${config.appSlug}/metadata`
|
|
85
|
-
)
|
|
86
|
-
callback = settings.frontend_url || window.location.origin
|
|
87
|
-
} catch (error) {
|
|
88
|
-
console.error("Failed to fetch site settings, using origin:", error)
|
|
89
|
-
callback = window.location.origin
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const logoutUrl = `${deskUrl}/accounts/logout/?redirect_to=${encodeURIComponent(callback)}`
|
|
94
|
-
window.location.href = logoutUrl
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Check if a session token exists locally (does not validate with server)
|
|
99
|
-
*/
|
|
100
|
-
hasToken(): boolean {
|
|
101
|
-
return this.client.tokenClient.isAuthenticated()
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Check if user is authenticated by validating session with the server
|
|
106
|
-
*/
|
|
107
|
-
async isUserAuthenticated(): Promise<boolean> {
|
|
108
|
-
if (!this.hasToken()) return false
|
|
109
|
-
try {
|
|
110
|
-
await this.validateSession()
|
|
111
|
-
return true
|
|
112
|
-
} catch {
|
|
113
|
-
return false
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Validate current session token with auth session endpoint.
|
|
119
|
-
* HttpClient injects X-Session-Token automatically.
|
|
120
|
-
*/
|
|
121
|
-
async validateSession(): Promise<void> {
|
|
122
|
-
await this.client.httpClient.get(AuthRoutes.session())
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Get the current session token
|
|
127
|
-
*/
|
|
128
|
-
getSessionToken(): string | null {
|
|
129
|
-
return this.client.tokenClient.getSessionToken()
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Get current user from API
|
|
134
|
-
* @returns Promise with user data or null if not authenticated
|
|
135
|
-
*/
|
|
136
|
-
async getCurrentUser(): Promise<TaruviResponse<UserData> | null> {
|
|
137
|
-
if (!this.hasToken()) {
|
|
138
|
-
return null
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
try {
|
|
142
|
-
return await this.client.httpClient.get<TaruviResponse<UserData>>(UserRoutes.getCurrentUser())
|
|
143
|
-
} catch (error) {
|
|
144
|
-
console.error("Failed to fetch current user:", error)
|
|
145
|
-
return null
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
package/src/lib/auth/types.ts
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
export interface UserCreateRequest {
|
|
2
|
-
// Required fields
|
|
3
|
-
username: string
|
|
4
|
-
email: string
|
|
5
|
-
first_name: string
|
|
6
|
-
last_name: string
|
|
7
|
-
password: string
|
|
8
|
-
confirm_password: string
|
|
9
|
-
// Optional fields
|
|
10
|
-
is_active?: boolean
|
|
11
|
-
is_staff?: boolean
|
|
12
|
-
attributes?: string
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface UserCreateResponse {
|
|
16
|
-
id: string
|
|
17
|
-
username: string
|
|
18
|
-
email: string
|
|
19
|
-
first_name: string
|
|
20
|
-
last_name: string
|
|
21
|
-
full_name: string
|
|
22
|
-
is_active: boolean
|
|
23
|
-
is_superuser: boolean
|
|
24
|
-
is_deleted: boolean
|
|
25
|
-
date_joined: string
|
|
26
|
-
last_login: string
|
|
27
|
-
groups: UserGroup[]
|
|
28
|
-
user_permissions: UserPermission[]
|
|
29
|
-
attributes: Record<string, unknown>
|
|
30
|
-
missing_attributes: string[]
|
|
31
|
-
roles: UserRole[]
|
|
32
|
-
icon_url: string | null
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface UserGroup {
|
|
36
|
-
id: number
|
|
37
|
-
name: string
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface UserPermission {
|
|
41
|
-
id: number
|
|
42
|
-
name: string
|
|
43
|
-
codename: string
|
|
44
|
-
content_type: string // "app_label.model"
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface UserRole {
|
|
48
|
-
name: string
|
|
49
|
-
slug: string
|
|
50
|
-
type: "app_role"
|
|
51
|
-
app_slug: string
|
|
52
|
-
source: "direct" | "site_role" | "inherited"
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface UserDataResponse {
|
|
56
|
-
id: string
|
|
57
|
-
username: string
|
|
58
|
-
email: string
|
|
59
|
-
first_name: string
|
|
60
|
-
last_name: string
|
|
61
|
-
full_name: string
|
|
62
|
-
is_active: boolean
|
|
63
|
-
is_superuser: boolean
|
|
64
|
-
is_deleted: boolean
|
|
65
|
-
date_joined: string
|
|
66
|
-
last_login: string
|
|
67
|
-
groups: UserGroup[]
|
|
68
|
-
user_permissions: UserPermission[]
|
|
69
|
-
attributes: Record<string, unknown>
|
|
70
|
-
missing_attributes: string[]
|
|
71
|
-
roles: UserRole[]
|
|
72
|
-
icon_url: string | null
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface UserUpdateRequest {
|
|
76
|
-
username?: string
|
|
77
|
-
email?: string
|
|
78
|
-
first_name?: string
|
|
79
|
-
last_name?: string
|
|
80
|
-
is_active?: boolean
|
|
81
|
-
is_staff?: boolean
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export interface UserUpdateResponse {
|
|
85
|
-
id: string
|
|
86
|
-
username: string
|
|
87
|
-
email: string
|
|
88
|
-
first_name: string
|
|
89
|
-
last_name: string
|
|
90
|
-
full_name: string
|
|
91
|
-
is_active: boolean
|
|
92
|
-
is_superuser: boolean
|
|
93
|
-
is_deleted: boolean
|
|
94
|
-
date_joined: string
|
|
95
|
-
last_login: string
|
|
96
|
-
groups: UserGroup[]
|
|
97
|
-
user_permissions: UserPermission[]
|
|
98
|
-
attributes: Record<string, unknown>
|
|
99
|
-
missing_attributes: string[]
|
|
100
|
-
roles: UserRole[]
|
|
101
|
-
icon_url: string | null
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export interface UserList {
|
|
105
|
-
search: string
|
|
106
|
-
is_active: boolean
|
|
107
|
-
is_staff: boolean
|
|
108
|
-
is_superuser: boolean
|
|
109
|
-
is_deleted: boolean
|
|
110
|
-
ordering: string
|
|
111
|
-
page: Number
|
|
112
|
-
page_size: Number
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export interface UserApp {
|
|
116
|
-
name: string
|
|
117
|
-
slug: string
|
|
118
|
-
icon: string
|
|
119
|
-
url: string
|
|
120
|
-
display_name: string
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export type UserAppsResponse = UserApp[]
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import type { Client } from "../../client.js";
|
|
2
|
-
import { DatabaseRoutes } from "../../lib-internal/routes/DatabaseRoutes.js";
|
|
3
|
-
import { HttpMethod } from "../../lib-internal/http/types.js";
|
|
4
|
-
import type { TaruviConfig, DatabaseFilters, TaruviResponse } from "../../types.js";
|
|
5
|
-
import type { UrlParams, FilterOperator, SortOrder, GraphInclude, GraphFormat, EdgeRequest, EdgeDeleteRequest } from "./types.js";
|
|
6
|
-
import { buildQueryString } from "../../utils/utils.js";
|
|
7
|
-
|
|
8
|
-
interface GraphQueryParams {
|
|
9
|
-
include?: GraphInclude
|
|
10
|
-
depth?: number
|
|
11
|
-
format?: GraphFormat
|
|
12
|
-
relationship_type?: string[]
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Used to access app data
|
|
16
|
-
export class Database<T = Record<string, unknown>> {
|
|
17
|
-
private client: Client
|
|
18
|
-
private urlParams: UrlParams
|
|
19
|
-
private config: TaruviConfig
|
|
20
|
-
private operation: HttpMethod | undefined
|
|
21
|
-
private body: object | undefined
|
|
22
|
-
private queryParams: DatabaseFilters | undefined
|
|
23
|
-
private graphParams: GraphQueryParams
|
|
24
|
-
private isEdges: boolean
|
|
25
|
-
private isUpsert: boolean
|
|
26
|
-
|
|
27
|
-
constructor(client: Client, urlParams: UrlParams = {}, operation?: HttpMethod | undefined, body?: object | undefined, queryParams?: DatabaseFilters, graphParams: GraphQueryParams = {}, isEdges: boolean = false, isUpsert: boolean = false) {
|
|
28
|
-
this.client = client
|
|
29
|
-
this.urlParams = urlParams
|
|
30
|
-
this.operation = operation
|
|
31
|
-
this.body = body
|
|
32
|
-
this.config = this.client.getConfig()
|
|
33
|
-
this.queryParams = queryParams
|
|
34
|
-
this.graphParams = graphParams
|
|
35
|
-
this.isEdges = isEdges
|
|
36
|
-
this.isUpsert = isUpsert
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
from<U = Record<string, unknown>>(dataTables: string): Database<U> {
|
|
40
|
-
return new Database<U>(this.client, { ...this.urlParams, dataTables }, undefined, undefined, undefined, {}, this.isEdges)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
edges(): Database<T> {
|
|
44
|
-
return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, this.queryParams, { ...this.graphParams }, true)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Graph traversal methods
|
|
48
|
-
include(direction: GraphInclude): Database<T> {
|
|
49
|
-
return new Database<T>(this.client, { ...this.urlParams }, this.operation, this.body, this.queryParams, { ...this.graphParams, include: direction }, this.isEdges)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
depth(n: number): Database<T> {
|
|
53
|
-
return new Database<T>(this.client, { ...this.urlParams }, this.operation, this.body, this.queryParams, { ...this.graphParams, depth: n }, this.isEdges)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
format(fmt: GraphFormat): Database<T> {
|
|
57
|
-
return new Database<T>(this.client, { ...this.urlParams }, this.operation, this.body, this.queryParams, { ...this.graphParams, format: fmt }, this.isEdges)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
types(types: string[]): Database<T> {
|
|
61
|
-
return new Database<T>(this.client, { ...this.urlParams }, this.operation, this.body, this.queryParams, { ...this.graphParams, relationship_type: types }, this.isEdges)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Filter & query methods
|
|
65
|
-
filter(field: string, operator: FilterOperator, value: string | number | boolean | (string | number)[]): Database<T> {
|
|
66
|
-
const filterKey = operator === 'eq' ? field : `${field}__${operator}`
|
|
67
|
-
const filterValue = Array.isArray(value) ? value.join(',') : value
|
|
68
|
-
return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, {
|
|
69
|
-
...this.queryParams,
|
|
70
|
-
[filterKey]: filterValue
|
|
71
|
-
}, { ...this.graphParams }, this.isEdges)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
sort(field: string, order: SortOrder = 'asc'): Database<T> {
|
|
75
|
-
const ordering = order === 'desc' ? `-${field}` : field
|
|
76
|
-
return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, {
|
|
77
|
-
...this.queryParams,
|
|
78
|
-
ordering
|
|
79
|
-
}, { ...this.graphParams }, this.isEdges)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
pageSize(size: number): Database<T> {
|
|
83
|
-
return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, {
|
|
84
|
-
...this.queryParams,
|
|
85
|
-
page_size: size
|
|
86
|
-
}, { ...this.graphParams }, this.isEdges)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
page(num: number): Database<T> {
|
|
90
|
-
return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, {
|
|
91
|
-
...this.queryParams,
|
|
92
|
-
page: num
|
|
93
|
-
}, { ...this.graphParams }, this.isEdges)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
populate(populate: string[]): Database<T> {
|
|
97
|
-
return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, {
|
|
98
|
-
...this.queryParams,
|
|
99
|
-
populate: populate.join(',')
|
|
100
|
-
}, { ...this.graphParams }, this.isEdges)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
search(query: string): Database<T> {
|
|
104
|
-
return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, {
|
|
105
|
-
...this.queryParams,
|
|
106
|
-
search: query
|
|
107
|
-
}, { ...this.graphParams }, this.isEdges)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
allowedActions(actions: string[]): Database<T> {
|
|
111
|
-
return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, {
|
|
112
|
-
...this.queryParams,
|
|
113
|
-
allowed_actions: actions.join(',')
|
|
114
|
-
}, { ...this.graphParams }, this.isEdges)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
aggregate(...expressions: string[]): Database<T> {
|
|
118
|
-
return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, {
|
|
119
|
-
...this.queryParams,
|
|
120
|
-
_aggregate: expressions.join(',')
|
|
121
|
-
}, { ...this.graphParams }, this.isEdges)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
groupBy(...fields: string[]): Database<T> {
|
|
125
|
-
return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, {
|
|
126
|
-
...this.queryParams,
|
|
127
|
-
_group_by: fields.join(',')
|
|
128
|
-
}, { ...this.graphParams }, this.isEdges)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
having(condition: string): Database<T> {
|
|
132
|
-
return new Database<T>(this.client, { ...this.urlParams }, undefined, undefined, {
|
|
133
|
-
...this.queryParams,
|
|
134
|
-
_having: condition
|
|
135
|
-
}, { ...this.graphParams }, this.isEdges)
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// CRUD methods
|
|
139
|
-
get(recordId: string): Database<T> {
|
|
140
|
-
return new Database<T>(this.client, { ...this.urlParams, recordId }, HttpMethod.GET, undefined, this.queryParams, { ...this.graphParams }, this.isEdges)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
create(body: Partial<T> | Partial<T>[] | EdgeRequest[]): Database<T> {
|
|
144
|
-
return new Database<T>(this.client, { ...this.urlParams }, HttpMethod.POST, body as object, this.queryParams, { ...this.graphParams }, this.isEdges)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
upsert(body: Partial<T> | Partial<T>[], uniqueFields?: string[]): Database<T> {
|
|
148
|
-
const qp = uniqueFields?.length ? { ...this.queryParams, unique_fields: uniqueFields.join(',') } : this.queryParams
|
|
149
|
-
return new Database<T>(this.client, { ...this.urlParams }, HttpMethod.POST, body as object, qp, { ...this.graphParams }, this.isEdges, true)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
update(body: Partial<T> | EdgeRequest): Database<T> {
|
|
153
|
-
return new Database<T>(this.client, { ...this.urlParams }, HttpMethod.PATCH, body as object, this.queryParams, { ...this.graphParams }, this.isEdges)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
bulkUpdate(body: Partial<T>[]): Database<T> {
|
|
157
|
-
return new Database<T>(this.client, { ...this.urlParams }, HttpMethod.PATCH, body as object, this.queryParams, { ...this.graphParams }, this.isEdges)
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
delete(recordIdOrEdgeIds: string | number[]): Database<T> {
|
|
161
|
-
if (Array.isArray(recordIdOrEdgeIds)) {
|
|
162
|
-
const body: EdgeDeleteRequest = { edge_ids: recordIdOrEdgeIds }
|
|
163
|
-
return new Database<T>(this.client, { ...this.urlParams }, HttpMethod.DELETE, body, this.queryParams, { ...this.graphParams }, this.isEdges)
|
|
164
|
-
}
|
|
165
|
-
return new Database<T>(this.client, { ...this.urlParams, recordId: recordIdOrEdgeIds }, HttpMethod.DELETE, undefined, this.queryParams, { ...this.graphParams }, this.isEdges)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
bulkDelete(ids: string[]): Database<T> {
|
|
169
|
-
return new Database<T>(this.client, { ...this.urlParams }, HttpMethod.DELETE, undefined, {
|
|
170
|
-
...this.queryParams,
|
|
171
|
-
ids: ids.join(',')
|
|
172
|
-
}, { ...this.graphParams }, this.isEdges)
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
deleteFiltered(): Database<T> {
|
|
176
|
-
return new Database<T>(this.client, { ...this.urlParams }, HttpMethod.DELETE, undefined, this.queryParams, { ...this.graphParams }, this.isEdges)
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
async first(): Promise<T | null> {
|
|
180
|
-
const response = await this.execute()
|
|
181
|
-
const data = response.data
|
|
182
|
-
if (Array.isArray(data)) {
|
|
183
|
-
return data[0] ?? null
|
|
184
|
-
}
|
|
185
|
-
return data ?? null
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
async count(): Promise<number> {
|
|
189
|
-
const response = await this.execute()
|
|
190
|
-
if (response.total !== undefined) {
|
|
191
|
-
return response.total
|
|
192
|
-
}
|
|
193
|
-
return Array.isArray(response.data) ? response.data.length : 0
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
private getTableName(): string {
|
|
197
|
-
const table = this.urlParams.dataTables
|
|
198
|
-
if (!table) throw new Error('Table name is required. Call .from(tableName) first.')
|
|
199
|
-
return this.isEdges ? `${table}_edges` : table
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
private buildRoute(): string {
|
|
203
|
-
const tableName = this.getTableName()
|
|
204
|
-
const base = DatabaseRoutes.baseUrl(this.config.appSlug) +
|
|
205
|
-
DatabaseRoutes.dataTables(tableName) +
|
|
206
|
-
(this.urlParams.recordId ? DatabaseRoutes.recordId(this.urlParams.recordId) : '') +
|
|
207
|
-
(this.isUpsert ? DatabaseRoutes.upsert() : '') +
|
|
208
|
-
'/'
|
|
209
|
-
|
|
210
|
-
// Merge database filters and graph params into one query string
|
|
211
|
-
const allParams: Record<string, unknown> = { ...this.queryParams, ...this.graphParams }
|
|
212
|
-
return base + buildQueryString(allParams)
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
async execute(): Promise<TaruviResponse<T | T[]>> {
|
|
216
|
-
if (!this.urlParams.dataTables) {
|
|
217
|
-
throw new Error('Table name is required. Call .from(tableName) first.')
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const url = this.buildRoute()
|
|
221
|
-
const operation = this.operation || HttpMethod.GET
|
|
222
|
-
|
|
223
|
-
switch (operation) {
|
|
224
|
-
case HttpMethod.POST:
|
|
225
|
-
return await this.client.httpClient.post(url, this.body)
|
|
226
|
-
|
|
227
|
-
case HttpMethod.PATCH:
|
|
228
|
-
if (!this.urlParams.recordId && !Array.isArray(this.body)) {
|
|
229
|
-
throw new Error('PATCH operation requires a record ID.')
|
|
230
|
-
}
|
|
231
|
-
return await this.client.httpClient.patch(url, this.body)
|
|
232
|
-
|
|
233
|
-
case HttpMethod.DELETE:
|
|
234
|
-
if (this.body) {
|
|
235
|
-
return await this.client.httpClient.delete(url, this.body)
|
|
236
|
-
}
|
|
237
|
-
return await this.client.httpClient.delete(url)
|
|
238
|
-
|
|
239
|
-
case HttpMethod.GET:
|
|
240
|
-
default:
|
|
241
|
-
return await this.client.httpClient.get(url)
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import type { Client } from "../../client.js"
|
|
2
|
-
import { HttpMethod } from "../../lib-internal/http/types.js"
|
|
3
|
-
import type { TaruviResponse } from "../../types.js"
|
|
4
|
-
|
|
5
|
-
export type DatabaseOperation = HttpMethod
|
|
6
|
-
|
|
7
|
-
// Filter operators matching backend FilterParams.OPERATORS (32 operators)
|
|
8
|
-
export type FilterOperator =
|
|
9
|
-
// Comparison
|
|
10
|
-
| 'eq' // Equal
|
|
11
|
-
| 'ne' // Not equal
|
|
12
|
-
| 'gt' // Greater than
|
|
13
|
-
| 'gte' // Greater than or equal
|
|
14
|
-
| 'lt' // Less than
|
|
15
|
-
| 'lte' // Less than or equal
|
|
16
|
-
// IN operators
|
|
17
|
-
| 'in' // In array
|
|
18
|
-
| 'nin' // Not in array
|
|
19
|
-
| 'ina' // In array (case-insensitive)
|
|
20
|
-
| 'nina' // Not in array (case-insensitive)
|
|
21
|
-
// String contains
|
|
22
|
-
| 'contains' // Contains (case-sensitive)
|
|
23
|
-
| 'ncontains' // Not contains (case-sensitive)
|
|
24
|
-
| 'containss' // Contains (case-sensitive, strict)
|
|
25
|
-
| 'ncontainss' // Not contains (case-sensitive, strict)
|
|
26
|
-
| 'icontains' // Contains (case-insensitive)
|
|
27
|
-
| 'nicontains' // Not contains (case-insensitive)
|
|
28
|
-
// Starts with
|
|
29
|
-
| 'startswith' // Starts with (case-sensitive)
|
|
30
|
-
| 'nstartswith' // Not starts with (case-sensitive)
|
|
31
|
-
| 'startswiths' // Starts with (case-sensitive, strict)
|
|
32
|
-
| 'nstartswiths' // Not starts with (case-sensitive, strict)
|
|
33
|
-
// Ends with
|
|
34
|
-
| 'endswith' // Ends with (case-sensitive)
|
|
35
|
-
| 'nendswith' // Not ends with (case-sensitive)
|
|
36
|
-
| 'endswiths' // Ends with (case-sensitive, strict)
|
|
37
|
-
| 'nendswiths' // Not ends with (case-sensitive, strict)
|
|
38
|
-
// Range
|
|
39
|
-
| 'between' // Between two values
|
|
40
|
-
| 'nbetween' // Not between two values
|
|
41
|
-
// Null checks
|
|
42
|
-
| 'null' // Is null
|
|
43
|
-
| 'nnull' // Is not null
|
|
44
|
-
|
|
45
|
-
export type SortOrder = 'asc' | 'desc'
|
|
46
|
-
|
|
47
|
-
// Internal types
|
|
48
|
-
export interface UrlParams {
|
|
49
|
-
appSlug?: string
|
|
50
|
-
dataTables?: string
|
|
51
|
-
recordId?: string
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface DatabaseClientInterface {
|
|
55
|
-
client: Client
|
|
56
|
-
urlParams?: UrlParams
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Request types
|
|
60
|
-
export interface DatabaseRequest {
|
|
61
|
-
[key: string]: unknown
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Response types - uses standard wrapper
|
|
65
|
-
export type DatabaseResponse<T = unknown> = TaruviResponse<T[]>
|
|
66
|
-
export type DatabaseSingleResponse<T = unknown> = TaruviResponse<T>
|
|
67
|
-
|
|
68
|
-
// Graph traversal types
|
|
69
|
-
export type GraphInclude = 'descendants' | 'ancestors' | 'both'
|
|
70
|
-
export type GraphFormat = 'tree' | 'graph'
|
|
71
|
-
|
|
72
|
-
// Edge types
|
|
73
|
-
export interface EdgeRequest {
|
|
74
|
-
from_id: number | string
|
|
75
|
-
to_id: number | string
|
|
76
|
-
type: string
|
|
77
|
-
metadata?: Record<string, unknown>
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface EdgeResponse {
|
|
81
|
-
id: number
|
|
82
|
-
from_id: number | string
|
|
83
|
-
to_id: number | string
|
|
84
|
-
type: string
|
|
85
|
-
metadata?: Record<string, unknown>
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export interface EdgeDeleteRequest {
|
|
89
|
-
edge_ids: number[]
|
|
90
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { Client } from "../../client.js";
|
|
2
|
-
import type { TaruviConfig } from "../../types.js";
|
|
3
|
-
import type { FunctionRequest, FunctionResponse } from "./types.js";
|
|
4
|
-
import { FunctionRoutes } from "../../lib-internal/routes/FunctionRoutes.js";
|
|
5
|
-
|
|
6
|
-
export class Functions {
|
|
7
|
-
private client: Client
|
|
8
|
-
private config: TaruviConfig
|
|
9
|
-
|
|
10
|
-
constructor(client: Client) {
|
|
11
|
-
this.client = client
|
|
12
|
-
this.config = this.client.getConfig()
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async execute<T = unknown>(functionSlug: string, options: FunctionRequest = {}): Promise<FunctionResponse<T>> {
|
|
16
|
-
const url = `${FunctionRoutes.baseUrl(this.config.appSlug, functionSlug)}/execute/`
|
|
17
|
-
|
|
18
|
-
const body = {
|
|
19
|
-
async: options.async ?? false,
|
|
20
|
-
params: {
|
|
21
|
-
...options.params
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return await this.client.httpClient.post<FunctionResponse<T>>(url, body)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export interface FunctionRequest {
|
|
2
|
-
async?: boolean
|
|
3
|
-
params?: Record<string, unknown>
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface FunctionInvocation {
|
|
7
|
-
id: number
|
|
8
|
-
celery_task_id: string
|
|
9
|
-
function: number
|
|
10
|
-
function_name: string
|
|
11
|
-
function_slug: string
|
|
12
|
-
user_id: string | null
|
|
13
|
-
user_username: string
|
|
14
|
-
user_email: string
|
|
15
|
-
task_status: string
|
|
16
|
-
trigger_type: string
|
|
17
|
-
created_at: string
|
|
18
|
-
updated_at?: string
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Response type - matches backend AppDataResponse with invocation
|
|
22
|
-
export interface FunctionResponse<T = unknown> {
|
|
23
|
-
status: "success" | "error"
|
|
24
|
-
message: string
|
|
25
|
-
data: T | null
|
|
26
|
-
invocation: FunctionInvocation
|
|
27
|
-
}
|
package/src/lib/policy/types.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { TaruviResponse } from "../../types.js"
|
|
2
|
-
|
|
3
|
-
export interface Principal {
|
|
4
|
-
id: string
|
|
5
|
-
roles: string[]
|
|
6
|
-
attr: Record<string, unknown>
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export type Resource = {
|
|
10
|
-
kind: string
|
|
11
|
-
id: string
|
|
12
|
-
attr: Record<string, unknown>
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type Resources = {
|
|
16
|
-
resource: string
|
|
17
|
-
recordId: string
|
|
18
|
-
attributes: Record<string, unknown>
|
|
19
|
-
actions: string[]
|
|
20
|
-
}[]
|
|
21
|
-
|
|
22
|
-
export interface PolicyCheckResult {
|
|
23
|
-
resource: Resource
|
|
24
|
-
actions: Record<string, string>
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface PolicyCheckBatchResult {
|
|
28
|
-
requestId: string
|
|
29
|
-
results: PolicyCheckResult[]
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export type GetAllowedActionsOptions = {
|
|
33
|
-
actions?: string[]
|
|
34
|
-
principal?: Principal
|
|
35
|
-
auxData?: Record<string, unknown>
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Response types - uses standard wrapper
|
|
39
|
-
export type ResourceCheckResponse = TaruviResponse<PolicyCheckBatchResult>
|