@rvoh/dream 2.1.3 → 2.1.4-alpha.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 (206) hide show
  1. package/dist/cjs/src/cli/index.js +4 -0
  2. package/dist/cjs/src/dream/QueryDriver/Kysely.js +4 -6
  3. package/dist/cjs/src/dream/QueryDriver/helpers/kysely/foreignKeyTypeFromPrimaryKey.js +3 -0
  4. package/dist/cjs/src/dream/constants.js +1 -1
  5. package/dist/cjs/src/helpers/cli/generateFactoryContent.js +13 -3
  6. package/dist/cjs/src/helpers/cli/generateMigrationContent.js +17 -3
  7. package/dist/cjs/src/package-exports/system.js +1 -0
  8. package/dist/esm/src/cli/index.js +4 -0
  9. package/dist/esm/src/dream/QueryDriver/Kysely.js +4 -6
  10. package/dist/esm/src/dream/QueryDriver/helpers/kysely/foreignKeyTypeFromPrimaryKey.js +3 -0
  11. package/dist/esm/src/dream/constants.js +1 -1
  12. package/dist/esm/src/helpers/cli/generateFactoryContent.js +13 -3
  13. package/dist/esm/src/helpers/cli/generateMigrationContent.js +17 -3
  14. package/dist/esm/src/package-exports/system.js +1 -0
  15. package/dist/types/src/Dream.d.ts +14 -0
  16. package/dist/types/src/dream/QueryDriver/Base.d.ts +3 -3
  17. package/dist/types/src/dream/QueryDriver/Kysely.d.ts +4 -4
  18. package/dist/types/src/dream/QueryDriver/helpers/kysely/foreignKeyTypeFromPrimaryKey.d.ts +2 -2
  19. package/dist/types/src/dream/constants.d.ts +1 -1
  20. package/dist/types/src/dream-app/index.d.ts +4 -5
  21. package/dist/types/src/helpers/cli/generateMigrationContent.d.ts +1 -1
  22. package/dist/types/src/helpers/cli/generateStiMigrationContent.d.ts +1 -1
  23. package/dist/types/src/package-exports/system.d.ts +1 -0
  24. package/dist/types/src/package-exports/types.d.ts +1 -1
  25. package/dist/types/src/types/db.d.ts +2 -0
  26. package/dist/types/src/types/db.ts +2 -0
  27. package/dist/types/src/types/dream.d.ts +1 -2
  28. package/dist/types/src/types/dream.ts +1 -3
  29. package/docs/assets/navigation.js +1 -1
  30. package/docs/assets/search.js +1 -1
  31. package/docs/classes/db.DreamMigrationHelpers.html +9 -9
  32. package/docs/classes/db.KyselyQueryDriver.html +32 -32
  33. package/docs/classes/db.PostgresQueryDriver.html +33 -33
  34. package/docs/classes/db.QueryDriverBase.html +31 -31
  35. package/docs/classes/errors.CheckConstraintViolation.html +3 -3
  36. package/docs/classes/errors.ColumnOverflow.html +3 -3
  37. package/docs/classes/errors.CreateOrFindByFailedToCreateAndFind.html +3 -3
  38. package/docs/classes/errors.DataIncompatibleWithDatabaseField.html +3 -3
  39. package/docs/classes/errors.DataTypeColumnTypeMismatch.html +3 -3
  40. package/docs/classes/errors.GlobalNameNotSet.html +3 -3
  41. package/docs/classes/errors.InvalidCalendarDate.html +2 -2
  42. package/docs/classes/errors.MissingSerializersDefinition.html +3 -3
  43. package/docs/classes/errors.NonLoadedAssociation.html +3 -3
  44. package/docs/classes/errors.NotNullViolation.html +3 -3
  45. package/docs/classes/errors.RecordNotFound.html +3 -3
  46. package/docs/classes/errors.ValidationError.html +3 -3
  47. package/docs/classes/index.CalendarDate.html +2 -2
  48. package/docs/classes/index.Decorators.html +19 -19
  49. package/docs/classes/index.Dream.html +132 -122
  50. package/docs/classes/index.DreamApp.html +5 -5
  51. package/docs/classes/index.DreamTransaction.html +2 -2
  52. package/docs/classes/index.Env.html +2 -2
  53. package/docs/classes/index.Query.html +55 -55
  54. package/docs/classes/system.CliFileWriter.html +2 -2
  55. package/docs/classes/system.DreamBin.html +2 -2
  56. package/docs/classes/system.DreamCLI.html +5 -5
  57. package/docs/classes/system.DreamImporter.html +2 -2
  58. package/docs/classes/system.DreamLogos.html +2 -2
  59. package/docs/classes/system.DreamSerializerBuilder.html +8 -8
  60. package/docs/classes/system.ObjectSerializerBuilder.html +8 -8
  61. package/docs/classes/utils.Encrypt.html +2 -2
  62. package/docs/classes/utils.Range.html +2 -2
  63. package/docs/functions/db.closeAllDbConnections.html +1 -1
  64. package/docs/functions/db.dreamDbConnections.html +1 -1
  65. package/docs/functions/db.untypedDb.html +1 -1
  66. package/docs/functions/db.validateColumn.html +1 -1
  67. package/docs/functions/db.validateTable.html +1 -1
  68. package/docs/functions/errors.pgErrorType.html +1 -1
  69. package/docs/functions/index.DreamSerializer.html +1 -1
  70. package/docs/functions/index.ObjectSerializer.html +1 -1
  71. package/docs/functions/index.ReplicaSafe.html +1 -1
  72. package/docs/functions/index.STI.html +1 -1
  73. package/docs/functions/index.SoftDelete.html +1 -1
  74. package/docs/functions/utils.camelize.html +1 -1
  75. package/docs/functions/utils.capitalize.html +1 -1
  76. package/docs/functions/utils.cloneDeepSafe.html +1 -1
  77. package/docs/functions/utils.compact.html +1 -1
  78. package/docs/functions/utils.groupBy.html +1 -1
  79. package/docs/functions/utils.hyphenize.html +1 -1
  80. package/docs/functions/utils.intersection.html +1 -1
  81. package/docs/functions/utils.isEmpty.html +1 -1
  82. package/docs/functions/utils.normalizeUnicode.html +1 -1
  83. package/docs/functions/utils.pascalize.html +1 -1
  84. package/docs/functions/utils.percent.html +1 -1
  85. package/docs/functions/utils.range-1.html +1 -1
  86. package/docs/functions/utils.round.html +1 -1
  87. package/docs/functions/utils.sanitizeString.html +1 -1
  88. package/docs/functions/utils.snakeify.html +1 -1
  89. package/docs/functions/utils.sort.html +1 -1
  90. package/docs/functions/utils.sortBy.html +1 -1
  91. package/docs/functions/utils.sortObjectByKey.html +1 -1
  92. package/docs/functions/utils.sortObjectByValue.html +1 -1
  93. package/docs/functions/utils.uncapitalize.html +1 -1
  94. package/docs/functions/utils.uniq.html +1 -1
  95. package/docs/interfaces/openapi.OpenapiDescription.html +2 -2
  96. package/docs/interfaces/openapi.OpenapiSchemaProperties.html +1 -1
  97. package/docs/interfaces/openapi.OpenapiSchemaPropertiesShorthand.html +1 -1
  98. package/docs/interfaces/openapi.OpenapiTypeFieldObject.html +1 -1
  99. package/docs/interfaces/types.BelongsToStatement.html +2 -2
  100. package/docs/interfaces/types.DecoratorContext.html +2 -2
  101. package/docs/interfaces/types.DreamAppInitOptions.html +2 -2
  102. package/docs/interfaces/types.DreamAppOpts.html +2 -2
  103. package/docs/interfaces/types.EncryptOptions.html +2 -2
  104. package/docs/interfaces/types.InternalAnyTypedSerializerRendersMany.html +2 -2
  105. package/docs/interfaces/types.InternalAnyTypedSerializerRendersOne.html +2 -2
  106. package/docs/interfaces/types.SerializerRendererOpts.html +2 -2
  107. package/docs/modules/db.html +1 -1
  108. package/docs/modules/errors.html +1 -1
  109. package/docs/modules/index.html +1 -1
  110. package/docs/modules/openapi.html +1 -1
  111. package/docs/modules/system.html +2 -1
  112. package/docs/modules/types.html +4 -3
  113. package/docs/modules/utils.html +1 -1
  114. package/docs/types/index.DateTime.html +1 -1
  115. package/docs/types/openapi.CommonOpenapiSchemaObjectFields.html +1 -1
  116. package/docs/types/openapi.OpenapiAllTypes.html +1 -1
  117. package/docs/types/openapi.OpenapiFormats.html +1 -1
  118. package/docs/types/openapi.OpenapiNumberFormats.html +1 -1
  119. package/docs/types/openapi.OpenapiPrimitiveBaseTypes.html +1 -1
  120. package/docs/types/openapi.OpenapiPrimitiveTypes.html +1 -1
  121. package/docs/types/openapi.OpenapiSchemaArray.html +1 -1
  122. package/docs/types/openapi.OpenapiSchemaArrayShorthand.html +1 -1
  123. package/docs/types/openapi.OpenapiSchemaBase.html +1 -1
  124. package/docs/types/openapi.OpenapiSchemaBody.html +1 -1
  125. package/docs/types/openapi.OpenapiSchemaBodyShorthand.html +1 -1
  126. package/docs/types/openapi.OpenapiSchemaCommonFields.html +1 -1
  127. package/docs/types/openapi.OpenapiSchemaExpressionAllOf.html +1 -1
  128. package/docs/types/openapi.OpenapiSchemaExpressionAnyOf.html +1 -1
  129. package/docs/types/openapi.OpenapiSchemaExpressionOneOf.html +1 -1
  130. package/docs/types/openapi.OpenapiSchemaExpressionRef.html +1 -1
  131. package/docs/types/openapi.OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
  132. package/docs/types/openapi.OpenapiSchemaInteger.html +1 -1
  133. package/docs/types/openapi.OpenapiSchemaNull.html +1 -1
  134. package/docs/types/openapi.OpenapiSchemaNumber.html +1 -1
  135. package/docs/types/openapi.OpenapiSchemaObject.html +1 -1
  136. package/docs/types/openapi.OpenapiSchemaObjectAllOf.html +1 -1
  137. package/docs/types/openapi.OpenapiSchemaObjectAllOfShorthand.html +1 -1
  138. package/docs/types/openapi.OpenapiSchemaObjectAnyOf.html +1 -1
  139. package/docs/types/openapi.OpenapiSchemaObjectAnyOfShorthand.html +1 -1
  140. package/docs/types/openapi.OpenapiSchemaObjectBase.html +1 -1
  141. package/docs/types/openapi.OpenapiSchemaObjectBaseShorthand.html +1 -1
  142. package/docs/types/openapi.OpenapiSchemaObjectOneOf.html +1 -1
  143. package/docs/types/openapi.OpenapiSchemaObjectOneOfShorthand.html +1 -1
  144. package/docs/types/openapi.OpenapiSchemaObjectShorthand.html +1 -1
  145. package/docs/types/openapi.OpenapiSchemaPrimitiveGeneric.html +1 -1
  146. package/docs/types/openapi.OpenapiSchemaShorthandExpressionAllOf.html +1 -1
  147. package/docs/types/openapi.OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
  148. package/docs/types/openapi.OpenapiSchemaShorthandExpressionOneOf.html +1 -1
  149. package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
  150. package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
  151. package/docs/types/openapi.OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
  152. package/docs/types/openapi.OpenapiSchemaString.html +1 -1
  153. package/docs/types/openapi.OpenapiShorthandAllTypes.html +1 -1
  154. package/docs/types/openapi.OpenapiShorthandPrimitiveBaseTypes.html +1 -1
  155. package/docs/types/openapi.OpenapiShorthandPrimitiveTypes.html +1 -1
  156. package/docs/types/openapi.OpenapiTypeField.html +1 -1
  157. package/docs/types/system.DreamAppAllowedPackageManagersEnum.html +1 -1
  158. package/docs/types/types.Camelized.html +1 -1
  159. package/docs/types/types.DbConnectionType.html +1 -1
  160. package/docs/types/types.DbTypes.html +1 -1
  161. package/docs/types/types.DreamAssociationMetadata.html +1 -1
  162. package/docs/types/types.DreamAttributes.html +1 -1
  163. package/docs/types/types.DreamClassAssociationAndStatement.html +1 -1
  164. package/docs/types/types.DreamClassColumn.html +1 -1
  165. package/docs/types/types.DreamColumn.html +1 -1
  166. package/docs/types/types.DreamColumnNames.html +1 -1
  167. package/docs/types/types.DreamLogLevel.html +1 -1
  168. package/docs/types/types.DreamLogger.html +1 -1
  169. package/docs/types/types.DreamModelSerializerType.html +1 -1
  170. package/docs/types/types.DreamOrViewModelClassSerializerKey.html +1 -1
  171. package/docs/types/types.DreamOrViewModelSerializerKey.html +1 -1
  172. package/docs/types/types.DreamParamSafeAttributes.html +1 -1
  173. package/docs/types/types.DreamParamSafeColumnNames.html +1 -1
  174. package/docs/types/types.DreamSerializable.html +1 -1
  175. package/docs/types/types.DreamSerializableArray.html +1 -1
  176. package/docs/types/types.DreamSerializerKey.html +1 -1
  177. package/docs/types/types.DreamSerializers.html +1 -1
  178. package/docs/types/types.DreamVirtualColumns.html +1 -1
  179. package/docs/types/types.EncryptAlgorithm.html +1 -1
  180. package/docs/types/types.HasManyStatement.html +1 -1
  181. package/docs/types/types.HasOneStatement.html +1 -1
  182. package/docs/types/types.Hyphenized.html +1 -1
  183. package/docs/types/types.Pascalized.html +1 -1
  184. package/docs/types/types.PrimaryKeyType.html +1 -0
  185. package/docs/types/types.RoundingPrecision.html +1 -1
  186. package/docs/types/types.SerializerCasing.html +1 -1
  187. package/docs/types/types.SimpleObjectSerializerType.html +1 -1
  188. package/docs/types/types.Snakeified.html +1 -1
  189. package/docs/types/types.StrictInterface.html +1 -1
  190. package/docs/types/types.UpdateableAssociationProperties.html +1 -1
  191. package/docs/types/types.UpdateableProperties.html +1 -1
  192. package/docs/types/types.ValidationType.html +1 -1
  193. package/docs/types/types.ViewModel.html +1 -1
  194. package/docs/types/types.ViewModelClass.html +1 -1
  195. package/docs/types/types.WhereStatementForDream.html +1 -1
  196. package/docs/types/types.WhereStatementForDreamClass.html +1 -1
  197. package/docs/variables/index.DateTime-1.html +1 -1
  198. package/docs/variables/index.DreamConst.html +1 -1
  199. package/docs/variables/index.ops.html +1 -1
  200. package/docs/variables/openapi.openapiPrimitiveTypes-1.html +1 -1
  201. package/docs/variables/openapi.openapiShorthandPrimitiveTypes-1.html +1 -1
  202. package/docs/variables/system.DreamAppAllowedPackageManagersEnumValues.html +1 -1
  203. package/docs/variables/system.primaryKeyTypes.html +1 -0
  204. package/docs/variables/types.TRIGRAM_OPERATORS.html +1 -1
  205. package/package.json +1 -1
  206. package/docs/variables/types.primaryKeyTypes.html +0 -1
