@payloadcms/db-mongodb 4.0.0-internal.ea6e8f8 → 4.0.0-internal.ee5d8bd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +0 -1
- package/dist/connect.js.map +1 -1
- package/dist/count.d.ts.map +1 -1
- package/dist/count.js +4 -33
- package/dist/count.js.map +1 -1
- package/dist/countGlobalVersions.d.ts.map +1 -1
- package/dist/countGlobalVersions.js +0 -1
- package/dist/countGlobalVersions.js.map +1 -1
- package/dist/countVersions.d.ts.map +1 -1
- package/dist/countVersions.js +4 -36
- package/dist/countVersions.js.map +1 -1
- package/dist/createGlobalVersion.d.ts.map +1 -1
- package/dist/createGlobalVersion.js +0 -22
- package/dist/createGlobalVersion.js.map +1 -1
- package/dist/createVersion.d.ts.map +1 -1
- package/dist/createVersion.js +3 -16
- package/dist/createVersion.js.map +1 -1
- package/dist/deleteMany.d.ts.map +1 -1
- package/dist/deleteMany.js +0 -1
- package/dist/deleteMany.js.map +1 -1
- package/dist/deleteOne.d.ts.map +1 -1
- package/dist/deleteOne.js +1 -20
- package/dist/deleteOne.js.map +1 -1
- package/dist/deleteVersions.d.ts.map +1 -1
- package/dist/deleteVersions.js +0 -1
- package/dist/deleteVersions.js.map +1 -1
- package/dist/exports/migration-utils.d.ts +0 -1
- package/dist/exports/migration-utils.d.ts.map +1 -1
- package/dist/exports/migration-utils.js +0 -1
- package/dist/exports/migration-utils.js.map +1 -1
- package/dist/find.d.ts.map +1 -1
- package/dist/find.js +8 -44
- package/dist/find.js.map +1 -1
- package/dist/findDistinct.d.ts.map +1 -1
- package/dist/findDistinct.js +11 -70
- package/dist/findDistinct.js.map +1 -1
- package/dist/findGlobal.d.ts.map +1 -1
- package/dist/findGlobal.js +5 -34
- package/dist/findGlobal.js.map +1 -1
- package/dist/findGlobalVersions.d.ts.map +1 -1
- package/dist/findGlobalVersions.js +2 -10
- package/dist/findGlobalVersions.js.map +1 -1
- package/dist/findOne.d.ts.map +1 -1
- package/dist/findOne.js +5 -43
- package/dist/findOne.js.map +1 -1
- package/dist/findVersions.d.ts.map +1 -1
- package/dist/findVersions.js +5 -49
- package/dist/findVersions.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/dist/models/buildGlobalModel.d.ts.map +1 -1
- package/dist/models/buildGlobalModel.js +1 -30
- package/dist/models/buildGlobalModel.js.map +1 -1
- package/dist/models/buildSchema.d.ts.map +1 -1
- package/dist/models/buildSchema.js +10 -30
- package/dist/models/buildSchema.js.map +1 -1
- package/dist/predefinedMigrations/migrateSizesToVariants.js.map +1 -1
- package/dist/queries/buildAndOrConditions.d.ts +2 -4
- package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
- package/dist/queries/buildAndOrConditions.js +1 -3
- package/dist/queries/buildAndOrConditions.js.map +1 -1
- package/dist/queries/buildQuery.d.ts +2 -4
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/buildQuery.js +1 -3
- package/dist/queries/buildQuery.js.map +1 -1
- package/dist/queries/buildSearchParams.d.ts +2 -4
- package/dist/queries/buildSearchParams.d.ts.map +1 -1
- package/dist/queries/buildSearchParams.js +44 -175
- package/dist/queries/buildSearchParams.js.map +1 -1
- package/dist/queries/getBuildQueryPlugin.d.ts +1 -3
- package/dist/queries/getBuildQueryPlugin.d.ts.map +1 -1
- package/dist/queries/getBuildQueryPlugin.js +1 -3
- package/dist/queries/getBuildQueryPlugin.js.map +1 -1
- package/dist/queries/parseParams.d.ts +2 -4
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +1 -5
- package/dist/queries/parseParams.js.map +1 -1
- package/dist/queryDrafts.d.ts.map +1 -1
- package/dist/queryDrafts.js +7 -38
- package/dist/queryDrafts.js.map +1 -1
- package/dist/transactions/commitTransaction.d.ts.map +1 -1
- package/dist/transactions/commitTransaction.js +7 -55
- package/dist/transactions/commitTransaction.js.map +1 -1
- package/dist/transactions/rollbackTransaction.d.ts.map +1 -1
- package/dist/transactions/rollbackTransaction.js +9 -10
- package/dist/transactions/rollbackTransaction.js.map +1 -1
- package/dist/updateGlobal.d.ts.map +1 -1
- package/dist/updateGlobal.js +7 -87
- package/dist/updateGlobal.js.map +1 -1
- package/dist/updateGlobalVersion.d.ts.map +1 -1
- package/dist/updateGlobalVersion.js +0 -1
- package/dist/updateGlobalVersion.js.map +1 -1
- package/dist/updateMany.d.ts.map +1 -1
- package/dist/updateMany.js +1 -3
- package/dist/updateMany.js.map +1 -1
- package/dist/updateOne.d.ts.map +1 -1
- package/dist/updateOne.js +2 -28
- package/dist/updateOne.js.map +1 -1
- package/dist/updateVersion.d.ts.map +1 -1
- package/dist/updateVersion.js +0 -1
- package/dist/updateVersion.js.map +1 -1
- package/dist/utilities/aggregatePaginate.d.ts +1 -2
- package/dist/utilities/aggregatePaginate.d.ts.map +1 -1
- package/dist/utilities/aggregatePaginate.js +4 -18
- package/dist/utilities/aggregatePaginate.js.map +1 -1
- package/dist/utilities/buildJoinAggregation.d.ts +2 -4
- package/dist/utilities/buildJoinAggregation.d.ts.map +1 -1
- package/dist/utilities/buildJoinAggregation.js +23 -118
- package/dist/utilities/buildJoinAggregation.js.map +1 -1
- package/dist/utilities/resolveJoins.d.ts +2 -6
- package/dist/utilities/resolveJoins.d.ts.map +1 -1
- package/dist/utilities/resolveJoins.js +26 -114
- package/dist/utilities/resolveJoins.js.map +1 -1
- package/package.json +16 -19
- package/dist/deleteBranchGlobal.d.ts +0 -10
- package/dist/deleteBranchGlobal.d.ts.map +0 -1
- package/dist/deleteBranchGlobal.js +0 -22
- package/dist/deleteBranchGlobal.js.map +0 -1
- package/dist/predefinedMigrations/branching.d.ts +0 -4
- package/dist/predefinedMigrations/branching.d.ts.map +0 -1
- package/dist/predefinedMigrations/branching.js +0 -9
- package/dist/predefinedMigrations/branching.js.map +0 -1
- package/dist/predefinedMigrations/migrateBranching.d.ts +0 -15
- package/dist/predefinedMigrations/migrateBranching.d.ts.map +0 -1
- package/dist/predefinedMigrations/migrateBranching.js +0 -88
- package/dist/predefinedMigrations/migrateBranching.js.map +0 -1
- package/dist/queries/buildBranchVisibility.d.ts +0 -11
- package/dist/queries/buildBranchVisibility.d.ts.map +0 -1
- package/dist/queries/buildBranchVisibility.js +0 -204
- package/dist/queries/buildBranchVisibility.js.map +0 -1
- package/dist/upsertBranchGlobalChange.d.ts +0 -3
- package/dist/upsertBranchGlobalChange.d.ts.map +0 -1
- package/dist/upsertBranchGlobalChange.js +0 -28
- package/dist/upsertBranchGlobalChange.js.map +0 -1
|
@@ -78,39 +78,19 @@ export const buildSchema = (args)=>{
|
|
|
78
78
|
});
|
|
79
79
|
if (args.compoundIndexes) {
|
|
80
80
|
for (const index of args.compoundIndexes){
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const indexDefinition = {};
|
|
87
|
-
const resolveIndexPath = (path)=>{
|
|
88
|
-
const indexField = index.fields.find((field)=>field.path === path);
|
|
89
|
-
if (indexField?.pathHasLocalized && locale) {
|
|
90
|
-
return indexField.localizedPath.replace('<locale>', locale.code);
|
|
81
|
+
const indexDefinition = {};
|
|
82
|
+
for (const field of index.fields){
|
|
83
|
+
if (field.pathHasLocalized && payload.config.localization) {
|
|
84
|
+
for (const locale of payload.config.localization.locales){
|
|
85
|
+
indexDefinition[field.localizedPath.replace('<locale>', locale.code)] = 1;
|
|
91
86
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
for (const field of index.fields){
|
|
95
|
-
indexDefinition[resolveIndexPath(field.path)] = 1;
|
|
96
|
-
}
|
|
97
|
-
const indexOptions = {
|
|
98
|
-
unique: args.buildSchemaOptions.disableUnique ? false : index.unique
|
|
99
|
-
};
|
|
100
|
-
// A missing field is an ordinary value to a MongoDB unique index, unlike a
|
|
101
|
-
// NULL column in a Postgres or SQLite composite unique constraint, which
|
|
102
|
-
// always excludes that row from the comparison. `partialFilterExpression`
|
|
103
|
-
// is what makes the two behave the same.
|
|
104
|
-
if (index.requireExists?.length) {
|
|
105
|
-
indexOptions.partialFilterExpression = Object.fromEntries(index.requireExists.map((field)=>[
|
|
106
|
-
resolveIndexPath(field),
|
|
107
|
-
{
|
|
108
|
-
$exists: true
|
|
109
|
-
}
|
|
110
|
-
]));
|
|
87
|
+
} else {
|
|
88
|
+
indexDefinition[field.path] = 1;
|
|
111
89
|
}
|
|
112
|
-
schema.index(indexDefinition, indexOptions);
|
|
113
90
|
}
|
|
91
|
+
schema.index(indexDefinition, {
|
|
92
|
+
unique: args.buildSchemaOptions.disableUnique ? false : index.unique
|
|
93
|
+
});
|
|
114
94
|
}
|
|
115
95
|
}
|
|
116
96
|
return schema;
|
|
@@ -1 +1 @@
|
|
|
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 BlocksField,\n type CheckboxField,\n type CodeField,\n type CollapsibleField,\n type DateField,\n type EmailField,\n type Field,\n type FieldAffectingData,\n type FlattenedField,\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 SanitizedCompoundIndex,\n type SanitizedLocalizationConfig,\n type SelectField,\n type SlugField,\n type Tab,\n type TabsField,\n type TextareaField,\n type TextField,\n type UploadField,\n} from 'payload'\nimport { createSchemaBuildContext } from 'payload/internal'\nimport {\n fieldAffectsData,\n fieldIsPresentationalOnly,\n fieldIsVirtual,\n fieldShouldBeLocalized,\n tabHasName,\n} from 'payload/shared'\n\nimport type { MongoSchemaBuildContext } from './schemaBuildContext.js'\n\nimport { getBlockSchemaCacheKey } from './schemaBuildContext.js'\n\nexport type BuildSchemaOptions = {\n allowIDField?: boolean\n disableUnique?: boolean\n draftsEnabled?: boolean\n indexSortableFields?: boolean\n options?: SchemaOptions\n}\n\ntype FieldSchemaGenerator<T extends Field = Field> = (\n field: T,\n schema: Schema,\n config: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n parentIsLocalized: boolean,\n schemaBuildState: SchemaBuildState,\n) => void\n\ntype SchemaBuildState = {\n context: MongoSchemaBuildContext\n isVersion: boolean\n path: string\n}\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 = ({\n buildSchemaOptions,\n field,\n parentIsLocalized,\n}: {\n buildSchemaOptions: BuildSchemaOptions\n field: FieldAffectingData\n parentIsLocalized: boolean\n}) => {\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 (fieldShouldBeLocalized({ field, parentIsLocalized }) ||\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: SchemaTypeOptions<any>,\n localization: false | SanitizedLocalizationConfig,\n parentIsLocalized: boolean,\n) => {\n if (\n fieldShouldBeLocalized({ field: entity, parentIsLocalized }) &&\n localization &&\n Array.isArray(localization.locales)\n ) {\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 = (args: {\n buildSchemaOptions: BuildSchemaOptions\n compoundIndexes?: SanitizedCompoundIndex[]\n configFields: Field[]\n flattenedFields?: FlattenedField[]\n isVersion?: boolean\n parentIsLocalized?: boolean\n payload: Payload\n schemaBuildContext?: MongoSchemaBuildContext\n schemaPath?: string\n}): Schema => {\n const {\n buildSchemaOptions = {},\n configFields,\n flattenedFields,\n parentIsLocalized,\n payload,\n } = args\n const schemaBuildContext = args.schemaBuildContext ?? createSchemaBuildContext<Schema>()\n const schemaBuildState: SchemaBuildState = {\n context: schemaBuildContext,\n isVersion: args.isVersion ?? false,\n path: args.schemaPath ?? 'schema',\n }\n const { allowIDField, options } = buildSchemaOptions\n let fields = {}\n\n let schemaFields = configFields\n\n if (!allowIDField) {\n // Use flattenedFields if available to find custom id field regardless of nesting\n const fieldsToSearch = flattenedFields || schemaFields\n const idField = fieldsToSearch.find((field) => fieldAffectsData(field) && field.name === 'id')\n if (idField) {\n fields = {\n _id:\n idField.type === 'number'\n ? payload.db.useBigIntForNumberIDs\n ? mongoose.Schema.Types.BigInt\n : Number\n : 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 as any)\n\n schemaFields.forEach((field) => {\n if (fieldIsVirtual(field)) {\n return\n }\n\n if (!fieldIsPresentationalOnly(field)) {\n const addFieldSchema = getSchemaGenerator(field.type)\n\n if (addFieldSchema) {\n addFieldSchema(\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized ?? false,\n schemaBuildState,\n )\n }\n }\n })\n\n if (args.compoundIndexes) {\n for (const index of args.compoundIndexes) {\n const hasLocalizedField = index.fields.some((field) => field.pathHasLocalized)\n const locales =\n hasLocalizedField && payload.config.localization\n ? payload.config.localization.locales\n : [undefined]\n\n for (const locale of locales) {\n const indexDefinition: Record<string, 1> = {}\n const resolveIndexPath = (path: string): string => {\n const indexField = index.fields.find((field) => field.path === path)\n\n if (indexField?.pathHasLocalized && locale) {\n return indexField.localizedPath.replace('<locale>', locale.code)\n }\n\n return path\n }\n\n for (const field of index.fields) {\n indexDefinition[resolveIndexPath(field.path)] = 1\n }\n\n const indexOptions: IndexOptions = {\n unique: args.buildSchemaOptions.disableUnique ? false : index.unique,\n }\n\n // A missing field is an ordinary value to a MongoDB unique index, unlike a\n // NULL column in a Postgres or SQLite composite unique constraint, which\n // always excludes that row from the comparison. `partialFilterExpression`\n // is what makes the two behave the same.\n if (index.requireExists?.length) {\n indexOptions.partialFilterExpression = Object.fromEntries(\n index.requireExists.map((field) => [resolveIndexPath(field), { $exists: true }]),\n )\n }\n\n schema.index(indexDefinition, indexOptions)\n }\n }\n }\n\n return schema\n}\n\nconst array: FieldSchemaGenerator<ArrayField> = (\n field: ArrayField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n schemaBuildState,\n) => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: [\n buildSchema({\n buildSchemaOptions: {\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 configFields: field.fields,\n isVersion: schemaBuildState.isVersion,\n parentIsLocalized: parentIsLocalized || field.localized,\n payload,\n schemaBuildContext: schemaBuildState.context,\n schemaPath: `${schemaBuildState.path}/field:${field.name}`,\n }),\n ],\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst blocks: FieldSchemaGenerator<BlocksField> = (\n field: BlocksField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n schemaBuildState,\n): void => {\n const fieldSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: [new mongoose.Schema({}, { _id: false, discriminatorKey: 'blockType' })],\n }\n\n schema.add({\n [field.name]: localizeSchema(\n field,\n fieldSchema,\n payload.config.localization,\n parentIsLocalized,\n ),\n })\n field.blocks.forEach((blockItem) => {\n const block = typeof blockItem === 'string' ? payload.blocks[blockItem] : blockItem\n\n if (!block) {\n return\n }\n\n const isLocalized = Boolean(parentIsLocalized || field.localized)\n const isReference = typeof blockItem === 'string'\n const fieldPath = `${schemaBuildState.path}/field:${field.name}`\n const blockSchema = schemaBuildState.context.getOrCreate({\n build: () => {\n const template = new mongoose.Schema({}, { _id: false, id: false })\n\n block.fields.forEach((blockField) => {\n if (fieldIsVirtual(blockField)) {\n return\n }\n\n const addFieldSchema = getSchemaGenerator(blockField.type)\n\n if (addFieldSchema) {\n addFieldSchema(blockField, template, payload, buildSchemaOptions, isLocalized, {\n context: schemaBuildState.context,\n isVersion: schemaBuildState.isVersion,\n path: isReference ? `block:${block.slug}` : `${fieldPath}/block:${block.slug}`,\n })\n }\n })\n\n return template\n },\n cacheKey: getBlockSchemaCacheKey({\n blockSlug: block.slug,\n buildSchemaOptions,\n fieldPath,\n isLocalized,\n isReference,\n isVersion: schemaBuildState.isVersion,\n }),\n definition: block,\n })\n\n if (fieldShouldBeLocalized({ field, parentIsLocalized }) && 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(block.slug, blockSchema)\n })\n } else {\n // @ts-expect-error Possible incorrect typing in mongoose types, this works\n schema.path(field.name).discriminator(block.slug, blockSchema)\n }\n })\n}\n\nconst checkbox: FieldSchemaGenerator<CheckboxField> = (\n field: CheckboxField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: Boolean,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst code: FieldSchemaGenerator<CodeField> = (\n field: CodeField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: String,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst collapsible: FieldSchemaGenerator<CollapsibleField> = (\n field: CollapsibleField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n schemaBuildState,\n): void => {\n field.fields.forEach((subField: Field) => {\n if (fieldIsVirtual(subField)) {\n return\n }\n\n const addFieldSchema = getSchemaGenerator(subField.type)\n\n if (addFieldSchema) {\n addFieldSchema(\n subField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n schemaBuildState,\n )\n }\n })\n}\n\nconst date: FieldSchemaGenerator<DateField> = (\n field: DateField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: Date,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst email: FieldSchemaGenerator<EmailField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: String,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst group: FieldSchemaGenerator<GroupField> = (\n field: GroupField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n schemaBuildState,\n): void => {\n if (fieldAffectsData(field)) {\n const formattedBaseSchema = formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized })\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: SchemaTypeOptions<any> = {\n ...formattedBaseSchema,\n type: buildSchema({\n buildSchemaOptions: {\n disableUnique: buildSchemaOptions.disableUnique,\n draftsEnabled: buildSchemaOptions.draftsEnabled,\n indexSortableFields,\n options: {\n _id: false,\n id: false,\n minimize: false,\n },\n },\n configFields: field.fields,\n isVersion: schemaBuildState.isVersion,\n parentIsLocalized: parentIsLocalized || field.localized,\n payload,\n schemaBuildContext: schemaBuildState.context,\n schemaPath: `${schemaBuildState.path}/field:${field.name}`,\n }),\n }\n\n schema.add({\n [field.name]: localizeSchema(\n field,\n baseSchema,\n payload.config.localization,\n parentIsLocalized,\n ),\n })\n } else {\n field.fields.forEach((subField) => {\n if (fieldIsVirtual(subField)) {\n return\n }\n\n const addFieldSchema = getSchemaGenerator(subField.type)\n\n if (addFieldSchema) {\n addFieldSchema(\n subField,\n schema,\n payload,\n buildSchemaOptions,\n (parentIsLocalized || field.localized) ?? false,\n schemaBuildState,\n )\n }\n })\n }\n}\n\nconst json: FieldSchemaGenerator<JSONField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: mongoose.Schema.Types.Mixed,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst number: FieldSchemaGenerator<NumberField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: field.hasMany ? [Number] : Number,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst point: FieldSchemaGenerator<PointField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\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\n if (\n buildSchemaOptions.disableUnique &&\n field.unique &&\n fieldShouldBeLocalized({ field, parentIsLocalized })\n ) {\n baseSchema.coordinates.sparse = true\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\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 (fieldShouldBeLocalized({ field, parentIsLocalized }) && 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\nconst radio: FieldSchemaGenerator<RadioField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\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, parentIsLocalized),\n })\n}\n\nconst relationship: FieldSchemaGenerator<RelationshipField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n) => {\n const hasManyRelations = Array.isArray(field.relationTo)\n let schemaToReturn: { [key: string]: any } = {}\n\n const valueType = getRelationshipValueType(field, payload)\n\n if (fieldShouldBeLocalized({ field, parentIsLocalized }) && payload.config.localization) {\n schemaToReturn = {\n _id: false,\n type: payload.config.localization.localeCodes.reduce((locales, locale) => {\n let localeSchema: { [key: string]: any } = {}\n\n if (hasManyRelations) {\n localeSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\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({ buildSchemaOptions, field, parentIsLocalized }),\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({ buildSchemaOptions, field, parentIsLocalized }),\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({ buildSchemaOptions, field, parentIsLocalized }),\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\nconst richText: FieldSchemaGenerator<RichTextField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: mongoose.Schema.Types.Mixed,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst row: FieldSchemaGenerator<RowField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n schemaBuildState,\n): void => {\n field.fields.forEach((subField: Field) => {\n if (fieldIsVirtual(subField)) {\n return\n }\n\n const addFieldSchema = getSchemaGenerator(subField.type)\n\n if (addFieldSchema) {\n addFieldSchema(\n subField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n schemaBuildState,\n )\n }\n })\n}\n\nconst select: FieldSchemaGenerator<SelectField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\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 as unknown[]).push(null)\n }\n\n schema.add({\n [field.name]: localizeSchema(\n field,\n field.hasMany ? [baseSchema] : baseSchema,\n payload.config.localization,\n parentIsLocalized,\n ),\n })\n}\n\nconst tabs: FieldSchemaGenerator<TabsField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n schemaBuildState,\n): void => {\n field.tabs.forEach((tab) => {\n if (tabHasName(tab)) {\n if (fieldIsVirtual(tab)) {\n return\n }\n const baseSchema = {\n type: buildSchema({\n buildSchemaOptions: {\n disableUnique: buildSchemaOptions.disableUnique,\n draftsEnabled: buildSchemaOptions.draftsEnabled,\n options: {\n _id: false,\n id: false,\n minimize: false,\n },\n },\n configFields: tab.fields,\n isVersion: schemaBuildState.isVersion,\n parentIsLocalized: parentIsLocalized || tab.localized,\n payload,\n schemaBuildContext: schemaBuildState.context,\n schemaPath: `${schemaBuildState.path}/tab:${tab.name}`,\n }),\n }\n\n schema.add({\n [tab.name]: localizeSchema(tab, baseSchema, payload.config.localization, parentIsLocalized),\n })\n } else {\n tab.fields.forEach((subField: Field) => {\n if (fieldIsVirtual(subField)) {\n return\n }\n const addFieldSchema = getSchemaGenerator(subField.type)\n\n if (addFieldSchema) {\n addFieldSchema(\n subField,\n schema,\n payload,\n buildSchemaOptions,\n (parentIsLocalized || tab.localized) ?? false,\n schemaBuildState,\n )\n }\n })\n }\n })\n}\n\nconst text: FieldSchemaGenerator<TextField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: field.hasMany ? [String] : String,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst slug: FieldSchemaGenerator<SlugField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: String,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst textarea: FieldSchemaGenerator<TextareaField> = (\n field: TextareaField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: String,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst upload: FieldSchemaGenerator<UploadField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\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 (fieldShouldBeLocalized({ field, parentIsLocalized }) && payload.config.localization) {\n schemaToReturn = {\n _id: false,\n type: payload.config.localization.localeCodes.reduce((locales, locale) => {\n let localeSchema: { [key: string]: any } = {}\n\n if (hasManyRelations) {\n localeSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\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({ buildSchemaOptions, field, parentIsLocalized }),\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({ buildSchemaOptions, field, parentIsLocalized }),\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({ buildSchemaOptions, field, parentIsLocalized }),\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\nconst getSchemaGenerator = (fieldType: string): FieldSchemaGenerator | null => {\n if (fieldType in fieldToSchemaMap) {\n return fieldToSchemaMap[fieldType as keyof typeof fieldToSchemaMap] as FieldSchemaGenerator\n }\n\n return null\n}\n\nconst fieldToSchemaMap = {\n slug,\n array,\n blocks,\n checkbox,\n code,\n collapsible,\n date,\n email,\n group,\n json,\n number,\n point,\n radio,\n relationship,\n richText,\n row,\n select,\n tabs,\n text,\n textarea,\n upload,\n}\n\nconst getRelationshipValueType = (field: RelationshipField | UploadField, payload: Payload) => {\n if (typeof field.relationTo === 'string') {\n const customIDType = payload.collections[field.relationTo]?.customIDType\n\n if (!customIDType) {\n return mongoose.Schema.Types.ObjectId\n }\n\n if (customIDType === 'number') {\n if (payload.db.useBigIntForNumberIDs) {\n return mongoose.Schema.Types.BigInt\n } else {\n return mongoose.Schema.Types.Number\n }\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","createSchemaBuildContext","fieldAffectsData","fieldIsPresentationalOnly","fieldIsVirtual","fieldShouldBeLocalized","tabHasName","getBlockSchemaCacheKey","formatDefaultValue","field","defaultValue","undefined","formatBaseSchema","buildSchemaOptions","parentIsLocalized","disableUnique","draftsEnabled","indexSortableFields","schema","default","index","unique","required","type","sparse","hidden","localizeSchema","entity","localization","Array","isArray","locales","localeCodes","reduce","localeSchema","locale","_id","localized","buildSchema","args","configFields","flattenedFields","payload","schemaBuildContext","schemaBuildState","context","isVersion","path","schemaPath","allowIDField","options","fields","schemaFields","fieldsToSearch","idField","find","name","db","useBigIntForNumberIDs","Schema","Types","BigInt","Number","String","filter","forEach","addFieldSchema","getSchemaGenerator","compoundIndexes","hasLocalizedField","some","pathHasLocalized","config","indexDefinition","resolveIndexPath","indexField","localizedPath","replace","code","indexOptions","requireExists","length","partialFilterExpression","Object","fromEntries","map","$exists","array","baseSchema","id","minimize","add","blocks","fieldSchema","discriminatorKey","blockItem","block","isLocalized","Boolean","isReference","fieldPath","blockSchema","getOrCreate","build","template","blockField","slug","cacheKey","blockSlug","definition","localeCode","discriminator","checkbox","collapsible","subField","date","Date","email","group","formattedBaseSchema","json","Mixed","number","hasMany","point","enum","coordinates","radio","option","value","relationship","hasManyRelations","relationTo","schemaToReturn","valueType","getRelationshipValueType","refPath","ref","richText","row","select","push","tabs","tab","text","textarea","upload","fieldType","fieldToSchemaMap","customIDType","collections","ObjectId"],"mappings":"AAEA,OAAOA,cAAc,WAAU;AAgC/B,SAASC,wBAAwB,QAAQ,mBAAkB;AAC3D,SACEC,gBAAgB,EAChBC,yBAAyB,EACzBC,cAAc,EACdC,sBAAsB,EACtBC,UAAU,QACL,iBAAgB;AAIvB,SAASC,sBAAsB,QAAQ,0BAAyB;AAyBhE;;;CAGC,GACD,MAAMC,qBAAqB,CAACC,QAC1B,OAAOA,MAAMC,YAAY,KAAK,eAAe,OAAOD,MAAMC,YAAY,KAAK,aACvED,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EA,MAAMX,2BAA2B,CAAC9H,OAAwCiC;IACxE,IAAI,OAAOjC,MAAM2H,UAAU,KAAK,UAAU;QACxC,MAAMiB,eAAe3G,QAAQ4G,WAAW,CAAC7I,MAAM2H,UAAU,CAAC,EAAEiB;QAE5D,IAAI,CAACA,cAAc;YACjB,OAAOrJ,SAAS2D,MAAM,CAACC,KAAK,CAAC2F,QAAQ;QACvC;QAEA,IAAIF,iBAAiB,UAAU;YAC7B,IAAI3G,QAAQe,EAAE,CAACC,qBAAqB,EAAE;gBACpC,OAAO1D,SAAS2D,MAAM,CAACC,KAAK,CAACC,MAAM;YACrC,OAAO;gBACL,OAAO7D,SAAS2D,MAAM,CAACC,KAAK,CAACE,MAAM;YACrC;QACF;QAEA,OAAO9D,SAAS2D,MAAM,CAACC,KAAK,CAACG,MAAM;IACrC;IAEA,2BAA2B;IAC3B,IACEtD,MAAM2H,UAAU,CAAC9D,IAAI,CAAC,CAAC8D;QACrB,OAAO,CAAC,CAAC1F,QAAQ4G,WAAW,CAAClB,WAAW,EAAEiB;IAC5C,IACA;QACA,OAAOrJ,SAAS2D,MAAM,CAACC,KAAK,CAAC6D,KAAK;IACpC;IAEA,OAAOzH,SAAS2D,MAAM,CAACC,KAAK,CAAC2F,QAAQ;AACvC"}
|
|
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 BlocksField,\n type CheckboxField,\n type CodeField,\n type CollapsibleField,\n type DateField,\n type EmailField,\n type Field,\n type FieldAffectingData,\n type FlattenedField,\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 SanitizedCompoundIndex,\n type SanitizedLocalizationConfig,\n type SelectField,\n type SlugField,\n type Tab,\n type TabsField,\n type TextareaField,\n type TextField,\n type UploadField,\n} from 'payload'\nimport { createSchemaBuildContext } from 'payload/internal'\nimport {\n fieldAffectsData,\n fieldIsPresentationalOnly,\n fieldIsVirtual,\n fieldShouldBeLocalized,\n tabHasName,\n} from 'payload/shared'\n\nimport type { MongoSchemaBuildContext } from './schemaBuildContext.js'\n\nimport { getBlockSchemaCacheKey } from './schemaBuildContext.js'\n\nexport type BuildSchemaOptions = {\n allowIDField?: boolean\n disableUnique?: boolean\n draftsEnabled?: boolean\n indexSortableFields?: boolean\n options?: SchemaOptions\n}\n\ntype FieldSchemaGenerator<T extends Field = Field> = (\n field: T,\n schema: Schema,\n config: Payload,\n buildSchemaOptions: BuildSchemaOptions,\n parentIsLocalized: boolean,\n schemaBuildState: SchemaBuildState,\n) => void\n\ntype SchemaBuildState = {\n context: MongoSchemaBuildContext\n isVersion: boolean\n path: string\n}\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 = ({\n buildSchemaOptions,\n field,\n parentIsLocalized,\n}: {\n buildSchemaOptions: BuildSchemaOptions\n field: FieldAffectingData\n parentIsLocalized: boolean\n}) => {\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 (fieldShouldBeLocalized({ field, parentIsLocalized }) ||\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: SchemaTypeOptions<any>,\n localization: false | SanitizedLocalizationConfig,\n parentIsLocalized: boolean,\n) => {\n if (\n fieldShouldBeLocalized({ field: entity, parentIsLocalized }) &&\n localization &&\n Array.isArray(localization.locales)\n ) {\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 = (args: {\n buildSchemaOptions: BuildSchemaOptions\n compoundIndexes?: SanitizedCompoundIndex[]\n configFields: Field[]\n flattenedFields?: FlattenedField[]\n isVersion?: boolean\n parentIsLocalized?: boolean\n payload: Payload\n schemaBuildContext?: MongoSchemaBuildContext\n schemaPath?: string\n}): Schema => {\n const {\n buildSchemaOptions = {},\n configFields,\n flattenedFields,\n parentIsLocalized,\n payload,\n } = args\n const schemaBuildContext = args.schemaBuildContext ?? createSchemaBuildContext<Schema>()\n const schemaBuildState: SchemaBuildState = {\n context: schemaBuildContext,\n isVersion: args.isVersion ?? false,\n path: args.schemaPath ?? 'schema',\n }\n const { allowIDField, options } = buildSchemaOptions\n let fields = {}\n\n let schemaFields = configFields\n\n if (!allowIDField) {\n // Use flattenedFields if available to find custom id field regardless of nesting\n const fieldsToSearch = flattenedFields || schemaFields\n const idField = fieldsToSearch.find((field) => fieldAffectsData(field) && field.name === 'id')\n if (idField) {\n fields = {\n _id:\n idField.type === 'number'\n ? payload.db.useBigIntForNumberIDs\n ? mongoose.Schema.Types.BigInt\n : Number\n : 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 as any)\n\n schemaFields.forEach((field) => {\n if (fieldIsVirtual(field)) {\n return\n }\n\n if (!fieldIsPresentationalOnly(field)) {\n const addFieldSchema = getSchemaGenerator(field.type)\n\n if (addFieldSchema) {\n addFieldSchema(\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized ?? false,\n schemaBuildState,\n )\n }\n }\n })\n\n if (args.compoundIndexes) {\n for (const index of args.compoundIndexes) {\n const indexDefinition: Record<string, 1> = {}\n\n for (const field of index.fields) {\n if (field.pathHasLocalized && payload.config.localization) {\n for (const locale of payload.config.localization.locales) {\n indexDefinition[field.localizedPath.replace('<locale>', locale.code)] = 1\n }\n } else {\n indexDefinition[field.path] = 1\n }\n }\n\n schema.index(indexDefinition, {\n unique: args.buildSchemaOptions.disableUnique ? false : index.unique,\n })\n }\n }\n\n return schema\n}\n\nconst array: FieldSchemaGenerator<ArrayField> = (\n field: ArrayField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n schemaBuildState,\n) => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: [\n buildSchema({\n buildSchemaOptions: {\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 configFields: field.fields,\n isVersion: schemaBuildState.isVersion,\n parentIsLocalized: parentIsLocalized || field.localized,\n payload,\n schemaBuildContext: schemaBuildState.context,\n schemaPath: `${schemaBuildState.path}/field:${field.name}`,\n }),\n ],\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst blocks: FieldSchemaGenerator<BlocksField> = (\n field: BlocksField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n schemaBuildState,\n): void => {\n const fieldSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: [new mongoose.Schema({}, { _id: false, discriminatorKey: 'blockType' })],\n }\n\n schema.add({\n [field.name]: localizeSchema(\n field,\n fieldSchema,\n payload.config.localization,\n parentIsLocalized,\n ),\n })\n field.blocks.forEach((blockItem) => {\n const block = typeof blockItem === 'string' ? payload.blocks[blockItem] : blockItem\n\n if (!block) {\n return\n }\n\n const isLocalized = Boolean(parentIsLocalized || field.localized)\n const isReference = typeof blockItem === 'string'\n const fieldPath = `${schemaBuildState.path}/field:${field.name}`\n const blockSchema = schemaBuildState.context.getOrCreate({\n build: () => {\n const template = new mongoose.Schema({}, { _id: false, id: false })\n\n block.fields.forEach((blockField) => {\n if (fieldIsVirtual(blockField)) {\n return\n }\n\n const addFieldSchema = getSchemaGenerator(blockField.type)\n\n if (addFieldSchema) {\n addFieldSchema(blockField, template, payload, buildSchemaOptions, isLocalized, {\n context: schemaBuildState.context,\n isVersion: schemaBuildState.isVersion,\n path: isReference ? `block:${block.slug}` : `${fieldPath}/block:${block.slug}`,\n })\n }\n })\n\n return template\n },\n cacheKey: getBlockSchemaCacheKey({\n blockSlug: block.slug,\n buildSchemaOptions,\n fieldPath,\n isLocalized,\n isReference,\n isVersion: schemaBuildState.isVersion,\n }),\n definition: block,\n })\n\n if (fieldShouldBeLocalized({ field, parentIsLocalized }) && 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(block.slug, blockSchema)\n })\n } else {\n // @ts-expect-error Possible incorrect typing in mongoose types, this works\n schema.path(field.name).discriminator(block.slug, blockSchema)\n }\n })\n}\n\nconst checkbox: FieldSchemaGenerator<CheckboxField> = (\n field: CheckboxField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: Boolean,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst code: FieldSchemaGenerator<CodeField> = (\n field: CodeField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: String,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst collapsible: FieldSchemaGenerator<CollapsibleField> = (\n field: CollapsibleField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n schemaBuildState,\n): void => {\n field.fields.forEach((subField: Field) => {\n if (fieldIsVirtual(subField)) {\n return\n }\n\n const addFieldSchema = getSchemaGenerator(subField.type)\n\n if (addFieldSchema) {\n addFieldSchema(\n subField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n schemaBuildState,\n )\n }\n })\n}\n\nconst date: FieldSchemaGenerator<DateField> = (\n field: DateField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: Date,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst email: FieldSchemaGenerator<EmailField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: String,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst group: FieldSchemaGenerator<GroupField> = (\n field: GroupField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n schemaBuildState,\n): void => {\n if (fieldAffectsData(field)) {\n const formattedBaseSchema = formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized })\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: SchemaTypeOptions<any> = {\n ...formattedBaseSchema,\n type: buildSchema({\n buildSchemaOptions: {\n disableUnique: buildSchemaOptions.disableUnique,\n draftsEnabled: buildSchemaOptions.draftsEnabled,\n indexSortableFields,\n options: {\n _id: false,\n id: false,\n minimize: false,\n },\n },\n configFields: field.fields,\n isVersion: schemaBuildState.isVersion,\n parentIsLocalized: parentIsLocalized || field.localized,\n payload,\n schemaBuildContext: schemaBuildState.context,\n schemaPath: `${schemaBuildState.path}/field:${field.name}`,\n }),\n }\n\n schema.add({\n [field.name]: localizeSchema(\n field,\n baseSchema,\n payload.config.localization,\n parentIsLocalized,\n ),\n })\n } else {\n field.fields.forEach((subField) => {\n if (fieldIsVirtual(subField)) {\n return\n }\n\n const addFieldSchema = getSchemaGenerator(subField.type)\n\n if (addFieldSchema) {\n addFieldSchema(\n subField,\n schema,\n payload,\n buildSchemaOptions,\n (parentIsLocalized || field.localized) ?? false,\n schemaBuildState,\n )\n }\n })\n }\n}\n\nconst json: FieldSchemaGenerator<JSONField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: mongoose.Schema.Types.Mixed,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst number: FieldSchemaGenerator<NumberField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: field.hasMany ? [Number] : Number,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst point: FieldSchemaGenerator<PointField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\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\n if (\n buildSchemaOptions.disableUnique &&\n field.unique &&\n fieldShouldBeLocalized({ field, parentIsLocalized })\n ) {\n baseSchema.coordinates.sparse = true\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\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 (fieldShouldBeLocalized({ field, parentIsLocalized }) && 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\nconst radio: FieldSchemaGenerator<RadioField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\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, parentIsLocalized),\n })\n}\n\nconst relationship: FieldSchemaGenerator<RelationshipField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n) => {\n const hasManyRelations = Array.isArray(field.relationTo)\n let schemaToReturn: { [key: string]: any } = {}\n\n const valueType = getRelationshipValueType(field, payload)\n\n if (fieldShouldBeLocalized({ field, parentIsLocalized }) && payload.config.localization) {\n schemaToReturn = {\n _id: false,\n type: payload.config.localization.localeCodes.reduce((locales, locale) => {\n let localeSchema: { [key: string]: any } = {}\n\n if (hasManyRelations) {\n localeSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\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({ buildSchemaOptions, field, parentIsLocalized }),\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({ buildSchemaOptions, field, parentIsLocalized }),\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({ buildSchemaOptions, field, parentIsLocalized }),\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\nconst richText: FieldSchemaGenerator<RichTextField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: mongoose.Schema.Types.Mixed,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst row: FieldSchemaGenerator<RowField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n schemaBuildState,\n): void => {\n field.fields.forEach((subField: Field) => {\n if (fieldIsVirtual(subField)) {\n return\n }\n\n const addFieldSchema = getSchemaGenerator(subField.type)\n\n if (addFieldSchema) {\n addFieldSchema(\n subField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n schemaBuildState,\n )\n }\n })\n}\n\nconst select: FieldSchemaGenerator<SelectField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\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 as unknown[]).push(null)\n }\n\n schema.add({\n [field.name]: localizeSchema(\n field,\n field.hasMany ? [baseSchema] : baseSchema,\n payload.config.localization,\n parentIsLocalized,\n ),\n })\n}\n\nconst tabs: FieldSchemaGenerator<TabsField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n schemaBuildState,\n): void => {\n field.tabs.forEach((tab) => {\n if (tabHasName(tab)) {\n if (fieldIsVirtual(tab)) {\n return\n }\n const baseSchema = {\n type: buildSchema({\n buildSchemaOptions: {\n disableUnique: buildSchemaOptions.disableUnique,\n draftsEnabled: buildSchemaOptions.draftsEnabled,\n options: {\n _id: false,\n id: false,\n minimize: false,\n },\n },\n configFields: tab.fields,\n isVersion: schemaBuildState.isVersion,\n parentIsLocalized: parentIsLocalized || tab.localized,\n payload,\n schemaBuildContext: schemaBuildState.context,\n schemaPath: `${schemaBuildState.path}/tab:${tab.name}`,\n }),\n }\n\n schema.add({\n [tab.name]: localizeSchema(tab, baseSchema, payload.config.localization, parentIsLocalized),\n })\n } else {\n tab.fields.forEach((subField: Field) => {\n if (fieldIsVirtual(subField)) {\n return\n }\n const addFieldSchema = getSchemaGenerator(subField.type)\n\n if (addFieldSchema) {\n addFieldSchema(\n subField,\n schema,\n payload,\n buildSchemaOptions,\n (parentIsLocalized || tab.localized) ?? false,\n schemaBuildState,\n )\n }\n })\n }\n })\n}\n\nconst text: FieldSchemaGenerator<TextField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: field.hasMany ? [String] : String,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst slug: FieldSchemaGenerator<SlugField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema: SchemaTypeOptions<any> = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: String,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst textarea: FieldSchemaGenerator<TextareaField> = (\n field: TextareaField,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\n): void => {\n const baseSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\n type: String,\n }\n\n schema.add({\n [field.name]: localizeSchema(field, baseSchema, payload.config.localization, parentIsLocalized),\n })\n}\n\nconst upload: FieldSchemaGenerator<UploadField> = (\n field,\n schema,\n payload,\n buildSchemaOptions,\n parentIsLocalized,\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 (fieldShouldBeLocalized({ field, parentIsLocalized }) && payload.config.localization) {\n schemaToReturn = {\n _id: false,\n type: payload.config.localization.localeCodes.reduce((locales, locale) => {\n let localeSchema: { [key: string]: any } = {}\n\n if (hasManyRelations) {\n localeSchema = {\n ...formatBaseSchema({ buildSchemaOptions, field, parentIsLocalized }),\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({ buildSchemaOptions, field, parentIsLocalized }),\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({ buildSchemaOptions, field, parentIsLocalized }),\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({ buildSchemaOptions, field, parentIsLocalized }),\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\nconst getSchemaGenerator = (fieldType: string): FieldSchemaGenerator | null => {\n if (fieldType in fieldToSchemaMap) {\n return fieldToSchemaMap[fieldType as keyof typeof fieldToSchemaMap] as FieldSchemaGenerator\n }\n\n return null\n}\n\nconst fieldToSchemaMap = {\n slug,\n array,\n blocks,\n checkbox,\n code,\n collapsible,\n date,\n email,\n group,\n json,\n number,\n point,\n radio,\n relationship,\n richText,\n row,\n select,\n tabs,\n text,\n textarea,\n upload,\n}\n\nconst getRelationshipValueType = (field: RelationshipField | UploadField, payload: Payload) => {\n if (typeof field.relationTo === 'string') {\n const customIDType = payload.collections[field.relationTo]?.customIDType\n\n if (!customIDType) {\n return mongoose.Schema.Types.ObjectId\n }\n\n if (customIDType === 'number') {\n if (payload.db.useBigIntForNumberIDs) {\n return mongoose.Schema.Types.BigInt\n } else {\n return mongoose.Schema.Types.Number\n }\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","createSchemaBuildContext","fieldAffectsData","fieldIsPresentationalOnly","fieldIsVirtual","fieldShouldBeLocalized","tabHasName","getBlockSchemaCacheKey","formatDefaultValue","field","defaultValue","undefined","formatBaseSchema","buildSchemaOptions","parentIsLocalized","disableUnique","draftsEnabled","indexSortableFields","schema","default","index","unique","required","type","sparse","hidden","localizeSchema","entity","localization","Array","isArray","locales","localeCodes","reduce","localeSchema","locale","_id","localized","buildSchema","args","configFields","flattenedFields","payload","schemaBuildContext","schemaBuildState","context","isVersion","path","schemaPath","allowIDField","options","fields","schemaFields","fieldsToSearch","idField","find","name","db","useBigIntForNumberIDs","Schema","Types","BigInt","Number","String","filter","forEach","addFieldSchema","getSchemaGenerator","compoundIndexes","indexDefinition","pathHasLocalized","config","localizedPath","replace","code","array","baseSchema","id","minimize","add","blocks","fieldSchema","discriminatorKey","blockItem","block","isLocalized","Boolean","isReference","fieldPath","blockSchema","getOrCreate","build","template","blockField","slug","cacheKey","blockSlug","definition","localeCode","discriminator","checkbox","collapsible","subField","date","Date","email","group","formattedBaseSchema","json","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","fieldType","fieldToSchemaMap","customIDType","collections","ObjectId","some"],"mappings":"AAEA,OAAOA,cAAc,WAAU;AAgC/B,SAASC,wBAAwB,QAAQ,mBAAkB;AAC3D,SACEC,gBAAgB,EAChBC,yBAAyB,EACzBC,cAAc,EACdC,sBAAsB,EACtBC,UAAU,QACL,iBAAgB;AAIvB,SAASC,sBAAsB,QAAQ,0BAAyB;AAyBhE;;;CAGC,GACD,MAAMC,qBAAqB,CAACC,QAC1B,OAAOA,MAAMC,YAAY,KAAK,eAAe,OAAOD,MAAMC,YAAY,KAAK,aACvED,MAAMC,YAAY,GAClBC;AAEN,MAAMC,mBAAmB,CAAC,EACxBC,kBAAkB,EAClBJ,KAAK,EACLK,iBAAiB,EAKlB;IACC,MAAM,EAAEC,aAAa,EAAEC,aAAa,EAAEC,mBAAmB,EAAE,GAAGJ;IAC9D,MAAMK,SA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|
-
{"version":3,"sources":["../../src/predefinedMigrations/migrateSizesToVariants.ts"],"sourcesContent":["import type {\n Collection,\n CreateIndexesOptions,\n Document,\n IndexDescriptionInfo,\n IndexDirection,\n} from 'mongodb'\nimport type { Payload, PayloadRequest } from 'payload'\n\nimport { isDeepStrictEqual } from 'node:util'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { getSession } from '../utilities/getSession.js'\n\n/** Mongo error codes for an index that conflicts with an existing index. */\nconst INDEX_CONFLICT_CODES = new Set([85, 86])\n/** Mongo error code for a collection that hasn't been created yet. */\nconst NAMESPACE_NOT_FOUND_CODE = 26\nconst GENERATED_VARIANT_METADATA_FIELDS = new Set([\n 'filename',\n 'filesize',\n 'height',\n 'mimeType',\n 'url',\n 'width',\n])\n\n/**\n * Moves every upload collection's stored image sizes between the legacy `sizes` field and\n * `variants`, on each collection and its versions collection (`version.sizes`). Uses `$rename`,\n * so no document is rewritten beyond the renamed key, and re-keys the indexes on those fields.\n * Documents that are already renamed are left as they are, so it's safe to re-run.\n */\nexport async function migrateSizesToVariants({\n direction = 'up',\n payload,\n req,\n}: {\n direction?: 'down' | 'up'\n payload: Payload\n req?: Partial<PayloadRequest>\n}): Promise<void> {\n const adapter = payload.db as unknown as MongooseAdapter\n const session = await getSession(adapter, req)\n const [from, to] = direction === 'up' ? ['sizes', 'variants'] : ['variants', 'sizes']\n\n const targets: {\n collection: Collection\n expectedVariantNames: string[]\n fromPath: string\n toPath: string\n }[] = []\n\n for (const collection of payload.config.collections) {\n if (!collection.upload) {\n continue\n }\n\n const upload = typeof collection.upload === 'object' ? collection.upload : undefined\n const expectedVariantNames = (upload?.variants ?? []).map(({ name }) => name)\n\n targets.push({\n collection: adapter.collections[collection.slug]!.collection,\n expectedVariantNames,\n fromPath: from,\n toPath: to,\n })\n\n if (collection.versions && adapter.versions[collection.slug]) {\n targets.push({\n collection: adapter.versions[collection.slug]!.collection,\n expectedVariantNames,\n fromPath: `version.${from}`,\n toPath: `version.${to}`,\n })\n }\n }\n\n for (const { collection, expectedVariantNames, fromPath, toPath } of targets) {\n const [sourceData, directCollision] = await Promise.all([\n collection.findOne({ [fromPath]: { $exists: true } }, { projection: { _id: 1 } }),\n collection.findOne(\n { [fromPath]: { $exists: true }, [toPath]: { $exists: true } },\n { projection: { _id: 1 } },\n ),\n ])\n\n if (\n sourceData &&\n (directCollision ||\n (await findUnexpectedDestinationData({ collection, expectedVariantNames, toPath })))\n ) {\n throw new Error(\n `Cannot run the sizes-to-variants migration because collection \"${collection.collectionName}\" contains both \"${fromPath}\" and \"${toPath}\" data. Move or rename the existing destination data before running this migration.`,\n )\n }\n }\n\n // Index changes can't be part of a multi-document transaction, and one made after the\n // migration's transaction has written to a collection aborts it. A transaction's snapshot starts\n // at its first operation, so re-keying every index before any transactional write is safe.\n for (const target of targets) {\n await rekeyIndexes(target)\n }\n\n for (const { collection, fromPath, toPath } of targets) {\n const result = await collection.updateMany(\n { [fromPath]: { $exists: true }, [toPath]: { $exists: false } },\n { $rename: { [fromPath]: toPath } },\n { session },\n )\n\n payload.logger.info({\n msg: `sizes-to-variants (${direction}): renamed ${fromPath} on ${result.modifiedCount} document(s) in \"${collection.collectionName}\"`,\n })\n }\n}\n\nasync function findUnexpectedDestinationData({\n collection,\n expectedVariantNames,\n toPath,\n}: {\n collection: Collection\n expectedVariantNames: string[]\n toPath: string\n}): Promise<Document | null> {\n const expectedVariantNameSet = new Set(expectedVariantNames)\n const cursor = collection.find(\n { [toPath]: { $exists: true } },\n { projection: { _id: 1, [toPath]: 1 } },\n )\n\n try {\n for await (const document of cursor) {\n const destinationData = getDocumentPath({ document, path: toPath })\n\n if (hasUnexpectedVariantData({ destinationData, expectedVariantNameSet })) {\n return document\n }\n }\n } finally {\n await cursor.close()\n }\n\n return null\n}\n\nfunction getDocumentPath({ document, path }: { document: Document; path: string }): unknown {\n return path.split('.').reduce<unknown>((value, pathSegment) => {\n if (!isRecord(value)) {\n return undefined\n }\n\n return value[pathSegment]\n }, document)\n}\n\nfunction hasUnexpectedVariantData({\n destinationData,\n expectedVariantNameSet,\n}: {\n destinationData: unknown\n expectedVariantNameSet: Set<string>\n}): boolean {\n if (!isRecord(destinationData)) {\n return destinationData !== null && destinationData !== undefined\n }\n\n for (const [variantName, variantData] of Object.entries(destinationData)) {\n if (!expectedVariantNameSet.has(variantName)) {\n return true\n }\n\n if (variantData === null || variantData === undefined) {\n continue\n }\n\n if (\n !isRecord(variantData) ||\n Object.keys(variantData).some(\n (metadataFieldName) => !GENERATED_VARIANT_METADATA_FIELDS.has(metadataFieldName),\n )\n ) {\n return true\n }\n }\n\n return false\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n}\n\nasync function rekeyIndexes({\n collection,\n fromPath,\n toPath,\n}: {\n collection: Collection\n fromPath: string\n toPath: string\n}): Promise<void> {\n let indexes: IndexDescriptionInfo[]\n\n try {\n indexes = await collection.indexes()\n } catch (err) {\n if ((err as { code?: number }).code === NAMESPACE_NOT_FOUND_CODE) {\n return\n }\n\n throw err\n }\n\n for (const index of indexes) {\n const sourceKeys = getIndexKeysForCreate({ fromPath, index, toPath: fromPath })\n\n if (!Object.keys(sourceKeys).some((key) => isPathAtOrBelow({ key, path: fromPath }))) {\n continue\n }\n\n const rekeyedKeys = getIndexKeysForCreate({ fromPath, index, toPath })\n const destinationOptions = getDestinationIndexOptions({ fromPath, index, toPath })\n\n if (index.weights && '_fts' in index.key && '_ftsx' in index.key) {\n await rekeyTextIndex({\n collection,\n destinationOptions,\n index,\n rekeyedKeys,\n sourceKeys,\n })\n continue\n }\n\n try {\n await collection.createIndex(rekeyedKeys, destinationOptions)\n } catch (err) {\n if (!INDEX_CONFLICT_CODES.has((err as { code?: number }).code ?? 0)) {\n throw err\n }\n\n const destinationIndex = (await collection.indexes()).find((candidate) =>\n isDeepStrictEqual(\n getIndexKeysForCreate({ fromPath: toPath, index: candidate, toPath }),\n rekeyedKeys,\n ),\n )\n const existingDestinationOptions = destinationIndex\n ? getDestinationIndexOptions({\n fromPath: toPath,\n index: destinationIndex,\n toPath,\n })\n : undefined\n\n if (!destinationIndex || !isDeepStrictEqual(existingDestinationOptions, destinationOptions)) {\n throw err\n }\n }\n\n await collection.dropIndex(index.name!)\n }\n}\n\nasync function rekeyTextIndex({\n collection,\n destinationOptions,\n index,\n rekeyedKeys,\n sourceKeys,\n}: {\n collection: Collection\n destinationOptions: CreateIndexesOptions\n index: IndexDescriptionInfo\n rekeyedKeys: Record<string, IndexDirection>\n sourceKeys: Record<string, IndexDirection>\n}): Promise<void> {\n if (!index.name) {\n throw new Error('Cannot re-key an unnamed MongoDB text index.')\n }\n\n const sourceOptions: CreateIndexesOptions = {\n ...getDestinationIndexOptions({ fromPath: '', index, toPath: '' }),\n name: index.name,\n }\n\n await collection.dropIndex(index.name)\n\n try {\n await collection.createIndex(rekeyedKeys, destinationOptions)\n } catch (err) {\n try {\n await collection.createIndex(sourceKeys, sourceOptions)\n } catch (restoreErr) {\n throw new AggregateError(\n [err, restoreErr],\n `Failed to create the replacement for MongoDB text index \"${index.name}\" and failed to restore the source index.`,\n )\n }\n\n throw err\n }\n}\n\nfunction getIndexKeysForCreate({\n fromPath,\n index,\n toPath,\n}: {\n fromPath: string\n index: IndexDescriptionInfo\n toPath: string\n}): Record<string, IndexDirection> {\n const keys: [string, IndexDirection][] = []\n const hasInternalTextKeys = '_fts' in index.key && '_ftsx' in index.key\n\n for (const [key, value] of Object.entries(index.key)) {\n if (hasInternalTextKeys && key === '_fts') {\n for (const textPath of Object.keys(index.weights ?? {})) {\n keys.push([rekeyPath({ fromPath, path: textPath, toPath }), 'text'])\n }\n continue\n }\n\n if (hasInternalTextKeys && key === '_ftsx') {\n continue\n }\n\n keys.push([rekeyPath({ fromPath, path: key, toPath }), value])\n }\n\n return Object.fromEntries(keys)\n}\n\nfunction getDestinationIndexOptions({\n fromPath,\n index,\n toPath,\n}: {\n fromPath: string\n index: IndexDescriptionInfo\n toPath: string\n}): CreateIndexesOptions {\n const options: CreateIndexesOptions = {\n '2dsphereIndexVersion': index['2dsphereIndexVersion'],\n background: index.background,\n bits: index.bits,\n bucketSize: index.bucketSize,\n collation: index.collation,\n default_language: index.default_language,\n expireAfterSeconds: index.expireAfterSeconds,\n hidden: index.hidden,\n language_override: index.language_override,\n max: index.max,\n min: index.min,\n partialFilterExpression: index.partialFilterExpression\n ? rekeyDocumentPaths({ document: index.partialFilterExpression, fromPath, toPath })\n : undefined,\n sparse: index.sparse,\n storageEngine: index.storageEngine,\n textIndexVersion: index.textIndexVersion,\n unique: index.unique,\n weights: index.weights\n ? rekeyDocumentPaths({ document: index.weights, fromPath, toPath })\n : undefined,\n wildcardProjection: index.wildcardProjection\n ? rekeyDocumentPaths({ document: index.wildcardProjection, fromPath, toPath })\n : undefined,\n }\n\n return Object.fromEntries(\n Object.entries(options).filter(([, value]) => value !== undefined),\n ) as CreateIndexesOptions\n}\n\nfunction rekeyDocumentPaths({\n document,\n fromPath,\n toPath,\n}: {\n document: Document\n fromPath: string\n toPath: string\n}): Document {\n return Object.fromEntries(\n Object.entries(document).map(([key, value]) => [\n rekeyPath({ fromPath, path: key, toPath }),\n rekeyDocumentValue({ fromPath, toPath, value }),\n ]),\n )\n}\n\nfunction isPathAtOrBelow({ key, path }: { key: string; path: string }): boolean {\n return key === path || key.startsWith(`${path}.`)\n}\n\nfunction rekeyPath({\n fromPath,\n path,\n toPath,\n}: {\n fromPath: string\n path: string\n toPath: string\n}): string {\n return isPathAtOrBelow({ key: path, path: fromPath })\n ? `${toPath}${path.slice(fromPath.length)}`\n : path\n}\n\nfunction rekeyDocumentValue({\n fromPath,\n toPath,\n value,\n}: {\n fromPath: string\n toPath: string\n value: unknown\n}): unknown {\n if (Array.isArray(value)) {\n return value.map((item) => rekeyDocumentValue({ fromPath, toPath, value: item }))\n }\n\n if (\n value !== null &&\n typeof value === 'object' &&\n (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null)\n ) {\n return rekeyDocumentPaths({ document: value as Document, fromPath, toPath })\n }\n\n return value\n}\n"],"names":["isDeepStrictEqual","getSession","INDEX_CONFLICT_CODES","Set","NAMESPACE_NOT_FOUND_CODE","GENERATED_VARIANT_METADATA_FIELDS","migrateSizesToVariants","direction","payload","req","adapter","db","session","from","to","targets","collection","config","collections","upload","undefined","expectedVariantNames","variants","map","name","push","slug","fromPath","toPath","versions","sourceData","directCollision","Promise","all","findOne","$exists","projection","_id","findUnexpectedDestinationData","Error","collectionName","target","rekeyIndexes","result","updateMany","$rename","logger","info","msg","modifiedCount","expectedVariantNameSet","cursor","find","document","destinationData","getDocumentPath","path","hasUnexpectedVariantData","close","split","reduce","value","pathSegment","isRecord","variantName","variantData","Object","entries","has","keys","some","metadataFieldName","Array","isArray","indexes","err","code","index","sourceKeys","getIndexKeysForCreate","key","isPathAtOrBelow","rekeyedKeys","destinationOptions","getDestinationIndexOptions","weights","rekeyTextIndex","createIndex","destinationIndex","candidate","existingDestinationOptions","dropIndex","sourceOptions","restoreErr","AggregateError","hasInternalTextKeys","textPath","rekeyPath","fromEntries","options","background","bits","bucketSize","collation","default_language","expireAfterSeconds","hidden","language_override","max","min","partialFilterExpression","rekeyDocumentPaths","sparse","storageEngine","textIndexVersion","unique","wildcardProjection","filter","rekeyDocumentValue","startsWith","slice","length","item","getPrototypeOf","prototype"],"mappings":"AASA,SAASA,iBAAiB,QAAQ,YAAW;AAI7C,SAASC,UAAU,QAAQ,6BAA4B;AAEvD,0EAA0E,GAC1E,MAAMC,uBAAuB,IAAIC,IAAI;IAAC;IAAI;CAAG;AAC7C,oEAAoE,GACpE,MAAMC,2BAA2B;AACjC,MAAMC,oCAAoC,IAAIF,IAAI;IAChD;IACA;IACA;IACA;IACA;IACA;CACD;AAED;;;;;CAKC,GACD,OAAO,eAAeG,uBAAuB,EAC3CC,YAAY,IAAI,EAChBC,OAAO,EACPC,GAAG,EAKJ;IACC,MAAMC,UAAUF,QAAQG,EAAE;IAC1B,MAAMC,UAAU,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nB,MAAM,GAAK;YAC7CoC,UAAU;gBAAEtE;gBAAU6B,MAAMwB;gBAAKpD;YAAO;YACxC0F,mBAAmB;gBAAE3F;gBAAUC;gBAAQiC;YAAM;SAC9C;AAEL;AAEA,SAASoB,gBAAgB,EAAED,GAAG,EAAExB,IAAI,EAAiC;IACnE,OAAOwB,QAAQxB,QAAQwB,IAAIuC,UAAU,CAAC,GAAG/D,KAAK,CAAC,CAAC;AAClD;AAEA,SAASyC,UAAU,EACjBtE,QAAQ,EACR6B,IAAI,EACJ5B,MAAM,EAKP;IACC,OAAOqD,gBAAgB;QAAED,KAAKxB;QAAMA,MAAM7B;IAAS,KAC/C,GAAGC,SAAS4B,KAAKgE,KAAK,CAAC7F,SAAS8F,MAAM,GAAG,GACzCjE;AACN;AAEA,SAAS8D,mBAAmB,EAC1B3F,QAAQ,EACRC,MAAM,EACNiC,KAAK,EAKN;IACC,IAAIW,MAAMC,OAAO,CAACZ,QAAQ;QACxB,OAAOA,MAAMtC,GAAG,CAAC,CAACmG,OAASJ,mBAAmB;gBAAE3F;gBAAUC;gBAAQiC,OAAO6D;YAAK;IAChF;IAEA,IACE7D,UAAU,QACV,OAAOA,UAAU,YAChBK,CAAAA,OAAOyD,cAAc,CAAC9D,WAAWK,OAAO0D,SAAS,IAAI1D,OAAOyD,cAAc,CAAC9D,WAAW,IAAG,GAC1F;QACA,OAAOkD,mBAAmB;YAAE1D,UAAUQ;YAAmBlC;YAAUC;QAAO;IAC5E;IAEA,OAAOiC;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../src/predefinedMigrations/migrateSizesToVariants.ts"],"sourcesContent":["import type {\n Collection,\n CreateIndexesOptions,\n Document,\n IndexDescriptionInfo,\n IndexDirection,\n} from 'mongodb'\nimport type { Payload, PayloadRequest } from 'payload'\n\nimport { isDeepStrictEqual } from 'node:util'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { getSession } from '../utilities/getSession.js'\n\n/** Mongo error codes for an index that conflicts with an existing index. */\nconst INDEX_CONFLICT_CODES = new Set([85, 86])\n/** Mongo error code for a collection that hasn't been created yet. */\nconst NAMESPACE_NOT_FOUND_CODE = 26\nconst GENERATED_VARIANT_METADATA_FIELDS = new Set([\n 'filename',\n 'filesize',\n 'height',\n 'mimeType',\n 'url',\n 'width',\n])\n\n/**\n * Moves every upload collection's stored image sizes between the legacy `sizes` field and\n * `variants`, on each collection and its versions collection (`version.sizes`). Uses `$rename`,\n * so no document is rewritten beyond the renamed key, and re-keys the indexes on those fields.\n * Documents that are already renamed are left as they are, so it's safe to re-run.\n */\nexport async function migrateSizesToVariants({\n direction = 'up',\n payload,\n req,\n}: {\n direction?: 'down' | 'up'\n payload: Payload\n req?: Partial<PayloadRequest>\n}): Promise<void> {\n const adapter = payload.db as unknown as MongooseAdapter\n const session = await getSession(adapter, req)\n const [from, to] = direction === 'up' ? ['sizes', 'variants'] : ['variants', 'sizes']\n\n const targets: {\n collection: Collection\n expectedVariantNames: string[]\n fromPath: string\n toPath: string\n }[] = []\n\n for (const collection of payload.config.collections) {\n if (!collection.upload) {\n continue\n }\n\n const upload = typeof collection.upload === 'object' ? collection.upload : undefined\n const expectedVariantNames = (upload?.variants ?? []).map(({ name }) => name)\n\n targets.push({\n collection: adapter.collections[collection.slug]!.collection,\n expectedVariantNames,\n fromPath: from,\n toPath: to,\n })\n\n if (collection.versions && adapter.versions[collection.slug]) {\n targets.push({\n collection: adapter.versions[collection.slug]!.collection,\n expectedVariantNames,\n fromPath: `version.${from}`,\n toPath: `version.${to}`,\n })\n }\n }\n\n for (const { collection, expectedVariantNames, fromPath, toPath } of targets) {\n const [sourceData, directCollision] = await Promise.all([\n collection.findOne({ [fromPath]: { $exists: true } }, { projection: { _id: 1 } }),\n collection.findOne(\n { [fromPath]: { $exists: true }, [toPath]: { $exists: true } },\n { projection: { _id: 1 } },\n ),\n ])\n\n if (\n sourceData &&\n (directCollision ||\n (await findUnexpectedDestinationData({ collection, expectedVariantNames, toPath })))\n ) {\n throw new Error(\n `Cannot run the sizes-to-variants migration because collection \"${collection.collectionName}\" contains both \"${fromPath}\" and \"${toPath}\" data. Move or rename the existing destination data before running this migration.`,\n )\n }\n }\n\n // Index changes can't be part of a multi-document transaction, and one made after the\n // migration's transaction has written to a collection aborts it. A transaction's snapshot starts\n // at its first operation, so re-keying every index before any transactional write is safe.\n for (const target of targets) {\n await rekeyIndexes(target)\n }\n\n for (const { collection, fromPath, toPath } of targets) {\n const result = await collection.updateMany(\n { [fromPath]: { $exists: true }, [toPath]: { $exists: false } },\n { $rename: { [fromPath]: toPath } },\n { session },\n )\n\n payload.logger.info({\n msg: `sizes-to-variants (${direction}): renamed ${fromPath} on ${result.modifiedCount} document(s) in \"${collection.collectionName}\"`,\n })\n }\n}\n\nasync function findUnexpectedDestinationData({\n collection,\n expectedVariantNames,\n toPath,\n}: {\n collection: Collection\n expectedVariantNames: string[]\n toPath: string\n}): Promise<Document | null> {\n const expectedVariantNameSet = new Set(expectedVariantNames)\n const cursor = collection.find(\n { [toPath]: { $exists: true } },\n { projection: { _id: 1, [toPath]: 1 } },\n )\n\n try {\n for await (const document of cursor) {\n const destinationData = getDocumentPath({ document, path: toPath })\n\n if (hasUnexpectedVariantData({ destinationData, expectedVariantNameSet })) {\n return document\n }\n }\n } finally {\n await cursor.close()\n }\n\n return null\n}\n\nfunction getDocumentPath({ document, path }: { document: Document; path: string }): unknown {\n return path.split('.').reduce<unknown>((value, pathSegment) => {\n if (!isRecord(value)) {\n return undefined\n }\n\n return value[pathSegment]\n }, document)\n}\n\nfunction hasUnexpectedVariantData({\n destinationData,\n expectedVariantNameSet,\n}: {\n destinationData: unknown\n expectedVariantNameSet: Set<string>\n}): boolean {\n if (!isRecord(destinationData)) {\n return destinationData !== null && destinationData !== undefined\n }\n\n for (const [variantName, variantData] of Object.entries(destinationData)) {\n if (!expectedVariantNameSet.has(variantName)) {\n return true\n }\n\n if (variantData === null || variantData === undefined) {\n continue\n }\n\n if (\n !isRecord(variantData) ||\n Object.keys(variantData).some(\n (metadataFieldName) => !GENERATED_VARIANT_METADATA_FIELDS.has(metadataFieldName),\n )\n ) {\n return true\n }\n }\n\n return false\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n}\n\nasync function rekeyIndexes({\n collection,\n fromPath,\n toPath,\n}: {\n collection: Collection\n fromPath: string\n toPath: string\n}): Promise<void> {\n let indexes: IndexDescriptionInfo[]\n\n try {\n indexes = await collection.indexes()\n } catch (err) {\n if ((err as { code?: number }).code === NAMESPACE_NOT_FOUND_CODE) {\n return\n }\n\n throw err\n }\n\n for (const index of indexes) {\n const sourceKeys = getIndexKeysForCreate({ fromPath, index, toPath: fromPath })\n\n if (!Object.keys(sourceKeys).some((key) => isPathAtOrBelow({ key, path: fromPath }))) {\n continue\n }\n\n const rekeyedKeys = getIndexKeysForCreate({ fromPath, index, toPath })\n const destinationOptions = getDestinationIndexOptions({ fromPath, index, toPath })\n\n if (index.weights && '_fts' in index.key && '_ftsx' in index.key) {\n await rekeyTextIndex({\n collection,\n destinationOptions,\n index,\n rekeyedKeys,\n sourceKeys,\n })\n continue\n }\n\n try {\n await collection.createIndex(rekeyedKeys, destinationOptions)\n } catch (err) {\n if (!INDEX_CONFLICT_CODES.has((err as { code?: number }).code ?? 0)) {\n throw err\n }\n\n const destinationIndex = (await collection.indexes()).find((candidate) =>\n isDeepStrictEqual(\n getIndexKeysForCreate({ fromPath: toPath, index: candidate, toPath }),\n rekeyedKeys,\n ),\n )\n const existingDestinationOptions = destinationIndex\n ? getDestinationIndexOptions({\n fromPath: toPath,\n index: destinationIndex,\n toPath,\n })\n : undefined\n\n if (!destinationIndex || !isDeepStrictEqual(existingDestinationOptions, destinationOptions)) {\n throw err\n }\n }\n\n await collection.dropIndex(index.name!)\n }\n}\n\nasync function rekeyTextIndex({\n collection,\n destinationOptions,\n index,\n rekeyedKeys,\n sourceKeys,\n}: {\n collection: Collection\n destinationOptions: CreateIndexesOptions\n index: IndexDescriptionInfo\n rekeyedKeys: Record<string, IndexDirection>\n sourceKeys: Record<string, IndexDirection>\n}): Promise<void> {\n if (!index.name) {\n throw new Error('Cannot re-key an unnamed MongoDB text index.')\n }\n\n const sourceOptions: CreateIndexesOptions = {\n ...getDestinationIndexOptions({ fromPath: '', index, toPath: '' }),\n name: index.name,\n }\n\n await collection.dropIndex(index.name)\n\n try {\n await collection.createIndex(rekeyedKeys, destinationOptions)\n } catch (err) {\n try {\n await collection.createIndex(sourceKeys, sourceOptions)\n } catch (restoreErr) {\n throw new AggregateError(\n [err, restoreErr],\n `Failed to create the replacement for MongoDB text index \"${index.name}\" and failed to restore the source index.`,\n )\n }\n\n throw err\n }\n}\n\nfunction getIndexKeysForCreate({\n fromPath,\n index,\n toPath,\n}: {\n fromPath: string\n index: IndexDescriptionInfo\n toPath: string\n}): Record<string, IndexDirection> {\n const keys: [string, IndexDirection][] = []\n const hasInternalTextKeys = '_fts' in index.key && '_ftsx' in index.key\n\n for (const [key, value] of Object.entries(index.key)) {\n if (hasInternalTextKeys && key === '_fts') {\n for (const textPath of Object.keys(index.weights ?? {})) {\n keys.push([rekeyPath({ fromPath, path: textPath, toPath }), 'text'])\n }\n continue\n }\n\n if (hasInternalTextKeys && key === '_ftsx') {\n continue\n }\n\n keys.push([rekeyPath({ fromPath, path: key, toPath }), value])\n }\n\n return Object.fromEntries(keys)\n}\n\nfunction getDestinationIndexOptions({\n fromPath,\n index,\n toPath,\n}: {\n fromPath: string\n index: IndexDescriptionInfo\n toPath: string\n}): CreateIndexesOptions {\n const options: CreateIndexesOptions = {\n '2dsphereIndexVersion': index['2dsphereIndexVersion'],\n background: index.background,\n bits: index.bits,\n bucketSize: index.bucketSize,\n collation: index.collation,\n default_language: index.default_language,\n expireAfterSeconds: index.expireAfterSeconds,\n hidden: index.hidden,\n language_override: index.language_override,\n max: index.max,\n min: index.min,\n partialFilterExpression: index.partialFilterExpression\n ? rekeyDocumentPaths({ document: index.partialFilterExpression, fromPath, toPath })\n : undefined,\n sparse: index.sparse,\n storageEngine: index.storageEngine,\n textIndexVersion: index.textIndexVersion,\n unique: index.unique,\n weights: index.weights\n ? rekeyDocumentPaths({ document: index.weights, fromPath, toPath })\n : undefined,\n wildcardProjection: index.wildcardProjection\n ? rekeyDocumentPaths({ document: index.wildcardProjection, fromPath, toPath })\n : undefined,\n }\n\n return Object.fromEntries(Object.entries(options).filter(([, value]) => value !== undefined))\n}\n\nfunction rekeyDocumentPaths({\n document,\n fromPath,\n toPath,\n}: {\n document: Document\n fromPath: string\n toPath: string\n}): Document {\n return Object.fromEntries(\n Object.entries(document).map(([key, value]) => [\n rekeyPath({ fromPath, path: key, toPath }),\n rekeyDocumentValue({ fromPath, toPath, value }),\n ]),\n )\n}\n\nfunction isPathAtOrBelow({ key, path }: { key: string; path: string }): boolean {\n return key === path || key.startsWith(`${path}.`)\n}\n\nfunction rekeyPath({\n fromPath,\n path,\n toPath,\n}: {\n fromPath: string\n path: string\n toPath: string\n}): string {\n return isPathAtOrBelow({ key: path, path: fromPath })\n ? `${toPath}${path.slice(fromPath.length)}`\n : path\n}\n\nfunction rekeyDocumentValue({\n fromPath,\n toPath,\n value,\n}: {\n fromPath: string\n toPath: string\n value: unknown\n}): unknown {\n if (Array.isArray(value)) {\n return value.map((item) => rekeyDocumentValue({ fromPath, toPath, value: item }))\n }\n\n if (\n value !== null &&\n typeof value === 'object' &&\n (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null)\n ) {\n return rekeyDocumentPaths({ document: value, fromPath, toPath })\n }\n\n return value\n}\n"],"names":["isDeepStrictEqual","getSession","INDEX_CONFLICT_CODES","Set","NAMESPACE_NOT_FOUND_CODE","GENERATED_VARIANT_METADATA_FIELDS","migrateSizesToVariants","direction","payload","req","adapter","db","session","from","to","targets","collection","config","collections","upload","undefined","expectedVariantNames","variants","map","name","push","slug","fromPath","toPath","versions","sourceData","directCollision","Promise","all","findOne","$exists","projection","_id","findUnexpectedDestinationData","Error","collectionName","target","rekeyIndexes","result","updateMany","$rename","logger","info","msg","modifiedCount","expectedVariantNameSet","cursor","find","document","destinationData","getDocumentPath","path","hasUnexpectedVariantData","close","split","reduce","value","pathSegment","isRecord","variantName","variantData","Object","entries","has","keys","some","metadataFieldName","Array","isArray","indexes","err","code","index","sourceKeys","getIndexKeysForCreate","key","isPathAtOrBelow","rekeyedKeys","destinationOptions","getDestinationIndexOptions","weights","rekeyTextIndex","createIndex","destinationIndex","candidate","existingDestinationOptions","dropIndex","sourceOptions","restoreErr","AggregateError","hasInternalTextKeys","textPath","rekeyPath","fromEntries","options","background","bits","bucketSize","collation","default_language","expireAfterSeconds","hidden","language_override","max","min","partialFilterExpression","rekeyDocumentPaths","sparse","storageEngine","textIndexVersion","unique","wildcardProjection","filter","rekeyDocumentValue","startsWith","slice","length","item","getPrototypeOf","prototype"],"mappings":"AASA,SAASA,iBAAiB,QAAQ,YAAW;AAI7C,SAASC,UAAU,QAAQ,6BAA4B;AAEvD,0EAA0E,GAC1E,MAAMC,uBAAuB,IAAIC,IAAI;IAAC;IAAI;CAAG;AAC7C,oEAAoE,GACpE,MAAMC,2BAA2B;AACjC,MAAMC,oCAAoC,IAAIF,IAAI;IAChD;IACA;IACA;IACA;IACA;IACA;CACD;AAED;;;;;CAKC,GACD,OAAO,eAAeG,uBAAuB,EAC3CC,YAAY,IAAI,EAChBC,OAAO,EACPC,GAAG,EAKJ;IACC,MAAMC,UAAUF,QAAQG,EAAE;IAC1B,MAAMC,UAAU,MAAMX,WAAWS,SAASD;IAC1C,MAAM,CAACI,MAAMC,GAAG,GAAGP,cAAc,OAAO;QAAC;QAAS;KAAW,GAAG;QAAC;QAAY;KAAQ;IAErF,MAAMQ,UAKA,EAAE;IAER,KAAK,MAAMC,cAAcR,QAAQS,MAAM,CAACC,WAAW,CAAE;QACnD,IAAI,CAACF,WAAWG,MAAM,EAAE;YACtB;QACF;QAEA,MAAMA,SAAS,OAAOH,WAAWG,MAAM,KAAK,WAAWH,WAAWG,MAAM,G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B,IAAI,EACJ5B,MAAM,EAKP;IACC,OAAOqD,gBAAgB;QAAED,KAAKxB;QAAMA,MAAM7B;IAAS,KAC/C,GAAGC,SAAS4B,KAAKgE,KAAK,CAAC7F,SAAS8F,MAAM,GAAG,GACzCjE;AACN;AAEA,SAAS8D,mBAAmB,EAC1B3F,QAAQ,EACRC,MAAM,EACNiC,KAAK,EAKN;IACC,IAAIW,MAAMC,OAAO,CAACZ,QAAQ;QACxB,OAAOA,MAAMtC,GAAG,CAAC,CAACmG,OAASJ,mBAAmB;gBAAE3F;gBAAUC;gBAAQiC,OAAO6D;YAAK;IAChF;IAEA,IACE7D,UAAU,QACV,OAAOA,UAAU,YAChBK,CAAAA,OAAOyD,cAAc,CAAC9D,WAAWK,OAAO0D,SAAS,IAAI1D,OAAOyD,cAAc,CAAC9D,WAAW,IAAG,GAC1F;QACA,OAAOkD,mBAAmB;YAAE1D,UAAUQ;YAAOlC;YAAUC;QAAO;IAChE;IAEA,OAAOiC;AACT"}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import type { FlattenedField, Payload,
|
|
2
|
-
export declare function buildAndOrConditions({
|
|
3
|
-
branch?: false | string;
|
|
1
|
+
import type { FlattenedField, Payload, Where } from 'payload';
|
|
2
|
+
export declare function buildAndOrConditions({ collectionSlug, fields, globalSlug, locale, parentIsLocalized, payload, where, }: {
|
|
4
3
|
collectionSlug?: string;
|
|
5
4
|
fields: FlattenedField[];
|
|
6
5
|
globalSlug?: string;
|
|
7
6
|
locale?: string;
|
|
8
7
|
parentIsLocalized: boolean;
|
|
9
8
|
payload: Payload;
|
|
10
|
-
req?: Partial<PayloadRequest>;
|
|
11
9
|
where: Where[];
|
|
12
10
|
}): Promise<Record<string, unknown>[]>;
|
|
13
11
|
//# sourceMappingURL=buildAndOrConditions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildAndOrConditions.d.ts","sourceRoot":"","sources":["../../src/queries/buildAndOrConditions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"buildAndOrConditions.d.ts","sourceRoot":"","sources":["../../src/queries/buildAndOrConditions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAI7D,wBAAsB,oBAAoB,CAAC,EACzC,cAAc,EACd,MAAM,EACN,UAAU,EACV,MAAM,EACN,iBAAiB,EACjB,OAAO,EACP,KAAK,GACN,EAAE;IACD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,iBAAiB,EAAE,OAAO,CAAA;IAC1B,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,KAAK,EAAE,CAAA;CACf,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAuBrC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseParams } from './parseParams.js';
|
|
2
|
-
export async function buildAndOrConditions({
|
|
2
|
+
export async function buildAndOrConditions({ collectionSlug, fields, globalSlug, locale, parentIsLocalized, payload, where }) {
|
|
3
3
|
const completedConditions = [];
|
|
4
4
|
// Loop over all AND / OR operations and add them to the AND / OR query param
|
|
5
5
|
// Operations should come through as an array
|
|
@@ -7,14 +7,12 @@ export async function buildAndOrConditions({ branch, collectionSlug, fields, glo
|
|
|
7
7
|
// If the operation is properly formatted as an object
|
|
8
8
|
if (typeof condition === 'object') {
|
|
9
9
|
const result = await parseParams({
|
|
10
|
-
branch,
|
|
11
10
|
collectionSlug,
|
|
12
11
|
fields,
|
|
13
12
|
globalSlug,
|
|
14
13
|
locale,
|
|
15
14
|
parentIsLocalized,
|
|
16
15
|
payload,
|
|
17
|
-
req,
|
|
18
16
|
where: condition
|
|
19
17
|
});
|
|
20
18
|
if (Object.keys(result).length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/queries/buildAndOrConditions.ts"],"sourcesContent":["import type { FlattenedField, Payload,
|
|
1
|
+
{"version":3,"sources":["../../src/queries/buildAndOrConditions.ts"],"sourcesContent":["import type { FlattenedField, Payload, Where } from 'payload'\n\nimport { parseParams } from './parseParams.js'\n\nexport async function buildAndOrConditions({\n collectionSlug,\n fields,\n globalSlug,\n locale,\n parentIsLocalized,\n payload,\n where,\n}: {\n collectionSlug?: string\n fields: FlattenedField[]\n globalSlug?: string\n locale?: string\n parentIsLocalized: boolean\n payload: Payload\n where: Where[]\n}): Promise<Record<string, unknown>[]> {\n const completedConditions = []\n // Loop over all AND / OR operations and add them to the AND / OR query param\n // Operations should come through as an array\n\n for (const condition of where) {\n // If the operation is properly formatted as an object\n if (typeof condition === 'object') {\n const result = await parseParams({\n collectionSlug,\n fields,\n globalSlug,\n locale,\n parentIsLocalized,\n payload,\n where: condition,\n })\n if (Object.keys(result).length > 0) {\n completedConditions.push(result)\n }\n }\n }\n return completedConditions\n}\n"],"names":["parseParams","buildAndOrConditions","collectionSlug","fields","globalSlug","locale","parentIsLocalized","payload","where","completedConditions","condition","result","Object","keys","length","push"],"mappings":"AAEA,SAASA,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,eAAeC,qBAAqB,EACzCC,cAAc,EACdC,MAAM,EACNC,UAAU,EACVC,MAAM,EACNC,iBAAiB,EACjBC,OAAO,EACPC,KAAK,EASN;IACC,MAAMC,sBAAsB,EAAE;IAC9B,6EAA6E;IAC7E,6CAA6C;IAE7C,KAAK,MAAMC,aAAaF,MAAO;QAC7B,sDAAsD;QACtD,IAAI,OAAOE,cAAc,UAAU;YACjC,MAAMC,SAAS,MAAMX,YAAY;gBAC/BE;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC,OAAOE;YACT;YACA,IAAIE,OAAOC,IAAI,CAACF,QAAQG,MAAM,GAAG,GAAG;gBAClCL,oBAAoBM,IAAI,CAACJ;YAC3B;QACF;IACF;IACA,OAAOF;AACT"}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import type { FlattenedField,
|
|
1
|
+
import type { FlattenedField, Where } from 'payload';
|
|
2
2
|
import type { MongooseAdapter } from '../index.js';
|
|
3
|
-
export declare const buildQuery: ({ adapter,
|
|
3
|
+
export declare const buildQuery: ({ adapter, collectionSlug, fields, globalSlug, locale, where, }: {
|
|
4
4
|
adapter: MongooseAdapter;
|
|
5
|
-
branch?: false | string;
|
|
6
5
|
collectionSlug?: string;
|
|
7
6
|
fields: FlattenedField[];
|
|
8
7
|
globalSlug?: string;
|
|
9
8
|
locale?: string;
|
|
10
|
-
req?: Partial<PayloadRequest>;
|
|
11
9
|
where: Where;
|
|
12
10
|
}) => Promise<Record<string, unknown>>;
|
|
13
11
|
//# sourceMappingURL=buildQuery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildQuery.d.ts","sourceRoot":"","sources":["../../src/queries/buildQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"buildQuery.d.ts","sourceRoot":"","sources":["../../src/queries/buildQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAIlD,eAAO,MAAM,UAAU,oEAOpB;IACD,OAAO,EAAE,eAAe,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,KAAK,CAAA;CACb,qCAYA,CAAA"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { parseParams } from './parseParams.js';
|
|
2
|
-
export const buildQuery = async ({ adapter,
|
|
2
|
+
export const buildQuery = async ({ adapter, collectionSlug, fields, globalSlug, locale, where })=>{
|
|
3
3
|
const result = await parseParams({
|
|
4
|
-
branch,
|
|
5
4
|
collectionSlug,
|
|
6
5
|
fields,
|
|
7
6
|
globalSlug,
|
|
8
7
|
locale,
|
|
9
8
|
parentIsLocalized: false,
|
|
10
9
|
payload: adapter.payload,
|
|
11
|
-
req,
|
|
12
10
|
where
|
|
13
11
|
});
|
|
14
12
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/queries/buildQuery.ts"],"sourcesContent":["import type { FlattenedField,
|
|
1
|
+
{"version":3,"sources":["../../src/queries/buildQuery.ts"],"sourcesContent":["import type { FlattenedField, Where } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { parseParams } from './parseParams.js'\n\nexport const buildQuery = async ({\n adapter,\n collectionSlug,\n fields,\n globalSlug,\n locale,\n where,\n}: {\n adapter: MongooseAdapter\n collectionSlug?: string\n fields: FlattenedField[]\n globalSlug?: string\n locale?: string\n where: Where\n}) => {\n const result = await parseParams({\n collectionSlug,\n fields,\n globalSlug,\n locale,\n parentIsLocalized: false,\n payload: adapter.payload,\n where,\n })\n\n return result\n}\n"],"names":["parseParams","buildQuery","adapter","collectionSlug","fields","globalSlug","locale","where","result","parentIsLocalized","payload"],"mappings":"AAIA,SAASA,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,aAAa,OAAO,EAC/BC,OAAO,EACPC,cAAc,EACdC,MAAM,EACNC,UAAU,EACVC,MAAM,EACNC,KAAK,EAQN;IACC,MAAMC,SAAS,MAAMR,YAAY;QAC/BG;QACAC;QACAC;QACAC;QACAG,mBAAmB;QACnBC,SAASR,QAAQQ,OAAO;QACxBH;IACF;IAEA,OAAOC;AACT,EAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FlattenedField, Operator, Payload
|
|
1
|
+
import type { FlattenedField, Operator, Payload } from 'payload';
|
|
2
2
|
type SearchParam = {
|
|
3
3
|
path?: string;
|
|
4
4
|
rawQuery?: unknown;
|
|
@@ -7,8 +7,7 @@ type SearchParam = {
|
|
|
7
7
|
/**
|
|
8
8
|
* Convert the Payload key / value / operator into a MongoDB query
|
|
9
9
|
*/
|
|
10
|
-
export declare function buildSearchParam({
|
|
11
|
-
branch?: false | string;
|
|
10
|
+
export declare function buildSearchParam({ collectionSlug, fields, globalSlug, incomingPath, locale, operator, parentIsLocalized, payload, val, }: {
|
|
12
11
|
collectionSlug?: string;
|
|
13
12
|
fields: FlattenedField[];
|
|
14
13
|
globalSlug?: string;
|
|
@@ -17,7 +16,6 @@ export declare function buildSearchParam({ branch, collectionSlug, fields, globa
|
|
|
17
16
|
operator: Operator;
|
|
18
17
|
parentIsLocalized: boolean;
|
|
19
18
|
payload: Payload;
|
|
20
|
-
req?: Partial<PayloadRequest>;
|
|
21
19
|
val: unknown;
|
|
22
20
|
}): Promise<SearchParam | undefined>;
|
|
23
21
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildSearchParams.d.ts","sourceRoot":"","sources":["../../src/queries/buildSearchParams.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EAEd,QAAQ,EAER,OAAO,
|
|
1
|
+
{"version":3,"file":"buildSearchParams.d.ts","sourceRoot":"","sources":["../../src/queries/buildSearchParams.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EAEd,QAAQ,EAER,OAAO,EACR,MAAM,SAAS,CAAA;AAkBhB,KAAK,WAAW,GAAG;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAMD;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,cAAc,EACd,MAAM,EACN,UAAU,EACV,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,iBAAiB,EACjB,OAAO,EACP,GAAG,GACJ,EAAE;IACD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,QAAQ,CAAA;IAClB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,EAAE,OAAO,CAAA;CACb,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAmZnC"}
|