@aphexcms/cms-core 9.10.0 → 10.0.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/api/assets.d.ts +62 -7
- package/dist/api/assets.d.ts.map +1 -1
- package/dist/api/assets.js +116 -9
- package/dist/api/client.d.ts +1 -1
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +39 -9
- package/dist/api/limits.d.ts +55 -0
- package/dist/api/limits.d.ts.map +1 -0
- package/dist/api/limits.js +58 -0
- package/dist/api/schemas/assets.d.ts +94 -4
- package/dist/api/schemas/assets.d.ts.map +1 -1
- package/dist/api/schemas/assets.js +82 -5
- package/dist/api/types.d.ts +25 -0
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/upload-timeout.d.ts +17 -0
- package/dist/api/upload-timeout.d.ts.map +1 -0
- package/dist/api/upload-timeout.js +35 -0
- package/dist/api/upload.d.ts +42 -0
- package/dist/api/upload.d.ts.map +1 -0
- package/dist/api/upload.js +144 -0
- package/dist/components/AdminApp.svelte +130 -26
- package/dist/components/AdminApp.svelte.d.ts.map +1 -1
- package/dist/components/admin/AssetBrowserModal.svelte +4 -3
- package/dist/components/admin/AssetBrowserModal.svelte.d.ts +2 -1
- package/dist/components/admin/AssetBrowserModal.svelte.d.ts.map +1 -1
- package/dist/components/admin/MediaBrowser.svelte +1859 -281
- package/dist/components/admin/MediaBrowser.svelte.d.ts +21 -1
- package/dist/components/admin/MediaBrowser.svelte.d.ts.map +1 -1
- package/dist/components/admin/fields/ArrayField.svelte +21 -10
- package/dist/components/admin/fields/ArrayField.svelte.d.ts.map +1 -1
- package/dist/components/admin/fields/FileField.svelte +9 -2
- package/dist/components/admin/fields/FileField.svelte.d.ts.map +1 -1
- package/dist/components/admin/fields/ImageField.svelte +47 -12
- package/dist/components/admin/fields/ImageField.svelte.d.ts.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +14 -0
- package/dist/db/interfaces/asset.d.ts +114 -5
- package/dist/db/interfaces/asset.d.ts.map +1 -1
- package/dist/db/interfaces/document.d.ts +98 -3
- package/dist/db/interfaces/document.d.ts.map +1 -1
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +2 -1
- package/dist/image/Image.svelte +72 -0
- package/dist/image/Image.svelte.d.ts +40 -0
- package/dist/image/Image.svelte.d.ts.map +1 -0
- package/dist/image/index.d.ts +3 -0
- package/dist/image/index.d.ts.map +1 -0
- package/dist/image/index.js +11 -0
- package/dist/image/types.d.ts +28 -0
- package/dist/image/types.d.ts.map +1 -0
- package/dist/image/types.js +1 -0
- package/dist/images/generate.d.ts +55 -0
- package/dist/images/generate.d.ts.map +1 -0
- package/dist/images/generate.js +243 -0
- package/dist/images/index.d.ts +2 -0
- package/dist/images/index.d.ts.map +1 -0
- package/dist/images/index.js +7 -0
- package/dist/images/variants.d.ts +82 -0
- package/dist/images/variants.d.ts.map +1 -0
- package/dist/images/variants.js +124 -0
- package/dist/jobs/asset-reference-jobs.d.ts +49 -0
- package/dist/jobs/asset-reference-jobs.d.ts.map +1 -0
- package/dist/jobs/asset-reference-jobs.js +74 -0
- package/dist/jobs/run-batch.d.ts.map +1 -1
- package/dist/jobs/run-batch.js +5 -0
- package/dist/lib/api/assets.d.ts +62 -7
- package/dist/lib/api/assets.d.ts.map +1 -1
- package/dist/lib/api/assets.js +116 -9
- package/dist/lib/api/assets.js.map +1 -1
- package/dist/lib/api/client.d.ts +1 -1
- package/dist/lib/api/client.d.ts.map +1 -1
- package/dist/lib/api/client.js +39 -9
- package/dist/lib/api/client.js.map +1 -1
- package/dist/lib/api/limits.d.ts +55 -0
- package/dist/lib/api/limits.d.ts.map +1 -0
- package/dist/lib/api/limits.js +59 -0
- package/dist/lib/api/limits.js.map +1 -0
- package/dist/lib/api/schemas/assets.d.ts +94 -4
- package/dist/lib/api/schemas/assets.d.ts.map +1 -1
- package/dist/lib/api/schemas/assets.js +82 -5
- package/dist/lib/api/schemas/assets.js.map +1 -1
- package/dist/lib/api/types.d.ts +25 -0
- package/dist/lib/api/types.d.ts.map +1 -1
- package/dist/lib/api/upload-timeout.d.ts +17 -0
- package/dist/lib/api/upload-timeout.d.ts.map +1 -0
- package/dist/lib/api/upload-timeout.js +36 -0
- package/dist/lib/api/upload-timeout.js.map +1 -0
- package/dist/lib/api/upload.d.ts +42 -0
- package/dist/lib/api/upload.d.ts.map +1 -0
- package/dist/lib/api/upload.js +145 -0
- package/dist/lib/api/upload.js.map +1 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +14 -0
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/db/interfaces/asset.d.ts +114 -5
- package/dist/lib/db/interfaces/asset.d.ts.map +1 -1
- package/dist/lib/db/interfaces/document.d.ts +98 -3
- package/dist/lib/db/interfaces/document.d.ts.map +1 -1
- package/dist/lib/hooks.d.ts.map +1 -1
- package/dist/lib/hooks.js +2 -1
- package/dist/lib/hooks.js.map +1 -1
- package/dist/lib/image/index.d.ts +3 -0
- package/dist/lib/image/index.d.ts.map +1 -0
- package/dist/lib/image/index.js +12 -0
- package/dist/lib/image/index.js.map +1 -0
- package/dist/lib/image/types.d.ts +28 -0
- package/dist/lib/image/types.d.ts.map +1 -0
- package/dist/lib/image/types.js +2 -0
- package/dist/lib/image/types.js.map +1 -0
- package/dist/lib/images/generate.d.ts +55 -0
- package/dist/lib/images/generate.d.ts.map +1 -0
- package/dist/lib/images/generate.js +244 -0
- package/dist/lib/images/generate.js.map +1 -0
- package/dist/lib/images/index.d.ts +2 -0
- package/dist/lib/images/index.d.ts.map +1 -0
- package/dist/lib/images/index.js +8 -0
- package/dist/lib/images/index.js.map +1 -0
- package/dist/lib/images/variants.d.ts +82 -0
- package/dist/lib/images/variants.d.ts.map +1 -0
- package/dist/lib/images/variants.js +125 -0
- package/dist/lib/images/variants.js.map +1 -0
- package/dist/lib/jobs/asset-reference-jobs.d.ts +49 -0
- package/dist/lib/jobs/asset-reference-jobs.d.ts.map +1 -0
- package/dist/lib/jobs/asset-reference-jobs.js +75 -0
- package/dist/lib/jobs/asset-reference-jobs.js.map +1 -0
- package/dist/lib/jobs/run-batch.d.ts.map +1 -1
- package/dist/lib/jobs/run-batch.js +5 -0
- package/dist/lib/jobs/run-batch.js.map +1 -1
- package/dist/lib/local-api/collection-api.d.ts +19 -2
- package/dist/lib/local-api/collection-api.d.ts.map +1 -1
- package/dist/lib/local-api/collection-api.js +65 -17
- package/dist/lib/local-api/collection-api.js.map +1 -1
- package/dist/lib/preview/assets.d.ts +19 -0
- package/dist/lib/preview/assets.d.ts.map +1 -1
- package/dist/lib/preview/assets.js +6 -0
- package/dist/lib/preview/assets.js.map +1 -1
- package/dist/lib/routes/assets-cdn.d.ts +19 -0
- package/dist/lib/routes/assets-cdn.d.ts.map +1 -1
- package/dist/lib/routes/assets-cdn.js +295 -17
- package/dist/lib/routes/assets-cdn.js.map +1 -1
- package/dist/lib/server/api/index.d.ts.map +1 -1
- package/dist/lib/server/api/index.js +87 -8
- package/dist/lib/server/api/index.js.map +1 -1
- package/dist/lib/server/api/routes/assets-bulk.d.ts.map +1 -1
- package/dist/lib/server/api/routes/assets-bulk.js +36 -7
- package/dist/lib/server/api/routes/assets-bulk.js.map +1 -1
- package/dist/lib/server/api/routes/assets-by-id.d.ts.map +1 -1
- package/dist/lib/server/api/routes/assets-by-id.js +32 -15
- package/dist/lib/server/api/routes/assets-by-id.js.map +1 -1
- package/dist/lib/server/api/routes/assets-direct-upload.d.ts +4 -0
- package/dist/lib/server/api/routes/assets-direct-upload.d.ts.map +1 -0
- package/dist/lib/server/api/routes/assets-direct-upload.js +164 -0
- package/dist/lib/server/api/routes/assets-direct-upload.js.map +1 -0
- package/dist/lib/server/api/routes/assets-poster.d.ts +4 -0
- package/dist/lib/server/api/routes/assets-poster.d.ts.map +1 -0
- package/dist/lib/server/api/routes/assets-poster.js +120 -0
- package/dist/lib/server/api/routes/assets-poster.js.map +1 -0
- package/dist/lib/server/api/routes/assets-references.d.ts.map +1 -1
- package/dist/lib/server/api/routes/assets-references.js +64 -5
- package/dist/lib/server/api/routes/assets-references.js.map +1 -1
- package/dist/lib/server/api/routes/assets.d.ts.map +1 -1
- package/dist/lib/server/api/routes/assets.js +116 -12
- package/dist/lib/server/api/routes/assets.js.map +1 -1
- package/dist/lib/server/api/routes/clear-asset-references.d.ts +18 -0
- package/dist/lib/server/api/routes/clear-asset-references.d.ts.map +1 -0
- package/dist/lib/server/api/routes/clear-asset-references.js +32 -0
- package/dist/lib/server/api/routes/clear-asset-references.js.map +1 -0
- package/dist/lib/server/api/routes/documents.d.ts.map +1 -1
- package/dist/lib/server/api/routes/documents.js +27 -1
- package/dist/lib/server/api/routes/documents.js.map +1 -1
- package/dist/lib/server/index.d.ts +2 -0
- package/dist/lib/server/index.d.ts.map +1 -1
- package/dist/lib/server/index.js +4 -0
- package/dist/lib/server/index.js.map +1 -1
- package/dist/lib/services/asset-references-service.d.ts +93 -0
- package/dist/lib/services/asset-references-service.d.ts.map +1 -0
- package/dist/lib/services/asset-references-service.js +198 -0
- package/dist/lib/services/asset-references-service.js.map +1 -0
- package/dist/lib/services/asset-service.d.ts +115 -14
- package/dist/lib/services/asset-service.d.ts.map +1 -1
- package/dist/lib/services/asset-service.js +312 -31
- package/dist/lib/services/asset-service.js.map +1 -1
- package/dist/lib/services/references-service.d.ts +19 -15
- package/dist/lib/services/references-service.d.ts.map +1 -1
- package/dist/lib/services/references-service.js +59 -31
- package/dist/lib/services/references-service.js.map +1 -1
- package/dist/lib/services/version-service.d.ts +10 -1
- package/dist/lib/services/version-service.d.ts.map +1 -1
- package/dist/lib/services/version-service.js +26 -4
- package/dist/lib/services/version-service.js.map +1 -1
- package/dist/lib/storage/adapters/local-storage-adapter.d.ts +38 -0
- package/dist/lib/storage/adapters/local-storage-adapter.d.ts.map +1 -1
- package/dist/lib/storage/adapters/local-storage-adapter.js +86 -19
- package/dist/lib/storage/adapters/local-storage-adapter.js.map +1 -1
- package/dist/lib/storage/index.d.ts +1 -0
- package/dist/lib/storage/index.d.ts.map +1 -1
- package/dist/lib/storage/index.js +2 -0
- package/dist/lib/storage/index.js.map +1 -1
- package/dist/lib/storage/interfaces/storage.d.ts +135 -5
- package/dist/lib/storage/interfaces/storage.d.ts.map +1 -1
- package/dist/lib/storage/keys.d.ts +96 -0
- package/dist/lib/storage/keys.d.ts.map +1 -0
- package/dist/lib/storage/keys.js +160 -0
- package/dist/lib/storage/keys.js.map +1 -0
- package/dist/lib/types/asset.d.ts +92 -12
- package/dist/lib/types/asset.d.ts.map +1 -1
- package/dist/lib/types/capabilities.d.ts +11 -0
- package/dist/lib/types/capabilities.d.ts.map +1 -1
- package/dist/lib/types/capabilities.js +20 -6
- package/dist/lib/types/capabilities.js.map +1 -1
- package/dist/lib/types/config.d.ts +127 -0
- package/dist/lib/types/config.d.ts.map +1 -1
- package/dist/lib/utils/asset-reference-walk.d.ts +44 -0
- package/dist/lib/utils/asset-reference-walk.d.ts.map +1 -0
- package/dist/lib/utils/asset-reference-walk.js +144 -0
- package/dist/lib/utils/asset-reference-walk.js.map +1 -0
- package/dist/lib/utils/image-url.d.ts +61 -26
- package/dist/lib/utils/image-url.d.ts.map +1 -1
- package/dist/lib/utils/image-url.js +143 -26
- package/dist/lib/utils/image-url.js.map +1 -1
- package/dist/lib/utils/video-metadata.d.ts +39 -0
- package/dist/lib/utils/video-metadata.d.ts.map +1 -0
- package/dist/lib/utils/video-metadata.js +161 -0
- package/dist/lib/utils/video-metadata.js.map +1 -0
- package/dist/local-api/collection-api.d.ts +19 -2
- package/dist/local-api/collection-api.d.ts.map +1 -1
- package/dist/local-api/collection-api.js +65 -17
- package/dist/preview/assets.d.ts +19 -0
- package/dist/preview/assets.d.ts.map +1 -1
- package/dist/preview/assets.js +6 -0
- package/dist/routes/assets-cdn.d.ts +19 -0
- package/dist/routes/assets-cdn.d.ts.map +1 -1
- package/dist/routes/assets-cdn.js +295 -17
- package/dist/server/api/index.d.ts.map +1 -1
- package/dist/server/api/index.js +87 -8
- package/dist/server/api/routes/assets-bulk.d.ts.map +1 -1
- package/dist/server/api/routes/assets-bulk.js +36 -7
- package/dist/server/api/routes/assets-by-id.d.ts.map +1 -1
- package/dist/server/api/routes/assets-by-id.js +32 -15
- package/dist/server/api/routes/assets-direct-upload.d.ts +4 -0
- package/dist/server/api/routes/assets-direct-upload.d.ts.map +1 -0
- package/dist/server/api/routes/assets-direct-upload.js +163 -0
- package/dist/server/api/routes/assets-poster.d.ts +4 -0
- package/dist/server/api/routes/assets-poster.d.ts.map +1 -0
- package/dist/server/api/routes/assets-poster.js +119 -0
- package/dist/server/api/routes/assets-references.d.ts.map +1 -1
- package/dist/server/api/routes/assets-references.js +64 -5
- package/dist/server/api/routes/assets.d.ts.map +1 -1
- package/dist/server/api/routes/assets.js +116 -12
- package/dist/server/api/routes/clear-asset-references.d.ts +18 -0
- package/dist/server/api/routes/clear-asset-references.d.ts.map +1 -0
- package/dist/server/api/routes/clear-asset-references.js +31 -0
- package/dist/server/api/routes/documents.d.ts.map +1 -1
- package/dist/server/api/routes/documents.js +27 -1
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +4 -0
- package/dist/services/asset-references-service.d.ts +93 -0
- package/dist/services/asset-references-service.d.ts.map +1 -0
- package/dist/services/asset-references-service.js +197 -0
- package/dist/services/asset-service.d.ts +115 -14
- package/dist/services/asset-service.d.ts.map +1 -1
- package/dist/services/asset-service.js +312 -31
- package/dist/services/references-service.d.ts +19 -15
- package/dist/services/references-service.d.ts.map +1 -1
- package/dist/services/references-service.js +59 -31
- package/dist/services/version-service.d.ts +10 -1
- package/dist/services/version-service.d.ts.map +1 -1
- package/dist/services/version-service.js +26 -4
- package/dist/storage/adapters/local-storage-adapter.d.ts +38 -0
- package/dist/storage/adapters/local-storage-adapter.d.ts.map +1 -1
- package/dist/storage/adapters/local-storage-adapter.js +86 -19
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +2 -0
- package/dist/storage/interfaces/storage.d.ts +135 -5
- package/dist/storage/interfaces/storage.d.ts.map +1 -1
- package/dist/storage/keys.d.ts +96 -0
- package/dist/storage/keys.d.ts.map +1 -0
- package/dist/storage/keys.js +159 -0
- package/dist/types/asset.d.ts +92 -12
- package/dist/types/asset.d.ts.map +1 -1
- package/dist/types/capabilities.d.ts +11 -0
- package/dist/types/capabilities.d.ts.map +1 -1
- package/dist/types/capabilities.js +20 -6
- package/dist/types/config.d.ts +127 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/asset-reference-walk.d.ts +44 -0
- package/dist/utils/asset-reference-walk.d.ts.map +1 -0
- package/dist/utils/asset-reference-walk.js +143 -0
- package/dist/utils/image-url.d.ts +61 -26
- package/dist/utils/image-url.d.ts.map +1 -1
- package/dist/utils/image-url.js +143 -26
- package/dist/utils/video-metadata.d.ts +39 -0
- package/dist/utils/video-metadata.d.ts.map +1 -0
- package/dist/utils/video-metadata.js +160 -0
- package/package.json +6 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../../src/lib/api/schemas/assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;iBAuBT,CAAC;AAEhB,eAAO,MAAM,oBAAoB
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../../src/lib/api/schemas/assets.ts"],"names":[],"mappings":"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"}
|
|
@@ -28,16 +28,46 @@ export const assetReferenceSchema = z.object({
|
|
|
28
28
|
documentId: z.string(),
|
|
29
29
|
type: z.string(),
|
|
30
30
|
title: z.string(),
|
|
31
|
-
status: z.string().nullable()
|
|
31
|
+
status: z.string().nullable(),
|
|
32
|
+
/**
|
|
33
|
+
* Where in the document the asset is used (`coverImage`,
|
|
34
|
+
* `content[13].images[0]`). Annotated from the asset-reference index, so it is
|
|
35
|
+
* absent when the index has no row — the reference itself is still authoritative.
|
|
36
|
+
*/
|
|
37
|
+
fieldPaths: z.array(z.string()).optional()
|
|
32
38
|
});
|
|
33
39
|
// ---------- GET /assets (list) ----------
|
|
34
40
|
export const listAssetsQuery = z.object({
|
|
35
41
|
assetType: z.enum(['image', 'file']).optional(),
|
|
36
42
|
mimeType: z.string().optional(),
|
|
43
|
+
/**
|
|
44
|
+
* Coarse media kind, resolved against `mimeType` in SQL. A separate axis from
|
|
45
|
+
* `assetType` ('image' | 'file'), which records how the upload pipeline treated
|
|
46
|
+
* the file rather than what the editor is hunting for — hence `svg` being its
|
|
47
|
+
* own bucket rather than an image.
|
|
48
|
+
*/
|
|
49
|
+
category: z.enum(['image', 'svg', 'video', 'audio', 'document']).optional(),
|
|
50
|
+
/** Matches filename, title, alt and description. Case-insensitive. */
|
|
37
51
|
search: z.string().optional(),
|
|
52
|
+
/**
|
|
53
|
+
* Whether the asset is referenced by any document, answered from the
|
|
54
|
+
* asset-reference index as an indexed EXISTS. Impossible to offer before that
|
|
55
|
+
* index existed: references were resolved by scanning every document's JSON,
|
|
56
|
+
* so a *filter* cost assets x documents.
|
|
57
|
+
*/
|
|
58
|
+
usage: z.enum(['in-use', 'unused']).optional(),
|
|
38
59
|
includeSystem: z
|
|
39
60
|
.union([z.boolean(), z.enum(['true', 'false']).transform((value) => value === 'true')])
|
|
40
61
|
.optional(),
|
|
62
|
+
/**
|
|
63
|
+
* Ordering, applied in SQL over the whole collection.
|
|
64
|
+
*
|
|
65
|
+
* It has to be a query parameter: the admin used to sort the loaded page in
|
|
66
|
+
* the browser, which meant "Name: A–Z" on page 2 of 300 assets alphabetised
|
|
67
|
+
* those 30 rows and nothing else. The result looked sorted and wasn't, which
|
|
68
|
+
* is the failure mode that never gets reported as a bug.
|
|
69
|
+
*/
|
|
70
|
+
sort: z.enum(['newest', 'oldest', 'name-asc', 'name-desc']).optional(),
|
|
41
71
|
limit: z.coerce.number().int().min(1).max(500).optional(),
|
|
42
72
|
offset: z.coerce.number().int().min(0).optional()
|
|
43
73
|
});
|
|
@@ -59,11 +89,24 @@ export const getAssetResponse = z.object({
|
|
|
59
89
|
data: assetSchema
|
|
60
90
|
});
|
|
61
91
|
// ---------- PATCH /assets/[id] ----------
|
|
92
|
+
/**
|
|
93
|
+
* Metadata patch. Every field is a tri-state: omitted leaves the column alone,
|
|
94
|
+
* `null` clears it, a string sets it.
|
|
95
|
+
*
|
|
96
|
+
* `.nullable()` is the load-bearing part. Without it an emptied input could only
|
|
97
|
+
* be sent as `undefined`, which `JSON.stringify` drops from the body entirely —
|
|
98
|
+
* so metadata could be added but never removed.
|
|
99
|
+
*/
|
|
62
100
|
export const updateAssetRequest = z.object({
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Display filename. Not nullable — an asset always has a name, so there is no
|
|
103
|
+
* "clear it" state; omit the field to leave it alone.
|
|
104
|
+
*/
|
|
105
|
+
originalFilename: z.string().trim().min(1).max(255).optional(),
|
|
106
|
+
title: z.string().nullable().optional(),
|
|
107
|
+
description: z.string().nullable().optional(),
|
|
108
|
+
alt: z.string().nullable().optional(),
|
|
109
|
+
creditLine: z.string().nullable().optional()
|
|
67
110
|
});
|
|
68
111
|
export const updateAssetResponse = z.object({
|
|
69
112
|
success: z.literal(true),
|
|
@@ -100,3 +143,37 @@ export const assetReferenceCountsResponse = z.object({
|
|
|
100
143
|
success: z.literal(true),
|
|
101
144
|
data: z.record(z.string(), z.number())
|
|
102
145
|
});
|
|
146
|
+
/**
|
|
147
|
+
* Ask for a URL the browser can upload directly to.
|
|
148
|
+
*
|
|
149
|
+
* Deliberately carries no key or path. The server mints the asset id and
|
|
150
|
+
* derives the destination from it, because a caller-supplied key would let
|
|
151
|
+
* anyone holding `asset.upload` write anywhere in the bucket — including over
|
|
152
|
+
* an existing asset's original.
|
|
153
|
+
*/
|
|
154
|
+
export const createUploadUrlRequest = z.object({
|
|
155
|
+
filename: z.string().trim().min(1).max(255),
|
|
156
|
+
mimeType: z.string().trim().min(1).max(255),
|
|
157
|
+
/**
|
|
158
|
+
* Declared up front so an oversized upload is refused before a write grant
|
|
159
|
+
* is issued at all. It is a claim, not proof — the size is verified against
|
|
160
|
+
* the stored object on confirm.
|
|
161
|
+
*/
|
|
162
|
+
size: z.number().int().positive(),
|
|
163
|
+
/** Where the asset is being used, for privacy resolution. */
|
|
164
|
+
schemaType: z.string().trim().max(255).optional(),
|
|
165
|
+
fieldPath: z.string().trim().max(255).optional()
|
|
166
|
+
});
|
|
167
|
+
/**
|
|
168
|
+
* Report that a direct upload finished, so the asset row can be created.
|
|
169
|
+
*
|
|
170
|
+
* Only the id is trusted. Everything describing the object — that it exists,
|
|
171
|
+
* how large it is — is read back from storage, never taken from the client.
|
|
172
|
+
*/
|
|
173
|
+
export const confirmUploadRequest = z.object({
|
|
174
|
+
assetId: z.string().uuid(),
|
|
175
|
+
title: z.string().trim().max(255).optional(),
|
|
176
|
+
description: z.string().trim().max(2000).optional(),
|
|
177
|
+
alt: z.string().trim().max(1000).optional(),
|
|
178
|
+
creditLine: z.string().trim().max(255).optional()
|
|
179
|
+
});
|
package/dist/api/types.d.ts
CHANGED
|
@@ -13,6 +13,31 @@ export interface ApiResponse<T> {
|
|
|
13
13
|
error?: string;
|
|
14
14
|
message?: string;
|
|
15
15
|
pagination?: PaginationMeta;
|
|
16
|
+
/**
|
|
17
|
+
* Server-side limits the client should respect, reported by endpoints whose
|
|
18
|
+
* clients need to pre-check against them. Present on `GET /assets` so the
|
|
19
|
+
* media browser can refuse an oversized file without hardcoding a size that
|
|
20
|
+
* drifts from whatever the server actually enforces.
|
|
21
|
+
*/
|
|
22
|
+
limits?: {
|
|
23
|
+
maxUploadBytes?: number;
|
|
24
|
+
/** Whether the browser may upload straight to storage. */
|
|
25
|
+
directUpload?: boolean;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The resolved image pipeline, or null when it's off.
|
|
29
|
+
*
|
|
30
|
+
* Reported so the media browser can address a small derivative instead of
|
|
31
|
+
* the original. `configHash` comes from the server rather than being
|
|
32
|
+
* recomputed here: it is the server that decides which files exist, and a
|
|
33
|
+
* client that derived a different hash would request URLs that quietly fall
|
|
34
|
+
* back to the original — the exact bug this exists to fix, but silent.
|
|
35
|
+
*/
|
|
36
|
+
images?: {
|
|
37
|
+
widths: number[];
|
|
38
|
+
quality: number;
|
|
39
|
+
configHash: string;
|
|
40
|
+
} | null;
|
|
16
41
|
meta?: {
|
|
17
42
|
count: number;
|
|
18
43
|
limit: number;
|
package/dist/api/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/api/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG5D,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;CACrB;AAGD,MAAM,WAAW,WAAW,CAAC,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,UAAU,CAAC,EAAE,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/api/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG5D,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;CACrB;AAGD,MAAM,WAAW,WAAW,CAAC,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B;;;;;OAKG;IACH,MAAM,CAAC,EAAE;QACR,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,0DAA0D;QAC1D,YAAY,CAAC,EAAE,OAAO,CAAC;KACvB,CAAC;IACF;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE;QACR,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;KACnB,GAAG,IAAI,CAAC;IAET,IAAI,CAAC,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC7B,CAAC;CACF;AAGD,MAAM,WAAW,kBAAkB;IAElC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IAEpC,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;CACjC;AAGD,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAGD,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAGD,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How long to wait on a request carrying a file body.
|
|
3
|
+
*
|
|
4
|
+
* Its own module because both transports need it — the XHR upload path and the
|
|
5
|
+
* fetch client — and a second copy of a heuristic is a second thing to get
|
|
6
|
+
* wrong. No imports, so neither pays for it.
|
|
7
|
+
*
|
|
8
|
+
* Derived from the payload rather than configured. A timeout encodes no
|
|
9
|
+
* decision the way a size limit does: its only job is to stop a hung request
|
|
10
|
+
* spinning forever. Exposing it as a setting invites an inconsistent pair —
|
|
11
|
+
* raise `upload.maxFileSize` to 100MB, leave the timeout at the JSON default,
|
|
12
|
+
* and every large upload fails in a way that reads as a server rejection.
|
|
13
|
+
* Deriving it means raising the size limit adjusts the deadline for free.
|
|
14
|
+
*/
|
|
15
|
+
export declare function uploadTimeoutForBytes(bytes: number): number;
|
|
16
|
+
export declare function uploadTimeoutFor(body: FormData): number;
|
|
17
|
+
//# sourceMappingURL=upload-timeout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-timeout.d.ts","sourceRoot":"","sources":["../../src/lib/api/upload-timeout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAWH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAG3D;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAOvD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How long to wait on a request carrying a file body.
|
|
3
|
+
*
|
|
4
|
+
* Its own module because both transports need it — the XHR upload path and the
|
|
5
|
+
* fetch client — and a second copy of a heuristic is a second thing to get
|
|
6
|
+
* wrong. No imports, so neither pays for it.
|
|
7
|
+
*
|
|
8
|
+
* Derived from the payload rather than configured. A timeout encodes no
|
|
9
|
+
* decision the way a size limit does: its only job is to stop a hung request
|
|
10
|
+
* spinning forever. Exposing it as a setting invites an inconsistent pair —
|
|
11
|
+
* raise `upload.maxFileSize` to 100MB, leave the timeout at the JSON default,
|
|
12
|
+
* and every large upload fails in a way that reads as a server rejection.
|
|
13
|
+
* Deriving it means raising the size limit adjusts the deadline for free.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Assumed floor throughput, deliberately pessimistic — a phone on a bad
|
|
17
|
+
* connection, not an office line. Too generous costs a slow failure on a
|
|
18
|
+
* genuinely dead request; too tight kills uploads that were succeeding.
|
|
19
|
+
*/
|
|
20
|
+
const UPLOAD_ASSUMED_BYTES_PER_SECOND = 64 * 1024; // ~0.5 Mbps
|
|
21
|
+
const UPLOAD_TIMEOUT_FLOOR = 30_000;
|
|
22
|
+
const UPLOAD_TIMEOUT_CEILING = 15 * 60 * 1000;
|
|
23
|
+
export function uploadTimeoutForBytes(bytes) {
|
|
24
|
+
const transfer = (bytes / UPLOAD_ASSUMED_BYTES_PER_SECOND) * 1000;
|
|
25
|
+
return Math.min(UPLOAD_TIMEOUT_CEILING, Math.max(UPLOAD_TIMEOUT_FLOOR, transfer));
|
|
26
|
+
}
|
|
27
|
+
export function uploadTimeoutFor(body) {
|
|
28
|
+
let bytes = 0;
|
|
29
|
+
for (const value of body.values()) {
|
|
30
|
+
// `File` extends `Blob`; checking Blob also covers a raw Blob part.
|
|
31
|
+
if (typeof Blob !== 'undefined' && value instanceof Blob)
|
|
32
|
+
bytes += value.size;
|
|
33
|
+
}
|
|
34
|
+
return uploadTimeoutForBytes(bytes);
|
|
35
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ApiResponse } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Uploads, on XMLHttpRequest rather than fetch.
|
|
4
|
+
*
|
|
5
|
+
* Not nostalgia: `fetch` has no upload progress event. Request body streams are
|
|
6
|
+
* the standards-track answer and are still neither broadly supported nor usable
|
|
7
|
+
* with a plain `FormData`, so XHR remains the only way to report how far a
|
|
8
|
+
* multi-megabyte upload has actually got. Everything else here exists to make
|
|
9
|
+
* that swap invisible — same `ApiResponse`, same `ApiError`, same defensive
|
|
10
|
+
* parsing — so callers can't tell which transport ran.
|
|
11
|
+
*/
|
|
12
|
+
export interface UploadOptions {
|
|
13
|
+
/** Called with 0–100 as the body is sent. Never called after completion. */
|
|
14
|
+
onProgress?: (percent: number) => void;
|
|
15
|
+
/** Aborts the upload. The promise rejects with an `ApiError` of status 0. */
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
/** Milliseconds of inactivity before giving up. */
|
|
18
|
+
timeoutMs?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* POST a FormData body with progress reporting.
|
|
22
|
+
*
|
|
23
|
+
* Resolves with the parsed body on success and rejects with `ApiError`
|
|
24
|
+
* otherwise, matching `ApiClient` exactly.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* PUT a file straight to object storage, reporting progress.
|
|
28
|
+
*
|
|
29
|
+
* Distinct from {@link uploadFormData} in two ways that matter:
|
|
30
|
+
*
|
|
31
|
+
* - **No credentials.** The target is a third-party origin and the URL already
|
|
32
|
+
* carries its own signature. Sending cookies would leak the session to the
|
|
33
|
+
* storage provider and trip CORS besides.
|
|
34
|
+
* - **Raw body, not FormData.** The signature covers the object bytes; wrapping
|
|
35
|
+
* them in multipart framing would store the framing.
|
|
36
|
+
*
|
|
37
|
+
* A failure here is very often missing bucket CORS rather than a broken file,
|
|
38
|
+
* and the browser deliberately hides the distinction — so the error says so.
|
|
39
|
+
*/
|
|
40
|
+
export declare function putToStorage(url: string, file: File | Blob, headers?: Record<string, string>, options?: UploadOptions): Promise<void>;
|
|
41
|
+
export declare function uploadFormData<T>(url: string, body: FormData, options?: UploadOptions): Promise<ApiResponse<T>>;
|
|
42
|
+
//# sourceMappingURL=upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/lib/api/upload.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;;;;GASG;AAEH,MAAM,WAAW,aAAa;IAC7B,4EAA4E;IAC5E,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,6EAA6E;IAC7E,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAC3B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,IAAI,GAAG,IAAI,EACjB,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EACpC,OAAO,GAAE,aAAkB,GACzB,OAAO,CAAC,IAAI,CAAC,CA+Df;AAED,wBAAgB,cAAc,CAAC,CAAC,EAC/B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,QAAQ,EACd,OAAO,GAAE,aAAkB,GACzB,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAuFzB"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { ApiError } from './client.js';
|
|
2
|
+
/**
|
|
3
|
+
* POST a FormData body with progress reporting.
|
|
4
|
+
*
|
|
5
|
+
* Resolves with the parsed body on success and rejects with `ApiError`
|
|
6
|
+
* otherwise, matching `ApiClient` exactly.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* PUT a file straight to object storage, reporting progress.
|
|
10
|
+
*
|
|
11
|
+
* Distinct from {@link uploadFormData} in two ways that matter:
|
|
12
|
+
*
|
|
13
|
+
* - **No credentials.** The target is a third-party origin and the URL already
|
|
14
|
+
* carries its own signature. Sending cookies would leak the session to the
|
|
15
|
+
* storage provider and trip CORS besides.
|
|
16
|
+
* - **Raw body, not FormData.** The signature covers the object bytes; wrapping
|
|
17
|
+
* them in multipart framing would store the framing.
|
|
18
|
+
*
|
|
19
|
+
* A failure here is very often missing bucket CORS rather than a broken file,
|
|
20
|
+
* and the browser deliberately hides the distinction — so the error says so.
|
|
21
|
+
*/
|
|
22
|
+
export function putToStorage(url, file, headers = {}, options = {}) {
|
|
23
|
+
const { onProgress, signal, timeoutMs } = options;
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
if (signal?.aborted) {
|
|
26
|
+
reject(new ApiError(0, null, 'Upload cancelled'));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const xhr = new XMLHttpRequest();
|
|
30
|
+
xhr.open('PUT', url, true);
|
|
31
|
+
xhr.withCredentials = false;
|
|
32
|
+
for (const [name, value] of Object.entries(headers))
|
|
33
|
+
xhr.setRequestHeader(name, value);
|
|
34
|
+
if (timeoutMs)
|
|
35
|
+
xhr.timeout = timeoutMs;
|
|
36
|
+
if (onProgress) {
|
|
37
|
+
xhr.upload.addEventListener('progress', (event) => {
|
|
38
|
+
if (event.lengthComputable && event.total > 0) {
|
|
39
|
+
onProgress(Math.min(100, Math.round((event.loaded / event.total) * 100)));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const onAbort = () => xhr.abort();
|
|
44
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
45
|
+
const cleanup = () => signal?.removeEventListener('abort', onAbort);
|
|
46
|
+
xhr.addEventListener('load', () => {
|
|
47
|
+
cleanup();
|
|
48
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
49
|
+
resolve();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
reject(new ApiError(xhr.status, null, `Storage rejected the upload (${xhr.status})`));
|
|
53
|
+
});
|
|
54
|
+
xhr.addEventListener('error', () => {
|
|
55
|
+
cleanup();
|
|
56
|
+
// A cross-origin PUT blocked by CORS surfaces here as a bare network
|
|
57
|
+
// error with no detail, by design. Naming the likely cause is the only
|
|
58
|
+
// way an operator finds it, since the browser console message is the
|
|
59
|
+
// only other clue and nobody reads it from a toast.
|
|
60
|
+
reject(new ApiError(0, null, 'Could not reach storage. The bucket may not allow PUT from this origin (CORS).'));
|
|
61
|
+
});
|
|
62
|
+
xhr.addEventListener('timeout', () => {
|
|
63
|
+
cleanup();
|
|
64
|
+
reject(new ApiError(0, null, 'Upload timed out'));
|
|
65
|
+
});
|
|
66
|
+
xhr.addEventListener('abort', () => {
|
|
67
|
+
cleanup();
|
|
68
|
+
reject(new ApiError(0, null, 'Upload cancelled'));
|
|
69
|
+
});
|
|
70
|
+
xhr.send(file);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
export function uploadFormData(url, body, options = {}) {
|
|
74
|
+
const { onProgress, signal, timeoutMs } = options;
|
|
75
|
+
return new Promise((resolve, reject) => {
|
|
76
|
+
if (signal?.aborted) {
|
|
77
|
+
reject(new ApiError(0, null, 'Upload cancelled'));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const xhr = new XMLHttpRequest();
|
|
81
|
+
xhr.open('POST', url, true);
|
|
82
|
+
// Deliberately not setting Content-Type: the browser must add the
|
|
83
|
+
// multipart boundary, and setting it by hand produces a body the server
|
|
84
|
+
// cannot parse.
|
|
85
|
+
xhr.withCredentials = true;
|
|
86
|
+
if (timeoutMs)
|
|
87
|
+
xhr.timeout = timeoutMs;
|
|
88
|
+
if (onProgress) {
|
|
89
|
+
xhr.upload.addEventListener('progress', (event) => {
|
|
90
|
+
// `lengthComputable` is false when the size isn't known up front;
|
|
91
|
+
// reporting a fabricated percentage would be worse than none.
|
|
92
|
+
if (event.lengthComputable && event.total > 0) {
|
|
93
|
+
onProgress(Math.min(100, Math.round((event.loaded / event.total) * 100)));
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
const onAbort = () => xhr.abort();
|
|
98
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
99
|
+
const cleanup = () => signal?.removeEventListener('abort', onAbort);
|
|
100
|
+
xhr.addEventListener('load', () => {
|
|
101
|
+
cleanup();
|
|
102
|
+
// Parse defensively, for the same reason the fetch client does: a
|
|
103
|
+
// proxy or serverless platform can reject the request before it
|
|
104
|
+
// reaches the app and answer with HTML, and parsing first would throw
|
|
105
|
+
// a syntax error that buries the real status.
|
|
106
|
+
let data = null;
|
|
107
|
+
try {
|
|
108
|
+
data = JSON.parse(xhr.responseText);
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
// Left null; handled below.
|
|
112
|
+
}
|
|
113
|
+
const ok = xhr.status >= 200 && xhr.status < 300;
|
|
114
|
+
if (!ok) {
|
|
115
|
+
reject(new ApiError(xhr.status, data, data?.message || data?.error || `Upload failed (${xhr.status})`));
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (!data) {
|
|
119
|
+
reject(new ApiError(xhr.status, null, 'Malformed response from server'));
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (!data.success) {
|
|
123
|
+
reject(new ApiError(xhr.status, data, data.message || data.error));
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
resolve(data);
|
|
127
|
+
});
|
|
128
|
+
xhr.addEventListener('error', () => {
|
|
129
|
+
cleanup();
|
|
130
|
+
// XHR reports network failures with no detail at all, by design —
|
|
131
|
+
// exposing more would leak cross-origin information.
|
|
132
|
+
reject(new ApiError(0, null, 'Network error during upload'));
|
|
133
|
+
});
|
|
134
|
+
xhr.addEventListener('timeout', () => {
|
|
135
|
+
cleanup();
|
|
136
|
+
reject(new ApiError(0, null, 'Upload timed out'));
|
|
137
|
+
});
|
|
138
|
+
xhr.addEventListener('abort', () => {
|
|
139
|
+
cleanup();
|
|
140
|
+
reject(new ApiError(0, null, 'Upload cancelled'));
|
|
141
|
+
});
|
|
142
|
+
xhr.send(body);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
@@ -444,6 +444,20 @@
|
|
|
444
444
|
const COLLAPSED_WIDTH = 60;
|
|
445
445
|
const TYPES_WIDTH = 350;
|
|
446
446
|
const DOCS_WIDTH = 350;
|
|
447
|
+
const VERSION_PANEL_WIDTH = 280;
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Width actually available to the panes, measured from the pane container.
|
|
451
|
+
*
|
|
452
|
+
* Not `window.innerWidth`: the app sidebar sits outside this container and is
|
|
453
|
+
* itself collapsible, so the window is wider than the panes ever get. Feeding
|
|
454
|
+
* the window width to the collapse math below made it believe there was
|
|
455
|
+
* ~260px more room than existed, so the panels never collapsed and the editor
|
|
456
|
+
* was squeezed instead. Measuring is also stable — the container is `flex-1`
|
|
457
|
+
* off the sidebar, so its width doesn't depend on the panes inside it.
|
|
458
|
+
*/
|
|
459
|
+
let contentWidth = $state(0);
|
|
460
|
+
|
|
447
461
|
let layoutConfig = $derived.by(() => {
|
|
448
462
|
const totalEditors = (currentView === 'editor' ? 1 : 0) + (editorStack.length > 0 ? 1 : 0);
|
|
449
463
|
|
|
@@ -475,37 +489,69 @@
|
|
|
475
489
|
let typesExpanded = typesActive || totalEditors < 2;
|
|
476
490
|
let docsExpanded = docsActive || totalEditors < 2;
|
|
477
491
|
|
|
492
|
+
// Everything competing with the editor for horizontal space. The version
|
|
493
|
+
// panel is a sibling of the editor inside this container, so it has to be
|
|
494
|
+
// subtracted too — leaving it out is what let a 280px panel open on top of
|
|
495
|
+
// an editor that was already at its minimum.
|
|
496
|
+
const available = (contentWidth || windowWidth) - (showVersionPanel ? VERSION_PANEL_WIDTH : 0);
|
|
497
|
+
|
|
478
498
|
let panelsWidth =
|
|
479
499
|
(typesExpanded ? TYPES_WIDTH : COLLAPSED_WIDTH) +
|
|
480
500
|
(hasDocs ? (docsExpanded ? DOCS_WIDTH : COLLAPSED_WIDTH) : 0);
|
|
481
|
-
let editorSpace =
|
|
501
|
+
let editorSpace = available - panelsWidth;
|
|
482
502
|
let maxEditors = Math.floor(editorSpace / MIN_EDITOR_WIDTH);
|
|
483
503
|
|
|
484
|
-
//
|
|
485
|
-
//
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
504
|
+
// Reclaim space for the editor by collapsing the list panels, shallowest
|
|
505
|
+
// last: docs first, then types. Panes are depth-ordered and the deepest
|
|
506
|
+
// one has priority, so an open editor is never the thing that gives way —
|
|
507
|
+
// a list panel losing 290px is recoverable in one click, an editor
|
|
508
|
+
// squeezed under its minimum is unusable.
|
|
509
|
+
//
|
|
510
|
+
// A panel the user explicitly expanded (by clicking its collapsed strip) is
|
|
511
|
+
// never collapsed — an explicit click has to take effect. Collapsing it
|
|
512
|
+
// back in the same derivation is indistinguishable from the click doing
|
|
513
|
+
// nothing. If the editor then has no room, it becomes a strip instead and
|
|
514
|
+
// one click swaps them back; every pane stays reachable.
|
|
515
|
+
const reclaim = (collapseTypes: boolean, collapseDocs: boolean) => {
|
|
516
|
+
if (maxEditors >= 1) return;
|
|
517
|
+
if (collapseDocs && hasDocs) docsExpanded = false;
|
|
518
|
+
if (collapseTypes) typesExpanded = false;
|
|
519
|
+
panelsWidth =
|
|
520
|
+
(typesExpanded ? TYPES_WIDTH : COLLAPSED_WIDTH) +
|
|
521
|
+
(hasDocs ? (docsExpanded ? DOCS_WIDTH : COLLAPSED_WIDTH) : 0);
|
|
522
|
+
editorSpace = available - panelsWidth;
|
|
523
|
+
maxEditors = Math.floor(editorSpace / MIN_EDITOR_WIDTH);
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
if (totalEditors >= 1) {
|
|
527
|
+
reclaim(false, !docsActive); // docs, unless the user just opened it
|
|
528
|
+
reclaim(!typesActive, false); // types, unless the user just opened it
|
|
493
529
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
530
|
+
// Neither list was explicitly opened, so there is no click to honour —
|
|
531
|
+
// collapse them regardless rather than leave the editor unusable.
|
|
532
|
+
if (!typesActive && !docsActive) {
|
|
533
|
+
reclaim(false, true);
|
|
534
|
+
reclaim(true, false);
|
|
499
535
|
}
|
|
500
536
|
}
|
|
501
537
|
|
|
538
|
+
// MIN_EDITOR_WIDTH is what the editor *wants*, not a floor it must clear to
|
|
539
|
+
// be shown. If the lists couldn't be collapsed any further (the user
|
|
540
|
+
// explicitly opened one), the editor simply takes what's left — a narrow
|
|
541
|
+
// editor still beats a 60px strip sitting next to unused space.
|
|
502
542
|
if (maxEditors < 1) maxEditors = 1;
|
|
503
543
|
|
|
504
|
-
// Build expanded editor indices, prioritizing active + most recent
|
|
505
|
-
|
|
544
|
+
// Build expanded editor indices, prioritizing active + most recent.
|
|
545
|
+
// A negative `validActiveIndex` means a *list* panel holds focus (-1 types,
|
|
546
|
+
// -2 docs), not an editor. Seeding the array with it left no editor in the
|
|
547
|
+
// expanded set at all, so clicking the document list collapsed the open
|
|
548
|
+
// editor to a 60px strip. Focus and space priority are separate concerns:
|
|
549
|
+
// fall back to the deepest editor so one is always expanded.
|
|
550
|
+
const primaryIndex = validActiveIndex >= 0 ? validActiveIndex : totalEditors - 1;
|
|
551
|
+
let expandedIndices: number[] = [primaryIndex];
|
|
506
552
|
if (maxEditors > 1) {
|
|
507
553
|
for (let i = totalEditors - 1; i >= 0 && expandedIndices.length < maxEditors; i--) {
|
|
508
|
-
if (i !==
|
|
554
|
+
if (i !== primaryIndex) expandedIndices.push(i);
|
|
509
555
|
}
|
|
510
556
|
}
|
|
511
557
|
|
|
@@ -522,6 +568,11 @@
|
|
|
522
568
|
};
|
|
523
569
|
});
|
|
524
570
|
|
|
571
|
+
// Pane widths: both lists are fixed (350px expanded, 60px collapsed) and never
|
|
572
|
+
// flex. Only the editor absorbs leftover width — it is the one pane that reads
|
|
573
|
+
// better wide, whereas a list stretched across 700px is mostly whitespace. With
|
|
574
|
+
// no document open the lists simply sit at their natural width and the space to
|
|
575
|
+
// the right stays empty.
|
|
525
576
|
let typesPanel = $derived.by(() => {
|
|
526
577
|
// Focus/presentation mode hides the types sidebar so the editor takes full width.
|
|
527
578
|
if (focusModeOn || presentationModeOn) return 'hidden';
|
|
@@ -609,6 +660,23 @@
|
|
|
609
660
|
fetchOrganizations();
|
|
610
661
|
});
|
|
611
662
|
|
|
663
|
+
/**
|
|
664
|
+
* A URL naming an asset should land on the media area.
|
|
665
|
+
*
|
|
666
|
+
* One-shot, on the initial URL only. Reacting to the param on every change
|
|
667
|
+
* would drag the user back to media whenever they navigated away with an
|
|
668
|
+
* `assetId` still in the query — and the param stays until the detail panel
|
|
669
|
+
* is closed, so that is the common case, not the edge one.
|
|
670
|
+
*/
|
|
671
|
+
let appliedInitialAssetId = false;
|
|
672
|
+
$effect(() => {
|
|
673
|
+
if (appliedInitialAssetId) return;
|
|
674
|
+
appliedInitialAssetId = true;
|
|
675
|
+
if (page.url.searchParams.get('assetId') && activeTab.value !== 'media') {
|
|
676
|
+
handleTabChange('media');
|
|
677
|
+
}
|
|
678
|
+
});
|
|
679
|
+
|
|
612
680
|
// Watch URL params for bookmarkable navigation
|
|
613
681
|
$effect(() => {
|
|
614
682
|
const url = page.url;
|
|
@@ -684,12 +752,22 @@
|
|
|
684
752
|
}
|
|
685
753
|
}
|
|
686
754
|
|
|
687
|
-
// Restore version history panel from URL
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
755
|
+
// Restore version history panel from URL.
|
|
756
|
+
//
|
|
757
|
+
// Retarget on every navigation, not only when the panel is closed. The
|
|
758
|
+
// `history=1` param survives switching documents, so a panel opened on
|
|
759
|
+
// document A stayed pinned to A while the editor moved to B — the version
|
|
760
|
+
// list was wrong and Restore would have written to the document the user
|
|
761
|
+
// was no longer looking at. Any preview of A's content is dropped too.
|
|
762
|
+
if (historyParam === '1') {
|
|
763
|
+
const targetDocId = stackParam
|
|
691
764
|
? (editorStack[editorStack.length - 1]?.documentId ?? docId)
|
|
692
765
|
: docId;
|
|
766
|
+
if (!showVersionPanel || versionPanelDocId !== targetDocId) {
|
|
767
|
+
showVersionPanel = true;
|
|
768
|
+
versionPanelDocId = targetDocId;
|
|
769
|
+
versionPreviewData = null;
|
|
770
|
+
}
|
|
693
771
|
} else if (!historyParam && showVersionPanel) {
|
|
694
772
|
showVersionPanel = false;
|
|
695
773
|
versionPanelDocId = null;
|
|
@@ -904,6 +982,21 @@
|
|
|
904
982
|
activeEditorIndex = 1;
|
|
905
983
|
}
|
|
906
984
|
|
|
985
|
+
/**
|
|
986
|
+
* Mirror the open asset into `?assetId=`, so a media item is linkable.
|
|
987
|
+
*
|
|
988
|
+
* `replaceState`, because browsing a media library is not navigation —
|
|
989
|
+
* clicking through twenty thumbnails would otherwise bury the page the user
|
|
990
|
+
* arrived from under twenty history entries.
|
|
991
|
+
*/
|
|
992
|
+
async function syncAssetIdParam(assetId: string | null) {
|
|
993
|
+
const params = new SvelteURLSearchParams(page.url.searchParams);
|
|
994
|
+
if (params.get('assetId') === (assetId ?? null)) return;
|
|
995
|
+
if (assetId) params.set('assetId', assetId);
|
|
996
|
+
else params.delete('assetId');
|
|
997
|
+
await goto(`/admin?${params.toString()}`, { replaceState: true, noScroll: true });
|
|
998
|
+
}
|
|
999
|
+
|
|
907
1000
|
// Back button on the stacked panel — pop one level. If the stack
|
|
908
1001
|
// becomes empty, the panel closes entirely.
|
|
909
1002
|
async function handleStackedEditorBack() {
|
|
@@ -1178,7 +1271,10 @@
|
|
|
1178
1271
|
<Tabs.Root value={activeTab.value} onValueChange={handleTabChange} class="h-full">
|
|
1179
1272
|
<Tabs.Content value="structure" class="h-full overflow-hidden">
|
|
1180
1273
|
{#key `${currentView}-${selectedDocumentType}`}
|
|
1181
|
-
<div
|
|
1274
|
+
<div
|
|
1275
|
+
bind:clientWidth={contentWidth}
|
|
1276
|
+
class={windowWidth < 620 ? 'h-full w-full' : 'flex h-full w-full overflow-hidden'}
|
|
1277
|
+
>
|
|
1182
1278
|
{#if schemaError}
|
|
1183
1279
|
<div class="bg-destructive/5 flex flex-1 items-center justify-center p-8">
|
|
1184
1280
|
<div class="w-full max-w-2xl">
|
|
@@ -1874,10 +1970,14 @@
|
|
|
1874
1970
|
{/if}
|
|
1875
1971
|
{/if}
|
|
1876
1972
|
|
|
1877
|
-
<!-- Version History Panel
|
|
1973
|
+
<!-- Version History Panel. Below 620px there is no room for a 280px
|
|
1974
|
+
column beside the editor — it left ~95px for the fields — so it
|
|
1975
|
+
becomes a full-screen sheet, dismissed with its own close button. -->
|
|
1878
1976
|
{#if showVersionPanel && versionPanelDocId}
|
|
1879
1977
|
<div
|
|
1880
|
-
class=
|
|
1978
|
+
class={windowWidth < 620
|
|
1979
|
+
? 'bg-background fixed inset-0 z-50 overflow-y-auto'
|
|
1980
|
+
: 'border-rule h-full w-[280px] shrink-0 overflow-y-auto border-l transition-all duration-200'}
|
|
1881
1981
|
>
|
|
1882
1982
|
<DocumentVersionPanel
|
|
1883
1983
|
bind:this={versionPanelRef}
|
|
@@ -1949,7 +2049,11 @@
|
|
|
1949
2049
|
{/if}
|
|
1950
2050
|
|
|
1951
2051
|
<Tabs.Content value="media" class="m-0 h-full p-0">
|
|
1952
|
-
<MediaBrowser
|
|
2052
|
+
<MediaBrowser
|
|
2053
|
+
active={activeTab.value === 'media'}
|
|
2054
|
+
assetId={page.url.searchParams.get('assetId')}
|
|
2055
|
+
onAssetOpen={syncAssetIdParam}
|
|
2056
|
+
/>
|
|
1953
2057
|
</Tabs.Content>
|
|
1954
2058
|
|
|
1955
2059
|
<!-- Plugin admin tools — each rendered as its own top-level area. -->
|