@xcitedbs/client 0.1.0 → 0.2.5
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 +2 -1
- package/dist/client.d.ts +47 -14
- package/dist/client.js +71 -16
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +37 -5
- package/llms-full.txt +1181 -0
- package/llms.txt +274 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -26,11 +26,12 @@ import { XCiteDBClient } from '@xcitedbs/client';
|
|
|
26
26
|
const client = new XCiteDBClient({
|
|
27
27
|
baseUrl: 'http://localhost:8080',
|
|
28
28
|
apiKey: process.env.XCITEDB_API_KEY,
|
|
29
|
-
context: { branch: '
|
|
29
|
+
context: { branch: '', date: '' },
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
await client.health();
|
|
33
33
|
const docs = await client.queryByIdentifier('/test1', 'FirstMatch');
|
|
34
|
+
await client.put('app.settings', { theme: 'dark' });
|
|
34
35
|
```
|
|
35
36
|
|
|
36
37
|
### WebSocket
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccessCheckResult, AppAuthConfig, AppEmailConfig, AppEmailTemplates, AppUser, AppUserTokenPair, EmailTestResponse, ForgotPasswordResponse, SendVerificationResponse, BranchInfo, CommitRecord, DatabaseContext, DiffRef, DiffResult, Flags, ListIdentifierChildrenResult, ListIdentifiersResult, LockInfo, LogEntry, MergeResult, PolicySubjectInput, PolicyUpdateResponse, RealtimeEvent, SecurityConfig, SecurityPolicy, StoredTriggerResponse, TriggerDefinition, StoredPolicyResponse, SubscriptionOptions, TagRecord, TextSearchQuery, TextSearchResult, OAuthProvidersResponse,
|
|
1
|
+
import { AccessCheckResult, AppAuthConfig, AppEmailConfig, AppEmailTemplates, AppUser, AppUserTokenPair, EmailTestResponse, ForgotPasswordResponse, SendVerificationResponse, BranchInfo, CommitRecord, DatabaseContext, DiffRef, DiffResult, Flags, ListIdentifierChildrenResult, ListIdentifiersResult, LockInfo, LogEntry, MergeResult, MetaValue, PlatformRegisterResult, PolicySubjectInput, UnqueryResult, PolicyUpdateResponse, RealtimeEvent, SecurityConfig, SecurityPolicy, StoredTriggerResponse, TriggerDefinition, StoredPolicyResponse, SubscriptionOptions, TagRecord, TextSearchQuery, TextSearchResult, OAuthProvidersResponse, ProjectInfo, PlatformRegistrationConfig, PlatformWorkspacesResponse, TokenPair, UserInfo, ApiKeyInfo, WriteDocumentOptions, XCiteDBClientOptions, XCiteQuery } from './types';
|
|
2
2
|
import { WebSocketSubscription } from './websocket';
|
|
3
3
|
export declare class XCiteDBClient {
|
|
4
4
|
private baseUrl;
|
|
@@ -48,8 +48,8 @@ export declare class XCiteDBClient {
|
|
|
48
48
|
api_version: string;
|
|
49
49
|
}>;
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
51
|
+
* @deprecated Use {@link platformLogin} for platform operator sign-in, or {@link loginAppUser} for app end-users.
|
|
52
|
+
* This method only performs platform console login.
|
|
53
53
|
*/
|
|
54
54
|
login(email: string, password: string): Promise<TokenPair>;
|
|
55
55
|
/** Platform console sign-in (`email` + `password`). Project context is `X-Project-Id`, not the JWT. */
|
|
@@ -67,14 +67,14 @@ export declare class XCiteDBClient {
|
|
|
67
67
|
org_name?: string;
|
|
68
68
|
org_id?: string;
|
|
69
69
|
attributes?: Record<string, unknown>;
|
|
70
|
-
}): Promise<
|
|
70
|
+
}): Promise<PlatformRegisterResult>;
|
|
71
71
|
platformWorkspaces(): Promise<PlatformWorkspacesResponse>;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
/** @deprecated Prefer {@link listMyProjects}. */
|
|
73
|
+
listMyTenants(): Promise<ProjectInfo[]>;
|
|
74
|
+
/** Lists projects the platform user can access (from workspaces). */
|
|
75
|
+
listMyProjects(): Promise<ProjectInfo[]>;
|
|
75
76
|
/**
|
|
76
|
-
*
|
|
77
|
-
* Legacy `/api/v1/auth/switch-tenant` has been removed; non-platform callers should set context instead.
|
|
77
|
+
* @deprecated Use {@link switchProject}. Platform console: updates `X-Project-Id` only (no token exchange).
|
|
78
78
|
*/
|
|
79
79
|
switchTenant(tenantId: string): Promise<void>;
|
|
80
80
|
/** Alias for {@link switchTenant}. */
|
|
@@ -165,8 +165,33 @@ export declare class XCiteDBClient {
|
|
|
165
165
|
message?: string;
|
|
166
166
|
autoResolve?: 'none' | 'source' | 'target';
|
|
167
167
|
}): Promise<MergeResult>;
|
|
168
|
-
/**
|
|
168
|
+
/**
|
|
169
|
+
* Create `branchName` from {@link options.fromBranch} (or current context branch), run `fn` scoped to that branch,
|
|
170
|
+
* create a commit, then merge back into the parent branch unless {@link options.autoMerge} is `false`.
|
|
171
|
+
* Restores previous {@link DatabaseContext} afterward.
|
|
172
|
+
*/
|
|
173
|
+
withBranch<T>(branchName: string, fn: (client: XCiteDBClient) => Promise<T>, options?: {
|
|
174
|
+
message?: string;
|
|
175
|
+
/** When true (default), merge `branchName` into the parent branch after commit. */
|
|
176
|
+
autoMerge?: boolean;
|
|
177
|
+
/** Branch to fork from (default: current `context.branch`, or `""`). */
|
|
178
|
+
fromBranch?: string;
|
|
179
|
+
author?: string;
|
|
180
|
+
}): Promise<{
|
|
181
|
+
result: T;
|
|
182
|
+
commit?: CommitRecord;
|
|
183
|
+
merge?: MergeResult;
|
|
184
|
+
}>;
|
|
185
|
+
/** Send raw XML body (`Content-Type: application/xml`). For JSON wrapper + options use `writeXmlDocument`. */
|
|
169
186
|
writeXML(xml: string, _options?: WriteDocumentOptions): Promise<void>;
|
|
187
|
+
/**
|
|
188
|
+
* Write an **XML** document using a JSON request body (`xml` field). The identifier is taken from `db:identifier` on the root element.
|
|
189
|
+
* For storing JSON data by key, use `writeJsonDocument`.
|
|
190
|
+
*/
|
|
191
|
+
writeXmlDocument(xml: string, options?: WriteDocumentOptions): Promise<void>;
|
|
192
|
+
/**
|
|
193
|
+
* @deprecated Use {@link writeXmlDocument}. This name was misleading: it writes **XML** via a JSON wrapper, not a JSON document.
|
|
194
|
+
*/
|
|
170
195
|
writeDocumentJson(xml: string, options?: WriteDocumentOptions): Promise<void>;
|
|
171
196
|
queryByIdentifier(identifier: string, flags?: Flags, filter?: string, pathFilter?: string): Promise<string[]>;
|
|
172
197
|
queryDocuments(query: XCiteQuery, flags?: Flags, filter?: string, pathFilter?: string): Promise<string[]>;
|
|
@@ -187,22 +212,30 @@ export declare class XCiteDBClient {
|
|
|
187
212
|
}): Promise<boolean>;
|
|
188
213
|
appendMeta(identifier: string, value: unknown, path?: string): Promise<boolean>;
|
|
189
214
|
appendMetaByQuery(query: XCiteQuery, value: unknown, path?: string, firstMatch?: boolean): Promise<boolean>;
|
|
190
|
-
queryMeta(identifier: string, path?: string): Promise<
|
|
191
|
-
queryMetaByQuery(query: XCiteQuery, path?: string): Promise<
|
|
215
|
+
queryMeta<T = MetaValue>(identifier: string, path?: string): Promise<T>;
|
|
216
|
+
queryMetaByQuery<T = MetaValue>(query: XCiteQuery, path?: string): Promise<T>;
|
|
192
217
|
clearMeta(query: XCiteQuery): Promise<boolean>;
|
|
193
218
|
acquireLock(identifier: string, expires?: number): Promise<LockInfo>;
|
|
194
219
|
releaseLock(identifier: string, lockId: string): Promise<boolean>;
|
|
195
220
|
findLocks(identifier: string): Promise<LockInfo[]>;
|
|
196
|
-
unquery(query: XCiteQuery, unquery: unknown): Promise<
|
|
221
|
+
unquery<T = UnqueryResult>(query: XCiteQuery, unquery: unknown): Promise<T>;
|
|
197
222
|
search(q: TextSearchQuery): Promise<TextSearchResult>;
|
|
198
223
|
reindex(): Promise<{
|
|
199
224
|
status: string;
|
|
200
225
|
message: string;
|
|
201
226
|
}>;
|
|
202
227
|
writeJsonDocument(identifier: string, data: unknown): Promise<void>;
|
|
203
|
-
readJsonDocument(identifier: string): Promise<
|
|
228
|
+
readJsonDocument<T = unknown>(identifier: string): Promise<T>;
|
|
204
229
|
deleteJsonDocument(identifier: string): Promise<void>;
|
|
205
230
|
listJsonDocuments(match?: string, limit?: number, offset?: number): Promise<ListIdentifiersResult>;
|
|
231
|
+
/** JSON document shorthand — same as {@link writeJsonDocument}. */
|
|
232
|
+
put(identifier: string, data: unknown): Promise<void>;
|
|
233
|
+
/** JSON document read — same as {@link readJsonDocument}. */
|
|
234
|
+
get<T = unknown>(identifier: string): Promise<T>;
|
|
235
|
+
/** JSON document delete — same as {@link deleteJsonDocument}. */
|
|
236
|
+
remove(identifier: string): Promise<void>;
|
|
237
|
+
/** List JSON document keys — same as {@link listJsonDocuments}. */
|
|
238
|
+
list(match?: string, limit?: number, offset?: number): Promise<ListIdentifiersResult>;
|
|
206
239
|
/**
|
|
207
240
|
* WebSocket `/api/v1/ws` — optional initial subscription pattern.
|
|
208
241
|
* Uses `access_token` or `api_key` query params when headers are not available (browser).
|
package/dist/client.js
CHANGED
|
@@ -101,11 +101,13 @@ class XCiteDBClient {
|
|
|
101
101
|
h['X-Date'] = c.date;
|
|
102
102
|
if (c.prefix)
|
|
103
103
|
h['X-Prefix'] = c.prefix;
|
|
104
|
+
if (c.unversioned)
|
|
105
|
+
h['X-Unversioned'] = 'true';
|
|
104
106
|
return h;
|
|
105
107
|
}
|
|
106
108
|
/** Include `tenant_id` for public app-auth routes when using only app-user tokens (no developer key/JWT). */
|
|
107
109
|
mergeAppTenant(body) {
|
|
108
|
-
const tid = this.defaultContext.tenant_id;
|
|
110
|
+
const tid = this.defaultContext.project_id ?? this.defaultContext.tenant_id;
|
|
109
111
|
if (tid)
|
|
110
112
|
return { ...body, tenant_id: tid };
|
|
111
113
|
return body;
|
|
@@ -214,8 +216,8 @@ class XCiteDBClient {
|
|
|
214
216
|
return this.request('GET', '/api/v1/version');
|
|
215
217
|
}
|
|
216
218
|
/**
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
+
* @deprecated Use {@link platformLogin} for platform operator sign-in, or {@link loginAppUser} for app end-users.
|
|
220
|
+
* This method only performs platform console login.
|
|
219
221
|
*/
|
|
220
222
|
async login(email, password) {
|
|
221
223
|
return this.platformLogin(email, password);
|
|
@@ -257,12 +259,19 @@ class XCiteDBClient {
|
|
|
257
259
|
async platformWorkspaces() {
|
|
258
260
|
return this.request('GET', '/api/v1/platform/auth/workspaces');
|
|
259
261
|
}
|
|
262
|
+
/** @deprecated Prefer {@link listMyProjects}. */
|
|
260
263
|
async listMyTenants() {
|
|
264
|
+
return this.listMyProjects();
|
|
265
|
+
}
|
|
266
|
+
/** Lists projects the platform user can access (from workspaces). */
|
|
267
|
+
async listMyProjects() {
|
|
261
268
|
const w = await this.platformWorkspaces();
|
|
262
269
|
const tenants = (w.projects ?? []).map((p) => {
|
|
263
270
|
const r = p;
|
|
271
|
+
const id = r.tenant_id || r.project_id || '';
|
|
264
272
|
return {
|
|
265
|
-
|
|
273
|
+
project_id: id,
|
|
274
|
+
tenant_id: id,
|
|
266
275
|
org_id: r.org_id,
|
|
267
276
|
name: r.name,
|
|
268
277
|
status: r.status,
|
|
@@ -277,13 +286,8 @@ class XCiteDBClient {
|
|
|
277
286
|
}
|
|
278
287
|
return tenants;
|
|
279
288
|
}
|
|
280
|
-
/** Alias for {@link listMyTenants} (organization/project terminology). */
|
|
281
|
-
async listMyProjects() {
|
|
282
|
-
return this.listMyTenants();
|
|
283
|
-
}
|
|
284
289
|
/**
|
|
285
|
-
*
|
|
286
|
-
* Legacy `/api/v1/auth/switch-tenant` has been removed; non-platform callers should set context instead.
|
|
290
|
+
* @deprecated Use {@link switchProject}. Platform console: updates `X-Project-Id` only (no token exchange).
|
|
287
291
|
*/
|
|
288
292
|
async switchTenant(tenantId) {
|
|
289
293
|
if (this.platformConsole) {
|
|
@@ -327,15 +331,14 @@ class XCiteDBClient {
|
|
|
327
331
|
return this.request('POST', '/api/v1/app/auth/register', this.mergeAppTenant(body));
|
|
328
332
|
}
|
|
329
333
|
async getOAuthProviders() {
|
|
330
|
-
const tid = this.defaultContext.tenant_id;
|
|
334
|
+
const tid = this.defaultContext.project_id ?? this.defaultContext.tenant_id;
|
|
331
335
|
const q = buildQuery({ tenant_id: tid && String(tid).length > 0 ? String(tid) : 'default' });
|
|
332
336
|
return this.request('GET', `/api/v1/app/auth/oauth/providers${q}`);
|
|
333
337
|
}
|
|
334
338
|
/** Relative path + query for browser navigation to start OAuth (append to API base URL). */
|
|
335
339
|
oauthAuthorizePath(provider) {
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
: 'default';
|
|
340
|
+
const raw = this.defaultContext.project_id ?? this.defaultContext.tenant_id;
|
|
341
|
+
const tid = raw && String(raw).length > 0 ? String(raw) : 'default';
|
|
339
342
|
return `/api/v1/app/auth/oauth/${encodeURIComponent(provider)}/authorize${buildQuery({ tenant_id: tid })}`;
|
|
340
343
|
}
|
|
341
344
|
/** Exchange one-time session code from OAuth browser redirect (public + tenant_id). */
|
|
@@ -591,19 +594,55 @@ class XCiteDBClient {
|
|
|
591
594
|
body.auto_resolve = options?.autoResolve ?? 'none';
|
|
592
595
|
return this.request('POST', `/api/v1/branches/${encodeURIComponent(targetBranch)}/merge`, body);
|
|
593
596
|
}
|
|
594
|
-
/**
|
|
597
|
+
/**
|
|
598
|
+
* Create `branchName` from {@link options.fromBranch} (or current context branch), run `fn` scoped to that branch,
|
|
599
|
+
* create a commit, then merge back into the parent branch unless {@link options.autoMerge} is `false`.
|
|
600
|
+
* Restores previous {@link DatabaseContext} afterward.
|
|
601
|
+
*/
|
|
602
|
+
async withBranch(branchName, fn, options) {
|
|
603
|
+
const prev = { ...this.defaultContext };
|
|
604
|
+
const fromBranch = options?.fromBranch ?? prev.branch ?? '';
|
|
605
|
+
let commit;
|
|
606
|
+
let merge;
|
|
607
|
+
try {
|
|
608
|
+
await this.createBranch(branchName, fromBranch || undefined, prev.date || undefined);
|
|
609
|
+
this.setContext({ branch: branchName });
|
|
610
|
+
const result = await fn(this);
|
|
611
|
+
commit = await this.createCommit(options?.message ?? `Branch ${branchName}`, options?.author);
|
|
612
|
+
if (options?.autoMerge !== false) {
|
|
613
|
+
merge = await this.mergeBranch(fromBranch, branchName, {
|
|
614
|
+
message: options?.message,
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
return { result, commit, merge };
|
|
618
|
+
}
|
|
619
|
+
finally {
|
|
620
|
+
this.setContext(prev);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
/** Send raw XML body (`Content-Type: application/xml`). For JSON wrapper + options use `writeXmlDocument`. */
|
|
595
624
|
async writeXML(xml, _options) {
|
|
596
625
|
await this.request('POST', '/api/v1/documents', xml, {
|
|
597
626
|
'Content-Type': 'application/xml',
|
|
598
627
|
});
|
|
599
628
|
}
|
|
600
|
-
|
|
629
|
+
/**
|
|
630
|
+
* Write an **XML** document using a JSON request body (`xml` field). The identifier is taken from `db:identifier` on the root element.
|
|
631
|
+
* For storing JSON data by key, use `writeJsonDocument`.
|
|
632
|
+
*/
|
|
633
|
+
async writeXmlDocument(xml, options) {
|
|
601
634
|
await this.request('POST', '/api/v1/documents', {
|
|
602
635
|
xml,
|
|
603
636
|
is_top: options?.is_top ?? true,
|
|
604
637
|
compare_attributes: options?.compare_attributes ?? false,
|
|
605
638
|
});
|
|
606
639
|
}
|
|
640
|
+
/**
|
|
641
|
+
* @deprecated Use {@link writeXmlDocument}. This name was misleading: it writes **XML** via a JSON wrapper, not a JSON document.
|
|
642
|
+
*/
|
|
643
|
+
async writeDocumentJson(xml, options) {
|
|
644
|
+
return this.writeXmlDocument(xml, options);
|
|
645
|
+
}
|
|
607
646
|
async queryByIdentifier(identifier, flags, filter, pathFilter) {
|
|
608
647
|
const q = buildQuery({
|
|
609
648
|
identifier,
|
|
@@ -865,6 +904,22 @@ class XCiteDBClient {
|
|
|
865
904
|
}
|
|
866
905
|
return { identifiers: [], total: 0, offset: 0, limit: 0 };
|
|
867
906
|
}
|
|
907
|
+
/** JSON document shorthand — same as {@link writeJsonDocument}. */
|
|
908
|
+
async put(identifier, data) {
|
|
909
|
+
return this.writeJsonDocument(identifier, data);
|
|
910
|
+
}
|
|
911
|
+
/** JSON document read — same as {@link readJsonDocument}. */
|
|
912
|
+
async get(identifier) {
|
|
913
|
+
return this.readJsonDocument(identifier);
|
|
914
|
+
}
|
|
915
|
+
/** JSON document delete — same as {@link deleteJsonDocument}. */
|
|
916
|
+
async remove(identifier) {
|
|
917
|
+
return this.deleteJsonDocument(identifier);
|
|
918
|
+
}
|
|
919
|
+
/** List JSON document keys — same as {@link listJsonDocuments}. */
|
|
920
|
+
async list(match, limit, offset) {
|
|
921
|
+
return this.listJsonDocuments(match, limit, offset);
|
|
922
|
+
}
|
|
868
923
|
/**
|
|
869
924
|
* WebSocket `/api/v1/ws` — optional initial subscription pattern.
|
|
870
925
|
* Uses `access_token` or `api_key` query params when headers are not available (browser).
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { XCiteDBClient } from './client';
|
|
2
2
|
export { WebSocketSubscription } from './websocket';
|
|
3
|
-
export type { AccessCheckResult, ApiKeyInfo, AppAuthConfig, AppEmailConfig, AppEmailSmtpConfig, AppEmailTemplateEntry, AppEmailTemplates, AppEmailWebhookConfig, AppUser, AppUserTokenPair, EmailTestResponse, ForgotPasswordResponse, SendVerificationResponse, DatabaseContext, Flags, IdentifierChildNode, ListIdentifierChildrenResult, ListIdentifiersResult, LockInfo, OAuthProviderInfo, OAuthProvidersResponse, OwnedTenantInfo, PlatformRegistrationConfig, PlatformWorkspaceOrg, PlatformWorkspacesResponse, LogEntry, PolicyUpdateResponse, PolicyConditions, PolicyIdentifierPattern, PolicyResources, PolicySubjectInput, PolicySubjects, RealtimeEvent, SecurityConfig, SecurityPolicy, StoredPolicyResponse, StoredTriggerResponse, SubscriptionOptions, TextSearchHit, TextSearchQuery, TextSearchResult, TriggerDefinition, TokenPair, UserInfo, WriteDocumentOptions, XCiteDBClientOptions, XCiteQuery, } from './types';
|
|
3
|
+
export type { AccessCheckResult, ApiKeyInfo, AppAuthConfig, AppEmailConfig, AppEmailSmtpConfig, AppEmailTemplateEntry, AppEmailTemplates, AppEmailWebhookConfig, AppUser, AppUserTokenPair, EmailTestResponse, ForgotPasswordResponse, SendVerificationResponse, DatabaseContext, Flags, JsonDocumentData, IdentifierChildNode, ListIdentifierChildrenResult, ListIdentifiersResult, LockInfo, OAuthProviderInfo, OAuthProvidersResponse, OwnedTenantInfo, ProjectInfo, PlatformRegistrationConfig, PlatformWorkspaceOrg, PlatformWorkspacesResponse, LogEntry, MetaValue, PlatformRegisterResult, PolicyUpdateResponse, PolicyConditions, PolicyIdentifierPattern, PolicyResources, PolicySubjectInput, PolicySubjects, RealtimeEvent, SecurityConfig, SecurityPolicy, StoredPolicyResponse, StoredTriggerResponse, SubscriptionOptions, TextSearchHit, TextSearchQuery, TextSearchResult, TriggerDefinition, TokenPair, UserInfo, WriteDocumentOptions, XCiteDBClientOptions, UnqueryResult, XCiteQuery, } from './types';
|
|
4
4
|
export { XCiteDBError } from './types';
|
package/dist/types.d.ts
CHANGED
|
@@ -14,6 +14,19 @@ export interface XCiteQuery {
|
|
|
14
14
|
/** Skip this many rows (for pagination). */
|
|
15
15
|
offset?: number;
|
|
16
16
|
}
|
|
17
|
+
/** Root object returned by `readJsonDocument` (use generics for app-specific shapes). */
|
|
18
|
+
export type JsonDocumentData = Record<string, unknown>;
|
|
19
|
+
/** JSON metadata from meta APIs (structure is document-specific). */
|
|
20
|
+
export type MetaValue = unknown;
|
|
21
|
+
/** Result of `unquery` (shape depends on the unquery definition). */
|
|
22
|
+
export type UnqueryResult = unknown;
|
|
23
|
+
/** Typical `POST /api/v1/platform/auth/register` response (fields vary by registration policy). */
|
|
24
|
+
export interface PlatformRegisterResult {
|
|
25
|
+
user_id?: string;
|
|
26
|
+
status?: string;
|
|
27
|
+
message?: string;
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
}
|
|
17
30
|
/** Full-text search (`POST /api/v1/search`) */
|
|
18
31
|
export interface TextSearchQuery {
|
|
19
32
|
query: string;
|
|
@@ -77,8 +90,14 @@ export interface TokenPair {
|
|
|
77
90
|
refresh_token: string;
|
|
78
91
|
expires_in: number;
|
|
79
92
|
}
|
|
80
|
-
/**
|
|
81
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Project row from `GET /api/v1/platform/auth/workspaces` and related APIs.
|
|
95
|
+
* The server often labels the id as `tenant_id`; both fields are set when mapped by the SDK.
|
|
96
|
+
*/
|
|
97
|
+
export interface ProjectInfo {
|
|
98
|
+
/** Project id (wire alias: `tenant_id` in many JSON bodies). */
|
|
99
|
+
project_id: string;
|
|
100
|
+
/** Same id as `project_id` (legacy / wire field name). */
|
|
82
101
|
tenant_id: string;
|
|
83
102
|
org_id?: string;
|
|
84
103
|
name: string;
|
|
@@ -88,6 +107,8 @@ export interface OwnedTenantInfo {
|
|
|
88
107
|
config?: unknown;
|
|
89
108
|
owner_user_id?: string;
|
|
90
109
|
}
|
|
110
|
+
/** @deprecated Use {@link ProjectInfo}. */
|
|
111
|
+
export type OwnedTenantInfo = ProjectInfo;
|
|
91
112
|
export interface UserInfo {
|
|
92
113
|
user_id: string;
|
|
93
114
|
username: string;
|
|
@@ -117,7 +138,7 @@ export interface PlatformWorkspaceOrg {
|
|
|
117
138
|
}
|
|
118
139
|
export interface PlatformWorkspacesResponse {
|
|
119
140
|
orgs: PlatformWorkspaceOrg[];
|
|
120
|
-
projects:
|
|
141
|
+
projects: ProjectInfo[];
|
|
121
142
|
}
|
|
122
143
|
/** One row from `GET /api/v1/project/keys` (secret is never returned). */
|
|
123
144
|
export interface ApiKeyInfo {
|
|
@@ -127,13 +148,24 @@ export interface ApiKeyInfo {
|
|
|
127
148
|
expires_at: number;
|
|
128
149
|
/** `secret` = server-side full access; `public` = client-safe, restricted. */
|
|
129
150
|
key_type?: 'secret' | 'public';
|
|
151
|
+
/** Project id this key belongs to. */
|
|
152
|
+
tenant_id?: string;
|
|
130
153
|
}
|
|
131
154
|
export type Flags = 'None' | 'FirstMatch' | 'IncludeChildren' | 'NoChildren' | 'KeepIndexNodes' | 'PrevIfDeleted' | string;
|
|
132
155
|
export interface DatabaseContext {
|
|
133
156
|
branch?: string;
|
|
134
157
|
date?: string;
|
|
135
158
|
prefix?: string;
|
|
136
|
-
/**
|
|
159
|
+
/**
|
|
160
|
+
* When true, sends `X-Unversioned: true` so writes use flat LMDB keys (no date revision).
|
|
161
|
+
* Do not combine with `date`; the server returns 400 if both are set.
|
|
162
|
+
*/
|
|
163
|
+
unversioned?: boolean;
|
|
164
|
+
/** Preferred: project id; sent as `tenant_id` in app-user public auth bodies when no developer token is used. */
|
|
165
|
+
project_id?: string;
|
|
166
|
+
/**
|
|
167
|
+
* @deprecated Use {@link DatabaseContext.project_id} (same JSON field name on the wire: `tenant_id`).
|
|
168
|
+
*/
|
|
137
169
|
tenant_id?: string;
|
|
138
170
|
}
|
|
139
171
|
export interface WriteDocumentOptions {
|
|
@@ -162,7 +194,7 @@ export interface XCiteDBClientOptions {
|
|
|
162
194
|
context?: DatabaseContext;
|
|
163
195
|
/** When true, sends `X-Project-Id` for console requests; developer JWTs are always platform tokens. */
|
|
164
196
|
platformConsole?: boolean;
|
|
165
|
-
/** Active project id for platform console requests (`X-Project-Id` header). */
|
|
197
|
+
/** Active project id for platform console requests (`X-Project-Id` header). Alias of {@link DatabaseContext.project_id} for console mode. */
|
|
166
198
|
projectId?: string;
|
|
167
199
|
/** Persist developer session tokens after refresh (e.g. localStorage). */
|
|
168
200
|
onSessionTokensUpdated?: (pair: TokenPair) => void;
|