@aws-amplify/predictions 6.0.22-unstable.bd1fefd.0 → 6.0.22

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 +4 -2
  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 +20 -25
  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 +14 -15
  14. package/dist/cjs/types/Predictions.js.map +1 -1
  15. package/dist/esm/Predictions.mjs +2 -0
  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 +20 -25
  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 +14 -15
  31. package/dist/esm/types/Predictions.mjs.map +1 -1
  32. package/package.json +71 -72
  33. package/src/Predictions.ts +3 -2
  34. package/src/providers/AmazonAIConvertPredictionsProvider.ts +10 -20
  35. package/src/providers/AmazonAIIdentifyPredictionsProvider.ts +26 -41
  36. package/src/providers/AmazonAIInterpretPredictionsProvider.ts +18 -22
  37. package/src/providers/IdentifyTextUtils.ts +22 -25
  38. package/src/providers/Utils.ts +6 -8
  39. package/src/providers/index.ts +0 -1
  40. package/src/types/AWSTypes.ts +3 -2
  41. package/src/types/Predictions.ts +44 -60
@@ -7,15 +7,14 @@
7
7
  export function makeCamelCase(obj?: any, keys?: string[]) {
8
8
  if (!obj) return undefined;
9
9
  const newObj = {};
10
- const keysToRename = keys || Object.keys(obj);
10
+ const keysToRename = keys ? keys : Object.keys(obj);
11
11
  keysToRename.forEach(key => {
12
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
12
+ if (obj.hasOwnProperty(key)) {
13
13
  // change the key to camelcase.
14
14
  const camelCaseKey = key.charAt(0).toLowerCase() + key.substr(1);
15
15
  Object.assign(newObj, { [camelCaseKey]: obj[key] });
16
16
  }
17
17
  });
18
-
19
18
  return newObj;
20
19
  }
21
20
 
