@payloadcms/ui 4.0.0-canary.29 → 4.0.0-canary.30

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":"slugify.d.ts","sourceRoot":"","sources":["../../src/utilities/slugify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,EAML,KAAK,cAAc,EACnB,KAAK,yBAAyB,EAE/B,MAAM,SAAS,CAAA;AAGhB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,EAAE,cAAc,CACzC,yBAAyB,EACzB,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAqF7B,CAAA"}
1
+ {"version":3,"file":"slugify.d.ts","sourceRoot":"","sources":["../../src/utilities/slugify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,EAML,KAAK,cAAc,EACnB,KAAK,yBAAyB,EAE/B,MAAM,SAAS,CAAA;AAGhB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,EAAE,cAAc,CACzC,yBAAyB,EACzB,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAuF7B,CAAA"}
@@ -75,6 +75,7 @@ export const slugifyHandler = async args => {
75
75
  draftsEnabled: hasDraftsEnabled(collectionConfig),
76
76
  field: field.name,
77
77
  locale: localeToScope,
78
+ overrideAccess: true,
78
79
  req,
79
80
  value: result
80
81
  });
@@ -84,6 +85,7 @@ export const slugifyHandler = async args => {
84
85
  collection: collectionConfig,
85
86
  field: field.name,
86
87
  locale: localeToScope,
88
+ overrideAccess: true,
87
89
  req,
88
90
  slugify
89
91
  });
