@rvoh/dream 0.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +382 -0
- package/boilerplate/app/models/ApplicationModel.ts +14 -0
- package/boilerplate/app/serializers/.gitkeep +0 -0
- package/boilerplate/bin/esm.js +19 -0
- package/boilerplate/cli/helpers/initializeDreamApplication.ts +6 -0
- package/boilerplate/cli/index.ts +22 -0
- package/boilerplate/conf/inflections.ts +5 -0
- package/boilerplate/conf/loadEnv.ts +4 -0
- package/boilerplate/conf/repl.ts +11 -0
- package/boilerplate/eslint.config.js +21 -0
- package/boilerplate/package.json +42 -0
- package/boilerplate/tsconfig.build.json +41 -0
- package/boilerplate/tsconfig.json +12 -0
- package/boilerplate/types/db.ts +5 -0
- package/boilerplate/types/dream.ts +3 -0
- package/dist/cjs/boilerplate/package.json +42 -0
- package/dist/cjs/src/Dream.js +2984 -0
- package/dist/cjs/src/bin/helpers/sync.js +109 -0
- package/dist/cjs/src/bin/index.js +107 -0
- package/dist/cjs/src/cli/index.js +155 -0
- package/dist/cjs/src/db/ConnectedToDB.js +43 -0
- package/dist/cjs/src/db/ConnectionConfRetriever.js +22 -0
- package/dist/cjs/src/db/DreamDbConnection.js +77 -0
- package/dist/cjs/src/db/dataTypes.js +58 -0
- package/dist/cjs/src/db/errors.js +17 -0
- package/dist/cjs/src/db/index.js +12 -0
- package/dist/cjs/src/db/migration-helpers/DreamMigrationHelpers.js +193 -0
- package/dist/cjs/src/db/reflections.js +2 -0
- package/dist/cjs/src/db/types.js +2 -0
- package/dist/cjs/src/db/validators/validateColumn.js +11 -0
- package/dist/cjs/src/db/validators/validateTable.js +9 -0
- package/dist/cjs/src/db/validators/validateTableAlias.js +55 -0
- package/dist/cjs/src/decorators/DecoratorContextType.js +2 -0
- package/dist/cjs/src/decorators/Decorators.js +326 -0
- package/dist/cjs/src/decorators/Encrypted.js +83 -0
- package/dist/cjs/src/decorators/ReplicaSafe.js +12 -0
- package/dist/cjs/src/decorators/STI.js +35 -0
- package/dist/cjs/src/decorators/Scope.js +31 -0
- package/dist/cjs/src/decorators/SoftDelete.js +54 -0
- package/dist/cjs/src/decorators/Virtual.js +28 -0
- package/dist/cjs/src/decorators/associations/BelongsTo.js +77 -0
- package/dist/cjs/src/decorators/associations/HasMany.js +100 -0
- package/dist/cjs/src/decorators/associations/HasOne.js +96 -0
- package/dist/cjs/src/decorators/associations/associationToGetterSetterProp.js +6 -0
- package/dist/cjs/src/decorators/associations/shared.js +132 -0
- package/dist/cjs/src/decorators/helpers/freezeBaseClassArrayMap.js +10 -0
- package/dist/cjs/src/decorators/hooks/AfterCreate.js +26 -0
- package/dist/cjs/src/decorators/hooks/AfterCreateCommit.js +43 -0
- package/dist/cjs/src/decorators/hooks/AfterDestroy.js +25 -0
- package/dist/cjs/src/decorators/hooks/AfterDestroyCommit.js +40 -0
- package/dist/cjs/src/decorators/hooks/AfterSave.js +26 -0
- package/dist/cjs/src/decorators/hooks/AfterSaveCommit.js +43 -0
- package/dist/cjs/src/decorators/hooks/AfterUpdate.js +26 -0
- package/dist/cjs/src/decorators/hooks/AfterUpdateCommit.js +43 -0
- package/dist/cjs/src/decorators/hooks/BeforeCreate.js +26 -0
- package/dist/cjs/src/decorators/hooks/BeforeDestroy.js +25 -0
- package/dist/cjs/src/decorators/hooks/BeforeSave.js +26 -0
- package/dist/cjs/src/decorators/hooks/BeforeUpdate.js +26 -0
- package/dist/cjs/src/decorators/hooks/shared.js +23 -0
- package/dist/cjs/src/decorators/sortable/Sortable.js +160 -0
- package/dist/cjs/src/decorators/sortable/helpers/applySortableScopeToQuery.js +17 -0
- package/dist/cjs/src/decorators/sortable/helpers/clearCachedSortableValues.js +11 -0
- package/dist/cjs/src/decorators/sortable/helpers/decrementScopedRecordsGreaterThanPosition.js +26 -0
- package/dist/cjs/src/decorators/sortable/helpers/getColumnForSortableScope.js +18 -0
- package/dist/cjs/src/decorators/sortable/helpers/isSortedCorrectly.js +7 -0
- package/dist/cjs/src/decorators/sortable/helpers/positionIsInvalid.js +11 -0
- package/dist/cjs/src/decorators/sortable/helpers/resortAllRecords.js +38 -0
- package/dist/cjs/src/decorators/sortable/helpers/scopeArray.js +10 -0
- package/dist/cjs/src/decorators/sortable/helpers/setPosition.js +158 -0
- package/dist/cjs/src/decorators/sortable/helpers/sortableCacheKeyName.js +7 -0
- package/dist/cjs/src/decorators/sortable/helpers/sortableCacheValuesName.js +7 -0
- package/dist/cjs/src/decorators/sortable/helpers/sortableQueryExcludingDream.js +10 -0
- package/dist/cjs/src/decorators/sortable/hooks/afterSortableCreate.js +18 -0
- package/dist/cjs/src/decorators/sortable/hooks/afterSortableDestroy.js +14 -0
- package/dist/cjs/src/decorators/sortable/hooks/afterSortableUpdate.js +31 -0
- package/dist/cjs/src/decorators/sortable/hooks/beforeSortableSave.js +65 -0
- package/dist/cjs/src/decorators/validations/Validate.js +22 -0
- package/dist/cjs/src/decorators/validations/Validates.js +70 -0
- package/dist/cjs/src/decorators/validations/shared.js +2 -0
- package/dist/cjs/src/dream/DreamClassTransactionBuilder.js +592 -0
- package/dist/cjs/src/dream/DreamInstanceTransactionBuilder.js +480 -0
- package/dist/cjs/src/dream/DreamTransaction.js +26 -0
- package/dist/cjs/src/dream/LeftJoinLoadBuilder.js +77 -0
- package/dist/cjs/src/dream/LoadBuilder.js +68 -0
- package/dist/cjs/src/dream/Query.js +2618 -0
- package/dist/cjs/src/dream/internal/applyScopeBypassingSettingsToQuery.js +11 -0
- package/dist/cjs/src/dream/internal/associations/associationQuery.js +23 -0
- package/dist/cjs/src/dream/internal/associations/associationUpdateQuery.js +36 -0
- package/dist/cjs/src/dream/internal/associations/createAssociation.js +55 -0
- package/dist/cjs/src/dream/internal/associations/destroyAssociation.js +17 -0
- package/dist/cjs/src/dream/internal/associations/undestroyAssociation.js +12 -0
- package/dist/cjs/src/dream/internal/checkSingleValidation.js +52 -0
- package/dist/cjs/src/dream/internal/destroyAssociatedRecords.js +21 -0
- package/dist/cjs/src/dream/internal/destroyDream.js +72 -0
- package/dist/cjs/src/dream/internal/destroyOptions.js +32 -0
- package/dist/cjs/src/dream/internal/ensureSTITypeFieldIsSet.js +10 -0
- package/dist/cjs/src/dream/internal/executeDatabaseQuery.js +24 -0
- package/dist/cjs/src/dream/internal/extractAssociationMetadataFromAssociationName.js +8 -0
- package/dist/cjs/src/dream/internal/orderByDirection.js +15 -0
- package/dist/cjs/src/dream/internal/reload.js +21 -0
- package/dist/cjs/src/dream/internal/runHooksFor.js +99 -0
- package/dist/cjs/src/dream/internal/runValidations.js +16 -0
- package/dist/cjs/src/dream/internal/safelyRunCommitHooks.js +15 -0
- package/dist/cjs/src/dream/internal/saveDream.js +67 -0
- package/dist/cjs/src/dream/internal/scopeHelpers.js +13 -0
- package/dist/cjs/src/dream/internal/shouldBypassDefaultScope.js +12 -0
- package/dist/cjs/src/dream/internal/similarity/SimilarityBuilder.js +331 -0
- package/dist/cjs/src/dream/internal/similarity/similaritySelectSql.js +21 -0
- package/dist/cjs/src/dream/internal/similarity/similarityWhereSql.js +21 -0
- package/dist/cjs/src/dream/internal/softDeleteDream.js +22 -0
- package/dist/cjs/src/dream/internal/sqlResultToDreamInstance.js +38 -0
- package/dist/cjs/src/dream/internal/undestroyDream.js +90 -0
- package/dist/cjs/src/dream/types.js +98 -0
- package/dist/cjs/src/dream-application/cache.js +13 -0
- package/dist/cjs/src/dream-application/helpers/DreamImporter.js +52 -0
- package/dist/cjs/src/dream-application/helpers/globalModelKeyFromPath.js +10 -0
- package/dist/cjs/src/dream-application/helpers/globalSerializerKeyFromPath.js +17 -0
- package/dist/cjs/src/dream-application/helpers/globalServiceKeyFromPath.js +11 -0
- package/dist/cjs/src/dream-application/helpers/importers/importModels.js +81 -0
- package/dist/cjs/src/dream-application/helpers/importers/importSerializers.js +63 -0
- package/dist/cjs/src/dream-application/helpers/importers/importServices.js +43 -0
- package/dist/cjs/src/dream-application/helpers/lookupClassByGlobalName.js +17 -0
- package/dist/cjs/src/dream-application/helpers/lookupModelByGlobalName.js +13 -0
- package/dist/cjs/src/dream-application/helpers/lookupModelByGlobalNameOrNames.js +10 -0
- package/dist/cjs/src/dream-application/index.js +284 -0
- package/dist/cjs/src/encrypt/InternalEncrypt.js +32 -0
- package/dist/cjs/src/encrypt/algorithms/aes-gcm/decryptAESGCM.js +26 -0
- package/dist/cjs/src/encrypt/algorithms/aes-gcm/encryptAESGCM.js +12 -0
- package/dist/cjs/src/encrypt/algorithms/aes-gcm/generateKeyAESGCM.js +7 -0
- package/dist/cjs/src/encrypt/algorithms/aes-gcm/validateKeyAESGCM.js +11 -0
- package/dist/cjs/src/encrypt/index.js +95 -0
- package/dist/cjs/src/errors/AttemptingToMarshalInvalidArrayType.js +20 -0
- package/dist/cjs/src/errors/CannotCallUndestroyOnANonSoftDeleteModel.js +21 -0
- package/dist/cjs/src/errors/CannotDefineAssociationWithBothDependentAndPassthrough.js +19 -0
- package/dist/cjs/src/errors/CannotDefineAssociationWithBothDependentAndRequiredOnClause.js +19 -0
- package/dist/cjs/src/errors/CannotNegateSimilarityClause.js +22 -0
- package/dist/cjs/src/errors/CannotPassAdditionalFieldsToPluckEachAfterCallback.js +22 -0
- package/dist/cjs/src/errors/CannotPassUndefinedAsAValueToAWhereClause.js +20 -0
- package/dist/cjs/src/errors/CannotReloadUnsavedDream.js +16 -0
- package/dist/cjs/src/errors/ConstructorOnlyForInternalUse.js +9 -0
- package/dist/cjs/src/errors/CreateOrFindByFailedToCreateAndFind.js +18 -0
- package/dist/cjs/src/errors/DoNotSetEncryptedFieldsDirectly.js +23 -0
- package/dist/cjs/src/errors/InvalidColumnName.js +19 -0
- package/dist/cjs/src/errors/InvalidDecimalFieldPassedToGenerator.js +19 -0
- package/dist/cjs/src/errors/InvalidTableAlias.js +30 -0
- package/dist/cjs/src/errors/InvalidTableName.js +23 -0
- package/dist/cjs/src/errors/LeftJoinPreloadIncompatibleWithFindEach.js +12 -0
- package/dist/cjs/src/errors/MissingDB.js +10 -0
- package/dist/cjs/src/errors/MissingDeletedAtFieldForSoftDelete.js +24 -0
- package/dist/cjs/src/errors/MissingRequiredCallbackFunctionToPluckEach.js +22 -0
- package/dist/cjs/src/errors/MissingSerializersDefinition.js +26 -0
- package/dist/cjs/src/errors/MissingTable.js +27 -0
- package/dist/cjs/src/errors/NoUpdateAllOnJoins.js +13 -0
- package/dist/cjs/src/errors/NoUpdateOnAssociationQuery.js +10 -0
- package/dist/cjs/src/errors/NonBelongsToAssociationProvidedAsSortableDecoratorScope.js +23 -0
- package/dist/cjs/src/errors/NonExistentScopeProvidedToResort.js +23 -0
- package/dist/cjs/src/errors/PrototypePollutingAssignment.js +13 -0
- package/dist/cjs/src/errors/RecordNotFound.js +15 -0
- package/dist/cjs/src/errors/SortableDecoratorRequiresColumnOrBelongsToAssociation.js +26 -0
- package/dist/cjs/src/errors/ValidationError.js +19 -0
- package/dist/cjs/src/errors/associations/CanOnlyPassBelongsToModelParam.js +20 -0
- package/dist/cjs/src/errors/associations/CannotAssociateThroughPolymorphic.js +19 -0
- package/dist/cjs/src/errors/associations/CannotCreateAssociationWithThroughContext.js +19 -0
- package/dist/cjs/src/errors/associations/CannotJoinPolymorphicBelongsToError.js +27 -0
- package/dist/cjs/src/errors/associations/CannotPassNullOrUndefinedToRequiredBelongsTo.js +19 -0
- package/dist/cjs/src/errors/associations/InvalidComputedForeignKey.js +64 -0
- package/dist/cjs/src/errors/associations/JoinAttemptedOnMissingAssociation.js +27 -0
- package/dist/cjs/src/errors/associations/MissingRequiredAssociationOnClause.js +19 -0
- package/dist/cjs/src/errors/associations/MissingRequiredPassthroughForAssociationOnClause.js +16 -0
- package/dist/cjs/src/errors/associations/MissingThroughAssociation.js +27 -0
- package/dist/cjs/src/errors/associations/MissingThroughAssociationSource.js +42 -0
- package/dist/cjs/src/errors/associations/NonLoadedAssociation.js +18 -0
- package/dist/cjs/src/errors/dream-application/DreamApplicationInitMissingCallToLoadModels.js +18 -0
- package/dist/cjs/src/errors/dream-application/DreamApplicationInitMissingMissingProjectRoot.js +19 -0
- package/dist/cjs/src/errors/dream-application/GlobalNameNotSet.js +14 -0
- package/dist/cjs/src/errors/dream-application/SerializerNameConflict.js +15 -0
- package/dist/cjs/src/errors/encrypt/MissingColumnEncryptionOpts.js +27 -0
- package/dist/cjs/src/errors/encrypt/MissingEncryptionKey.js +12 -0
- package/dist/cjs/src/errors/environment/MissingRequiredEnvironmentVariable.js +13 -0
- package/dist/cjs/src/errors/ops/AnyRequiresArrayColumn.js +18 -0
- package/dist/cjs/src/errors/ops/ScoreMustBeANormalNumber.js +17 -0
- package/dist/cjs/src/errors/schema-builder/FailedToIdentifyAssociation.js +80 -0
- package/dist/cjs/src/errors/serializers/FailedToRenderThroughAssociationForSerializer.js +17 -0
- package/dist/cjs/src/errors/sortable/CannotCallSortableOnSTIChild.js +18 -0
- package/dist/cjs/src/errors/sti/STIChildMissing.js +23 -0
- package/dist/cjs/src/errors/sti/StiChildCannotDefineNewAssociations.js +20 -0
- package/dist/cjs/src/errors/sti/StiChildIncompatibleWithReplicaSafeDecorator.js +17 -0
- package/dist/cjs/src/errors/sti/StiChildIncompatibleWithSoftDeleteDecorator.js +17 -0
- package/dist/cjs/src/global-cli/dream.js +46 -0
- package/dist/cjs/src/global-cli/file-builders/DreamtsBuilder.js +69 -0
- package/dist/cjs/src/global-cli/file-builders/EnvBuilder.js +27 -0
- package/dist/cjs/src/global-cli/file-builders/EslintConfBuilder.js +29 -0
- package/dist/cjs/src/global-cli/file-builders/PackagejsonBuilder.js +9 -0
- package/dist/cjs/src/global-cli/helpers/argAndValue.js +15 -0
- package/dist/cjs/src/global-cli/helpers/autogeneratedFileMessage.js +71 -0
- package/dist/cjs/src/global-cli/helpers/buildNewDreamApp.js +63 -0
- package/dist/cjs/src/global-cli/helpers/copyRecursive.js +20 -0
- package/dist/cjs/src/global-cli/helpers/filterObjectByKey.js +23 -0
- package/dist/cjs/src/global-cli/helpers/generateEncryptionKey.js +26 -0
- package/dist/cjs/src/global-cli/helpers/globalCliSnakeify.js +1 -0
- package/dist/cjs/src/global-cli/helpers/initDreamAppIntoExistingProject.js +85 -0
- package/dist/cjs/src/global-cli/helpers/log.js +28 -0
- package/dist/cjs/src/global-cli/helpers/logo.js +81 -0
- package/dist/cjs/src/global-cli/helpers/primaryKeyTypes.js +13 -0
- package/dist/cjs/src/global-cli/helpers/prompt.js +33 -0
- package/dist/cjs/src/global-cli/helpers/select.js +113 -0
- package/dist/cjs/src/global-cli/helpers/sleep.js +10 -0
- package/dist/cjs/src/global-cli/helpers/sspawn.js +21 -0
- package/dist/cjs/src/global-cli/helpers/welcomeMessage.js +41 -0
- package/dist/cjs/src/global-cli/init.js +56 -0
- package/dist/cjs/src/global-cli/new.js +10 -0
- package/dist/cjs/src/helpers/CalendarDate.js +172 -0
- package/dist/cjs/src/helpers/Env.js +78 -0
- package/dist/cjs/src/helpers/EnvInternal.js +5 -0
- package/dist/cjs/src/helpers/allNestedObjectKeys.js +12 -0
- package/dist/cjs/src/helpers/benchmark.js +18 -0
- package/dist/cjs/src/helpers/camelize.js +15 -0
- package/dist/cjs/src/helpers/capitalize.js +6 -0
- package/dist/cjs/src/helpers/cli/SchemaBuilder.js +378 -0
- package/dist/cjs/src/helpers/cli/generateDream.js +48 -0
- package/dist/cjs/src/helpers/cli/generateDreamContent.js +107 -0
- package/dist/cjs/src/helpers/cli/generateFactory.js +26 -0
- package/dist/cjs/src/helpers/cli/generateFactoryContent.js +58 -0
- package/dist/cjs/src/helpers/cli/generateMigration.js +56 -0
- package/dist/cjs/src/helpers/cli/generateMigrationContent.js +196 -0
- package/dist/cjs/src/helpers/cli/generateSerializer.js +26 -0
- package/dist/cjs/src/helpers/cli/generateSerializerContent.js +130 -0
- package/dist/cjs/src/helpers/cli/generateStiMigrationContent.js +7 -0
- package/dist/cjs/src/helpers/cli/generateUnitSpec.js +26 -0
- package/dist/cjs/src/helpers/cli/generateUnitSpecContent.js +10 -0
- package/dist/cjs/src/helpers/cloneDeepSafe.js +69 -0
- package/dist/cjs/src/helpers/compact.js +14 -0
- package/dist/cjs/src/helpers/customPgParsers.js +39 -0
- package/dist/cjs/src/helpers/db/cachedTypeForAttribute.js +6 -0
- package/dist/cjs/src/helpers/db/createDb.js +20 -0
- package/dist/cjs/src/helpers/db/dropDb.js +36 -0
- package/dist/cjs/src/helpers/db/foreignKeyTypeFromPrimaryKey.js +11 -0
- package/dist/cjs/src/helpers/db/loadPgClient.js +20 -0
- package/dist/cjs/src/helpers/db/primaryKeyType.js +23 -0
- package/dist/cjs/src/helpers/db/runMigration.js +97 -0
- package/dist/cjs/src/helpers/db/truncateDb.js +27 -0
- package/dist/cjs/src/helpers/db/types/isDatabaseArrayColumn.js +6 -0
- package/dist/cjs/src/helpers/db/types/isDateColumn.js +6 -0
- package/dist/cjs/src/helpers/db/types/isDateTimeColumn.js +6 -0
- package/dist/cjs/src/helpers/db/types/isJsonColumn.js +6 -0
- package/dist/cjs/src/helpers/debug.js +11 -0
- package/dist/cjs/src/helpers/dreamOrPsychicCoreDevelopment.js +10 -0
- package/dist/cjs/src/helpers/filterObjectByKey.js +14 -0
- package/dist/cjs/src/helpers/getFiles.js +20 -0
- package/dist/cjs/src/helpers/globalClassNameFromFullyQualifiedModelName.js +7 -0
- package/dist/cjs/src/helpers/hyphenize.js +11 -0
- package/dist/cjs/src/helpers/inferSerializerFromDreamOrViewModel.js +16 -0
- package/dist/cjs/src/helpers/isEmpty.js +8 -0
- package/dist/cjs/src/helpers/loadEnv.js +37 -0
- package/dist/cjs/src/helpers/loadRepl.js +25 -0
- package/dist/cjs/src/helpers/migrationVersion.js +6 -0
- package/dist/cjs/src/helpers/namespaceColumn.js +8 -0
- package/dist/cjs/src/helpers/objectPathsToArrays.js +19 -0
- package/dist/cjs/src/helpers/pascalize.js +12 -0
- package/dist/cjs/src/helpers/pascalizePath.js +10 -0
- package/dist/cjs/src/helpers/path/dreamFileAndDirPaths.js +16 -0
- package/dist/cjs/src/helpers/path/dreamPath.js +25 -0
- package/dist/cjs/src/helpers/path/relativeDreamPath.js +50 -0
- package/dist/cjs/src/helpers/path/sharedPathPrefix.js +14 -0
- package/dist/cjs/src/helpers/propertyNameFromFullyQualifiedModelName.js +8 -0
- package/dist/cjs/src/helpers/protectAgainstPollutingAssignment.js +14 -0
- package/dist/cjs/src/helpers/range.js +20 -0
- package/dist/cjs/src/helpers/round.js +7 -0
- package/dist/cjs/src/helpers/serializerNameFromFullyQualifiedModelName.js +13 -0
- package/dist/cjs/src/helpers/snakeify.js +14 -0
- package/dist/cjs/src/helpers/sortBy.js +31 -0
- package/dist/cjs/src/helpers/sqlAttributes.js +28 -0
- package/dist/cjs/src/helpers/sspawn.js +21 -0
- package/dist/cjs/src/helpers/standardizeFullyQualifiedModelName.js +10 -0
- package/dist/cjs/src/helpers/stringCasing.js +34 -0
- package/dist/cjs/src/helpers/typechecks.js +16 -0
- package/dist/cjs/src/helpers/typeutils.js +2 -0
- package/dist/cjs/src/helpers/uncapitalize.js +6 -0
- package/dist/cjs/src/helpers/uniq.js +21 -0
- package/dist/cjs/src/index.js +154 -0
- package/dist/cjs/src/openapi/types.js +26 -0
- package/dist/cjs/src/ops/curried-ops-statement.js +12 -0
- package/dist/cjs/src/ops/index.js +42 -0
- package/dist/cjs/src/ops/ops-statement.js +38 -0
- package/dist/cjs/src/serializer/decorators/associations/RendersMany.js +84 -0
- package/dist/cjs/src/serializer/decorators/associations/RendersOne.js +87 -0
- package/dist/cjs/src/serializer/decorators/associations/shared.js +10 -0
- package/dist/cjs/src/serializer/decorators/attribute.js +161 -0
- package/dist/cjs/src/serializer/decorators/helpers/dreamAttributeOpenapiShape.js +78 -0
- package/dist/cjs/src/serializer/decorators/helpers/hasSerializersGetter.js +11 -0
- package/dist/cjs/src/serializer/decorators/helpers/maybeSerializableToDreamSerializerCallbackFunction.js +20 -0
- package/dist/cjs/src/serializer/index.js +271 -0
- package/dist/esm/boilerplate/package.json +42 -0
- package/dist/esm/src/Dream.js +2981 -0
- package/dist/esm/src/bin/helpers/sync.js +106 -0
- package/dist/esm/src/bin/index.js +104 -0
- package/dist/esm/src/cli/index.js +152 -0
- package/dist/esm/src/db/ConnectedToDB.js +40 -0
- package/dist/esm/src/db/ConnectionConfRetriever.js +19 -0
- package/dist/esm/src/db/DreamDbConnection.js +72 -0
- package/dist/esm/src/db/dataTypes.js +53 -0
- package/dist/esm/src/db/errors.js +13 -0
- package/dist/esm/src/db/index.js +9 -0
- package/dist/esm/src/db/migration-helpers/DreamMigrationHelpers.js +190 -0
- package/dist/esm/src/db/reflections.js +1 -0
- package/dist/esm/src/db/types.js +1 -0
- package/dist/esm/src/db/validators/validateColumn.js +8 -0
- package/dist/esm/src/db/validators/validateTable.js +6 -0
- package/dist/esm/src/db/validators/validateTableAlias.js +52 -0
- package/dist/esm/src/decorators/DecoratorContextType.js +1 -0
- package/dist/esm/src/decorators/Decorators.js +323 -0
- package/dist/esm/src/decorators/Encrypted.js +80 -0
- package/dist/esm/src/decorators/ReplicaSafe.js +9 -0
- package/dist/esm/src/decorators/STI.js +31 -0
- package/dist/esm/src/decorators/Scope.js +27 -0
- package/dist/esm/src/decorators/SoftDelete.js +50 -0
- package/dist/esm/src/decorators/Virtual.js +25 -0
- package/dist/esm/src/decorators/associations/BelongsTo.js +74 -0
- package/dist/esm/src/decorators/associations/HasMany.js +97 -0
- package/dist/esm/src/decorators/associations/HasOne.js +93 -0
- package/dist/esm/src/decorators/associations/associationToGetterSetterProp.js +3 -0
- package/dist/esm/src/decorators/associations/shared.js +123 -0
- package/dist/esm/src/decorators/helpers/freezeBaseClassArrayMap.js +7 -0
- package/dist/esm/src/decorators/hooks/AfterCreate.js +22 -0
- package/dist/esm/src/decorators/hooks/AfterCreateCommit.js +39 -0
- package/dist/esm/src/decorators/hooks/AfterDestroy.js +21 -0
- package/dist/esm/src/decorators/hooks/AfterDestroyCommit.js +36 -0
- package/dist/esm/src/decorators/hooks/AfterSave.js +22 -0
- package/dist/esm/src/decorators/hooks/AfterSaveCommit.js +39 -0
- package/dist/esm/src/decorators/hooks/AfterUpdate.js +22 -0
- package/dist/esm/src/decorators/hooks/AfterUpdateCommit.js +39 -0
- package/dist/esm/src/decorators/hooks/BeforeCreate.js +22 -0
- package/dist/esm/src/decorators/hooks/BeforeDestroy.js +21 -0
- package/dist/esm/src/decorators/hooks/BeforeSave.js +22 -0
- package/dist/esm/src/decorators/hooks/BeforeUpdate.js +22 -0
- package/dist/esm/src/decorators/hooks/shared.js +20 -0
- package/dist/esm/src/decorators/sortable/Sortable.js +157 -0
- package/dist/esm/src/decorators/sortable/helpers/applySortableScopeToQuery.js +14 -0
- package/dist/esm/src/decorators/sortable/helpers/clearCachedSortableValues.js +8 -0
- package/dist/esm/src/decorators/sortable/helpers/decrementScopedRecordsGreaterThanPosition.js +23 -0
- package/dist/esm/src/decorators/sortable/helpers/getColumnForSortableScope.js +15 -0
- package/dist/esm/src/decorators/sortable/helpers/isSortedCorrectly.js +4 -0
- package/dist/esm/src/decorators/sortable/helpers/positionIsInvalid.js +8 -0
- package/dist/esm/src/decorators/sortable/helpers/resortAllRecords.js +35 -0
- package/dist/esm/src/decorators/sortable/helpers/scopeArray.js +7 -0
- package/dist/esm/src/decorators/sortable/helpers/setPosition.js +154 -0
- package/dist/esm/src/decorators/sortable/helpers/sortableCacheKeyName.js +4 -0
- package/dist/esm/src/decorators/sortable/helpers/sortableCacheValuesName.js +4 -0
- package/dist/esm/src/decorators/sortable/helpers/sortableQueryExcludingDream.js +7 -0
- package/dist/esm/src/decorators/sortable/hooks/afterSortableCreate.js +15 -0
- package/dist/esm/src/decorators/sortable/hooks/afterSortableDestroy.js +11 -0
- package/dist/esm/src/decorators/sortable/hooks/afterSortableUpdate.js +28 -0
- package/dist/esm/src/decorators/sortable/hooks/beforeSortableSave.js +62 -0
- package/dist/esm/src/decorators/validations/Validate.js +19 -0
- package/dist/esm/src/decorators/validations/Validates.js +64 -0
- package/dist/esm/src/decorators/validations/shared.js +1 -0
- package/dist/esm/src/dream/DreamClassTransactionBuilder.js +589 -0
- package/dist/esm/src/dream/DreamInstanceTransactionBuilder.js +477 -0
- package/dist/esm/src/dream/DreamTransaction.js +23 -0
- package/dist/esm/src/dream/LeftJoinLoadBuilder.js +74 -0
- package/dist/esm/src/dream/LoadBuilder.js +65 -0
- package/dist/esm/src/dream/Query.js +2615 -0
- package/dist/esm/src/dream/internal/applyScopeBypassingSettingsToQuery.js +8 -0
- package/dist/esm/src/dream/internal/associations/associationQuery.js +20 -0
- package/dist/esm/src/dream/internal/associations/associationUpdateQuery.js +33 -0
- package/dist/esm/src/dream/internal/associations/createAssociation.js +52 -0
- package/dist/esm/src/dream/internal/associations/destroyAssociation.js +14 -0
- package/dist/esm/src/dream/internal/associations/undestroyAssociation.js +9 -0
- package/dist/esm/src/dream/internal/checkSingleValidation.js +49 -0
- package/dist/esm/src/dream/internal/destroyAssociatedRecords.js +18 -0
- package/dist/esm/src/dream/internal/destroyDream.js +69 -0
- package/dist/esm/src/dream/internal/destroyOptions.js +27 -0
- package/dist/esm/src/dream/internal/ensureSTITypeFieldIsSet.js +7 -0
- package/dist/esm/src/dream/internal/executeDatabaseQuery.js +21 -0
- package/dist/esm/src/dream/internal/extractAssociationMetadataFromAssociationName.js +5 -0
- package/dist/esm/src/dream/internal/orderByDirection.js +12 -0
- package/dist/esm/src/dream/internal/reload.js +18 -0
- package/dist/esm/src/dream/internal/runHooksFor.js +95 -0
- package/dist/esm/src/dream/internal/runValidations.js +13 -0
- package/dist/esm/src/dream/internal/safelyRunCommitHooks.js +12 -0
- package/dist/esm/src/dream/internal/saveDream.js +64 -0
- package/dist/esm/src/dream/internal/scopeHelpers.js +9 -0
- package/dist/esm/src/dream/internal/shouldBypassDefaultScope.js +9 -0
- package/dist/esm/src/dream/internal/similarity/SimilarityBuilder.js +327 -0
- package/dist/esm/src/dream/internal/similarity/similaritySelectSql.js +18 -0
- package/dist/esm/src/dream/internal/similarity/similarityWhereSql.js +18 -0
- package/dist/esm/src/dream/internal/softDeleteDream.js +19 -0
- package/dist/esm/src/dream/internal/sqlResultToDreamInstance.js +34 -0
- package/dist/esm/src/dream/internal/undestroyDream.js +87 -0
- package/dist/esm/src/dream/types.js +95 -0
- package/dist/esm/src/dream-application/cache.js +9 -0
- package/dist/esm/src/dream-application/helpers/DreamImporter.js +49 -0
- package/dist/esm/src/dream-application/helpers/globalModelKeyFromPath.js +7 -0
- package/dist/esm/src/dream-application/helpers/globalSerializerKeyFromPath.js +14 -0
- package/dist/esm/src/dream-application/helpers/globalServiceKeyFromPath.js +8 -0
- package/dist/esm/src/dream-application/helpers/importers/importModels.js +75 -0
- package/dist/esm/src/dream-application/helpers/importers/importSerializers.js +57 -0
- package/dist/esm/src/dream-application/helpers/importers/importServices.js +37 -0
- package/dist/esm/src/dream-application/helpers/lookupClassByGlobalName.js +14 -0
- package/dist/esm/src/dream-application/helpers/lookupModelByGlobalName.js +10 -0
- package/dist/esm/src/dream-application/helpers/lookupModelByGlobalNameOrNames.js +7 -0
- package/dist/esm/src/dream-application/index.js +281 -0
- package/dist/esm/src/encrypt/InternalEncrypt.js +29 -0
- package/dist/esm/src/encrypt/algorithms/aes-gcm/decryptAESGCM.js +23 -0
- package/dist/esm/src/encrypt/algorithms/aes-gcm/encryptAESGCM.js +9 -0
- package/dist/esm/src/encrypt/algorithms/aes-gcm/generateKeyAESGCM.js +4 -0
- package/dist/esm/src/encrypt/algorithms/aes-gcm/validateKeyAESGCM.js +8 -0
- package/dist/esm/src/encrypt/index.js +92 -0
- package/dist/esm/src/errors/AttemptingToMarshalInvalidArrayType.js +17 -0
- package/dist/esm/src/errors/CannotCallUndestroyOnANonSoftDeleteModel.js +18 -0
- package/dist/esm/src/errors/CannotDefineAssociationWithBothDependentAndPassthrough.js +16 -0
- package/dist/esm/src/errors/CannotDefineAssociationWithBothDependentAndRequiredOnClause.js +16 -0
- package/dist/esm/src/errors/CannotNegateSimilarityClause.js +19 -0
- package/dist/esm/src/errors/CannotPassAdditionalFieldsToPluckEachAfterCallback.js +19 -0
- package/dist/esm/src/errors/CannotPassUndefinedAsAValueToAWhereClause.js +17 -0
- package/dist/esm/src/errors/CannotReloadUnsavedDream.js +13 -0
- package/dist/esm/src/errors/ConstructorOnlyForInternalUse.js +6 -0
- package/dist/esm/src/errors/CreateOrFindByFailedToCreateAndFind.js +15 -0
- package/dist/esm/src/errors/DoNotSetEncryptedFieldsDirectly.js +20 -0
- package/dist/esm/src/errors/InvalidColumnName.js +16 -0
- package/dist/esm/src/errors/InvalidDecimalFieldPassedToGenerator.js +16 -0
- package/dist/esm/src/errors/InvalidTableAlias.js +27 -0
- package/dist/esm/src/errors/InvalidTableName.js +20 -0
- package/dist/esm/src/errors/LeftJoinPreloadIncompatibleWithFindEach.js +9 -0
- package/dist/esm/src/errors/MissingDB.js +7 -0
- package/dist/esm/src/errors/MissingDeletedAtFieldForSoftDelete.js +21 -0
- package/dist/esm/src/errors/MissingRequiredCallbackFunctionToPluckEach.js +19 -0
- package/dist/esm/src/errors/MissingSerializersDefinition.js +23 -0
- package/dist/esm/src/errors/MissingTable.js +24 -0
- package/dist/esm/src/errors/NoUpdateAllOnJoins.js +10 -0
- package/dist/esm/src/errors/NoUpdateOnAssociationQuery.js +7 -0
- package/dist/esm/src/errors/NonBelongsToAssociationProvidedAsSortableDecoratorScope.js +20 -0
- package/dist/esm/src/errors/NonExistentScopeProvidedToResort.js +20 -0
- package/dist/esm/src/errors/PrototypePollutingAssignment.js +10 -0
- package/dist/esm/src/errors/RecordNotFound.js +12 -0
- package/dist/esm/src/errors/SortableDecoratorRequiresColumnOrBelongsToAssociation.js +23 -0
- package/dist/esm/src/errors/ValidationError.js +16 -0
- package/dist/esm/src/errors/associations/CanOnlyPassBelongsToModelParam.js +17 -0
- package/dist/esm/src/errors/associations/CannotAssociateThroughPolymorphic.js +16 -0
- package/dist/esm/src/errors/associations/CannotCreateAssociationWithThroughContext.js +16 -0
- package/dist/esm/src/errors/associations/CannotJoinPolymorphicBelongsToError.js +24 -0
- package/dist/esm/src/errors/associations/CannotPassNullOrUndefinedToRequiredBelongsTo.js +16 -0
- package/dist/esm/src/errors/associations/InvalidComputedForeignKey.js +58 -0
- package/dist/esm/src/errors/associations/JoinAttemptedOnMissingAssociation.js +24 -0
- package/dist/esm/src/errors/associations/MissingRequiredAssociationOnClause.js +16 -0
- package/dist/esm/src/errors/associations/MissingRequiredPassthroughForAssociationOnClause.js +13 -0
- package/dist/esm/src/errors/associations/MissingThroughAssociation.js +24 -0
- package/dist/esm/src/errors/associations/MissingThroughAssociationSource.js +39 -0
- package/dist/esm/src/errors/associations/NonLoadedAssociation.js +15 -0
- package/dist/esm/src/errors/dream-application/DreamApplicationInitMissingCallToLoadModels.js +15 -0
- package/dist/esm/src/errors/dream-application/DreamApplicationInitMissingMissingProjectRoot.js +16 -0
- package/dist/esm/src/errors/dream-application/GlobalNameNotSet.js +11 -0
- package/dist/esm/src/errors/dream-application/SerializerNameConflict.js +12 -0
- package/dist/esm/src/errors/encrypt/MissingColumnEncryptionOpts.js +24 -0
- package/dist/esm/src/errors/encrypt/MissingEncryptionKey.js +9 -0
- package/dist/esm/src/errors/environment/MissingRequiredEnvironmentVariable.js +10 -0
- package/dist/esm/src/errors/ops/AnyRequiresArrayColumn.js +15 -0
- package/dist/esm/src/errors/ops/ScoreMustBeANormalNumber.js +14 -0
- package/dist/esm/src/errors/schema-builder/FailedToIdentifyAssociation.js +77 -0
- package/dist/esm/src/errors/serializers/FailedToRenderThroughAssociationForSerializer.js +14 -0
- package/dist/esm/src/errors/sortable/CannotCallSortableOnSTIChild.js +15 -0
- package/dist/esm/src/errors/sti/STIChildMissing.js +20 -0
- package/dist/esm/src/errors/sti/StiChildCannotDefineNewAssociations.js +17 -0
- package/dist/esm/src/errors/sti/StiChildIncompatibleWithReplicaSafeDecorator.js +14 -0
- package/dist/esm/src/errors/sti/StiChildIncompatibleWithSoftDeleteDecorator.js +14 -0
- package/dist/esm/src/global-cli/dream.js +44 -0
- package/dist/esm/src/global-cli/file-builders/DreamtsBuilder.js +66 -0
- package/dist/esm/src/global-cli/file-builders/EnvBuilder.js +24 -0
- package/dist/esm/src/global-cli/file-builders/EslintConfBuilder.js +26 -0
- package/dist/esm/src/global-cli/file-builders/PackagejsonBuilder.js +6 -0
- package/dist/esm/src/global-cli/helpers/argAndValue.js +12 -0
- package/dist/esm/src/global-cli/helpers/autogeneratedFileMessage.js +68 -0
- package/dist/esm/src/global-cli/helpers/buildNewDreamApp.js +60 -0
- package/dist/esm/src/global-cli/helpers/copyRecursive.js +17 -0
- package/dist/esm/src/global-cli/helpers/filterObjectByKey.js +20 -0
- package/dist/esm/src/global-cli/helpers/generateEncryptionKey.js +23 -0
- package/dist/esm/src/global-cli/helpers/globalCliSnakeify.js +1 -0
- package/dist/esm/src/global-cli/helpers/initDreamAppIntoExistingProject.js +82 -0
- package/dist/esm/src/global-cli/helpers/log.js +24 -0
- package/dist/esm/src/global-cli/helpers/logo.js +77 -0
- package/dist/esm/src/global-cli/helpers/primaryKeyTypes.js +10 -0
- package/dist/esm/src/global-cli/helpers/prompt.js +30 -0
- package/dist/esm/src/global-cli/helpers/select.js +110 -0
- package/dist/esm/src/global-cli/helpers/sleep.js +7 -0
- package/dist/esm/src/global-cli/helpers/sspawn.js +17 -0
- package/dist/esm/src/global-cli/helpers/welcomeMessage.js +38 -0
- package/dist/esm/src/global-cli/init.js +53 -0
- package/dist/esm/src/global-cli/new.js +7 -0
- package/dist/esm/src/helpers/CalendarDate.js +169 -0
- package/dist/esm/src/helpers/Env.js +75 -0
- package/dist/esm/src/helpers/EnvInternal.js +3 -0
- package/dist/esm/src/helpers/allNestedObjectKeys.js +9 -0
- package/dist/esm/src/helpers/benchmark.js +15 -0
- package/dist/esm/src/helpers/camelize.js +11 -0
- package/dist/esm/src/helpers/capitalize.js +3 -0
- package/dist/esm/src/helpers/cli/SchemaBuilder.js +375 -0
- package/dist/esm/src/helpers/cli/generateDream.js +45 -0
- package/dist/esm/src/helpers/cli/generateDreamContent.js +104 -0
- package/dist/esm/src/helpers/cli/generateFactory.js +23 -0
- package/dist/esm/src/helpers/cli/generateFactoryContent.js +55 -0
- package/dist/esm/src/helpers/cli/generateMigration.js +53 -0
- package/dist/esm/src/helpers/cli/generateMigrationContent.js +193 -0
- package/dist/esm/src/helpers/cli/generateSerializer.js +23 -0
- package/dist/esm/src/helpers/cli/generateSerializerContent.js +127 -0
- package/dist/esm/src/helpers/cli/generateStiMigrationContent.js +4 -0
- package/dist/esm/src/helpers/cli/generateUnitSpec.js +23 -0
- package/dist/esm/src/helpers/cli/generateUnitSpecContent.js +7 -0
- package/dist/esm/src/helpers/cloneDeepSafe.js +64 -0
- package/dist/esm/src/helpers/compact.js +11 -0
- package/dist/esm/src/helpers/customPgParsers.js +31 -0
- package/dist/esm/src/helpers/db/cachedTypeForAttribute.js +3 -0
- package/dist/esm/src/helpers/db/createDb.js +17 -0
- package/dist/esm/src/helpers/db/dropDb.js +33 -0
- package/dist/esm/src/helpers/db/foreignKeyTypeFromPrimaryKey.js +8 -0
- package/dist/esm/src/helpers/db/loadPgClient.js +17 -0
- package/dist/esm/src/helpers/db/primaryKeyType.js +20 -0
- package/dist/esm/src/helpers/db/runMigration.js +94 -0
- package/dist/esm/src/helpers/db/truncateDb.js +24 -0
- package/dist/esm/src/helpers/db/types/isDatabaseArrayColumn.js +3 -0
- package/dist/esm/src/helpers/db/types/isDateColumn.js +3 -0
- package/dist/esm/src/helpers/db/types/isDateTimeColumn.js +3 -0
- package/dist/esm/src/helpers/db/types/isJsonColumn.js +3 -0
- package/dist/esm/src/helpers/debug.js +8 -0
- package/dist/esm/src/helpers/dreamOrPsychicCoreDevelopment.js +7 -0
- package/dist/esm/src/helpers/filterObjectByKey.js +11 -0
- package/dist/esm/src/helpers/getFiles.js +17 -0
- package/dist/esm/src/helpers/globalClassNameFromFullyQualifiedModelName.js +4 -0
- package/dist/esm/src/helpers/hyphenize.js +8 -0
- package/dist/esm/src/helpers/inferSerializerFromDreamOrViewModel.js +12 -0
- package/dist/esm/src/helpers/isEmpty.js +5 -0
- package/dist/esm/src/helpers/loadEnv.js +35 -0
- package/dist/esm/src/helpers/loadRepl.js +22 -0
- package/dist/esm/src/helpers/migrationVersion.js +3 -0
- package/dist/esm/src/helpers/namespaceColumn.js +5 -0
- package/dist/esm/src/helpers/objectPathsToArrays.js +16 -0
- package/dist/esm/src/helpers/pascalize.js +9 -0
- package/dist/esm/src/helpers/pascalizePath.js +7 -0
- package/dist/esm/src/helpers/path/dreamFileAndDirPaths.js +13 -0
- package/dist/esm/src/helpers/path/dreamPath.js +22 -0
- package/dist/esm/src/helpers/path/relativeDreamPath.js +46 -0
- package/dist/esm/src/helpers/path/sharedPathPrefix.js +11 -0
- package/dist/esm/src/helpers/propertyNameFromFullyQualifiedModelName.js +5 -0
- package/dist/esm/src/helpers/protectAgainstPollutingAssignment.js +11 -0
- package/dist/esm/src/helpers/range.js +15 -0
- package/dist/esm/src/helpers/round.js +4 -0
- package/dist/esm/src/helpers/serializerNameFromFullyQualifiedModelName.js +10 -0
- package/dist/esm/src/helpers/snakeify.js +10 -0
- package/dist/esm/src/helpers/sortBy.js +26 -0
- package/dist/esm/src/helpers/sqlAttributes.js +25 -0
- package/dist/esm/src/helpers/sspawn.js +17 -0
- package/dist/esm/src/helpers/standardizeFullyQualifiedModelName.js +7 -0
- package/dist/esm/src/helpers/stringCasing.js +31 -0
- package/dist/esm/src/helpers/typechecks.js +12 -0
- package/dist/esm/src/helpers/typeutils.js +1 -0
- package/dist/esm/src/helpers/uncapitalize.js +3 -0
- package/dist/esm/src/helpers/uniq.js +18 -0
- package/dist/esm/src/index.js +73 -0
- package/dist/esm/src/openapi/types.js +23 -0
- package/dist/esm/src/ops/curried-ops-statement.js +9 -0
- package/dist/esm/src/ops/index.js +40 -0
- package/dist/esm/src/ops/ops-statement.js +35 -0
- package/dist/esm/src/serializer/decorators/associations/RendersMany.js +81 -0
- package/dist/esm/src/serializer/decorators/associations/RendersOne.js +84 -0
- package/dist/esm/src/serializer/decorators/associations/shared.js +7 -0
- package/dist/esm/src/serializer/decorators/attribute.js +158 -0
- package/dist/esm/src/serializer/decorators/helpers/dreamAttributeOpenapiShape.js +73 -0
- package/dist/esm/src/serializer/decorators/helpers/hasSerializersGetter.js +8 -0
- package/dist/esm/src/serializer/decorators/helpers/maybeSerializableToDreamSerializerCallbackFunction.js +17 -0
- package/dist/esm/src/serializer/index.js +268 -0
- package/dist/types/src/Dream.d.ts +2211 -0
- package/dist/types/src/bin/helpers/sync.d.ts +2 -0
- package/dist/types/src/bin/index.d.ts +20 -0
- package/dist/types/src/cli/index.d.ts +20 -0
- package/dist/types/src/db/ConnectedToDB.d.ts +26 -0
- package/dist/types/src/db/ConnectionConfRetriever.d.ts +6 -0
- package/dist/types/src/db/DreamDbConnection.d.ts +10 -0
- package/dist/types/src/db/dataTypes.d.ts +6 -0
- package/dist/types/src/db/errors.d.ts +6 -0
- package/dist/types/src/db/index.d.ts +5 -0
- package/dist/types/src/db/migration-helpers/DreamMigrationHelpers.d.ts +116 -0
- package/dist/types/src/db/reflections.d.ts +5 -0
- package/dist/types/src/db/types.d.ts +1 -0
- package/dist/types/src/db/validators/validateColumn.d.ts +1 -0
- package/dist/types/src/db/validators/validateTable.d.ts +1 -0
- package/dist/types/src/db/validators/validateTableAlias.d.ts +1 -0
- package/dist/types/src/decorators/DecoratorContextType.d.ts +13 -0
- package/dist/types/src/decorators/Decorators.d.ts +214 -0
- package/dist/types/src/decorators/Encrypted.d.ts +5 -0
- package/dist/types/src/decorators/ReplicaSafe.d.ts +1 -0
- package/dist/types/src/decorators/STI.d.ts +5 -0
- package/dist/types/src/decorators/Scope.d.ts +11 -0
- package/dist/types/src/decorators/SoftDelete.d.ts +37 -0
- package/dist/types/src/decorators/Virtual.d.ts +6 -0
- package/dist/types/src/decorators/associations/BelongsTo.d.ts +33 -0
- package/dist/types/src/decorators/associations/HasMany.d.ts +19 -0
- package/dist/types/src/decorators/associations/HasOne.d.ts +11 -0
- package/dist/types/src/decorators/associations/associationToGetterSetterProp.d.ts +5 -0
- package/dist/types/src/decorators/associations/shared.d.ts +118 -0
- package/dist/types/src/decorators/helpers/freezeBaseClassArrayMap.d.ts +1 -0
- package/dist/types/src/decorators/hooks/AfterCreate.d.ts +4 -0
- package/dist/types/src/decorators/hooks/AfterCreateCommit.d.ts +21 -0
- package/dist/types/src/decorators/hooks/AfterDestroy.d.ts +3 -0
- package/dist/types/src/decorators/hooks/AfterDestroyCommit.d.ts +18 -0
- package/dist/types/src/decorators/hooks/AfterSave.d.ts +4 -0
- package/dist/types/src/decorators/hooks/AfterSaveCommit.d.ts +21 -0
- package/dist/types/src/decorators/hooks/AfterUpdate.d.ts +4 -0
- package/dist/types/src/decorators/hooks/AfterUpdateCommit.d.ts +21 -0
- package/dist/types/src/decorators/hooks/BeforeCreate.d.ts +4 -0
- package/dist/types/src/decorators/hooks/BeforeDestroy.d.ts +3 -0
- package/dist/types/src/decorators/hooks/BeforeSave.d.ts +4 -0
- package/dist/types/src/decorators/hooks/BeforeUpdate.d.ts +4 -0
- package/dist/types/src/decorators/hooks/shared.d.ts +34 -0
- package/dist/types/src/decorators/sortable/Sortable.d.ts +9 -0
- package/dist/types/src/decorators/sortable/helpers/applySortableScopeToQuery.d.ts +9 -0
- package/dist/types/src/decorators/sortable/helpers/clearCachedSortableValues.d.ts +2 -0
- package/dist/types/src/decorators/sortable/helpers/decrementScopedRecordsGreaterThanPosition.d.ts +8 -0
- package/dist/types/src/decorators/sortable/helpers/getColumnForSortableScope.d.ts +2 -0
- package/dist/types/src/decorators/sortable/helpers/isSortedCorrectly.d.ts +1 -0
- package/dist/types/src/decorators/sortable/helpers/positionIsInvalid.d.ts +8 -0
- package/dist/types/src/decorators/sortable/helpers/resortAllRecords.d.ts +2 -0
- package/dist/types/src/decorators/sortable/helpers/scopeArray.d.ts +1 -0
- package/dist/types/src/decorators/sortable/helpers/setPosition.d.ts +14 -0
- package/dist/types/src/decorators/sortable/helpers/sortableCacheKeyName.d.ts +1 -0
- package/dist/types/src/decorators/sortable/helpers/sortableCacheValuesName.d.ts +1 -0
- package/dist/types/src/decorators/sortable/helpers/sortableQueryExcludingDream.d.ts +9 -0
- package/dist/types/src/decorators/sortable/hooks/afterSortableCreate.d.ts +10 -0
- package/dist/types/src/decorators/sortable/hooks/afterSortableDestroy.d.ts +8 -0
- package/dist/types/src/decorators/sortable/hooks/afterSortableUpdate.d.ts +10 -0
- package/dist/types/src/decorators/sortable/hooks/beforeSortableSave.d.ts +8 -0
- package/dist/types/src/decorators/validations/Validate.d.ts +1 -0
- package/dist/types/src/decorators/validations/Validates.d.ts +18 -0
- package/dist/types/src/decorators/validations/shared.d.ts +19 -0
- package/dist/types/src/dream/DreamClassTransactionBuilder.d.ts +549 -0
- package/dist/types/src/dream/DreamInstanceTransactionBuilder.d.ts +316 -0
- package/dist/types/src/dream/DreamTransaction.d.ts +15 -0
- package/dist/types/src/dream/LeftJoinLoadBuilder.d.ts +48 -0
- package/dist/types/src/dream/LoadBuilder.d.ts +47 -0
- package/dist/types/src/dream/Query.d.ts +1132 -0
- package/dist/types/src/dream/internal/applyScopeBypassingSettingsToQuery.d.ts +13 -0
- package/dist/types/src/dream/internal/associations/associationQuery.d.ts +9 -0
- package/dist/types/src/dream/internal/associations/associationUpdateQuery.d.ts +9 -0
- package/dist/types/src/dream/internal/associations/createAssociation.d.ts +4 -0
- package/dist/types/src/dream/internal/associations/destroyAssociation.d.ts +11 -0
- package/dist/types/src/dream/internal/associations/undestroyAssociation.d.ts +10 -0
- package/dist/types/src/dream/internal/checkSingleValidation.d.ts +3 -0
- package/dist/types/src/dream/internal/destroyAssociatedRecords.d.ts +10 -0
- package/dist/types/src/dream/internal/destroyDream.d.ts +19 -0
- package/dist/types/src/dream/internal/destroyOptions.d.ts +46 -0
- package/dist/types/src/dream/internal/ensureSTITypeFieldIsSet.d.ts +2 -0
- package/dist/types/src/dream/internal/executeDatabaseQuery.d.ts +1 -0
- package/dist/types/src/dream/internal/extractAssociationMetadataFromAssociationName.d.ts +4 -0
- package/dist/types/src/dream/internal/orderByDirection.d.ts +2 -0
- package/dist/types/src/dream/internal/reload.d.ts +3 -0
- package/dist/types/src/dream/internal/runHooksFor.d.ts +8 -0
- package/dist/types/src/dream/internal/runValidations.d.ts +2 -0
- package/dist/types/src/dream/internal/safelyRunCommitHooks.d.ts +7 -0
- package/dist/types/src/dream/internal/saveDream.d.ts +5 -0
- package/dist/types/src/dream/internal/scopeHelpers.d.ts +7 -0
- package/dist/types/src/dream/internal/shouldBypassDefaultScope.d.ts +4 -0
- package/dist/types/src/dream/internal/similarity/SimilarityBuilder.d.ts +38 -0
- package/dist/types/src/dream/internal/similarity/similaritySelectSql.d.ts +11 -0
- package/dist/types/src/dream/internal/similarity/similarityWhereSql.d.ts +10 -0
- package/dist/types/src/dream/internal/softDeleteDream.d.ts +3 -0
- package/dist/types/src/dream/internal/sqlResultToDreamInstance.d.ts +4 -0
- package/dist/types/src/dream/internal/undestroyDream.d.ts +16 -0
- package/dist/types/src/dream/types.d.ts +184 -0
- package/dist/types/src/dream-application/cache.d.ts +3 -0
- package/dist/types/src/dream-application/helpers/DreamImporter.d.ts +8 -0
- package/dist/types/src/dream-application/helpers/globalModelKeyFromPath.d.ts +1 -0
- package/dist/types/src/dream-application/helpers/globalSerializerKeyFromPath.d.ts +1 -0
- package/dist/types/src/dream-application/helpers/globalServiceKeyFromPath.d.ts +1 -0
- package/dist/types/src/dream-application/helpers/importers/importModels.d.ts +5 -0
- package/dist/types/src/dream-application/helpers/importers/importSerializers.d.ts +5 -0
- package/dist/types/src/dream-application/helpers/importers/importServices.d.ts +4 -0
- package/dist/types/src/dream-application/helpers/lookupClassByGlobalName.d.ts +1 -0
- package/dist/types/src/dream-application/helpers/lookupModelByGlobalName.d.ts +1 -0
- package/dist/types/src/dream-application/helpers/lookupModelByGlobalNameOrNames.d.ts +1 -0
- package/dist/types/src/dream-application/index.d.ts +143 -0
- package/dist/types/src/encrypt/InternalEncrypt.d.ts +6 -0
- package/dist/types/src/encrypt/algorithms/aes-gcm/decryptAESGCM.d.ts +2 -0
- package/dist/types/src/encrypt/algorithms/aes-gcm/encryptAESGCM.d.ts +2 -0
- package/dist/types/src/encrypt/algorithms/aes-gcm/generateKeyAESGCM.d.ts +2 -0
- package/dist/types/src/encrypt/algorithms/aes-gcm/validateKeyAESGCM.d.ts +2 -0
- package/dist/types/src/encrypt/index.d.ts +26 -0
- package/dist/types/src/errors/AttemptingToMarshalInvalidArrayType.d.ts +5 -0
- package/dist/types/src/errors/CannotCallUndestroyOnANonSoftDeleteModel.d.ts +6 -0
- package/dist/types/src/errors/CannotDefineAssociationWithBothDependentAndPassthrough.d.ts +7 -0
- package/dist/types/src/errors/CannotDefineAssociationWithBothDependentAndRequiredOnClause.d.ts +7 -0
- package/dist/types/src/errors/CannotNegateSimilarityClause.d.ts +7 -0
- package/dist/types/src/errors/CannotPassAdditionalFieldsToPluckEachAfterCallback.d.ts +6 -0
- package/dist/types/src/errors/CannotPassUndefinedAsAValueToAWhereClause.d.ts +7 -0
- package/dist/types/src/errors/CannotReloadUnsavedDream.d.ts +6 -0
- package/dist/types/src/errors/ConstructorOnlyForInternalUse.d.ts +3 -0
- package/dist/types/src/errors/CreateOrFindByFailedToCreateAndFind.d.ts +6 -0
- package/dist/types/src/errors/DoNotSetEncryptedFieldsDirectly.d.ts +8 -0
- package/dist/types/src/errors/InvalidColumnName.d.ts +6 -0
- package/dist/types/src/errors/InvalidDecimalFieldPassedToGenerator.d.ts +5 -0
- package/dist/types/src/errors/InvalidTableAlias.d.ts +5 -0
- package/dist/types/src/errors/InvalidTableName.d.ts +6 -0
- package/dist/types/src/errors/LeftJoinPreloadIncompatibleWithFindEach.d.ts +3 -0
- package/dist/types/src/errors/MissingDB.d.ts +3 -0
- package/dist/types/src/errors/MissingDeletedAtFieldForSoftDelete.d.ts +6 -0
- package/dist/types/src/errors/MissingRequiredCallbackFunctionToPluckEach.d.ts +6 -0
- package/dist/types/src/errors/MissingSerializersDefinition.d.ts +6 -0
- package/dist/types/src/errors/MissingTable.d.ts +6 -0
- package/dist/types/src/errors/NoUpdateAllOnJoins.d.ts +3 -0
- package/dist/types/src/errors/NoUpdateOnAssociationQuery.d.ts +3 -0
- package/dist/types/src/errors/NonBelongsToAssociationProvidedAsSortableDecoratorScope.d.ts +7 -0
- package/dist/types/src/errors/NonExistentScopeProvidedToResort.d.ts +7 -0
- package/dist/types/src/errors/PrototypePollutingAssignment.d.ts +5 -0
- package/dist/types/src/errors/RecordNotFound.d.ts +5 -0
- package/dist/types/src/errors/SortableDecoratorRequiresColumnOrBelongsToAssociation.d.ts +7 -0
- package/dist/types/src/errors/ValidationError.d.ts +11 -0
- package/dist/types/src/errors/associations/CanOnlyPassBelongsToModelParam.d.ts +9 -0
- package/dist/types/src/errors/associations/CannotAssociateThroughPolymorphic.d.ts +12 -0
- package/dist/types/src/errors/associations/CannotCreateAssociationWithThroughContext.d.ts +12 -0
- package/dist/types/src/errors/associations/CannotJoinPolymorphicBelongsToError.d.ts +15 -0
- package/dist/types/src/errors/associations/CannotPassNullOrUndefinedToRequiredBelongsTo.d.ts +8 -0
- package/dist/types/src/errors/associations/InvalidComputedForeignKey.d.ts +19 -0
- package/dist/types/src/errors/associations/JoinAttemptedOnMissingAssociation.d.ts +10 -0
- package/dist/types/src/errors/associations/MissingRequiredAssociationOnClause.d.ts +8 -0
- package/dist/types/src/errors/associations/MissingRequiredPassthroughForAssociationOnClause.d.ts +5 -0
- package/dist/types/src/errors/associations/MissingThroughAssociation.d.ts +12 -0
- package/dist/types/src/errors/associations/MissingThroughAssociationSource.d.ts +14 -0
- package/dist/types/src/errors/associations/NonLoadedAssociation.d.ts +10 -0
- package/dist/types/src/errors/dream-application/DreamApplicationInitMissingCallToLoadModels.d.ts +3 -0
- package/dist/types/src/errors/dream-application/DreamApplicationInitMissingMissingProjectRoot.d.ts +3 -0
- package/dist/types/src/errors/dream-application/GlobalNameNotSet.d.ts +5 -0
- package/dist/types/src/errors/dream-application/SerializerNameConflict.d.ts +5 -0
- package/dist/types/src/errors/encrypt/MissingColumnEncryptionOpts.d.ts +3 -0
- package/dist/types/src/errors/encrypt/MissingEncryptionKey.d.ts +3 -0
- package/dist/types/src/errors/environment/MissingRequiredEnvironmentVariable.d.ts +5 -0
- package/dist/types/src/errors/ops/AnyRequiresArrayColumn.d.ts +7 -0
- package/dist/types/src/errors/ops/ScoreMustBeANormalNumber.d.ts +5 -0
- package/dist/types/src/errors/schema-builder/FailedToIdentifyAssociation.d.ts +9 -0
- package/dist/types/src/errors/serializers/FailedToRenderThroughAssociationForSerializer.d.ts +6 -0
- package/dist/types/src/errors/sortable/CannotCallSortableOnSTIChild.d.ts +6 -0
- package/dist/types/src/errors/sti/STIChildMissing.d.ts +8 -0
- package/dist/types/src/errors/sti/StiChildCannotDefineNewAssociations.d.ts +7 -0
- package/dist/types/src/errors/sti/StiChildIncompatibleWithReplicaSafeDecorator.d.ts +6 -0
- package/dist/types/src/errors/sti/StiChildIncompatibleWithSoftDeleteDecorator.d.ts +6 -0
- package/dist/types/src/global-cli/dream.d.ts +2 -0
- package/dist/types/src/global-cli/file-builders/DreamtsBuilder.d.ts +4 -0
- package/dist/types/src/global-cli/file-builders/EnvBuilder.d.ts +6 -0
- package/dist/types/src/global-cli/file-builders/EslintConfBuilder.d.ts +3 -0
- package/dist/types/src/global-cli/file-builders/PackagejsonBuilder.d.ts +3 -0
- package/dist/types/src/global-cli/helpers/argAndValue.d.ts +1 -0
- package/dist/types/src/global-cli/helpers/autogeneratedFileMessage.d.ts +1 -0
- package/dist/types/src/global-cli/helpers/buildNewDreamApp.d.ts +2 -0
- package/dist/types/src/global-cli/helpers/copyRecursive.d.ts +1 -0
- package/dist/types/src/global-cli/helpers/filterObjectByKey.d.ts +1 -0
- package/dist/types/src/global-cli/helpers/generateEncryptionKey.d.ts +1 -0
- package/dist/types/src/global-cli/helpers/globalCliSnakeify.d.ts +0 -0
- package/dist/types/src/global-cli/helpers/initDreamAppIntoExistingProject.d.ts +2 -0
- package/dist/types/src/global-cli/helpers/log.d.ts +10 -0
- package/dist/types/src/global-cli/helpers/logo.d.ts +2 -0
- package/dist/types/src/global-cli/helpers/primaryKeyTypes.d.ts +22 -0
- package/dist/types/src/global-cli/helpers/prompt.d.ts +8 -0
- package/dist/types/src/global-cli/helpers/select.d.ts +17 -0
- package/dist/types/src/global-cli/helpers/sleep.d.ts +1 -0
- package/dist/types/src/global-cli/helpers/sspawn.d.ts +2 -0
- package/dist/types/src/global-cli/helpers/welcomeMessage.d.ts +1 -0
- package/dist/types/src/global-cli/init.d.ts +2 -0
- package/dist/types/src/global-cli/new.d.ts +2 -0
- package/dist/types/src/helpers/CalendarDate.d.ts +51 -0
- package/dist/types/src/helpers/Env.d.ts +37 -0
- package/dist/types/src/helpers/EnvInternal.d.ts +6 -0
- package/dist/types/src/helpers/allNestedObjectKeys.d.ts +1 -0
- package/dist/types/src/helpers/benchmark.d.ts +6 -0
- package/dist/types/src/helpers/camelize.d.ts +3 -0
- package/dist/types/src/helpers/capitalize.d.ts +1 -0
- package/dist/types/src/helpers/cli/SchemaBuilder.d.ts +17 -0
- package/dist/types/src/helpers/cli/generateDream.d.ts +8 -0
- package/dist/types/src/helpers/cli/generateDreamContent.d.ts +6 -0
- package/dist/types/src/helpers/cli/generateFactory.d.ts +4 -0
- package/dist/types/src/helpers/cli/generateFactoryContent.d.ts +4 -0
- package/dist/types/src/helpers/cli/generateMigration.d.ts +6 -0
- package/dist/types/src/helpers/cli/generateMigrationContent.d.ts +7 -0
- package/dist/types/src/helpers/cli/generateSerializer.d.ts +5 -0
- package/dist/types/src/helpers/cli/generateSerializerContent.d.ts +5 -0
- package/dist/types/src/helpers/cli/generateStiMigrationContent.d.ts +6 -0
- package/dist/types/src/helpers/cli/generateUnitSpec.d.ts +3 -0
- package/dist/types/src/helpers/cli/generateUnitSpecContent.d.ts +3 -0
- package/dist/types/src/helpers/cloneDeepSafe.d.ts +18 -0
- package/dist/types/src/helpers/compact.d.ts +19 -0
- package/dist/types/src/helpers/customPgParsers.d.ts +9 -0
- package/dist/types/src/helpers/db/cachedTypeForAttribute.d.ts +2 -0
- package/dist/types/src/helpers/db/createDb.d.ts +2 -0
- package/dist/types/src/helpers/db/dropDb.d.ts +2 -0
- package/dist/types/src/helpers/db/foreignKeyTypeFromPrimaryKey.d.ts +2 -0
- package/dist/types/src/helpers/db/loadPgClient.d.ts +3 -0
- package/dist/types/src/helpers/db/primaryKeyType.d.ts +1 -0
- package/dist/types/src/helpers/db/runMigration.d.ts +6 -0
- package/dist/types/src/helpers/db/truncateDb.d.ts +1 -0
- package/dist/types/src/helpers/db/types/isDatabaseArrayColumn.d.ts +2 -0
- package/dist/types/src/helpers/db/types/isDateColumn.d.ts +2 -0
- package/dist/types/src/helpers/db/types/isDateTimeColumn.d.ts +2 -0
- package/dist/types/src/helpers/db/types/isJsonColumn.d.ts +2 -0
- package/dist/types/src/helpers/debug.d.ts +4 -0
- package/dist/types/src/helpers/dreamOrPsychicCoreDevelopment.d.ts +1 -0
- package/dist/types/src/helpers/filterObjectByKey.d.ts +1 -0
- package/dist/types/src/helpers/getFiles.d.ts +1 -0
- package/dist/types/src/helpers/globalClassNameFromFullyQualifiedModelName.d.ts +1 -0
- package/dist/types/src/helpers/hyphenize.d.ts +2 -0
- package/dist/types/src/helpers/inferSerializerFromDreamOrViewModel.d.ts +4 -0
- package/dist/types/src/helpers/isEmpty.d.ts +1 -0
- package/dist/types/src/helpers/loadEnv.d.ts +1 -0
- package/dist/types/src/helpers/loadRepl.d.ts +2 -0
- package/dist/types/src/helpers/migrationVersion.d.ts +1 -0
- package/dist/types/src/helpers/namespaceColumn.d.ts +1 -0
- package/dist/types/src/helpers/objectPathsToArrays.d.ts +2 -0
- package/dist/types/src/helpers/pascalize.d.ts +2 -0
- package/dist/types/src/helpers/pascalizePath.d.ts +1 -0
- package/dist/types/src/helpers/path/dreamFileAndDirPaths.d.ts +5 -0
- package/dist/types/src/helpers/path/dreamPath.d.ts +3 -0
- package/dist/types/src/helpers/path/relativeDreamPath.d.ts +3 -0
- package/dist/types/src/helpers/path/sharedPathPrefix.d.ts +1 -0
- package/dist/types/src/helpers/propertyNameFromFullyQualifiedModelName.d.ts +1 -0
- package/dist/types/src/helpers/protectAgainstPollutingAssignment.d.ts +1 -0
- package/dist/types/src/helpers/range.d.ts +7 -0
- package/dist/types/src/helpers/round.d.ts +2 -0
- package/dist/types/src/helpers/serializerNameFromFullyQualifiedModelName.d.ts +1 -0
- package/dist/types/src/helpers/snakeify.d.ts +3 -0
- package/dist/types/src/helpers/sortBy.d.ts +8 -0
- package/dist/types/src/helpers/sqlAttributes.d.ts +4 -0
- package/dist/types/src/helpers/sspawn.d.ts +2 -0
- package/dist/types/src/helpers/standardizeFullyQualifiedModelName.d.ts +1 -0
- package/dist/types/src/helpers/stringCasing.d.ts +28 -0
- package/dist/types/src/helpers/typechecks.d.ts +2 -0
- package/dist/types/src/helpers/typeutils.d.ts +115 -0
- package/dist/types/src/helpers/uncapitalize.d.ts +1 -0
- package/dist/types/src/helpers/uniq.d.ts +1 -0
- package/dist/types/src/index.d.ts +78 -0
- package/dist/types/src/openapi/types.d.ts +139 -0
- package/dist/types/src/ops/curried-ops-statement.d.ts +7 -0
- package/dist/types/src/ops/index.d.ts +49 -0
- package/dist/types/src/ops/ops-statement.d.ts +14 -0
- package/dist/types/src/serializer/decorators/associations/RendersMany.d.ts +42 -0
- package/dist/types/src/serializer/decorators/associations/RendersOne.d.ts +46 -0
- package/dist/types/src/serializer/decorators/associations/shared.d.ts +23 -0
- package/dist/types/src/serializer/decorators/attribute.d.ts +29 -0
- package/dist/types/src/serializer/decorators/helpers/dreamAttributeOpenapiShape.d.ts +7 -0
- package/dist/types/src/serializer/decorators/helpers/hasSerializersGetter.d.ts +2 -0
- package/dist/types/src/serializer/decorators/helpers/maybeSerializableToDreamSerializerCallbackFunction.d.ts +2 -0
- package/dist/types/src/serializer/index.d.ts +56 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +92 -0
- package/docs/assets/icons.js +18 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +60 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1448 -0
- package/docs/classes/Benchmark.html +4 -0
- package/docs/classes/CalendarDate.html +34 -0
- package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +12 -0
- package/docs/classes/Decorators.html +81 -0
- package/docs/classes/Dream.html +896 -0
- package/docs/classes/DreamApplication.html +37 -0
- package/docs/classes/DreamBin.html +11 -0
- package/docs/classes/DreamCLI.html +7 -0
- package/docs/classes/DreamImporter.html +6 -0
- package/docs/classes/DreamMigrationHelpers.html +32 -0
- package/docs/classes/DreamSerializer.html +19 -0
- package/docs/classes/DreamTransaction.html +5 -0
- package/docs/classes/Encrypt.html +8 -0
- package/docs/classes/Env.html +20 -0
- package/docs/classes/GlobalNameNotSet.html +12 -0
- package/docs/classes/NonLoadedAssociation.html +14 -0
- package/docs/classes/Query.html +383 -0
- package/docs/classes/Range.html +5 -0
- package/docs/classes/RecordNotFound.html +13 -0
- package/docs/classes/ValidationError.html +14 -0
- package/docs/functions/AfterCreate.html +1 -0
- package/docs/functions/AfterCreateCommit.html +13 -0
- package/docs/functions/AfterDestroy.html +1 -0
- package/docs/functions/AfterDestroyCommit.html +13 -0
- package/docs/functions/AfterSave.html +1 -0
- package/docs/functions/AfterSaveCommit.html +13 -0
- package/docs/functions/AfterUpdate.html +1 -0
- package/docs/functions/AfterUpdateCommit.html +13 -0
- package/docs/functions/Attribute.html +1 -0
- package/docs/functions/BeforeCreate.html +1 -0
- package/docs/functions/BeforeDestroy.html +1 -0
- package/docs/functions/BeforeSave.html +1 -0
- package/docs/functions/BeforeUpdate.html +1 -0
- package/docs/functions/RendersMany.html +16 -0
- package/docs/functions/RendersOne.html +16 -0
- package/docs/functions/ReplicaSafe.html +1 -0
- package/docs/functions/STI.html +1 -0
- package/docs/functions/Scope.html +1 -0
- package/docs/functions/SoftDelete.html +19 -0
- package/docs/functions/Sortable.html +1 -0
- package/docs/functions/Validate.html +1 -0
- package/docs/functions/Validates.html +1 -0
- package/docs/functions/Virtual.html +1 -0
- package/docs/functions/camelize.html +1 -0
- package/docs/functions/capitalize.html +1 -0
- package/docs/functions/closeAllDbConnections.html +1 -0
- package/docs/functions/compact.html +1 -0
- package/docs/functions/db.html +1 -0
- package/docs/functions/debug.html +1 -0
- package/docs/functions/dreamDbConnections.html +1 -0
- package/docs/functions/dreamPath.html +1 -0
- package/docs/functions/generateDream.html +1 -0
- package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -0
- package/docs/functions/hyphenize.html +1 -0
- package/docs/functions/inferSerializerFromDreamClassOrViewModelClass.html +1 -0
- package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -0
- package/docs/functions/isEmpty.html +1 -0
- package/docs/functions/loadRepl.html +1 -0
- package/docs/functions/lookupClassByGlobalName.html +1 -0
- package/docs/functions/pascalize.html +1 -0
- package/docs/functions/pgErrorType.html +1 -0
- package/docs/functions/range-1.html +1 -0
- package/docs/functions/relativeDreamPath.html +1 -0
- package/docs/functions/round.html +1 -0
- package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -0
- package/docs/functions/sharedPathPrefix.html +1 -0
- package/docs/functions/snakeify.html +1 -0
- package/docs/functions/sortBy.html +1 -0
- package/docs/functions/standardizeFullyQualifiedModelName.html +1 -0
- package/docs/functions/uncapitalize.html +1 -0
- package/docs/functions/uniq.html +1 -0
- package/docs/functions/validateColumn.html +1 -0
- package/docs/functions/validateTable.html +1 -0
- package/docs/index.html +123 -0
- package/docs/interfaces/AttributeStatement.html +6 -0
- package/docs/interfaces/DecoratorContext.html +8 -0
- package/docs/interfaces/DreamApplicationInitOptions.html +2 -0
- package/docs/interfaces/DreamApplicationOpts.html +8 -0
- package/docs/interfaces/DreamSerializerAssociationStatement.html +11 -0
- package/docs/interfaces/EncryptOptions.html +3 -0
- package/docs/interfaces/OpenapiSchemaProperties.html +1 -0
- package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -0
- package/docs/interfaces/OpenapiTypeFieldObject.html +1 -0
- package/docs/modules.html +163 -0
- package/docs/types/Camelized.html +1 -0
- package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -0
- package/docs/types/DreamAssociationMetadata.html +1 -0
- package/docs/types/DreamAttributes.html +1 -0
- package/docs/types/DreamClassColumn.html +1 -0
- package/docs/types/DreamColumn.html +1 -0
- package/docs/types/DreamColumnNames.html +1 -0
- package/docs/types/DreamLogLevel.html +1 -0
- package/docs/types/DreamLogger.html +1 -0
- package/docs/types/DreamOrViewModelSerializerKey.html +1 -0
- package/docs/types/DreamParamSafeAttributes.html +1 -0
- package/docs/types/DreamParamSafeColumnNames.html +1 -0
- package/docs/types/DreamSerializerKey.html +1 -0
- package/docs/types/DreamSerializers.html +1 -0
- package/docs/types/DreamTableSchema.html +1 -0
- package/docs/types/DreamVirtualColumns.html +1 -0
- package/docs/types/EncryptAlgorithm.html +1 -0
- package/docs/types/Hyphenized.html +1 -0
- package/docs/types/IdType.html +1 -0
- package/docs/types/OpenapiAllTypes.html +1 -0
- package/docs/types/OpenapiFormats.html +1 -0
- package/docs/types/OpenapiNumberFormats.html +1 -0
- package/docs/types/OpenapiPrimitiveTypes.html +1 -0
- package/docs/types/OpenapiSchemaArray.html +1 -0
- package/docs/types/OpenapiSchemaArrayShorthand.html +1 -0
- package/docs/types/OpenapiSchemaBase.html +1 -0
- package/docs/types/OpenapiSchemaBody.html +1 -0
- package/docs/types/OpenapiSchemaBodyShorthand.html +1 -0
- package/docs/types/OpenapiSchemaCommonFields.html +1 -0
- package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -0
- package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -0
- package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -0
- package/docs/types/OpenapiSchemaExpressionRef.html +1 -0
- package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -0
- package/docs/types/OpenapiSchemaInteger.html +1 -0
- package/docs/types/OpenapiSchemaNull.html +1 -0
- package/docs/types/OpenapiSchemaNumber.html +1 -0
- package/docs/types/OpenapiSchemaObject.html +1 -0
- package/docs/types/OpenapiSchemaObjectAllOf.html +1 -0
- package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -0
- package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -0
- package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -0
- package/docs/types/OpenapiSchemaObjectBase.html +1 -0
- package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -0
- package/docs/types/OpenapiSchemaObjectOneOf.html +1 -0
- package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -0
- package/docs/types/OpenapiSchemaObjectShorthand.html +1 -0
- package/docs/types/OpenapiSchemaPartialSegment.html +1 -0
- package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -0
- package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -0
- package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -0
- package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -0
- package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -0
- package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -0
- package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -0
- package/docs/types/OpenapiSchemaString.html +1 -0
- package/docs/types/OpenapiShorthandAllTypes.html +1 -0
- package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -0
- package/docs/types/OpenapiTypeField.html +1 -0
- package/docs/types/Pascalized.html +1 -0
- package/docs/types/PrimaryKeyType.html +1 -0
- package/docs/types/RoundingPrecision.html +1 -0
- package/docs/types/SerializableClassOrSerializerCallback.html +1 -0
- package/docs/types/SerializableDreamClassOrViewModelClass.html +1 -0
- package/docs/types/SerializableDreamOrViewModel.html +1 -0
- package/docs/types/SerializableTypes.html +1 -0
- package/docs/types/Snakeified.html +1 -0
- package/docs/types/Timestamp.html +1 -0
- package/docs/types/UpdateableAssociationProperties.html +1 -0
- package/docs/types/UpdateableProperties.html +1 -0
- package/docs/types/ValidationType.html +1 -0
- package/docs/types/ViewModelSerializerKey.html +1 -0
- package/docs/types/WhereStatementForDream.html +1 -0
- package/docs/types/WhereStatementForDreamClass.html +1 -0
- package/docs/variables/DreamConst.html +1 -0
- package/docs/variables/TRIGRAM_OPERATORS.html +1 -0
- package/docs/variables/openapiPrimitiveTypes-1.html +1 -0
- package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -0
- package/docs/variables/ops.html +1 -0
- package/docs/variables/primaryKeyTypes.html +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
import associationQuery from './internal/associations/associationQuery.js';
|
|
2
|
+
import associationUpdateQuery from './internal/associations/associationUpdateQuery.js';
|
|
3
|
+
import createAssociation from './internal/associations/createAssociation.js';
|
|
4
|
+
import destroyAssociation from './internal/associations/destroyAssociation.js';
|
|
5
|
+
import undestroyAssociation from './internal/associations/undestroyAssociation.js';
|
|
6
|
+
import destroyDream from './internal/destroyDream.js';
|
|
7
|
+
import { destroyOptions, reallyDestroyOptions, undestroyOptions, } from './internal/destroyOptions.js';
|
|
8
|
+
import reload from './internal/reload.js';
|
|
9
|
+
import saveDream from './internal/saveDream.js';
|
|
10
|
+
import { DEFAULT_BYPASS_ALL_DEFAULT_SCOPES, DEFAULT_DEFAULT_SCOPES_TO_BYPASS, DEFAULT_SKIP_HOOKS, } from './internal/scopeHelpers.js';
|
|
11
|
+
import undestroyDream from './internal/undestroyDream.js';
|
|
12
|
+
import LeftJoinLoadBuilder from './LeftJoinLoadBuilder.js';
|
|
13
|
+
import LoadBuilder from './LoadBuilder.js';
|
|
14
|
+
export default class DreamInstanceTransactionBuilder {
|
|
15
|
+
dreamInstance;
|
|
16
|
+
dreamTransaction;
|
|
17
|
+
/**
|
|
18
|
+
* Constructs a new DreamInstanceTransactionBuilder.
|
|
19
|
+
*
|
|
20
|
+
* @param dreamInstance - The Dream instance to build the transaction for
|
|
21
|
+
* @param txn - The DreamTransaction instance
|
|
22
|
+
*/
|
|
23
|
+
constructor(dreamInstance, txn) {
|
|
24
|
+
this.dreamInstance = dreamInstance;
|
|
25
|
+
this.dreamTransaction = txn;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Loads the requested associations upon execution
|
|
29
|
+
*
|
|
30
|
+
* NOTE: {@link Dream#preload} is often a preferrable way of achieving the
|
|
31
|
+
* same goal.
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* await user
|
|
35
|
+
* .load('posts', { body: ops.ilike('%hello world%') }, 'comments', 'replies')
|
|
36
|
+
* .load('images')
|
|
37
|
+
* .execute()
|
|
38
|
+
*
|
|
39
|
+
* user.posts[0].comments[0].replies[0]
|
|
40
|
+
* // Reply{}
|
|
41
|
+
*
|
|
42
|
+
* user.images[0]
|
|
43
|
+
* // Image{}
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @param args - A list of associations (and optional where clauses) to load
|
|
47
|
+
* @returns A chainable LoadBuilder instance
|
|
48
|
+
*/
|
|
49
|
+
load(...args) {
|
|
50
|
+
return new LoadBuilder(this.dreamInstance, this.dreamTransaction).load(...args);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Load each specified association using a single SQL query.
|
|
54
|
+
* See {@link #load} for loading in separate queries.
|
|
55
|
+
*
|
|
56
|
+
* Note: since leftJoinPreload loads via single query, it has
|
|
57
|
+
* some downsides and that may be avoided using {@link #load}:
|
|
58
|
+
* 1. `limit` and `offset` will be automatically removed
|
|
59
|
+
* 2. `through` associations will bring additional namespaces into the query that can conflict with through associations from other associations, creating an invalid query
|
|
60
|
+
* 3. each nested association will result in an additional record which duplicates data from the outer record. E.g., given `.leftJoinPreload('a', 'b', 'c')`, if each `a` has 10 `b` and each `b` has 10 `c`, then for one `a`, 100 records will be returned, each of which has all of the columns of `a`. `.load('a', 'b', 'c')` would perform three separate SQL queries, but the data for a single `a` would only be returned once.
|
|
61
|
+
* 4. the individual query becomes more complex the more associations are included
|
|
62
|
+
* 5. associations loading associations loading associations could result in exponential amounts of data; in those cases, `.load(...).findEach(...)` avoids instantiating massive amounts of data at once
|
|
63
|
+
* Loads the requested associations upon execution
|
|
64
|
+
*
|
|
65
|
+
* NOTE: {@link Dream#leftJoinPreload} is often a preferrable way of achieving the
|
|
66
|
+
* same goal.
|
|
67
|
+
*
|
|
68
|
+
* ```ts
|
|
69
|
+
* await user.txn(txn)
|
|
70
|
+
* .leftJoinLoad('posts', { body: ops.ilike('%hello world%') }, 'comments', 'replies')
|
|
71
|
+
* .leftJoinLoad('images')
|
|
72
|
+
* .execute()
|
|
73
|
+
*
|
|
74
|
+
* user.posts[0].comments[0].replies[0]
|
|
75
|
+
* // Reply{}
|
|
76
|
+
*
|
|
77
|
+
* user.images[0]
|
|
78
|
+
* // Image{}
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @param args - A list of associations (and optional where clauses) to load
|
|
82
|
+
* @returns A chainable LeftJoinLoadBuilder instance
|
|
83
|
+
*/
|
|
84
|
+
leftJoinLoad(...args) {
|
|
85
|
+
return new LeftJoinLoadBuilder(this.dreamInstance, this.dreamTransaction).leftJoinLoad(...args);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Returns a new Query instance with the provided
|
|
89
|
+
* inner join statement attached
|
|
90
|
+
*
|
|
91
|
+
* ```ts
|
|
92
|
+
* await ApplicationModel.transaction(async txn => {
|
|
93
|
+
* await user.txn(txn).innerJoin('posts').first()
|
|
94
|
+
* })
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @param args - A chain of association names and where clauses
|
|
98
|
+
* @returns A Query for this model with the inner join clause applied
|
|
99
|
+
*/
|
|
100
|
+
innerJoin(...args) {
|
|
101
|
+
return this.queryInstance().innerJoin(...args);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Returns a new Query instance with the provided
|
|
105
|
+
* left join statement attached
|
|
106
|
+
*
|
|
107
|
+
* ```ts
|
|
108
|
+
* await ApplicationModel.transaction(async txn => {
|
|
109
|
+
* await user.txn(txn).leftJoin('posts').first()
|
|
110
|
+
* })
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* @param args - A chain of association names and where clauses
|
|
114
|
+
* @returns A Query for this model with the left join clause applied
|
|
115
|
+
*/
|
|
116
|
+
leftJoin(...args) {
|
|
117
|
+
return this.queryInstance().leftJoin(...args);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Deletes the record represented by this instance
|
|
121
|
+
* from the database, calling any destroy
|
|
122
|
+
* hooks on this model.
|
|
123
|
+
*
|
|
124
|
+
* ```ts
|
|
125
|
+
* const user = await User.last()
|
|
126
|
+
* await ApplicationModel.transaction(async txn => {
|
|
127
|
+
* await user.txn(txn).destroy()
|
|
128
|
+
* })
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* @param options - Options for destroying the instance
|
|
132
|
+
* @param options.skipHooks - If true, skips applying model hooks during the destroy operation. Defaults to false
|
|
133
|
+
* @param options.cascade - If false, skips destroying associations marked `dependent: 'destroy'`. Defaults to true
|
|
134
|
+
* @param options.bypassAllDefaultScopes - If true, bypasses all default scopes when cascade destroying. Defaults to false
|
|
135
|
+
* @param options.defaultScopesToBypass - An array of default scope names to bypass when cascade destroying. Defaults to an empty array
|
|
136
|
+
* @returns The instance that was destroyed
|
|
137
|
+
*/
|
|
138
|
+
async destroy(options = {}) {
|
|
139
|
+
return await destroyDream(this.dreamInstance, this.dreamTransaction, destroyOptions(options));
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Deletes the record represented by this instance
|
|
143
|
+
* from the database, calling any destroy
|
|
144
|
+
* hooks on this model.
|
|
145
|
+
*
|
|
146
|
+
* ```ts
|
|
147
|
+
* const user = await User.last()
|
|
148
|
+
* await ApplicationModel.transaction(async txn => {
|
|
149
|
+
* await user.txn(txn).reallyDestroy()
|
|
150
|
+
* })
|
|
151
|
+
* ```
|
|
152
|
+
*
|
|
153
|
+
* @param options - Options for destroying the instance
|
|
154
|
+
* @param options.skipHooks - If true, skips applying model hooks during the destroy operation. Defaults to false
|
|
155
|
+
* @param options.cascade - If false, skips destroying associations marked `dependent: 'destroy'`. Defaults to true
|
|
156
|
+
* @param options.bypassAllDefaultScopes - If true, bypasses all default scopes when cascade destroying. Defaults to false
|
|
157
|
+
* @param options.defaultScopesToBypass - An array of default scope names to bypass when cascade destroying. Defaults to an empty array
|
|
158
|
+
* @returns The instance that was destroyed
|
|
159
|
+
*/
|
|
160
|
+
async reallyDestroy(options = {}) {
|
|
161
|
+
return await destroyDream(this.dreamInstance, this.dreamTransaction, reallyDestroyOptions(options));
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Undestroys a SoftDelete model, unsetting
|
|
165
|
+
* the `deletedAt` field in the database.
|
|
166
|
+
*
|
|
167
|
+
* If the model is not a SoftDelete model,
|
|
168
|
+
* this will raise an exception.
|
|
169
|
+
*
|
|
170
|
+
* ```ts
|
|
171
|
+
* const user = await User.removeAllDefaultScopes().last()
|
|
172
|
+
* await user.txn(txn).undestroy()
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* @param options - Options for undestroying the instance
|
|
176
|
+
* @param options.skipHooks - If true, skips applying model hooks during the undestroy operation. Defaults to false
|
|
177
|
+
* @param options.cascade - If false, skips undestroying associations marked `dependent: 'destroy'`. Defaults to true
|
|
178
|
+
* @param options.bypassAllDefaultScopes - If true, bypasses all default scopes when cascade undestroying. Defaults to false
|
|
179
|
+
* @param options.defaultScopesToBypass - An array of default scope names to bypass when cascade undestroying (soft delete is always bypassed). Defaults to an empty array
|
|
180
|
+
* @returns The undestroyed instance
|
|
181
|
+
*/
|
|
182
|
+
async undestroy(options = {}) {
|
|
183
|
+
await undestroyDream(this.dreamInstance, this.dreamTransaction, undestroyOptions(options));
|
|
184
|
+
await this.reload();
|
|
185
|
+
return this.dreamInstance;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Applies all attribute changes passed to the Dream
|
|
189
|
+
* instance, leveraging any custom-defined setters,
|
|
190
|
+
* and then saves the Dream instance. Can be called
|
|
191
|
+
* on an unpersisted Dream instance.
|
|
192
|
+
*
|
|
193
|
+
* See {@link Dream.save | save} for details on
|
|
194
|
+
* the side effects of saving.
|
|
195
|
+
*
|
|
196
|
+
* NOTE:
|
|
197
|
+
* To bypass custom-defined setters, use {@link Dream.updateAttributes | updateAttributes} instead.
|
|
198
|
+
*
|
|
199
|
+
* ```ts
|
|
200
|
+
* const user = await User.create({ email: 'saly@gmail.com' })
|
|
201
|
+
* await ApplicationModel.transaction(async txn => {
|
|
202
|
+
* await user.txn(txn).update({ email: 'sally@gmail.com' })
|
|
203
|
+
* })
|
|
204
|
+
* ```
|
|
205
|
+
*
|
|
206
|
+
* @param attributes - the attributes to set on the model
|
|
207
|
+
* @param opts.skipHooks - if true, will skip applying model hooks. Defaults to false
|
|
208
|
+
* @returns void
|
|
209
|
+
*/
|
|
210
|
+
async update(attributes, { skipHooks } = {}) {
|
|
211
|
+
this.dreamInstance.assignAttributes(attributes);
|
|
212
|
+
await saveDream(this.dreamInstance, this.dreamTransaction, { skipHooks });
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Applies all attribute changes passed to the dream,
|
|
216
|
+
* bypassing any custom-defined setters,
|
|
217
|
+
* and then saves the dream instance. Does not bypass
|
|
218
|
+
* model hooks.
|
|
219
|
+
*
|
|
220
|
+
* See {@link Dream.save | save} for details on
|
|
221
|
+
* the side effects of saving.
|
|
222
|
+
*
|
|
223
|
+
* NOTE:
|
|
224
|
+
* To update the values without bypassing any custom-defined
|
|
225
|
+
* setters, use {@link Dream.update | update} instead.
|
|
226
|
+
*
|
|
227
|
+
* ```ts
|
|
228
|
+
* const user = await User.create({ email: 'saly@gmail.com' })
|
|
229
|
+
* await ApplicationModel.transaction(async txn => {
|
|
230
|
+
* await user.txn(txn).updateAttributes({ email: 'sally@gmail.com' })
|
|
231
|
+
* })
|
|
232
|
+
* ```
|
|
233
|
+
*
|
|
234
|
+
* @param attributes - The attributes to update on this instance
|
|
235
|
+
* @param opts.skipHooks - if true, will skip applying model hooks. Defaults to false
|
|
236
|
+
* @returns - void
|
|
237
|
+
*/
|
|
238
|
+
async updateAttributes(attributes, { skipHooks } = {}) {
|
|
239
|
+
this.dreamInstance.setAttributes(attributes);
|
|
240
|
+
await saveDream(this.dreamInstance, this.dreamTransaction, { skipHooks });
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Reloads an instance, refreshing all it's attribute values
|
|
244
|
+
* to those in the database.
|
|
245
|
+
*
|
|
246
|
+
* NOTE: this does not refresh associations
|
|
247
|
+
*
|
|
248
|
+
* ```ts
|
|
249
|
+
* await ApplicationModel.transaction(async txn => {
|
|
250
|
+
* await user.txn(txn).reload()
|
|
251
|
+
* })
|
|
252
|
+
* ```
|
|
253
|
+
*
|
|
254
|
+
* @returns void
|
|
255
|
+
*/
|
|
256
|
+
async reload() {
|
|
257
|
+
await reload(this.dreamInstance, this.dreamTransaction);
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Saves the state of the current instance to the
|
|
261
|
+
* database. For new instances (that have not been
|
|
262
|
+
* persisted), `save` and `create` model hooks will be called.
|
|
263
|
+
* For instances that have already been persisted,
|
|
264
|
+
* the `save` and `update` model hooks will be called.
|
|
265
|
+
*
|
|
266
|
+
* Upon saving a new instance, the primary key, timestamp
|
|
267
|
+
* fields (if defined), and `type` (if STI) will be set on
|
|
268
|
+
* the model.
|
|
269
|
+
*
|
|
270
|
+
* Upon updating an instance, the update timestamp (if defined)
|
|
271
|
+
* will be updated on the model.
|
|
272
|
+
*
|
|
273
|
+
* ```ts
|
|
274
|
+
* const user = User.new({ email: 'how@yadoin' })
|
|
275
|
+
*
|
|
276
|
+
* await ApplicationModel.transaction(async txn => {
|
|
277
|
+
* user.name = 'fred'
|
|
278
|
+
* await user.txn(txn).save()
|
|
279
|
+
* })
|
|
280
|
+
*
|
|
281
|
+
* user.email // 'how@yadoin'
|
|
282
|
+
* user.name // 'fred'
|
|
283
|
+
* user.id // 1
|
|
284
|
+
* user.createdAt // A DateTime object
|
|
285
|
+
* user.updatedAt // A DateTime object
|
|
286
|
+
*
|
|
287
|
+
* // If User were STI:
|
|
288
|
+
* user.type // 'User'
|
|
289
|
+
* ```
|
|
290
|
+
*
|
|
291
|
+
* @param opts.skipHooks - if true, will skip applying model hooks. Defaults to false
|
|
292
|
+
* @returns void
|
|
293
|
+
*/
|
|
294
|
+
async save({ skipHooks } = {}) {
|
|
295
|
+
await saveDream(this.dreamInstance, this.dreamTransaction, { skipHooks });
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Returns a Query instance for the specified
|
|
299
|
+
* association on the current instance.
|
|
300
|
+
*
|
|
301
|
+
* ```ts
|
|
302
|
+
* await ApplicationModel.transaction(async txn => {
|
|
303
|
+
* await user.txn(txn).associationQuery('posts').all()
|
|
304
|
+
* // only user posts returned
|
|
305
|
+
* })
|
|
306
|
+
* ```
|
|
307
|
+
*
|
|
308
|
+
* @returns A Query scoped to the specified association on the current instance
|
|
309
|
+
*/
|
|
310
|
+
associationQuery(associationName, joinOnStatements) {
|
|
311
|
+
return associationQuery(this.dreamInstance, this.dreamTransaction, associationName, {
|
|
312
|
+
joinOnStatements: joinOnStatements,
|
|
313
|
+
bypassAllDefaultScopes: DEFAULT_BYPASS_ALL_DEFAULT_SCOPES,
|
|
314
|
+
defaultScopesToBypass: DEFAULT_DEFAULT_SCOPES_TO_BYPASS,
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Updates all records matching the association with
|
|
319
|
+
* the provided attributes. If a where statement is passed,
|
|
320
|
+
* The where statement will be applied to the query
|
|
321
|
+
* before updating.
|
|
322
|
+
*
|
|
323
|
+
* ```ts
|
|
324
|
+
* await ApplicationModel.transaction(async txn => {
|
|
325
|
+
* await user.txn(txn).createAssociation('posts', { body: 'hello world' })
|
|
326
|
+
* await user.txn(txn).createAssociation('posts', { body: 'howyadoin' })
|
|
327
|
+
* await user.txn(txn).updateAssociation('posts', { body: 'goodbye world' }, { on: { body: 'hello world' }})
|
|
328
|
+
* // 1
|
|
329
|
+
* })
|
|
330
|
+
* ```
|
|
331
|
+
*
|
|
332
|
+
* @param associationName - The name of the association to update
|
|
333
|
+
* @param attributes - The attributes to update on the association
|
|
334
|
+
* @param updateAssociationOptions - Options for updating the association
|
|
335
|
+
* @param updateAssociationOptions.where - Optional where statement to apply to query before updating
|
|
336
|
+
* @param updateAssociationOptions.bypassAllDefaultScopes - If true, bypasses all default scopes when updating the association. Defaults to false
|
|
337
|
+
* @param updateAssociationOptions.defaultScopesToBypass - An array of default scope names to bypass when updating the association. Defaults to an empty array
|
|
338
|
+
* @param updateAssociationOptions.skipHooks - If true, skips applying model hooks during the update operation. Defaults to false
|
|
339
|
+
* @returns The number of updated records
|
|
340
|
+
*/
|
|
341
|
+
async updateAssociation(associationName, attributes, updateAssociationOptions) {
|
|
342
|
+
return await associationUpdateQuery(this.dreamInstance, this.dreamTransaction, associationName, {
|
|
343
|
+
joinOnStatements: {
|
|
344
|
+
on: updateAssociationOptions?.on,
|
|
345
|
+
notOn: updateAssociationOptions?.notOn,
|
|
346
|
+
onAny: updateAssociationOptions?.onAny,
|
|
347
|
+
},
|
|
348
|
+
bypassAllDefaultScopes: updateAssociationOptions?.bypassAllDefaultScopes ?? DEFAULT_BYPASS_ALL_DEFAULT_SCOPES,
|
|
349
|
+
defaultScopesToBypass: updateAssociationOptions?.defaultScopesToBypass ?? DEFAULT_DEFAULT_SCOPES_TO_BYPASS,
|
|
350
|
+
}).update(attributes, { skipHooks: updateAssociationOptions?.skipHooks ?? DEFAULT_SKIP_HOOKS });
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Creates an association for an instance. Automatically
|
|
354
|
+
* handles setting foreign key and, in the case of polymorphism,
|
|
355
|
+
* foreign key type.
|
|
356
|
+
*
|
|
357
|
+
* ```ts
|
|
358
|
+
* await ApplicationModel.transaction(async txn => {
|
|
359
|
+
* await user.txn(txn).createAssociation('posts', { body: 'hello world' })
|
|
360
|
+
* })
|
|
361
|
+
* ```
|
|
362
|
+
*
|
|
363
|
+
* @param associationName - The name of the association to create
|
|
364
|
+
* @param attributes - The attributes with which to create the associated model
|
|
365
|
+
* @returns The created association
|
|
366
|
+
*/
|
|
367
|
+
async createAssociation(associationName, opts = {}) {
|
|
368
|
+
return await createAssociation(this.dreamInstance, this.dreamTransaction, associationName, opts);
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Destroys models associated with the current instance,
|
|
372
|
+
* deleting their corresponding records within the database.
|
|
373
|
+
*
|
|
374
|
+
* ```ts
|
|
375
|
+
* await ApplicationModel.transaction(async txn => {
|
|
376
|
+
* await user.txn(txn).destroyAssociation('posts', { on: { body: 'hello world' } })
|
|
377
|
+
* })
|
|
378
|
+
* ```
|
|
379
|
+
*
|
|
380
|
+
* @param associationName - The name of the association to destroy
|
|
381
|
+
* @param options - Options for destroying the association
|
|
382
|
+
* @param options.on - Optional where statement to apply to query before destroying
|
|
383
|
+
* @param options.skipHooks - If true, skips applying model hooks during the destroy operation. Defaults to false
|
|
384
|
+
* @param options.cascade - If false, skips destroying associations marked `dependent: 'destroy'`. Defaults to true
|
|
385
|
+
* @param options.bypassAllDefaultScopes - If true, bypasses all default scopes when destroying the association. Defaults to false
|
|
386
|
+
* @param options.defaultScopesToBypass - An array of default scope names to bypass when destroying the association. Defaults to an empty array
|
|
387
|
+
* @returns The number of records deleted
|
|
388
|
+
*/
|
|
389
|
+
async destroyAssociation(associationName, options) {
|
|
390
|
+
return await destroyAssociation(this.dreamInstance, this.dreamTransaction, associationName, {
|
|
391
|
+
...destroyOptions(options),
|
|
392
|
+
joinOnStatements: {
|
|
393
|
+
on: options?.on,
|
|
394
|
+
notOn: options?.notOn,
|
|
395
|
+
onAny: options?.onAny,
|
|
396
|
+
},
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Destroys models associated with the current instance,
|
|
401
|
+
* deleting their corresponding records within the database.
|
|
402
|
+
*
|
|
403
|
+
* If the record, or else any of its associations
|
|
404
|
+
* which are marked cascade: "destroy", are using
|
|
405
|
+
* the SoftDelete decorator, it will be bypassed,
|
|
406
|
+
* causing those records to be deleted from the database.
|
|
407
|
+
*
|
|
408
|
+
* ```ts
|
|
409
|
+
* await ApplicationModel.transaction(async txn => {
|
|
410
|
+
* await user.txn(txn).reallyDestroyAssociation('posts', { on: { body: 'hello world' } })
|
|
411
|
+
* })
|
|
412
|
+
* ```
|
|
413
|
+
*
|
|
414
|
+
* @param associationName - The name of the association to destroy
|
|
415
|
+
* @param options - Options for destroying the association
|
|
416
|
+
* @param options.on - Optional where statement to apply to query before destroying
|
|
417
|
+
* @param options.skipHooks - If true, skips applying model hooks during the destroy operation. Defaults to false
|
|
418
|
+
* @param options.cascade - If true, cascades the destroy operation to associations marked with `dependent: 'destroy'`. Defaults to true
|
|
419
|
+
* @param options.bypassAllDefaultScopes - If true, bypasses all default scopes when destroying the association. Defaults to false
|
|
420
|
+
* @param options.defaultScopesToBypass - An array of default scope names to bypass when destroying the association. Defaults to an empty array
|
|
421
|
+
* @returns The number of records deleted
|
|
422
|
+
*/
|
|
423
|
+
async reallyDestroyAssociation(associationName, options) {
|
|
424
|
+
return await destroyAssociation(this.dreamInstance, this.dreamTransaction, associationName, {
|
|
425
|
+
...reallyDestroyOptions(options),
|
|
426
|
+
joinOnStatements: {
|
|
427
|
+
on: options?.on,
|
|
428
|
+
notOn: options?.notOn,
|
|
429
|
+
onAny: options?.onAny,
|
|
430
|
+
},
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Undestroys a SoftDelete association.
|
|
435
|
+
* If cascade: true is passed, any child
|
|
436
|
+
* associations that have been soft deleted
|
|
437
|
+
* will also be undeleted.
|
|
438
|
+
*
|
|
439
|
+
* ```ts
|
|
440
|
+
* await user.undestroyAssociation('posts', { on: { body: 'hello world' } })
|
|
441
|
+
* ```
|
|
442
|
+
*
|
|
443
|
+
* @param associationName - The name of the association to undestroy
|
|
444
|
+
* @param options - Options for undestroying the association
|
|
445
|
+
* @param options.on - Optional where statement to apply to query before undestroying
|
|
446
|
+
* @param options.skipHooks - If true, skips applying model hooks during the undestroy operation. Defaults to false
|
|
447
|
+
* @param options.cascade - If false, skips undestroying associations marked `dependent: 'destroy'`. Defaults to true
|
|
448
|
+
* @param options.bypassAllDefaultScopes - If true, bypasses all default scopes when undestroying the association. Defaults to false
|
|
449
|
+
* @param options.defaultScopesToBypass - An array of default scope names to bypass when undestroying the association. Defaults to an empty array
|
|
450
|
+
* @returns The number of records undestroyed
|
|
451
|
+
*/
|
|
452
|
+
async undestroyAssociation(associationName, options) {
|
|
453
|
+
return await undestroyAssociation(this.dreamInstance, this.dreamTransaction, associationName, {
|
|
454
|
+
...undestroyOptions(options),
|
|
455
|
+
joinOnStatements: {
|
|
456
|
+
on: options?.on,
|
|
457
|
+
notOn: options?.notOn,
|
|
458
|
+
onAny: options?.onAny,
|
|
459
|
+
},
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
///////////////////
|
|
463
|
+
// end: undestroyAssociation
|
|
464
|
+
///////////////////
|
|
465
|
+
/**
|
|
466
|
+
* @internal
|
|
467
|
+
*
|
|
468
|
+
* returns a query instance, scoped to the current
|
|
469
|
+
* dream instance with primary key where statement
|
|
470
|
+
* automatically applied.
|
|
471
|
+
*/
|
|
472
|
+
queryInstance() {
|
|
473
|
+
const dreamClass = this.dreamInstance.constructor;
|
|
474
|
+
const id = this.dreamInstance.primaryKeyValue;
|
|
475
|
+
return dreamClass.txn(this.dreamTransaction).where({ [this.dreamInstance.primaryKey]: id });
|
|
476
|
+
}
|
|
477
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { runHook } from './internal/runHooksFor.js';
|
|
2
|
+
// though this class is called `DreamTransaction`, it is not itself
|
|
3
|
+
// a transaction class, as much as a collector for various callbacks
|
|
4
|
+
// that must be run after the underlying transaction is commited (i.e.
|
|
5
|
+
// AfterCreateCommit, AfterUpdateCommit, etc...).
|
|
6
|
+
export default class DreamTransaction {
|
|
7
|
+
_kyselyTransaction;
|
|
8
|
+
commitHooks = [];
|
|
9
|
+
get kyselyTransaction() {
|
|
10
|
+
return this._kyselyTransaction;
|
|
11
|
+
}
|
|
12
|
+
set kyselyTransaction(txn) {
|
|
13
|
+
this._kyselyTransaction = txn;
|
|
14
|
+
}
|
|
15
|
+
addCommitHook(hookStatement, dreamInstance) {
|
|
16
|
+
this.commitHooks.push({ dreamInstance, hookStatement });
|
|
17
|
+
}
|
|
18
|
+
async runAfterCommitHooks(txn) {
|
|
19
|
+
for (const hook of this.commitHooks) {
|
|
20
|
+
await runHook(hook.hookStatement, hook.dreamInstance, txn);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export default class LeftJoinLoadBuilder {
|
|
2
|
+
dream;
|
|
3
|
+
dreamTransaction;
|
|
4
|
+
query;
|
|
5
|
+
/**
|
|
6
|
+
* An intermediate class on the way to executing a load
|
|
7
|
+
* query. this can be accessed on an instance of a dream
|
|
8
|
+
* model by using the `#load` method:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const user = await User.firstOrFail()
|
|
12
|
+
* await user.load('settings').execute()
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
constructor(dream, txn) {
|
|
16
|
+
this.dream = dream['clone']();
|
|
17
|
+
// Load queries start from the table corresponding to an instance
|
|
18
|
+
// of a Dream. However, the Dream may have default scopes that would
|
|
19
|
+
// preclude finding that instance, so the Query that forms the base of
|
|
20
|
+
// a load must be unscoped, but that unscoping should not carry through
|
|
21
|
+
// to other associations (thus the use of `removeAllDefaultScopesExceptOnAssociations`
|
|
22
|
+
// instead of `removeAllDefaultScopes`).
|
|
23
|
+
this.query = this.dream.query()['removeAllDefaultScopesExceptOnAssociations']();
|
|
24
|
+
this.dreamTransaction = txn;
|
|
25
|
+
}
|
|
26
|
+
passthrough(passthroughWhereStatement) {
|
|
27
|
+
this.query = this.query.passthrough(passthroughWhereStatement);
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Attaches a load statement to the load builder
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* const user = await User.firstOrFail()
|
|
35
|
+
* await user
|
|
36
|
+
* .load('settings')
|
|
37
|
+
* .load('posts', 'comments', 'replies', ['image', 'localizedText'])
|
|
38
|
+
* .execute()
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
leftJoinLoad(...args) {
|
|
42
|
+
this.query = this.query.leftJoinPreload(...args);
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* executes a load builder query, binding
|
|
47
|
+
* all associations to their respective model
|
|
48
|
+
* instances.
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* const user = await User.firstOrFail()
|
|
52
|
+
* await user
|
|
53
|
+
* .load('settings')
|
|
54
|
+
* .load('posts', 'comments', 'replies', ['image', 'localizedText'])
|
|
55
|
+
* .execute()
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
async execute() {
|
|
59
|
+
if (this.dreamTransaction) {
|
|
60
|
+
this.query = this.query.txn(this.dreamTransaction);
|
|
61
|
+
}
|
|
62
|
+
const dreamWithLoadedAssociations = await this.query.firstOrFail();
|
|
63
|
+
Object.keys(this.query['leftJoinStatements']).forEach(associationName => {
|
|
64
|
+
this.query['hydrateAssociation']([this.dream], this.dream['getAssociationMetadata'](associationName), this.associationToPreloadedDreamsAndWhatTheyPointTo({
|
|
65
|
+
pointsToPrimaryKey: this.dream.primaryKeyValue,
|
|
66
|
+
associatedModels: dreamWithLoadedAssociations[associationName],
|
|
67
|
+
}));
|
|
68
|
+
});
|
|
69
|
+
return this.dream;
|
|
70
|
+
}
|
|
71
|
+
associationToPreloadedDreamsAndWhatTheyPointTo({ pointsToPrimaryKey, associatedModels, }) {
|
|
72
|
+
return [associatedModels].flat().map(dream => ({ dream, pointsToPrimaryKey }));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export default class LoadBuilder {
|
|
2
|
+
dream;
|
|
3
|
+
dreamTransaction;
|
|
4
|
+
query;
|
|
5
|
+
/**
|
|
6
|
+
* An intermediate class on the way to executing a load
|
|
7
|
+
* query. this can be accessed on an instance of a dream
|
|
8
|
+
* model by using the `#load` method:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const user = await User.firstOrFail()
|
|
12
|
+
* await user.load('settings').execute()
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
constructor(dream, txn) {
|
|
16
|
+
this.dream = dream['clone']();
|
|
17
|
+
// Load queries start from the table corresponding to an instance
|
|
18
|
+
// of a Dream. However, the Dream may have default scopes that would
|
|
19
|
+
// preclude finding that instance, so the Query that forms the base of
|
|
20
|
+
// a load must be unscoped, but that unscoping should not carry through
|
|
21
|
+
// to other associations (thus the use of `removeAllDefaultScopesExceptOnAssociations`
|
|
22
|
+
// instead of `removeAllDefaultScopes`).
|
|
23
|
+
this.query = this.dream.query()['removeAllDefaultScopesExceptOnAssociations']();
|
|
24
|
+
this.dreamTransaction = txn;
|
|
25
|
+
}
|
|
26
|
+
passthrough(passthroughWhereStatement) {
|
|
27
|
+
this.query = this.query.passthrough(passthroughWhereStatement);
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Attaches a load statement to the load builder
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* const user = await User.firstOrFail()
|
|
35
|
+
* await user
|
|
36
|
+
* .load('settings')
|
|
37
|
+
* .load('posts', 'comments', 'replies', ['image', 'localizedText'])
|
|
38
|
+
* .execute()
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
load(...args) {
|
|
42
|
+
this.query = this.query.preload(...args);
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* executes a load builder query, binding
|
|
47
|
+
* all associations to their respective model
|
|
48
|
+
* instances.
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* const user = await User.firstOrFail()
|
|
52
|
+
* await user
|
|
53
|
+
* .load('settings')
|
|
54
|
+
* .load('posts', 'comments', 'replies', ['image', 'localizedText'])
|
|
55
|
+
* .execute()
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
async execute() {
|
|
59
|
+
if (this.dreamTransaction) {
|
|
60
|
+
this.query = this.query.txn(this.dreamTransaction);
|
|
61
|
+
}
|
|
62
|
+
await this.query['hydratePreload'](this.dream);
|
|
63
|
+
return this.dream;
|
|
64
|
+
}
|
|
65
|
+
}
|