@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/README.md
CHANGED
|
@@ -42,22 +42,22 @@ const user = await User.where({ email: ops.like('%fred@%') })
|
|
|
42
42
|
|
|
43
43
|
class Composition {
|
|
44
44
|
...
|
|
45
|
-
@
|
|
45
|
+
@deco.BeforeCreate()
|
|
46
46
|
public setDefaultContent() {
|
|
47
47
|
if (!this.content) this.content = 'default content'
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
@
|
|
50
|
+
@deco.AfterCreate()
|
|
51
51
|
public conditionallyChangeContentOnCreate() {
|
|
52
52
|
if (this.content === 'change me after create') this.content = 'changed after create'
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
@
|
|
55
|
+
@deco.AfterUpdate()
|
|
56
56
|
public conditionallyChangeContentOnUpdate() {
|
|
57
57
|
if (this.content === 'change me after update') this.content = 'changed after update'
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
@
|
|
60
|
+
@deco.AfterSave()
|
|
61
61
|
public conditionallyChangeContentOnSave() {
|
|
62
62
|
if (this.content === 'change me after save') this.content = 'changed after save'
|
|
63
63
|
}
|
|
@@ -73,11 +73,11 @@ class Composition {
|
|
|
73
73
|
```ts
|
|
74
74
|
export default class User extends Dream {
|
|
75
75
|
...
|
|
76
|
-
@
|
|
77
|
-
@
|
|
76
|
+
@deco.Validates('contains', '@')
|
|
77
|
+
@deco.Validates('presence')
|
|
78
78
|
public email: string
|
|
79
79
|
|
|
80
|
-
@
|
|
80
|
+
@deco.Validates('length', { min: 4, max: 18 })
|
|
81
81
|
public password: string
|
|
82
82
|
...
|
|
83
83
|
}
|
|
@@ -97,13 +97,13 @@ export default class User extends Dream {
|
|
|
97
97
|
// models/user.ts
|
|
98
98
|
class User {
|
|
99
99
|
...
|
|
100
|
-
@
|
|
100
|
+
@deco.HasMany('Composition')
|
|
101
101
|
public compositions: Composition[]
|
|
102
102
|
|
|
103
|
-
@
|
|
103
|
+
@deco.HasOne('Composition')
|
|
104
104
|
public mainComposition: Composition
|
|
105
105
|
|
|
106
|
-
@
|
|
106
|
+
@deco.HasMany('CompositionAsset', {
|
|
107
107
|
through: 'compositions',
|
|
108
108
|
})
|
|
109
109
|
public compositionAssets: CompositionAsset[]
|
|
@@ -112,14 +112,14 @@ class User {
|
|
|
112
112
|
// models/composition.ts
|
|
113
113
|
export default class Composition extends Dream {
|
|
114
114
|
...
|
|
115
|
-
@
|
|
115
|
+
@deco.BelongsTo('User')
|
|
116
116
|
public user: User
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
// models/composition-asset.ts
|
|
120
120
|
export default class CompositionAsset extends Dream {
|
|
121
121
|
...
|
|
122
|
-
@
|
|
122
|
+
@deco.BelongsTo('Composition')
|
|
123
123
|
public composition: Composition
|
|
124
124
|
...
|
|
125
125
|
}
|
|
@@ -136,13 +136,13 @@ export default class CompositionAsset extends Dream {
|
|
|
136
136
|
|
|
137
137
|
```ts
|
|
138
138
|
class User {
|
|
139
|
-
@
|
|
139
|
+
@deco.Scope()
|
|
140
140
|
public static withFunnyName(query: Query<User>) {
|
|
141
141
|
return query.where({ name: 'Chalupas jr' })
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
// this will always fire whenever queries are run against the model
|
|
145
|
-
@
|
|
145
|
+
@deco.Scope({ default: true })
|
|
146
146
|
public static hideDeleted(query: Query<User>) {
|
|
147
147
|
return query.where({ deleted_at: null })
|
|
148
148
|
}
|
|
@@ -354,18 +354,18 @@ const pets = await user
|
|
|
354
354
|
```ts
|
|
355
355
|
@STI(A)
|
|
356
356
|
class B extends A {
|
|
357
|
-
@
|
|
357
|
+
@deco.HasMany('X')
|
|
358
358
|
public xx: X[]
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
@STI(A)
|
|
362
362
|
class C extends A {
|
|
363
|
-
@
|
|
363
|
+
@deco.HasMany('X', { on: { something: true } })
|
|
364
364
|
public xx: X[]
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
class Z extends Dream {
|
|
368
|
-
@
|
|
368
|
+
@deco.HasMany('A')
|
|
369
369
|
public aa: A[]
|
|
370
370
|
}
|
|
371
371
|
|
package/dist/cjs/src/Dream.js
CHANGED
|
@@ -163,9 +163,9 @@ class Dream {
|
|
|
163
163
|
* @internal
|
|
164
164
|
*
|
|
165
165
|
* Model storage for association metadata, set when using the association decorators like:
|
|
166
|
-
* @
|
|
167
|
-
* @
|
|
168
|
-
* @
|
|
166
|
+
* @deco.HasOne
|
|
167
|
+
* @deco.HasMany
|
|
168
|
+
* @deco.BelongsTo
|
|
169
169
|
*/
|
|
170
170
|
static associationMetadataByType = (0, shared_js_1.blankAssociationsFactory)(this, {
|
|
171
171
|
freeze: true,
|
|
@@ -371,9 +371,8 @@ class Dream {
|
|
|
371
371
|
return this.constructor.stiBaseClassOrOwnClassName;
|
|
372
372
|
}
|
|
373
373
|
/**
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
* Shadows .sanitizedName. Returns a string
|
|
374
|
+
* this.constructor.name may be prefixed with an underscore during conversion to Javascript.
|
|
375
|
+
* This method returns the constructor name without a leading underscore.
|
|
377
376
|
*
|
|
378
377
|
* @returns A string
|
|
379
378
|
*/
|
|
@@ -1136,7 +1135,7 @@ class Dream {
|
|
|
1136
1135
|
*
|
|
1137
1136
|
* ```ts
|
|
1138
1137
|
* class Post extends ApplicationModel {
|
|
1139
|
-
* @
|
|
1138
|
+
* @deco.Sortable({ scope: ['user']})
|
|
1140
1139
|
* public position: DreamColumn<User, 'position'>
|
|
1141
1140
|
* }
|
|
1142
1141
|
*
|
|
@@ -1166,7 +1165,7 @@ class Dream {
|
|
|
1166
1165
|
*
|
|
1167
1166
|
* ```ts
|
|
1168
1167
|
* class User extends ApplicationModel {
|
|
1169
|
-
* @
|
|
1168
|
+
* @deco.Scope()
|
|
1170
1169
|
* public visible(query: Query<User>) {
|
|
1171
1170
|
* return query.where({ hidden: false })
|
|
1172
1171
|
* }
|
|
@@ -1291,10 +1290,10 @@ class Dream {
|
|
|
1291
1290
|
*
|
|
1292
1291
|
* ```ts
|
|
1293
1292
|
* class Post {
|
|
1294
|
-
* @
|
|
1293
|
+
* @deco.HasMany('LocalizedText')
|
|
1295
1294
|
* public localizedTexts: LocalizedText[]
|
|
1296
1295
|
*
|
|
1297
|
-
* @
|
|
1296
|
+
* @deco.HasOne('LocalizedText', {
|
|
1298
1297
|
* where: { locale: DreamConst.passthrough },
|
|
1299
1298
|
* })
|
|
1300
1299
|
* public currentLocalizedText: LocalizedText
|
|
@@ -1634,7 +1633,7 @@ class Dream {
|
|
|
1634
1633
|
*
|
|
1635
1634
|
* ```ts
|
|
1636
1635
|
* class User extends ApplicationModel {
|
|
1637
|
-
* @
|
|
1636
|
+
* @deco.Validates('presence')
|
|
1638
1637
|
* public email: DreamColumn<User, 'email'>
|
|
1639
1638
|
* }
|
|
1640
1639
|
* const user = User.new()
|
|
@@ -1680,7 +1679,7 @@ class Dream {
|
|
|
1680
1679
|
*
|
|
1681
1680
|
* ```ts
|
|
1682
1681
|
* class User extends ApplicationModel {
|
|
1683
|
-
* @
|
|
1682
|
+
* @deco.Validates('presence')
|
|
1684
1683
|
* public email: DreamColumn<User, 'email'>
|
|
1685
1684
|
* }
|
|
1686
1685
|
*
|
|
@@ -2071,7 +2070,7 @@ class Dream {
|
|
|
2071
2070
|
* ```ts
|
|
2072
2071
|
* class User extends ApplicationModel {
|
|
2073
2072
|
* ...
|
|
2074
|
-
* @
|
|
2073
|
+
* @deco.Validate()
|
|
2075
2074
|
* public async validateName() {
|
|
2076
2075
|
* if (typeof this.name === 'number')
|
|
2077
2076
|
* this.addError('name', 'name cannot be a number')
|
|
@@ -2699,10 +2698,10 @@ class Dream {
|
|
|
2699
2698
|
*
|
|
2700
2699
|
* ```ts
|
|
2701
2700
|
* class Post {
|
|
2702
|
-
* @
|
|
2701
|
+
* @deco.HasMany('LocalizedText')
|
|
2703
2702
|
* public localizedTexts: LocalizedText[]
|
|
2704
2703
|
*
|
|
2705
|
-
* @
|
|
2704
|
+
* @deco.HasOne('LocalizedText', {
|
|
2706
2705
|
* where: { locale: DreamConst.passthrough },
|
|
2707
2706
|
* })
|
|
2708
2707
|
* public currentLocalizedText: LocalizedText
|
|
@@ -2999,7 +2998,7 @@ class Dream {
|
|
|
2999
2998
|
*
|
|
3000
2999
|
* ```ts
|
|
3001
3000
|
* class User extends ApplicationModel {
|
|
3002
|
-
* @
|
|
3001
|
+
* @deco.BeforeDestroy()
|
|
3003
3002
|
* public softDelete() {
|
|
3004
3003
|
* await this.update({ deletedAt: DateTime.now() })
|
|
3005
3004
|
* this.preventDeletion()
|
|
@@ -3020,13 +3019,13 @@ class Dream {
|
|
|
3020
3019
|
*
|
|
3021
3020
|
* ```ts
|
|
3022
3021
|
* class User extends ApplicationModel {
|
|
3023
|
-
* @
|
|
3022
|
+
* @deco.BeforeDestroy()
|
|
3024
3023
|
* public async softDelete() {
|
|
3025
3024
|
* await this.update({ deletedAt: DateTime.now() })
|
|
3026
3025
|
* this.preventDeletion()
|
|
3027
3026
|
* }
|
|
3028
3027
|
*
|
|
3029
|
-
* @
|
|
3028
|
+
* @deco.BeforeDestroy()
|
|
3030
3029
|
* public async undoSoftDelete() {
|
|
3031
3030
|
* await this.update({ deletedAt: null })
|
|
3032
3031
|
* this.unpreventDeletion()
|
|
@@ -12,18 +12,25 @@ const EnvInternal_js_1 = require("../../helpers/EnvInternal.js");
|
|
|
12
12
|
const dreamPath_js_1 = require("../../helpers/path/dreamPath.js");
|
|
13
13
|
const snakeify_js_1 = require("../../helpers/snakeify.js");
|
|
14
14
|
const sspawn_js_1 = require("../../helpers/sspawn.js");
|
|
15
|
+
const index_js_2 = require("../../cli/index.js");
|
|
16
|
+
const colorize_js_1 = require("../../cli/logger/loggable/colorize.js");
|
|
15
17
|
async function writeSyncFile() {
|
|
16
18
|
const dbConf = new ConnectionConfRetriever_js_1.default().getConnectionConf('primary');
|
|
17
19
|
const dreamApp = index_js_1.default.getOrFail();
|
|
18
20
|
const dbSyncFilePath = path.join((0, dreamPath_js_1.default)('types'), 'db.ts');
|
|
19
21
|
const absoluteDbSyncPath = path.join(dreamApp.projectRoot, dbSyncFilePath);
|
|
20
|
-
await (0, sspawn_js_1.default)(`kysely-codegen --url=postgres://${dbConf.user}:${dbConf.password}@${dbConf.host}:${dbConf.port}/${dbConf.name} --out-file=${absoluteDbSyncPath}
|
|
22
|
+
await (0, sspawn_js_1.default)(`kysely-codegen --dialect=postgres --url=postgres://${dbConf.user}:${dbConf.password}@${dbConf.host}:${dbConf.port}/${dbConf.name} --out-file=${absoluteDbSyncPath}`, {
|
|
23
|
+
onStdout: message => {
|
|
24
|
+
index_js_2.default.logger.logContinueProgress((0, colorize_js_1.default)(`[db]`, { color: 'cyan' }) + ' ' + message, {
|
|
25
|
+
logPrefixColor: 'cyan',
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
});
|
|
21
29
|
// intentionally bypassing helpers here, since they often end up referencing
|
|
22
30
|
// from the dist folder, whereas dirname here is pointing to true src folder.
|
|
23
31
|
const file = (await fs.readFile(absoluteDbSyncPath)).toString();
|
|
24
32
|
const enhancedSchema = enhanceSchema(file);
|
|
25
33
|
await fs.writeFile(absoluteDbSyncPath, enhancedSchema);
|
|
26
|
-
index_js_1.default.log('done writing dream sync file!');
|
|
27
34
|
}
|
|
28
35
|
// begin: schema helpers
|
|
29
36
|
function enhanceSchema(file) {
|
|
@@ -58,8 +65,8 @@ export type Timestamp = ColumnType<DateTime | CalendarDate>`);
|
|
|
58
65
|
}
|
|
59
66
|
function addCustomImports(file) {
|
|
60
67
|
const customImports = EnvInternal_js_1.default.boolean('DREAM_CORE_DEVELOPMENT')
|
|
61
|
-
? "import CalendarDate from '../../src/helpers/CalendarDate.js'\nimport { DateTime } from '../../src/helpers/DateTime.js'"
|
|
62
|
-
: "import { CalendarDate, DateTime } from '@rvoh/dream'";
|
|
68
|
+
? "import type CalendarDate from '../../src/helpers/CalendarDate.js'\nimport { type DateTime } from '../../src/helpers/DateTime.js'"
|
|
69
|
+
: "import { type CalendarDate, type DateTime } from '@rvoh/dream'";
|
|
63
70
|
return `${(0, autogeneratedFileMessage_js_1.default)()}${customImports}
|
|
64
71
|
${file}`;
|
|
65
72
|
}
|
|
@@ -15,20 +15,25 @@ const sspawn_js_1 = require("../helpers/sspawn.js");
|
|
|
15
15
|
const sync_js_1 = require("./helpers/sync.js");
|
|
16
16
|
class DreamBin {
|
|
17
17
|
static async sync(onSync) {
|
|
18
|
+
index_js_1.default.logger.logStartProgress('writing db schema...');
|
|
18
19
|
await (0, sync_js_1.default)();
|
|
20
|
+
index_js_1.default.logger.logEndProgress();
|
|
21
|
+
index_js_1.default.logger.logStartProgress('building dream schema...');
|
|
19
22
|
await this.buildDreamSchema();
|
|
23
|
+
index_js_1.default.logger.logEndProgress();
|
|
24
|
+
index_js_1.default.logger.logStartProgress('running sync hooks...');
|
|
20
25
|
await onSync();
|
|
26
|
+
index_js_1.default.logger.logEndProgress();
|
|
21
27
|
}
|
|
22
28
|
static async buildDreamSchema() {
|
|
23
|
-
const spinner = index_js_1.default.logger.log('writing dream schema...', { spinner: true });
|
|
24
29
|
await new SchemaBuilder_js_1.default().build();
|
|
25
|
-
spinner.stop();
|
|
26
30
|
}
|
|
27
31
|
static async dbCreate() {
|
|
28
32
|
const connectionRetriever = new ConnectionConfRetriever_js_1.default();
|
|
29
33
|
const primaryDbConf = connectionRetriever.getConnectionConf('primary');
|
|
30
|
-
|
|
34
|
+
index_js_1.default.logger.logStartProgress(`creating ${primaryDbConf.name}...`);
|
|
31
35
|
await (0, createDb_js_1.default)('primary');
|
|
36
|
+
index_js_1.default.logger.logEndProgress();
|
|
32
37
|
// TODO: add support for creating replicas. Began doing it below, but it is very tricky,
|
|
33
38
|
// and we don't need it at the moment, so kicking off for future development when we have more time
|
|
34
39
|
// to flesh this out.
|
|
@@ -37,13 +42,13 @@ class DreamBin {
|
|
|
37
42
|
// console.log(`creating ${process.env[replicaDbConf.name]}`)
|
|
38
43
|
// await createDb('replica')
|
|
39
44
|
// }
|
|
40
|
-
spinner.stop();
|
|
41
45
|
}
|
|
42
46
|
static async dbDrop() {
|
|
43
47
|
const connectionRetriever = new ConnectionConfRetriever_js_1.default();
|
|
44
48
|
const primaryDbConf = connectionRetriever.getConnectionConf('primary');
|
|
45
|
-
|
|
49
|
+
index_js_1.default.logger.logStartProgress(`dropping ${primaryDbConf.name}...`);
|
|
46
50
|
await (0, dropDb_js_1.default)('primary');
|
|
51
|
+
index_js_1.default.logger.logEndProgress();
|
|
47
52
|
// TODO: add support for dropping replicas. Began doing it below, but it is very tricky,
|
|
48
53
|
// and we don't need it at the moment, so kicking off for future development when we have more time
|
|
49
54
|
// to flesh this out.
|
|
@@ -52,27 +57,26 @@ class DreamBin {
|
|
|
52
57
|
// console.log(`dropping ${process.env[replicaDbConf.name]}`)
|
|
53
58
|
// await _dropDb('replica')
|
|
54
59
|
// }
|
|
55
|
-
spinner.stop();
|
|
56
60
|
}
|
|
57
61
|
static async dbMigrate() {
|
|
58
62
|
const connectionRetriever = new ConnectionConfRetriever_js_1.default();
|
|
59
63
|
const primaryDbConf = connectionRetriever.getConnectionConf('primary');
|
|
60
|
-
|
|
64
|
+
index_js_1.default.logger.logStartProgress(`migrating ${primaryDbConf.name}...`);
|
|
61
65
|
await (0, runMigration_js_1.default)({ mode: 'migrate' });
|
|
62
66
|
await this.duplicateDatabase();
|
|
63
|
-
|
|
67
|
+
index_js_1.default.logger.logEndProgress();
|
|
64
68
|
}
|
|
65
69
|
static async dbRollback(opts) {
|
|
66
70
|
const connectionRetriever = new ConnectionConfRetriever_js_1.default();
|
|
67
71
|
const primaryDbConf = connectionRetriever.getConnectionConf('primary');
|
|
68
|
-
|
|
72
|
+
index_js_1.default.logger.logStartProgress(`rolling back ${primaryDbConf.name}...`);
|
|
69
73
|
let step = opts.steps;
|
|
70
74
|
while (step > 0) {
|
|
71
75
|
await (0, runMigration_js_1.default)({ mode: 'rollback' });
|
|
72
76
|
step -= 1;
|
|
73
77
|
}
|
|
74
78
|
await this.duplicateDatabase();
|
|
75
|
-
|
|
79
|
+
index_js_1.default.logger.logEndProgress();
|
|
76
80
|
}
|
|
77
81
|
static async generateDream(fullyQualifiedModelName, columnsWithTypes, options) {
|
|
78
82
|
await (0, generateDream_js_1.default)({ fullyQualifiedModelName, columnsWithTypes, options });
|
|
@@ -87,8 +91,9 @@ class DreamBin {
|
|
|
87
91
|
// It is only made private so that people don't mistakenly try
|
|
88
92
|
// to use it to generate docs for their apps.
|
|
89
93
|
static async buildDocs() {
|
|
90
|
-
index_js_1.default.logger.
|
|
94
|
+
index_js_1.default.logger.logStartProgress('generating docs...');
|
|
91
95
|
await (0, sspawn_js_1.default)('yarn typedoc src/index.ts --tsconfig ./tsconfig.esm.build.json --out docs');
|
|
96
|
+
index_js_1.default.logger.logEndProgress();
|
|
92
97
|
}
|
|
93
98
|
static async duplicateDatabase() {
|
|
94
99
|
const parallelTests = index_js_2.default.getOrFail().parallelTests;
|
|
@@ -99,22 +104,16 @@ class DreamBin {
|
|
|
99
104
|
const client = await (0, loadPgClient_js_1.default)({ useSystemDb: true });
|
|
100
105
|
if (process.env.DREAM_CORE_DEVELOPMENT === '1') {
|
|
101
106
|
const replicaTestWorkerDatabaseName = `replica_test_${dbConf.name}`;
|
|
102
|
-
|
|
103
|
-
spinner: true,
|
|
104
|
-
});
|
|
107
|
+
index_js_1.default.logger.logContinueProgress(`creating fake replica test database ${replicaTestWorkerDatabaseName}...`);
|
|
105
108
|
await client.query(`DROP DATABASE IF EXISTS ${replicaTestWorkerDatabaseName};`);
|
|
106
109
|
await client.query(`CREATE DATABASE ${replicaTestWorkerDatabaseName} TEMPLATE ${dbConf.name};`);
|
|
107
|
-
spinner.stop();
|
|
108
110
|
}
|
|
109
111
|
for (let i = 2; i <= parallelTests; i++) {
|
|
110
112
|
const workerDatabaseName = `${dbConf.name}_${i}`;
|
|
111
113
|
console.log(`creating duplicate test database ${workerDatabaseName} for concurrent tests`);
|
|
112
|
-
|
|
113
|
-
spinner: true,
|
|
114
|
-
});
|
|
114
|
+
index_js_1.default.logger.logContinueProgress(`creating duplicate test database ${workerDatabaseName} for concurrent tests...`);
|
|
115
115
|
await client.query(`DROP DATABASE IF EXISTS ${workerDatabaseName};`);
|
|
116
116
|
await client.query(`CREATE DATABASE ${workerDatabaseName} TEMPLATE ${dbConf.name};`);
|
|
117
|
-
spinner.stop();
|
|
118
117
|
}
|
|
119
118
|
await client.end();
|
|
120
119
|
}
|
|
@@ -1,57 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const DreamCliLoggableSpinner_js_1 = require("./loggable/DreamCliLoggableSpinner.js");
|
|
4
3
|
const DreamCliLoggableText_js_1 = require("./loggable/DreamCliLoggableText.js");
|
|
5
4
|
class DreamCliLogger {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
permanent: false,
|
|
12
|
-
spinner: 'noise',
|
|
13
|
-
color: spinnerPrefixColor,
|
|
14
|
-
bgColor: spinnerPrefixBgColor,
|
|
15
|
-
})
|
|
16
|
-
: new DreamCliLoggableText_js_1.default(text, {
|
|
17
|
-
permanent,
|
|
18
|
-
logPrefix,
|
|
19
|
-
logPrefixColor: logPrefixColor || (permanent ? 'green' : 'yellow'),
|
|
20
|
-
logPrefixBgColor,
|
|
21
|
-
});
|
|
22
|
-
this.logs.push(loggable);
|
|
23
|
-
// re-render everything
|
|
24
|
-
this.render();
|
|
25
|
-
return loggable;
|
|
26
|
-
}
|
|
27
|
-
render() {
|
|
28
|
-
this.clear();
|
|
29
|
-
let skipNext = false;
|
|
30
|
-
this.logs.forEach(loggable => {
|
|
31
|
-
if (skipNext) {
|
|
32
|
-
skipNext = false;
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
loggable.render();
|
|
5
|
+
log(text, { logPrefix, logPrefixColor, logPrefixBgColor } = {}) {
|
|
6
|
+
const loggable = new DreamCliLoggableText_js_1.default(text, {
|
|
7
|
+
logPrefix,
|
|
8
|
+
logPrefixColor: logPrefixColor || 'green',
|
|
9
|
+
logPrefixBgColor,
|
|
36
10
|
});
|
|
11
|
+
loggable.render();
|
|
37
12
|
}
|
|
38
|
-
|
|
39
|
-
|
|
13
|
+
logStartProgress(text, { logPrefix = '✺ ┌', logPrefixColor, logPrefixBgColor } = {}) {
|
|
14
|
+
this.log(text, { logPrefix, logPrefixColor, logPrefixBgColor });
|
|
40
15
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
* then clear STDOUT and re-render with only
|
|
44
|
-
* the permanent logs remaining.
|
|
45
|
-
*/
|
|
46
|
-
purge() {
|
|
47
|
-
this.logs = this.logs.filter(log => log.permanent);
|
|
48
|
-
this.render();
|
|
16
|
+
logContinueProgress(text, { logPrefix = '✺ ├', logPrefixColor, logPrefixBgColor } = {}) {
|
|
17
|
+
this.log(text, { logPrefix, logPrefixColor, logPrefixBgColor });
|
|
49
18
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// @ts-expect-error this works fine with no args provided
|
|
53
|
-
process.stdout.clearLine?.();
|
|
54
|
-
process.stdout.cursorTo?.(0);
|
|
19
|
+
logEndProgress(text = 'complete', { logPrefix = '✺ └', logPrefixColor, logPrefixBgColor } = {}) {
|
|
20
|
+
this.log(text, { logPrefix, logPrefixColor, logPrefixBgColor });
|
|
55
21
|
}
|
|
56
22
|
}
|
|
57
23
|
exports.default = DreamCliLogger;
|
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const colorize_js_1 = require("./colorize.js");
|
|
4
4
|
class DreamCliLoggable {
|
|
5
|
-
permanent;
|
|
6
5
|
logPrefix;
|
|
7
6
|
logPrefixColor;
|
|
8
7
|
logPrefixBgColor;
|
|
9
|
-
constructor({
|
|
10
|
-
this.permanent = permanent;
|
|
8
|
+
constructor({ logPrefix = '✺', logPrefixColor, logPrefixBgColor, }) {
|
|
11
9
|
this.logPrefix = logPrefix;
|
|
12
10
|
this.logPrefixColor = logPrefixColor;
|
|
13
11
|
this.logPrefixBgColor = logPrefixBgColor;
|
|
@@ -6,8 +6,8 @@ class DreamCliLoggableText extends DreamCliLoggable_js_1.default {
|
|
|
6
6
|
text;
|
|
7
7
|
color;
|
|
8
8
|
bgColor;
|
|
9
|
-
constructor(text, {
|
|
10
|
-
super({
|
|
9
|
+
constructor(text, { logPrefix, color, bgColor, logPrefixColor, logPrefixBgColor, }) {
|
|
10
|
+
super({ logPrefix });
|
|
11
11
|
this.text = text;
|
|
12
12
|
this.color = color;
|
|
13
13
|
this.bgColor = bgColor;
|