@xcitedbs/client 0.2.13 → 0.2.15

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 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`, `meta:read`, `meta:write`, `unquery`.
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, metaPath?: string, branch?: string): Promise<AccessCheckResult>;
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
  */
@@ -526,6 +529,10 @@ export declare class XCiteDBClient {
526
529
  writeJsonDocument(identifier: string, data: unknown, opts?: {
527
530
  overwrite?: boolean;
528
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>;
529
536
  readJsonDocument<T = unknown>(identifier: string): Promise<T>;
530
537
  deleteJsonDocument(identifier: string): Promise<void>;
531
538
  listJsonDocuments(match?: string, limit?: number, offset?: number): Promise<ListIdentifiersResult>;
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`, `meta:read`, `meta:write`, `unquery`.
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, metaPath, branch) {
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
  */
@@ -1562,6 +1585,12 @@ class XCiteDBClient {
1562
1585
  body.min_score = options.min_score;
1563
1586
  if (options.semantic_weight !== undefined)
1564
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;
1565
1594
  const data = await this.request('POST', '/api/v1/rag/query', body);
1566
1595
  if (!data || typeof data !== 'object') {
1567
1596
  throw new types_1.XCiteDBError('Invalid RAG response', 500, data);
@@ -1585,6 +1614,9 @@ class XCiteDBClient {
1585
1614
  ...(options.search_mode !== undefined ? { search_mode: options.search_mode } : {}),
1586
1615
  ...(options.min_score !== undefined ? { min_score: options.min_score } : {}),
1587
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 } : {}),
1588
1620
  });
1589
1621
  for (let attempt = 0; attempt < 2; attempt++) {
1590
1622
  const url = joinUrl(this.baseUrl, path);
@@ -1664,6 +1696,30 @@ class XCiteDBClient {
1664
1696
  body.overwrite = true;
1665
1697
  await this.request('POST', '/api/v1/json-documents', body);
1666
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;
1722
+ }
1667
1723
  async readJsonDocument(identifier) {
1668
1724
  return this.request('GET', `/api/v1/json-documents${buildQuery({ identifier: this.isoPrefixId(identifier) })}`);
1669
1725
  }
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 (internal 7-char keys), when returned by the server. */
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: string;
207
+ text?: string;
198
208
  done: false;
199
- sources?: undefined;
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
@@ -613,6 +613,8 @@ Unquery supports: hierarchical navigation (self, parents, ancestors, children, d
613
613
 
614
614
  The `unquery` body is a **JSON template**: each **object key** names an output field; each **value** is either a nested object/array (recursed) or a **string parsed as an expression**. Arrays produce JSON arrays in order.
615
615
 
616
+ **Parser-faithful grammar / AST** (for syntax checking, static typing, and tooling): see **`unquery-grammar.md`** shipped next to this file in SDK packages (canonical document in the XciteDB-server repository: `docs/unquery-grammar.md`). The MCP server also exposes it as the resource URI **`xcitedb://unquery-grammar`**.
617
+
616
618
  ### Core expression builtins (string values)
617
619
 
618
620
  - **Document / path:** `$identifier`, `$identifier(n)` (path segment by index), `$key`, `$index`, `$path`
package/llms.txt CHANGED
@@ -301,7 +301,7 @@ interface XCiteDBClientOptions {
301
301
 
302
302
  - JSON **keys** = output fields; **string values** = expressions referencing meta/XML (e.g. field name `"title"` reads meta key `title`).
303
303
  - **Common builtins:** `$count`, `$sum(expr)`, `$avg(expr)`, `$min(expr)`, `$max(expr)`, `$xpath("…")`, `$identifier`, `$size(expr)`, `$length(expr)`, `$if(cond, a, b)`, `$var(name)` / `%name`.
304
- - **Example:** `{ "query": { "match_start": "/orders/" }, "unquery": { "n": "$count" } }` — count documents. Full grammar: **`llms-full.txt`** in this package.
304
+ - **Example:** `{ "query": { "match_start": "/orders/" }, "unquery": { "n": "$count" } }` — count documents. Human-oriented reference: **`llms-full.txt`** in this package. **AI-first writing guide (read this before generating any Unquery query):** **`unquery-ai-guide.md`** (canonical source in the server repo: `docs/unquery-ai-guide.md`; MCP resource `xcitedb://unquery-guide`). **Parser-faithful grammar / parse tree** (syntax + static checks for tooling): **`unquery-grammar.md`** (canonical: `docs/unquery-grammar.md`; MCP resource `xcitedb://unquery-grammar`).
305
305
 
306
306
  **App Users (admin):**
307
307
  - `listAppUsers()` / `createAppUser()` / `deleteAppUser()` — Manage end-user accounts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xcitedbs/client",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "description": "XCiteDB BaaS client SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -41,7 +41,9 @@
41
41
  "files": [
42
42
  "dist",
43
43
  "llms.txt",
44
- "llms-full.txt"
44
+ "llms-full.txt",
45
+ "unquery-grammar.md",
46
+ "unquery-ai-guide.md"
45
47
  ],
46
48
  "license": "MIT"
47
49
  }