express-sweet 1.0.15 → 1.0.18

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 (75) hide show
  1. package/CHANGELOG.md +215 -0
  2. package/INSTALL-Redis.md +51 -0
  3. package/README.md +13 -44
  4. package/dist/build.common.js +59 -0
  5. package/dist/build.esm.js +59 -0
  6. package/docs/{styles/docs.css → docs.css} +99 -100
  7. package/docs/docs.js +41 -0
  8. package/docs/{images → img/associations}/belongs-to-many.png +0 -0
  9. package/docs/{images → img/associations}/belongs-to.png +0 -0
  10. package/docs/{images → img/associations}/has-many.png +0 -0
  11. package/docs/{images → img/associations}/has-one.png +0 -0
  12. package/docs/img/demos/login&users.jfif +0 -0
  13. package/docs/img/hero.svg +1 -0
  14. package/docs/{images → img}/logo.svg +0 -0
  15. package/docs/index.html +2520 -3144
  16. package/docs/templates/cjs/authentication.js +96 -0
  17. package/docs/templates/cjs/config.js +78 -0
  18. package/docs/templates/cjs/database.js +35 -0
  19. package/docs/templates/cjs/view.js +36 -0
  20. package/docs/templates/esm/authentication.js +96 -0
  21. package/docs/templates/esm/config.js +78 -0
  22. package/docs/templates/esm/database.js +35 -0
  23. package/docs/templates/esm/view.js +36 -0
  24. package/package.json +9 -6
  25. package/types/database/Database.d.ts +162 -0
  26. package/types/database/Model.d.ts +221 -0
  27. package/types/database/index.d.ts +4 -0
  28. package/types/database/loadModels.d.ts +6 -0
  29. package/types/exceptions/ApiError.d.ts +29 -0
  30. package/types/exceptions/index.d.ts +2 -0
  31. package/types/handlebars_helpers/comparison.d.ts +302 -0
  32. package/types/handlebars_helpers/date.d.ts +21 -0
  33. package/types/handlebars_helpers/html.d.ts +11 -0
  34. package/types/handlebars_helpers/index.d.ts +5 -0
  35. package/types/handlebars_helpers/object.d.ts +21 -0
  36. package/types/handlebars_helpers/string.d.ts +32 -0
  37. package/types/index.d.ts +9 -0
  38. package/types/interfaces/AuthenticationOptions.d.ts +97 -0
  39. package/types/interfaces/BoundingBox.d.ts +25 -0
  40. package/types/interfaces/Config.d.ts +66 -0
  41. package/types/interfaces/DatabaseOptions.d.ts +7 -0
  42. package/types/interfaces/FaceMatch.d.ts +31 -0
  43. package/types/interfaces/RekognitionOptions.d.ts +26 -0
  44. package/types/interfaces/ViewOptions.d.ts +30 -0
  45. package/types/interfaces/index.d.ts +8 -0
  46. package/types/middlewares/Authentication.d.ts +16 -0
  47. package/types/middlewares/CORS.d.ts +16 -0
  48. package/types/middlewares/Environment.d.ts +17 -0
  49. package/types/middlewares/ErrorHandling.d.ts +16 -0
  50. package/types/middlewares/Global.d.ts +13 -0
  51. package/types/middlewares/Http.d.ts +16 -0
  52. package/types/middlewares/Local.d.ts +20 -0
  53. package/types/middlewares/View.d.ts +16 -0
  54. package/types/middlewares/index.d.ts +8 -0
  55. package/types/mount.d.ts +7 -0
  56. package/types/package.d.ts +94 -0
  57. package/types/routing/Router.d.ts +19 -0
  58. package/types/routing/index.d.ts +2 -0
  59. package/types/services/AWSRekognitionClient.d.ts +359 -0
  60. package/types/services/Authentication.d.ts +39 -0
  61. package/types/services/RedisClient.d.ts +80 -0
  62. package/types/services/index.d.ts +3 -0
  63. package/types/utils/Types.d.ts +24 -0
  64. package/types/utils/index.d.ts +6 -0
  65. package/types/utils/isAsyncFunction.d.ts +12 -0
  66. package/types/utils/isObject.d.ts +8 -0
  67. package/types/utils/isString.d.ts +8 -0
  68. package/docs/images/all.jpg +0 -0
  69. package/docs/images/edit-user.png +0 -0
  70. package/docs/images/home.png +0 -0
  71. package/docs/images/login.png +0 -0
  72. package/docs/images/logo-dark.svg +0 -12
  73. package/docs/images/new-user.png +0 -0
  74. package/docs/images/user-list.png +0 -0
  75. package/docs/scripts/docs.js +0 -23
