@payloadcms/next 3.0.2-canary.935d33d → 3.0.2

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.
@@ -28,9 +28,9 @@ export function getRouteInfo({
28
28
  if (globalSlug) {
29
29
  globalConfig = config.globals.find(global => global.slug === globalSlug);
30
30
  }
31
- // If the collection has an ID field, we need to determine the type of the ID field
31
+ // If the collection is using a custom ID, we need to determine it's type
32
32
  if (collectionConfig && payload) {
33
- if (payload.collections?.[collectionSlug]) {
33
+ if (payload.collections?.[collectionSlug]?.customIDType) {
34
34
  idType = payload.collections?.[collectionSlug].customIDType;
35
35
  }
36
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"handleAdminPage.js","names":["getRouteWithoutAdmin","isAdminRoute","getRouteInfo","adminRoute","config","defaultIDType","payload","route","routeWithoutAdmin","routeSegments","split","filter","Boolean","entityType","entitySlug","createOrID","collectionSlug","undefined","globalSlug","collectionConfig","globalConfig","idType","collections","find","collection","slug","globals","global","customIDType","docID","Number"],"sources":["../../../src/utilities/initPage/handleAdminPage.ts"],"sourcesContent":["import type {\n Payload,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport { fieldAffectsData } from 'payload/shared'\n\nimport { getRouteWithoutAdmin, isAdminRoute } from './shared.js'\n\ntype Args = {\n adminRoute: string\n config: SanitizedConfig\n defaultIDType: Payload['db']['defaultIDType']\n payload?: Payload\n route: string\n}\n\ntype RouteInfo = {\n collectionConfig?: SanitizedCollectionConfig\n collectionSlug?: string\n docID?: number | string\n globalConfig?: SanitizedGlobalConfig\n globalSlug?: string\n}\n\nexport function getRouteInfo({\n adminRoute,\n config,\n defaultIDType,\n payload,\n route,\n}: Args): RouteInfo {\n if (isAdminRoute({ adminRoute, config, route })) {\n const routeWithoutAdmin = getRouteWithoutAdmin({ adminRoute, route })\n const routeSegments = routeWithoutAdmin.split('/').filter(Boolean)\n const [entityType, entitySlug, createOrID] = routeSegments\n const collectionSlug = entityType === 'collections' ? entitySlug : undefined\n const globalSlug = entityType === 'globals' ? entitySlug : undefined\n\n let collectionConfig: SanitizedCollectionConfig | undefined\n let globalConfig: SanitizedGlobalConfig | undefined\n let idType = defaultIDType\n\n if (collectionSlug) {\n collectionConfig = config.collections.find((collection) => collection.slug === collectionSlug)\n }\n\n if (globalSlug) {\n globalConfig = config.globals.find((global) => global.slug === globalSlug)\n }\n\n // If the collection has an ID field, we need to determine the type of the ID field\n if (collectionConfig && payload) {\n if (payload.collections?.[collectionSlug]) {\n idType = payload.collections?.[collectionSlug].customIDType\n }\n }\n\n const docID =\n collectionSlug && createOrID !== 'create'\n ? idType === 'number'\n ? Number(createOrID)\n : createOrID\n : undefined\n\n return {\n collectionConfig,\n collectionSlug,\n docID,\n globalConfig,\n globalSlug,\n }\n }\n\n return {}\n}\n"],"mappings":"AASA,SAASA,oBAAoB,EAAEC,YAAY,QAAQ;AAkBnD,OAAO,SAASC,aAAa;EAC3BC,UAAU;EACVC,MAAM;EACNC,aAAa;EACbC,OAAO;EACPC;AAAK,CACA;EACL,IAAIN,YAAA,CAAa;IAAEE,UAAA;IAAYC,MAAA;IAAQG;EAAM,IAAI;IAC/C,MAAMC,iBAAA,GAAoBR,oBAAA,CAAqB;MAAEG,UAAA;MAAYI;IAAM;IACnE,MAAME,aAAA,GAAgBD,iBAAA,CAAkBE,KAAK,CAAC,KAAKC,MAAM,CAACC,OAAA;IAC1D,MAAM,CAACC,UAAA,EAAYC,UAAA,EAAYC,UAAA,CAAW,GAAGN,aAAA;IAC7C,MAAMO,cAAA,GAAiBH,UAAA,KAAe,gBAAgBC,UAAA,GAAaG,SAAA;IACnE,MAAMC,UAAA,GAAaL,UAAA,KAAe,YAAYC,UAAA,GAAaG,SAAA;IAE3D,IAAIE,gBAAA;IACJ,IAAIC,YAAA;IACJ,IAAIC,MAAA,GAAShB,aAAA;IAEb,IAAIW,cAAA,EAAgB;MAClBG,gBAAA,GAAmBf,MAAA,CAAOkB,WAAW,CAACC,IAAI,CAAEC,UAAA,IAAeA,UAAA,CAAWC,IAAI,KAAKT,cAAA;IACjF;IAEA,IAAIE,UAAA,EAAY;MACdE,YAAA,GAAehB,MAAA,CAAOsB,OAAO,CAACH,IAAI,CAAEI,MAAA,IAAWA,MAAA,CAAOF,IAAI,KAAKP,UAAA;IACjE;IAEA;IACA,IAAIC,gBAAA,IAAoBb,OAAA,EAAS;MAC/B,IAAIA,OAAA,CAAQgB,WAAW,GAAGN,cAAA,CAAe,EAAE;QACzCK,MAAA,GAASf,OAAA,CAAQgB,WAAW,GAAGN,cAAA,CAAe,CAACY,YAAA;MACjD;IACF;IAEA,MAAMC,KAAA,GACJb,cAAA,IAAkBD,UAAA,KAAe,WAC7BM,MAAA,KAAW,WACTS,MAAA,CAAOf,UAAA,IACPA,UAAA,GACFE,SAAA;IAEN,OAAO;MACLE,gBAAA;MACAH,cAAA;MACAa,KAAA;MACAT,YAAA;MACAF;IACF;EACF;EAEA,OAAO,CAAC;AACV","ignoreList":[]}
1
+ {"version":3,"file":"handleAdminPage.js","names":["getRouteWithoutAdmin","isAdminRoute","getRouteInfo","adminRoute","config","defaultIDType","payload","route","routeWithoutAdmin","routeSegments","split","filter","Boolean","entityType","entitySlug","createOrID","collectionSlug","undefined","globalSlug","collectionConfig","globalConfig","idType","collections","find","collection","slug","globals","global","customIDType","docID","Number"],"sources":["../../../src/utilities/initPage/handleAdminPage.ts"],"sourcesContent":["import type {\n Payload,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport { fieldAffectsData } from 'payload/shared'\n\nimport { getRouteWithoutAdmin, isAdminRoute } from './shared.js'\n\ntype Args = {\n adminRoute: string\n config: SanitizedConfig\n defaultIDType: Payload['db']['defaultIDType']\n payload?: Payload\n route: string\n}\n\ntype RouteInfo = {\n collectionConfig?: SanitizedCollectionConfig\n collectionSlug?: string\n docID?: number | string\n globalConfig?: SanitizedGlobalConfig\n globalSlug?: string\n}\n\nexport function getRouteInfo({\n adminRoute,\n config,\n defaultIDType,\n payload,\n route,\n}: Args): RouteInfo {\n if (isAdminRoute({ adminRoute, config, route })) {\n const routeWithoutAdmin = getRouteWithoutAdmin({ adminRoute, route })\n const routeSegments = routeWithoutAdmin.split('/').filter(Boolean)\n const [entityType, entitySlug, createOrID] = routeSegments\n const collectionSlug = entityType === 'collections' ? entitySlug : undefined\n const globalSlug = entityType === 'globals' ? entitySlug : undefined\n\n let collectionConfig: SanitizedCollectionConfig | undefined\n let globalConfig: SanitizedGlobalConfig | undefined\n let idType = defaultIDType\n\n if (collectionSlug) {\n collectionConfig = config.collections.find((collection) => collection.slug === collectionSlug)\n }\n\n if (globalSlug) {\n globalConfig = config.globals.find((global) => global.slug === globalSlug)\n }\n\n // If the collection is using a custom ID, we need to determine it's type\n if (collectionConfig && payload) {\n if (payload.collections?.[collectionSlug]?.customIDType) {\n idType = payload.collections?.[collectionSlug].customIDType\n }\n }\n\n const docID =\n collectionSlug && createOrID !== 'create'\n ? idType === 'number'\n ? Number(createOrID)\n : createOrID\n : undefined\n\n return {\n collectionConfig,\n collectionSlug,\n docID,\n globalConfig,\n globalSlug,\n }\n }\n\n return {}\n}\n"],"mappings":"AASA,SAASA,oBAAoB,EAAEC,YAAY,QAAQ;AAkBnD,OAAO,SAASC,aAAa;EAC3BC,UAAU;EACVC,MAAM;EACNC,aAAa;EACbC,OAAO;EACPC;AAAK,CACA;EACL,IAAIN,YAAA,CAAa;IAAEE,UAAA;IAAYC,MAAA;IAAQG;EAAM,IAAI;IAC/C,MAAMC,iBAAA,GAAoBR,oBAAA,CAAqB;MAAEG,UAAA;MAAYI;IAAM;IACnE,MAAME,aAAA,GAAgBD,iBAAA,CAAkBE,KAAK,CAAC,KAAKC,MAAM,CAACC,OAAA;IAC1D,MAAM,CAACC,UAAA,EAAYC,UAAA,EAAYC,UAAA,CAAW,GAAGN,aAAA;IAC7C,MAAMO,cAAA,GAAiBH,UAAA,KAAe,gBAAgBC,UAAA,GAAaG,SAAA;IACnE,MAAMC,UAAA,GAAaL,UAAA,KAAe,YAAYC,UAAA,GAAaG,SAAA;IAE3D,IAAIE,gBAAA;IACJ,IAAIC,YAAA;IACJ,IAAIC,MAAA,GAAShB,aAAA;IAEb,IAAIW,cAAA,EAAgB;MAClBG,gBAAA,GAAmBf,MAAA,CAAOkB,WAAW,CAACC,IAAI,CAAEC,UAAA,IAAeA,UAAA,CAAWC,IAAI,KAAKT,cAAA;IACjF;IAEA,IAAIE,UAAA,EAAY;MACdE,YAAA,GAAehB,MAAA,CAAOsB,OAAO,CAACH,IAAI,CAAEI,MAAA,IAAWA,MAAA,CAAOF,IAAI,KAAKP,UAAA;IACjE;IAEA;IACA,IAAIC,gBAAA,IAAoBb,OAAA,EAAS;MAC/B,IAAIA,OAAA,CAAQgB,WAAW,GAAGN,cAAA,CAAe,EAAEY,YAAA,EAAc;QACvDP,MAAA,GAASf,OAAA,CAAQgB,WAAW,GAAGN,cAAA,CAAe,CAACY,YAAA;MACjD;IACF;IAEA,MAAMC,KAAA,GACJb,cAAA,IAAkBD,UAAA,KAAe,WAC7BM,MAAA,KAAW,WACTS,MAAA,CAAOf,UAAA,IACPA,UAAA,GACFE,SAAA;IAEN,OAAO;MACLE,gBAAA;MACAH,cAAA;MACAa,KAAA;MACAT,YAAA;MACAF;IACF;EACF;EAEA,OAAO,CAAC;AACV","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"getDocumentPermissions.d.ts","sourceRoot":"","sources":["../../../src/views/Document/getDocumentPermissions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EAEJ,cAAc,EACd,yBAAyB,EACzB,4BAA4B,EAC5B,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAQhB,eAAO,MAAM,sBAAsB,SAAgB;IACjD,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,IAAI,EAAE,IAAI,CAAA;IACV,YAAY,CAAC,EAAE,qBAAqB,CAAA;IACpC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,OAAO,CAAC;IACV,cAAc,EAAE,4BAA4B,CAAA;IAC5C,oBAAoB,EAAE,OAAO,CAAA;IAC7B,iBAAiB,EAAE,OAAO,CAAA;CAC3B,CAyFA,CAAA"}
1
+ {"version":3,"file":"getDocumentPermissions.d.ts","sourceRoot":"","sources":["../../../src/views/Document/getDocumentPermissions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,cAAc,EACd,yBAAyB,EACzB,4BAA4B,EAC5B,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAQhB,eAAO,MAAM,sBAAsB,SAAgB;IACjD,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,IAAI,EAAE,IAAI,CAAA;IACV,YAAY,CAAC,EAAE,qBAAqB,CAAA;IACpC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,OAAO,CAAC;IACV,cAAc,EAAE,4BAA4B,CAAA;IAC5C,oBAAoB,EAAE,OAAO,CAAA;IAC7B,iBAAiB,EAAE,OAAO,CAAA;CAC3B,CAqFA,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { hasSavePermission as getHasSavePermission, isEditing as getIsEditing } from '@payloadcms/ui/shared';
2
- import { docAccessOperation, docAccessOperationGlobal, sanitizePermissions } from 'payload';
2
+ import { docAccessOperation, docAccessOperationGlobal } from 'payload';
3
3
  export const getDocumentPermissions = async args => {
4
4
  const {
5
5
  id,
@@ -38,9 +38,7 @@ export const getDocumentPermissions = async args => {
38
38
  _status: 'published'
39
39
  }
40
40
  }
41
- }).then(({
42
- update
43
- }) => update?.permission);
41
+ }).then(permissions => permissions.update);
44
42
  }
45
43
  } catch (error) {
46
44
  req.payload.logger.error(error);
@@ -65,22 +63,15 @@ export const getDocumentPermissions = async args => {
65
63
  _status: 'published'
66
64
  }
67
65
  }
68
- }).then(({
69
- update
70
- }) => update?.permission);
66
+ }).then(permissions => permissions.update);
71
67
  }
