@rvoh/dream 0.31.5 → 0.32.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 +9 -9
- package/dist/cjs/src/bin/helpers/sync.js +7 -7
- package/dist/cjs/src/cli/logger/loggable/colorize.js +1 -1
- package/dist/cjs/src/db/DreamDbConnection.js +1 -1
- package/dist/cjs/src/decorators/field/sortable/hooks/beforeSortableSave.js +6 -3
- package/dist/cjs/src/dream/DreamInstanceTransactionBuilder.js +3 -3
- package/dist/cjs/src/dream/LeftJoinLoadBuilder.js +5 -1
- package/dist/cjs/src/dream/Query.js +74 -12
- package/dist/cjs/src/dream/internal/associations/associationUpdateQuery.js +3 -0
- package/dist/cjs/src/dream/internal/associations/createAssociation.js +3 -0
- package/dist/cjs/src/dream/internal/checkSingleValidation.js +8 -1
- package/dist/cjs/src/dream/internal/extractAssociationMetadataFromAssociationName.js +7 -3
- package/dist/cjs/src/errors/MissingTable.js +1 -1
- package/dist/cjs/src/errors/UnexpectedUndefined.js +14 -0
- package/dist/cjs/src/errors/associations/AssociationDeclaredWithoutAssociatedDreamClass.js +17 -0
- package/dist/cjs/src/global-cli/file-builders/DreamtsBuilder.js +2 -2
- package/dist/cjs/src/global-cli/helpers/argAndValue.js +4 -4
- package/dist/cjs/src/helpers/CalendarDate.js +1 -1
- package/dist/cjs/src/helpers/cli/SchemaBuilder.js +52 -17
- package/dist/cjs/src/helpers/cli/generateDreamContent.js +3 -1
- package/dist/cjs/src/helpers/cli/generateFactoryContent.js +7 -3
- package/dist/cjs/src/helpers/cli/generateMigrationContent.js +53 -21
- package/dist/cjs/src/helpers/cli/generateSerializerContent.js +3 -25
- package/dist/cjs/src/helpers/objectPathsToArrays.js +2 -1
- package/dist/esm/src/Dream.js +9 -9
- package/dist/esm/src/bin/helpers/sync.js +4 -4
- package/dist/esm/src/cli/logger/loggable/colorize.js +1 -1
- package/dist/esm/src/db/DreamDbConnection.js +1 -1
- package/dist/esm/src/decorators/field/sortable/hooks/beforeSortableSave.js +6 -3
- package/dist/esm/src/dream/DreamInstanceTransactionBuilder.js +3 -3
- package/dist/esm/src/dream/LeftJoinLoadBuilder.js +5 -1
- package/dist/esm/src/dream/Query.js +74 -12
- package/dist/esm/src/dream/internal/associations/associationUpdateQuery.js +3 -0
- package/dist/esm/src/dream/internal/associations/createAssociation.js +3 -0
- package/dist/esm/src/dream/internal/checkSingleValidation.js +8 -1
- package/dist/esm/src/dream/internal/extractAssociationMetadataFromAssociationName.js +7 -3
- package/dist/esm/src/errors/MissingTable.js +1 -1
- package/dist/esm/src/errors/UnexpectedUndefined.js +11 -0
- package/dist/esm/src/errors/associations/AssociationDeclaredWithoutAssociatedDreamClass.js +14 -0
- package/dist/esm/src/global-cli/file-builders/DreamtsBuilder.js +2 -2
- package/dist/esm/src/global-cli/helpers/argAndValue.js +4 -4
- package/dist/esm/src/helpers/CalendarDate.js +1 -1
- package/dist/esm/src/helpers/cli/SchemaBuilder.js +52 -17
- package/dist/esm/src/helpers/cli/generateDreamContent.js +3 -1
- package/dist/esm/src/helpers/cli/generateFactoryContent.js +7 -3
- package/dist/esm/src/helpers/cli/generateMigrationContent.js +53 -21
- package/dist/esm/src/helpers/cli/generateSerializerContent.js +3 -25
- package/dist/esm/src/helpers/objectPathsToArrays.js +2 -1
- package/dist/types/src/Dream.d.ts +1 -1
- package/dist/types/src/cli/logger/loggable/DreamCliLoggable.d.ts +3 -3
- package/dist/types/src/cli/logger/loggable/DreamCliLoggableText.d.ts +5 -5
- package/dist/types/src/cli/logger/loggable/colorize.d.ts +3 -3
- package/dist/types/src/db/ConnectedToDB.d.ts +3 -3
- package/dist/types/src/decorators/field/sortable/helpers/decrementScopedRecordsGreaterThanPosition.d.ts +1 -1
- package/dist/types/src/decorators/field/sortable/helpers/positionIsInvalid.d.ts +1 -1
- package/dist/types/src/decorators/field/sortable/helpers/setPosition.d.ts +2 -2
- package/dist/types/src/decorators/field/sortable/hooks/afterSortableCreate.d.ts +2 -2
- package/dist/types/src/decorators/field/sortable/hooks/afterSortableDestroy.d.ts +1 -1
- package/dist/types/src/decorators/field/sortable/hooks/afterSortableUpdate.d.ts +2 -2
- package/dist/types/src/decorators/field/sortable/hooks/beforeSortableSave.d.ts +1 -1
- package/dist/types/src/decorators/field-or-getter/Virtual.d.ts +1 -1
- package/dist/types/src/dream/Query.d.ts +26 -26
- package/dist/types/src/dream/internal/destroyOptions.d.ts +4 -4
- package/dist/types/src/dream/internal/similarity/SimilarityBuilder.d.ts +4 -4
- package/dist/types/src/dream-application/index.d.ts +1 -1
- package/dist/types/src/errors/UnexpectedUndefined.d.ts +4 -0
- package/dist/types/src/errors/associations/AssociationDeclaredWithoutAssociatedDreamClass.d.ts +7 -0
- package/dist/types/src/errors/associations/MissingRequiredAssociationOnClause.d.ts +1 -1
- package/dist/types/src/helpers/cli/generateDream.d.ts +1 -1
- package/dist/types/src/helpers/cli/generateDreamContent.d.ts +1 -1
- package/dist/types/src/helpers/cli/generateMigration.d.ts +2 -2
- package/dist/types/src/helpers/cli/generateMigrationContent.d.ts +4 -4
- package/dist/types/src/helpers/cli/generateSerializer.d.ts +1 -1
- package/dist/types/src/helpers/cli/generateSerializerContent.d.ts +2 -2
- package/dist/types/src/types/associations/shared.d.ts +1 -6
- package/dist/types/src/types/dream.d.ts +2 -13
- package/dist/types/src/types/lifecycle.d.ts +2 -2
- package/dist/types/src/types/logger.d.ts +3 -3
- 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 +127 -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 +51 -51
- package/docs/classes/Range.html +2 -2
- package/docs/classes/RecordNotFound.html +3 -3
- package/docs/classes/ValidationError.html +3 -3
- package/docs/functions/Attribute.html +1 -1
- package/docs/functions/RendersMany.html +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 +1 -1
- package/docs/functions/sortBy.html +1 -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/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 +1 -1
|
@@ -2,14 +2,19 @@ import pluralize from 'pluralize-esm';
|
|
|
2
2
|
import InvalidDecimalFieldPassedToGenerator from '../../errors/InvalidDecimalFieldPassedToGenerator.js';
|
|
3
3
|
import foreignKeyTypeFromPrimaryKey from '../db/foreignKeyTypeFromPrimaryKey.js';
|
|
4
4
|
import snakeify from '../snakeify.js';
|
|
5
|
+
const STI_TYPE_COLUMN_NAME = 'type';
|
|
6
|
+
const COLUMNS_TO_INDEX = [STI_TYPE_COLUMN_NAME];
|
|
7
|
+
const NOT_NULL_COLUMNS = [STI_TYPE_COLUMN_NAME];
|
|
5
8
|
export default function generateMigrationContent({ table, columnsWithTypes = [], primaryKeyType = 'bigserial', createOrAlter = 'create', } = {}) {
|
|
6
9
|
const altering = createOrAlter === 'alter';
|
|
7
10
|
let requireCitextExtension = false;
|
|
8
|
-
const { columnDefs, columnDrops } = columnsWithTypes.reduce((acc, attribute) => {
|
|
9
|
-
const { columnDefs, columnDrops } = acc;
|
|
11
|
+
const { columnDefs, columnDrops, indexDefs, indexDrops } = columnsWithTypes.reduce((acc, attribute) => {
|
|
12
|
+
const { columnDefs, columnDrops, indexDefs, indexDrops } = acc;
|
|
10
13
|
const [nonStandardAttributeName, attributeType, ...descriptors] = attribute.split(':');
|
|
11
14
|
let attributeName = snakeify(nonStandardAttributeName);
|
|
12
|
-
if (
|
|
15
|
+
if (attributeName === undefined)
|
|
16
|
+
return acc;
|
|
17
|
+
if (attributeType !== undefined && ['has_one', 'has_many'].includes(attributeType))
|
|
13
18
|
return acc;
|
|
14
19
|
if (attributeType === 'citext')
|
|
15
20
|
requireCitextExtension = true;
|
|
@@ -35,12 +40,23 @@ export default function generateMigrationContent({ table, columnsWithTypes = [],
|
|
|
35
40
|
columnDefs.push(generateColumnStr(`encrypted_${attributeName}`, 'text', descriptors));
|
|
36
41
|
break;
|
|
37
42
|
default:
|
|
38
|
-
|
|
43
|
+
if (coercedAttributeType !== undefined) {
|
|
44
|
+
columnDefs.push(generateColumnStr(attributeName, coercedAttributeType, descriptors));
|
|
45
|
+
}
|
|
39
46
|
break;
|
|
40
47
|
}
|
|
41
48
|
columnDrops.push(`.dropColumn('${attributeName}')`);
|
|
49
|
+
if (COLUMNS_TO_INDEX.includes(attributeName)) {
|
|
50
|
+
const indexName = `${table}_${attributeName}`;
|
|
51
|
+
indexDefs.push(`await db.schema
|
|
52
|
+
.createIndex('${indexName}')
|
|
53
|
+
.on('${table}')
|
|
54
|
+
.column('${attributeName}')
|
|
55
|
+
.execute()`);
|
|
56
|
+
indexDrops.push(`await db.schema.dropIndex('${indexName}').execute()`);
|
|
57
|
+
}
|
|
42
58
|
return acc;
|
|
43
|
-
}, { columnDefs: [], columnDrops: [] });
|
|
59
|
+
}, { columnDefs: [], columnDrops: [], indexDefs: [], indexDrops: [] });
|
|
44
60
|
if (!table) {
|
|
45
61
|
return `\
|
|
46
62
|
import { Kysely, sql } from 'kysely'
|
|
@@ -61,28 +77,31 @@ export async function down(db: Kysely<any>): Promise<void> {
|
|
|
61
77
|
const dreamImports = [];
|
|
62
78
|
if (requireCitextExtension)
|
|
63
79
|
dreamImports.push('DreamMigrationHelpers');
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const
|
|
80
|
+
const newlineIndent = '\n ';
|
|
81
|
+
const newlineDoubleIndent = '\n ';
|
|
82
|
+
const columnDefLines = columnDefs.length ? newlineDoubleIndent + columnDefs.join(newlineDoubleIndent) : '';
|
|
83
|
+
const columnDropLines = columnDrops.length
|
|
84
|
+
? newlineDoubleIndent + columnDrops.join(newlineDoubleIndent) + newlineDoubleIndent
|
|
85
|
+
: '';
|
|
67
86
|
return `\
|
|
68
87
|
${dreamImports.length ? `import { ${dreamImports.join(', ')} } from '@rvoh/dream'\n` : ''}import { ${kyselyImports.join(', ')} } from 'kysely'
|
|
69
88
|
|
|
70
89
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
71
90
|
export async function up(db: Kysely<any>): Promise<void> {
|
|
72
91
|
${citextExtension}${generateEnumStatements(columnsWithTypes)} await db.schema
|
|
73
|
-
.${altering ? 'alterTable' : 'createTable'}('${table}')${altering ? '' :
|
|
92
|
+
.${altering ? 'alterTable' : 'createTable'}('${table}')${altering ? '' : newlineDoubleIndent + generateIdStr({ primaryKeyType })}${columnDefLines}${altering
|
|
74
93
|
? ''
|
|
75
|
-
:
|
|
94
|
+
: newlineDoubleIndent +
|
|
76
95
|
".addColumn('created_at', 'timestamp', col => col.notNull())" +
|
|
77
|
-
|
|
96
|
+
newlineDoubleIndent +
|
|
78
97
|
".addColumn('updated_at', 'timestamp', col => col.notNull())"}
|
|
79
|
-
.execute()
|
|
98
|
+
.execute()${indexDefs.length ? `\n${newlineIndent}` : ''}${indexDefs.join(newlineDoubleIndent)}
|
|
80
99
|
}
|
|
81
100
|
|
|
82
101
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
83
102
|
export async function down(db: Kysely<any>): Promise<void> {
|
|
84
|
-
${altering
|
|
85
|
-
? `await db.schema${
|
|
103
|
+
${indexDrops.join(newlineIndent)}${indexDrops.length ? newlineIndent : ''}${altering
|
|
104
|
+
? `await db.schema${newlineDoubleIndent}.alterTable('${table}')${columnDropLines}.execute()`
|
|
86
105
|
: `await db.schema.dropTable('${table}').execute()`}${generateEnumDropStatements(columnsWithTypes)}
|
|
87
106
|
}\
|
|
88
107
|
`;
|
|
@@ -109,7 +128,10 @@ function generateEnumStatements(columnsWithTypes) {
|
|
|
109
128
|
const enumStatements = columnsWithTypes.filter(attribute => /:enum:.*:/.test(attribute));
|
|
110
129
|
const finalStatements = enumStatements.map(statement => {
|
|
111
130
|
const enumName = statement.split(':')[2];
|
|
112
|
-
const
|
|
131
|
+
const columnsWithTypesString = statement.split(':')[3];
|
|
132
|
+
if (columnsWithTypesString === undefined)
|
|
133
|
+
return '';
|
|
134
|
+
const columnsWithTypes = columnsWithTypesString.split(/,\s{0,}/);
|
|
113
135
|
return ` await db.schema
|
|
114
136
|
.createType('${enumName}_enum')
|
|
115
137
|
.asEnum([
|
|
@@ -132,7 +154,11 @@ function generateBooleanStr(attributeName) {
|
|
|
132
154
|
}
|
|
133
155
|
function generateEnumStr(attribute) {
|
|
134
156
|
const computedAttributeType = enumAttributeType(attribute);
|
|
135
|
-
|
|
157
|
+
const attributeName = attribute.split(':')[0];
|
|
158
|
+
if (attributeName === undefined)
|
|
159
|
+
return '';
|
|
160
|
+
const notNull = NOT_NULL_COLUMNS.includes(attributeName);
|
|
161
|
+
return `.addColumn('${attributeName}', ${computedAttributeType}${notNull ? ', col => col.notNull()' : ''})`;
|
|
136
162
|
}
|
|
137
163
|
function generateDecimalStr(attribute) {
|
|
138
164
|
const [, , ...descriptors] = attribute.split(':');
|
|
@@ -145,15 +171,21 @@ function generateColumnStr(attributeName, attributeType, descriptors) {
|
|
|
145
171
|
let returnStr = `.addColumn('${attributeName}', ${attributeTypeString(attributeType)}`;
|
|
146
172
|
const providedDefaultArg = descriptors.find(d => /^default\(/.test(d));
|
|
147
173
|
const providedDefault = providedDefaultArg?.replace(/^default\(/, '')?.replace(/\)$/, '');
|
|
148
|
-
const
|
|
174
|
+
const notNull = NOT_NULL_COLUMNS.includes(attributeName);
|
|
175
|
+
const hasExtraValues = providedDefault || notNull;
|
|
149
176
|
if (hasExtraValues)
|
|
150
177
|
returnStr += ', col => col';
|
|
151
|
-
if (
|
|
152
|
-
returnStr +=
|
|
178
|
+
if (notNull)
|
|
179
|
+
returnStr += '.notNull()';
|
|
153
180
|
if (providedDefault)
|
|
154
181
|
returnStr += `.defaultTo('${providedDefault}')`;
|
|
155
|
-
|
|
156
|
-
|
|
182
|
+
returnStr = `${returnStr})`;
|
|
183
|
+
if (attributeName === STI_TYPE_COLUMN_NAME)
|
|
184
|
+
returnStr = `// CONSIDER: when using type for STI, always use an enum
|
|
185
|
+
// Try using the enum syntax in your generator, e.g.:
|
|
186
|
+
// yarn psy g:model Balloon type:enum:balloon_type:latex,mylar
|
|
187
|
+
${returnStr}`;
|
|
188
|
+
return returnStr;
|
|
157
189
|
}
|
|
158
190
|
function attributeTypeString(attributeType) {
|
|
159
191
|
const attributeTypesRequiringSql = ['citext'];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import camelize from '../camelize.js';
|
|
2
2
|
import globalClassNameFromFullyQualifiedModelName from '../globalClassNameFromFullyQualifiedModelName.js';
|
|
3
|
-
import pascalize from '../pascalize.js';
|
|
4
3
|
import relativeDreamPath from '../path/relativeDreamPath.js';
|
|
5
4
|
import serializerNameFromFullyQualifiedModelName from '../serializerNameFromFullyQualifiedModelName.js';
|
|
6
5
|
import standardizeFullyQualifiedModelName from '../standardizeFullyQualifiedModelName.js';
|
|
@@ -71,6 +70,8 @@ export default class ${defaultSerialzerClassName}${dataTypeCapture} extends ${de
|
|
|
71
70
|
${columnsWithTypes
|
|
72
71
|
.map(attr => {
|
|
73
72
|
const [name, type] = attr.split(':');
|
|
73
|
+
if (name === undefined)
|
|
74
|
+
return '';
|
|
74
75
|
const fullyQualifiedAssociatedModelName = standardizeFullyQualifiedModelName(name);
|
|
75
76
|
const associatedModelName = globalClassNameFromFullyQualifiedModelName(fullyQualifiedAssociatedModelName);
|
|
76
77
|
const propertyName = camelize(associatedModelName);
|
|
@@ -81,7 +82,7 @@ ${columnsWithTypes
|
|
|
81
82
|
return '';
|
|
82
83
|
default:
|
|
83
84
|
return ` @Attribute(${modelClassName}${attributeOptionsSpecifier(type, attr)})
|
|
84
|
-
public ${propertyName}: ${
|
|
85
|
+
public ${propertyName}: ${`DreamColumn<${modelClassName}, '${propertyName}'>`}`;
|
|
85
86
|
}
|
|
86
87
|
})
|
|
87
88
|
.join('\n\n ')}
|
|
@@ -96,29 +97,6 @@ function attributeOptionsSpecifier(type, attr) {
|
|
|
96
97
|
return '';
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
|
-
function jsType(type, originalAttribute, propertyName, modelClass = null) {
|
|
100
|
-
if (modelClass)
|
|
101
|
-
return `DreamColumn<${modelClass}, '${propertyName}'>`;
|
|
102
|
-
switch (type) {
|
|
103
|
-
case 'date':
|
|
104
|
-
return 'CalendarDate';
|
|
105
|
-
case 'datetime':
|
|
106
|
-
return 'DateTime';
|
|
107
|
-
case 'decimal':
|
|
108
|
-
case 'integer':
|
|
109
|
-
case 'number':
|
|
110
|
-
return 'number';
|
|
111
|
-
case 'string':
|
|
112
|
-
case 'text':
|
|
113
|
-
case 'bigint':
|
|
114
|
-
case 'uuid':
|
|
115
|
-
return 'string';
|
|
116
|
-
case 'enum':
|
|
117
|
-
return pascalize(originalAttribute.split(':')[2]) + 'Enum';
|
|
118
|
-
default:
|
|
119
|
-
return 'any';
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
100
|
function importStatementForSerializer(originModelName, destinationModelName) {
|
|
123
101
|
return `\nimport ${globalClassNameFromFullyQualifiedModelName(serializerNameFromFullyQualifiedModelName(destinationModelName))}, { ${globalClassNameFromFullyQualifiedModelName(serializerNameFromFullyQualifiedModelName(destinationModelName, 'summary'))} } from '${relativeDreamPath('serializers', 'serializers', originModelName, destinationModelName)}'`;
|
|
124
102
|
}
|
|
@@ -6,7 +6,8 @@ export default function objectPathsToArrays(obj) {
|
|
|
6
6
|
}
|
|
7
7
|
function depthFirstSearch(obj, workingPath, completePaths) {
|
|
8
8
|
return Object.keys(obj).forEach(key => {
|
|
9
|
-
|
|
9
|
+
const subObj = obj[key];
|
|
10
|
+
if (subObj && Object.keys(subObj).length) {
|
|
10
11
|
depthFirstSearch(obj[key], [...workingPath, key], completePaths);
|
|
11
12
|
}
|
|
12
13
|
else {
|
|
@@ -4,9 +4,9 @@ export default class DreamCliLoggable {
|
|
|
4
4
|
logPrefixColor: DreamCliForegroundColor | undefined;
|
|
5
5
|
logPrefixBgColor: DreamCliBgColor | undefined;
|
|
6
6
|
constructor({ logPrefix, logPrefixColor, logPrefixBgColor, }: {
|
|
7
|
-
logPrefix?: string;
|
|
8
|
-
logPrefixColor?: DreamCliForegroundColor;
|
|
9
|
-
logPrefixBgColor?: DreamCliBgColor;
|
|
7
|
+
logPrefix?: string | undefined;
|
|
8
|
+
logPrefixColor?: DreamCliForegroundColor | undefined;
|
|
9
|
+
logPrefixBgColor?: DreamCliBgColor | undefined;
|
|
10
10
|
});
|
|
11
11
|
render(): void;
|
|
12
12
|
get colorizedLogPrefix(): string;
|
|
@@ -5,11 +5,11 @@ export default class DreamCliLoggableText extends DreamCliLoggable {
|
|
|
5
5
|
private color;
|
|
6
6
|
private bgColor;
|
|
7
7
|
constructor(text: string, { logPrefix, color, bgColor, logPrefixColor, logPrefixBgColor, }: {
|
|
8
|
-
logPrefix?: string;
|
|
9
|
-
color?: DreamCliForegroundColor;
|
|
10
|
-
bgColor?: DreamCliBgColor;
|
|
11
|
-
logPrefixColor?: DreamCliForegroundColor;
|
|
12
|
-
logPrefixBgColor?: DreamCliBgColor;
|
|
8
|
+
logPrefix?: string | undefined;
|
|
9
|
+
color?: DreamCliForegroundColor | undefined;
|
|
10
|
+
bgColor?: DreamCliBgColor | undefined;
|
|
11
|
+
logPrefixColor?: DreamCliForegroundColor | undefined;
|
|
12
|
+
logPrefixBgColor?: DreamCliBgColor | undefined;
|
|
13
13
|
});
|
|
14
14
|
render(): void;
|
|
15
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DreamCliBgColor, DreamCliForegroundColor } from '../../../types/logger.js';
|
|
2
|
-
export default function colorize(text: string, { color, bgColor }: {
|
|
3
|
-
color?: DreamCliForegroundColor;
|
|
4
|
-
bgColor?: DreamCliBgColor;
|
|
2
|
+
export default function colorize(text: string, { color, bgColor, }: {
|
|
3
|
+
color?: DreamCliForegroundColor | undefined;
|
|
4
|
+
bgColor?: DreamCliBgColor | undefined;
|
|
5
5
|
}): string;
|
|
@@ -7,7 +7,7 @@ export default class ConnectedToDB<DreamInstance extends Dream> {
|
|
|
7
7
|
dreamInstance: DreamInstance;
|
|
8
8
|
protected readonly dreamClass: DreamConstructorType<DreamInstance>;
|
|
9
9
|
protected dreamTransaction: DreamTransaction<Dream> | null;
|
|
10
|
-
protected connectionOverride
|
|
10
|
+
protected connectionOverride: DbConnectionType | undefined;
|
|
11
11
|
/**
|
|
12
12
|
* @internal
|
|
13
13
|
*
|
|
@@ -21,6 +21,6 @@ export default class ConnectedToDB<DreamInstance extends Dream> {
|
|
|
21
21
|
}
|
|
22
22
|
export interface ConnectedToDBOpts {
|
|
23
23
|
transaction?: DreamTransaction<Dream> | null | undefined;
|
|
24
|
-
connection?: DbConnectionType;
|
|
25
|
-
innerJoinDreamClasses?: readonly (typeof Dream)[];
|
|
24
|
+
connection?: DbConnectionType | undefined;
|
|
25
|
+
innerJoinDreamClasses?: readonly (typeof Dream)[] | undefined;
|
|
26
26
|
}
|
|
@@ -8,7 +8,7 @@ export default function setPosition({ position, previousPosition, dream, positio
|
|
|
8
8
|
previousPosition?: number;
|
|
9
9
|
positionField: string;
|
|
10
10
|
query: Query<Dream>;
|
|
11
|
-
scope
|
|
12
|
-
txn
|
|
11
|
+
scope: string | string[] | undefined;
|
|
12
|
+
txn: DreamTransaction<any> | undefined;
|
|
13
13
|
}): Promise<void>;
|
|
14
14
|
export declare function applySortableScopesToQuery<QB extends UpdateQueryBuilder<any, string, string, any> | SelectQueryBuilder<any, any, any>>(dream: Dream, kyselyQuery: QB, whereValueCB: (column: string) => any, scope?: string | string[]): QB;
|
|
@@ -5,6 +5,6 @@ export default function afterSortableCreate({ positionField, dream, query, txn,
|
|
|
5
5
|
positionField: string;
|
|
6
6
|
dream: Dream;
|
|
7
7
|
query: Query<Dream>;
|
|
8
|
-
txn?: DreamTransaction<any
|
|
9
|
-
scope
|
|
8
|
+
txn?: DreamTransaction<any> | undefined;
|
|
9
|
+
scope: string | string[] | undefined;
|
|
10
10
|
}): Promise<void>;
|
|
@@ -5,6 +5,6 @@ export default function afterUpdateSortable({ positionField, dream, query, txn,
|
|
|
5
5
|
positionField: string;
|
|
6
6
|
dream: Dream;
|
|
7
7
|
query: Query<Dream>;
|
|
8
|
-
txn?: DreamTransaction<any
|
|
9
|
-
scope
|
|
8
|
+
txn?: DreamTransaction<any> | undefined;
|
|
9
|
+
scope: string | string[] | undefined;
|
|
10
10
|
}): Promise<void>;
|
|
@@ -2,5 +2,5 @@ import { SerializableTypes } from '../../serializer/decorators/attribute.js';
|
|
|
2
2
|
export default function Virtual(type?: SerializableTypes): any;
|
|
3
3
|
export interface VirtualAttributeStatement {
|
|
4
4
|
property: string;
|
|
5
|
-
type
|
|
5
|
+
type: SerializableTypes | undefined;
|
|
6
6
|
}
|
|
@@ -885,8 +885,8 @@ export default class Query<DreamInstance extends Dream, QueryTypeOpts extends Re
|
|
|
885
885
|
* @returns The number of records that were removed
|
|
886
886
|
*/
|
|
887
887
|
destroy({ skipHooks, cascade, }?: {
|
|
888
|
-
skipHooks?: boolean;
|
|
889
|
-
cascade?: boolean;
|
|
888
|
+
skipHooks?: boolean | undefined;
|
|
889
|
+
cascade?: boolean | undefined;
|
|
890
890
|
}): Promise<number>;
|
|
891
891
|
/**
|
|
892
892
|
* Destroys all records matching the Query,
|
|
@@ -1073,29 +1073,29 @@ export default class Query<DreamInstance extends Dream, QueryTypeOpts extends Re
|
|
|
1073
1073
|
private invertOrder;
|
|
1074
1074
|
}
|
|
1075
1075
|
export interface QueryOpts<DreamInstance extends Dream, ColumnType extends DreamColumnNames<DreamInstance> = DreamColumnNames<DreamInstance>, Schema extends DreamInstance['schema'] = DreamInstance['schema'], DB extends DreamInstance['DB'] = DreamInstance['DB'], PassthroughColumns extends PassthroughColumnNames<DreamInstance> = PassthroughColumnNames<DreamInstance>> {
|
|
1076
|
-
baseSqlAlias?: TableOrAssociationName<Schema
|
|
1077
|
-
baseSelectQuery?: Query<any, any> | null;
|
|
1078
|
-
passthroughOnStatement?: PassthroughOnClause<PassthroughColumns> | null;
|
|
1079
|
-
where?: readonly WhereStatement<DB, Schema, any>[] | null;
|
|
1080
|
-
whereNot?: readonly WhereStatement<DB, Schema, any>[] | null;
|
|
1081
|
-
limit?: LimitStatement | null;
|
|
1082
|
-
offset?: OffsetStatement | null;
|
|
1083
|
-
or?: WhereStatement<DB, Schema, any>[][] | null;
|
|
1084
|
-
order?: OrderQueryStatement<ColumnType>[] | null;
|
|
1085
|
-
loadFromJoins?: boolean;
|
|
1086
|
-
preloadStatements?: RelaxedPreloadStatement;
|
|
1087
|
-
preloadOnStatements?: RelaxedPreloadOnStatement<DB, Schema
|
|
1088
|
-
distinctColumn?: ColumnType | null;
|
|
1089
|
-
innerJoinDreamClasses?: readonly (typeof Dream)[];
|
|
1090
|
-
innerJoinStatements?: RelaxedJoinStatement;
|
|
1091
|
-
innerJoinOnStatements?: RelaxedJoinOnStatement<DB, Schema
|
|
1092
|
-
leftJoinStatements?: RelaxedJoinStatement;
|
|
1093
|
-
leftJoinOnStatements?: RelaxedJoinOnStatement<DB, Schema
|
|
1094
|
-
bypassAllDefaultScopes?: boolean;
|
|
1095
|
-
bypassAllDefaultScopesExceptOnAssociations?: boolean;
|
|
1096
|
-
defaultScopesToBypass?: AllDefaultScopeNames<DreamInstance>[];
|
|
1097
|
-
defaultScopesToBypassExceptOnAssociations?: DefaultScopeName<DreamInstance>[];
|
|
1076
|
+
baseSqlAlias?: TableOrAssociationName<Schema> | undefined;
|
|
1077
|
+
baseSelectQuery?: Query<any, any> | null | undefined;
|
|
1078
|
+
passthroughOnStatement?: PassthroughOnClause<PassthroughColumns> | null | undefined;
|
|
1079
|
+
where?: readonly WhereStatement<DB, Schema, any>[] | null | undefined;
|
|
1080
|
+
whereNot?: readonly WhereStatement<DB, Schema, any>[] | null | undefined;
|
|
1081
|
+
limit?: LimitStatement | null | undefined;
|
|
1082
|
+
offset?: OffsetStatement | null | undefined;
|
|
1083
|
+
or?: WhereStatement<DB, Schema, any>[][] | null | undefined;
|
|
1084
|
+
order?: OrderQueryStatement<ColumnType>[] | null | undefined;
|
|
1085
|
+
loadFromJoins?: boolean | undefined;
|
|
1086
|
+
preloadStatements?: RelaxedPreloadStatement | undefined;
|
|
1087
|
+
preloadOnStatements?: RelaxedPreloadOnStatement<DB, Schema> | undefined;
|
|
1088
|
+
distinctColumn?: ColumnType | null | undefined;
|
|
1089
|
+
innerJoinDreamClasses?: readonly (typeof Dream)[] | undefined;
|
|
1090
|
+
innerJoinStatements?: RelaxedJoinStatement | undefined;
|
|
1091
|
+
innerJoinOnStatements?: RelaxedJoinOnStatement<DB, Schema> | undefined;
|
|
1092
|
+
leftJoinStatements?: RelaxedJoinStatement | undefined;
|
|
1093
|
+
leftJoinOnStatements?: RelaxedJoinOnStatement<DB, Schema> | undefined;
|
|
1094
|
+
bypassAllDefaultScopes?: boolean | undefined;
|
|
1095
|
+
bypassAllDefaultScopesExceptOnAssociations?: boolean | undefined;
|
|
1096
|
+
defaultScopesToBypass?: AllDefaultScopeNames<DreamInstance>[] | undefined;
|
|
1097
|
+
defaultScopesToBypassExceptOnAssociations?: DefaultScopeName<DreamInstance>[] | undefined;
|
|
1098
1098
|
transaction?: DreamTransaction<Dream> | null | undefined;
|
|
1099
|
-
connection?: DbConnectionType;
|
|
1100
|
-
shouldReallyDestroy?: boolean;
|
|
1099
|
+
connection?: DbConnectionType | undefined;
|
|
1100
|
+
shouldReallyDestroy?: boolean | undefined;
|
|
1101
1101
|
}
|
|
@@ -8,21 +8,21 @@ export interface DestroyOptions<DreamInstance extends Dream> {
|
|
|
8
8
|
* If true, bypasses all default scopes when destroying the instance.
|
|
9
9
|
* Defaults to false.
|
|
10
10
|
*/
|
|
11
|
-
bypassAllDefaultScopes?: boolean;
|
|
11
|
+
bypassAllDefaultScopes?: boolean | undefined;
|
|
12
12
|
/**
|
|
13
13
|
* An array of default scope names to bypass when destroying the instance.
|
|
14
14
|
* Defaults to an empty array.
|
|
15
15
|
*/
|
|
16
|
-
defaultScopesToBypass?: AllDefaultScopeNames<DreamInstance>[];
|
|
16
|
+
defaultScopesToBypass?: AllDefaultScopeNames<DreamInstance>[] | undefined;
|
|
17
17
|
/**
|
|
18
18
|
* If false, skips destroying associations marked `dependent: 'destroy'`. Defaults to true.
|
|
19
19
|
*/
|
|
20
|
-
cascade?: boolean;
|
|
20
|
+
cascade?: boolean | undefined;
|
|
21
21
|
/**
|
|
22
22
|
* If true, skips applying model hooks during the destroy operation.
|
|
23
23
|
* Defaults to false.
|
|
24
24
|
*/
|
|
25
|
-
skipHooks?: boolean;
|
|
25
|
+
skipHooks?: boolean | undefined;
|
|
26
26
|
}
|
|
27
27
|
export declare function destroyOptions<DreamInstance extends Dream>(options: DestroyOptions<DreamInstance>): {
|
|
28
28
|
reallyDestroy: boolean;
|
|
@@ -28,11 +28,11 @@ export default class SimilarityBuilder<DreamInstance extends Dream, DB extends D
|
|
|
28
28
|
private rankSQLAlias;
|
|
29
29
|
}
|
|
30
30
|
export interface SimilarityBuilderOpts<DreamInstance extends Dream, DB extends DreamInstance['DB'] = DreamInstance['DB'], Schema extends DreamInstance['schema'] = DreamInstance['schema']> {
|
|
31
|
-
where?: WhereStatement<DB, Schema, any>[];
|
|
32
|
-
whereNot?: WhereStatement<DB, Schema, any>[];
|
|
33
|
-
joinOnStatements?: RelaxedJoinOnStatement<DB, Schema
|
|
31
|
+
where?: WhereStatement<DB, Schema, any>[] | undefined;
|
|
32
|
+
whereNot?: WhereStatement<DB, Schema, any>[] | undefined;
|
|
33
|
+
joinOnStatements?: RelaxedJoinOnStatement<DB, Schema> | undefined;
|
|
34
34
|
transaction?: DreamTransaction<Dream> | null | undefined;
|
|
35
|
-
connection?: DbConnectionType;
|
|
35
|
+
connection?: DbConnectionType | undefined;
|
|
36
36
|
}
|
|
37
37
|
export declare const SIMILARITY_TYPES: readonly ["where", "on"];
|
|
38
38
|
export type SimilarityStatementType = (typeof SIMILARITY_TYPES)[number];
|
|
@@ -103,7 +103,7 @@ export interface DreamDirectoryPaths {
|
|
|
103
103
|
}
|
|
104
104
|
export interface DreamDbCredentialOptions {
|
|
105
105
|
primary: SingleDbCredential;
|
|
106
|
-
replica?: SingleDbCredential;
|
|
106
|
+
replica?: SingleDbCredential | undefined;
|
|
107
107
|
}
|
|
108
108
|
export interface SingleDbCredential {
|
|
109
109
|
user: string;
|
package/dist/types/src/errors/associations/AssociationDeclaredWithoutAssociatedDreamClass.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import Dream from '../../Dream.js';
|
|
2
|
+
export default class AssociationDeclaredWithoutAssociatedDreamClass extends Error {
|
|
3
|
+
private dreamClass;
|
|
4
|
+
private associationName;
|
|
5
|
+
constructor(dreamClass: typeof Dream, associationName: string | number | symbol);
|
|
6
|
+
get message(): string;
|
|
7
|
+
}
|
|
@@ -3,6 +3,6 @@ import { HasOneStatement } from '../../types/associations/hasOne.js';
|
|
|
3
3
|
export default class MissingRequiredAssociationOnClause extends Error {
|
|
4
4
|
private association;
|
|
5
5
|
private column;
|
|
6
|
-
constructor(association: HasManyStatement<any, any, any, any> | HasOneStatement<any, any, any, any>, column: string);
|
|
6
|
+
constructor(association: HasManyStatement<any, any, any, any> | HasOneStatement<any, any, any, any>, column: string | undefined);
|
|
7
7
|
get message(): string;
|
|
8
8
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default function generateDreamContent({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, serializer, }: {
|
|
2
2
|
fullyQualifiedModelName: string;
|
|
3
3
|
columnsWithTypes: string[];
|
|
4
|
-
fullyQualifiedParentName?: string;
|
|
4
|
+
fullyQualifiedParentName?: string | undefined;
|
|
5
5
|
serializer: boolean;
|
|
6
6
|
}): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default function generateMigration({ migrationName, columnsWithTypes, fullyQualifiedModelName, fullyQualifiedParentName, }: {
|
|
2
2
|
migrationName: string;
|
|
3
3
|
columnsWithTypes: string[];
|
|
4
|
-
fullyQualifiedModelName?: string;
|
|
5
|
-
fullyQualifiedParentName?: string;
|
|
4
|
+
fullyQualifiedModelName?: string | undefined;
|
|
5
|
+
fullyQualifiedParentName?: string | undefined;
|
|
6
6
|
}): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PrimaryKeyType } from '../../types/dream.js';
|
|
2
2
|
export default function generateMigrationContent({ table, columnsWithTypes, primaryKeyType, createOrAlter, }?: {
|
|
3
|
-
table?: string;
|
|
4
|
-
columnsWithTypes?: string[];
|
|
5
|
-
primaryKeyType?: PrimaryKeyType;
|
|
6
|
-
createOrAlter?: 'create' | 'alter';
|
|
3
|
+
table?: string | undefined;
|
|
4
|
+
columnsWithTypes?: string[] | undefined;
|
|
5
|
+
primaryKeyType?: PrimaryKeyType | undefined;
|
|
6
|
+
createOrAlter?: 'create' | 'alter' | undefined;
|
|
7
7
|
}): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default function generateSerializer({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, }: {
|
|
2
2
|
fullyQualifiedModelName: string;
|
|
3
3
|
columnsWithTypes: string[];
|
|
4
|
-
fullyQualifiedParentName?: string;
|
|
4
|
+
fullyQualifiedParentName?: string | undefined;
|
|
5
5
|
}): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default function generateSerializerContent({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, }: {
|
|
2
2
|
fullyQualifiedModelName: string;
|
|
3
|
-
columnsWithTypes?: string[];
|
|
4
|
-
fullyQualifiedParentName?: string;
|
|
3
|
+
columnsWithTypes?: string[] | undefined;
|
|
4
|
+
fullyQualifiedParentName?: string | undefined;
|
|
5
5
|
}): string;
|
|
@@ -33,12 +33,7 @@ import { HasOneStatement } from './hasOne.ts'
|
|
|
33
33
|
|
|
34
34
|
export type MAX_JOINED_TABLES_DEPTH = 25
|
|
35
35
|
|
|
36
|
-
export type AssociationMetadataMap = Record<
|
|
37
|
-
string,
|
|
38
|
-
| BelongsToStatement<any, any, any, any>
|
|
39
|
-
| HasManyStatement<any, any, any, any>
|
|
40
|
-
| HasOneStatement<any, any, any, any>
|
|
41
|
-
>
|
|
36
|
+
export type AssociationMetadataMap = Record<string, AssociationStatement>
|
|
42
37
|
|
|
43
38
|
export type AssociatedBelongsToModelType<
|
|
44
39
|
I extends Dream,
|
|
@@ -6,9 +6,6 @@ import CalendarDate from '../helpers/CalendarDate.ts'
|
|
|
6
6
|
import { DateTime } from '../helpers/DateTime.ts'
|
|
7
7
|
import OpsStatement from '../ops/ops-statement.ts'
|
|
8
8
|
import DreamSerializer from '../serializer/index.ts'
|
|
9
|
-
import { BelongsToStatement } from './associations/belongsTo.ts'
|
|
10
|
-
import { HasManyStatement } from './associations/hasMany.ts'
|
|
11
|
-
import { HasOneStatement } from './associations/hasOne.ts'
|
|
12
9
|
import { AssociatedModelParam, OnStatementForAssociation, WhereStatement } from './associations/shared.ts'
|
|
13
10
|
import { AssociationTableNames } from './db.js'
|
|
14
11
|
import { FindEachOpts } from './query.ts'
|
|
@@ -386,20 +383,12 @@ export type PreloadArgumentTypeAssociatedTableNames<
|
|
|
386
383
|
// end:preload
|
|
387
384
|
|
|
388
385
|
export type AssociationNameToDreamClassMap = Record<string, typeof Dream>
|
|
389
|
-
export type AssociationNameToAssociationMap = Record<
|
|
390
|
-
string,
|
|
391
|
-
| BelongsToStatement<any, any, any, any>
|
|
392
|
-
| HasOneStatement<any, any, any, any>
|
|
393
|
-
| HasManyStatement<any, any, any, any>
|
|
394
|
-
>
|
|
386
|
+
export type AssociationNameToAssociationMap = Record<string, AssociationMetadata>
|
|
395
387
|
export type AssociationNameToAssociationDataAndDreamClassMap = Record<
|
|
396
388
|
string,
|
|
397
389
|
{
|
|
398
390
|
dreamClass: typeof Dream
|
|
399
|
-
association:
|
|
400
|
-
| BelongsToStatement<any, any, any, any>
|
|
401
|
-
| HasOneStatement<any, any, any, any>
|
|
402
|
-
| HasManyStatement<any, any, any, any>
|
|
391
|
+
association: AssociationMetadata
|
|
403
392
|
}
|
|
404
393
|
>
|
|
405
394
|
|
|
@@ -22,8 +22,8 @@ export interface HookStatement {
|
|
|
22
22
|
type: HookType
|
|
23
23
|
className: string
|
|
24
24
|
method: string
|
|
25
|
-
ifChanging?: string[]
|
|
26
|
-
ifChanged?: string[]
|
|
25
|
+
ifChanging?: string[] | undefined
|
|
26
|
+
ifChanged?: string[] | undefined
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export interface BeforeHookOpts<T extends Dream | null = null> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface DreamCliLoggerLogOpts {
|
|
2
|
-
logPrefix?: string
|
|
3
|
-
logPrefixColor?: DreamCliForegroundColor
|
|
4
|
-
logPrefixBgColor?: DreamCliBgColor
|
|
2
|
+
logPrefix?: string | undefined
|
|
3
|
+
logPrefixColor?: DreamCliForegroundColor | undefined
|
|
4
|
+
logPrefixBgColor?: DreamCliBgColor | undefined
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export type DreamCliColor = DreamCliForegroundColor | DreamCliBgColor
|