express-sweet 1.0.9 → 1.0.13

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.
@@ -4,13 +4,9 @@
4
4
  line-height: 1.0;
5
5
  }
6
6
 
7
- body {
8
- font-size: 13px;
9
- }
10
-
11
7
  .topnav {
12
8
  padding: .75rem 0;
13
- background-color: #6b00b1;
9
+ background-color: hsl(202deg, 100%, 39%);
14
10
  }
15
11
 
16
12
  .topnav .navbar-toggler {
@@ -28,10 +24,22 @@ body {
28
24
  }
29
25
 
30
26
  .topnav .navbar-nav-svg {
31
- width: 1rem;
32
- height: 1rem
27
+ width: 1.5rem;
28
+ height: 1.5rem
33
29
  }
34
30
 
31
+ .min-w-150px {
32
+ min-width: 150px;
33
+ }
34
+
35
+ .min-w-200px {
36
+ min-width: 200px;
37
+ }
38
+
39
+ .min-w-300px {
40
+ min-width: 300px;
41
+ }
42
+
35
43
  ul li,
36
44
  ol li {
37
45
  margin-bottom: .25rem
@@ -50,18 +58,6 @@ table {
50
58
  }
51
59
  }
52
60
 
53
- table.summary tbody td:nth-child(1) {
54
- min-width: 150px;
55
- }
56
-
57
- table.summary tbody td:nth-last-child(1) {
58
- min-width: 200px;
59
- }
60
-
61
- th {
62
- white-space: nowrap;
63
- }
64
-
65
61
  .h1,.h2,.h3,.h4,.h5,.h6,h1,h2,h3,h4,h5, h6 {
66
62
  line-height: unset;
67
63
  }
@@ -131,20 +127,14 @@ h4 {
131
127
  margin-top: .125rem;
132
128
  margin-left: 1.25rem;
133
129
  width: fit-content;
134
- color: rgba(0,0,0,0.65);
130
+ color: hsl(202deg, 100%, 20%);
135
131
  text-decoration: none;
136
132
  }
137
133
 
138
134
  .sidenav a:hover,
139
- .sidenav a:focus {
140
- color: rgba(0,0,0,0.85);
141
- background-color: rgba(121,82,179,0.1);
142
- }
143
-
144
135
  .sidenav .nav-link.active {
145
136
  font-weight: 600;
146
- color: #b66dff;
147
- /* color: #0d6efd; */
137
+ color: #0d6efd;
148
138
  background-color: transparent;
149
139
  }
150
140
 
@@ -265,46 +255,12 @@ h4 {
265
255
  margin-bottom: 0
266
256
  }
267
257
 
268
- .callout code {
269
- border-radius: .25rem
270
- }
271
-
272
258
  .callout+.callout {
273
259
  margin-top: -.25rem
274
260
  }
275
261
 
276
- code:not(.hljs),
277
- .code {
278
- /* font-family: Source Code Pro,Consolas,Liberation Mono,Menlo,Courier,monospace; */
279
- font-size: 1em;
280
- color: #d63384;
281
- word-wrap: break-word;
282
- font-style: normal;
283
- background-color: rgba(70,94,105,.05);
284
- text-shadow: 0 1px 0 hsl(0deg 0% 100% / 60%);
285
- }
286
-
287
- .method,
288
- .member {
289
- padding: 6px 10px;
290
- width: fit-content;
291
- background: #E8F4FF;
292
- color: #212529;
293
- font-size: 1.1rem;
294
- font-family: Monaco, Consolas, Courier, monospace;
295
- }
296
-
297
262
  .hljs {
298
- border-radius: .5em;
299
- background: #2e2e42;
300
- }
301
-
302
- .hljs-comment {
303
- color: #9e8f9e;
304
- }
305
-
306
- .text-primary {
307
- color: #b66dff !important;
263
+ background: #f8f9fa;
308
264
  }
309
265
 
310
266
  .example {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-sweet",
3
- "version": "1.0.9",
3
+ "version": "1.0.13",
4
4
  "description": "Extend Express functionality with Express Sweet and start developing fast, minimal web applications.",
5
5
  "main": "dist/build.common.js",
6
6
  "module": "dist/build.esm.js",
@@ -17,11 +17,22 @@ export default class Model extends sequelize.Model {
17
17
  protected static attributes: sequelize.ModelAttributes;
18
18
  /**
19
19
  * Column type.
20
+ *
21
+ * @see https://sequelize.org/master/variable/index.html#static-variable-DataTypes
20
22
  * @type {sequelize.DataTypes}
21
23
  */
22
24
  static readonly DataTypes: {
23
25
  [key: string]: any;
24
26
  };
27
+ /**
28
+ * An enum of query types used by sequelize.query
29
+ *
30
+ * @see https://sequelize.org/master/variable/index.html#static-variable-QueryTypes
31
+ * @type {sequelize.QueryTypes}
32
+ */
33
+ static readonly QueryTypes: {
34
+ [key: string]: string;
35
+ };
25
36
  /**
26
37
  * Operator.
27
38
  *
@@ -29,8 +40,8 @@ export default class Model extends sequelize.Model {
29
40
  * // Sequelize provides several operators.
30
41
  * Post.findAll({
31
42
  * where: {
32
- * [this.Op.and]: [{ a: 5 }, { b: 6 }], // (a = 5) AND (b = 6)
33
- * [this.Op.or]: [{ a: 5 }, { b: 6 }], // (a = 5) OR (b = 6)
43
+ * [this.Op.and]: [{a: 5}, {b: 6}], // (a = 5) AND (b = 6)
44
+ * [this.Op.or]: [{a: 5}, {b: 6}], // (a = 5) OR (b = 6)
34
45
  * someAttribute: {
35
46
  * // Basics
36
47
  * [this.Op.eq]: 3, // = 3
@@ -67,7 +78,7 @@ export default class Model extends sequelize.Model {
67
78
  * [this.Op.notIRegexp]: '^[h|a|t]', // !~* '^[h|a|t]' (PG only)
68
79
  * [this.Op.any]: [2, 3], // ANY ARRAY[2, 3]::INTEGER (PG only)
69
80
  * // In Postgres, this.Op.like/this.Op.iLike/this.Op.notLike can be combined to this.Op.any:
70
- * [this.Op.like]: { [this.Op.any]: ['cat', 'hat'] } // LIKE ANY ARRAY['cat', 'hat']
81
+ * [this.Op.like]: {[this.Op.any]: ['cat', 'hat']} // LIKE ANY ARRAY['cat', 'hat']
71
82
  * // There are more postgres-only range operators, see below
72
83
  * }
73
84
  * }
@@ -111,6 +122,20 @@ export default class Model extends sequelize.Model {
111
122
  * @type {sequelize.where}
112
123
  */
113
124
  static readonly where: (attr: sequelize.AttributeType, comparator: string, logic: sequelize.LogicType) => sequelize.Utils.Where;
125
+ /**
126
+ * Reference to sequelize.Transaction.
127
+ * This includes properties such as isolation level enums used with the transaction option.
128
+ *
129
+ * @example
130
+ * BookModel.Transaction.ISOLATION_LEVELS.READ_UNCOMMITTED // "READ UNCOMMITTED"
131
+ * BookModel.Transaction.ISOLATION_LEVELS.READ_COMMITTED // "READ COMMITTED"
132
+ * BookModel.Transaction.ISOLATION_LEVELS.REPEATABLE_READ // "REPEATABLE READ"
133
+ * BookModel.Transaction.ISOLATION_LEVELS.SERIALIZABLE // "SERIALIZABLE"
134
+ *
135
+ * @see https://sequelize.org/master/class/lib/transaction.js~Transaction.html
136
+ * @type {sequelize.Transaction}
137
+ */
138
+ static readonly Transaction: (typeof sequelize.Transaction);
114
139
  /**
115
140
  * Initialize the model that represents the table in the DB with attributes and options.
116
141
  * This method is called automatically from within the "express-sweet.mount" method, so you don't have to run it yourself.
@@ -131,28 +156,66 @@ export default class Model extends sequelize.Model {
131
156
  * Starts a transaction and returns a transaction object to identify the running transaction.
132
157
  *
133
158
  * @example
134
- * // First, we start a transaction and save it into a variable
135
- * const t = await SampleModel.begin();
159
+ * // Simple transaction usage example.
160
+ * let transaction;
161
+ * try {
162
+ * transaction = await BookModel.begin();
163
+ * const book = await BookModel.create({title: 'When Im Gone'}, {transaction});
164
+ * await transaction.commit();
165
+ * } catch(error) {
166
+ * if (transaction)
167
+ * await transaction.rollback();
168
+ * }
136
169
  *
170
+ * // You can also use transaction options.
171
+ * let transaction;
137
172
  * try {
138
- * // Then, we do some calls passing this transaction as an option:
139
- * const user = await SampleModel.create({ name: 'Bart' }, { transaction: t });
140
- *
141
- * // If the execution reaches this line, no errors were thrown.
142
- * // We commit the transaction.
143
- * await t.commit();
144
- * } catch (error) {
145
- * // If the execution reaches this line, an error was thrown.
146
- * // We rollback the transaction.
147
- * await t.rollback();
173
+ * transaction = await BookModel.begin({
174
+ * isolationLevel: BookModel.Transaction.ISOLATION_LEVELS.REPEATABLE_READ,
175
+ * type: BookModel.Transaction.TYPES.DEFERRED,
176
+ * });
177
+ * const book = await BookModel.findOne({where: {id: 1}}, {transaction});
178
+ * book.title = 'When Im Gone';
179
+ * await book.save({transaction});
180
+ * await transaction.commit();
181
+ *
182
+ * // Check the update result.
183
+ * // Output: New title of book: When Im Gone
184
+ * await book.reload();
185
+ * console.log(`New title of book: ${book.title}`);
186
+ * } catch (err) {
187
+ * if (transaction)
188
+ * await transaction.rollback();
148
189
  * }
149
- * @see https://sequelize.org/master/manual/transactions.html
150
190
  *
151
- * @return {Promise<sequelize.Transaction>} Returns a transaction object to identify the transaction being executed.
191
+ * @see https://sequelize.org/master/manual/transactions.html
192
+ * @param {sequelize.TransactionOptions} opts? Options provided when the transaction is created.
193
+ * @return {Promise<sequelize.Transaction>} Returns a transaction object to identify the transaction being executed.
152
194
  */
153
- static begin(): Promise<sequelize.Transaction>;
195
+ static begin(opts?: sequelize.TransactionOptions): Promise<sequelize.Transaction>;
154
196
  /**
155
197
  * Returns data that matches the ID.
156
198
  */
157
199
  static findById(id: number): Promise<{} | null>;
200
+ /**
201
+ * Raw Queries.
202
+ * As there are often use cases in which it is just easier to execute raw / already prepared SQL queries, you can use the Model.query method.
203
+ *
204
+ * @example
205
+ * // By default the function will return two arguments - a results array, and an object containing metadata (such as amount of affected rows, etc).
206
+ * // Note that since this is a raw query, the metadata are dialect specific.
207
+ * const [results, metadata] = await BookModel.query("UPDATE book SET title = 'When Im Gone' WHERE id = 1");
208
+ *
209
+ * // In cases where you don't need to access the metadata you can pass in a query type to tell sequelize how to format the results. For example, for a simple select query you could do:
210
+ * // We didn't need to destructure the result here - the results were returned directly
211
+ * const users = await BookModel.query("SELECT * FROM book", {type: BookModel.QueryTypes.SELECT});
212
+ *
213
+ * @see https://sequelize.org/master/manual/raw-queries.html
214
+ *
215
+ * @param {string} sql SQL string.
216
+ * @param {object} opts Query options.
217
+ * @return {Promise<any>} By default, the function will return two arguments: an array of results, and a metadata object, containing number of affected rows etc.
218
+ * If you are running a type of query where you don't need the metadata, for example a SELECT query, you can pass in a query type to make sequelize format the results:
219
+ */
220
+ static query(sql: string, opts: sequelize.QueryOptionsWithType<sequelize.QueryTypes.UPDATE> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.BULKUPDATE> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.INSERT> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.UPSERT> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.DELETE> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.BULKDELETE> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.SHOWTABLES> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.DESCRIBE> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.SELECT> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.SELECT> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.RAW> | sequelize.QueryOptionsWithType<sequelize.QueryTypes.RAW>): Promise<any>;
158
221
  }
@@ -22,4 +22,10 @@ export default interface {
22
22
  * @type {string}
23
23
  */
24
24
  externalImageId?: string;
25
+ /**
26
+ * Confidence in the match of this face with the input face.
27
+ * Valid Range: Minimum value of 0. Maximum value of 100.
28
+ * @type {number}
29
+ */
30
+ similarity?: number;
25
31
  }
@@ -7,7 +7,7 @@ export default class {
7
7
  /**
8
8
  * Mount on application.
9
9
  */
10
- static mount(): void;
10
+ static mount(): undefined;
11
11
  /**
12
12
  * Returns the option.
13
13
  *
@@ -13,7 +13,7 @@ export default class {
13
13
  /**
14
14
  * Constructs a rekognition client object.
15
15
  */
16
- constructor(options: RekognitionOptions);
16
+ constructor(opts: RekognitionOptions);
17
17
  /**
18
18
  * Detects faces within an image that is provided as input.
19
19
  * For each face detected, the operation returns a bounding box of the face.
@@ -100,11 +100,11 @@ export default class {
100
100
  * try {
101
101
  * // Creates a collection.
102
102
  * await client.createCollection('MyCollection');
103
- * } catch (e) {
103
+ * } catch(err) {
104
104
  * // You can get the resulting HTTP status code from the exception.
105
- * console.log(`name: ${e.name}`);
106
- * console.log(`statusCode: ${e.statusCode}`);
107
- * console.log(`message: ${e.message}`);
105
+ * console.log(`name: ${err.name}`);
106
+ * console.log(`statusCode: ${err.statusCode}`);
107
+ * console.log(`message: ${err.message}`);
108
108
  * }
109
109
  *
110
110
  * @param {string} collectionId ID for the collection that you are creating.
@@ -175,11 +175,11 @@ export default class {
175
175
  * // message: No face was found in the image
176
176
  * try {
177
177
  * await client.indexFace('MyCollection', 'img.jpg');
178
- * } catch (e) {
178
+ * } catch(err) {
179
179
  * // You can get the resulting HTTP status code from the exception.
180
- * console.log(`name: ${e.name}`);
181
- * console.log(`statusCode: ${e.statusCode}`);
182
- * console.log(`message: ${e.message}`);
180
+ * console.log(`name: ${err.name}`);
181
+ * console.log(`statusCode: ${err.statusCode}`);
182
+ * console.log(`message: ${err.message}`);
183
183
  * }
184
184
  *
185
185
  * // If multiple faces are found in the image, throw an error.
@@ -188,11 +188,11 @@ export default class {
188
188
  * // message: Multiple faces found in the image
189
189
  * try {
190
190
  * await client.indexFace('MyCollection', 'img.jpg');
191
- * } catch (e) {
191
+ * } catch(err) {
192
192
  * // You can get the resulting HTTP status code from the exception.
193
- * console.log(`name: ${e.name}`);
194
- * console.log(`statusCode: ${e.statusCode}`);
195
- * console.log(`message: ${e.message}`);
193
+ * console.log(`name: ${err.name}`);
194
+ * console.log(`statusCode: ${err.statusCode}`);
195
+ * console.log(`message: ${err.message}`);
196
196
  * }
197
197
  *
198
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.
@@ -268,7 +268,7 @@ export default class {
268
268
  * If options.maxFaces is 2 or more, the list of face information found is returned.
269
269
  * Returns null if no face is found.
270
270
  */
271
- searchFaces(collectionId: string, img: string, options?: {
271
+ searchFaces(collectionId: string, img: string, opts?: {
272
272
  minConfidence?: number;
273
273
  maxFaces?: number;
274
274
  }): Promise<FaceMatch[] | FaceMatch | null>;
@@ -76,5 +76,5 @@ export default class extends IORedis.Redis {
76
76
  * const unixSocketRedis = new RedisClient({path: "/tmp/echo.sock"});
77
77
  * const redis = new RedisClient({host: 'localhost', port: 6379});
78
78
  */
79
- constructor(options: IORedis.IRedisOptions);
79
+ constructor(opts: IORedis.IRedisOptions);
80
80
  }