@rvoh/dream 0.43.0 → 0.43.2

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 (189) hide show
  1. package/dist/cjs/src/dream/Query.js +6 -4
  2. package/dist/cjs/src/errors/serializers/MissingSerializersDefinitionForKey.js +3 -4
  3. package/dist/cjs/src/helpers/cli/generateDreamContent.js +7 -14
  4. package/dist/cjs/src/helpers/cli/generateSerializerContent.js +0 -1
  5. package/dist/cjs/src/serializer/SerializerRenderer.js +12 -8
  6. package/dist/esm/src/dream/Query.js +6 -4
  7. package/dist/esm/src/errors/serializers/MissingSerializersDefinitionForKey.js +3 -4
  8. package/dist/esm/src/helpers/cli/generateDreamContent.js +7 -14
  9. package/dist/esm/src/helpers/cli/generateSerializerContent.js +1 -1
  10. package/dist/esm/src/serializer/SerializerRenderer.js +12 -8
  11. package/dist/types/src/Dream.d.ts +16 -4
  12. package/dist/types/src/decorators/field/sortable/helpers/applySortableScopeToQuery.d.ts +3 -0
  13. package/dist/types/src/decorators/field/sortable/helpers/sortableQueryExcludingDream.d.ts +3 -0
  14. package/dist/types/src/dream/DreamClassTransactionBuilder.d.ts +6 -0
  15. package/dist/types/src/dream/Query.d.ts +19 -4
  16. package/dist/types/src/dream/internal/applyScopeBypassingSettingsToQuery.d.ts +3 -0
  17. package/dist/types/src/helpers/cli/generateSerializerContent.d.ts +0 -1
  18. package/dist/types/src/types/query.d.ts +6 -0
  19. package/dist/types/src/types/query.ts +6 -0
  20. package/dist/types/src/types/variadic.d.ts +3 -0
  21. package/dist/types/src/types/variadic.ts +3 -0
  22. package/docs/classes/Benchmark.html +2 -2
  23. package/docs/classes/CalendarDate.html +2 -2
  24. package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +3 -3
  25. package/docs/classes/Decorators.html +19 -19
  26. package/docs/classes/Dream.html +151 -151
  27. package/docs/classes/DreamApp.html +4 -4
  28. package/docs/classes/DreamBin.html +2 -2
  29. package/docs/classes/DreamCLI.html +4 -4
  30. package/docs/classes/DreamImporter.html +2 -2
  31. package/docs/classes/DreamLogos.html +2 -2
  32. package/docs/classes/DreamMigrationHelpers.html +7 -7
  33. package/docs/classes/DreamSerializerBuilder.html +2 -2
  34. package/docs/classes/DreamTransaction.html +2 -2
  35. package/docs/classes/Encrypt.html +2 -2
  36. package/docs/classes/Env.html +2 -2
  37. package/docs/classes/GlobalNameNotSet.html +3 -3
  38. package/docs/classes/NonLoadedAssociation.html +3 -3
  39. package/docs/classes/ObjectSerializerBuilder.html +2 -2
  40. package/docs/classes/Query.html +63 -63
  41. package/docs/classes/Range.html +2 -2
  42. package/docs/classes/RecordNotFound.html +3 -3
  43. package/docs/classes/ValidationError.html +3 -3
  44. package/docs/functions/DreamSerializer.html +1 -1
  45. package/docs/functions/ObjectSerializer.html +1 -1
  46. package/docs/functions/ReplicaSafe.html +1 -1
  47. package/docs/functions/STI.html +1 -1
  48. package/docs/functions/SoftDelete.html +1 -1
  49. package/docs/functions/camelize.html +1 -1
  50. package/docs/functions/capitalize.html +1 -1
  51. package/docs/functions/cloneDeepSafe.html +1 -1
  52. package/docs/functions/closeAllDbConnections.html +1 -1
  53. package/docs/functions/compact.html +1 -1
  54. package/docs/functions/dreamDbConnections.html +1 -1
  55. package/docs/functions/dreamPath.html +1 -1
  56. package/docs/functions/expandStiClasses.html +1 -1
  57. package/docs/functions/generateDream.html +1 -1
  58. package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
  59. package/docs/functions/groupBy.html +1 -1
  60. package/docs/functions/hyphenize.html +1 -1
  61. package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
  62. package/docs/functions/inferSerializersFromDreamClassOrViewModelClass.html +1 -1
  63. package/docs/functions/intersection.html +1 -1
  64. package/docs/functions/isDreamSerializer.html +1 -1
  65. package/docs/functions/isEmpty.html +1 -1
  66. package/docs/functions/loadRepl.html +1 -1
  67. package/docs/functions/lookupClassByGlobalName.html +1 -1
  68. package/docs/functions/normalizeUnicode.html +1 -1
  69. package/docs/functions/pascalize.html +1 -1
  70. package/docs/functions/pgErrorType.html +1 -1
  71. package/docs/functions/range-1.html +1 -1
  72. package/docs/functions/relativeDreamPath.html +1 -1
  73. package/docs/functions/round.html +1 -1
  74. package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
  75. package/docs/functions/sharedPathPrefix.html +1 -1
  76. package/docs/functions/snakeify.html +1 -1
  77. package/docs/functions/sort.html +1 -1
  78. package/docs/functions/sortBy.html +1 -1
  79. package/docs/functions/sortObjectByKey.html +1 -1
  80. package/docs/functions/sortObjectByValue.html +1 -1
  81. package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
  82. package/docs/functions/uncapitalize.html +1 -1
  83. package/docs/functions/uniq.html +1 -1
  84. package/docs/functions/untypedDb.html +1 -1
  85. package/docs/functions/validateColumn.html +1 -1
  86. package/docs/functions/validateTable.html +1 -1
  87. package/docs/interfaces/BelongsToStatement.html +2 -2
  88. package/docs/interfaces/DecoratorContext.html +2 -2
  89. package/docs/interfaces/DreamAppInitOptions.html +2 -2
  90. package/docs/interfaces/DreamAppOpts.html +2 -2
  91. package/docs/interfaces/EncryptOptions.html +2 -2
  92. package/docs/interfaces/InternalAnyTypedSerializerRendersMany.html +2 -2
  93. package/docs/interfaces/InternalAnyTypedSerializerRendersOne.html +2 -2
  94. package/docs/interfaces/OpenapiDescription.html +2 -2
  95. package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
  96. package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
  97. package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
  98. package/docs/interfaces/SerializerRendererOpts.html +2 -2
  99. package/docs/types/Camelized.html +1 -1
  100. package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
  101. package/docs/types/DateTime.html +1 -1
  102. package/docs/types/DbConnectionType.html +1 -1
  103. package/docs/types/DbTypes.html +1 -1
  104. package/docs/types/DreamAssociationMetadata.html +1 -1
  105. package/docs/types/DreamAttributes.html +1 -1
  106. package/docs/types/DreamClassColumn.html +1 -1
  107. package/docs/types/DreamColumn.html +1 -1
  108. package/docs/types/DreamColumnNames.html +1 -1
  109. package/docs/types/DreamLogLevel.html +1 -1
  110. package/docs/types/DreamLogger.html +1 -1
  111. package/docs/types/DreamModelSerializerType.html +1 -1
  112. package/docs/types/DreamOrViewModelClassSerializerKey.html +1 -1
  113. package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
  114. package/docs/types/DreamParamSafeAttributes.html +1 -1
  115. package/docs/types/DreamParamSafeColumnNames.html +1 -1
  116. package/docs/types/DreamSerializable.html +1 -1
  117. package/docs/types/DreamSerializableArray.html +1 -1
  118. package/docs/types/DreamSerializerKey.html +1 -1
  119. package/docs/types/DreamSerializers.html +1 -1
  120. package/docs/types/DreamTableSchema.html +1 -1
  121. package/docs/types/DreamVirtualColumns.html +1 -1
  122. package/docs/types/EncryptAlgorithm.html +1 -1
  123. package/docs/types/HasManyStatement.html +1 -1
  124. package/docs/types/HasOneStatement.html +1 -1
  125. package/docs/types/Hyphenized.html +1 -1
  126. package/docs/types/IdType.html +1 -1
  127. package/docs/types/OpenapiAllTypes.html +1 -1
  128. package/docs/types/OpenapiFormats.html +1 -1
  129. package/docs/types/OpenapiNumberFormats.html +1 -1
  130. package/docs/types/OpenapiPrimitiveBaseTypes.html +1 -1
  131. package/docs/types/OpenapiPrimitiveTypes.html +1 -1
  132. package/docs/types/OpenapiSchemaArray.html +1 -1
  133. package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
  134. package/docs/types/OpenapiSchemaBase.html +1 -1
  135. package/docs/types/OpenapiSchemaBody.html +1 -1
  136. package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
  137. package/docs/types/OpenapiSchemaCommonFields.html +1 -1
  138. package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
  139. package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
  140. package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
  141. package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
  142. package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
  143. package/docs/types/OpenapiSchemaInteger.html +1 -1
  144. package/docs/types/OpenapiSchemaNull.html +1 -1
  145. package/docs/types/OpenapiSchemaNumber.html +1 -1
  146. package/docs/types/OpenapiSchemaObject.html +1 -1
  147. package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
  148. package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
  149. package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
  150. package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
  151. package/docs/types/OpenapiSchemaObjectBase.html +1 -1
  152. package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
  153. package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
  154. package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
  155. package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
  156. package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
  157. package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
  158. package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
  159. package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
  160. package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
  161. package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
  162. package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
  163. package/docs/types/OpenapiSchemaString.html +1 -1
  164. package/docs/types/OpenapiShorthandAllTypes.html +1 -1
  165. package/docs/types/OpenapiShorthandPrimitiveBaseTypes.html +1 -1
  166. package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
  167. package/docs/types/OpenapiTypeField.html +1 -1
  168. package/docs/types/Pascalized.html +1 -1
  169. package/docs/types/PrimaryKeyType.html +1 -1
  170. package/docs/types/RoundingPrecision.html +1 -1
  171. package/docs/types/SerializerCasing.html +1 -1
  172. package/docs/types/SimpleObjectSerializerType.html +1 -1
  173. package/docs/types/Snakeified.html +1 -1
  174. package/docs/types/Timestamp.html +1 -1
  175. package/docs/types/UpdateableAssociationProperties.html +1 -1
  176. package/docs/types/UpdateableProperties.html +1 -1
  177. package/docs/types/ValidationType.html +1 -1
  178. package/docs/types/ViewModel.html +1 -1
  179. package/docs/types/ViewModelClass.html +1 -1
  180. package/docs/types/WhereStatementForDream.html +1 -1
  181. package/docs/types/WhereStatementForDreamClass.html +1 -1
  182. package/docs/variables/DateTime-1.html +1 -1
  183. package/docs/variables/DreamConst.html +1 -1
  184. package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
  185. package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
  186. package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
  187. package/docs/variables/ops.html +1 -1
  188. package/docs/variables/primaryKeyTypes.html +1 -1
  189. package/package.json +1 -1