72
68
  } catch (error) {
73
69
  req.payload.logger.error(error);
74
70
  }
75
71
  }
76
- // TODO: do this in a better way. Only doing this bc this is how the fn was written (mutates the original object)
77
- const sanitizedDocPermissions = {
78
- ...docPermissions
79
- };
80
- sanitizePermissions(sanitizedDocPermissions);
81
72
  const hasSavePermission = getHasSavePermission({
82
73
  collectionSlug: collectionConfig?.slug,
83
- docPermissions: sanitizedDocPermissions,
74
+ docPermissions,
84
75
  globalSlug: globalConfig?.slug,
85
76
  isEditing: getIsEditing({
86
77
  id,
@@ -89,7 +80,7 @@ export const getDocumentPermissions = async args => {
89
80
  })
90
81
  });
91
82
  return {
92
- docPermissions: sanitizedDocPermissions,
83
+ docPermissions,
93
84
  hasPublishPermission,
94
85
  hasSavePermission
95
86
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getDocumentPermissions.js","names":["hasSavePermission","getHasSavePermission","isEditing","getIsEditing","docAccessOperation","docAccessOperationGlobal","sanitizePermissions","getDocumentPermissions","args","id","collectionConfig","data","globalConfig","req","docPermissions","hasPublishPermission","toString","collection","config","_status","versions","drafts","then","update","permission","error","payload","logger","sanitizedDocPermissions","collectionSlug","slug","globalSlug"],"sources":["../../../src/views/Document/getDocumentPermissions.tsx"],"sourcesContent":["import type {\n Data,\n DocumentPermissions,\n PayloadRequest,\n SanitizedCollectionConfig,\n SanitizedDocumentPermissions,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport {\n hasSavePermission as getHasSavePermission,\n isEditing as getIsEditing,\n} from '@payloadcms/ui/shared'\nimport { docAccessOperation, docAccessOperationGlobal, sanitizePermissions } from 'payload'\n\nexport const getDocumentPermissions = async (args: {\n collectionConfig?: SanitizedCollectionConfig\n data: Data\n globalConfig?: SanitizedGlobalConfig\n id?: number | string\n req: PayloadRequest\n}): Promise<{\n docPermissions: SanitizedDocumentPermissions\n hasPublishPermission: boolean\n hasSavePermission: boolean\n}> => {\n const { id, collectionConfig, data = {}, globalConfig, req } = args\n\n let docPermissions: DocumentPermissions\n let hasPublishPermission = false\n\n if (collectionConfig) {\n try {\n docPermissions = await docAccessOperation({\n id: id?.toString(),\n collection: {\n config: collectionConfig,\n },\n req: {\n ...req,\n data: {\n ...data,\n _status: 'draft',\n },\n },\n })\n\n if (collectionConfig.versions?.drafts) {\n hasPublishPermission = await docAccessOperation({\n id: id?.toString(),\n collection: {\n config: collectionConfig,\n },\n req: {\n ...req,\n data: {\n ...data,\n _status: 'published',\n },\n },\n }).then(({ update }) => update?.permission)\n }\n } catch (error) {\n req.payload.logger.error(error)\n }\n }\n\n if (globalConfig) {\n try {\n docPermissions = await docAccessOperationGlobal({\n globalConfig,\n req: {\n ...req,\n data,\n },\n })\n\n if (globalConfig.versions?.drafts) {\n hasPublishPermission = await docAccessOperationGlobal({\n globalConfig,\n req: {\n ...req,\n data: {\n ...data,\n _status: 'published',\n },\n },\n }).then(({ update }) => update?.permission)\n }\n } catch (error) {\n req.payload.logger.error(error)\n }\n }\n\n // TODO: do this in a better way. Only doing this bc this is how the fn was written (mutates the original object)\n const sanitizedDocPermissions = { ...docPermissions } as any as SanitizedDocumentPermissions\n sanitizePermissions(sanitizedDocPermissions)\n\n const hasSavePermission = getHasSavePermission({\n collectionSlug: collectionConfig?.slug,\n docPermissions: sanitizedDocPermissions,\n globalSlug: globalConfig?.slug,\n isEditing: getIsEditing({\n id,\n collectionSlug: collectionConfig?.slug,\n globalSlug: globalConfig?.slug,\n }),\n })\n\n return {\n docPermissions: sanitizedDocPermissions,\n hasPublishPermission,\n hasSavePermission,\n }\n}\n"],"mappings":"AASA,SACEA,iBAAA,IAAqBC,oBAAoB,EACzCC,SAAA,IAAaC,YAAY,QACpB;AACP,SAASC,kBAAkB,EAAEC,wBAAwB,EAAEC,mBAAmB,QAAQ;AAElF,OAAO,MAAMC,sBAAA,GAAyB,MAAOC,IAAA;EAW3C,M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ACPQ,OAAA,EAAS;YACX;UACF;QACF,GAAGG,IAAI,CAAC,CAAC;UAAEC;QAAM,CAAE,KAAKA,MAAA,EAAQC,UAAA;MAClC;IACF,EAAE,OAAOC,KAAA,EAAO;MACdZ,GAAA,CAAIa,OAAO,CAACC,MAAM,CAACF,KAAK,CAACA,KAAA;IAC3B;EACF;EAEA;EACA,MAAMG,uBAAA,GAA0B;IAAE,GAAGd;EAAe;EACpDR,mBAAA,CAAoBsB,uBAAA;EAEpB,MAAM5B,iBAAA,GAAoBC,oBAAA,CAAqB;IAC7C4B,cAAA,EAAgBnB,gBAAA,EAAkBoB,IAAA;IAClChB,cAAA,EAAgBc,uBAAA;IAChBG,UAAA,EAAYnB,YAAA,EAAckB,IAAA;IAC1B5B,SAAA,EAAWC,YAAA,CAAa;MACtBM,EAAA;MACAoB,cAAA,EAAgBnB,gBAAA,EAAkBoB,IAAA;MAClCC,UAAA,EAAYnB,YAAA,EAAckB;IAC5B;EACF;EAEA,OAAO;IACLhB,cAAA,EAAgBc,uBAAA;IAChBb,oBAAA;IACAf;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"getDocumentPermissions.js","names":["hasSavePermission","getHasSavePermission","isEditing","getIsEditing","docAccessOperation","docAccessOperationGlobal","getDocumentPermissions","args","id","collectionConfig","data","globalConfig","req","docPermissions","hasPublishPermission","toString","collection","config","_status","versions","drafts","then","permissions","update","error","payload","logger","collectionSlug","slug","globalSlug"],"sources":["../../../src/views/Document/getDocumentPermissions.tsx"],"sourcesContent":["import type {\n Data,\n PayloadRequest,\n SanitizedCollectionConfig,\n SanitizedDocumentPermissions,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport {\n hasSavePermission as getHasSavePermission,\n isEditing as getIsEditing,\n} from '@payloadcms/ui/shared'\nimport { docAccessOperation, docAccessOperationGlobal } from 'payload'\n\nexport const getDocumentPermissions = async (args: {\n collectionConfig?: SanitizedCollectionConfig\n data: Data\n globalConfig?: SanitizedGlobalConfig\n id?: number | string\n req: PayloadRequest\n}): Promise<{\n docPermissions: SanitizedDocumentPermissions\n hasPublishPermission: boolean\n hasSavePermission: boolean\n}> => {\n const { id, collectionConfig, data = {}, globalConfig, req } = args\n\n let docPermissions: SanitizedDocumentPermissions\n let hasPublishPermission = false\n\n if (collectionConfig) {\n try {\n docPermissions = await docAccessOperation({\n id: id?.toString(),\n collection: {\n config: collectionConfig,\n },\n req: {\n ...req,\n data: {\n ...data,\n _status: 'draft',\n },\n },\n })\n\n if (collectionConfig.versions?.drafts) {\n hasPublishPermission = await docAccessOperation({\n id: id?.toString(),\n collection: {\n config: collectionConfig,\n },\n req: {\n ...req,\n data: {\n ...data,\n _status: 'published',\n },\n },\n }).then((permissions) => permissions.update)\n }\n } catch (error) {\n req.payload.logger.error(error)\n }\n }\n\n if (globalConfig) {\n try {\n docPermissions = await docAccessOperationGlobal({\n globalConfig,\n req: {\n ...req,\n data,\n },\n })\n\n if (globalConfig.versions?.drafts) {\n hasPublishPermission = await docAccessOperationGlobal({\n globalConfig,\n req: {\n ...req,\n data: {\n ...data,\n _status: 'published',\n },\n },\n }).then((permissions) => permissions.update)\n }\n } catch (error) {\n req.payload.logger.error(error)\n }\n }\n\n const hasSavePermission = getHasSavePermission({\n collectionSlug: collectionConfig?.slug,\n docPermissions,\n globalSlug: globalConfig?.slug,\n isEditing: getIsEditing({\n id,\n collectionSlug: collectionConfig?.slug,\n globalSlug: globalConfig?.slug,\n }),\n })\n\n return {\n docPermissions,\n hasPublishPermission,\n hasSavePermission,\n }\n}\n"],"mappings":"AAQA,SACEA,iBAAA,IAAqBC,oBAAoB,EACzCC,SAAA,IAAaC,YAAY,QACpB;AACP,SAASC,kBAAkB,EAAEC,wBAAwB,QAAQ;AAE7D,OAAO,MAAMC,sBAAA,GAAyB,MAAOC,IAAA;EAW3C,MAAM;IAAEC,EAAE;IAAEC,gBAAgB;IAAEC,IAAA,GAAO,CAAC,CAAC;IAAEC,YAAY;IAAEC;EAAG,CAAE,GAAGL,IAAA;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dZ,GAAA,CAAIa,OAAO,CAACC,MAAM,CAACF,KAAK,CAACA,KAAA;IAC3B;EACF;EAEA,MAAMxB,iBAAA,GAAoBC,oBAAA,CAAqB;IAC7C0B,cAAA,EAAgBlB,gBAAA,EAAkBmB,IAAA;IAClCf,cAAA;IACAgB,UAAA,EAAYlB,YAAA,EAAciB,IAAA;IAC1B1B,SAAA,EAAWC,YAAA,CAAa;MACtBK,EAAA;MACAmB,cAAA,EAAgBlB,gBAAA,EAAkBmB,IAAA;MAClCC,UAAA,EAAYlB,YAAA,EAAciB;IAC5B;EACF;EAEA,OAAO;IACLf,cAAA;IACAC,oBAAA;IACAd;EACF;AACF","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/next",
3
- "version": "3.0.2-canary.935d33d",
3
+ "version": "3.0.2",
4
4
  "homepage": "https://payloadcms.com",
5
5
  "repository": {
6
6
  "type": "git",
@@ -79,9 +79,9 @@
79
79
  "sass": "1.77.4",
80
80
  "sonner": "^1.5.0",
81
81
  "uuid": "10.0.0",
82
- "@payloadcms/graphql": "3.0.2-canary.935d33d",
83
- "@payloadcms/translations": "3.0.2-canary.935d33d",
84
- "@payloadcms/ui": "3.0.2-canary.935d33d"
82
+ "@payloadcms/graphql": "3.0.2",
83
+ "@payloadcms/translations": "3.0.2",
84
+ "@payloadcms/ui": "3.0.2"
85
85
  },
86
86
  "devDependencies": {
87
87
  "@babel/cli": "^7.24.5",
@@ -99,13 +99,13 @@
99
99
  "esbuild-sass-plugin": "3.3.1",
100
100
  "eslint-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
101
101
  "swc-plugin-transform-remove-imports": "1.15.0",
102
- "@payloadcms/eslint-config": "3.0.0",
103
- "payload": "3.0.2-canary.935d33d"
102
+ "payload": "3.0.2",
103
+ "@payloadcms/eslint-config": "3.0.0"
104
104
  },
105
105
  "peerDependencies": {
106
106
  "graphql": "^16.8.1",
107
107
  "next": "^15.0.0",
108
- "payload": "3.0.2-canary.935d33d"
108
+ "payload": "3.0.2"
109
109
  },
110
110
  "engines": {
111
111
  "node": "^18.20.2 || >=20.9.0"