@aws-amplify/predictions 6.0.16 → 6.0.17-unstable.0d2aa5d.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/package.json CHANGED
@@ -1,73 +1,73 @@
1
1
  {
2
- "name": "@aws-amplify/predictions",
3
- "version": "6.0.16",
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": "./src/index.ts",
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 -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": "tslint 'src/**/*.ts' && npm run ts-coverage",
25
- "generate-docs-local": "typedoc --out docs src",
26
- "generate-docs-root": "typedoc --out ../../docs src",
27
- "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 87.84"
28
- },
29
- "repository": {
30
- "type": "git",
31
- "url": "https://github.com/aws-amplify/amplify-js.git"
32
- },
33
- "author": "Amazon Web Services",
34
- "license": "Apache-2.0",
35
- "bugs": {
36
- "url": "https://github.com/aws/aws-amplify/issues"
37
- },
38
- "homepage": "https://aws-amplify.github.io/",
39
- "files": [
40
- "dist/cjs",
41
- "dist/esm",
42
- "src"
43
- ],
44
- "dependencies": {
45
- "@aws-amplify/storage": "6.0.16",
46
- "@aws-sdk/client-comprehend": "3.398.0",
47
- "@aws-sdk/client-polly": "3.398.0",
48
- "@aws-sdk/client-rekognition": "3.398.0",
49
- "@aws-sdk/client-textract": "3.398.0",
50
- "@aws-sdk/client-translate": "3.398.0",
51
- "@smithy/eventstream-codec": "2.0.9",
52
- "@smithy/util-utf8": "2.0.0",
53
- "buffer": "4.9.2",
54
- "tslib": "^2.5.0",
55
- "uuid": "^9.0.0"
56
- },
57
- "peerDependencies": {
58
- "@aws-amplify/core": "^6.0.0"
59
- },
60
- "devDependencies": {
61
- "@aws-amplify/core": "6.0.16",
62
- "typescript": "5.0.2"
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": "0e919f6e759cb94d03e119162b530b32d48f1357"
2
+ "name": "@aws-amplify/predictions",
3
+ "version": "6.0.17-unstable.0d2aa5d.0+0d2aa5d",
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": "./src/index.ts",
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 -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": "tslint 'src/**/*.ts' && npm run ts-coverage",
25
+ "generate-docs-local": "typedoc --out docs src",
26
+ "generate-docs-root": "typedoc --out ../../docs src",
27
+ "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 87.84"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/aws-amplify/amplify-js.git"
32
+ },
33
+ "author": "Amazon Web Services",
34
+ "license": "Apache-2.0",
35
+ "bugs": {
36
+ "url": "https://github.com/aws/aws-amplify/issues"
37
+ },
38
+ "homepage": "https://aws-amplify.github.io/",
39
+ "files": [
40
+ "dist/cjs",
41
+ "dist/esm",
42
+ "src"
43
+ ],
44
+ "dependencies": {
45
+ "@aws-amplify/storage": "6.0.17-unstable.0d2aa5d.0+0d2aa5d",
46
+ "@aws-sdk/client-comprehend": "3.398.0",
47
+ "@aws-sdk/client-polly": "3.398.0",
48
+ "@aws-sdk/client-rekognition": "3.398.0",
49
+ "@aws-sdk/client-textract": "3.398.0",
50
+ "@aws-sdk/client-translate": "3.398.0",
51
+ "@smithy/eventstream-codec": "2.0.9",
52
+ "@smithy/util-utf8": "2.0.0",
53
+ "buffer": "4.9.2",
54
+ "tslib": "^2.5.0",
55
+ "uuid": "^9.0.0"
56
+ },
57
+ "peerDependencies": {
58
+ "@aws-amplify/core": "6.0.17-unstable.0d2aa5d.0+0d2aa5d"
59
+ },
60
+ "devDependencies": {
61
+ "@aws-amplify/core": "6.0.17-unstable.0d2aa5d.0+0d2aa5d",
62
+ "typescript": "5.0.2"
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": "0d2aa5d71a6b995e302c7404becd8345763eae43"
73
73
  }
