@payloadcms/db-mongodb 3.0.0-canary.291e44c → 3.0.0-canary.2d0dd26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. package/dist/connect.d.ts.map +1 -1
  2. package/dist/connect.js +5 -0
  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 +3 -0
  17. package/dist/create.js.map +1 -1
  18. package/dist/createMigration.d.ts.map +1 -1
  19. package/dist/createMigration.js +6 -4
  20. package/dist/createMigration.js.map +1 -1
  21. package/dist/createVersion.js +2 -2
  22. package/dist/createVersion.js.map +1 -1
  23. package/dist/deleteOne.d.ts.map +1 -1
  24. package/dist/deleteOne.js +10 -2
  25. package/dist/deleteOne.js.map +1 -1
  26. package/dist/exports/migration-utils.d.ts +3 -0
  27. package/dist/exports/migration-utils.d.ts.map +1 -0
  28. package/dist/exports/migration-utils.js +4 -0
  29. package/dist/exports/migration-utils.js.map +1 -0
  30. package/dist/find.d.ts.map +1 -1
  31. package/dist/find.js +9 -3
  32. package/dist/find.js.map +1 -1
  33. package/dist/findGlobal.d.ts.map +1 -1
  34. package/dist/findGlobal.js +8 -2
  35. package/dist/findGlobal.js.map +1 -1
  36. package/dist/findGlobalVersions.d.ts.map +1 -1
  37. package/dist/findGlobalVersions.js +7 -2
  38. package/dist/findGlobalVersions.js.map +1 -1
  39. package/dist/findOne.d.ts.map +1 -1
  40. package/dist/findOne.js +9 -1
  41. package/dist/findOne.js.map +1 -1
  42. package/dist/findVersions.d.ts.map +1 -1
  43. package/dist/findVersions.js +8 -3
  44. package/dist/findVersions.js.map +1 -1
  45. package/dist/index.d.ts +18 -2
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +7 -2
  48. package/dist/index.js.map +1 -1
  49. package/dist/init.d.ts.map +1 -1
  50. package/dist/init.js +11 -12
  51. package/dist/init.js.map +1 -1
  52. package/dist/models/buildCollectionSchema.d.ts +2 -2
  53. package/dist/models/buildCollectionSchema.d.ts.map +1 -1
  54. package/dist/models/buildCollectionSchema.js +4 -4
  55. package/dist/models/buildCollectionSchema.js.map +1 -1
  56. package/dist/models/buildGlobalModel.d.ts +2 -2
  57. package/dist/models/buildGlobalModel.d.ts.map +1 -1
  58. package/dist/models/buildGlobalModel.js +4 -4
  59. package/dist/models/buildGlobalModel.js.map +1 -1
  60. package/dist/models/buildSchema.d.ts +2 -2
  61. package/dist/models/buildSchema.d.ts.map +1 -1
  62. package/dist/models/buildSchema.js +98 -62
  63. package/dist/models/buildSchema.js.map +1 -1
  64. package/dist/predefinedMigrations/migrateRelationshipsV2_V3.d.ts +6 -0
  65. package/dist/predefinedMigrations/migrateRelationshipsV2_V3.d.ts.map +1 -0
  66. package/dist/predefinedMigrations/migrateRelationshipsV2_V3.js +141 -0
  67. package/dist/predefinedMigrations/migrateRelationshipsV2_V3.js.map +1 -0
  68. package/dist/predefinedMigrations/migrateVersionsV1_V2.d.ts +5 -0
  69. package/dist/predefinedMigrations/migrateVersionsV1_V2.d.ts.map +1 -0
  70. package/dist/predefinedMigrations/migrateVersionsV1_V2.js +107 -0
  71. package/dist/predefinedMigrations/migrateVersionsV1_V2.js.map +1 -0
  72. package/dist/predefinedMigrations/relationships-v2-v3.d.ts +4 -0
  73. package/dist/predefinedMigrations/relationships-v2-v3.d.ts.map +1 -0
  74. package/dist/predefinedMigrations/relationships-v2-v3.js +9 -0
  75. package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -0
  76. package/dist/predefinedMigrations/versions-v1-v2.d.ts +4 -0
  77. package/dist/predefinedMigrations/versions-v1-v2.d.ts.map +1 -0
  78. package/dist/predefinedMigrations/versions-v1-v2.js +5 -95
  79. package/dist/predefinedMigrations/versions-v1-v2.js.map +1 -1
  80. package/dist/queries/buildSearchParams.d.ts.map +1 -1
  81. package/dist/queries/buildSearchParams.js +10 -7
  82. package/dist/queries/buildSearchParams.js.map +1 -1
  83. package/dist/queries/buildSortParam.d.ts +2 -2
  84. package/dist/queries/buildSortParam.d.ts.map +1 -1
  85. package/dist/queries/buildSortParam.js +26 -17
  86. package/dist/queries/buildSortParam.js.map +1 -1
  87. package/dist/queries/parseParams.d.ts.map +1 -1
  88. package/dist/queries/parseParams.js +4 -1
  89. package/dist/queries/parseParams.js.map +1 -1
  90. package/dist/queries/sanitizeQueryValue.d.ts +3 -2
  91. package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
  92. package/dist/queries/sanitizeQueryValue.js +157 -47
  93. package/dist/queries/sanitizeQueryValue.js.map +1 -1
  94. package/dist/queryDrafts.d.ts.map +1 -1
  95. package/dist/queryDrafts.js +28 -7
  96. package/dist/queryDrafts.js.map +1 -1
  97. package/dist/updateGlobal.d.ts.map +1 -1
  98. package/dist/updateGlobal.js +11 -3
  99. package/dist/updateGlobal.js.map +1 -1
  100. package/dist/updateGlobalVersion.d.ts +1 -1
  101. package/dist/updateGlobalVersion.d.ts.map +1 -1
  102. package/dist/updateGlobalVersion.js +11 -3
  103. package/dist/updateGlobalVersion.js.map +1 -1
  104. package/dist/updateOne.d.ts.map +1 -1
  105. package/dist/updateOne.js +10 -3
  106. package/dist/updateOne.js.map +1 -1
  107. package/dist/updateVersion.d.ts.map +1 -1
  108. package/dist/updateVersion.js +11 -3
  109. package/dist/updateVersion.js.map +1 -1
  110. package/dist/upsert.js +2 -1
  111. package/dist/upsert.js.map +1 -1
  112. package/dist/utilities/buildJoinAggregation.d.ts +4 -1
  113. package/dist/utilities/buildJoinAggregation.d.ts.map +1 -1
  114. package/dist/utilities/buildJoinAggregation.js +20 -9
  115. package/dist/utilities/buildJoinAggregation.js.map +1 -1
  116. package/dist/utilities/buildProjectionFromSelect.d.ts +8 -0
  117. package/dist/utilities/buildProjectionFromSelect.d.ts.map +1 -0
  118. package/dist/utilities/buildProjectionFromSelect.js +171 -0
  119. package/dist/utilities/buildProjectionFromSelect.js.map +1 -0
  120. package/dist/utilities/handleError.js +2 -2
  121. package/dist/utilities/handleError.js.map +1 -1
  122. package/dist/utilities/sanitizeRelationshipIDs.d.ts.map +1 -1
  123. package/dist/utilities/sanitizeRelationshipIDs.js +19 -5
  124. package/dist/utilities/sanitizeRelationshipIDs.js.map +1 -1
  125. package/dist/utilities/sanitizeRelationshipIDs.spec.js +408 -0
  126. package/dist/utilities/sanitizeRelationshipIDs.spec.js.map +1 -0
  127. package/license.md +22 -0
  128. package/package.json +21 -11
  129. package/dist/queries/mock.js +0 -2
  130. package/dist/queries/mock.js.map +0 -1
