@taruvi/sdk 1.5.0 → 1.5.1
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 +47 -0
- package/dist/lib/auth/AuthClient.d.ts.map +1 -0
- package/{src/lib/auth/AuthClient.ts → dist/lib/auth/AuthClient.js} +58 -79
- 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 +4 -0
- package/dist/lib-internal/routes/AuthRoutes.d.ts.map +1 -0
- package/{src/lib-internal/routes/AuthRoutes.ts → dist/lib-internal/routes/AuthRoutes.js} +2 -1
- 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/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/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,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>
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type { Client } from "../../client.js";
|
|
2
|
-
import type { SecretsUrlParams, GetSecretOptions, GetSecretsOptions, SecretsBatchResponse, SecretsBatchMetadataResponse } from "./types.js";
|
|
3
|
-
import { HttpMethod } from "../../lib-internal/http/types.js";
|
|
4
|
-
import { SecretsRoutes } from "../../lib-internal/routes/SecretsRoutes.js";
|
|
5
|
-
import { buildQueryString } from "../../utils/utils.js";
|
|
6
|
-
|
|
7
|
-
export class Secrets {
|
|
8
|
-
private client: Client
|
|
9
|
-
private urlParams: SecretsUrlParams
|
|
10
|
-
private body: object | undefined
|
|
11
|
-
private method: HttpMethod
|
|
12
|
-
|
|
13
|
-
constructor(client: Client, urlParams: SecretsUrlParams = {}, body?: object, method: HttpMethod = HttpMethod.GET) {
|
|
14
|
-
this.client = client
|
|
15
|
-
this.urlParams = urlParams
|
|
16
|
-
this.body = body
|
|
17
|
-
this.method = method
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Get a specific secret by key.
|
|
22
|
-
*
|
|
23
|
-
* @param key - Secret key/name
|
|
24
|
-
* @param options - Optional app context for 2-tier inheritance and tag validation
|
|
25
|
-
* @returns Secrets instance for chaining with execute()
|
|
26
|
-
*/
|
|
27
|
-
get(key: string, options: GetSecretOptions = {}): Secrets {
|
|
28
|
-
if (!key || typeof key !== 'string') {
|
|
29
|
-
throw new Error('Secret key is required and must be a string.')
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const path = SecretsRoutes.get(key)
|
|
33
|
-
const queryParams: Record<string, unknown> = {}
|
|
34
|
-
|
|
35
|
-
if (options.app) queryParams.app = options.app
|
|
36
|
-
if (options.tags && options.tags.length > 0) queryParams.tags = options.tags.join(',')
|
|
37
|
-
|
|
38
|
-
return new Secrets(this.client, { ...this.urlParams, path, queryParams }, undefined, HttpMethod.GET)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* List multiple secrets by keys using backend batch endpoint.
|
|
43
|
-
* More efficient than making multiple individual requests - uses a single API call.
|
|
44
|
-
*
|
|
45
|
-
* @param keys - List of secret keys to retrieve
|
|
46
|
-
* @param options - Optional app context and metadata flag
|
|
47
|
-
* @returns Promise with dict mapping keys to values (or full objects if includeMetadata=true)
|
|
48
|
-
*/
|
|
49
|
-
async list(keys: string[], options: GetSecretsOptions = {}): Promise<SecretsBatchResponse | SecretsBatchMetadataResponse> {
|
|
50
|
-
const queryParams: Record<string, unknown> = {
|
|
51
|
-
keys: keys.join(',')
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (options.app) queryParams.app = options.app
|
|
55
|
-
if (options.includeMetadata) queryParams.include_metadata = options.includeMetadata
|
|
56
|
-
|
|
57
|
-
const queryString = buildQueryString(queryParams)
|
|
58
|
-
const url = SecretsRoutes.baseUrl + queryString
|
|
59
|
-
|
|
60
|
-
return await this.client.httpClient.get<SecretsBatchResponse | SecretsBatchMetadataResponse>(url)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async execute<T = unknown>(): Promise<T> {
|
|
64
|
-
const queryString = buildQueryString(this.urlParams.queryParams)
|
|
65
|
-
const url = (this.urlParams.path ?? SecretsRoutes.baseUrl) + queryString
|
|
66
|
-
|
|
67
|
-
switch (this.method) {
|
|
68
|
-
case HttpMethod.PUT:
|
|
69
|
-
return await this.client.httpClient.put<T>(url, this.body)
|
|
70
|
-
case HttpMethod.GET:
|
|
71
|
-
default:
|
|
72
|
-
return await this.client.httpClient.get<T>(url)
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
package/src/lib/secrets/types.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { TaruviResponse } from "../../types.js"
|
|
2
|
-
|
|
3
|
-
// Internal types
|
|
4
|
-
export interface SecretsUrlParams {
|
|
5
|
-
path?: string
|
|
6
|
-
queryParams?: Record<string, unknown>
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
// Request types - matches SiteSecretIn from backend
|
|
10
|
-
export interface SecretCreateRequest {
|
|
11
|
-
key: string
|
|
12
|
-
value: string | Record<string, unknown>
|
|
13
|
-
secret_type: string
|
|
14
|
-
tags?: string[]
|
|
15
|
-
app?: string
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface SecretUpdateRequest {
|
|
19
|
-
value?: string | Record<string, unknown>
|
|
20
|
-
secret_type?: string
|
|
21
|
-
tags?: string[]
|
|
22
|
-
app?: string
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Options for getting a single secret
|
|
26
|
-
export interface GetSecretOptions {
|
|
27
|
-
app?: string
|
|
28
|
-
tags?: string[]
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Options for batch getting secrets
|
|
32
|
-
export interface GetSecretsOptions {
|
|
33
|
-
app?: string
|
|
34
|
-
includeMetadata?: boolean
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Secret data
|
|
38
|
-
export interface SecretData {
|
|
39
|
-
key: string
|
|
40
|
-
value: string | Record<string, unknown>
|
|
41
|
-
tags?: string[]
|
|
42
|
-
secret_type?: string
|
|
43
|
-
created_at?: string
|
|
44
|
-
updated_at?: string
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Response types - uses standard wrapper
|
|
48
|
-
export type SecretResponse = TaruviResponse<SecretData>
|
|
49
|
-
export type SecretsListResponse = TaruviResponse<SecretData[]>
|
|
50
|
-
|
|
51
|
-
// Batch get response - values only
|
|
52
|
-
export type SecretsBatchResponse = TaruviResponse<Record<string, string>>
|
|
53
|
-
|
|
54
|
-
// Batch get response - with metadata
|
|
55
|
-
export type SecretsBatchMetadataResponse = TaruviResponse<Record<string, {
|
|
56
|
-
value: string
|
|
57
|
-
tags: string[]
|
|
58
|
-
secret_type: string
|
|
59
|
-
}>>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Client } from "../../client.js";
|
|
2
|
-
import { SettingsRoutes } from "../../lib-internal/routes/SettingsRoutes.js";
|
|
3
|
-
|
|
4
|
-
export class Settings {
|
|
5
|
-
private client: Client
|
|
6
|
-
|
|
7
|
-
constructor(client: Client) {
|
|
8
|
-
this.client = client
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
async get<T = unknown>(): Promise<T> {
|
|
12
|
-
return await this.client.httpClient.get<T>(SettingsRoutes.metadata)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async getUserAttributes<T = unknown>(): Promise<T> {
|
|
16
|
-
return await this.client.httpClient.get<T>(SettingsRoutes.userAttributes)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async updateUserAttributes<T = unknown>(schema: Record<string, unknown>): Promise<T> {
|
|
20
|
-
return await this.client.httpClient.post<T>(SettingsRoutes.userAttributes, schema)
|
|
21
|
-
}
|
|
22
|
-
}
|