@rvoh/dream 0.31.0 → 0.31.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -17
- package/dist/cjs/src/Dream.js +17 -18
- package/dist/cjs/src/bin/helpers/sync.js +11 -4
- package/dist/cjs/src/bin/index.js +18 -19
- package/dist/cjs/src/cli/logger/DreamCliLogger.js +12 -46
- package/dist/cjs/src/cli/logger/loggable/DreamCliLoggable.js +1 -3
- package/dist/cjs/src/cli/logger/loggable/DreamCliLoggableText.js +2 -2
- package/dist/cjs/src/decorators/Decorators.js +28 -28
- package/dist/cjs/src/decorators/field/association/BelongsTo.js +2 -2
- package/dist/cjs/src/decorators/field/association/HasMany.js +2 -2
- package/dist/cjs/src/decorators/field/association/HasOne.js +2 -2
- package/dist/cjs/src/decorators/field/association/shared.js +8 -8
- package/dist/cjs/src/decorators/field/lifecycle/AfterCreateCommit.js +1 -1
- package/dist/cjs/src/decorators/field/lifecycle/AfterDestroyCommit.js +1 -1
- package/dist/cjs/src/decorators/field/lifecycle/AfterSaveCommit.js +1 -1
- package/dist/cjs/src/decorators/field/lifecycle/AfterUpdateCommit.js +1 -1
- package/dist/cjs/src/decorators/field/validation/Validates.js +1 -1
- package/dist/cjs/src/dream/DreamClassTransactionBuilder.js +2 -2
- package/dist/cjs/src/dream/Query.js +7 -7
- package/dist/cjs/src/{openapi/types.js → dream/constants.js} +13 -1
- package/dist/cjs/src/dream/internal/similarity/SimilarityBuilder.js +3 -3
- package/dist/cjs/src/helpers/cli/SchemaBuilder.js +5 -5
- package/dist/cjs/src/helpers/cli/generateDream.js +1 -1
- package/dist/cjs/src/helpers/cli/generateDreamContent.js +2 -2
- package/dist/cjs/src/helpers/db/primaryKeyType.js +2 -2
- package/dist/cjs/src/helpers/db/runMigration.js +5 -5
- package/dist/cjs/src/helpers/isEmpty.js +2 -0
- package/dist/cjs/src/helpers/sort.js +24 -0
- package/dist/cjs/src/helpers/sortBy.js +19 -2
- package/dist/cjs/src/helpers/sspawn.js +29 -3
- package/dist/cjs/src/helpers/uniq.js +6 -5
- package/dist/cjs/src/index.js +8 -7
- package/dist/cjs/src/ops/ops-statement.js +3 -3
- package/dist/cjs/src/serializer/decorators/associations/RendersMany.js +2 -2
- package/dist/cjs/src/serializer/decorators/associations/RendersOne.js +2 -2
- package/dist/cjs/src/serializer/index.js +2 -2
- package/dist/esm/src/Dream.js +18 -19
- package/dist/esm/src/bin/helpers/sync.js +11 -4
- package/dist/esm/src/bin/index.js +18 -19
- package/dist/esm/src/cli/logger/DreamCliLogger.js +12 -46
- package/dist/esm/src/cli/logger/loggable/DreamCliLoggable.js +1 -3
- package/dist/esm/src/cli/logger/loggable/DreamCliLoggableText.js +2 -2
- package/dist/esm/src/decorators/Decorators.js +28 -28
- package/dist/esm/src/decorators/field/association/BelongsTo.js +2 -2
- package/dist/esm/src/decorators/field/association/HasMany.js +2 -2
- package/dist/esm/src/decorators/field/association/HasOne.js +2 -2
- package/dist/esm/src/decorators/field/association/shared.js +6 -6
- package/dist/esm/src/decorators/field/lifecycle/AfterCreateCommit.js +1 -1
- package/dist/esm/src/decorators/field/lifecycle/AfterDestroyCommit.js +1 -1
- package/dist/esm/src/decorators/field/lifecycle/AfterSaveCommit.js +1 -1
- package/dist/esm/src/decorators/field/lifecycle/AfterUpdateCommit.js +1 -1
- package/dist/esm/src/decorators/field/validation/Validates.js +1 -1
- package/dist/esm/src/dream/DreamClassTransactionBuilder.js +2 -2
- package/dist/esm/src/dream/Query.js +3 -3
- package/dist/esm/src/{openapi/types.js → dream/constants.js} +12 -0
- package/dist/esm/src/dream/internal/similarity/SimilarityBuilder.js +1 -1
- package/dist/esm/src/errors/associations/InvalidComputedForeignKey.js +1 -1
- package/dist/esm/src/helpers/cli/SchemaBuilder.js +3 -3
- package/dist/esm/src/helpers/cli/generateDream.js +1 -1
- package/dist/esm/src/helpers/cli/generateDreamContent.js +2 -2
- package/dist/esm/src/helpers/db/primaryKeyType.js +1 -1
- package/dist/esm/src/helpers/db/runMigration.js +5 -5
- package/dist/esm/src/helpers/isEmpty.js +2 -0
- package/dist/esm/src/helpers/sort.js +21 -0
- package/dist/esm/src/helpers/sortBy.js +19 -2
- package/dist/esm/src/helpers/sspawn.js +29 -3
- package/dist/esm/src/helpers/uniq.js +6 -5
- package/dist/esm/src/index.js +2 -2
- package/dist/esm/src/ops/ops-statement.js +1 -1
- package/dist/esm/src/serializer/decorators/associations/RendersMany.js +2 -2
- package/dist/esm/src/serializer/decorators/associations/RendersOne.js +2 -2
- package/dist/esm/src/serializer/index.js +1 -1
- package/dist/types/src/Dream.d.ts +28 -28
- package/dist/types/src/cli/logger/DreamCliLogger.d.ts +5 -20
- package/dist/types/src/cli/logger/loggable/DreamCliLoggable.d.ts +2 -4
- package/dist/types/src/cli/logger/loggable/DreamCliLoggableText.d.ts +2 -3
- package/dist/types/src/cli/logger/loggable/colorize.d.ts +1 -1
- package/dist/types/src/db/ConnectedToDB.d.ts +2 -2
- package/dist/types/src/db/ConnectionConfRetriever.d.ts +1 -1
- package/dist/types/src/db/DreamDbConnection.d.ts +1 -1
- package/dist/types/src/db/dataTypes.d.ts +0 -3
- package/dist/types/src/db/index.d.ts +1 -1
- package/dist/types/src/decorators/Decorators.d.ts +28 -28
- package/dist/types/src/decorators/field/association/BelongsTo.d.ts +2 -30
- package/dist/types/src/decorators/field/association/HasMany.d.ts +2 -15
- package/dist/types/src/decorators/field/association/HasOne.d.ts +2 -7
- package/dist/types/src/decorators/field/association/associationToGetterSetterProp.d.ts +4 -4
- package/dist/types/src/decorators/field/association/shared.d.ts +1 -100
- package/dist/types/src/decorators/field/lifecycle/AfterCreate.d.ts +1 -1
- package/dist/types/src/decorators/field/lifecycle/AfterCreateCommit.d.ts +2 -2
- package/dist/types/src/decorators/field/lifecycle/AfterDestroyCommit.d.ts +1 -1
- package/dist/types/src/decorators/field/lifecycle/AfterSave.d.ts +1 -1
- package/dist/types/src/decorators/field/lifecycle/AfterSaveCommit.d.ts +2 -2
- package/dist/types/src/decorators/field/lifecycle/AfterUpdate.d.ts +1 -1
- package/dist/types/src/decorators/field/lifecycle/AfterUpdateCommit.d.ts +2 -2
- package/dist/types/src/decorators/field/lifecycle/BeforeCreate.d.ts +1 -1
- package/dist/types/src/decorators/field/lifecycle/BeforeSave.d.ts +1 -1
- package/dist/types/src/decorators/field/lifecycle/BeforeUpdate.d.ts +1 -1
- package/dist/types/src/decorators/field/lifecycle/shared.d.ts +1 -30
- package/dist/types/src/decorators/field/validation/Validates.d.ts +1 -1
- package/dist/types/src/dream/DreamClassTransactionBuilder.d.ts +8 -6
- package/dist/types/src/dream/DreamInstanceTransactionBuilder.d.ts +4 -2
- package/dist/types/src/dream/DreamTransaction.d.ts +1 -1
- package/dist/types/src/dream/LeftJoinLoadBuilder.d.ts +3 -2
- package/dist/types/src/dream/LoadBuilder.d.ts +3 -2
- package/dist/types/src/dream/Query.d.ts +7 -49
- package/dist/types/src/dream/constants.d.ts +15 -0
- package/dist/types/src/dream/internal/applyScopeBypassingSettingsToQuery.d.ts +1 -1
- package/dist/types/src/dream/internal/associations/associationQuery.d.ts +1 -1
- package/dist/types/src/dream/internal/associations/associationUpdateQuery.d.ts +1 -1
- package/dist/types/src/dream/internal/associations/createAssociation.d.ts +1 -1
- package/dist/types/src/dream/internal/associations/destroyAssociation.d.ts +1 -1
- package/dist/types/src/dream/internal/associations/undestroyAssociation.d.ts +1 -1
- package/dist/types/src/dream/internal/checkSingleValidation.d.ts +1 -1
- package/dist/types/src/dream/internal/destroyOptions.d.ts +1 -1
- package/dist/types/src/dream/internal/orderByDirection.d.ts +1 -1
- package/dist/types/src/dream/internal/runHooksFor.d.ts +1 -1
- package/dist/types/src/dream/internal/safelyRunCommitHooks.d.ts +1 -1
- package/dist/types/src/dream/internal/scopeHelpers.d.ts +1 -1
- package/dist/types/src/dream/internal/similarity/SimilarityBuilder.d.ts +3 -3
- package/dist/types/src/dream/internal/sqlResultToDreamInstance.d.ts +1 -1
- package/dist/types/src/dream-application/index.d.ts +1 -1
- package/dist/types/src/errors/ValidationError.d.ts +1 -1
- package/dist/types/src/errors/associations/CanOnlyPassBelongsToModelParam.d.ts +2 -2
- package/dist/types/src/errors/associations/CannotAssociateThroughPolymorphic.d.ts +2 -2
- package/dist/types/src/errors/associations/CannotCreateAssociationWithThroughContext.d.ts +2 -2
- package/dist/types/src/errors/associations/CannotJoinPolymorphicBelongsToError.d.ts +1 -1
- package/dist/types/src/errors/associations/CannotPassNullOrUndefinedToRequiredBelongsTo.d.ts +1 -1
- package/dist/types/src/errors/associations/InvalidComputedForeignKey.d.ts +1 -1
- package/dist/types/src/errors/associations/MissingRequiredAssociationOnClause.d.ts +2 -2
- package/dist/types/src/errors/associations/MissingThroughAssociation.d.ts +2 -2
- package/dist/types/src/errors/associations/MissingThroughAssociationSource.d.ts +2 -2
- 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/helpers/db/createDb.d.ts +1 -1
- package/dist/types/src/helpers/db/dropDb.d.ts +1 -1
- package/dist/types/src/helpers/db/foreignKeyTypeFromPrimaryKey.d.ts +1 -1
- package/dist/types/src/helpers/inferSerializerFromDreamOrViewModel.d.ts +1 -1
- package/dist/types/src/helpers/isEmpty.d.ts +1 -1
- package/dist/types/src/helpers/objectPathsToArrays.d.ts +1 -1
- package/dist/types/src/helpers/sort.d.ts +15 -0
- package/dist/types/src/helpers/sortBy.d.ts +2 -2
- package/dist/types/src/helpers/sspawn.d.ts +6 -2
- package/dist/types/src/helpers/stringCasing.d.ts +1 -1
- package/dist/types/src/helpers/uniq.d.ts +1 -1
- package/dist/types/src/index.d.ts +6 -4
- package/dist/types/src/ops/index.d.ts +1 -1
- package/dist/types/src/ops/ops-statement.d.ts +1 -1
- package/dist/types/src/serializer/decorators/associations/RendersMany.d.ts +3 -3
- package/dist/types/src/serializer/decorators/associations/RendersOne.d.ts +3 -3
- package/dist/types/src/serializer/decorators/associations/shared.d.ts +2 -1
- package/dist/types/src/serializer/decorators/attribute.d.ts +1 -1
- package/dist/types/src/serializer/decorators/helpers/dreamAttributeOpenapiShape.d.ts +2 -2
- package/dist/types/src/serializer/decorators/helpers/hasSerializersGetter.d.ts +1 -1
- package/dist/types/src/serializer/decorators/helpers/maybeSerializableToDreamSerializerCallbackFunction.d.ts +1 -1
- package/dist/types/src/types/associations/belongsTo.d.ts +76 -0
- package/dist/types/src/types/associations/hasMany.d.ts +80 -0
- package/dist/types/src/types/associations/hasOne.d.ts +26 -0
- package/dist/types/src/types/associations/shared.d.ts +453 -0
- package/dist/types/src/types/db.d.ts +14 -0
- package/dist/types/src/types/dream.d.ts +527 -0
- package/dist/types/src/types/lifecycle.d.ts +50 -0
- package/dist/types/src/types/logger.d.ts +42 -0
- package/dist/types/src/types/openapi.d.ts +243 -0
- package/dist/types/src/types/query.d.ts +127 -0
- package/dist/types/src/types/utils.d.ts +173 -0
- package/dist/types/src/types/validation.d.ts +20 -0
- package/dist/types/src/types/variadic.d.ts +447 -0
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Benchmark.html +2 -2
- package/docs/classes/CalendarDate.html +2 -2
- package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +3 -3
- package/docs/classes/Decorators.html +38 -38
- package/docs/classes/Dream.html +140 -139
- package/docs/classes/DreamApplication.html +4 -4
- package/docs/classes/DreamBin.html +2 -2
- package/docs/classes/DreamCLI.html +4 -4
- package/docs/classes/DreamDbConnection.html +2 -2
- package/docs/classes/DreamGlam.html +2 -2
- package/docs/classes/DreamImporter.html +2 -2
- package/docs/classes/DreamMigrationHelpers.html +7 -7
- package/docs/classes/DreamSerializer.html +2 -2
- package/docs/classes/DreamTransaction.html +2 -2
- package/docs/classes/Encrypt.html +2 -2
- package/docs/classes/Env.html +2 -2
- package/docs/classes/GlobalNameNotSet.html +3 -3
- package/docs/classes/NonLoadedAssociation.html +3 -3
- package/docs/classes/Query.html +51 -51
- package/docs/classes/Range.html +2 -2
- package/docs/classes/RecordNotFound.html +3 -3
- package/docs/classes/ValidationError.html +3 -3
- package/docs/functions/Attribute.html +1 -1
- package/docs/functions/RendersMany.html +2 -2
- package/docs/functions/RendersOne.html +2 -2
- package/docs/functions/ReplicaSafe.html +1 -1
- package/docs/functions/STI.html +1 -1
- package/docs/functions/SoftDelete.html +1 -1
- package/docs/functions/camelize.html +1 -1
- package/docs/functions/capitalize.html +1 -1
- package/docs/functions/closeAllDbConnections.html +1 -1
- package/docs/functions/compact.html +1 -1
- package/docs/functions/db.html +1 -1
- package/docs/functions/debug.html +1 -1
- package/docs/functions/dreamDbConnections.html +1 -1
- package/docs/functions/dreamPath.html +1 -1
- package/docs/functions/generateDream.html +1 -1
- package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/hyphenize.html +1 -1
- package/docs/functions/inferSerializerFromDreamClassOrViewModelClass.html +1 -1
- package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
- package/docs/functions/isEmpty.html +1 -1
- package/docs/functions/loadRepl.html +1 -1
- package/docs/functions/lookupClassByGlobalName.html +1 -1
- package/docs/functions/pascalize.html +1 -1
- package/docs/functions/pgErrorType.html +1 -1
- package/docs/functions/range-1.html +1 -1
- package/docs/functions/relativeDreamPath.html +1 -1
- package/docs/functions/round.html +1 -1
- package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/sharedPathPrefix.html +1 -1
- package/docs/functions/snakeify.html +1 -1
- package/docs/functions/sort.html +6 -0
- package/docs/functions/sortBy.html +6 -1
- package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
- package/docs/functions/uncapitalize.html +1 -1
- package/docs/functions/uniq.html +1 -1
- package/docs/functions/validateColumn.html +1 -1
- package/docs/functions/validateTable.html +1 -1
- package/docs/index.html +5 -5
- package/docs/interfaces/AttributeStatement.html +2 -2
- package/docs/interfaces/DecoratorContext.html +2 -2
- package/docs/interfaces/DreamApplicationInitOptions.html +2 -2
- package/docs/interfaces/DreamApplicationOpts.html +2 -2
- package/docs/interfaces/DreamSerializerAssociationStatement.html +2 -2
- package/docs/interfaces/EncryptOptions.html +2 -2
- package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
- package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
- package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
- package/docs/modules.html +1 -0
- package/docs/types/Camelized.html +1 -1
- package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
- package/docs/types/DateTime.html +1 -1
- package/docs/types/DreamAssociationMetadata.html +1 -1
- package/docs/types/DreamAttributes.html +1 -1
- package/docs/types/DreamClassColumn.html +1 -1
- package/docs/types/DreamColumn.html +1 -1
- package/docs/types/DreamColumnNames.html +1 -1
- package/docs/types/DreamLogLevel.html +1 -1
- package/docs/types/DreamLogger.html +1 -1
- package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
- package/docs/types/DreamParamSafeAttributes.html +1 -1
- package/docs/types/DreamParamSafeColumnNames.html +1 -1
- package/docs/types/DreamSerializerKey.html +1 -1
- package/docs/types/DreamSerializers.html +1 -1
- package/docs/types/DreamTableSchema.html +1 -1
- package/docs/types/DreamVirtualColumns.html +1 -1
- package/docs/types/EncryptAlgorithm.html +1 -1
- package/docs/types/Hyphenized.html +1 -1
- package/docs/types/IdType.html +1 -1
- package/docs/types/OpenapiAllTypes.html +1 -1
- package/docs/types/OpenapiFormats.html +1 -1
- package/docs/types/OpenapiNumberFormats.html +1 -1
- package/docs/types/OpenapiPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiSchemaArray.html +1 -1
- package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
- package/docs/types/OpenapiSchemaBase.html +1 -1
- package/docs/types/OpenapiSchemaBody.html +1 -1
- package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
- package/docs/types/OpenapiSchemaCommonFields.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
- package/docs/types/OpenapiSchemaInteger.html +1 -1
- package/docs/types/OpenapiSchemaNull.html +1 -1
- package/docs/types/OpenapiSchemaNumber.html +1 -1
- package/docs/types/OpenapiSchemaObject.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectBase.html +1 -1
- package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
- package/docs/types/OpenapiSchemaPartialSegment.html +1 -1
- package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaString.html +1 -1
- package/docs/types/OpenapiShorthandAllTypes.html +1 -1
- package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiTypeField.html +1 -1
- package/docs/types/Pascalized.html +1 -1
- package/docs/types/PrimaryKeyType.html +1 -1
- package/docs/types/RoundingPrecision.html +1 -1
- package/docs/types/SerializableClassOrSerializerCallback.html +1 -1
- package/docs/types/SerializableDreamClassOrViewModelClass.html +1 -1
- package/docs/types/SerializableDreamOrViewModel.html +1 -1
- package/docs/types/SerializableTypes.html +1 -1
- package/docs/types/Snakeified.html +1 -1
- package/docs/types/Timestamp.html +1 -1
- package/docs/types/UpdateableAssociationProperties.html +1 -1
- package/docs/types/UpdateableProperties.html +1 -1
- package/docs/types/ValidationType.html +1 -1
- package/docs/types/ViewModelSerializerKey.html +1 -1
- package/docs/types/WhereStatementForDream.html +1 -1
- package/docs/types/WhereStatementForDreamClass.html +1 -1
- package/docs/variables/DateTime-1.html +1 -1
- package/docs/variables/DreamConst.html +1 -1
- package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
- package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
- package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
- package/docs/variables/ops.html +1 -1
- package/docs/variables/primaryKeyTypes.html +1 -1
- package/package.json +2 -3
- package/dist/cjs/src/cli/logger/helpers/createSpinner.js +0 -14
- package/dist/cjs/src/cli/logger/loggable/DreamCliLoggableSpinner.js +0 -31
- package/dist/cjs/src/cli/logger/loggable/spinners.js +0 -1185
- package/dist/cjs/src/db/reflections.js +0 -2
- package/dist/cjs/src/db/types.js +0 -2
- package/dist/cjs/src/decorators/field/validation/shared.js +0 -2
- package/dist/cjs/src/dream/types.js +0 -98
- package/dist/cjs/src/helpers/typeutils.js +0 -2
- package/dist/esm/src/cli/logger/helpers/createSpinner.js +0 -11
- package/dist/esm/src/cli/logger/loggable/DreamCliLoggableSpinner.js +0 -28
- package/dist/esm/src/cli/logger/loggable/spinners.js +0 -1183
- package/dist/esm/src/db/reflections.js +0 -1
- package/dist/esm/src/db/types.js +0 -1
- package/dist/esm/src/decorators/field/validation/shared.js +0 -1
- package/dist/esm/src/dream/types.js +0 -95
- package/dist/esm/src/helpers/typeutils.js +0 -1
- package/dist/types/src/cli/logger/helpers/createSpinner.d.ts +0 -2
- package/dist/types/src/cli/logger/loggable/DreamCliLoggableSpinner.d.ts +0 -21
- package/dist/types/src/cli/logger/loggable/spinners.d.ts +0 -355
- package/dist/types/src/db/reflections.d.ts +0 -5
- package/dist/types/src/db/types.d.ts +0 -1
- package/dist/types/src/decorators/field/validation/shared.d.ts +0 -19
- package/dist/types/src/dream/types.d.ts +0 -184
- package/dist/types/src/helpers/typeutils.d.ts +0 -115
- package/dist/types/src/openapi/types.d.ts +0 -139
package/dist/esm/src/index.js
CHANGED
|
@@ -14,9 +14,9 @@ export { default as DreamImporter } from './dream-application/helpers/DreamImpor
|
|
|
14
14
|
export { default as lookupClassByGlobalName } from './dream-application/helpers/lookupClassByGlobalName.js';
|
|
15
15
|
export { default as DreamApplication, } from './dream-application/index.js';
|
|
16
16
|
export { default as Dream } from './Dream.js';
|
|
17
|
+
export { DreamConst, openapiPrimitiveTypes, openapiShorthandPrimitiveTypes, } from './dream/constants.js';
|
|
17
18
|
export { default as DreamTransaction } from './dream/DreamTransaction.js';
|
|
18
19
|
export { default as Query } from './dream/Query.js';
|
|
19
|
-
export { DreamConst, } from './dream/types.js';
|
|
20
20
|
export { default as Encrypt } from './encrypt/index.js';
|
|
21
21
|
export { default as NonLoadedAssociation } from './errors/associations/NonLoadedAssociation.js';
|
|
22
22
|
export { default as CreateOrFindByFailedToCreateAndFind } from './errors/CreateOrFindByFailedToCreateAndFind.js';
|
|
@@ -46,11 +46,11 @@ export { Range, default as range } from './helpers/range.js';
|
|
|
46
46
|
export { default as round } from './helpers/round.js';
|
|
47
47
|
export { default as serializerNameFromFullyQualifiedModelName } from './helpers/serializerNameFromFullyQualifiedModelName.js';
|
|
48
48
|
export { default as snakeify } from './helpers/snakeify.js';
|
|
49
|
+
export { default as sort } from './helpers/sort.js';
|
|
49
50
|
export { default as sortBy } from './helpers/sortBy.js';
|
|
50
51
|
export { default as standardizeFullyQualifiedModelName } from './helpers/standardizeFullyQualifiedModelName.js';
|
|
51
52
|
export { default as uncapitalize } from './helpers/uncapitalize.js';
|
|
52
53
|
export { default as uniq } from './helpers/uniq.js';
|
|
53
|
-
export { openapiPrimitiveTypes, openapiShorthandPrimitiveTypes, } from './openapi/types.js';
|
|
54
54
|
export { default as ops } from './ops/index.js';
|
|
55
55
|
export { default as RendersMany } from './serializer/decorators/associations/RendersMany.js';
|
|
56
56
|
export { default as RendersOne } from './serializer/decorators/associations/RendersOne.js';
|
|
@@ -13,12 +13,12 @@ import { isSerializable } from './shared.js';
|
|
|
13
13
|
*
|
|
14
14
|
* ```ts
|
|
15
15
|
* class User extends ApplicationModel {
|
|
16
|
-
* @
|
|
16
|
+
* @deco.HasOne('Settings')
|
|
17
17
|
* public settings: Settings
|
|
18
18
|
* }
|
|
19
19
|
*
|
|
20
20
|
* class Post extends ApplicationModel {
|
|
21
|
-
* @
|
|
21
|
+
* @deco.BelongsTo('User')
|
|
22
22
|
* public user: User
|
|
23
23
|
* }
|
|
24
24
|
*
|
|
@@ -13,12 +13,12 @@ import { isSerializable } from './shared.js';
|
|
|
13
13
|
*
|
|
14
14
|
* ```ts
|
|
15
15
|
* class User extends ApplicationModel {
|
|
16
|
-
* @
|
|
16
|
+
* @deco.HasOne('Settings')
|
|
17
17
|
* public settings: Settings
|
|
18
18
|
* }
|
|
19
19
|
*
|
|
20
20
|
* class Settings extends ApplicationModel {
|
|
21
|
-
* @
|
|
21
|
+
* @deco.BelongsTo('User')
|
|
22
22
|
* public user: User
|
|
23
23
|
* }
|
|
24
24
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import DreamApplication from '../dream-application/index.js';
|
|
2
|
-
import { DreamConst
|
|
2
|
+
import { DreamConst } from '../dream/constants.js';
|
|
3
3
|
import GlobalNameNotSet from '../errors/dream-application/GlobalNameNotSet.js';
|
|
4
4
|
import MissingSerializer from '../errors/MissingSerializersDefinition.js';
|
|
5
5
|
import FailedToRenderThroughAssociationForSerializer from '../errors/serializers/FailedToRenderThroughAssociationForSerializer.js';
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { CompiledQuery, DeleteQueryBuilder, InsertQueryBuilder, SelectQueryBuilder, Updateable, UpdateQueryBuilder } from 'kysely';
|
|
2
|
-
import { AssociationTableNames } from './db/reflections.js';
|
|
3
|
-
import { DbConnectionType } from './db/types.js';
|
|
4
2
|
import { VirtualAttributeStatement } from './decorators/field-or-getter/Virtual.js';
|
|
5
|
-
import { AssociationStatementsMap, PassthroughOnClause, WhereStatement } from './decorators/field/association/shared.js';
|
|
6
|
-
import { HookStatement, HookStatementMap } from './decorators/field/lifecycle/shared.js';
|
|
7
3
|
import { SortableFieldConfig } from './decorators/field/sortable/Sortable.js';
|
|
8
|
-
import ValidationStatement, { ValidationType } from './decorators/field/validation/shared.js';
|
|
9
4
|
import { ScopeStatement } from './decorators/static-method/Scope.js';
|
|
10
5
|
import DreamClassTransactionBuilder from './dream/DreamClassTransactionBuilder.js';
|
|
11
6
|
import DreamInstanceTransactionBuilder from './dream/DreamInstanceTransactionBuilder.js';
|
|
@@ -13,8 +8,14 @@ import DreamTransaction from './dream/DreamTransaction.js';
|
|
|
13
8
|
import { DestroyOptions } from './dream/internal/destroyOptions.js';
|
|
14
9
|
import LeftJoinLoadBuilder from './dream/LeftJoinLoadBuilder.js';
|
|
15
10
|
import LoadBuilder from './dream/LoadBuilder.js';
|
|
16
|
-
import Query
|
|
17
|
-
import {
|
|
11
|
+
import Query from './dream/Query.js';
|
|
12
|
+
import { AssociationStatementsMap, PassthroughOnClause, WhereStatement } from './types/associations/shared.js';
|
|
13
|
+
import { AssociationTableNames, DbConnectionType } from './types/db.js';
|
|
14
|
+
import { AllDefaultScopeNames, AssociationNameToDream, AttributeKeys, DefaultOrNamedScopeName, DreamAssociationNames, DreamAssociationNamesWithoutRequiredOnClauses, DreamAttributes, DreamColumnNames, DreamParamSafeColumnNames, DreamSerializeOptions, IdType, JoinOnStatements, NextPreloadArgumentType, OrderDir, PassthroughColumnNames, PluckEachArgs, PrimaryKeyForFind, TableColumnNames, UpdateableAssociationProperties, UpdateableProperties, UpdateablePropertiesForClass } from './types/dream.js';
|
|
15
|
+
import { HookStatement, HookStatementMap } from './types/lifecycle.js';
|
|
16
|
+
import { BaseModelColumnTypes, DefaultQueryTypeOptions, FindEachOpts, QueryWithJoinedAssociationsType, QueryWithJoinedAssociationsTypeAndNoPreload } from './types/query.js';
|
|
17
|
+
import { ValidationStatement, ValidationType } from './types/validation.js';
|
|
18
|
+
import { JoinedAssociation, JoinedAssociationsTypeFromAssociations, RequiredOnClauseKeys, VariadicJoinsArgs, VariadicLeftJoinLoadArgs, VariadicLoadArgs } from './types/variadic.js';
|
|
18
19
|
export default class Dream {
|
|
19
20
|
DB: any;
|
|
20
21
|
/**
|
|
@@ -107,9 +108,9 @@ export default class Dream {
|
|
|
107
108
|
* @internal
|
|
108
109
|
*
|
|
109
110
|
* Model storage for association metadata, set when using the association decorators like:
|
|
110
|
-
* @
|
|
111
|
-
* @
|
|
112
|
-
* @
|
|
111
|
+
* @deco.HasOne
|
|
112
|
+
* @deco.HasMany
|
|
113
|
+
* @deco.BelongsTo
|
|
113
114
|
*/
|
|
114
115
|
protected static associationMetadataByType: AssociationStatementsMap;
|
|
115
116
|
/**
|
|
@@ -297,13 +298,12 @@ export default class Dream {
|
|
|
297
298
|
*/
|
|
298
299
|
protected get stiBaseClassOrOwnClassName(): string;
|
|
299
300
|
/**
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
* Shadows .sanitizedName. Returns a string
|
|
301
|
+
* this.constructor.name may be prefixed with an underscore during conversion to Javascript.
|
|
302
|
+
* This method returns the constructor name without a leading underscore.
|
|
303
303
|
*
|
|
304
304
|
* @returns A string
|
|
305
305
|
*/
|
|
306
|
-
|
|
306
|
+
get sanitizedConstructorName(): string;
|
|
307
307
|
/**
|
|
308
308
|
* @internal
|
|
309
309
|
*
|
|
@@ -929,7 +929,7 @@ export default class Dream {
|
|
|
929
929
|
*
|
|
930
930
|
* ```ts
|
|
931
931
|
* class Post extends ApplicationModel {
|
|
932
|
-
* @
|
|
932
|
+
* @deco.Sortable({ scope: ['user']})
|
|
933
933
|
* public position: DreamColumn<User, 'position'>
|
|
934
934
|
* }
|
|
935
935
|
*
|
|
@@ -952,7 +952,7 @@ export default class Dream {
|
|
|
952
952
|
*
|
|
953
953
|
* ```ts
|
|
954
954
|
* class User extends ApplicationModel {
|
|
955
|
-
* @
|
|
955
|
+
* @deco.Scope()
|
|
956
956
|
* public visible(query: Query<User>) {
|
|
957
957
|
* return query.where({ hidden: false })
|
|
958
958
|
* }
|
|
@@ -1047,10 +1047,10 @@ export default class Dream {
|
|
|
1047
1047
|
*
|
|
1048
1048
|
* ```ts
|
|
1049
1049
|
* class Post {
|
|
1050
|
-
* @
|
|
1050
|
+
* @deco.HasMany('LocalizedText')
|
|
1051
1051
|
* public localizedTexts: LocalizedText[]
|
|
1052
1052
|
*
|
|
1053
|
-
* @
|
|
1053
|
+
* @deco.HasOne('LocalizedText', {
|
|
1054
1054
|
* where: { locale: DreamConst.passthrough },
|
|
1055
1055
|
* })
|
|
1056
1056
|
* public currentLocalizedText: LocalizedText
|
|
@@ -1351,7 +1351,7 @@ export default class Dream {
|
|
|
1351
1351
|
*
|
|
1352
1352
|
* ```ts
|
|
1353
1353
|
* class User extends ApplicationModel {
|
|
1354
|
-
* @
|
|
1354
|
+
* @deco.Validates('presence')
|
|
1355
1355
|
* public email: DreamColumn<User, 'email'>
|
|
1356
1356
|
* }
|
|
1357
1357
|
* const user = User.new()
|
|
@@ -1393,7 +1393,7 @@ export default class Dream {
|
|
|
1393
1393
|
*
|
|
1394
1394
|
* ```ts
|
|
1395
1395
|
* class User extends ApplicationModel {
|
|
1396
|
-
* @
|
|
1396
|
+
* @deco.Validates('presence')
|
|
1397
1397
|
* public email: DreamColumn<User, 'email'>
|
|
1398
1398
|
* }
|
|
1399
1399
|
*
|
|
@@ -1591,7 +1591,7 @@ export default class Dream {
|
|
|
1591
1591
|
* ```ts
|
|
1592
1592
|
* class User extends ApplicationModel {
|
|
1593
1593
|
* ...
|
|
1594
|
-
* @
|
|
1594
|
+
* @deco.Validate()
|
|
1595
1595
|
* public async validateName() {
|
|
1596
1596
|
* if (typeof this.name === 'number')
|
|
1597
1597
|
* this.addError('name', 'name cannot be a number')
|
|
@@ -1948,10 +1948,10 @@ export default class Dream {
|
|
|
1948
1948
|
*
|
|
1949
1949
|
* ```ts
|
|
1950
1950
|
* class Post {
|
|
1951
|
-
* @
|
|
1951
|
+
* @deco.HasMany('LocalizedText')
|
|
1952
1952
|
* public localizedTexts: LocalizedText[]
|
|
1953
1953
|
*
|
|
1954
|
-
* @
|
|
1954
|
+
* @deco.HasOne('LocalizedText', {
|
|
1955
1955
|
* where: { locale: DreamConst.passthrough },
|
|
1956
1956
|
* })
|
|
1957
1957
|
* public currentLocalizedText: LocalizedText
|
|
@@ -2088,7 +2088,7 @@ export default class Dream {
|
|
|
2088
2088
|
* user.assignAttributes({ email: 'my@email', password: 'my password' })
|
|
2089
2089
|
* ```
|
|
2090
2090
|
*/
|
|
2091
|
-
assignAttributes<I extends Dream>(this: I, attributes: UpdateableProperties<I>): Partial<import("./
|
|
2091
|
+
assignAttributes<I extends Dream>(this: I, attributes: UpdateableProperties<I>): Partial<import("./types/utils.js").MergeUnionOfRecordTypes<{
|
|
2092
2092
|
[x: string]: any;
|
|
2093
2093
|
} | Partial<{
|
|
2094
2094
|
[x: string]: any;
|
|
@@ -2105,7 +2105,7 @@ export default class Dream {
|
|
|
2105
2105
|
* user.setAttributes({ email: 'my@email', password: 'my password' })
|
|
2106
2106
|
* ```
|
|
2107
2107
|
*/
|
|
2108
|
-
setAttributes<I extends Dream>(this: I, attributes: UpdateableProperties<I>): Partial<import("./
|
|
2108
|
+
setAttributes<I extends Dream>(this: I, attributes: UpdateableProperties<I>): Partial<import("./types/utils.js").MergeUnionOfRecordTypes<{
|
|
2109
2109
|
[x: string]: any;
|
|
2110
2110
|
} | Partial<{
|
|
2111
2111
|
[x: string]: any;
|
|
@@ -2217,7 +2217,7 @@ export default class Dream {
|
|
|
2217
2217
|
*
|
|
2218
2218
|
* ```ts
|
|
2219
2219
|
* class User extends ApplicationModel {
|
|
2220
|
-
* @
|
|
2220
|
+
* @deco.BeforeDestroy()
|
|
2221
2221
|
* public softDelete() {
|
|
2222
2222
|
* await this.update({ deletedAt: DateTime.now() })
|
|
2223
2223
|
* this.preventDeletion()
|
|
@@ -2236,13 +2236,13 @@ export default class Dream {
|
|
|
2236
2236
|
*
|
|
2237
2237
|
* ```ts
|
|
2238
2238
|
* class User extends ApplicationModel {
|
|
2239
|
-
* @
|
|
2239
|
+
* @deco.BeforeDestroy()
|
|
2240
2240
|
* public async softDelete() {
|
|
2241
2241
|
* await this.update({ deletedAt: DateTime.now() })
|
|
2242
2242
|
* this.preventDeletion()
|
|
2243
2243
|
* }
|
|
2244
2244
|
*
|
|
2245
|
-
* @
|
|
2245
|
+
* @deco.BeforeDestroy()
|
|
2246
2246
|
* public async undoSoftDelete() {
|
|
2247
2247
|
* await this.update({ deletedAt: null })
|
|
2248
2248
|
* this.unpreventDeletion()
|
|
@@ -1,22 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import DreamCliLoggableText from './loggable/DreamCliLoggableText.js';
|
|
1
|
+
import { DreamCliLoggerLogOpts } from '../../types/logger.js';
|
|
3
2
|
export default class DreamCliLogger {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
purge(): void;
|
|
9
|
-
private clear;
|
|
3
|
+
log(text: string, { logPrefix, logPrefixColor, logPrefixBgColor }?: DreamCliLoggerLogOpts): void;
|
|
4
|
+
logStartProgress(text: string, { logPrefix, logPrefixColor, logPrefixBgColor }?: DreamCliLoggerLogOpts): void;
|
|
5
|
+
logContinueProgress(text: string, { logPrefix, logPrefixColor, logPrefixBgColor }?: DreamCliLoggerLogOpts): void;
|
|
6
|
+
logEndProgress(text?: string, { logPrefix, logPrefixColor, logPrefixBgColor }?: DreamCliLoggerLogOpts): void;
|
|
10
7
|
}
|
|
11
|
-
export interface DreamCliLoggerLogOpts<IsSpinner extends boolean> {
|
|
12
|
-
permanent?: boolean;
|
|
13
|
-
spinner?: IsSpinner;
|
|
14
|
-
logPrefix?: string;
|
|
15
|
-
logPrefixColor?: DreamCliForegroundColor;
|
|
16
|
-
logPrefixBgColor?: DreamCliBgColor;
|
|
17
|
-
spinnerPrefixColor?: DreamCliForegroundColor;
|
|
18
|
-
spinnerPrefixBgColor?: DreamCliBgColor;
|
|
19
|
-
}
|
|
20
|
-
export type DreamCliColor = DreamCliForegroundColor | DreamCliBgColor;
|
|
21
|
-
export type DreamCliForegroundColor = 'black' | 'red' | 'redBright' | 'green' | 'greenBright' | 'yellow' | 'yellowBright' | 'blue' | 'blueBright' | 'magenta' | 'magentaBright' | 'cyan' | 'cyanBright' | 'white' | 'whiteBright' | 'gray';
|
|
22
|
-
export type DreamCliBgColor = 'bgBlack' | 'bgRed' | 'bgRedBright' | 'bgGreen' | 'bgGreenBright' | 'bgYellow' | 'bgYellowBright' | 'bgBlue' | 'bgBlueBright' | 'bgMagenta' | 'bgMagentaBright' | 'bgCyan' | 'bgCyanBright' | 'bgWhite' | 'bgWhiteBright';
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { DreamCliBgColor, DreamCliForegroundColor } from '
|
|
1
|
+
import { DreamCliBgColor, DreamCliForegroundColor } from '../../../types/logger.js';
|
|
2
2
|
export default class DreamCliLoggable {
|
|
3
|
-
permanent: boolean;
|
|
4
3
|
logPrefix: string;
|
|
5
4
|
logPrefixColor: DreamCliForegroundColor | undefined;
|
|
6
5
|
logPrefixBgColor: DreamCliBgColor | undefined;
|
|
7
|
-
constructor({
|
|
8
|
-
permanent: boolean;
|
|
6
|
+
constructor({ logPrefix, logPrefixColor, logPrefixBgColor, }: {
|
|
9
7
|
logPrefix?: string;
|
|
10
8
|
logPrefixColor?: DreamCliForegroundColor;
|
|
11
9
|
logPrefixBgColor?: DreamCliBgColor;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { DreamCliBgColor, DreamCliForegroundColor } from '
|
|
1
|
+
import { DreamCliBgColor, DreamCliForegroundColor } from '../../../types/logger.js';
|
|
2
2
|
import DreamCliLoggable from './DreamCliLoggable.js';
|
|
3
3
|
export default class DreamCliLoggableText extends DreamCliLoggable {
|
|
4
4
|
private text;
|
|
5
5
|
private color;
|
|
6
6
|
private bgColor;
|
|
7
|
-
constructor(text: string, {
|
|
8
|
-
permanent: boolean;
|
|
7
|
+
constructor(text: string, { logPrefix, color, bgColor, logPrefixColor, logPrefixBgColor, }: {
|
|
9
8
|
logPrefix?: string;
|
|
10
9
|
color?: DreamCliForegroundColor;
|
|
11
10
|
bgColor?: DreamCliBgColor;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DreamCliBgColor, DreamCliForegroundColor } from '
|
|
1
|
+
import { DreamCliBgColor, DreamCliForegroundColor } from '../../../types/logger.js';
|
|
2
2
|
export default function colorize(text: string, { color, bgColor }: {
|
|
3
3
|
color?: DreamCliForegroundColor;
|
|
4
4
|
bgColor?: DreamCliBgColor;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Kysely, Transaction as KyselyTransaction } from 'kysely';
|
|
2
2
|
import Dream from '../Dream.js';
|
|
3
3
|
import DreamTransaction from '../dream/DreamTransaction.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { DbConnectionType } from '../types/db.js';
|
|
5
|
+
import { DreamConstructorType, SqlCommandType } from '../types/dream.js';
|
|
6
6
|
export default class ConnectedToDB<DreamInstance extends Dream> {
|
|
7
7
|
dreamInstance: DreamInstance;
|
|
8
8
|
protected readonly dreamClass: DreamConstructorType<DreamInstance>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SingleDbCredential } from '../dream-application/index.js';
|
|
2
|
-
import { DbConnectionType } from '
|
|
2
|
+
import { DbConnectionType } from '../types/db.js';
|
|
3
3
|
export default class ConnectionConfRetriever {
|
|
4
4
|
getConnectionConf(connection: DbConnectionType): SingleDbCredential;
|
|
5
5
|
hasReplicaConfig(): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Kysely } from 'kysely';
|
|
2
|
-
import { DbConnectionType } from '
|
|
2
|
+
import { DbConnectionType } from '../types/db.js';
|
|
3
3
|
export default class DreamDbConnection {
|
|
4
4
|
static getConnection<DB>(connectionType: DbConnectionType): Kysely<DB>;
|
|
5
5
|
static dropAllConnections(): Promise<void>;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
export default function dataTypes(): readonly ["bigint", "bigserial", "bit", "bit varying", "boolean", "box", "bytea", "character", "character varying", "char", "cidr", "circle", "citext", "date", "double precision", "inet", "integer", "interval", "json", "jsonb", "line", "lseg", "macaddr", "money", "numeric", "path", "point", "polygon", "real", "smallint", "smallserial", "serial", "text", "time", "time with time zone", "timestamp", "timestamp with time zone", "timestamp without time zone", "tsquery", "tsvector", "txid_snapshot", "uuid", "xml"];
|
|
2
2
|
export declare function isPrimitiveDataType(type: string): boolean;
|
|
3
3
|
export declare const postgresDatatypes: readonly ["bigint", "bigserial", "bit", "bit varying", "boolean", "box", "bytea", "character", "character varying", "char", "cidr", "circle", "citext", "date", "double precision", "inet", "integer", "interval", "json", "jsonb", "line", "lseg", "macaddr", "money", "numeric", "path", "point", "polygon", "real", "smallint", "smallserial", "serial", "text", "time", "time with time zone", "timestamp", "timestamp with time zone", "timestamp without time zone", "tsquery", "tsvector", "txid_snapshot", "uuid", "xml"];
|
|
4
|
-
type NonArrayDbTypes = (typeof postgresDatatypes)[number];
|
|
5
|
-
export type DbTypes = NonArrayDbTypes | `${NonArrayDbTypes}[]`;
|
|
6
|
-
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Kysely } from 'kysely';
|
|
2
2
|
import Dream from '../Dream.js';
|
|
3
3
|
import '../helpers/loadEnv.js';
|
|
4
|
-
import { DbConnectionType } from '
|
|
4
|
+
import { DbConnectionType } from '../types/db.js';
|
|
5
5
|
export default function db<T extends Dream, DB extends T['DB'] = T['DB']>(connectionType?: DbConnectionType): Kysely<DB>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import Dream from '../Dream.js';
|
|
2
|
-
import { DreamColumnNames, GlobalModelNameTableMap, SortableOptions } from '../dream/types.js';
|
|
3
2
|
import { SerializableTypes } from '../serializer/decorators/attribute.js';
|
|
4
|
-
import { NonPolymorphicBelongsToOptions, PolymorphicBelongsToOptions } from '
|
|
5
|
-
import { HasManyOptions, HasManyThroughOptions, PolymorphicHasManyOptions } from '
|
|
6
|
-
import { HasOneOptions, HasOneThroughOptions, PolymorphicHasOneOptions } from '
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
3
|
+
import { NonPolymorphicBelongsToOptions, PolymorphicBelongsToOptions } from '../types/associations/belongsTo.js';
|
|
4
|
+
import { HasManyOptions, HasManyThroughOptions, PolymorphicHasManyOptions } from '../types/associations/hasMany.js';
|
|
5
|
+
import { HasOneOptions, HasOneThroughOptions, PolymorphicHasOneOptions } from '../types/associations/hasOne.js';
|
|
6
|
+
import { DreamColumnNames, GlobalModelNameTableMap, SortableOptions } from '../types/dream.js';
|
|
7
|
+
import { AfterHookOpts, BeforeHookOpts } from '../types/lifecycle.js';
|
|
8
|
+
import { ValidationType } from '../types/validation.js';
|
|
9
9
|
export default class Decorators<T extends Dream> {
|
|
10
10
|
BelongsTo<const AssociationGlobalNameOrNames extends keyof GlobalModelNameTableMap<T> | (keyof GlobalModelNameTableMap<T>)[]>(this: Decorators<T>, globalAssociationNameOrNames: AssociationGlobalNameOrNames, options?: NonPolymorphicBelongsToOptions<T, AssociationGlobalNameOrNames>): any;
|
|
11
11
|
BelongsTo<const AssociationGlobalNameOrNames extends keyof GlobalModelNameTableMap<T> | (keyof GlobalModelNameTableMap<T>)[]>(this: Decorators<T>, globalAssociationNameOrNames: AssociationGlobalNameOrNames, options?: PolymorphicBelongsToOptions<T, AssociationGlobalNameOrNames>): any;
|
|
@@ -22,14 +22,14 @@ export default class Decorators<T extends Dream> {
|
|
|
22
22
|
*
|
|
23
23
|
* ```ts
|
|
24
24
|
* class User {
|
|
25
|
-
* @
|
|
25
|
+
* @deco.Encrypted()
|
|
26
26
|
* // automatically sets `encryptedSsn` to the encrypted value that
|
|
27
27
|
* // `ssn` is set to in new/create/update, e.g., `await user.update({ ssn })`
|
|
28
28
|
* public ssn: string
|
|
29
29
|
*
|
|
30
30
|
* // automatically sets `myEncryptedPhone` to the encrypted value that
|
|
31
31
|
* // `phone` is set to new/create/update, e.g., `await user.update({ phone })`
|
|
32
|
-
* @
|
|
32
|
+
* @deco.Encrypted('myEncryptedPhone)
|
|
33
33
|
* public phone: string
|
|
34
34
|
* }
|
|
35
35
|
* ```
|
|
@@ -44,7 +44,7 @@ export default class Decorators<T extends Dream> {
|
|
|
44
44
|
*
|
|
45
45
|
* ```ts
|
|
46
46
|
* class Collar {
|
|
47
|
-
* @
|
|
47
|
+
* @deco.Scope({ default: true })
|
|
48
48
|
* public static hideHiddenCollars(query: Query<Collar>) {
|
|
49
49
|
* return query.where({ hidden: false })
|
|
50
50
|
* }
|
|
@@ -66,7 +66,7 @@ export default class Decorators<T extends Dream> {
|
|
|
66
66
|
*
|
|
67
67
|
* ```ts
|
|
68
68
|
* class Balloon {
|
|
69
|
-
* @
|
|
69
|
+
* @deco.Sortable({ scope: 'user' })
|
|
70
70
|
* public position: DreamColumn<Balloon, 'position'>
|
|
71
71
|
* }
|
|
72
72
|
* ```
|
|
@@ -82,7 +82,7 @@ export default class Decorators<T extends Dream> {
|
|
|
82
82
|
*
|
|
83
83
|
* ```ts
|
|
84
84
|
* class Sandbag {
|
|
85
|
-
* @
|
|
85
|
+
* @deco.Validate()
|
|
86
86
|
* public validateWeight(this: Sandbag) {
|
|
87
87
|
* if (!this.weight) return
|
|
88
88
|
*
|
|
@@ -105,7 +105,7 @@ export default class Decorators<T extends Dream> {
|
|
|
105
105
|
*
|
|
106
106
|
* ```ts
|
|
107
107
|
* class Balloon {
|
|
108
|
-
* @
|
|
108
|
+
* @deco.Validates('numericality', { min: 0, max: 100 })
|
|
109
109
|
* public volume: DreamColumn<Balloon, 'volume'>
|
|
110
110
|
* }
|
|
111
111
|
* ```
|
|
@@ -143,7 +143,7 @@ export default class Decorators<T extends Dream> {
|
|
|
143
143
|
*
|
|
144
144
|
* ```ts
|
|
145
145
|
* class BodyMeasurement {
|
|
146
|
-
* @
|
|
146
|
+
* @deco.Virtual()
|
|
147
147
|
* public get lbs() {
|
|
148
148
|
* const self: User = this
|
|
149
149
|
* return gramsToLbs(self.getAttribute('grams') ?? 0)
|
|
@@ -154,7 +154,7 @@ export default class Decorators<T extends Dream> {
|
|
|
154
154
|
* self.setAttribute('grams', lbsToGrams(lbs))
|
|
155
155
|
* }
|
|
156
156
|
*
|
|
157
|
-
* @
|
|
157
|
+
* @deco.Virtual()
|
|
158
158
|
* public get kilograms() {
|
|
159
159
|
* const self: User = this
|
|
160
160
|
* return gramsToKilograms(self.getAttribute('grams') ?? 0)
|
|
@@ -170,10 +170,10 @@ export default class Decorators<T extends Dream> {
|
|
|
170
170
|
*
|
|
171
171
|
* ```ts
|
|
172
172
|
* class User {
|
|
173
|
-
* @
|
|
173
|
+
* @deco.Virtual()
|
|
174
174
|
* public password: string
|
|
175
175
|
*
|
|
176
|
-
* @
|
|
176
|
+
* @deco.BeforeSave()
|
|
177
177
|
* public hasPassword() {
|
|
178
178
|
* this.setAttribute('hashedPassword', preferredHashingAlgorithm(this.password))
|
|
179
179
|
* }
|
|
@@ -188,7 +188,7 @@ export default class Decorators<T extends Dream> {
|
|
|
188
188
|
*
|
|
189
189
|
* ```ts
|
|
190
190
|
* class User {
|
|
191
|
-
* @
|
|
191
|
+
* @deco.BeforeCreate()
|
|
192
192
|
* public doSomething() {
|
|
193
193
|
* console.log('hi!')
|
|
194
194
|
* }
|
|
@@ -204,7 +204,7 @@ export default class Decorators<T extends Dream> {
|
|
|
204
204
|
*
|
|
205
205
|
* ```ts
|
|
206
206
|
* class User {
|
|
207
|
-
* @
|
|
207
|
+
* @deco.BeforeSave()
|
|
208
208
|
* public doSomething() {
|
|
209
209
|
* console.log('hi!')
|
|
210
210
|
* }
|
|
@@ -220,7 +220,7 @@ export default class Decorators<T extends Dream> {
|
|
|
220
220
|
*
|
|
221
221
|
* ```ts
|
|
222
222
|
* class User {
|
|
223
|
-
* @
|
|
223
|
+
* @deco.BeforeUpdate()
|
|
224
224
|
* public doSomething() {
|
|
225
225
|
* console.log('hi!')
|
|
226
226
|
* }
|
|
@@ -236,7 +236,7 @@ export default class Decorators<T extends Dream> {
|
|
|
236
236
|
*
|
|
237
237
|
* ```ts
|
|
238
238
|
* class User {
|
|
239
|
-
* @
|
|
239
|
+
* @deco.BeforeDestroy()
|
|
240
240
|
* public doSomething() {
|
|
241
241
|
* console.log('hi!')
|
|
242
242
|
* }
|
|
@@ -251,7 +251,7 @@ export default class Decorators<T extends Dream> {
|
|
|
251
251
|
*
|
|
252
252
|
* ```ts
|
|
253
253
|
* class User {
|
|
254
|
-
* @
|
|
254
|
+
* @deco.AfterCreate()
|
|
255
255
|
* public doSomething() {
|
|
256
256
|
* console.log('hi!')
|
|
257
257
|
* }
|
|
@@ -267,7 +267,7 @@ export default class Decorators<T extends Dream> {
|
|
|
267
267
|
*
|
|
268
268
|
* ```ts
|
|
269
269
|
* class User {
|
|
270
|
-
* @
|
|
270
|
+
* @deco.AfterCreateCommit()
|
|
271
271
|
* public doSomething() {
|
|
272
272
|
* console.log('hi!')
|
|
273
273
|
* }
|
|
@@ -282,7 +282,7 @@ export default class Decorators<T extends Dream> {
|
|
|
282
282
|
*
|
|
283
283
|
* ```ts
|
|
284
284
|
* class User {
|
|
285
|
-
* @
|
|
285
|
+
* @deco.AfterSave()
|
|
286
286
|
* public doSomething() {
|
|
287
287
|
* console.log('hi!')
|
|
288
288
|
* }
|
|
@@ -298,7 +298,7 @@ export default class Decorators<T extends Dream> {
|
|
|
298
298
|
*
|
|
299
299
|
* ```ts
|
|
300
300
|
* class User {
|
|
301
|
-
* @
|
|
301
|
+
* @deco.AfterSaveCommit()
|
|
302
302
|
* public doSomething() {
|
|
303
303
|
* console.log('hi!')
|
|
304
304
|
* }
|
|
@@ -314,7 +314,7 @@ export default class Decorators<T extends Dream> {
|
|
|
314
314
|
*
|
|
315
315
|
* ```ts
|
|
316
316
|
* class User {
|
|
317
|
-
* @
|
|
317
|
+
* @deco.AfterUpdate()
|
|
318
318
|
* public doSomething() {
|
|
319
319
|
* console.log('hi!')
|
|
320
320
|
* }
|
|
@@ -330,7 +330,7 @@ export default class Decorators<T extends Dream> {
|
|
|
330
330
|
*
|
|
331
331
|
* ```ts
|
|
332
332
|
* class User {
|
|
333
|
-
* @
|
|
333
|
+
* @deco.AfterUpdateCommit()
|
|
334
334
|
* public doSomething() {
|
|
335
335
|
* console.log('hi!')
|
|
336
336
|
* }
|
|
@@ -346,7 +346,7 @@ export default class Decorators<T extends Dream> {
|
|
|
346
346
|
*
|
|
347
347
|
* ```ts
|
|
348
348
|
* class User {
|
|
349
|
-
* @
|
|
349
|
+
* @deco.AfterDestroy()
|
|
350
350
|
* public doSomething() {
|
|
351
351
|
* console.log('hi!')
|
|
352
352
|
* }
|
|
@@ -362,7 +362,7 @@ export default class Decorators<T extends Dream> {
|
|
|
362
362
|
*
|
|
363
363
|
* ```ts
|
|
364
364
|
* class User {
|
|
365
|
-
* @
|
|
365
|
+
* @deco.AfterDestroyCommit()
|
|
366
366
|
* public doSomething() {
|
|
367
367
|
* console.log('hi!')
|
|
368
368
|
* }
|
|
@@ -1,33 +1,5 @@
|
|
|
1
|
-
import { AssociationTableNames } from '../../../db/reflections.js';
|
|
2
1
|
import Dream from '../../../Dream.js';
|
|
3
|
-
import {
|
|
2
|
+
import { NonPolymorphicBelongsToOptions, PolymorphicBelongsToOptions } from '../../../types/associations/belongsTo.js';
|
|
3
|
+
import { GlobalModelNameTableMap } from '../../../types/dream.js';
|
|
4
4
|
export default function BelongsTo<BaseInstance extends Dream, AssociationGlobalNameOrNames extends keyof GlobalModelNameTableMap<BaseInstance> | (keyof GlobalModelNameTableMap<BaseInstance>)[]>(globalAssociationNameOrNames: AssociationGlobalNameOrNames, opts?: NonPolymorphicBelongsToOptions<BaseInstance, AssociationGlobalNameOrNames>): any;
|
|
5
5
|
export default function BelongsTo<BaseInstance extends Dream, AssociationGlobalNameOrNames extends keyof GlobalModelNameTableMap<BaseInstance> | (keyof GlobalModelNameTableMap<BaseInstance>)[]>(globalAssociationNameOrNames: AssociationGlobalNameOrNames, opts?: PolymorphicBelongsToOptions<BaseInstance, AssociationGlobalNameOrNames>): any;
|
|
6
|
-
export interface BelongsToStatement<BaseInstance extends Dream, DB, Schema, TableName extends AssociationTableNames<DB, Schema> & keyof DB> {
|
|
7
|
-
modelCB: () => typeof Dream | (typeof Dream)[];
|
|
8
|
-
globalAssociationNameOrNames: string[];
|
|
9
|
-
type: 'BelongsTo';
|
|
10
|
-
as: string;
|
|
11
|
-
primaryKey: (associationInstance?: Dream) => keyof DB[TableName] & string;
|
|
12
|
-
primaryKeyValue: (associationInstance: Dream | null) => any;
|
|
13
|
-
primaryKeyOverride?: (keyof DB[TableName] & string) | null;
|
|
14
|
-
foreignKey: () => DreamColumnNames<BaseInstance> & string;
|
|
15
|
-
foreignKeyTypeField: () => DreamColumnNames<BaseInstance> & string;
|
|
16
|
-
optional: boolean;
|
|
17
|
-
distinct: null;
|
|
18
|
-
polymorphic: boolean;
|
|
19
|
-
withoutDefaultScopes?: DefaultScopeName<BaseInstance>[];
|
|
20
|
-
}
|
|
21
|
-
export interface NonPolymorphicBelongsToOptions<BaseInstance extends Dream, AssociationGlobalNameOrNames extends GlobalModelNames<BaseInstance> | readonly GlobalModelNames<BaseInstance>[], AssociationGlobalName = AssociationGlobalNameOrNames extends Readonly<any[]> ? AssociationGlobalNameOrNames[0] & string : AssociationGlobalNameOrNames & string, AssociationTableName extends AssociationTableNames<BaseInstance['DB'], BaseInstance['schema']> & keyof BaseInstance['DB'] = TableNameForGlobalModelName<BaseInstance, AssociationGlobalName & GlobalModelNames<BaseInstance>> & AssociationTableNames<BaseInstance['DB'], BaseInstance['schema']> & keyof BaseInstance['DB']> {
|
|
22
|
-
foreignKey?: DreamColumnNames<BaseInstance>;
|
|
23
|
-
primaryKeyOverride?: TableColumnNames<BaseInstance['DB'], AssociationTableName> | null;
|
|
24
|
-
optional?: boolean;
|
|
25
|
-
withoutDefaultScopes?: DefaultScopeNameForTable<BaseInstance['schema'], AssociationTableName>[];
|
|
26
|
-
}
|
|
27
|
-
export interface PolymorphicBelongsToOptions<BaseInstance extends Dream, AssociationGlobalNameOrNames extends GlobalModelNames<BaseInstance> | readonly GlobalModelNames<BaseInstance>[], AssociationGlobalName = AssociationGlobalNameOrNames extends Readonly<any[]> ? AssociationGlobalNameOrNames[0] & string : AssociationGlobalNameOrNames & string, AssociationTableName extends AssociationTableNames<BaseInstance['DB'], BaseInstance['schema']> & keyof BaseInstance['DB'] = TableNameForGlobalModelName<BaseInstance, AssociationGlobalName & GlobalModelNames<BaseInstance>> & AssociationTableNames<BaseInstance['DB'], BaseInstance['schema']> & keyof BaseInstance['DB']> {
|
|
28
|
-
foreignKey: DreamColumnNames<BaseInstance>;
|
|
29
|
-
primaryKeyOverride?: TableColumnNames<BaseInstance['DB'], AssociationTableName> | null;
|
|
30
|
-
optional?: boolean;
|
|
31
|
-
polymorphic: boolean;
|
|
32
|
-
withoutDefaultScopes?: DefaultScopeNameForTable<BaseInstance['schema'], AssociationTableName>[];
|
|
33
|
-
}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
import { AssociationTableNames } from '../../../db/reflections.js';
|
|
2
1
|
import Dream from '../../../Dream.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { HasManyOptions, HasManyThroughOptions, PolymorphicHasManyOptions } from '../../../types/associations/hasMany.js';
|
|
3
|
+
import { GlobalModelNameTableMap } from '../../../types/dream.js';
|
|
5
4
|
export default function HasMany<BaseInstance extends Dream, AssociationGlobalName extends keyof GlobalModelNameTableMap<BaseInstance>>(globalAssociationNameOrNames: AssociationGlobalName, opts?: HasManyOptions<BaseInstance, AssociationGlobalName>): any;
|
|
6
5
|
export default function HasMany<BaseInstance extends Dream, AssociationGlobalName extends keyof GlobalModelNameTableMap<BaseInstance>>(globalAssociationNameOrNames: AssociationGlobalName, opts?: HasManyThroughOptions<BaseInstance, AssociationGlobalName>): any;
|
|
7
6
|
export default function HasMany<BaseInstance extends Dream, AssociationGlobalName extends keyof GlobalModelNameTableMap<BaseInstance>>(globalAssociationNameOrNames: AssociationGlobalName, opts?: PolymorphicHasManyOptions<BaseInstance, AssociationGlobalName>): any;
|
|
8
|
-
export type HasManyStatement<BaseInstance extends Dream, DB, Schema, ForeignTableName extends AssociationTableNames<DB, Schema> & keyof DB> = HasStatement<BaseInstance, DB, Schema, ForeignTableName, 'HasMany'> & {
|
|
9
|
-
distinct?: TableColumnNames<DB, ForeignTableName>;
|
|
10
|
-
order?: OrderStatement<DB, Schema, ForeignTableName>;
|
|
11
|
-
};
|
|
12
|
-
interface HasManyOnlyOptions<BaseInstance extends Dream, AssociationGlobalNameOrNames extends GlobalModelNames<BaseInstance> | readonly GlobalModelNames<BaseInstance>[], AssociationGlobalName = AssociationGlobalNameOrNames extends any[] ? AssociationGlobalNameOrNames[0] & string : AssociationGlobalNameOrNames & string, AssociationTableName = TableNameForGlobalModelName<BaseInstance, AssociationGlobalName & GlobalModelNames<BaseInstance>>> {
|
|
13
|
-
distinct?: TableColumnNames<BaseInstance['DB'], AssociationTableName & AssociationTableNames<BaseInstance['DB'], BaseInstance['schema']> & keyof BaseInstance['DB']> | boolean;
|
|
14
|
-
order?: OrderStatement<BaseInstance['DB'], BaseInstance['schema'], AssociationTableName & AssociationTableNames<BaseInstance['DB'], BaseInstance['schema']> & keyof BaseInstance['DB']> | OrderStatement<BaseInstance['DB'], BaseInstance['schema'], AssociationTableName & AssociationTableNames<BaseInstance['DB'], BaseInstance['schema']> & keyof BaseInstance['DB']>[];
|
|
15
|
-
}
|
|
16
|
-
export type HasManyOptions<BaseInstance extends Dream, AssociationGlobalName extends keyof GlobalModelNameTableMap<BaseInstance>> = HasOptions<BaseInstance, AssociationGlobalName> & HasManyOnlyOptions<BaseInstance, AssociationGlobalName>;
|
|
17
|
-
export type PolymorphicHasManyOptions<BaseInstance extends Dream, AssociationGlobalName extends keyof GlobalModelNameTableMap<BaseInstance>> = PolymorphicHasOptions<BaseInstance, AssociationGlobalName> & HasManyOnlyOptions<BaseInstance, AssociationGlobalName>;
|
|
18
|
-
export type HasManyThroughOptions<BaseInstance extends Dream, AssociationGlobalName extends keyof GlobalModelNameTableMap<BaseInstance>> = HasThroughOptions<BaseInstance, AssociationGlobalName> & HasManyOnlyOptions<BaseInstance, AssociationGlobalName>;
|
|
19
|
-
export {};
|