payload 3.69.0-internal.2883df2 → 3.69.0-internal.35bf893

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.
Files changed (32) hide show
  1. package/dist/exports/shared.d.ts +1 -0
  2. package/dist/exports/shared.d.ts.map +1 -1
  3. package/dist/exports/shared.js +1 -0
  4. package/dist/exports/shared.js.map +1 -1
  5. package/dist/fields/hooks/afterChange/promise.d.ts.map +1 -1
  6. package/dist/fields/hooks/afterChange/promise.js +3 -2
  7. package/dist/fields/hooks/afterChange/promise.js.map +1 -1
  8. package/dist/uploads/endpoints/getFile.d.ts.map +1 -1
  9. package/dist/uploads/endpoints/getFile.js +46 -3
  10. package/dist/uploads/endpoints/getFile.js.map +1 -1
  11. package/dist/uploads/fetchAPI-stream-file/index.d.ts +7 -1
  12. package/dist/uploads/fetchAPI-stream-file/index.d.ts.map +1 -1
  13. package/dist/uploads/fetchAPI-stream-file/index.js +2 -2
  14. package/dist/uploads/fetchAPI-stream-file/index.js.map +1 -1
  15. package/dist/uploads/parseRangeHeader.d.ts +24 -0
  16. package/dist/uploads/parseRangeHeader.d.ts.map +1 -0
  17. package/dist/uploads/parseRangeHeader.js +52 -0
  18. package/dist/uploads/parseRangeHeader.js.map +1 -0
  19. package/dist/utilities/canAccessAdmin.d.ts.map +1 -1
  20. package/dist/utilities/canAccessAdmin.js +4 -3
  21. package/dist/utilities/canAccessAdmin.js.map +1 -1
  22. package/dist/utilities/formatAdminURL.d.ts +19 -4
  23. package/dist/utilities/formatAdminURL.d.ts.map +1 -1
  24. package/dist/utilities/formatAdminURL.js +21 -12
  25. package/dist/utilities/formatAdminURL.js.map +1 -1
  26. package/dist/utilities/formatAdminURL.spec.js +169 -0
  27. package/dist/utilities/formatAdminURL.spec.js.map +1 -0
  28. package/dist/utilities/formatApiURL.d.ts +9 -0
  29. package/dist/utilities/formatApiURL.d.ts.map +1 -0
  30. package/dist/utilities/formatApiURL.js +11 -0
  31. package/dist/utilities/formatApiURL.js.map +1 -0
  32. package/package.json +4 -2
@@ -25,6 +25,7 @@ export { extractID } from '../utilities/extractID.js';
25
25
  export { flattenAllFields } from '../utilities/flattenAllFields.js';
26
26
  export { flattenTopLevelFields } from '../utilities/flattenTopLevelFields.js';
27
27
  export { formatAdminURL } from '../utilities/formatAdminURL.js';
28
+ export { formatApiURL } from '../utilities/formatApiURL.js';
28
29
  export { formatLabels, toWords } from '../utilities/formatLabels.js';
29
30
  export { getBestFitFromSizes } from '../utilities/getBestFitFromSizes.js';
30
31
  export { getDataByPath } from '../utilities/getDataByPath.js';
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/exports/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,4BAA4B,EAC5B,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,GACb,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAA;AACzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,6DAA6D,CAAA;AACnG,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAElF,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,oCAAoC,CAAA;AAEjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAA;AAEpF,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,SAAS,EACT,gBAAgB,EAChB,yBAAyB,EACzB,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,YAAY,E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AE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA"}
@@ -23,6 +23,7 @@ export { extractID } from '../utilities/extractID.js';
23
23
  export { flattenAllFields } from '../utilities/flattenAllFields.js';
24
24
  export { flattenTopLevelFields } from '../utilities/flattenTopLevelFields.js';
25
25
  export { formatAdminURL } from '../utilities/formatAdminURL.js';
26
+ export { formatApiURL } from '../utilities/formatApiURL.js';
26
27
  export { formatLabels, toWords } from '../utilities/formatLabels.js';
27
28
  export { getBestFitFromSizes } from '../utilities/getBestFitFromSizes.js';
28
29
  export { getDataByPath } from '../utilities/getDataByPath.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/shared.ts"],"sourcesContent":["export {\n generateCookie,\n generateExpiredPayloadCookie,\n generatePayloadCookie,\n getCookieExpiration,\n parseCookies,\n} from '../auth/cookies.js'\nexport { getLoginOptions } from '../auth/getLoginOptions.js'\nexport { addSessionToUser, removeExpiredSessions } from '../auth/sessions.js'\nexport { getFromImportMap } from '../bin/generateImportMap/utilities/getFromImportMap.js'\nexport { parsePayloadComponent } from '../bin/generateImportMap/utilities/parsePayloadComponent.js'\nexport { defaults as collectionDefaults } from '../collections/config/defaults.js'\n\nexport { serverProps } from '../config/types.js'\n\nexport { type Slugify } from '../fields/baseFields/slug/index.js'\n\nexport { defaultTimezones } from '../fields/baseFields/timezone/defaultTimezones.js'\n\nexport {\n fieldAffectsData,\n fieldHasMaxDepth,\n fieldHasSubFields,\n fieldIsArrayType,\n fieldIsBlockType,\n fieldIsGroupType,\n fieldIsHiddenOrDisabled,\n fieldIsID,\n fieldIsLocalized,\n fieldIsPresentationalOnly,\n fieldIsSidebar,\n fieldIsVirtual,\n fieldShouldBeLocalized,\n fieldSupportsMany,\n groupHasName,\n optionIsObject,\n optionIsValue,\n optionsAreObjects,\n tabHasName,\n valueIsValueWithRelation,\n} from '../fields/config/types.js'\n\nexport { getFieldPaths } from '../fields/getFieldPaths.js'\nexport * from '../fields/validations.js'\n\nexport type {\n FolderBreadcrumb,\n FolderDocumentItemKey,\n FolderEnabledColection,\n FolderInterface,\n FolderOrDocument,\n GetFolderDataResult,\n Subfolder,\n} from '../folders/types.js'\n\nexport { buildFolderWhereConstraints } from '../folders/utils/buildFolderWhereConstraints.js'\nexport { formatFolderOrDocumentItem } from '../folders/utils/formatFolderOrDocumentItem.js'\nexport { validOperators, validOperatorSet } from '../types/constants.js'\n\nexport { formatFilesize } from '../uploads/formatFilesize.js'\n\nexport { isImage } from '../uploads/isImage.js'\nexport { appendUploadSelectFields } from '../utilities/appendUploadSelectFields.js'\nexport { applyLocaleFiltering } from '../utilities/applyLocaleFiltering.js'\nexport { combineWhereConstraints } from '../utilities/combineWhereConstraints.js'\n\nexport {\n deepCopyObject,\n deepCopyObjectComplex,\n deepCopyObjectSimple,\n deepCopyObjectSimpleWithoutReactComponents,\n} from '../utilities/deepCopyObject.js'\n\nexport {\n deepMerge,\n deepMergeWithCombinedArrays,\n deepMergeWithReactComponents,\n deepMergeWithSourceArrays,\n} from '../utilities/deepMerge.js'\nexport { extractID } from '../utilities/extractID.js'\n\nexport { flattenAllFields } from '../utilities/flattenAllFields.js'\n\nexport { flattenTopLevelFields } from '../utilities/flattenTopLevelFields.js'\nexport { formatAdminURL } from '../utilities/formatAdminURL.js'\nexport { formatLabels, toWords } from '../utilities/formatLabels.js'\nexport { getBestFitFromSizes } from '../utilities/getBestFitFromSizes.js'\n\nexport { getDataByPath } from '../utilities/getDataByPath.js'\nexport { getFieldPermissions } from '../utilities/getFieldPermissions.js'\nexport { getObjectDotNotation } from '../utilities/getObjectDotNotation.js'\nexport { getSafeRedirect } from '../utilities/getSafeRedirect.js'\n\nexport { getSelectMode } from '../utilities/getSelectMode.js'\n\nexport { getSiblingData } from '../utilities/getSiblingData.js'\n\nexport { getUniqueListBy } from '../utilities/getUniqueListBy.js'\n\nexport {\n getAutosaveInterval,\n getVersionsMax,\n hasAutosaveEnabled,\n hasDraftsEnabled,\n hasDraftValidationEnabled,\n hasScheduledPublishEnabled,\n} from '../utilities/getVersionsConfig.js'\n\nexport { isNextBuild } from '../utilities/isNextBuild.js'\n\nexport { isNumber } from '../utilities/isNumber.js'\n\nexport { isPlainObject } from '../utilities/isPlainObject.js'\n\nexport {\n isReactClientComponent,\n isReactComponentOrFunction,\n isReactServerComponentOrFunction,\n} from '../utilities/isReactComponent.js'\n\nexport {\n hoistQueryParamsToAnd,\n mergeListSearchAndWhere,\n} from '../utilities/mergeListSearchAndWhere.js'\n\nexport { reduceFieldsToValues } from '../utilities/reduceFieldsToValues.js'\n\nexport { sanitizeUserDataForEmail } from '../utilities/sanitizeUserDataForEmail.js'\n\nexport { setsAreEqual } from '../utilities/setsAreEqual.js'\n\nexport { slugify } from '../utilities/slugify.js'\n\nexport { toKebabCase } from '../utilities/toKebabCase.js'\n\nexport {\n transformColumnsToPreferences,\n transformColumnsToSearchParams,\n} from '../utilities/transformColumnPreferences.js'\n\nexport { transformWhereQuery } from '../utilities/transformWhereQuery.js'\n\nexport { unflatten } from '../utilities/unflatten.js'\nexport { validateMimeType } from '../utilities/validateMimeType.js'\nexport { validateWhereQuery } from '../utilities/validateWhereQuery.js'\nexport { wait } from '../utilities/wait.js'\nexport { wordBoundariesRegex } from '../utilities/wordBoundariesRegex.js'\nexport { versionDefaults } from '../versions/defaults.js'\n\nexport { deepMergeSimple } from '@payloadcms/translations/utilities'\n"],"names":["generateCookie","generateExpiredPayloadCookie","generatePayloadCookie","getCookieExpiration","parseCookies","getLoginOptions","addSessionToUser","removeExpiredSessions","getFromImportMap","parsePayloadComponent","defaults","collectionDefaults","serverProps","defaultTimezones","fieldAffectsData","fieldHasMaxDepth","fieldHasSubFields","fieldIsArrayType","fieldIsBlockType","fieldIsGroupType","fieldIsHiddenOrDisabled","fieldIsID","fieldIsLocalized","fieldIsPresentationalOnly","fieldIsSidebar","fieldIsVirtual","fieldShouldBeLocalized","fieldSupportsMany","groupHasName","optionIsObject","optionIsValue","optionsAreObjects","tabHasName","valueIsValueWithRelation","getFieldPaths","buildFolderWhereConstraints","formatFolderOrDocumentItem","validOperators","validOperatorSet","formatFilesize","isImage","appendUploadSelectFields","applyLocaleFiltering","combineWhereConstraints","deepCopyObject","deepCopyObjectComplex","deepCopyObjectSimple","deepCopyObjectSimpleWithoutReactComponents","deepMerge","deepMergeWithCombinedArrays","deepMergeWithReactComponents","deepMergeWithSourceArrays","extractID","flattenAllFields","flattenTopLevelFields","formatAdminURL","formatLabels","toWords","getBestFitFromSizes","getDataByPath","getFieldPermissions","getObjectDotNotation","getSafeRedirect","getSelectMode","getSiblingData","getUniqueListBy","getAutosaveInterval","getVersionsMax","hasAutosaveEnabled","hasDraftsEnabled","hasDraftValidationEnabled","hasScheduledPublishEnabled","isNextBuild","isNumber","isPlainObject","isReactClientComponent","isReactComponentOrFunction","isReactServerComponentOrFunction","hoistQueryParamsToAnd","mergeListSearchAndWhere","reduceFieldsToValues","sanitizeUserDataForEmail","setsAreEqual","slugify","toKebabCase","transformColumnsToPreferences","transformColumnsToSearchParams","transformWhereQuery","unflatten","validateMimeType","validateWhereQuery","wait","wordBoundariesRegex","versionDefaults","deepMergeSimple"],"mappings":"AAAA,SACEA,cAAc,EACdC,4BAA4B,EAC5BC,qBAAqB,EACrBC,mBAAmB,EACnBC,YAAY,QACP,qBAAoB;AAC3B,SAASC,eAAe,QAAQ,6BAA4B;AAC5D,SAASC,gBAAgB,EAAEC,qBAAqB,QAAQ,sBAAqB;AAC7E,SAASC,gBAAgB,QAAQ,yDAAwD;AACzF,SAASC,qBAAq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ASC,mBAAmB,QAAQ,sCAAqC;AACzE,SAASC,oBAAoB,QAAQ,uCAAsC;AAC3E,SAASC,eAAe,QAAQ,kCAAiC;AAEjE,SAASC,aAAa,QAAQ,gCAA+B;AAE7D,SAASC,cAAc,QAAQ,iCAAgC;AAE/D,SAASC,eAAe,QAAQ,kCAAiC;AAEjE,SACEC,mBAAmB,EACnBC,cAAc,EACdC,kBAAkB,EAClBC,gBAAgB,EAChBC,yBAAyB,EACzBC,0BAA0B,QACrB,oCAAmC;AAE1C,SAASC,WAAW,QAAQ,8BAA6B;AAEzD,SAASC,QAAQ,QAAQ,2BAA0B;AAEnD,SAASC,aAAa,QAAQ,gCAA+B;AAE7D,SACEC,sBAAsB,EACtBC,0BAA0B,EAC1BC,gCAAgC,QAC3B,mCAAkC;AAEzC,SACEC,qBAAqB,EACrBC,uBAAuB,QAClB,0CAAyC;AAEhD,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,SAASC,wBAAwB,QAAQ,2CAA0C;AAEnF,SAASC,YAAY,QAAQ,+BAA8B;AAE3D,SAASC,OAAO,QAAQ,0BAAyB;AAEjD,SAASC,WAAW,QAAQ,8BAA6B;AAEzD,SACEC,6BAA6B,EAC7BC,8BAA8B,QACzB,6CAA4C;AAEnD,SAASC,mBAAmB,QAAQ,sCAAqC;AAEzE,SAASC,SAAS,QAAQ,4BAA2B;AACrD,SAASC,gBAAgB,QAAQ,mCAAkC;AACnE,SAASC,kBAAkB,QAAQ,qCAAoC;AACvE,SAASC,IAAI,QAAQ,uBAAsB;AAC3C,SAASC,mBAAmB,QAAQ,sCAAqC;AACzE,SAASC,eAAe,QAAQ,0BAAyB;AAEzD,SAASC,eAAe,QAAQ,qCAAoC"}
