@payloadcms/plugin-import-export 4.0.0-internal.4804abd → 4.0.0-internal.4c2ee12

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.
Files changed (174) hide show
  1. package/dist/components/CollectionField/index.d.ts +3 -2
  2. package/dist/components/CollectionField/index.d.ts.map +1 -1
  3. package/dist/components/CollectionField/index.js.map +1 -1
  4. package/dist/components/ExportListMenuItem/index.d.ts.map +1 -1
  5. package/dist/components/ExportListMenuItem/index.js +14 -12
  6. package/dist/components/ExportListMenuItem/index.js.map +1 -1
  7. package/dist/components/ExportPreview/index.css +0 -3
  8. package/dist/components/ExportPreview/index.d.ts.map +1 -1
  9. package/dist/components/ExportPreview/index.js +11 -1
  10. package/dist/components/ExportPreview/index.js.map +1 -1
  11. package/dist/components/FieldsToExport/index.d.ts +3 -2
  12. package/dist/components/FieldsToExport/index.d.ts.map +1 -1
  13. package/dist/components/FieldsToExport/index.js +18 -15
  14. package/dist/components/FieldsToExport/index.js.map +1 -1
  15. package/dist/components/FieldsToExport/reduceFields.d.ts +6 -0
  16. package/dist/components/FieldsToExport/reduceFields.d.ts.map +1 -1
  17. package/dist/components/FieldsToExport/reduceFields.js +4 -0
  18. package/dist/components/FieldsToExport/reduceFields.js.map +1 -1
  19. package/dist/components/FormatField/index.d.ts +3 -2
  20. package/dist/components/FormatField/index.d.ts.map +1 -1
  21. package/dist/components/FormatField/index.js.map +1 -1
  22. package/dist/components/ImportListMenuItem/index.d.ts.map +1 -1
  23. package/dist/components/ImportListMenuItem/index.js +14 -12
  24. package/dist/components/ImportListMenuItem/index.js.map +1 -1
  25. package/dist/components/ImportPreview/index.css +0 -3
  26. package/dist/components/ImportPreview/index.d.ts.map +1 -1
  27. package/dist/components/ImportPreview/index.js +27 -8
  28. package/dist/components/ImportPreview/index.js.map +1 -1
  29. package/dist/components/LimitField/index.d.ts +3 -2
  30. package/dist/components/LimitField/index.d.ts.map +1 -1
  31. package/dist/components/LimitField/index.js.map +1 -1
  32. package/dist/components/LocaleField/index.d.ts +3 -2
  33. package/dist/components/LocaleField/index.d.ts.map +1 -1
  34. package/dist/components/LocaleField/index.js.map +1 -1
  35. package/dist/components/Page/index.d.ts +3 -2
  36. package/dist/components/Page/index.d.ts.map +1 -1
  37. package/dist/components/Page/index.js.map +1 -1
  38. package/dist/components/RelationshipCell/getRelationshipGroupKey.d.ts +7 -0
  39. package/dist/components/RelationshipCell/getRelationshipGroupKey.d.ts.map +1 -0
  40. package/dist/components/RelationshipCell/getRelationshipGroupKey.js +3 -0
  41. package/dist/components/RelationshipCell/getRelationshipGroupKey.js.map +1 -0
  42. package/dist/components/RelationshipCell/getRelationshipGroups.d.ts +43 -0
  43. package/dist/components/RelationshipCell/getRelationshipGroups.d.ts.map +1 -0
  44. package/dist/components/RelationshipCell/getRelationshipGroups.js +109 -0
  45. package/dist/components/RelationshipCell/getRelationshipGroups.js.map +1 -0
  46. package/dist/components/RelationshipCell/index.css +30 -0
  47. package/dist/components/RelationshipCell/index.d.ts +15 -0
  48. package/dist/components/RelationshipCell/index.d.ts.map +1 -0
  49. package/dist/components/RelationshipCell/index.js +57 -0
  50. package/dist/components/RelationshipCell/index.js.map +1 -0
  51. package/dist/components/SortBy/index.d.ts +3 -2
  52. package/dist/components/SortBy/index.d.ts.map +1 -1
  53. package/dist/components/SortBy/index.js.map +1 -1
  54. package/dist/components/SortOrder/index.d.ts +3 -2
  55. package/dist/components/SortOrder/index.d.ts.map +1 -1
  56. package/dist/components/SortOrder/index.js.map +1 -1
  57. package/dist/export/batchProcessor.d.ts +4 -3
  58. package/dist/export/batchProcessor.d.ts.map +1 -1
  59. package/dist/export/batchProcessor.js +6 -2
  60. package/dist/export/batchProcessor.js.map +1 -1
  61. package/dist/export/createExport.d.ts +4 -2
  62. package/dist/export/createExport.d.ts.map +1 -1
  63. package/dist/export/createExport.js +7 -2
  64. package/dist/export/createExport.js.map +1 -1
  65. package/dist/export/getCreateExportCollectionTask.d.ts.map +1 -1
  66. package/dist/export/getCreateExportCollectionTask.js +11 -0
  67. package/dist/export/getCreateExportCollectionTask.js.map +1 -1
  68. package/dist/export/getExportCollection.d.ts.map +1 -1
  69. package/dist/export/getExportCollection.js +9 -4
  70. package/dist/export/getExportCollection.js.map +1 -1
  71. package/dist/export/getFields.d.ts.map +1 -1
  72. package/dist/export/handleDownload.d.ts.map +1 -1
  73. package/dist/export/handleDownload.js +7 -3
  74. package/dist/export/handleDownload.js.map +1 -1
  75. package/dist/export/handlePreview.d.ts.map +1 -1
  76. package/dist/export/handlePreview.js +24 -5
  77. package/dist/export/handlePreview.js.map +1 -1
  78. package/dist/exports/types.d.ts +1 -1
  79. package/dist/exports/types.d.ts.map +1 -1
  80. package/dist/exports/types.js.map +1 -1
  81. package/dist/import/batchProcessor.d.ts +4 -3
  82. package/dist/import/batchProcessor.d.ts.map +1 -1
  83. package/dist/import/batchProcessor.js +15 -8
  84. package/dist/import/batchProcessor.js.map +1 -1
  85. package/dist/import/createImport.d.ts +3 -2
  86. package/dist/import/createImport.d.ts.map +1 -1
  87. package/dist/import/createImport.js +8 -1
  88. package/dist/import/createImport.js.map +1 -1
  89. package/dist/import/getCreateImportCollectionTask.d.ts.map +1 -1
  90. package/dist/import/getCreateImportCollectionTask.js +5 -2
  91. package/dist/import/getCreateImportCollectionTask.js.map +1 -1
  92. package/dist/import/getFields.d.ts.map +1 -1
  93. package/dist/import/getImportCollection.d.ts.map +1 -1
  94. package/dist/import/getImportCollection.js +6 -4
  95. package/dist/import/getImportCollection.js.map +1 -1
  96. package/dist/import/handlePreview.d.ts.map +1 -1
  97. package/dist/import/handlePreview.js +5 -1
  98. package/dist/import/handlePreview.js.map +1 -1
  99. package/dist/index.d.ts +1 -2
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +6 -3
  102. package/dist/index.js.map +1 -1
  103. package/dist/translations/languages/en.d.ts.map +1 -1
  104. package/dist/types.d.ts +17 -1
  105. package/dist/types.d.ts.map +1 -1
  106. package/dist/types.js.map +1 -1
  107. package/dist/utilities/applyFieldHooks.d.ts.map +1 -1
  108. package/dist/utilities/buildDisabledFieldRegex.d.ts.map +1 -1
  109. package/dist/utilities/collectDisabledFieldPaths.d.ts.map +1 -1
  110. package/dist/utilities/fieldToRegex.d.ts.map +1 -1
  111. package/dist/utilities/flattenObject.d.ts.map +1 -1
  112. package/dist/utilities/flattenedFields.d.ts.map +1 -1
  113. package/dist/utilities/getExportFieldFunctions.d.ts.map +1 -1
  114. package/dist/utilities/getExportFieldFunctions.js +64 -27
  115. package/dist/utilities/getExportFieldFunctions.js.map +1 -1
  116. package/dist/utilities/getFileFromDoc.d.ts.map +1 -1
  117. package/dist/utilities/getFileFromDoc.js +3 -3
  118. package/dist/utilities/getFileFromDoc.js.map +1 -1
  119. package/dist/utilities/getFlattenedFieldKeys.d.ts.map +1 -1
  120. package/dist/utilities/getImportFieldFunctions.d.ts.map +1 -1
  121. package/dist/utilities/getPluginCollections.d.ts.map +1 -1
  122. package/dist/utilities/getSchemaColumns.d.ts.map +1 -1
  123. package/dist/utilities/getSelect.d.ts.map +1 -1
  124. package/dist/utilities/getSelect.js +11 -3
  125. package/dist/utilities/getSelect.js.map +1 -1
  126. package/dist/utilities/getSubmittedFormValues.d.ts +12 -0
  127. package/dist/utilities/getSubmittedFormValues.d.ts.map +1 -0
  128. package/dist/utilities/getSubmittedFormValues.js +24 -0
  129. package/dist/utilities/getSubmittedFormValues.js.map +1 -0
  130. package/dist/utilities/isPlainObject.d.ts.map +1 -1
  131. package/dist/utilities/parseCSV.d.ts.map +1 -1
  132. package/dist/utilities/parseJSON.d.ts.map +1 -1
  133. package/dist/utilities/polymorphicRel.d.ts.map +1 -1
  134. package/dist/utilities/processRichTextField.d.ts.map +1 -1
  135. package/dist/utilities/removeDisabledFields.d.ts.map +1 -1
  136. package/dist/utilities/setNestedValue.d.ts +2 -1
  137. package/dist/utilities/setNestedValue.d.ts.map +1 -1
  138. package/dist/utilities/setNestedValue.js +65 -34
  139. package/dist/utilities/setNestedValue.js.map +1 -1
  140. package/dist/utilities/sortHelpers.d.ts +1 -1
  141. package/dist/utilities/sortHelpers.d.ts.map +1 -1
  142. package/dist/utilities/unflattenObject.d.ts.map +1 -1
  143. package/dist/utilities/unflattenPostProcess.d.ts.map +1 -1
  144. package/dist/utilities/validateLimitValue.d.ts.map +1 -1
  145. package/license.md +1 -1
  146. package/package.json +9 -9
  147. package/dist/@types/assets.d.js +0 -2
  148. package/dist/@types/assets.d.js.map +0 -1
  149. package/dist/components/FieldsToExport/reduceFields.spec.js +0 -239
  150. package/dist/components/FieldsToExport/reduceFields.spec.js.map +0 -1
  151. package/dist/utilities/applyFieldHooks.spec.js +0 -205
  152. package/dist/utilities/applyFieldHooks.spec.js.map +0 -1
  153. package/dist/utilities/buildDisabledFieldRegex.spec.js +0 -64
  154. package/dist/utilities/buildDisabledFieldRegex.spec.js.map +0 -1
  155. package/dist/utilities/fieldToRegex.spec.js +0 -151
  156. package/dist/utilities/fieldToRegex.spec.js.map +0 -1
  157. package/dist/utilities/filterToSelectedFields.spec.js +0 -204
  158. package/dist/utilities/filterToSelectedFields.spec.js.map +0 -1
  159. package/dist/utilities/flattenObject.spec.js +0 -158
  160. package/dist/utilities/flattenObject.spec.js.map +0 -1
  161. package/dist/utilities/getExportFieldFunctions.spec.js +0 -50
  162. package/dist/utilities/getExportFieldFunctions.spec.js.map +0 -1
  163. package/dist/utilities/getImportFieldFunctions.spec.js +0 -167
  164. package/dist/utilities/getImportFieldFunctions.spec.js.map +0 -1
  165. package/dist/utilities/getSchemaColumns.spec.js +0 -157
  166. package/dist/utilities/getSchemaColumns.spec.js.map +0 -1
  167. package/dist/utilities/parseCSV.spec.js +0 -195
  168. package/dist/utilities/parseCSV.spec.js.map +0 -1
  169. package/dist/utilities/processRichTextField.spec.js +0 -308
  170. package/dist/utilities/processRichTextField.spec.js.map +0 -1
  171. package/dist/utilities/siblingDoc.spec.js +0 -278
  172. package/dist/utilities/siblingDoc.spec.js.map +0 -1
  173. package/dist/utilities/unflattenObject.spec.js +0 -819
  174. package/dist/utilities/unflattenObject.spec.js.map +0 -1