@@ -14,6 +14,10 @@ ${INDENT}all properties default to not nullable; null can be allowed by appendin
14
14
  ${INDENT} subtitle:string:optional
15
15
  ${INDENT}
16
16
  ${INDENT}supported types:
17
+ ${INDENT} - uuid:
18
+ ${INDENT} - uuid[]:
19
+ ${INDENT} a column optimized for storing UUIDs
20
+ ${INDENT}
17
21
  ${INDENT} - citext:
18
22
  ${INDENT} - citext[]:
19
23
  ${INDENT} case insensitive text (indexes and queries are automatically case insensitive)
@@ -67,6 +67,7 @@ import sqlResultToDreamInstance from '../internal/sqlResultToDreamInstance.js';
67
67
  import Query from '../Query.js';
68
68
  import QueryDriverBase from './Base.js';
69
69
  import checkForNeedToBeRunMigrations from './helpers/kysely/checkForNeedToBeRunMigrations.js';
70
+ import foreignKeyTypeFromPrimaryKey from './helpers/kysely/foreignKeyTypeFromPrimaryKey.js';
70
71
  import runMigration from './helpers/kysely/runMigration.js';
71
72
  export default class KyselyQueryDriver extends QueryDriverBase {
72
73
  // ATTENTION FRED
@@ -211,12 +212,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
211
212
  * gives the driver the opportunity to switch i.e. bigserial to bigint.
212
213
  */
213
214
  static foreignKeyTypeFromPrimaryKey(primaryKey) {
214
- switch (primaryKey) {
215
- case 'bigserial':
216
- return 'bigint';
217
- default:
218
- return primaryKey;
219
- }
215
+ return foreignKeyTypeFromPrimaryKey(primaryKey);
220
216
  }
221
217
  /**
222
218
  * @internal
@@ -229,6 +225,8 @@ export default class KyselyQueryDriver extends QueryDriverBase {
229
225
  switch (dreamconf.primaryKeyType) {
230
226
  case 'bigint':
231
227
  case 'bigserial':
228
+ case 'uuid7':
229
+ case 'uuid4':
232
230
  case 'uuid':
233
231
  case 'integer':
234
232
  return dreamconf.primaryKeyType;
@@ -1,5 +1,8 @@
1
1
  export default function foreignKeyTypeFromPrimaryKey(primaryKey) {
2
2
  switch (primaryKey) {
3
+ case 'uuid7':
4
+ case 'uuid4':
5
+ return 'uuid';
3
6
  case 'bigserial':
4
7
  return 'bigint';
5
8
  default:
@@ -1,4 +1,4 @@
1
- export const primaryKeyTypes = ['bigserial', 'bigint', 'uuid', 'integer'];
1
+ export const primaryKeyTypes = ['uuid7', 'uuid4', 'bigserial', 'bigint', 'integer'];
2
2
  export const TRIGRAM_OPERATORS = ['%', '<%', '<<%'];
3
3
  class RequiredAttribute {
4
4
  constructor() { }
@@ -9,16 +9,17 @@ export default function generateFactoryContent({ fullyQualifiedModelName, column
9
9
  const dreamTypeImports = ['UpdateableProperties'];
10
10
  const dreamImports = [];
11
11
  const additionalImports = [];
12
+ const nodeImports = [];
12
13
  const belongsToNames = [];
13
14
  const belongsToTypedNames = [];
14
15
  const associationCreationStatements = [];
15
16
  const attributeDefaults = [];
16
17
  let counterVariableIncremented = false;
17
18
  for (const attribute of columnsWithTypes) {
18
- const [attributeName, attributeType, ...descriptors] = attribute.split(':');
19
+ const [attributeName, _attributeType, ...descriptors] = attribute.split(':');
19
20
  if (attributeName === undefined)
20
21
  continue;
21
- if (attributeType === undefined)
22
+ if (_attributeType === undefined)
22
23
  continue;
23
24
  const optional = optionalFromDescriptors(descriptors);
24
25
  if (optional)
@@ -28,6 +29,7 @@ export default function generateFactoryContent({ fullyQualifiedModelName, column
28
29
  continue;
29
30
  if (/(_type|_id)$/.test(attributeName))
30
31
  continue;
32
+ const attributeType = /uuid$/.test(attributeName) ? 'uuid' : _attributeType;
31
33
  if (!attributeType)
32
34
  throw new Error(`Must pass a column type for ${attributeName} (i.e. ${attributeName}:string)`);
33
35
  const safeAttributeType = camelize(attributeType)?.toLowerCase();
@@ -95,6 +97,14 @@ export default function generateFactoryContent({ fullyQualifiedModelName, column
95
97
  dreamImports.push('DateTime');
96
98
  attributeDefaults.push(`${attributeVariable}: [DateTime.now()],`);
97
99
  break;
100
+ case 'uuid':
101
+ nodeImports.push('randomUUID');
102
+ attributeDefaults.push(`${attributeVariable}: randomUUID(),`);
103
+ break;
104
+ case 'uuid[]':
105
+ nodeImports.push('randomUUID');
106
+ attributeDefaults.push(`${attributeVariable}: [randomUUID()],`);
107
+ break;
98
108
  default:
99
109
  if (/\[\]$/.test(attributeType)) {
100
110
  attributeDefaults.push(`${attributeVariable}: [],`);
@@ -105,7 +115,7 @@ export default function generateFactoryContent({ fullyQualifiedModelName, column
105
115
  const relativePath = absoluteDreamPath('models', fullyQualifiedModelName);
106
116
  const modelClassName = globalClassNameFromFullyQualifiedModelName(fullyQualifiedModelName);
107
117
  return `\
108
- ${dreamImports.length ? `import { ${uniq(dreamImports).join(', ')} } from '@rvoh/dream'\n` : ''}import { ${uniq(dreamTypeImports).join(', ')} } from '@rvoh/dream/types'
118
+ ${nodeImports.length ? `import { ${uniq(nodeImports).join(', ')} } from 'node:crypto'\n` : ''}${dreamImports.length ? `import { ${uniq(dreamImports).join(', ')} } from '@rvoh/dream'\n` : ''}import { ${uniq(dreamTypeImports).join(', ')} } from '@rvoh/dream/types'
109
119
  import ${modelClassName} from '${relativePath}'${additionalImports.length ? '\n' + uniq(additionalImports).join('\n') : ''}
110
120
  ${counterVariableIncremented ? '\nlet counter = 0\n' : ''}
111
121
  export default async function create${modelClassName}(attrs: UpdateableProperties<${modelClassName}> = {}) {
@@ -1,9 +1,9 @@
1
1
  import pluralize from 'pluralize-esm';
2
2
  import Query from '../../dream/Query.js';
3
3
  import InvalidDecimalFieldPassedToGenerator from '../../errors/InvalidDecimalFieldPassedToGenerator.js';
4
+ import camelize from '../camelize.js';
4
5
  import compact from '../compact.js';
5
6
  import snakeify from '../snakeify.js';
6
- import camelize from '../camelize.js';
7
7
  const STI_TYPE_COLUMN_NAME = 'type';
8
8
  const COLUMNS_TO_INDEX = [STI_TYPE_COLUMN_NAME];
9
9
  export default function generateMigrationContent({ connectionName = 'default', table, columnsWithTypes = [], primaryKeyType = 'bigserial', createOrAlter = 'create', stiChildClassName, } = {}) {
@@ -13,11 +13,17 @@ export default function generateMigrationContent({ connectionName = 'default', t
13
13
  const { columnDefs, columnDrops, indexDefs, indexDrops } = columnsWithTypes.reduce((acc, attributeDeclaration) => {
14
14
  const { columnDefs, columnDrops, indexDefs, indexDrops } = acc;
15
15
  const [nonStandardAttributeName, _attributeType, ...descriptors] = attributeDeclaration.split(':');
16
+ if (!nonStandardAttributeName)
17
+ return acc;
16
18
  /**
17
19
  * Automatically set email columns to citext since different casings of
18
20
  * email address are the same email address
19
21
  */
20
- const attributeType = nonStandardAttributeName === 'email' ? 'citext' : _attributeType;
22
+ const attributeType = /email$/.test(nonStandardAttributeName)
23
+ ? 'citext'
24
+ : /uuid$/.test(nonStandardAttributeName)
25
+ ? 'uuid'
26
+ : _attributeType;
21
27
  const processedAttrType = camelize(attributeType)?.toLowerCase();
22
28
  const userWantsThisOptional = optionalFromDescriptors(descriptors);
23
29
  // when creating a migration for an STI child, we don't want to include notNull;
@@ -232,7 +238,7 @@ function generateColumnStr(attributeName, attributeType, descriptors, { omitInli
232
238
  const providedDefaultArg = descriptors.find(d => /^default\(/.test(d));
233
239
  const providedDefault = providedDefaultArg?.replace(/^default\(/, '')?.replace(/\)$/, '');
234
240
  const notNull = !optional;
235
- const isUnique = attributeName === 'email' || /token$/.test(attributeName);
241
+ const isUnique = /(email|token|uuid)$/.test(attributeName);
236
242
  const hasExtraValues = providedDefault || notNull || isUnique;
237
243
  const isArray = /\[\]$/.test(attributeType);
238
244
  if (hasExtraValues)
@@ -281,6 +287,14 @@ function generateBelongsToStr(connectionName, associationName, { primaryKeyType,
281
287
  }
282
288
  function generateIdStr({ primaryKeyType }) {
283
289
  switch (primaryKeyType) {
290
+ case 'uuid7':
291
+ return `\
292
+ .addColumn('id', 'uuid', col =>
293
+ col
294
+ .primaryKey()
295
+ .defaultTo(sql\`uuid_generate_v7()\`),
296
+ )`;
297
+ case 'uuid4':
284
298
  case 'uuid':
285
299
  return `\
286
300
  .addColumn('id', 'uuid', col =>
@@ -3,6 +3,7 @@ export { CliFileWriter } from '../cli/CliFileWriter.js';
3
3
  export { default as DreamCLI } from '../cli/index.js';
4
4
  export { default as DreamImporter } from '../dream-app/helpers/DreamImporter.js';
5
5
  export { DreamAppAllowedPackageManagersEnumValues, } from '../dream-app/index.js';
6
+ export { primaryKeyTypes } from '../dream/constants.js';
6
7
  export { default as DreamLogos } from '../helpers/DreamLogos/DreamLogos.js';
7
8
  export { default as DreamSerializerBuilder } from '../serializer/builders/DreamSerializerBuilder.js';
8
9
  export { default as ObjectSerializerBuilder } from '../serializer/builders/ObjectSerializerBuilder.js';
@@ -14,6 +14,10 @@ ${INDENT}all properties default to not nullable; null can be allowed by appendin
14
14
  ${INDENT} subtitle:string:optional
15
15
  ${INDENT}
16
16
  ${INDENT}supported types:
17
+ ${INDENT} - uuid:
18
+ ${INDENT} - uuid[]:
19
+ ${INDENT} a column optimized for storing UUIDs
20
+ ${INDENT}
17
21
  ${INDENT} - citext:
18
22
  ${INDENT} - citext[]:
19
23
  ${INDENT} case insensitive text (indexes and queries are automatically case insensitive)
@@ -67,6 +67,7 @@ import sqlResultToDreamInstance from '../internal/sqlResultToDreamInstance.js';
67
67
  import Query from '../Query.js';
68
68
  import QueryDriverBase from './Base.js';
69
69
  import checkForNeedToBeRunMigrations from './helpers/kysely/checkForNeedToBeRunMigrations.js';
70
+ import foreignKeyTypeFromPrimaryKey from './helpers/kysely/foreignKeyTypeFromPrimaryKey.js';
70
71
  import runMigration from './helpers/kysely/runMigration.js';
71
72
  export default class KyselyQueryDriver extends QueryDriverBase {
72
73
  // ATTENTION FRED
@@ -211,12 +212,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
211
212
  * gives the driver the opportunity to switch i.e. bigserial to bigint.
212
213
  */
213
214
  static foreignKeyTypeFromPrimaryKey(primaryKey) {
214
- switch (primaryKey) {
215
- case 'bigserial':
216
- return 'bigint';
217
- default:
218
- return primaryKey;
219
- }
215
+ return foreignKeyTypeFromPrimaryKey(primaryKey);
220
216
  }
221
217
  /**
222
218
  * @internal
@@ -229,6 +225,8 @@ export default class KyselyQueryDriver extends QueryDriverBase {
229
225
  switch (dreamconf.primaryKeyType) {
230
226
  case 'bigint':
231
227
  case 'bigserial':
228
+ case 'uuid7':
229
+ case 'uuid4':
232
230
  case 'uuid':
233
231
  case 'integer':
234
232
  return dreamconf.primaryKeyType;
@@ -1,5 +1,8 @@
1
1
  export default function foreignKeyTypeFromPrimaryKey(primaryKey) {
2
2
  switch (primaryKey) {
3
+ case 'uuid7':
4
+ case 'uuid4':
5
+ return 'uuid';
3
6
  case 'bigserial':
4
7
  return 'bigint';
5
8
  default:
@@ -1,4 +1,4 @@
1
- export const primaryKeyTypes = ['bigserial', 'bigint', 'uuid', 'integer'];
1
+ export const primaryKeyTypes = ['uuid7', 'uuid4', 'bigserial', 'bigint', 'integer'];
2
2
  export const TRIGRAM_OPERATORS = ['%', '<%', '<<%'];
3
3
  class RequiredAttribute {
4
4
  constructor() { }
@@ -9,16 +9,17 @@ export default function generateFactoryContent({ fullyQualifiedModelName, column
9
9
  const dreamTypeImports = ['UpdateableProperties'];
10
10
  const dreamImports = [];
11
11
  const additionalImports = [];
12
+ const nodeImports = [];
12
13
  const belongsToNames = [];
13
14
  const belongsToTypedNames = [];
14
15
  const associationCreationStatements = [];
15
16
  const attributeDefaults = [];
16
17
  let counterVariableIncremented = false;
17
18
  for (const attribute of columnsWithTypes) {
18
- const [attributeName, attributeType, ...descriptors] = attribute.split(':');
19
+ const [attributeName, _attributeType, ...descriptors] = attribute.split(':');
19
20
  if (attributeName === undefined)
20
21
  continue;
21
- if (attributeType === undefined)
22
+ if (_attributeType === undefined)
22
23
  continue;
23
24
  const optional = optionalFromDescriptors(descriptors);
24
25
  if (optional)
@@ -28,6 +29,7 @@ export default function generateFactoryContent({ fullyQualifiedModelName, column
28
29
  continue;
29
30
  if (/(_type|_id)$/.test(attributeName))
30
31
  continue;
32
+ const attributeType = /uuid$/.test(attributeName) ? 'uuid' : _attributeType;
31
33
  if (!attributeType)
32
34
  throw new Error(`Must pass a column type for ${attributeName} (i.e. ${attributeName}:string)`);
33
35
  const safeAttributeType = camelize(attributeType)?.toLowerCase();
@@ -95,6 +97,14 @@ export default function generateFactoryContent({ fullyQualifiedModelName, column
95
97
  dreamImports.push('DateTime');
96
98
  attributeDefaults.push(`${attributeVariable}: [DateTime.now()],`);
97
99
  break;
100
+ case 'uuid':
101
+ nodeImports.push('randomUUID');
102
+ attributeDefaults.push(`${attributeVariable}: randomUUID(),`);
103
+ break;
104
+ case 'uuid[]':
105
+ nodeImports.push('randomUUID');
106
+ attributeDefaults.push(`${attributeVariable}: [randomUUID()],`);
107
+ break;
98
108
  default:
99
109
  if (/\[\]$/.test(attributeType)) {
100
110
  attributeDefaults.push(`${attributeVariable}: [],`);
@@ -105,7 +115,7 @@ export default function generateFactoryContent({ fullyQualifiedModelName, column
105
115
  const relativePath = absoluteDreamPath('models', fullyQualifiedModelName);
106
116
  const modelClassName = globalClassNameFromFullyQualifiedModelName(fullyQualifiedModelName);
107
117
  return `\
108
- ${dreamImports.length ? `import { ${uniq(dreamImports).join(', ')} } from '@rvoh/dream'\n` : ''}import { ${uniq(dreamTypeImports).join(', ')} } from '@rvoh/dream/types'
118
+ ${nodeImports.length ? `import { ${uniq(nodeImports).join(', ')} } from 'node:crypto'\n` : ''}${dreamImports.length ? `import { ${uniq(dreamImports).join(', ')} } from '@rvoh/dream'\n` : ''}import { ${uniq(dreamTypeImports).join(', ')} } from '@rvoh/dream/types'
109
119
  import ${modelClassName} from '${relativePath}'${additionalImports.length ? '\n' + uniq(additionalImports).join('\n') : ''}
110
120
  ${counterVariableIncremented ? '\nlet counter = 0\n' : ''}
111
121
  export default async function create${modelClassName}(attrs: UpdateableProperties<${modelClassName}> = {}) {
@@ -1,9 +1,9 @@
1
1
  import pluralize from 'pluralize-esm';
2
2
  import Query from '../../dream/Query.js';
3
3
  import InvalidDecimalFieldPassedToGenerator from '../../errors/InvalidDecimalFieldPassedToGenerator.js';
4
+ import camelize from '../camelize.js';
4
5
  import compact from '../compact.js';
5
6
  import snakeify from '../snakeify.js';
6
- import camelize from '../camelize.js';
7
7
  const STI_TYPE_COLUMN_NAME = 'type';
8
8
  const COLUMNS_TO_INDEX = [STI_TYPE_COLUMN_NAME];
9
9
  export default function generateMigrationContent({ connectionName = 'default', table, columnsWithTypes = [], primaryKeyType = 'bigserial', createOrAlter = 'create', stiChildClassName, } = {}) {
@@ -13,11 +13,17 @@ export default function generateMigrationContent({ connectionName = 'default', t
13
13
  const { columnDefs, columnDrops, indexDefs, indexDrops } = columnsWithTypes.reduce((acc, attributeDeclaration) => {
14
14
  const { columnDefs, columnDrops, indexDefs, indexDrops } = acc;
15
15
  const [nonStandardAttributeName, _attributeType, ...descriptors] = attributeDeclaration.split(':');
16
+ if (!nonStandardAttributeName)
17
+ return acc;
16
18
  /**
17
19
  * Automatically set email columns to citext since different casings of
18
20
  * email address are the same email address
19
21
  */
20
- const attributeType = nonStandardAttributeName === 'email' ? 'citext' : _attributeType;
22
+ const attributeType = /email$/.test(nonStandardAttributeName)
23
+ ? 'citext'
24
+ : /uuid$/.test(nonStandardAttributeName)
25
+ ? 'uuid'
26
+ : _attributeType;
21
27
  const processedAttrType = camelize(attributeType)?.toLowerCase();
22
28
  const userWantsThisOptional = optionalFromDescriptors(descriptors);
23
29
  // when creating a migration for an STI child, we don't want to include notNull;
@@ -232,7 +238,7 @@ function generateColumnStr(attributeName, attributeType, descriptors, { omitInli
232
238
  const providedDefaultArg = descriptors.find(d => /^default\(/.test(d));
233
239
  const providedDefault = providedDefaultArg?.replace(/^default\(/, '')?.replace(/\)$/, '');
234
240
  const notNull = !optional;
235
- const isUnique = attributeName === 'email' || /token$/.test(attributeName);
241
+ const isUnique = /(email|token|uuid)$/.test(attributeName);
236
242
  const hasExtraValues = providedDefault || notNull || isUnique;
237
243
  const isArray = /\[\]$/.test(attributeType);
238
244
  if (hasExtraValues)
@@ -281,6 +287,14 @@ function generateBelongsToStr(connectionName, associationName, { primaryKeyType,
281
287
  }
282
288
  function generateIdStr({ primaryKeyType }) {
283
289
  switch (primaryKeyType) {
290
+ case 'uuid7':
291
+ return `\
292
+ .addColumn('id', 'uuid', col =>
293
+ col
294
+ .primaryKey()
295
+ .defaultTo(sql\`uuid_generate_v7()\`),
296
+ )`;
297
+ case 'uuid4':
284
298
  case 'uuid':
285
299
  return `\
286
300
  .addColumn('id', 'uuid', col =>
@@ -3,6 +3,7 @@ export { CliFileWriter } from '../cli/CliFileWriter.js';
3
3
  export { default as DreamCLI } from '../cli/index.js';
4
4
  export { default as DreamImporter } from '../dream-app/helpers/DreamImporter.js';
5
5
  export { DreamAppAllowedPackageManagersEnumValues, } from '../dream-app/index.js';
6
+ export { primaryKeyTypes } from '../dream/constants.js';
6
7
  export { default as DreamLogos } from '../helpers/DreamLogos/DreamLogos.js';
7
8
  export { default as DreamSerializerBuilder } from '../serializer/builders/DreamSerializerBuilder.js';
8
9
  export { default as ObjectSerializerBuilder } from '../serializer/builders/ObjectSerializerBuilder.js';
@@ -2377,6 +2377,13 @@ export default class Dream {
2377
2377
  * For HasMany associations, returns an array (empty if no records). For BelongsTo/HasOne
2378
2378
  * associations, returns the associated model or null if not found.
2379
2379
  *
2380
+ * @remarks
2381
+ * **Warning:** Using `association` in loops or when processing multiple records can lead to the
2382
+ * [N+1 query problem](https://guides.rubyonrails.org/active_record_querying.html#eager-loading-associations).
2383
+ * Each call to `association` on an unloaded association will trigger a separate database query.
2384
+ * To avoid this, use {@link Dream.load | `load`} or {@link Dream.preload | `preload`} to eager load
2385
+ * associations before accessing them.
2386
+ *
2380
2387
  * ```ts
2381
2388
  * // Basic association loading
2382
2389
  * const user = await post.association('user')
@@ -2429,6 +2436,13 @@ export default class Dream {
2429
2436
  * For HasMany associations, returns an array (empty if no records). For BelongsTo/HasOne
2430
2437
  * associations, returns the associated model or throws RecordNotFound if not found.
2431
2438
  *
2439
+ * @remarks
2440
+ * **Warning:** Using `associationOrFail` in loops or when processing multiple records can lead to the
2441
+ * [N+1 query problem](https://guides.rubyonrails.org/active_record_querying.html#eager-loading-associations).
2442
+ * Each call to `associationOrFail` on an unloaded association will trigger a separate database query.
2443
+ * To avoid this, use {@link Dream.load | `load`} or {@link Dream.preload | `preload`} to eager load
2444
+ * associations before accessing them.
2445
+ *
2432
2446
  * ```ts
2433
2447
  * // Basic association loading - throws RecordNotFound if user doesn't exist
2434
2448
  * const user = await post.associationOrFail('user')
@@ -1,12 +1,12 @@
1
1
  import { CompiledQuery, DeleteQueryBuilder, SelectQueryBuilder, UpdateQueryBuilder } from 'kysely';
2
2
  import Dream from '../../Dream.js';
3
+ import { SchemaBuilderAssociationData, SchemaBuilderColumnData } from '../../helpers/cli/ASTBuilder.js';
3
4
  import { AssociationStatement } from '../../types/associations/shared.js';
4
- import { DbConnectionType } from '../../types/db.js';
5
- import { DreamColumnNames, DreamConstructorType, DreamTableSchema, PrimaryKeyType } from '../../types/dream.js';
5
+ import { DbConnectionType, PrimaryKeyType } from '../../types/db.js';
6
+ import { DreamColumnNames, DreamConstructorType, DreamTableSchema } from '../../types/dream.js';
6
7
  import { PreloadedDreamsAndWhatTheyPointTo, QueryToKyselyDBType, QueryToKyselyTableNamesType } from '../../types/query.js';
7
8
  import DreamTransaction from '../DreamTransaction.js';
8
9
  import Query from '../Query.js';
9
- import { SchemaBuilderAssociationData, SchemaBuilderColumnData } from '../../helpers/cli/ASTBuilder.js';
10
10
  export default class QueryDriverBase<DreamInstance extends Dream> {
11
11
  query: Query<DreamInstance, any>;
12
12
  protected readonly dreamClass: DreamConstructorType<DreamInstance>;
@@ -3,8 +3,8 @@ import { DialectProviderCb } from '../../db/DreamDbConnection.js';
3
3
  import Dream from '../../Dream.js';
4
4
  import { SchemaBuilderInformationSchemaRow } from '../../helpers/cli/ASTBuilder.js';
5
5
  import { AssociationStatement } from '../../types/associations/shared.js';
6
- import { DbConnectionType } from '../../types/db.js';
7
- import { DreamColumnNames, DreamTableSchema, OrderDir, PrimaryKeyType, SqlCommandType } from '../../types/dream.js';
6
+ import { DbConnectionType, PrimaryKeyType } from '../../types/db.js';
7
+ import { DreamColumnNames, DreamTableSchema, OrderDir, SqlCommandType } from '../../types/dream.js';
8
8
  import { PreloadedDreamsAndWhatTheyPointTo, QueryToKyselyDBType, QueryToKyselyTableNamesType } from '../../types/query.js';
9
9
  import DreamTransaction from '../DreamTransaction.js';
10
10
  import Query from '../Query.js';
@@ -48,14 +48,14 @@ export default class KyselyQueryDriver<DreamInstance extends Dream> extends Quer
48
48
  * returns the foreign key type based on the primary key received.
49
49
  * gives the driver the opportunity to switch i.e. bigserial to bigint.
50
50
  */
51
- static foreignKeyTypeFromPrimaryKey(primaryKey: PrimaryKeyType): "bigint" | "uuid" | "integer";
51
+ static foreignKeyTypeFromPrimaryKey(primaryKey: PrimaryKeyType): "bigint" | "integer" | "uuid";
52
52
  /**
53
53
  * @internal
54
54
  *
55
55
  * used to return the computed primary key type based
56
56
  * on the primaryKeyType set in the DreamApp class.
57
57
  */
58
- static primaryKeyType(): "bigint" | "bigserial" | "uuid" | "integer";
58
+ static primaryKeyType(): PrimaryKeyType;
59
59
  /**
60
60
  * destroys a dream, possibly implementing soft delete if reallyDestroy is false
61
61
  * and the record being deleted implements soft delete.
@@ -1,2 +1,2 @@
1
- import { PrimaryKeyType } from '../../../../types/dream.js';
2
- export default function foreignKeyTypeFromPrimaryKey(primaryKey: PrimaryKeyType): "bigint" | "uuid" | "integer";
1
+ import { PrimaryKeyType } from '../../../../types/db.js';
2
+ export default function foreignKeyTypeFromPrimaryKey(primaryKey: PrimaryKeyType): "bigint" | "integer" | "uuid";
@@ -1,4 +1,4 @@
1
- export declare const primaryKeyTypes: readonly ["bigserial", "bigint", "uuid", "integer"];
1
+ export declare const primaryKeyTypes: readonly ["uuid7", "uuid4", "bigserial", "bigint", "integer"];
2
2
  export declare const TRIGRAM_OPERATORS: readonly ["%", "<%", "<<%"];
3
3
  declare class RequiredAttribute {
4
4
  constructor();
@@ -1,7 +1,6 @@
1
1
  import { CompiledQuery } from 'kysely';
2
2
  import { Context } from 'node:vm';
3
3
  import Dream from '../Dream.js';
4
- import { primaryKeyTypes } from '../dream/constants.js';
5
4
  import QueryDriverBase from '../dream/QueryDriver/Base.js';
6
5
  import { EncryptOptions } from '../encrypt/index.js';
7
6
  import autogeneratedFileDisclaimer from '../helpers/cli/autoGeneratedFileDisclaimer.js';
@@ -13,7 +12,7 @@ import expandStiClasses from '../helpers/sti/expandStiClasses.js';
13
12
  import inferSerializerFromDreamOrViewModel, { inferSerializersFromDreamClassOrViewModelClass } from '../serializer/helpers/inferSerializerFromDreamOrViewModel.js';
14
13
  import isDreamSerializer from '../serializer/helpers/isDreamSerializer.js';
15
14
  import serializerNameFromFullyQualifiedModelName from '../serializer/helpers/serializerNameFromFullyQualifiedModelName.js';
16
- import { DbConnectionType } from '../types/db.js';
15
+ import { DbConnectionType, PrimaryKeyType } from '../types/db.js';
17
16
  import { DreamModelSerializerType, SimpleObjectSerializerType } from '../types/serializer.js';
18
17
  export default class DreamApp {
19
18
  /**
@@ -116,7 +115,7 @@ export default class DreamApp {
116
115
  private _paginationPageSize;
117
116
  get paginationPageSize(): number;
118
117
  private _primaryKeyType;
119
- get primaryKeyType(): "bigint" | "bigserial" | "uuid" | "integer";
118
+ get primaryKeyType(): PrimaryKeyType;
120
119
  private _projectRoot;
121
120
  get projectRoot(): string;
122
121
  private _paths;
@@ -153,13 +152,13 @@ export default class DreamApp {
153
152
  get parallelDatabasesEnabled(): boolean;
154
153
  load<RT extends 'models' | 'serializers'>(resourceType: RT, resourcePath: string, importCb: (path: string) => Promise<any>): Promise<void>;
155
154
  plugin(cb: (app: DreamApp) => void | Promise<void>): void;
156
- set<ApplyOpt extends DreamAppSetOption>(applyOption: ApplyOpt, options: ApplyOpt extends 'bypassDeprecationChecks' ? boolean : ApplyOpt extends 'db' ? DreamDbCredentialOptions | string : ApplyOpt extends 'encryption' ? DreamAppEncryptionOptions : ApplyOpt extends 'primaryKeyType' ? (typeof primaryKeyTypes)[number] : ApplyOpt extends 'importExtension' ? GeneratorImportStyle : ApplyOpt extends 'logger' ? DreamLogger : ApplyOpt extends 'projectRoot' ? string : ApplyOpt extends 'inflections' ? () => void | Promise<void> : ApplyOpt extends 'packageManager' ? DreamAppAllowedPackageManagersEnum : ApplyOpt extends 'paths' ? DreamDirectoryPaths : ApplyOpt extends 'parallelTests' ? number : ApplyOpt extends 'unicodeNormalization' ? UnicodeNormalizationForm : ApplyOpt extends 'paginationPageSize' ? number : never, secondaryOptions?: ApplyOpt extends 'db' ? DreamDbCredentialOptions : never): void;
155
+ set<ApplyOpt extends DreamAppSetOption>(applyOption: ApplyOpt, options: ApplyOpt extends 'bypassDeprecationChecks' ? boolean : ApplyOpt extends 'db' ? DreamDbCredentialOptions | string : ApplyOpt extends 'encryption' ? DreamAppEncryptionOptions : ApplyOpt extends 'primaryKeyType' ? PrimaryKeyType : ApplyOpt extends 'importExtension' ? GeneratorImportStyle : ApplyOpt extends 'logger' ? DreamLogger : ApplyOpt extends 'projectRoot' ? string : ApplyOpt extends 'inflections' ? () => void | Promise<void> : ApplyOpt extends 'packageManager' ? DreamAppAllowedPackageManagersEnum : ApplyOpt extends 'paths' ? DreamDirectoryPaths : ApplyOpt extends 'parallelTests' ? number : ApplyOpt extends 'unicodeNormalization' ? UnicodeNormalizationForm : ApplyOpt extends 'paginationPageSize' ? number : never, secondaryOptions?: ApplyOpt extends 'db' ? DreamDbCredentialOptions : never): void;
157
156
  on<T extends DreamHookEventType>(hookEventType: T, cb: T extends 'db:log' ? (event: KyselyLogEvent) => void : T extends 'repl:start' ? (context: Context) => void | Promise<void> : never): void;
158
157
  }
159
158
  export type DreamHookEventType = 'db:log' | 'repl:start';
160
159
  export interface DreamAppOpts {
161
160
  projectRoot: string;
162
- primaryKeyType: (typeof primaryKeyTypes)[number];
161
+ primaryKeyType: PrimaryKeyType;
163
162
  db: DreamDbCredentialOptions;
164
163
  inflections?: () => void | Promise<void>;
165
164
  paths?: DreamDirectoryPaths;
@@ -1,4 +1,4 @@
1
- import { PrimaryKeyType } from '../../types/dream.js';
1
+ import { PrimaryKeyType } from '../../types/db.js';
2
2
  export default function generateMigrationContent({ connectionName, table, columnsWithTypes, primaryKeyType, createOrAlter, stiChildClassName, }?: {
3
3
  connectionName?: string;
4
4
  table?: string | undefined;
@@ -1,4 +1,4 @@
1
- import { PrimaryKeyType } from '../../types/dream.js';
1
+ import { PrimaryKeyType } from '../../types/db.js';
2
2
  export default function generateStiMigrationContent({ table, columnsWithTypes, primaryKeyType, stiChildClassName, }: {
3
3
  table?: string;
4
4
  columnsWithTypes?: string[];
@@ -3,6 +3,7 @@ export { CliFileWriter } from '../cli/CliFileWriter.js';
3
3
  export { default as DreamCLI } from '../cli/index.js';
4
4
  export { default as DreamImporter } from '../dream-app/helpers/DreamImporter.js';
5
5
  export { DreamAppAllowedPackageManagersEnumValues, type DreamAppAllowedPackageManagersEnum, } from '../dream-app/index.js';
6
+ export { primaryKeyTypes } from '../dream/constants.js';
6
7
  export { default as DreamLogos } from '../helpers/DreamLogos/DreamLogos.js';
7
8
  export { default as DreamSerializerBuilder } from '../serializer/builders/DreamSerializerBuilder.js';
8
9
  export { default as ObjectSerializerBuilder } from '../serializer/builders/ObjectSerializerBuilder.js';
@@ -7,7 +7,7 @@ export { type SerializerRendererOpts } from '../serializer/SerializerRenderer.js
7
7
  export { type BelongsToStatement } from '../types/associations/belongsTo.js';
8
8
  export { type HasManyStatement } from '../types/associations/hasMany.js';
9
9
  export { type HasOneStatement } from '../types/associations/hasOne.js';
10
- export { type DbConnectionType, type DbTypes } from '../types/db.js';
10
+ export { type DbConnectionType, type DbTypes, type PrimaryKeyType } from '../types/db.js';
11
11
  export { type StrictInterface } from '../types/utils.js';
12
12
  export { type DreamAssociationMetadata, type DreamAttributes, type DreamClassAssociationAndStatement, type DreamClassColumn, type DreamColumn, type DreamColumnNames, type DreamOrViewModelClassSerializerKey, type DreamOrViewModelSerializerKey, type DreamParamSafeAttributes, type DreamParamSafeColumnNames, type DreamSerializable, type DreamSerializableArray, type DreamSerializerKey, type DreamSerializers, type DreamVirtualColumns, type UpdateableAssociationProperties, type UpdateableProperties, type ViewModel, type ViewModelClass, } from '../types/dream.js';
13
13
  export { type DreamModelSerializerType, type InternalAnyTypedSerializerRendersMany, type InternalAnyTypedSerializerRendersOne, type SerializerCasing, type SimpleObjectSerializerType, } from '../types/serializer.js';
@@ -1,4 +1,5 @@
1
1
  import { postgresDatatypes } from '../db/dataTypes.js';
2
+ import { primaryKeyTypes } from '../dream/constants.js';
2
3
  export type DbConnectionType = 'primary' | 'replica';
3
4
  export type AssociationTableNames<DB, Schema> = keyof DB & keyof Schema extends never ? unknown : keyof DB & keyof Schema & string;
4
5
  export type Tables<DB> = keyof DB;
@@ -6,4 +7,5 @@ export type TableInterfaces<DB> = valueof<DB>;
6
7
  type valueof<T> = T[keyof T];
7
8
  export type NonArrayDbTypes = (typeof postgresDatatypes)[number];
8
9
  export type DbTypes = NonArrayDbTypes | `${NonArrayDbTypes}[]`;
10
+ export type PrimaryKeyType = (typeof primaryKeyTypes)[number] | 'uuid';
9
11
  export {};
@@ -1,4 +1,5 @@
1
1
  import { postgresDatatypes } from '../db/dataTypes.js'
2
+ import { primaryKeyTypes } from '../dream/constants.js'
2
3
 
3
4
  export type DbConnectionType = 'primary' | 'replica'
4
5
 
@@ -12,3 +13,4 @@ type valueof<T> = T[keyof T]
12
13
 
13
14
  export type NonArrayDbTypes = (typeof postgresDatatypes)[number]
14
15
  export type DbTypes = NonArrayDbTypes | `${NonArrayDbTypes}[]`
16
+ export type PrimaryKeyType = (typeof primaryKeyTypes)[number] | 'uuid'
@@ -1,7 +1,7 @@
1
1
  import { ColumnType, Updateable } from 'kysely';
2
2
  import { STI_SCOPE_NAME } from '../decorators/class/STI.js';
3
3
  import Dream from '../Dream.js';
4
- import { primaryKeyTypes, TRIGRAM_OPERATORS } from '../dream/constants.js';
4
+ import { TRIGRAM_OPERATORS } from '../dream/constants.js';
5
5
  import CalendarDate from '../helpers/CalendarDate.js';
6
6
  import { DateTime } from '../helpers/DateTime.js';
7
7
  import OpsStatement from '../ops/ops-statement.js';
@@ -11,7 +11,6 @@ import { FindEachOpts } from './query.js';
11
11
  import { DreamModelSerializerType, SimpleObjectSerializerType } from './serializer.js';
12
12
  import { FilterInterface, Inc, RejectInterface } from './utils.js';
13
13
  import { AliasedSchemaAssociation } from './variadic.js';
14
- export type PrimaryKeyType = (typeof primaryKeyTypes)[number];
15
14
  export type DreamPrimaryKeyType<I extends Dream, Schema extends I['schema'] = I['schema'], TableName extends keyof Schema = I['table'] & keyof Schema, PrimaryKey extends I['primaryKey' & keyof I] extends undefined ? 'id' : I['primaryKey' & keyof I] = I['primaryKey' & keyof I] extends undefined ? 'id' : I['primaryKey' & keyof I]> = Schema[TableName]['columns'][PrimaryKey & keyof Schema[TableName]['columns']]['coercedType'];
16
15
  export type Timestamp = ColumnType<DateTime | CalendarDate>;
17
16
  export type MAX_VARIADIC_DEPTH = 25;
@@ -1,7 +1,7 @@
1
1
  import { ColumnType, Updateable } from 'kysely'
2
2
  import { STI_SCOPE_NAME } from '../decorators/class/STI.js'
3
3
  import Dream from '../Dream.js'
4
- import { primaryKeyTypes, TRIGRAM_OPERATORS } from '../dream/constants.js'
4
+ import { TRIGRAM_OPERATORS } from '../dream/constants.js'
5
5
  import CalendarDate from '../helpers/CalendarDate.js'
6
6
  import { DateTime } from '../helpers/DateTime.js'
7
7
  import OpsStatement from '../ops/ops-statement.js'
@@ -17,8 +17,6 @@ import { DreamModelSerializerType, SimpleObjectSerializerType } from './serializ
17
17
  import { FilterInterface, Inc, RejectInterface } from './utils.js'
18
18
  import { AliasedSchemaAssociation } from './variadic.js'
19
19
 
20
- export type PrimaryKeyType = (typeof primaryKeyTypes)[number]
21
-
22
20
  export type DreamPrimaryKeyType<
23
21
  I extends Dream,
24
22
  Schema extends I['schema'] = I['schema'],
@@ -1 +1 @@
1
- window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAE62b23LbthaG30XX6W6T3WPuZMlONbEtV1Kdi05mD0QuS2hAgAUgJ0qn774HPIggCCyAdO80xL++HyRx4gL0x98zDV/07O0s389ezUqij7O3s0LkJwbq23z/n6Mu2OzV7BPl+eztm1ez7EhZLoHP3v5xCV1KIMUdPUiiqeC/AitBqo6WMaJUTfMq+x6v3/z8z6sL+v1ZATv/dgJ5Xkr6DNKLHagw5INQ+iBBxaAeHYa1ZFdEgRfpaDBcxoSCOWPL/UJwDpl5XtYzfTrx+pLBerV9+I/fW+zcvIUU8FCIUE9cn0vIl/sA7FKOMJ4JoznRsBDsVPAAqC9KoO3InkEEVmkGrI8WDaQUdrNuO0l9PamjLI6QfVoIrrQklOtHKljVEYaNpYGGArCWUz+W9TPIJyY+h9E9GQqUQDSs5Q3l+dX5hlAG+U7UV+c8N5fDLvFYzHpJNFnxTBQl0XTP4APVR3NtTxTcUGBh42hkzHZ3LpsWZn7dUVUQnR1RP38IZvSOiT1h96SAe6G3oIN4V4hBV7xq1AvCgOdELon2jEYN16PF0HdUKcoPW5CUMPoVpFrCE+UUbcRYEGZ2L/itIDnkc6VERvGe4hPjcH1/YizeBV0hBt1AJmR+L/SNOCGdoi/DgI/16EQFvzahQaKjw5DloZKYFuobEhugpUIHRcpz+DIcE6vLaUMi2kprTmrrXJrnSrTwLT5qUqdAOWbaCyJMYTR6XpYoYF6WUcZO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8XeoUqpFhuGueyXOZUM2+EEOaTInkhM352YzNub0q4jlIdUf4GXFKin9RBdYcXuK/5u5nbM/e1YOMvCt/ALpXQwowAYOpvwZeiqODhHVIrX+0wca5qjjVu/hpYUlrnLr9dodS7kCTnGgSgAbUaS5aS7o/6WCN+6Ik5sJMHVaF5jz3DF8DFyws3dc9Bui38Z0DDFGjwLEscyQLe9yWKol6Kw638AyDbKuFbCWpPE9iuE9LyAbXB3dFDqzr40g/C6iTXNbykcLnKrp6vR3iPQy2liw/NG6s8wTT8X4PRJLCnJxI6rge9TiXtAbrkyf52HkMhG/LRnO9O7ABeNIerLPYxl/2+DdsnXlM4qY96Ucq9Ymw+gVh4L4wxm4WRnN2EJLq42BF31s+XVQx6q+kWuZEJg1XlUBdc4hDbVGUeS6PwMOLka48RnogKiPIsqYrj5E25oQo5YcHCRlVvcNGNnAgi3G7JrcgypMsc9dztSpKpUXJwP28DM8TYX3UiZNPQJ9o6Al35VGSljTTq3YpG8D1RTHm76X5S0E1CHVLIN9xLtsjEpTumW6UTu8OGIffZl8TJbbzZgDWFidzqkk/Aqs0MeKHI8hu1LgR0jkPbJP92mkOyA0gATGv3Wb1bjO/+9/64Xoz3603W1+epHYZSJH8ZylpQeT5PZyDCc8a6gjRFMtJU+ZJsVSXk1IszeQ0zHzViKYYS3RtCD94DqLX8VUhFp0136u+o6o1olUgJ14zUlJNYphWg4GY4LAEKENHeBuWLcNw5s809mmKAagWIIiDFKfy6hxGNAIEcWxn4TDkIkEwVe5CgXO63iXZKgymrotSI7fVCBAEN2crzfv8ndNM5MjduUoEWrbrjDDtIsEwILPeImsAqQUIQva7lQuoit2tjz6g/4+aAWD4T5peuCLm/0Zfwd0adDl9HQasFxjIO28VGERI5Kma0kgw1pXq8gigOWBy7n34+EiWMBFZpdTToJUUwZ54yphoq1AY/QuD0L8GwR//+fh/b6EHfik9AAA="
1
+ window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAE62bXXPbNhaG/4v2Nrtt0rS7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