@byline/host-tanstack-start 3.16.1 → 3.17.1
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.
|
@@ -25,7 +25,7 @@ function parseUploadFormData(data) {
|
|
|
25
25
|
fields
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function resolveUploadField(definition, collectionPath, requested) {
|
|
29
29
|
const candidates = getUploadFields(definition);
|
|
30
30
|
if (requested) {
|
|
31
31
|
const match = candidates.find((f)=>f.name === requested);
|
|
@@ -37,9 +37,9 @@ function resolveUploadFieldName(definition, collectionPath, requested) {
|
|
|
37
37
|
available: candidates.map((f)=>f.name)
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
|
-
return match
|
|
40
|
+
return match;
|
|
41
41
|
}
|
|
42
|
-
if (1 === candidates.length) return candidates[0]
|
|
42
|
+
if (1 === candidates.length) return candidates[0];
|
|
43
43
|
if (0 === candidates.length) throw ERR_VALIDATION({
|
|
44
44
|
message: `Collection '${collectionPath}' has no upload-capable image/file field. Add an 'upload' block to one of its image/file fields.`,
|
|
45
45
|
details: {
|
|
@@ -72,10 +72,9 @@ const uploadCollectionField = createServerFn({
|
|
|
72
72
|
}
|
|
73
73
|
}, uploadCollectionField).log(logger);
|
|
74
74
|
const serverConfig = getServerConfig();
|
|
75
|
-
const
|
|
76
|
-
const targetField = config.definition.fields.find((f)=>f.name === resolvedFieldName);
|
|
75
|
+
const targetField = resolveUploadField(config.definition, collectionPath, fieldName);
|
|
77
76
|
const storage = targetField.upload?.storage ?? serverConfig.storage;
|
|
78
|
-
if (!storage) throw new Error(`No storage provider configured for field '${
|
|
77
|
+
if (!storage) throw new Error(`No storage provider configured for field '${targetField.name}' on collection '${collectionPath}'. Set either field.upload.storage or the site-wide ServerConfig.storage.`);
|
|
79
78
|
let buffer;
|
|
80
79
|
try {
|
|
81
80
|
buffer = Buffer.from(await file.arrayBuffer());
|
|
@@ -92,7 +91,7 @@ const uploadCollectionField = createServerFn({
|
|
|
92
91
|
collectionId: config.collection.id,
|
|
93
92
|
collectionVersion: config.collection.version,
|
|
94
93
|
collectionPath,
|
|
95
|
-
fieldName:
|
|
94
|
+
fieldName: targetField.name,
|
|
96
95
|
storage,
|
|
97
96
|
logger,
|
|
98
97
|
defaultLocale: serverConfig.i18n.content.defaultLocale,
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"private": false,
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
|
-
"version": "3.
|
|
6
|
+
"version": "3.17.1",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=20.9.0"
|
|
9
9
|
},
|
|
@@ -119,13 +119,13 @@
|
|
|
119
119
|
"react-swipeable": "^7.0.2",
|
|
120
120
|
"uuid": "^14.0.0",
|
|
121
121
|
"zod": "^4.4.3",
|
|
122
|
-
"@byline/admin": "3.
|
|
123
|
-
"@byline/
|
|
124
|
-
"@byline/
|
|
125
|
-
"@byline/auth": "3.
|
|
126
|
-
"@byline/
|
|
127
|
-
"@byline/
|
|
128
|
-
"@byline/
|
|
122
|
+
"@byline/admin": "3.17.1",
|
|
123
|
+
"@byline/client": "3.17.1",
|
|
124
|
+
"@byline/ai": "3.17.1",
|
|
125
|
+
"@byline/auth": "3.17.1",
|
|
126
|
+
"@byline/i18n": "3.17.1",
|
|
127
|
+
"@byline/core": "3.17.1",
|
|
128
|
+
"@byline/ui": "3.17.1"
|
|
129
129
|
},
|
|
130
130
|
"peerDependencies": {
|
|
131
131
|
"@tanstack/react-router": "^1.167.0",
|
|
@@ -84,16 +84,17 @@ function parseUploadFormData(data: FormData): UploadDocumentInput {
|
|
|
84
84
|
* wins; otherwise default to the unique upload-capable field. Throws
|
|
85
85
|
* `ERR_VALIDATION` when the request is ambiguous.
|
|
86
86
|
*
|
|
87
|
-
*
|
|
88
|
-
* `blocks`
|
|
89
|
-
*
|
|
90
|
-
*
|
|
87
|
+
* Candidates come from `getUploadFields`, which recurses into `group` /
|
|
88
|
+
* `array` / `blocks` — upload fields nested in repeating structures are
|
|
89
|
+
* addressed by their leaf field name. Note the ambiguity fallback counts
|
|
90
|
+
* nested fields too: a collection whose only extra upload field is
|
|
91
|
+
* nested still requires an explicit `field` selector.
|
|
91
92
|
*/
|
|
92
|
-
function
|
|
93
|
+
function resolveUploadField(
|
|
93
94
|
definition: CollectionDefinition,
|
|
94
95
|
collectionPath: string,
|
|
95
96
|
requested: string | null
|
|
96
|
-
):
|
|
97
|
+
): ImageField | FileField {
|
|
97
98
|
const candidates = getUploadFields(definition)
|
|
98
99
|
|
|
99
100
|
if (requested) {
|
|
@@ -110,10 +111,10 @@ function resolveUploadFieldName(
|
|
|
110
111
|
},
|
|
111
112
|
})
|
|
112
113
|
}
|
|
113
|
-
return match
|
|
114
|
+
return match
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
if (candidates.length === 1) return candidates[0]
|
|
117
|
+
if (candidates.length === 1) return candidates[0]
|
|
117
118
|
|
|
118
119
|
if (candidates.length === 0) {
|
|
119
120
|
throw ERR_VALIDATION({
|
|
@@ -167,19 +168,12 @@ export const uploadCollectionField = createServerFn({ method: 'POST' })
|
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
const serverConfig = getServerConfig()
|
|
170
|
-
const
|
|
171
|
-
config.definition,
|
|
172
|
-
collectionPath,
|
|
173
|
-
fieldName
|
|
174
|
-
)
|
|
175
|
-
const targetField = config.definition.fields.find((f) => f.name === resolvedFieldName) as
|
|
176
|
-
| ImageField
|
|
177
|
-
| FileField
|
|
171
|
+
const targetField = resolveUploadField(config.definition, collectionPath, fieldName)
|
|
178
172
|
// Per-field storage routing falls through to the site-wide default.
|
|
179
173
|
const storage = targetField.upload?.storage ?? serverConfig.storage
|
|
180
174
|
if (!storage) {
|
|
181
175
|
throw new Error(
|
|
182
|
-
`No storage provider configured for field '${
|
|
176
|
+
`No storage provider configured for field '${targetField.name}' on collection ` +
|
|
183
177
|
`'${collectionPath}'. Set either field.upload.storage or the site-wide ` +
|
|
184
178
|
'ServerConfig.storage.'
|
|
185
179
|
)
|
|
@@ -199,7 +193,7 @@ export const uploadCollectionField = createServerFn({ method: 'POST' })
|
|
|
199
193
|
collectionId: config.collection.id,
|
|
200
194
|
collectionVersion: config.collection.version,
|
|
201
195
|
collectionPath,
|
|
202
|
-
fieldName:
|
|
196
|
+
fieldName: targetField.name,
|
|
203
197
|
storage,
|
|
204
198
|
logger,
|
|
205
199
|
defaultLocale: serverConfig.i18n.content.defaultLocale,
|