@@ -931,7 +931,7 @@ class Query extends ConnectedToDB_js_1.default {
931
931
  * @returns A cloned Query with the limit clause applied
932
932
  */
933
933
  limit(limit) {
934
- return this.clone({ limit });
934
+ return this.clone({ limit: limit });
935
935
  }
936
936
  /**
937
937
  * Returns a new Query instance, specifying an offset
@@ -944,7 +944,7 @@ class Query extends ConnectedToDB_js_1.default {
944
944
  * @returns A cloned Query with the offset clause applied
945
945
  */
946
946
  offset(offset) {
947
- return this.clone({ offset });
947
+ return this.clone({ offset: offset });
948
948
  }
949
949
  /**
950
950
  * Returns the sql that would be executed by this Query
@@ -1457,7 +1457,8 @@ class Query extends ConnectedToDB_js_1.default {
1457
1457
  const recordCount = await this.count();
1458
1458
  const pageSize = opts.pageSize || index_js_1.default.getOrFail().paginationPageSize;
1459
1459
  const pageCount = Math.ceil(recordCount / pageSize);
1460
- const results = await this.limit(pageSize)
1460
+ const results = await this
1461
+ .limit(pageSize)
1461
1462
  .offset((page - 1) * pageSize)
1462
1463
  .all();
1463
1464
  return {
@@ -1876,7 +1877,8 @@ class Query extends ConnectedToDB_js_1.default {
1876
1877
  }
1877
1878
  async preloadPolymorphicAssociationModel(dreams, association, associatedDreamClass, associatedDreams) {
1878
1879
  const relevantAssociatedModels = dreams.filter((dream) => {
1879
- return dream[association.foreignKeyTypeField()] === associatedDreamClass['stiBaseClassOrOwnClassName'];
1880
+ const field = association.foreignKeyTypeField();
1881
+ return dream[field] === associatedDreamClass['stiBaseClassOrOwnClassName'] || dream[field] === null;
1880
1882
  });
1881
1883
  if (relevantAssociatedModels.length) {
1882
1884
  dreams.forEach((dream) => {
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const pascalize_js_1 = require("../../helpers/pascalize.js");
4
3
  class MissingSerializersDefinitionForKey extends Error {
5
4
  viewModel;
6
5
  serializerKey;
@@ -17,10 +16,10 @@ Missing serializers definition for \`${this.serializerKey}\` on class \`${classN
17
16
  Try something like this in your ${className}'s serializer getter:
18
17
 
19
18
  class ${className} {
20
- public get serializers() {
19
+ public get serializers(): DreamSerializers<${className}> {
21
20
  return {
22
- default: ${className}Serializer
23
- ${this.serializerKey}: ${className}${(0, pascalize_js_1.default)(this.serializerKey)}Serializer
21
+ default: '${className}Serializer'
22
+ ${this.serializerKey}: '<the_global_name_of_a_serializer>'
24
23
  }
25
24
  }
26
25
  ...
@@ -2,34 +2,30 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = generateDreamContent;
4
4
  const pluralize_esm_1 = require("pluralize-esm");
5
- const serializerNameFromFullyQualifiedModelName_js_1 = require("../../serializer/helpers/serializerNameFromFullyQualifiedModelName.js");
5
+ const serializerGlobalNameFromFullyQualifiedModelName_js_1 = require("../../serializer/helpers/serializerGlobalNameFromFullyQualifiedModelName.js");
6
6
  const camelize_js_1 = require("../camelize.js");
7
7
  const globalClassNameFromFullyQualifiedModelName_js_1 = require("../globalClassNameFromFullyQualifiedModelName.js");
8
8
  const relativeDreamPath_js_1 = require("../path/relativeDreamPath.js");
9
9
  const snakeify_js_1 = require("../snakeify.js");
10
10
  const standardizeFullyQualifiedModelName_js_1 = require("../standardizeFullyQualifiedModelName.js");
11
11
  const uniq_js_1 = require("../uniq.js");
12
- const generateSerializerContent_js_1 = require("./generateSerializerContent.js");
13
12
  function generateDreamContent({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, serializer, }) {
14
13
  fullyQualifiedModelName = (0, standardizeFullyQualifiedModelName_js_1.default)(fullyQualifiedModelName);
15
14
  const modelClassName = (0, globalClassNameFromFullyQualifiedModelName_js_1.default)(fullyQualifiedModelName);
16
15
  let parentModelClassName;
17
16
  const dreamImports = ['Decorators', 'DreamColumn'];
17
+ if (serializer)
18
+ dreamImports.push('DreamSerializers');
18
19
  const isSTI = !!fullyQualifiedParentName;
19
20
  if (isSTI) {
20
21
  fullyQualifiedParentName = (0, standardizeFullyQualifiedModelName_js_1.default)(fullyQualifiedParentName);
21
22
  parentModelClassName = (0, globalClassNameFromFullyQualifiedModelName_js_1.default)(fullyQualifiedParentName);
22
23
  dreamImports.push('STI');
23
24
  }
24
- const serialzerClassName = (0, serializerNameFromFullyQualifiedModelName_js_1.default)((0, generateSerializerContent_js_1.fullyQualifiedModelNameToSerializerBaseName)(fullyQualifiedModelName));
25
- const summarySerialzerClassName = (0, serializerNameFromFullyQualifiedModelName_js_1.default)((0, generateSerializerContent_js_1.fullyQualifiedModelNameToSerializerBaseName)(fullyQualifiedModelName), 'summary');
26
25
  const idTypescriptType = `DreamColumn<${modelClassName}, 'id'>`;
27
26
  const modelImportStatements = isSTI
28
27
  ? [importStatementForModel(fullyQualifiedModelName, fullyQualifiedParentName)]
29
28
  : [importStatementForModel(fullyQualifiedModelName, 'ApplicationModel')];
30
- const serializerImportStatement = serializer
31
- ? importStatementForSerializers(fullyQualifiedModelName, serialzerClassName, summarySerialzerClassName)
32
- : '';
33
29
  const attributeStatements = columnsWithTypes.map(attribute => {
34
30
  const [attributeName, attributeType, ...descriptors] = attribute.split(':');
35
31
  if (attributeName === undefined)
@@ -80,7 +76,7 @@ public ${(0, camelize_js_1.default)(attributeName)}: ${getAttributeType(attribut
80
76
  timestamps = timestamps.replace(/\n$/, '');
81
77
  const tableName = (0, snakeify_js_1.default)((0, pluralize_esm_1.default)(fullyQualifiedModelName.replace(/\//g, '_')));
82
78
  return `\
83
- import { ${(0, uniq_js_1.default)(dreamImports).join(', ')} } from '@rvoh/dream'${(0, uniq_js_1.default)(modelImportStatements).join('')}${serializerImportStatement}
79
+ import { ${(0, uniq_js_1.default)(dreamImports).join(', ')} } from '@rvoh/dream'${(0, uniq_js_1.default)(modelImportStatements).join('')}
84
80
 
85
81
  const deco = new Decorators<typeof ${modelClassName}>()
86
82
 
@@ -93,10 +89,10 @@ ${isSTI
93
89
  }
94
90
 
95
91
  `}${serializer
96
- ? ` public ${isSTI ? 'override ' : ''}get serializers() {
92
+ ? ` public ${isSTI ? 'override ' : ''}get serializers(): DreamSerializers<${modelClassName}> {
97
93
  return {
98
- default: ${serialzerClassName},
99
- summary: ${summarySerialzerClassName},
94
+ default: '${(0, serializerGlobalNameFromFullyQualifiedModelName_js_1.default)(fullyQualifiedModelName)}',
95
+ summary: '${(0, serializerGlobalNameFromFullyQualifiedModelName_js_1.default)(fullyQualifiedModelName, 'summary')}',
100
96
  }
101
97
  }
102
98
 
@@ -111,6 +107,3 @@ function getAttributeType(attribute, modelClassName) {
111
107
  function importStatementForModel(originModelName, destinationModelName = originModelName) {
112
108
  return `\nimport ${(0, globalClassNameFromFullyQualifiedModelName_js_1.default)(destinationModelName)} from '${(0, relativeDreamPath_js_1.default)('models', 'models', originModelName, destinationModelName)}'`;
113
109
  }
114
- function importStatementForSerializers(originModelName, serialzerClassName, summarySerialzerClassName) {
115
- return `\nimport { ${serialzerClassName}, ${summarySerialzerClassName} } from '${(0, relativeDreamPath_js_1.default)('models', 'serializers', originModelName)}'`;
116
- }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = generateSerializerContent;
4
- exports.fullyQualifiedModelNameToSerializerBaseName = fullyQualifiedModelNameToSerializerBaseName;
5
4
  const serializerNameFromFullyQualifiedModelName_js_1 = require("../../serializer/helpers/serializerNameFromFullyQualifiedModelName.js");
6
5
  const camelize_js_1 = require("../camelize.js");
7
6
  const globalClassNameFromFullyQualifiedModelName_js_1 = require("../globalClassNameFromFullyQualifiedModelName.js");
@@ -6,6 +6,8 @@ const compact_js_1 = require("../helpers/compact.js");
6
6
  const DateTime_js_1 = require("../helpers/DateTime.js");
7
7
  const round_js_1 = require("../helpers/round.js");
8
8
  const snakeify_js_1 = require("../helpers/snakeify.js");
9
+ const DreamSerializerBuilder_js_1 = require("./builders/DreamSerializerBuilder.js");
10
+ const ObjectSerializerBuilder_js_1 = require("./builders/ObjectSerializerBuilder.js");
9
11
  const inferSerializerFromDreamOrViewModel_js_1 = require("./helpers/inferSerializerFromDreamOrViewModel.js");
10
12
  class SerializerRenderer {
11
13
  serializerBuilder;
@@ -39,7 +41,7 @@ class SerializerRenderer {
39
41
  case 'attribute': {
40
42
  const outputAttributeName = this.setCase(attribute.options?.as ?? attribute.name);
41
43
  const value = data[attribute.name];
42
- accumulator[outputAttributeName] = applyRenderingOptionsToAttribute(value, attribute.options);
44
+ accumulator[outputAttributeName] = applyRenderingOptionsToAttribute(value, attribute.options, this.passthroughData, this.renderOpts);
43
45
  return accumulator;
44
46
  }
45
47
  /////////////////////
@@ -52,7 +54,7 @@ class SerializerRenderer {
52
54
  const outputAttributeName = this.setCase(attribute.options?.as ?? attribute.name);
53
55
  const target = data[attribute.targetName];
54
56
  const value = target[attribute.name];
55
- accumulator[outputAttributeName] = applyRenderingOptionsToAttribute(value, attribute.options);
57
+ accumulator[outputAttributeName] = applyRenderingOptionsToAttribute(value, attribute.options, this.passthroughData, this.renderOpts);
56
58
  return accumulator;
57
59
  }
58
60
  //////////////////////////////
@@ -69,11 +71,11 @@ class SerializerRenderer {
69
71
  if (attribute.options.flatten) {
70
72
  return {
71
73
  ...accumulator,
72
- ...applyRenderingOptionsToAttribute(attribute.fn(), {}),
74
+ ...applyRenderingOptionsToAttribute(attribute.fn(), {}, this.passthroughData, this.renderOpts),
73
75
  };
74
76
  }
75
77
  else {
76
- accumulator[outputAttributeName] = applyRenderingOptionsToAttribute(attribute.fn(), {});
78
+ accumulator[outputAttributeName] = applyRenderingOptionsToAttribute(attribute.fn(), {}, this.passthroughData, this.renderOpts);
77
79
  return accumulator;
78
80
  }
79
81
  }
@@ -180,12 +182,14 @@ class SerializerRenderer {
180
182
  }
181
183
  }
182
184
  exports.default = SerializerRenderer;
183
- function applyRenderingOptionsToAttribute(value, options) {
185
+ function applyRenderingOptionsToAttribute(value, options, passthroughData, renderOptions) {
184
186
  if (Array.isArray(value))
185
- return value.map(val => _applyRenderingOptionsToAttribute(val, options));
186
- return _applyRenderingOptionsToAttribute(value, options);
187
+ return value.map(val => _applyRenderingOptionsToAttribute(val, options, passthroughData, renderOptions));
188
+ return _applyRenderingOptionsToAttribute(value, options, passthroughData, renderOptions);
187
189
  }
188
- function _applyRenderingOptionsToAttribute(value, options) {
190
+ function _applyRenderingOptionsToAttribute(value, options, passthroughData, renderOptions) {
191
+ if (value instanceof DreamSerializerBuilder_js_1.default || value instanceof ObjectSerializerBuilder_js_1.default)
192
+ return value.render(passthroughData, renderOptions);
189
193
  if (value instanceof DateTime_js_1.DateTime)
190
194
  return value.toISO();
191
195
  if (value instanceof CalendarDate_js_1.default)
@@ -929,7 +929,7 @@ export default class Query extends ConnectedToDB {
929
929
  * @returns A cloned Query with the limit clause applied
930
930
  */
931
931
  limit(limit) {
932
- return this.clone({ limit });
932
+ return this.clone({ limit: limit });
933
933
  }
934
934
  /**
935
935
  * Returns a new Query instance, specifying an offset
@@ -942,7 +942,7 @@ export default class Query extends ConnectedToDB {
942
942
  * @returns A cloned Query with the offset clause applied
943
943
  */
944
944
  offset(offset) {
945
- return this.clone({ offset });
945
+ return this.clone({ offset: offset });
946
946
  }
947
947
  /**
948
948
  * Returns the sql that would be executed by this Query
@@ -1455,7 +1455,8 @@ export default class Query extends ConnectedToDB {
1455
1455
  const recordCount = await this.count();
1456
1456
  const pageSize = opts.pageSize || DreamApp.getOrFail().paginationPageSize;
1457
1457
  const pageCount = Math.ceil(recordCount / pageSize);
1458
- const results = await this.limit(pageSize)
1458
+ const results = await this
1459
+ .limit(pageSize)
1459
1460
  .offset((page - 1) * pageSize)
1460
1461
  .all();
1461
1462
  return {
@@ -1874,7 +1875,8 @@ export default class Query extends ConnectedToDB {
1874
1875
  }
1875
1876
  async preloadPolymorphicAssociationModel(dreams, association, associatedDreamClass, associatedDreams) {
1876
1877
  const relevantAssociatedModels = dreams.filter((dream) => {
1877
- return dream[association.foreignKeyTypeField()] === associatedDreamClass['stiBaseClassOrOwnClassName'];
1878
+ const field = association.foreignKeyTypeField();
1879
+ return dream[field] === associatedDreamClass['stiBaseClassOrOwnClassName'] || dream[field] === null;
1878
1880
  });
1879
1881
  if (relevantAssociatedModels.length) {
1880
1882
  dreams.forEach((dream) => {
@@ -1,4 +1,3 @@
1
- import pascalize from '../../helpers/pascalize.js';
2
1
  export default class MissingSerializersDefinitionForKey extends Error {
3
2
  viewModel;
4
3
  serializerKey;
@@ -15,10 +14,10 @@ Missing serializers definition for \`${this.serializerKey}\` on class \`${classN
15
14
  Try something like this in your ${className}'s serializer getter:
16
15
 
17
16
  class ${className} {
18
- public get serializers() {
17
+ public get serializers(): DreamSerializers<${className}> {
19
18
  return {
20
- default: ${className}Serializer
21
- ${this.serializerKey}: ${className}${pascalize(this.serializerKey)}Serializer
19
+ default: '${className}Serializer'
20
+ ${this.serializerKey}: '<the_global_name_of_a_serializer>'
22
21
  }
23
22
  }
24
23
  ...
@@ -1,32 +1,28 @@
1
1
  import pluralize from 'pluralize-esm';
2
- import serializerNameFromFullyQualifiedModelName from '../../serializer/helpers/serializerNameFromFullyQualifiedModelName.js';
2
+ import serializerGlobalNameFromFullyQualifiedModelName from '../../serializer/helpers/serializerGlobalNameFromFullyQualifiedModelName.js';
3
3
  import camelize from '../camelize.js';
4
4
  import globalClassNameFromFullyQualifiedModelName from '../globalClassNameFromFullyQualifiedModelName.js';
5
5
  import relativeDreamPath from '../path/relativeDreamPath.js';
6
6
  import snakeify from '../snakeify.js';
7
7
  import standardizeFullyQualifiedModelName from '../standardizeFullyQualifiedModelName.js';
8
8
  import uniq from '../uniq.js';
9
- import { fullyQualifiedModelNameToSerializerBaseName } from './generateSerializerContent.js';
10
9
  export default function generateDreamContent({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, serializer, }) {
11
10
  fullyQualifiedModelName = standardizeFullyQualifiedModelName(fullyQualifiedModelName);
12
11
  const modelClassName = globalClassNameFromFullyQualifiedModelName(fullyQualifiedModelName);
13
12
  let parentModelClassName;
14
13
  const dreamImports = ['Decorators', 'DreamColumn'];
14
+ if (serializer)
15
+ dreamImports.push('DreamSerializers');
15
16
  const isSTI = !!fullyQualifiedParentName;
16
17
  if (isSTI) {
17
18
  fullyQualifiedParentName = standardizeFullyQualifiedModelName(fullyQualifiedParentName);
18
19
  parentModelClassName = globalClassNameFromFullyQualifiedModelName(fullyQualifiedParentName);
19
20
  dreamImports.push('STI');
20
21
  }
21
- const serialzerClassName = serializerNameFromFullyQualifiedModelName(fullyQualifiedModelNameToSerializerBaseName(fullyQualifiedModelName));
22
- const summarySerialzerClassName = serializerNameFromFullyQualifiedModelName(fullyQualifiedModelNameToSerializerBaseName(fullyQualifiedModelName), 'summary');
23
22
  const idTypescriptType = `DreamColumn<${modelClassName}, 'id'>`;
24
23
  const modelImportStatements = isSTI
25
24
  ? [importStatementForModel(fullyQualifiedModelName, fullyQualifiedParentName)]
26
25
  : [importStatementForModel(fullyQualifiedModelName, 'ApplicationModel')];
27
- const serializerImportStatement = serializer
28
- ? importStatementForSerializers(fullyQualifiedModelName, serialzerClassName, summarySerialzerClassName)
29
- : '';
30
26
  const attributeStatements = columnsWithTypes.map(attribute => {
31
27
  const [attributeName, attributeType, ...descriptors] = attribute.split(':');
32
28
  if (attributeName === undefined)
@@ -77,7 +73,7 @@ public ${camelize(attributeName)}: ${getAttributeType(attribute, modelClassName)
77
73
  timestamps = timestamps.replace(/\n$/, '');
78
74
  const tableName = snakeify(pluralize(fullyQualifiedModelName.replace(/\//g, '_')));
79
75
  return `\
80
- import { ${uniq(dreamImports).join(', ')} } from '@rvoh/dream'${uniq(modelImportStatements).join('')}${serializerImportStatement}
76
+ import { ${uniq(dreamImports).join(', ')} } from '@rvoh/dream'${uniq(modelImportStatements).join('')}
81
77
 
82
78
  const deco = new Decorators<typeof ${modelClassName}>()
83
79
 
@@ -90,10 +86,10 @@ ${isSTI
90
86
  }
91
87
 
92
88
  `}${serializer
93
- ? ` public ${isSTI ? 'override ' : ''}get serializers() {
89
+ ? ` public ${isSTI ? 'override ' : ''}get serializers(): DreamSerializers<${modelClassName}> {
94
90
  return {
95
- default: ${serialzerClassName},
96
- summary: ${summarySerialzerClassName},
91
+ default: '${serializerGlobalNameFromFullyQualifiedModelName(fullyQualifiedModelName)}',
92
+ summary: '${serializerGlobalNameFromFullyQualifiedModelName(fullyQualifiedModelName, 'summary')}',
97
93
  }
98
94
  }
99
95
 
@@ -108,6 +104,3 @@ function getAttributeType(attribute, modelClassName) {
108
104
  function importStatementForModel(originModelName, destinationModelName = originModelName) {
109
105
  return `\nimport ${globalClassNameFromFullyQualifiedModelName(destinationModelName)} from '${relativeDreamPath('models', 'models', originModelName, destinationModelName)}'`;
110
106
  }
111
- function importStatementForSerializers(originModelName, serialzerClassName, summarySerialzerClassName) {
112
- return `\nimport { ${serialzerClassName}, ${summarySerialzerClassName} } from '${relativeDreamPath('models', 'serializers', originModelName)}'`;
113
- }
@@ -84,6 +84,6 @@ function importStatementForModel(originModelName, destinationModelName = originM
84
84
  const importFrom = relativeDreamPath('serializers', 'models', originModelName, destinationModelName);
85
85
  return `import ${modelName} from '${importFrom}'\n`;
86
86
  }
87
- export function fullyQualifiedModelNameToSerializerBaseName(fullyQualifiedModelName) {
87
+ function fullyQualifiedModelNameToSerializerBaseName(fullyQualifiedModelName) {
88
88
  return fullyQualifiedModelName.replace(/\//g, '');
89
89
  }
@@ -4,6 +4,8 @@ import compact from '../helpers/compact.js';
4
4
  import { DateTime } from '../helpers/DateTime.js';
5
5
  import round from '../helpers/round.js';
6
6
  import snakeify from '../helpers/snakeify.js';
7
+ import DreamSerializerBuilder from './builders/DreamSerializerBuilder.js';
8
+ import ObjectSerializerBuilder from './builders/ObjectSerializerBuilder.js';
7
9
  import inferSerializerFromDreamOrViewModel, { inferSerializersFromDreamClassOrViewModelClass, } from './helpers/inferSerializerFromDreamOrViewModel.js';
8
10
  export default class SerializerRenderer {
9
11
  serializerBuilder;
@@ -37,7 +39,7 @@ export default class SerializerRenderer {
37
39
  case 'attribute': {
38
40
  const outputAttributeName = this.setCase(attribute.options?.as ?? attribute.name);
39
41
  const value = data[attribute.name];
40
- accumulator[outputAttributeName] = applyRenderingOptionsToAttribute(value, attribute.options);
42
+ accumulator[outputAttributeName] = applyRenderingOptionsToAttribute(value, attribute.options, this.passthroughData, this.renderOpts);
41
43
  return accumulator;
42
44
  }
43
45
  /////////////////////
@@ -50,7 +52,7 @@ export default class SerializerRenderer {
50
52
  const outputAttributeName = this.setCase(attribute.options?.as ?? attribute.name);
51
53
  const target = data[attribute.targetName];
52
54
  const value = target[attribute.name];
53
- accumulator[outputAttributeName] = applyRenderingOptionsToAttribute(value, attribute.options);
55
+ accumulator[outputAttributeName] = applyRenderingOptionsToAttribute(value, attribute.options, this.passthroughData, this.renderOpts);
54
56
  return accumulator;
55
57
  }
56
58
  //////////////////////////////
@@ -67,11 +69,11 @@ export default class SerializerRenderer {
67
69
  if (attribute.options.flatten) {
68
70
  return {
69
71
  ...accumulator,
70
- ...applyRenderingOptionsToAttribute(attribute.fn(), {}),
72
+ ...applyRenderingOptionsToAttribute(attribute.fn(), {}, this.passthroughData, this.renderOpts),
71
73
  };
72
74
  }
73
75
  else {
74
- accumulator[outputAttributeName] = applyRenderingOptionsToAttribute(attribute.fn(), {});
76
+ accumulator[outputAttributeName] = applyRenderingOptionsToAttribute(attribute.fn(), {}, this.passthroughData, this.renderOpts);
75
77
  return accumulator;
76
78
  }
77
79
  }
@@ -177,12 +179,14 @@ export default class SerializerRenderer {
177
179
  }
178
180
  }
179
181
  }
180
- function applyRenderingOptionsToAttribute(value, options) {
182
+ function applyRenderingOptionsToAttribute(value, options, passthroughData, renderOptions) {
181
183
  if (Array.isArray(value))
182
- return value.map(val => _applyRenderingOptionsToAttribute(val, options));
183
- return _applyRenderingOptionsToAttribute(value, options);
184
+ return value.map(val => _applyRenderingOptionsToAttribute(val, options, passthroughData, renderOptions));
185
+ return _applyRenderingOptionsToAttribute(value, options, passthroughData, renderOptions);
184
186
  }
185
- function _applyRenderingOptionsToAttribute(value, options) {
187
+ function _applyRenderingOptionsToAttribute(value, options, passthroughData, renderOptions) {
188
+ if (value instanceof DreamSerializerBuilder || value instanceof ObjectSerializerBuilder)
189
+ return value.render(passthroughData, renderOptions);
186
190
  if (value instanceof DateTime)
187
191
  return value.toISO();
188
192
  if (value instanceof CalendarDate)
@@ -601,6 +601,9 @@ export default class Dream {
601
601
  rootTableAlias: InstanceType<T> extends infer T_1 ? T_1 extends InstanceType<T> ? T_1 extends Dream ? T_1["table"] : T_1 : never : never;
602
602
  allowPreload: true;
603
603
  allowLeftJoinPreload: true;
604
+ allowLimit: true;
605
+ allowOffset: true;
606
+ allowPaginate: true;
604
607
  }>>;
605
608
  /**
606
609
  * Finds a record for the corresponding model with the
@@ -790,6 +793,9 @@ export default class Dream {
790
793
  rootTableAlias: InstanceType<T> extends infer T_1 ? T_1 extends InstanceType<T> ? T_1 extends Dream ? T_1["table"] : T_1 : never : never;
791
794
  allowPreload: true;
792
795
  allowLeftJoinPreload: false;
796
+ allowLimit: true;
797
+ allowOffset: true;
798
+ allowPaginate: true;
793
799
  }>>;
794
800
  /**
795
801
  * Returns a new Query instance with the provided
@@ -912,11 +918,14 @@ export default class Dream {
912
918
  * @returns A Query for this model with the limit clause applied
913
919
  */
914
920
  static limit<T extends typeof Dream>(this: T, count: number | null): Query<InstanceType<T>, Readonly<{
915
- joinedAssociations: Readonly<[]>;
921
+ joinedAssociations: readonly [];
916
922
  rootTableName: InstanceType<T>["table"];
917
923
  rootTableAlias: InstanceType<T> extends infer T_1 ? T_1 extends InstanceType<T> ? T_1 extends Dream ? T_1["table"] : T_1 : never : never;
918
924
  allowPreload: true;
919
- allowLeftJoinPreload: true;
925
+ allowLeftJoinPreload: false;
926
+ allowLimit: true;
927
+ allowOffset: true;
928
+ allowPaginate: false;
920
929
  }>>;
921
930
  /**
922
931
  * Returns a new Query instance, specifying an offset
@@ -929,11 +938,14 @@ export default class Dream {
929
938
  * @returns A Query for this model with the offset clause applied
930
939
  */
931
940
  static offset<T extends typeof Dream>(this: T, offset: number | null): Query<InstanceType<T>, Readonly<{
932
- joinedAssociations: Readonly<[]>;
941
+ joinedAssociations: readonly [];
933
942
  rootTableName: InstanceType<T>["table"];
934
943
  rootTableAlias: InstanceType<T> extends infer T_1 ? T_1 extends InstanceType<T> ? T_1 extends Dream ? T_1["table"] : T_1 : never : never;
935
944
  allowPreload: true;
936
- allowLeftJoinPreload: true;
945
+ allowLeftJoinPreload: false;
946
+ allowLimit: true;
947
+ allowOffset: true;
948
+ allowPaginate: false;
937
949
  }>>;
938
950
  /**
939
951
  * Returns a new Query instance, attaching the provided
@@ -6,4 +6,7 @@ export default function applySortableScopeToQuery(query: Query<Dream>, dream: Dr
6
6
  rootTableAlias: string;
7
7
  allowPreload: true;
8
8
  allowLeftJoinPreload: true;
9
+ allowLimit: true;
10
+ allowOffset: true;
11
+ allowPaginate: true;
9
12
  }>>;
@@ -6,4 +6,7 @@ export default function sortableQueryExcludingDream(dream: Dream, query: Query<D
6
6
  rootTableAlias: string;
7
7
  allowPreload: true;
8
8
  allowLeftJoinPreload: true;
9
+ allowLimit: true;
10
+ allowOffset: true;
11
+ allowPaginate: true;
9
12
  }>>;
@@ -364,6 +364,9 @@ export default class DreamClassTransactionBuilder<DreamClass extends typeof Drea
364
364
  rootTableAlias: DreamInstance extends Dream ? DreamInstance["table"] : DreamInstance;
365
365
  allowPreload: true;
366
366
  allowLeftJoinPreload: false;
367
+ allowLimit: true;
368
+ allowOffset: true;
369
+ allowPaginate: true;
367
370
  }>>;
368
371
  /**
369
372
  * Returns a new Query instance with the provided
@@ -498,6 +501,9 @@ export default class DreamClassTransactionBuilder<DreamClass extends typeof Drea
498
501
  rootTableAlias: DreamInstance extends Dream ? DreamInstance["table"] : DreamInstance;
499
502
  allowPreload: true;
500
503
  allowLeftJoinPreload: true;
504
+ allowLimit: true;
505
+ allowOffset: true;
506
+ allowPaginate: true;
501
507
  }>>;
502
508
  /**
503
509
  * Plucks the provided fields from the corresponding model.
@@ -317,7 +317,10 @@ export default class Query<DreamInstance extends Dream, QueryTypeOpts extends Re
317
317
  }> ? true : false, const JoinedAssociationsCandidate = JoinedAssociationsTypeFromAssociations<DB, Schema, TableName, Incompatible extends true ? [] : [...Arr, LastArg]>, const JoinedAssociations extends readonly JoinedAssociation[] = JoinedAssociationsCandidate extends readonly JoinedAssociation[] ? JoinedAssociationsCandidate : never, RetQuery = Query<DreamInstance, ExtendQueryType<QueryTypeOpts, Readonly<{
318
318
  joinedAssociations: JoinedAssociations;
319
319
  allowPreload: false;
320
- }>>>>(this: Q, ...args: Incompatible extends true ? 'leftJoinPreload is incompatible with preload'[] : [...Arr, LastArg]): RetQuery;
320
+ allowLimit: false;
321
+ allowOffset: false;
322
+ allowPaginate: false;
323
+ }>>>>(this: Q, ...args: Incompatible extends true ? 'leftJoinPreload is incompatible with preload, limit, offset, and paginate'[] : [...Arr, LastArg]): RetQuery;
321
324
  /**
322
325
  * Load each specified association using a separate SQL query.
323
326
  * See {@link #leftJoinPreload} for preloading in a single query.
@@ -577,7 +580,12 @@ export default class Query<DreamInstance extends Dream, QueryTypeOpts extends Re
577
580
  *
578
581
  * @returns A cloned Query with the limit clause applied
579
582
  */
580
- limit(limit: number | null): Query<DreamInstance, QueryTypeOpts>;
583
+ limit<Q extends Query<DreamInstance, any>, Incompatible extends Q['queryTypeOpts'] extends Readonly<{
584
+ allowLimit: false;
585
+ }> ? true : false, RetQuery = Query<DreamInstance, ExtendQueryType<QueryTypeOpts, Readonly<{
586
+ allowPaginate: false;
587
+ allowLeftJoinPreload: false;
588
+ }>>>>(this: Q, limit: Incompatible extends true ? 'limit is incompatible with paginate and leftJoinPreload'[] : number | null): RetQuery;
581
589
  /**
582
590
  * Returns a new Query instance, specifying an offset
583
591
  *
@@ -588,7 +596,12 @@ export default class Query<DreamInstance extends Dream, QueryTypeOpts extends Re
588
596
  *
589
597
  * @returns A cloned Query with the offset clause applied
590
598
  */
591
- offset(offset: number | null): Query<DreamInstance, QueryTypeOpts>;
599
+ offset<Q extends Query<DreamInstance, any>, Incompatible extends Q['queryTypeOpts'] extends Readonly<{
600
+ allowOffset: false;
601
+ }> ? true : false, RetQuery = Query<DreamInstance, ExtendQueryType<QueryTypeOpts, Readonly<{
602
+ allowPaginate: false;
603
+ allowLeftJoinPreload: false;
604
+ }>>>>(this: Q, offset: Incompatible extends true ? 'offset is incompatible with paginate and leftJoinPreload'[] : number | null): RetQuery;
592
605
  /**
593
606
  * Returns the sql that would be executed by this Query
594
607
  *
@@ -801,7 +814,9 @@ export default class Query<DreamInstance extends Dream, QueryTypeOpts extends Re
801
814
  * @returns results.currentPage - The current page (same as what is provided in the paginate args)
802
815
  * @returns results.results - An array of records matching the current record
803
816
  */
804
- paginate(opts: PaginatedDreamQueryOptions): Promise<PaginatedDreamQueryResult<DreamInstance>>;
817
+ paginate<Q extends Query<DreamInstance, any>, Incompatible extends Q['queryTypeOpts'] extends Readonly<{
818
+ allowPaginate: false;
819
+ }> ? true : false>(this: Q, opts: Incompatible extends true ? 'paginate is incompatible with limit, offset, and leftJoinPreload'[] : PaginatedDreamQueryOptions): Promise<PaginatedDreamQueryResult<DreamInstance>>;
805
820
  /**
806
821
  * Forces use of a database connection (e.g. 'primary') during the query.
807
822
  *
@@ -10,4 +10,7 @@ export default function applyScopeBypassingSettingsToQuery<DreamInstance extends
10
10
  rootTableAlias: DreamInstance extends Dream ? DreamInstance["table"] : DreamInstance;
11
11
  allowPreload: true;
12
12
  allowLeftJoinPreload: true;
13
+ allowLimit: true;
14
+ allowOffset: true;
15
+ allowPaginate: true;
13
16
  }>>;
@@ -4,4 +4,3 @@ export default function generateSerializerContent({ fullyQualifiedModelName, col
4
4
  fullyQualifiedParentName?: string | undefined;
5
5
  stiBaseSerializer?: boolean;
6
6
  }): string;
7
- export declare function fullyQualifiedModelNameToSerializerBaseName(fullyQualifiedModelName: string): string;
@@ -21,6 +21,9 @@ export type DefaultQueryTypeOptions<TableNameSource extends Dream, TableAliasSou
21
21
  rootTableAlias: TableAliasSource extends Dream ? TableAliasSource['table'] : TableAliasSource;
22
22
  allowPreload: true;
23
23
  allowLeftJoinPreload: true;
24
+ allowLimit: true;
25
+ allowOffset: true;
26
+ allowPaginate: true;
24
27
  }>;
25
28
  export interface PreloadedDreamsAndWhatTheyPointTo {
26
29
  dream: Dream;
@@ -36,6 +39,9 @@ export type ExtendQueryType<OriginalOpts extends Readonly<QueryTypeOptions>, Opt
36
39
  rootTableAlias: OriginalOpts['rootTableAlias'];
37
40
  allowPreload: Opts['allowPreload'] extends false ? false : OriginalOpts['allowPreload'];
38
41
  allowLeftJoinPreload: Opts['allowLeftJoinPreload'] extends false ? false : OriginalOpts['allowLeftJoinPreload'];
42
+ allowLimit: Opts['allowLimit'] extends false ? false : OriginalOpts['allowLimit'];
43
+ allowOffset: Opts['allowOffset'] extends false ? false : OriginalOpts['allowOffset'];
44
+ allowPaginate: Opts['allowPaginate'] extends false ? false : OriginalOpts['allowPaginate'];
39
45
  }>;
40
46
  export type NamespacedColumnType<ColumnName, Q extends Query<any, any>, DreamInstance extends Dream, JoinedAssociationsArr = Q['queryTypeOpts']['joinedAssociations'], AssociationName = ColumnName extends `${infer Name extends string}.${string}` ? Name : never, RealColumnName = ColumnName extends `${string}.${infer Col extends string}` ? Col : never, JoinedAssociation extends FindInterfaceWithValue<JoinedAssociationsArr, 'alias', AssociationName> = FindInterfaceWithValue<JoinedAssociationsArr, 'alias', AssociationName>, JoinedTable = JoinedAssociation['table'] extends never ? DreamInstance['table'] : JoinedAssociation['table'], ReturnType = TableColumnType<DreamInstance['schema'], JoinedTable, RealColumnName>> = ReturnType;
41
47
  type NamespacedColumnTypes<ColumnNames, Q extends Query<any, any>, DreamInstance extends Dream> = ColumnNames extends Readonly<[infer First, ...infer Rest]> ? [
@@ -55,6 +55,9 @@ export type DefaultQueryTypeOptions<
55
55
  rootTableAlias: TableAliasSource extends Dream ? TableAliasSource['table'] : TableAliasSource
56
56
  allowPreload: true
57
57
  allowLeftJoinPreload: true
58
+ allowLimit: true
59
+ allowOffset: true
60
+ allowPaginate: true
58
61
  }>
59
62
 
60
63
  export interface PreloadedDreamsAndWhatTheyPointTo {
@@ -82,6 +85,9 @@ export type ExtendQueryType<
82
85
  allowLeftJoinPreload: Opts['allowLeftJoinPreload'] extends false
83
86
  ? false
84
87
  : OriginalOpts['allowLeftJoinPreload']
88
+ allowLimit: Opts['allowLimit'] extends false ? false : OriginalOpts['allowLimit']
89
+ allowOffset: Opts['allowOffset'] extends false ? false : OriginalOpts['allowOffset']
90
+ allowPaginate: Opts['allowPaginate'] extends false ? false : OriginalOpts['allowPaginate']
85
91
  }>
86
92
 
87
93
  export type NamespacedColumnType<
@@ -28,6 +28,9 @@ export type QueryTypeOptions = {
28
28
  rootTableAlias: string;
29
29
  allowPreload: boolean;
30
30
  allowLeftJoinPreload: boolean;
31
+ allowLimit: boolean;
32
+ allowOffset: boolean;
33
+ allowPaginate: boolean;
31
34
  };
32
35
  export type JoinedAssociationsTypeFromAssociations<DB, Schema, ConcreteTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, ConcreteArgs extends readonly unknown[], Depth extends number = 0, PreviousConcreteTableName = ConcreteTableName, ConcreteAssociationName = never, JoinedAssociationsType extends Readonly<JoinedAssociation[]> = Readonly<[]>, SchemaAssociations = Schema[ConcreteTableName]['associations' & keyof Schema[ConcreteTableName]], ConcreteNthArg extends (keyof SchemaAssociations & string) | AliasedSchemaAssociation<Schema, ConcreteTableName> | Readonly<unknown[]> | null = ConcreteArgs[0] extends undefined ? null : ConcreteArgs[0] extends null ? null : ConcreteArgs[0] extends keyof SchemaAssociations & string ? ConcreteArgs[0] & keyof SchemaAssociations & string : ConcreteArgs[0] extends AliasedSchemaAssociation<Schema, ConcreteTableName> ? ConcreteArgs[0] & AliasedSchemaAssociation<Schema, ConcreteTableName> : ConcreteArgs[0] extends Readonly<unknown[]> ? Readonly<unknown[]> : null, CurrentArgumentType extends IS_ASSOCIATION_NAME | IS_ASSOCIATION_ALIAS | IS_NOT_ASSOCIATION_NAME = ConcreteNthArg extends null ? IS_NOT_ASSOCIATION_NAME : ConcreteNthArg extends Readonly<unknown[]> ? IS_NOT_ASSOCIATION_NAME : ConcreteNthArg extends keyof SchemaAssociations & string ? IS_ASSOCIATION_NAME : ConcreteNthArg extends AliasedSchemaAssociation<Schema, ConcreteTableName> ? IS_ASSOCIATION_ALIAS : IS_NOT_ASSOCIATION_NAME, NextPreviousConcreteTableName = CurrentArgumentType extends IS_ASSOCIATION_NAME ? ConcreteTableName : CurrentArgumentType extends IS_ASSOCIATION_ALIAS ? ConcreteTableName : PreviousConcreteTableName, NextUnaliasedAssociationName = CurrentArgumentType extends IS_ASSOCIATION_NAME ? ConcreteNthArg : CurrentArgumentType extends IS_ASSOCIATION_ALIAS ? ConcreteNthArg extends `${infer AssocName extends string} as ${string}` ? AssocName & keyof SchemaAssociations : never : never, NextAliasedAssociationName = CurrentArgumentType extends IS_ASSOCIATION_NAME ? ConcreteNthArg : CurrentArgumentType extends IS_ASSOCIATION_ALIAS ? ConcreteNthArg extends `${string} as ${infer Alias extends string}` ? Alias : ConcreteAssociationName : ConcreteAssociationName, NextTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB = CurrentArgumentType extends IS_ASSOCIATION_NAME ? AssociationTableName<Schema, ConcreteTableName, NextUnaliasedAssociationName> : CurrentArgumentType extends IS_ASSOCIATION_ALIAS ? AssociationTableName<Schema, ConcreteTableName, NextUnaliasedAssociationName> : ConcreteTableName & AssociationTableNames<DB, Schema> & keyof DB> = ConcreteArgs['length'] extends 0 ? JoinedAssociationsType : Depth extends MAX_VARIADIC_DEPTH ? never : ConcreteArgs['length'] extends 1 ? ConcreteNthArg extends Readonly<unknown[]> ? JoinedAssociationsType : JoinedAssociationsTypeFromAssociations<DB, Schema, NextTableName, ReadonlyTail<ConcreteArgs>, Inc<Depth>, NextPreviousConcreteTableName, NextAliasedAssociationName, CurrentArgumentType extends IS_NOT_ASSOCIATION_NAME ? JoinedAssociationsType : Readonly<[
33
36
  ...JoinedAssociationsType,
@@ -330,6 +330,9 @@ export type QueryTypeOptions = {
330
330
  rootTableAlias: string
331
331
  allowPreload: boolean
332
332
  allowLeftJoinPreload: boolean
333
+ allowLimit: boolean
334
+ allowOffset: boolean
335
+ allowPaginate: boolean
333
336
  }
334
337
 
335
338
  export type JoinedAssociationsTypeFromAssociations<