{"version":3,"file":"AmazonAIIdentifyPredictionsProvider.mjs","sources":["../../../src/providers/AmazonAIIdentifyPredictionsProvider.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger, isAmplifyContext, } from '@aws-amplify/core';\nimport { Category, PredictionsAction, createCtxResolver, getAmplifyUserAgentObject, } from '@aws-amplify/core/internals/utils';\nimport { getUrl } from '@aws-amplify/storage';\nimport { DetectFacesCommand, DetectLabelsCommand, DetectModerationLabelsCommand, DetectTextCommand, RecognizeCelebritiesCommand, RekognitionClient, SearchFacesByImageCommand, } from '@aws-sdk/client-rekognition';\nimport { AnalyzeDocumentCommand, DetectDocumentTextCommand, TextractClient, } from '@aws-sdk/client-textract';\nimport { PredictionsValidationErrorCode } from '../errors/types/validation';\nimport { assertValidationError } from '../errors/utils/assertValidationError';\nimport { isFileSource, isIdentifyBytesSource, isIdentifyCelebrities, isIdentifyFromCollection, isIdentifyLabelsInput, isIdentifyTextInput, isStorageSource, isValidIdentifyInput, } from '../types';\nimport { categorizeRekognitionBlocks, categorizeTextractBlocks, } from './IdentifyTextUtils';\nimport { blobToArrayBuffer, makeCamelCase, makeCamelCaseArray } from './Utils';\nconst logger = new ConsoleLogger('AmazonAIIdentifyPredictionsProvider');\nexport class AmazonAIIdentifyPredictionsProvider {\n    /**\n     * @param ctx - The AmplifyContext to use for auth and config.\n     *   When provided, the provider is pinned to this context.\n     *   When omitted, the provider resolves the global context lazily per operation.\n     */\n    constructor(ctx) {\n        this._resolveCtx = createCtxResolver(isAmplifyContext(ctx) ? ctx : undefined);\n    }\n    getProviderName() {\n        return 'AmazonAIIdentifyPredictionsProvider';\n    }\n    identify(input) {\n        assertValidationError(isValidIdentifyInput(input), PredictionsValidationErrorCode.InvalidInput);\n        if (isIdentifyTextInput(input)) {\n            logger.debug('identifyText');\n            return this.identifyText(input);\n        }\n        else if (isIdentifyLabelsInput(input)) {\n            logger.debug('identifyLabels');\n            return this.identifyLabels(input);\n        }\n        else {\n            logger.debug('identifyEntities');\n            return this.identifyEntities(input);\n        }\n    }\n    /**\n     * Verify user input source and converts it into source object readable by Rekognition and Textract.\n     * Note that Rekognition and Textract use the same source interface, so we need not worry about types.\n     * @param {IdentifySource} source - User input source that directs to the object user wants\n     * to identify (storage, file, or bytes).\n     * @return {Promise<Image>} - Promise resolving to the converted source object.\n     */\n    configureSource(source) {\n        return new Promise((resolve, reject) => {\n            if (isStorageSource(source)) {\n                const storageConfig = {\n                    accessLevel: source.level,\n                    targetIdentityId: source.identityId,\n                };\n                getUrl(this._resolveCtx(), { key: source.key, options: storageConfig })\n                    .then(value => {\n                    const parser = /https:\\/\\/([a-zA-Z0-9%\\-_.]+)\\.s3\\.[A-Za-z0-9%\\-._~]+\\/([a-zA-Z0-9%\\-._~/]+)\\?/;\n                    const parsedURL = value.url.toString().match(parser) ?? '';\n                    if (parsedURL.length < 3)\n                        reject(new Error('Invalid S3 key was given.'));\n                    resolve({\n                        S3Object: {\n                            Bucket: parsedURL[1],\n                            Name: decodeURIComponent(parsedURL[2]),\n                        },\n                    });\n                })\n                    .catch(err => {\n                    reject(err);\n                });\n            }\n            else if (isFileSource(source)) {\n                blobToArrayBuffer(source.file)\n                    .then(buffer => {\n                    resolve({ Bytes: new Uint8Array(buffer) });\n                })\n                    .catch(err => {\n                    reject(err);\n                });\n            }\n            else if (isIdentifyBytesSource(source)) {\n                const { bytes } = source;\n                if (bytes instanceof Blob) {\n                    blobToArrayBuffer(bytes)\n                        .then(buffer => {\n                        resolve({ Bytes: new Uint8Array(buffer) });\n                    })\n                        .catch(err => {\n                        reject(err);\n                    });\n                }\n                if (bytes instanceof ArrayBuffer || bytes instanceof Buffer) {\n                    resolve({ Bytes: new Uint8Array(bytes) });\n                }\n                // everything else can be directly passed to Rekognition / Textract.\n                resolve({ Bytes: bytes });\n            }\n            else {\n                reject(new Error('Input source is not configured correctly.'));\n            }\n        });\n    }\n    /**\n     * Recognize text from real-world images and documents (plain text, forms and tables). Detects text in the input\n     * image and converts it into machine-readable text.\n     * @param {IdentifySource} source - Object containing the source image and feature types to analyze.\n     * @return {Promise<IdentifyTextOutput>} - Promise resolving to object containing identified texts.\n     */\n    async identifyText(input) {\n        const { credentials } = await this._resolveCtx().fetchAuthSession();\n        assertValidationError(!!credentials, PredictionsValidationErrorCode.NoCredentials);\n        const { identifyText = {} } = this._resolveCtx().resourcesConfig.Predictions?.identify ?? {};\n        const { region = '', defaults = {} } = identifyText;\n        const { format: configFormat = 'PLAIN' } = defaults;\n        this.rekognitionClient = new RekognitionClient({\n            region,\n            credentials,\n            customUserAgent: _getPredictionsIdentifyAmplifyUserAgent(),\n        });\n        this.textractClient = new TextractClient({\n            region,\n            credentials,\n            customUserAgent: _getPredictionsIdentifyAmplifyUserAgent(),\n        });\n        const inputDocument = await this.configureSource(input.text?.source);\n        // get default value if format isn't specified in the input.\n        const format = input.text?.format ?? configFormat;\n        const featureTypes = []; // structures we want to analyze (e.g. [TABLES, FORMS]).\n        if (format === 'FORM' || format === 'ALL')\n            featureTypes.push('FORMS');\n        if (format === 'TABLE' || format === 'ALL')\n            featureTypes.push('TABLES');\n        if (featureTypes.length === 0) {\n            /**\n             * Empty featureTypes indicates that we will identify plain text. We will use rekognition (suitable\n             * for everyday images but has 50 word limit) first and see if reaches its word limit. If it does, then\n             * we call textract and use the data that identify more words.\n             */\n            const textractParam = {\n                Document: inputDocument,\n            };\n            const rekognitionParam = {\n                Image: inputDocument,\n            };\n            const detectTextCommand = new DetectTextCommand(rekognitionParam);\n            const rekognitionData = await this.rekognitionClient.send(detectTextCommand);\n            const rekognitionResponse = categorizeRekognitionBlocks(rekognitionData.TextDetections);\n            if (rekognitionResponse.text.words.length < 50) {\n                // did not hit the word limit, return the data\n                return rekognitionResponse;\n            }\n            const detectDocumentTextCommand = new DetectDocumentTextCommand(textractParam);\n            const { Blocks } = await this.textractClient.send(detectDocumentTextCommand);\n            if ((rekognitionData.TextDetections?.length ?? 0) > (Blocks?.length ?? 0)) {\n                return rekognitionResponse;\n            }\n            return categorizeTextractBlocks(Blocks);\n        }\n        else {\n            const param = {\n                Document: inputDocument,\n                FeatureTypes: featureTypes,\n            };\n            const analyzeDocumentCommand = new AnalyzeDocumentCommand(param);\n            const { Blocks } = await this.textractClient.send(analyzeDocumentCommand);\n            return categorizeTextractBlocks(Blocks);\n        }\n    }\n    /**\n     * Identify instances of real world entities from an image and if it contains unsafe content.\n     * @param {IdentifyLabelsInput} input - Object containing the source image and entity type to identify.\n     * @return {Promise<IdentifyLabelsOutput>} - Promise resolving to an array of identified entities.\n     */\n    async identifyLabels(input) {\n        const { credentials } = await this._resolveCtx().fetchAuthSession();\n        assertValidationError(!!credentials, PredictionsValidationErrorCode.NoCredentials);\n        const { identifyLabels = {} } = this._resolveCtx().resourcesConfig.Predictions?.identify ?? {};\n        const { region = '', defaults = {} } = identifyLabels;\n        const { type = 'LABELS' } = defaults;\n        this.rekognitionClient = new RekognitionClient({\n            region,\n            credentials,\n            customUserAgent: _getPredictionsIdentifyAmplifyUserAgent(),\n        });\n        const inputImage = await this.configureSource(input.labels?.source);\n        const param = { Image: inputImage };\n        const servicePromises = [];\n        // get default argument\n        const entityType = input.labels?.type ?? type;\n        if (entityType === 'LABELS' || entityType === 'ALL') {\n            servicePromises.push(this.detectLabels(param));\n        }\n        if (entityType === 'UNSAFE' || entityType === 'ALL') {\n            servicePromises.push(this.detectModerationLabels(param));\n        }\n        return Promise.all(servicePromises).then(data => {\n            let identifyResult = {};\n            // concatenate resolved promises to a single object\n            data.forEach(val => {\n                identifyResult = { ...identifyResult, ...val };\n            });\n            return identifyResult;\n        });\n    }\n    /**\n     * Calls Rekognition.detectLabels and organizes the returned data.\n     * @param param - parameters as {@link DetectLabelsCommandInput} to be passed onto Rekognition\n     * @return a promise resolving to organized detectLabels response as {@link IdentifyLabelsOutput}.\n     */\n    async detectLabels(param) {\n        const detectLabelsCommand = new DetectLabelsCommand(param);\n        const data = await this.rekognitionClient.send(detectLabelsCommand);\n        if (!data.Labels)\n            return {}; // no image was detected\n        const detectLabelData = data.Labels.map(label => {\n            const boxes = label.Instances?.map(instance => makeCamelCase(instance.BoundingBox)) || [];\n            return {\n                name: label.Name,\n                boundingBoxes: boxes,\n                metadata: {\n                    confidence: label.Confidence,\n                    parents: makeCamelCaseArray(label.Parents),\n                },\n            };\n        });\n        return { labels: detectLabelData };\n    }\n    /**\n     * Calls Rekognition.detectModerationLabels and organizes the returned data.\n     * @param param parameter to be passed onto Rekognition as {@link DetectModerationLabelsCommandInput}\n     * @return a promise resolving to organized detectModerationLabels response as {@link IdentifyLabelsOutput}.\n     */\n    async detectModerationLabels(param) {\n        const detectModerationLabelsCommand = new DetectModerationLabelsCommand(param);\n        const data = await this.rekognitionClient.send(detectModerationLabelsCommand);\n        if (data.ModerationLabels?.length !== 0) {\n            return { unsafe: 'YES' };\n        }\n        else {\n            return { unsafe: 'NO' };\n        }\n    }\n    /**\n     * Identify faces within an image that is provided as input, and match faces from a collection\n     * or identify celebrities.\n     * @param input - object of {@link IdentifyEntitiesInput} containing the source image and face match options.\n     * @return a promise resolving to identify results as {@link IdentifyEntitiesOutput}.\n     */\n    async identifyEntities(input) {\n        const { credentials } = await this._resolveCtx().fetchAuthSession();\n        assertValidationError(!!credentials, PredictionsValidationErrorCode.NoCredentials);\n        const { identifyEntities = {} } = this._resolveCtx().resourcesConfig.Predictions?.identify ?? {};\n        const { region = '', celebrityDetectionEnabled = false, defaults = {}, } = identifyEntities;\n        const { collectionId: collectionIdConfig = '', maxEntities: maxFacesConfig = 50, } = defaults;\n        // default arguments\n        this.rekognitionClient = new RekognitionClient({\n            region,\n            credentials,\n            customUserAgent: _getPredictionsIdentifyAmplifyUserAgent(),\n        });\n        const inputImage = await this.configureSource(input.entities?.source);\n        const param = { Attributes: ['ALL'], Image: inputImage };\n        if (isIdentifyCelebrities(input.entities) &&\n            input.entities.celebrityDetection) {\n            assertValidationError(celebrityDetectionEnabled, PredictionsValidationErrorCode.CelebrityDetectionNotEnabled);\n            const recognizeCelebritiesCommand = new RecognizeCelebritiesCommand(param);\n            const data = await this.rekognitionClient.send(recognizeCelebritiesCommand);\n            const faces = data.CelebrityFaces?.map(celebrity => ({\n                boundingBox: makeCamelCase(celebrity.Face?.BoundingBox),\n                landmarks: makeCamelCaseArray(celebrity.Face?.Landmarks),\n                metadata: {\n                    ...makeCamelCase(celebrity, ['Id', 'Name', 'Urls']),\n                    pose: makeCamelCase(celebrity.Face?.Pose),\n                },\n            })) ?? [];\n            return { entities: faces };\n        }\n        else if (isIdentifyFromCollection(input.entities) &&\n            input.entities.collection) {\n            const { collectionId = collectionIdConfig, maxEntities: maxFaces = maxFacesConfig, } = input.entities;\n            // Concatenate additional parameters\n            const updatedParam = {\n                ...param,\n                CollectionId: collectionId,\n                MaxFaces: maxFaces,\n            };\n            const searchFacesByImageCommand = new SearchFacesByImageCommand(updatedParam);\n            const data = await this.rekognitionClient.send(searchFacesByImageCommand);\n            const faces = data.FaceMatches?.map(match => {\n                const externalImageId = match.Face?.ExternalImageId\n                    ? this.decodeExternalImageId(match.Face.ExternalImageId)\n                    : undefined;\n                return {\n                    boundingBox: makeCamelCase(match.Face?.BoundingBox),\n                    metadata: {\n                        externalImageId,\n                        similarity: match.Similarity,\n                    },\n                };\n            }) ?? [];\n            return { entities: faces };\n        }\n        else {\n            const detectFacesCommand = new DetectFacesCommand(param);\n            const data = await this.rekognitionClient.send(detectFacesCommand);\n            const faces = data.FaceDetails?.map(detail => {\n                // face attributes keys we want to extract from Rekognition's response\n                const attributeKeys = [\n                    'Smile',\n                    'Eyeglasses',\n                    'Sunglasses',\n                    'Gender',\n                    'Beard',\n                    'Mustache',\n                    'EyesOpen',\n                    'MouthOpen',\n                ];\n                const faceAttributes = makeCamelCase(detail, attributeKeys);\n                faceAttributes.emotions = detail.Emotions?.map(emotion => emotion.Type);\n                return {\n                    boundingBox: makeCamelCase(detail.BoundingBox),\n                    landmarks: makeCamelCaseArray(detail.Landmarks),\n                    ageRange: makeCamelCase(detail.AgeRange),\n                    attributes: faceAttributes,\n                    metadata: {\n                        confidence: detail.Confidence,\n                        pose: makeCamelCase(detail.Pose),\n                    },\n                };\n            }) ?? [];\n            return { entities: faces };\n        }\n    }\n    decodeExternalImageId(externalImageId) {\n        return ('' + externalImageId).replace(/::/g, '/');\n    }\n}\nfunction _getPredictionsIdentifyAmplifyUserAgent() {\n    return getAmplifyUserAgentObject({\n        category: Category.Predictions,\n        action: PredictionsAction.Identify,\n    });\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AACA;AAWA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,qCAAqC,CAAC;AAChE,MAAM,mCAAmC,CAAC;AACjD;AACA;AACA;AACA;AACA;AACA,IAAI,WAAW,CAAC,GAAG,EAAE;AACrB,QAAQ,IAAI,CAAC,WAAW,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,SAAS,CAAC;AACrF,IAAI;AACJ,IAAI,eAAe,GAAG;AACtB,QAAQ,OAAO,qCAAqC;AACpD,IAAI;AACJ,IAAI,QAAQ,CAAC,KAAK,EAAE;AACpB,QAAQ,qBAAqB,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE,8BAA8B,CAAC,YAAY,CAAC;AACvG,QAAQ,IAAI,mBAAmB,CAAC,KAAK,CAAC,EAAE;AACxC,YAAY,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC;AACxC,YAAY,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;AAC3C,QAAQ;AACR,aAAa,IAAI,qBAAqB,CAAC,KAAK,CAAC,EAAE;AAC/C,YAAY,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC;AAC1C,YAAY,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC;AAC7C,QAAQ;AACR,aAAa;AACb,YAAY,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC;AAC5C,YAAY,OAAO,I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