@byline/client 4.14.1 → 4.15.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.
@@ -7,7 +7,7 @@
7
7
  */
8
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 { AuditLogOptions, ClientDocument, ClientSearchResults, CollectionSearchOptions, CreateOptions, FindByIdOptions, FindByPathOptions, FindByVersionOptions, FindOneOptions, FindOptions, FindResult, GetAncestorsOptions, GetSubtreeOptions, GetTreeParentOptions, HistoryOptions, PlaceTreeNodeOptions, ReindexResult, RemoveFromTreeOptions, TreeNode, TreeParentResult, UpdateOptions } from './types.js';
10
+ import type { AuditLogOptions, ClientDocument, ClientSearchResults, CollectionSearchOptions, ConfirmScheduledPublishOptions, CreateOptions, DocumentPublishScheduleInfo, FindByIdOptions, FindByPathOptions, FindByVersionOptions, FindOneOptions, FindOptions, FindResult, GetAncestorsOptions, GetSubtreeOptions, GetTreeParentOptions, HistoryOptions, PlaceTreeNodeOptions, ReindexResult, RemoveFromTreeOptions, SchedulePublishOptions, TreeNode, TreeParentResult, 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.
@@ -124,6 +124,22 @@ export declare class CollectionHandle<TFields extends Record<string, any> = Reco
124
124
  * versions of the same document.
125
125
  */
126
126
  changeStatus(documentId: string, nextStatus: string): Promise<ChangeStatusResult>;
127
+ /**
128
+ * Arm or reschedule publication of the exact current version the caller
129
+ * reviewed. The lifecycle requires both `changeStatus` and `publish` and
130
+ * validates the instant against database time.
131
+ */
132
+ schedulePublish(documentId: string, options: SchedulePublishOptions): Promise<DocumentPublishScheduleInfo>;
133
+ /** Re-authorize a content-edited schedule against the reviewed version. */
134
+ confirmScheduledPublish(documentId: string, options: ConfirmScheduledPublishOptions): Promise<DocumentPublishScheduleInfo>;
135
+ /**
136
+ * Cancel the active schedule. A null result means no schedule remained when
137
+ * the cancellation transaction acquired the row lock; callers must not
138
+ * report that outcome as a successful cancellation.
139
+ */
140
+ cancelScheduledPublish(documentId: string): Promise<DocumentPublishScheduleInfo | null>;
141
+ /** Read the active document-grain schedule under the same two abilities. */
142
+ getScheduledPublish(documentId: string): Promise<DocumentPublishScheduleInfo | null>;
127
143
  /**
128
144
  * Archive the currently-published version(s) of a document.
129
145
  */
@@ -5,10 +5,14 @@
5
5
  *
6
6
  * Copyright (c) Infonomic Company Limited
7
7
  */
8
- import { applyAfterRead, assertActorCanPerform, buildSearchDocument, changeDocumentStatus, createDocument, createReadContext, createRichTextDocumentReader, deleteDocument, ERR_VALIDATION, parseSort, parseWhere, placeTreeNode as placeTreeNodeLifecycle, populateDocuments, populateRichTextFields, removeFromTree as removeFromTreeLifecycle, resolveIdentityField, restoreDocumentVersion, unpublishDocument, updateDocument, } from '@byline/core';
8
+ import { applyAfterRead, assertActorCanPerform, buildSearchDocument, cancelDocumentScheduledPublish, changeDocumentStatus, confirmDocumentScheduledPublish, createDocument, createReadContext, createRichTextDocumentReader, deleteDocument, ERR_VALIDATION, getDocumentScheduledPublish, parseSort, parseWhere, placeTreeNode as placeTreeNodeLifecycle, populateDocuments, populateRichTextFields, removeFromTree as removeFromTreeLifecycle, resolveIdentityField, restoreDocumentVersion, scheduleDocumentPublish, unpublishDocument, updateDocument, } from '@byline/core';
9
9
  import { getReadSecurityDomain, resolveReadRequestContext, resolveReadSecurityFilters, } from './read-context.js';
10
10
  import { shapeDocument, shapePopulatedInPlace } from './response.js';
11
11
  import { assertSearchQueryLength, finalizeSearchHits } from './search.js';
12
+ function toScheduleInfo(schedule) {
13
+ const { executionToken: _executionToken, executionExpiresAt: _executionExpiresAt, ...info } = schedule;
14
+ return info;
15
+ }
12
16
  /**
13
17
  * A handle scoped to a single collection. Provides read (and eventually write)
14
18
  * operations against that collection's documents.
@@ -417,6 +421,36 @@ export class CollectionHandle {
417
421
  const ctx = await this.buildLifecycleContext();
418
422
  return changeDocumentStatus(ctx, { documentId, nextStatus });
419
423
  }
424
+ /**
425
+ * Arm or reschedule publication of the exact current version the caller
426
+ * reviewed. The lifecycle requires both `changeStatus` and `publish` and
427
+ * validates the instant against database time.
428
+ */
429
+ async schedulePublish(documentId, options) {
430
+ const ctx = await this.buildLifecycleContext();
431
+ return toScheduleInfo(await scheduleDocumentPublish(ctx, { documentId, ...options }));
432
+ }
433
+ /** Re-authorize a content-edited schedule against the reviewed version. */
434
+ async confirmScheduledPublish(documentId, options) {
435
+ const ctx = await this.buildLifecycleContext();
436
+ return toScheduleInfo(await confirmDocumentScheduledPublish(ctx, { documentId, ...options }));
437
+ }
438
+ /**
439
+ * Cancel the active schedule. A null result means no schedule remained when
440
+ * the cancellation transaction acquired the row lock; callers must not
441
+ * report that outcome as a successful cancellation.
442
+ */
443
+ async cancelScheduledPublish(documentId) {
444
+ const ctx = await this.buildLifecycleContext();
445
+ const schedule = await cancelDocumentScheduledPublish(ctx, { documentId });
446
+ return schedule == null ? null : toScheduleInfo(schedule);
447
+ }
448
+ /** Read the active document-grain schedule under the same two abilities. */
449
+ async getScheduledPublish(documentId) {
450
+ const ctx = await this.buildLifecycleContext();
451
+ const schedule = await getDocumentScheduledPublish(ctx, { documentId });
452
+ return schedule == null ? null : toScheduleInfo(schedule);
453
+ }
420
454
  /**
421
455
  * Archive the currently-published version(s) of a document.
422
456
  */
package/dist/index.d.ts CHANGED
@@ -9,4 +9,4 @@ export { type AuditLogEntry, type AuditLogPage, type ChangeStatusResult, type Cr
9
9
  export { BylineClient, createBylineClient } from './client.js';
10
10
  export { CollectionHandle } from './collection-handle.js';
11
11
  export type { Register, RegisteredCollections } from './register.js';
12
- export type { AuditLogOptions, BylineClientConfig, ClientDocument, ClientSearchResults, CollectionSearchOptions, CreateOptions, FilterOperators, FindByIdOptions, FindByPathOptions, FindOneOptions, FindOptions, FindResult, GetAncestorsOptions, GetSubtreeOptions, GetTreeParentOptions, HydratedSearchHit, PlaceTreeNodeOptions, PopulatedRelation, ReindexResult, RemoveFromTreeOptions, SearchFacetBucket, SearchHit, SearchResults, SortDirection, SortSpec, TreeNode, TreeParentResult, UpdateOptions, WhereClause, WhereValue, WithPopulated, WithPopulatedMany, ZoneSearchOptions, } from './types.js';
12
+ export type { AuditLogOptions, BylineClientConfig, ClientDocument, ClientSearchResults, CollectionSearchOptions, ConfirmScheduledPublishOptions, CreateOptions, DocumentPublishScheduleInfo, FilterOperators, FindByIdOptions, FindByPathOptions, FindOneOptions, FindOptions, FindResult, GetAncestorsOptions, GetSubtreeOptions, GetTreeParentOptions, HydratedSearchHit, PlaceTreeNodeOptions, PopulatedRelation, ReindexResult, RemoveFromTreeOptions, SchedulePublishOptions, SearchFacetBucket, SearchHit, SearchResults, SortDirection, SortSpec, TreeNode, TreeParentResult, UpdateOptions, WhereClause, WhereValue, WithPopulated, WithPopulatedMany, ZoneSearchOptions, } from './types.js';
package/dist/types.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * Copyright (c) Infonomic Company Limited
7
7
  */
8
8
  import type { RequestContext } from '@byline/auth';
9
- import type { BylineLogger, CollectionDefinition, IDbAdapter, IStorageProvider, MissingLocalePolicy, PopulateSpec, PredicateValue, QueryPredicate, ReadContext, ReadMode, RichTextPopulateFn, RichTextToTextFn, SearchFacetBucket, SearchHit, SearchMatching, SearchProvider, ServerConfig, SlugifierFn, SortSpec } from '@byline/core';
9
+ import type { BylineLogger, CollectionDefinition, DocumentPublishSchedule, IDbAdapter, IStorageProvider, MissingLocalePolicy, PopulateSpec, PredicateValue, QueryPredicate, ReadContext, ReadMode, RichTextPopulateFn, RichTextToTextFn, SearchFacetBucket, SearchHit, SearchMatching, SearchProvider, ServerConfig, SlugifierFn, SortSpec } from '@byline/core';
10
10
  export type { FilterOperators, PredicateValue, QueryPredicate, SearchFacetBucket, SearchHit, SearchProvider, SearchResults, SortDirection, SortSpec, } from '@byline/core';
11
11
  export interface BylineClientConfig {
12
12
  /**
@@ -417,6 +417,23 @@ export interface UpdateOptions {
417
417
  */
418
418
  availableLocales?: string[];
419
419
  }
420
+ /** Optimistic, absolute-time input for `CollectionHandle.schedulePublish()`. */
421
+ export interface SchedulePublishOptions {
422
+ /** ISO instant carrying an explicit UTC offset or `Z`. */
423
+ publishAt: string;
424
+ /** The current version the editor reviewed and intends to publish. */
425
+ expectedVersionId: string;
426
+ }
427
+ /** Reviewed current version used to re-arm a suspended publication. */
428
+ export interface ConfirmScheduledPublishOptions {
429
+ expectedVersionId: string;
430
+ }
431
+ /**
432
+ * Editorial schedule state exposed by the client API. The execution token and
433
+ * its lease expiry are deliberately absent: they are internal fencing
434
+ * credentials owned by the sweep, not document metadata.
435
+ */
436
+ export type DocumentPublishScheduleInfo = Omit<DocumentPublishSchedule, 'executionToken' | 'executionExpiresAt'>;
420
437
  /**
421
438
  * Options for `CollectionHandle.placeTreeNode(documentId, options)`. Places or
422
439
  * moves a node within the collection's single-parent ordered tree — one upsert
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": "4.14.1",
5
+ "version": "4.15.0",
6
6
  "engines": {
7
7
  "node": ">=20.9.0"
8
8
  },
@@ -44,8 +44,8 @@
44
44
  ],
45
45
  "dependencies": {
46
46
  "uuid": "^14.0.2",
47
- "@byline/core": "4.14.1",
48
- "@byline/auth": "4.14.1"
47
+ "@byline/auth": "4.15.0",
48
+ "@byline/core": "4.15.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@biomejs/biome": "2.5.9",
@@ -58,8 +58,8 @@
58
58
  "tsx": "^4.23.12",
59
59
  "typescript": "^7.0.2",
60
60
  "vitest": "^4.1.11",
61
- "@byline/search-postgres": "4.14.1",
62
- "@byline/db-postgres": "4.14.1"
61
+ "@byline/search-postgres": "4.15.0",
62
+ "@byline/db-postgres": "4.15.0"
63
63
  },
64
64
  "publishConfig": {
65
65
  "access": "public",