1 | {"version":3,"file":"validateStorageOperationInputWithPrefix.mjs","sources":["../../../../../src/providers/s3/utils/validateStorageOperationInputWithPrefix.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { assertValidationError } from '../../../errors/utils/assertValidationError';\nimport { StorageValidationErrorCode } from '../../../errors/types/validation';\nimport { STORAGE_INPUT_PATH, STORAGE_INPUT_PREFIX } from './constants';\n// Local assertion function with StorageOperationInputWithPrefixPath as Input\nconst _isInputWithPath = (input) => {\n return input.path !== undefined;\n};\nexport const validateStorageOperationInputWithPrefix = (input, identityId) => {\n // Validate prefix & path not present at the same time\n assertValidationError(!(input.prefix && input.path), StorageValidationErrorCode.InvalidStorageOperationPrefixInput);\n if (_isInputWithPath(input)) {\n const { path } = input;\n const objectKey = typeof path === 'string' ? path : path({ identityId });\n // Assert on no leading slash in the path parameter\n assertValidationError(!objectKey.startsWith('/'), StorageValidationErrorCode.InvalidStoragePathInput);\n return {\n inputType: STORAGE_INPUT_PATH,\n objectKey,\n };\n }\n else {\n return { inputType: STORAGE_INPUT_PREFIX, objectKey: input.prefix ?? '' };\n }\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIA;AACA,MAAM,gBAAgB,GAAG,CAAC,KAAK,KAAK;AACpC,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC;AACpC,CAAC,CAAC;AACU,MAAC,uCAAuC,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK;AAC9E;AACA,IAAI,qBAAqB,CAAC,EAAE,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,0BAA0B,CAAC,kCAAkC,CAAC,CAAC;AACxH,IAAI,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;AACjC,QAAQ,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;AAC/B,QAAQ,MAAM,SAAS,GAAG,OAAO,IAAI,KAAK,QAAQ,GAAG,IAAI,GAAG,IAAI,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;AACjF;AACA,QAAQ,qBAAqB,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,0BAA0B,CAAC,uBAAuB,CAAC,CAAC;AAC9G,QAAQ,OAAO;AACf,YAAY,SAAS,EAAE,kBAAkB;AACzC,YAAY,SAAS;AACrB,SAAS,CAAC;AACV,KAAK;AACL,SAAS;AACT,QAAQ,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,SAAS,EAAE,KAAK,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;AAClF,KAAK;AACL;;;;"} |