@xcitedbs/client 0.3.11 → 0.3.12

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 CHANGED
@@ -67,6 +67,85 @@ Call **`POST /api/v1/test/sessions`** with your normal API key or Bearer (same p
67
67
 
68
68
  Tear down with **`destroyTestSession()`** (or **`DELETE /api/v1/test/sessions/current`** with the session header). With the **same** API key / Bearer and **no** `X-Test-Session`, use **`listTestSessions()`**, **`destroyAllTestSessions()`**, and **`destroyTestSessionByToken(token)`** to clear leaked sessions before large suites (avoids the default per-credential concurrent cap). See **`llms.txt`** / **`llms-full.txt`** in this package for full behavior, limits, and auth notes.
69
69
 
70
+ ## Gotchas and conventions
71
+
72
+ These trip up most first-time users; they're listed once here so you don't hit them twice.
73
+
74
+ ### Search (`search`) tokenizes on hyphens
75
+
76
+ The full-text index treats `-` as a token boundary, so `client.search({ query: 'Test - Article' })` won't match a document titled exactly `"Test - Article"` — it tokenizes to `Test`, `Article` and ranks any doc containing both. Use `search` only for relevance queries.
77
+
78
+ For exact-title or exact-meta lookups, use **`unquery`** with a meta-equality filter:
79
+
80
+ ```ts
81
+ client.unquery(
82
+ { match_start: '/spaces/<u>/docs/' },
83
+ [{ title: 'title', match: '$equals(title, $string("Test - Article"))' }]
84
+ );
85
+ ```
86
+
87
+ ### `list*` methods return wrapper objects, not bare arrays
88
+
89
+ For consistency, every `list*` family method returns an object with the data nested under a named key:
90
+
91
+ | Method | Wrapper shape |
92
+ |---|---|
93
+ | `listIdentifiers` | `{ identifiers: string[], total, offset, limit }` |
94
+ | `listCheckpoints` | `{ checkpoints: CheckpointRecord[], total, branch }` |
95
+ | `listUserWorkspaces` | `{ user_workspaces: [...] }` |
96
+ | `listBookmarks` | `{ bookmarks: [...], total }` |
97
+
98
+ Don't `for…of` the result directly — use `for (const x of ids.identifiers)`, not `for (const x of ids)`.
99
+
100
+ ### Reading meta — `getMeta` and `queryMeta`
101
+
102
+ The read sibling of `addMeta` / `appendMeta` / `clearMeta` is **`getMeta`** (alias of `queryMeta`). With an empty `path` it returns the whole top-level meta object, which by convention is keyed by tool/flow:
103
+
104
+ ```ts
105
+ const meta = await client.getMeta(docId); // { lint: {...}, summary: {...}, ... }
106
+ const lint = await client.getMeta(docId, 'lint'); // just the lint sub-object
107
+ ```
108
+
109
+ For an array-typed or keyed-object meta path (e.g. an items list, or a per-tool dictionary), pair with **`appendItem`** to push and **`removeItem`** to atomically delete by key — `removeItem` matches against `id` / `item_id` (or by string equality for primitive arrays) and writes back inside one server-side write txn, avoiding the read/modify/write race that read-then-set on the client would create.
110
+
111
+ ### Overlay test sessions — visibility matrix
112
+
113
+ `createTestSession({ overlay: true })` lets you read production data and write into an isolated overlay. The visibility model is **not "read-through everywhere"** — these are the layers that participate in the overlay→base fallback:
114
+
115
+ | API | Sees prod data? |
116
+ |---|---|
117
+ | Document and meta reads (anywhere in the doc store) | **yes** |
118
+ | Branch table existence checks (e.g. `_uw/<owner>/<slug>`) | **yes** |
119
+ | Per-branch identifier scans on base-only branches (`listIdentifiers`, `compare`) | **yes** |
120
+ | User-workspace records (`listUserWorkspaces`, `getUserWorkspace`) | **yes** |
121
+ | Branch tip / commit lookups (`listCheckpoints`, `compare` against checkpoints) | **yes** |
122
+ | `publishUserWorkspace` writes | sandboxed in overlay — does **not** touch prod |
123
+ | `createCheckpoint`, `addMeta`, `addDocument`, etc. | sandboxed in overlay |
124
+
125
+ Anything you write inside an overlay session lives under `_test/<uuid>/` and is dropped when the session is destroyed. To inspect a real production conflict mutation-free, call the production admin client directly with `{ autoResolve: 'none' }`.
126
+
127
+ ### `compare()` ref shapes
128
+
129
+ `{ branch }` without `date` or `checkpoint_id` resolves to the branch's **live tip**, not its base. On a branch with zero checkpoints the server returns 400 `branch_has_no_commits` rather than producing an ambiguous diff — pass an explicit `date` or `checkpoint_id` instead.
130
+
131
+ `compare()` accepts **both** `matchStart` (camelCase, our convention) and `match_start` (snake_case, matching `XCiteQuery`) on the options object; they're equivalent.
132
+
133
+ ### `withContext` / `fork`
134
+
135
+ `fork(partial)` returns a child client with the merged context (workspace, date, prefix). **`withContext(partial)`** is a one-line alias for the same operation.
136
+
137
+ ### `_xcite_json_doc` sentinel
138
+
139
+ JSON documents written via `writeJsonDocument` no longer leak the internal `_xcite_json_doc: true` marker into the read payload — the server strips it before serializing. Older clients that filtered it out can drop that workaround. Likewise, `deleteDocument` now correctly removes JSON documents (it routes JSON ids through `deleteJSON` automatically); you don't need to pick `deleteJsonDocument` based on the document's storage shape.
140
+
141
+ ### `testAuth: 'bypass'` requires the creator credential
142
+
143
+ When you create a test session, the issuing API key/Bearer is the **creator credential**. Calling endpoints under `X-Test-Auth: bypass` requires presenting that same credential alongside `X-Test-Session`; it isn't only a login restriction. If you can't present the creator credential (e.g. you're operating from a different identity), switch to `X-Test-Auth: required` and the session itself authenticates the request.
144
+
145
+ ### BFF/SPA-side concerns (tracked separately)
146
+
147
+ The following are app/BFF-repo concerns rather than SDK or server bugs: `getOrCreateDraft` check-then-act races (TOCTOU on per-`(user, key)` resource minting); coexisting legacy and modern `last-drafts` storage formats with different identifier encodings; and project-level workspace wiring of `@xcitedbs/client` for top-level diagnostic scripts. They're tracked in the BFF/SPA repo and aren't fixed here.
148
+
70
149
  ## Build
71
150
 
72
151
  ```bash
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, SmartDiffRef, SmartDiffResult, DocumentBatchResponse, DocumentExportFormat, ExportDocumentResult, Flags, JsonDocumentBatchItem, ImportDocumentOptions, ImportDocumentResult, ListIdentifierChildrenResult, ListIdentifiersResult, LockInfo, AcquireLockOptions, LogEntry, MergeResult, PublishResult, RebaseUserWorkspaceResult, WorkspaceInfo, MetaValue, PlatformRegisterResult, PolicySubjectInput, UnqueryResult, UnqueryTemplate, PolicyUpdateResponse, RealtimeEvent, SecurityConfig, SecurityPolicy, StoredTriggerResponse, TriggerDefinition, TriggerEventsResponse, StoredPolicyResponse, TxnRequest, TxnResponse, VerifyAppUserTokenOptions, SubscriptionOptions, TagRecord, TextSearchQuery, TextSearchResult, ProjectSearchSettings, ProjectSearchSettingsUpdate, ProjectDocConfResponse, AssetGcDryRunResult, AssetHeadResult, AssetListResponse, AssetMagicLinkListResponse, AssetMagicLinkResult, AssetShareListResponse, AssetShareRequest, AssetUnshareRequest, AssetUploadResult, CreateAssetMagicLinkRequest, ListAssetsOptions, ProjectAssetStorageConfig, UploadAssetOptions, PlatformDefaultDocConfResponse, VectorIndexEstimate, RagQueryOptions, RagQueryResult, RagStreamEvent, OAuthProvidersResponse, ProjectInfo, PlatformRegistrationConfig, PlatformWorkspacesResponse, TokenPair, UserInfo, ApiKeyInfo, WriteDocumentOptions, XmlDocumentBatchItem, CreateTestSessionOptions, XCiteDBClientOptions, XCiteDBJwtClaims, TestSessionBootstrapSummary, TestSessionInfo, XCiteQuery, UserIsolationConfig, UserIsolationCreateShareParams, UserIsolationShareResult, UserIsolationShareListResponse, UserIsolationUnshareParams, ShareDirection, AppUserGroup, CreateGroupParams, ListGroupsResponse } from './types';
1
+ import { AccessCheckResult, AppAuthConfig, AppEmailConfig, AppEmailTemplates, AppUser, AppUserTokenPair, EmailTestResponse, ForgotPasswordResponse, SendVerificationResponse, BranchInfo, BookmarkRecord, CheckpointRecord, CommitRecord, CompareRef, CompareResult, DatabaseContext, DiffRef, DiffResult, SmartDiffRef, SmartDiffResult, DocumentBatchResponse, DocumentExportFormat, ExportDocumentResult, Flags, JsonDocumentBatchItem, ImportDocumentOptions, ImportDocumentResult, ListIdentifierChildrenResult, ListIdentifiersResult, LockInfo, AcquireLockOptions, LogEntry, MergeResult, PublishResult, RebaseUserWorkspaceResult, WorkspaceInfo, MetaValue, PlatformRegisterResult, PolicySubjectInput, UnqueryResult, UnqueryTemplate, PolicyUpdateResponse, RealtimeEvent, SecurityConfig, SecurityPolicy, StoredTriggerResponse, TriggerDefinition, TriggerEventsResponse, StoredPolicyResponse, TxnRequest, TxnResponse, VerifyAppUserTokenOptions, SubscriptionOptions, TagRecord, TextSearchQuery, TextSearchResult, ProjectSearchSettings, ProjectSearchSettingsUpdate, ProjectDocConfResponse, AssetGcDryRunResult, AssetHeadResult, AssetListResponse, AssetMagicLinkListResponse, AssetMagicLinkResult, AssetShareListResponse, AssetShareRequest, AssetUnshareRequest, AssetUploadResult, CreateAssetMagicLinkRequest, ListAssetsOptions, ProjectAssetStorageConfig, UploadAssetOptions, PlatformDefaultDocConfResponse, VectorIndexEstimate, RagQueryOptions, RagQueryResult, RagStreamEvent, OAuthProvidersResponse, ProjectInfo, PlatformRegistrationConfig, PlatformWorkspacesResponse, TokenPair, UserInfo, ApiKeyInfo, WriteDocumentOptions, XmlDocumentBatchItem, CreateTestSessionOptions, XCiteDBClientOptions, XCiteDBJwtClaims, TestSessionBootstrapSummary, TestSessionInfo, XCiteQuery, UserIsolationConfig, UserIsolationCreateShareParams, UserIsolationShareResult, UserIsolationShareListResponse, UserIsolationUnshareParams, ShareDirection, AppUserGroup, CreateGroupParams, ListGroupsResponse, FunctionManifest, FunctionListItem, FunctionDeployRequest, FunctionSecretsList } from './types';
2
2
  import { WebSocketSubscription } from './websocket';
3
3
  export declare class XCiteDBClient {
4
4
  private baseUrl;
@@ -217,6 +217,8 @@ export declare class XCiteDBClient {
217
217
  * the `onSessionTokensUpdated` / `onAppUserTokensUpdated` callbacks supplied at construction.
218
218
  */
219
219
  fork(partial?: Partial<DatabaseContext>): XCiteDBClient;
220
+ /** Alias for {@link fork}. Both names are commonly guessed; this avoids a discoverability cliff. */
221
+ withContext(partial?: Partial<DatabaseContext>): XCiteDBClient;
220
222
  setTokens(access: string, refresh?: string): void;
221
223
  /** End-user (app) tokens. With developer `accessToken`/`apiKey`, sent as `X-App-User-Token`. */
222
224
  setAppUserTokens(access: string, refresh?: string): void;
@@ -454,6 +456,56 @@ export declare class XCiteDBClient {
454
456
  * `admin`/`editor` roles can read this; public-key requests are rejected.
455
457
  */
456
458
  listTriggerEvents(limit?: number): Promise<TriggerEventsResponse>;
459
+ /**
460
+ * List deployed functions for the current project. Returns metadata only
461
+ * (no wasm bytes). Requires admin or editor role on the project.
462
+ */
463
+ listFunctions(): Promise<FunctionListItem[]>;
464
+ /**
465
+ * Fetch a single function's manifest. Wasm bytes are omitted unless
466
+ * `includeWasm` is true (admin export path).
467
+ */
468
+ getFunction(name: string, opts?: {
469
+ includeWasm?: boolean;
470
+ }): Promise<FunctionManifest>;
471
+ /**
472
+ * Deploy / replace a function. Body MUST include `wasm_b64` (base64 wasm
473
+ * bytes) plus the manifest fields. Server validates the wasm magic and
474
+ * compiles it before persisting.
475
+ */
476
+ deployFunction(name: string, manifest: FunctionDeployRequest): Promise<FunctionManifest>;
477
+ deleteFunction(name: string): Promise<{
478
+ deleted: string;
479
+ }>;
480
+ invokeFunction<T = unknown>(name: string, body?: unknown): Promise<T>;
481
+ /**
482
+ * List the secret-name slots for a function. Each entry carries `set:
483
+ * true|false` — values are NEVER returned. The `orphan_secrets` field, if
484
+ * present, lists names that were once set but no longer appear in the
485
+ * manifest's `secrets[]` declaration; clean up via deleteFunctionSecret.
486
+ * Requires admin role.
487
+ */
488
+ listFunctionSecrets(name: string): Promise<FunctionSecretsList>;
489
+ /**
490
+ * Set one or more secret values. Each KEY must be declared in the
491
+ * manifest's `secrets[]` array; values are encrypted at rest and never
492
+ * round-trip on any GET. Requires admin role.
493
+ *
494
+ * @example
495
+ * ```ts
496
+ * await client.setFunctionSecrets('charge', {
497
+ * STRIPE_KEY: 'sk_live_...',
498
+ * WEBHOOK_SIGNING_KEY: 'whsec_...',
499
+ * });
500
+ * ```
501
+ */
502
+ setFunctionSecrets(name: string, values: Record<string, string>): Promise<{
503
+ function: string;
504
+ set: string[];
505
+ }>;
506
+ deleteFunctionSecret(name: string, key: string): Promise<{
507
+ deleted: string;
508
+ }>;
457
509
  /**
458
510
  * Dry-run access check (`POST /api/v1/security/check`). Returns `effect` and optional `matched_policy_id`.
459
511
  * Useful for debugging policies. Actions: `read`, `write`, `delete`, `list`, `unquery`.
@@ -673,12 +725,14 @@ export declare class XCiteDBClient {
673
725
  compare(from: CompareRef, to: CompareRef, options?: {
674
726
  includeContent?: boolean;
675
727
  matchStart?: string;
728
+ match_start?: string;
676
729
  }): Promise<CompareResult>;
677
730
  /** @deprecated Use {@link compare}. */
678
731
  diff(from: DiffRef, to: DiffRef, includeContent?: boolean): Promise<DiffResult>;
679
732
  diff(from: DiffRef, to: DiffRef, options?: {
680
733
  includeContent?: boolean;
681
734
  matchStart?: string;
735
+ match_start?: string;
682
736
  }): Promise<DiffResult>;
683
737
  /**
684
738
  * Compare two XML provision trees structurally + textually and write the resulting
@@ -889,6 +943,20 @@ export declare class XCiteDBClient {
889
943
  overwrite?: boolean;
890
944
  context?: Partial<DatabaseContext>;
891
945
  }): Promise<boolean>;
946
+ /**
947
+ * Atomic single-item removal — sibling to {@link appendItem}. Resolves to true when
948
+ * the item was found and removed, false (HTTP 404) when no match. Behavior depends on
949
+ * the meta shape at `path`:
950
+ * - object → drops the field named `itemKey` (siblings untouched).
951
+ * - array → drops entries equal to `itemKey` (string), or whose `id`/`item_id`
952
+ * matches `itemKey`.
953
+ * Read+filter+write happens server-side inside one write txn so concurrent removes
954
+ * on the same key elect exactly one winner — use this instead of read-then-set on the
955
+ * client to avoid the race-loser cleanup the convention warns about.
956
+ */
957
+ removeItem(identifier: string, itemKey: string, path?: string, opts?: {
958
+ context?: Partial<DatabaseContext>;
959
+ }): Promise<boolean>;
892
960
  /** Convenience: push a single item via query. Wraps `item` in `[item]` and calls {@link appendMetaByQuery}. */
893
961
  appendItemByQuery<T = unknown>(query: XCiteQuery, item: T, path?: string, firstMatch?: boolean, opts?: {
894
962
  overwrite?: boolean;
@@ -897,6 +965,14 @@ export declare class XCiteDBClient {
897
965
  queryMeta<T = MetaValue>(identifier: string, path?: string, opts?: {
898
966
  context?: Partial<DatabaseContext>;
899
967
  }): Promise<T>;
968
+ /**
969
+ * Alias for {@link queryMeta} that pairs by name with {@link addMeta} / {@link appendMeta} /
970
+ * {@link clearMeta}. With `path` empty this returns the whole top-level meta object — which
971
+ * by convention is keyed per tool/flow.
972
+ */
973
+ getMeta<T = MetaValue>(identifier: string, path?: string, opts?: {
974
+ context?: Partial<DatabaseContext>;
975
+ }): Promise<T>;
900
976
  queryMetaByQuery<T = MetaValue>(query: XCiteQuery, path?: string, opts?: {
901
977
  context?: Partial<DatabaseContext>;
902
978
  }): Promise<T>;
package/dist/client.js CHANGED
@@ -894,6 +894,10 @@ class XCiteDBClient {
894
894
  child.cachedAppUserId = undefined;
895
895
  return child;
896
896
  }
897
+ /** Alias for {@link fork}. Both names are commonly guessed; this avoids a discoverability cliff. */
898
+ withContext(partial) {
899
+ return this.fork(partial);
900
+ }
897
901
  setTokens(access, refresh) {
898
902
  this.accessToken = access;
899
903
  if (refresh !== undefined)
@@ -1606,6 +1610,72 @@ class XCiteDBClient {
1606
1610
  limit: typeof r?.limit === 'number' ? r.limit : 0,
1607
1611
  };
1608
1612
  }
1613
+ // ----- Functions / BFF (Phase 2 + 2.5 + 9) -----
1614
+ // Server-side WASM functions stored at /_xcitedb/functions/<name> per
1615
+ // tenant. Manifests carry runtime, identity_mode, limits, env (non-secret
1616
+ // config), egress_allowlist, secrets[] (capability declaration), and the
1617
+ // raw wasm bytes (base64). Secret VALUES live in a separate per-function
1618
+ // store and are never returned by any GET path — only set via PUT and
1619
+ // observed as `set: true|false` via list.
1620
+ /**
1621
+ * List deployed functions for the current project. Returns metadata only
1622
+ * (no wasm bytes). Requires admin or editor role on the project.
1623
+ */
1624
+ async listFunctions() {
1625
+ const r = await this.request('GET', '/api/v1/functions');
1626
+ return Array.isArray(r?.functions) ? r.functions : [];
1627
+ }
1628
+ /**
1629
+ * Fetch a single function's manifest. Wasm bytes are omitted unless
1630
+ * `includeWasm` is true (admin export path).
1631
+ */
1632
+ async getFunction(name, opts) {
1633
+ const q = buildQuery({ include_wasm: opts?.includeWasm ? 'true' : undefined });
1634
+ return this.request('GET', `/api/v1/functions/${encodeURIComponent(name)}${q}`);
1635
+ }
1636
+ /**
1637
+ * Deploy / replace a function. Body MUST include `wasm_b64` (base64 wasm
1638
+ * bytes) plus the manifest fields. Server validates the wasm magic and
1639
+ * compiles it before persisting.
1640
+ */
1641
+ async deployFunction(name, manifest) {
1642
+ return this.request('PUT', `/api/v1/functions/${encodeURIComponent(name)}`, manifest);
1643
+ }
1644
+ async deleteFunction(name) {
1645
+ return this.request('DELETE', `/api/v1/functions/${encodeURIComponent(name)}`);
1646
+ }
1647
+ async invokeFunction(name, body) {
1648
+ return this.request('POST', `/api/v1/functions/${encodeURIComponent(name)}/invoke`, body);
1649
+ }
1650
+ /**
1651
+ * List the secret-name slots for a function. Each entry carries `set:
1652
+ * true|false` — values are NEVER returned. The `orphan_secrets` field, if
1653
+ * present, lists names that were once set but no longer appear in the
1654
+ * manifest's `secrets[]` declaration; clean up via deleteFunctionSecret.
1655
+ * Requires admin role.
1656
+ */
1657
+ async listFunctionSecrets(name) {
1658
+ return this.request('GET', `/api/v1/functions/${encodeURIComponent(name)}/secrets`);
1659
+ }
1660
+ /**
1661
+ * Set one or more secret values. Each KEY must be declared in the
1662
+ * manifest's `secrets[]` array; values are encrypted at rest and never
1663
+ * round-trip on any GET. Requires admin role.
1664
+ *
1665
+ * @example
1666
+ * ```ts
1667
+ * await client.setFunctionSecrets('charge', {
1668
+ * STRIPE_KEY: 'sk_live_...',
1669
+ * WEBHOOK_SIGNING_KEY: 'whsec_...',
1670
+ * });
1671
+ * ```
1672
+ */
1673
+ async setFunctionSecrets(name, values) {
1674
+ return this.request('PUT', `/api/v1/functions/${encodeURIComponent(name)}/secrets`, values);
1675
+ }
1676
+ async deleteFunctionSecret(name, key) {
1677
+ return this.request('DELETE', `/api/v1/functions/${encodeURIComponent(name)}/secrets/${encodeURIComponent(key)}`);
1678
+ }
1609
1679
  /**
1610
1680
  * Dry-run access check (`POST /api/v1/security/check`). Returns `effect` and optional `matched_policy_id`.
1611
1681
  * Useful for debugging policies. Actions: `read`, `write`, `delete`, `list`, `unquery`.
@@ -2025,7 +2095,9 @@ class XCiteDBClient {
2025
2095
  }
2026
2096
  else if (third !== undefined && typeof third === 'object') {
2027
2097
  include_content = third.includeContent ?? false;
2028
- match_start = third.matchStart;
2098
+ // Accept both casings: matchStart (camelCase, our convention) and match_start
2099
+ // (snake_case, matching XCiteQuery and the wire field). camelCase wins on conflict.
2100
+ match_start = third.matchStart ?? third.match_start;
2029
2101
  }
2030
2102
  const body = {
2031
2103
  from,
@@ -2478,6 +2550,33 @@ class XCiteDBClient {
2478
2550
  async appendItem(identifier, item, path = '', opts) {
2479
2551
  return this.appendMeta(identifier, [item], path, opts);
2480
2552
  }
2553
+ /**
2554
+ * Atomic single-item removal — sibling to {@link appendItem}. Resolves to true when
2555
+ * the item was found and removed, false (HTTP 404) when no match. Behavior depends on
2556
+ * the meta shape at `path`:
2557
+ * - object → drops the field named `itemKey` (siblings untouched).
2558
+ * - array → drops entries equal to `itemKey` (string), or whose `id`/`item_id`
2559
+ * matches `itemKey`.
2560
+ * Read+filter+write happens server-side inside one write txn so concurrent removes
2561
+ * on the same key elect exactly one winner — use this instead of read-then-set on the
2562
+ * client to avoid the race-loser cleanup the convention warns about.
2563
+ */
2564
+ async removeItem(identifier, itemKey, path = '', opts) {
2565
+ const body = {
2566
+ identifier: this.isoPrefixId(identifier),
2567
+ item_key: itemKey,
2568
+ path,
2569
+ };
2570
+ try {
2571
+ const r = await this.request('DELETE', '/api/v1/meta/item', body, undefined, { contextOverride: opts?.context });
2572
+ return r?.ok !== false;
2573
+ }
2574
+ catch (e) {
2575
+ if (e instanceof types_1.XCiteDBError && e.status === 404)
2576
+ return false;
2577
+ throw e;
2578
+ }
2579
+ }
2481
2580
  /** Convenience: push a single item via query. Wraps `item` in `[item]` and calls {@link appendMetaByQuery}. */
2482
2581
  async appendItemByQuery(query, item, path = '', firstMatch = false, opts) {
2483
2582
  return this.appendMetaByQuery(query, [item], path, firstMatch, opts);
@@ -2485,6 +2584,14 @@ class XCiteDBClient {
2485
2584
  async queryMeta(identifier, path = '', opts) {
2486
2585
  return this.request('GET', `/api/v1/meta${buildQuery({ identifier: this.isoPrefixId(identifier), path })}`, undefined, undefined, { contextOverride: opts?.context });
2487
2586
  }
2587
+ /**
2588
+ * Alias for {@link queryMeta} that pairs by name with {@link addMeta} / {@link appendMeta} /
2589
+ * {@link clearMeta}. With `path` empty this returns the whole top-level meta object — which
2590
+ * by convention is keyed per tool/flow.
2591
+ */
2592
+ async getMeta(identifier, path = '', opts) {
2593
+ return this.queryMeta(identifier, path, opts);
2594
+ }
2488
2595
  async queryMetaByQuery(query, path = '', opts) {
2489
2596
  return this.request('POST', '/api/v1/meta/query', { query: this.isoPrefixQuery(query), path }, undefined, { contextOverride: opts?.context });
2490
2597
  }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { XCiteDBClient } from './client';
2
2
  export { parseAssetUri, formatAssetUri, collectIdentifiersFromText, ASSET_URI_PREFIX } from './assetUri';
3
3
  export { WebSocketSubscription } from './websocket';
4
- 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, SmartDiffRef, SmartDiffResult, SmartDiffStats, DocumentBatchResponse, DocumentBatchResultRow, DocumentExportFormat, DocumentImportFormat, ExportDocumentResult, Flags, ImportDocumentOptions, ImportDocumentResult, JsonDocumentData, JsonDocumentBatchItem, IdentifierChildNode, ListIdentifierChildrenResult, ListIdentifiersResult, LockInfo, AcquireLockOptions, LockConflictBody, LockExpiredBody, LockUnknownBody, MergeConflict, MergeResult, OAuthProviderInfo, OAuthProvidersResponse, OwnedTenantInfo, ProjectInfo, PlatformRegistrationConfig, PlatformWorkspaceOrg, PlatformWorkspacesResponse, ProjectSearchSettings, ProjectSearchSettingsUpdate, ProjectDocConfResponse, AssetGcDryRunResult, AssetHeadResult, AssetListItem, AssetListResponse, AssetMagicLinkListResponse, AssetMagicLinkRecord, AssetMagicLinkResult, AssetShareListEntry, AssetShareListResponse, AssetShareRequest, AssetStorageImport, AssetStorageMount, AssetStorageTarget, AssetStorageTargetType, AssetUnshareRequest, AssetUploadResult, CreateAssetMagicLinkRequest, ListAssetsOptions, ProjectAssetStorageConfig, UploadAssetOptions, PlatformDefaultDocConfResponse, LogEntry, MetaValue, PlatformRegisterResult, PolicyUpdateResponse, PublishConflict, PublishResult, RebaseUserWorkspaceResult, PolicyConditions, PolicyIdentifierPattern, PolicyResources, PolicySubjectInput, PolicySubjects, RagQueryOptions, RagQueryResult, RagStreamEvent, RealtimeEvent, SandboxApiKeyMintResult, SandboxInfo, SandboxMember, SearchIndexingProgress, SecurityConfig, SecurityPolicy, StoredPolicyResponse, StoredTriggerResponse, SubscriptionOptions, TagRecord, TextSearchHit, TextSearchQuery, TextSearchResult, TriggerDefinition, TriggerEvent, TriggerEventsResponse, TxnOperation, TxnOperationResult, TxnPrecondition, TxnPreconditionResult, TxnRequest, TxnResponse, JwksKey, JwksResponse, VerifyAppUserTokenOptions, TokenPair, UserInfo, UserIsolationConfig, UserIsolationCreateShareParams, UserIsolationOptions, UserIsolationShareMode, UserIsolationShareResult, UserIsolationShareListEntry, UserIsolationShareListResponse, UserIsolationUnshareParams, ShareTarget, ShareDirection, AppUserGroup, AppUserGroupKind, CreateGroupParams, ListGroupsResponse, WorkspaceInfo, WriteDocumentOptions, XmlDocumentBatchItem, CreateSandboxOptions, CreateTestSessionOptions, TestSessionBootstrap, TestSessionBootstrapSummary, TestSessionInfo, XCiteDBClientOptions, XCiteDBErrorExtras, XCiteDBJwtClaims, UnqueryResult, UnqueryTemplate, XCiteQuery, } from './types';
4
+ 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, SmartDiffRef, SmartDiffResult, SmartDiffStats, DocumentBatchResponse, DocumentBatchResultRow, DocumentExportFormat, DocumentImportFormat, ExportDocumentResult, Flags, ImportDocumentOptions, ImportDocumentResult, JsonDocumentData, JsonDocumentBatchItem, IdentifierChildNode, ListIdentifierChildrenResult, ListIdentifiersResult, LockInfo, AcquireLockOptions, LockConflictBody, LockExpiredBody, LockUnknownBody, MergeConflict, MergeResult, OAuthProviderInfo, OAuthProvidersResponse, OwnedTenantInfo, ProjectInfo, PlatformRegistrationConfig, PlatformWorkspaceOrg, PlatformWorkspacesResponse, ProjectSearchSettings, ProjectSearchSettingsUpdate, ProjectDocConfResponse, AssetGcDryRunResult, AssetHeadResult, AssetListItem, AssetListResponse, AssetMagicLinkListResponse, AssetMagicLinkRecord, AssetMagicLinkResult, AssetShareListEntry, AssetShareListResponse, AssetShareRequest, AssetStorageImport, AssetStorageMount, AssetStorageTarget, AssetStorageTargetType, AssetUnshareRequest, AssetUploadResult, CreateAssetMagicLinkRequest, ListAssetsOptions, ProjectAssetStorageConfig, UploadAssetOptions, PlatformDefaultDocConfResponse, LogEntry, MetaValue, PlatformRegisterResult, PolicyUpdateResponse, PublishConflict, PublishResult, RebaseUserWorkspaceResult, PolicyConditions, PolicyIdentifierPattern, PolicyResources, PolicySubjectInput, PolicySubjects, RagQueryOptions, RagQueryResult, RagStreamEvent, RealtimeEvent, SandboxApiKeyMintResult, SandboxInfo, SandboxMember, SearchIndexingProgress, SecurityConfig, SecurityPolicy, StoredPolicyResponse, StoredTriggerResponse, SubscriptionOptions, TagRecord, TextSearchHit, TextSearchQuery, TextSearchResult, TriggerDefinition, TriggerEvent, TriggerEventsResponse, FunctionManifest, FunctionListItem, FunctionDeployRequest, FunctionLimits, FunctionSecretEntry, FunctionSecretsList, TxnOperation, TxnOperationResult, TxnPrecondition, TxnPreconditionResult, TxnRequest, TxnResponse, JwksKey, JwksResponse, VerifyAppUserTokenOptions, TokenPair, UserInfo, UserIsolationConfig, UserIsolationCreateShareParams, UserIsolationOptions, UserIsolationShareMode, UserIsolationShareResult, UserIsolationShareListEntry, UserIsolationShareListResponse, UserIsolationUnshareParams, ShareTarget, ShareDirection, AppUserGroup, AppUserGroupKind, CreateGroupParams, ListGroupsResponse, WorkspaceInfo, WriteDocumentOptions, XmlDocumentBatchItem, CreateSandboxOptions, CreateTestSessionOptions, TestSessionBootstrap, TestSessionBootstrapSummary, TestSessionInfo, XCiteDBClientOptions, XCiteDBErrorExtras, XCiteDBJwtClaims, UnqueryResult, UnqueryTemplate, XCiteQuery, } from './types';
5
5
  export { XCiteDBError, XCiteDBForbiddenError, XCiteDBNotFoundError, XCiteDBAuthError, XCiteDBLockConflictError, } from './types';
package/dist/types.d.ts CHANGED
@@ -1223,6 +1223,93 @@ export interface StoredTriggerResponse {
1223
1223
  trigger_id: string;
1224
1224
  trigger: TriggerDefinition;
1225
1225
  }
1226
+ export interface FunctionLimits {
1227
+ /** Per-invocation fuel budget (0 = use server default). */
1228
+ fuel?: number;
1229
+ /** Per-invocation wall-clock cap in ms (0 = use server default). */
1230
+ wall_ms?: number;
1231
+ /** Per-invocation linear-memory cap in MiB (0 = use server default). */
1232
+ mem_mb?: number;
1233
+ }
1234
+ /**
1235
+ * Wire-format function manifest as surfaced by `GET /api/v1/functions/{name}`.
1236
+ * Note: `wasm_b64` is included only when `?include_wasm=true` was requested
1237
+ * (admin export path); the standard read path returns `wasm_size` instead.
1238
+ * Secret VALUES are NEVER returned by any GET path — `secrets` here is the
1239
+ * capability-list declaration (just names).
1240
+ */
1241
+ export interface FunctionManifest {
1242
+ name: string;
1243
+ version: number;
1244
+ entrypoint: string;
1245
+ /** Phase 2.5: only `"raw_wasm"`. Phase 4 adds `"javy"` (server-compiled JS/TS). */
1246
+ runtime: 'raw_wasm' | 'javy';
1247
+ /** Phase 2.5: only `"as_caller"`. Phase 5 adds `"as_role"`. */
1248
+ identity_mode: 'as_caller' | 'as_role';
1249
+ role?: string;
1250
+ limits: FunctionLimits;
1251
+ /**
1252
+ * Per-function egress allowlist applied by `xcite.fetch`. Hostnames and
1253
+ * `*.example.com` glob patterns; empty = no external HTTP allowed.
1254
+ */
1255
+ egress_allowlist: string[];
1256
+ /**
1257
+ * Capability-style declaration of secret names this function may read at
1258
+ * runtime. Set values via `setFunctionSecrets` — they are never echoed
1259
+ * back. To remove a name from the function's capability set, drop it
1260
+ * from this array on the next deploy AND call `deleteFunctionSecret` for
1261
+ * any orphaned value.
1262
+ */
1263
+ secrets: string[];
1264
+ /**
1265
+ * Non-secret config: URLs, feature flags, model names. Round-trips on
1266
+ * GET — DO NOT put API keys / passwords here.
1267
+ */
1268
+ env: Record<string, string | number | boolean | null>;
1269
+ /** Size of the stored .wasm bytes in bytes. */
1270
+ wasm_size?: number;
1271
+ /** Only present when `getFunction(name, { includeWasm: true })`. */
1272
+ wasm_b64?: string;
1273
+ }
1274
+ /** Compact metadata used by the list endpoint (`GET /api/v1/functions`). */
1275
+ export type FunctionListItem = FunctionManifest;
1276
+ /**
1277
+ * Body for `PUT /api/v1/functions/{name}` (function deploy). The server
1278
+ * fills `name` from the URL path; sending it in the body is ignored.
1279
+ * Validation: `wasm_b64` is required and must decode to a wasm module
1280
+ * starting with the magic header `\\0asm`.
1281
+ */
1282
+ export interface FunctionDeployRequest {
1283
+ version?: number;
1284
+ entrypoint?: string;
1285
+ runtime?: 'raw_wasm' | 'javy';
1286
+ identity_mode?: 'as_caller' | 'as_role';
1287
+ role?: string;
1288
+ limits?: FunctionLimits;
1289
+ egress_allowlist?: string[];
1290
+ secrets?: string[];
1291
+ env?: Record<string, string | number | boolean | null>;
1292
+ /** Required: base64-encoded wasm bytes. */
1293
+ wasm_b64: string;
1294
+ }
1295
+ export interface FunctionSecretEntry {
1296
+ name: string;
1297
+ /** True iff a value is currently stored. Values themselves are never returned. */
1298
+ set: boolean;
1299
+ }
1300
+ export interface FunctionSecretsList {
1301
+ function: string;
1302
+ secrets: FunctionSecretEntry[];
1303
+ /**
1304
+ * Names that have a stored value but are no longer declared in the
1305
+ * manifest's `secrets[]` array. Operators should either re-declare or
1306
+ * delete each one — orphans are unreachable by guests but still take
1307
+ * storage and audit attention.
1308
+ */
1309
+ orphan_secrets?: string[];
1310
+ /** "project" | "sealed" | "none" — which encryption backend the server picked. */
1311
+ backend: string;
1312
+ }
1226
1313
  /** Named snapshot on a workspace (checkpoint). */
1227
1314
  export interface CheckpointRecord {
1228
1315
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xcitedbs/client",
3
- "version": "0.3.11",
3
+ "version": "0.3.12",
4
4
  "description": "XCiteDB BaaS client SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",