payload 3.68.0-internal.35482da → 3.68.0-internal.6fa474a

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 (68) hide show
  1. package/dist/auth/strategies/local/incrementLoginAttempts.js +1 -2
  2. package/dist/auth/strategies/local/incrementLoginAttempts.js.map +1 -1
  3. package/dist/bin/generateImportMap/iterateFields.js +1 -2
  4. package/dist/bin/generateImportMap/iterateFields.js.map +1 -1
  5. package/dist/bin/index.js +2 -4
  6. package/dist/bin/index.js.map +1 -1
  7. package/dist/bin/migrate.js +1 -2
  8. package/dist/bin/migrate.js.map +1 -1
  9. package/dist/collections/config/defaults.js +1 -2
  10. package/dist/collections/config/defaults.js.map +1 -1
  11. package/dist/config/find.js +1 -2
  12. package/dist/config/find.js.map +1 -1
  13. package/dist/errors/APIError.js +1 -2
  14. package/dist/errors/APIError.js.map +1 -1
  15. package/dist/errors/AuthenticationError.js.map +1 -1
  16. package/dist/errors/DuplicateCollection.js.map +1 -1
  17. package/dist/errors/DuplicateFieldName.js.map +1 -1
  18. package/dist/errors/DuplicateGlobal.js.map +1 -1
  19. package/dist/errors/ErrorDeletingFile.js.map +1 -1
  20. package/dist/errors/FileRetrievalError.js.map +1 -1
  21. package/dist/errors/FileUploadError.js.map +1 -1
  22. package/dist/errors/Forbidden.js.map +1 -1
  23. package/dist/errors/InvalidConfiguration.js.map +1 -1
  24. package/dist/errors/InvalidFieldJoin.js.map +1 -1
  25. package/dist/errors/InvalidFieldName.js.map +1 -1
  26. package/dist/errors/InvalidFieldRelationship.js.map +1 -1
  27. package/dist/errors/InvalidSchema.js.map +1 -1
  28. package/dist/errors/Locked.js.map +1 -1
  29. package/dist/errors/LockedAuth.js.map +1 -1
  30. package/dist/errors/MissingCollectionLabel.js.map +1 -1
  31. package/dist/errors/MissingEditorProp.js.map +1 -1
  32. package/dist/errors/MissingFieldInputOptions.js.map +1 -1
  33. package/dist/errors/MissingFieldType.js.map +1 -1
  34. package/dist/errors/MissingFile.js.map +1 -1
  35. package/dist/errors/NotFound.js.map +1 -1
  36. package/dist/errors/QueryError.js.map +1 -1
  37. package/dist/errors/ReservedFieldName.js.map +1 -1
  38. package/dist/errors/TimestampsRequired.js.map +1 -1
  39. package/dist/errors/UnauthorizedError.js.map +1 -1
  40. package/dist/errors/UnverifiedEmail.js.map +1 -1
  41. package/dist/errors/ValidationError.js.map +1 -1
  42. package/dist/fields/config/client.js +1 -2
  43. package/dist/fields/config/client.js.map +1 -1
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +26 -10
  46. package/dist/index.js.map +1 -1
  47. package/dist/kv/adapters/DatabaseKVAdapter.js.map +1 -1
  48. package/dist/queues/errors/index.js.map +1 -1
  49. package/dist/queues/operations/runJobs/index.js +1 -2
  50. package/dist/queues/operations/runJobs/index.js.map +1 -1
  51. package/dist/uploads/fetchAPI-multipart/utilities.js +1 -2
  52. package/dist/uploads/fetchAPI-multipart/utilities.js.map +1 -1
  53. package/dist/uploads/generateFileData.js +4 -8
  54. package/dist/uploads/generateFileData.js.map +1 -1
  55. package/dist/utilities/createLocalReq.js.map +1 -1
  56. package/dist/utilities/deepCopyObject.js.map +1 -1
  57. package/dist/utilities/findUp.js +4 -8
  58. package/dist/utilities/findUp.js.map +1 -1
  59. package/dist/utilities/formatErrors.js.map +1 -1
  60. package/dist/utilities/getFieldPermissions.spec.js +2 -4
  61. package/dist/utilities/getFieldPermissions.spec.js.map +1 -1
  62. package/dist/utilities/parseParams/index.spec.js +5 -10
  63. package/dist/utilities/parseParams/index.spec.js.map +1 -1
  64. package/dist/utilities/telemetry/conf/index.js.map +1 -1
  65. package/dist/utilities/transformColumnPreferences.js +1 -2
  66. package/dist/utilities/transformColumnPreferences.js.map +1 -1
  67. package/dist/utilities/unflatten.js.map +1 -1
  68. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getFieldPermissions.spec.ts"],"sourcesContent":["import type { SanitizedDocumentPermissions } from '../auth/types.js'\n\nimport { getFieldPermissions } from './getFieldPermissions.js'\n\ndescribe('getFieldPermissions with collection fallback', () => {\n const mockField = {\n name: 'testField',\n type: 'text' as const,\n }\n\n describe('fallback to collection permissions', () => {\n it('should enable read-only mode when field permissions are missing but collection has read access', () => {\n const fieldPermissions = {} // Empty/sanitized field permissions\n const collectionPermissions: SanitizedDocumentPermissions = {\n read: true,\n fields: {},\n }\n\n const result = getFieldPermissions({\n field: mockField,\n operation: 'update',\n parentName: '',\n permissions: fieldPermissions,\n collectionPermissions,\n })\n\n expect(result.read).toBe(true)\n expect(result.operation).toBe(false) // Should be read-only\n expect(result.permissions).toEqual({ read: true })\n })\n\n it('should respect existing field permissions when they exist', () => {\n const fieldPermissions = true // All permissions are true\n const collectionPermissions: SanitizedDocumentPermissions = {\n read: true,\n fields: {},\n }\n\n const result = getFieldPermissions({\n field: mockField,\n operation: 'update',\n parentName: '',\n permissions: fieldPermissions,\n })\n\n expect(result.read).toBe(true)\n expect(result.operation).toBe(true) // Should have operation permission\n expect(result.permissions).toBe(true)\n })\n\n it('should not provide access when neither field nor collection has read permission', () => {\n const fieldPermissions = {}\n const collectionPermissions: SanitizedDocumentPermissions = {\n // No read permission at collection level\n fields: {},\n }\n\n const result = getFieldPermissions({\n field: mockField,\n operation: 'update',\n parentName: '',\n permissions: fieldPermissions,\n collectionPermissions,\n })\n\n expect(result.read).toBe(false)\n expect(result.operation).toBe(false)\n })\n\n it('should work without collection permissions (backward compatibility)', () => {\n const fieldPermissions = true // All permissions\n\n const result = getFieldPermissions({\n field: mockField,\n operation: 'update',\n parentName: '',\n permissions: fieldPermissions,\n // No collectionPermissions provided\n })\n\n expect(result.read).toBe(true)\n expect(result.operation).toBe(true)\n expect(result.permissions).toBe(true)\n })\n })\n})\n"],"names":["getFieldPermissions","describe","mockField","name","type","it","fieldPermissions","collectionPermissions","read","fields","result","field","operation","parentName","permissions","expect","toBe","toEqual"],"mappings":"AAEA,SAASA,mBAAmB,QAAQ,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MC,mBAAmB,KAAK,kBAAkB;;YAEhD,MAAMI,SAASV,oBAAoB;gBACjCW,OAAOT;gBACPU,WAAW;gBACXC,YAAY;gBACZC,aAAaR;YAEf;YAEAS,OAAOL,OAAOF,IAAI,EAAEQ,IAAI,CAAC;YACzBD,OAAOL,OAAOE,SAAS,EAAEI,IAAI,CAAC;YAC9BD,OAAOL,OAAOI,WAAW,EAAEE,IAAI,CAAC;QAClC;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/utilities/getFieldPermissions.spec.ts"],"sourcesContent":["import type { SanitizedDocumentPermissions } from '../auth/types.js'\n\nimport { getFieldPermissions } from './getFieldPermissions.js'\n\ndescribe('getFieldPermissions with collection fallback', () => {\n const mockField = {\n name: 'testField',\n type: 'text' as const,\n }\n\n describe('fallback to collection permissions', () => {\n it('should enable read-only mode when field permissions are missing but collection has read access', () => {\n const fieldPermissions = {} // Empty/sanitized field permissions\n const collectionPermissions: SanitizedDocumentPermissions = {\n read: true,\n fields: {},\n }\n\n const result = getFieldPermissions({\n field: mockField,\n operation: 'update',\n parentName: '',\n permissions: fieldPermissions,\n collectionPermissions,\n })\n\n expect(result.read).toBe(true)\n expect(result.operation).toBe(false) // Should be read-only\n expect(result.permissions).toEqual({ read: true })\n })\n\n it('should respect existing field permissions when they exist', () => {\n const fieldPermissions = true // All permissions are true\n const collectionPermissions: SanitizedDocumentPermissions = {\n read: true,\n fields: {},\n }\n\n const result = getFieldPermissions({\n field: mockField,\n operation: 'update',\n parentName: '',\n permissions: fieldPermissions,\n })\n\n expect(result.read).toBe(true)\n expect(result.operation).toBe(true) // Should have operation permission\n expect(result.permissions).toBe(true)\n })\n\n it('should not provide access when neither field nor collection has read permission', () => {\n const fieldPermissions = {}\n const collectionPermissions: SanitizedDocumentPermissions = {\n // No read permission at collection level\n fields: {},\n }\n\n const result = getFieldPermissions({\n field: mockField,\n operation: 'update',\n parentName: '',\n permissions: fieldPermissions,\n collectionPermissions,\n })\n\n expect(result.read).toBe(false)\n expect(result.operation).toBe(false)\n })\n\n it('should work without collection permissions (backward compatibility)', () => {\n const fieldPermissions = true // All permissions\n\n const result = getFieldPermissions({\n field: mockField,\n operation: 'update',\n parentName: '',\n permissions: fieldPermissions,\n // No collectionPermissions provided\n })\n\n expect(result.read).toBe(true)\n expect(result.operation).toBe(true)\n expect(result.permissions).toBe(true)\n })\n })\n})\n"],"names":["getFieldPermissions","describe","mockField","name","type","it","fieldPermissions","collectionPermissions","read","fields","result","field","operation","parentName","permissions","expect","toBe","toEqual"],"mappings":"AAEA,SAASA,mBAAmB,QAAQ,2BAA0B;AAE9DC,SAAS,gDAAgD;IACvD,MAAMC,YAAY;QAChBC,MAAM;QACNC,MAAM;IACR;IAEAH,SAAS,sCAAsC;QAC7CI,GAAG,kGAAkG;YACnG,MAAMC,mBAAmB,CAAC,EAAE,oCAAoC;;YAChE,MAAMC,wBAAsD;gBAC1DC,MAAM;gBACNC,QAAQ,CAAC;YACX;YAEA,MAAMC,SAASV,oBAAoB;gBACjCW,OAAOT;gBACPU,WAAW;gBACXC,YAAY;gBACZC,aAAaR;gBACbC;YACF;YAEAQ,OAAOL,OAAOF,IAAI,EAAEQ,IAAI,CAAC;YACzBD,OAAOL,OAAOE,SAAS,EAAEI,IAAI,CAAC,QAAO,sBAAsB;YAC3DD,OAAOL,OAAOI,WAAW,EAAEG,OAAO,CAAC;gBAAET,MAAM;YAAK;QAClD;QAEAH,GAAG,6DAA6D;YAC9D,MAAMC,mBAAmB,KAAK,2BAA2B;;YACzD,MAAMC,wBAAsD;gBAC1DC,MAAM;gBACNC,QAAQ,CAAC;YACX;YAEA,MAAMC,SAASV,oBAAoB;gBACjCW,OAAOT;gBACPU,WAAW;gBACXC,YAAY;gBACZC,aAAaR;YACf;YAEAS,OAAOL,OAAOF,IAAI,EAAEQ,IAAI,CAAC;YACzBD,OAAOL,OAAOE,SAAS,EAAEI,IAAI,CAAC,OAAM,mCAAmC;YACvED,OAAOL,OAAOI,WAAW,EAAEE,IAAI,CAAC;QAClC;QAEAX,GAAG,mFAAmF;YACpF,MAAMC,mBAAmB,CAAC;YAC1B,MAAMC,wBAAsD;gBAC1D,yCAAyC;gBACzCE,QAAQ,CAAC;YACX;YAEA,MAAMC,SAASV,oBAAoB;gBACjCW,OAAOT;gBACPU,WAAW;gBACXC,YAAY;gBACZC,aAAaR;gBACbC;YACF;YAEAQ,OAAOL,OAAOF,IAAI,EAAEQ,IAAI,CAAC;YACzBD,OAAOL,OAAOE,SAAS,EAAEI,IAAI,CAAC;QAChC;QAEAX,GAAG,uEAAuE;YACxE,MAAMC,mBAAmB,KAAK,kBAAkB;;YAEhD,MAAMI,SAASV,oBAAoB;gBACjCW,OAAOT;gBACPU,WAAW;gBACXC,YAAY;gBACZC,aAAaR;YAEf;YAEAS,OAAOL,OAAOF,IAAI,EAAEQ,IAAI,CAAC;YACzBD,OAAOL,OAAOE,SAAS,EAAEI,IAAI,CAAC;YAC9BD,OAAOL,OAAOI,WAAW,EAAEE,IAAI,CAAC;QAClC;IACF;AACF"}
@@ -79,15 +79,13 @@ describe('parseParams', ()=>{
79
79
  const result = parseParams({
80
80
  [param]: 'not-a-number'
81
81
  });
82
- expect(result[param]).toBe('not-a-number') // remains as string
83
- ;
82
+ expect(result[param]).toBe('not-a-number'); // remains as string
84
83
  });
85
84
  it('should not parse empty string', ()=>{
86
85
  const result = parseParams({
87
86
  [param]: ''
88
87
  });
89
- expect(result[param]).toBe('') // remains as string
90
- ;
88
+ expect(result[param]).toBe(''); // remains as string
91
89
  });
92
90
  it('should handle already numeric values', ()=>{
93
91
  const result = parseParams({
@@ -180,8 +178,7 @@ describe('parseParams', ()=>{
180
178
  const result = parseParams({
181
179
  data: ''
182
180
  });
183
- expect(result.data).toBe('') // empty string is not processed, remains as string
184
- ;
181
+ expect(result.data).toBe(''); // empty string is not processed, remains as string
185
182
  });
186
183
  it('should throw error for invalid JSON', ()=>{
187
184
  expect(()=>{
@@ -316,10 +313,8 @@ describe('parseParams', ()=>{
316
313
  unknownString: 'test'
317
314
  };
318
315
  const result = parseParams(params);
319
- expect(result.unknownBoolean).toBe('true') // should remain string
320
- ;
321
- expect(result.unknownNumber).toBe('42') // should remain string
322
- ;
316
+ expect(result.unknownBoolean).toBe('true'); // should remain string
317
+ expect(result.unknownNumber).toBe('42'); // should remain string
323
318
  expect(result.unknownString).toBe('test');
324
319
  });
325
320
  it('should only process parameters that exist in the input', ()=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utilities/parseParams/index.spec.ts"],"sourcesContent":["import { parseParams, booleanParams, numberParams } from './index.js'\n\ndescribe('parseParams', () => {\n describe('boolean parameters', () => {\n booleanParams.forEach((param) => {\n describe(param, () => {\n it('should parse string \"true\" to boolean true', () => {\n const result = parseParams({ [param]: 'true' })\n expect(result[param]).toBe(true)\n })\n\n it('should parse string \"false\" to boolean false', () => {\n const result = parseParams({ [param]: 'false' })\n expect(result[param]).toBe(false)\n })\n\n it('should parse boolean true to boolean true', () => {\n const result = parseParams({ [param]: true })\n expect(result[param]).toBe(true)\n })\n\n it('should parse boolean false to boolean false', () => {\n const result = parseParams({ [param]: false })\n expect(result[param]).toBe(false)\n })\n\n it('should return undefined for truthy strings (not exact \"true\")', () => {\n const result = parseParams({ [param]: '1' })\n expect(result[param]).toBeUndefined()\n })\n\n it('should return undefined for falsy strings (not exact \"false\")', () => {\n const result = parseParams({ [param]: '0' })\n expect(result[param]).toBeUndefined()\n })\n\n it('should return undefined for empty string', () => {\n const result = parseParams({ [param]: '' })\n expect(result[param]).toBeUndefined()\n })\n })\n })\n })\n\n describe('number parameters', () => {\n numberParams.forEach((param) => {\n describe(param, () => {\n it('should parse valid number string to number', () => {\n const result = parseParams({ [param]: '42' })\n expect(result[param]).toBe(42)\n })\n\n it('should parse zero string to zero', () => {\n const result = parseParams({ [param]: '0' })\n expect(result[param]).toBe(0)\n })\n\n it('should parse negative number string to negative number', () => {\n const result = parseParams({ [param]: '-5' })\n expect(result[param]).toBe(-5)\n })\n\n it('should parse decimal number string to decimal number', () => {\n const result = parseParams({ [param]: '3.14' })\n expect(result[param]).toBe(3.14)\n })\n\n it('should not parse invalid number strings', () => {\n const result = parseParams({ [param]: 'not-a-number' })\n expect(result[param]).toBe('not-a-number') // remains as string\n })\n\n it('should not parse empty string', () => {\n const result = parseParams({ [param]: '' })\n expect(result[param]).toBe('') // remains as string\n })\n\n it('should handle already numeric values', () => {\n const result = parseParams({ [param]: 123 })\n expect(result[param]).toBe(123)\n })\n })\n })\n })\n\n describe('sort parameter', () => {\n it('should parse comma-separated string to array', () => {\n const result = parseParams({ sort: 'name,createdAt,-updatedAt' })\n expect(result.sort).toEqual(['name', 'createdAt', '-updatedAt'])\n })\n\n it('should parse single value string to array with one element', () => {\n const result = parseParams({ sort: 'name' })\n expect(result.sort).toEqual(['name'])\n })\n\n it('should handle empty string', () => {\n const result = parseParams({ sort: '' })\n expect(result.sort).toEqual([''])\n })\n\n it('should handle comma-separated string with spaces', () => {\n const result = parseParams({ sort: 'name, createdAt , -updatedAt' })\n expect(result.sort).toEqual(['name', ' createdAt ', ' -updatedAt'])\n })\n\n it('should return undefined for non-string sort values', () => {\n const result = parseParams({ sort: 123 as any })\n expect(result.sort).toBeUndefined()\n })\n\n it('should return undefined for null sort values', () => {\n const result = parseParams({ sort: null as any })\n expect(result.sort).toBeUndefined()\n })\n })\n\n describe('data parameter', () => {\n it('should parse valid JSON string', () => {\n const data = { name: 'test', value: 42 }\n const result = parseParams({ data: JSON.stringify(data) })\n expect(result.data).toEqual(data)\n })\n\n it('should parse empty object JSON string', () => {\n const result = parseParams({ data: '{}' })\n expect(result.data).toEqual({})\n })\n\n it('should parse array JSON string', () => {\n const data = [1, 2, 3]\n const result = parseParams({ data: JSON.stringify(data) })\n expect(result.data).toEqual(data)\n })\n\n it('should not process empty string', () => {\n const result = parseParams({ data: '' })\n expect(result.data).toBe('') // empty string is not processed, remains as string\n })\n\n it('should throw error for invalid JSON', () => {\n expect(() => {\n parseParams({ data: 'invalid-json' })\n }).toThrow()\n })\n\n it('should not process non-string data values', () => {\n const result = parseParams({ data: { already: 'parsed' } as any })\n expect(result.data).toEqual({ already: 'parsed' })\n })\n })\n\n describe('special parameters', () => {\n it('should handle populate parameter', () => {\n const result = parseParams({ populate: 'field1,field2' })\n expect(result).toHaveProperty('populate')\n // Note: actual sanitization logic is tested in sanitizePopulateParam tests\n })\n\n it('should handle select parameter', () => {\n const result = parseParams({ select: 'field1,field2' })\n expect(result).toHaveProperty('select')\n // Note: actual sanitization logic is tested in sanitizeSelectParam tests\n })\n\n it('should handle joins parameter', () => {\n const joins = { collection: 'posts' }\n const result = parseParams({ joins })\n expect(result).toHaveProperty('joins')\n // Note: actual sanitization logic is tested in sanitizeJoinParams tests\n })\n })\n\n describe('selectedLocales parameter', () => {\n it('should pass through selectedLocales as-is', () => {\n const selectedLocales = 'en,es,fr'\n const result = parseParams({ selectedLocales })\n expect(result.selectedLocales).toBe(selectedLocales)\n })\n })\n\n describe('publishSpecificLocale parameter', () => {\n it('should pass through publishSpecificLocale as-is', () => {\n const publishSpecificLocale = 'en'\n const result = parseParams({ publishSpecificLocale })\n expect(result.publishSpecificLocale).toBe(publishSpecificLocale)\n })\n })\n\n describe('field parameter', () => {\n it('should pass through field as-is', () => {\n const field = 'myField'\n const result = parseParams({ field })\n expect(result.field).toBe(field)\n })\n })\n\n describe('where parameter', () => {\n it('should pass through where as-is', () => {\n const where = { name: { equals: 'test' } }\n const result = parseParams({ where })\n expect(result.where).toBe(where)\n })\n })\n\n describe('edge cases', () => {\n it('should handle empty params object', () => {\n const result = parseParams({})\n expect(result).toEqual({})\n })\n\n it('should throw error for null params (current implementation bug)', () => {\n expect(() => {\n parseParams(null as any)\n }).toThrow(TypeError)\n })\n\n it('should throw error for undefined params (current implementation bug)', () => {\n expect(() => {\n parseParams(undefined as any)\n }).toThrow(TypeError)\n })\n\n it('should preserve unknown parameters', () => {\n const result = parseParams({ customParam: 'customValue' })\n expect(result.customParam).toBe('customValue')\n })\n\n it('should handle mixed parameter types', () => {\n const result = parseParams({\n draft: 'true',\n depth: '5',\n sort: 'name,createdAt',\n data: '{\"test\": true}',\n customParam: 'custom',\n })\n\n expect(result.draft).toBe(true)\n expect(result.depth).toBe(5)\n expect(result.sort).toEqual(['name', 'createdAt'])\n expect(result.data).toEqual({ test: true })\n expect(result.customParam).toBe('custom')\n })\n })\n\n describe('parameter preservation', () => {\n it('should not modify parameters that are not in known lists', () => {\n const params = {\n unknownBoolean: 'true',\n unknownNumber: '42',\n unknownString: 'test',\n }\n const result = parseParams(params)\n\n expect(result.unknownBoolean).toBe('true') // should remain string\n expect(result.unknownNumber).toBe('42') // should remain string\n expect(result.unknownString).toBe('test')\n })\n\n it('should only process parameters that exist in the input', () => {\n const result = parseParams({ draft: 'true' })\n\n expect(result.draft).toBe(true)\n expect(result).not.toHaveProperty('autosave')\n expect(result).not.toHaveProperty('depth')\n expect(result).not.toHaveProperty('sort')\n })\n })\n})\n"],"names":["parseParams","booleanParams","numberParams","describe","forEach","param","it","result","expect","toBe","toBeUndefined","sort","toEqual","data","name","value","JSON","stringify","toThrow","already","populate","toHaveProperty","select","joins","collection","selectedLocales","publishSpecificLocale","field","where","equals","TypeError","undefined","customParam","draft","depth","test","params","unknownBoolean","unknownNumber","unknownString","not"],"mappings":"AAAA,SAASA,WAAW,EAAEC,aAAa,EAAEC,YAAY,QAAQ,aAAY;AAErEC,SAAS,eAAe;IACtBA,SAAS,sBAAsB;QAC7BF,cAAcG,OAAO,CAAC,CAACC;YACrBF,SAASE,OAAO;gBACdC,GAAG,8CAA8C;oBAC/C,MAAMC,SAASP,YAAY;wBAAE,CAACK,MAAM,EAAE;oBAAO;oBAC7CG,OAAOD,MAAM,CAACF,MAAM,EAAEI,IAAI,CAAC;gBAC7B;gBAEAH,GAAG,gDAAgD;oBACjD,MAAMC,SAASP,YAAY;wBAAE,CAACK,MAAM,EAAE;oBAAQ;oBAC9CG,OAAOD,MAAM,CAACF,MAAM,EAAEI,IAAI,CAAC;gBAC7B;gB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GAAG,CAACnB,cAAc,CAAC;YAClCb,OAAOD,QAAQiC,GAAG,CAACnB,cAAc,CAAC;QACpC;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/utilities/parseParams/index.spec.ts"],"sourcesContent":["import { parseParams, booleanParams, numberParams } from './index.js'\n\ndescribe('parseParams', () => {\n describe('boolean parameters', () => {\n booleanParams.forEach((param) => {\n describe(param, () => {\n it('should parse string \"true\" to boolean true', () => {\n const result = parseParams({ [param]: 'true' })\n expect(result[param]).toBe(true)\n })\n\n it('should parse string \"false\" to boolean false', () => {\n const result = parseParams({ [param]: 'false' })\n expect(result[param]).toBe(false)\n })\n\n it('should parse boolean true to boolean true', () => {\n const result = parseParams({ [param]: true })\n expect(result[param]).toBe(true)\n })\n\n it('should parse boolean false to boolean false', () => {\n const result = parseParams({ [param]: false })\n expect(result[param]).toBe(false)\n })\n\n it('should return undefined for truthy strings (not exact \"true\")', () => {\n const result = parseParams({ [param]: '1' })\n expect(result[param]).toBeUndefined()\n })\n\n it('should return undefined for falsy strings (not exact \"false\")', () => {\n const result = parseParams({ [param]: '0' })\n expect(result[param]).toBeUndefined()\n })\n\n it('should return undefined for empty string', () => {\n const result = parseParams({ [param]: '' })\n expect(result[param]).toBeUndefined()\n })\n })\n })\n })\n\n describe('number parameters', () => {\n numberParams.forEach((param) => {\n describe(param, () => {\n it('should parse valid number string to number', () => {\n const result = parseParams({ [param]: '42' })\n expect(result[param]).toBe(42)\n })\n\n it('should parse zero string to zero', () => {\n const result = parseParams({ [param]: '0' })\n expect(result[param]).toBe(0)\n })\n\n it('should parse negative number string to negative number', () => {\n const result = parseParams({ [param]: '-5' })\n expect(result[param]).toBe(-5)\n })\n\n it('should parse decimal number string to decimal number', () => {\n const result = parseParams({ [param]: '3.14' })\n expect(result[param]).toBe(3.14)\n })\n\n it('should not parse invalid number strings', () => {\n const result = parseParams({ [param]: 'not-a-number' })\n expect(result[param]).toBe('not-a-number') // remains as string\n })\n\n it('should not parse empty string', () => {\n const result = parseParams({ [param]: '' })\n expect(result[param]).toBe('') // remains as string\n })\n\n it('should handle already numeric values', () => {\n const result = parseParams({ [param]: 123 })\n expect(result[param]).toBe(123)\n })\n })\n })\n })\n\n describe('sort parameter', () => {\n it('should parse comma-separated string to array', () => {\n const result = parseParams({ sort: 'name,createdAt,-updatedAt' })\n expect(result.sort).toEqual(['name', 'createdAt', '-updatedAt'])\n })\n\n it('should parse single value string to array with one element', () => {\n const result = parseParams({ sort: 'name' })\n expect(result.sort).toEqual(['name'])\n })\n\n it('should handle empty string', () => {\n const result = parseParams({ sort: '' })\n expect(result.sort).toEqual([''])\n })\n\n it('should handle comma-separated string with spaces', () => {\n const result = parseParams({ sort: 'name, createdAt , -updatedAt' })\n expect(result.sort).toEqual(['name', ' createdAt ', ' -updatedAt'])\n })\n\n it('should return undefined for non-string sort values', () => {\n const result = parseParams({ sort: 123 as any })\n expect(result.sort).toBeUndefined()\n })\n\n it('should return undefined for null sort values', () => {\n const result = parseParams({ sort: null as any })\n expect(result.sort).toBeUndefined()\n })\n })\n\n describe('data parameter', () => {\n it('should parse valid JSON string', () => {\n const data = { name: 'test', value: 42 }\n const result = parseParams({ data: JSON.stringify(data) })\n expect(result.data).toEqual(data)\n })\n\n it('should parse empty object JSON string', () => {\n const result = parseParams({ data: '{}' })\n expect(result.data).toEqual({})\n })\n\n it('should parse array JSON string', () => {\n const data = [1, 2, 3]\n const result = parseParams({ data: JSON.stringify(data) })\n expect(result.data).toEqual(data)\n })\n\n it('should not process empty string', () => {\n const result = parseParams({ data: '' })\n expect(result.data).toBe('') // empty string is not processed, remains as string\n })\n\n it('should throw error for invalid JSON', () => {\n expect(() => {\n parseParams({ data: 'invalid-json' })\n }).toThrow()\n })\n\n it('should not process non-string data values', () => {\n const result = parseParams({ data: { already: 'parsed' } as any })\n expect(result.data).toEqual({ already: 'parsed' })\n })\n })\n\n describe('special parameters', () => {\n it('should handle populate parameter', () => {\n const result = parseParams({ populate: 'field1,field2' })\n expect(result).toHaveProperty('populate')\n // Note: actual sanitization logic is tested in sanitizePopulateParam tests\n })\n\n it('should handle select parameter', () => {\n const result = parseParams({ select: 'field1,field2' })\n expect(result).toHaveProperty('select')\n // Note: actual sanitization logic is tested in sanitizeSelectParam tests\n })\n\n it('should handle joins parameter', () => {\n const joins = { collection: 'posts' }\n const result = parseParams({ joins })\n expect(result).toHaveProperty('joins')\n // Note: actual sanitization logic is tested in sanitizeJoinParams tests\n })\n })\n\n describe('selectedLocales parameter', () => {\n it('should pass through selectedLocales as-is', () => {\n const selectedLocales = 'en,es,fr'\n const result = parseParams({ selectedLocales })\n expect(result.selectedLocales).toBe(selectedLocales)\n })\n })\n\n describe('publishSpecificLocale parameter', () => {\n it('should pass through publishSpecificLocale as-is', () => {\n const publishSpecificLocale = 'en'\n const result = parseParams({ publishSpecificLocale })\n expect(result.publishSpecificLocale).toBe(publishSpecificLocale)\n })\n })\n\n describe('field parameter', () => {\n it('should pass through field as-is', () => {\n const field = 'myField'\n const result = parseParams({ field })\n expect(result.field).toBe(field)\n })\n })\n\n describe('where parameter', () => {\n it('should pass through where as-is', () => {\n const where = { name: { equals: 'test' } }\n const result = parseParams({ where })\n expect(result.where).toBe(where)\n })\n })\n\n describe('edge cases', () => {\n it('should handle empty params object', () => {\n const result = parseParams({})\n expect(result).toEqual({})\n })\n\n it('should throw error for null params (current implementation bug)', () => {\n expect(() => {\n parseParams(null as any)\n }).toThrow(TypeError)\n })\n\n it('should throw error for undefined params (current implementation bug)', () => {\n expect(() => {\n parseParams(undefined as any)\n }).toThrow(TypeError)\n })\n\n it('should preserve unknown parameters', () => {\n const result = parseParams({ customParam: 'customValue' })\n expect(result.customParam).toBe('customValue')\n })\n\n it('should handle mixed parameter types', () => {\n const result = parseParams({\n draft: 'true',\n depth: '5',\n sort: 'name,createdAt',\n data: '{\"test\": true}',\n customParam: 'custom',\n })\n\n expect(result.draft).toBe(true)\n expect(result.depth).toBe(5)\n expect(result.sort).toEqual(['name', 'createdAt'])\n expect(result.data).toEqual({ test: true })\n expect(result.customParam).toBe('custom')\n })\n })\n\n describe('parameter preservation', () => {\n it('should not modify parameters that are not in known lists', () => {\n const params = {\n unknownBoolean: 'true',\n unknownNumber: '42',\n unknownString: 'test',\n }\n const result = parseParams(params)\n\n expect(result.unknownBoolean).toBe('true') // should remain string\n expect(result.unknownNumber).toBe('42') // should remain string\n expect(result.unknownString).toBe('test')\n })\n\n it('should only process parameters that exist in the input', () => {\n const result = parseParams({ draft: 'true' })\n\n expect(result.draft).toBe(true)\n expect(result).not.toHaveProperty('autosave')\n expect(result).not.toHaveProperty('depth')\n expect(result).not.toHaveProperty('sort')\n })\n })\n})\n"],"names":["parseParams","booleanParams","numberParams","describe","forEach","param","it","result","expect","toBe","toBeUndefined","sort","toEqual","data","name","value","JSON","stringify","toThrow","already","populate","toHaveProperty","select","joins","collection","selectedLocales","publishSpecificLocale","field","where","equals","TypeError","undefined","customParam","draft","depth","test","params","unknownBoolean","unknownNumber","unknownString","not"],"mappings":"AAAA,SAASA,WAAW,EAAEC,aAAa,EAAEC,YAAY,QAAQ,aAAY;AAErEC,SAAS,eAAe;IACtBA,SAAS,sBAAsB;QAC7BF,cAAcG,OAAO,CAAC,CAACC;YACrBF,SAASE,OAAO;gBACdC,GAAG,8CAA8C;oBAC/C,MAAMC,SAASP,YAAY;wBAAE,CAACK,MAAM,EAAE;oBAAO;oBAC7CG,OAAOD,MAAM,CAACF,MAAM,EAAEI,IAAI,CAAC;gBAC7B;gBAEAH,GAAG,gDAAgD;oBACjD,MAAMC,SAASP,YAAY;wBAAE,CAACK,MAAM,EAAE;oBAAQ;oBAC9CG,OAAOD,MAAM,CAACF,MAAM,EAAEI,IAAI,CAAC;gBAC7B;gBAEAH,GAAG,6CAA6C;oBAC9C,MAAMC,SAASP,YAAY;wBAAE,CAACK,MAAM,EAAE;oBAAK;oBAC3CG,OAAOD,MAAM,CAACF,MAAM,EAAEI,IAAI,CAAC;gBAC7B;gBAEAH,GAAG,+CAA+C;oBAChD,MA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sC;YACvC,MAAMC,SAASP,YAAY;gBAAEgC,aAAa;YAAc;YACxDxB,OAAOD,OAAOyB,WAAW,EAAEvB,IAAI,CAAC;QAClC;QAEAH,GAAG,uCAAuC;YACxC,MAAMC,SAASP,YAAY;gBACzBiC,OAAO;gBACPC,OAAO;gBACPvB,MAAM;gBACNE,MAAM;gBACNmB,aAAa;YACf;YAEAxB,OAAOD,OAAO0B,KAAK,EAAExB,IAAI,CAAC;YAC1BD,OAAOD,OAAO2B,KAAK,EAAEzB,IAAI,CAAC;YAC1BD,OAAOD,OAAOI,IAAI,EAAEC,OAAO,CAAC;gBAAC;gBAAQ;aAAY;YACjDJ,OAAOD,OAAOM,IAAI,EAAED,OAAO,CAAC;gBAAEuB,MAAM;YAAK;YACzC3B,OAAOD,OAAOyB,WAAW,EAAEvB,IAAI,CAAC;QAClC;IACF;IAEAN,SAAS,0BAA0B;QACjCG,GAAG,4DAA4D;YAC7D,MAAM8B,SAAS;gBACbC,gBAAgB;gBAChBC,eAAe;gBACfC,eAAe;YACjB;YACA,MAAMhC,SAASP,YAAYoC;YAE3B5B,OAAOD,OAAO8B,cAAc,EAAE5B,IAAI,CAAC,SAAQ,uBAAuB;YAClED,OAAOD,OAAO+B,aAAa,EAAE7B,IAAI,CAAC,OAAM,uBAAuB;YAC/DD,OAAOD,OAAOgC,aAAa,EAAE9B,IAAI,CAAC;QACpC;QAEAH,GAAG,0DAA0D;YAC3D,MAAMC,SAASP,YAAY;gBAAEiC,OAAO;YAAO;YAE3CzB,OAAOD,OAAO0B,KAAK,EAAExB,IAAI,CAAC;YAC1BD,OAAOD,QAAQiC,GAAG,CAACnB,cAAc,CAAC;YAClCb,OAAOD,QAAQiC,GAAG,CAACnB,cAAc,CAAC;YAClCb,OAAOD,QAAQiC,GAAG,CAACnB,cAAc,CAAC;QACpC;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utilities/telemetry/conf/index.ts"],"sourcesContent":["/**\n * Taken & simplified from https://github.com/sindresorhus/conf/blob/main/source/index.ts\n *\n * MIT License\n *\n * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport assert from 'node:assert'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { envPaths } from './envPaths.js'\n\nconst createPlainObject = <T = Record<string, unknown>>(): T => Object.create(null)\n\nconst checkValueType = (key: string, value: unknown): void => {\n const nonJsonTypes = new Set(['function', 'symbol', 'undefined'])\n\n const type = typeof value\n\n if (nonJsonTypes.has(type)) {\n throw new TypeError(\n `Setting a value of type \\`${type}\\` for key \\`${key}\\` is not allowed as it's not supported by JSON`,\n )\n }\n}\n\nexport class Conf<T extends Record<string, any> = Record<string, unknown>>\n implements Iterable<[keyof T, T[keyof T]]>\n{\n readonly #options: Readonly<Partial<Options>>\n private readonly _deserialize: Deserialize<T> = (value) => JSON.parse(value)\n private readonly _serialize: Serialize<T> = (value) => JSON.stringify(value, undefined, '\\t')\n\n readonly events: EventTarget\n\n readonly path: string\n\n constructor() {\n const options: Partial<Options> = {\n configFileMode: 0o666,\n configName: 'config',\n fileExtension: 'json',\n projectSuffix: 'nodejs',\n }\n\n const cwd = envPaths('payload', { suffix: options.projectSuffix }).config\n\n this.#options = options\n\n this.events = new EventTarget()\n\n const fileExtension = options.fileExtension ? `.${options.fileExtension}` : ''\n this.path = path.resolve(cwd, `${options.configName ?? 'config'}${fileExtension}`)\n\n const fileStore = this.store\n const store = Object.assign(createPlainObject(), fileStore)\n\n try {\n assert.deepEqual(fileStore, store)\n } catch {\n this.store = store\n }\n }\n\n private _ensureDirectory(): void {\n // Ensure the directory exists as it could have been deleted in the meantime.\n fs.mkdirSync(path.dirname(this.path), { recursive: true })\n }\n\n private _write(value: T): void {\n const data: string | Uint8Array = this._serialize(value)\n\n fs.writeFileSync(this.path, data, { mode: this.#options.configFileMode })\n }\n\n /**\n Delete an item.\n\n @param key - The key of the item to delete.\n */\n delete(key: string): void {\n const { store } = this\n delete store[key]\n\n this.store = store\n }\n\n /**\n Get an item.\n\n @param key - The key of the item to get.\n */\n get<Key extends keyof T>(key: Key): T[Key] {\n const { store } = this\n return store[key]\n }\n\n /**\n Set an item or multiple items at once.\n\n @param key - You can use [dot-notation](https://github.com/sindresorhus/dot-prop) in a key to access nested properties. Or a hashmap of items to set at once.\n @param value - Must be JSON serializable. Trying to set the type `undefined`, `function`, or `symbol` will result in a `TypeError`.\n */\n set<Key extends keyof T>(key: string, value?: T[Key] | unknown): void {\n if (typeof key !== 'string' && typeof key !== 'object') {\n throw new TypeError(\n `Expected \\`key\\` to be of type \\`string\\` or \\`object\\`, got ${typeof key}`,\n )\n }\n\n if (typeof key !== 'object' && value === undefined) {\n throw new TypeError('Use `delete()` to clear values')\n }\n\n const { store } = this\n\n const set = (key: string, value?: T | T[Key] | unknown): void => {\n checkValueType(key, value)\n store[key as Key] = value as T[Key]\n }\n\n if (typeof key === 'object') {\n const object = key\n for (const [key, value] of Object.entries(object)) {\n set(key, value)\n }\n } else {\n set(key, value)\n }\n\n this.store = store\n }\n\n *[Symbol.iterator](): IterableIterator<[keyof T, T[keyof T]]> {\n for (const [key, value] of Object.entries(this.store)) {\n yield [key, value]\n }\n }\n get size(): number {\n return Object.keys(this.store).length\n }\n get store(): T {\n try {\n const dataString = fs.readFileSync(this.path, 'utf8')\n const deserializedData = this._deserialize(dataString)\n return Object.assign(createPlainObject(), deserializedData)\n } catch (error: unknown) {\n if ((error as any)?.code === 'ENOENT') {\n this._ensureDirectory()\n return createPlainObject()\n }\n\n throw error\n }\n }\n\n set store(value: T) {\n this._ensureDirectory()\n\n this._write(value)\n\n this.events.dispatchEvent(new Event('change'))\n }\n}\n\nexport type Options = {\n /**\n The config is cleared if reading the config file causes a `SyntaxError`. This is a good behavior for unimportant data, as the config file is not intended to be hand-edited, so it usually means the config is corrupt and there's nothing the user can do about it anyway. However, if you let the user edit the config file directly, mistakes might happen and it could be more useful to throw an error when the config is invalid instead of clearing.\n\n @default false\n */\n clearInvalidConfig?: boolean\n\n /**\n The [mode](https://en.wikipedia.org/wiki/File-system_permissions#Numeric_notation) that will be used for the config file.\n\n You would usually not need this, but it could be useful if you want to restrict the permissions of the config file. Setting a permission such as `0o600` would result in a config file that can only be accessed by the user running the program.\n\n Note that setting restrictive permissions can cause problems if different users need to read the file. A common problem is a user running your tool with and without `sudo` and then not being able to access the config the second time.\n\n @default 0o666\n */\n readonly configFileMode?: number\n\n /**\n Name of the config file (without extension).\n\n Useful if you need multiple config files for your app or module. For example, different config files between two major versions.\n\n @default 'config'\n */\n configName?: string\n\n /**\n Extension of the config file.\n\n You would usually not need this, but could be useful if you want to interact with a file with a custom file extension that can be associated with your app. These might be simple save/export/preference files that are intended to be shareable or saved outside of the app.\n\n @default 'json'\n */\n fileExtension?: string\n\n readonly projectSuffix?: string\n}\n\nexport type Serialize<T> = (value: T) => string\nexport type Deserialize<T> = (text: string) => T\n"],"names":["assert","fs","path","envPaths","createPlainObject","Object","create","checkValueType","key","value","nonJsonTypes","Set","type","has","TypeError","Conf","_deserialize","JSON","parse","_serialize","stringify","undefined","events","constructor","options","configFileMode","configName","fileExtension","projectSuffix","cwd","suffix","config","EventTarget","resolve","fileStore","store","assign","deepEqual","_ensureDirectory","mkdirSync","dirname","recursive","_write","data","writeFileSync","mode","delete","get","set","object","entries","Symbol","iterator","size","keys","length","dataString","readFileSync","deserializedData","error","code","dispatchEvent","Event"],"mappings":"AAAA;;;;;;;;;;;;CAYC,GAED,OAAOA,YAAY,cAAa;AAChC,OAAOC,QAAQ,UAAS;AACxB,OAAOC,UAAU,YAAW;AAE5B,SAASC,QAAQ,QAAQ,gBAAe;AAExC,MAAMC,oBAAoB,IAAsCC,OAAOC,MAAM,CAAC;AAE9E,MAAMC,iBAAiB,CAACC,KAAaC;IACnC,MAAMC,eAAe,IAAIC,IAAI;QAAC;QAAY;QAAU;KAAY;IAEhE,MAAMC,OAAO,OAAOH;IAEpB,IAAIC,aAAaG,GAAG,CAACD,OAAO;QAC1B,MAAM,IAAIE,UACR,CAAC,0BAA0B,EAAEF,KAAK,aAAa,EAAEJ,IAAI,+CAA+C,CAAC;IAEzG;AACF;AAEA,OAAO,MAAMO;IAGF,CAAA,OAAQ,CAA4B;IAC5BC,eAA+B,CAACP,QAAUQ,KAAKC,KAAK,CAACT,OAAM;IAC3DU,aAA2B,CAACV,QAAUQ,KAAKG,SAAS,CAACX,OAAOY,WAAW,MAAK;IAEpFC,OAAmB;IAEnBpB,KAAY;IAErBqB,aAAc;QACZ,MAAMC,UAA4B;YAChCC,gBAAgB;YAChBC,YAAY;YACZC,eAAe;YACfC,eAAe;QACjB;QAEA,MAAMC,MAAM1B,SAAS,WAAW;YAAE2B,QAAQN,QAAQI,aAAa;QAAC,GAAGG,MAAM;QAEzE,IAAI,CAAC,CAAA,OAAQ,GAAGP;QAEhB,IAAI,CAACF,MAAM,GAAG,IAAIU;QAElB,MAAML,gBAAgBH,QAAQG,aAAa,GAAG,CAAC,CAAC,EAAEH,QAAQG,aAAa,EAAE,GAAG;QAC5E,IAAI,CAAC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,MAAM,CAACxC,KAAaC;YACxBF,eAAeC,KAAKC;YACpB0B,KAAK,CAAC3B,IAAW,GAAGC;QACtB;QAEA,IAAI,OAAOD,QAAQ,UAAU;YAC3B,MAAMyC,SAASzC;YACf,KAAK,MAAM,CAACA,KAAKC,MAAM,IAAIJ,OAAO6C,OAAO,CAACD,QAAS;gBACjDD,IAAIxC,KAAKC;YACX;QACF,OAAO;YACLuC,IAAIxC,KAAKC;QACX;QAEA,IAAI,CAAC0B,KAAK,GAAGA;IACf;IAEA,CAAC,CAACgB,OAAOC,QAAQ,CAAC,GAA4C;QAC5D,KAAK,MAAM,CAAC5C,KAAKC,MAAM,IAAIJ,OAAO6C,OAAO,CAAC,IAAI,CAACf,KAAK,EAAG;YACrD,MAAM;gBAAC3B;gBAAKC;aAAM;QACpB;IACF;IACA,IAAI4C,OAAe;QACjB,OAAOhD,OAAOiD,IAAI,CAAC,IAAI,CAACnB,KAAK,EAAEoB,MAAM;IACvC;IACA,IAAIpB,QAAW;QACb,IAAI;YACF,MAAMqB,aAAavD,GAAGwD,YAAY,CAAC,IAAI,CAACvD,IAAI,EAAE;YAC9C,MAAMwD,mBAAmB,IAAI,CAAC1C,YAAY,CAACwC;YAC3C,OAAOnD,OAAO+B,MAAM,CAAChC,qBAAqBsD;QAC5C,EAAE,OAAOC,OAAgB;YACvB,IAAI,AAACA,OAAeC,SAAS,UAAU;gBACrC,IAAI,CAACtB,gBAAgB;gBACrB,OAAOlC;YACT;YAEA,MAAMuD;QACR;IACF;IAEA,IAAIxB,MAAM1B,KAAQ,EAAE;QAClB,IAAI,CAAC6B,gBAAgB;QAErB,IAAI,CAACI,MAAM,CAACjC;QAEZ,IAAI,CAACa,MAAM,CAACuC,aAAa,CAAC,IAAIC,MAAM;IACtC;AACF"}
1
+ {"version":3,"sources":["../../../../src/utilities/telemetry/conf/index.ts"],"sourcesContent":["/**\n * Taken & simplified from https://github.com/sindresorhus/conf/blob/main/source/index.ts\n *\n * MIT License\n *\n * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport assert from 'node:assert'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { envPaths } from './envPaths.js'\n\nconst createPlainObject = <T = Record<string, unknown>>(): T => Object.create(null)\n\nconst checkValueType = (key: string, value: unknown): void => {\n const nonJsonTypes = new Set(['function', 'symbol', 'undefined'])\n\n const type = typeof value\n\n if (nonJsonTypes.has(type)) {\n throw new TypeError(\n `Setting a value of type \\`${type}\\` for key \\`${key}\\` is not allowed as it's not supported by JSON`,\n )\n }\n}\n\nexport class Conf<T extends Record<string, any> = Record<string, unknown>>\n implements Iterable<[keyof T, T[keyof T]]>\n{\n readonly #options: Readonly<Partial<Options>>\n private readonly _deserialize: Deserialize<T> = (value) => JSON.parse(value)\n private readonly _serialize: Serialize<T> = (value) => JSON.stringify(value, undefined, '\\t')\n\n readonly events: EventTarget\n\n readonly path: string\n\n constructor() {\n const options: Partial<Options> = {\n configFileMode: 0o666,\n configName: 'config',\n fileExtension: 'json',\n projectSuffix: 'nodejs',\n }\n\n const cwd = envPaths('payload', { suffix: options.projectSuffix }).config\n\n this.#options = options\n\n this.events = new EventTarget()\n\n const fileExtension = options.fileExtension ? `.${options.fileExtension}` : ''\n this.path = path.resolve(cwd, `${options.configName ?? 'config'}${fileExtension}`)\n\n const fileStore = this.store\n const store = Object.assign(createPlainObject(), fileStore)\n\n try {\n assert.deepEqual(fileStore, store)\n } catch {\n this.store = store\n }\n }\n\n private _ensureDirectory(): void {\n // Ensure the directory exists as it could have been deleted in the meantime.\n fs.mkdirSync(path.dirname(this.path), { recursive: true })\n }\n\n private _write(value: T): void {\n const data: string | Uint8Array = this._serialize(value)\n\n fs.writeFileSync(this.path, data, { mode: this.#options.configFileMode })\n }\n\n /**\n Delete an item.\n\n @param key - The key of the item to delete.\n */\n delete(key: string): void {\n const { store } = this\n delete store[key]\n\n this.store = store\n }\n\n /**\n Get an item.\n\n @param key - The key of the item to get.\n */\n get<Key extends keyof T>(key: Key): T[Key] {\n const { store } = this\n return store[key]\n }\n\n /**\n Set an item or multiple items at once.\n\n @param key - You can use [dot-notation](https://github.com/sindresorhus/dot-prop) in a key to access nested properties. Or a hashmap of items to set at once.\n @param value - Must be JSON serializable. Trying to set the type `undefined`, `function`, or `symbol` will result in a `TypeError`.\n */\n set<Key extends keyof T>(key: string, value?: T[Key] | unknown): void {\n if (typeof key !== 'string' && typeof key !== 'object') {\n throw new TypeError(\n `Expected \\`key\\` to be of type \\`string\\` or \\`object\\`, got ${typeof key}`,\n )\n }\n\n if (typeof key !== 'object' && value === undefined) {\n throw new TypeError('Use `delete()` to clear values')\n }\n\n const { store } = this\n\n const set = (key: string, value?: T | T[Key] | unknown): void => {\n checkValueType(key, value)\n store[key as Key] = value as T[Key]\n }\n\n if (typeof key === 'object') {\n const object = key\n for (const [key, value] of Object.entries(object)) {\n set(key, value)\n }\n } else {\n set(key, value)\n }\n\n this.store = store\n }\n\n *[Symbol.iterator](): IterableIterator<[keyof T, T[keyof T]]> {\n for (const [key, value] of Object.entries(this.store)) {\n yield [key, value]\n }\n }\n get size(): number {\n return Object.keys(this.store).length\n }\n get store(): T {\n try {\n const dataString = fs.readFileSync(this.path, 'utf8')\n const deserializedData = this._deserialize(dataString)\n return Object.assign(createPlainObject(), deserializedData)\n } catch (error: unknown) {\n if ((error as any)?.code === 'ENOENT') {\n this._ensureDirectory()\n return createPlainObject()\n }\n\n throw error\n }\n }\n\n set store(value: T) {\n this._ensureDirectory()\n\n this._write(value)\n\n this.events.dispatchEvent(new Event('change'))\n }\n}\n\nexport type Options = {\n /**\n The config is cleared if reading the config file causes a `SyntaxError`. This is a good behavior for unimportant data, as the config file is not intended to be hand-edited, so it usually means the config is corrupt and there's nothing the user can do about it anyway. However, if you let the user edit the config file directly, mistakes might happen and it could be more useful to throw an error when the config is invalid instead of clearing.\n\n @default false\n */\n clearInvalidConfig?: boolean\n\n /**\n The [mode](https://en.wikipedia.org/wiki/File-system_permissions#Numeric_notation) that will be used for the config file.\n\n You would usually not need this, but it could be useful if you want to restrict the permissions of the config file. Setting a permission such as `0o600` would result in a config file that can only be accessed by the user running the program.\n\n Note that setting restrictive permissions can cause problems if different users need to read the file. A common problem is a user running your tool with and without `sudo` and then not being able to access the config the second time.\n\n @default 0o666\n */\n readonly configFileMode?: number\n\n /**\n Name of the config file (without extension).\n\n Useful if you need multiple config files for your app or module. For example, different config files between two major versions.\n\n @default 'config'\n */\n configName?: string\n\n /**\n Extension of the config file.\n\n You would usually not need this, but could be useful if you want to interact with a file with a custom file extension that can be associated with your app. These might be simple save/export/preference files that are intended to be shareable or saved outside of the app.\n\n @default 'json'\n */\n fileExtension?: string\n\n readonly projectSuffix?: string\n}\n\nexport type Serialize<T> = (value: T) => string\nexport type Deserialize<T> = (text: string) => T\n"],"names":["assert","fs","path","envPaths","createPlainObject","Object","create","checkValueType","key","value","nonJsonTypes","Set","type","has","TypeError","Conf","_deserialize","JSON","parse","_serialize","stringify","undefined","events","options","configFileMode","configName","fileExtension","projectSuffix","cwd","suffix","config","EventTarget","resolve","fileStore","store","assign","deepEqual","_ensureDirectory","mkdirSync","dirname","recursive","_write","data","writeFileSync","mode","delete","get","set","object","entries","Symbol","iterator","size","keys","length","dataString","readFileSync","deserializedData","error","code","dispatchEvent","Event"],"mappings":"AAAA;;;;;;;;;;;;CAYC,GAED,OAAOA,YAAY,cAAa;AAChC,OAAOC,QAAQ,UAAS;AACxB,OAAOC,UAAU,YAAW;AAE5B,SAASC,QAAQ,QAAQ,gBAAe;AAExC,MAAMC,oBAAoB,IAAsCC,OAAOC,MAAM,CAAC;AAE9E,MAAMC,iBAAiB,CAACC,KAAaC;IACnC,MAAMC,eAAe,IAAIC,IAAI;QAAC;QAAY;QAAU;KAAY;IAEhE,MAAMC,OAAO,OAAOH;IAEpB,IAAIC,aAAaG,GAAG,CAACD,OAAO;QAC1B,MAAM,IAAIE,UACR,CAAC,0BAA0B,EAAEF,KAAK,aAAa,EAAEJ,IAAI,+CAA+C,CAAC;IAEzG;AACF;AAEA,OAAO,MAAMO;IAGF,CAAA,OAAQ,CAA4B;IAC5BC,eAA+B,CAACP,QAAUQ,KAAKC,KAAK,CAACT,OAAM;IAC3DU,aAA2B,CAACV,QAAUQ,KAAKG,SAAS,CAACX,OAAOY,WAAW,MAAK;IAEpFC,OAAmB;IAEnBpB,KAAY;IAErB,aAAc;QACZ,MAAMqB,UAA4B;YAChCC,gBAAgB;YAChBC,YAAY;YACZC,eAAe;YACfC,eAAe;QACjB;QAEA,MAAMC,MAAMzB,SAAS,WAAW;YAAE0B,QAAQN,QAAQI,aAAa;QAAC,GAAGG,MAAM;QAEzE,IAAI,CAAC,CAAA,OAAQ,GAAGP;QAEhB,IAAI,CAACD,MAAM,GAAG,IAAIS;QAElB,MAAML,gBAAgBH,QAAQG,aAAa,GAAG,CAAC,CAAC,EAAEH,QAAQG,aAAa,EAAE,GAAG;QAC5E,IAAI,CAACxB,IAAI,GAAGA,KAAK8B,OAAO,CAACJ,KAAK,GAAGL,QAAQE,U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C1B,IAAW,GAAGC;QACtB;QAEA,IAAI,OAAOD,QAAQ,UAAU;YAC3B,MAAMwC,SAASxC;YACf,KAAK,MAAM,CAACA,KAAKC,MAAM,IAAIJ,OAAO4C,OAAO,CAACD,QAAS;gBACjDD,IAAIvC,KAAKC;YACX;QACF,OAAO;YACLsC,IAAIvC,KAAKC;QACX;QAEA,IAAI,CAACyB,KAAK,GAAGA;IACf;IAEA,CAAC,CAACgB,OAAOC,QAAQ,CAAC,GAA4C;QAC5D,KAAK,MAAM,CAAC3C,KAAKC,MAAM,IAAIJ,OAAO4C,OAAO,CAAC,IAAI,CAACf,KAAK,EAAG;YACrD,MAAM;gBAAC1B;gBAAKC;aAAM;QACpB;IACF;IACA,IAAI2C,OAAe;QACjB,OAAO/C,OAAOgD,IAAI,CAAC,IAAI,CAACnB,KAAK,EAAEoB,MAAM;IACvC;IACA,IAAIpB,QAAW;QACb,IAAI;YACF,MAAMqB,aAAatD,GAAGuD,YAAY,CAAC,IAAI,CAACtD,IAAI,EAAE;YAC9C,MAAMuD,mBAAmB,IAAI,CAACzC,YAAY,CAACuC;YAC3C,OAAOlD,OAAO8B,MAAM,CAAC/B,qBAAqBqD;QAC5C,EAAE,OAAOC,OAAgB;YACvB,IAAI,AAACA,OAAeC,SAAS,UAAU;gBACrC,IAAI,CAACtB,gBAAgB;gBACrB,OAAOjC;YACT;YAEA,MAAMsD;QACR;IACF;IAEA,IAAIxB,MAAMzB,KAAQ,EAAE;QAClB,IAAI,CAAC4B,gBAAgB;QAErB,IAAI,CAACI,MAAM,CAAChC;QAEZ,IAAI,CAACa,MAAM,CAACsC,aAAa,CAAC,IAAIC,MAAM;IACtC;AACF"}
@@ -14,8 +14,7 @@
14
14
  try {
15
15
  columnsToTransform = JSON.parse(columns);
16
16
  } catch (e) {
17
- console.error('Error parsing columns', columns, e) // eslint-disable-line no-console
18
- ;
17
+ console.error('Error parsing columns', columns, e); // eslint-disable-line no-console
19
18
  }
20
19
  }
21
20
  if (columnsToTransform && Array.isArray(columnsToTransform)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/transformColumnPreferences.ts"],"sourcesContent":["import type { Column } from '../admin/types.js'\nimport type { ColumnPreference } from '../preferences/types.js'\n\nexport type ColumnsFromURL = string[]\n\n/**\n * Transforms various forms of columns into `ColumnPreference[]` which is what is stored in the user's preferences table\n * In React state, for example, columns are stored in in their entirety, including React components: `[{ accessor: 'title', active: true, Label: React.ReactNode, ... }]`\n * In the URL, they are stored as an array of strings: `['title', '-slug']`, where the `-` prefix is used to indicate that the column is inactive\n * However in the database, columns must be in this exact shape: `[{ accessor: 'title', active: true }, { accessor: 'slug', active: false }]`\n * This means that when handling columns, they need to be consistently transformed back and forth\n */\nexport const transformColumnsToPreferences = (\n columns: Column[] | ColumnPreference[] | ColumnsFromURL | string | undefined,\n): ColumnPreference[] | undefined => {\n if (!columns) {\n return undefined\n }\n\n let columnsToTransform = columns\n\n // Columns that originate from the URL are a stringified JSON array and need to be parsed first\n if (typeof columns === 'string') {\n try {\n columnsToTransform = JSON.parse(columns)\n } catch (e) {\n console.error('Error parsing columns', columns, e) // eslint-disable-line no-console\n }\n }\n\n if (columnsToTransform && Array.isArray(columnsToTransform)) {\n return columnsToTransform.map((col) => {\n if (typeof col === 'string') {\n const active = col[0] !== '-'\n return { accessor: active ? col : col.slice(1), active }\n }\n\n return { accessor: col.accessor, active: col.active }\n })\n }\n}\n\n/**\n * Does the opposite of `transformColumnsToPreferences`, where `ColumnPreference[]` and `Column[]` are transformed into `ColumnsFromURL`\n * This is useful for storing the columns in the URL, where it appears as a simple comma delimited array of strings\n * The `-` prefix is used to indicate that the column is inactive\n */\nexport const transformColumnsToSearchParams = (\n columns: Column[] | ColumnPreference[],\n): ColumnsFromURL => {\n return columns?.map((col) => (col.active ? col.accessor : `-${col.accessor}`))\n}\n"],"names":["transformColumnsToPreferences","columns","undefined","columnsToTransform","JSON","parse","e","console","error","Array","isArray","map","col","active","accessor","slice","transformColumnsToSearchParams"],"mappings":"AAKA;;;;;;CAMC,GACD,OAAO,MAAMA,gCAAgC,CAC3CC;IAEA,IAAI,CAACA,SAAS;QACZ,OAAOC;IACT;IAEA,IAAIC,qBAAqBF;IAEzB,+FAA+F;IAC/F,IAAI,OAAOA,YAAY,UAAU;QAC/B,IAAI;YACFE,qBAAqBC,KAAKC,KAAK,CAACJ;QAClC,EAAE,OAAOK,GAAG;YACVC,QAAQC,KAAK,CAAC,yBAAyBP,SAASK,GAAG,iCAAiC;;QACtF;IACF;IAEA,IAAIH,sBAAsBM,MAAMC,OAAO,CAACP,qBAAqB;QAC3D,OAAOA,mBAAmBQ,GAAG,CAAC,CAACC;YAC7B,IAAI,OAAOA,QAAQ,UAAU;gBAC3B,MAAMC,SAASD,GAAG,CAAC,EAAE,KAAK;gBAC1B,OAAO;oBAAEE,UAAUD,SAASD,MAAMA,IAAIG,KAAK,CAAC;oBAAIF;gBAAO;YACzD;YAEA,OAAO;gBAAEC,UAAUF,IAAIE,QAAQ;gBAAED,QAAQD,IAAIC,MAAM;YAAC;QACtD;IACF;AACF,EAAC;AAED;;;;CAIC,GACD,OAAO,MAAMG,iCAAiC,CAC5Cf;IAEA,OAAOA,SAASU,IAAI,CAACC,MAASA,IAAIC,MAAM,GAAGD,IAAIE,QAAQ,GAAG,CAAC,CAAC,EAAEF,IAAIE,QAAQ,EAAE;AAC9E,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/transformColumnPreferences.ts"],"sourcesContent":["import type { Column } from '../admin/types.js'\nimport type { ColumnPreference } from '../preferences/types.js'\n\nexport type ColumnsFromURL = string[]\n\n/**\n * Transforms various forms of columns into `ColumnPreference[]` which is what is stored in the user's preferences table\n * In React state, for example, columns are stored in in their entirety, including React components: `[{ accessor: 'title', active: true, Label: React.ReactNode, ... }]`\n * In the URL, they are stored as an array of strings: `['title', '-slug']`, where the `-` prefix is used to indicate that the column is inactive\n * However in the database, columns must be in this exact shape: `[{ accessor: 'title', active: true }, { accessor: 'slug', active: false }]`\n * This means that when handling columns, they need to be consistently transformed back and forth\n */\nexport const transformColumnsToPreferences = (\n columns: Column[] | ColumnPreference[] | ColumnsFromURL | string | undefined,\n): ColumnPreference[] | undefined => {\n if (!columns) {\n return undefined\n }\n\n let columnsToTransform = columns\n\n // Columns that originate from the URL are a stringified JSON array and need to be parsed first\n if (typeof columns === 'string') {\n try {\n columnsToTransform = JSON.parse(columns)\n } catch (e) {\n console.error('Error parsing columns', columns, e) // eslint-disable-line no-console\n }\n }\n\n if (columnsToTransform && Array.isArray(columnsToTransform)) {\n return columnsToTransform.map((col) => {\n if (typeof col === 'string') {\n const active = col[0] !== '-'\n return { accessor: active ? col : col.slice(1), active }\n }\n\n return { accessor: col.accessor, active: col.active }\n })\n }\n}\n\n/**\n * Does the opposite of `transformColumnsToPreferences`, where `ColumnPreference[]` and `Column[]` are transformed into `ColumnsFromURL`\n * This is useful for storing the columns in the URL, where it appears as a simple comma delimited array of strings\n * The `-` prefix is used to indicate that the column is inactive\n */\nexport const transformColumnsToSearchParams = (\n columns: Column[] | ColumnPreference[],\n): ColumnsFromURL => {\n return columns?.map((col) => (col.active ? col.accessor : `-${col.accessor}`))\n}\n"],"names":["transformColumnsToPreferences","columns","undefined","columnsToTransform","JSON","parse","e","console","error","Array","isArray","map","col","active","accessor","slice","transformColumnsToSearchParams"],"mappings":"AAKA;;;;;;CAMC,GACD,OAAO,MAAMA,gCAAgC,CAC3CC;IAEA,IAAI,CAACA,SAAS;QACZ,OAAOC;IACT;IAEA,IAAIC,qBAAqBF;IAEzB,+FAA+F;IAC/F,IAAI,OAAOA,YAAY,UAAU;QAC/B,IAAI;YACFE,qBAAqBC,KAAKC,KAAK,CAACJ;QAClC,EAAE,OAAOK,GAAG;YACVC,QAAQC,KAAK,CAAC,yBAAyBP,SAASK,IAAG,iCAAiC;QACtF;IACF;IAEA,IAAIH,sBAAsBM,MAAMC,OAAO,CAACP,qBAAqB;QAC3D,OAAOA,mBAAmBQ,GAAG,CAAC,CAACC;YAC7B,IAAI,OAAOA,QAAQ,UAAU;gBAC3B,MAAMC,SAASD,GAAG,CAAC,EAAE,KAAK;gBAC1B,OAAO;oBAAEE,UAAUD,SAASD,MAAMA,IAAIG,KAAK,CAAC;oBAAIF;gBAAO;YACzD;YAEA,OAAO;gBAAEC,UAAUF,IAAIE,QAAQ;gBAAED,QAAQD,IAAIC,MAAM;YAAC;QACtD;IACF;AACF,EAAC;AAED;;;;CAIC,GACD,OAAO,MAAMG,iCAAiC,CAC5Cf;IAEA,OAAOA,SAASU,IAAI,CAACC,MAASA,IAAIC,MAAM,GAAGD,IAAIE,QAAQ,GAAG,CAAC,CAAC,EAAEF,IAAIE,QAAQ,EAAE;AAC9E,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/unflatten.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/*\n * Copyright (c) 2014, Hugh Kennedy\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*\n * Copyright (c) 2020, Feross Aboukhadijeh <https://feross.org>\n * Reference: https://www.npmjs.com/package/is-buffer\n * All rights reserved.\n */\nfunction isBuffer(obj: any) {\n return (\n obj != null &&\n obj.constructor != null &&\n typeof obj.constructor.isBuffer === 'function' &&\n obj.constructor.isBuffer(obj)\n )\n}\n\ninterface Opts {\n delimiter?: string\n object?: any\n overwrite?: boolean\n recursive?: boolean\n}\n\nexport const unflatten = (target: any, opts?: Opts) => {\n opts = opts || {}\n\n const delimiter = opts.delimiter || '.'\n const overwrite = opts.overwrite || false\n const recursive = opts.recursive || false\n const result = {}\n\n const isbuffer = isBuffer(target)\n\n if (isbuffer || Object.prototype.toString.call(target) !== '[object Object]') {\n return target\n }\n\n // safely ensure that the key is an integer.\n const getkey = (key: any) => {\n const parsedKey = Number(key)\n return isNaN(parsedKey) || key.indexOf('.') !== -1 || opts.object ? key : parsedKey\n }\n\n const sortedKeys = Object.keys(target).sort((keyA, keyB) => keyA.length - keyB.length)\n\n sortedKeys.forEach((key) => {\n const split = key.split(delimiter)\n let key1 = getkey(split.shift())\n let key2 = getkey(split[0])\n let recipient = result as Record<string, any>\n\n while (key2 !== undefined) {\n if (key1 === '__proto__') {\n return\n }\n\n const type = Object.prototype.toString.call(recipient[key1])\n const isobject = type === '[object Object]' || type === '[object Array]'\n\n // do not write over falsey, non-undefined values if overwrite is false\n if (!overwrite && !isobject && typeof recipient[key1] !== 'undefined') {\n return\n }\n\n if ((overwrite && !isobject) || (!overwrite && recipient[key1] == null)) {\n recipient[key1] = typeof key2 === 'number' && !opts.object ? [] : {}\n }\n\n recipient = recipient[key1]\n\n if (split.length > 0) {\n key1 = getkey(split.shift())\n key2 = getkey(split[0])\n }\n }\n\n // unflatten again for 'messy objects'\n recipient[key1] = recursive ? unflatten(target[key], opts) : target[key]\n })\n\n return result\n}\n"],"names":["isBuffer","obj","constructor","unflatten","target","opts","delimiter","overwrite","recursive","result","isbuffer","Object","prototype","toString","call","getkey","key","parsedKey","Number","isNaN","indexOf","object","sortedKeys","keys","sort","keyA","keyB","length","forEach","split","key1","shift","key2","recipient","undefined","type","isobject"],"mappings":"AAAA,qDAAqD,GACrD;;;;;;;;;;CAUC,GAED;;;;CAIC,GACD,SAASA,SAASC,GAAQ;IACxB,OACEA,OAAO,QACPA,IAAIC,WAAW,IAAI,QACnB,OAAOD,IAAIC,WAAW,CAACF,QAAQ,KAAK,cACpCC,IAAIC,WAAW,CAACF,QAAQ,CAACC;AAE7B;AASA,OAAO,MAAME,YAAY,CAACC,QAAaC;IACrCA,OAAOA,QAAQ,CAAC;IAEhB,MAAMC,YAAYD,KAAKC,SAAS,IAAI;IACpC,MAAMC,YAAYF,KAAKE,SAAS,IAAI;IACpC,MAAMC,YAAYH,KAAKG,SAAS,IAAI;IACpC,MAAMC,SAAS,CAAC;IAEhB,MAAMC,WAAWV,SAASI;IAE1B,IAAIM,YAAYC,OAAOC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACV,YAAY,mBAAmB;QAC5E,OAAOA;IACT;IAEA,4CAA4C;IAC5C,MAAMW,SAAS,CAACC;QACd,MAAMC,YAAYC,OAAOF;QACzB,OAAOG,MAAMF,cAAcD,IAAII,OAAO,CAAC,SAAS,CAAC,KAAKf,KAAKgB,MAAM,GAAGL,MAAMC;IAC5E;IAEA,MAAMK,aAAaX,OAAOY,IAAI,CAACnB,QAAQoB,IAAI,CAAC,CAACC,MAAMC,OAASD,KAAKE,MAAM,GAAGD,KAAKC,MAAM;IAErFL,WAAWM,OAAO,CAAC,CAACZ;QAClB,MAAMa,QAAQb,IAAIa,KAAK,CAACvB;QACxB,IAAIwB,OAAOf,OAAOc,MAAME,KAAK;QAC7B,IAAIC,OAAOjB,OAAOc,KAAK,CAAC,EAAE;QAC1B,IAAII,YAAYxB;QAEhB,MAAOuB,SAASE,UAAW;YACzB,IAAIJ,SAAS,aAAa;gBACxB;YACF;YAEA,MAAMK,OAAOxB,OAAOC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACmB,SAAS,CAACH,KAAK;YAC3D,MAAMM,WAAWD,SAAS,qBAAqBA,SAAS;YAExD,uEAAuE;YACvE,IAAI,CAAC5B,aAAa,CAAC6B,YAAY,OAAOH,SAAS,CAACH,KAAK,KAAK,aAAa;gBACrE;YACF;YAEA,IAAI,AAACvB,aAAa,CAAC6B,YAAc,CAAC7B,aAAa0B,SAAS,CAACH,KAAK,IAAI,MAAO;gBACvEG,SAAS,CAACH,KAAK,GAAG,OAAOE,SAAS,YAAY,CAAC3B,KAAKgB,MAAM,GAAG,EAAE,GAAG,CAAC;YACrE;YAEAY,YAAYA,SAAS,CAACH,KAAK;YAE3B,IAAID,MAAMF,MAAM,GAAG,GAAG;gBACpBG,OAAOf,OAAOc,MAAME,KAAK;gBACzBC,OAAOjB,OAAOc,KAAK,CAAC,EAAE;YACxB;QACF;QAEA,sCAAsC;QACtCI,SAAS,CAACH,KAAK,GAAGtB,YAAYL,UAAUC,MAAM,CAACY,IAAI,EAAEX,QAAQD,MAAM,CAACY,IAAI;IAC1E;IAEA,OAAOP;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/unflatten.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/*\n * Copyright (c) 2014, Hugh Kennedy\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/*\n * Copyright (c) 2020, Feross Aboukhadijeh <https://feross.org>\n * Reference: https://www.npmjs.com/package/is-buffer\n * All rights reserved.\n */\nfunction isBuffer(obj: any) {\n return (\n obj != null &&\n obj.constructor != null &&\n typeof obj.constructor.isBuffer === 'function' &&\n obj.constructor.isBuffer(obj)\n )\n}\n\ninterface Opts {\n delimiter?: string\n object?: any\n overwrite?: boolean\n recursive?: boolean\n}\n\nexport const unflatten = (target: any, opts?: Opts) => {\n opts = opts || {}\n\n const delimiter = opts.delimiter || '.'\n const overwrite = opts.overwrite || false\n const recursive = opts.recursive || false\n const result = {}\n\n const isbuffer = isBuffer(target)\n\n if (isbuffer || Object.prototype.toString.call(target) !== '[object Object]') {\n return target\n }\n\n // safely ensure that the key is an integer.\n const getkey = (key: any) => {\n const parsedKey = Number(key)\n return isNaN(parsedKey) || key.indexOf('.') !== -1 || opts.object ? key : parsedKey\n }\n\n const sortedKeys = Object.keys(target).sort((keyA, keyB) => keyA.length - keyB.length)\n\n sortedKeys.forEach((key) => {\n const split = key.split(delimiter)\n let key1 = getkey(split.shift())\n let key2 = getkey(split[0])\n let recipient = result as Record<string, any>\n\n while (key2 !== undefined) {\n if (key1 === '__proto__') {\n return\n }\n\n const type = Object.prototype.toString.call(recipient[key1])\n const isobject = type === '[object Object]' || type === '[object Array]'\n\n // do not write over falsey, non-undefined values if overwrite is false\n if (!overwrite && !isobject && typeof recipient[key1] !== 'undefined') {\n return\n }\n\n if ((overwrite && !isobject) || (!overwrite && recipient[key1] == null)) {\n recipient[key1] = typeof key2 === 'number' && !opts.object ? [] : {}\n }\n\n recipient = recipient[key1]\n\n if (split.length > 0) {\n key1 = getkey(split.shift())\n key2 = getkey(split[0])\n }\n }\n\n // unflatten again for 'messy objects'\n recipient[key1] = recursive ? unflatten(target[key], opts) : target[key]\n })\n\n return result\n}\n"],"names":["isBuffer","obj","unflatten","target","opts","delimiter","overwrite","recursive","result","isbuffer","Object","prototype","toString","call","getkey","key","parsedKey","Number","isNaN","indexOf","object","sortedKeys","keys","sort","keyA","keyB","length","forEach","split","key1","shift","key2","recipient","undefined","type","isobject"],"mappings":"AAAA,qDAAqD,GACrD;;;;;;;;;;CAUC,GAED;;;;CAIC,GACD,SAASA,SAASC,GAAQ;IACxB,OACEA,OAAO,QACPA,IAAI,WAAW,IAAI,QACnB,OAAOA,IAAI,WAAW,CAACD,QAAQ,KAAK,cACpCC,IAAI,WAAW,CAACD,QAAQ,CAACC;AAE7B;AASA,OAAO,MAAMC,YAAY,CAACC,QAAaC;IACrCA,OAAOA,QAAQ,CAAC;IAEhB,MAAMC,YAAYD,KAAKC,SAAS,IAAI;IACpC,MAAMC,YAAYF,KAAKE,SAAS,IAAI;IACpC,MAAMC,YAAYH,KAAKG,SAAS,IAAI;IACpC,MAAMC,SAAS,CAAC;IAEhB,MAAMC,WAAWT,SAASG;IAE1B,IAAIM,YAAYC,OAAOC,SAAS,CAACC,QAAQ,CAACC,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CAACY,IAAI,EAAEX,QAAQD,MAAM,CAACY,IAAI;IAC1E;IAEA,OAAOP;AACT,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload",
3
- "version": "3.68.0-internal.35482da",
3
+ "version": "3.68.0-internal.6fa474a",
4
4
  "description": "Node, React, Headless CMS and Application Framework built on Next.js",
5
5
  "keywords": [
6
6
  "admin panel",
@@ -106,7 +106,7 @@
106
106
  "undici": "7.10.0",
107
107
  "uuid": "10.0.0",
108
108
  "ws": "^8.16.0",
109
- "@payloadcms/translations": "3.68.0-internal.35482da"
109
+ "@payloadcms/translations": "3.68.0-internal.6fa474a"
110
110
  },
111
111
  "devDependencies": {
112
112
  "@hyrious/esbuild-plugin-commonjs": "0.2.6",