@byline/client 1.7.7 → 1.8.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.js +5 -5
- package/dist/types.d.ts +12 -5
- package/package.json +4 -4
|
@@ -32,7 +32,7 @@ export class CollectionHandle {
|
|
|
32
32
|
async find(options = {}) {
|
|
33
33
|
const requestContext = await this.resolveAndAssertRead();
|
|
34
34
|
const collectionId = await this.client.resolveCollectionId(this.definition.path);
|
|
35
|
-
const { where, select, sort, locale =
|
|
35
|
+
const { where, select, sort, locale = this.client.defaultLocale, page = 1, pageSize = 20, } = options;
|
|
36
36
|
const readMode = resolveReadMode(options.status);
|
|
37
37
|
const readCtx = options._readContext ?? createReadContext();
|
|
38
38
|
const hookPredicate = await this.resolveBeforeReadPredicate(requestContext, readCtx, options._bypassBeforeRead);
|
|
@@ -107,7 +107,7 @@ export class CollectionHandle {
|
|
|
107
107
|
async findById(documentId, options = {}) {
|
|
108
108
|
const requestContext = await this.resolveAndAssertRead();
|
|
109
109
|
const collectionId = await this.client.resolveCollectionId(this.definition.path);
|
|
110
|
-
const { locale =
|
|
110
|
+
const { locale = this.client.defaultLocale } = options;
|
|
111
111
|
const readMode = resolveReadMode(options.status);
|
|
112
112
|
const readCtx = options._readContext ?? createReadContext();
|
|
113
113
|
const filters = await this.resolveBeforeReadFilters(requestContext, readCtx, options._bypassBeforeRead);
|
|
@@ -147,7 +147,7 @@ export class CollectionHandle {
|
|
|
147
147
|
async findByPath(path, options = {}) {
|
|
148
148
|
const requestContext = await this.resolveAndAssertRead();
|
|
149
149
|
const collectionId = await this.client.resolveCollectionId(this.definition.path);
|
|
150
|
-
const { locale =
|
|
150
|
+
const { locale = this.client.defaultLocale } = options;
|
|
151
151
|
const readMode = resolveReadMode(options.status);
|
|
152
152
|
const readCtx = options._readContext ?? createReadContext();
|
|
153
153
|
const filters = await this.resolveBeforeReadFilters(requestContext, readCtx, options._bypassBeforeRead);
|
|
@@ -308,7 +308,7 @@ export class CollectionHandle {
|
|
|
308
308
|
const _requestContext = await this.resolveAndAssertRead();
|
|
309
309
|
const collectionId = await this.client.resolveCollectionId(this.definition.path);
|
|
310
310
|
const readCtx = options._readContext ?? createReadContext();
|
|
311
|
-
const locale = options.locale ??
|
|
311
|
+
const locale = options.locale ?? this.client.defaultLocale;
|
|
312
312
|
const page = options.page ?? 1;
|
|
313
313
|
const pageSize = options.pageSize ?? 20;
|
|
314
314
|
// Access gate. `findById` runs `beforeRead`; a `null` here means either
|
|
@@ -365,7 +365,7 @@ export class CollectionHandle {
|
|
|
365
365
|
*/
|
|
366
366
|
async findByVersion(versionId, options = {}) {
|
|
367
367
|
await this.resolveAndAssertRead();
|
|
368
|
-
const locale = options.locale ??
|
|
368
|
+
const locale = options.locale ?? this.client.defaultLocale;
|
|
369
369
|
const raw = await this.client.db.queries.documents.getDocumentByVersion({
|
|
370
370
|
document_version_id: versionId,
|
|
371
371
|
locale,
|
package/dist/types.d.ts
CHANGED
|
@@ -42,8 +42,15 @@ export interface BylineClientConfig {
|
|
|
42
42
|
*/
|
|
43
43
|
logger?: BylineLogger;
|
|
44
44
|
/**
|
|
45
|
-
* Default content locale. Forwarded to `DocumentLifecycleContext
|
|
46
|
-
* used to anchor `path` derivation
|
|
45
|
+
* Default content locale. Forwarded to `DocumentLifecycleContext`,
|
|
46
|
+
* used to anchor `path` derivation, and applied as the implicit
|
|
47
|
+
* default for `locale` on every read method (`find`, `findOne`,
|
|
48
|
+
* `findById`, `findByPath`). Resolved in priority order:
|
|
49
|
+
* 1. explicit `defaultLocale` on the client config
|
|
50
|
+
* 2. `config.i18n.content.defaultLocale` when a `ServerConfig` is
|
|
51
|
+
* passed via `config`
|
|
52
|
+
* 3. `'en'` as a last-resort fallback for tests / migration scripts
|
|
53
|
+
* that never configure i18n.
|
|
47
54
|
*/
|
|
48
55
|
defaultLocale?: string;
|
|
49
56
|
/**
|
|
@@ -153,7 +160,7 @@ export interface FindOptions<F = Record<string, any>> extends PopulateControls,
|
|
|
153
160
|
select?: (keyof F & string)[] | string[];
|
|
154
161
|
/** Sort specification. Keys are field names or document-level columns. */
|
|
155
162
|
sort?: SortSpec;
|
|
156
|
-
/** Locale for field value resolution. Defaults to '
|
|
163
|
+
/** Locale for field value resolution. Defaults to the client's `defaultLocale`. */
|
|
157
164
|
locale?: string;
|
|
158
165
|
/** Page number (1-based). Defaults to 1. */
|
|
159
166
|
page?: number;
|
|
@@ -208,7 +215,7 @@ export interface FindByVersionOptions<F = Record<string, any>> {
|
|
|
208
215
|
locale?: string;
|
|
209
216
|
}
|
|
210
217
|
export interface CreateOptions {
|
|
211
|
-
/** Locale for field value resolution. Defaults to '
|
|
218
|
+
/** Locale for field value resolution. Defaults to the client's `defaultLocale`. */
|
|
212
219
|
locale?: string;
|
|
213
220
|
/**
|
|
214
221
|
* Initial workflow status. When omitted, `document-lifecycle` derives
|
|
@@ -222,7 +229,7 @@ export interface CreateOptions {
|
|
|
222
229
|
path?: string;
|
|
223
230
|
}
|
|
224
231
|
export interface UpdateOptions {
|
|
225
|
-
/** Locale for field value resolution. Defaults to '
|
|
232
|
+
/** Locale for field value resolution. Defaults to the client's `defaultLocale`. */
|
|
226
233
|
locale?: string;
|
|
227
234
|
/**
|
|
228
235
|
* Explicit path override. When omitted, the previous version's path
|
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.8.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.8.0",
|
|
42
|
+
"@byline/core": "1.8.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.8.0"
|
|
55
55
|
},
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public",
|