@aws-amplify/predictions 6.1.55 → 6.1.56-local-stack.00864ae.0
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.
- package/dist/cjs/errors/types/validation.js +1 -1
- package/dist/cjs/errors/types/validation.js.map +1 -1
- package/dist/cjs/errors/utils/assertValidationError.js +1 -2
- package/dist/cjs/errors/utils/assertValidationError.js.map +1 -1
- package/dist/cjs/providers/IdentifyTextUtils.js +2 -3
- package/dist/cjs/providers/IdentifyTextUtils.js.map +1 -1
- package/dist/cjs/providers/Utils.js +3 -4
- package/dist/cjs/providers/Utils.js.map +1 -1
- package/dist/cjs/types/Predictions.js +17 -18
- package/dist/cjs/types/Predictions.js.map +1 -1
- package/dist/esm/types/Predictions.d.ts +3 -4
- package/package.json +71 -72
|
@@ -16,7 +16,7 @@ var PredictionsValidationErrorCode;
|
|
|
16
16
|
PredictionsValidationErrorCode["NoSourceLanguage"] = "NoSourceLanguage";
|
|
17
17
|
PredictionsValidationErrorCode["NoTargetLanguage"] = "NoTargetLanguage";
|
|
18
18
|
PredictionsValidationErrorCode["NoVoiceId"] = "NoVoiceId";
|
|
19
|
-
})(PredictionsValidationErrorCode
|
|
19
|
+
})(PredictionsValidationErrorCode || (exports.PredictionsValidationErrorCode = PredictionsValidationErrorCode = {}));
|
|
20
20
|
exports.validationErrorMap = {
|
|
21
21
|
[PredictionsValidationErrorCode.CelebrityDetectionNotEnabled]: {
|
|
22
22
|
message: 'Celebrity Detection must be enabled.',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sources":["../../../../src/errors/types/validation.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.validationErrorMap = exports.PredictionsValidationErrorCode = void 0;\nvar PredictionsValidationErrorCode;\n(function (PredictionsValidationErrorCode) {\n PredictionsValidationErrorCode[\"CelebrityDetectionNotEnabled\"] = \"CelebrityDetectionNotEnabled\";\n PredictionsValidationErrorCode[\"InvalidInput\"] = \"InvalidInput\";\n PredictionsValidationErrorCode[\"InvalidSource\"] = \"InvalidSource\";\n PredictionsValidationErrorCode[\"NoCredentials\"] = \"NoCredentials\";\n PredictionsValidationErrorCode[\"NoLanguage\"] = \"NoLanguage\";\n PredictionsValidationErrorCode[\"NoRegion\"] = \"NoRegion\";\n PredictionsValidationErrorCode[\"NoSource\"] = \"NoSource\";\n PredictionsValidationErrorCode[\"NoSourceLanguage\"] = \"NoSourceLanguage\";\n PredictionsValidationErrorCode[\"NoTargetLanguage\"] = \"NoTargetLanguage\";\n PredictionsValidationErrorCode[\"NoVoiceId\"] = \"NoVoiceId\";\n})(PredictionsValidationErrorCode
|
|
1
|
+
{"version":3,"file":"validation.js","sources":["../../../../src/errors/types/validation.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.validationErrorMap = exports.PredictionsValidationErrorCode = void 0;\nvar PredictionsValidationErrorCode;\n(function (PredictionsValidationErrorCode) {\n PredictionsValidationErrorCode[\"CelebrityDetectionNotEnabled\"] = \"CelebrityDetectionNotEnabled\";\n PredictionsValidationErrorCode[\"InvalidInput\"] = \"InvalidInput\";\n PredictionsValidationErrorCode[\"InvalidSource\"] = \"InvalidSource\";\n PredictionsValidationErrorCode[\"NoCredentials\"] = \"NoCredentials\";\n PredictionsValidationErrorCode[\"NoLanguage\"] = \"NoLanguage\";\n PredictionsValidationErrorCode[\"NoRegion\"] = \"NoRegion\";\n PredictionsValidationErrorCode[\"NoSource\"] = \"NoSource\";\n PredictionsValidationErrorCode[\"NoSourceLanguage\"] = \"NoSourceLanguage\";\n PredictionsValidationErrorCode[\"NoTargetLanguage\"] = \"NoTargetLanguage\";\n PredictionsValidationErrorCode[\"NoVoiceId\"] = \"NoVoiceId\";\n})(PredictionsValidationErrorCode || (exports.PredictionsValidationErrorCode = PredictionsValidationErrorCode = {}));\nexports.validationErrorMap = {\n [PredictionsValidationErrorCode.CelebrityDetectionNotEnabled]: {\n message: 'Celebrity Detection must be enabled.',\n },\n [PredictionsValidationErrorCode.InvalidInput]: {\n message: 'Input does not conform to expected type.',\n },\n [PredictionsValidationErrorCode.InvalidSource]: {\n message: 'Source type not supported.',\n },\n [PredictionsValidationErrorCode.NoCredentials]: {\n message: 'Credentials should not be empty.',\n },\n [PredictionsValidationErrorCode.NoLanguage]: {\n message: 'Missing language.',\n },\n [PredictionsValidationErrorCode.NoRegion]: {\n message: 'Missing region.',\n },\n [PredictionsValidationErrorCode.NoSource]: {\n message: 'Missing source.',\n },\n [PredictionsValidationErrorCode.NoSourceLanguage]: {\n message: 'Missing source language for translation.',\n },\n [PredictionsValidationErrorCode.NoTargetLanguage]: {\n message: 'Missing target language for translation.',\n },\n [PredictionsValidationErrorCode.NoVoiceId]: {\n message: 'Missing voice id.',\n },\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,8BAA8B,GAAG,MAAM;AAC5E,IAAI,8BAA8B;AAClC,CAAC,UAAU,8BAA8B,EAAE;AAC3C,IAAI,8BAA8B,CAAC,8BAA8B,CAAC,GAAG,8BAA8B;AACnG,IAAI,8BAA8B,CAAC,cAAc,CAAC,GAAG,cAAc;AACnE,IAAI,8BAA8B,CAAC,eAAe,CAAC,GAAG,eAAe;AACrE,IAAI,8BAA8B,CAAC,eAAe,CAAC,GAAG,eAAe;AACrE,IAAI,8BAA8B,CAAC,YAAY,CAAC,GAAG,YAAY;AAC/D,IAAI,8BAA8B,CAAC,UAAU,CAAC,GAAG,UAAU;AAC3D,IAAI,8BAA8B,CAAC,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C;;"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.assertValidationError =
|
|
6
|
+
exports.assertValidationError = assertValidationError;
|
|
7
7
|
const PredictionsError_1 = require("../PredictionsError");
|
|
8
8
|
const validation_1 = require("../types/validation");
|
|
9
9
|
function assertValidationError(assertion, name) {
|
|
@@ -12,5 +12,4 @@ function assertValidationError(assertion, name) {
|
|
|
12
12
|
throw new PredictionsError_1.PredictionsError({ name, message, recoverySuggestion });
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
exports.assertValidationError = assertValidationError;
|
|
16
15
|
//# sourceMappingURL=assertValidationError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertValidationError.js","sources":["../../../../src/errors/utils/assertValidationError.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.assertValidationError =
|
|
1
|
+
{"version":3,"file":"assertValidationError.js","sources":["../../../../src/errors/utils/assertValidationError.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.assertValidationError = assertValidationError;\nconst PredictionsError_1 = require(\"../PredictionsError\");\nconst validation_1 = require(\"../types/validation\");\nfunction assertValidationError(assertion, name) {\n if (!assertion) {\n const { message, recoverySuggestion } = validation_1.validationErrorMap[name];\n throw new PredictionsError_1.PredictionsError({ name, message, recoverySuggestion });\n }\n}\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,qBAAqB,GAAG,qBAAqB;AACrD,MAAM,kBAAkB,GAAG,OAAO,CAAC,qBAAqB,CAAC;AACzD,MAAM,YAAY,GAAG,OAAO,CAAC,qBAAqB,CAAC;AACnD,SAAS,qBAAqB,CAAC,SAAS,EAAE,IAAI,EAAE;AAChD,IAAI,IAAI,CAAC,SAAS,EAAE;AACpB,QAAQ,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAG,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC;AACrF,QAAQ,MAAM,IAAI,kBAAkB,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAC5F;AACA;;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.categorizeRekognitionBlocks = categorizeRekognitionBlocks;
|
|
5
|
+
exports.categorizeTextractBlocks = categorizeTextractBlocks;
|
|
5
6
|
const Utils_1 = require("./Utils");
|
|
6
7
|
function getBoundingBox(geometry) {
|
|
7
8
|
return (0, Utils_1.makeCamelCase)(geometry?.BoundingBox);
|
|
@@ -55,7 +56,6 @@ function categorizeRekognitionBlocks(blocks) {
|
|
|
55
56
|
response.text.fullText = response.text.fullText.substr(0, response.text.fullText.length - 1);
|
|
56
57
|
return response;
|
|
57
58
|
}
|
|
58
|
-
exports.categorizeRekognitionBlocks = categorizeRekognitionBlocks;
|
|
59
59
|
/**
|
|
60
60
|
* Organizes blocks from Textract API to each of the categories and and structures
|
|
61
61
|
* their data accordingly.
|
|
@@ -166,7 +166,6 @@ function categorizeTextractBlocks(blocks) {
|
|
|
166
166
|
}
|
|
167
167
|
return response;
|
|
168
168
|
}
|
|
169
|
-
exports.categorizeTextractBlocks = categorizeTextractBlocks;
|
|
170
169
|
/**
|
|
171
170
|
* Constructs a table object using data from its children cells.
|
|
172
171
|
* @param {Block} table - Table block that has references (`Relationships`) to its cells
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentifyTextUtils.js","sources":["../../../src/providers/IdentifyTextUtils.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.categorizeTextractBlocks = exports.categorizeRekognitionBlocks = void 0;\nconst Utils_1 = require(\"./Utils\");\nfunction getBoundingBox(geometry) {\n return (0, Utils_1.makeCamelCase)(geometry?.BoundingBox);\n}\nfunction getPolygon(geometry) {\n if (!geometry?.Polygon)\n return undefined;\n return (0, Utils_1.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 */\nfunction 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}\nexports.categorizeRekognitionBlocks = categorizeRekognitionBlocks;\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 */\nfunction 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}\nexports.categorizeTextractBlocks = categorizeTextractBlocks;\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,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,wBAAwB,GAAG,OAAO,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,EAAE,SAAS,EAAE;AAChD;AACA,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;AACpD,YAAY,IAAI,YAAY,CAAC,SAAS,KAAK,MAAM,EAAE;AACnD,gBAAgB,KAAK,IAAI,YAAY,CAAC,IAAI,GAAG,GAAG;AAChD;AACA,iBAAiB,IAAI,YAAY,CAAC,SAAS,KAAK,mBAAmB,EAAE;AACrE,gBAAgB,UAAU,GAAG,YAAY,CAAC,eAAe,KAAK,UAAU;AACxE;AACA;AACA;AACA,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;AAChD;;"}
|
|
1
|
+
{"version":3,"file":"IdentifyTextUtils.js","sources":["../../../src/providers/IdentifyTextUtils.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.categorizeRekognitionBlocks = categorizeRekognitionBlocks;\nexports.categorizeTextractBlocks = categorizeTextractBlocks;\nconst Utils_1 = require(\"./Utils\");\nfunction getBoundingBox(geometry) {\n return (0, Utils_1.makeCamelCase)(geometry?.BoundingBox);\n}\nfunction getPolygon(geometry) {\n if (!geometry?.Polygon)\n return undefined;\n return (0, Utils_1.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 */\nfunction 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 */\nfunction 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,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,2BAA2B,GAAG,2BAA2B;AACjE,OAAO,CAAC,wBAAwB,GAAG,wBAAwB;AAC3D,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;AAClC,SAAS,cAAc,CAAC,QAAQ,EAAE;AAClC,IAAI,OAAO,IAAI,OAAO,CAAC,aAAa,EAAE,QAAQ,EAAE,WAAW,CAAC;AAC5D;AACA,SAAS,UAAU,CAAC,QAAQ,EAAE;AAC9B,IAAI,IAAI,CAAC,QAAQ,EAAE,OAAO;AAC1B,QAAQ,OAAO,SAAS;AACxB,IAAI,OAAO,IAAI,OAAO,CAAC,kBAAkB,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,2BAA2B,CAAC,MAAM,EAAE;AAC7C;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;AACL;AACA,IA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makeCamelCase = makeCamelCase;
|
|
5
|
+
exports.makeCamelCaseArray = makeCamelCaseArray;
|
|
6
|
+
exports.blobToArrayBuffer = blobToArrayBuffer;
|
|
5
7
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
7
9
|
/**
|
|
@@ -22,7 +24,6 @@ function makeCamelCase(obj, keys) {
|
|
|
22
24
|
});
|
|
23
25
|
return newObj;
|
|
24
26
|
}
|
|
25
|
-
exports.makeCamelCase = makeCamelCase;
|
|
26
27
|
/**
|
|
27
28
|
* Given an array of object, call makeCamelCase(...) on each option.
|
|
28
29
|
*/
|
|
@@ -31,7 +32,6 @@ function makeCamelCaseArray(objArr, keys) {
|
|
|
31
32
|
return undefined;
|
|
32
33
|
return objArr.map(obj => makeCamelCase(obj, keys));
|
|
33
34
|
}
|
|
34
|
-
exports.makeCamelCaseArray = makeCamelCaseArray;
|
|
35
35
|
/**
|
|
36
36
|
* Converts blob to array buffer
|
|
37
37
|
*/
|
|
@@ -52,5 +52,4 @@ function blobToArrayBuffer(blob) {
|
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
-
exports.blobToArrayBuffer = blobToArrayBuffer;
|
|
56
55
|
//# sourceMappingURL=Utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.js","sources":["../../../src/providers/Utils.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.
|
|
1
|
+
{"version":3,"file":"Utils.js","sources":["../../../src/providers/Utils.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.makeCamelCase = makeCamelCase;\nexports.makeCamelCaseArray = makeCamelCaseArray;\nexports.blobToArrayBuffer = blobToArrayBuffer;\n// 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 */\nfunction 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 */\nfunction 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 */\nfunction 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":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,aAAa,GAAG,aAAa;AACrC,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;AAC/C,OAAO,CAAC,iBAAiB,GAAG,iBAAiB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE;AAClC,IAAI,IAAI,CAAC,GAAG;AACZ,QAAQ,OAAO,SAAS;AACxB,IAAI,MAAM,MAAM,GAAG,EAAE;AACrB,IAAI,MAAM,YAAY,GAAG,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AACjD,IAAI,YAAY,CAAC,OAAO,CAAC,GAAG,IAAI;AAChC,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE;AAC5D;AACA,YAAY,MAAM,YAAY,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAC5E,YAAY,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;AAC/D;AACA,KAAK,CAAC;AACN,IAAI,OAAO,MAAM;AACjB;AACA;AACA;AACA;AACA,SAAS,kBAAkB,CAAC,MAAM,EAAE,IAAI,EAAE;AAC1C,IAAI,IAAI,CAAC,MAAM;AACf,QAAQ,OAAO,SAAS;AACxB,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACtD;AACA;AACA;AACA;AACA,SAAS,iBAAiB,CAAC,IAAI,EAAE;AACjC,IAAI,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAC5C,QAAQ,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE;AACvC,QAAQ,MAAM,CAAC,MAAM,GAAG,MAAM,IAAI;AAClC,YAAY,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;AAClC,SAAS;AACT,QAAQ,MAAM,CAAC,OAAO,GAAG,GAAG,IAAI;AAChC,YAAY,MAAM,CAAC,GAAG,CAAC;AACvB,SAAS;AACT,QAAQ,IAAI;AACZ,YAAY,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC;AAC1C;AACA,QAAQ,OAAO,GAAG,EAAE;AACpB,YAAY,MAAM,CAAC,GAAG,CAAC,CAAC;AACxB;AACA,KAAK,CAAC;AACN;;"}
|
|
@@ -3,23 +3,36 @@
|
|
|
3
3
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.isValidConvertInput = isValidConvertInput;
|
|
7
|
+
exports.isValidIdentifyInput = isValidIdentifyInput;
|
|
8
|
+
exports.isValidInterpretInput = isValidInterpretInput;
|
|
9
|
+
exports.isIdentifyFromCollection = isIdentifyFromCollection;
|
|
10
|
+
exports.isIdentifyCelebrities = isIdentifyCelebrities;
|
|
11
|
+
exports.isTranslateTextInput = isTranslateTextInput;
|
|
12
|
+
exports.isTextToSpeechInput = isTextToSpeechInput;
|
|
13
|
+
exports.isSpeechToTextInput = isSpeechToTextInput;
|
|
14
|
+
exports.isStorageSource = isStorageSource;
|
|
15
|
+
exports.isFileSource = isFileSource;
|
|
16
|
+
exports.isConvertBytesSource = isConvertBytesSource;
|
|
17
|
+
exports.isIdentifyBytesSource = isIdentifyBytesSource;
|
|
18
|
+
exports.isIdentifyTextInput = isIdentifyTextInput;
|
|
19
|
+
exports.isIdentifyLabelsInput = isIdentifyLabelsInput;
|
|
20
|
+
exports.isIdentifyEntitiesInput = isIdentifyEntitiesInput;
|
|
21
|
+
exports.isInterpretTextInput = isInterpretTextInput;
|
|
22
|
+
exports.isInterpretTextOthers = isInterpretTextOthers;
|
|
7
23
|
function isValidConvertInput(obj) {
|
|
8
24
|
return (isTranslateTextInput(obj) ||
|
|
9
25
|
isTextToSpeechInput(obj) ||
|
|
10
26
|
isSpeechToTextInput(obj));
|
|
11
27
|
}
|
|
12
|
-
exports.isValidConvertInput = isValidConvertInput;
|
|
13
28
|
function isValidIdentifyInput(obj) {
|
|
14
29
|
return (isIdentifyTextInput(obj) ||
|
|
15
30
|
isIdentifyLabelsInput(obj) ||
|
|
16
31
|
isIdentifyEntitiesInput(obj));
|
|
17
32
|
}
|
|
18
|
-
exports.isValidIdentifyInput = isValidIdentifyInput;
|
|
19
33
|
function isValidInterpretInput(obj) {
|
|
20
34
|
return isInterpretTextInput(obj);
|
|
21
35
|
}
|
|
22
|
-
exports.isValidInterpretInput = isValidInterpretInput;
|
|
23
36
|
function isIdentifyFromCollection(obj) {
|
|
24
37
|
const key = 'collection';
|
|
25
38
|
const keyId = 'collectionId';
|
|
@@ -27,69 +40,55 @@ function isIdentifyFromCollection(obj) {
|
|
|
27
40
|
(Object.prototype.hasOwnProperty.call(obj, key) ||
|
|
28
41
|
Object.prototype.hasOwnProperty.call(obj, keyId)));
|
|
29
42
|
}
|
|
30
|
-
exports.isIdentifyFromCollection = isIdentifyFromCollection;
|
|
31
43
|
function isIdentifyCelebrities(obj) {
|
|
32
44
|
const key = 'celebrityDetection';
|
|
33
45
|
return obj && Object.prototype.hasOwnProperty.call(obj, key);
|
|
34
46
|
}
|
|
35
|
-
exports.isIdentifyCelebrities = isIdentifyCelebrities;
|
|
36
47
|
function isTranslateTextInput(obj) {
|
|
37
48
|
const key = 'translateText';
|
|
38
49
|
return obj && Object.prototype.hasOwnProperty.call(obj, key);
|
|
39
50
|
}
|
|
40
|
-
exports.isTranslateTextInput = isTranslateTextInput;
|
|
41
51
|
function isTextToSpeechInput(obj) {
|
|
42
52
|
const key = 'textToSpeech';
|
|
43
53
|
return obj && Object.prototype.hasOwnProperty.call(obj, key);
|
|
44
54
|
}
|
|
45
|
-
exports.isTextToSpeechInput = isTextToSpeechInput;
|
|
46
55
|
function isSpeechToTextInput(obj) {
|
|
47
56
|
const key = 'transcription';
|
|
48
57
|
return obj && Object.prototype.hasOwnProperty.call(obj, key);
|
|
49
58
|
}
|
|
50
|
-
exports.isSpeechToTextInput = isSpeechToTextInput;
|
|
51
59
|
function isStorageSource(obj) {
|
|
52
60
|
const key = 'key';
|
|
53
61
|
return obj && Object.prototype.hasOwnProperty.call(obj, key);
|
|
54
62
|
}
|
|
55
|
-
exports.isStorageSource = isStorageSource;
|
|
56
63
|
function isFileSource(obj) {
|
|
57
64
|
const key = 'file';
|
|
58
65
|
return obj && Object.prototype.hasOwnProperty.call(obj, key);
|
|
59
66
|
}
|
|
60
|
-
exports.isFileSource = isFileSource;
|
|
61
67
|
function isConvertBytesSource(obj) {
|
|
62
68
|
const key = 'bytes';
|
|
63
69
|
return obj && Object.prototype.hasOwnProperty.call(obj, key);
|
|
64
70
|
}
|
|
65
|
-
exports.isConvertBytesSource = isConvertBytesSource;
|
|
66
71
|
function isIdentifyBytesSource(obj) {
|
|
67
72
|
const key = 'bytes';
|
|
68
73
|
return obj && Object.prototype.hasOwnProperty.call(obj, key);
|
|
69
74
|
}
|
|
70
|
-
exports.isIdentifyBytesSource = isIdentifyBytesSource;
|
|
71
75
|
function isIdentifyTextInput(obj) {
|
|
72
76
|
const key = 'text';
|
|
73
77
|
return obj && Object.prototype.hasOwnProperty.call(obj, key);
|
|
74
78
|
}
|
|
75
|
-
exports.isIdentifyTextInput = isIdentifyTextInput;
|
|
76
79
|
function isIdentifyLabelsInput(obj) {
|
|
77
80
|
const key = 'labels';
|
|
78
81
|
return obj && Object.prototype.hasOwnProperty.call(obj, key);
|
|
79
82
|
}
|
|
80
|
-
exports.isIdentifyLabelsInput = isIdentifyLabelsInput;
|
|
81
83
|
function isIdentifyEntitiesInput(obj) {
|
|
82
84
|
const key = 'entities';
|
|
83
85
|
return obj && Object.prototype.hasOwnProperty.call(obj, key);
|
|
84
86
|
}
|
|
85
|
-
exports.isIdentifyEntitiesInput = isIdentifyEntitiesInput;
|
|
86
87
|
function isInterpretTextInput(obj) {
|
|
87
88
|
const key = 'text';
|
|
88
89
|
return obj && Object.prototype.hasOwnProperty.call(obj, key);
|
|
89
90
|
}
|
|
90
|
-
exports.isInterpretTextInput = isInterpretTextInput;
|
|
91
91
|
function isInterpretTextOthers(text) {
|
|
92
92
|
return text.source.language !== undefined;
|
|
93
93
|
}
|
|
94
|
-
exports.isInterpretTextOthers = isInterpretTextOthers;
|
|
95
94
|
//# sourceMappingURL=Predictions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Predictions.js","sources":["../../../src/types/Predictions.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.
|
|
1
|
+
{"version":3,"file":"Predictions.js","sources":["../../../src/types/Predictions.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isValidConvertInput = isValidConvertInput;\nexports.isValidIdentifyInput = isValidIdentifyInput;\nexports.isValidInterpretInput = isValidInterpretInput;\nexports.isIdentifyFromCollection = isIdentifyFromCollection;\nexports.isIdentifyCelebrities = isIdentifyCelebrities;\nexports.isTranslateTextInput = isTranslateTextInput;\nexports.isTextToSpeechInput = isTextToSpeechInput;\nexports.isSpeechToTextInput = isSpeechToTextInput;\nexports.isStorageSource = isStorageSource;\nexports.isFileSource = isFileSource;\nexports.isConvertBytesSource = isConvertBytesSource;\nexports.isIdentifyBytesSource = isIdentifyBytesSource;\nexports.isIdentifyTextInput = isIdentifyTextInput;\nexports.isIdentifyLabelsInput = isIdentifyLabelsInput;\nexports.isIdentifyEntitiesInput = isIdentifyEntitiesInput;\nexports.isInterpretTextInput = isInterpretTextInput;\nexports.isInterpretTextOthers = isInterpretTextOthers;\nfunction isValidConvertInput(obj) {\n return (isTranslateTextInput(obj) ||\n isTextToSpeechInput(obj) ||\n isSpeechToTextInput(obj));\n}\nfunction isValidIdentifyInput(obj) {\n return (isIdentifyTextInput(obj) ||\n isIdentifyLabelsInput(obj) ||\n isIdentifyEntitiesInput(obj));\n}\nfunction isValidInterpretInput(obj) {\n return isInterpretTextInput(obj);\n}\nfunction 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}\nfunction isIdentifyCelebrities(obj) {\n const key = 'celebrityDetection';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nfunction isTranslateTextInput(obj) {\n const key = 'translateText';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nfunction isTextToSpeechInput(obj) {\n const key = 'textToSpeech';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nfunction isSpeechToTextInput(obj) {\n const key = 'transcription';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nfunction isStorageSource(obj) {\n const key = 'key';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nfunction isFileSource(obj) {\n const key = 'file';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nfunction isConvertBytesSource(obj) {\n const key = 'bytes';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nfunction isIdentifyBytesSource(obj) {\n const key = 'bytes';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nfunction isIdentifyTextInput(obj) {\n const key = 'text';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nfunction isIdentifyLabelsInput(obj) {\n const key = 'labels';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nfunction isIdentifyEntitiesInput(obj) {\n const key = 'entities';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nfunction isInterpretTextInput(obj) {\n const key = 'text';\n return obj && Object.prototype.hasOwnProperty.call(obj, key);\n}\nfunction isInterpretTextOthers(text) {\n return text.source.language !== undefined;\n}\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,mBAAmB,GAAG,mBAAmB;AACjD,OAAO,CAAC,oBAAoB,GAAG,oBAAoB;AACnD,OAAO,CAAC,qBAAqB,GAAG,qBAAqB;AACrD,OAAO,CAAC,wBAAwB,GAAG,wBAAwB;AAC3D,OAAO,CAAC,qBAAqB,GAAG,qBAAqB;AACrD,OAAO,CAAC,oBAAoB,GAAG,oBAAoB;AACn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,qBAAqB,CAAC,GAAG,EAAE;AACpC,IAAI,MAAM,GAAG,GAAG,OAAO;AACvB,IAAI,OAAO,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;AAChE;AACA,SAAS,mBAAmB,CAAC,GAAG,EAAE;AAClC,IAAI,MAAM,GAAG,GAAG,MAAM;AACtB,IAAI,OAAO,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;AAChE;AACA,SAAS,qBAAqB,CAAC,GAAG,EAAE;AACpC,IAAI,MAAM,GAAG,GAAG,QAAQ;AACxB,IAAI,OAAO,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;AAChE;AACA,SAAS,uBAAuB,CAAC,GAAG,EAAE;AACtC,IAAI,MAAM,GAAG,GAAG,UAAU;AAC1B,IAAI,OAAO,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;AAChE;AACA,SAAS,oBAAoB,CAAC,GAAG,EAAE;AACnC,IAAI,MAAM,GAAG,GAAG,MAAM;AACtB,IAAI,OAAO,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;AAChE;AACA,SAAS,qBAAqB,CAAC,IAAI,EAAE;AACrC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS;AAC7C;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
/**
|
|
3
2
|
* Convert types
|
|
4
3
|
*/
|
|
@@ -257,9 +256,9 @@ export interface IdentifyEntity {
|
|
|
257
256
|
export interface IdentifyEntitiesOutput {
|
|
258
257
|
entities: IdentifyEntity[];
|
|
259
258
|
}
|
|
260
|
-
export declare function isValidConvertInput(obj: any):
|
|
261
|
-
export declare function isValidIdentifyInput(obj: any):
|
|
262
|
-
export declare function isValidInterpretInput(obj: any):
|
|
259
|
+
export declare function isValidConvertInput(obj: any): obj is TranslateTextInput | TextToSpeechInput | SpeechToTextInput;
|
|
260
|
+
export declare function isValidIdentifyInput(obj: any): obj is IdentifyTextInput | IdentifyLabelsInput | IdentifyEntitiesInput;
|
|
261
|
+
export declare function isValidInterpretInput(obj: any): obj is InterpretTextInput;
|
|
263
262
|
export declare function isIdentifyFromCollection(obj: any): obj is IdentifyFromCollection;
|
|
264
263
|
export declare function isIdentifyCelebrities(obj: any): obj is IdentifyCelebrities;
|
|
265
264
|
export declare function isTranslateTextInput(obj: any): obj is TranslateTextInput;
|
package/package.json
CHANGED
|
@@ -1,74 +1,73 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
"gitHead": "f2ac9929610f7f878f124083ceaf03465113cd44"
|
|
2
|
+
"name": "@aws-amplify/predictions",
|
|
3
|
+
"version": "6.1.56-local-stack.00864ae.0+00864ae",
|
|
4
|
+
"description": "Machine learning category of aws-amplify",
|
|
5
|
+
"main": "./dist/cjs/index.js",
|
|
6
|
+
"module": "./dist/esm/index.mjs",
|
|
7
|
+
"typings": "./dist/esm/index.d.ts",
|
|
8
|
+
"react-native": "./dist/cjs/index.js",
|
|
9
|
+
"sideEffects": [
|
|
10
|
+
"./dist/cjs/Predictions.js",
|
|
11
|
+
"./dist/esm/Predictions.mjs"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"test": "npm run lint && jest -w 1 --coverage --logHeapUsage",
|
|
15
|
+
"test:size": "size-limit",
|
|
16
|
+
"build-with-test": "npm run clean && npm run build",
|
|
17
|
+
"build:umd": "webpack && webpack --config ./webpack.config.dev.js",
|
|
18
|
+
"build:esm-cjs": "rollup --forceExit -c rollup.config.mjs",
|
|
19
|
+
"build:watch": "npm run build:esm-cjs -- --watch",
|
|
20
|
+
"build": "npm run clean && npm run build:esm-cjs && npm run build:umd",
|
|
21
|
+
"clean": "npm run clean:size && rimraf dist lib lib-esm",
|
|
22
|
+
"clean:size": "rimraf dual-publish-tmp tmp*",
|
|
23
|
+
"format": "echo \"Not implemented\"",
|
|
24
|
+
"lint": "eslint '**/*.{ts,tsx}' && npm run ts-coverage",
|
|
25
|
+
"lint:fix": "eslint '**/*.{ts,tsx}' --fix",
|
|
26
|
+
"generate-docs-local": "typedoc --out docs src",
|
|
27
|
+
"generate-docs-root": "typedoc --out ../../docs src",
|
|
28
|
+
"ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 87.84"
|
|
29
|
+
},
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/aws-amplify/amplify-js.git"
|
|
33
|
+
},
|
|
34
|
+
"author": "Amazon Web Services",
|
|
35
|
+
"license": "Apache-2.0",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/aws/aws-amplify/issues"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://aws-amplify.github.io/",
|
|
40
|
+
"files": [
|
|
41
|
+
"dist/cjs",
|
|
42
|
+
"dist/esm",
|
|
43
|
+
"src"
|
|
44
|
+
],
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@aws-amplify/storage": "6.8.5-local-stack.00864ae.0+00864ae",
|
|
47
|
+
"@aws-sdk/client-comprehend": "3.621.0",
|
|
48
|
+
"@aws-sdk/client-polly": "3.621.0",
|
|
49
|
+
"@aws-sdk/client-rekognition": "3.621.0",
|
|
50
|
+
"@aws-sdk/client-textract": "3.621.0",
|
|
51
|
+
"@aws-sdk/client-translate": "3.621.0",
|
|
52
|
+
"@smithy/eventstream-codec": "2.0.9",
|
|
53
|
+
"@smithy/util-utf8": "2.0.0",
|
|
54
|
+
"buffer": "4.9.2",
|
|
55
|
+
"tslib": "^2.5.0",
|
|
56
|
+
"uuid": "^9.0.0"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"@aws-amplify/core": "6.11.5-local-stack.00864ae.0+00864ae"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@aws-amplify/core": "6.11.5-local-stack.00864ae.0+00864ae"
|
|
63
|
+
},
|
|
64
|
+
"size-limit": [
|
|
65
|
+
{
|
|
66
|
+
"name": "Predictions",
|
|
67
|
+
"path": "./dist/esm/index.mjs",
|
|
68
|
+
"import": "{ Predictions }",
|
|
69
|
+
"limit": "69.8 kB"
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
"gitHead": "00864aec571d0509655eea0673e896d69d434972"
|
|
74
73
|
}
|