payload 3.1.0 → 3.1.1-canary.c40ff01

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.
@@ -166,7 +166,7 @@ export interface IncomingAuthType {
166
166
  disableLocalStrategy?: true;
167
167
  /**
168
168
  * Customize the way that the forgotPassword operation functions.
169
- * @link https://payloadcms.com/docs/beta/authentication/email#forgot-password
169
+ * @link https://payloadcms.com/docs/authentication/email#forgot-password
170
170
  */
171
171
  forgotPassword?: {
172
172
  generateEmailHTML?: GenerateForgotPasswordEmailHTML;
@@ -179,7 +179,7 @@ export interface IncomingAuthType {
179
179
  /**
180
180
  * Ability to allow users to login with username/password.
181
181
  *
182
- * @link https://payloadcms.com/docs/beta/authentication/overview#login-with-username
182
+ * @link https://payloadcms.com/docs/authentication/overview#login-with-username
183
183
  */
184
184
  loginWithUsername?: boolean | LoginWithUsernameOptions;
185
185
  /**
@@ -192,24 +192,24 @@ export interface IncomingAuthType {
192
192
  removeTokenFromResponses?: true;
193
193
  /**
194
194
  * Advanced - an array of custom authentification strategies to extend this collection's authentication with.
195
- * @link https://payloadcms.com/docs/beta/authentication/custom-strategies
195
+ * @link https://payloadcms.com/docs/authentication/custom-strategies
196
196
  */
197
197
  strategies?: AuthStrategy[];
198
198
  /**
199
199
  * Controls how many seconds the token will be valid for. Default is 2 hours.
200
200
  * @default 7200
201
- * @link https://payloadcms.com/docs/beta/authentication/overview#config-options
201
+ * @link https://payloadcms.com/docs/authentication/overview#config-options
202
202
  */
203
203
  tokenExpiration?: number;
204
204
  /**
205
205
  * Payload Authentication provides for API keys to be set on each user within an Authentication-enabled Collection.
206
206
  * @default false
207
- * @link https://payloadcms.com/docs/beta/authentication/api-keys
207
+ * @link https://payloadcms.com/docs/authentication/api-keys
208
208
  */
209
209
  useAPIKey?: boolean;
210
210
  /**
211
211
  * 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.
212
- * @link https://payloadcms.com/docs/beta/authentication/email#email-verification
212
+ * @link https://payloadcms.com/docs/authentication/email#email-verification
213
213
  */
214
214
  verify?: {
215
215
  generateEmailHTML?: GenerateVerifyEmailHTML;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/auth/types.ts"],"sourcesContent":["import type { DeepRequired } from 'ts-essentials'\n\nimport type { CollectionSlug, GlobalSlug, Payload } 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 update: Permission\n}\n\nexport type SanitizedCollectionPermission = {\n create?: true\n delete?: true\n fields: SanitizedFieldsPermissions\n read?: true\n readVersions?: 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 username?: string\n}\n\nexport type User = {\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\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 headers: Request['headers']\n isGraphQL?: boolean\n payload: Payload\n}\n\nexport type AuthStrategyResult = {\n responseHeaders?: Headers\n user: null | User\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?: true\n /**\n * Customize the way that the forgotPassword operation functions.\n * @link https://payloadcms.com/docs/beta/authentication/email#forgot-password\n */\n forgotPassword?: {\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/beta/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/beta/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/beta/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/beta/authentication/api-keys\n */\n useAPIKey?: boolean\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/beta/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 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":"AAuRA,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 } 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 update: Permission\n}\n\nexport type SanitizedCollectionPermission = {\n create?: true\n delete?: true\n fields: SanitizedFieldsPermissions\n read?: true\n readVersions?: 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 username?: string\n}\n\nexport type User = {\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\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 headers: Request['headers']\n isGraphQL?: boolean\n payload: Payload\n}\n\nexport type AuthStrategyResult = {\n responseHeaders?: Headers\n user: null | User\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?: 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 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 * 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 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":"AAuRA,OAAO,SAASA,qBAAqBC,MAAuB;IAC1D,OAAOA,UAAU,OAAOA,WAAW;AACrC"}
@@ -1,2 +1,2 @@
1
- export declare function checkPayloadDependencies(): Promise<void>;
1
+ export declare function checkPayloadDependencies(): void;
2
2
  //# sourceMappingURL=checkPayloadDependencies.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkPayloadDependencies.d.ts","sourceRoot":"","sources":["../src/checkPayloadDependencies.ts"],"names":[],"mappings":"AAGA,wBAAsB,wBAAwB,kBAiB7C"}
1
+ {"version":3,"file":"checkPayloadDependencies.d.ts","sourceRoot":"","sources":["../src/checkPayloadDependencies.ts"],"names":[],"mappings":"AAGA,wBAAgB,wBAAwB,SAiBvC"}
@@ -1,6 +1,6 @@
1
1
  import { checkDependencies } from './utilities/dependencies/dependencyChecker.js';
2
2
  import { PAYLOAD_PACKAGE_LIST } from './versions/payloadPackageList.js';
3
- export async function checkPayloadDependencies() {
3
+ export function checkPayloadDependencies() {
4
4
  const dependencies = [
5
5
  ...PAYLOAD_PACKAGE_LIST
6
6
  ];
@@ -8,7 +8,7 @@ export async function checkPayloadDependencies() {
8
8
  dependencies.push('@payloadcms/plugin-sentry');
9
9
  }
10
10
  // First load. First check if there are mismatching dependency versions of payload packages
11
- await checkDependencies({
11
+ void checkDependencies({
12
12
  dependencyGroups: [
13
13
  {
14
14
  name: 'payload',
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/checkPayloadDependencies.ts"],"sourcesContent":["import { checkDependencies } from './utilities/dependencies/dependencyChecker.js'\nimport { PAYLOAD_PACKAGE_LIST } from './versions/payloadPackageList.js'\n\nexport async function checkPayloadDependencies() {\n const dependencies = [...PAYLOAD_PACKAGE_LIST]\n\n if (process.env.PAYLOAD_CI_DEPENDENCY_CHECKER !== 'true') {\n dependencies.push('@payloadcms/plugin-sentry')\n }\n\n // First load. First check if there are mismatching dependency versions of payload packages\n await checkDependencies({\n dependencyGroups: [\n {\n name: 'payload',\n dependencies,\n targetVersionDependency: 'payload',\n },\n ],\n })\n}\n"],"names":["checkDependencies","PAYLOAD_PACKAGE_LIST","checkPayloadDependencies","dependencies","process","env","PAYLOAD_CI_DEPENDENCY_CHECKER","push","dependencyGroups","name","targetVersionDependency"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,gDAA+C;AACjF,SAASC,oBAAoB,QAAQ,mCAAkC;AAEvE,OAAO,eAAeC;IACpB,MAAMC,eAAe;WAAIF;KAAqB;IAE9C,IAAIG,QAAQC,GAAG,CAACC,6BAA6B,KAAK,QAAQ;QACxDH,aAAaI,IAAI,CAAC;IACpB;IAEA,2FAA2F;IAC3F,MAAMP,kBAAkB;QACtBQ,kBAAkB;YAChB;gBACEC,MAAM;gBACNN;gBACAO,yBAAyB;YAC3B;SACD;IACH;AACF"}
1
+ {"version":3,"sources":["../src/checkPayloadDependencies.ts"],"sourcesContent":["import { checkDependencies } from './utilities/dependencies/dependencyChecker.js'\nimport { PAYLOAD_PACKAGE_LIST } from './versions/payloadPackageList.js'\n\nexport function checkPayloadDependencies() {\n const dependencies = [...PAYLOAD_PACKAGE_LIST]\n\n if (process.env.PAYLOAD_CI_DEPENDENCY_CHECKER !== 'true') {\n dependencies.push('@payloadcms/plugin-sentry')\n }\n\n // First load. First check if there are mismatching dependency versions of payload packages\n void checkDependencies({\n dependencyGroups: [\n {\n name: 'payload',\n dependencies,\n targetVersionDependency: 'payload',\n },\n ],\n })\n}\n"],"names":["checkDependencies","PAYLOAD_PACKAGE_LIST","checkPayloadDependencies","dependencies","process","env","PAYLOAD_CI_DEPENDENCY_CHECKER","push","dependencyGroups","name","targetVersionDependency"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,gDAA+C;AACjF,SAASC,oBAAoB,QAAQ,mCAAkC;AAEvE,OAAO,SAASC;IACd,MAAMC,eAAe;WAAIF;KAAqB;IAE9C,IAAIG,QAAQC,GAAG,CAACC,6BAA6B,KAAK,QAAQ;QACxDH,aAAaI,IAAI,CAAC;IACpB;IAEA,2FAA2F;IAC3F,KAAKP,kBAAkB;QACrBQ,kBAAkB;YAChB;gBACEC,MAAM;gBACNN;gBACAO,yBAAyB;YAC3B;SACD;IACH;AACF"}
@@ -14,12 +14,15 @@ export type ClientCollectionConfig = {
14
14
  livePreview?: Omit<LivePreviewConfig, ServerOnlyLivePreviewProperties>;
15
15
  preview?: boolean;
16
16
  } & Omit<SanitizedCollectionConfig['admin'], 'components' | 'description' | 'joins' | 'livePreview' | 'preview' | ServerOnlyCollectionAdminProperties>;
17
+ auth?: {
18
+ verify?: true;
19
+ } & Omit<SanitizedCollectionConfig['auth'], 'forgotPassword' | 'strategies' | 'verify'>;
17
20
  fields: ClientField[];
18
21
  labels: {
19
22
  plural: StaticLabel;
20
23
  singular: StaticLabel;
21
24
  };
22
- } & Omit<SanitizedCollectionConfig, 'admin' | 'fields' | 'labels' | ServerOnlyCollectionProperties>;
25
+ } & Omit<SanitizedCollectionConfig, 'admin' | 'auth' | 'fields' | 'labels' | ServerOnlyCollectionProperties>;
23
26
  export declare const createClientCollectionConfig: ({ collection, defaultIDType, i18n, importMap, }: {
24
27
  collection: SanitizedCollectionConfig;
25
28
  defaultIDType: Payload["config"]["db"]["defaultIDType"];
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/collections/config/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,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,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA;AAK3D,MAAM,MAAM,8BAA8B,GAAG,MAAM,IAAI,CACrD,yBAAyB,EACzB,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,GAAG,OAAO,CACtD,CAAA;AAED,MAAM,MAAM,mCAAmC,GAAG,MAAM,IAAI,CAC1D,yBAAyB,CAAC,OAAO,CAAC,EAClC,gBAAgB,GAAG,YAAY,GAAG,QAAQ,CAC3C,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG,MAAM,IAAI,CACjD,yBAAyB,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AI,CAC7B,yBAAyB,CAAC,MAAM,CAAC,EACjC,gBAAgB,GAAG,YAAY,GAAG,QAAQ,CAC3C,CAAA;IACD,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,MAAM,EAAE;QACN,MAAM,EAAE,WAAW,CAAA;QACnB,QAAQ,EAAE,WAAW,CAAA;KACtB,CAAA;CACF,GAAG,IAAI,CACN,yBAAyB,EACzB,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,8BAA8B,CACxE,CAAA;AA6BD,eAAO,MAAM,4BAA4B,oDAKtC;IACD,UAAU,EAAE,yBAAyB,CAAA;IACrC,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,CAAA;IACvD,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,EAAE,SAAS,CAAA;CACrB,KAAG,sBA8IH,CAAA;AAED,eAAO,MAAM,6BAA6B,qDAKvC;IACD,WAAW,EAAE,yBAAyB,EAAE,CAAA;IACxC,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,CAAA;IACvD,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,EAAE,SAAS,CAAA;CACrB,KAAG,sBAAsB,EAezB,CAAA"}
@@ -1,5 +1,4 @@
1
1
  import { createClientFields } from '../../fields/config/client.js';
2
- import { deepCopyObjectSimple } from '../../utilities/deepCopyObject.js';
3
2
  const serverOnlyCollectionProperties = [
4
3
  'hooks',
5
4
  'access',
@@ -20,78 +19,138 @@ const serverOnlyCollectionAdminProperties = [
20
19
  'components'
21
20
  ];
22
21
  export const createClientCollectionConfig = ({ collection, defaultIDType, i18n, importMap })=>{
23
- const clientCollection = deepCopyObjectSimple(collection, true);
24
- clientCollection.fields = createClientFields({
25
- clientFields: clientCollection?.fields || [],
26
- defaultIDType,
27
- fields: collection.fields,
28
- i18n,
29
- importMap
30
- });
31
- serverOnlyCollectionProperties.forEach((key)=>{
32
- if (key in clientCollection) {
33
- delete clientCollection[key];
22
+ const clientCollection = {};
23
+ for(const key in collection){
24
+ if (serverOnlyCollectionProperties.includes(key)) {
25
+ continue;
34
26
  }
35
- });
36
- if ('upload' in clientCollection && typeof clientCollection.upload === 'object') {
37
- serverOnlyUploadProperties.forEach((key)=>{
38
- if (key in clientCollection.upload) {
39
- delete clientCollection.upload[key];
40
- }
41
- });
42
- if ('imageSizes' in clientCollection.upload && clientCollection.upload.imageSizes.length) {
43
- clientCollection.upload.imageSizes = clientCollection.upload.imageSizes.map((size)=>{
44
- const sanitizedSize = {
45
- ...size
46
- };
47
- if ('generateImageName' in sanitizedSize) {
48
- delete sanitizedSize.generateImageName;
27
+ switch(key){
28
+ case 'admin':
29
+ if (!collection.admin) {
30
+ break;
49
31
  }
50
- return sanitizedSize;
51
- });
52
- }
53
- }
54
- if ('auth' in clientCollection && typeof clientCollection.auth === 'object') {
55
- delete clientCollection.auth.strategies;
56
- delete clientCollection.auth.forgotPassword;
57
- delete clientCollection.auth.verify;
58
- }
59
- if (collection.labels) {
60
- Object.entries(collection.labels).forEach(([labelType, collectionLabel])=>{
61
- if (typeof collectionLabel === 'function') {
62
- clientCollection.labels[labelType] = collectionLabel({
63
- t: i18n.t
32
+ clientCollection.admin = {};
33
+ for(const adminKey in collection.admin){
34
+ if (serverOnlyCollectionAdminProperties.includes(adminKey)) {
35
+ continue;
36
+ }
37
+ switch(adminKey){
38
+ case 'description':
39
+ if (typeof collection.admin.description === 'string' || typeof collection.admin.description === 'object') {
40
+ if (collection.admin.description) {
41
+ clientCollection.admin.description = collection.admin.description;
42
+ }
43
+ } else if (typeof collection.admin.description === 'function') {
44
+ const description = collection.admin.description({
45
+ t: i18n.t
46
+ });
47
+ if (description) {
48
+ clientCollection.admin.description = description;
49
+ }
50
+ }
51
+ break;
52
+ case 'livePreview':
53
+ clientCollection.admin.livePreview = {};
54
+ if (collection.admin.livePreview.breakpoints) {
55
+ clientCollection.admin.livePreview.breakpoints = collection.admin.livePreview.breakpoints;
56
+ }
57
+ break;
58
+ case 'preview':
59
+ if (collection.admin.preview) {
60
+ clientCollection.admin.preview = true;
61
+ }
62
+ break;
63
+ default:
64
+ clientCollection.admin[adminKey] = collection.admin[adminKey];
65
+ }
66
+ }
67
+ break;
68
+ case 'auth':
69
+ if (!clientCollection.auth) {
70
+ break;
71
+ }
72
+ clientCollection.auth = {};
73
+ if (collection.auth.cookies) {
74
+ clientCollection.auth.cookies = collection.auth.cookies;
75
+ }
76
+ if (collection.auth.depth !== undefined) {
77
+ // Check for undefined as it can be a number (0)
78
+ clientCollection.auth.depth = collection.auth.depth;
79
+ }
80
+ if (collection.auth.disableLocalStrategy) {
81
+ clientCollection.auth.disableLocalStrategy = collection.auth.disableLocalStrategy;
82
+ }
83
+ if (collection.auth.lockTime !== undefined) {
84
+ // Check for undefined as it can be a number (0)
85
+ clientCollection.auth.lockTime = collection.auth.lockTime;
86
+ }
87
+ if (collection.auth.loginWithUsername) {
88
+ clientCollection.auth.loginWithUsername = collection.auth.loginWithUsername;
89
+ }
90
+ if (collection.auth.maxLoginAttempts !== undefined) {
91
+ // Check for undefined as it can be a number (0)
92
+ clientCollection.auth.maxLoginAttempts = collection.auth.maxLoginAttempts;
93
+ }
94
+ if (collection.auth.removeTokenFromResponses) {
95
+ clientCollection.auth.removeTokenFromResponses = collection.auth.removeTokenFromResponses;
96
+ }
97
+ if (collection.auth.useAPIKey) {
98
+ clientCollection.auth.useAPIKey = collection.auth.useAPIKey;
99
+ }
100
+ if (collection.auth.tokenExpiration) {
101
+ clientCollection.auth.tokenExpiration = collection.auth.tokenExpiration;
102
+ }
103
+ if (collection.auth.verify) {
104
+ clientCollection.auth.verify = true;
105
+ }
106
+ break;
107
+ case 'fields':
108
+ clientCollection.fields = createClientFields({
109
+ defaultIDType,
110
+ fields: collection.fields,
111
+ i18n,
112
+ importMap
64
113
  });
65
- }
66
- });
67
- }
68
- if (!clientCollection.admin) {
69
- clientCollection.admin = {};
70
- }
71
- serverOnlyCollectionAdminProperties.forEach((key)=>{
72
- if (key in clientCollection.admin) {
73
- delete clientCollection.admin[key];
74
- }
75
- });
76
- if (collection.admin.preview) {
77
- clientCollection.admin.preview = true;
78
- }
79
- let description = undefined;
80
- if (collection.admin?.description) {
81
- if (typeof collection.admin?.description === 'string' || typeof collection.admin?.description === 'object') {
82
- description = collection.admin.description;
83
- } else if (typeof collection.admin?.description === 'function') {
84
- description = collection.admin?.description({
85
- t: i18n.t
86
- });
114
+ break;
115
+ case 'labels':
116
+ clientCollection.labels = {
117
+ plural: typeof collection.labels.plural === 'function' ? collection.labels.plural({
118
+ t: i18n.t
119
+ }) : collection.labels.plural,
120
+ singular: typeof collection.labels.singular === 'function' ? collection.labels.singular({
121
+ t: i18n.t
122
+ }) : collection.labels.singular
123
+ };
124
+ break;
125
+ case 'upload':
126
+ if (!collection.upload) {
127
+ break;
128
+ }
129
+ clientCollection.upload = {};
130
+ for(const uploadKey in collection.upload){
131
+ if (serverOnlyUploadProperties.includes(uploadKey)) {
132
+ continue;
133
+ }
134
+ if (uploadKey === 'imageSizes') {
135
+ clientCollection.upload.imageSizes = collection.upload.imageSizes.map((size)=>{
136
+ const sanitizedSize = {
137
+ ...size
138
+ };
139
+ if ('generateImageName' in sanitizedSize) {
140
+ delete sanitizedSize.generateImageName;
141
+ }
142
+ return sanitizedSize;
143
+ });
144
+ } else {
145
+ clientCollection.upload[uploadKey] = collection.upload[uploadKey];
146
+ }
147
+ }
148
+ break;
149
+ break;
150
+ default:
151
+ clientCollection[key] = collection[key];
87
152
  }
88
153
  }
89
- if (description) {
90
- clientCollection.admin.description = description;
91
- }
92
- if ('livePreview' in clientCollection.admin && clientCollection.admin.livePreview && 'url' in clientCollection.admin.livePreview) {
93
- delete clientCollection.admin.livePreview.url;
94
- }
95
154
  return clientCollection;
96
155
  };
97
156
  export const createClientCollectionConfigs = ({ collections, defaultIDType, i18n, importMap })=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/config/client.ts"],"sourcesContent":["import type { I18nClient } 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 { Payload } from '../../types/index.js'\nimport type { SanitizedCollectionConfig } from './types.js'\n\nimport { createClientFields } from '../../fields/config/client.js'\nimport { deepCopyObjectSimple } from '../../utilities/deepCopyObject.js'\n\nexport type ServerOnlyCollectionProperties = keyof Pick<\n SanitizedCollectionConfig,\n 'access' | 'custom' | 'endpoints' | 'hooks' | 'joins'\n>\n\nexport type ServerOnlyCollectionAdminProperties = keyof Pick<\n SanitizedCollectionConfig['admin'],\n 'baseListFilter' | 'components' | '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 | 'joins'\n | 'livePreview'\n | 'preview'\n | ServerOnlyCollectionAdminProperties\n >\n fields: ClientField[]\n labels: {\n plural: StaticLabel\n singular: StaticLabel\n }\n} & Omit<SanitizedCollectionConfig, 'admin' | 'fields' | 'labels' | ServerOnlyCollectionProperties>\n\nconst serverOnlyCollectionProperties: Partial<ServerOnlyCollectionProperties>[] = [\n 'hooks',\n 'access',\n 'endpoints',\n 'custom',\n 'joins',\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 'baseListFilter',\n 'components',\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 = deepCopyObjectSimple(\n collection,\n true,\n ) as unknown as ClientCollectionConfig\n\n clientCollection.fields = createClientFields({\n clientFields: clientCollection?.fields || [],\n defaultIDType,\n fields: collection.fields,\n i18n,\n importMap,\n })\n\n serverOnlyCollectionProperties.forEach((key) => {\n if (key in clientCollection) {\n delete clientCollection[key]\n }\n })\n\n if ('upload' in clientCollection && typeof clientCollection.upload === 'object') {\n serverOnlyUploadProperties.forEach((key) => {\n if (key in clientCollection.upload) {\n delete clientCollection.upload[key]\n }\n })\n\n if ('imageSizes' in clientCollection.upload && clientCollection.upload.imageSizes.length) {\n clientCollection.upload.imageSizes = clientCollection.upload.imageSizes.map((size) => {\n const sanitizedSize = { ...size }\n if ('generateImageName' in sanitizedSize) {\n delete sanitizedSize.generateImageName\n }\n return sanitizedSize\n })\n }\n }\n\n if ('auth' in clientCollection && typeof clientCollection.auth === 'object') {\n delete clientCollection.auth.strategies\n delete clientCollection.auth.forgotPassword\n delete clientCollection.auth.verify\n }\n\n if (collection.labels) {\n Object.entries(collection.labels).forEach(([labelType, collectionLabel]) => {\n if (typeof collectionLabel === 'function') {\n clientCollection.labels[labelType] = collectionLabel({ t: i18n.t })\n }\n })\n }\n\n if (!clientCollection.admin) {\n clientCollection.admin = {} as ClientCollectionConfig['admin']\n }\n\n serverOnlyCollectionAdminProperties.forEach((key) => {\n if (key in clientCollection.admin) {\n delete clientCollection.admin[key]\n }\n })\n\n if (collection.admin.preview) {\n clientCollection.admin.preview = true\n }\n\n let description = undefined\n\n if (collection.admin?.description) {\n if (\n typeof collection.admin?.description === 'string' ||\n typeof collection.admin?.description === 'object'\n ) {\n description = collection.admin.description\n } else if (typeof collection.admin?.description === 'function') {\n description = collection.admin?.description({ t: i18n.t })\n }\n }\n\n if (description) {\n clientCollection.admin.description = description\n }\n\n if (\n 'livePreview' in clientCollection.admin &&\n clientCollection.admin.livePreview &&\n 'url' in clientCollection.admin.livePreview\n ) {\n delete clientCollection.admin.livePreview.url\n }\n\n return clientCollection\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","deepCopyObjectSimple","serverOnlyCollectionProperties","serverOnlyUploadProperties","serverOnlyCollectionAdminProperties","createClientCollectionConfig","collection","defaultIDType","i18n","importMap","clientCollection","fields","clientFields","forEach","key","upload","imageSizes","length","map","size","sanitizedSize","generateImageName","auth","strategies","forgotPassword","verify","labels","Object","entries","labelType","collectionLabel","t","admin","preview","description","undefined","livePreview","url","createClientCollectionConfigs","collections","clientCollections","Array","i"],"mappings":"AAaA,SAASA,kBAAkB,QAAQ,gCAA+B;AAClE,SAASC,oBAAoB,QAAQ,oCAAmC;AA0CxE,MAAMC,iCAA4E;IAChF;IACA;IACA;IACA;IACA;CAID;AAED,MAAMC,6BAAoE;IACxE;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,sCAAsF;IAC1F;IACA;IACA;CAGD;AAED,OAAO,MAAMC,+BAA+B,CAAC,EAC3CC,UAAU,EACVC,aAAa,EACbC,IAAI,EACJC,SAAS,EAMV;IACC,MAA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CAACG,EAAE;QAEjCF,iBAAiB,CAACE,EAAE,GAAGrC,6BAA6B;YAClDC;YACAC;YACAC;YACAC;QACF;IACF;IAEA,OAAO+B;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/collections/config/client.ts"],"sourcesContent":["import type { I18nClient } 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 { 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' | 'custom' | 'endpoints' | 'hooks' | 'joins'\n>\n\nexport type ServerOnlyCollectionAdminProperties = keyof Pick<\n SanitizedCollectionConfig['admin'],\n 'baseListFilter' | 'components' | '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 | '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 labels: {\n plural: StaticLabel\n singular: StaticLabel\n }\n} & Omit<\n SanitizedCollectionConfig,\n 'admin' | 'auth' | 'fields' | 'labels' | ServerOnlyCollectionProperties\n>\n\nconst serverOnlyCollectionProperties: Partial<ServerOnlyCollectionProperties>[] = [\n 'hooks',\n 'access',\n 'endpoints',\n 'custom',\n 'joins',\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 'baseListFilter',\n 'components',\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 clientCollection.admin = {} as ClientCollectionConfig['admin']\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 })\n if (description) {\n clientCollection.admin.description = description\n }\n }\n break\n case 'livePreview':\n clientCollection.admin.livePreview =\n {} as ClientCollectionConfig['admin']['livePreview']\n if (collection.admin.livePreview.breakpoints) {\n clientCollection.admin.livePreview.breakpoints =\n collection.admin.livePreview.breakpoints\n }\n break\n case 'preview':\n if (collection.admin.preview) {\n clientCollection.admin.preview = true\n }\n break\n default:\n clientCollection.admin[adminKey] = collection.admin[adminKey]\n }\n }\n break\n case 'auth':\n if (!clientCollection.auth) {\n break\n }\n clientCollection.auth = {} as { verify?: true } & SanitizedCollectionConfig['auth']\n if (collection.auth.cookies) {\n clientCollection.auth.cookies = collection.auth.cookies\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 if (collection.auth.disableLocalStrategy) {\n clientCollection.auth.disableLocalStrategy = collection.auth.disableLocalStrategy\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 if (collection.auth.loginWithUsername) {\n clientCollection.auth.loginWithUsername = collection.auth.loginWithUsername\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 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 if (collection.auth.tokenExpiration) {\n clientCollection.auth.tokenExpiration = collection.auth.tokenExpiration\n }\n if (collection.auth.verify) {\n clientCollection.auth.verify = true\n }\n break\n case 'fields':\n clientCollection.fields = createClientFields({\n defaultIDType,\n fields: collection.fields,\n i18n,\n importMap,\n })\n break\n case 'labels':\n clientCollection.labels = {\n plural:\n typeof collection.labels.plural === 'function'\n ? collection.labels.plural({ t: i18n.t })\n : collection.labels.plural,\n singular:\n typeof collection.labels.singular === 'function'\n ? collection.labels.singular({ t: i18n.t })\n : collection.labels.singular,\n }\n break\n case 'upload':\n if (!collection.upload) {\n break\n }\n clientCollection.upload = {} as SanitizedUploadConfig\n for (const uploadKey in collection.upload) {\n if (serverOnlyUploadProperties.includes(uploadKey as any)) {\n continue\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[uploadKey] = collection.upload[uploadKey]\n }\n }\n break\n\n break\n default:\n clientCollection[key] = collection[key]\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","labels","plural","singular","upload","uploadKey","imageSizes","map","size","sanitizedSize","generateImageName","createClientCollectionConfigs","collections","clientCollections","Array","length","i"],"mappings":"AAcA,SAASA,kBAAkB,QAAQ,gCAA+B;AAiDlE,MAAMC,iCAA4E;IAChF;IACA;IACA;IACA;IACA;CAID;AAED,MAAMC,6BAAoE;IACxE;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,sCAAsF;IAC1F;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,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IAEA,OAAOD;AACT,EAAC;AAED,OAAO,MAAMiC,gCAAgC,CAAC,EAC5CC,WAAW,EACXrC,aAAa,EACbC,IAAI,EACJC,SAAS,EAMV;IACC,MAAMoC,oBAAoB,IAAIC,MAAMF,YAAYG,MAAM;IAEtD,IAAK,IAAIC,IAAI,GAAGA,IAAIJ,YAAYG,MAAM,EAAEC,IAAK;QAC3C,MAAM1C,aAAasC,WAAW,CAACI,EAAE;QAEjCH,iBAAiB,CAACG,EAAE,GAAG3C,6BAA6B;YAClDC;YACAC;YACAC;YACAC;QACF;IACF;IAEA,OAAOoC;AACT,EAAC"}
@@ -7,7 +7,6 @@ export type ServerOnlyRootProperties = keyof Pick<SanitizedConfig, 'bin' | 'cors
7
7
  export type ServerOnlyRootAdminProperties = keyof Pick<SanitizedConfig['admin'], 'components'>;
8
8
  export type ClientConfig = {
9
9
  admin: {
10
- components: null;
11
10
  dependencies?: Record<string, React.ReactNode>;
12
11
  livePreview?: Omit<LivePreviewConfig, ServerOnlyLivePreviewProperties>;
13
12
  } & Omit<SanitizedConfig['admin'], 'components' | 'dependencies' | 'livePreview'>;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/config/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAA;AAClE,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,+BAA+B,EAChC,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAAE,KAAK,kBAAkB,EAA6B,MAAM,6BAA6B,CAAA;AAGhG,MAAM,MAAM,wBAAwB,GAAG,MAAM,IAAI,CAC/C,eAAe,EACb,KAAK,GACL,MAAM,GACN,MAAM,GACN,QAAQ,GACR,IAAI,GACJ,QAAQ,GACR,OAAO,GAC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,GAAG,IAAI,CAAC,eAAe,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,wBAAwB,CAAC,CAAA;AAElG,eAAO,MAAM,+BAA+B,EAAE,SAAS,OAAO,CAAC,6BAA6B,CAAC,EAAO,CAAA;AAEpG,eAAO,MAAM,0BAA0B,EAAE,SAAS,OAAO,CAAC,wBAAwB,CAAC,EAmBlF,CAAA;AAED,eAAO,MAAM,kBAAkB,iCAI5B;IACD,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,EAAE,SAAS,CAAA;CACrB,KAAG,YA4FH,CAAA"}
@@ -1,6 +1,5 @@
1
1
  import { createClientCollectionConfigs } from '../collections/config/client.js';
2
2
  import { createClientGlobalConfigs } from '../globals/config/client.js';
3
- import { deepCopyObjectSimple } from '../utilities/deepCopyObject.js';
4
3
  export const serverOnlyAdminConfigProperties = [];
5
4
  export const serverOnlyConfigProperties = [
6
5
  'endpoints',
@@ -22,40 +21,94 @@ export const serverOnlyConfigProperties = [
22
21
  'logger'
23
22
  ];
24
23
  export const createClientConfig = ({ config, i18n, importMap })=>{
25
- // We can use deepCopySimple here, as the clientConfig should be JSON serializable anyways, since it will be sent from server => client
26
- const clientConfig = deepCopyObjectSimple(config, true);
27
- for (const key of serverOnlyConfigProperties){
28
- if (key in clientConfig) {
29
- delete clientConfig[key];
24
+ const clientConfig = {};
25
+ for(const key in config){
26
+ if (serverOnlyConfigProperties.includes(key)) {
27
+ continue;
30
28
  }
31
- }
32
- if ('localization' in clientConfig && clientConfig.localization) {
33
- for (const locale of clientConfig.localization.locales){
34
- delete locale.toString;
29
+ switch(key){
30
+ case 'admin':
31
+ clientConfig.admin = {
32
+ autoLogin: config.admin.autoLogin,
33
+ avatar: config.admin.avatar,
34
+ custom: config.admin.custom,
35
+ dateFormat: config.admin.dateFormat,
36
+ dependencies: config.admin.dependencies,
37
+ disable: config.admin.disable,
38
+ importMap: config.admin.importMap,
39
+ meta: config.admin.meta,
40
+ routes: config.admin.routes,
41
+ theme: config.admin.theme,
42
+ user: config.admin.user
43
+ };
44
+ if (config.admin.livePreview) {
45
+ clientConfig.admin.livePreview = {};
46
+ if (config.admin.livePreview.breakpoints) {
47
+ clientConfig.admin.livePreview.breakpoints = config.admin.livePreview.breakpoints;
48
+ }
49
+ }
50
+ break;
51
+ case 'collections':
52
+ clientConfig.collections = createClientCollectionConfigs({
53
+ collections: config.collections,
54
+ defaultIDType: config.db.defaultIDType,
55
+ i18n,
56
+ importMap
57
+ });
58
+ break;
59
+ case 'globals':
60
+ clientConfig.globals = createClientGlobalConfigs({
61
+ defaultIDType: config.db.defaultIDType,
62
+ globals: config.globals,
63
+ i18n,
64
+ importMap
65
+ });
66
+ break;
67
+ case 'i18n':
68
+ clientConfig.i18n = {
69
+ fallbackLanguage: config.i18n.fallbackLanguage,
70
+ translations: config.i18n.translations
71
+ };
72
+ break;
73
+ case 'localization':
74
+ if (typeof config.localization === 'object' && config.localization) {
75
+ clientConfig.localization = {};
76
+ if (config.localization.defaultLocale) {
77
+ clientConfig.localization.defaultLocale = config.localization.defaultLocale;
78
+ }
79
+ if (config.localization.fallback) {
80
+ clientConfig.localization.fallback = config.localization.fallback;
81
+ }
82
+ if (config.localization.localeCodes) {
83
+ clientConfig.localization.localeCodes = config.localization.localeCodes;
84
+ }
85
+ if (config.localization.locales) {
86
+ clientConfig.localization.locales = [];
87
+ for (const locale of config.localization.locales){
88
+ if (locale) {
89
+ const clientLocale = {};
90
+ if (locale.code) {
91
+ clientLocale.code = locale.code;
92
+ }
93
+ if (locale.fallbackLocale) {
94
+ clientLocale.fallbackLocale = locale.fallbackLocale;
95
+ }
96
+ if (locale.label) {
97
+ clientLocale.label = locale.label;
98
+ }
99
+ if (locale.rtl) {
100
+ clientLocale.rtl = locale.rtl;
101
+ }
102
+ clientConfig.localization.locales.push(clientLocale);
103
+ }
104
+ }
105
+ }
106
+ }
107
+ break;
108
+ default:
109
+ clientConfig[key] = config[key];
35
110
  }
36
111
  }
37
- if ('i18n' in clientConfig && 'supportedLanguages' in clientConfig.i18n && clientConfig.i18n.supportedLanguages) {
38
- delete clientConfig.i18n.supportedLanguages;
39
- }
40
- if (!clientConfig.admin) {
41
- clientConfig.admin = {};
42
- }
43
- clientConfig.admin.components = null;
44
- if ('livePreview' in clientConfig.admin && clientConfig.admin.livePreview && 'url' in clientConfig.admin.livePreview) {
45
- delete clientConfig.admin.livePreview.url;
46
- }
47
- clientConfig.collections = createClientCollectionConfigs({
48
- collections: config.collections,
49
- defaultIDType: config.db.defaultIDType,
50
- i18n,
51
- importMap
52
- });
53
- clientConfig.globals = createClientGlobalConfigs({
54
- defaultIDType: config.db.defaultIDType,
55
- globals: config.globals,
56
- i18n,
57
- importMap
58
- });
59
112
  return clientConfig;
60
113
  };
61
114