@rvoh/dream 2.0.4 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +332 -0
- package/dist/cjs/src/bin/index.js +2 -0
- package/dist/cjs/src/db/helpers/dreamSchemaTypesFilenameForConnection.js +3 -0
- package/dist/cjs/src/db/helpers/syncDbTypesFiles.js +2 -89
- package/dist/cjs/src/dream/QueryDriver/Base.js +2 -2
- package/dist/cjs/src/dream/QueryDriver/Kysely.js +9 -19
- package/dist/cjs/src/dream/QueryDriver/Postgres.js +2 -2
- package/dist/cjs/src/dream-app/index.js +15 -0
- package/dist/cjs/src/helpers/cli/ASTBuilder.js +277 -0
- package/dist/cjs/src/helpers/cli/ASTConnectionBuilder.js +284 -0
- package/dist/cjs/src/helpers/cli/ASTGlobalSchemaBuilder.js +57 -0
- package/dist/cjs/src/helpers/cli/ASTKyselyCodegenEnhancer.js +236 -0
- package/dist/cjs/src/helpers/cli/ASTSchemaBuilder.js +304 -0
- package/dist/cjs/src/helpers/cli/DBClassDeprecation.js +60 -0
- package/dist/cjs/src/helpers/cli/generateDreamContent.js +5 -4
- package/dist/cjs/src/helpers/cli/generateFactoryContent.js +3 -2
- package/dist/cjs/src/helpers/cli/generateMigrationContent.js +6 -4
- package/dist/cjs/src/helpers/cli/generateSerializerContent.js +1 -1
- package/dist/esm/src/bin/index.js +2 -0
- package/dist/esm/src/db/helpers/dreamSchemaTypesFilenameForConnection.js +3 -0
- package/dist/esm/src/db/helpers/syncDbTypesFiles.js +2 -89
- package/dist/esm/src/dream/QueryDriver/Base.js +2 -2
- package/dist/esm/src/dream/QueryDriver/Kysely.js +9 -19
- package/dist/esm/src/dream/QueryDriver/Postgres.js +2 -2
- package/dist/esm/src/dream-app/index.js +15 -0
- package/dist/esm/src/helpers/cli/ASTBuilder.js +277 -0
- package/dist/esm/src/helpers/cli/ASTConnectionBuilder.js +284 -0
- package/dist/esm/src/helpers/cli/ASTGlobalSchemaBuilder.js +57 -0
- package/dist/esm/src/helpers/cli/ASTKyselyCodegenEnhancer.js +236 -0
- package/dist/esm/src/helpers/cli/ASTSchemaBuilder.js +304 -0
- package/dist/esm/src/helpers/cli/DBClassDeprecation.js +60 -0
- package/dist/esm/src/helpers/cli/generateDreamContent.js +5 -4
- package/dist/esm/src/helpers/cli/generateFactoryContent.js +3 -2
- package/dist/esm/src/helpers/cli/generateMigrationContent.js +6 -4
- package/dist/esm/src/helpers/cli/generateSerializerContent.js +1 -1
- package/dist/types/src/db/helpers/dreamSchemaTypesFilenameForConnection.d.ts +1 -0
- package/dist/types/src/dream/QueryDriver/Base.d.ts +3 -3
- package/dist/types/src/dream/QueryDriver/Kysely.d.ts +2 -14
- package/dist/types/src/dream/QueryDriver/Postgres.d.ts +2 -2
- package/dist/types/src/dream-app/index.d.ts +12 -2
- package/dist/types/src/helpers/cli/ASTBuilder.d.ts +159 -0
- package/dist/types/src/helpers/cli/ASTConnectionBuilder.d.ts +104 -0
- package/dist/types/src/helpers/cli/ASTGlobalSchemaBuilder.d.ts +28 -0
- package/dist/types/src/helpers/cli/ASTKyselyCodegenEnhancer.d.ts +68 -0
- package/dist/types/src/helpers/cli/ASTSchemaBuilder.d.ts +80 -0
- package/dist/types/src/helpers/cli/DBClassDeprecation.d.ts +14 -0
- package/docs/assets/search.js +1 -1
- package/docs/classes/db.DreamMigrationHelpers.html +9 -9
- package/docs/classes/db.KyselyQueryDriver.html +31 -44
- package/docs/classes/db.PostgresQueryDriver.html +32 -45
- package/docs/classes/db.QueryDriverBase.html +30 -30
- package/docs/classes/errors.CheckConstraintViolation.html +3 -3
- package/docs/classes/errors.ColumnOverflow.html +3 -3
- package/docs/classes/errors.CreateOrFindByFailedToCreateAndFind.html +3 -3
- package/docs/classes/errors.DataIncompatibleWithDatabaseField.html +3 -3
- package/docs/classes/errors.DataTypeColumnTypeMismatch.html +3 -3
- package/docs/classes/errors.GlobalNameNotSet.html +3 -3
- package/docs/classes/errors.InvalidCalendarDate.html +2 -2
- package/docs/classes/errors.MissingSerializersDefinition.html +3 -3
- package/docs/classes/errors.NonLoadedAssociation.html +3 -3
- package/docs/classes/errors.NotNullViolation.html +3 -3
- package/docs/classes/errors.RecordNotFound.html +3 -3
- package/docs/classes/errors.ValidationError.html +3 -3
- package/docs/classes/index.CalendarDate.html +2 -2
- package/docs/classes/index.Decorators.html +19 -19
- package/docs/classes/index.Dream.html +113 -113
- package/docs/classes/index.DreamApp.html +7 -6
- package/docs/classes/index.DreamTransaction.html +2 -2
- package/docs/classes/index.Env.html +2 -2
- package/docs/classes/index.Query.html +53 -53
- package/docs/classes/system.CliFileWriter.html +2 -2
- package/docs/classes/system.DreamBin.html +2 -2
- package/docs/classes/system.DreamCLI.html +5 -5
- package/docs/classes/system.DreamImporter.html +2 -2
- package/docs/classes/system.DreamLogos.html +2 -2
- package/docs/classes/system.DreamSerializerBuilder.html +8 -8
- package/docs/classes/system.ObjectSerializerBuilder.html +8 -8
- package/docs/classes/utils.Encrypt.html +2 -2
- package/docs/classes/utils.Range.html +2 -2
- package/docs/functions/db.closeAllDbConnections.html +1 -1
- package/docs/functions/db.dreamDbConnections.html +1 -1
- package/docs/functions/db.untypedDb.html +1 -1
- package/docs/functions/db.validateColumn.html +1 -1
- package/docs/functions/db.validateTable.html +1 -1
- package/docs/functions/errors.pgErrorType.html +1 -1
- package/docs/functions/index.DreamSerializer.html +1 -1
- package/docs/functions/index.ObjectSerializer.html +1 -1
- package/docs/functions/index.ReplicaSafe.html +1 -1
- package/docs/functions/index.STI.html +1 -1
- package/docs/functions/index.SoftDelete.html +1 -1
- package/docs/functions/utils.camelize.html +1 -1
- package/docs/functions/utils.capitalize.html +1 -1
- package/docs/functions/utils.cloneDeepSafe.html +1 -1
- package/docs/functions/utils.compact.html +1 -1
- package/docs/functions/utils.groupBy.html +1 -1
- package/docs/functions/utils.hyphenize.html +1 -1
- package/docs/functions/utils.intersection.html +1 -1
- package/docs/functions/utils.isEmpty.html +1 -1
- package/docs/functions/utils.normalizeUnicode.html +1 -1
- package/docs/functions/utils.pascalize.html +1 -1
- package/docs/functions/utils.percent.html +1 -1
- package/docs/functions/utils.range-1.html +1 -1
- package/docs/functions/utils.round.html +1 -1
- package/docs/functions/utils.sanitizeString.html +1 -1
- package/docs/functions/utils.snakeify.html +1 -1
- package/docs/functions/utils.sort.html +1 -1
- package/docs/functions/utils.sortBy.html +1 -1
- package/docs/functions/utils.sortObjectByKey.html +1 -1
- package/docs/functions/utils.sortObjectByValue.html +1 -1
- package/docs/functions/utils.uncapitalize.html +1 -1
- package/docs/functions/utils.uniq.html +1 -1
- package/docs/interfaces/openapi.OpenapiDescription.html +2 -2
- package/docs/interfaces/openapi.OpenapiSchemaProperties.html +1 -1
- package/docs/interfaces/openapi.OpenapiSchemaPropertiesShorthand.html +1 -1
- package/docs/interfaces/openapi.OpenapiTypeFieldObject.html +1 -1
- package/docs/interfaces/types.BelongsToStatement.html +2 -2
- package/docs/interfaces/types.DecoratorContext.html +2 -2
- package/docs/interfaces/types.DreamAppInitOptions.html +2 -2
- package/docs/interfaces/types.DreamAppOpts.html +2 -2
- package/docs/interfaces/types.EncryptOptions.html +2 -2
- package/docs/interfaces/types.InternalAnyTypedSerializerRendersMany.html +2 -2
- package/docs/interfaces/types.InternalAnyTypedSerializerRendersOne.html +2 -2
- package/docs/interfaces/types.SerializerRendererOpts.html +2 -2
- package/docs/modules/db.html +1 -1
- package/docs/modules/errors.html +1 -1
- package/docs/modules/index.html +1 -1
- package/docs/modules/openapi.html +1 -1
- package/docs/modules/system.html +1 -1
- package/docs/modules/types.html +1 -1
- package/docs/modules/utils.html +1 -1
- package/docs/types/index.DateTime.html +1 -1
- package/docs/types/openapi.CommonOpenapiSchemaObjectFields.html +1 -1
- package/docs/types/openapi.OpenapiAllTypes.html +1 -1
- package/docs/types/openapi.OpenapiFormats.html +1 -1
- package/docs/types/openapi.OpenapiNumberFormats.html +1 -1
- package/docs/types/openapi.OpenapiPrimitiveBaseTypes.html +1 -1
- package/docs/types/openapi.OpenapiPrimitiveTypes.html +1 -1
- package/docs/types/openapi.OpenapiSchemaArray.html +1 -1
- package/docs/types/openapi.OpenapiSchemaArrayShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaBase.html +1 -1
- package/docs/types/openapi.OpenapiSchemaBody.html +1 -1
- package/docs/types/openapi.OpenapiSchemaBodyShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaCommonFields.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionAllOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionAnyOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionOneOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionRef.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaInteger.html +1 -1
- package/docs/types/openapi.OpenapiSchemaNull.html +1 -1
- package/docs/types/openapi.OpenapiSchemaNumber.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObject.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAllOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAllOfShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAnyOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAnyOfShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectBase.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectBaseShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectOneOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectOneOfShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaPrimitiveGeneric.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionAllOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionOneOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
- package/docs/types/openapi.OpenapiSchemaString.html +1 -1
- package/docs/types/openapi.OpenapiShorthandAllTypes.html +1 -1
- package/docs/types/openapi.OpenapiShorthandPrimitiveBaseTypes.html +1 -1
- package/docs/types/openapi.OpenapiShorthandPrimitiveTypes.html +1 -1
- package/docs/types/openapi.OpenapiTypeField.html +1 -1
- package/docs/types/system.DreamAppAllowedPackageManagersEnum.html +1 -1
- package/docs/types/types.Camelized.html +1 -1
- package/docs/types/types.DbConnectionType.html +1 -1
- package/docs/types/types.DbTypes.html +1 -1
- package/docs/types/types.DreamAssociationMetadata.html +1 -1
- package/docs/types/types.DreamAttributes.html +1 -1
- package/docs/types/types.DreamClassAssociationAndStatement.html +1 -1
- package/docs/types/types.DreamClassColumn.html +1 -1
- package/docs/types/types.DreamColumn.html +1 -1
- package/docs/types/types.DreamColumnNames.html +1 -1
- package/docs/types/types.DreamLogLevel.html +1 -1
- package/docs/types/types.DreamLogger.html +1 -1
- package/docs/types/types.DreamModelSerializerType.html +1 -1
- package/docs/types/types.DreamOrViewModelClassSerializerKey.html +1 -1
- package/docs/types/types.DreamOrViewModelSerializerKey.html +1 -1
- package/docs/types/types.DreamParamSafeAttributes.html +1 -1
- package/docs/types/types.DreamParamSafeColumnNames.html +1 -1
- package/docs/types/types.DreamSerializable.html +1 -1
- package/docs/types/types.DreamSerializableArray.html +1 -1
- package/docs/types/types.DreamSerializerKey.html +1 -1
- package/docs/types/types.DreamSerializers.html +1 -1
- package/docs/types/types.DreamVirtualColumns.html +1 -1
- package/docs/types/types.EncryptAlgorithm.html +1 -1
- package/docs/types/types.HasManyStatement.html +1 -1
- package/docs/types/types.HasOneStatement.html +1 -1
- package/docs/types/types.Hyphenized.html +1 -1
- package/docs/types/types.Pascalized.html +1 -1
- package/docs/types/types.RoundingPrecision.html +1 -1
- package/docs/types/types.SerializerCasing.html +1 -1
- package/docs/types/types.SimpleObjectSerializerType.html +1 -1
- package/docs/types/types.Snakeified.html +1 -1
- package/docs/types/types.StrictInterface.html +1 -1
- package/docs/types/types.UpdateableAssociationProperties.html +1 -1
- package/docs/types/types.UpdateableProperties.html +1 -1
- package/docs/types/types.ValidationType.html +1 -1
- package/docs/types/types.ViewModel.html +1 -1
- package/docs/types/types.ViewModelClass.html +1 -1
- package/docs/types/types.WhereStatementForDream.html +1 -1
- package/docs/types/types.WhereStatementForDreamClass.html +1 -1
- package/docs/variables/index.DateTime-1.html +1 -1
- package/docs/variables/index.DreamConst.html +1 -1
- package/docs/variables/index.ops.html +1 -1
- package/docs/variables/openapi.openapiPrimitiveTypes-1.html +1 -1
- package/docs/variables/openapi.openapiShorthandPrimitiveTypes-1.html +1 -1
- package/docs/variables/system.DreamAppAllowedPackageManagersEnumValues.html +1 -1
- package/docs/variables/types.TRIGRAM_OPERATORS.html +1 -1
- package/docs/variables/types.primaryKeyTypes.html +1 -1
- package/package.json +7 -3
- package/dist/cjs/src/helpers/cli/SchemaBuilder.js +0 -408
- package/dist/esm/src/helpers/cli/SchemaBuilder.js +0 -408
- package/dist/types/src/helpers/cli/SchemaBuilder.d.ts +0 -44
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
## 2.1.2
|
|
2
|
+
|
|
3
|
+
- add missing peerDependencies
|
|
4
|
+
|
|
5
|
+
## 2.1.1
|
|
6
|
+
|
|
7
|
+
generators support alternate casings when parsing association statements (i.e. `psy g model Pet user:belongsTo`)
|
|
8
|
+
|
|
9
|
+
## 2.1.0
|
|
10
|
+
|
|
11
|
+
- Change type file generation to AST
|
|
12
|
+
- Soft-deprecate DBClass (automatically updated on sync)
|
|
13
|
+
|
|
14
|
+
## 2.0.4
|
|
15
|
+
|
|
16
|
+
improve CLI command descriptions
|
|
17
|
+
|
|
18
|
+
## 2.0.3
|
|
19
|
+
|
|
20
|
+
don't require database to exist when creating migrations (fixes create-psychic with uuid primary keys)
|
|
21
|
+
|
|
22
|
+
## 2.0.2
|
|
23
|
+
|
|
24
|
+
bump glob to close dependabot alerts
|
|
25
|
+
|
|
26
|
+
## 2.0.1
|
|
27
|
+
|
|
28
|
+
remove dream-spec-helpers from peer dependencies
|
|
29
|
+
|
|
30
|
+
## 2.0.0
|
|
31
|
+
|
|
32
|
+
- namespace package exports
|
|
33
|
+
- remove `Benchmark`
|
|
34
|
+
- Remove `leftJoinPreloadFor` and `leftJoinLoadFor`. They were never a good idea since the idea of `preloadFor` is that one doesn't need to pay attention to all the things that need to be preloaded, but in a join situation, this is a recipe for disaster since loading tables in parallel results in a Cartesian product of result rows being
|
|
35
|
+
|
|
36
|
+
## 1.13.0
|
|
37
|
+
|
|
38
|
+
- generated code uses absolute imports
|
|
39
|
+
- `Virtual` decorator requires OpenAPI shape
|
|
40
|
+
- don't let a null value in a `Sortable` column break future sorts (null may enter via a migration or `skipHooks`)
|
|
41
|
+
- simplify and DRY up Sortable
|
|
42
|
+
- Sortable keeps values within the range 1 to N
|
|
43
|
+
- fix STI child generation with array attributes (arrays can always be initialized to an empty array, so can leverage a regular non-null constraint). E.g:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
yarn psy g:sti-child Room/Bedroom extends Room bed_types:enum\[\]:bed_types:twin,bunk,queen,king,cot,sofabed
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 1.12.0
|
|
50
|
+
|
|
51
|
+
- DateTime and CalendarDate are always valid and throw an error if invalid
|
|
52
|
+
|
|
53
|
+
## 1.11.0
|
|
54
|
+
|
|
55
|
+
- fix `scrollPaginate` when the column being ordered by is not unique
|
|
56
|
+
- fix `pluck` so it properly omits soft-deleted records
|
|
57
|
+
|
|
58
|
+
## 1.11.0
|
|
59
|
+
|
|
60
|
+
- `association` and `associationOrFail` handle required and passthrough `and` clauses
|
|
61
|
+
- `association` and `associationOrFail` compatible with transactions
|
|
62
|
+
- `scrollPaginate` Query and static Dream methods
|
|
63
|
+
- remove `paginate` from DreamClassTransactionBuilder
|
|
64
|
+
|
|
65
|
+
## 1.10.0
|
|
66
|
+
|
|
67
|
+
- bump kysely
|
|
68
|
+
- paginate includes default ordering on id
|
|
69
|
+
- cli command to ensure migrations have been run prior to running specs
|
|
70
|
+
- fix ability to sync when type files don't reflect models
|
|
71
|
+
- leverage Map instead of an object so don't need to prefix numeric keys with underscore to prevent them from being sorted by numeric value rather than by the order in which they were added to the map
|
|
72
|
+
- renameTable migration helper
|
|
73
|
+
- the key function passed to `sortBy` may now also return a DateTime, a CalendarDate, or a bigint
|
|
74
|
+
- fix `sort` on bigint arrays
|
|
75
|
+
- `percent` function
|
|
76
|
+
- `association` and `associationOrFail` methods to encapsulate the loaded check or associationQuery ternary pattern
|
|
77
|
+
- generated association name and id for a `belongs_to` association are based on the final part of the model name, not the entire namespace [requires Psychic update for generated resource controllers/specs to generate valid code]
|
|
78
|
+
- [BREAKING] `on` replaces `foreignKey` in association declarations, e.g.:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
@deco.HasOne('BalloonLine', { on: 'balloonId' })
|
|
82
|
+
public balloonLine: BalloonLine
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
- generated migrations include index on foreign key
|
|
86
|
+
- don't require openapi for delegatedType when delegating to an association since we can derive the openapi type automatically [requires Psychic update for proper OpenAPI shape to be generated]
|
|
87
|
+
- fix OpenAPI in generated STI base serializer
|
|
88
|
+
|
|
89
|
+
## 1.9.4
|
|
90
|
+
|
|
91
|
+
- if `required: false`, leave the property undefined rather than rendering as `null`
|
|
92
|
+
|
|
93
|
+
## 1.9.3
|
|
94
|
+
|
|
95
|
+
- serializer builder attribute option types allow `required: false`; this will be used by Psychic to omit attributes from the required array in OpenaAPI
|
|
96
|
+
|
|
97
|
+
## 1.9.2
|
|
98
|
+
|
|
99
|
+
- allow null for ops argument to a where clause on a datetime or date column
|
|
100
|
+
|
|
101
|
+
## 1.9.1
|
|
102
|
+
|
|
103
|
+
- fix where clause range types to allow mixing of CalendarDate and DateTime between start and end of range
|
|
104
|
+
- DateTime and CalendarDate may be used in ops when comparing against a date or datetime column
|
|
105
|
+
|
|
106
|
+
## 1.9.0
|
|
107
|
+
|
|
108
|
+
Fix broken param safe type columns so that:
|
|
109
|
+
|
|
110
|
+
1. polymorphic type fields are excluded from param safe types
|
|
111
|
+
2. association names are excluded
|
|
112
|
+
|
|
113
|
+
Bumping minor, since it could introduce breaking changes for those reliant on previous param safe behavior.
|
|
114
|
+
|
|
115
|
+
## 1.8.0
|
|
116
|
+
|
|
117
|
+
- throw ColumnOverflow when saving too long a string / number to a database column
|
|
118
|
+
- make all of these errors extend the same error so Psychic can check a single error type when deciding to return 400
|
|
119
|
+
|
|
120
|
+
## 1.7.3
|
|
121
|
+
|
|
122
|
+
- remove unnecessary token, now that we are open-sourced
|
|
123
|
+
|
|
124
|
+
## 1.7.2
|
|
125
|
+
|
|
126
|
+
- fix issue causing generators to generate invalid uuid primary keys
|
|
127
|
+
|
|
128
|
+
## 1.7.1
|
|
129
|
+
|
|
130
|
+
- fix error when file without default export exists in the models directory hierarchy
|
|
131
|
+
|
|
132
|
+
## 1.7.0
|
|
133
|
+
|
|
134
|
+
- Remove `Dream#isDreamInstance` and `DreamSerializerBuilder/ObjectSerializerBuilder#isSerializer`
|
|
135
|
+
- Export `MissingSerializersDefinition`
|
|
136
|
+
|
|
137
|
+
## 1.6.0
|
|
138
|
+
|
|
139
|
+
- Move sanitization to Psychic so it can sanitize to real unicode representations
|
|
140
|
+
|
|
141
|
+
## 1.5.2
|
|
142
|
+
|
|
143
|
+
- Don't require `openapi` for virtual attributes
|
|
144
|
+
- Fix Sortable with null value in scope column
|
|
145
|
+
- Enable sanitization of serialized attributes
|
|
146
|
+
- Enable `<association>.<column>: null` where statements even when the column can't be null so that queries can be constructed to locate models that don't have a particular association
|
|
147
|
+
|
|
148
|
+
## 1.5.1
|
|
149
|
+
|
|
150
|
+
Add `DreamMigrationHelpers.newTransaction()` to support explicitly starting a new transaction within a migration.
|
|
151
|
+
|
|
152
|
+
## 1.5.0
|
|
153
|
+
|
|
154
|
+
- add support for multiple database connections in a single dream application. To take advantage of this new feature, you can do the following:
|
|
155
|
+
|
|
156
|
+
1. Add a new connection configuration to your conf/dream.ts file, providing it an explicit alternate connection name as the second argument, like so:
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
dreamApp.set('db', 'myAlternateConnection', {
|
|
160
|
+
primary: {
|
|
161
|
+
user: AppEnv.string('DB_USER'),
|
|
162
|
+
password: AppEnv.string('DB_PASSWORD', { optional: !AppEnv.isProduction }),
|
|
163
|
+
host: AppEnv.string('DB_HOST', { optional: true }),
|
|
164
|
+
name: AppEnv.string('ALTERNATE_DB_NAME', { optional: true }),
|
|
165
|
+
port: AppEnv.integer('ALTERNATE_DB_PORT', { optional: true }),
|
|
166
|
+
useSsl: false,
|
|
167
|
+
},
|
|
168
|
+
})
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Be sure to add any new environment variables to your .env and .env.test files.
|
|
172
|
+
|
|
173
|
+
2. Run sync
|
|
174
|
+
|
|
175
|
+
```sh
|
|
176
|
+
yarn psy sync
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
3. add a new application model for your new connection, naming it the name of your connection, pascalized, with the string `ApplicationModel` at the end, like so:
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
// app/models/MyAlternateConnectionApplicationModel.ts
|
|
183
|
+
|
|
184
|
+
import Dream from '../../../src/Dream.js'
|
|
185
|
+
import { DBClass } from '../../types/db.alternateConnection.js'
|
|
186
|
+
import { connectionTypeConfig, schema } from '../../types/dream.alternateConnection.js'
|
|
187
|
+
import { globalTypeConfig } from '../../types/dream.globals.js'
|
|
188
|
+
|
|
189
|
+
export default class MyAlternateConnectionApplicationModel extends Dream {
|
|
190
|
+
declare public DB: DBClass
|
|
191
|
+
|
|
192
|
+
public override get connectionName() {
|
|
193
|
+
return 'alternateConnection' as const
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
public override get schema(): any {
|
|
197
|
+
return schema
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
public override get connectionTypeConfig() {
|
|
201
|
+
return connectionTypeConfig
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
public override get globalTypeConfig() {
|
|
205
|
+
return globalTypeConfig
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
4. Now you can proceed to generate a model for your new connection, like so:
|
|
211
|
+
|
|
212
|
+
```sh
|
|
213
|
+
yarn psy g:model MyNewModel someField:text --connection-name=myAlternateConnection
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Dream will automatically read the connectionName and use it to derive the `MyAlternateConnectionApplicationModel` automatically, though if this isn't correct, you will need to manually adjust it.
|
|
217
|
+
|
|
218
|
+
5. Alternate db engine support
|
|
219
|
+
|
|
220
|
+
If you would like to use an alternate db engine, this is also now supported. To do this, you will need to provide a query driver class that extends one of our base query driver classes. As an example, I recommend you take a look at the `MysqlQueryDriver.ts` file housed within the test-app folder of this repo. This class is not ready for production use, but is a good jumping off point for those interested in supporting a different query driver for dream.
|
|
221
|
+
|
|
222
|
+
To utilize this feature, simply provide a different query driver class in your db connection config, like so:
|
|
223
|
+
|
|
224
|
+
```ts
|
|
225
|
+
// conf/dream.ts
|
|
226
|
+
|
|
227
|
+
app.set('db', {
|
|
228
|
+
queryDriverClass: MyCustomQueryDriverClass,
|
|
229
|
+
...
|
|
230
|
+
})
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## 1.4.2
|
|
234
|
+
|
|
235
|
+
- add ability to set custom import extension, which will be used when generating new files for your application
|
|
236
|
+
|
|
237
|
+
## 1.4.1
|
|
238
|
+
|
|
239
|
+
- cache Dream app earlier in the initialization sequence
|
|
240
|
+
|
|
241
|
+
## 1.4.0
|
|
242
|
+
|
|
243
|
+
- fix `preloadFor` infinite loop when serializers have circular references
|
|
244
|
+
|
|
245
|
+
- generated STI base serializer updated to only include the single type of the particular STI child in the OpenAPI shape for that child
|
|
246
|
+
|
|
247
|
+
- change `primaryKeyValue` from a getter to a method so it can return the correct type even when `primaryKey` has been overridden on a particular Dream model
|
|
248
|
+
|
|
249
|
+
- remove `IdType`, an unnecessary abstraction that caused type inconsistencies
|
|
250
|
+
|
|
251
|
+
- explicitly handle bigint from the database as string
|
|
252
|
+
|
|
253
|
+
## 1.3.3
|
|
254
|
+
|
|
255
|
+
- make `referenceTypeString` public
|
|
256
|
+
|
|
257
|
+
## 1.3.2
|
|
258
|
+
|
|
259
|
+
- restore aliasing in preload/load queries
|
|
260
|
+
|
|
261
|
+
## 1.3.1
|
|
262
|
+
|
|
263
|
+
- throw NotNullViolation when Postgres throws a not null violation
|
|
264
|
+
|
|
265
|
+
- throw CheckViolation when Postgres throws a check violation
|
|
266
|
+
|
|
267
|
+
## 1.3.0
|
|
268
|
+
|
|
269
|
+
- sti-child generator includes check constraint instead of not-null since the column should only be not-null for that STI child (or modified by hand to accommodate more than one STI child)
|
|
270
|
+
|
|
271
|
+
- add `Dream#hasAssociation`
|
|
272
|
+
|
|
273
|
+
- fix preloading associations on other side of a polyorphic belongs-to association so that we don't set an association on a dream model that doesn't define that association
|
|
274
|
+
|
|
275
|
+
- fix preloading association on the other side of a polymorphic belongs-to since the same association name may be defined differently on different models. For example, taskable may be a Chore or a Workout, both of which have an `images` association, but `images` goes through ChoreImage on Chore and through WorkoutImage on Workout
|
|
276
|
+
|
|
277
|
+
- fix preloadFor when a rendersOne/Many renders a polymorphic belongs-to (was only preloading serializer associations for one of the polymorphically associated models)
|
|
278
|
+
|
|
279
|
+
- fix preloadFor when an explicit serializer option is provided to a rendersOne/Many
|
|
280
|
+
|
|
281
|
+
## 1.2.1
|
|
282
|
+
|
|
283
|
+
- Throw DataTypeColumnTypeMismatch when Postgres throws an error attempting to save to a column with a value that can't be cast to the column type.
|
|
284
|
+
|
|
285
|
+
## 1.2.0
|
|
286
|
+
|
|
287
|
+
- Add Dream.lookup, enabling devs to tap into the IOC provided by dream to dodge circular import issues
|
|
288
|
+
|
|
289
|
+
## 1.1.2
|
|
290
|
+
|
|
291
|
+
- CliFileWriter does not raise error if the file we are writing is not in the file system yet.
|
|
292
|
+
|
|
293
|
+
## 1.1.1
|
|
294
|
+
|
|
295
|
+
- Add fs.writeFile options as third argument to CliFileWriter.write, enabling psychic to provide custom flags when writing openapi.json files.
|
|
296
|
+
|
|
297
|
+
## 1.1.0
|
|
298
|
+
|
|
299
|
+
- Remove support for preloadThroughColumns. They were broken, fixing them would be overly complex, and the same effect can be obtained using flatten on a serializer rendersOne
|
|
300
|
+
|
|
301
|
+
## 1.0.6
|
|
302
|
+
|
|
303
|
+
- Fix joining after a through a polymorphic BelongsTo
|
|
304
|
+
association.
|
|
305
|
+
|
|
306
|
+
- Improve join implementation
|
|
307
|
+
|
|
308
|
+
- Disable leftJoinPreload preloadThroughColumns since it doesn't actually work on through associations that resolve to a source that doesn't match the association name (and we were unnecessarily including columns in the leftJoinPreload statement even when there was no `preloadThroughColumns`, thereby bloating the queries unnecessarily)
|
|
309
|
+
|
|
310
|
+
## 1.0.5
|
|
311
|
+
|
|
312
|
+
- Support HasOne/Many through polymorphic BelongsTo (trick is that it uses the associated model from the HasOne/Many to limit the BelongsTo to a single associated class / table)
|
|
313
|
+
|
|
314
|
+
- Fix HasOne/Many through source type
|
|
315
|
+
|
|
316
|
+
- sync process is now fail-safe, leveraging a utility which caches old copies of files before writing to them. If an exception is thrown at any point during the process, dream will revert all files written using the new `CliFileWriter` class
|
|
317
|
+
|
|
318
|
+
## 1.0.4
|
|
319
|
+
|
|
320
|
+
- properly exclude type from `DreamParamSafeColumnNames`
|
|
321
|
+
|
|
322
|
+
## 1.0.3
|
|
323
|
+
|
|
324
|
+
- exclude type from `DreamParamSafeColumnNames`
|
|
325
|
+
|
|
326
|
+
## 1.0.2
|
|
327
|
+
|
|
328
|
+
- stop computing foreign keys in schema builder when building schema for through associations
|
|
329
|
+
|
|
330
|
+
## 1.0.1
|
|
331
|
+
|
|
332
|
+
- [bug] fix preloading STI model via polymporhic association (polymorphic type was being altered to the STI child rather than left as the STI base)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import DreamCLI from '../cli/index.js';
|
|
2
2
|
import DreamApp from '../dream-app/index.js';
|
|
3
3
|
import Query from '../dream/Query.js';
|
|
4
|
+
import DBClassDeprecation from '../helpers/cli/DBClassDeprecation.js';
|
|
4
5
|
import generateDream from '../helpers/cli/generateDream.js';
|
|
5
6
|
import sspawn from '../helpers/sspawn.js';
|
|
6
7
|
export default class DreamBin {
|
|
@@ -9,6 +10,7 @@ export default class DreamBin {
|
|
|
9
10
|
for (const connectionName of Object.keys(dreamApp.dbCredentials)) {
|
|
10
11
|
await Query.dbDriverClass(connectionName).sync(connectionName, onSync, options);
|
|
11
12
|
}
|
|
13
|
+
await new DBClassDeprecation().deprecate();
|
|
12
14
|
}
|
|
13
15
|
static async dbCreate() {
|
|
14
16
|
const dreamApp = DreamApp.getOrFail();
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import * as fs from 'node:fs/promises';
|
|
2
1
|
import * as path from 'node:path';
|
|
3
2
|
import { CliFileWriter } from '../../cli/CliFileWriter.js';
|
|
4
3
|
import DreamCLI from '../../cli/index.js';
|
|
5
4
|
import colorize from '../../cli/logger/loggable/colorize.js';
|
|
6
5
|
import DreamApp from '../../dream-app/index.js';
|
|
7
|
-
import
|
|
8
|
-
import compact from '../../helpers/compact.js';
|
|
9
|
-
import EnvInternal from '../../helpers/EnvInternal.js';
|
|
6
|
+
import ASTKyselyCodegenEnhancer from '../../helpers/cli/ASTKyselyCodegenEnhancer.js';
|
|
10
7
|
import dreamPath from '../../helpers/path/dreamPath.js';
|
|
11
|
-
import snakeify from '../../helpers/snakeify.js';
|
|
12
8
|
import sspawn from '../../helpers/sspawn.js';
|
|
13
9
|
import dbTypesFilenameForConnection from './dbTypesFilenameForConnection.js';
|
|
14
10
|
export default async function syncDbTypesFiles(connectionName) {
|
|
@@ -26,88 +22,5 @@ export default async function syncDbTypesFiles(connectionName) {
|
|
|
26
22
|
});
|
|
27
23
|
},
|
|
28
24
|
});
|
|
29
|
-
|
|
30
|
-
// from the dist folder, whereas dirname here is pointing to true src folder.
|
|
31
|
-
const file = (await fs.readFile(absoluteDbSyncPath)).toString();
|
|
32
|
-
const enhancedSchema = enhanceSchema(file);
|
|
33
|
-
await CliFileWriter.write(absoluteDbSyncPath, enhancedSchema);
|
|
34
|
-
}
|
|
35
|
-
// begin: schema helpers
|
|
36
|
-
function enhanceSchema(file) {
|
|
37
|
-
file = removeUnwantedExports(file);
|
|
38
|
-
file = replaceInt8Type(file);
|
|
39
|
-
file = replaceJsonType(file);
|
|
40
|
-
const interfaces = file.split(/export interface /g);
|
|
41
|
-
const results = interfaces.slice(1, interfaces.length);
|
|
42
|
-
const dbInterface = results.find(str => /^DB \{/.test(str));
|
|
43
|
-
const camelDbInterface = camelcasify(dbInterface);
|
|
44
|
-
file = camelcasify(file);
|
|
45
|
-
file = file.replace(camelDbInterface, dbInterface);
|
|
46
|
-
file = addCustomImports(file);
|
|
47
|
-
const transformedNames = compact(results.map(result => transformName(result)));
|
|
48
|
-
const fileWithCoercedTypes = exportedEnumTypesToExportedTypeValues(file);
|
|
49
|
-
// BEGIN FILE CONTENTS BUILDING
|
|
50
|
-
const newFileContents = `${fileWithCoercedTypes}
|
|
51
|
-
|
|
52
|
-
export class DBClass {
|
|
53
|
-
${transformedNames
|
|
54
|
-
.map(name => `${snakeify(name)}: ${name}`)
|
|
55
|
-
.sort()
|
|
56
|
-
.join('\n ')}
|
|
57
|
-
}
|
|
58
|
-
`;
|
|
59
|
-
const sortedFileContents = alphaSortInterfaceProperties(newFileContents);
|
|
60
|
-
return sortedFileContents;
|
|
61
|
-
}
|
|
62
|
-
function removeUnwantedExports(file) {
|
|
63
|
-
return file.replace(/\nexport type Timestamp = ColumnType<.*/, `export type Timestamp = ColumnType<DateTime | CalendarDate>`);
|
|
64
|
-
}
|
|
65
|
-
function addCustomImports(file) {
|
|
66
|
-
const customImports = EnvInternal.boolean('DREAM_CORE_DEVELOPMENT')
|
|
67
|
-
? "import type CalendarDate from '../../src/helpers/CalendarDate.js'\nimport { type DateTime } from '../../src/helpers/DateTime.js'"
|
|
68
|
-
: "import { type CalendarDate, type DateTime } from '@rvoh/dream'";
|
|
69
|
-
return `${autogeneratedFileDisclaimer()}${customImports}
|
|
70
|
-
${file}`;
|
|
71
|
-
}
|
|
72
|
-
function replaceInt8Type(str) {
|
|
73
|
-
return str.replace('export type Int8 = ColumnType<string, bigint | number | string>', 'export type Int8 = ColumnType<string, bigint | number | string, bigint | number | string>');
|
|
74
|
-
}
|
|
75
|
-
function replaceJsonType(str) {
|
|
76
|
-
return str.replace('export type Json = ColumnType<JsonValue, string, string>', 'export type Json = ColumnType<JsonValue, string | JsonValue, string | JsonValue>');
|
|
77
|
-
}
|
|
78
|
-
function camelcasify(str) {
|
|
79
|
-
return _camelcasify(str);
|
|
80
|
-
}
|
|
81
|
-
function _camelcasify(str) {
|
|
82
|
-
const camelString = str.replace(/([( .])([a-z][a-zA-Z0-9]*)_([a-z0-9])([a-z0-9]*)/g, (match, p1, p2, p3, p4) => `${p1}${p2}${p3.toUpperCase()}${p4}`);
|
|
83
|
-
return camelString === str ? camelString : _camelcasify(camelString);
|
|
84
|
-
}
|
|
85
|
-
function alphaSortInterfaceProperties(str) {
|
|
86
|
-
return str.replace(/(export interface [^\n{]+){\n([^}]+)\n}/g, (_match, interfaceDeclaration, lines) => {
|
|
87
|
-
const props = lines.split(/\n/);
|
|
88
|
-
return `${interfaceDeclaration}{
|
|
89
|
-
${props.sort().join('\n')}
|
|
90
|
-
}`;
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
function exportedEnumTypesToExportedTypeValues(str) {
|
|
94
|
-
const ommitedTypes = ['Generated<T>', 'Json', 'JsonArray', 'JsonObject', 'JsonPrimitive', 'JsonValue'];
|
|
95
|
-
return str.replace(/export type ([^=]*) = ((?!ColumnType)[^;\n]*);/g, (_match, typeDeclaration, types) => {
|
|
96
|
-
const originalType = `export type ${typeDeclaration} = ${types};`;
|
|
97
|
-
if (ommitedTypes.some(type => type === typeDeclaration)) {
|
|
98
|
-
return originalType;
|
|
99
|
-
}
|
|
100
|
-
return `\
|
|
101
|
-
${originalType}
|
|
102
|
-
export const ${typeDeclaration}Values = [
|
|
103
|
-
${types.split(' | ').join(',\n ')}
|
|
104
|
-
] as const
|
|
105
|
-
`;
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
function transformName(str) {
|
|
109
|
-
const name = str.split(' {')[0]?.replace(/\s/g, '');
|
|
110
|
-
if (name === undefined || name === 'DB')
|
|
111
|
-
return null;
|
|
112
|
-
return name;
|
|
25
|
+
await new ASTKyselyCodegenEnhancer(connectionName).enhance();
|
|
113
26
|
}
|
|
@@ -90,7 +90,7 @@ export default class QueryDriverBase {
|
|
|
90
90
|
* this file is extremely complex and messy, and will be difficult
|
|
91
91
|
* to achieve.
|
|
92
92
|
* 2. generate a types/dream.ts file in the same shape as the existing
|
|
93
|
-
* one. This is normally done using
|
|
93
|
+
* one. This is normally done using the ASTSchemaBuilder
|
|
94
94
|
* but this will likely need to be overridden to tailor to your custom
|
|
95
95
|
* database engine.
|
|
96
96
|
*/
|
|
@@ -172,7 +172,7 @@ export default class QueryDriverBase {
|
|
|
172
172
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
173
173
|
tableName,
|
|
174
174
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
175
|
-
|
|
175
|
+
allTableAssociationData) {
|
|
176
176
|
throw new Error('implement getColumnData in child class');
|
|
177
177
|
}
|
|
178
178
|
static serializeDbType(type, val) {
|
|
@@ -34,8 +34,9 @@ import NotNullViolation from '../../errors/db/NotNullViolation.js';
|
|
|
34
34
|
import UnexpectedUndefined from '../../errors/UnexpectedUndefined.js';
|
|
35
35
|
import CalendarDate from '../../helpers/CalendarDate.js';
|
|
36
36
|
import camelize from '../../helpers/camelize.js';
|
|
37
|
+
import ASTGlobalSchemaBuilder from '../../helpers/cli/ASTGlobalSchemaBuilder.js';
|
|
38
|
+
import ASTSchemaBuilder from '../../helpers/cli/ASTSchemaBuilder.js';
|
|
37
39
|
import generateMigration from '../../helpers/cli/generateMigration.js';
|
|
38
|
-
import SchemaBuilder from '../../helpers/cli/SchemaBuilder.js';
|
|
39
40
|
import compact from '../../helpers/compact.js';
|
|
40
41
|
import { DateTime } from '../../helpers/DateTime.js';
|
|
41
42
|
import EnvInternal from '../../helpers/EnvInternal.js';
|
|
@@ -158,31 +159,20 @@ export default class KyselyQueryDriver extends QueryDriverBase {
|
|
|
158
159
|
/**
|
|
159
160
|
* defines the syncing behavior for dream and psychic,
|
|
160
161
|
* which is run whenever the `sync` command is called.
|
|
161
|
-
*
|
|
162
|
-
* comlpex to override. You will need to do the following
|
|
163
|
-
* when overriding this method:
|
|
164
|
-
*
|
|
165
|
-
* 1. introspect the db and use it to generate a db.ts file in the
|
|
166
|
-
* same shape as the existing one. Currently, the process for generating
|
|
167
|
-
* this file is extremely complex and messy, and will be difficult
|
|
168
|
-
* to achieve.
|
|
169
|
-
* 2. generate a types/dream.ts file in the same shape as the existing
|
|
170
|
-
* one. This is normally done using `await new SchemaBuilder().build()`,
|
|
171
|
-
* but this will likely need to be overridden to tailor to your custom
|
|
172
|
-
* database engine.
|
|
173
|
-
*/
|
|
162
|
+
* */
|
|
174
163
|
static async sync(connectionName, onSync, options = {}) {
|
|
175
164
|
try {
|
|
176
165
|
if (!options?.schemaOnly) {
|
|
177
166
|
await DreamCLI.logger.logProgress(`introspecting db for connection: ${connectionName}...`, async () => {
|
|
167
|
+
// this calls kysely-codegen under the hood
|
|
178
168
|
await syncDbTypesFiles(connectionName);
|
|
179
169
|
});
|
|
180
170
|
}
|
|
181
|
-
const
|
|
171
|
+
const newSchemaBuilder = new ASTSchemaBuilder(connectionName);
|
|
182
172
|
await DreamCLI.logger.logProgress(`building dream schema for connection ${connectionName}...`, async () => {
|
|
183
|
-
await
|
|
173
|
+
await newSchemaBuilder.build();
|
|
184
174
|
});
|
|
185
|
-
if (
|
|
175
|
+
if (newSchemaBuilder.hasForeignKeyError && !options?.schemaOnly) {
|
|
186
176
|
await DreamCLI.logger.logProgress('triggering resync to correct for foreign key errors...', async () => {
|
|
187
177
|
// TODO: make this customizable to enable dream apps to separate
|
|
188
178
|
const cliCmd = EnvInternal.boolean('DREAM_CORE_DEVELOPMENT') ? 'dream' : 'psy';
|
|
@@ -196,7 +186,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
|
|
|
196
186
|
});
|
|
197
187
|
});
|
|
198
188
|
}
|
|
199
|
-
await
|
|
189
|
+
await new ASTGlobalSchemaBuilder().build();
|
|
200
190
|
if (!options?.schemaOnly) {
|
|
201
191
|
// intentionally leaving logs off here, since it allows other
|
|
202
192
|
// onSync handlers to determine their own independent logging approach
|
|
@@ -205,7 +195,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
|
|
|
205
195
|
}
|
|
206
196
|
catch (error) {
|
|
207
197
|
console.error(error);
|
|
208
|
-
await DreamCLI.logger.logProgress('sync failed, reverting file contents...', async () => {
|
|
198
|
+
await DreamCLI.logger.logProgress('[dream] sync failed, reverting file contents...', async () => {
|
|
209
199
|
await CliFileWriter.revert();
|
|
210
200
|
});
|
|
211
201
|
}
|
|
@@ -111,7 +111,7 @@ export default class PostgresQueryDriver extends KyselyQueryDriver {
|
|
|
111
111
|
* this is used by the SchemaBuilder to store column data permanently
|
|
112
112
|
* within the types/dream.ts file.
|
|
113
113
|
*/
|
|
114
|
-
static async getColumnData(connectionName, tableName,
|
|
114
|
+
static async getColumnData(connectionName, tableName, allTableAssociationData) {
|
|
115
115
|
const db = this.dbFor(connectionName, 'primary');
|
|
116
116
|
const sqlQuery = sql `SELECT column_name, udt_name::regtype, is_nullable, data_type FROM information_schema.columns WHERE table_name = ${tableName}`;
|
|
117
117
|
const columnToDBTypeMap = await sqlQuery.execute(db);
|
|
@@ -120,7 +120,7 @@ export default class PostgresQueryDriver extends KyselyQueryDriver {
|
|
|
120
120
|
rows.forEach(row => {
|
|
121
121
|
const isEnum = ['USER-DEFINED', 'ARRAY'].includes(row.dataType) && !isPrimitiveDataType(row.udtName);
|
|
122
122
|
const isArray = ['ARRAY'].includes(row.dataType);
|
|
123
|
-
const associationMetadata =
|
|
123
|
+
const associationMetadata = allTableAssociationData[row.columnName];
|
|
124
124
|
columnData[camelize(row.columnName)] = {
|
|
125
125
|
dbType: row.udtName,
|
|
126
126
|
allowNull: row.isNullable === 'YES',
|
|
@@ -6,6 +6,7 @@ import Encrypt from '../encrypt/index.js';
|
|
|
6
6
|
import DreamAppInitMissingCallToLoadModels from '../errors/dream-app/DreamAppInitMissingCallToLoadModels.js';
|
|
7
7
|
import DreamAppInitMissingMissingProjectRoot from '../errors/dream-app/DreamAppInitMissingMissingProjectRoot.js';
|
|
8
8
|
import CalendarDate from '../helpers/CalendarDate.js';
|
|
9
|
+
import autogeneratedFileDisclaimer from '../helpers/cli/autoGeneratedFileDisclaimer.js';
|
|
9
10
|
import { DateTime, Settings } from '../helpers/DateTime.js';
|
|
10
11
|
import EnvInternal from '../helpers/EnvInternal.js';
|
|
11
12
|
import globalClassNameFromFullyQualifiedModelName from '../helpers/globalClassNameFromFullyQualifiedModelName.js';
|
|
@@ -92,6 +93,7 @@ export default class DreamApp {
|
|
|
92
93
|
inferSerializersFromDreamClassOrViewModelClass,
|
|
93
94
|
isDreamSerializer,
|
|
94
95
|
serializerNameFromFullyQualifiedModelName,
|
|
96
|
+
autogeneratedFileDisclaimer,
|
|
95
97
|
};
|
|
96
98
|
}
|
|
97
99
|
/**
|
|
@@ -233,6 +235,16 @@ Try setting it to something valid, like:
|
|
|
233
235
|
get importExtension() {
|
|
234
236
|
return this._importExtension;
|
|
235
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* if set to true, it will bypass deprecation checks that run
|
|
240
|
+
* during the sync hook. Defaults to false, we only recommend
|
|
241
|
+
* overriding this if you are having issues with the deprecation
|
|
242
|
+
* check.
|
|
243
|
+
*/
|
|
244
|
+
_bypassDeprecationChecks = false;
|
|
245
|
+
get bypassDeprecationChecks() {
|
|
246
|
+
return this._bypassDeprecationChecks;
|
|
247
|
+
}
|
|
236
248
|
loadedModels = false;
|
|
237
249
|
constructor(opts) {
|
|
238
250
|
if (opts?.db)
|
|
@@ -317,6 +329,9 @@ Try setting it to something valid, like:
|
|
|
317
329
|
}
|
|
318
330
|
set(applyOption, options, secondaryOptions) {
|
|
319
331
|
switch (applyOption) {
|
|
332
|
+
case 'bypassDeprecationChecks':
|
|
333
|
+
this._bypassDeprecationChecks = options;
|
|
334
|
+
break;
|
|
320
335
|
case 'db':
|
|
321
336
|
if (typeof options === 'string') {
|
|
322
337
|
this._dbCredentials[options] = secondaryOptions;
|