@@ -0,0 +1,30 @@
1
+ /**
2
+ * View's configuration interface.
3
+ */
4
+ export default interface {
5
+ /**
6
+ * Absolute path to the directory where the view files are located, defaults to `<application root directory>/views`.
7
+ * @type {string}
8
+ */
9
+ views_dir?: string;
10
+ /**
11
+ * Path to partials templates, one or several directories, defaults to `<application root directory>/views/partials`.
12
+ * @type {string|string[]}
13
+ */
14
+ partials_dir?: string | string[];
15
+ /**
16
+ * Path to layout templates, defaults to `<application root directory>/views/layout`.
17
+ * @type {string}
18
+ */
19
+ layouts_dir?: string;
20
+ /**
21
+ * Absolute path to default layout template. defaults to `<application root directory>/views/layout/default.hbs`.
22
+ * @type {string}
23
+ */
24
+ default_layout?: string;
25
+ /**
26
+ * Extension for templates & partials, defaults to `.hbs`,
27
+ * @type {string}
28
+ */
29
+ extension?: string;
30
+ }
@@ -0,0 +1,8 @@
1
+ import AuthenticationOptions from './AuthenticationOptions';
2
+ import Config from './Config';
3
+ import DatabaseOptions from './DatabaseOptions';
4
+ import FaceMatch from './FaceMatch';
5
+ import BoundingBox from './BoundingBox';
6
+ import RekognitionOptions from './RekognitionOptions';
7
+ import ViewOptions from './ViewOptions';
8
+ export { AuthenticationOptions, Config, DatabaseOptions, FaceMatch, BoundingBox, RekognitionOptions, ViewOptions };
@@ -0,0 +1,16 @@
1
+ import express from 'express';
2
+ /**
3
+ * Incorporate user authentication into your application.
4
+ */
5
+ export default class {
6
+ /**
7
+ * Mount on application.
8
+ */
9
+ static mount(app: express.Express): void;
10
+ /**
11
+ * Returns the option.
12
+ *
13
+ * @return {AuthenticationOptions} option.
14
+ */
15
+ private static loadOptions;
16
+ }
@@ -0,0 +1,16 @@
1
+ import express from 'express';
2
+ /**
3
+ * Enables the CORS.
4
+ */
5
+ export default class {
6
+ /**
7
+ * Mount on application.
8
+ */
9
+ static mount(app: express.Express): void;
10
+ /**
11
+ * Returns the option.
12
+ *
13
+ * @return {Config} option.
14
+ */
15
+ private static loadOptions;
16
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Set environment variables.
3
+ *
4
+ * Read the environment variable file in options.path and set it in "process.env".
5
+ */
6
+ export default class {
7
+ /**
8
+ * Mount on application.
9
+ */
10
+ static mount(): undefined;
11
+ /**
12
+ * Returns the option.
13
+ *
14
+ * @return {Config} option.
15
+ */
16
+ private static loadOptions;
17
+ }
@@ -0,0 +1,16 @@
1
+ import express from 'express';
2
+ /**
3
+ * Error handling.
4
+ */
5
+ export default class {
6
+ /**
7
+ * Mount on application.
8
+ */
9
+ static mount(app: express.Express): void;
10
+ /**
11
+ * Returns the option.
12
+ *
13
+ * @return {Config} option.
14
+ */
15
+ private static loadOptions;
16
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Set global variables.
3
+ * It can be accessed like "global.xxx" in all router and model classes.
4
+ *
5
+ * Below is a description of the variables.
6
+ * APP_DIR: The directory where app.js is located.
7
+ */
8
+ export default class {
9
+ /**
10
+ * Mount on application.
11
+ */
12
+ static mount(): void;
13
+ }
@@ -0,0 +1,16 @@
1
+ import express from 'express';
2
+ /**
3
+ * Defines all the requisites in HTTP.
4
+ */
5
+ export default class {
6
+ /**
7
+ * Mount on application.
8
+ */
9
+ static mount(app: express.Express): void;
10
+ /**
11
+ * Returns the option.
12
+ *
13
+ * @return {Config} option.
14
+ */
15
+ private static loadOptions;
16
+ }
@@ -0,0 +1,20 @@
1
+ import express from 'express';
2
+ /**
3
+ * Set local variables.
4
+ * It can be accessed in all views as {{var}} or {{{var}}}.
5
+ *
6
+ * Below is a description of the variables.
7
+ * baseUrl: The base URL for this application.
8
+ */
9
+ export default class {
10
+ /**
11
+ * Mount on application.
12
+ */
13
+ static mount(app: express.Express): void;
14
+ /**
15
+ * Returns the option.
16
+ *
17
+ * @return {Config} option.
18
+ */
19
+ private static loadOptions;
20
+ }
@@ -0,0 +1,16 @@
1
+ import express from 'express';
2
+ /**
3
+ * Enable Handlebars template engine.
4
+ */
5
+ export default class {
6
+ /**
7
+ * Mount on application.
8
+ */
9
+ static mount(app: express.Express): void;
10
+ /**
11
+ * Returns the option.
12
+ *
13
+ * @return {ViewOptions} option.
14
+ */
15
+ private static loadOptions;
16
+ }
@@ -0,0 +1,8 @@
1
+ import CORS from './CORS';
2
+ import Environment from './Environment';
3
+ import Global from './Global';
4
+ import Http from './Http';
5
+ import Local from './Local';
6
+ import View from './View';
7
+ import ErrorHandling from './ErrorHandling';
8
+ export { CORS, Environment, Global, Http, Local, View, ErrorHandling };
@@ -0,0 +1,7 @@
1
+ import express from 'express';
2
+ /**
3
+ * Mount extensions on your application.
4
+ *
5
+ * @param {express.Express} app Express application instance
6
+ */
7
+ export default function (app: express.Express): void;
@@ -0,0 +1,94 @@
1
+ export declare var name: string;
2
+ export declare var version: string;
3
+ export declare var description: string;
4
+ export declare var main: string;
5
+ export declare var module: string;
6
+ export declare var types: string;
7
+ export declare var files: string[];
8
+ export declare var scripts: {
9
+ watch: string;
10
+ prewatch: string;
11
+ build: string;
12
+ prebuild: string;
13
+ test: string;
14
+ start: string;
15
+ prestart: string;
16
+ };
17
+ export declare var _moduleAliases: {
18
+ "~": string;
19
+ };
20
+ export declare var repository: {
21
+ type: string;
22
+ url: string;
23
+ };
24
+ export declare var keywords: string[];
25
+ export declare var author: string;
26
+ export declare var license: string;
27
+ export declare var bugs: {
28
+ url: string;
29
+ email: string;
30
+ };
31
+ export declare var homepage: string;
32
+ export declare var dependencies: {
33
+ "aws-sdk": string;
34
+ "body-parser": string;
35
+ "class-transformer": string;
36
+ "class-validator": string;
37
+ "connect-redis": string;
38
+ "cookie-parser": string;
39
+ cors: string;
40
+ debug: string;
41
+ dotenv: string;
42
+ esm: string;
43
+ express: string;
44
+ "express-hbs": string;
45
+ "express-session": string;
46
+ "fs-extra": string;
47
+ glob: string;
48
+ hbs: string;
49
+ "http-errors": string;
50
+ ioredis: string;
51
+ mariadb: string;
52
+ "mime-types": string;
53
+ "module-alias": string;
54
+ moment: string;
55
+ morgan: string;
56
+ multer: string;
57
+ "nodejs-shared": string;
58
+ passport: string;
59
+ "passport-local": string;
60
+ redis: string;
61
+ "reflect-metadata": string;
62
+ sequelize: string;
63
+ uniqid: string;
64
+ };
65
+ export declare var devDependencies: {
66
+ "@types/aws-sdk": string;
67
+ "@types/connect-redis": string;
68
+ "@types/cookie-parser": string;
69
+ "@types/debug": string;
70
+ "@types/express": string;
71
+ "@types/express-session": string;
72
+ "@types/http-errors": string;
73
+ "@types/ioredis": string;
74
+ "@types/jest": string;
75
+ "@types/multer": string;
76
+ "@types/node": string;
77
+ "@types/passport": string;
78
+ "@types/passport-local": string;
79
+ "@types/validator": string;
80
+ jest: string;
81
+ json2module: string;
82
+ rollup: string;
83
+ "rollup-plugin-commonjs": string;
84
+ "rollup-plugin-json": string;
85
+ "rollup-plugin-node-resolve": string;
86
+ "rollup-plugin-terser": string;
87
+ "rollup-plugin-typescript2": string;
88
+ "ts-loader": string;
89
+ "ts-node": string;
90
+ "tsc-alias": string;
91
+ "tsconfig-paths": string;
92
+ tslint: string;
93
+ typescript: string;
94
+ };
@@ -0,0 +1,19 @@
1
+ import express from 'express';
2
+ /**
3
+ * Set up URL routing.
4
+ *
5
+ * Define URL routing based on the path of the file in the routes directory.
6
+ * For example, if you have "routes/api/users.js", you can request the method in "user.js (ts)" with the base URL as "https:////api/users".
7
+ */
8
+ export default class {
9
+ /**
10
+ * Mount on application.
11
+ */
12
+ static mount(app: express.Express): void;
13
+ /**
14
+ * Returns the option.
15
+ *
16
+ * @return {Config} option.
17
+ */
18
+ private static loadOptions;
19
+ }
@@ -0,0 +1,2 @@
1
+ import Router from './Router';
2
+ export { Router };
@@ -0,0 +1,359 @@
1
+ import RekognitionOptions from '~/interfaces/RekognitionOptions';
2
+ import FaceMatch from '~/interfaces/FaceMatch';
3
+ import BoundingBox from '~/interfaces/BoundingBox';
4
+ /**
5
+ * AWS Rekognition Client.
6
+ */
7
+ export default class {
8
+ /**
9
+ * Rekognition client instance.
10
+ * @type {AWS.Rekognition}
11
+ */
12
+ private client;
13
+ /**
14
+ * Constructs a rekognition client object.
15
+ */
16
+ constructor(options: RekognitionOptions);
17
+ /**
18
+ * Detects faces within an image that is provided as input.
19
+ * For each face detected, the operation returns a bounding box of the face.
20
+ *
21
+ * @example
22
+ * const AWSRekognitionClient = require('express-sweet').services.AWSRekognitionClient;
23
+ * const fs = require('fs');
24
+ *
25
+ * // Instantiate Rekognition client.
26
+ * const client = new AWSRekognitionClient({
27
+ * accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
28
+ * secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
29
+ * region: process.env.AWS_REKOGNITION_REGION
30
+ * });
31
+ *
32
+ * // Detect faces from path.
33
+ * // Output: [
34
+ * // {
35
+ * // width: 0.5004957914352417,
36
+ * // height: 0.6926820874214172,
37
+ * // left: 0.2928674817085266,
38
+ * // top: 0.09095800668001175
39
+ * // }
40
+ * // ]
41
+ * await client.detectFaces('img.jpg');
42
+ *
43
+ * // Detect faces from data URL.
44
+ * await client.detectFaces('data:image/png;base64,/9j/4...');
45
+ *
46
+ * // Detect faces from buffer.
47
+ * await client.detectFaces(fs.readFileSync('img.jpg'));
48
+ *
49
+ * @param {string} img Image path or Data Url or image buffer.
50
+ * @param {number} minConfidence The minimum confidence of the detected face.
51
+ * Faces with a confidence lower than this value will not be returned as a result.
52
+ * @return {Promise<BoundingBox[]>} Returns the bounding box of the detected face.
53
+ */
54
+ detectFaces(img: string, minConfidence?: number): Promise<BoundingBox[]>;
55
+ /**
56
+ * Compare the similarity of two faces.
57
+ *
58
+ * @example
59
+ * const AWSRekognitionClient = require('express-sweet').services.AWSRekognitionClient;
60
+ * const fs = require('fs');
61
+ *
62
+ * // Instantiate Rekognition client.
63
+ * const client = new AWSRekognitionClient({
64
+ * accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
65
+ * secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
66
+ * region: process.env.AWS_REKOGNITION_REGION
67
+ * });
68
+ *
69
+ * // Compare faces from path.
70
+ * await client.compareFaces('img1.jpg', 'img2.jpg');
71
+ *
72
+ * // Compare faces from data URL.
73
+ * await client.compareFaces('data:image/png;base64,/9j/4...', 'data:image/png;base64,/9j/4...');
74
+ *
75
+ * // Compare faces from buffer.
76
+ * await client.compareFaces(fs.readFileSync('img1.jpg'), fs.readFileSync('img1.jpg'));
77
+ *
78
+ * @param {string} img1 Image path or Data Url or image buffer.
79
+ * @param {string} img2 Image path or Data Url or image buffer.
80
+ * @return {Promise<number>} Level of confidence that the faces match.
81
+ */
82
+ compareFaces(img1: string, img2: string): Promise<number>;
83
+ /**
84
+ * Add faces to the collection using the IndexFaces operation.
85
+ * For example, you might create collections, one for each of your application users.
86
+ * A user can then index faces using the IndexFaces operation and persist results in a specific collection.
87
+ * Then, a user can search the collection for faces in the user-specific container.
88
+ * Note that Collection names are case-sensitive.
89
+ *
90
+ * @example
91
+ * const AWSRekognitionClient = require('express-sweet').services.AWSRekognitionClient;
92
+ *
93
+ * // Instantiate Rekognition client.
94
+ * const client = new AWSRekognitionClient({
95
+ * accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
96
+ * secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
97
+ * region: process.env.AWS_REKOGNITION_REGION
98
+ * });
99
+ *
100
+ * try {
101
+ * // Creates a collection.
102
+ * await client.createCollection('MyCollection');
103
+ * } catch(err) {
104
+ * // You can get the resulting HTTP status code from the exception.
105
+ * console.log(`name: ${err.name}`);
106
+ * console.log(`statusCode: ${err.statusCode}`);
107
+ * console.log(`message: ${err.message}`);
108
+ * }
109
+ *
110
+ * @param {string} collectionId ID for the collection that you are creating.
111
+ * The maximum length is 255, and the characters that can be used are "[a-zA-Z0-9_.\-]+".
112
+ */
113
+ createCollection(collectionId: string): Promise<void>;
114
+ /**
115
+ * Returns list of collection IDs.
116
+ *
117
+ * @example
118
+ * const AWSRekognitionClient = require('express-sweet').services.AWSRekognitionClient;
119
+ *
120
+ * // Instantiate Rekognition client.
121
+ * const client = new AWSRekognitionClient({
122
+ * accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
123
+ * secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
124
+ * region: process.env.AWS_REKOGNITION_REGION
125
+ * });
126
+ *
127
+ * // Find the collection IDs.
128
+ * // Output: [
129
+ * // 'MyCollection',
130
+ * // 'AnotherCollection'
131
+ * // ]
132
+ * await client.listCollections();
133
+ *
134
+ * @return {Promise<string[]>} An array of collection IDs.
135
+ */
136
+ listCollections(): Promise<string[]>;
137
+ /**
138
+ * Detects one face in the input image and adds it to the specified collection.
139
+ * This method doesn't save the actual faces that are detected.
140
+ * Instead, the underlying detection algorithm first detects the faces in the input image.
141
+ * The algorithm extracts facial features into a feature vector, and stores it in the backend database.
142
+ *
143
+ * Note that this method is used to index one face.
144
+ * Throws an exception if no face is found in the input image or multiple faces are found.
145
+ *
146
+ * @example
147
+ * const AWSRekognitionClient = require('express-sweet').services.AWSRekognitionClient;
148
+ * const fs = require('fs');
149
+ *
150
+ * // Instantiate Rekognition client.
151
+ * const client = new AWSRekognitionClient({
152
+ * accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
153
+ * secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
154
+ * region: process.env.AWS_REKOGNITION_REGION
155
+ * });
156
+ *
157
+ * // Add face to collection from path.
158
+ * // Output: df8adc94-e888-4442-a03d-42aacd4a6cee
159
+ * const faceId = await client.indexFace('MyCollection', 'img.jpg', 'img.jpg');
160
+ * console.log(faceId);
161
+ *
162
+ * // Add face to collection from data URL.
163
+ * // Output: df8adc94-e888-4442-a03d-42aacd4a6cee
164
+ * const faceId = await client.indexFace('MyCollection', 'data:image/png;base64,/9j/4...', 'img.jpg');
165
+ * console.log(faceId);
166
+ *
167
+ * // Add face to collection from buffer.
168
+ * // Output: df8adc94-e888-4442-a03d-42aacd4a6cee
169
+ * const faceId = await client.indexFace('MyCollection', fs.readFileSync('img.jpg'), 'img.jpg');
170
+ * console.log(faceId);
171
+ *
172
+ * // If the face is not found in the image, throw an error.
173
+ * // Output: name: IndexFaceFaceNotFound
174
+ * // statusCode: 400
175
+ * // message: No face was found in the image
176
+ * try {
177
+ * await client.indexFace('MyCollection', 'img.jpg');
178
+ * } catch(err) {
179
+ * // You can get the resulting HTTP status code from the exception.
180
+ * console.log(`name: ${err.name}`);
181
+ * console.log(`statusCode: ${err.statusCode}`);
182
+ * console.log(`message: ${err.message}`);
183
+ * }
184
+ *
185
+ * // If multiple faces are found in the image, throw an error.
186
+ * // Output: name: IndexFaceMultipleFacesFound
187
+ * // statusCode: 400
188
+ * // message: Multiple faces found in the image
189
+ * try {
190
+ * await client.indexFace('MyCollection', 'img.jpg');
191
+ * } catch(err) {
192
+ * // You can get the resulting HTTP status code from the exception.
193
+ * console.log(`name: ${err.name}`);
194
+ * console.log(`statusCode: ${err.statusCode}`);
195
+ * console.log(`message: ${err.message}`);
196
+ * }
197
+ *
198
+ * @param {string} collectionId The ID of an existing collection to which you want to add the faces that are detected in the input images.
199
+ * @param {string} img Image path or Data Url or image buffer.
200
+ * @param {string} externalImageId The ID you want to assign to the faces detected in the image.
201
+ * When you call the "listFaces" operation, the response returns the external ID.
202
+ * You can use this external image ID to create a client-side index to associate the faces with each image.
203
+ * You can then use the index to find all faces in an image.
204
+ * The maximum length is 255, and the characters that can be used are "[a-zA-Z0-9_.\-:]+".
205
+ * @return {Promise<string>} A unique identifier assigned to the face.
206
+ */
207
+ indexFace(collectionId: string, img: string, externalImageId?: string): Promise<string>;
208
+ /**
209
+ * For a given input image, first detects the largest face in the image, and then searches the specified collection for matching faces.
210
+ * The operation compares the features of the input face with faces in the specified collection.
211
+ *
212
+ * @example
213
+ * const AWSRekognitionClient = require('express-sweet').services.AWSRekognitionClient;
214
+ * const fs = require('fs');
215
+ *
216
+ * // Instantiate Rekognition client.
217
+ * const client = new AWSRekognitionClient({
218
+ * accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
219
+ * secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
220
+ * region: process.env.AWS_REKOGNITION_REGION
221
+ * });
222
+ *
223
+ * // If you want to search for one face, specify 1 for the maxFaces option.
224
+ * // In that case, the search result will return the face data for one person.
225
+ * // Output: {
226
+ * // faceId: '2ce7f471-9c4b-4f27-b5a4-bbd02a5e134d',
227
+ * // boundingBox: {
228
+ * // width: 0.500495970249176,
229
+ * // height: 0.6926820278167725,
230
+ * // left: 0.2928670048713684,
231
+ * // top: 0.09095799922943115
232
+ * // },
233
+ * // externalImageId: 'img.jpg'
234
+ * // }
235
+ * const match = await client.searchFaces('MyCollection', 'img.jpg', {minConfidence: 99, maxFaces: 1});
236
+ * console.log(match);
237
+ *
238
+ * // If you want to search for multiple faces, specify 2 or more for the maxFaces option.
239
+ * // In that case, the search results will return a list of the face data of multiple people found.
240
+ * // Output: [
241
+ * // {
242
+ * // faceId: '2ce7f471-9c4b-4f27-b5a4-bbd02a5e134d',
243
+ * // boundingBox: {
244
+ * // width: 0.500495970249176,
245
+ * // height: 0.6926820278167725,
246
+ * // left: 0.2928670048713684,
247
+ * // top: 0.09095799922943115
248
+ * // },
249
+ * // externalImageId: 'img.jpg'
250
+ * // }
251
+ * // ]
252
+ * const matches = await client.searchFaces('MyCollection', 'img.jpg', {minConfidence: 99, maxFaces: 5});
253
+ * console.log(matches);
254
+ *
255
+ * // The input image can specify a buffer or DataURL in addition to the image path.
256
+ * await client.searchFaces('MyCollection', 'data:image/png;base64,/9j/4...');
257
+ * await client.searchFaces('MyCollection', fs.readFileSync('img.jpg'));
258
+ *
259
+ * @param {string} collectionId ID of the collection to search.
260
+ * @param {string} img Image path or Data Url or image buffer.
261
+ * @param {object} options option.
262
+ * @param {number} options.minConfidence Specifies the minimum confidence in the face match to return.
263
+ * The default value is 80%.
264
+ * @param {number} options.maxFaces Maximum number of faces to return.
265
+ * The operation returns the maximum number of faces with the highest confidence in the match.
266
+ * The default value is 5.
267
+ * @return {Promise<FaceMatch[]|FaceMatch|null>} If options.maxFaces is 1, the face information found is returned.
268
+ * If options.maxFaces is 2 or more, the list of face information found is returned.
269
+ * Returns null if no face is found.
270
+ */
271
+ searchFaces(collectionId: string, img: string, options?: {
272
+ minConfidence?: number;
273
+ maxFaces?: number;
274
+ }): Promise<FaceMatch[] | FaceMatch | null>;
275
+ /**
276
+ * Returns metadata for faces in the specified collection.
277
+ * This metadata includes information such as the bounding box coordinates, and face ID.
278
+ *
279
+ * @example
280
+ * const AWSRekognitionClient = require('express-sweet').services.AWSRekognitionClient;
281
+ * const fs = require('fs');
282
+ *
283
+ * // Instantiate Rekognition client.
284
+ * const client = new AWSRekognitionClient({
285
+ * accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
286
+ * secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
287
+ * region: process.env.AWS_REKOGNITION_REGION
288
+ * });
289
+ *
290
+ * // Find all face metadata in the collection.
291
+ * // Output: [
292
+ * // {
293
+ * // faceId: '2ce7f471-9c4b-4f27-b5a4-bbd02a5e134d',
294
+ * // boundingBox: {
295
+ * // width: 0.500495970249176,
296
+ * // height: 0.6926820278167725,
297
+ * // left: 0.2928670048713684,
298
+ * // top: 0.09095799922943115
299
+ * // },
300
+ * // externalImageId: 'img.jpg'
301
+ * // }
302
+ * // ]
303
+ * const result = await client.listFaces('MyCollection');
304
+ * console.log(result);
305
+ *
306
+ * @param {string} collectionId ID of the collection from which to list the faces.
307
+ * @param {number} maxResults Maximum number of faces to return.
308
+ * The default value is 1000.
309
+ * @return {Promise<FaceMatch[]>} Returns all face metadata in the collection.
310
+ */
311
+ listFaces(collectionId: string, maxResults?: number): Promise<FaceMatch[]>;
312
+ /**
313
+ * Deletes faces from a collection.
314
+ * You specify a collection ID and an array of face IDs to remove from the collection.
315
+ *
316
+ * @example
317
+ * const AWSRekognitionClient = require('express-sweet').services.AWSRekognitionClient;
318
+ *
319
+ * // Instantiate Rekognition client.
320
+ * const client = new AWSRekognitionClient({
321
+ * accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
322
+ * secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
323
+ * region: process.env.AWS_REKOGNITION_REGION
324
+ * });
325
+ *
326
+ * // Delete a face from the collection.
327
+ * await client.deleteFaces('MyCollection', ['f7befa24-3b83-43cc-b21f-7fac4b91f51d']);
328
+ *
329
+ * @param {string} collectionId Collection from which to remove the specific faces.
330
+ * @param {string[]} faceIds An array of face IDs to delete.
331
+ */
332
+ deleteFaces(collectionId: string, faceIds: string[]): Promise<void>;
333
+ /**
334
+ * Deletes the specified collection.
335
+ * Note that this operation removes all faces in the collection.
336
+ *
337
+ * @example
338
+ * const AWSRekognitionClient = require('express-sweet').services.AWSRekognitionClient;
339
+ *
340
+ * // Instantiate Rekognition client.
341
+ * const client = new AWSRekognitionClient({
342
+ * accessKeyId: process.env.AWS_REKOGNITION_ACCESS_KEY_ID,
343
+ * secretAccessKey: process.env.AWS_REKOGNITION_SECRET_ACCESS_KEY,
344
+ * region: process.env.AWS_REKOGNITION_REGION
345
+ * });
346
+ *
347
+ * // Delete collection.
348
+ * await client.deleteCollection('MyCollection');
349
+ *
350
+ * @param {string} collectionId ID of the collection to delete.
351
+ */
352
+ deleteCollection(collectionId: string): Promise<void>;
353
+ /**
354
+ * Returns a buffer of images..
355
+ * @param {string|Buffer} img Image path or Data Url or image buffer.
356
+ * @return {Buffer} Image buffer.
357
+ */
358
+ private getImageBuffer;
359
+ }