@aws-amplify/predictions 6.0.22 → 6.0.23

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 (41) hide show
  1. package/dist/cjs/Predictions.js +2 -4
  2. package/dist/cjs/Predictions.js.map +1 -1
  3. package/dist/cjs/providers/AmazonAIConvertPredictionsProvider.js +9 -9
  4. package/dist/cjs/providers/AmazonAIConvertPredictionsProvider.js.map +1 -1
  5. package/dist/cjs/providers/AmazonAIIdentifyPredictionsProvider.js +25 -20
  6. package/dist/cjs/providers/AmazonAIIdentifyPredictionsProvider.js.map +1 -1
  7. package/dist/cjs/providers/AmazonAIInterpretPredictionsProvider.js +7 -7
  8. package/dist/cjs/providers/AmazonAIInterpretPredictionsProvider.js.map +1 -1
  9. package/dist/cjs/providers/IdentifyTextUtils.js +9 -9
  10. package/dist/cjs/providers/IdentifyTextUtils.js.map +1 -1
  11. package/dist/cjs/providers/Utils.js +6 -6
  12. package/dist/cjs/providers/Utils.js.map +1 -1
  13. package/dist/cjs/types/Predictions.js +15 -14
  14. package/dist/cjs/types/Predictions.js.map +1 -1
  15. package/dist/esm/Predictions.mjs +0 -2
  16. package/dist/esm/Predictions.mjs.map +1 -1
  17. package/dist/esm/providers/AmazonAIConvertPredictionsProvider.mjs +9 -9
  18. package/dist/esm/providers/AmazonAIConvertPredictionsProvider.mjs.map +1 -1
  19. package/dist/esm/providers/AmazonAIIdentifyPredictionsProvider.d.ts +6 -6
  20. package/dist/esm/providers/AmazonAIIdentifyPredictionsProvider.mjs +25 -20
  21. package/dist/esm/providers/AmazonAIIdentifyPredictionsProvider.mjs.map +1 -1
  22. package/dist/esm/providers/AmazonAIInterpretPredictionsProvider.mjs +7 -7
  23. package/dist/esm/providers/AmazonAIInterpretPredictionsProvider.mjs.map +1 -1
  24. package/dist/esm/providers/IdentifyTextUtils.mjs +9 -9
  25. package/dist/esm/providers/IdentifyTextUtils.mjs.map +1 -1
  26. package/dist/esm/providers/Utils.mjs +6 -6
  27. package/dist/esm/providers/Utils.mjs.map +1 -1
  28. package/dist/esm/types/AWSTypes.d.ts +2 -2
  29. package/dist/esm/types/Predictions.d.ts +30 -30
  30. package/dist/esm/types/Predictions.mjs +15 -14
  31. package/dist/esm/types/Predictions.mjs.map +1 -1
  32. package/package.json +6 -5
  33. package/src/Predictions.ts +2 -3
  34. package/src/providers/AmazonAIConvertPredictionsProvider.ts +20 -10
  35. package/src/providers/AmazonAIIdentifyPredictionsProvider.ts +41 -26
  36. package/src/providers/AmazonAIInterpretPredictionsProvider.ts +22 -18
  37. package/src/providers/IdentifyTextUtils.ts +25 -22
  38. package/src/providers/Utils.ts +8 -6
  39. package/src/providers/index.ts +1 -0
  40. package/src/types/AWSTypes.ts +2 -3
  41. package/src/types/Predictions.ts +60 -44
