@rvoh/dream 0.31.5 → 0.32.1

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 (229) hide show
  1. package/dist/cjs/src/Dream.js +9 -9
  2. package/dist/cjs/src/bin/helpers/sync.js +7 -7
  3. package/dist/cjs/src/cli/logger/loggable/colorize.js +1 -1
  4. package/dist/cjs/src/db/DreamDbConnection.js +1 -1
  5. package/dist/cjs/src/decorators/field/sortable/hooks/beforeSortableSave.js +6 -3
  6. package/dist/cjs/src/dream/DreamInstanceTransactionBuilder.js +3 -3
  7. package/dist/cjs/src/dream/LeftJoinLoadBuilder.js +5 -1
  8. package/dist/cjs/src/dream/Query.js +74 -12
  9. package/dist/cjs/src/dream/internal/associations/associationUpdateQuery.js +3 -0
  10. package/dist/cjs/src/dream/internal/associations/createAssociation.js +3 -0
  11. package/dist/cjs/src/dream/internal/checkSingleValidation.js +8 -1
  12. package/dist/cjs/src/dream/internal/extractAssociationMetadataFromAssociationName.js +7 -3
  13. package/dist/cjs/src/errors/MissingTable.js +1 -1
  14. package/dist/cjs/src/errors/UnexpectedUndefined.js +14 -0
  15. package/dist/cjs/src/errors/associations/AssociationDeclaredWithoutAssociatedDreamClass.js +17 -0
  16. package/dist/cjs/src/global-cli/file-builders/DreamtsBuilder.js +2 -2
  17. package/dist/cjs/src/global-cli/helpers/argAndValue.js +4 -4
  18. package/dist/cjs/src/helpers/CalendarDate.js +1 -1
  19. package/dist/cjs/src/helpers/cli/SchemaBuilder.js +52 -17
  20. package/dist/cjs/src/helpers/cli/generateDreamContent.js +3 -1
  21. package/dist/cjs/src/helpers/cli/generateFactoryContent.js +7 -3
  22. package/dist/cjs/src/helpers/cli/generateMigrationContent.js +53 -21
  23. package/dist/cjs/src/helpers/cli/generateSerializerContent.js +3 -25
  24. package/dist/cjs/src/helpers/objectPathsToArrays.js +2 -1
  25. package/dist/esm/src/Dream.js +9 -9
  26. package/dist/esm/src/bin/helpers/sync.js +4 -4
  27. package/dist/esm/src/cli/logger/loggable/colorize.js +1 -1
  28. package/dist/esm/src/db/DreamDbConnection.js +1 -1
  29. package/dist/esm/src/decorators/field/sortable/hooks/beforeSortableSave.js +6 -3
  30. package/dist/esm/src/dream/DreamInstanceTransactionBuilder.js +3 -3
  31. package/dist/esm/src/dream/LeftJoinLoadBuilder.js +5 -1
  32. package/dist/esm/src/dream/Query.js +74 -12
  33. package/dist/esm/src/dream/internal/associations/associationUpdateQuery.js +3 -0
  34. package/dist/esm/src/dream/internal/associations/createAssociation.js +3 -0
  35. package/dist/esm/src/dream/internal/checkSingleValidation.js +8 -1
  36. package/dist/esm/src/dream/internal/extractAssociationMetadataFromAssociationName.js +7 -3
  37. package/dist/esm/src/errors/MissingTable.js +1 -1
  38. package/dist/esm/src/errors/UnexpectedUndefined.js +11 -0
  39. package/dist/esm/src/errors/associations/AssociationDeclaredWithoutAssociatedDreamClass.js +14 -0
  40. package/dist/esm/src/global-cli/file-builders/DreamtsBuilder.js +2 -2
  41. package/dist/esm/src/global-cli/helpers/argAndValue.js +4 -4
  42. package/dist/esm/src/helpers/CalendarDate.js +1 -1
  43. package/dist/esm/src/helpers/cli/SchemaBuilder.js +52 -17
  44. package/dist/esm/src/helpers/cli/generateDreamContent.js +3 -1
  45. package/dist/esm/src/helpers/cli/generateFactoryContent.js +7 -3
  46. package/dist/esm/src/helpers/cli/generateMigrationContent.js +53 -21
  47. package/dist/esm/src/helpers/cli/generateSerializerContent.js +3 -25
  48. package/dist/esm/src/helpers/objectPathsToArrays.js +2 -1
  49. package/dist/types/src/Dream.d.ts +1 -1
  50. package/dist/types/src/cli/logger/loggable/DreamCliLoggable.d.ts +3 -3
  51. package/dist/types/src/cli/logger/loggable/DreamCliLoggableText.d.ts +5 -5
  52. package/dist/types/src/cli/logger/loggable/colorize.d.ts +3 -3
  53. package/dist/types/src/db/ConnectedToDB.d.ts +3 -3
  54. package/dist/types/src/decorators/field/sortable/helpers/decrementScopedRecordsGreaterThanPosition.d.ts +1 -1
  55. package/dist/types/src/decorators/field/sortable/helpers/positionIsInvalid.d.ts +1 -1
  56. package/dist/types/src/decorators/field/sortable/helpers/setPosition.d.ts +2 -2
  57. package/dist/types/src/decorators/field/sortable/hooks/afterSortableCreate.d.ts +2 -2
  58. package/dist/types/src/decorators/field/sortable/hooks/afterSortableDestroy.d.ts +1 -1
  59. package/dist/types/src/decorators/field/sortable/hooks/afterSortableUpdate.d.ts +2 -2
  60. package/dist/types/src/decorators/field/sortable/hooks/beforeSortableSave.d.ts +1 -1
  61. package/dist/types/src/decorators/field-or-getter/Virtual.d.ts +1 -1
  62. package/dist/types/src/dream/Query.d.ts +26 -26
  63. package/dist/types/src/dream/internal/destroyOptions.d.ts +4 -4
  64. package/dist/types/src/dream/internal/similarity/SimilarityBuilder.d.ts +4 -4
  65. package/dist/types/src/dream-application/index.d.ts +1 -1
  66. package/dist/types/src/errors/UnexpectedUndefined.d.ts +4 -0
  67. package/dist/types/src/errors/associations/AssociationDeclaredWithoutAssociatedDreamClass.d.ts +7 -0
  68. package/dist/types/src/errors/associations/MissingRequiredAssociationOnClause.d.ts +1 -1
  69. package/dist/types/src/helpers/cli/generateDream.d.ts +1 -1
  70. package/dist/types/src/helpers/cli/generateDreamContent.d.ts +1 -1
  71. package/dist/types/src/helpers/cli/generateMigration.d.ts +2 -2
  72. package/dist/types/src/helpers/cli/generateMigrationContent.d.ts +4 -4
  73. package/dist/types/src/helpers/cli/generateSerializer.d.ts +1 -1
  74. package/dist/types/src/helpers/cli/generateSerializerContent.d.ts +2 -2
  75. package/dist/types/src/types/associations/shared.d.ts +1 -6
  76. package/dist/types/src/types/dream.d.ts +2 -13
  77. package/dist/types/src/types/lifecycle.d.ts +2 -2
  78. package/dist/types/src/types/logger.d.ts +3 -3
  79. package/docs/classes/Benchmark.html +2 -2
  80. package/docs/classes/CalendarDate.html +2 -2
  81. package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +3 -3
  82. package/docs/classes/Decorators.html +19 -19
  83. package/docs/classes/Dream.html +127 -127
  84. package/docs/classes/DreamApplication.html +4 -4
  85. package/docs/classes/DreamBin.html +2 -2
  86. package/docs/classes/DreamCLI.html +4 -4
  87. package/docs/classes/DreamDbConnection.html +2 -2
  88. package/docs/classes/DreamGlam.html +2 -2
  89. package/docs/classes/DreamImporter.html +2 -2
  90. package/docs/classes/DreamMigrationHelpers.html +7 -7
  91. package/docs/classes/DreamSerializer.html +2 -2
  92. package/docs/classes/DreamTransaction.html +2 -2
  93. package/docs/classes/Encrypt.html +2 -2
  94. package/docs/classes/Env.html +2 -2
  95. package/docs/classes/GlobalNameNotSet.html +3 -3
  96. package/docs/classes/NonLoadedAssociation.html +3 -3
  97. package/docs/classes/Query.html +51 -51
  98. package/docs/classes/Range.html +2 -2
  99. package/docs/classes/RecordNotFound.html +3 -3
  100. package/docs/classes/ValidationError.html +3 -3
  101. package/docs/functions/Attribute.html +1 -1
  102. package/docs/functions/RendersMany.html +1 -1
  103. package/docs/functions/RendersOne.html +1 -1
  104. package/docs/functions/ReplicaSafe.html +1 -1
  105. package/docs/functions/STI.html +1 -1
  106. package/docs/functions/SoftDelete.html +1 -1
  107. package/docs/functions/camelize.html +1 -1
  108. package/docs/functions/capitalize.html +1 -1
  109. package/docs/functions/closeAllDbConnections.html +1 -1
  110. package/docs/functions/compact.html +1 -1
  111. package/docs/functions/db.html +1 -1
  112. package/docs/functions/debug.html +1 -1
  113. package/docs/functions/dreamDbConnections.html +1 -1
  114. package/docs/functions/dreamPath.html +1 -1
  115. package/docs/functions/generateDream.html +1 -1
  116. package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
  117. package/docs/functions/hyphenize.html +1 -1
  118. package/docs/functions/inferSerializerFromDreamClassOrViewModelClass.html +1 -1
  119. package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
  120. package/docs/functions/isEmpty.html +1 -1
  121. package/docs/functions/loadRepl.html +1 -1
  122. package/docs/functions/lookupClassByGlobalName.html +1 -1
  123. package/docs/functions/pascalize.html +1 -1
  124. package/docs/functions/pgErrorType.html +1 -1
  125. package/docs/functions/range-1.html +1 -1
  126. package/docs/functions/relativeDreamPath.html +1 -1
  127. package/docs/functions/round.html +1 -1
  128. package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
  129. package/docs/functions/sharedPathPrefix.html +1 -1
  130. package/docs/functions/snakeify.html +1 -1
  131. package/docs/functions/sort.html +1 -1
  132. package/docs/functions/sortBy.html +1 -1
  133. package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
  134. package/docs/functions/uncapitalize.html +1 -1
  135. package/docs/functions/uniq.html +1 -1
  136. package/docs/functions/validateColumn.html +1 -1
  137. package/docs/functions/validateTable.html +1 -1
  138. package/docs/interfaces/AttributeStatement.html +2 -2
  139. package/docs/interfaces/DecoratorContext.html +2 -2
  140. package/docs/interfaces/DreamApplicationInitOptions.html +2 -2
  141. package/docs/interfaces/DreamApplicationOpts.html +2 -2
  142. package/docs/interfaces/DreamSerializerAssociationStatement.html +2 -2
  143. package/docs/interfaces/EncryptOptions.html +2 -2
  144. package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
  145. package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
  146. package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
  147. package/docs/types/Camelized.html +1 -1
  148. package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
  149. package/docs/types/DateTime.html +1 -1
  150. package/docs/types/DreamAssociationMetadata.html +1 -1
  151. package/docs/types/DreamAttributes.html +1 -1
  152. package/docs/types/DreamClassColumn.html +1 -1
  153. package/docs/types/DreamColumn.html +1 -1
  154. package/docs/types/DreamColumnNames.html +1 -1
  155. package/docs/types/DreamLogLevel.html +1 -1
  156. package/docs/types/DreamLogger.html +1 -1
  157. package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
  158. package/docs/types/DreamParamSafeAttributes.html +1 -1
  159. package/docs/types/DreamParamSafeColumnNames.html +1 -1
  160. package/docs/types/DreamSerializerKey.html +1 -1
  161. package/docs/types/DreamSerializers.html +1 -1
  162. package/docs/types/DreamTableSchema.html +1 -1
  163. package/docs/types/DreamVirtualColumns.html +1 -1
  164. package/docs/types/EncryptAlgorithm.html +1 -1
  165. package/docs/types/Hyphenized.html +1 -1
  166. package/docs/types/IdType.html +1 -1
  167. package/docs/types/OpenapiAllTypes.html +1 -1
  168. package/docs/types/OpenapiFormats.html +1 -1
  169. package/docs/types/OpenapiNumberFormats.html +1 -1
  170. package/docs/types/OpenapiPrimitiveTypes.html +1 -1
  171. package/docs/types/OpenapiSchemaArray.html +1 -1
  172. package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
  173. package/docs/types/OpenapiSchemaBase.html +1 -1
  174. package/docs/types/OpenapiSchemaBody.html +1 -1
  175. package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
  176. package/docs/types/OpenapiSchemaCommonFields.html +1 -1
  177. package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
  178. package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
  179. package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
  180. package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
  181. package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
  182. package/docs/types/OpenapiSchemaInteger.html +1 -1
  183. package/docs/types/OpenapiSchemaNull.html +1 -1
  184. package/docs/types/OpenapiSchemaNumber.html +1 -1
  185. package/docs/types/OpenapiSchemaObject.html +1 -1
  186. package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
  187. package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
  188. package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
  189. package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
  190. package/docs/types/OpenapiSchemaObjectBase.html +1 -1
  191. package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
  192. package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
  193. package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
  194. package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
  195. package/docs/types/OpenapiSchemaPartialSegment.html +1 -1
  196. package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
  197. package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
  198. package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
  199. package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
  200. package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
  201. package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
  202. package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
  203. package/docs/types/OpenapiSchemaString.html +1 -1
  204. package/docs/types/OpenapiShorthandAllTypes.html +1 -1
  205. package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
  206. package/docs/types/OpenapiTypeField.html +1 -1
  207. package/docs/types/Pascalized.html +1 -1
  208. package/docs/types/PrimaryKeyType.html +1 -1
  209. package/docs/types/RoundingPrecision.html +1 -1
  210. package/docs/types/SerializableClassOrSerializerCallback.html +1 -1
  211. package/docs/types/SerializableDreamClassOrViewModelClass.html +1 -1
  212. package/docs/types/SerializableDreamOrViewModel.html +1 -1
  213. package/docs/types/SerializableTypes.html +1 -1
  214. package/docs/types/Snakeified.html +1 -1
  215. package/docs/types/Timestamp.html +1 -1
  216. package/docs/types/UpdateableAssociationProperties.html +1 -1
  217. package/docs/types/UpdateableProperties.html +1 -1
  218. package/docs/types/ValidationType.html +1 -1
  219. package/docs/types/ViewModelSerializerKey.html +1 -1
  220. package/docs/types/WhereStatementForDream.html +1 -1
  221. package/docs/types/WhereStatementForDreamClass.html +1 -1
  222. package/docs/variables/DateTime-1.html +1 -1
  223. package/docs/variables/DreamConst.html +1 -1
  224. package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
  225. package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
  226. package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
  227. package/docs/variables/ops.html +1 -1
  228. package/docs/variables/primaryKeyTypes.html +1 -1
  229. package/package.json +1 -1
