@aws-amplify/storage
Version:
Storage category of aws-amplify
1 lines • 2.19 kB
Source Map (JSON)
{"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';\nimport { resolveIdentityId } from './resolveIdentityId';\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'\n ? path\n : path({ identityId: resolveIdentityId(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;AAMY,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;AAC9F,IAAI,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE;AAChC,QAAQ,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK;AAC9B,QAAQ,MAAM,SAAS,GAAG,OAAO,IAAI,KAAK;AAC1C,cAAc;AACd,cAAc,IAAI,CAAC,EAAE,UAAU,EAAE,iBAAiB,CAAC,UAAU,CAAC,EAAE,CAAC;AACjE,QAAQ,qBAAqB,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,0BAA0B,CAAC,uBAAuB,CAAC;AAC7G,QAAQ,OAAO;AACf,YAAY,SAAS,EAAE,kBAAkB;AACzC,YAAY,SAAS;AACrB,SAAS;AACT;AACA,SAAS;AACT,QAAQ,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,KAAK,CAAC,GAAG,EAAE;AACrE;AACA;;;;"}