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.
Files changed (123) hide show
  1. package/.jsdoc.conf.json +1 -1
  2. package/docs/Dobo.html +1 -24
  3. package/docs/DoboAction.html +13 -0
  4. package/docs/DoboAdapter.html +3 -0
  5. package/docs/DoboConnection.html +3 -0
  6. package/docs/DoboFeature.html +3 -0
  7. package/docs/DoboModel.html +51 -0
  8. package/docs/data/search.json +1 -1
  9. package/docs/extend_bajo_hook-docs.js.html +241 -0
  10. package/docs/external-Tools.html +3 -0
  11. package/docs/global.html +1 -5
  12. package/docs/index.html +1 -1
  13. package/docs/index.js.html +434 -380
  14. package/docs/lib_factory_action.js.html +290 -0
  15. package/docs/lib_factory_adapter.js.html +1057 -0
  16. package/docs/lib_factory_connection.js.html +112 -0
  17. package/docs/lib_factory_feature.js.html +55 -0
  18. package/docs/lib_factory_model.js.html +503 -0
  19. package/docs/lib_factory_model_build.js.html +28 -0
  20. package/docs/lib_factory_model_clear-record.js.html +33 -0
  21. package/docs/lib_factory_model_count-record.js.html +45 -0
  22. package/docs/lib_factory_model_create-record.js.html +52 -0
  23. package/docs/lib_factory_model_drop.js.html +29 -0
  24. package/docs/lib_factory_model_exists.js.html +29 -0
  25. package/docs/lib_factory_model_find-all-record.js.html +115 -0
  26. package/docs/lib_factory_model_find-one-record.js.html +41 -0
  27. package/docs/lib_factory_model_find-record.js.html +85 -0
  28. package/docs/lib_factory_model_get-record.js.html +55 -0
  29. package/docs/lib_factory_model_helper.js.html +579 -0
  30. package/docs/lib_factory_model_remove-record.js.html +47 -0
  31. package/docs/lib_factory_model_sanitize-body.js.html +60 -0
  32. package/docs/lib_factory_model_sanitize-fixture.js.html +59 -0
  33. package/docs/lib_factory_model_sanitize-record.js.html +73 -0
  34. package/docs/lib_factory_model_update-record.js.html +61 -0
  35. package/docs/lib_factory_model_upsert-record.js.html +74 -0
  36. package/docs/{method_validate.js.html → lib_factory_model_validate.js.html} +109 -73
  37. package/docs/lib_helper.js.html +466 -0
  38. package/docs/module-Helper.html +3 -0
  39. package/docs/module-Helper_Model.html +3 -0
  40. package/docs/module-Hook.html +15 -0
  41. package/docs/scripts/core.js +477 -476
  42. package/docs/scripts/resize.js +36 -36
  43. package/docs/scripts/search.js +105 -105
  44. package/docs/scripts/third-party/fuse.js +1 -1
  45. package/docs/scripts/third-party/hljs-line-num-original.js +285 -282
  46. package/docs/scripts/third-party/hljs-line-num.js +1 -1
  47. package/docs/scripts/third-party/hljs-original.js +1202 -1195
  48. package/docs/scripts/third-party/hljs.js +1 -1
  49. package/docs/scripts/third-party/popper.js +1 -1
  50. package/docs/scripts/third-party/tippy.js +1 -1
  51. package/docs/scripts/third-party/tocbot.js +509 -508
  52. package/docs/static/home.md +3 -1
  53. package/extend/bajo/hook-docs.js +238 -0
  54. package/extend/bajo/intl/en-US.json +9 -9
  55. package/extend/bajo/intl/id.json +9 -9
  56. package/extend/bajoCli/applet/rebuild-model.js +2 -2
  57. package/extend/dobo/{driver → adapter}/memory.js +6 -6
  58. package/extend/dobo/feature/immutable.js +2 -2
  59. package/extend/dobo/feature/removed-at.js +1 -1
  60. package/index.js +33 -30
  61. package/lib/factory/action.js +145 -18
  62. package/lib/factory/adapter.js +1054 -0
  63. package/lib/factory/connection.js +46 -22
  64. package/lib/factory/feature.js +23 -3
  65. package/lib/factory/model/build.js +11 -2
  66. package/lib/factory/model/bulk-create-record.js +2 -2
  67. package/lib/factory/model/clear-record.js +13 -3
  68. package/lib/factory/model/count-record.js +13 -2
  69. package/lib/factory/model/create-aggregate.js +2 -2
  70. package/lib/factory/model/create-attachment.js +1 -1
  71. package/lib/factory/model/create-histogram.js +2 -2
  72. package/lib/factory/model/create-record.js +15 -2
  73. package/lib/factory/model/drop.js +12 -2
  74. package/lib/factory/model/exists.js +10 -6
  75. package/lib/factory/model/find-all-record.js +14 -3
  76. package/lib/factory/model/find-attachment.js +1 -1
  77. package/lib/factory/model/find-one-record.js +13 -1
  78. package/lib/factory/model/find-record.js +17 -53
  79. package/lib/factory/model/get-record.js +11 -39
  80. package/lib/factory/model/{_util.js → helper.js} +176 -16
  81. package/lib/factory/model/remove-attachment.js +1 -1
  82. package/lib/factory/model/remove-record.js +11 -28
  83. package/lib/factory/model/sanitize-body.js +14 -12
  84. package/lib/factory/model/sanitize-fixture.js +17 -4
  85. package/lib/factory/model/sanitize-record.js +9 -6
  86. package/lib/factory/model/transaction.js +2 -2
  87. package/lib/factory/model/update-record.js +12 -40
  88. package/lib/factory/model/upsert-record.js +13 -42
  89. package/lib/factory/model/validate.js +47 -14
  90. package/lib/factory/model.js +301 -23
  91. package/lib/{collect-models.js → helper.js} +463 -364
  92. package/package.json +1 -1
  93. package/wiki/CHANGES.md +17 -7
  94. package/wiki/ECOSYSTEM.md +7 -7
  95. package/wiki/GETTING-STARTED.md +3 -3
  96. package/wiki/QUERY-LANGUAGE.md +1 -1
  97. package/docs/lib_collect-connections.js.html +0 -39
  98. package/docs/lib_collect-drivers.js.html +0 -52
  99. package/docs/lib_collect-features.js.html +0 -36
  100. package/docs/lib_collect-schemas.js.html +0 -94
  101. package/docs/lib_index.js.html +0 -6
  102. package/docs/method_model_create.js.html +0 -35
  103. package/docs/method_model_drop.js.html +0 -34
  104. package/docs/method_model_exists.js.html +0 -40
  105. package/docs/method_record_count.js.html +0 -69
  106. package/docs/method_record_create.js.html +0 -114
  107. package/docs/method_record_find-all.js.html +0 -44
  108. package/docs/method_record_find-one.js.html +0 -73
  109. package/docs/method_record_find.js.html +0 -118
  110. package/docs/method_record_get.js.html +0 -92
  111. package/docs/method_record_remove.js.html +0 -75
  112. package/docs/method_record_update.js.html +0 -107
  113. package/docs/method_record_upsert.js.html +0 -54
  114. package/docs/method_sanitize_body.js.html +0 -88
  115. package/docs/method_sanitize_date.js.html +0 -30
  116. package/docs/method_sanitize_id.js.html +0 -20
  117. package/docs/module-Lib.html +0 -3
  118. package/lib/collect-connections.js +0 -56
  119. package/lib/collect-drivers.js +0 -35
  120. package/lib/collect-features.js +0 -40
  121. package/lib/factory/driver.js +0 -574
  122. package/lib/factory/model/sanitize-id.js +0 -7
  123. package/lib/index.js +0 -3