@@ -50,45 +50,82 @@ const registerExportHandler = (field, fullKey, result)=>{
50
50
  registerHandler(({ value })=>typeof value === 'object' && value && 'id' in value ? value.id : value);
51
51
  return;
52
52
  }
53
- registerHandler(({ siblingData, value })=>{
54
- if (isPolymorphicRelValue(value)) {
55
- const id = getPolymorphicRelId(value);
56
- if (id !== undefined) {
57
- siblingData[`${fullKey}_id`] = id;
58
- siblingData[`${fullKey}_relationTo`] = value.relationTo;
59
- }
53
+ registerHandler(({ format, siblingData, value })=>{
54
+ // A shape this handler does not recognize is left untouched for JSON, which holds the
55
+ // source value verbatim. CSV still clears it, since its id/relationTo would otherwise
56
+ // land in sibling columns.
57
+ if (!isPolymorphicRelValue(value)) {
58
+ return format === 'json' ? undefined : null;
59
+ }
60
+ // A recognized reference that resolves to no id is dangling, and a dangling reference
61
+ // cannot be imported back — clear it for both formats.
62
+ const id = getPolymorphicRelId(value);
63
+ if (id === undefined) {
64
+ return null;
65
+ }
66
+ if (format === 'json') {
67
+ return {
68
+ relationTo: value.relationTo,
69
+ value: id
70
+ };
60
71
  }
72
+ siblingData[`${fullKey}_id`] = id;
73
+ siblingData[`${fullKey}_relationTo`] = value.relationTo;
61
74
  return null;
62
75
  });
63
76
  return;
64
77
  }
65
78
  if (!Array.isArray(field.relationTo)) {
66
- registerHandler(({ siblingData, value })=>{
67
- if (Array.isArray(value)) {
68
- value.forEach((val, i)=>{
69
- const id = typeof val === 'object' && val ? val.id : val;
70
- siblingData[`${fullKey}_${i}_id`] = id;
71
- });
72
- return null;
79
+ registerHandler(({ format, siblingData, value })=>{
80
+ if (!Array.isArray(value)) {
81
+ return undefined;
73
82
  }
74
- return undefined;
83
+ const ids = value.map((val)=>typeof val === 'object' && val ? val.id : val);
84
+ // Bare null entries fail relationship validation when the JSON is imported, so drop
85
+ // references that could not be resolved. CSV keeps source indexes in its column names;
86
+ // unflattening those columns collapses any gaps on import.
87
+ if (format === 'json') {
88
+ return ids.filter((id)=>id !== null && id !== undefined);
89
+ }
90
+ ids.forEach((id, i)=>{
91
+ siblingData[`${fullKey}_${i}_id`] = id;
92
+ });
93
+ return null;
75
94
  });
76
95
  return;
77
96
  }
78
- registerHandler(({ siblingData, value })=>{
79
- if (Array.isArray(value)) {
80
- value.forEach((val, i)=>{
81
- if (isPolymorphicRelValue(val)) {
82
- const id = getPolymorphicRelId(val);
83
- if (id !== undefined) {
84
- siblingData[`${fullKey}_${i}_id`] = id;
85
- siblingData[`${fullKey}_${i}_relationTo`] = val.relationTo;
86
- }
97
+ registerHandler(({ format, siblingData, value })=>{
98
+ if (!Array.isArray(value)) {
99
+ return undefined;
100
+ }
101
+ // `index` is carried so CSV columns stay pinned to the source position: an entry
102
+ // that cannot be resolved to an id leaves a gap rather than shifting its siblings.
103
+ const rels = value.flatMap((val, index)=>{
104
+ if (!isPolymorphicRelValue(val)) {
105
+ return [];
106
+ }
107
+ const id = getPolymorphicRelId(val);
108
+ return id === undefined ? [] : [
109
+ {
110
+ id,
111
+ index,
112
+ relationTo: val.relationTo
87
113
  }
88
- });
89
- return null;
114
+ ];
115
+ });
116
+ if (format === 'json') {
117
+ // Bare null entries fail relationship validation when the JSON is imported, so return
118
+ // only references that resolved to an id.
119
+ return rels.map(({ id, relationTo })=>({
120
+ relationTo,
121
+ value: id
122
+ }));
90
123
  }
91
- return undefined;
124
+ rels.forEach(({ id, index, relationTo })=>{
125
+ siblingData[`${fullKey}_${index}_id`] = id;
126
+ siblingData[`${fullKey}_${index}_relationTo`] = relationTo;
127
+ });
128
+ return null;
92
129
  });
93
130
  };
94
131
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getExportFieldFunctions.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\nimport type { ExportFieldHookEntry, FieldBeforeExportHook } from '../types.js'\n\nimport { registerFieldHooks } from './flattenedFields.js'\nimport { getPolymorphicRelId, isPolymorphicRelValue } from './polymorphicRel.js'\n\ntype Args = {\n fields: FlattenedField[]\n}\n\n/**\n * Builds a map from logical field path (e.g. `content_textBlock_body`) to\n * the export hook entry. Paths include block slugs but never array indices.\n */\nexport const getExportFieldFunctions = ({ fields }: Args): Record<string, ExportFieldHookEntry> => {\n const result: Record<string, ExportFieldHookEntry> = {}\n registerFieldHooks(fields, '', result, registerExportHandler)\n return result\n}\n\nconst registerExportHandler = (\n field: FlattenedField,\n fullKey: string,\n result: Record<string, ExportFieldHookEntry>,\n): void => {\n const beforeExport = field.custom?.['plugin-import-export']?.hooks?.beforeExport\n\n if (typeof beforeExport === 'function') {\n result[fullKey] = { type: 'beforeExport', fn: beforeExport }\n return\n }\n\n const registerHandler = (handler: FieldBeforeExportHook) => {\n result[fullKey] = { type: 'beforeExport', fn: handler }\n }\n\n if (field.type === 'json' || field.type === 'richText') {\n registerHandler(({ format, value }) => {\n if (format === 'json') {\n return value\n }\n if (value === null || value === undefined) {\n return value\n }\n if (typeof value === 'object') {\n return JSON.stringify(value)\n }\n return value\n })\n return\n }\n\n if (field.type === 'date') {\n registerHandler(({ value }) => value)\n return\n }\n\n if (field.type !== 'relationship' && field.type !== 'upload') {\n return\n }\n\n if (field.hasMany !== true) {\n if (!Array.isArray(field.relationTo)) {\n registerHandler(({ value }) =>\n typeof value === 'object' && value && 'id' in value ? value.id : value,\n )\n return\n }\n\n registerHandler(({ siblingData, value }) => {\n if (isPolymorphicRelValue(value)) {\n const id = getPolymorphicRelId(value)\n if (id !== undefined) {\n siblingData[`${fullKey}_id`] = id\n siblingData[`${fullKey}_relationTo`] = value.relationTo\n }\n }\n return null\n })\n return\n }\n\n if (!Array.isArray(field.relationTo)) {\n registerHandler(({ siblingData, value }) => {\n if (Array.isArray(value)) {\n value.forEach((val, i) => {\n const id = typeof val === 'object' && val ? (val as { id: unknown }).id : val\n siblingData[`${fullKey}_${i}_id`] = id\n })\n return null\n }\n return undefined\n })\n return\n }\n\n registerHandler(({ siblingData, value }) => {\n if (Array.isArray(value)) {\n value.forEach((val, i) => {\n if (isPolymorphicRelValue(val)) {\n const id = getPolymorphicRelId(val)\n if (id !== undefined) {\n siblingData[`${fullKey}_${i}_id`] = id\n siblingData[`${fullKey}_${i}_relationTo`] = val.relationTo\n }\n }\n })\n return null\n }\n return undefined\n })\n}\n"],"names":["registerFieldHooks","getPolymorphicRelId","isPolymorphicRelValue","getExportFieldFunctions","fields","result","registerExportHandler","field","fullKey","beforeExport","custom","hooks","type","fn","registerHandler","handler","format","value","undefined","JSON","stringify","hasMany","Array","isArray","relationTo","id","siblingData","forEach","val","i"],"mappings":"AAIA,SAASA,kBAAkB,QAAQ,uBAAsB;AACzD,SAASC,mBAAmB,EAAEC,qBAAqB,QAAQ,sBAAqB;AAMhF;;;CAGC,GACD,OAAO,MAAMC,0BAA0B,CAAC,EAAEC,MAAM,EAAQ;IACtD,MAAMC,SAA+C,CAAC;IACtDL,mBAAmBI,QAAQ,IAAIC,QAAQC;IACvC,OAAOD;AACT,EAAC;AAED,MAAMC,wBAAwB,CAC5BC,OACAC,SACAH;IAEA,MAAMI,eAAeF,MAAMG,MAAM,EAAE,CAAC,uBAAuB,EAAEC,OAAOF;IAEpE,IAAI,OAAOA,iBAAiB,YAAY;QACtCJ,MAAM,CAACG,QAAQ,GAAG;YAAEI,MAAM;YAAgBC,IAAIJ;QAAa;QAC3D;IACF;IAEA,MAAMK,kBAAkB,CAACC;QACvBV,MAAM,CAACG,QAAQ,GAAG;YAAEI,MAAM;YAAgBC,IAAIE;QAAQ;IACxD;IAEA,IAAIR,MAAMK,IAAI,KAAK,UAAUL,MAAMK,IAAI,KAAK,YAAY;QACtDE,gBAAgB,CAAC,EAAEE,MAAM,EAAEC,KAAK,EAAE;YAChC,IAAID,WAAW,QAAQ;gBACrB,OAAOC;YACT;YACA,IAAIA,UAAU,QAAQA,UAAUC,WAAW;gBACzC,OAAOD;YACT;YACA,IAAI,OAAOA,UAAU,UAAU;gBAC7B,OAAOE,KAAKC,SA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AAIK,MAAMC,OAAO,CAACN,QAAQ;YACxBA,MAAMU,OAAO,CAAC,CAACC,KAAKC;gBAClB,IAAI3B,sBAAsB0B,MAAM;oBAC9B,MAAMH,KAAKxB,oBAAoB2B;oBAC/B,IAAIH,OAAOP,WAAW;wBACpBQ,WAAW,CAAC,GAAGlB,QAAQ,CAAC,EAAEqB,EAAE,GAAG,CAAC,CAAC,GAAGJ;wBACpCC,WAAW,CAAC,GAAGlB,QAAQ,CAAC,EAAEqB,EAAE,WAAW,CAAC,CAAC,GAAGD,IAAIJ,UAAU;oBAC5D;gBACF;YACF;YACA,OAAO;QACT;QACA,OAAON;IACT;AACF"}
1
+ {"version":3,"sources":["../../src/utilities/getExportFieldFunctions.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\nimport type { ExportFieldHookEntry, FieldBeforeExportHook } from '../types.js'\n\nimport { registerFieldHooks } from './flattenedFields.js'\nimport { getPolymorphicRelId, isPolymorphicRelValue } from './polymorphicRel.js'\n\ntype Args = {\n fields: FlattenedField[]\n}\n\n/**\n * Builds a map from logical field path (e.g. `content_textBlock_body`) to\n * the export hook entry. Paths include block slugs but never array indices.\n */\nexport const getExportFieldFunctions = ({ fields }: Args): Record<string, ExportFieldHookEntry> => {\n const result: Record<string, ExportFieldHookEntry> = {}\n registerFieldHooks(fields, '', result, registerExportHandler)\n return result\n}\n\nconst registerExportHandler = (\n field: FlattenedField,\n fullKey: string,\n result: Record<string, ExportFieldHookEntry>,\n): void => {\n const beforeExport = field.custom?.['plugin-import-export']?.hooks?.beforeExport\n\n if (typeof beforeExport === 'function') {\n result[fullKey] = { type: 'beforeExport', fn: beforeExport }\n return\n }\n\n const registerHandler = (handler: FieldBeforeExportHook) => {\n result[fullKey] = { type: 'beforeExport', fn: handler }\n }\n\n if (field.type === 'json' || field.type === 'richText') {\n registerHandler(({ format, value }) => {\n if (format === 'json') {\n return value\n }\n if (value === null || value === undefined) {\n return value\n }\n if (typeof value === 'object') {\n return JSON.stringify(value)\n }\n return value\n })\n return\n }\n\n if (field.type === 'date') {\n registerHandler(({ value }) => value)\n return\n }\n\n if (field.type !== 'relationship' && field.type !== 'upload') {\n return\n }\n\n if (field.hasMany !== true) {\n if (!Array.isArray(field.relationTo)) {\n registerHandler(({ value }) =>\n typeof value === 'object' && value && 'id' in value ? value.id : value,\n )\n return\n }\n\n registerHandler(({ format, siblingData, value }) => {\n // A shape this handler does not recognize is left untouched for JSON, which holds the\n // source value verbatim. CSV still clears it, since its id/relationTo would otherwise\n // land in sibling columns.\n if (!isPolymorphicRelValue(value)) {\n return format === 'json' ? undefined : null\n }\n\n // A recognized reference that resolves to no id is dangling, and a dangling reference\n // cannot be imported back — clear it for both formats.\n const id = getPolymorphicRelId(value)\n if (id === undefined) {\n return null\n }\n\n if (format === 'json') {\n return { relationTo: value.relationTo, value: id }\n }\n siblingData[`${fullKey}_id`] = id\n siblingData[`${fullKey}_relationTo`] = value.relationTo\n return null\n })\n return\n }\n\n if (!Array.isArray(field.relationTo)) {\n registerHandler(({ format, siblingData, value }) => {\n if (!Array.isArray(value)) {\n return undefined\n }\n const ids = value.map((val) =>\n typeof val === 'object' && val ? (val as { id: unknown }).id : val,\n )\n // Bare null entries fail relationship validation when the JSON is imported, so drop\n // references that could not be resolved. CSV keeps source indexes in its column names;\n // unflattening those columns collapses any gaps on import.\n if (format === 'json') {\n return ids.filter((id) => id !== null && id !== undefined)\n }\n ids.forEach((id, i) => {\n siblingData[`${fullKey}_${i}_id`] = id\n })\n return null\n })\n return\n }\n\n registerHandler(({ format, siblingData, value }) => {\n if (!Array.isArray(value)) {\n return undefined\n }\n // `index` is carried so CSV columns stay pinned to the source position: an entry\n // that cannot be resolved to an id leaves a gap rather than shifting its siblings.\n const rels = value.flatMap((val, index) => {\n if (!isPolymorphicRelValue(val)) {\n return []\n }\n const id = getPolymorphicRelId(val)\n return id === undefined ? [] : [{ id, index, relationTo: val.relationTo }]\n })\n\n if (format === 'json') {\n // Bare null entries fail relationship validation when the JSON is imported, so return\n // only references that resolved to an id.\n return rels.map(({ id, relationTo }) => ({ relationTo, value: id }))\n }\n rels.forEach(({ id, index, relationTo }) => {\n siblingData[`${fullKey}_${index}_id`] = id\n siblingData[`${fullKey}_${index}_relationTo`] = relationTo\n })\n return null\n })\n}\n"],"names":["registerFieldHooks","getPolymorphicRelId","isPolymorphicRelValue","getExportFieldFunctions","fields","result","registerExportHandler","field","fullKey","beforeExport","custom","hooks","type","fn","registerHandler","handler","format","value","undefined","JSON","stringify","hasMany","Array","isArray","relationTo","id","siblingData","ids","map","val","filter","forEach","i","rels","flatMap","index"],"mappings":"AAIA,SAASA,kBAAkB,QAAQ,uBAAsB;AACzD,SAASC,mBAAmB,EAAEC,qBAAqB,QAAQ,sBAAqB;AAMhF;;;CAGC,GACD,OAAO,MAAMC,0BAA0B,CAAC,EAAEC,MAAM,EAAQ;IACtD,MAAMC,SAA+C,CAAC;IACtDL,mBAAmBI,QAAQ,IAAIC,QAAQC;IACvC,OAAOD;AACT,EAAC;AAED,MAAMC,wBAAwB,CAC5BC,OACAC,SACAH;IAEA,MAAMI,eAAeF,MAAMG,MAAM,EAAE,CAAC,uBAAuB,EAAEC,OAAOF;IAEpE,IAAI,OAAOA,iBAAiB,YAAY;QACtCJ,MAAM,CAACG,QAAQ,GAAG;YAAEI,MAAM;YAAgBC,IAAIJ;QAAa;QAC3D;IACF;IAEA,MAAMK,kBAAkB,CAACC;QACvBV,MAAM,CAACG,QAAQ,GAAG;YAAEI,MAAM;YAAgBC,IAAIE;QAAQ;IACxD;IAEA,IAAIR,MAAMK,IAAI,KAAK,UAAUL,MAAMK,IAAI,KAAK,YAAY;QACtDE,gBAAgB,CAAC,EAAEE,MAAM,EAAEC,KAAK,EAAE;YAChC,IAAID,WAAW,QAAQ;gBACrB,OAAOC;YACT;YACA,IAAIA,UAAU,QAAQA,UAAUC,WAAW;gBACzC,OAAOD;YACT;YACA,IAAI,OAAOA,UAAU,UAAU;gBAC7B,OAAOE,KAAKC,SAAS,CAAC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1 @@
1
- {"version":3,"file":"getFileFromDoc.d.ts","sourceRoot":"","sources":["../../src/utilities/getFileFromDoc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAY,cAAc,EAAgB,MAAM,SAAS,CAAA;AAMvF,KAAK,IAAI,GAAG;IACV,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,GAAG,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAC1D,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,KAAK,MAAM,GAAG;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAU,gCAAgC,IAAI,KAAG,OAAO,CAAC,MAAM,CAkEzF,CAAA"}
1
+ {"version":3,"file":"getFileFromDoc.d.ts","sourceRoot":"","sources":["../../src/utilities/getFileFromDoc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAY,cAAc,EAAgB,MAAM,SAAS,CAAA;AAMvF,KAAK,IAAI,GAAG;IACV,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,GAAG,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAC1D,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,KAAK,MAAM,GAAG;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,mCAA0C,IAAI,KAAG,OAAO,CAAC,MAAM,CAkEzF,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { FileRetrievalError, getFileByPath } from 'payload';
2
- import { getExternalFile } from 'payload/internal';
2
+ import { downloadFileToBuffer } from 'payload/internal';
3
3
  import { formatAdminURL } from 'payload/shared';
4
4
  /**
5
5
  * Retrieves file data from an uploaded document, handling both local storage
@@ -33,7 +33,7 @@ import { formatAdminURL } from 'payload/shared';
33
33
  }
34
34
  if (doc.filename && doc.url) {
35
35
  // Cloud storage or external - fetch via Payload's file endpoint
36
- // getExternalFile constructs full URL, includes cookies for auth, and
36
+ // downloadFileToBuffer constructs full URL, includes cookies for auth, and
37
37
  // the request goes through Payload's handler chain (including storage adapter)
38
38
  // For relative URLs, construct a full URL using formatAdminURL which properly
39
39
  // handles serverURL, basePath, and other config. This is important in job contexts
@@ -44,7 +44,7 @@ import { formatAdminURL } from 'payload/shared';
44
44
  path: doc.url,
45
45
  serverURL: serverURL || req.origin
46
46
  });
47
- const file = await getExternalFile({
47
+ const file = await downloadFileToBuffer({
48
48
  data: {
49
49
  filename: doc.filename,
50
50
  url: fileUrl
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getFileFromDoc.ts"],"sourcesContent":["import type { CollectionConfig, FileData, PayloadRequest, UploadConfig } from 'payload'\n\nimport { FileRetrievalError, getFileByPath } from 'payload'\nimport { getExternalFile } from 'payload/internal'\nimport { formatAdminURL } from 'payload/shared'\n\ntype Args = {\n collectionConfig: CollectionConfig\n doc: { filename: string; mimeType?: string; url?: string }\n req: PayloadRequest\n}\n\ntype Result = {\n data: Buffer\n mimetype: string\n}\n\n/**\n * Retrieves file data from an uploaded document, handling both local storage\n * and cloud storage (S3, Azure, GCS, etc.) scenarios correctly.\n *\n * This function uses the same pattern as Payload's internal file retrieval:\n * - For local storage: reads directly from disk (efficient, no HTTP roundtrip)\n * - For cloud storage: fetches via Payload's file endpoint, which triggers\n * the storage adapter's staticHandler to serve the file\n */\nexport const getFileFromDoc = async ({ collectionConfig, doc, req }: Args): Promise<Result> => {\n const uploadConfig: UploadConfig =\n typeof collectionConfig.upload === 'object' ? collectionConfig.upload : {}\n const disableLocalStorage = uploadConfig.disableLocalStorage ?? false\n const staticDir = uploadConfig.staticDir || collectionConfig.slug\n\n const serverURL = req.payload.config.serverURL\n const isLocalFile = (serverURL && doc.url?.startsWith(serverURL)) || doc.url?.startsWith('/')\n\n if (!disableLocalStorage && isLocalFile && doc.filename) {\n // Local storage enabled - read directly from disk (efficient, no HTTP roundtrip)\n const filePath = `${staticDir}/${doc.filename}`\n const file = await getFileByPath(filePath)\n\n if (!file) {\n throw new Error(`File not found at path: ${filePath}`)\n }\n\n const mimetype = file.mimetype || doc.mimeType\n\n if (!mimetype) {\n throw new FileRetrievalError(req.t, `Unable to determine mimetype for file: ${doc.filename}`)\n }\n\n return {\n data: file.data,\n mimetype,\n }\n }\n\n if (doc.filename && doc.url) {\n // Cloud storage or external - fetch via Payload's file endpoint\n // getExternalFile constructs full URL, includes cookies for auth, and\n // the request goes through Payload's handler chain (including storage adapter)\n\n // For relative URLs, construct a full URL using formatAdminURL which properly\n // handles serverURL, basePath, and other config. This is important in job contexts\n // where request headers may not be available for URL construction.\n // Use serverURL from config, falling back to req.origin for local/job requests.\n const fileUrl = doc.url.startsWith('http')\n ? doc.url\n : formatAdminURL({\n apiRoute: '',\n path: doc.url as `/${string}`,\n serverURL: serverURL || req.origin,\n })\n\n const file = await getExternalFile({\n data: { filename: doc.filename, url: fileUrl } as FileData,\n req,\n uploadConfig,\n })\n\n const mimetype = file.mimetype || doc.mimeType\n\n if (!mimetype) {\n throw new FileRetrievalError(req.t, `Unable to determine mimetype for file: ${doc.filename}`)\n }\n\n return {\n data: file.data,\n mimetype,\n }\n }\n\n throw new Error('Unable to retrieve file: missing filename or url')\n}\n"],"names":["FileRetrievalError","getFileByPath","getExternalFile","formatAdminURL","getFileFromDoc","collectionConfig","doc","req","uploadConfig","upload","disableLocalStorage","staticDir","slug","serverURL","payload","config","isLocalFile","url","startsWith","filename","filePath","file","Error","mimetype","mimeType","t","data","fileUrl","apiRoute","path","origin"],"mappings":"AA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IAAIW,GAAG,CAACC,UAAU,CAAC,UAC/BZ,IAAIW,GAAG,GACPd,eAAe;YACbyB,UAAU;YACVC,MAAMvB,IAAIW,GAAG;YACbJ,WAAWA,aAAaN,IAAIuB,MAAM;QACpC;QAEJ,MAAMT,OAAO,MAAMnB,gBAAgB;YACjCwB,MAAM;gBAAEP,UAAUb,IAAIa,QAAQ;gBAAEF,KAAKU;YAAQ;YAC7CpB;YACAC;QACF;QAEA,MAAMe,WAAWF,KAAKE,QAAQ,IAAIjB,IAAIkB,QAAQ;QAE9C,IAAI,CAACD,UAAU;YACb,MAAM,IAAIvB,mBAAmBO,IAAIkB,CAAC,EAAE,CAAC,uCAAuC,EAAEnB,IAAIa,QAAQ,EAAE;QAC9F;QAEA,OAAO;YACLO,MAAML,KAAKK,IAAI;YACfH;QACF;IACF;IAEA,MAAM,IAAID,MAAM;AAClB,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/getFileFromDoc.ts"],"sourcesContent":["import type { CollectionConfig, FileData, PayloadRequest, UploadConfig } from 'payload'\n\nimport { FileRetrievalError, getFileByPath } from 'payload'\nimport { downloadFileToBuffer } from 'payload/internal'\nimport { formatAdminURL } from 'payload/shared'\n\ntype Args = {\n collectionConfig: CollectionConfig\n doc: { filename: string; mimeType?: string; url?: string }\n req: PayloadRequest\n}\n\ntype Result = {\n data: Buffer\n mimetype: string\n}\n\n/**\n * Retrieves file data from an uploaded document, handling both local storage\n * and cloud storage (S3, Azure, GCS, etc.) scenarios correctly.\n *\n * This function uses the same pattern as Payload's internal file retrieval:\n * - For local storage: reads directly from disk (efficient, no HTTP roundtrip)\n * - For cloud storage: fetches via Payload's file endpoint, which triggers\n * the storage adapter's staticHandler to serve the file\n */\nexport const getFileFromDoc = async ({ collectionConfig, doc, req }: Args): Promise<Result> => {\n const uploadConfig: UploadConfig =\n typeof collectionConfig.upload === 'object' ? collectionConfig.upload : {}\n const disableLocalStorage = uploadConfig.disableLocalStorage ?? false\n const staticDir = uploadConfig.staticDir || collectionConfig.slug\n\n const serverURL = req.payload.config.serverURL\n const isLocalFile = (serverURL && doc.url?.startsWith(serverURL)) || doc.url?.startsWith('/')\n\n if (!disableLocalStorage && isLocalFile && doc.filename) {\n // Local storage enabled - read directly from disk (efficient, no HTTP roundtrip)\n const filePath = `${staticDir}/${doc.filename}`\n const file = await getFileByPath(filePath)\n\n if (!file) {\n throw new Error(`File not found at path: ${filePath}`)\n }\n\n const mimetype = file.mimetype || doc.mimeType\n\n if (!mimetype) {\n throw new FileRetrievalError(req.t, `Unable to determine mimetype for file: ${doc.filename}`)\n }\n\n return {\n data: file.data,\n mimetype,\n }\n }\n\n if (doc.filename && doc.url) {\n // Cloud storage or external - fetch via Payload's file endpoint\n // downloadFileToBuffer constructs full URL, includes cookies for auth, and\n // the request goes through Payload's handler chain (including storage adapter)\n\n // For relative URLs, construct a full URL using formatAdminURL which properly\n // handles serverURL, basePath, and other config. This is important in job contexts\n // where request headers may not be available for URL construction.\n // Use serverURL from config, falling back to req.origin for local/job requests.\n const fileUrl = doc.url.startsWith('http')\n ? doc.url\n : formatAdminURL({\n apiRoute: '',\n path: doc.url as `/${string}`,\n serverURL: serverURL || req.origin,\n })\n\n const file = await downloadFileToBuffer({\n data: { filename: doc.filename, url: fileUrl } as FileData,\n req,\n uploadConfig,\n })\n\n const mimetype = file.mimetype || doc.mimeType\n\n if (!mimetype) {\n throw new FileRetrievalError(req.t, `Unable to determine mimetype for file: ${doc.filename}`)\n }\n\n return {\n data: file.data,\n mimetype,\n }\n }\n\n throw new Error('Unable to retrieve file: missing filename or url')\n}\n"],"names":["FileRetrievalError","getFileByPath","downloadFileToBuffer","formatAdminURL","getFileFromDoc","collectionConfig","doc","req","uploadConfig","upload","disableLocalStorage","staticDir","slug","serverURL","payload","config","isLocalFile","url","startsWith","filename","filePath","file","Error","mimetype","mimeType","t","data","fileUrl","apiRoute","path","origin"],"mappings":"AAEA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,UAAS;AAC3D,SAASC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,GACPd,eAAe;YACbyB,UAAU;YACVC,MAAMvB,IAAIW,GAAG;YACbJ,WAAWA,aAAaN,IAAIuB,MAAM;QACpC;QAEJ,MAAMT,OAAO,MAAMnB,qBAAqB;YACtCwB,MAAM;gBAAEP,UAAUb,IAAIa,QAAQ;gBAAEF,KAAKU;YAAQ;YAC7CpB;YACAC;QACF;QAEA,MAAMe,WAAWF,KAAKE,QAAQ,IAAIjB,IAAIkB,QAAQ;QAE9C,IAAI,CAACD,UAAU;YACb,MAAM,IAAIvB,mBAAmBO,IAAIkB,CAAC,EAAE,CAAC,uCAAuC,EAAEnB,IAAIa,QAAQ,EAAE;QAC9F;QAEA,OAAO;YACLO,MAAML,KAAKK,IAAI;YACfH;QACF;IACF;IAEA,MAAM,IAAID,MAAM;AAClB,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getFlattenedFieldKeys.d.ts","sourceRoot":"","sources":["../../src/utilities/getFlattenedFieldKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,KAAK,uBAAuB,GACxB;IACE,MAAM,CAAC,EAAE,cAAc,EAAE,CAAA;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE;QACL,MAAM,EAAE,cAAc,EAAE,CAAA;QACxB,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,EAAE,CAAA;IACH,IAAI,EAAE,aAAa,GAAG,KAAK,GAAG,MAAM,CAAA;CACrC,GACD,cAAc,CAAA;AAElB,MAAM,MAAM,4BAA4B,GAAG;IACzC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACvB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,uBAAuB,EAAE,EACjC,eAAW,EACX,UAAS,4BAAiC,KACzC,MAAM,EAuGR,CAAA"}
1
+ {"version":3,"file":"getFlattenedFieldKeys.d.ts","sourceRoot":"","sources":["../../src/utilities/getFlattenedFieldKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,KAAK,uBAAuB,GACxB;IACE,MAAM,CAAC,EAAE,cAAc,EAAE,CAAA;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE;QACL,MAAM,EAAE,cAAc,EAAE,CAAA;QACxB,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,EAAE,CAAA;IACH,IAAI,EAAE,aAAa,GAAG,KAAK,GAAG,MAAM,CAAA;CACrC,GACD,cAAc,CAAA;AAElB,MAAM,MAAM,4BAA4B,GAAG;IACzC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACvB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,WACxB,uBAAuB,EAAE,6BAExB,4BAA4B,KACpC,MAAM,EAuGR,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getImportFieldFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/getImportFieldFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAyB,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAI9E,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,cAAc,EAAE,CAAA;CACzB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAAI,YAAY,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAI7F,CAAA"}
1
+ {"version":3,"file":"getImportFieldFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/getImportFieldFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAyB,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAI9E,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,cAAc,EAAE,CAAA;CACzB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,eAAgB,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAI7F,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getPluginCollections.d.ts","sourceRoot":"","sources":["../../src/utilities/getPluginCollections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEvD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAK3D,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;OAGG;IACH,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxC;;;OAGG;IACH,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxC;;OAEG;IACH,iBAAiB,EAAE,gBAAgB,EAAE,CAAA;IACrC;;OAEG;IACH,iBAAiB,EAAE,gBAAgB,EAAE,CAAA;CACtC,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oBAAoB,GAAU,2BAGxC;IACD,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,wBAAwB,CAAA;CACvC,KAAG,OAAO,CAAC,uBAAuB,CAyLlC,CAAA"}
1
+ {"version":3,"file":"getPluginCollections.d.ts","sourceRoot":"","sources":["../../src/utilities/getPluginCollections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEvD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAK3D,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;OAGG;IACH,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxC;;;OAGG;IACH,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxC;;OAEG;IACH,iBAAiB,EAAE,gBAAgB,EAAE,CAAA;IACrC;;OAEG;IACH,iBAAiB,EAAE,gBAAgB,EAAE,CAAA;CACtC,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oBAAoB,8BAG9B;IACD,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,wBAAwB,CAAA;CACvC,KAAG,OAAO,CAAC,uBAAuB,CAyLlC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getSchemaColumns.d.ts","sourceRoot":"","sources":["../../src/utilities/getSchemaColumns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAIxD,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB;;OAEG;IACH,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;IACtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACvB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,GAAI,oFAM9B,oBAAoB,KAAG,MAAM,EAmC/B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,eAAe,MAAM,EAAE,EAAE,aAAa,MAAM,EAAE,KAAG,MAAM,EAqEnF,CAAA;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAmC5F"}
1
+ {"version":3,"file":"getSchemaColumns.d.ts","sourceRoot":"","sources":["../../src/utilities/getSchemaColumns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAIxD,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB;;OAEG;IACH,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;IACtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACvB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,uFAM1B,oBAAoB,KAAG,MAAM,EAmC/B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,kBAAmB,MAAM,EAAE,eAAe,MAAM,EAAE,KAAG,MAAM,EAqEnF,CAAA;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAmC5F"}
@@ -1 +1 @@
1
- {"version":3,"file":"getSelect.d.ts","sourceRoot":"","sources":["../../src/utilities/getSelect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,EAAE,KAAG,iBAoB5C,CAAA"}
1
+ {"version":3,"file":"getSelect.d.ts","sourceRoot":"","sources":["../../src/utilities/getSelect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAOhD;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,WAAY,MAAM,EAAE,KAAG,iBAyB5C,CAAA"}
@@ -1,3 +1,6 @@
1
+ import { APIError } from 'payload';
2
+ import { hasUnsupportedFieldPathSegment } from 'payload/shared';
3
+ const createSelect = ()=>Object.create(null);
1
4
  /**
2
5
  * Takes an input of array of string paths in dot notation and returns a select object.
3
6
  * Used for both export and import to build Payload's select query format.
@@ -6,16 +9,21 @@
6
9
  * getSelect(['id', 'title', 'group.value', 'createdAt', 'updatedAt'])
7
10
  * // Returns: { id: true, title: true, group: { value: true }, createdAt: true, updatedAt: true }
8
11
  */ export const getSelect = (fields)=>{
9
- const select = {};
12
+ const select = createSelect();
10
13
  fields.forEach((field)=>{
11
14
  const segments = field.split('.');
15
+ if (hasUnsupportedFieldPathSegment({
16
+ segments
17
+ })) {
18
+ throw new APIError('Invalid field path.', 400, null, true);
19
+ }
12
20
  let selectRef = select;
13
21
  segments.forEach((segment, i)=>{
14
22
  if (i === segments.length - 1) {
15
23
  selectRef[segment] = true;
16
24
  } else {
17
- if (!selectRef[segment]) {
18
- selectRef[segment] = {};
25
+ if (!Object.prototype.hasOwnProperty.call(selectRef, segment)) {
26
+ selectRef[segment] = createSelect();
19
27
  }
20
28
  selectRef = selectRef[segment];
21
29
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getSelect.ts"],"sourcesContent":["import type { SelectIncludeType } from 'payload'\n\n/**\n * Takes an input of array of string paths in dot notation and returns a select object.\n * Used for both export and import to build Payload's select query format.\n *\n * @example\n * getSelect(['id', 'title', 'group.value', 'createdAt', 'updatedAt'])\n * // Returns: { id: true, title: true, group: { value: true }, createdAt: true, updatedAt: true }\n */\nexport const getSelect = (fields: string[]): SelectIncludeType => {\n const select: SelectIncludeType = {}\n\n fields.forEach((field) => {\n const segments = field.split('.')\n let selectRef = select\n\n segments.forEach((segment, i) => {\n if (i === segments.length - 1) {\n selectRef[segment] = true\n } else {\n if (!selectRef[segment]) {\n selectRef[segment] = {}\n }\n selectRef = selectRef[segment] as SelectIncludeType\n }\n })\n })\n\n return select\n}\n"],"names":["getSelect","fields","select","forEach","field","segments","split","selectRef","segment","i","length"],"mappings":"AAEA;;;;;;;CAOC,GACD,OAAO,MAAMA,YAAY,CAACC;IACxB,MAAMC,SAA4B,CAAC;IAEnCD,OAAOE,OAAO,CAAC,CAACC;QACd,MAAMC,WAAWD,MAAME,KAAK,CAAC;QAC7B,IAAIC,YAAYL;QAEhBG,SAASF,OAAO,CAAC,CAACK,SAASC;YACzB,IAAIA,MAAMJ,SAASK,MAAM,GAAG,GAAG;gBAC7BH,SAAS,CAACC,QAAQ,GAAG;YACvB,OAAO;gBACL,IAAI,CAACD,SAAS,CAACC,QAAQ,EAAE;oBACvBD,SAAS,CAACC,QAAQ,GAAG,CAAC;gBACxB;gBACAD,YAAYA,SAAS,CAACC,QAAQ;YAChC;QACF;IACF;IAEA,OAAON;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/getSelect.ts"],"sourcesContent":["import type { SelectIncludeType } from 'payload'\n\nimport { APIError } from 'payload'\nimport { hasUnsupportedFieldPathSegment } from 'payload/shared'\n\nconst createSelect = (): SelectIncludeType => Object.create(null) as SelectIncludeType\n\n/**\n * Takes an input of array of string paths in dot notation and returns a select object.\n * Used for both export and import to build Payload's select query format.\n *\n * @example\n * getSelect(['id', 'title', 'group.value', 'createdAt', 'updatedAt'])\n * // Returns: { id: true, title: true, group: { value: true }, createdAt: true, updatedAt: true }\n */\nexport const getSelect = (fields: string[]): SelectIncludeType => {\n const select = createSelect()\n\n fields.forEach((field) => {\n const segments = field.split('.')\n\n if (hasUnsupportedFieldPathSegment({ segments })) {\n throw new APIError('Invalid field path.', 400, null, true)\n }\n\n let selectRef = select\n\n segments.forEach((segment, i) => {\n if (i === segments.length - 1) {\n selectRef[segment] = true\n } else {\n if (!Object.prototype.hasOwnProperty.call(selectRef, segment)) {\n selectRef[segment] = createSelect()\n }\n selectRef = selectRef[segment] as SelectIncludeType\n }\n })\n })\n\n return select\n}\n"],"names":["APIError","hasUnsupportedFieldPathSegment","createSelect","Object","create","getSelect","fields","select","forEach","field","segments","split","selectRef","segment","i","length","prototype","hasOwnProperty","call"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,UAAS;AAClC,SAASC,8BAA8B,QAAQ,iBAAgB;AAE/D,MAAMC,eAAe,IAAyBC,OAAOC,MAAM,CAAC;AAE5D;;;;;;;CAOC,GACD,OAAO,MAAMC,YAAY,CAACC;IACxB,MAAMC,SAASL;IAEfI,OAAOE,OAAO,CAAC,CAACC;QACd,MAAMC,WAAWD,MAAME,KAAK,CAAC;QAE7B,IAAIV,+BAA+B;YAAES;QAAS,IAAI;YAChD,MAAM,IAAIV,SAAS,uBAAuB,KAAK,MAAM;QACvD;QAEA,IAAIY,YAAYL;QAEhBG,SAASF,OAAO,CAAC,CAACK,SAASC;YACzB,IAAIA,MAAMJ,SAASK,MAAM,GAAG,GAAG;gBAC7BH,SAAS,CAACC,QAAQ,GAAG;YACvB,OAAO;gBACL,IAAI,CAACV,OAAOa,SAAS,CAACC,cAAc,CAACC,IAAI,CAACN,WAAWC,UAAU;oBAC7DD,SAAS,CAACC,QAAQ,GAAGX;gBACvB;gBACAU,YAAYA,SAAS,CAACC,QAAQ;YAChC;QACF;IACF;IAEA,OAAON;AACT,EAAC"}
@@ -0,0 +1,12 @@
1
+ export declare const getSubmittedFormValues: ({ formData, omit, }: {
2
+ formData: Record<string, unknown>;
3
+ omit?: string[];
4
+ }) => Record<string, unknown>;
5
+ /** Tracks value changes, including nested custom fields, without depending on field state identity. */
6
+ export declare const getFormStateSignature: ({ fields, omit, }: {
7
+ fields: Record<string, {
8
+ value?: unknown;
9
+ } | undefined>;
10
+ omit?: string[];
11
+ }) => string;
12
+ //# sourceMappingURL=getSubmittedFormValues.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSubmittedFormValues.d.ts","sourceRoot":"","sources":["../../src/utilities/getSubmittedFormValues.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,sBAAsB,wBAGhC;IACD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAIzB,CAAA;AAED,uGAAuG;AACvG,eAAO,MAAM,qBAAqB,sBAG/B;IACD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,CAAC,CAAA;IACvD,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB,KAAG,MAQH,CAAA"}
@@ -0,0 +1,24 @@
1
+ /** Unsaved form values must not appear to come from a saved document. */ const serverOwnedFormKeys = new Set([
2
+ 'createdAt',
3
+ 'id',
4
+ 'updatedAt'
5
+ ]);
6
+ export const getSubmittedFormValues = ({ formData, omit = [] })=>{
7
+ const omitKeys = new Set([
8
+ ...omit,
9
+ ...serverOwnedFormKeys
10
+ ]);
11
+ return Object.fromEntries(Object.entries(formData).filter(([key])=>!omitKeys.has(key)));
12
+ };
13
+ /** Tracks value changes, including nested custom fields, without depending on field state identity. */ export const getFormStateSignature = ({ fields, omit = [] })=>{
14
+ const omitKeys = new Set([
15
+ ...omit,
16
+ ...serverOwnedFormKeys
17
+ ]);
18
+ return JSON.stringify(Object.entries(fields).filter(([path])=>!omitKeys.has(path)).map(([path, field])=>[
19
+ path,
20
+ field?.value
21
+ ]));
22
+ };
23
+
24
+ //# sourceMappingURL=getSubmittedFormValues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/getSubmittedFormValues.ts"],"sourcesContent":["/** Unsaved form values must not appear to come from a saved document. */\nconst serverOwnedFormKeys = new Set(['createdAt', 'id', 'updatedAt'])\n\nexport const getSubmittedFormValues = ({\n formData,\n omit = [],\n}: {\n formData: Record<string, unknown>\n omit?: string[]\n}): Record<string, unknown> => {\n const omitKeys = new Set([...omit, ...serverOwnedFormKeys])\n\n return Object.fromEntries(Object.entries(formData).filter(([key]) => !omitKeys.has(key)))\n}\n\n/** Tracks value changes, including nested custom fields, without depending on field state identity. */\nexport const getFormStateSignature = ({\n fields,\n omit = [],\n}: {\n fields: Record<string, { value?: unknown } | undefined>\n omit?: string[]\n}): string => {\n const omitKeys = new Set([...omit, ...serverOwnedFormKeys])\n\n return JSON.stringify(\n Object.entries(fields)\n .filter(([path]) => !omitKeys.has(path))\n .map(([path, field]) => [path, field?.value]),\n )\n}\n"],"names":["serverOwnedFormKeys","Set","getSubmittedFormValues","formData","omit","omitKeys","Object","fromEntries","entries","filter","key","has","getFormStateSignature","fields","JSON","stringify","path","map","field","value"],"mappings":"AAAA,uEAAuE,GACvE,MAAMA,sBAAsB,IAAIC,IAAI;IAAC;IAAa;IAAM;CAAY;AAEpE,OAAO,MAAMC,yBAAyB,CAAC,EACrCC,QAAQ,EACRC,OAAO,EAAE,EAIV;IACC,MAAMC,WAAW,IAAIJ,IAAI;WAAIG;WAASJ;KAAoB;IAE1D,OAAOM,OAAOC,WAAW,CAACD,OAAOE,OAAO,CAACL,UAAUM,MAAM,CAAC,CAAC,CAACC,IAAI,GAAK,CAACL,SAASM,GAAG,CAACD;AACrF,EAAC;AAED,qGAAqG,GACrG,OAAO,MAAME,wBAAwB,CAAC,EACpCC,MAAM,EACNT,OAAO,EAAE,EAIV;IACC,MAAMC,WAAW,IAAIJ,IAAI;WAAIG;WAASJ;KAAoB;IAE1D,OAAOc,KAAKC,SAAS,CACnBT,OAAOE,OAAO,CAACK,QACZJ,MAAM,CAAC,CAAC,CAACO,KAAK,GAAK,CAACX,SAASM,GAAG,CAACK,OACjCC,GAAG,CAAC,CAAC,CAACD,MAAME,MAAM,GAAK;YAACF;YAAME,OAAOC;SAAM;AAElD,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"isPlainObject.d.ts","sourceRoot":"","sources":["../../src/utilities/isPlainObject.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CACR,CAAA"}
1
+ {"version":3,"file":"isPlainObject.d.ts","sourceRoot":"","sources":["../../src/utilities/isPlainObject.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,UAAW,OAAO,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CACR,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"parseCSV.d.ts","sourceRoot":"","sources":["../../src/utilities/parseCSV.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,GAAU,eAAe,YAAY,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CA8D7F,CAAA"}
1
+ {"version":3,"file":"parseCSV.d.ts","sourceRoot":"","sources":["../../src/utilities/parseCSV.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,kBAAyB,YAAY,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CA8D7F,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"parseJSON.d.ts","sourceRoot":"","sources":["../../src/utilities/parseJSON.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,eAAe,aAAa,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAiB/E,CAAA"}
1
+ {"version":3,"file":"parseJSON.d.ts","sourceRoot":"","sources":["../../src/utilities/parseJSON.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,kBAAmB,aAAa,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAiB/E,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"polymorphicRel.d.ts","sourceRoot":"","sources":["../../src/utilities/polymorphicRel.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,MAAM,GAAG,MAAM,CAAA;CACjD,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,mBACkB,CAAA;AAE1E;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,GAAG,mBAAmB,KAAG,MAAM,GAAG,MAAM,GAAG,SAS9E,CAAA"}
1
+ {"version":3,"file":"polymorphicRel.d.ts","sourceRoot":"","sources":["../../src/utilities/polymorphicRel.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,MAAM,GAAG,MAAM,CAAA;CACjD,CAAA;AAED,eAAO,MAAM,qBAAqB,MAAO,OAAO,KAAG,CAAC,IAAI,mBACkB,CAAA;AAE1E;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,MAAO,mBAAmB,KAAG,MAAM,GAAG,MAAM,GAAG,SAS9E,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"processRichTextField.d.ts","sourceRoot":"","sources":["../../src/utilities/processRichTextField.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,OAAO,KAAG,OAoDrD,CAAA"}
1
+ {"version":3,"file":"processRichTextField.d.ts","sourceRoot":"","sources":["../../src/utilities/processRichTextField.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,oBAAoB,UAAW,OAAO,KAAG,OAoDrD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"removeDisabledFields.d.ts","sourceRoot":"","sources":["../../src/utilities/removeDisabledFields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,oBAAoB,GAC/B,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,WAAU,MAAM,EAAO,KACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CA8DxB,CAAA"}
1
+ {"version":3,"file":"removeDisabledFields.d.ts","sourceRoot":"","sources":["../../src/utilities/removeDisabledFields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,oBAAoB,QAC1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,aAClB,MAAM,EAAE,KACjB,MAAM,CAAC,MAAM,EAAE,OAAO,CA8DxB,CAAA"}
@@ -14,6 +14,7 @@
14
14
  * @param obj - The target object to mutate.
15
15
  * @param path - A dot-separated string path indicating where to assign the value.
16
16
  * @param value - The value to set at the specified path.
17
+ * @param source - The source object used to validate array boundaries.
17
18
  */
18
- export declare const setNestedValue: (obj: Record<string, unknown>, path: string, value: unknown) => void;
19
+ export declare const setNestedValue: (obj: Record<string, unknown>, path: string, value: unknown, source?: Record<string, unknown>) => void;
19
20
  //# sourceMappingURL=setNestedValue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setNestedValue.d.ts","sourceRoot":"","sources":["../../src/utilities/setNestedValue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,eAAO,MAAM,cAAc,GACzB,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,MAAM,MAAM,EACZ,OAAO,OAAO,KACb,IA8CF,CAAA"}
1
+ {"version":3,"file":"setNestedValue.d.ts","sourceRoot":"","sources":["../../src/utilities/setNestedValue.ts"],"names":[],"mappings":"AAoDA;;;;;;;;;;;;;;;;;GAiBG;AAEH,eAAO,MAAM,cAAc,QACpB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QACtB,MAAM,SACL,OAAO,WACL,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC/B,IAyCF,CAAA"}
@@ -1,3 +1,34 @@
1
+ import { APIError } from 'payload';
2
+ import { hasUnsupportedFieldPathSegment, setOwnProperty } from 'payload/shared';
3
+ const MAX_UNVERIFIED_SPARSE_ARRAY_GAP = 1;
4
+ const createObject = ()=>Object.create(null);
5
+ const isArrayIndex = (part)=>{
6
+ if (!/^(?:0|[1-9]\d*)$/.test(part)) {
7
+ return false;
8
+ }
9
+ const index = Number(part);
10
+ return Number.isSafeInteger(index) && index >= 0;
11
+ };
12
+ const getPathKey = (target, part, source)=>{
13
+ if (!Array.isArray(target) || !isArrayIndex(part)) {
14
+ return part;
15
+ }
16
+ const index = Number(part);
17
+ if (Array.isArray(source) && index >= source.length || !Array.isArray(source) && index > target.length + MAX_UNVERIFIED_SPARSE_ARRAY_GAP) {
18
+ throw new APIError('Invalid field path.', 400, null, true);
19
+ }
20
+ return index;
21
+ };
22
+ const getSourceValue = (source, part)=>{
23
+ if (source === null || typeof source !== 'object') {
24
+ return undefined;
25
+ }
26
+ const key = Array.isArray(source) && isArrayIndex(part) ? Number(part) : part;
27
+ if (!Object.hasOwn(source, key)) {
28
+ return undefined;
29
+ }
30
+ return source[key];
31
+ };
1
32
  /**
2
33
  * Sets a value deeply into a nested object or array, based on a dot-notation path.
3
34
  *
@@ -14,44 +45,44 @@
14
45
  * @param obj - The target object to mutate.
15
46
  * @param path - A dot-separated string path indicating where to assign the value.
16
47
  * @param value - The value to set at the specified path.
17
- */ export const setNestedValue = (obj, path, value)=>{
48
+ * @param source - The source object used to validate array boundaries.
49
+ */ export const setNestedValue = (obj, path, value, source)=>{
18
50
  const parts = path.split('.');
51
+ if (hasUnsupportedFieldPathSegment({
52
+ segments: parts
53
+ })) {
54
+ throw new APIError('Invalid field path.', 400, null, true);
55
+ }
56
+ const lastPart = parts.pop();
57
+ if (lastPart === undefined) {
58
+ return;
59
+ }
19
60
  let current = obj;
20
- for(let i = 0; i < parts.length; i++){
21
- const part = parts[i];
22
- const isLast = i === parts.length - 1;
23
- const isIndex = !Number.isNaN(Number(part));
24
- if (isIndex) {
25
- const index = Number(part);
26
- // Ensure the current target is an array
27
- if (!Array.isArray(current)) {
28
- current = [];
29
- }
30
- const currentArray = current;
31
- // Ensure the array slot is initialized
32
- if (!currentArray[index]) {
33
- currentArray[index] = {};
34
- }
35
- if (isLast) {
36
- currentArray[index] = value;
37
- } else {
38
- current = currentArray[index];
39
- }
40
- } else {
41
- const currentObj = current;
42
- // Ensure the object key exists
43
- if (isLast) {
44
- if (typeof part === 'string') {
45
- currentObj[part] = value;
46
- }
47
- } else {
48
- if (typeof currentObj[part] !== 'object' || currentObj[part] === null) {
49
- currentObj[part] = {};
50
- }
51
- current = currentObj[part];
52
- }
61
+ let sourceCurrent = source;
62
+ for (const [i, part] of parts.entries()){
63
+ const key = getPathKey(current, part, sourceCurrent);
64
+ const currentRecord = current;
65
+ const nextPart = parts[i + 1] ?? lastPart;
66
+ const nextSource = getSourceValue(sourceCurrent, part);
67
+ const hasOwnNextValue = Object.hasOwn(currentRecord, key);
68
+ const nextValue = hasOwnNextValue ? currentRecord[key] : undefined;
69
+ if (!hasOwnNextValue || typeof nextValue !== 'object' || nextValue === null) {
70
+ setOwnProperty({
71
+ key,
72
+ target: currentRecord,
73
+ value: isArrayIndex(nextPart) ? [] : createObject()
74
+ });
53
75
  }
76
+ current = currentRecord[key];
77
+ sourceCurrent = nextSource;
54
78
  }
79
+ const lastKey = getPathKey(current, lastPart, sourceCurrent);
80
+ const finalRecord = current;
81
+ setOwnProperty({
82
+ key: lastKey,
83
+ target: finalRecord,
84
+ value
85
+ });
55
86
  };
56
87
 
57
88
  //# sourceMappingURL=setNestedValue.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/setNestedValue.ts"],"sourcesContent":["/**\n * Sets a value deeply into a nested object or array, based on a dot-notation path.\n *\n * This function:\n * - Supports array indexing (e.g., \"array.0.field1\")\n * - Creates intermediate arrays/objects as needed\n * - Mutates the target object directly\n *\n * @example\n * const obj = {}\n * setNestedValue(obj, 'group.array.0.field1', 'hello')\n * // Result: { group: { array: [ { field1: 'hello' } ] } }\n *\n * @param obj - The target object to mutate.\n * @param path - A dot-separated string path indicating where to assign the value.\n * @param value - The value to set at the specified path.\n */\n\nexport const setNestedValue = (\n obj: Record<string, unknown>,\n path: string,\n value: unknown,\n): void => {\n const parts = path.split('.')\n let current: unknown = obj\n\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i]\n const isLast = i === parts.length - 1\n const isIndex = !Number.isNaN(Number(part))\n\n if (isIndex) {\n const index = Number(part)\n\n // Ensure the current target is an array\n if (!Array.isArray(current)) {\n current = []\n }\n\n const currentArray = current as unknown[]\n\n // Ensure the array slot is initialized\n if (!currentArray[index]) {\n currentArray[index] = {}\n }\n\n if (isLast) {\n currentArray[index] = value\n } else {\n current = currentArray[index]\n }\n } else {\n const currentObj = current as Record<string, unknown>\n\n // Ensure the object key exists\n if (isLast) {\n if (typeof part === 'string') {\n currentObj[part] = value\n }\n } else {\n if (typeof currentObj[part as string] !== 'object' || currentObj[part as string] === null) {\n currentObj[part as string] = {}\n }\n\n current = currentObj[part as string]\n }\n }\n }\n}\n"],"names":["setNestedValue","obj","path","value","parts","split","current","i","length","part","isLast","isIndex","Number","isNaN","index","Array","isArray","currentArray","currentObj"],"mappings":"AAAA;;;;;;;;;;;;;;;;CAgBC,GAED,OAAO,MAAMA,iBAAiB,CAC5BC,KACAC,MACAC;IAEA,MAAMC,QAAQF,KAAKG,KAAK,CAAC;IACzB,IAAIC,UAAmBL;IAEvB,IAAK,IAAIM,IAAI,GAAGA,IAAIH,MAAMI,MAAM,EAAED,IAAK;QACrC,MAAME,OAAOL,KAAK,CAACG,EAAE;QACrB,MAAMG,SAASH,MAAMH,MAAMI,MAAM,GAAG;QACpC,MAAMG,UAAU,CAACC,OAAOC,KAAK,CAACD,OAAOH;QAErC,IAAIE,SAAS;YACX,MAAMG,QAAQF,OAAOH;YAErB,wCAAwC;YACxC,IAAI,CAACM,MAAMC,OAAO,CAACV,UAAU;gBAC3BA,UAAU,EAAE;YACd;YAEA,MAAMW,eAAeX;YAErB,uCAAuC;YACvC,IAAI,CAACW,YAAY,CAACH,MAAM,EAAE;gBACxBG,YAAY,CAACH,MAAM,GAAG,CAAC;YACzB;YAEA,IAAIJ,QAAQ;gBACVO,YAAY,CAACH,MAAM,GAAGX;YACxB,OAAO;gBACLG,UAAUW,YAAY,CAACH,MAAM;YAC/B;QACF,OAAO;YACL,MAAMI,aAAaZ;YAEnB,+BAA+B;YAC/B,IAAII,QAAQ;gBACV,IAAI,OAAOD,SAAS,UAAU;oBAC5BS,UAAU,CAACT,KAAK,GAAGN;gBACrB;YACF,OAAO;gBACL,IAAI,OAAOe,UAAU,CAACT,KAAe,KAAK,YAAYS,UAAU,CAACT,KAAe,KAAK,MAAM;oBACzFS,UAAU,CAACT,KAAe,GAAG,CAAC;gBAChC;gBAEAH,UAAUY,UAAU,CAACT,KAAe;YACtC;QACF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/setNestedValue.ts"],"sourcesContent":["import { APIError } from 'payload'\nimport { hasUnsupportedFieldPathSegment, setOwnProperty } from 'payload/shared'\n\nconst MAX_UNVERIFIED_SPARSE_ARRAY_GAP = 1\n\nconst createObject = (): Record<string, unknown> => Object.create(null) as Record<string, unknown>\n\nconst isArrayIndex = (part: string): boolean => {\n if (!/^(?:0|[1-9]\\d*)$/.test(part)) {\n return false\n }\n\n const index = Number(part)\n\n return Number.isSafeInteger(index) && index >= 0\n}\n\nconst getPathKey = (\n target: Record<string, unknown> | unknown[],\n part: string,\n source: unknown,\n): number | string => {\n if (!Array.isArray(target) || !isArrayIndex(part)) {\n return part\n }\n\n const index = Number(part)\n\n if (\n (Array.isArray(source) && index >= source.length) ||\n (!Array.isArray(source) && index > target.length + MAX_UNVERIFIED_SPARSE_ARRAY_GAP)\n ) {\n throw new APIError('Invalid field path.', 400, null, true)\n }\n\n return index\n}\n\nconst getSourceValue = (source: unknown, part: string): unknown => {\n if (source === null || typeof source !== 'object') {\n return undefined\n }\n\n const key = Array.isArray(source) && isArrayIndex(part) ? Number(part) : part\n\n if (!Object.hasOwn(source, key)) {\n return undefined\n }\n\n return (source as Record<number | string, unknown>)[key]\n}\n\n/**\n * Sets a value deeply into a nested object or array, based on a dot-notation path.\n *\n * This function:\n * - Supports array indexing (e.g., \"array.0.field1\")\n * - Creates intermediate arrays/objects as needed\n * - Mutates the target object directly\n *\n * @example\n * const obj = {}\n * setNestedValue(obj, 'group.array.0.field1', 'hello')\n * // Result: { group: { array: [ { field1: 'hello' } ] } }\n *\n * @param obj - The target object to mutate.\n * @param path - A dot-separated string path indicating where to assign the value.\n * @param value - The value to set at the specified path.\n * @param source - The source object used to validate array boundaries.\n */\n\nexport const setNestedValue = (\n obj: Record<string, unknown>,\n path: string,\n value: unknown,\n source?: Record<string, unknown>,\n): void => {\n const parts = path.split('.')\n\n if (hasUnsupportedFieldPathSegment({ segments: parts })) {\n throw new APIError('Invalid field path.', 400, null, true)\n }\n\n const lastPart = parts.pop()\n\n if (lastPart === undefined) {\n return\n }\n\n let current: Record<string, unknown> | unknown[] = obj\n let sourceCurrent: unknown = source\n\n for (const [i, part] of parts.entries()) {\n const key = getPathKey(current, part, sourceCurrent)\n const currentRecord = current as Record<number | string, unknown>\n const nextPart = parts[i + 1] ?? lastPart\n const nextSource = getSourceValue(sourceCurrent, part)\n\n const hasOwnNextValue = Object.hasOwn(currentRecord, key)\n const nextValue = hasOwnNextValue ? currentRecord[key] : undefined\n\n if (!hasOwnNextValue || typeof nextValue !== 'object' || nextValue === null) {\n setOwnProperty({\n key,\n target: currentRecord,\n value: isArrayIndex(nextPart) ? [] : createObject(),\n })\n }\n\n current = currentRecord[key] as Record<string, unknown> | unknown[]\n sourceCurrent = nextSource\n }\n\n const lastKey = getPathKey(current, lastPart, sourceCurrent)\n const finalRecord = current as Record<number | string, unknown>\n\n setOwnProperty({ key: lastKey, target: finalRecord, value })\n}\n"],"names":["APIError","hasUnsupportedFieldPathSegment","setOwnProperty","MAX_UNVERIFIED_SPARSE_ARRAY_GAP","createObject","Object","create","isArrayIndex","part","test","index","Number","isSafeInteger","getPathKey","target","source","Array","isArray","length","getSourceValue","undefined","key","hasOwn","setNestedValue","obj","path","value","parts","split","segments","lastPart","pop","current","sourceCurrent","i","entries","currentRecord","nextPart","nextSource","hasOwnNextValue","nextValue","lastKey","finalRecord"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,UAAS;AAClC,SAASC,8BAA8B,EAAEC,cAAc,QAAQ,iBAAgB;AAE/E,MAAMC,kCAAkC;AAExC,MAAMC,eAAe,IAA+BC,OAAOC,MAAM,CAAC;AAElE,MAAMC,eAAe,CAACC;IACpB,IAAI,CAAC,mBAAmBC,IAAI,CAACD,OAAO;QAClC,OAAO;IACT;IAEA,MAAME,QAAQC,OAAOH;IAErB,OAAOG,OAAOC,aAAa,CAACF,UAAUA,SAAS;AACjD;AAEA,MAAMG,aAAa,CACjBC,QACAN,MACAO;IAEA,IAAI,CAACC,MAAMC,OAAO,CAACH,WAAW,CAACP,aAAaC,OAAO;QACjD,OAAOA;IACT;IAEA,MAAME,QAAQC,OAAOH;IAErB,IACE,AAACQ,MAAMC,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;gBACbmB;gBACAP,QAAQsB;gBACRV,OAAOnB,aAAa8B,YAAY,EAAE,GAAGjC;YACvC;QACF;QAEA4B,UAAUI,aAAa,CAACf,IAAI;QAC5BY,gBAAgBK;IAClB;IAEA,MAAMG,UAAU5B,WAAWmB,SAASF,UAAUG;IAC9C,MAAMS,cAAcV;IAEpB9B,eAAe;QAAEmB,KAAKoB;QAAS3B,QAAQ4B;QAAahB;IAAM;AAC5D,EAAC"}
@@ -1,6 +1,6 @@
1
1
  /** Remove a leading '-' from a sort value (e.g. "-title" -> "title") */
2
2
  export declare const stripSortDash: (v?: null | string) => string;
3
3
  /** Apply order to a base field (("title","desc") -> "-title") */
4
- export declare const applySortOrder: (field: string, order: "asc" | "desc") => string;
4
+ export declare const applySortOrder: (field: string, order: 'asc' | 'desc') => string;
5
5
  export declare const normalizeQueryParam: (v: unknown) => string | undefined;
6
6
  //# sourceMappingURL=sortHelpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sortHelpers.d.ts","sourceRoot":"","sources":["../../src/utilities/sortHelpers.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,eAAO,MAAM,aAAa,GAAI,IAAI,IAAI,GAAG,MAAM,KAAG,MAAwC,CAAA;AAE1F,iEAAiE;AACjE,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,EAAE,OAAO,KAAK,GAAG,MAAM,KAAG,MAC9B,CAAA;AAGxC,eAAO,MAAM,mBAAmB,GAAI,GAAG,OAAO,KAAG,MAAM,GAAG,SAQzD,CAAA"}
1
+ {"version":3,"file":"sortHelpers.d.ts","sourceRoot":"","sources":["../../src/utilities/sortHelpers.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,eAAO,MAAM,aAAa,OAAQ,IAAI,GAAG,MAAM,KAAG,MAAwC,CAAA;AAE1F,iEAAiE;AACjE,eAAO,MAAM,cAAc,UAAW,MAAM,SAAS,KAAK,GAAG,MAAM,KAAG,MAC9B,CAAA;AAGxC,eAAO,MAAM,mBAAmB,MAAO,OAAO,KAAG,MAAM,GAAG,SAQzD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"unflattenObject.d.ts","sourceRoot":"","sources":["../../src/utilities/unflattenObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAKvD,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,CAAA;IACvC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;IACvD,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAuCD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,GAAI,kDAM7B,aAAa,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAyUxC,CAAA"}
1
+ {"version":3,"file":"unflattenObject.d.ts","sourceRoot":"","sources":["../../src/utilities/unflattenObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAKvD,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,CAAA;IACvC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;IACvD,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAuCD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,qDAMzB,aAAa,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAyUxC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"unflattenPostProcess.d.ts","sourceRoot":"","sources":["../../src/utilities/unflattenPostProcess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAuM7C;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAC9B,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,QAAQ,cAAc,EAAE,KACvB,IAMF,CAAA"}
1
+ {"version":3,"file":"unflattenPostProcess.d.ts","sourceRoot":"","sources":["../../src/utilities/unflattenPostProcess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAuM7C;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,QACzB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,UACpB,cAAc,EAAE,KACvB,IAMF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"validateLimitValue.d.ts","sourceRoot":"","sources":["../../src/utilities/validateLimitValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAEzD,eAAO,MAAM,kBAAkB,GAC7B,OAAO,IAAI,GAAG,MAAM,GAAG,SAAS,EAChC,GAAG,SAAS,KACX,MAAM,GAAG,SAMX,CAAA"}
1
+ {"version":3,"file":"validateLimitValue.d.ts","sourceRoot":"","sources":["../../src/utilities/validateLimitValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAEzD,eAAO,MAAM,kBAAkB,UACtB,IAAI,GAAG,MAAM,GAAG,SAAS,KAC7B,SAAS,KACX,MAAM,GAAG,SAMX,CAAA"}
package/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2018-2024 Payload CMS, Inc. <info@payloadcms.com>
3
+ Copyright (c) 2018-2026 Payload CMS, LLC <info@payloadcms.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the