1
+ {"version":3,"sources":["../../src/exports/shared.ts"],"sourcesContent":["export {\n generateCookie,\n generateExpiredPayloadCookie,\n generatePayloadCookie,\n getCookieExpiration,\n parseCookies,\n} from '../auth/cookies.js'\nexport { getLoginOptions } from '../auth/getLoginOptions.js'\nexport { addSessionToUser, removeExpiredSessions } from '../auth/sessions.js'\nexport { getFromImportMap } from '../bin/generateImportMap/utilities/getFromImportMap.js'\nexport { parsePayloadComponent } from '../bin/generateImportMap/utilities/parsePayloadComponent.js'\nexport { defaults as collectionDefaults } from '../collections/config/defaults.js'\n\nexport { serverProps } from '../config/types.js'\n\nexport { type Slugify } from '../fields/baseFields/slug/index.js'\n\nexport { defaultTimezones } from '../fields/baseFields/timezone/defaultTimezones.js'\n\nexport {\n fieldAffectsData,\n fieldHasMaxDepth,\n fieldHasSubFields,\n fieldIsArrayType,\n fieldIsBlockType,\n fieldIsGroupType,\n fieldIsHiddenOrDisabled,\n fieldIsID,\n fieldIsLocalized,\n fieldIsPresentationalOnly,\n fieldIsSidebar,\n fieldIsVirtual,\n fieldShouldBeLocalized,\n fieldSupportsMany,\n groupHasName,\n optionIsObject,\n optionIsValue,\n optionsAreObjects,\n tabHasName,\n valueIsValueWithRelation,\n} from '../fields/config/types.js'\n\nexport { getFieldPaths } from '../fields/getFieldPaths.js'\nexport * from '../fields/validations.js'\n\nexport type {\n FolderBreadcrumb,\n FolderDocumentItemKey,\n FolderEnabledColection,\n FolderInterface,\n FolderOrDocument,\n GetFolderDataResult,\n Subfolder,\n} from '../folders/types.js'\n\nexport { buildFolderWhereConstraints } from '../folders/utils/buildFolderWhereConstraints.js'\nexport { formatFolderOrDocumentItem } from '../folders/utils/formatFolderOrDocumentItem.js'\nexport { validOperators, validOperatorSet } from '../types/constants.js'\n\nexport { formatFilesize } from '../uploads/formatFilesize.js'\n\nexport { isImage } from '../uploads/isImage.js'\nexport { appendUploadSelectFields } from '../utilities/appendUploadSelectFields.js'\nexport { applyLocaleFiltering } from '../utilities/applyLocaleFiltering.js'\nexport { combineWhereConstraints } from '../utilities/combineWhereConstraints.js'\n\nexport {\n deepCopyObject,\n deepCopyObjectComplex,\n deepCopyObjectSimple,\n deepCopyObjectSimpleWithoutReactComponents,\n} from '../utilities/deepCopyObject.js'\n\nexport {\n deepMerge,\n deepMergeWithCombinedArrays,\n deepMergeWithReactComponents,\n deepMergeWithSourceArrays,\n} from '../utilities/deepMerge.js'\nexport { extractID } from '../utilities/extractID.js'\n\nexport { flattenAllFields } from '../utilities/flattenAllFields.js'\n\nexport { flattenTopLevelFields } from '../utilities/flattenTopLevelFields.js'\nexport { formatAdminURL } from '../utilities/formatAdminURL.js'\nexport { formatApiURL } from '../utilities/formatApiURL.js'\nexport { formatLabels, toWords } from '../utilities/formatLabels.js'\nexport { getBestFitFromSizes } from '../utilities/getBestFitFromSizes.js'\n\nexport { getDataByPath } from '../utilities/getDataByPath.js'\nexport { getFieldPermissions } from '../utilities/getFieldPermissions.js'\nexport { getObjectDotNotation } from '../utilities/getObjectDotNotation.js'\nexport { getSafeRedirect } from '../utilities/getSafeRedirect.js'\n\nexport { getSelectMode } from '../utilities/getSelectMode.js'\n\nexport { getSiblingData } from '../utilities/getSiblingData.js'\n\nexport { getUniqueListBy } from '../utilities/getUniqueListBy.js'\n\nexport {\n getAutosaveInterval,\n getVersionsMax,\n hasAutosaveEnabled,\n hasDraftsEnabled,\n hasDraftValidationEnabled,\n hasScheduledPublishEnabled,\n} from '../utilities/getVersionsConfig.js'\n\nexport { isNextBuild } from '../utilities/isNextBuild.js'\n\nexport { isNumber } from '../utilities/isNumber.js'\n\nexport { isPlainObject } from '../utilities/isPlainObject.js'\n\nexport {\n isReactClientComponent,\n isReactComponentOrFunction,\n isReactServerComponentOrFunction,\n} from '../utilities/isReactComponent.js'\n\nexport {\n hoistQueryParamsToAnd,\n mergeListSearchAndWhere,\n} from '../utilities/mergeListSearchAndWhere.js'\n\nexport { reduceFieldsToValues } from '../utilities/reduceFieldsToValues.js'\n\nexport { sanitizeUserDataForEmail } from '../utilities/sanitizeUserDataForEmail.js'\n\nexport { setsAreEqual } from '../utilities/setsAreEqual.js'\n\nexport { slugify } from '../utilities/slugify.js'\n\nexport { toKebabCase } from '../utilities/toKebabCase.js'\n\nexport {\n transformColumnsToPreferences,\n transformColumnsToSearchParams,\n} from '../utilities/transformColumnPreferences.js'\n\nexport { transformWhereQuery } from '../utilities/transformWhereQuery.js'\n\nexport { unflatten } from '../utilities/unflatten.js'\nexport { validateMimeType } from '../utilities/validateMimeType.js'\nexport { validateWhereQuery } from '../utilities/validateWhereQuery.js'\nexport { wait } from '../utilities/wait.js'\nexport { wordBoundariesRegex } from '../utilities/wordBoundariesRegex.js'\nexport { versionDefaults } from '../versions/defaults.js'\n\nexport { deepMergeSimple } from '@payloadcms/translations/utilities'\n"],"names":["generateCookie","generateExpiredPayloadCookie","generatePayloadCookie","getCookieExpiration","parseCookies","getLoginOptions","addSessionToUser","removeExpiredSessions","getFromImportMap","parsePayloadComponent","defaults","collectionDefaults","serverProps","defaultTimezones","fieldAffectsData","fieldHasMaxDepth","fieldHasSubFields","fieldIsArrayType","fieldIsBlockType","fieldIsGroupType","fieldIsHiddenOrDisabled","fieldIsID","fieldIsLocalized","fieldIsPresentationalOnly","fieldIsSidebar","fieldIsVirtual","fieldShouldBeLocalized","fieldSupportsMany","groupHasName","optionIsObject","optionIsValue","optionsAreObjects","tabHasName","valueIsValueWithRelation","getFieldPaths","buildFolderWhereConstraints","formatFolderOrDocumentItem","validOperators","validOperatorSet","formatFilesize","isImage","appendUploadSelectFields","applyLocaleFiltering","combineWhereConstraints","deepCopyObject","deepCopyObjectComplex","deepCopyObjectSimple","deepCopyObjectSimpleWithoutReactComponents","deepMerge","deepMergeWithCombinedArrays","deepMergeWithReactComponents","deepMergeWithSourceArrays","extractID","flattenAllFields","flattenTopLevelFields","formatAdminURL","formatApiURL","formatLabels","toWords","getBestFitFromSizes","getDataByPath","getFieldPermissions","getObjectDotNotation","getSafeRedirect","getSelectMode","getSiblingData","getUniqueListBy","getAutosaveInterval","getVersionsMax","hasAutosaveEnabled","hasDraftsEnabled","hasDraftValidationEnabled","hasScheduledPublishEnabled","isNextBuild","isNumber","isPlainObject","isReactClientComponent","isReactComponentOrFunction","isReactServerComponentOrFunction","hoistQueryParamsToAnd","mergeListSearchAndWhere","reduceFieldsToValues","sanitizeUserDataForEmail","setsAreEqual","slugify","toKebabCase","transformColumnsToPreferences","transformColumnsToSearchParams","transformWhereQuery","unflatten","validateMimeType","validateWhereQuery","wait","wordBoundariesRegex","versionDefaults","deepMergeSimple"],"mappings":"AAAA,SACEA,cAAc,EACdC,4BAA4B,EAC5BC,qBAAqB,EACrBC,mBAAmB,EACnBC,YAAY,QACP,qBAAoB;AAC3B,SAASC,eAAe,QAAQ,6BAA4B;AAC5D,SAASC,gBAAgB,EAAEC,qBAAqB,QAAQ,sBAAqB;AAC7E,SAASC,gBAAgB,QAAQ,yDAAwD;AACzF,SAASC,qBAAqB,QAAQ,8DAA6D;AACnG,SAASC,YAAYC,kBAAkB,QAAQ,oCAAmC;AAElF,SAASC,WAAW,QAAQ,qBAAoB;AAIhD,SAASC,gBAAgB,QAAQ,oDAAmD;AAEpF,SACEC,gBAAgB,EAChBC,gBAAgB,EAChBC,iBAAiB,EACjBC,gBAAgB,EAChBC,gBAAgB,EAChBC,gBAAgB,EAChBC,uBAAuB,EACvBC,SAAS,EACTC,gBAAgB,EAChBC,yBAAyB,EACzBC,cAAc,EACdC,cAAc,EACdC,sBAAsB,EACtBC,iBAAiB,EACjBC,YAAY,EACZC,cAAc,EACdC,aAAa,EACbC,iBAAiB,EACjBC,UAAU,EACVC,wBAAwB,QACnB,4BAA2B;AAElC,SAASC,aAAa,QAAQ,6BAA4B;AAC1D,cAAc,2BAA0B;AAYxC,SAASC,2BAA2B,QAAQ,kDAAiD;AAC7F,SAASC,0BAA0B,QAAQ,iDAAgD;AAC3F,SAASC,cAAc,EAAEC,gBAAgB,QAAQ,wBAAuB;AAExE,SAASC,cAAc,QAAQ,+BAA8B;AAE7D,SAASC,OAAO,QAAQ,wBAAuB;AAC/C,SAASC,wBAAwB,QAAQ,2CAA0C;AACnF,SAASC,oBAAoB,QAAQ,uCAAsC;AAC3E,SAASC,uBAAuB,QAAQ,0CAAyC;AAEjF,SACEC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GAAG,EAAE,cAAc,CAAA;IACnB,WAAW,EAAE,UAAU,CAAA;IACvB,UAAU,EAAE,UAAU,CAAA;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;CACvC,CAAA;AAKD,eAAO,MAAM,OAAO,yOAoBjB,IAAI,KAAG,OAAO,CAAC,IAAI,CAsTrB,CAAA"}
@@ -16,6 +16,7 @@ export const promise = async ({ blockData, collection, context, data, doc, field
16
16
  const schemaPathSegments = schemaPath ? schemaPath.split('.') : [];
17
17
  const indexPathSegments = indexPath ? indexPath.split('-').filter(Boolean)?.map(Number) : [];
18
18
  const getNestedValue = (data, path)=>path.reduce((acc, key)=>acc && acc[key] !== undefined ? acc[key] : undefined, data);
19
+ const previousValData = previousSiblingDoc && Object.keys(previousSiblingDoc).length > 0 ? previousSiblingDoc : previousDoc;
19
20
  if (fieldAffectsData(field)) {
20
21
  // Execute hooks
21
22
  if ('hooks' in field && field.hooks?.afterChange) {
@@ -33,7 +34,7 @@ export const promise = async ({ blockData, collection, context, data, doc, field
33
34
  path: pathSegments,
34
35
  previousDoc,
35
36
  previousSiblingDoc,
36
- previousValue: getNestedValue(previousDoc, pathSegments) ?? previousDoc?.[field.name],
37
+ previousValue: getNestedValue(previousValData, pathSegments) ?? previousValData?.[field.name],
37
38
  req,
38
39
  schemaPath: schemaPathSegments,
39
40
  siblingData,
@@ -103,7 +104,7 @@ export const promise = async ({ blockData, collection, context, data, doc, field
103
104
  parentPath: path + '.' + rowIndex,
104
105
  parentSchemaPath: schemaPath + '.' + block.slug,
105
106
  previousDoc,
106
- previousSiblingDoc: previousDoc?.[field.name]?.[rowIndex] || {},
107
+ previousSiblingDoc: previousValData?.[field.name]?.[rowIndex] || {},
107
108
  req,
108
109
  siblingData: siblingData?.[field.name]?.[rowIndex] || {},
109
110
  siblingDoc: row ? {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/fields/hooks/afterChange/promise.ts"],"sourcesContent":["import type { RichTextAdapter } from '../../../admin/RichText.js'\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { RequestContext } from '../../../index.js'\nimport type { JsonObject, PayloadRequest } from '../../../types/index.js'\nimport type { Block, Field, TabAsField } from '../../config/types.js'\n\nimport { MissingEditorProp } from '../../../errors/index.js'\nimport { fieldAffectsData, tabHasName } from '../../config/types.js'\nimport { getFieldPathsModified as getFieldPaths } from '../../getFieldPaths.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n /**\n * Data of the nearest parent block. If no parent block exists, this will be the `undefined`\n */\n blockData?: JsonObject\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n data: JsonObject\n doc: JsonObject\n field: Field | TabAsField\n fieldIndex: number\n global: null | SanitizedGlobalConfig\n operation: 'create' | 'update'\n parentIndexPath: string\n parentIsLocalized: boolean\n parentPath: string\n parentSchemaPath: string\n previousDoc: JsonObject\n previousSiblingDoc: JsonObject\n req: PayloadRequest\n siblingData: JsonObject\n siblingDoc: JsonObject\n siblingFields?: (Field | TabAsField)[]\n}\n\n// This function is responsible for the following actions, in order:\n// - Execute field hooks\n\nexport const promise = async ({\n blockData,\n collection,\n context,\n data,\n doc,\n field,\n fieldIndex,\n global,\n operation,\n parentIndexPath,\n parentIsLocalized,\n parentPath,\n parentSchemaPath,\n previousDoc,\n previousSiblingDoc,\n req,\n siblingData,\n siblingDoc,\n siblingFields,\n}: Args): Promise<void> => {\n const { indexPath, path, schemaPath } = getFieldPaths({\n field,\n index: fieldIndex,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n })\n\n const pathSegments = path ? path.split('.') : []\n const schemaPathSegments = schemaPath ? schemaPath.split('.') : []\n const indexPathSegments = indexPath ? indexPath.split('-').filter(Boolean)?.map(Number) : []\n const getNestedValue = (data: JsonObject, path: string[]) =>\n path.reduce((acc, key) => (acc && acc[key] !== undefined ? acc[key] : undefined), data)\n\n if (fieldAffectsData(field)) {\n // Execute hooks\n if ('hooks' in field && field.hooks?.afterChange) {\n for (const hook of field.hooks.afterChange) {\n const hookedValue = await hook({\n blockData,\n collection,\n context,\n data,\n field,\n global,\n indexPath: indexPathSegments,\n operation,\n originalDoc: doc,\n path: pathSegments,\n previousDoc,\n previousSiblingDoc,\n previousValue: getNestedValue(previousDoc, pathSegments) ?? previousDoc?.[field.name],\n req,\n schemaPath: schemaPathSegments,\n siblingData,\n siblingFields: siblingFields!,\n value: getNestedValue(siblingDoc, pathSegments) ?? siblingDoc?.[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }\n }\n }\n\n // Traverse subfields\n switch (field.type) {\n case 'array': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n const promises: Promise<void>[] = []\n rows.forEach((row, rowIndex) => {\n promises.push(\n traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: '',\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: previousDoc?.[field.name]?.[rowIndex] || ({} as JsonObject),\n req,\n siblingData: siblingData?.[field.name]?.[rowIndex] || {},\n siblingDoc: row ? { ...row } : {},\n }),\n )\n })\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'blocks': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n const promises: Promise<void>[] = []\n\n rows.forEach((row, rowIndex) => {\n const blockTypeToMatch = (row as JsonObject).blockType\n\n const block: Block | undefined =\n req.payload.blocks[blockTypeToMatch] ??\n ((field.blockReferences ?? field.blocks).find(\n (curBlock) => typeof curBlock !== 'string' && curBlock.slug === blockTypeToMatch,\n ) as Block | undefined)\n\n if (block) {\n promises.push(\n traverseFields({\n blockData: siblingData?.[field.name]?.[rowIndex],\n collection,\n context,\n data,\n doc,\n fields: block.fields,\n global,\n operation,\n parentIndexPath: '',\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath + '.' + block.slug,\n previousDoc,\n previousSiblingDoc: previousDoc?.[field.name]?.[rowIndex] || ({} as JsonObject),\n req,\n siblingData: siblingData?.[field.name]?.[rowIndex] || {},\n siblingDoc: row ? { ...row } : {},\n }),\n )\n }\n })\n\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'collapsible':\n case 'row': {\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: indexPath,\n parentIsLocalized,\n parentPath,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: { ...previousSiblingDoc },\n req,\n siblingData: siblingData || {},\n siblingDoc: { ...siblingDoc },\n })\n\n break\n }\n\n case 'group': {\n if (fieldAffectsData(field)) {\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: '',\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: path,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: (previousDoc?.[field.name] as JsonObject) || {},\n req,\n siblingData: (siblingData?.[field.name] as JsonObject) || {},\n siblingDoc: (siblingDoc?.[field.name] as JsonObject) || {},\n })\n } else {\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: indexPath,\n parentIsLocalized,\n parentPath,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: { ...previousSiblingDoc },\n req,\n siblingData: siblingData || {},\n siblingDoc: { ...siblingDoc },\n })\n }\n\n break\n }\n\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n\n if (typeof field.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n const editor: RichTextAdapter = field.editor\n\n if (editor?.hooks?.afterChange?.length) {\n for (const hook of editor.hooks.afterChange) {\n const hookedValue = await hook({\n collection,\n context,\n data,\n field,\n global,\n indexPath: indexPathSegments,\n operation,\n originalDoc: doc,\n parentIsLocalized,\n path: pathSegments,\n previousDoc,\n previousSiblingDoc,\n previousValue: previousDoc?.[field.name],\n req,\n schemaPath: schemaPathSegments,\n siblingData,\n value: siblingDoc?.[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }\n }\n break\n }\n\n case 'tab': {\n let tabSiblingData = siblingData\n let tabSiblingDoc = siblingDoc\n let tabPreviousSiblingDoc = siblingDoc\n\n const isNamedTab = tabHasName(field)\n\n if (isNamedTab) {\n tabSiblingData = (siblingData?.[field.name] ?? {}) as JsonObject\n tabSiblingDoc = (siblingDoc?.[field.name] ?? {}) as JsonObject\n tabPreviousSiblingDoc = (previousDoc?.[field.name] ?? {}) as JsonObject\n }\n\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: isNamedTab ? '' : indexPath,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: isNamedTab ? path : parentPath,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: tabPreviousSiblingDoc,\n req,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n operation,\n parentIndexPath: indexPath,\n parentIsLocalized,\n parentPath: path,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: { ...previousSiblingDoc },\n req,\n siblingData: siblingData || {},\n siblingDoc: { ...siblingDoc },\n })\n\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","fieldAffectsData","tabHasName","getFieldPathsModified","getFieldPaths","traverseFields","promise","blockData","collection","context","data","doc","field","fieldIndex","global","operation","parentIndexPath","parentIsLocalized","parentPath","parentSchemaPath","previousDoc","previousSiblingDoc","req","siblingData","siblingDoc","siblingFields","indexPath","path","schemaPath","index","pathSegments","split","schemaPathSegments","indexPathSegments","filter","Boolean","map","Number","getNestedValue","reduce","acc","key","undefined","hooks","afterChange","hook","hookedValue","originalDoc","previousValue","name","value","type","rows","Array","isArray","promises","forEach","row","rowIndex","push","fields","localized","Promise","all","blockTypeToMatch","blockType","block","payload","blocks","blockReferences","find","curBlock","slug","editor","Error","length","tabSiblingData","tabSiblingDoc","tabPreviousSiblingDoc","isNamedTab","tabs","tab"],"mappings":"AAOA,SAASA,iBAAiB,QAAQ,2BAA0B;AAC5D,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,wBAAuB;AACpE,SAASC,yBAAyBC,aAAa,QAAQ,yBAAwB;AAC/E,SAASC,cAAc,QAAQ,sBAAqB;AA2BpD,oEAAoE;AACpE,wBAAwB;AAExB,OAAO,MAAMC,UAAU,OAAO,EAC5BC,SAAS,EACTC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,KAAK,EACLC,UAAU,EACVC,MAAM,EACNC,SAAS,EACTC,eAAe,EACfC,iBAAiB,EACjBC,UAAU,EACVC,gBAAgB,EAChBC,WAAW,EACXC,kBAAkB,EAClBC,GAAG,EACHC,WAAW,EACXC,UAAU,EACVC,aAAa,EACR;IACL,MAAM,EAAEC,SAAS,EAAEC,IAAI,EAAEC,UAAU,EAAE,GAAGxB,cAAc;QACpDQ;QACAiB,OAAOhB;QACPG;QACAE;QACAC;IACF;IAEA,MAAMW,eAAeH,OAAOA,KAAKI,KAAK,CAAC,OAAO,EAAE;IAChD,MAAMC,qBAAqBJ,aAAaA,WAAWG,KAAK,CAAC,OAAO,EAAE;IAClE,MAAME,oBAAoBP,YAAYA,UAAUK,KAAK,CAAC,KAAKG,MAAM,CAACC,UAAUC,IAAIC,UAAU,EAAE;IAC5F,MAAMC,iBAAiB,CAAC5B,MAAkBiB,OACx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aAAa,KAAKrD;oBACnCT,mBAAmBA,qBAAqBL,MAAMiD,SAAS;oBACvD3C,YAAY6D,aAAapD,OAAOT;oBAChCC,kBAAkBS;oBAClBR;oBACAC,oBAAoByD;oBACpBxD;oBACAC,aAAaqD;oBACbpD,YAAYqD;gBACd;gBAEA;YACF;QAEA,KAAK;YAAQ;gBACX,MAAMxE,eAAe;oBACnBE;oBACAC;oBACAC;oBACAC;oBACAC;oBACAiD,QAAQhD,MAAMoE,IAAI,CAAC5C,GAAG,CAAC,CAAC6C,MAAS,CAAA;4BAAE,GAAGA,GAAG;4BAAE9B,MAAM;wBAAM,CAAA;oBACvDrC;oBACAC;oBACAC,iBAAiBU;oBACjBT;oBACAC,YAAYS;oBACZR,kBAAkBS;oBAClBR;oBACAC,oBAAoB;wBAAE,GAAGA,kBAAkB;oBAAC;oBAC5CC;oBACAC,aAAaA,eAAe,CAAC;oBAC7BC,YAAY;wBAAE,GAAGA,UAAU;oBAAC;gBAC9B;gBAEA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/fields/hooks/afterChange/promise.ts"],"sourcesContent":["import type { RichTextAdapter } from '../../../admin/RichText.js'\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { RequestContext } from '../../../index.js'\nimport type { JsonObject, PayloadRequest } from '../../../types/index.js'\nimport type { Block, Field, TabAsField } from '../../config/types.js'\n\nimport { MissingEditorProp } from '../../../errors/index.js'\nimport { fieldAffectsData, tabHasName } from '../../config/types.js'\nimport { getFieldPathsModified as getFieldPaths } from '../../getFieldPaths.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n /**\n * Data of the nearest parent block. If no parent block exists, this will be the `undefined`\n */\n blockData?: JsonObject\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n data: JsonObject\n doc: JsonObject\n field: Field | TabAsField\n fieldIndex: number\n global: null | SanitizedGlobalConfig\n operation: 'create' | 'update'\n parentIndexPath: string\n parentIsLocalized: boolean\n parentPath: string\n parentSchemaPath: string\n previousDoc: JsonObject\n previousSiblingDoc: JsonObject\n req: PayloadRequest\n siblingData: JsonObject\n siblingDoc: JsonObject\n siblingFields?: (Field | TabAsField)[]\n}\n\n// This function is responsible for the following actions, in order:\n// - Execute field hooks\n\nexport const promise = async ({\n blockData,\n collection,\n context,\n data,\n doc,\n field,\n fieldIndex,\n global,\n operation,\n parentIndexPath,\n parentIsLocalized,\n parentPath,\n parentSchemaPath,\n previousDoc,\n previousSiblingDoc,\n req,\n siblingData,\n siblingDoc,\n siblingFields,\n}: Args): Promise<void> => {\n const { indexPath, path, schemaPath } = getFieldPaths({\n field,\n index: fieldIndex,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n })\n\n const pathSegments = path ? path.split('.') : []\n const schemaPathSegments = schemaPath ? schemaPath.split('.') : []\n const indexPathSegments = indexPath ? indexPath.split('-').filter(Boolean)?.map(Number) : []\n const getNestedValue = (data: JsonObject, path: string[]) =>\n path.reduce((acc, key) => (acc && acc[key] !== undefined ? acc[key] : undefined), data)\n const previousValData =\n previousSiblingDoc && Object.keys(previousSiblingDoc).length > 0\n ? previousSiblingDoc\n : previousDoc\n\n if (fieldAffectsData(field)) {\n // Execute hooks\n if ('hooks' in field && field.hooks?.afterChange) {\n for (const hook of field.hooks.afterChange) {\n const hookedValue = await hook({\n blockData,\n collection,\n context,\n data,\n field,\n global,\n indexPath: indexPathSegments,\n operation,\n originalDoc: doc,\n path: pathSegments,\n previousDoc,\n previousSiblingDoc,\n previousValue:\n getNestedValue(previousValData, pathSegments) ?? previousValData?.[field.name],\n req,\n schemaPath: schemaPathSegments,\n siblingData,\n siblingFields: siblingFields!,\n value: getNestedValue(siblingDoc, pathSegments) ?? siblingDoc?.[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }\n }\n }\n\n // Traverse subfields\n switch (field.type) {\n case 'array': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n const promises: Promise<void>[] = []\n rows.forEach((row, rowIndex) => {\n promises.push(\n traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: '',\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: previousDoc?.[field.name]?.[rowIndex] || ({} as JsonObject),\n req,\n siblingData: siblingData?.[field.name]?.[rowIndex] || {},\n siblingDoc: row ? { ...row } : {},\n }),\n )\n })\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'blocks': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n const promises: Promise<void>[] = []\n\n rows.forEach((row, rowIndex) => {\n const blockTypeToMatch = (row as JsonObject).blockType\n\n const block: Block | undefined =\n req.payload.blocks[blockTypeToMatch] ??\n ((field.blockReferences ?? field.blocks).find(\n (curBlock) => typeof curBlock !== 'string' && curBlock.slug === blockTypeToMatch,\n ) as Block | undefined)\n\n if (block) {\n promises.push(\n traverseFields({\n blockData: siblingData?.[field.name]?.[rowIndex],\n collection,\n context,\n data,\n doc,\n fields: block.fields,\n global,\n operation,\n parentIndexPath: '',\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath + '.' + block.slug,\n previousDoc,\n previousSiblingDoc: previousValData?.[field.name]?.[rowIndex] || ({} as JsonObject),\n req,\n siblingData: siblingData?.[field.name]?.[rowIndex] || {},\n siblingDoc: row ? { ...row } : {},\n }),\n )\n }\n })\n\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'collapsible':\n case 'row': {\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: indexPath,\n parentIsLocalized,\n parentPath,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: { ...previousSiblingDoc },\n req,\n siblingData: siblingData || {},\n siblingDoc: { ...siblingDoc },\n })\n\n break\n }\n\n case 'group': {\n if (fieldAffectsData(field)) {\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: '',\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: path,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: (previousDoc?.[field.name] as JsonObject) || {},\n req,\n siblingData: (siblingData?.[field.name] as JsonObject) || {},\n siblingDoc: (siblingDoc?.[field.name] as JsonObject) || {},\n })\n } else {\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: indexPath,\n parentIsLocalized,\n parentPath,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: { ...previousSiblingDoc },\n req,\n siblingData: siblingData || {},\n siblingDoc: { ...siblingDoc },\n })\n }\n\n break\n }\n\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n\n if (typeof field.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n const editor: RichTextAdapter = field.editor\n\n if (editor?.hooks?.afterChange?.length) {\n for (const hook of editor.hooks.afterChange) {\n const hookedValue = await hook({\n collection,\n context,\n data,\n field,\n global,\n indexPath: indexPathSegments,\n operation,\n originalDoc: doc,\n parentIsLocalized,\n path: pathSegments,\n previousDoc,\n previousSiblingDoc,\n previousValue: previousDoc?.[field.name],\n req,\n schemaPath: schemaPathSegments,\n siblingData,\n value: siblingDoc?.[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }\n }\n break\n }\n\n case 'tab': {\n let tabSiblingData = siblingData\n let tabSiblingDoc = siblingDoc\n let tabPreviousSiblingDoc = siblingDoc\n\n const isNamedTab = tabHasName(field)\n\n if (isNamedTab) {\n tabSiblingData = (siblingData?.[field.name] ?? {}) as JsonObject\n tabSiblingDoc = (siblingDoc?.[field.name] ?? {}) as JsonObject\n tabPreviousSiblingDoc = (previousDoc?.[field.name] ?? {}) as JsonObject\n }\n\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: isNamedTab ? '' : indexPath,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: isNamedTab ? path : parentPath,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: tabPreviousSiblingDoc,\n req,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n operation,\n parentIndexPath: indexPath,\n parentIsLocalized,\n parentPath: path,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: { ...previousSiblingDoc },\n req,\n siblingData: siblingData || {},\n siblingDoc: { ...siblingDoc },\n })\n\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","fieldAffectsData","tabHasName","getFieldPathsModified","getFieldPaths","traverseFields","promise","blockData","collection","context","data","doc","field","fieldIndex","global","operation","parentIndexPath","parentIsLocalized","parentPath","parentSchemaPath","previousDoc","previousSiblingDoc","req","siblingData","siblingDoc","siblingFields","indexPath","path","schemaPath","index","pathSegments","split","schemaPathSegments","indexPathSegments","filter","Boolean","map","Number","getNestedValue","reduce","acc","key","undefined","previousValData","Object","keys","length","hooks","afterChange","hook","hookedValue","originalDoc","previousValue","name","value","type","rows","Array","isArray","promises","forEach","row","rowIndex","push","fields","localized","Promise","all","blockTypeToMatch","blockType","block","payload","blocks","blockReferences","find","curBlock","slug","editor","Error","tabSiblingData","tabSiblingDoc","tabPreviousSiblingDoc","isNamedTab","tabs","tab"],"mappings":"AAOA,SAASA,iBAAiB,QAAQ,2BAA0B;AAC5D,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,MAAS,CAAA;4BAAE,GAAGA,GAAG;4BAAE7B,MAAM;wBAAM,CAAA;oBACvDzC;oBACAC;oBACAC,iBAAiBU;oBACjBT;oBACAC,YAAYS;oBACZR,kBAAkBS;oBAClBR;oBACAC,oBAAoB;wBAAE,GAAGA,kBAAkB;oBAAC;oBAC5CC;oBACAC,aAAaA,eAAe,CAAC;oBAC7BC,YAAY;wBAAE,GAAGA,UAAU;oBAAC;gBAC9B;gBAEA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getFile.d.ts","sourceRoot":"","sources":["../../../src/uploads/endpoints/getFile.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAS3D,eAAO,MAAM,cAAc,EAAE,cAsG5B,CAAA"}
1
+ {"version":3,"file":"getFile.d.ts","sourceRoot":"","sources":["../../../src/uploads/endpoints/getFile.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAU3D,eAAO,MAAM,cAAc,EAAE,cA8I5B,CAAA"}
@@ -6,6 +6,7 @@ import { APIError } from '../../errors/APIError.js';
6
6
  import { checkFileAccess } from '../../uploads/checkFileAccess.js';
7
7
  import { streamFile } from '../../uploads/fetchAPI-stream-file/index.js';
8
8
  import { getFileTypeFallback } from '../../uploads/getFileTypeFallback.js';
9
+ import { parseRangeHeader } from '../../uploads/parseRangeHeader.js';
9
10
  import { getRequestCollection } from '../../utilities/getRequestEntity.js';
10
11
  import { headersWithCors } from '../../utilities/headersWithCors.js';
11
12
  export const getFileHandler = async (req)=>{
@@ -68,15 +69,57 @@ export const getFileHandler = async (req)=>{
68
69
  }
69
70
  throw err;
70
71
  }
71
- const data = streamFile(filePath);
72
72
  const fileTypeResult = await fileTypeFromFile(filePath) || getFileTypeFallback(filePath);
73
73
  let mimeType = fileTypeResult.mime;
74
74
  if (filePath.endsWith('.svg') && fileTypeResult.mime === 'application/xml') {
75
75
  mimeType = 'image/svg+xml';
76
76
  }
77
+ // Parse Range header for byte range requests
78
+ const rangeHeader = req.headers.get('range');
79
+ const rangeResult = parseRangeHeader({
80
+ fileSize: stats.size,
81
+ rangeHeader
82
+ });
83
+ if (rangeResult.type === 'invalid') {
84
+ let headers = new Headers();
85
+ headers.set('Content-Range', `bytes */${stats.size}`);
86
+ headers = collection.config.upload?.modifyResponseHeaders ? collection.config.upload.modifyResponseHeaders({
87
+ headers
88
+ }) || headers : headers;
89
+ return new Response(null, {
90
+ headers: headersWithCors({
91
+ headers,
92
+ req
93
+ }),
94
+ status: httpStatus.REQUESTED_RANGE_NOT_SATISFIABLE
95
+ });
96
+ }
77
97
  let headers = new Headers();
78
98
  headers.set('Content-Type', mimeType);
79
- headers.set('Content-Length', stats.size + '');
99
+ headers.set('Accept-Ranges', 'bytes');
100
+ let data;
101
+ let status;
102
+ const isPartial = rangeResult.type === 'partial';
103
+ const range = rangeResult.range;
104
+ if (isPartial && range) {
105
+ const contentLength = range.end - range.start + 1;
106
+ headers.set('Content-Length', String(contentLength));
107
+ headers.set('Content-Range', `bytes ${range.start}-${range.end}/${stats.size}`);
108
+ data = streamFile({
109
+ filePath,
110
+ options: {
111
+ end: range.end,
112
+ start: range.start
113
+ }
114
+ });
115
+ status = httpStatus.PARTIAL_CONTENT;
116
+ } else {
117
+ headers.set('Content-Length', String(stats.size));
118
+ data = streamFile({
119
+ filePath
120
+ });
121
+ status = httpStatus.OK;
122
+ }
80
123
  headers = collection.config.upload?.modifyResponseHeaders ? collection.config.upload.modifyResponseHeaders({
81
124
  headers
82
125
  }) || headers : headers;
@@ -85,7 +128,7 @@ export const getFileHandler = async (req)=>{
85
128
  headers,
86
129
  req
87
130
  }),
88
- status: httpStatus.OK
131
+ status
89
132
  });
90
133
  };
91
134
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/uploads/endpoints/getFile.ts"],"sourcesContent":["import type { Stats } from 'fs'\n\nimport { fileTypeFromFile } from 'file-type'\nimport fsPromises from 'fs/promises'\nimport { status as httpStatus } from 'http-status'\nimport path from 'path'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { APIError } from '../../errors/APIError.js'\nimport { checkFileAccess } from '../../uploads/checkFileAccess.js'\nimport { streamFile } from '../../uploads/fetchAPI-stream-file/index.js'\nimport { getFileTypeFallback } from '../../uploads/getFileTypeFallback.js'\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\n\nexport const getFileHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n\n const filename = req.routeParams?.filename as string\n\n if (!collection.config.upload) {\n throw new APIError(\n `This collection is not an upload collection: ${collection.config.slug}`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n const accessResult = (await checkFileAccess({\n collection,\n filename,\n req,\n }))!\n\n if (accessResult instanceof Response) {\n return accessResult\n }\n\n if (collection.config.upload.handlers?.length) {\n let customResponse: null | Response | void = null\n const headers = new Headers()\n\n for (const handler of collection.config.upload.handlers) {\n customResponse = await handler(req, {\n doc: accessResult,\n headers,\n params: {\n collection: collection.config.slug,\n filename,\n },\n })\n if (customResponse && customResponse instanceof Response) {\n break\n }\n }\n\n if (customResponse instanceof Response) {\n return customResponse\n }\n }\n\n const fileDir = collection.config.upload?.staticDir || collection.config.slug\n const filePath = path.resolve(`${fileDir}/${filename}`)\n let stats: Stats\n\n try {\n stats = await fsPromises.stat(filePath)\n } catch (err) {\n if ((err as { code?: string }).code === 'ENOENT') {\n req.payload.logger.error(\n `File ${filename} for collection ${collection.config.slug} is missing on the disk. Expected path: ${filePath}`,\n )\n\n // Omit going to the routeError handler by returning response instead of\n // throwing an error to cut down log noise. The response still matches what you get with APIError to not leak details to the user.\n return Response.json(\n {\n errors: [\n {\n message: 'Something went wrong.',\n },\n ],\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: 500,\n },\n )\n }\n\n throw err\n }\n\n const data = streamFile(filePath)\n const fileTypeResult = (await fileTypeFromFile(filePath)) || getFileTypeFallback(filePath)\n let mimeType = fileTypeResult.mime\n\n if (filePath.endsWith('.svg') && fileTypeResult.mime === 'application/xml') {\n mimeType = 'image/svg+xml'\n }\n\n let headers = new Headers()\n headers.set('Content-Type', mimeType)\n headers.set('Content-Length', stats.size + '')\n headers = collection.config.upload?.modifyResponseHeaders\n ? collection.config.upload.modifyResponseHeaders({ headers }) || headers\n : headers\n\n return new Response(data, {\n headers: headersWithCors({\n headers,\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"names":["fileTypeFromFile","fsPromises","status","httpStatus","path","APIError","checkFileAccess","streamFile","getFileTypeFallback","getRequestCollection","headersWithCors","getFileHandler","req","collection","filename","routeParams","config","upload","slug","BAD_REQUEST","accessResult","Response","handlers","length","customResponse","headers","Headers","handler","doc","params","fileDir","staticDir","filePath","resolve","stats","stat","err","code","payload","logger","error","json","errors","message","data","fileTypeResult","mimeType","mime","endsWith","set","size","modifyResponseHeaders","OK"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,YAAW;AAC5C,OAAOC,gBAAgB,cAAa;AACpC,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAClD,OAAOC,UAAU,OAAM;AAIvB,SAASC,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,eAAe,QAAQ,mCAAkC;AAClE,SAASC,UAAU,QAAQ,8CAA6C;AACxE,SAASC,mBAAmB,QAAQ,uCAAsC;AAC1E,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AAEpE,OAAO,MAAMC,iBAAiC,OAAOC;IACnD,MAAMC,aAAaJ,qBAAqBG;IAExC,MAAME,WAAWF,IAAIG,WAAW,EAAED;IAElC,IAAI,CAACD,WAAWG,MAAM,CAACC,MAAM,EAAE;QAC7B,MAAM,IAAIZ,SACR,CAAC,6CAA6C,EAAEQ,WAAWG,MAAM,CAACE,IAAI,EAAE,EAC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;IACR;IAEA,MAAMQ,OAAOrC,WAAWyB;IACxB,MAAMa,iBAAiB,AAAC,MAAM7C,iBAAiBgC,aAAcxB,oBAAoBwB;IACjF,IAAIc,WAAWD,eAAeE,IAAI;IAElC,IAAIf,SAASgB,QAAQ,CAAC,WAAWH,eAAeE,IAAI,KAAK,mBAAmB;QAC1ED,WAAW;IACb;IAEA,IAAIrB,UAAU,IAAIC;IAClBD,QAAQwB,GAAG,CAAC,gBAAgBH;IAC5BrB,QAAQwB,GAAG,CAAC,kBAAkBf,MAAMgB,IAAI,GAAG;IAC3CzB,UAAUZ,WAAWG,MAAM,CAACC,MAAM,EAAEkC,wBAChCtC,WAAWG,MAAM,CAACC,MAAM,CAACkC,qBAAqB,CAAC;QAAE1B;IAAQ,MAAMA,UAC/DA;IAEJ,OAAO,IAAIJ,SAASuB,MAAM;QACxBnB,SAASf,gBAAgB;YACvBe;YACAb;QACF;QACAV,QAAQC,WAAWiD,EAAE;IACvB;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/uploads/endpoints/getFile.ts"],"sourcesContent":["import type { Stats } from 'fs'\n\nimport { fileTypeFromFile } from 'file-type'\nimport fsPromises from 'fs/promises'\nimport { status as httpStatus } from 'http-status'\nimport path from 'path'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { APIError } from '../../errors/APIError.js'\nimport { checkFileAccess } from '../../uploads/checkFileAccess.js'\nimport { streamFile } from '../../uploads/fetchAPI-stream-file/index.js'\nimport { getFileTypeFallback } from '../../uploads/getFileTypeFallback.js'\nimport { parseRangeHeader } from '../../uploads/parseRangeHeader.js'\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\n\nexport const getFileHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n\n const filename = req.routeParams?.filename as string\n\n if (!collection.config.upload) {\n throw new APIError(\n `This collection is not an upload collection: ${collection.config.slug}`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n const accessResult = (await checkFileAccess({\n collection,\n filename,\n req,\n }))!\n\n if (accessResult instanceof Response) {\n return accessResult\n }\n\n if (collection.config.upload.handlers?.length) {\n let customResponse: null | Response | void = null\n const headers = new Headers()\n\n for (const handler of collection.config.upload.handlers) {\n customResponse = await handler(req, {\n doc: accessResult,\n headers,\n params: {\n collection: collection.config.slug,\n filename,\n },\n })\n if (customResponse && customResponse instanceof Response) {\n break\n }\n }\n\n if (customResponse instanceof Response) {\n return customResponse\n }\n }\n\n const fileDir = collection.config.upload?.staticDir || collection.config.slug\n const filePath = path.resolve(`${fileDir}/${filename}`)\n let stats: Stats\n\n try {\n stats = await fsPromises.stat(filePath)\n } catch (err) {\n if ((err as { code?: string }).code === 'ENOENT') {\n req.payload.logger.error(\n `File ${filename} for collection ${collection.config.slug} is missing on the disk. Expected path: ${filePath}`,\n )\n\n // Omit going to the routeError handler by returning response instead of\n // throwing an error to cut down log noise. The response still matches what you get with APIError to not leak details to the user.\n return Response.json(\n {\n errors: [\n {\n message: 'Something went wrong.',\n },\n ],\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: 500,\n },\n )\n }\n\n throw err\n }\n\n const fileTypeResult = (await fileTypeFromFile(filePath)) || getFileTypeFallback(filePath)\n let mimeType = fileTypeResult.mime\n\n if (filePath.endsWith('.svg') && fileTypeResult.mime === 'application/xml') {\n mimeType = 'image/svg+xml'\n }\n\n // Parse Range header for byte range requests\n const rangeHeader = req.headers.get('range')\n const rangeResult = parseRangeHeader({\n fileSize: stats.size,\n rangeHeader,\n })\n\n if (rangeResult.type === 'invalid') {\n let headers = new Headers()\n headers.set('Content-Range', `bytes */${stats.size}`)\n headers = collection.config.upload?.modifyResponseHeaders\n ? collection.config.upload.modifyResponseHeaders({ headers }) || headers\n : headers\n\n return new Response(null, {\n headers: headersWithCors({\n headers,\n req,\n }),\n status: httpStatus.REQUESTED_RANGE_NOT_SATISFIABLE,\n })\n }\n\n let headers = new Headers()\n headers.set('Content-Type', mimeType)\n headers.set('Accept-Ranges', 'bytes')\n\n let data: ReadableStream\n let status: number\n const isPartial = rangeResult.type === 'partial'\n const range = rangeResult.range\n\n if (isPartial && range) {\n const contentLength = range.end - range.start + 1\n headers.set('Content-Length', String(contentLength))\n headers.set('Content-Range', `bytes ${range.start}-${range.end}/${stats.size}`)\n data = streamFile({ filePath, options: { end: range.end, start: range.start } })\n status = httpStatus.PARTIAL_CONTENT\n } else {\n headers.set('Content-Length', String(stats.size))\n data = streamFile({ filePath })\n status = httpStatus.OK\n }\n\n headers = collection.config.upload?.modifyResponseHeaders\n ? collection.config.upload.modifyResponseHeaders({ headers }) || headers\n : headers\n\n return new Response(data, {\n headers: headersWithCors({\n headers,\n req,\n }),\n status,\n })\n}\n"],"names":["fileTypeFromFile","fsPromises","status","httpStatus","path","APIError","checkFileAccess","streamFile","getFileTypeFallback","parseRangeHeader","getRequestCollection","headersWithCors","getFileHandler","req","collection","filename","routeParams","config","upload","slug","BAD_REQUEST","accessResult","Response","handlers","length","customResponse","headers","Headers","handler","doc","params","fileDir","staticDir","filePath","resolve","stats","stat","err","code","payload","logger","error","json","errors","message","fileTypeResult","mimeType","mime","endsWith","rangeHeader","get","rangeResult","fileSize","size","type","set","modifyResponseHeaders","REQUESTED_RANGE_NOT_SATISFIABLE","data","isPartial","range","contentLength","end","start","String","options","PARTIAL_CONTENT","OK"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,YAAW;AAC5C,OAAOC,gBAAgB,cAAa;AACpC,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAClD,OAAOC,UAAU,OAAM;AAIvB,SAASC,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,eAAe,QAAQ,mCAAkC;AAClE,SAASC,UAAU,QAAQ,8CAA6C;AACxE,SAASC,mBAAmB,QAAQ,uCAAsC;AAC1E,SAASC,gBAAgB,QAAQ,oCAAmC;AACpE,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC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MAAME,GAAG,GAAGF,MAAMG,KAAK,GAAG;QAChDrC,QAAQ6B,GAAG,CAAC,kBAAkBS,OAAOH;QACrCnC,QAAQ6B,GAAG,CAAC,iBAAiB,CAAC,MAAM,EAAEK,MAAMG,KAAK,CAAC,CAAC,EAAEH,MAAME,GAAG,CAAC,CAAC,EAAE3B,MAAMkB,IAAI,EAAE;QAC9EK,OAAOnD,WAAW;YAAE0B;YAAUgC,SAAS;gBAAEH,KAAKF,MAAME,GAAG;gBAAEC,OAAOH,MAAMG,KAAK;YAAC;QAAE;QAC9E7D,SAASC,WAAW+D,eAAe;IACrC,OAAO;QACLxC,QAAQ6B,GAAG,CAAC,kBAAkBS,OAAO7B,MAAMkB,IAAI;QAC/CK,OAAOnD,WAAW;YAAE0B;QAAS;QAC7B/B,SAASC,WAAWgE,EAAE;IACxB;IAEAzC,UAAUZ,WAAWG,MAAM,CAACC,MAAM,EAAEsC,wBAChC1C,WAAWG,MAAM,CAACC,MAAM,CAACsC,qBAAqB,CAAC;QAAE9B;IAAQ,MAAMA,UAC/DA;IAEJ,OAAO,IAAIJ,SAASoC,MAAM;QACxBhC,SAASf,gBAAgB;YACvBe;YACAb;QACF;QACAX;IACF;AACF,EAAC"}
@@ -1,5 +1,11 @@
1
1
  import fs from 'fs';
2
2
  export declare function iteratorToStream(iterator: AsyncIterator<Uint8Array>): import("stream/web").ReadableStream<any>;
3
3
  export declare function nodeStreamToIterator(stream: fs.ReadStream): AsyncGenerator<Uint8Array<any>, void, unknown>;
4
- export declare function streamFile(path: string): ReadableStream;
4
+ export declare function streamFile({ filePath, options, }: {
5
+ filePath: string;
6
+ options?: {
7
+ end?: number;
8
+ start?: number;
9
+ };
10
+ }): ReadableStream;
5
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/uploads/fetchAPI-stream-file/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,4CAWnE;AAED,wBAAuB,oBAAoB,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,kDAIhE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAIvD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/uploads/fetchAPI-stream-file/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,4CAWnE;AAED,wBAAuB,oBAAoB,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,kDAIhE;AAED,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAC3C,GAAG,cAAc,CAIjB"}
@@ -16,8 +16,8 @@ export async function* nodeStreamToIterator(stream) {
16
16
  yield new Uint8Array(chunk);
17
17
  }
18
18
  }
19
- export function streamFile(path) {
20
- const nodeStream = fs.createReadStream(path);
19
+ export function streamFile({ filePath, options }) {
20
+ const nodeStream = fs.createReadStream(filePath, options);
21
21
  const data = iteratorToStream(nodeStreamToIterator(nodeStream));
22
22
  return data;
23
23
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/uploads/fetchAPI-stream-file/index.ts"],"sourcesContent":["import fs from 'fs'\n\nexport function iteratorToStream(iterator: AsyncIterator<Uint8Array>) {\n return new ReadableStream({\n async pull(controller) {\n const { done, value } = await iterator.next()\n if (done) {\n controller.close()\n } else {\n controller.enqueue(value)\n }\n },\n })\n}\n\nexport async function* nodeStreamToIterator(stream: fs.ReadStream) {\n for await (const chunk of stream) {\n yield new Uint8Array(chunk)\n }\n}\n\nexport function streamFile(path: string): ReadableStream {\n const nodeStream = fs.createReadStream(path)\n const data: ReadableStream = iteratorToStream(nodeStreamToIterator(nodeStream))\n return data\n}\n"],"names":["fs","iteratorToStream","iterator","ReadableStream","pull","controller","done","value","next","close","enqueue","nodeStreamToIterator","stream","chunk","Uint8Array","streamFile","path","nodeStream","createReadStream","data"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AAEnB,OAAO,SAASC,iBAAiBC,QAAmC;IAClE,OAAO,IAAIC,eAAe;QACxB,MAAMC,MAAKC,UAAU;YACnB,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAG,MAAML,SAASM,IAAI;YAC3C,IAAIF,MAAM;gBACRD,WAAWI,KAAK;YAClB,OAAO;gBACLJ,WAAWK,OAAO,CAACH;YACrB;QACF;IACF;AACF;AAEA,OAAO,gBAAgBI,qBAAqBC,MAAqB;IAC/D,WAAW,MAAMC,SAASD,OAAQ;QAChC,MAAM,IAAIE,WAAWD;IACvB;AACF;AAEA,OAAO,SAASE,WAAWC,IAAY;IACrC,MAAMC,aAAajB,GAAGkB,gBAAgB,CAACF;IACvC,MAAMG,OAAuBlB,iBAAiBU,qBAAqBM;IACnE,OAAOE;AACT"}
1
+ {"version":3,"sources":["../../../src/uploads/fetchAPI-stream-file/index.ts"],"sourcesContent":["import fs from 'fs'\n\nexport function iteratorToStream(iterator: AsyncIterator<Uint8Array>) {\n return new ReadableStream({\n async pull(controller) {\n const { done, value } = await iterator.next()\n if (done) {\n controller.close()\n } else {\n controller.enqueue(value)\n }\n },\n })\n}\n\nexport async function* nodeStreamToIterator(stream: fs.ReadStream) {\n for await (const chunk of stream) {\n yield new Uint8Array(chunk)\n }\n}\n\nexport function streamFile({\n filePath,\n options,\n}: {\n filePath: string\n options?: { end?: number; start?: number }\n}): ReadableStream {\n const nodeStream = fs.createReadStream(filePath, options)\n const data: ReadableStream = iteratorToStream(nodeStreamToIterator(nodeStream))\n return data\n}\n"],"names":["fs","iteratorToStream","iterator","ReadableStream","pull","controller","done","value","next","close","enqueue","nodeStreamToIterator","stream","chunk","Uint8Array","streamFile","filePath","options","nodeStream","createReadStream","data"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AAEnB,OAAO,SAASC,iBAAiBC,QAAmC;IAClE,OAAO,IAAIC,eAAe;QACxB,MAAMC,MAAKC,UAAU;YACnB,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAG,MAAML,SAASM,IAAI;YAC3C,IAAIF,MAAM;gBACRD,WAAWI,KAAK;YAClB,OAAO;gBACLJ,WAAWK,OAAO,CAACH;YACrB;QACF;IACF;AACF;AAEA,OAAO,gBAAgBI,qBAAqBC,MAAqB;IAC/D,WAAW,MAAMC,SAASD,OAAQ;QAChC,MAAM,IAAIE,WAAWD;IACvB;AACF;AAEA,OAAO,SAASE,WAAW,EACzBC,QAAQ,EACRC,OAAO,EAIR;IACC,MAAMC,aAAalB,GAAGmB,gBAAgB,CAACH,UAAUC;IACjD,MAAMG,OAAuBnB,iBAAiBU,qBAAqBO;IACnE,OAAOE;AACT"}
@@ -0,0 +1,24 @@
1
+ export type ByteRange = {
2
+ end: number;
3
+ start: number;
4
+ };
5
+ export type ParseRangeResult = {
6
+ range: ByteRange;
7
+ type: 'partial';
8
+ } | {
9
+ range: null;
10
+ type: 'full';
11
+ } | {
12
+ range: null;
13
+ type: 'invalid';
14
+ };
15
+ /**
16
+ * Parses HTTP Range header according to RFC 7233
17
+ *
18
+ * @returns Result object indicating whether to serve full file, partial content, or invalid range
19
+ */
20
+ export declare function parseRangeHeader({ fileSize, rangeHeader, }: {
21
+ fileSize: number;
22
+ rangeHeader: null | string;
23
+ }): ParseRangeResult;
24
+ //# sourceMappingURL=parseRangeHeader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseRangeHeader.d.ts","sourceRoot":"","sources":["../../src/uploads/parseRangeHeader.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,gBAAgB,GACxB;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GACrC;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC7B;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAA;AAEpC;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,WAAW,GACZ,EAAE;IACD,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,IAAI,GAAG,MAAM,CAAA;CAC3B,GAAG,gBAAgB,CAoCnB"}
@@ -0,0 +1,52 @@
1
+ import parseRange from 'range-parser';
2
+ /**
3
+ * Parses HTTP Range header according to RFC 7233
4
+ *
5
+ * @returns Result object indicating whether to serve full file, partial content, or invalid range
6
+ */ export function parseRangeHeader({ fileSize, rangeHeader }) {
7
+ // No Range header - serve full file
8
+ if (!rangeHeader) {
9
+ return {
10
+ type: 'full',
11
+ range: null
12
+ };
13
+ }
14
+ const result = parseRange(fileSize, rangeHeader);
15
+ // Invalid range syntax or unsatisfiable range
16
+ if (result === -1 || result === -2) {
17
+ return {
18
+ type: 'invalid',
19
+ range: null
20
+ };
21
+ }
22
+ // Must be bytes range type
23
+ if (result.type !== 'bytes') {
24
+ return {
25
+ type: 'invalid',
26
+ range: null
27
+ };
28
+ }
29
+ // Multi-range requests: use first range only (standard simplification)
30
+ if (result.length === 0) {
31
+ return {
32
+ type: 'invalid',
33
+ range: null
34
+ };
35
+ }
36
+ const range = result[0];
37
+ if (range) {
38
+ return {
39
+ type: 'partial',
40
+ range: {
41
+ end: range.end,
42
+ start: range.start
43
+ }
44
+ };
45
+ }
46
+ return {
47
+ type: 'invalid',
48
+ range: null
49
+ };
50
+ }
51
+
52
+ //# sourceMappingURL=parseRangeHeader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/uploads/parseRangeHeader.ts"],"sourcesContent":["import parseRange from 'range-parser'\n\nexport type ByteRange = {\n end: number\n start: number\n}\n\nexport type ParseRangeResult =\n | { range: ByteRange; type: 'partial' }\n | { range: null; type: 'full' }\n | { range: null; type: 'invalid' }\n\n/**\n * Parses HTTP Range header according to RFC 7233\n *\n * @returns Result object indicating whether to serve full file, partial content, or invalid range\n */\nexport function parseRangeHeader({\n fileSize,\n rangeHeader,\n}: {\n fileSize: number\n rangeHeader: null | string\n}): ParseRangeResult {\n // No Range header - serve full file\n if (!rangeHeader) {\n return { type: 'full', range: null }\n }\n\n const result = parseRange(fileSize, rangeHeader)\n\n // Invalid range syntax or unsatisfiable range\n if (result === -1 || result === -2) {\n return { type: 'invalid', range: null }\n }\n\n // Must be bytes range type\n if (result.type !== 'bytes') {\n return { type: 'invalid', range: null }\n }\n\n // Multi-range requests: use first range only (standard simplification)\n if (result.length === 0) {\n return { type: 'invalid', range: null }\n }\n\n const range = result[0]\n\n if (range) {\n return {\n type: 'partial',\n range: {\n end: range.end,\n start: range.start,\n },\n }\n }\n\n return { type: 'invalid', range: null }\n}\n"],"names":["parseRange","parseRangeHeader","fileSize","rangeHeader","type","range","result","length","end","start"],"mappings":"AAAA,OAAOA,gBAAgB,eAAc;AAYrC;;;;CAIC,GACD,OAAO,SAASC,iBAAiB,EAC/BC,QAAQ,EACRC,WAAW,EAIZ;IACC,oCAAoC;IACpC,IAAI,CAACA,aAAa;QAChB,OAAO;YAAEC,MAAM;YAAQC,OAAO;QAAK;IACrC;IAEA,MAAMC,SAASN,WAAWE,UAAUC;IAEpC,8CAA8C;IAC9C,IAAIG,WAAW,CAAC,KAAKA,WAAW,CAAC,GAAG;QAClC,OAAO;YAAEF,MAAM;YAAWC,OAAO;QAAK;IACxC;IAEA,2BAA2B;IAC3B,IAAIC,OAAOF,IAAI,KAAK,SAAS;QAC3B,OAAO;YAAEA,MAAM;YAAWC,OAAO;QAAK;IACxC;IAEA,uEAAuE;IACvE,IAAIC,OAAOC,MAAM,KAAK,GAAG;QACvB,OAAO;YAAEH,MAAM;YAAWC,OAAO;QAAK;IACxC;IAEA,MAAMA,QAAQC,MAAM,CAAC,EAAE;IAEvB,IAAID,OAAO;QACT,OAAO;YACLD,MAAM;YACNC,OAAO;gBACLG,KAAKH,MAAMG,GAAG;gBACdC,OAAOJ,MAAMI,KAAK;YACpB;QACF;IACF;IAEA,OAAO;QAAEL,MAAM;QAAWC,OAAO;IAAK;AACxC"}
@@ -1 +1 @@
1
- {"version":3,"file":"canAccessAdmin.d.ts","sourceRoot":"","sources":["../../src/utilities/canAccessAdmin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,YAAmB;IAAE,GAAG,EAAE,cAAc,CAAA;CAAE,kBA8BpE,CAAA"}
1
+ {"version":3,"file":"canAccessAdmin.d.ts","sourceRoot":"","sources":["../../src/utilities/canAccessAdmin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAIvD;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,YAAmB;IAAE,GAAG,EAAE,cAAc,CAAA;CAAE,kBA8BpE,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { UnauthorizedError } from '../errors/UnauthorizedError.js';
1
2
  /**
2
3
  * Protects admin-only routes, server functions, etc.
3
4
  * The requesting user must either:
@@ -15,11 +16,11 @@
15
16
  req
16
17
  });
17
18
  if (!canAccess) {
18
- throw new Error('Unauthorized');
19
+ throw new UnauthorizedError();
19
20
  }
20
21
  // Match the user collection to the global admin config
21
22
  } else if (adminUserSlug !== incomingUserSlug) {
22
- throw new Error('Unauthorized');
23
+ throw new UnauthorizedError();
23
24
  }
24
25
  } else {
25
26
  const hasUsers = await req.payload.find({
@@ -30,7 +31,7 @@
30
31
  });
31
32
  // If there are users, we should not allow access because of `/create-first-user`
32
33
  if (hasUsers.docs.length) {
33
- throw new Error('Unauthorized');
34
+ throw new UnauthorizedError();
34
35
  }
35
36
  }
36
37
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/canAccessAdmin.ts"],"sourcesContent":["import type { PayloadRequest } from '../types/index.js'\n\n/**\n * Protects admin-only routes, server functions, etc.\n * The requesting user must either:\n * a. pass the `access.admin` function on the `users` collection, if defined\n * b. match the `config.admin.user` property on the Payload config\n * c. if no user is present, and there are no users in the system, allow access (for first user creation)\n * @throws {Error} Throws an `Unauthorized` error if access is denied that can be explicitly caught\n */\nexport const canAccessAdmin = async ({ req }: { req: PayloadRequest }) => {\n const incomingUserSlug = req.user?.collection\n const adminUserSlug = req.payload.config.admin.user\n\n if (incomingUserSlug) {\n const adminAccessFn = req.payload.collections[incomingUserSlug]?.config.access?.admin\n\n if (adminAccessFn) {\n const canAccess = await adminAccessFn({ req })\n\n if (!canAccess) {\n throw new Error('Unauthorized')\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n throw new Error('Unauthorized')\n }\n } else {\n const hasUsers = await req.payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n // If there are users, we should not allow access because of `/create-first-user`\n if (hasUsers.docs.length) {\n throw new Error('Unauthorized')\n }\n }\n}\n"],"names":["canAccessAdmin","req","incomingUserSlug","user","collection","adminUserSlug","payload","config","admin","adminAccessFn","collections","access","canAccess","Error","hasUsers","find","depth","limit","pagination","docs","length"],"mappings":"AAEA;;;;;;;CAOC,GACD,OAAO,MAAMA,iBAAiB,OAAO,EAAEC,GAAG,EAA2B;IACnE,MAAMC,mBAAmBD,IAAIE,IAAI,EAAEC;IACnC,MAAMC,gBAAgBJ,IAAIK,OAAO,CAACC,MAAM,CAACC,KAAK,CAACL,IAAI;IAEnD,IAAID,kBAAkB;QACpB,MAAMO,gBAAgBR,IAAIK,OAAO,CAACI,WAAW,CAACR,iBAAiB,EAAEK,OAAOI,QAAQH;QAEhF,IAAIC,eAAe;YACjB,MAAMG,YAAY,MAAMH,cAAc;gBAAER;YAAI;YAE5C,IAAI,CAACW,WAAW;gBACd,MAAM,IAAIC,MAAM;YAClB;QACA,uDAAuD;QACzD,OAAO,IAAIR,kBAAkBH,kBAAkB;YAC7C,MAAM,IAAIW,MAAM;QAClB;IACF,OAAO;QACL,MAAMC,WAAW,MAAMb,IAAIK,OAAO,CAACS,IAAI,CAAC;YACtCX,YAAYC;YACZW,OAAO;YACPC,OAAO;YACPC,YAAY;QACd;QAEA,iFAAiF;QACjF,IAAIJ,SAASK,IAAI,CAACC,MAAM,EAAE;YACxB,MAAM,IAAIP,MAAM;QAClB;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/canAccessAdmin.ts"],"sourcesContent":["import type { PayloadRequest } from '../types/index.js'\n\nimport { UnauthorizedError } from '../errors/UnauthorizedError.js'\n\n/**\n * Protects admin-only routes, server functions, etc.\n * The requesting user must either:\n * a. pass the `access.admin` function on the `users` collection, if defined\n * b. match the `config.admin.user` property on the Payload config\n * c. if no user is present, and there are no users in the system, allow access (for first user creation)\n * @throws {Error} Throws an `Unauthorized` error if access is denied that can be explicitly caught\n */\nexport const canAccessAdmin = async ({ req }: { req: PayloadRequest }) => {\n const incomingUserSlug = req.user?.collection\n const adminUserSlug = req.payload.config.admin.user\n\n if (incomingUserSlug) {\n const adminAccessFn = req.payload.collections[incomingUserSlug]?.config.access?.admin\n\n if (adminAccessFn) {\n const canAccess = await adminAccessFn({ req })\n\n if (!canAccess) {\n throw new UnauthorizedError()\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n throw new UnauthorizedError()\n }\n } else {\n const hasUsers = await req.payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n // If there are users, we should not allow access because of `/create-first-user`\n if (hasUsers.docs.length) {\n throw new UnauthorizedError()\n }\n }\n}\n"],"names":["UnauthorizedError","canAccessAdmin","req","incomingUserSlug","user","collection","adminUserSlug","payload","config","admin","adminAccessFn","collections","access","canAccess","hasUsers","find","depth","limit","pagination","docs","length"],"mappings":"AAEA,SAASA,iBAAiB,QAAQ,iCAAgC;AAElE;;;;;;;CAOC,GACD,OAAO,MAAMC,iBAAiB,OAAO,EAAEC,GAAG,EAA2B;IACnE,MAAMC,mBAAmBD,IAAIE,IAAI,EAAEC;IACnC,MAAMC,gBAAgBJ,IAAIK,OAAO,CAACC,MAAM,CAACC,KAAK,CAACL,IAAI;IAEnD,IAAID,kBAAkB;QACpB,MAAMO,gBAAgBR,IAAIK,OAAO,CAACI,WAAW,CAACR,iBAAiB,EAAEK,OAAOI,QAAQH;QAEhF,IAAIC,eAAe;YACjB,MAAMG,YAAY,MAAMH,cAAc;gBAAER;YAAI;YAE5C,IAAI,CAACW,WAAW;gBACd,MAAM,IAAIb;YACZ;QACA,uDAAuD;QACzD,OAAO,IAAIM,kBAAkBH,kBAAkB;YAC7C,MAAM,IAAIH;QACZ;IACF,OAAO;QACL,MAAMc,WAAW,MAAMZ,IAAIK,OAAO,CAACQ,IAAI,CAAC;YACtCV,YAAYC;YACZU,OAAO;YACPC,OAAO;YACPC,YAAY;QACd;QAEA,iFAAiF;QACjF,IAAIJ,SAASK,IAAI,CAACC,MAAM,EAAE;YACxB,MAAM,IAAIpB;QACZ;IACF;AACF,EAAC"}
@@ -1,9 +1,24 @@
1
1
  import type { Config } from '../config/types.js';
2
- /** Will read the `routes.admin` config and appropriately handle `"/"` admin paths */
2
+ /**
3
+ * This function builds correct URLs for admin panel routing.
4
+ * Its primary responsibilities are:
5
+ * 1. Read from your `routes.admin` config and appropriately handle `"/"` admin paths
6
+ * 2. Prepend the `basePath` from your Next.js config, if specified
7
+ * 3. Return relative or absolute URLs, as needed
8
+ */
3
9
  export declare const formatAdminURL: (args: {
4
10
  adminRoute: NonNullable<Config["routes"]>["admin"];
11
+ /**
12
+ * The subpath of your application, if specified.
13
+ * @see https://nextjs.org/docs/app/api-reference/config/next-config-js/basePath
14
+ * @example '/docs'
15
+ */
5
16
  basePath?: string;
6
- path: "" | `/${string}` | null | undefined;
7
- serverURL?: Config["serverURL"];
8
- }) => string;
17
+ path?: "" | `/${string}` | null;
18
+ /**
19
+ * Return a relative URL, e.g. ignore `serverURL`.
20
+ * Useful for route-matching, etc.
21
+ */
22
+ relative?: boolean;
23
+ } & Pick<Config, "serverURL">) => string;
9
24
  //# sourceMappingURL=formatAdminURL.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatAdminURL.d.ts","sourceRoot":"","sources":["../../src/utilities/formatAdminURL.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD,qFAAqF;AACrF,eAAO,MAAM,cAAc,SAAU;IACnC,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,CAAA;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC,CAAA;CAChC,KAAG,MAeH,CAAA"}
1
+ {"version":3,"file":"formatAdminURL.d.ts","sourceRoot":"","sources":["../../src/utilities/formatAdminURL.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,SACnB;IACJ,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAClD;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,IAAI,CAAA;IAC/B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,GAAG,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,KAC5B,MAoBF,CAAA"}
@@ -1,16 +1,25 @@
1
- /** Will read the `routes.admin` config and appropriately handle `"/"` admin paths */ export const formatAdminURL = (args)=>{
2
- const { adminRoute, basePath = '', path: pathFromArgs, serverURL } = args;
3
- const path = pathFromArgs || '';
4
- if (adminRoute) {
5
- if (adminRoute === '/') {
6
- if (!path) {
7
- return `${serverURL || ''}${basePath}${adminRoute}`;
8
- }
9
- } else {
10
- return `${serverURL || ''}${basePath}${adminRoute}${path}`;
11
- }
1
+ /**
2
+ * This function builds correct URLs for admin panel routing.
3
+ * Its primary responsibilities are:
4
+ * 1. Read from your `routes.admin` config and appropriately handle `"/"` admin paths
5
+ * 2. Prepend the `basePath` from your Next.js config, if specified
6
+ * 3. Return relative or absolute URLs, as needed
7
+ */ export const formatAdminURL = (args)=>{
8
+ const { adminRoute, basePath = '', path = '', relative = false, serverURL } = args;
9
+ const pathSegments = [
10
+ basePath
11
+ ];
12
+ if (adminRoute && adminRoute !== '/') {
13
+ pathSegments.push(adminRoute);
12
14
  }
13
- return `${serverURL || ''}${basePath}${path}`;
15
+ if (path && !(adminRoute === '/' && !path)) {
16
+ pathSegments.push(path);
17
+ }
18
+ const pathname = pathSegments.join('') || '/';
19
+ if (relative || !serverURL) {
20
+ return pathname;
21
+ }
22
+ return new URL(pathname, serverURL).toString();
14
23
  };
15
24
 
16
25
  //# sourceMappingURL=formatAdminURL.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/formatAdminURL.ts"],"sourcesContent":["import type { Config } from '../config/types.js'\n\n/** Will read the `routes.admin` config and appropriately handle `\"/\"` admin paths */\nexport const formatAdminURL = (args: {\n adminRoute: NonNullable<Config['routes']>['admin']\n basePath?: string\n path: '' | `/${string}` | null | undefined\n serverURL?: Config['serverURL']\n}): string => {\n const { adminRoute, basePath = '', path: pathFromArgs, serverURL } = args\n const path = pathFromArgs || ''\n\n if (adminRoute) {\n if (adminRoute === '/') {\n if (!path) {\n return `${serverURL || ''}${basePath}${adminRoute}`\n }\n } else {\n return `${serverURL || ''}${basePath}${adminRoute}${path}`\n }\n }\n\n return `${serverURL || ''}${basePath}${path}`\n}\n"],"names":["formatAdminURL","args","adminRoute","basePath","path","pathFromArgs","serverURL"],"mappings":"AAEA,mFAAmF,GACnF,OAAO,MAAMA,iBAAiB,CAACC;IAM7B,MAAM,EAAEC,UAAU,EAAEC,WAAW,EAAE,EAAEC,MAAMC,YAAY,EAAEC,SAAS,EAAE,GAAGL;IACrE,MAAMG,OAAOC,gBAAgB;IAE7B,IAAIH,YAAY;QACd,IAAIA,eAAe,KAAK;YACtB,IAAI,CAACE,MAAM;gBACT,OAAO,GAAGE,aAAa,KAAKH,WAAWD,YAAY;YACrD;QACF,OAAO;YACL,OAAO,GAAGI,aAAa,KAAKH,WAAWD,aAAaE,MAAM;QAC5D;IACF;IAEA,OAAO,GAAGE,aAAa,KAAKH,WAAWC,MAAM;AAC/C,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/formatAdminURL.ts"],"sourcesContent":["import type { Config } from '../config/types.js'\n\n/**\n * This function builds correct URLs for admin panel routing.\n * Its primary responsibilities are:\n * 1. Read from your `routes.admin` config and appropriately handle `\"/\"` admin paths\n * 2. Prepend the `basePath` from your Next.js config, if specified\n * 3. Return relative or absolute URLs, as needed\n */\nexport const formatAdminURL = (\n args: {\n adminRoute: NonNullable<Config['routes']>['admin']\n /**\n * The subpath of your application, if specified.\n * @see https://nextjs.org/docs/app/api-reference/config/next-config-js/basePath\n * @example '/docs'\n */\n basePath?: string\n path?: '' | `/${string}` | null\n /**\n * Return a relative URL, e.g. ignore `serverURL`.\n * Useful for route-matching, etc.\n */\n relative?: boolean\n } & Pick<Config, 'serverURL'>,\n): string => {\n const { adminRoute, basePath = '', path = '', relative = false, serverURL } = args\n\n const pathSegments = [basePath]\n\n if (adminRoute && adminRoute !== '/') {\n pathSegments.push(adminRoute)\n }\n\n if (path && !(adminRoute === '/' && !path)) {\n pathSegments.push(path)\n }\n\n const pathname = pathSegments.join('') || '/'\n\n if (relative || !serverURL) {\n return pathname\n }\n\n return new URL(pathname, serverURL).toString()\n}\n"],"names":["formatAdminURL","args","adminRoute","basePath","path","relative","serverURL","pathSegments","push","pathname","join","URL","toString"],"mappings":"AAEA;;;;;;CAMC,GACD,OAAO,MAAMA,iBAAiB,CAC5BC;IAgBA,MAAM,EAAEC,UAAU,EAAEC,WAAW,EAAE,EAAEC,OAAO,EAAE,EAAEC,WAAW,KAAK,EAAEC,SAAS,EAAE,GAAGL;IAE9E,MAAMM,eAAe;QAACJ;KAAS;IAE/B,IAAID,cAAcA,eAAe,KAAK;QACpCK,aAAaC,IAAI,CAACN;IACpB;IAEA,IAAIE,QAAQ,CAAEF,CAAAA,eAAe,OAAO,CAACE,IAAG,GAAI;QAC1CG,aAAaC,IAAI,CAACJ;IACpB;IAEA,MAAMK,WAAWF,aAAaG,IAAI,CAAC,OAAO;IAE1C,IAAIL,YAAY,CAACC,WAAW;QAC1B,OAAOG;IACT;IAEA,OAAO,IAAIE,IAAIF,UAAUH,WAAWM,QAAQ;AAC9C,EAAC"}
@@ -0,0 +1,169 @@
1
+ import { formatAdminURL } from './formatAdminURL.js';
2
+ describe('formatAdminURL', ()=>{
3
+ const serverURL = 'https://example.com';
4
+ const defaultAdminRoute = '/admin';
5
+ const rootAdminRoute = '/';
6
+ const dummyPath = '/collections/posts';
7
+ describe('relative URLs', ()=>{
8
+ it('should ignore `serverURL` when relative=true', ()=>{
9
+ const result = formatAdminURL({
10
+ adminRoute: defaultAdminRoute,
11
+ path: dummyPath,
12
+ serverURL,
13
+ relative: true
14
+ });
15
+ expect(result).toBe(`${defaultAdminRoute}${dummyPath}`);
16
+ });
17
+ it('should force relative URL when `serverURL` is omitted', ()=>{
18
+ const result = formatAdminURL({
19
+ adminRoute: defaultAdminRoute,
20
+ path: dummyPath,
21
+ relative: false
22
+ });
23
+ expect(result).toBe(`${defaultAdminRoute}${dummyPath}`);
24
+ });
25
+ });
26
+ describe('absolute URLs', ()=>{
27
+ it('should return absolute URL with serverURL', ()=>{
28
+ const result = formatAdminURL({
29
+ adminRoute: defaultAdminRoute,
30
+ path: dummyPath,
31
+ serverURL
32
+ });
33
+ expect(result).toBe(`${serverURL}${defaultAdminRoute}${dummyPath}`);
34
+ });
35
+ it('should handle serverURL with trailing slash', ()=>{
36
+ const result = formatAdminURL({
37
+ adminRoute: defaultAdminRoute,
38
+ path: '/collections/posts',
39
+ serverURL: 'https://example.com/'
40
+ });
41
+ expect(result).toBe('https://example.com/admin/collections/posts');
42
+ });
43
+ it('should handle serverURL with subdirectory', ()=>{
44
+ const result = formatAdminURL({
45
+ adminRoute: defaultAdminRoute,
46
+ path: '/collections/posts',
47
+ serverURL: 'https://example.com/api/v1'
48
+ });
49
+ expect(result).toBe('https://example.com/admin/collections/posts');
50
+ });
51
+ });
52
+ describe('admin route handling', ()=>{
53
+ it('should return relative URL for adminRoute="/", no path, no `serverURL`', ()=>{
54
+ const result = formatAdminURL({
55
+ adminRoute: rootAdminRoute,
56
+ relative: true
57
+ });
58
+ expect(result).toBe('/');
59
+ });
60
+ it('should handle relative URL for adminRoute="/", with path, no `serverURL`', ()=>{
61
+ const result = formatAdminURL({
62
+ adminRoute: rootAdminRoute,
63
+ path: dummyPath,
64
+ relative: true
65
+ });
66
+ expect(result).toBe(dummyPath);
67
+ });
68
+ it('should return absolute URL for adminRoute="/", no path, with `serverURL`', ()=>{
69
+ const result = formatAdminURL({
70
+ adminRoute: rootAdminRoute,
71
+ serverURL
72
+ });
73
+ expect(result).toBe('https://example.com/');
74
+ });
75
+ it('should handle absolute URL for adminRoute="/", with path and `serverURL`', ()=>{
76
+ const result = formatAdminURL({
77
+ adminRoute: rootAdminRoute,
78
+ serverURL,
79
+ path: dummyPath
80
+ });
81
+ expect(result).toBe(`${serverURL}${dummyPath}`);
82
+ });
83
+ });
84
+ describe('base path handling', ()=>{
85
+ it('should include basePath in URL', ()=>{
86
+ const result = formatAdminURL({
87
+ adminRoute: defaultAdminRoute,
88
+ basePath: '/v1',
89
+ path: dummyPath,
90
+ serverURL
91
+ });
92
+ expect(result).toBe(`${serverURL}/v1${defaultAdminRoute}${dummyPath}`);
93
+ });
94
+ it('should handle basePath with adminRoute="/"', ()=>{
95
+ const result = formatAdminURL({
96
+ adminRoute: rootAdminRoute,
97
+ basePath: '/v1',
98
+ serverURL
99
+ });
100
+ expect(result).toBe(`${serverURL}/v1`);
101
+ });
102
+ it('should handle basePath with no adminRoute', ()=>{
103
+ const result = formatAdminURL({
104
+ adminRoute: undefined,
105
+ basePath: '/v1',
106
+ path: dummyPath,
107
+ serverURL
108
+ });
109
+ expect(result).toBe(`${serverURL}/v1${dummyPath}`);
110
+ });
111
+ it('should handle empty basePath', ()=>{
112
+ const result = formatAdminURL({
113
+ adminRoute: defaultAdminRoute,
114
+ basePath: '',
115
+ path: dummyPath,
116
+ serverURL
117
+ });
118
+ expect(result).toBe(`${serverURL}${defaultAdminRoute}${dummyPath}`);
119
+ });
120
+ });
121
+ describe('path handling', ()=>{
122
+ it('should handle empty string path', ()=>{
123
+ const result = formatAdminURL({
124
+ adminRoute: defaultAdminRoute,
125
+ path: '',
126
+ serverURL
127
+ });
128
+ expect(result).toBe(`${serverURL}${defaultAdminRoute}`);
129
+ });
130
+ it('should handle null path', ()=>{
131
+ const result = formatAdminURL({
132
+ adminRoute: defaultAdminRoute,
133
+ path: null,
134
+ serverURL
135
+ });
136
+ expect(result).toBe(`${serverURL}${defaultAdminRoute}`);
137
+ });
138
+ it('should handle undefined path', ()=>{
139
+ const result = formatAdminURL({
140
+ adminRoute: defaultAdminRoute,
141
+ path: undefined,
142
+ serverURL
143
+ });
144
+ expect(result).toBe(`${serverURL}${defaultAdminRoute}`);
145
+ });
146
+ it('should handle path with query parameters', ()=>{
147
+ const path = `${dummyPath}?page=2`;
148
+ const result = formatAdminURL({
149
+ adminRoute: defaultAdminRoute,
150
+ path,
151
+ serverURL
152
+ });
153
+ expect(result).toBe(`${serverURL}${defaultAdminRoute}${path}`);
154
+ });
155
+ });
156
+ describe('edge cases', ()=>{
157
+ it('should return "/" when given minimal args', ()=>{
158
+ const result = formatAdminURL({
159
+ adminRoute: undefined,
160
+ basePath: '',
161
+ path: '',
162
+ relative: true
163
+ });
164
+ expect(result).toBe('/');
165
+ });
166
+ });
167
+ });
168
+
169
+ //# sourceMappingURL=formatAdminURL.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/formatAdminURL.spec.ts"],"sourcesContent":["import { formatAdminURL } from './formatAdminURL.js'\n\ndescribe('formatAdminURL', () => {\n const serverURL = 'https://example.com'\n\n const defaultAdminRoute = '/admin'\n const rootAdminRoute = '/'\n\n const dummyPath = '/collections/posts'\n\n describe('relative URLs', () => {\n it('should ignore `serverURL` when relative=true', () => {\n const result = formatAdminURL({\n adminRoute: defaultAdminRoute,\n path: dummyPath,\n serverURL,\n relative: true,\n })\n\n expect(result).toBe(`${defaultAdminRoute}${dummyPath}`)\n })\n\n it('should force relative URL when `serverURL` is omitted', () => {\n const result = formatAdminURL({\n adminRoute: defaultAdminRoute,\n path: dummyPath,\n relative: false,\n })\n\n expect(result).toBe(`${defaultAdminRoute}${dummyPath}`)\n })\n })\n\n describe('absolute URLs', () => {\n it('should return absolute URL with serverURL', () => {\n const result = formatAdminURL({\n adminRoute: defaultAdminRoute,\n path: dummyPath,\n serverURL,\n })\n\n expect(result).toBe(`${serverURL}${defaultAdminRoute}${dummyPath}`)\n })\n\n it('should handle serverURL with trailing slash', () => {\n const result = formatAdminURL({\n adminRoute: defaultAdminRoute,\n path: '/collections/posts',\n serverURL: 'https://example.com/',\n })\n\n expect(result).toBe('https://example.com/admin/collections/posts')\n })\n\n it('should handle serverURL with subdirectory', () => {\n const result = formatAdminURL({\n adminRoute: defaultAdminRoute,\n path: '/collections/posts',\n serverURL: 'https://example.com/api/v1',\n })\n\n expect(result).toBe('https://example.com/admin/collections/posts')\n })\n })\n\n describe('admin route handling', () => {\n it('should return relative URL for adminRoute=\"/\", no path, no `serverURL`', () => {\n const result = formatAdminURL({\n adminRoute: rootAdminRoute,\n relative: true,\n })\n\n expect(result).toBe('/')\n })\n\n it('should handle relative URL for adminRoute=\"/\", with path, no `serverURL`', () => {\n const result = formatAdminURL({\n adminRoute: rootAdminRoute,\n path: dummyPath,\n relative: true,\n })\n\n expect(result).toBe(dummyPath)\n })\n\n it('should return absolute URL for adminRoute=\"/\", no path, with `serverURL`', () => {\n const result = formatAdminURL({\n adminRoute: rootAdminRoute,\n serverURL,\n })\n\n expect(result).toBe('https://example.com/')\n })\n\n it('should handle absolute URL for adminRoute=\"/\", with path and `serverURL`', () => {\n const result = formatAdminURL({\n adminRoute: rootAdminRoute,\n serverURL,\n path: dummyPath,\n })\n\n expect(result).toBe(`${serverURL}${dummyPath}`)\n })\n })\n\n describe('base path handling', () => {\n it('should include basePath in URL', () => {\n const result = formatAdminURL({\n adminRoute: defaultAdminRoute,\n basePath: '/v1',\n path: dummyPath,\n serverURL,\n })\n\n expect(result).toBe(`${serverURL}/v1${defaultAdminRoute}${dummyPath}`)\n })\n\n it('should handle basePath with adminRoute=\"/\"', () => {\n const result = formatAdminURL({\n adminRoute: rootAdminRoute,\n basePath: '/v1',\n serverURL,\n })\n\n expect(result).toBe(`${serverURL}/v1`)\n })\n\n it('should handle basePath with no adminRoute', () => {\n const result = formatAdminURL({\n adminRoute: undefined,\n basePath: '/v1',\n path: dummyPath,\n serverURL,\n })\n\n expect(result).toBe(`${serverURL}/v1${dummyPath}`)\n })\n\n it('should handle empty basePath', () => {\n const result = formatAdminURL({\n adminRoute: defaultAdminRoute,\n basePath: '',\n path: dummyPath,\n serverURL,\n })\n\n expect(result).toBe(`${serverURL}${defaultAdminRoute}${dummyPath}`)\n })\n })\n\n describe('path handling', () => {\n it('should handle empty string path', () => {\n const result = formatAdminURL({\n adminRoute: defaultAdminRoute,\n path: '',\n serverURL,\n })\n\n expect(result).toBe(`${serverURL}${defaultAdminRoute}`)\n })\n\n it('should handle null path', () => {\n const result = formatAdminURL({\n adminRoute: defaultAdminRoute,\n path: null,\n serverURL,\n })\n expect(result).toBe(`${serverURL}${defaultAdminRoute}`)\n })\n\n it('should handle undefined path', () => {\n const result = formatAdminURL({\n adminRoute: defaultAdminRoute,\n path: undefined,\n serverURL,\n })\n\n expect(result).toBe(`${serverURL}${defaultAdminRoute}`)\n })\n\n it('should handle path with query parameters', () => {\n const path = `${dummyPath}?page=2`\n\n const result = formatAdminURL({\n adminRoute: defaultAdminRoute,\n path,\n serverURL,\n })\n\n expect(result).toBe(`${serverURL}${defaultAdminRoute}${path}`)\n })\n })\n\n describe('edge cases', () => {\n it('should return \"/\" when given minimal args', () => {\n const result = formatAdminURL({\n adminRoute: undefined,\n basePath: '',\n path: '',\n relative: true,\n })\n\n expect(result).toBe('/')\n })\n })\n})\n"],"names":["formatAdminURL","describe","serverURL","defaultAdminRoute","rootAdminRoute","dummyPath","it","result","adminRoute","path","relative","expect","toBe","basePath","undefined"],"mappings":"AAAA,SAASA,cAAc,QAAQ,sBAAqB;AAEpDC,SAAS,kBAAkB;IACzB,MAAMC,YAAY;IAElB,MAAMC,oBAAoB;IAC1B,MAAMC,iBAAiB;IAEvB,MAAMC,YAAY;IAElBJ,SAAS,iBAAiB;QACxBK,GAAG,gDAAgD;YACjD,MAAMC,SAASP,eAAe;gBAC5BQ,YAAYL;gBACZM,MAAMJ;gBACNH;gBACAQ,UAAU;YACZ;YAEAC,OAAOJ,QAAQK,IAAI,CAAC,GAAGT,oBAAoBE,WAAW;QACxD;QAEAC,GAAG,yDAAyD;YAC1D,MAAMC,SAASP,eAAe;gBAC5BQ,YAAYL;gBACZM,MAAMJ;gBACNK,UAAU;YACZ;YAEAC,OAAOJ,QAAQK,IAAI,CAAC,GAAGT,oBAAoBE,WAAW;QACxD;IACF;IAEAJ,SAAS,iBAAi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AS,cAAc;QACrBK,GAAG,6CAA6C;YAC9C,MAAMC,SAASP,eAAe;gBAC5BQ,YAAYM;gBACZD,UAAU;gBACVJ,MAAM;gBACNC,UAAU;YACZ;YAEAC,OAAOJ,QAAQK,IAAI,CAAC;QACtB;IACF;AACF"}
@@ -0,0 +1,9 @@
1
+ import type { Config } from '../config/types.js';
2
+ /** Will read the `routes.api` config and appropriately handle `"/"` api paths */
3
+ export declare const formatApiURL: (args: {
4
+ apiRoute: NonNullable<Config["routes"]>["api"];
5
+ basePath?: string;
6
+ path: "" | `/${string}` | null | undefined;
7
+ serverURL: Config["serverURL"];
8
+ }) => string;
9
+ //# sourceMappingURL=formatApiURL.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatApiURL.d.ts","sourceRoot":"","sources":["../../src/utilities/formatApiURL.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAIhD,iFAAiF;AACjF,eAAO,MAAM,YAAY,SAAU;IACjC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,CAAA;IAC1C,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,CAAA;CAC/B,KAAG,MAOH,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { formatAdminURL } from './formatAdminURL.js';
2
+ /** Will read the `routes.api` config and appropriately handle `"/"` api paths */ export const formatApiURL = (args)=>{
3
+ return formatAdminURL({
4
+ adminRoute: args.apiRoute,
5
+ basePath: args.basePath,
6
+ path: args.path,
7
+ serverURL: args.serverURL
8
+ });
9
+ };
10
+
11
+ //# sourceMappingURL=formatApiURL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/formatApiURL.ts"],"sourcesContent":["import type { Config } from '../config/types.js'\n\nimport { formatAdminURL } from './formatAdminURL.js'\n\n/** Will read the `routes.api` config and appropriately handle `\"/\"` api paths */\nexport const formatApiURL = (args: {\n apiRoute: NonNullable<Config['routes']>['api']\n basePath?: string\n path: '' | `/${string}` | null | undefined\n serverURL: Config['serverURL']\n}): string => {\n return formatAdminURL({\n adminRoute: args.apiRoute,\n basePath: args.basePath,\n path: args.path,\n serverURL: args.serverURL,\n })\n}\n"],"names":["formatAdminURL","formatApiURL","args","adminRoute","apiRoute","basePath","path","serverURL"],"mappings":"AAEA,SAASA,cAAc,QAAQ,sBAAqB;AAEpD,+EAA+E,GAC/E,OAAO,MAAMC,eAAe,CAACC;IAM3B,OAAOF,eAAe;QACpBG,YAAYD,KAAKE,QAAQ;QACzBC,UAAUH,KAAKG,QAAQ;QACvBC,MAAMJ,KAAKI,IAAI;QACfC,WAAWL,KAAKK,SAAS;IAC3B;AACF,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload",
3
- "version": "3.69.0-internal.2883df2",
3
+ "version": "3.69.0-internal.35bf893",
4
4
  "description": "Node, React, Headless CMS and Application Framework built on Next.js",
5
5
  "keywords": [
6
6
  "admin panel",
@@ -99,6 +99,7 @@
99
99
  "pino-pretty": "13.1.2",
100
100
  "pluralize": "8.0.0",
101
101
  "qs-esm": "7.0.2",
102
+ "range-parser": "1.2.1",
102
103
  "sanitize-filename": "1.6.3",
103
104
  "scmp": "2.1.0",
104
105
  "ts-essentials": "10.0.3",
@@ -106,7 +107,7 @@
106
107
  "undici": "7.10.0",
107
108
  "uuid": "10.0.0",
108
109
  "ws": "^8.16.0",
109
- "@payloadcms/translations": "3.69.0-internal.2883df2"
110
+ "@payloadcms/translations": "3.69.0-internal.35bf893"
110
111
  },
111
112
  "devDependencies": {
112
113
  "@hyrious/esbuild-plugin-commonjs": "0.2.6",
@@ -115,6 +116,7 @@
115
116
  "@types/minimist": "1.2.2",
116
117
  "@types/nodemailer": "7.0.2",
117
118
  "@types/pluralize": "0.0.33",
119
+ "@types/range-parser": "1.2.7",
118
120
  "@types/uuid": "10.0.0",
119
121
  "@types/ws": "^8.5.10",
120
122
  "copyfiles": "2.4.1",