@@ -42,7 +42,7 @@ export class PredictionsClass {
42
42
  public convert(input: TextToSpeechInput): Promise<TextToSpeechOutput>;
43
43
  public convert(input: SpeechToTextInput): Promise<SpeechToTextOutput>;
44
44
  public convert(
45
- input: TranslateTextInput | TextToSpeechInput | SpeechToTextInput
45
+ input: TranslateTextInput | TextToSpeechInput | SpeechToTextInput,
46
46
  ): Promise<TranslateTextOutput | TextToSpeechOutput | SpeechToTextOutput> {
47
47
  return this.convertProvider.convert(input);
48
48
  }
@@ -50,10 +50,10 @@ export class PredictionsClass {
50
50
  public identify(input: IdentifyTextInput): Promise<IdentifyTextOutput>;
51
51
  public identify(input: IdentifyLabelsInput): Promise<IdentifyLabelsOutput>;
52
52
  public identify(
53
- input: IdentifyEntitiesInput
53
+ input: IdentifyEntitiesInput,
54
54
  ): Promise<IdentifyEntitiesOutput>;
55
55
  public identify(
56
- input: IdentifyTextInput | IdentifyLabelsInput | IdentifyEntitiesInput
56
+ input: IdentifyTextInput | IdentifyLabelsInput | IdentifyEntitiesInput,
57
57
  ): Promise<
58
58
  IdentifyTextOutput | IdentifyLabelsOutput | IdentifyEntitiesOutput
59
59
  > {
@@ -9,7 +9,7 @@ import {
9
9
 
10
10
  export function assertValidationError(
11
11
  assertion: boolean,
12
- name: PredictionsValidationErrorCode
12
+ name: PredictionsValidationErrorCode,
13
13
  ): asserts assertion {
14
14
  if (!assertion) {
15
15
  const { message, recoverySuggestion } = validationErrorMap[name];
@@ -50,11 +50,11 @@ export class AmazonAIConvertPredictionsProvider {
50
50
  }
51
51
 
52
52
  convert(
53
- input: TranslateTextInput | TextToSpeechInput | SpeechToTextInput
53
+ input: TranslateTextInput | TextToSpeechInput | SpeechToTextInput,
54
54
  ): Promise<TextToSpeechOutput | TranslateTextOutput | SpeechToTextOutput> {
55
55
  assertValidationError(
56
56
  isValidConvertInput(input),
57
- PredictionsValidationErrorCode.InvalidInput
57
+ PredictionsValidationErrorCode.InvalidInput,
58
58
  );
59
59
 
60
60
  if (isTranslateTextInput(input)) {
@@ -70,7 +70,7 @@ export class AmazonAIConvertPredictionsProvider {
70
70
  }
71
71
 
72
72
  protected async translateText(
73
- input: TranslateTextInput
73
+ input: TranslateTextInput,
74
74
  ): Promise<TranslateTextOutput> {
75
75
  logger.debug('Starting translation');
76
76
 
@@ -78,14 +78,14 @@ export class AmazonAIConvertPredictionsProvider {
78
78
  Amplify.getConfig().Predictions?.convert ?? {};
79
79
  assertValidationError(
80
80
  !!translateText.region,
81
- PredictionsValidationErrorCode.NoRegion
81
+ PredictionsValidationErrorCode.NoRegion,
82
82
  );
83
83
  const { defaults = {}, region } = translateText;
84
84
 
85
85
  const { credentials } = await fetchAuthSession();
86
86
  assertValidationError(
87
87
  !!credentials,
88
- PredictionsValidationErrorCode.NoCredentials
88
+ PredictionsValidationErrorCode.NoCredentials,
89
89
  );
90
90
 
91
91
  const { sourceLanguage, targetLanguage } = defaults;
@@ -95,11 +95,11 @@ export class AmazonAIConvertPredictionsProvider {
95
95
  input.translateText?.targetLanguage ?? targetLanguage;
96
96
  assertValidationError(
97
97
  !!sourceLanguageCode,
98
- PredictionsValidationErrorCode.NoSourceLanguage
98
+ PredictionsValidationErrorCode.NoSourceLanguage,
99
99
  );
100
100
  assertValidationError(
101
101
  !!targetLanguageCode,
102
- PredictionsValidationErrorCode.NoTargetLanguage
102
+ PredictionsValidationErrorCode.NoTargetLanguage,
103
103
  );
104
104
 
105
105
  this.translateClient = new TranslateClient({
@@ -123,22 +123,22 @@ export class AmazonAIConvertPredictionsProvider {
123
123
  }
124
124
 
125
125
  protected async convertTextToSpeech(
126
- input: TextToSpeechInput
126
+ input: TextToSpeechInput,
127
127
  ): Promise<TextToSpeechOutput> {
128
128
  const { credentials } = await fetchAuthSession();
129
129
  assertValidationError(
130
130
  !!credentials,
131
- PredictionsValidationErrorCode.NoCredentials
131
+ PredictionsValidationErrorCode.NoCredentials,
132
132
  );
133
133
  assertValidationError(
134
134
  !!input.textToSpeech?.source,
135
- PredictionsValidationErrorCode.NoSource
135
+ PredictionsValidationErrorCode.NoSource,
136
136
  );
137
137
 
138
138
  const { speechGenerator } = Amplify.getConfig().Predictions?.convert ?? {};
139
139
  assertValidationError(
140
140
  !!speechGenerator?.region,
141
- PredictionsValidationErrorCode.NoRegion
141
+ PredictionsValidationErrorCode.NoRegion,
142
142
  );
143
143
 
144
144
  const { defaults = {}, region } = speechGenerator;
@@ -178,19 +178,19 @@ export class AmazonAIConvertPredictionsProvider {
178
178
  }
179
179
 
180
180
  protected async convertSpeechToText(
181
- input: SpeechToTextInput
181
+ input: SpeechToTextInput,
182
182
  ): Promise<SpeechToTextOutput> {
183
183
  logger.debug('starting transcription..');
184
184
  const { credentials } = await fetchAuthSession();
185
185
  assertValidationError(
186
186
  !!credentials,
187
- PredictionsValidationErrorCode.NoCredentials
187
+ PredictionsValidationErrorCode.NoCredentials,
188
188
  );
189
189
 
190
190
  const { transcription } = Amplify.getConfig().Predictions?.convert ?? {};
191
191
  assertValidationError(
192
192
  !!transcription?.region,
193
- PredictionsValidationErrorCode.NoRegion
193
+ PredictionsValidationErrorCode.NoRegion,
194
194
  );
195
195
 
196
196
  const { defaults, region } = transcription;
@@ -198,13 +198,13 @@ export class AmazonAIConvertPredictionsProvider {
198
198
 
199
199
  assertValidationError(
200
200
  !!language,
201
- PredictionsValidationErrorCode.NoLanguage
201
+ PredictionsValidationErrorCode.NoLanguage,
202
202
  );
203
203
 
204
204
  const source = input.transcription?.source;
205
205
  assertValidationError(
206
206
  isConvertBytesSource(source),
207
- PredictionsValidationErrorCode.InvalidSource
207
+ PredictionsValidationErrorCode.InvalidSource,
208
208
  );
209
209
 
210
210
  const connection = await this.openConnectionWithTranscribe({
@@ -232,7 +232,7 @@ export class AmazonAIConvertPredictionsProvider {
232
232
  if (transcribeMessage.headers[':message-type'].value === 'exception') {
233
233
  logger.debug(
234
234
  'exception',
235
- JSON.stringify(transcribeMessageJson.Message, null, 2)
235
+ JSON.stringify(transcribeMessageJson.Message, null, 2),
236
236
  );
237
237
  throw new Error(transcribeMessageJson.Message);
238
238
  } else if (transcribeMessage.headers[':message-type'].value === 'event') {
@@ -275,7 +275,7 @@ export class AmazonAIConvertPredictionsProvider {
275
275
  try {
276
276
  const decodedMessage =
277
277
  AmazonAIConvertPredictionsProvider.serializeDataFromTranscribe(
278
- message
278
+ message,
279
279
  );
280
280
  if (decodedMessage) {
281
281
  fullText += decodedMessage + ' ';
@@ -318,7 +318,7 @@ export class AmazonAIConvertPredictionsProvider {
318
318
  private sendEncodedDataToTranscribe(
319
319
  connection: WebSocket,
320
320
  data: ConvertBytes | any[],
321
- languageCode: string
321
+ languageCode: string,
322
322
  ) {
323
323
  const downsampledBuffer = this.downsampleBuffer({
324
324
  buffer: data,
@@ -329,7 +329,7 @@ export class AmazonAIConvertPredictionsProvider {
329
329
 
330
330
  const pcmEncodedBuffer = this.pcmEncode(downsampledBuffer);
331
331
  const audioEventMessage = this.getAudioEventMessage(
332
- Buffer.from(pcmEncodedBuffer)
332
+ Buffer.from(pcmEncodedBuffer),
333
333
  );
334
334
  const binary = eventBuilder.encode(audioEventMessage);
335
335
  connection.send(binary);
@@ -467,7 +467,7 @@ export class AmazonAIConvertPredictionsProvider {
467
467
  url,
468
468
  credentials,
469
469
  { region, service: 'transcribe' },
470
- 300
470
+ 300,
471
471
  );
472
472
 
473
473
  return signedUrl;
@@ -73,13 +73,13 @@ export class AmazonAIIdentifyPredictionsProvider {
73
73
  }
74
74
 
75
75
  identify(
76
- input: IdentifyTextInput | IdentifyLabelsInput | IdentifyEntitiesInput
76
+ input: IdentifyTextInput | IdentifyLabelsInput | IdentifyEntitiesInput,
77
77
  ): Promise<
78
78
  IdentifyTextOutput | IdentifyLabelsOutput | IdentifyEntitiesOutput
79
79
  > {
80
80
  assertValidationError(
81
81
  isValidIdentifyInput(input),
82
- PredictionsValidationErrorCode.InvalidInput
82
+ PredictionsValidationErrorCode.InvalidInput,
83
83
  );
84
84
 
85
85
  if (isIdentifyTextInput(input)) {
@@ -156,12 +156,12 @@ export class AmazonAIIdentifyPredictionsProvider {
156
156
  * @return {Promise<IdentifyTextOutput>} - Promise resolving to object containing identified texts.
157
157
  */
158
158
  protected async identifyText(
159
- input: IdentifyTextInput
159
+ input: IdentifyTextInput,
160
160
  ): Promise<IdentifyTextOutput> {
161
161
  const { credentials } = await fetchAuthSession();
162
162
  assertValidationError(
163
163
  !!credentials,
164
- PredictionsValidationErrorCode.NoCredentials
164
+ PredictionsValidationErrorCode.NoCredentials,
165
165
  );
166
166
 
167
167
  const { identifyText = {} } =
@@ -207,7 +207,7 @@ export class AmazonAIIdentifyPredictionsProvider {
207
207
  await this.rekognitionClient.send(detectTextCommand);
208
208
 
209
209
  const rekognitionResponse = categorizeRekognitionBlocks(
210
- rekognitionData.TextDetections as TextDetectionList
210
+ rekognitionData.TextDetections as TextDetectionList,
211
211
  );
212
212
  if (rekognitionResponse.text.words.length < 50) {
213
213
  // did not hit the word limit, return the data
@@ -215,11 +215,11 @@ export class AmazonAIIdentifyPredictionsProvider {
215
215
  }
216
216
 
217
217
  const detectDocumentTextCommand = new DetectDocumentTextCommand(
218
- textractParam
218
+ textractParam,
219
219
  );
220
220
 
221
221
  const { Blocks } = await this.textractClient.send(
222
- detectDocumentTextCommand
222
+ detectDocumentTextCommand,
223
223
  );
224
224
 
225
225
  if (
@@ -247,12 +247,12 @@ export class AmazonAIIdentifyPredictionsProvider {
247
247
  * @return {Promise<IdentifyLabelsOutput>} - Promise resolving to an array of identified entities.
248
248
  */
249
249
  protected async identifyLabels(
250
- input: IdentifyLabelsInput
250
+ input: IdentifyLabelsInput,
251
251
  ): Promise<IdentifyLabelsOutput> {
252
252
  const { credentials } = await fetchAuthSession();
253
253
  assertValidationError(
254
254
  !!credentials,
255
- PredictionsValidationErrorCode.NoCredentials
255
+ PredictionsValidationErrorCode.NoCredentials,
256
256
  );
257
257
 
258
258
  const { identifyLabels = {} } =
@@ -295,7 +295,7 @@ export class AmazonAIIdentifyPredictionsProvider {
295
295
  * @return {Promise<IdentifyLabelsOutput>} - Promise resolving to organized detectLabels response.
296
296
  */
297
297
  private async detectLabels(
298
- param: DetectLabelsCommandInput
298
+ param: DetectLabelsCommandInput,
299
299
  ): Promise<IdentifyLabelsOutput> {
300
300
  const detectLabelsCommand = new DetectLabelsCommand(param);
301
301
  const data = await this.rekognitionClient!.send(detectLabelsCommand);
@@ -304,7 +304,7 @@ export class AmazonAIIdentifyPredictionsProvider {
304
304
  const boxes =
305
305
  label.Instances?.map(
306
306
  instance =>
307
- makeCamelCase(instance.BoundingBox) as BoundingBox | undefined
307
+ makeCamelCase(instance.BoundingBox) as BoundingBox | undefined,
308
308
  ) || [];
309
309
  return {
310
310
  name: label.Name,
@@ -324,13 +324,13 @@ export class AmazonAIIdentifyPredictionsProvider {
324
324
  * @return {Promise<IdentifyLabelsOutput>} - Promise resolving to organized detectModerationLabels response.
325
325
  */
326
326
  private async detectModerationLabels(
327
- param: DetectModerationLabelsCommandInput
327
+ param: DetectModerationLabelsCommandInput,
328
328
  ): Promise<IdentifyLabelsOutput> {
329
329
  const detectModerationLabelsCommand = new DetectModerationLabelsCommand(
330
- param
330
+ param,
331
331
  );
332
332
  const data = await this.rekognitionClient!.send(
333
- detectModerationLabelsCommand
333
+ detectModerationLabelsCommand,
334
334
  );
335
335
  if (data.ModerationLabels?.length !== 0) {
336
336
  return { unsafe: 'YES' };
@@ -346,12 +346,12 @@ export class AmazonAIIdentifyPredictionsProvider {
346
346
  * @return {Promise<IdentifyEntityOutput>} Promise resolving to identify results.
347
347
  */
348
348
  protected async identifyEntities(
349
- input: IdentifyEntitiesInput
349
+ input: IdentifyEntitiesInput,
350
350
  ): Promise<IdentifyEntitiesOutput> {
351
351
  const { credentials } = await fetchAuthSession();
352
352
  assertValidationError(
353
353
  !!credentials,
354
- PredictionsValidationErrorCode.NoCredentials
354
+ PredictionsValidationErrorCode.NoCredentials,
355
355
  );
356
356
 
357
357
  const { identifyEntities = {} } =
@@ -381,13 +381,13 @@ export class AmazonAIIdentifyPredictionsProvider {
381
381
  ) {
382
382
  assertValidationError(
383
383
  celebrityDetectionEnabled,
384
- PredictionsValidationErrorCode.CelebrityDetectionNotEnabled
384
+ PredictionsValidationErrorCode.CelebrityDetectionNotEnabled,
385
385
  );
386
386
  const recognizeCelebritiesCommand = new RecognizeCelebritiesCommand(
387
- param
387
+ param,
388
388
  );
389
389
  const data = await this.rekognitionClient.send(
390
- recognizeCelebritiesCommand
390
+ recognizeCelebritiesCommand,
391
391
  );
392
392
  const faces =
393
393
  data.CelebrityFaces?.map(
@@ -399,7 +399,7 @@ export class AmazonAIIdentifyPredictionsProvider {
399
399
  ...makeCamelCase(celebrity, ['Id', 'Name', 'Urls']),
400
400
  pose: makeCamelCase(celebrity.Face?.Pose),
401
401
  },
402
- }) as IdentifyEntity
402
+ }) as IdentifyEntity,
403
403
  ) ?? [];
404
404
  return { entities: faces };
405
405
  } else if (
@@ -417,7 +417,7 @@ export class AmazonAIIdentifyPredictionsProvider {
417
417
  MaxFaces: maxFaces,
418
418
  };
419
419
  const searchFacesByImageCommand = new SearchFacesByImageCommand(
420
- updatedParam
420
+ updatedParam,
421
421
  );
422
422
  const data = await this.rekognitionClient.send(searchFacesByImageCommand);
423
423
  const faces =
@@ -452,11 +452,11 @@ export class AmazonAIIdentifyPredictionsProvider {
452
452
  ];
453
453
  const faceAttributes = makeCamelCase(
454
454
  detail,
455
- attributeKeys
455
+ attributeKeys,
456
456
  ) as FaceAttributes;
457
457
 
458
458
  faceAttributes.emotions = detail.Emotions?.map(
459
- emotion => emotion.Type
459
+ emotion => emotion.Type,
460
460
  );
461
461
  return {
462
462
  boundingBox: makeCamelCase(detail.BoundingBox),
@@ -42,7 +42,7 @@ export class AmazonAIInterpretPredictionsProvider {
42
42
  interpret(input: InterpretTextInput): Promise<InterpretTextOutput> {
43
43
  assertValidationError(
44
44
  isValidInterpretInput(input),
45
- PredictionsValidationErrorCode.InvalidInput
45
+ PredictionsValidationErrorCode.InvalidInput,
46
46
  );
47
47
 
48
48
  return this.interpretText(input);
@@ -52,7 +52,7 @@ export class AmazonAIInterpretPredictionsProvider {
52
52
  const { credentials } = await fetchAuthSession();
53
53
  assertValidationError(
54
54
  !!credentials,
55
- PredictionsValidationErrorCode.NoCredentials
55
+ PredictionsValidationErrorCode.NoCredentials,
56
56
  );
57
57
 
58
58
  const { interpretText = {} } =
@@ -91,7 +91,7 @@ export class AmazonAIInterpretPredictionsProvider {
91
91
  if (doAll || type === 'entities') {
92
92
  assertValidationError(
93
93
  !!languageCode,
94
- PredictionsValidationErrorCode.NoLanguage
94
+ PredictionsValidationErrorCode.NoLanguage,
95
95
  );
96
96
  const entitiesDetectionParams = {
97
97
  Text: text,
@@ -104,7 +104,7 @@ export class AmazonAIInterpretPredictionsProvider {
104
104
  if (doAll || type === 'sentiment') {
105
105
  assertValidationError(
106
106
  !!languageCode,
107
- PredictionsValidationErrorCode.NoLanguage
107
+ PredictionsValidationErrorCode.NoLanguage,
108
108
  );
109
109
  const sentimentParams = {
110
110
  Text: text,
@@ -117,7 +117,7 @@ export class AmazonAIInterpretPredictionsProvider {
117
117
  if (doAll || type === 'syntax') {
118
118
  assertValidationError(
119
119
  !!languageCode,
120
- PredictionsValidationErrorCode.NoLanguage
120
+ PredictionsValidationErrorCode.NoLanguage,
121
121
  );
122
122
  const syntaxParams = {
123
123
  Text: text,
@@ -130,7 +130,7 @@ export class AmazonAIInterpretPredictionsProvider {
130
130
  if (doAll || type === 'keyPhrases') {
131
131
  assertValidationError(
132
132
  !!languageCode,
133
- PredictionsValidationErrorCode.NoLanguage
133
+ PredictionsValidationErrorCode.NoLanguage,
134
134
  );
135
135
 
136
136
  const keyPhrasesParams = {
@@ -168,7 +168,7 @@ export class AmazonAIInterpretPredictionsProvider {
168
168
  if (err.code === 'AccessDeniedException') {
169
169
  throw new Error(
170
170
  'Not authorized, did you enable Interpret Text on predictions category Amplify CLI? try: ' +
171
- 'amplify predictions add'
171
+ 'amplify predictions add',
172
172
  );
173
173
  } else {
174
174
  throw err;
@@ -186,7 +186,7 @@ export class AmazonAIInterpretPredictionsProvider {
186
186
  if (err.code === 'AccessDeniedException') {
187
187
  throw new Error(
188
188
  'Not authorized, did you enable Interpret Text on predictions category Amplify CLI? try: ' +
189
- 'amplify predictions add'
189
+ 'amplify predictions add',
190
190
  );
191
191
  } else {
192
192
  throw err;
@@ -195,14 +195,14 @@ export class AmazonAIInterpretPredictionsProvider {
195
195
  }
196
196
 
197
197
  private serializeSyntaxFromComprehend(
198
- tokens: SyntaxToken[]
198
+ tokens: SyntaxToken[],
199
199
  ): Array<TextSyntax> {
200
200
  let response: TextSyntax[] = [];
201
201
  if (tokens && Array.isArray(tokens)) {
202
202
  response = tokens.map(
203
203
  ({ Text: text = '', PartOfSpeech: { Tag: syntax = '' } = {} }) => {
204
204
  return { text, syntax };
205
- }
205
+ },
206
206
  );
207
207
  }
208
208
  return response;
@@ -226,7 +226,7 @@ export class AmazonAIInterpretPredictionsProvider {
226
226
  if (err.code === 'AccessDeniedException') {
227
227
  throw new Error(
228
228
  'Not authorized, did you enable Interpret Text on predictions category Amplify CLI? try: ' +
229
- 'amplify predictions add'
229
+ 'amplify predictions add',
230
230
  );
231
231
  } else {
232
232
  throw err;
@@ -235,7 +235,7 @@ export class AmazonAIInterpretPredictionsProvider {
235
235
  }
236
236
 
237
237
  private async detectEntities(
238
- params: DetectParams
238
+ params: DetectParams,
239
239
  ): Promise<Array<TextEntities>> {
240
240
  try {
241
241
  const detectEntitiesCommand = new DetectEntitiesCommand(params);
@@ -246,7 +246,7 @@ export class AmazonAIInterpretPredictionsProvider {
246
246
  if (err.code === 'AccessDeniedException') {
247
247
  throw new Error(
248
248
  'Not authorized, did you enable Interpret Text on predictions category Amplify CLI? try: ' +
249
- 'amplify predictions add'
249
+ 'amplify predictions add',
250
250
  );
251
251
  } else {
252
252
  throw err;
@@ -267,15 +267,15 @@ export class AmazonAIInterpretPredictionsProvider {
267
267
  private async detectLanguage(params: { Text: string }): Promise<string> {
268
268
  try {
269
269
  const detectDominantLanguageCommand = new DetectDominantLanguageCommand(
270
- params
270
+ params,
271
271
  );
272
272
  const data = await this.comprehendClient!.send(
273
- detectDominantLanguageCommand
273
+ detectDominantLanguageCommand,
274
274
  );
275
275
  const { Languages: [{ LanguageCode }] = [{}] } = ({} = data || {});
276
276
  assertValidationError(
277
277
  !!LanguageCode,
278
- PredictionsValidationErrorCode.NoLanguage
278
+ PredictionsValidationErrorCode.NoLanguage,
279
279
  );
280
280
 
281
281
  return LanguageCode;
@@ -283,7 +283,7 @@ export class AmazonAIInterpretPredictionsProvider {
283
283
  if (err.code === 'AccessDeniedException') {
284
284
  throw new Error(
285
285
  'Not authorized, did you enable Interpret Text on predictions category Amplify CLI? try: ' +
286
- 'amplify predictions add'
286
+ 'amplify predictions add',
287
287
  );
288
288
  } else {
289
289
  throw err;
@@ -29,7 +29,7 @@ function getPolygon(geometry?: Geometry): Polygon | undefined {
29
29
  * @return {IdentifyTextOutput} - Object that categorizes each block and its information.
30
30
  */
31
31
  export function categorizeRekognitionBlocks(
32
- blocks: TextDetectionList
32
+ blocks: TextDetectionList,
33
33
  ): IdentifyTextOutput {
34
34
  // Skeleton IdentifyText API response. We will populate it as we iterate through blocks.
35
35
  const response: IdentifyTextOutput = {
@@ -67,7 +67,7 @@ export function categorizeRekognitionBlocks(
67
67
  // remove trailing space of fullText
68
68
  response.text.fullText = response.text.fullText.substr(
69
69
  0,
70
- response.text.fullText.length - 1
70
+ response.text.fullText.length - 1,
71
71
  );
72
72
  return response;
73
73
  }
@@ -79,7 +79,7 @@ export function categorizeRekognitionBlocks(
79
79
  * @return {IdentifyTextOutput} - Object that categorizes each block and its information.
80
80
  */
81
81
  export function categorizeTextractBlocks(
82
- blocks: BlockList
82
+ blocks: BlockList,
83
83
  ): IdentifyTextOutput {
84
84
  // Skeleton IdentifyText API response. We will populate it as we iterate through blocks.
85
85
  const response: IdentifyTextOutput = {
@@ -161,7 +161,7 @@ export function categorizeTextractBlocks(
161
161
  // remove trailing space in fullText
162
162
  response.text.fullText = response.text.fullText.substr(
163
163
  0,
164
- response.text.fullText.length - 1
164
+ response.text.fullText.length - 1,
165
165
  );
166
166
 
167
167
  // Post-process complex structures if they exist.
@@ -195,7 +195,7 @@ export function categorizeTextractBlocks(
195
195
  */
196
196
  function constructTable(
197
197
  table: Block,
198
- blockMap: { [key: string]: Block }
198
+ blockMap: { [key: string]: Block },
199
199
  ): Table {
200
200
  let tableMatrix: TableCell[][];
201
201
  tableMatrix = [];
@@ -241,7 +241,7 @@ function constructTable(
241
241
  */
242
242
  function constructKeyValue(
243
243
  keyBlock: Block,
244
- blockMap: { [key: string]: Block }
244
+ blockMap: { [key: string]: Block },
245
245
  ): KeyValue {
246
246
  let keyText: string = '';
247
247
  let valueText: string = '';
@@ -276,7 +276,7 @@ function constructKeyValue(
276
276
  */
277
277
  function extractContentsFromBlock(
278
278
  block: Block,
279
- blockMap: { [id: string]: Block }
279
+ blockMap: { [id: string]: Block },
280
280
  ): Content {
281
281
  let words: string = '';
282
282
  let isSelected: boolean = false;
@@ -338,7 +338,7 @@ export function isValidInterpretInput(obj: any) {
338
338
  }
339
339
 
340
340
  export function isIdentifyFromCollection(
341
- obj: any
341
+ obj: any,
342
342
  ): obj is IdentifyFromCollection {
343
343
  const key: keyof IdentifyFromCollection = 'collection';
344
344
  const keyId: keyof IdentifyFromCollection = 'collectionId';
@@ -376,14 +376,14 @@ export function isFileSource(obj: any): obj is FileSource {
376
376
  }
377
377
 
378
378
  export function isConvertBytesSource(
379
- obj: any
379
+ obj: any,
380
380
  ): obj is BytesSource<ConvertBytes> {
381
381
  const key: keyof BytesSource<ConvertBytes> = 'bytes';
382
382
  return obj && obj.hasOwnProperty(key);
383
383
  }
384
384
 
385
385
  export function isIdentifyBytesSource(
386
- obj: any
386
+ obj: any,
387
387
  ): obj is BytesSource<IdentifyBytes> {
388
388
  const key: keyof BytesSource<IdentifyBytes> = 'bytes';
389
389
  return obj && obj.hasOwnProperty(key);
@@ -400,7 +400,7 @@ export function isIdentifyLabelsInput(obj: any): obj is IdentifyLabelsInput {
400
400
  }
401
401
 
402
402
  export function isIdentifyEntitiesInput(
403
- obj: any
403
+ obj: any,
404
404
  ): obj is IdentifyEntitiesInput {
405
405
  const key: keyof IdentifyEntitiesInput = 'entities';
406
406
  return obj && obj.hasOwnProperty(key);
@@ -412,7 +412,7 @@ export function isInterpretTextInput(obj: any): obj is InterpretTextInput {
412
412
  }
413
413
 
414
414
  export function isInterpretTextOthers(
415
- text: InterpretTextInput['text']
415
+ text: InterpretTextInput['text'],
416
416
  ): text is InterpretTextOthers {
417
417
  return (text as InterpretTextOthers).source.language !== undefined;
418
418
  }