@byline/client 1.0.0 → 1.2.0
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 +13 -1
- package/dist/collection-handle.js +16 -1
- package/dist/index.d.ts +1 -1
- package/package.json +4 -4
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) Infonomic Company Limited
|
|
7
7
|
*/
|
|
8
|
-
import type { ChangeStatusResult, CollectionDefinition, CreateDocumentResult, DeleteDocumentResult, UnpublishResult, UpdateDocumentResult } from '@byline/core';
|
|
8
|
+
import type { ChangeStatusResult, CollectionDefinition, CreateDocumentResult, DeleteDocumentResult, RestoreVersionResult, UnpublishResult, UpdateDocumentResult } from '@byline/core';
|
|
9
9
|
import type { BylineClient } from './client.js';
|
|
10
10
|
import type { ClientDocument, CreateOptions, FindByIdOptions, FindByPathOptions, FindByVersionOptions, FindOneOptions, FindOptions, FindResult, HistoryOptions, UpdateOptions } from './types.js';
|
|
11
11
|
/**
|
|
@@ -68,6 +68,18 @@ export declare class CollectionHandle {
|
|
|
68
68
|
* Archive the currently-published version(s) of a document.
|
|
69
69
|
*/
|
|
70
70
|
unpublish(documentId: string): Promise<UnpublishResult>;
|
|
71
|
+
/**
|
|
72
|
+
* Restore a historical version as the new current version of this
|
|
73
|
+
* document. Creates a new immutable version row whose content is copied
|
|
74
|
+
* from the source version (all locales, with block / array `_id` identity
|
|
75
|
+
* preserved) and whose status defaults to the workflow's first status —
|
|
76
|
+
* never re-publishes silently.
|
|
77
|
+
*
|
|
78
|
+
* Reuses the `update` ability. Fires `beforeUpdate` / `afterUpdate` with
|
|
79
|
+
* a `restore: { sourceVersionId }` field on the hook context so userland
|
|
80
|
+
* hooks can branch.
|
|
81
|
+
*/
|
|
82
|
+
restoreVersion(documentId: string, sourceVersionId: string): Promise<RestoreVersionResult>;
|
|
71
83
|
/**
|
|
72
84
|
* Soft-delete a document. All versions are flagged `is_deleted = true`
|
|
73
85
|
* and disappear from read paths (the `current_documents` view filters
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) Infonomic Company Limited
|
|
7
7
|
*/
|
|
8
|
-
import { applyAfterRead, applyBeforeRead, assertActorCanPerform, changeDocumentStatus, createDocument, createReadContext, deleteDocument, mergePredicates, parseSort, parseWhere, populateDocuments, populateRichTextFields, unpublishDocument, updateDocument, } from '@byline/core';
|
|
8
|
+
import { applyAfterRead, applyBeforeRead, assertActorCanPerform, changeDocumentStatus, createDocument, createReadContext, deleteDocument, mergePredicates, parseSort, parseWhere, populateDocuments, populateRichTextFields, restoreDocumentVersion, unpublishDocument, updateDocument, } from '@byline/core';
|
|
9
9
|
import { shapeDocument, shapePopulatedInPlace } from './response.js';
|
|
10
10
|
/**
|
|
11
11
|
* A handle scoped to a single collection. Provides read (and eventually write)
|
|
@@ -234,6 +234,21 @@ export class CollectionHandle {
|
|
|
234
234
|
const ctx = await this.buildLifecycleContext();
|
|
235
235
|
return unpublishDocument(ctx, { documentId });
|
|
236
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* Restore a historical version as the new current version of this
|
|
239
|
+
* document. Creates a new immutable version row whose content is copied
|
|
240
|
+
* from the source version (all locales, with block / array `_id` identity
|
|
241
|
+
* preserved) and whose status defaults to the workflow's first status —
|
|
242
|
+
* never re-publishes silently.
|
|
243
|
+
*
|
|
244
|
+
* Reuses the `update` ability. Fires `beforeUpdate` / `afterUpdate` with
|
|
245
|
+
* a `restore: { sourceVersionId }` field on the hook context so userland
|
|
246
|
+
* hooks can branch.
|
|
247
|
+
*/
|
|
248
|
+
async restoreVersion(documentId, sourceVersionId) {
|
|
249
|
+
const ctx = await this.buildLifecycleContext();
|
|
250
|
+
return restoreDocumentVersion(ctx, { documentId, sourceVersionId });
|
|
251
|
+
}
|
|
237
252
|
/**
|
|
238
253
|
* Soft-delete a document. All versions are flagged `is_deleted = true`
|
|
239
254
|
* and disappear from read paths (the `current_documents` view filters
|
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 UnpublishResult, type UnresolvedRelationValue, type UpdateDocumentResult, } from '@byline/core';
|
|
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';
|
|
9
9
|
export { BylineClient, createBylineClient } from './client.js';
|
|
10
10
|
export { CollectionHandle } from './collection-handle.js';
|
|
11
11
|
export type { BylineClientConfig, ClientDocument, CreateOptions, FilterOperators, FindByIdOptions, FindByPathOptions, FindOneOptions, FindOptions, FindResult, PopulatedRelation, SortDirection, SortSpec, UpdateOptions, WhereClause, WhereValue, WithPopulated, } from './types.js';
|
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": "1.
|
|
5
|
+
"version": "1.2.0",
|
|
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": "1.
|
|
42
|
-
"@byline/core": "1.
|
|
41
|
+
"@byline/auth": "1.2.0",
|
|
42
|
+
"@byline/core": "1.2.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@biomejs/biome": "2.4.14",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"tsx": "^4.21.0",
|
|
52
52
|
"typescript": "6.0.3",
|
|
53
53
|
"vitest": "^4.1.5",
|
|
54
|
-
"@byline/db-postgres": "1.
|
|
54
|
+
"@byline/db-postgres": "1.2.0"
|
|
55
55
|
},
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public",
|