payload 4.0.0-internal.5f0cd13 → 4.0.0-internal.a0ef1b8
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/admin/RichText.d.ts +22 -2
- package/dist/admin/RichText.d.ts.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/admin/adapters/devReload.d.ts +9 -0
- package/dist/admin/adapters/devReload.d.ts.map +1 -0
- package/dist/admin/adapters/devReload.js +6 -0
- package/dist/admin/adapters/devReload.js.map +1 -0
- package/dist/admin/adapters/index.d.ts +3 -0
- package/dist/admin/adapters/index.d.ts.map +1 -1
- package/dist/admin/adapters/index.js.map +1 -1
- package/dist/admin/adapters/render.d.ts +16 -0
- package/dist/admin/adapters/render.d.ts.map +1 -0
- package/dist/admin/adapters/render.js +7 -0
- package/dist/admin/adapters/render.js.map +1 -0
- package/dist/admin/adapters/views.d.ts +36 -0
- package/dist/admin/adapters/views.d.ts.map +1 -0
- package/dist/admin/adapters/views.js +7 -0
- package/dist/admin/adapters/views.js.map +1 -0
- package/dist/admin/forms/Field.d.ts +7 -0
- package/dist/admin/forms/Field.d.ts.map +1 -1
- package/dist/admin/forms/Field.js.map +1 -1
- package/dist/admin/forms/Form.d.ts +29 -0
- package/dist/admin/forms/Form.d.ts.map +1 -1
- package/dist/admin/forms/Form.js.map +1 -1
- package/dist/admin/functions/index.d.ts +9 -0
- package/dist/admin/functions/index.d.ts.map +1 -1
- package/dist/admin/functions/index.js.map +1 -1
- package/dist/admin/types.d.ts +1 -1
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/admin/types.js.map +1 -1
- package/dist/admin/views/dashboard.d.ts +7 -0
- package/dist/admin/views/dashboard.d.ts.map +1 -1
- package/dist/admin/views/dashboard.js.map +1 -1
- package/dist/admin/views/document.d.ts +7 -1
- package/dist/admin/views/document.d.ts.map +1 -1
- package/dist/admin/views/document.js.map +1 -1
- package/dist/auth/defaultAccess.d.ts +1 -1
- package/dist/auth/defaultAccess.d.ts.map +1 -1
- package/dist/auth/defaultAccess.js +1 -1
- package/dist/auth/defaultAccess.js.map +1 -1
- package/dist/auth/defaultUser.d.ts.map +1 -1
- package/dist/auth/defaultUser.js +2 -1
- package/dist/auth/defaultUser.js.map +1 -1
- package/dist/bin/build.d.ts +25 -0
- package/dist/bin/build.d.ts.map +1 -0
- package/dist/bin/build.js +80 -0
- package/dist/bin/build.js.map +1 -0
- package/dist/bin/build.spec.js +170 -0
- package/dist/bin/build.spec.js.map +1 -0
- package/dist/bin/generateImportMap/index.d.ts.map +1 -1
- package/dist/bin/generateImportMap/index.js +8 -5
- package/dist/bin/generateImportMap/index.js.map +1 -1
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.d.ts +5 -1
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.d.ts.map +1 -1
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.js +24 -18
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.js.map +1 -1
- package/dist/bin/generateTypes.d.ts +3 -2
- package/dist/bin/generateTypes.d.ts.map +1 -1
- package/dist/bin/generateTypes.js +4 -0
- package/dist/bin/generateTypes.js.map +1 -1
- package/dist/bin/index.d.ts.map +1 -1
- package/dist/bin/index.js +9 -0
- package/dist/bin/index.js.map +1 -1
- package/dist/bin/loadEnv.d.ts +3 -1
- package/dist/bin/loadEnv.d.ts.map +1 -1
- package/dist/bin/loadEnv.js +40 -10
- package/dist/bin/loadEnv.js.map +1 -1
- package/dist/collections/config/defaults.js +2 -2
- package/dist/collections/config/defaults.js.map +1 -1
- package/dist/collections/config/defaults.spec.js +47 -0
- package/dist/collections/config/defaults.spec.js.map +1 -0
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +1 -0
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/collections/operations/local/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/local/duplicate.js.map +1 -1
- package/dist/collections/operations/local/find.d.ts.map +1 -1
- package/dist/collections/operations/local/find.js.map +1 -1
- package/dist/collections/operations/local/findByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findByID.js.map +1 -1
- package/dist/collections/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersionByID.js.map +1 -1
- package/dist/collections/operations/local/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersions.js.map +1 -1
- package/dist/collections/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/local/restoreVersion.js.map +1 -1
- package/dist/collections/operations/utilities/update.d.ts.map +1 -1
- package/dist/collections/operations/utilities/update.js +16 -8
- package/dist/collections/operations/utilities/update.js.map +1 -1
- package/dist/config/types.d.ts +10 -1
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js +1 -0
- package/dist/config/types.js.map +1 -1
- package/dist/database/migrations/migrationsCollection.d.ts.map +1 -1
- package/dist/database/migrations/migrationsCollection.js +2 -1
- package/dist/database/migrations/migrationsCollection.js.map +1 -1
- package/dist/exports/shared.d.ts +20 -0
- package/dist/exports/shared.d.ts.map +1 -1
- package/dist/exports/shared.js +20 -0
- package/dist/exports/shared.js.map +1 -1
- package/dist/fields/config/client.d.ts +1 -1
- package/dist/fields/config/client.d.ts.map +1 -1
- package/dist/fields/config/client.js +1 -1
- package/dist/fields/config/client.js.map +1 -1
- package/dist/fields/validations.d.ts.map +1 -1
- package/dist/fields/validations.js +5 -4
- package/dist/fields/validations.js.map +1 -1
- package/dist/globals/config/sanitize.d.ts.map +1 -1
- package/dist/globals/config/sanitize.js +1 -0
- package/dist/globals/config/sanitize.js.map +1 -1
- package/dist/globals/config/sanitize.spec.js +43 -0
- package/dist/globals/config/sanitize.spec.js.map +1 -0
- package/dist/globals/operations/local/findOne.d.ts.map +1 -1
- package/dist/globals/operations/local/findOne.js.map +1 -1
- package/dist/globals/operations/local/update.d.ts.map +1 -1
- package/dist/globals/operations/local/update.js.map +1 -1
- package/dist/index.bundled.d.ts +178 -17
- package/dist/index.d.ts +8 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +50 -33
- package/dist/index.js.map +1 -1
- package/dist/kv/adapters/DatabaseKVAdapter.d.ts.map +1 -1
- package/dist/kv/adapters/DatabaseKVAdapter.js +1 -0
- package/dist/kv/adapters/DatabaseKVAdapter.js.map +1 -1
- package/dist/locked-documents/config.d.ts.map +1 -1
- package/dist/locked-documents/config.js +2 -1
- package/dist/locked-documents/config.js.map +1 -1
- package/dist/preferences/config.d.ts.map +1 -1
- package/dist/preferences/config.js +2 -1
- package/dist/preferences/config.js.map +1 -1
- package/dist/query-presets/config.d.ts.map +1 -1
- package/dist/query-presets/config.js +2 -1
- package/dist/query-presets/config.js.map +1 -1
- package/dist/queues/config/collection.d.ts.map +1 -1
- package/dist/queues/config/collection.js +2 -1
- package/dist/queues/config/collection.js.map +1 -1
- package/dist/queues/config/generateJobsJSONSchemas.js +2 -2
- package/dist/queues/config/generateJobsJSONSchemas.js.map +1 -1
- package/dist/queues/config/global.d.ts.map +1 -1
- package/dist/queues/config/global.js +2 -1
- package/dist/queues/config/global.js.map +1 -1
- package/dist/uploads/fetchAPI-multipart/processMultipart.d.ts.map +1 -1
- package/dist/uploads/fetchAPI-multipart/processMultipart.js +14 -1
- package/dist/uploads/fetchAPI-multipart/processMultipart.js.map +1 -1
- package/dist/uploads/generateFileData.d.ts +2 -1
- package/dist/uploads/generateFileData.d.ts.map +1 -1
- package/dist/uploads/generateFileData.js +5 -2
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/uploads/safeFetch.d.ts.map +1 -1
- package/dist/uploads/safeFetch.js +11 -5
- package/dist/uploads/safeFetch.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts +25 -0
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +73 -31
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/configToJSONSchema.spec.js +216 -29
- package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
- package/dist/utilities/dependencies/dependencyChecker.js +1 -1
- package/dist/utilities/dependencies/dependencyChecker.js.map +1 -1
- package/dist/utilities/dependencies/getDependencies.d.ts.map +1 -1
- package/dist/utilities/dependencies/getDependencies.js +5 -5
- package/dist/utilities/dependencies/getDependencies.js.map +1 -1
- package/dist/utilities/dynamicImport.js +1 -1
- package/dist/utilities/dynamicImport.js.map +1 -1
- package/dist/utilities/formatErrors.d.ts.map +1 -1
- package/dist/utilities/formatErrors.js +3 -1
- package/dist/utilities/formatErrors.js.map +1 -1
- package/dist/utilities/getRequestLanguage.d.ts +2 -2
- package/dist/utilities/getRequestLanguage.d.ts.map +1 -1
- package/dist/utilities/getRequestLanguage.js.map +1 -1
- package/dist/utilities/handleEndpoints.d.ts.map +1 -1
- package/dist/utilities/handleEndpoints.js +7 -3
- package/dist/utilities/handleEndpoints.js.map +1 -1
- package/dist/utilities/isRSCEnabled.d.ts +12 -0
- package/dist/utilities/isRSCEnabled.d.ts.map +1 -0
- package/dist/utilities/isRSCEnabled.js +14 -0
- package/dist/utilities/isRSCEnabled.js.map +1 -0
- package/dist/utilities/telemetry/conf/envPaths.d.ts.map +1 -1
- package/dist/utilities/telemetry/conf/envPaths.js +31 -40
- package/dist/utilities/telemetry/conf/envPaths.js.map +1 -1
- package/dist/utilities/transformColumnPreferences.js +4 -2
- package/dist/utilities/transformColumnPreferences.js.map +1 -1
- package/package.json +8 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utilities/dependencies/getDependencies.ts"],"sourcesContent":["/*\n This source code has been taken and modified from https://github.com/vercel/next.js/blob/41a80533f900467e1b788bd2673abe2dca20be6a/packages/next/src/lib/has-necessary-dependencies.ts\n\n License:\n\n The MIT License (MIT)\n\n Copyright (c) 2024 Vercel, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\n\nimport { promises as fs } from 'fs'\nimport path from 'path'\nimport { fileURLToPath } from 'url'\n\nimport { findUp } from '../findUp.js'\nimport { resolveFrom } from './resolveFrom.js'\n\
|
|
1
|
+
{"version":3,"sources":["../../../src/utilities/dependencies/getDependencies.ts"],"sourcesContent":["/*\n This source code has been taken and modified from https://github.com/vercel/next.js/blob/41a80533f900467e1b788bd2673abe2dca20be6a/packages/next/src/lib/has-necessary-dependencies.ts\n\n License:\n\n The MIT License (MIT)\n\n Copyright (c) 2024 Vercel, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\n\nimport { promises as fs } from 'fs'\nimport path from 'path'\nimport { fileURLToPath } from 'url'\n\nimport { findUp } from '../findUp.js'\nimport { resolveFrom } from './resolveFrom.js'\n\nexport type NecessaryDependencies = {\n missing: string[]\n resolved: Map<\n string,\n {\n path: string\n version: string\n }\n >\n}\n\nexport async function getDependencies(\n baseDir: string,\n requiredPackages: string[],\n): Promise<NecessaryDependencies> {\n const filename = fileURLToPath(import.meta.url)\n const dirname = path.dirname(filename)\n const payloadPkgDirname = path.resolve(dirname, '../../../') // pkg dir (outside src)\n const resolvedCwd = path.resolve(process.cwd())\n\n const resolutions = new Map<\n string,\n {\n path: string\n version: string\n }\n >()\n const missingPackages: string[] = []\n\n await Promise.all(\n requiredPackages.map(async (pkg) => {\n try {\n const pkgPath = await fs.realpath(resolveFrom(baseDir, pkg))\n const pkgDir = path.dirname(pkgPath)\n\n let packageJsonFilePath: null | string = null\n\n const foundPackageJsonDir = await findUp({\n dir: pkgDir,\n fileNames: ['package.json'],\n })\n\n if (foundPackageJsonDir) {\n const resolvedFoundPath = path.resolve(foundPackageJsonDir)\n\n if (\n resolvedFoundPath.startsWith(resolvedCwd) ||\n resolvedFoundPath.startsWith(payloadPkgDirname)\n ) {\n // We don't want to match node modules outside the user's project. Checking for both process.cwd and dirname is a reliable way to do this.\n packageJsonFilePath = resolvedFoundPath\n }\n }\n\n // No need to check if packageJsonFilePath exists - findUp checks that for us\n if (packageJsonFilePath) {\n // parse version\n const packageJson = JSON.parse(await fs.readFile(packageJsonFilePath, 'utf8'))\n const version = packageJson.version\n\n resolutions.set(pkg, {\n path: packageJsonFilePath,\n version,\n })\n } else {\n return missingPackages.push(pkg)\n }\n } catch (_) {\n return missingPackages.push(pkg)\n }\n }),\n )\n\n return {\n missing: missingPackages,\n resolved: resolutions,\n }\n}\n"],"names":["promises","fs","path","fileURLToPath","findUp","resolveFrom","getDependencies","baseDir","requiredPackages","filename","url","dirname","payloadPkgDirname","resolve","resolvedCwd","process","cwd","resolutions","Map","missingPackages","Promise","all","map","pkg","pkgPath","realpath","pkgDir","packageJsonFilePath","foundPackageJsonDir","dir","fileNames","resolvedFoundPath","startsWith","packageJson","JSON","parse","readFile","version","set","push","_","missing","resolved"],"mappings":"AAAA;;;;;;;;;;;;;;AAcA,GAEA,SAASA,YAAYC,EAAE,QAAQ,KAAI;AACnC,OAAOC,UAAU,OAAM;AACvB,SAASC,aAAa,QAAQ,MAAK;AAEnC,SAASC,MAAM,QAAQ,eAAc;AACrC,SAASC,WAAW,QAAQ,mBAAkB;AAa9C,OAAO,eAAeC,gBACpBC,OAAe,EACfC,gBAA0B;IAE1B,MAAMC,WAAWN,cAAc,YAAYO,GAAG;IAC9C,MAAMC,UAAUT,KAAKS,OAAO,CAACF;IAC7B,MAAMG,oBAAoBV,KAAKW,OAAO,CAACF,SAAS,aAAa,wBAAwB;;IACrF,MAAMG,cAAcZ,KAAKW,OAAO,CAACE,QAAQC,GAAG;IAE5C,MAAMC,cAAc,IAAIC;IAOxB,MAAMC,kBAA4B,EAAE;IAEpC,MAAMC,QAAQC,GAAG,CACfb,iBAAiBc,GAAG,CAAC,OAAOC;QAC1B,IAAI;YACF,MAAMC,UAAU,MAAMvB,GAAGwB,QAAQ,CAACpB,YAAYE,SAASgB;YACvD,MAAMG,SAASxB,KAAKS,OAAO,CAACa;YAE5B,IAAIG,sBAAqC;YAEzC,MAAMC,sBAAsB,MAAMxB,OAAO;gBACvCyB,KAAKH;gBACLI,WAAW;oBAAC;iBAAe;YAC7B;YAEA,IAAIF,qBAAqB;gBACvB,MAAMG,oBAAoB7B,KAAKW,OAAO,CAACe;gBAEvC,IACEG,kBAAkBC,UAAU,CAAClB,gBAC7BiB,kBAAkBC,UAAU,CAACpB,oBAC7B;oBACA,0IAA0I;oBAC1Ie,sBAAsBI;gBACxB;YACF;YAEA,6EAA6E;YAC7E,IAAIJ,qBAAqB;gBACvB,gBAAgB;gBAChB,MAAMM,cAAcC,KAAKC,KAAK,CAAC,MAAMlC,GAAGmC,QAAQ,CAACT,qBAAqB;gBACtE,MAAMU,UAAUJ,YAAYI,OAAO;gBAEnCpB,YAAYqB,GAAG,CAACf,KAAK;oBACnBrB,MAAMyB;oBACNU;gBACF;YACF,OAAO;gBACL,OAAOlB,gBAAgBoB,IAAI,CAAChB;YAC9B;QACF,EAAE,OAAOiB,GAAG;YACV,OAAOrB,gBAAgBoB,IAAI,CAAChB;QAC9B;IACF;IAGF,OAAO;QACLkB,SAAStB;QACTuB,UAAUzB;IACZ;AACF"}
|
|
@@ -13,7 +13,7 @@ import { pathToFileURL } from 'url';
|
|
|
13
13
|
// Vitest runs tests in a VM context where eval'd dynamic imports fail with
|
|
14
14
|
// ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING. Use direct import in test environment.
|
|
15
15
|
if (process.env.VITEST) {
|
|
16
|
-
return await import(/* webpackIgnore: true */ importPath);
|
|
16
|
+
return await import(/* webpackIgnore: true */ /* @vite-ignore */ importPath);
|
|
17
17
|
}
|
|
18
18
|
// Without the eval, the Next.js bundler will throw this error when encountering the import statement:
|
|
19
19
|
// ⚠ Compiled with warnings in X.Xs
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/dynamicImport.ts"],"sourcesContent":["import path from 'path'\nimport { pathToFileURL } from 'url'\n\n/**\n * Dynamically imports a module from a file path or module specifier.\n *\n * Uses a direct `import()` in Vitest (where eval'd imports fail with ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING),\n * and `eval(`import(...)`)` elsewhere to hide the import from Next.js bundler static analysis.\n *\n * @param modulePathOrSpecifier - Either an absolute file path or a module specifier (package name)\n */\nexport async function dynamicImport<T = unknown>(modulePathOrSpecifier: string): Promise<T> {\n // Convert absolute file paths to file:// URLs, but leave package specifiers as-is\n const importPath = path.isAbsolute(modulePathOrSpecifier)\n ? pathToFileURL(modulePathOrSpecifier).href\n : modulePathOrSpecifier\n\n // Vitest runs tests in a VM context where eval'd dynamic imports fail with\n // ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING. Use direct import in test environment.\n if (process.env.VITEST) {\n return await import(/* webpackIgnore: true */ importPath)\n }\n\n // Without the eval, the Next.js bundler will throw this error when encountering the import statement:\n // ⚠ Compiled with warnings in X.Xs\n // Critical dependency: the request of a dependency is an expression\n return await eval(`import('${importPath}')`)\n}\n"],"names":["path","pathToFileURL","dynamicImport","modulePathOrSpecifier","importPath","isAbsolute","href","process","env","VITEST","eval"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AACvB,SAASC,aAAa,QAAQ,MAAK;AAEnC;;;;;;;CAOC,GACD,OAAO,eAAeC,cAA2BC,qBAA6B;IAC5E,kFAAkF;IAClF,MAAMC,aAAaJ,KAAKK,UAAU,CAACF,yBAC/BF,cAAcE,uBAAuBG,IAAI,GACzCH;IAEJ,2EAA2E;IAC3E,iFAAiF;IACjF,IAAII,QAAQC,GAAG,CAACC,MAAM,EAAE;QACtB,OAAO,MAAM,MAAM,CAAC,uBAAuB,GAAGL;
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/dynamicImport.ts"],"sourcesContent":["import path from 'path'\nimport { pathToFileURL } from 'url'\n\n/**\n * Dynamically imports a module from a file path or module specifier.\n *\n * Uses a direct `import()` in Vitest (where eval'd imports fail with ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING),\n * and `eval(`import(...)`)` elsewhere to hide the import from Next.js bundler static analysis.\n *\n * @param modulePathOrSpecifier - Either an absolute file path or a module specifier (package name)\n */\nexport async function dynamicImport<T = unknown>(modulePathOrSpecifier: string): Promise<T> {\n // Convert absolute file paths to file:// URLs, but leave package specifiers as-is\n const importPath = path.isAbsolute(modulePathOrSpecifier)\n ? pathToFileURL(modulePathOrSpecifier).href\n : modulePathOrSpecifier\n\n // Vitest runs tests in a VM context where eval'd dynamic imports fail with\n // ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING. Use direct import in test environment.\n if (process.env.VITEST) {\n return await import(/* webpackIgnore: true */ /* @vite-ignore */ importPath)\n }\n\n // Without the eval, the Next.js bundler will throw this error when encountering the import statement:\n // ⚠ Compiled with warnings in X.Xs\n // Critical dependency: the request of a dependency is an expression\n return await eval(`import('${importPath}')`)\n}\n"],"names":["path","pathToFileURL","dynamicImport","modulePathOrSpecifier","importPath","isAbsolute","href","process","env","VITEST","eval"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AACvB,SAASC,aAAa,QAAQ,MAAK;AAEnC;;;;;;;CAOC,GACD,OAAO,eAAeC,cAA2BC,qBAA6B;IAC5E,kFAAkF;IAClF,MAAMC,aAAaJ,KAAKK,UAAU,CAACF,yBAC/BF,cAAcE,uBAAuBG,IAAI,GACzCH;IAEJ,2EAA2E;IAC3E,iFAAiF;IACjF,IAAII,QAAQC,GAAG,CAACC,MAAM,EAAE;QACtB,OAAO,MAAM,MAAM,CAAC,uBAAuB,GAAG,gBAAgB,GAAGL;IACnE;IAEA,sGAAsG;IACtG,mCAAmC;IACnC,oEAAoE;IACpE,OAAO,MAAMM,KAAK,CAAC,QAAQ,EAAEN,WAAW,EAAE,CAAC;AAC7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatErrors.d.ts","sourceRoot":"","sources":["../../src/utilities/formatErrors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAGhD,eAAO,MAAM,YAAY,GAAI,UAAU;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,GAAG,QAAQ,KAAG,
|
|
1
|
+
{"version":3,"file":"formatErrors.d.ts","sourceRoot":"","sources":["../../src/utilities/formatErrors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAGhD,eAAO,MAAM,YAAY,GAAI,UAAU;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,GAAG,QAAQ,KAAG,WAmE9E,CAAA"}
|
|
@@ -3,7 +3,9 @@ import { ValidationError } from '../errors/ValidationError.js';
|
|
|
3
3
|
export const formatErrors = (incoming)=>{
|
|
4
4
|
if (incoming) {
|
|
5
5
|
// Payload 'ValidationError' and 'APIError'
|
|
6
|
-
|
|
6
|
+
// Use duck-typing fallback alongside instanceof to handle bundlers (e.g. Vite)
|
|
7
|
+
// that may load duplicate module instances, causing instanceof to fail.
|
|
8
|
+
if ((incoming instanceof ValidationError || incoming instanceof APIError || 'isOperational' in incoming && incoming.isOperational === true) && incoming.data) {
|
|
7
9
|
return {
|
|
8
10
|
errors: [
|
|
9
11
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/formatErrors.ts"],"sourcesContent":["import type { ErrorResult } from '../config/types.js'\n\nimport { APIError } from '../errors/APIError.js'\nimport { ValidationError } from '../errors/ValidationError.js'\n\nexport const formatErrors = (incoming: { [key: string]: unknown } | APIError): ErrorResult => {\n if (incoming) {\n // Payload 'ValidationError' and 'APIError'\n if ((incoming instanceof ValidationError
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/formatErrors.ts"],"sourcesContent":["import type { ErrorResult } from '../config/types.js'\n\nimport { APIError } from '../errors/APIError.js'\nimport { ValidationError } from '../errors/ValidationError.js'\n\nexport const formatErrors = (incoming: { [key: string]: unknown } | APIError): ErrorResult => {\n if (incoming) {\n // Payload 'ValidationError' and 'APIError'\n // Use duck-typing fallback alongside instanceof to handle bundlers (e.g. Vite)\n // that may load duplicate module instances, causing instanceof to fail.\n if (\n (incoming instanceof ValidationError ||\n incoming instanceof APIError ||\n ('isOperational' in incoming && incoming.isOperational === true)) &&\n incoming.data\n ) {\n return {\n errors: [\n {\n name: incoming.name as string | undefined,\n data: incoming.data as Record<string, unknown>,\n message: incoming.message as string | undefined,\n },\n ],\n }\n }\n\n // Mongoose 'ValidationError': https://mongoosejs.com/docs/api/error.html#Error.ValidationError\n if (\n 'name' in incoming &&\n incoming.name === 'ValidationError' &&\n 'errors' in incoming &&\n incoming.errors\n ) {\n return {\n errors: Object.keys(incoming.errors).reduce(\n (acc, key) => {\n acc.push({\n field: (incoming.errors as any)[key].path,\n message: (incoming.errors as any)[key].message,\n })\n return acc\n },\n [] as { field: string; message: string }[],\n ),\n }\n }\n\n if (Array.isArray(incoming.message)) {\n return {\n errors: incoming.message,\n }\n }\n\n if (incoming.name) {\n return {\n errors: [\n {\n message: incoming.message as string,\n },\n ],\n }\n }\n }\n\n return {\n errors: [\n {\n message: 'An unknown error occurred.',\n },\n ],\n }\n}\n"],"names":["APIError","ValidationError","formatErrors","incoming","isOperational","data","errors","name","message","Object","keys","reduce","acc","key","push","field","path","Array","isArray"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,eAAe,QAAQ,+BAA8B;AAE9D,OAAO,MAAMC,eAAe,CAACC;IAC3B,IAAIA,UAAU;QACZ,2CAA2C;QAC3C,+EAA+E;QAC/E,wEAAwE;QACxE,IACE,AAACA,CAAAA,oBAAoBF,mBACnBE,oBAAoBH,YACnB,mBAAmBG,YAAYA,SAASC,aAAa,KAAK,IAAI,KACjED,SAASE,IAAI,EACb;YACA,OAAO;gBACLC,QAAQ;oBACN;wBACEC,MAAMJ,SAASI,IAAI;wBACnBF,MAAMF,SAASE,IAAI;wBACnBG,SAASL,SAASK,OAAO;oBAC3B;iBACD;YACH;QACF;QAEA,+FAA+F;QAC/F,IACE,UAAUL,YACVA,SAASI,IAAI,KAAK,qBAClB,YAAYJ,YACZA,SAASG,MAAM,EACf;YACA,OAAO;gBACLA,QAAQG,OAAOC,IAAI,CAACP,SAASG,MAAM,EAAEK,MAAM,CACzC,CAACC,KAAKC;oBACJD,IAAIE,IAAI,CAAC;wBACPC,OAAO,AAACZ,SAASG,MAAM,AAAQ,CAACO,IAAI,CAACG,IAAI;wBACzCR,SAAS,AAACL,SAASG,MAAM,AAAQ,CAACO,IAAI,CAACL,OAAO;oBAChD;oBACA,OAAOI;gBACT,GACA,EAAE;YAEN;QACF;QAEA,IAAIK,MAAMC,OAAO,CAACf,SAASK,OAAO,GAAG;YACnC,OAAO;gBACLF,QAAQH,SAASK,OAAO;YAC1B;QACF;QAEA,IAAIL,SAASI,IAAI,EAAE;YACjB,OAAO;gBACLD,QAAQ;oBACN;wBACEE,SAASL,SAASK,OAAO;oBAC3B;iBACD;YACH;QACF;IACF;IAEA,OAAO;QACLF,QAAQ;YACN;gBACEE,SAAS;YACX;SACD;IACH;AACF,EAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { AcceptedLanguages } from '@payloadcms/translations';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CookieStore } from '../admin/adapters/cookies.js';
|
|
3
3
|
import type { SanitizedConfig } from '../config/types.js';
|
|
4
4
|
type GetRequestLanguageArgs = {
|
|
5
5
|
config: SanitizedConfig;
|
|
6
|
-
cookies: Map<string, string
|
|
6
|
+
cookies: CookieStore | Map<string, string>;
|
|
7
7
|
defaultLanguage?: AcceptedLanguages;
|
|
8
8
|
headers: Request['headers'];
|
|
9
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRequestLanguage.d.ts","sourceRoot":"","sources":["../../src/utilities/getRequestLanguage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"getRequestLanguage.d.ts","sourceRoot":"","sources":["../../src/utilities/getRequestLanguage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAIjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEzD,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC1C,eAAe,CAAC,EAAE,iBAAiB,CAAA;IACnC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,+BAIhC,sBAAsB,KAAG,iBAqB3B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/getRequestLanguage.ts"],"sourcesContent":["import type { AcceptedLanguages } from '@payloadcms/translations'\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/getRequestLanguage.ts"],"sourcesContent":["import type { AcceptedLanguages } from '@payloadcms/translations'\n\nimport { extractHeaderLanguage } from '@payloadcms/translations'\n\nimport type { CookieStore } from '../admin/adapters/cookies.js'\nimport type { SanitizedConfig } from '../config/types.js'\n\ntype GetRequestLanguageArgs = {\n config: SanitizedConfig\n cookies: CookieStore | Map<string, string>\n defaultLanguage?: AcceptedLanguages\n headers: Request['headers']\n}\n\nexport const getRequestLanguage = ({\n config,\n cookies,\n headers,\n}: GetRequestLanguageArgs): AcceptedLanguages => {\n const supportedLanguageKeys = Object.keys(config.i18n.supportedLanguages) as AcceptedLanguages[]\n const langCookie = cookies.get(`${config.cookiePrefix || 'payload'}-lng`)\n\n const languageFromCookie: AcceptedLanguages = (\n typeof langCookie === 'string' ? langCookie : langCookie?.value\n ) as AcceptedLanguages\n\n if (languageFromCookie && supportedLanguageKeys.includes(languageFromCookie)) {\n return languageFromCookie\n }\n\n const languageFromHeader = headers.get('Accept-Language')\n ? extractHeaderLanguage(headers.get('Accept-Language')!)\n : undefined\n\n if (languageFromHeader && supportedLanguageKeys.includes(languageFromHeader)) {\n return languageFromHeader\n }\n\n return config.i18n.fallbackLanguage\n}\n"],"names":["extractHeaderLanguage","getRequestLanguage","config","cookies","headers","supportedLanguageKeys","Object","keys","i18n","supportedLanguages","langCookie","get","cookiePrefix","languageFromCookie","value","includes","languageFromHeader","undefined","fallbackLanguage"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,2BAA0B;AAYhE,OAAO,MAAMC,qBAAqB,CAAC,EACjCC,MAAM,EACNC,OAAO,EACPC,OAAO,EACgB;IACvB,MAAMC,wBAAwBC,OAAOC,IAAI,CAACL,OAAOM,IAAI,CAACC,kBAAkB;IACxE,MAAMC,aAAaP,QAAQQ,GAAG,CAAC,GAAGT,OAAOU,YAAY,IAAI,UAAU,IAAI,CAAC;IAExE,MAAMC,qBACJ,OAAOH,eAAe,WAAWA,aAAaA,YAAYI;IAG5D,IAAID,sBAAsBR,sBAAsBU,QAAQ,CAACF,qBAAqB;QAC5E,OAAOA;IACT;IAEA,MAAMG,qBAAqBZ,QAAQO,GAAG,CAAC,qBACnCX,sBAAsBI,QAAQO,GAAG,CAAC,sBAClCM;IAEJ,IAAID,sBAAsBX,sBAAsBU,QAAQ,CAACC,qBAAqB;QAC5E,OAAOA;IACT;IAEA,OAAOd,OAAOM,IAAI,CAACU,gBAAgB;AACrC,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleEndpoints.d.ts","sourceRoot":"","sources":["../../src/utilities/handleEndpoints.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA4B,eAAe,EAAE,MAAM,oBAAoB,CAAA;AA0BnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,eAAe,GAAU,+EAMnC;IACD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IAClD,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,OAAO,EAAE,OAAO,CAAA;CACjB,KAAG,OAAO,CAAC,QAAQ,
|
|
1
|
+
{"version":3,"file":"handleEndpoints.d.ts","sourceRoot":"","sources":["../../src/utilities/handleEndpoints.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA4B,eAAe,EAAE,MAAM,oBAAoB,CAAA;AA0BnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,eAAe,GAAU,+EAMnC;IACD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IAClD,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,OAAO,EAAE,OAAO,CAAA;CACjB,KAAG,OAAO,CAAC,QAAQ,CAmNnB,CAAA"}
|
|
@@ -56,6 +56,11 @@ const notFoundResponse = (req, pathname)=>{
|
|
|
56
56
|
// We use this internally for relationships querying on the frontend
|
|
57
57
|
// packages/ui/src/fields/Relationship/index.tsx
|
|
58
58
|
if (request.method.toLowerCase() === 'post' && (request.headers.get('X-Payload-HTTP-Method-Override') === 'GET' || request.headers.get('X-HTTP-Method-Override') === 'GET')) {
|
|
59
|
+
// Extract properties before consuming the body — srvx (TanStack Start) uses
|
|
60
|
+
// lazy property getters that reconstruct the underlying Request, which throws
|
|
61
|
+
// after the body has been read via .text() / .json().
|
|
62
|
+
const requestHeaders = request.headers;
|
|
63
|
+
const requestSignal = request.signal;
|
|
59
64
|
let url = request.url;
|
|
60
65
|
let data = undefined;
|
|
61
66
|
if (request.headers.get('Content-Type') === 'application/x-www-form-urlencoded') {
|
|
@@ -74,10 +79,9 @@ const notFoundResponse = (req, pathname)=>{
|
|
|
74
79
|
}
|
|
75
80
|
}
|
|
76
81
|
const req = new Request(url, {
|
|
77
|
-
|
|
78
|
-
headers: request.headers,
|
|
82
|
+
headers: requestHeaders,
|
|
79
83
|
method: 'GET',
|
|
80
|
-
signal:
|
|
84
|
+
signal: requestSignal
|
|
81
85
|
});
|
|
82
86
|
if (data) {
|
|
83
87
|
// @ts-expect-error attach data to request - less overhead than using urlencoded
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/handleEndpoints.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\nimport { match } from 'path-to-regexp'\n\nimport type { Collection } from '../collections/config/types.js'\nimport type { Endpoint, PayloadHandler, SanitizedConfig } from '../config/types.js'\nimport type { APIError } from '../errors/APIError.js'\nimport type { GlobalConfig } from '../globals/config/types.js'\nimport type { PayloadRequest } from '../types/index.js'\n\nimport { createPayloadRequest } from './createPayloadRequest.js'\nimport { formatAdminURL } from './formatAdminURL.js'\nimport { headersWithCors } from './headersWithCors.js'\nimport { mergeHeaders } from './mergeHeaders.js'\nimport { routeError } from './routeError.js'\n\nconst notFoundResponse = (req: PayloadRequest, pathname?: string) => {\n return Response.json(\n {\n message: `Route not found \"${pathname ?? new URL(req.url!).pathname}\"`,\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.NOT_FOUND,\n },\n )\n}\n\n/**\n * Attaches the Payload REST API to any backend framework that uses Fetch Request/Response\n * like Next.js (app router), Remix, Bun, Hono.\n *\n * ### Example: Using Hono\n * ```ts\n * import { handleEndpoints } from 'payload';\n * import { serve } from '@hono/node-server';\n * import { loadEnv } from 'payload/node';\n *\n * const port = 3001;\n * loadEnv();\n *\n * const { default: config } = await import('@payload-config');\n *\n * const server = serve({\n * fetch: async (request) => {\n * const response = await handleEndpoints({\n * config,\n * request: request.clone(),\n * });\n *\n * return response;\n * },\n * port,\n * });\n *\n * server.on('listening', () => {\n * console.log(`API server is listening on http://localhost:${port}/api`);\n * });\n * ```\n */\nexport const handleEndpoints = async ({\n basePath = '',\n config: incomingConfig,\n path,\n payloadInstanceCacheKey,\n request,\n}: {\n basePath?: string\n config: Promise<SanitizedConfig> | SanitizedConfig\n /** Override path from the request */\n path?: string\n payloadInstanceCacheKey?: string\n request: Request\n}): Promise<Response> => {\n let handler!: PayloadHandler\n let req: PayloadRequest\n let collection!: Collection\n\n // This can be used against GET request search params size limit.\n // Instead you can do POST request with a text body as search params.\n // We use this internally for relationships querying on the frontend\n // packages/ui/src/fields/Relationship/index.tsx\n if (\n request.method.toLowerCase() === 'post' &&\n (request.headers.get('X-Payload-HTTP-Method-Override') === 'GET' ||\n request.headers.get('X-HTTP-Method-Override') === 'GET')\n ) {\n let url = request.url\n let data: any = undefined\n\n if (request.headers.get('Content-Type') === 'application/x-www-form-urlencoded') {\n const search = await request.text()\n url = `${request.url}?${search}`\n } else if (request.headers.get('Content-Type') === 'application/json') {\n // May not be supported by every endpoint\n data = await request.json()\n\n // locale and fallbackLocale is read by createPayloadRequest to populate req.locale and req.fallbackLocale\n // => add to searchParams\n if (data?.locale) {\n url += `?locale=${data.locale}`\n }\n if (data?.fallbackLocale) {\n url += `&fallbackLocale=${data.depth}`\n }\n }\n\n const req = new Request(url, {\n credentials: request.credentials,\n headers: request.headers,\n method: 'GET',\n signal: request.signal,\n })\n\n if (data) {\n // @ts-expect-error attach data to request - less overhead than using urlencoded\n req.data = data\n }\n\n const response = await handleEndpoints({\n basePath,\n config: incomingConfig,\n path,\n payloadInstanceCacheKey,\n request: req,\n })\n\n return response\n }\n\n try {\n req = await createPayloadRequest({\n canSetHeaders: true,\n config: incomingConfig,\n payloadInstanceCacheKey,\n request,\n })\n\n const { payload } = req\n const { config } = payload\n\n const pathname = path ?? new URL(req.url!).pathname\n const baseAPIPath = formatAdminURL({\n apiRoute: config.routes.api,\n path: '',\n })\n\n if (!pathname.startsWith(baseAPIPath)) {\n return notFoundResponse(req, pathname)\n }\n\n // /api/posts/route -> /posts/route\n let adjustedPathname = pathname.replace(baseAPIPath, '')\n\n let isGlobals = false\n\n // /globals/header/route -> /header/route\n if (adjustedPathname.startsWith('/globals')) {\n isGlobals = true\n adjustedPathname = adjustedPathname.replace('/globals', '')\n }\n\n const segments = adjustedPathname.split('/')\n // remove empty string first element\n segments.shift()\n\n const firstParam = segments[0]\n\n let globalConfig!: GlobalConfig\n\n // first param can be a global slug or collection slug, find the relevant config\n if (firstParam) {\n if (isGlobals) {\n globalConfig = payload.globals.config.find((each) => each.slug === firstParam)!\n } else if (payload.collections[firstParam]) {\n collection = payload.collections[firstParam]\n }\n }\n\n let endpoints: Endpoint[] | false = config.endpoints\n\n if (collection) {\n endpoints = collection.config.endpoints\n // /posts/route -> /route\n adjustedPathname = adjustedPathname.replace(`/${collection.config.slug}`, '')\n } else if (globalConfig) {\n // /header/route -> /route\n adjustedPathname = adjustedPathname.replace(`/${globalConfig.slug}`, '')\n endpoints = globalConfig.endpoints!\n }\n\n // sanitize when endpoint.path is '/'\n if (adjustedPathname === '') {\n adjustedPathname = '/'\n }\n\n if (endpoints === false) {\n return Response.json(\n {\n message: `Cannot ${req.method?.toUpperCase()} ${req.url}`,\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.NOT_IMPLEMENTED,\n },\n )\n }\n\n // Find the relevant endpoint configuration\n const endpoint = endpoints?.find((endpoint) => {\n if (endpoint.method !== req.method?.toLowerCase()) {\n return false\n }\n\n const pathMatchFn = match(endpoint.path, { decode: decodeURIComponent })\n\n const matchResult = pathMatchFn(adjustedPathname)\n\n if (!matchResult) {\n return false\n }\n\n req.routeParams = matchResult.params as Record<string, unknown>\n\n // Inject to routeParams the slug as well so it can be used later\n if (collection) {\n req.routeParams.collection = collection.config.slug\n } else if (globalConfig) {\n req.routeParams.global = globalConfig.slug\n }\n\n return true\n })\n\n if (endpoint) {\n handler = endpoint.handler\n }\n\n if (!handler) {\n // If no custom handler found and this is an OPTIONS request,\n // return default CORS response for preflight requests\n if (req.method?.toLowerCase() === 'options') {\n return Response.json(\n {},\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: 200,\n },\n )\n }\n\n return notFoundResponse(req, pathname)\n }\n\n const response = await handler(req)\n\n return new Response(response.body, {\n headers: headersWithCors({\n headers: mergeHeaders(req.responseHeaders ?? new Headers(), response.headers),\n req,\n }),\n status: response.status,\n statusText: response.statusText,\n })\n } catch (_err) {\n const err = _err as APIError\n return routeError({\n collection,\n config: incomingConfig,\n err,\n req: req!,\n })\n }\n}\n"],"names":["status","httpStatus","match","createPayloadRequest","formatAdminURL","headersWithCors","mergeHeaders","routeError","notFoundResponse","req","pathname","Response","json","message","URL","url","headers","Headers","NOT_FOUND","handleEndpoints","basePath","config","incomingConfig","path","payloadInstanceCacheKey","request","handler","collection","method","toLowerCase","get","data","undefined","search","text","locale","fallbackLocale","depth","Request","credentials","signal","response","canSetHeaders","payload","baseAPIPath","apiRoute","routes","api","startsWith","adjustedPathname","replace","isGlobals","segments","split","shift","firstParam","globalConfig","globals","find","each","slug","collections","endpoints","toUpperCase","NOT_IMPLEMENTED","endpoint","pathMatchFn","decode","decodeURIComponent","matchResult","routeParams","params","global","body","responseHeaders","statusText","_err","err"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAClD,SAASC,KAAK,QAAQ,iBAAgB;AAQtC,SAASC,oBAAoB,QAAQ,4BAA2B;AAChE,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,UAAU,QAAQ,kBAAiB;AAE5C,MAAMC,mBAAmB,CAACC,KAAqBC;IAC7C,OAAOC,SAASC,IAAI,CAClB;QACEC,SAAS,CAAC,iBAAiB,EAAEH,YAAY,IAAII,IAAIL,IAAIM,GAAG,EAAGL,QAAQ,CAAC,CAAC,CAAC;IACxE,GACA;QACEM,SAASX,gBAAgB;YACvBW,SAAS,IAAIC;YACbR;QACF;QACAT,QAAQC,WAAWiB,SAAS;IAC9B;AAEJ;AAEA;;;;;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gBAC3C,OAAOlB,SAASC,IAAI,CAClB,CAAC,GACD;oBACEI,SAASX,gBAAgB;wBACvBW,SAAS,IAAIC;wBACbR;oBACF;oBACAT,QAAQ;gBACV;YAEJ;YAEA,OAAOQ,iBAAiBC,KAAKC;QAC/B;QAEA,MAAM+B,WAAW,MAAMf,QAAQjB;QAE/B,OAAO,IAAIE,SAAS8B,SAASgC,IAAI,EAAE;YACjCzD,SAASX,gBAAgB;gBACvBW,SAASV,aAAaG,IAAIiE,eAAe,IAAI,IAAIzD,WAAWwB,SAASzB,OAAO;gBAC5EP;YACF;YACAT,QAAQyC,SAASzC,MAAM;YACvB2E,YAAYlC,SAASkC,UAAU;QACjC;IACF,EAAE,OAAOC,MAAM;QACb,MAAMC,MAAMD;QACZ,OAAOrE,WAAW;YAChBoB;YACAN,QAAQC;YACRuD;YACApE,KAAKA;QACP;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/handleEndpoints.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\nimport { match } from 'path-to-regexp'\n\nimport type { Collection } from '../collections/config/types.js'\nimport type { Endpoint, PayloadHandler, SanitizedConfig } from '../config/types.js'\nimport type { APIError } from '../errors/APIError.js'\nimport type { GlobalConfig } from '../globals/config/types.js'\nimport type { PayloadRequest } from '../types/index.js'\n\nimport { createPayloadRequest } from './createPayloadRequest.js'\nimport { formatAdminURL } from './formatAdminURL.js'\nimport { headersWithCors } from './headersWithCors.js'\nimport { mergeHeaders } from './mergeHeaders.js'\nimport { routeError } from './routeError.js'\n\nconst notFoundResponse = (req: PayloadRequest, pathname?: string) => {\n return Response.json(\n {\n message: `Route not found \"${pathname ?? new URL(req.url!).pathname}\"`,\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.NOT_FOUND,\n },\n )\n}\n\n/**\n * Attaches the Payload REST API to any backend framework that uses Fetch Request/Response\n * like Next.js (app router), Remix, Bun, Hono.\n *\n * ### Example: Using Hono\n * ```ts\n * import { handleEndpoints } from 'payload';\n * import { serve } from '@hono/node-server';\n * import { loadEnv } from 'payload/node';\n *\n * const port = 3001;\n * loadEnv();\n *\n * const { default: config } = await import('@payload-config');\n *\n * const server = serve({\n * fetch: async (request) => {\n * const response = await handleEndpoints({\n * config,\n * request: request.clone(),\n * });\n *\n * return response;\n * },\n * port,\n * });\n *\n * server.on('listening', () => {\n * console.log(`API server is listening on http://localhost:${port}/api`);\n * });\n * ```\n */\nexport const handleEndpoints = async ({\n basePath = '',\n config: incomingConfig,\n path,\n payloadInstanceCacheKey,\n request,\n}: {\n basePath?: string\n config: Promise<SanitizedConfig> | SanitizedConfig\n /** Override path from the request */\n path?: string\n payloadInstanceCacheKey?: string\n request: Request\n}): Promise<Response> => {\n let handler!: PayloadHandler\n let req: PayloadRequest\n let collection!: Collection\n\n // This can be used against GET request search params size limit.\n // Instead you can do POST request with a text body as search params.\n // We use this internally for relationships querying on the frontend\n // packages/ui/src/fields/Relationship/index.tsx\n if (\n request.method.toLowerCase() === 'post' &&\n (request.headers.get('X-Payload-HTTP-Method-Override') === 'GET' ||\n request.headers.get('X-HTTP-Method-Override') === 'GET')\n ) {\n // Extract properties before consuming the body — srvx (TanStack Start) uses\n // lazy property getters that reconstruct the underlying Request, which throws\n // after the body has been read via .text() / .json().\n const requestHeaders = request.headers\n const requestSignal = request.signal\n\n let url = request.url\n let data: any = undefined\n\n if (request.headers.get('Content-Type') === 'application/x-www-form-urlencoded') {\n const search = await request.text()\n url = `${request.url}?${search}`\n } else if (request.headers.get('Content-Type') === 'application/json') {\n // May not be supported by every endpoint\n data = await request.json()\n\n // locale and fallbackLocale is read by createPayloadRequest to populate req.locale and req.fallbackLocale\n // => add to searchParams\n if (data?.locale) {\n url += `?locale=${data.locale}`\n }\n if (data?.fallbackLocale) {\n url += `&fallbackLocale=${data.depth}`\n }\n }\n\n const req = new Request(url, {\n headers: requestHeaders,\n method: 'GET',\n signal: requestSignal,\n })\n\n if (data) {\n // @ts-expect-error attach data to request - less overhead than using urlencoded\n req.data = data\n }\n\n const response = await handleEndpoints({\n basePath,\n config: incomingConfig,\n path,\n payloadInstanceCacheKey,\n request: req,\n })\n\n return response\n }\n\n try {\n req = await createPayloadRequest({\n canSetHeaders: true,\n config: incomingConfig,\n payloadInstanceCacheKey,\n request,\n })\n\n const { payload } = req\n const { config } = payload\n\n const pathname = path ?? new URL(req.url!).pathname\n const baseAPIPath = formatAdminURL({\n apiRoute: config.routes.api,\n path: '',\n })\n\n if (!pathname.startsWith(baseAPIPath)) {\n return notFoundResponse(req, pathname)\n }\n\n // /api/posts/route -> /posts/route\n let adjustedPathname = pathname.replace(baseAPIPath, '')\n\n let isGlobals = false\n\n // /globals/header/route -> /header/route\n if (adjustedPathname.startsWith('/globals')) {\n isGlobals = true\n adjustedPathname = adjustedPathname.replace('/globals', '')\n }\n\n const segments = adjustedPathname.split('/')\n // remove empty string first element\n segments.shift()\n\n const firstParam = segments[0]\n\n let globalConfig!: GlobalConfig\n\n // first param can be a global slug or collection slug, find the relevant config\n if (firstParam) {\n if (isGlobals) {\n globalConfig = payload.globals.config.find((each) => each.slug === firstParam)!\n } else if (payload.collections[firstParam]) {\n collection = payload.collections[firstParam]\n }\n }\n\n let endpoints: Endpoint[] | false = config.endpoints\n\n if (collection) {\n endpoints = collection.config.endpoints\n // /posts/route -> /route\n adjustedPathname = adjustedPathname.replace(`/${collection.config.slug}`, '')\n } else if (globalConfig) {\n // /header/route -> /route\n adjustedPathname = adjustedPathname.replace(`/${globalConfig.slug}`, '')\n endpoints = globalConfig.endpoints!\n }\n\n // sanitize when endpoint.path is '/'\n if (adjustedPathname === '') {\n adjustedPathname = '/'\n }\n\n if (endpoints === false) {\n return Response.json(\n {\n message: `Cannot ${req.method?.toUpperCase()} ${req.url}`,\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.NOT_IMPLEMENTED,\n },\n )\n }\n\n // Find the relevant endpoint configuration\n const endpoint = endpoints?.find((endpoint) => {\n if (endpoint.method !== req.method?.toLowerCase()) {\n return false\n }\n\n const pathMatchFn = match(endpoint.path, { decode: decodeURIComponent })\n\n const matchResult = pathMatchFn(adjustedPathname)\n\n if (!matchResult) {\n return false\n }\n\n req.routeParams = matchResult.params as Record<string, unknown>\n\n // Inject to routeParams the slug as well so it can be used later\n if (collection) {\n req.routeParams.collection = collection.config.slug\n } else if (globalConfig) {\n req.routeParams.global = globalConfig.slug\n }\n\n return true\n })\n\n if (endpoint) {\n handler = endpoint.handler\n }\n\n if (!handler) {\n // If no custom handler found and this is an OPTIONS request,\n // return default CORS response for preflight requests\n if (req.method?.toLowerCase() === 'options') {\n return Response.json(\n {},\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: 200,\n },\n )\n }\n\n return notFoundResponse(req, pathname)\n }\n\n const response = await handler(req)\n\n return new Response(response.body, {\n headers: headersWithCors({\n headers: mergeHeaders(req.responseHeaders ?? new Headers(), response.headers),\n req,\n }),\n status: response.status,\n statusText: response.statusText,\n })\n } catch (_err) {\n const err = _err as APIError\n return routeError({\n collection,\n config: incomingConfig,\n err,\n req: req!,\n })\n }\n}\n"],"names":["status","httpStatus","match","createPayloadRequest","formatAdminURL","headersWithCors","mergeHeaders","routeError","notFoundResponse","req","pathname","Response","json","message","URL","url","headers","Headers","NOT_FOUND","handleEndpoints","basePath","config","incomingConfig","path","payloadInstanceCacheKey","request","handler","collection","method","toLowerCase","get","requestHeaders","requestSignal","signal","data","undefined","search","text","locale","fallbackLocale","depth","Request","response","canSetHeaders","payload","baseAPIPath","apiRoute","routes","api","startsWith","adjustedPathname","replace","isGlobals","segments","split","shift","firstParam","globalConfig","globals","find","each","slug","collections","endpoints","toUpperCase","NOT_IMPLEMENTED","endpoint","pathMatchFn","decode","decodeURIComponent","matchResult","routeParams","params","global","body","responseHeaders","statusText","_err","err"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAClD,SAASC,KAAK,QAAQ,iBAAgB;AAQt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AE;gBAAE6C,QAAQC;YAAmB;YAEtE,MAAMC,cAAcH,YAAYjB;YAEhC,IAAI,CAACoB,aAAa;gBAChB,OAAO;YACT;YAEA7D,IAAI8D,WAAW,GAAGD,YAAYE,MAAM;YAEpC,iEAAiE;YACjE,IAAI7C,YAAY;gBACdlB,IAAI8D,WAAW,CAAC5C,UAAU,GAAGA,WAAWN,MAAM,CAACwC,IAAI;YACrD,OAAO,IAAIJ,cAAc;gBACvBhD,IAAI8D,WAAW,CAACE,MAAM,GAAGhB,aAAaI,IAAI;YAC5C;YAEA,OAAO;QACT;QAEA,IAAIK,UAAU;YACZxC,UAAUwC,SAASxC,OAAO;QAC5B;QAEA,IAAI,CAACA,SAAS;YACZ,6DAA6D;YAC7D,sDAAsD;YACtD,IAAIjB,IAAImB,MAAM,EAAEC,kBAAkB,WAAW;gBAC3C,OAAOlB,SAASC,IAAI,CAClB,CAAC,GACD;oBACEI,SAASX,gBAAgB;wBACvBW,SAAS,IAAIC;wBACbR;oBACF;oBACAT,QAAQ;gBACV;YAEJ;YAEA,OAAOQ,iBAAiBC,KAAKC;QAC/B;QAEA,MAAMgC,WAAW,MAAMhB,QAAQjB;QAE/B,OAAO,IAAIE,SAAS+B,SAASgC,IAAI,EAAE;YACjC1D,SAASX,gBAAgB;gBACvBW,SAASV,aAAaG,IAAIkE,eAAe,IAAI,IAAI1D,WAAWyB,SAAS1B,OAAO;gBAC5EP;YACF;YACAT,QAAQ0C,SAAS1C,MAAM;YACvB4E,YAAYlC,SAASkC,UAAU;QACjC;IACF,EAAE,OAAOC,MAAM;QACb,MAAMC,MAAMD;QACZ,OAAOtE,WAAW;YAChBoB;YACAN,QAAQC;YACRwD;YACArE,KAAKA;QACP;IACF;AACF,EAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether React Server Components are supported in the current environment.
|
|
3
|
+
* Controlled by the `PAYLOAD_FRAMEWORK_RSC_ENABLED` environment variable.
|
|
4
|
+
*
|
|
5
|
+
* - `PAYLOAD_FRAMEWORK_RSC_ENABLED=true` → RSC is available (set by Next.js `withPayload` and
|
|
6
|
+
* TanStack Start's `payloadPlugin` via `@vitejs/plugin-rsc`)
|
|
7
|
+
* - `PAYLOAD_FRAMEWORK_RSC_ENABLED=false` → RSC is NOT available
|
|
8
|
+
*
|
|
9
|
+
* Defaults to `true` when the variable is not set.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isRSCEnabled(): boolean;
|
|
12
|
+
//# sourceMappingURL=isRSCEnabled.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isRSCEnabled.d.ts","sourceRoot":"","sources":["../../src/utilities/isRSCEnabled.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAEtC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether React Server Components are supported in the current environment.
|
|
3
|
+
* Controlled by the `PAYLOAD_FRAMEWORK_RSC_ENABLED` environment variable.
|
|
4
|
+
*
|
|
5
|
+
* - `PAYLOAD_FRAMEWORK_RSC_ENABLED=true` → RSC is available (set by Next.js `withPayload` and
|
|
6
|
+
* TanStack Start's `payloadPlugin` via `@vitejs/plugin-rsc`)
|
|
7
|
+
* - `PAYLOAD_FRAMEWORK_RSC_ENABLED=false` → RSC is NOT available
|
|
8
|
+
*
|
|
9
|
+
* Defaults to `true` when the variable is not set.
|
|
10
|
+
*/ export function isRSCEnabled() {
|
|
11
|
+
return process.env.PAYLOAD_FRAMEWORK_RSC_ENABLED !== 'false';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=isRSCEnabled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/isRSCEnabled.ts"],"sourcesContent":["/**\n * Whether React Server Components are supported in the current environment.\n * Controlled by the `PAYLOAD_FRAMEWORK_RSC_ENABLED` environment variable.\n *\n * - `PAYLOAD_FRAMEWORK_RSC_ENABLED=true` → RSC is available (set by Next.js `withPayload` and\n * TanStack Start's `payloadPlugin` via `@vitejs/plugin-rsc`)\n * - `PAYLOAD_FRAMEWORK_RSC_ENABLED=false` → RSC is NOT available\n *\n * Defaults to `true` when the variable is not set.\n */\nexport function isRSCEnabled(): boolean {\n return process.env.PAYLOAD_FRAMEWORK_RSC_ENABLED !== 'false'\n}\n"],"names":["isRSCEnabled","process","env","PAYLOAD_FRAMEWORK_RSC_ENABLED"],"mappings":"AAAA;;;;;;;;;CASC,GACD,OAAO,SAASA;IACd,OAAOC,QAAQC,GAAG,CAACC,6BAA6B,KAAK;AACvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envPaths.d.ts","sourceRoot":"","sources":["../../../../src/utilities/telemetry/conf/envPaths.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"envPaths.d.ts","sourceRoot":"","sources":["../../../../src/utilities/telemetry/conf/envPaths.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;GAYG;AAMH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAiB,EAAE;;CAAK;;;;;;EAgDhE"}
|
|
@@ -14,43 +14,6 @@
|
|
|
14
14
|
*/ import os from 'node:os';
|
|
15
15
|
import path from 'node:path';
|
|
16
16
|
import process from 'node:process';
|
|
17
|
-
const homedir = os.homedir();
|
|
18
|
-
const tmpdir = os.tmpdir();
|
|
19
|
-
const { env } = process;
|
|
20
|
-
const macos = (name)=>{
|
|
21
|
-
const library = path.join(homedir, 'Library');
|
|
22
|
-
return {
|
|
23
|
-
cache: path.join(library, 'Caches', name),
|
|
24
|
-
config: path.join(library, 'Preferences', name),
|
|
25
|
-
data: path.join(library, 'Application Support', name),
|
|
26
|
-
log: path.join(library, 'Logs', name),
|
|
27
|
-
temp: path.join(tmpdir, name)
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
const windows = (name)=>{
|
|
31
|
-
const appData = env.APPDATA || path.join(homedir, 'AppData', 'Roaming');
|
|
32
|
-
const localAppData = env.LOCALAPPDATA || path.join(homedir, 'AppData', 'Local');
|
|
33
|
-
return {
|
|
34
|
-
// Data/config/cache/log are invented by me as Windows isn't opinionated about this
|
|
35
|
-
cache: path.join(localAppData, name, 'Cache'),
|
|
36
|
-
config: path.join(appData, name, 'Config'),
|
|
37
|
-
data: path.join(localAppData, name, 'Data'),
|
|
38
|
-
log: path.join(localAppData, name, 'Log'),
|
|
39
|
-
temp: path.join(tmpdir, name)
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
|
43
|
-
const linux = (name)=>{
|
|
44
|
-
const username = path.basename(homedir);
|
|
45
|
-
return {
|
|
46
|
-
cache: path.join(env.XDG_CACHE_HOME || path.join(homedir, '.cache'), name),
|
|
47
|
-
config: path.join(env.XDG_CONFIG_HOME || path.join(homedir, '.config'), name),
|
|
48
|
-
data: path.join(env.XDG_DATA_HOME || path.join(homedir, '.local', 'share'), name),
|
|
49
|
-
// https://wiki.debian.org/XDGBaseDirectorySpecification#state
|
|
50
|
-
log: path.join(env.XDG_STATE_HOME || path.join(homedir, '.local', 'state'), name),
|
|
51
|
-
temp: path.join(tmpdir, username, name)
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
17
|
export function envPaths(name, { suffix = 'nodejs' } = {}) {
|
|
55
18
|
if (typeof name !== 'string') {
|
|
56
19
|
throw new TypeError(`Expected a string, got ${typeof name}`);
|
|
@@ -59,13 +22,41 @@ export function envPaths(name, { suffix = 'nodejs' } = {}) {
|
|
|
59
22
|
// Add suffix to prevent possible conflict with native apps
|
|
60
23
|
name += `-${suffix}`;
|
|
61
24
|
}
|
|
25
|
+
const homedir = os.homedir();
|
|
26
|
+
const tmpdir = os.tmpdir();
|
|
27
|
+
const { env } = process;
|
|
62
28
|
if (process.platform === 'darwin') {
|
|
63
|
-
|
|
29
|
+
const library = path.join(homedir, 'Library');
|
|
30
|
+
return {
|
|
31
|
+
cache: path.join(library, 'Caches', name),
|
|
32
|
+
config: path.join(library, 'Preferences', name),
|
|
33
|
+
data: path.join(library, 'Application Support', name),
|
|
34
|
+
log: path.join(library, 'Logs', name),
|
|
35
|
+
temp: path.join(tmpdir, name)
|
|
36
|
+
};
|
|
64
37
|
}
|
|
65
38
|
if (process.platform === 'win32') {
|
|
66
|
-
|
|
39
|
+
const appData = env.APPDATA || path.join(homedir, 'AppData', 'Roaming');
|
|
40
|
+
const localAppData = env.LOCALAPPDATA || path.join(homedir, 'AppData', 'Local');
|
|
41
|
+
return {
|
|
42
|
+
// Data/config/cache/log are invented by me as Windows isn't opinionated about this
|
|
43
|
+
cache: path.join(localAppData, name, 'Cache'),
|
|
44
|
+
config: path.join(appData, name, 'Config'),
|
|
45
|
+
data: path.join(localAppData, name, 'Data'),
|
|
46
|
+
log: path.join(localAppData, name, 'Log'),
|
|
47
|
+
temp: path.join(tmpdir, name)
|
|
48
|
+
};
|
|
67
49
|
}
|
|
68
|
-
|
|
50
|
+
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
|
51
|
+
const username = path.basename(homedir);
|
|
52
|
+
return {
|
|
53
|
+
cache: path.join(env.XDG_CACHE_HOME || path.join(homedir, '.cache'), name),
|
|
54
|
+
config: path.join(env.XDG_CONFIG_HOME || path.join(homedir, '.config'), name),
|
|
55
|
+
data: path.join(env.XDG_DATA_HOME || path.join(homedir, '.local', 'share'), name),
|
|
56
|
+
// https://wiki.debian.org/XDGBaseDirectorySpecification#state
|
|
57
|
+
log: path.join(env.XDG_STATE_HOME || path.join(homedir, '.local', 'state'), name),
|
|
58
|
+
temp: path.join(tmpdir, username, name)
|
|
59
|
+
};
|
|
69
60
|
}
|
|
70
61
|
|
|
71
62
|
//# sourceMappingURL=envPaths.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utilities/telemetry/conf/envPaths.ts"],"sourcesContent":["// @ts-strict-ignore\n/**\n * Taken from https://github.com/sindresorhus/env-paths/blob/main/index.js\n *\n * MIT License\n *\n * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport os from 'node:os'\nimport path from 'node:path'\nimport process from 'node:process'\n\
|
|
1
|
+
{"version":3,"sources":["../../../../src/utilities/telemetry/conf/envPaths.ts"],"sourcesContent":["// @ts-strict-ignore\n/**\n * Taken from https://github.com/sindresorhus/env-paths/blob/main/index.js\n *\n * MIT License\n *\n * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport os from 'node:os'\nimport path from 'node:path'\nimport process from 'node:process'\n\nexport function envPaths(name: string, { suffix = 'nodejs' } = {}) {\n if (typeof name !== 'string') {\n throw new TypeError(`Expected a string, got ${typeof name}`)\n }\n\n if (suffix) {\n // Add suffix to prevent possible conflict with native apps\n name += `-${suffix}`\n }\n\n const homedir = os.homedir()\n const tmpdir = os.tmpdir()\n const { env } = process\n\n if (process.platform === 'darwin') {\n const library = path.join(homedir, 'Library')\n return {\n cache: path.join(library, 'Caches', name),\n config: path.join(library, 'Preferences', name),\n data: path.join(library, 'Application Support', name),\n log: path.join(library, 'Logs', name),\n temp: path.join(tmpdir, name),\n }\n }\n\n if (process.platform === 'win32') {\n const appData = env.APPDATA || path.join(homedir, 'AppData', 'Roaming')\n const localAppData = env.LOCALAPPDATA || path.join(homedir, 'AppData', 'Local')\n return {\n // Data/config/cache/log are invented by me as Windows isn't opinionated about this\n cache: path.join(localAppData, name, 'Cache'),\n config: path.join(appData, name, 'Config'),\n data: path.join(localAppData, name, 'Data'),\n log: path.join(localAppData, name, 'Log'),\n temp: path.join(tmpdir, name),\n }\n }\n\n // https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html\n const username = path.basename(homedir)\n return {\n cache: path.join(env.XDG_CACHE_HOME || path.join(homedir, '.cache'), name),\n config: path.join(env.XDG_CONFIG_HOME || path.join(homedir, '.config'), name),\n data: path.join(env.XDG_DATA_HOME || path.join(homedir, '.local', 'share'), name),\n // https://wiki.debian.org/XDGBaseDirectorySpecification#state\n log: path.join(env.XDG_STATE_HOME || path.join(homedir, '.local', 'state'), name),\n temp: path.join(tmpdir, username, name),\n }\n}\n"],"names":["os","path","process","envPaths","name","suffix","TypeError","homedir","tmpdir","env","platform","library","join","cache","config","data","log","temp","appData","APPDATA","localAppData","LOCALAPPDATA","username","basename","XDG_CACHE_HOME","XDG_CONFIG_HOME","XDG_DATA_HOME","XDG_STATE_HOME"],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;;;;;;CAYC,GAED,OAAOA,QAAQ,UAAS;AACxB,OAAOC,UAAU,YAAW;AAC5B,OAAOC,aAAa,eAAc;AAElC,OAAO,SAASC,SAASC,IAAY,EAAE,EAAEC,SAAS,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC/D,IAAI,OAAOD,SAAS,UAAU;QAC5B,MAAM,IAAIE,UAAU,CAAC,uBAAuB,EAAE,OAAOF,MAAM;IAC7D;IAEA,IAAIC,QAAQ;QACV,2DAA2D;QAC3DD,QAAQ,CAAC,CAAC,EAAEC,QAAQ;IACtB;IAEA,MAAME,UAAUP,GAAGO,OAAO;IAC1B,MAAMC,SAASR,GAAGQ,MAAM;IACxB,MAAM,EAAEC,GAAG,EAAE,GAAGP;IAEhB,IAAIA,QAAQQ,QAAQ,KAAK,UAAU;QACjC,MAAMC,UAAUV,KAAKW,IAAI,CAACL,SAAS;QACnC,OAAO;YACLM,OAAOZ,KAAKW,IAAI,CAACD,SAAS,UAAUP;YACpCU,QAAQb,KAAKW,IAAI,CAACD,SAAS,eAAeP;YAC1CW,MAAMd,KAAKW,IAAI,CAACD,SAAS,uBAAuBP;YAChDY,KAAKf,KAAKW,IAAI,CAACD,SAAS,QAAQP;YAChCa,MAAMhB,KAAKW,IAAI,CAACJ,QAAQJ;QAC1B;IACF;IAEA,IAAIF,QAAQQ,QAAQ,KAAK,SAAS;QAChC,MAAMQ,UAAUT,IAAIU,OAAO,IAAIlB,KAAKW,IAAI,CAACL,SAAS,WAAW;QAC7D,MAAMa,eAAeX,IAAIY,YAAY,IAAIpB,KAAKW,IAAI,CAACL,SAAS,WAAW;QACvE,OAAO;YACL,mFAAmF;YACnFM,OAAOZ,KAAKW,IAAI,CAACQ,cAAchB,MAAM;YACrCU,QAAQb,KAAKW,IAAI,CAACM,SAASd,MAAM;YACjCW,MAAMd,KAAKW,IAAI,CAACQ,cAAchB,MAAM;YACpCY,KAAKf,KAAKW,IAAI,CAACQ,cAAchB,MAAM;YACnCa,MAAMhB,KAAKW,IAAI,CAACJ,QAAQJ;QAC1B;IACF;IAEA,+EAA+E;IAC/E,MAAMkB,WAAWrB,KAAKsB,QAAQ,CAAChB;IAC/B,OAAO;QACLM,OAAOZ,KAAKW,IAAI,CAACH,IAAIe,cAAc,IAAIvB,KAAKW,IAAI,CAACL,SAAS,WAAWH;QACrEU,QAAQb,KAAKW,IAAI,CAACH,IAAIgB,eAAe,IAAIxB,KAAKW,IAAI,CAACL,SAAS,YAAYH;QACxEW,MAAMd,KAAKW,IAAI,CAACH,IAAIiB,aAAa,IAAIzB,KAAKW,IAAI,CAACL,SAAS,UAAU,UAAUH;QAC5E,8DAA8D;QAC9DY,KAAKf,KAAKW,IAAI,CAACH,IAAIkB,cAAc,IAAI1B,KAAKW,IAAI,CAACL,SAAS,UAAU,UAAUH;QAC5Ea,MAAMhB,KAAKW,IAAI,CAACJ,QAAQc,UAAUlB;IACpC;AACF"}
|
|
@@ -13,8 +13,10 @@
|
|
|
13
13
|
if (typeof columns === 'string') {
|
|
14
14
|
try {
|
|
15
15
|
columnsToTransform = JSON.parse(columns);
|
|
16
|
-
} catch
|
|
17
|
-
|
|
16
|
+
} catch {
|
|
17
|
+
columnsToTransform = columns.includes(',') ? columns.split(',') : [
|
|
18
|
+
columns
|
|
19
|
+
];
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
if (columnsToTransform && Array.isArray(columnsToTransform)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/transformColumnPreferences.ts"],"sourcesContent":["import type { Column } from '../admin/types.js'\nimport type { ColumnPreference } from '../preferences/types.js'\n\nexport type ColumnsFromURL = string[]\n\n/**\n * Transforms various forms of columns into `ColumnPreference[]` which is what is stored in the user's preferences table\n * In React state, for example, columns are stored in in their entirety, including React components: `[{ accessor: 'title', active: true, Label: React.ReactNode, ... }]`\n * In the URL, they are stored as an array of strings: `['title', '-slug']`, where the `-` prefix is used to indicate that the column is inactive\n * However in the database, columns must be in this exact shape: `[{ accessor: 'title', active: true }, { accessor: 'slug', active: false }]`\n * This means that when handling columns, they need to be consistently transformed back and forth\n */\nexport const transformColumnsToPreferences = (\n columns: Column[] | ColumnPreference[] | ColumnsFromURL | string | undefined,\n): ColumnPreference[] | undefined => {\n if (!columns) {\n return undefined\n }\n\n let columnsToTransform = columns\n\n // Columns that originate from the URL are a stringified JSON array and need to be parsed first\n if (typeof columns === 'string') {\n try {\n columnsToTransform = JSON.parse(columns)\n } catch
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/transformColumnPreferences.ts"],"sourcesContent":["import type { Column } from '../admin/types.js'\nimport type { ColumnPreference } from '../preferences/types.js'\n\nexport type ColumnsFromURL = string[]\n\n/**\n * Transforms various forms of columns into `ColumnPreference[]` which is what is stored in the user's preferences table\n * In React state, for example, columns are stored in in their entirety, including React components: `[{ accessor: 'title', active: true, Label: React.ReactNode, ... }]`\n * In the URL, they are stored as an array of strings: `['title', '-slug']`, where the `-` prefix is used to indicate that the column is inactive\n * However in the database, columns must be in this exact shape: `[{ accessor: 'title', active: true }, { accessor: 'slug', active: false }]`\n * This means that when handling columns, they need to be consistently transformed back and forth\n */\nexport const transformColumnsToPreferences = (\n columns: Column[] | ColumnPreference[] | ColumnsFromURL | string | undefined,\n): ColumnPreference[] | undefined => {\n if (!columns) {\n return undefined\n }\n\n let columnsToTransform = columns\n\n // Columns that originate from the URL are a stringified JSON array and need to be parsed first\n if (typeof columns === 'string') {\n try {\n columnsToTransform = JSON.parse(columns)\n } catch {\n columnsToTransform = columns.includes(',') ? columns.split(',') : [columns]\n }\n }\n\n if (columnsToTransform && Array.isArray(columnsToTransform)) {\n return columnsToTransform.map((col) => {\n if (typeof col === 'string') {\n const active = col[0] !== '-'\n return { accessor: active ? col : col.slice(1), active }\n }\n\n return { accessor: col.accessor, active: col.active }\n })\n }\n}\n\n/**\n * Does the opposite of `transformColumnsToPreferences`, where `ColumnPreference[]` and `Column[]` are transformed into `ColumnsFromURL`\n * This is useful for storing the columns in the URL, where it appears as a simple comma delimited array of strings\n * The `-` prefix is used to indicate that the column is inactive\n */\nexport const transformColumnsToSearchParams = (\n columns: Column[] | ColumnPreference[],\n): ColumnsFromURL => {\n return columns?.map((col) => (col.active ? col.accessor : `-${col.accessor}`))\n}\n"],"names":["transformColumnsToPreferences","columns","undefined","columnsToTransform","JSON","parse","includes","split","Array","isArray","map","col","active","accessor","slice","transformColumnsToSearchParams"],"mappings":"AAKA;;;;;;CAMC,GACD,OAAO,MAAMA,gCAAgC,CAC3CC;IAEA,IAAI,CAACA,SAAS;QACZ,OAAOC;IACT;IAEA,IAAIC,qBAAqBF;IAEzB,+FAA+F;IAC/F,IAAI,OAAOA,YAAY,UAAU;QAC/B,IAAI;YACFE,qBAAqBC,KAAKC,KAAK,CAACJ;QAClC,EAAE,OAAM;YACNE,qBAAqBF,QAAQK,QAAQ,CAAC,OAAOL,QAAQM,KAAK,CAAC,OAAO;gBAACN;aAAQ;QAC7E;IACF;IAEA,IAAIE,sBAAsBK,MAAMC,OAAO,CAACN,qBAAqB;QAC3D,OAAOA,mBAAmBO,GAAG,CAAC,CAACC;YAC7B,IAAI,OAAOA,QAAQ,UAAU;gBAC3B,MAAMC,SAASD,GAAG,CAAC,EAAE,KAAK;gBAC1B,OAAO;oBAAEE,UAAUD,SAASD,MAAMA,IAAIG,KAAK,CAAC;oBAAIF;gBAAO;YACzD;YAEA,OAAO;gBAAEC,UAAUF,IAAIE,QAAQ;gBAAED,QAAQD,IAAIC,MAAM;YAAC;QACtD;IACF;AACF,EAAC;AAED;;;;CAIC,GACD,OAAO,MAAMG,iCAAiC,CAC5Cd;IAEA,OAAOA,SAASS,IAAI,CAACC,MAASA,IAAIC,MAAM,GAAGD,IAAIE,QAAQ,GAAG,CAAC,CAAC,EAAEF,IAAIE,QAAQ,EAAE;AAC9E,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.a0ef1b8",
|
|
4
4
|
"description": "Node, React, Headless CMS and Application Framework built on Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"admin panel",
|
|
@@ -41,8 +41,9 @@
|
|
|
41
41
|
"type": "module",
|
|
42
42
|
"exports": {
|
|
43
43
|
".": {
|
|
44
|
-
"import": "./dist/index.js",
|
|
45
44
|
"types": "./dist/index.d.ts",
|
|
45
|
+
"browser": "./dist/exports/shared.js",
|
|
46
|
+
"import": "./dist/index.js",
|
|
46
47
|
"default": "./dist/index.js"
|
|
47
48
|
},
|
|
48
49
|
"./internal": {
|
|
@@ -85,7 +86,7 @@
|
|
|
85
86
|
"bin.js"
|
|
86
87
|
],
|
|
87
88
|
"dependencies": {
|
|
88
|
-
"@next/env": "16.2.
|
|
89
|
+
"@next/env": "16.2.7",
|
|
89
90
|
"@types/busboy": "1.5.4",
|
|
90
91
|
"ajv": "8.20.0",
|
|
91
92
|
"bson-objectid": "2.0.4",
|
|
@@ -95,6 +96,8 @@
|
|
|
95
96
|
"croner": "10.0.1",
|
|
96
97
|
"dataloader": "2.2.3",
|
|
97
98
|
"deepmerge": "4.3.1",
|
|
99
|
+
"dotenv": "16.4.5",
|
|
100
|
+
"dotenv-expand": "11.0.6",
|
|
98
101
|
"file-type": "22.0.1",
|
|
99
102
|
"get-tsconfig": "4.14.0",
|
|
100
103
|
"http-status": "2.1.0",
|
|
@@ -111,11 +114,11 @@
|
|
|
111
114
|
"range-parser": "1.2.1",
|
|
112
115
|
"sanitize-filename": "1.6.4",
|
|
113
116
|
"ts-essentials": "10.0.3",
|
|
114
|
-
"tsx": "4.
|
|
117
|
+
"tsx": "4.22.4",
|
|
115
118
|
"undici": "7.25.0",
|
|
116
119
|
"uuid": "14.0.0",
|
|
117
120
|
"ws": "^8.16.0",
|
|
118
|
-
"@payloadcms/translations": "4.0.0-internal.
|
|
121
|
+
"@payloadcms/translations": "4.0.0-internal.a0ef1b8"
|
|
119
122
|
},
|
|
120
123
|
"devDependencies": {
|
|
121
124
|
"@hyrious/esbuild-plugin-commonjs": "0.2.6",
|