@byline/host-tanstack-start 1.3.1 → 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.
@@ -82,6 +82,7 @@ const EditView = ({ collectionDefinition, adminConfig, initialData, locale, cont
82
82
  }
83
83
  };
84
84
  const publishedVersion = initialData?._publishedVersion ?? null;
85
+ const restoreWarnings = initialData?._restoreWarnings;
85
86
  const handleUnpublish = async ()=>{
86
87
  try {
87
88
  await unpublishDocument({
@@ -262,6 +263,7 @@ const EditView = ({ collectionDefinition, adminConfig, initialData, locale, cont
262
263
  onUnpublish: publishedVersion ? handleUnpublish : void 0,
263
264
  onDelete: handleDelete,
264
265
  publishedVersion: publishedVersion,
266
+ restoreWarnings: restoreWarnings,
265
267
  nextStatus: nextStatus,
266
268
  workflowStatuses: workflowStatuses,
267
269
  onCancel: ()=>navigate({
@@ -16,6 +16,7 @@
16
16
  * `{target_document_id, target_collection_id}` refs.
17
17
  */
18
18
  export declare function getCollectionDocument(collection: string, id: string, locale?: string, depth?: number, populateRelations?: boolean): Promise<{
19
+ _restoreWarnings?: string[] | undefined;
19
20
  _publishedVersion: Record<string, any> | null;
20
21
  } | null>;
21
22
  /**
@@ -38,7 +38,8 @@ const getDocumentFn = createServerFn({
38
38
  locale: locale ?? 'en',
39
39
  populate,
40
40
  depth: resolvedDepth,
41
- status: 'any'
41
+ status: 'any',
42
+ lenient: true
42
43
  });
43
44
  if (!document) throw ERR_NOT_FOUND({
44
45
  message: 'Document not found',
@@ -67,9 +68,13 @@ const getDocumentFn = createServerFn({
67
68
  updatedAt: pv.updated_at
68
69
  }) : null;
69
70
  }
71
+ const restoreWarnings = serialised._restoreWarnings;
70
72
  return {
71
73
  ...parsed,
72
- _publishedVersion: publishedVersion
74
+ _publishedVersion: publishedVersion,
75
+ ...restoreWarnings && restoreWarnings.length > 0 ? {
76
+ _restoreWarnings: restoreWarnings
77
+ } : {}
73
78
  };
74
79
  });
75
80
  const getDocumentByVersionFn = createServerFn({
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "private": false,
4
4
  "type": "module",
5
5
  "license": "MPL-2.0",
6
- "version": "1.3.1",
6
+ "version": "1.6.0",
7
7
  "engines": {
8
8
  "node": ">=20.9.0"
9
9
  },
@@ -101,11 +101,11 @@
101
101
  "react-swipeable": "^7.0.2",
102
102
  "uuid": "^14.0.0",
103
103
  "zod": "^4.4.2",
104
- "@byline/admin": "1.3.1",
105
- "@byline/client": "1.4.0",
106
- "@byline/core": "1.4.0",
107
- "@byline/auth": "1.3.0",
108
- "@byline/ui": "1.3.1"
104
+ "@byline/auth": "1.6.0",
105
+ "@byline/core": "1.6.0",
106
+ "@byline/admin": "1.6.0",
107
+ "@byline/client": "1.6.0",
108
+ "@byline/ui": "1.6.0"
109
109
  },
110
110
  "peerDependencies": {
111
111
  "@tanstack/react-router": "^1.167.0",
@@ -119,6 +119,13 @@ export const EditView = ({
119
119
  // biome-ignore lint/suspicious/noExplicitAny: storage shape
120
120
  const publishedVersion = (initialData as any)?._publishedVersion ?? null
121
121
 
122
+ // Schema-mismatch warnings — attached by getCollectionDocument when the
123
+ // document was loaded leniently (admin edit path) and at least one
124
+ // orphan row was skipped because the collection schema has moved on
125
+ // since the document was written.
126
+ // biome-ignore lint/suspicious/noExplicitAny: storage shape
127
+ const restoreWarnings = (initialData as any)?._restoreWarnings as string[] | undefined
128
+
122
129
  const handleUnpublish = async () => {
123
130
  try {
124
131
  await unpublishDocument({ data: { collection: path, id: String(initialData.id) } })
@@ -302,6 +309,7 @@ export const EditView = ({
302
309
  onUnpublish={publishedVersion ? handleUnpublish : undefined}
303
310
  onDelete={handleDelete}
304
311
  publishedVersion={publishedVersion}
312
+ restoreWarnings={restoreWarnings}
305
313
  nextStatus={nextStatus}
306
314
  workflowStatuses={workflowStatuses}
307
315
  onCancel={() =>
@@ -25,10 +25,12 @@
25
25
  * document yet, so offering a preview link would just lead to a 404.
26
26
  *
27
27
  * The component does not load the document itself. Callers pass the
28
- * already-loaded `doc` from their route loader. If `preview.populate`
29
- * is configured, it's the loader's responsibility to apply that hint
30
- * when fetching the document so `url(doc, ctx)` sees the resolved
31
- * relation values it expects (e.g. `doc.fields.area?.document?.path`).
28
+ * already-loaded `doc` from their route loader. The edit-view loader
29
+ * applies a blanket depth-1 populate (picker projection) so direct
30
+ * relation targets are available as `doc.fields.<name>?.document`
31
+ * `url(doc, ctx)` inherits that populated tree without further work.
32
+ * Deeper hops or fields outside the picker projection are not available;
33
+ * see `CollectionAdminConfig.preview` for the full contract.
32
34
  *
33
35
  * Two-step "enable cookie then navigate" intentionally avoids the
34
36
  * Payload-style `/routes/draft?url=...&secret=...` redirect handler:
@@ -88,6 +88,10 @@ const getDocumentFn = createServerFn({ method: 'GET' })
88
88
  populate,
89
89
  depth: resolvedDepth,
90
90
  status: 'any',
91
+ // Admin edit path: tolerate schema-mismatch warnings rather than
92
+ // hard-failing the load. Warnings (if any) come back on the document
93
+ // as `_restoreWarnings` and the edit form surfaces them via an Alert.
94
+ lenient: true,
91
95
  })
92
96
 
93
97
  if (!document) {
@@ -136,7 +140,21 @@ const getDocumentFn = createServerFn({ method: 'GET' })
136
140
  : null
137
141
  }
138
142
 
139
- return { ...(parsed as Record<string, any>), _publishedVersion: publishedVersion }
143
+ // Preserve `_restoreWarnings` across the Zod parse the parse strips
144
+ // unknown keys, so the warnings list (set by `findById({ lenient: true })`
145
+ // when older rows can't be reconstructed against the current schema)
146
+ // would otherwise be lost before reaching the edit form.
147
+ const restoreWarnings = (serialised as Record<string, any>)._restoreWarnings as
148
+ | string[]
149
+ | undefined
150
+
151
+ return {
152
+ ...(parsed as Record<string, any>),
153
+ _publishedVersion: publishedVersion,
154
+ ...(restoreWarnings && restoreWarnings.length > 0
155
+ ? { _restoreWarnings: restoreWarnings }
156
+ : {}),
157
+ }
140
158
  })
141
159
 
142
160
  // ---------------------------------------------------------------------------