1 | {"version":3,"file":"validateStorageOperationInput.mjs","sources":["../../../../../src/providers/s3/utils/validateStorageOperationInput.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 { isInputWithPath } from './isInputWithPath';\nimport { STORAGE_INPUT_KEY, STORAGE_INPUT_PATH } from './constants';\nexport const validateStorageOperationInput = (input, identityId) => {\n assertValidationError(\n // Key present without a path\n (!!input.key && !input.path) ||\n // Path present without a key\n (!input.key && !!input.path), StorageValidationErrorCode.InvalidStorageOperationInput);\n if (isInputWithPath(input)) {\n const { path } = input;\n const objectKey = typeof path === 'string' ? path : path({ identityId });\n assertValidationError(!objectKey.startsWith('/'), StorageValidationErrorCode.InvalidStoragePathInput);\n return {\n inputType: STORAGE_INPUT_PATH,\n objectKey,\n };\n }\n else {\n return { inputType: STORAGE_INPUT_KEY, objectKey: input.key };\n }\n};\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAKY,MAAC,6BAA6B,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK;AACpE,IAAI,qBAAqB;AACzB;AACA,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI;AAC/B;AACA,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,0BAA0B,CAAC,4BAA4B,CAAC,CAAC;AAC/F,IAAI,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE;AAChC,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,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,iBAAiB,EAAE,SAAS,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;AACtE,KAAK;AACL;;;;"} |