@@ -2,14 +2,19 @@ import pluralize from 'pluralize-esm';
2
2
  import InvalidDecimalFieldPassedToGenerator from '../../errors/InvalidDecimalFieldPassedToGenerator.js';
3
3
  import foreignKeyTypeFromPrimaryKey from '../db/foreignKeyTypeFromPrimaryKey.js';
4
4
  import snakeify from '../snakeify.js';
5
+ const STI_TYPE_COLUMN_NAME = 'type';
6
+ const COLUMNS_TO_INDEX = [STI_TYPE_COLUMN_NAME];
7
+ const NOT_NULL_COLUMNS = [STI_TYPE_COLUMN_NAME];
5
8
  export default function generateMigrationContent({ table, columnsWithTypes = [], primaryKeyType = 'bigserial', createOrAlter = 'create', } = {}) {
6
9
  const altering = createOrAlter === 'alter';
7
10
  let requireCitextExtension = false;
8
- const { columnDefs, columnDrops } = columnsWithTypes.reduce((acc, attribute) => {
9
- const { columnDefs, columnDrops } = acc;
11
+ const { columnDefs, columnDrops, indexDefs, indexDrops } = columnsWithTypes.reduce((acc, attribute) => {
12
+ const { columnDefs, columnDrops, indexDefs, indexDrops } = acc;
10
13
  const [nonStandardAttributeName, attributeType, ...descriptors] = attribute.split(':');
11
14
  let attributeName = snakeify(nonStandardAttributeName);
12
- if (['has_one', 'has_many'].includes(attributeType))
15
+ if (attributeName === undefined)
16
+ return acc;
17
+ if (attributeType !== undefined && ['has_one', 'has_many'].includes(attributeType))
13
18
  return acc;
14
19
  if (attributeType === 'citext')
15
20
  requireCitextExtension = true;
@@ -35,12 +40,23 @@ export default function generateMigrationContent({ table, columnsWithTypes = [],
35
40
  columnDefs.push(generateColumnStr(`encrypted_${attributeName}`, 'text', descriptors));
36
41
  break;
37
42
  default:
38
- columnDefs.push(generateColumnStr(attributeName, coercedAttributeType, descriptors));
43
+ if (coercedAttributeType !== undefined) {
44
+ columnDefs.push(generateColumnStr(attributeName, coercedAttributeType, descriptors));
45
+ }
39
46
  break;
40
47
  }
41
48
  columnDrops.push(`.dropColumn('${attributeName}')`);
49
+ if (COLUMNS_TO_INDEX.includes(attributeName)) {
50
+ const indexName = `${table}_${attributeName}`;
51
+ indexDefs.push(`await db.schema
52
+ .createIndex('${indexName}')
53
+ .on('${table}')
54
+ .column('${attributeName}')
55
+ .execute()`);
56
+ indexDrops.push(`await db.schema.dropIndex('${indexName}').execute()`);
57
+ }
42
58
  return acc;
43
- }, { columnDefs: [], columnDrops: [] });
59
+ }, { columnDefs: [], columnDrops: [], indexDefs: [], indexDrops: [] });
44
60
  if (!table) {
45
61
  return `\
46
62
  import { Kysely, sql } from 'kysely'
@@ -61,28 +77,31 @@ export async function down(db: Kysely<any>): Promise<void> {
61
77
  const dreamImports = [];
62
78
  if (requireCitextExtension)
63
79
  dreamImports.push('DreamMigrationHelpers');
64
- const newline = '\n ';
65
- const columnDefLines = columnDefs.length ? newline + columnDefs.join(newline) : '';
66
- const columnDropLines = columnDrops.length ? newline + columnDrops.join(newline) + newline : '';
80
+ const newlineIndent = '\n ';
81
+ const newlineDoubleIndent = '\n ';
82
+ const columnDefLines = columnDefs.length ? newlineDoubleIndent + columnDefs.join(newlineDoubleIndent) : '';
83
+ const columnDropLines = columnDrops.length
84
+ ? newlineDoubleIndent + columnDrops.join(newlineDoubleIndent) + newlineDoubleIndent
85
+ : '';
67
86
  return `\
68
87
  ${dreamImports.length ? `import { ${dreamImports.join(', ')} } from '@rvoh/dream'\n` : ''}import { ${kyselyImports.join(', ')} } from 'kysely'
69
88
 
70
89
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
71
90
  export async function up(db: Kysely<any>): Promise<void> {
72
91
  ${citextExtension}${generateEnumStatements(columnsWithTypes)} await db.schema
73
- .${altering ? 'alterTable' : 'createTable'}('${table}')${altering ? '' : newline + generateIdStr({ primaryKeyType })}${columnDefLines}${altering
92
+ .${altering ? 'alterTable' : 'createTable'}('${table}')${altering ? '' : newlineDoubleIndent + generateIdStr({ primaryKeyType })}${columnDefLines}${altering
74
93
  ? ''
75
- : newline +
94
+ : newlineDoubleIndent +
76
95
  ".addColumn('created_at', 'timestamp', col => col.notNull())" +
77
- newline +
96
+ newlineDoubleIndent +
78
97
  ".addColumn('updated_at', 'timestamp', col => col.notNull())"}
79
- .execute()
98
+ .execute()${indexDefs.length ? `\n${newlineIndent}` : ''}${indexDefs.join(newlineDoubleIndent)}
80
99
  }
81
100
 
82
101
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
102
  export async function down(db: Kysely<any>): Promise<void> {
84
- ${altering
85
- ? `await db.schema${newline}.alterTable('${table}')${columnDropLines}.execute()`
103
+ ${indexDrops.join(newlineIndent)}${indexDrops.length ? newlineIndent : ''}${altering
104
+ ? `await db.schema${newlineDoubleIndent}.alterTable('${table}')${columnDropLines}.execute()`
86
105
  : `await db.schema.dropTable('${table}').execute()`}${generateEnumDropStatements(columnsWithTypes)}
87
106
  }\
88
107
  `;
@@ -109,7 +128,10 @@ function generateEnumStatements(columnsWithTypes) {
109
128
  const enumStatements = columnsWithTypes.filter(attribute => /:enum:.*:/.test(attribute));
110
129
  const finalStatements = enumStatements.map(statement => {
111
130
  const enumName = statement.split(':')[2];
112
- const columnsWithTypes = statement.split(':')[3].split(/,\s{0,}/);
131
+ const columnsWithTypesString = statement.split(':')[3];
132
+ if (columnsWithTypesString === undefined)
133
+ return '';
134
+ const columnsWithTypes = columnsWithTypesString.split(/,\s{0,}/);
113
135
  return ` await db.schema
114
136
  .createType('${enumName}_enum')
115
137
  .asEnum([
@@ -132,7 +154,11 @@ function generateBooleanStr(attributeName) {
132
154
  }
133
155
  function generateEnumStr(attribute) {
134
156
  const computedAttributeType = enumAttributeType(attribute);
135
- return `.addColumn('${attribute.split(':')[0]}', ${computedAttributeType})`;
157
+ const attributeName = attribute.split(':')[0];
158
+ if (attributeName === undefined)
159
+ return '';
160
+ const notNull = NOT_NULL_COLUMNS.includes(attributeName);
161
+ return `.addColumn('${attributeName}', ${computedAttributeType}${notNull ? ', col => col.notNull()' : ''})`;
136
162
  }
137
163
  function generateDecimalStr(attribute) {
138
164
  const [, , ...descriptors] = attribute.split(':');
@@ -145,15 +171,21 @@ function generateColumnStr(attributeName, attributeType, descriptors) {
145
171
  let returnStr = `.addColumn('${attributeName}', ${attributeTypeString(attributeType)}`;
146
172
  const providedDefaultArg = descriptors.find(d => /^default\(/.test(d));
147
173
  const providedDefault = providedDefaultArg?.replace(/^default\(/, '')?.replace(/\)$/, '');
148
- const hasExtraValues = descriptors.includes('primary') || providedDefault;
174
+ const notNull = NOT_NULL_COLUMNS.includes(attributeName);
175
+ const hasExtraValues = providedDefault || notNull;
149
176
  if (hasExtraValues)
150
177
  returnStr += ', col => col';
151
- if (descriptors.includes('primary'))
152
- returnStr += `.defaultTo('${providedDefault}')`;
178
+ if (notNull)
179
+ returnStr += '.notNull()';
153
180
  if (providedDefault)
154
181
  returnStr += `.defaultTo('${providedDefault}')`;
155
- // TODO: handle index
156
- return `${returnStr}${hasExtraValues ? '))' : ')'}`;
182
+ returnStr = `${returnStr})`;
183
+ if (attributeName === STI_TYPE_COLUMN_NAME)
184
+ returnStr = `// CONSIDER: when using type for STI, always use an enum
185
+ // Try using the enum syntax in your generator, e.g.:
186
+ // yarn psy g:model Balloon type:enum:balloon_type:latex,mylar
187
+ ${returnStr}`;
188
+ return returnStr;
157
189
  }
158
190
  function attributeTypeString(attributeType) {
159
191
  const attributeTypesRequiringSql = ['citext'];
@@ -1,6 +1,5 @@
1
1
  import camelize from '../camelize.js';
2
2
  import globalClassNameFromFullyQualifiedModelName from '../globalClassNameFromFullyQualifiedModelName.js';
3
- import pascalize from '../pascalize.js';
4
3
  import relativeDreamPath from '../path/relativeDreamPath.js';
5
4
  import serializerNameFromFullyQualifiedModelName from '../serializerNameFromFullyQualifiedModelName.js';
6
5
  import standardizeFullyQualifiedModelName from '../standardizeFullyQualifiedModelName.js';
@@ -71,6 +70,8 @@ export default class ${defaultSerialzerClassName}${dataTypeCapture} extends ${de
71
70
  ${columnsWithTypes
72
71
  .map(attr => {
73
72
  const [name, type] = attr.split(':');
73
+ if (name === undefined)
74
+ return '';
74
75
  const fullyQualifiedAssociatedModelName = standardizeFullyQualifiedModelName(name);
75
76
  const associatedModelName = globalClassNameFromFullyQualifiedModelName(fullyQualifiedAssociatedModelName);
76
77
  const propertyName = camelize(associatedModelName);
@@ -81,7 +82,7 @@ ${columnsWithTypes
81
82
  return '';
82
83
  default:
83
84
  return ` @Attribute(${modelClassName}${attributeOptionsSpecifier(type, attr)})
84
- public ${propertyName}: ${jsType(type, attr, propertyName, modelClassName)}`;
85
+ public ${propertyName}: ${`DreamColumn<${modelClassName}, '${propertyName}'>`}`;
85
86
  }
86
87
  })
87
88
  .join('\n\n ')}
@@ -96,29 +97,6 @@ function attributeOptionsSpecifier(type, attr) {
96
97
  return '';
97
98
  }
98
99
  }
99
- function jsType(type, originalAttribute, propertyName, modelClass = null) {
100
- if (modelClass)
101
- return `DreamColumn<${modelClass}, '${propertyName}'>`;
102
- switch (type) {
103
- case 'date':
104
- return 'CalendarDate';
105
- case 'datetime':
106
- return 'DateTime';
107
- case 'decimal':
108
- case 'integer':
109
- case 'number':
110
- return 'number';
111
- case 'string':
112
- case 'text':
113
- case 'bigint':
114
- case 'uuid':
115
- return 'string';
116
- case 'enum':
117
- return pascalize(originalAttribute.split(':')[2]) + 'Enum';
118
- default:
119
- return 'any';
120
- }
121
- }
122
100
  function importStatementForSerializer(originModelName, destinationModelName) {
123
101
  return `\nimport ${globalClassNameFromFullyQualifiedModelName(serializerNameFromFullyQualifiedModelName(destinationModelName))}, { ${globalClassNameFromFullyQualifiedModelName(serializerNameFromFullyQualifiedModelName(destinationModelName, 'summary'))} } from '${relativeDreamPath('serializers', 'serializers', originModelName, destinationModelName)}'`;
124
102
  }
@@ -6,7 +6,8 @@ export default function objectPathsToArrays(obj) {
6
6
  }
7
7
  function depthFirstSearch(obj, workingPath, completePaths) {
8
8
  return Object.keys(obj).forEach(key => {
9
- if (Object.keys(obj[key]).length) {
9
+ const subObj = obj[key];
10
+ if (subObj && Object.keys(subObj).length) {
10
11
  depthFirstSearch(obj[key], [...workingPath, key], completePaths);
11
12
  }
12
13
  else {
@@ -1440,7 +1440,7 @@ export default class Dream {
1440
1440
  *
1441
1441
  * ```ts
1442
1442
  * class User extends ApplicationModel {
1443
- * public get table() {
1443
+ * public override get table() {
1444
1444
  * return 'users' as const
1445
1445
  * }
1446
1446
  * }
@@ -4,9 +4,9 @@ export default class DreamCliLoggable {
4
4
  logPrefixColor: DreamCliForegroundColor | undefined;
5
5
  logPrefixBgColor: DreamCliBgColor | undefined;
6
6
  constructor({ logPrefix, logPrefixColor, logPrefixBgColor, }: {
7
- logPrefix?: string;
8
- logPrefixColor?: DreamCliForegroundColor;
9
- logPrefixBgColor?: DreamCliBgColor;
7
+ logPrefix?: string | undefined;
8
+ logPrefixColor?: DreamCliForegroundColor | undefined;
9
+ logPrefixBgColor?: DreamCliBgColor | undefined;
10
10
  });
11
11
  render(): void;
12
12
  get colorizedLogPrefix(): string;
@@ -5,11 +5,11 @@ export default class DreamCliLoggableText extends DreamCliLoggable {
5
5
  private color;
6
6
  private bgColor;
7
7
  constructor(text: string, { logPrefix, color, bgColor, logPrefixColor, logPrefixBgColor, }: {
8
- logPrefix?: string;
9
- color?: DreamCliForegroundColor;
10
- bgColor?: DreamCliBgColor;
11
- logPrefixColor?: DreamCliForegroundColor;
12
- logPrefixBgColor?: DreamCliBgColor;
8
+ logPrefix?: string | undefined;
9
+ color?: DreamCliForegroundColor | undefined;
10
+ bgColor?: DreamCliBgColor | undefined;
11
+ logPrefixColor?: DreamCliForegroundColor | undefined;
12
+ logPrefixBgColor?: DreamCliBgColor | undefined;
13
13
  });
14
14
  render(): void;
15
15
  }
@@ -1,5 +1,5 @@
1
1
  import { DreamCliBgColor, DreamCliForegroundColor } from '../../../types/logger.js';
2
- export default function colorize(text: string, { color, bgColor }: {
3
- color?: DreamCliForegroundColor;
4
- bgColor?: DreamCliBgColor;
2
+ export default function colorize(text: string, { color, bgColor, }: {
3
+ color?: DreamCliForegroundColor | undefined;
4
+ bgColor?: DreamCliBgColor | undefined;
5
5
  }): string;
@@ -7,7 +7,7 @@ export default class ConnectedToDB<DreamInstance extends Dream> {
7
7
  dreamInstance: DreamInstance;
8
8
  protected readonly dreamClass: DreamConstructorType<DreamInstance>;
9
9
  protected dreamTransaction: DreamTransaction<Dream> | null;
10
- protected connectionOverride?: DbConnectionType;
10
+ protected connectionOverride: DbConnectionType | undefined;
11
11
  /**
12
12
  * @internal
13
13
  *
@@ -21,6 +21,6 @@ export default class ConnectedToDB<DreamInstance extends Dream> {
21
21
  }
22
22
  export interface ConnectedToDBOpts {
23
23
  transaction?: DreamTransaction<Dream> | null | undefined;
24
- connection?: DbConnectionType;
25
- innerJoinDreamClasses?: readonly (typeof Dream)[];
24
+ connection?: DbConnectionType | undefined;
25
+ innerJoinDreamClasses?: readonly (typeof Dream)[] | undefined;
26
26
  }
@@ -4,5 +4,5 @@ export default function decrementPositionForScopedRecordsGreaterThanPosition(pos
4
4
  dream: Dream;
5
5
  positionField: string;
6
6
  query: Query<Dream>;
7
- scope?: string | string[];
7
+ scope: string | string[] | undefined;
8
8
  }): Promise<void>;
@@ -4,5 +4,5 @@ export default function positionIsInvalid({ query, dream, position, scope, }: {
4
4
  query: Query<Dream>;
5
5
  dream: Dream;
6
6
  position: number | null | undefined;
7
- scope?: string | string[];
7
+ scope: string | string[] | undefined;
8
8
  }): Promise<boolean>;
@@ -8,7 +8,7 @@ export default function setPosition({ position, previousPosition, dream, positio
8
8
  previousPosition?: number;
9
9
  positionField: string;
10
10
  query: Query<Dream>;
11
- scope?: string | string[];
12
- txn?: DreamTransaction<any>;
11
+ scope: string | string[] | undefined;
12
+ txn: DreamTransaction<any> | undefined;
13
13
  }): Promise<void>;
14
14
  export declare function applySortableScopesToQuery<QB extends UpdateQueryBuilder<any, string, string, any> | SelectQueryBuilder<any, any, any>>(dream: Dream, kyselyQuery: QB, whereValueCB: (column: string) => any, scope?: string | string[]): QB;
@@ -5,6 +5,6 @@ export default function afterSortableCreate({ positionField, dream, query, txn,
5
5
  positionField: string;
6
6
  dream: Dream;
7
7
  query: Query<Dream>;
8
- txn?: DreamTransaction<any>;
9
- scope?: string | string[];
8
+ txn?: DreamTransaction<any> | undefined;
9
+ scope: string | string[] | undefined;
10
10
  }): Promise<void>;
@@ -4,5 +4,5 @@ export default function afterSortableDestroy({ positionField, dream, query, scop
4
4
  positionField: string;
5
5
  dream: Dream;
6
6
  query: Query<Dream>;
7
- scope?: string | string[];
7
+ scope: string | string[] | undefined;
8
8
  }): Promise<void>;
@@ -5,6 +5,6 @@ export default function afterUpdateSortable({ positionField, dream, query, txn,
5
5
  positionField: string;
6
6
  dream: Dream;
7
7
  query: Query<Dream>;
8
- txn?: DreamTransaction<any>;
9
- scope?: string | string[];
8
+ txn?: DreamTransaction<any> | undefined;
9
+ scope: string | string[] | undefined;
10
10
  }): Promise<void>;
@@ -4,5 +4,5 @@ export default function beforeSortableSave({ positionField, dream, query, scope,
4
4
  positionField: string;
5
5
  dream: Dream;
6
6
  query: Query<Dream>;
7
- scope?: string | string[];
7
+ scope: string | string[] | undefined;
8
8
  }): Promise<void>;
@@ -2,5 +2,5 @@ import { SerializableTypes } from '../../serializer/decorators/attribute.js';
2
2
  export default function Virtual(type?: SerializableTypes): any;
3
3
  export interface VirtualAttributeStatement {
4
4
  property: string;
5
- type?: SerializableTypes;
5
+ type: SerializableTypes | undefined;
6
6
  }
@@ -885,8 +885,8 @@ export default class Query<DreamInstance extends Dream, QueryTypeOpts extends Re
885
885
  * @returns The number of records that were removed
886
886
  */
887
887
  destroy({ skipHooks, cascade, }?: {
888
- skipHooks?: boolean;
889
- cascade?: boolean;
888
+ skipHooks?: boolean | undefined;
889
+ cascade?: boolean | undefined;
890
890
  }): Promise<number>;
891
891
  /**
892
892
  * Destroys all records matching the Query,
@@ -1073,29 +1073,29 @@ export default class Query<DreamInstance extends Dream, QueryTypeOpts extends Re
1073
1073
  private invertOrder;
1074
1074
  }
1075
1075
  export interface QueryOpts<DreamInstance extends Dream, ColumnType extends DreamColumnNames<DreamInstance> = DreamColumnNames<DreamInstance>, Schema extends DreamInstance['schema'] = DreamInstance['schema'], DB extends DreamInstance['DB'] = DreamInstance['DB'], PassthroughColumns extends PassthroughColumnNames<DreamInstance> = PassthroughColumnNames<DreamInstance>> {
1076
- baseSqlAlias?: TableOrAssociationName<Schema>;
1077
- baseSelectQuery?: Query<any, any> | null;
1078
- passthroughOnStatement?: PassthroughOnClause<PassthroughColumns> | null;
1079
- where?: readonly WhereStatement<DB, Schema, any>[] | null;
1080
- whereNot?: readonly WhereStatement<DB, Schema, any>[] | null;
1081
- limit?: LimitStatement | null;
1082
- offset?: OffsetStatement | null;
1083
- or?: WhereStatement<DB, Schema, any>[][] | null;
1084
- order?: OrderQueryStatement<ColumnType>[] | null;
1085
- loadFromJoins?: boolean;
1086
- preloadStatements?: RelaxedPreloadStatement;
1087
- preloadOnStatements?: RelaxedPreloadOnStatement<DB, Schema>;
1088
- distinctColumn?: ColumnType | null;
1089
- innerJoinDreamClasses?: readonly (typeof Dream)[];
1090
- innerJoinStatements?: RelaxedJoinStatement;
1091
- innerJoinOnStatements?: RelaxedJoinOnStatement<DB, Schema>;
1092
- leftJoinStatements?: RelaxedJoinStatement;
1093
- leftJoinOnStatements?: RelaxedJoinOnStatement<DB, Schema>;
1094
- bypassAllDefaultScopes?: boolean;
1095
- bypassAllDefaultScopesExceptOnAssociations?: boolean;
1096
- defaultScopesToBypass?: AllDefaultScopeNames<DreamInstance>[];
1097
- defaultScopesToBypassExceptOnAssociations?: DefaultScopeName<DreamInstance>[];
1076
+ baseSqlAlias?: TableOrAssociationName<Schema> | undefined;
1077
+ baseSelectQuery?: Query<any, any> | null | undefined;
1078
+ passthroughOnStatement?: PassthroughOnClause<PassthroughColumns> | null | undefined;
1079
+ where?: readonly WhereStatement<DB, Schema, any>[] | null | undefined;
1080
+ whereNot?: readonly WhereStatement<DB, Schema, any>[] | null | undefined;
1081
+ limit?: LimitStatement | null | undefined;
1082
+ offset?: OffsetStatement | null | undefined;
1083
+ or?: WhereStatement<DB, Schema, any>[][] | null | undefined;
1084
+ order?: OrderQueryStatement<ColumnType>[] | null | undefined;
1085
+ loadFromJoins?: boolean | undefined;
1086
+ preloadStatements?: RelaxedPreloadStatement | undefined;
1087
+ preloadOnStatements?: RelaxedPreloadOnStatement<DB, Schema> | undefined;
1088
+ distinctColumn?: ColumnType | null | undefined;
1089
+ innerJoinDreamClasses?: readonly (typeof Dream)[] | undefined;
1090
+ innerJoinStatements?: RelaxedJoinStatement | undefined;
1091
+ innerJoinOnStatements?: RelaxedJoinOnStatement<DB, Schema> | undefined;
1092
+ leftJoinStatements?: RelaxedJoinStatement | undefined;
1093
+ leftJoinOnStatements?: RelaxedJoinOnStatement<DB, Schema> | undefined;
1094
+ bypassAllDefaultScopes?: boolean | undefined;
1095
+ bypassAllDefaultScopesExceptOnAssociations?: boolean | undefined;
1096
+ defaultScopesToBypass?: AllDefaultScopeNames<DreamInstance>[] | undefined;
1097
+ defaultScopesToBypassExceptOnAssociations?: DefaultScopeName<DreamInstance>[] | undefined;
1098
1098
  transaction?: DreamTransaction<Dream> | null | undefined;
1099
- connection?: DbConnectionType;
1100
- shouldReallyDestroy?: boolean;
1099
+ connection?: DbConnectionType | undefined;
1100
+ shouldReallyDestroy?: boolean | undefined;
1101
1101
  }
@@ -8,21 +8,21 @@ export interface DestroyOptions<DreamInstance extends Dream> {
8
8
  * If true, bypasses all default scopes when destroying the instance.
9
9
  * Defaults to false.
10
10
  */
11
- bypassAllDefaultScopes?: boolean;
11
+ bypassAllDefaultScopes?: boolean | undefined;
12
12
  /**
13
13
  * An array of default scope names to bypass when destroying the instance.
14
14
  * Defaults to an empty array.
15
15
  */
16
- defaultScopesToBypass?: AllDefaultScopeNames<DreamInstance>[];
16
+ defaultScopesToBypass?: AllDefaultScopeNames<DreamInstance>[] | undefined;
17
17
  /**
18
18
  * If false, skips destroying associations marked `dependent: 'destroy'`. Defaults to true.
19
19
  */
20
- cascade?: boolean;
20
+ cascade?: boolean | undefined;
21
21
  /**
22
22
  * If true, skips applying model hooks during the destroy operation.
23
23
  * Defaults to false.
24
24
  */
25
- skipHooks?: boolean;
25
+ skipHooks?: boolean | undefined;
26
26
  }
27
27
  export declare function destroyOptions<DreamInstance extends Dream>(options: DestroyOptions<DreamInstance>): {
28
28
  reallyDestroy: boolean;
@@ -28,11 +28,11 @@ export default class SimilarityBuilder<DreamInstance extends Dream, DB extends D
28
28
  private rankSQLAlias;
29
29
  }
30
30
  export interface SimilarityBuilderOpts<DreamInstance extends Dream, DB extends DreamInstance['DB'] = DreamInstance['DB'], Schema extends DreamInstance['schema'] = DreamInstance['schema']> {
31
- where?: WhereStatement<DB, Schema, any>[];
32
- whereNot?: WhereStatement<DB, Schema, any>[];
33
- joinOnStatements?: RelaxedJoinOnStatement<DB, Schema>;
31
+ where?: WhereStatement<DB, Schema, any>[] | undefined;
32
+ whereNot?: WhereStatement<DB, Schema, any>[] | undefined;
33
+ joinOnStatements?: RelaxedJoinOnStatement<DB, Schema> | undefined;
34
34
  transaction?: DreamTransaction<Dream> | null | undefined;
35
- connection?: DbConnectionType;
35
+ connection?: DbConnectionType | undefined;
36
36
  }
37
37
  export declare const SIMILARITY_TYPES: readonly ["where", "on"];
38
38
  export type SimilarityStatementType = (typeof SIMILARITY_TYPES)[number];
@@ -103,7 +103,7 @@ export interface DreamDirectoryPaths {
103
103
  }
104
104
  export interface DreamDbCredentialOptions {
105
105
  primary: SingleDbCredential;
106
- replica?: SingleDbCredential;
106
+ replica?: SingleDbCredential | undefined;
107
107
  }
108
108
  export interface SingleDbCredential {
109
109
  user: string;
@@ -0,0 +1,4 @@
1
+ export default class UnexpectedUndefined extends Error {
2
+ constructor();
3
+ get message(): string;
4
+ }
@@ -0,0 +1,7 @@
1
+ import Dream from '../../Dream.js';
2
+ export default class AssociationDeclaredWithoutAssociatedDreamClass extends Error {
3
+ private dreamClass;
4
+ private associationName;
5
+ constructor(dreamClass: typeof Dream, associationName: string | number | symbol);
6
+ get message(): string;
7
+ }
@@ -3,6 +3,6 @@ import { HasOneStatement } from '../../types/associations/hasOne.js';
3
3
  export default class MissingRequiredAssociationOnClause extends Error {
4
4
  private association;
5
5
  private column;
6
- constructor(association: HasManyStatement<any, any, any, any> | HasOneStatement<any, any, any, any>, column: string);
6
+ constructor(association: HasManyStatement<any, any, any, any> | HasOneStatement<any, any, any, any>, column: string | undefined);
7
7
  get message(): string;
8
8
  }
@@ -4,5 +4,5 @@ export default function generateDream({ fullyQualifiedModelName, columnsWithType
4
4
  options: {
5
5
  serializer: boolean;
6
6
  };
7
- fullyQualifiedParentName?: string;
7
+ fullyQualifiedParentName?: string | undefined;
8
8
  }): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  export default function generateDreamContent({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, serializer, }: {
2
2
  fullyQualifiedModelName: string;
3
3
  columnsWithTypes: string[];
4
- fullyQualifiedParentName?: string;
4
+ fullyQualifiedParentName?: string | undefined;
5
5
  serializer: boolean;
6
6
  }): string;
@@ -1,6 +1,6 @@
1
1
  export default function generateMigration({ migrationName, columnsWithTypes, fullyQualifiedModelName, fullyQualifiedParentName, }: {
2
2
  migrationName: string;
3
3
  columnsWithTypes: string[];
4
- fullyQualifiedModelName?: string;
5
- fullyQualifiedParentName?: string;
4
+ fullyQualifiedModelName?: string | undefined;
5
+ fullyQualifiedParentName?: string | undefined;
6
6
  }): Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import { PrimaryKeyType } from '../../types/dream.js';
2
2
  export default function generateMigrationContent({ table, columnsWithTypes, primaryKeyType, createOrAlter, }?: {
3
- table?: string;
4
- columnsWithTypes?: string[];
5
- primaryKeyType?: PrimaryKeyType;
6
- createOrAlter?: 'create' | 'alter';
3
+ table?: string | undefined;
4
+ columnsWithTypes?: string[] | undefined;
5
+ primaryKeyType?: PrimaryKeyType | undefined;
6
+ createOrAlter?: 'create' | 'alter' | undefined;
7
7
  }): string;
@@ -1,5 +1,5 @@
1
1
  export default function generateSerializer({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, }: {
2
2
  fullyQualifiedModelName: string;
3
3
  columnsWithTypes: string[];
4
- fullyQualifiedParentName?: string;
4
+ fullyQualifiedParentName?: string | undefined;
5
5
  }): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  export default function generateSerializerContent({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, }: {
2
2
  fullyQualifiedModelName: string;
3
- columnsWithTypes?: string[];
4
- fullyQualifiedParentName?: string;
3
+ columnsWithTypes?: string[] | undefined;
4
+ fullyQualifiedParentName?: string | undefined;
5
5
  }): string;
@@ -33,12 +33,7 @@ import { HasOneStatement } from './hasOne.ts'
33
33
 
34
34
  export type MAX_JOINED_TABLES_DEPTH = 25
35
35
 
36
- export type AssociationMetadataMap = Record<
37
- string,
38
- | BelongsToStatement<any, any, any, any>
39
- | HasManyStatement<any, any, any, any>
40
- | HasOneStatement<any, any, any, any>
41
- >
36
+ export type AssociationMetadataMap = Record<string, AssociationStatement>
42
37
 
43
38
  export type AssociatedBelongsToModelType<
44
39
  I extends Dream,
@@ -6,9 +6,6 @@ import CalendarDate from '../helpers/CalendarDate.ts'
6
6
  import { DateTime } from '../helpers/DateTime.ts'
7
7
  import OpsStatement from '../ops/ops-statement.ts'
8
8
  import DreamSerializer from '../serializer/index.ts'
9
- import { BelongsToStatement } from './associations/belongsTo.ts'
10
- import { HasManyStatement } from './associations/hasMany.ts'
11
- import { HasOneStatement } from './associations/hasOne.ts'
12
9
  import { AssociatedModelParam, OnStatementForAssociation, WhereStatement } from './associations/shared.ts'
13
10
  import { AssociationTableNames } from './db.js'
14
11
  import { FindEachOpts } from './query.ts'
@@ -386,20 +383,12 @@ export type PreloadArgumentTypeAssociatedTableNames<
386
383
  // end:preload
387
384
 
388
385
  export type AssociationNameToDreamClassMap = Record<string, typeof Dream>
389
- export type AssociationNameToAssociationMap = Record<
390
- string,
391
- | BelongsToStatement<any, any, any, any>
392
- | HasOneStatement<any, any, any, any>
393
- | HasManyStatement<any, any, any, any>
394
- >
386
+ export type AssociationNameToAssociationMap = Record<string, AssociationMetadata>
395
387
  export type AssociationNameToAssociationDataAndDreamClassMap = Record<
396
388
  string,
397
389
  {
398
390
  dreamClass: typeof Dream
399
- association:
400
- | BelongsToStatement<any, any, any, any>
401
- | HasOneStatement<any, any, any, any>
402
- | HasManyStatement<any, any, any, any>
391
+ association: AssociationMetadata
403
392
  }
404
393
  >
405
394
 
@@ -22,8 +22,8 @@ export interface HookStatement {
22
22
  type: HookType
23
23
  className: string
24
24
  method: string
25
- ifChanging?: string[]
26
- ifChanged?: string[]
25
+ ifChanging?: string[] | undefined
26
+ ifChanged?: string[] | undefined
27
27
  }
28
28
 
29
29
  export interface BeforeHookOpts<T extends Dream | null = null> {
@@ -1,7 +1,7 @@
1
1
  export interface DreamCliLoggerLogOpts {
2
- logPrefix?: string
3
- logPrefixColor?: DreamCliForegroundColor
4
- logPrefixBgColor?: DreamCliBgColor
2
+ logPrefix?: string | undefined
3
+ logPrefixColor?: DreamCliForegroundColor | undefined
4
+ logPrefixBgColor?: DreamCliBgColor | undefined
5
5
  }
6
6
 
7
7
  export type DreamCliColor = DreamCliForegroundColor | DreamCliBgColor