@xcitedbs/client 0.2.12 → 0.2.14
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/dist/client.d.ts +25 -8
- package/dist/client.js +76 -13
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +36 -4
- package/llms-full.txt +35 -9
- package/llms.txt +9 -3
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccessCheckResult, AppAuthConfig, AppEmailConfig, AppEmailTemplates, AppUser, AppUserTokenPair, EmailTestResponse, ForgotPasswordResponse, SendVerificationResponse, BranchInfo, BookmarkRecord, CheckpointRecord, CommitRecord, CompareRef, CompareResult, DatabaseContext, DiffRef, DiffResult, Flags, ListIdentifierChildrenResult, ListIdentifiersResult, LockInfo, LogEntry, MergeResult, PublishResult, WorkspaceInfo, MetaValue, PlatformRegisterResult, PolicySubjectInput, UnqueryResult, UnqueryTemplate, PolicyUpdateResponse, RealtimeEvent, SecurityConfig, SecurityPolicy, StoredTriggerResponse, TriggerDefinition, StoredPolicyResponse, SubscriptionOptions, TagRecord, TextSearchQuery, TextSearchResult, ProjectSearchSettings, ProjectSearchSettingsUpdate, ProjectDocConfResponse, PlatformDefaultDocConfResponse, VectorIndexEstimate, RagQueryOptions, RagQueryResult, RagStreamEvent, OAuthProvidersResponse, ProjectInfo, PlatformRegistrationConfig, PlatformWorkspacesResponse, TokenPair, UserInfo, ApiKeyInfo, WriteDocumentOptions, CreateTestSessionOptions, XCiteDBClientOptions, XCiteDBJwtClaims, XCiteQuery, UserIsolationConfig } from './types';
|
|
1
|
+
import { AccessCheckResult, AppAuthConfig, AppEmailConfig, AppEmailTemplates, AppUser, AppUserTokenPair, EmailTestResponse, ForgotPasswordResponse, SendVerificationResponse, BranchInfo, BookmarkRecord, CheckpointRecord, CommitRecord, CompareRef, CompareResult, DatabaseContext, DiffRef, DiffResult, DocumentBatchResponse, Flags, JsonDocumentBatchItem, ListIdentifierChildrenResult, ListIdentifiersResult, LockInfo, LogEntry, MergeResult, PublishResult, WorkspaceInfo, MetaValue, PlatformRegisterResult, PolicySubjectInput, UnqueryResult, UnqueryTemplate, PolicyUpdateResponse, RealtimeEvent, SecurityConfig, SecurityPolicy, StoredTriggerResponse, TriggerDefinition, StoredPolicyResponse, SubscriptionOptions, TagRecord, TextSearchQuery, TextSearchResult, ProjectSearchSettings, ProjectSearchSettingsUpdate, ProjectDocConfResponse, PlatformDefaultDocConfResponse, VectorIndexEstimate, RagQueryOptions, RagQueryResult, RagStreamEvent, OAuthProvidersResponse, ProjectInfo, PlatformRegistrationConfig, PlatformWorkspacesResponse, TokenPair, UserInfo, ApiKeyInfo, WriteDocumentOptions, XmlDocumentBatchItem, CreateTestSessionOptions, XCiteDBClientOptions, XCiteDBJwtClaims, XCiteQuery, UserIsolationConfig } from './types';
|
|
2
2
|
import { WebSocketSubscription } from './websocket';
|
|
3
3
|
export declare class XCiteDBClient {
|
|
4
4
|
private baseUrl;
|
|
@@ -248,7 +248,7 @@ export declare class XCiteDBClient {
|
|
|
248
248
|
deleteTrigger(name: string): Promise<void>;
|
|
249
249
|
/**
|
|
250
250
|
* Dry-run access check (`POST /api/v1/security/check`). Returns `effect` and optional `matched_policy_id`.
|
|
251
|
-
* Useful for debugging policies. Actions: `read`, `write`, `delete`, `list`, `
|
|
251
|
+
* Useful for debugging policies. Actions: `read`, `write`, `delete`, `list`, `unquery`.
|
|
252
252
|
*
|
|
253
253
|
* @example
|
|
254
254
|
* ```ts
|
|
@@ -263,13 +263,12 @@ export declare class XCiteDBClient {
|
|
|
263
263
|
* },
|
|
264
264
|
* '/acme/reports/q1',
|
|
265
265
|
* 'read',
|
|
266
|
-
* undefined,
|
|
267
266
|
* 'main'
|
|
268
267
|
* );
|
|
269
268
|
* console.log(r.effect, r.matched_policy_id);
|
|
270
269
|
* ```
|
|
271
270
|
*/
|
|
272
|
-
checkAccess(subject: PolicySubjectInput, identifier: string, action: string,
|
|
271
|
+
checkAccess(subject: PolicySubjectInput, identifier: string, action: string, branch?: string): Promise<AccessCheckResult>;
|
|
273
272
|
getSecurityConfig(): Promise<SecurityConfig>;
|
|
274
273
|
/**
|
|
275
274
|
* Update tenant security defaults (`PUT /api/v1/security/config`). When ABAC is enabled, pair
|
|
@@ -419,6 +418,10 @@ export declare class XCiteDBClient {
|
|
|
419
418
|
* For storing JSON data by key, use `writeJsonDocument`.
|
|
420
419
|
*/
|
|
421
420
|
writeXmlDocument(xml: string, options?: WriteDocumentOptions): Promise<void>;
|
|
421
|
+
/**
|
|
422
|
+
* Best-effort batch XML writes (`POST /api/v1/documents/batch`). Each item is independent; check `results[].ok`.
|
|
423
|
+
*/
|
|
424
|
+
writeXmlDocumentsBatch(items: XmlDocumentBatchItem[]): Promise<DocumentBatchResponse>;
|
|
422
425
|
/**
|
|
423
426
|
* @deprecated Use {@link writeXmlDocument}. This name was misleading: it writes **XML** via a JSON wrapper, not a JSON document.
|
|
424
427
|
*/
|
|
@@ -436,12 +439,18 @@ export declare class XCiteDBClient {
|
|
|
436
439
|
queryLog(query: XCiteQuery, fromDate: string, toDate: string): Promise<LogEntry[]>;
|
|
437
440
|
addMeta(identifier: string, value: unknown, path?: string, opts?: {
|
|
438
441
|
mode?: 'set' | 'append';
|
|
442
|
+
overwrite?: boolean;
|
|
439
443
|
}): Promise<boolean>;
|
|
440
444
|
addMetaByQuery(query: XCiteQuery, value: unknown, path?: string, firstMatch?: boolean, opts?: {
|
|
441
445
|
mode?: 'set' | 'append';
|
|
446
|
+
overwrite?: boolean;
|
|
447
|
+
}): Promise<boolean>;
|
|
448
|
+
appendMeta(identifier: string, value: unknown, path?: string, opts?: {
|
|
449
|
+
overwrite?: boolean;
|
|
450
|
+
}): Promise<boolean>;
|
|
451
|
+
appendMetaByQuery(query: XCiteQuery, value: unknown, path?: string, firstMatch?: boolean, opts?: {
|
|
452
|
+
overwrite?: boolean;
|
|
442
453
|
}): Promise<boolean>;
|
|
443
|
-
appendMeta(identifier: string, value: unknown, path?: string): Promise<boolean>;
|
|
444
|
-
appendMetaByQuery(query: XCiteQuery, value: unknown, path?: string, firstMatch?: boolean): Promise<boolean>;
|
|
445
454
|
queryMeta<T = MetaValue>(identifier: string, path?: string): Promise<T>;
|
|
446
455
|
queryMetaByQuery<T = MetaValue>(query: XCiteQuery, path?: string): Promise<T>;
|
|
447
456
|
clearMeta(query: XCiteQuery): Promise<boolean>;
|
|
@@ -517,12 +526,20 @@ export declare class XCiteDBClient {
|
|
|
517
526
|
* The final event has `done: true` and may include `sources`.
|
|
518
527
|
*/
|
|
519
528
|
ragQueryStream(options: Omit<RagQueryOptions, 'stream'>, onEvent: (ev: RagStreamEvent) => void): Promise<void>;
|
|
520
|
-
writeJsonDocument(identifier: string, data: unknown
|
|
529
|
+
writeJsonDocument(identifier: string, data: unknown, opts?: {
|
|
530
|
+
overwrite?: boolean;
|
|
531
|
+
}): Promise<void>;
|
|
532
|
+
/**
|
|
533
|
+
* Best-effort batch JSON document writes (`POST /api/v1/json-documents/batch`). Each item is independent; check `results[].ok`.
|
|
534
|
+
*/
|
|
535
|
+
writeJsonDocumentsBatch(items: JsonDocumentBatchItem[]): Promise<DocumentBatchResponse>;
|
|
521
536
|
readJsonDocument<T = unknown>(identifier: string): Promise<T>;
|
|
522
537
|
deleteJsonDocument(identifier: string): Promise<void>;
|
|
523
538
|
listJsonDocuments(match?: string, limit?: number, offset?: number): Promise<ListIdentifiersResult>;
|
|
524
539
|
/** JSON document shorthand — same as {@link writeJsonDocument}. */
|
|
525
|
-
put(identifier: string, data: unknown
|
|
540
|
+
put(identifier: string, data: unknown, opts?: {
|
|
541
|
+
overwrite?: boolean;
|
|
542
|
+
}): Promise<void>;
|
|
526
543
|
/** JSON document read — same as {@link readJsonDocument}. */
|
|
527
544
|
get<T = unknown>(identifier: string): Promise<T>;
|
|
528
545
|
/** JSON document delete — same as {@link deleteJsonDocument}. */
|
package/dist/client.js
CHANGED
|
@@ -900,7 +900,7 @@ class XCiteDBClient {
|
|
|
900
900
|
}
|
|
901
901
|
/**
|
|
902
902
|
* Dry-run access check (`POST /api/v1/security/check`). Returns `effect` and optional `matched_policy_id`.
|
|
903
|
-
* Useful for debugging policies. Actions: `read`, `write`, `delete`, `list`, `
|
|
903
|
+
* Useful for debugging policies. Actions: `read`, `write`, `delete`, `list`, `unquery`.
|
|
904
904
|
*
|
|
905
905
|
* @example
|
|
906
906
|
* ```ts
|
|
@@ -915,16 +915,13 @@ class XCiteDBClient {
|
|
|
915
915
|
* },
|
|
916
916
|
* '/acme/reports/q1',
|
|
917
917
|
* 'read',
|
|
918
|
-
* undefined,
|
|
919
918
|
* 'main'
|
|
920
919
|
* );
|
|
921
920
|
* console.log(r.effect, r.matched_policy_id);
|
|
922
921
|
* ```
|
|
923
922
|
*/
|
|
924
|
-
async checkAccess(subject, identifier, action,
|
|
923
|
+
async checkAccess(subject, identifier, action, branch) {
|
|
925
924
|
const body = { subject, identifier: this.isoPrefixId(identifier), action };
|
|
926
|
-
if (metaPath !== undefined)
|
|
927
|
-
body.meta_path = metaPath;
|
|
928
925
|
if (branch !== undefined)
|
|
929
926
|
body.branch = branch;
|
|
930
927
|
return this.request('POST', '/api/v1/security/check', body);
|
|
@@ -1193,6 +1190,32 @@ class XCiteDBClient {
|
|
|
1193
1190
|
compare_attributes: options?.compare_attributes ?? false,
|
|
1194
1191
|
});
|
|
1195
1192
|
}
|
|
1193
|
+
/**
|
|
1194
|
+
* Best-effort batch XML writes (`POST /api/v1/documents/batch`). Each item is independent; check `results[].ok`.
|
|
1195
|
+
*/
|
|
1196
|
+
async writeXmlDocumentsBatch(items) {
|
|
1197
|
+
const body = {
|
|
1198
|
+
items: items.map((it) => {
|
|
1199
|
+
const row = {
|
|
1200
|
+
xml: this.isoApplyXmlDbIdentifier(it.xml),
|
|
1201
|
+
is_top: it.is_top ?? true,
|
|
1202
|
+
compare_attributes: it.compare_attributes ?? false,
|
|
1203
|
+
};
|
|
1204
|
+
if (it.identifier !== undefined && it.identifier !== '') {
|
|
1205
|
+
row.identifier = this.isoPrefixId(it.identifier);
|
|
1206
|
+
}
|
|
1207
|
+
return row;
|
|
1208
|
+
}),
|
|
1209
|
+
};
|
|
1210
|
+
const r = await this.request('POST', '/api/v1/documents/batch', body);
|
|
1211
|
+
if (r?.results) {
|
|
1212
|
+
for (const row of r.results) {
|
|
1213
|
+
if (row.identifier)
|
|
1214
|
+
row.identifier = this.isoUnprefixId(String(row.identifier));
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
return r;
|
|
1218
|
+
}
|
|
1196
1219
|
/**
|
|
1197
1220
|
* @deprecated Use {@link writeXmlDocument}. This name was misleading: it writes **XML** via a JSON wrapper, not a JSON document.
|
|
1198
1221
|
*/
|
|
@@ -1352,6 +1375,8 @@ class XCiteDBClient {
|
|
|
1352
1375
|
const body = { identifier: this.isoPrefixId(identifier), value, path };
|
|
1353
1376
|
if (opts?.mode === 'append')
|
|
1354
1377
|
body.mode = 'append';
|
|
1378
|
+
if (opts?.overwrite)
|
|
1379
|
+
body.overwrite = true;
|
|
1355
1380
|
const r = await this.request('POST', '/api/v1/meta', body);
|
|
1356
1381
|
return r?.ok !== false;
|
|
1357
1382
|
}
|
|
@@ -1364,14 +1389,16 @@ class XCiteDBClient {
|
|
|
1364
1389
|
};
|
|
1365
1390
|
if (opts?.mode === 'append')
|
|
1366
1391
|
body.mode = 'append';
|
|
1392
|
+
if (opts?.overwrite)
|
|
1393
|
+
body.overwrite = true;
|
|
1367
1394
|
const r = await this.request('POST', '/api/v1/meta', body);
|
|
1368
1395
|
return r?.ok !== false;
|
|
1369
1396
|
}
|
|
1370
|
-
async appendMeta(identifier, value, path = '') {
|
|
1371
|
-
return this.addMeta(identifier, value, path, { mode: 'append' });
|
|
1397
|
+
async appendMeta(identifier, value, path = '', opts) {
|
|
1398
|
+
return this.addMeta(identifier, value, path, { mode: 'append', ...opts });
|
|
1372
1399
|
}
|
|
1373
|
-
async appendMetaByQuery(query, value, path = '', firstMatch = false) {
|
|
1374
|
-
return this.addMetaByQuery(query, value, path, firstMatch, { mode: 'append' });
|
|
1400
|
+
async appendMetaByQuery(query, value, path = '', firstMatch = false, opts) {
|
|
1401
|
+
return this.addMetaByQuery(query, value, path, firstMatch, { mode: 'append', ...opts });
|
|
1375
1402
|
}
|
|
1376
1403
|
async queryMeta(identifier, path = '') {
|
|
1377
1404
|
return this.request('GET', `/api/v1/meta${buildQuery({ identifier: this.isoPrefixId(identifier), path })}`);
|
|
@@ -1558,6 +1585,12 @@ class XCiteDBClient {
|
|
|
1558
1585
|
body.min_score = options.min_score;
|
|
1559
1586
|
if (options.semantic_weight !== undefined)
|
|
1560
1587
|
body.semantic_weight = options.semantic_weight;
|
|
1588
|
+
if (options.temperature !== undefined)
|
|
1589
|
+
body.temperature = options.temperature;
|
|
1590
|
+
if (options.max_tokens !== undefined)
|
|
1591
|
+
body.max_tokens = options.max_tokens;
|
|
1592
|
+
if (options.messages?.length)
|
|
1593
|
+
body.messages = options.messages;
|
|
1561
1594
|
const data = await this.request('POST', '/api/v1/rag/query', body);
|
|
1562
1595
|
if (!data || typeof data !== 'object') {
|
|
1563
1596
|
throw new types_1.XCiteDBError('Invalid RAG response', 500, data);
|
|
@@ -1581,6 +1614,9 @@ class XCiteDBClient {
|
|
|
1581
1614
|
...(options.search_mode !== undefined ? { search_mode: options.search_mode } : {}),
|
|
1582
1615
|
...(options.min_score !== undefined ? { min_score: options.min_score } : {}),
|
|
1583
1616
|
...(options.semantic_weight !== undefined ? { semantic_weight: options.semantic_weight } : {}),
|
|
1617
|
+
...(options.temperature !== undefined ? { temperature: options.temperature } : {}),
|
|
1618
|
+
...(options.max_tokens !== undefined ? { max_tokens: options.max_tokens } : {}),
|
|
1619
|
+
...(options.messages?.length ? { messages: options.messages } : {}),
|
|
1584
1620
|
});
|
|
1585
1621
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
1586
1622
|
const url = joinUrl(this.baseUrl, path);
|
|
@@ -1654,8 +1690,35 @@ class XCiteDBClient {
|
|
|
1654
1690
|
}
|
|
1655
1691
|
throw new types_1.XCiteDBError('RAG stream failed after retry', 401, null);
|
|
1656
1692
|
}
|
|
1657
|
-
async writeJsonDocument(identifier, data) {
|
|
1658
|
-
|
|
1693
|
+
async writeJsonDocument(identifier, data, opts) {
|
|
1694
|
+
const body = { identifier: this.isoPrefixId(identifier), data };
|
|
1695
|
+
if (opts?.overwrite)
|
|
1696
|
+
body.overwrite = true;
|
|
1697
|
+
await this.request('POST', '/api/v1/json-documents', body);
|
|
1698
|
+
}
|
|
1699
|
+
/**
|
|
1700
|
+
* Best-effort batch JSON document writes (`POST /api/v1/json-documents/batch`). Each item is independent; check `results[].ok`.
|
|
1701
|
+
*/
|
|
1702
|
+
async writeJsonDocumentsBatch(items) {
|
|
1703
|
+
const body = {
|
|
1704
|
+
items: items.map((it) => {
|
|
1705
|
+
const row = {
|
|
1706
|
+
identifier: this.isoPrefixId(it.identifier),
|
|
1707
|
+
data: it.data,
|
|
1708
|
+
};
|
|
1709
|
+
if (it.overwrite)
|
|
1710
|
+
row.overwrite = true;
|
|
1711
|
+
return row;
|
|
1712
|
+
}),
|
|
1713
|
+
};
|
|
1714
|
+
const r = await this.request('POST', '/api/v1/json-documents/batch', body);
|
|
1715
|
+
if (r?.results) {
|
|
1716
|
+
for (const row of r.results) {
|
|
1717
|
+
if (row.identifier)
|
|
1718
|
+
row.identifier = this.isoUnprefixId(String(row.identifier));
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
return r;
|
|
1659
1722
|
}
|
|
1660
1723
|
async readJsonDocument(identifier) {
|
|
1661
1724
|
return this.request('GET', `/api/v1/json-documents${buildQuery({ identifier: this.isoPrefixId(identifier) })}`);
|
|
@@ -1684,8 +1747,8 @@ class XCiteDBClient {
|
|
|
1684
1747
|
return { identifiers: [], total: 0, offset: 0, limit: 0 };
|
|
1685
1748
|
}
|
|
1686
1749
|
/** JSON document shorthand — same as {@link writeJsonDocument}. */
|
|
1687
|
-
async put(identifier, data) {
|
|
1688
|
-
return this.writeJsonDocument(identifier, data);
|
|
1750
|
+
async put(identifier, data, opts) {
|
|
1751
|
+
return this.writeJsonDocument(identifier, data, opts);
|
|
1689
1752
|
}
|
|
1690
1753
|
/** JSON document read — same as {@link readJsonDocument}. */
|
|
1691
1754
|
async get(identifier) {
|
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, BookmarkRecord, BranchInfo, BranchListItem, CheckpointRecord, CommitRecord, CompareEntry, CompareRef, CompareResult, DatabaseContext, DiffEntry, DiffRef, DiffResult, Flags, JsonDocumentData, IdentifierChildNode, ListIdentifierChildrenResult, ListIdentifiersResult, LockInfo, MergeConflict, MergeResult, OAuthProviderInfo, OAuthProvidersResponse, OwnedTenantInfo, ProjectInfo, PlatformRegistrationConfig, PlatformWorkspaceOrg, PlatformWorkspacesResponse, ProjectSearchSettings, ProjectSearchSettingsUpdate, ProjectDocConfResponse, PlatformDefaultDocConfResponse, LogEntry, MetaValue, PlatformRegisterResult, PolicyUpdateResponse, PublishConflict, PublishResult, PolicyConditions, PolicyIdentifierPattern, PolicyResources, PolicySubjectInput, PolicySubjects, RagQueryOptions, RagQueryResult, RagStreamEvent, RealtimeEvent, SearchIndexingProgress, SecurityConfig, SecurityPolicy, StoredPolicyResponse, StoredTriggerResponse, SubscriptionOptions, TagRecord, TextSearchHit, TextSearchQuery, TextSearchResult, TriggerDefinition, TokenPair, UserInfo, UserIsolationConfig, UserIsolationOptions, WorkspaceInfo, WriteDocumentOptions, CreateTestSessionOptions, XCiteDBClientOptions, XCiteDBJwtClaims, UnqueryResult, UnqueryTemplate, XCiteQuery, } from './types';
|
|
3
|
+
export type { AccessCheckResult, ApiKeyInfo, AppAuthConfig, AppEmailConfig, AppEmailSmtpConfig, AppEmailTemplateEntry, AppEmailTemplates, AppEmailWebhookConfig, AppUser, AppUserTokenPair, EmailTestResponse, ForgotPasswordResponse, SendVerificationResponse, BookmarkRecord, BranchInfo, BranchListItem, CheckpointRecord, CommitRecord, CompareEntry, CompareRef, CompareResult, DatabaseContext, DiffEntry, DiffRef, DiffResult, DocumentBatchResponse, DocumentBatchResultRow, Flags, JsonDocumentData, JsonDocumentBatchItem, IdentifierChildNode, ListIdentifierChildrenResult, ListIdentifiersResult, LockInfo, MergeConflict, MergeResult, OAuthProviderInfo, OAuthProvidersResponse, OwnedTenantInfo, ProjectInfo, PlatformRegistrationConfig, PlatformWorkspaceOrg, PlatformWorkspacesResponse, ProjectSearchSettings, ProjectSearchSettingsUpdate, ProjectDocConfResponse, PlatformDefaultDocConfResponse, LogEntry, MetaValue, PlatformRegisterResult, PolicyUpdateResponse, PublishConflict, PublishResult, PolicyConditions, PolicyIdentifierPattern, PolicyResources, PolicySubjectInput, PolicySubjects, RagQueryOptions, RagQueryResult, RagStreamEvent, RealtimeEvent, SearchIndexingProgress, SecurityConfig, SecurityPolicy, StoredPolicyResponse, StoredTriggerResponse, SubscriptionOptions, TagRecord, TextSearchHit, TextSearchQuery, TextSearchResult, TriggerDefinition, TokenPair, UserInfo, UserIsolationConfig, UserIsolationOptions, WorkspaceInfo, WriteDocumentOptions, XmlDocumentBatchItem, CreateTestSessionOptions, XCiteDBClientOptions, XCiteDBJwtClaims, UnqueryResult, UnqueryTemplate, XCiteQuery, } from './types';
|
|
4
4
|
export { XCiteDBError } from './types';
|
package/dist/types.d.ts
CHANGED
|
@@ -57,6 +57,7 @@ export interface TextSearchQuery {
|
|
|
57
57
|
date_to?: string;
|
|
58
58
|
}
|
|
59
59
|
export interface TextSearchHit {
|
|
60
|
+
/** JSON: document id. XML: first non-xcitepath id from db:identifier, else xcitepath (xcitepath also in `xcitepath`). */
|
|
60
61
|
identifier: string;
|
|
61
62
|
/** Canonical db:xcitepath for XML hits; omitted or empty for JSON. */
|
|
62
63
|
xcitepath?: string;
|
|
@@ -67,7 +68,7 @@ export interface TextSearchHit {
|
|
|
67
68
|
score: number;
|
|
68
69
|
/** Present for semantic / hybrid search. */
|
|
69
70
|
source?: 'fts' | 'semantic' | 'both';
|
|
70
|
-
/** FTS temporal window for this hit (
|
|
71
|
+
/** FTS temporal validity window for this hit (human-readable UTC, MM/DD/YYYY HH:MM:SS), when returned by the server. */
|
|
71
72
|
valid_from?: string;
|
|
72
73
|
valid_to?: string;
|
|
73
74
|
}
|
|
@@ -187,6 +188,15 @@ export interface RagQueryOptions {
|
|
|
187
188
|
min_score?: number;
|
|
188
189
|
/** Hybrid retrieval only: semantic vs FTS weight in weighted RRF (0–1, default 0.5). */
|
|
189
190
|
semantic_weight?: number;
|
|
191
|
+
/** Overrides project default when set (0–2). */
|
|
192
|
+
temperature?: number;
|
|
193
|
+
/** Overrides project default when set (1–32768). */
|
|
194
|
+
max_tokens?: number;
|
|
195
|
+
/** Prior turns; roles `system` | `user` | `assistant`. Current question is separate. */
|
|
196
|
+
messages?: {
|
|
197
|
+
role: 'system' | 'user' | 'assistant';
|
|
198
|
+
content: string;
|
|
199
|
+
}[];
|
|
190
200
|
}
|
|
191
201
|
export interface RagQueryResult {
|
|
192
202
|
answer: string;
|
|
@@ -194,9 +204,9 @@ export interface RagQueryResult {
|
|
|
194
204
|
}
|
|
195
205
|
/** One SSE JSON payload from streaming RAG (`stream: true`). */
|
|
196
206
|
export type RagStreamEvent = {
|
|
197
|
-
text
|
|
207
|
+
text?: string;
|
|
198
208
|
done: false;
|
|
199
|
-
sources?:
|
|
209
|
+
sources?: unknown;
|
|
200
210
|
error?: undefined;
|
|
201
211
|
} | {
|
|
202
212
|
text?: string;
|
|
@@ -357,6 +367,29 @@ export interface WriteDocumentOptions {
|
|
|
357
367
|
is_top?: boolean;
|
|
358
368
|
compare_attributes?: boolean;
|
|
359
369
|
}
|
|
370
|
+
/** One row in `POST /api/v1/documents/batch` or `POST /api/v1/json-documents/batch` response `results`. */
|
|
371
|
+
export interface DocumentBatchResultRow {
|
|
372
|
+
index: number;
|
|
373
|
+
identifier: string;
|
|
374
|
+
ok: boolean;
|
|
375
|
+
error?: string;
|
|
376
|
+
code?: number;
|
|
377
|
+
}
|
|
378
|
+
export interface DocumentBatchResponse {
|
|
379
|
+
results: DocumentBatchResultRow[];
|
|
380
|
+
}
|
|
381
|
+
export interface XmlDocumentBatchItem {
|
|
382
|
+
xml: string;
|
|
383
|
+
is_top?: boolean;
|
|
384
|
+
compare_attributes?: boolean;
|
|
385
|
+
/** When set, must match canonical root `db:identifier` in `xml` (after server normalization). */
|
|
386
|
+
identifier?: string;
|
|
387
|
+
}
|
|
388
|
+
export interface JsonDocumentBatchItem {
|
|
389
|
+
identifier: string;
|
|
390
|
+
data: unknown;
|
|
391
|
+
overwrite?: boolean;
|
|
392
|
+
}
|
|
360
393
|
export interface SubscriptionOptions {
|
|
361
394
|
pattern: string;
|
|
362
395
|
event_type?: string;
|
|
@@ -551,7 +584,6 @@ export interface PolicyIdentifierPattern {
|
|
|
551
584
|
}
|
|
552
585
|
export interface PolicyResources {
|
|
553
586
|
identifiers?: PolicyIdentifierPattern[];
|
|
554
|
-
meta_paths?: string[];
|
|
555
587
|
xml_paths?: string[];
|
|
556
588
|
}
|
|
557
589
|
export interface PolicyConditions {
|
package/llms-full.txt
CHANGED
|
@@ -452,14 +452,23 @@ Returns `{ parent_path, parent_is_identifier, children: [{ segment, full_path, i
|
|
|
452
452
|
|
|
453
453
|
**`POST /api/v1/json-documents`**
|
|
454
454
|
|
|
455
|
+
JSON body fields:
|
|
456
|
+
|
|
457
|
+
| Field | Required | Meaning |
|
|
458
|
+
|-------|----------|---------|
|
|
459
|
+
| `identifier` | yes | Document path key |
|
|
460
|
+
| `data` | yes | JSON value to merge or store |
|
|
461
|
+
| `overwrite` | no (default `false`) | When `true`, delete all metadata under the document root first, then write `data` only. When `false`, **`data` is merged** into any existing document (nested objects combine fields; nested arrays follow meta merge rules—see Metadata). |
|
|
462
|
+
|
|
455
463
|
```json
|
|
456
464
|
{
|
|
457
465
|
"identifier": "app.settings",
|
|
458
|
-
"data": { "theme": "dark", "maxUploadMb": 25 }
|
|
466
|
+
"data": { "theme": "dark", "maxUploadMb": 25 },
|
|
467
|
+
"overwrite": false
|
|
459
468
|
}
|
|
460
469
|
```
|
|
461
470
|
|
|
462
|
-
Note:
|
|
471
|
+
Note: SDKs use `identifier` and `data` (optional `overwrite`). Some older documentation shows `key` and `value`.
|
|
463
472
|
|
|
464
473
|
## Read JSON document
|
|
465
474
|
|
|
@@ -503,15 +512,26 @@ Attach structured **JSON metadata** to documents or nodes.
|
|
|
503
512
|
|
|
504
513
|
**`POST /api/v1/meta`**
|
|
505
514
|
|
|
515
|
+
| Field | Required | Meaning |
|
|
516
|
+
|-------|----------|---------|
|
|
517
|
+
| `identifier` **or** `query` | one required | Target document id or document query |
|
|
518
|
+
| `value` | yes | JSON to write (omit only for string-specific query batch paths handled by the server) |
|
|
519
|
+
| `path` | no (default `""`) | Meta path (dot-separated keys; `[i]` for array indices) |
|
|
520
|
+
| `mode` | no (default `"set"`) | `"set"` — write/replace at `path`. For **arrays** at `path`, indices `0..n-1` are written and any previous tail beyond the new length is cleared. `"append"` — for **arrays** at `path`, new elements are written after existing indices (extend in place). |
|
|
521
|
+
| `overwrite` | no (default `false`) | When `true`, delete existing metadata under `path` before applying `value`. |
|
|
522
|
+
| `first_match` | no | With `query`, only the first matching identifier is updated when `true`. |
|
|
523
|
+
|
|
506
524
|
```json
|
|
507
525
|
{
|
|
508
526
|
"identifier": "/book/ch1",
|
|
509
527
|
"value": { "status": "review", "owner": "alice" },
|
|
510
|
-
"path": ""
|
|
528
|
+
"path": "",
|
|
529
|
+
"mode": "set",
|
|
530
|
+
"overwrite": false
|
|
511
531
|
}
|
|
512
532
|
```
|
|
513
533
|
|
|
514
|
-
|
|
534
|
+
Use `"mode": "append"` to extend arrays at `path` instead of replacing them.
|
|
515
535
|
|
|
516
536
|
Can also use `"query"` instead of `"identifier"` to target multiple documents by query filter.
|
|
517
537
|
|
|
@@ -527,6 +547,12 @@ Can also use `"query"` instead of `"identifier"` to target multiple documents by
|
|
|
527
547
|
|
|
528
548
|
**`DELETE /api/v1/meta`** — `{ "query": {...} }`
|
|
529
549
|
|
|
550
|
+
## JSON metadata storage model (best practices)
|
|
551
|
+
|
|
552
|
+
- **Field-indexed objects.** Metadata and standalone JSON documents share the same shredded-key storage. **JSON objects** map to named paths so fields can be read or updated without loading a monolithic blob.
|
|
553
|
+
- **Dictionary threshold.** When the **set of distinct field names** on an object reaches the server threshold (default **32**, native setting `meta_dict_field_threshold`), XCiteDB switches that object to **dictionary storage** (`{*}` plus per-field keys) for scalable indexed access.
|
|
554
|
+
- **Modeling guidance.** Prefer stable **`{ "key": value, ... }`** / nested-object shapes for records you look up by key. Arrays are appropriate for ordered lists; use **`mode: "append"`** when appending to a stored array.
|
|
555
|
+
|
|
530
556
|
---
|
|
531
557
|
|
|
532
558
|
# Search
|
|
@@ -1374,17 +1400,17 @@ interface DatabaseContext {
|
|
|
1374
1400
|
- `queryLog(query, fromDate, toDate)` → `LogEntry[]`
|
|
1375
1401
|
|
|
1376
1402
|
### JSON Documents
|
|
1377
|
-
- `writeJsonDocument(identifier, data)` → `void`
|
|
1403
|
+
- `writeJsonDocument(identifier, data, opts?)` → `void` — merge by default; `opts?.overwrite` replaces root
|
|
1378
1404
|
- `readJsonDocument<T>(identifier)` → `T` (default `unknown`)
|
|
1379
1405
|
- `deleteJsonDocument(identifier)` → `void`
|
|
1380
1406
|
- `listJsonDocuments(match?, limit?, offset?)` → `ListIdentifiersResult`
|
|
1381
|
-
- `put(identifier, data)` / `get<T>(identifier)` / `remove(identifier)` / `list(match?, limit?, offset?)` — JSON CRUD aliases
|
|
1407
|
+
- `put(identifier, data, opts?)` / `get<T>(identifier)` / `remove(identifier)` / `list(match?, limit?, offset?)` — JSON CRUD aliases (`opts` same as `writeJsonDocument`)
|
|
1382
1408
|
|
|
1383
1409
|
### Metadata
|
|
1384
|
-
- `addMeta(identifier, value, path?, opts?)` → `boolean`
|
|
1410
|
+
- `addMeta(identifier, value, path?, opts?)` → `boolean` — `opts`: `mode?: 'set'|'append'`, `overwrite?: boolean`
|
|
1385
1411
|
- `addMetaByQuery(query, value, path?, firstMatch?, opts?)` → `boolean`
|
|
1386
|
-
- `appendMeta(identifier, value, path?)` → `boolean`
|
|
1387
|
-
- `appendMetaByQuery(query, value, path?, firstMatch?)` → `boolean`
|
|
1412
|
+
- `appendMeta(identifier, value, path?, opts?)` → `boolean` — same as `addMeta` with `mode: 'append'`
|
|
1413
|
+
- `appendMetaByQuery(query, value, path?, firstMatch?, opts?)` → `boolean`
|
|
1388
1414
|
- `queryMeta<T>(identifier, path?)` → `T`
|
|
1389
1415
|
- `queryMetaByQuery<T>(query, path?)` → `T`
|
|
1390
1416
|
- `clearMeta(query)` → `boolean`
|
package/llms.txt
CHANGED
|
@@ -111,6 +111,12 @@ await app.writeJsonDocument('userdata/alice/profile', { ok: true });
|
|
|
111
111
|
4. **Cleanup:** `DELETE /api/v1/test/sessions/current` with `X-Test-Session` (no other auth), or `DELETE /api/v1/test/sessions/all` / `DELETE /api/v1/test/sessions/{token}` with normal auth for the owning key or JWT.
|
|
112
112
|
5. **SDKs:** **JS/TS:** `XCiteDBClient.createTestSession({ baseUrl, apiKey, … })`, optional `overlay: true`, optional `testRequireAuth`, then `destroyTestSession()`. **Python:** `async with XCiteDBClient.test_session(...)` or provision with **`POST /api/v1/test/sessions`** and JSON **`{"overlay":true}`** when you need overlay, then pass `test_session_token` / `test_require_auth` to the constructor. **C++:** `XCiteDBClient::create_test_session(options)` with optional `test_session_overlay = true`, `destroy_test_session()`, optional `test_require_auth` in options.
|
|
113
113
|
|
|
114
|
+
## JSON documents and metadata (merge, overwrite, efficiency)
|
|
115
|
+
|
|
116
|
+
- **JSON documents merge by default.** `POST /api/v1/json-documents` merges the posted `data` into the existing document (object fields combined per XCiteDB meta merge rules). Send **`overwrite: true`** to clear all stored JSON under that document root first, then write only the new payload. SDKs accept the same flag (e.g. `writeJsonDocument(id, data, { overwrite: true })` in JavaScript).
|
|
117
|
+
- **Metadata `mode` and arrays.** **`POST /api/v1/meta`** uses **`mode`**: default **`set`** writes or replaces at `path` (arrays are replaced in range; excess old indices cleared); **`append`** appends array elements after existing ones at `path`. Optional **`overwrite: true`** clears metadata under `path` before writing. JavaScript: **`appendMeta`** or **`addMeta(..., { mode: 'append' })`**; Python/C++: **`append_meta`** or **`add_meta`** with **`mode`** / **`overwrite`** (see SDK sections below).
|
|
118
|
+
- **Prefer dictionary-style objects.** Shredded JSON metadata is keyed by field names. **Object maps** get per-field storage; when an object accumulates enough distinct field names (server default threshold **32**), XCiteDB switches automatically to **dictionary storage** (`{*}` plus per-field keys) for efficient indexed access. For lookup-heavy or wide records, use **`{ "key": value, ... }`** shapes (or one document per logical row) rather than opaque arrays when you need keyed reads.
|
|
119
|
+
|
|
114
120
|
## JavaScript/TypeScript SDK (`@xcitedbs/client`)
|
|
115
121
|
|
|
116
122
|
Install: `npm install @xcitedbs/client`
|
|
@@ -232,15 +238,15 @@ interface XCiteDBClientOptions {
|
|
|
232
238
|
- `listIdentifierChildren(parentPath?)` — Navigate identifier hierarchy
|
|
233
239
|
|
|
234
240
|
**JSON Documents:**
|
|
235
|
-
- `writeJsonDocument(identifier, data)` — Store a JSON document
|
|
241
|
+
- `writeJsonDocument(identifier, data, opts?)` — Store or merge a JSON document (`opts?.overwrite` replaces entire document root)
|
|
236
242
|
- `readJsonDocument(identifier)` — Read a JSON document (generic `readJsonDocument<T>()` supported)
|
|
237
243
|
- `deleteJsonDocument(identifier)` — Delete a JSON document
|
|
238
244
|
- `listJsonDocuments(match?, limit?, offset?)` — List JSON document keys
|
|
239
245
|
- **Quick JSON aliases:** `put`, `get`, `remove`, `list` — same as the four methods above
|
|
240
246
|
|
|
241
247
|
**Metadata (JSON on XML):**
|
|
242
|
-
- `addMeta(identifier, value, path?)` — Set metadata
|
|
243
|
-
- `appendMeta(identifier, value, path?)` — Append
|
|
248
|
+
- `addMeta(identifier, value, path?, opts?)` — Set or append metadata (`opts?.mode`: `set`|`append`; `opts?.overwrite`)
|
|
249
|
+
- `appendMeta(identifier, value, path?, opts?)` — Append at `path` (same as `addMeta` with `mode: 'append'`)
|
|
244
250
|
- `queryMeta(identifier, path?)` — Read metadata
|
|
245
251
|
- `clearMeta(query)` — Remove metadata
|
|
246
252
|
|