@payloadcms/plugin-cloud-storage 3.84.0-canary.0 → 3.84.0-internal.d5d6e43
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/utilities/getFileKey.d.ts +7 -1
- package/dist/utilities/getFileKey.d.ts.map +1 -1
- package/dist/utilities/getFileKey.js +9 -4
- package/dist/utilities/getFileKey.js.map +1 -1
- package/dist/utilities/getFileKey.spec.js +76 -16
- package/dist/utilities/getFileKey.spec.js.map +1 -1
- package/dist/utilities/initClientUploads.js +3 -3
- package/dist/utilities/initClientUploads.js.map +1 -1
- package/package.json +4 -4
|
@@ -4,6 +4,12 @@ type GetFileKeyArgs = {
|
|
|
4
4
|
filename: string;
|
|
5
5
|
useCompositePrefixes?: boolean;
|
|
6
6
|
};
|
|
7
|
+
type GetFileKeyResult = {
|
|
8
|
+
fileKey: string;
|
|
9
|
+
sanitizedCollectionPrefix: string;
|
|
10
|
+
sanitizedDocPrefix: string;
|
|
11
|
+
sanitizedFilename: string;
|
|
12
|
+
};
|
|
7
13
|
/**
|
|
8
14
|
* Computes the file key (path) for storage.
|
|
9
15
|
*
|
|
@@ -11,6 +17,6 @@ type GetFileKeyArgs = {
|
|
|
11
17
|
* In composite mode (useCompositePrefixes: true), both are combined.
|
|
12
18
|
* Both prefixes are passed through {@link sanitizePrefix} so keys stay normalized.
|
|
13
19
|
*/
|
|
14
|
-
export declare function getFileKey({ collectionPrefix, docPrefix, filename, useCompositePrefixes, }: GetFileKeyArgs):
|
|
20
|
+
export declare function getFileKey({ collectionPrefix, docPrefix, filename, useCompositePrefixes, }: GetFileKeyArgs): GetFileKeyResult;
|
|
15
21
|
export {};
|
|
16
22
|
//# sourceMappingURL=getFileKey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFileKey.d.ts","sourceRoot":"","sources":["../../src/utilities/getFileKey.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getFileKey.d.ts","sourceRoot":"","sources":["../../src/utilities/getFileKey.ts"],"names":[],"mappings":"AAKA,KAAK,cAAc,GAAG;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B,CAAA;AAED,KAAK,gBAAgB,GAAG;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,yBAAyB,EAAE,MAAM,CAAA;IACjC,kBAAkB,EAAE,MAAM,CAAA;IAC1B,iBAAiB,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,EACzB,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,oBAA4B,GAC7B,EAAE,cAAc,GAAG,gBAAgB,CAenC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
+
import { sanitizeFilename } from 'payload/shared';
|
|
2
3
|
import { sanitizePrefix } from './sanitizePrefix.js';
|
|
3
4
|
/**
|
|
4
5
|
* Computes the file key (path) for storage.
|
|
@@ -9,10 +10,14 @@ import { sanitizePrefix } from './sanitizePrefix.js';
|
|
|
9
10
|
*/ export function getFileKey({ collectionPrefix, docPrefix, filename, useCompositePrefixes = false }) {
|
|
10
11
|
const safeCollectionPrefix = sanitizePrefix(collectionPrefix || '');
|
|
11
12
|
const safeDocPrefix = sanitizePrefix(docPrefix || '');
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const safeFilename = sanitizeFilename(filename);
|
|
14
|
+
const fileKey = useCompositePrefixes ? path.posix.join(safeCollectionPrefix, safeDocPrefix, safeFilename) : path.posix.join(safeDocPrefix || safeCollectionPrefix, safeFilename);
|
|
15
|
+
return {
|
|
16
|
+
fileKey,
|
|
17
|
+
sanitizedCollectionPrefix: safeCollectionPrefix,
|
|
18
|
+
sanitizedDocPrefix: safeDocPrefix,
|
|
19
|
+
sanitizedFilename: safeFilename
|
|
20
|
+
};
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
//# sourceMappingURL=getFileKey.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/getFileKey.ts"],"sourcesContent":["import path from 'path'\n\nimport { sanitizePrefix } from './sanitizePrefix.js'\n\ntype GetFileKeyArgs = {\n collectionPrefix?: string\n docPrefix?: string\n filename: string\n useCompositePrefixes?: boolean\n}\n\n/**\n * Computes the file key (path) for storage.\n *\n * In non-composite mode (useCompositePrefixes: false), docPrefix overrides collectionPrefix.\n * In composite mode (useCompositePrefixes: true), both are combined.\n * Both prefixes are passed through {@link sanitizePrefix} so keys stay normalized.\n */\nexport function getFileKey({\n collectionPrefix,\n docPrefix,\n filename,\n useCompositePrefixes = false,\n}: GetFileKeyArgs):
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/getFileKey.ts"],"sourcesContent":["import path from 'path'\nimport { sanitizeFilename } from 'payload/shared'\n\nimport { sanitizePrefix } from './sanitizePrefix.js'\n\ntype GetFileKeyArgs = {\n collectionPrefix?: string\n docPrefix?: string\n filename: string\n useCompositePrefixes?: boolean\n}\n\ntype GetFileKeyResult = {\n fileKey: string\n sanitizedCollectionPrefix: string\n sanitizedDocPrefix: string\n sanitizedFilename: string\n}\n\n/**\n * Computes the file key (path) for storage.\n *\n * In non-composite mode (useCompositePrefixes: false), docPrefix overrides collectionPrefix.\n * In composite mode (useCompositePrefixes: true), both are combined.\n * Both prefixes are passed through {@link sanitizePrefix} so keys stay normalized.\n */\nexport function getFileKey({\n collectionPrefix,\n docPrefix,\n filename,\n useCompositePrefixes = false,\n}: GetFileKeyArgs): GetFileKeyResult {\n const safeCollectionPrefix = sanitizePrefix(collectionPrefix || '')\n const safeDocPrefix = sanitizePrefix(docPrefix || '')\n const safeFilename = sanitizeFilename(filename)\n\n const fileKey = useCompositePrefixes\n ? path.posix.join(safeCollectionPrefix, safeDocPrefix, safeFilename)\n : path.posix.join(safeDocPrefix || safeCollectionPrefix, safeFilename)\n\n return {\n fileKey,\n sanitizedCollectionPrefix: safeCollectionPrefix,\n sanitizedDocPrefix: safeDocPrefix,\n sanitizedFilename: safeFilename,\n }\n}\n"],"names":["path","sanitizeFilename","sanitizePrefix","getFileKey","collectionPrefix","docPrefix","filename","useCompositePrefixes","safeCollectionPrefix","safeDocPrefix","safeFilename","fileKey","posix","join","sanitizedCollectionPrefix","sanitizedDocPrefix","sanitizedFilename"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AACvB,SAASC,gBAAgB,QAAQ,iBAAgB;AAEjD,SAASC,cAAc,QAAQ,sBAAqB;AAgBpD;;;;;;CAMC,GACD,OAAO,SAASC,WAAW,EACzBC,gBAAgB,EAChBC,SAAS,EACTC,QAAQ,EACRC,uBAAuB,KAAK,EACb;IACf,MAAMC,uBAAuBN,eAAeE,oBAAoB;IAChE,MAAMK,gBAAgBP,eAAeG,aAAa;IAClD,MAAMK,eAAeT,iBAAiBK;IAEtC,MAAMK,UAAUJ,uBACZP,KAAKY,KAAK,CAACC,IAAI,CAACL,sBAAsBC,eAAeC,gBACrDV,KAAKY,KAAK,CAACC,IAAI,CAACJ,iBAAiBD,sBAAsBE;IAE3D,OAAO;QACLC;QACAG,2BAA2BN;QAC3BO,oBAAoBN;QACpBO,mBAAmBN;IACrB;AACF"}
|
|
@@ -9,7 +9,12 @@ describe('getFileKey', ()=>{
|
|
|
9
9
|
filename: 'test.png',
|
|
10
10
|
useCompositePrefixes: false
|
|
11
11
|
});
|
|
12
|
-
expect(result).
|
|
12
|
+
expect(result).toEqual({
|
|
13
|
+
fileKey: 'document/test.png',
|
|
14
|
+
sanitizedCollectionPrefix: 'collection',
|
|
15
|
+
sanitizedDocPrefix: 'document',
|
|
16
|
+
sanitizedFilename: 'test.png'
|
|
17
|
+
});
|
|
13
18
|
});
|
|
14
19
|
it('should fallback to collectionPrefix when docPrefix is empty', ()=>{
|
|
15
20
|
const result = getFileKey({
|
|
@@ -18,7 +23,12 @@ describe('getFileKey', ()=>{
|
|
|
18
23
|
filename: 'test.png',
|
|
19
24
|
useCompositePrefixes: false
|
|
20
25
|
});
|
|
21
|
-
expect(result).
|
|
26
|
+
expect(result).toEqual({
|
|
27
|
+
fileKey: 'collection/test.png',
|
|
28
|
+
sanitizedCollectionPrefix: 'collection',
|
|
29
|
+
sanitizedDocPrefix: '',
|
|
30
|
+
sanitizedFilename: 'test.png'
|
|
31
|
+
});
|
|
22
32
|
});
|
|
23
33
|
it('should fallback to collectionPrefix when docPrefix is undefined', ()=>{
|
|
24
34
|
const result = getFileKey({
|
|
@@ -26,14 +36,24 @@ describe('getFileKey', ()=>{
|
|
|
26
36
|
filename: 'test.png',
|
|
27
37
|
useCompositePrefixes: false
|
|
28
38
|
});
|
|
29
|
-
expect(result).
|
|
39
|
+
expect(result).toEqual({
|
|
40
|
+
fileKey: 'collection/test.png',
|
|
41
|
+
sanitizedCollectionPrefix: 'collection',
|
|
42
|
+
sanitizedDocPrefix: '',
|
|
43
|
+
sanitizedFilename: 'test.png'
|
|
44
|
+
});
|
|
30
45
|
});
|
|
31
46
|
it('should return only filename when both prefixes are empty', ()=>{
|
|
32
47
|
const result = getFileKey({
|
|
33
48
|
filename: 'test.png',
|
|
34
49
|
useCompositePrefixes: false
|
|
35
50
|
});
|
|
36
|
-
expect(result).
|
|
51
|
+
expect(result).toEqual({
|
|
52
|
+
fileKey: 'test.png',
|
|
53
|
+
sanitizedCollectionPrefix: '',
|
|
54
|
+
sanitizedDocPrefix: '',
|
|
55
|
+
sanitizedFilename: 'test.png'
|
|
56
|
+
});
|
|
37
57
|
});
|
|
38
58
|
});
|
|
39
59
|
describe('composite mode (useCompositePrefixes: true)', ()=>{
|
|
@@ -44,7 +64,12 @@ describe('getFileKey', ()=>{
|
|
|
44
64
|
filename: 'test.png',
|
|
45
65
|
useCompositePrefixes: true
|
|
46
66
|
});
|
|
47
|
-
expect(result).
|
|
67
|
+
expect(result).toEqual({
|
|
68
|
+
fileKey: 'collection/document/test.png',
|
|
69
|
+
sanitizedCollectionPrefix: 'collection',
|
|
70
|
+
sanitizedDocPrefix: 'document',
|
|
71
|
+
sanitizedFilename: 'test.png'
|
|
72
|
+
});
|
|
48
73
|
});
|
|
49
74
|
it('should work with only collectionPrefix', ()=>{
|
|
50
75
|
const result = getFileKey({
|
|
@@ -52,7 +77,12 @@ describe('getFileKey', ()=>{
|
|
|
52
77
|
filename: 'test.png',
|
|
53
78
|
useCompositePrefixes: true
|
|
54
79
|
});
|
|
55
|
-
expect(result).
|
|
80
|
+
expect(result).toEqual({
|
|
81
|
+
fileKey: 'collection/test.png',
|
|
82
|
+
sanitizedCollectionPrefix: 'collection',
|
|
83
|
+
sanitizedDocPrefix: '',
|
|
84
|
+
sanitizedFilename: 'test.png'
|
|
85
|
+
});
|
|
56
86
|
});
|
|
57
87
|
it('should work with only docPrefix', ()=>{
|
|
58
88
|
const result = getFileKey({
|
|
@@ -60,14 +90,24 @@ describe('getFileKey', ()=>{
|
|
|
60
90
|
filename: 'test.png',
|
|
61
91
|
useCompositePrefixes: true
|
|
62
92
|
});
|
|
63
|
-
expect(result).
|
|
93
|
+
expect(result).toEqual({
|
|
94
|
+
fileKey: 'document/test.png',
|
|
95
|
+
sanitizedCollectionPrefix: '',
|
|
96
|
+
sanitizedDocPrefix: 'document',
|
|
97
|
+
sanitizedFilename: 'test.png'
|
|
98
|
+
});
|
|
64
99
|
});
|
|
65
100
|
it('should return only filename when both prefixes are empty', ()=>{
|
|
66
101
|
const result = getFileKey({
|
|
67
102
|
filename: 'test.png',
|
|
68
103
|
useCompositePrefixes: true
|
|
69
104
|
});
|
|
70
|
-
expect(result).
|
|
105
|
+
expect(result).toEqual({
|
|
106
|
+
fileKey: 'test.png',
|
|
107
|
+
sanitizedCollectionPrefix: '',
|
|
108
|
+
sanitizedDocPrefix: '',
|
|
109
|
+
sanitizedFilename: 'test.png'
|
|
110
|
+
});
|
|
71
111
|
});
|
|
72
112
|
});
|
|
73
113
|
describe('sanitization', ()=>{
|
|
@@ -77,8 +117,13 @@ describe('getFileKey', ()=>{
|
|
|
77
117
|
filename: 'test.png',
|
|
78
118
|
useCompositePrefixes: false
|
|
79
119
|
});
|
|
80
|
-
expect(result).
|
|
81
|
-
|
|
120
|
+
expect(result).toEqual({
|
|
121
|
+
fileKey: 'etc/test.png',
|
|
122
|
+
sanitizedCollectionPrefix: 'etc',
|
|
123
|
+
sanitizedDocPrefix: '',
|
|
124
|
+
sanitizedFilename: 'test.png'
|
|
125
|
+
});
|
|
126
|
+
expect(result.fileKey).not.toContain('..');
|
|
82
127
|
});
|
|
83
128
|
it('should remove path traversal segments from docPrefix', ()=>{
|
|
84
129
|
const result = getFileKey({
|
|
@@ -86,8 +131,13 @@ describe('getFileKey', ()=>{
|
|
|
86
131
|
filename: 'test.png',
|
|
87
132
|
useCompositePrefixes: false
|
|
88
133
|
});
|
|
89
|
-
expect(result).
|
|
90
|
-
|
|
134
|
+
expect(result).toEqual({
|
|
135
|
+
fileKey: 'a/outside/test.png',
|
|
136
|
+
sanitizedCollectionPrefix: '',
|
|
137
|
+
sanitizedDocPrefix: 'a/outside',
|
|
138
|
+
sanitizedFilename: 'test.png'
|
|
139
|
+
});
|
|
140
|
+
expect(result.fileKey).not.toContain('..');
|
|
91
141
|
});
|
|
92
142
|
it('should remove control characters from prefixes', ()=>{
|
|
93
143
|
const result = getFileKey({
|
|
@@ -95,8 +145,13 @@ describe('getFileKey', ()=>{
|
|
|
95
145
|
filename: 'test.png',
|
|
96
146
|
useCompositePrefixes: false
|
|
97
147
|
});
|
|
98
|
-
expect(result).
|
|
99
|
-
|
|
148
|
+
expect(result).toEqual({
|
|
149
|
+
fileKey: 'testprefix/test.png',
|
|
150
|
+
sanitizedCollectionPrefix: 'testprefix',
|
|
151
|
+
sanitizedDocPrefix: '',
|
|
152
|
+
sanitizedFilename: 'test.png'
|
|
153
|
+
});
|
|
154
|
+
expect(result.fileKey).not.toMatch(/[\x00-\x1f]/);
|
|
100
155
|
});
|
|
101
156
|
it('should sanitize both prefixes in composite mode', ()=>{
|
|
102
157
|
const result = getFileKey({
|
|
@@ -105,8 +160,13 @@ describe('getFileKey', ()=>{
|
|
|
105
160
|
filename: 'test.png',
|
|
106
161
|
useCompositePrefixes: true
|
|
107
162
|
});
|
|
108
|
-
expect(result).
|
|
109
|
-
|
|
163
|
+
expect(result).toEqual({
|
|
164
|
+
fileKey: 'collection/doc/test.png',
|
|
165
|
+
sanitizedCollectionPrefix: 'collection',
|
|
166
|
+
sanitizedDocPrefix: 'doc',
|
|
167
|
+
sanitizedFilename: 'test.png'
|
|
168
|
+
});
|
|
169
|
+
expect(result.fileKey).not.toContain('..');
|
|
110
170
|
});
|
|
111
171
|
});
|
|
112
172
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/getFileKey.spec.ts"],"sourcesContent":["import { getFileKey } from './getFileKey.js'\nimport { describe, expect, it } from 'vitest'\n\ndescribe('getFileKey', () => {\n describe('non-composite mode (useCompositePrefixes: false)', () => {\n it('should use docPrefix when provided, ignoring collectionPrefix', () => {\n const result = getFileKey({\n collectionPrefix: 'collection',\n docPrefix: 'document',\n filename: 'test.png',\n useCompositePrefixes: false,\n })\n expect(result).
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/getFileKey.spec.ts"],"sourcesContent":["import { getFileKey } from './getFileKey.js'\nimport { describe, expect, it } from 'vitest'\n\ndescribe('getFileKey', () => {\n describe('non-composite mode (useCompositePrefixes: false)', () => {\n it('should use docPrefix when provided, ignoring collectionPrefix', () => {\n const result = getFileKey({\n collectionPrefix: 'collection',\n docPrefix: 'document',\n filename: 'test.png',\n useCompositePrefixes: false,\n })\n expect(result).toEqual({\n fileKey: 'document/test.png',\n sanitizedCollectionPrefix: 'collection',\n sanitizedDocPrefix: 'document',\n sanitizedFilename: 'test.png',\n })\n })\n\n it('should fallback to collectionPrefix when docPrefix is empty', () => {\n const result = getFileKey({\n collectionPrefix: 'collection',\n docPrefix: '',\n filename: 'test.png',\n useCompositePrefixes: false,\n })\n expect(result).toEqual({\n fileKey: 'collection/test.png',\n sanitizedCollectionPrefix: 'collection',\n sanitizedDocPrefix: '',\n sanitizedFilename: 'test.png',\n })\n })\n\n it('should fallback to collectionPrefix when docPrefix is undefined', () => {\n const result = getFileKey({\n collectionPrefix: 'collection',\n filename: 'test.png',\n useCompositePrefixes: false,\n })\n expect(result).toEqual({\n fileKey: 'collection/test.png',\n sanitizedCollectionPrefix: 'collection',\n sanitizedDocPrefix: '',\n sanitizedFilename: 'test.png',\n })\n })\n\n it('should return only filename when both prefixes are empty', () => {\n const result = getFileKey({\n filename: 'test.png',\n useCompositePrefixes: false,\n })\n expect(result).toEqual({\n fileKey: 'test.png',\n sanitizedCollectionPrefix: '',\n sanitizedDocPrefix: '',\n sanitizedFilename: 'test.png',\n })\n })\n })\n\n describe('composite mode (useCompositePrefixes: true)', () => {\n it('should combine collectionPrefix and docPrefix', () => {\n const result = getFileKey({\n collectionPrefix: 'collection',\n docPrefix: 'document',\n filename: 'test.png',\n useCompositePrefixes: true,\n })\n expect(result).toEqual({\n fileKey: 'collection/document/test.png',\n sanitizedCollectionPrefix: 'collection',\n sanitizedDocPrefix: 'document',\n sanitizedFilename: 'test.png',\n })\n })\n\n it('should work with only collectionPrefix', () => {\n const result = getFileKey({\n collectionPrefix: 'collection',\n filename: 'test.png',\n useCompositePrefixes: true,\n })\n expect(result).toEqual({\n fileKey: 'collection/test.png',\n sanitizedCollectionPrefix: 'collection',\n sanitizedDocPrefix: '',\n sanitizedFilename: 'test.png',\n })\n })\n\n it('should work with only docPrefix', () => {\n const result = getFileKey({\n docPrefix: 'document',\n filename: 'test.png',\n useCompositePrefixes: true,\n })\n expect(result).toEqual({\n fileKey: 'document/test.png',\n sanitizedCollectionPrefix: '',\n sanitizedDocPrefix: 'document',\n sanitizedFilename: 'test.png',\n })\n })\n\n it('should return only filename when both prefixes are empty', () => {\n const result = getFileKey({\n filename: 'test.png',\n useCompositePrefixes: true,\n })\n expect(result).toEqual({\n fileKey: 'test.png',\n sanitizedCollectionPrefix: '',\n sanitizedDocPrefix: '',\n sanitizedFilename: 'test.png',\n })\n })\n })\n\n describe('sanitization', () => {\n it('should remove path traversal segments from collectionPrefix', () => {\n const result = getFileKey({\n collectionPrefix: '../../../etc',\n filename: 'test.png',\n useCompositePrefixes: false,\n })\n expect(result).toEqual({\n fileKey: 'etc/test.png',\n sanitizedCollectionPrefix: 'etc',\n sanitizedDocPrefix: '',\n sanitizedFilename: 'test.png',\n })\n expect(result.fileKey).not.toContain('..')\n })\n\n it('should remove path traversal segments from docPrefix', () => {\n const result = getFileKey({\n docPrefix: 'a/../../outside',\n filename: 'test.png',\n useCompositePrefixes: false,\n })\n expect(result).toEqual({\n fileKey: 'a/outside/test.png',\n sanitizedCollectionPrefix: '',\n sanitizedDocPrefix: 'a/outside',\n sanitizedFilename: 'test.png',\n })\n expect(result.fileKey).not.toContain('..')\n })\n\n it('should remove control characters from prefixes', () => {\n const result = getFileKey({\n collectionPrefix: 'test\\x00\\x1fprefix',\n filename: 'test.png',\n useCompositePrefixes: false,\n })\n expect(result).toEqual({\n fileKey: 'testprefix/test.png',\n sanitizedCollectionPrefix: 'testprefix',\n sanitizedDocPrefix: '',\n sanitizedFilename: 'test.png',\n })\n expect(result.fileKey).not.toMatch(/[\\x00-\\x1f]/)\n })\n\n it('should sanitize both prefixes in composite mode', () => {\n const result = getFileKey({\n collectionPrefix: '../collection',\n docPrefix: '../../doc',\n filename: 'test.png',\n useCompositePrefixes: true,\n })\n expect(result).toEqual({\n fileKey: 'collection/doc/test.png',\n sanitizedCollectionPrefix: 'collection',\n sanitizedDocPrefix: 'doc',\n sanitizedFilename: 'test.png',\n })\n expect(result.fileKey).not.toContain('..')\n })\n })\n})\n"],"names":["getFileKey","describe","expect","it","result","collectionPrefix","docPrefix","filename","useCompositePrefixes","toEqual","fileKey","sanitizedCollectionPrefix","s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AAG,kDAAkD;YACnD,MAAMC,SAASJ,WAAW;gBACxBK,kBAAkB;gBAClBE,UAAU;gBACVC,sBAAsB;YACxB;YACAN,OAAOE,QAAQK,OAAO,CAAC;gBACrBC,SAAS;gBACTC,2BAA2B;gBAC3BC,oBAAoB;gBACpBC,mBAAmB;YACrB;YACAX,OAAOE,OAAOM,OAAO,EAAEI,GAAG,CAACE,OAAO,CAAC;QACrC;QAEAb,GAAG,mDAAmD;YACpD,MAAMC,SAASJ,WAAW;gBACxBK,kBAAkB;gBAClBC,WAAW;gBACXC,UAAU;gBACVC,sBAAsB;YACxB;YACAN,OAAOE,QAAQK,OAAO,CAAC;gBACrBC,SAAS;gBACTC,2BAA2B;gBAC3BC,oBAAoB;gBACpBC,mBAAmB;YACrB;YACAX,OAAOE,OAAOM,OAAO,EAAEI,GAAG,CAACC,SAAS,CAAC;QACvC;IACF;AACF"}
|
|
@@ -43,16 +43,16 @@ export const initClientUploads = ({ clientHandler, collections, config, enabled,
|
|
|
43
43
|
}
|
|
44
44
|
for(const collectionSlug in collections){
|
|
45
45
|
const collection = collections[collectionSlug];
|
|
46
|
-
let
|
|
46
|
+
let collectionPrefix;
|
|
47
47
|
if (collection && typeof collection === 'object' && 'prefix' in collection && typeof collection.prefix === 'string') {
|
|
48
|
-
|
|
48
|
+
collectionPrefix = collection.prefix;
|
|
49
49
|
}
|
|
50
50
|
config.admin.components.providers.push({
|
|
51
51
|
clientProps: {
|
|
52
52
|
collectionSlug,
|
|
53
53
|
enabled,
|
|
54
54
|
extra: extraClientHandlerProps ? extraClientHandlerProps(collection) : undefined,
|
|
55
|
-
prefix,
|
|
55
|
+
prefix: collectionPrefix,
|
|
56
56
|
serverHandlerPath
|
|
57
57
|
},
|
|
58
58
|
path: clientHandler
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/initClientUploads.ts"],"sourcesContent":["import type { Config, PayloadHandler } from 'payload'\n\nexport const initClientUploads = <ExtraProps extends Record<string, unknown>, T>({\n clientHandler,\n collections,\n config,\n enabled,\n extraClientHandlerProps,\n serverHandler,\n serverHandlerPath,\n}: {\n /** Path to clientHandler component */\n clientHandler: string\n collections: Record<string, T>\n config: Config\n enabled: boolean\n /** extra props to pass to the client handler */\n extraClientHandlerProps?: (collection: T) => ExtraProps\n serverHandler: PayloadHandler\n serverHandlerPath: string\n}) => {\n if (enabled) {\n if (!config.endpoints) {\n config.endpoints = []\n }\n\n /**\n * Tracks how many times the same handler was already applied.\n * This allows to apply the same plugin multiple times, for example\n * to use different buckets for different collections.\n */\n let handlerCount = 0\n\n for (const endpoint of config.endpoints) {\n // We want to match on 'path', 'path-1', 'path-2', etc.\n if (endpoint.path?.startsWith(serverHandlerPath)) {\n handlerCount++\n }\n }\n\n if (handlerCount) {\n serverHandlerPath = `${serverHandlerPath}-${handlerCount}`\n }\n\n config.endpoints.push({\n handler: serverHandler,\n method: 'post',\n path: serverHandlerPath,\n })\n }\n\n if (!config.admin) {\n config.admin = {}\n }\n\n if (!config.admin.dependencies) {\n config.admin.dependencies = {}\n }\n // Ensure client handler is always part of the import map, to avoid\n // import map discrepancies between dev and prod\n config.admin.dependencies[clientHandler] = {\n type: 'function',\n path: clientHandler,\n }\n\n if (!config.admin.components) {\n config.admin.components = {}\n }\n\n if (!config.admin.components.providers) {\n config.admin.components.providers = []\n }\n\n for (const collectionSlug in collections) {\n const collection = collections[collectionSlug]\n\n let
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/initClientUploads.ts"],"sourcesContent":["import type { Config, PayloadHandler } from 'payload'\n\nexport const initClientUploads = <ExtraProps extends Record<string, unknown>, T>({\n clientHandler,\n collections,\n config,\n enabled,\n extraClientHandlerProps,\n serverHandler,\n serverHandlerPath,\n}: {\n /** Path to clientHandler component */\n clientHandler: string\n collections: Record<string, T>\n config: Config\n enabled: boolean\n /** extra props to pass to the client handler */\n extraClientHandlerProps?: (collection: T) => ExtraProps\n serverHandler: PayloadHandler\n serverHandlerPath: string\n}) => {\n if (enabled) {\n if (!config.endpoints) {\n config.endpoints = []\n }\n\n /**\n * Tracks how many times the same handler was already applied.\n * This allows to apply the same plugin multiple times, for example\n * to use different buckets for different collections.\n */\n let handlerCount = 0\n\n for (const endpoint of config.endpoints) {\n // We want to match on 'path', 'path-1', 'path-2', etc.\n if (endpoint.path?.startsWith(serverHandlerPath)) {\n handlerCount++\n }\n }\n\n if (handlerCount) {\n serverHandlerPath = `${serverHandlerPath}-${handlerCount}`\n }\n\n config.endpoints.push({\n handler: serverHandler,\n method: 'post',\n path: serverHandlerPath,\n })\n }\n\n if (!config.admin) {\n config.admin = {}\n }\n\n if (!config.admin.dependencies) {\n config.admin.dependencies = {}\n }\n // Ensure client handler is always part of the import map, to avoid\n // import map discrepancies between dev and prod\n config.admin.dependencies[clientHandler] = {\n type: 'function',\n path: clientHandler,\n }\n\n if (!config.admin.components) {\n config.admin.components = {}\n }\n\n if (!config.admin.components.providers) {\n config.admin.components.providers = []\n }\n\n for (const collectionSlug in collections) {\n const collection = collections[collectionSlug]\n\n let collectionPrefix: string | undefined\n\n if (\n collection &&\n typeof collection === 'object' &&\n 'prefix' in collection &&\n typeof collection.prefix === 'string'\n ) {\n collectionPrefix = collection.prefix\n }\n\n config.admin.components.providers.push({\n clientProps: {\n collectionSlug,\n enabled,\n extra: extraClientHandlerProps ? extraClientHandlerProps(collection!) : undefined,\n prefix: collectionPrefix,\n serverHandlerPath,\n },\n path: clientHandler,\n })\n }\n}\n"],"names":["initClientUploads","clientHandler","collections","config","enabled","extraClientHandlerProps","serverHandler","serverHandlerPath","endpoints","handlerCount","endpoint","path","startsWith","push","handler","method","admin","dependencies","type","components","providers","collectionSlug","collection","collectionPrefix","prefix","clientProps","extra","undefined"],"mappings":"AAEA,OAAO,MAAMA,oBAAoB,CAAgD,EAC/EC,aAAa,EACbC,WAAW,EACXC,MAAM,EACNC,OAAO,EACPC,uBAAuB,EACvBC,aAAa,EACbC,iBAAiB,EAWlB;IACC,IAAIH,SAAS;QACX,I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AOrB,0BAA0BA,wBAAwBiB,cAAeK;gBACxEH,QAAQD;gBACRhB;YACF;YACAI,MAAMV;QACR;IACF;AACF,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-cloud-storage",
|
|
3
|
-
"version": "3.84.0-
|
|
3
|
+
"version": "3.84.0-internal.d5d6e43",
|
|
4
4
|
"description": "The official cloud storage plugin for Payload CMS",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -51,18 +51,18 @@
|
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"find-node-modules": "^2.1.3",
|
|
53
53
|
"range-parser": "^1.2.1",
|
|
54
|
-
"@payloadcms/ui": "3.84.0-
|
|
54
|
+
"@payloadcms/ui": "3.84.0-internal.d5d6e43"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/find-node-modules": "^2.1.2",
|
|
58
58
|
"@types/react": "19.2.9",
|
|
59
59
|
"@types/react-dom": "19.2.3",
|
|
60
|
-
"payload": "3.84.0-
|
|
60
|
+
"payload": "3.84.0-internal.d5d6e43"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"react": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
64
64
|
"react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
65
|
-
"payload": "3.84.0-
|
|
65
|
+
"payload": "3.84.0-internal.d5d6e43"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"registry": "https://registry.npmjs.org/"
|