payload 3.0.0 → 3.0.1-canary.d23ede3
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/bin/generateImportMap/index.d.ts +2 -1
- package/dist/bin/generateImportMap/index.d.ts.map +1 -1
- package/dist/bin/generateImportMap/index.js +7 -6
- package/dist/bin/generateImportMap/index.js.map +1 -1
- package/dist/bin/migrate.d.ts.map +1 -1
- package/dist/bin/migrate.js +12 -2
- package/dist/bin/migrate.js.map +1 -1
- package/dist/database/types.d.ts +1 -0
- package/dist/database/types.d.ts.map +1 -1
- package/dist/database/types.js.map +1 -1
- package/dist/fields/config/sanitize.d.ts.map +1 -1
- package/dist/fields/config/sanitize.js +0 -3
- package/dist/fields/config/sanitize.js.map +1 -1
- package/package.json +3 -3
|
@@ -35,8 +35,9 @@ export declare function generateImportMap(config: SanitizedConfig, options?: {
|
|
|
35
35
|
force?: boolean;
|
|
36
36
|
log: boolean;
|
|
37
37
|
}): Promise<void>;
|
|
38
|
-
export declare function writeImportMap({ componentMap, fileName, force, importMap, log, rootDir, }: {
|
|
38
|
+
export declare function writeImportMap({ componentMap, config, fileName, force, importMap, log, rootDir, }: {
|
|
39
39
|
componentMap: InternalImportMap;
|
|
40
|
+
config: SanitizedConfig;
|
|
40
41
|
fileName: string;
|
|
41
42
|
force?: boolean;
|
|
42
43
|
importMap: Imports;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bin/generateImportMap/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAK9E,KAAK,gBAAgB,GAAG,MAAM,CAAA;AAC9B,KAAK,eAAe,GAAG,MAAM,CAAA;AAC7B,KAAK,UAAU,GAAG,MAAM,CAAA;AACxB,KAAK,cAAc,GAAG,MAAM,CAAA;AAE5B;;GAEG;AACH,MAAM,MAAM,iBA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eImportMap({
|
|
109
109
|
componentMap: importMap,
|
|
110
|
+
config,
|
|
110
111
|
fileName: 'importMap.js',
|
|
111
112
|
force: options?.force,
|
|
112
113
|
importMap: imports,
|
|
@@ -114,14 +115,14 @@ export async function generateImportMap(config, options) {
|
|
|
114
115
|
rootDir
|
|
115
116
|
});
|
|
116
117
|
}
|
|
117
|
-
export async function writeImportMap({ componentMap, fileName, force, importMap, log, rootDir }) {
|
|
118
|
+
export async function writeImportMap({ componentMap, config, fileName, force, importMap, log, rootDir }) {
|
|
118
119
|
let importMapFolderPath = '';
|
|
119
|
-
if (fs.existsSync(path.resolve(rootDir,
|
|
120
|
-
importMapFolderPath = path.resolve(rootDir,
|
|
121
|
-
} else if (fs.existsSync(path.resolve(rootDir,
|
|
122
|
-
importMapFolderPath = path.resolve(rootDir,
|
|
120
|
+
if (fs.existsSync(path.resolve(rootDir, `app/(payload)${config.routes.admin}/`))) {
|
|
121
|
+
importMapFolderPath = path.resolve(rootDir, `app/(payload)${config.routes.admin}/`);
|
|
122
|
+
} else if (fs.existsSync(path.resolve(rootDir, `src/app/(payload)${config.routes.admin}/`))) {
|
|
123
|
+
importMapFolderPath = path.resolve(rootDir, `src/app/(payload)${config.routes.admin}/`);
|
|
123
124
|
} else {
|
|
124
|
-
throw new Error(`Could not find the payload admin directory. Looked in ${path.resolve(rootDir,
|
|
125
|
+
throw new Error(`Could not find the payload admin directory. Looked in ${path.resolve(rootDir, `app/(payload)${config.routes.admin}/`)} and ${path.resolve(rootDir, `src/app/(payload)${config.routes.admin}/`)}`);
|
|
125
126
|
}
|
|
126
127
|
const imports = [];
|
|
127
128
|
for (const [identifier, { path, specifier }] of Object.entries(importMap)){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/bin/generateImportMap/index.ts"],"sourcesContent":["import crypto from 'crypto'\nimport fs from 'fs'\nimport process from 'node:process'\nimport path from 'path'\n\nimport type { PayloadComponent, SanitizedConfig } from '../../config/types.js'\n\nimport { iterateConfig } from './iterateConfig.js'\nimport { parsePayloadComponent } from './parsePayloadComponent.js'\n\ntype ImportIdentifier = string\ntype ImportSpecifier = string\ntype ImportPath = string\ntype UserImportPath = string\n\n/**\n * Import Map before being written to the file. Only contains all paths\n */\nexport type InternalImportMap = {\n [path: UserImportPath]: ImportIdentifier\n}\n\n/**\n * Imports of the import map.\n */\nexport type Imports = {\n [identifier: ImportIdentifier]: {\n path: ImportPath\n specifier: ImportSpecifier\n }\n}\n\n/**\n * Import Map after being imported from the actual import map. Contains all the actual imported components\n */\nexport type ImportMap = {\n [path: UserImportPath]: any\n}\n\nexport function addPayloadComponentToImportMap({\n baseDir,\n importMap,\n imports,\n payloadComponent,\n}: {\n baseDir: string\n importMap: InternalImportMap\n imports: Imports\n payloadComponent: PayloadComponent\n}) {\n if (!payloadComponent) {\n return\n }\n const { exportName, path: componentPath } = parsePayloadComponent(payloadComponent)\n\n if (importMap[componentPath + '#' + exportName]) {\n return\n }\n\n const importIdentifier =\n exportName + '_' + crypto.createHash('md5').update(componentPath).digest('hex')\n\n // e.g. if baseDir is /test/fields and componentPath is /components/Field.tsx\n // then path needs to be /test/fields/components/Field.tsx NOT /users/username/project/test/fields/components/Field.tsx\n // so we need to append baseDir to componentPath\n\n if (componentPath.startsWith('.') || componentPath.startsWith('/')) {\n const normalizedBaseDir = baseDir.replace(/\\\\/g, '/')\n\n const finalPath = normalizedBaseDir.startsWith('/../')\n ? `${normalizedBaseDir}${componentPath.slice(1)}`\n : path.posix.join(normalizedBaseDir, componentPath.slice(1))\n\n imports[importIdentifier] = {\n path:\n componentPath.startsWith('.') || componentPath.startsWith('/') ? finalPath : componentPath,\n specifier: exportName,\n }\n } else {\n imports[importIdentifier] = {\n path: componentPath,\n specifier: exportName,\n }\n }\n importMap[componentPath + '#' + exportName] = importIdentifier\n}\n\nexport type AddToImportMap = (payloadComponent: PayloadComponent | PayloadComponent[]) => void\n\nexport async function generateImportMap(\n config: SanitizedConfig,\n options?: { force?: boolean; log: boolean },\n): Promise<void> {\n const shouldLog = options?.log ?? true\n\n if (shouldLog) {\n console.log('Generating import map')\n }\n\n const importMap: InternalImportMap = {}\n const imports: Imports = {}\n\n const rootDir = process.env.ROOT_DIR ?? process.cwd()\n\n // get componentsBaseDir.\n // E.g.:\n // config.admin.importMap.baseDir = /test/fields/\n // rootDir: /\n // componentsBaseDir = /test/fields/\n\n // or\n\n // E.g.:\n // config.admin.importMap.baseDir = /test/fields/\n // rootDir: /test\n // componentsBaseDir = /fields/\n\n // or\n // config.admin.importMap.baseDir = /\n // rootDir: /\n // componentsBaseDir = /\n\n // E.g.:\n // config.admin.importMap.baseDir = /test/fields/\n // rootDir: /test/fields/prod\n // componentsBaseDir = ../\n\n // Check if rootDir is a subdirectory of baseDir\n const baseDir = config.admin.importMap.baseDir\n const isSubdirectory = path.relative(baseDir, rootDir).startsWith('..')\n\n let componentsBaseDir\n\n if (isSubdirectory) {\n // Get the relative path from rootDir to baseDir\n componentsBaseDir = path.relative(rootDir, baseDir)\n } else {\n // If rootDir is not a subdirectory, just return baseDir relative to rootDir\n componentsBaseDir = `/${path.relative(rootDir, baseDir)}`\n }\n\n // Ensure result has a trailing slash\n if (!componentsBaseDir.endsWith('/')) {\n componentsBaseDir += '/'\n }\n\n const addToImportMap: AddToImportMap = (payloadComponent) => {\n if (!payloadComponent) {\n return\n }\n\n if (typeof payloadComponent !== 'object' && typeof payloadComponent !== 'string') {\n console.error(payloadComponent)\n throw new Error('addToImportMap > Payload component must be an object or a string')\n }\n\n if (Array.isArray(payloadComponent)) {\n for (const component of payloadComponent) {\n addPayloadComponentToImportMap({\n baseDir: componentsBaseDir,\n importMap,\n imports,\n payloadComponent: component,\n })\n }\n } else {\n addPayloadComponentToImportMap({\n baseDir: componentsBaseDir,\n importMap,\n imports,\n payloadComponent,\n })\n }\n }\n\n iterateConfig({\n addToImportMap,\n baseDir: config.admin.importMap.baseDir,\n config,\n importMap,\n imports,\n })\n\n await writeImportMap({\n componentMap: importMap,\n fileName: 'importMap.js',\n force: options?.force,\n importMap: imports,\n log: shouldLog,\n rootDir,\n })\n}\n\nexport async function writeImportMap({\n componentMap,\n fileName,\n force,\n importMap,\n log,\n rootDir,\n}: {\n componentMap: InternalImportMap\n fileName: string\n force?: boolean\n importMap: Imports\n log?: boolean\n rootDir: string\n}) {\n let importMapFolderPath = ''\n if (fs.existsSync(path.resolve(rootDir, 'app/(payload)/admin/'))) {\n importMapFolderPath = path.resolve(rootDir, 'app/(payload)/admin/')\n } else if (fs.existsSync(path.resolve(rootDir, 'src/app/(payload)/admin/'))) {\n importMapFolderPath = path.resolve(rootDir, 'src/app/(payload)/admin/')\n } else {\n throw new Error(\n `Could not find the payload admin directory. Looked in ${path.resolve(rootDir, 'app/(payload)/admin/')} and ${path.resolve(rootDir, 'src/app/(payload)/admin/')}`,\n )\n }\n\n const imports: string[] = []\n for (const [identifier, { path, specifier }] of Object.entries(importMap)) {\n imports.push(`import { ${specifier} as ${identifier} } from '${path}'`)\n }\n\n const mapKeys: string[] = []\n for (const [userPath, identifier] of Object.entries(componentMap)) {\n mapKeys.push(` \"${userPath}\": ${identifier}`)\n }\n\n const importMapOutputFile = `${imports.join('\\n')}\n\nexport const importMap = {\n${mapKeys.join(',\\n')}\n}\n`\n\n const importMapFilePath = path.resolve(importMapFolderPath, fileName)\n\n if (!force) {\n // Read current import map and check in the IMPORTS if there are any new imports. If not, don't write the file.\n const currentImportMap = await fs.promises.readFile(importMapFilePath, 'utf-8')\n\n if (currentImportMap?.trim() === importMapOutputFile?.trim()) {\n if (log) {\n console.log('No new imports found, skipping writing import map')\n }\n return\n }\n }\n\n if (log) {\n console.log('Writing import map to', importMapFilePath)\n }\n\n await fs.promises.writeFile(importMapFilePath, importMapOutputFile)\n}\n"],"names":["crypto","fs","process","path","iterateConfig","parsePayloadComponent","addPayloadComponentToImportMap","baseDir","importMap","imports","payloadComponent","exportName","componentPath","importIdentifier","createHash","update","digest","startsWith","normalizedBaseDir","replace","finalPath","slice","posix","join","specifier","generateImportMap","config","options","shouldLog","log","console","rootDir","env","ROOT_DIR","cwd","admin","isSubdirectory","relative","componentsBaseDir","endsWith","addToImportMap","error","Error","Array","isArray","component","writeImportMap","componentMap","fileName","force","importMapFolderPath","existsSync","resolve","identifier","Object","entries","push","mapKeys","userPath","importMapOutputFile","importMapFilePath","currentImportMap","promises","readFile","trim","writeFile"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAC3B,OAAOC,QAAQ,KAAI;AACnB,OAAOC,aAAa,eAAc;AAClC,OAAOC,UAAU,OAAM;AAIvB,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,qBAAqB,QAAQ,6BAA4B;AA+BlE,OAAO,SAASC,+BAA+B,EAC7CC,OAAO,EACPC,SAAS,EACTC,OAAO,EACPC,gBAAgB,EAMjB;IACC,IAAI,CAACA,kBAAkB;QACrB;IACF;IACA,MAAM,EAAEC,UAAU,EAAER,MAAMS,aAAa,EAAE,GAAGP,sBAAsBK;IAElE,IAAIF,SAAS,CAACI,gBAAgB,MAAMD,WAAW,EAAE;QAC/C;IACF;IAEA,MAAME,mBACJF,aAAa,MAAMX,OAAOc,UAAU,CAAC,OAAOC,MAAM,CAACH,eAAeI,MAAM,CAAC;IAE3E,6EAA6E;IAC7E,uHAAuH;IACvH,gDAAgD;IAEhD,IAAIJ,cAAcK,UAAU,CAAC,QAAQL,cAAcK,UAAU,CAAC,MAAM;QAClE,MAAMC,oBAAoBX,QAAQY,OAAO,CAAC,OAAO;QAEjD,MAAMC,YAAYF,kBAAkBD,UAAU,CAAC,UAC3C,CAAC,EAAEC,kBAAkB,EAAEN,cAAcS,KAAK,CAAC,GAAG,CAAC,GAC/ClB,KAAKmB,KAAK,CAACC,IAAI,CAACL,mBAAmBN,cAAcS,KAAK,CAAC;QAE3DZ,OAAO,CAACI,iBAAiB,GAAG;YAC1BV,MACES,cAAcK,UAAU,CAAC,QAAQL,cAAcK,UAAU,CAAC,OAAOG,YAAYR;YAC/EY,WAAWb;QACb;I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EAAE6B,WAAW,SAAS,EAAElD,KAAK,CAAC,CAAC;IACxE;IAEA,MAAMsD,UAAoB,EAAE;IAC5B,KAAK,MAAM,CAACC,UAAUL,WAAW,IAAIC,OAAOC,OAAO,CAACR,cAAe;QACjEU,QAAQD,IAAI,CAAC,CAAC,GAAG,EAAEE,SAAS,GAAG,EAAEL,WAAW,CAAC;IAC/C;IAEA,MAAMM,sBAAsB,CAAC,EAAElD,QAAQc,IAAI,CAAC,MAAM;;;AAGpD,EAAEkC,QAAQlC,IAAI,CAAC,OAAO;;AAEtB,CAAC;IAEC,MAAMqC,oBAAoBzD,KAAKiD,OAAO,CAACF,qBAAqBF;IAE5D,IAAI,CAACC,OAAO;QACV,+GAA+G;QAC/G,MAAMY,mBAAmB,MAAM5D,GAAG6D,QAAQ,CAACC,QAAQ,CAACH,mBAAmB;QAEvE,IAAIC,kBAAkBG,WAAWL,qBAAqBK,QAAQ;YAC5D,IAAInC,KAAK;gBACPC,QAAQD,GAAG,CAAC;YACd;YACA;QACF;IACF;IAEA,IAAIA,KAAK;QACPC,QAAQD,GAAG,CAAC,yBAAyB+B;IACvC;IAEA,MAAM3D,GAAG6D,QAAQ,CAACG,SAAS,CAACL,mBAAmBD;AACjD"}
|
|
1
|
+
{"version":3,"sources":["../../../src/bin/generateImportMap/index.ts"],"sourcesContent":["import crypto from 'crypto'\nimport fs from 'fs'\nimport process from 'node:process'\nimport path from 'path'\n\nimport type { PayloadComponent, SanitizedConfig } from '../../config/types.js'\n\nimport { iterateConfig } from './iterateConfig.js'\nimport { parsePayloadComponent } from './parsePayloadComponent.js'\n\ntype ImportIdentifier = string\ntype ImportSpecifier = string\ntype ImportPath = string\ntype UserImportPath = string\n\n/**\n * Import Map before being written to the file. Only contains all paths\n */\nexport type InternalImportMap = {\n [path: UserImportPath]: ImportIdentifier\n}\n\n/**\n * Imports of the import map.\n */\nexport type Imports = {\n [identifier: ImportIdentifier]: {\n path: ImportPath\n specifier: ImportSpecifier\n }\n}\n\n/**\n * Import Map after being imported from the actual import map. Contains all the actual imported components\n */\nexport type ImportMap = {\n [path: UserImportPath]: any\n}\n\nexport function addPayloadComponentToImportMap({\n baseDir,\n importMap,\n imports,\n payloadComponent,\n}: {\n baseDir: string\n importMap: InternalImportMap\n imports: Imports\n payloadComponent: PayloadComponent\n}) {\n if (!payloadComponent) {\n return\n }\n const { exportName, path: componentPath } = parsePayloadComponent(payloadComponent)\n\n if (importMap[componentPath + '#' + exportName]) {\n return\n }\n\n const importIdentifier =\n exportName + '_' + crypto.createHash('md5').update(componentPath).digest('hex')\n\n // e.g. if baseDir is /test/fields and componentPath is /components/Field.tsx\n // then path needs to be /test/fields/components/Field.tsx NOT /users/username/project/test/fields/components/Field.tsx\n // so we need to append baseDir to componentPath\n\n if (componentPath.startsWith('.') || componentPath.startsWith('/')) {\n const normalizedBaseDir = baseDir.replace(/\\\\/g, '/')\n\n const finalPath = normalizedBaseDir.startsWith('/../')\n ? `${normalizedBaseDir}${componentPath.slice(1)}`\n : path.posix.join(normalizedBaseDir, componentPath.slice(1))\n\n imports[importIdentifier] = {\n path:\n componentPath.startsWith('.') || componentPath.startsWith('/') ? finalPath : componentPath,\n specifier: exportName,\n }\n } else {\n imports[importIdentifier] = {\n path: componentPath,\n specifier: exportName,\n }\n }\n importMap[componentPath + '#' + exportName] = importIdentifier\n}\n\nexport type AddToImportMap = (payloadComponent: PayloadComponent | PayloadComponent[]) => void\n\nexport async function generateImportMap(\n config: SanitizedConfig,\n options?: { force?: boolean; log: boolean },\n): Promise<void> {\n const shouldLog = options?.log ?? true\n\n if (shouldLog) {\n console.log('Generating import map')\n }\n\n const importMap: InternalImportMap = {}\n const imports: Imports = {}\n\n const rootDir = process.env.ROOT_DIR ?? process.cwd()\n\n // get componentsBaseDir.\n // E.g.:\n // config.admin.importMap.baseDir = /test/fields/\n // rootDir: /\n // componentsBaseDir = /test/fields/\n\n // or\n\n // E.g.:\n // config.admin.importMap.baseDir = /test/fields/\n // rootDir: /test\n // componentsBaseDir = /fields/\n\n // or\n // config.admin.importMap.baseDir = /\n // rootDir: /\n // componentsBaseDir = /\n\n // E.g.:\n // config.admin.importMap.baseDir = /test/fields/\n // rootDir: /test/fields/prod\n // componentsBaseDir = ../\n\n // Check if rootDir is a subdirectory of baseDir\n const baseDir = config.admin.importMap.baseDir\n const isSubdirectory = path.relative(baseDir, rootDir).startsWith('..')\n\n let componentsBaseDir\n\n if (isSubdirectory) {\n // Get the relative path from rootDir to baseDir\n componentsBaseDir = path.relative(rootDir, baseDir)\n } else {\n // If rootDir is not a subdirectory, just return baseDir relative to rootDir\n componentsBaseDir = `/${path.relative(rootDir, baseDir)}`\n }\n\n // Ensure result has a trailing slash\n if (!componentsBaseDir.endsWith('/')) {\n componentsBaseDir += '/'\n }\n\n const addToImportMap: AddToImportMap = (payloadComponent) => {\n if (!payloadComponent) {\n return\n }\n\n if (typeof payloadComponent !== 'object' && typeof payloadComponent !== 'string') {\n console.error(payloadComponent)\n throw new Error('addToImportMap > Payload component must be an object or a string')\n }\n\n if (Array.isArray(payloadComponent)) {\n for (const component of payloadComponent) {\n addPayloadComponentToImportMap({\n baseDir: componentsBaseDir,\n importMap,\n imports,\n payloadComponent: component,\n })\n }\n } else {\n addPayloadComponentToImportMap({\n baseDir: componentsBaseDir,\n importMap,\n imports,\n payloadComponent,\n })\n }\n }\n\n iterateConfig({\n addToImportMap,\n baseDir: config.admin.importMap.baseDir,\n config,\n importMap,\n imports,\n })\n\n await writeImportMap({\n componentMap: importMap,\n config,\n fileName: 'importMap.js',\n force: options?.force,\n importMap: imports,\n log: shouldLog,\n rootDir,\n })\n}\n\nexport async function writeImportMap({\n componentMap,\n config,\n fileName,\n force,\n importMap,\n log,\n rootDir,\n}: {\n componentMap: InternalImportMap\n config: SanitizedConfig\n fileName: string\n force?: boolean\n importMap: Imports\n log?: boolean\n rootDir: string\n}) {\n let importMapFolderPath = ''\n if (fs.existsSync(path.resolve(rootDir, `app/(payload)${config.routes.admin}/`))) {\n importMapFolderPath = path.resolve(rootDir, `app/(payload)${config.routes.admin}/`)\n } else if (fs.existsSync(path.resolve(rootDir, `src/app/(payload)${config.routes.admin}/`))) {\n importMapFolderPath = path.resolve(rootDir, `src/app/(payload)${config.routes.admin}/`)\n } else {\n throw new Error(\n `Could not find the payload admin directory. Looked in ${path.resolve(rootDir, `app/(payload)${config.routes.admin}/`)} and ${path.resolve(rootDir, `src/app/(payload)${config.routes.admin}/`)}`,\n )\n }\n\n const imports: string[] = []\n for (const [identifier, { path, specifier }] of Object.entries(importMap)) {\n imports.push(`import { ${specifier} as ${identifier} } from '${path}'`)\n }\n\n const mapKeys: string[] = []\n for (const [userPath, identifier] of Object.entries(componentMap)) {\n mapKeys.push(` \"${userPath}\": ${identifier}`)\n }\n\n const importMapOutputFile = `${imports.join('\\n')}\n\nexport const importMap = {\n${mapKeys.join(',\\n')}\n}\n`\n\n const importMapFilePath = path.resolve(importMapFolderPath, fileName)\n\n if (!force) {\n // Read current import map and check in the IMPORTS if there are any new imports. If not, don't write the file.\n const currentImportMap = await fs.promises.readFile(importMapFilePath, 'utf-8')\n\n if (currentImportMap?.trim() === importMapOutputFile?.trim()) {\n if (log) {\n console.log('No new imports found, skipping writing import map')\n }\n return\n }\n }\n\n if (log) {\n console.log('Writing import map to', importMapFilePath)\n }\n\n await fs.promises.writeFile(importMapFilePath, importMapOutputFile)\n}\n"],"names":["crypto","fs","process","path","iterateConfig","parsePayloadComponent","addPayloadComponentToImportMap","baseDir","importMap","imports","payloadComponent","exportName","componentPath","importIdentifier","createHash","update","digest","startsWith","normalizedBaseDir","replace","finalPath","slice","posix","join","specifier","generateImportMap","config","options","shouldLog","log","console","rootDir","env","ROOT_DIR","cwd","admin","isSubdirectory","relative","componentsBaseDir","endsWith","addToImportMap","error","Error","Array","isArray","component","writeImportMap","componentMap","fileName","force","importMapFolderPath","existsSync","resolve","routes","identifier","Object","entries","push","mapKeys","userPath","importMapOutputFile","importMapFilePath","currentImportMap","promises","readFile","trim","writeFile"],"mapp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,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,OAAO,2BAAkC,IAAI,KAAG,OAAO,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/bin/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AA0BzD,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,eAAe,CAAA;IACvB,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,OAAO,2BAAkC,IAAI,KAAG,OAAO,CAAC,IAAI,CA2FxE,CAAA"}
|
package/dist/bin/migrate.js
CHANGED
|
@@ -18,7 +18,16 @@ const availableCommands = [
|
|
|
18
18
|
];
|
|
19
19
|
const availableCommandsMsg = `Available commands: ${availableCommands.join(', ')}`;
|
|
20
20
|
export const migrate = async ({ config, parsedArgs })=>{
|
|
21
|
-
const { _: args, file, forceAcceptWarning, help } = parsedArgs;
|
|
21
|
+
const { _: args, file, forceAcceptWarning: forceAcceptFromProps, help } = parsedArgs;
|
|
22
|
+
const formattedArgs = Object.keys(parsedArgs).map((key)=>{
|
|
23
|
+
const formattedKey = key.replace(/^[-_]+/, '');
|
|
24
|
+
if (!formattedKey) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return formattedKey.split('-').map((word, index)=>index === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1)).join('');
|
|
28
|
+
}).filter(Boolean);
|
|
29
|
+
const forceAcceptWarning = forceAcceptFromProps || formattedArgs.includes('forceAcceptWarning');
|
|
30
|
+
const skipEmpty = formattedArgs.includes('skipEmpty');
|
|
22
31
|
if (help) {
|
|
23
32
|
// eslint-disable-next-line no-console
|
|
24
33
|
console.log(`\n\n${availableCommandsMsg}\n`) // Avoid having to init payload to get the logger
|
|
@@ -52,7 +61,8 @@ export const migrate = async ({ config, parsedArgs })=>{
|
|
|
52
61
|
file,
|
|
53
62
|
forceAcceptWarning,
|
|
54
63
|
migrationName: args[1],
|
|
55
|
-
payload
|
|
64
|
+
payload,
|
|
65
|
+
skipEmpty
|
|
56
66
|
});
|
|
57
67
|
} catch (err) {
|
|
58
68
|
throw new Error(`Error creating migration: ${err.message}`);
|
package/dist/bin/migrate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bin/migrate.ts"],"sourcesContent":["import type { ParsedArgs } from 'minimist'\n\nimport type { SanitizedConfig } from '../config/types.js'\n\nimport payload from '../index.js'\nimport { prettySyncLoggerDestination } from '../utilities/logger.js'\n\n/**\n * The default logger's options did not allow for forcing sync logging\n * Using these options, to force both pretty print and sync logging\n */\nconst prettySyncLogger = {\n loggerDestination: prettySyncLoggerDestination,\n loggerOptions: {},\n}\n\nconst availableCommands = [\n 'migrate',\n 'migrate:create',\n 'migrate:down',\n 'migrate:refresh',\n 'migrate:reset',\n 'migrate:status',\n 'migration:fresh',\n]\n\nconst availableCommandsMsg = `Available commands: ${availableCommands.join(', ')}`\n\ntype Args = {\n config: SanitizedConfig\n parsedArgs: ParsedArgs\n}\n\nexport const migrate = async ({ config, parsedArgs }: Args): Promise<void> => {\n const { _: args, file, forceAcceptWarning, help } = parsedArgs\n if (help) {\n // eslint-disable-next-line no-console\n console.log(`\\n\\n${availableCommandsMsg}\\n`) // Avoid having to init payload to get the logger\n process.exit(0)\n }\n\n process.env.PAYLOAD_MIGRATING = 'true'\n\n // Barebones instance to access database adapter\n await payload.init({\n config,\n disableOnInit: true,\n ...prettySyncLogger,\n })\n\n const adapter = payload.db\n\n if (!adapter) {\n throw new Error('No database adapter found')\n }\n\n if (!args.length) {\n payload.logger.error({\n msg: `No migration command provided. ${availableCommandsMsg}`,\n })\n process.exit(1)\n }\n\n switch (args[0]) {\n case 'migrate':\n await adapter.migrate()\n break\n case 'migrate:create':\n try {\n await adapter.createMigration({\n file,\n forceAcceptWarning,\n migrationName: args[1],\n payload,\n })\n } catch (err) {\n throw new Error(`Error creating migration: ${err.message}`)\n }\n break\n case 'migrate:down':\n await adapter.migrateDown()\n break\n case 'migrate:fresh':\n await adapter.migrateFresh({ forceAcceptWarning })\n break\n case 'migrate:refresh':\n await adapter.migrateRefresh()\n break\n case 'migrate:reset':\n await adapter.migrateReset()\n break\n case 'migrate:status':\n await adapter.migrateStatus()\n break\n\n default:\n payload.logger.error({\n msg: `Unknown migration command: ${args[0]}. ${availableCommandsMsg}`,\n })\n process.exit(1)\n }\n\n payload.logger.info('Done.')\n}\n"],"names":["payload","prettySyncLoggerDestination","prettySyncLogger","loggerDestination","loggerOptions","availableCommands","availableCommandsMsg","join","migrate","config","parsedArgs","_","args","file","forceAcceptWarning","help","console","log","process","exit","env","PAYLOAD_MIGRATING","init","disableOnInit","adapter","db","Error","length","logger","error","msg","createMigration","migrationName","err","message","migrateDown","migrateFresh","migrateRefresh","migrateReset","migrateStatus","info"],"mappings":"AAIA,OAAOA,aAAa,cAAa;AACjC,SAASC,2BAA2B,QAAQ,yBAAwB;AAEpE;;;CAGC,GACD,MAAMC,mBAAmB;IACvBC,mBAAmBF;IACnBG,eAAe,CAAC;AAClB;AAEA,MAAMC,oBAAoB;IACxB;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,uBAAuB,CAAC,oBAAoB,EAAED,kBAAkBE,IAAI,CAAC,MAAM,CAAC;AAOlF,OAAO,MAAMC,UAAU,OAAO,EAAEC,MAAM,EAAEC,UAAU,EAAQ;IACxD,MAAM,EAAEC,GAAGC,IAAI,EAAEC,IAAI,EAAEC,
|
|
1
|
+
{"version":3,"sources":["../../src/bin/migrate.ts"],"sourcesContent":["import type { ParsedArgs } from 'minimist'\n\nimport type { SanitizedConfig } from '../config/types.js'\n\nimport payload from '../index.js'\nimport { prettySyncLoggerDestination } from '../utilities/logger.js'\n\n/**\n * The default logger's options did not allow for forcing sync logging\n * Using these options, to force both pretty print and sync logging\n */\nconst prettySyncLogger = {\n loggerDestination: prettySyncLoggerDestination,\n loggerOptions: {},\n}\n\nconst availableCommands = [\n 'migrate',\n 'migrate:create',\n 'migrate:down',\n 'migrate:refresh',\n 'migrate:reset',\n 'migrate:status',\n 'migration:fresh',\n]\n\nconst availableCommandsMsg = `Available commands: ${availableCommands.join(', ')}`\n\ntype Args = {\n config: SanitizedConfig\n parsedArgs: ParsedArgs\n}\n\nexport const migrate = async ({ config, parsedArgs }: Args): Promise<void> => {\n const { _: args, file, forceAcceptWarning: forceAcceptFromProps, help } = parsedArgs\n\n const formattedArgs = Object.keys(parsedArgs)\n .map((key) => {\n const formattedKey = key.replace(/^[-_]+/, '')\n if (!formattedKey) {\n return null\n }\n\n return formattedKey\n .split('-')\n .map((word, index) =>\n index === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1),\n )\n .join('')\n })\n .filter(Boolean)\n\n const forceAcceptWarning = forceAcceptFromProps || formattedArgs.includes('forceAcceptWarning')\n const skipEmpty = formattedArgs.includes('skipEmpty')\n\n if (help) {\n // eslint-disable-next-line no-console\n console.log(`\\n\\n${availableCommandsMsg}\\n`) // Avoid having to init payload to get the logger\n process.exit(0)\n }\n\n process.env.PAYLOAD_MIGRATING = 'true'\n\n // Barebones instance to access database adapter\n await payload.init({\n config,\n disableOnInit: true,\n ...prettySyncLogger,\n })\n\n const adapter = payload.db\n\n if (!adapter) {\n throw new Error('No database adapter found')\n }\n\n if (!args.length) {\n payload.logger.error({\n msg: `No migration command provided. ${availableCommandsMsg}`,\n })\n process.exit(1)\n }\n\n switch (args[0]) {\n case 'migrate':\n await adapter.migrate()\n break\n case 'migrate:create':\n try {\n await adapter.createMigration({\n file,\n forceAcceptWarning,\n migrationName: args[1],\n payload,\n skipEmpty,\n })\n } catch (err) {\n throw new Error(`Error creating migration: ${err.message}`)\n }\n break\n case 'migrate:down':\n await adapter.migrateDown()\n break\n case 'migrate:fresh':\n await adapter.migrateFresh({ forceAcceptWarning })\n break\n case 'migrate:refresh':\n await adapter.migrateRefresh()\n break\n case 'migrate:reset':\n await adapter.migrateReset()\n break\n case 'migrate:status':\n await adapter.migrateStatus()\n break\n\n default:\n payload.logger.error({\n msg: `Unknown migration command: ${args[0]}. ${availableCommandsMsg}`,\n })\n process.exit(1)\n }\n\n payload.logger.info('Done.')\n}\n"],"names":["payload","prettySyncLoggerDestination","prettySyncLogger","loggerDestination","loggerOptions","availableCommands","availableCommandsMsg","join","migrate","config","parsedArgs","_","args","file","forceAcceptWarning","forceAcceptFromProps","help","formattedArgs","Object","keys","map","key","formattedKey","replace","split","word","index","toLowerCase","charAt","toUpperCase","slice","filter","Boolean","includes","skipEmpty","console","log","process","exit","env","PAYLOAD_MIGRATING","init","disableOnInit","adapter","db","Error","length","logger","error","msg","createMigration","migrationName","err","message","migrateDown","migrateFresh","migrateRefresh","migrateReset","migrateStatus","info"],"mappings":"AAIA,OAAOA,aAAa,cAAa;AACjC,SAASC,2BAA2B,QAAQ,yBAAwB;AAEpE;;;CAGC,GACD,MAAMC,mBAAmB;IACvBC,mBAAmBF;IACnBG,eAAe,CAAC;AAClB;AAEA,MAAMC,oBAAoB;IACxB;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,uBAAuB,CAAC,oBAAoB,EAAED,kBAAkBE,IAAI,CAAC,MAAM,CAAC;AAOlF,OAAO,MAAMC,UAAU,OAAO,EAAEC,MAAM,EAAEC,UAAU,EAAQ;IACxD,MAAM,EAAEC,GAAGC,IAAI,EAAEC,IAAI,EAAEC,oBAAoBC,oBAAoB,EAAEC,IAAI,EAAE,GAAGN;IAE1E,MAAMO,gBAAgBC,OAAOC,IAAI,CAACT,YAC/BU,GAAG,CAAC,CAACC;QACJ,MAAMC,eAAeD,IAAIE,OAAO,CAAC,UAAU;QAC3C,IAAI,CAACD,cAAc;YACjB,OAAO;QACT;QAEA,OAAOA,aACJE,KAAK,CAAC,KACNJ,GAAG,CAAC,CAACK,MAAMC,QACVA,UAAU,I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,MAAM6B,QAAQa,cAAc;YAC5B;QACF,KAAK;YACH,MAAMb,QAAQc,YAAY;YAC1B;QACF,KAAK;YACH,MAAMd,QAAQe,aAAa;YAC3B;QAEF;YACE1D,QAAQ+C,MAAM,CAACC,KAAK,CAAC;gBACnBC,KAAK,CAAC,2BAA2B,EAAErC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAEN,qBAAqB,CAAC;YACvE;YACA+B,QAAQC,IAAI,CAAC;IACjB;IAEAtC,QAAQ+C,MAAM,CAACY,IAAI,CAAC;AACtB,EAAC"}
|
package/dist/database/types.d.ts
CHANGED
|
@@ -131,6 +131,7 @@ export type CreateMigration = (args: {
|
|
|
131
131
|
forceAcceptWarning?: boolean;
|
|
132
132
|
migrationName?: string;
|
|
133
133
|
payload: Payload;
|
|
134
|
+
skipEmpty?: boolean;
|
|
134
135
|
}) => Promise<void> | void;
|
|
135
136
|
export type Transaction = (callback: () => Promise<void>, options?: Record<string, unknown>) => Promise<void>;
|
|
136
137
|
export type BeginTransaction = (options?: Record<string, unknown>) => Promise<null | number | string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/database/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7D,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EACT,OAAO,EACP,cAAc,EACd,UAAU,EACV,IAAI,EACJ,KAAK,EACN,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D,YAAY,EAAE,eAAe,EAAE,CAAA;AAE/B,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,gBAAgB,EAAE,gBAAgB,CAAA;IAClC;;OAEG;IACH,iBAAiB,EAAE,iBAAiB,CAAA;IAEpC;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C,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAAA;IACpC,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,qBAAqB,CAAC,CAAC,GAAG,mBAAmB,IAAI;IAC3D,aAAa,EAAE,QAAQ,GAAG,MAAM,CAAA;IAChC,IAAI,EAAE,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,KAAK,CAAC,CAAA;CACxC,CAAA;AAED,MAAM,MAAM,gBAAgB,GACxB,CAAC,CAAC,IAAI,EAAE;IACN,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,KAAK,MAAM,CAAC,GACb,MAAM,CAAA;AAEV,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/database/types.ts"],"sourcesContent":["import type { TypeWithID } from '../collections/config/types.js'\nimport type { CollectionSlug, GlobalSlug } from '../index.js'\nimport type {\n Document,\n JoinQuery,\n Payload,\n PayloadRequest,\n SelectType,\n Sort,\n Where,\n} from '../types/index.js'\nimport type { TypeWithVersion } from '../versions/types.js'\n\nexport type { TypeWithVersion }\n\nexport interface BaseDatabaseAdapter {\n /**\n * Start a transaction, requiring commitTransaction() to be called for any changes to be made.\n * @returns an identifier for the transaction or null if one cannot be established\n */\n beginTransaction: BeginTransaction\n /**\n * Persist the changes made since the start of the transaction.\n */\n commitTransaction: CommitTransaction\n\n /**\n * Open the connection to the database\n */\n connect?: Connect\n\n count: Count\n countGlobalVersions: CountGlobalVersions\n countVersions: CountVersions\n\n create: Create\n\n createGlobal: CreateGlobal\n\n createGlobalVersion: CreateGlobalVersion\n /**\n * Output a migration file\n */\n createMigration: CreateMigration\n\n createVersion: CreateVersion\n\n /**\n * Specify if the ID is a text or number field by default within this database adapter.\n */\n defaultIDType: 'number' | 'text'\n\n deleteMany: DeleteMany\n\n deleteOne: DeleteOne\n\n deleteVersions: DeleteVersions\n /**\n * Terminate the connection with the database\n */\n destroy?: Destroy\n\n find: Find\n\n findGlobal: FindGlobal\n\n findGlobalVersions: FindGlobalVersions\n\n findOne: FindOne\n\n findVersions: FindVersions\n\n /**\n * Perform startup tasks required to interact with the database such as building Schema and models\n */\n init?: Init\n\n /**\n * Run any migration up functions that have not yet been performed and update the status\n */\n migrate: (args?: { migrations?: Migration[] }) => Promise<void>\n\n /**\n * Run any migration down functions that have been performed\n */\n migrateDown: () => Promise<void>\n\n /**\n * Drop the current database and run all migrate up functions\n */\n migrateFresh: (args: { forceAcceptWarning?: boolean }) => Promise<void>\n\n /**\n * Run all migration down functions before running up\n */\n migrateRefresh: () => Promise<void>\n /**\n * Run all migrate down functions\n */\n migrateReset: () => Promise<void>\n\n /**\n * Read the current state of migrations and output the result to show which have been run\n */\n migrateStatus: () => Promise<void>\n /**\n * Path to read and write migration files from\n */\n migrationDir: string\n /**\n * The name of the database adapter\n */\n name: string\n /**\n * Full package name of the database adapter\n *\n * @example @payloadcms/db-postgres\n */\n packageName: string\n\n /**\n * reference to the instance of payload\n */\n payload: Payload\n\n queryDrafts: QueryDrafts\n /**\n * Abort any changes since the start of the transaction.\n */\n rollbackTransaction: RollbackTransaction\n /**\n * A key-value store of all sessions open (used for transactions)\n */\n sessions?: {\n [id: string]: {\n db: unknown\n reject: () => Promise<void>\n resolve: () => Promise<void>\n }\n }\n\n updateGlobal: UpdateGlobal\n\n updateGlobalVersion: UpdateGlobalVersion\n\n updateOne: UpdateOne\n\n updateVersion: UpdateVersion\n\n upsert: Upsert\n}\n\nexport type Init = () => Promise<void> | void\n\ntype ConnectArgs = {\n hotReload: boolean\n}\n\nexport type Connect = (args?: ConnectArgs) => Promise<void>\n\nexport type Destroy = () => Promise<void>\n\nexport type CreateMigration = (args: {\n /** dirname of the package, required in drizzle */\n dirname?: string\n file?: string\n /**\n * Skips the prompt asking to create empty migrations\n */\n forceAcceptWarning?: boolean\n migrationName?: string\n payload: Payload\n}) => Promise<void> | void\n\nexport type Transaction = (\n callback: () => Promise<void>,\n options?: Record<string, unknown>,\n) => Promise<void>\n\nexport type BeginTransaction = (\n options?: Record<string, unknown>,\n) => Promise<null | number | string>\n\nexport type RollbackTransaction = (id: number | Promise<number | string> | string) => Promise<void>\n\nexport type CommitTransaction = (id: number | Promise<number | string> | string) => Promise<void>\n\nexport type QueryDraftsArgs = {\n collection: CollectionSlug\n joins?: JoinQuery\n limit?: number\n locale?: string\n page?: number\n pagination?: boolean\n req: PayloadRequest\n select?: SelectType\n sort?: Sort\n where?: Where\n}\n\nexport type QueryDrafts = <T = TypeWithID>(args: QueryDraftsArgs) => Promise<PaginatedDocs<T>>\n\nexport type FindOneArgs = {\n collection: CollectionSlug\n joins?: JoinQuery\n locale?: string\n req: PayloadRequest\n select?: SelectType\n where?: Where\n}\n\nexport type FindOne = <T extends TypeWithID>(args: FindOneArgs) => Promise<null | T>\n\nexport type FindArgs = {\n collection: CollectionSlug\n joins?: JoinQuery\n /** Setting limit to 1 is equal to the previous Model.findOne(). Setting limit to 0 disables the limit */\n limit?: number\n locale?: string\n page?: number\n pagination?: boolean\n projection?: Record<string, unknown>\n req: PayloadRequest\n select?: SelectType\n skip?: number\n sort?: Sort\n versions?: boolean\n where?: Where\n}\n\nexport type Find = <T = TypeWithID>(args: FindArgs) => Promise<PaginatedDocs<T>>\n\nexport type CountArgs = {\n collection: CollectionSlug\n locale?: string\n req: PayloadRequest\n where?: Where\n}\n\nexport type Count = (args: CountArgs) => Promise<{ totalDocs: number }>\n\nexport type CountVersions = (args: CountArgs) => Promise<{ totalDocs: number }>\n\nexport type CountGlobalVersionArgs = {\n global: string\n locale?: string\n req: PayloadRequest\n where?: Where\n}\n\nexport type CountGlobalVersions = (args: CountGlobalVersionArgs) => Promise<{ totalDocs: number }>\n\ntype BaseVersionArgs = {\n limit?: number\n locale?: string\n page?: number\n pagination?: boolean\n req: PayloadRequest\n select?: SelectType\n skip?: number\n sort?: Sort\n versions?: boolean\n where?: Where\n}\n\nexport type FindVersionsArgs = {\n collection: CollectionSlug\n} & BaseVersionArgs\n\nexport type FindVersions = <T = TypeWithID>(\n args: FindVersionsArgs,\n) => Promise<PaginatedDocs<TypeWithVersion<T>>>\n\nexport type FindGlobalVersionsArgs = {\n global: GlobalSlug\n} & BaseVersionArgs\n\nexport type FindGlobalArgs = {\n locale?: string\n req: PayloadRequest\n select?: SelectType\n slug: string\n where?: Where\n}\n\nexport type UpdateGlobalVersionArgs<T = TypeWithID> = {\n global: GlobalSlug\n locale?: string\n /**\n * Additional database adapter specific options to pass to the query\n */\n options?: Record<string, unknown>\n req: PayloadRequest\n select?: SelectType\n versionData: T\n} & (\n | {\n id: number | string\n where?: never\n }\n | {\n id?: never\n where: Where\n }\n)\n\nexport type UpdateGlobalVersion = <T extends TypeWithID = TypeWithID>(\n args: UpdateGlobalVersionArgs<T>,\n) => Promise<TypeWithVersion<T>>\n\nexport type FindGlobal = <T extends Record<string, unknown> = any>(\n args: FindGlobalArgs,\n) => Promise<T>\n\nexport type CreateGlobalArgs<T extends Record<string, unknown> = any> = {\n data: T\n req: PayloadRequest\n slug: string\n}\nexport type CreateGlobal = <T extends Record<string, unknown> = any>(\n args: CreateGlobalArgs<T>,\n) => Promise<T>\n\nexport type UpdateGlobalArgs<T extends Record<string, unknown> = any> = {\n data: T\n /**\n * Additional database adapter specific options to pass to the query\n */\n options?: Record<string, unknown>\n req: PayloadRequest\n select?: SelectType\n slug: string\n}\nexport type UpdateGlobal = <T extends Record<string, unknown> = any>(\n args: UpdateGlobalArgs<T>,\n) => Promise<T>\n// export type UpdateOne = (args: UpdateOneArgs) => Promise<Document>\n\nexport type FindGlobalVersions = <T = TypeWithID>(\n args: FindGlobalVersionsArgs,\n) => Promise<PaginatedDocs<TypeWithVersion<T>>>\n\nexport type DeleteVersionsArgs = {\n collection: CollectionSlug\n locale?: string\n req: PayloadRequest\n sort?: {\n [key: string]: string\n }\n where: Where\n}\n\nexport type CreateVersionArgs<T = TypeWithID> = {\n autosave: boolean\n collectionSlug: CollectionSlug\n createdAt: string\n /** ID of the parent document for which the version should be created for */\n parent: number | string\n publishedLocale?: string\n req: PayloadRequest\n select?: SelectType\n snapshot?: true\n updatedAt: string\n versionData: T\n}\n\nexport type CreateVersion = <T extends TypeWithID = TypeWithID>(\n args: CreateVersionArgs<T>,\n) => Promise<TypeWithVersion<T>>\n\nexport type CreateGlobalVersionArgs<T = TypeWithID> = {\n autosave: boolean\n createdAt: string\n globalSlug: GlobalSlug\n /** ID of the parent document for which the version should be created for */\n parent: number | string\n publishedLocale?: string\n req: PayloadRequest\n select?: SelectType\n snapshot?: true\n updatedAt: string\n versionData: T\n}\n\nexport type CreateGlobalVersion = <T extends TypeWithID = TypeWithID>(\n args: CreateGlobalVersionArgs<T>,\n) => Promise<TypeWithVersion<T>>\n\nexport type DeleteVersions = (args: DeleteVersionsArgs) => Promise<void>\n\nexport type UpdateVersionArgs<T = TypeWithID> = {\n collection: CollectionSlug\n locale?: string\n /**\n * Additional database adapter specific options to pass to the query\n */\n options?: Record<string, unknown>\n req: PayloadRequest\n select?: SelectType\n versionData: T\n} & (\n | {\n id: number | string\n where?: never\n }\n | {\n id?: never\n where: Where\n }\n)\n\nexport type UpdateVersion = <T extends TypeWithID = TypeWithID>(\n args: UpdateVersionArgs<T>,\n) => Promise<TypeWithVersion<T>>\n\nexport type CreateArgs = {\n collection: CollectionSlug\n data: Record<string, unknown>\n draft?: boolean\n locale?: string\n req: PayloadRequest\n select?: SelectType\n}\n\nexport type Create = (args: CreateArgs) => Promise<Document>\n\nexport type UpdateOneArgs = {\n collection: CollectionSlug\n data: Record<string, unknown>\n draft?: boolean\n joins?: JoinQuery\n locale?: string\n /**\n * Additional database adapter specific options to pass to the query\n */\n options?: Record<string, unknown>\n req: PayloadRequest\n select?: SelectType\n} & (\n | {\n id: number | string\n where?: never\n }\n | {\n id?: never\n where: Where\n }\n)\n\nexport type UpdateOne = (args: UpdateOneArgs) => Promise<Document>\n\nexport type UpsertArgs = {\n collection: CollectionSlug\n data: Record<string, unknown>\n joins?: JoinQuery\n locale?: string\n req: PayloadRequest\n select?: SelectType\n where: Where\n}\n\nexport type Upsert = (args: UpsertArgs) => Promise<Document>\n\nexport type DeleteOneArgs = {\n collection: CollectionSlug\n joins?: JoinQuery\n req: PayloadRequest\n select?: SelectType\n where: Where\n}\n\nexport type DeleteOne = (args: DeleteOneArgs) => Promise<Document>\n\nexport type DeleteManyArgs = {\n collection: CollectionSlug\n joins?: JoinQuery\n req: PayloadRequest\n where: Where\n}\n\nexport type DeleteMany = (args: DeleteManyArgs) => Promise<void>\n\nexport type Migration = {\n down: (args: unknown) => Promise<void>\n up: (args: unknown) => Promise<void>\n} & MigrationData\n\nexport type MigrationData = {\n batch?: number\n id?: string\n name: string\n}\n\nexport type PaginatedDocs<T = any> = {\n docs: T[]\n hasNextPage: boolean\n hasPrevPage: boolean\n limit: number\n nextPage?: null | number | undefined\n page?: number\n pagingCounter: number\n prevPage?: null | number | undefined\n totalDocs: number\n totalPages: number\n}\n\nexport type DatabaseAdapterResult<T = BaseDatabaseAdapter> = {\n defaultIDType: 'number' | 'text'\n init: (args: { payload: Payload }) => T\n}\n\nexport type DBIdentifierName =\n | ((Args: {\n /** The name of the parent table when using relational DBs */\n tableName?: string\n }) => string)\n | string\n\nexport type MigrationTemplateArgs = {\n downSQL?: string\n imports?: string\n packageName?: string\n upSQL?: string\n}\n"],"names":[],"mappings":"AAsgBA,WAKC"}
|
|
1
|
+
{"version":3,"sources":["../../src/database/types.ts"],"sourcesContent":["import type { TypeWithID } from '../collections/config/types.js'\nimport type { CollectionSlug, GlobalSlug } from '../index.js'\nimport type {\n Document,\n JoinQuery,\n Payload,\n PayloadRequest,\n SelectType,\n Sort,\n Where,\n} from '../types/index.js'\nimport type { TypeWithVersion } from '../versions/types.js'\n\nexport type { TypeWithVersion }\n\nexport interface BaseDatabaseAdapter {\n /**\n * Start a transaction, requiring commitTransaction() to be called for any changes to be made.\n * @returns an identifier for the transaction or null if one cannot be established\n */\n beginTransaction: BeginTransaction\n /**\n * Persist the changes made since the start of the transaction.\n */\n commitTransaction: CommitTransaction\n\n /**\n * Open the connection to the database\n */\n connect?: Connect\n\n count: Count\n countGlobalVersions: CountGlobalVersions\n countVersions: CountVersions\n\n create: Create\n\n createGlobal: CreateGlobal\n\n createGlobalVersion: CreateGlobalVersion\n /**\n * Output a migration file\n */\n createMigration: CreateMigration\n\n createVersion: CreateVersion\n\n /**\n * Specify if the ID is a text or number field by default within this database adapter.\n */\n defaultIDType: 'number' | 'text'\n\n deleteMany: DeleteMany\n\n deleteOne: DeleteOne\n\n deleteVersions: DeleteVersions\n /**\n * Terminate the connection with the database\n */\n destroy?: Destroy\n\n find: Find\n\n findGlobal: FindGlobal\n\n findGlobalVersions: FindGlobalVersions\n\n findOne: FindOne\n\n findVersions: FindVersions\n\n /**\n * Perform startup tasks required to interact with the database such as building Schema and models\n */\n init?: Init\n\n /**\n * Run any migration up functions that have not yet been performed and update the status\n */\n migrate: (args?: { migrations?: Migration[] }) => Promise<void>\n\n /**\n * Run any migration down functions that have been performed\n */\n migrateDown: () => Promise<void>\n\n /**\n * Drop the current database and run all migrate up functions\n */\n migrateFresh: (args: { forceAcceptWarning?: boolean }) => Promise<void>\n\n /**\n * Run all migration down functions before running up\n */\n migrateRefresh: () => Promise<void>\n /**\n * Run all migrate down functions\n */\n migrateReset: () => Promise<void>\n\n /**\n * Read the current state of migrations and output the result to show which have been run\n */\n migrateStatus: () => Promise<void>\n /**\n * Path to read and write migration files from\n */\n migrationDir: string\n /**\n * The name of the database adapter\n */\n name: string\n /**\n * Full package name of the database adapter\n *\n * @example @payloadcms/db-postgres\n */\n packageName: string\n\n /**\n * reference to the instance of payload\n */\n payload: Payload\n\n queryDrafts: QueryDrafts\n /**\n * Abort any changes since the start of the transaction.\n */\n rollbackTransaction: RollbackTransaction\n /**\n * A key-value store of all sessions open (used for transactions)\n */\n sessions?: {\n [id: string]: {\n db: unknown\n reject: () => Promise<void>\n resolve: () => Promise<void>\n }\n }\n\n updateGlobal: UpdateGlobal\n\n updateGlobalVersion: UpdateGlobalVersion\n\n updateOne: UpdateOne\n\n updateVersion: UpdateVersion\n\n upsert: Upsert\n}\n\nexport type Init = () => Promise<void> | void\n\ntype ConnectArgs = {\n hotReload: boolean\n}\n\nexport type Connect = (args?: ConnectArgs) => Promise<void>\n\nexport type Destroy = () => Promise<void>\n\nexport type CreateMigration = (args: {\n /** dirname of the package, required in drizzle */\n dirname?: string\n file?: string\n /**\n * Skips the prompt asking to create empty migrations\n */\n forceAcceptWarning?: boolean\n migrationName?: string\n payload: Payload\n skipEmpty?: boolean\n}) => Promise<void> | void\n\nexport type Transaction = (\n callback: () => Promise<void>,\n options?: Record<string, unknown>,\n) => Promise<void>\n\nexport type BeginTransaction = (\n options?: Record<string, unknown>,\n) => Promise<null | number | string>\n\nexport type RollbackTransaction = (id: number | Promise<number | string> | string) => Promise<void>\n\nexport type CommitTransaction = (id: number | Promise<number | string> | string) => Promise<void>\n\nexport type QueryDraftsArgs = {\n collection: CollectionSlug\n joins?: JoinQuery\n limit?: number\n locale?: string\n page?: number\n pagination?: boolean\n req: PayloadRequest\n select?: SelectType\n sort?: Sort\n where?: Where\n}\n\nexport type QueryDrafts = <T = TypeWithID>(args: QueryDraftsArgs) => Promise<PaginatedDocs<T>>\n\nexport type FindOneArgs = {\n collection: CollectionSlug\n joins?: JoinQuery\n locale?: string\n req: PayloadRequest\n select?: SelectType\n where?: Where\n}\n\nexport type FindOne = <T extends TypeWithID>(args: FindOneArgs) => Promise<null | T>\n\nexport type FindArgs = {\n collection: CollectionSlug\n joins?: JoinQuery\n /** Setting limit to 1 is equal to the previous Model.findOne(). Setting limit to 0 disables the limit */\n limit?: number\n locale?: string\n page?: number\n pagination?: boolean\n projection?: Record<string, unknown>\n req: PayloadRequest\n select?: SelectType\n skip?: number\n sort?: Sort\n versions?: boolean\n where?: Where\n}\n\nexport type Find = <T = TypeWithID>(args: FindArgs) => Promise<PaginatedDocs<T>>\n\nexport type CountArgs = {\n collection: CollectionSlug\n locale?: string\n req: PayloadRequest\n where?: Where\n}\n\nexport type Count = (args: CountArgs) => Promise<{ totalDocs: number }>\n\nexport type CountVersions = (args: CountArgs) => Promise<{ totalDocs: number }>\n\nexport type CountGlobalVersionArgs = {\n global: string\n locale?: string\n req: PayloadRequest\n where?: Where\n}\n\nexport type CountGlobalVersions = (args: CountGlobalVersionArgs) => Promise<{ totalDocs: number }>\n\ntype BaseVersionArgs = {\n limit?: number\n locale?: string\n page?: number\n pagination?: boolean\n req: PayloadRequest\n select?: SelectType\n skip?: number\n sort?: Sort\n versions?: boolean\n where?: Where\n}\n\nexport type FindVersionsArgs = {\n collection: CollectionSlug\n} & BaseVersionArgs\n\nexport type FindVersions = <T = TypeWithID>(\n args: FindVersionsArgs,\n) => Promise<PaginatedDocs<TypeWithVersion<T>>>\n\nexport type FindGlobalVersionsArgs = {\n global: GlobalSlug\n} & BaseVersionArgs\n\nexport type FindGlobalArgs = {\n locale?: string\n req: PayloadRequest\n select?: SelectType\n slug: string\n where?: Where\n}\n\nexport type UpdateGlobalVersionArgs<T = TypeWithID> = {\n global: GlobalSlug\n locale?: string\n /**\n * Additional database adapter specific options to pass to the query\n */\n options?: Record<string, unknown>\n req: PayloadRequest\n select?: SelectType\n versionData: T\n} & (\n | {\n id: number | string\n where?: never\n }\n | {\n id?: never\n where: Where\n }\n)\n\nexport type UpdateGlobalVersion = <T extends TypeWithID = TypeWithID>(\n args: UpdateGlobalVersionArgs<T>,\n) => Promise<TypeWithVersion<T>>\n\nexport type FindGlobal = <T extends Record<string, unknown> = any>(\n args: FindGlobalArgs,\n) => Promise<T>\n\nexport type CreateGlobalArgs<T extends Record<string, unknown> = any> = {\n data: T\n req: PayloadRequest\n slug: string\n}\nexport type CreateGlobal = <T extends Record<string, unknown> = any>(\n args: CreateGlobalArgs<T>,\n) => Promise<T>\n\nexport type UpdateGlobalArgs<T extends Record<string, unknown> = any> = {\n data: T\n /**\n * Additional database adapter specific options to pass to the query\n */\n options?: Record<string, unknown>\n req: PayloadRequest\n select?: SelectType\n slug: string\n}\nexport type UpdateGlobal = <T extends Record<string, unknown> = any>(\n args: UpdateGlobalArgs<T>,\n) => Promise<T>\n// export type UpdateOne = (args: UpdateOneArgs) => Promise<Document>\n\nexport type FindGlobalVersions = <T = TypeWithID>(\n args: FindGlobalVersionsArgs,\n) => Promise<PaginatedDocs<TypeWithVersion<T>>>\n\nexport type DeleteVersionsArgs = {\n collection: CollectionSlug\n locale?: string\n req: PayloadRequest\n sort?: {\n [key: string]: string\n }\n where: Where\n}\n\nexport type CreateVersionArgs<T = TypeWithID> = {\n autosave: boolean\n collectionSlug: CollectionSlug\n createdAt: string\n /** ID of the parent document for which the version should be created for */\n parent: number | string\n publishedLocale?: string\n req: PayloadRequest\n select?: SelectType\n snapshot?: true\n updatedAt: string\n versionData: T\n}\n\nexport type CreateVersion = <T extends TypeWithID = TypeWithID>(\n args: CreateVersionArgs<T>,\n) => Promise<TypeWithVersion<T>>\n\nexport type CreateGlobalVersionArgs<T = TypeWithID> = {\n autosave: boolean\n createdAt: string\n globalSlug: GlobalSlug\n /** ID of the parent document for which the version should be created for */\n parent: number | string\n publishedLocale?: string\n req: PayloadRequest\n select?: SelectType\n snapshot?: true\n updatedAt: string\n versionData: T\n}\n\nexport type CreateGlobalVersion = <T extends TypeWithID = TypeWithID>(\n args: CreateGlobalVersionArgs<T>,\n) => Promise<TypeWithVersion<T>>\n\nexport type DeleteVersions = (args: DeleteVersionsArgs) => Promise<void>\n\nexport type UpdateVersionArgs<T = TypeWithID> = {\n collection: CollectionSlug\n locale?: string\n /**\n * Additional database adapter specific options to pass to the query\n */\n options?: Record<string, unknown>\n req: PayloadRequest\n select?: SelectType\n versionData: T\n} & (\n | {\n id: number | string\n where?: never\n }\n | {\n id?: never\n where: Where\n }\n)\n\nexport type UpdateVersion = <T extends TypeWithID = TypeWithID>(\n args: UpdateVersionArgs<T>,\n) => Promise<TypeWithVersion<T>>\n\nexport type CreateArgs = {\n collection: CollectionSlug\n data: Record<string, unknown>\n draft?: boolean\n locale?: string\n req: PayloadRequest\n select?: SelectType\n}\n\nexport type Create = (args: CreateArgs) => Promise<Document>\n\nexport type UpdateOneArgs = {\n collection: CollectionSlug\n data: Record<string, unknown>\n draft?: boolean\n joins?: JoinQuery\n locale?: string\n /**\n * Additional database adapter specific options to pass to the query\n */\n options?: Record<string, unknown>\n req: PayloadRequest\n select?: SelectType\n} & (\n | {\n id: number | string\n where?: never\n }\n | {\n id?: never\n where: Where\n }\n)\n\nexport type UpdateOne = (args: UpdateOneArgs) => Promise<Document>\n\nexport type UpsertArgs = {\n collection: CollectionSlug\n data: Record<string, unknown>\n joins?: JoinQuery\n locale?: string\n req: PayloadRequest\n select?: SelectType\n where: Where\n}\n\nexport type Upsert = (args: UpsertArgs) => Promise<Document>\n\nexport type DeleteOneArgs = {\n collection: CollectionSlug\n joins?: JoinQuery\n req: PayloadRequest\n select?: SelectType\n where: Where\n}\n\nexport type DeleteOne = (args: DeleteOneArgs) => Promise<Document>\n\nexport type DeleteManyArgs = {\n collection: CollectionSlug\n joins?: JoinQuery\n req: PayloadRequest\n where: Where\n}\n\nexport type DeleteMany = (args: DeleteManyArgs) => Promise<void>\n\nexport type Migration = {\n down: (args: unknown) => Promise<void>\n up: (args: unknown) => Promise<void>\n} & MigrationData\n\nexport type MigrationData = {\n batch?: number\n id?: string\n name: string\n}\n\nexport type PaginatedDocs<T = any> = {\n docs: T[]\n hasNextPage: boolean\n hasPrevPage: boolean\n limit: number\n nextPage?: null | number | undefined\n page?: number\n pagingCounter: number\n prevPage?: null | number | undefined\n totalDocs: number\n totalPages: number\n}\n\nexport type DatabaseAdapterResult<T = BaseDatabaseAdapter> = {\n defaultIDType: 'number' | 'text'\n init: (args: { payload: Payload }) => T\n}\n\nexport type DBIdentifierName =\n | ((Args: {\n /** The name of the parent table when using relational DBs */\n tableName?: string\n }) => string)\n | string\n\nexport type MigrationTemplateArgs = {\n downSQL?: string\n imports?: string\n packageName?: string\n upSQL?: string\n}\n"],"names":[],"mappings":"AAugBA,WAKC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/fields/config/sanitize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AACzF,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAiBvC,KAAK,IAAI,GAAG;IACV,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAChC,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,cAAc,CAAA;IACtB,iBAAiB,EAAE,OAAO,CAAA;IAE1B;;;;OAIG;IACH,+BAA+B,CAAC,EAAE,OAAO,CAAA;IACzC;;;OAGG;IACH,4BAA4B,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAChF;;;OAGG;IACH,kBAAkB,EAAE,IAAI,GAAG,MAAM,EAAE,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,cAAc,mKAUxB,IAAI,KAAG,OAAO,CAAC,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/fields/config/sanitize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AACzF,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAiBvC,KAAK,IAAI,GAAG;IACV,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAChC,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,cAAc,CAAA;IACtB,iBAAiB,EAAE,OAAO,CAAA;IAE1B;;;;OAIG;IACH,+BAA+B,CAAC,EAAE,OAAO,CAAA;IACzC;;;OAGG;IACH,4BAA4B,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAChF;;;OAGG;IACH,kBAAkB,EAAE,IAAI,GAAG,MAAM,EAAE,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,cAAc,mKAUxB,IAAI,KAAG,OAAO,CAAC,KAAK,EAAE,CAuOxB,CAAA"}
|
|
@@ -101,9 +101,6 @@ export const sanitizeFields = async ({ config, existingFieldNames = new Set(), f
|
|
|
101
101
|
field.validate = ()=>true;
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
if (typeof field.virtual === 'undefined') {
|
|
105
|
-
field.virtual = false;
|
|
106
|
-
}
|
|
107
104
|
if (!field.hooks) {
|
|
108
105
|
field.hooks = {};
|
|
109
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/config/sanitize.ts"],"sourcesContent":["import { deepMergeSimple } from '@payloadcms/translations/utilities'\n\nimport type { CollectionConfig, SanitizedJoins } from '../../collections/config/types.js'\nimport type { Config, SanitizedConfig } from '../../config/types.js'\nimport type { Field } from './types.js'\n\nimport {\n DuplicateFieldName,\n InvalidFieldName,\n InvalidFieldRelationship,\n MissingEditorProp,\n MissingFieldType,\n} from '../../errors/index.js'\nimport { formatLabels, toWords } from '../../utilities/formatLabels.js'\nimport { baseBlockFields } from '../baseFields/baseBlockFields.js'\nimport { baseIDField } from '../baseFields/baseIDField.js'\nimport { setDefaultBeforeDuplicate } from '../setDefaultBeforeDuplicate.js'\nimport validations from '../validations.js'\nimport { sanitizeJoinField } from './sanitizeJoinField.js'\nimport { fieldAffectsData, tabHasName } from './types.js'\n\ntype Args = {\n collectionConfig?: CollectionConfig\n config: Config\n existingFieldNames?: Set<string>\n fields: Field[]\n joinPath?: string\n /**\n * When not passed in, assume that join are not supported (globals, arrays, blocks)\n */\n joins?: SanitizedJoins\n parentIsLocalized: boolean\n\n /**\n * If true, a richText field will require an editor property to be set, as the sanitizeFields function will not add it from the payload config if not present.\n *\n * @default false\n */\n requireFieldLevelRichTextEditor?: boolean\n /**\n * If this property is set, RichText fields won't be sanitized immediately. Instead, they will be added to this array as promises\n * so that you can sanitize them together, after the config has been sanitized.\n */\n richTextSanitizationPromises?: Array<(config: SanitizedConfig) => Promise<void>>\n /**\n * If not null, will validate that upload and relationship fields do not relate to a collection that is not in this array.\n * This validation will be skipped if validRelationships is null.\n */\n validRelationships: null | string[]\n}\n\nexport const sanitizeFields = async ({\n config,\n existingFieldNames = new Set(),\n fields,\n joinPath = '',\n joins,\n parentIsLocalized,\n requireFieldLevelRichTextEditor = false,\n richTextSanitizationPromises,\n validRelationships,\n}: Args): Promise<Field[]> => {\n if (!fields) {\n return []\n }\n\n for (let i = 0; i < fields.length; i++) {\n const field = fields[i]\n\n if ('_sanitized' in field && field._sanitized === true) {\n continue\n }\n\n if (!field.type) {\n throw new MissingFieldType(field)\n }\n\n // assert that field names do not contain forbidden characters\n if (fieldAffectsData(field) && field.name.includes('.')) {\n throw new InvalidFieldName(field, field.name)\n }\n\n // Auto-label\n if (\n 'name' in field &&\n field.name &&\n typeof field.label !== 'object' &&\n typeof field.label !== 'string' &&\n typeof field.label !== 'function' &&\n field.label !== false\n ) {\n field.label = toWords(field.name)\n }\n\n if (\n field.type === 'checkbox' &&\n typeof field.defaultValue === 'undefined' &&\n field.required === true\n ) {\n field.defaultValue = false\n }\n\n if (field.type === 'join') {\n sanitizeJoinField({ config, field, joinPath, joins })\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n if (validRelationships) {\n const relationships = Array.isArray(field.relationTo)\n ? field.relationTo\n : [field.relationTo]\n relationships.forEach((relationship: string) => {\n if (!validRelationships.includes(relationship)) {\n throw new InvalidFieldRelationship(field, relationship)\n }\n })\n }\n\n if (field.min && !field.minRows) {\n console.warn(\n `(payload): The \"min\" property is deprecated for the Relationship field \"${field.name}\" and will be removed in a future version. Please use \"minRows\" instead.`,\n )\n }\n if (field.max && !field.maxRows) {\n console.warn(\n `(payload): The \"max\" property is deprecated for the Relationship field \"${field.name}\" and will be removed in a future version. Please use \"maxRows\" instead.`,\n )\n }\n field.minRows = field.minRows || field.min\n field.maxRows = field.maxRows || field.max\n }\n\n if (field.type === 'upload') {\n if (!field.admin || !('isSortable' in field.admin)) {\n field.admin = {\n isSortable: true,\n ...field.admin,\n }\n }\n }\n\n if (field.type === 'array' && field.fields) {\n field.fields.push(baseIDField)\n }\n\n if ((field.type === 'blocks' || field.type === 'array') && field.label) {\n field.labels = field.labels || formatLabels(field.name)\n }\n\n if (fieldAffectsData(field)) {\n if (existingFieldNames.has(field.name)) {\n throw new DuplicateFieldName(field.name)\n } else if (!['blockName', 'id'].includes(field.name)) {\n existingFieldNames.add(field.name)\n }\n\n if (typeof field.localized !== 'undefined') {\n let shouldDisableLocalized = !config.localization\n\n if (!config.compatibility?.allowLocalizedWithinLocalized && parentIsLocalized) {\n shouldDisableLocalized = true\n }\n\n if (shouldDisableLocalized) {\n delete field.localized\n }\n }\n\n if (typeof field.validate === 'undefined') {\n const defaultValidate = validations[field.type]\n if (defaultValidate) {\n field.validate = (val, options) => defaultValidate(val, { ...field, ...options })\n } else {\n field.validate = (): true => true\n }\n }\n\n if (typeof field.virtual === 'undefined') {\n field.virtual = false\n }\n\n if (!field.hooks) {\n field.hooks = {}\n }\n if (!field.access) {\n field.access = {}\n }\n\n setDefaultBeforeDuplicate(field)\n }\n\n if (!field.admin) {\n field.admin = {}\n }\n\n // Make sure that the richText field has an editor\n if (field.type === 'richText') {\n const sanitizeRichText = async (_config: SanitizedConfig) => {\n if (!field.editor) {\n if (_config.editor && !requireFieldLevelRichTextEditor) {\n // config.editor should be sanitized at this point\n field.editor = _config.editor\n } else {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n }\n\n if (typeof field.editor === 'function') {\n field.editor = await field.editor({\n config: _config,\n isRoot: requireFieldLevelRichTextEditor,\n parentIsLocalized: parentIsLocalized || field.localized,\n })\n }\n\n if (field.editor.i18n && Object.keys(field.editor.i18n).length >= 0) {\n config.i18n.translations = deepMergeSimple(config.i18n.translations, field.editor.i18n)\n }\n }\n if (richTextSanitizationPromises) {\n richTextSanitizationPromises.push(sanitizeRichText)\n } else {\n await sanitizeRichText(config as unknown as SanitizedConfig)\n }\n }\n\n if (field.type === 'blocks' && field.blocks) {\n for (const block of field.blocks) {\n if (block._sanitized === true) {\n continue\n }\n block._sanitized = true\n block.fields = block.fields.concat(baseBlockFields)\n block.labels = !block.labels ? formatLabels(block.slug) : block.labels\n block.fields = await sanitizeFields({\n config,\n existingFieldNames: new Set(),\n fields: block.fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n }\n\n if ('fields' in field && field.fields) {\n field.fields = await sanitizeFields({\n config,\n existingFieldNames: fieldAffectsData(field) ? new Set() : existingFieldNames,\n fields: field.fields,\n joinPath: fieldAffectsData(field)\n ? `${joinPath ? joinPath + '.' : ''}${field.name}`\n : joinPath,\n joins,\n parentIsLocalized: parentIsLocalized || field.localized,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n\n if (field.type === 'tabs') {\n for (let j = 0; j < field.tabs.length; j++) {\n const tab = field.tabs[j]\n if (tabHasName(tab) && typeof tab.label === 'undefined') {\n tab.label = toWords(tab.name)\n }\n\n tab.fields = await sanitizeFields({\n config,\n existingFieldNames: tabHasName(tab) ? new Set() : existingFieldNames,\n fields: tab.fields,\n joinPath: tabHasName(tab) ? `${joinPath ? joinPath + '.' : ''}${tab.name}` : joinPath,\n joins,\n parentIsLocalized: parentIsLocalized || (tabHasName(tab) && tab.localized),\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n field.tabs[j] = tab\n }\n }\n\n if (field.type === 'ui' && typeof field.admin.disableBulkEdit === 'undefined') {\n field.admin.disableBulkEdit = true\n }\n\n if ('_sanitized' in field) {\n field._sanitized = true\n }\n\n fields[i] = field\n }\n\n return fields\n}\n"],"names":["deepMergeSimple","DuplicateFieldName","InvalidFieldName","InvalidFieldRelationship","MissingEditorProp","MissingFieldType","formatLabels","toWords","baseBlockFields","baseIDField","setDefaultBeforeDuplicate","validations","sanitizeJoinField","fieldAffectsData","tabHasName","sanitizeFields","config","existingFieldNames","Set","fields","joinPath","joins","parentIsLocalized","requireFieldLevelRichTextEditor","richTextSanitizationPromises","validRelationships","i","length","field","_sanitized","type","name","includes","label","defaultValue","required","relationships","Array","isArray","relationTo","forEach","relationship","min","minRows","console","warn","max","maxRows","admin","isSortable","push","labels","has","add","localized","shouldDisableLocalized","localization","compatibility","allowLocalizedWithinLocalized","validate","defaultValidate","val","options","virtual","hooks","access","sanitizeRichText","_config","editor","isRoot","i18n","Object","keys","translations","blocks","block","concat","slug","j","tabs","tab","disableBulkEdit"],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M;oBAClBC,UAAUN,WAAWkE,OAAO,CAAC,EAAE5D,WAAWA,WAAW,MAAM,GAAG,EAAE4D,IAAIjD,IAAI,CAAC,CAAC,GAAGX;oBAC7EC;oBACAC,mBAAmBA,qBAAsBR,WAAWkE,QAAQA,IAAI1B,SAAS;oBACzE/B;oBACAC;oBACAC;gBACF;gBACAG,MAAMmD,IAAI,CAACD,EAAE,GAAGE;YAClB;QACF;QAEA,IAAIpD,MAAME,IAAI,KAAK,QAAQ,OAAOF,MAAMoB,KAAK,CAACiC,eAAe,KAAK,aAAa;YAC7ErD,MAAMoB,KAAK,CAACiC,eAAe,GAAG;QAChC;QAEA,IAAI,gBAAgBrD,OAAO;YACzBA,MAAMC,UAAU,GAAG;QACrB;QAEAV,MAAM,CAACO,EAAE,GAAGE;IACd;IAEA,OAAOT;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/config/sanitize.ts"],"sourcesContent":["import { deepMergeSimple } from '@payloadcms/translations/utilities'\n\nimport type { CollectionConfig, SanitizedJoins } from '../../collections/config/types.js'\nimport type { Config, SanitizedConfig } from '../../config/types.js'\nimport type { Field } from './types.js'\n\nimport {\n DuplicateFieldName,\n InvalidFieldName,\n InvalidFieldRelationship,\n MissingEditorProp,\n MissingFieldType,\n} from '../../errors/index.js'\nimport { formatLabels, toWords } from '../../utilities/formatLabels.js'\nimport { baseBlockFields } from '../baseFields/baseBlockFields.js'\nimport { baseIDField } from '../baseFields/baseIDField.js'\nimport { setDefaultBeforeDuplicate } from '../setDefaultBeforeDuplicate.js'\nimport validations from '../validations.js'\nimport { sanitizeJoinField } from './sanitizeJoinField.js'\nimport { fieldAffectsData, tabHasName } from './types.js'\n\ntype Args = {\n collectionConfig?: CollectionConfig\n config: Config\n existingFieldNames?: Set<string>\n fields: Field[]\n joinPath?: string\n /**\n * When not passed in, assume that join are not supported (globals, arrays, blocks)\n */\n joins?: SanitizedJoins\n parentIsLocalized: boolean\n\n /**\n * If true, a richText field will require an editor property to be set, as the sanitizeFields function will not add it from the payload config if not present.\n *\n * @default false\n */\n requireFieldLevelRichTextEditor?: boolean\n /**\n * If this property is set, RichText fields won't be sanitized immediately. Instead, they will be added to this array as promises\n * so that you can sanitize them together, after the config has been sanitized.\n */\n richTextSanitizationPromises?: Array<(config: SanitizedConfig) => Promise<void>>\n /**\n * If not null, will validate that upload and relationship fields do not relate to a collection that is not in this array.\n * This validation will be skipped if validRelationships is null.\n */\n validRelationships: null | string[]\n}\n\nexport const sanitizeFields = async ({\n config,\n existingFieldNames = new Set(),\n fields,\n joinPath = '',\n joins,\n parentIsLocalized,\n requireFieldLevelRichTextEditor = false,\n richTextSanitizationPromises,\n validRelationships,\n}: Args): Promise<Field[]> => {\n if (!fields) {\n return []\n }\n\n for (let i = 0; i < fields.length; i++) {\n const field = fields[i]\n\n if ('_sanitized' in field && field._sanitized === true) {\n continue\n }\n\n if (!field.type) {\n throw new MissingFieldType(field)\n }\n\n // assert that field names do not contain forbidden characters\n if (fieldAffectsData(field) && field.name.includes('.')) {\n throw new InvalidFieldName(field, field.name)\n }\n\n // Auto-label\n if (\n 'name' in field &&\n field.name &&\n typeof field.label !== 'object' &&\n typeof field.label !== 'string' &&\n typeof field.label !== 'function' &&\n field.label !== false\n ) {\n field.label = toWords(field.name)\n }\n\n if (\n field.type === 'checkbox' &&\n typeof field.defaultValue === 'undefined' &&\n field.required === true\n ) {\n field.defaultValue = false\n }\n\n if (field.type === 'join') {\n sanitizeJoinField({ config, field, joinPath, joins })\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n if (validRelationships) {\n const relationships = Array.isArray(field.relationTo)\n ? field.relationTo\n : [field.relationTo]\n relationships.forEach((relationship: string) => {\n if (!validRelationships.includes(relationship)) {\n throw new InvalidFieldRelationship(field, relationship)\n }\n })\n }\n\n if (field.min && !field.minRows) {\n console.warn(\n `(payload): The \"min\" property is deprecated for the Relationship field \"${field.name}\" and will be removed in a future version. Please use \"minRows\" instead.`,\n )\n }\n if (field.max && !field.maxRows) {\n console.warn(\n `(payload): The \"max\" property is deprecated for the Relationship field \"${field.name}\" and will be removed in a future version. Please use \"maxRows\" instead.`,\n )\n }\n field.minRows = field.minRows || field.min\n field.maxRows = field.maxRows || field.max\n }\n\n if (field.type === 'upload') {\n if (!field.admin || !('isSortable' in field.admin)) {\n field.admin = {\n isSortable: true,\n ...field.admin,\n }\n }\n }\n\n if (field.type === 'array' && field.fields) {\n field.fields.push(baseIDField)\n }\n\n if ((field.type === 'blocks' || field.type === 'array') && field.label) {\n field.labels = field.labels || formatLabels(field.name)\n }\n\n if (fieldAffectsData(field)) {\n if (existingFieldNames.has(field.name)) {\n throw new DuplicateFieldName(field.name)\n } else if (!['blockName', 'id'].includes(field.name)) {\n existingFieldNames.add(field.name)\n }\n\n if (typeof field.localized !== 'undefined') {\n let shouldDisableLocalized = !config.localization\n\n if (!config.compatibility?.allowLocalizedWithinLocalized && parentIsLocalized) {\n shouldDisableLocalized = true\n }\n\n if (shouldDisableLocalized) {\n delete field.localized\n }\n }\n\n if (typeof field.validate === 'undefined') {\n const defaultValidate = validations[field.type]\n if (defaultValidate) {\n field.validate = (val, options) => defaultValidate(val, { ...field, ...options })\n } else {\n field.validate = (): true => true\n }\n }\n\n if (!field.hooks) {\n field.hooks = {}\n }\n if (!field.access) {\n field.access = {}\n }\n\n setDefaultBeforeDuplicate(field)\n }\n\n if (!field.admin) {\n field.admin = {}\n }\n\n // Make sure that the richText field has an editor\n if (field.type === 'richText') {\n const sanitizeRichText = async (_config: SanitizedConfig) => {\n if (!field.editor) {\n if (_config.editor && !requireFieldLevelRichTextEditor) {\n // config.editor should be sanitized at this point\n field.editor = _config.editor\n } else {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n }\n\n if (typeof field.editor === 'function') {\n field.editor = await field.editor({\n config: _config,\n isRoot: requireFieldLevelRichTextEditor,\n parentIsLocalized: parentIsLocalized || field.localized,\n })\n }\n\n if (field.editor.i18n && Object.keys(field.editor.i18n).length >= 0) {\n config.i18n.translations = deepMergeSimple(config.i18n.translations, field.editor.i18n)\n }\n }\n if (richTextSanitizationPromises) {\n richTextSanitizationPromises.push(sanitizeRichText)\n } else {\n await sanitizeRichText(config as unknown as SanitizedConfig)\n }\n }\n\n if (field.type === 'blocks' && field.blocks) {\n for (const block of field.blocks) {\n if (block._sanitized === true) {\n continue\n }\n block._sanitized = true\n block.fields = block.fields.concat(baseBlockFields)\n block.labels = !block.labels ? formatLabels(block.slug) : block.labels\n block.fields = await sanitizeFields({\n config,\n existingFieldNames: new Set(),\n fields: block.fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n }\n\n if ('fields' in field && field.fields) {\n field.fields = await sanitizeFields({\n config,\n existingFieldNames: fieldAffectsData(field) ? new Set() : existingFieldNames,\n fields: field.fields,\n joinPath: fieldAffectsData(field)\n ? `${joinPath ? joinPath + '.' : ''}${field.name}`\n : joinPath,\n joins,\n parentIsLocalized: parentIsLocalized || field.localized,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n\n if (field.type === 'tabs') {\n for (let j = 0; j < field.tabs.length; j++) {\n const tab = field.tabs[j]\n if (tabHasName(tab) && typeof tab.label === 'undefined') {\n tab.label = toWords(tab.name)\n }\n\n tab.fields = await sanitizeFields({\n config,\n existingFieldNames: tabHasName(tab) ? new Set() : existingFieldNames,\n fields: tab.fields,\n joinPath: tabHasName(tab) ? `${joinPath ? joinPath + '.' : ''}${tab.name}` : joinPath,\n joins,\n parentIsLocalized: parentIsLocalized || (tabHasName(tab) && tab.localized),\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n field.tabs[j] = tab\n }\n }\n\n if (field.type === 'ui' && typeof field.admin.disableBulkEdit === 'undefined') {\n field.admin.disableBulkEdit = true\n }\n\n if ('_sanitized' in field) {\n field._sanitized = true\n }\n\n fields[i] = field\n }\n\n return fields\n}\n"],"names":["deepMergeSimple","DuplicateFieldName","InvalidFieldName","InvalidFieldRelationship","MissingEditorProp","MissingFieldType","formatLabels","toWords","baseBlockFields","baseIDField","setDefaultBeforeDuplicate","validations","sanitizeJoinField","fieldAffectsData","tabHasName","sanitizeFields","config","existingFieldNames","Set","fields","joinPath","joins","parentIsLocalized","requireFieldLevelRichTextEditor","richTextSanitizationPromises","validRelationships","i","length","field","_sanitized","type","name","includes","label","defaultValue","required","relationships","Array","isArray","relationTo","forEach","relationship","min","minRows","console","warn","max","maxRows","admin","isSortable","push","labels","has","add","localized","shouldDisableLocalized","localization","compatibility","allowLocalizedWithinLocalized","validate","defaultValidate","val","options","hooks","access","sanitizeRichText","_config","editor","isRoot","i18n","Object","keys","translations","blocks","block","concat","slug","j","tabs","tab","disableBulkEdit"],"mappings":"AAAA,SAASA,eAAe,QAAQ,qCAAoC;AAMpE,SACEC,kBAAkB,EAClBC,gBAAgB,EAChBC,wBAAwB,EACxBC,iBAAiB,EACjBC,gBAAgB,QACX,wBAAuB;AAC9B,SAASC,YAAY,EAAEC,OAAO,QAAQ,kCAAiC;AACvE,SAASC,eAAe,QAAQ,mCAAkC;AAClE,SAASC,WAAW,QAAQ,+BAA8B;AAC1D,SAASC,yBAAyB,QAAQ,kCAAiC;AAC3E,OAAOC,iBAAiB,oBAAmB;AAC3C,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,aAAY;AAgCzD,OAAO,MAAMC,iBAAiB,OAAO,EACnCC,MAAM,EACNC,qBAAqB,IAAIC,KAAK,EAC9BC,MAAM,EACNC,WAAW,EAAE,EACbC,KAAK,EACLC,iBAAiB,EACjBC,kCAAkC,KAAK,EACvCC,4BAA4B,EAC5BC,kBAAkB,EACb;IACL,IAAI,CAACN,QAAQ;QACX,OAAO,EAAE;IACX;IAEA,IAAK,IAAIO,IAAI,GAAGA,IAAIP,OAAOQ,MAAM,EAAED,IA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F;QACF;QAEA,IAAIG,MAAME,IAAI,KAAK,QAAQ;YACzB,IAAK,IAAI+C,IAAI,GAAGA,IAAIjD,MAAMkD,IAAI,CAACnD,MAAM,EAAEkD,IAAK;gBAC1C,MAAME,MAAMnD,MAAMkD,IAAI,CAACD,EAAE;gBACzB,IAAI/D,WAAWiE,QAAQ,OAAOA,IAAI9C,KAAK,KAAK,aAAa;oBACvD8C,IAAI9C,KAAK,GAAG1B,QAAQwE,IAAIhD,IAAI;gBAC9B;gBAEAgD,IAAI5D,MAAM,GAAG,MAAMJ,eAAe;oBAChCC;oBACAC,oBAAoBH,WAAWiE,OAAO,IAAI7D,QAAQD;oBAClDE,QAAQ4D,IAAI5D,MAAM;oBAClBC,UAAUN,WAAWiE,OAAO,CAAC,EAAE3D,WAAWA,WAAW,MAAM,GAAG,EAAE2D,IAAIhD,IAAI,CAAC,CAAC,GAAGX;oBAC7EC;oBACAC,mBAAmBA,qBAAsBR,WAAWiE,QAAQA,IAAIzB,SAAS;oBACzE/B;oBACAC;oBACAC;gBACF;gBACAG,MAAMkD,IAAI,CAACD,EAAE,GAAGE;YAClB;QACF;QAEA,IAAInD,MAAME,IAAI,KAAK,QAAQ,OAAOF,MAAMoB,KAAK,CAACgC,eAAe,KAAK,aAAa;YAC7EpD,MAAMoB,KAAK,CAACgC,eAAe,GAAG;QAChC;QAEA,IAAI,gBAAgBpD,OAAO;YACzBA,MAAMC,UAAU,GAAG;QACrB;QAEAV,MAAM,CAACO,EAAE,GAAGE;IACd;IAEA,OAAOT;AACT,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1-canary.d23ede3",
|
|
4
4
|
"description": "Node, React, Headless CMS and Application Framework built on Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"admin panel",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"tsx": "4.19.2",
|
|
98
98
|
"uuid": "10.0.0",
|
|
99
99
|
"ws": "^8.16.0",
|
|
100
|
-
"@payloadcms/translations": "3.0.
|
|
100
|
+
"@payloadcms/translations": "3.0.1-canary.d23ede3"
|
|
101
101
|
},
|
|
102
102
|
"devDependencies": {
|
|
103
103
|
"@hyrious/esbuild-plugin-commonjs": "^0.2.4",
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
"graphql-http": "^1.22.0",
|
|
115
115
|
"rimraf": "3.0.2",
|
|
116
116
|
"sharp": "0.32.6",
|
|
117
|
-
"@payloadcms/eslint-config": "3.0.0
|
|
117
|
+
"@payloadcms/eslint-config": "3.0.0"
|
|
118
118
|
},
|
|
119
119
|
"peerDependencies": {
|
|
120
120
|
"graphql": "^16.8.1"
|