payload 4.0.0-beta.11 → 4.0.0-beta.12
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/admin/forms/Form.d.ts +0 -7
- package/dist/admin/forms/Form.d.ts.map +1 -1
- package/dist/admin/forms/Form.js.map +1 -1
- package/dist/collections/operations/count.d.ts.map +1 -1
- package/dist/collections/operations/count.js +3 -1
- package/dist/collections/operations/count.js.map +1 -1
- package/dist/collections/operations/countVersions.d.ts.map +1 -1
- package/dist/collections/operations/countVersions.js +3 -1
- package/dist/collections/operations/countVersions.js.map +1 -1
- package/dist/collections/operations/delete.d.ts.map +1 -1
- package/dist/collections/operations/delete.js +9 -7
- package/dist/collections/operations/delete.js.map +1 -1
- package/dist/collections/operations/find.d.ts.map +1 -1
- package/dist/collections/operations/find.js +9 -15
- package/dist/collections/operations/find.js.map +1 -1
- package/dist/collections/operations/findDistinct.d.ts.map +1 -1
- package/dist/collections/operations/findDistinct.js +3 -1
- package/dist/collections/operations/findDistinct.js.map +1 -1
- package/dist/collections/operations/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/findVersions.js +10 -8
- package/dist/collections/operations/findVersions.js.map +1 -1
- package/dist/collections/operations/renameFile.d.ts.map +1 -1
- package/dist/collections/operations/renameFile.js +16 -9
- package/dist/collections/operations/renameFile.js.map +1 -1
- package/dist/collections/operations/update.d.ts.map +1 -1
- package/dist/collections/operations/update.js +9 -15
- package/dist/collections/operations/update.js.map +1 -1
- package/dist/database/cloneWhere.d.ts +10 -0
- package/dist/database/cloneWhere.d.ts.map +1 -0
- package/dist/database/cloneWhere.js +31 -0
- package/dist/database/cloneWhere.js.map +1 -0
- package/dist/database/nestedRelationshipReadConstraint.d.ts +20 -0
- package/dist/database/nestedRelationshipReadConstraint.d.ts.map +1 -0
- package/dist/database/nestedRelationshipReadConstraint.js +33 -0
- package/dist/database/nestedRelationshipReadConstraint.js.map +1 -0
- package/dist/database/queryValidation/validateSearchParams.d.ts.map +1 -1
- package/dist/database/queryValidation/validateSearchParams.js +36 -1
- package/dist/database/queryValidation/validateSearchParams.js.map +1 -1
- package/dist/database/queryValidation/validateSortQuery.d.ts.map +1 -1
- package/dist/database/queryValidation/validateSortQuery.js +4 -2
- package/dist/database/queryValidation/validateSortQuery.js.map +1 -1
- package/dist/exports/internal.d.ts +1 -0
- package/dist/exports/internal.d.ts.map +1 -1
- package/dist/exports/internal.js +1 -0
- package/dist/exports/internal.js.map +1 -1
- package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/index.js +6 -0
- package/dist/fields/hooks/beforeChange/index.js.map +1 -1
- package/dist/globals/operations/countGlobalVersions.d.ts.map +1 -1
- package/dist/globals/operations/countGlobalVersions.js +3 -1
- package/dist/globals/operations/countGlobalVersions.js.map +1 -1
- package/dist/globals/operations/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/findVersions.js +10 -8
- package/dist/globals/operations/findVersions.js.map +1 -1
- package/dist/index.bundled.d.ts +0 -7
- package/dist/uploads/fileVersioning/archive.d.ts.map +1 -1
- package/dist/uploads/fileVersioning/archive.js +5 -13
- package/dist/uploads/fileVersioning/archive.js.map +1 -1
- package/dist/uploads/fileVersioning/cloudStorage.d.ts.map +1 -1
- package/dist/uploads/fileVersioning/cloudStorage.js +6 -7
- package/dist/uploads/fileVersioning/cloudStorage.js.map +1 -1
- package/dist/uploads/fileVersioning/resolveHistoricalFile.d.ts.map +1 -1
- package/dist/uploads/fileVersioning/resolveHistoricalFile.js +48 -48
- package/dist/uploads/fileVersioning/resolveHistoricalFile.js.map +1 -1
- package/dist/uploads/fileVersioning/restore.d.ts.map +1 -1
- package/dist/uploads/fileVersioning/restore.js +7 -9
- package/dist/uploads/fileVersioning/restore.js.map +1 -1
- package/dist/uploads/fileVersioning/restoreRequestTime.d.ts.map +1 -1
- package/dist/uploads/fileVersioning/restoreRequestTime.js +22 -36
- package/dist/uploads/fileVersioning/restoreRequestTime.js.map +1 -1
- package/dist/uploads/fileVersioning/storedFiles.d.ts +39 -8
- package/dist/uploads/fileVersioning/storedFiles.d.ts.map +1 -1
- package/dist/uploads/fileVersioning/storedFiles.js +150 -93
- package/dist/uploads/fileVersioning/storedFiles.js.map +1 -1
- package/dist/uploads/fileVersioning/types.d.ts +13 -1
- package/dist/uploads/fileVersioning/types.d.ts.map +1 -1
- package/dist/uploads/fileVersioning/types.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +6 -0
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/sanitizeUpdateData.d.ts +5 -0
- package/dist/utilities/sanitizeUpdateData.d.ts.map +1 -0
- package/dist/utilities/sanitizeUpdateData.js +10 -0
- package/dist/utilities/sanitizeUpdateData.js.map +1 -0
- package/package.json +2 -2
|
@@ -5,116 +5,139 @@ import { normalizeStorageKey } from './naming.js';
|
|
|
5
5
|
export const getStoredFileIdentity = ({ key })=>normalizeStorageKey({
|
|
6
6
|
key
|
|
7
7
|
});
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return files;
|
|
8
|
+
/**
|
|
9
|
+
* Lists the saved objects of the main file, the original and each size, in that order. Values
|
|
10
|
+
* that are not objects are left out. Each value is the document's own object, not a copy.
|
|
11
|
+
*/ export const getUploadFileObjects = ({ doc })=>{
|
|
12
|
+
const variants = isEntryObject(doc.variants) ? Object.entries(doc.variants) : [];
|
|
13
|
+
const values = [
|
|
14
|
+
{
|
|
15
|
+
role: {
|
|
16
|
+
type: 'default'
|
|
17
|
+
},
|
|
18
|
+
value: doc
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
role: {
|
|
22
|
+
type: 'original'
|
|
23
|
+
},
|
|
24
|
+
value: doc.original
|
|
25
|
+
},
|
|
26
|
+
...variants.map(([sizeKey, value])=>({
|
|
27
|
+
role: {
|
|
28
|
+
type: 'size',
|
|
29
|
+
sizeKey
|
|
30
|
+
},
|
|
31
|
+
value
|
|
32
|
+
}))
|
|
33
|
+
];
|
|
34
|
+
return values.filter((entry)=>isEntryObject(entry.value));
|
|
38
35
|
};
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
/** The document's own object for one role, so a caller can change that entry. */ export const getUploadFileObject = ({ doc, role })=>getUploadFileObjects({
|
|
37
|
+
doc
|
|
38
|
+
}).find((entry)=>isSameFileRole({
|
|
39
|
+
first: entry.role,
|
|
40
|
+
second: role
|
|
41
|
+
}))?.value;
|
|
42
|
+
export const isSameFileRole = ({ first, second })=>first.type === second.type && (first.type !== 'size' || second.type === 'size' && first.sizeKey === second.sizeKey);
|
|
43
|
+
/** Older uploads without an original have not been identified as Payload-managed. */ export const isManagedUpload = ({ doc })=>isEntryObject(doc.original) && typeof doc.original.filename === 'string';
|
|
44
|
+
/**
|
|
45
|
+
* Lists the main file, the original and each size of a saved upload, one entry per role. Each
|
|
46
|
+
* entry says whether Payload stores it, builds it on request, or does not manage it. Run
|
|
47
|
+
* `withLegacyUploadFileData` or `withLegacyCloudUploadFileData` first for older documents.
|
|
48
|
+
*/ export const getUploadFileEntries = ({ collection, doc, req, roles, trustGenerated = false })=>{
|
|
49
|
+
const isManaged = isManagedUpload({
|
|
50
|
+
doc
|
|
51
|
+
});
|
|
52
|
+
const objects = getUploadFileObjects({
|
|
53
|
+
doc
|
|
54
|
+
}).filter(({ role })=>!roles || roles.some((wanted)=>isSameFileRole({
|
|
55
|
+
first: wanted,
|
|
56
|
+
second: role
|
|
57
|
+
})));
|
|
58
|
+
return objects.flatMap(({ role, value })=>{
|
|
59
|
+
if (typeof value.filename !== 'string') {
|
|
60
|
+
return [];
|
|
46
61
|
}
|
|
47
|
-
const
|
|
62
|
+
const filename = value.filename;
|
|
48
63
|
// A `_stored: false` entry is built when it is requested, so it has no object to copy or delete.
|
|
49
|
-
|
|
50
|
-
|
|
64
|
+
// An original is never built on request, so Payload does not manage one with that marker.
|
|
65
|
+
if (isRequestTimeFile({
|
|
66
|
+
entry: value
|
|
51
67
|
})) {
|
|
52
|
-
return
|
|
68
|
+
return [
|
|
69
|
+
{
|
|
70
|
+
role,
|
|
71
|
+
status: role.type === 'original' ? 'unmanaged' : 'requestTime'
|
|
72
|
+
}
|
|
73
|
+
];
|
|
53
74
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
75
|
+
if (!isManaged || !collection.upload.fileOperations && !trustGenerated && !hasPayloadFileURL({
|
|
76
|
+
collection,
|
|
77
|
+
doc,
|
|
78
|
+
entry: value,
|
|
58
79
|
filename,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
filename,
|
|
69
|
-
isOriginal: true,
|
|
70
|
-
relative: true,
|
|
71
|
-
urlOrPath: undefined
|
|
72
|
-
}))) {
|
|
73
|
-
return;
|
|
80
|
+
req,
|
|
81
|
+
role
|
|
82
|
+
})) {
|
|
83
|
+
return [
|
|
84
|
+
{
|
|
85
|
+
role,
|
|
86
|
+
status: 'unmanaged'
|
|
87
|
+
}
|
|
88
|
+
];
|
|
74
89
|
}
|
|
75
|
-
|
|
76
|
-
const _objectKey = typeof representation._objectKey === 'string' ? representation._objectKey : undefined;
|
|
77
|
-
const key = operations ? operations.resolveStorageKey({
|
|
78
|
-
_objectKey,
|
|
79
|
-
filename,
|
|
80
|
-
prefix
|
|
81
|
-
}) : filename;
|
|
82
|
-
references.push({
|
|
83
|
-
key,
|
|
90
|
+
validateRole({
|
|
84
91
|
role
|
|
85
92
|
});
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
return [
|
|
94
|
+
{
|
|
95
|
+
key: resolveStorageKey({
|
|
96
|
+
collection,
|
|
97
|
+
entry: value,
|
|
98
|
+
filename
|
|
99
|
+
}),
|
|
100
|
+
role,
|
|
101
|
+
status: 'stored'
|
|
102
|
+
}
|
|
103
|
+
];
|
|
93
104
|
});
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
105
|
+
};
|
|
106
|
+
/** Lists the stored objects of a saved upload. An object shared by several roles is listed once. */ export const collectStoredFiles = (args)=>{
|
|
107
|
+
const files = [];
|
|
108
|
+
const fileByIdentity = new Map();
|
|
109
|
+
for (const entry of getUploadFileEntries(args)){
|
|
110
|
+
if (entry.status !== 'stored') {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
const identity = getStoredFileIdentity({
|
|
114
|
+
key: entry.key
|
|
115
|
+
});
|
|
116
|
+
const file = fileByIdentity.get(identity);
|
|
117
|
+
if (file) {
|
|
118
|
+
file.roles.push(entry.role);
|
|
119
|
+
} else {
|
|
120
|
+
const newFile = {
|
|
121
|
+
key: entry.key,
|
|
122
|
+
roles: [
|
|
123
|
+
entry.role
|
|
124
|
+
]
|
|
125
|
+
};
|
|
126
|
+
fileByIdentity.set(identity, newFile);
|
|
127
|
+
files.push(newFile);
|
|
103
128
|
}
|
|
104
129
|
}
|
|
105
|
-
return
|
|
106
|
-
references
|
|
107
|
-
});
|
|
130
|
+
return files;
|
|
108
131
|
};
|
|
109
|
-
/** Whether the original is
|
|
132
|
+
/** Whether the original is stored, so a request-time file can be built from it. */ export const hasStoredOriginal = ({ entries })=>entries.some(({ role, status })=>status === 'stored' && role.type === 'original');
|
|
110
133
|
export const withLegacyUploadFileData = ({ collection, config, doc })=>{
|
|
111
134
|
const upload = typeof collection.upload === 'object' ? collection.upload : {};
|
|
112
135
|
const filename = doc.filename;
|
|
113
136
|
const url = doc.url;
|
|
114
137
|
const filesize = doc.filesize;
|
|
115
138
|
const mimeType = doc.mimeType;
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
139
|
+
const hasOriginalData = doc.original && typeof doc.original === 'object' && !Array.isArray(doc.original) && Object.values(doc.original).some((value)=>value !== null && value !== undefined);
|
|
140
|
+
if (hasOriginalData) {
|
|
118
141
|
return doc;
|
|
119
142
|
}
|
|
120
143
|
if (typeof filename !== 'string' || typeof url !== 'string' || typeof filesize !== 'number' || typeof mimeType !== 'string' || upload.disableLocalStorage || upload.adapter) {
|
|
@@ -161,7 +184,9 @@ export const withLegacyCloudUploadFileData = async ({ collection, doc, req })=>{
|
|
|
161
184
|
doc
|
|
162
185
|
});
|
|
163
186
|
const operations = typeof collection.upload === 'object' ? collection.upload.fileOperations : undefined;
|
|
164
|
-
if (
|
|
187
|
+
if (isManagedUpload({
|
|
188
|
+
doc: stored
|
|
189
|
+
}) || !operations?.hasLegacyFile || typeof stored.filename !== 'string' || typeof stored.url !== 'string' || typeof stored.filesize !== 'number' || typeof stored.mimeType !== 'string') {
|
|
165
190
|
return stored;
|
|
166
191
|
}
|
|
167
192
|
if (!await operations.hasLegacyFile({
|
|
@@ -192,7 +217,39 @@ export const withLegacyCloudUploadFileData = async ({ collection, doc, req })=>{
|
|
|
192
217
|
variants
|
|
193
218
|
});
|
|
194
219
|
};
|
|
195
|
-
const
|
|
220
|
+
const isEntryObject = (value)=>Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
221
|
+
/** Without a storage adapter, an entry is Payload-managed only when its URL is Payload's file route. */ const hasPayloadFileURL = ({ collection, doc, entry, filename, req, role })=>{
|
|
222
|
+
const getFileURL = ({ isOriginal })=>generateFilePathOrURL({
|
|
223
|
+
collectionSlug: collection.slug,
|
|
224
|
+
config: req.payload.config,
|
|
225
|
+
filename,
|
|
226
|
+
isOriginal,
|
|
227
|
+
relative: true,
|
|
228
|
+
urlOrPath: undefined
|
|
229
|
+
});
|
|
230
|
+
if (entry.url === getFileURL({
|
|
231
|
+
isOriginal: role.type === 'original' && shouldRequestOriginal({
|
|
232
|
+
doc
|
|
233
|
+
})
|
|
234
|
+
})) {
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
// Archiving can rename the original away from the main file while retaining its role query.
|
|
238
|
+
return role.type === 'original' && entry.url === getFileURL({
|
|
239
|
+
isOriginal: true
|
|
240
|
+
});
|
|
241
|
+
};
|
|
242
|
+
const resolveStorageKey = ({ collection, entry, filename })=>{
|
|
243
|
+
const operations = collection.upload.fileOperations;
|
|
244
|
+
const key = operations ? operations.resolveStorageKey({
|
|
245
|
+
_objectKey: typeof entry._objectKey === 'string' ? entry._objectKey : undefined,
|
|
246
|
+
filename,
|
|
247
|
+
prefix: typeof entry.prefix === 'string' ? entry.prefix : undefined
|
|
248
|
+
}) : filename;
|
|
249
|
+
return normalizeStorageKey({
|
|
250
|
+
key
|
|
251
|
+
});
|
|
252
|
+
};
|
|
196
253
|
const validateRole = ({ role })=>{
|
|
197
254
|
if (role.type === 'size' && (!role.sizeKey || role.sizeKey.includes('/'))) {
|
|
198
255
|
throw new Error('A stored variant requires a safe size key');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/uploads/fileVersioning/storedFiles.ts"],"sourcesContent":["import type { CollectionConfig, SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type { Config } from '../../config/types.js'\nimport type { PayloadRequest } from '../../types/index.js'\nimport type { OriginalFileData } from '../types.js'\nimport type {\n StoredFileIdentity,\n StoredFileList,\n StoredFileReference,\n StoredFileRole,\n} from './types.js'\n\nimport { generateFilePathOrURL } from '../generateFilePathOrURL.js'\nimport { shouldRequestOriginal } from '../isOriginalFileRequest.js'\nimport { isRequestTimeFile } from '../isRequestTimeFile.js'\nimport { normalizeStorageKey } from './naming.js'\n\nexport const getStoredFileIdentity = ({ key }: StoredFileIdentity): string =>\n normalizeStorageKey({ key })\n\nconst createStoredFileList = ({\n references,\n}: {\n references: StoredFileReference[]\n}): StoredFileList => {\n const files: StoredFileList = []\n const fileByIdentity = new Map<string, StoredFileList[number]>()\n\n for (const { key, role } of references) {\n validateRole({ role })\n\n const normalizedKey = normalizeStorageKey({ key })\n const identity = getStoredFileIdentity({ key: normalizedKey })\n let file = fileByIdentity.get(identity)\n\n if (!file) {\n file = { key: normalizedKey, roles: [] }\n fileByIdentity.set(identity, file)\n files.push(file)\n }\n\n if (!file.roles.some((existingRole) => isSameRole({ first: existingRole, second: role }))) {\n file.roles.push(role)\n }\n }\n\n return files\n}\n\n/** Builds the file list from the locations saved on each stored representation. */\nexport const collectStoredFiles = ({\n collection,\n doc,\n req,\n trustGenerated = false,\n}: {\n collection: SanitizedCollectionConfig\n doc: Record<string, unknown>\n req: PayloadRequest\n trustGenerated?: boolean\n}): StoredFileList => {\n const upload = collection.upload\n const operations = upload.fileOperations\n const references: StoredFileReference[] = []\n const add = (value: unknown, role: StoredFileRole) => {\n if (!value || typeof value !== 'object' || Array.isArray(value)) {\n return\n }\n const representation = value as Record<string, unknown>\n // A `_stored: false` entry is built when it is requested, so it has no object to copy or delete.\n if (\n typeof representation.filename !== 'string' ||\n isRequestTimeFile({ entry: representation })\n ) {\n return\n }\n const filename = representation.filename\n if (\n !operations &&\n !trustGenerated &&\n representation.url !==\n generateFilePathOrURL({\n collectionSlug: collection.slug,\n config: req.payload.config,\n filename,\n isOriginal: role.type === 'original' && shouldRequestOriginal({ doc }),\n relative: true,\n urlOrPath: undefined,\n }) &&\n // Archiving can rename the original away from the main file while retaining its role query.\n (role.type !== 'original' ||\n representation.url !==\n generateFilePathOrURL({\n collectionSlug: collection.slug,\n config: req.payload.config,\n filename,\n isOriginal: true,\n relative: true,\n urlOrPath: undefined,\n }))\n ) {\n return\n }\n const prefix = typeof representation.prefix === 'string' ? representation.prefix : undefined\n const _objectKey =\n typeof representation._objectKey === 'string' ? representation._objectKey : undefined\n const key = operations\n ? operations.resolveStorageKey({ _objectKey, filename, prefix })\n : filename\n references.push({ key, role })\n }\n\n // Older uploads without an original have not been identified as Payload-managed.\n if (\n !doc.original ||\n typeof doc.original !== 'object' ||\n typeof (doc.original as Record<string, unknown>).filename !== 'string'\n ) {\n return []\n }\n add(doc, { type: 'default' })\n add(doc.original, { type: 'original' })\n if (doc.variants && typeof doc.variants === 'object' && !Array.isArray(doc.variants)) {\n for (const [sizeKey, value] of Object.entries(doc.variants)) {\n add(value, { type: 'size', sizeKey })\n }\n }\n return createStoredFileList({ references })\n}\n\n/** Whether the original is one of the stored files, so a request-time file can be built from it. */\nexport const hasStoredOriginal = ({ storedFiles }: { storedFiles: StoredFileList }): boolean =>\n storedFiles.some(({ roles }) => roles.some(({ type }) => type === 'original'))\n\nexport const withLegacyUploadFileData = ({\n collection,\n config,\n doc,\n}: {\n collection: CollectionConfig\n config: Pick<Config, 'routes' | 'serverURL'>\n doc: Record<string, unknown>\n}): Record<string, unknown> => {\n const upload = typeof collection.upload === 'object' ? collection.upload : {}\n const filename = doc.filename\n const url = doc.url\n const filesize = doc.filesize\n const mimeType = doc.mimeType\n\n const hasStoredOriginal =\n doc.original &&\n typeof doc.original === 'object' &&\n !Array.isArray(doc.original) &&\n Object.values(doc.original).some((value) => value !== null && value !== undefined)\n\n if (hasStoredOriginal) {\n return doc\n }\n\n if (\n typeof filename !== 'string' ||\n typeof url !== 'string' ||\n typeof filesize !== 'number' ||\n typeof mimeType !== 'string' ||\n upload.disableLocalStorage ||\n upload.adapter\n ) {\n return doc\n }\n\n const expectedURL = generateFilePathOrURL({\n collectionSlug: collection.slug,\n config,\n filename,\n relative: true,\n urlOrPath: undefined,\n })\n\n if (url !== expectedURL) {\n return doc\n }\n\n try {\n normalizeStorageKey({ key: filename })\n } catch {\n return doc\n }\n\n const original: OriginalFileData = {\n filename,\n filesize,\n mimeType,\n url,\n }\n if (typeof doc.width === 'number') {\n original.width = doc.width\n }\n if (typeof doc.height === 'number') {\n original.height = doc.height\n }\n\n return {\n ...doc,\n original,\n }\n}\n\nexport const withLegacyCloudUploadFileData = async <T extends Record<string, unknown>>({\n collection,\n doc,\n req,\n}: {\n collection: CollectionConfig\n doc: T\n req: PayloadRequest\n}): Promise<T> => {\n const stored = withLegacyUploadFileData({ collection, config: req.payload.config, doc })\n const operations =\n typeof collection.upload === 'object' ? collection.upload.fileOperations : undefined\n\n if (\n (stored.original &&\n typeof stored.original === 'object' &&\n typeof (stored.original as Record<string, unknown>).filename === 'string') ||\n !operations?.hasLegacyFile ||\n typeof stored.filename !== 'string' ||\n typeof stored.url !== 'string' ||\n typeof stored.filesize !== 'number' ||\n typeof stored.mimeType !== 'string'\n ) {\n return stored as T\n }\n\n if (!(await operations.hasLegacyFile({ doc: stored, req }))) {\n return stored as T\n }\n\n const variants =\n stored.variants && typeof stored.variants === 'object'\n ? Object.fromEntries(\n Object.entries(stored.variants).map(([name, value]) => [\n name,\n value && typeof value === 'object'\n ? { ...value, _objectKey: stored._objectKey, prefix: stored.prefix }\n : value,\n ]),\n )\n : stored.variants\n\n return Object.assign({}, doc, stored, {\n original: {\n _objectKey: stored._objectKey,\n filename: stored.filename,\n filesize: stored.filesize,\n height: stored.height,\n mimeType: stored.mimeType,\n prefix: stored.prefix,\n url: stored.url,\n width: stored.width,\n },\n variants,\n })\n}\n\nconst isSameRole = ({ first, second }: { first: StoredFileRole; second: StoredFileRole }) =>\n first.type === second.type &&\n (first.type !== 'size' || (second.type === 'size' && first.sizeKey === second.sizeKey))\n\nconst validateRole = ({ role }: { role: StoredFileRole }): void => {\n if (role.type === 'size' && (!role.sizeKey || role.sizeKey.includes('/'))) {\n throw new Error('A stored variant requires a safe size key')\n }\n}\n"],"names":["generateFilePathOrURL","shouldRequestOriginal","isRequestTimeFile","normalizeStorageKey","getStoredFileIdentity","key","createStoredFileList","references","files","fileByIdentity","Map","role","validateRole","normalizedKey","identity","file","get","roles","set","push","some","existingRole","isSameRole","first","second","collectStoredFiles","collection","doc","req","trustGenerated","upload","operations","fileOperations","add","value","Array","isArray","representation","filename","entry","url","collectionSlug","slug","config","payload","isOriginal","type","relative","urlOrPath","undefined","prefix","_objectKey","resolveStorageKey","original","variants","sizeKey","Object","entries","hasStoredOriginal","storedFiles","withLegacyUploadFileData","filesize","mimeType","values","disableLocalStorage","adapter","expectedURL","width","height","withLegacyCloudUploadFileData","stored","hasLegacyFile","fromEntries","map","name","assign","includes","Error"],"mappings":"AAWA,SAASA,qBAAqB,QAAQ,8BAA6B;AACnE,SAASC,qBAAqB,QAAQ,8BAA6B;AACnE,SAASC,iBAAiB,QAAQ,0BAAyB;AAC3D,SAASC,mBAAmB,QAAQ,cAAa;AAEjD,OAAO,MAAMC,wBAAwB,CAAC,EAAEC,GAAG,EAAsB,GAC/DF,oBAAoB;QAAEE;IAAI,GAAE;AAE9B,MAAMC,uBAAuB,CAAC,EAC5BC,UAAU,EAGX;IACC,MAAMC,QAAwB,EAAE;IAChC,MAAMC,iBAAiB,IAAIC;IAE3B,KAAK,MAAM,EAAEL,GAAG,EAAEM,IAAI,EAAE,IAAIJ,WAAY;QACtCK,aAAa;YAAED;QAAK;QAEpB,MAAME,gBAAgBV,oBAAoB;YAAEE;QAAI;QAChD,MAAMS,WAAWV,sBAAsB;YAAEC,KAAKQ;QAAc;QAC5D,IAAIE,OAAON,eAAeO,GAAG,CAACF;QAE9B,IAAI,CAACC,MAAM;YACTA,OAAO;gBAAEV,KAAKQ;gBAAeI,OAAO,EAAE;YAAC;YACvCR,eAAeS,GAAG,CAACJ,UAAUC;YAC7BP,MAAMW,IAAI,CAACJ;QACb;QAEA,IAAI,CAACA,KAAKE,KAAK,CAACG,IAAI,CAAC,CAACC,eA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AA,MAAMuB,IAAI,KAAK,UAAWtB,OAAOsB,IAAI,KAAK,UAAUvB,MAAMgC,OAAO,KAAK/B,OAAO+B,OAAO;AAEvF,MAAM3C,eAAe,CAAC,EAAED,IAAI,EAA4B;IACtD,IAAIA,KAAKmC,IAAI,KAAK,UAAW,CAAA,CAACnC,KAAK4C,OAAO,IAAI5C,KAAK4C,OAAO,CAACqB,QAAQ,CAAC,IAAG,GAAI;QACzE,MAAM,IAAIC,MAAM;IAClB;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/uploads/fileVersioning/storedFiles.ts"],"sourcesContent":["import type { CollectionConfig, SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type { Config } from '../../config/types.js'\nimport type { PayloadRequest } from '../../types/index.js'\nimport type { OriginalFileData } from '../types.js'\nimport type {\n StoredFile,\n StoredFileIdentity,\n StoredFileList,\n StoredFileRole,\n UploadFileEntry,\n UploadFileObject,\n} from './types.js'\n\nimport { generateFilePathOrURL } from '../generateFilePathOrURL.js'\nimport { shouldRequestOriginal } from '../isOriginalFileRequest.js'\nimport { isRequestTimeFile } from '../isRequestTimeFile.js'\nimport { normalizeStorageKey } from './naming.js'\n\ntype UploadFileEntriesArgs = {\n collection: SanitizedCollectionConfig\n doc: Record<string, unknown>\n req: PayloadRequest\n /** Read only these roles, so a damaged entry for another role does not throw. */\n roles?: StoredFileRole[]\n /** Treat local entries as Payload-managed without checking their URL, for a next state Payload built. */\n trustGenerated?: boolean\n}\n\nexport const getStoredFileIdentity = ({ key }: StoredFileIdentity): string =>\n normalizeStorageKey({ key })\n\n/**\n * Lists the saved objects of the main file, the original and each size, in that order. Values\n * that are not objects are left out. Each value is the document's own object, not a copy.\n */\nexport const getUploadFileObjects = ({\n doc,\n}: {\n doc: Record<string, unknown>\n}): UploadFileObject[] => {\n const variants = isEntryObject(doc.variants) ? Object.entries(doc.variants) : []\n const values: { role: StoredFileRole; value: unknown }[] = [\n { role: { type: 'default' }, value: doc },\n { role: { type: 'original' }, value: doc.original },\n ...variants.map(([sizeKey, value]) => ({\n role: { type: 'size', sizeKey } as const,\n value,\n })),\n ]\n\n return values.filter((entry): entry is UploadFileObject => isEntryObject(entry.value))\n}\n\n/** The document's own object for one role, so a caller can change that entry. */\nexport const getUploadFileObject = ({\n doc,\n role,\n}: {\n doc: Record<string, unknown>\n role: StoredFileRole\n}): Record<string, unknown> | undefined =>\n getUploadFileObjects({ doc }).find((entry) => isSameFileRole({ first: entry.role, second: role }))\n ?.value\n\nexport const isSameFileRole = ({\n first,\n second,\n}: {\n first: StoredFileRole\n second: StoredFileRole\n}): boolean =>\n first.type === second.type &&\n (first.type !== 'size' || (second.type === 'size' && first.sizeKey === second.sizeKey))\n\n/** Older uploads without an original have not been identified as Payload-managed. */\nexport const isManagedUpload = ({ doc }: { doc: Record<string, unknown> }): boolean =>\n isEntryObject(doc.original) && typeof doc.original.filename === 'string'\n\n/**\n * Lists the main file, the original and each size of a saved upload, one entry per role. Each\n * entry says whether Payload stores it, builds it on request, or does not manage it. Run\n * `withLegacyUploadFileData` or `withLegacyCloudUploadFileData` first for older documents.\n */\nexport const getUploadFileEntries = ({\n collection,\n doc,\n req,\n roles,\n trustGenerated = false,\n}: UploadFileEntriesArgs): UploadFileEntry[] => {\n const isManaged = isManagedUpload({ doc })\n const objects = getUploadFileObjects({ doc }).filter(\n ({ role }) => !roles || roles.some((wanted) => isSameFileRole({ first: wanted, second: role })),\n )\n\n return objects.flatMap(({ role, value }): UploadFileEntry[] => {\n if (typeof value.filename !== 'string') {\n return []\n }\n\n const filename = value.filename\n\n // A `_stored: false` entry is built when it is requested, so it has no object to copy or delete.\n // An original is never built on request, so Payload does not manage one with that marker.\n if (isRequestTimeFile({ entry: value })) {\n return [{ role, status: role.type === 'original' ? 'unmanaged' : 'requestTime' }]\n }\n\n if (\n !isManaged ||\n (!collection.upload.fileOperations &&\n !trustGenerated &&\n !hasPayloadFileURL({ collection, doc, entry: value, filename, req, role }))\n ) {\n return [{ role, status: 'unmanaged' }]\n }\n\n validateRole({ role })\n\n return [\n {\n key: resolveStorageKey({ collection, entry: value, filename }),\n role,\n status: 'stored',\n },\n ]\n })\n}\n\n/** Lists the stored objects of a saved upload. An object shared by several roles is listed once. */\nexport const collectStoredFiles = (args: UploadFileEntriesArgs): StoredFileList => {\n const files: StoredFileList = []\n const fileByIdentity = new Map<string, StoredFile>()\n\n for (const entry of getUploadFileEntries(args)) {\n if (entry.status !== 'stored') {\n continue\n }\n\n const identity = getStoredFileIdentity({ key: entry.key })\n const file = fileByIdentity.get(identity)\n\n if (file) {\n file.roles.push(entry.role)\n } else {\n const newFile = { key: entry.key, roles: [entry.role] }\n fileByIdentity.set(identity, newFile)\n files.push(newFile)\n }\n }\n\n return files\n}\n\n/** Whether the original is stored, so a request-time file can be built from it. */\nexport const hasStoredOriginal = ({ entries }: { entries: UploadFileEntry[] }): boolean =>\n entries.some(({ role, status }) => status === 'stored' && role.type === 'original')\n\nexport const withLegacyUploadFileData = ({\n collection,\n config,\n doc,\n}: {\n collection: CollectionConfig\n config: Pick<Config, 'routes' | 'serverURL'>\n doc: Record<string, unknown>\n}): Record<string, unknown> => {\n const upload = typeof collection.upload === 'object' ? collection.upload : {}\n const filename = doc.filename\n const url = doc.url\n const filesize = doc.filesize\n const mimeType = doc.mimeType\n\n const hasOriginalData =\n doc.original &&\n typeof doc.original === 'object' &&\n !Array.isArray(doc.original) &&\n Object.values(doc.original).some((value) => value !== null && value !== undefined)\n\n if (hasOriginalData) {\n return doc\n }\n\n if (\n typeof filename !== 'string' ||\n typeof url !== 'string' ||\n typeof filesize !== 'number' ||\n typeof mimeType !== 'string' ||\n upload.disableLocalStorage ||\n upload.adapter\n ) {\n return doc\n }\n\n const expectedURL = generateFilePathOrURL({\n collectionSlug: collection.slug,\n config,\n filename,\n relative: true,\n urlOrPath: undefined,\n })\n\n if (url !== expectedURL) {\n return doc\n }\n\n try {\n normalizeStorageKey({ key: filename })\n } catch {\n return doc\n }\n\n const original: OriginalFileData = {\n filename,\n filesize,\n mimeType,\n url,\n }\n if (typeof doc.width === 'number') {\n original.width = doc.width\n }\n if (typeof doc.height === 'number') {\n original.height = doc.height\n }\n\n return {\n ...doc,\n original,\n }\n}\n\nexport const withLegacyCloudUploadFileData = async <T extends Record<string, unknown>>({\n collection,\n doc,\n req,\n}: {\n collection: CollectionConfig\n doc: T\n req: PayloadRequest\n}): Promise<T> => {\n const stored = withLegacyUploadFileData({ collection, config: req.payload.config, doc })\n const operations =\n typeof collection.upload === 'object' ? collection.upload.fileOperations : undefined\n\n if (\n isManagedUpload({ doc: stored }) ||\n !operations?.hasLegacyFile ||\n typeof stored.filename !== 'string' ||\n typeof stored.url !== 'string' ||\n typeof stored.filesize !== 'number' ||\n typeof stored.mimeType !== 'string'\n ) {\n return stored as T\n }\n\n if (!(await operations.hasLegacyFile({ doc: stored, req }))) {\n return stored as T\n }\n\n const variants =\n stored.variants && typeof stored.variants === 'object'\n ? Object.fromEntries(\n Object.entries(stored.variants).map(([name, value]) => [\n name,\n value && typeof value === 'object'\n ? { ...value, _objectKey: stored._objectKey, prefix: stored.prefix }\n : value,\n ]),\n )\n : stored.variants\n\n return Object.assign({}, doc, stored, {\n original: {\n _objectKey: stored._objectKey,\n filename: stored.filename,\n filesize: stored.filesize,\n height: stored.height,\n mimeType: stored.mimeType,\n prefix: stored.prefix,\n url: stored.url,\n width: stored.width,\n },\n variants,\n })\n}\n\nconst isEntryObject = (value: unknown): value is Record<string, unknown> =>\n Boolean(value) && typeof value === 'object' && !Array.isArray(value)\n\n/** Without a storage adapter, an entry is Payload-managed only when its URL is Payload's file route. */\nconst hasPayloadFileURL = ({\n collection,\n doc,\n entry,\n filename,\n req,\n role,\n}: {\n collection: SanitizedCollectionConfig\n doc: Record<string, unknown>\n entry: Record<string, unknown>\n filename: string\n req: PayloadRequest\n role: StoredFileRole\n}): boolean => {\n const getFileURL = ({ isOriginal }: { isOriginal: boolean }) =>\n generateFilePathOrURL({\n collectionSlug: collection.slug,\n config: req.payload.config,\n filename,\n isOriginal,\n relative: true,\n urlOrPath: undefined,\n })\n\n if (\n entry.url ===\n getFileURL({ isOriginal: role.type === 'original' && shouldRequestOriginal({ doc }) })\n ) {\n return true\n }\n\n // Archiving can rename the original away from the main file while retaining its role query.\n return role.type === 'original' && entry.url === getFileURL({ isOriginal: true })\n}\n\nconst resolveStorageKey = ({\n collection,\n entry,\n filename,\n}: {\n collection: SanitizedCollectionConfig\n entry: Record<string, unknown>\n filename: string\n}): string => {\n const operations = collection.upload.fileOperations\n const key = operations\n ? operations.resolveStorageKey({\n _objectKey: typeof entry._objectKey === 'string' ? entry._objectKey : undefined,\n filename,\n prefix: typeof entry.prefix === 'string' ? entry.prefix : undefined,\n })\n : filename\n\n return normalizeStorageKey({ key })\n}\n\nconst validateRole = ({ role }: { role: StoredFileRole }): void => {\n if (role.type === 'size' && (!role.sizeKey || role.sizeKey.includes('/'))) {\n throw new Error('A stored variant requires a safe size key')\n }\n}\n"],"names":["generateFilePathOrURL","shouldRequestOriginal","isRequestTimeFile","normalizeStorageKey","getStoredFileIdentity","key","getUploadFileObjects","doc","variants","isEntryObject","Object","entries","values","role","type","value","original","map","sizeKey","filter","entry","getUploadFileObject","find","isSameFileRole","first","second","isManagedUpload","filename","getUploadFileEntries","collection","req","roles","trustGenerated","isManaged","objects","some","wanted","flatMap","status","upload","fileOperations","hasPayloadFileURL","validateRole","resolveStorageKey","collectStoredFiles","args","files","fileByIdentity","Map","identity","file","get","push","newFile","set","hasStoredOriginal","withLegacyUploadFileData","config","url","filesize","mimeType","hasOriginalData","Array","isArray","undefined","disableLocalStorage","adapter","expectedURL","collectionSlug","slug","relative","urlOrPath","width","height","withLegacyCloudUploadFileData","stored","payload","operations","hasLegacyFile","fromEntries","name","_objectKey","prefix","assign","Boolean","getFileURL","isOriginal","includes","Error"],"mappings":"AAaA,SAASA,qBAAqB,QAAQ,8BAA6B;AACnE,SAASC,qBAAqB,QAAQ,8BAA6B;AACnE,SAASC,iBAAiB,QAAQ,0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,KAAKC,IAAI,KAAK,cAAcb,sBAAsB;YAAEM;QAAI;IAAG,IACpF;QACA,OAAO;IACT;IAEA,4FAA4F;IAC5F,OAAOM,KAAKC,IAAI,KAAK,cAAcM,MAAMsC,GAAG,KAAK2B,WAAW;QAAEC,YAAY;IAAK;AACjF;AAEA,MAAM3C,oBAAoB,CAAC,EACzBd,UAAU,EACVT,KAAK,EACLO,QAAQ,EAKT;IACC,MAAMkD,aAAahD,WAAWU,MAAM,CAACC,cAAc;IACnD,MAAMnC,MAAMwE,aACRA,WAAWlC,iBAAiB,CAAC;QAC3BsC,YAAY,OAAO7D,MAAM6D,UAAU,KAAK,WAAW7D,MAAM6D,UAAU,GAAGjB;QACtErC;QACAuD,QAAQ,OAAO9D,MAAM8D,MAAM,KAAK,WAAW9D,MAAM8D,MAAM,GAAGlB;IAC5D,KACArC;IAEJ,OAAOxB,oBAAoB;QAAEE;IAAI;AACnC;AAEA,MAAMqC,eAAe,CAAC,EAAE7B,IAAI,EAA4B;IACtD,IAAIA,KAAKC,IAAI,KAAK,UAAW,CAAA,CAACD,KAAKK,OAAO,IAAIL,KAAKK,OAAO,CAACqE,QAAQ,CAAC,IAAG,GAAI;QACzE,MAAM,IAAIC,MAAM;IAClB;AACF"}
|
|
@@ -10,9 +10,21 @@ export type StoredFile = {
|
|
|
10
10
|
roles: StoredFileRole[];
|
|
11
11
|
};
|
|
12
12
|
export type StoredFileList = StoredFile[];
|
|
13
|
-
|
|
13
|
+
/** One file of a saved upload, for one role. Only a stored entry has an object in storage. */
|
|
14
|
+
export type UploadFileEntry = {
|
|
15
|
+
/** The object's resolved storage key. */
|
|
14
16
|
key: string;
|
|
15
17
|
role: StoredFileRole;
|
|
18
|
+
status: 'stored';
|
|
19
|
+
} | {
|
|
20
|
+
role: StoredFileRole;
|
|
21
|
+
/** `requestTime`: built when requested (`_stored: false`). `unmanaged`: Payload did not store it. */
|
|
22
|
+
status: 'requestTime' | 'unmanaged';
|
|
23
|
+
};
|
|
24
|
+
/** The document's own object for one role of a saved upload. */
|
|
25
|
+
export type UploadFileObject = {
|
|
26
|
+
role: StoredFileRole;
|
|
27
|
+
value: Record<string, unknown>;
|
|
16
28
|
};
|
|
17
29
|
export type StoredFileIdentity = Pick<StoredFile, 'key'>;
|
|
18
30
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/uploads/fileVersioning/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,SAAS,GAAG,UAAU,CAAA;CAAE,CAAA;AAEjG,gFAAgF;AAChF,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,cAAc,EAAE,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,UAAU,EAAE,CAAA;AAEzC,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/uploads/fileVersioning/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,SAAS,GAAG,UAAU,CAAA;CAAE,CAAA;AAEjG,gFAAgF;AAChF,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,cAAc,EAAE,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,UAAU,EAAE,CAAA;AAEzC,8FAA8F;AAC9F,MAAM,MAAM,eAAe,GACvB;IACE,yCAAyC;IACzC,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,cAAc,CAAA;IACpB,MAAM,EAAE,QAAQ,CAAA;CACjB,GACD;IACE,IAAI,EAAE,cAAc,CAAA;IACpB,qGAAqG;IACrG,MAAM,EAAE,aAAa,GAAG,WAAW,CAAA;CACpC,CAAA;AAEL,gEAAgE;AAChE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,cAAc,CAAA;IACpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/B,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/uploads/fileVersioning/types.ts"],"sourcesContent":["export type StoredFileRole = { sizeKey: string; type: 'size' } | { type: 'default' | 'original' }\n\n/** One stored file. It can be both the original upload and the default file. */\nexport type StoredFile = {\n key: string\n roles: StoredFileRole[]\n}\n\nexport type StoredFileList = StoredFile[]\n\nexport type
|
|
1
|
+
{"version":3,"sources":["../../../src/uploads/fileVersioning/types.ts"],"sourcesContent":["export type StoredFileRole = { sizeKey: string; type: 'size' } | { type: 'default' | 'original' }\n\n/** One stored file. It can be both the original upload and the default file. */\nexport type StoredFile = {\n key: string\n roles: StoredFileRole[]\n}\n\nexport type StoredFileList = StoredFile[]\n\n/** One file of a saved upload, for one role. Only a stored entry has an object in storage. */\nexport type UploadFileEntry =\n | {\n /** The object's resolved storage key. */\n key: string\n role: StoredFileRole\n status: 'stored'\n }\n | {\n role: StoredFileRole\n /** `requestTime`: built when requested (`_stored: false`). `unmanaged`: Payload did not store it. */\n status: 'requestTime' | 'unmanaged'\n }\n\n/** The document's own object for one role of a saved upload. */\nexport type UploadFileObject = {\n role: StoredFileRole\n value: Record<string, unknown>\n}\n\nexport type StoredFileIdentity = Pick<StoredFile, 'key'>\n"],"names":[],"mappings":"AA8BA,WAAwD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configToJSONSchema.d.ts","sourceRoot":"","sources":["../../src/utilities/configToJSONSchema.ts"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BAAwB,CAAC,EACvC,MAAM,EACN,MAAM,EACN,wBAAwB,GACzB,EAAE;IACD,MAAM,EAAE,eAAe,CAAA;IACvB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,wBAAwB,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;CACnD,GAAG,WAAW,CAgGd;AAgHD,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,yBAAyB,GAChC,WAAW,CA0Bb;AAGD,wBAAgB,qBAAqB,CACnC,kBAAkB,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC,oBAAoB,CAAC,GAC9E,WAAW,CAcb;AA0BD;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAC/C,WAAW,EAAE,WAAW,EACxB,wBAAwB,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAClD,OAAO,GAAE,aAAwB,GAChC,MAAM,CAgCR;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,eAAe,EACvB,aAAa,CAAC,EAAE,QAAQ,GAAG,MAAM,EACjC,IAAI,CAAC,EAAE,IAAI,EACX,EAAE,iBAAiB,EAAE,GAAE,yBAA8B,GACpD;IAAE,UAAU,EAAE,WAAW,CAAC;IAAC,qBAAqB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAE,CAwOjE"}
|
|
@@ -1250,6 +1250,12 @@ export function authCollectionToOperationsJSONSchema(config) {
|
|
|
1250
1250
|
}
|
|
1251
1251
|
// Generates the JSON Schema for supported timezones
|
|
1252
1252
|
export function timezonesToJSONSchema(supportedTimezones) {
|
|
1253
|
+
if (supportedTimezones.length === 0) {
|
|
1254
|
+
return {
|
|
1255
|
+
description: 'Supported timezones in IANA format.',
|
|
1256
|
+
tsType: 'never'
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1253
1259
|
return {
|
|
1254
1260
|
description: 'Supported timezones in IANA format.',
|
|
1255
1261
|
enum: supportedTimezones.map((timezone)=>typeof timezone === 'string' ? timezone : timezone.value)
|