@payloadcms/db-mongodb 3.0.0-canary.ff8c8fd → 3.0.1-canary.34c6cc0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. package/dist/connect.d.ts.map +1 -1
  2. package/dist/connect.js +12 -3
  3. package/dist/connect.js.map +1 -1
  4. package/dist/count.d.ts.map +1 -1
  5. package/dist/count.js +8 -1
  6. package/dist/count.js.map +1 -1
  7. package/dist/countGlobalVersions.d.ts +3 -0
  8. package/dist/countGlobalVersions.d.ts.map +1 -0
  9. package/dist/countGlobalVersions.js +40 -0
  10. package/dist/countGlobalVersions.js.map +1 -0
  11. package/dist/countVersions.d.ts +3 -0
  12. package/dist/countVersions.d.ts.map +1 -0
  13. package/dist/countVersions.js +40 -0
  14. package/dist/countVersions.js.map +1 -0
  15. package/dist/create.d.ts.map +1 -1
  16. package/dist/create.js +10 -1
  17. package/dist/create.js.map +1 -1
  18. package/dist/createGlobal.d.ts.map +1 -1
  19. package/dist/createGlobal.js +10 -5
  20. package/dist/createGlobal.js.map +1 -1
  21. package/dist/createGlobalVersion.d.ts +1 -1
  22. package/dist/createGlobalVersion.d.ts.map +1 -1
  23. package/dist/createGlobalVersion.js +13 -4
  24. package/dist/createGlobalVersion.js.map +1 -1
  25. package/dist/createMigration.d.ts.map +1 -1
  26. package/dist/createMigration.js +8 -6
  27. package/dist/createMigration.js.map +1 -1
  28. package/dist/createVersion.d.ts +1 -1
  29. package/dist/createVersion.d.ts.map +1 -1
  30. package/dist/createVersion.js +31 -9
  31. package/dist/createVersion.js.map +1 -1
  32. package/dist/deleteOne.d.ts.map +1 -1
  33. package/dist/deleteOne.js +11 -3
  34. package/dist/deleteOne.js.map +1 -1
  35. package/dist/exports/migration-utils.d.ts +3 -0
  36. package/dist/exports/migration-utils.d.ts.map +1 -0
  37. package/dist/exports/migration-utils.js +4 -0
  38. package/dist/exports/migration-utils.js.map +1 -0
  39. package/dist/find.d.ts.map +1 -1
  40. package/dist/find.js +27 -4
  41. package/dist/find.js.map +1 -1
  42. package/dist/findGlobal.d.ts.map +1 -1
  43. package/dist/findGlobal.js +9 -3
  44. package/dist/findGlobal.js.map +1 -1
  45. package/dist/findGlobalVersions.d.ts.map +1 -1
  46. package/dist/findGlobalVersions.js +9 -4
  47. package/dist/findGlobalVersions.js.map +1 -1
  48. package/dist/findOne.d.ts.map +1 -1
  49. package/dist/findOne.js +27 -3
  50. package/dist/findOne.js.map +1 -1
  51. package/dist/findVersions.d.ts.map +1 -1
  52. package/dist/findVersions.js +9 -4
  53. package/dist/findVersions.js.map +1 -1
  54. package/dist/index.d.ts +23 -4
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +16 -7
  57. package/dist/index.js.map +1 -1
  58. package/dist/init.d.ts.map +1 -1
  59. package/dist/init.js +20 -18
  60. package/dist/init.js.map +1 -1
  61. package/dist/models/buildCollectionSchema.d.ts +2 -3
  62. package/dist/models/buildCollectionSchema.d.ts.map +1 -1
  63. package/dist/models/buildCollectionSchema.js +10 -7
  64. package/dist/models/buildCollectionSchema.js.map +1 -1
  65. package/dist/models/buildGlobalModel.d.ts +2 -2
  66. package/dist/models/buildGlobalModel.d.ts.map +1 -1
  67. package/dist/models/buildGlobalModel.js +6 -6
  68. package/dist/models/buildGlobalModel.js.map +1 -1
  69. package/dist/models/buildSchema.d.ts +2 -3
  70. package/dist/models/buildSchema.d.ts.map +1 -1
  71. package/dist/models/buildSchema.js +108 -66
  72. package/dist/models/buildSchema.js.map +1 -1
  73. package/dist/predefinedMigrations/migrateRelationshipsV2_V3.d.ts +6 -0
  74. package/dist/predefinedMigrations/migrateRelationshipsV2_V3.d.ts.map +1 -0
  75. package/dist/predefinedMigrations/migrateRelationshipsV2_V3.js +141 -0
  76. package/dist/predefinedMigrations/migrateRelationshipsV2_V3.js.map +1 -0
  77. package/dist/predefinedMigrations/migrateVersionsV1_V2.d.ts +5 -0
  78. package/dist/predefinedMigrations/migrateVersionsV1_V2.d.ts.map +1 -0
  79. package/dist/predefinedMigrations/migrateVersionsV1_V2.js +107 -0
  80. package/dist/predefinedMigrations/migrateVersionsV1_V2.js.map +1 -0
  81. package/dist/predefinedMigrations/relationships-v2-v3.d.ts +4 -0
  82. package/dist/predefinedMigrations/relationships-v2-v3.d.ts.map +1 -0
  83. package/dist/predefinedMigrations/relationships-v2-v3.js +9 -0
  84. package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -0
  85. package/dist/predefinedMigrations/versions-v1-v2.d.ts +4 -0
  86. package/dist/predefinedMigrations/versions-v1-v2.d.ts.map +1 -0
  87. package/dist/predefinedMigrations/versions-v1-v2.js +5 -95
  88. package/dist/predefinedMigrations/versions-v1-v2.js.map +1 -1
  89. package/dist/queries/buildQuery.d.ts +2 -2
  90. package/dist/queries/buildQuery.d.ts.map +1 -1
  91. package/dist/queries/buildQuery.js +1 -2
  92. package/dist/queries/buildQuery.js.map +1 -1
  93. package/dist/queries/buildSearchParams.d.ts.map +1 -1
  94. package/dist/queries/buildSearchParams.js +29 -18
  95. package/dist/queries/buildSearchParams.js.map +1 -1
  96. package/dist/queries/buildSortParam.d.ts +2 -2
  97. package/dist/queries/buildSortParam.d.ts.map +1 -1
  98. package/dist/queries/buildSortParam.js +26 -17
  99. package/dist/queries/buildSortParam.js.map +1 -1
  100. package/dist/queries/getLocalizedSortProperty.spec.js +1 -1
  101. package/dist/queries/getLocalizedSortProperty.spec.js.map +1 -1
  102. package/dist/queries/parseParams.d.ts.map +1 -1
  103. package/dist/queries/parseParams.js +7 -2
  104. package/dist/queries/parseParams.js.map +1 -1
  105. package/dist/queries/sanitizeQueryValue.d.ts +3 -2
  106. package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
  107. package/dist/queries/sanitizeQueryValue.js +263 -37
  108. package/dist/queries/sanitizeQueryValue.js.map +1 -1
  109. package/dist/queryDrafts.d.ts.map +1 -1
  110. package/dist/queryDrafts.js +29 -8
  111. package/dist/queryDrafts.js.map +1 -1
  112. package/dist/transactions/beginTransaction.d.ts.map +1 -1
  113. package/dist/transactions/beginTransaction.js +2 -0
  114. package/dist/transactions/beginTransaction.js.map +1 -1
  115. package/dist/transactions/commitTransaction.d.ts.map +1 -1
  116. package/dist/transactions/commitTransaction.js +3 -1
  117. package/dist/transactions/commitTransaction.js.map +1 -1
  118. package/dist/types.d.ts +7 -4
  119. package/dist/types.d.ts.map +1 -1
  120. package/dist/types.js.map +1 -1
  121. package/dist/updateGlobal.d.ts.map +1 -1
  122. package/dist/updateGlobal.js +18 -4
  123. package/dist/updateGlobal.js.map +1 -1
  124. package/dist/updateGlobalVersion.d.ts +2 -2
  125. package/dist/updateGlobalVersion.d.ts.map +1 -1
  126. package/dist/updateGlobalVersion.js +19 -4
  127. package/dist/updateGlobalVersion.js.map +1 -1
  128. package/dist/updateOne.d.ts.map +1 -1
  129. package/dist/updateOne.js +18 -4
  130. package/dist/updateOne.js.map +1 -1
  131. package/dist/updateVersion.d.ts +1 -1
  132. package/dist/updateVersion.d.ts.map +1 -1
  133. package/dist/updateVersion.js +18 -3
  134. package/dist/updateVersion.js.map +1 -1
  135. package/dist/upsert.d.ts +3 -0
  136. package/dist/upsert.d.ts.map +1 -0
  137. package/dist/upsert.js +15 -0
  138. package/dist/upsert.js.map +1 -0
  139. package/dist/utilities/buildJoinAggregation.d.ts +18 -0
  140. package/dist/utilities/buildJoinAggregation.d.ts.map +1 -0
  141. package/dist/utilities/buildJoinAggregation.js +159 -0
  142. package/dist/utilities/buildJoinAggregation.js.map +1 -0
  143. package/dist/utilities/buildProjectionFromSelect.d.ts +8 -0
  144. package/dist/utilities/buildProjectionFromSelect.d.ts.map +1 -0
  145. package/dist/utilities/buildProjectionFromSelect.js +171 -0
  146. package/dist/utilities/buildProjectionFromSelect.js.map +1 -0
  147. package/dist/utilities/getDBName.d.ts.map +1 -1
  148. package/dist/utilities/getDBName.js +3 -1
  149. package/dist/utilities/getDBName.js.map +1 -1
  150. package/dist/utilities/handleError.js +2 -2
  151. package/dist/utilities/handleError.js.map +1 -1
  152. package/dist/utilities/sanitizeInternalFields.d.ts +1 -2
  153. package/dist/utilities/sanitizeInternalFields.d.ts.map +1 -1
  154. package/dist/utilities/sanitizeInternalFields.js +1 -2
  155. package/dist/utilities/sanitizeInternalFields.js.map +1 -1
  156. package/dist/utilities/sanitizeRelationshipIDs.d.ts +9 -0
  157. package/dist/utilities/sanitizeRelationshipIDs.d.ts.map +1 -0
  158. package/dist/utilities/sanitizeRelationshipIDs.js +125 -0
  159. package/dist/utilities/sanitizeRelationshipIDs.js.map +1 -0
  160. package/dist/utilities/sanitizeRelationshipIDs.spec.js +408 -0
  161. package/dist/utilities/sanitizeRelationshipIDs.spec.js.map +1 -0
  162. package/dist/withSession.d.ts +1 -1
  163. package/dist/withSession.d.ts.map +1 -1
  164. package/dist/withSession.js +5 -3
  165. package/dist/withSession.js.map +1 -1
  166. package/license.md +22 -0
  167. package/package.json +24 -11
  168. package/dist/queries/mock.js +0 -2
  169. package/dist/queries/mock.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import mongoose from 'mongoose';
