@byline/client 3.20.3 → 3.21.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/client.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, RichTextPopulateFn, RichTextToTextFn, SearchProvider, SlugifierFn } from '@byline/core';
9
+ import type { BylineLogger, CollectionDefinition, CollectionRegistry, IDbAdapter, IStorageProvider, RichTextPopulateFn, RichTextToTextFn, SearchProvider, SlugifierFn } from '@byline/core';
10
10
  import { CollectionHandle } from './collection-handle.js';
11
11
  import type { BylineClientConfig, ClientSearchResults, ZoneSearchOptions } from './types.js';
12
12
  /**
@@ -14,9 +14,9 @@ import type { BylineClientConfig, ClientSearchResults, ZoneSearchOptions } from
14
14
  * definitions, and optional storage provider. Use `collection(path)` to get
15
15
  * a scoped handle for querying and mutating documents.
16
16
  */
17
- export declare class BylineClient {
17
+ export declare class BylineClient<TRegistry extends CollectionRegistry = CollectionRegistry> {
18
18
  readonly db: IDbAdapter;
19
- readonly collections: CollectionDefinition[];
19
+ readonly collections: readonly CollectionDefinition[];
20
20
  readonly storage: IStorageProvider | undefined;
21
21
  readonly logger: BylineLogger;
22
22
  readonly defaultLocale: string;
@@ -54,7 +54,7 @@ export declare class BylineClient {
54
54
  * Get a handle scoped to a single collection. All subsequent read/write
55
55
  * operations on the handle are performed against this collection.
56
56
  */
57
- collection(path: string): CollectionHandle;
57
+ collection<TPath extends keyof TRegistry & string>(path: TPath): CollectionHandle<TRegistry[TPath]>;
58
58
  /**
59
59
  * Resolve a collection path to its database row id and current schema
60
60
  * version. Cached for the lifetime of this client instance. The version
@@ -73,4 +73,4 @@ export declare class BylineClient {
73
73
  /**
74
74
  * Create a new Byline client instance.
75
75
  */
76
- export declare function createBylineClient(config: BylineClientConfig): BylineClient;
76
+ export declare function createBylineClient<TRegistry extends CollectionRegistry = CollectionRegistry>(config: BylineClientConfig): BylineClient<TRegistry>;
@@ -14,10 +14,10 @@ import type { AuditLogOptions, ClientDocument, ClientSearchResults, CollectionSe
14
14
  *
15
15
  * Created via `client.collection('posts')`.
16
16
  */
17
- export declare class CollectionHandle {
17
+ export declare class CollectionHandle<TFields extends Record<string, any> = Record<string, any>> {
18
18
  private client;
19
19
  private definition;
20
- constructor(client: BylineClient, definition: CollectionDefinition);
20
+ constructor(client: BylineClient<any>, definition: CollectionDefinition);
21
21
  /**
22
22
  * Find documents with optional filtering, sorting, pagination, and field
23
23
  * selection.
@@ -27,12 +27,12 @@ export declare class CollectionHandle {
27
27
  * (EXISTS subqueries against EAV store tables), and field-level sorting
28
28
  * (LATERAL JOINs).
29
29
  */
30
- find<F = Record<string, any>>(options?: FindOptions<F>): Promise<FindResult<F>>;
30
+ find<F = TFields>(options?: FindOptions<F>): Promise<FindResult<F>>;
31
31
  /**
32
32
  * Find a single document matching the given options. Returns `null` if no
33
33
  * document matches.
34
34
  */
35
- findOne<F = Record<string, any>>(options?: FindOneOptions<F>): Promise<ClientDocument<F> | null>;
35
+ findOne<F = TFields>(options?: FindOneOptions<F>): Promise<ClientDocument<F> | null>;
36
36
  /**
37
37
  * Ranked full-text search scoped to this collection, delegated to the
38
38
  * registered `SearchProvider` (see `ServerConfig.search`). Returns the
@@ -96,13 +96,13 @@ export declare class CollectionHandle {
96
96
  /**
97
97
  * Find a document by its logical document ID.
98
98
  */
99
- findById<F = Record<string, any>>(documentId: string, options?: FindByIdOptions<F>): Promise<ClientDocument<F> | null>;
99
+ findById<F = TFields>(documentId: string, options?: FindByIdOptions<F>): Promise<ClientDocument<F> | null>;
100
100
  /**
101
101
  * Find a document by its URL path/slug. Returns `null` when no document
102
102
  * exists at the given path (the storage adapter resolves missing paths
103
103
  * to `null` rather than throwing).
104
104
  */
105
- findByPath<F = Record<string, any>>(path: string, options?: FindByPathOptions<F>): Promise<ClientDocument<F> | null>;
105
+ findByPath<F = TFields>(path: string, options?: FindByPathOptions<F>): Promise<ClientDocument<F> | null>;
106
106
  /**
107
107
  * Create a new document in this collection.
108
108
  *
@@ -182,7 +182,7 @@ export declare class CollectionHandle {
182
182
  * mirrors the storage adapter's `{ documents, meta }` shape, then is
183
183
  * mapped to the same `{ docs, meta }` envelope `find()` returns.
184
184
  */
185
- history<F = Record<string, any>>(documentId: string, options?: HistoryOptions): Promise<FindResult<F>>;
185
+ history<F = TFields>(documentId: string, options?: HistoryOptions): Promise<FindResult<F>>;
186
186
  /**
187
187
  * Fetch the document-grain audit log for a single document (docs/06-auth-and-security/02-auditability.md —
188
188
  * Workstream 3): the non-versioned system-field writes (path,
@@ -210,7 +210,7 @@ export declare class CollectionHandle {
210
210
  * expected to have already passed an access check on the parent
211
211
  * document. Use `history()` instead if you want the access gate.
212
212
  */
213
- findByVersion<F = Record<string, any>>(versionId: string, options?: FindByVersionOptions<F>): Promise<ClientDocument<F> | null>;
213
+ findByVersion<F = TFields>(versionId: string, options?: FindByVersionOptions<F>): Promise<ClientDocument<F> | null>;
214
214
  /**
215
215
  * Place or move a document within this collection's tree — a single upsert
216
216
  * covering place, reorder, and re-parent (they differ only in whether the
@@ -236,7 +236,7 @@ export declare class CollectionHandle {
236
236
  * `'published'` (the client default) — an unpublished node hides its whole
237
237
  * subtree in that mode.
238
238
  */
239
- getSubtree<F = Record<string, any>>(options?: GetSubtreeOptions<F>): Promise<TreeNode<F>[]>;
239
+ getSubtree<F = TFields>(options?: GetSubtreeOptions<F>): Promise<TreeNode<F>[]>;
240
240
  /**
241
241
  * Walk a document's ancestor chain upward, returning the ancestors
242
242
  * **root-first** (the breadcrumb trail, excluding the node itself), hydrated
@@ -245,7 +245,7 @@ export declare class CollectionHandle {
245
245
  * truncated chain), so a broken spine surfaces as a short chain the caller can
246
246
  * detect rather than a silently-compacted one.
247
247
  */
248
- getAncestors<F = Record<string, any>>(documentId: string, options?: GetAncestorsOptions<F>): Promise<ClientDocument<F>[]>;
248
+ getAncestors<F = TFields>(documentId: string, options?: GetAncestorsOptions<F>): Promise<ClientDocument<F>[]>;
249
249
  /**
250
250
  * Resolve a document's placement state in the tree — the tri-state that
251
251
  * `getAncestors` cannot express (it returns `[]` for both a root and an
package/dist/search.d.ts CHANGED
@@ -21,7 +21,7 @@ import type { ReadContext, ReadMode, SearchHit } from '@byline/core';
21
21
  import type { BylineClient } from './client.js';
22
22
  import type { ClientSearchResults, HydratedSearchHit, ZoneSearchOptions } from './types.js';
23
23
  export interface FinalizeSearchHitsParams {
24
- client: BylineClient;
24
+ client: BylineClient<any>;
25
25
  requestContext: RequestContext;
26
26
  hits: SearchHit[];
27
27
  locale?: string;
@@ -57,4 +57,4 @@ export declare function finalizeSearchHits(params: FinalizeSearchHitsParams): Pr
57
57
  * `ERR_VALIDATION` for a zone no collection indexes into; rethrows the
58
58
  * ability error only when the actor can read none of the members.
59
59
  */
60
- export declare function zoneSearch(client: BylineClient, options: ZoneSearchOptions): Promise<ClientSearchResults>;
60
+ export declare function zoneSearch(client: BylineClient<any>, options: ZoneSearchOptions): Promise<ClientSearchResults>;
package/dist/types.d.ts CHANGED
@@ -31,7 +31,7 @@ export interface BylineClientConfig {
31
31
  /** The database adapter (e.g. from @byline/db-postgres). Required when `config` is omitted. */
32
32
  db?: IDbAdapter;
33
33
  /** All registered collection definitions. Required when `config` is omitted. */
34
- collections?: CollectionDefinition[];
34
+ collections?: readonly CollectionDefinition[];
35
35
  /** Optional storage provider — needed for delete file cleanup. */
36
36
  storage?: IStorageProvider;
37
37
  /**
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.20.3",
5
+ "version": "3.21.0",
6
6
  "engines": {
7
7
  "node": ">=20.9.0"
8
8
  },
@@ -37,8 +37,8 @@
37
37
  "dist"
38
38
  ],
39
39
  "dependencies": {
40
- "@byline/auth": "3.20.3",
41
- "@byline/core": "3.20.3"
40
+ "@byline/auth": "3.21.0",
41
+ "@byline/core": "3.21.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@biomejs/biome": "2.5.2",
@@ -51,8 +51,8 @@
51
51
  "tsx": "^4.23.0",
52
52
  "typescript": "^7.0.2",
53
53
  "vitest": "^4.1.10",
54
- "@byline/db-postgres": "3.20.3",
55
- "@byline/search-postgres": "3.20.3"
54
+ "@byline/db-postgres": "3.21.0",
55
+ "@byline/search-postgres": "3.21.0"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public",