@@ -34,7 +34,7 @@ const localizeSchema = (entity, schema, localization)=>{
34
34
  }
35
35
  return schema;
36
36
  };
37
- export 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;
@@ -55,18 +55,18 @@ export const buildSchema = (config, configFields, buildSchemaOptions = {})=>{
55
55
  if (!fieldIsPresentationalOnly(field)) {
56
56
  const addFieldSchema = fieldToSchemaMap[field.type];
57
57
  if (addFieldSchema) {
58
- addFieldSchema(field, schema, config, buildSchemaOptions);
58
+ addFieldSchema(field, schema, payload, buildSchemaOptions);
59
59
  }
60
60
  }
61
61
  });
62
62
  return schema;
63
63
  };
64
64
  const fieldToSchemaMap = {
65
- array: (field, schema, config, buildSchemaOptions)=>{
65
+ array: (field, schema, payload, buildSchemaOptions)=>{
66
66
  const baseSchema = {
67
67
  ...formatBaseSchema(field, buildSchemaOptions),
68
68
  type: [
69
- buildSchema(config, field.fields, {
69
+ buildSchema(payload, field.fields, {
70
70
  allowIDField: true,
71
71
  disableUnique: buildSchemaOptions.disableUnique,
72
72
  draftsEnabled: buildSchemaOptions.draftsEnabled,
@@ -79,10 +79,10 @@ const fieldToSchemaMap = {
79
79
  ]
80
80
  };
81
81
  schema.add({
82
- [field.name]: localizeSchema(field, baseSchema, config.localization)
82
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
83
83
  });
84
84
  },
85
- blocks: (field, schema, config, buildSchemaOptions)=>{
85
+ blocks: (field, schema, payload, buildSchemaOptions)=>{
86
86
  const fieldSchema = {
87
87
  type: [
88
88
  new mongoose.Schema({}, {
@@ -92,7 +92,7 @@ const fieldToSchemaMap = {
92
92
  ]
93
93
  };
94
94
  schema.add({
95
- [field.name]: localizeSchema(field, fieldSchema, config.localization)
95
+ [field.name]: localizeSchema(field, fieldSchema, payload.config.localization)
96
96
  });
97
97
  field.blocks.forEach((blockItem)=>{
98
98
  const blockSchema = new mongoose.Schema({}, {
@@ -102,11 +102,11 @@ const fieldToSchemaMap = {
102
102
  blockItem.fields.forEach((blockField)=>{
103
103
  const addFieldSchema = fieldToSchemaMap[blockField.type];
104
104
  if (addFieldSchema) {
105
- addFieldSchema(blockField, blockSchema, config, buildSchemaOptions);
105
+ addFieldSchema(blockField, blockSchema, payload, buildSchemaOptions);
106
106
  }
107
107
  });
108
- if (field.localized && config.localization) {
109
- config.localization.localeCodes.forEach((localeCode)=>{
108
+ if (field.localized && payload.config.localization) {
109
+ payload.config.localization.localeCodes.forEach((localeCode)=>{
110
110
  // @ts-expect-error Possible incorrect typing in mongoose types, this works
111
111
  schema.path(`${field.name}.${localeCode}`).discriminator(blockItem.slug, blockSchema);
112
112
  });
@@ -116,57 +116,60 @@ const fieldToSchemaMap = {
116
116
  }
117
117
  });
118
118
  },
119
- checkbox: (field, schema, config, buildSchemaOptions)=>{
119
+ checkbox: (field, schema, payload, buildSchemaOptions)=>{
120
120
  const baseSchema = {
121
121
  ...formatBaseSchema(field, buildSchemaOptions),
122
122
  type: Boolean
123
123
  };
124
124
  schema.add({
125
- [field.name]: localizeSchema(field, baseSchema, config.localization)
125
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
126
126
  });
127
127
  },
128
- code: (field, schema, config, buildSchemaOptions)=>{
128
+ code: (field, schema, payload, buildSchemaOptions)=>{
129
129
  const baseSchema = {
130
130
  ...formatBaseSchema(field, buildSchemaOptions),
131
131
  type: String
132
132
  };
133
133
  schema.add({
134
- [field.name]: localizeSchema(field, baseSchema, config.localization)
134
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
135
135
  });
136
136
  },
137
- collapsible: (field, schema, config, buildSchemaOptions)=>{
137
+ collapsible: (field, schema, payload, buildSchemaOptions)=>{
138
138
  field.fields.forEach((subField)=>{
139
+ if (fieldIsVirtual(subField)) {
140
+ return;
141
+ }
139
142
  const addFieldSchema = fieldToSchemaMap[subField.type];
140
143
  if (addFieldSchema) {
141
- addFieldSchema(subField, schema, config, buildSchemaOptions);
144
+ addFieldSchema(subField, schema, payload, buildSchemaOptions);
142
145
  }
143
146
  });
144
147
  },
145
- date: (field, schema, config, buildSchemaOptions)=>{
148
+ date: (field, schema, payload, buildSchemaOptions)=>{
146
149
  const baseSchema = {
147
150
  ...formatBaseSchema(field, buildSchemaOptions),
148
151
  type: Date
149
152
  };
150
153
  schema.add({
151
- [field.name]: localizeSchema(field, baseSchema, config.localization)
154
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
152
155
  });
153
156
  },
154
- email: (field, schema, config, buildSchemaOptions)=>{
157
+ email: (field, schema, payload, buildSchemaOptions)=>{
155
158
  const baseSchema = {
156
159
  ...formatBaseSchema(field, buildSchemaOptions),
157
160
  type: String
158
161
  };
159
162
  schema.add({
160
- [field.name]: localizeSchema(field, baseSchema, config.localization)
163
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
161
164
  });
162
165
  },
163
- group: (field, schema, config, buildSchemaOptions)=>{
166
+ group: (field, schema, payload, buildSchemaOptions)=>{
164
167
  const formattedBaseSchema = formatBaseSchema(field, buildSchemaOptions);
165
168
  // carry indexSortableFields through to versions if drafts enabled
166
169
  const indexSortableFields = buildSchemaOptions.indexSortableFields && field.name === 'version' && buildSchemaOptions.draftsEnabled;
167
170
  const baseSchema = {
168
171
  ...formattedBaseSchema,
169
- type: buildSchema(config, field.fields, {
172
+ type: buildSchema(payload, field.fields, {
170
173
  disableUnique: buildSchemaOptions.disableUnique,
171
174
  draftsEnabled: buildSchemaOptions.draftsEnabled,
172
175
  indexSortableFields,
@@ -178,19 +181,19 @@ const fieldToSchemaMap = {
178
181
  })
179
182
  };
180
183
  schema.add({
181
- [field.name]: localizeSchema(field, baseSchema, config.localization)
184
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
182
185
  });
183
186
  },
184
- json: (field, schema, config, buildSchemaOptions)=>{
187
+ json: (field, schema, payload, buildSchemaOptions)=>{
185
188
  const baseSchema = {
186
189
  ...formatBaseSchema(field, buildSchemaOptions),
187
190
  type: mongoose.Schema.Types.Mixed
188
191
  };
189
192
  schema.add({
190
- [field.name]: localizeSchema(field, baseSchema, config.localization)
193
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
191
194
  });
192
195
  },
193
- number: (field, schema, config, buildSchemaOptions)=>{
196
+ number: (field, schema, payload, buildSchemaOptions)=>{
194
197
  const baseSchema = {
195
198
  ...formatBaseSchema(field, buildSchemaOptions),
196
199
  type: field.hasMany ? [
@@ -198,16 +201,19 @@ const fieldToSchemaMap = {
198
201
  ] : Number
199
202
  };
200
203
  schema.add({
201
- [field.name]: localizeSchema(field, baseSchema, config.localization)
204
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
202
205
  });
203
206
  },
204
- point: (field, schema, config, buildSchemaOptions)=>{
207
+ point: (field, schema, payload, buildSchemaOptions)=>{
205
208
  const baseSchema = {
206
209
  type: {
207
210
  type: String,
208
211
  enum: [
209
212
  'Point'
210
- ]
213
+ ],
214
+ ...typeof field.defaultValue !== 'undefined' && {
215
+ default: 'Point'
216
+ }
211
217
  },
212
218
  coordinates: {
213
219
  type: [
@@ -221,7 +227,7 @@ const fieldToSchemaMap = {
221
227
  baseSchema.coordinates.sparse = true;
222
228
  }
223
229
  schema.add({
224
- [field.name]: localizeSchema(field, baseSchema, config.localization)
230
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
225
231
  });
226
232
  if (field.index === true || field.index === undefined) {
227
233
  const indexOptions = {};
@@ -229,8 +235,8 @@ const fieldToSchemaMap = {
229
235
  indexOptions.sparse = true;
230
236
  indexOptions.unique = true;
231
237
  }
232
- if (field.localized && config.localization) {
233
- config.localization.locales.forEach((locale)=>{
238
+ if (field.localized && payload.config.localization) {
239
+ payload.config.localization.locales.forEach((locale)=>{
234
240
  schema.index({
235
241
  [`${field.name}.${locale.code}`]: '2dsphere'
236
242
  }, indexOptions);
@@ -242,7 +248,7 @@ const fieldToSchemaMap = {
242
248
  }
243
249
  }
244
250
  },
245
- radio: (field, schema, config, buildSchemaOptions)=>{
251
+ radio: (field, schema, payload, buildSchemaOptions)=>{
246
252
  const baseSchema = {
247
253
  ...formatBaseSchema(field, buildSchemaOptions),
248
254
  type: String,
@@ -254,15 +260,16 @@ const fieldToSchemaMap = {
254
260
  })
255
261
  };
256
262
  schema.add({
257
- [field.name]: localizeSchema(field, baseSchema, config.localization)
263
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
258
264
  });
259
265
  },
260
- relationship: (field, schema, config, buildSchemaOptions)=>{
266
+ relationship: (field, schema, payload, buildSchemaOptions)=>{
261
267
  const hasManyRelations = Array.isArray(field.relationTo);
262
268
  let schemaToReturn = {};
263
- if (field.localized && config.localization) {
269
+ const valueType = getRelationshipValueType(field, payload);
270
+ if (field.localized && payload.config.localization) {
264
271
  schemaToReturn = {
265
- type: config.localization.localeCodes.reduce((locales, locale)=>{
272
+ type: payload.config.localization.localeCodes.reduce((locales, locale)=>{
266
273
  let localeSchema = {};
267
274
  if (hasManyRelations) {
268
275
  localeSchema = {
@@ -274,14 +281,14 @@ const fieldToSchemaMap = {
274
281
  enum: field.relationTo
275
282
  },
276
283
  value: {
277
- type: mongoose.Schema.Types.Mixed,
284
+ type: valueType,
278
285
  refPath: `${field.name}.${locale}.relationTo`
279
286
  }
280
287
  };
281
288
  } else {
282
289
  localeSchema = {
283
290
  ...formatBaseSchema(field, buildSchemaOptions),
284
- type: mongoose.Schema.Types.Mixed,
291
+ type: valueType,
285
292
  ref: field.relationTo
286
293
  };
287
294
  }
@@ -307,7 +314,7 @@ const fieldToSchemaMap = {
307
314
  enum: field.relationTo
308
315
  },
309
316
  value: {
310
- type: mongoose.Schema.Types.Mixed,
317
+ type: valueType,
311
318
  refPath: `${field.name}.relationTo`
312
319
  }
313
320
  };
@@ -322,7 +329,7 @@ const fieldToSchemaMap = {
322
329
  } else {
323
330
  schemaToReturn = {
324
331
  ...formatBaseSchema(field, buildSchemaOptions),
325
- type: mongoose.Schema.Types.Mixed,
332
+ type: valueType,
326
333
  ref: field.relationTo
327
334
  };
328
335
  if (field.hasMany) {
@@ -338,24 +345,27 @@ const fieldToSchemaMap = {
338
345
  [field.name]: schemaToReturn
339
346
  });
340
347
  },
341
- richText: (field, schema, config, buildSchemaOptions)=>{
348
+ richText: (field, schema, payload, buildSchemaOptions)=>{
342
349
  const baseSchema = {
343
350
  ...formatBaseSchema(field, buildSchemaOptions),
344
351
  type: mongoose.Schema.Types.Mixed
345
352
  };
346
353
  schema.add({
347
- [field.name]: localizeSchema(field, baseSchema, config.localization)
354
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
348
355
  });
349
356
  },
350
- row: (field, schema, config, buildSchemaOptions)=>{
357
+ row: (field, schema, payload, buildSchemaOptions)=>{
351
358
  field.fields.forEach((subField)=>{
359
+ if (fieldIsVirtual(subField)) {
360
+ return;
361
+ }
352
362
  const addFieldSchema = fieldToSchemaMap[subField.type];
353
363
  if (addFieldSchema) {
354
- addFieldSchema(subField, schema, config, buildSchemaOptions);
364
+ addFieldSchema(subField, schema, payload, buildSchemaOptions);
355
365
  }
356
366
  });
357
367
  },
358
- select: (field, schema, config, buildSchemaOptions)=>{
368
+ select: (field, schema, payload, buildSchemaOptions)=>{
359
369
  const baseSchema = {
360
370
  ...formatBaseSchema(field, buildSchemaOptions),
361
371
  type: String,
@@ -372,14 +382,17 @@ const fieldToSchemaMap = {
372
382
  schema.add({
373
383
  [field.name]: localizeSchema(field, field.hasMany ? [
374
384
  baseSchema
375
- ] : baseSchema, config.localization)
385
+ ] : baseSchema, payload.config.localization)
376
386
  });
377
387
  },
378
- tabs: (field, schema, config, buildSchemaOptions)=>{
388
+ tabs: (field, schema, payload, buildSchemaOptions)=>{
379
389
  field.tabs.forEach((tab)=>{
380
390
  if (tabHasName(tab)) {
391
+ if (fieldIsVirtual(tab)) {
392
+ return;
393
+ }
381
394
  const baseSchema = {
382
- type: buildSchema(config, tab.fields, {
395
+ type: buildSchema(payload, tab.fields, {
383
396
  disableUnique: buildSchemaOptions.disableUnique,
384
397
  draftsEnabled: buildSchemaOptions.draftsEnabled,
385
398
  options: {
@@ -390,19 +403,22 @@ const fieldToSchemaMap = {
390
403
  })
391
404
  };
392
405
  schema.add({
393
- [tab.name]: localizeSchema(tab, baseSchema, config.localization)
406
+ [tab.name]: localizeSchema(tab, baseSchema, payload.config.localization)
394
407
  });
395
408
  } else {
396
409
  tab.fields.forEach((subField)=>{
410
+ if (fieldIsVirtual(subField)) {
411
+ return;
412
+ }
397
413
  const addFieldSchema = fieldToSchemaMap[subField.type];
398
414
  if (addFieldSchema) {
399
- addFieldSchema(subField, schema, config, buildSchemaOptions);
415
+ addFieldSchema(subField, schema, payload, buildSchemaOptions);
400
416
  }
401
417
  });
402
418
  }
403
419
  });
404
420
  },
405
- text: (field, schema, config, buildSchemaOptions)=>{
421
+ text: (field, schema, payload, buildSchemaOptions)=>{
406
422
  const baseSchema = {
407
423
  ...formatBaseSchema(field, buildSchemaOptions),
408
424
  type: field.hasMany ? [
@@ -410,24 +426,25 @@ const fieldToSchemaMap = {
410
426
  ] : String
411
427
  };
412
428
  schema.add({
413
- [field.name]: localizeSchema(field, baseSchema, config.localization)
429
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
414
430
  });
415
431
  },
416
- textarea: (field, schema, config, buildSchemaOptions)=>{
432
+ textarea: (field, schema, payload, buildSchemaOptions)=>{
417
433
  const baseSchema = {
418
434
  ...formatBaseSchema(field, buildSchemaOptions),
419
435
  type: String
420
436
  };
421
437
  schema.add({
422
- [field.name]: localizeSchema(field, baseSchema, config.localization)
438
+ [field.name]: localizeSchema(field, baseSchema, payload.config.localization)
423
439
  });
424
440
  },
425
- upload: (field, schema, config, buildSchemaOptions)=>{
441
+ upload: (field, schema, payload, buildSchemaOptions)=>{
426
442
  const hasManyRelations = Array.isArray(field.relationTo);
427
443
  let schemaToReturn = {};
428
- if (field.localized && config.localization) {
444
+ const valueType = getRelationshipValueType(field, payload);
445
+ if (field.localized && payload.config.localization) {
429
446
  schemaToReturn = {
430
- type: config.localization.localeCodes.reduce((locales, locale)=>{
447
+ type: payload.config.localization.localeCodes.reduce((locales, locale)=>{
431
448
  let localeSchema = {};
432
449
  if (hasManyRelations) {
433
450
  localeSchema = {
@@ -439,14 +456,14 @@ const fieldToSchemaMap = {
439
456
  enum: field.relationTo
440
457
  },
441
458
  value: {
442
- type: mongoose.Schema.Types.Mixed,
459
+ type: valueType,
443
460
  refPath: `${field.name}.${locale}.relationTo`
444
461
  }
445
462
  };
446
463
  } else {
447
464
  localeSchema = {
448
465
  ...formatBaseSchema(field, buildSchemaOptions),
449
- type: mongoose.Schema.Types.Mixed,
466
+ type: valueType,
450
467
  ref: field.relationTo
451
468
  };
452
469
  }
@@ -472,7 +489,7 @@ const fieldToSchemaMap = {
472
489
  enum: field.relationTo
473
490
  },
474
491
  value: {
475
- type: mongoose.Schema.Types.Mixed,
492
+ type: valueType,
476
493
  refPath: `${field.name}.relationTo`
477
494
  }
478
495
  };
@@ -487,7 +504,7 @@ const fieldToSchemaMap = {
487
504
  } else {
488
505
  schemaToReturn = {
489
506
  ...formatBaseSchema(field, buildSchemaOptions),
490
- type: mongoose.Schema.Types.Mixed,
507
+ type: valueType,
491
508
  ref: field.relationTo
492
509
  };
493
510
  if (field.hasMany) {
@@ -504,5 +521,24 @@ const fieldToSchemaMap = {
504
521
  });
505
522
  }
506
523
  };
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
+ };
507
543
 
508
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 BlocksField,\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 TextareaField,\n TextField,\n UploadField,\n} from 'payload'\n\nimport mongoose from 'mongoose'\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: 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: 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 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 (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, 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: BlocksField,\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') {\n return option.value\n }\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') {\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 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"],"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","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,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;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BAAiB;oBACfxE,MAAM;wBAACwE;qBAAe;oBACtB7E,SAASV,mBAAmBC;gBAC9B;YACF;QACF,OAAO;YACLsF,iBAAiB;gBACf,GAAGnF,iBAAiBH,OAAOI,mBAAmB;gBAC9CU,MAAMrB,SAASgD,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"}
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,mBA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G,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"}