payload 3.0.0-beta.104 → 3.0.0-beta.106
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/Description.d.ts +1 -1
- package/dist/admin/forms/Description.d.ts.map +1 -1
- package/dist/admin/forms/Description.js.map +1 -1
- package/dist/admin/forms/Error.d.ts +1 -1
- package/dist/admin/forms/Error.d.ts.map +1 -1
- package/dist/admin/forms/Error.js.map +1 -1
- package/dist/admin/forms/Label.d.ts +3 -3
- package/dist/admin/forms/Label.d.ts.map +1 -1
- package/dist/admin/forms/Label.js.map +1 -1
- package/dist/collections/operations/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/duplicate.js +10 -2
- package/dist/collections/operations/duplicate.js.map +1 -1
- package/dist/fields/baseFields/baseIDField.d.ts.map +1 -1
- package/dist/fields/baseFields/baseIDField.js +5 -0
- package/dist/fields/baseFields/baseIDField.js.map +1 -1
- package/dist/fields/config/sanitize.d.ts.map +1 -1
- package/dist/fields/config/sanitize.js +0 -19
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/fields/hooks/afterChange/promise.js +4 -4
- package/dist/fields/hooks/afterChange/promise.js.map +1 -1
- package/dist/fields/hooks/beforeChange/index.d.ts +1 -3
- package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/index.js +1 -3
- package/dist/fields/hooks/beforeChange/index.js.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.d.ts +1 -2
- package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.js +2 -18
- package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts +1 -2
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.js +1 -2
- package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/index.d.ts +19 -0
- package/dist/fields/hooks/beforeDuplicate/index.d.ts.map +1 -0
- package/dist/fields/hooks/beforeDuplicate/index.js +25 -0
- package/dist/fields/hooks/beforeDuplicate/index.js.map +1 -0
- package/dist/fields/hooks/beforeDuplicate/promise.d.ts +18 -0
- package/dist/fields/hooks/beforeDuplicate/promise.d.ts.map +1 -0
- package/dist/fields/hooks/beforeDuplicate/promise.js +299 -0
- package/dist/fields/hooks/beforeDuplicate/promise.js.map +1 -0
- package/dist/fields/hooks/beforeDuplicate/runHook.d.ts +3 -0
- package/dist/fields/hooks/beforeDuplicate/runHook.d.ts.map +1 -0
- package/dist/fields/hooks/beforeDuplicate/runHook.js +6 -0
- package/dist/fields/hooks/beforeDuplicate/runHook.js.map +1 -0
- package/dist/fields/hooks/beforeDuplicate/traverseFields.d.ts +18 -0
- package/dist/fields/hooks/beforeDuplicate/traverseFields.d.ts.map +1 -0
- package/dist/fields/hooks/beforeDuplicate/traverseFields.js +21 -0
- package/dist/fields/hooks/beforeDuplicate/traverseFields.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +6 -6
- package/dist/fields/baseFields/baseBeforeDuplicateArrays.d.ts +0 -6
- package/dist/fields/baseFields/baseBeforeDuplicateArrays.d.ts.map +0 -1
- package/dist/fields/baseFields/baseBeforeDuplicateArrays.js +0 -15
- package/dist/fields/baseFields/baseBeforeDuplicateArrays.js.map +0 -1
- package/dist/fields/hooks/beforeChange/beforeDuplicate.d.ts +0 -3
- package/dist/fields/hooks/beforeChange/beforeDuplicate.d.ts.map +0 -1
- package/dist/fields/hooks/beforeChange/beforeDuplicate.js +0 -6
- package/dist/fields/hooks/beforeChange/beforeDuplicate.js.map +0 -1
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { fieldAffectsData, tabHasName } from '../../config/types.js';
|
|
2
|
+
import { getFieldPaths } from '../../getFieldPaths.js';
|
|
3
|
+
import { runBeforeDuplicateHooks } from './runHook.js';
|
|
4
|
+
import { traverseFields } from './traverseFields.js';
|
|
5
|
+
export const promise = async ({ id, collection, context, doc, field, overrideAccess, parentPath, parentSchemaPath, req, siblingDoc })=>{
|
|
6
|
+
const { localization } = req.payload.config;
|
|
7
|
+
const { path: fieldPath, schemaPath: fieldSchemaPath } = getFieldPaths({
|
|
8
|
+
field,
|
|
9
|
+
parentPath,
|
|
10
|
+
parentSchemaPath
|
|
11
|
+
});
|
|
12
|
+
if (fieldAffectsData(field)) {
|
|
13
|
+
let fieldData = siblingDoc?.[field.name];
|
|
14
|
+
const fieldIsLocalized = field.localized && localization;
|
|
15
|
+
// Run field beforeDuplicate hooks
|
|
16
|
+
if (Array.isArray(field.hooks?.beforeDuplicate)) {
|
|
17
|
+
if (fieldIsLocalized) {
|
|
18
|
+
const localeData = await localization.localeCodes.reduce(async (localizedValuesPromise, locale)=>{
|
|
19
|
+
const localizedValues = await localizedValuesPromise;
|
|
20
|
+
const beforeDuplicateArgs = {
|
|
21
|
+
collection,
|
|
22
|
+
context,
|
|
23
|
+
data: doc,
|
|
24
|
+
field,
|
|
25
|
+
global: undefined,
|
|
26
|
+
path: fieldPath,
|
|
27
|
+
previousSiblingDoc: siblingDoc,
|
|
28
|
+
previousValue: siblingDoc[field.name]?.[locale],
|
|
29
|
+
req,
|
|
30
|
+
schemaPath: parentSchemaPath,
|
|
31
|
+
siblingData: siblingDoc,
|
|
32
|
+
siblingDocWithLocales: siblingDoc,
|
|
33
|
+
value: siblingDoc[field.name]?.[locale]
|
|
34
|
+
};
|
|
35
|
+
const hookResult = await runBeforeDuplicateHooks(beforeDuplicateArgs);
|
|
36
|
+
if (typeof hookResult !== 'undefined') {
|
|
37
|
+
return {
|
|
38
|
+
...localizedValues,
|
|
39
|
+
[locale]: hookResult
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return localizedValuesPromise;
|
|
43
|
+
}, Promise.resolve({}));
|
|
44
|
+
siblingDoc[field.name] = localeData;
|
|
45
|
+
} else {
|
|
46
|
+
const beforeDuplicateArgs = {
|
|
47
|
+
collection,
|
|
48
|
+
context,
|
|
49
|
+
data: doc,
|
|
50
|
+
field,
|
|
51
|
+
global: undefined,
|
|
52
|
+
path: fieldPath,
|
|
53
|
+
previousSiblingDoc: siblingDoc,
|
|
54
|
+
previousValue: siblingDoc[field.name],
|
|
55
|
+
req,
|
|
56
|
+
schemaPath: parentSchemaPath,
|
|
57
|
+
siblingData: siblingDoc,
|
|
58
|
+
siblingDocWithLocales: siblingDoc,
|
|
59
|
+
value: siblingDoc[field.name]
|
|
60
|
+
};
|
|
61
|
+
const hookResult = await runBeforeDuplicateHooks(beforeDuplicateArgs);
|
|
62
|
+
if (typeof hookResult !== 'undefined') {
|
|
63
|
+
siblingDoc[field.name] = hookResult;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// First, for any localized fields, we will loop over locales
|
|
68
|
+
// and if locale data is present, traverse the sub fields.
|
|
69
|
+
// There are only a few different fields where this is possible.
|
|
70
|
+
if (fieldIsLocalized) {
|
|
71
|
+
if (typeof fieldData !== 'object' || fieldData === null) {
|
|
72
|
+
siblingDoc[field.name] = {};
|
|
73
|
+
fieldData = siblingDoc[field.name];
|
|
74
|
+
}
|
|
75
|
+
const promises = [];
|
|
76
|
+
localization.localeCodes.forEach((locale)=>{
|
|
77
|
+
if (fieldData[locale]) {
|
|
78
|
+
switch(field.type){
|
|
79
|
+
case 'tab':
|
|
80
|
+
case 'group':
|
|
81
|
+
{
|
|
82
|
+
promises.push(traverseFields({
|
|
83
|
+
id,
|
|
84
|
+
collection,
|
|
85
|
+
context,
|
|
86
|
+
doc,
|
|
87
|
+
fields: field.fields,
|
|
88
|
+
overrideAccess,
|
|
89
|
+
path: fieldSchemaPath,
|
|
90
|
+
req,
|
|
91
|
+
schemaPath: fieldSchemaPath,
|
|
92
|
+
siblingDoc: fieldData[locale]
|
|
93
|
+
}));
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
case 'array':
|
|
97
|
+
{
|
|
98
|
+
const rows = fieldData[locale];
|
|
99
|
+
if (Array.isArray(rows)) {
|
|
100
|
+
const promises = [];
|
|
101
|
+
rows.forEach((row, i)=>{
|
|
102
|
+
promises.push(traverseFields({
|
|
103
|
+
id,
|
|
104
|
+
collection,
|
|
105
|
+
context,
|
|
106
|
+
doc,
|
|
107
|
+
fields: field.fields,
|
|
108
|
+
overrideAccess,
|
|
109
|
+
path: [
|
|
110
|
+
...fieldPath,
|
|
111
|
+
i
|
|
112
|
+
],
|
|
113
|
+
req,
|
|
114
|
+
schemaPath: fieldSchemaPath,
|
|
115
|
+
siblingDoc: row
|
|
116
|
+
}));
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
case 'blocks':
|
|
122
|
+
{
|
|
123
|
+
const rows = fieldData[locale];
|
|
124
|
+
if (Array.isArray(rows)) {
|
|
125
|
+
const promises = [];
|
|
126
|
+
rows.forEach((row, i)=>{
|
|
127
|
+
const blockTypeToMatch = row.blockType;
|
|
128
|
+
const block = field.blocks.find((blockType)=>blockType.slug === blockTypeToMatch);
|
|
129
|
+
promises.push(traverseFields({
|
|
130
|
+
id,
|
|
131
|
+
collection,
|
|
132
|
+
context,
|
|
133
|
+
doc,
|
|
134
|
+
fields: block.fields,
|
|
135
|
+
overrideAccess,
|
|
136
|
+
path: [
|
|
137
|
+
...fieldPath,
|
|
138
|
+
i
|
|
139
|
+
],
|
|
140
|
+
req,
|
|
141
|
+
schemaPath: fieldSchemaPath,
|
|
142
|
+
siblingDoc: row
|
|
143
|
+
}));
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
await Promise.all(promises);
|
|
152
|
+
} else {
|
|
153
|
+
// If the field is not localized, but it affects data,
|
|
154
|
+
// we need to further traverse its children
|
|
155
|
+
// so the child fields can run beforeDuplicate hooks
|
|
156
|
+
switch(field.type){
|
|
157
|
+
case 'tab':
|
|
158
|
+
case 'group':
|
|
159
|
+
{
|
|
160
|
+
if (field.type === 'tab' && !tabHasName(field)) {
|
|
161
|
+
await traverseFields({
|
|
162
|
+
id,
|
|
163
|
+
collection,
|
|
164
|
+
context,
|
|
165
|
+
doc,
|
|
166
|
+
fields: field.fields,
|
|
167
|
+
overrideAccess,
|
|
168
|
+
path: fieldPath,
|
|
169
|
+
req,
|
|
170
|
+
schemaPath: fieldSchemaPath,
|
|
171
|
+
siblingDoc
|
|
172
|
+
});
|
|
173
|
+
} else {
|
|
174
|
+
if (typeof siblingDoc[field.name] !== 'object') {
|
|
175
|
+
siblingDoc[field.name] = {};
|
|
176
|
+
}
|
|
177
|
+
const groupDoc = siblingDoc[field.name];
|
|
178
|
+
await traverseFields({
|
|
179
|
+
id,
|
|
180
|
+
collection,
|
|
181
|
+
context,
|
|
182
|
+
doc,
|
|
183
|
+
fields: field.fields,
|
|
184
|
+
overrideAccess,
|
|
185
|
+
path: fieldPath,
|
|
186
|
+
req,
|
|
187
|
+
schemaPath: fieldSchemaPath,
|
|
188
|
+
siblingDoc: groupDoc
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
case 'array':
|
|
194
|
+
{
|
|
195
|
+
const rows = siblingDoc[field.name];
|
|
196
|
+
if (Array.isArray(rows)) {
|
|
197
|
+
const promises = [];
|
|
198
|
+
rows.forEach((row, i)=>{
|
|
199
|
+
promises.push(traverseFields({
|
|
200
|
+
id,
|
|
201
|
+
collection,
|
|
202
|
+
context,
|
|
203
|
+
doc,
|
|
204
|
+
fields: field.fields,
|
|
205
|
+
overrideAccess,
|
|
206
|
+
path: [
|
|
207
|
+
...fieldPath,
|
|
208
|
+
i
|
|
209
|
+
],
|
|
210
|
+
req,
|
|
211
|
+
schemaPath: fieldSchemaPath,
|
|
212
|
+
siblingDoc: row
|
|
213
|
+
}));
|
|
214
|
+
});
|
|
215
|
+
await Promise.all(promises);
|
|
216
|
+
}
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
case 'blocks':
|
|
220
|
+
{
|
|
221
|
+
const rows = siblingDoc[field.name];
|
|
222
|
+
if (Array.isArray(rows)) {
|
|
223
|
+
const promises = [];
|
|
224
|
+
rows.forEach((row, i)=>{
|
|
225
|
+
const blockTypeToMatch = row.blockType;
|
|
226
|
+
const block = field.blocks.find((blockType)=>blockType.slug === blockTypeToMatch);
|
|
227
|
+
if (block) {
|
|
228
|
+
row.blockType = blockTypeToMatch;
|
|
229
|
+
promises.push(traverseFields({
|
|
230
|
+
id,
|
|
231
|
+
collection,
|
|
232
|
+
context,
|
|
233
|
+
doc,
|
|
234
|
+
fields: block.fields,
|
|
235
|
+
overrideAccess,
|
|
236
|
+
path: [
|
|
237
|
+
...fieldPath,
|
|
238
|
+
i
|
|
239
|
+
],
|
|
240
|
+
req,
|
|
241
|
+
schemaPath: fieldSchemaPath,
|
|
242
|
+
siblingDoc: row
|
|
243
|
+
}));
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
await Promise.all(promises);
|
|
247
|
+
}
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
} else {
|
|
253
|
+
// Finally, we traverse fields which do not affect data here
|
|
254
|
+
switch(field.type){
|
|
255
|
+
case 'row':
|
|
256
|
+
case 'collapsible':
|
|
257
|
+
{
|
|
258
|
+
await traverseFields({
|
|
259
|
+
id,
|
|
260
|
+
collection,
|
|
261
|
+
context,
|
|
262
|
+
doc,
|
|
263
|
+
fields: field.fields,
|
|
264
|
+
overrideAccess,
|
|
265
|
+
path: fieldPath,
|
|
266
|
+
req,
|
|
267
|
+
schemaPath: fieldSchemaPath,
|
|
268
|
+
siblingDoc
|
|
269
|
+
});
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
case 'tabs':
|
|
273
|
+
{
|
|
274
|
+
await traverseFields({
|
|
275
|
+
id,
|
|
276
|
+
collection,
|
|
277
|
+
context,
|
|
278
|
+
doc,
|
|
279
|
+
fields: field.tabs.map((tab)=>({
|
|
280
|
+
...tab,
|
|
281
|
+
type: 'tab'
|
|
282
|
+
})),
|
|
283
|
+
overrideAccess,
|
|
284
|
+
path: fieldPath,
|
|
285
|
+
req,
|
|
286
|
+
schemaPath: fieldSchemaPath,
|
|
287
|
+
siblingDoc
|
|
288
|
+
});
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
default:
|
|
292
|
+
{
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
//# sourceMappingURL=promise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/beforeDuplicate/promise.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { JsonObject, PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, FieldHookArgs, TabAsField } from '../../config/types.js'\n\nimport { fieldAffectsData, tabHasName } from '../../config/types.js'\nimport { getFieldPaths } from '../../getFieldPaths.js'\nimport { runBeforeDuplicateHooks } from './runHook.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args<T> = {\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n doc: T\n field: Field | TabAsField\n id?: number | string\n overrideAccess: boolean\n parentPath: (number | string)[]\n parentSchemaPath: string[]\n req: PayloadRequest\n siblingDoc: JsonObject\n}\n\nexport const promise = async <T>({\n id,\n collection,\n context,\n doc,\n field,\n overrideAccess,\n parentPath,\n parentSchemaPath,\n req,\n siblingDoc,\n}: Args<T>): Promise<void> => {\n const { localization } = req.payload.config\n\n const { path: fieldPath, schemaPath: fieldSchemaPath } = getFieldPaths({\n field,\n parentPath,\n parentSchemaPath,\n })\n\n if (fieldAffectsData(field)) {\n let fieldData = siblingDoc?.[field.name]\n const fieldIsLocalized = field.localized && localization\n\n // Run field beforeDuplicate hooks\n if (Array.isArray(field.hooks?.beforeDuplicate)) {\n if (fieldIsLocalized) {\n const localeData = await localization.localeCodes.reduce(\n async (localizedValuesPromise: Promise<JsonObject>, locale) => {\n const localizedValues = await localizedValuesPromise\n\n const beforeDuplicateArgs: FieldHookArgs = {\n collection,\n context,\n data: doc,\n field,\n global: undefined,\n path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingDoc[field.name]?.[locale],\n req,\n schemaPath: parentSchemaPath,\n siblingData: siblingDoc,\n siblingDocWithLocales: siblingDoc,\n value: siblingDoc[field.name]?.[locale],\n }\n\n const hookResult = await runBeforeDuplicateHooks(beforeDuplicateArgs)\n\n if (typeof hookResult !== 'undefined') {\n return {\n ...localizedValues,\n [locale]: hookResult,\n }\n }\n\n return localizedValuesPromise\n },\n Promise.resolve({}),\n )\n\n siblingDoc[field.name] = localeData\n } else {\n const beforeDuplicateArgs: FieldHookArgs = {\n collection,\n context,\n data: doc,\n field,\n global: undefined,\n path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingDoc[field.name],\n req,\n schemaPath: parentSchemaPath,\n siblingData: siblingDoc,\n siblingDocWithLocales: siblingDoc,\n value: siblingDoc[field.name],\n }\n\n const hookResult = await runBeforeDuplicateHooks(beforeDuplicateArgs)\n if (typeof hookResult !== 'undefined') {\n siblingDoc[field.name] = hookResult\n }\n }\n }\n\n // First, for any localized fields, we will loop over locales\n // and if locale data is present, traverse the sub fields.\n // There are only a few different fields where this is possible.\n if (fieldIsLocalized) {\n if (typeof fieldData !== 'object' || fieldData === null) {\n siblingDoc[field.name] = {}\n fieldData = siblingDoc[field.name]\n }\n\n const promises = []\n\n localization.localeCodes.forEach((locale) => {\n if (fieldData[locale]) {\n switch (field.type) {\n case 'tab':\n case 'group': {\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n doc,\n fields: field.fields,\n overrideAccess,\n path: fieldSchemaPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingDoc: fieldData[locale],\n }),\n )\n\n break\n }\n\n case 'array': {\n const rows = fieldData[locale]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row, i) => {\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n doc,\n fields: field.fields,\n overrideAccess,\n path: [...fieldPath, i],\n req,\n schemaPath: fieldSchemaPath,\n siblingDoc: row,\n }),\n )\n })\n }\n break\n }\n\n case 'blocks': {\n const rows = fieldData[locale]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row, i) => {\n const blockTypeToMatch = row.blockType\n\n const block = field.blocks.find(\n (blockType) => blockType.slug === blockTypeToMatch,\n )\n\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n doc,\n fields: block.fields,\n overrideAccess,\n path: [...fieldPath, i],\n req,\n schemaPath: fieldSchemaPath,\n siblingDoc: row,\n }),\n )\n })\n }\n break\n }\n }\n }\n })\n\n await Promise.all(promises)\n } else {\n // If the field is not localized, but it affects data,\n // we need to further traverse its children\n // so the child fields can run beforeDuplicate hooks\n switch (field.type) {\n case 'tab':\n case 'group': {\n if (field.type === 'tab' && !tabHasName(field)) {\n await traverseFields({\n id,\n collection,\n context,\n doc,\n fields: field.fields,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingDoc,\n })\n } else {\n if (typeof siblingDoc[field.name] !== 'object') {\n siblingDoc[field.name] = {}\n }\n\n const groupDoc = siblingDoc[field.name] as Record<string, unknown>\n\n await traverseFields({\n id,\n collection,\n context,\n doc,\n fields: field.fields,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingDoc: groupDoc as JsonObject,\n })\n }\n\n break\n }\n\n case 'array': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row, i) => {\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n doc,\n fields: field.fields,\n overrideAccess,\n path: [...fieldPath, i],\n req,\n schemaPath: fieldSchemaPath,\n siblingDoc: row,\n }),\n )\n })\n await Promise.all(promises)\n }\n break\n }\n\n case 'blocks': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row, i) => {\n const blockTypeToMatch = row.blockType\n const block = field.blocks.find((blockType) => blockType.slug === blockTypeToMatch)\n\n if (block) {\n ;(row as JsonObject).blockType = blockTypeToMatch\n\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n doc,\n fields: block.fields,\n overrideAccess,\n path: [...fieldPath, i],\n req,\n schemaPath: fieldSchemaPath,\n siblingDoc: row,\n }),\n )\n }\n })\n await Promise.all(promises)\n }\n\n break\n }\n }\n }\n } else {\n // Finally, we traverse fields which do not affect data here\n switch (field.type) {\n case 'row':\n case 'collapsible': {\n await traverseFields({\n id,\n collection,\n context,\n doc,\n fields: field.fields,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingDoc,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n id,\n collection,\n context,\n doc,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingDoc,\n })\n\n break\n }\n\n default: {\n break\n }\n }\n }\n}\n"],"names":["fieldAffectsData","tabHasName","getFieldPaths","runBeforeDuplicateHooks","traverseFields","promise","id","collection","context","doc","field","overrideAccess","parentPath","parentSchemaPath","req","siblingDoc","localization","payload","config","path","fieldPath","schemaPath","fieldSchemaPath","fieldData","name","fieldIsLocalized","localized","Array","isArray","hooks","beforeDuplicate","localeData","localeCodes","reduce","localizedValuesPromise","locale","localizedValues","beforeDuplicateArgs","data","global","undefined","previousSiblingDoc","previousValue","siblingData","siblingDocWithLocales","value","hookResult","Promise","resolve","promises","forEach","type","push","fields","rows","row","i","blockTypeToMatch","blockType","block","blocks","find","slug","all","groupDoc","tabs","map","tab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QAAQM,MAAMN,MAAM;wCACpB1C;wCACAQ,MAAM;+CAAIC;4CAAWoC;yCAAE;wCACvB1C;wCACAO,YAAYC;wCACZP,YAAYwC;oCACd;gCAEJ;4BACF;4BACA,MAAMR,QAAQgB,GAAG,CAACd;wBACpB;wBAEA;oBACF;YACF;QACF;IACF,OAAO;QACL,4DAA4D;QAC5D,OAAQvC,MAAMyC,IAAI;YAChB,KAAK;YACL,KAAK;gBAAe;oBAClB,MAAM/C,eAAe;wBACnBE;wBACAC;wBACAC;wBACAC;wBACA4C,QAAQ3C,MAAM2C,MAAM;wBACpB1C;wBACAQ,MAAMC;wBACNN;wBACAO,YAAYC;wBACZP;oBACF;oBAEA;gBACF;YAEA,KAAK;gBAAQ;oBACX,MAAMX,eAAe;wBACnBE;wBACAC;wBACAC;wBACAC;wBACA4C,QAAQ3C,MAAMuD,IAAI,CAACC,GAAG,CAAC,CAACC,MAAS,CAAA;gCAAE,GAAGA,GAAG;gCAAEhB,MAAM;4BAAM,CAAA;wBACvDxC;wBACAQ,MAAMC;wBACNN;wBACAO,YAAYC;wBACZP;oBACF;oBAEA;gBACF;YAEA;gBAAS;oBACP;gBACF;QACF;IACF;AACF,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runHook.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeDuplicate/runHook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D,eAAO,MAAM,uBAAuB,SAAgB,aAAa,iBAI1C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/beforeDuplicate/runHook.ts"],"sourcesContent":["import type { FieldHookArgs } from '../../config/types.js'\n\nexport const runBeforeDuplicateHooks = async (args: FieldHookArgs) =>\n await args.field.hooks.beforeDuplicate.reduce(async (priorHook, currentHook) => {\n await priorHook\n return await currentHook(args)\n }, Promise.resolve())\n"],"names":["runBeforeDuplicateHooks","args","field","hooks","beforeDuplicate","reduce","priorHook","currentHook","Promise","resolve"],"mappings":"AAEA,OAAO,MAAMA,0BAA0B,OAAOC,OAC5C,MAAMA,KAAKC,KAAK,CAACC,KAAK,CAACC,eAAe,CAACC,MAAM,CAAC,OAAOC,WAAWC;QAC9D,MAAMD;QACN,OAAO,MAAMC,YAAYN;IAC3B,GAAGO,QAAQC,OAAO,IAAG"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SanitizedCollectionConfig } from '../../../collections/config/types.js';
|
|
2
|
+
import type { JsonObject, PayloadRequest, RequestContext } from '../../../types/index.js';
|
|
3
|
+
import type { Field, TabAsField } from '../../config/types.js';
|
|
4
|
+
type Args<T> = {
|
|
5
|
+
collection: null | SanitizedCollectionConfig;
|
|
6
|
+
context: RequestContext;
|
|
7
|
+
doc: T;
|
|
8
|
+
fields: (Field | TabAsField)[];
|
|
9
|
+
id?: number | string;
|
|
10
|
+
overrideAccess: boolean;
|
|
11
|
+
path: (number | string)[];
|
|
12
|
+
req: PayloadRequest;
|
|
13
|
+
schemaPath: string[];
|
|
14
|
+
siblingDoc: JsonObject;
|
|
15
|
+
};
|
|
16
|
+
export declare const traverseFields: <T>({ id, collection, context, doc, fields, overrideAccess, path, req, schemaPath, siblingDoc, }: Args<T>) => Promise<void>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=traverseFields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeDuplicate/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACzF,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAI9D,KAAK,IAAI,CAAC,CAAC,IAAI;IACb,UAAU,EAAE,IAAI,GAAG,yBAAyB,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,GAAG,EAAE,CAAC,CAAA;IACN,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,cAAc,EAAE,OAAO,CAAA;IACvB,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IACzB,GAAG,EAAE,cAAc,CAAA;IACnB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,cAAc,GAAU,CAAC,gGAWnC,IAAI,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,IAAI,CAmBxB,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { promise } from './promise.js';
|
|
2
|
+
export const traverseFields = async ({ id, collection, context, doc, fields, overrideAccess, path, req, schemaPath, siblingDoc })=>{
|
|
3
|
+
const promises = [];
|
|
4
|
+
fields.forEach((field)=>{
|
|
5
|
+
promises.push(promise({
|
|
6
|
+
id,
|
|
7
|
+
collection,
|
|
8
|
+
context,
|
|
9
|
+
doc,
|
|
10
|
+
field,
|
|
11
|
+
overrideAccess,
|
|
12
|
+
parentPath: path,
|
|
13
|
+
parentSchemaPath: schemaPath,
|
|
14
|
+
req,
|
|
15
|
+
siblingDoc
|
|
16
|
+
}));
|
|
17
|
+
});
|
|
18
|
+
await Promise.all(promises);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=traverseFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/beforeDuplicate/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { JsonObject, PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args<T> = {\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n doc: T\n fields: (Field | TabAsField)[]\n id?: number | string\n overrideAccess: boolean\n path: (number | string)[]\n req: PayloadRequest\n schemaPath: string[]\n siblingDoc: JsonObject\n}\n\nexport const traverseFields = async <T>({\n id,\n collection,\n context,\n doc,\n fields,\n overrideAccess,\n path,\n req,\n schemaPath,\n siblingDoc,\n}: Args<T>): Promise<void> => {\n const promises = []\n fields.forEach((field) => {\n promises.push(\n promise({\n id,\n collection,\n context,\n doc,\n field,\n overrideAccess,\n parentPath: path,\n parentSchemaPath: schemaPath,\n req,\n siblingDoc,\n }),\n )\n })\n await Promise.all(promises)\n}\n"],"names":["promise","traverseFields","id","collection","context","doc","fields","overrideAccess","path","req","schemaPath","siblingDoc","promises","forEach","field","push","parentPath","parentSchemaPath","Promise","all"],"mappings":"AAIA,SAASA,OAAO,QAAQ,eAAc;AAetC,OAAO,MAAMC,iBAAiB,OAAU,EACtCC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,GAAG,EACHC,MAAM,EACNC,cAAc,EACdC,IAAI,EACJC,GAAG,EACHC,UAAU,EACVC,UAAU,EACF;IACR,MAAMC,WAAW,EAAE;IACnBN,OAAOO,OAAO,CAAC,CAACC;QACdF,SAASG,IAAI,CACXf,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAS;YACAP;YACAS,YAAYR;YACZS,kBAAkBP;YAClBD;YACAE;QACF;IAEJ;IACA,MAAMO,QAAQC,GAAG,CAACP;AACpB,EAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { I18n, TFunction } from '@payloadcms/translations';
|
|
2
2
|
import type DataLoader from 'dataloader';
|
|
3
|
+
import type { URL } from 'url';
|
|
3
4
|
import type { TypeWithID, TypeWithTimestamps } from '../collections/config/types.js';
|
|
4
5
|
import type payload from '../index.js';
|
|
5
6
|
import type { TypedLocale, TypedUser } from '../index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,UAAU,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,UAAU,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE9B,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACpF,OAAO,KAAK,OAAO,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,YAAY,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,MAAM,8BAA8B,GAAG;IAC3C,OAAO,EAAE,cAAc,CAAA;IACvB,mGAAmG;IACnG,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,IAAI,EAAE,IAAI,CAAA;IACV;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;OAEG;IACH,OAAO,EAAE,OAAO,OAAO,CAAA;IACvB;;OAEG;IACH,UAAU,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,CAAA;IACxC,gCAAgC;IAChC,iBAAiB,CAAC,EAAE,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAClD,0EAA0E;IAC1E,kBAAkB,CAAC,E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G,WAAW,GAAG,CAAC,CAAA"}
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["import type { I18n, TFunction } from '@payloadcms/translations'\nimport type DataLoader from 'dataloader'\n\nimport type { TypeWithID, TypeWithTimestamps } from '../collections/config/types.js'\nimport type payload from '../index.js'\nimport type { TypedLocale, TypedUser } from '../index.js'\nimport type { validOperators } from './constants.js'\nexport type { Payload as Payload } from '../index.js'\n\nexport type CustomPayloadRequestProperties = {\n context: RequestContext\n /** The locale that should be used for a field when it is not translated to the requested locale */\n fallbackLocale?: string\n i18n: I18n\n /**\n * The requested locale if specified\n * Only available for localized collections\n */\n locale?: TypedLocale\n /**\n * The payload object\n */\n payload: typeof payload\n /**\n * The context in which the request is being made\n */\n payloadAPI: 'GraphQL' | 'local' | 'REST'\n /** Optimized document loader */\n payloadDataLoader?: DataLoader<string, TypeWithID>\n /** Resized versions of the image that was uploaded during this request */\n payloadUploadSizes?: Record<string, Buffer>\n /** Query params on the request */\n query: Record<string, unknown>\n /** Any response headers that are required to be set when a response is sent */\n responseHeaders?: Headers\n /** The route parameters\n * @example\n * /:collection/:id -> /posts/123\n * { collection: 'posts', id: '123' }\n */\n routeParams?: Record<string, unknown>\n /** Translate function - duplicate of i18n.t */\n t: TFunction\n /**\n * Identifier for the database transaction for interactions in a single, all-or-nothing operation.\n * Can also be used to ensure consistency when multiple operations try to create a transaction concurrently on the same request.\n */\n transactionID?: number | Promise<number | string> | string\n /**\n * Used to ensure consistency when multiple operations try to create a transaction concurrently on the same request\n */\n transactionIDPromise?: Promise<void>\n /** The signed-in user */\n user: null | TypedUser\n} & Pick<\n URL,\n 'hash' | 'host' | 'href' | 'origin' | 'pathname' | 'port' | 'protocol' | 'search' | 'searchParams'\n>\ntype PayloadRequestData = {\n /**\n * Data from the request body\n *\n * Within Payload operations, i.e. hooks, data will be there\n * BUT in custom endpoints it will not be, you will need to\n * use either:\n * 1. `const data = await req.json()`\n *\n * 2. import { addDataAndFileToRequest } from '@payloadcms/next/utilities'\n * `await addDataAndFileToRequest(req)`\n * */\n data?: JsonObject\n /** The file on the request, same rules apply as the `data` property */\n file?: {\n data: Buffer\n mimetype: string\n name: string\n size: number\n tempFilePath?: string\n }\n}\nexport type PayloadRequest = CustomPayloadRequestProperties &\n Partial<Request> &\n PayloadRequestData &\n Required<Pick<Request, 'headers'>>\n\nexport interface RequestContext {\n [key: string]: unknown\n}\n\nexport type Operator = (typeof validOperators)[number]\n\n// Makes it so things like passing new Date() will error\nexport type JsonValue = JsonArray | JsonObject | unknown //Date | JsonArray | JsonObject | boolean | null | number | string // TODO: Evaluate proper, strong type for this\n\nexport interface JsonArray extends Array<JsonValue> {}\n\nexport interface JsonObject {\n [key: string]: any\n}\n\nexport type WhereField = {\n // any json-serializable value\n [key in Operator]?: JsonValue\n}\n\nexport type Where = {\n [key: string]: Where[] | WhereField\n and?: Where[]\n or?: Where[]\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Document = any\n\nexport type Operation = 'create' | 'delete' | 'read' | 'update'\nexport type VersionOperations = 'readVersions'\nexport type AuthOperations = 'unlock'\nexport type AllOperations = AuthOperations | Operation | VersionOperations\n\nexport function docHasTimestamps(doc: any): doc is TypeWithTimestamps {\n return doc?.createdAt && doc?.updatedAt\n}\n\nexport type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N // This is a commonly used trick to detect 'any'\nexport type IsAny<T> = IfAny<T, true, false>\nexport type ReplaceAny<T, DefaultType> = IsAny<T> extends true ? DefaultType : T\n"],"names":["docHasTimestamps","doc","createdAt","updatedAt"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["import type { I18n, TFunction } from '@payloadcms/translations'\nimport type DataLoader from 'dataloader'\nimport type { URL } from 'url'\n\nimport type { TypeWithID, TypeWithTimestamps } from '../collections/config/types.js'\nimport type payload from '../index.js'\nimport type { TypedLocale, TypedUser } from '../index.js'\nimport type { validOperators } from './constants.js'\nexport type { Payload as Payload } from '../index.js'\n\nexport type CustomPayloadRequestProperties = {\n context: RequestContext\n /** The locale that should be used for a field when it is not translated to the requested locale */\n fallbackLocale?: string\n i18n: I18n\n /**\n * The requested locale if specified\n * Only available for localized collections\n */\n locale?: TypedLocale\n /**\n * The payload object\n */\n payload: typeof payload\n /**\n * The context in which the request is being made\n */\n payloadAPI: 'GraphQL' | 'local' | 'REST'\n /** Optimized document loader */\n payloadDataLoader?: DataLoader<string, TypeWithID>\n /** Resized versions of the image that was uploaded during this request */\n payloadUploadSizes?: Record<string, Buffer>\n /** Query params on the request */\n query: Record<string, unknown>\n /** Any response headers that are required to be set when a response is sent */\n responseHeaders?: Headers\n /** The route parameters\n * @example\n * /:collection/:id -> /posts/123\n * { collection: 'posts', id: '123' }\n */\n routeParams?: Record<string, unknown>\n /** Translate function - duplicate of i18n.t */\n t: TFunction\n /**\n * Identifier for the database transaction for interactions in a single, all-or-nothing operation.\n * Can also be used to ensure consistency when multiple operations try to create a transaction concurrently on the same request.\n */\n transactionID?: number | Promise<number | string> | string\n /**\n * Used to ensure consistency when multiple operations try to create a transaction concurrently on the same request\n */\n transactionIDPromise?: Promise<void>\n /** The signed-in user */\n user: null | TypedUser\n} & Pick<\n URL,\n 'hash' | 'host' | 'href' | 'origin' | 'pathname' | 'port' | 'protocol' | 'search' | 'searchParams'\n>\ntype PayloadRequestData = {\n /**\n * Data from the request body\n *\n * Within Payload operations, i.e. hooks, data will be there\n * BUT in custom endpoints it will not be, you will need to\n * use either:\n * 1. `const data = await req.json()`\n *\n * 2. import { addDataAndFileToRequest } from '@payloadcms/next/utilities'\n * `await addDataAndFileToRequest(req)`\n * */\n data?: JsonObject\n /** The file on the request, same rules apply as the `data` property */\n file?: {\n data: Buffer\n mimetype: string\n name: string\n size: number\n tempFilePath?: string\n }\n}\nexport type PayloadRequest = CustomPayloadRequestProperties &\n Partial<Request> &\n PayloadRequestData &\n Required<Pick<Request, 'headers'>>\n\nexport interface RequestContext {\n [key: string]: unknown\n}\n\nexport type Operator = (typeof validOperators)[number]\n\n// Makes it so things like passing new Date() will error\nexport type JsonValue = JsonArray | JsonObject | unknown //Date | JsonArray | JsonObject | boolean | null | number | string // TODO: Evaluate proper, strong type for this\n\nexport interface JsonArray extends Array<JsonValue> {}\n\nexport interface JsonObject {\n [key: string]: any\n}\n\nexport type WhereField = {\n // any json-serializable value\n [key in Operator]?: JsonValue\n}\n\nexport type Where = {\n [key: string]: Where[] | WhereField\n and?: Where[]\n or?: Where[]\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Document = any\n\nexport type Operation = 'create' | 'delete' | 'read' | 'update'\nexport type VersionOperations = 'readVersions'\nexport type AuthOperations = 'unlock'\nexport type AllOperations = AuthOperations | Operation | VersionOperations\n\nexport function docHasTimestamps(doc: any): doc is TypeWithTimestamps {\n return doc?.createdAt && doc?.updatedAt\n}\n\nexport type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N // This is a commonly used trick to detect 'any'\nexport type IsAny<T> = IfAny<T, true, false>\nexport type ReplaceAny<T, DefaultType> = IsAny<T> extends true ? DefaultType : T\n"],"names":["docHasTimestamps","doc","createdAt","updatedAt"],"mappings":"AAwHA,OAAO,SAASA,iBAAiBC,GAAQ;IACvC,OAAOA,KAAKC,aAAaD,KAAKE;AAChC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.106",
|
|
4
4
|
"description": "Node, React, Headless CMS and Application Framework built on Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"admin panel",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@monaco-editor/react": "4.6.0",
|
|
75
75
|
"@next/env": "^15.0.0-canary.104",
|
|
76
76
|
"@types/busboy": "1.5.4",
|
|
77
|
-
"ajv": "8.
|
|
77
|
+
"ajv": "8.17.1",
|
|
78
78
|
"bson-objectid": "2.0.4",
|
|
79
79
|
"ci-info": "^4.0.0",
|
|
80
80
|
"console-table-printer": "2.11.2",
|
|
@@ -86,17 +86,17 @@
|
|
|
86
86
|
"http-status": "1.6.2",
|
|
87
87
|
"image-size": "^1.1.1",
|
|
88
88
|
"json-schema-to-typescript": "15.0.1",
|
|
89
|
-
"jsonwebtoken": "9.0.
|
|
89
|
+
"jsonwebtoken": "9.0.2",
|
|
90
90
|
"minimist": "1.2.8",
|
|
91
91
|
"pino": "9.3.1",
|
|
92
92
|
"pino-pretty": "11.2.1",
|
|
93
93
|
"pluralize": "8.0.0",
|
|
94
94
|
"sanitize-filename": "1.6.3",
|
|
95
95
|
"scmp": "2.1.0",
|
|
96
|
-
"ts-essentials": "
|
|
97
|
-
"tsx": "4.
|
|
96
|
+
"ts-essentials": "10.0.2",
|
|
97
|
+
"tsx": "4.19.1",
|
|
98
98
|
"uuid": "10.0.0",
|
|
99
|
-
"@payloadcms/translations": "3.0.0-beta.
|
|
99
|
+
"@payloadcms/translations": "3.0.0-beta.106"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
102
|
"@hyrious/esbuild-plugin-commonjs": "^0.2.4",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"baseBeforeDuplicateArrays.d.ts","sourceRoot":"","sources":["../../../src/fields/baseFields/baseBeforeDuplicateArrays.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAInD;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,SAQvC,CAAA"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import ObjectIdImport from 'bson-objectid';
|
|
2
|
-
const ObjectId = ObjectIdImport.default || ObjectIdImport;
|
|
3
|
-
/**
|
|
4
|
-
* Arrays and Blocks need to clear ids beforeDuplicate
|
|
5
|
-
*/ export const baseBeforeDuplicateArrays = ({ value })=>{
|
|
6
|
-
if (value) {
|
|
7
|
-
value = value.map((item)=>{
|
|
8
|
-
item.id = new ObjectId().toHexString();
|
|
9
|
-
return item;
|
|
10
|
-
});
|
|
11
|
-
return value;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=baseBeforeDuplicateArrays.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/baseFields/baseBeforeDuplicateArrays.ts"],"sourcesContent":["import ObjectIdImport from 'bson-objectid'\n\nimport type { FieldHook } from '../config/types.js'\n\nconst ObjectId = (ObjectIdImport.default ||\n ObjectIdImport) as unknown as typeof ObjectIdImport.default\n/**\n * Arrays and Blocks need to clear ids beforeDuplicate\n */\nexport const baseBeforeDuplicateArrays: FieldHook = ({ value }) => {\n if (value) {\n value = value.map((item) => {\n item.id = new ObjectId().toHexString()\n return item\n })\n return value\n }\n}\n"],"names":["ObjectIdImport","ObjectId","default","baseBeforeDuplicateArrays","value","map","item","id","toHexString"],"mappings":"AAAA,OAAOA,oBAAoB,gBAAe;AAI1C,MAAMC,WAAYD,eAAeE,OAAO,IACtCF;AACF;;CAEC,GACD,OAAO,MAAMG,4BAAuC,CAAC,EAAEC,KAAK,EAAE;IAC5D,IAAIA,OAAO;QACTA,QAAQA,MAAMC,GAAG,CAAC,CAACC;YACjBA,KAAKC,EAAE,GAAG,IAAIN,WAAWO,WAAW;YACpC,OAAOF;QACT;QACA,OAAOF;IACT;AACF,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"beforeDuplicate.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeChange/beforeDuplicate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D,eAAO,MAAM,eAAe,SAAgB,aAAa,iBAIlC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/beforeChange/beforeDuplicate.ts"],"sourcesContent":["import type { FieldHookArgs } from '../../config/types.js'\n\nexport const beforeDuplicate = async (args: FieldHookArgs) =>\n await args.field.hooks.beforeDuplicate.reduce(async (priorHook, currentHook) => {\n await priorHook\n return await currentHook(args)\n }, Promise.resolve())\n"],"names":["beforeDuplicate","args","field","hooks","reduce","priorHook","currentHook","Promise","resolve"],"mappings":"AAEA,OAAO,MAAMA,kBAAkB,OAAOC,OACpC,MAAMA,KAAKC,KAAK,CAACC,KAAK,CAACH,eAAe,CAACI,MAAM,CAAC,OAAOC,WAAWC;QAC9D,MAAMD;QACN,OAAO,MAAMC,YAAYL;IAC3B,GAAGM,QAAQC,OAAO,IAAG"}
|