payload 3.68.0-internal-debug.591ab42 → 3.68.0-internal-debug.e9b66ee
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/auth/strategies/local/incrementLoginAttempts.js +1 -2
- package/dist/auth/strategies/local/incrementLoginAttempts.js.map +1 -1
- package/dist/bin/generateImportMap/iterateFields.js +1 -2
- package/dist/bin/generateImportMap/iterateFields.js.map +1 -1
- package/dist/bin/index.js +2 -4
- package/dist/bin/index.js.map +1 -1
- package/dist/bin/migrate.js +1 -2
- package/dist/bin/migrate.js.map +1 -1
- package/dist/collections/config/defaults.js +1 -2
- package/dist/collections/config/defaults.js.map +1 -1
- package/dist/config/find.js +1 -2
- package/dist/config/find.js.map +1 -1
- package/dist/errors/APIError.js +1 -2
- package/dist/errors/APIError.js.map +1 -1
- package/dist/errors/AuthenticationError.js.map +1 -1
- package/dist/errors/DuplicateCollection.js.map +1 -1
- package/dist/errors/DuplicateFieldName.js.map +1 -1
- package/dist/errors/DuplicateGlobal.js.map +1 -1
- package/dist/errors/ErrorDeletingFile.js.map +1 -1
- package/dist/errors/FileRetrievalError.js.map +1 -1
- package/dist/errors/FileUploadError.js.map +1 -1
- package/dist/errors/Forbidden.js.map +1 -1
- package/dist/errors/InvalidConfiguration.js.map +1 -1
- package/dist/errors/InvalidFieldJoin.js.map +1 -1
- package/dist/errors/InvalidFieldName.js.map +1 -1
- package/dist/errors/InvalidFieldRelationship.js.map +1 -1
- package/dist/errors/InvalidSchema.js.map +1 -1
- package/dist/errors/Locked.js.map +1 -1
- package/dist/errors/LockedAuth.js.map +1 -1
- package/dist/errors/MissingCollectionLabel.js.map +1 -1
- package/dist/errors/MissingEditorProp.js.map +1 -1
- package/dist/errors/MissingFieldInputOptions.js.map +1 -1
- package/dist/errors/MissingFieldType.js.map +1 -1
- package/dist/errors/MissingFile.js.map +1 -1
- package/dist/errors/NotFound.js.map +1 -1
- package/dist/errors/QueryError.js.map +1 -1
- package/dist/errors/ReservedFieldName.js.map +1 -1
- package/dist/errors/TimestampsRequired.js.map +1 -1
- package/dist/errors/UnauthorizedError.js.map +1 -1
- package/dist/errors/UnverifiedEmail.js.map +1 -1
- package/dist/errors/ValidationError.js.map +1 -1
- package/dist/fields/config/client.js +1 -2
- package/dist/fields/config/client.js.map +1 -1
- package/dist/kv/adapters/DatabaseKVAdapter.js.map +1 -1
- package/dist/queues/errors/index.js.map +1 -1
- package/dist/queues/operations/runJobs/index.js +1 -2
- package/dist/queues/operations/runJobs/index.js.map +1 -1
- package/dist/uploads/fetchAPI-multipart/utilities.js +1 -2
- package/dist/uploads/fetchAPI-multipart/utilities.js.map +1 -1
- package/dist/uploads/generateFileData.js +4 -8
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/utilities/createLocalReq.js.map +1 -1
- package/dist/utilities/deepCopyObject.js.map +1 -1
- package/dist/utilities/findUp.js +4 -8
- package/dist/utilities/findUp.js.map +1 -1
- package/dist/utilities/formatErrors.js.map +1 -1
- package/dist/utilities/getFieldPermissions.spec.js +2 -4
- package/dist/utilities/getFieldPermissions.spec.js.map +1 -1
- package/dist/utilities/parseParams/index.spec.js +5 -10
- package/dist/utilities/parseParams/index.spec.js.map +1 -1
- package/dist/utilities/telemetry/conf/index.js.map +1 -1
- package/dist/utilities/transformColumnPreferences.js +1 -2
- package/dist/utilities/transformColumnPreferences.js.map +1 -1
- package/dist/utilities/unflatten.js.map +1 -1
- package/package.json +2 -2
|
@@ -57,8 +57,7 @@ export const incrementLoginAttempts = async ({ collection, payload, req, user })
|
|
|
57
57
|
if (reachedMaxAttemptsForCurrentUser) {
|
|
58
58
|
user.lockUntil = updatedLockUntil;
|
|
59
59
|
}
|
|
60
|
-
user.loginAttempts = updatedLoginAttempts - 1 // -1, as the updated increment is applied for the *next* login attempt, not the current one
|
|
61
|
-
;
|
|
60
|
+
user.loginAttempts = updatedLoginAttempts - 1; // -1, as the updated increment is applied for the *next* login attempt, not the current one
|
|
62
61
|
if (reachedMaxAttemptsForNextUser && (!updatedLockUntil || !isUserLocked(new Date(updatedLockUntil)))) {
|
|
63
62
|
// If lockUntil reached max login attempts due to multiple parallel attempts but user was not locked yet,
|
|
64
63
|
const newLockUntil = new Date(currentTime + lockTime).toISOString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/auth/strategies/local/incrementLoginAttempts.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { PayloadRequest } from '../../../types/index.js'\n\nimport { type JsonObject, type Payload, type TypedUser } from '../../../index.js'\nimport { isUserLocked } from '../../isUserLocked.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig\n payload: Payload\n req: PayloadRequest\n user: TypedUser\n}\n\n// Note: this function does not use req in most updates, as we want those to be visible in parallel requests that are on a different\n// transaction. At the same time, we want updates from parallel requests to be visible here.\nexport const incrementLoginAttempts = async ({\n collection,\n payload,\n req,\n user,\n}: Args): Promise<void> => {\n const {\n auth: { lockTime, maxLoginAttempts },\n } = collection\n\n const currentTime = Date.now()\n\n let updatedLockUntil: null | string = null\n let updatedLoginAttempts: null | number = null\n\n if (user.lockUntil && !isUserLocked(new Date(user.lockUntil))) {\n // Expired lock, restart count at 1\n const updatedUser = await payload.db.updateOne({\n id: user.id,\n collection: collection.slug,\n data: {\n lockUntil: null,\n loginAttempts: 1,\n },\n req,\n select: {\n lockUntil: true,\n loginAttempts: true,\n },\n })\n updatedLockUntil = updatedUser.lockUntil\n updatedLoginAttempts = updatedUser.loginAttempts\n user.lockUntil = updatedLockUntil\n } else {\n const data: JsonObject = {\n loginAttempts: {\n $inc: 1,\n },\n }\n\n const willReachMaxAttempts =\n typeof user.loginAttempts === 'number' && user.loginAttempts + 1 >= maxLoginAttempts\n // Lock the account if at max attempts and not already locked\n if (willReachMaxAttempts) {\n const lockUntil = new Date(currentTime + lockTime).toISOString()\n data.lockUntil = lockUntil\n }\n\n const updatedUser = await payload.db.updateOne({\n id: user.id,\n collection: collection.slug,\n data,\n select: {\n lockUntil: true,\n loginAttempts: true,\n },\n })\n\n updatedLockUntil = updatedUser.lockUntil\n updatedLoginAttempts = updatedUser.loginAttempts\n }\n\n if (updatedLoginAttempts === null) {\n throw new Error('Failed to update login attempts or lockUntil for user')\n }\n\n // Check updated latest lockUntil and loginAttempts in case there were parallel updates\n const reachedMaxAttemptsForCurrentUser =\n typeof updatedLoginAttempts === 'number' && updatedLoginAttempts - 1 >= maxLoginAttempts\n\n const reachedMaxAttemptsForNextUser =\n typeof updatedLoginAttempts === 'number' && updatedLoginAttempts >= maxLoginAttempts\n\n if (reachedMaxAttemptsForCurrentUser) {\n user.lockUntil = updatedLockUntil\n }\n user.loginAttempts = updatedLoginAttempts - 1 // -1, as the updated increment is applied for the *next* login attempt, not the current one\n\n if (\n reachedMaxAttemptsForNextUser &&\n (!updatedLockUntil || !isUserLocked(new Date(updatedLockUntil)))\n ) {\n // If lockUntil reached max login attempts due to multiple parallel attempts but user was not locked yet,\n const newLockUntil = new Date(currentTime + lockTime).toISOString()\n\n await payload.db.updateOne({\n id: user.id,\n collection: collection.slug,\n data: {\n lockUntil: newLockUntil,\n },\n returning: false,\n })\n\n if (reachedMaxAttemptsForCurrentUser) {\n user.lockUntil = newLockUntil\n }\n\n if (collection.auth.useSessions) {\n // Remove all active sessions that have been created in a 20 second window. This protects\n // against brute force attacks - example: 99 incorrect, 1 correct parallel login attempts.\n // The correct login attempt will be finished first, as it's faster due to not having to perform\n // an additional db update here.\n // However, this request (the incorrect login attempt request) can kill the successful login attempt here.\n\n // Fetch user sessions separately (do not do this in the updateOne select in order to preserve the returning: true db call optimization)\n const currentUser = await payload.db.findOne<TypedUser>({\n collection: collection.slug,\n select: {\n sessions: true,\n },\n where: {\n id: {\n equals: user.id,\n },\n },\n })\n if (currentUser?.sessions?.length) {\n // Does not hurt also removing expired sessions\n currentUser.sessions = currentUser.sessions.filter((session) => {\n const sessionCreatedAt = new Date(session.createdAt)\n const twentySecondsAgo = new Date(currentTime - 20000)\n\n // Remove sessions created within the last 20 seconds\n return sessionCreatedAt <= twentySecondsAgo\n })\n\n user.sessions = currentUser.sessions\n\n // Ensure updatedAt date is always updated\n user.updatedAt = new Date().toISOString()\n\n await payload.db.updateOne({\n id: user.id,\n collection: collection.slug,\n data: user,\n returning: false,\n })\n }\n }\n }\n}\n"],"names":["isUserLocked","incrementLoginAttempts","collection","payload","req","user","auth","lockTime","maxLoginAttempts","currentTime","Date","now","updatedLockUntil","updatedLoginAttempts","lockUntil","updatedUser","db","updateOne","id","slug","data","loginAttempts","select","$inc","willReachMaxAttempts","toISOString","Error","reachedMaxAttemptsForCurrentUser","reachedMaxAttemptsForNextUser","newLockUntil","returning","useSessions","currentUser","findOne","sessions","where","equals","length","filter","session","sessionCreatedAt","createdAt","twentySecondsAgo","updatedAt"],"mappings":"AAIA,SAASA,YAAY,QAAQ,wBAAuB;AASpD,oIAAoI;AACpI,4FAA4F;AAC5F,OAAO,MAAMC,yBAAyB,OAAO,EAC3CC,UAAU,EACVC,OAAO,EACPC,GAAG,EACHC,IAAI,EACC;IACL,MAAM,EACJC,MAAM,EAAEC,QAAQ,EAAEC,gBAAgB,EAAE,EACrC,GAAGN;IAEJ,MAAMO,cAAcC,KAAKC,GAAG;IAE5B,IAAIC,mBAAkC;IACtC,IAAIC,uBAAsC;IAE1C,IAAIR,KAAKS,SAAS,IAAI,CAACd,aAAa,IAAIU,KAAKL,KAAKS,SAAS,IAAI;QAC7D,mCAAmC;QACnC,MAAMC,cAAc,MAAMZ,QAAQa,EAAE,CAACC,SAAS,CAAC;YAC7CC,IAAIb,KAAKa,EAAE;YACXhB,YAAYA,WAAWiB,IAAI;YAC3BC,MAAM;gBACJN,WAAW;gBACXO,eAAe;YACjB;YACAjB;YACAkB,QAAQ;gBACNR,WAAW;gBACXO,eAAe;YACjB;QACF;QACAT,mBAAmBG,YAAYD,SAAS;QACxCD,uBAAuBE,YAAYM,aAAa;QAChDhB,KAAKS,SAAS,GAAGF;IACnB,OAAO;QACL,MAAMQ,OAAmB;YACvBC,eAAe;gBACbE,MAAM;YACR;QACF;QAEA,MAAMC,uBACJ,OAAOnB,KAAKgB,aAAa,KAAK,YAAYhB,KAAKgB,aAAa,GAAG,KAAKb;QACtE,6DAA6D;QAC7D,IAAIgB,sBAAsB;YACxB,MAAMV,YAAY,IAAIJ,KAAKD,cAAcF,UAAUkB,WAAW;YAC9DL,KAAKN,SAAS,GAAGA;QACnB;QAEA,MAAMC,cAAc,MAAMZ,QAAQa,EAAE,CAACC,SAAS,CAAC;YAC7CC,IAAIb,KAAKa,EAAE;YACXhB,YAAYA,WAAWiB,IAAI;YAC3BC;YACAE,QAAQ;gBACNR,WAAW;gBACXO,eAAe;YACjB;QACF;QAEAT,mBAAmBG,YAAYD,SAAS;QACxCD,uBAAuBE,YAAYM,aAAa;IAClD;IAEA,IAAIR,yBAAyB,MAAM;QACjC,MAAM,IAAIa,MAAM;IAClB;IAEA,uFAAuF;IACvF,MAAMC,mCACJ,OAAOd,yBAAyB,YAAYA,uBAAuB,KAAKL;IAE1E,MAAMoB,gCACJ,OAAOf,yBAAyB,YAAYA,wBAAwBL;IAEtE,IAAImB,kCAAkC;QACpCtB,KAAKS,SAAS,GAAGF;IACnB;IACAP,KAAKgB,aAAa,GAAGR,uBAAuB,
|
|
1
|
+
{"version":3,"sources":["../../../../src/auth/strategies/local/incrementLoginAttempts.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { PayloadRequest } from '../../../types/index.js'\n\nimport { type JsonObject, type Payload, type TypedUser } from '../../../index.js'\nimport { isUserLocked } from '../../isUserLocked.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig\n payload: Payload\n req: PayloadRequest\n user: TypedUser\n}\n\n// Note: this function does not use req in most updates, as we want those to be visible in parallel requests that are on a different\n// transaction. At the same time, we want updates from parallel requests to be visible here.\nexport const incrementLoginAttempts = async ({\n collection,\n payload,\n req,\n user,\n}: Args): Promise<void> => {\n const {\n auth: { lockTime, maxLoginAttempts },\n } = collection\n\n const currentTime = Date.now()\n\n let updatedLockUntil: null | string = null\n let updatedLoginAttempts: null | number = null\n\n if (user.lockUntil && !isUserLocked(new Date(user.lockUntil))) {\n // Expired lock, restart count at 1\n const updatedUser = await payload.db.updateOne({\n id: user.id,\n collection: collection.slug,\n data: {\n lockUntil: null,\n loginAttempts: 1,\n },\n req,\n select: {\n lockUntil: true,\n loginAttempts: true,\n },\n })\n updatedLockUntil = updatedUser.lockUntil\n updatedLoginAttempts = updatedUser.loginAttempts\n user.lockUntil = updatedLockUntil\n } else {\n const data: JsonObject = {\n loginAttempts: {\n $inc: 1,\n },\n }\n\n const willReachMaxAttempts =\n typeof user.loginAttempts === 'number' && user.loginAttempts + 1 >= maxLoginAttempts\n // Lock the account if at max attempts and not already locked\n if (willReachMaxAttempts) {\n const lockUntil = new Date(currentTime + lockTime).toISOString()\n data.lockUntil = lockUntil\n }\n\n const updatedUser = await payload.db.updateOne({\n id: user.id,\n collection: collection.slug,\n data,\n select: {\n lockUntil: true,\n loginAttempts: true,\n },\n })\n\n updatedLockUntil = updatedUser.lockUntil\n updatedLoginAttempts = updatedUser.loginAttempts\n }\n\n if (updatedLoginAttempts === null) {\n throw new Error('Failed to update login attempts or lockUntil for user')\n }\n\n // Check updated latest lockUntil and loginAttempts in case there were parallel updates\n const reachedMaxAttemptsForCurrentUser =\n typeof updatedLoginAttempts === 'number' && updatedLoginAttempts - 1 >= maxLoginAttempts\n\n const reachedMaxAttemptsForNextUser =\n typeof updatedLoginAttempts === 'number' && updatedLoginAttempts >= maxLoginAttempts\n\n if (reachedMaxAttemptsForCurrentUser) {\n user.lockUntil = updatedLockUntil\n }\n user.loginAttempts = updatedLoginAttempts - 1 // -1, as the updated increment is applied for the *next* login attempt, not the current one\n\n if (\n reachedMaxAttemptsForNextUser &&\n (!updatedLockUntil || !isUserLocked(new Date(updatedLockUntil)))\n ) {\n // If lockUntil reached max login attempts due to multiple parallel attempts but user was not locked yet,\n const newLockUntil = new Date(currentTime + lockTime).toISOString()\n\n await payload.db.updateOne({\n id: user.id,\n collection: collection.slug,\n data: {\n lockUntil: newLockUntil,\n },\n returning: false,\n })\n\n if (reachedMaxAttemptsForCurrentUser) {\n user.lockUntil = newLockUntil\n }\n\n if (collection.auth.useSessions) {\n // Remove all active sessions that have been created in a 20 second window. This protects\n // against brute force attacks - example: 99 incorrect, 1 correct parallel login attempts.\n // The correct login attempt will be finished first, as it's faster due to not having to perform\n // an additional db update here.\n // However, this request (the incorrect login attempt request) can kill the successful login attempt here.\n\n // Fetch user sessions separately (do not do this in the updateOne select in order to preserve the returning: true db call optimization)\n const currentUser = await payload.db.findOne<TypedUser>({\n collection: collection.slug,\n select: {\n sessions: true,\n },\n where: {\n id: {\n equals: user.id,\n },\n },\n })\n if (currentUser?.sessions?.length) {\n // Does not hurt also removing expired sessions\n currentUser.sessions = currentUser.sessions.filter((session) => {\n const sessionCreatedAt = new Date(session.createdAt)\n const twentySecondsAgo = new Date(currentTime - 20000)\n\n // Remove sessions created within the last 20 seconds\n return sessionCreatedAt <= twentySecondsAgo\n })\n\n user.sessions = currentUser.sessions\n\n // Ensure updatedAt date is always updated\n user.updatedAt = new Date().toISOString()\n\n await payload.db.updateOne({\n id: user.id,\n collection: collection.slug,\n data: user,\n returning: false,\n })\n }\n }\n }\n}\n"],"names":["isUserLocked","incrementLoginAttempts","collection","payload","req","user","auth","lockTime","maxLoginAttempts","currentTime","Date","now","updatedLockUntil","updatedLoginAttempts","lockUntil","updatedUser","db","updateOne","id","slug","data","loginAttempts","select","$inc","willReachMaxAttempts","toISOString","Error","reachedMaxAttemptsForCurrentUser","reachedMaxAttemptsForNextUser","newLockUntil","returning","useSessions","currentUser","findOne","sessions","where","equals","length","filter","session","sessionCreatedAt","createdAt","twentySecondsAgo","updatedAt"],"mappings":"AAIA,SAASA,YAAY,QAAQ,wBAAuB;AASpD,oIAAoI;AACpI,4FAA4F;AAC5F,OAAO,MAAMC,yBAAyB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AEpC,0CAA0C;gBAC1C7B,KAAKsC,SAAS,GAAG,IAAIjC,OAAOe,WAAW;gBAEvC,MAAMtB,QAAQa,EAAE,CAACC,SAAS,CAAC;oBACzBC,IAAIb,KAAKa,EAAE;oBACXhB,YAAYA,WAAWiB,IAAI;oBAC3BC,MAAMf;oBACNyB,WAAW;gBACb;YACF;QACF;IACF;AACF,EAAC"}
|
|
@@ -57,8 +57,7 @@ export function genImportMapIterateFields({ addToImportMap, baseDir, config, fie
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
hasKey(field?.admin, 'jsx') && addToImportMap(field.admin.jsx) // For Blocks
|
|
61
|
-
;
|
|
60
|
+
hasKey(field?.admin, 'jsx') && addToImportMap(field.admin.jsx); // For Blocks
|
|
62
61
|
hasKey(field?.admin?.components, 'Label') && addToImportMap(field.admin.components.Label);
|
|
63
62
|
hasKey(field?.admin?.components, 'Block') && addToImportMap(field.admin.components.Block);
|
|
64
63
|
hasKey(field?.admin?.components, 'Cell') && addToImportMap(field?.admin?.components?.Cell);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/bin/generateImportMap/iterateFields.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-expressions */\nimport type { PayloadComponent, SanitizedConfig } from '../../config/types.js'\nimport type { Block, Field, Tab } from '../../fields/config/types.js'\nimport type { AddToImportMap, Imports, InternalImportMap } from './index.js'\n\nfunction hasKey<T, K extends string>(\n obj: null | T | undefined,\n key: K,\n): obj is { [P in K]: PayloadComponent | PayloadComponent[] } & T {\n return obj != null && Object.prototype.hasOwnProperty.call(obj, key)\n}\n\nconst defaultUIFieldComponentKeys: Array<'Cell' | 'Description' | 'Field' | 'Filter'> = [\n 'Cell',\n 'Description',\n 'Field',\n 'Filter',\n]\nexport function genImportMapIterateFields({\n addToImportMap,\n baseDir,\n config,\n fields,\n importMap,\n imports,\n}: {\n addToImportMap: AddToImportMap\n baseDir: string\n config: SanitizedConfig\n fields: Block[] | Field[] | Tab[]\n importMap: InternalImportMap\n imports: Imports\n}) {\n for (const field of fields) {\n if ('fields' in field) {\n genImportMapIterateFields({\n addToImportMap,\n baseDir,\n config,\n fields: field.fields,\n importMap,\n imports,\n })\n } else if (field.type === 'blocks') {\n genImportMapIterateFields({\n addToImportMap,\n baseDir,\n config,\n fields: field.blocks.filter((block) => typeof block !== 'string'),\n importMap,\n imports,\n })\n } else if (field.type === 'tabs') {\n genImportMapIterateFields({\n addToImportMap,\n baseDir,\n config,\n fields: field.tabs,\n importMap,\n imports,\n })\n } else if (field.type === 'richText') {\n if (\n field?.editor &&\n typeof field.editor === 'object' &&\n field.editor.generateImportMap &&\n typeof field.editor.generateImportMap === 'function'\n ) {\n field.editor.generateImportMap({\n addToImportMap,\n baseDir,\n config,\n importMap,\n imports,\n })\n }\n } else if (field.type === 'ui') {\n if (field?.admin?.components) {\n // Render any extra, untyped components\n for (const key in field.admin.components) {\n if (key in defaultUIFieldComponentKeys) {\n continue\n }\n addToImportMap(field.admin.components[key])\n }\n }\n }\n\n hasKey(field?.admin, 'jsx') && addToImportMap(field.admin.jsx) // For Blocks\n\n hasKey(field?.admin?.components, 'Label') && addToImportMap(field.admin.components.Label)\n\n hasKey(field?.admin?.components, 'Block') && addToImportMap(field.admin.components.Block)\n\n hasKey(field?.admin?.components, 'Cell') && addToImportMap(field?.admin?.components?.Cell)\n\n hasKey(field?.admin?.components, 'Description') &&\n addToImportMap(field?.admin?.components?.Description)\n\n hasKey(field?.admin?.components, 'Field') && addToImportMap(field?.admin?.components?.Field)\n hasKey(field?.admin?.components, 'Filter') && addToImportMap(field?.admin?.components?.Filter)\n\n hasKey(field?.admin?.components, 'Error') && addToImportMap(field?.admin?.components?.Error)\n\n hasKey(field?.admin?.components, 'afterInput') &&\n addToImportMap(field?.admin?.components?.afterInput)\n\n hasKey(field?.admin?.components, 'beforeInput') &&\n addToImportMap(field?.admin?.components?.beforeInput)\n\n hasKey(field?.admin?.components, 'RowLabel') &&\n addToImportMap(field?.admin?.components?.RowLabel)\n\n hasKey(field?.admin?.components, 'Diff') && addToImportMap(field?.admin?.components?.Diff)\n }\n}\n"],"names":["hasKey","obj","key","Object","prototype","hasOwnProperty","call","defaultUIFieldComponentKeys","genImportMapIterateFields","addToImportMap","baseDir","config","fields","importMap","imports","field","type","blocks","filter","block","tabs","editor","generateImportMap","admin","components","jsx","Label","Block","Cell","Description","Field","Filter","Error","afterInput","beforeInput","RowLabel","Diff"],"mappings":"AAAA,2DAA2D,GAK3D,SAASA,OACPC,GAAyB,EACzBC,GAAM;IAEN,OAAOD,OAAO,QAAQE,OAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACL,KAAKC;AAClE;AAEA,MAAMK,8BAAkF;IACtF;IACA;IACA;IACA;CACD;AACD,OAAO,SAASC,0BAA0B,EACxCC,cAAc,EACdC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,SAAS,EACTC,OAAO,EAQR;IACC,KAAK,MAAMC,SAASH,OAAQ;QAC1B,IAAI,YAAYG,OAAO;YACrBP,0BAA0B;gBACxBC;gBACAC;gBACAC;gBACAC,QAAQG,MAAMH,MAAM;gBACpBC;gBACAC;YACF;QACF,OAAO,IAAIC,MAAMC,IAAI,KAAK,UAAU;YAClCR,0BAA0B;gBACxBC;gBACAC;gBACAC;gBACAC,QAAQG,MAAME,MAAM,CAACC,MAAM,CAAC,CAACC,QAAU,OAAOA,UAAU;gBACxDN;gBACAC;YACF;QACF,OAAO,IAAIC,MAAMC,IAAI,KAAK,QAAQ;YAChCR,0BAA0B;gBACxBC;gBACAC;gBACAC;gBACAC,QAAQG,MAAMK,IAAI;gBAClBP;gBACAC;YACF;QACF,OAAO,IAAIC,MAAMC,IAAI,KAAK,YAAY;YACpC,IACED,OAAOM,UACP,OAAON,MAAMM,MAAM,KAAK,YACxBN,MAAMM,MAAM,CAACC,iBAAiB,IAC9B,OAAOP,MAAMM,MAAM,CAACC,iBAAiB,KAAK,YAC1C;gBACAP,MAAMM,MAAM,CAACC,iBAAiB,CAAC;oBAC7Bb;oBACAC;oBACAC;oBACAE;oBACAC;gBACF;YACF;QACF,OAAO,IAAIC,MAAMC,IAAI,KAAK,MAAM;YAC9B,IAAID,OAAOQ,OAAOC,YAAY;gBAC5B,uCAAuC;gBACvC,IAAK,MAAMtB,OAAOa,MAAMQ,KAAK,CAACC,UAAU,CAAE;oBACxC,IAAItB,OAAOK,6BAA6B;wBACtC;oBACF;oBACAE,eAAeM,MAAMQ,KAAK,CAACC,UAAU,CAACtB,IAAI;gBAC5C;YACF;QACF;QAEAF,OAAOe,OAAOQ,OAAO,UAAUd,eAAeM,MAAMQ,KAAK,CAACE,GAAG,
|
|
1
|
+
{"version":3,"sources":["../../../src/bin/generateImportMap/iterateFields.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-expressions */\nimport type { PayloadComponent, SanitizedConfig } from '../../config/types.js'\nimport type { Block, Field, Tab } from '../../fields/config/types.js'\nimport type { AddToImportMap, Imports, InternalImportMap } from './index.js'\n\nfunction hasKey<T, K extends string>(\n obj: null | T | undefined,\n key: K,\n): obj is { [P in K]: PayloadComponent | PayloadComponent[] } & T {\n return obj != null && Object.prototype.hasOwnProperty.call(obj, key)\n}\n\nconst defaultUIFieldComponentKeys: Array<'Cell' | 'Description' | 'Field' | 'Filter'> = [\n 'Cell',\n 'Description',\n 'Field',\n 'Filter',\n]\nexport function genImportMapIterateFields({\n addToImportMap,\n baseDir,\n config,\n fields,\n importMap,\n imports,\n}: {\n addToImportMap: AddToImportMap\n baseDir: string\n config: SanitizedConfig\n fields: Block[] | Field[] | Tab[]\n importMap: InternalImportMap\n imports: Imports\n}) {\n for (const field of fields) {\n if ('fields' in field) {\n genImportMapIterateFields({\n addToImportMap,\n baseDir,\n config,\n fields: field.fields,\n importMap,\n imports,\n })\n } else if (field.type === 'blocks') {\n genImportMapIterateFields({\n addToImportMap,\n baseDir,\n config,\n fields: field.blocks.filter((block) => typeof block !== 'string'),\n importMap,\n imports,\n })\n } else if (field.type === 'tabs') {\n genImportMapIterateFields({\n addToImportMap,\n baseDir,\n config,\n fields: field.tabs,\n importMap,\n imports,\n })\n } else if (field.type === 'richText') {\n if (\n field?.editor &&\n typeof field.editor === 'object' &&\n field.editor.generateImportMap &&\n typeof field.editor.generateImportMap === 'function'\n ) {\n field.editor.generateImportMap({\n addToImportMap,\n baseDir,\n config,\n importMap,\n imports,\n })\n }\n } else if (field.type === 'ui') {\n if (field?.admin?.components) {\n // Render any extra, untyped components\n for (const key in field.admin.components) {\n if (key in defaultUIFieldComponentKeys) {\n continue\n }\n addToImportMap(field.admin.components[key])\n }\n }\n }\n\n hasKey(field?.admin, 'jsx') && addToImportMap(field.admin.jsx) // For Blocks\n\n hasKey(field?.admin?.components, 'Label') && addToImportMap(field.admin.components.Label)\n\n hasKey(field?.admin?.components, 'Block') && addToImportMap(field.admin.components.Block)\n\n hasKey(field?.admin?.components, 'Cell') && addToImportMap(field?.admin?.components?.Cell)\n\n hasKey(field?.admin?.components, 'Description') &&\n addToImportMap(field?.admin?.components?.Description)\n\n hasKey(field?.admin?.components, 'Field') && addToImportMap(field?.admin?.components?.Field)\n hasKey(field?.admin?.components, 'Filter') && addToImportMap(field?.admin?.components?.Filter)\n\n hasKey(field?.admin?.components, 'Error') && addToImportMap(field?.admin?.components?.Error)\n\n hasKey(field?.admin?.components, 'afterInput') &&\n addToImportMap(field?.admin?.components?.afterInput)\n\n hasKey(field?.admin?.components, 'beforeInput') &&\n addToImportMap(field?.admin?.components?.beforeInput)\n\n hasKey(field?.admin?.components, 'RowLabel') &&\n addToImportMap(field?.admin?.components?.RowLabel)\n\n hasKey(field?.admin?.components, 'Diff') && addToImportMap(field?.admin?.components?.Diff)\n }\n}\n"],"names":["hasKey","obj","key","Object","prototype","hasOwnProperty","call","defaultUIFieldComponentKeys","genImportMapIterateFields","addToImportMap","baseDir","config","fields","importMap","imports","field","type","blocks","filter","block","tabs","editor","generateImportMap","admin","components","jsx","Label","Block","Cell","Description","Field","Filter","Error","afterInput","beforeInput","RowLabel","Diff"],"mappings":"AAAA,2DAA2D,GAK3D,SAASA,OACPC,GAAyB,EACzBC,GAAM;IAEN,OAAOD,OAAO,QAAQE,OAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACL,KAAKC;AAClE;AAEA,MAAMK,8BAAkF;IACtF;IACA;IACA;IACA;CACD;AACD,OAAO,SAASC,0BAA0B,EACxCC,cAAc,EACdC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,SAAS,EACTC,OAAO,EAQR;IACC,KAAK,MAAMC,SAASH,OAAQ;QAC1B,IAAI,YAAYG,OAAO;YACrBP,0BAA0B;gBACxBC;gBACAC;gBACAC;gBACAC,QAAQG,MAAMH,MAAM;gBACpBC;gBACAC;YACF;QACF,OAAO,IAAIC,MAAMC,IAAI,KAAK,UAAU;YAClCR,0BAA0B;gBACxBC;gBACAC;gBACAC;gBACAC,QAAQG,MAAME,MAAM,CAACC,MAAM,CAAC,CAACC,QAAU,OAAOA,UAAU;gBACxDN;gBACAC;YACF;QACF,OAAO,IAAIC,MAAMC,IAAI,KAAK,QAAQ;YAChCR,0BAA0B;gBACxBC;gBACAC;gBACAC;gBACAC,QAAQG,MAAMK,IAAI;gBAClBP;gBACAC;YACF;QACF,OAAO,IAAIC,MAAMC,IAAI,KAAK,YAAY;YACpC,IACED,OAAOM,UACP,OAAON,MAAMM,MAAM,KAAK,YACxBN,MAAMM,MAAM,CAACC,iBAAiB,IAC9B,OAAOP,MAAMM,MAAM,CAACC,iBAAiB,KAAK,YAC1C;gBACAP,MAAMM,MAAM,CAACC,iBAAiB,CAAC;oBAC7Bb;oBACAC;oBACAC;oBACAE;oBACAC;gBACF;YACF;QACF,OAAO,IAAIC,MAAMC,IAAI,KAAK,MAAM;YAC9B,IAAID,OAAOQ,OAAOC,YAAY;gBAC5B,uCAAuC;gBACvC,IAAK,MAAMtB,OAAOa,MAAMQ,KAAK,CAACC,UAAU,CAAE;oBACxC,IAAIt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keep the process alive
|
|
42
|
-
;
|
|
41
|
+
process.stdin.resume(); // Keep the process alive
|
|
43
42
|
return;
|
|
44
43
|
} else {
|
|
45
44
|
const { payload } = await runBinScript({
|
|
@@ -47,8 +46,7 @@ export const bin = async ()=>{
|
|
|
47
46
|
script
|
|
48
47
|
});
|
|
49
48
|
if (payload) {
|
|
50
|
-
await payload.destroy() // close database connections after running jobs so process can exit cleanly
|
|
51
|
-
;
|
|
49
|
+
await payload.destroy(); // close database connections after running jobs so process can exit cleanly
|
|
52
50
|
}
|
|
53
51
|
process.exit(0);
|
|
54
52
|
}
|
package/dist/bin/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bin/index.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport { Cron } from 'croner'\nimport minimist from 'minimist'\nimport { pathToFileURL } from 'node:url'\nimport path from 'path'\n\nimport { findConfig } from '../config/find.js'\nimport { getPayload, type Payload } from '../index.js'\nimport { generateImportMap } from './generateImportMap/index.js'\nimport { generateTypes } from './generateTypes.js'\nimport { info } from './info.js'\nimport { loadEnv } from './loadEnv.js'\nimport { migrate, availableCommands as migrateCommands } from './migrate.js'\n\n// Note: this does not account for any user bin scripts\nconst availableScripts = [\n 'generate:db-schema',\n 'generate:importmap',\n 'generate:types',\n 'info',\n 'jobs:run',\n 'jobs:handle-schedules',\n 'run',\n ...migrateCommands,\n] as const\n\nexport const bin = async () => {\n loadEnv()\n process.env.DISABLE_PAYLOAD_HMR = 'true'\n\n const args = minimist(process.argv.slice(2))\n const script = (typeof args._[0] === 'string' ? args._[0] : '').toLowerCase()\n\n if (args.cron) {\n new Cron(\n args.cron,\n async () => {\n // If the bin script initializes payload (getPayload), this will only happen once, as getPayload\n // caches the payload instance on the module scope => no need to manually cache and manage getPayload initialization\n // outside the Cron here.\n await runBinScript({ args, script })\n },\n {\n // Do not run consecutive crons if previous crons still ongoing\n protect: true,\n },\n )\n\n process.stdin.resume() // Keep the process alive\n\n return\n } else {\n const { payload } = await runBinScript({ args, script })\n if (payload) {\n await payload.destroy() // close database connections after running jobs so process can exit cleanly\n }\n process.exit(0)\n }\n}\n\nasync function runBinScript({\n args,\n script,\n}: {\n args: minimist.ParsedArgs\n script: string\n}): Promise<{\n /**\n * Scripts can return a payload instance if it exists. The bin script runner can then safely\n * shut off the instance, depending on if it's running in a cron job or not.\n */\n payload?: Payload\n}> {\n if (script === 'info') {\n await info()\n return {}\n }\n\n if (script === 'run') {\n const scriptPath = args._[1]\n if (!scriptPath) {\n console.error('Please provide a script path to run.')\n process.exit(1)\n }\n\n const absoluteScriptPath = path.resolve(process.cwd(), scriptPath)\n\n // Modify process.argv to remove 'run' and the script path\n const originalArgv = process.argv\n process.argv = [process.argv[0]!, process.argv[1]!, ...args._.slice(2)]\n\n try {\n await import(pathToFileURL(absoluteScriptPath).toString())\n } catch (error) {\n console.error(`Error running script: ${absoluteScriptPath}`)\n console.error(error)\n process.exit(1)\n } finally {\n // Restore original process.argv\n process.argv = originalArgv\n }\n return {}\n }\n\n const configPath = findConfig()\n const configPromise = await import(pathToFileURL(configPath).toString())\n let config = await configPromise\n if (config.default) {\n config = await config.default\n }\n\n const userBinScript = Array.isArray(config.bin)\n ? config.bin.find(({ key }: { key: string }) => key === script)\n : false\n\n if (userBinScript) {\n try {\n const module = await import(pathToFileURL(userBinScript.scriptPath).toString())\n\n if (!module.script || typeof module.script !== 'function') {\n console.error(\n `Could not find \"script\" function export for script ${userBinScript.key} in ${userBinScript.scriptPath}`,\n )\n } else {\n await module.script(config).catch((err: unknown) => {\n console.log(`Script ${userBinScript.key} failed, details:`)\n console.error(err)\n })\n }\n } catch (err) {\n console.log(`Could not find associated bin script for the ${userBinScript.key} command`)\n console.error(err)\n }\n\n return {}\n }\n\n if (script.startsWith('migrate')) {\n await migrate({ config, parsedArgs: args })\n return {}\n }\n\n if (script === 'generate:types') {\n await generateTypes(config)\n return {}\n }\n\n if (script === 'generate:importmap') {\n await generateImportMap(config)\n return {}\n }\n\n if (script === 'jobs:run') {\n const payload = await getPayload({ config }) // Do not setup crons here - this bin script can set up its own crons\n const limit = args.limit ? parseInt(args.limit, 10) : undefined\n const queue = args.queue ? args.queue : undefined\n const allQueues = !!args['all-queues']\n const handleSchedules = !!args['handle-schedules']\n\n if (handleSchedules) {\n await payload.jobs.handleSchedules({\n allQueues,\n queue,\n })\n }\n\n await payload.jobs.run({\n allQueues,\n limit,\n queue,\n })\n\n return { payload }\n }\n\n if (script === 'jobs:handle-schedules') {\n const payload = await getPayload({ config }) // Do not setup crons here - this bin script can set up its own crons\n const queue = args.queue ? args.queue : undefined\n const allQueues = !!args['all-queues']\n\n await payload.jobs.handleSchedules({\n allQueues,\n queue,\n })\n\n return { payload }\n }\n\n if (script === 'generate:db-schema') {\n // Barebones instance to access database adapter, without connecting to the DB\n const payload = await getPayload({ config, disableDBConnect: true, disableOnInit: true }) // Do not setup crons here\n\n if (typeof payload.db.generateSchema !== 'function') {\n payload.logger.error({\n msg: `${payload.db.packageName} does not support database schema generation`,\n })\n\n await payload.destroy()\n process.exit(1)\n }\n\n await payload.db.generateSchema({\n log: args.log === 'false' ? false : true,\n prettify: args.prettify === 'false' ? false : true,\n })\n\n return { payload }\n }\n\n console.error(script ? `Unknown command: \"${script}\"` : 'Please provide a command to run')\n console.log(`\\nAvailable commands:\\n${availableScripts.map((c) => ` - ${c}`).join('\\n')}`)\n\n process.exit(1)\n}\n"],"names":["Cron","minimist","pathToFileURL","path","findConfig","getPayload","generateImportMap","generateTypes","info","loadEnv","migrate","availableCommands","migrateCommands","availableScripts","bin","process","env","DISABLE_PAYLOAD_HMR","args","argv","slice","script","_","toLowerCase","cron","runBinScript","protect","stdin","resume","payload","destroy","exit","scriptPath","console","error","absoluteScriptPath","resolve","cwd","originalArgv","toString","configPath","configPromise","config","default","userBinScript","Array","isArray","find","key","module","catch","err","log","startsWith","parsedArgs","limit","parseInt","undefined","queue","allQueues","handleSchedules","jobs","run","disableDBConnect","disableOnInit","db","generateSchema","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|
+
{"version":3,"sources":["../../src/bin/index.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport { Cron } from 'croner'\nimport minimist from 'minimist'\nimport { pathToFileURL } from 'node:url'\nimport path from 'path'\n\nimport { findConfig } from '../config/find.js'\nimport { getPayload, type Payload } from '../index.js'\nimport { generateImportMap } from './generateImportMap/index.js'\nimport { generateTypes } from './generateTypes.js'\nimport { info } from './info.js'\nimport { loadEnv } from './loadEnv.js'\nimport { migrate, availableCommands as migrateCommands } from './migrate.js'\n\n// Note: this does not account for any user bin scripts\nconst availableScripts = [\n 'generate:db-schema',\n 'generate:importmap',\n 'generate:types',\n 'info',\n 'jobs:run',\n 'jobs:handle-schedules',\n 'run',\n ...migrateCommands,\n] as const\n\nexport const bin = async () => {\n loadEnv()\n process.env.DISABLE_PAYLOAD_HMR = 'true'\n\n const args = minimist(process.argv.slice(2))\n const script = (typeof args._[0] === 'string' ? args._[0] : '').toLowerCase()\n\n if (args.cron) {\n new Cron(\n args.cron,\n async () => {\n // If the bin script initializes payload (getPayload), this will only happen once, as getPayload\n // caches the payload instance on the module scope => no need to manually cache and manage getPayload initialization\n // outside the Cron here.\n await runBinScript({ args, script })\n },\n {\n // Do not run consecutive crons if previous crons still ongoing\n protect: true,\n },\n )\n\n process.stdin.resume() // Keep the process alive\n\n return\n } else {\n const { payload } = await runBinScript({ args, script })\n if (payload) {\n await payload.destroy() // close database connections after running jobs so process can exit cleanly\n }\n process.exit(0)\n }\n}\n\nasync function runBinScript({\n args,\n script,\n}: {\n args: minimist.ParsedArgs\n script: string\n}): Promise<{\n /**\n * Scripts can return a payload instance if it exists. The bin script runner can then safely\n * shut off the instance, depending on if it's running in a cron job or not.\n */\n payload?: Payload\n}> {\n if (script === 'info') {\n await info()\n return {}\n }\n\n if (script === 'run') {\n const scriptPath = args._[1]\n if (!scriptPath) {\n console.error('Please provide a script path to run.')\n process.exit(1)\n }\n\n const absoluteScriptPath = path.resolve(process.cwd(), scriptPath)\n\n // Modify process.argv to remove 'run' and the script path\n const originalArgv = process.argv\n process.argv = [process.argv[0]!, process.argv[1]!, ...args._.slice(2)]\n\n try {\n await import(pathToFileURL(absoluteScriptPath).toString())\n } catch (error) {\n console.error(`Error running script: ${absoluteScriptPath}`)\n console.error(error)\n process.exit(1)\n } finally {\n // Restore original process.argv\n process.argv = originalArgv\n }\n return {}\n }\n\n const configPath = findConfig()\n const configPromise = await import(pathToFileURL(configPath).toString())\n let config = await configPromise\n if (config.default) {\n config = await config.default\n }\n\n const userBinScript = Array.isArray(config.bin)\n ? config.bin.find(({ key }: { key: string }) => key === script)\n : false\n\n if (userBinScript) {\n try {\n const module = await import(pathToFileURL(userBinScript.scriptPath).toString())\n\n if (!module.script || typeof module.script !== 'function') {\n console.error(\n `Could not find \"script\" function export for script ${userBinScript.key} in ${userBinScript.scriptPath}`,\n )\n } else {\n await module.script(config).catch((err: unknown) => {\n console.log(`Script ${userBinScript.key} failed, details:`)\n console.error(err)\n })\n }\n } catch (err) {\n console.log(`Could not find associated bin script for the ${userBinScript.key} command`)\n console.error(err)\n }\n\n return {}\n }\n\n if (script.startsWith('migrate')) {\n await migrate({ config, parsedArgs: args })\n return {}\n }\n\n if (script === 'generate:types') {\n await generateTypes(config)\n return {}\n }\n\n if (script === 'generate:importmap') {\n await generateImportMap(config)\n return {}\n }\n\n if (script === 'jobs:run') {\n const payload = await getPayload({ config }) // Do not setup crons here - this bin script can set up its own crons\n const limit = args.limit ? parseInt(args.limit, 10) : undefined\n const queue = args.queue ? args.queue : undefined\n const allQueues = !!args['all-queues']\n const handleSchedules = !!args['handle-schedules']\n\n if (handleSchedules) {\n await payload.jobs.handleSchedules({\n allQueues,\n queue,\n })\n }\n\n await payload.jobs.run({\n allQueues,\n limit,\n queue,\n })\n\n return { payload }\n }\n\n if (script === 'jobs:handle-schedules') {\n const payload = await getPayload({ config }) // Do not setup crons here - this bin script can set up its own crons\n const queue = args.queue ? args.queue : undefined\n const allQueues = !!args['all-queues']\n\n await payload.jobs.handleSchedules({\n allQueues,\n queue,\n })\n\n return { payload }\n }\n\n if (script === 'generate:db-schema') {\n // Barebones instance to access database adapter, without connecting to the DB\n const payload = await getPayload({ config, disableDBConnect: true, disableOnInit: true }) // Do not setup crons here\n\n if (typeof payload.db.generateSchema !== 'function') {\n payload.logger.error({\n msg: `${payload.db.packageName} does not support database schema generation`,\n })\n\n await payload.destroy()\n process.exit(1)\n }\n\n await payload.db.generateSchema({\n log: args.log === 'false' ? false : true,\n prettify: args.prettify === 'false' ? false : true,\n })\n\n return { payload }\n }\n\n console.error(script ? `Unknown command: \"${script}\"` : 'Please provide a command to run')\n console.log(`\\nAvailable commands:\\n${availableScripts.map((c) => ` - ${c}`).join('\\n')}`)\n\n process.exit(1)\n}\n"],"names":["Cron","minimist","pathToFileURL","path","findConfig","getPayload","generateImportMap","generateTypes","info","loadEnv","migrate","availableCommands","migrateCommands","availableScripts","bin","process","env","DISABLE_PAYLOAD_HMR","args","argv","slice","script","_","toLowerCase","cron","runBinScript","protect","stdin","resume","payload","destroy","exit","scriptPath","console","error","absoluteScriptPath","resolve","cwd","originalArgv","toString","configPath","configPromise","config","default","userBinScript","Array","isArray","find","key","module","catch","err","log","startsWith","parsedArgs","limit","parseInt","undefined","queue","allQueues","handleSchedules","jobs","run","disableDBConnect","disableOnInit","db","generateSchema","logger","msg","packageName","prettify","map","c","join"],"mappings":"AAAA,6BAA6B,GAC7B,SAASA,IAAI,QAAQ,SAAQ;AAC7B,OAAOC,cAAc,WAAU;AAC/B,SAASC,aAAa,QAAQ,WAAU;AACxC,OAAOC,UAAU,OAAM;AAEvB,SAASC,UAAU,QAAQ,oBAAmB;AAC9C,SAASC,UAAU,QAAsB,cAAa;AACtD,SAASC,iBAAiB,QAAQ,+BAA8B;AAChE,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,IAAI,QAAQ,YAAW;AAChC,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,OAAO,EAAEC,qBAAqBC,eAAe,QAAQ,eAAc;A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W,sBAAsB;QACnC,8EAA8E;QAC9E,MAAMQ,UAAU,MAAMxB,WAAW;YAAEqC;YAAQqB,kBAAkB;YAAMC,eAAe;QAAK,GAAG,0BAA0B;;QAEpH,IAAI,OAAOnC,QAAQoC,EAAE,CAACC,cAAc,KAAK,YAAY;YACnDrC,QAAQsC,MAAM,CAACjC,KAAK,CAAC;gBACnBkC,KAAK,GAAGvC,QAAQoC,EAAE,CAACI,WAAW,CAAC,4CAA4C,CAAC;YAC9E;YAEA,MAAMxC,QAAQC,OAAO;YACrBf,QAAQgB,IAAI,CAAC;QACf;QAEA,MAAMF,QAAQoC,EAAE,CAACC,cAAc,CAAC;YAC9Bd,KAAKlC,KAAKkC,GAAG,KAAK,UAAU,QAAQ;YACpCkB,UAAUpD,KAAKoD,QAAQ,KAAK,UAAU,QAAQ;QAChD;QAEA,OAAO;YAAEzC;QAAQ;IACnB;IAEAI,QAAQC,KAAK,CAACb,SAAS,CAAC,kBAAkB,EAAEA,OAAO,CAAC,CAAC,GAAG;IACxDY,QAAQmB,GAAG,CAAC,CAAC,uBAAuB,EAAEvC,iBAAiB0D,GAAG,CAAC,CAACC,IAAM,CAAC,IAAI,EAAEA,GAAG,EAAEC,IAAI,CAAC,OAAO;IAE1F1D,QAAQgB,IAAI,CAAC;AACf"}
|
package/dist/bin/migrate.js
CHANGED
|
@@ -30,8 +30,7 @@ export const migrate = async ({ config, parsedArgs })=>{
|
|
|
30
30
|
const skipEmpty = formattedArgs.includes('skipEmpty');
|
|
31
31
|
if (help) {
|
|
32
32
|
// eslint-disable-next-line no-console
|
|
33
|
-
console.log(`\n\n${availableCommandsMsg}\n`) // Avoid having to init payload to get the logger
|
|
34
|
-
;
|
|
33
|
+
console.log(`\n\n${availableCommandsMsg}\n`); // Avoid having to init payload to get the logger
|
|
35
34
|
process.exit(0);
|
|
36
35
|
}
|
|
37
36
|
process.env.PAYLOAD_MIGRATING = 'true';
|
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\nexport const availableCommands = [\n 'migrate',\n 'migrate:create',\n 'migrate:down',\n 'migrate:refresh',\n 'migrate:reset',\n 'migrate:status',\n 'migrate: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 disableDBConnect: args[0] === 'migrate:create',\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 const error = err instanceof Error ? err.message : 'Unknown error'\n throw new Error(`Error creating migration: ${error}`)\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","disableDBConnect","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,OAAO,MAAMC,oBAAoB;IAC/B;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAED,MAAMC,uBAAuB,CAAC,oBAAoB,EAAED,kBAAkBE,IAAI,CAAC,OAAO;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,IAAID,KAAKE,WAAW,KAAKF,KAAKG,MAAM,CAAC,GAAGC,WAAW,KAAKJ,KAAKK,KAAK,CAAC,IAE9EvB,IAAI,CAAC;IACV,GACCwB,MAAM,CAACC;IAEV,MAAMlB,qBAAqBC,wBAAwBE,cAAcgB,QAAQ,CAAC;IAC1E,MAAMC,YAAYjB,cAAcgB,QAAQ,CAAC;IAEzC,IAAIjB,MAAM;QACR,sCAAsC;QACtCmB,QAAQC,GAAG,CAAC,CAAC,IAAI,EAAE9B,qBAAqB,EAAE,CAAC,
|
|
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\nexport const availableCommands = [\n 'migrate',\n 'migrate:create',\n 'migrate:down',\n 'migrate:refresh',\n 'migrate:reset',\n 'migrate:status',\n 'migrate: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 disableDBConnect: args[0] === 'migrate:create',\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 const error = err instanceof Error ? err.message : 'Unknown error'\n throw new Error(`Error creating migration: ${error}`)\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","disableDBConnect","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,OAAO,MAAMC,oBAAoB;IAC/B;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAED,MAAMC,uBAAuB,CAAC,oBAAoB,EAAED,kBAAkBE,IAAI,CAAC,OAAO;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,IAAID,KAAKE,WAAW,KAAKF,KAAKG,MAAM,CAAC,GAAGC,WAAW,KAAKJ,KAAKK,KAAK,CAAC,IAE9EvB,IAAI,CAAC;IACV,GACCwB,MAAM,CAACC;IAEV,MAAMlB,qBAAqBC,wBAAwBE,cAAcgB,QAAQ,CAAC;IAC1E,MAAMC,YAAYjB,cAAcgB,QAAQ,CAAC;IAEzC,IAAIjB,MAAM;QACR,sCAAsC;QACtCmB,QAAQC,GAAG,CAAC,CAAC,IAAI,EAAE9B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sB;YACvE;YACA+B,QAAQC,IAAI,CAAC;IACjB;IAEAtC,QAAQgD,MAAM,CAACY,IAAI,CAAC;AACtB,EAAC"}
|
|
@@ -135,8 +135,7 @@ export const addDefaultsToAuthConfig = (auth)=>{
|
|
|
135
135
|
...auth.cookies || {}
|
|
136
136
|
};
|
|
137
137
|
auth.forgotPassword = auth.forgotPassword ?? {};
|
|
138
|
-
auth.lockTime = auth.lockTime ?? 600000 // 10 minutes
|
|
139
|
-
;
|
|
138
|
+
auth.lockTime = auth.lockTime ?? 600000; // 10 minutes
|
|
140
139
|
auth.loginWithUsername = auth.loginWithUsername ?? false;
|
|
141
140
|
auth.maxLoginAttempts = auth.maxLoginAttempts ?? 5;
|
|
142
141
|
auth.tokenExpiration = auth.tokenExpiration ?? 7200;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/config/defaults.ts"],"sourcesContent":["import type { IncomingAuthType, LoginWithUsernameOptions } from '../../auth/types.js'\nimport type { CollectionConfig } from './types.js'\n\nimport { defaultAccess } from '../../auth/defaultAccess.js'\n\n/**\n * @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.\n */\nexport const defaults: Partial<CollectionConfig> = {\n access: {\n create: defaultAccess,\n delete: defaultAccess,\n read: defaultAccess,\n unlock: defaultAccess,\n update: defaultAccess,\n },\n admin: {\n components: {},\n custom: {},\n enableRichTextLink: true,\n enableRichTextRelationship: true,\n pagination: {\n defaultLimit: 10,\n limits: [5, 10, 25, 50, 100],\n },\n useAsTitle: 'id',\n },\n auth: false,\n custom: {},\n endpoints: [],\n fields: [],\n hooks: {\n afterChange: [],\n afterDelete: [],\n afterForgotPassword: [],\n afterLogin: [],\n afterLogout: [],\n afterMe: [],\n afterOperation: [],\n afterRead: [],\n afterRefresh: [],\n beforeChange: [],\n beforeDelete: [],\n beforeLogin: [],\n beforeOperation: [],\n beforeRead: [],\n beforeValidate: [],\n me: [],\n refresh: [],\n },\n indexes: [],\n timestamps: true,\n upload: false,\n versions: false,\n}\n\nexport const addDefaultsToCollectionConfig = (collection: CollectionConfig): CollectionConfig => {\n collection.access = {\n create: defaultAccess,\n delete: defaultAccess,\n read: defaultAccess,\n unlock: defaultAccess,\n update: defaultAccess,\n ...(collection.access || {}),\n }\n\n collection.admin = {\n components: {},\n custom: {},\n enableRichTextLink: true,\n enableRichTextRelationship: true,\n useAsTitle: 'id',\n ...(collection.admin || {}),\n pagination: {\n defaultLimit: 10,\n limits: [5, 10, 25, 50, 100],\n ...(collection.admin?.pagination || {}),\n },\n }\n\n collection.auth = collection.auth ?? false\n collection.custom = collection.custom ?? {}\n collection.endpoints = collection.endpoints ?? []\n collection.fields = collection.fields ?? []\n collection.folders = collection.folders ?? false\n\n collection.hooks = {\n afterChange: [],\n afterDelete: [],\n afterForgotPassword: [],\n afterLogin: [],\n afterLogout: [],\n afterMe: [],\n afterOperation: [],\n afterRead: [],\n afterRefresh: [],\n beforeChange: [],\n beforeDelete: [],\n beforeLogin: [],\n beforeOperation: [],\n beforeRead: [],\n beforeValidate: [],\n me: [],\n refresh: [],\n ...(collection.hooks || {}),\n }\n\n collection.timestamps = collection.timestamps ?? true\n collection.upload = collection.upload ?? false\n collection.versions = collection.versions ?? false\n\n collection.indexes = collection.indexes ?? []\n\n return collection\n}\n\n/**\n * @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.\n */\nexport const authDefaults: IncomingAuthType = {\n cookies: {\n sameSite: 'Lax',\n secure: false,\n },\n forgotPassword: {},\n lockTime: 600000, // 10 minutes\n loginWithUsername: false,\n maxLoginAttempts: 5,\n tokenExpiration: 7200,\n useSessions: true,\n verify: false,\n}\n\nexport const addDefaultsToAuthConfig = (auth: IncomingAuthType): IncomingAuthType => {\n auth.cookies = {\n sameSite: 'Lax',\n secure: false,\n ...(auth.cookies || {}),\n }\n\n auth.forgotPassword = auth.forgotPassword ?? {}\n auth.lockTime = auth.lockTime ?? 600000 // 10 minutes\n auth.loginWithUsername = auth.loginWithUsername ?? false\n auth.maxLoginAttempts = auth.maxLoginAttempts ?? 5\n auth.tokenExpiration = auth.tokenExpiration ?? 7200\n auth.useSessions = auth.useSessions ?? true\n auth.verify = auth.verify ?? false\n auth.strategies = auth.strategies ?? []\n\n if (!auth.disableLocalStrategy && auth.verify === true) {\n auth.verify = {}\n }\n\n return auth\n}\n\n/**\n * @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.\n */\nexport const loginWithUsernameDefaults: LoginWithUsernameOptions = {\n allowEmailLogin: false,\n requireEmail: false,\n requireUsername: true,\n}\n\nexport const addDefaultsToLoginWithUsernameConfig = (\n loginWithUsername: LoginWithUsernameOptions,\n): LoginWithUsernameOptions =>\n ({\n allowEmailLogin: false,\n requireEmail: false,\n requireUsername: true,\n ...(loginWithUsername || {}),\n }) as LoginWithUsernameOptions\n"],"names":["defaultAccess","defaults","access","create","delete","read","unlock","update","admin","components","custom","enableRichTextLink","enableRichTextRelationship","pagination","defaultLimit","limits","useAsTitle","auth","endpoints","fields","hooks","afterChange","afterDelete","afterForgotPassword","afterLogin","afterLogout","afterMe","afterOperation","afterRead","afterRefresh","beforeChange","beforeDelete","beforeLogin","beforeOperation","beforeRead","beforeValidate","me","refresh","indexes","timestamps","upload","versions","addDefaultsToCollectionConfig","collection","folders","authDefaults","cookies","sameSite","secure","forgotPassword","lockTime","loginWithUsername","maxLoginAttempts","tokenExpiration","useSessions","verify","addDefaultsToAuthConfig","strategies","disableLocalStrategy","loginWithUsernameDefaults","allowEmailLogin","requireEmail","requireUsername","addDefaultsToLoginWithUsernameConfig"],"mappings":"AAGA,SAASA,aAAa,QAAQ,8BAA6B;AAE3D;;CAEC,GACD,OAAO,MAAMC,WAAsC;IACjDC,QAAQ;QACNC,QAAQH;QACRI,QAAQJ;QACRK,MAAML;QACNM,QAAQN;QACRO,QAAQP;IACV;IACAQ,OAAO;QACLC,YAAY,CAAC;QACbC,QAAQ,CAAC;QACTC,oBAAo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version":3,"sources":["../../../src/collections/config/defaults.ts"],"sourcesContent":["import type { IncomingAuthType, LoginWithUsernameOptions } from '../../auth/types.js'\nimport type { CollectionConfig } from './types.js'\n\nimport { defaultAccess } from '../../auth/defaultAccess.js'\n\n/**\n * @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.\n */\nexport const defaults: Partial<CollectionConfig> = {\n access: {\n create: defaultAccess,\n delete: defaultAccess,\n read: defaultAccess,\n unlock: defaultAccess,\n update: defaultAccess,\n },\n admin: {\n components: {},\n custom: {},\n enableRichTextLink: true,\n enableRichTextRelationship: true,\n pagination: {\n defaultLimit: 10,\n limits: [5, 10, 25, 50, 100],\n },\n useAsTitle: 'id',\n },\n auth: false,\n custom: {},\n endpoints: [],\n fields: [],\n hooks: {\n afterChange: [],\n afterDelete: [],\n afterForgotPassword: [],\n afterLogin: [],\n afterLogout: [],\n afterMe: [],\n afterOperation: [],\n afterRead: [],\n afterRefresh: [],\n beforeChange: [],\n beforeDelete: [],\n beforeLogin: [],\n beforeOperation: [],\n beforeRead: [],\n beforeValidate: [],\n me: [],\n refresh: [],\n },\n indexes: [],\n timestamps: true,\n upload: false,\n versions: false,\n}\n\nexport const addDefaultsToCollectionConfig = (collection: CollectionConfig): CollectionConfig => {\n collection.access = {\n create: defaultAccess,\n delete: defaultAccess,\n read: defaultAccess,\n unlock: defaultAccess,\n update: defaultAccess,\n ...(collection.access || {}),\n }\n\n collection.admin = {\n components: {},\n custom: {},\n enableRichTextLink: true,\n enableRichTextRelationship: true,\n useAsTitle: 'id',\n ...(collection.admin || {}),\n pagination: {\n defaultLimit: 10,\n limits: [5, 10, 25, 50, 100],\n ...(collection.admin?.pagination || {}),\n },\n }\n\n collection.auth = collection.auth ?? false\n collection.custom = collection.custom ?? {}\n collection.endpoints = collection.endpoints ?? []\n collection.fields = collection.fields ?? []\n collection.folders = collection.folders ?? false\n\n collection.hooks = {\n afterChange: [],\n afterDelete: [],\n afterForgotPassword: [],\n afterLogin: [],\n afterLogout: [],\n afterMe: [],\n afterOperation: [],\n afterRead: [],\n afterRefresh: [],\n beforeChange: [],\n beforeDelete: [],\n beforeLogin: [],\n beforeOperation: [],\n beforeRead: [],\n beforeValidate: [],\n me: [],\n refresh: [],\n ...(collection.hooks || {}),\n }\n\n collection.timestamps = collection.timestamps ?? true\n collection.upload = collection.upload ?? false\n collection.versions = collection.versions ?? false\n\n collection.indexes = collection.indexes ?? []\n\n return collection\n}\n\n/**\n * @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.\n */\nexport const authDefaults: IncomingAuthType = {\n cookies: {\n sameSite: 'Lax',\n secure: false,\n },\n forgotPassword: {},\n lockTime: 600000, // 10 minutes\n loginWithUsername: false,\n maxLoginAttempts: 5,\n tokenExpiration: 7200,\n useSessions: true,\n verify: false,\n}\n\nexport const addDefaultsToAuthConfig = (auth: IncomingAuthType): IncomingAuthType => {\n auth.cookies = {\n sameSite: 'Lax',\n secure: false,\n ...(auth.cookies || {}),\n }\n\n auth.forgotPassword = auth.forgotPassword ?? {}\n auth.lockTime = auth.lockTime ?? 600000 // 10 minutes\n auth.loginWithUsername = auth.loginWithUsername ?? false\n auth.maxLoginAttempts = auth.maxLoginAttempts ?? 5\n auth.tokenExpiration = auth.tokenExpiration ?? 7200\n auth.useSessions = auth.useSessions ?? true\n auth.verify = auth.verify ?? false\n auth.strategies = auth.strategies ?? []\n\n if (!auth.disableLocalStrategy && auth.verify === true) {\n auth.verify = {}\n }\n\n return auth\n}\n\n/**\n * @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.\n */\nexport const loginWithUsernameDefaults: LoginWithUsernameOptions = {\n allowEmailLogin: false,\n requireEmail: false,\n requireUsername: true,\n}\n\nexport const addDefaultsToLoginWithUsernameConfig = (\n loginWithUsername: LoginWithUsernameOptions,\n): LoginWithUsernameOptions =>\n ({\n allowEmailLogin: false,\n requireEmail: false,\n requireUsername: true,\n ...(loginWithUsername || {}),\n }) as LoginWithUsernameOptions\n"],"names":["defaultAccess","defaults","access","create","delete","read","unlock","update","admin","components","custom","enableRichTextLink","enableRichTextRelationship","pagination","defaultLimit","limits","useAsTitle","auth","endpoints","fields","hooks","afterChange","afterDelete","afterForgotPassword","afterLogin","afterLogout","afterMe","afterOperation","afterRead","afterRefresh","beforeChange","beforeDelete","beforeLogin","beforeOperation","beforeRead","beforeValidate","me","refresh","indexes","timestamps","upload","versions","addDefaultsToCollectionConfig","collection","folders","authDefaults","cookies","sameSite","secure","forgotPassword","lockTime","loginWithUsername","maxLoginAttempts","tokenExpiration","useSessions","verify","addDefaultsToAuthConfig","strategies","disableLocalStrategy","loginWithUsernameDefaults","allowEmailLogin","requireEmail","requireUsername","addDefaultsToLoginWithUsernameConfig"],"mappings":"AAGA,SAASA,aAAa,QAAQ,8BAA6B;AAE3D;;CAEC,GACD,OAAO,MAAMC,WAAsC;IACjDC,QAAQ;QACNC,QAAQH;QACRI,QAAQJ;QACRK,MAAML;QACNM,QAAQN;QACRO,QAAQP;IACV;IACAQ,OAAO;QACLC,YAAY,CAAC;QACbC,QAAQ,CAAC;QACTC,oBAAoB;QACpBC,4BAA4B;QAC5BC,YAAY;YACVC,cAAc;YACdC,QAAQ;gBAAC;gBAAG;gBAAI;gBAAI;gBAAI;aAAI;QAC9B;QACAC,YAAY;IACd;IACAC,MAAM;IACNP,QAAQ,CAAC;IACTQ,WAAW,EAAE;IACbC,QAAQ,EAAE;IACVC,OAAO;QACLC,aAAa,EAAE;QACfC,aAAa,EAAE;QACfC,qBAAqB,EAAE;QACvBC,YAAY,EAAE;QACdC,aAAa,EAAE;QACfC,SAAS,EAAE;QACXC,gBAAgB,EAAE;QAClBC,WAAW,EAAE;QACbC,cAAc,EAAE;QAChBC,cAAc,EAAE;QAChBC,cAAc,EAAE;QAChBC,aAAa,EAAE;QACfC,iBAAiB,EAAE;QACnBC,YAAY,EAAE;QACdC,gBAAgB,EAAE;QAClBC,IAAI,EAAE;QACNC,SAAS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C,cAAc;IACdC,iBAAiB;AACnB,EAAC;AAED,OAAO,MAAMC,uCAAuC,CAClDZ,oBAEC,CAAA;QACCS,iBAAiB;QACjBC,cAAc;QACdC,iBAAiB;QACjB,GAAIX,qBAAqB,CAAC,CAAC;IAC7B,CAAA,EAA8B"}
|
package/dist/config/find.js
CHANGED
|
@@ -31,8 +31,7 @@ import { findUpSync } from '../utilities/findUp.js';
|
|
|
31
31
|
tsConfigPath: tsConfigResult.path
|
|
32
32
|
};
|
|
33
33
|
} catch (error) {
|
|
34
|
-
console.error(`Error parsing tsconfig.json: ${error}`) // Do not throw the error, as we can still continue with the other config path finding methods
|
|
35
|
-
;
|
|
34
|
+
console.error(`Error parsing tsconfig.json: ${error}`); // Do not throw the error, as we can still continue with the other config path finding methods
|
|
36
35
|
return {
|
|
37
36
|
rootPath: process.cwd()
|
|
38
37
|
};
|
package/dist/config/find.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config/find.ts"],"sourcesContent":["import { getTsconfig } from 'get-tsconfig'\nimport path from 'path'\n\nimport { findUpSync } from '../utilities/findUp.js'\n\n/**\n * List of all filenames to detect as a Payload configuration file.\n */\nexport const payloadConfigFileNames = ['payload.config.js', 'payload.config.ts']\n\n/**\n * Returns the source and output paths from the nearest tsconfig.json file.\n * If no tsconfig.json file is found, returns the current working directory.\n * @returns An object containing the source and output paths.\n */\nconst getTSConfigPaths = (): {\n configPath?: string\n outPath?: string\n rootPath?: string\n srcPath?: string\n tsConfigPath?: string\n} => {\n const tsConfigResult = getTsconfig()!\n const tsConfig = tsConfigResult.config\n const tsConfigDir = path.dirname(tsConfigResult.path)\n\n try {\n const rootConfigDir = path.resolve(tsConfigDir, tsConfig.compilerOptions!.baseUrl || '')\n const srcPath = tsConfig.compilerOptions?.rootDir || path.resolve(process.cwd(), 'src')\n const outPath = tsConfig.compilerOptions?.outDir || path.resolve(process.cwd(), 'dist')\n let configPath = tsConfig.compilerOptions?.paths?.['@payload-config']?.[0]\n\n if (configPath) {\n configPath = path.resolve(rootConfigDir, configPath)\n }\n return {\n configPath,\n outPath,\n rootPath: rootConfigDir,\n srcPath,\n tsConfigPath: tsConfigResult.path,\n }\n } catch (error) {\n console.error(`Error parsing tsconfig.json: ${error}`) // Do not throw the error, as we can still continue with the other config path finding methods\n return {\n rootPath: process.cwd(),\n }\n }\n}\n\n/**\n * Searches for a Payload configuration file.\n * @returns The absolute path to the Payload configuration file.\n * @throws An error if no configuration file is found.\n */\nexport const findConfig = (): string => {\n // If the developer has specified a config path,\n // format it if relative and use it directly if absolute\n if (process.env.PAYLOAD_CONFIG_PATH) {\n if (path.isAbsolute(process.env.PAYLOAD_CONFIG_PATH)) {\n return process.env.PAYLOAD_CONFIG_PATH\n }\n\n return path.resolve(process.cwd(), process.env.PAYLOAD_CONFIG_PATH)\n }\n\n const { configPath, outPath, rootPath, srcPath } = getTSConfigPaths()\n\n // if configPath is absolute file, not folder, return it\n if (configPath && (path.extname(configPath) === '.js' || path.extname(configPath) === '.ts')) {\n return configPath\n }\n\n const searchPaths =\n process.env.NODE_ENV === 'production'\n ? [configPath, outPath, srcPath, rootPath]\n : [configPath, srcPath, rootPath]\n\n for (const searchPath of searchPaths) {\n if (!searchPath) {\n continue\n }\n\n const configPath = findUpSync({\n dir: searchPath,\n fileNames: payloadConfigFileNames,\n })\n\n if (configPath) {\n return configPath\n }\n }\n\n // If no config file is found in the directories defined by tsconfig.json,\n // try searching in the 'src' and 'dist' directory as a last resort, as they are most commonly used\n if (process.env.NODE_ENV === 'production') {\n const distConfigPath = findUpSync({\n dir: path.resolve(process.cwd(), 'dist'),\n fileNames: ['payload.config.js'],\n })\n\n if (distConfigPath) {\n return distConfigPath\n }\n } else {\n const srcConfigPath = findUpSync({\n dir: path.resolve(process.cwd(), 'src'),\n fileNames: payloadConfigFileNames,\n })\n\n if (srcConfigPath) {\n return srcConfigPath\n }\n }\n\n throw new Error(\n 'Error: cannot find Payload config. Please create a configuration file located at the root of your current working directory called \"payload.config.js\" or \"payload.config.ts\".',\n )\n}\n"],"names":["getTsconfig","path","findUpSync","payloadConfigFileNames","getTSConfigPaths","tsConfigResult","tsConfig","config","tsConfigDir","dirname","rootConfigDir","resolve","compilerOptions","baseUrl","srcPath","rootDir","process","cwd","outPath","outDir","configPath","paths","rootPath","tsConfigPath","error","console","findConfig","env","PAYLOAD_CONFIG_PATH","isAbsolute","extname","searchPaths","NODE_ENV","searchPath","dir","fileNames","distConfigPath","srcConfigPath","Error"],"mappings":"AAAA,SAASA,WAAW,QAAQ,eAAc;AAC1C,OAAOC,UAAU,OAAM;AAEvB,SAASC,UAAU,QAAQ,yBAAwB;AAEnD;;CAEC,GACD,OAAO,MAAMC,yBAAyB;IAAC;IAAqB;CAAoB,CAAA;AAEhF;;;;CAIC,GACD,MAAMC,mBAAmB;IAOvB,MAAMC,iBAAiBL;IACvB,MAAMM,WAAWD,eAAeE,MAAM;IACtC,MAAMC,cAAcP,KAAKQ,OAAO,CAACJ,eAAeJ,IAAI;IAEpD,IAAI;QACF,MAAMS,gBAAgBT,KAAKU,OAAO,CAACH,aAAaF,SAASM,eAAe,CAAEC,OAAO,IAAI;QACrF,MAAMC,UAAUR,SAASM,eAAe,EAAEG,WAAWd,KAAKU,OAAO,CAACK,QAAQC,GAAG,IAAI;QACjF,MAAMC,UAAUZ,SAASM,eAAe,EAAEO,UAAUlB,KAAKU,OAAO,CAACK,QAAQC,GAAG,IAAI;QAChF,IAAIG,aAAad,SAASM,eAAe,EAAES,OAAO,CAAC,kBAAkB,EAAE,CAAC,EAAE;QAE1E,IAAID,YAAY;YACdA,aAAanB,KAAKU,OAAO,CAACD,eAAeU;QAC3C;QACA,OAAO;YACLA;YACAF;YACAI,UAAUZ;YACVI;YACAS,cAAclB,eAAeJ,IAAI;QACnC;IACF,EAAE,OAAOuB,OAAO;QACdC,QAAQD,KAAK,CAAC,CAAC,6BAA6B,EAAEA,OAAO,
|
|
1
|
+
{"version":3,"sources":["../../src/config/find.ts"],"sourcesContent":["import { getTsconfig } from 'get-tsconfig'\nimport path from 'path'\n\nimport { findUpSync } from '../utilities/findUp.js'\n\n/**\n * List of all filenames to detect as a Payload configuration file.\n */\nexport const payloadConfigFileNames = ['payload.config.js', 'payload.config.ts']\n\n/**\n * Returns the source and output paths from the nearest tsconfig.json file.\n * If no tsconfig.json file is found, returns the current working directory.\n * @returns An object containing the source and output paths.\n */\nconst getTSConfigPaths = (): {\n configPath?: string\n outPath?: string\n rootPath?: string\n srcPath?: string\n tsConfigPath?: string\n} => {\n const tsConfigResult = getTsconfig()!\n const tsConfig = tsConfigResult.config\n const tsConfigDir = path.dirname(tsConfigResult.path)\n\n try {\n const rootConfigDir = path.resolve(tsConfigDir, tsConfig.compilerOptions!.baseUrl || '')\n const srcPath = tsConfig.compilerOptions?.rootDir || path.resolve(process.cwd(), 'src')\n const outPath = tsConfig.compilerOptions?.outDir || path.resolve(process.cwd(), 'dist')\n let configPath = tsConfig.compilerOptions?.paths?.['@payload-config']?.[0]\n\n if (configPath) {\n configPath = path.resolve(rootConfigDir, configPath)\n }\n return {\n configPath,\n outPath,\n rootPath: rootConfigDir,\n srcPath,\n tsConfigPath: tsConfigResult.path,\n }\n } catch (error) {\n console.error(`Error parsing tsconfig.json: ${error}`) // Do not throw the error, as we can still continue with the other config path finding methods\n return {\n rootPath: process.cwd(),\n }\n }\n}\n\n/**\n * Searches for a Payload configuration file.\n * @returns The absolute path to the Payload configuration file.\n * @throws An error if no configuration file is found.\n */\nexport const findConfig = (): string => {\n // If the developer has specified a config path,\n // format it if relative and use it directly if absolute\n if (process.env.PAYLOAD_CONFIG_PATH) {\n if (path.isAbsolute(process.env.PAYLOAD_CONFIG_PATH)) {\n return process.env.PAYLOAD_CONFIG_PATH\n }\n\n return path.resolve(process.cwd(), process.env.PAYLOAD_CONFIG_PATH)\n }\n\n const { configPath, outPath, rootPath, srcPath } = getTSConfigPaths()\n\n // if configPath is absolute file, not folder, return it\n if (configPath && (path.extname(configPath) === '.js' || path.extname(configPath) === '.ts')) {\n return configPath\n }\n\n const searchPaths =\n process.env.NODE_ENV === 'production'\n ? [configPath, outPath, srcPath, rootPath]\n : [configPath, srcPath, rootPath]\n\n for (const searchPath of searchPaths) {\n if (!searchPath) {\n continue\n }\n\n const configPath = findUpSync({\n dir: searchPath,\n fileNames: payloadConfigFileNames,\n })\n\n if (configPath) {\n return configPath\n }\n }\n\n // If no config file is found in the directories defined by tsconfig.json,\n // try searching in the 'src' and 'dist' directory as a last resort, as they are most commonly used\n if (process.env.NODE_ENV === 'production') {\n const distConfigPath = findUpSync({\n dir: path.resolve(process.cwd(), 'dist'),\n fileNames: ['payload.config.js'],\n })\n\n if (distConfigPath) {\n return distConfigPath\n }\n } else {\n const srcConfigPath = findUpSync({\n dir: path.resolve(process.cwd(), 'src'),\n fileNames: payloadConfigFileNames,\n })\n\n if (srcConfigPath) {\n return srcConfigPath\n }\n }\n\n throw new Error(\n 'Error: cannot find Payload config. Please create a configuration file located at the root of your current working directory called \"payload.config.js\" or \"payload.config.ts\".',\n )\n}\n"],"names":["getTsconfig","path","findUpSync","payloadConfigFileNames","getTSConfigPaths","tsConfigResult","tsConfig","config","tsConfigDir","dirname","rootConfigDir","resolve","compilerOptions","baseUrl","srcPath","rootDir","process","cwd","outPath","outDir","configPath","paths","rootPath","tsConfigPath","error","console","findConfig","env","PAYLOAD_CONFIG_PATH","isAbsolute","extname","searchPaths","NODE_ENV","searchPath","dir","fileNames","distConfigPath","srcConfigPath","Error"],"mappings":"AAAA,SAASA,WAAW,QAAQ,eAAc;AAC1C,OAAOC,UAAU,OAAM;AAEvB,SAASC,UAAU,QAAQ,yBAAwB;AAEnD;;CAEC,GACD,OAAO,MAAMC,yBAAyB;IAAC;IAAqB;CAAoB,CAAA;AAEhF;;;;CAIC,GACD,MAAMC,mBAAmB;IAOvB,MAAMC,iBAAiBL;IACvB,MAAMM,WAAWD,eAAeE,MAAM;IACtC,MAAMC,cAAcP,KAAKQ,OAAO,CAACJ,eAA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eACrB;QAACZ;QAAYF;QAASJ;QAASQ;KAAS,GACxC;QAACF;QAAYN;QAASQ;KAAS;IAErC,KAAK,MAAMW,cAAcF,YAAa;QACpC,IAAI,CAACE,YAAY;YACf;QACF;QAEA,MAAMb,aAAalB,WAAW;YAC5BgC,KAAKD;YACLE,WAAWhC;QACb;QAEA,IAAIiB,YAAY;YACd,OAAOA;QACT;IACF;IAEA,0EAA0E;IAC1E,mGAAmG;IACnG,IAAIJ,QAAQW,GAAG,CAACK,QAAQ,KAAK,cAAc;QACzC,MAAMI,iBAAiBlC,WAAW;YAChCgC,KAAKjC,KAAKU,OAAO,CAACK,QAAQC,GAAG,IAAI;YACjCkB,WAAW;gBAAC;aAAoB;QAClC;QAEA,IAAIC,gBAAgB;YAClB,OAAOA;QACT;IACF,OAAO;QACL,MAAMC,gBAAgBnC,WAAW;YAC/BgC,KAAKjC,KAAKU,OAAO,CAACK,QAAQC,GAAG,IAAI;YACjCkB,WAAWhC;QACb;QAEA,IAAIkC,eAAe;YACjB,OAAOA;QACT;IACF;IAEA,MAAM,IAAIC,MACR;AAEJ,EAAC"}
|
package/dist/errors/APIError.js
CHANGED
|
@@ -17,8 +17,7 @@ class ExtendableError extends Error {
|
|
|
17
17
|
this.status = status;
|
|
18
18
|
this.data = data;
|
|
19
19
|
this.isPublic = isPublic;
|
|
20
|
-
this.isOperational = true // This is required since bluebird 4 doesn't append it anymore.
|
|
21
|
-
;
|
|
20
|
+
this.isOperational = true; // This is required since bluebird 4 doesn't append it anymore.
|
|
22
21
|
Error.captureStackTrace(this, this.constructor);
|
|
23
22
|
}
|
|
24
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/APIError.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\n// This gets dynamically reassigned during compilation\nexport let APIErrorName = 'APIError'\n\nclass ExtendableError<TData extends object = { [key: string]: unknown }> extends Error {\n data: TData\n\n isOperational: boolean\n\n isPublic: boolean\n\n status: number\n\n constructor(message: string, status: number, data: TData, isPublic: boolean) {\n super(message, {\n // show data in cause\n cause: data,\n })\n APIErrorName = this.constructor.name\n this.name = this.constructor.name\n this.message = message\n this.status = status\n this.data = data\n this.isPublic = isPublic\n this.isOperational = true // This is required since bluebird 4 doesn't append it anymore.\n Error.captureStackTrace(this, this.constructor)\n }\n}\n\n/**\n * Class representing an API error.\n * @extends ExtendableError\n */\nexport class APIError<\n TData extends null | object = { [key: string]: unknown } | null,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n> extends ExtendableError<TData> {\n /**\n * Creates an API error.\n * @param {string} message - Error message.\n * @param {number} status - HTTP status code of error.\n * @param {object} data - response data to be returned.\n * @param {boolean} isPublic - Whether the message should be visible to user or not.\n */\n constructor(\n message: string,\n status: number = httpStatus.INTERNAL_SERVER_ERROR,\n data: TData = null!,\n isPublic?: boolean,\n ) {\n super(\n message,\n status,\n data,\n typeof isPublic === 'boolean' ? isPublic : status !== httpStatus.INTERNAL_SERVER_ERROR,\n )\n }\n}\n"],"names":["status","httpStatus","APIErrorName","ExtendableError","Error","data","isOperational","isPublic","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/APIError.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\n// This gets dynamically reassigned during compilation\nexport let APIErrorName = 'APIError'\n\nclass ExtendableError<TData extends object = { [key: string]: unknown }> extends Error {\n data: TData\n\n isOperational: boolean\n\n isPublic: boolean\n\n status: number\n\n constructor(message: string, status: number, data: TData, isPublic: boolean) {\n super(message, {\n // show data in cause\n cause: data,\n })\n APIErrorName = this.constructor.name\n this.name = this.constructor.name\n this.message = message\n this.status = status\n this.data = data\n this.isPublic = isPublic\n this.isOperational = true // This is required since bluebird 4 doesn't append it anymore.\n Error.captureStackTrace(this, this.constructor)\n }\n}\n\n/**\n * Class representing an API error.\n * @extends ExtendableError\n */\nexport class APIError<\n TData extends null | object = { [key: string]: unknown } | null,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n> extends ExtendableError<TData> {\n /**\n * Creates an API error.\n * @param {string} message - Error message.\n * @param {number} status - HTTP status code of error.\n * @param {object} data - response data to be returned.\n * @param {boolean} isPublic - Whether the message should be visible to user or not.\n */\n constructor(\n message: string,\n status: number = httpStatus.INTERNAL_SERVER_ERROR,\n data: TData = null!,\n isPublic?: boolean,\n ) {\n super(\n message,\n status,\n data,\n typeof isPublic === 'boolean' ? isPublic : status !== httpStatus.INTERNAL_SERVER_ERROR,\n )\n }\n}\n"],"names":["status","httpStatus","APIErrorName","ExtendableError","Error","data","isOperational","isPublic","message","cause","name","captureStackTrace","APIError","INTERNAL_SERVER_ERROR"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAElD,sDAAsD;AACtD,OAAO,IAAIC,eAAe,WAAU;AAEpC,MAAMC,wBAA2EC;IAC/EC,KAAW;IAEXC,cAAsB;IAEtBC,SAAiB;IAEjBP,OAAc;IAEd,YAAYQ,OAAe,EAAER,MAAc,EAAEK,IAAW,EAAEE,QAAiB,CAAE;QAC3E,KAAK,CAACC,SAAS;YACb,qBAAqB;YACrBC,OAAOJ;QACT;QACAH,eAAe,IAAI,CAAC,WAAW,CAACQ,IAAI;QACpC,IAAI,CAACA,IAAI,GAAG,IAAI,CAAC,WAAW,CAACA,IAAI;QACjC,IAAI,CAACF,OAAO,GAAGA;QACf,IAAI,CAACR,MAAM,GAAGA;QACd,IAAI,CAACK,IAAI,GAAGA;QACZ,IAAI,CAACE,QAAQ,GAAGA;QAChB,IAAI,CAACD,aAAa,GAAG,MAAK,+DAA+D;QACzFF,MAAMO,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW;IAChD;AACF;AAEA;;;CAGC,GACD,OAAO,MAAMC,iBAGHT;IACR;;;;;;GAMC,GACD,YACEK,OAAe,EACfR,SAAiBC,WAAWY,qBAAqB,EACjDR,OAAc,IAAK,EACnBE,QAAkB,CAClB;QACA,KAAK,CACHC,SACAR,QACAK,MACA,OAAOE,aAAa,YAAYA,WAAWP,WAAWC,WAAWY,qBAAqB;IAE1F;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/AuthenticationError.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class AuthenticationError extends APIError {\n constructor(t?: TFunction, loginWithUsername?: boolean) {\n super(\n t\n ? `${loginWithUsername ? t('error:usernameOrPasswordIncorrect') : t('error:emailOrPasswordIncorrect')}`\n : en.translations.error.emailOrPasswordIncorrect,\n httpStatus.UNAUTHORIZED,\n )\n }\n}\n"],"names":["en","status","httpStatus","APIError","AuthenticationError","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/AuthenticationError.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class AuthenticationError extends APIError {\n constructor(t?: TFunction, loginWithUsername?: boolean) {\n super(\n t\n ? `${loginWithUsername ? t('error:usernameOrPasswordIncorrect') : t('error:emailOrPasswordIncorrect')}`\n : en.translations.error.emailOrPasswordIncorrect,\n httpStatus.UNAUTHORIZED,\n )\n }\n}\n"],"names":["en","status","httpStatus","APIError","AuthenticationError","t","loginWithUsername","translations","error","emailOrPasswordIncorrect","UNAUTHORIZED"],"mappings":"AAEA,SAASA,EAAE,QAAQ,wCAAuC;AAC1D,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,4BAA4BD;IACvC,YAAYE,CAAa,EAAEC,iBAA2B,CAAE;QACtD,KAAK,CACHD,IACI,GAAGC,oBAAoBD,EAAE,uCAAuCA,EAAE,mCAAmC,GACrGL,GAAGO,YAAY,CAACC,KAAK,CAACC,wBAAwB,EAClDP,WAAWQ,YAAY;IAE3B;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/DuplicateCollection.ts"],"sourcesContent":["import { APIError } from './APIError.js'\n\nexport class DuplicateCollection extends APIError {\n constructor(propertyName: string, duplicate: string) {\n super(`Collection ${propertyName} already in use: \"${duplicate}\"`)\n }\n}\n"],"names":["APIError","DuplicateCollection","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/DuplicateCollection.ts"],"sourcesContent":["import { APIError } from './APIError.js'\n\nexport class DuplicateCollection extends APIError {\n constructor(propertyName: string, duplicate: string) {\n super(`Collection ${propertyName} already in use: \"${duplicate}\"`)\n }\n}\n"],"names":["APIError","DuplicateCollection","propertyName","duplicate"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,4BAA4BD;IACvC,YAAYE,YAAoB,EAAEC,SAAiB,CAAE;QACnD,KAAK,CAAC,CAAC,WAAW,EAAED,aAAa,kBAAkB,EAAEC,UAAU,CAAC,CAAC;IACnE;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/DuplicateFieldName.ts"],"sourcesContent":["import { APIError } from './APIError.js'\n\nexport class DuplicateFieldName extends APIError {\n constructor(fieldName: string) {\n super(\n `A field with the name '${fieldName}' was found multiple times on the same level. Field names must be unique.`,\n )\n }\n}\n"],"names":["APIError","DuplicateFieldName","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/DuplicateFieldName.ts"],"sourcesContent":["import { APIError } from './APIError.js'\n\nexport class DuplicateFieldName extends APIError {\n constructor(fieldName: string) {\n super(\n `A field with the name '${fieldName}' was found multiple times on the same level. Field names must be unique.`,\n )\n }\n}\n"],"names":["APIError","DuplicateFieldName","fieldName"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,2BAA2BD;IACtC,YAAYE,SAAiB,CAAE;QAC7B,KAAK,CACH,CAAC,uBAAuB,EAAEA,UAAU,yEAAyE,CAAC;IAElH;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/DuplicateGlobal.ts"],"sourcesContent":["import type { GlobalConfig } from '../globals/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class DuplicateGlobal extends APIError {\n constructor(config: GlobalConfig) {\n super(`Global label \"${config.label}\" is already in use`)\n }\n}\n"],"names":["APIError","DuplicateGlobal","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/DuplicateGlobal.ts"],"sourcesContent":["import type { GlobalConfig } from '../globals/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class DuplicateGlobal extends APIError {\n constructor(config: GlobalConfig) {\n super(`Global label \"${config.label}\" is already in use`)\n }\n}\n"],"names":["APIError","DuplicateGlobal","config","label"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,wBAAwBD;IACnC,YAAYE,MAAoB,CAAE;QAChC,KAAK,CAAC,CAAC,cAAc,EAAEA,OAAOC,KAAK,CAAC,mBAAmB,CAAC;IAC1D;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/ErrorDeletingFile.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class ErrorDeletingFile extends APIError {\n constructor(t?: TFunction) {\n super(\n t ? t('error:deletingFile') : en.translations.error.deletingFile,\n httpStatus.INTERNAL_SERVER_ERROR,\n )\n }\n}\n"],"names":["en","status","httpStatus","APIError","ErrorDeletingFile","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/ErrorDeletingFile.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class ErrorDeletingFile extends APIError {\n constructor(t?: TFunction) {\n super(\n t ? t('error:deletingFile') : en.translations.error.deletingFile,\n httpStatus.INTERNAL_SERVER_ERROR,\n )\n }\n}\n"],"names":["en","status","httpStatus","APIError","ErrorDeletingFile","t","translations","error","deletingFile","INTERNAL_SERVER_ERROR"],"mappings":"AAEA,SAASA,EAAE,QAAQ,wCAAuC;AAC1D,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,0BAA0BD;IACrC,YAAYE,CAAa,CAAE;QACzB,KAAK,CACHA,IAAIA,EAAE,wBAAwBL,GAAGM,YAAY,CAACC,KAAK,CAACC,YAAY,EAChEN,WAAWO,qBAAqB;IAEpC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/FileRetrievalError.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class FileRetrievalError extends APIError {\n constructor(t?: TFunction, message?: string) {\n let msg = t ? t('error:problemUploadingFile') : 'There was a problem while retrieving the file.'\n\n if (message) {\n msg += ` ${message}`\n }\n super(msg, httpStatus.INTERNAL_SERVER_ERROR)\n }\n}\n"],"names":["status","httpStatus","APIError","FileRetrievalError","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/FileRetrievalError.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class FileRetrievalError extends APIError {\n constructor(t?: TFunction, message?: string) {\n let msg = t ? t('error:problemUploadingFile') : 'There was a problem while retrieving the file.'\n\n if (message) {\n msg += ` ${message}`\n }\n super(msg, httpStatus.INTERNAL_SERVER_ERROR)\n }\n}\n"],"names":["status","httpStatus","APIError","FileRetrievalError","t","message","msg","INTERNAL_SERVER_ERROR"],"mappings":"AAEA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,2BAA2BD;IACtC,YAAYE,CAAa,EAAEC,OAAgB,CAAE;QAC3C,IAAIC,MAAMF,IAAIA,EAAE,gCAAgC;QAEhD,IAAIC,SAAS;YACXC,OAAO,CAAC,CAAC,EAAED,SAAS;QACtB;QACA,KAAK,CAACC,KAAKL,WAAWM,qBAAqB;IAC7C;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/FileUploadError.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class FileUploadError extends APIError {\n constructor(t?: TFunction) {\n super(\n t ? t('error:problemUploadingFile') : en.translations.error.problemUploadingFile,\n httpStatus.BAD_REQUEST,\n )\n }\n}\n"],"names":["en","status","httpStatus","APIError","FileUploadError","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/FileUploadError.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class FileUploadError extends APIError {\n constructor(t?: TFunction) {\n super(\n t ? t('error:problemUploadingFile') : en.translations.error.problemUploadingFile,\n httpStatus.BAD_REQUEST,\n )\n }\n}\n"],"names":["en","status","httpStatus","APIError","FileUploadError","t","translations","error","problemUploadingFile","BAD_REQUEST"],"mappings":"AAEA,SAASA,EAAE,QAAQ,wCAAuC;AAC1D,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,wBAAwBD;IACnC,YAAYE,CAAa,CAAE;QACzB,KAAK,CACHA,IAAIA,EAAE,gCAAgCL,GAAGM,YAAY,CAACC,KAAK,CAACC,oBAAoB,EAChFN,WAAWO,WAAW;IAE1B;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/Forbidden.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class Forbidden extends APIError {\n constructor(t?: TFunction) {\n super(\n t ? t('error:notAllowedToPerformAction') : en.translations.error.notAllowedToPerformAction,\n httpStatus.FORBIDDEN,\n )\n }\n}\n"],"names":["en","status","httpStatus","APIError","Forbidden","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/Forbidden.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class Forbidden extends APIError {\n constructor(t?: TFunction) {\n super(\n t ? t('error:notAllowedToPerformAction') : en.translations.error.notAllowedToPerformAction,\n httpStatus.FORBIDDEN,\n )\n }\n}\n"],"names":["en","status","httpStatus","APIError","Forbidden","t","translations","error","notAllowedToPerformAction","FORBIDDEN"],"mappings":"AAEA,SAASA,EAAE,QAAQ,wCAAuC;AAC1D,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,kBAAkBD;IAC7B,YAAYE,CAAa,CAAE;QACzB,KAAK,CACHA,IAAIA,EAAE,qCAAqCL,GAAGM,YAAY,CAACC,KAAK,CAACC,yBAAyB,EAC1FN,WAAWO,SAAS;IAExB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/InvalidConfiguration.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class InvalidConfiguration extends APIError {\n constructor(message: string) {\n super(message, httpStatus.INTERNAL_SERVER_ERROR)\n }\n}\n"],"names":["status","httpStatus","APIError","InvalidConfiguration","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/InvalidConfiguration.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class InvalidConfiguration extends APIError {\n constructor(message: string) {\n super(message, httpStatus.INTERNAL_SERVER_ERROR)\n }\n}\n"],"names":["status","httpStatus","APIError","InvalidConfiguration","message","INTERNAL_SERVER_ERROR"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,6BAA6BD;IACxC,YAAYE,OAAe,CAAE;QAC3B,KAAK,CAACA,SAASH,WAAWI,qBAAqB;IACjD;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/InvalidFieldJoin.ts"],"sourcesContent":["import type { JoinField } from '../fields/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class InvalidFieldJoin extends APIError {\n constructor(field: JoinField) {\n super(\n `Invalid join field ${field.name}. The config does not have a field '${field.on}' in collection '${field.collection}'.`,\n )\n }\n}\n"],"names":["APIError","InvalidFieldJoin","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/InvalidFieldJoin.ts"],"sourcesContent":["import type { JoinField } from '../fields/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class InvalidFieldJoin extends APIError {\n constructor(field: JoinField) {\n super(\n `Invalid join field ${field.name}. The config does not have a field '${field.on}' in collection '${field.collection}'.`,\n )\n }\n}\n"],"names":["APIError","InvalidFieldJoin","field","name","on","collection"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,yBAAyBD;IACpC,YAAYE,KAAgB,CAAE;QAC5B,KAAK,CACH,CAAC,mBAAmB,EAAEA,MAAMC,IAAI,CAAC,oCAAoC,EAAED,MAAME,EAAE,CAAC,iBAAiB,EAAEF,MAAMG,UAAU,CAAC,EAAE,CAAC;IAE3H;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/InvalidFieldName.ts"],"sourcesContent":["import type { FieldAffectingData } from '../fields/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class InvalidFieldName extends APIError {\n constructor(field: FieldAffectingData, fieldName: string) {\n super(\n `Field ${field.label} has invalid name '${fieldName}'. Field names can not include periods (.) and must be alphanumeric.`,\n )\n }\n}\n"],"names":["APIError","InvalidFieldName","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/InvalidFieldName.ts"],"sourcesContent":["import type { FieldAffectingData } from '../fields/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class InvalidFieldName extends APIError {\n constructor(field: FieldAffectingData, fieldName: string) {\n super(\n `Field ${field.label} has invalid name '${fieldName}'. Field names can not include periods (.) and must be alphanumeric.`,\n )\n }\n}\n"],"names":["APIError","InvalidFieldName","field","fieldName","label"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,yBAAyBD;IACpC,YAAYE,KAAyB,EAAEC,SAAiB,CAAE;QACxD,KAAK,CACH,CAAC,MAAM,EAAED,MAAME,KAAK,CAAC,mBAAmB,EAAED,UAAU,oEAAoE,CAAC;IAE7H;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/InvalidFieldRelationship.ts"],"sourcesContent":["import type { RelationshipField, UploadField } from '../fields/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class InvalidFieldRelationship extends APIError {\n constructor(field: RelationshipField | UploadField, relationship: string) {\n super(`Field ${field.label} has invalid relationship '${relationship}'.`)\n }\n}\n"],"names":["APIError","InvalidFieldRelationship","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/InvalidFieldRelationship.ts"],"sourcesContent":["import type { RelationshipField, UploadField } from '../fields/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class InvalidFieldRelationship extends APIError {\n constructor(field: RelationshipField | UploadField, relationship: string) {\n super(`Field ${field.label} has invalid relationship '${relationship}'.`)\n }\n}\n"],"names":["APIError","InvalidFieldRelationship","field","relationship","label"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,iCAAiCD;IAC5C,YAAYE,KAAsC,EAAEC,YAAoB,CAAE;QACxE,KAAK,CAAC,CAAC,MAAM,EAAED,MAAME,KAAK,CAAC,2BAA2B,EAAED,aAAa,EAAE,CAAC;IAC1E;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/InvalidSchema.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class InvalidSchema extends APIError {\n constructor(message: string, results: any) {\n super(message, httpStatus.INTERNAL_SERVER_ERROR, results)\n }\n}\n"],"names":["status","httpStatus","APIError","InvalidSchema","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/InvalidSchema.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class InvalidSchema extends APIError {\n constructor(message: string, results: any) {\n super(message, httpStatus.INTERNAL_SERVER_ERROR, results)\n }\n}\n"],"names":["status","httpStatus","APIError","InvalidSchema","message","results","INTERNAL_SERVER_ERROR"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,sBAAsBD;IACjC,YAAYE,OAAe,EAAEC,OAAY,CAAE;QACzC,KAAK,CAACD,SAASH,WAAWK,qBAAqB,EAAED;IACnD;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/Locked.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class Locked extends APIError {\n constructor(message: string) {\n super(message, httpStatus.LOCKED)\n }\n}\n"],"names":["status","httpStatus","APIError","Locked","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/Locked.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class Locked extends APIError {\n constructor(message: string) {\n super(message, httpStatus.LOCKED)\n }\n}\n"],"names":["status","httpStatus","APIError","Locked","message","LOCKED"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,eAAeD;IAC1B,YAAYE,OAAe,CAAE;QAC3B,KAAK,CAACA,SAASH,WAAWI,MAAM;IAClC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/LockedAuth.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class LockedAuth extends APIError {\n constructor(t?: TFunction) {\n super(t ? t('error:userLocked') : en.translations.error.userLocked, httpStatus.UNAUTHORIZED)\n }\n}\n"],"names":["en","status","httpStatus","APIError","LockedAuth","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/LockedAuth.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class LockedAuth extends APIError {\n constructor(t?: TFunction) {\n super(t ? t('error:userLocked') : en.translations.error.userLocked, httpStatus.UNAUTHORIZED)\n }\n}\n"],"names":["en","status","httpStatus","APIError","LockedAuth","t","translations","error","userLocked","UNAUTHORIZED"],"mappings":"AAEA,SAASA,EAAE,QAAQ,wCAAuC;AAC1D,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,mBAAmBD;IAC9B,YAAYE,CAAa,CAAE;QACzB,KAAK,CAACA,IAAIA,EAAE,sBAAsBL,GAAGM,YAAY,CAACC,KAAK,CAACC,UAAU,EAAEN,WAAWO,YAAY;IAC7F;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/MissingCollectionLabel.ts"],"sourcesContent":["import { APIError } from './APIError.js'\n\nexport class MissingCollectionLabel extends APIError {\n constructor() {\n super('payload.config.collection object is missing label')\n }\n}\n"],"names":["APIError","MissingCollectionLabel"
|
|
1
|
+
{"version":3,"sources":["../../src/errors/MissingCollectionLabel.ts"],"sourcesContent":["import { APIError } from './APIError.js'\n\nexport class MissingCollectionLabel extends APIError {\n constructor() {\n super('payload.config.collection object is missing label')\n }\n}\n"],"names":["APIError","MissingCollectionLabel"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,+BAA+BD;IAC1C,aAAc;QACZ,KAAK,CAAC;IACR;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/MissingEditorProp.ts"],"sourcesContent":["import type { Field } from '../fields/config/types.js'\n\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { APIError } from './APIError.js'\n\nexport class MissingEditorProp extends APIError {\n constructor(field: Field) {\n super(\n `RichText field${fieldAffectsData(field) ? ` \"${field.name}\"` : ''} is missing the editor prop. For sub-richText fields, the editor props is required, as it would otherwise create infinite recursion.`,\n )\n }\n}\n"],"names":["fieldAffectsData","APIError","MissingEditorProp","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/MissingEditorProp.ts"],"sourcesContent":["import type { Field } from '../fields/config/types.js'\n\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { APIError } from './APIError.js'\n\nexport class MissingEditorProp extends APIError {\n constructor(field: Field) {\n super(\n `RichText field${fieldAffectsData(field) ? ` \"${field.name}\"` : ''} is missing the editor prop. For sub-richText fields, the editor props is required, as it would otherwise create infinite recursion.`,\n )\n }\n}\n"],"names":["fieldAffectsData","APIError","MissingEditorProp","field","name"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,0BAA0BD;IACrC,YAAYE,KAAY,CAAE;QACxB,KAAK,CACH,CAAC,cAAc,EAAEH,iBAAiBG,SAAS,CAAC,EAAE,EAAEA,MAAMC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,oIAAoI,CAAC;IAE5M;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/MissingFieldInputOptions.ts"],"sourcesContent":["import type { RadioField, SelectField } from '../fields/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class MissingFieldInputOptions extends APIError {\n constructor(field: RadioField | SelectField) {\n super(`Field ${field.label} is missing options.`)\n }\n}\n"],"names":["APIError","MissingFieldInputOptions","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/MissingFieldInputOptions.ts"],"sourcesContent":["import type { RadioField, SelectField } from '../fields/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class MissingFieldInputOptions extends APIError {\n constructor(field: RadioField | SelectField) {\n super(`Field ${field.label} is missing options.`)\n }\n}\n"],"names":["APIError","MissingFieldInputOptions","field","label"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,iCAAiCD;IAC5C,YAAYE,KAA+B,CAAE;QAC3C,KAAK,CAAC,CAAC,MAAM,EAAEA,MAAMC,KAAK,CAAC,oBAAoB,CAAC;IAClD;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/MissingFieldType.ts"],"sourcesContent":["import type { Field } from '../fields/config/types.js'\n\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { APIError } from './APIError.js'\n\nexport class MissingFieldType extends APIError {\n constructor(field: Field) {\n super(\n `Field${\n fieldAffectsData(field) ? ` \"${field.name}\"` : ''\n } is either missing a field type or it does not match an available field type`,\n )\n }\n}\n"],"names":["fieldAffectsData","APIError","MissingFieldType","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/MissingFieldType.ts"],"sourcesContent":["import type { Field } from '../fields/config/types.js'\n\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { APIError } from './APIError.js'\n\nexport class MissingFieldType extends APIError {\n constructor(field: Field) {\n super(\n `Field${\n fieldAffectsData(field) ? ` \"${field.name}\"` : ''\n } is either missing a field type or it does not match an available field type`,\n )\n }\n}\n"],"names":["fieldAffectsData","APIError","MissingFieldType","field","name"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,yBAAyBD;IACpC,YAAYE,KAAY,CAAE;QACxB,KAAK,CACH,CAAC,KAAK,EACJH,iBAAiBG,SAAS,CAAC,EAAE,EAAEA,MAAMC,IAAI,CAAC,CAAC,CAAC,GAAG,GAChD,4EAA4E,CAAC;IAElF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/MissingFile.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class MissingFile extends APIError {\n constructor(t?: TFunction) {\n super(\n t ? t('error:noFilesUploaded') : en.translations.error.noFilesUploaded,\n httpStatus.BAD_REQUEST,\n )\n }\n}\n"],"names":["en","status","httpStatus","APIError","MissingFile","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/MissingFile.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class MissingFile extends APIError {\n constructor(t?: TFunction) {\n super(\n t ? t('error:noFilesUploaded') : en.translations.error.noFilesUploaded,\n httpStatus.BAD_REQUEST,\n )\n }\n}\n"],"names":["en","status","httpStatus","APIError","MissingFile","t","translations","error","noFilesUploaded","BAD_REQUEST"],"mappings":"AAEA,SAASA,EAAE,QAAQ,wCAAuC;AAC1D,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,oBAAoBD;IAC/B,YAAYE,CAAa,CAAE;QACzB,KAAK,CACHA,IAAIA,EAAE,2BAA2BL,GAAGM,YAAY,CAACC,KAAK,CAACC,eAAe,EACtEN,WAAWO,WAAW;IAE1B;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/NotFound.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class NotFound extends APIError {\n constructor(t?: TFunction) {\n super(t ? t('general:notFound') : en.translations.general.notFound, httpStatus.NOT_FOUND)\n }\n}\n"],"names":["en","status","httpStatus","APIError","NotFound","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/NotFound.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class NotFound extends APIError {\n constructor(t?: TFunction) {\n super(t ? t('general:notFound') : en.translations.general.notFound, httpStatus.NOT_FOUND)\n }\n}\n"],"names":["en","status","httpStatus","APIError","NotFound","t","translations","general","notFound","NOT_FOUND"],"mappings":"AAEA,SAASA,EAAE,QAAQ,wCAAuC;AAC1D,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,iBAAiBD;IAC5B,YAAYE,CAAa,CAAE;QACzB,KAAK,CAACA,IAAIA,EAAE,sBAAsBL,GAAGM,YAAY,CAACC,OAAO,CAACC,QAAQ,EAAEN,WAAWO,SAAS;IAC1F;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/QueryError.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class QueryError extends APIError<{ path: string }[]> {\n constructor(results: { path: string }[]) {\n const message = `The following path${results.length === 1 ? '' : 's'} cannot be queried:`\n\n super(\n `${message} ${results.map((err) => err.path).join(', ')}`,\n httpStatus.BAD_REQUEST,\n results,\n )\n }\n}\n"],"names":["status","httpStatus","APIError","QueryError","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/QueryError.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport { APIError } from './APIError.js'\n\nexport class QueryError extends APIError<{ path: string }[]> {\n constructor(results: { path: string }[]) {\n const message = `The following path${results.length === 1 ? '' : 's'} cannot be queried:`\n\n super(\n `${message} ${results.map((err) => err.path).join(', ')}`,\n httpStatus.BAD_REQUEST,\n results,\n )\n }\n}\n"],"names":["status","httpStatus","APIError","QueryError","results","message","length","map","err","path","join","BAD_REQUEST"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAElD,SAASC,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,mBAAmBD;IAC9B,YAAYE,OAA2B,CAAE;QACvC,MAAMC,UAAU,CAAC,kBAAkB,EAAED,QAAQE,MAAM,KAAK,IAAI,KAAK,IAAI,mBAAmB,CAAC;QAEzF,KAAK,CACH,GAAGD,QAAQ,CAAC,EAAED,QAAQG,GAAG,CAAC,CAACC,MAAQA,IAAIC,IAAI,EAAEC,IAAI,CAAC,OAAO,EACzDT,WAAWU,WAAW,EACtBP;IAEJ;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/ReservedFieldName.ts"],"sourcesContent":["import type { FieldAffectingData } from '../fields/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class ReservedFieldName extends APIError {\n constructor(field: FieldAffectingData, fieldName: string) {\n super(`Field ${field.label} has reserved name '${fieldName}'.`)\n }\n}\n"],"names":["APIError","ReservedFieldName","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/ReservedFieldName.ts"],"sourcesContent":["import type { FieldAffectingData } from '../fields/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class ReservedFieldName extends APIError {\n constructor(field: FieldAffectingData, fieldName: string) {\n super(`Field ${field.label} has reserved name '${fieldName}'.`)\n }\n}\n"],"names":["APIError","ReservedFieldName","field","fieldName","label"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,0BAA0BD;IACrC,YAAYE,KAAyB,EAAEC,SAAiB,CAAE;QACxD,KAAK,CAAC,CAAC,MAAM,EAAED,MAAME,KAAK,CAAC,oBAAoB,EAAED,UAAU,EAAE,CAAC;IAChE;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors/TimestampsRequired.ts"],"sourcesContent":["import type { CollectionConfig } from '../collections/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class TimestampsRequired extends APIError {\n constructor(collection: CollectionConfig) {\n super(\n `Timestamps are required in the collection ${collection.slug} because you have opted in to Versions.`,\n )\n }\n}\n"],"names":["APIError","TimestampsRequired","
|
|
1
|
+
{"version":3,"sources":["../../src/errors/TimestampsRequired.ts"],"sourcesContent":["import type { CollectionConfig } from '../collections/config/types.js'\n\nimport { APIError } from './APIError.js'\n\nexport class TimestampsRequired extends APIError {\n constructor(collection: CollectionConfig) {\n super(\n `Timestamps are required in the collection ${collection.slug} because you have opted in to Versions.`,\n )\n }\n}\n"],"names":["APIError","TimestampsRequired","collection","slug"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,gBAAe;AAExC,OAAO,MAAMC,2BAA2BD;IACtC,YAAYE,UAA4B,CAAE;QACxC,KAAK,CACH,CAAC,0CAA0C,EAAEA,WAAWC,IAAI,CAAC,uCAAuC,CAAC;IAEzG;AACF"}
|