express-sweet 1.0.12 → 1.0.16

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.
@@ -6,7 +6,7 @@
6
6
 
7
7
  .topnav {
8
8
  padding: .75rem 0;
9
- background-color: hsl(267deg, 42%, 29%);
9
+ background-color: hsl(202deg, 100%, 39%);
10
10
  }
11
11
 
12
12
  .topnav .navbar-toggler {
@@ -24,8 +24,8 @@
24
24
  }
25
25
 
26
26
  .topnav .navbar-nav-svg {
27
- width: 1rem;
28
- height: 1rem
27
+ width: 1.5rem;
28
+ height: 1.5rem
29
29
  }
30
30
 
31
31
  .min-w-150px {
@@ -127,7 +127,7 @@ h4 {
127
127
  margin-top: .125rem;
128
128
  margin-left: 1.25rem;
129
129
  width: fit-content;
130
- color: hsl(267deg, 42%, 29%);
130
+ color: hsl(202deg, 100%, 20%);
131
131
  text-decoration: none;
132
132
  }
133
133
 
@@ -260,14 +260,9 @@ h4 {
260
260
  }
261
261
 
262
262
  .hljs {
263
- border-radius: .5em;
264
- background: #2e2e42;
263
+ background: #f8f9fa;
265
264
  }
266
265
 
267
- .hljs-comment {
268
- color: #9e8f9e;
269
- }
270
-
271
266
  .example {
272
267
  margin-bottom: 1rem;
273
268
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-sweet",
3
- "version": "1.0.12",
3
+ "version": "1.0.16",
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",
@@ -40,8 +40,8 @@ export default class Model extends sequelize.Model {
40
40
  * // Sequelize provides several operators.
41
41
  * Post.findAll({
42
42
  * where: {
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)
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)
45
45
  * someAttribute: {
46
46
  * // Basics
47
47
  * [this.Op.eq]: 3, // = 3
@@ -78,7 +78,7 @@ export default class Model extends sequelize.Model {
78
78
  * [this.Op.notIRegexp]: '^[h|a|t]', // !~* '^[h|a|t]' (PG only)
79
79
  * [this.Op.any]: [2, 3], // ANY ARRAY[2, 3]::INTEGER (PG only)
80
80
  * // In Postgres, this.Op.like/this.Op.iLike/this.Op.notLike can be combined to this.Op.any:
81
- * [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']
82
82
  * // There are more postgres-only range operators, see below
83
83
  * }
84
84
  * }
@@ -122,6 +122,20 @@ export default class Model extends sequelize.Model {
122
122
  * @type {sequelize.where}
123
123
  */
124
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);
125
139
  /**
126
140
  * Initialize the model that represents the table in the DB with attributes and options.
127
141
  * This method is called automatically from within the "express-sweet.mount" method, so you don't have to run it yourself.
@@ -142,26 +156,43 @@ export default class Model extends sequelize.Model {
142
156
  * Starts a transaction and returns a transaction object to identify the running transaction.
143
157
  *
144
158
  * @example
145
- * // First, we start a transaction and save it into a variable
146
- * 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
+ * }
147
169
  *
170
+ * // You can also use transaction options.
171
+ * let transaction;
148
172
  * try {
149
- * // Then, we do some calls passing this transaction as an option:
150
- * const user = await SampleModel.create({ name: 'Bart' }, { transaction: t });
151
- *
152
- * // If the execution reaches this line, no errors were thrown.
153
- * // We commit the transaction.
154
- * await t.commit();
155
- * } catch (error) {
156
- * // If the execution reaches this line, an error was thrown.
157
- * // We rollback the transaction.
158
- * 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();
159
189
  * }
160
- * @see https://sequelize.org/master/manual/transactions.html
161
190
  *
162
- * @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.
163
194
  */
164
- static begin(): Promise<sequelize.Transaction>;
195
+ static begin(opts?: sequelize.TransactionOptions): Promise<sequelize.Transaction>;
165
196
  /**
166
197
  * Returns data that matches the ID.
167
198
  */
@@ -173,11 +204,11 @@ export default class Model extends sequelize.Model {
173
204
  * @example
174
205
  * // By default the function will return two arguments - a results array, and an object containing metadata (such as amount of affected rows, etc).
175
206
  * // Note that since this is a raw query, the metadata are dialect specific.
176
- * const [results, metadata] = await UserModel.query("UPDATE user SET name = 'Beil' WHERE id = 1");
207
+ * const [results, metadata] = await BookModel.query("UPDATE book SET title = 'When Im Gone' WHERE id = 1");
177
208
  *
178
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:
179
210
  * // We didn't need to destructure the result here - the results were returned directly
180
- * const users = await sequelize.query("SELECT * FROM user", {type: UserModel.QueryTypes.SELECT});
211
+ * const users = await BookModel.query("SELECT * FROM book", {type: BookModel.QueryTypes.SELECT});
181
212
  *
182
213
  * @see https://sequelize.org/master/manual/raw-queries.html
183
214
  *
@@ -153,20 +153,61 @@ export declare function not(expression: any): boolean;
153
153
  */
154
154
  export declare function ifx(condition: boolean, value1: any, value2: any): any;
155
155
  /**
156
- * Check if an array is empty.
156
+ * Check if it is empty.
157
+ * If the value is an array, returns true if there are no elements.
158
+ * If the value is a string, the leading and trailing spaces are trimmed and then checked.
157
159
  *
158
160
  * @example
159
- * let items = [5, 6];
160
- * {{empty items}} => false
161
+ * // If the value is an array.
162
+ * let value = [5, 6];
163
+ * {{empty value}} => false
161
164
  *
162
- * {{#if (empty items)}}
165
+ * {{#if (empty value)}}
163
166
  * Hello
164
167
  * {{/if}}
165
168
  *
166
- * @param {any[]} items Array/object to be checked.
167
- * @returns {boolean} Returns true if the array is empty, false otherwise.
169
+ * // If the value is a string.
170
+ * let value = 'Hello';
171
+ * {{empty value}} => false
172
+ *
173
+ * let value = '';
174
+ * {{empty value}} => true
175
+ *
176
+ * let value = ' ';
177
+ * {{empty value}} => true
178
+ *
179
+ * @param {any} value Character strings, arrays, objects, etc. to be checked.
180
+ * @returns {boolean} Returns true if the value is empty, false otherwise.
181
+ */
182
+ export declare function empty(value: any): boolean;
183
+ /**
184
+ * Check that it is not empty.
185
+ * If the value is an array, returns true if there is an element.
186
+ * If the value is a string, the leading and trailing spaces are trimmed and then checked.
187
+ *
188
+ * @example
189
+ * // If the value is an array.
190
+ * let value = [5, 6];
191
+ * {{not_empty value}} => true
192
+ *
193
+ * {{#if (not_empty value)}}
194
+ * Hello
195
+ * {{/if}}
196
+ *
197
+ * // If the value is a string.
198
+ * let value = 'Hello';
199
+ * {{not_empty value}} => true
200
+ *
201
+ * let value = '';
202
+ * {{not_empty value}} => false
203
+ *
204
+ * let value = ' ';
205
+ * {{not_empty value}} => false
206
+ *
207
+ * @param {any} value Character strings, arrays, objects, etc. to be checked.
208
+ * @returns {boolean} Returns true if the value is not empty, false otherwise.
168
209
  */
169
- export declare function empty(items: any[]): boolean;
210
+ export declare function not_empty(value: any): boolean;
170
211
  /**
171
212
  * Determine the length of an array.
172
213
  *
@@ -73,9 +73,9 @@ export default interface {
73
73
  }>;
74
74
  /**
75
75
  * URL without authentication. If the URL described in the access URL partially matches, authentication will not be performed, defaults to none.
76
- * @type {string}
76
+ * @type {(string|RegExp)[]}
77
77
  */
78
- allow_unauthenticated: string[];
78
+ allow_unauthenticated: (string | RegExp)[];
79
79
  /**
80
80
  * Authenticated user session expiration, defaults to 24 hours (24 * 3600000).
81
81
  * @type {number}
@@ -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.