@@ -1 +1 @@
1
- {"version":3,"file":"IdentifyTextUtils.mjs","sources":["../../../src/providers/IdentifyTextUtils.ts"],"sourcesContent":["import { makeCamelCase, makeCamelCaseArray } from './Utils';\nfunction getBoundingBox(geometry) {\n return makeCamelCase(geometry?.BoundingBox);\n}\nfunction getPolygon(geometry) {\n if (!geometry?.Polygon)\n return undefined;\n return makeCamelCaseArray(Array.from(geometry.Polygon));\n}\n/**\n * Organizes blocks from Rekognition API to each of the categories and and structures\n * their data accordingly.\n * @param {BlockList} source - Array containing blocks returned from Textract API.\n * @return {IdentifyTextOutput} - Object that categorizes each block and its information.\n */\nexport function categorizeRekognitionBlocks(blocks) {\n // Skeleton IdentifyText API response. We will populate it as we iterate through blocks.\n const response = {\n text: {\n fullText: '',\n words: [],\n lines: [],\n linesDetailed: [],\n },\n };\n // We categorize each block by running a forEach loop through them.\n blocks.forEach(block => {\n switch (block.Type) {\n case 'LINE':\n if (block.DetectedText) {\n response.text.lines.push(block.DetectedText);\n }\n response.text.linesDetailed.push({\n text: block.DetectedText,\n polygon: getPolygon(block.Geometry),\n boundingBox: getBoundingBox(block.Geometry),\n page: undefined, // rekognition doesn't have this info\n });\n break;\n case 'WORD':\n response.text.fullText += block.DetectedText + ' ';\n response.text.words.push({\n text: block.DetectedText,\n polygon: getPolygon(block.Geometry),\n boundingBox: getBoundingBox(block.Geometry),\n });\n break;\n }\n });\n // remove trailing space of fullText\n response.text.fullText = response.text.fullText.substr(0, response.text.fullText.length - 1);\n return response;\n}\n/**\n * Organizes blocks from Textract API to each of the categories and and structures\n * their data accordingly.\n * @param {BlockList} source - Array containing blocks returned from Textract API.\n * @return {IdentifyTextOutput} - Object that categorizes each block and its information.\n */\nexport function categorizeTextractBlocks(blocks) {\n // Skeleton IdentifyText API response. We will populate it as we iterate through blocks.\n const response = {\n text: {\n fullText: '',\n words: [],\n lines: [],\n linesDetailed: [],\n },\n };\n // if blocks is an empty array, ie. textract did not detect anything, return empty response.\n if (blocks.length === 0)\n return response;\n /**\n * We categorize each of the blocks by running a forEach loop through them.\n *\n * For complex structures such as Tables and KeyValue, we need to trasverse through their children. To do so,\n * we will post-process them after the for each loop. We do this by storing table and keyvalues in arrays and\n * mapping other blocks in `blockMap` (id to block) so we can reference them easily later.\n *\n * Note that we do not map `WORD` and `TABLE` in `blockMap` because they will not be referenced by any other\n * block except the Page block.\n */\n const tableBlocks = Array();\n const keyValueBlocks = Array();\n const blockMap = {};\n blocks.forEach(block => {\n switch (block.BlockType) {\n case 'LINE':\n if (block.Text) {\n response.text.lines.push(block.Text);\n }\n response.text.linesDetailed.push({\n text: block.Text,\n polygon: getPolygon(block.Geometry),\n boundingBox: getBoundingBox(block.Geometry),\n page: block.Page,\n });\n break;\n case 'WORD':\n response.text.fullText += block.Text + ' ';\n response.text.words.push({\n text: block.Text,\n polygon: getPolygon(block.Geometry),\n boundingBox: getBoundingBox(block.Geometry),\n });\n if (block.Id) {\n blockMap[block.Id] = block;\n }\n break;\n case 'SELECTION_ELEMENT':\n const selectionStatus = block.SelectionStatus === 'SELECTED' ? true : false;\n if (!response.text.selections)\n response.text.selections = [];\n response.text.selections.push({\n selected: selectionStatus,\n polygon: getPolygon(block.Geometry),\n boundingBox: getBoundingBox(block.Geometry),\n });\n if (block.Id) {\n blockMap[block.Id] = block;\n }\n break;\n case 'TABLE':\n tableBlocks.push(block);\n break;\n case 'KEY_VALUE_SET':\n keyValueBlocks.push(block);\n if (block.Id) {\n blockMap[block.Id] = block;\n }\n break;\n default:\n if (block.Id) {\n blockMap[block.Id] = block;\n }\n }\n });\n // remove trailing space in fullText\n response.text.fullText = response.text.fullText.substr(0, response.text.fullText.length - 1);\n // Post-process complex structures if they exist.\n if (tableBlocks.length !== 0) {\n const tableResponse = Array();\n tableBlocks.forEach(table => {\n tableResponse.push(constructTable(table, blockMap));\n });\n response.text.tables = tableResponse;\n }\n if (keyValueBlocks.length !== 0) {\n const keyValueResponse = Array();\n keyValueBlocks.forEach(keyValue => {\n // We need the KeyValue blocks of EntityType = `KEY`, which has both key and value references.\n if (keyValue.EntityTypes) {\n const entityTypes = Array.from(keyValue.EntityTypes);\n if (entityTypes.indexOf('KEY') !== -1) {\n keyValueResponse.push(constructKeyValue(keyValue, blockMap));\n }\n }\n });\n response.text.keyValues = keyValueResponse;\n }\n return response;\n}\n/**\n * Constructs a table object using data from its children cells.\n * @param {Block} table - Table block that has references (`Relationships`) to its cells\n * @param {[id: string]: Block} blockMap - Maps block Ids to blocks.\n */\nfunction constructTable(table, blockMap) {\n let tableMatrix;\n tableMatrix = [];\n // visit each of the cell associated with the table's relationship.\n for (const tableRelation of table.Relationships ?? []) {\n for (const cellId of tableRelation.Ids ?? []) {\n const cellBlock = blockMap[cellId];\n if (cellBlock.RowIndex && cellBlock.ColumnIndex) {\n const row = cellBlock.RowIndex - 1; // textract starts indexing at 1, so subtract it by 1.\n const col = cellBlock.ColumnIndex - 1; // textract starts indexing at 1, so subtract it by 1.\n // extract data contained inside the cell.\n const content = extractContentsFromBlock(cellBlock, blockMap);\n const cell = {\n text: content.text,\n boundingBox: getBoundingBox(cellBlock.Geometry),\n polygon: getPolygon(cellBlock.Geometry),\n selected: content.selected,\n rowSpan: cellBlock.RowSpan,\n columnSpan: cellBlock.ColumnSpan,\n };\n if (!tableMatrix[row])\n tableMatrix[row] = [];\n tableMatrix[row][col] = cell;\n }\n }\n }\n const rowSize = tableMatrix.length;\n const columnSize = tableMatrix[0].length;\n const boundingBox = getBoundingBox(table.Geometry);\n const polygon = getPolygon(table.Geometry);\n // Note that we leave spanned cells undefined for distinction\n return {\n size: { rows: rowSize, columns: columnSize },\n table: tableMatrix,\n boundingBox,\n polygon,\n };\n}\n/**\n * Constructs a key value object from its children key and value blocks.\n * @param {Block} KeyValue - KeyValue block that has references (`Relationships`) to its children.\n * @param {[id: string]: Block} blockMap - Maps block Ids to blocks.\n */\nfunction constructKeyValue(keyBlock, blockMap) {\n let keyText = '';\n let valueText = '';\n let valueSelected = false;\n for (const keyValueRelation of keyBlock.Relationships ?? []) {\n if (keyValueRelation.Type === 'CHILD') {\n // relation refers to key\n const contents = extractContentsFromBlock(keyBlock, blockMap);\n keyText = contents.text ?? '';\n }\n else if (keyValueRelation.Type === 'VALUE') {\n // relation refers to value\n for (const valueId of keyValueRelation.Ids ?? []) {\n const valueBlock = blockMap[valueId];\n const contents = extractContentsFromBlock(valueBlock, blockMap);\n valueText = contents.text ?? '';\n if (contents.selected != null)\n valueSelected = contents.selected;\n }\n }\n }\n return {\n key: keyText,\n value: { text: valueText, selected: valueSelected },\n polygon: getPolygon(keyBlock.Geometry),\n boundingBox: getBoundingBox(keyBlock.Geometry),\n };\n}\n/**\n * Extracts text and selection from input block's children.\n * @param {Block}} block - Block that we want to extract contents from.\n * @param {[id: string]: Block} blockMap - Maps block Ids to blocks.\n */\nfunction extractContentsFromBlock(block, blockMap) {\n let words = '';\n let isSelected = false;\n if (!block.Relationships) {\n // some block might have no content\n return { text: '', selected: undefined };\n }\n for (const relation of block.Relationships) {\n for (const contentId of relation.Ids ?? []) {\n const contentBlock = blockMap[contentId];\n if (contentBlock.BlockType === 'WORD') {\n words += contentBlock.Text + ' ';\n }\n else if (contentBlock.BlockType === 'SELECTION_ELEMENT') {\n isSelected = contentBlock.SelectionStatus === 'SELECTED' ? true : false;\n }\n }\n }\n words = words.substr(0, words.length - 1); // remove trailing space.\n return { text: words, selected: isSelected };\n}\n"],"names":[],"mappings":";;AACA,SAAS,cAAc,CAAC,QAAQ,EAAE;AAClC,IAAI,OAAO,aAAa,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AAChD,CAAC;AACD,SAAS,UAAU,CAAC,QAAQ,EAAE;AAC9B,IAAI,IAAI,CAAC,QAAQ,EAAE,OAAO;AAC1B,QAAQ,OAAO,SAAS,CAAC;AACzB,IAAI,OAAO,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AAC5D,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,2BAA2B,CAAC,MAAM,EAAE;AACpD;AACA,IAAI,MAAM,QAAQ,GAAG;AACrB,QAAQ,IAAI,EAAE;AACd,YAAY,QAAQ,EAAE,EAAE;AACxB,YAAY,KAAK,EAAE,EAAE;AACrB,YAAY,KAAK,EAAE,EAAE;AACrB,YAAY,aAAa,EAAE,EAAE;AAC7B,SAAS;AACT,KAAK,CAAC;AACN;AACA,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI;AAC5B,QAAQ,QAAQ,KAAK,CAAC,IAAI;AAC1B,YAAY,KAAK,MAAM;AACvB,gBAAgB,IAAI,KAAK,CAAC,YAAY,EAAE;AACxC,oBAAoB,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AACjE,iBAAiB;AACjB,gBAAgB,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;AACjD,oBAAoB,IAAI,EAAE,KAAK,CAAC,YAAY;AAC5C,oBAAoB,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC;AACvD,oBAAoB,WAAW,EAAE,cAAc,CAAC,KA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,CAAC,CAAC,CAAC;AAC9C,IAAI,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AACjD;;;;"}
1
+ {"version":3,"file":"IdentifyTextUtils.mjs","sources":["../../../src/providers/IdentifyTextUtils.ts"],"sourcesContent":["import { makeCamelCase, makeCamelCaseArray } from './Utils';\nfunction getBoundingBox(geometry) {\n return makeCamelCase(geometry?.BoundingBox);\n}\nfunction getPolygon(geometry) {\n if (!geometry?.Polygon)\n return undefined;\n return makeCamelCaseArray(Array.from(geometry.Polygon));\n}\n/**\n * Organizes blocks from Rekognition API to each of the categories and and structures\n * their data accordingly.\n * @param {BlockList} source - Array containing blocks returned from Textract API.\n * @return {IdentifyTextOutput} - Object that categorizes each block and its information.\n */\nexport function categorizeRekognitionBlocks(blocks) {\n // Skeleton IdentifyText API response. We will populate it as we iterate through blocks.\n const response = {\n text: {\n fullText: '',\n words: [],\n lines: [],\n linesDetailed: [],\n },\n };\n // We categorize each block by running a forEach loop through them.\n blocks.forEach(block => {\n switch (block.Type) {\n case 'LINE':\n if (block.DetectedText) {\n response.text.lines.push(block.DetectedText);\n }\n response.text.linesDetailed.push({\n text: block.DetectedText,\n polygon: getPolygon(block.Geometry),\n boundingBox: getBoundingBox(block.Geometry),\n page: undefined, // rekognition doesn't have this info\n });\n break;\n case 'WORD':\n response.text.fullText += block.DetectedText + ' ';\n response.text.words.push({\n text: block.DetectedText,\n polygon: getPolygon(block.Geometry),\n boundingBox: getBoundingBox(block.Geometry),\n });\n break;\n }\n });\n // remove trailing space of fullText\n response.text.fullText = response.text.fullText.substr(0, response.text.fullText.length - 1);\n return response;\n}\n/**\n * Organizes blocks from Textract API to each of the categories and and structures\n * their data accordingly.\n * @param {BlockList} source - Array containing blocks returned from Textract API.\n * @return {IdentifyTextOutput} - Object that categorizes each block and its information.\n */\nexport function categorizeTextractBlocks(blocks) {\n // Skeleton IdentifyText API response. We will populate it as we iterate through blocks.\n const response = {\n text: {\n fullText: '',\n words: [],\n lines: [],\n linesDetailed: [],\n },\n };\n // if blocks is an empty array, ie. textract did not detect anything, return empty response.\n if (blocks.length === 0)\n return response;\n /**\n * We categorize each of the blocks by running a forEach loop through them.\n *\n * For complex structures such as Tables and KeyValue, we need to trasverse through their children. To do so,\n * we will post-process them after the for each loop. We do this by storing table and keyvalues in arrays and\n * mapping other blocks in `blockMap` (id to block) so we can reference them easily later.\n *\n * Note that we do not map `WORD` and `TABLE` in `blockMap` because they will not be referenced by any other\n * block except the Page block.\n */\n const tableBlocks = [];\n const keyValueBlocks = [];\n const blockMap = {};\n blocks.forEach(block => {\n switch (block.BlockType) {\n case 'LINE':\n if (block.Text) {\n response.text.lines.push(block.Text);\n }\n response.text.linesDetailed.push({\n text: block.Text,\n polygon: getPolygon(block.Geometry),\n boundingBox: getBoundingBox(block.Geometry),\n page: block.Page,\n });\n break;\n case 'WORD':\n response.text.fullText += block.Text + ' ';\n response.text.words.push({\n text: block.Text,\n polygon: getPolygon(block.Geometry),\n boundingBox: getBoundingBox(block.Geometry),\n });\n if (block.Id) {\n blockMap[block.Id] = block;\n }\n break;\n case 'SELECTION_ELEMENT': {\n const selectionStatus = block.SelectionStatus === 'SELECTED';\n if (!response.text.selections)\n response.text.selections = [];\n response.text.selections.push({\n selected: selectionStatus,\n polygon: getPolygon(block.Geometry),\n boundingBox: getBoundingBox(block.Geometry),\n });\n if (block.Id) {\n blockMap[block.Id] = block;\n }\n break;\n }\n case 'TABLE':\n tableBlocks.push(block);\n break;\n case 'KEY_VALUE_SET':\n keyValueBlocks.push(block);\n if (block.Id) {\n blockMap[block.Id] = block;\n }\n break;\n default:\n if (block.Id) {\n blockMap[block.Id] = block;\n }\n }\n });\n // remove trailing space in fullText\n response.text.fullText = response.text.fullText.substr(0, response.text.fullText.length - 1);\n // Post-process complex structures if they exist.\n if (tableBlocks.length !== 0) {\n const tableResponse = [];\n tableBlocks.forEach(table => {\n tableResponse.push(constructTable(table, blockMap));\n });\n response.text.tables = tableResponse;\n }\n if (keyValueBlocks.length !== 0) {\n const keyValueResponse = [];\n keyValueBlocks.forEach(keyValue => {\n // We need the KeyValue blocks of EntityType = `KEY`, which has both key and value references.\n if (keyValue.EntityTypes) {\n const entityTypes = Array.from(keyValue.EntityTypes);\n if (entityTypes.indexOf('KEY') !== -1) {\n keyValueResponse.push(constructKeyValue(keyValue, blockMap));\n }\n }\n });\n response.text.keyValues = keyValueResponse;\n }\n return response;\n}\n/**\n * Constructs a table object using data from its children cells.\n * @param {Block} table - Table block that has references (`Relationships`) to its cells\n * @param {[id: string]: Block} blockMap - Maps block Ids to blocks.\n */\nfunction constructTable(table, blockMap) {\n const tableMatrix = [];\n // visit each of the cell associated with the table's relationship.\n for (const tableRelation of table.Relationships ?? []) {\n for (const cellId of tableRelation.Ids ?? []) {\n const cellBlock = blockMap[cellId];\n if (cellBlock.RowIndex && cellBlock.ColumnIndex) {\n const row = cellBlock.RowIndex - 1; // textract starts indexing at 1, so subtract it by 1.\n const col = cellBlock.ColumnIndex - 1; // textract starts indexing at 1, so subtract it by 1.\n // extract data contained inside the cell.\n const content = extractContentsFromBlock(cellBlock, blockMap);\n const cell = {\n text: content.text,\n boundingBox: getBoundingBox(cellBlock.Geometry),\n polygon: getPolygon(cellBlock.Geometry),\n selected: content.selected,\n rowSpan: cellBlock.RowSpan,\n columnSpan: cellBlock.ColumnSpan,\n };\n if (!tableMatrix[row])\n tableMatrix[row] = [];\n tableMatrix[row][col] = cell;\n }\n }\n }\n const rowSize = tableMatrix.length;\n const columnSize = tableMatrix[0].length;\n const boundingBox = getBoundingBox(table.Geometry);\n const polygon = getPolygon(table.Geometry);\n // Note that we leave spanned cells undefined for distinction\n return {\n size: { rows: rowSize, columns: columnSize },\n table: tableMatrix,\n boundingBox,\n polygon,\n };\n}\n/**\n * Constructs a key value object from its children key and value blocks.\n * @param {Block} KeyValue - KeyValue block that has references (`Relationships`) to its children.\n * @param {[id: string]: Block} blockMap - Maps block Ids to blocks.\n */\nfunction constructKeyValue(keyBlock, blockMap) {\n let keyText = '';\n let valueText = '';\n let valueSelected = false;\n for (const keyValueRelation of keyBlock.Relationships ?? []) {\n if (keyValueRelation.Type === 'CHILD') {\n // relation refers to key\n const contents = extractContentsFromBlock(keyBlock, blockMap);\n keyText = contents.text ?? '';\n }\n else if (keyValueRelation.Type === 'VALUE') {\n // relation refers to value\n for (const valueId of keyValueRelation.Ids ?? []) {\n const valueBlock = blockMap[valueId];\n const contents = extractContentsFromBlock(valueBlock, blockMap);\n valueText = contents.text ?? '';\n if (contents.selected != null)\n valueSelected = contents.selected;\n }\n }\n }\n return {\n key: keyText,\n value: { text: valueText, selected: valueSelected },\n polygon: getPolygon(keyBlock.Geometry),\n boundingBox: getBoundingBox(keyBlock.Geometry),\n };\n}\n/**\n * Extracts text and selection from input block's children.\n * @param {Block}} block - Block that we want to extract contents from.\n * @param {[id: string]: Block} blockMap - Maps block Ids to blocks.\n */\nfunction extractContentsFromBlock(block, blockMap) {\n let words = '';\n let isSelected = false;\n if (!block.Relationships) {\n // some block might have no content\n return { text: '', selected: undefined };\n }\n for (const relation of block.Relationships) {\n for (const contentId of relation.Ids ?? []) {\n const contentBlock = blockMap[contentId];\n if (contentBlock.BlockType === 'WORD') {\n words += contentBlock.Text + ' ';\n }\n else if (contentBlock.BlockType === 'SELECTION_ELEMENT') {\n isSelected = contentBlock.SelectionStatus === 'SELECTED';\n }\n }\n }\n words = words.substr(0, words.length - 1); // remove trailing space.\n return { text: words, selected: isSelected };\n}\n"],"names":[],"mappings":";;AACA,SAAS,cAAc,CAAC,QAAQ,EAAE;AAClC,IAAI,OAAO,aAAa,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AAChD,CAAC;AACD,SAAS,UAAU,CAAC,QAAQ,EAAE;AAC9B,IAAI,IAAI,CAAC,QAAQ,EAAE,OAAO;AAC1B,QAAQ,OAAO,SAAS,CAAC;AACzB,IAAI,OAAO,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ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AU,GAAG,KAAK,CAAC;AAC3B,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE;AAC9B;AACA,QAAQ,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AACjD,KAAK;AACL,IAAI,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,aAAa,EAAE;AAChD,QAAQ,KAAK,MAAM,SAAS,IAAI,QAAQ,CAAC,GAAG,IAAI,EAAE,EAAE;AACpD,YAAY,MAAM,YAAY,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;AACrD,YAAY,IAAI,YAAY,CAAC,SAAS,KAAK,MAAM,EAAE;AACnD,gBAAgB,KAAK,IAAI,YAAY,CAAC,IAAI,GAAG,GAAG,CAAC;AACjD,aAAa;AACb,iBAAiB,IAAI,YAAY,CAAC,SAAS,KAAK,mBAAmB,EAAE;AACrE,gBAAgB,UAAU,GAAG,YAAY,CAAC,eAAe,KAAK,UAAU,CAAC;AACzE,aAAa;AACb,SAAS;AACT,KAAK;AACL,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC9C,IAAI,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AACjD;;;;"}
@@ -8,9 +8,9 @@ function makeCamelCase(obj, keys) {
8
8
  if (!obj)
9
9
  return undefined;
10
10
  const newObj = {};
11
- const keysToRename = keys ? keys : Object.keys(obj);
11
+ const keysToRename = keys || Object.keys(obj);
12
12
  keysToRename.forEach(key => {
13
- if (obj.hasOwnProperty(key)) {
13
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
14
14
  // change the key to camelcase.
15
15
  const camelCaseKey = key.charAt(0).toLowerCase() + key.substr(1);
16
16
  Object.assign(newObj, { [camelCaseKey]: obj[key] });
@@ -30,19 +30,19 @@ function makeCamelCaseArray(objArr, keys) {
30
30
  * Converts blob to array buffer
31
31
  */
32
32
  function blobToArrayBuffer(blob) {
33
- return new Promise((res, rej) => {
33
+ return new Promise((resolve, reject) => {
34
34
  const reader = new FileReader();
35
35
  reader.onload = _event => {
36
- res(reader.result);
36
+ resolve(reader.result);
37
37
  };
38
38
  reader.onerror = err => {
39
- rej(err);
39
+ reject(err);
40
40
  };
41
41
  try {
42
42
  reader.readAsArrayBuffer(blob);
43
43
  }
44
44
  catch (err) {
45
- rej(err); // in case user gives invalid type
45
+ reject(err); // in case user gives invalid type
46
46
  }
47
47
  });
48
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.mjs","sources":["../../../src/providers/Utils.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Changes object keys to camel case. If optional parameter `keys` is given, then we extract only the\n * keys specified in `keys`.\n */\nexport function makeCamelCase(obj, keys) {\n if (!obj)\n return undefined;\n const newObj = {};\n const keysToRename = keys ? keys : Object.keys(obj);\n keysToRename.forEach(key => {\n if (obj.hasOwnProperty(key)) {\n // change the key to camelcase.\n const camelCaseKey = key.charAt(0).toLowerCase() + key.substr(1);\n Object.assign(newObj, { [camelCaseKey]: obj[key] });\n }\n });\n return newObj;\n}\n/**\n * Given an array of object, call makeCamelCase(...) on each option.\n */\nexport function makeCamelCaseArray(objArr, keys) {\n if (!objArr)\n return undefined;\n return objArr.map(obj => makeCamelCase(obj, keys));\n}\n/**\n * Converts blob to array buffer\n */\nexport function blobToArrayBuffer(blob) {\n return new Promise((res, rej) => {\n const reader = new FileReader();\n reader.onload = _event => {\n res(reader.result);\n };\n reader.onerror = err => {\n rej(err);\n };\n try {\n reader.readAsArrayBuffer(blob);\n }\n catch (err) {\n rej(err); // in case user gives invalid type\n }\n });\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE;AACzC,IAAI,IAAI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,CAAC,CAAC;AACrB,SAAS,CAAC;AACV,QAAQ,IAAI;AACZ,YAAY,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAC3C,SAAS;AACT,QAAQ,OAAO,GAAG,EAAE;AACpB,YAAY,GAAG,CAAC,GAAG,CAAC,CAAC;AACrB,SAAS;AACT,KAAK,CAAC,CAAC;AACP;;;;"}
1
+ {"version":3,"file":"Utils.mjs","sources":["../../../src/providers/Utils.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Changes object keys to camel case. If optional parameter `keys` is given, then we extract only the\n * keys specified in `keys`.\n */\nexport function makeCamelCase(obj, keys) {\n if (!obj)\n return undefined;\n const newObj = {};\n const keysToRename = keys || Object.keys(obj);\n keysToRename.forEach(key => {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n // change the key to camelcase.\n const camelCaseKey = key.charAt(0).toLowerCase() + key.substr(1);\n Object.assign(newObj, { [camelCaseKey]: obj[key] });\n }\n });\n return newObj;\n}\n/**\n * Given an array of object, call makeCamelCase(...) on each option.\n */\nexport function makeCamelCaseArray(objArr, keys) {\n if (!objArr)\n return undefined;\n return objArr.map(obj => makeCamelCase(obj, keys));\n}\n/**\n * Converts blob to array buffer\n */\nexport function blobToArrayBuffer(blob) {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = _event => {\n resolve(reader.result);\n };\n reader.onerror = err => {\n reject(err);\n };\n try {\n reader.readAsArrayBuffer(blob);\n }\n catch (err) {\n reject(err); // in case user gives invalid type\n }\n });\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE;AACzC,IAAI,IAAI,CAAC,GAAG;AACZ,QAAQ,OAAO,SAAS,CAAC;AACzB,IAAI,MAAM,MAAM,GAAG,EAAE,CAAC;AACtB,IAAI,MAAM,YAAY,GAAG,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I,CAAC,CAAC;AAC3C,SAAS;AACT,QAAQ,OAAO,GAAG,EAAE;AACpB,YAAY,MAAM,CAAC,GAAG,CAAC,CAAC;AACxB,SAAS;AACT,KAAK,CAAC,CAAC;AACP;;;;"}
@@ -40,11 +40,11 @@ export interface Block {
40
40
  /**
41
41
  * <p>A list of child blocks of the current block. For example a LINE object has child blocks for each WORD block that's part of the line of text. There aren't Relationship objects in the list for relationships that don't exist, such as when the current block has no child blocks. The list size can be the following:</p> <ul> <li> <p>0 - The block has no child blocks.</p> </li> <li> <p>1 - The block has child blocks.</p> </li> </ul>
42
42
  */
43
- Relationships?: Array<Relationship> | Iterable<Relationship>;
43
+ Relationships?: Relationship[] | Iterable<Relationship>;
44
44
  /**
45
45
  * <p>The type of entity. The following can be returned:</p> <ul> <li> <p> <i>KEY</i> - An identifier for a field on the document.</p> </li> <li> <p> <i>VALUE</i> - The field text.</p> </li> </ul> <p> <code>EntityTypes</code> isn't returned by <code>DetectDocumentText</code> and <code>GetDocumentTextDetection</code>.</p>
46
46
  */
47
- EntityTypes?: Array<'KEY' | 'VALUE' | string> | Iterable<'KEY' | 'VALUE' | string>;
47
+ EntityTypes?: ('KEY' | 'VALUE' | string)[] | Iterable<'KEY' | 'VALUE' | string>;
48
48
  /**
49
49
  * <p>The selection status of a selectable element such as a radio button or checkbox. </p>
50
50
  */
@@ -30,9 +30,9 @@ export interface TextEntities {
30
30
  text?: string;
31
31
  }
32
32
  export type KeyPhrases = KeyPhrase[];
33
- export type KeyPhrase = {
33
+ export interface KeyPhrase {
34
34
  text?: string;
35
- };
35
+ }
36
36
  export interface TextSyntax {
37
37
  text: string;
38
38
  syntax: string;
@@ -44,17 +44,17 @@ export interface TextSentiment {
44
44
  neutral: number;
45
45
  mixed: number;
46
46
  }
47
- export type DetectParams = {
47
+ export interface DetectParams {
48
48
  Text: string;
49
49
  LanguageCode: string;
50
- };
50
+ }
51
51
  export interface InterpretTextOutput {
52
52
  textInterpretation: {
53
53
  language?: string;
54
- textEntities?: Array<TextEntities>;
54
+ textEntities?: TextEntities[];
55
55
  keyPhrases?: KeyPhrases;
56
56
  sentiment?: TextSentiment;
57
- syntax?: Array<TextSyntax>;
57
+ syntax?: TextSyntax[];
58
58
  };
59
59
  }
60
60
  export interface TranslateTextInput {
@@ -105,11 +105,11 @@ export interface SpeechToTextInput {
105
105
  language?: string;
106
106
  };
107
107
  }
108
- export type TranscribeData = {
108
+ export interface TranscribeData {
109
109
  connection: WebSocket;
110
110
  raw: ConvertBytes;
111
111
  languageCode: string;
112
- };
112
+ }
113
113
  export interface SpeechToTextOutput {
114
114
  transcription: {
115
115
  fullText: string;
@@ -140,8 +140,8 @@ export interface Content {
140
140
  export interface TableCell extends Content {
141
141
  boundingBox?: BoundingBox;
142
142
  polygon?: Polygon;
143
- rowSpan?: Number;
144
- columnSpan?: Number;
143
+ rowSpan?: number;
144
+ columnSpan?: number;
145
145
  }
146
146
  export interface Table {
147
147
  size: {
@@ -180,21 +180,21 @@ export interface IdentifyLabelsInput {
180
180
  };
181
181
  }
182
182
  export interface Point {
183
- x?: Number;
184
- y?: Number;
183
+ x?: number;
184
+ y?: number;
185
185
  }
186
- export type Polygon = Array<Point> | Iterable<Point>;
186
+ export type Polygon = Point[] | Iterable<Point>;
187
187
  export interface BoundingBox {
188
- width?: Number;
189
- height?: Number;
190
- left?: Number;
191
- top?: Number;
188
+ width?: number;
189
+ height?: number;
190
+ left?: number;
191
+ top?: number;
192
192
  }
193
193
  export interface IdentifyLabelsOutput {
194
194
  labels?: {
195
195
  name?: string;
196
196
  boundingBoxes?: (BoundingBox | undefined)[];
197
- metadata?: Object;
197
+ metadata?: object;
198
198
  }[];
199
199
  unsafe?: 'YES' | 'NO' | 'UNKNOWN';
200
200
  }
@@ -225,16 +225,16 @@ export interface FaceAttributes {
225
225
  mouthOpen?: boolean;
226
226
  emotions?: (string | undefined)[];
227
227
  }
228
- export type EntityAgeRange = {
229
- low?: Number;
230
- high?: Number;
231
- };
232
- export type EntityLandmark = {
228
+ export interface EntityAgeRange {
229
+ low?: number;
230
+ high?: number;
231
+ }
232
+ export interface EntityLandmark {
233
233
  type?: string;
234
234
  x?: number;
235
235
  y?: number;
236
- };
237
- export type EntityMetadata = {
236
+ }
237
+ export interface EntityMetadata {
238
238
  id?: string;
239
239
  name?: string;
240
240
  pose?: {
@@ -246,14 +246,14 @@ export type EntityMetadata = {
246
246
  externalImageId?: string;
247
247
  similarity?: number;
248
248
  confidence?: number;
249
- };
250
- export type IdentifyEntity = {
249
+ }
250
+ export interface IdentifyEntity {
251
251
  boundingBox?: BoundingBox;
252
252
  ageRange?: EntityAgeRange;
253
253
  landmarks?: (EntityLandmark | undefined)[];
254
254
  attributes?: FaceAttributes;
255
255
  metadata?: EntityMetadata;
256
- };
256
+ }
257
257
  export interface IdentifyEntitiesOutput {
258
258
  entities: IdentifyEntity[];
259
259
  }
@@ -282,7 +282,7 @@ export interface Geometry {
282
282
  /**
283
283
  * <p>Within the bounding box, a fine-grained polygon around the detected text.</p>
284
284
  */
285
- Polygon?: Array<Point> | Iterable<Point>;
285
+ Polygon?: Point[] | Iterable<Point>;
286
286
  }
287
287
  export interface Relationship {
288
288
  /**
@@ -292,7 +292,7 @@ export interface Relationship {
292
292
  /**
293
293
  * <p>An array of IDs for related blocks. You can get the type of the relationship from the <code>Type</code> element.</p>
294
294
  */
295
- Ids?: Array<string> | Iterable<string>;
295
+ Ids?: string[] | Iterable<string>;
296
296
  }
297
297
  export type FeatureType = 'TABLES' | 'FORMS' | string;
298
298
  export type FeatureTypes = FeatureType[];
@@ -1,6 +1,5 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- /* tslint:disable:max-line-length */
4
3
  function isValidConvertInput(obj) {
5
4
  return (isTranslateTextInput(obj) ||
6
5
  isTextToSpeechInput(obj) ||
@@ -17,55 +16,57 @@ function isValidInterpretInput(obj) {
17
16
  function isIdentifyFromCollection(obj) {
18
17
  const key = 'collection';
19
18
  const keyId = 'collectionId';
20
- return obj && (obj.hasOwnProperty(key) || obj.hasOwnProperty(keyId));
19
+ return (obj &&
20
+ (Object.prototype.hasOwnProperty.call(obj, key) ||
21
+ Object.prototype.hasOwnProperty.call(obj, keyId)));
21
22
  }
22
23
  function isIdentifyCelebrities(obj) {
23
24
  const key = 'celebrityDetection';
24
- return obj && obj.hasOwnProperty(key);
25
+ return obj && Object.prototype.hasOwnProperty.call(obj, key);
25
26
  }
26
27
  function isTranslateTextInput(obj) {
27
28
  const key = 'translateText';
28
- return obj && obj.hasOwnProperty(key);
29
+ return obj && Object.prototype.hasOwnProperty.call(obj, key);
29
30
  }
30
31
  function isTextToSpeechInput(obj) {
31
32
  const key = 'textToSpeech';
32
- return obj && obj.hasOwnProperty(key);
33
+ return obj && Object.prototype.hasOwnProperty.call(obj, key);
33
34
  }
34
35
  function isSpeechToTextInput(obj) {
35
36
  const key = 'transcription';
36
- return obj && obj.hasOwnProperty(key);
37
+ return obj && Object.prototype.hasOwnProperty.call(obj, key);
37
38
  }
38
39
  function isStorageSource(obj) {
39
40
  const key = 'key';
40
- return obj && obj.hasOwnProperty(key);
41
+ return obj && Object.prototype.hasOwnProperty.call(obj, key);
41
42
  }
42
43
  function isFileSource(obj) {
43
44
  const key = 'file';
44
- return obj && obj.hasOwnProperty(key);
45
+ return obj && Object.prototype.hasOwnProperty.call(obj, key);
45
46
  }
46
47
  function isConvertBytesSource(obj) {
47
48
  const key = 'bytes';
48
- return obj && obj.hasOwnProperty(key);
49
+ return obj && Object.prototype.hasOwnProperty.call(obj, key);
49
50
  }
50
51
  function isIdentifyBytesSource(obj) {
51
52
  const key = 'bytes';
52
- return obj && obj.hasOwnProperty(key);
53
+ return obj && Object.prototype.hasOwnProperty.call(obj, key);
53
54
  }
54
55
  function isIdentifyTextInput(obj) {
55
56
  const key = 'text';
56
- return obj && obj.hasOwnProperty(key);
57
+ return obj && Object.prototype.hasOwnProperty.call(obj, key);
57
58
  }
58
59
  function isIdentifyLabelsInput(obj) {
59
60
  const key = 'labels';
60
- return obj && obj.hasOwnProperty(key);
61
+ return obj && Object.prototype.hasOwnProperty.call(obj, key);
61
62
  }
62
63
  function isIdentifyEntitiesInput(obj) {
63
64
  const key = 'entities';
64
- return obj && obj.hasOwnProperty(key);
65
+ return obj && Object.prototype.hasOwnProperty.call(obj, key);
65
66
  }
66
67
  function isInterpretTextInput(obj) {
67
68
  const key = 'text';
68
- return obj && obj.hasOwnProperty(key);
69
+ return obj && Object.prototype.hasOwnProperty.call(obj, key);
69
70
  }
70
71
  function isInterpretTextOthers(text) {
71
72
  return text.source.language !== undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"Predictions.mjs","sources":["../../../src/types/Predictions.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/* tslint:disable:max-line-length */\nexport function isValidConvertInput(obj) {\n return (isTranslateTextInput(obj) ||\n isTextToSpeechInput(obj) ||\n isSpeechToTextInput(obj));\n}\nexport function isValidIdentifyInput(obj) {\n return (isIdentifyTextInput(obj) ||\n isIdentifyLabelsInput(obj) ||\n isIdentifyEntitiesInput(obj));\n}\nexport function isValidInterpretInput(obj) {\n return isInterpretTextInput(obj);\n}\nexport function isIdentifyFromCollection(obj) {\n const key = 'collection';\n const keyId = 'collectionId';\n return obj && (obj.hasOwnProperty(key) || obj.hasOwnProperty(keyId));\n}\nexport function isIdentifyCelebrities(obj) {\n const key = 'celebrityDetection';\n return obj && obj.hasOwnProperty(key);\n}\nexport function isTranslateTextInput(obj) {\n const key = 'translateText';\n return obj && obj.hasOwnProperty(key);\n}\nexport function isTextToSpeechInput(obj) {\n const key = 'textToSpeech';\n return obj && obj.hasOwnProperty(key);\n}\nexport function isSpeechToTextInput(obj) {\n const key = 'transcription';\n return obj && obj.hasOwnProperty(key);\n}\nexport function isStorageSource(obj) {\n const key = 'key';\n return obj && obj.hasOwnProperty(key);\n}\nexport function isFileSource(obj) {\n const key = 'file';\n return obj && obj.hasOwnProperty(key);\n}\nexport function isConvertBytesSource(obj) {\n const key = 'bytes';\n return obj && obj.hasOwnProperty(key);\n}\nexport function isIdentifyBytesSource(obj) {\n const key = 'bytes';\n return obj && obj.hasOwnProperty(key);\n}\nexport function isIdentifyTextInput(obj) {\n const key = 'text';\n return obj && obj.hasOwnProperty(key);\n}\nexport function isIdentifyLabelsInput(obj) {\n const key = 'labels';\n return obj && obj.hasOwnProperty(key);\n}\nexport function isIdentifyEntitiesInput(obj) {\n const key = 'entities';\n return obj && obj.hasOwnProperty(key);\n}\nexport function isInterpretTextInput(obj) {\n const key = 'text';\n return obj && obj.hasOwnProperty(key);\n}\nexport function isInterpretTextOthers(text) {\n return text.source.language !== undefined;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,GAAG,EAAE;AACzC,IAAI,QAAQ,oBAAoB,CAAC,GAAG,CAAC;AACrC,QAAQ,mBAAmB,CAAC,GAAG,CAAC;AAChC,QAAQ,mBAAmB,CAAC,GAAG,CAAC,EAAE;AAClC,CAAC;AACM,SAAS,oBAAoB,CAAC,GAAG,EAAE;AAC1C,IAAI,QAAQ,mBAAmB,CAAC,GAAG,CAAC;AACpC,QAAQ,qBAAqB,CAAC,GAAG,CAAC;AAClC,QAAQ,uBAAuB,CAAC,GAAG,CAAC,EAAE;AACtC,CAAC;AACM,SAAS,qBAAqB,CAAC,GAAG,EAAE;AAC3C,IAAI,OAAO,oBAAoB,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC;AACM,SAAS,wBAAwB,CAAC,GAAG,EAAE;AAC9C,IAAI,MAAM,GAAG,GAAG,YAAY,CAAC;AAC7B,IAAI,MAAM,KAAK,GAAG,cAAc,CAAC;AACjC,IAAI,OAAO,GAAG,KAAK,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;AACzE,CAAC;AACM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;AACxB,IAAI,OAAO,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;AAC1C,CAAC;AACM,SAAS,mBAAmB,CAAC,GAAG,EAAE;AACzC,IAAI,MAAM,GAAG,GAAG,MAAM,CAAC;AACvB,IAAI,OAAO,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;AAC1C,CAAC;AACM,SAAS,qBAAqB,CAAC,GAAG,EAAE;AAC3C,IAAI,MAAM,GAAG,GAAG,QAAQ,CAAC;AACzB,IAAI,OAAO,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;AAC1C,CAAC;AACM,SAAS,uBAAuB,CAAC,GAAG,EAAE;AAC7C,IAAI,MAAM,GAAG,GAAG,UAAU,CAAC;AAC3B,IAAI,OAAO,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;AAC1C,CAAC;AACM,SAAS,oBAAoB,CAAC,GAAG,EAAE;AAC1C,IAAI,MAAM,GAAG,GAAG,MAAM,CAAC;AACvB,IAAI,OAAO,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;AAC1C,CAAC;AACM,SAAS,qBAAqB,CAAC,IAAI,EAAE;AAC5C,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,CAAC;AAC9C;;;;"}
1
+ {"version":3,"file":"Predictions.mjs","sources":["../../../src/types/Predictions.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport function isValidConvertInput(obj) {\n return (isTranslateTextInput(obj) ||\n isTextToSpeechInput(obj) ||\n isSpeechToTextInput(obj));\n}\nexport function isValidIdentifyInput(obj) {\n return (isIdentifyTextInput(obj) ||\n isIdentifyLabelsInput(obj) ||\n isIdentifyEntitiesInput(obj));\n}\nexport function isValidInterpretInput(obj) {\n return isInterpretTextInput(obj);\n}\nexport function isIdentifyFromCollection(obj) {\n const key = 'collection';\n const keyId = 'collectionId';\n return (obj &&\n (Object.prototype.hasOwnProperty.call(obj, key) ||\n Object.prototype.hasOwnProperty.call(obj, keyId)));\n}\nexport function isIdentifyCelebrities(obj) {\n const key = 'celebrityDetection';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nexport function isTranslateTextInput(obj) {\n const key = 'translateText';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nexport function isTextToSpeechInput(obj) {\n const key = 'textToSpeech';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nexport function isSpeechToTextInput(obj) {\n const key = 'transcription';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nexport function isStorageSource(obj) {\n const key = 'key';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nexport function isFileSource(obj) {\n const key = 'file';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nexport function isConvertBytesSource(obj) {\n const key = 'bytes';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nexport function isIdentifyBytesSource(obj) {\n const key = 'bytes';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nexport function isIdentifyTextInput(obj) {\n const key = 'text';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nexport function isIdentifyLabelsInput(obj) {\n const key = 'labels';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nexport function isIdentifyEntitiesInput(obj) {\n const key = 'entities';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nexport function isInterpretTextInput(obj) {\n const key = 'text';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nexport function isInterpretTextOthers(text) {\n return text.source.language !== undefined;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACO,SAAS,mBAAmB,CAAC,GAAG,EAAE;AACzC,IAAI,QAAQ,oBAAoB,CAAC,GAAG,CAAC;AACrC,QAAQ,mBAAmB,CAAC,GAAG,CAAC;A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CAAC;AACjE,CAAC;AACM,SAAS,qBAAqB,CAAC,GAAG,EAAE;AAC3C,IAAI,MAAM,GAAG,GAAG,QAAQ,CAAC;AACzB,IAAI,OAAO,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACjE,CAAC;AACM,SAAS,uBAAuB,CAAC,GAAG,EAAE;AAC7C,IAAI,MAAM,GAAG,GAAG,UAAU,CAAC;AAC3B,IAAI,OAAO,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACjE,CAAC;AACM,SAAS,oBAAoB,CAAC,GAAG,EAAE;AAC1C,IAAI,MAAM,GAAG,GAAG,MAAM,CAAC;AACvB,IAAI,OAAO,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACjE,CAAC;AACM,SAAS,qBAAqB,CAAC,IAAI,EAAE;AAC5C,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,CAAC;AAC9C;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/predictions",
3
- "version": "6.0.22",
3
+ "version": "6.0.23",
4
4
  "description": "Machine learning category of aws-amplify",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -21,7 +21,8 @@
21
21
  "clean": "npm run clean:size && rimraf dist lib lib-esm",
22
22
  "clean:size": "rimraf dual-publish-tmp tmp*",
23
23
  "format": "echo \"Not implemented\"",
24
- "lint": "tslint 'src/**/*.ts' && npm run ts-coverage",
24
+ "lint": "eslint '**/*.{ts,tsx}' && npm run ts-coverage",
25
+ "lint:fix": "eslint '**/*.{ts,tsx}' --fix",
25
26
  "generate-docs-local": "typedoc --out docs src",
26
27
  "generate-docs-root": "typedoc --out ../../docs src",
27
28
  "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 87.84"
@@ -42,7 +43,7 @@
42
43
  "src"
43
44
  ],
44
45
  "dependencies": {
45
- "@aws-amplify/storage": "6.0.22",
46
+ "@aws-amplify/storage": "6.0.23",
46
47
  "@aws-sdk/client-comprehend": "3.398.0",
47
48
  "@aws-sdk/client-polly": "3.398.0",
48
49
  "@aws-sdk/client-rekognition": "3.398.0",
@@ -58,7 +59,7 @@
58
59
  "@aws-amplify/core": "^6.0.0"
59
60
  },
60
61
  "devDependencies": {
61
- "@aws-amplify/core": "6.0.22",
62
+ "@aws-amplify/core": "6.0.23",
62
63
  "typescript": "5.0.2"
63
64
  },
64
65
  "size-limit": [
@@ -69,5 +70,5 @@
69
70
  "limit": "69.8 kB"
70
71
  }
71
72
  ],
72
- "gitHead": "080f8c11e9eb89cdcd29d78a2b4fe07c8c5b5404"
73
+ "gitHead": "6c46368559f4c3229024d10c18aabb34c58efe68"
73
74
  }
@@ -1,6 +1,6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { ConsoleLogger } from '@aws-amplify/core';
3
+
4
4
  import {
5
5
  AmazonAIConvertPredictionsProvider,
6
6
  AmazonAIIdentifyPredictionsProvider,
@@ -23,8 +23,6 @@ import {
23
23
  TranslateTextOutput,
24
24
  } from './types';
25
25
 
26
- const logger = new ConsoleLogger('Predictions');
27
-
28
26
  export class PredictionsClass {
29
27
  private convertProvider = new AmazonAIConvertPredictionsProvider();
30
28
  private identifyProvider = new AmazonAIIdentifyPredictionsProvider();
@@ -52,6 +50,7 @@ export class PredictionsClass {
52
50
  public identify(
53
51
  input: IdentifyEntitiesInput,
54
52
  ): Promise<IdentifyEntitiesOutput>;
53
+
55
54
  public identify(
56
55
  input: IdentifyTextInput | IdentifyLabelsInput | IdentifyEntitiesInput,
57
56
  ): Promise<
@@ -1,5 +1,7 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
+ import { Buffer } from 'buffer';
4
+
3
5
  import { Amplify, ConsoleLogger, fetchAuthSession } from '@aws-amplify/core';
4
6
  import {
5
7
  AWSCredentials,
@@ -18,7 +20,7 @@ import {
18
20
  MessageHeaderValue,
19
21
  } from '@smithy/eventstream-codec';
20
22
  import { fromUtf8, toUtf8 } from '@smithy/util-utf8';
21
- import { Buffer } from 'buffer';
23
+
22
24
  import { PredictionsValidationErrorCode } from '../errors/types/validation';
23
25
  import { assertValidationError } from '../errors/utils/assertValidationError';
24
26
  import {
@@ -59,12 +61,15 @@ export class AmazonAIConvertPredictionsProvider {
59
61
 
60
62
  if (isTranslateTextInput(input)) {
61
63
  logger.debug('translateText');
64
+
62
65
  return this.translateText(input);
63
66
  } else if (isTextToSpeechInput(input)) {
64
67
  logger.debug('textToSpeech');
68
+
65
69
  return this.convertTextToSpeech(input);
66
70
  } else {
67
71
  logger.debug('textToSpeech');
72
+
68
73
  return this.convertSpeechToText(input);
69
74
  }
70
75
  }
@@ -116,6 +121,7 @@ export class AmazonAIConvertPredictionsProvider {
116
121
  Text: input.translateText?.source?.text,
117
122
  });
118
123
  const data = await this.translateClient.send(translateTextCommand);
124
+
119
125
  return {
120
126
  text: data.TranslatedText,
121
127
  language: data.TargetLanguageCode,
@@ -161,7 +167,6 @@ export class AmazonAIConvertPredictionsProvider {
161
167
  VoiceId: voiceId,
162
168
  TextType: 'text',
163
169
  SampleRate: '24000',
164
- // tslint:disable-next-line: align
165
170
  });
166
171
  const data = await this.pollyClient.send(synthesizeSpeechCommand);
167
172
  const response = new Response(data.AudioStream as ReadableStream);
@@ -170,6 +175,7 @@ export class AmazonAIConvertPredictionsProvider {
170
175
  type: data.ContentType,
171
176
  });
172
177
  const url = URL.createObjectURL(blob);
178
+
173
179
  return {
174
180
  speech: { url },
175
181
  audioStream: arrayBuffer,
@@ -218,6 +224,7 @@ export class AmazonAIConvertPredictionsProvider {
218
224
  raw: source.bytes,
219
225
  languageCode: language,
220
226
  });
227
+
221
228
  return {
222
229
  transcription: {
223
230
  fullText,
@@ -261,6 +268,7 @@ export class AmazonAIConvertPredictionsProvider {
261
268
  }
262
269
  }
263
270
  }
271
+
264
272
  return decodedMessage;
265
273
  }
266
274
 
@@ -269,7 +277,7 @@ export class AmazonAIConvertPredictionsProvider {
269
277
  raw,
270
278
  languageCode,
271
279
  }: TranscribeData): Promise<string> {
272
- return new Promise((res, rej) => {
280
+ return new Promise((resolve, reject) => {
273
281
  let fullText = '';
274
282
  connection.onmessage = message => {
275
283
  try {
@@ -282,18 +290,19 @@ export class AmazonAIConvertPredictionsProvider {
282
290
  }
283
291
  } catch (err: unknown) {
284
292
  logger.debug(err);
285
- rej(err);
293
+ reject(err);
286
294
  }
287
295
  };
288
296
 
289
297
  connection.onerror = errorEvent => {
290
298
  logger.debug({ errorEvent });
291
- rej('failed to transcribe, network error');
299
+ reject(new Error('failed to transcribe, network error'));
292
300
  };
293
301
 
294
302
  connection.onclose = closeEvent => {
295
303
  logger.debug({ closeEvent });
296
- return res(fullText.trim());
304
+
305
+ resolve(fullText.trim());
297
306
  };
298
307
 
299
308
  logger.debug({ raw });
@@ -366,6 +375,7 @@ export class AmazonAIConvertPredictionsProvider {
366
375
  const s = Math.max(-1, Math.min(1, input[i]));
367
376
  view.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7fff, true);
368
377
  }
378
+
369
379
  return buffer;
370
380
  }
371
381
 
@@ -393,8 +403,8 @@ export class AmazonAIConvertPredictionsProvider {
393
403
  let offsetBuffer = 0;
394
404
  while (offsetResult < result.length) {
395
405
  const nextOffsetBuffer = Math.round((offsetResult + 1) * sampleRateRatio);
396
- let accum = 0,
397
- count = 0;
406
+ let accum = 0;
407
+ let count = 0;
398
408
  for (
399
409
  let i = offsetBuffer;
400
410
  i < nextOffsetBuffer && i < buffer.length;
@@ -420,7 +430,7 @@ export class AmazonAIConvertPredictionsProvider {
420
430
  region: string;
421
431
  languageCode: string;
422
432
  }): Promise<WebSocket> {
423
- return new Promise(async (res, rej) => {
433
+ return new Promise((resolve, _reject) => {
424
434
  const signedUrl = this.generateTranscribeUrl({
425
435
  credentials,
426
436
  region,
@@ -433,7 +443,7 @@ export class AmazonAIConvertPredictionsProvider {
433
443
  connection.binaryType = 'arraybuffer';
434
444
  connection.onopen = () => {
435
445
  logger.debug('connected');
436
- res(connection);
446
+ resolve(connection);
437
447
  };
438
448
  });
439
449
  }