express-sweet 2.0.2 → 2.0.3

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 (50) hide show
  1. package/CHANGELOG.md +51 -7
  2. package/README.md +2109 -20
  3. package/configuration_sample/cjs/authentication.js +103 -0
  4. package/configuration_sample/cjs/config.js +76 -0
  5. package/configuration_sample/cjs/database.js +35 -0
  6. package/configuration_sample/cjs/view.js +36 -0
  7. package/configuration_sample/esm/authentication.js +103 -0
  8. package/configuration_sample/esm/config.js +76 -0
  9. package/configuration_sample/esm/database.js +35 -0
  10. package/configuration_sample/esm/view.js +36 -0
  11. package/dist/build.cjs +22 -22
  12. package/dist/build.mjs +22 -22
  13. package/package.json +8 -11
  14. package/screencaps/belongs-to-many.png +0 -0
  15. package/screencaps/belongs-to.png +0 -0
  16. package/screencaps/demonstration.webp +0 -0
  17. package/screencaps/has-many.png +0 -0
  18. package/screencaps/has-one.png +0 -0
  19. package/types/database/Database.d.ts +3 -171
  20. package/types/database/Model.d.ts +9 -6
  21. package/types/database/loadModels.d.ts +2 -1
  22. package/types/handlebars_helpers/comparison.d.ts +40 -170
  23. package/types/handlebars_helpers/index.d.ts +1 -0
  24. package/types/handlebars_helpers/layouts.d.ts +21 -0
  25. package/types/handlebars_helpers/math.d.ts +0 -7
  26. package/types/handlebars_helpers/object.d.ts +2 -2
  27. package/types/handlebars_helpers/string.d.ts +1 -6
  28. package/types/interfaces/AuthenticationConfig.d.ts +0 -4
  29. package/types/interfaces/BasicConfig.d.ts +1 -4
  30. package/types/interfaces/ViewConfig.d.ts +0 -1
  31. package/types/middlewares/Authentication.d.ts +3 -1
  32. package/types/middlewares/CORS.d.ts +3 -1
  33. package/types/middlewares/Environment.d.ts +3 -3
  34. package/types/middlewares/ErrorHandler.d.ts +3 -1
  35. package/types/middlewares/Http.d.ts +3 -1
  36. package/types/middlewares/Local.d.ts +3 -1
  37. package/types/middlewares/View.d.ts +6 -2
  38. package/types/mount.d.ts +3 -2
  39. package/types/routing/Router.d.ts +3 -1
  40. package/types/services/Authentication.d.ts +4 -2
  41. package/types/utils/loadAuthenticationConfig.d.ts +2 -2
  42. package/types/utils/loadBasicConfig.d.ts +2 -2
  43. package/types/utils/loadDatabaseConfig.d.ts +2 -2
  44. package/types/utils/loadViewConfig.d.ts +2 -2
  45. package/INSTALL-Redis.md +0 -77
  46. package/QUICK_START.md +0 -149
  47. package/screencaps/login.jpg +0 -0
  48. package/screencaps/personal.jpg +0 -0
  49. package/screencaps/user-editing.jpg +0 -0
  50. package/screencaps/users.jpg +0 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "express-sweet",
3
- "version": "2.0.2",
4
- "description": "Express Extension.",
3
+ "version": "2.0.3",
4
+ "description": "EXPRESS SWEET is an extension of EXPRESS.",
5
5
  "type": "module",
6
6
  "main": "dist/build.cjs",
7
7
  "module": "dist/build.mjs",
@@ -16,12 +16,11 @@
16
16
  "dist/",
17
17
  "types/",
18
18
  "CHANGELOG.md",
19
- "INSTALL-Redis.md",
20
19
  "LICENSE",
21
20
  "package.json",
22
21
  "README.md",
23
- "QUICK_START.md",
24
- "screencaps/"
22
+ "screencaps/",
23
+ "configuration_sample/"
25
24
  ],
26
25
  "scripts": {
27
26
  "build": "node --max-old-space-size=8192 node_modules/rollup/dist/bin/rollup -c rollup.config.js",
@@ -71,24 +70,23 @@
71
70
  "cookie-parser": "~1.4.4",
72
71
  "dotenv": "^8.2.0",
73
72
  "express": "^4.19.2",
74
- "express-hbs": "^2.5.0",
73
+ "express-handlebars": "^7.1.3",
75
74
  "express-session": "^1.18.0",
76
75
  "glob": "^10.3.12",
77
- "handlebars-extd": "^1.0.7",
78
76
  "hbs": "~4.0.4",
79
77
  "http-errors": "~1.6.3",
80
78
  "mariadb": "^3.2.3",
81
79
  "moment": "^2.30.1",
82
80
  "morgan": "^1.10.0",
83
81
  "multer": "^1.4.5-lts.1",
84
- "passport": "^0.4.1",
82
+ "passport": "^0.7.0",
85
83
  "passport-local": "^1.0.0",
86
84
  "redis": "^4.6.8",
87
85
  "sequelize": "^6.37.1"
88
86
  },
