@rvoh/dream 0.31.0 → 0.31.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/dist/cjs/src/Dream.js +2 -3
- package/dist/cjs/src/bin/helpers/sync.js +2 -2
- package/dist/cjs/src/cli/logger/loggable/DreamCliLoggableSpinner.js +1 -1
- package/dist/cjs/src/decorators/field/association/shared.js +8 -8
- package/dist/cjs/src/dream/Query.js +5 -5
- package/dist/cjs/src/{openapi/types.js → dream/constants.js} +13 -1
- package/dist/cjs/src/dream/internal/similarity/SimilarityBuilder.js +3 -3
- package/dist/cjs/src/helpers/cli/SchemaBuilder.js +5 -5
- package/dist/cjs/src/helpers/cli/generateDream.js +1 -1
- package/dist/cjs/src/helpers/db/primaryKeyType.js +2 -2
- package/dist/cjs/src/helpers/isEmpty.js +2 -0
- package/dist/cjs/src/helpers/sort.js +24 -0
- package/dist/cjs/src/helpers/sortBy.js +19 -2
- package/dist/cjs/src/helpers/uniq.js +6 -5
- package/dist/cjs/src/index.js +8 -7
- package/dist/cjs/src/ops/ops-statement.js +3 -3
- package/dist/cjs/src/serializer/index.js +2 -2
- package/dist/esm/src/Dream.js +3 -4
- package/dist/esm/src/bin/helpers/sync.js +2 -2
- package/dist/esm/src/cli/logger/loggable/DreamCliLoggableSpinner.js +1 -1
- package/dist/esm/src/decorators/field/association/shared.js +6 -6
- package/dist/esm/src/dream/Query.js +1 -1
- package/dist/esm/src/{openapi/types.js → dream/constants.js} +12 -0
- package/dist/esm/src/dream/internal/similarity/SimilarityBuilder.js +1 -1
- package/dist/esm/src/errors/associations/InvalidComputedForeignKey.js +1 -1
- package/dist/esm/src/helpers/cli/SchemaBuilder.js +3 -3
- package/dist/esm/src/helpers/cli/generateDream.js +1 -1
- package/dist/esm/src/helpers/db/primaryKeyType.js +1 -1
- package/dist/esm/src/helpers/isEmpty.js +2 -0
- package/dist/esm/src/helpers/sort.js +21 -0
- package/dist/esm/src/helpers/sortBy.js +19 -2
- package/dist/esm/src/helpers/uniq.js +6 -5
- package/dist/esm/src/index.js +2 -2
- package/dist/esm/src/ops/ops-statement.js +1 -1
- package/dist/esm/src/serializer/index.js +1 -1
- package/dist/types/src/Dream.d.ts +13 -13
- package/dist/types/src/cli/logger/DreamCliLogger.d.ts +1 -12
- package/dist/types/src/cli/logger/loggable/DreamCliLoggable.d.ts +1 -1
- package/dist/types/src/cli/logger/loggable/DreamCliLoggableSpinner.d.ts +1 -1
- package/dist/types/src/cli/logger/loggable/DreamCliLoggableText.d.ts +1 -1
- package/dist/types/src/cli/logger/loggable/colorize.d.ts +1 -1
- package/dist/types/src/db/ConnectedToDB.d.ts +2 -2
- package/dist/types/src/db/ConnectionConfRetriever.d.ts +1 -1
- package/dist/types/src/db/DreamDbConnection.d.ts +1 -1
- package/dist/types/src/db/dataTypes.d.ts +0 -3
- package/dist/types/src/db/index.d.ts +1 -1
- package/dist/types/src/decorators/Decorators.d.ts +6 -6
- package/dist/types/src/decorators/field/association/BelongsTo.d.ts +2 -30
- package/dist/types/src/decorators/field/association/HasMany.d.ts +2 -15
- package/dist/types/src/decorators/field/association/HasOne.d.ts +2 -7
- package/dist/types/src/decorators/field/association/associationToGetterSetterProp.d.ts +4 -4
- package/dist/types/src/decorators/field/association/shared.d.ts +1 -100
- package/dist/types/src/decorators/field/lifecycle/AfterCreate.d.ts +1 -1
- package/dist/types/src/decorators/field/lifecycle/AfterCreateCommit.d.ts +1 -1
- package/dist/types/src/decorators/field/lifecycle/AfterSave.d.ts +1 -1
- package/dist/types/src/decorators/field/lifecycle/AfterSaveCommit.d.ts +1 -1
- package/dist/types/src/decorators/field/lifecycle/AfterUpdate.d.ts +1 -1
- package/dist/types/src/decorators/field/lifecycle/AfterUpdateCommit.d.ts +1 -1
- package/dist/types/src/decorators/field/lifecycle/BeforeCreate.d.ts +1 -1
- package/dist/types/src/decorators/field/lifecycle/BeforeSave.d.ts +1 -1
- package/dist/types/src/decorators/field/lifecycle/BeforeUpdate.d.ts +1 -1
- package/dist/types/src/decorators/field/lifecycle/shared.d.ts +1 -30
- package/dist/types/src/decorators/field/validation/Validates.d.ts +1 -1
- package/dist/types/src/dream/DreamClassTransactionBuilder.d.ts +6 -4
- package/dist/types/src/dream/DreamInstanceTransactionBuilder.d.ts +4 -2
- package/dist/types/src/dream/DreamTransaction.d.ts +1 -1
- package/dist/types/src/dream/LeftJoinLoadBuilder.d.ts +3 -2
- package/dist/types/src/dream/LoadBuilder.d.ts +3 -2
- package/dist/types/src/dream/Query.d.ts +5 -47
- package/dist/types/src/dream/constants.d.ts +15 -0
- package/dist/types/src/dream/internal/applyScopeBypassingSettingsToQuery.d.ts +1 -1
- package/dist/types/src/dream/internal/associations/associationQuery.d.ts +1 -1
- package/dist/types/src/dream/internal/associations/associationUpdateQuery.d.ts +1 -1
- package/dist/types/src/dream/internal/associations/createAssociation.d.ts +1 -1
- package/dist/types/src/dream/internal/associations/destroyAssociation.d.ts +1 -1
- package/dist/types/src/dream/internal/associations/undestroyAssociation.d.ts +1 -1
- package/dist/types/src/dream/internal/checkSingleValidation.d.ts +1 -1
- package/dist/types/src/dream/internal/destroyOptions.d.ts +1 -1
- package/dist/types/src/dream/internal/orderByDirection.d.ts +1 -1
- package/dist/types/src/dream/internal/runHooksFor.d.ts +1 -1
- package/dist/types/src/dream/internal/safelyRunCommitHooks.d.ts +1 -1
- package/dist/types/src/dream/internal/scopeHelpers.d.ts +1 -1
- package/dist/types/src/dream/internal/similarity/SimilarityBuilder.d.ts +3 -3
- package/dist/types/src/dream/internal/sqlResultToDreamInstance.d.ts +1 -1
- package/dist/types/src/dream-application/index.d.ts +1 -1
- package/dist/types/src/errors/ValidationError.d.ts +1 -1
- package/dist/types/src/errors/associations/CanOnlyPassBelongsToModelParam.d.ts +2 -2
- package/dist/types/src/errors/associations/CannotAssociateThroughPolymorphic.d.ts +2 -2
- package/dist/types/src/errors/associations/CannotCreateAssociationWithThroughContext.d.ts +2 -2
- package/dist/types/src/errors/associations/CannotJoinPolymorphicBelongsToError.d.ts +1 -1
- package/dist/types/src/errors/associations/CannotPassNullOrUndefinedToRequiredBelongsTo.d.ts +1 -1
- package/dist/types/src/errors/associations/InvalidComputedForeignKey.d.ts +1 -1
- package/dist/types/src/errors/associations/MissingRequiredAssociationOnClause.d.ts +2 -2
- package/dist/types/src/errors/associations/MissingThroughAssociation.d.ts +2 -2
- package/dist/types/src/errors/associations/MissingThroughAssociationSource.d.ts +2 -2
- package/dist/types/src/helpers/cli/generateMigrationContent.d.ts +1 -1
- package/dist/types/src/helpers/cli/generateStiMigrationContent.d.ts +1 -1
- package/dist/types/src/helpers/db/createDb.d.ts +1 -1
- package/dist/types/src/helpers/db/dropDb.d.ts +1 -1
- package/dist/types/src/helpers/db/foreignKeyTypeFromPrimaryKey.d.ts +1 -1
- package/dist/types/src/helpers/inferSerializerFromDreamOrViewModel.d.ts +1 -1
- package/dist/types/src/helpers/isEmpty.d.ts +1 -1
- package/dist/types/src/helpers/objectPathsToArrays.d.ts +1 -1
- package/dist/types/src/helpers/sort.d.ts +15 -0
- package/dist/types/src/helpers/sortBy.d.ts +2 -2
- package/dist/types/src/helpers/stringCasing.d.ts +1 -1
- package/dist/types/src/helpers/uniq.d.ts +1 -1
- package/dist/types/src/index.d.ts +6 -4
- package/dist/types/src/ops/index.d.ts +1 -1
- package/dist/types/src/ops/ops-statement.d.ts +1 -1
- package/dist/types/src/serializer/decorators/associations/RendersMany.d.ts +1 -1
- package/dist/types/src/serializer/decorators/associations/RendersOne.d.ts +1 -1
- package/dist/types/src/serializer/decorators/associations/shared.d.ts +2 -1
- package/dist/types/src/serializer/decorators/attribute.d.ts +1 -1
- package/dist/types/src/serializer/decorators/helpers/dreamAttributeOpenapiShape.d.ts +2 -2
- package/dist/types/src/serializer/decorators/helpers/hasSerializersGetter.d.ts +1 -1
- package/dist/types/src/serializer/decorators/helpers/maybeSerializableToDreamSerializerCallbackFunction.d.ts +1 -1
- package/dist/types/src/types/associations/belongsTo.d.ts +76 -0
- package/dist/types/src/types/associations/hasMany.d.ts +80 -0
- package/dist/types/src/types/associations/hasOne.d.ts +26 -0
- package/dist/types/src/types/associations/shared.d.ts +453 -0
- package/dist/types/src/types/db.d.ts +14 -0
- package/dist/types/src/types/dream.d.ts +527 -0
- package/dist/types/src/types/lifecycle.d.ts +50 -0
- package/dist/types/src/types/logger.d.ts +46 -0
- package/dist/types/src/types/openapi.d.ts +243 -0
- package/dist/types/src/types/query.d.ts +127 -0
- package/dist/types/src/types/utils.d.ts +173 -0
- package/dist/types/src/types/validation.d.ts +20 -0
- package/dist/types/src/types/variadic.d.ts +447 -0
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Benchmark.html +2 -2
- package/docs/classes/CalendarDate.html +2 -2
- package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +3 -3
- package/docs/classes/Decorators.html +19 -19
- package/docs/classes/Dream.html +128 -127
- package/docs/classes/DreamApplication.html +4 -4
- package/docs/classes/DreamBin.html +2 -2
- package/docs/classes/DreamCLI.html +4 -4
- package/docs/classes/DreamDbConnection.html +2 -2
- package/docs/classes/DreamGlam.html +2 -2
- package/docs/classes/DreamImporter.html +2 -2
- package/docs/classes/DreamMigrationHelpers.html +7 -7
- package/docs/classes/DreamSerializer.html +2 -2
- package/docs/classes/DreamTransaction.html +2 -2
- package/docs/classes/Encrypt.html +2 -2
- package/docs/classes/Env.html +2 -2
- package/docs/classes/GlobalNameNotSet.html +3 -3
- package/docs/classes/NonLoadedAssociation.html +3 -3
- package/docs/classes/Query.html +50 -50
- package/docs/classes/Range.html +2 -2
- package/docs/classes/RecordNotFound.html +3 -3
- package/docs/classes/ValidationError.html +3 -3
- package/docs/functions/Attribute.html +1 -1
- package/docs/functions/RendersMany.html +1 -1
- package/docs/functions/RendersOne.html +1 -1
- package/docs/functions/ReplicaSafe.html +1 -1
- package/docs/functions/STI.html +1 -1
- package/docs/functions/SoftDelete.html +1 -1
- package/docs/functions/camelize.html +1 -1
- package/docs/functions/capitalize.html +1 -1
- package/docs/functions/closeAllDbConnections.html +1 -1
- package/docs/functions/compact.html +1 -1
- package/docs/functions/db.html +1 -1
- package/docs/functions/debug.html +1 -1
- package/docs/functions/dreamDbConnections.html +1 -1
- package/docs/functions/dreamPath.html +1 -1
- package/docs/functions/generateDream.html +1 -1
- package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/hyphenize.html +1 -1
- package/docs/functions/inferSerializerFromDreamClassOrViewModelClass.html +1 -1
- package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
- package/docs/functions/isEmpty.html +1 -1
- package/docs/functions/loadRepl.html +1 -1
- package/docs/functions/lookupClassByGlobalName.html +1 -1
- package/docs/functions/pascalize.html +1 -1
- package/docs/functions/pgErrorType.html +1 -1
- package/docs/functions/range-1.html +1 -1
- package/docs/functions/relativeDreamPath.html +1 -1
- package/docs/functions/round.html +1 -1
- package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/sharedPathPrefix.html +1 -1
- package/docs/functions/snakeify.html +1 -1
- package/docs/functions/sort.html +6 -0
- package/docs/functions/sortBy.html +6 -1
- package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
- package/docs/functions/uncapitalize.html +1 -1
- package/docs/functions/uniq.html +1 -1
- package/docs/functions/validateColumn.html +1 -1
- package/docs/functions/validateTable.html +1 -1
- package/docs/interfaces/AttributeStatement.html +2 -2
- package/docs/interfaces/DecoratorContext.html +2 -2
- package/docs/interfaces/DreamApplicationInitOptions.html +2 -2
- package/docs/interfaces/DreamApplicationOpts.html +2 -2
- package/docs/interfaces/DreamSerializerAssociationStatement.html +2 -2
- package/docs/interfaces/EncryptOptions.html +2 -2
- package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
- package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
- package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
- package/docs/modules.html +1 -0
- package/docs/types/Camelized.html +1 -1
- package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
- package/docs/types/DateTime.html +1 -1
- package/docs/types/DreamAssociationMetadata.html +1 -1
- package/docs/types/DreamAttributes.html +1 -1
- package/docs/types/DreamClassColumn.html +1 -1
- package/docs/types/DreamColumn.html +1 -1
- package/docs/types/DreamColumnNames.html +1 -1
- package/docs/types/DreamLogLevel.html +1 -1
- package/docs/types/DreamLogger.html +1 -1
- package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
- package/docs/types/DreamParamSafeAttributes.html +1 -1
- package/docs/types/DreamParamSafeColumnNames.html +1 -1
- package/docs/types/DreamSerializerKey.html +1 -1
- package/docs/types/DreamSerializers.html +1 -1
- package/docs/types/DreamTableSchema.html +1 -1
- package/docs/types/DreamVirtualColumns.html +1 -1
- package/docs/types/EncryptAlgorithm.html +1 -1
- package/docs/types/Hyphenized.html +1 -1
- package/docs/types/IdType.html +1 -1
- package/docs/types/OpenapiAllTypes.html +1 -1
- package/docs/types/OpenapiFormats.html +1 -1
- package/docs/types/OpenapiNumberFormats.html +1 -1
- package/docs/types/OpenapiPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiSchemaArray.html +1 -1
- package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
- package/docs/types/OpenapiSchemaBase.html +1 -1
- package/docs/types/OpenapiSchemaBody.html +1 -1
- package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
- package/docs/types/OpenapiSchemaCommonFields.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
- package/docs/types/OpenapiSchemaInteger.html +1 -1
- package/docs/types/OpenapiSchemaNull.html +1 -1
- package/docs/types/OpenapiSchemaNumber.html +1 -1
- package/docs/types/OpenapiSchemaObject.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectBase.html +1 -1
- package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
- package/docs/types/OpenapiSchemaPartialSegment.html +1 -1
- package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaString.html +1 -1
- package/docs/types/OpenapiShorthandAllTypes.html +1 -1
- package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiTypeField.html +1 -1
- package/docs/types/Pascalized.html +1 -1
- package/docs/types/PrimaryKeyType.html +1 -1
- package/docs/types/RoundingPrecision.html +1 -1
- package/docs/types/SerializableClassOrSerializerCallback.html +1 -1
- package/docs/types/SerializableDreamClassOrViewModelClass.html +1 -1
- package/docs/types/SerializableDreamOrViewModel.html +1 -1
- package/docs/types/SerializableTypes.html +1 -1
- package/docs/types/Snakeified.html +1 -1
- package/docs/types/Timestamp.html +1 -1
- package/docs/types/UpdateableAssociationProperties.html +1 -1
- package/docs/types/UpdateableProperties.html +1 -1
- package/docs/types/ValidationType.html +1 -1
- package/docs/types/ViewModelSerializerKey.html +1 -1
- package/docs/types/WhereStatementForDream.html +1 -1
- package/docs/types/WhereStatementForDreamClass.html +1 -1
- package/docs/variables/DateTime-1.html +1 -1
- package/docs/variables/DreamConst.html +1 -1
- package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
- package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
- package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
- package/docs/variables/ops.html +1 -1
- package/docs/variables/primaryKeyTypes.html +1 -1
- package/package.json +2 -2
- package/dist/cjs/src/db/reflections.js +0 -2
- package/dist/cjs/src/db/types.js +0 -2
- package/dist/cjs/src/decorators/field/validation/shared.js +0 -2
- package/dist/cjs/src/dream/types.js +0 -98
- package/dist/cjs/src/helpers/typeutils.js +0 -2
- package/dist/esm/src/db/reflections.js +0 -1
- package/dist/esm/src/db/types.js +0 -1
- package/dist/esm/src/decorators/field/validation/shared.js +0 -1
- package/dist/esm/src/dream/types.js +0 -95
- package/dist/esm/src/helpers/typeutils.js +0 -1
- package/dist/types/src/db/reflections.d.ts +0 -5
- package/dist/types/src/db/types.d.ts +0 -1
- package/dist/types/src/decorators/field/validation/shared.d.ts +0 -19
- package/dist/types/src/dream/types.d.ts +0 -184
- package/dist/types/src/helpers/typeutils.d.ts +0 -115
- package/dist/types/src/openapi/types.d.ts +0 -139
package/dist/cjs/src/Dream.js
CHANGED
|
@@ -371,9 +371,8 @@ class Dream {
|
|
|
371
371
|
return this.constructor.stiBaseClassOrOwnClassName;
|
|
372
372
|
}
|
|
373
373
|
/**
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
* Shadows .sanitizedName. Returns a string
|
|
374
|
+
* this.constructor.name may be prefixed with an underscore during conversion to Javascript.
|
|
375
|
+
* This method returns the constructor name without a leading underscore.
|
|
377
376
|
*
|
|
378
377
|
* @returns A string
|
|
379
378
|
*/
|
|
@@ -58,8 +58,8 @@ export type Timestamp = ColumnType<DateTime | CalendarDate>`);
|
|
|
58
58
|
}
|
|
59
59
|
function addCustomImports(file) {
|
|
60
60
|
const customImports = EnvInternal_js_1.default.boolean('DREAM_CORE_DEVELOPMENT')
|
|
61
|
-
? "import CalendarDate from '../../src/helpers/CalendarDate.js'\nimport { DateTime } from '../../src/helpers/DateTime.js'"
|
|
62
|
-
: "import { CalendarDate, DateTime } from '@rvoh/dream'";
|
|
61
|
+
? "import type CalendarDate from '../../src/helpers/CalendarDate.js'\nimport { type DateTime } from '../../src/helpers/DateTime.js'"
|
|
62
|
+
: "import { type CalendarDate, type DateTime } from '@rvoh/dream'";
|
|
63
63
|
return `${(0, autogeneratedFileMessage_js_1.default)()}${customImports}
|
|
64
64
|
${file}`;
|
|
65
65
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const index_js_1 = require("../../index.js");
|
|
3
4
|
const createSpinner_js_1 = require("../helpers/createSpinner.js");
|
|
4
5
|
const DreamCliLoggable_js_1 = require("./DreamCliLoggable.js");
|
|
5
|
-
const index_js_1 = require("../../index.js");
|
|
6
6
|
class DreamCliLoggableSpinner extends DreamCliLoggable_js_1.default {
|
|
7
7
|
text;
|
|
8
8
|
spinner;
|
|
@@ -8,7 +8,7 @@ exports.applyGetterAndSetter = applyGetterAndSetter;
|
|
|
8
8
|
exports.associationPrimaryKeyAccessors = associationPrimaryKeyAccessors;
|
|
9
9
|
exports.validateHasStatementArgs = validateHasStatementArgs;
|
|
10
10
|
const pluralize_esm_1 = require("pluralize-esm");
|
|
11
|
-
const
|
|
11
|
+
const constants_js_1 = require("../../../dream/constants.js");
|
|
12
12
|
const InvalidComputedForeignKey_js_1 = require("../../../errors/associations/InvalidComputedForeignKey.js");
|
|
13
13
|
const NonLoadedAssociation_js_1 = require("../../../errors/associations/NonLoadedAssociation.js");
|
|
14
14
|
const CannotDefineAssociationWithBothDependentAndPassthrough_js_1 = require("../../../errors/CannotDefineAssociationWithBothDependentAndPassthrough.js");
|
|
@@ -30,6 +30,11 @@ function blankAssociationsFactory(dreamClass, { freeze = false, } = {}) {
|
|
|
30
30
|
return (0, freezeBaseClassArrayMap_js_1.default)(associationsMap);
|
|
31
31
|
return associationsMap;
|
|
32
32
|
}
|
|
33
|
+
// function hydratedSourceValue(dream: Dream | typeof Dream | undefined, sourceName: string) {
|
|
34
|
+
// if (!dream) return
|
|
35
|
+
// if (!sourceName) return
|
|
36
|
+
// return (dream as any)[sourceName] || (dream as any)[singular(sourceName)]
|
|
37
|
+
// }
|
|
33
38
|
function finalForeignKey(foreignKey, dreamClass, partialAssociation) {
|
|
34
39
|
let computedForeignKey = foreignKey;
|
|
35
40
|
if (!computedForeignKey) {
|
|
@@ -118,15 +123,10 @@ association: ${this.as}
|
|
|
118
123
|
};
|
|
119
124
|
}
|
|
120
125
|
function validateHasStatementArgs({ dreamClass, dependent, methodName, on, }) {
|
|
121
|
-
const hasPassthroughOn = Object.values(on || {}).find(val => val ===
|
|
122
|
-
const hasRequiredOn = Object.values(on || {}).find(val => val ===
|
|
126
|
+
const hasPassthroughOn = Object.values(on || {}).find(val => val === constants_js_1.DreamConst.passthrough);
|
|
127
|
+
const hasRequiredOn = Object.values(on || {}).find(val => val === constants_js_1.DreamConst.required);
|
|
123
128
|
if (dependent && hasPassthroughOn)
|
|
124
129
|
throw new CannotDefineAssociationWithBothDependentAndPassthrough_js_1.default(dreamClass, methodName);
|
|
125
130
|
if (dependent && hasRequiredOn)
|
|
126
131
|
throw new CannotDefineAssociationWithBothDependentAndRequiredOnClause_js_1.default(dreamClass, methodName);
|
|
127
132
|
}
|
|
128
|
-
// function hydratedSourceValue(dream: Dream | typeof Dream | undefined, sourceName: string) {
|
|
129
|
-
// if (!dream) return
|
|
130
|
-
// if (!sourceName) return
|
|
131
|
-
// return (dream as any)[sourceName] || (dream as any)[singular(sourceName)]
|
|
132
|
-
// }
|
|
@@ -37,13 +37,13 @@ const uniq_js_1 = require("../helpers/uniq.js");
|
|
|
37
37
|
const curried_ops_statement_js_1 = require("../ops/curried-ops-statement.js");
|
|
38
38
|
const index_js_1 = require("../ops/index.js");
|
|
39
39
|
const ops_statement_js_1 = require("../ops/ops-statement.js");
|
|
40
|
+
const constants_js_1 = require("./constants.js");
|
|
40
41
|
const executeDatabaseQuery_js_1 = require("./internal/executeDatabaseQuery.js");
|
|
41
42
|
const extractAssociationMetadataFromAssociationName_js_1 = require("./internal/extractAssociationMetadataFromAssociationName.js");
|
|
42
43
|
const orderByDirection_js_1 = require("./internal/orderByDirection.js");
|
|
43
44
|
const shouldBypassDefaultScope_js_1 = require("./internal/shouldBypassDefaultScope.js");
|
|
44
45
|
const SimilarityBuilder_js_1 = require("./internal/similarity/SimilarityBuilder.js");
|
|
45
46
|
const sqlResultToDreamInstance_js_1 = require("./internal/sqlResultToDreamInstance.js");
|
|
46
|
-
const types_js_1 = require("./types.js");
|
|
47
47
|
class Query extends ConnectedToDB_js_1.default {
|
|
48
48
|
/**
|
|
49
49
|
* @internal
|
|
@@ -2229,7 +2229,7 @@ class Query extends ConnectedToDB_js_1.default {
|
|
|
2229
2229
|
throwUnlessAllRequiredWhereClausesProvided(association, namespace, joinOnStatements) {
|
|
2230
2230
|
const whereStatement = association.on;
|
|
2231
2231
|
const columnsRequiringWhereStatements = Object.keys(whereStatement).reduce((agg, column) => {
|
|
2232
|
-
if (whereStatement[column] ===
|
|
2232
|
+
if (whereStatement[column] === constants_js_1.DreamConst.required)
|
|
2233
2233
|
agg.push(column);
|
|
2234
2234
|
return agg;
|
|
2235
2235
|
}, []);
|
|
@@ -2280,7 +2280,7 @@ class Query extends ConnectedToDB_js_1.default {
|
|
|
2280
2280
|
}
|
|
2281
2281
|
whereStatementToExpressionWrapper(eb, whereStatement, { negate = false, disallowSimilarityOperator = true, } = {}) {
|
|
2282
2282
|
const clauses = (0, compact_js_1.default)(Object.keys(whereStatement)
|
|
2283
|
-
.filter(key => whereStatement[key] !==
|
|
2283
|
+
.filter(key => whereStatement[key] !== constants_js_1.DreamConst.required)
|
|
2284
2284
|
.map(attr => {
|
|
2285
2285
|
const val = whereStatement[attr];
|
|
2286
2286
|
if (val?.isOpsStatement &&
|
|
@@ -2357,10 +2357,10 @@ class Query extends ConnectedToDB_js_1.default {
|
|
|
2357
2357
|
let a2 = null;
|
|
2358
2358
|
let b2 = null;
|
|
2359
2359
|
let c2 = null;
|
|
2360
|
-
if (val instanceof Function && val !==
|
|
2360
|
+
if (val instanceof Function && val !== constants_js_1.DreamConst.passthrough) {
|
|
2361
2361
|
val = val();
|
|
2362
2362
|
}
|
|
2363
|
-
else if (val ===
|
|
2363
|
+
else if (val === constants_js_1.DreamConst.passthrough) {
|
|
2364
2364
|
const column = attr.split('.').pop();
|
|
2365
2365
|
if (this.passthroughOnStatement[column] === undefined)
|
|
2366
2366
|
throw new MissingRequiredPassthroughForAssociationOnClause_js_1.default(column);
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.openapiShorthandPrimitiveTypes = exports.openapiPrimitiveTypes = void 0;
|
|
3
|
+
exports.openapiShorthandPrimitiveTypes = exports.openapiPrimitiveTypes = exports.DreamConst = exports.TRIGRAM_OPERATORS = exports.primaryKeyTypes = void 0;
|
|
4
|
+
exports.primaryKeyTypes = ['bigserial', 'bigint', 'uuid', 'integer'];
|
|
5
|
+
exports.TRIGRAM_OPERATORS = ['%', '<%', '<<%'];
|
|
6
|
+
class RequiredAttribute {
|
|
7
|
+
constructor() { }
|
|
8
|
+
}
|
|
9
|
+
class PassthroughAttribute {
|
|
10
|
+
constructor() { }
|
|
11
|
+
}
|
|
12
|
+
exports.DreamConst = {
|
|
13
|
+
passthrough: PassthroughAttribute,
|
|
14
|
+
required: RequiredAttribute,
|
|
15
|
+
};
|
|
4
16
|
exports.openapiPrimitiveTypes = [
|
|
5
17
|
'string',
|
|
6
18
|
'boolean',
|
|
@@ -8,7 +8,7 @@ const validateTable_js_1 = require("../../../db/validators/validateTable.js");
|
|
|
8
8
|
const validateTableAlias_js_1 = require("../../../db/validators/validateTableAlias.js");
|
|
9
9
|
const namespaceColumn_js_1 = require("../../../helpers/namespaceColumn.js");
|
|
10
10
|
const typechecks_js_1 = require("../../../helpers/typechecks.js");
|
|
11
|
-
const
|
|
11
|
+
const constants_js_1 = require("../../constants.js");
|
|
12
12
|
const similaritySelectSql_js_1 = require("./similaritySelectSql.js");
|
|
13
13
|
const similarityWhereSql_js_1 = require("./similarityWhereSql.js");
|
|
14
14
|
class SimilarityBuilder extends ConnectedToDB_js_1.default {
|
|
@@ -185,7 +185,7 @@ class SimilarityBuilder extends ConnectedToDB_js_1.default {
|
|
|
185
185
|
Object.keys(tableValues).forEach(columnOrAssociationName => {
|
|
186
186
|
const statementOrValueOrNestedObject = tableValues[columnOrAssociationName];
|
|
187
187
|
if (statementOrValueOrNestedObject?.isOpsStatement &&
|
|
188
|
-
|
|
188
|
+
constants_js_1.TRIGRAM_OPERATORS.includes(statementOrValueOrNestedObject?.operator)) {
|
|
189
189
|
similar.push({
|
|
190
190
|
tableName,
|
|
191
191
|
tableAlias: associationName,
|
|
@@ -292,7 +292,7 @@ class SimilarityBuilder extends ConnectedToDB_js_1.default {
|
|
|
292
292
|
statements.forEach(statement => {
|
|
293
293
|
Object.keys(statement).forEach(key => {
|
|
294
294
|
if (statement[key]?.constructor?.name === 'OpsStatement' &&
|
|
295
|
-
|
|
295
|
+
constants_js_1.TRIGRAM_OPERATORS.includes(statement[key].operator)) {
|
|
296
296
|
similar.push({
|
|
297
297
|
tableName,
|
|
298
298
|
tableAlias: tableName,
|
|
@@ -6,7 +6,7 @@ const path = require("path");
|
|
|
6
6
|
const dataTypes_js_1 = require("../../db/dataTypes.js");
|
|
7
7
|
const index_js_1 = require("../../db/index.js");
|
|
8
8
|
const index_js_2 = require("../../dream-application/index.js");
|
|
9
|
-
const
|
|
9
|
+
const constants_js_1 = require("../../dream/constants.js");
|
|
10
10
|
const FailedToIdentifyAssociation_js_1 = require("../../errors/schema-builder/FailedToIdentifyAssociation.js");
|
|
11
11
|
const autogeneratedFileMessage_js_1 = require("../../global-cli/helpers/autogeneratedFileMessage.js");
|
|
12
12
|
const camelize_js_1 = require("../camelize.js");
|
|
@@ -25,8 +25,8 @@ import {
|
|
|
25
25
|
} from './db.js'`
|
|
26
26
|
: '';
|
|
27
27
|
const calendarDateImportStatement = EnvInternal_js_1.default.boolean('DREAM_CORE_DEVELOPMENT')
|
|
28
|
-
? "import CalendarDate from '../../src/helpers/CalendarDate.js'\nimport { DateTime } from '../../src/helpers/DateTime.js'"
|
|
29
|
-
: "import { CalendarDate, DateTime } from '@rvoh/dream'";
|
|
28
|
+
? "import type CalendarDate from '../../src/helpers/CalendarDate.js'\nimport { type DateTime } from '../../src/helpers/DateTime.js'"
|
|
29
|
+
: "import { type CalendarDate, type DateTime } from '@rvoh/dream'";
|
|
30
30
|
const dreamApp = index_js_2.default.getOrFail();
|
|
31
31
|
const newSchemaFileContents = `\
|
|
32
32
|
${(0, autogeneratedFileMessage_js_1.default)()}
|
|
@@ -109,13 +109,13 @@ ${tableName}: {
|
|
|
109
109
|
const whereStatement = associationMetadata.where;
|
|
110
110
|
const requiredOnClauses = whereStatement === null
|
|
111
111
|
? []
|
|
112
|
-
: Object.keys(whereStatement).filter(column => whereStatement[column] ===
|
|
112
|
+
: Object.keys(whereStatement).filter(column => whereStatement[column] === constants_js_1.DreamConst.required);
|
|
113
113
|
passthroughColumns =
|
|
114
114
|
whereStatement === null
|
|
115
115
|
? passthroughColumns
|
|
116
116
|
: [
|
|
117
117
|
...passthroughColumns,
|
|
118
|
-
...Object.keys(whereStatement).filter(column => whereStatement[column] ===
|
|
118
|
+
...Object.keys(whereStatement).filter(column => whereStatement[column] === constants_js_1.DreamConst.passthrough),
|
|
119
119
|
];
|
|
120
120
|
return `${associationName}: {
|
|
121
121
|
type: '${associationMetadata.type}',
|
|
@@ -39,7 +39,7 @@ async function generateDream({ fullyQualifiedModelName, columnsWithTypes, option
|
|
|
39
39
|
const isSTI = !!fullyQualifiedParentName;
|
|
40
40
|
if (columnsWithTypes.length || !isSTI) {
|
|
41
41
|
await (0, generateMigration_js_1.default)({
|
|
42
|
-
migrationName: fullyQualifiedModelName
|
|
42
|
+
migrationName: `Create${fullyQualifiedModelName}`,
|
|
43
43
|
columnsWithTypes,
|
|
44
44
|
fullyQualifiedModelName,
|
|
45
45
|
fullyQualifiedParentName,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = primaryKeyType;
|
|
4
4
|
const index_js_1 = require("../../dream-application/index.js");
|
|
5
|
-
const
|
|
5
|
+
const constants_js_1 = require("../../dream/constants.js");
|
|
6
6
|
function primaryKeyType() {
|
|
7
7
|
const dreamconf = index_js_1.default.getOrFail();
|
|
8
8
|
switch (dreamconf.primaryKeyType) {
|
|
@@ -17,7 +17,7 @@ ATTENTION!
|
|
|
17
17
|
|
|
18
18
|
unrecognized primary key type "${dreamconf.primaryKeyType}" found in .dream.yml.
|
|
19
19
|
please use one of the allowed primary key types:
|
|
20
|
-
${
|
|
20
|
+
${constants_js_1.primaryKeyTypes.join(', ')}
|
|
21
21
|
`);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = sort;
|
|
4
|
+
const sortBy_js_1 = require("./sortBy.js");
|
|
5
|
+
/**
|
|
6
|
+
* Returns a copy of array containing strings, numbers, bigints, and/or IdTypes, sorted in ascending order.
|
|
7
|
+
* To sort other types use {@link sortBy}.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { sort } from '@rvoh/dream'
|
|
11
|
+
*
|
|
12
|
+
* sort([2, 1, 3])
|
|
13
|
+
* // [1, 2, 3]
|
|
14
|
+
*
|
|
15
|
+
* sort(['world', 'Hello', 'hello', 'World'])
|
|
16
|
+
* // ['hello', 'Hello', 'world', 'World']
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
function sort(array) {
|
|
20
|
+
if (typeof array[0] === 'bigint') {
|
|
21
|
+
return (0, sortBy_js_1.default)(array, a => String(a));
|
|
22
|
+
}
|
|
23
|
+
return (0, sortBy_js_1.default)(array, a => a);
|
|
24
|
+
}
|
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UnsupportedValueFromComparisonFunction = void 0;
|
|
4
4
|
exports.default = sortBy;
|
|
5
|
+
/**
|
|
6
|
+
* Returns a copy of the array, sorted by the value returned by calling the function in the second argument on each element in the array
|
|
7
|
+
* Returns a copy of the array sorted by the return value of the function passed as the second argument.
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { sortBy } from '@rvoh/dream'
|
|
10
|
+
*
|
|
11
|
+
* sortBy(['aaa', 'a', 'aa'], (str: string) => str.length)
|
|
12
|
+
* // ['a', 'aa', 'aaa']
|
|
13
|
+
*
|
|
14
|
+
* sortBy(['aaa', 'a', 'aa'], (str: string) => -str.length)
|
|
15
|
+
* // ['aaa', 'aa', 'a']
|
|
16
|
+
*
|
|
17
|
+
* sortBy([5, 3, 7], (num: number) => num)
|
|
18
|
+
* // [3, 5, 7]
|
|
19
|
+
*
|
|
20
|
+
* sortBy([5, 3, 7], (num: number) => -num)
|
|
21
|
+
* // [7, 5, 3]
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
5
24
|
function sortBy(array, valueToCompare) {
|
|
6
25
|
const arrayClone = [...array];
|
|
7
26
|
return arrayClone.sort((a, b) => {
|
|
@@ -11,8 +30,6 @@ function sortBy(array, valueToCompare) {
|
|
|
11
30
|
return aPrime.localeCompare(bPrime);
|
|
12
31
|
if (typeof aPrime === 'number' && typeof bPrime === 'number')
|
|
13
32
|
return aPrime - bPrime;
|
|
14
|
-
if (typeof aPrime === 'bigint' && typeof bPrime === 'bigint')
|
|
15
|
-
return aPrime.toString().localeCompare(bPrime.toString());
|
|
16
33
|
throw new UnsupportedValueFromComparisonFunction(aPrime, bPrime);
|
|
17
34
|
});
|
|
18
35
|
}
|
|
@@ -4,17 +4,18 @@ exports.default = uniq;
|
|
|
4
4
|
function uniq(arr, toKey = undefined) {
|
|
5
5
|
if (toKey)
|
|
6
6
|
return uniqWith(arr, toKey);
|
|
7
|
-
|
|
8
|
-
return uniqWith(arr, dreamKey);
|
|
9
|
-
else
|
|
10
|
-
return Array.from(new Set(arr));
|
|
7
|
+
return uniqWith(arr, a => String(a));
|
|
11
8
|
}
|
|
12
9
|
function dreamKey(dream) {
|
|
13
10
|
return `${dream.constructor.globalName}:${dream.primaryKeyValue}`;
|
|
14
11
|
}
|
|
15
12
|
function uniqWith(arr, toKey) {
|
|
16
13
|
const map = arr.reduce((acc, val) => {
|
|
17
|
-
|
|
14
|
+
// Prefix with underscore to ensure that the values cannot be interpreted as integers.
|
|
15
|
+
// If they can be interpreted as integers, then the keys are ordered not by the
|
|
16
|
+
// order in which they were added, but in ascending numerical order.
|
|
17
|
+
const key = val?.isDreamInstance ? dreamKey(val) : `_${toKey(val)}`;
|
|
18
|
+
acc[key] ||= val;
|
|
18
19
|
return acc;
|
|
19
20
|
}, {});
|
|
20
21
|
return Object.values(map);
|
package/dist/cjs/src/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.DreamSerializer = exports.Attribute = exports.RendersOne = exports.RendersMany = exports.ops = exports.
|
|
3
|
+
exports.Range = exports.sharedPathPrefix = exports.relativeDreamPath = exports.dreamPath = exports.pascalize = exports.loadRepl = exports.isEmpty = exports.inferSerializerFromDreamOrViewModel = exports.inferSerializerFromDreamClassOrViewModelClass = exports.hyphenize = exports.globalClassNameFromFullyQualifiedModelName = exports.Env = exports.DreamGlam = exports.debug = exports.DateTime = exports.compact = exports.generateDream = exports.capitalize = exports.camelize = exports.CalendarDate = exports.Benchmark = exports.ValidationError = exports.RecordNotFound = exports.GlobalNameNotSet = exports.CreateOrFindByFailedToCreateAndFind = exports.NonLoadedAssociation = exports.Encrypt = exports.Query = exports.DreamTransaction = exports.openapiShorthandPrimitiveTypes = exports.openapiPrimitiveTypes = exports.DreamConst = exports.Dream = exports.DreamApplication = exports.lookupClassByGlobalName = exports.DreamImporter = exports.Decorators = exports.STI = exports.SoftDelete = exports.ReplicaSafe = exports.validateTable = exports.validateColumn = exports.DreamMigrationHelpers = exports.db = exports.pgErrorType = exports.dreamDbConnections = exports.DreamDbConnection = exports.closeAllDbConnections = exports.DreamCLI = exports.DreamBin = void 0;
|
|
4
|
+
exports.DreamSerializer = exports.Attribute = exports.RendersOne = exports.RendersMany = exports.ops = exports.uniq = exports.uncapitalize = exports.standardizeFullyQualifiedModelName = exports.sortBy = exports.sort = exports.snakeify = exports.serializerNameFromFullyQualifiedModelName = exports.round = exports.range = void 0;
|
|
5
5
|
var index_js_1 = require("./bin/index.js");
|
|
6
6
|
Object.defineProperty(exports, "DreamBin", { enumerable: true, get: function () { return index_js_1.default; } });
|
|
7
7
|
var index_js_2 = require("./cli/index.js");
|
|
@@ -36,12 +36,14 @@ var index_js_4 = require("./dream-application/index.js");
|
|
|
36
36
|
Object.defineProperty(exports, "DreamApplication", { enumerable: true, get: function () { return index_js_4.default; } });
|
|
37
37
|
var Dream_js_1 = require("./Dream.js");
|
|
38
38
|
Object.defineProperty(exports, "Dream", { enumerable: true, get: function () { return Dream_js_1.default; } });
|
|
39
|
+
var constants_js_1 = require("./dream/constants.js");
|
|
40
|
+
Object.defineProperty(exports, "DreamConst", { enumerable: true, get: function () { return constants_js_1.DreamConst; } });
|
|
41
|
+
Object.defineProperty(exports, "openapiPrimitiveTypes", { enumerable: true, get: function () { return constants_js_1.openapiPrimitiveTypes; } });
|
|
42
|
+
Object.defineProperty(exports, "openapiShorthandPrimitiveTypes", { enumerable: true, get: function () { return constants_js_1.openapiShorthandPrimitiveTypes; } });
|
|
39
43
|
var DreamTransaction_js_1 = require("./dream/DreamTransaction.js");
|
|
40
44
|
Object.defineProperty(exports, "DreamTransaction", { enumerable: true, get: function () { return DreamTransaction_js_1.default; } });
|
|
41
45
|
var Query_js_1 = require("./dream/Query.js");
|
|
42
46
|
Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return Query_js_1.default; } });
|
|
43
|
-
var types_js_1 = require("./dream/types.js");
|
|
44
|
-
Object.defineProperty(exports, "DreamConst", { enumerable: true, get: function () { return types_js_1.DreamConst; } });
|
|
45
47
|
var index_js_5 = require("./encrypt/index.js");
|
|
46
48
|
Object.defineProperty(exports, "Encrypt", { enumerable: true, get: function () { return index_js_5.default; } });
|
|
47
49
|
var NonLoadedAssociation_js_1 = require("./errors/associations/NonLoadedAssociation.js");
|
|
@@ -102,6 +104,8 @@ var serializerNameFromFullyQualifiedModelName_js_1 = require("./helpers/serializ
|
|
|
102
104
|
Object.defineProperty(exports, "serializerNameFromFullyQualifiedModelName", { enumerable: true, get: function () { return serializerNameFromFullyQualifiedModelName_js_1.default; } });
|
|
103
105
|
var snakeify_js_1 = require("./helpers/snakeify.js");
|
|
104
106
|
Object.defineProperty(exports, "snakeify", { enumerable: true, get: function () { return snakeify_js_1.default; } });
|
|
107
|
+
var sort_js_1 = require("./helpers/sort.js");
|
|
108
|
+
Object.defineProperty(exports, "sort", { enumerable: true, get: function () { return sort_js_1.default; } });
|
|
105
109
|
var sortBy_js_1 = require("./helpers/sortBy.js");
|
|
106
110
|
Object.defineProperty(exports, "sortBy", { enumerable: true, get: function () { return sortBy_js_1.default; } });
|
|
107
111
|
var standardizeFullyQualifiedModelName_js_1 = require("./helpers/standardizeFullyQualifiedModelName.js");
|
|
@@ -110,9 +114,6 @@ var uncapitalize_js_1 = require("./helpers/uncapitalize.js");
|
|
|
110
114
|
Object.defineProperty(exports, "uncapitalize", { enumerable: true, get: function () { return uncapitalize_js_1.default; } });
|
|
111
115
|
var uniq_js_1 = require("./helpers/uniq.js");
|
|
112
116
|
Object.defineProperty(exports, "uniq", { enumerable: true, get: function () { return uniq_js_1.default; } });
|
|
113
|
-
var types_js_2 = require("./openapi/types.js");
|
|
114
|
-
Object.defineProperty(exports, "openapiPrimitiveTypes", { enumerable: true, get: function () { return types_js_2.openapiPrimitiveTypes; } });
|
|
115
|
-
Object.defineProperty(exports, "openapiShorthandPrimitiveTypes", { enumerable: true, get: function () { return types_js_2.openapiShorthandPrimitiveTypes; } });
|
|
116
117
|
var index_js_6 = require("./ops/index.js");
|
|
117
118
|
Object.defineProperty(exports, "ops", { enumerable: true, get: function () { return index_js_6.default; } });
|
|
118
119
|
var RendersMany_js_1 = require("./serializer/decorators/associations/RendersMany.js");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const constants_js_1 = require("../dream/constants.js");
|
|
4
4
|
const ScoreMustBeANormalNumber_js_1 = require("../errors/ops/ScoreMustBeANormalNumber.js");
|
|
5
5
|
class OpsStatement {
|
|
6
6
|
operator;
|
|
@@ -24,10 +24,10 @@ class OpsStatement {
|
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
26
26
|
get shouldBypassWhereStatement() {
|
|
27
|
-
return
|
|
27
|
+
return constants_js_1.TRIGRAM_OPERATORS.includes(this.operator);
|
|
28
28
|
}
|
|
29
29
|
get minTrigramScore() {
|
|
30
|
-
if (
|
|
30
|
+
if (constants_js_1.TRIGRAM_OPERATORS.includes(this.operator)) {
|
|
31
31
|
return this.extraArgs?.score;
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const index_js_1 = require("../dream-application/index.js");
|
|
4
|
-
const
|
|
4
|
+
const constants_js_1 = require("../dream/constants.js");
|
|
5
5
|
const GlobalNameNotSet_js_1 = require("../errors/dream-application/GlobalNameNotSet.js");
|
|
6
6
|
const MissingSerializersDefinition_js_1 = require("../errors/MissingSerializersDefinition.js");
|
|
7
7
|
const FailedToRenderThroughAssociationForSerializer_js_1 = require("../errors/serializers/FailedToRenderThroughAssociationForSerializer.js");
|
|
@@ -213,7 +213,7 @@ class DreamSerializer {
|
|
|
213
213
|
return new SerializerClass(associatedData).absorbPassthrough(this).render();
|
|
214
214
|
}
|
|
215
215
|
associatedData(associationStatement) {
|
|
216
|
-
const delegateToPassthroughData = associationStatement.source ===
|
|
216
|
+
const delegateToPassthroughData = associationStatement.source === constants_js_1.DreamConst.passthrough;
|
|
217
217
|
let self = (delegateToPassthroughData ? this.$passthroughData : this.$data);
|
|
218
218
|
if (associationStatement.through) {
|
|
219
219
|
const throughField = associationStatement.through;
|
package/dist/esm/src/Dream.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { pgErrorType } from './db/errors.js';
|
|
2
2
|
import db from './db/index.js';
|
|
3
3
|
import associationToGetterSetterProp from './decorators/field/association/associationToGetterSetterProp.js';
|
|
4
|
-
import { blankAssociationsFactory
|
|
4
|
+
import { blankAssociationsFactory } from './decorators/field/association/shared.js';
|
|
5
5
|
import { blankHooksFactory } from './decorators/field/lifecycle/shared.js';
|
|
6
6
|
import resortAllRecords from './decorators/field/sortable/helpers/resortAllRecords.js';
|
|
7
7
|
import DreamClassTransactionBuilder from './dream/DreamClassTransactionBuilder.js';
|
|
@@ -369,9 +369,8 @@ export default class Dream {
|
|
|
369
369
|
return this.constructor.stiBaseClassOrOwnClassName;
|
|
370
370
|
}
|
|
371
371
|
/**
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
* Shadows .sanitizedName. Returns a string
|
|
372
|
+
* this.constructor.name may be prefixed with an underscore during conversion to Javascript.
|
|
373
|
+
* This method returns the constructor name without a leading underscore.
|
|
375
374
|
*
|
|
376
375
|
* @returns A string
|
|
377
376
|
*/
|
|
@@ -55,8 +55,8 @@ export type Timestamp = ColumnType<DateTime | CalendarDate>`);
|
|
|
55
55
|
}
|
|
56
56
|
function addCustomImports(file) {
|
|
57
57
|
const customImports = EnvInternal.boolean('DREAM_CORE_DEVELOPMENT')
|
|
58
|
-
? "import CalendarDate from '../../src/helpers/CalendarDate.js'\nimport { DateTime } from '../../src/helpers/DateTime.js'"
|
|
59
|
-
: "import { CalendarDate, DateTime } from '@rvoh/dream'";
|
|
58
|
+
? "import type CalendarDate from '../../src/helpers/CalendarDate.js'\nimport { type DateTime } from '../../src/helpers/DateTime.js'"
|
|
59
|
+
: "import { type CalendarDate, type DateTime } from '@rvoh/dream'";
|
|
60
60
|
return `${autogeneratedFileDisclaimer()}${customImports}
|
|
61
61
|
${file}`;
|
|
62
62
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import DreamCLI from '../../index.js';
|
|
1
2
|
import createSpinner from '../helpers/createSpinner.js';
|
|
2
3
|
import DreamCliLoggable from './DreamCliLoggable.js';
|
|
3
|
-
import DreamCLI from '../../index.js';
|
|
4
4
|
export default class DreamCliLoggableSpinner extends DreamCliLoggable {
|
|
5
5
|
text;
|
|
6
6
|
spinner;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import pluralize from 'pluralize-esm';
|
|
2
|
-
import { DreamConst
|
|
2
|
+
import { DreamConst } from '../../../dream/constants.js';
|
|
3
3
|
import { checkForeignKey } from '../../../errors/associations/InvalidComputedForeignKey.js';
|
|
4
4
|
import NonLoadedAssociation from '../../../errors/associations/NonLoadedAssociation.js';
|
|
5
5
|
import CannotDefineAssociationWithBothDependentAndPassthrough from '../../../errors/CannotDefineAssociationWithBothDependentAndPassthrough.js';
|
|
@@ -21,6 +21,11 @@ export function blankAssociationsFactory(dreamClass, { freeze = false, } = {}) {
|
|
|
21
21
|
return freezeBaseClassArrayMap(associationsMap);
|
|
22
22
|
return associationsMap;
|
|
23
23
|
}
|
|
24
|
+
// function hydratedSourceValue(dream: Dream | typeof Dream | undefined, sourceName: string) {
|
|
25
|
+
// if (!dream) return
|
|
26
|
+
// if (!sourceName) return
|
|
27
|
+
// return (dream as any)[sourceName] || (dream as any)[singular(sourceName)]
|
|
28
|
+
// }
|
|
24
29
|
export function finalForeignKey(foreignKey, dreamClass, partialAssociation) {
|
|
25
30
|
let computedForeignKey = foreignKey;
|
|
26
31
|
if (!computedForeignKey) {
|
|
@@ -116,8 +121,3 @@ export function validateHasStatementArgs({ dreamClass, dependent, methodName, on
|
|
|
116
121
|
if (dependent && hasRequiredOn)
|
|
117
122
|
throw new CannotDefineAssociationWithBothDependentAndRequiredOnClause(dreamClass, methodName);
|
|
118
123
|
}
|
|
119
|
-
// function hydratedSourceValue(dream: Dream | typeof Dream | undefined, sourceName: string) {
|
|
120
|
-
// if (!dream) return
|
|
121
|
-
// if (!sourceName) return
|
|
122
|
-
// return (dream as any)[sourceName] || (dream as any)[singular(sourceName)]
|
|
123
|
-
// }
|
|
@@ -35,13 +35,13 @@ import uniq from '../helpers/uniq.js';
|
|
|
35
35
|
import CurriedOpsStatement from '../ops/curried-ops-statement.js';
|
|
36
36
|
import ops from '../ops/index.js';
|
|
37
37
|
import OpsStatement from '../ops/ops-statement.js';
|
|
38
|
+
import { DreamConst } from './constants.js';
|
|
38
39
|
import executeDatabaseQuery from './internal/executeDatabaseQuery.js';
|
|
39
40
|
import extractAssociationMetadataFromAssociationName from './internal/extractAssociationMetadataFromAssociationName.js';
|
|
40
41
|
import orderByDirection from './internal/orderByDirection.js';
|
|
41
42
|
import shouldBypassDefaultScope from './internal/shouldBypassDefaultScope.js';
|
|
42
43
|
import SimilarityBuilder from './internal/similarity/SimilarityBuilder.js';
|
|
43
44
|
import sqlResultToDreamInstance from './internal/sqlResultToDreamInstance.js';
|
|
44
|
-
import { DreamConst, } from './types.js';
|
|
45
45
|
export default class Query extends ConnectedToDB {
|
|
46
46
|
/**
|
|
47
47
|
* @internal
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
export const primaryKeyTypes = ['bigserial', 'bigint', 'uuid', 'integer'];
|
|
2
|
+
export const TRIGRAM_OPERATORS = ['%', '<%', '<<%'];
|
|
3
|
+
class RequiredAttribute {
|
|
4
|
+
constructor() { }
|
|
5
|
+
}
|
|
6
|
+
class PassthroughAttribute {
|
|
7
|
+
constructor() { }
|
|
8
|
+
}
|
|
9
|
+
export const DreamConst = {
|
|
10
|
+
passthrough: PassthroughAttribute,
|
|
11
|
+
required: RequiredAttribute,
|
|
12
|
+
};
|
|
1
13
|
export const openapiPrimitiveTypes = [
|
|
2
14
|
'string',
|
|
3
15
|
'boolean',
|
|
@@ -5,7 +5,7 @@ import validateTable from '../../../db/validators/validateTable.js';
|
|
|
5
5
|
import validateTableAlias from '../../../db/validators/validateTableAlias.js';
|
|
6
6
|
import namespaceColumn from '../../../helpers/namespaceColumn.js';
|
|
7
7
|
import { isObject } from '../../../helpers/typechecks.js';
|
|
8
|
-
import { TRIGRAM_OPERATORS
|
|
8
|
+
import { TRIGRAM_OPERATORS } from '../../constants.js';
|
|
9
9
|
import similaritySelectSql from './similaritySelectSql.js';
|
|
10
10
|
import similarityWhereSql from './similarityWhereSql.js';
|
|
11
11
|
export default class SimilarityBuilder extends ConnectedToDB {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { modelCBtoSingleDreamClass
|
|
1
|
+
import { modelCBtoSingleDreamClass } from '../../decorators/field/association/shared.js';
|
|
2
2
|
export class InvalidComputedForeignKey extends Error {
|
|
3
3
|
dreamClass;
|
|
4
4
|
partialAssociation;
|
|
@@ -4,7 +4,7 @@ import * as path from 'path';
|
|
|
4
4
|
import { isPrimitiveDataType } from '../../db/dataTypes.js';
|
|
5
5
|
import _db from '../../db/index.js';
|
|
6
6
|
import DreamApplication from '../../dream-application/index.js';
|
|
7
|
-
import { DreamConst } from '../../dream/
|
|
7
|
+
import { DreamConst } from '../../dream/constants.js';
|
|
8
8
|
import FailedToIdentifyAssociation from '../../errors/schema-builder/FailedToIdentifyAssociation.js';
|
|
9
9
|
import autogeneratedFileDisclaimer from '../../global-cli/helpers/autogeneratedFileMessage.js';
|
|
10
10
|
import camelize from '../camelize.js';
|
|
@@ -23,8 +23,8 @@ import {
|
|
|
23
23
|
} from './db.js'`
|
|
24
24
|
: '';
|
|
25
25
|
const calendarDateImportStatement = EnvInternal.boolean('DREAM_CORE_DEVELOPMENT')
|
|
26
|
-
? "import CalendarDate from '../../src/helpers/CalendarDate.js'\nimport { DateTime } from '../../src/helpers/DateTime.js'"
|
|
27
|
-
: "import { CalendarDate, DateTime } from '@rvoh/dream'";
|
|
26
|
+
? "import type CalendarDate from '../../src/helpers/CalendarDate.js'\nimport { type DateTime } from '../../src/helpers/DateTime.js'"
|
|
27
|
+
: "import { type CalendarDate, type DateTime } from '@rvoh/dream'";
|
|
28
28
|
const dreamApp = DreamApplication.getOrFail();
|
|
29
29
|
const newSchemaFileContents = `\
|
|
30
30
|
${autogeneratedFileDisclaimer()}
|
|
@@ -36,7 +36,7 @@ export default async function generateDream({ fullyQualifiedModelName, columnsWi
|
|
|
36
36
|
const isSTI = !!fullyQualifiedParentName;
|
|
37
37
|
if (columnsWithTypes.length || !isSTI) {
|
|
38
38
|
await generateMigration({
|
|
39
|
-
migrationName: fullyQualifiedModelName
|
|
39
|
+
migrationName: `Create${fullyQualifiedModelName}`,
|
|
40
40
|
columnsWithTypes,
|
|
41
41
|
fullyQualifiedModelName,
|
|
42
42
|
fullyQualifiedParentName,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import DreamApplication from '../../dream-application/index.js';
|
|
2
|
-
import { primaryKeyTypes } from '../../dream/
|
|
2
|
+
import { primaryKeyTypes } from '../../dream/constants.js';
|
|
3
3
|
export default function primaryKeyType() {
|
|
4
4
|
const dreamconf = DreamApplication.getOrFail();
|
|
5
5
|
switch (dreamconf.primaryKeyType) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import sortBy from './sortBy.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a copy of array containing strings, numbers, bigints, and/or IdTypes, sorted in ascending order.
|
|
4
|
+
* To sort other types use {@link sortBy}.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { sort } from '@rvoh/dream'
|
|
8
|
+
*
|
|
9
|
+
* sort([2, 1, 3])
|
|
10
|
+
* // [1, 2, 3]
|
|
11
|
+
*
|
|
12
|
+
* sort(['world', 'Hello', 'hello', 'World'])
|
|
13
|
+
* // ['hello', 'Hello', 'world', 'World']
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export default function sort(array) {
|
|
17
|
+
if (typeof array[0] === 'bigint') {
|
|
18
|
+
return sortBy(array, a => String(a));
|
|
19
|
+
}
|
|
20
|
+
return sortBy(array, a => a);
|
|
21
|
+
}
|