@rvoh/dream 0.29.2 → 0.29.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 (180) hide show
  1. package/dist/cjs/src/Dream.js +1 -1
  2. package/dist/cjs/src/decorators/Decorators.js +34 -26
  3. package/dist/cjs/src/decorators/sortable/Sortable.js +8 -19
  4. package/dist/cjs/src/index.js +2 -28
  5. package/dist/esm/src/Dream.js +1 -1
  6. package/dist/esm/src/decorators/Decorators.js +34 -26
  7. package/dist/esm/src/decorators/sortable/Sortable.js +8 -19
  8. package/dist/esm/src/index.js +0 -13
  9. package/dist/types/src/Dream.d.ts +1 -1
  10. package/dist/types/src/decorators/Decorators.d.ts +34 -26
  11. package/dist/types/src/index.d.ts +0 -13
  12. package/docs/assets/navigation.js +1 -1
  13. package/docs/assets/search.js +1 -1
  14. package/docs/classes/Benchmark.html +2 -2
  15. package/docs/classes/CalendarDate.html +2 -2
  16. package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +3 -3
  17. package/docs/classes/Decorators.html +31 -28
  18. package/docs/classes/Dream.html +123 -123
  19. package/docs/classes/DreamApplication.html +4 -4
  20. package/docs/classes/DreamBin.html +2 -2
  21. package/docs/classes/DreamCLI.html +3 -3
  22. package/docs/classes/DreamImporter.html +2 -2
  23. package/docs/classes/DreamMigrationHelpers.html +7 -7
  24. package/docs/classes/DreamSerializer.html +2 -2
  25. package/docs/classes/DreamTransaction.html +2 -2
  26. package/docs/classes/Encrypt.html +2 -2
  27. package/docs/classes/Env.html +2 -2
  28. package/docs/classes/GlobalNameNotSet.html +3 -3
  29. package/docs/classes/NonLoadedAssociation.html +3 -3
  30. package/docs/classes/Query.html +50 -50
  31. package/docs/classes/Range.html +2 -2
  32. package/docs/classes/RecordNotFound.html +3 -3
  33. package/docs/classes/ValidationError.html +3 -3
  34. package/docs/functions/Attribute.html +1 -1
  35. package/docs/functions/RendersMany.html +1 -1
  36. package/docs/functions/RendersOne.html +1 -1
  37. package/docs/functions/ReplicaSafe.html +1 -1
  38. package/docs/functions/STI.html +1 -1
  39. package/docs/functions/Scope.html +1 -1
  40. package/docs/functions/SoftDelete.html +1 -1
  41. package/docs/functions/Validate.html +1 -1
  42. package/docs/functions/Validates.html +1 -1
  43. package/docs/functions/Virtual.html +1 -1
  44. package/docs/functions/camelize.html +1 -1
  45. package/docs/functions/capitalize.html +1 -1
  46. package/docs/functions/closeAllDbConnections.html +1 -1
  47. package/docs/functions/compact.html +1 -1
  48. package/docs/functions/db.html +1 -1
  49. package/docs/functions/debug.html +1 -1
  50. package/docs/functions/dreamDbConnections.html +1 -1
  51. package/docs/functions/dreamPath.html +1 -1
  52. package/docs/functions/generateDream.html +1 -1
  53. package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
  54. package/docs/functions/hyphenize.html +1 -1
  55. package/docs/functions/inferSerializerFromDreamClassOrViewModelClass.html +1 -1
  56. package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
  57. package/docs/functions/isEmpty.html +1 -1
  58. package/docs/functions/loadRepl.html +1 -1
  59. package/docs/functions/lookupClassByGlobalName.html +1 -1
  60. package/docs/functions/pascalize.html +1 -1
  61. package/docs/functions/pgErrorType.html +1 -1
  62. package/docs/functions/range-1.html +1 -1
  63. package/docs/functions/relativeDreamPath.html +1 -1
  64. package/docs/functions/round.html +1 -1
  65. package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
  66. package/docs/functions/sharedPathPrefix.html +1 -1
  67. package/docs/functions/snakeify.html +1 -1
  68. package/docs/functions/sortBy.html +1 -1
  69. package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
  70. package/docs/functions/uncapitalize.html +1 -1
  71. package/docs/functions/uniq.html +1 -1
  72. package/docs/functions/validateColumn.html +1 -1
  73. package/docs/functions/validateTable.html +1 -1
  74. package/docs/interfaces/AttributeStatement.html +2 -2
  75. package/docs/interfaces/DecoratorContext.html +2 -2
  76. package/docs/interfaces/DreamApplicationInitOptions.html +2 -2
  77. package/docs/interfaces/DreamApplicationOpts.html +2 -2
  78. package/docs/interfaces/DreamSerializerAssociationStatement.html +2 -2
  79. package/docs/interfaces/EncryptOptions.html +2 -2
  80. package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
  81. package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
  82. package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
  83. package/docs/modules.html +1 -14
  84. package/docs/types/Camelized.html +1 -1
  85. package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
  86. package/docs/types/DreamAssociationMetadata.html +1 -1
  87. package/docs/types/DreamAttributes.html +1 -1
  88. package/docs/types/DreamClassColumn.html +1 -1
  89. package/docs/types/DreamColumn.html +1 -1
  90. package/docs/types/DreamColumnNames.html +1 -1
  91. package/docs/types/DreamLogLevel.html +1 -1
  92. package/docs/types/DreamLogger.html +1 -1
  93. package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
  94. package/docs/types/DreamParamSafeAttributes.html +1 -1
  95. package/docs/types/DreamParamSafeColumnNames.html +1 -1
  96. package/docs/types/DreamSerializerKey.html +1 -1
  97. package/docs/types/DreamSerializers.html +1 -1
  98. package/docs/types/DreamTableSchema.html +1 -1
  99. package/docs/types/DreamVirtualColumns.html +1 -1
  100. package/docs/types/EncryptAlgorithm.html +1 -1
  101. package/docs/types/Hyphenized.html +1 -1
  102. package/docs/types/IdType.html +1 -1
  103. package/docs/types/OpenapiAllTypes.html +1 -1
  104. package/docs/types/OpenapiFormats.html +1 -1
  105. package/docs/types/OpenapiNumberFormats.html +1 -1
  106. package/docs/types/OpenapiPrimitiveTypes.html +1 -1
  107. package/docs/types/OpenapiSchemaArray.html +1 -1
  108. package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
  109. package/docs/types/OpenapiSchemaBase.html +1 -1
  110. package/docs/types/OpenapiSchemaBody.html +1 -1
  111. package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
  112. package/docs/types/OpenapiSchemaCommonFields.html +1 -1
  113. package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
  114. package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
  115. package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
  116. package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
  117. package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
  118. package/docs/types/OpenapiSchemaInteger.html +1 -1
  119. package/docs/types/OpenapiSchemaNull.html +1 -1
  120. package/docs/types/OpenapiSchemaNumber.html +1 -1
  121. package/docs/types/OpenapiSchemaObject.html +1 -1
  122. package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
  123. package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
  124. package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
  125. package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
  126. package/docs/types/OpenapiSchemaObjectBase.html +1 -1
  127. package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
  128. package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
  129. package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
  130. package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
  131. package/docs/types/OpenapiSchemaPartialSegment.html +1 -1
  132. package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
  133. package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
  134. package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
  135. package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
  136. package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
  137. package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
  138. package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
  139. package/docs/types/OpenapiSchemaString.html +1 -1
  140. package/docs/types/OpenapiShorthandAllTypes.html +1 -1
  141. package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
  142. package/docs/types/OpenapiTypeField.html +1 -1
  143. package/docs/types/Pascalized.html +1 -1
  144. package/docs/types/PrimaryKeyType.html +1 -1
  145. package/docs/types/RoundingPrecision.html +1 -1
  146. package/docs/types/SerializableClassOrSerializerCallback.html +1 -1
  147. package/docs/types/SerializableDreamClassOrViewModelClass.html +1 -1
  148. package/docs/types/SerializableDreamOrViewModel.html +1 -1
  149. package/docs/types/SerializableTypes.html +1 -1
  150. package/docs/types/Snakeified.html +1 -1
  151. package/docs/types/Timestamp.html +1 -1
  152. package/docs/types/UpdateableAssociationProperties.html +1 -1
  153. package/docs/types/UpdateableProperties.html +1 -1
  154. package/docs/types/ValidationType.html +1 -1
  155. package/docs/types/ViewModelSerializerKey.html +1 -1
  156. package/docs/types/WhereStatementForDream.html +1 -1
  157. package/docs/types/WhereStatementForDreamClass.html +1 -1
  158. package/docs/variables/DreamConst.html +1 -1
  159. package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
  160. package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
  161. package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
  162. package/docs/variables/ops.html +1 -1
  163. package/docs/variables/primaryKeyTypes.html +1 -1
  164. package/package.json +1 -1
  165. package/dist/cjs/src/errors/sortable/CannotCallSortableOnSTIChild.js +0 -18
  166. package/dist/esm/src/errors/sortable/CannotCallSortableOnSTIChild.js +0 -15
  167. package/dist/types/src/errors/sortable/CannotCallSortableOnSTIChild.d.ts +0 -6
  168. package/docs/functions/AfterCreate.html +0 -1
  169. package/docs/functions/AfterCreateCommit.html +0 -13
  170. package/docs/functions/AfterDestroy.html +0 -1
  171. package/docs/functions/AfterDestroyCommit.html +0 -13
  172. package/docs/functions/AfterSave.html +0 -1
  173. package/docs/functions/AfterSaveCommit.html +0 -13
  174. package/docs/functions/AfterUpdate.html +0 -1
  175. package/docs/functions/AfterUpdateCommit.html +0 -13
  176. package/docs/functions/BeforeCreate.html +0 -1
  177. package/docs/functions/BeforeDestroy.html +0 -1
  178. package/docs/functions/BeforeSave.html +0 -1
  179. package/docs/functions/BeforeUpdate.html +0 -1
  180. package/docs/functions/Sortable.html +0 -1