@@ -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: true,
25
- noBodySanitizer: true,
26
- noResultSanitizer: true,
27
- noValidation: true,
87
+ noResult: false,
88
+ noBodySanitizer: false,
89
+ noResultSanitizer: false,
90
+ noValidation: false,
28
91
  dataOnly: true,
29
- noHook: true,
30
- noModelHook: true,
92
+ noHook: false,
93
+ noModelHook: false,
94
+ noDynHook: false,
31
95
  extFields: [],
32
96
  fields: [],
33
- noFlash: true,
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 normall call. Examples:
131
+ * in addition of the normal call.
62
132
  *
63
- * ```javascript
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 result = await model.action().getRecord('rec-id').noHook().dataOnly(false).run()
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('getRecord').id('rec-id').noHook().dataOnly(false).run()
149
+ * const result = await model.action().getRecord('rec-id').noHook().dataOnly(false).run()
68
150
  * // method 3:
69
- * const result = await model.action('getRecord', 'rec-id').noHook().dataOnly(false).run()
151
+ * const result = await model.action('getRecord').id('rec-id').noHook().dataOnly(false).run()
70
152
  * // method 4:
71
- * const action = await model.getRecord() // Important: no parameter passed
72
- * const result = action.id('rec-id').noHook().dataOnly(false).run()
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