dobo 2.30.7 → 2.32.0
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/.jsdoc.conf.json +1 -1
- package/docs/Dobo.html +1 -24
- package/docs/DoboAction.html +13 -0
- package/docs/DoboAdapter.html +3 -0
- package/docs/DoboConnection.html +3 -0
- package/docs/DoboFeature.html +3 -0
- package/docs/DoboModel.html +51 -0
- package/docs/data/search.json +1 -1
- package/docs/extend_bajo_hook-docs.js.html +241 -0
- package/docs/external-Tools.html +3 -0
- package/docs/global.html +1 -5
- package/docs/index.html +1 -1
- package/docs/index.js.html +434 -380
- package/docs/lib_factory_action.js.html +290 -0
- package/docs/lib_factory_adapter.js.html +1057 -0
- package/docs/lib_factory_connection.js.html +112 -0
- package/docs/lib_factory_feature.js.html +55 -0
- package/docs/lib_factory_model.js.html +503 -0
- package/docs/lib_factory_model_build.js.html +28 -0
- package/docs/lib_factory_model_clear-record.js.html +33 -0
- package/docs/lib_factory_model_count-record.js.html +45 -0
- package/docs/lib_factory_model_create-record.js.html +52 -0
- package/docs/lib_factory_model_drop.js.html +29 -0
- package/docs/lib_factory_model_exists.js.html +29 -0
- package/docs/lib_factory_model_find-all-record.js.html +115 -0
- package/docs/lib_factory_model_find-one-record.js.html +41 -0
- package/docs/lib_factory_model_find-record.js.html +85 -0
- package/docs/lib_factory_model_get-record.js.html +55 -0
- package/docs/lib_factory_model_helper.js.html +579 -0
- package/docs/lib_factory_model_remove-record.js.html +47 -0
- package/docs/lib_factory_model_sanitize-body.js.html +60 -0
- package/docs/lib_factory_model_sanitize-fixture.js.html +59 -0
- package/docs/lib_factory_model_sanitize-record.js.html +73 -0
- package/docs/lib_factory_model_update-record.js.html +61 -0
- package/docs/lib_factory_model_upsert-record.js.html +74 -0
- package/docs/{method_validate.js.html → lib_factory_model_validate.js.html} +109 -73
- package/docs/lib_helper.js.html +466 -0
- package/docs/module-Helper.html +3 -0
- package/docs/module-Helper_Model.html +3 -0
- package/docs/module-Hook.html +15 -0
- package/docs/scripts/core.js +477 -476
- package/docs/scripts/resize.js +36 -36
- package/docs/scripts/search.js +105 -105
- package/docs/scripts/third-party/fuse.js +1 -1
- package/docs/scripts/third-party/hljs-line-num-original.js +285 -282
- package/docs/scripts/third-party/hljs-line-num.js +1 -1
- package/docs/scripts/third-party/hljs-original.js +1202 -1195
- package/docs/scripts/third-party/hljs.js +1 -1
- package/docs/scripts/third-party/popper.js +1 -1
- package/docs/scripts/third-party/tippy.js +1 -1
- package/docs/scripts/third-party/tocbot.js +509 -508
- package/docs/static/home.md +3 -1
- package/extend/bajo/hook-docs.js +238 -0
- package/extend/bajo/intl/en-US.json +9 -9
- package/extend/bajo/intl/id.json +9 -9
- package/extend/bajoCli/applet/rebuild-model.js +2 -2
- package/extend/dobo/{driver → adapter}/memory.js +6 -6
- package/extend/dobo/feature/immutable.js +2 -2
- package/extend/dobo/feature/removed-at.js +1 -1
- package/index.js +33 -30
- package/lib/factory/action.js +145 -18
- package/lib/factory/adapter.js +1054 -0
- package/lib/factory/connection.js +46 -22
- package/lib/factory/feature.js +23 -3
- package/lib/factory/model/build.js +11 -2
- package/lib/factory/model/bulk-create-record.js +2 -2
- package/lib/factory/model/clear-record.js +13 -3
- package/lib/factory/model/count-record.js +13 -2
- package/lib/factory/model/create-aggregate.js +2 -2
- package/lib/factory/model/create-attachment.js +1 -1
- package/lib/factory/model/create-histogram.js +2 -2
- package/lib/factory/model/create-record.js +15 -2
- package/lib/factory/model/drop.js +12 -2
- package/lib/factory/model/exists.js +10 -6
- package/lib/factory/model/find-all-record.js +14 -3
- package/lib/factory/model/find-attachment.js +1 -1
- package/lib/factory/model/find-one-record.js +13 -1
- package/lib/factory/model/find-record.js +17 -53
- package/lib/factory/model/get-record.js +11 -39
- package/lib/factory/model/{_util.js → helper.js} +176 -16
- package/lib/factory/model/remove-attachment.js +1 -1
- package/lib/factory/model/remove-record.js +11 -28
- package/lib/factory/model/sanitize-body.js +14 -12
- package/lib/factory/model/sanitize-fixture.js +17 -4
- package/lib/factory/model/sanitize-record.js +9 -6
- package/lib/factory/model/transaction.js +2 -2
- package/lib/factory/model/update-record.js +12 -40
- package/lib/factory/model/upsert-record.js +13 -42
- package/lib/factory/model/validate.js +47 -14
- package/lib/factory/model.js +301 -23
- package/lib/{collect-models.js → helper.js} +463 -364
- package/package.json +1 -1
- package/wiki/CHANGES.md +17 -7
- package/wiki/ECOSYSTEM.md +7 -7
- package/wiki/GETTING-STARTED.md +3 -3
- package/wiki/QUERY-LANGUAGE.md +1 -1
- package/docs/lib_collect-connections.js.html +0 -39
- package/docs/lib_collect-drivers.js.html +0 -52
- package/docs/lib_collect-features.js.html +0 -36
- package/docs/lib_collect-schemas.js.html +0 -94
- package/docs/lib_index.js.html +0 -6
- package/docs/method_model_create.js.html +0 -35
- package/docs/method_model_drop.js.html +0 -34
- package/docs/method_model_exists.js.html +0 -40
- package/docs/method_record_count.js.html +0 -69
- package/docs/method_record_create.js.html +0 -114
- package/docs/method_record_find-all.js.html +0 -44
- package/docs/method_record_find-one.js.html +0 -73
- package/docs/method_record_find.js.html +0 -118
- package/docs/method_record_get.js.html +0 -92
- package/docs/method_record_remove.js.html +0 -75
- package/docs/method_record_update.js.html +0 -107
- package/docs/method_record_upsert.js.html +0 -54
- package/docs/method_sanitize_body.js.html +0 -88
- package/docs/method_sanitize_date.js.html +0 -30
- package/docs/method_sanitize_id.js.html +0 -20
- package/docs/module-Lib.html +0 -3
- package/lib/collect-connections.js +0 -56
- package/lib/collect-drivers.js +0 -35
- package/lib/collect-features.js +0 -40
- package/lib/factory/driver.js +0 -574
- package/lib/factory/model/sanitize-id.js +0 -7
- package/lib/index.js +0 -3
package/lib/factory/action.js
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dobo model's chainable methods. Only the keys listed here are allowed to be called in chainable methods.
|
|
3
|
+
* The values are the only allowed arguments for the corresponding chainable methods.
|
|
4
|
+
* @typedef {Object} TMethods
|
|
5
|
+
* @type {Object}
|
|
6
|
+
* @memberof DoboAction
|
|
7
|
+
* @property {string[]} [createRecord=['body']]
|
|
8
|
+
* @property {string[]} [updateRecord=['id', 'body']]
|
|
9
|
+
* @property {string[]} [upsertRecord=['body']]
|
|
10
|
+
* @property {string[]} [removeRecord=['id']]
|
|
11
|
+
* @property {string[]} [getRecord=['id']]
|
|
12
|
+
* @property {string[]} [findRecord=['filter']]
|
|
13
|
+
* @property {string[]} [findOneRecord=['filter']]
|
|
14
|
+
* @property {string[]} [findAllRecord=['filter']]
|
|
15
|
+
* @property {string[]} [findAllRecords=['filter']] - Alias of `findAllRecord`
|
|
16
|
+
* @property {string[]} [countRecord=['params']]
|
|
17
|
+
* @property {string[]} [createAggregate=['params']]
|
|
18
|
+
* @property {string[]} [createHistogram=['params']]
|
|
19
|
+
* @property {string[]} [createAttachment=['id']]
|
|
20
|
+
* @property {string[]} [findAttachment=['id']]
|
|
21
|
+
* @property {string[]} [getAttachment=['id', 'field', 'file']]
|
|
22
|
+
* @property {string[]} [listAttachment=['params']]
|
|
23
|
+
* @property {string[]} [removeAttachment=['id', 'field', 'file']]
|
|
24
|
+
* @property {string[]} [updateAttachment=['id']]
|
|
25
|
+
*/
|
|
1
26
|
const methods = {
|
|
2
27
|
createRecord: ['body'],
|
|
3
28
|
updateRecord: ['id', 'body'],
|
|
@@ -19,18 +44,57 @@ const methods = {
|
|
|
19
44
|
updateAttachment: ['id']
|
|
20
45
|
}
|
|
21
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Allowed options for Dobo model's chainable methods. Only the keys listed here are allowed to be called
|
|
49
|
+
* in chainable methods. The values are the default values for the corresponding options.
|
|
50
|
+
* @typedef {Object} TOptions
|
|
51
|
+
* @type {Object}
|
|
52
|
+
* @memberof DoboAction
|
|
53
|
+
* @property {boolean} [truncateString=true]
|
|
54
|
+
* @property {boolean} [noResult=false]
|
|
55
|
+
* @property {boolean} [noBodySanitizer=false]
|
|
56
|
+
* @property {boolean} [noResultSanitizer=false]
|
|
57
|
+
* @property {boolean} [noValidation=false]
|
|
58
|
+
* @property {boolean} [dataOnly=true]
|
|
59
|
+
* @property {boolean} [noHook=false]
|
|
60
|
+
* @property {boolean} [noModelHook=false]
|
|
61
|
+
* @property {boolean} [noDynHook=false]
|
|
62
|
+
* @property {Array} [extFields=[]]
|
|
63
|
+
* @property {Array} [fields=[]]
|
|
64
|
+
* @property {boolean} [noFlash=false]
|
|
65
|
+
* @property {Array} [hidden=[]]
|
|
66
|
+
* @property {Array} [refs=[]]
|
|
67
|
+
* @property {Array} [types=[]]
|
|
68
|
+
* @property {string|undefined} [type=undefined]
|
|
69
|
+
* @property {string|undefined} [group=undefined]
|
|
70
|
+
* @property {Array} [aggregates=[]]
|
|
71
|
+
* @property {string|undefined} [field=undefined]
|
|
72
|
+
* @property {string|undefined} [queryHandler=undefined]
|
|
73
|
+
* @property {boolean} [count=true]
|
|
74
|
+
* @property {boolean} [noCache=true]
|
|
75
|
+
* @property {boolean} [partial=true]
|
|
76
|
+
* @property {boolean} [mimeType=true]
|
|
77
|
+
* @property {boolean} [fullPath=true]
|
|
78
|
+
* @property {boolean} [stats=true]
|
|
79
|
+
* @property {boolean} [dirOnly=true]
|
|
80
|
+
* @property {string|undefined} [setField=undefined]
|
|
81
|
+
* @property {string|undefined} [setFile=undefined]
|
|
82
|
+
* @property {string|undefined} [source=undefined]
|
|
83
|
+
* @property {boolean} [uriEncoded=true]
|
|
84
|
+
*/
|
|
22
85
|
const options = {
|
|
23
86
|
truncateString: true,
|
|
24
|
-
noResult:
|
|
25
|
-
noBodySanitizer:
|
|
26
|
-
noResultSanitizer:
|
|
27
|
-
noValidation:
|
|
87
|
+
noResult: false,
|
|
88
|
+
noBodySanitizer: false,
|
|
89
|
+
noResultSanitizer: false,
|
|
90
|
+
noValidation: false,
|
|
28
91
|
dataOnly: true,
|
|
29
|
-
noHook:
|
|
30
|
-
noModelHook:
|
|
92
|
+
noHook: false,
|
|
93
|
+
noModelHook: false,
|
|
94
|
+
noDynHook: false,
|
|
31
95
|
extFields: [],
|
|
32
96
|
fields: [],
|
|
33
|
-
noFlash:
|
|
97
|
+
noFlash: false,
|
|
34
98
|
hidden: [],
|
|
35
99
|
refs: [],
|
|
36
100
|
types: [],
|
|
@@ -53,28 +117,42 @@ const options = {
|
|
|
53
117
|
uriEncoded: true
|
|
54
118
|
}
|
|
55
119
|
|
|
120
|
+
/**
|
|
121
|
+
* Action factory function
|
|
122
|
+
*
|
|
123
|
+
* @async
|
|
124
|
+
* @returns {Promise<void>}
|
|
125
|
+
*/
|
|
56
126
|
async function actionFactory () {
|
|
57
127
|
const { Tools } = this.app.baseClass
|
|
58
128
|
|
|
59
129
|
/**
|
|
60
130
|
* Action class enables you to call model's method with all parameters and options in chainable methods
|
|
61
|
-
* in addition of the
|
|
131
|
+
* in addition of the normal call.
|
|
62
132
|
*
|
|
63
|
-
*
|
|
133
|
+
* Action class is created by calling model method without any parameter.
|
|
134
|
+
* The resulted class instance can be used to call model's method with all parameters and options
|
|
135
|
+
* in chainable methods.
|
|
136
|
+
*
|
|
137
|
+
* Action class can also be created by calling `model.action()` method, with or without parameters.
|
|
138
|
+
* Please see the example below:
|
|
139
|
+
*
|
|
140
|
+
* You always need to call the `run()` method as the last step. The `run()` method will return the result
|
|
141
|
+
* of the model's method call.
|
|
142
|
+
*
|
|
143
|
+
* @class
|
|
144
|
+
* @example
|
|
64
145
|
* // method 1:
|
|
65
|
-
* const
|
|
146
|
+
* const action = await model.getRecord() // Important: no parameter passed
|
|
147
|
+
* const result = action.id('rec-id').noHook().dataOnly(false).run()
|
|
66
148
|
* // method 2:
|
|
67
|
-
* const result = await model.action(
|
|
149
|
+
* const result = await model.action().getRecord('rec-id').noHook().dataOnly(false).run()
|
|
68
150
|
* // method 3:
|
|
69
|
-
* const result = await model.action('getRecord'
|
|
151
|
+
* const result = await model.action('getRecord').id('rec-id').noHook().dataOnly(false).run()
|
|
70
152
|
* // method 4:
|
|
71
|
-
* const
|
|
72
|
-
*
|
|
73
|
-
* // Instead of chaining options as methods, you can also pass options object to the run() method
|
|
153
|
+
* const result = await model.action('getRecord', 'rec-id').noHook().dataOnly(false).run()
|
|
154
|
+
* // Instead of chaining options as methods, you can also pass options object as the parameter to the run() method
|
|
74
155
|
* const result = await model.action('getRecord', 'rec-id').run({ noHook: true, dataOnly: false })
|
|
75
|
-
* ```
|
|
76
|
-
*
|
|
77
|
-
* @class
|
|
78
156
|
*/
|
|
79
157
|
class DoboAction extends Tools {
|
|
80
158
|
constructor (model, name, ...args) {
|
|
@@ -101,6 +179,15 @@ async function actionFactory () {
|
|
|
101
179
|
}
|
|
102
180
|
}
|
|
103
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Internal method to set the arguments to the instance properties based on the method name
|
|
184
|
+
* and the arguments passed.
|
|
185
|
+
* @internal
|
|
186
|
+
* @method
|
|
187
|
+
* @param {string} method - The name of the method being called
|
|
188
|
+
* @param {Array} args - The arguments passed to the method
|
|
189
|
+
* @returns {void}
|
|
190
|
+
*/
|
|
104
191
|
_setArgs = (method, args) => {
|
|
105
192
|
if (args.length === 0) return
|
|
106
193
|
for (const idx in methods[method]) {
|
|
@@ -108,16 +195,37 @@ async function actionFactory () {
|
|
|
108
195
|
}
|
|
109
196
|
}
|
|
110
197
|
|
|
198
|
+
/**
|
|
199
|
+
* Set the ID for the corresponding record. You need this for `updateRecord` or `removeRecord`
|
|
200
|
+
* operations. This method is chainable.
|
|
201
|
+
* @method
|
|
202
|
+
* @param {string|number} value - The ID value to set
|
|
203
|
+
* @returns {DoboAction} The current instance for chaining
|
|
204
|
+
*/
|
|
111
205
|
id = value => {
|
|
112
206
|
this._id = value
|
|
113
207
|
return this
|
|
114
208
|
}
|
|
115
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Set the body for the corresponding record. You need this for `createRecord`, `updateRecord`
|
|
212
|
+
* or `upsertRecord` operations. This method is chainable.
|
|
213
|
+
* @method
|
|
214
|
+
* @param {object} value - The body value to set
|
|
215
|
+
* @returns {DoboAction} The current instance for chaining
|
|
216
|
+
*/
|
|
116
217
|
body = value => {
|
|
117
218
|
this._body = value
|
|
118
219
|
return this
|
|
119
220
|
}
|
|
120
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Set the filter for the corresponding record. You optionally need this for `findRecord`,
|
|
224
|
+
* `findOneRecord` or `findAllRecord` operations. This method is chainable.
|
|
225
|
+
* @method
|
|
226
|
+
* @param {object} value - The filter value to set
|
|
227
|
+
* @returns {DoboAction} The current instance for chaining
|
|
228
|
+
*/
|
|
121
229
|
filter = value => {
|
|
122
230
|
this._filter = value
|
|
123
231
|
return this
|
|
@@ -133,6 +241,12 @@ async function actionFactory () {
|
|
|
133
241
|
return this
|
|
134
242
|
}
|
|
135
243
|
|
|
244
|
+
/**
|
|
245
|
+
* Set the options for the corresponding method. This method is chainable.
|
|
246
|
+
* @method
|
|
247
|
+
* @param {DoboAction.TOptions} value - The options to set
|
|
248
|
+
* @returns {DoboAction} The current instance for chaining
|
|
249
|
+
*/
|
|
136
250
|
options = (value = {}) => {
|
|
137
251
|
for (const k in value) {
|
|
138
252
|
this._options[k] = value
|
|
@@ -140,6 +254,13 @@ async function actionFactory () {
|
|
|
140
254
|
return this
|
|
141
255
|
}
|
|
142
256
|
|
|
257
|
+
/**
|
|
258
|
+
* Execute the corresponding method with the set arguments and options. This method is chainable.
|
|
259
|
+
* @async
|
|
260
|
+
* @method
|
|
261
|
+
* @param {DoboAction.TOptions} value - If set, it will override the options set by the `options()` method. This is useful if you want to set options at the last step.
|
|
262
|
+
* @returns {Promise<*>} The result of the method execution
|
|
263
|
+
*/
|
|
143
264
|
run = async (value = {}) => {
|
|
144
265
|
this.options(value)
|
|
145
266
|
const args = methods[this.name].map(item => this['_' + item])
|
|
@@ -147,6 +268,12 @@ async function actionFactory () {
|
|
|
147
268
|
return await this.model[this.name](...args)
|
|
148
269
|
}
|
|
149
270
|
|
|
271
|
+
/**
|
|
272
|
+
* Dispose the instance and clean up resources.
|
|
273
|
+
* @async
|
|
274
|
+
* @method
|
|
275
|
+
* @returns {Promise<void>}
|
|
276
|
+
*/
|
|
150
277
|
dispose = async () => {
|
|
151
278
|
await super.dispose()
|
|
152
279
|
this.model = null
|