@@ -1075,7 +1075,7 @@ class Dream {
1075
1075
  *
1076
1076
  * ```ts
1077
1077
  * class Post extends ApplicationModel {
1078
- * @Sortable({ scope: ['user']})
1078
+ * @Deco.Sortable({ scope: ['user']})
1079
1079
  * public position: DreamColumn<User, 'position'>
1080
1080
  * }
1081
1081
  *
@@ -99,8 +99,16 @@ class Decorators {
99
99
  // end: HasOne
100
100
  //////////////
101
101
  /**
102
- * Shortcut to the Sortable decorator, which also provides extra type protection which cannot be provided
103
- * with the Sortable decorator.
102
+ * Sortable decorator.
103
+ *
104
+ * NOTE: the Sortable decorator may not be used in STI child models (it may be used in the STI base class)
105
+ *
106
+ * ```ts
107
+ * class Balloon {
108
+ * @Deco.Sortable()
109
+ * public position: DreamColumn<Balloon, 'position'>
110
+ * }
111
+ * ```
104
112
  *
105
113
  * @param scope - The column, association, or combination there-of which you would like to restrict the incrementing logic to
106
114
  * @returns A Sortable decorator
@@ -109,11 +117,11 @@ class Decorators {
109
117
  return (0, Sortable_js_1.default)(opts);
110
118
  }
111
119
  /**
112
- * Shortcut to the BeforeCreate decorator
120
+ * BeforeCreate decorator
113
121
  *
114
122
  * ```ts
115
123
  * class User {
116
- * User.BeforeCreate()
124
+ * @Deco.BeforeCreate()
117
125
  * public doSomething() {
118
126
  * console.log('hi!')
119
127
  * }
@@ -127,11 +135,11 @@ class Decorators {
127
135
  return (0, BeforeCreate_js_1.default)(opts);
128
136
  }
129
137
  /**
130
- * Shortcut to the BeforeSave decorator
138
+ * BeforeSave decorator
131
139
  *
132
140
  * ```ts
133
141
  * class User {
134
- * User.BeforeSave()
142
+ * @Deco.BeforeSave()
135
143
  * public doSomething() {
136
144
  * console.log('hi!')
137
145
  * }
@@ -145,11 +153,11 @@ class Decorators {
145
153
  return (0, BeforeSave_js_1.default)(opts);
146
154
  }
147
155
  /**
148
- * Shortcut to the BeforeUpdate decorator
156
+ * BeforeUpdate decorator
149
157
  *
150
158
  * ```ts
151
159
  * class User {
152
- * User.BeforeUpdate()
160
+ * @Deco.BeforeUpdate()
153
161
  * public doSomething() {
154
162
  * console.log('hi!')
155
163
  * }
@@ -163,11 +171,11 @@ class Decorators {
163
171
  return (0, BeforeUpdate_js_1.default)(opts);
164
172
  }
165
173
  /**
166
- * Shortcut to the BeforeDestroy decorator
174
+ * BeforeDestroy decorator
167
175
  *
168
176
  * ```ts
169
177
  * class User {
170
- * User.BeforeDestroy()
178
+ * @Deco.BeforeDestroy()
171
179
  * public doSomething() {
172
180
  * console.log('hi!')
173
181
  * }
@@ -180,11 +188,11 @@ class Decorators {
180
188
  return (0, BeforeDestroy_js_1.default)();
181
189
  }
182
190
  /**
183
- * Shortcut to the AfterCreate decorator
191
+ * AfterCreate decorator
184
192
  *
185
193
  * ```ts
186
194
  * class User {
187
- * User.AfterCreate()
195
+ * @Deco.AfterCreate()
188
196
  * public doSomething() {
189
197
  * console.log('hi!')
190
198
  * }
@@ -198,11 +206,11 @@ class Decorators {
198
206
  return (0, AfterCreate_js_1.default)(opts);
199
207
  }
200
208
  /**
201
- * Shortcut to the AfterCreateCommit decorator
209
+ * AfterCreateCommit decorator
202
210
  *
203
211
  * ```ts
204
212
  * class User {
205
- * User.AfterCreateCommit()
213
+ * @Deco.AfterCreateCommit()
206
214
  * public doSomething() {
207
215
  * console.log('hi!')
208
216
  * }
@@ -215,11 +223,11 @@ class Decorators {
215
223
  return (0, AfterCreateCommit_js_1.default)(opts);
216
224
  }
217
225
  /**
218
- * Shortcut to the AfterSave decorator
226
+ * AfterSave decorator
219
227
  *
220
228
  * ```ts
221
229
  * class User {
222
- * User.AfterSave()
230
+ * @Deco.AfterSave()
223
231
  * public doSomething() {
224
232
  * console.log('hi!')
225
233
  * }
@@ -233,11 +241,11 @@ class Decorators {
233
241
  return (0, AfterSave_js_1.default)(opts);
234
242
  }
235
243
  /**
236
- * Shortcut to the AfterSaveCommit decorator
244
+ * AfterSaveCommit decorator
237
245
  *
238
246
  * ```ts
239
247
  * class User {
240
- * User.AfterSaveCommit()
248
+ * @Deco.AfterSaveCommit()
241
249
  * public doSomething() {
242
250
  * console.log('hi!')
243
251
  * }
@@ -251,11 +259,11 @@ class Decorators {
251
259
  return (0, AfterSaveCommit_js_1.default)(opts);
252
260
  }
253
261
  /**
254
- * Shortcut to the AfterUpdate decorator
262
+ * AfterUpdate decorator
255
263
  *
256
264
  * ```ts
257
265
  * class User {
258
- * User.AfterUpdate()
266
+ * @Deco.AfterUpdate()
259
267
  * public doSomething() {
260
268
  * console.log('hi!')
261
269
  * }
@@ -269,11 +277,11 @@ class Decorators {
269
277
  return (0, AfterUpdate_js_1.default)(opts);
270
278
  }
271
279
  /**
272
- * Shortcut to the AfterUpdateCommit decorator
280
+ * AfterUpdateCommit decorator
273
281
  *
274
282
  * ```ts
275
283
  * class User {
276
- * User.AfterUpdateCommit()
284
+ * @Deco.AfterUpdateCommit()
277
285
  * public doSomething() {
278
286
  * console.log('hi!')
279
287
  * }
@@ -287,11 +295,11 @@ class Decorators {
287
295
  return (0, AfterUpdateCommit_js_1.default)(opts);
288
296
  }
289
297
  /**
290
- * Shortcut to the AfterDestroy decorator
298
+ * AfterDestroy decorator
291
299
  *
292
300
  * ```ts
293
301
  * class User {
294
- * User.AfterDestroy()
302
+ * @Deco.AfterDestroy()
295
303
  * public doSomething() {
296
304
  * console.log('hi!')
297
305
  * }
@@ -305,11 +313,11 @@ class Decorators {
305
313
  return (0, AfterDestroy_js_1.default)();
306
314
  }
307
315
  /**
308
- * Shortcut to the AfterDestroyCommit decorator
316
+ * AfterDestroyCommit decorator
309
317
  *
310
318
  * ```ts
311
319
  * class User {
312
- * User.AfterDestroyCommit()
320
+ * @Deco.AfterDestroyCommit()
313
321
  * public doSomething() {
314
322
  * console.log('hi!')
315
323
  * }
@@ -9,6 +9,7 @@ const AfterDestroyCommit_js_1 = require("../hooks/AfterDestroyCommit.js");
9
9
  const AfterUpdate_js_1 = require("../hooks/AfterUpdate.js");
10
10
  const AfterUpdateCommit_js_1 = require("../hooks/AfterUpdateCommit.js");
11
11
  const BeforeSave_js_1 = require("../hooks/BeforeSave.js");
12
+ const STI_js_1 = require("../STI.js");
12
13
  const scopeArray_js_1 = require("./helpers/scopeArray.js");
13
14
  const afterSortableCreate_js_1 = require("./hooks/afterSortableCreate.js");
14
15
  const afterSortableDestroy_js_1 = require("./hooks/afterSortableDestroy.js");
@@ -22,18 +23,6 @@ function Sortable(opts = {}) {
22
23
  const dreamClass = dream.constructor;
23
24
  if (!dreamClass['globallyInitializingDecorators'])
24
25
  return;
25
- if (dreamClass['sti']['active']) {
26
- if (!(dreamClass instanceof dreamClass['stiBaseClassOrOwnClass'])) {
27
- // what we should really be doing is throwing CannotCallSortableOnSTIChild,
28
- // but we cannot, since there is no way to know during this initializer if
29
- // the Sortable decorator was applied to the STI child, or the STI parent.
30
- //
31
- // because of this bizarre issue, we are forced to early return when
32
- // we are processing Sortable on an STI child.
33
- // throw new CannotCallSortableOnSTIChild(dreamClass)
34
- return;
35
- }
36
- }
37
26
  if (!Object.getOwnPropertyDescriptor(dreamClass, 'sortableFields')) {
38
27
  // This pattern allows `sortableFields` on a base STI class and on
39
28
  // child STI classes. The new `sortableFields` property will be created
@@ -58,7 +47,7 @@ function Sortable(opts = {}) {
58
47
  // before saving, we remember the new value for position, but clear it from our
59
48
  // supervised attributes to prevent position from saving
60
49
  dreamPrototype[beforeSaveMethodName] = async function (txn) {
61
- let query = dreamClass.query();
50
+ let query = dreamClass.query().removeDefaultScope(STI_js_1.STI_SCOPE_NAME);
62
51
  if (txn)
63
52
  query = query.txn(txn);
64
53
  await (0, beforeSortableSave_js_1.default)({
@@ -73,7 +62,7 @@ function Sortable(opts = {}) {
73
62
  // if no transaction is provided, leverage update commit hook instead
74
63
  if (!txn)
75
64
  return;
76
- const query = dreamClass.query().txn(txn);
65
+ const query = dreamClass.query().removeDefaultScope(STI_js_1.STI_SCOPE_NAME).txn(txn);
77
66
  await (0, afterSortableUpdate_js_1.default)({
78
67
  dream: this,
79
68
  positionField,
@@ -86,7 +75,7 @@ function Sortable(opts = {}) {
86
75
  // if transaction is provided, leverage update hook instead
87
76
  if (txn)
88
77
  return;
89
- const query = dreamClass.query();
78
+ const query = dreamClass.query().removeDefaultScope(STI_js_1.STI_SCOPE_NAME);
90
79
  await (0, afterSortableUpdate_js_1.default)({
91
80
  dream: this,
92
81
  positionField,
@@ -101,7 +90,7 @@ function Sortable(opts = {}) {
101
90
  // if no transaction is provided, leverage create commit hook instead
102
91
  if (!txn)
103
92
  return;
104
- const query = dreamClass.query().txn(txn);
93
+ const query = dreamClass.query().removeDefaultScope(STI_js_1.STI_SCOPE_NAME).txn(txn);
105
94
  await (0, afterSortableCreate_js_1.default)({
106
95
  dream: this,
107
96
  positionField,
@@ -114,7 +103,7 @@ function Sortable(opts = {}) {
114
103
  // if transaction is provided, leverage create hook instead
115
104
  if (txn)
116
105
  return;
117
- const query = dreamClass.query();
106
+ const query = dreamClass.query().removeDefaultScope(STI_js_1.STI_SCOPE_NAME);
118
107
  await (0, afterSortableCreate_js_1.default)({
119
108
  dream: this,
120
109
  positionField,
@@ -128,7 +117,7 @@ function Sortable(opts = {}) {
128
117
  // if no transaction is provided, leverage destroy commit hook instead
129
118
  if (!txn)
130
119
  return;
131
- const query = dreamClass.query().txn(txn);
120
+ const query = dreamClass.query().removeDefaultScope(STI_js_1.STI_SCOPE_NAME).txn(txn);
132
121
  await (0, afterSortableDestroy_js_1.default)({
133
122
  dream: this,
134
123
  positionField,
@@ -140,7 +129,7 @@ function Sortable(opts = {}) {
140
129
  // if transaction is provided, leverage destroy hook instead
141
130
  if (txn)
142
131
  return;
143
- const query = dreamClass.query();
132
+ const query = dreamClass.query().removeDefaultScope(STI_js_1.STI_SCOPE_NAME);
144
133
  await (0, afterSortableDestroy_js_1.default)({
145
134
  dream: this,
146
135
  positionField,
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.debug = exports.compact = exports.generateDream = exports.capitalize = exports.camelize = exports.CalendarDate = exports.Benchmark = exports.ValidationError = exports.RecordNotFound = exports.GlobalNameNotSet = exports.CreateOrFindByFailedToCreateAndFind = exports.NonLoadedAssociation = exports.Encrypt = exports.DreamConst = exports.Query = exports.DreamTransaction = exports.Dream = exports.DreamApplication = exports.lookupClassByGlobalName = exports.DreamImporter = exports.Virtual = exports.Validates = exports.Validate = exports.STI = exports.Sortable = exports.SoftDelete = exports.Scope = exports.ReplicaSafe = exports.BeforeUpdate = exports.BeforeSave = exports.BeforeDestroy = exports.BeforeCreate = exports.AfterUpdateCommit = exports.AfterUpdate = exports.AfterSaveCommit = exports.AfterSave = exports.AfterDestroyCommit = exports.AfterDestroy = exports.AfterCreateCommit = exports.AfterCreate = exports.Decorators = exports.validateTable = exports.validateColumn = exports.DreamMigrationHelpers = exports.db = exports.pgErrorType = exports.dreamDbConnections = exports.closeAllDbConnections = exports.DreamCLI = exports.DreamBin = void 0;
4
- exports.DreamSerializer = exports.Attribute = exports.RendersOne = exports.RendersMany = exports.ops = exports.openapiShorthandPrimitiveTypes = exports.openapiPrimitiveTypes = exports.uniq = exports.uncapitalize = exports.standardizeFullyQualifiedModelName = exports.sortBy = exports.snakeify = exports.serializerNameFromFullyQualifiedModelName = exports.round = exports.range = exports.Range = exports.sharedPathPrefix = exports.relativeDreamPath = exports.dreamPath = exports.pascalize = exports.loadRepl = exports.isEmpty = exports.inferSerializerFromDreamOrViewModel = exports.inferSerializerFromDreamClassOrViewModelClass = exports.hyphenize = exports.globalClassNameFromFullyQualifiedModelName = exports.Env = void 0;
3
+ exports.range = exports.Range = exports.sharedPathPrefix = exports.relativeDreamPath = exports.dreamPath = exports.pascalize = exports.loadRepl = exports.isEmpty = exports.inferSerializerFromDreamOrViewModel = exports.inferSerializerFromDreamClassOrViewModelClass = exports.hyphenize = exports.globalClassNameFromFullyQualifiedModelName = exports.Env = exports.debug = exports.compact = exports.generateDream = exports.capitalize = exports.camelize = exports.CalendarDate = exports.Benchmark = exports.ValidationError = exports.RecordNotFound = exports.GlobalNameNotSet = exports.CreateOrFindByFailedToCreateAndFind = exports.NonLoadedAssociation = exports.Encrypt = exports.DreamConst = exports.Query = exports.DreamTransaction = exports.Dream = exports.DreamApplication = exports.lookupClassByGlobalName = exports.DreamImporter = exports.Virtual = exports.Validates = exports.Validate = exports.STI = exports.SoftDelete = exports.Scope = exports.ReplicaSafe = exports.Decorators = exports.validateTable = exports.validateColumn = exports.DreamMigrationHelpers = exports.db = exports.pgErrorType = exports.dreamDbConnections = exports.closeAllDbConnections = exports.DreamCLI = exports.DreamBin = void 0;
4
+ exports.DreamSerializer = exports.Attribute = exports.RendersOne = exports.RendersMany = exports.ops = exports.openapiShorthandPrimitiveTypes = exports.openapiPrimitiveTypes = exports.uniq = exports.uncapitalize = exports.standardizeFullyQualifiedModelName = exports.sortBy = exports.snakeify = exports.serializerNameFromFullyQualifiedModelName = exports.round = void 0;
5
5
  var index_js_1 = require("./bin/index.js");
6
6
  Object.defineProperty(exports, "DreamBin", { enumerable: true, get: function () { return index_js_1.default; } });
7
7
  var index_js_2 = require("./cli/index.js");
@@ -21,38 +21,12 @@ var validateTable_js_1 = require("./db/validators/validateTable.js");
21
21
  Object.defineProperty(exports, "validateTable", { enumerable: true, get: function () { return validateTable_js_1.default; } });
22
22
  var Decorators_js_1 = require("./decorators/Decorators.js");
23
23
  Object.defineProperty(exports, "Decorators", { enumerable: true, get: function () { return Decorators_js_1.default; } });
24
- var AfterCreate_js_1 = require("./decorators/hooks/AfterCreate.js");
25
- Object.defineProperty(exports, "AfterCreate", { enumerable: true, get: function () { return AfterCreate_js_1.default; } });
26
- var AfterCreateCommit_js_1 = require("./decorators/hooks/AfterCreateCommit.js");
27
- Object.defineProperty(exports, "AfterCreateCommit", { enumerable: true, get: function () { return AfterCreateCommit_js_1.default; } });
28
- var AfterDestroy_js_1 = require("./decorators/hooks/AfterDestroy.js");
29
- Object.defineProperty(exports, "AfterDestroy", { enumerable: true, get: function () { return AfterDestroy_js_1.default; } });
30
- var AfterDestroyCommit_js_1 = require("./decorators/hooks/AfterDestroyCommit.js");
31
- Object.defineProperty(exports, "AfterDestroyCommit", { enumerable: true, get: function () { return AfterDestroyCommit_js_1.default; } });
32
- var AfterSave_js_1 = require("./decorators/hooks/AfterSave.js");
33
- Object.defineProperty(exports, "AfterSave", { enumerable: true, get: function () { return AfterSave_js_1.default; } });
34
- var AfterSaveCommit_js_1 = require("./decorators/hooks/AfterSaveCommit.js");
35
- Object.defineProperty(exports, "AfterSaveCommit", { enumerable: true, get: function () { return AfterSaveCommit_js_1.default; } });
36
- var AfterUpdate_js_1 = require("./decorators/hooks/AfterUpdate.js");
37
- Object.defineProperty(exports, "AfterUpdate", { enumerable: true, get: function () { return AfterUpdate_js_1.default; } });
38
- var AfterUpdateCommit_js_1 = require("./decorators/hooks/AfterUpdateCommit.js");
39
- Object.defineProperty(exports, "AfterUpdateCommit", { enumerable: true, get: function () { return AfterUpdateCommit_js_1.default; } });
40
- var BeforeCreate_js_1 = require("./decorators/hooks/BeforeCreate.js");
41
- Object.defineProperty(exports, "BeforeCreate", { enumerable: true, get: function () { return BeforeCreate_js_1.default; } });
42
- var BeforeDestroy_js_1 = require("./decorators/hooks/BeforeDestroy.js");
43
- Object.defineProperty(exports, "BeforeDestroy", { enumerable: true, get: function () { return BeforeDestroy_js_1.default; } });
44
- var BeforeSave_js_1 = require("./decorators/hooks/BeforeSave.js");
45
- Object.defineProperty(exports, "BeforeSave", { enumerable: true, get: function () { return BeforeSave_js_1.default; } });
46
- var BeforeUpdate_js_1 = require("./decorators/hooks/BeforeUpdate.js");
47
- Object.defineProperty(exports, "BeforeUpdate", { enumerable: true, get: function () { return BeforeUpdate_js_1.default; } });
48
24
  var ReplicaSafe_js_1 = require("./decorators/ReplicaSafe.js");
49
25
  Object.defineProperty(exports, "ReplicaSafe", { enumerable: true, get: function () { return ReplicaSafe_js_1.default; } });
50
26
  var Scope_js_1 = require("./decorators/Scope.js");
51
27
  Object.defineProperty(exports, "Scope", { enumerable: true, get: function () { return Scope_js_1.default; } });
52
28
  var SoftDelete_js_1 = require("./decorators/SoftDelete.js");
53
29
  Object.defineProperty(exports, "SoftDelete", { enumerable: true, get: function () { return SoftDelete_js_1.default; } });
54
- var Sortable_js_1 = require("./decorators/sortable/Sortable.js");
55
- Object.defineProperty(exports, "Sortable", { enumerable: true, get: function () { return Sortable_js_1.default; } });
56
30
  var STI_js_1 = require("./decorators/STI.js");
57
31
  Object.defineProperty(exports, "STI", { enumerable: true, get: function () { return STI_js_1.default; } });
58
32
  var Validate_js_1 = require("./decorators/validations/Validate.js");
@@ -1073,7 +1073,7 @@ export default class Dream {
1073
1073
  *
1074
1074
  * ```ts
1075
1075
  * class Post extends ApplicationModel {
1076
- * @Sortable({ scope: ['user']})
1076
+ * @Deco.Sortable({ scope: ['user']})
1077
1077
  * public position: DreamColumn<User, 'position'>
1078
1078
  * }
1079
1079
  *
@@ -97,8 +97,16 @@ export default class Decorators {
97
97
  // end: HasOne
98
98
  //////////////
99
99
  /**
100
- * Shortcut to the Sortable decorator, which also provides extra type protection which cannot be provided
101
- * with the Sortable decorator.
100
+ * Sortable decorator.
101
+ *
102
+ * NOTE: the Sortable decorator may not be used in STI child models (it may be used in the STI base class)
103
+ *
104
+ * ```ts
105
+ * class Balloon {
106
+ * @Deco.Sortable()
107
+ * public position: DreamColumn<Balloon, 'position'>
108
+ * }
109
+ * ```
102
110
  *
103
111
  * @param scope - The column, association, or combination there-of which you would like to restrict the incrementing logic to
104
112
  * @returns A Sortable decorator
@@ -107,11 +115,11 @@ export default class Decorators {
107
115
  return Sortable(opts);
108
116
  }
109
117
  /**
110
- * Shortcut to the BeforeCreate decorator
118
+ * BeforeCreate decorator
111
119
  *
112
120
  * ```ts
113
121
  * class User {
114
- * User.BeforeCreate()
122
+ * @Deco.BeforeCreate()
115
123
  * public doSomething() {
116
124
  * console.log('hi!')
117
125
  * }
@@ -125,11 +133,11 @@ export default class Decorators {
125
133
  return BeforeCreate(opts);
126
134
  }
127
135
  /**
128
- * Shortcut to the BeforeSave decorator
136
+ * BeforeSave decorator
129
137
  *
130
138
  * ```ts
131
139
  * class User {
132
- * User.BeforeSave()
140
+ * @Deco.BeforeSave()
133
141
  * public doSomething() {
134
142
  * console.log('hi!')
135
143
  * }
@@ -143,11 +151,11 @@ export default class Decorators {
143
151
  return BeforeSave(opts);
144
152
  }
145
153
  /**
146
- * Shortcut to the BeforeUpdate decorator
154
+ * BeforeUpdate decorator
147
155
  *
148
156
  * ```ts
149
157
  * class User {
150
- * User.BeforeUpdate()
158
+ * @Deco.BeforeUpdate()
151
159
  * public doSomething() {
152
160
  * console.log('hi!')
153
161
  * }
@@ -161,11 +169,11 @@ export default class Decorators {
161
169
  return BeforeUpdate(opts);
162
170
  }
163
171
  /**
164
- * Shortcut to the BeforeDestroy decorator
172
+ * BeforeDestroy decorator
165
173
  *
166
174
  * ```ts
167
175
  * class User {
168
- * User.BeforeDestroy()
176
+ * @Deco.BeforeDestroy()
169
177
  * public doSomething() {
170
178
  * console.log('hi!')
171
179
  * }
@@ -178,11 +186,11 @@ export default class Decorators {
178
186
  return BeforeDestroy();
179
187
  }
180
188
  /**
181
- * Shortcut to the AfterCreate decorator
189
+ * AfterCreate decorator
182
190
  *
183
191
  * ```ts
184
192
  * class User {
185
- * User.AfterCreate()
193
+ * @Deco.AfterCreate()
186
194
  * public doSomething() {
187
195
  * console.log('hi!')
188
196
  * }
@@ -196,11 +204,11 @@ export default class Decorators {
196
204
  return AfterCreate(opts);
197
205
  }
198
206
  /**
199
- * Shortcut to the AfterCreateCommit decorator
207
+ * AfterCreateCommit decorator
200
208
  *
201
209
  * ```ts
202
210
  * class User {
203
- * User.AfterCreateCommit()
211
+ * @Deco.AfterCreateCommit()
204
212
  * public doSomething() {
205
213
  * console.log('hi!')
206
214
  * }
@@ -213,11 +221,11 @@ export default class Decorators {
213
221
  return AfterCreateCommit(opts);
214
222
  }
215
223
  /**
216
- * Shortcut to the AfterSave decorator
224
+ * AfterSave decorator
217
225
  *
218
226
  * ```ts
219
227
  * class User {
220
- * User.AfterSave()
228
+ * @Deco.AfterSave()
221
229
  * public doSomething() {
222
230
  * console.log('hi!')
223
231
  * }
@@ -231,11 +239,11 @@ export default class Decorators {
231
239
  return AfterSave(opts);
232
240
  }
233
241
  /**
234
- * Shortcut to the AfterSaveCommit decorator
242
+ * AfterSaveCommit decorator
235
243
  *
236
244
  * ```ts
237
245
  * class User {
238
- * User.AfterSaveCommit()
246
+ * @Deco.AfterSaveCommit()
239
247
  * public doSomething() {
240
248
  * console.log('hi!')
241
249
  * }
@@ -249,11 +257,11 @@ export default class Decorators {
249
257
  return AfterSaveCommit(opts);
250
258
  }
251
259
  /**
252
- * Shortcut to the AfterUpdate decorator
260
+ * AfterUpdate decorator
253
261
  *
254
262
  * ```ts
255
263
  * class User {
256
- * User.AfterUpdate()
264
+ * @Deco.AfterUpdate()
257
265
  * public doSomething() {
258
266
  * console.log('hi!')
259
267
  * }
@@ -267,11 +275,11 @@ export default class Decorators {
267
275
  return AfterUpdate(opts);
268
276
  }
269
277
  /**
270
- * Shortcut to the AfterUpdateCommit decorator
278
+ * AfterUpdateCommit decorator
271
279
  *
272
280
  * ```ts
273
281
  * class User {
274
- * User.AfterUpdateCommit()
282
+ * @Deco.AfterUpdateCommit()
275
283
  * public doSomething() {
276
284
  * console.log('hi!')
277
285
  * }
@@ -285,11 +293,11 @@ export default class Decorators {
285
293
  return AfterUpdateCommit(opts);
286
294
  }
287
295
  /**
288
- * Shortcut to the AfterDestroy decorator
296
+ * AfterDestroy decorator
289
297
  *
290
298
  * ```ts
291
299
  * class User {
292
- * User.AfterDestroy()
300
+ * @Deco.AfterDestroy()
293
301
  * public doSomething() {
294
302
  * console.log('hi!')
295
303
  * }
@@ -303,11 +311,11 @@ export default class Decorators {
303
311
  return AfterDestroy();
304
312
  }
305
313
  /**
306
- * Shortcut to the AfterDestroyCommit decorator
314
+ * AfterDestroyCommit decorator
307
315
  *
308
316
  * ```ts
309
317
  * class User {
310
- * User.AfterDestroyCommit()
318
+ * @Deco.AfterDestroyCommit()
311
319
  * public doSomething() {
312
320
  * console.log('hi!')
313
321
  * }
@@ -6,6 +6,7 @@ import { afterDestroyCommitImplementation } from '../hooks/AfterDestroyCommit.js
6
6
  import { afterUpdateImplementation } from '../hooks/AfterUpdate.js';
7
7
  import { afterUpdateCommitImplementation } from '../hooks/AfterUpdateCommit.js';
8
8
  import { beforeSaveImplementation } from '../hooks/BeforeSave.js';
9
+ import { STI_SCOPE_NAME } from '../STI.js';
9
10
  import scopeArray from './helpers/scopeArray.js';
10
11
  import afterSortableCreate from './hooks/afterSortableCreate.js';
11
12
  import afterSortableDestroy from './hooks/afterSortableDestroy.js';
@@ -19,18 +20,6 @@ export default function Sortable(opts = {}) {
19
20
  const dreamClass = dream.constructor;
20
21
  if (!dreamClass['globallyInitializingDecorators'])
21
22
  return;
22
- if (dreamClass['sti']['active']) {
23
- if (!(dreamClass instanceof dreamClass['stiBaseClassOrOwnClass'])) {
24
- // what we should really be doing is throwing CannotCallSortableOnSTIChild,
25
- // but we cannot, since there is no way to know during this initializer if
26
- // the Sortable decorator was applied to the STI child, or the STI parent.
27
- //
28
- // because of this bizarre issue, we are forced to early return when
29
- // we are processing Sortable on an STI child.
30
- // throw new CannotCallSortableOnSTIChild(dreamClass)
31
- return;
32
- }
33
- }
34
23
  if (!Object.getOwnPropertyDescriptor(dreamClass, 'sortableFields')) {
35
24
  // This pattern allows `sortableFields` on a base STI class and on
36
25
  // child STI classes. The new `sortableFields` property will be created
@@ -55,7 +44,7 @@ export default function Sortable(opts = {}) {
55
44
  // before saving, we remember the new value for position, but clear it from our
56
45
  // supervised attributes to prevent position from saving
57
46
  dreamPrototype[beforeSaveMethodName] = async function (txn) {
58
- let query = dreamClass.query();
47
+ let query = dreamClass.query().removeDefaultScope(STI_SCOPE_NAME);
59
48
  if (txn)
60
49
  query = query.txn(txn);
61
50
  await beforeSortableSave({
@@ -70,7 +59,7 @@ export default function Sortable(opts = {}) {
70
59
  // if no transaction is provided, leverage update commit hook instead
71
60
  if (!txn)
72
61
  return;
73
- const query = dreamClass.query().txn(txn);
62
+ const query = dreamClass.query().removeDefaultScope(STI_SCOPE_NAME).txn(txn);
74
63
  await afterUpdateSortable({
75
64
  dream: this,
76
65
  positionField,
@@ -83,7 +72,7 @@ export default function Sortable(opts = {}) {
83
72
  // if transaction is provided, leverage update hook instead
84
73
  if (txn)
85
74
  return;
86
- const query = dreamClass.query();
75
+ const query = dreamClass.query().removeDefaultScope(STI_SCOPE_NAME);
87
76
  await afterUpdateSortable({
88
77
  dream: this,
89
78
  positionField,
@@ -98,7 +87,7 @@ export default function Sortable(opts = {}) {
98
87
  // if no transaction is provided, leverage create commit hook instead
99
88
  if (!txn)
100
89
  return;
101
- const query = dreamClass.query().txn(txn);
90
+ const query = dreamClass.query().removeDefaultScope(STI_SCOPE_NAME).txn(txn);
102
91
  await afterSortableCreate({
103
92
  dream: this,
104
93
  positionField,
@@ -111,7 +100,7 @@ export default function Sortable(opts = {}) {
111
100
  // if transaction is provided, leverage create hook instead
112
101
  if (txn)
113
102
  return;
114
- const query = dreamClass.query();
103
+ const query = dreamClass.query().removeDefaultScope(STI_SCOPE_NAME);
115
104
  await afterSortableCreate({
116
105
  dream: this,
117
106
  positionField,
@@ -125,7 +114,7 @@ export default function Sortable(opts = {}) {
125
114
  // if no transaction is provided, leverage destroy commit hook instead
126
115
  if (!txn)
127
116
  return;
128
- const query = dreamClass.query().txn(txn);
117
+ const query = dreamClass.query().removeDefaultScope(STI_SCOPE_NAME).txn(txn);
129
118
  await afterSortableDestroy({
130
119
  dream: this,
131
120
  positionField,
@@ -137,7 +126,7 @@ export default function Sortable(opts = {}) {
137
126
  // if transaction is provided, leverage destroy hook instead
138
127
  if (txn)
139
128
  return;
140
- const query = dreamClass.query();
129
+ const query = dreamClass.query().removeDefaultScope(STI_SCOPE_NAME);
141
130
  await afterSortableDestroy({
142
131
  dream: this,
143
132
  positionField,
@@ -7,22 +7,9 @@ export { default as DreamMigrationHelpers } from './db/migration-helpers/DreamMi
7
7
  export { default as validateColumn } from './db/validators/validateColumn.js';
8
8
  export { default as validateTable } from './db/validators/validateTable.js';
9
9
  export { default as Decorators } from './decorators/Decorators.js';
10
- export { default as AfterCreate } from './decorators/hooks/AfterCreate.js';
11
- export { default as AfterCreateCommit } from './decorators/hooks/AfterCreateCommit.js';
12
- export { default as AfterDestroy } from './decorators/hooks/AfterDestroy.js';
13
- export { default as AfterDestroyCommit } from './decorators/hooks/AfterDestroyCommit.js';
14
- export { default as AfterSave } from './decorators/hooks/AfterSave.js';
15
- export { default as AfterSaveCommit } from './decorators/hooks/AfterSaveCommit.js';
16
- export { default as AfterUpdate } from './decorators/hooks/AfterUpdate.js';
17
- export { default as AfterUpdateCommit } from './decorators/hooks/AfterUpdateCommit.js';
18
- export { default as BeforeCreate } from './decorators/hooks/BeforeCreate.js';
19
- export { default as BeforeDestroy } from './decorators/hooks/BeforeDestroy.js';
20
- export { default as BeforeSave } from './decorators/hooks/BeforeSave.js';
21
- export { default as BeforeUpdate } from './decorators/hooks/BeforeUpdate.js';
22
10
  export { default as ReplicaSafe } from './decorators/ReplicaSafe.js';
23
11
  export { default as Scope } from './decorators/Scope.js';
24
12
  export { default as SoftDelete } from './decorators/SoftDelete.js';
25
- export { default as Sortable } from './decorators/sortable/Sortable.js';
26
13
  export { default as STI } from './decorators/STI.js';
27
14
  export { default as Validate } from './decorators/validations/Validate.js';
28
15
  export { default as Validates } from './decorators/validations/Validates.js';
@@ -880,7 +880,7 @@ export default class Dream {
880
880
  *
881
881
  * ```ts
882
882
  * class Post extends ApplicationModel {
883
- * @Sortable({ scope: ['user']})
883
+ * @Deco.Sortable({ scope: ['user']})
884
884
  * public position: DreamColumn<User, 'position'>
885
885
  * }
886
886
  *