payload 4.0.0-internal.2fddfc0 → 4.0.0-internal.3aa3d85
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/LICENSE.md +1 -1
- package/bin.js +11 -0
- package/dist/admin/RichText.d.ts +1 -21
- package/dist/admin/RichText.d.ts.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/admin/forms/Field.d.ts +2 -2
- package/dist/admin/forms/Field.d.ts.map +1 -1
- package/dist/admin/forms/Field.js.map +1 -1
- package/dist/admin/forms/Form.d.ts +0 -29
- package/dist/admin/forms/Form.d.ts.map +1 -1
- package/dist/admin/forms/Form.js.map +1 -1
- package/dist/admin/functions/index.d.ts +1 -1
- package/dist/admin/functions/index.js.map +1 -1
- package/dist/admin/types.d.ts +1 -0
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/admin/types.js.map +1 -1
- package/dist/auth/operations/auth.d.ts +2 -2
- package/dist/auth/operations/auth.d.ts.map +1 -1
- package/dist/auth/operations/auth.js.map +1 -1
- package/dist/auth/operations/login.d.ts +2 -1
- package/dist/auth/operations/login.d.ts.map +1 -1
- package/dist/auth/operations/login.js.map +1 -1
- package/dist/auth/operations/me.js.map +1 -1
- package/dist/auth/operations/refresh.d.ts.map +1 -1
- package/dist/auth/operations/refresh.js +9 -3
- package/dist/auth/operations/refresh.js.map +1 -1
- package/dist/auth/operations/resetPassword.d.ts.map +1 -1
- package/dist/auth/operations/resetPassword.js.map +1 -1
- package/dist/auth/sendVerificationEmail.d.ts +2 -2
- package/dist/auth/sendVerificationEmail.d.ts.map +1 -1
- package/dist/auth/sendVerificationEmail.js +1 -1
- package/dist/auth/sendVerificationEmail.js.map +1 -1
- package/dist/auth/sessions.d.ts +4 -5
- package/dist/auth/sessions.d.ts.map +1 -1
- package/dist/auth/sessions.js +5 -3
- package/dist/auth/sessions.js.map +1 -1
- package/dist/auth/strategies/apiKey.js.map +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.d.ts +2 -2
- package/dist/auth/strategies/local/incrementLoginAttempts.d.ts.map +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.js +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.js.map +1 -1
- package/dist/auth/types.d.ts +28 -21
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/bin/generateImportMap/iterateCollections.d.ts.map +1 -1
- package/dist/bin/generateImportMap/iterateCollections.js +10 -0
- package/dist/bin/generateImportMap/iterateCollections.js.map +1 -1
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.d.ts.map +1 -1
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.js +11 -3
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.js.map +1 -1
- package/dist/collections/config/client.d.ts +1 -1
- package/dist/collections/config/client.d.ts.map +1 -1
- package/dist/collections/config/client.js +1 -0
- package/dist/collections/config/client.js.map +1 -1
- package/dist/collections/config/defaults.d.ts +0 -4
- package/dist/collections/config/defaults.d.ts.map +1 -1
- package/dist/collections/config/defaults.js +0 -15
- package/dist/collections/config/defaults.js.map +1 -1
- package/dist/collections/config/types.d.ts +6 -0
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/operations/findDistinct.d.ts.map +1 -1
- package/dist/collections/operations/findDistinct.js +1 -0
- package/dist/collections/operations/findDistinct.js.map +1 -1
- package/dist/collections/operations/local/count.d.ts +3 -3
- package/dist/collections/operations/local/count.d.ts.map +1 -1
- package/dist/collections/operations/local/count.js.map +1 -1
- package/dist/collections/operations/local/countVersions.d.ts +3 -3
- package/dist/collections/operations/local/countVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/countVersions.js.map +1 -1
- package/dist/collections/operations/local/create.d.ts +3 -3
- package/dist/collections/operations/local/create.d.ts.map +1 -1
- package/dist/collections/operations/local/create.js.map +1 -1
- package/dist/collections/operations/local/delete.d.ts +3 -3
- package/dist/collections/operations/local/delete.d.ts.map +1 -1
- package/dist/collections/operations/local/delete.js.map +1 -1
- package/dist/collections/operations/local/duplicate.d.ts +3 -3
- package/dist/collections/operations/local/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/local/duplicate.js.map +1 -1
- package/dist/collections/operations/local/find.d.ts +3 -3
- package/dist/collections/operations/local/find.d.ts.map +1 -1
- package/dist/collections/operations/local/find.js.map +1 -1
- package/dist/collections/operations/local/findByID.d.ts +3 -3
- package/dist/collections/operations/local/findByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findByID.js.map +1 -1
- package/dist/collections/operations/local/findDistinct.d.ts +2 -2
- package/dist/collections/operations/local/findDistinct.d.ts.map +1 -1
- package/dist/collections/operations/local/findDistinct.js.map +1 -1
- package/dist/collections/operations/local/findVersionByID.d.ts +3 -3
- package/dist/collections/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersionByID.js.map +1 -1
- package/dist/collections/operations/local/findVersions.d.ts +3 -3
- package/dist/collections/operations/local/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersions.js.map +1 -1
- package/dist/collections/operations/local/restoreVersion.d.ts +3 -3
- package/dist/collections/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/local/restoreVersion.js.map +1 -1
- package/dist/collections/operations/local/update.d.ts +3 -3
- package/dist/collections/operations/local/update.d.ts.map +1 -1
- package/dist/collections/operations/local/update.js.map +1 -1
- package/dist/collections/operations/utilities/types.d.ts +0 -9
- package/dist/collections/operations/utilities/types.d.ts.map +1 -1
- package/dist/collections/operations/utilities/types.js.map +1 -1
- package/dist/config/client.d.ts +2 -2
- package/dist/config/client.d.ts.map +1 -1
- package/dist/config/client.js.map +1 -1
- package/dist/config/defaults.d.ts +0 -4
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +0 -78
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/definePlugin.d.ts +10 -10
- package/dist/config/definePlugin.d.ts.map +1 -1
- package/dist/config/definePlugin.js +7 -11
- package/dist/config/definePlugin.js.map +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js +137 -13
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/types.d.ts +35 -3
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/exports/internal.d.ts +1 -0
- package/dist/exports/internal.d.ts.map +1 -1
- package/dist/exports/internal.js +1 -0
- package/dist/exports/internal.js.map +1 -1
- package/dist/exports/shared.d.ts +3 -2
- package/dist/exports/shared.d.ts.map +1 -1
- package/dist/exports/shared.js +2 -1
- package/dist/exports/shared.js.map +1 -1
- package/dist/fields/baseFields/slug/countVersions.d.ts.map +1 -1
- package/dist/fields/baseFields/slug/countVersions.js +6 -8
- package/dist/fields/baseFields/slug/countVersions.js.map +1 -1
- package/dist/fields/baseFields/slug/generateSlug.d.ts +14 -7
- package/dist/fields/baseFields/slug/generateSlug.d.ts.map +1 -1
- package/dist/fields/baseFields/slug/generateSlug.js +53 -73
- package/dist/fields/baseFields/slug/generateSlug.js.map +1 -1
- package/dist/fields/baseFields/slug/types.d.ts +14 -0
- package/dist/fields/baseFields/slug/types.d.ts.map +1 -0
- package/dist/fields/baseFields/slug/types.js +6 -0
- package/dist/fields/baseFields/slug/types.js.map +1 -0
- package/dist/fields/config/client.d.ts +1 -1
- package/dist/fields/config/client.d.ts.map +1 -1
- package/dist/fields/config/client.js +2 -1
- package/dist/fields/config/client.js.map +1 -1
- package/dist/fields/config/sanitize.d.ts.map +1 -1
- package/dist/fields/config/sanitize.js +39 -0
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/fields/config/types.d.ts +44 -8
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js +11 -1
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.js +10 -1
- package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
- package/dist/fields/setDefaultBeforeDuplicate.js +1 -0
- package/dist/fields/setDefaultBeforeDuplicate.js.map +1 -1
- package/dist/fields/sortableFieldTypes.d.ts.map +1 -1
- package/dist/fields/sortableFieldTypes.js +1 -0
- package/dist/fields/sortableFieldTypes.js.map +1 -1
- package/dist/fields/validations.d.ts +4 -1
- package/dist/fields/validations.d.ts.map +1 -1
- package/dist/fields/validations.js +7 -0
- package/dist/fields/validations.js.map +1 -1
- package/dist/globals/operations/local/countVersions.d.ts +3 -3
- package/dist/globals/operations/local/countVersions.d.ts.map +1 -1
- package/dist/globals/operations/local/countVersions.js.map +1 -1
- package/dist/globals/operations/local/findOne.d.ts +3 -3
- package/dist/globals/operations/local/findOne.d.ts.map +1 -1
- package/dist/globals/operations/local/findOne.js.map +1 -1
- package/dist/globals/operations/local/findVersionByID.d.ts +3 -3
- package/dist/globals/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersionByID.js.map +1 -1
- package/dist/globals/operations/local/findVersions.d.ts +3 -3
- package/dist/globals/operations/local/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersions.js.map +1 -1
- package/dist/globals/operations/local/restoreVersion.d.ts +3 -3
- package/dist/globals/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/globals/operations/local/restoreVersion.js.map +1 -1
- package/dist/globals/operations/local/update.d.ts +3 -3
- package/dist/globals/operations/local/update.d.ts.map +1 -1
- package/dist/globals/operations/local/update.js.map +1 -1
- package/dist/index.bundled.d.ts +365 -300
- package/dist/index.d.ts +59 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/preferences/keys.d.ts +4 -0
- package/dist/preferences/keys.d.ts.map +1 -1
- package/dist/preferences/keys.js +4 -1
- package/dist/preferences/keys.js.map +1 -1
- package/dist/preferences/types.d.ts +15 -0
- package/dist/preferences/types.d.ts.map +1 -1
- package/dist/preferences/types.js +3 -1
- package/dist/preferences/types.js.map +1 -1
- package/dist/types/index.d.ts +8 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/uploads/fetchAPI-multipart/processMultipart.d.ts.map +1 -1
- package/dist/uploads/fetchAPI-multipart/processMultipart.js +1 -14
- package/dist/uploads/fetchAPI-multipart/processMultipart.js.map +1 -1
- package/dist/uploads/matchMimeType.d.ts +8 -0
- package/dist/uploads/matchMimeType.d.ts.map +1 -0
- package/dist/uploads/matchMimeType.js +19 -0
- package/dist/uploads/matchMimeType.js.map +1 -0
- package/dist/uploads/matchMimeType.spec.js +66 -0
- package/dist/uploads/matchMimeType.spec.js.map +1 -0
- package/dist/uploads/types.d.ts +21 -0
- package/dist/uploads/types.d.ts.map +1 -1
- package/dist/uploads/types.js.map +1 -1
- package/dist/utilities/addDataAndFileToRequest.d.ts.map +1 -1
- package/dist/utilities/addDataAndFileToRequest.js +6 -0
- package/dist/utilities/addDataAndFileToRequest.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts +13 -4
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +139 -61
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/configToJSONSchema.spec.js +319 -0
- package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
- package/dist/utilities/createLocalReq.d.ts +2 -2
- package/dist/utilities/createLocalReq.d.ts.map +1 -1
- package/dist/utilities/createLocalReq.js.map +1 -1
- package/dist/utilities/createPayloadRequest.d.ts.map +1 -1
- package/dist/utilities/createPayloadRequest.js +1 -0
- package/dist/utilities/createPayloadRequest.js.map +1 -1
- package/dist/utilities/getEntityPermissions/getEntityPermissions.d.ts.map +1 -1
- package/dist/utilities/getEntityPermissions/getEntityPermissions.js +2 -0
- package/dist/utilities/getEntityPermissions/getEntityPermissions.js.map +1 -1
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts +7 -1
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts.map +1 -1
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.js +19 -2
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.js.map +1 -1
- package/dist/utilities/isURLAllowed.d.ts.map +1 -1
- package/dist/utilities/isURLAllowed.js +9 -3
- package/dist/utilities/isURLAllowed.js.map +1 -1
- package/dist/utilities/isURLAllowed.spec.js +78 -0
- package/dist/utilities/isURLAllowed.spec.js.map +1 -0
- package/dist/utilities/telemetry/conf/envPaths.d.ts.map +1 -1
- package/dist/utilities/telemetry/conf/envPaths.js +40 -31
- package/dist/utilities/telemetry/conf/envPaths.js.map +1 -1
- package/dist/utilities/telemetry/events/adminInit.d.ts.map +1 -1
- package/dist/utilities/telemetry/events/adminInit.js +2 -3
- package/dist/utilities/telemetry/events/adminInit.js.map +1 -1
- package/dist/utilities/telemetry/events/serverInit.d.ts.map +1 -1
- package/dist/utilities/telemetry/events/serverInit.js +2 -3
- package/dist/utilities/telemetry/events/serverInit.js.map +1 -1
- package/dist/utilities/telemetry/index.d.ts +14 -3
- package/dist/utilities/telemetry/index.d.ts.map +1 -1
- package/dist/utilities/telemetry/index.js +6 -1
- package/dist/utilities/telemetry/index.js.map +1 -1
- package/dist/utilities/telemetry/index.spec.js +43 -0
- package/dist/utilities/telemetry/index.spec.js.map +1 -0
- package/dist/versions/schedule/job.js.map +1 -1
- package/package.json +3 -3
- package/dist/fields/baseFields/slug/index.d.ts +0 -89
- package/dist/fields/baseFields/slug/index.d.ts.map +0 -1
- package/dist/fields/baseFields/slug/index.js +0 -81
- package/dist/fields/baseFields/slug/index.js.map +0 -1
- package/dist/utilities/isRSCEnabled.d.ts +0 -12
- package/dist/utilities/isRSCEnabled.d.ts.map +0 -1
- package/dist/utilities/isRSCEnabled.js +0 -14
- package/dist/utilities/isRSCEnabled.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/auth/strategies/local/incrementLoginAttempts.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\n\nimport { type JsonObject, type Payload, type
|
|
1
|
+
{"version":3,"sources":["../../../../src/auth/strategies/local/incrementLoginAttempts.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\n\nimport { type JsonObject, type Payload, type User } from '../../../index.js'\nimport { isUserLocked } from '../../isUserLocked.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig\n payload: Payload\n user: User\n}\n\n// Note: this function does not use req in its 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 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 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<User>({\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 ?? 0)\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","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":"AAGA,SAASA,YAAY,QAAQ,wBAAuB;AAQpD,mIAAmI;AACnI,4FAA4F;AAC5F,OAAO,MAAMC,yBAAyB,OAAO,EAC3CC,UAAU,EACVC,OAAO,EACPC,IAAI,EACC;IACL,MAAM,EACJC,MAAM,EAAEC,QAAQ,EAAEC,gBAAgB,EAAE,EACrC,GAAGL;IAEJ,MAAMM,cAAcC,KAAKC,GAAG;IAE5B,IAAIC,mBAAkC;IACtC,IAAIC,uBAAsC;IAE1C,IAAIR,KAAKS,SAAS,IAAI,CAACb,aAAa,IAAIS,KAAKL,KAAKS,SAAS,IAAI;QAC7D,mCAAmC;QACnC,MAAMC,cAAc,MAAMX,QAAQY,EAAE,CAACC,SAAS,CAAC;YAC7CC,IAAIb,KAAKa,EAAE;YACXf,YAAYA,WAAWgB,IAAI;YAC3BC,MAAM;gBACJN,WAAW;gBACXO,eAAe;YACjB;YACAC,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,YAAY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AAE,CAACiB,OAAO,CAAO;gBACjD9B,YAAYA,WAAWgB,IAAI;gBAC3BG,QAAQ;oBACNY,UAAU;gBACZ;gBACAC,OAAO;oBACLjB,IAAI;wBACFkB,QAAQ/B,KAAKa,EAAE;oBACjB;gBACF;YACF;YACA,IAAIc,aAAaE,UAAUG,QAAQ;gBACjC,+CAA+C;gBAC/CL,YAAYE,QAAQ,GAAGF,YAAYE,QAAQ,CAACI,MAAM,CAAC,CAACC;oBAClD,MAAMC,mBAAmB,IAAI9B,KAAK6B,QAAQE,SAAS,IAAI;oBACvD,MAAMC,mBAAmB,IAAIhC,KAAKD,cAAc;oBAEhD,qDAAqD;oBACrD,OAAO+B,oBAAoBE;gBAC7B;gBAEArC,KAAK6B,QAAQ,GAAGF,YAAYE,QAAQ;gBAEpC,0CAA0C;gBAC1C7B,KAAKsC,SAAS,GAAG,IAAIjC,OAAOe,WAAW;gBAEvC,MAAMrB,QAAQY,EAAE,CAACC,SAAS,CAAC;oBACzBC,IAAIb,KAAKa,EAAE;oBACXf,YAAYA,WAAWgB,IAAI;oBAC3BC,MAAMf;oBACNyB,WAAW;gBACb;YACF;QACF;IACF;AACF,EAAC"}
|
package/dist/auth/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DeepRequired } from 'ts-essentials';
|
|
2
|
-
import type { CollectionSlug, GlobalSlug, Payload,
|
|
2
|
+
import type { CollectionSlug, GlobalSlug, Payload, User } from '../index.js';
|
|
3
3
|
import type { PayloadRequest, Where } from '../types/index.js';
|
|
4
4
|
/**
|
|
5
5
|
* A permission object that can be used to determine if a user has access to a specific operation.
|
|
@@ -89,28 +89,38 @@ export type SanitizedPermissions = {
|
|
|
89
89
|
[globalSlug: string]: SanitizedGlobalPermission;
|
|
90
90
|
};
|
|
91
91
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Fields injected onto a user at authentication time. They are never stored in the database and
|
|
94
|
+
* never present on a plain document read (e.g. `payload.findByID`) - only on the authenticated
|
|
95
|
+
* user (`req.user`, login/auth/me results, auth strategies).
|
|
96
|
+
*/
|
|
97
|
+
export type AuthRuntimeFields = {
|
|
98
|
+
/**
|
|
99
|
+
* The session ID of the current request. Present only when sessions are enabled.
|
|
100
|
+
*/
|
|
101
|
+
_sid?: string;
|
|
102
|
+
/**
|
|
103
|
+
* The name of the auth strategy that authenticated the request (e.g. `local-jwt`).
|
|
104
|
+
*/
|
|
105
|
+
_strategy?: string;
|
|
98
106
|
};
|
|
99
107
|
/**
|
|
100
|
-
*
|
|
108
|
+
* Note: AuthenticatedUser still carries the write-only `password` from `User` (always `undefined` at runtime).
|
|
109
|
+
* Stripping it cleanly isn't possible, because auth operations build the authenticated user
|
|
110
|
+
* from a read `User` doc, so a `never`-typed `password` would break those assignments
|
|
111
|
+
*/
|
|
112
|
+
/**
|
|
113
|
+
* The signed-in user: the read user plus the runtime auth markers (`_strategy`, `_sid`). This is
|
|
114
|
+
* what `req.user`, `payload.auth()`, the `me` operation, and auth strategies return.
|
|
101
115
|
*/
|
|
102
|
-
export type
|
|
103
|
-
[key: string]: any;
|
|
104
|
-
} & BaseUser;
|
|
116
|
+
export type AuthenticatedUser = AuthRuntimeFields & User;
|
|
105
117
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
118
|
+
* The user as available on the client (`useAuth().user`). It is the authenticated user as
|
|
119
|
+
* serialized to the browser: `collection` and `_strategy` are present, `_sid` is not sent.
|
|
108
120
|
*/
|
|
109
|
-
export type ClientUser =
|
|
110
|
-
[key: string]: any;
|
|
111
|
-
} & BaseUser;
|
|
121
|
+
export type ClientUser = AuthenticatedUser;
|
|
112
122
|
export type UserSession = {
|
|
113
|
-
createdAt
|
|
123
|
+
createdAt?: Date | null | string;
|
|
114
124
|
expiresAt: Date | string;
|
|
115
125
|
id: string;
|
|
116
126
|
};
|
|
@@ -149,10 +159,7 @@ export type AuthStrategyFunctionArgs = {
|
|
|
149
159
|
};
|
|
150
160
|
export type AuthStrategyResult = {
|
|
151
161
|
responseHeaders?: Headers;
|
|
152
|
-
user:
|
|
153
|
-
_strategy?: string;
|
|
154
|
-
collection?: string;
|
|
155
|
-
} & TypedUser) | null;
|
|
162
|
+
user: AuthenticatedUser | null;
|
|
156
163
|
};
|
|
157
164
|
export type AuthStrategyFunction = (args: AuthStrategyFunctionArgs) => AuthStrategyResult | Promise<AuthStrategyResult>;
|
|
158
165
|
export type AuthStrategy = {
|
package/dist/auth/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/auth/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/auth/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE9D;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,UAAU,EAAE,OAAO,CAAA;IACnB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAAA;CACtC,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,UAAU,CAAA;IAClB,MAAM,EAAE,iBAAiB,CAAA;IACzB,IAAI,EAAE,UAAU,CAAA;IAChB,MAAM,EAAE,UAAU,C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AAE,kCAAkC,CAAA;KAC1D,CAAA;IACD,iBAAiB,EAAE,KAAK,GAAG,wBAAwB,CAAA;IACnD,MAAM,CAAC,EAAE,OAAO,GAAG,YAAY,CAAA;CAChC;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,IAAI,KAAK,CAE7E"}
|
package/dist/auth/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/auth/types.ts"],"sourcesContent":["import type { DeepRequired } from 'ts-essentials'\n\nimport type { CollectionSlug, GlobalSlug, Payload, TypedUser } from '../index.js'\nimport type { PayloadRequest, Where } from '../types/index.js'\n\n/**\n * A permission object that can be used to determine if a user has access to a specific operation.\n */\nexport type Permission = {\n permission: boolean\n where?: Where\n}\n\nexport type FieldsPermissions = {\n [fieldName: string]: FieldPermissions\n}\n\nexport type BlockPermissions = {\n create: Permission\n fields: FieldsPermissions\n read: Permission\n update: Permission\n}\n\nexport type SanitizedBlockPermissions =\n | {\n fields: SanitizedFieldsPermissions\n }\n | true\n\nexport type BlocksPermissions = {\n [blockSlug: string]: BlockPermissions\n}\n\nexport type SanitizedBlocksPermissions =\n | {\n [blockSlug: string]: SanitizedBlockPermissions\n }\n | true\n\nexport type FieldPermissions = {\n blocks?: BlocksPermissions\n create?: Permission\n fields?: FieldsPermissions\n read?: Permission\n update?: Permission\n}\n\nexport type SanitizedFieldPermissions =\n | {\n blocks?: SanitizedBlocksPermissions\n create: true\n fields?: SanitizedFieldsPermissions\n read: true\n update: true\n }\n | true\n\nexport type SanitizedFieldsPermissions =\n | {\n [fieldName: string]: SanitizedFieldPermissions\n }\n | true\n\nexport type CollectionPermission = {\n create?: Permission\n delete?: Permission\n fields: FieldsPermissions\n read?: Permission\n readVersions?: Permission\n // Auth-enabled Collections only\n unlock?: Permission\n update?: Permission\n}\n\nexport type SanitizedCollectionPermission = {\n create?: true\n delete?: true\n fields: SanitizedFieldsPermissions\n read?: true\n readVersions?: true\n // Auth-enabled Collections only\n unlock?: true\n update?: true\n}\n\nexport type GlobalPermission = {\n fields: FieldsPermissions\n read?: Permission\n readVersions?: Permission\n update?: Permission\n}\n\nexport type SanitizedGlobalPermission = {\n fields: SanitizedFieldsPermissions\n read?: true\n readVersions?: true\n update?: true\n}\n\nexport type DocumentPermissions = CollectionPermission | GlobalPermission\n\nexport type SanitizedDocumentPermissions = SanitizedCollectionPermission | SanitizedGlobalPermission\n\nexport type Permissions = {\n canAccessAdmin: boolean\n collections?: Record<CollectionSlug, CollectionPermission>\n globals?: Record<GlobalSlug, GlobalPermission>\n}\n\nexport type SanitizedPermissions = {\n canAccessAdmin?: boolean\n collections?: {\n [collectionSlug: string]: SanitizedCollectionPermission\n }\n globals?: {\n [globalSlug: string]: SanitizedGlobalPermission\n }\n}\n\ntype BaseUser = {\n collection: string\n email?: string\n id: number | string\n sessions?: Array<UserSession>\n username?: string\n}\n\n/**\n * @deprecated Use `TypedUser` instead. This will be removed in 4.0.\n */\nexport type UntypedUser = {\n [key: string]: any\n} & BaseUser\n\n/**\n * `collection` is not available one the client. It's only available on the server (req.user)\n * On the client, you can access the collection via config.admin.user. Config can be accessed using the useConfig() hook\n */\nexport type ClientUser = {\n [key: string]: any\n} & BaseUser\n\nexport type UserSession = { createdAt: Date | string; expiresAt: Date | string; id: string }\ntype GenerateVerifyEmailHTML<TUser = any> = (args: {\n req: PayloadRequest\n token: string\n user: TUser\n}) => Promise<string> | string\n\ntype GenerateVerifyEmailSubject<TUser = any> = (args: {\n req: PayloadRequest\n token: string\n user: TUser\n}) => Promise<string> | string\n\ntype GenerateForgotPasswordEmailHTML<TUser = any> = (args?: {\n req?: PayloadRequest\n token?: string\n user?: TUser\n}) => Promise<string> | string\n\ntype GenerateForgotPasswordEmailSubject<TUser = any> = (args?: {\n req?: PayloadRequest\n token?: string\n user?: TUser\n}) => Promise<string> | string\n\nexport type AuthStrategyFunctionArgs = {\n /**\n * Specifies whether or not response headers can be set from this strategy.\n */\n canSetHeaders?: boolean\n headers: Request['headers']\n isGraphQL?: boolean\n payload: Payload\n /**\n * The AuthStrategy name property from the payload config.\n */\n strategyName?: string\n}\n\nexport type AuthStrategyResult = {\n responseHeaders?: Headers\n user:\n | ({\n _strategy?: string\n collection?: string\n } & TypedUser)\n | null\n}\n\nexport type AuthStrategyFunction = (\n args: AuthStrategyFunctionArgs,\n) => AuthStrategyResult | Promise<AuthStrategyResult>\nexport type AuthStrategy = {\n authenticate: AuthStrategyFunction\n name: string\n}\n\nexport type LoginWithUsernameOptions =\n | {\n allowEmailLogin?: false\n requireEmail?: boolean\n // If `allowEmailLogin` is false, `requireUsername` must be true (default: true)\n requireUsername?: true\n }\n | {\n allowEmailLogin?: true\n requireEmail?: boolean\n requireUsername?: boolean\n }\n\nexport interface IncomingAuthType {\n /**\n * Set cookie options, including secure, sameSite, and domain. For advanced users.\n */\n cookies?: {\n domain?: string\n sameSite?: 'Lax' | 'None' | 'Strict' | boolean\n secure?: boolean\n }\n /**\n * How many levels deep a user document should be populated when creating the JWT and binding the user to the req. Defaults to 0 and should only be modified if absolutely necessary, as this will affect performance.\n * @default 0\n */\n depth?: number\n /**\n * Advanced - disable Payload's built-in local auth strategy. Only use this property if you have replaced Payload's auth mechanisms with your own.\n */\n disableLocalStrategy?:\n | {\n /**\n * Include auth fields on the collection even though the local strategy is disabled.\n * Useful when you do not want the database or types to vary depending on the auth configuration.\n */\n enableFields?: true\n optionalPassword?: true\n }\n | true\n /**\n * Customize the way that the forgotPassword operation functions.\n * @link https://payloadcms.com/docs/authentication/email#forgot-password\n */\n forgotPassword?: {\n /**\n * The number of milliseconds that the forgot password token should be valid for.\n * @default 3600000 // 1 hour\n */\n expiration?: number\n generateEmailHTML?: GenerateForgotPasswordEmailHTML\n generateEmailSubject?: GenerateForgotPasswordEmailSubject\n }\n /**\n * Set the time (in milliseconds) that a user should be locked out if they fail authentication more times than maxLoginAttempts allows for.\n */\n lockTime?: number\n /**\n * Ability to allow users to login with username/password.\n *\n * @link https://payloadcms.com/docs/authentication/overview#login-with-username\n */\n loginWithUsername?: boolean | LoginWithUsernameOptions\n /**\n * Only allow a user to attempt logging in X amount of times. Automatically locks out a user from authenticating if this limit is passed. Set to 0 to disable.\n */\n maxLoginAttempts?: number\n /***\n * Set to true if you want to remove the token from the returned authentication API responses such as login or refresh.\n */\n removeTokenFromResponses?: true\n /**\n * Advanced - an array of custom authentification strategies to extend this collection's authentication with.\n * @link https://payloadcms.com/docs/authentication/custom-strategies\n */\n strategies?: AuthStrategy[]\n /**\n * Controls how many seconds the token will be valid for. Default is 2 hours.\n * @default 7200\n * @link https://payloadcms.com/docs/authentication/overview#config-options\n */\n tokenExpiration?: number\n /**\n * Payload Authentication provides for API keys to be set on each user within an Authentication-enabled Collection.\n * @default false\n * @link https://payloadcms.com/docs/authentication/api-keys\n */\n useAPIKey?: boolean\n\n /**\n * Use sessions for authentication. Enabled by default.\n * @default true\n */\n useSessions?: boolean\n\n /**\n * Set to true or pass an object with verification options to require users to verify by email before they are allowed to log into your app.\n * @link https://payloadcms.com/docs/authentication/email#email-verification\n */\n verify?:\n | {\n generateEmailHTML?: GenerateVerifyEmailHTML\n generateEmailSubject?: GenerateVerifyEmailSubject\n }\n | boolean\n}\n\nexport type VerifyConfig = {\n generateEmailHTML?: GenerateVerifyEmailHTML\n generateEmailSubject?: GenerateVerifyEmailSubject\n}\n\nexport interface Auth\n extends Omit<DeepRequired<IncomingAuthType>, 'forgotPassword' | 'loginWithUsername' | 'verify'> {\n forgotPassword?: {\n expiration?: number\n generateEmailHTML?: GenerateForgotPasswordEmailHTML\n generateEmailSubject?: GenerateForgotPasswordEmailSubject\n }\n loginWithUsername: false | LoginWithUsernameOptions\n verify?: boolean | VerifyConfig\n}\n\nexport function hasWhereAccessResult(result: boolean | Where): result is Where {\n return result && typeof result === 'object'\n}\n"],"names":["hasWhereAccessResult","result"],"mappings":"AAmUA,OAAO,SAASA,qBAAqBC,MAAuB;IAC1D,OAAOA,UAAU,OAAOA,WAAW;AACrC"}
|
|
1
|
+
{"version":3,"sources":["../../src/auth/types.ts"],"sourcesContent":["import type { DeepRequired } from 'ts-essentials'\n\nimport type { CollectionSlug, GlobalSlug, Payload, User } from '../index.js'\nimport type { PayloadRequest, Where } from '../types/index.js'\n\n/**\n * A permission object that can be used to determine if a user has access to a specific operation.\n */\nexport type Permission = {\n permission: boolean\n where?: Where\n}\n\nexport type FieldsPermissions = {\n [fieldName: string]: FieldPermissions\n}\n\nexport type BlockPermissions = {\n create: Permission\n fields: FieldsPermissions\n read: Permission\n update: Permission\n}\n\nexport type SanitizedBlockPermissions =\n | {\n fields: SanitizedFieldsPermissions\n }\n | true\n\nexport type BlocksPermissions = {\n [blockSlug: string]: BlockPermissions\n}\n\nexport type SanitizedBlocksPermissions =\n | {\n [blockSlug: string]: SanitizedBlockPermissions\n }\n | true\n\nexport type FieldPermissions = {\n blocks?: BlocksPermissions\n create?: Permission\n fields?: FieldsPermissions\n read?: Permission\n update?: Permission\n}\n\nexport type SanitizedFieldPermissions =\n | {\n blocks?: SanitizedBlocksPermissions\n create: true\n fields?: SanitizedFieldsPermissions\n read: true\n update: true\n }\n | true\n\nexport type SanitizedFieldsPermissions =\n | {\n [fieldName: string]: SanitizedFieldPermissions\n }\n | true\n\nexport type CollectionPermission = {\n create?: Permission\n delete?: Permission\n fields: FieldsPermissions\n read?: Permission\n readVersions?: Permission\n // Auth-enabled Collections only\n unlock?: Permission\n update?: Permission\n}\n\nexport type SanitizedCollectionPermission = {\n create?: true\n delete?: true\n fields: SanitizedFieldsPermissions\n read?: true\n readVersions?: true\n // Auth-enabled Collections only\n unlock?: true\n update?: true\n}\n\nexport type GlobalPermission = {\n fields: FieldsPermissions\n read?: Permission\n readVersions?: Permission\n update?: Permission\n}\n\nexport type SanitizedGlobalPermission = {\n fields: SanitizedFieldsPermissions\n read?: true\n readVersions?: true\n update?: true\n}\n\nexport type DocumentPermissions = CollectionPermission | GlobalPermission\n\nexport type SanitizedDocumentPermissions = SanitizedCollectionPermission | SanitizedGlobalPermission\n\nexport type Permissions = {\n canAccessAdmin: boolean\n collections?: Record<CollectionSlug, CollectionPermission>\n globals?: Record<GlobalSlug, GlobalPermission>\n}\n\nexport type SanitizedPermissions = {\n canAccessAdmin?: boolean\n collections?: {\n [collectionSlug: string]: SanitizedCollectionPermission\n }\n globals?: {\n [globalSlug: string]: SanitizedGlobalPermission\n }\n}\n\n/**\n * Fields injected onto a user at authentication time. They are never stored in the database and\n * never present on a plain document read (e.g. `payload.findByID`) - only on the authenticated\n * user (`req.user`, login/auth/me results, auth strategies).\n */\nexport type AuthRuntimeFields = {\n /**\n * The session ID of the current request. Present only when sessions are enabled.\n */\n _sid?: string\n /**\n * The name of the auth strategy that authenticated the request (e.g. `local-jwt`).\n */\n _strategy?: string\n}\n\n/**\n * Note: AuthenticatedUser still carries the write-only `password` from `User` (always `undefined` at runtime).\n * Stripping it cleanly isn't possible, because auth operations build the authenticated user\n * from a read `User` doc, so a `never`-typed `password` would break those assignments\n */\n/**\n * The signed-in user: the read user plus the runtime auth markers (`_strategy`, `_sid`). This is\n * what `req.user`, `payload.auth()`, the `me` operation, and auth strategies return.\n */\nexport type AuthenticatedUser = AuthRuntimeFields & User\n\n/**\n * The user as available on the client (`useAuth().user`). It is the authenticated user as\n * serialized to the browser: `collection` and `_strategy` are present, `_sid` is not sent.\n */\nexport type ClientUser = AuthenticatedUser\n\nexport type UserSession = {\n createdAt?: Date | null | string\n expiresAt: Date | string\n id: string\n}\ntype GenerateVerifyEmailHTML<TUser = any> = (args: {\n req: PayloadRequest\n token: string\n user: TUser\n}) => Promise<string> | string\n\ntype GenerateVerifyEmailSubject<TUser = any> = (args: {\n req: PayloadRequest\n token: string\n user: TUser\n}) => Promise<string> | string\n\ntype GenerateForgotPasswordEmailHTML<TUser = any> = (args?: {\n req?: PayloadRequest\n token?: string\n user?: TUser\n}) => Promise<string> | string\n\ntype GenerateForgotPasswordEmailSubject<TUser = any> = (args?: {\n req?: PayloadRequest\n token?: string\n user?: TUser\n}) => Promise<string> | string\n\nexport type AuthStrategyFunctionArgs = {\n /**\n * Specifies whether or not response headers can be set from this strategy.\n */\n canSetHeaders?: boolean\n headers: Request['headers']\n isGraphQL?: boolean\n payload: Payload\n /**\n * The AuthStrategy name property from the payload config.\n */\n strategyName?: string\n}\n\nexport type AuthStrategyResult = {\n responseHeaders?: Headers\n user: AuthenticatedUser | null\n}\n\nexport type AuthStrategyFunction = (\n args: AuthStrategyFunctionArgs,\n) => AuthStrategyResult | Promise<AuthStrategyResult>\nexport type AuthStrategy = {\n authenticate: AuthStrategyFunction\n name: string\n}\n\nexport type LoginWithUsernameOptions =\n | {\n allowEmailLogin?: false\n requireEmail?: boolean\n // If `allowEmailLogin` is false, `requireUsername` must be true (default: true)\n requireUsername?: true\n }\n | {\n allowEmailLogin?: true\n requireEmail?: boolean\n requireUsername?: boolean\n }\n\nexport interface IncomingAuthType {\n /**\n * Set cookie options, including secure, sameSite, and domain. For advanced users.\n */\n cookies?: {\n domain?: string\n sameSite?: 'Lax' | 'None' | 'Strict' | boolean\n secure?: boolean\n }\n /**\n * How many levels deep a user document should be populated when creating the JWT and binding the user to the req. Defaults to 0 and should only be modified if absolutely necessary, as this will affect performance.\n * @default 0\n */\n depth?: number\n /**\n * Advanced - disable Payload's built-in local auth strategy. Only use this property if you have replaced Payload's auth mechanisms with your own.\n */\n disableLocalStrategy?:\n | {\n /**\n * Include auth fields on the collection even though the local strategy is disabled.\n * Useful when you do not want the database or types to vary depending on the auth configuration.\n */\n enableFields?: true\n optionalPassword?: true\n }\n | true\n /**\n * Customize the way that the forgotPassword operation functions.\n * @link https://payloadcms.com/docs/authentication/email#forgot-password\n */\n forgotPassword?: {\n /**\n * The number of milliseconds that the forgot password token should be valid for.\n * @default 3600000 // 1 hour\n */\n expiration?: number\n generateEmailHTML?: GenerateForgotPasswordEmailHTML\n generateEmailSubject?: GenerateForgotPasswordEmailSubject\n }\n /**\n * Set the time (in milliseconds) that a user should be locked out if they fail authentication more times than maxLoginAttempts allows for.\n */\n lockTime?: number\n /**\n * Ability to allow users to login with username/password.\n *\n * @link https://payloadcms.com/docs/authentication/overview#login-with-username\n */\n loginWithUsername?: boolean | LoginWithUsernameOptions\n /**\n * Only allow a user to attempt logging in X amount of times. Automatically locks out a user from authenticating if this limit is passed. Set to 0 to disable.\n */\n maxLoginAttempts?: number\n /***\n * Set to true if you want to remove the token from the returned authentication API responses such as login or refresh.\n */\n removeTokenFromResponses?: true\n /**\n * Advanced - an array of custom authentification strategies to extend this collection's authentication with.\n * @link https://payloadcms.com/docs/authentication/custom-strategies\n */\n strategies?: AuthStrategy[]\n /**\n * Controls how many seconds the token will be valid for. Default is 2 hours.\n * @default 7200\n * @link https://payloadcms.com/docs/authentication/overview#config-options\n */\n tokenExpiration?: number\n /**\n * Payload Authentication provides for API keys to be set on each user within an Authentication-enabled Collection.\n * @default false\n * @link https://payloadcms.com/docs/authentication/api-keys\n */\n useAPIKey?: boolean\n\n /**\n * Use sessions for authentication. Enabled by default.\n * @default true\n */\n useSessions?: boolean\n\n /**\n * Set to true or pass an object with verification options to require users to verify by email before they are allowed to log into your app.\n * @link https://payloadcms.com/docs/authentication/email#email-verification\n */\n verify?:\n | {\n generateEmailHTML?: GenerateVerifyEmailHTML\n generateEmailSubject?: GenerateVerifyEmailSubject\n }\n | boolean\n}\n\nexport type VerifyConfig = {\n generateEmailHTML?: GenerateVerifyEmailHTML\n generateEmailSubject?: GenerateVerifyEmailSubject\n}\n\nexport interface Auth\n extends Omit<DeepRequired<IncomingAuthType>, 'forgotPassword' | 'loginWithUsername' | 'verify'> {\n forgotPassword?: {\n expiration?: number\n generateEmailHTML?: GenerateForgotPasswordEmailHTML\n generateEmailSubject?: GenerateForgotPasswordEmailSubject\n }\n loginWithUsername: false | LoginWithUsernameOptions\n verify?: boolean | VerifyConfig\n}\n\nexport function hasWhereAccessResult(result: boolean | Where): result is Where {\n return result && typeof result === 'object'\n}\n"],"names":["hasWhereAccessResult","result"],"mappings":"AA4UA,OAAO,SAASA,qBAAqBC,MAAuB;IAC1D,OAAOA,UAAU,OAAOA,WAAW;AACrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iterateCollections.d.ts","sourceRoot":"","sources":["../../../src/bin/generateImportMap/iterateCollections.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAA;AAClF,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"iterateCollections.d.ts","sourceRoot":"","sources":["../../../src/bin/generateImportMap/iterateCollections.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAA;AAClF,OAAO,KAAK,EAAoB,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAI5E,wBAAgB,kBAAkB,CAAC,EACjC,cAAc,EACd,OAAO,EACP,WAAW,EACX,MAAM,EACN,SAAS,EACT,OAAO,GACR,EAAE;IACD,cAAc,EAAE,cAAc,CAAA;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,yBAAyB,EAAE,CAAA;IACxC,MAAM,EAAE,eAAe,CAAA;IACvB,SAAS,EAAE,iBAAiB,CAAA;IAC5B,OAAO,EAAE,OAAO,CAAA;CACjB,QAgFA"}
|
|
@@ -28,6 +28,16 @@ export function iterateCollections({ addToImportMap, baseDir, collections, confi
|
|
|
28
28
|
if (collection.upload?.admin?.components?.controls) {
|
|
29
29
|
addToImportMap(collection.upload?.admin?.components?.controls);
|
|
30
30
|
}
|
|
31
|
+
const filePreview = collection.upload?.admin?.components?.filePreview;
|
|
32
|
+
if (filePreview) {
|
|
33
|
+
if (typeof filePreview === 'string' || typeof filePreview === 'object' && 'path' in filePreview) {
|
|
34
|
+
addToImportMap(filePreview);
|
|
35
|
+
} else {
|
|
36
|
+
for (const component of Object.values(filePreview)){
|
|
37
|
+
addToImportMap(component);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
31
41
|
if (collection.admin?.components?.views?.edit) {
|
|
32
42
|
for (const editViewConfig of Object.values(collection.admin?.components?.views?.edit)){
|
|
33
43
|
if ('Component' in editViewConfig) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/bin/generateImportMap/iterateCollections.ts"],"sourcesContent":["import type { AdminViewConfig } from '../../admin/views/index.js'\nimport type { SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type { SanitizedConfig } from '../../config/types.js'\nimport type { AddToImportMap, Imports, InternalImportMap } from './index.js'\n\nimport { genImportMapIterateFields } from './iterateFields.js'\n\nexport function iterateCollections({\n addToImportMap,\n baseDir,\n collections,\n config,\n importMap,\n imports,\n}: {\n addToImportMap: AddToImportMap\n baseDir: string\n collections: SanitizedCollectionConfig[]\n config: SanitizedConfig\n importMap: InternalImportMap\n imports: Imports\n}) {\n for (const collection of collections) {\n genImportMapIterateFields({\n addToImportMap,\n baseDir,\n config,\n fields: collection.fields,\n importMap,\n imports,\n })\n\n addToImportMap(collection.admin?.components?.afterList)\n addToImportMap(collection.admin?.components?.listMenuItems)\n addToImportMap(collection.admin?.components?.afterListTable)\n addToImportMap(collection.admin?.components?.beforeList)\n addToImportMap(collection.admin?.components?.beforeListTable)\n addToImportMap(collection.admin?.components?.Description)\n\n addToImportMap(collection.admin?.components?.edit?.beforeDocumentControls)\n addToImportMap(collection.admin?.components?.edit?.BeforeDocumentMeta)\n addToImportMap(collection.admin?.components?.edit?.editMenuItems)\n addToImportMap(collection.admin?.components?.edit?.PreviewButton)\n addToImportMap(collection.admin?.components?.edit?.PublishButton)\n addToImportMap(collection.admin?.components?.edit?.SaveButton)\n addToImportMap(collection.admin?.components?.edit?.SaveDraftButton)\n addToImportMap(collection.admin?.components?.edit?.Status)\n addToImportMap(collection.admin?.components?.edit?.UnpublishButton)\n addToImportMap(collection.admin?.components?.edit?.Upload)\n\n if (collection.upload?.admin?.components?.controls) {\n addToImportMap(collection.upload?.admin?.components?.controls)\n }\n\n if (collection.admin?.components?.views?.edit) {\n for (const editViewConfig of Object.values(collection.admin?.components?.views?.edit)) {\n if ('Component' in editViewConfig) {\n addToImportMap(editViewConfig?.Component)\n }\n\n if ('actions' in editViewConfig) {\n addToImportMap(editViewConfig?.actions)\n }\n\n if ('tab' in editViewConfig) {\n addToImportMap(editViewConfig?.tab?.Component)\n addToImportMap(editViewConfig?.tab?.Pill)\n }\n }\n }\n\n addToImportMap(collection.admin?.components?.views?.list?.Component)\n addToImportMap(collection.admin?.components?.views?.list?.actions)\n addToImportMap(collection.admin?.components?.views?.list?.NoResults)\n\n // Register custom collection view components (any key other than 'edit' and 'list')\n if (collection.admin?.components?.views) {\n for (const [key, view] of Object.entries(collection.admin.components.views)) {\n if (key === 'edit' || key === 'list') {\n continue\n }\n if (view && typeof view === 'object' && 'Component' in view && 'path' in view) {\n addToImportMap((view as AdminViewConfig).Component)\n }\n }\n }\n }\n}\n"],"names":["genImportMapIterateFields","iterateCollections","addToImportMap","baseDir","collections","config","importMap","imports","collection","fields","admin","components","afterList","listMenuItems","afterListTable","beforeList","beforeListTable","Description","edit","beforeDocumentControls","BeforeDocumentMeta","editMenuItems","PreviewButton","PublishButton","SaveButton","SaveDraftButton","Status","UnpublishButton","Upload","upload","controls","
|
|
1
|
+
{"version":3,"sources":["../../../src/bin/generateImportMap/iterateCollections.ts"],"sourcesContent":["import type { AdminViewConfig } from '../../admin/views/index.js'\nimport type { SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type { PayloadComponent, SanitizedConfig } from '../../config/types.js'\nimport type { AddToImportMap, Imports, InternalImportMap } from './index.js'\n\nimport { genImportMapIterateFields } from './iterateFields.js'\n\nexport function iterateCollections({\n addToImportMap,\n baseDir,\n collections,\n config,\n importMap,\n imports,\n}: {\n addToImportMap: AddToImportMap\n baseDir: string\n collections: SanitizedCollectionConfig[]\n config: SanitizedConfig\n importMap: InternalImportMap\n imports: Imports\n}) {\n for (const collection of collections) {\n genImportMapIterateFields({\n addToImportMap,\n baseDir,\n config,\n fields: collection.fields,\n importMap,\n imports,\n })\n\n addToImportMap(collection.admin?.components?.afterList)\n addToImportMap(collection.admin?.components?.listMenuItems)\n addToImportMap(collection.admin?.components?.afterListTable)\n addToImportMap(collection.admin?.components?.beforeList)\n addToImportMap(collection.admin?.components?.beforeListTable)\n addToImportMap(collection.admin?.components?.Description)\n\n addToImportMap(collection.admin?.components?.edit?.beforeDocumentControls)\n addToImportMap(collection.admin?.components?.edit?.BeforeDocumentMeta)\n addToImportMap(collection.admin?.components?.edit?.editMenuItems)\n addToImportMap(collection.admin?.components?.edit?.PreviewButton)\n addToImportMap(collection.admin?.components?.edit?.PublishButton)\n addToImportMap(collection.admin?.components?.edit?.SaveButton)\n addToImportMap(collection.admin?.components?.edit?.SaveDraftButton)\n addToImportMap(collection.admin?.components?.edit?.Status)\n addToImportMap(collection.admin?.components?.edit?.UnpublishButton)\n addToImportMap(collection.admin?.components?.edit?.Upload)\n\n if (collection.upload?.admin?.components?.controls) {\n addToImportMap(collection.upload?.admin?.components?.controls)\n }\n\n const filePreview = collection.upload?.admin?.components?.filePreview\n if (filePreview) {\n if (\n typeof filePreview === 'string' ||\n (typeof filePreview === 'object' && 'path' in filePreview)\n ) {\n addToImportMap(filePreview as PayloadComponent)\n } else {\n for (const component of Object.values(filePreview as Record<string, PayloadComponent>)) {\n addToImportMap(component)\n }\n }\n }\n\n if (collection.admin?.components?.views?.edit) {\n for (const editViewConfig of Object.values(collection.admin?.components?.views?.edit)) {\n if ('Component' in editViewConfig) {\n addToImportMap(editViewConfig?.Component)\n }\n\n if ('actions' in editViewConfig) {\n addToImportMap(editViewConfig?.actions)\n }\n\n if ('tab' in editViewConfig) {\n addToImportMap(editViewConfig?.tab?.Component)\n addToImportMap(editViewConfig?.tab?.Pill)\n }\n }\n }\n\n addToImportMap(collection.admin?.components?.views?.list?.Component)\n addToImportMap(collection.admin?.components?.views?.list?.actions)\n addToImportMap(collection.admin?.components?.views?.list?.NoResults)\n\n // Register custom collection view components (any key other than 'edit' and 'list')\n if (collection.admin?.components?.views) {\n for (const [key, view] of Object.entries(collection.admin.components.views)) {\n if (key === 'edit' || key === 'list') {\n continue\n }\n if (view && typeof view === 'object' && 'Component' in view && 'path' in view) {\n addToImportMap((view as AdminViewConfig).Component)\n }\n }\n }\n }\n}\n"],"names":["genImportMapIterateFields","iterateCollections","addToImportMap","baseDir","collections","config","importMap","imports","collection","fields","admin","components","afterList","listMenuItems","afterListTable","beforeList","beforeListTable","Description","edit","beforeDocumentControls","BeforeDocumentMeta","editMenuItems","PreviewButton","PublishButton","SaveButton","SaveDraftButton","Status","UnpublishButton","Upload","upload","controls","filePreview","component","Object","values","views","editViewConfig","Component","actions","tab","Pill","list","NoResults","key","view","entries"],"mappings":"AAKA,SAASA,yBAAyB,QAAQ,qBAAoB;AAE9D,OAAO,SAASC,mBAAmB,EACjCC,cAAc,EACdC,OAAO,EACPC,WAAW,EACXC,MAAM,EACNC,SAAS,EACTC,OAAO,EAQR;IACC,KAAK,MAAMC,cAAcJ,YAAa;QACpCJ,0BAA0B;YACxBE;YACAC;YACAE;YACAI,QAAQD,WAAWC,MAAM;YACzBH;YACAC;QACF;QAEAL,eAAeM,WAAWE,KAAK,EAAEC,YAAYC;QAC7CV,eAAeM,WAAWE,KAAK,EAAEC,YAAYE;QAC7CX,eAAeM,WAAWE,KAAK,EAAEC,YAAYG;QAC7CZ,eAAeM,WAAWE,KAAK,EAAEC,YAAYI;QAC7Cb,eAAeM,WAAWE,KAAK,EAAEC,YAAYK;QAC7Cd,eAAeM,WAAWE,KAAK,EAAEC,YAAYM;QAE7Cf,eAAeM,WAAWE,KAAK,EAAEC,YAAYO,MAAMC;QACnDjB,eAAeM,WAAWE,KAAK,EAAEC,YAAYO,MAAME;QACnDlB,eAAeM,WAAWE,KAAK,EAAEC,YAAYO,MAAMG;QACn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B,OAAOM,MAAMH;QAC1DpC,eAAeM,WAAWE,KAAK,EAAEC,YAAYwB,OAAOM,MAAMC;QAE1D,oFAAoF;QACpF,IAAIlC,WAAWE,KAAK,EAAEC,YAAYwB,OAAO;YACvC,KAAK,MAAM,CAACQ,KAAKC,KAAK,IAAIX,OAAOY,OAAO,CAACrC,WAAWE,KAAK,CAACC,UAAU,CAACwB,KAAK,EAAG;gBAC3E,IAAIQ,QAAQ,UAAUA,QAAQ,QAAQ;oBACpC;gBACF;gBACA,IAAIC,QAAQ,OAAOA,SAAS,YAAY,eAAeA,QAAQ,UAAUA,MAAM;oBAC7E1C,eAAe,AAAC0C,KAAyBP,SAAS;gBACpD;YACF;QACF;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveImportMapFilePath.d.ts","sourceRoot":"","sources":["../../../../src/bin/generateImportMap/utilities/resolveImportMapFilePath.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolveImportMapFilePath.d.ts","sourceRoot":"","sources":["../../../../src/bin/generateImportMap/utilities/resolveImportMapFilePath.ts"],"names":[],"mappings":"AA6BA;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAAC,EAC7C,UAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,OAAO,GACR,EAAE;IACD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;CAChB,GAAG,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,CAkC1B"}
|
|
@@ -9,11 +9,19 @@ async function pathOrFileExists(path) {
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* Default directory patterns for
|
|
13
|
-
*
|
|
12
|
+
* Default directory patterns for import map resolution, covering the supported
|
|
13
|
+
* framework conventions. Directories are probed in order and the first existing
|
|
14
|
+
* one wins; the conventions are mutually exclusive in practice, so a Next.js app
|
|
15
|
+
* never matches the TanStack patterns and vice versa.
|
|
16
|
+
*
|
|
17
|
+
* Adapters with a bespoke layout can still bypass this via `candidateDirectories`.
|
|
14
18
|
*/ const defaultCandidateDirectories = (rootDir, adminRoute)=>[
|
|
19
|
+
// Next.js App Router: `(payload)` route group nested under the admin route
|
|
15
20
|
path.resolve(rootDir, `app/(payload)${adminRoute}/`),
|
|
16
|
-
path.resolve(rootDir, `src/app/(payload)${adminRoute}/`)
|
|
21
|
+
path.resolve(rootDir, `src/app/(payload)${adminRoute}/`),
|
|
22
|
+
// TanStack Start: `_payload` pathless route folder at the app root
|
|
23
|
+
path.resolve(rootDir, `app/_payload/`),
|
|
24
|
+
path.resolve(rootDir, `src/app/_payload/`)
|
|
17
25
|
];
|
|
18
26
|
/**
|
|
19
27
|
* Returns the path to the import map file. If the import map file is not found, it throws an error.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/bin/generateImportMap/utilities/resolveImportMapFilePath.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport path from 'path'\n\nasync function pathOrFileExists(path: string): Promise<boolean> {\n try {\n await fs.access(path)\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Default directory patterns for Next.js
|
|
1
|
+
{"version":3,"sources":["../../../../src/bin/generateImportMap/utilities/resolveImportMapFilePath.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport path from 'path'\n\nasync function pathOrFileExists(path: string): Promise<boolean> {\n try {\n await fs.access(path)\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Default directory patterns for import map resolution, covering the supported\n * framework conventions. Directories are probed in order and the first existing\n * one wins; the conventions are mutually exclusive in practice, so a Next.js app\n * never matches the TanStack patterns and vice versa.\n *\n * Adapters with a bespoke layout can still bypass this via `candidateDirectories`.\n */\nconst defaultCandidateDirectories = (rootDir: string, adminRoute: string): string[] => [\n // Next.js App Router: `(payload)` route group nested under the admin route\n path.resolve(rootDir, `app/(payload)${adminRoute}/`),\n path.resolve(rootDir, `src/app/(payload)${adminRoute}/`),\n // TanStack Start: `_payload` pathless route folder at the app root\n path.resolve(rootDir, `app/_payload/`),\n path.resolve(rootDir, `src/app/_payload/`),\n]\n\n/**\n * Returns the path to the import map file. If the import map file is not found, it throws an error.\n *\n * @param candidateDirectories - Optional array of directory paths to search for the import map.\n * Defaults to Next.js app directory convention. Framework adapters can provide their own.\n */\nexport async function resolveImportMapFilePath({\n adminRoute = '/admin',\n candidateDirectories,\n importMapFile,\n rootDir,\n}: {\n adminRoute?: string\n candidateDirectories?: string[]\n importMapFile?: string\n rootDir: string\n}): Promise<Error | string> {\n let importMapFilePath: string | undefined = undefined\n\n if (importMapFile?.length) {\n if (!(await pathOrFileExists(importMapFile))) {\n try {\n await fs.writeFile(importMapFile, '', { flag: 'wx' })\n } catch (err) {\n return new Error(\n `Could not find the import map file at ${importMapFile}${err instanceof Error && err?.message ? `: ${err.message}` : ''}`,\n )\n }\n }\n importMapFilePath = importMapFile\n } else {\n const directories = candidateDirectories ?? defaultCandidateDirectories(rootDir, adminRoute)\n\n for (const dir of directories) {\n if (await pathOrFileExists(dir)) {\n importMapFilePath = path.resolve(dir, 'importMap.js')\n if (!(await pathOrFileExists(importMapFilePath))) {\n await fs.writeFile(importMapFilePath, '', { flag: 'wx' })\n }\n break\n }\n }\n\n if (!importMapFilePath) {\n return new Error(\n `Could not find Payload import map folder. Looked in ${directories.join(' and ')}`,\n )\n }\n }\n return importMapFilePath\n}\n"],"names":["fs","path","pathOrFileExists","access","defaultCandidateDirectories","rootDir","adminRoute","resolve","resolveImportMapFilePath","candidateDirectories","importMapFile","importMapFilePath","undefined","length","writeFile","flag","err","Error","message","directories","dir","join"],"mappings":"AAAA,OAAOA,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAEvB,eAAeC,iBAAiBD,IAAY;IAC1C,IAAI;QACF,MAAMD,GAAGG,MAAM,CAACF;QAChB,OAAO;IACT,EAAE,OA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E,IAAI,CAAC,UAAU;QAEtF;IACF;IACA,OAAOV;AACT"}
|
|
@@ -8,7 +8,7 @@ import type { Payload } from '../../types/index.js';
|
|
|
8
8
|
import type { SanitizedCollectionConfig } from './types.js';
|
|
9
9
|
export type ServerOnlyCollectionProperties = keyof Pick<SanitizedCollectionConfig, 'access' | 'custom' | 'endpoints' | 'flattenedFields' | 'hooks' | 'indexes' | 'joins' | 'polymorphicJoins' | 'sanitizedIndexes' | 'select'>;
|
|
10
10
|
export type ServerOnlyCollectionAdminProperties = keyof Pick<SanitizedCollectionConfig['admin'], 'baseFilter' | 'baseListFilter' | 'components' | 'formatDocURL' | 'hidden'>;
|
|
11
|
-
export type ServerOnlyUploadProperties = keyof Pick<SanitizedCollectionConfig['upload'], 'adminThumbnail' | 'externalFileHeaderFilter' | 'handlers' | 'modifyResponseHeaders' | 'withMetadata'>;
|
|
11
|
+
export type ServerOnlyUploadProperties = keyof Pick<SanitizedCollectionConfig['upload'], 'admin' | 'adminThumbnail' | 'externalFileHeaderFilter' | 'handlers' | 'modifyResponseHeaders' | 'withMetadata'>;
|
|
12
12
|
export type ClientCollectionConfig = {
|
|
13
13
|
admin: {
|
|
14
14
|
description?: StaticDescription;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/collections/config/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,0BAA0B,CAAA;AAErE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAA;AACrE,OAAO,KAAK,EACV,iBAAiB,EACjB,+BAA+B,EAC/B,WAAW,EACZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AACr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CAAA;IACvD,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,EAAE,SAAS,CAAA;CACrB,KAAG,sBAAsB,EAezB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/config/client.ts"],"sourcesContent":["import type { I18nClient, TFunction } from '@payloadcms/translations'\n\nimport type { StaticDescription } from '../../admin/types.js'\nimport type { ImportMap } from '../../bin/generateImportMap/index.js'\nimport type {\n LivePreviewConfig,\n ServerOnlyLivePreviewProperties,\n StaticLabel,\n} from '../../config/types.js'\nimport type { ClientField } from '../../fields/config/client.js'\nimport type { ClientHierarchyConfig } from '../../hierarchy/types.js'\nimport type { Payload } from '../../types/index.js'\nimport type { SanitizedUploadConfig } from '../../uploads/types.js'\nimport type { SanitizedCollectionConfig } from './types.js'\n\nimport { createClientFields } from '../../fields/config/client.js'\n\nexport type ServerOnlyCollectionProperties = keyof Pick<\n SanitizedCollectionConfig,\n | 'access'\n | 'custom'\n | 'endpoints'\n | 'flattenedFields'\n | 'hooks'\n | 'indexes'\n | 'joins'\n | 'polymorphicJoins'\n | 'sanitizedIndexes'\n | 'select'\n>\n\nexport type ServerOnlyCollectionAdminProperties = keyof Pick<\n SanitizedCollectionConfig['admin'],\n 'baseFilter' | 'baseListFilter' | 'components' | 'formatDocURL' | 'hidden'\n>\n\nexport type ServerOnlyUploadProperties = keyof Pick<\n SanitizedCollectionConfig['upload'],\n | 'adminThumbnail'\n | 'externalFileHeaderFilter'\n | 'handlers'\n | 'modifyResponseHeaders'\n | 'withMetadata'\n>\n\nexport type ClientCollectionConfig = {\n admin: {\n description?: StaticDescription\n livePreview?: Omit<LivePreviewConfig, ServerOnlyLivePreviewProperties>\n preview?: boolean\n } & Omit<\n SanitizedCollectionConfig['admin'],\n | 'components'\n | 'description'\n | 'formatDocURL'\n | 'joins'\n | 'livePreview'\n | 'preview'\n | ServerOnlyCollectionAdminProperties\n >\n auth?: { verify?: true } & Omit<\n SanitizedCollectionConfig['auth'],\n 'forgotPassword' | 'strategies' | 'verify'\n >\n fields: ClientField[]\n hierarchy?: ClientHierarchyConfig | false\n labels: {\n plural: StaticLabel\n singular: StaticLabel\n }\n} & Omit<\n SanitizedCollectionConfig,\n 'admin' | 'auth' | 'fields' | 'hierarchy' | 'labels' | ServerOnlyCollectionProperties\n>\n\nconst serverOnlyCollectionProperties: Partial<ServerOnlyCollectionProperties>[] = [\n 'hooks',\n 'access',\n 'endpoints',\n 'custom',\n 'joins',\n 'polymorphicJoins',\n 'flattenedFields',\n 'indexes',\n 'sanitizedIndexes',\n 'select',\n // `upload`\n // `admin`\n // are all handled separately\n]\n\nconst serverOnlyUploadProperties: Partial<ServerOnlyUploadProperties>[] = [\n 'adminThumbnail',\n 'externalFileHeaderFilter',\n 'handlers',\n 'modifyResponseHeaders',\n 'withMetadata',\n]\n\nconst serverOnlyCollectionAdminProperties: Partial<ServerOnlyCollectionAdminProperties>[] = [\n 'hidden',\n 'baseFilter',\n 'baseListFilter',\n 'components',\n 'formatDocURL',\n // 'preview' is handled separately\n // `livePreview` is handled separately\n]\n\nexport const createClientCollectionConfig = ({\n collection,\n defaultIDType,\n i18n,\n importMap,\n}: {\n collection: SanitizedCollectionConfig\n defaultIDType: Payload['config']['db']['defaultIDType']\n i18n: I18nClient\n importMap: ImportMap\n}): ClientCollectionConfig => {\n const clientCollection = {} as Partial<ClientCollectionConfig>\n\n for (const key in collection) {\n if (serverOnlyCollectionProperties.includes(key as any)) {\n continue\n }\n switch (key) {\n case 'admin':\n if (!collection.admin) {\n break\n }\n\n clientCollection.admin = {} as ClientCollectionConfig['admin']\n\n for (const adminKey in collection.admin) {\n if (serverOnlyCollectionAdminProperties.includes(adminKey as any)) {\n continue\n }\n\n switch (adminKey) {\n case 'description':\n if (\n typeof collection.admin.description === 'string' ||\n typeof collection.admin.description === 'object'\n ) {\n if (collection.admin.description) {\n clientCollection.admin.description = collection.admin.description\n }\n } else if (typeof collection.admin.description === 'function') {\n const description = collection.admin.description({ t: i18n.t as TFunction })\n\n if (description) {\n clientCollection.admin.description = description\n }\n }\n break\n\n case 'livePreview':\n clientCollection.admin.livePreview = {}\n\n if (collection.admin.livePreview?.breakpoints) {\n clientCollection.admin.livePreview.breakpoints =\n collection.admin.livePreview.breakpoints\n }\n\n break\n\n case 'preview':\n if (collection.admin.preview) {\n clientCollection.admin.preview = true\n }\n\n break\n\n default:\n ;(clientCollection as any).admin[adminKey] =\n collection.admin[adminKey as keyof SanitizedCollectionConfig['admin']]\n }\n }\n\n break\n\n case 'auth':\n if (!collection.auth) {\n break\n }\n\n clientCollection.auth = {} as { verify?: true } & SanitizedCollectionConfig['auth']\n\n if (collection.auth.cookies) {\n clientCollection.auth.cookies = collection.auth.cookies\n }\n\n if (collection.auth.depth !== undefined) {\n // Check for undefined as it can be a number (0)\n clientCollection.auth.depth = collection.auth.depth\n }\n\n if (collection.auth.disableLocalStrategy) {\n clientCollection.auth.disableLocalStrategy = collection.auth.disableLocalStrategy\n }\n\n if (collection.auth.lockTime !== undefined) {\n // Check for undefined as it can be a number (0)\n clientCollection.auth.lockTime = collection.auth.lockTime\n }\n\n if (collection.auth.loginWithUsername) {\n clientCollection.auth.loginWithUsername = collection.auth.loginWithUsername\n }\n\n if (collection.auth.maxLoginAttempts !== undefined) {\n // Check for undefined as it can be a number (0)\n clientCollection.auth.maxLoginAttempts = collection.auth.maxLoginAttempts\n }\n\n if (collection.auth.removeTokenFromResponses) {\n clientCollection.auth.removeTokenFromResponses = collection.auth.removeTokenFromResponses\n }\n\n if (collection.auth.useAPIKey) {\n clientCollection.auth.useAPIKey = collection.auth.useAPIKey\n }\n\n if (collection.auth.tokenExpiration) {\n clientCollection.auth.tokenExpiration = collection.auth.tokenExpiration\n }\n\n if (collection.auth.verify) {\n clientCollection.auth.verify = true\n }\n\n break\n\n case 'fields':\n clientCollection.fields = createClientFields({\n defaultIDType,\n fields: collection.fields,\n i18n,\n importMap,\n })\n\n break\n\n case 'hierarchy': {\n if (!collection.hierarchy || typeof collection.hierarchy !== 'object') {\n clientCollection.hierarchy = false\n break\n }\n\n // Strip slugify function as it can't cross server-client boundary\n const { slugify: _slugify, ...clientHierarchy } = collection.hierarchy\n clientCollection.hierarchy = clientHierarchy as ClientHierarchyConfig\n\n break\n }\n\n case 'labels':\n clientCollection.labels = {\n plural:\n typeof collection.labels.plural === 'function'\n ? collection.labels.plural({ i18n, t: i18n.t as TFunction })\n : collection.labels.plural,\n singular:\n typeof collection.labels.singular === 'function'\n ? collection.labels.singular({ i18n, t: i18n.t as TFunction })\n : collection.labels.singular,\n }\n\n break\n\n case 'upload':\n if (!collection.upload) {\n break\n }\n\n clientCollection.upload = {} as SanitizedUploadConfig\n\n for (const uploadKey in collection.upload) {\n if (serverOnlyUploadProperties.includes(uploadKey as any)) {\n continue\n }\n\n if (uploadKey === 'imageSizes') {\n clientCollection.upload.imageSizes = collection.upload.imageSizes?.map((size) => {\n const sanitizedSize = { ...size }\n if ('generateImageName' in sanitizedSize) {\n delete sanitizedSize.generateImageName\n }\n return sanitizedSize\n })\n } else {\n ;(clientCollection.upload as any)[uploadKey] =\n collection.upload[uploadKey as keyof SanitizedUploadConfig]\n }\n }\n\n break\n\n default:\n ;(clientCollection as any)[key] = collection[key as keyof SanitizedCollectionConfig]\n }\n }\n\n return clientCollection as ClientCollectionConfig\n}\n\nexport const createClientCollectionConfigs = ({\n collections,\n defaultIDType,\n i18n,\n importMap,\n}: {\n collections: SanitizedCollectionConfig[]\n defaultIDType: Payload['config']['db']['defaultIDType']\n i18n: I18nClient\n importMap: ImportMap\n}): ClientCollectionConfig[] => {\n const clientCollections = new Array(collections.length)\n\n for (let i = 0; i < collections.length; i++) {\n const collection = collections[i]!\n\n clientCollections[i] = createClientCollectionConfig({\n collection,\n defaultIDType,\n i18n,\n importMap,\n })\n }\n\n return clientCollections\n}\n"],"names":["createClientFields","serverOnlyCollectionProperties","serverOnlyUploadProperties","serverOnlyCollectionAdminProperties","createClientCollectionConfig","collection","defaultIDType","i18n","importMap","clientCollection","key","includes","admin","adminKey","description","t","livePreview","breakpoints","preview","auth","cookies","depth","undefined","disableLocalStrategy","lockTime","loginWithUsername","maxLoginAttempts","removeTokenFromResponses","useAPIKey","tokenExpiration","verify","fields","hierarchy","slugify","_slugify","clientHierarchy","labels","plural","singular","upload","uploadKey","imageSizes","map","size","sanitizedSize","generateImageName","createClientCollectionConfigs","collections","clientCollections","Array","length","i"],"mappings":"AAeA,SAASA,kBAAkB,QAAQ,gCAA+B;AA4DlE,MAAMC,iCAA4E;IAChF;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CAID;AAED,MAAMC,6BAAoE;IACxE;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,sCAAsF;IAC1F;IACA;IACA;IACA;IACA;CAGD;AAED,OAAO,MAAMC,+BAA+B,CAAC,EAC3CC,UAAU,EACVC,aAAa,EACbC,IAAI,EACJC,SAAS,EAMV;IACC,MAAMC,mBAAmB,CAAC;IAE1B,IAAK,MAAMC,OAAOL,WAAY;QAC5B,IAAIJ,+BAA+BU,QAAQ,CAACD,MAAa;YACvD;QACF;QACA,OAAQA;YACN,KAAK;gBACH,IAAI,CAACL,WAAWO,KAAK,EAAE;oBACrB;gBACF;gBAEAH,iBAAiBG,KAAK,GAAG,CAAC;gBAE1B,IAAK,MAAMC,YAAYR,WAAWO,KAAK,CAAE;oBACvC,IAAIT,oCAAoCQ,QAAQ,CAACE,WAAkB;wBACjE;oBACF;oBAEA,OAAQA;wBACN,KAAK;4BACH,IACE,OAAOR,WAAWO,KAAK,CAACE,WAAW,KAAK,YACxC,OAAOT,WAAWO,KAAK,CAACE,WAAW,KAAK,UACxC;gCACA,IAAIT,WAAWO,KAAK,CAACE,WAAW,EAAE;oCAChCL,iBAAiBG,KAAK,CAACE,WAAW,GAAGT,WAAWO,KAAK,CAACE,WAAW;gCACnE;4BACF,OAAO,IAAI,OAAOT,WAAWO,KAAK,CAACE,WAAW,KAAK,YAAY;gCAC7D,MAAMA,cAAcT,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,IAAI,GAAGA,IAAIJ,YAAYG,MAAM,EAAEC,IAAK;QAC3C,MAAM9C,aAAa0C,WAAW,CAACI,EAAE;QAEjCH,iBAAiB,CAACG,EAAE,GAAG/C,6BAA6B;YAClDC;YACAC;YACAC;YACAC;QACF;IACF;IAEA,OAAOwC;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/config/client.ts"],"sourcesContent":["import type { I18nClient, TFunction } from '@payloadcms/translations'\n\nimport type { StaticDescription } from '../../admin/types.js'\nimport type { ImportMap } from '../../bin/generateImportMap/index.js'\nimport type {\n LivePreviewConfig,\n ServerOnlyLivePreviewProperties,\n StaticLabel,\n} from '../../config/types.js'\nimport type { ClientField } from '../../fields/config/client.js'\nimport type { ClientHierarchyConfig } from '../../hierarchy/types.js'\nimport type { Payload } from '../../types/index.js'\nimport type { SanitizedUploadConfig } from '../../uploads/types.js'\nimport type { SanitizedCollectionConfig } from './types.js'\n\nimport { createClientFields } from '../../fields/config/client.js'\n\nexport type ServerOnlyCollectionProperties = keyof Pick<\n SanitizedCollectionConfig,\n | 'access'\n | 'custom'\n | 'endpoints'\n | 'flattenedFields'\n | 'hooks'\n | 'indexes'\n | 'joins'\n | 'polymorphicJoins'\n | 'sanitizedIndexes'\n | 'select'\n>\n\nexport type ServerOnlyCollectionAdminProperties = keyof Pick<\n SanitizedCollectionConfig['admin'],\n 'baseFilter' | 'baseListFilter' | 'components' | 'formatDocURL' | 'hidden'\n>\n\nexport type ServerOnlyUploadProperties = keyof Pick<\n SanitizedCollectionConfig['upload'],\n | 'admin'\n | 'adminThumbnail'\n | 'externalFileHeaderFilter'\n | 'handlers'\n | 'modifyResponseHeaders'\n | 'withMetadata'\n>\n\nexport type ClientCollectionConfig = {\n admin: {\n description?: StaticDescription\n livePreview?: Omit<LivePreviewConfig, ServerOnlyLivePreviewProperties>\n preview?: boolean\n } & Omit<\n SanitizedCollectionConfig['admin'],\n | 'components'\n | 'description'\n | 'formatDocURL'\n | 'joins'\n | 'livePreview'\n | 'preview'\n | ServerOnlyCollectionAdminProperties\n >\n auth?: { verify?: true } & Omit<\n SanitizedCollectionConfig['auth'],\n 'forgotPassword' | 'strategies' | 'verify'\n >\n fields: ClientField[]\n hierarchy?: ClientHierarchyConfig | false\n labels: {\n plural: StaticLabel\n singular: StaticLabel\n }\n} & Omit<\n SanitizedCollectionConfig,\n 'admin' | 'auth' | 'fields' | 'hierarchy' | 'labels' | ServerOnlyCollectionProperties\n>\n\nconst serverOnlyCollectionProperties: Partial<ServerOnlyCollectionProperties>[] = [\n 'hooks',\n 'access',\n 'endpoints',\n 'custom',\n 'joins',\n 'polymorphicJoins',\n 'flattenedFields',\n 'indexes',\n 'sanitizedIndexes',\n 'select',\n // `upload`\n // `admin`\n // are all handled separately\n]\n\nconst serverOnlyUploadProperties: Partial<ServerOnlyUploadProperties>[] = [\n 'admin',\n 'adminThumbnail',\n 'externalFileHeaderFilter',\n 'handlers',\n 'modifyResponseHeaders',\n 'withMetadata',\n]\n\nconst serverOnlyCollectionAdminProperties: Partial<ServerOnlyCollectionAdminProperties>[] = [\n 'hidden',\n 'baseFilter',\n 'baseListFilter',\n 'components',\n 'formatDocURL',\n // 'preview' is handled separately\n // `livePreview` is handled separately\n]\n\nexport const createClientCollectionConfig = ({\n collection,\n defaultIDType,\n i18n,\n importMap,\n}: {\n collection: SanitizedCollectionConfig\n defaultIDType: Payload['config']['db']['defaultIDType']\n i18n: I18nClient\n importMap: ImportMap\n}): ClientCollectionConfig => {\n const clientCollection = {} as Partial<ClientCollectionConfig>\n\n for (const key in collection) {\n if (serverOnlyCollectionProperties.includes(key as any)) {\n continue\n }\n switch (key) {\n case 'admin':\n if (!collection.admin) {\n break\n }\n\n clientCollection.admin = {} as ClientCollectionConfig['admin']\n\n for (const adminKey in collection.admin) {\n if (serverOnlyCollectionAdminProperties.includes(adminKey as any)) {\n continue\n }\n\n switch (adminKey) {\n case 'description':\n if (\n typeof collection.admin.description === 'string' ||\n typeof collection.admin.description === 'object'\n ) {\n if (collection.admin.description) {\n clientCollection.admin.description = collection.admin.description\n }\n } else if (typeof collection.admin.description === 'function') {\n const description = collection.admin.description({ t: i18n.t as TFunction })\n\n if (description) {\n clientCollection.admin.description = description\n }\n }\n break\n\n case 'livePreview':\n clientCollection.admin.livePreview = {}\n\n if (collection.admin.livePreview?.breakpoints) {\n clientCollection.admin.livePreview.breakpoints =\n collection.admin.livePreview.breakpoints\n }\n\n break\n\n case 'preview':\n if (collection.admin.preview) {\n clientCollection.admin.preview = true\n }\n\n break\n\n default:\n ;(clientCollection as any).admin[adminKey] =\n collection.admin[adminKey as keyof SanitizedCollectionConfig['admin']]\n }\n }\n\n break\n\n case 'auth':\n if (!collection.auth) {\n break\n }\n\n clientCollection.auth = {} as { verify?: true } & SanitizedCollectionConfig['auth']\n\n if (collection.auth.cookies) {\n clientCollection.auth.cookies = collection.auth.cookies\n }\n\n if (collection.auth.depth !== undefined) {\n // Check for undefined as it can be a number (0)\n clientCollection.auth.depth = collection.auth.depth\n }\n\n if (collection.auth.disableLocalStrategy) {\n clientCollection.auth.disableLocalStrategy = collection.auth.disableLocalStrategy\n }\n\n if (collection.auth.lockTime !== undefined) {\n // Check for undefined as it can be a number (0)\n clientCollection.auth.lockTime = collection.auth.lockTime\n }\n\n if (collection.auth.loginWithUsername) {\n clientCollection.auth.loginWithUsername = collection.auth.loginWithUsername\n }\n\n if (collection.auth.maxLoginAttempts !== undefined) {\n // Check for undefined as it can be a number (0)\n clientCollection.auth.maxLoginAttempts = collection.auth.maxLoginAttempts\n }\n\n if (collection.auth.removeTokenFromResponses) {\n clientCollection.auth.removeTokenFromResponses = collection.auth.removeTokenFromResponses\n }\n\n if (collection.auth.useAPIKey) {\n clientCollection.auth.useAPIKey = collection.auth.useAPIKey\n }\n\n if (collection.auth.tokenExpiration) {\n clientCollection.auth.tokenExpiration = collection.auth.tokenExpiration\n }\n\n if (collection.auth.verify) {\n clientCollection.auth.verify = true\n }\n\n break\n\n case 'fields':\n clientCollection.fields = createClientFields({\n defaultIDType,\n fields: collection.fields,\n i18n,\n importMap,\n })\n\n break\n\n case 'hierarchy': {\n if (!collection.hierarchy || typeof collection.hierarchy !== 'object') {\n clientCollection.hierarchy = false\n break\n }\n\n // Strip slugify function as it can't cross server-client boundary\n const { slugify: _slugify, ...clientHierarchy } = collection.hierarchy\n clientCollection.hierarchy = clientHierarchy as ClientHierarchyConfig\n\n break\n }\n\n case 'labels':\n clientCollection.labels = {\n plural:\n typeof collection.labels.plural === 'function'\n ? collection.labels.plural({ i18n, t: i18n.t as TFunction })\n : collection.labels.plural,\n singular:\n typeof collection.labels.singular === 'function'\n ? collection.labels.singular({ i18n, t: i18n.t as TFunction })\n : collection.labels.singular,\n }\n\n break\n\n case 'upload':\n if (!collection.upload) {\n break\n }\n\n clientCollection.upload = {} as SanitizedUploadConfig\n\n for (const uploadKey in collection.upload) {\n if (serverOnlyUploadProperties.includes(uploadKey as any)) {\n continue\n }\n\n if (uploadKey === 'imageSizes') {\n clientCollection.upload.imageSizes = collection.upload.imageSizes?.map((size) => {\n const sanitizedSize = { ...size }\n if ('generateImageName' in sanitizedSize) {\n delete sanitizedSize.generateImageName\n }\n return sanitizedSize\n })\n } else {\n ;(clientCollection.upload as any)[uploadKey] =\n collection.upload[uploadKey as keyof SanitizedUploadConfig]\n }\n }\n\n break\n\n default:\n ;(clientCollection as any)[key] = collection[key as keyof SanitizedCollectionConfig]\n }\n }\n\n return clientCollection as ClientCollectionConfig\n}\n\nexport const createClientCollectionConfigs = ({\n collections,\n defaultIDType,\n i18n,\n importMap,\n}: {\n collections: SanitizedCollectionConfig[]\n defaultIDType: Payload['config']['db']['defaultIDType']\n i18n: I18nClient\n importMap: ImportMap\n}): ClientCollectionConfig[] => {\n const clientCollections = new Array(collections.length)\n\n for (let i = 0; i < collections.length; i++) {\n const collection = collections[i]!\n\n clientCollections[i] = createClientCollectionConfig({\n collection,\n defaultIDType,\n i18n,\n importMap,\n })\n }\n\n return clientCollections\n}\n"],"names":["createClientFields","serverOnlyCollectionProperties","serverOnlyUploadProperties","serverOnlyCollectionAdminProperties","createClientCollectionConfig","collection","defaultIDType","i18n","importMap","clientCollection","key","includes","admin","adminKey","description","t","livePreview","breakpoints","preview","auth","cookies","depth","undefined","disableLocalStrategy","lockTime","loginWithUsername","maxLoginAttempts","removeTokenFromResponses","useAPIKey","tokenExpiration","verify","fields","hierarchy","slugify","_slugify","clientHierarchy","labels","plural","singular","upload","uploadKey","imageSizes","map","size","sanitizedSize","generateImageName","createClientCollectionConfigs","collections","clientCollections","Array","length","i"],"mappings":"AAeA,SAASA,kBAAkB,QAAQ,gCAA+B;AA6DlE,MAAMC,iCAA4E;IAChF;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CAID;AAED,MAAMC,6BAAoE;IACxE;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,sCAAsF;IAC1F;IACA;IACA;IACA;IACA;CAGD;AAED,OAAO,MAAMC,+BAA+B,CAAC,EAC3CC,UAAU,EACVC,aAAa,EACbC,IAAI,EACJC,SAAS,EAMV;IACC,MAAMC,mBAAmB,CAAC;IAE1B,IAAK,MAAMC,OAAOL,WAAY;QAC5B,IAAIJ,+BAA+BU,QAAQ,CAACD,MAAa;YACvD;QACF;QACA,OAAQA;YACN,KAAK;gBACH,IAAI,CAACL,WAAWO,KAAK,EAAE;oBACrB;gBACF;gBAEAH,iBAAiBG,KAAK,GAAG,CAAC;gBAE1B,IAAK,MAAMC,YAAYR,WAAWO,KAAK,CAAE;oBACvC,IAAIT,oCAAoCQ,QAAQ,CAACE,WAAkB;wBACjE;oBACF;oBAEA,OAAQA;wBACN,KAAK;4BACH,IACE,OAAOR,WAAWO,KAAK,CAACE,WAAW,KAAK,YACxC,OAAOT,WAAWO,KAAK,CAACE,WAAW,KAAK,UACxC;gCACA,IAAIT,WAAWO,KAAK,CAACE,WAAW,EAAE;oCAChCL,iBAAiBG,KAAK,CAACE,WAAW,GAAGT,WAAWO,KAAK,CAACE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,EACbC,IAAI,EACJC,SAAS,EAMV;IACC,MAAMwC,oBAAoB,IAAIC,MAAMF,YAAYG,MAAM;IAEtD,IAAK,IAAIC,IAAI,GAAGA,IAAIJ,YAAYG,MAAM,EAAEC,IAAK;QAC3C,MAAM9C,aAAa0C,WAAW,CAACI,EAAE;QAEjCH,iBAAiB,CAACG,EAAE,GAAG/C,6BAA6B;YAClDC;YACAC;YACAC;YACAC;QACF;IACF;IAEA,OAAOwC;AACT,EAAC"}
|
|
@@ -5,10 +5,6 @@ import type { CollectionConfig } from './types.js';
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const defaults: Partial<CollectionConfig>;
|
|
7
7
|
export declare const addDefaultsToCollectionConfig: (collection: CollectionConfig) => CollectionConfig;
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.
|
|
10
|
-
*/
|
|
11
|
-
export declare const authDefaults: IncomingAuthType;
|
|
12
8
|
export declare const addDefaultsToAuthConfig: (auth: IncomingAuthType) => IncomingAuthType;
|
|
13
9
|
/**
|
|
14
10
|
* @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../src/collections/config/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AACrF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAIlD;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,OAAO,CAAC,gBAAgB,CA8C9C,CAAA;AAED,eAAO,MAAM,6BAA6B,GAAI,YAAY,gBAAgB,KAAG,gBA0D5E,CAAA;AAED
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../src/collections/config/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AACrF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAIlD;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,OAAO,CAAC,gBAAgB,CA8C9C,CAAA;AAED,eAAO,MAAM,6BAA6B,GAAI,YAAY,gBAAgB,KAAG,gBA0D5E,CAAA;AAED,eAAO,MAAM,uBAAuB,GAAI,MAAM,gBAAgB,KAAG,gBAqBhE,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,wBAIvC,CAAA;AAED,eAAO,MAAM,oCAAoC,GAC/C,mBAAmB,wBAAwB,KAC1C,wBAM6B,CAAA"}
|
|
@@ -113,21 +113,6 @@ export const addDefaultsToCollectionConfig = (collection)=>{
|
|
|
113
113
|
collection.indexes = collection.indexes ?? [];
|
|
114
114
|
return collection;
|
|
115
115
|
};
|
|
116
|
-
/**
|
|
117
|
-
* @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.
|
|
118
|
-
*/ export const authDefaults = {
|
|
119
|
-
cookies: {
|
|
120
|
-
sameSite: 'Lax',
|
|
121
|
-
secure: false
|
|
122
|
-
},
|
|
123
|
-
forgotPassword: {},
|
|
124
|
-
lockTime: 600000,
|
|
125
|
-
loginWithUsername: false,
|
|
126
|
-
maxLoginAttempts: 5,
|
|
127
|
-
tokenExpiration: 7200,
|
|
128
|
-
useSessions: true,
|
|
129
|
-
verify: false
|
|
130
|
-
};
|
|
131
116
|
export const addDefaultsToAuthConfig = (auth)=>{
|
|
132
117
|
auth.cookies = {
|
|
133
118
|
sameSite: 'Lax',
|
|
@@ -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: true,\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.hierarchy = collection.hierarchy ?? 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 ?? true\n\n collection.indexes = collection.indexes ?? []\n\n return collection\n}\n\
|
|
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: true,\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.hierarchy = collection.hierarchy ?? 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 ?? true\n\n collection.indexes = collection.indexes ?? []\n\n return collection\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","hierarchy","addDefaultsToAuthConfig","cookies","sameSite","secure","forgotPassword","lockTime","loginWithUsername","maxLoginAttempts","tokenExpiration","useSessions","verify","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,EAAE;IACb;IACAC,SAAS,EAAE;IACXC,YAAY;IACZC,QAAQ;IACRC,UAAU;AACZ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ingCollectionVersions, SanitizedCollectionVersions } from '../../versions/types.js';
|
|
15
15
|
import type { AfterOperationArg, BeforeOperationArg, OperationMap } from '../operations/utilities/types.js';
|
|
16
16
|
export type DataFromCollectionSlug<TSlug extends CollectionSlug> = TypedCollection[TSlug];
|
|
17
|
+
/**
|
|
18
|
+
* The ID type of a given collection (e.g. `string` or `number`), taken from its generated type.
|
|
19
|
+
* Use this instead of the project-wide {@link DefaultDocumentIDType} when the collection slug is
|
|
20
|
+
* known, since each collection can have its own ID type.
|
|
21
|
+
*/
|
|
22
|
+
export type IDTypeForCollectionSlug<TSlug extends CollectionSlug> = DataFromCollectionSlug<TSlug>['id'];
|
|
17
23
|
export type SelectFromCollectionSlug<TSlug extends CollectionSlug> = TypedCollectionSelect[TSlug];
|
|
18
24
|
/**
|
|
19
25
|
* Collection slugs that do not have drafts enabled.
|