89
87
  "devDependencies": {
90
- "@rollup/plugin-alias": "^5.1.0",
91
88
  "@rollup/plugin-commonjs": "^26.0.1",
89
+ "@rollup/plugin-json": "^6.1.0",
92
90
  "@rollup/plugin-node-resolve": "^15.2.3",
93
91
  "@rollup/plugin-terser": "^0.4.4",
94
92
  "@types/cookie-parser": "^1.4.2",
@@ -99,10 +97,9 @@
99
97
  "@types/morgan": "^1.9.9",
100
98
  "@types/multer": "^1.4.11",
101
99
  "@types/node": "^22.5.1",
102
- "@types/passport": "^1.0.6",
100
+ "@types/passport": "^1.0.16",
103
101
  "@types/passport-local": "^1.0.33",
104
102
  "rollup": "^4.21.2",
105
- "rollup-plugin-json": "^4.0.0",
106
103
  "rollup-plugin-typescript2": "^0.36.0",
107
104
  "typescript": "^5.5.4"
108
105
  }
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,179 +1,11 @@
1
1
  import sequelize from 'sequelize';
2
2
  /**
3
- * Connect to DB.
3
+ * Database class.
4
4
  */
5
- declare const _default: {
5
+ export default class extends sequelize.Sequelize {
6
6
  /**
7
7
  * Returns true if the DB can be connected.
8
- * @example
9
- * const database = require('express-sweet').database.Database;
10
- *
11
- * // Check database connection.
12
- * const isConnected = await database.isConnect();
13
8
  * @return {Promise<boolean>} Returns true if it can connect to the database, false if it cannot.
14
9
  */
15
10
  isConnect(): Promise<boolean>;
16
- fn: typeof sequelize.fn;
17
- col: typeof sequelize.col;
18
- cast: typeof sequelize.cast;
19
- literal: typeof sequelize.literal;
20
- and: typeof sequelize.and;
21
- or: typeof sequelize.or;
22
- json: typeof sequelize.json;
23
- where: typeof sequelize.where;
24
- Sequelize: typeof sequelize.Sequelize;
25
- readonly config: sequelize.Config;
26
- readonly modelManager: import("sequelize/types/model-manager").ModelManager;
27
- readonly connectionManager: import("sequelize/types/dialects/abstract/connection-manager").ConnectionManager;
28
- readonly models: {
29
- [key: string]: sequelize.ModelCtor<sequelize.Model>;
30
- };
31
- beforeValidate(name: string, fn: (instance: sequelize.Model, options: import("sequelize/types/instance-validator").ValidationOptions) => void): void;
32
- beforeValidate(fn: (instance: sequelize.Model, options: import("sequelize/types/instance-validator").ValidationOptions) => void): void;
33
- afterValidate(name: string, fn: (instance: sequelize.Model, options: import("sequelize/types/instance-validator").ValidationOptions) => void): void;
34
- afterValidate(fn: (instance: sequelize.Model, options: import("sequelize/types/instance-validator").ValidationOptions) => void): void;
35
- beforeCreate(name: string, fn: (attributes: sequelize.Model, options: sequelize.CreateOptions<any>) => void): void;
36
- beforeCreate(fn: (attributes: sequelize.Model, options: sequelize.CreateOptions<any>) => void): void;
37
- afterCreate(name: string, fn: (attributes: sequelize.Model, options: sequelize.CreateOptions<any>) => void): void;
38
- afterCreate(fn: (attributes: sequelize.Model, options: sequelize.CreateOptions<any>) => void): void;
39
- beforeDestroy(name: string, fn: (instance: sequelize.Model, options: sequelize.InstanceDestroyOptions) => void): void;
40
- beforeDestroy(fn: (instance: sequelize.Model, options: sequelize.InstanceDestroyOptions) => void): void;
41
- afterDestroy(name: string, fn: (instance: sequelize.Model, options: sequelize.InstanceDestroyOptions) => void): void;
42
- afterDestroy(fn: (instance: sequelize.Model, options: sequelize.InstanceDestroyOptions) => void): void;
43
- beforeUpdate(name: string, fn: (instance: sequelize.Model, options: sequelize.UpdateOptions<any>) => void): void;
44
- beforeUpdate(fn: (instance: sequelize.Model, options: sequelize.UpdateOptions<any>) => void): void;
45
- afterUpdate(name: string, fn: (instance: sequelize.Model, options: sequelize.UpdateOptions<any>) => void): void;
46
- afterUpdate(fn: (instance: sequelize.Model, options: sequelize.UpdateOptions<any>) => void): void;
47
- beforeBulkCreate(name: string, fn: (instances: sequelize.Model[], options: sequelize.BulkCreateOptions<any>) => void): void;
48
- beforeBulkCreate(fn: (instances: sequelize.Model[], options: sequelize.BulkCreateOptions<any>) => void): void;
49
- afterBulkCreate(name: string, fn: (instances: sequelize.Model[], options: sequelize.BulkCreateOptions<any>) => void): void;
50
- afterBulkCreate(fn: (instances: sequelize.Model[], options: sequelize.BulkCreateOptions<any>) => void): void;
51
- beforeBulkDestroy(name: string, fn: (options: sequelize.BulkCreateOptions<any>) => void): void;
52
- beforeBulkDestroy(fn: (options: sequelize.BulkCreateOptions<any>) => void): void;
53
- afterBulkDestroy(name: string, fn: (options: sequelize.DestroyOptions<any>) => void): void;
54
- afterBulkDestroy(fn: (options: sequelize.DestroyOptions<any>) => void): void;
55
- beforeBulkUpdate(name: string, fn: (options: sequelize.UpdateOptions<any>) => void): void;
56
- beforeBulkUpdate(fn: (options: sequelize.UpdateOptions<any>) => void): void;
57
- afterBulkUpdate(name: string, fn: (options: sequelize.UpdateOptions<any>) => void): void;
58
- afterBulkUpdate(fn: (options: sequelize.UpdateOptions<any>) => void): void;
59
- beforeFind(name: string, fn: (options: sequelize.FindOptions<any>) => void): void;
60
- beforeFind(fn: (options: sequelize.FindOptions<any>) => void): void;
61
- beforeFindAfterExpandIncludeAll(name: string, fn: (options: sequelize.FindOptions<any>) => void): void;
62
- beforeFindAfterExpandIncludeAll(fn: (options: sequelize.FindOptions<any>) => void): void;
63
- beforeFindAfterOptions(name: string, fn: (options: sequelize.FindOptions<any>) => void): void;
64
- beforeFindAfterOptions(fn: (options: sequelize.FindOptions<any>) => void): void;
65
- afterFind(name: string, fn: (instancesOrInstance: sequelize.Model[] | sequelize.Model | null, options: sequelize.FindOptions<any>) => void): void;
66
- afterFind(fn: (instancesOrInstance: sequelize.Model[] | sequelize.Model | null, options: sequelize.FindOptions<any>) => void): void;
67
- beforeDefine(name: string, fn: (attributes: sequelize.ModelAttributes<sequelize.Model, any>, options: sequelize.ModelOptions) => void): void;
68
- beforeDefine(fn: (attributes: sequelize.ModelAttributes<sequelize.Model, any>, options: sequelize.ModelOptions) => void): void;
69
- afterDefine(name: string, fn: (model: sequelize.ModelType) => void): void;
70
- afterDefine(fn: (model: sequelize.ModelType) => void): void;
71
- beforeInit(name: string, fn: (config: sequelize.Config, options: sequelize.Options) => void): void;
72
- beforeInit(fn: (config: sequelize.Config, options: sequelize.Options) => void): void;
73
- afterInit(name: string, fn: (sequelize: sequelize.Sequelize) => void): void;
74
- afterInit(fn: (sequelize: sequelize.Sequelize) => void): void;
75
- beforeBulkSync(name: string, fn: (options: sequelize.SyncOptions) => import("sequelize/types/hooks").HookReturn): void;
76
- beforeBulkSync(fn: (options: sequelize.SyncOptions) => import("sequelize/types/hooks").HookReturn): void;
77
- afterBulkSync(name: string, fn: (options: sequelize.SyncOptions) => import("sequelize/types/hooks").HookReturn): void;
78
- afterBulkSync(fn: (options: sequelize.SyncOptions) => import("sequelize/types/hooks").HookReturn): void;
79
- beforeSync(name: string, fn: (options: sequelize.SyncOptions) => import("sequelize/types/hooks").HookReturn): void;
80
- beforeSync(fn: (options: sequelize.SyncOptions) => import("sequelize/types/hooks").HookReturn): void;
81
- afterSync(name: string, fn: (options: sequelize.SyncOptions) => import("sequelize/types/hooks").HookReturn): void;
82
- afterSync(fn: (options: sequelize.SyncOptions) => import("sequelize/types/hooks").HookReturn): void;
83
- getDialect(): string;
84
- getDatabaseName(): string;
85
- getQueryInterface(): sequelize.QueryInterface;
86
- define<M extends sequelize.Model, TAttributes = sequelize.Attributes<M>>(modelName: string, attributes: sequelize.ModelAttributes<M, TAttributes>, options?: sequelize.ModelOptions<M>): sequelize.ModelCtor<M>;
87
- model(modelName: string): sequelize.ModelCtor<sequelize.Model>;
88
- isDefined(modelName: string): boolean;
89
- query(sql: string | {
90
- query: string;
91
- values: unknown[];
92
- }, options: sequelize.QueryOptionsWithType<sequelize.QueryTypes.UPDATE>): Promise<[undefined, number]>;
93
- query(sql: string | {
94
- query: string;
95
- values: unknown[];
96
- }, options: sequelize.QueryOptionsWithType<sequelize.QueryTypes.BULKUPDATE>): Promise<number>;
97
- query(sql: string | {
98
- query: string;
99
- values: unknown[];
100
- }, options: sequelize.QueryOptionsWithType<sequelize.QueryTypes.INSERT>): Promise<[number, number]>;
101
- query(sql: string | {
102
- query: string;
103
- values: unknown[];
104
- }, options: sequelize.QueryOptionsWithType<sequelize.QueryTypes.UPSERT>): Promise<number>;
105
- query(sql: string | {
106
- query: string;
107
- values: unknown[];
108
- }, options: sequelize.QueryOptionsWithType<sequelize.QueryTypes.DELETE>): Promise<void>;
109
- query(sql: string | {
110
- query: string;
111
- values: unknown[];
112
- }, options: sequelize.QueryOptionsWithType<sequelize.QueryTypes.BULKDELETE>): Promise<number>;
113
- query(sql: string | {
114
- query: string;
115
- values: unknown[];
116
- }, options: sequelize.QueryOptionsWithType<sequelize.QueryTypes.SHOWTABLES>): Promise<string[]>;
117
- query(sql: string | {
118
- query: string;
119
- values: unknown[];
120
- }, options: sequelize.QueryOptionsWithType<sequelize.QueryTypes.DESCRIBE>): Promise<sequelize.ColumnsDescription>;
121
- query<M extends sequelize.Model>(sql: string | {
122
- query: string;
123
- values: unknown[];
124
- }, options: sequelize.QueryOptionsWithModel<M> & {
125
- plain: true;
126
- }): Promise<M | null>;
127
- query<M extends sequelize.Model>(sql: string | {
128
- query: string;
129
- values: unknown[];
130
- }, options: sequelize.QueryOptionsWithModel<M>): Promise<M[]>;
131
- query<T extends object>(sql: string | {
132
- query: string;
133
- values: unknown[];
134
- }, options: sequelize.QueryOptionsWithType<sequelize.QueryTypes.SELECT> & {
135
- plain: true;
136
- }): Promise<T | null>;
137
- query<T extends object>(sql: string | {
138
- query: string;
139
- values: unknown[];
140
- }, options: sequelize.QueryOptionsWithType<sequelize.QueryTypes.SELECT>): Promise<T[]>;
141
- query(sql: string | {
142
- query: string;
143
- values: unknown[];
144
- }, options: (sequelize.QueryOptions | sequelize.QueryOptionsWithType<sequelize.QueryTypes.RAW>) & {
145
- plain: true;
146
- }): Promise<{
147
- [key: string]: unknown;
148
- } | null>;
149
- query(sql: string | {
150
- query: string;
151
- values: unknown[];
152
- }, options?: sequelize.QueryOptions | sequelize.QueryOptionsWithType<sequelize.QueryTypes.RAW>): Promise<[unknown[], unknown]>;
153
- random(): sequelize.Utils.Fn;
154
- set(variables: object, options: sequelize.QueryOptionsTransactionRequired): Promise<unknown>;
155
- escape(value: string | number | Date): string;
156
- createSchema(schema: string, options: sequelize.Logging): Promise<unknown>;
157
- showAllSchemas(options: sequelize.Logging): Promise<object[]>;
158
- dropSchema(schema: string, options: sequelize.Logging): Promise<unknown[]>;
159
- dropAllSchemas(options: sequelize.Logging): Promise<unknown[]>;
160
- sync(options?: sequelize.SyncOptions): Promise<any>;
161
- truncate(options?: sequelize.DestroyOptions<any>): Promise<unknown[]>;
162
- drop(options?: sequelize.DropOptions): Promise<unknown[]>;
163
- authenticate(options?: sequelize.QueryOptions): Promise<void>;
164
- validate(options?: sequelize.QueryOptions): Promise<void>;
165
- transaction<T>(options: sequelize.TransactionOptions, autoCallback: (t: sequelize.Transaction) => PromiseLike<T>): Promise<T>;
166
- transaction<T>(autoCallback: (t: sequelize.Transaction) => PromiseLike<T>): Promise<T>;
167
- transaction(options?: sequelize.TransactionOptions): Promise<sequelize.Transaction>;
168
- close(): Promise<void>;
169
- databaseVersion(): Promise<string>;
170
- _model: sequelize.Model<any, any>;
171
- _attributes: any;
172
- _creationAttributes: any;
173
- addHook<K extends keyof import("sequelize/types/hooks").SequelizeHooks<sequelize.Model<any, any>, any, any>>(hookType: K, name: string, fn: import("sequelize/types/hooks").SequelizeHooks<sequelize.Model<any, any>, any, any>[K]): any;
174
- addHook<K extends keyof import("sequelize/types/hooks").SequelizeHooks<sequelize.Model<any, any>, any, any>>(hookType: K, fn: import("sequelize/types/hooks").SequelizeHooks<sequelize.Model<any, any>, any, any>[K]): any;
175
- removeHook<K extends keyof import("sequelize/types/hooks").SequelizeHooks<sequelize.Model<any, any>, any, any>>(hookType: K, name: string): any;
176
- hasHook<K extends keyof import("sequelize/types/hooks").SequelizeHooks<sequelize.Model<any, any>, any, any>>(hookType: K): boolean;
177
- hasHooks<K extends keyof import("sequelize/types/hooks").SequelizeHooks<sequelize.Model<any, any>, any, any>>(hookType: K): boolean;
178
- };
179
- export default _default;
11
+ }
@@ -1,4 +1,5 @@
1
1
  import sequelize from 'sequelize';
