@byline/client 3.9.0 → 3.10.1
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/collection-handle.d.ts +18 -2
- package/dist/collection-handle.js +43 -0
- package/dist/index.d.ts +2 -2
- package/dist/types.d.ts +16 -0
- package/package.json +4 -4
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) Infonomic Company Limited
|
|
7
7
|
*/
|
|
8
|
-
import type { ChangeStatusResult, CollectionDefinition, CreateDocumentResult, DeleteDocumentResult, RestoreVersionResult, UnpublishResult, UpdateDocumentResult } from '@byline/core';
|
|
8
|
+
import type { AuditLogPage, ChangeStatusResult, CollectionDefinition, CreateDocumentResult, DeleteDocumentResult, RestoreVersionResult, UnpublishResult, UpdateDocumentResult } from '@byline/core';
|
|
9
9
|
import type { BylineClient } from './client.js';
|
|
10
|
-
import type { ClientDocument, CreateOptions, FindByIdOptions, FindByPathOptions, FindByVersionOptions, FindOneOptions, FindOptions, FindResult, HistoryOptions, UpdateOptions } from './types.js';
|
|
10
|
+
import type { AuditLogOptions, ClientDocument, CreateOptions, FindByIdOptions, FindByPathOptions, FindByVersionOptions, FindOneOptions, FindOptions, FindResult, HistoryOptions, UpdateOptions } from './types.js';
|
|
11
11
|
/**
|
|
12
12
|
* A handle scoped to a single collection. Provides read (and eventually write)
|
|
13
13
|
* operations against that collection's documents.
|
|
@@ -123,6 +123,22 @@ export declare class CollectionHandle {
|
|
|
123
123
|
* mapped to the same `{ docs, meta }` envelope `find()` returns.
|
|
124
124
|
*/
|
|
125
125
|
history<F = Record<string, any>>(documentId: string, options?: HistoryOptions): Promise<FindResult<F>>;
|
|
126
|
+
/**
|
|
127
|
+
* Fetch the document-grain audit log for a single document (docs/AUDIT.md —
|
|
128
|
+
* Workstream 3): the non-versioned system-field writes (path,
|
|
129
|
+
* available-locales), in-place status transitions, and the deletion event
|
|
130
|
+
* the immutable version stream deliberately does not record an actor for.
|
|
131
|
+
*
|
|
132
|
+
* Applies `beforeRead` as an access gate via `findById` — exactly as
|
|
133
|
+
* `history()` does — so an actor who cannot see the document at all gets an
|
|
134
|
+
* empty log rather than leaking change metadata. Entries are newest-first.
|
|
135
|
+
* Actor *ids* are returned raw; resolving them to display labels is an
|
|
136
|
+
* admin-realm concern handled above the SDK.
|
|
137
|
+
*
|
|
138
|
+
* Returns an empty page when the adapter has no audit-query capability
|
|
139
|
+
* (`queries.audit` absent) — the same graceful shape as a gated-out read.
|
|
140
|
+
*/
|
|
141
|
+
auditLog(documentId: string, options?: AuditLogOptions): Promise<AuditLogPage>;
|
|
126
142
|
/**
|
|
127
143
|
* Fetch a specific version of a document by its `documentVersionId`.
|
|
128
144
|
* Used by admin diff views.
|
|
@@ -358,6 +358,49 @@ export class CollectionHandle {
|
|
|
358
358
|
},
|
|
359
359
|
};
|
|
360
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* Fetch the document-grain audit log for a single document (docs/AUDIT.md —
|
|
363
|
+
* Workstream 3): the non-versioned system-field writes (path,
|
|
364
|
+
* available-locales), in-place status transitions, and the deletion event
|
|
365
|
+
* the immutable version stream deliberately does not record an actor for.
|
|
366
|
+
*
|
|
367
|
+
* Applies `beforeRead` as an access gate via `findById` — exactly as
|
|
368
|
+
* `history()` does — so an actor who cannot see the document at all gets an
|
|
369
|
+
* empty log rather than leaking change metadata. Entries are newest-first.
|
|
370
|
+
* Actor *ids* are returned raw; resolving them to display labels is an
|
|
371
|
+
* admin-realm concern handled above the SDK.
|
|
372
|
+
*
|
|
373
|
+
* Returns an empty page when the adapter has no audit-query capability
|
|
374
|
+
* (`queries.audit` absent) — the same graceful shape as a gated-out read.
|
|
375
|
+
*/
|
|
376
|
+
async auditLog(documentId, options = {}) {
|
|
377
|
+
await this.resolveAndAssertRead();
|
|
378
|
+
const readCtx = options._readContext ?? createReadContext();
|
|
379
|
+
const locale = options.locale ?? this.client.defaultLocale;
|
|
380
|
+
const page = options.page ?? 1;
|
|
381
|
+
const pageSize = options.pageSize ?? 20;
|
|
382
|
+
const empty = { entries: [], meta: { total: 0, page, pageSize, totalPages: 0 } };
|
|
383
|
+
// Access gate — same rationale as `history()`. `status: 'any'` asks "can
|
|
384
|
+
// the actor see *any* version of this document?", so a draft-only doc with
|
|
385
|
+
// the owning actor still surfaces its audit log.
|
|
386
|
+
if (!options._bypassBeforeRead) {
|
|
387
|
+
const accessible = await this.findById(documentId, {
|
|
388
|
+
locale,
|
|
389
|
+
status: 'any',
|
|
390
|
+
_readContext: readCtx,
|
|
391
|
+
});
|
|
392
|
+
if (accessible == null)
|
|
393
|
+
return empty;
|
|
394
|
+
}
|
|
395
|
+
const audit = this.client.db.queries.audit;
|
|
396
|
+
if (audit == null)
|
|
397
|
+
return empty;
|
|
398
|
+
return audit.getDocumentAuditLog({
|
|
399
|
+
document_id: documentId,
|
|
400
|
+
page,
|
|
401
|
+
page_size: pageSize,
|
|
402
|
+
});
|
|
403
|
+
}
|
|
361
404
|
/**
|
|
362
405
|
* Fetch a specific version of a document by its `documentVersionId`.
|
|
363
406
|
* Used by admin diff views.
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) Infonomic Company Limited
|
|
7
7
|
*/
|
|
8
|
-
export { type ChangeStatusResult, type CreateDocumentResult, type CycleRelationValue, createReadContext, type DeleteDocumentResult, ERR_CONFLICT, ERR_INVALID_TRANSITION, ERR_NOT_FOUND, ERR_READ_BUDGET_EXCEEDED, ERR_VALIDATION, type PopulatedRelationValue, type PopulateFieldOptions, type PopulateFieldSpec, type PopulateMap, type PopulateSpec, type ReadContext, type ReadMode, type RestoreVersionResult, type UnpublishResult, type UnresolvedRelationValue, type UpdateDocumentResult, } from '@byline/core';
|
|
8
|
+
export { type AuditLogEntry, type AuditLogPage, type ChangeStatusResult, type CreateDocumentResult, type CycleRelationValue, createReadContext, type DeleteDocumentResult, ERR_CONFLICT, ERR_INVALID_TRANSITION, ERR_NOT_FOUND, ERR_READ_BUDGET_EXCEEDED, ERR_VALIDATION, type PopulatedRelationValue, type PopulateFieldOptions, type PopulateFieldSpec, type PopulateMap, type PopulateSpec, type ReadContext, type ReadMode, type RestoreVersionResult, type UnpublishResult, type UnresolvedRelationValue, type UpdateDocumentResult, } from '@byline/core';
|
|
9
9
|
export { BylineClient, createBylineClient } from './client.js';
|
|
10
10
|
export { CollectionHandle } from './collection-handle.js';
|
|
11
|
-
export type { BylineClientConfig, ClientDocument, CreateOptions, FilterOperators, FindByIdOptions, FindByPathOptions, FindOneOptions, FindOptions, FindResult, PopulatedRelation, SortDirection, SortSpec, UpdateOptions, WhereClause, WhereValue, WithPopulated, } from './types.js';
|
|
11
|
+
export type { AuditLogOptions, BylineClientConfig, ClientDocument, CreateOptions, FilterOperators, FindByIdOptions, FindByPathOptions, FindOneOptions, FindOptions, FindResult, PopulatedRelation, SortDirection, SortSpec, UpdateOptions, WhereClause, WhereValue, WithPopulated, } from './types.js';
|
package/dist/types.d.ts
CHANGED
|
@@ -229,6 +229,22 @@ export interface HistoryOptions extends BeforeReadControls {
|
|
|
229
229
|
/** @internal — see `_readContext` on read options. */
|
|
230
230
|
_readContext?: ReadContext;
|
|
231
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Options for `CollectionHandle.auditLog(documentId, options)`. The
|
|
234
|
+
* document-grain audit log (docs/AUDIT.md — Workstream 3) records the
|
|
235
|
+
* non-versioned changes the immutable version stream does not capture an
|
|
236
|
+
* actor for: system-field writes (path, available-locales), in-place status
|
|
237
|
+
* transitions, and the deletion event. Entries are newest-first and paged;
|
|
238
|
+
* `_bypassBeforeRead` skips the `findById` access gate for admin tooling.
|
|
239
|
+
*/
|
|
240
|
+
export interface AuditLogOptions extends BeforeReadControls {
|
|
241
|
+
page?: number;
|
|
242
|
+
pageSize?: number;
|
|
243
|
+
/** Locale used by the access-gate `findById`. Defaults to the client's `defaultLocale`. */
|
|
244
|
+
locale?: string;
|
|
245
|
+
/** @internal — see `_readContext` on read options. */
|
|
246
|
+
_readContext?: ReadContext;
|
|
247
|
+
}
|
|
232
248
|
/**
|
|
233
249
|
* Options for `CollectionHandle.findByVersion(versionId, options)`. No
|
|
234
250
|
* `BeforeReadControls` — `findByVersion` is a low-level pass-through
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@byline/client",
|
|
3
3
|
"private": false,
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
|
-
"version": "3.
|
|
5
|
+
"version": "3.10.1",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=20.9.0"
|
|
8
8
|
},
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"npm-run-all": "^4.1.5",
|
|
41
|
-
"@byline/auth": "3.
|
|
42
|
-
"@byline/core": "3.
|
|
41
|
+
"@byline/auth": "3.10.1",
|
|
42
|
+
"@byline/core": "3.10.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@biomejs/biome": "2.4.15",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"tsx": "^4.22.3",
|
|
52
52
|
"typescript": "6.0.3",
|
|
53
53
|
"vitest": "^4.1.7",
|
|
54
|
-
"@byline/db-postgres": "3.
|
|
54
|
+
"@byline/db-postgres": "3.10.1"
|
|
55
55
|
},
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public",
|