@rvoh/dream 2.1.2 → 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.
- package/README.md +4 -4
- package/dist/cjs/src/Dream.js +35 -0
- package/dist/cjs/src/bin/index.js +1 -1
- package/dist/cjs/src/cli/index.js +5 -1
- package/dist/cjs/src/cli/logger/loggable/DreamCliLoggableText.js +1 -0
- package/dist/cjs/src/dream/DreamClassTransactionBuilder.js +30 -0
- package/dist/cjs/src/dream/Query.js +30 -0
- package/dist/cjs/src/dream/QueryDriver/Base.js +32 -0
- package/dist/cjs/src/dream/QueryDriver/Kysely.js +52 -6
- package/dist/cjs/src/dream/QueryDriver/helpers/kysely/foreignKeyTypeFromPrimaryKey.js +3 -0
- package/dist/cjs/src/dream/constants.js +1 -1
- package/dist/cjs/src/dream/internal/printSerializerHierarchyLevel.js +2 -0
- package/dist/cjs/src/dream-app/helpers/DreamImporter.js +3 -1
- package/dist/cjs/src/dream-app/index.js +2 -1
- package/dist/cjs/src/helpers/Env.js +2 -0
- package/dist/cjs/src/helpers/cli/ASTConnectionBuilder.js +1 -1
- package/dist/cjs/src/helpers/cli/DBClassDeprecation.js +2 -0
- package/dist/cjs/src/helpers/cli/generateDream.js +2 -1
- package/dist/cjs/src/helpers/cli/generateFactory.js +2 -1
- package/dist/cjs/src/helpers/cli/generateFactoryContent.js +13 -3
- package/dist/cjs/src/helpers/cli/generateMigration.js +2 -1
- package/dist/cjs/src/helpers/cli/generateMigrationContent.js +18 -4
- package/dist/cjs/src/helpers/cli/generateSerializer.js +2 -1
- package/dist/cjs/src/helpers/cli/generateUnitSpec.js +2 -1
- package/dist/cjs/src/helpers/getFiles.js +3 -1
- package/dist/cjs/src/helpers/sspawn.js +2 -0
- package/dist/cjs/src/package-exports/system.js +1 -0
- package/dist/esm/src/Dream.js +35 -0
- package/dist/esm/src/bin/index.js +1 -1
- package/dist/esm/src/cli/index.js +5 -1
- package/dist/esm/src/cli/logger/loggable/DreamCliLoggableText.js +1 -0
- package/dist/esm/src/dream/DreamClassTransactionBuilder.js +30 -0
- package/dist/esm/src/dream/Query.js +30 -0
- package/dist/esm/src/dream/QueryDriver/Base.js +32 -0
- package/dist/esm/src/dream/QueryDriver/Kysely.js +52 -6
- package/dist/esm/src/dream/QueryDriver/helpers/kysely/foreignKeyTypeFromPrimaryKey.js +3 -0
- package/dist/esm/src/dream/constants.js +1 -1
- package/dist/esm/src/dream/internal/printSerializerHierarchyLevel.js +2 -0
- package/dist/esm/src/dream-app/helpers/DreamImporter.js +3 -1
- package/dist/esm/src/dream-app/index.js +2 -1
- package/dist/esm/src/helpers/Env.js +2 -0
- package/dist/esm/src/helpers/cli/ASTConnectionBuilder.js +1 -1
- package/dist/esm/src/helpers/cli/DBClassDeprecation.js +2 -0
- package/dist/esm/src/helpers/cli/generateDream.js +2 -1
- package/dist/esm/src/helpers/cli/generateFactory.js +2 -1
- package/dist/esm/src/helpers/cli/generateFactoryContent.js +13 -3
- package/dist/esm/src/helpers/cli/generateMigration.js +2 -1
- package/dist/esm/src/helpers/cli/generateMigrationContent.js +18 -4
- package/dist/esm/src/helpers/cli/generateSerializer.js +2 -1
- package/dist/esm/src/helpers/cli/generateUnitSpec.js +2 -1
- package/dist/esm/src/helpers/getFiles.js +3 -1
- package/dist/esm/src/helpers/sspawn.js +2 -0
- package/dist/esm/src/package-exports/system.js +1 -0
- package/dist/types/src/Dream.d.ts +42 -0
- package/dist/types/src/dream/DreamClassTransactionBuilder.d.ts +26 -0
- package/dist/types/src/dream/Query.d.ts +26 -0
- package/dist/types/src/dream/QueryDriver/Base.d.ts +29 -3
- package/dist/types/src/dream/QueryDriver/Kysely.d.ts +30 -4
- package/dist/types/src/dream/QueryDriver/helpers/kysely/foreignKeyTypeFromPrimaryKey.d.ts +2 -2
- package/dist/types/src/dream/constants.d.ts +1 -1
- package/dist/types/src/dream-app/helpers/PackageManager.d.ts +1 -1
- package/dist/types/src/dream-app/index.d.ts +6 -7
- package/dist/types/src/helpers/cli/generateMigrationContent.d.ts +1 -1
- package/dist/types/src/helpers/cli/generateStiMigrationContent.d.ts +1 -1
- package/dist/types/src/package-exports/system.d.ts +1 -0
- package/dist/types/src/package-exports/types.d.ts +1 -1
- package/dist/types/src/types/associations/belongsTo.d.ts +1 -1
- package/dist/types/src/types/associations/belongsTo.ts +1 -1
- package/dist/types/src/types/db.d.ts +2 -0
- package/dist/types/src/types/db.ts +2 -0
- package/dist/types/src/types/dream.d.ts +1 -2
- package/dist/types/src/types/dream.ts +1 -3
- package/dist/types/src/types/serializer.ts +2 -2
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/db.DreamMigrationHelpers.html +9 -9
- package/docs/classes/db.KyselyQueryDriver.html +47 -31
- package/docs/classes/db.PostgresQueryDriver.html +48 -32
- package/docs/classes/db.QueryDriverBase.html +46 -30
- package/docs/classes/errors.CheckConstraintViolation.html +4 -4
- package/docs/classes/errors.ColumnOverflow.html +4 -4
- package/docs/classes/errors.CreateOrFindByFailedToCreateAndFind.html +4 -4
- package/docs/classes/errors.DataIncompatibleWithDatabaseField.html +4 -4
- package/docs/classes/errors.DataTypeColumnTypeMismatch.html +4 -4
- package/docs/classes/errors.GlobalNameNotSet.html +4 -4
- package/docs/classes/errors.InvalidCalendarDate.html +4 -4
- package/docs/classes/errors.MissingSerializersDefinition.html +4 -4
- package/docs/classes/errors.NonLoadedAssociation.html +4 -4
- package/docs/classes/errors.NotNullViolation.html +4 -4
- package/docs/classes/errors.RecordNotFound.html +4 -4
- package/docs/classes/errors.ValidationError.html +4 -4
- package/docs/classes/index.CalendarDate.html +2 -2
- package/docs/classes/index.Decorators.html +19 -19
- package/docs/classes/index.Dream.html +227 -201
- package/docs/classes/index.DreamApp.html +5 -5
- package/docs/classes/index.DreamTransaction.html +2 -2
- package/docs/classes/index.Env.html +2 -2
- package/docs/classes/index.Query.html +91 -75
- package/docs/classes/system.CliFileWriter.html +2 -2
- package/docs/classes/system.DreamBin.html +2 -2
- package/docs/classes/system.DreamCLI.html +5 -5
- package/docs/classes/system.DreamImporter.html +2 -2
- package/docs/classes/system.DreamLogos.html +2 -2
- package/docs/classes/system.DreamSerializerBuilder.html +8 -8
- package/docs/classes/system.ObjectSerializerBuilder.html +8 -8
- package/docs/classes/utils.Encrypt.html +2 -2
- package/docs/classes/utils.Range.html +2 -2
- package/docs/functions/db.closeAllDbConnections.html +1 -1
- package/docs/functions/db.dreamDbConnections.html +1 -1
- package/docs/functions/db.untypedDb.html +1 -1
- package/docs/functions/db.validateColumn.html +1 -1
- package/docs/functions/db.validateTable.html +1 -1
- package/docs/functions/errors.pgErrorType.html +1 -1
- package/docs/functions/index.DreamSerializer.html +1 -1
- package/docs/functions/index.ObjectSerializer.html +1 -1
- package/docs/functions/index.ReplicaSafe.html +1 -1
- package/docs/functions/index.STI.html +1 -1
- package/docs/functions/index.SoftDelete.html +1 -1
- package/docs/functions/utils.camelize.html +1 -1
- package/docs/functions/utils.capitalize.html +1 -1
- package/docs/functions/utils.cloneDeepSafe.html +1 -1
- package/docs/functions/utils.compact.html +1 -1
- package/docs/functions/utils.groupBy.html +1 -1
- package/docs/functions/utils.hyphenize.html +1 -1
- package/docs/functions/utils.intersection.html +1 -1
- package/docs/functions/utils.isEmpty.html +1 -1
- package/docs/functions/utils.normalizeUnicode.html +1 -1
- package/docs/functions/utils.pascalize.html +1 -1
- package/docs/functions/utils.percent.html +1 -1
- package/docs/functions/utils.range-1.html +1 -1
- package/docs/functions/utils.round.html +1 -1
- package/docs/functions/utils.sanitizeString.html +1 -1
- package/docs/functions/utils.snakeify.html +1 -1
- package/docs/functions/utils.sort.html +1 -1
- package/docs/functions/utils.sortBy.html +1 -1
- package/docs/functions/utils.sortObjectByKey.html +1 -1
- package/docs/functions/utils.sortObjectByValue.html +1 -1
- package/docs/functions/utils.uncapitalize.html +1 -1
- package/docs/functions/utils.uniq.html +1 -1
- package/docs/index.html +4 -4
- package/docs/interfaces/openapi.OpenapiDescription.html +2 -2
- package/docs/interfaces/openapi.OpenapiSchemaProperties.html +1 -1
- package/docs/interfaces/openapi.OpenapiSchemaPropertiesShorthand.html +1 -1
- package/docs/interfaces/openapi.OpenapiTypeFieldObject.html +1 -1
- package/docs/interfaces/types.BelongsToStatement.html +2 -2
- package/docs/interfaces/types.DecoratorContext.html +2 -2
- package/docs/interfaces/types.DreamAppInitOptions.html +2 -2
- package/docs/interfaces/types.DreamAppOpts.html +2 -2
- package/docs/interfaces/types.EncryptOptions.html +2 -2
- package/docs/interfaces/types.InternalAnyTypedSerializerRendersMany.html +2 -2
- package/docs/interfaces/types.InternalAnyTypedSerializerRendersOne.html +2 -2
- package/docs/interfaces/types.SerializerRendererOpts.html +2 -2
- package/docs/modules/db.html +1 -1
- package/docs/modules/errors.html +1 -1
- package/docs/modules/index.html +1 -1
- package/docs/modules/openapi.html +1 -1
- package/docs/modules/system.html +2 -1
- package/docs/modules/types.html +4 -3
- package/docs/modules/utils.html +1 -1
- package/docs/types/index.DateTime.html +1 -1
- package/docs/types/openapi.CommonOpenapiSchemaObjectFields.html +1 -1
- package/docs/types/openapi.OpenapiAllTypes.html +1 -1
- package/docs/types/openapi.OpenapiFormats.html +1 -1
- package/docs/types/openapi.OpenapiNumberFormats.html +1 -1
- package/docs/types/openapi.OpenapiPrimitiveBaseTypes.html +1 -1
- package/docs/types/openapi.OpenapiPrimitiveTypes.html +1 -1
- package/docs/types/openapi.OpenapiSchemaArray.html +1 -1
- package/docs/types/openapi.OpenapiSchemaArrayShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaBase.html +1 -1
- package/docs/types/openapi.OpenapiSchemaBody.html +1 -1
- package/docs/types/openapi.OpenapiSchemaBodyShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaCommonFields.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionAllOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionAnyOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionOneOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionRef.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaInteger.html +1 -1
- package/docs/types/openapi.OpenapiSchemaNull.html +1 -1
- package/docs/types/openapi.OpenapiSchemaNumber.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObject.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAllOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAllOfShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAnyOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAnyOfShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectBase.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectBaseShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectOneOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectOneOfShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaPrimitiveGeneric.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionAllOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionOneOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
- package/docs/types/openapi.OpenapiSchemaString.html +1 -1
- package/docs/types/openapi.OpenapiShorthandAllTypes.html +1 -1
- package/docs/types/openapi.OpenapiShorthandPrimitiveBaseTypes.html +1 -1
- package/docs/types/openapi.OpenapiShorthandPrimitiveTypes.html +1 -1
- package/docs/types/openapi.OpenapiTypeField.html +1 -1
- package/docs/types/system.DreamAppAllowedPackageManagersEnum.html +1 -1
- package/docs/types/types.Camelized.html +1 -1
- package/docs/types/types.DbConnectionType.html +1 -1
- package/docs/types/types.DbTypes.html +1 -1
- package/docs/types/types.DreamAssociationMetadata.html +1 -1
- package/docs/types/types.DreamAttributes.html +1 -1
- package/docs/types/types.DreamClassAssociationAndStatement.html +1 -1
- package/docs/types/types.DreamClassColumn.html +1 -1
- package/docs/types/types.DreamColumn.html +1 -1
- package/docs/types/types.DreamColumnNames.html +1 -1
- package/docs/types/types.DreamLogLevel.html +1 -1
- package/docs/types/types.DreamLogger.html +1 -1
- package/docs/types/types.DreamModelSerializerType.html +1 -1
- package/docs/types/types.DreamOrViewModelClassSerializerKey.html +1 -1
- package/docs/types/types.DreamOrViewModelSerializerKey.html +1 -1
- package/docs/types/types.DreamParamSafeAttributes.html +1 -1
- package/docs/types/types.DreamParamSafeColumnNames.html +1 -1
- package/docs/types/types.DreamSerializable.html +1 -1
- package/docs/types/types.DreamSerializableArray.html +1 -1
- package/docs/types/types.DreamSerializerKey.html +1 -1
- package/docs/types/types.DreamSerializers.html +1 -1
- package/docs/types/types.DreamVirtualColumns.html +1 -1
- package/docs/types/types.EncryptAlgorithm.html +1 -1
- package/docs/types/types.HasManyStatement.html +1 -1
- package/docs/types/types.HasOneStatement.html +1 -1
- package/docs/types/types.Hyphenized.html +1 -1
- package/docs/types/types.Pascalized.html +1 -1
- package/docs/types/types.PrimaryKeyType.html +1 -0
- package/docs/types/types.RoundingPrecision.html +1 -1
- package/docs/types/types.SerializerCasing.html +1 -1
- package/docs/types/types.SimpleObjectSerializerType.html +1 -1
- package/docs/types/types.Snakeified.html +1 -1
- package/docs/types/types.StrictInterface.html +1 -1
- package/docs/types/types.UpdateableAssociationProperties.html +1 -1
- package/docs/types/types.UpdateableProperties.html +1 -1
- package/docs/types/types.ValidationType.html +1 -1
- package/docs/types/types.ViewModel.html +1 -1
- package/docs/types/types.ViewModelClass.html +1 -1
- package/docs/types/types.WhereStatementForDream.html +1 -1
- package/docs/types/types.WhereStatementForDreamClass.html +1 -1
- package/docs/variables/index.DateTime-1.html +1 -1
- package/docs/variables/index.DreamConst.html +1 -1
- package/docs/variables/index.ops.html +1 -1
- package/docs/variables/openapi.openapiPrimitiveTypes-1.html +1 -1
- package/docs/variables/openapi.openapiShorthandPrimitiveTypes-1.html +1 -1
- package/docs/variables/system.DreamAppAllowedPackageManagersEnumValues.html +1 -1
- package/docs/variables/system.primaryKeyTypes.html +1 -0
- package/docs/variables/types.TRIGRAM_OPERATORS.html +1 -1
- package/package.json +17 -17
- package/CHANGELOG.md +0 -332
- package/docs/variables/types.primaryKeyTypes.html +0 -1
|
@@ -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';
|
|
@@ -707,6 +707,34 @@ export default class Dream {
|
|
|
707
707
|
* @returns the min value of the specified column for this model's records
|
|
708
708
|
*/
|
|
709
709
|
static min<T extends typeof Dream, ColumnName extends DreamColumnNames<InstanceType<T>>>(this: T, columnName: ColumnName): Promise<InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]][ColumnName & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]]]["coercedType" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]][ColumnName & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]]]]>;
|
|
710
|
+
/**
|
|
711
|
+
* Retrieves the sum for all values of the specified column
|
|
712
|
+
* for this model's records.
|
|
713
|
+
*
|
|
714
|
+
*
|
|
715
|
+
* ```ts
|
|
716
|
+
* await Game.sum('score')
|
|
717
|
+
* // 100
|
|
718
|
+
* ```
|
|
719
|
+
*
|
|
720
|
+
* @param columnName - a column name on the model
|
|
721
|
+
* @returns the sum for all values of the specified column for this model's records
|
|
722
|
+
*/
|
|
723
|
+
static sum<T extends typeof Dream, ColumnName extends DreamColumnNames<InstanceType<T>>>(this: T, columnName: ColumnName): Promise<InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]][ColumnName & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]]]["coercedType" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]][ColumnName & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]]]]>;
|
|
724
|
+
/**
|
|
725
|
+
* Retrieves the average for all values of the specified column
|
|
726
|
+
* for this model's records.
|
|
727
|
+
*
|
|
728
|
+
*
|
|
729
|
+
* ```ts
|
|
730
|
+
* await Game.avg('score')
|
|
731
|
+
* // 100
|
|
732
|
+
* ```
|
|
733
|
+
*
|
|
734
|
+
* @param columnName - a column name on the model
|
|
735
|
+
* @returns the average for all values of the specified column for this model's records
|
|
736
|
+
*/
|
|
737
|
+
static avg<T extends typeof Dream, ColumnName extends DreamColumnNames<InstanceType<T>>>(this: T, columnName: ColumnName): Promise<InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]][ColumnName & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]]]["coercedType" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]][ColumnName & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]["columns" & keyof InstanceType<T>["schema"][InstanceType<T>["table"] & keyof InstanceType<T>["schema"]]]]]>;
|
|
710
738
|
/**
|
|
711
739
|
* Persists a new record, setting the provided attributes.
|
|
712
740
|
* Automatically sets createdAt and updatedAt timestamps.
|
|
@@ -2349,6 +2377,13 @@ export default class Dream {
|
|
|
2349
2377
|
* For HasMany associations, returns an array (empty if no records). For BelongsTo/HasOne
|
|
2350
2378
|
* associations, returns the associated model or null if not found.
|
|
2351
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
|
+
*
|
|
2352
2387
|
* ```ts
|
|
2353
2388
|
* // Basic association loading
|
|
2354
2389
|
* const user = await post.association('user')
|
|
@@ -2401,6 +2436,13 @@ export default class Dream {
|
|
|
2401
2436
|
* For HasMany associations, returns an array (empty if no records). For BelongsTo/HasOne
|
|
2402
2437
|
* associations, returns the associated model or throws RecordNotFound if not found.
|
|
2403
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
|
+
*
|
|
2404
2446
|
* ```ts
|
|
2405
2447
|
* // Basic association loading - throws RecordNotFound if user doesn't exist
|
|
2406
2448
|
* const user = await post.associationOrFail('user')
|
|
@@ -115,6 +115,32 @@ export default class DreamClassTransactionBuilder<DreamClass extends typeof Drea
|
|
|
115
115
|
* @returns The min value of the specified column for this model's records
|
|
116
116
|
*/
|
|
117
117
|
min<I extends DreamClassTransactionBuilder<DreamClass, DreamInstance>, T extends DreamColumnNames<DreamInstance>>(this: I, columnName: T): Promise<DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]][T & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]]]["coercedType" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]][T & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]]]]>;
|
|
118
|
+
/**
|
|
119
|
+
* Retrieves the sum value of the specified column
|
|
120
|
+
* for this Query
|
|
121
|
+
*
|
|
122
|
+
* ```ts
|
|
123
|
+
* await Game.txn(txn).sum('score')
|
|
124
|
+
* // 1
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* @param columnName - a column name on the model
|
|
128
|
+
* @returns the sum of the values of the specified column for this Query
|
|
129
|
+
*/
|
|
130
|
+
sum<I extends DreamClassTransactionBuilder<DreamClass, DreamInstance>, T extends DreamColumnNames<DreamInstance>>(this: I, columnName: T): Promise<DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]][T & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]]]["coercedType" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]][T & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]]]]>;
|
|
131
|
+
/**
|
|
132
|
+
* Retrieves the average value of the specified column
|
|
133
|
+
* for this Query
|
|
134
|
+
*
|
|
135
|
+
* ```ts
|
|
136
|
+
* await Game.txn(txn).avg('score')
|
|
137
|
+
* // 1
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
140
|
+
* @param columnName - a column name on the model
|
|
141
|
+
* @returns the average of the values of the specified column for this Query
|
|
142
|
+
*/
|
|
143
|
+
avg<I extends DreamClassTransactionBuilder<DreamClass, DreamInstance>, T extends DreamColumnNames<DreamInstance>>(this: I, columnName: T): Promise<DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]][T & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]]]["coercedType" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]][T & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]["columns" & keyof DreamInstance["schema"][DreamInstance["table"] & keyof DreamInstance["schema"]]]]]>;
|
|
118
144
|
/**
|
|
119
145
|
* Persists a new record, setting the provided attributes.
|
|
120
146
|
* Automatically sets createdAt and updatedAt timestamps.
|
|
@@ -752,6 +752,32 @@ export default class Query<DreamInstance extends Dream, QueryTypeOpts extends Re
|
|
|
752
752
|
* @returns the min value of the specified column for this Query
|
|
753
753
|
*/
|
|
754
754
|
min<Q extends Query<DreamInstance, QueryTypeOpts>, DB extends DreamInstance['DB'], ColumnName extends ColumnNamesAccountingForJoinedAssociations<Q['queryTypeOpts']['joinedAssociations'], DB, QueryTypeOpts['rootTableName'], QueryTypeOpts['rootTableAlias']>, ReturnType extends NamespacedOrBaseModelColumnTypes<[ColumnName], Q, DreamInstance>[0]>(columnName: ColumnName): Promise<ReturnType>;
|
|
755
|
+
/**
|
|
756
|
+
* Retrieves the sum value of the specified column
|
|
757
|
+
* for this Query
|
|
758
|
+
*
|
|
759
|
+
* ```ts
|
|
760
|
+
* await Game.query().sum('score')
|
|
761
|
+
* // 1
|
|
762
|
+
* ```
|
|
763
|
+
*
|
|
764
|
+
* @param columnName - a column name on the model
|
|
765
|
+
* @returns the sum of the values of the specified column for this Query
|
|
766
|
+
*/
|
|
767
|
+
sum<Q extends Query<DreamInstance, QueryTypeOpts>, DB extends DreamInstance['DB'], ColumnName extends ColumnNamesAccountingForJoinedAssociations<Q['queryTypeOpts']['joinedAssociations'], DB, QueryTypeOpts['rootTableName'], QueryTypeOpts['rootTableAlias']>, ReturnType extends NamespacedOrBaseModelColumnTypes<[ColumnName], Q, DreamInstance>[0]>(columnName: ColumnName): Promise<ReturnType>;
|
|
768
|
+
/**
|
|
769
|
+
* Retrieves the average value of the specified column
|
|
770
|
+
* for this Query
|
|
771
|
+
*
|
|
772
|
+
* ```ts
|
|
773
|
+
* await Game.query().avg('score')
|
|
774
|
+
* // 1
|
|
775
|
+
* ```
|
|
776
|
+
*
|
|
777
|
+
* @param columnName - a column name on the model
|
|
778
|
+
* @returns the average of the values of the specified column for this Query
|
|
779
|
+
*/
|
|
780
|
+
avg<Q extends Query<DreamInstance, QueryTypeOpts>, DB extends DreamInstance['DB'], ColumnName extends ColumnNamesAccountingForJoinedAssociations<Q['queryTypeOpts']['joinedAssociations'], DB, QueryTypeOpts['rootTableName'], QueryTypeOpts['rootTableAlias']>, ReturnType extends NamespacedOrBaseModelColumnTypes<[ColumnName], Q, DreamInstance>[0]>(columnName: ColumnName): Promise<ReturnType>;
|
|
755
781
|
/**
|
|
756
782
|
* Plucks the provided fields from the given dream class table
|
|
757
783
|
*
|
|
@@ -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
|
|
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>;
|
|
@@ -195,6 +195,32 @@ export default class QueryDriverBase<DreamInstance extends Dream> {
|
|
|
195
195
|
* @returns the min value of the specified column for this Query
|
|
196
196
|
*/
|
|
197
197
|
min(columnName: string): Promise<any>;
|
|
198
|
+
/**
|
|
199
|
+
* Retrieves the sum value of the specified column
|
|
200
|
+
* for this Query
|
|
201
|
+
*
|
|
202
|
+
* ```ts
|
|
203
|
+
* await Game.query().sum('score')
|
|
204
|
+
* // 1
|
|
205
|
+
* ```
|
|
206
|
+
*
|
|
207
|
+
* @param columnName - a column name on the model
|
|
208
|
+
* @returns the sum of the values of the specified column for this Query
|
|
209
|
+
*/
|
|
210
|
+
sum(columnName: string): Promise<any>;
|
|
211
|
+
/**
|
|
212
|
+
* Retrieves the average value of the specified column
|
|
213
|
+
* for this Query
|
|
214
|
+
*
|
|
215
|
+
* ```ts
|
|
216
|
+
* await Game.query().avg('score')
|
|
217
|
+
* // 1
|
|
218
|
+
* ```
|
|
219
|
+
*
|
|
220
|
+
* @param columnName - a column name on the model
|
|
221
|
+
* @returns the average of the values of the specified column for this Query
|
|
222
|
+
*/
|
|
223
|
+
avg(columnName: string): Promise<any>;
|
|
198
224
|
/**
|
|
199
225
|
* Retrieves the number of records in the database
|
|
200
226
|
*
|
|
@@ -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,
|
|
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" | "
|
|
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():
|
|
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.
|
|
@@ -168,6 +168,32 @@ export default class KyselyQueryDriver<DreamInstance extends Dream> extends Quer
|
|
|
168
168
|
* @returns the min value of the specified column for this Query
|
|
169
169
|
*/
|
|
170
170
|
min(columnName: string): Promise<any>;
|
|
171
|
+
/**
|
|
172
|
+
* Retrieves the sum value of the specified column
|
|
173
|
+
* for this Query
|
|
174
|
+
*
|
|
175
|
+
* ```ts
|
|
176
|
+
* await Game.query().sum('score')
|
|
177
|
+
* // 1
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* @param columnName - a column name on the model
|
|
181
|
+
* @returns the sum of the values of the specified column for this Query
|
|
182
|
+
*/
|
|
183
|
+
sum(columnName: string): Promise<any>;
|
|
184
|
+
/**
|
|
185
|
+
* Retrieves the average value of the specified column
|
|
186
|
+
* for this Query
|
|
187
|
+
*
|
|
188
|
+
* ```ts
|
|
189
|
+
* await Game.query().avg('score')
|
|
190
|
+
* // 1
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* @param columnName - a column name on the model
|
|
194
|
+
* @returns the average of the values of the specified column for this Query
|
|
195
|
+
*/
|
|
196
|
+
avg(columnName: string): Promise<any>;
|
|
171
197
|
/**
|
|
172
198
|
* Retrieves the number of records in the database
|
|
173
199
|
*
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PrimaryKeyType } from '../../../../types/
|
|
2
|
-
export default function foreignKeyTypeFromPrimaryKey(primaryKey: PrimaryKeyType): "bigint" | "
|
|
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 ["
|
|
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():
|
|
118
|
+
get primaryKeyType(): PrimaryKeyType;
|
|
120
119
|
private _projectRoot;
|
|
121
120
|
get projectRoot(): string;
|
|
122
121
|
private _paths;
|
|
@@ -130,7 +129,7 @@ export default class DreamApp {
|
|
|
130
129
|
private _plugins;
|
|
131
130
|
get plugins(): ((app: DreamApp) => void | Promise<void>)[];
|
|
132
131
|
private _packageManager;
|
|
133
|
-
get packageManager(): "
|
|
132
|
+
get packageManager(): "pnpm" | "yarn" | "npm";
|
|
134
133
|
private _importExtension;
|
|
135
134
|
get importExtension(): ".js" | ".ts" | "none";
|
|
136
135
|
/**
|
|
@@ -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' ?
|
|
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:
|
|
161
|
+
primaryKeyType: PrimaryKeyType;
|
|
163
162
|
db: DreamDbCredentialOptions;
|
|
164
163
|
inflections?: () => void | Promise<void>;
|
|
165
164
|
paths?: DreamDirectoryPaths;
|
|
@@ -219,7 +218,7 @@ export interface KyselyLogEvent {
|
|
|
219
218
|
queryDurationMillis: number;
|
|
220
219
|
error: unknown;
|
|
221
220
|
}
|
|
222
|
-
export declare const DreamAppAllowedPackageManagersEnumValues: readonly ["
|
|
221
|
+
export declare const DreamAppAllowedPackageManagersEnumValues: readonly ["pnpm", "yarn", "npm"];
|
|
223
222
|
export type DreamAppAllowedPackageManagersEnum = (typeof DreamAppAllowedPackageManagersEnumValues)[number];
|
|
224
223
|
export declare const GeneratorImportStyles: readonly [".js", ".ts", "none"];
|
|
225
224
|
export type GeneratorImportStyle = (typeof GeneratorImportStyles)[number];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PrimaryKeyType } from '../../types/
|
|
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/
|
|
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';
|
|
@@ -6,7 +6,7 @@ export interface BelongsToStatement<BaseInstance extends Dream, DB, Schema, Tabl
|
|
|
6
6
|
globalAssociationNameOrNames: string[];
|
|
7
7
|
type: 'BelongsTo';
|
|
8
8
|
as: string;
|
|
9
|
-
primaryKey: (associationInstance?: Dream
|
|
9
|
+
primaryKey: (associationInstance?: Dream, opts?: {
|
|
10
10
|
associatedClassOverride?: typeof Dream | undefined;
|
|
11
11
|
}) => keyof DB[TableName] & string;
|
|
12
12
|
primaryKeyValue: (associationInstance: Dream | null) => any;
|
|
@@ -20,7 +20,7 @@ export interface BelongsToStatement<
|
|
|
20
20
|
type: 'BelongsTo'
|
|
21
21
|
as: string
|
|
22
22
|
primaryKey: (
|
|
23
|
-
associationInstance?: Dream
|
|
23
|
+
associationInstance?: Dream,
|
|
24
24
|
opts?: { associatedClassOverride?: typeof Dream | undefined }
|
|
25
25
|
) => keyof DB[TableName] & string
|
|
26
26
|
primaryKeyValue: (associationInstance: Dream | null) => any
|
|
@@ -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 {
|
|
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 {
|
|
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'],
|
|
@@ -13,13 +13,13 @@ import {
|
|
|
13
13
|
export type SerializerCasing = 'camel' | 'snake'
|
|
14
14
|
export type DreamsOrSerializersOrViewModels = DreamSerializable | DreamSerializableArray
|
|
15
15
|
|
|
16
|
-
export interface InternalAnyTypedSerializerAttribute
|
|
16
|
+
export interface InternalAnyTypedSerializerAttribute {
|
|
17
17
|
type: 'attribute'
|
|
18
18
|
name: string
|
|
19
19
|
options: Partial<NonAutomaticSerializerAttributeOptionsWithPossibleDecimalRenderOption>
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export interface InternalAnyTypedSerializerDelegatedAttribute
|
|
22
|
+
export interface InternalAnyTypedSerializerDelegatedAttribute {
|
|
23
23
|
type: 'delegatedAttribute'
|
|
24
24
|
targetName: string
|
|
25
25
|
name: string
|
|
@@ -1 +1 @@
|
|
|
1
|
-
window.navigationData = "data:application/octet-stream;base64,
|
|
1
|
+
window.navigationData = "data:application/octet-stream;base64,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"
|