2
+ import Database from '~/database/Database';
2
3
  /**
3
4
  * Model base class.
4
5
  */
@@ -15,6 +16,11 @@ export default class Model extends sequelize.Model {
15
16
  * @type {sequelize.ModelAttributes}
16
17
  */
17
18
  protected static attributes: sequelize.ModelAttributes;
19
+ /**
20
+ * Database instance.
21
+ * @type {Database}
22
+ */
23
+ protected static database: Database;
18
24
  /**
19
25
  * Column type.
20
26
  * @see https://sequelize.org/api/v6/variable/index.html#static-variable-DataTypes
@@ -121,7 +127,6 @@ export default class Model extends sequelize.Model {
121
127
  * BookModel.Transaction.ISOLATION_LEVELS.READ_COMMITTED // "READ COMMITTED"
122
128
  * BookModel.Transaction.ISOLATION_LEVELS.REPEATABLE_READ // "REPEATABLE READ"
123
129
  * BookModel.Transaction.ISOLATION_LEVELS.SERIALIZABLE // "SERIALIZABLE"
124
- *
125
130
  * @see https://sequelize.org/api/v6/class/src/transaction.js~transaction
126
131
  * @type {sequelize.Transaction}
127
132
  */
@@ -129,9 +134,9 @@ export default class Model extends sequelize.Model {
129
134
  /**
130
135
  * Initialize the model that represents the table in the DB with attributes and options.
131
136
  * This method is called automatically from within the "express-sweet.mount" method, so you don't have to run it yourself.
132
- * @return {typeof Model} Returns this model class itself.
137
+ * @return {Promise<typeof Model>} Returns this model class itself.
133
138
  */
134
- static initialize(): (typeof Model);
139
+ static initialize(): Promise<typeof Model>;
135
140
  /**
136
141
  * Associate the model.
137
142
  * Define associations with other models such as "hasOne", "hasMany", "belongsTo", "belongsToMany".
@@ -166,10 +171,8 @@ export default class Model extends sequelize.Model {
166
171
  * await book.save({transaction});
167
172
  * await transaction.commit();
168
173
  *
169
- * // Check the update result.
170
- * // results in: New title of book: When Im Gone
174
+ * // Load updated data.
171
175
  * await book.reload();
172
- * console.log(`New title of book: ${book.title}`);
173
176
  * } catch (err) {
174
177
  * if (transaction)
175
178
  * await transaction.rollback();
@@ -2,6 +2,7 @@
2
2
  * Model initialization and association.
3
3
  * All models must be pre-loaded before associating models.So it loads and caches all defined models in advance.
4
4
  * This must be done before any method that may load other models is called.
5
+ * @return {Promise<void>}
5
6
  */
6
- declare const _default: () => void;
7
+ declare const _default: () => Promise<void>;
7
8
  export default _default;
@@ -1,12 +1,8 @@
1
1
  /**
2
2
  * Determine whether or not two values are equal (===).
3
3
  * @example
4
- * {{!-- results in: false --}}
5
- * {{eq '3' 3}}
6
- *
7
- * {{#if (eqw foo 'bar')}}
8
- * Hello
9
- * {{/if}}
4
+ * {{eq val1 val2}}
5
+ * {{#if (eqw val1 val2)}}...{{/if}}
10
6
  * @param {any} value1 First value to be compared with second.
11
7
  * @param {any} value2 Second value to be compared with first.
12
8
  * @return {boolean} Returns true if the value and type are the same, false if they are different.
@@ -15,12 +11,8 @@ export declare const eq: (value1: any, value2: any) => boolean;
15
11
  /**
16
12
  * Determine whether or not two values are equal (==) i.e weak checking.
17
13
  * @example
18
- * {{!-- results in: true --}}
19
- * {{eqw '3' 3}}
20
- *
21
- * {{#if (eqw foo 'bar')}}
22
- * Hello
23
- * {/if}}
14
+ * {{eqw val1 val2}}
15
+ * {{#if (eqw val1 val2)}}...{{/if}}
24
16
  * @param {any} value1 First value to be compared with second.
25
17
  * @param {any} value2 Second value to be compared with first.
26
18
  * @return {boolean} Returns true if the values are the same, false if they are different.
@@ -29,12 +21,8 @@ export declare const eqw: (value1: any, value2: any) => boolean;
29
21
  /**
30
22
  * Determine whether or not two values are not equal (!==).
31
23
  * @example
32
- * {{!-- results in: true --}}
33
- * {{neq 4 3}}
34
- *
35
- * {{#if (neq foo 'bar')}}
36
- * Hello
37
- * {{/if}}
24
+ * {{neq val1 val2}}
25
+ * {{#if (neq val1 val2)}}...{{/if}}
38
26
  * @param {any} value1 First value to be compared with second.
39
27
  * @param {any} value2 Second value to be compared with first.
40
28
  * @return {boolean} Returns true if the value and type are different, false if they are the same.
@@ -43,12 +31,8 @@ export declare const neq: (value1: any, value2: any) => boolean;
43
31
  /**
44
32
  * Determine whether or not two values are not equal (!=) weak checking.
45
33
  * @example
46
- * {{!-- results in: false --}}
47
- * {{neqw '3' 3}}
48
- *
49
- * {{#if (neqw foo 'bar')}}
50
- * Hello
51
- * {{/if}}
34
+ * {{neqw val1 val2}}
35
+ * {{#if (neqw val1 val2)}}...{{/if}}
52
36
  * @param {any} value1 First value to be compared with second.
53
37
  * @param {any} value2 Second value to be compared with first.
54
38
  * @return {boolean} Returns true if the values are different, false if they are the same.
@@ -57,12 +41,8 @@ export declare const neqw: (value1: any, value2: any) => boolean;
57
41
  /**
58
42
  * Check for less than condition (a < b).
59
43
  * @example
60
- * {{!-- results in: true --}}
61
- * {{lt 2 3}}
62
- *
63
- * {{#if (lt 2 5)}}
64
- * Hello
65
- * {{/if}}
44
+ * {{lt val1 val2}}
45
+ * {{#if (lt val1 val2)}}...{{/if}}
66
46
  * @param {any} value1 First value to be compared with second.
67
47
  * @param {any} value2 Second value to be compared with first.
68
48
  * @return {boolean} Returns true if the first value is less than the second value, false otherwise.
@@ -71,12 +51,8 @@ export declare const lt: (value1: any, value2: any) => boolean;
71
51
  /**
72
52
  * Check for less than or equals condition (a <= b).
73
53
  * @example
74
- * {{!-- results in: true --}}
75
- * {{lte 2 3}}
76
- *
77
- * {{#if (lte 2 5)}}
78
- * Hello
79
- * {{/if}}
54
+ * {{lte val1 val2}}
55
+ * {{#if (lte val1 val2)}}...{{/if}}
80
56
  * @param {any} value1 First value to be compared with second.
81
57
  * @param {any} value2 Second value to be compared with first.
82
58
  * @return {boolean} Returns true if the first value is less than or equal to the second value, false otherwise.
@@ -85,12 +61,8 @@ export declare const lte: (value1: any, value2: any) => boolean;
85
61
  /**
86
62
  * Check for greater than condition (a > b).
87
63
  * @example
88
- * {{!-- results in: false --}}
89
- * {{gt 2 3}}
90
- *
91
- * {{#if (gt 5 6)}}
92
- * Hello
93
- * {{/if}}
64
+ * {{gt val1 val2}}
65
+ * {{#if (gt val1 val2)}}...{{/if}}
94
66
  * @param {any} value1 First value to be compared with second.
95
67
  * @param {any} value2 Second value to be compared with first.
96
68
  * @return {boolean} Returns true if the first value exceeds the second value, false otherwise.
@@ -99,12 +71,8 @@ export declare const gt: (value1: any, value2: any) => boolean;
99
71
  /**
100
72
  * Check for greater than or equals condition (a >= b).
101
73
  * @example
102
- * {{!-- results in: true --}}
103
- * {{gte 3 3}}
104
- *
105
- * {{#if (gte 10 2)}}
106
- * Hello
107
- * {{/if}}
74
+ * {{gte val1 val2}}
75
+ * {{#if (gte val1 val2)}}...{{/if}}
108
76
  * @param {any} value1 First value to be compared with second.
109
77
  * @param {any} value2 Second value to be compared with first.
110
78
  * @return {boolean} Returns true if the first value is greater than or equal to the second value, false otherwise.
@@ -113,15 +81,8 @@ export declare const gte: (value1: any, value2: any) => boolean;
113
81
  /**
114
82
  * Logical NOT of any expression.
115
83
  * @example
116
- * {{!-- results in: false --}}
117
- * {{not true}}
118
- *
119
- * {{!-- results in: true --}}
120
- * {{not false}}
121
- *
122
- * {{#if (not (eq foo 'bar'))}}
123
- * Hello
124
- * {{/if}}
84
+ * {{not val}}
85
+ * {{#if (not (eq val1 val2))}}...{{/if}}
125
86
  * @param {any} expression Any expression.
126
87
  * @return {boolean} Returns the logical negation of the value.
127
88
  */
@@ -129,24 +90,12 @@ export declare const not: (expression: any) => boolean;
129
90
  /**
130
91
  * Helper to imitate the ternary '?:' conditional operator.
131
92
  * @example
132
- * {{!-- results in: foo --}}
133
- * {{ifx true 'foo' 'bar'}}
134
- *
135
- * {{!-- results in: bar --}}
136
- * {{ifx false 'foo' 'bar'}}
137
- *
138
- * {{!-- results in: 6 --}}
139
- * {{ifx (eq value 1) 5 6}}
140
- *
141
- * {{!-- results in: 6 --}}
142
- * {{ifx (not (eq value 1)) 5 6}}
143
- *
144
- * {{!-- The third parameter is optional, and by default it will be blank string ('') --}}
145
- * {{!-- results in: active --}}
146
- * {{ifx true 'active'}}
147
- *
148
- * {{!-- results in: '' --}}
149
- * {{ifx false 'active'}}
93
+ * {{ifx true val1 val2}}
94
+ * {{ifx false val1 val2}}
95
+ * {{ifx (eq val1 val2) val3 val4}}
96
+ * {{ifx (not (eq val1 val2)) val3 val4}}
97
+ * {{ifx true val}}
98
+ * {{ifx false val}}
150
99
  * @param {boolean} condition Satisfying condition for getting first value. Either true of false.
151
100
  * @param {any} value1 First value to be displayed as result..
152
101
  * @param {any} value2 Second value to be displayed as result. Defaults to an empty string.
@@ -158,21 +107,8 @@ export declare const ifx: (condition: boolean, value1: any, value2: any) => any;
158
107
  * If the value is an array, returns true if there are no elements.
159
108
  * If the value is a string, the leading and trailing spaces are trimmed and then checked.
160
109
  * @example
161
- * {{!-- results in: false --}}
162
- * {{empty [5, 6]}}
163
- *
164
- * {{#if (empty 'foo')}}
165
- * Hello
166
- * {{/if}}
167
- *
168
- * {{!-- results in: false --}}
169
- * {{empty 'Hello'}}
170
- *
171
- * {{!-- results in: true --}}
172
- * {{empty ''}}
173
- *
174
- * {{!-- results in: true --}}
175
- * {{empty ' '}}
110
+ * {{empty val}}
111
+ * {{#if (empty val)}}...{{/if}}
176
112
  * @param {any} value Character strings, arrays, objects, etc. to be checked.
177
113
  * @return {boolean} Returns true if the value is empty, false otherwise.
178
114
  */
@@ -182,31 +118,16 @@ export declare const empty: (value: any) => boolean;
182
118
  * If the value is an array, returns true if there is an element.
183
119
  * If the value is a string, the leading and trailing spaces are trimmed and then checked.
184
120
  * @example
185
- * {{!-- results in: true --}}
186
- * {{notEmpty [5, 6]}}
187
- *
188
- * {{#if (notEmpty 'foo')}}
189
- * Hello
190
- * {{/if}}
191
- *
192
- * {{!-- results in: true --}}
193
- * {{notEmpty 'Hello'}}
194
- *
195
- * {{!-- results in: false --}}
196
- * {{notEmpty ''}}
197
- *
198
- * {{!-- results in: false --}}
199
- * {{notEmpty ' '}}
121
+ * {{notEmpty val}}
122
+ * {{#if (notEmpty val)}}...{{/if}}
200
123
  * @param {any} value Character strings, arrays, objects, etc. to be checked.
201
124
  * @return {boolean} Returns true if the value is not empty, false otherwise.
202
125
  */
203
126
  export declare const notEmpty: (value: any) => boolean;
204
127
  /**
205
128
  * Determine the length of an array.
206
- *
207
129
  * @example
208
- * {{!-- results in: 2 --}}
209
- * {{count [5, 6]}}
130
+ * {{count val}}
210
131
  * @param {any[]} items Array whose elements to be counted.
211
132
  * @return {number|false} Returns the length of the array if the value is an array, false if the value is not an array.
212
133
  */
@@ -214,17 +135,8 @@ export declare const count: (items: any[]) => number | false;
214
135
  /**
215
136
  * Returns the boolean AND of two or more parameters passed i.e it is true iff all the parameters are true.
216
137
  * @example
217
- * {{!-- results in: true --}}
218
- * {{and true true}}
219
- *
220
- * {{!-- results in: false --}}
221
- * {{and false true}}
222
- *
223
- * {{#if (and value1 value2)}}
224
- * {{!-- do something --}}
225
- * {{else}}
226
- * {{!-- do something else --}}
227
- * {{/if}}
138
+ * {{and val1 val2}}
139
+ * {{#if (and val1 val2)}}...{{/if}}
228
140
  * @param {...any} params Any number of boolean parameters.
229
141
  * @return {boolean} Returns the result of the logical product.
230
142
  */
@@ -232,17 +144,8 @@ export declare const and: (...params: any[]) => boolean;
232
144
  /**
233
145
  * Returns the boolean OR of two or more parameters passed i.e it is true if any of the parameters is true.
234
146
  * @example
235
- * {{!-- results in: true --}}
236
- * {{or true false}}
237
- *
238
- * {{!-- results in: false --}}
239
- * {{or false false}}
240
- *
241
- * {{#if (or value1 value2)}}
242
- * {{!-- do something --}}
243
- * {{else}}
244
- * {{!-- do something else --}}
245
- * {{/if}}
147
+ * {{or val1 val2}}
148
+ * {{#if (or val1 val2)}}...{{/if}}
246
149
  * @param {...any} params Any number of boolean parameters.
247
150
  * @return {boolean} Returns the result of the OR.
248
151
  */
@@ -251,11 +154,7 @@ export declare const or: (...params: any[]) => boolean;
251
154
  * Returns the first non-falsy value from the parameter list.
252
155
  * Works quite similar to the SQL's "COALESCE()" function, but unlike this checks for the first non-false parameter.
253
156
  * @example
254
- * {{!-- results in: foo bar --}}
255
- * {{coalesce 'foo bar' 'foob' 'unknown'}}
256
- *
257
- * {{!-- results in: foob --}}
258
- * {{coalesce '' 'foob' 'unknown'}}
157
+ * {{coalesce val1 val2}}
259
158
  * @param {...any} params Any number of parameters.
260
159
  * @return {any} Returns the first non-false element of the parameter.
261
160
  */
@@ -263,23 +162,10 @@ export declare const coalesce: (...params: any[]) => any;
263
162
  /**
264
163
  * Returns boolean if the array contains the element strictly or non-strictly.
265
164
  * @example
266
- * {{!-- results in: true --}}
267
165
  * {{includes [1, 2, 3] 2}}
268
- *
269
- * {{!-- results in: false --}}
270
- * {{includes [1, 2, 3] '2'}}
271
- *
272
- * {{!-- results in: false --}}
273
- * {{includes [1, 2, 3] '2' true}}
274
- *
275
- * {{!-- results in: true --}}
276
- * {{includes [1, 2, 3] '2' false}}
277
- *
278
- * {{#if (includes [1, 2, 3] '2')}}
279
- * {{!-- Do something --}}
280
- * {{/if}}
281
- *
282
- * {{ifx (includes [1, 2, 3] '2') 'yes' 'no'}}
166
+ * {{includes [1, 2, 3] 2 true}}
167
+ * {{#if (includes [1, 2, 3] 2)}}...{{/if}}
168
+ * {{ifx (includes [1, 2, 3] 2) true false}}
283
169
  * @param {any[]} items The array.
284
170
  * @param {any} value The value to be checked for existence in the array.
285
171
  * @param {boolean} strict FALSE for non-strict checking. TRUE by default.
@@ -289,25 +175,9 @@ export declare const includes: (items: any[], value: any, strict?: boolean) => b
289
175
  /**
290
176
  * Returns true if the given str matches the given regex.
291
177
  * @example
292
- * {{!-- results in: true --}}
293
- * {{regexMatch 'foobar' 'foo'}}
294
- *
295
- * {{!-- results in: false --}}
296
- * {{regexMatch 'bar' 'foo'}}
297
- *
298
- * {{!-- results in: false --}}
299
- * {{regexMatch 'foobar' '^foo$'}}
300
- *
301
- * {{!-- results in: true --}}
302
- * {{regexMatch 'Visit Here' 'here' 'i'}}
303
- *
304
- * {{!-- results in: false --}}
305
- * {{regexMatch 'Visit Here' 'here'}}
306
- *
307
- * {{!-- results in: Match --}}
308
- * {{#if (regexMatch 'foobar' 'foo')}}
309
- * Match
310
- * {{/if}}
178
+ * {{regexMatch 'Hello, world!' 'Hello'}}
179
+ * {{regexMatch 'Hello, world!' 'Hello' 'i'}}
180
+ * {{#if (regexMatch 'Hello, world!' 'Hello')}}...{{/if}}
311
181
  * @param {string} val The string against which to match the regular expression.
312
182
  * @param {string} pattern The text of the regular expression.
313
183
  * @param {string} flags? Regular expression flags, such as global and case-insensitive searches. The default is none (undefined).
@@ -5,3 +5,4 @@ export * as comparison from '~/handlebars_helpers/comparison';
5
5
  export * as date from '~/handlebars_helpers/date';
6
6
  export * as number from '~/handlebars_helpers/number';
7
7
  export * as math from '~/handlebars_helpers/math';
8
+ export * as layouts from '~/handlebars_helpers/layouts';