2
- import { fieldAffectsData, fieldIsLocalized, fieldIsPresentationalOnly, tabHasName } from 'payload/shared';
2
+ import { fieldAffectsData, fieldIsLocalized, fieldIsPresentationalOnly, fieldIsVirtual, tabHasName } from 'payload/shared';
3
3
  /**
4
4
  * get a field's defaultValue only if defined and not dynamic so that it can be set on the field schema
5
5
  * @param field
@@ -34,7 +34,7 @@ const localizeSchema = (entity, schema, localization)=>{
34
34
  }
35
35
  return schema;
36
36
  };
37
- const buildSchema = (config, configFields, buildSchemaOptions = {})=>{
37
+ export const buildSchema = (payload, configFields, buildSchemaOptions = {})=>{
38
38
  const { allowIDField, options } = buildSchemaOptions;
39
39
  let fields = {};
40
40
  let schemaFields = configFields;
@@ -49,21 +49,24 @@ const buildSchema = (config, configFields, buildSchemaOptions = {})=>{
49
49
  }
50
50
  const schema = new mongoose.Schema(fields, options);
51
51
  schemaFields.forEach((field)=>{
52
+ if (fieldIsVirtual(field)) {
53
+ return;
54
+ }
52
55
  if (!fieldIsPresentationalOnly(field)) {
53
56
  const addFieldSchema = fieldToSchemaMap[field.type];
54
57
  if (addFieldSchema) {
55
- addFieldSchema(field, schema, config, buildSchemaOptions);
58
+ addFieldSchema(field, schema, payload, buildSchemaOptions);
56
59
  }
57
60
  }
58
61
  });
59
62
  return schema;
60
63
  };
61
64
  const fieldToSchemaMap = {
62
- array: (field, schema, config, buildSchemaOptions)=>{
65
+ array: (field, schema, payload, buildSchemaOptions)=>{
63
66
  const baseSchema = {
64
67
  ...formatBaseSchema(field, buildSchemaOptions),
65
68
  type: [
66
- buildSchema(config, field.fields, {
69
+ buildSchema(payload, field.fields, {
67
70
  allowIDField: true,
68
71
  disableUnique: buildSchemaOptions.disableUnique,
69
72
  draftsEnabled: buildSchemaOptions.draftsEnabled,
@@ -76,10 +79,10 @@ const fieldToSchemaMap = {
76
79
  ]
77
80
  };
78
81
  schema.add({
79
- [field.name]: localizeSchema(field, baseSchema, config.localization)
82
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
80
83
  });
81
84
  },
82
- blocks: (field, schema, config, buildSchemaOptions)=>{
85
+ blocks: (field, schema, payload, buildSchemaOptions)=>{
83
86
  const fieldSchema = {
84
87
  type: [
85
88
  new mongoose.Schema({}, {
@@ -89,7 +92,7 @@ const fieldToSchemaMap = {
89
92
  ]
90
93
  };
91
94
  schema.add({
92
- [field.name]: localizeSchema(field, fieldSchema, config.localization)
95
+ [field.name]: localizeSchema(field, fieldSchema, payload.config.localization)
93
96
  });
94
97
  field.blocks.forEach((blockItem)=>{
95
98
  const blockSchema = new mongoose.Schema({}, {
@@ -99,11 +102,11 @@ const fieldToSchemaMap = {
99
102
  blockItem.fields.forEach((blockField)=>{
100
103
  const addFieldSchema = fieldToSchemaMap[blockField.type];
101
104
  if (addFieldSchema) {
102
- addFieldSchema(blockField, blockSchema, config, buildSchemaOptions);
105
+ addFieldSchema(blockField, blockSchema, payload, buildSchemaOptions);
103
106
  }
104
107
  });
105
- if (field.localized && config.localization) {
106
- config.localization.localeCodes.forEach((localeCode)=>{
108
+ if (field.localized && payload.config.localization) {
109
+ payload.config.localization.localeCodes.forEach((localeCode)=>{
107
110
  // @ts-expect-error Possible incorrect typing in mongoose types, this works
108
111
  schema.path(`${field.name}.${localeCode}`).discriminator(blockItem.slug, blockSchema);
109
112
  });
@@ -113,57 +116,60 @@ const fieldToSchemaMap = {
113
116
  }
114
117
  });
115
118
  },
116
- checkbox: (field, schema, config, buildSchemaOptions)=>{
119
+ checkbox: (field, schema, payload, buildSchemaOptions)=>{
117
120
  const baseSchema = {
118
121
  ...formatBaseSchema(field, buildSchemaOptions),
119
122
  type: Boolean
120
123
  };
121
124
  schema.add({
122
- [field.name]: localizeSchema(field, baseSchema, config.localization)
125
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
123
126
  });
124
127
  },
125
- code: (field, schema, config, buildSchemaOptions)=>{
128
+ code: (field, schema, payload, buildSchemaOptions)=>{
126
129
  const baseSchema = {
127
130
  ...formatBaseSchema(field, buildSchemaOptions),
128
131
  type: String
129
132
  };
130
133
  schema.add({
131
- [field.name]: localizeSchema(field, baseSchema, config.localization)
134
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
132
135
  });
133
136
  },
134
- collapsible: (field, schema, config, buildSchemaOptions)=>{
137
+ collapsible: (field, schema, payload, buildSchemaOptions)=>{
135
138
  field.fields.forEach((subField)=>{
139
+ if (fieldIsVirtual(subField)) {
140
+ return;
141
+ }
136
142
  const addFieldSchema = fieldToSchemaMap[subField.type];
137
143
  if (addFieldSchema) {
138
- addFieldSchema(subField, schema, config, buildSchemaOptions);
144
+ addFieldSchema(subField, schema, payload, buildSchemaOptions);
139
145
  }
140
146
  });
141
147
  },
142
- date: (field, schema, config, buildSchemaOptions)=>{
148
+ date: (field, schema, payload, buildSchemaOptions)=>{
143
149
  const baseSchema = {
144
150
  ...formatBaseSchema(field, buildSchemaOptions),
145
151
  type: Date
146
152
  };
147
153
  schema.add({
148
- [field.name]: localizeSchema(field, baseSchema, config.localization)
154
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
149
155
  });
150
156
  },
151
- email: (field, schema, config, buildSchemaOptions)=>{
157
+ email: (field, schema, payload, buildSchemaOptions)=>{
152
158
  const baseSchema = {
153
159
  ...formatBaseSchema(field, buildSchemaOptions),
154
160
  type: String
155
161
  };
156
162
  schema.add({
157
- [field.name]: localizeSchema(field, baseSchema, config.localization)
163
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
158
164
  });
159
165
  },
160
- group: (field, schema, config, buildSchemaOptions)=>{
166
+ group: (field, schema, payload, buildSchemaOptions)=>{
161
167
  const formattedBaseSchema = formatBaseSchema(field, buildSchemaOptions);
162
168
  // carry indexSortableFields through to versions if drafts enabled
163
169
  const indexSortableFields = buildSchemaOptions.indexSortableFields && field.name === 'version' && buildSchemaOptions.draftsEnabled;
164
170
  const baseSchema = {
165
171
  ...formattedBaseSchema,
166
- type: buildSchema(config, field.fields, {
172
+ type: buildSchema(payload, field.fields, {
167
173
  disableUnique: buildSchemaOptions.disableUnique,
168
174
  draftsEnabled: buildSchemaOptions.draftsEnabled,
169
175
  indexSortableFields,
@@ -175,19 +181,19 @@ const fieldToSchemaMap = {
175
181
  })
176
182
  };
177
183
  schema.add({
178
- [field.name]: localizeSchema(field, baseSchema, config.localization)
184
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
179
185
  });
180
186
  },
181
- json: (field, schema, config, buildSchemaOptions)=>{
187
+ json: (field, schema, payload, buildSchemaOptions)=>{
182
188
  const baseSchema = {
183
189
  ...formatBaseSchema(field, buildSchemaOptions),
184
190
  type: mongoose.Schema.Types.Mixed
185
191
  };
186
192
  schema.add({
187
- [field.name]: localizeSchema(field, baseSchema, config.localization)
193
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
188
194
  });
189
195
  },
190
- number: (field, schema, config, buildSchemaOptions)=>{
196
+ number: (field, schema, payload, buildSchemaOptions)=>{
191
197
  const baseSchema = {
192
198
  ...formatBaseSchema(field, buildSchemaOptions),
193
199
  type: field.hasMany ? [
@@ -195,16 +201,19 @@ const fieldToSchemaMap = {
195
201
  ] : Number
196
202
  };
197
203
  schema.add({
198
- [field.name]: localizeSchema(field, baseSchema, config.localization)
204
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
199
205
  });
200
206
  },
201
- point: (field, schema, config, buildSchemaOptions)=>{
207
+ point: (field, schema, payload, buildSchemaOptions)=>{
202
208
  const baseSchema = {
203
209
  type: {
204
210
  type: String,
205
211
  enum: [
206
212
  'Point'
207
- ]
213
+ ],
214
+ ...typeof field.defaultValue !== 'undefined' && {
215
+ default: 'Point'
216
+ }
208
217
  },
209
218
  coordinates: {
210
219
  type: [
@@ -218,7 +227,7 @@ const fieldToSchemaMap = {
218
227
  baseSchema.coordinates.sparse = true;
219
228
  }
220
229
  schema.add({
221
- [field.name]: localizeSchema(field, baseSchema, config.localization)
230
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
222
231
  });
223
232
  if (field.index === true || field.index === undefined) {
224
233
  const indexOptions = {};
@@ -226,8 +235,8 @@ const fieldToSchemaMap = {
226
235
  indexOptions.sparse = true;
227
236
  indexOptions.unique = true;
228
237
  }
229
- if (field.localized && config.localization) {
230
- config.localization.locales.forEach((locale)=>{
238
+ if (field.localized && payload.config.localization) {
239
+ payload.config.localization.locales.forEach((locale)=>{
231
240
  schema.index({
232
241
  [`${field.name}.${locale.code}`]: '2dsphere'
233
242
  }, indexOptions);
@@ -239,25 +248,28 @@ const fieldToSchemaMap = {
239
248
  }
240
249
  }
241
250
  },
242
- radio: (field, schema, config, buildSchemaOptions)=>{
251
+ radio: (field, schema, payload, buildSchemaOptions)=>{
243
252
  const baseSchema = {
244
253
  ...formatBaseSchema(field, buildSchemaOptions),
245
254
  type: String,
246
255
  enum: field.options.map((option)=>{
247
- if (typeof option === 'object') return option.value;
256
+ if (typeof option === 'object') {
257
+ return option.value;
258
+ }
248
259
  return option;
249
260
  })
250
261
  };
251
262
  schema.add({
252
- [field.name]: localizeSchema(field, baseSchema, config.localization)
263
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
253
264
  });
254
265
  },
255
- relationship: (field, schema, config, buildSchemaOptions)=>{
266
+ relationship: (field, schema, payload, buildSchemaOptions)=>{
256
267
  const hasManyRelations = Array.isArray(field.relationTo);
257
268
  let schemaToReturn = {};
258
- if (field.localized && config.localization) {
269
+ const valueType = getRelationshipValueType(field, payload);
270
+ if (field.localized && payload.config.localization) {
259
271
  schemaToReturn = {
260
- type: config.localization.localeCodes.reduce((locales, locale)=>{
272
+ type: payload.config.localization.localeCodes.reduce((locales, locale)=>{
261
273
  let localeSchema = {};
262
274
  if (hasManyRelations) {
263
275
  localeSchema = {
@@ -269,14 +281,14 @@ const fieldToSchemaMap = {
269
281
  enum: field.relationTo
270
282
  },
271
283
  value: {
272
- type: mongoose.Schema.Types.Mixed,
284
+ type: valueType,
273
285
  refPath: `${field.name}.${locale}.relationTo`
274
286
  }
275
287
  };
276
288
  } else {
277
289
  localeSchema = {
278
290
  ...formatBaseSchema(field, buildSchemaOptions),
279
- type: mongoose.Schema.Types.Mixed,
291
+ type: valueType,
280
292
  ref: field.relationTo
281
293
  };
282
294
  }
@@ -302,7 +314,7 @@ const fieldToSchemaMap = {
302
314
  enum: field.relationTo
303
315
  },
304
316
  value: {
305
- type: mongoose.Schema.Types.Mixed,
317
+ type: valueType,
306
318
  refPath: `${field.name}.relationTo`
307
319
  }
308
320
  };
@@ -317,7 +329,7 @@ const fieldToSchemaMap = {
317
329
  } else {
318
330
  schemaToReturn = {
319
331
  ...formatBaseSchema(field, buildSchemaOptions),
320
- type: mongoose.Schema.Types.Mixed,
332
+ type: valueType,
321
333
  ref: field.relationTo
322
334
  };
323
335
  if (field.hasMany) {
@@ -333,29 +345,34 @@ const fieldToSchemaMap = {
333
345
  [field.name]: schemaToReturn
334
346
  });
335
347
  },
336
- richText: (field, schema, config, buildSchemaOptions)=>{
348
+ richText: (field, schema, payload, buildSchemaOptions)=>{
337
349
  const baseSchema = {
338
350
  ...formatBaseSchema(field, buildSchemaOptions),
339
351
  type: mongoose.Schema.Types.Mixed
340
352
  };
341
353
  schema.add({
342
- [field.name]: localizeSchema(field, baseSchema, config.localization)
354
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
343
355
  });
344
356
  },
345
- row: (field, schema, config, buildSchemaOptions)=>{
357
+ row: (field, schema, payload, buildSchemaOptions)=>{
346
358
  field.fields.forEach((subField)=>{
359
+ if (fieldIsVirtual(subField)) {
360
+ return;
361
+ }
347
362
  const addFieldSchema = fieldToSchemaMap[subField.type];
348
363
  if (addFieldSchema) {
349
- addFieldSchema(subField, schema, config, buildSchemaOptions);
364
+ addFieldSchema(subField, schema, payload, buildSchemaOptions);
350
365
  }
351
366
  });
352
367
  },
353
- select: (field, schema, config, buildSchemaOptions)=>{
368
+ select: (field, schema, payload, buildSchemaOptions)=>{
354
369
  const baseSchema = {
355
370
  ...formatBaseSchema(field, buildSchemaOptions),
356
371
  type: String,
357
372
  enum: field.options.map((option)=>{
358
- if (typeof option === 'object') return option.value;
373
+ if (typeof option === 'object') {
374
+ return option.value;
375
+ }
359
376
  return option;
360
377
  })
361
378
  };
@@ -365,14 +382,17 @@ const fieldToSchemaMap = {
365
382
  schema.add({
366
383
  [field.name]: localizeSchema(field, field.hasMany ? [
367
384
  baseSchema
368
- ] : baseSchema, config.localization)
385
+ ] : baseSchema, payload.config.localization)
369
386
  });
370
387
  },
371
- tabs: (field, schema, config, buildSchemaOptions)=>{
388
+ tabs: (field, schema, payload, buildSchemaOptions)=>{
372
389
  field.tabs.forEach((tab)=>{
373
390
  if (tabHasName(tab)) {
391
+ if (fieldIsVirtual(tab)) {
392
+ return;
393
+ }
374
394
  const baseSchema = {
375
- type: buildSchema(config, tab.fields, {
395
+ type: buildSchema(payload, tab.fields, {
376
396
  disableUnique: buildSchemaOptions.disableUnique,
377
397
  draftsEnabled: buildSchemaOptions.draftsEnabled,
378
398
  options: {
@@ -383,19 +403,22 @@ const fieldToSchemaMap = {
383
403
  })
384
404
  };
385
405
  schema.add({
386
- [tab.name]: localizeSchema(tab, baseSchema, config.localization)
406
+ [tab.name]: localizeSchema(tab, baseSchema, payload.config.localization)
387
407
  });
388
408
  } else {
389
409
  tab.fields.forEach((subField)=>{
410
+ if (fieldIsVirtual(subField)) {
411
+ return;
412
+ }
390
413
  const addFieldSchema = fieldToSchemaMap[subField.type];
391
414
  if (addFieldSchema) {
392
- addFieldSchema(subField, schema, config, buildSchemaOptions);
415
+ addFieldSchema(subField, schema, payload, buildSchemaOptions);
393
416
  }
394
417
  });
395
418
  }
396
419
  });
397
420
  },
398
- text: (field, schema, config, buildSchemaOptions)=>{
421
+ text: (field, schema, payload, buildSchemaOptions)=>{
399
422
  const baseSchema = {
400
423
  ...formatBaseSchema(field, buildSchemaOptions),
401
424
  type: field.hasMany ? [
@@ -403,24 +426,25 @@ const fieldToSchemaMap = {
403
426
  ] : String
404
427
  };
405
428
  schema.add({
406
- [field.name]: localizeSchema(field, baseSchema, config.localization)
429
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
407
430
  });
408
431
  },
409
- textarea: (field, schema, config, buildSchemaOptions)=>{
432
+ textarea: (field, schema, payload, buildSchemaOptions)=>{
410
433
  const baseSchema = {
411
434
  ...formatBaseSchema(field, buildSchemaOptions),
412
435
  type: String
413
436
  };
414
437
  schema.add({
415
- [field.name]: localizeSchema(field, baseSchema, config.localization)
438
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
416
439
  });
417
440
  },
418
- upload: (field, schema, config, buildSchemaOptions)=>{
441
+ upload: (field, schema, payload, buildSchemaOptions)=>{
419
442
  const hasManyRelations = Array.isArray(field.relationTo);
420
443
  let schemaToReturn = {};
421
- if (field.localized && config.localization) {
444
+ const valueType = getRelationshipValueType(field, payload);
445
+ if (field.localized && payload.config.localization) {
422
446
  schemaToReturn = {
423
- type: config.localization.localeCodes.reduce((locales, locale)=>{
447
+ type: payload.config.localization.localeCodes.reduce((locales, locale)=>{
424
448
  let localeSchema = {};
425
449
  if (hasManyRelations) {
426
450
  localeSchema = {
@@ -432,14 +456,14 @@ const fieldToSchemaMap = {
432
456
  enum: field.relationTo
433
457
  },
434
458
  value: {
435
- type: mongoose.Schema.Types.Mixed,
459
+ type: valueType,
436
460
  refPath: `${field.name}.${locale}.relationTo`
437
461
  }
438
462
  };
439
463
  } else {
440
464
  localeSchema = {
441
465
  ...formatBaseSchema(field, buildSchemaOptions),
442
- type: mongoose.Schema.Types.Mixed,
466
+ type: valueType,
443
467
  ref: field.relationTo
444
468
  };
445
469
  }
@@ -465,7 +489,7 @@ const fieldToSchemaMap = {
465
489
  enum: field.relationTo
466
490
  },
467
491
  value: {
468
- type: mongoose.Schema.Types.Mixed,
492
+ type: valueType,
469
493
  refPath: `${field.name}.relationTo`
470
494
  }
471
495
  };
@@ -480,7 +504,7 @@ const fieldToSchemaMap = {
480
504
  } else {
481
505
  schemaToReturn = {
482
506
  ...formatBaseSchema(field, buildSchemaOptions),
483
- type: mongoose.Schema.Types.Mixed,
507
+ type: valueType,
484
508
  ref: field.relationTo
485
509
  };
486
510
  if (field.hasMany) {
@@ -497,6 +521,24 @@ const fieldToSchemaMap = {
497
521
  });
498
522
  }
499
523
  };
500
- export default buildSchema;
524
+ const getRelationshipValueType = (field, payload)=>{
525
+ if (typeof field.relationTo === 'string') {
526
+ const { customIDType } = payload.collections[field.relationTo];
527
+ if (!customIDType) {
528
+ return mongoose.Schema.Types.ObjectId;
529
+ }
530
+ if (customIDType === 'number') {
531
+ return mongoose.Schema.Types.Number;
532
+ }
533
+ return mongoose.Schema.Types.String;
534
+ }
535
+ // has custom id relationTo
536
+ if (field.relationTo.some((relationTo)=>{
537
+ return !!payload.collections[relationTo].customIDType;
538
+ })) {
539
+ return mongoose.Schema.Types.Mixed;
540
+ }
541
+ return mongoose.Schema.Types.ObjectId;
542
+ };
501
543
 
502
544
  //# sourceMappingURL=buildSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/models/buildSchema.ts"],"sourcesContent":["import type { IndexOptions, Schema, SchemaOptions, SchemaTypeOptions } from 'mongoose'\nimport type {\n ArrayField,\n Block,\n BlockField,\n CheckboxField,\n CodeField,\n CollapsibleField,\n DateField,\n EmailField,\n Field,\n FieldAffectingData,\n GroupField,\n JSONField,\n NonPresentationalField,\n NumberField,\n PointField,\n RadioField,\n RelationshipField,\n RichTextField,\n RowField,\n SanitizedConfig,\n SanitizedLocalizationConfig,\n SelectField,\n Tab,\n TabsField,\n TextField,\n TextareaField,\n UploadField,\n} from 'payload'\n\nimport mongoose from 'mongoose'\nimport {\n fieldAffectsData,\n fieldIsLocalized,\n fieldIsPresentationalOnly,\n tabHasName,\n} from 'payload/shared'\n\nexport type BuildSchemaOptions = {\n allowIDField?: boolean\n disableUnique?: boolean\n draftsEnabled?: boolean\n indexSortableFields?: boolean\n options?: SchemaOptions\n}\n\ntype FieldSchemaGenerator = (\n field: Field,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n) => void\n\n/**\n * get a field's defaultValue only if defined and not dynamic so that it can be set on the field schema\n * @param field\n */\nconst formatDefaultValue = (field: FieldAffectingData) =>\n typeof field.defaultValue !== 'undefined' && typeof field.defaultValue !== 'function'\n ? field.defaultValue\n : undefined\n\nconst formatBaseSchema = (field: FieldAffectingData, buildSchemaOptions: BuildSchemaOptions) => {\n const { disableUnique, draftsEnabled, indexSortableFields } = buildSchemaOptions\n const schema: SchemaTypeOptions<unknown> = {\n default: formatDefaultValue(field),\n index: field.index || (!disableUnique && field.unique) || indexSortableFields || false,\n required: false,\n unique: (!disableUnique && field.unique) || false,\n }\n\n if (\n schema.unique &&\n (field.localized ||\n draftsEnabled ||\n (fieldAffectsData(field) &&\n field.type !== 'group' &&\n field.type !== 'tab' &&\n field.required !== true))\n ) {\n schema.sparse = true\n }\n\n if (field.hidden) {\n schema.hidden = true\n }\n\n return schema\n}\n\nconst localizeSchema = (\n entity: NonPresentationalField | Tab,\n schema,\n localization: SanitizedLocalizationConfig | false,\n) => {\n if (fieldIsLocalized(entity) && localization && Array.isArray(localization.locales)) {\n return {\n type: localization.localeCodes.reduce(\n (localeSchema, locale) => ({\n ...localeSchema,\n [locale]: schema,\n }),\n {\n _id: false,\n },\n ),\n localized: true,\n }\n }\n return schema\n}\n\nconst buildSchema = (\n config: SanitizedConfig,\n configFields: Field[],\n buildSchemaOptions: BuildSchemaOptions = {},\n): Schema => {\n const { allowIDField, options } = buildSchemaOptions\n let fields = {}\n\n let schemaFields = configFields\n\n if (!allowIDField) {\n const idField = schemaFields.find((field) => fieldAffectsData(field) && field.name === 'id')\n if (idField) {\n fields = {\n _id: idField.type === 'number' ? Number : String,\n }\n schemaFields = schemaFields.filter(\n (field) => !(fieldAffectsData(field) && field.name === 'id'),\n )\n }\n }\n\n const schema = new mongoose.Schema(fields, options)\n\n schemaFields.forEach((field) => {\n if (!fieldIsPresentationalOnly(field)) {\n const addFieldSchema: FieldSchemaGenerator = fieldToSchemaMap[field.type]\n\n if (addFieldSchema) {\n addFieldSchema(field, schema, config, buildSchemaOptions)\n }\n }\n })\n\n return schema\n}\n\nconst fieldToSchemaMap: Record<string, FieldSchemaGenerator> = {\n array: (\n field: ArrayField,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n ) => {\n const baseSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: [\n buildSchema(config, field.fields, {\n allowIDField: true,\n disableUnique: buildSchemaOptions.disableUnique,\n draftsEnabled: buildSchemaOptions.draftsEnabled,\n options: {\n _id: false,\n id: false,\n minimize: false,\n },\n }),\n ],\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, config.localization),\n })\n },\n blocks: (\n field: BlockField,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const fieldSchema = {\n type: [new mongoose.Schema({}, { _id: false, discriminatorKey: 'blockType' })],\n }\n\n schema.add({\n [field.name]: localizeSchema(field, fieldSchema, config.localization),\n })\n\n field.blocks.forEach((blockItem: Block) => {\n const blockSchema = new mongoose.Schema({}, { _id: false, id: false })\n\n blockItem.fields.forEach((blockField) => {\n const addFieldSchema: FieldSchemaGenerator = fieldToSchemaMap[blockField.type]\n if (addFieldSchema) {\n addFieldSchema(blockField, blockSchema, config, buildSchemaOptions)\n }\n })\n\n if (field.localized && config.localization) {\n config.localization.localeCodes.forEach((localeCode) => {\n // @ts-expect-error Possible incorrect typing in mongoose types, this works\n schema.path(`${field.name}.${localeCode}`).discriminator(blockItem.slug, blockSchema)\n })\n } else {\n // @ts-expect-error Possible incorrect typing in mongoose types, this works\n schema.path(field.name).discriminator(blockItem.slug, blockSchema)\n }\n })\n },\n checkbox: (\n field: CheckboxField,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = { ...formatBaseSchema(field, buildSchemaOptions), type: Boolean }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, config.localization),\n })\n },\n code: (\n field: CodeField,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = { ...formatBaseSchema(field, buildSchemaOptions), type: String }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, config.localization),\n })\n },\n collapsible: (\n field: CollapsibleField,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n field.fields.forEach((subField: Field) => {\n const addFieldSchema: FieldSchemaGenerator = fieldToSchemaMap[subField.type]\n\n if (addFieldSchema) {\n addFieldSchema(subField, schema, config, buildSchemaOptions)\n }\n })\n },\n date: (\n field: DateField,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = { ...formatBaseSchema(field, buildSchemaOptions), type: Date }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, config.localization),\n })\n },\n email: (\n field: EmailField,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = { ...formatBaseSchema(field, buildSchemaOptions), type: String }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, config.localization),\n })\n },\n group: (\n field: GroupField,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const formattedBaseSchema = formatBaseSchema(field, buildSchemaOptions)\n\n // carry indexSortableFields through to versions if drafts enabled\n const indexSortableFields =\n buildSchemaOptions.indexSortableFields &&\n field.name === 'version' &&\n buildSchemaOptions.draftsEnabled\n\n const baseSchema = {\n ...formattedBaseSchema,\n type: buildSchema(config, field.fields, {\n disableUnique: buildSchemaOptions.disableUnique,\n draftsEnabled: buildSchemaOptions.draftsEnabled,\n indexSortableFields,\n options: {\n _id: false,\n id: false,\n minimize: false,\n },\n }),\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, config.localization),\n })\n },\n json: (\n field: JSONField,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: mongoose.Schema.Types.Mixed,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, config.localization),\n })\n },\n number: (\n field: NumberField,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: field.hasMany ? [Number] : Number,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, config.localization),\n })\n },\n point: (\n field: PointField,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema: SchemaTypeOptions<unknown> = {\n type: {\n type: String,\n enum: ['Point'],\n },\n coordinates: {\n type: [Number],\n default: formatDefaultValue(field),\n required: false,\n },\n }\n if (buildSchemaOptions.disableUnique && field.unique && field.localized) {\n baseSchema.coordinates.sparse = true\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, config.localization),\n })\n\n if (field.index === true || field.index === undefined) {\n const indexOptions: IndexOptions = {}\n if (!buildSchemaOptions.disableUnique && field.unique) {\n indexOptions.sparse = true\n indexOptions.unique = true\n }\n if (field.localized && config.localization) {\n config.localization.locales.forEach((locale) => {\n schema.index({ [`${field.name}.${locale.code}`]: '2dsphere' }, indexOptions)\n })\n } else {\n schema.index({ [field.name]: '2dsphere' }, indexOptions)\n }\n }\n },\n radio: (\n field: RadioField,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: String,\n enum: field.options.map((option) => {\n if (typeof option === 'object') return option.value\n return option\n }),\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, config.localization),\n })\n },\n relationship: (\n field: RelationshipField,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n ) => {\n const hasManyRelations = Array.isArray(field.relationTo)\n let schemaToReturn: { [key: string]: any } = {}\n\n if (field.localized && config.localization) {\n schemaToReturn = {\n type: config.localization.localeCodes.reduce((locales, locale) => {\n let localeSchema: { [key: string]: any } = {}\n\n if (hasManyRelations) {\n localeSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n _id: false,\n type: mongoose.Schema.Types.Mixed,\n relationTo: { type: String, enum: field.relationTo },\n value: {\n type: mongoose.Schema.Types.Mixed,\n refPath: `${field.name}.${locale}.relationTo`,\n },\n }\n } else {\n localeSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: mongoose.Schema.Types.Mixed,\n ref: field.relationTo,\n }\n }\n\n return {\n ...locales,\n [locale]: field.hasMany\n ? { type: [localeSchema], default: formatDefaultValue(field) }\n : localeSchema,\n }\n }, {}),\n localized: true,\n }\n } else if (hasManyRelations) {\n schemaToReturn = {\n ...formatBaseSchema(field, buildSchemaOptions),\n _id: false,\n type: mongoose.Schema.Types.Mixed,\n relationTo: { type: String, enum: field.relationTo },\n value: {\n type: mongoose.Schema.Types.Mixed,\n refPath: `${field.name}.relationTo`,\n },\n }\n\n if (field.hasMany) {\n schemaToReturn = {\n type: [schemaToReturn],\n default: formatDefaultValue(field),\n }\n }\n } else {\n schemaToReturn = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: mongoose.Schema.Types.Mixed,\n ref: field.relationTo,\n }\n\n if (field.hasMany) {\n schemaToReturn = {\n type: [schemaToReturn],\n default: formatDefaultValue(field),\n }\n }\n }\n\n schema.add({\n [field.name]: schemaToReturn,\n })\n },\n richText: (\n field: RichTextField,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: mongoose.Schema.Types.Mixed,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, config.localization),\n })\n },\n row: (\n field: RowField,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n field.fields.forEach((subField: Field) => {\n const addFieldSchema: FieldSchemaGenerator = fieldToSchemaMap[subField.type]\n\n if (addFieldSchema) {\n addFieldSchema(subField, schema, config, buildSchemaOptions)\n }\n })\n },\n select: (\n field: SelectField,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: String,\n enum: field.options.map((option) => {\n if (typeof option === 'object') return option.value\n return option\n }),\n }\n\n if (buildSchemaOptions.draftsEnabled || !field.required) {\n baseSchema.enum.push(null)\n }\n\n schema.add({\n [field.name]: localizeSchema(\n field,\n field.hasMany ? [baseSchema] : baseSchema,\n config.localization,\n ),\n })\n },\n tabs: (\n field: TabsField,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n field.tabs.forEach((tab) => {\n if (tabHasName(tab)) {\n const baseSchema = {\n type: buildSchema(config, tab.fields, {\n disableUnique: buildSchemaOptions.disableUnique,\n draftsEnabled: buildSchemaOptions.draftsEnabled,\n options: {\n _id: false,\n id: false,\n minimize: false,\n },\n }),\n }\n\n schema.add({\n [tab.name]: localizeSchema(tab, baseSchema, config.localization),\n })\n } else {\n tab.fields.forEach((subField: Field) => {\n const addFieldSchema: FieldSchemaGenerator = fieldToSchemaMap[subField.type]\n\n if (addFieldSchema) {\n addFieldSchema(subField, schema, config, buildSchemaOptions)\n }\n })\n }\n })\n },\n text: (\n field: TextField,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: field.hasMany ? [String] : String,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, config.localization),\n })\n },\n textarea: (\n field: TextareaField,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = { ...formatBaseSchema(field, buildSchemaOptions), type: String }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, config.localization),\n })\n },\n upload: (\n field: UploadField,\n schema: Schema,\n config: SanitizedConfig,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const hasManyRelations = Array.isArray(field.relationTo)\n let schemaToReturn: { [key: string]: any } = {}\n\n if (field.localized && config.localization) {\n schemaToReturn = {\n type: config.localization.localeCodes.reduce((locales, locale) => {\n let localeSchema: { [key: string]: any } = {}\n\n if (hasManyRelations) {\n localeSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n _id: false,\n type: mongoose.Schema.Types.Mixed,\n relationTo: { type: String, enum: field.relationTo },\n value: {\n type: mongoose.Schema.Types.Mixed,\n refPath: `${field.name}.${locale}.relationTo`,\n },\n }\n } else {\n localeSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: mongoose.Schema.Types.Mixed,\n ref: field.relationTo,\n }\n }\n\n return {\n ...locales,\n [locale]: field.hasMany\n ? { type: [localeSchema], default: formatDefaultValue(field) }\n : localeSchema,\n }\n }, {}),\n localized: true,\n }\n } else if (hasManyRelations) {\n schemaToReturn = {\n ...formatBaseSchema(field, buildSchemaOptions),\n _id: false,\n type: mongoose.Schema.Types.Mixed,\n relationTo: { type: String, enum: field.relationTo },\n value: {\n type: mongoose.Schema.Types.Mixed,\n refPath: `${field.name}.relationTo`,\n },\n }\n\n if (field.hasMany) {\n schemaToReturn = {\n type: [schemaToReturn],\n default: formatDefaultValue(field),\n }\n }\n } else {\n schemaToReturn = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: mongoose.Schema.Types.Mixed,\n ref: field.relationTo,\n }\n\n if (field.hasMany) {\n schemaToReturn = {\n type: [schemaToReturn],\n default: formatDefaultValue(field),\n }\n }\n }\n\n schema.add({\n [field.name]: schemaToReturn,\n })\n },\n}\n\nexport default buildSchema\n"],"names":["mongoose","fieldAffectsData","fieldIsLocalized","fieldIsPresentationalOnly","tabHasName","formatDefaultValue","field","defaultValue","undefined","formatBaseSchema","buildSchemaOptions","disableUnique","draftsEnabled","indexSortableFields","schema","default","index","unique","required","localized","type","sparse","hidden","localizeSchema","entity","localization","Array","isArray","locales","localeCodes","reduce","localeSchema","locale","_id","buildSchema","config","configFields","allowIDField","options","fields","schemaFields","idField","find","name","Number","String","filter","Schema","forEach","addFieldSchema","fieldToSchemaMap","array","baseSchema","id","minimize","add","blocks","fieldSchema","discriminatorKey","blockItem","blockSchema","blockField","localeCode","path","discriminator","slug","checkbox","Boolean","code","collapsible","subField","date","Date","email","group","formattedBaseSchema","json","Types","Mixed","number","hasMany","point","enum","coordinates","indexOptions","radio","map","option","value","relationship","hasManyRelations","relationTo","schemaToReturn","refPath","ref","richText","row","select","push","tabs","tab","text","textarea","upload"],"mappings":"AA+BA,OAAOA,cAAc,WAAU;AAC/B,SACEC,gBAAgB,EAChBC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;QACF,OAAO,IAAIuE,kBAAkB;YAC3BE,iBAAiB;gBACf,GAAGnF,iBAAiBH,OAAOI,mBAAmB;gBAC9CuB,KAAK;gBACLb,MAAMpB,SAAS+C,MAAM,CAAC8B,KAAK,CAACC,KAAK;gBACjCa,YAAY;oBAAEvE,MAAMyB;oBAAQqC,MAAM5E,MAAMqF,UAAU;gBAAC;gBACnDH,OAAO;oBACLpE,MAAMpB,SAAS+C,MAAM,CAAC8B,KAAK,CAACC,KAAK;oBACjCe,SAAS,CAAC,EAAEvF,MAAMqC,IAAI,CAAC,WAAW,CAAC;gBACrC;YACF;YAEA,IAAIrC,MAAM0E,OAAO,EAAE;gBACjBY,iBAAiB;oBACfxE,MAAM;wBAACwE;qBAAe;oBACtB7E,SAASV,mBAAmBC;gBAC9B;YACF;QACF,OAAO;YACLsF,iBAAiB;gBACf,GAAGnF,iBAAiBH,OAAOI,mBAAmB;gBAC9CU,MAAMpB,SAAS+C,MAAM,CAAC8B,KAAK,CAACC,KAAK;gBACjCgB,KAAKxF,MAAMqF,UAAU;YACvB;YAEA,IAAIrF,MAAM0E,OAAO,EAAE;gBACjBY,iBAAiB;oBACfxE,MAAM;wBAACwE;qBAAe;oBACtB7E,SAASV,mBAAmBC;gBAC9B;YACF;QACF;QAEAQ,OAAOyC,GAAG,CAAC;YACT,CAACjD,MAAMqC,IAAI,CAAC,EAAEiD;QAChB;IACF;AACF;AAEA,eAAe1D,YAAW"}
1
+ {"version":3,"sources":["../../src/models/buildSchema.ts"],"sourcesContent":["import type { IndexOptions, Schema, SchemaOptions, SchemaTypeOptions } from 'mongoose'\n\nimport mongoose from 'mongoose'\nimport {\n type ArrayField,\n type Block,\n type BlocksField,\n type CheckboxField,\n type CodeField,\n type CollapsibleField,\n type DateField,\n type EmailField,\n type Field,\n type FieldAffectingData,\n type GroupField,\n type JSONField,\n type NonPresentationalField,\n type NumberField,\n type Payload,\n type PointField,\n type RadioField,\n type RelationshipField,\n type RichTextField,\n type RowField,\n type SanitizedLocalizationConfig,\n type SelectField,\n type Tab,\n type TabsField,\n type TextareaField,\n type TextField,\n type UploadField,\n} from 'payload'\nimport {\n fieldAffectsData,\n fieldIsLocalized,\n fieldIsPresentationalOnly,\n fieldIsVirtual,\n tabHasName,\n} from 'payload/shared'\n\nexport type BuildSchemaOptions = {\n allowIDField?: boolean\n disableUnique?: boolean\n draftsEnabled?: boolean\n indexSortableFields?: boolean\n options?: SchemaOptions\n}\n\ntype FieldSchemaGenerator = (\n field: Field,\n schema: Schema,\n config: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n) => void\n\n/**\n * get a field's defaultValue only if defined and not dynamic so that it can be set on the field schema\n * @param field\n */\nconst formatDefaultValue = (field: FieldAffectingData) =>\n typeof field.defaultValue !== 'undefined' && typeof field.defaultValue !== 'function'\n ? field.defaultValue\n : undefined\n\nconst formatBaseSchema = (field: FieldAffectingData, buildSchemaOptions: BuildSchemaOptions) => {\n const { disableUnique, draftsEnabled, indexSortableFields } = buildSchemaOptions\n const schema: SchemaTypeOptions<unknown> = {\n default: formatDefaultValue(field),\n index: field.index || (!disableUnique && field.unique) || indexSortableFields || false,\n required: false,\n unique: (!disableUnique && field.unique) || false,\n }\n\n if (\n schema.unique &&\n (field.localized ||\n draftsEnabled ||\n (fieldAffectsData(field) &&\n field.type !== 'group' &&\n field.type !== 'tab' &&\n field.required !== true))\n ) {\n schema.sparse = true\n }\n\n if (field.hidden) {\n schema.hidden = true\n }\n\n return schema\n}\n\nconst localizeSchema = (\n entity: NonPresentationalField | Tab,\n schema,\n localization: false | SanitizedLocalizationConfig,\n) => {\n if (fieldIsLocalized(entity) && localization && Array.isArray(localization.locales)) {\n return {\n type: localization.localeCodes.reduce(\n (localeSchema, locale) => ({\n ...localeSchema,\n [locale]: schema,\n }),\n {\n _id: false,\n },\n ),\n localized: true,\n }\n }\n return schema\n}\n\nexport const buildSchema = (\n payload: Payload,\n configFields: Field[],\n buildSchemaOptions: BuildSchemaOptions = {},\n): Schema => {\n const { allowIDField, options } = buildSchemaOptions\n let fields = {}\n\n let schemaFields = configFields\n\n if (!allowIDField) {\n const idField = schemaFields.find((field) => fieldAffectsData(field) && field.name === 'id')\n if (idField) {\n fields = {\n _id: idField.type === 'number' ? Number : String,\n }\n schemaFields = schemaFields.filter(\n (field) => !(fieldAffectsData(field) && field.name === 'id'),\n )\n }\n }\n\n const schema = new mongoose.Schema(fields, options)\n\n schemaFields.forEach((field) => {\n if (fieldIsVirtual(field)) {\n return\n }\n\n if (!fieldIsPresentationalOnly(field)) {\n const addFieldSchema: FieldSchemaGenerator = fieldToSchemaMap[field.type]\n\n if (addFieldSchema) {\n addFieldSchema(field, schema, payload, buildSchemaOptions)\n }\n }\n })\n\n return schema\n}\n\nconst fieldToSchemaMap: Record<string, FieldSchemaGenerator> = {\n array: (\n field: ArrayField,\n schema: Schema,\n payload: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n ) => {\n const baseSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: [\n buildSchema(payload, field.fields, {\n allowIDField: true,\n disableUnique: buildSchemaOptions.disableUnique,\n draftsEnabled: buildSchemaOptions.draftsEnabled,\n options: {\n _id: false,\n id: false,\n minimize: false,\n },\n }),\n ],\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization),\n })\n },\n blocks: (\n field: BlocksField,\n schema: Schema,\n payload: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const fieldSchema = {\n type: [new mongoose.Schema({}, { _id: false, discriminatorKey: 'blockType' })],\n }\n\n schema.add({\n [field.name]: localizeSchema(field, fieldSchema, payload.config.localization),\n })\n\n field.blocks.forEach((blockItem: Block) => {\n const blockSchema = new mongoose.Schema({}, { _id: false, id: false })\n\n blockItem.fields.forEach((blockField) => {\n const addFieldSchema: FieldSchemaGenerator = fieldToSchemaMap[blockField.type]\n if (addFieldSchema) {\n addFieldSchema(blockField, blockSchema, payload, buildSchemaOptions)\n }\n })\n\n if (field.localized && payload.config.localization) {\n payload.config.localization.localeCodes.forEach((localeCode) => {\n // @ts-expect-error Possible incorrect typing in mongoose types, this works\n schema.path(`${field.name}.${localeCode}`).discriminator(blockItem.slug, blockSchema)\n })\n } else {\n // @ts-expect-error Possible incorrect typing in mongoose types, this works\n schema.path(field.name).discriminator(blockItem.slug, blockSchema)\n }\n })\n },\n checkbox: (\n field: CheckboxField,\n schema: Schema,\n payload: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = { ...formatBaseSchema(field, buildSchemaOptions), type: Boolean }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization),\n })\n },\n code: (\n field: CodeField,\n schema: Schema,\n payload: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = { ...formatBaseSchema(field, buildSchemaOptions), type: String }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization),\n })\n },\n collapsible: (\n field: CollapsibleField,\n schema: Schema,\n payload: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n field.fields.forEach((subField: Field) => {\n if (fieldIsVirtual(subField)) {\n return\n }\n\n const addFieldSchema: FieldSchemaGenerator = fieldToSchemaMap[subField.type]\n\n if (addFieldSchema) {\n addFieldSchema(subField, schema, payload, buildSchemaOptions)\n }\n })\n },\n date: (\n field: DateField,\n schema: Schema,\n payload: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = { ...formatBaseSchema(field, buildSchemaOptions), type: Date }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization),\n })\n },\n email: (\n field: EmailField,\n schema: Schema,\n payload: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = { ...formatBaseSchema(field, buildSchemaOptions), type: String }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization),\n })\n },\n group: (\n field: GroupField,\n schema: Schema,\n payload: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const formattedBaseSchema = formatBaseSchema(field, buildSchemaOptions)\n\n // carry indexSortableFields through to versions if drafts enabled\n const indexSortableFields =\n buildSchemaOptions.indexSortableFields &&\n field.name === 'version' &&\n buildSchemaOptions.draftsEnabled\n\n const baseSchema = {\n ...formattedBaseSchema,\n type: buildSchema(payload, field.fields, {\n disableUnique: buildSchemaOptions.disableUnique,\n draftsEnabled: buildSchemaOptions.draftsEnabled,\n indexSortableFields,\n options: {\n _id: false,\n id: false,\n minimize: false,\n },\n }),\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization),\n })\n },\n json: (\n field: JSONField,\n schema: Schema,\n payload: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: mongoose.Schema.Types.Mixed,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization),\n })\n },\n number: (\n field: NumberField,\n schema: Schema,\n payload: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: field.hasMany ? [Number] : Number,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization),\n })\n },\n point: (\n field: PointField,\n schema: Schema,\n payload: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema: SchemaTypeOptions<unknown> = {\n type: {\n type: String,\n enum: ['Point'],\n ...(typeof field.defaultValue !== 'undefined' && {\n default: 'Point',\n }),\n },\n coordinates: {\n type: [Number],\n default: formatDefaultValue(field),\n required: false,\n },\n }\n if (buildSchemaOptions.disableUnique && field.unique && field.localized) {\n baseSchema.coordinates.sparse = true\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization),\n })\n\n if (field.index === true || field.index === undefined) {\n const indexOptions: IndexOptions = {}\n if (!buildSchemaOptions.disableUnique && field.unique) {\n indexOptions.sparse = true\n indexOptions.unique = true\n }\n if (field.localized && payload.config.localization) {\n payload.config.localization.locales.forEach((locale) => {\n schema.index({ [`${field.name}.${locale.code}`]: '2dsphere' }, indexOptions)\n })\n } else {\n schema.index({ [field.name]: '2dsphere' }, indexOptions)\n }\n }\n },\n radio: (\n field: RadioField,\n schema: Schema,\n payload: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: String,\n enum: field.options.map((option) => {\n if (typeof option === 'object') {\n return option.value\n }\n return option\n }),\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization),\n })\n },\n relationship: (\n field: RelationshipField,\n schema: Schema,\n payload: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n ) => {\n const hasManyRelations = Array.isArray(field.relationTo)\n let schemaToReturn: { [key: string]: any } = {}\n\n const valueType = getRelationshipValueType(field, payload)\n\n if (field.localized && payload.config.localization) {\n schemaToReturn = {\n type: payload.config.localization.localeCodes.reduce((locales, locale) => {\n let localeSchema: { [key: string]: any } = {}\n\n if (hasManyRelations) {\n localeSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n _id: false,\n type: mongoose.Schema.Types.Mixed,\n relationTo: { type: String, enum: field.relationTo },\n value: {\n type: valueType,\n refPath: `${field.name}.${locale}.relationTo`,\n },\n }\n } else {\n localeSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: valueType,\n ref: field.relationTo,\n }\n }\n\n return {\n ...locales,\n [locale]: field.hasMany\n ? { type: [localeSchema], default: formatDefaultValue(field) }\n : localeSchema,\n }\n }, {}),\n localized: true,\n }\n } else if (hasManyRelations) {\n schemaToReturn = {\n ...formatBaseSchema(field, buildSchemaOptions),\n _id: false,\n type: mongoose.Schema.Types.Mixed,\n relationTo: { type: String, enum: field.relationTo },\n value: {\n type: valueType,\n refPath: `${field.name}.relationTo`,\n },\n }\n\n if (field.hasMany) {\n schemaToReturn = {\n type: [schemaToReturn],\n default: formatDefaultValue(field),\n }\n }\n } else {\n schemaToReturn = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: valueType,\n ref: field.relationTo,\n }\n\n if (field.hasMany) {\n schemaToReturn = {\n type: [schemaToReturn],\n default: formatDefaultValue(field),\n }\n }\n }\n\n schema.add({\n [field.name]: schemaToReturn,\n })\n },\n richText: (\n field: RichTextField,\n schema: Schema,\n payload: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: mongoose.Schema.Types.Mixed,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization),\n })\n },\n row: (\n field: RowField,\n schema: Schema,\n payload: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n field.fields.forEach((subField: Field) => {\n if (fieldIsVirtual(subField)) {\n return\n }\n\n const addFieldSchema: FieldSchemaGenerator = fieldToSchemaMap[subField.type]\n\n if (addFieldSchema) {\n addFieldSchema(subField, schema, payload, buildSchemaOptions)\n }\n })\n },\n select: (\n field: SelectField,\n schema: Schema,\n payload: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: String,\n enum: field.options.map((option) => {\n if (typeof option === 'object') {\n return option.value\n }\n return option\n }),\n }\n\n if (buildSchemaOptions.draftsEnabled || !field.required) {\n baseSchema.enum.push(null)\n }\n\n schema.add({\n [field.name]: localizeSchema(\n field,\n field.hasMany ? [baseSchema] : baseSchema,\n payload.config.localization,\n ),\n })\n },\n tabs: (\n field: TabsField,\n schema: Schema,\n payload: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n field.tabs.forEach((tab) => {\n if (tabHasName(tab)) {\n if (fieldIsVirtual(tab)) {\n return\n }\n const baseSchema = {\n type: buildSchema(payload, tab.fields, {\n disableUnique: buildSchemaOptions.disableUnique,\n draftsEnabled: buildSchemaOptions.draftsEnabled,\n options: {\n _id: false,\n id: false,\n minimize: false,\n },\n }),\n }\n\n schema.add({\n [tab.name]: localizeSchema(tab, baseSchema, payload.config.localization),\n })\n } else {\n tab.fields.forEach((subField: Field) => {\n if (fieldIsVirtual(subField)) {\n return\n }\n const addFieldSchema: FieldSchemaGenerator = fieldToSchemaMap[subField.type]\n\n if (addFieldSchema) {\n addFieldSchema(subField, schema, payload, buildSchemaOptions)\n }\n })\n }\n })\n },\n text: (\n field: TextField,\n schema: Schema,\n payload: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: field.hasMany ? [String] : String,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization),\n })\n },\n textarea: (\n field: TextareaField,\n schema: Schema,\n payload: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const baseSchema = { ...formatBaseSchema(field, buildSchemaOptions), type: String }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization),\n })\n },\n upload: (\n field: UploadField,\n schema: Schema,\n payload: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n ): void => {\n const hasManyRelations = Array.isArray(field.relationTo)\n let schemaToReturn: { [key: string]: any } = {}\n\n const valueType = getRelationshipValueType(field, payload)\n\n if (field.localized && payload.config.localization) {\n schemaToReturn = {\n type: payload.config.localization.localeCodes.reduce((locales, locale) => {\n let localeSchema: { [key: string]: any } = {}\n\n if (hasManyRelations) {\n localeSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n _id: false,\n type: mongoose.Schema.Types.Mixed,\n relationTo: { type: String, enum: field.relationTo },\n value: {\n type: valueType,\n refPath: `${field.name}.${locale}.relationTo`,\n },\n }\n } else {\n localeSchema = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: valueType,\n ref: field.relationTo,\n }\n }\n\n return {\n ...locales,\n [locale]: field.hasMany\n ? { type: [localeSchema], default: formatDefaultValue(field) }\n : localeSchema,\n }\n }, {}),\n localized: true,\n }\n } else if (hasManyRelations) {\n schemaToReturn = {\n ...formatBaseSchema(field, buildSchemaOptions),\n _id: false,\n type: mongoose.Schema.Types.Mixed,\n relationTo: { type: String, enum: field.relationTo },\n value: {\n type: valueType,\n refPath: `${field.name}.relationTo`,\n },\n }\n\n if (field.hasMany) {\n schemaToReturn = {\n type: [schemaToReturn],\n default: formatDefaultValue(field),\n }\n }\n } else {\n schemaToReturn = {\n ...formatBaseSchema(field, buildSchemaOptions),\n type: valueType,\n ref: field.relationTo,\n }\n\n if (field.hasMany) {\n schemaToReturn = {\n type: [schemaToReturn],\n default: formatDefaultValue(field),\n }\n }\n }\n\n schema.add({\n [field.name]: schemaToReturn,\n })\n },\n}\n\nconst getRelationshipValueType = (field: RelationshipField | UploadField, payload: Payload) => {\n if (typeof field.relationTo === 'string') {\n const { customIDType } = payload.collections[field.relationTo]\n\n if (!customIDType) {\n return mongoose.Schema.Types.ObjectId\n }\n\n if (customIDType === 'number') {\n return mongoose.Schema.Types.Number\n }\n\n return mongoose.Schema.Types.String\n }\n\n // has custom id relationTo\n if (\n field.relationTo.some((relationTo) => {\n return !!payload.collections[relationTo].customIDType\n })\n ) {\n return mongoose.Schema.Types.Mixed\n }\n\n return mongoose.Schema.Types.ObjectId\n}\n"],"names":["mongoose","fieldAffectsData","fieldIsLocalized","fieldIsPresentationalOnly","fieldIsVirtual","tabHasName","formatDefaultValue","field","defaultValue","undefined","formatBaseSchema","buildSchemaOptions","disableUnique","draftsEnabled","indexSortableFields","schema","default","index","unique","required","localized","type","sparse","hidden","localizeSchema","entity","localization","Array","isArray","locales","localeCodes","reduce","localeSchema","locale","_id","buildSchema","payload","configFields","allowIDField","options","fields","schemaFields","idField","find","name","Number","String","filter","Schema","forEach","addFieldSchema","fieldToSchemaMap","array","baseSchema","id","minimize","add","config","blocks","fieldSchema","discriminatorKey","blockItem","blockSchema","blockField","localeCode","path","discriminator","slug","checkbox","Boolean","code","collapsible","subField","date","Date","email","group","formattedBaseSchema","json","Types","Mixed","number","hasMany","point","enum","coordinates","indexOptions","radio","map","option","value","relationship","hasManyRelations","relationTo","schemaToReturn","valueType","getRelationshipValueType","refPath","ref","richText","row","select","push","tabs","tab","text","textarea","upload","customIDType","collections","ObjectId","some"],"mappings":"AAEA,OAAOA,cAAc,WAAU;AA8B/B,SACEC,gBAAgB,EAChBC,gBAAgB,EAChBC,yBAAyB,EACzBC,cAAc,EACdC,UAAU,QACL,iBAAgB;AAiBvB;;;CAGC,GACD,MAAMC,qBAAqB,CAACC,QAC1B,OAAOA,MAAMC,YAAY,KAAK,eAAe,OAAOD,MAAMC,YAAY,KAAK,aACvED,MAAMC,YAAY,GAClBC;AAEN,MAAMC,mBAAmB,CAACH,OAA2BI;IACnD,MAAM,EAAEC,aAAa,EAAEC,aAAa,EAAEC,mBAAmB,EAAE,GAAGH;IAC9D,MAAMI,SAAqC;QACzCC,SAASV,mBAAmBC;QAC5BU,OAAOV,MAAMU,KAAK,IAAK,CAACL,iBAAiBL,MAAMW,MAAM,IAAKJ,uBAAuB;QACjFK,UAAU;QACVD,QAAQ,AAAC,CAACN,iBAAiBL,MAAMW,MAAM,IAAK;IAC9C;IAEA,IACEH,OAAOG,MAAM,IACZX,CAAAA,MAAMa,SAAS,IACdP,iBACCZ,iBAAiBM,UAChBA,MAAMc,IAAI,KAAK,WACfd,MAAMc,IAAI,KAAK,SACfd,MAAMY,QAAQ,KAAK,IAAI,GAC3B;QACAJ,OAAOO,MAAM,GAAG;IAClB;IAEA,IAAIf,MAAMgB,MAAM,EAAE;QAChBR,OAAOQ,MAAM,GAAG;IAClB;IAEA,OAAOR;AACT;AAEA,MAAMS,iBAAiB,CACrBC,QACAV,QACAW;IAEA,IAAIxB,iBAAiBuB,WAAWC,gBAAgBC,MAAMC,OAAO,CAACF,aAAaG,OAAO,GAAG;QACnF,OAAO;YACLR,MAAMK,aAAaI,WAAW,CAACC,MAAM,CACnC,CAACC,cAAcC,SAAY,CAAA;oBACzB,GAAGD,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f,GAAGpF,iBAAiBH,OAAOI,mBAAmB;gBAC9CU,MAAM0E;gBACNG,KAAK3F,MAAMsF,UAAU;YACvB;YAEA,IAAItF,MAAM2E,OAAO,EAAE;gBACjBY,iBAAiB;oBACfzE,MAAM;wBAACyE;qBAAe;oBACtB9E,SAASV,mBAAmBC;gBAC9B;YACF;QACF;QAEAQ,OAAOyC,GAAG,CAAC;YACT,CAACjD,MAAMqC,IAAI,CAAC,EAAEkD;QAChB;IACF;AACF;AAEA,MAAME,2BAA2B,CAACzF,OAAwC6B;IACxE,IAAI,OAAO7B,MAAMsF,UAAU,KAAK,UAAU;QACxC,MAAM,EAAEe,YAAY,EAAE,GAAGxE,QAAQyE,WAAW,CAACtG,MAAMsF,UAAU,CAAC;QAE9D,IAAI,CAACe,cAAc;YACjB,OAAO5G,SAASgD,MAAM,CAAC+B,KAAK,CAAC+B,QAAQ;QACvC;QAEA,IAAIF,iBAAiB,UAAU;YAC7B,OAAO5G,SAASgD,MAAM,CAAC+B,KAAK,CAAClC,MAAM;QACrC;QAEA,OAAO7C,SAASgD,MAAM,CAAC+B,KAAK,CAACjC,MAAM;IACrC;IAEA,2BAA2B;IAC3B,IACEvC,MAAMsF,UAAU,CAACkB,IAAI,CAAC,CAAClB;QACrB,OAAO,CAAC,CAACzD,QAAQyE,WAAW,CAAChB,WAAW,CAACe,YAAY;IACvD,IACA;QACA,OAAO5G,SAASgD,MAAM,CAAC+B,KAAK,CAACC,KAAK;IACpC;IAEA,OAAOhF,SAASgD,MAAM,CAAC+B,KAAK,CAAC+B,QAAQ;AACvC"}
@@ -0,0 +1,6 @@
1
+ import type { PayloadRequest } from 'payload';
2
+ export declare function migrateRelationshipsV2_V3({ batchSize, req, }: {
3
+ batchSize: number;
4
+ req: PayloadRequest;
5
+ }): Promise<void>;
6
+ //# sourceMappingURL=migrateRelationshipsV2_V3.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrateRelationshipsV2_V3.d.ts","sourceRoot":"","sources":["../../src/predefinedMigrations/migrateRelationshipsV2_V3.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAS,cAAc,EAAmB,MAAM,SAAS,CAAA;AAmGrE,wBAAsB,yBAAyB,CAAC,EAC9C,SAAS,EACT,GAAG,GACJ,EAAE;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,cAAc,CAAA;CACpB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4EhB"}