@@ -24,7 +23,6 @@ export function makeCamelCase(obj?: any, keys?: string[]) {
24
23
  */
25
24
  export function makeCamelCaseArray(objArr?: object[], keys?: string[]) {
26
25
  if (!objArr) return undefined;
27
-
28
26
  return objArr.map(obj => makeCamelCase(obj, keys));
29
27
  }
30
28
 
@@ -32,18 +30,18 @@ export function makeCamelCaseArray(objArr?: object[], keys?: string[]) {
32
30
  * Converts blob to array buffer
33
31
  */
34
32
  export function blobToArrayBuffer(blob: Blob): Promise<Uint8Array> {
35
- return new Promise((resolve, reject) => {
33
+ return new Promise((res, rej) => {
36
34
  const reader = new FileReader();
37
35
  reader.onload = _event => {
38
- resolve(reader.result as Uint8Array);
36
+ res(reader.result as Uint8Array);
39
37
  };
40
38
  reader.onerror = err => {
41
- reject(err);
39
+ rej(err);
42
40
  };
43
41
  try {
44
42
  reader.readAsArrayBuffer(blob);
45
43
  } catch (err) {
46
- reject(err); // in case user gives invalid type
44
+ rej(err); // in case user gives invalid type
47
45
  }
48
46
  });
49
47
  }
@@ -3,7 +3,6 @@
3
3
  import { AmazonAIConvertPredictionsProvider } from './AmazonAIConvertPredictionsProvider';
4
4
  import { AmazonAIIdentifyPredictionsProvider } from './AmazonAIIdentifyPredictionsProvider';
5
5
  import { AmazonAIInterpretPredictionsProvider } from './AmazonAIInterpretPredictionsProvider';
6
-
7
6
  export {
8
7
  AmazonAIConvertPredictionsProvider,
9
8
  AmazonAIIdentifyPredictionsProvider,
@@ -1,5 +1,6 @@
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 */
3
4
  import { Geometry, Relationship } from './Predictions';
4
5
 
5
6
  export type BlockList = Block[];
@@ -60,13 +61,13 @@ export interface Block {
60
61
  /**
61
62
  * <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>
62
63
  */
63
- Relationships?: Relationship[] | Iterable<Relationship>;
64
+ Relationships?: Array<Relationship> | Iterable<Relationship>;
64
65
 
65
66
  /**
66
67
  * <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>
67
68
  */
68
69
  EntityTypes?:
69
- | ('KEY' | 'VALUE' | string)[]
70
+ | Array<'KEY' | 'VALUE' | string>
70
71
  | Iterable<'KEY' | 'VALUE' | string>;
71
72
 
72
73
  /**
@@ -1,5 +1,6 @@
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 */
3
4
 
4
5
  /**
5
6
  * Convert types
@@ -48,9 +49,9 @@ export interface TextEntities {
48
49
  }
49
50
 
50
51
  export type KeyPhrases = KeyPhrase[];
51
- export interface KeyPhrase {
52
+ export type KeyPhrase = {
52
53
  text?: string;
53
- }
54
+ };
54
55
 
55
56
  export interface TextSyntax {
56
57
  text: string;
@@ -65,18 +66,18 @@ export interface TextSentiment {
65
66
  mixed: number;
66
67
  }
67
68
 
68
- export interface DetectParams {
69
+ export type DetectParams = {
69
70
  Text: string;
70
71
  LanguageCode: string;
71
- }
72
+ };
72
73
 
73
74
  export interface InterpretTextOutput {
74
75
  textInterpretation: {
75
76
  language?: string;
76
- textEntities?: TextEntities[];
77
+ textEntities?: Array<TextEntities>;
77
78
  keyPhrases?: KeyPhrases;
78
79
  sentiment?: TextSentiment;
79
- syntax?: TextSyntax[];
80
+ syntax?: Array<TextSyntax>;
80
81
  };
81
82
  }
82
83
 
@@ -135,11 +136,11 @@ export interface SpeechToTextInput {
135
136
  };
136
137
  }
137
138
 
138
- export interface TranscribeData {
139
+ export type TranscribeData = {
139
140
  connection: WebSocket;
140
141
  raw: ConvertBytes;
141
142
  languageCode: string;
142
- }
143
+ };
143
144
 
144
145
  export interface SpeechToTextOutput {
145
146
  transcription: {
@@ -180,8 +181,8 @@ export interface Content {
180
181
  export interface TableCell extends Content {
181
182
  boundingBox?: BoundingBox;
182
183
  polygon?: Polygon;
183
- rowSpan?: number;
184
- columnSpan?: number;
184
+ rowSpan?: Number;
185
+ columnSpan?: Number;
185
186
  }
186
187
 
187
188
  export interface Table {
@@ -225,24 +226,24 @@ export interface IdentifyLabelsInput {
225
226
  }
226
227
 
227
228
  export interface Point {
228
- x?: number;
229
- y?: number;
229
+ x?: Number;
230
+ y?: Number;
230
231
  }
231
232
 
232
- export type Polygon = Point[] | Iterable<Point>;
233
+ export type Polygon = Array<Point> | Iterable<Point>;
233
234
 
234
235
  export interface BoundingBox {
235
- width?: number;
236
- height?: number;
237
- left?: number;
238
- top?: number;
236
+ width?: Number;
237
+ height?: Number;
238
+ left?: Number;
239
+ top?: Number;
239
240
  }
240
241
 
241
242
  export interface IdentifyLabelsOutput {
242
243
  labels?: {
243
244
  name?: string;
244
245
  boundingBoxes?: (BoundingBox | undefined)[];
245
- metadata?: object;
246
+ metadata?: Object;
246
247
  }[];
247
248
  unsafe?: 'YES' | 'NO' | 'UNKNOWN';
248
249
  }
@@ -279,18 +280,18 @@ export interface FaceAttributes {
279
280
  emotions?: (string | undefined)[];
280
281
  }
281
282
 
282
- export interface EntityAgeRange {
283
- low?: number;
284
- high?: number;
285
- }
283
+ export type EntityAgeRange = {
284
+ low?: Number;
285
+ high?: Number;
286
+ };
286
287
 
287
- export interface EntityLandmark {
288
+ export type EntityLandmark = {
288
289
  type?: string;
289
290
  x?: number;
290
291
  y?: number;
291
- }
292
+ };
292
293
 
293
- export interface EntityMetadata {
294
+ export type EntityMetadata = {
294
295
  id?: string;
295
296
  name?: string;
296
297
  pose?: {
@@ -302,15 +303,15 @@ export interface EntityMetadata {
302
303
  externalImageId?: string;
303
304
  similarity?: number;
304
305
  confidence?: number;
305
- }
306
+ };
306
307
 
307
- export interface IdentifyEntity {
308
+ export type IdentifyEntity = {
308
309
  boundingBox?: BoundingBox;
309
310
  ageRange?: EntityAgeRange;
310
311
  landmarks?: (EntityLandmark | undefined)[];
311
312
  attributes?: FaceAttributes;
312
313
  metadata?: EntityMetadata;
313
- }
314
+ };
314
315
 
315
316
  export interface IdentifyEntitiesOutput {
316
317
  entities: IdentifyEntity[];
@@ -341,90 +342,73 @@ export function isIdentifyFromCollection(
341
342
  ): obj is IdentifyFromCollection {
342
343
  const key: keyof IdentifyFromCollection = 'collection';
343
344
  const keyId: keyof IdentifyFromCollection = 'collectionId';
344
-
345
- return (
346
- obj &&
347
- (Object.prototype.hasOwnProperty.call(obj, key) ||
348
- Object.prototype.hasOwnProperty.call(obj, keyId))
349
- );
345
+ return obj && (obj.hasOwnProperty(key) || obj.hasOwnProperty(keyId));
350
346
  }
351
347
 
352
348
  export function isIdentifyCelebrities(obj: any): obj is IdentifyCelebrities {
353
349
  const key: keyof IdentifyCelebrities = 'celebrityDetection';
354
-
355
- return obj && Object.prototype.hasOwnProperty.call(obj, key);
350
+ return obj && obj.hasOwnProperty(key);
356
351
  }
357
352
 
358
353
  export function isTranslateTextInput(obj: any): obj is TranslateTextInput {
359
354
  const key: keyof TranslateTextInput = 'translateText';
360
-
361
- return obj && Object.prototype.hasOwnProperty.call(obj, key);
355
+ return obj && obj.hasOwnProperty(key);
362
356
  }
363
357
 
364
358
  export function isTextToSpeechInput(obj: any): obj is TextToSpeechInput {
365
359
  const key: keyof TextToSpeechInput = 'textToSpeech';
366
-
367
- return obj && Object.prototype.hasOwnProperty.call(obj, key);
360
+ return obj && obj.hasOwnProperty(key);
368
361
  }
369
362
 
370
363
  export function isSpeechToTextInput(obj: any): obj is SpeechToTextInput {
371
364
  const key: keyof SpeechToTextInput = 'transcription';
372
-
373
- return obj && Object.prototype.hasOwnProperty.call(obj, key);
365
+ return obj && obj.hasOwnProperty(key);
374
366
  }
375
367
 
376
368
  export function isStorageSource(obj: any): obj is StorageSource {
377
369
  const key: keyof StorageSource = 'key';
378
-
379
- return obj && Object.prototype.hasOwnProperty.call(obj, key);
370
+ return obj && obj.hasOwnProperty(key);
380
371
  }
381
372
 
382
373
  export function isFileSource(obj: any): obj is FileSource {
383
374
  const key: keyof FileSource = 'file';
384
-
385
- return obj && Object.prototype.hasOwnProperty.call(obj, key);
375
+ return obj && obj.hasOwnProperty(key);
386
376
  }
387
377
 
388
378
  export function isConvertBytesSource(
389
379
  obj: any,
390
380
  ): obj is BytesSource<ConvertBytes> {
391
381
  const key: keyof BytesSource<ConvertBytes> = 'bytes';
392
-
393
- return obj && Object.prototype.hasOwnProperty.call(obj, key);
382
+ return obj && obj.hasOwnProperty(key);
394
383
  }
395
384
 
396
385
  export function isIdentifyBytesSource(
397
386
  obj: any,
398
387
  ): obj is BytesSource<IdentifyBytes> {
399
388
  const key: keyof BytesSource<IdentifyBytes> = 'bytes';
400
-
401
- return obj && Object.prototype.hasOwnProperty.call(obj, key);
389
+ return obj && obj.hasOwnProperty(key);
402
390
  }
403
391
 
404
392
  export function isIdentifyTextInput(obj: any): obj is IdentifyTextInput {
405
393
  const key: keyof IdentifyTextInput = 'text';
406
-
407
- return obj && Object.prototype.hasOwnProperty.call(obj, key);
394
+ return obj && obj.hasOwnProperty(key);
408
395
  }
409
396
 
410
397
  export function isIdentifyLabelsInput(obj: any): obj is IdentifyLabelsInput {
411
398
  const key: keyof IdentifyLabelsInput = 'labels';
412
-
413
- return obj && Object.prototype.hasOwnProperty.call(obj, key);
399
+ return obj && obj.hasOwnProperty(key);
414
400
  }
415
401
 
416
402
  export function isIdentifyEntitiesInput(
417
403
  obj: any,
418
404
  ): obj is IdentifyEntitiesInput {
419
405
  const key: keyof IdentifyEntitiesInput = 'entities';
420
-
421
- return obj && Object.prototype.hasOwnProperty.call(obj, key);
406
+ return obj && obj.hasOwnProperty(key);
422
407
  }
423
408
 
424
409
  export function isInterpretTextInput(obj: any): obj is InterpretTextInput {
425
410
  const key: keyof InterpretTextInput = 'text';
426
-
427
- return obj && Object.prototype.hasOwnProperty.call(obj, key);
411
+ return obj && obj.hasOwnProperty(key);
428
412
  }
429
413
 
430
414
  export function isInterpretTextOthers(
@@ -442,7 +426,7 @@ export interface Geometry {
442
426
  /**
443
427
  * <p>Within the bounding box, a fine-grained polygon around the detected text.</p>
444
428
  */
445
- Polygon?: Point[] | Iterable<Point>;
429
+ Polygon?: Array<Point> | Iterable<Point>;
446
430
  }
447
431
 
448
432
  export interface Relationship {
@@ -454,7 +438,7 @@ export interface Relationship {
454
438
  /**
455
439
  * <p>An array of IDs for related blocks. You can get the type of the relationship from the <code>Type</code> element.</p>
456
440
  */
457
- Ids?: string[] | Iterable<string>;
441
+ Ids?: Array<string> | Iterable<string>;
458
442
  }
459
443
 
460
444
  export type FeatureType = 'TABLES' | 'FORMS' | string;