@payloadcms/next 3.0.0-beta.67 → 3.0.0-beta.68

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.
@@ -1 +1 @@
1
- {"version":3,"file":"routeError.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/routeError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAG1E,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAKlC,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,CAAC,EAAE,GAAG,CAAC;IAAC,MAAM,EAAE,OAAO,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AA+D7E,eAAO,MAAM,UAAU,iDAKpB;IACD,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IAClD,GAAG,EAAE,QAAQ,CAAA;IACb,GAAG,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;CAC7B,sBA8DA,CAAA"}
1
+ {"version":3,"file":"routeError.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/routeError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAG1E,OAAO,EAAE,QAAQ,EAAqC,MAAM,SAAS,CAAA;AAKrE,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,CAAC,EAAE,GAAG,CAAC;IAAC,MAAM,EAAE,OAAO,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AA+D7E,eAAO,MAAM,UAAU,iDAKpB;IACD,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IAClD,GAAG,EAAE,QAAQ,CAAA;IACb,GAAG,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;CAC7B,sBA8DA,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import httpStatus from 'http-status';
2
- import { APIError } from 'payload';
2
+ import { APIError, APIErrorName, ValidationErrorName } from 'payload';
3
3
  import { getPayloadHMR } from '../../utilities/getPayloadHMR.js';
4
4
  import { headersWithCors } from '../../utilities/headersWithCors.js';
5
5
  const formatErrors = (incoming)=>{
@@ -8,7 +8,7 @@ const formatErrors = (incoming)=>{
8
8
  // Instead, get the prototype of the incoming error and check its constructor name
9
9
  const proto = Object.getPrototypeOf(incoming);
10
10
  // Payload 'ValidationError' and 'APIError'
11
- if ((proto.constructor.name === 'ValidationError' || proto.constructor.name === 'APIError') && incoming.data) {
11
+ if ((proto.constructor.name === ValidationErrorName || proto.constructor.name === APIErrorName) && incoming.data) {
12
12
  return {
13
13
  errors: [
14
14
  {
@@ -20,7 +20,7 @@ const formatErrors = (incoming)=>{
20
20
  };
21
21
  }
22
22
  // Mongoose 'ValidationError': https://mongoosejs.com/docs/api/error.html#Error.ValidationError
23
- if (proto.constructor.name === 'ValidationError' && 'errors' in incoming && incoming.errors) {
23
+ if (proto.constructor.name === ValidationErrorName && 'errors' in incoming && incoming.errors) {
24
24
  return {
25
25
  errors: Object.keys(incoming.errors).reduce((acc, key)=>{
26
26
  acc.push({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/routes/rest/routeError.ts"],"sourcesContent":["import type { Collection, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport httpStatus from 'http-status'\nimport { APIError } from 'payload'\n\nimport { getPayloadHMR } from '../../utilities/getPayloadHMR.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\n\nexport type ErrorResponse = { data?: any; errors: unknown[]; stack?: string }\n\nconst formatErrors = (incoming: { [key: string]: unknown } | APIError): ErrorResponse => {\n if (incoming) {\n // Cannot use `instanceof` to check error type: https://github.com/microsoft/TypeScript/issues/13965\n // Instead, get the prototype of the incoming error and check its constructor name\n const proto = Object.getPrototypeOf(incoming)\n\n // Payload 'ValidationError' and 'APIError'\n if (\n (proto.constructor.name === 'ValidationError' || proto.constructor.name === 'APIError') &&\n incoming.data\n ) {\n return {\n errors: [\n {\n name: incoming.name,\n data: incoming.data,\n message: incoming.message,\n },\n ],\n }\n }\n\n // Mongoose 'ValidationError': https://mongoosejs.com/docs/api/error.html#Error.ValidationError\n if (proto.constructor.name === 'ValidationError' && 'errors' in incoming && incoming.errors) {\n return {\n errors: Object.keys(incoming.errors).reduce((acc, key) => {\n acc.push({\n field: incoming.errors[key].path,\n message: incoming.errors[key].message,\n })\n return acc\n }, []),\n }\n }\n\n if (Array.isArray(incoming.message)) {\n return {\n errors: incoming.message,\n }\n }\n\n if (incoming.name) {\n return {\n errors: [\n {\n message: incoming.message,\n },\n ],\n }\n }\n }\n\n return {\n errors: [\n {\n message: 'An unknown error occurred.',\n },\n ],\n }\n}\n\nexport const routeError = async ({\n collection,\n config: configArg,\n err,\n req,\n}: {\n collection?: Collection\n config: Promise<SanitizedConfig> | SanitizedConfig\n err: APIError\n req: Partial<PayloadRequest>\n}) => {\n let payload = req?.payload\n\n if (!payload) {\n try {\n payload = await getPayloadHMR({ config: configArg })\n } catch (e) {\n return Response.json(\n {\n message: 'There was an error initializing Payload',\n },\n { status: httpStatus.INTERNAL_SERVER_ERROR },\n )\n }\n }\n\n req.payload = payload\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n const { config, logger } = payload\n\n let response = formatErrors(err)\n\n let status = err.status || httpStatus.INTERNAL_SERVER_ERROR\n\n logger.error(err.stack)\n\n // Internal server errors can contain anything, including potentially sensitive data.\n // Therefore, error details will be hidden from the response unless `config.debug` is `true`\n if (!config.debug && status === httpStatus.INTERNAL_SERVER_ERROR) {\n response = formatErrors(new APIError('Something went wrong.'))\n }\n\n if (config.debug && config.debug === true) {\n response.stack = err.stack\n }\n\n if (collection && typeof collection.config.hooks.afterError === 'function') {\n ;({ response, status } = collection.config.hooks.afterError(\n err,\n response,\n req?.context,\n collection.config,\n ) || { response, status })\n }\n\n if (typeof config.hooks.afterError === 'function') {\n ;({ response, status } = config.hooks.afterError(\n err,\n response,\n req?.context,\n collection?.config,\n ) || {\n response,\n status,\n })\n }\n\n return Response.json(response, { headers, status })\n}\n"],"names":["httpStatus","APIError","getPayloadHMR","headersWithCors","formatErrors","incoming","proto","Object","getPrototypeOf","constructor","name","data","errors","message","keys","reduce","acc","key","push","field","path","Array","isArray","routeError","collection","config","configArg","err","req","payload","e","Response","json","status","INTERNAL_SERVER_ERROR","headers","Headers","logger","response","error","stack","debug","hooks","afterError","context"],"mappings":"AAEA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,QAAQ,QAAQ,UAAS;AAElC,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,eAAe,QAAQ,qCAAoC;AAIpE,MAAMC,eAAe,CAACC;IACpB,IAAIA,UAAU;QACZ,oGAAoG;QACpG,kFAAkF;QAClF,MAAMC,QAAQC,OAAOC,cAAc,CAACH;QAEpC,2CAA2C;QAC3C,IACE,AAACC,CAAAA,MAAMG,WAAW,CAACC,IAAI,KAAK,qBAAqBJ,MAAMG,WAAW,CAACC,IAAI,KAAK,UAAS,KACrFL,SAASM,IAAI,EACb;YACA,OAAO;gBACLC,QAAQ;oBACN;wBACEF,MAAML,SAASK,IAAI;wBACnBC,MAAMN,SAASM,IAAI;wBACnBE,SAASR,SAASQ,OAAO;oBAC3B;iBACD;YACH;QACF;QAEA,+FAA+F;QAC/F,IAAIP,MAAMG,WAAW,CAACC,IAAI,KAAK,qBAAqB,YAAYL,YAAYA,SAASO,MAAM,EAAE;YAC3F,OAAO;gBACLA,QAAQL,OAAOO,IAAI,CAACT,SAASO,MAAM,EAAEG,MAAM,CAAC,CAACC,KAAKC;oBAChDD,IAAIE,IAAI,CAAC;wBACPC,OAAOd,SAASO,MAAM,CAACK,IAAI,CAACG,IAAI;wBAChCP,SAASR,SAASO,M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B;IAEA,IAAIhB,cAAc,OAAOA,WAAWC,MAAM,CAACiB,KAAK,CAACC,UAAU,KAAK,YAAY;QACxE,CAAA,EAAEL,QAAQ,EAAEL,MAAM,EAAE,GAAGT,WAAWC,MAAM,CAACiB,KAAK,CAACC,UAAU,CACzDhB,KACAW,UACAV,KAAKgB,SACLpB,WAAWC,MAAM,KACd;YAAEa;YAAUL;QAAO,CAAA;IAC1B;IAEA,IAAI,OAAOR,OAAOiB,KAAK,CAACC,UAAU,KAAK,YAAY;QAC/C,CAAA,EAAEL,QAAQ,EAAEL,MAAM,EAAE,GAAGR,OAAOiB,KAAK,CAACC,UAAU,CAC9ChB,KACAW,UACAV,KAAKgB,SACLpB,YAAYC,WACT;YACHa;YACAL;QACF,CAAA;IACF;IAEA,OAAOF,SAASC,IAAI,CAACM,UAAU;QAAEH;QAASF;IAAO;AACnD,EAAC"}
1
+ {"version":3,"sources":["../../../src/routes/rest/routeError.ts"],"sourcesContent":["import type { Collection, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport httpStatus from 'http-status'\nimport { APIError, APIErrorName, ValidationErrorName } from 'payload'\n\nimport { getPayloadHMR } from '../../utilities/getPayloadHMR.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\n\nexport type ErrorResponse = { data?: any; errors: unknown[]; stack?: string }\n\nconst formatErrors = (incoming: { [key: string]: unknown } | APIError): ErrorResponse => {\n if (incoming) {\n // Cannot use `instanceof` to check error type: https://github.com/microsoft/TypeScript/issues/13965\n // Instead, get the prototype of the incoming error and check its constructor name\n const proto = Object.getPrototypeOf(incoming)\n\n // Payload 'ValidationError' and 'APIError'\n if (\n (proto.constructor.name === ValidationErrorName || proto.constructor.name === APIErrorName) &&\n incoming.data\n ) {\n return {\n errors: [\n {\n name: incoming.name,\n data: incoming.data,\n message: incoming.message,\n },\n ],\n }\n }\n\n // Mongoose 'ValidationError': https://mongoosejs.com/docs/api/error.html#Error.ValidationError\n if (proto.constructor.name === ValidationErrorName && 'errors' in incoming && incoming.errors) {\n return {\n errors: Object.keys(incoming.errors).reduce((acc, key) => {\n acc.push({\n field: incoming.errors[key].path,\n message: incoming.errors[key].message,\n })\n return acc\n }, []),\n }\n }\n\n if (Array.isArray(incoming.message)) {\n return {\n errors: incoming.message,\n }\n }\n\n if (incoming.name) {\n return {\n errors: [\n {\n message: incoming.message,\n },\n ],\n }\n }\n }\n\n return {\n errors: [\n {\n message: 'An unknown error occurred.',\n },\n ],\n }\n}\n\nexport const routeError = async ({\n collection,\n config: configArg,\n err,\n req,\n}: {\n collection?: Collection\n config: Promise<SanitizedConfig> | SanitizedConfig\n err: APIError\n req: Partial<PayloadRequest>\n}) => {\n let payload = req?.payload\n\n if (!payload) {\n try {\n payload = await getPayloadHMR({ config: configArg })\n } catch (e) {\n return Response.json(\n {\n message: 'There was an error initializing Payload',\n },\n { status: httpStatus.INTERNAL_SERVER_ERROR },\n )\n }\n }\n\n req.payload = payload\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n const { config, logger } = payload\n\n let response = formatErrors(err)\n\n let status = err.status || httpStatus.INTERNAL_SERVER_ERROR\n\n logger.error(err.stack)\n\n // Internal server errors can contain anything, including potentially sensitive data.\n // Therefore, error details will be hidden from the response unless `config.debug` is `true`\n if (!config.debug && status === httpStatus.INTERNAL_SERVER_ERROR) {\n response = formatErrors(new APIError('Something went wrong.'))\n }\n\n if (config.debug && config.debug === true) {\n response.stack = err.stack\n }\n\n if (collection && typeof collection.config.hooks.afterError === 'function') {\n ;({ response, status } = collection.config.hooks.afterError(\n err,\n response,\n req?.context,\n collection.config,\n ) || { response, status })\n }\n\n if (typeof config.hooks.afterError === 'function') {\n ;({ response, status } = config.hooks.afterError(\n err,\n response,\n req?.context,\n collection?.config,\n ) || {\n response,\n status,\n })\n }\n\n return Response.json(response, { headers, status })\n}\n"],"names":["httpStatus","APIError","APIErrorName","ValidationErrorName","getPayloadHMR","headersWithCors","formatErrors","incoming","proto","Object","getPrototypeOf","constructor","name","data","errors","message","keys","reduce","acc","key","push","field","path","Array","isArray","routeError","collection","config","configArg","err","req","payload","e","Response","json","status","INTERNAL_SERVER_ERROR","headers","Headers","logger","response","error","stack","debug","hooks","afterError","context"],"mappings":"AAEA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,QAAQ,EAAEC,YAAY,EAAEC,mBAAmB,QAAQ,UAAS;AAErE,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,eAAe,QAAQ,qCAAoC;AAIpE,MAAMC,eAAe,CAACC;IACpB,IAAIA,UAAU;QACZ,oGAAoG;QACpG,kFAAkF;QAClF,MAAMC,QAAQC,OAAOC,cAAc,CAACH;QAEpC,2CAA2C;QAC3C,IACE,AAACC,CAAAA,MAAMG,WAAW,CAACC,IAAI,KAAKT,uBAAuBK,MAAMG,WAAW,CAACC,IAAI,KAAKV,YAAW,KACzFK,SAASM,IAAI,EACb;YACA,OAAO;gBACLC,QAAQ;oBACN;wBACEF,MAAML,SAASK,IAAI;wBACnBC,MAAMN,SAASM,IAAI;wBACnBE,SAASR,SAASQ,OAAO;oBAC3B;iBACD;YACH;QACF;QAEA,+FAA+F;QAC/F,IAAIP,MAAMG,WAAW,CAACC,IAAI,KAAKT,uBAAuB,YAAYI,YAAYA,SAASO,MAAM,EAAE;YAC7F,OAAO;gBACLA,QAAQL,OAAOO,IAAI,CAACT,SAASO,MAAM,EAAEG,MAAM,CAAC,CAACC,KAAKC;oBAChDD,IAAIE,IAAI,CAAC;wBACPC,OAAOd,SAASO,MAAM,CAACK,IAAI,CAACG,IAAI;wBAChCP,SAASR,SAASO,MAAM,CAACK,IAAI,CAACJ,OAAO;oBACvC;oBACA,OAAOG;gBACT,GAAG,EAAE;YACP;QACF;QAEA,IAAIK,MAAMC,OAAO,CAACjB,SAASQ,OAAO,GAAG;YACnC,OAAO;gBACLD,QAAQP,SAASQ,OAAO;YAC1B;QACF;QAEA,IAAIR,SAASK,IAAI,EAAE;YACjB,OAAO;gBACLE,QAAQ;oBACN;wBACEC,S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1B;IAEA,IAAI,OAAOR,OAAOiB,KAAK,CAACC,UAAU,KAAK,YAAY;QAC/C,CAAA,EAAEL,QAAQ,EAAEL,MAAM,EAAE,GAAGR,OAAOiB,KAAK,CAACC,UAAU,CAC9ChB,KACAW,UACAV,KAAKgB,SACLpB,YAAYC,WACT;YACHa;YACAL;QACF,CAAA;IACF;IAEA,OAAOF,SAASC,IAAI,CAACM,UAAU;QAAEH;QAASF;IAAO;AACnD,EAAC"}
@@ -1,6 +1,9 @@
1
1
  import React from 'react';
2
2
  import './index.scss';
3
3
  export declare const LoginForm: React.FC<{
4
+ prefillEmail?: string;
5
+ prefillPassword?: string;
6
+ prefillUsername?: string;
4
7
  searchParams: {
5
8
  [key: string]: string | string[] | undefined;
6
9
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Login/LoginForm/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAA;AAazB,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;IAC/B,YAAY,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAA;KAAE,CAAA;CAC/D,CA0FA,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Login/LoginForm/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAA;AAazB,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,YAAY,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAA;KAAE,CAAA;CAC/D,CAuFA,CAAA"}
@@ -7,9 +7,9 @@ const Link = LinkImport.default || LinkImport;
7
7
  import { Form, FormSubmit, PasswordField, useConfig, useTranslation } from '@payloadcms/ui';
8
8
  import { password } from 'payload/shared';
9
9
  import { LoginField } from '../LoginField/index.js';
10
- export const LoginForm = ({ searchParams })=>{
10
+ export const LoginForm = ({ prefillEmail, prefillPassword, prefillUsername, searchParams })=>{
11
11
  const config = useConfig();
12
- const { admin: { autoLogin, routes: { forgot: forgotRoute }, user: userSlug }, routes: { admin, api } } = config;
12
+ const { admin: { routes: { forgot: forgotRoute }, user: userSlug }, routes: { admin, api } } = config;
13
13
  const collectionConfig = config.collections?.find((collection)=>collection?.slug === userSlug);
14
14
  const { auth: authOptions } = collectionConfig;
15
15
  const loginWithUsername = authOptions.loginWithUsername;
@@ -21,25 +21,24 @@ export const LoginForm = ({ searchParams })=>{
21
21
  return 'email';
22
22
  });
23
23
  const { t } = useTranslation();
24
- const prefillForm = autoLogin && autoLogin.prefillOnly;
25
24
  const initialState = {
26
25
  password: {
27
- initialValue: prefillForm ? autoLogin.password : undefined,
26
+ initialValue: prefillPassword ?? undefined,
28
27
  valid: true,
29
- value: prefillForm ? autoLogin.password : undefined
28
+ value: prefillPassword ?? undefined
30
29
  }
31
30
  };
32
31
  if (loginWithUsername) {
33
32
  initialState.username = {
34
- initialValue: prefillForm ? autoLogin.username : undefined,
33
+ initialValue: prefillUsername ?? undefined,
35
34
  valid: true,
36
- value: prefillForm ? autoLogin.username : undefined
35
+ value: prefillUsername ?? undefined
37
36
  };
38
37
  } else {
39
38
  initialState.email = {
40
- initialValue: prefillForm ? autoLogin.email : undefined,
39
+ initialValue: prefillEmail ?? undefined,
41
40
  valid: true,
42
- value: prefillForm ? autoLogin.email : undefined
41
+ value: prefillEmail ?? undefined
43
42
  };
44
43
  }
45
44
  return /*#__PURE__*/ _jsxs(Form, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/views/Login/LoginForm/index.tsx"],"sourcesContent":["'use client'\n\nimport LinkImport from 'next/link.js'\nimport React from 'react'\n\nconst baseClass = 'login__form'\nconst Link = (LinkImport.default || LinkImport) as unknown as typeof LinkImport.default\n\nimport type { FormState, PayloadRequest } from 'payload'\n\nimport { Form, FormSubmit, PasswordField, useConfig, useTranslation } from '@payloadcms/ui'\nimport { password } from 'payload/shared'\n\nimport type { LoginFieldProps } from '../LoginField/index.js'\n\nimport { LoginField } from '../LoginField/index.js'\nimport './index.scss'\n\nexport const LoginForm: React.FC<{\n searchParams: { [key: string]: string | string[] | undefined }\n}> = ({ searchParams }) => {\n const config = useConfig()\n\n const {\n admin: {\n autoLogin,\n routes: { forgot: forgotRoute },\n user: userSlug,\n },\n routes: { admin, api },\n } = config\n\n const collectionConfig = config.collections?.find((collection) => collection?.slug === userSlug)\n const { auth: authOptions } = collectionConfig\n const loginWithUsername = authOptions.loginWithUsername\n const canLoginWithEmail =\n !authOptions.loginWithUsername || authOptions.loginWithUsername.allowEmailLogin\n const canLoginWithUsername = authOptions.loginWithUsername\n\n const [loginType] = React.useState<LoginFieldProps['type']>(() => {\n if (canLoginWithEmail && canLoginWithUsername) return 'emailOrUsername'\n if (canLoginWithUsername) return 'username'\n return 'email'\n })\n\n const { t } = useTranslation()\n\n const prefillForm = autoLogin && autoLogin.prefillOnly\n\n const initialState: FormState = {\n password: {\n initialValue: prefillForm ? autoLogin.password : undefined,\n valid: true,\n value: prefillForm ? autoLogin.password : undefined,\n },\n }\n\n if (loginWithUsername) {\n initialState.username = {\n initialValue: prefillForm ? autoLogin.username : undefined,\n valid: true,\n value: prefillForm ? autoLogin.username : undefined,\n }\n } else {\n initialState.email = {\n initialValue: prefillForm ? autoLogin.email : undefined,\n valid: true,\n value: prefillForm ? autoLogin.email : undefined,\n }\n }\n\n return (\n <Form\n action={`${api}/${userSlug}/login`}\n className={baseClass}\n disableSuccessStatus\n initialState={initialState}\n method=\"POST\"\n redirect={typeof searchParams?.redirect === 'string' ? searchParams.redirect : admin}\n waitForAutocomplete\n >\n <div className={`${baseClass}__inputWrap`}>\n <LoginField type={loginType} />\n <PasswordField\n autoComplete=\"off\"\n label={t('general:password')}\n name=\"password\"\n required\n validate={(value) =>\n password(value, {\n name: 'password',\n type: 'text',\n data: {},\n preferences: { fields: {} },\n req: {\n payload: {\n config,\n },\n t,\n } as PayloadRequest,\n required: true,\n siblingData: {},\n })\n }\n />\n </div>\n <Link href={`${admin}${forgotRoute}`}>{t('authentication:forgotPasswordQuestion')}</Link>\n <FormSubmit>{t('authentication:login')}</FormSubmit>\n </Form>\n )\n}\n"],"names":["LinkImport","React","baseClass","Link","default","Form","FormSubmit","PasswordField","useConfig","useTranslation","password","LoginField","LoginForm","searchParams","config","admin","autoLogin","routes","forgot","forgotRoute","user","userSlug","api","collectionConfig","collections","find","collection","slug","auth","authOptions","loginWithUsername","canLoginWithEmail","allowEmailLogin","canLoginWithUsername","loginType","useState","t","prefillForm","prefillOnly","initialState","initialValue","undefined","valid","value","username","email","action","className","disableSuccessStatus","method","redirect","waitForAutocomplete","div","type","autoComplete","label","name","required","validate","data","preferences","fields","req","payload","siblingData","href"],"mappings":"AAAA;;AAEA,OAAOA,gBAAgB,eAAc;AACrC,OAAOC,WAAW,QAAO;AAEzB,MAAMC,YAAY;AAClB,MAAMC,OAAQH,WAAWI,OAAO,IAAIJ;AAIpC,SAASK,IAAI,EAAEC,UAAU,EAAEC,aAAa,EAAEC,SAAS,EAAEC,cAAc,QAAQ,iBAAgB;AAC3F,SAASC,QAAQ,QAAQ,iBAAgB;AAIzC,SAASC,UAAU,QAAQ,yBAAwB;AAGnD,OAAO,MAAMC,YAER,CAAC,EAAEC,YAAY,EAAE;IACpB,MAAMC,SAASN;IAEf,MAAM,EACJO,OAAO,EACLC,SAAS,EACTC,QAAQ,EAAEC,QAAQC,WAAW,EAAE,EAC/BC,MAAMC,QAAQ,EACf,EACDJ,QAAQ,EAAEF,KAAK,EAAEO,GAAG,EAAE,EACvB,GAAGR;IAEJ,MAAMS,mBAAmBT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;kCACvC,KAACS;wBAAW0C,MAAMnB;;kCAClB,KAAC3B;wBACC+C,cAAa;wBACbC,OAAOnB,EAAE;wBACToB,MAAK;wBACLC,QAAQ;wBACRC,UAAU,CAACf,QACTjC,SAASiC,OAAO;gCACda,MAAM;gCACNH,MAAM;gCACNM,MAAM,CAAC;gCACPC,aAAa;oCAAEC,QAAQ,CAAC;gCAAE;gCAC1BC,KAAK;oCACHC,SAAS;wCACPjD;oCACF;oCACAsB;gCACF;gCACAqB,UAAU;gCACVO,aAAa,CAAC;4BAChB;;;;0BAIN,KAAC7D;gBAAK8D,MAAM,CAAC,EAAElD,MAAM,EAAEI,YAAY,CAAC;0BAAGiB,EAAE;;0BACzC,KAAC9B;0BAAY8B,EAAE;;;;AAGrB,EAAC"}
1
+ {"version":3,"sources":["../../../../src/views/Login/LoginForm/index.tsx"],"sourcesContent":["'use client'\n\nimport LinkImport from 'next/link.js'\nimport React from 'react'\n\nconst baseClass = 'login__form'\nconst Link = (LinkImport.default || LinkImport) as unknown as typeof LinkImport.default\n\nimport type { FormState, PayloadRequest } from 'payload'\n\nimport { Form, FormSubmit, PasswordField, useConfig, useTranslation } from '@payloadcms/ui'\nimport { password } from 'payload/shared'\n\nimport type { LoginFieldProps } from '../LoginField/index.js'\n\nimport { LoginField } from '../LoginField/index.js'\nimport './index.scss'\n\nexport const LoginForm: React.FC<{\n prefillEmail?: string\n prefillPassword?: string\n prefillUsername?: string\n searchParams: { [key: string]: string | string[] | undefined }\n}> = ({ prefillEmail, prefillPassword, prefillUsername, searchParams }) => {\n const config = useConfig()\n\n const {\n admin: {\n routes: { forgot: forgotRoute },\n user: userSlug,\n },\n routes: { admin, api },\n } = config\n\n const collectionConfig = config.collections?.find((collection) => collection?.slug === userSlug)\n const { auth: authOptions } = collectionConfig\n const loginWithUsername = authOptions.loginWithUsername\n const canLoginWithEmail =\n !authOptions.loginWithUsername || authOptions.loginWithUsername.allowEmailLogin\n const canLoginWithUsername = authOptions.loginWithUsername\n\n const [loginType] = React.useState<LoginFieldProps['type']>(() => {\n if (canLoginWithEmail && canLoginWithUsername) return 'emailOrUsername'\n if (canLoginWithUsername) return 'username'\n return 'email'\n })\n\n const { t } = useTranslation()\n\n const initialState: FormState = {\n password: {\n initialValue: prefillPassword ?? undefined,\n valid: true,\n value: prefillPassword ?? undefined,\n },\n }\n\n if (loginWithUsername) {\n initialState.username = {\n initialValue: prefillUsername ?? undefined,\n valid: true,\n value: prefillUsername ?? undefined,\n }\n } else {\n initialState.email = {\n initialValue: prefillEmail ?? undefined,\n valid: true,\n value: prefillEmail ?? undefined,\n }\n }\n\n return (\n <Form\n action={`${api}/${userSlug}/login`}\n className={baseClass}\n disableSuccessStatus\n initialState={initialState}\n method=\"POST\"\n redirect={typeof searchParams?.redirect === 'string' ? searchParams.redirect : admin}\n waitForAutocomplete\n >\n <div className={`${baseClass}__inputWrap`}>\n <LoginField type={loginType} />\n <PasswordField\n autoComplete=\"off\"\n label={t('general:password')}\n name=\"password\"\n required\n validate={(value) =>\n password(value, {\n name: 'password',\n type: 'text',\n data: {},\n preferences: { fields: {} },\n req: {\n payload: {\n config,\n },\n t,\n } as PayloadRequest,\n required: true,\n siblingData: {},\n })\n }\n />\n </div>\n <Link href={`${admin}${forgotRoute}`}>{t('authentication:forgotPasswordQuestion')}</Link>\n <FormSubmit>{t('authentication:login')}</FormSubmit>\n </Form>\n )\n}\n"],"names":["LinkImport","React","baseClass","Link","default","Form","FormSubmit","PasswordField","useConfig","useTranslation","password","LoginField","LoginForm","prefillEmail","prefillPassword","prefillUsername","searchParams","config","admin","routes","forgot","forgotRoute","user","userSlug","api","collectionConfig","collections","find","collection","slug","auth","authOptions","loginWithUsername","canLoginWithEmail","allowEmailLogin","canLoginWithUsername","loginType","useState","t","initialState","initialValue","undefined","valid","value","username","email","action","className","disableSuccessStatus","method","redirect","waitForAutocomplete","div","type","autoComplete","label","name","required","validate","data","preferences","fields","req","payload","siblingData","href"],"mappings":"AAAA;;AAEA,OAAOA,gBAA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AaM,KAAK,GAAG;YACnBL,cAAc3B,gBAAgB4B;YAC9BC,OAAO;YACPC,OAAO9B,gBAAgB4B;QACzB;IACF;IAEA,qBACE,MAACpC;QACCyC,QAAQ,CAAC,EAAEtB,IAAI,CAAC,EAAED,SAAS,MAAM,CAAC;QAClCwB,WAAW7C;QACX8C,oBAAoB;QACpBT,cAAcA;QACdU,QAAO;QACPC,UAAU,OAAOlC,cAAckC,aAAa,WAAWlC,aAAakC,QAAQ,GAAGhC;QAC/EiC,mBAAmB;;0BAEnB,MAACC;gBAAIL,WAAW,CAAC,EAAE7C,UAAU,WAAW,CAAC;;kCACvC,KAACS;wBAAW0C,MAAMjB;;kCAClB,KAAC7B;wBACC+C,cAAa;wBACbC,OAAOjB,EAAE;wBACTkB,MAAK;wBACLC,QAAQ;wBACRC,UAAU,CAACf,QACTjC,SAASiC,OAAO;gCACda,MAAM;gCACNH,MAAM;gCACNM,MAAM,CAAC;gCACPC,aAAa;oCAAEC,QAAQ,CAAC;gCAAE;gCAC1BC,KAAK;oCACHC,SAAS;wCACP9C;oCACF;oCACAqB;gCACF;gCACAmB,UAAU;gCACVO,aAAa,CAAC;4BAChB;;;;0BAIN,KAAC7D;gBAAK8D,MAAM,CAAC,EAAE/C,MAAM,EAAEG,YAAY,CAAC;0BAAGiB,EAAE;;0BACzC,KAAChC;0BAAYgC,EAAE;;;;AAGrB,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Login/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,OAAO,KAAmB,MAAM,OAAO,CAAA;AAIvC,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AAEjD,eAAO,MAAM,cAAc,UAAU,CAAA;AAErC,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA4E9C,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Login/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7C,OAAO,KAAmB,MAAM,OAAO,CAAA;AAIvC,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AAEjD,eAAO,MAAM,cAAc,UAAU,CAAA;AAErC,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAqG9C,CAAA"}
@@ -38,6 +38,10 @@ export const LoginView = ({ initPageResult, params, searchParams })=>{
38
38
  redirect(admin);
39
39
  }
40
40
  const collectionConfig = collections.find(({ slug })=>slug === userSlug);
41
+ const prefillAutoLogin = typeof config.admin?.autoLogin === 'object' && config.admin?.autoLogin.prefillOnly;
42
+ const prefillUsername = prefillAutoLogin && typeof config.admin?.autoLogin === 'object' ? config.admin?.autoLogin.username : undefined;
43
+ const prefillEmail = prefillAutoLogin && typeof config.admin?.autoLogin === 'object' ? config.admin?.autoLogin.email : undefined;
44
+ const prefillPassword = prefillAutoLogin && typeof config.admin?.autoLogin === 'object' ? config.admin?.autoLogin.password : undefined;
41
45
  return /*#__PURE__*/ _jsxs(Fragment, {
42
46
  children: [
43
47
  /*#__PURE__*/ _jsx("div", {
@@ -54,6 +58,9 @@ export const LoginView = ({ initPageResult, params, searchParams })=>{
54
58
  }),
55
59
  Array.isArray(BeforeLogins) && BeforeLogins.map((Component)=>Component),
56
60
  !collectionConfig?.auth?.disableLocalStrategy && /*#__PURE__*/ _jsx(LoginForm, {
61
+ prefillEmail: prefillEmail,
62
+ prefillPassword: prefillPassword,
63
+ prefillUsername: prefillUsername,
57
64
  searchParams: searchParams
58
65
  }),
59
66
  Array.isArray(AfterLogins) && AfterLogins.map((Component)=>Component)
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/views/Login/index.tsx"],"sourcesContent":["import type { AdminViewProps } from 'payload'\n\nimport { WithServerSideProps } from '@payloadcms/ui/shared'\nimport { redirect } from 'next/navigation.js'\nimport React, { Fragment } from 'react'\n\nimport { Logo } from '../../elements/Logo/index.js'\nimport { LoginForm } from './LoginForm/index.js'\nimport './index.scss'\n\nexport { generateLoginMetadata } from './meta.js'\n\nexport const loginBaseClass = 'login'\n\nexport const LoginView: React.FC<AdminViewProps> = ({ initPageResult, params, searchParams }) => {\n const { locale, permissions, req } = initPageResult\n\n const {\n i18n,\n payload: { config },\n payload,\n user,\n } = req\n\n const {\n admin: { components: { afterLogin, beforeLogin } = {}, user: userSlug },\n collections,\n routes: { admin },\n } = config\n\n const BeforeLogins = Array.isArray(beforeLogin)\n ? beforeLogin.map((Component, i) => (\n <WithServerSideProps\n Component={Component}\n key={i}\n serverOnlyProps={{\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n }}\n />\n ))\n : null\n\n const AfterLogins = Array.isArray(afterLogin)\n ? afterLogin.map((Component, i) => (\n <WithServerSideProps\n Component={Component}\n key={i}\n serverOnlyProps={{\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n }}\n />\n ))\n : null\n\n if (user) {\n redirect(admin)\n }\n\n const collectionConfig = collections.find(({ slug }) => slug === userSlug)\n\n return (\n <Fragment>\n <div className={`${loginBaseClass}__brand`}>\n <Logo\n i18n={i18n}\n locale={locale}\n params={params}\n payload={payload}\n permissions={permissions}\n searchParams={searchParams}\n user={user}\n />\n </div>\n {Array.isArray(BeforeLogins) && BeforeLogins.map((Component) => Component)}\n {!collectionConfig?.auth?.disableLocalStrategy && <LoginForm searchParams={searchParams} />}\n {Array.isArray(AfterLogins) && AfterLogins.map((Component) => Component)}\n </Fragment>\n )\n}\n"],"names":["WithServerSideProps","redirect","React","Fragment","Logo","LoginForm","generateLoginMetadata","loginBaseClass","LoginView","initPageResult","params","searchParams","locale","permissions","req","i18n","payload","config","user","admin","components","afterLogin","beforeLogin","userSlug","collections","routes","BeforeLogins","Array","isArray","map","Component","i","serverOnlyProps","AfterLogins","collectionConfig","find","slug","div","className","auth","disableLocalStrategy"],"mappings":";AAEA,SAASA,mBAAmB,QAAQ,wBAAuB;AAC3D,SAASC,QAAQ,QAAQ,qBAAoB;AAC7C,OAAOC,SAASC,QAAQ,QAAQ,QAAO;AAEvC,SAASC,IAAI,QAAQ,+BAA8B;AACnD,SAASC,SAAS,QAAQ,uBAAsB;AAGhD,SAASC,qBAAqB,QAAQ,YAAW;AAEjD,OAAO,MAAMC,iBAAiB,QAAO;AAErC,OAAO,MAAMC,YAAsC,CAAC,EAAEC,cAAc,EAAEC,MAAM,EAAEC,YAAY,EAAE;IAC1F,MAAM,EAAEC,MAAM,EAAEC,WAAW,EAAEC,GAAG,EAAE,GAAGL;IAErC,MAAM,EACJM,IAAI,EACJC,SAAS,EAAEC,MAAM,EAAE,EACnBD,OAAO,EACPE,IAAI,EACL,GAAGJ;IAEJ,MAAM,EACJK,OAAO,EAAEC,YAAY,EAAEC,UAAU,EAAEC,WAAW,EAAE,GAAG,CAAC,CAAC,EAAEJ,MAAMK,QAAQ,EAAE,EACvEC,WAAW,EACXC,QAAQ,EAAEN,KAAK,EAAE,EAClB,GAAGF;IAEJ,MAAMS,eAAeC,MAAMC,OAAO,CAACN,eAC/BA,YAAYO,GAAG,CAAC,CAACC,WAAWC,kBAC1B,KAAC/B;YACC8B,WAAWA;YAEXE,iBAAiB;gBACfjB;gBACAH;gBACAF;gBACAM;gBACAH;gBACAF;gBACAO;YACF;WATKa,MAYT;IAEJ,MAAME,cAAcN,MAAMC,OAAO,CAACP,cAC9BA,WAAWQ,GAAG,CAAC,CAACC,WAAWC,kBACzB,KAAC/B;YACC8B,WAAWA;YAEXE,iBAAiB;gBACfjB;gBACAH;gBACAF;gBACAM;gBACAH;gBACAF;gBACAO;YACF;WATKa,MAYT;IAEJ,IAAIb,MAAM;QACRjB,SAASkB;IACX;IAEA,MAAMe,mBAAmBV,YAAYW,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASb;IAEjE,qBACE,MAACpB;;0BACC,KAACkC;gBAAIC,WAAW,CAAC,EAAE/B,eAAe,OAAO,CAAC;0BACxC,cAAA,KAACH;oBACCW,MAAMA;oBACNH,QAAQA;oBACRF,QAAQA;oBACRM,SAASA;oBACTH,aAAaA;oBACbF,cAAcA;oBACdO,MAAMA;;;YAGTS,MAAMC,OAAO,CAACF,iBAAiBA,aAAaG,GAAG,CAAC,CAACC,YAAcA;YAC/D,CAACI,kBAAkBK,MAAMC,sCAAwB,KAACnC;gBAAUM,cAAcA;;YAC1EgB,MAAMC,OAAO,CAACK,gBAAgBA,YAAYJ,GAAG,CAAC,CAACC,YAAcA;;;AAGpE,EAAC"}
1
+ {"version":3,"sources":["../../../src/views/Login/index.tsx"],"sourcesContent":["import type { AdminViewProps } from 'payload'\n\nimport { WithServerSideProps } from '@payloadcms/ui/shared'\nimport { redirect } from 'next/navigation.js'\nimport React, { Fragment } from 'react'\n\nimport { Logo } from '../../elements/Logo/index.js'\nimport { LoginForm } from './LoginForm/index.js'\nimport './index.scss'\n\nexport { generateLoginMetadata } from './meta.js'\n\nexport const loginBaseClass = 'login'\n\nexport const LoginView: React.FC<AdminViewProps> = ({ initPageResult, params, searchParams }) => {\n const { locale, permissions, req } = initPageResult\n\n const {\n i18n,\n payload: { config },\n payload,\n user,\n } = req\n\n const {\n admin: { components: { afterLogin, beforeLogin } = {}, user: userSlug },\n collections,\n routes: { admin },\n } = config\n\n const BeforeLogins = Array.isArray(beforeLogin)\n ? beforeLogin.map((Component, i) => (\n <WithServerSideProps\n Component={Component}\n key={i}\n serverOnlyProps={{\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n }}\n />\n ))\n : null\n\n const AfterLogins = Array.isArray(afterLogin)\n ? afterLogin.map((Component, i) => (\n <WithServerSideProps\n Component={Component}\n key={i}\n serverOnlyProps={{\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n }}\n />\n ))\n : null\n\n if (user) {\n redirect(admin)\n }\n\n const collectionConfig = collections.find(({ slug }) => slug === userSlug)\n\n const prefillAutoLogin =\n typeof config.admin?.autoLogin === 'object' && config.admin?.autoLogin.prefillOnly\n\n const prefillUsername =\n prefillAutoLogin && typeof config.admin?.autoLogin === 'object'\n ? config.admin?.autoLogin.username\n : undefined\n\n const prefillEmail =\n prefillAutoLogin && typeof config.admin?.autoLogin === 'object'\n ? config.admin?.autoLogin.email\n : undefined\n\n const prefillPassword =\n prefillAutoLogin && typeof config.admin?.autoLogin === 'object'\n ? config.admin?.autoLogin.password\n : undefined\n\n return (\n <Fragment>\n <div className={`${loginBaseClass}__brand`}>\n <Logo\n i18n={i18n}\n locale={locale}\n params={params}\n payload={payload}\n permissions={permissions}\n searchParams={searchParams}\n user={user}\n />\n </div>\n {Array.isArray(BeforeLogins) && BeforeLogins.map((Component) => Component)}\n {!collectionConfig?.auth?.disableLocalStrategy && (\n <LoginForm\n prefillEmail={prefillEmail}\n prefillPassword={prefillPassword}\n prefillUsername={prefillUsername}\n searchParams={searchParams}\n />\n )}\n {Array.isArray(AfterLogins) && AfterLogins.map((Component) => Component)}\n </Fragment>\n )\n}\n"],"names":["WithServerSideProps","redirect","React","Fragment","Logo","LoginForm","generateLoginMetadata","loginBaseClass","LoginView","initPageResult","params","searchParams","locale","permissions","req","i18n","payload","config","user","admin","components","afterLogin","beforeLogin","userSlug","collections","routes","BeforeLogins","Array","isArray","map","Component","i","serverOnlyProps","AfterLogins","collectionConfig","find","slug","prefillAutoLogin","autoLogin","prefillOnly","prefillUsername","username","undefined","prefillEmail","email","prefillPassword","password","div","className","auth","disableLocalStrategy"],"mappings":";AAEA,SAASA,mBAAmB,QAAQ,wBAAuB;AAC3D,SAASC,QAAQ,QAAQ,qBAAoB;AAC7C,OAAOC,SAASC,QAAQ,QAAQ,QAAO;AAEvC,SAASC,IAAI,QAAQ,+BAA8B;AACnD,SAASC,SAAS,QAAQ,uBAAsB;AAGhD,SAASC,q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,KAAK,EAAEmB,cAAc,WACnDrB,OAAOE,KAAK,EAAEmB,UAAUM,QACxBF;IAEN,MAAMG,kBACJR,oBAAoB,OAAOpB,OAAOE,KAAK,EAAEmB,cAAc,WACnDrB,OAAOE,KAAK,EAAEmB,UAAUQ,WACxBJ;IAEN,qBACE,MAACvC;;0BACC,KAAC4C;gBAAIC,WAAW,CAAC,EAAEzC,eAAe,OAAO,CAAC;0BACxC,cAAA,KAACH;oBACCW,MAAMA;oBACNH,QAAQA;oBACRF,QAAQA;oBACRM,SAASA;oBACTH,aAAaA;oBACbF,cAAcA;oBACdO,MAAMA;;;YAGTS,MAAMC,OAAO,CAACF,iBAAiBA,aAAaG,GAAG,CAAC,CAACC,YAAcA;YAC/D,CAACI,kBAAkBe,MAAMC,sCACxB,KAAC7C;gBACCsC,cAAcA;gBACdE,iBAAiBA;gBACjBL,iBAAiBA;gBACjB7B,cAAcA;;YAGjBgB,MAAMC,OAAO,CAACK,gBAAgBA,YAAYJ,GAAG,CAAC,CAACC,YAAcA;;;AAGpE,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/next",
3
- "version": "3.0.0-beta.67",
3
+ "version": "3.0.0-beta.68",
4
4
  "homepage": "https://payloadcms.com",
5
5
  "repository": {
6
6
  "type": "git",
@@ -63,9 +63,9 @@
63
63
  "sonner": "^1.5.0",
64
64
  "uuid": "10.0.0",
65
65
  "ws": "^8.16.0",
66
- "@payloadcms/translations": "3.0.0-beta.67",
67
- "@payloadcms/ui": "3.0.0-beta.67",
68
- "@payloadcms/graphql": "3.0.0-beta.67"
66
+ "@payloadcms/graphql": "3.0.0-beta.68",
67
+ "@payloadcms/translations": "3.0.0-beta.68",
68
+ "@payloadcms/ui": "3.0.0-beta.68"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@next/eslint-plugin-next": "^14.1.0",
@@ -77,13 +77,13 @@
77
77
  "esbuild": "0.23.0",
78
78
  "esbuild-sass-plugin": "3.3.1",
79
79
  "swc-plugin-transform-remove-imports": "1.14.0",
80
- "@payloadcms/eslint-config": "3.0.0-beta.59",
81
- "payload": "3.0.0-beta.67"
80
+ "payload": "3.0.0-beta.68",
81
+ "@payloadcms/eslint-config": "3.0.0-beta.59"
82
82
  },
83
83
  "peerDependencies": {
84
84
  "graphql": "^16.8.1",
85
85
  "next": "^15.0.0-canary.53",
86
- "payload": "3.0.0-beta.67"
86
+ "payload": "3.0.0-beta.68"
87
87
  },
88
88
  "engines": {
89
89
  "node": "^18.20.2 || >=20.9.0"