@apito-io/js-admin-sdk 2.7.0 → 3.0.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/README.md +30 -12
- package/dist/index.d.mts +102 -40
- package/dist/index.d.ts +102 -40
- package/dist/index.js +62 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/client.test.ts +9 -9
- package/src/client.ts +274 -57
- package/src/index.ts +8 -3
- package/src/types.ts +79 -24
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -145,33 +145,51 @@ const relatedUsers = await client.getRelationDocuments('todo-123', {
|
|
|
145
145
|
});
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
-
###
|
|
148
|
+
### Project users (system GraphQL)
|
|
149
149
|
|
|
150
|
-
These calls use the
|
|
150
|
+
These calls use the admin client and system GraphQL endpoint. They mirror the Go SDK. Pass `projectId`; on Pro/SaaS engines each user may include `tenant_id`.
|
|
151
151
|
|
|
152
152
|
| Method | Description |
|
|
153
153
|
|--------|-------------|
|
|
154
|
-
| `
|
|
154
|
+
| `searchUsers(projectId, limit?, offset?)` | List project end-users (`email`, `phone`, optional `tenant_id`). |
|
|
155
155
|
| `searchTenantsByDomain(projectId, domain)` | Exact domain lookup in project scope; returns `{ tenant }` (null if no match). |
|
|
156
|
-
| `
|
|
157
|
-
| `
|
|
158
|
-
| `
|
|
159
|
-
| `
|
|
160
|
-
| `
|
|
156
|
+
| `createUser(projectId, params)` | Create a local-password user; `params`: `{ password, role?, email?, phone? }`. |
|
|
157
|
+
| `loginUser(params)` | General: `{ projectId, password, email? or phone? }`. Google: **`googleOAuthState(projectId)`** then **`loginUser({ projectId, authMethod: 'google', code, state })`**. |
|
|
158
|
+
| `googleOAuthState(projectId)` | Returns **`{ state }`** for the Google authorize URL. |
|
|
159
|
+
| `updateUser(userId, params)` | Mutate `email`, `phone`, and/or `role` only. |
|
|
160
|
+
| `resetUserPassword(userId, password)` | Admin password reset. |
|
|
161
|
+
| `deleteUser(userId)` | Remove a project user. |
|
|
162
|
+
|
|
163
|
+
### Project storage settings (system GraphQL)
|
|
164
|
+
|
|
165
|
+
| Method | Description |
|
|
166
|
+
|--------|-------------|
|
|
167
|
+
| `getProjectStorageSettings(projectId)` | Read S3/storage settings (secrets not returned). |
|
|
168
|
+
| `updateProjectStorageSettings(input)` | Persist storage settings. |
|
|
169
|
+
|
|
170
|
+
### System files (REST)
|
|
171
|
+
|
|
172
|
+
REST base is derived from `baseURL` by stripping `/graphql`, or set `restBaseURL` on the client config.
|
|
173
|
+
|
|
174
|
+
| Method | Description |
|
|
175
|
+
|--------|-------------|
|
|
176
|
+
| `uploadSystemFile(params)` | POST `/files/upload` (multipart). |
|
|
177
|
+
| `listSystemFiles(fileType?, limit?, offset?)` | GET `/files/list`. |
|
|
178
|
+
| `deleteSystemFiles(ids)` | POST `/files/delete`. |
|
|
161
179
|
|
|
162
180
|
On the engine system GraphQL API, `createTenant` accepts an optional `domain`; when set, the domain must be unused in the project (otherwise the mutation fails). `updateTenant` enforces the same when setting `domain` to a non-empty value. Call those mutations via `executeGraphQL` if needed.
|
|
163
181
|
|
|
164
182
|
```javascript
|
|
165
183
|
const projectId = 'your-project-id';
|
|
166
184
|
|
|
167
|
-
const { users, count } = await client.
|
|
185
|
+
const { users, count } = await client.searchUsers(projectId, 50, 0);
|
|
168
186
|
console.log(
|
|
169
187
|
'users:',
|
|
170
188
|
count,
|
|
171
189
|
users.map((u) => u.email || u.phone || u.id),
|
|
172
190
|
);
|
|
173
191
|
|
|
174
|
-
const login = await client.
|
|
192
|
+
const login = await client.loginUser({
|
|
175
193
|
projectId,
|
|
176
194
|
password: 'your-password',
|
|
177
195
|
email: 'user@example.com', // use phone: '+15551234567' when project is phone mode
|
|
@@ -181,7 +199,7 @@ if (login.token) {
|
|
|
181
199
|
}
|
|
182
200
|
```
|
|
183
201
|
|
|
184
|
-
Runnable
|
|
202
|
+
Runnable samples: `examples/users`, `examples/system_files` (set `APITO_BASE_URL`, `APITO_API_KEY`, `APITO_PROJECT_ID`).
|
|
185
203
|
|
|
186
204
|
### Typed Operations
|
|
187
205
|
|
|
@@ -374,7 +392,7 @@ npm start
|
|
|
374
392
|
Pro tenant-user listing (optional `APITO_TENANT_EMAIL` / `APITO_TENANT_PHONE` + `APITO_TENANT_PASSWORD` for login):
|
|
375
393
|
|
|
376
394
|
```bash
|
|
377
|
-
cd examples/
|
|
395
|
+
cd examples/users
|
|
378
396
|
npm install
|
|
379
397
|
APITO_BASE_URL=http://localhost:5050/system/graphql APITO_API_KEY=... APITO_PROJECT_ID=... npm start
|
|
380
398
|
```
|
package/dist/index.d.mts
CHANGED
|
@@ -69,56 +69,97 @@ interface CreateAndUpdateRequest {
|
|
|
69
69
|
singlePageData?: boolean;
|
|
70
70
|
forceUpdate?: boolean;
|
|
71
71
|
}
|
|
72
|
-
/**
|
|
73
|
-
interface
|
|
72
|
+
/** Project end-user from engine system DB (table project_users). */
|
|
73
|
+
interface User {
|
|
74
74
|
id: string;
|
|
75
75
|
email?: string;
|
|
76
76
|
phone?: string;
|
|
77
77
|
role: string;
|
|
78
|
-
tenant_id
|
|
78
|
+
tenant_id?: string;
|
|
79
79
|
provider?: string;
|
|
80
80
|
status?: string;
|
|
81
81
|
created_at?: string;
|
|
82
82
|
updated_at?: string;
|
|
83
83
|
}
|
|
84
|
-
/** Login via system GraphQL `
|
|
85
|
-
interface
|
|
84
|
+
/** Login via system GraphQL `loginUser`. Password path: use `email` or `phone` per project settings. Google OAuth code path: `authMethod: 'google'`, `code`, `state` from redirect (get `state` first via `googleOAuthState`). */
|
|
85
|
+
interface LoginUserParams {
|
|
86
86
|
projectId: string;
|
|
87
|
-
/** Required for general (password) login. */
|
|
88
87
|
password?: string;
|
|
89
88
|
email?: string;
|
|
90
89
|
phone?: string;
|
|
91
|
-
/** `general` (default) or `google`. */
|
|
92
90
|
authMethod?: string;
|
|
93
|
-
/** Google authorization code (with `authMethod: 'google'`). */
|
|
94
91
|
code?: string;
|
|
95
|
-
/** OAuth state from `tenantGoogleOAuthState` or callback (with `authMethod: 'google'`). */
|
|
96
92
|
state?: string;
|
|
97
93
|
}
|
|
98
|
-
interface
|
|
94
|
+
interface GoogleOAuthStateResponse {
|
|
99
95
|
state: string;
|
|
100
96
|
}
|
|
101
|
-
interface
|
|
97
|
+
interface CreateUserParams {
|
|
102
98
|
password: string;
|
|
103
99
|
role?: string;
|
|
104
100
|
email?: string;
|
|
105
101
|
phone?: string;
|
|
106
102
|
}
|
|
107
|
-
/** Optional fields for `
|
|
108
|
-
interface
|
|
103
|
+
/** Optional fields for `updateUser`; omitted keys are not sent. */
|
|
104
|
+
interface UpdateUserParams {
|
|
109
105
|
email?: string;
|
|
110
106
|
phone?: string;
|
|
111
|
-
password?: string;
|
|
112
107
|
role?: string;
|
|
113
108
|
}
|
|
114
|
-
interface
|
|
109
|
+
interface LoginUserResponse {
|
|
115
110
|
token: string;
|
|
116
|
-
user?:
|
|
111
|
+
user?: User;
|
|
117
112
|
}
|
|
118
|
-
interface
|
|
119
|
-
users:
|
|
113
|
+
interface UsersResponse {
|
|
114
|
+
users: User[];
|
|
120
115
|
count: number;
|
|
121
116
|
}
|
|
117
|
+
interface ProjectStorageSettings {
|
|
118
|
+
use_free_cloud_storage: boolean;
|
|
119
|
+
endpoint?: string | null;
|
|
120
|
+
region?: string | null;
|
|
121
|
+
bucket?: string | null;
|
|
122
|
+
access_key_id?: string | null;
|
|
123
|
+
has_secret_access_key: boolean;
|
|
124
|
+
public_base_url?: string | null;
|
|
125
|
+
force_path_style?: boolean | null;
|
|
126
|
+
}
|
|
127
|
+
interface UpdateProjectStorageInput {
|
|
128
|
+
use_free_cloud_storage?: boolean;
|
|
129
|
+
endpoint?: string;
|
|
130
|
+
region?: string;
|
|
131
|
+
bucket?: string;
|
|
132
|
+
access_key_id?: string;
|
|
133
|
+
secret_access_key?: string;
|
|
134
|
+
public_base_url?: string;
|
|
135
|
+
force_path_style?: boolean;
|
|
136
|
+
}
|
|
137
|
+
interface SystemFile {
|
|
138
|
+
id: string;
|
|
139
|
+
file_type: string;
|
|
140
|
+
file_name: string;
|
|
141
|
+
file_extension?: string;
|
|
142
|
+
content_type?: string;
|
|
143
|
+
size: number;
|
|
144
|
+
url: string;
|
|
145
|
+
created_by?: string;
|
|
146
|
+
created_at?: string;
|
|
147
|
+
}
|
|
148
|
+
interface SystemFilesListResponse {
|
|
149
|
+
files: SystemFile[];
|
|
150
|
+
total: number;
|
|
151
|
+
}
|
|
152
|
+
interface SystemFileUploadParams {
|
|
153
|
+
fileName: string;
|
|
154
|
+
content: Uint8Array | ArrayBuffer;
|
|
155
|
+
fileType?: string;
|
|
156
|
+
}
|
|
157
|
+
interface DeleteSystemFilesResponse {
|
|
158
|
+
success: boolean;
|
|
159
|
+
deleted_ids: string[];
|
|
160
|
+
storage_failed?: string[];
|
|
161
|
+
message?: string;
|
|
162
|
+
}
|
|
122
163
|
/** One SaaS catalog tenant row from searchTenantsByDomain. */
|
|
123
164
|
interface TenantCatalogSearchRow {
|
|
124
165
|
id: string;
|
|
@@ -132,6 +173,8 @@ interface TenantByDomainResponse {
|
|
|
132
173
|
}
|
|
133
174
|
interface ClientConfig {
|
|
134
175
|
baseURL: string;
|
|
176
|
+
/** REST base (e.g. http://host:5050/system); derived from baseURL when omitted */
|
|
177
|
+
restBaseURL?: string;
|
|
135
178
|
apiKey: string;
|
|
136
179
|
timeout?: number;
|
|
137
180
|
httpClient?: any;
|
|
@@ -159,13 +202,19 @@ interface InjectedDBOperationInterface {
|
|
|
159
202
|
}): Promise<GraphQLResponse>;
|
|
160
203
|
/** @param token Legacy; ignored. Auth uses client API key. */
|
|
161
204
|
generateTenantToken(tenantId: string, duration?: string, role?: string): Promise<string>;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
205
|
+
loginUser(params: LoginUserParams): Promise<LoginUserResponse>;
|
|
206
|
+
googleOAuthState(projectId: string): Promise<GoogleOAuthStateResponse>;
|
|
207
|
+
searchUsers(projectId: string, limit?: number, offset?: number): Promise<UsersResponse>;
|
|
165
208
|
searchTenantsByDomain(projectId: string, domain: string): Promise<TenantByDomainResponse>;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
209
|
+
createUser(projectId: string, params: CreateUserParams): Promise<User>;
|
|
210
|
+
updateUser(userId: string, params: UpdateUserParams): Promise<User>;
|
|
211
|
+
resetUserPassword(userId: string, password: string): Promise<boolean>;
|
|
212
|
+
deleteUser(userId: string): Promise<boolean>;
|
|
213
|
+
getProjectStorageSettings(projectId: string): Promise<ProjectStorageSettings>;
|
|
214
|
+
updateProjectStorageSettings(input: UpdateProjectStorageInput): Promise<ProjectStorageSettings>;
|
|
215
|
+
uploadSystemFile(params: SystemFileUploadParams): Promise<SystemFile>;
|
|
216
|
+
listSystemFiles(fileType?: string, limit?: number, offset?: number): Promise<SystemFilesListResponse>;
|
|
217
|
+
deleteSystemFiles(ids: string[]): Promise<DeleteSystemFilesResponse>;
|
|
169
218
|
getSingleResource(model: string, id: string, singlePageData?: boolean): Promise<DefaultDocumentStructure>;
|
|
170
219
|
searchResources(model: string, filter?: Record<string, any>, aggregate?: boolean): Promise<SearchResult>;
|
|
171
220
|
getRelationDocuments(id: string, connection: Record<string, any>): Promise<SearchResult>;
|
|
@@ -203,6 +252,7 @@ declare class ValidationError extends ApitoError {
|
|
|
203
252
|
declare class ApitoClient implements InjectedDBOperationInterface {
|
|
204
253
|
private httpClient;
|
|
205
254
|
private baseURL;
|
|
255
|
+
private restBaseURL;
|
|
206
256
|
private apiKey;
|
|
207
257
|
private tenantId?;
|
|
208
258
|
constructor(config: ClientConfig);
|
|
@@ -222,36 +272,48 @@ declare class ApitoClient implements InjectedDBOperationInterface {
|
|
|
222
272
|
* @param role Optional token role; if omitted/empty, the engine defaults to `admin`.
|
|
223
273
|
*/
|
|
224
274
|
generateTenantToken(tenantId: string, duration?: string, role?: string): Promise<string>;
|
|
275
|
+
private authHeaders;
|
|
276
|
+
private executeREST;
|
|
225
277
|
/**
|
|
226
|
-
*
|
|
278
|
+
* Project user login (system GraphQL `loginUser`). Password path: pass `password` and `email` or `phone` per project Authentication settings. Google OAuth path: `authMethod: 'google'` with `code` and `state` from the redirect; call `googleOAuthState(projectId)` before opening Google to obtain `state`.
|
|
227
279
|
*/
|
|
228
|
-
|
|
280
|
+
loginUser(params: LoginUserParams): Promise<LoginUserResponse>;
|
|
229
281
|
/**
|
|
230
|
-
* Signed OAuth state for
|
|
282
|
+
* Signed OAuth state for Google login (system query `googleOAuthState`). Use in the authorize URL together with project `google_client_id` and the configured redirect URI.
|
|
231
283
|
*/
|
|
232
|
-
|
|
233
|
-
state: string;
|
|
234
|
-
}>;
|
|
284
|
+
googleOAuthState(projectId: string): Promise<GoogleOAuthStateResponse>;
|
|
235
285
|
/**
|
|
236
|
-
* Search
|
|
286
|
+
* Search project end-users.
|
|
237
287
|
*/
|
|
238
|
-
|
|
288
|
+
searchUsers(projectId: string, limit?: number, offset?: number): Promise<UsersResponse>;
|
|
239
289
|
/**
|
|
240
290
|
* Resolve the single SaaS catalog tenant for an exact domain match in the project (`tenant` null if none).
|
|
241
291
|
*/
|
|
242
292
|
searchTenantsByDomain(projectId: string, domain: string): Promise<TenantByDomainResponse>;
|
|
243
293
|
/**
|
|
244
|
-
* Create a
|
|
294
|
+
* Create a project user (local password). Use `email` and/or `phone` per engine validation for the project identifier mode.
|
|
245
295
|
*/
|
|
246
|
-
|
|
296
|
+
createUser(projectId: string, params: CreateUserParams): Promise<User>;
|
|
247
297
|
/**
|
|
248
|
-
* Update a
|
|
298
|
+
* Update a project user. Project scope is implied by the API key. Only include fields to change.
|
|
249
299
|
*/
|
|
250
|
-
|
|
300
|
+
updateUser(userId: string, params: UpdateUserParams): Promise<User>;
|
|
301
|
+
/** Set a new password for a project user (admin mutation resetUserPassword). */
|
|
302
|
+
resetUserPassword(userId: string, password: string): Promise<boolean>;
|
|
251
303
|
/**
|
|
252
|
-
* Delete a
|
|
304
|
+
* Delete a project user by id. Project scope is implied by the API key.
|
|
253
305
|
*/
|
|
254
|
-
|
|
306
|
+
deleteUser(userId: string): Promise<boolean>;
|
|
307
|
+
/** Read project storage settings via getProject. */
|
|
308
|
+
getProjectStorageSettings(projectId: string): Promise<ProjectStorageSettings>;
|
|
309
|
+
/** Persist project storage settings. */
|
|
310
|
+
updateProjectStorageSettings(input: UpdateProjectStorageInput): Promise<ProjectStorageSettings>;
|
|
311
|
+
/** Upload a file via POST /system/files/upload. */
|
|
312
|
+
uploadSystemFile(params: SystemFileUploadParams): Promise<SystemFile>;
|
|
313
|
+
/** List files via GET /system/files/list. */
|
|
314
|
+
listSystemFiles(fileType?: string, limit?: number, offset?: number): Promise<SystemFilesListResponse>;
|
|
315
|
+
/** Delete files via POST /system/files/delete. */
|
|
316
|
+
deleteSystemFiles(ids: string[]): Promise<DeleteSystemFilesResponse>;
|
|
255
317
|
/**
|
|
256
318
|
* Get a single resource by model and ID
|
|
257
319
|
*/
|
|
@@ -319,10 +381,10 @@ declare class TypedOperations {
|
|
|
319
381
|
/**
|
|
320
382
|
* Apito JavaScript internal SDK version (kept in sync with package.json for releases)
|
|
321
383
|
*/
|
|
322
|
-
declare const Version = "
|
|
384
|
+
declare const Version = "3.0.0";
|
|
323
385
|
/**
|
|
324
386
|
* GetVersion returns the current version of the SDK
|
|
325
387
|
*/
|
|
326
388
|
declare function getVersion(): string;
|
|
327
389
|
|
|
328
|
-
export { ApitoClient, ApitoError, type ClientConfig, type ConnectionOptions, type CreateAndUpdateRequest, type
|
|
390
|
+
export { ApitoClient, ApitoError, type ClientConfig, type ConnectionOptions, type CreateAndUpdateRequest, type CreateUserParams, type DefaultDocumentStructure, type DeleteSystemFilesResponse, type Filter, type GoogleOAuthStateResponse, GraphQLError, type GraphQLErrorLocation, type GraphQLResponse, type InjectedDBOperationInterface, type LoginUserParams, type LoginUserResponse, type MetaField, type ProjectStorageSettings, type RequestOptions, type SearchOptions, type SearchResult, type SystemFile, type SystemFileUploadParams, type SystemFilesListResponse, type TenantByDomainResponse, type TenantCatalogSearchRow, type TypedDocumentStructure, TypedOperations, type TypedSearchResult, type UpdateProjectStorageInput, type UpdateUserParams, type User, type UsersResponse, ValidationError, Version, createClient, ApitoClient as default, getVersion };
|
package/dist/index.d.ts
CHANGED
|
@@ -69,56 +69,97 @@ interface CreateAndUpdateRequest {
|
|
|
69
69
|
singlePageData?: boolean;
|
|
70
70
|
forceUpdate?: boolean;
|
|
71
71
|
}
|
|
72
|
-
/**
|
|
73
|
-
interface
|
|
72
|
+
/** Project end-user from engine system DB (table project_users). */
|
|
73
|
+
interface User {
|
|
74
74
|
id: string;
|
|
75
75
|
email?: string;
|
|
76
76
|
phone?: string;
|
|
77
77
|
role: string;
|
|
78
|
-
tenant_id
|
|
78
|
+
tenant_id?: string;
|
|
79
79
|
provider?: string;
|
|
80
80
|
status?: string;
|
|
81
81
|
created_at?: string;
|
|
82
82
|
updated_at?: string;
|
|
83
83
|
}
|
|
84
|
-
/** Login via system GraphQL `
|
|
85
|
-
interface
|
|
84
|
+
/** Login via system GraphQL `loginUser`. Password path: use `email` or `phone` per project settings. Google OAuth code path: `authMethod: 'google'`, `code`, `state` from redirect (get `state` first via `googleOAuthState`). */
|
|
85
|
+
interface LoginUserParams {
|
|
86
86
|
projectId: string;
|
|
87
|
-
/** Required for general (password) login. */
|
|
88
87
|
password?: string;
|
|
89
88
|
email?: string;
|
|
90
89
|
phone?: string;
|
|
91
|
-
/** `general` (default) or `google`. */
|
|
92
90
|
authMethod?: string;
|
|
93
|
-
/** Google authorization code (with `authMethod: 'google'`). */
|
|
94
91
|
code?: string;
|
|
95
|
-
/** OAuth state from `tenantGoogleOAuthState` or callback (with `authMethod: 'google'`). */
|
|
96
92
|
state?: string;
|
|
97
93
|
}
|
|
98
|
-
interface
|
|
94
|
+
interface GoogleOAuthStateResponse {
|
|
99
95
|
state: string;
|
|
100
96
|
}
|
|
101
|
-
interface
|
|
97
|
+
interface CreateUserParams {
|
|
102
98
|
password: string;
|
|
103
99
|
role?: string;
|
|
104
100
|
email?: string;
|
|
105
101
|
phone?: string;
|
|
106
102
|
}
|
|
107
|
-
/** Optional fields for `
|
|
108
|
-
interface
|
|
103
|
+
/** Optional fields for `updateUser`; omitted keys are not sent. */
|
|
104
|
+
interface UpdateUserParams {
|
|
109
105
|
email?: string;
|
|
110
106
|
phone?: string;
|
|
111
|
-
password?: string;
|
|
112
107
|
role?: string;
|
|
113
108
|
}
|
|
114
|
-
interface
|
|
109
|
+
interface LoginUserResponse {
|
|
115
110
|
token: string;
|
|
116
|
-
user?:
|
|
111
|
+
user?: User;
|
|
117
112
|
}
|
|
118
|
-
interface
|
|
119
|
-
users:
|
|
113
|
+
interface UsersResponse {
|
|
114
|
+
users: User[];
|
|
120
115
|
count: number;
|
|
121
116
|
}
|
|
117
|
+
interface ProjectStorageSettings {
|
|
118
|
+
use_free_cloud_storage: boolean;
|
|
119
|
+
endpoint?: string | null;
|
|
120
|
+
region?: string | null;
|
|
121
|
+
bucket?: string | null;
|
|
122
|
+
access_key_id?: string | null;
|
|
123
|
+
has_secret_access_key: boolean;
|
|
124
|
+
public_base_url?: string | null;
|
|
125
|
+
force_path_style?: boolean | null;
|
|
126
|
+
}
|
|
127
|
+
interface UpdateProjectStorageInput {
|
|
128
|
+
use_free_cloud_storage?: boolean;
|
|
129
|
+
endpoint?: string;
|
|
130
|
+
region?: string;
|
|
131
|
+
bucket?: string;
|
|
132
|
+
access_key_id?: string;
|
|
133
|
+
secret_access_key?: string;
|
|
134
|
+
public_base_url?: string;
|
|
135
|
+
force_path_style?: boolean;
|
|
136
|
+
}
|
|
137
|
+
interface SystemFile {
|
|
138
|
+
id: string;
|
|
139
|
+
file_type: string;
|
|
140
|
+
file_name: string;
|
|
141
|
+
file_extension?: string;
|
|
142
|
+
content_type?: string;
|
|
143
|
+
size: number;
|
|
144
|
+
url: string;
|
|
145
|
+
created_by?: string;
|
|
146
|
+
created_at?: string;
|
|
147
|
+
}
|
|
148
|
+
interface SystemFilesListResponse {
|
|
149
|
+
files: SystemFile[];
|
|
150
|
+
total: number;
|
|
151
|
+
}
|
|
152
|
+
interface SystemFileUploadParams {
|
|
153
|
+
fileName: string;
|
|
154
|
+
content: Uint8Array | ArrayBuffer;
|
|
155
|
+
fileType?: string;
|
|
156
|
+
}
|
|
157
|
+
interface DeleteSystemFilesResponse {
|
|
158
|
+
success: boolean;
|
|
159
|
+
deleted_ids: string[];
|
|
160
|
+
storage_failed?: string[];
|
|
161
|
+
message?: string;
|
|
162
|
+
}
|
|
122
163
|
/** One SaaS catalog tenant row from searchTenantsByDomain. */
|
|
123
164
|
interface TenantCatalogSearchRow {
|
|
124
165
|
id: string;
|
|
@@ -132,6 +173,8 @@ interface TenantByDomainResponse {
|
|
|
132
173
|
}
|
|
133
174
|
interface ClientConfig {
|
|
134
175
|
baseURL: string;
|
|
176
|
+
/** REST base (e.g. http://host:5050/system); derived from baseURL when omitted */
|
|
177
|
+
restBaseURL?: string;
|
|
135
178
|
apiKey: string;
|
|
136
179
|
timeout?: number;
|
|
137
180
|
httpClient?: any;
|
|
@@ -159,13 +202,19 @@ interface InjectedDBOperationInterface {
|
|
|
159
202
|
}): Promise<GraphQLResponse>;
|
|
160
203
|
/** @param token Legacy; ignored. Auth uses client API key. */
|
|
161
204
|
generateTenantToken(tenantId: string, duration?: string, role?: string): Promise<string>;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
205
|
+
loginUser(params: LoginUserParams): Promise<LoginUserResponse>;
|
|
206
|
+
googleOAuthState(projectId: string): Promise<GoogleOAuthStateResponse>;
|
|
207
|
+
searchUsers(projectId: string, limit?: number, offset?: number): Promise<UsersResponse>;
|
|
165
208
|
searchTenantsByDomain(projectId: string, domain: string): Promise<TenantByDomainResponse>;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
209
|
+
createUser(projectId: string, params: CreateUserParams): Promise<User>;
|
|
210
|
+
updateUser(userId: string, params: UpdateUserParams): Promise<User>;
|
|
211
|
+
resetUserPassword(userId: string, password: string): Promise<boolean>;
|
|
212
|
+
deleteUser(userId: string): Promise<boolean>;
|
|
213
|
+
getProjectStorageSettings(projectId: string): Promise<ProjectStorageSettings>;
|
|
214
|
+
updateProjectStorageSettings(input: UpdateProjectStorageInput): Promise<ProjectStorageSettings>;
|
|
215
|
+
uploadSystemFile(params: SystemFileUploadParams): Promise<SystemFile>;
|
|
216
|
+
listSystemFiles(fileType?: string, limit?: number, offset?: number): Promise<SystemFilesListResponse>;
|
|
217
|
+
deleteSystemFiles(ids: string[]): Promise<DeleteSystemFilesResponse>;
|
|
169
218
|
getSingleResource(model: string, id: string, singlePageData?: boolean): Promise<DefaultDocumentStructure>;
|
|
170
219
|
searchResources(model: string, filter?: Record<string, any>, aggregate?: boolean): Promise<SearchResult>;
|
|
171
220
|
getRelationDocuments(id: string, connection: Record<string, any>): Promise<SearchResult>;
|
|
@@ -203,6 +252,7 @@ declare class ValidationError extends ApitoError {
|
|
|
203
252
|
declare class ApitoClient implements InjectedDBOperationInterface {
|
|
204
253
|
private httpClient;
|
|
205
254
|
private baseURL;
|
|
255
|
+
private restBaseURL;
|
|
206
256
|
private apiKey;
|
|
207
257
|
private tenantId?;
|
|
208
258
|
constructor(config: ClientConfig);
|
|
@@ -222,36 +272,48 @@ declare class ApitoClient implements InjectedDBOperationInterface {
|
|
|
222
272
|
* @param role Optional token role; if omitted/empty, the engine defaults to `admin`.
|
|
223
273
|
*/
|
|
224
274
|
generateTenantToken(tenantId: string, duration?: string, role?: string): Promise<string>;
|
|
275
|
+
private authHeaders;
|
|
276
|
+
private executeREST;
|
|
225
277
|
/**
|
|
226
|
-
*
|
|
278
|
+
* Project user login (system GraphQL `loginUser`). Password path: pass `password` and `email` or `phone` per project Authentication settings. Google OAuth path: `authMethod: 'google'` with `code` and `state` from the redirect; call `googleOAuthState(projectId)` before opening Google to obtain `state`.
|
|
227
279
|
*/
|
|
228
|
-
|
|
280
|
+
loginUser(params: LoginUserParams): Promise<LoginUserResponse>;
|
|
229
281
|
/**
|
|
230
|
-
* Signed OAuth state for
|
|
282
|
+
* Signed OAuth state for Google login (system query `googleOAuthState`). Use in the authorize URL together with project `google_client_id` and the configured redirect URI.
|
|
231
283
|
*/
|
|
232
|
-
|
|
233
|
-
state: string;
|
|
234
|
-
}>;
|
|
284
|
+
googleOAuthState(projectId: string): Promise<GoogleOAuthStateResponse>;
|
|
235
285
|
/**
|
|
236
|
-
* Search
|
|
286
|
+
* Search project end-users.
|
|
237
287
|
*/
|
|
238
|
-
|
|
288
|
+
searchUsers(projectId: string, limit?: number, offset?: number): Promise<UsersResponse>;
|
|
239
289
|
/**
|
|
240
290
|
* Resolve the single SaaS catalog tenant for an exact domain match in the project (`tenant` null if none).
|
|
241
291
|
*/
|
|
242
292
|
searchTenantsByDomain(projectId: string, domain: string): Promise<TenantByDomainResponse>;
|
|
243
293
|
/**
|
|
244
|
-
* Create a
|
|
294
|
+
* Create a project user (local password). Use `email` and/or `phone` per engine validation for the project identifier mode.
|
|
245
295
|
*/
|
|
246
|
-
|
|
296
|
+
createUser(projectId: string, params: CreateUserParams): Promise<User>;
|
|
247
297
|
/**
|
|
248
|
-
* Update a
|
|
298
|
+
* Update a project user. Project scope is implied by the API key. Only include fields to change.
|
|
249
299
|
*/
|
|
250
|
-
|
|
300
|
+
updateUser(userId: string, params: UpdateUserParams): Promise<User>;
|
|
301
|
+
/** Set a new password for a project user (admin mutation resetUserPassword). */
|
|
302
|
+
resetUserPassword(userId: string, password: string): Promise<boolean>;
|
|
251
303
|
/**
|
|
252
|
-
* Delete a
|
|
304
|
+
* Delete a project user by id. Project scope is implied by the API key.
|
|
253
305
|
*/
|
|
254
|
-
|
|
306
|
+
deleteUser(userId: string): Promise<boolean>;
|
|
307
|
+
/** Read project storage settings via getProject. */
|
|
308
|
+
getProjectStorageSettings(projectId: string): Promise<ProjectStorageSettings>;
|
|
309
|
+
/** Persist project storage settings. */
|
|
310
|
+
updateProjectStorageSettings(input: UpdateProjectStorageInput): Promise<ProjectStorageSettings>;
|
|
311
|
+
/** Upload a file via POST /system/files/upload. */
|
|
312
|
+
uploadSystemFile(params: SystemFileUploadParams): Promise<SystemFile>;
|
|
313
|
+
/** List files via GET /system/files/list. */
|
|
314
|
+
listSystemFiles(fileType?: string, limit?: number, offset?: number): Promise<SystemFilesListResponse>;
|
|
315
|
+
/** Delete files via POST /system/files/delete. */
|
|
316
|
+
deleteSystemFiles(ids: string[]): Promise<DeleteSystemFilesResponse>;
|
|
255
317
|
/**
|
|
256
318
|
* Get a single resource by model and ID
|
|
257
319
|
*/
|
|
@@ -319,10 +381,10 @@ declare class TypedOperations {
|
|
|
319
381
|
/**
|
|
320
382
|
* Apito JavaScript internal SDK version (kept in sync with package.json for releases)
|
|
321
383
|
*/
|
|
322
|
-
declare const Version = "
|
|
384
|
+
declare const Version = "3.0.0";
|
|
323
385
|
/**
|
|
324
386
|
* GetVersion returns the current version of the SDK
|
|
325
387
|
*/
|
|
326
388
|
declare function getVersion(): string;
|
|
327
389
|
|
|
328
|
-
export { ApitoClient, ApitoError, type ClientConfig, type ConnectionOptions, type CreateAndUpdateRequest, type
|
|
390
|
+
export { ApitoClient, ApitoError, type ClientConfig, type ConnectionOptions, type CreateAndUpdateRequest, type CreateUserParams, type DefaultDocumentStructure, type DeleteSystemFilesResponse, type Filter, type GoogleOAuthStateResponse, GraphQLError, type GraphQLErrorLocation, type GraphQLResponse, type InjectedDBOperationInterface, type LoginUserParams, type LoginUserResponse, type MetaField, type ProjectStorageSettings, type RequestOptions, type SearchOptions, type SearchResult, type SystemFile, type SystemFileUploadParams, type SystemFilesListResponse, type TenantByDomainResponse, type TenantCatalogSearchRow, type TypedDocumentStructure, TypedOperations, type TypedSearchResult, type UpdateProjectStorageInput, type UpdateUserParams, type User, type UsersResponse, ValidationError, Version, createClient, ApitoClient as default, getVersion };
|