@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
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UnsupportedValueFromComparisonFunction = void 0;
|
|
4
4
|
exports.default = sortBy;
|
|
5
|
+
/**
|
|
6
|
+
* Returns a copy of the array, sorted by the value returned by calling the function in the second argument on each element in the array
|
|
7
|
+
* Returns a copy of the array sorted by the return value of the function passed as the second argument.
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { sortBy } from '@rvoh/dream'
|
|
10
|
+
*
|
|
11
|
+
* sortBy(['aaa', 'a', 'aa'], (str: string) => str.length)
|
|
12
|
+
* // ['a', 'aa', 'aaa']
|
|
13
|
+
*
|
|
14
|
+
* sortBy(['aaa', 'a', 'aa'], (str: string) => -str.length)
|
|
15
|
+
* // ['aaa', 'aa', 'a']
|
|
16
|
+
*
|
|
17
|
+
* sortBy([5, 3, 7], (num: number) => num)
|
|
18
|
+
* // [3, 5, 7]
|
|
19
|
+
*
|
|
20
|
+
* sortBy([5, 3, 7], (num: number) => -num)
|
|
21
|
+
* // [7, 5, 3]
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
5
24
|
function sortBy(array, valueToCompare) {
|
|
6
25
|
const arrayClone = [...array];
|
|
7
26
|
return arrayClone.sort((a, b) => {
|
|
@@ -11,8 +30,6 @@ function sortBy(array, valueToCompare) {
|
|
|
11
30
|
return aPrime.localeCompare(bPrime);
|
|
12
31
|
if (typeof aPrime === 'number' && typeof bPrime === 'number')
|
|
13
32
|
return aPrime - bPrime;
|
|
14
|
-
if (typeof aPrime === 'bigint' && typeof bPrime === 'bigint')
|
|
15
|
-
return aPrime.toString().localeCompare(bPrime.toString());
|
|
16
33
|
throw new UnsupportedValueFromComparisonFunction(aPrime, bPrime);
|
|
17
34
|
});
|
|
18
35
|
}
|
|
@@ -7,15 +7,41 @@ function sspawn(command, opts = {}) {
|
|
|
7
7
|
return new Promise((accept, reject) => {
|
|
8
8
|
ssspawn(command, opts).on('close', code => {
|
|
9
9
|
if (code !== 0)
|
|
10
|
-
reject(
|
|
10
|
+
reject(code);
|
|
11
11
|
accept({});
|
|
12
12
|
});
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
function ssspawn(command, opts = {}) {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const proc = (0, child_process_1.spawn)(command, {
|
|
17
|
+
// even though github security scans want to remove this,
|
|
18
|
+
// it is necessary to allow the cli util to run as the current
|
|
19
|
+
// user. This is only done to provision a new psychic application,
|
|
20
|
+
// so it is safe from unknown execution contexts.
|
|
18
21
|
shell: true,
|
|
19
22
|
...opts,
|
|
20
23
|
});
|
|
24
|
+
// NOTE: adding this stdout spy so that
|
|
25
|
+
// when this cli utility runs node commands,
|
|
26
|
+
// it can properly hijack the stdout from the command
|
|
27
|
+
proc.stdout.on('data', chunk => {
|
|
28
|
+
const txt = chunk?.toString()?.trim();
|
|
29
|
+
if (typeof txt !== 'string' || !txt)
|
|
30
|
+
return;
|
|
31
|
+
if (opts?.onStdout) {
|
|
32
|
+
opts?.onStdout?.(txt);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
console.log(txt);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
proc.stdout.on('error', err => {
|
|
39
|
+
console.log('sspawn error!');
|
|
40
|
+
console.error(err);
|
|
41
|
+
});
|
|
42
|
+
proc.on('error', err => {
|
|
43
|
+
console.log('sspawn error!');
|
|
44
|
+
console.error(err);
|
|
45
|
+
});
|
|
46
|
+
return proc;
|
|
21
47
|
}
|
|
@@ -4,17 +4,18 @@ exports.default = uniq;
|
|
|
4
4
|
function uniq(arr, toKey = undefined) {
|
|
5
5
|
if (toKey)
|
|
6
6
|
return uniqWith(arr, toKey);
|
|
7
|
-
|
|
8
|
-
return uniqWith(arr, dreamKey);
|
|
9
|
-
else
|
|
10
|
-
return Array.from(new Set(arr));
|
|
7
|
+
return uniqWith(arr, a => String(a));
|
|
11
8
|
}
|
|
12
9
|
function dreamKey(dream) {
|
|
13
10
|
return `${dream.constructor.globalName}:${dream.primaryKeyValue}`;
|
|
14
11
|
}
|
|
15
12
|
function uniqWith(arr, toKey) {
|
|
16
13
|
const map = arr.reduce((acc, val) => {
|
|
17
|
-
|
|
14
|
+
// Prefix with underscore to ensure that the values cannot be interpreted as integers.
|
|
15
|
+
// If they can be interpreted as integers, then the keys are ordered not by the
|
|
16
|
+
// order in which they were added, but in ascending numerical order.
|
|
17
|
+
const key = val?.isDreamInstance ? dreamKey(val) : `_${toKey(val)}`;
|
|
18
|
+
acc[key] ||= val;
|
|
18
19
|
return acc;
|
|
19
20
|
}, {});
|
|
20
21
|
return Object.values(map);
|
package/dist/cjs/src/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.DreamSerializer = exports.Attribute = exports.RendersOne = exports.RendersMany = exports.ops = exports.
|
|
3
|
+
exports.Range = exports.sharedPathPrefix = exports.relativeDreamPath = exports.dreamPath = exports.pascalize = exports.loadRepl = exports.isEmpty = exports.inferSerializerFromDreamOrViewModel = exports.inferSerializerFromDreamClassOrViewModelClass = exports.hyphenize = exports.globalClassNameFromFullyQualifiedModelName = exports.Env = exports.DreamGlam = exports.debug = exports.DateTime = exports.compact = exports.generateDream = exports.capitalize = exports.camelize = exports.CalendarDate = exports.Benchmark = exports.ValidationError = exports.RecordNotFound = exports.GlobalNameNotSet = exports.CreateOrFindByFailedToCreateAndFind = exports.NonLoadedAssociation = exports.Encrypt = exports.Query = exports.DreamTransaction = exports.openapiShorthandPrimitiveTypes = exports.openapiPrimitiveTypes = exports.DreamConst = exports.Dream = exports.DreamApplication = exports.lookupClassByGlobalName = exports.DreamImporter = exports.Decorators = exports.STI = exports.SoftDelete = exports.ReplicaSafe = exports.validateTable = exports.validateColumn = exports.DreamMigrationHelpers = exports.db = exports.pgErrorType = exports.dreamDbConnections = exports.DreamDbConnection = exports.closeAllDbConnections = exports.DreamCLI = exports.DreamBin = void 0;
|
|
4
|
+
exports.DreamSerializer = exports.Attribute = exports.RendersOne = exports.RendersMany = exports.ops = exports.uniq = exports.uncapitalize = exports.standardizeFullyQualifiedModelName = exports.sortBy = exports.sort = exports.snakeify = exports.serializerNameFromFullyQualifiedModelName = exports.round = exports.range = void 0;
|
|
5
5
|
var index_js_1 = require("./bin/index.js");
|
|
6
6
|
Object.defineProperty(exports, "DreamBin", { enumerable: true, get: function () { return index_js_1.default; } });
|
|
7
7
|
var index_js_2 = require("./cli/index.js");
|
|
@@ -36,12 +36,14 @@ var index_js_4 = require("./dream-application/index.js");
|
|
|
36
36
|
Object.defineProperty(exports, "DreamApplication", { enumerable: true, get: function () { return index_js_4.default; } });
|
|
37
37
|
var Dream_js_1 = require("./Dream.js");
|
|
38
38
|
Object.defineProperty(exports, "Dream", { enumerable: true, get: function () { return Dream_js_1.default; } });
|
|
39
|
+
var constants_js_1 = require("./dream/constants.js");
|
|
40
|
+
Object.defineProperty(exports, "DreamConst", { enumerable: true, get: function () { return constants_js_1.DreamConst; } });
|
|
41
|
+
Object.defineProperty(exports, "openapiPrimitiveTypes", { enumerable: true, get: function () { return constants_js_1.openapiPrimitiveTypes; } });
|
|
42
|
+
Object.defineProperty(exports, "openapiShorthandPrimitiveTypes", { enumerable: true, get: function () { return constants_js_1.openapiShorthandPrimitiveTypes; } });
|
|
39
43
|
var DreamTransaction_js_1 = require("./dream/DreamTransaction.js");
|
|
40
44
|
Object.defineProperty(exports, "DreamTransaction", { enumerable: true, get: function () { return DreamTransaction_js_1.default; } });
|
|
41
45
|
var Query_js_1 = require("./dream/Query.js");
|
|
42
46
|
Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return Query_js_1.default; } });
|
|
43
|
-
var types_js_1 = require("./dream/types.js");
|
|
44
|
-
Object.defineProperty(exports, "DreamConst", { enumerable: true, get: function () { return types_js_1.DreamConst; } });
|
|
45
47
|
var index_js_5 = require("./encrypt/index.js");
|
|
46
48
|
Object.defineProperty(exports, "Encrypt", { enumerable: true, get: function () { return index_js_5.default; } });
|
|
47
49
|
var NonLoadedAssociation_js_1 = require("./errors/associations/NonLoadedAssociation.js");
|
|
@@ -102,6 +104,8 @@ var serializerNameFromFullyQualifiedModelName_js_1 = require("./helpers/serializ
|
|
|
102
104
|
Object.defineProperty(exports, "serializerNameFromFullyQualifiedModelName", { enumerable: true, get: function () { return serializerNameFromFullyQualifiedModelName_js_1.default; } });
|
|
103
105
|
var snakeify_js_1 = require("./helpers/snakeify.js");
|
|
104
106
|
Object.defineProperty(exports, "snakeify", { enumerable: true, get: function () { return snakeify_js_1.default; } });
|
|
107
|
+
var sort_js_1 = require("./helpers/sort.js");
|
|
108
|
+
Object.defineProperty(exports, "sort", { enumerable: true, get: function () { return sort_js_1.default; } });
|
|
105
109
|
var sortBy_js_1 = require("./helpers/sortBy.js");
|
|
106
110
|
Object.defineProperty(exports, "sortBy", { enumerable: true, get: function () { return sortBy_js_1.default; } });
|
|
107
111
|
var standardizeFullyQualifiedModelName_js_1 = require("./helpers/standardizeFullyQualifiedModelName.js");
|
|
@@ -110,9 +114,6 @@ var uncapitalize_js_1 = require("./helpers/uncapitalize.js");
|
|
|
110
114
|
Object.defineProperty(exports, "uncapitalize", { enumerable: true, get: function () { return uncapitalize_js_1.default; } });
|
|
111
115
|
var uniq_js_1 = require("./helpers/uniq.js");
|
|
112
116
|
Object.defineProperty(exports, "uniq", { enumerable: true, get: function () { return uniq_js_1.default; } });
|
|
113
|
-
var types_js_2 = require("./openapi/types.js");
|
|
114
|
-
Object.defineProperty(exports, "openapiPrimitiveTypes", { enumerable: true, get: function () { return types_js_2.openapiPrimitiveTypes; } });
|
|
115
|
-
Object.defineProperty(exports, "openapiShorthandPrimitiveTypes", { enumerable: true, get: function () { return types_js_2.openapiShorthandPrimitiveTypes; } });
|
|
116
117
|
var index_js_6 = require("./ops/index.js");
|
|
117
118
|
Object.defineProperty(exports, "ops", { enumerable: true, get: function () { return index_js_6.default; } });
|
|
118
119
|
var RendersMany_js_1 = require("./serializer/decorators/associations/RendersMany.js");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const constants_js_1 = require("../dream/constants.js");
|
|
4
4
|
const ScoreMustBeANormalNumber_js_1 = require("../errors/ops/ScoreMustBeANormalNumber.js");
|
|
5
5
|
class OpsStatement {
|
|
6
6
|
operator;
|
|
@@ -24,10 +24,10 @@ class OpsStatement {
|
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
26
26
|
get shouldBypassWhereStatement() {
|
|
27
|
-
return
|
|
27
|
+
return constants_js_1.TRIGRAM_OPERATORS.includes(this.operator);
|
|
28
28
|
}
|
|
29
29
|
get minTrigramScore() {
|
|
30
|
-
if (
|
|
30
|
+
if (constants_js_1.TRIGRAM_OPERATORS.includes(this.operator)) {
|
|
31
31
|
return this.extraArgs?.score;
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
@@ -16,12 +16,12 @@ const shared_js_1 = require("./shared.js");
|
|
|
16
16
|
*
|
|
17
17
|
* ```ts
|
|
18
18
|
* class User extends ApplicationModel {
|
|
19
|
-
* @
|
|
19
|
+
* @deco.HasOne('Settings')
|
|
20
20
|
* public settings: Settings
|
|
21
21
|
* }
|
|
22
22
|
*
|
|
23
23
|
* class Post extends ApplicationModel {
|
|
24
|
-
* @
|
|
24
|
+
* @deco.BelongsTo('User')
|
|
25
25
|
* public user: User
|
|
26
26
|
* }
|
|
27
27
|
*
|
|
@@ -16,12 +16,12 @@ const shared_js_1 = require("./shared.js");
|
|
|
16
16
|
*
|
|
17
17
|
* ```ts
|
|
18
18
|
* class User extends ApplicationModel {
|
|
19
|
-
* @
|
|
19
|
+
* @deco.HasOne('Settings')
|
|
20
20
|
* public settings: Settings
|
|
21
21
|
* }
|
|
22
22
|
*
|
|
23
23
|
* class Settings extends ApplicationModel {
|
|
24
|
-
* @
|
|
24
|
+
* @deco.BelongsTo('User')
|
|
25
25
|
* public user: User
|
|
26
26
|
* }
|
|
27
27
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const index_js_1 = require("../dream-application/index.js");
|
|
4
|
-
const
|
|
4
|
+
const constants_js_1 = require("../dream/constants.js");
|
|
5
5
|
const GlobalNameNotSet_js_1 = require("../errors/dream-application/GlobalNameNotSet.js");
|
|
6
6
|
const MissingSerializersDefinition_js_1 = require("../errors/MissingSerializersDefinition.js");
|
|
7
7
|
const FailedToRenderThroughAssociationForSerializer_js_1 = require("../errors/serializers/FailedToRenderThroughAssociationForSerializer.js");
|
|
@@ -213,7 +213,7 @@ class DreamSerializer {
|
|
|
213
213
|
return new SerializerClass(associatedData).absorbPassthrough(this).render();
|
|
214
214
|
}
|
|
215
215
|
associatedData(associationStatement) {
|
|
216
|
-
const delegateToPassthroughData = associationStatement.source ===
|
|
216
|
+
const delegateToPassthroughData = associationStatement.source === constants_js_1.DreamConst.passthrough;
|
|
217
217
|
let self = (delegateToPassthroughData ? this.$passthroughData : this.$data);
|
|
218
218
|
if (associationStatement.through) {
|
|
219
219
|
const throughField = associationStatement.through;
|
package/dist/esm/src/Dream.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { pgErrorType } from './db/errors.js';
|
|
2
2
|
import db from './db/index.js';
|
|
3
3
|
import associationToGetterSetterProp from './decorators/field/association/associationToGetterSetterProp.js';
|
|
4
|
-
import { blankAssociationsFactory
|
|
4
|
+
import { blankAssociationsFactory } from './decorators/field/association/shared.js';
|
|
5
5
|
import { blankHooksFactory } from './decorators/field/lifecycle/shared.js';
|
|
6
6
|
import resortAllRecords from './decorators/field/sortable/helpers/resortAllRecords.js';
|
|
7
7
|
import DreamClassTransactionBuilder from './dream/DreamClassTransactionBuilder.js';
|
|
@@ -161,9 +161,9 @@ export default class Dream {
|
|
|
161
161
|
* @internal
|
|
162
162
|
*
|
|
163
163
|
* Model storage for association metadata, set when using the association decorators like:
|
|
164
|
-
* @
|
|
165
|
-
* @
|
|
166
|
-
* @
|
|
164
|
+
* @deco.HasOne
|
|
165
|
+
* @deco.HasMany
|
|
166
|
+
* @deco.BelongsTo
|
|
167
167
|
*/
|
|
168
168
|
static associationMetadataByType = blankAssociationsFactory(this, {
|
|
169
169
|
freeze: true,
|
|
@@ -369,9 +369,8 @@ export default class Dream {
|
|
|
369
369
|
return this.constructor.stiBaseClassOrOwnClassName;
|
|
370
370
|
}
|
|
371
371
|
/**
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
* Shadows .sanitizedName. Returns a string
|
|
372
|
+
* this.constructor.name may be prefixed with an underscore during conversion to Javascript.
|
|
373
|
+
* This method returns the constructor name without a leading underscore.
|
|
375
374
|
*
|
|
376
375
|
* @returns A string
|
|
377
376
|
*/
|
|
@@ -1134,7 +1133,7 @@ export default class Dream {
|
|
|
1134
1133
|
*
|
|
1135
1134
|
* ```ts
|
|
1136
1135
|
* class Post extends ApplicationModel {
|
|
1137
|
-
* @
|
|
1136
|
+
* @deco.Sortable({ scope: ['user']})
|
|
1138
1137
|
* public position: DreamColumn<User, 'position'>
|
|
1139
1138
|
* }
|
|
1140
1139
|
*
|
|
@@ -1164,7 +1163,7 @@ export default class Dream {
|
|
|
1164
1163
|
*
|
|
1165
1164
|
* ```ts
|
|
1166
1165
|
* class User extends ApplicationModel {
|
|
1167
|
-
* @
|
|
1166
|
+
* @deco.Scope()
|
|
1168
1167
|
* public visible(query: Query<User>) {
|
|
1169
1168
|
* return query.where({ hidden: false })
|
|
1170
1169
|
* }
|
|
@@ -1289,10 +1288,10 @@ export default class Dream {
|
|
|
1289
1288
|
*
|
|
1290
1289
|
* ```ts
|
|
1291
1290
|
* class Post {
|
|
1292
|
-
* @
|
|
1291
|
+
* @deco.HasMany('LocalizedText')
|
|
1293
1292
|
* public localizedTexts: LocalizedText[]
|
|
1294
1293
|
*
|
|
1295
|
-
* @
|
|
1294
|
+
* @deco.HasOne('LocalizedText', {
|
|
1296
1295
|
* where: { locale: DreamConst.passthrough },
|
|
1297
1296
|
* })
|
|
1298
1297
|
* public currentLocalizedText: LocalizedText
|
|
@@ -1632,7 +1631,7 @@ export default class Dream {
|
|
|
1632
1631
|
*
|
|
1633
1632
|
* ```ts
|
|
1634
1633
|
* class User extends ApplicationModel {
|
|
1635
|
-
* @
|
|
1634
|
+
* @deco.Validates('presence')
|
|
1636
1635
|
* public email: DreamColumn<User, 'email'>
|
|
1637
1636
|
* }
|
|
1638
1637
|
* const user = User.new()
|
|
@@ -1678,7 +1677,7 @@ export default class Dream {
|
|
|
1678
1677
|
*
|
|
1679
1678
|
* ```ts
|
|
1680
1679
|
* class User extends ApplicationModel {
|
|
1681
|
-
* @
|
|
1680
|
+
* @deco.Validates('presence')
|
|
1682
1681
|
* public email: DreamColumn<User, 'email'>
|
|
1683
1682
|
* }
|
|
1684
1683
|
*
|
|
@@ -2069,7 +2068,7 @@ export default class Dream {
|
|
|
2069
2068
|
* ```ts
|
|
2070
2069
|
* class User extends ApplicationModel {
|
|
2071
2070
|
* ...
|
|
2072
|
-
* @
|
|
2071
|
+
* @deco.Validate()
|
|
2073
2072
|
* public async validateName() {
|
|
2074
2073
|
* if (typeof this.name === 'number')
|
|
2075
2074
|
* this.addError('name', 'name cannot be a number')
|
|
@@ -2697,10 +2696,10 @@ export default class Dream {
|
|
|
2697
2696
|
*
|
|
2698
2697
|
* ```ts
|
|
2699
2698
|
* class Post {
|
|
2700
|
-
* @
|
|
2699
|
+
* @deco.HasMany('LocalizedText')
|
|
2701
2700
|
* public localizedTexts: LocalizedText[]
|
|
2702
2701
|
*
|
|
2703
|
-
* @
|
|
2702
|
+
* @deco.HasOne('LocalizedText', {
|
|
2704
2703
|
* where: { locale: DreamConst.passthrough },
|
|
2705
2704
|
* })
|
|
2706
2705
|
* public currentLocalizedText: LocalizedText
|
|
@@ -2997,7 +2996,7 @@ export default class Dream {
|
|
|
2997
2996
|
*
|
|
2998
2997
|
* ```ts
|
|
2999
2998
|
* class User extends ApplicationModel {
|
|
3000
|
-
* @
|
|
2999
|
+
* @deco.BeforeDestroy()
|
|
3001
3000
|
* public softDelete() {
|
|
3002
3001
|
* await this.update({ deletedAt: DateTime.now() })
|
|
3003
3002
|
* this.preventDeletion()
|
|
@@ -3018,13 +3017,13 @@ export default class Dream {
|
|
|
3018
3017
|
*
|
|
3019
3018
|
* ```ts
|
|
3020
3019
|
* class User extends ApplicationModel {
|
|
3021
|
-
* @
|
|
3020
|
+
* @deco.BeforeDestroy()
|
|
3022
3021
|
* public async softDelete() {
|
|
3023
3022
|
* await this.update({ deletedAt: DateTime.now() })
|
|
3024
3023
|
* this.preventDeletion()
|
|
3025
3024
|
* }
|
|
3026
3025
|
*
|
|
3027
|
-
* @
|
|
3026
|
+
* @deco.BeforeDestroy()
|
|
3028
3027
|
* public async undoSoftDelete() {
|
|
3029
3028
|
* await this.update({ deletedAt: null })
|
|
3030
3029
|
* this.unpreventDeletion()
|
|
@@ -9,18 +9,25 @@ import EnvInternal from '../../helpers/EnvInternal.js';
|
|
|
9
9
|
import dreamPath from '../../helpers/path/dreamPath.js';
|
|
10
10
|
import snakeify from '../../helpers/snakeify.js';
|
|
11
11
|
import sspawn from '../../helpers/sspawn.js';
|
|
12
|
+
import DreamCLI from '../../cli/index.js';
|
|
13
|
+
import colorize from '../../cli/logger/loggable/colorize.js';
|
|
12
14
|
export default async function writeSyncFile() {
|
|
13
15
|
const dbConf = new ConnectionConfRetriever().getConnectionConf('primary');
|
|
14
16
|
const dreamApp = DreamApplication.getOrFail();
|
|
15
17
|
const dbSyncFilePath = path.join(dreamPath('types'), 'db.ts');
|
|
16
18
|
const absoluteDbSyncPath = path.join(dreamApp.projectRoot, dbSyncFilePath);
|
|
17
|
-
await sspawn(`kysely-codegen --url=postgres://${dbConf.user}:${dbConf.password}@${dbConf.host}:${dbConf.port}/${dbConf.name} --out-file=${absoluteDbSyncPath}
|
|
19
|
+
await sspawn(`kysely-codegen --dialect=postgres --url=postgres://${dbConf.user}:${dbConf.password}@${dbConf.host}:${dbConf.port}/${dbConf.name} --out-file=${absoluteDbSyncPath}`, {
|
|
20
|
+
onStdout: message => {
|
|
21
|
+
DreamCLI.logger.logContinueProgress(colorize(`[db]`, { color: 'cyan' }) + ' ' + message, {
|
|
22
|
+
logPrefixColor: 'cyan',
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
});
|
|
18
26
|
// intentionally bypassing helpers here, since they often end up referencing
|
|
19
27
|
// from the dist folder, whereas dirname here is pointing to true src folder.
|
|
20
28
|
const file = (await fs.readFile(absoluteDbSyncPath)).toString();
|
|
21
29
|
const enhancedSchema = enhanceSchema(file);
|
|
22
30
|
await fs.writeFile(absoluteDbSyncPath, enhancedSchema);
|
|
23
|
-
DreamApplication.log('done writing dream sync file!');
|
|
24
31
|
}
|
|
25
32
|
// begin: schema helpers
|
|
26
33
|
function enhanceSchema(file) {
|
|
@@ -55,8 +62,8 @@ export type Timestamp = ColumnType<DateTime | CalendarDate>`);
|
|
|
55
62
|
}
|
|
56
63
|
function addCustomImports(file) {
|
|
57
64
|
const customImports = EnvInternal.boolean('DREAM_CORE_DEVELOPMENT')
|
|
58
|
-
? "import CalendarDate from '../../src/helpers/CalendarDate.js'\nimport { DateTime } from '../../src/helpers/DateTime.js'"
|
|
59
|
-
: "import { CalendarDate, DateTime } from '@rvoh/dream'";
|
|
65
|
+
? "import type CalendarDate from '../../src/helpers/CalendarDate.js'\nimport { type DateTime } from '../../src/helpers/DateTime.js'"
|
|
66
|
+
: "import { type CalendarDate, type DateTime } from '@rvoh/dream'";
|
|
60
67
|
return `${autogeneratedFileDisclaimer()}${customImports}
|
|
61
68
|
${file}`;
|
|
62
69
|
}
|
|
@@ -13,20 +13,25 @@ import sspawn from '../helpers/sspawn.js';
|
|
|
13
13
|
import writeSyncFile from './helpers/sync.js';
|
|
14
14
|
export default class DreamBin {
|
|
15
15
|
static async sync(onSync) {
|
|
16
|
+
DreamCLI.logger.logStartProgress('writing db schema...');
|
|
16
17
|
await writeSyncFile();
|
|
18
|
+
DreamCLI.logger.logEndProgress();
|
|
19
|
+
DreamCLI.logger.logStartProgress('building dream schema...');
|
|
17
20
|
await this.buildDreamSchema();
|
|
21
|
+
DreamCLI.logger.logEndProgress();
|
|
22
|
+
DreamCLI.logger.logStartProgress('running sync hooks...');
|
|
18
23
|
await onSync();
|
|
24
|
+
DreamCLI.logger.logEndProgress();
|
|
19
25
|
}
|
|
20
26
|
static async buildDreamSchema() {
|
|
21
|
-
const spinner = DreamCLI.logger.log('writing dream schema...', { spinner: true });
|
|
22
27
|
await new SchemaBuilder().build();
|
|
23
|
-
spinner.stop();
|
|
24
28
|
}
|
|
25
29
|
static async dbCreate() {
|
|
26
30
|
const connectionRetriever = new ConnectionConfRetriever();
|
|
27
31
|
const primaryDbConf = connectionRetriever.getConnectionConf('primary');
|
|
28
|
-
|
|
32
|
+
DreamCLI.logger.logStartProgress(`creating ${primaryDbConf.name}...`);
|
|
29
33
|
await createDb('primary');
|
|
34
|
+
DreamCLI.logger.logEndProgress();
|
|
30
35
|
// TODO: add support for creating replicas. Began doing it below, but it is very tricky,
|
|
31
36
|
// and we don't need it at the moment, so kicking off for future development when we have more time
|
|
32
37
|
// to flesh this out.
|
|
@@ -35,13 +40,13 @@ export default class DreamBin {
|
|
|
35
40
|
// console.log(`creating ${process.env[replicaDbConf.name]}`)
|
|
36
41
|
// await createDb('replica')
|
|
37
42
|
// }
|
|
38
|
-
spinner.stop();
|
|
39
43
|
}
|
|
40
44
|
static async dbDrop() {
|
|
41
45
|
const connectionRetriever = new ConnectionConfRetriever();
|
|
42
46
|
const primaryDbConf = connectionRetriever.getConnectionConf('primary');
|
|
43
|
-
|
|
47
|
+
DreamCLI.logger.logStartProgress(`dropping ${primaryDbConf.name}...`);
|
|
44
48
|
await _dropDb('primary');
|
|
49
|
+
DreamCLI.logger.logEndProgress();
|
|
45
50
|
// TODO: add support for dropping replicas. Began doing it below, but it is very tricky,
|
|
46
51
|
// and we don't need it at the moment, so kicking off for future development when we have more time
|
|
47
52
|
// to flesh this out.
|
|
@@ -50,27 +55,26 @@ export default class DreamBin {
|
|
|
50
55
|
// console.log(`dropping ${process.env[replicaDbConf.name]}`)
|
|
51
56
|
// await _dropDb('replica')
|
|
52
57
|
// }
|
|
53
|
-
spinner.stop();
|
|
54
58
|
}
|
|
55
59
|
static async dbMigrate() {
|
|
56
60
|
const connectionRetriever = new ConnectionConfRetriever();
|
|
57
61
|
const primaryDbConf = connectionRetriever.getConnectionConf('primary');
|
|
58
|
-
|
|
62
|
+
DreamCLI.logger.logStartProgress(`migrating ${primaryDbConf.name}...`);
|
|
59
63
|
await runMigration({ mode: 'migrate' });
|
|
60
64
|
await this.duplicateDatabase();
|
|
61
|
-
|
|
65
|
+
DreamCLI.logger.logEndProgress();
|
|
62
66
|
}
|
|
63
67
|
static async dbRollback(opts) {
|
|
64
68
|
const connectionRetriever = new ConnectionConfRetriever();
|
|
65
69
|
const primaryDbConf = connectionRetriever.getConnectionConf('primary');
|
|
66
|
-
|
|
70
|
+
DreamCLI.logger.logStartProgress(`rolling back ${primaryDbConf.name}...`);
|
|
67
71
|
let step = opts.steps;
|
|
68
72
|
while (step > 0) {
|
|
69
73
|
await runMigration({ mode: 'rollback' });
|
|
70
74
|
step -= 1;
|
|
71
75
|
}
|
|
72
76
|
await this.duplicateDatabase();
|
|
73
|
-
|
|
77
|
+
DreamCLI.logger.logEndProgress();
|
|
74
78
|
}
|
|
75
79
|
static async generateDream(fullyQualifiedModelName, columnsWithTypes, options) {
|
|
76
80
|
await generateDream({ fullyQualifiedModelName, columnsWithTypes, options });
|
|
@@ -85,8 +89,9 @@ export default class DreamBin {
|
|
|
85
89
|
// It is only made private so that people don't mistakenly try
|
|
86
90
|
// to use it to generate docs for their apps.
|
|
87
91
|
static async buildDocs() {
|
|
88
|
-
DreamCLI.logger.
|
|
92
|
+
DreamCLI.logger.logStartProgress('generating docs...');
|
|
89
93
|
await sspawn('yarn typedoc src/index.ts --tsconfig ./tsconfig.esm.build.json --out docs');
|
|
94
|
+
DreamCLI.logger.logEndProgress();
|
|
90
95
|
}
|
|
91
96
|
static async duplicateDatabase() {
|
|
92
97
|
const parallelTests = DreamApplication.getOrFail().parallelTests;
|
|
@@ -97,22 +102,16 @@ export default class DreamBin {
|
|
|
97
102
|
const client = await loadPgClient({ useSystemDb: true });
|
|
98
103
|
if (process.env.DREAM_CORE_DEVELOPMENT === '1') {
|
|
99
104
|
const replicaTestWorkerDatabaseName = `replica_test_${dbConf.name}`;
|
|
100
|
-
|
|
101
|
-
spinner: true,
|
|
102
|
-
});
|
|
105
|
+
DreamCLI.logger.logContinueProgress(`creating fake replica test database ${replicaTestWorkerDatabaseName}...`);
|
|
103
106
|
await client.query(`DROP DATABASE IF EXISTS ${replicaTestWorkerDatabaseName};`);
|
|
104
107
|
await client.query(`CREATE DATABASE ${replicaTestWorkerDatabaseName} TEMPLATE ${dbConf.name};`);
|
|
105
|
-
spinner.stop();
|
|
106
108
|
}
|
|
107
109
|
for (let i = 2; i <= parallelTests; i++) {
|
|
108
110
|
const workerDatabaseName = `${dbConf.name}_${i}`;
|
|
109
111
|
console.log(`creating duplicate test database ${workerDatabaseName} for concurrent tests`);
|
|
110
|
-
|
|
111
|
-
spinner: true,
|
|
112
|
-
});
|
|
112
|
+
DreamCLI.logger.logContinueProgress(`creating duplicate test database ${workerDatabaseName} for concurrent tests...`);
|
|
113
113
|
await client.query(`DROP DATABASE IF EXISTS ${workerDatabaseName};`);
|
|
114
114
|
await client.query(`CREATE DATABASE ${workerDatabaseName} TEMPLATE ${dbConf.name};`);
|
|
115
|
-
spinner.stop();
|
|
116
115
|
}
|
|
117
116
|
await client.end();
|
|
118
117
|
}
|
|
@@ -1,54 +1,20 @@
|
|
|
1
|
-
import DreamCliLoggableSpinner from './loggable/DreamCliLoggableSpinner.js';
|
|
2
1
|
import DreamCliLoggableText from './loggable/DreamCliLoggableText.js';
|
|
3
2
|
export default class DreamCliLogger {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
permanent: false,
|
|
10
|
-
spinner: 'noise',
|
|
11
|
-
color: spinnerPrefixColor,
|
|
12
|
-
bgColor: spinnerPrefixBgColor,
|
|
13
|
-
})
|
|
14
|
-
: new DreamCliLoggableText(text, {
|
|
15
|
-
permanent,
|
|
16
|
-
logPrefix,
|
|
17
|
-
logPrefixColor: logPrefixColor || (permanent ? 'green' : 'yellow'),
|
|
18
|
-
logPrefixBgColor,
|
|
19
|
-
});
|
|
20
|
-
this.logs.push(loggable);
|
|
21
|
-
// re-render everything
|
|
22
|
-
this.render();
|
|
23
|
-
return loggable;
|
|
24
|
-
}
|
|
25
|
-
render() {
|
|
26
|
-
this.clear();
|
|
27
|
-
let skipNext = false;
|
|
28
|
-
this.logs.forEach(loggable => {
|
|
29
|
-
if (skipNext) {
|
|
30
|
-
skipNext = false;
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
loggable.render();
|
|
3
|
+
log(text, { logPrefix, logPrefixColor, logPrefixBgColor } = {}) {
|
|
4
|
+
const loggable = new DreamCliLoggableText(text, {
|
|
5
|
+
logPrefix,
|
|
6
|
+
logPrefixColor: logPrefixColor || 'green',
|
|
7
|
+
logPrefixBgColor,
|
|
34
8
|
});
|
|
9
|
+
loggable.render();
|
|
35
10
|
}
|
|
36
|
-
|
|
37
|
-
|
|
11
|
+
logStartProgress(text, { logPrefix = '✺ ┌', logPrefixColor, logPrefixBgColor } = {}) {
|
|
12
|
+
this.log(text, { logPrefix, logPrefixColor, logPrefixBgColor });
|
|
38
13
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
* then clear STDOUT and re-render with only
|
|
42
|
-
* the permanent logs remaining.
|
|
43
|
-
*/
|
|
44
|
-
purge() {
|
|
45
|
-
this.logs = this.logs.filter(log => log.permanent);
|
|
46
|
-
this.render();
|
|
14
|
+
logContinueProgress(text, { logPrefix = '✺ ├', logPrefixColor, logPrefixBgColor } = {}) {
|
|
15
|
+
this.log(text, { logPrefix, logPrefixColor, logPrefixBgColor });
|
|
47
16
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// @ts-expect-error this works fine with no args provided
|
|
51
|
-
process.stdout.clearLine?.();
|
|
52
|
-
process.stdout.cursorTo?.(0);
|
|
17
|
+
logEndProgress(text = 'complete', { logPrefix = '✺ └', logPrefixColor, logPrefixBgColor } = {}) {
|
|
18
|
+
this.log(text, { logPrefix, logPrefixColor, logPrefixBgColor });
|
|
53
19
|
}
|
|
54
20
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import colorize from './colorize.js';
|
|
2
2
|
export default class DreamCliLoggable {
|
|
3
|
-
permanent;
|
|
4
3
|
logPrefix;
|
|
5
4
|
logPrefixColor;
|
|
6
5
|
logPrefixBgColor;
|
|
7
|
-
constructor({
|
|
8
|
-
this.permanent = permanent;
|
|
6
|
+
constructor({ logPrefix = '✺', logPrefixColor, logPrefixBgColor, }) {
|
|
9
7
|
this.logPrefix = logPrefix;
|
|
10
8
|
this.logPrefixColor = logPrefixColor;
|
|
11
9
|
this.logPrefixBgColor = logPrefixBgColor;
|
|
@@ -4,8 +4,8 @@ export default class DreamCliLoggableText extends DreamCliLoggable {
|
|
|
4
4
|
text;
|
|
5
5
|
color;
|
|
6
6
|
bgColor;
|
|
7
|
-
constructor(text, {
|
|
8
|
-
super({
|
|
7
|
+
constructor(text, { logPrefix, color, bgColor, logPrefixColor, logPrefixBgColor, }) {
|
|
8
|
+
super({ logPrefix });
|
|
9
9
|
this.text = text;
|
|
10
10
|
this.color = color;
|
|
11
11
|
this.bgColor = bgColor;
|