@byline/client 1.5.0 → 1.6.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.
@@ -118,6 +118,7 @@ export class CollectionHandle {
118
118
  reconstruct: true,
119
119
  readMode,
120
120
  filters,
121
+ lenient: options.lenient,
121
122
  });
122
123
  if (raw == null)
123
124
  return null;
package/dist/response.js CHANGED
@@ -23,7 +23,7 @@ function toDate(value, fieldName) {
23
23
  * `fields` property for callers that know their collection's shape.
24
24
  */
25
25
  export function shapeDocument(raw) {
26
- return {
26
+ const shaped = {
27
27
  id: raw.document_id ?? '',
28
28
  versionId: raw.document_version_id ?? '',
29
29
  path: raw.path ?? '',
@@ -32,6 +32,10 @@ export function shapeDocument(raw) {
32
32
  updatedAt: toDate(raw.updated_at, 'updated_at'),
33
33
  fields: (raw.fields ?? {}),
34
34
  };
35
+ if (Array.isArray(raw.restoreWarnings) && raw.restoreWarnings.length > 0) {
36
+ shaped._restoreWarnings = raw.restoreWarnings;
37
+ }
38
+ return shaped;
35
39
  }
36
40
  /**
37
41
  * Detect a raw (storage-shape) document vs a shaped `ClientDocument` vs a
package/dist/types.d.ts CHANGED
@@ -168,6 +168,15 @@ export interface FindOneOptions<F = Record<string, any>> extends PopulateControl
168
168
  export interface FindByIdOptions<F = Record<string, any>> extends PopulateControls, StatusControls, BeforeReadControls {
169
169
  select?: (keyof F & string)[] | string[];
170
170
  locale?: string;
171
+ /**
172
+ * "Best-effort" reconstruction. When `true`, schema-mismatch warnings
173
+ * (e.g. a field's type was changed and old rows can't be rebuilt against
174
+ * the new shape) are surfaced on the returned `ClientDocument` as
175
+ * `_restoreWarnings` instead of being thrown. Intended for the admin
176
+ * edit path only — public reads should leave this `false` so partial
177
+ * data never reaches end users.
178
+ */
179
+ lenient?: boolean;
171
180
  }
172
181
  export interface FindByPathOptions<F = Record<string, any>> extends PopulateControls, StatusControls, BeforeReadControls {
173
182
  select?: (keyof F & string)[] | string[];
@@ -281,6 +290,15 @@ export interface ClientDocument<F = Record<string, any>> {
281
290
  updatedAt: Date;
282
291
  /** Reconstructed field data. */
283
292
  fields: F;
293
+ /**
294
+ * Schema-mismatch warnings produced by a "best-effort" reconstruction
295
+ * (`findById` with `lenient: true`). Present only when the document was
296
+ * loaded leniently and at least one orphan row was skipped — for example,
297
+ * after a `CollectionDefinition` change retired or replaced a field and
298
+ * older rows can no longer be rebuilt against the new shape. Absent on
299
+ * normal reads.
300
+ */
301
+ _restoreWarnings?: string[];
284
302
  }
285
303
  export interface FindResult<F = Record<string, any>> {
286
304
  docs: ClientDocument<F>[];
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.0",
5
+ "version": "1.6.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.4.0",
42
- "@byline/core": "1.5.0"
41
+ "@byline/auth": "1.6.0",
42
+ "@byline/core": "1.6.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.4.0"
54
+ "@byline/db-postgres": "1.6.0"
55
55
  },
56
56
  "publishConfig": {
57
57
  "access": "public",