@@ -1 +1 @@
1
- {"version":3,"file":"slugify.js","names":["executeAccess","getFieldByPath","getSlugFallbackValue","getUniqueFieldValue","hasDraftsEnabled","UnauthorizedError","slugify","defaultSlugify","slugifyHandler","args","id","collectionSlug","data","globalSlug","locale","path","req","valueToSlugify","user","docConfig","payload","collections","config","globals","find","g","slug","Error","field","fields","flattenedFields","customSlugify","custom","undefined","result","collectionConfig","type","canRead","disableErrors","access","read","localeToScope","localized","excludeId","collection","draftsEnabled","name","value"],"sources":["../../src/utilities/slugify.ts"],"sourcesContent":["import type { Slugify } from 'payload/shared'\n\nimport {\n executeAccess,\n getFieldByPath,\n getSlugFallbackValue,\n getUniqueFieldValue,\n hasDraftsEnabled,\n type ServerFunction,\n type SlugifyServerFunctionArgs,\n UnauthorizedError,\n} from 'payload'\nimport { slugify as defaultSlugify } from 'payload/shared'\n\n/**\n * This server function is directly related to the {@link https://payloadcms.com/docs/fields/slug | Slug Field}.\n * This is a server function that is used to invoke the user's custom slugify function from the client.\n * This pattern is required, as there is no other way for us to pass their function across the client-server boundary.\n * - Not through props\n * - Not from a server function defined within a server component (see below)\n * When a server function contains non-serializable data within its closure, it gets passed through the boundary (and breaks).\n * The only way to pass server functions to the client (that contain non-serializable data) is if it is globally defined.\n * But we also cannot define this function alongside the server component, as we will not have access to their custom slugify function.\n * See `ServerFunctionsProvider` for more details.\n */\nexport const slugifyHandler: ServerFunction<\n SlugifyServerFunctionArgs,\n Promise<ReturnType<Slugify>>\n> = async (args) => {\n const { id, collectionSlug, data, globalSlug, locale, path, req, valueToSlugify } = args\n\n if (!req.user) {\n throw new UnauthorizedError()\n }\n\n const docConfig = collectionSlug\n ? req.payload.collections[collectionSlug]?.config\n : globalSlug\n ? req.payload.config.globals.find((g) => g.slug === globalSlug)\n : null\n\n if (!docConfig) {\n throw new Error()\n }\n\n const { field } = getFieldByPath({\n config: req.payload.config,\n fields: docConfig.flattenedFields,\n path,\n })\n\n const customSlugify = (\n typeof field?.custom?.slugify === 'function' ? field.custom.slugify : undefined\n ) as Slugify\n\n const slugify = (valueToSlugify: unknown) =>\n customSlugify\n ? customSlugify({ data, req, valueToSlugify })\n : defaultSlugify(valueToSlugify as string)\n\n const result = await slugify(valueToSlugify)\n\n const collectionConfig = collectionSlug ? req.payload.collections[collectionSlug]?.config : null\n\n // Uniqueness dedupe only applies to a collection's slug field. Globals have no collection to\n // dedupe against, so their result is returned as-is.\n if (!collectionConfig || !field || field.type !== 'slug' || !('name' in field)) {\n return result\n }\n\n // Probing reads across the whole collection with the raw db, so require unrestricted read access —\n // a row-filtered (`Where`) result is treated as not allowed, since scoping the probe to readable\n // rows would break uniqueness.\n const canRead = await executeAccess(\n { slug: collectionConfig.slug, disableErrors: true, req },\n collectionConfig.access.read,\n )\n\n if (canRead !== true) {\n return result\n }\n\n // A localized slug is unique per-locale, so scope the probe to the current locale — otherwise it\n // dedupes against the default locale and can hand back a colliding value. The client passes the\n // active admin locale; fall back to the request's own locale.\n const localeToScope = field.localized ? (locale ?? req.locale ?? undefined) : undefined\n\n // The current doc is excluded so a regenerate can reuse its own value rather than bump past it.\n const excludeId = typeof id === 'string' || typeof id === 'number' ? id : undefined\n\n // A source resolved to a value: dedupe it the same way the next save would, so the generate button\n // can't hand back a slug that's already taken. With no source, return the `<singular>-N` fallback.\n if (result) {\n return getUniqueFieldValue({\n id: excludeId,\n collection: collectionConfig.slug,\n draftsEnabled: hasDraftsEnabled(collectionConfig),\n field: field.name,\n locale: localeToScope,\n req,\n value: result,\n })\n }\n\n return getSlugFallbackValue({\n id: excludeId,\n collection: collectionConfig,\n field: field.name,\n locale: localeToScope,\n req,\n slugify,\n })\n}\n"],"mappings":"AAEA,SACEA,aAAa,EACbC,cAAc,EACdC,oBAAoB,EACpBC,mBAAmB,EACnBC,gBAAgB,EAGhBC,iBAAiB,QACZ;AACP,SAASC,OAAA,IAAWC,cAAc,QAAQ;AAE1C;;;;;;;;;;;AAWA,OAAO,MAAMC,cAAA,GAGT,MAAOC,IAAA;EACT,MAAM;IAAEC,EAAE;IAAEC,cAAc;IAAEC,IAAI;IAAEC,UAAU;IAAEC,MAAM;IAAEC,IAAI;IAAEC,GAAG;IAAEC;EAAc,CAA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AA,EAAe;IAAMtB;EAAI,GACxDmB,gBAAA,CAAiBI,MAAM,CAACC,IAAI;EAG9B,IAAIH,OAAA,KAAY,MAAM;IACpB,OAAOH,MAAA;EACT;EAEA;EACA;EACA;EACA,MAAMO,aAAA,GAAgBb,KAAA,CAAMc,SAAS,GAAI5B,MAAA,IAAUE,GAAA,CAAIF,MAAM,IAAImB,SAAA,GAAaA,SAAA;EAE9E;EACA,MAAMU,SAAA,GAAY,OAAOjC,EAAA,KAAO,YAAY,OAAOA,EAAA,KAAO,WAAWA,EAAA,GAAKuB,SAAA;EAE1E;EACA;EACA,IAAIC,MAAA,EAAQ;IACV,OAAO/B,mBAAA,CAAoB;MACzBO,EAAA,EAAIiC,SAAA;MACJC,UAAA,EAAYT,gBAAA,CAAiBT,IAAI;MACjCmB,aAAA,EAAezC,gBAAA,CAAiB+B,gBAAA;MAChCP,KAAA,EAAOA,KAAA,CAAMkB,IAAI;MACjBhC,MAAA,EAAQ2B,aAAA;MACRzB,GAAA;MACA+B,KAAA,EAAOb;IACT;EACF;EAEA,OAAOhC,oBAAA,CAAqB;IAC1BQ,EAAA,EAAIiC,SAAA;IACJC,UAAA,EAAYT,gBAAA;IACZP,KAAA,EAAOA,KAAA,CAAMkB,IAAI;IACjBhC,MAAA,EAAQ2B,aAAA;IACRzB,GAAA;IACAV;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"slugify.js","names":["executeAccess","getFieldByPath","getSlugFallbackValue","getUniqueFieldValue","hasDraftsEnabled","UnauthorizedError","slugify","defaultSlugify","slugifyHandler","args","id","collectionSlug","data","globalSlug","locale","path","req","valueToSlugify","user","docConfig","payload","collections","config","globals","find","g","slug","Error","field","fields","flattenedFields","customSlugify","custom","undefined","result","collectionConfig","type","canRead","disableErrors","access","read","localeToScope","localized","excludeId","collection","draftsEnabled","name","overrideAccess","value"],"sources":["../../src/utilities/slugify.ts"],"sourcesContent":["import type { Slugify } from 'payload/shared'\n\nimport {\n executeAccess,\n getFieldByPath,\n getSlugFallbackValue,\n getUniqueFieldValue,\n hasDraftsEnabled,\n type ServerFunction,\n type SlugifyServerFunctionArgs,\n UnauthorizedError,\n} from 'payload'\nimport { slugify as defaultSlugify } from 'payload/shared'\n\n/**\n * This server function is directly related to the {@link https://payloadcms.com/docs/fields/slug | Slug Field}.\n * This is a server function that is used to invoke the user's custom slugify function from the client.\n * This pattern is required, as there is no other way for us to pass their function across the client-server boundary.\n * - Not through props\n * - Not from a server function defined within a server component (see below)\n * When a server function contains non-serializable data within its closure, it gets passed through the boundary (and breaks).\n * The only way to pass server functions to the client (that contain non-serializable data) is if it is globally defined.\n * But we also cannot define this function alongside the server component, as we will not have access to their custom slugify function.\n * See `ServerFunctionsProvider` for more details.\n */\nexport const slugifyHandler: ServerFunction<\n SlugifyServerFunctionArgs,\n Promise<ReturnType<Slugify>>\n> = async (args) => {\n const { id, collectionSlug, data, globalSlug, locale, path, req, valueToSlugify } = args\n\n if (!req.user) {\n throw new UnauthorizedError()\n }\n\n const docConfig = collectionSlug\n ? req.payload.collections[collectionSlug]?.config\n : globalSlug\n ? req.payload.config.globals.find((g) => g.slug === globalSlug)\n : null\n\n if (!docConfig) {\n throw new Error()\n }\n\n const { field } = getFieldByPath({\n config: req.payload.config,\n fields: docConfig.flattenedFields,\n path,\n })\n\n const customSlugify = (\n typeof field?.custom?.slugify === 'function' ? field.custom.slugify : undefined\n ) as Slugify\n\n const slugify = (valueToSlugify: unknown) =>\n customSlugify\n ? customSlugify({ data, req, valueToSlugify })\n : defaultSlugify(valueToSlugify as string)\n\n const result = await slugify(valueToSlugify)\n\n const collectionConfig = collectionSlug ? req.payload.collections[collectionSlug]?.config : null\n\n // Uniqueness dedupe only applies to a collection's slug field. Globals have no collection to\n // dedupe against, so their result is returned as-is.\n if (!collectionConfig || !field || field.type !== 'slug' || !('name' in field)) {\n return result\n }\n\n // Probing reads across the whole collection with the raw db, so require unrestricted read access —\n // a row-filtered (`Where`) result is treated as not allowed, since scoping the probe to readable\n // rows would break uniqueness.\n const canRead = await executeAccess(\n { slug: collectionConfig.slug, disableErrors: true, req },\n collectionConfig.access.read,\n )\n\n if (canRead !== true) {\n return result\n }\n\n // A localized slug is unique per-locale, so scope the probe to the current locale — otherwise it\n // dedupes against the default locale and can hand back a colliding value. The client passes the\n // active admin locale; fall back to the request's own locale.\n const localeToScope = field.localized ? (locale ?? req.locale ?? undefined) : undefined\n\n // The current doc is excluded so a regenerate can reuse its own value rather than bump past it.\n const excludeId = typeof id === 'string' || typeof id === 'number' ? id : undefined\n\n // A source resolved to a value: dedupe it the same way the next save would, so the generate button\n // can't hand back a slug that's already taken. With no source, return the `<singular>-N` fallback.\n if (result) {\n return getUniqueFieldValue({\n id: excludeId,\n collection: collectionConfig.slug,\n draftsEnabled: hasDraftsEnabled(collectionConfig),\n field: field.name,\n locale: localeToScope,\n overrideAccess: true,\n req,\n value: result,\n })\n }\n\n return getSlugFallbackValue({\n id: excludeId,\n collection: collectionConfig,\n field: field.name,\n locale: localeToScope,\n overrideAccess: true,\n req,\n slugify,\n })\n}\n"],"mappings":"AAEA,SACEA,aAAa,EACbC,cAAc,EACdC,oBAAoB,EACpBC,mBAAmB,EACnBC,gBAAgB,EAGhBC,iBAAiB,QACZ;AACP,SAASC,OAAA,IAAWC,cAAc,QAAQ;AAE1C;;;;;;;;;;;AAWA,OAAO,MAAMC,cAAA,GAGT,MAAOC,IAAA;EACT,MAAM;IAAEC,EAAE;IAAEC,cAAc;IAAEC,IAAI;IAAEC,UAAU;IAAEC,MAAM;IAAEC,IAAI;IAAEC,GAAG;IAAEC;EAAc,CAAE,GAAGR,IAAA;EAEpF,IAAI,CAACO,GAAA,CAAIE,IAAI,EAAE;IACb,MAAM,IAAIb,iBAAA;EACZ;EAEA,MAAMc,SAAA,GAAYR,cAAA,GACdK,GAAA,CAAII,OAAO,CAACC,WAAW,CAACV,cAAA,CAAe,EAAEW,MAAA,GACzCT,UAAA,GACEG,GAAA,CAAII,OAAO,CAACE,MAAM,CAACC,OAAO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EAE9E;EACA,MAAMU,SAAA,GAAY,OAAOjC,EAAA,KAAO,YAAY,OAAOA,EAAA,KAAO,WAAWA,EAAA,GAAKuB,SAAA;EAE1E;EACA;EACA,IAAIC,MAAA,EAAQ;IACV,OAAO/B,mBAAA,CAAoB;MACzBO,EAAA,EAAIiC,SAAA;MACJC,UAAA,EAAYT,gBAAA,CAAiBT,IAAI;MACjCmB,aAAA,EAAezC,gBAAA,CAAiB+B,gBAAA;MAChCP,KAAA,EAAOA,KAAA,CAAMkB,IAAI;MACjBhC,MAAA,EAAQ2B,aAAA;MACRM,cAAA,EAAgB;MAChB/B,GAAA;MACAgC,KAAA,EAAOd;IACT;EACF;EAEA,OAAOhC,oBAAA,CAAqB;IAC1BQ,EAAA,EAAIiC,SAAA;IACJC,UAAA,EAAYT,gBAAA;IACZP,KAAA,EAAOA,KAAA,CAAMkB,IAAI;IACjBhC,MAAA,EAAQ2B,aAAA;IACRM,cAAA,EAAgB;IAChB/B,GAAA;IACAV;EACF;AACF","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/ui",
3
- "version": "4.0.0-canary.29",
3
+ "version": "4.0.0-canary.30",
4
4
  "homepage": "https://payloadcms.com",
5
5
  "repository": {
6
6
  "type": "git",
@@ -274,6 +274,7 @@
274
274
  "@faceless-ui/window-info": "3.0.1",
275
275
  "@floating-ui/dom": "1.7.6",
276
276
  "@monaco-editor/react": "4.7.0",
277
+ "@swc/helpers": ">=0.5.17",
277
278
  "bson-objectid": "2.0.4",
278
279
  "date-fns": "4.1.0",
279
280
  "dequal": "2.0.3",
@@ -289,7 +290,7 @@
289
290
  "ts-essentials": "10.0.3",
290
291
  "use-context-selector": "2.0.0",
291
292
  "uuid": "14.0.0",
292
- "@payloadcms/translations": "4.0.0-canary.29"
293
+ "@payloadcms/translations": "4.0.0-canary.30"
293
294
  },
294
295
  "devDependencies": {
295
296
  "@babel/cli": "7.27.2",
@@ -303,13 +304,13 @@
303
304
  "babel-plugin-react-compiler": "19.1.0-rc.3",
304
305
  "esbuild": "0.27.1",
305
306
  "esbuild-sass-plugin": "3.3.1",
306
- "payload": "4.0.0-canary.29",
307
- "@payloadcms/eslint-config": "3.28.0"
307
+ "@payloadcms/eslint-config": "3.28.0",
308
+ "payload": "4.0.0-canary.30"
308
309
  },
309
310
  "peerDependencies": {
310
311
  "react": "^19.0.1 || ^19.1.2 || ^19.2.1",
311
312
  "react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
312
- "payload": "4.0.0-canary.29"
313
+ "payload": "4.0.0-canary.30"
313
314
  },
314
315
  "engines": {
315
316
  "node": ">=24.15.0"