express-sweet 2.0.3 → 2.0.4
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/CHANGELOG.md +26 -3
- package/LICENSE +1 -1
- package/README.md +137 -53
- package/configuration_sample/cjs/config.js +8 -10
- package/configuration_sample/esm/config.js +8 -10
- package/dist/build.cjs +2 -2
- package/dist/build.mjs +2 -2
- package/package.json +2 -2
- package/types/database/Model.d.ts +13 -13
- package/types/handlebars_helpers/array.d.ts +20 -0
- package/types/handlebars_helpers/comparison.d.ts +50 -50
- package/types/handlebars_helpers/date.d.ts +4 -4
- package/types/handlebars_helpers/html.d.ts +3 -3
- package/types/handlebars_helpers/index.d.ts +1 -0
- package/types/handlebars_helpers/layouts.d.ts +4 -4
- package/types/handlebars_helpers/math.d.ts +14 -14
- package/types/handlebars_helpers/number.d.ts +5 -5
- package/types/handlebars_helpers/object.d.ts +4 -4
- package/types/handlebars_helpers/string.d.ts +8 -8
- package/types/interfaces/AuthenticationConfig.d.ts +4 -7
- package/types/interfaces/BasicConfig.d.ts +10 -11
- package/types/interfaces/ViewConfig.d.ts +1 -2
- package/types/utils/Types.d.ts +2 -2
- package/types/utils/isAsyncFunction.d.ts +7 -7
- package/types/utils/isFunction.d.ts +8 -8
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-sweet",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "EXPRESS SWEET is
|
|
3
|
+
"version": "2.0.4",
|
|
4
|
+
"description": "EXPRESS SWEET is a powerful Express.js extension that streamlines your workflow and boosts productivity with a suite of utilities and enhancements.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/build.cjs",
|
|
7
7
|
"module": "dist/build.mjs",
|
|
@@ -39,6 +39,7 @@ export default class Model extends sequelize.Model {
|
|
|
39
39
|
};
|
|
40
40
|
/**
|
|
41
41
|
* Operator.
|
|
42
|
+
* @type {sequelize.Op}
|
|
42
43
|
* @example
|
|
43
44
|
* // Sequelize provides several operators.
|
|
44
45
|
* Post.findAll({
|
|
@@ -86,7 +87,6 @@ export default class Model extends sequelize.Model {
|
|
|
86
87
|
* }
|
|
87
88
|
* }
|
|
88
89
|
* });
|
|
89
|
-
* @type {sequelize.Op}
|
|
90
90
|
*/
|
|
91
91
|
static readonly Op: {
|
|
92
92
|
[key: string]: any;
|
|
@@ -95,12 +95,12 @@ export default class Model extends sequelize.Model {
|
|
|
95
95
|
* Creates a object representing a database function. This can be used in search queries, both in where and
|
|
96
96
|
* order parts, and as default values in column definitions. If you want to refer to columns in your
|
|
97
97
|
* function, you should use `sequelize.col`, so that the columns are properly interpreted as columns and not a strings.
|
|
98
|
+
* @type {sequelize.fn}
|
|
98
99
|
* @example
|
|
99
100
|
* // Convert a user's username to upper case
|
|
100
101
|
* Post.update({
|
|
101
102
|
* username: this.fn('upper', this.col('username'))
|
|
102
103
|
* })
|
|
103
|
-
* @type {sequelize.fn}
|
|
104
104
|
*/
|
|
105
105
|
static readonly fn: (fn: string, ...args: unknown[]) => any;
|
|
106
106
|
/**
|
|
@@ -122,13 +122,13 @@ export default class Model extends sequelize.Model {
|
|
|
122
122
|
/**
|
|
123
123
|
* Reference to sequelize.Transaction.
|
|
124
124
|
* This includes properties such as isolation level enums used with the transaction option.
|
|
125
|
+
* @see https://sequelize.org/api/v6/class/src/transaction.js~transaction
|
|
126
|
+
* @type {sequelize.Transaction}
|
|
125
127
|
* @example
|
|
126
128
|
* BookModel.Transaction.ISOLATION_LEVELS.READ_UNCOMMITTED // "READ UNCOMMITTED"
|
|
127
129
|
* BookModel.Transaction.ISOLATION_LEVELS.READ_COMMITTED // "READ COMMITTED"
|
|
128
130
|
* BookModel.Transaction.ISOLATION_LEVELS.REPEATABLE_READ // "REPEATABLE READ"
|
|
129
131
|
* BookModel.Transaction.ISOLATION_LEVELS.SERIALIZABLE // "SERIALIZABLE"
|
|
130
|
-
* @see https://sequelize.org/api/v6/class/src/transaction.js~transaction
|
|
131
|
-
* @type {sequelize.Transaction}
|
|
132
132
|
*/
|
|
133
133
|
static readonly Transaction: (typeof sequelize.Transaction);
|
|
134
134
|
/**
|
|
@@ -147,6 +147,9 @@ export default class Model extends sequelize.Model {
|
|
|
147
147
|
static association(): void;
|
|
148
148
|
/**
|
|
149
149
|
* Starts a transaction and returns a transaction object to identify the running transaction.
|
|
150
|
+
* @see https://sequelize.org/api/v6/class/src/transaction.js~transaction
|
|
151
|
+
* @param {sequelize.TransactionOptions} options? Options provided when the transaction is created.
|
|
152
|
+
* @return {Promise<sequelize.Transaction>} Returns a transaction object to identify the transaction being executed.
|
|
150
153
|
* @example
|
|
151
154
|
* // Simple transaction usage example.
|
|
152
155
|
* let transaction;
|
|
@@ -173,13 +176,10 @@ export default class Model extends sequelize.Model {
|
|
|
173
176
|
*
|
|
174
177
|
* // Load updated data.
|
|
175
178
|
* await book.reload();
|
|
176
|
-
* } catch (
|
|
179
|
+
* } catch (error) {
|
|
177
180
|
* if (transaction)
|
|
178
181
|
* await transaction.rollback();
|
|
179
182
|
* }
|
|
180
|
-
* @see https://sequelize.org/api/v6/class/src/transaction.js~transaction
|
|
181
|
-
* @param {sequelize.TransactionOptions} options? Options provided when the transaction is created.
|
|
182
|
-
* @return {Promise<sequelize.Transaction>} Returns a transaction object to identify the transaction being executed.
|
|
183
183
|
*/
|
|
184
184
|
static begin(options?: sequelize.TransactionOptions): Promise<sequelize.Transaction>;
|
|
185
185
|
/**
|
|
@@ -189,6 +189,11 @@ export default class Model extends sequelize.Model {
|
|
|
189
189
|
/**
|
|
190
190
|
* Raw Queries.
|
|
191
191
|
* 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.
|
|
192
|
+
* @see https://sequelize.org/master/manual/raw-queries.html
|
|
193
|
+
* @param {string} sql SQL string.
|
|
194
|
+
* @param {object} options Query options.
|
|
195
|
+
* @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.
|
|
196
|
+
* 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:
|
|
192
197
|
* @example
|
|
193
198
|
* // By default the function will return two arguments - a results array, and an object containing metadata (such as amount of affected rows, etc).
|
|
194
199
|
* // Note that since this is a raw query, the metadata are dialect specific.
|
|
@@ -197,11 +202,6 @@ export default class Model extends sequelize.Model {
|
|
|
197
202
|
* // 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:
|
|
198
203
|
* // We didn't need to destructure the result here - the results were returned directly
|
|
199
204
|
* const users = await BookModel.query("SELECT * FROM book", {type: BookModel.QueryTypes.SELECT});
|
|
200
|
-
* @see https://sequelize.org/master/manual/raw-queries.html
|
|
201
|
-
* @param {string} sql SQL string.
|
|
202
|
-
* @param {object} options Query options.
|
|
203
|
-
* @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.
|
|
204
|
-
* 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:
|
|
205
205
|
*/
|
|
206
206
|
static query(sql: string, options: 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>;
|
|
207
207
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds an object in an array based on the specified field name and value.
|
|
3
|
+
* @param {Array<{[key: string]: any}>} array The array of objects to search.
|
|
4
|
+
* @param {string} fieldName The name of the field to search.
|
|
5
|
+
* @param {*} fieldValue The value to search for.
|
|
6
|
+
* @return {object|null} The first object in the array that matches the criteria, or null if no match is found.
|
|
7
|
+
* @example
|
|
8
|
+
* {{!--
|
|
9
|
+
* items is an array of objects: [{ id: 123, name: 'Item A' }, { id: 456, name: 'Item B' }]
|
|
10
|
+
* This code will output: "Item A"
|
|
11
|
+
* --}}
|
|
12
|
+
* {{#each items}}
|
|
13
|
+
* {{#if (eq id 123)}}
|
|
14
|
+
* {{lookup (findObjectInArray ../items 'id' id) 'name'}}
|
|
15
|
+
* {{/if}}
|
|
16
|
+
* {{/each}}
|
|
17
|
+
*/
|
|
18
|
+
export declare const findObjectInArray: (array: Array<{
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
}>, fieldName: string, fieldValue: any) => object | null;
|
|
@@ -1,94 +1,98 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Determine whether or not two values are equal (===).
|
|
3
|
-
* @example
|
|
4
|
-
* {{eq val1 val2}}
|
|
5
|
-
* {{#if (eqw val1 val2)}}...{{/if}}
|
|
6
3
|
* @param {any} value1 First value to be compared with second.
|
|
7
4
|
* @param {any} value2 Second value to be compared with first.
|
|
8
5
|
* @return {boolean} Returns true if the value and type are the same, false if they are different.
|
|
6
|
+
* @example
|
|
7
|
+
* {{eq val1 val2}}
|
|
8
|
+
* {{#if (eqw val1 val2)}}...{{/if}}
|
|
9
9
|
*/
|
|
10
10
|
export declare const eq: (value1: any, value2: any) => boolean;
|
|
11
11
|
/**
|
|
12
12
|
* Determine whether or not two values are equal (==) i.e weak checking.
|
|
13
|
-
* @example
|
|
14
|
-
* {{eqw val1 val2}}
|
|
15
|
-
* {{#if (eqw val1 val2)}}...{{/if}}
|
|
16
13
|
* @param {any} value1 First value to be compared with second.
|
|
17
14
|
* @param {any} value2 Second value to be compared with first.
|
|
18
15
|
* @return {boolean} Returns true if the values are the same, false if they are different.
|
|
16
|
+
* @example
|
|
17
|
+
* {{eqw val1 val2}}
|
|
18
|
+
* {{#if (eqw val1 val2)}}...{{/if}}
|
|
19
19
|
*/
|
|
20
20
|
export declare const eqw: (value1: any, value2: any) => boolean;
|
|
21
21
|
/**
|
|
22
22
|
* Determine whether or not two values are not equal (!==).
|
|
23
|
-
* @example
|
|
24
|
-
* {{neq val1 val2}}
|
|
25
|
-
* {{#if (neq val1 val2)}}...{{/if}}
|
|
26
23
|
* @param {any} value1 First value to be compared with second.
|
|
27
24
|
* @param {any} value2 Second value to be compared with first.
|
|
28
25
|
* @return {boolean} Returns true if the value and type are different, false if they are the same.
|
|
26
|
+
* @example
|
|
27
|
+
* {{neq val1 val2}}
|
|
28
|
+
* {{#if (neq val1 val2)}}...{{/if}}
|
|
29
29
|
*/
|
|
30
30
|
export declare const neq: (value1: any, value2: any) => boolean;
|
|
31
31
|
/**
|
|
32
32
|
* Determine whether or not two values are not equal (!=) weak checking.
|
|
33
|
-
* @example
|
|
34
|
-
* {{neqw val1 val2}}
|
|
35
|
-
* {{#if (neqw val1 val2)}}...{{/if}}
|
|
36
33
|
* @param {any} value1 First value to be compared with second.
|
|
37
34
|
* @param {any} value2 Second value to be compared with first.
|
|
38
35
|
* @return {boolean} Returns true if the values are different, false if they are the same.
|
|
36
|
+
* @example
|
|
37
|
+
* {{neqw val1 val2}}
|
|
38
|
+
* {{#if (neqw val1 val2)}}...{{/if}}
|
|
39
39
|
*/
|
|
40
40
|
export declare const neqw: (value1: any, value2: any) => boolean;
|
|
41
41
|
/**
|
|
42
42
|
* Check for less than condition (a < b).
|
|
43
|
-
* @example
|
|
44
|
-
* {{lt val1 val2}}
|
|
45
|
-
* {{#if (lt val1 val2)}}...{{/if}}
|
|
46
43
|
* @param {any} value1 First value to be compared with second.
|
|
47
44
|
* @param {any} value2 Second value to be compared with first.
|
|
48
45
|
* @return {boolean} Returns true if the first value is less than the second value, false otherwise.
|
|
46
|
+
* @example
|
|
47
|
+
* {{lt val1 val2}}
|
|
48
|
+
* {{#if (lt val1 val2)}}...{{/if}}
|
|
49
49
|
*/
|
|
50
50
|
export declare const lt: (value1: any, value2: any) => boolean;
|
|
51
51
|
/**
|
|
52
52
|
* Check for less than or equals condition (a <= b).
|
|
53
|
-
* @example
|
|
54
|
-
* {{lte val1 val2}}
|
|
55
|
-
* {{#if (lte val1 val2)}}...{{/if}}
|
|
56
53
|
* @param {any} value1 First value to be compared with second.
|
|
57
54
|
* @param {any} value2 Second value to be compared with first.
|
|
58
55
|
* @return {boolean} Returns true if the first value is less than or equal to the second value, false otherwise.
|
|
56
|
+
* @example
|
|
57
|
+
* {{lte val1 val2}}
|
|
58
|
+
* {{#if (lte val1 val2)}}...{{/if}}
|
|
59
59
|
*/
|
|
60
60
|
export declare const lte: (value1: any, value2: any) => boolean;
|
|
61
61
|
/**
|
|
62
62
|
* Check for greater than condition (a > b).
|
|
63
|
-
* @example
|
|
64
|
-
* {{gt val1 val2}}
|
|
65
|
-
* {{#if (gt val1 val2)}}...{{/if}}
|
|
66
63
|
* @param {any} value1 First value to be compared with second.
|
|
67
64
|
* @param {any} value2 Second value to be compared with first.
|
|
68
65
|
* @return {boolean} Returns true if the first value exceeds the second value, false otherwise.
|
|
66
|
+
* @example
|
|
67
|
+
* {{gt val1 val2}}
|
|
68
|
+
* {{#if (gt val1 val2)}}...{{/if}}
|
|
69
69
|
*/
|
|
70
70
|
export declare const gt: (value1: any, value2: any) => boolean;
|
|
71
71
|
/**
|
|
72
72
|
* Check for greater than or equals condition (a >= b).
|
|
73
|
-
* @example
|
|
74
|
-
* {{gte val1 val2}}
|
|
75
|
-
* {{#if (gte val1 val2)}}...{{/if}}
|
|
76
73
|
* @param {any} value1 First value to be compared with second.
|
|
77
74
|
* @param {any} value2 Second value to be compared with first.
|
|
78
75
|
* @return {boolean} Returns true if the first value is greater than or equal to the second value, false otherwise.
|
|
76
|
+
* @example
|
|
77
|
+
* {{gte val1 val2}}
|
|
78
|
+
* {{#if (gte val1 val2)}}...{{/if}}
|
|
79
79
|
*/
|
|
80
80
|
export declare const gte: (value1: any, value2: any) => boolean;
|
|
81
81
|
/**
|
|
82
82
|
* Logical NOT of any expression.
|
|
83
|
+
* @param {any} expression Any expression.
|
|
84
|
+
* @return {boolean} Returns the logical negation of the value.
|
|
83
85
|
* @example
|
|
84
86
|
* {{not val}}
|
|
85
87
|
* {{#if (not (eq val1 val2))}}...{{/if}}
|
|
86
|
-
* @param {any} expression Any expression.
|
|
87
|
-
* @return {boolean} Returns the logical negation of the value.
|
|
88
88
|
*/
|
|
89
89
|
export declare const not: (expression: any) => boolean;
|
|
90
90
|
/**
|
|
91
91
|
* Helper to imitate the ternary '?:' conditional operator.
|
|
92
|
+
* @param {boolean} condition Satisfying condition for getting first value. Either true of false.
|
|
93
|
+
* @param {any} value1 First value to be displayed as result..
|
|
94
|
+
* @param {any} value2 Second value to be displayed as result. Defaults to an empty string.
|
|
95
|
+
* @return {any} Returns the result of the ternary operator.
|
|
92
96
|
* @example
|
|
93
97
|
* {{ifx true val1 val2}}
|
|
94
98
|
* {{ifx false val1 val2}}
|
|
@@ -96,91 +100,87 @@ export declare const not: (expression: any) => boolean;
|
|
|
96
100
|
* {{ifx (not (eq val1 val2)) val3 val4}}
|
|
97
101
|
* {{ifx true val}}
|
|
98
102
|
* {{ifx false val}}
|
|
99
|
-
* @param {boolean} condition Satisfying condition for getting first value. Either true of false.
|
|
100
|
-
* @param {any} value1 First value to be displayed as result..
|
|
101
|
-
* @param {any} value2 Second value to be displayed as result. Defaults to an empty string.
|
|
102
|
-
* @return {any} Returns the result of the ternary operator.
|
|
103
103
|
*/
|
|
104
104
|
export declare const ifx: (condition: boolean, value1: any, value2: any) => any;
|
|
105
105
|
/**
|
|
106
106
|
* Check if it is empty.
|
|
107
107
|
* If the value is an array, returns true if there are no elements.
|
|
108
108
|
* If the value is a string, the leading and trailing spaces are trimmed and then checked.
|
|
109
|
+
* @param {any} value Character strings, arrays, objects, etc. to be checked.
|
|
110
|
+
* @return {boolean} Returns true if the value is empty, false otherwise.
|
|
109
111
|
* @example
|
|
110
112
|
* {{empty val}}
|
|
111
113
|
* {{#if (empty val)}}...{{/if}}
|
|
112
|
-
* @param {any} value Character strings, arrays, objects, etc. to be checked.
|
|
113
|
-
* @return {boolean} Returns true if the value is empty, false otherwise.
|
|
114
114
|
*/
|
|
115
115
|
export declare const empty: (value: any) => boolean;
|
|
116
116
|
/**
|
|
117
117
|
* Check that it is not empty.
|
|
118
118
|
* If the value is an array, returns true if there is an element.
|
|
119
119
|
* If the value is a string, the leading and trailing spaces are trimmed and then checked.
|
|
120
|
+
* @param {any} value Character strings, arrays, objects, etc. to be checked.
|
|
121
|
+
* @return {boolean} Returns true if the value is not empty, false otherwise.
|
|
120
122
|
* @example
|
|
121
123
|
* {{notEmpty val}}
|
|
122
124
|
* {{#if (notEmpty val)}}...{{/if}}
|
|
123
|
-
* @param {any} value Character strings, arrays, objects, etc. to be checked.
|
|
124
|
-
* @return {boolean} Returns true if the value is not empty, false otherwise.
|
|
125
125
|
*/
|
|
126
126
|
export declare const notEmpty: (value: any) => boolean;
|
|
127
127
|
/**
|
|
128
128
|
* Determine the length of an array.
|
|
129
|
-
* @example
|
|
130
|
-
* {{count val}}
|
|
131
129
|
* @param {any[]} items Array whose elements to be counted.
|
|
132
130
|
* @return {number|false} Returns the length of the array if the value is an array, false if the value is not an array.
|
|
131
|
+
* @example
|
|
132
|
+
* {{count val}}
|
|
133
133
|
*/
|
|
134
134
|
export declare const count: (items: any[]) => number | false;
|
|
135
135
|
/**
|
|
136
136
|
* Returns the boolean AND of two or more parameters passed i.e it is true iff all the parameters are true.
|
|
137
|
+
* @param {...any} params Any number of boolean parameters.
|
|
138
|
+
* @return {boolean} Returns the result of the logical product.
|
|
137
139
|
* @example
|
|
138
140
|
* {{and val1 val2}}
|
|
139
141
|
* {{#if (and val1 val2)}}...{{/if}}
|
|
140
|
-
* @param {...any} params Any number of boolean parameters.
|
|
141
|
-
* @return {boolean} Returns the result of the logical product.
|
|
142
142
|
*/
|
|
143
143
|
export declare const and: (...params: any[]) => boolean;
|
|
144
144
|
/**
|
|
145
145
|
* Returns the boolean OR of two or more parameters passed i.e it is true if any of the parameters is true.
|
|
146
|
+
* @param {...any} params Any number of boolean parameters.
|
|
147
|
+
* @return {boolean} Returns the result of the OR.
|
|
146
148
|
* @example
|
|
147
149
|
* {{or val1 val2}}
|
|
148
150
|
* {{#if (or val1 val2)}}...{{/if}}
|
|
149
|
-
* @param {...any} params Any number of boolean parameters.
|
|
150
|
-
* @return {boolean} Returns the result of the OR.
|
|
151
151
|
*/
|
|
152
152
|
export declare const or: (...params: any[]) => boolean;
|
|
153
153
|
/**
|
|
154
154
|
* Returns the first non-falsy value from the parameter list.
|
|
155
155
|
* Works quite similar to the SQL's "COALESCE()" function, but unlike this checks for the first non-false parameter.
|
|
156
|
-
* @example
|
|
157
|
-
* {{coalesce val1 val2}}
|
|
158
156
|
* @param {...any} params Any number of parameters.
|
|
159
157
|
* @return {any} Returns the first non-false element of the parameter.
|
|
158
|
+
* @example
|
|
159
|
+
* {{coalesce val1 val2}}
|
|
160
160
|
*/
|
|
161
161
|
export declare const coalesce: (...params: any[]) => any;
|
|
162
162
|
/**
|
|
163
163
|
* Returns boolean if the array contains the element strictly or non-strictly.
|
|
164
|
+
* @param {any[]} items The array.
|
|
165
|
+
* @param {any} value The value to be checked for existence in the array.
|
|
166
|
+
* @param {boolean} strict FALSE for non-strict checking. TRUE by default.
|
|
167
|
+
* @return {boolean} Returns true if the array contains the specified value, false otherwise.
|
|
164
168
|
* @example
|
|
165
169
|
* {{includes [1, 2, 3] 2}}
|
|
166
170
|
* {{includes [1, 2, 3] 2 true}}
|
|
167
171
|
* {{#if (includes [1, 2, 3] 2)}}...{{/if}}
|
|
168
172
|
* {{ifx (includes [1, 2, 3] 2) true false}}
|
|
169
|
-
* @param {any[]} items The array.
|
|
170
|
-
* @param {any} value The value to be checked for existence in the array.
|
|
171
|
-
* @param {boolean} strict FALSE for non-strict checking. TRUE by default.
|
|
172
|
-
* @return {boolean} Returns true if the array contains the specified value, false otherwise.
|
|
173
173
|
*/
|
|
174
174
|
export declare const includes: (items: any[], value: any, strict?: boolean) => boolean;
|
|
175
175
|
/**
|
|
176
176
|
* Returns true if the given str matches the given regex.
|
|
177
|
-
* @example
|
|
178
|
-
* {{regexMatch 'Hello, world!' 'Hello'}}
|
|
179
|
-
* {{regexMatch 'Hello, world!' 'Hello' 'i'}}
|
|
180
|
-
* {{#if (regexMatch 'Hello, world!' 'Hello')}}...{{/if}}
|
|
181
177
|
* @param {string} val The string against which to match the regular expression.
|
|
182
178
|
* @param {string} pattern The text of the regular expression.
|
|
183
179
|
* @param {string} flags? Regular expression flags, such as global and case-insensitive searches. The default is none (undefined).
|
|
184
180
|
* @return {boolean} true if there is a match between the regular expression and the string str. Otherwise, false.
|
|
181
|
+
* @example
|
|
182
|
+
* {{regexMatch 'Hello, world!' 'Hello'}}
|
|
183
|
+
* {{regexMatch 'Hello, world!' 'Hello' 'i'}}
|
|
184
|
+
* {{#if (regexMatch 'Hello, world!' 'Hello')}}...{{/if}}
|
|
185
185
|
*/
|
|
186
186
|
export declare const regexMatch: (val: string, pattern: string, flags?: string) => boolean;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Use moment to format the date.
|
|
3
|
+
* @param {string} format A format string based on moment.
|
|
4
|
+
* @param {string} date Date string to format.
|
|
5
|
+
* @param {string|string[]} locale Language or language-country locale string (or array of strings) available in https://github.com/moment/moment/tree/develop/locale .
|
|
6
|
+
* @return {string} Returns formatted date.
|
|
3
7
|
* @example
|
|
4
8
|
* {{!-- results in: 2021/10/24 --}}
|
|
5
9
|
* {{formatDate 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z"}}
|
|
@@ -9,9 +13,5 @@
|
|
|
9
13
|
*
|
|
10
14
|
* {{!-- results in: 2021/10/24 --}}
|
|
11
15
|
* {{formatDate 'YYYY/MM/DD' "2021-10-24T02:13:06.610Z" 'es'}}
|
|
12
|
-
* @param {string} format A format string based on moment.
|
|
13
|
-
* @param {string} date Date string to format.
|
|
14
|
-
* @param {string|string[]} locale Language or language-country locale string (or array of strings) available in https://github.com/moment/moment/tree/develop/locale .
|
|
15
|
-
* @return {string} Returns formatted date.
|
|
16
16
|
*/
|
|
17
17
|
export declare const formatDate: (format: string, date: string, locale: string | string[]) => string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns the Assets path containing the file update time parameter.
|
|
3
|
-
* @example
|
|
4
|
-
* {{!-- results in: example.com/assets/style.css?1620526340463 --}}
|
|
5
|
-
* {{cacheBusting '/assets/style.css' '//example.com'}}
|
|
6
3
|
* @param {string} filePath Paths of Assets files such as CSS and JS in public directories.
|
|
7
4
|
* @param {string} baseUrl Application Origin URL. The default is none (undefined).
|
|
8
5
|
* @return {string} Returns the Assets file path with the update date and time parameters.
|
|
6
|
+
* @example
|
|
7
|
+
* {{!-- results in: example.com/assets/style.css?1620526340463 --}}
|
|
8
|
+
* {{cacheBusting '/assets/style.css' '//example.com'}}
|
|
9
9
|
*/
|
|
10
10
|
export declare const cacheBusting: (filePath: string, baseUrl?: string) => string;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Declare block race holders in layout.
|
|
3
3
|
* Imported from {@link https://github.com/TryGhost/express-hbs|express-hbs}
|
|
4
|
-
* @example
|
|
5
|
-
* {{{block "pageScripts"}}}
|
|
6
4
|
* @param {string} name Block Name.
|
|
7
5
|
* @param {Handlebars.HelperOptions} options Helper Options.
|
|
8
6
|
* @return {string} String.
|
|
7
|
+
* @example
|
|
8
|
+
* {{{block "pageScripts"}}}
|
|
9
9
|
*/
|
|
10
10
|
export declare const block: (this: any, name: string, options: Handlebars.HelperOptions) => any;
|
|
11
11
|
/**
|
|
12
12
|
* Define block content within a page.
|
|
13
13
|
* Imported from {@link https://github.com/TryGhost/express-hbs|express-hbs}
|
|
14
|
+
* @param {string} name Block Name.
|
|
15
|
+
* @param {Handlebars.HelperOptions} options Helper Options.
|
|
14
16
|
* @example
|
|
15
17
|
* {{#contentFor "pageScripts"}}
|
|
16
18
|
* CONTENT HERE
|
|
17
19
|
* {{/contentFor}}
|
|
18
|
-
* @param {string} name Block Name.
|
|
19
|
-
* @param {Handlebars.HelperOptions} options Helper Options.
|
|
20
20
|
*/
|
|
21
21
|
export declare const contentFor: (this: any, name: string, options: any) => void;
|
|
@@ -1,60 +1,60 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Calculates the sum of two numbers.
|
|
3
|
-
* @example
|
|
4
|
-
* {{add 1 2}}
|
|
5
3
|
* @param {number|string} val1 The first number.
|
|
6
4
|
* @param {number|string} val2 The second number.
|
|
7
5
|
* @return {number}
|
|
6
|
+
* @example
|
|
7
|
+
* {{add 1 2}}
|
|
8
8
|
*/
|
|
9
9
|
export declare const add: (val1: number | string, val2: number | string) => number;
|
|
10
10
|
/**
|
|
11
11
|
* Calculates the difference of the given values.
|
|
12
|
-
* @example
|
|
13
|
-
* {{sub 5 2}}
|
|
14
12
|
* @param {number|string} val1 The first number.
|
|
15
13
|
* @param {number|string} val2 The second number.
|
|
16
14
|
* @return {number}
|
|
15
|
+
* @example
|
|
16
|
+
* {{sub 5 2}}
|
|
17
17
|
*/
|
|
18
18
|
export declare const sub: (val1: number | string, val2: number | string) => number;
|
|
19
19
|
/**
|
|
20
20
|
* Calculate the multiplication of the given values.
|
|
21
|
-
* @example
|
|
22
|
-
* {{multiply 5 2}}
|
|
23
21
|
* @param {number|string} val1 The first number.
|
|
24
22
|
* @param {number|string} val2 The second number.
|
|
25
23
|
* @return {number}
|
|
24
|
+
* @example
|
|
25
|
+
* {{multiply 5 2}}
|
|
26
26
|
*/
|
|
27
27
|
export declare const multiply: (val1: number | string, val2: number | string) => number;
|
|
28
28
|
/**
|
|
29
29
|
* Compute the division of the given values.
|
|
30
|
-
* @example
|
|
31
|
-
* {{divide 10 2}}
|
|
32
30
|
* @param {number|string} val1 The first number.
|
|
33
31
|
* @param {number|string} val2 The second number.
|
|
34
32
|
* @return {number}
|
|
33
|
+
* @example
|
|
34
|
+
* {{divide 10 2}}
|
|
35
35
|
*/
|
|
36
36
|
export declare const divide: (val1: number | string, val2: number | string) => number;
|
|
37
37
|
/**
|
|
38
38
|
* Round up the value.
|
|
39
|
-
* @example
|
|
40
|
-
* {{ceil 5.6}}
|
|
41
39
|
* @param {number|string} val Number to be rounded to nearest greater integer.
|
|
42
40
|
* @return {number}
|
|
41
|
+
* @example
|
|
42
|
+
* {{ceil 5.6}}
|
|
43
43
|
*/
|
|
44
44
|
export declare const ceil: (val: number | string) => number;
|
|
45
45
|
/**
|
|
46
46
|
* Rounds down a number.
|
|
47
|
-
* @example
|
|
48
|
-
* {{floor 5.6}}
|
|
49
47
|
* @param {number|string} val Number to be rounded to nearest lower integer.
|
|
50
48
|
* @return {number}
|
|
49
|
+
* @example
|
|
50
|
+
* {{floor 5.6}}
|
|
51
51
|
*/
|
|
52
52
|
export declare const floor: (val: number | string) => number;
|
|
53
53
|
/**
|
|
54
54
|
* Returns an absolute value.
|
|
55
|
-
* @example
|
|
56
|
-
* {{abs -5.6}}
|
|
57
55
|
* @param {number} val Number to perform absolute value operation on.
|
|
58
56
|
* @return {number}
|
|
57
|
+
* @example
|
|
58
|
+
* {{abs -5.6}}
|
|
59
59
|
*/
|
|
60
60
|
export declare const abs: (val: number | string) => number;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns the language-sensitive representation of a number as a string.
|
|
3
|
+
* @param {number|string} val Target number or numeric string.
|
|
4
|
+
* @param {string|undefined} locales A string with a BCP 47 language tag, or an array of such strings.
|
|
5
|
+
* Corresponds to the <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#locales">locales</a> parameter of the Intl.NumberFormat() constructor.
|
|
6
|
+
* In implementations without Intl.NumberFormat support, this parameter is ignored and the host's locale is usually used.
|
|
7
|
+
* @return {string} A string with a language-sensitive representation of the given number.
|
|
3
8
|
* @example
|
|
4
9
|
* {{!-- results in: 123,456.789 --}}
|
|
5
10
|
* {{number2locale 123456.789}}
|
|
@@ -7,10 +12,5 @@
|
|
|
7
12
|
* {{!-- German uses comma as decimal separator and period for thousands. --}}
|
|
8
13
|
* {{!-- results in: 123.456,789 --}}
|
|
9
14
|
* {{number2locale 123456.789 'de-DE'}}
|
|
10
|
-
* @param {number|string} val Target number or numeric string.
|
|
11
|
-
* @param {string|undefined} locales A string with a BCP 47 language tag, or an array of such strings.
|
|
12
|
-
* Corresponds to the <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#locales">locales</a> parameter of the Intl.NumberFormat() constructor.
|
|
13
|
-
* In implementations without Intl.NumberFormat support, this parameter is ignored and the host's locale is usually used.
|
|
14
|
-
* @return {string} A string with a language-sensitive representation of the given number.
|
|
15
15
|
*/
|
|
16
16
|
export declare const number2locale: (val: number | string, locales?: string) => string;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Stringify an object using JSON.stringify.
|
|
3
|
-
* @example
|
|
4
|
-
* {{jsonStringify val}}
|
|
5
3
|
* @param {any} value The value to convert to a JSON string.
|
|
6
4
|
* @param {number} indent The number of space characters to use as whitespace.
|
|
7
5
|
* @return {string} A JSON string representing the given value, or undefined.
|
|
6
|
+
* @example
|
|
7
|
+
* {{jsonStringify val}}
|
|
8
8
|
*/
|
|
9
9
|
export declare const jsonStringify: (value: any, indent?: number | string) => string | undefined;
|
|
10
10
|
/**
|
|
11
11
|
* Parses the given string using JSON.parse.
|
|
12
|
-
* @example
|
|
13
|
-
* {{jsonParse val}}
|
|
14
12
|
* @param {any} value Object to stringify.
|
|
15
13
|
* @return {any} JavaScript value or object described by a string.
|
|
14
|
+
* @example
|
|
15
|
+
* {{jsonParse val}}
|
|
16
16
|
*/
|
|
17
17
|
export declare const jsonParse: (value: any) => any;
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns a new string with some or all matches of a pattern replaced by a replacement.
|
|
3
|
-
* @example
|
|
4
|
-
* {{replace 'The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?' 'dog' 'monkey'}}
|
|
5
3
|
* @param {string} value String.
|
|
6
4
|
* @param {string} find The string to be replaced.
|
|
7
5
|
* @param {string} replace The string to replace.
|
|
8
6
|
* @return {string} Character string after replacement.
|
|
7
|
+
* @example
|
|
8
|
+
* {{replace 'The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?' 'dog' 'monkey'}}
|
|
9
9
|
*/
|
|
10
10
|
export declare const replace: (value: string, find: string, replace: string) => string;
|
|
11
11
|
/**
|
|
12
12
|
* Split `string` by the given `character`.
|
|
13
|
-
* @example
|
|
14
|
-
* {{split "a,b,c" ","}}
|
|
15
|
-
* {{#each (split list ',')}}<div>{{this}}</div>{{/each}}
|
|
16
13
|
* @param {string} value String.
|
|
17
14
|
* @param {string} separator A character that delimits the substrings in this string. Default is a comma.
|
|
18
15
|
* @return {string[]} An Array of strings, split at each point where the separator occurs in the given string. The default is a comma.
|
|
16
|
+
* @example
|
|
17
|
+
* {{split "a,b,c" ","}}
|
|
18
|
+
* {{#each (split list ',')}}<div>{{this}}</div>{{/each}}
|
|
19
19
|
*/
|
|
20
20
|
export declare const split: (value: string, separator: string) => string[];
|
|
21
21
|
/**
|
|
22
22
|
* Convert bytes to just the right units(KB, MB, GB, TB, PB, EB, ZB, YB).
|
|
23
|
+
* @param {number} bytes Bytes.
|
|
24
|
+
* @param {number} decimals Number of decimal places to display. Default is 0.
|
|
25
|
+
* @return {string} Returns a value with units.
|
|
23
26
|
* @example
|
|
24
27
|
* {{!-- results in: 1 KB --}}
|
|
25
28
|
* {{formatBytes 1024}}
|
|
@@ -32,8 +35,5 @@ export declare const split: (value: string, separator: string) => string[];
|
|
|
32
35
|
*
|
|
33
36
|
* {{!-- results in: 0 Bytes --}}
|
|
34
37
|
* {{formatBytes 0}}
|
|
35
|
-
* @param {number} bytes Bytes.
|
|
36
|
-
* @param {number} decimals Number of decimal places to display. Default is 0.
|
|
37
|
-
* @return {string} Returns a value with units.
|
|
38
38
|
*/
|
|
39
39
|
export declare const formatBytes: (bytes: number, decimals?: number) => string;
|
|
@@ -56,6 +56,7 @@ export default interface AuthenticationConfig {
|
|
|
56
56
|
success_redirect: string;
|
|
57
57
|
/**
|
|
58
58
|
* URL to redirect after log off, defaults to `/login`.
|
|
59
|
+
* @type {string|((req: express.Request, res: express.Response) => string)}
|
|
59
60
|
* @example
|
|
60
61
|
* // Set the URL to redirect to in case of login failure as a string.
|
|
61
62
|
* failure_redirect: '/login',
|
|
@@ -65,15 +66,14 @@ export default interface AuthenticationConfig {
|
|
|
65
66
|
* // If the role stored in the cookie is admin, redirect to the admin login screen.
|
|
66
67
|
* return req.cookies.role === 'admin' ? '/adminlogin' : 'login';
|
|
67
68
|
* },
|
|
68
|
-
|
|
69
|
-
* @type {string|((req: express.Request, res: express.Response) => string)}
|
|
70
|
-
*/
|
|
69
|
+
*/
|
|
71
70
|
failure_redirect: string | ((req: express.Request, res: express.Response) => string);
|
|
72
71
|
/**
|
|
73
72
|
* This hook is called when authenticating a user.
|
|
74
73
|
* Please find the user information that owns the credentials based on the user name and password you received and return it.
|
|
75
74
|
* If the user who owns the credentials cannot be found, return null.
|
|
76
75
|
* Note that the user information must include an ID value that can identify the user.
|
|
76
|
+
* @type {(username: string, password: string, req: express.Request) => Promise<{[key: string]: any}|null>}
|
|
77
77
|
* @example
|
|
78
78
|
* authenticate_user: async (username, password, req) => {
|
|
79
79
|
* const UserModel = require('../models/UserModel');
|
|
@@ -85,8 +85,6 @@ export default interface AuthenticationConfig {
|
|
|
85
85
|
* raw: true
|
|
86
86
|
* });
|
|
87
87
|
* }
|
|
88
|
-
*
|
|
89
|
-
* @type {(username: string, password: string, req: express.Request) => Promise<{[key: string]: any}|null>}
|
|
90
88
|
*/
|
|
91
89
|
authenticate_user: (username: string, password: string, req: express.Request) => Promise<{
|
|
92
90
|
[key: string]: any;
|
|
@@ -95,6 +93,7 @@ export default interface AuthenticationConfig {
|
|
|
95
93
|
* This hook is called when user authentication is successful.
|
|
96
94
|
* Please search and return the authenticated user information to be set in the session based on the user ID of the parameter.
|
|
97
95
|
* The returned data will be set in the req.user property and the view's session variable.
|
|
96
|
+
* @type {(id: number|string) => Promise<{[key: string]: any}>}
|
|
98
97
|
* @example
|
|
99
98
|
* subscribe_user: async (id) => {
|
|
100
99
|
* const UserModel = require('../models/UserModel');
|
|
@@ -103,8 +102,6 @@ export default interface AuthenticationConfig {
|
|
|
103
102
|
* raw: true
|
|
104
103
|
* });
|
|
105
104
|
* }
|
|
106
|
-
*
|
|
107
|
-
* @type {(id: number|string) => Promise<{[key: string]: any}>}
|
|
108
105
|
*/
|
|
109
106
|
subscribe_user: (id: number | string) => Promise<{
|
|
110
107
|
[key: string]: any;
|