@xcitedbs/client 0.2.25 → 0.2.26
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 +3 -1
- package/dist/client.js +16 -4
- package/dist/client.test.js +22 -0
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +28 -0
- 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, 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, StoredPolicyResponse, SubscriptionOptions, TagRecord, TextSearchQuery, TextSearchResult, ProjectSearchSettings, ProjectSearchSettingsUpdate, ProjectDocConfResponse, AssetGcDryRunResult, AssetHeadResult, AssetMagicLinkListResponse, AssetMagicLinkResult, AssetShareListResponse, AssetShareRequest, AssetUnshareRequest, AssetUploadResult, CreateAssetMagicLinkRequest, 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 } from './types';
|
|
1
|
+
import { AccessCheckResult, AppAuthConfig, AppEmailConfig, AppEmailTemplates, AppUser, AppUserTokenPair, EmailTestResponse, ForgotPasswordResponse, SendVerificationResponse, BranchInfo, BookmarkRecord, CheckpointRecord, CommitRecord, CompareRef, CompareResult, DatabaseContext, DiffRef, DiffResult, 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, StoredPolicyResponse, 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 } from './types';
|
|
2
2
|
import { WebSocketSubscription } from './websocket';
|
|
3
3
|
export declare class XCiteDBClient {
|
|
4
4
|
private baseUrl;
|
|
@@ -686,6 +686,8 @@ export declare class XCiteDBClient {
|
|
|
686
686
|
headAsset(uriOrIdentifier: string, opts?: {
|
|
687
687
|
ml?: string;
|
|
688
688
|
}): Promise<AssetHeadResult>;
|
|
689
|
+
/** `GET /api/v1/assets` — paginated, ABAC-filtered listing. Magic-link auth is rejected by the server. */
|
|
690
|
+
listAssets(opts?: ListAssetsOptions): Promise<AssetListResponse>;
|
|
689
691
|
/** Admin: GC dry-run — manifest vs live meta references (`POST /api/v1/admin/assets/gc/dry-run`). */
|
|
690
692
|
adminAssetsGcDryRun(opts?: {
|
|
691
693
|
ownerUserId?: string;
|
package/dist/client.js
CHANGED
|
@@ -1636,8 +1636,7 @@ class XCiteDBClient {
|
|
|
1636
1636
|
filter,
|
|
1637
1637
|
path_filter: pathFilter,
|
|
1638
1638
|
});
|
|
1639
|
-
|
|
1640
|
-
return Array.isArray(rows) ? rows.map((x) => this.isoUnprefixId(String(x))) : rows;
|
|
1639
|
+
return this.request('GET', `/api/v1/documents/by-id${q}`);
|
|
1641
1640
|
}
|
|
1642
1641
|
/**
|
|
1643
1642
|
* Shallow read (`flags=NoChildren,KeepIndexNodes,FirstMatch` on `GET /api/v1/documents/by-id`):
|
|
@@ -1682,8 +1681,7 @@ class XCiteDBClient {
|
|
|
1682
1681
|
if (pq.filter_any_meta === true) {
|
|
1683
1682
|
params.any_meta = '1';
|
|
1684
1683
|
}
|
|
1685
|
-
|
|
1686
|
-
return Array.isArray(rows) ? rows.map((x) => this.isoUnprefixId(String(x))) : rows;
|
|
1684
|
+
return this.request('GET', `/api/v1/documents${buildQuery(params)}`);
|
|
1687
1685
|
}
|
|
1688
1686
|
async deleteDocument(identifier) {
|
|
1689
1687
|
await this.request('DELETE', `/api/v1/documents/by-id${buildQuery({ identifier: this.isoPrefixId(identifier) })}`);
|
|
@@ -2265,6 +2263,20 @@ class XCiteDBClient {
|
|
|
2265
2263
|
this.notifySessionInvalidIfNeeded(path, 401);
|
|
2266
2264
|
throw new types_1.XCiteDBError('Request failed after retry', 401, null);
|
|
2267
2265
|
}
|
|
2266
|
+
/** `GET /api/v1/assets` — paginated, ABAC-filtered listing. Magic-link auth is rejected by the server. */
|
|
2267
|
+
async listAssets(opts) {
|
|
2268
|
+
const params = {};
|
|
2269
|
+
if (opts?.prefix)
|
|
2270
|
+
params.prefix = opts.prefix;
|
|
2271
|
+
if (typeof opts?.limit === 'number')
|
|
2272
|
+
params.limit = String(opts.limit);
|
|
2273
|
+
if (opts?.cursor)
|
|
2274
|
+
params.cursor = opts.cursor;
|
|
2275
|
+
if (opts?.includeHeader)
|
|
2276
|
+
params.include_header = 'true';
|
|
2277
|
+
const q = buildQuery(params);
|
|
2278
|
+
return this.request('GET', `/api/v1/assets${q}`, undefined);
|
|
2279
|
+
}
|
|
2268
2280
|
/** Admin: GC dry-run — manifest vs live meta references (`POST /api/v1/admin/assets/gc/dry-run`). */
|
|
2269
2281
|
async adminAssetsGcDryRun(opts) {
|
|
2270
2282
|
const q = opts?.ownerUserId && opts.ownerUserId.trim()
|
package/dist/client.test.js
CHANGED
|
@@ -32,6 +32,28 @@ const types_js_1 = require("./types.js");
|
|
|
32
32
|
globalThis.fetch = orig;
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
|
+
(0, node_test_1.it)('queryByIdentifier / queryDocuments return XML bodies unmodified under userIsolation', async () => {
|
|
36
|
+
const xml = '<?xml version="1.0"?><doc xmlns:db="http://www.xcitedb.com/schema"><a href="https://example.com//path">x</a></doc>';
|
|
37
|
+
const orig = globalThis.fetch;
|
|
38
|
+
globalThis.fetch = node_test_1.mock.fn(async () => {
|
|
39
|
+
return new Response(JSON.stringify([xml]), { status: 200 });
|
|
40
|
+
});
|
|
41
|
+
try {
|
|
42
|
+
const c = new client_js_1.XCiteDBClient({
|
|
43
|
+
baseUrl: 'http://127.0.0.1:9',
|
|
44
|
+
apiKey: 'test-key',
|
|
45
|
+
userIsolation: { enabled: true, namespace: '/users/{userId}' },
|
|
46
|
+
});
|
|
47
|
+
c.setAppUserTokens('header.eyJzdWIiOiJ1c2VyLTEifQ.sig');
|
|
48
|
+
const a = await c.queryByIdentifier('/x');
|
|
49
|
+
strict_1.default.deepEqual(a, [xml]);
|
|
50
|
+
const b = await c.queryDocuments({ match: '/x' });
|
|
51
|
+
strict_1.default.deepEqual(b, [xml]);
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
globalThis.fetch = orig;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
35
57
|
(0, node_test_1.it)('403 becomes XCiteDBForbiddenError with policy_id and request ids', async () => {
|
|
36
58
|
const orig = globalThis.fetch;
|
|
37
59
|
globalThis.fetch = node_test_1.mock.fn(async () => {
|
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, 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, AssetMagicLinkListResponse, AssetMagicLinkRecord, AssetMagicLinkResult, AssetShareListEntry, AssetShareListResponse, AssetShareRequest, AssetStorageImport, AssetStorageMount, AssetStorageTarget, AssetStorageTargetType, AssetUnshareRequest, AssetUploadResult, CreateAssetMagicLinkRequest, ProjectAssetStorageConfig, UploadAssetOptions, PlatformDefaultDocConfResponse, LogEntry, MetaValue, PlatformRegisterResult, PolicyUpdateResponse, PublishConflict, PublishResult, RebaseUserWorkspaceResult, PolicyConditions, PolicyIdentifierPattern, PolicyResources, PolicySubjectInput, PolicySubjects, RagQueryOptions, RagQueryResult, RagStreamEvent, RealtimeEvent, SearchIndexingProgress, SecurityConfig, SecurityPolicy, StoredPolicyResponse, StoredTriggerResponse, SubscriptionOptions, TagRecord, TextSearchHit, TextSearchQuery, TextSearchResult, TriggerDefinition, TokenPair, UserInfo, UserIsolationConfig, UserIsolationCreateShareParams, UserIsolationOptions, UserIsolationShareMode, UserIsolationShareResult, WorkspaceInfo, WriteDocumentOptions, XmlDocumentBatchItem, 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, 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, SearchIndexingProgress, SecurityConfig, SecurityPolicy, StoredPolicyResponse, StoredTriggerResponse, SubscriptionOptions, TagRecord, TextSearchHit, TextSearchQuery, TextSearchResult, TriggerDefinition, TokenPair, UserInfo, UserIsolationConfig, UserIsolationCreateShareParams, UserIsolationOptions, UserIsolationShareMode, UserIsolationShareResult, WorkspaceInfo, WriteDocumentOptions, XmlDocumentBatchItem, 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
|
@@ -194,6 +194,34 @@ export interface AssetHeadResult {
|
|
|
194
194
|
size: number;
|
|
195
195
|
etag?: string;
|
|
196
196
|
}
|
|
197
|
+
/** One row of `GET /api/v1/assets`. Header fields are present only when `include_header=true`. */
|
|
198
|
+
export interface AssetListItem {
|
|
199
|
+
identifier: string;
|
|
200
|
+
uri: string;
|
|
201
|
+
content_type?: string;
|
|
202
|
+
size?: number;
|
|
203
|
+
sha256?: string;
|
|
204
|
+
etag?: string;
|
|
205
|
+
target_name?: string;
|
|
206
|
+
owner_user_id?: string;
|
|
207
|
+
created?: string;
|
|
208
|
+
}
|
|
209
|
+
/** `GET /api/v1/assets` paginated, ABAC-filtered. */
|
|
210
|
+
export interface AssetListResponse {
|
|
211
|
+
items: AssetListItem[];
|
|
212
|
+
next_cursor: string | null;
|
|
213
|
+
}
|
|
214
|
+
/** Options for {@link XCiteDBClient.listAssets}. */
|
|
215
|
+
export interface ListAssetsOptions {
|
|
216
|
+
/** Filter by canonical id prefix (e.g. `/users/abc/assets/`). */
|
|
217
|
+
prefix?: string;
|
|
218
|
+
/** Page size, 1..1000 (default 200). */
|
|
219
|
+
limit?: number;
|
|
220
|
+
/** Last identifier from previous page (exclusive). */
|
|
221
|
+
cursor?: string;
|
|
222
|
+
/** Include per-asset header fields (`content_type`, `size`, …). */
|
|
223
|
+
includeHeader?: boolean;
|
|
224
|
+
}
|
|
197
225
|
/** `POST /api/v1/admin/assets/gc/dry-run` (admin). */
|
|
198
226
|
export interface AssetGcDryRunResult {
|
|
199
227
|
manifest_count: number;
|